@legendapp/spark 0.0.3 → 0.0.4

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 (186) hide show
  1. package/init-template.cjs +7 -1
  2. package/package.json +10 -5
  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 +116 -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 +85 -0
  24. package/skills/spark/ui.md +57 -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 +137 -105
  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 +12 -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/patch.js +92 -0
  53. package/vendor/node_modules/@legendapp/spark-cli/dist/project-version.js +12 -4
  54. package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +8 -1
  55. package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +20 -20
  56. package/vendor/node_modules/@legendapp/spark-cli/dist/upgrade.js +1 -1
  57. package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +3 -0
  58. package/vendor/node_modules/@legendapp/spark-cli/package.json +5 -4
  59. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +2 -2
  60. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +2 -2
  61. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +2 -2
  62. package/vendor/node_modules/@legendapp/spark-clipboard/macos/RNDesktopClipboard.mm +1 -1
  63. package/vendor/node_modules/@legendapp/spark-clipboard/package.json +3 -10
  64. package/vendor/node_modules/@legendapp/spark-clipboard/src/desktop.ts +1 -0
  65. package/vendor/node_modules/@legendapp/spark-codex/package.json +3 -7
  66. package/vendor/node_modules/@legendapp/spark-commands/package.json +5 -5
  67. package/vendor/node_modules/@legendapp/spark-context-menu/package.json +3 -10
  68. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.h +3 -1
  69. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +51 -10
  70. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.h +4 -0
  71. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.mm +82 -0
  72. package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +2 -8
  73. package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +6 -8
  74. package/vendor/node_modules/@legendapp/spark-desktop-config/identity.cjs +2 -0
  75. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs +300 -71
  76. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.d.cts +7 -0
  77. package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +3 -3
  78. package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.cjs +318 -0
  79. package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.d.cts +20 -0
  80. package/vendor/node_modules/@legendapp/spark-desktop-config/validation.cjs +66 -9
  81. package/vendor/node_modules/@legendapp/spark-desktop-config/windows.plugin.cjs +1 -0
  82. package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +1 -0
  83. package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +2 -2
  84. package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +3 -10
  85. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +3 -10
  86. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.mm +7 -2
  87. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +235 -240
  88. package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +4 -11
  89. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/api.ts +9 -3
  90. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +7 -0
  91. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/types.ts +32 -3
  92. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/validation.ts +28 -11
  93. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/createWindowsNavigator.tsx +15 -3
  94. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/primaryWindowLifecycle.ts +12 -3
  95. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/usePrimaryWindowLifecycle.ts +2 -1
  96. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/useWindowFocusEffect.ts +4 -1
  97. package/vendor/node_modules/@legendapp/spark-documents/package.json +7 -7
  98. package/vendor/node_modules/@legendapp/spark-drag-drop/macos/RNDesktopDragView.mm +77 -17
  99. package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +3 -8
  100. package/vendor/node_modules/@legendapp/spark-drag-drop/src/DesktopDragViewNativeComponent.ts +1 -0
  101. package/vendor/node_modules/@legendapp/spark-drag-drop/src/contracts.ts +13 -4
  102. package/vendor/node_modules/@legendapp/spark-drag-drop/src/index.tsx +5 -3
  103. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.h +6 -1
  104. package/vendor/node_modules/@legendapp/spark-expo-compat/metro.cjs +44 -0
  105. package/vendor/node_modules/@legendapp/spark-expo-compat/package.json +20 -0
  106. package/vendor/node_modules/@legendapp/spark-expo-compat/src/clipboard.ts +40 -0
  107. package/vendor/node_modules/@legendapp/spark-expo-compat/src/document-picker.ts +52 -0
  108. package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +3 -10
  109. package/vendor/node_modules/@legendapp/spark-file-dialog/src/options.ts +5 -2
  110. package/vendor/node_modules/@legendapp/spark-file-dialog/src/types.ts +3 -3
  111. package/vendor/node_modules/@legendapp/spark-file-system/macos/RNDesktopFileSystem.mm +1 -1
  112. package/vendor/node_modules/@legendapp/spark-file-system/package.json +3 -11
  113. package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +3 -10
  114. package/vendor/node_modules/@legendapp/spark-html/package.json +2 -2
  115. package/vendor/node_modules/@legendapp/spark-markdown/package.json +2 -2
  116. package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +3 -10
  117. package/vendor/node_modules/@legendapp/spark-message-dialog/src/index.ts +1 -0
  118. package/vendor/node_modules/@legendapp/spark-native-menu/package.json +3 -9
  119. package/vendor/node_modules/@legendapp/spark-native-menu/src/hooks.ts +4 -0
  120. package/vendor/node_modules/@legendapp/spark-notifications/package.json +3 -10
  121. package/vendor/node_modules/@legendapp/spark-processes/package.json +3 -10
  122. package/vendor/node_modules/@legendapp/spark-rich-text/package.json +2 -2
  123. package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +3 -10
  124. package/vendor/node_modules/@legendapp/spark-settings/package.json +3 -3
  125. package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +4 -4
  126. package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
  127. package/vendor/node_modules/@legendapp/spark-system/package.json +3 -10
  128. package/vendor/node_modules/@legendapp/spark-tray/package.json +3 -10
  129. package/vendor/node_modules/@legendapp/spark-tray/src/index.ts +2 -1
  130. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.mm +82 -14
  131. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.h +1 -1
  132. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.mm +94 -11
  133. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +235 -18
  134. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.h +17 -0
  135. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.mm +216 -0
  136. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.h +4 -0
  137. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.mm +212 -0
  138. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewUpdates.h +6 -0
  139. package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +26 -13
  140. package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.h +9 -0
  141. package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.mm +126 -0
  142. package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.h +9 -0
  143. package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.mm +66 -0
  144. package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.h +9 -0
  145. package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.mm +118 -0
  146. package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.mm +4 -12
  147. package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.h +9 -0
  148. package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.mm +109 -0
  149. package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +418 -102
  150. package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.h +9 -0
  151. package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.mm +179 -0
  152. package/vendor/node_modules/@legendapp/spark-ui/package.json +9 -8
  153. package/vendor/node_modules/@legendapp/spark-ui/src/SparkButtonNativeComponent.ts +10 -2
  154. package/vendor/node_modules/@legendapp/spark-ui/src/SparkTextInputNativeComponent.ts +2 -0
  155. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +9 -0
  156. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitView.tsx +99 -0
  157. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitViewNativeComponent.ts +29 -0
  158. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +34 -17
  159. package/vendor/node_modules/@legendapp/spark-ui/src/availability.ts +5 -4
  160. package/vendor/node_modules/@legendapp/spark-ui/src/checkbox-unavailable.tsx +20 -0
  161. package/vendor/node_modules/@legendapp/spark-ui/src/control.ts +24 -3
  162. package/vendor/node_modules/@legendapp/spark-ui/src/desktop.tsx +63 -13
  163. package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +12 -7
  164. package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +12 -7
  165. package/vendor/node_modules/@legendapp/spark-ui/src/index.web.tsx +35 -13
  166. package/vendor/node_modules/@legendapp/spark-ui/src/mobile-input.tsx +2 -2
  167. package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSegmentedControlNativeComponent.ts +3 -1
  168. package/vendor/node_modules/@legendapp/spark-ui/src/popover/PopoverNativeComponent.ts +20 -0
  169. package/vendor/node_modules/@legendapp/spark-ui/src/popover/index.tsx +45 -0
  170. package/vendor/node_modules/@legendapp/spark-ui/src/progress/ProgressIndicatorNativeComponent.ts +13 -0
  171. package/vendor/node_modules/@legendapp/spark-ui/src/progress/index.tsx +32 -0
  172. package/vendor/node_modules/@legendapp/spark-ui/src/radio-group/RadioGroupNativeComponent.ts +17 -0
  173. package/vendor/node_modules/@legendapp/spark-ui/src/sheet/SheetNativeComponent.ts +15 -0
  174. package/vendor/node_modules/@legendapp/spark-ui/src/sheet/index.tsx +38 -0
  175. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarItemNativeComponent.ts +9 -1
  176. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarNativeComponent.ts +17 -2
  177. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/index.tsx +106 -22
  178. package/vendor/node_modules/@legendapp/spark-ui/src/table/TableNativeComponent.ts +22 -0
  179. package/vendor/node_modules/@legendapp/spark-ui/src/table/index.tsx +118 -0
  180. package/vendor/node_modules/@legendapp/spark-ui/src/types.ts +39 -6
  181. package/vendor/node_modules/@legendapp/spark-ui/uniwind.ts +3 -1
  182. package/vendor/node_modules/@legendapp/spark-ui/uniwind.web.ts +2 -1
  183. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.h +46 -15
  184. package/vendor/node_modules/@legendapp/spark-updates/package.json +3 -9
  185. package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
  186. package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spark-template-universal",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "private": true,
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -41,7 +41,7 @@
41
41
  "react-native-web": "0.21.0",
