@legendapp/spark 0.0.1-next.10

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 (933) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +27 -0
  3. package/ai-codex.ts +1 -0
  4. package/ai.ts +1 -0
  5. package/app-documents.ts +1 -0
  6. package/app.ts +1 -0
  7. package/audio.ts +1 -0
  8. package/auth-session.ts +1 -0
  9. package/bin/spark.cjs +5 -0
  10. package/camera.ts +13 -0
  11. package/clipboard.ts +1 -0
  12. package/config-plugin.cjs +1 -0
  13. package/config-plugin.d.cts +2 -0
  14. package/config.cjs +1 -0
  15. package/config.d.cts +1 -0
  16. package/context-menu.ts +1 -0
  17. package/contracts.ts +2 -0
  18. package/customize.ts +2 -0
  19. package/diagnostics.ts +1 -0
  20. package/dialogs.ts +2 -0
  21. package/drag-drop.ts +1 -0
  22. package/expo-config.cjs +1 -0
  23. package/expo-config.d.cts +1 -0
  24. package/files.ts +1 -0
  25. package/global-shortcuts.ts +1 -0
  26. package/html.ts +1 -0
  27. package/init-template.cjs +2 -0
  28. package/links.ts +1 -0
  29. package/markdown.ts +1 -0
  30. package/menus.ts +1 -0
  31. package/metro-gate.cjs +1 -0
  32. package/metro.cjs +4 -0
  33. package/metro.d.cts +12 -0
  34. package/native.cjs +3 -0
  35. package/native.d.cts +6 -0
  36. package/notifications.ts +1 -0
  37. package/package.json +248 -0
  38. package/patches/camera/react-native-nitro-image.patch +320 -0
  39. package/patches/camera/react-native-nitro-modules.patch +50 -0
  40. package/patches/camera/react-native-vision-camera.patch +2662 -0
  41. package/patches/camera/upstream.json +22 -0
  42. package/patches/dependencies.json +14 -0
  43. package/patches/react-native-enriched-html@1.1.1.patch +854 -0
  44. package/patches/react-native-enriched-markdown@1.1.1.patch +7751 -0
  45. package/postinstall.cjs +1 -0
  46. package/processes.ts +1 -0
  47. package/runtime-entry.cjs +1 -0
  48. package/schema.json +636 -0
  49. package/secure-storage.ts +1 -0
  50. package/settings-observable.ts +1 -0
  51. package/settings-window.ts +1 -0
  52. package/settings.ts +1 -0
  53. package/shortcuts-commands.ts +1 -0
  54. package/shortcuts-keyboard.ts +3 -0
  55. package/shortcuts.ts +1 -0
  56. package/skills/spark/SKILL.md +56 -0
  57. package/skills/spark/UPGRADING.md +322 -0
  58. package/sqlite.ts +1 -0
  59. package/system.ts +1 -0
  60. package/tray.ts +1 -0
  61. package/ui-classnames.ts +1 -0
  62. package/ui-glass.ts +1 -0
  63. package/ui-search.ts +1 -0
  64. package/ui-sidebar.ts +1 -0
  65. package/ui-split-view.ts +1 -0
  66. package/ui-swipe.ts +1 -0
  67. package/ui-symbol.ts +1 -0
  68. package/ui-uniwind.ts +1 -0
  69. package/ui.ts +1 -0
  70. package/updates.ts +1 -0
  71. package/vendor/node_modules/@legendapp/spark-ai/package.json +19 -0
  72. package/vendor/node_modules/@legendapp/spark-ai/src/availability.ts +17 -0
  73. package/vendor/node_modules/@legendapp/spark-ai/src/index.ts +15 -0
  74. package/vendor/node_modules/@legendapp/spark-ai/src/invocation-command.cjs +11 -0
  75. package/vendor/node_modules/@legendapp/spark-ai/src/invocation-command.d.cts +2 -0
  76. package/vendor/node_modules/@legendapp/spark-ai/src/invocations.ts +17 -0
  77. package/vendor/node_modules/@legendapp/spark-ai/src/output.ts +62 -0
  78. package/vendor/node_modules/@legendapp/spark-ai/src/run.ts +12 -0
  79. package/vendor/node_modules/@legendapp/spark-ai/src/types.ts +16 -0
  80. package/vendor/node_modules/@legendapp/spark-audio/RNSparkAudio.podspec +18 -0
  81. package/vendor/node_modules/@legendapp/spark-audio/macos/RNSparkAudio.h +5 -0
  82. package/vendor/node_modules/@legendapp/spark-audio/macos/RNSparkAudio.mm +256 -0
  83. package/vendor/node_modules/@legendapp/spark-audio/package.json +52 -0
  84. package/vendor/node_modules/@legendapp/spark-audio/src/NativeSparkAudio.ts +7 -0
  85. package/vendor/node_modules/@legendapp/spark-audio/src/desktop.ts +43 -0
  86. package/vendor/node_modules/@legendapp/spark-audio/src/events.ts +11 -0
  87. package/vendor/node_modules/@legendapp/spark-audio/src/hooks.ts +65 -0
  88. package/vendor/node_modules/@legendapp/spark-audio/src/index.android.ts +1 -0
  89. package/vendor/node_modules/@legendapp/spark-audio/src/index.ios.ts +1 -0
  90. package/vendor/node_modules/@legendapp/spark-audio/src/index.ts +1 -0
  91. package/vendor/node_modules/@legendapp/spark-audio/src/index.web.ts +101 -0
  92. package/vendor/node_modules/@legendapp/spark-audio/src/index.windows.ts +1 -0
  93. package/vendor/node_modules/@legendapp/spark-audio/src/media-session-unavailable.ts +7 -0
  94. package/vendor/node_modules/@legendapp/spark-audio/src/media-session.ts +58 -0
  95. package/vendor/node_modules/@legendapp/spark-audio/src/media-session.web.ts +43 -0
  96. package/vendor/node_modules/@legendapp/spark-audio/src/media-types.ts +59 -0
  97. package/vendor/node_modules/@legendapp/spark-audio/src/mobile.ts +46 -0
  98. package/vendor/node_modules/@legendapp/spark-audio/src/player.ts +97 -0
  99. package/vendor/node_modules/@legendapp/spark-audio/src/status-listeners.ts +28 -0
  100. package/vendor/node_modules/@legendapp/spark-audio/src/types.ts +26 -0
  101. package/vendor/node_modules/@legendapp/spark-audio/windows/ExperimentalFeatures.props +33 -0
  102. package/vendor/node_modules/@legendapp/spark-audio/windows/LICENSE +25 -0
  103. package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/ReactPackageProvider.cpp +20 -0
  104. package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/ReactPackageProvider.h +24 -0
  105. package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/ReactPackageProvider.idl +9 -0
  106. package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/SparkAudio.cpp +2 -0
  107. package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/SparkAudio.def +3 -0
  108. package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/SparkAudio.h +193 -0
  109. package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/SparkAudio.rc +0 -0
  110. package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/SparkAudio.vcxproj +143 -0
  111. package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/SparkAudio.vcxproj.filters +44 -0
  112. package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/pch.cpp +1 -0
  113. package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/pch.h +30 -0
  114. package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/resource.h +5 -0
  115. package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/targetver.h +8 -0
  116. package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio.sln +43 -0
  117. package/vendor/node_modules/@legendapp/spark-auth-session/package.json +42 -0
  118. package/vendor/node_modules/@legendapp/spark-auth-session/src/core.ts +86 -0
  119. package/vendor/node_modules/@legendapp/spark-auth-session/src/index.android.ts +1 -0
  120. package/vendor/node_modules/@legendapp/spark-auth-session/src/index.ios.ts +1 -0
  121. package/vendor/node_modules/@legendapp/spark-auth-session/src/index.ts +38 -0
  122. package/vendor/node_modules/@legendapp/spark-auth-session/src/index.web.ts +1 -0
  123. package/vendor/node_modules/@legendapp/spark-auth-session/src/mobile.ts +108 -0
  124. package/vendor/node_modules/@legendapp/spark-auth-session/src/types.ts +49 -0
  125. package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +207 -0
  126. package/vendor/node_modules/@legendapp/spark-cli/dist/build-mode.js +7 -0
  127. package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +379 -0
  128. package/vendor/node_modules/@legendapp/spark-cli/dist/cli-arguments.js +61 -0
  129. package/vendor/node_modules/@legendapp/spark-cli/dist/commands.js +113 -0
  130. package/vendor/node_modules/@legendapp/spark-cli/dist/create.js +160 -0
  131. package/vendor/node_modules/@legendapp/spark-cli/dist/credentials.js +130 -0
  132. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-ai.cjs +108 -0
  133. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-artifacts.js +315 -0
  134. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-cli.cjs +75 -0
  135. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-github.cjs +133 -0
  136. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-policy.cjs +102 -0
  137. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-provider.cjs +2 -0
  138. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-worker.cjs +273 -0
  139. package/vendor/node_modules/@legendapp/spark-cli/dist/dependency-pins.js +157 -0
  140. package/vendor/node_modules/@legendapp/spark-cli/dist/dev-command.js +92 -0
  141. package/vendor/node_modules/@legendapp/spark-cli/dist/dev.js +415 -0
  142. package/vendor/node_modules/@legendapp/spark-cli/dist/enriched-html-pins.js +128 -0
  143. package/vendor/node_modules/@legendapp/spark-cli/dist/errors.js +100 -0
  144. package/vendor/node_modules/@legendapp/spark-cli/dist/examples.js +43 -0
  145. package/vendor/node_modules/@legendapp/spark-cli/dist/executable.js +19 -0
  146. package/vendor/node_modules/@legendapp/spark-cli/dist/expo-dev-extension.cjs +51 -0
  147. package/vendor/node_modules/@legendapp/spark-cli/dist/expo-dev-patch.cjs +69 -0
  148. package/vendor/node_modules/@legendapp/spark-cli/dist/expo-dev-preload.cjs +19 -0
  149. package/vendor/node_modules/@legendapp/spark-cli/dist/expo-metro.cjs +41 -0
  150. package/vendor/node_modules/@legendapp/spark-cli/dist/expo-native.cjs +14 -0
  151. package/vendor/node_modules/@legendapp/spark-cli/dist/expo-node.js +21 -0
  152. package/vendor/node_modules/@legendapp/spark-cli/dist/go-profile.js +20 -0
  153. package/vendor/node_modules/@legendapp/spark-cli/dist/helpers.js +79 -0
  154. package/vendor/node_modules/@legendapp/spark-cli/dist/index.js +280 -0
  155. package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.cjs +26 -0
  156. package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.d.cts +1 -0
  157. package/vendor/node_modules/@legendapp/spark-cli/dist/js-runtime.cjs +96 -0
  158. package/vendor/node_modules/@legendapp/spark-cli/dist/json.js +16 -0
  159. package/vendor/node_modules/@legendapp/spark-cli/dist/local.js +124 -0
  160. package/vendor/node_modules/@legendapp/spark-cli/dist/macos-release.js +11 -0
  161. package/vendor/node_modules/@legendapp/spark-cli/dist/metro-gate.cjs +33 -0
  162. package/vendor/node_modules/@legendapp/spark-cli/dist/metro.cjs +84 -0
  163. package/vendor/node_modules/@legendapp/spark-cli/dist/metro.js +25 -0
  164. package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.cjs +152 -0
  165. package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.d.cts +15 -0
  166. package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.cjs +184 -0
  167. package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.d.cts +16 -0
  168. package/vendor/node_modules/@legendapp/spark-cli/dist/native-metadata.js +26 -0
  169. package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +88 -0
  170. package/vendor/node_modules/@legendapp/spark-cli/dist/native-preparation.js +88 -0
  171. package/vendor/node_modules/@legendapp/spark-cli/dist/notary-profiles.js +75 -0
  172. package/vendor/node_modules/@legendapp/spark-cli/dist/npm-bin/npm +6 -0
  173. package/vendor/node_modules/@legendapp/spark-cli/dist/npm-bin/npm.cmd +1 -0
  174. package/vendor/node_modules/@legendapp/spark-cli/dist/pack-archive.js +23 -0
  175. package/vendor/node_modules/@legendapp/spark-cli/dist/package-manager-config.js +43 -0
  176. package/vendor/node_modules/@legendapp/spark-cli/dist/package-manager.js +58 -0
  177. package/vendor/node_modules/@legendapp/spark-cli/dist/package.js +201 -0
  178. package/vendor/node_modules/@legendapp/spark-cli/dist/platform.js +48 -0
  179. package/vendor/node_modules/@legendapp/spark-cli/dist/process.js +64 -0
  180. package/vendor/node_modules/@legendapp/spark-cli/dist/project-version.js +12 -0
  181. package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +419 -0
  182. package/vendor/node_modules/@legendapp/spark-cli/dist/release-driver.js +35 -0
  183. package/vendor/node_modules/@legendapp/spark-cli/dist/release.js +123 -0
  184. package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +42 -0
  185. package/vendor/node_modules/@legendapp/spark-cli/dist/runner-install.js +254 -0
  186. package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-bootstrap.ps1 +87 -0
  187. package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-bootstrap.sh +107 -0
  188. package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-downloads.tsv +13 -0
  189. package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-entry.cjs +1 -0
  190. package/vendor/node_modules/@legendapp/spark-cli/dist/sdk-install.js +71 -0
  191. package/vendor/node_modules/@legendapp/spark-cli/dist/sdk-transfer.js +113 -0
  192. package/vendor/node_modules/@legendapp/spark-cli/dist/session-status.js +26 -0
  193. package/vendor/node_modules/@legendapp/spark-cli/dist/signing.js +176 -0
  194. package/vendor/node_modules/@legendapp/spark-cli/dist/universal.cjs +29 -0
  195. package/vendor/node_modules/@legendapp/spark-cli/dist/updates.js +157 -0
  196. package/vendor/node_modules/@legendapp/spark-cli/dist/upgrade.js +102 -0
  197. package/vendor/node_modules/@legendapp/spark-cli/dist/windows-associations.js +45 -0
  198. package/vendor/node_modules/@legendapp/spark-cli/dist/windows-associations.ps1 +57 -0
  199. package/vendor/node_modules/@legendapp/spark-cli/dist/windows-geometry.js +33 -0
  200. package/vendor/node_modules/@legendapp/spark-cli/dist/windows-metro.js +112 -0
  201. package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +137 -0
  202. package/vendor/node_modules/@legendapp/spark-cli/package.json +25 -0
  203. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/.claude/skills/spark/SKILL.md +9 -0
  204. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/AGENTS.md +4 -0
  205. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/App.tsx +23 -0
  206. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/CLAUDE.md +4 -0
  207. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/README.md +15 -0
  208. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/app.json +15 -0
  209. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/assets/icon.png +0 -0
  210. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/desktop.config.json +21 -0
  211. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/gitignore +9 -0
  212. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/index.ts +5 -0
  213. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/metro.config.js +3 -0
  214. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +102 -0
  215. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/tsconfig.json +10 -0
  216. package/vendor/node_modules/@legendapp/spark-cli/templates/diff-lite/App.tsx +34 -0
  217. package/vendor/node_modules/@legendapp/spark-cli/templates/diff-lite/Git.macos.tsx +13 -0
  218. package/vendor/node_modules/@legendapp/spark-cli/templates/diff-lite/Git.tsx +1 -0
  219. package/vendor/node_modules/@legendapp/spark-cli/templates/diff-lite/compare.ts +12 -0
  220. package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/App.tsx +34 -0
  221. package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/Integration.macos.tsx +59 -0
  222. package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/Integration.tsx +13 -0
  223. package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/Integration.web.tsx +14 -0
  224. package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/Integration.windows.tsx +59 -0
  225. package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/document.ts +58 -0
  226. package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/io.desktop.ts +27 -0
  227. package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/io.macos.ts +7 -0
  228. package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/io.ts +31 -0
  229. package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/io.web.ts +21 -0
  230. package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/io.windows.ts +1 -0
  231. package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/sessions.ts +8 -0
  232. package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/useDocument.ts +6 -0
  233. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/Lifecycle.desktop.tsx +25 -0
  234. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/Lifecycle.macos.tsx +1 -0
  235. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/Lifecycle.tsx +14 -0
  236. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/Lifecycle.web.tsx +20 -0
  237. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/Lifecycle.windows.tsx +1 -0
  238. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/OpenFiles.desktop.tsx +23 -0
  239. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/OpenFiles.macos.tsx +1 -0
  240. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/OpenFiles.tsx +2 -0
  241. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/OpenFiles.windows.tsx +1 -0
  242. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/document.ts +58 -0
  243. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/io.desktop.ts +27 -0
  244. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/io.macos.ts +7 -0
  245. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/io.ts +31 -0
  246. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/io.web.ts +21 -0
  247. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/io.windows.ts +1 -0
  248. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/lifecycle-types.ts +10 -0
  249. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/lifetime.ts +23 -0
  250. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/records.ts +51 -0
  251. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/storage.ts +6 -0
  252. package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/useModel.ts +6 -0
  253. package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/Activation.desktop.tsx +4 -0
  254. package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/Activation.macos.tsx +1 -0
  255. package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/Activation.tsx +1 -0
  256. package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/Activation.windows.tsx +1 -0
  257. package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/App.tsx +38 -0
  258. package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/assets.desktop.ts +7 -0
  259. package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/assets.macos.ts +1 -0
  260. package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/assets.ts +18 -0
  261. package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/assets.web.ts +37 -0
  262. package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/assets.windows.ts +1 -0
  263. package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/model.ts +91 -0
  264. package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/store.ts +10 -0
  265. package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Activation.desktop.tsx +5 -0
  266. package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Activation.macos.tsx +1 -0
  267. package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Activation.tsx +1 -0
  268. package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Activation.windows.tsx +1 -0
  269. package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/App.tsx +92 -0
  270. package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Desktop.desktop.ts +47 -0
  271. package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Desktop.macos.ts +1 -0
  272. package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Desktop.ts +7 -0
  273. package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Desktop.windows.ts +1 -0
  274. package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Theme.tsx +17 -0
  275. package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/model.ts +61 -0
  276. package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/search.ts +3 -0
  277. package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/session.ts +15 -0
  278. package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/store.ts +4 -0
  279. package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/window-session.ts +63 -0
  280. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/.claude/skills/spark/SKILL.md +9 -0
  281. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/AGENTS.md +4 -0
  282. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/App.tsx +57 -0
  283. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/CLAUDE.md +4 -0
  284. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/README.md +15 -0
  285. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/app.json +19 -0
  286. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/assets/icon.png +0 -0
  287. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/desktop.config.json +64 -0
  288. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/gitignore +11 -0
  289. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/global.css +31 -0
  290. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/index.ts +4 -0
  291. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/metro.config.js +7 -0
  292. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +116 -0
  293. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/react-native.config.js +2 -0
  294. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/tsconfig.json +10 -0
  295. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/uniwind-types.d.ts +10 -0
  296. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/.claude/skills/spark/SKILL.md +9 -0
  297. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/AGENTS.md +4 -0
  298. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/App.tsx +16 -0
  299. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/CLAUDE.md +4 -0
  300. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/README.md +15 -0
  301. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/app.json +15 -0
  302. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/assets/icon.png +0 -0
  303. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/desktop.config.json +10 -0
  304. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/gitignore +9 -0
  305. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/index.ts +3 -0
  306. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/metro.config.js +3 -0
  307. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +103 -0
  308. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/react-native.config.js +2 -0
  309. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/tsconfig.json +10 -0
  310. package/vendor/node_modules/@legendapp/spark-clipboard/RNDesktopClipboard.podspec +16 -0
  311. package/vendor/node_modules/@legendapp/spark-clipboard/macos/RNDesktopClipboard.h +4 -0
  312. package/vendor/node_modules/@legendapp/spark-clipboard/macos/RNDesktopClipboard.mm +81 -0
  313. package/vendor/node_modules/@legendapp/spark-clipboard/package.json +52 -0
  314. package/vendor/node_modules/@legendapp/spark-clipboard/react-native.config.js +6 -0
  315. package/vendor/node_modules/@legendapp/spark-clipboard/src/NativeDesktopClipboard.ts +6 -0
  316. package/vendor/node_modules/@legendapp/spark-clipboard/src/desktop.ts +63 -0
  317. package/vendor/node_modules/@legendapp/spark-clipboard/src/expo.ts +22 -0
  318. package/vendor/node_modules/@legendapp/spark-clipboard/src/formats.ts +1 -0
  319. package/vendor/node_modules/@legendapp/spark-clipboard/src/index.android.ts +1 -0
  320. package/vendor/node_modules/@legendapp/spark-clipboard/src/index.ios.ts +1 -0
  321. package/vendor/node_modules/@legendapp/spark-clipboard/src/index.ts +1 -0
  322. package/vendor/node_modules/@legendapp/spark-clipboard/src/index.web.ts +1 -0
  323. package/vendor/node_modules/@legendapp/spark-clipboard/src/index.windows.ts +1 -0
  324. package/vendor/node_modules/@legendapp/spark-clipboard/src/options.ts +8 -0
  325. package/vendor/node_modules/@legendapp/spark-clipboard/src/types.ts +10 -0
  326. package/vendor/node_modules/@legendapp/spark-clipboard/windows/ExperimentalFeatures.props +33 -0
  327. package/vendor/node_modules/@legendapp/spark-clipboard/windows/LICENSE +25 -0
  328. package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/ReactPackageProvider.cpp +20 -0
  329. package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/ReactPackageProvider.h +24 -0
  330. package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/ReactPackageProvider.idl +9 -0
  331. package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/SparkClipboard.cpp +2 -0
  332. package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/SparkClipboard.def +3 -0
  333. package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/SparkClipboard.h +142 -0
  334. package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/SparkClipboard.rc +0 -0
  335. package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/SparkClipboard.vcxproj +145 -0
  336. package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/SparkClipboard.vcxproj.filters +44 -0
  337. package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/pch.cpp +1 -0
  338. package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/pch.h +30 -0
  339. package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/resource.h +5 -0
  340. package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/targetver.h +8 -0
  341. package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard.sln +43 -0
  342. package/vendor/node_modules/@legendapp/spark-codex/RNCodex.podspec +22 -0
  343. package/vendor/node_modules/@legendapp/spark-codex/cpp/HybridCodexAppServer.hpp +23 -0
  344. package/vendor/node_modules/@legendapp/spark-codex/cpp/HybridCodexAppServer.mm +1541 -0
  345. package/vendor/node_modules/@legendapp/spark-codex/nitro.json +21 -0
  346. package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/.gitattributes +1 -0
  347. package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodex+autolinking.rb +62 -0
  348. package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodex-Swift-Cxx-Bridge.cpp +17 -0
  349. package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodex-Swift-Cxx-Bridge.hpp +27 -0
  350. package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodex-Swift-Cxx-Umbrella.hpp +38 -0
  351. package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodexAutolinking.mm +35 -0
  352. package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodexAutolinking.swift +16 -0
  353. package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/shared/c++/CodexAvailability.hpp +95 -0
  354. package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/shared/c++/CodexRunResult.hpp +99 -0
  355. package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/shared/c++/HybridCodexAppServerSpec.cpp +24 -0
  356. package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/shared/c++/HybridCodexAppServerSpec.hpp +71 -0
  357. package/vendor/node_modules/@legendapp/spark-codex/package.json +35 -0
  358. package/vendor/node_modules/@legendapp/spark-codex/react-native.config.js +11 -0
  359. package/vendor/node_modules/@legendapp/spark-codex/src/Codex.nitro.ts +30 -0
  360. package/vendor/node_modules/@legendapp/spark-codex/src/index.ts +65 -0
  361. package/vendor/node_modules/@legendapp/spark-codex/src/native.ts +6 -0
  362. package/vendor/node_modules/@legendapp/spark-commands/package.json +21 -0
  363. package/vendor/node_modules/@legendapp/spark-commands/src/bindings.ts +90 -0
  364. package/vendor/node_modules/@legendapp/spark-commands/src/index.tsx +400 -0
  365. package/vendor/node_modules/@legendapp/spark-commands/src/router.ts +138 -0
  366. package/vendor/node_modules/@legendapp/spark-commands/src/storage.ts +20 -0
  367. package/vendor/node_modules/@legendapp/spark-context-menu/RNContextMenu.podspec +16 -0
  368. package/vendor/node_modules/@legendapp/spark-context-menu/macos/RNContextMenu.h +9 -0
  369. package/vendor/node_modules/@legendapp/spark-context-menu/macos/RNContextMenu.mm +159 -0
  370. package/vendor/node_modules/@legendapp/spark-context-menu/package.json +47 -0
  371. package/vendor/node_modules/@legendapp/spark-context-menu/react-native.config.js +6 -0
  372. package/vendor/node_modules/@legendapp/spark-context-menu/src/NativeContextMenu.ts +8 -0
  373. package/vendor/node_modules/@legendapp/spark-context-menu/src/index.ts +29 -0
  374. package/vendor/node_modules/@legendapp/spark-context-menu/windows/ExperimentalFeatures.props +33 -0
  375. package/vendor/node_modules/@legendapp/spark-context-menu/windows/LICENSE +25 -0
  376. package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/ReactPackageProvider.cpp +20 -0
  377. package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/ReactPackageProvider.h +24 -0
  378. package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/ReactPackageProvider.idl +9 -0
  379. package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/SparkContextMenu.cpp +2 -0
  380. package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/SparkContextMenu.def +3 -0
  381. package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/SparkContextMenu.h +113 -0
  382. package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/SparkContextMenu.rc +0 -0
  383. package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/SparkContextMenu.vcxproj +143 -0
  384. package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/SparkContextMenu.vcxproj.filters +44 -0
  385. package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/pch.cpp +1 -0
  386. package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/pch.h +30 -0
  387. package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/resource.h +5 -0
  388. package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/targetver.h +8 -0
  389. package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu.sln +43 -0
  390. package/vendor/node_modules/@legendapp/spark-desktop-app/RNDesktopApp.podspec +27 -0
  391. package/vendor/node_modules/@legendapp/spark-desktop-app/cpp/SparkBinaryJSI.hpp +89 -0
  392. package/vendor/node_modules/@legendapp/spark-desktop-app/cpp/SparkBinaryWindows.hpp +22 -0
  393. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/RNDesktopApp.h +4 -0
  394. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/RNDesktopApp.mm +60 -0
  395. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkBinaryJSI.h +48 -0
  396. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.h +35 -0
  397. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +198 -0
  398. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktopError.h +20 -0
  399. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkInstance.h +27 -0
  400. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkInstance.mm +207 -0
  401. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkLifecycle.h +26 -0
  402. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkLifecycle.mm +49 -0
  403. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkQuitCoordinator.h +9 -0
  404. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkQuitCoordinator.mm +70 -0
  405. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.h +44 -0
  406. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.mm +349 -0
  407. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkWindow.mm +86 -0
  408. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/recent-documents/RNRecentDocumentController.mm +55 -0
  409. package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +41 -0
  410. package/vendor/node_modules/@legendapp/spark-desktop-app/react-native.config.js +6 -0
  411. package/vendor/node_modules/@legendapp/spark-desktop-app/src/NativeDesktopApp.ts +8 -0
  412. package/vendor/node_modules/@legendapp/spark-desktop-app/src/api.ts +121 -0
  413. package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/accelerator.ts +40 -0
  414. package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/index.ts +56 -0
  415. package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/menu.ts +130 -0
  416. package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/native-buffer.ts +22 -0
  417. package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/path.ts +24 -0
  418. package/vendor/node_modules/@legendapp/spark-desktop-app/src/customize-hooks.ts +17 -0
  419. package/vendor/node_modules/@legendapp/spark-desktop-app/src/customize.ts +117 -0
  420. package/vendor/node_modules/@legendapp/spark-desktop-app/src/events.ts +75 -0
  421. package/vendor/node_modules/@legendapp/spark-desktop-app/src/index.ts +3 -0
  422. package/vendor/node_modules/@legendapp/spark-desktop-app/src/index.windows.ts +3 -0
  423. package/vendor/node_modules/@legendapp/spark-desktop-app/src/open-requests.ts +43 -0
  424. package/vendor/node_modules/@legendapp/spark-desktop-app/src/restoration.ts +11 -0
  425. package/vendor/node_modules/@legendapp/spark-desktop-app/src/transport.ts +10 -0
  426. package/vendor/node_modules/@legendapp/spark-desktop-config/accessibility-state.cjs +50 -0
  427. package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.cjs +107 -0
  428. package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.d.cts +3 -0
  429. package/vendor/node_modules/@legendapp/spark-desktop-config/autolinking.cjs +42 -0
  430. package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +177 -0
  431. package/vendor/node_modules/@legendapp/spark-desktop-config/config.d.cts +113 -0
  432. package/vendor/node_modules/@legendapp/spark-desktop-config/customize-provider.cjs +16 -0
  433. package/vendor/node_modules/@legendapp/spark-desktop-config/customize.cjs +16 -0
  434. package/vendor/node_modules/@legendapp/spark-desktop-config/entitlements.cjs +23 -0
  435. package/vendor/node_modules/@legendapp/spark-desktop-config/expo.cjs +27 -0
  436. package/vendor/node_modules/@legendapp/spark-desktop-config/expo.d.cts +3 -0
  437. package/vendor/node_modules/@legendapp/spark-desktop-config/fabric-lifecycle.cjs +125 -0
  438. package/vendor/node_modules/@legendapp/spark-desktop-config/helpers.cjs +20 -0
  439. package/vendor/node_modules/@legendapp/spark-desktop-config/identity.cjs +29 -0
  440. package/vendor/node_modules/@legendapp/spark-desktop-config/keyboard-events.cjs +44 -0
  441. package/vendor/node_modules/@legendapp/spark-desktop-config/lifecycle.cjs +20 -0
  442. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs +106 -0
  443. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.d.cts +1 -0
  444. package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +21 -0
  445. package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-scroll-view.cjs +144 -0
  446. package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-text-alignment.cjs +60 -0
  447. package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-text-input-alignment.cjs +112 -0
  448. package/vendor/node_modules/@legendapp/spark-desktop-config/schema.json +636 -0
  449. package/vendor/node_modules/@legendapp/spark-desktop-config/test-driver.cjs +11 -0
  450. package/vendor/node_modules/@legendapp/spark-desktop-config/test-driver.d.cts +2 -0
  451. package/vendor/node_modules/@legendapp/spark-desktop-config/text-input-accessibility.cjs +47 -0
  452. package/vendor/node_modules/@legendapp/spark-desktop-config/updates.cjs +27 -0
  453. package/vendor/node_modules/@legendapp/spark-desktop-config/validation.cjs +36 -0
  454. package/vendor/node_modules/@legendapp/spark-desktop-config/windows.plugin.cjs +73 -0
  455. package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +209 -0
  456. package/vendor/node_modules/@legendapp/spark-desktop-host/SparkCustomize.mm +517 -0
  457. package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +14 -0
  458. package/vendor/node_modules/@legendapp/spark-desktop-host/windows/SparkComponentGeometry.h +9 -0
  459. package/vendor/node_modules/@legendapp/spark-desktop-host/windows/application.inc +849 -0
  460. package/vendor/node_modules/@legendapp/spark-desktop-host/windows/launch.inc +67 -0
  461. package/vendor/node_modules/@legendapp/spark-desktop-host/windows/notifications.inc +60 -0
  462. package/vendor/node_modules/@legendapp/spark-desktop-host/windows/runtime.inc +63 -0
  463. package/vendor/node_modules/@legendapp/spark-desktop-host/windows/runtimes.inc +162 -0
  464. package/vendor/node_modules/@legendapp/spark-desktop-links/RNDesktopLinks.podspec +17 -0
  465. package/vendor/node_modules/@legendapp/spark-desktop-links/common/AuthLoopback.h +119 -0
  466. package/vendor/node_modules/@legendapp/spark-desktop-links/macos/RNDesktopLinks.h +4 -0
  467. package/vendor/node_modules/@legendapp/spark-desktop-links/macos/RNDesktopLinks.mm +80 -0
  468. package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +53 -0
  469. package/vendor/node_modules/@legendapp/spark-desktop-links/react-native.config.js +6 -0
  470. package/vendor/node_modules/@legendapp/spark-desktop-links/src/NativeDesktopLinks.ts +6 -0
  471. package/vendor/node_modules/@legendapp/spark-desktop-links/src/api.ts +31 -0
  472. package/vendor/node_modules/@legendapp/spark-desktop-links/src/expo.ts +4 -0
  473. package/vendor/node_modules/@legendapp/spark-desktop-links/src/index.android.ts +1 -0
  474. package/vendor/node_modules/@legendapp/spark-desktop-links/src/index.ios.ts +1 -0
  475. package/vendor/node_modules/@legendapp/spark-desktop-links/src/index.ts +1 -0
  476. package/vendor/node_modules/@legendapp/spark-desktop-links/src/index.web.ts +1 -0
  477. package/vendor/node_modules/@legendapp/spark-desktop-links/src/index.windows.ts +1 -0
  478. package/vendor/node_modules/@legendapp/spark-desktop-links/src/native.ts +9 -0
  479. package/vendor/node_modules/@legendapp/spark-desktop-links/windows/ExperimentalFeatures.props +33 -0
  480. package/vendor/node_modules/@legendapp/spark-desktop-links/windows/LICENSE +25 -0
  481. package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/ReactPackageProvider.cpp +20 -0
  482. package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/ReactPackageProvider.h +24 -0
  483. package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/ReactPackageProvider.idl +9 -0
  484. package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/SparkLinks.cpp +2 -0
  485. package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/SparkLinks.def +3 -0
  486. package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/SparkLinks.h +128 -0
  487. package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/SparkLinks.rc +0 -0
  488. package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/SparkLinks.vcxproj +143 -0
  489. package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/SparkLinks.vcxproj.filters +44 -0
  490. package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/pch.cpp +1 -0
  491. package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/pch.h +30 -0
  492. package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/resource.h +5 -0
  493. package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/targetver.h +8 -0
  494. package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks.sln +43 -0
  495. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/RNDesktopShortcuts.podspec +17 -0
  496. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/RNDesktopShortcuts.h +4 -0
  497. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/RNDesktopShortcuts.mm +58 -0
  498. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/keyboard-manager/RNKeyboardManager.h +12 -0
  499. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/keyboard-manager/RNKeyboardManager.mm +307 -0
  500. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +46 -0
  501. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/NativeDesktopShortcuts.ts +8 -0
  502. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/api.ts +45 -0
  503. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/index.ts +1 -0
  504. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/index.windows.ts +1 -0
  505. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/keyboard-manager/NativeKeyboardManager.ts +12 -0
  506. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/keyboard-manager/codes.ts +108 -0
  507. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/keyboard-manager/index.ts +99 -0
  508. package/vendor/node_modules/@legendapp/spark-desktop-windows/RNDesktopWindows.podspec +22 -0
  509. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.h +4 -0
  510. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.mm +339 -0
  511. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/SparkWindowGeometry.h +63 -0
  512. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/LegendWindowRegistry.h +20 -0
  513. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/LegendWindowRegistry.mm +27 -0
  514. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.h +12 -0
  515. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +3189 -0
  516. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManagerStartup.mm +31 -0
  517. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/SidebarStartupFallbacks.mm +14 -0
  518. package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +48 -0
  519. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/NativeDesktopWindowManager.ts +6 -0
  520. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/api.ts +192 -0
  521. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/diagnostics.ts +17 -0
  522. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/index.ts +3 -0
  523. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/index.windows.ts +3 -0
  524. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +55 -0
  525. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos.ts +51 -0
  526. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/transport.ts +41 -0
  527. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/types.ts +140 -0
  528. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/validation.ts +162 -0
  529. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/window-manager/NativeWindowManager.ts +28 -0
  530. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/WindowProvider.tsx +20 -0
  531. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/createWindowsNavigator.tsx +78 -0
  532. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/index.ts +6 -0
  533. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/primaryWindowLifecycle.ts +34 -0
  534. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/types.ts +11 -0
  535. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/usePrimaryWindowLifecycle.ts +18 -0
  536. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/useWindowFocusEffect.ts +17 -0
  537. package/vendor/node_modules/@legendapp/spark-documents/package.json +22 -0
  538. package/vendor/node_modules/@legendapp/spark-documents/src/controller.ts +97 -0
  539. package/vendor/node_modules/@legendapp/spark-documents/src/documentTransition.ts +13 -0
  540. package/vendor/node_modules/@legendapp/spark-documents/src/hooks.ts +139 -0
  541. package/vendor/node_modules/@legendapp/spark-documents/src/index.tsx +50 -0
  542. package/vendor/node_modules/@legendapp/spark-documents/src/reload.ts +39 -0
  543. package/vendor/node_modules/@legendapp/spark-documents/src/requests.ts +15 -0
  544. package/vendor/node_modules/@legendapp/spark-drag-drop/RNDesktopDrag.podspec +20 -0
  545. package/vendor/node_modules/@legendapp/spark-drag-drop/macos/RNDesktopDragView.h +4 -0
  546. package/vendor/node_modules/@legendapp/spark-drag-drop/macos/RNDesktopDragView.mm +94 -0
  547. package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +45 -0
  548. package/vendor/node_modules/@legendapp/spark-drag-drop/react-native.config.js +6 -0
  549. package/vendor/node_modules/@legendapp/spark-drag-drop/src/DesktopDragViewNativeComponent.ts +16 -0
  550. package/vendor/node_modules/@legendapp/spark-drag-drop/src/contracts.ts +83 -0
  551. package/vendor/node_modules/@legendapp/spark-drag-drop/src/index.tsx +60 -0
  552. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/ExperimentalFeatures.props +33 -0
  553. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/LICENSE +25 -0
  554. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/ReactPackageProvider.cpp +21 -0
  555. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/ReactPackageProvider.h +24 -0
  556. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/ReactPackageProvider.idl +9 -0
  557. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.cpp +2 -0
  558. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.def +3 -0
  559. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.h +215 -0
  560. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.rc +0 -0
  561. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.vcxproj +143 -0
  562. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.vcxproj.filters +44 -0
  563. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/pch.cpp +1 -0
  564. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/pch.h +30 -0
  565. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/resource.h +5 -0
  566. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/targetver.h +8 -0
  567. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop.sln +43 -0
  568. package/vendor/node_modules/@legendapp/spark-file-dialog/RNFileDialog.podspec +18 -0
  569. package/vendor/node_modules/@legendapp/spark-file-dialog/ios/RNFileDialog.h +9 -0
  570. package/vendor/node_modules/@legendapp/spark-file-dialog/ios/RNFileDialog.mm +261 -0
  571. package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +50 -0
  572. package/vendor/node_modules/@legendapp/spark-file-dialog/src/NativeFileDialog.ts +9 -0
  573. package/vendor/node_modules/@legendapp/spark-file-dialog/src/index.ts +36 -0
  574. package/vendor/node_modules/@legendapp/spark-file-dialog/src/native.ts +16 -0
  575. package/vendor/node_modules/@legendapp/spark-file-dialog/src/options.ts +74 -0
  576. package/vendor/node_modules/@legendapp/spark-file-dialog/src/types.ts +42 -0
  577. package/vendor/node_modules/@legendapp/spark-file-dialog/windows/ExperimentalFeatures.props +33 -0
  578. package/vendor/node_modules/@legendapp/spark-file-dialog/windows/LICENSE +25 -0
  579. package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/ReactPackageProvider.cpp +20 -0
  580. package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/ReactPackageProvider.h +24 -0
  581. package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/ReactPackageProvider.idl +9 -0
  582. package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/SparkFileDialog.cpp +2 -0
  583. package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/SparkFileDialog.def +3 -0
  584. package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/SparkFileDialog.h +112 -0
  585. package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/SparkFileDialog.rc +0 -0
  586. package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/SparkFileDialog.vcxproj +143 -0
  587. package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/SparkFileDialog.vcxproj.filters +44 -0
  588. package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/pch.cpp +1 -0
  589. package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/pch.h +30 -0
  590. package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/resource.h +5 -0
  591. package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/targetver.h +8 -0
  592. package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog.sln +43 -0
  593. package/vendor/node_modules/@legendapp/spark-file-system/RNDesktopFileSystem.podspec +18 -0
  594. package/vendor/node_modules/@legendapp/spark-file-system/macos/RNDesktopFileSystem.h +4 -0
  595. package/vendor/node_modules/@legendapp/spark-file-system/macos/RNDesktopFileSystem.mm +222 -0
  596. package/vendor/node_modules/@legendapp/spark-file-system/macos/SparkFileMutations.h +25 -0
  597. package/vendor/node_modules/@legendapp/spark-file-system/macos/SparkFileMutations.mm +216 -0
  598. package/vendor/node_modules/@legendapp/spark-file-system/macos/file-scanner/RNFileScanner.h +9 -0
  599. package/vendor/node_modules/@legendapp/spark-file-system/macos/file-scanner/RNFileScanner.mm +82 -0
  600. package/vendor/node_modules/@legendapp/spark-file-system/macos/file-scanner/RNFileScannerCore.h +47 -0
  601. package/vendor/node_modules/@legendapp/spark-file-system/macos/file-scanner/RNFileScannerCore.mm +306 -0
  602. package/vendor/node_modules/@legendapp/spark-file-system/package.json +49 -0
  603. package/vendor/node_modules/@legendapp/spark-file-system/react-native.config.js +6 -0
  604. package/vendor/node_modules/@legendapp/spark-file-system/src/NativeDesktopFileSystem.ts +8 -0
  605. package/vendor/node_modules/@legendapp/spark-file-system/src/file-scanner/NativeFileScanner.ts +11 -0
  606. package/vendor/node_modules/@legendapp/spark-file-system/src/file-scanner/index.ts +93 -0
  607. package/vendor/node_modules/@legendapp/spark-file-system/src/handles.ts +79 -0
  608. package/vendor/node_modules/@legendapp/spark-file-system/src/index.ts +150 -0
  609. package/vendor/node_modules/@legendapp/spark-file-system/src/path.ts +1 -0
  610. package/vendor/node_modules/@legendapp/spark-file-system/windows/ExperimentalFeatures.props +33 -0
  611. package/vendor/node_modules/@legendapp/spark-file-system/windows/LICENSE +25 -0
  612. package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/ReactPackageProvider.cpp +20 -0
  613. package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/ReactPackageProvider.h +24 -0
  614. package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/ReactPackageProvider.idl +9 -0
  615. package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/SparkFileSystem.cpp +2 -0
  616. package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/SparkFileSystem.def +3 -0
  617. package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/SparkFileSystem.h +371 -0
  618. package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/SparkFileSystem.rc +0 -0
  619. package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/SparkFileSystem.vcxproj +146 -0
  620. package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/SparkFileSystem.vcxproj.filters +45 -0
  621. package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/Trash.h +52 -0
  622. package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/pch.cpp +1 -0
  623. package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/pch.h +30 -0
  624. package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/resource.h +5 -0
  625. package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/targetver.h +8 -0
  626. package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem.sln +43 -0
  627. package/vendor/node_modules/@legendapp/spark-global-shortcuts/RNDesktopGlobalShortcuts.podspec +18 -0
  628. package/vendor/node_modules/@legendapp/spark-global-shortcuts/macos/RNDesktopGlobalShortcuts.h +3 -0
  629. package/vendor/node_modules/@legendapp/spark-global-shortcuts/macos/RNDesktopGlobalShortcuts.mm +68 -0
  630. package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +47 -0
  631. package/vendor/node_modules/@legendapp/spark-global-shortcuts/react-native.config.js +6 -0
  632. package/vendor/node_modules/@legendapp/spark-global-shortcuts/src/NativeDesktopGlobalShortcuts.ts +3 -0
  633. package/vendor/node_modules/@legendapp/spark-global-shortcuts/src/index.ts +45 -0
  634. package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/ExperimentalFeatures.props +33 -0
  635. package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/LICENSE +25 -0
  636. package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/ReactPackageProvider.cpp +20 -0
  637. package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/ReactPackageProvider.h +24 -0
  638. package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/ReactPackageProvider.idl +9 -0
  639. package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/SparkGlobalShortcuts.cpp +2 -0
  640. package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/SparkGlobalShortcuts.def +3 -0
  641. package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/SparkGlobalShortcuts.h +81 -0
  642. package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/SparkGlobalShortcuts.rc +0 -0
  643. package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/SparkGlobalShortcuts.vcxproj +143 -0
  644. package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/SparkGlobalShortcuts.vcxproj.filters +44 -0
  645. package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/pch.cpp +1 -0
  646. package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/pch.h +30 -0
  647. package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/resource.h +5 -0
  648. package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/targetver.h +8 -0
  649. package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts.sln +43 -0
  650. package/vendor/node_modules/@legendapp/spark-html/package.json +24 -0
  651. package/vendor/node_modules/@legendapp/spark-html/src/Html.tsx +22 -0
  652. package/vendor/node_modules/@legendapp/spark-html/src/HtmlInput.tsx +102 -0
  653. package/vendor/node_modules/@legendapp/spark-html/src/index.ts +4 -0
  654. package/vendor/node_modules/@legendapp/spark-html/src/types.ts +4 -0
  655. package/vendor/node_modules/@legendapp/spark-markdown/package.json +24 -0
  656. package/vendor/node_modules/@legendapp/spark-markdown/src/Markdown.tsx +25 -0
  657. package/vendor/node_modules/@legendapp/spark-markdown/src/MarkdownInput.tsx +111 -0
  658. package/vendor/node_modules/@legendapp/spark-markdown/src/index.ts +4 -0
  659. package/vendor/node_modules/@legendapp/spark-message-dialog/RNDesktopMessageDialog.podspec +17 -0
  660. package/vendor/node_modules/@legendapp/spark-message-dialog/macos/RNDesktopMessageDialog.h +3 -0
  661. package/vendor/node_modules/@legendapp/spark-message-dialog/macos/RNDesktopMessageDialog.mm +137 -0
  662. package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +46 -0
  663. package/vendor/node_modules/@legendapp/spark-message-dialog/react-native.config.js +6 -0
  664. package/vendor/node_modules/@legendapp/spark-message-dialog/src/NativeDesktopMessageDialog.ts +3 -0
  665. package/vendor/node_modules/@legendapp/spark-message-dialog/src/index.ts +146 -0
  666. package/vendor/node_modules/@legendapp/spark-message-dialog/windows/ExperimentalFeatures.props +33 -0
  667. package/vendor/node_modules/@legendapp/spark-message-dialog/windows/LICENSE +25 -0
  668. package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/ReactPackageProvider.cpp +20 -0
  669. package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/ReactPackageProvider.h +24 -0
  670. package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/ReactPackageProvider.idl +9 -0
  671. package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/SparkMessageDialog.cpp +2 -0
  672. package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/SparkMessageDialog.def +3 -0
  673. package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/SparkMessageDialog.h +145 -0
  674. package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/SparkMessageDialog.rc +0 -0
  675. package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/SparkMessageDialog.vcxproj +143 -0
  676. package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/SparkMessageDialog.vcxproj.filters +44 -0
  677. package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/pch.cpp +1 -0
  678. package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/pch.h +30 -0
  679. package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/resource.h +5 -0
  680. package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/targetver.h +8 -0
  681. package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog.sln +43 -0
  682. package/vendor/node_modules/@legendapp/spark-native-menu/RNNativeMenu.podspec +17 -0
  683. package/vendor/node_modules/@legendapp/spark-native-menu/ios/RNNativeMenu.h +10 -0
  684. package/vendor/node_modules/@legendapp/spark-native-menu/ios/RNNativeMenu.mm +272 -0
  685. package/vendor/node_modules/@legendapp/spark-native-menu/package.json +46 -0
  686. package/vendor/node_modules/@legendapp/spark-native-menu/src/NativeMenu.ts +8 -0
  687. package/vendor/node_modules/@legendapp/spark-native-menu/src/api.ts +128 -0
  688. package/vendor/node_modules/@legendapp/spark-native-menu/src/hooks.ts +103 -0
  689. package/vendor/node_modules/@legendapp/spark-native-menu/src/index.ts +1 -0
  690. package/vendor/node_modules/@legendapp/spark-native-menu/src/index.windows.ts +1 -0
  691. package/vendor/node_modules/@legendapp/spark-native-menu/src/windows-menus.ts +49 -0
  692. package/vendor/node_modules/@legendapp/spark-notifications/RNDesktopNotifications.podspec +17 -0
  693. package/vendor/node_modules/@legendapp/spark-notifications/macos/RNDesktopNotifications.h +4 -0
  694. package/vendor/node_modules/@legendapp/spark-notifications/macos/RNDesktopNotifications.mm +156 -0
  695. package/vendor/node_modules/@legendapp/spark-notifications/package.json +46 -0
  696. package/vendor/node_modules/@legendapp/spark-notifications/react-native.config.js +6 -0
  697. package/vendor/node_modules/@legendapp/spark-notifications/src/NativeDesktopNotifications.ts +4 -0
  698. package/vendor/node_modules/@legendapp/spark-notifications/src/index.ts +141 -0
  699. package/vendor/node_modules/@legendapp/spark-notifications/windows/ExperimentalFeatures.props +33 -0
  700. package/vendor/node_modules/@legendapp/spark-notifications/windows/LICENSE +25 -0
  701. package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/ReactPackageProvider.cpp +20 -0
  702. package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/ReactPackageProvider.h +24 -0
  703. package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/ReactPackageProvider.idl +9 -0
  704. package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/SparkNotifications.cpp +2 -0
  705. package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/SparkNotifications.def +3 -0
  706. package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/SparkNotifications.h +175 -0
  707. package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/SparkNotifications.rc +0 -0
  708. package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/SparkNotifications.vcxproj +143 -0
  709. package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/SparkNotifications.vcxproj.filters +44 -0
  710. package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/pch.cpp +1 -0
  711. package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/pch.h +30 -0
  712. package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/resource.h +5 -0
  713. package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/targetver.h +8 -0
  714. package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications.sln +43 -0
  715. package/vendor/node_modules/@legendapp/spark-processes/RNDesktopProcesses.podspec +17 -0
  716. package/vendor/node_modules/@legendapp/spark-processes/macos/RNDesktopProcesses.h +3 -0
  717. package/vendor/node_modules/@legendapp/spark-processes/macos/RNDesktopProcesses.mm +226 -0
  718. package/vendor/node_modules/@legendapp/spark-processes/package.json +47 -0
  719. package/vendor/node_modules/@legendapp/spark-processes/react-native.config.js +6 -0
  720. package/vendor/node_modules/@legendapp/spark-processes/src/NativeDesktopProcesses.ts +3 -0
  721. package/vendor/node_modules/@legendapp/spark-processes/src/index.ts +135 -0
  722. package/vendor/node_modules/@legendapp/spark-processes/src/types.ts +34 -0
  723. package/vendor/node_modules/@legendapp/spark-processes/windows/ExperimentalFeatures.props +33 -0
  724. package/vendor/node_modules/@legendapp/spark-processes/windows/LICENSE +25 -0
  725. package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/ReactPackageProvider.cpp +20 -0
  726. package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/ReactPackageProvider.h +24 -0
  727. package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/ReactPackageProvider.idl +9 -0
  728. package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/SparkProcesses.cpp +2 -0
  729. package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/SparkProcesses.def +3 -0
  730. package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/SparkProcesses.h +220 -0
  731. package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/SparkProcesses.rc +0 -0
  732. package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/SparkProcesses.vcxproj +145 -0
  733. package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/SparkProcesses.vcxproj.filters +44 -0
  734. package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/pch.cpp +1 -0
  735. package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/pch.h +30 -0
  736. package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/resource.h +5 -0
  737. package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/targetver.h +8 -0
  738. package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses.sln +43 -0
  739. package/vendor/node_modules/@legendapp/spark-rich-text/package.json +18 -0
  740. package/vendor/node_modules/@legendapp/spark-rich-text/src/components.tsx +52 -0
  741. package/vendor/node_modules/@legendapp/spark-rich-text/src/index.ts +4 -0
  742. package/vendor/node_modules/@legendapp/spark-rich-text/src/types.ts +24 -0
  743. package/vendor/node_modules/@legendapp/spark-rich-text/src/useInputShortcuts.macos.ts +55 -0
  744. package/vendor/node_modules/@legendapp/spark-rich-text/src/useInputShortcuts.ts +13 -0
  745. package/vendor/node_modules/@legendapp/spark-rich-text/src/useInputValue.ts +14 -0
  746. package/vendor/node_modules/@legendapp/spark-rich-text/src/value.ts +16 -0
  747. package/vendor/node_modules/@legendapp/spark-secure-storage/RNDesktopSecureStorage.podspec +17 -0
  748. package/vendor/node_modules/@legendapp/spark-secure-storage/macos/RNDesktopSecureStorage.h +4 -0
  749. package/vendor/node_modules/@legendapp/spark-secure-storage/macos/RNDesktopSecureStorage.mm +62 -0
  750. package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +52 -0
  751. package/vendor/node_modules/@legendapp/spark-secure-storage/react-native.config.js +6 -0
  752. package/vendor/node_modules/@legendapp/spark-secure-storage/src/NativeDesktopSecureStorage.ts +6 -0
  753. package/vendor/node_modules/@legendapp/spark-secure-storage/src/desktop.ts +26 -0
  754. package/vendor/node_modules/@legendapp/spark-secure-storage/src/expo.ts +13 -0
  755. package/vendor/node_modules/@legendapp/spark-secure-storage/src/index.android.ts +1 -0
  756. package/vendor/node_modules/@legendapp/spark-secure-storage/src/index.ios.ts +1 -0
  757. package/vendor/node_modules/@legendapp/spark-secure-storage/src/index.ts +1 -0
  758. package/vendor/node_modules/@legendapp/spark-secure-storage/src/index.web.ts +1 -0
  759. package/vendor/node_modules/@legendapp/spark-secure-storage/src/index.windows.ts +2 -0
  760. package/vendor/node_modules/@legendapp/spark-secure-storage/src/options.ts +7 -0
  761. package/vendor/node_modules/@legendapp/spark-secure-storage/src/unavailable.ts +8 -0
  762. package/vendor/node_modules/@legendapp/spark-secure-storage/windows/ExperimentalFeatures.props +33 -0
  763. package/vendor/node_modules/@legendapp/spark-secure-storage/windows/LICENSE +25 -0
  764. package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/ReactPackageProvider.cpp +20 -0
  765. package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/ReactPackageProvider.h +24 -0
  766. package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/ReactPackageProvider.idl +9 -0
  767. package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/SparkSecureStorage.cpp +2 -0
  768. package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/SparkSecureStorage.def +3 -0
  769. package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/SparkSecureStorage.h +48 -0
  770. package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/SparkSecureStorage.rc +0 -0
  771. package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/SparkSecureStorage.vcxproj +143 -0
  772. package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/SparkSecureStorage.vcxproj.filters +44 -0
  773. package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/pch.cpp +1 -0
  774. package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/pch.h +30 -0
  775. package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/resource.h +5 -0
  776. package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/targetver.h +8 -0
  777. package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage.sln +43 -0
  778. package/vendor/node_modules/@legendapp/spark-settings/package.json +20 -0
  779. package/vendor/node_modules/@legendapp/spark-settings/src/fileStorage.ts +11 -0
  780. package/vendor/node_modules/@legendapp/spark-settings/src/filename.ts +1 -0
  781. package/vendor/node_modules/@legendapp/spark-settings/src/filename.windows.ts +9 -0
  782. package/vendor/node_modules/@legendapp/spark-settings/src/index.ts +17 -0
  783. package/vendor/node_modules/@legendapp/spark-settings/src/storage/index.ts +142 -0
  784. package/vendor/node_modules/@legendapp/spark-settings/src/store.ts +79 -0
  785. package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +20 -0
  786. package/vendor/node_modules/@legendapp/spark-settings-ui/src/index.tsx +439 -0
  787. package/vendor/node_modules/@legendapp/spark-settings-ui/src/options.ts +10 -0
  788. package/vendor/node_modules/@legendapp/spark-sqlite/package.json +16 -0
  789. package/vendor/node_modules/@legendapp/spark-sqlite/src/database.ts +182 -0
  790. package/vendor/node_modules/@legendapp/spark-sqlite/src/index.ts +20 -0
  791. package/vendor/node_modules/@legendapp/spark-sqlite/src/types.ts +22 -0
  792. package/vendor/node_modules/@legendapp/spark-system/RNDesktopSystem.podspec +17 -0
  793. package/vendor/node_modules/@legendapp/spark-system/macos/RNDesktopSystem.h +3 -0
  794. package/vendor/node_modules/@legendapp/spark-system/macos/RNDesktopSystem.mm +143 -0
  795. package/vendor/node_modules/@legendapp/spark-system/macos/SparkAppearancePreferences.h +9 -0
  796. package/vendor/node_modules/@legendapp/spark-system/macos/SparkAppearancePreferences.mm +31 -0
  797. package/vendor/node_modules/@legendapp/spark-system/macos/SparkDockTile.h +24 -0
  798. package/vendor/node_modules/@legendapp/spark-system/macos/SparkDockTile.mm +101 -0
  799. package/vendor/node_modules/@legendapp/spark-system/package.json +46 -0
  800. package/vendor/node_modules/@legendapp/spark-system/react-native.config.js +6 -0
  801. package/vendor/node_modules/@legendapp/spark-system/src/NativeDesktopSystem.ts +3 -0
  802. package/vendor/node_modules/@legendapp/spark-system/src/index.ts +158 -0
  803. package/vendor/node_modules/@legendapp/spark-system/windows/ExperimentalFeatures.props +33 -0
  804. package/vendor/node_modules/@legendapp/spark-system/windows/LICENSE +25 -0
  805. package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/ReactPackageProvider.cpp +20 -0
  806. package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/ReactPackageProvider.h +24 -0
  807. package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/ReactPackageProvider.idl +9 -0
  808. package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/SparkSystem.cpp +2 -0
  809. package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/SparkSystem.def +3 -0
  810. package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/SparkSystem.h +158 -0
  811. package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/SparkSystem.rc +0 -0
  812. package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/SparkSystem.vcxproj +143 -0
  813. package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/SparkSystem.vcxproj.filters +44 -0
  814. package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/pch.cpp +1 -0
  815. package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/pch.h +30 -0
  816. package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/resource.h +5 -0
  817. package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/targetver.h +8 -0
  818. package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem.sln +43 -0
  819. package/vendor/node_modules/@legendapp/spark-tray/RNDesktopTray.podspec +17 -0
  820. package/vendor/node_modules/@legendapp/spark-tray/macos/RNDesktopTray.h +4 -0
  821. package/vendor/node_modules/@legendapp/spark-tray/macos/RNDesktopTray.mm +75 -0
  822. package/vendor/node_modules/@legendapp/spark-tray/package.json +46 -0
  823. package/vendor/node_modules/@legendapp/spark-tray/react-native.config.js +6 -0
  824. package/vendor/node_modules/@legendapp/spark-tray/src/NativeDesktopTray.ts +4 -0
  825. package/vendor/node_modules/@legendapp/spark-tray/src/index.ts +103 -0
  826. package/vendor/node_modules/@legendapp/spark-tray/windows/ExperimentalFeatures.props +33 -0
  827. package/vendor/node_modules/@legendapp/spark-tray/windows/LICENSE +25 -0
  828. package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/ReactPackageProvider.cpp +20 -0
  829. package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/ReactPackageProvider.h +24 -0
  830. package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/ReactPackageProvider.idl +9 -0
  831. package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/SparkTray.cpp +2 -0
  832. package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/SparkTray.def +3 -0
  833. package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/SparkTray.h +163 -0
  834. package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/SparkTray.rc +0 -0
  835. package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/SparkTray.vcxproj +143 -0
  836. package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/SparkTray.vcxproj.filters +44 -0
  837. package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/pch.cpp +1 -0
  838. package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/pch.h +30 -0
  839. package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/resource.h +5 -0
  840. package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/targetver.h +8 -0
  841. package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray.sln +43 -0
  842. package/vendor/node_modules/@legendapp/spark-ui/RNSparkUI.podspec +17 -0
  843. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.h +4 -0
  844. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.mm +54 -0
  845. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkLayoutDirection.h +17 -0
  846. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.h +4 -0
  847. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.mm +58 -0
  848. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.h +15 -0
  849. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +1554 -0
  850. package/vendor/node_modules/@legendapp/spark-ui/macos/glass-effect-view/RNGlassEffectView.mm +76 -0
  851. package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.h +15 -0
  852. package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +198 -0
  853. package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSelect.h +15 -0
  854. package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSelect.mm +184 -0
  855. package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.h +15 -0
  856. package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.mm +159 -0
  857. package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.h +18 -0
  858. package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +708 -0
  859. package/vendor/node_modules/@legendapp/spark-ui/macos/swipe-actions/RNSwipeActions.h +10 -0
  860. package/vendor/node_modules/@legendapp/spark-ui/macos/swipe-actions/RNSwipeActions.mm +446 -0
  861. package/vendor/node_modules/@legendapp/spark-ui/macos/text-input-search/RNTextInputSearch.h +15 -0
  862. package/vendor/node_modules/@legendapp/spark-ui/macos/text-input-search/RNTextInputSearch.mm +188 -0
  863. package/vendor/node_modules/@legendapp/spark-ui/package.json +74 -0
  864. package/vendor/node_modules/@legendapp/spark-ui/react-native.config.js +5 -0
  865. package/vendor/node_modules/@legendapp/spark-ui/src/SparkButtonNativeComponent.ts +12 -0
  866. package/vendor/node_modules/@legendapp/spark-ui/src/SparkSelectNativeComponent.ts +12 -0
  867. package/vendor/node_modules/@legendapp/spark-ui/src/SparkTextInputNativeComponent.ts +13 -0
  868. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +42 -0
  869. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +94 -0
  870. package/vendor/node_modules/@legendapp/spark-ui/src/availability.ts +10 -0
  871. package/vendor/node_modules/@legendapp/spark-ui/src/classnames/index.ts +8 -0
  872. package/vendor/node_modules/@legendapp/spark-ui/src/control.ts +42 -0
  873. package/vendor/node_modules/@legendapp/spark-ui/src/desktop.tsx +56 -0
  874. package/vendor/node_modules/@legendapp/spark-ui/src/glass-effect-view/index.tsx +15 -0
  875. package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +39 -0
  876. package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +59 -0
  877. package/vendor/node_modules/@legendapp/spark-ui/src/index.tsx +1 -0
  878. package/vendor/node_modules/@legendapp/spark-ui/src/index.web.tsx +54 -0
  879. package/vendor/node_modules/@legendapp/spark-ui/src/index.windows.tsx +1 -0
  880. package/vendor/node_modules/@legendapp/spark-ui/src/mobile-input.tsx +11 -0
  881. package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSegmentedControlNativeComponent.ts +17 -0
  882. package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSelectNativeComponent.ts +17 -0
  883. package/vendor/node_modules/@legendapp/spark-ui/src/select.ts +9 -0
  884. package/vendor/node_modules/@legendapp/spark-ui/src/sf-symbol/SFSymbolNativeComponent.ts +13 -0
  885. package/vendor/node_modules/@legendapp/spark-ui/src/sf-symbol/index.tsx +27 -0
  886. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarItemNativeComponent.ts +25 -0
  887. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarNativeComponent.ts +29 -0
  888. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/index.tsx +115 -0
  889. package/vendor/node_modules/@legendapp/spark-ui/src/specialized.ts +22 -0
  890. package/vendor/node_modules/@legendapp/spark-ui/src/swipe-actions/SwipeActionsNativeComponent.ts +11 -0
  891. package/vendor/node_modules/@legendapp/spark-ui/src/swipe-actions/index.tsx +41 -0
  892. package/vendor/node_modules/@legendapp/spark-ui/src/text-input-search/TextInputSearchNativeComponent.ts +33 -0
  893. package/vendor/node_modules/@legendapp/spark-ui/src/text-input-search/index.tsx +34 -0
  894. package/vendor/node_modules/@legendapp/spark-ui/src/types.ts +39 -0
  895. package/vendor/node_modules/@legendapp/spark-ui/uniwind.ts +10 -0
  896. package/vendor/node_modules/@legendapp/spark-ui/uniwind.web.ts +19 -0
  897. package/vendor/node_modules/@legendapp/spark-ui/windows/ExperimentalFeatures.props +33 -0
  898. package/vendor/node_modules/@legendapp/spark-ui/windows/LICENSE +25 -0
  899. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/ReactPackageProvider.cpp +21 -0
  900. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/ReactPackageProvider.h +24 -0
  901. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/ReactPackageProvider.idl +9 -0
  902. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkAppearance.h +61 -0
  903. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.cpp +2 -0
  904. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.def +3 -0
  905. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.h +186 -0
  906. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.rc +0 -0
  907. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.vcxproj +144 -0
  908. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.vcxproj.filters +44 -0
  909. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/pch.cpp +1 -0
  910. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/pch.h +30 -0
  911. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/resource.h +5 -0
  912. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/targetver.h +8 -0
  913. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI.sln +43 -0
  914. package/vendor/node_modules/@legendapp/spark-updates/RNDesktopUpdates.podspec +18 -0
  915. package/vendor/node_modules/@legendapp/spark-updates/Sparkle.podspec.json +39 -0
  916. package/vendor/node_modules/@legendapp/spark-updates/macos/RNDesktopUpdates.h +4 -0
  917. package/vendor/node_modules/@legendapp/spark-updates/macos/RNDesktopUpdates.mm +97 -0
  918. package/vendor/node_modules/@legendapp/spark-updates/macos/SparkUpdateState.h +39 -0
  919. package/vendor/node_modules/@legendapp/spark-updates/package.json +44 -0
  920. package/vendor/node_modules/@legendapp/spark-updates/src/NativeDesktopUpdates.ts +5 -0
  921. package/vendor/node_modules/@legendapp/spark-updates/src/index.ts +115 -0
  922. package/vendor/node_modules/@legendapp/spark-webview/package.json +15 -0
  923. package/vendor/node_modules/@legendapp/spark-webview/src/WebView.tsx +11 -0
  924. package/vendor/node_modules/@legendapp/spark-webview/src/adapter.ts +55 -0
  925. package/vendor/node_modules/@legendapp/spark-webview/src/index.ts +2 -0
  926. package/vendor/node_modules/@legendapp/spark-webview/src/types.ts +32 -0
  927. package/vendor/node_modules/@legendapp/spark-webview/src/view-props.ts +28 -0
  928. package/vendor/node_modules/@legendapp/spark-window-options/index.cjs +62 -0
  929. package/vendor/node_modules/@legendapp/spark-window-options/index.d.ts +25 -0
  930. package/vendor/node_modules/@legendapp/spark-window-options/package.json +12 -0
  931. package/webview.ts +1 -0
  932. package/windows-macos.ts +1 -0
  933. package/windows.ts +1 -0
