@legendapp/spark 0.0.3 → 0.0.5

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 (202) hide show
  1. package/init-template.cjs +7 -1
  2. package/package.json +11 -6
  3. package/patches/dependencies.json +4 -4
  4. package/patches/react-native-mmkv@4.3.2.patch +2 -2
  5. package/patches/react-native-nitro-zxing@0.3.1.patch +22 -0
  6. package/patches/registry.json +615 -0
  7. package/patches/workspace/expo-audio@55.0.18.patch +159 -0
  8. package/patches/workspace/op-engineering-op-sqlite@18.2.1.patch +796 -0
  9. package/patches/workspace/react-native-nitro-modules@0.37.0.patch +1348 -0
  10. package/patches/workspace/react-native-runtimes-core@0.1.0-alpha.2.patch +276 -0
  11. package/patches/workspace/react-native-webview@16.0.0.patch +208 -0
  12. package/postinstall.cjs +10 -1
  13. package/skills/spark/SKILL.md +37 -4
  14. package/skills/spark/UPGRADING.md +174 -1
  15. package/skills/spark/ai-customize.md +39 -0
  16. package/skills/spark/app-and-documents.md +56 -0
  17. package/skills/spark/external-libraries.md +87 -0
  18. package/skills/spark/files.md +64 -0
  19. package/skills/spark/integrations.md +69 -0
  20. package/skills/spark/keyboard.md +54 -0
  21. package/skills/spark/library-compat.md +76 -0
  22. package/skills/spark/menus-tray-dock.md +83 -0
  23. package/skills/spark/storage-settings.md +59 -0
  24. package/skills/spark/ui.md +83 -0
  25. package/skills/spark/windows.md +91 -0
  26. package/ui-popover.ts +1 -0
  27. package/ui-progress.ts +1 -0
  28. package/ui-sheet.ts +1 -0
  29. package/ui-split-view.ts +1 -0
  30. package/ui-table.ts +1 -0
  31. package/vendor/node_modules/@legendapp/spark-ai/package.json +3 -3
  32. package/vendor/node_modules/@legendapp/spark-audio/package.json +3 -13
  33. package/vendor/node_modules/@legendapp/spark-auth-session/package.json +3 -10
  34. package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +5 -0
  35. package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +157 -106
  36. package/vendor/node_modules/@legendapp/spark-cli/dist/cli-arguments.js +4 -1
  37. package/vendor/node_modules/@legendapp/spark-cli/dist/commands.js +16 -7
  38. package/vendor/node_modules/@legendapp/spark-cli/dist/dependency-pins.js +19 -3
  39. package/vendor/node_modules/@legendapp/spark-cli/dist/dev-command.js +2 -0
  40. package/vendor/node_modules/@legendapp/spark-cli/dist/dev.js +3 -0
  41. package/vendor/node_modules/@legendapp/spark-cli/dist/enriched-html-pins.js +2 -0
  42. package/vendor/node_modules/@legendapp/spark-cli/dist/errors.js +1 -1
  43. package/vendor/node_modules/@legendapp/spark-cli/dist/index.js +57 -9
  44. package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.cjs +12 -2
  45. package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.d.cts +1 -1
  46. package/vendor/node_modules/@legendapp/spark-cli/dist/metro.cjs +1 -0
  47. package/vendor/node_modules/@legendapp/spark-cli/dist/migrate.js +65 -0
  48. package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.cjs +4 -4
  49. package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.d.cts +2 -2
  50. package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.cjs +15 -8
  51. package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +35 -7
  52. package/vendor/node_modules/@legendapp/spark-cli/dist/package.js +4 -8
  53. package/vendor/node_modules/@legendapp/spark-cli/dist/patch.js +92 -0
  54. package/vendor/node_modules/@legendapp/spark-cli/dist/project-version.js +12 -4
  55. package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +8 -1
  56. package/vendor/node_modules/@legendapp/spark-cli/dist/publish-directory.js +32 -0
  57. package/vendor/node_modules/@legendapp/spark-cli/dist/release-app.js +139 -0
  58. package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +17 -17
  59. package/vendor/node_modules/@legendapp/spark-cli/dist/signing.js +61 -41
  60. package/vendor/node_modules/@legendapp/spark-cli/dist/upgrade.js +1 -1
  61. package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +3 -0
  62. package/vendor/node_modules/@legendapp/spark-cli/package.json +5 -4
  63. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +2 -2
  64. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +2 -2
  65. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +2 -2
  66. package/vendor/node_modules/@legendapp/spark-clipboard/macos/RNDesktopClipboard.mm +1 -1
  67. package/vendor/node_modules/@legendapp/spark-clipboard/package.json +3 -10
  68. package/vendor/node_modules/@legendapp/spark-clipboard/src/desktop.ts +1 -0
  69. package/vendor/node_modules/@legendapp/spark-codex/package.json +3 -7
  70. package/vendor/node_modules/@legendapp/spark-commands/package.json +5 -5
  71. package/vendor/node_modules/@legendapp/spark-context-menu/package.json +3 -10
  72. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.h +3 -1
  73. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +51 -10
  74. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.h +4 -0
  75. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.mm +82 -0
  76. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.h +2 -0
  77. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.mm +1 -0
  78. package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +2 -8
  79. package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.cjs +1 -0
  80. package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +6 -8
  81. package/vendor/node_modules/@legendapp/spark-desktop-config/identity.cjs +2 -0
  82. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs +300 -71
  83. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.d.cts +7 -0
  84. package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +3 -3
  85. package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.cjs +318 -0
  86. package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.d.cts +20 -0
  87. package/vendor/node_modules/@legendapp/spark-desktop-config/rpaths.cjs +20 -0
  88. package/vendor/node_modules/@legendapp/spark-desktop-config/rpaths.d.cts +1 -0
  89. package/vendor/node_modules/@legendapp/spark-desktop-config/validation.cjs +66 -9
  90. package/vendor/node_modules/@legendapp/spark-desktop-config/windows.plugin.cjs +1 -0
  91. package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +17 -5
  92. package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +2 -2
  93. package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +3 -10
  94. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +3 -10
  95. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.mm +7 -2
  96. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +235 -240
  97. package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +4 -11
  98. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/api.ts +9 -3
  99. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +7 -0
  100. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/types.ts +32 -3
  101. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/validation.ts +28 -11
  102. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/createWindowsNavigator.tsx +15 -3
  103. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/primaryWindowLifecycle.ts +12 -3
  104. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/usePrimaryWindowLifecycle.ts +2 -1
  105. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/useWindowFocusEffect.ts +4 -1
  106. package/vendor/node_modules/@legendapp/spark-documents/package.json +7 -7
  107. package/vendor/node_modules/@legendapp/spark-drag-drop/macos/RNDesktopDragView.mm +77 -17
  108. package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +3 -8
  109. package/vendor/node_modules/@legendapp/spark-drag-drop/src/DesktopDragViewNativeComponent.ts +1 -0
  110. package/vendor/node_modules/@legendapp/spark-drag-drop/src/contracts.ts +13 -4
  111. package/vendor/node_modules/@legendapp/spark-drag-drop/src/index.tsx +5 -3
  112. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.h +6 -1
  113. package/vendor/node_modules/@legendapp/spark-expo-compat/metro.cjs +44 -0
  114. package/vendor/node_modules/@legendapp/spark-expo-compat/package.json +20 -0
  115. package/vendor/node_modules/@legendapp/spark-expo-compat/src/clipboard.ts +40 -0
  116. package/vendor/node_modules/@legendapp/spark-expo-compat/src/document-picker.ts +52 -0
  117. package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +3 -10
  118. package/vendor/node_modules/@legendapp/spark-file-dialog/src/options.ts +5 -2
  119. package/vendor/node_modules/@legendapp/spark-file-dialog/src/types.ts +3 -3
  120. package/vendor/node_modules/@legendapp/spark-file-system/macos/RNDesktopFileSystem.mm +1 -1
  121. package/vendor/node_modules/@legendapp/spark-file-system/package.json +3 -11
  122. package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +3 -10
  123. package/vendor/node_modules/@legendapp/spark-html/package.json +2 -2
  124. package/vendor/node_modules/@legendapp/spark-markdown/package.json +2 -2
  125. package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +3 -10
  126. package/vendor/node_modules/@legendapp/spark-message-dialog/src/index.ts +1 -0
  127. package/vendor/node_modules/@legendapp/spark-native-menu/package.json +3 -9
  128. package/vendor/node_modules/@legendapp/spark-native-menu/src/hooks.ts +4 -0
  129. package/vendor/node_modules/@legendapp/spark-notifications/package.json +3 -10
  130. package/vendor/node_modules/@legendapp/spark-processes/package.json +3 -10
  131. package/vendor/node_modules/@legendapp/spark-rich-text/package.json +2 -2
  132. package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +3 -10
  133. package/vendor/node_modules/@legendapp/spark-settings/package.json +3 -3
  134. package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +4 -4
  135. package/vendor/node_modules/@legendapp/spark-settings-ui/src/index.tsx +122 -334
  136. package/vendor/node_modules/@legendapp/spark-settings-ui/src/rows.tsx +183 -0
  137. package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
  138. package/vendor/node_modules/@legendapp/spark-system/package.json +3 -10
  139. package/vendor/node_modules/@legendapp/spark-tray/package.json +3 -10
  140. package/vendor/node_modules/@legendapp/spark-tray/src/index.ts +2 -1
  141. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.mm +82 -14
  142. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.h +1 -1
  143. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.mm +94 -11
  144. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +235 -18
  145. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.h +17 -0
  146. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.mm +216 -0
  147. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.h +4 -0
  148. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.mm +212 -0
  149. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewUpdates.h +6 -0
  150. package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +28 -13
  151. package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSelect.mm +17 -1
  152. package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.h +9 -0
  153. package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.mm +126 -0
  154. package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.h +9 -0
  155. package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.mm +66 -0
  156. package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.h +9 -0
  157. package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.mm +118 -0
  158. package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.mm +4 -12
  159. package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.h +9 -0
  160. package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.mm +109 -0
  161. package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +438 -102
  162. package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.h +9 -0
  163. package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.mm +179 -0
  164. package/vendor/node_modules/@legendapp/spark-ui/package.json +9 -8
  165. package/vendor/node_modules/@legendapp/spark-ui/src/SparkButtonNativeComponent.ts +10 -2
  166. package/vendor/node_modules/@legendapp/spark-ui/src/SparkTextInputNativeComponent.ts +2 -0
  167. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +9 -0
  168. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitView.tsx +99 -0
  169. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitViewNativeComponent.ts +29 -0
  170. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +34 -17
  171. package/vendor/node_modules/@legendapp/spark-ui/src/availability.ts +6 -4
  172. package/vendor/node_modules/@legendapp/spark-ui/src/checkbox-unavailable.tsx +20 -0
  173. package/vendor/node_modules/@legendapp/spark-ui/src/control.ts +24 -3
  174. package/vendor/node_modules/@legendapp/spark-ui/src/desktop.tsx +72 -20
  175. package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +18 -12
  176. package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +21 -15
  177. package/vendor/node_modules/@legendapp/spark-ui/src/index.web.tsx +40 -16
  178. package/vendor/node_modules/@legendapp/spark-ui/src/mobile-input.tsx +2 -2
  179. package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSegmentedControlNativeComponent.ts +3 -1
  180. package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSelectNativeComponent.ts +1 -0
  181. package/vendor/node_modules/@legendapp/spark-ui/src/popover/PopoverNativeComponent.ts +20 -0
  182. package/vendor/node_modules/@legendapp/spark-ui/src/popover/index.tsx +45 -0
  183. package/vendor/node_modules/@legendapp/spark-ui/src/progress/ProgressIndicatorNativeComponent.ts +13 -0
  184. package/vendor/node_modules/@legendapp/spark-ui/src/progress/index.tsx +32 -0
  185. package/vendor/node_modules/@legendapp/spark-ui/src/radio-group/RadioGroupNativeComponent.ts +17 -0
  186. package/vendor/node_modules/@legendapp/spark-ui/src/select.ts +4 -0
  187. package/vendor/node_modules/@legendapp/spark-ui/src/sheet/SheetNativeComponent.ts +15 -0
  188. package/vendor/node_modules/@legendapp/spark-ui/src/sheet/index.tsx +38 -0
  189. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarItemNativeComponent.ts +9 -1
  190. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarNativeComponent.ts +17 -2
  191. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/index.tsx +106 -22
  192. package/vendor/node_modules/@legendapp/spark-ui/src/switch.tsx +13 -0
  193. package/vendor/node_modules/@legendapp/spark-ui/src/table/TableNativeComponent.ts +22 -0
  194. package/vendor/node_modules/@legendapp/spark-ui/src/table/index.tsx +118 -0
  195. package/vendor/node_modules/@legendapp/spark-ui/src/types.ts +52 -7
  196. package/vendor/node_modules/@legendapp/spark-ui/uniwind.ts +3 -1
  197. package/vendor/node_modules/@legendapp/spark-ui/uniwind.web.ts +2 -1
  198. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.h +46 -15
  199. package/vendor/node_modules/@legendapp/spark-updates/package.json +3 -9
  200. package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
  201. package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
  202. /package/{settings-window.ts → ui-settings.ts} +0 -0