42
42
  "uniwind": "1.6.3",
43
43
  "tailwindcss": "4.2.4",
44
- "@legendapp/spark": "0.0.3"
44
+ "@legendapp/spark": "0.0.4"
45
45
  },
46
46
  "overrides": {
47
47
  "expo": "55.0.32",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spark-template-windows",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "private": true,
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -28,7 +28,7 @@
28
28
  "react-native-windows": "0.83.2",
29
29
  "expo-desktop-modules-core": "55.0.2",
30
30
  "expo-desktop-stubs": "55.0.2",
31
- "@legendapp/spark": "0.0.3"
31
+ "@legendapp/spark": "0.0.4"
32
32
  },
33
33
  "overrides": {
34
34
  "expo": "55.0.32",
@@ -70,7 +70,7 @@ RCT_EXPORT_MODULE(NativeDesktopClipboard)
70
70
  if (item.types.count) [objects addObject:item];
71
71
  }
72
72
  [board clearContents]; if (objects.count && ![board writeObjects:objects]) { reject(@"E_CLIPBOARD", @"Could not write clipboard", nil); return; }
73
- resolve(@"null"); return;
73
+ resolve(binary ? NSNull.null : @"null"); return;
74
74
  }
75
75
  SparkInvalid(reject, @"Unknown clipboard operation");