@@ -0,0 +1,3189 @@
1
+ #include <math.h>
2
+ #import "RNWindowManager.h"
3
+ #import "LegendWindowRegistry.h"
4
+ #if TARGET_OS_OSX
5
+ extern "C" void SparkRebindWindowDelegate(NSWindow *, NSString *, id<NSWindowDelegate>);
6
+ #endif
7
+
8
+ #import <React-RCTAppDelegate/RCTRootViewFactory.h>
9
+ #import <React/RCTBridge.h>
10
+ #import <React/RCTBridgeModule.h>
11
+ #import <React/RCTRootView.h>
12
+ #import <React/RCTUIKit.h>
13
+ #import <React/RCTUtils.h>
14
+ #import <TargetConditionals.h>
15
+
16
+ #include <cmath>
17
+ #include <cxxreact/ReactMarker.h>
18
+
19
+ #if TARGET_OS_OSX && !__has_include(<RNDesktopApp/SparkDesktop.h>)
20
+ extern double LegendMainWindowFirstVisibleTimeMs;
21
+ extern double LegendMainWindowReactRootAttachedTimeMs;
22
+ #endif
23
+
24
+ #if TARGET_OS_OSX
25
+ #import <AppKit/AppKit.h>
26
+ #if __has_include(<RNDesktopApp/SparkDesktop.h>)
27
+ #import <RNDesktopApp/SparkDesktop.h>
28
+ #import <RNDesktopApp/SparkTestDriver.h>
29
+ // Safe-mode (docs/app.md) and driver-mode (docs/test-driver.md) launches neither restore nor save window state.
30
+ static BOOL LegendSafeMode(void) { return SparkSafeMode(); }
31
+ static BOOL LegendTestDriverActive(void) { return SparkTestDriverActive(); }
32
+ #else
33
+ static BOOL LegendSafeMode(void) { return NO; }
34
+ static BOOL LegendTestDriverActive(void) { return NO; }
35
+ #endif
36
+ #import <CoreImage/CoreImage.h>
37
+ #import <CoreGraphics/CoreGraphics.h>
38
+ #import <objc/runtime.h>
39
+ #import <QuartzCore/QuartzCore.h>
40
+ #endif
41
+
42
+ @protocol RNWindowManagerRootViewFactoryProvider <NSObject>
43
+ - (RCTRootViewFactory *)rootViewFactory;
44
+ #if TARGET_OS_OSX
45
+ - (NSWindow *)window;
46
+ #endif
47
+ @end
48
+
49
+ #if TARGET_OS_OSX
50
+ static char LegendManagedFullscreenPresentationKey;
51
+ static NSString * const LegendApplicationReopenRequestedNotification = @"LegendApplicationReopenRequestedNotification";
52
+ static NSString * const LegendMainWindowCloseRequestedNotification = @"LegendMainWindowCloseRequestedNotification";
53
+ extern "C" void LegendPrepareSidebarSplitViewStartup(NSWindow *, NSDictionary *) __attribute__((weak_import));
54
+ extern "C" BOOL LegendAttachSidebarSplitViewStartupRoot(NSWindow *, NSView *, void (^)(void)) __attribute__((weak_import));
55
+ extern "C" void LegendFinishSidebarSplitViewStartup(NSWindow *) __attribute__((weak_import));
56
+ static NSString * const LegendMainWindowStartupSplitViewKey = @"LegendMainWindowStartupSplitView";
57
+
58
+ extern "C" NSDictionary *LegendMainWindowStartupSplitViewConfiguration(void)
59
+ {
60
+ if (LegendSafeMode() || LegendTestDriverActive()) return nil;
61
+ NSDictionary *configuration = [NSUserDefaults.standardUserDefaults dictionaryForKey:LegendMainWindowStartupSplitViewKey];
62
+ return [configuration[@"restoreOnLaunch"] isEqual:@NO] ? nil : configuration;
63
+ }
64
+
65
+ static NSString * const LegendRestorableWindowOptionsDefaultsKey = @"LegendRestorableWindowOptions";
66
+ static NSMutableDictionary<NSString *, NSWindow *> *LegendPrecreatedWindows;
67
+ static BOOL LegendApplicationIsTerminating = NO;
68
+
69
+ static NSString *LegendManagedWindowFrameAutosaveName(NSString *identifier)
70
+ {
71
+ NSString *bundleIdentifier = NSBundle.mainBundle.bundleIdentifier ?: @"legend-app";
72
+ return [NSString stringWithFormat:@"LegendManagedWindow.%@.%@", bundleIdentifier, identifier ?: @""];
73
+ }
74
+
75
+ static NSArray<NSDictionary *> *LegendReadRestorableWindowOptions(void)
76
+ {
77
+ if (LegendSafeMode() || LegendTestDriverActive()) return @[];
78
+ NSArray *records = [NSUserDefaults.standardUserDefaults arrayForKey:LegendRestorableWindowOptionsDefaultsKey];
79
+ if (![records isKindOfClass:NSArray.class]) {
80
+ return @[];
81
+ }
82
+ NSMutableArray<NSDictionary *> *options = [NSMutableArray new];
83
+ for (NSString *record in records) {
84
+ if (![record isKindOfClass:NSString.class]) {
85
+ continue;
86
+ }
87
+ NSData *data = [record dataUsingEncoding:NSUTF8StringEncoding];
88
+ id value = data ? [NSJSONSerialization JSONObjectWithData:data options:0 error:nil] : nil;
89
+ if ([value isKindOfClass:NSDictionary.class]) {
90
+ [options addObject:value];
91
+ }
92
+ }
93
+ return options;
94
+ }
95
+
96
+ static NSDictionary *LegendFindRestorableWindowOptions(NSString *identifier)
97
+ {
98
+ for (NSDictionary *record in LegendReadRestorableWindowOptions()) {
99
+ if ([record[@"identifier"] isEqualToString:identifier]) {
100
+ return record;
101
+ }
102
+ }
103
+ return nil;
104
+ }
105
+
106
+ static NSDictionary *LegendRestorableWindowOptions(NSDictionary *options)
107
+ {
108
+ static NSArray<NSString *> *keys;
109
+ static dispatch_once_t onceToken;
110
+ dispatch_once(&onceToken, ^{
111
+ keys = @[
112
+ @"deferOrderFront", @"hasShadow", @"height", @"identifier", @"level", @"moduleName",
113
+ @"representedURL", @"restoreOnLaunch", @"title", @"transparentBackground", @"width", @"windowStyle",
114
+ @"x", @"y",
115
+ ];
116
+ });
117
+ NSMutableDictionary *restorableOptions = [NSMutableDictionary new];
118
+ for (NSString *key in keys) {
119
+ id value = options[key];
120
+ if (value != nil) {
121
+ restorableOptions[key] = value;
122
+ }
123
+ }
124
+ return restorableOptions;
125
+ }
126
+
127
+ static void LegendWriteRestorableWindowOptions(NSArray<NSDictionary *> *options)
128
+ {
129
+ if (LegendSafeMode() || LegendTestDriverActive()) {
130
+ return;
131
+ }
132
+ NSMutableArray<NSString *> *records = [NSMutableArray new];
133
+ for (NSDictionary *record in options) {
134
+ NSData *data = [NSJSONSerialization dataWithJSONObject:record options:0 error:nil];
135
+ NSString *json = data ? [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] : nil;
136
+ if (json) {
137
+ [records addObject:json];
138
+ }
139
+ }
140
+ [NSUserDefaults.standardUserDefaults setObject:records forKey:LegendRestorableWindowOptionsDefaultsKey];
141
+ }
142
+
143
+ static void LegendSetRestorableWindowOptions(NSString *identifier, NSDictionary *options)
144
+ {
145
+ if (identifier.length == 0) {
146
+ return;
147
+ }
148
+ NSMutableArray<NSDictionary *> *records = [LegendReadRestorableWindowOptions() mutableCopy];
149
+ NSIndexSet *matchingIndexes = [records indexesOfObjectsPassingTest:^BOOL(NSDictionary *record, NSUInteger index, BOOL *stop) {
150
+ return [record[@"identifier"] isEqualToString:identifier];
151
+ }];
152
+ if (matchingIndexes.count > 0) {
153
+ [records removeObjectsAtIndexes:matchingIndexes];
154
+ }
155
+ if (options != nil) {
156
+ [records addObject:LegendRestorableWindowOptions(options)];
157
+ }
158
+ LegendWriteRestorableWindowOptions(records);
159
+ }
160
+
161
+ static void LegendRemovePrecreatedWindow(NSString *identifier)
162
+ {
163
+ NSWindow *window = LegendPrecreatedWindows[identifier];
164
+ [LegendPrecreatedWindows removeObjectForKey:identifier];
165
+ [window close];
166
+ }
167
+
168
+ extern "C" NSWindow *LegendTakePrecreatedWindow(NSString *identifier)
169
+ {
170
+ NSWindow *window = LegendPrecreatedWindows[identifier];
171
+ [LegendPrecreatedWindows removeObjectForKey:identifier];
172
+ return window;
173
+ }
174
+
175
+ static inline NSAppearance *LegendDarkAppearance()
176
+ {
177
+ if (@available(macOS 10.14, *)) {
178
+ return [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
179
+ } else if (@available(macOS 10.10, *)) {
180
+ return [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark];
181
+ }
182
+ return nil;
183
+ }
184
+
185
+
186
+
187
+ static NSAppearance *LegendAppearanceForName(NSString *value)
188
+ {
189
+ if (![value isKindOfClass:NSString.class] || value.length == 0 || [value isEqualToString:@"system"]) {
190
+ return nil;
191
+ }
192
+
193
+ if ([value isEqualToString:@"light"]) {
194
+ return [NSAppearance appearanceNamed:NSAppearanceNameAqua];
195
+ }
196
+
197
+ if ([value isEqualToString:@"dark"]) {
198
+ return [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua] ?: LegendDarkAppearance();
199
+ }
200
+
201
+ return nil;
202
+ }
203
+
204
+ static void LegendApplyWindowAppearance(NSWindow *window, NSString *value)
205
+ {
206
+ if (![value isKindOfClass:NSString.class] || value.length == 0) {
207
+ return;
208
+ }
209
+
210
+ window.appearance = LegendAppearanceForName(value);
211
+ [window displayIfNeeded];
212
+ }
213
+
214
+ static void LegendApplyTitleVisibility(NSWindow *window, NSString *value)
215
+ {
216
+ if (![value isKindOfClass:NSString.class] || value.length == 0) {
217
+ return;
218
+ }
219
+
220
+ if ([value isEqualToString:@"hidden"]) {
221
+ window.titleVisibility = NSWindowTitleHidden;
222
+ } else if ([value isEqualToString:@"visible"]) {
223
+ window.titleVisibility = NSWindowTitleVisible;
224
+ }
225
+ }
226
+
227
+ static void LegendApplyToolbarStyle(NSWindow *window, NSString *value)
228
+ {
229
+ if (![value isKindOfClass:NSString.class] || value.length == 0) {
230
+ return;
231
+ }
232
+
233
+ if (@available(macOS 11.0, *)) {
234
+ if ([value isEqualToString:@"automatic"]) {
235
+ window.toolbarStyle = NSWindowToolbarStyleAutomatic;
236
+ } else if ([value isEqualToString:@"expanded"]) {
237
+ window.toolbarStyle = NSWindowToolbarStyleExpanded;
238
+ } else if ([value isEqualToString:@"preference"]) {
239
+ window.toolbarStyle = NSWindowToolbarStylePreference;
240
+ } else if ([value isEqualToString:@"unified"]) {
241
+ window.toolbarStyle = NSWindowToolbarStyleUnified;
242
+ } else if ([value isEqualToString:@"unifiedCompact"]) {
243
+ window.toolbarStyle = NSWindowToolbarStyleUnifiedCompact;
244
+ }
245
+ }
246
+ }
247
+
248
+ static void LegendApplyTitlebarSeparatorStyle(NSWindow *window, NSString *value)
249
+ {
250
+ if (![value isKindOfClass:NSString.class] || value.length == 0) {
251
+ return;
252
+ }
253
+
254
+ if (@available(macOS 11.0, *)) {
255
+ if ([value isEqualToString:@"automatic"]) {
256
+ window.titlebarSeparatorStyle = NSTitlebarSeparatorStyleAutomatic;
257
+ } else if ([value isEqualToString:@"none"]) {
258
+ window.titlebarSeparatorStyle = NSTitlebarSeparatorStyleNone;
259
+ } else if ([value isEqualToString:@"line"]) {
260
+ window.titlebarSeparatorStyle = NSTitlebarSeparatorStyleLine;
261
+ } else if ([value isEqualToString:@"shadow"]) {
262
+ window.titlebarSeparatorStyle = NSTitlebarSeparatorStyleShadow;
263
+ }
264
+ }
265
+ }
266
+
267
+ static NSColor *LegendColorFromHexString(NSString *value)
268
+ {
269
+ if (![value isKindOfClass:NSString.class] || value.length == 0) {
270
+ return nil;
271
+ }
272
+
273
+ if ([value isEqualToString:@"system"]) {
274
+ return NSColor.windowBackgroundColor;
275
+ }
276
+
277
+ NSString *hex = [value hasPrefix:@"#"] ? [value substringFromIndex:1] : value;
278
+ if (hex.length != 6 && hex.length != 8) {
279
+ return nil;
280
+ }
281
+
282
+ unsigned long long raw = 0;
283
+ NSScanner *scanner = [NSScanner scannerWithString:hex];
284
+ if (![scanner scanHexLongLong:&raw]) {
285
+ return nil;
286
+ }
287
+
288
+ CGFloat red = 0;
289
+ CGFloat green = 0;
290
+ CGFloat blue = 0;
291
+ CGFloat alpha = 1;
292
+
293
+ if (hex.length == 8) {
294
+ red = ((raw >> 24) & 0xff) / 255.0;
295
+ green = ((raw >> 16) & 0xff) / 255.0;
296
+ blue = ((raw >> 8) & 0xff) / 255.0;
297
+ alpha = (raw & 0xff) / 255.0;
298
+ } else {
299
+ red = ((raw >> 16) & 0xff) / 255.0;
300
+ green = ((raw >> 8) & 0xff) / 255.0;
301
+ blue = (raw & 0xff) / 255.0;
302
+ }
303
+
304
+ return [NSColor colorWithSRGBRed:red green:green blue:blue alpha:alpha];
305
+ }
306
+
307
+ static BOOL LegendAppearanceIsDark(NSAppearance *appearance)
308
+ {
309
+ if (@available(macOS 10.14, *)) {
310
+ NSAppearanceName match = [appearance bestMatchFromAppearancesWithNames:@[
311
+ NSAppearanceNameDarkAqua,
312
+ NSAppearanceNameAqua,
313
+ ]];
314
+ return [match isEqualToString:NSAppearanceNameDarkAqua];
315
+ }
316
+
317
+ return NO;
318
+ }
319
+
320
+ static BOOL LegendWindowUsesDarkAppearance(NSWindow *window)
321
+ {
322
+ if (window.appearance != nil) {
323
+ return LegendAppearanceIsDark(window.appearance);
324
+ }
325
+ if (NSApp.appearance != nil) {
326
+ return LegendAppearanceIsDark(NSApp.appearance);
327
+ }
328
+
329
+ NSString *interfaceStyle = [NSUserDefaults.standardUserDefaults stringForKey:@"AppleInterfaceStyle"];
330
+ return [interfaceStyle caseInsensitiveCompare:@"Dark"] == NSOrderedSame ||
331
+ LegendAppearanceIsDark(NSApp.effectiveAppearance);
332
+ }
333
+
334
+ static NSColor *LegendWindowStartupBackgroundColor(NSWindow *window, NSString *value)
335
+ {
336
+ NSColor *configuredColor = LegendColorFromHexString(value);
337
+ if (configuredColor != nil) {
338
+ return configuredColor;
339
+ }
340
+
341
+ return LegendWindowUsesDarkAppearance(window)
342
+ ? [NSColor colorWithSRGBRed:25.0 / 255.0 green:26.0 / 255.0 blue:27.0 / 255.0 alpha:1]
343
+ : [NSColor colorWithSRGBRed:245.0 / 255.0 green:246.0 / 255.0 blue:248.0 / 255.0 alpha:1];
344
+ }
345
+
346
+ static void LegendApplyBackgroundColorToView(NSView *view, NSColor *backgroundColor)
347
+ {
348
+ if (!view || !backgroundColor) {
349
+ return;
350
+ }
351
+
352
+ if ([view respondsToSelector:@selector(setBackgroundColor:)]) {
353
+ [(id)view setBackgroundColor:backgroundColor];
354
+ }
355
+ view.wantsLayer = YES;
356
+ view.layer.backgroundColor = backgroundColor.CGColor;
357
+ }
358
+
359
+ static BOOL LegendViewIsTitlebarContainer(NSView *view)
360
+ {
361
+ NSString *className = NSStringFromClass(view.class);
362
+ return [className isEqualToString:@"NSTitlebarContainerView"] ||
363
+ [className isEqualToString:@"NSTitlebarView"] ||
364
+ [className isEqualToString:@"NSTitlebarBackgroundView"];
365
+ }
366
+
367
+ static NSVisualEffectMaterial LegendVisualEffectMaterialForTitlebarMaterial(NSString *value)
368
+ {
369
+ if ([value isEqualToString:@"hudWindow"]) {
370
+ return NSVisualEffectMaterialHUDWindow;
371
+ }
372
+ if ([value isEqualToString:@"sidebar"]) {
373
+ return NSVisualEffectMaterialSidebar;
374
+ }
375
+ if ([value isEqualToString:@"windowBackground"]) {
376
+ return NSVisualEffectMaterialWindowBackground;
377
+ }
378
+ if ([value isEqualToString:@"titlebar"]) {
379
+ return NSVisualEffectMaterialTitlebar;
380
+ }
381
+ if ([value isEqualToString:@"glass"] || [value isEqualToString:@"headerView"]) {
382
+ if (@available(macOS 10.14, *)) {
383
+ return NSVisualEffectMaterialHeaderView;
384
+ }
385
+ return NSVisualEffectMaterialTitlebar;
386
+ }
387
+ return NSVisualEffectMaterialTitlebar;
388
+ }
389
+
390
+ static NSVisualEffectBlendingMode LegendVisualEffectBlendingModeForName(NSString *value)
391
+ {
392
+ return [value isEqualToString:@"withinWindow"] ? NSVisualEffectBlendingModeWithinWindow : NSVisualEffectBlendingModeBehindWindow;
393
+ }
394
+
395
+ static NSVisualEffectState LegendVisualEffectStateForName(NSString *value)
396
+ {
397
+ if ([value isEqualToString:@"active"]) {
398
+ return NSVisualEffectStateActive;
399
+ }
400
+ if ([value isEqualToString:@"inactive"]) {
401
+ return NSVisualEffectStateInactive;
402
+ }
403
+ return NSVisualEffectStateFollowsWindowActiveState;
404
+ }
405
+
406
+ static NSRect LegendTitlebarMaterialFrame(NSWindow *window, NSView *frameView)
407
+ {
408
+ NSRect frameBounds = frameView.bounds;
409
+ NSRect contentLayoutRect = [frameView convertRect:window.contentLayoutRect fromView:nil];
410
+ CGFloat materialMinY = NSMaxY(contentLayoutRect);
411
+ CGFloat materialHeight = NSMaxY(frameBounds) - materialMinY;
412
+
413
+ if (materialHeight <= 0 || materialHeight > NSHeight(frameBounds)) {
414
+ materialHeight = MAX(0, NSHeight(window.frame) - NSHeight(window.contentLayoutRect));
415
+ materialMinY = NSMaxY(frameBounds) - materialHeight;
416
+ }
417
+
418
+ return NSMakeRect(0, materialMinY, NSWidth(frameBounds), materialHeight);
419
+ }
420
+
421
+ API_AVAILABLE(macos(26.0))
422
+ static NSView *LegendCreateOverscannedGlassEffectView(NSRect frame)
423
+ {
424
+ NSView *containerView = [[NSView alloc] initWithFrame:frame];
425
+ containerView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
426
+ containerView.wantsLayer = YES;
427
+ containerView.layer.backgroundColor = NSColor.clearColor.CGColor;
428
+ containerView.layer.masksToBounds = YES;
429
+
430
+ CGFloat overscan = 48;
431
+ NSRect glassFrame = NSMakeRect(-overscan, 0, NSWidth(frame) + overscan, NSHeight(frame) + overscan);
432
+ NSGlassEffectView *glassView = [[NSGlassEffectView alloc] initWithFrame:glassFrame];
433
+ glassView.cornerRadius = 0;
434
+ glassView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
435
+ glassView.wantsLayer = YES;
436
+ glassView.layer.backgroundColor = NSColor.clearColor.CGColor;
437
+ [containerView addSubview:glassView];
438
+
439
+ return containerView;
440
+ }
441
+
442
+ static void LegendApplyTitlebarBackgroundColor(NSView *view, NSColor *backgroundColor)
443
+ {
444
+ BOOL isTitlebarContainer = LegendViewIsTitlebarContainer(view);
445
+
446
+ if (isTitlebarContainer) {
447
+ LegendApplyBackgroundColorToView(view, backgroundColor);
448
+ }
449
+
450
+ for (NSView *subview in view.subviews) {
451
+ LegendApplyTitlebarBackgroundColor(subview, backgroundColor);
452
+ }
453
+ }
454
+
455
+ static BOOL LegendUsesFullSizeContentLayout(NSWindow *window);
456
+
457
+ static void LegendApplyWindowBackgroundColor(NSWindow *window, NSString *value)
458
+ {
459
+ NSColor *backgroundColor = LegendColorFromHexString(value);
460
+ if (!backgroundColor) {
461
+ return;
462
+ }
463
+
464
+ window.backgroundColor = backgroundColor;
465
+ window.opaque = backgroundColor.alphaComponent >= 1;
466
+
467
+ NSView *contentView = window.contentView;
468
+ if (contentView) {
469
+ // System window backing must remain behind AppKit-managed sidebar materials.
470
+ LegendApplyBackgroundColorToView(contentView, [value isEqualToString:@"system"] ? NSColor.clearColor : backgroundColor);
471
+ }
472
+
473
+ NSView *frameView = contentView.superview;
474
+ if (frameView) {
475
+ NSColor *titlebarBackgroundColor = LegendUsesFullSizeContentLayout(window) ? NSColor.clearColor : backgroundColor;
476
+ LegendApplyTitlebarBackgroundColor(frameView, titlebarBackgroundColor);
477
+ dispatch_async(dispatch_get_main_queue(), ^{
478
+ NSView *currentFrameView = window.contentView.superview;
479
+ if (currentFrameView) {
480
+ LegendApplyTitlebarBackgroundColor(currentFrameView, titlebarBackgroundColor);
481
+ }
482
+ });
483
+ }
484
+ }
485
+
486
+ static char LegendManagedRootViewKey;
487
+ static char LegendContentLayoutModeKey;
488
+ static char LegendTitlebarControlMetadataKey;
489
+ static char LegendToolbarControlMetadataKey;
490
+ static char LegendToolbarWindowIdentifierKey;
491
+ static char LegendToolbarSearchFieldKey;
492
+ static char LegendToolbarSearchItemKey;
493
+ static char LegendToolbarSearchWidthKey;
494
+ static char LegendToolbarSearchButtonKey;
495
+ static char LegendToolbarSearchContainerKey;
496
+ static char LegendToolbarSearchWidthConstraintKey;
497
+ static const CGFloat LegendToolbarSearchCollapsedSize = 34;
498
+ static const CGFloat LegendToolbarIconControlWidth = 36;
499
+
500
+ // AppKit synchronizes all toolbars with the same identifier as a family.
501
+ // Our windows own independent item state, including across React reloads.
502
+ static NSToolbar *LegendCreateToolbar(NSString *windowIdentifier)
503
+ {
504
+ NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier:
505
+ [@"LegendToolbar." stringByAppendingString:NSUUID.UUID.UUIDString]];
506
+ objc_setAssociatedObject(toolbar, &LegendToolbarWindowIdentifierKey,
507
+ windowIdentifier ?: @"", OBJC_ASSOCIATION_COPY_NONATOMIC);
508
+ toolbar.displayMode = NSToolbarDisplayModeIconOnly;
509
+ toolbar.showsBaselineSeparator = NO;
510
+ return toolbar;
511
+ }
512
+
513
+ static NSString *LegendToolbarWindowIdentifier(NSToolbar *toolbar)
514
+ {
515
+ return objc_getAssociatedObject(toolbar, &LegendToolbarWindowIdentifierKey) ?: @"";
516
+ }
517
+
518
+ static RCTUIView *LegendManagedRootView(NSWindow *window)
519
+ {
520
+ id associatedRootView = objc_getAssociatedObject(window, &LegendManagedRootViewKey);
521
+ if ([associatedRootView isKindOfClass:RCTUIView.class]) {
522
+ return associatedRootView;
523
+ }
524
+
525
+ if ([window.contentView isKindOfClass:RCTUIView.class]) {
526
+ return (RCTUIView *)window.contentView;
527
+ }
528
+
529
+ return nil;
530
+ }
531
+
532
+ static void LegendEnsureRootViewContainer(NSWindow *window, RCTUIView *rootView)
533
+ {
534
+ if (!window || !rootView || window.contentView != rootView) {
535
+ return;
536
+ }
537
+
538
+ NSView *containerView = [[NSView alloc] initWithFrame:rootView.frame];
539
+ containerView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
540
+ LegendApplyBackgroundColorToView(containerView, window.backgroundColor);
541
+
542
+ window.contentView = containerView;
543
+ [containerView addSubview:rootView];
544
+ objc_setAssociatedObject(window, &LegendManagedRootViewKey, rootView, OBJC_ASSOCIATION_ASSIGN);
545
+ }
546
+
547
+ static void LegendApplyContentLayoutModeOption(NSWindow *window, NSString *contentLayoutMode)
548
+ {
549
+ if (!window || ![contentLayoutMode isKindOfClass:NSString.class]) {
550
+ return;
551
+ }
552
+
553
+ objc_setAssociatedObject(window, &LegendContentLayoutModeKey, contentLayoutMode, OBJC_ASSOCIATION_COPY_NONATOMIC);
554
+ }
555
+
556
+ static BOOL LegendUsesFullSizeContentLayout(NSWindow *window)
557
+ {
558
+ id contentLayoutMode = objc_getAssociatedObject(window, &LegendContentLayoutModeKey);
559
+ return [contentLayoutMode isKindOfClass:NSString.class] && [(NSString *)contentLayoutMode isEqualToString:@"fullSize"];
560
+ }
561
+
562
+ static void LegendPrepareWindowForDisplay(NSWindow *window, NSString *backgroundColor)
563
+ {
564
+ LegendApplyWindowBackgroundColor(window, backgroundColor);
565
+ [window.contentView displayIfNeeded];
566
+ [window displayIfNeeded];
567
+ }
568
+
569
+ static void LegendApplyContentLayoutMode(NSWindow *window, NSNumber *maskNumber, BOOL usesTitlebarBackground)
570
+ {
571
+ NSString *contentLayoutMode = objc_getAssociatedObject(window, &LegendContentLayoutModeKey);
572
+ if ([contentLayoutMode isEqualToString:@"fullSize"] || (usesTitlebarBackground && ![contentLayoutMode isEqualToString:@"contentLayoutGuide"])) {
573
+ window.styleMask = window.styleMask | NSWindowStyleMaskFullSizeContentView;
574
+ return;
575
+ }
576
+
577
+ if ([contentLayoutMode isEqualToString:@"contentLayoutGuide"] || (maskNumber && (maskNumber.unsignedIntegerValue & NSWindowStyleMaskFullSizeContentView) == 0)) {
578
+ window.styleMask = window.styleMask & ~NSWindowStyleMaskFullSizeContentView;
579
+ }
580
+ }
581
+
582
+ static BOOL LegendDictionaryHasKey(NSDictionary *dictionary, NSString *key)
583
+ {
584
+ return [dictionary isKindOfClass:NSDictionary.class] && dictionary[key] != nil;
585
+ }
586
+
587
+ static void LegendSizeRootViewToWindow(RCTUIView *rootView, NSWindow *window);
588
+
589
+ static NSURL *LegendURLFromString(NSString *value)
590
+ {
591
+ if (![value isKindOfClass:NSString.class] || value.length == 0) {
592
+ return nil;
593
+ }
594
+
595
+ NSURL *url = [NSURL URLWithString:value];
596
+ if (url.scheme.length > 0) {
597
+ return url;
598
+ }
599
+
600
+ return [NSURL fileURLWithPath:value];
601
+ }
602
+
603
+ static void LegendApplyWindowTitleAndRepresentedURL(NSWindow *window,
604
+ NSString *title,
605
+ BOOL hasRepresentedURL,
606
+ id representedURLValue,
607
+ NSString *fallbackTitle)
608
+ {
609
+ NSURL *representedURL = [representedURLValue isKindOfClass:NSString.class]
610
+ ? LegendURLFromString((NSString *)representedURLValue)
611
+ : nil;
612
+
613
+ if (hasRepresentedURL) {
614
+ if ([representedURLValue isKindOfClass:NSNull.class]) {
615
+ window.representedURL = nil;
616
+ } else if (representedURL.fileURL && representedURL.path.length > 0) {
617
+ window.representedURL = representedURL;
618
+ } else {
619
+ window.representedURL = representedURL;
620
+ }
621
+ }
622
+
623
+ if (!title && representedURL.lastPathComponent.length > 0) {
624
+ title = representedURL.lastPathComponent;
625
+ }
626
+ window.title = title ?: fallbackTitle ?: @"";
627
+ }
628
+
629
+ static void LegendApplyWindowOptions(NSWindow *window, NSDictionary *options)
630
+ {
631
+ if (!window || ![options isKindOfClass:NSDictionary.class]) {
632
+ return;
633
+ }
634
+
635
+ BOOL hasTitle = LegendDictionaryHasKey(options, @"title");
636
+ BOOL hasRepresentedURL = LegendDictionaryHasKey(options, @"representedURL");
637
+ id representedURLValue = hasRepresentedURL ? options[@"representedURL"] : nil;
638
+ NSString *title = [options[@"title"] isKindOfClass:NSString.class] ? options[@"title"] : nil;
639
+ if (hasTitle || hasRepresentedURL) {
640
+ LegendApplyWindowTitleAndRepresentedURL(window, title, hasRepresentedURL, representedURLValue, nil);
641
+ }
642
+
643
+ NSDictionary *windowStyle = [options[@"windowStyle"] isKindOfClass:NSDictionary.class] ? options[@"windowStyle"] : @{};
644
+ if (windowStyle[@"startupSplitView"] == NSNull.null && LegendFinishSidebarSplitViewStartup) {
645
+ LegendFinishSidebarSplitViewStartup(window);
646
+ }
647
+ NSNumber *maskNumber = [windowStyle[@"mask"] isKindOfClass:NSNumber.class] ? windowStyle[@"mask"] : nil;
648
+ NSNumber *transparentTitlebar = [windowStyle[@"titlebarAppearsTransparent"] isKindOfClass:NSNumber.class]
649
+ ? windowStyle[@"titlebarAppearsTransparent"]
650
+ : nil;
651
+ NSString *titleVisibility = [windowStyle[@"titleVisibility"] isKindOfClass:NSString.class]
652
+ ? windowStyle[@"titleVisibility"]
653
+ : nil;
654
+ NSString *toolbarStyle = [windowStyle[@"toolbarStyle"] isKindOfClass:NSString.class] ? windowStyle[@"toolbarStyle"] : nil;
655
+ NSString *contentLayoutMode = [windowStyle[@"contentLayoutMode"] isKindOfClass:NSString.class]
656
+ ? windowStyle[@"contentLayoutMode"]
657
+ : nil;
658
+ NSString *titlebarSeparatorStyle = [windowStyle[@"titlebarSeparatorStyle"] isKindOfClass:NSString.class]
659
+ ? windowStyle[@"titlebarSeparatorStyle"]
660
+ : nil;
661
+ NSString *backgroundColor = [windowStyle[@"backgroundColor"] isKindOfClass:NSString.class]
662
+ ? windowStyle[@"backgroundColor"]
663
+ : nil;
664
+ NSString *appearance = [windowStyle[@"appearance"] isKindOfClass:NSString.class]
665
+ ? windowStyle[@"appearance"]
666
+ : nil;
667
+ BOOL hasToolbarKey = LegendDictionaryHasKey(windowStyle, @"hasToolbar");
668
+ BOOL hasToolbar = [windowStyle[@"hasToolbar"] boolValue];
669
+ BOOL usesTitlebarBackground = transparentTitlebar.boolValue && backgroundColor.length > 0;
670
+
671
+ if (maskNumber) window.styleMask = maskNumber.unsignedIntegerValue;
672
+ if (options[@"level"]) window.level = [options[@"level"] integerValue];
673
+ if (windowStyle[@"trafficLights"]) for (NSNumber *button in @[@(NSWindowCloseButton), @(NSWindowMiniaturizeButton), @(NSWindowZoomButton)]) [window standardWindowButton:(NSWindowButton)button.integerValue].hidden = ![windowStyle[@"trafficLights"] boolValue];
674
+ if (windowStyle[@"panelStyle"]) {
675
+ NSWindowStyleMask mask = window.styleMask & ~(NSWindowStyleMaskUtilityWindow | NSWindowStyleMaskDocModalWindow | NSWindowStyleMaskNonactivatingPanel);
676
+ NSString *panel = windowStyle[@"panelStyle"];
677
+ window.styleMask = mask | ([panel isEqual:@"utility"] ? NSWindowStyleMaskUtilityWindow : [panel isEqual:@"documentModal"] ? NSWindowStyleMaskDocModalWindow : NSWindowStyleMaskNonactivatingPanel);
678
+ }
679
+ LegendApplyContentLayoutModeOption(window, contentLayoutMode);
680
+ LegendApplyContentLayoutMode(window, maskNumber, usesTitlebarBackground);
681
+ if (transparentTitlebar != nil) {
682
+ window.titlebarAppearsTransparent = transparentTitlebar.boolValue;
683
+ }
684
+ LegendApplyTitleVisibility(window, titleVisibility);
685
+ if (hasToolbarKey) {
686
+ if (hasToolbar && !window.toolbar) {
687
+ NSToolbar *toolbar = LegendCreateToolbar([options[@"identifier"] isKindOfClass:NSString.class] ? options[@"identifier"] : @"main");
688
+ window.toolbar = toolbar;
689
+ } else if (!hasToolbar) {
690
+ window.toolbar = nil;
691
+ }
692
+ }
693
+ LegendApplyToolbarStyle(window, toolbarStyle);
694
+ LegendApplyTitlebarSeparatorStyle(window, titlebarSeparatorStyle);
695
+ LegendApplyWindowAppearance(window, appearance);
696
+ LegendApplyWindowBackgroundColor(window, backgroundColor);
697
+
698
+ RCTUIView *rootView = LegendManagedRootView(window);
699
+ if ((usesTitlebarBackground || contentLayoutMode.length > 0) && rootView) {
700
+ LegendEnsureRootViewContainer(window, rootView);
701
+ LegendSizeRootViewToWindow(rootView, window);
702
+ }
703
+ }
704
+
705
+ static void LegendSizeRootViewToWindow(RCTUIView *rootView, NSWindow *window)
706
+ {
707
+ if (!rootView || !window) {
708
+ return;
709
+ }
710
+
711
+ NSView *contentView = window.contentView;
712
+ if (contentView && contentView != rootView && (window.styleMask & NSWindowStyleMaskFullSizeContentView) != 0) {
713
+ rootView.frame = LegendUsesFullSizeContentLayout(window)
714
+ ? contentView.bounds
715
+ : [contentView convertRect:window.contentLayoutRect fromView:nil];
716
+ } else {
717
+ rootView.frame = contentView ? contentView.bounds : NSMakeRect(0, 0, window.frame.size.width, window.frame.size.height);
718
+ }
719
+ rootView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
720
+ [rootView setNeedsLayout:YES];
721
+ }
722
+
723
+ extern "C" void LegendPrecreateRestorableWindows(void)
724
+ {
725
+ if (LegendPrecreatedWindows != nil) {
726
+ return;
727
+ }
728
+
729
+ LegendPrecreatedWindows = [NSMutableDictionary new];
730
+ // Safe and driver mode open no saved windows; their records stay for the next normal launch.
731
+ if (LegendSafeMode() || LegendTestDriverActive()) {
732
+ return;
733
+ }
734
+ for (NSDictionary *options in LegendReadRestorableWindowOptions()) {
735
+ NSString *identifier = [options[@"identifier"] isKindOfClass:NSString.class] ? options[@"identifier"] : nil;
736
+ if (identifier.length == 0 || ![options[@"restoreOnLaunch"] boolValue]) {
737
+ continue;
738
+ }
739
+
740
+ NSDictionary *windowStyle = [options[@"windowStyle"] isKindOfClass:NSDictionary.class]
741
+ ? options[@"windowStyle"]
742
+ : @{};
743
+ NSNumber *maskNumber = [windowStyle[@"mask"] isKindOfClass:NSNumber.class] ? windowStyle[@"mask"] : nil;
744
+ NSNumber *widthNumber = [windowStyle[@"width"] isKindOfClass:NSNumber.class]
745
+ ? windowStyle[@"width"]
746
+ : ([options[@"width"] isKindOfClass:NSNumber.class] ? options[@"width"] : nil);
747
+ NSNumber *heightNumber = [windowStyle[@"height"] isKindOfClass:NSNumber.class]
748
+ ? windowStyle[@"height"]
749
+ : ([options[@"height"] isKindOfClass:NSNumber.class] ? options[@"height"] : nil);
750
+ CGFloat width = widthNumber ? MAX(widthNumber.doubleValue, 1) : 400;
751
+ CGFloat height = heightNumber ? MAX(heightNumber.doubleValue, 1) : 300;
752
+ NSUInteger styleMask = maskNumber
753
+ ? maskNumber.unsignedIntegerValue
754
+ : (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable | NSWindowStyleMaskMiniaturizable);
755
+ NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, width, height)
756
+ styleMask:styleMask
757
+ backing:NSBackingStoreBuffered
758
+ defer:NO];
759
+ window.releasedWhenClosed = NO;
760
+ LegendApplyWindowOptions(window, options);
761
+
762
+ NSNumber *levelNumber = [options[@"level"] isKindOfClass:NSNumber.class] ? options[@"level"] : nil;
763
+ if (levelNumber) {
764
+ window.level = levelNumber.integerValue;
765
+ }
766
+ NSNumber *hasShadow = [options[@"hasShadow"] isKindOfClass:NSNumber.class] ? options[@"hasShadow"] : nil;
767
+ if (hasShadow) {
768
+ window.hasShadow = hasShadow.boolValue;
769
+ }
770
+ BOOL transparentBackground = [options[@"transparentBackground"] boolValue];
771
+ NSString *backgroundColor = [windowStyle[@"backgroundColor"] isKindOfClass:NSString.class]
772
+ ? windowStyle[@"backgroundColor"]
773
+ : nil;
774
+ NSColor *startupBackgroundColor = transparentBackground
775
+ ? NSColor.clearColor
776
+ : LegendWindowStartupBackgroundColor(window, backgroundColor);
777
+ window.backgroundColor = startupBackgroundColor;
778
+ window.opaque = !transparentBackground && startupBackgroundColor.alphaComponent >= 1;
779
+
780
+ NSView *placeholder = [[NSView alloc] initWithFrame:window.contentView.bounds];
781
+ placeholder.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
782
+ LegendApplyBackgroundColorToView(placeholder, startupBackgroundColor);
783
+ window.contentView = placeholder;
784
+
785
+ NSString *autosaveName = LegendManagedWindowFrameAutosaveName(identifier);
786
+ [window setFrameAutosaveName:autosaveName];
787
+ if (![window setFrameUsingName:autosaveName]) {
788
+ NSNumber *originX = [options[@"x"] isKindOfClass:NSNumber.class] ? options[@"x"] : nil;
789
+ NSNumber *originY = [options[@"y"] isKindOfClass:NSNumber.class] ? options[@"y"] : nil;
790
+ if (originX || originY) {
791
+ NSPoint origin = window.frame.origin;
792
+ origin.x = originX ? originX.doubleValue : origin.x;
793
+ origin.y = originY ? originY.doubleValue : origin.y;
794
+ [window setFrameOrigin:origin];
795
+ } else {
796
+ [window center];
797
+ }
798
+ }
799
+
800
+ if (LegendPrepareSidebarSplitViewStartup) {
801
+ LegendPrepareSidebarSplitViewStartup(window, windowStyle[@"startupSplitView"]);
802
+ }
803
+ LegendPrecreatedWindows[identifier] = window;
804
+ if (![options[@"deferOrderFront"] boolValue]) {
805
+ [window makeKeyAndOrderFront:nil];
806
+ if (levelNumber) {
807
+ [window orderFrontRegardless];
808
+ }
809
+ }
810
+ }
811
+ }
812
+ #endif
813
+
814
+ @interface RNWindowManager ()
815
+ #if TARGET_OS_OSX
816
+ <NSWindowDelegate, NSSearchFieldDelegate, NSToolbarDelegate>
817
+ #endif
818
+ @property (nonatomic, strong) NSMutableDictionary<NSString *, id> *windows;
819
+ @property (nonatomic, strong) NSMutableDictionary<NSString *, RCTUIView *> *rootViews;
820
+ @property (nonatomic, strong) NSMutableDictionary<NSString *, NSString *> *moduleNames;
821
+ @property (nonatomic, strong) NSMutableDictionary<NSString *, NSArray<NSTitlebarAccessoryViewController *> *> *titlebarAccessoryControllers;
822
+ @property (nonatomic, strong) NSMutableDictionary<NSString *, NSView *> *titlebarMaterialViews;
823
+ @property (nonatomic, strong) NSMutableDictionary<NSString *, NSArray<NSDictionary *> *> *toolbarItemConfigs;
824
+ @property (nonatomic, strong) NSMutableDictionary<NSString *, CIFilter *> *windowBlurFilters;
825
+ @property (nonatomic, strong) NSMutableDictionary<NSString *, NSDictionary *> *windowOptions;
826
+ @property (nonatomic, strong) NSMutableSet<NSString *> *closeRequestIdentifiers;
827
+ @property (nonatomic, strong, nullable) id displaySleepActivity;
828
+ @property (nonatomic, assign) BOOL hasListeners;
829
+ @property (nonatomic, assign) BOOL mainWindowObserversInstalled;
830
+ #if TARGET_OS_OSX
831
+ - (void)sendToolbarSearchEventForField:(NSSearchField *)searchField submitted:(BOOL)submitted shiftKey:(BOOL)shiftKey;
832
+ - (void)recordWindowOptions:(NSDictionary *)options identifier:(NSString *)identifier moduleName:(NSString *)moduleName;
833
+ #endif
834
+ @end
835
+
836
+ @implementation RNWindowManager
837
+
838
+ RCT_EXPORT_MODULE(NativeWindowManager)
839
+
840
+ + (BOOL)requiresMainQueueSetup
841
+ {
842
+ return YES;
843
+ }
844
+
845
+ - (instancetype)init
846
+ {
847
+ if (self = [super init]) {
848
+ #if TARGET_OS_OSX
849
+ LegendWindowRegistry *registry = LegendWindowRegistry.sharedRegistry;
850
+ _windows = (id)registry.windows;
851
+ _rootViews = (id)registry.rootViews;
852
+ _moduleNames = registry.moduleNames;
853
+ _titlebarAccessoryControllers = registry.titlebarAccessoryControllers;
854
+ _titlebarMaterialViews = registry.titlebarMaterialViews;
855
+ _toolbarItemConfigs = registry.toolbarItemConfigs;
856
+ _windowBlurFilters = registry.windowBlurFilters;
857
+ _windowOptions = registry.windowOptions;
858
+ _closeRequestIdentifiers = registry.closeRequestIdentifiers;
859
+ for (NSString *identifier in _moduleNames.allKeys) {
860
+ NSWindow *window = _windows[identifier];
861
+ SparkRebindWindowDelegate(window, identifier, self);
862
+ [self bindChromeForWindow:window];
863
+ }
864
+ [self bindChromeForWindow:[RNWindowManager getMainWindow]];
865
+ #else
866
+ _windows = [NSMutableDictionary new];
867
+ _rootViews = [NSMutableDictionary new];
868
+ _moduleNames = [NSMutableDictionary new];
869
+ _titlebarAccessoryControllers = [NSMutableDictionary new];
870
+ _titlebarMaterialViews = [NSMutableDictionary new];
871
+ _toolbarItemConfigs = [NSMutableDictionary new];
872
+ _windowBlurFilters = [NSMutableDictionary new];
873
+ _windowOptions = [NSMutableDictionary new];
874
+ _closeRequestIdentifiers = [NSMutableSet new];
875
+ #endif
876
+ #if TARGET_OS_OSX
877
+ #if __has_include(<RNDesktopApp/SparkDesktop.h>)
878
+ [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(sparkDesktopEvent:) name:SparkDesktopEvent object:nil];
879
+ #endif
880
+ [NSNotificationCenter.defaultCenter addObserver:self
881
+ selector:@selector(applicationReopenRequested:)
882
+ name:LegendApplicationReopenRequestedNotification
883
+ object:nil];
884
+ [NSNotificationCenter.defaultCenter addObserver:self
885
+ selector:@selector(mainWindowCloseRequested:)
886
+ name:LegendMainWindowCloseRequestedNotification
887
+ object:nil];
888
+ [NSNotificationCenter.defaultCenter addObserver:self
889
+ selector:@selector(applicationWillTerminate:)
890
+ name:NSApplicationWillTerminateNotification
891
+ object:nil];
892
+ [NSNotificationCenter.defaultCenter addObserver:self
893
+ selector:@selector(windowDidBecomeKey:)
894
+ name:NSWindowDidBecomeKeyNotification
895
+ object:nil];
896
+ [NSNotificationCenter.defaultCenter addObserver:self
897
+ selector:@selector(screensChanged:)
898
+ name:NSApplicationDidChangeScreenParametersNotification
899
+ object:nil];
900
+ #endif
901
+ }
902
+ return self;
903
+ }
904
+
905
+ #if TARGET_OS_OSX
906
+ - (void)bindChromeControlView:(NSView *)view
907
+ {
908
+ BOOL managed = objc_getAssociatedObject(view, &LegendToolbarControlMetadataKey) != nil ||
909
+ objc_getAssociatedObject(view, &LegendTitlebarControlMetadataKey) != nil ||
910
+ objc_getAssociatedObject(view, &LegendToolbarSearchItemKey) != nil;
911
+ if (managed && [view isKindOfClass:NSControl.class]) {
912
+ ((NSControl *)view).target = self;
913
+ if ([view isKindOfClass:NSSearchField.class]) ((NSSearchField *)view).delegate = self;
914
+ }
915
+ for (NSView *child in view.subviews) [self bindChromeControlView:child];
916
+ }
917
+
918
+ - (void)bindChromeForWindow:(NSWindow *)window
919
+ {
920
+ NSToolbar *toolbar = window.toolbar;
921
+ if (objc_getAssociatedObject(toolbar, &LegendToolbarWindowIdentifierKey)) {
922
+ toolbar.delegate = self;
923
+ for (NSToolbarItem *item in toolbar.items) {
924
+ if (objc_getAssociatedObject(item, &LegendToolbarControlMetadataKey)) item.target = self;
925
+ [self bindChromeControlView:item.view];
926
+ }
927
+ }
928
+ for (NSTitlebarAccessoryViewController *controller in window.titlebarAccessoryViewControllers) {
929
+ [self bindChromeControlView:controller.view];
930
+ }
931
+ }
932
+ #endif
933
+
934
+ - (NSArray<NSString *> *)supportedEvents
935
+ {
936
+ return @[
937
+ @"onWindowClosed",
938
+ @"onWindowCloseRequested",
939
+ @"onMainWindowMoved",
940
+ @"onMainWindowResized",
941
+ @"onWindowMoved",
942
+ @"onWindowResized",
943
+ @"onApplicationReopenRequested",
944
+ @"onWindowFocused",
945
+ @"onTitlebarControlPressed",
946
+ @"onToolbarItemSelected",
947
+ @"onToolbarSearch",
948
+ @"onDisplaysChanged",
949
+ ];
950
+ }
951
+
952
+ - (void)startObserving
953
+ {
954
+ self.hasListeners = YES;
955
+ #if TARGET_OS_OSX
956
+ [self setupMainWindowObservers];
957
+ #endif
958
+ }
959
+
960
+ - (void)stopObserving
961
+ {
962
+ self.hasListeners = NO;
963
+ // Native observers belong to this module, not a JS subscription. React may
964
+ // briefly remove every listener while effects update or a document closes.
965
+ // Keep lifecycle/restoration tracking alive until dealloc; event emission is
966
+ // already gated by hasListeners.
967
+ }
968
+
969
+ - (dispatch_queue_t)methodQueue
970
+ {
971
+ return dispatch_get_main_queue();
972
+ }
973
+
974
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
975
+ (const facebook::react::ObjCTurboModule::InitParams &)params
976
+ {
977
+ return std::make_shared<facebook::react::NativeWindowManagerSpecJSI>(params);
978
+ }
979
+
980
+ - (NSDictionary *)parseObjectJSON:(NSString *)json
981
+ {
982
+ NSData *data = [json dataUsingEncoding:NSUTF8StringEncoding];
983
+ if (!data) {
984
+ return @{};
985
+ }
986
+
987
+ id value = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
988
+ return [value isKindOfClass:NSDictionary.class] ? value : @{};
989
+ }
990
+
991
+ - (NSString *)jsonStringFromObject:(id)object
992
+ {
993
+ id value = object ?: [NSNull null];
994
+ NSData *data = [NSJSONSerialization dataWithJSONObject:value options:0 error:nil];
995
+ return data ? [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] : @"null";
996
+ }
997
+
998
+ #if TARGET_OS_OSX
999
+ - (void)removeTitlebarMaterialForIdentifier:(NSString *)identifier
1000
+ {
1001
+ NSView *materialView = self.titlebarMaterialViews[identifier];
1002
+ [materialView removeFromSuperview];
1003
+ [self.titlebarMaterialViews removeObjectForKey:identifier];
1004
+ }
1005
+
1006
+ - (NSView *)createTitlebarMaterialView:(NSString *)material frame:(NSRect)frame
1007
+ {
1008
+ if ([material isEqualToString:@"glass"]) {
1009
+ if (@available(macOS 26.0, *)) {
1010
+ return LegendCreateOverscannedGlassEffectView(frame);
1011
+ }
1012
+ }
1013
+
1014
+ NSVisualEffectView *effectView = [[NSVisualEffectView alloc] initWithFrame:frame];
1015
+ effectView.material = LegendVisualEffectMaterialForTitlebarMaterial(material);
1016
+ effectView.blendingMode = NSVisualEffectBlendingModeBehindWindow;
1017
+ effectView.state = NSVisualEffectStateFollowsWindowActiveState;
1018
+ effectView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
1019
+ effectView.wantsLayer = YES;
1020
+ effectView.layer.backgroundColor = NSColor.clearColor.CGColor;
1021
+ return effectView;
1022
+ }
1023
+
1024
+ - (void)applyTitlebarMaterialFromOptions:(NSDictionary *)options toWindow:(NSWindow *)window identifier:(NSString *)identifier
1025
+ {
1026
+ NSDictionary *windowStyle = [options[@"windowStyle"] isKindOfClass:NSDictionary.class] ? options[@"windowStyle"] : @{};
1027
+ if (!LegendDictionaryHasKey(windowStyle, @"titlebarMaterial")) {
1028
+ return;
1029
+ }
1030
+
1031
+ NSString *material = [windowStyle[@"titlebarMaterial"] isKindOfClass:NSString.class] ? windowStyle[@"titlebarMaterial"] : nil;
1032
+ [self removeTitlebarMaterialForIdentifier:identifier];
1033
+
1034
+ if (material.length == 0 || [material isEqualToString:@"none"]) {
1035
+ return;
1036
+ }
1037
+
1038
+ NSView *frameView = window.contentView.superview;
1039
+ if (!frameView) {
1040
+ return;
1041
+ }
1042
+
1043
+ NSView *materialView = [self createTitlebarMaterialView:material frame:LegendTitlebarMaterialFrame(window, frameView)];
1044
+ if ([materialView isKindOfClass:NSVisualEffectView.class]) {
1045
+ NSVisualEffectView *effectView = (NSVisualEffectView *)materialView;
1046
+ NSString *blendingMode = [windowStyle[@"titlebarMaterialBlendingMode"] isKindOfClass:NSString.class]
1047
+ ? windowStyle[@"titlebarMaterialBlendingMode"]
1048
+ : nil;
1049
+ NSString *state = [windowStyle[@"titlebarMaterialState"] isKindOfClass:NSString.class]
1050
+ ? windowStyle[@"titlebarMaterialState"]
1051
+ : nil;
1052
+ effectView.blendingMode = LegendVisualEffectBlendingModeForName(blendingMode);
1053
+ effectView.state = LegendVisualEffectStateForName(state);
1054
+ }
1055
+
1056
+ materialView.translatesAutoresizingMaskIntoConstraints = YES;
1057
+ materialView.autoresizingMask = NSViewWidthSizable | NSViewMinYMargin;
1058
+ [frameView addSubview:materialView positioned:NSWindowAbove relativeTo:window.contentView];
1059
+ self.titlebarMaterialViews[identifier] = materialView;
1060
+ }
1061
+
1062
+ - (void)removeTitlebarControlsForIdentifier:(NSString *)identifier fromWindow:(NSWindow *)window
1063
+ {
1064
+ NSArray<NSTitlebarAccessoryViewController *> *controllers = self.titlebarAccessoryControllers[identifier] ?: @[];
1065
+ for (NSTitlebarAccessoryViewController *controller in controllers) {
1066
+ NSUInteger index = [window.titlebarAccessoryViewControllers indexOfObjectIdenticalTo:controller];
1067
+ if (index != NSNotFound) {
1068
+ [window removeTitlebarAccessoryViewControllerAtIndex:index];
1069
+ }
1070
+ }
1071
+ [self.titlebarAccessoryControllers removeObjectForKey:identifier];
1072
+ }
1073
+
1074
+ - (void)applyTitlebarControlsFromOptions:(NSDictionary *)options toWindow:(NSWindow *)window identifier:(NSString *)identifier
1075
+ {
1076
+ NSDictionary *windowStyle = [options[@"windowStyle"] isKindOfClass:NSDictionary.class] ? options[@"windowStyle"] : @{};
1077
+ if (!LegendDictionaryHasKey(windowStyle, @"titlebarControls")) {
1078
+ return;
1079
+ }
1080
+
1081
+ [self removeTitlebarControlsForIdentifier:identifier fromWindow:window];
1082
+
1083
+ NSArray *titlebarControls = [windowStyle[@"titlebarControls"] isKindOfClass:NSArray.class]
1084
+ ? windowStyle[@"titlebarControls"]
1085
+ : @[];
1086
+ NSMutableArray<NSTitlebarAccessoryViewController *> *controllers = [NSMutableArray new];
1087
+
1088
+ for (id controlCandidate in titlebarControls) {
1089
+ if (![controlCandidate isKindOfClass:NSDictionary.class]) {
1090
+ continue;
1091
+ }
1092
+
1093
+ NSDictionary *control = (NSDictionary *)controlCandidate;
1094
+ NSString *type = [control[@"type"] isKindOfClass:NSString.class] ? control[@"type"] : nil;
1095
+ NSString *controlId = [control[@"id"] isKindOfClass:NSString.class] ? control[@"id"] : nil;
1096
+ if (![type isEqualToString:@"button"] || controlId.length == 0) {
1097
+ continue;
1098
+ }
1099
+
1100
+ NSString *label = [control[@"label"] isKindOfClass:NSString.class] ? control[@"label"] : controlId;
1101
+ NSString *systemImageName = [control[@"systemImageName"] isKindOfClass:NSString.class] ? control[@"systemImageName"] : nil;
1102
+ NSImage *image = nil;
1103
+ if (systemImageName.length > 0) {
1104
+ if (@available(macOS 11.0, *)) {
1105
+ image = [NSImage imageWithSystemSymbolName:systemImageName accessibilityDescription:label];
1106
+ }
1107
+ }
1108
+
1109
+ NSSegmentedControl *segmentedControl = [[NSSegmentedControl alloc] initWithFrame:NSZeroRect];
1110
+ segmentedControl.segmentCount = 1;
1111
+ segmentedControl.segmentStyle = NSSegmentStyleSeparated;
1112
+ segmentedControl.trackingMode = NSSegmentSwitchTrackingSelectAny;
1113
+ [segmentedControl setSelected:[control[@"selected"] boolValue] forSegment:0];
1114
+ segmentedControl.target = self;
1115
+ segmentedControl.action = @selector(titlebarControlPressed:);
1116
+ segmentedControl.controlSize = NSControlSizeRegular;
1117
+ [segmentedControl setEnabled:LegendDictionaryHasKey(control, @"enabled") ? [control[@"enabled"] boolValue] : YES forSegment:0];
1118
+ if (image) {
1119
+ [segmentedControl setImage:image forSegment:0];
1120
+ [segmentedControl setImageScaling:NSImageScaleProportionallyDown forSegment:0];
1121
+ } else {
1122
+ [segmentedControl setLabel:label forSegment:0];
1123
+ }
1124
+ if (@available(macOS 10.13, *)) {
1125
+ [segmentedControl setToolTip:[control[@"tooltip"] isKindOfClass:NSString.class] ? control[@"tooltip"] : label forSegment:0];
1126
+ }
1127
+ CGFloat segmentWidth = image ? 36 : MAX(84, [label sizeWithAttributes:@{NSFontAttributeName: segmentedControl.font ?: [NSFont systemFontOfSize:NSFont.systemFontSize]}].width + 24);
1128
+ [segmentedControl setWidth:segmentWidth forSegment:0];
1129
+ segmentedControl.frame = NSMakeRect(0, 0, segmentWidth, MAX(28, segmentedControl.fittingSize.height));
1130
+ objc_setAssociatedObject(segmentedControl, &LegendTitlebarControlMetadataKey, @{
1131
+ @"controlId": controlId,
1132
+ @"windowIdentifier": identifier ?: @"",
1133
+ @"instanceId": objc_getAssociatedObject(window, NSSelectorFromString(@"sparkWindowInstanceId")) ?: @"",
1134
+ @"selected": control[@"selected"] ?: @NO,
1135
+ }, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
1136
+
1137
+ NSTitlebarAccessoryViewController *controller = [NSTitlebarAccessoryViewController new];
1138
+ controller.view = segmentedControl;
1139
+ NSString *placement = [control[@"placement"] isKindOfClass:NSString.class] ? control[@"placement"] : @"left";
1140
+ controller.layoutAttribute = [placement isEqualToString:@"right"] ? NSLayoutAttributeRight : NSLayoutAttributeLeft;
1141
+ [window addTitlebarAccessoryViewController:controller];
1142
+ [controllers addObject:controller];
1143
+ }
1144
+
1145
+ self.titlebarAccessoryControllers[identifier] = controllers;
1146
+ }
1147
+
1148
+ - (void)titlebarControlPressed:(id)sender
1149
+ {
1150
+ id metadata = objc_getAssociatedObject(sender, &LegendTitlebarControlMetadataKey);
1151
+ NSDictionary *representedObject = [metadata isKindOfClass:NSDictionary.class]
1152
+ ? metadata
1153
+ : @{};
1154
+ NSString *identifier = [representedObject[@"windowIdentifier"] isKindOfClass:NSString.class]
1155
+ ? representedObject[@"windowIdentifier"]
1156
+ : @"";
1157
+ NSString *controlId = [representedObject[@"controlId"] isKindOfClass:NSString.class]
1158
+ ? representedObject[@"controlId"]
1159
+ : @"";
1160
+
1161
+ if ([sender isKindOfClass:NSSegmentedControl.class]) [(NSSegmentedControl *)sender setSelected:[representedObject[@"selected"] boolValue] forSegment:0];
1162
+ [self sendWindowEventWithName:@"onTitlebarControlPressed"
1163
+ body:@{@"identifier": identifier, @"controlId": controlId, @"instanceId": representedObject[@"instanceId"] ?: @""}];
1164
+ }
1165
+
1166
+ - (NSString *)toolbarItemIdentifierForConfig:(NSDictionary *)config
1167
+ {
1168
+ NSString *itemId = [config[@"id"] isKindOfClass:NSString.class] ? config[@"id"] : nil;
1169
+ return itemId.length > 0 ? [@"legend.toolbar." stringByAppendingString:itemId] : nil;
1170
+ }
1171
+
1172
+ - (NSDictionary *)toolbarItemConfigForIdentifier:(NSToolbarItemIdentifier)itemIdentifier toolbar:(NSToolbar *)toolbar
1173
+ {
1174
+ if (![itemIdentifier hasPrefix:@"legend.toolbar."]) {
1175
+ return nil;
1176
+ }
1177
+
1178
+ NSArray<NSDictionary *> *configs = self.toolbarItemConfigs[toolbar.identifier] ?: @[];
1179
+ for (NSDictionary *config in configs) {
1180
+ NSString *configIdentifier = [self toolbarItemIdentifierForConfig:config];
1181
+ if ([configIdentifier isEqualToString:itemIdentifier]) {
1182
+ return config;
1183
+ }
1184
+ }
1185
+ return nil;
1186
+ }
1187
+
1188
+ - (NSArray<NSToolbarItemIdentifier> *)toolbarItemIdentifiersForToolbar:(NSToolbar *)toolbar
1189
+ {
1190
+ NSMutableArray<NSToolbarItemIdentifier> *leadingIdentifiers = [NSMutableArray new];
1191
+ NSMutableArray<NSToolbarItemIdentifier> *trailingIdentifiers = [NSMutableArray new];
1192
+ NSArray<NSDictionary *> *configs = self.toolbarItemConfigs[toolbar.identifier] ?: @[];
1193
+ for (NSDictionary *config in configs) {
1194
+ NSString *itemIdentifier = [self toolbarItemIdentifierForConfig:config];
1195
+ if (itemIdentifier.length > 0) {
1196
+ NSString *placement = [config[@"placement"] isKindOfClass:NSString.class] ? config[@"placement"] : @"trailing";
1197
+ if ([placement isEqualToString:@"leading"]) {
1198
+ [leadingIdentifiers addObject:itemIdentifier];
1199
+ } else {
1200
+ [trailingIdentifiers addObject:itemIdentifier];
1201
+ }
1202
+ }
1203
+ }
1204
+ NSMutableArray<NSToolbarItemIdentifier> *identifiers = [NSMutableArray new];
1205
+ [identifiers addObjectsFromArray:leadingIdentifiers];
1206
+ [identifiers addObject:NSToolbarFlexibleSpaceItemIdentifier];
1207
+ [identifiers addObjectsFromArray:trailingIdentifiers];
1208
+ return identifiers;
1209
+ }
1210
+
1211
+ - (NSToolbar *)ensureToolbarForWindow:(NSWindow *)window identifier:(NSString *)identifier
1212
+ {
1213
+ NSToolbar *toolbar = window.toolbar;
1214
+ if (!toolbar || !objc_getAssociatedObject(toolbar, &LegendToolbarWindowIdentifierKey)) {
1215
+ toolbar = LegendCreateToolbar(identifier);
1216
+ window.toolbar = toolbar;
1217
+ }
1218
+ toolbar.delegate = self;
1219
+ toolbar.allowsUserCustomization = NO;
1220
+ toolbar.autosavesConfiguration = NO;
1221
+ return toolbar;
1222
+ }
1223
+
1224
+ - (void)applyToolbarItemsFromOptions:(NSDictionary *)options toWindow:(NSWindow *)window identifier:(NSString *)identifier
1225
+ {
1226
+ NSDictionary *windowStyle = [options[@"windowStyle"] isKindOfClass:NSDictionary.class] ? options[@"windowStyle"] : @{};
1227
+ if (!LegendDictionaryHasKey(windowStyle, @"toolbarItems")) {
1228
+ return;
1229
+ }
1230
+
1231
+ NSArray *toolbarItems = [windowStyle[@"toolbarItems"] isKindOfClass:NSArray.class] ? windowStyle[@"toolbarItems"] : @[];
1232
+ NSToolbar *toolbar = [self ensureToolbarForWindow:window identifier:identifier];
1233
+ NSMutableArray<NSDictionary *> *configs = [NSMutableArray new];
1234
+ for (id item in toolbarItems) {
1235
+ if ([item isKindOfClass:NSDictionary.class]) {
1236
+ NSMutableDictionary *config = [item mutableCopy]; config[@"instanceId"] = objc_getAssociatedObject(window, NSSelectorFromString(@"sparkWindowInstanceId")) ?: @""; [configs addObject:config];
1237
+ }
1238
+ }
1239
+ NSArray<NSDictionary *> *previousConfigs = self.toolbarItemConfigs[toolbar.identifier];
1240
+ BOOL menuUpdate = previousConfigs != nil && previousConfigs.count == configs.count;
1241
+ for (NSUInteger index = 0; menuUpdate && index < configs.count; index++) {
1242
+ NSMutableDictionary *previous = [previousConfigs[index] mutableCopy];
1243
+ NSMutableDictionary *next = [configs[index] mutableCopy];
1244
+ if ([next[@"type"] isEqual:@"menuButton"]) {
1245
+ [previous removeObjectForKey:@"menuItems"];
1246
+ [next removeObjectForKey:@"menuItems"];
1247
+ }
1248
+ menuUpdate = [previous isEqualToDictionary:next];
1249
+ }
1250
+ self.toolbarItemConfigs[toolbar.identifier] = configs;
1251
+ if (menuUpdate) {
1252
+ for (NSDictionary *config in configs) {
1253
+ if (![config[@"type"] isEqual:@"menuButton"]) continue;
1254
+ NSString *itemId = config[@"id"];
1255
+ if (![itemId isKindOfClass:NSString.class] || itemId.length == 0) { menuUpdate = NO; break; }
1256
+ NSString *itemIdentifier = [@"legend.toolbar." stringByAppendingString:itemId];
1257
+ NSToolbarItem *item = nil;
1258
+ for (NSToolbarItem *candidate in toolbar.items) {
1259
+ if ([candidate.itemIdentifier isEqual:itemIdentifier]) { item = candidate; break; }
1260
+ }
1261
+ id control = item.view ?: item;
1262
+ NSDictionary *metadata = control ? objc_getAssociatedObject(control, &LegendToolbarControlMetadataKey) : nil;
1263
+ if (!metadata) { menuUpdate = NO; break; }
1264
+ NSMutableDictionary *nextMetadata = [metadata mutableCopy];
1265
+ nextMetadata[@"menuItems"] = config[@"menuItems"] ?: @[];
1266
+ objc_setAssociatedObject(control, &LegendToolbarControlMetadataKey, nextMetadata, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
1267
+ }
1268
+ if (menuUpdate) return;
1269
+ }
1270
+
1271
+ while (toolbar.items.count > 0) {
1272
+ [toolbar removeItemAtIndex:toolbar.items.count - 1];
1273
+ }
1274
+ for (NSToolbarItemIdentifier itemIdentifier in [self toolbarDefaultItemIdentifiers:toolbar]) {
1275
+ [toolbar insertItemWithItemIdentifier:itemIdentifier atIndex:toolbar.items.count];
1276
+ }
1277
+ }
1278
+
1279
+ - (NSArray<NSToolbarItemIdentifier> *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar
1280
+ {
1281
+ NSMutableArray<NSToolbarItemIdentifier> *identifiers = [[self toolbarItemIdentifiersForToolbar:toolbar] mutableCopy];
1282
+ [identifiers addObject:NSToolbarSpaceItemIdentifier];
1283
+ return identifiers;
1284
+ }
1285
+
1286
+ - (NSArray<NSToolbarItemIdentifier> *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar
1287
+ {
1288
+ return [self toolbarItemIdentifiersForToolbar:toolbar];
1289
+ }
1290
+
1291
+ - (NSArray<NSToolbarItemIdentifier> *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar
1292
+ {
1293
+ return @[];
1294
+ }
1295
+
1296
+ - (NSImage *)toolbarSearchImageWithLabel:(NSString *)label
1297
+ {
1298
+ if (@available(macOS 11.0, *)) {
1299
+ return [NSImage imageWithSystemSymbolName:@"magnifyingglass" accessibilityDescription:label ?: @"Search"];
1300
+ }
1301
+ return [NSImage imageNamed:NSImageNameTouchBarSearchTemplate];
1302
+ }
1303
+
1304
+ - (void)focusToolbarSearchField:(NSSearchField *)searchField
1305
+ {
1306
+ id metadata = objc_getAssociatedObject(searchField, &LegendToolbarControlMetadataKey);
1307
+ NSDictionary *representedObject = [metadata isKindOfClass:NSDictionary.class]
1308
+ ? metadata
1309
+ : @{};
1310
+ NSString *identifier = [representedObject[@"windowIdentifier"] isKindOfClass:NSString.class]
1311
+ ? representedObject[@"windowIdentifier"]
1312
+ : @"";
1313
+ NSWindow *window = (NSWindow *)self.windows[identifier];
1314
+ [window makeKeyAndOrderFront:nil];
1315
+ [window makeFirstResponder:searchField];
1316
+ }
1317
+
1318
+ - (void)setToolbarSearchItem:(NSToolbarItem *)toolbarItem
1319
+ expanded:(BOOL)expanded
1320
+ value:(NSString *)value
1321
+ focus:(BOOL)focus
1322
+ sendChange:(BOOL)sendChange
1323
+ animated:(BOOL)animated
1324
+ {
1325
+ if (!toolbarItem) {
1326
+ return;
1327
+ }
1328
+
1329
+ id associatedField = objc_getAssociatedObject(toolbarItem, &LegendToolbarSearchFieldKey);
1330
+ id associatedButton = objc_getAssociatedObject(toolbarItem, &LegendToolbarSearchButtonKey);
1331
+ id associatedContainer = objc_getAssociatedObject(toolbarItem, &LegendToolbarSearchContainerKey);
1332
+ id associatedWidthConstraint = objc_getAssociatedObject(toolbarItem, &LegendToolbarSearchWidthConstraintKey);
1333
+ if (![associatedField isKindOfClass:NSSearchField.class]) {
1334
+ return;
1335
+ }
1336
+
1337
+ NSSearchField *searchField = (NSSearchField *)associatedField;
1338
+ NSButton *button = [associatedButton isKindOfClass:NSButton.class] ? (NSButton *)associatedButton : nil;
1339
+ NSView *container = [associatedContainer isKindOfClass:NSView.class] ? (NSView *)associatedContainer : toolbarItem.view;
1340
+ NSLayoutConstraint *widthConstraint = [associatedWidthConstraint isKindOfClass:NSLayoutConstraint.class]
1341
+ ? (NSLayoutConstraint *)associatedWidthConstraint
1342
+ : nil;
1343
+ NSNumber *widthNumber = objc_getAssociatedObject(toolbarItem, &LegendToolbarSearchWidthKey);
1344
+ CGFloat width = [widthNumber isKindOfClass:NSNumber.class] ? widthNumber.doubleValue : 240;
1345
+ CGFloat targetWidth = expanded ? width : LegendToolbarSearchCollapsedSize;
1346
+
1347
+ if (value) {
1348
+ searchField.stringValue = value;
1349
+ }
1350
+ if (expanded) {
1351
+ searchField.hidden = NO;
1352
+ button.hidden = NO;
1353
+ }
1354
+ if (focus) {
1355
+ [self focusToolbarSearchField:searchField];
1356
+ }
1357
+ if (container) {
1358
+ NSRect frame = container.frame;
1359
+ frame.size.width = targetWidth;
1360
+ if (animated) {
1361
+ [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
1362
+ context.duration = 0.18;
1363
+ context.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
1364
+ widthConstraint.animator.constant = targetWidth;
1365
+ container.animator.frame = frame;
1366
+ searchField.animator.alphaValue = expanded ? 1 : 0;
1367
+ button.animator.alphaValue = expanded ? 0 : 1;
1368
+ [container.superview.animator layoutSubtreeIfNeeded];
1369
+ [container.animator layoutSubtreeIfNeeded];
1370
+ } completionHandler:^{
1371
+ button.hidden = expanded;
1372
+ searchField.hidden = !expanded;
1373
+ }];
1374
+ } else {
1375
+ widthConstraint.constant = targetWidth;
1376
+ container.frame = frame;
1377
+ searchField.alphaValue = expanded ? 1 : 0;
1378
+ button.alphaValue = expanded ? 0 : 1;
1379
+ button.hidden = expanded;
1380
+ searchField.hidden = !expanded;
1381
+ [container layoutSubtreeIfNeeded];
1382
+ }
1383
+ }
1384
+ if (sendChange) {
1385
+ [self sendToolbarSearchEventForField:searchField submitted:NO shiftKey:NO];
1386
+ }
1387
+ }
1388
+
1389
+ - (void)collapseToolbarSearchItem:(NSToolbarItem *)toolbarItem animated:(BOOL)animated
1390
+ {
1391
+ [self setToolbarSearchItem:toolbarItem
1392
+ expanded:NO
1393
+ value:nil
1394
+ focus:NO
1395
+ sendChange:NO
1396
+ animated:animated];
1397
+ }
1398
+
1399
+ - (void)expandToolbarSearchItem:(NSToolbarItem *)toolbarItem
1400
+ value:(NSString *)value
1401
+ focus:(BOOL)focus
1402
+ sendChange:(BOOL)sendChange
1403
+ animated:(BOOL)animated
1404
+ {
1405
+ [self setToolbarSearchItem:toolbarItem
1406
+ expanded:YES
1407
+ value:value
1408
+ focus:focus
1409
+ sendChange:sendChange
1410
+ animated:animated];
1411
+ }
1412
+
1413
+ - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar
1414
+ itemForItemIdentifier:(NSToolbarItemIdentifier)itemIdentifier
1415
+ willBeInsertedIntoToolbar:(BOOL)flag
1416
+ {
1417
+ NSDictionary *config = [self toolbarItemConfigForIdentifier:itemIdentifier toolbar:toolbar];
1418
+ if (!config) {
1419
+ return nil;
1420
+ }
1421
+
1422
+ NSString *type = [config[@"type"] isKindOfClass:NSString.class] ? config[@"type"] : nil;
1423
+ if ([type isEqualToString:@"button"] || [type isEqualToString:@"menuButton"]) {
1424
+ NSString *itemId = [config[@"id"] isKindOfClass:NSString.class] ? config[@"id"] : @"";
1425
+ NSString *label = [config[@"label"] isKindOfClass:NSString.class] ? config[@"label"] : itemId;
1426
+ NSString *tooltip = [config[@"tooltip"] isKindOfClass:NSString.class] ? config[@"tooltip"] : label;
1427
+ NSString *systemImageName = [config[@"systemImageName"] isKindOfClass:NSString.class] ? config[@"systemImageName"] : nil;
1428
+ NSImage *image = nil;
1429
+ if (systemImageName.length > 0) {
1430
+ if (@available(macOS 11.0, *)) {
1431
+ image = [NSImage imageWithSystemSymbolName:systemImageName accessibilityDescription:label];
1432
+ }
1433
+ }
1434
+ NSArray *menuItems = [config[@"menuItems"] isKindOfClass:NSArray.class] ? config[@"menuItems"] : @[];
1435
+ NSNumber *widthNumber = [config[@"width"] isKindOfClass:NSNumber.class] ? config[@"width"] : nil;
1436
+ BOOL isMenuButton = [type isEqualToString:@"menuButton"] || menuItems.count > 0;
1437
+
1438
+ NSToolbarItem *toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
1439
+ toolbarItem.label = label;
1440
+ toolbarItem.paletteLabel = label;
1441
+ toolbarItem.toolTip = tooltip;
1442
+ toolbarItem.enabled = LegendDictionaryHasKey(config, @"enabled") ? [config[@"enabled"] boolValue] : YES;
1443
+ NSString *placement = [config[@"placement"] isKindOfClass:NSString.class] ? config[@"placement"] : @"trailing";
1444
+ if (@available(macOS 10.15, *)) {
1445
+ toolbarItem.bordered = LegendDictionaryHasKey(config, @"bordered") ? [config[@"bordered"] boolValue] : YES;
1446
+ }
1447
+ if (@available(macOS 11.0, *)) {
1448
+ toolbarItem.navigational = [placement isEqualToString:@"leading"];
1449
+ }
1450
+ NSDictionary *metadata = @{
1451
+ @"itemId": itemId,
1452
+ @"menuItems": menuItems,
1453
+ @"value": [config[@"value"] isKindOfClass:NSString.class] ? config[@"value"] : @"",
1454
+ @"windowIdentifier": LegendToolbarWindowIdentifier(toolbar),
1455
+ @"instanceId": config[@"instanceId"] ?: @"",
1456
+ };
1457
+ if (isMenuButton) {
1458
+ // The fallback name identifies the item; it is never what the control displays, so an
1459
+ // item without a label stays a bare icon instead of printing that identifier.
1460
+ NSString *title = [config[@"label"] isKindOfClass:NSString.class] ? config[@"label"] : @"";
1461
+ NSButton *button = [NSButton buttonWithTitle:title target:self action:@selector(toolbarButtonItemPressed:)];
1462
+ button.bezelStyle = NSBezelStyleRounded;
1463
+ button.controlSize = NSControlSizeRegular;
1464
+ button.enabled = toolbarItem.enabled;
1465
+ button.toolTip = tooltip;
1466
+ if (LegendDictionaryHasKey(config, @"monospacedDigits") && [config[@"monospacedDigits"] boolValue]) {
1467
+ button.font = [NSFont monospacedDigitSystemFontOfSize:NSFont.systemFontSize weight:NSFontWeightSemibold];
1468
+ }
1469
+ if (image) {
1470
+ button.image = image;
1471
+ button.imagePosition = title.length > 0 ? NSImageLeft : NSImageOnly;
1472
+ }
1473
+ NSFont *font = button.font ?: [NSFont systemFontOfSize:NSFont.systemFontSize];
1474
+ CGFloat textWidth = [title sizeWithAttributes:@{NSFontAttributeName: font}].width + (title.length > 0 ? (image ? 64 : 52) : 0);
1475
+ CGFloat buttonWidth = widthNumber ? widthNumber.doubleValue
1476
+ : MAX(title.length > 0 ? 148 : LegendToolbarIconControlWidth, textWidth);
1477
+ button.frame = NSMakeRect(0, 0, buttonWidth, MAX(28, button.fittingSize.height));
1478
+ objc_setAssociatedObject(button, &LegendToolbarControlMetadataKey, metadata, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
1479
+ toolbarItem.view = button;
1480
+ } else {
1481
+ toolbarItem.image = image;
1482
+ toolbarItem.target = self;
1483
+ toolbarItem.action = @selector(toolbarButtonItemPressed:);
1484
+ objc_setAssociatedObject(toolbarItem, &LegendToolbarControlMetadataKey, metadata, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
1485
+ }
1486
+ return toolbarItem;
1487
+ }
1488
+
1489
+ if ([type isEqualToString:@"label"]) {
1490
+ NSString *itemId = [config[@"id"] isKindOfClass:NSString.class] ? config[@"id"] : @"";
1491
+ NSString *label = [config[@"label"] isKindOfClass:NSString.class] ? config[@"label"] : itemId;
1492
+ NSString *text = [config[@"text"] isKindOfClass:NSString.class] ? config[@"text"] : @"";
1493
+ NSNumber *widthNumber = [config[@"width"] isKindOfClass:NSNumber.class] ? config[@"width"] : nil;
1494
+ CGFloat width = widthNumber ? widthNumber.doubleValue : MAX(44, [text sizeWithAttributes:nil].width + 12);
1495
+
1496
+ NSTextField *textField = [NSTextField labelWithString:text];
1497
+ textField.translatesAutoresizingMaskIntoConstraints = NO;
1498
+ textField.alignment = NSTextAlignmentRight;
1499
+ textField.font = [NSFont monospacedDigitSystemFontOfSize:NSFont.systemFontSize weight:NSFontWeightSemibold];
1500
+ textField.textColor = NSColor.labelColor;
1501
+ textField.toolTip = label;
1502
+ [textField.widthAnchor constraintEqualToConstant:width].active = YES;
1503
+
1504
+ NSToolbarItem *toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
1505
+ toolbarItem.view = textField;
1506
+ toolbarItem.label = label;
1507
+ toolbarItem.paletteLabel = label;
1508
+ toolbarItem.toolTip = label;
1509
+ return toolbarItem;
1510
+ }
1511
+
1512
+ if ([type isEqualToString:@"search"]) {
1513
+ NSString *itemId = [config[@"id"] isKindOfClass:NSString.class] ? config[@"id"] : @"";
1514
+ NSString *label = [config[@"label"] isKindOfClass:NSString.class] ? config[@"label"] : itemId;
1515
+ NSString *placeholder = [config[@"placeholder"] isKindOfClass:NSString.class] ? config[@"placeholder"] : @"Search";
1516
+ NSString *value = [config[@"value"] isKindOfClass:NSString.class] ? config[@"value"] : @"";
1517
+ NSNumber *widthNumber = [config[@"width"] isKindOfClass:NSNumber.class] ? config[@"width"] : nil;
1518
+ CGFloat width = widthNumber ? widthNumber.doubleValue : 240;
1519
+ BOOL collapses = LegendDictionaryHasKey(config, @"collapses") && [config[@"collapses"] boolValue];
1520
+ NSDictionary *metadata = @{
1521
+ @"itemId": itemId,
1522
+ @"windowIdentifier": LegendToolbarWindowIdentifier(toolbar),
1523
+ @"instanceId": config[@"instanceId"] ?: @"",
1524
+ };
1525
+
1526
+ NSSearchField *searchField = nil;
1527
+ NSToolbarItem *toolbarItem = nil;
1528
+ if (collapses) {
1529
+ CGFloat initialWidth = value.length > 0 ? width : LegendToolbarSearchCollapsedSize;
1530
+ NSView *container = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, initialWidth, LegendToolbarSearchCollapsedSize)];
1531
+ container.translatesAutoresizingMaskIntoConstraints = NO;
1532
+ NSLayoutConstraint *containerWidthConstraint = [container.widthAnchor constraintEqualToConstant:initialWidth];
1533
+ containerWidthConstraint.active = YES;
1534
+ [container.heightAnchor constraintEqualToConstant:LegendToolbarSearchCollapsedSize].active = YES;
1535
+
1536
+ NSButton *searchButton = [NSButton buttonWithImage:[self toolbarSearchImageWithLabel:label]
1537
+ target:self
1538
+ action:@selector(toolbarSearchButtonPressed:)];
1539
+ searchButton.translatesAutoresizingMaskIntoConstraints = NO;
1540
+ searchButton.bordered = YES;
1541
+ searchButton.bezelStyle = NSBezelStyleCircular;
1542
+ searchButton.controlSize = NSControlSizeRegular;
1543
+ searchButton.imagePosition = NSImageOnly;
1544
+ searchButton.toolTip = placeholder;
1545
+ searchButton.enabled = LegendDictionaryHasKey(config, @"enabled") ? [config[@"enabled"] boolValue] : YES;
1546
+ [container addSubview:searchButton];
1547
+ [NSLayoutConstraint activateConstraints:@[
1548
+ [searchButton.centerXAnchor constraintEqualToAnchor:container.centerXAnchor],
1549
+ [searchButton.centerYAnchor constraintEqualToAnchor:container.centerYAnchor],
1550
+ [searchButton.widthAnchor constraintEqualToConstant:LegendToolbarSearchCollapsedSize],
1551
+ [searchButton.heightAnchor constraintEqualToConstant:LegendToolbarSearchCollapsedSize],
1552
+ ]];
1553
+
1554
+ searchField = [[NSSearchField alloc] initWithFrame:NSMakeRect(0, 0, width, 28)];
1555
+ searchField.translatesAutoresizingMaskIntoConstraints = NO;
1556
+ searchField.hidden = value.length == 0;
1557
+ searchField.alphaValue = value.length > 0 ? 1 : 0;
1558
+ searchButton.hidden = value.length > 0;
1559
+ searchButton.alphaValue = value.length > 0 ? 0 : 1;
1560
+ [container addSubview:searchField];
1561
+ [NSLayoutConstraint activateConstraints:@[
1562
+ [searchField.leadingAnchor constraintEqualToAnchor:container.leadingAnchor],
1563
+ [searchField.trailingAnchor constraintEqualToAnchor:container.trailingAnchor],
1564
+ [searchField.topAnchor constraintEqualToAnchor:container.topAnchor],
1565
+ [searchField.bottomAnchor constraintEqualToAnchor:container.bottomAnchor],
1566
+ ]];
1567
+ toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
1568
+ toolbarItem.view = container;
1569
+ objc_setAssociatedObject(toolbarItem, &LegendToolbarSearchFieldKey, searchField, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
1570
+ objc_setAssociatedObject(toolbarItem, &LegendToolbarSearchWidthKey, @(width), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
1571
+ objc_setAssociatedObject(toolbarItem, &LegendToolbarSearchButtonKey, searchButton, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
1572
+ objc_setAssociatedObject(toolbarItem, &LegendToolbarSearchContainerKey, container, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
1573
+ objc_setAssociatedObject(toolbarItem, &LegendToolbarSearchWidthConstraintKey, containerWidthConstraint, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
1574
+ objc_setAssociatedObject(searchButton, &LegendToolbarSearchItemKey, toolbarItem, OBJC_ASSOCIATION_ASSIGN);
1575
+ objc_setAssociatedObject(searchField, &LegendToolbarSearchItemKey, toolbarItem, OBJC_ASSOCIATION_ASSIGN);
1576
+ } else if (@available(macOS 11.0, *)) {
1577
+ NSSearchToolbarItem *searchToolbarItem = [[NSSearchToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
1578
+ searchField = searchToolbarItem.searchField;
1579
+ toolbarItem = searchToolbarItem;
1580
+ } else {
1581
+ searchField = [[NSSearchField alloc] initWithFrame:NSMakeRect(0, 0, width, 28)];
1582
+ toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
1583
+ toolbarItem.view = searchField;
1584
+ }
1585
+
1586
+ searchField.placeholderString = placeholder;
1587
+ searchField.stringValue = value;
1588
+ searchField.delegate = self;
1589
+ searchField.target = self;
1590
+ searchField.action = @selector(toolbarSearchSubmitted:);
1591
+ searchField.enabled = LegendDictionaryHasKey(config, @"enabled") ? [config[@"enabled"] boolValue] : YES;
1592
+ searchField.controlSize = NSControlSizeRegular;
1593
+ objc_setAssociatedObject(searchField, &LegendToolbarControlMetadataKey, metadata, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
1594
+
1595
+ toolbarItem.label = label;
1596
+ toolbarItem.paletteLabel = label;
1597
+ toolbarItem.toolTip = placeholder;
1598
+ toolbarItem.enabled = searchField.enabled;
1599
+ if (collapses) {
1600
+ searchField.enabled = toolbarItem.enabled;
1601
+ } else {
1602
+ toolbarItem.minSize = NSMakeSize(MIN(width, 120), 28);
1603
+ toolbarItem.maxSize = NSMakeSize(width, 28);
1604
+ }
1605
+ return toolbarItem;
1606
+ }
1607
+
1608
+ if (![type isEqualToString:@"segmented"]) {
1609
+ return nil;
1610
+ }
1611
+
1612
+ NSArray *segments = [config[@"segments"] isKindOfClass:NSArray.class] ? config[@"segments"] : @[];
1613
+ NSMutableArray<NSString *> *labels = [NSMutableArray new];
1614
+ NSMutableArray<NSString *> *systemImageNames = [NSMutableArray new];
1615
+ NSMutableArray<NSString *> *values = [NSMutableArray new];
1616
+ NSInteger selectedSegment = -1;
1617
+ NSString *selectedValue = [config[@"selectedValue"] isKindOfClass:NSString.class] ? config[@"selectedValue"] : nil;
1618
+
1619
+ for (id segment in segments) {
1620
+ if ([segment isKindOfClass:NSDictionary.class]) {
1621
+ NSDictionary *segmentConfig = (NSDictionary *)segment;
1622
+ NSString *label = [segmentConfig[@"label"] isKindOfClass:NSString.class] ? segmentConfig[@"label"] : @"";
1623
+ NSString *value = [segmentConfig[@"value"] isKindOfClass:NSString.class] ? segmentConfig[@"value"] : label;
1624
+ if (label.length > 0 && value != nil) {
1625
+ NSString *systemImageName = [segmentConfig[@"systemImageName"] isKindOfClass:NSString.class]
1626
+ ? segmentConfig[@"systemImageName"]
1627
+ : @"";
1628
+ if ([value isEqualToString:selectedValue]) {
1629
+ selectedSegment = values.count;
1630
+ }
1631
+ [labels addObject:label];
1632
+ [systemImageNames addObject:systemImageName];
1633
+ [values addObject:value];
1634
+ }
1635
+ }
1636
+ }
1637
+
1638
+ if (labels.count == 0) {
1639
+ return nil;
1640
+ }
1641
+
1642
+ NSSegmentedControl *control = [[NSSegmentedControl alloc] initWithFrame:NSZeroRect];
1643
+ control.segmentCount = labels.count;
1644
+ control.trackingMode = NSSegmentSwitchTrackingSelectOne;
1645
+ control.target = self;
1646
+ control.action = @selector(toolbarSegmentedControlChanged:);
1647
+ control.controlSize = NSControlSizeRegular;
1648
+ control.segmentStyle = NSSegmentStyleAutomatic;
1649
+ control.selectedSegment = selectedSegment;
1650
+
1651
+ CGFloat totalWidth = 0;
1652
+ for (NSInteger index = 0; index < labels.count; index += 1) {
1653
+ NSString *systemImageName = systemImageNames[index];
1654
+ NSImage *image = nil;
1655
+ if (systemImageName.length > 0) {
1656
+ if (@available(macOS 11.0, *)) {
1657
+ image = [NSImage imageWithSystemSymbolName:systemImageName accessibilityDescription:labels[index]];
1658
+ }
1659
+ }
1660
+ if (image) {
1661
+ [control setImage:image forSegment:index];
1662
+ [control setToolTip:labels[index] forSegment:index];
1663
+ } else {
1664
+ [control setLabel:labels[index] forSegment:index];
1665
+ }
1666
+
1667
+ NSFont *font = control.font ?: [NSFont systemFontOfSize:NSFont.systemFontSize];
1668
+ CGFloat width = image ? 38 : MAX(76, [labels[index] sizeWithAttributes:@{NSFontAttributeName: font}].width + 28);
1669
+ [control setWidth:width forSegment:index];
1670
+ totalWidth += width;
1671
+ }
1672
+
1673
+ NSString *itemId = [config[@"id"] isKindOfClass:NSString.class] ? config[@"id"] : @"";
1674
+ objc_setAssociatedObject(control, &LegendToolbarControlMetadataKey, @{
1675
+ @"itemId": itemId,
1676
+ @"values": values,
1677
+ @"windowIdentifier": LegendToolbarWindowIdentifier(toolbar),
1678
+ @"instanceId": config[@"instanceId"] ?: @"",
1679
+ }, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
1680
+ control.frame = NSMakeRect(0, 0, totalWidth, control.fittingSize.height);
1681
+
1682
+ NSToolbarItem *toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
1683
+ toolbarItem.view = control;
1684
+ toolbarItem.label = [config[@"label"] isKindOfClass:NSString.class] ? config[@"label"] : itemId;
1685
+ toolbarItem.paletteLabel = toolbarItem.label;
1686
+ return toolbarItem;
1687
+ }
1688
+
1689
+ - (void)toolbarMenuSliderChanged:(NSSlider *)sender
1690
+ {
1691
+ NSDictionary *metadata = objc_getAssociatedObject(sender, &LegendToolbarControlMetadataKey);
1692
+ double value = sender.doubleValue;
1693
+ NSTextField *readout = [sender.superview viewWithTag:731];
1694
+ readout.stringValue = [NSString stringWithFormat:@"%g%@", value, metadata[@"suffix"] ?: @""];
1695
+ [self sendWindowEventWithName:@"onToolbarItemSelected" body:@{
1696
+ @"identifier": metadata[@"windowIdentifier"], @"itemId": metadata[@"itemId"],
1697
+ @"instanceId": metadata[@"instanceId"] ?: @"",
1698
+ @"action": @{ @"type": @"valueChanged", @"itemId": metadata[@"value"], @"value": @(value) },
1699
+ }];
1700
+ }
1701
+
1702
+ - (void)toolbarMenuItemSelected:(NSMenuItem *)sender
1703
+ {
1704
+ NSDictionary *representedObject = [sender.representedObject isKindOfClass:NSDictionary.class]
1705
+ ? sender.representedObject
1706
+ : @{};
1707
+ NSString *identifier = [representedObject[@"windowIdentifier"] isKindOfClass:NSString.class]
1708
+ ? representedObject[@"windowIdentifier"]
1709
+ : @"";
1710
+ NSString *itemId = [representedObject[@"itemId"] isKindOfClass:NSString.class]
1711
+ ? representedObject[@"itemId"]
1712
+ : @"";
1713
+ NSString *value = [representedObject[@"value"] isKindOfClass:NSString.class]
1714
+ ? representedObject[@"value"]
1715
+ : @"";
1716
+
1717
+ [self sendWindowEventWithName:@"onToolbarItemSelected"
1718
+ body:@{@"identifier": identifier, @"itemId": itemId, @"action": @{ @"type": @"action", @"itemId": value }, @"instanceId": representedObject[@"instanceId"] ?: @""}];
1719
+ }
1720
+
1721
+ - (void)toolbarSearchButtonPressed:(id)sender
1722
+ {
1723
+ NSToolbarItem *toolbarItem = [sender isKindOfClass:NSToolbarItem.class]
1724
+ ? (NSToolbarItem *)sender
1725
+ : nil;
1726
+ if (!toolbarItem) {
1727
+ id associatedItem = objc_getAssociatedObject(sender, &LegendToolbarSearchItemKey);
1728
+ if ([associatedItem isKindOfClass:NSToolbarItem.class]) {
1729
+ toolbarItem = (NSToolbarItem *)associatedItem;
1730
+ }
1731
+ }
1732
+
1733
+ [self expandToolbarSearchItem:toolbarItem value:nil focus:YES sendChange:YES animated:YES];
1734
+ }
1735
+
1736
+ - (void)toolbarButtonItemPressed:(id)sender
1737
+ {
1738
+ id metadata = objc_getAssociatedObject(sender, &LegendToolbarControlMetadataKey);
1739
+ NSDictionary *representedObject = [metadata isKindOfClass:NSDictionary.class]
1740
+ ? metadata
1741
+ : @{};
1742
+ NSString *identifier = [representedObject[@"windowIdentifier"] isKindOfClass:NSString.class]
1743
+ ? representedObject[@"windowIdentifier"]
1744
+ : @"";
1745
+ NSString *itemId = [representedObject[@"itemId"] isKindOfClass:NSString.class]
1746
+ ? representedObject[@"itemId"]
1747
+ : @"";
1748
+ NSString *value = [representedObject[@"value"] isKindOfClass:NSString.class]
1749
+ ? representedObject[@"value"]
1750
+ : @"";
1751
+ NSArray *menuItems = [representedObject[@"menuItems"] isKindOfClass:NSArray.class]
1752
+ ? representedObject[@"menuItems"]
1753
+ : @[];
1754
+
1755
+ if (menuItems.count > 0) {
1756
+ NSMenu *menu = [NSMenu new];
1757
+ menu.autoenablesItems = NO;
1758
+ for (id itemCandidate in menuItems) {
1759
+ if (![itemCandidate isKindOfClass:NSDictionary.class]) {
1760
+ continue;
1761
+ }
1762
+ NSDictionary *itemConfig = (NSDictionary *)itemCandidate;
1763
+ if (LegendDictionaryHasKey(itemConfig, @"separator") && [itemConfig[@"separator"] boolValue]) {
1764
+ [menu addItem:NSMenuItem.separatorItem];
1765
+ continue;
1766
+ }
1767
+ NSString *itemLabel = [itemConfig[@"title"] isKindOfClass:NSString.class] ? itemConfig[@"title"] : @"";
1768
+ NSString *itemValue = [itemConfig[@"id"] isKindOfClass:NSString.class] ? itemConfig[@"id"] : @"";
1769
+ if (itemLabel.length == 0 || itemValue.length == 0) {
1770
+ continue;
1771
+ }
1772
+ NSDictionary *sliderConfig = [itemConfig[@"slider"] isKindOfClass:NSDictionary.class] ? itemConfig[@"slider"] : nil;
1773
+ if (sliderConfig) {
1774
+ double minimum = [sliderConfig[@"min"] doubleValue];
1775
+ double maximum = [sliderConfig[@"max"] doubleValue];
1776
+ double initial = [sliderConfig[@"value"] doubleValue];
1777
+ if (!isfinite(minimum) || !isfinite(maximum) || !isfinite(initial) || maximum <= minimum) continue;
1778
+ NSString *suffix = [sliderConfig[@"suffix"] isKindOfClass:NSString.class] ? sliderConfig[@"suffix"] : @"";
1779
+ NSView *container = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 280, 68)];
1780
+ NSTextField *label = [NSTextField labelWithString:itemLabel];
1781
+ label.frame = NSMakeRect(16, 42, 190, 18);
1782
+ [container addSubview:label];
1783
+ NSTextField *readout = [NSTextField labelWithString:@""];
1784
+ readout.tag = 731;
1785
+ readout.alignment = NSTextAlignmentRight;
1786
+ readout.frame = NSMakeRect(210, 42, 54, 18);
1787
+ [container addSubview:readout];
1788
+ NSSlider *slider = [NSSlider sliderWithValue:MAX(minimum, MIN(maximum, initial)) minValue:minimum maxValue:maximum target:self action:@selector(toolbarMenuSliderChanged:)];
1789
+ slider.frame = NSMakeRect(16, 12, 248, 24);
1790
+ slider.continuous = YES;
1791
+ slider.accessibilityLabel = itemLabel;
1792
+ slider.enabled = LegendDictionaryHasKey(itemConfig, @"enabled") ? [itemConfig[@"enabled"] boolValue] : YES;
1793
+ readout.stringValue = [NSString stringWithFormat:@"%g%@", slider.doubleValue, suffix];
1794
+ objc_setAssociatedObject(slider, &LegendToolbarControlMetadataKey, @{
1795
+ @"windowIdentifier": identifier, @"instanceId": representedObject[@"instanceId"] ?: @"", @"itemId": itemId, @"value": itemValue, @"suffix": suffix,
1796
+ }, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
1797
+ [container addSubview:slider];
1798
+ NSMenuItem *sliderItem = [NSMenuItem new];
1799
+ sliderItem.view = container;
1800
+ [menu addItem:sliderItem];
1801
+ continue;
1802
+ }
1803
+ NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:itemLabel action:@selector(toolbarMenuItemSelected:) keyEquivalent:@""];
1804
+ item.target = self;
1805
+ item.enabled = LegendDictionaryHasKey(itemConfig, @"enabled") ? [itemConfig[@"enabled"] boolValue] : YES;
1806
+ item.state = LegendDictionaryHasKey(itemConfig, @"checked") && [itemConfig[@"checked"] boolValue] ? NSControlStateValueOn : NSControlStateValueOff;
1807
+ NSString *itemSystemImageName = [itemConfig[@"systemImageName"] isKindOfClass:NSString.class] ? itemConfig[@"systemImageName"] : nil;
1808
+ if (itemSystemImageName.length > 0) {
1809
+ if (@available(macOS 11.0, *)) {
1810
+ item.image = [NSImage imageWithSystemSymbolName:itemSystemImageName accessibilityDescription:itemLabel];
1811
+ }
1812
+ }
1813
+ item.representedObject = @{
1814
+ @"itemId": itemId,
1815
+ @"value": itemValue,
1816
+ @"windowIdentifier": identifier, @"instanceId": representedObject[@"instanceId"] ?: @"",
1817
+ };
1818
+ [menu addItem:item];
1819
+ }
1820
+
1821
+ if (menu.numberOfItems > 0) {
1822
+ if ([sender isKindOfClass:NSView.class]) {
1823
+ NSView *senderView = (NSView *)sender;
1824
+ [menu popUpMenuPositioningItem:nil atLocation:NSMakePoint(0, NSHeight(senderView.bounds) + 4) inView:senderView];
1825
+ } else {
1826
+ NSEvent *event = NSApp.currentEvent;
1827
+ NSWindow *window = (NSWindow *)self.windows[identifier];
1828
+ if (event && window.contentView) {
1829
+ [NSMenu popUpContextMenu:menu withEvent:event forView:window.contentView];
1830
+ } else {
1831
+ [menu popUpMenuPositioningItem:nil atLocation:NSZeroPoint inView:nil];
1832
+ }
1833
+ }
1834
+ return;
1835
+ }
1836
+ }
1837
+
1838
+ [self sendWindowEventWithName:@"onToolbarItemSelected"
1839
+ body:@{@"identifier": identifier, @"itemId": itemId, @"value": value, @"instanceId": representedObject[@"instanceId"] ?: @""}];
1840
+ }
1841
+
1842
+ - (void)toolbarSegmentedControlChanged:(NSSegmentedControl *)sender
1843
+ {
1844
+ id metadata = objc_getAssociatedObject(sender, &LegendToolbarControlMetadataKey);
1845
+ NSDictionary *representedObject = [metadata isKindOfClass:NSDictionary.class]
1846
+ ? metadata
1847
+ : @{};
1848
+ NSArray *values = [representedObject[@"values"] isKindOfClass:NSArray.class] ? representedObject[@"values"] : @[];
1849
+ NSInteger selectedSegment = sender.selectedSegment;
1850
+ NSString *value = selectedSegment >= 0 && selectedSegment < values.count && [values[selectedSegment] isKindOfClass:NSString.class]
1851
+ ? values[selectedSegment]
1852
+ : @"";
1853
+ NSString *identifier = [representedObject[@"windowIdentifier"] isKindOfClass:NSString.class]
1854
+ ? representedObject[@"windowIdentifier"]
1855
+ : @"";
1856
+ NSString *itemId = [representedObject[@"itemId"] isKindOfClass:NSString.class]
1857
+ ? representedObject[@"itemId"]
1858
+ : @"";
1859
+
1860
+ [self sendWindowEventWithName:@"onToolbarItemSelected"
1861
+ body:@{@"identifier": identifier, @"itemId": itemId, @"value": value, @"kind": @"selection", @"instanceId": representedObject[@"instanceId"] ?: @""}];
1862
+ }
1863
+
1864
+ - (void)sendToolbarSearchEventForField:(NSSearchField *)searchField
1865
+ submitted:(BOOL)submitted
1866
+ shiftKey:(BOOL)shiftKey
1867
+ {
1868
+ id metadata = objc_getAssociatedObject(searchField, &LegendToolbarControlMetadataKey);
1869
+ NSDictionary *representedObject = [metadata isKindOfClass:NSDictionary.class]
1870
+ ? metadata
1871
+ : @{};
1872
+ NSString *identifier = [representedObject[@"windowIdentifier"] isKindOfClass:NSString.class]
1873
+ ? representedObject[@"windowIdentifier"]
1874
+ : @"";
1875
+ NSString *itemId = [representedObject[@"itemId"] isKindOfClass:NSString.class]
1876
+ ? representedObject[@"itemId"]
1877
+ : @"";
1878
+
1879
+ [self sendWindowEventWithName:@"onToolbarSearch"
1880
+ body:@{
1881
+ @"identifier": identifier,
1882
+ @"itemId": itemId,
1883
+ @"shiftKey": @(shiftKey),
1884
+ @"submitted": @(submitted),
1885
+ @"instanceId": representedObject[@"instanceId"] ?: @"",
1886
+ @"value": searchField.stringValue ?: @"",
1887
+ }];
1888
+ }
1889
+
1890
+ - (void)controlTextDidChange:(NSNotification *)notification
1891
+ {
1892
+ if ([notification.object isKindOfClass:NSSearchField.class]) {
1893
+ [self sendToolbarSearchEventForField:(NSSearchField *)notification.object submitted:NO shiftKey:NO];
1894
+ }
1895
+ }
1896
+
1897
+ - (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)commandSelector
1898
+ {
1899
+ if ([control isKindOfClass:NSSearchField.class] && commandSelector == @selector(cancelOperation:)) {
1900
+ [control.window makeFirstResponder:nil];
1901
+ return YES;
1902
+ }
1903
+ return NO;
1904
+ }
1905
+
1906
+ - (void)controlTextDidEndEditing:(NSNotification *)notification
1907
+ {
1908
+ if ([notification.object isKindOfClass:NSSearchField.class]) {
1909
+ NSSearchField *searchField = (NSSearchField *)notification.object;
1910
+ if (searchField.stringValue.length == 0) {
1911
+ id associatedItem = objc_getAssociatedObject(searchField, &LegendToolbarSearchItemKey);
1912
+ if ([associatedItem isKindOfClass:NSToolbarItem.class]) {
1913
+ [self collapseToolbarSearchItem:(NSToolbarItem *)associatedItem animated:YES];
1914
+ }
1915
+ }
1916
+ }
1917
+ }
1918
+
1919
+ - (void)toolbarSearchSubmitted:(NSSearchField *)sender
1920
+ {
1921
+ NSEvent *currentEvent = NSApp.currentEvent;
1922
+ BOOL shiftKey = currentEvent && ((currentEvent.modifierFlags & NSEventModifierFlagShift) != 0);
1923
+ [self sendToolbarSearchEventForField:sender submitted:YES shiftKey:shiftKey];
1924
+ }
1925
+ #endif
1926
+
1927
+ - (NSString *)successJson
1928
+ {
1929
+ return [self jsonStringFromObject:@{@"success": @YES}];
1930
+ }
1931
+
1932
+ - (NSString *)failureJson:(NSString *)message
1933
+ {
1934
+ return [self jsonStringFromObject:@{@"success": @NO, @"message": message ?: @""}];
1935
+ }
1936
+
1937
+ - (NSString *)getConstantsJson
1938
+ {
1939
+ #if TARGET_OS_OSX
1940
+ return [self jsonStringFromObject:@{
1941
+ @"STYLE_MASK_BORDERLESS": @(NSWindowStyleMaskBorderless),
1942
+ @"STYLE_MASK_TITLED": @(NSWindowStyleMaskTitled),
1943
+ @"STYLE_MASK_CLOSABLE": @(NSWindowStyleMaskClosable),
1944
+ @"STYLE_MASK_MINIATURIZABLE": @(NSWindowStyleMaskMiniaturizable),
1945
+ @"STYLE_MASK_RESIZABLE": @(NSWindowStyleMaskResizable),
1946
+ @"STYLE_MASK_UNIFIED_TITLE_AND_TOOLBAR": @(NSWindowStyleMaskUnifiedTitleAndToolbar),
1947
+ @"STYLE_MASK_FULL_SCREEN": @(NSWindowStyleMaskFullScreen),
1948
+ @"STYLE_MASK_FULL_SIZE_CONTENT_VIEW": @(NSWindowStyleMaskFullSizeContentView),
1949
+ @"STYLE_MASK_UTILITY_WINDOW": @(NSWindowStyleMaskUtilityWindow),
1950
+ @"STYLE_MASK_DOC_MODAL_WINDOW": @(NSWindowStyleMaskDocModalWindow),
1951
+ @"STYLE_MASK_NONACTIVATING_PANEL": @(NSWindowStyleMaskNonactivatingPanel),
1952
+ @"WINDOW_LEVEL_NORMAL": @(NSNormalWindowLevel),
1953
+ @"WINDOW_LEVEL_FLOATING": @(NSFloatingWindowLevel),
1954
+ @"WINDOW_LEVEL_MODAL_PANEL": @(NSModalPanelWindowLevel),
1955
+ @"WINDOW_LEVEL_MAIN_MENU": @(NSMainMenuWindowLevel),
1956
+ @"WINDOW_LEVEL_STATUS": @(NSStatusWindowLevel),
1957
+ @"WINDOW_LEVEL_SCREEN_SAVER": @(NSScreenSaverWindowLevel),
1958
+ }];
1959
+ #else
1960
+ return @"{}";
1961
+ #endif
1962
+ }
1963
+
1964
+ - (NSString *)getReactNativeStartupTimingJson
1965
+ {
1966
+ facebook::react::ReactMarker::StartupLogger& startupLogger =
1967
+ facebook::react::ReactMarker::StartupLogger::getInstance();
1968
+ NSMutableDictionary<NSString *, NSNumber *> *timing = [NSMutableDictionary new];
1969
+
1970
+ #if TARGET_OS_OSX
1971
+ timing[@"clockOffsetMs"] = @(
1972
+ NSDate.date.timeIntervalSince1970 * 1000 - CACurrentMediaTime() * 1000
1973
+ );
1974
+ #if __has_include(<RNDesktopApp/SparkDesktop.h>)
1975
+ [timing addEntriesFromDictionary:SparkStartupTiming()];
1976
+ #else
1977
+ if (LegendMainWindowFirstVisibleTimeMs > 0) {
1978
+ timing[@"mainWindowFirstVisibleTime"] = @(LegendMainWindowFirstVisibleTimeMs);
1979
+ }
1980
+ if (LegendMainWindowReactRootAttachedTimeMs > 0) {
1981
+ timing[@"mainWindowReactRootAttachedTime"] = @(LegendMainWindowReactRootAttachedTimeMs);
1982
+ }
1983
+ #endif
1984
+ #endif
1985
+
1986
+ double startTime = startupLogger.getAppStartupStartTime();
1987
+ if (std::isnan(startTime)) {
1988
+ startTime = startupLogger.getInitReactRuntimeStartTime();
1989
+ }
1990
+ if (!std::isnan(startTime)) {
1991
+ timing[@"startTime"] = @(startTime);
1992
+ }
1993
+
1994
+ const struct {
1995
+ NSString *key;
1996
+ double value;
1997
+ } markers[] = {
1998
+ {@"initializeRuntimeStart", startupLogger.getInitReactRuntimeStartTime()},
1999
+ {@"executeJavaScriptBundleEntryPointStart", startupLogger.getRunJSBundleStartTime()},
2000
+ {@"executeJavaScriptBundleEntryPointEnd", startupLogger.getRunJSBundleEndTime()},
2001
+ {@"initializeRuntimeEnd", startupLogger.getInitReactRuntimeEndTime()},
2002
+ {@"endTime", startupLogger.getAppStartupEndTime()},
2003
+ };
2004
+ for (const auto& marker : markers) {
2005
+ if (!std::isnan(marker.value)) {
2006
+ timing[marker.key] = @(marker.value);
2007
+ }
2008
+ }
2009
+
2010
+ return [self jsonStringFromObject:timing];
2011
+ }
2012
+
2013
+ - (NSArray<NSDictionary *> *)displayDictionaries
2014
+ {
2015
+ #if TARGET_OS_OSX
2016
+ NSMutableArray<NSDictionary *> *displays = [NSMutableArray new];
2017
+ NSScreen *mainScreen = NSScreen.mainScreen;
2018
+ for (NSScreen *screen in NSScreen.screens) {
2019
+ NSNumber *screenNumber = screen.deviceDescription[@"NSScreenNumber"];
2020
+ NSRect frame = screen.frame;
2021
+ NSRect visibleFrame = screen.visibleFrame;
2022
+ NSString *name = @"Display";
2023
+ if (@available(macOS 10.15, *)) {
2024
+ name = screen.localizedName ?: name;
2025
+ }
2026
+ CFUUIDRef uuid = screenNumber ? CGDisplayCreateUUIDFromDisplayID(screenNumber.unsignedIntValue) : nullptr;
2027
+ NSString *persistentId = uuid ? CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, uuid)) : screenNumber.stringValue;
2028
+ if (uuid) CFRelease(uuid);
2029
+ [displays addObject:@{
2030
+ @"persistentId": persistentId ?: @"",
2031
+ @"id": screenNumber.stringValue ?: @"",
2032
+ @"name": name,
2033
+ @"isMain": @(screen == mainScreen),
2034
+ @"scaleFactor": @(screen.backingScaleFactor),
2035
+ @"frame": @{ @"x": @(frame.origin.x), @"y": @(frame.origin.y), @"width": @(frame.size.width), @"height": @(frame.size.height) },
2036
+ @"visibleFrame": @{ @"x": @(visibleFrame.origin.x), @"y": @(visibleFrame.origin.y), @"width": @(visibleFrame.size.width), @"height": @(visibleFrame.size.height) },
2037
+ }];
2038
+ }
2039
+ return displays;
2040
+ #else
2041
+ return @[];
2042
+ #endif
2043
+ }
2044
+
2045
+ - (void)getDisplays:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
2046
+ {
2047
+ resolve([self jsonStringFromObject:[self displayDictionaries]]);
2048
+ }
2049
+
2050
+ #if TARGET_OS_OSX
2051
+ - (RCTUIView *)createReactRootViewWithModuleName:(NSString *)moduleName initialProperties:(NSDictionary *)initialProps
2052
+ {
2053
+
2054
+ id appDelegate = NSApplication.sharedApplication.delegate;
2055
+ RCTRootViewFactory *rootViewFactory = nil;
2056
+
2057
+ if ([appDelegate respondsToSelector:@selector(rootViewFactory)]) {
2058
+ rootViewFactory = [(id<RNWindowManagerRootViewFactoryProvider>)appDelegate rootViewFactory];
2059
+ }
2060
+
2061
+ if (rootViewFactory) {
2062
+ RCTUIView *rootView = (RCTUIView *)[rootViewFactory viewWithModuleName:moduleName initialProperties:initialProps];
2063
+ return rootView;
2064
+ }
2065
+
2066
+ RCTBridge *bridge = self.bridge;
2067
+ if (!bridge) {
2068
+ return nil;
2069
+ }
2070
+
2071
+ RCTUIView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProps];
2072
+ return rootView;
2073
+ }
2074
+ #endif
2075
+
2076
+ - (void)finishWindowRestoration:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
2077
+ {
2078
+ #if TARGET_OS_OSX
2079
+ RCTExecuteOnMainQueue(^{
2080
+ // Adopted windows are removed from this collection by LegendTakePrecreatedWindow.
2081
+ // Close only unclaimed native shells; preserve saved records and document data.
2082
+ for (NSString *identifier in LegendPrecreatedWindows.allKeys) {
2083
+ LegendRemovePrecreatedWindow(identifier);
2084
+ }
2085
+ resolve([self successJson]);
2086
+ });
2087
+ #else
2088
+ resolve([self failureJson:@"WindowManager is only available on macOS"]);
2089
+ #endif
2090
+ }
2091
+
2092
+ - (void)openWindow:(NSString *)optionsJson resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
2093
+ {
2094
+ #if TARGET_OS_OSX
2095
+ RCTExecuteOnMainQueue(^{
2096
+ NSDictionary *options = [self parseObjectJSON:optionsJson];
2097
+ NSString *identifier = [options[@"identifier"] isKindOfClass:NSString.class] ? options[@"identifier"] : nil;
2098
+ NSString *moduleName = [options[@"moduleName"] isKindOfClass:NSString.class] ? options[@"moduleName"] : nil;
2099
+ NSAppearance *darkAppearance = LegendDarkAppearance();
2100
+
2101
+ if (moduleName.length == 0) {
2102
+ moduleName = identifier;
2103
+ }
2104
+ if (identifier.length == 0) {
2105
+ identifier = moduleName ?: @"default";
2106
+ }
2107
+
2108
+ // A caller can turn off restoration before the window has been adopted by
2109
+ // React, so remove a native startup shell immediately when requested.
2110
+ if (LegendDictionaryHasKey(options, @"restoreOnLaunch") && ![options[@"restoreOnLaunch"] boolValue]) {
2111
+ LegendSetRestorableWindowOptions(identifier, nil);
2112
+ LegendRemovePrecreatedWindow(identifier);
2113
+ }
2114
+
2115
+ NSString *title = [options[@"title"] isKindOfClass:NSString.class] ? options[@"title"] : nil;
2116
+ title = title ?: moduleName ?: @"New Window";
2117
+ BOOL hasRepresentedURL = LegendDictionaryHasKey(options, @"representedURL");
2118
+ id representedURLValue = hasRepresentedURL ? options[@"representedURL"] : nil;
2119
+
2120
+ NSDictionary *windowStyle = [options[@"windowStyle"] isKindOfClass:NSDictionary.class] ? options[@"windowStyle"] : @{};
2121
+ NSNumber *maskNumber = [windowStyle[@"mask"] isKindOfClass:NSNumber.class] ? windowStyle[@"mask"] : nil;
2122
+ NSNumber *transparentTitlebar = [windowStyle[@"titlebarAppearsTransparent"] isKindOfClass:NSNumber.class]
2123
+ ? windowStyle[@"titlebarAppearsTransparent"]
2124
+ : nil;
2125
+ NSString *titleVisibility = [windowStyle[@"titleVisibility"] isKindOfClass:NSString.class]
2126
+ ? windowStyle[@"titleVisibility"]
2127
+ : nil;
2128
+ NSString *toolbarStyle = [windowStyle[@"toolbarStyle"] isKindOfClass:NSString.class] ? windowStyle[@"toolbarStyle"] : nil;
2129
+ NSString *contentLayoutMode = [windowStyle[@"contentLayoutMode"] isKindOfClass:NSString.class]
2130
+ ? windowStyle[@"contentLayoutMode"]
2131
+ : nil;
2132
+ NSString *titlebarSeparatorStyle = [windowStyle[@"titlebarSeparatorStyle"] isKindOfClass:NSString.class]
2133
+ ? windowStyle[@"titlebarSeparatorStyle"]
2134
+ : nil;
2135
+ NSString *backgroundColor = [windowStyle[@"backgroundColor"] isKindOfClass:NSString.class]
2136
+ ? windowStyle[@"backgroundColor"]
2137
+ : nil;
2138
+ NSString *appearance = [windowStyle[@"appearance"] isKindOfClass:NSString.class]
2139
+ ? windowStyle[@"appearance"]
2140
+ : nil;
2141
+ BOOL usesTitlebarBackground = transparentTitlebar.boolValue && backgroundColor.length > 0;
2142
+ NSNumber *levelNumber = [options[@"level"] isKindOfClass:NSNumber.class] ? options[@"level"] : nil;
2143
+ BOOL transparentBackground = [options[@"transparentBackground"] boolValue];
2144
+ BOOL interceptClose = [options[@"interceptClose"] boolValue];
2145
+ BOOL deferOrderFront = [options[@"deferOrderFront"] boolValue];
2146
+ NSNumber *hasShadowNumber = [options[@"hasShadow"] isKindOfClass:NSNumber.class] ? options[@"hasShadow"] : nil;
2147
+ BOOL shouldApplyHasShadow = hasShadowNumber != nil;
2148
+ BOOL hasShadow = shouldApplyHasShadow ? hasShadowNumber.boolValue : NO;
2149
+ NSNumber *animateFrameChangeNumber = [options[@"animateFrameChange"] isKindOfClass:NSNumber.class]
2150
+ ? options[@"animateFrameChange"]
2151
+ : nil;
2152
+ BOOL animateFrameChange = animateFrameChangeNumber ? animateFrameChangeNumber.boolValue : NO;
2153
+ NSNumber *frameAnimationDurationNumber = [options[@"frameAnimationDurationMs"] isKindOfClass:NSNumber.class]
2154
+ ? options[@"frameAnimationDurationMs"]
2155
+ : nil;
2156
+ NSTimeInterval frameAnimationDuration = frameAnimationDurationNumber ? frameAnimationDurationNumber.doubleValue / 1000.0 : 0;
2157
+ NSNumber *widthNumber = [windowStyle[@"width"] isKindOfClass:NSNumber.class]
2158
+ ? windowStyle[@"width"]
2159
+ : ([options[@"width"] isKindOfClass:NSNumber.class] ? options[@"width"] : nil);
2160
+ NSNumber *heightNumber = [windowStyle[@"height"] isKindOfClass:NSNumber.class]
2161
+ ? windowStyle[@"height"]
2162
+ : ([options[@"height"] isKindOfClass:NSNumber.class] ? options[@"height"] : nil);
2163
+ CGFloat width = widthNumber ? widthNumber.doubleValue : 400;
2164
+ CGFloat height = heightNumber ? heightNumber.doubleValue : 300;
2165
+ NSNumber *minWidthNumber = [windowStyle[@"minWidth"] isKindOfClass:NSNumber.class]
2166
+ ? windowStyle[@"minWidth"]
2167
+ : ([options[@"minWidth"] isKindOfClass:NSNumber.class] ? options[@"minWidth"] : nil);
2168
+ NSNumber *minHeightNumber = [windowStyle[@"minHeight"] isKindOfClass:NSNumber.class]
2169
+ ? windowStyle[@"minHeight"]
2170
+ : ([options[@"minHeight"] isKindOfClass:NSNumber.class] ? options[@"minHeight"] : nil);
2171
+ BOOL hasMinWidth = minWidthNumber != nil;
2172
+ BOOL hasMinHeight = minHeightNumber != nil;
2173
+ CGFloat minWidth = hasMinWidth ? minWidthNumber.doubleValue : 0;
2174
+ CGFloat minHeight = hasMinHeight ? minHeightNumber.doubleValue : 0;
2175
+
2176
+ if (hasMinWidth && width < minWidth) {
2177
+ width = minWidth;
2178
+ }
2179
+ if (hasMinHeight && height < minHeight) {
2180
+ height = minHeight;
2181
+ }
2182
+
2183
+ NSNumber *originX = [options[@"x"] isKindOfClass:NSNumber.class] ? options[@"x"] : nil;
2184
+ NSNumber *originY = [options[@"y"] isKindOfClass:NSNumber.class] ? options[@"y"] : nil;
2185
+ BOOL hasToolbar = [windowStyle[@"hasToolbar"] boolValue];
2186
+ NSWindow *existingWindow = (NSWindow *)self.windows[identifier];
2187
+ if (existingWindow) { reject(@"E_ALREADY_EXISTS", @"Window ID is already open", nil); return; }
2188
+
2189
+ NSUInteger styleMask = maskNumber
2190
+ ? maskNumber.unsignedIntegerValue
2191
+ : (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable | NSWindowStyleMaskMiniaturizable);
2192
+ NSWindow *precreatedWindow = LegendTakePrecreatedWindow ? LegendTakePrecreatedWindow(identifier) : nil;
2193
+ NSWindow *window = precreatedWindow ?: [[([options[@"sparkOverlay"] boolValue] || windowStyle[@"panelStyle"] ? NSPanel.class : NSWindow.class) alloc] initWithContentRect:NSMakeRect(0, 0, width, height)
2194
+ styleMask:styleMask
2195
+ backing:NSBackingStoreBuffered
2196
+ defer:NO];
2197
+ objc_setAssociatedObject(window, NSSelectorFromString(@"sparkWindowInstanceId"), NSUUID.UUID.UUIDString, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
2198
+ if ([options[@"sparkOverlay"] boolValue]) {
2199
+ ((NSPanel *)window).hidesOnDeactivate = NO;
2200
+ window.styleMask |= NSWindowStyleMaskNonactivatingPanel;
2201
+ window.collectionBehavior = NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorFullScreenAuxiliary;
2202
+ }
2203
+ objc_setAssociatedObject(window, NSSelectorFromString(@"sparkRestoredShell"), @(precreatedWindow != nil), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
2204
+ LegendApplyWindowOptions(window, options);
2205
+ LegendApplyContentLayoutModeOption(window, contentLayoutMode);
2206
+ LegendApplyContentLayoutMode(window, maskNumber, usesTitlebarBackground);
2207
+
2208
+ if (appearance) {
2209
+ LegendApplyWindowAppearance(window, appearance);
2210
+ } else if (darkAppearance) {
2211
+ window.appearance = darkAppearance;
2212
+ }
2213
+ window.releasedWhenClosed = NO;
2214
+ LegendApplyWindowTitleAndRepresentedURL(window, title, hasRepresentedURL, representedURLValue, title);
2215
+ if (transparentTitlebar != nil) {
2216
+ window.titlebarAppearsTransparent = transparentTitlebar.boolValue;
2217
+ }
2218
+ LegendApplyTitleVisibility(window, titleVisibility);
2219
+ if (hasToolbar) {
2220
+ NSToolbar *toolbar = LegendCreateToolbar(identifier);
2221
+ window.toolbar = toolbar;
2222
+ }
2223
+ LegendApplyToolbarStyle(window, toolbarStyle);
2224
+ LegendApplyTitlebarSeparatorStyle(window, titlebarSeparatorStyle);
2225
+ [self applyTitlebarControlsFromOptions:options toWindow:window identifier:identifier];
2226
+ [self applyToolbarItemsFromOptions:options toWindow:window identifier:identifier];
2227
+ [self applyTitlebarMaterialFromOptions:options toWindow:window identifier:identifier];
2228
+ LegendApplyWindowBackgroundColor(window, backgroundColor);
2229
+ if (levelNumber) {
2230
+ window.level = levelNumber.integerValue;
2231
+ }
2232
+ if (shouldApplyHasShadow) {
2233
+ window.hasShadow = hasShadow;
2234
+ if (hasShadow) {
2235
+ [window invalidateShadow];
2236
+ }
2237
+ }
2238
+ if (transparentBackground) {
2239
+ window.opaque = NO;
2240
+ if (!hasToolbar) {
2241
+ window.backgroundColor = NSColor.clearColor;
2242
+ }
2243
+ window.contentView.wantsLayer = YES;
2244
+ window.contentView.layer.masksToBounds = NO;
2245
+ }
2246
+
2247
+ if (precreatedWindow) {
2248
+ // Native startup already restored this window to its final AppKit frame.
2249
+ } else if (originX || originY) {
2250
+ NSPoint origin = window.frame.origin;
2251
+ if (originX) {
2252
+ origin.x = originX.doubleValue;
2253
+ }
2254
+ if (originY) {
2255
+ origin.y = originY.doubleValue;
2256
+ }
2257
+ [window setFrameOrigin:origin];
2258
+ } else {
2259
+ [window center];
2260
+ }
2261
+
2262
+ if (hasMinWidth || hasMinHeight) {
2263
+ NSSize currentMinSize = window.minSize;
2264
+ [window setMinSize:NSMakeSize(hasMinWidth ? minWidth : currentMinSize.width,
2265
+ hasMinHeight ? minHeight : currentMinSize.height)];
2266
+ }
2267
+
2268
+ NSColor *startupBackgroundColor = transparentBackground
2269
+ ? NSColor.clearColor
2270
+ : LegendWindowStartupBackgroundColor(window, backgroundColor);
2271
+ if (!transparentBackground && backgroundColor.length == 0) {
2272
+ window.backgroundColor = startupBackgroundColor;
2273
+ window.opaque = startupBackgroundColor.alphaComponent >= 1;
2274
+ LegendApplyBackgroundColorToView(window.contentView, startupBackgroundColor);
2275
+ }
2276
+
2277
+ if (!precreatedWindow && [options[@"restoreOnLaunch"] boolValue] && !LegendSafeMode() && !LegendTestDriverActive()) {
2278
+ [window setFrameAutosaveName:LegendManagedWindowFrameAutosaveName(identifier)];
2279
+ }
2280
+ if (!precreatedWindow && LegendPrepareSidebarSplitViewStartup) {
2281
+ LegendPrepareSidebarSplitViewStartup(window, windowStyle[@"startupSplitView"]);
2282
+ }
2283
+ BOOL presentedBeforeReactRoot = precreatedWindow != nil || !deferOrderFront;
2284
+ if (!deferOrderFront && !window.visible) {
2285
+ [window.contentView displayIfNeeded];
2286
+ [window displayIfNeeded];
2287
+ [window makeKeyAndOrderFront:nil];
2288
+ if (levelNumber) {
2289
+ [window orderFrontRegardless];
2290
+ }
2291
+ }
2292
+
2293
+ NSDictionary *initialProps = [self initialPropsFromOptions:options];
2294
+ RCTUIView *rootView = [self createReactRootViewWithModuleName:moduleName initialProperties:initialProps];
2295
+ if (!rootView) {
2296
+ if (presentedBeforeReactRoot) {
2297
+ [window close];
2298
+ }
2299
+ reject(@"no_root_view", @"React root view could not be created", nil);
2300
+ return;
2301
+ }
2302
+
2303
+ rootView.backgroundColor = startupBackgroundColor;
2304
+ __weak NSWindow *weakWindow = window;
2305
+ void (^installRoot)(void) = ^{
2306
+ NSWindow *targetWindow = weakWindow;
2307
+ if (!targetWindow) {
2308
+ return;
2309
+ }
2310
+ [rootView removeFromSuperview];
2311
+ targetWindow.contentView = rootView;
2312
+ if (usesTitlebarBackground || contentLayoutMode.length > 0) {
2313
+ LegendEnsureRootViewContainer(targetWindow, rootView);
2314
+ }
2315
+ LegendApplyWindowBackgroundColor(targetWindow, backgroundColor);
2316
+ LegendSizeRootViewToWindow(rootView, targetWindow);
2317
+ };
2318
+ if (!LegendAttachSidebarSplitViewStartupRoot ||
2319
+ !LegendAttachSidebarSplitViewStartupRoot(window, rootView, installRoot)) {
2320
+ installRoot();
2321
+ }
2322
+ objc_setAssociatedObject(window, &LegendManagedRootViewKey, rootView, OBJC_ASSOCIATION_ASSIGN);
2323
+ LegendSizeRootViewToWindow(rootView, window);
2324
+ if (transparentBackground) {
2325
+ rootView.backgroundColor = NSColor.clearColor;
2326
+ window.contentView.wantsLayer = YES;
2327
+ window.contentView.layer.backgroundColor = NSColor.clearColor.CGColor;
2328
+ window.contentView.layer.masksToBounds = NO;
2329
+ }
2330
+ rootView.wantsLayer = YES;
2331
+ rootView.layerUsesCoreImageFilters = YES;
2332
+ if (!rootView.layer) {
2333
+ rootView.layer = [CALayer layer];
2334
+ }
2335
+ rootView.layer.masksToBounds = NO;
2336
+ LegendPrepareWindowForDisplay(window, backgroundColor);
2337
+ window.delegate = self;
2338
+
2339
+ window.identifier = identifier;
2340
+ self.windows[identifier] = window;
2341
+ self.rootViews[identifier] = rootView;
2342
+ self.moduleNames[identifier] = moduleName ?: @"";
2343
+ [self recordWindowOptions:options identifier:identifier moduleName:moduleName];
2344
+ if (interceptClose) {
2345
+ [self.closeRequestIdentifiers addObject:identifier];
2346
+ } else {
2347
+ [self.closeRequestIdentifiers removeObject:identifier];
2348
+ }
2349
+
2350
+ [self finishOpeningWindow:window options:windowStyle resolve:resolve reject:reject];
2351
+ });
2352
+ #else
2353
+ resolve([self failureJson:@"WindowManager is only available on macOS"]);
2354
+ #endif
2355
+ }
2356
+
2357
+ #if TARGET_OS_OSX
2358
+ // Opening resolves only after AppKit enters its fullscreen Space, so callers
2359
+ // can safely focus a presenter on another display afterwards.
2360
+ - (void)finishOpeningWindow:(NSWindow *)window options:(NSDictionary *)windowStyle
2361
+ resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
2362
+ {
2363
+ if (![windowStyle[@"fullscreen"] boolValue] || (window.styleMask & NSWindowStyleMaskFullScreen)) {
2364
+ resolve([self successJson]);
2365
+ return;
2366
+ }
2367
+ objc_setAssociatedObject(window, &LegendManagedFullscreenPresentationKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
2368
+ window.collectionBehavior = (window.collectionBehavior & ~NSWindowCollectionBehaviorFullScreenAuxiliary)
2369
+ | NSWindowCollectionBehaviorFullScreenPrimary;
2370
+ __block id entered = nil;
2371
+ __block id closed = nil;
2372
+ __block BOOL finished = NO;
2373
+ void (^finish)(BOOL) = ^(BOOL success) {
2374
+ if (finished) return;
2375
+ finished = YES;
2376
+ [NSNotificationCenter.defaultCenter removeObserver:entered];
2377
+ [NSNotificationCenter.defaultCenter removeObserver:closed];
2378
+ entered = nil;
2379
+ closed = nil;
2380
+ if (success) resolve([self successJson]);
2381
+ else {
2382
+ [window close];
2383
+ reject(@"fullscreen_failed", @"Fullscreen did not complete. Check the selected display and try again.", nil);
2384
+ }
2385
+ };
2386
+ entered = [NSNotificationCenter.defaultCenter addObserverForName:NSWindowDidEnterFullScreenNotification
2387
+ object:window queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification *note) { finish(YES); }];
2388
+ closed = [NSNotificationCenter.defaultCenter addObserverForName:NSWindowWillCloseNotification
2389
+ object:window queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification *note) { finish(NO); }];
2390
+ [window makeKeyAndOrderFront:nil];
2391
+ [window toggleFullScreen:nil];
2392
+ // Bound failures where AppKit never sends the completion notification.
2393
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ finish(NO); });
2394
+ }
2395
+
2396
+ - (NSApplicationPresentationOptions)window:(NSWindow *)window
2397
+ willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)options
2398
+ {
2399
+ if (![objc_getAssociatedObject(window, &LegendManagedFullscreenPresentationKey) boolValue]) return options;
2400
+ return options | NSApplicationPresentationAutoHideMenuBar | NSApplicationPresentationAutoHideDock
2401
+ | NSApplicationPresentationAutoHideToolbar;
2402
+ }
2403
+ #endif
2404
+
2405
+ - (void)setWindowTitle:(NSString *)identifier
2406
+ title:(NSString *)title
2407
+ resolve:(RCTPromiseResolveBlock)resolve
2408
+ reject:(RCTPromiseRejectBlock)reject
2409
+ {
2410
+ #if TARGET_OS_OSX
2411
+ RCTExecuteOnMainQueue(^{
2412
+ NSString *targetIdentifier = [self normalizeIdentifier:identifier];
2413
+ NSWindow *window = [targetIdentifier isEqualToString:@"main"]
2414
+ ? [RNWindowManager getMainWindow]
2415
+ : (NSWindow *)self.windows[targetIdentifier];
2416
+ if (!window) {
2417
+ reject(@"E_NOT_FOUND", @"Window not found", nil);
2418
+ return;
2419
+ }
2420
+ window.title = title ?: @"";
2421
+ resolve([self successJson]);
2422
+ });
2423
+ #else
2424
+ resolve([self failureJson:@"WindowManager is only available on macOS"]);
2425
+ #endif
2426
+ }
2427
+
2428
+ - (void)setWindowToolbarItemText:(NSString *)identifier
2429
+ itemId:(NSString *)itemId
2430
+ text:(NSString *)text
2431
+ resolve:(RCTPromiseResolveBlock)resolve
2432
+ reject:(RCTPromiseRejectBlock)reject
2433
+ {
2434
+ #if TARGET_OS_OSX
2435
+ RCTExecuteOnMainQueue(^{
2436
+ NSString *targetIdentifier = [self normalizeIdentifier:identifier];
2437
+ NSWindow *window = (NSWindow *)self.windows[targetIdentifier];
2438
+ if (!window) {
2439
+ resolve([self failureJson:@"Window not found"]);
2440
+ return;
2441
+ }
2442
+
2443
+ NSString *toolbarIdentifier = [NSString stringWithFormat:@"legend.toolbar.%@", itemId ?: @""];
2444
+ NSToolbarItem *toolbarItem = nil;
2445
+ for (NSToolbarItem *candidate in window.toolbar.items) {
2446
+ if ([candidate.itemIdentifier isEqualToString:toolbarIdentifier]) {
2447
+ toolbarItem = candidate;
2448
+ break;
2449
+ }
2450
+ }
2451
+ if (!toolbarItem) {
2452
+ resolve([self failureJson:@"Toolbar item not found"]);
2453
+ return;
2454
+ }
2455
+
2456
+ if ([toolbarItem.view isKindOfClass:NSTextField.class]) {
2457
+ ((NSTextField *)toolbarItem.view).stringValue = text ?: @"";
2458
+ } else if ([toolbarItem.view isKindOfClass:NSButton.class]) {
2459
+ ((NSButton *)toolbarItem.view).title = text ?: @"";
2460
+ toolbarItem.label = text ?: @"";
2461
+ toolbarItem.paletteLabel = toolbarItem.label;
2462
+ } else {
2463
+ resolve([self failureJson:@"Toolbar item does not support text"]);
2464
+ return;
2465
+ }
2466
+ NSMutableArray *configs = [self.toolbarItemConfigs[window.toolbar.identifier] mutableCopy];
2467
+ for (NSUInteger index = 0; index < configs.count; index++) {
2468
+ if (![[self toolbarItemIdentifierForConfig:configs[index]] isEqualToString:toolbarIdentifier]) continue;
2469
+ NSMutableDictionary *config = [configs[index] mutableCopy];
2470
+ config[[toolbarItem.view isKindOfClass:NSTextField.class] ? @"text" : @"label"] = text ?: @"";
2471
+ configs[index] = config;
2472
+ break;
2473
+ }
2474
+ self.toolbarItemConfigs[window.toolbar.identifier] = configs;
2475
+ resolve([self successJson]);
2476
+ });
2477
+ #else
2478
+ resolve([self failureJson:@"WindowManager is only available on macOS"]);
2479
+ #endif
2480
+ }
2481
+
2482
+ - (void)setPreventDisplaySleep:(BOOL)enabled
2483
+ resolve:(RCTPromiseResolveBlock)resolve
2484
+ reject:(__unused RCTPromiseRejectBlock)reject
2485
+ {
2486
+ #if TARGET_OS_OSX
2487
+ RCTExecuteOnMainQueue(^{
2488
+ if (enabled && !self.displaySleepActivity) {
2489
+ self.displaySleepActivity = [NSProcessInfo.processInfo
2490
+ beginActivityWithOptions:NSActivityIdleDisplaySleepDisabled
2491
+ reason:@"Legend Slides presentation in progress"];
2492
+ } else if (!enabled && self.displaySleepActivity) {
2493
+ [NSProcessInfo.processInfo endActivity:self.displaySleepActivity];
2494
+ self.displaySleepActivity = nil;
2495
+ }
2496
+ resolve([self successJson]);
2497
+ });
2498
+ #else
2499
+ resolve([self failureJson:@"WindowManager is only available on macOS"]);
2500
+ #endif
2501
+ }
2502
+
2503
+ - (void)focusToolbarSearchItem:(NSString *)identifier
2504
+ itemId:(NSString *)itemId
2505
+ value:(NSString *)value
2506
+ resolve:(RCTPromiseResolveBlock)resolve
2507
+ reject:(RCTPromiseRejectBlock)reject
2508
+ {
2509
+ #if TARGET_OS_OSX
2510
+ RCTExecuteOnMainQueue(^{
2511
+ NSString *targetIdentifier = [self normalizeIdentifier:identifier];
2512
+ NSWindow *window = [targetIdentifier isEqualToString:@"main"]
2513
+ ? [RNWindowManager getMainWindow]
2514
+ : (NSWindow *)self.windows[targetIdentifier];
2515
+ if (!window) {
2516
+ reject(@"E_NOT_FOUND", @"Window not found", nil);
2517
+ return;
2518
+ }
2519
+
2520
+ NSString *toolbarIdentifier = [NSString stringWithFormat:@"legend.toolbar.%@", itemId ?: @""];
2521
+ NSToolbarItem *toolbarItem = nil;
2522
+ for (NSToolbarItem *candidate in window.toolbar.items) {
2523
+ if ([candidate.itemIdentifier isEqualToString:toolbarIdentifier]) {
2524
+ toolbarItem = candidate;
2525
+ break;
2526
+ }
2527
+ }
2528
+ if (!toolbarItem) {
2529
+ reject(@"E_NOT_FOUND", @"Toolbar search item not found", nil);
2530
+ return;
2531
+ }
2532
+
2533
+ NSSearchField *searchField = nil;
2534
+ if (@available(macOS 11.0, *)) {
2535
+ if ([toolbarItem isKindOfClass:NSSearchToolbarItem.class]) {
2536
+ searchField = ((NSSearchToolbarItem *)toolbarItem).searchField;
2537
+ }
2538
+ }
2539
+ if (!searchField && [toolbarItem.view isKindOfClass:NSSearchField.class]) {
2540
+ searchField = (NSSearchField *)toolbarItem.view;
2541
+ }
2542
+ if (!searchField) {
2543
+ id associatedField = objc_getAssociatedObject(toolbarItem, &LegendToolbarSearchFieldKey);
2544
+ if ([associatedField isKindOfClass:NSSearchField.class]) {
2545
+ [self expandToolbarSearchItem:toolbarItem value:value focus:YES sendChange:YES animated:YES];
2546
+ resolve([self successJson]);
2547
+ return;
2548
+ }
2549
+ }
2550
+ if (!searchField) {
2551
+ reject(@"E_NOT_FOUND", @"Toolbar search field not found", nil);
2552
+ return;
2553
+ }
2554
+
2555
+ if (value) searchField.stringValue = value;
2556
+ [self sendToolbarSearchEventForField:searchField submitted:NO shiftKey:NO];
2557
+ [window makeKeyAndOrderFront:nil];
2558
+ [window makeFirstResponder:searchField];
2559
+ resolve([self successJson]);
2560
+ });
2561
+ #else
2562
+ resolve([self failureJson:@"WindowManager is only available on macOS"]);
2563
+ #endif
2564
+ }
2565
+
2566
+ - (void)closeWindow:(NSString *)identifier resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
2567
+ {
2568
+ #if TARGET_OS_OSX
2569
+ RCTExecuteOnMainQueue(^{
2570
+ NSString *targetIdentifier = [self normalizeIdentifier:identifier];
2571
+ NSWindow *window = (NSWindow *)self.windows[targetIdentifier];
2572
+ if (!window) {
2573
+ resolve([self failureJson:@"No window to close"]);
2574
+ return;
2575
+ }
2576
+ [self handleWindowClosedForIdentifier:targetIdentifier closeWindow:YES];
2577
+ resolve([self successJson]);
2578
+ });
2579
+ #else
2580
+ resolve([self failureJson:@"WindowManager is only available on macOS"]);
2581
+ #endif
2582
+ }
2583
+
2584
+ - (void)closeFrontmostWindow:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
2585
+ {
2586
+ #if TARGET_OS_OSX
2587
+ RCTExecuteOnMainQueue(^{
2588
+ NSWindow *window = NSApp.keyWindow ?: NSApp.mainWindow;
2589
+ if (!window) {
2590
+ resolve([self failureJson:@"No window to close"]);
2591
+ return;
2592
+ }
2593
+ NSString *identifier = [self identifierForWindow:window];
2594
+ if (identifier) {
2595
+ [self handleWindowClosedForIdentifier:identifier closeWindow:YES];
2596
+ } else {
2597
+ [window performClose:nil];
2598
+ }
2599
+ resolve([self successJson]);
2600
+ });
2601
+ #else
2602
+ resolve([self failureJson:@"WindowManager is only available on macOS"]);
2603
+ #endif
2604
+ }
2605
+
2606
+ - (void)showMainWindow:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
2607
+ {
2608
+ #if TARGET_OS_OSX
2609
+ RCTExecuteOnMainQueue(^{
2610
+ NSWindow *mainWindow = [RNWindowManager getMainWindow];
2611
+ if (!mainWindow) {
2612
+ resolve([self failureJson:@"Main window not found"]);
2613
+ return;
2614
+ }
2615
+ [NSApp activateIgnoringOtherApps:YES];
2616
+ [mainWindow makeKeyAndOrderFront:nil];
2617
+ resolve([self successJson]);
2618
+ });
2619
+ #else
2620
+ resolve([self failureJson:@"WindowManager is only available on macOS"]);
2621
+ #endif
2622
+ }
2623
+
2624
+ - (void)hideMainWindow:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
2625
+ {
2626
+ #if TARGET_OS_OSX
2627
+ RCTExecuteOnMainQueue(^{
2628
+ NSWindow *mainWindow = [RNWindowManager getMainWindow];
2629
+ if (!mainWindow) {
2630
+ resolve([self failureJson:@"Main window not found"]);
2631
+ return;
2632
+ }
2633
+ [mainWindow orderOut:nil];
2634
+ if (!LegendSafeMode() && !LegendTestDriverActive()) {
2635
+ [NSUserDefaults.standardUserDefaults removeObjectForKey:LegendMainWindowStartupSplitViewKey];
2636
+ }
2637
+ [self sendWindowEventWithName:@"onWindowClosed"
2638
+ body:@{@"identifier": @"main", @"moduleName": @"main"}];
2639
+ resolve([self successJson]);
2640
+ });
2641
+ #else
2642
+ resolve([self failureJson:@"WindowManager is only available on macOS"]);
2643
+ #endif
2644
+ }
2645
+
2646
+ - (void)showWindow:(NSString *)identifier resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
2647
+ {
2648
+ #if TARGET_OS_OSX
2649
+ RCTExecuteOnMainQueue(^{
2650
+ NSString *targetIdentifier = [self normalizeIdentifier:identifier];
2651
+ NSWindow *window = (NSWindow *)self.windows[targetIdentifier];
2652
+ if (!window) {
2653
+ reject(@"E_NOT_FOUND", @"Window not found", nil);
2654
+ return;
2655
+ }
2656
+
2657
+ [NSApp activateIgnoringOtherApps:YES];
2658
+ [window makeKeyAndOrderFront:nil];
2659
+ resolve([self successJson]);
2660
+ });
2661
+ #else
2662
+ resolve([self failureJson:@"WindowManager is only available on macOS"]);
2663
+ #endif
2664
+ }
2665
+
2666
+ - (void)setMainWindowOptions:(NSString *)optionsJson resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
2667
+ {
2668
+ #if TARGET_OS_OSX
2669
+ RCTExecuteOnMainQueue(^{
2670
+ NSWindow *mainWindow = [RNWindowManager getMainWindow];
2671
+ if (!mainWindow) {
2672
+ reject(@"E_NOT_FOUND", @"Main window not found", nil);
2673
+ return;
2674
+ }
2675
+
2676
+ NSDictionary *options = [self parseObjectJSON:optionsJson];
2677
+ // Safe and driver modes save no window chrome.
2678
+ id startupSplitView = (LegendSafeMode() || LegendTestDriverActive()) ? nil : options[@"windowStyle"][@"startupSplitView"];
2679
+ if ([startupSplitView isKindOfClass:NSDictionary.class]) {
2680
+ // Persist window chrome only, just like AppKit's saved frame. No document data.
2681
+ if (![startupSplitView isEqual:[NSUserDefaults.standardUserDefaults dictionaryForKey:LegendMainWindowStartupSplitViewKey]]) {
2682
+ [NSUserDefaults.standardUserDefaults setObject:startupSplitView forKey:LegendMainWindowStartupSplitViewKey];
2683
+ }
2684
+ } else if (startupSplitView == NSNull.null) {
2685
+ [NSUserDefaults.standardUserDefaults removeObjectForKey:LegendMainWindowStartupSplitViewKey];
2686
+ }
2687
+ LegendApplyWindowOptions(mainWindow, options);
2688
+ [self applyTitlebarControlsFromOptions:options toWindow:mainWindow identifier:@"main"];
2689
+ [self applyToolbarItemsFromOptions:options toWindow:mainWindow identifier:@"main"];
2690
+ [self applyTitlebarMaterialFromOptions:options toWindow:mainWindow identifier:@"main"];
2691
+ resolve([self successJson]);
2692
+ });
2693
+ #else
2694
+ resolve([self failureJson:@"WindowManager is only available on macOS"]);
2695
+ #endif
2696
+ }
2697
+
2698
+ - (void)setWindowOptions:(NSString *)identifier
2699
+ optionsJson:(NSString *)optionsJson
2700
+ resolve:(RCTPromiseResolveBlock)resolve
2701
+ reject:(RCTPromiseRejectBlock)reject
2702
+ {
2703
+ #if TARGET_OS_OSX
2704
+ RCTExecuteOnMainQueue(^{
2705
+ NSString *targetIdentifier = [self normalizeIdentifier:identifier];
2706
+ NSDictionary *options = [self parseObjectJSON:optionsJson];
2707
+ NSWindow *window = (NSWindow *)self.windows[targetIdentifier];
2708
+ if (!window) {
2709
+ reject(@"E_NOT_FOUND", @"Window not found", nil);
2710
+ return;
2711
+ }
2712
+ [self recordWindowOptions:options
2713
+ identifier:targetIdentifier
2714
+ moduleName:self.moduleNames[targetIdentifier] ?: @""];
2715
+ LegendApplyWindowOptions(window, options);
2716
+ [self applyTitlebarControlsFromOptions:options toWindow:window identifier:targetIdentifier];
2717
+ [self applyToolbarItemsFromOptions:options toWindow:window identifier:targetIdentifier];
2718
+ [self applyTitlebarMaterialFromOptions:options toWindow:window identifier:targetIdentifier];
2719
+ RCTUIView *rootView = self.rootViews[targetIdentifier];
2720
+ LegendSizeRootViewToWindow(rootView, window);
2721
+ resolve([self successJson]);
2722
+ });
2723
+ #else
2724
+ resolve([self failureJson:@"WindowManager is only available on macOS"]);
2725
+ #endif
2726
+ }
2727
+
2728
+ - (void)getMainWindowFrame:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
2729
+ {
2730
+ #if TARGET_OS_OSX
2731
+ RCTExecuteOnMainQueue(^{
2732
+ NSWindow *mainWindow = [RNWindowManager getMainWindow];
2733
+ if (!mainWindow) {
2734
+ reject(@"no_main_window", @"Main window not found", nil);
2735
+ return;
2736
+ }
2737
+ resolve([self jsonStringFromObject:[self frameDictionary:mainWindow.frame]]);
2738
+ });
2739
+ #else
2740
+ resolve([self jsonStringFromObject:@{@"x": @0, @"y": @0, @"width": @0, @"height": @0}]);
2741
+ #endif
2742
+ }
2743
+
2744
+ - (void)setMainWindowFrame:(NSString *)frameJson resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
2745
+ {
2746
+ #if TARGET_OS_OSX
2747
+ RCTExecuteOnMainQueue(^{
2748
+ NSWindow *mainWindow = [RNWindowManager getMainWindow];
2749
+ if (!mainWindow) {
2750
+ reject(@"no_main_window", @"Main window not found", nil);
2751
+ return;
2752
+ }
2753
+ NSDictionary *frameDict = [self parseObjectJSON:frameJson];
2754
+ NSRect newFrame = NSMakeRect([frameDict[@"x"] doubleValue],
2755
+ [frameDict[@"y"] doubleValue],
2756
+ [frameDict[@"width"] doubleValue],
2757
+ [frameDict[@"height"] doubleValue]);
2758
+ [mainWindow setFrame:newFrame display:YES animate:NO];
2759
+ resolve([self successJson]);
2760
+ });
2761
+ #else
2762
+ resolve([self failureJson:@"WindowManager is only available on macOS"]);
2763
+ #endif
2764
+ }
2765
+
2766
+ - (void)setWindowBlur:(NSString *)identifier
2767
+ radius:(double)radius
2768
+ durationMs:(double)durationMs
2769
+ resolve:(RCTPromiseResolveBlock)resolve
2770
+ reject:(RCTPromiseRejectBlock)reject
2771
+ {
2772
+ #if TARGET_OS_OSX
2773
+ RCTExecuteOnMainQueue(^{
2774
+ NSString *targetIdentifier = [self normalizeIdentifier:identifier];
2775
+ NSWindow *window = (NSWindow *)self.windows[targetIdentifier];
2776
+ if (!window) {
2777
+ reject(@"E_NOT_FOUND", @"Target window not found for blur animation", nil);
2778
+ return;
2779
+ }
2780
+
2781
+ RCTUIView *rootView = self.rootViews[targetIdentifier];
2782
+ NSView *contentView = window.contentView ?: rootView;
2783
+ if (!contentView) {
2784
+ reject(@"no_content_view", @"Window does not have a content view to blur", nil);
2785
+ return;
2786
+ }
2787
+
2788
+ contentView.wantsLayer = YES;
2789
+ contentView.layerUsesCoreImageFilters = YES;
2790
+ if (!contentView.layer) {
2791
+ contentView.layer = [CALayer layer];
2792
+ }
2793
+ contentView.layer.masksToBounds = NO;
2794
+
2795
+ CIFilter *blurFilter = self.windowBlurFilters[targetIdentifier];
2796
+ if (!blurFilter) {
2797
+ blurFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
2798
+ if (!blurFilter) {
2799
+ reject(@"filter_unavailable", @"CIGaussianBlur filter could not be created", nil);
2800
+ return;
2801
+ }
2802
+ blurFilter.name = @"legendOverlayBlur";
2803
+ [blurFilter setDefaults];
2804
+ [blurFilter setValue:@0 forKey:kCIInputRadiusKey];
2805
+ self.windowBlurFilters[targetIdentifier] = blurFilter;
2806
+ }
2807
+
2808
+ BOOL filterAttached = NO;
2809
+ for (id existingFilter in contentView.layer.filters ?: @[]) {
2810
+ if ([existingFilter isKindOfClass:CIFilter.class] && [[existingFilter name] isEqualToString:@"legendOverlayBlur"]) {
2811
+ filterAttached = YES;
2812
+ break;
2813
+ }
2814
+ }
2815
+ if (!filterAttached) {
2816
+ NSMutableArray *filters = [NSMutableArray arrayWithArray:contentView.layer.filters ?: @[]];
2817
+ [filters addObject:blurFilter];
2818
+ contentView.layer.filters = filters;
2819
+ }
2820
+
2821
+ CGFloat targetRadius = radius;
2822
+ CGFloat currentRadius = [[blurFilter valueForKey:kCIInputRadiusKey] doubleValue];
2823
+ NSTimeInterval durationSeconds = durationMs / 1000.0;
2824
+ if (durationSeconds <= 0) {
2825
+ [CATransaction begin];
2826
+ [CATransaction setDisableActions:YES];
2827
+ [blurFilter setValue:@(targetRadius) forKey:kCIInputRadiusKey];
2828
+ [CATransaction commit];
2829
+ [contentView.layer removeAnimationForKey:@"legendOverlayBlurAnimation"];
2830
+ resolve([self successJson]);
2831
+ return;
2832
+ }
2833
+
2834
+ [contentView.layer removeAnimationForKey:@"legendOverlayBlurAnimation"];
2835
+ CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"filters.legendOverlayBlur.inputRadius"];
2836
+ animation.fromValue = @(currentRadius);
2837
+ animation.toValue = @(targetRadius);
2838
+ animation.duration = durationSeconds;
2839
+ animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
2840
+ animation.fillMode = kCAFillModeForwards;
2841
+ animation.removedOnCompletion = NO;
2842
+
2843
+ [CATransaction begin];
2844
+ [CATransaction setCompletionBlock:^{
2845
+ [CATransaction begin];
2846
+ [CATransaction setDisableActions:YES];
2847
+ [blurFilter setValue:@(targetRadius) forKey:kCIInputRadiusKey];
2848
+ [CATransaction commit];
2849
+ resolve([self successJson]);
2850
+ }];
2851
+ [contentView.layer addAnimation:animation forKey:@"legendOverlayBlurAnimation"];
2852
+ [CATransaction commit];
2853
+ });
2854
+ #else
2855
+ resolve([self failureJson:@"WindowManager is only available on macOS"]);
2856
+ #endif
2857
+ }
2858
+
2859
+ #if TARGET_OS_OSX
2860
+ + (NSWindow *)getMainWindow
2861
+ {
2862
+ // AppKit's window list includes precreated/restored document windows and has
2863
+ // no stable ordering. Both supported hosts own the main window on the delegate.
2864
+ id<RNWindowManagerRootViewFactoryProvider> delegate = (id)NSApplication.sharedApplication.delegate;
2865
+ return [delegate respondsToSelector:@selector(window)] ? delegate.window : nil;
2866
+ }
2867
+
2868
+ - (void)setupMainWindowObservers
2869
+ {
2870
+ if (self.mainWindowObserversInstalled) {
2871
+ return;
2872
+ }
2873
+ NSWindow *mainWindow = [RNWindowManager getMainWindow];
2874
+ if (!mainWindow) {
2875
+ return;
2876
+ }
2877
+ self.mainWindowObserversInstalled = YES;
2878
+ NSNotificationCenter *center = NSNotificationCenter.defaultCenter;
2879
+ [center addObserver:self selector:@selector(mainWindowDidMove:) name:NSWindowDidMoveNotification object:mainWindow];
2880
+ [center addObserver:self selector:@selector(mainWindowDidResize:) name:NSWindowDidResizeNotification object:mainWindow];
2881
+ [center addObserver:self selector:@selector(mainWindowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:mainWindow];
2882
+ }
2883
+
2884
+ - (void)mainWindowDidMove:(NSNotification *)notification
2885
+ {
2886
+ NSWindow *window = notification.object;
2887
+ [self sendWindowEventWithName:@"onMainWindowMoved" body:[self frameDictionary:window.frame]];
2888
+ }
2889
+
2890
+ - (void)mainWindowDidResize:(NSNotification *)notification
2891
+ {
2892
+ NSWindow *window = notification.object;
2893
+ RCTUIView *rootView = LegendManagedRootView(window);
2894
+ if (rootView) {
2895
+ LegendSizeRootViewToWindow(rootView, window);
2896
+ }
2897
+ [self sendWindowEventWithName:@"onMainWindowResized" body:[self frameDictionary:window.frame]];
2898
+ }
2899
+
2900
+ - (void)mainWindowDidBecomeKey:(NSNotification *)notification
2901
+ {
2902
+ [self sendWindowEventWithName:@"onWindowFocused" body:@{@"identifier": @"main", @"moduleName": @"main"}];
2903
+ }
2904
+
2905
+ - (void)windowDidBecomeKey:(NSNotification *)notification
2906
+ {
2907
+ NSString *identifier = [self identifierForWindow:notification.object];
2908
+ if (!identifier) {
2909
+ return;
2910
+ }
2911
+ [self sendWindowEventWithName:@"onWindowFocused"
2912
+ body:@{@"identifier": identifier, @"moduleName": self.moduleNames[identifier] ?: @""}];
2913
+ }
2914
+
2915
+ - (void)windowDidMove:(NSNotification *)notification
2916
+ {
2917
+ NSWindow *window = notification.object;
2918
+ NSString *identifier = [self identifierForWindow:window];
2919
+ if (!identifier) {
2920
+ return;
2921
+ }
2922
+ [self sendWindowEventWithName:@"onWindowMoved"
2923
+ body:@{
2924
+ @"identifier": identifier,
2925
+ @"moduleName": self.moduleNames[identifier] ?: @"",
2926
+ @"frame": [self frameDictionary:window.frame],
2927
+ }];
2928
+ }
2929
+
2930
+ - (void)windowDidResize:(NSNotification *)notification
2931
+ {
2932
+ NSWindow *window = notification.object;
2933
+ NSString *identifier = [self identifierForWindow:window];
2934
+ if (!identifier) {
2935
+ return;
2936
+ }
2937
+ RCTUIView *rootView = LegendManagedRootView(window);
2938
+ if (rootView) {
2939
+ LegendSizeRootViewToWindow(rootView, window);
2940
+ }
2941
+ [self sendWindowEventWithName:@"onWindowResized"
2942
+ body:@{
2943
+ @"identifier": identifier,
2944
+ @"moduleName": self.moduleNames[identifier] ?: @"",
2945
+ @"frame": [self frameDictionary:window.frame],
2946
+ }];
2947
+ }
2948
+
2949
+ - (void)windowWillClose:(NSNotification *)notification
2950
+ {
2951
+ NSString *identifier = [self identifierForWindow:notification.object];
2952
+ if (identifier) {
2953
+ [self handleWindowClosedForIdentifier:identifier closeWindow:NO];
2954
+ }
2955
+ }
2956
+
2957
+ - (void)sendWindowEventWithName:(NSString *)eventName body:(id)body
2958
+ {
2959
+ #if __has_include(<RNDesktopApp/SparkDesktop.h>)
2960
+ NSString *type = nil;
2961
+ if ([eventName isEqual:@"onTitlebarControlPressed"]) type = @"titleBarAction";
2962
+ else if ([eventName isEqual:@"onToolbarItemSelected"]) type = body[@"action"] ? @"toolbarMenuAction" : [body[@"kind"] isEqual:@"selection"] ? @"toolbarSelectionChanged" : @"toolbarAction";
2963
+ else if ([eventName isEqual:@"onToolbarSearch"]) type = [body[@"submitted"] boolValue] ? @"toolbarSearchSubmitted" : @"toolbarSearchChanged";
2964
+ if (type) {
2965
+ NSMutableDictionary *event = [body mutableCopy]; event[@"type"] = type; event[@"windowId"] = body[@"identifier"] ?: @"";
2966
+ SparkEmit(event); return;
2967
+ }
2968
+ #endif
2969
+
2970
+ if (!self.hasListeners) {
2971
+ return;
2972
+ }
2973
+ [self sendEventWithName:eventName body:body];
2974
+ }
2975
+
2976
+ #if __has_include(<RNDesktopApp/SparkDesktop.h>)
2977
+ - (void)sparkDesktopEvent:(NSNotification *)notification
2978
+ {
2979
+ NSDictionary *event = notification.userInfo;
2980
+ if ([event[@"type"] isEqual:@"reopen"]) {
2981
+ // A visible host can have been hidden while other managed windows remained.
2982
+ BOOL mainHidden = [SparkLifecycleConfiguration()[@"mainWindow"][@"hidden"] boolValue] || [SparkLifecycleConfiguration()[@"mainWindow"][@"reopenBehavior"] isEqual:@"visibleWindows"];
2983
+ NSNumber *visible = mainHidden ? event[@"hasVisibleWindows"] : event[@"mainWindowWasVisible"];
2984
+ [self sendWindowEventWithName:@"onApplicationReopenRequested" body:@{@"hasVisibleWindows": visible ?: @NO}];
2985
+ } else if ([event[@"type"] isEqual:@"closeRequested"] && [event[@"windowId"] isEqual:@"main"]) {
2986
+ [self mainWindowCloseRequested:notification];
2987
+ }
2988
+ }
2989
+ #endif
2990
+
2991
+ - (void)applicationReopenRequested:(NSNotification *)notification
2992
+ {
2993
+ NSNumber *hasVisibleWindows = notification.userInfo[@"hasVisibleWindows"];
2994
+ [self sendWindowEventWithName:@"onApplicationReopenRequested"
2995
+ body:@{@"hasVisibleWindows": hasVisibleWindows ?: @NO}];
2996
+ }
2997
+
2998
+ - (void)applicationWillTerminate:(NSNotification *)notification
2999
+ {
3000
+ LegendApplicationIsTerminating = YES;
3001
+ }
3002
+
3003
+ - (void)mainWindowCloseRequested:(NSNotification *)notification
3004
+ {
3005
+ [self sendWindowEventWithName:@"onWindowCloseRequested"
3006
+ body:@{@"identifier": @"main", @"moduleName": @"main"}];
3007
+ }
3008
+
3009
+ - (void)screensChanged:(NSNotification *)notification
3010
+ {
3011
+ [self sendWindowEventWithName:@"onDisplaysChanged" body:[self displayDictionaries]];
3012
+ }
3013
+
3014
+ - (BOOL)windowShouldClose:(NSWindow *)window
3015
+ {
3016
+ NSString *identifier = [self identifierForWindow:window];
3017
+ if (!identifier) {
3018
+ return NO;
3019
+ }
3020
+
3021
+ if ([self.closeRequestIdentifiers containsObject:identifier]) {
3022
+ [self sendWindowEventWithName:@"onWindowCloseRequested"
3023
+ body:@{@"identifier": identifier, @"moduleName": self.moduleNames[identifier] ?: @""}];
3024
+ return NO;
3025
+ }
3026
+
3027
+ return YES;
3028
+ }
3029
+
3030
+ - (NSDictionary *)frameDictionary:(NSRect)frame
3031
+ {
3032
+ return @{
3033
+ @"x": @(frame.origin.x),
3034
+ @"y": @(frame.origin.y),
3035
+ @"width": @(frame.size.width),
3036
+ @"height": @(frame.size.height),
3037
+ };
3038
+ }
3039
+
3040
+ - (NSString *)identifierForWindow:(NSWindow *)window
3041
+ {
3042
+ if (!window) {
3043
+ return nil;
3044
+ }
3045
+ for (NSString *identifier in self.windows.allKeys) {
3046
+ if ((NSWindow *)self.windows[identifier] == window) {
3047
+ return identifier;
3048
+ }
3049
+ }
3050
+ return nil;
3051
+ }
3052
+
3053
+ - (void)handleWindowClosedForIdentifier:(NSString *)identifier closeWindow:(BOOL)shouldCloseWindow
3054
+ {
3055
+ NSString *moduleName = self.moduleNames[identifier] ?: @"";
3056
+ NSWindow *window = (NSWindow *)self.windows[identifier];
3057
+ RCTUIView *rootView = self.rootViews[identifier];
3058
+ CIFilter *blurFilter = self.windowBlurFilters[identifier];
3059
+ if (blurFilter) {
3060
+ NSView *contentView = window.contentView ?: rootView;
3061
+ if (contentView.layer) {
3062
+ [contentView.layer removeAnimationForKey:@"legendOverlayBlurAnimation"];
3063
+ NSMutableArray *remainingFilters = [NSMutableArray array];
3064
+ for (id filter in contentView.layer.filters ?: @[]) {
3065
+ if ([filter isKindOfClass:CIFilter.class] && [[filter name] isEqualToString:@"legendOverlayBlur"]) {
3066
+ continue;
3067
+ }
3068
+ [remainingFilters addObject:filter];
3069
+ }
3070
+ contentView.layer.filters = remainingFilters;
3071
+ }
3072
+ }
3073
+ [self.windowBlurFilters removeObjectForKey:identifier];
3074
+ if (window) {
3075
+ [self removeTitlebarMaterialForIdentifier:identifier];
3076
+ [self removeTitlebarControlsForIdentifier:identifier fromWindow:window];
3077
+ NSToolbar *toolbar = window.toolbar;
3078
+ if (toolbar) {
3079
+ if (toolbar.identifier) {
3080
+ [self.toolbarItemConfigs removeObjectForKey:toolbar.identifier];
3081
+ }
3082
+ toolbar.delegate = nil;
3083
+ while (toolbar.items.count > 0) {
3084
+ [toolbar removeItemAtIndex:toolbar.items.count - 1];
3085
+ }
3086
+ window.toolbar = nil;
3087
+ }
3088
+ window.delegate = nil;
3089
+ if (rootView) {
3090
+ [rootView removeFromSuperview];
3091
+ objc_setAssociatedObject(window, &LegendManagedRootViewKey, nil, OBJC_ASSOCIATION_ASSIGN);
3092
+ }
3093
+ NSView *emptyContentView = [[NSView alloc] initWithFrame:window.contentView ? window.contentView.frame : NSZeroRect];
3094
+ emptyContentView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
3095
+ window.contentView = emptyContentView;
3096
+ } else {
3097
+ [self.titlebarMaterialViews removeObjectForKey:identifier];
3098
+ [self.titlebarAccessoryControllers removeObjectForKey:identifier];
3099
+ }
3100
+ [self.closeRequestIdentifiers removeObject:identifier];
3101
+ [self.toolbarItemConfigs removeObjectForKey:identifier];
3102
+ NSDictionary *windowOptions = self.windowOptions[identifier];
3103
+ if (!LegendApplicationIsTerminating && [windowOptions[@"restoreOnLaunch"] boolValue]) {
3104
+ LegendSetRestorableWindowOptions(identifier, nil);
3105
+ }
3106
+ [self.windows removeObjectForKey:identifier];
3107
+ [self.rootViews removeObjectForKey:identifier];
3108
+ [self.moduleNames removeObjectForKey:identifier];
3109
+ [self.windowOptions removeObjectForKey:identifier];
3110
+ if (shouldCloseWindow && window) {
3111
+ [window close];
3112
+ }
3113
+ [self sendWindowEventWithName:@"onWindowClosed" body:@{@"identifier": identifier ?: @"", @"moduleName": moduleName ?: @""}];
3114
+ }
3115
+
3116
+ - (void)recordWindowOptions:(NSDictionary *)options identifier:(NSString *)identifier moduleName:(NSString *)moduleName
3117
+ {
3118
+ if (identifier.length == 0 || ![options isKindOfClass:NSDictionary.class]) {
3119
+ return;
3120
+ }
3121
+
3122
+ NSDictionary *persistedOptions = LegendFindRestorableWindowOptions(identifier);
3123
+ NSDictionary *previousOptions = self.windowOptions[identifier] ?: persistedOptions ?: @{};
3124
+ NSMutableDictionary *mergedOptions = [previousOptions mutableCopy];
3125
+ [mergedOptions addEntriesFromDictionary:options];
3126
+ NSDictionary *previousWindowStyle = [previousOptions[@"windowStyle"] isKindOfClass:NSDictionary.class]
3127
+ ? previousOptions[@"windowStyle"]
3128
+ : @{};
3129
+ NSDictionary *nextWindowStyle = [options[@"windowStyle"] isKindOfClass:NSDictionary.class]
3130
+ ? options[@"windowStyle"]
3131
+ : nil;
3132
+ if (nextWindowStyle) {
3133
+ NSMutableDictionary *mergedWindowStyle = [previousWindowStyle mutableCopy];
3134
+ [mergedWindowStyle addEntriesFromDictionary:nextWindowStyle];
3135
+ mergedOptions[@"windowStyle"] = mergedWindowStyle;
3136
+ }
3137
+ mergedOptions[@"identifier"] = identifier;
3138
+ if (moduleName.length > 0) {
3139
+ mergedOptions[@"moduleName"] = moduleName;
3140
+ }
3141
+ self.windowOptions[identifier] = mergedOptions;
3142
+
3143
+ if (LegendDictionaryHasKey(options, @"restoreOnLaunch")) {
3144
+ if ([options[@"restoreOnLaunch"] boolValue]) {
3145
+ LegendSetRestorableWindowOptions(identifier, mergedOptions);
3146
+ } else {
3147
+ LegendSetRestorableWindowOptions(identifier, nil);
3148
+ LegendRemovePrecreatedWindow(identifier);
3149
+ }
3150
+ } else if ([mergedOptions[@"restoreOnLaunch"] boolValue]) {
3151
+ LegendSetRestorableWindowOptions(identifier, mergedOptions);
3152
+ }
3153
+ }
3154
+
3155
+ - (NSDictionary *)initialPropsFromOptions:(NSDictionary *)options
3156
+ {
3157
+ id initialPropsCandidate = options[@"initialProperties"];
3158
+ return [initialPropsCandidate isKindOfClass:NSDictionary.class] ? initialPropsCandidate : nil;
3159
+ }
3160
+
3161
+ - (NSString *)normalizeIdentifier:(NSString *)identifier
3162
+ {
3163
+ return [identifier isKindOfClass:NSString.class] && identifier.length > 0 ? identifier : @"default";
3164
+ }
3165
+ #endif
3166
+
3167
+ - (void)invalidate
3168
+ {
3169
+ // React's host restarts the existing surfaces on reload. Keep their native
3170
+ // registry, but retire this runtime's observers and event delivery.
3171
+ self.hasListeners = NO;
3172
+ #if TARGET_OS_OSX
3173
+ [NSNotificationCenter.defaultCenter removeObserver:self];
3174
+ #endif
3175
+ [super invalidate];
3176
+ }
3177
+
3178
+ - (void)dealloc
3179
+ {
3180
+ #if TARGET_OS_OSX
3181
+ if (self.displaySleepActivity) {
3182
+ [NSProcessInfo.processInfo endActivity:self.displaySleepActivity];
3183
+ self.displaySleepActivity = nil;
3184
+ }
3185
+ [NSNotificationCenter.defaultCenter removeObserver:self];
3186
+ #endif
3187
+ }
3188
+
3189
+ @end