@@ -0,0 +1,76 @@
1
+ # Third-party libraries
2
+
3
+ Export: `@legendapp/spark/contracts` (`SparkError`, `Availability`, `Subscription`, `AsyncRegistration`). This file also covers how Spark treats other npm packages.
4
+
5
+ ## Rules
6
+
7
+ - **Expo Clipboard:** declare `expo-clipboard@55.0.17` and keep its original import. macOS supports text/HTML and PNG images; JPEG/quality options, URL methods, listeners and synchronous writes reject with `ERR_UNAVAILABLE`. `isPasteButtonAvailable` is false.
8
+ - **Keep the library's own import.** Write `import { Image } from 'expo-image'`, not a Spark path. Where a library has no macOS native view, Spark redirects that import to a stand-in (for example `expo-image` and `react-native-fast-image` become JS stand-ins on React Native's `Image`; `react-native-screens` uses its web implementation; `expo-document-picker` opens Spark's file dialog; native-stack uses a JS stack). Stand-ins cover a documented subset; check the integration table before relying on advanced features.
9
+ - **Spark doesn't wrap external libraries.** Use them directly: `react-native-vision-camera` for camera, `react-native-reanimated`, `@shopify/react-native-skia`, `expo-router`, `react-native-mmkv`, etc. Spark only patches them for macOS, pins tested versions and handles native setup. Exceptions are the deliberate Spark contracts: `/webview`, `/sqlite`, `/clipboard`, `/secure-storage`, `/links`.
10
+ - **Install the version Spark tested.** Patches apply to exact versions; an unsupported version stops native preparation with a repair prompt or CI install command. Declare libraries you import in the app's `package.json` and keep Spark's overrides/resolutions.
11
+ - **Native libraries need a custom build.** Adding one means `b` in `spark dev` or `spark build --dev`; the prebuilt Runner won't contain it.
12
+ - **Data locations are fixed for you.** Spark moves MMKV storage from `~/Documents/mmkv` to the app's Application Support folder; Release Profiler traces and Image Manipulator output go to the app's Caches folder. Nitro SQLite uses `~/Library/Application Support/<bundle id>`. Don't override these to user-visible folders.
13
+ - iOS-only modules on macOS typically become no-ops or report unavailable (Keyboard Controller events never fire, Tracking Transparency reports `unavailable`, Splash Screen does nothing). Don't build features that depend on them on desktop.
14
+
15
+ ## Versioned patch registry
16
+
17
+ Spark keeps exact tested versions in `patches/registry.json`, including redirect-only adapters and the minimum Spark version for each patch. Old versions and their patch files are retained. Run `bun scripts/patch-registry.ts` after adding a version; validation rejects missing files, changed hashes, ranges and unknown metadata. Preserve an existing patch file when adding a newer recipe; give the new recipe a distinct file and `minSpark` entry.
18
+
19
+ Install, `spark prebuild`, `spark dev` and `spark build` check installed libraries before native work. Spark reads the latest registry and patches from `LegendApp/legend-spark` main over HTTPS, pins all files to one commit SHA, and caches that set by SHA. If the fetch fails, it prints a one-line notice and uses the patches bundled with the installed SDK. Build receipts record `runtime.patchSourceSHA` as that commit or `bundled`.
20
+
21
+ Spark selects the newest patch for the exact installed library version whose `minSpark` supports the installed Spark. If a newer recipe needs a newer Spark, it offers `spark upgrade`; declining keeps the compatible recipe. If no compatible patch exists, a terminal lists patched versions with the newest compatible version as the default. Accepting updates `package.json` and reinstalls; declining stops. CI and piped commands fail with an exact install command. Shared `node_modules` installations prompt and repair at their shared root.
22
+
23
+ Use `"spark": { "patches": { "<library>": false } }` in `package.json` to skip a library's check and Spark patch. A shared-root opt-out applies to its apps. `spark doctor` reports the same version findings with a `Fix:` line without prompts, migrations or filesystem writes. App patches still layer after Spark's selected recipe. SDK-owned native archives retain their provenance checks; use the matching SDK archive overrides when installing them.
24
+
25
+ No new Expo-owned packages are added to this registry. Existing Expo patches and the existing Clipboard/Document Picker redirects remain supported.
26
+
27
+ ## Patch a library
28
+
29
+ Fix bugs every Spark app would hit in Spark's own patch (`patches/` in the Spark repository), not in one app. For an app-specific change:
30
+
31
+ 1. Run `spark patch <lib>`. It prints a temporary copy of the installed library with Spark's patch applied.
32
+ 2. Edit that copy, then run `spark patch <lib> --done`. It saves `patches/<lib>@<version>.patch` (scoped names use `+` for `/`) against the Spark-patched library and updates `node_modules`. From a monorepo root or a subfolder, it uses the nearest Spark app or folder with `patches/`; `--root <dir>` sets where the library is installed and `--out <dir>` where `patches/` goes.
33
+ 3. Commit the patch file. Native preparation applies Spark's patch first, then the app's; this works for any library, Spark-patched or not.
34
+
35
+ Run `spark doctor` after dependency upgrades to find stale app patch versions, patches for libraries that are not installed, and conflicts with Spark's patches. It checks convention files, patch-package files, and Bun/pnpm `patchedDependencies`, prints a `Fix:` line for each issue, and leaves installed files and receipts unchanged. For a stale or conflicting patch, save your changes, remove the old patch and any package-manager declaration, reinstall the library, then recreate the app patch with `spark patch <lib>`.
36
+
37
+ App roots that share one `node_modules` (monorepo workspaces) need the same app patches: native preparation stops when another root's patch for that library differs. Keep the patch at the shared root and copy it to every app.
38
+
39
+ App patches are pinned to the installed version. When Spark moves a pin, native preparation stops and names the patch to redo with `spark patch <lib>`; nothing is half-applied. Editing or deleting a patch file needs no reinstall: the library keeps the app patch it carries in `.spark-app.patch`, and native preparation undoes it before applying the current one. If preparation still can't apply a patch (the library was patched before Spark kept that file, or the patch targets a library that isn't a direct dependency), delete `node_modules/<lib>` and reinstall.
40
+
41
+ patch-package (`patches/<lib>+<version>.patch`) and Bun/pnpm `patchedDependencies` keep working. For a library Spark also patches, Spark treats that patch as the app layer and warns; prefer `spark patch` there, because package-manager patches are made against the unpatched library.
42
+
43
+ To drop Spark's patch for one library, set `"spark": { "patches": { "<lib>": false } }` in the app's `package.json`. The app's patch still applies alone; native preparation warns that desktop support for that library isn't guaranteed. `spark.patches` must be an object of booleans keyed by Spark-patched package names; unknown names and malformed values reject before patching. Unknown `package.json.spark` metadata keys also reject during discovery. App settings belong in `desktop.config.json` or Expo's `extra.spark`, where unknown keys also reject.
44
+
45
+ [external-libraries.md](external-libraries.md) lists every integrated library with the version Spark tested and its per-library limits on desktop.
46
+
47
+ ## Spark errors and availability
48
+
49
+ Every Spark capability exposes a `get<Feature>Availability()` that is safe without the native module installed; use it to decide whether to show a feature. Operations still reject when unavailable. Branch on `error.code`, never on the message:
50
+
51
+ ```ts
52
+ import { SparkError } from '@legendapp/spark/contracts';
53
+ import { getTrayAvailability } from '@legendapp/spark/tray';
54
+
55
+ if (!getTrayAvailability().available) console.log('No menu-bar item on this platform');
56
+
57
+ export function isMissing(error: unknown) {
58
+ return error instanceof SparkError && error.code === 'E_NOT_FOUND';
59
+ }
60
+ ```
61
+
62
+ Common codes: `E_INVALID_ARGUMENT`, `E_UNSUPPORTED_OPTION` (unknown or inapplicable option, never silently ignored), `E_UNSUPPORTED_PLATFORM`, `E_MODULE_UNAVAILABLE`, `E_PERMISSION_DENIED`, `E_NOT_FOUND`, `E_ALREADY_EXISTS`, `E_BUSY`, `E_TIMEOUT`, `E_NATIVE`.
63
+
64
+ ## Lifecycle conventions
65
+
66
+ Synchronous subscriptions return `{ remove(): void }`; async registrations (`createMenu`, `createTray`, `watch`, `preventSleep`, close/quit guards) return `{ remove(): Promise<void> }`. Always keep the handle and remove it when the owner unmounts; prefer the provided hooks (`useMenu`, `useRoutedHotkeys`, `useDocumentAppController`) in components because they dispose late registrations correctly.
67
+
68
+ ## Platforms
69
+
70
+ macOS: shipped. Windows: development builds; external library integrations are implemented in source but not yet verified on hardware. Mobile/web: Expo owns the runtime; Spark's desktop APIs don't apply there except the Expo-shaped adapters.
71
+
72
+ Build metadata uses `nativeModules: true` as a marker, not a list of binding names;
73
+ codegen owns those names. Remove unused `spark.pod`, `spark.platforms` and
74
+ `spark.windowsAdapter`. Every build validates retained fields and patch receipts,
75
+ even when output is cached. Known patch settings for inactive libraries or targets
76
+ remain valid and take effect when that library is built.
@@ -0,0 +1,83 @@
1
+ # Menus, tray and Dock
2
+
3
+ Exports: `@legendapp/spark/menus`, `/context-menu`, `/tray`, plus `createDockMenu` / `createTaskbarMenu` from `/system`.
4
+
5
+ ## Shared item model
6
+
7
+ All surfaces use typed items with stable IDs: `{ type: 'action' | 'checkbox' | 'separator' | 'submenu' | 'role' | 'slider', id, label, … }`. IDs must be unique across the whole tree, including hidden items. Each surface supports a subset and **rejects** unsupported items/options (`E_UNSUPPORTED_OPTION`) instead of ignoring them:
8
+
9
+ | Surface | Supports |
10
+ | --- | --- |
11
+ | App menu (`createMenu` / `useMenu`) | actions, checkboxes, separators, submenus, roles (macOS), icons (macOS), shortcuts |
12
+ | Context menu (`showContextMenu`) | actions, checkboxes, separators only |
13
+ | Tray (`createTray`) | actions, checkboxes, separators, submenus (no icons/shortcuts/roles) |
14
+ | Dock menu (`createDockMenu`, macOS) | actions, checkboxes, separators, submenus |
15
+ | Taskbar Jump List (`createTaskbarMenu`, Windows) | actions, checkboxes |
16
+
17
+ Shortcuts use accelerator strings such as `CmdOrCtrl+S`, `Cmd+Shift+N`.
18
+
19
+ ## Application menu
20
+
21
+ - Top-level items are submenus. Target native roots with `target: { menu: 'file' | 'edit' | 'view' | 'window' | 'help' | 'app' }`; contributions merge by ID, never by label.
22
+ - Owners stack: a later or updated owner overrides matching items, and removing it restores earlier ones. A focused document can publish its commands and remove them on blur.
23
+ - In components use `useMenu` and keep the `items` array stable (memoize it); callback changes don't republish. Unknown hook options reject before creating a menu.
24
+ - A published shortcut takes over the key from a host menu item that has it (for example the template's `Ctrl+Cmd+S` Show Sidebar). Pick shortcuts that don't collide.
25
+ - `type: 'role'` items keep native responder-chain behavior and emit no JS action. To run your own code for a native command, use an action with `target: { role: 'copy' }`.
26
+
27
+ ```ts
28
+ import { createMenu } from '@legendapp/spark/menus';
29
+
30
+ declare function openDocument(): void;
31
+
32
+ const menu = await createMenu({
33
+ id: 'editor',
34
+ items: [{
35
+ type: 'submenu', id: 'file', label: 'File', target: { menu: 'file' },
36
+ items: [{ type: 'action', id: 'open', label: 'Open…', shortcut: 'CmdOrCtrl+O' }],
37
+ }],
38
+ onAction: event => { if (event.itemId === 'open') openDocument(); },
39
+ });
40
+ await menu.remove();
41
+ ```
42
+
43
+ ## Context menu
44
+
45
+ Pass the explicit owner `windowId` and a position in that window's content coordinates. Only one popup at a time (`E_BUSY` otherwise). Check `result.canceled`.
46
+
47
+ ```ts
48
+ import { showContextMenu } from '@legendapp/spark/context-menu';
49
+
50
+ const result = await showContextMenu({
51
+ windowId: 'main',
52
+ position: { x: 30, y: 80 },
53
+ items: [{ type: 'action', id: 'open', label: 'Open' }, { type: 'separator' }, { type: 'action', id: 'delete', label: 'Delete' }],
54
+ });
55
+ if (!result.canceled) console.log(result.itemId);
56
+ ```
57
+
58
+ ## Tray / menu bar and Dock menu
59
+
60
+ - Create the tray from a mounted React root and remove it on teardown. Duplicate IDs reject `E_ALREADY_EXISTS`. `update()` merges; arrays replace.
61
+ - On macOS `title` is visible text; `macos: { symbol: 'name' }` adds an SF Symbol. On Windows the app icon is used and macOS options reject.
62
+ - Opening UI from a tray, menu-bar, popover or Dock-menu click must activate the app: `showWindow('main', { activate: true })` (see [windows.md](windows.md)).
63
+ - Menu-bar-only apps (no Dock icon) need `"menuBarOnly": true` at the top level of `desktop.config.json` (`expo.extra.spark.menuBarOnly` in a direct `app.json` project) and a custom build. Always create a tray or another way to reopen the app.
64
+ - One Dock menu (macOS) / one Jump List (Windows) per app; remove it before creating a replacement.
65
+
66
+ ```ts
67
+ import { createTray } from '@legendapp/spark/tray';
68
+ import { showWindow } from '@legendapp/spark/windows';
69
+
70
+ const tray = await createTray({
71
+ id: 'main',
72
+ title: 'My app',
73
+ menu: [{ type: 'action', id: 'open', label: 'Show app' }],
74
+ onAction(event) {
75
+ if (event.type === 'action' && event.itemId === 'open') void showWindow('main', { activate: true });
76
+ },
77
+ });
78
+ await tray.remove();
79
+ ```
80
+
81
+ ## Platforms
82
+
83
+ macOS: all surfaces. Windows (dev builds): app menu without roles/icons/alternates/lifecycle, context menu, tray, Jump List. Check `getMenuAvailability(feature)` for macOS-only menu features. Mobile/web: none of these APIs.
@@ -0,0 +1,59 @@
1
+ # Storage and settings
2
+
3
+ Exports: `@legendapp/spark/settings`, `/settings/observable`, `/secure-storage`, `/sqlite`.
4
+
5
+ ## Pick the right store
6
+
7
+ | Data | Use |
8
+ | --- | --- |
9
+ | Small JSON preferences | `settings` (default project-scoped store) or `createSettingsStore` from `/settings` |
10
+ | Preferences bound to Legend State observables / UI | `createObservableSettings` or `createObservableFile` from `/settings/observable` |
11
+ | Tokens, passwords | `/secure-storage` (Keychain on macOS, Credential Manager on Windows) |
12
+ | Relational / large data | `openDatabase('name.sqlite')` from `/sqlite` |
13
+ | App files | `/files` with `getDirectory('data')` ([files.md](files.md)) |
14
+
15
+ On macOS settings, Spark SQLite, files and patched MMKV use `~/Library/Application Support/<bundle id>/Spark` (the Spark Runner adds the hosted project hash). Re-signed clones with a changed `CFBundleIdentifier` get separate file stores and launch locks. Rebuild the host; startup migrates an absent store only from a marker-owned legacy folder, or an unmarked folder for the configured default bundle ID. It atomically renames owned data, never overwrites an existing store, and rejects ambiguous or unreadable migration state. Keep `SparkDefaultBundleIdentifier` generated from `macos.bundleIdentifier`; changing only `CFBundleIdentifier` must not claim the original app's legacy data. The Runner uses the hosted project's configured bundle ID for migration eligibility, so it cannot claim the app's unmarked legacy store. Keychain services retain project identity.
16
+
17
+ ## Rules
18
+
19
+ - Settings values are finite JSON. Use `get(key, { decode })` to validate stored data on read; reads never repair corrupt data.
20
+ - Observable files: `path` is a full absolute path including extension, and the parent directory must exist (`mkdir` first). Await `close()` before quitting, ideally in a `beforeQuit` guard. Use Legend State mutations; don't mutate `peek()` results. No remote sync: use Legend State sync for that.
21
+ - Secure storage is the Expo SecureStore subset (`getItemAsync`, `setItemAsync`, `deleteItemAsync`, `isAvailableAsync`). Missing values are `null`. Only default options; authentication/service/access-group options reject. Windows limits values to 2560 bytes. Web has no secure storage (no localStorage fallback).
22
+ - SQLite: `openDatabase` takes a simple `.sqlite` filename, not a path. Use `tx` inside `transaction`; direct calls on the database reject while a transaction is active. Integers beyond 2^53−1 reject by default; open with `{ integers: 'text' }` to read them as strings. Requires the optional peer `@op-engineering/op-sqlite@18.2.1`.
23
+
24
+ ```ts
25
+ import { createObservableSettings } from '@legendapp/spark/settings/observable';
26
+ import { getDirectory, mkdir } from '@legendapp/spark/files';
27
+
28
+ const directory = `${await getDirectory('data')}/preferences`;
29
+ await mkdir(directory);
30
+ const preferences = await createObservableSettings({
31
+ path: `${directory}/preferences.json`,
32
+ fields: {
33
+ theme: { defaultValue: 'system', decode: (value: unknown): string => (value === 'light' || value === 'dark' ? value : 'system') },
34
+ },
35
+ });
36
+ preferences.value$.theme.set('dark');
37
+ await preferences.close();
38
+ ```
39
+
40
+ Each field needs `defaultValue` and `decode`; defaults apply only to absent fields.
41
+
42
+ ```ts
43
+ import { openDatabase } from '@legendapp/spark/sqlite';
44
+
45
+ const db = await openDatabase('notes.sqlite');
46
+ try {
47
+ await db.run('CREATE TABLE IF NOT EXISTS notes (body TEXT)');
48
+ await db.transaction(async tx => { await tx.run('INSERT INTO notes VALUES (?)', ['Hello']); });
49
+ console.log(await db.getAll('SELECT body FROM notes'));
50
+ } finally {
51
+ await db.close();
52
+ }
53
+ ```
54
+
55
+ For settings window composition, see `/ui/settings` in [UI components](ui.md).
56
+
57
+ ## Platforms
58
+
59
+ `/settings`, `/secure-storage`: macOS, Windows; secure storage also iOS/Android via `expo-secure-store`. `/sqlite`: macOS, Windows (Windows runtime not yet verified). Prefer the Spark wrappers in shared code; direct `op-sqlite` imports skip Spark's per-project isolation.
@@ -0,0 +1,83 @@
1
+ # UI components
2
+
3
+ Exports: `@legendapp/spark/ui`, `/ui/uniwind`, `/ui/classnames`, `/ui/search`, `/ui/sidebar`, `/ui/split-view`, `/ui/swipe`, `/ui/glass`, `/ui/symbol`, `/ui/progress`, `/ui/popover`, `/ui/table`, `/ui/sheet`, `/ui/settings`, `/webview`, `/markdown`, `/html`.
4
+
5
+ ## Rules
6
+
7
+ - Use ordinary React Native views and text for layout. Spark's UI exports are a small set of native controls, not a component library.
8
+ - `Button`, `TextInput`, `Select` and `SegmentedControl` (from `/ui`, or `/ui/uniwind` for className styling) render native AppKit/WinUI controls and work on iOS/Android/web through Expo UI or React Native.
9
+ - `Checkbox` (`value`/`onValueChange`, string label children) is macOS, Windows (WinUI `CheckBox`) and web; check `getControlAvailability('checkbox')`. `Button variant="disclosure"` (requires `expanded`) is macOS and web only. `RadioGroup` (`options`/`value`/`onValueChange` like Select, `orientation` `vertical`/`horizontal`, `size` `regular`/`small`/`mini`) is macOS (`NSButton` radios) and web only; check `getControlAvailability('radio-group')`. On macOS, buttons and checkboxes size themselves; give no fixed width unless you want one.
10
+ - `Button` takes `symbol` (an SF Symbol before the title; macOS only) and `size` (`regular`/`small`/`mini`; macOS, and web as smaller text). Elsewhere they report `E_UNSUPPORTED_PLATFORM` and render the disabled fallback; a symbol missing on the running macOS reports `E_NOT_FOUND`.
11
+ - `Switch` takes a boolean `value` and `onValueChange`. It uses the platform React Native switch, including `NSSwitch` on macOS. Label it with `accessibilityLabel`.
12
+ - `Select variant="borderless"` removes the bezel on macOS and web. Windows, iOS and Android report `E_UNSUPPORTED_PLATFORM` and show the current value in a disabled fallback.
13
+ - `SegmentedControl` takes `size` (`regular`/`small`) and `distribution` (`fit`/`fill`). `Sidebar` takes `listStyle="plain"` for lists inside content.
14
+ - `TextInput` is single-line unless `multiline` (an `NSTextView` on macOS; Return inserts a newline) and takes `placeholder`. It is either controlled (`value`) or uncontrolled (`defaultValue`), never both; switching needs a remount.
15
+ - `Select`/`SegmentedControl` never auto-select the first option when `value` is missing. Values are unique strings.
16
+ - Invalid props throw during render; runtime problems go to `onError` (default `console.error`). Spark never inserts error text into your UI.
17
+ - Specialized macOS views (`TextInputSearch`, `Sidebar`, `SidebarSplitView`, swipe actions, `GlassView`, `SFSymbol`, `ProgressIndicator`, `Popover`, `Table`, `Sheet`) render plain view content on other platforms and report through `onError`. Check their `get*Availability()` before advertising the feature.
18
+ - `ProgressIndicator` (`/ui/progress`, macOS) is `NSProgressIndicator`: `variant` `bar`/`spinner`, `size` `regular`/`small` (spinners also `mini`), `value` 0 to 1 (omit or `null` for indeterminate). Give a bar a width. For toolbar progress use a `progress` toolbar item instead.
19
+ - `Popover` (`/ui/popover`, macOS) is `NSPopover` with React `content`, anchored to its children or to `anchorRect` (e.g. a text selection). `visible` is controlled; set it false in `onClose` (AppKit closed it). `edge` `bottom`/`top`/`leading`/`trailing`, `behavior` `transient`/`semitransient`/`applicationDefined`. Give the content a width.
20
+ - `Table` (`/ui/table`, macOS) is `NSTableView` with a header: `columns` (`id`, `title`, optional `width`/`minWidth`/`maxWidth`, `alignment`, `monospacedDigits`, `secondary`) and `rows` of `{ id, values }` (text cells by column ID). Only visible rows get cells. Selection like `Sidebar` (`selectedId` or `selectedIds`, required `onSelectionChange({ id, ids })`), plus `onDoubleClick({ id })`, `onColumnResize({ id, width })` for header drags, `headerVisible`, `alternatingRows`, `rowHeight`. No sorting or custom cells.
21
+ - `Sheet` (`/ui/sheet`, macOS) is a sheet on the current window hosting React children (forms). `visible` is controlled; Escape calls `onCancel` and never closes it by itself. Give the content a size. The content stays mounted until the close animation ends. For one text field use `showPrompt` instead.
22
+ - `SplitView` (`/ui/split-view`, macOS) hosts any number of React panes with `panes=[{ id, content, initialSize?, minSize?, maxSize? }]`. Use `orientation="horizontal"` (default, left to right) or `"vertical"` (top to bottom), and `dividerStyle="thin" | "thick" | "paneSplitter"`. `onResize(sizes)` reports sizes in points, in pane order. You can nest it inside another `SplitView` or a `SidebarSplitView` detail pane. Persist sizes in the app if needed. Other platforms report `E_UNSUPPORTED_PLATFORM` and lay out static panes.
23
+ - `SidebarSplitView` takes optional `list` (Mail's middle column) and `inspector` (a trailing, collapsible inspector item) panes; control the inspector with `inspectorCollapsed` + `onInspectorCollapsedChange`, which, like the sidebar's, reports only native toggles.
24
+ - `Sidebar`'s `selectedId` is controlled and `onSelectionChange` is required.
25
+ - `Sidebar` trees: data `children` or `SidebarItem` `parentId` nest rows; `group` makes a source-list section header (never selectable, Show/Hide on hover); `count` is a trailing count in secondary digits (not a capsule). `collapsedIds` applies when its value changes and `onExpandedChange({ id, expanded })` reports the user's toggles. `onDoubleClick({ id })` reports double-clicks. Pass `selectedIds` instead of `selectedId` for ⌘/⇧ multiple selection; `onSelectionChange` then reports `{ id, ids }`.
26
+ - Layout follows `direction: 'rtl'` on macOS controls.
27
+ - Mobile apps using `Button`/`Select` install optional peer `@expo/ui`. `@expo/ui@55.0.17`, matching Expo SDK 55.
28
+
29
+ ```tsx
30
+ import { Button, Select, TextInput } from '@legendapp/spark/ui';
31
+ import { useState } from 'react';
32
+ import { View } from 'react-native';
33
+
34
+ export function Preferences() {
35
+ const [title, setTitle] = useState('');
36
+ const [theme, setTheme] = useState('light');
37
+ return (
38
+ <View>
39
+ <TextInput value={title} onChangeText={setTitle} accessibilityLabel="Title" />
40
+ <Select options={[{ label: 'Light', value: 'light' }, { label: 'Dark', value: 'dark' }]} value={theme} onValueChange={setTheme} accessibilityLabel="Theme" />
41
+ <Button onPress={() => console.log(title, theme)}>Save</Button>
42
+ </View>
43
+ );
44
+ }
45
+ ```
46
+
47
+ ## Settings windows on macOS
48
+
49
+ Use `@legendapp/spark/ui/settings` with `@legendapp/list` installed. Register a hidden window with `createSettingsWindowOptions()` and pass the registered `windowId` to `SettingsWindow` (also exported as `VirtualizedSettingsWindow`). The sidebar scrolls the shared list and follows its current page. Use `defaultPageId` or `selectedPageId` with `onSelectionChange`. Other platforms throw `E_UNSUPPORTED_PLATFORM` on render.
50
+
51
+ ```tsx
52
+ import { useState } from 'react';
53
+ import { SettingsPage, SettingsSection, SettingsSwitchRow, SettingsWindow } from '@legendapp/spark/ui/settings';
54
+
55
+ export function Preferences() {
56
+ const [wrap, setWrap] = useState(false);
57
+ return (
58
+ <SettingsWindow windowId="settings">
59
+ <SettingsPage id="editor" title="Editor" icon="square.and.pencil">
60
+ <SettingsSection title="Reading">
61
+ <SettingsSwitchRow label="Wrap long lines" value={wrap} onValueChange={setWrap} />
62
+ </SettingsSection>
63
+ </SettingsPage>
64
+ </SettingsWindow>
65
+ );
66
+ }
67
+ ```
68
+
69
+ Add `SettingsSelectRow`, `SettingsSegmentedRow`, or `SettingsImageChoiceRow` for controlled choices. Each image option has a `label`, `value`, and one React Native `image` source. Rows accept an optional `description` and `info` tooltip. Pass a custom control as children of `SettingsRow`, or put a full-width custom element directly in a section.
70
+
71
+ ## WebView, Markdown and HTML
72
+
73
+ - `/webview` is a Spark-owned subset over `react-native-webview@16.0.0` (WebKit on macOS, not Chromium). Upstream platform-specific props reject; import `react-native-webview` directly if you need its full surface. Nothing native is exposed to pages: define a navigation policy and expose only intended message handlers.
74
+ - `/markdown` (`Markdown`, `MarkdownInput`, `EditableMarkdown`) and `/html` need their optional peers `react-native-enriched-markdown@1.1.1` / `react-native-enriched-html@1.1.1`. They have no Windows implementation: universal apps targeting Windows exclude them in `expoByPlatform.windows.autolinking.exclude`.
75
+ - `spark doctor` reports a missing optional peer for these imports.
76
+
77
+ ## Styling
78
+
79
+ Uniwind/Tailwind classes are optional (`/ui/uniwind`, `cn` from `/ui/classnames`). Theme setup is in `docs/styling.md` in the Spark repository; it is not shipped with the package.
80
+
81
+ ## Platforms
82
+
83
+ `/ui` core controls: macOS, Windows (no `SegmentedControl`, `RadioGroup` or disclosure button), iOS, Android (no `Checkbox`, `RadioGroup` or disclosure button), web. Specialized `/ui/*` views: macOS only. `/webview`: macOS, Windows. `/markdown`, `/html`: macOS (and upstream mobile), not Windows.
@@ -0,0 +1,91 @@
1
+ # Windows
2
+
3
+ Exports: `@legendapp/spark/windows`, `/windows/macos`, `/diagnostics`. Main window is host-created with ID `'main'`; everything else is opened by your code.
4
+
5
+ ## Rules
6
+
7
+ - Every command takes an explicit window ID. There is no implicit "frontmost" or "main" default; focus never decides ownership.
8
+ - On macOS, launch forwarding is scoped to the bundle ID. A re-signed clone with a changed `CFBundleIdentifier` opens its own instance and uses separate Spark file storage; keep the generated default-bundle metadata for safe legacy migration.
9
+ - Named windows are singletons. `openWindow` on a live ID rejects `E_ALREADY_EXISTS`; call `showWindow(id)` for an existing window. IDs can be reused after close.
10
+ - `openWindow` resolves when the native window and root exist, not when your data has loaded. Use `show: false` to mount content first, then `showWindow`.
11
+ - Props passed at open are JSON-serializable and immutable. Put changing data in app state, not in window props.
12
+ - Each window is a separate React root. It does not inherit React providers from another window: wrap each registered component with the providers it needs.
13
+ - `useWindowId()` throws outside a Spark window root.
14
+ - Use `createWindowsNavigator` for typed registration: props are checked against the component and identity cannot be overridden at `open`.
15
+ - Coordinates are logical units relative to one display's top-left corner (`displayId` + `x`/`y`). Bounds are the outer frame.
16
+
17
+ ## Bringing a window forward
18
+
19
+ `showWindow(id)` focuses the window inside the app but does not bring an inactive app forward. Tray, popover, menu-bar and Dock-menu clicks do not activate the app, so from those handlers pass `activate: true`:
20
+
21
+ ```ts
22
+ import { showWindow } from '@legendapp/spark/windows';
23
+
24
+ // From a tray / popover / menu-bar / Dock-menu click:
25
+ await showWindow('main', { activate: true });
26
+ ```
27
+
28
+ Do not write `activate().then(() => showWindow(id, { focus: true }))`; use the option. `activate: true` with `focus: false` rejects `E_INVALID_ARGUMENT`.
29
+
30
+ ## Open, show and close
31
+
32
+ ```tsx
33
+ import type { ReactNode } from 'react';
34
+ import { createWindowsNavigator } from '@legendapp/spark/windows';
35
+
36
+ declare function Editor(props: { documentId: string }): ReactNode;
37
+
38
+ const windows = createWindowsNavigator({
39
+ editor: { id: 'editor', component: Editor, options: { title: 'Editor', size: { width: 960, height: 720 } } },
40
+ });
41
+
42
+ export async function openEditor(documentId: string) {
43
+ await windows.open('editor', { props: { documentId } });
44
+ }
45
+ export async function closeEditor() {
46
+ const result = await windows.close('editor');
47
+ if (!result.closed) console.log('Close was vetoed');
48
+ }
49
+ ```
50
+
51
+ ## Close guards and events
52
+
53
+ - `beforeWindowClose(id, handler)` vetoes close when the handler returns `false`, throws, or takes longer than 30 s. One guard per live window; a second registration rejects `E_BUSY`.
54
+ - `addWindowListener(id, type, listener)` is async and binds to the current native instance; it delivers future events only (no initial snapshot) and stops when that instance closes. For app-wide open/close across reused IDs use `/app` events `windowOpened` / `windowClosed`.
55
+ - For "open the main window once, reopen on Dock click" use `createPrimaryWindowLifecycle` / `usePrimaryWindowLifecycle` rather than hand-wiring `reopen`.
56
+
57
+ ```ts
58
+ import { beforeWindowClose } from '@legendapp/spark/windows';
59
+
60
+ declare function hasUnsavedChanges(): boolean;
61
+ declare function confirmDiscard(): Promise<boolean>;
62
+
63
+ const guard = await beforeWindowClose('editor', async () => !hasUnsavedChanges() || await confirmDiscard());
64
+ // When the owner goes away:
65
+ await guard.remove();
66
+ ```
67
+
68
+ ## macOS-only options
69
+
70
+ AppKit features live in typed `macos` groups (`macos.titleBar`, `macos.toolbar`, `macos.level`, `macos.restoreOnLaunch`, `macos.startupSplitView`, `macos.representedUri`, `macos.subtitle`, `macos.tabbing`) and in `/windows/macos` (`setWindowBlur`, `focusToolbarSearch`, `setToolbarItemText`, `addMacOSWindowListener`). On Windows a requested `macos` behavior that the target cannot honor rejects `E_UNSUPPORTED_OPTION`; it is never silently ignored. Animated frames use `setWindowBounds(id, bounds, { macos: { durationMs } })`; there is no separate animate call.
71
+
72
+ Plain toolbar buttons do not support `width` or `monospacedDigits`; these keys reject `E_UNSUPPORTED_OPTION`. Width is available on menu, popup, label, search and progress items. A `popup` toolbar item is an NSPopUpButton showing the current `value` from `options` (`{ value, label, symbol? }`, like segments); choosing one emits `toolbarSelectionChanged`, and its optional `items` (actions and separators) follow a separator and emit `toolbarMenuAction` while the popup keeps its value. Use it for pickers such as a branch picker. A `progress` toolbar item takes `value` (0 to 1; omit or `null` for indeterminate) and `variant: 'bar' | 'spinner'`; send new values in ordinary toolbar updates, which change the indicator in place. `macos.subtitle` sets the line under the title (`''` removes it). `macos.tabbing: { mode: 'preferred', identifier: 'review' }` opens windows with that identifier as native tabs of one window (`automatic` follows the user's setting, `disallowed` never tabs); each tab is a separate window id with its own props, so open one window per document. `toolbar.items` creates a toolbar, so combining it with `visible: false` rejects; hide the toolbar in a separate update without `items`. `macos.restoreOnLaunch` applies only to secondary windows and rejects for `main`, which the host creates. Lifecycle and focus hooks reject unknown option keys before subscribing.
73
+
74
+ `macos.startupSplitView` is an optional pre-React placeholder. When the native split-view backend is pruned, the window uses ordinary content until React mounts.
75
+
76
+ Per-window appearance is a window option (`appearance: 'system' | 'light' | 'dark'`). Content that should show a native material through needs a transparent React background.
77
+
78
+ `macos.titleBar.tintColor` (`'#RRGGBBAA'` or `{ light, dark }`) lays a color over the titlebar `material` and follows the window's effective appearance; alpha below `ff` keeps the blur showing through. Without `material` in the same call it uses `titlebar`; with `material: 'none'` it is rejected. `blendingMode` and `materialState` need a `material` other than `none` or `glass` (or a `tintColor`) in the same call, or validation throws.
79
+
80
+ `/diagnostics` exposes `getStartupTiming()`; `finishWindowRestoration()` lives in `/app`.
81
+
82
+ ## Platforms
83
+
84
+ macOS: shipped. Windows: development builds only; the same commands exist, `macos` groups reject. Mobile/web: not covered; do not call `/windows` from shared mobile code.
85
+
86
+ Portable window chrome applies first; explicit `macos` fields then override the
87
+ corresponding settings, including `macos.level` over `alwaysOnTop`. Contradictory
88
+ settings inside a group still reject, such as `toolbar.visible: false` with
89
+ `toolbar.items`, or `titleBar.material: 'none'` with a tint. AppKit validates
90
+ requested titlebar/toolbar/menu symbols before applying the macOS chrome;
91
+ missing symbols reject `E_INVALID_ARGUMENT` rather than showing a text fallback.
package/ui-popover.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./vendor/node_modules/@legendapp/spark-ui/src/popover/index.tsx";
package/ui-progress.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./vendor/node_modules/@legendapp/spark-ui/src/progress/index.tsx";
package/ui-sheet.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./vendor/node_modules/@legendapp/spark-ui/src/sheet/index.tsx";
package/ui-split-view.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from "./vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx";
2
+ export * from "./vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitView.tsx";
package/ui-table.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./vendor/node_modules/@legendapp/spark-ui/src/table/index.tsx";
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@legendapp/spark-ai",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "private": true,
5
5
  "main": "src/index.ts",
6
6
  "react-native": "src/index.ts",
7
7
  "dependencies": {
8
- "@legendapp/spark-desktop-app": "0.0.3",
9
- "@legendapp/spark-processes": "0.0.3"
8
+ "@legendapp/spark-desktop-app": "0.0.5",
9
+ "@legendapp/spark-processes": "0.0.5"
10
10
  },
11
11
  "peerDependencies": {
12
12
  "react": "^19.2.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-audio",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "license": "MIT",
5
5
  "main": "src/index",
6
6
  "react-native": "src/index",
@@ -32,21 +32,11 @@
32
32
  },
33
33
  "spark": {
34
34
  "sdk": true,
35
- "nativeModules": [
36
- "NativeSparkAudio"
37
- ],
38
- "pod": "RNSparkAudio",
39
- "platforms": [
40
- "macos",
41
- "windows",
42
- "ios",
43
- "android",
44
- "web"
45
- ],
35
+ "nativeModules": true,
46
36
  "requires": []
47
37
  },
48
38
  "private": true,
49
39
  "dependencies": {
50
- "@legendapp/spark-desktop-app": "0.0.3"
40
+ "@legendapp/spark-desktop-app": "0.0.5"
51
41
  }
52
42
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-auth-session",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "license": "MIT",
5
5
  "main": "src/index",
6
6
  "react-native": "src/index",
@@ -8,9 +8,9 @@
8
8
  "src"
9
9
  ],
10
10
  "dependencies": {
11
- "@legendapp/spark-desktop-links": "0.0.3",
11
+ "@legendapp/spark-desktop-links": "0.0.5",
12
12
  "base64-js": "1.5.1",
13
- "@legendapp/spark-desktop-app": "0.0.3"
13
+ "@legendapp/spark-desktop-app": "0.0.5"
14
14
  },
15
15
  "peerDependencies": {
16
16
  "react-native": "0.83.10",
@@ -27,13 +27,6 @@
27
27
  },
28
28
  "spark": {
29
29
  "sdk": true,
30
- "platforms": [
31
- "macos",
32
- "windows",
33
- "ios",
34
- "android",
35
- "web"
36
- ],
37
30
  "requires": [
38
31
  "@legendapp/spark-desktop-links"
39
32
  ]
@@ -1,4 +1,6 @@
1
1
  import { installWithEnrichedHtmlPins } from "./enriched-html-pins.js";
2
+ import { migrate } from "./migrate.js";
3
+ import { installedSparkVersion, migrateProject } from "./migrations.cjs";
2
4
  import { installedRelease, materializeReleasePackages, packageSources, verifyMaterializedReleasePackages } from "./release.js";
3
5
  import { packageManager, localArchive } from "./package-manager.js";
4
6
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
@@ -111,6 +113,7 @@ export async function addDesktop(root, manifestFile) {
111
113
  }
112
114
  }
113
115
  await installWithEnrichedHtmlPins(root, manager);
116
+ migrate(root);
114
117
  console.log("Desktop integration already exists; dependencies installed. Existing configuration preserved.");
115
118
  return;
116
119
  }
@@ -203,5 +206,7 @@ export async function addDesktop(root, manifestFile) {
203
206
  if (release)
204
207
  verifyMaterializedReleasePackages(release, root);
205
208
  await installWithEnrichedHtmlPins(root, manager);
209
+ const sparkVersion = installedSparkVersion(root);
210
+ migrateProject(root, sparkVersion, true, { fromVersion: sparkVersion });
206
211
  console.log(`Added desktop support to ${root}. Existing entry point and mobile/web scripts are unchanged.\nRun spark build --dev --platform macos, then spark dev --platform macos. Windows native builds run on Windows.`);
207
212
  }