76
76
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-clipboard",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "license": "MIT",
5
5
  "main": "src/index",
6
6
  "react-native": "src/index",
@@ -28,20 +28,13 @@
28
28
  },
29
29
  "spark": {
30
30
  "sdk": true,
31
- "nativeModules": [
32
- "NativeDesktopClipboard"
33
- ],
34
- "pod": "RNDesktopClipboard",
35
- "platforms": [
36
- "macos",
37
- "windows"
38
- ],
31
+ "nativeModules": true,
39
32
  "requires": [
40
33
  "@legendapp/spark-desktop-app"
41
34
  ]
42
35
  },
43
36
  "dependencies": {
44
- "@legendapp/spark-desktop-app": "0.0.3"
37
+ "@legendapp/spark-desktop-app": "0.0.4"
45
38
  },
46
39
  "peerDependenciesMeta": {
47
40
  "expo-clipboard": {
@@ -58,6 +58,7 @@ export async function writeClipboard(content: ClipboardWriteContent): Promise<vo
58
58
  const files = content.files?.map(path => nativePath(path, Platform.OS));
59
59
  const { image, ...rest } = content;
60
60
  if (image !== undefined && (!image || image.format !== "png" || !(image.bytes instanceof Uint8Array))) throw new SparkError("E_INVALID_ARGUMENT", "Expected PNG image bytes");
61
+ if (image !== undefined) for (const key of Object.keys(image)) if (key !== "format" && key !== "bytes") throw new SparkError("E_UNSUPPORTED_OPTION", `Unsupported clipboard image option: ${key}`);
61
62
  const response = await invokeNative(() => callBinary(native(), "__sparkClipboardBinary", "write", { ...rest, files }, image?.bytes));
62
63
  if (response !== null) throw new SparkError("E_INVALID_DATA", "Invalid native clipboard response");
63
64
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-codex",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "private": true,
5
5
  "main": "src/index.ts",
6
6
  "react-native": "src/index.ts",
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "license": "MIT",
12
12
  "dependencies": {
13
- "@legendapp/spark-desktop-app": "0.0.3",
13
+ "@legendapp/spark-desktop-app": "0.0.4",
14
14
  "react-native-nitro-modules": "0.37.0"
15
15
  },
16
16
  "files": [
@@ -23,11 +23,7 @@
23
23
  ],
24
24
  "spark": {
25
25
  "sdk": true,
26
- "nativeModules": [],
27
- "pod": "RNCodex",
28
- "platforms": [
29
- "macos"
30
- ],
26
+ "nativeModules": true,
31
27
  "requires": [
32
28
  "react-native-nitro-modules"
33
29
  ]
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-commands",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "main": "src/index.tsx",
@@ -8,11 +8,11 @@
8
8
  "src"
9
9
  ],
10
10
  "dependencies": {
11
- "@legendapp/spark-ui": "0.0.3",
12
- "@legendapp/spark-desktop-shortcuts": "0.0.3",
13
- "@legendapp/spark-settings": "0.0.3",
11
+ "@legendapp/spark-ui": "0.0.4",
12
+ "@legendapp/spark-desktop-shortcuts": "0.0.4",
13
+ "@legendapp/spark-settings": "0.0.4",
14
14
  "@legendapp/state": "^3.0.0-beta.42",
15
- "@legendapp/spark-desktop-app": "0.0.3"
15
+ "@legendapp/spark-desktop-app": "0.0.4"
16
16
  },
17
17
  "peerDependencies": {
18
18
  "react": "^19.2.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-context-menu",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "license": "MIT",
5
5
  "main": "src/index.ts",
6
6
  "react-native": "src/index.ts",
@@ -28,20 +28,13 @@
28
28
  },
29
29
  "spark": {
30
30
  "sdk": true,
31
- "nativeModules": [
32
- "NativeContextMenu"
33
- ],
34
- "pod": "RNContextMenu",
35
- "platforms": [
36
- "macos",
37
- "windows"
38
- ],
31
+ "nativeModules": true,
39
32
  "requires": [
40
33
  "@legendapp/spark-desktop-app"
41
34
  ]
42
35
  },
43
36
  "dependencies": {
44
- "@legendapp/spark-desktop-app": "0.0.3"
37
+ "@legendapp/spark-desktop-app": "0.0.4"
45
38
  },
46
39
  "private": true
47
40
  }
@@ -3,7 +3,7 @@
3
3
  #import <React/RCTBridgeModule.h>
4
4
 
5
5
  FOUNDATION_EXPORT NSString * const SparkDesktopEvent;
6
- // Call in applicationWillFinishLaunching:. YES: this process owns the project's
6
+ // Call in applicationWillFinishLaunching:. YES: this process owns the app's
7
7
  // instance. NO: another process does; this one forwards its launch and exits.
8
8
  FOUNDATION_EXPORT BOOL SparkAcquireInstance(void);
9
9
  // Latched on first call during launch: --spark-safe-mode, or Shift held at launch.
@@ -15,6 +15,8 @@ FOUNDATION_EXPORT void SparkRelaunch(NSArray<NSString *> *arguments, void (^comp
15
15
  FOUNDATION_EXPORT NSDictionary *SparkContext(void);
16
16
  FOUNDATION_EXPORT NSDictionary *SparkInitialProps(NSString *windowID, NSDictionary *props);
17
17
  FOUNDATION_EXPORT NSString *SparkNamespace(void);
18
+ FOUNDATION_EXPORT NSString *SparkStorageNamespace(void);
19
+ FOUNDATION_EXPORT void SparkPrepareStorage(void);
18
20
  FOUNDATION_EXPORT void SparkEmit(NSDictionary *event);
19
21
  FOUNDATION_EXPORT void SparkOpenURLs(NSArray<NSURL *> *urls);
20
22
  FOUNDATION_EXPORT NSArray *SparkPendingURLs(void);
@@ -2,6 +2,7 @@
2
2
  #import "SparkDesktopError.h"
3
3
  #import "SparkQuitCoordinator.h"
4
4
  #import "SparkInstance.h"
5
+ #import "SparkStorage.h"
5
6
  #import "SparkTestDriver.h"
6
7
  #import <sys/wait.h>
7
8
  #import <CommonCrypto/CommonDigest.h>
@@ -26,6 +27,14 @@ void SparkInvalid(RCTPromiseRejectBlock reject, NSString *message) { reject(@"E_
26
27
  void SparkReject(RCTPromiseRejectBlock reject, NSError *error) {
27
28
  reject(SparkDesktopErrorCode(error), error.localizedDescription ?: @"Native operation failed", error);
28
29
  }
30
+ static NSString *SparkHashedNamespace(NSString *identifier) {
31
+ NSData *data = [identifier dataUsingEncoding:NSUTF8StringEncoding];
32
+ unsigned char hash[CC_SHA256_DIGEST_LENGTH];
33
+ CC_SHA256(data.bytes, (CC_LONG)data.length, hash);
34
+ NSMutableString *result = [NSMutableString stringWithString:@"spark.desktop."];
35
+ for (int i = 0; i < CC_SHA256_DIGEST_LENGTH; i++) [result appendFormat:@"%02x", hash[i]];
36
+ return result;
37
+ }
29
38
  NSDictionary *SparkContext(void) {
30
39
  static NSDictionary *context;
31
40
  static dispatch_once_t once;
@@ -57,14 +66,29 @@ NSDictionary *SparkContext(void) {
57
66
  });
58
67
  return context;
59
68
  }
60
- NSString *SparkNamespace(void) {
61
- NSString *project = SparkContext()[@"projectId"];
62
- NSData *data = [project dataUsingEncoding:NSUTF8StringEncoding];
63
- unsigned char hash[CC_SHA256_DIGEST_LENGTH];
64
- CC_SHA256(data.bytes, (CC_LONG)data.length, hash);
65
- NSMutableString *result = [NSMutableString stringWithString:@"spark.desktop."];
66
- for (int i = 0; i < CC_SHA256_DIGEST_LENGTH; i++) [result appendFormat:@"%02x", hash[i]];
67
- return result;
69
+ NSString *SparkNamespace(void) { return SparkHashedNamespace(SparkContext()[@"projectId"]); }
70
+ static NSString *SparkBundleIdentifier(void) {
71
+ NSString *identifier = NSBundle.mainBundle.bundleIdentifier;
72
+ if (!identifier.length || [identifier containsString:@"/"] || [identifier isEqual:@"."] || [identifier isEqual:@".."]) {
73
+ [NSException raise:NSInvalidArgumentException format:@"Spark requires a valid CFBundleIdentifier"];
74
+ }
75
+ return identifier;
76
+ }
77
+ static NSString *SparkConfiguredBundleIdentifier(void) {
78
+ #if DEBUG
79
+ if ([SparkContext()[@"runtime"][@"mode"] isEqual:@"go"]) return NSProcessInfo.processInfo.environment[@"SPARK_PROJECT_BUNDLE_IDENTIFIER"];
80
+ #endif
81
+ return [NSBundle.mainBundle objectForInfoDictionaryKey:@"SparkDefaultBundleIdentifier"];
82
+ }
83
+ NSString *SparkStorageNamespace(void) {
84
+ NSString *value = [SparkBundleIdentifier() stringByAppendingPathComponent:@"Spark"];
85
+ if ([SparkContext()[@"runtime"][@"mode"] isEqual:@"go"]) value = [value stringByAppendingPathComponent:SparkNamespace()];
86
+ return value;
87
+ }
88
+ static NSString *SparkInstanceNamespace(void) {
89
+ NSString *identifier = SparkBundleIdentifier();
90
+ if ([SparkContext()[@"runtime"][@"mode"] isEqual:@"go"]) identifier = [identifier stringByAppendingFormat:@":%@", SparkContext()[@"projectId"]];
91
+ return SparkHashedNamespace(identifier);
68
92
  }
69
93
  NSDictionary *SparkInitialProps(NSString *windowID, NSDictionary *props) {
70
94
  NSMutableDictionary *result = [SparkContext() mutableCopy];
@@ -153,7 +177,7 @@ static void SparkForwardLaunch(void) {
153
177
  for (NSURL *url in forwardedURLs) { if (url.isFileURL) [files addObject:url.path]; else [urls addObject:url.absoluteString]; }
154
178
  NSDictionary *launch = @{ @"arguments": NSProcessInfo.processInfo.arguments, @"workingDirectory": NSFileManager.defaultManager.currentDirectoryPath ?: @"/", @"files": files, @"urls": urls };
155
179
  NSError *error;
156
- if (!SparkInstanceForward(NSTemporaryDirectory(), SparkNamespace(), launch, 10, &error)) SparkLaunchFailed(@"The running app did not accept this launch", error);
180
+ if (!SparkInstanceForward(NSTemporaryDirectory(), SparkInstanceNamespace(), launch, 10, &error)) SparkLaunchFailed(@"The running app did not accept this launch", error);
157
181
  exit(0);
158
182
  }];
159
183
  }
@@ -172,6 +196,23 @@ NSDictionary *SparkLaunchState(void) {
172
196
  return @{ @"safeMode": SparkSafeMode() ? safeModeTrigger : NSNull.null, @"relaunched": @(relaunched),
173
197
  @"instance": instanceOwner ? @"primary" : @"test-driver" };
174
198
  }
199
+ void SparkPrepareStorage(void) {
200
+ NSError *error = nil;
201
+ NSFileManager *fm = NSFileManager.defaultManager;
202
+ NSURL *base = [fm URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:&error];
203
+ if (!base) SparkLaunchFailed(@"Unable to locate the app storage directory", error);
204
+ NSMutableOrderedSet<NSURL *> *legacy = [NSMutableOrderedSet orderedSetWithObject:[base URLByAppendingPathComponent:SparkNamespace() isDirectory:YES]];
205
+ if (![SparkContext()[@"runtime"][@"mode"] isEqual:@"go"]) {
206
+ NSString *name = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleDisplayName"] ?: [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleName"];
207
+ if ([name containsString:@"/"] || [name isEqual:@"."] || [name isEqual:@".."]) {
208
+ SparkLaunchFailed(@"Unable to migrate legacy app storage", [NSError errorWithDomain:@"SparkStorage" code:1 userInfo:@{ NSLocalizedDescriptionKey: @"The legacy display name must be a single directory name. Migrate its data explicitly." }]);
209
+ }
210
+ if (name.length) [legacy addObject:[base URLByAppendingPathComponent:name isDirectory:YES]];
211
+ }
212
+ SparkMigrateStorage([base URLByAppendingPathComponent:SparkStorageNamespace() isDirectory:YES], legacy.array,
213
+ SparkBundleIdentifier(), SparkConfiguredBundleIdentifier(), &error);
214
+ if (error) SparkLaunchFailed(@"Unable to prepare the app's storage", error);
215
+ }
175
216
  BOOL SparkAcquireInstance(void) {
176
217
  SparkSafeMode();
177
218
  NSString *parent = NSProcessInfo.processInfo.environment[@"SPARK_RELAUNCH_PARENT"];
@@ -182,7 +223,7 @@ BOOL SparkAcquireInstance(void) {
182
223
  // The previous instance holds the lock until it exits; it kills this process if its quit is vetoed.
183
224
  if (!SparkInstanceWaitForExit(parent.intValue, &error)) SparkLaunchFailed(@"Unable to relaunch", error);
184
225
  }
185
- instanceOwner = SparkInstanceAcquire(NSTemporaryDirectory(), SparkNamespace(), ^(NSDictionary *launch) { SparkReceiveLaunch(launch); }, &error);
226
+ instanceOwner = SparkInstanceAcquire(NSTemporaryDirectory(), SparkInstanceNamespace(), ^(NSDictionary *launch) { SparkReceiveLaunch(launch); }, &error);
186
227
  if (error) SparkLaunchFailed(@"Unable to establish the app instance lock", error);
187
228
  if (!instanceOwner) SparkForwardLaunch();
188
229
  return instanceOwner;
@@ -0,0 +1,4 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ BOOL SparkMigrateStorage(NSURL *destination, NSArray<NSURL *> *legacyDirectories,
4
+ NSString *bundleIdentifier, NSString *configuredIdentifier, NSError **error);
@@ -0,0 +1,82 @@
1
+ #import "SparkStorage.h"
2
+ #import <sys/stdio.h>
3
+ #import <errno.h>
4
+
5
+ static NSString * const SparkStorageOwnerFile = @".spark-bundle-identifier";
6
+ static BOOL SparkStorageFail(NSError **error, NSString *message) {
7
+ if (error) *error = [NSError errorWithDomain:@"SparkStorage" code:1 userInfo:@{ NSLocalizedDescriptionKey: message }];
8
+ return NO;
9
+ }
10
+ static BOOL SparkStorageDirectory(NSURL *url, BOOL *exists, NSError **error) {
11
+ NSDictionary *attributes = [NSFileManager.defaultManager attributesOfItemAtPath:url.path error:error];
12
+ if (!attributes) {
13
+ if ([(*error).domain isEqual:NSCocoaErrorDomain] && ((*error).code == NSFileNoSuchFileError || (*error).code == NSFileReadNoSuchFileError)) { *error = nil; *exists = NO; return YES; }
14
+ return NO;
15
+ }
16
+ *exists = YES;
17
+ return [attributes[NSFileType] isEqual:NSFileTypeDirectory] || SparkStorageFail(error, [@"Expected a storage directory, not a file or symlink: " stringByAppendingString:url.path]);
18
+ }
19
+ static NSString *SparkStorageOwner(NSURL *directory, NSError **error) {
20
+ NSURL *marker = [directory URLByAppendingPathComponent:SparkStorageOwnerFile];
21
+ NSString *owner = [NSString stringWithContentsOfURL:marker encoding:NSUTF8StringEncoding error:error];
22
+ if (!owner && [(*error).domain isEqual:NSCocoaErrorDomain] && (*error).code == NSFileReadNoSuchFileError) *error = nil;
23
+ if (owner && !owner.length) SparkStorageFail(error, [@"Invalid storage owner marker: " stringByAppendingString:marker.path]);
24
+ return owner;
25
+ }
26
+ static BOOL SparkStorageClaim(NSURL *directory, NSString *bundleIdentifier, NSError **error) {
27
+ NSString *owner = SparkStorageOwner(directory, error);
28
+ if (*error) return NO;
29
+ if (!owner) {
30
+ NSFileManager *fm = NSFileManager.defaultManager;
31
+ NSURL *marker = [directory URLByAppendingPathComponent:SparkStorageOwnerFile];
32
+ NSURL *temporary = [directory URLByAppendingPathComponent:[@".spark-owner-" stringByAppendingString:NSUUID.UUID.UUIDString]];
33
+ NSData *data = [bundleIdentifier dataUsingEncoding:NSUTF8StringEncoding];
34
+ if (![data writeToURL:temporary options:NSDataWritingAtomic error:error]) return NO;
35
+ // Link a complete marker without replacing a concurrent owner's claim.
36
+ BOOL claimed = [fm linkItemAtURL:temporary toURL:marker error:error];
37
+ NSError *cleanup;
38
+ if (![fm removeItemAtURL:temporary error:&cleanup]) NSLog(@"Unable to remove storage owner staging file %@: %@", temporary.path, cleanup);
39
+ if (claimed) owner = bundleIdentifier;
40
+ else {
41
+ if (![(*error).domain isEqual:NSCocoaErrorDomain] || (*error).code != NSFileWriteFileExistsError) return NO;
42
+ *error = nil;
43
+ owner = SparkStorageOwner(directory, error);
44
+ if (*error) return NO;
45
+ }
46
+ }
47
+ return [owner isEqual:bundleIdentifier] || SparkStorageFail(error, [@"Storage belongs to another bundle: " stringByAppendingString:directory.path]);
48
+ }
49
+ BOOL SparkMigrateStorage(NSURL *destination, NSArray<NSURL *> *legacyDirectories,
50
+ NSString *bundleIdentifier, NSString *configuredIdentifier, NSError **error) {
51
+ NSError *__autoreleasing failure = nil;
52
+ if (!error) error = &failure;
53
+ *error = nil;
54
+ NSFileManager *fm = NSFileManager.defaultManager;
55
+ BOOL exists;
56
+ if (!SparkStorageDirectory(destination, &exists, error)) return NO;
57
+ if (exists) return SparkStorageClaim(destination, bundleIdentifier, error);
58
+ NSURL *source = nil;
59
+ for (NSURL *legacy in legacyDirectories) {
60
+ if ([legacy isEqual:destination]) continue;
61
+ if (!SparkStorageDirectory(legacy, &exists, error)) return NO;
62
+ if (!exists) continue;
63
+ NSString *owner = SparkStorageOwner(legacy, error);
64
+ if (*error) return NO;
65
+ if (!owner && !configuredIdentifier.length)
66
+ return SparkStorageFail(error, @"Unmarked storage needs SparkDefaultBundleIdentifier from a rebuilt custom host, or macos.bundleIdentifier supplied by the current Go CLI. Configure/rebuild the app or migrate explicitly.");
67
+ if (owner ? ![owner isEqual:bundleIdentifier] : ![configuredIdentifier isEqual:bundleIdentifier]) continue;
68
+ if (source) return SparkStorageFail(error, @"Multiple legacy storage directories need migration. Resolve them explicitly before launching the app.");
69
+ source = legacy;
70
+ }
71
+ if (![fm createDirectoryAtURL:destination.URLByDeletingLastPathComponent withIntermediateDirectories:YES attributes:nil error:error]) return NO;
72
+ if (!source) return [fm createDirectoryAtURL:destination withIntermediateDirectories:NO attributes:nil error:error] && SparkStorageClaim(destination, bundleIdentifier, error);
73
+ if ([destination.path hasPrefix:[source.path stringByAppendingString:@"/"]])
74
+ return SparkStorageFail(error, @"Legacy storage contains the destination. Resolve its data layout explicitly before launching the app.");
75
+ if (!SparkStorageClaim(source, bundleIdentifier, error)) return NO;
76
+ // Both paths are in Application Support. Rename the owned folder atomically so
77
+ // clearing the new store cannot resurrect an old snapshot on the next launch.
78
+ if (renamex_np(source.fileSystemRepresentation, destination.fileSystemRepresentation, RENAME_EXCL) == 0) return YES;
79
+ int code = errno;
80
+ *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:code userInfo:@{ NSFilePathErrorKey: source.path }];
81
+ return NO;
82
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-desktop-app",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "license": "MIT",
5
5
  "main": "src/index",
6
6
  "react-native": "src/index",
@@ -28,13 +28,7 @@
28
28
  },
29
29
  "spark": {
30
30
  "sdk": false,
31
- "nativeModules": [
32
- "NativeDesktopApp"
33
- ],
34
- "pod": "RNDesktopApp",
35
- "platforms": [
36
- "macos"
37
- ],
31
+ "nativeModules": true,
38
32
  "requires": []
39
33
  },
40
34
  "private": true
@@ -1,8 +1,7 @@
1
- const { validateOwned, validatePlatforms } = require("./validation.cjs");
1
+ const { validateOwned, validatePlatforms, validateSettings } = require("./validation.cjs");
2
2
  const fs = require("node:fs");
3
3
  const path = require("node:path");
4
4
  const { createHash } = require("node:crypto");
5
- const { validateWindow } = require("@legendapp/spark-window-options");
6
5
  const { identity } = require("./identity.cjs");
7
6
  const filename = "desktop.config.json";
8
7
  const managedConfig = "// Generated by spark: universal Expo configuration";
@@ -51,7 +50,9 @@ function readConfig(root, target = process.env.SPARK_PLATFORM) {
51
50
  if (!fs.existsSync(file)) {
52
51
  const value = JSON.parse(fs.readFileSync(path.join(root, "app.json"), "utf8"));
53
52
  if (!value?.expo || typeof value.expo !== "object" || Array.isArray(value.expo)) throw new Error("app.json needs an expo configuration object");
54
- return { ...value, expo: { ...value.expo, platforms: validatePlatforms(value.expo.platforms ?? ["macos"]) } };
53
+ const platforms = validatePlatforms(value.expo.platforms ?? ["macos"]);
54
+ if (value.expo.extra?.spark !== undefined) validateSettings(value.expo.extra.spark, selectTarget(platforms, target));
55
+ return { ...value, expo: { ...value.expo, platforms } };
55
56
  }
56
57
  const result = toExpo(JSON.parse(fs.readFileSync(file, "utf8")), target);
57
58
  return result;
@@ -93,15 +94,12 @@ function toExpo(value, target) {
93
94
  for (const key of ["name", "projectId", "version"]) if (typeof value[key] !== "string" || !value[key].trim()) throw new Error(`Desktop config needs ${key}`);
94
95
  const platforms = value.platforms ?? ["macos"];
95
96
  validatePlatforms(platforms);
96
- validateOwned(value);
97
+ validateOwned({ macos: value.macos });
97
98
  const selected = selectTarget(platforms, target);
98
99
  if (platforms.includes("macos") && (!value.macos || typeof value.macos.bundleIdentifier !== "string" || !/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/.test(value.macos.bundleIdentifier))) throw new Error("macos.bundleIdentifier must be a reverse-DNS identifier");
99
- validateWindow(value.window ?? {});
100
- if (value.include !== undefined && (!Array.isArray(value.include) || value.include.some(x => typeof x !== "string"))) throw new Error("include must be a list of package names");
101
- require("./helpers.cjs").validateHelpers(value.helpers);
102
- require("./customize.cjs").validateCustomize(value.customize);
103
100
  const extra = { projectId: value.projectId };
104
101
  for (const key of ["window", "documentTypes", "menuBarOnly", "updates", "include", "signing", "helpers", "customize"]) if (value[key] !== undefined) extra[key] = value[key];
102
+ validateSettings(extra, selected);
105
103
  const overrides = value.expoByPlatform ?? {};
106
104
  if (!overrides || typeof overrides !== "object" || Array.isArray(overrides) || Object.keys(overrides).some(p => !platforms.includes(p))) throw new Error("expoByPlatform keys must be supported platforms");
107
105
  const backend = merge(value.expo ?? {}, overrides[selected] ?? {});
@@ -1,6 +1,7 @@
1
1
  const { nativeWindowOptions } = require("@legendapp/spark-window-options");
2
2
  const { updatePlist } = require("./updates.cjs");
3
3
  function identity(config) {
4
+ require("./validation.cjs").validateSettings(config.extra?.spark, "macos");
4
5
  const projectId = config.extra?.spark?.projectId ?? config.macos?.bundleIdentifier;
5
6
  if (typeof projectId !== "string" || !projectId.length || projectId.length > 200) throw new Error("Set extra.spark.projectId to a stable project identifier");
6
7
  const schemes = config.scheme === undefined ? [] : Array.isArray(config.scheme) ? config.scheme : [config.scheme];
@@ -16,6 +17,7 @@ function identity(config) {
16
17
  LSUIElement: config.extra?.spark?.menuBarOnly === true,
17
18
  SparkMenuBarOnly: config.extra?.spark?.menuBarOnly === true,
18
19
  SparkProjectIdentifier: projectId,
20
+ SparkDefaultBundleIdentifier: config.macos?.bundleIdentifier,
19
21
  SparkLifecycleConfiguration: require("./lifecycle.cjs").validateLifecycle(config.macos?.lifecycle),
20
22
  SparkWindowConfiguration: nativeWindowOptions(config.extra?.spark?.window ?? {}),
21
23
  ...updatePlist(config),