@legendapp/spark 0.0.2 → 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 (224) hide show
  1. package/init-template.cjs +7 -1
  2. package/package.json +10 -5
  3. package/patches/dependencies.json +252 -0
  4. package/patches/expo-application@55.0.19.patch +54 -0
  5. package/patches/expo-blur@55.0.18.patch +130 -0
  6. package/patches/expo-device@55.0.21.patch +149 -0
  7. package/patches/expo-font@55.0.8.patch +55 -0
  8. package/patches/expo-glass-effect@55.0.11.patch +304 -0
  9. package/patches/expo-haptics@55.0.18.patch +54 -0
  10. package/patches/expo-image-manipulator@55.0.21.patch +312 -0
  11. package/patches/expo-image-picker@55.0.24.patch +327 -0
  12. package/patches/expo-image@55.0.11.patch +158 -0
  13. package/patches/expo-keep-awake@55.0.8.patch +41 -0
  14. package/patches/expo-localization@55.0.19.patch +32 -0
  15. package/patches/expo-location@55.1.15.patch +190 -0
  16. package/patches/expo-symbols@55.0.9.patch +286 -0
  17. package/patches/expo-system-ui@55.0.22.patch +61 -0
  18. package/patches/expo-web-browser@55.0.20.patch +13 -0
  19. package/patches/react-native-app-logs@0.3.1.patch +20 -0
  20. package/patches/react-native-blurhash@2.1.3.patch +318 -0
  21. package/patches/react-native-community-blur@4.4.1.patch +415 -0
  22. package/patches/react-native-community-datetimepicker@9.2.2.patch +320 -0
  23. package/patches/react-native-fast-image@10.9.9.patch +131 -0
  24. package/patches/react-native-graph@1.4.0.patch +157 -0
  25. package/patches/react-native-keyboard-controller@1.22.9.patch +16 -0
  26. package/patches/react-native-masked-view-masked-view@0.3.2.patch +140 -0
  27. package/patches/react-native-mmkv@4.3.2.patch +40 -0
  28. package/patches/react-native-nitro-fetch@1.9.0.patch +130 -0
  29. package/patches/react-native-nitro-zxing@0.3.0.patch +13 -0
  30. package/patches/react-native-nitro-zxing@0.3.1.patch +22 -0
  31. package/patches/react-native-quick-base64@3.0.1.patch +13 -0
  32. package/patches/react-native-quick-crypto@1.1.9.patch +31 -0
  33. package/patches/react-native-release-profiler@0.4.5.patch +37 -0
  34. package/patches/react-native-screen-corner-radius@0.2.3.patch +13 -0
  35. package/patches/react-native-screens@4.23.0.patch +160 -0
  36. package/patches/react-native-svg@15.15.3.patch +31 -0
  37. package/patches/react-native-unistyles@3.6.0.patch +203 -0
  38. package/patches/react-native-worklets-core@1.6.3.patch +13 -0
  39. package/patches/react-navigation-native-stack@7.21.0.patch +16 -0
  40. package/patches/registry.json +615 -0
  41. package/patches/sentry-react-native@8.32.0.patch +76 -0
  42. package/patches/workspace/expo-audio@55.0.18.patch +159 -0
  43. package/patches/workspace/op-engineering-op-sqlite@18.2.1.patch +796 -0
  44. package/patches/workspace/react-native-nitro-modules@0.37.0.patch +1348 -0
  45. package/patches/workspace/react-native-runtimes-core@0.1.0-alpha.2.patch +276 -0
  46. package/patches/workspace/react-native-webview@16.0.0.patch +208 -0
  47. package/postinstall.cjs +10 -1
  48. package/skills/spark/SKILL.md +37 -4
  49. package/skills/spark/UPGRADING.md +150 -1
  50. package/skills/spark/ai-customize.md +39 -0
  51. package/skills/spark/app-and-documents.md +56 -0
  52. package/skills/spark/external-libraries.md +87 -0
  53. package/skills/spark/files.md +64 -0
  54. package/skills/spark/integrations.md +69 -0
  55. package/skills/spark/keyboard.md +54 -0
  56. package/skills/spark/library-compat.md +76 -0
  57. package/skills/spark/menus-tray-dock.md +83 -0
  58. package/skills/spark/storage-settings.md +85 -0
  59. package/skills/spark/ui.md +57 -0
  60. package/skills/spark/windows.md +91 -0
  61. package/ui-popover.ts +1 -0
  62. package/ui-progress.ts +1 -0
  63. package/ui-sheet.ts +1 -0
  64. package/ui-split-view.ts +1 -0
  65. package/ui-table.ts +1 -0
  66. package/vendor/node_modules/@legendapp/spark-ai/package.json +3 -3
  67. package/vendor/node_modules/@legendapp/spark-audio/package.json +3 -13
  68. package/vendor/node_modules/@legendapp/spark-auth-session/package.json +3 -10
  69. package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +5 -0
  70. package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +139 -104
  71. package/vendor/node_modules/@legendapp/spark-cli/dist/cli-arguments.js +4 -1
  72. package/vendor/node_modules/@legendapp/spark-cli/dist/commands.js +16 -7
  73. package/vendor/node_modules/@legendapp/spark-cli/dist/dependency-pins.js +19 -3
  74. package/vendor/node_modules/@legendapp/spark-cli/dist/dev-command.js +2 -0
  75. package/vendor/node_modules/@legendapp/spark-cli/dist/dev.js +10 -2
  76. package/vendor/node_modules/@legendapp/spark-cli/dist/enriched-html-pins.js +2 -0
  77. package/vendor/node_modules/@legendapp/spark-cli/dist/errors.js +1 -1
  78. package/vendor/node_modules/@legendapp/spark-cli/dist/index.js +57 -9
  79. package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.cjs +12 -2
  80. package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.d.cts +1 -1
  81. package/vendor/node_modules/@legendapp/spark-cli/dist/metro.cjs +1 -0
  82. package/vendor/node_modules/@legendapp/spark-cli/dist/migrate.js +65 -0
  83. package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.cjs +4 -4
  84. package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.d.cts +2 -2
  85. package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.cjs +15 -8
  86. package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +35 -7
  87. package/vendor/node_modules/@legendapp/spark-cli/dist/patch.js +92 -0
  88. package/vendor/node_modules/@legendapp/spark-cli/dist/project-version.js +12 -4
  89. package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +20 -1
  90. package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +20 -20
  91. package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-input-cache.js +140 -0
  92. package/vendor/node_modules/@legendapp/spark-cli/dist/upgrade.js +1 -1
  93. package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +3 -0
  94. package/vendor/node_modules/@legendapp/spark-cli/package.json +5 -4
  95. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +2 -2
  96. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +2 -2
  97. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +2 -2
  98. package/vendor/node_modules/@legendapp/spark-clipboard/macos/RNDesktopClipboard.mm +1 -1
  99. package/vendor/node_modules/@legendapp/spark-clipboard/package.json +3 -10
  100. package/vendor/node_modules/@legendapp/spark-clipboard/src/desktop.ts +1 -0
  101. package/vendor/node_modules/@legendapp/spark-codex/package.json +3 -7
  102. package/vendor/node_modules/@legendapp/spark-commands/package.json +5 -5
  103. package/vendor/node_modules/@legendapp/spark-context-menu/package.json +3 -10
  104. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.h +3 -1
  105. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +51 -10
  106. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.h +4 -0
  107. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.mm +82 -0
  108. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.mm +64 -2
  109. package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +2 -8
  110. package/vendor/node_modules/@legendapp/spark-desktop-config/autolinking.cjs +3 -2
  111. package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +6 -8
  112. package/vendor/node_modules/@legendapp/spark-desktop-config/identity.cjs +2 -0
  113. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs +315 -68
  114. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.d.cts +7 -0
  115. package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +3 -3
  116. package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.cjs +318 -0
  117. package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.d.cts +20 -0
  118. package/vendor/node_modules/@legendapp/spark-desktop-config/validation.cjs +66 -9
  119. package/vendor/node_modules/@legendapp/spark-desktop-config/windows.plugin.cjs +1 -0
  120. package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +1 -0
  121. package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +2 -2
  122. package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +3 -10
  123. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +3 -10
  124. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.mm +7 -2
  125. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +235 -240
  126. package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +4 -11
  127. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/api.ts +9 -3
  128. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +7 -0
  129. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/types.ts +32 -3
  130. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/validation.ts +28 -11
  131. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/createWindowsNavigator.tsx +15 -3
  132. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/primaryWindowLifecycle.ts +12 -3
  133. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/usePrimaryWindowLifecycle.ts +2 -1
  134. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/useWindowFocusEffect.ts +4 -1
  135. package/vendor/node_modules/@legendapp/spark-documents/package.json +7 -7
  136. package/vendor/node_modules/@legendapp/spark-drag-drop/macos/RNDesktopDragView.mm +77 -17
  137. package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +3 -8
  138. package/vendor/node_modules/@legendapp/spark-drag-drop/src/DesktopDragViewNativeComponent.ts +1 -0
  139. package/vendor/node_modules/@legendapp/spark-drag-drop/src/contracts.ts +13 -4
  140. package/vendor/node_modules/@legendapp/spark-drag-drop/src/index.tsx +5 -3
  141. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.h +6 -1
  142. package/vendor/node_modules/@legendapp/spark-expo-compat/metro.cjs +44 -0
  143. package/vendor/node_modules/@legendapp/spark-expo-compat/package.json +20 -0
  144. package/vendor/node_modules/@legendapp/spark-expo-compat/src/clipboard.ts +40 -0
  145. package/vendor/node_modules/@legendapp/spark-expo-compat/src/document-picker.ts +52 -0
  146. package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +3 -10
  147. package/vendor/node_modules/@legendapp/spark-file-dialog/src/options.ts +5 -2
  148. package/vendor/node_modules/@legendapp/spark-file-dialog/src/types.ts +3 -3
  149. package/vendor/node_modules/@legendapp/spark-file-system/macos/RNDesktopFileSystem.mm +1 -1
  150. package/vendor/node_modules/@legendapp/spark-file-system/package.json +3 -11
  151. package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +3 -10
  152. package/vendor/node_modules/@legendapp/spark-html/package.json +2 -2
  153. package/vendor/node_modules/@legendapp/spark-markdown/package.json +2 -2
  154. package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +3 -10
  155. package/vendor/node_modules/@legendapp/spark-message-dialog/src/index.ts +1 -0
  156. package/vendor/node_modules/@legendapp/spark-native-menu/package.json +3 -9
  157. package/vendor/node_modules/@legendapp/spark-native-menu/src/hooks.ts +4 -0
  158. package/vendor/node_modules/@legendapp/spark-notifications/package.json +3 -10
  159. package/vendor/node_modules/@legendapp/spark-processes/package.json +3 -10
  160. package/vendor/node_modules/@legendapp/spark-rich-text/package.json +2 -2
  161. package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +3 -10
  162. package/vendor/node_modules/@legendapp/spark-settings/package.json +3 -3
  163. package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +4 -4
  164. package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
  165. package/vendor/node_modules/@legendapp/spark-system/package.json +3 -10
  166. package/vendor/node_modules/@legendapp/spark-tray/package.json +3 -10
  167. package/vendor/node_modules/@legendapp/spark-tray/src/index.ts +2 -1
  168. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.mm +82 -14
  169. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.h +1 -1
  170. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.mm +94 -11
  171. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +235 -18
  172. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.h +17 -0
  173. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.mm +216 -0
  174. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.h +4 -0
  175. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.mm +212 -0
  176. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewUpdates.h +6 -0
  177. package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +26 -13
  178. package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.h +9 -0
  179. package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.mm +126 -0
  180. package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.h +9 -0
  181. package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.mm +66 -0
  182. package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.h +9 -0
  183. package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.mm +118 -0
  184. package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.mm +4 -12
  185. package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.h +9 -0
  186. package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.mm +109 -0
  187. package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +418 -102
  188. package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.h +9 -0
  189. package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.mm +179 -0
  190. package/vendor/node_modules/@legendapp/spark-ui/package.json +9 -8
  191. package/vendor/node_modules/@legendapp/spark-ui/src/SparkButtonNativeComponent.ts +10 -2
  192. package/vendor/node_modules/@legendapp/spark-ui/src/SparkTextInputNativeComponent.ts +2 -0
  193. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +9 -0
  194. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitView.tsx +99 -0
  195. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitViewNativeComponent.ts +29 -0
  196. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +34 -17
  197. package/vendor/node_modules/@legendapp/spark-ui/src/availability.ts +5 -4
  198. package/vendor/node_modules/@legendapp/spark-ui/src/checkbox-unavailable.tsx +20 -0
  199. package/vendor/node_modules/@legendapp/spark-ui/src/control.ts +24 -3
  200. package/vendor/node_modules/@legendapp/spark-ui/src/desktop.tsx +63 -13
  201. package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +12 -7
  202. package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +12 -7
  203. package/vendor/node_modules/@legendapp/spark-ui/src/index.web.tsx +35 -13
  204. package/vendor/node_modules/@legendapp/spark-ui/src/mobile-input.tsx +2 -2
  205. package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSegmentedControlNativeComponent.ts +3 -1
  206. package/vendor/node_modules/@legendapp/spark-ui/src/popover/PopoverNativeComponent.ts +20 -0
  207. package/vendor/node_modules/@legendapp/spark-ui/src/popover/index.tsx +45 -0
  208. package/vendor/node_modules/@legendapp/spark-ui/src/progress/ProgressIndicatorNativeComponent.ts +13 -0
  209. package/vendor/node_modules/@legendapp/spark-ui/src/progress/index.tsx +32 -0
  210. package/vendor/node_modules/@legendapp/spark-ui/src/radio-group/RadioGroupNativeComponent.ts +17 -0
  211. package/vendor/node_modules/@legendapp/spark-ui/src/sheet/SheetNativeComponent.ts +15 -0
  212. package/vendor/node_modules/@legendapp/spark-ui/src/sheet/index.tsx +38 -0
  213. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarItemNativeComponent.ts +9 -1
  214. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarNativeComponent.ts +17 -2
  215. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/index.tsx +106 -22
  216. package/vendor/node_modules/@legendapp/spark-ui/src/table/TableNativeComponent.ts +22 -0
  217. package/vendor/node_modules/@legendapp/spark-ui/src/table/index.tsx +118 -0
  218. package/vendor/node_modules/@legendapp/spark-ui/src/types.ts +39 -6
  219. package/vendor/node_modules/@legendapp/spark-ui/uniwind.ts +3 -1
  220. package/vendor/node_modules/@legendapp/spark-ui/uniwind.web.ts +2 -1
  221. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.h +46 -15
  222. package/vendor/node_modules/@legendapp/spark-updates/package.json +3 -9
  223. package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
  224. package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
@@ -1,7 +1,9 @@
1
+ const { SparkError, validatePackageSettings } = require("./validation.cjs");
1
2
  const { createHash } = require("node:crypto");
2
3
  const fs = require("node:fs");
3
4
  const path = require("node:path");
4
5
  const { createRequire } = require("node:module");
6
+ const { sourceFor, selectPatch, assertRegistryVersions, patchDisabled, installedRegistryPackages, readPatch } = require("./patch-registry.cjs");
5
7
 
6
8
  const optionalBackends = ["react-native-enriched-markdown", "react-native-enriched-html", "react-native-webview", "@op-engineering/op-sqlite"];
7
9
  const cameraPackages = ["react-native-nitro-image", "react-native-vision-camera"];
@@ -10,48 +12,282 @@ function readManifest(file) {
10
12
  return JSON.parse(fs.readFileSync(file, "utf8"));
11
13
  }
12
14
 
15
+ // Find a package's manifest even when its exports map hides package.json, as Node finds the package.
16
+ function resolveManifest(req, name) {
17
+ try { return req.resolve(`${name}/package.json`); }
18
+ catch (error) {
19
+ if (error.code !== "ERR_PACKAGE_PATH_NOT_EXPORTED") throw error;
20
+ const file = (req.resolve.paths(name) ?? []).map(directory => path.join(directory, name, "package.json")).find(fs.existsSync);
21
+ if (!file) throw error;
22
+ return file;
23
+ }
24
+ }
25
+
26
+ const hash = bytes => createHash("sha256").update(bytes).digest("hex");
27
+ const warned = new Set();
28
+ function warnOnce(message) {
29
+ if (!warned.has(message)) console.warn(message);
30
+ warned.add(message);
31
+ }
32
+
33
+ // App patches by convention: patches/<name>@<version>.patch, with + for / in scoped names. patch-package's
34
+ // <name>+<version>.patch files and bun/pnpm patchedDependencies are third-party: the package manager installs them.
35
+ function appPatchEntries(root, app) {
36
+ const patches = [];
37
+ const add = (name, version, file, thirdParty) => {
38
+ patches.push([name, { version, file, thirdParty, bytes: fs.readFileSync(path.join(root, file)) }]);
39
+ };
40
+ const listed = { ...app.pnpm?.patchedDependencies, ...app.patchedDependencies };
41
+ for (const [key, file] of Object.entries(listed)) {
42
+ const at = key.lastIndexOf("@");
43
+ add(at > 0 ? key.slice(0, at) : key, at > 0 ? key.slice(at + 1) : undefined, path.normalize(file), true);
44
+ }
45
+ const files = new Set(Object.values(listed).map(file => path.normalize(file)));
46
+ const directory = path.join(root, "patches");
47
+ // Spark's own repository keeps Spark's patches there, under the same names.
48
+ const appFolder = fs.existsSync(directory) && !fs.existsSync(path.join(directory, "dependencies.json"));
49
+ for (const entry of appFolder ? fs.readdirSync(directory).sort() : []) {
50
+ const file = path.join("patches", entry);
51
+ const own = /^(.+?)@([^@]+)\.patch$/.exec(entry);
52
+ const match = own ?? /^((?:@[^+]+\+)?[^+@]+)\+([^+]+?)(?:\.dev)?(?:\+.*)?\.patch$/.exec(entry);
53
+ if (match && !files.has(file)) add(match[1].replace("+", "/"), match[2], file, !own);
54
+ }
55
+ return patches;
56
+ }
57
+
58
+ function appPatches(root, app) {
59
+ const patches = {};
60
+ for (const [name, own] of appPatchEntries(root, app)) {
61
+ const error = patches[name] && `Both ${patches[name].file} and ${own.file} patch ${name}; combine them into one.`;
62
+ // patch-package may split one library's patch in several files; that only matters where Spark layers it.
63
+ if (error && !(own.thirdParty && patches[name].thirdParty)) throw new Error(error);
64
+ patches[name] = { ...own, error };
65
+ }
66
+ return patches;
67
+ }
68
+
69
+ // The receipt rewrites package.json with two-space JSON, so patch hunks target that form without the receipt.
70
+ function withoutReceipt(text) {
71
+ const manifest = JSON.parse(text);
72
+ if (manifest.spark?.dependencyPatch) {
73
+ delete manifest.spark.dependencyPatch;
74
+ delete manifest.spark.sdk;
75
+ delete manifest.spark.requires;
76
+ if (!Object.keys(manifest.spark).length) delete manifest.spark;
77
+ }
78
+ return JSON.stringify(manifest, null, 2) + "\n";
79
+ }
80
+
81
+ // Layers are [Spark's patch, the app's patch], each { text, applied, apply, error }, where applied is the
82
+ // layer's text the package may hold when it differs from text. A file may hold both layers, Spark's alone,
83
+ // the app's alone (installed by a package manager) or neither: undo what it holds, then apply the enabled
84
+ // layers. Every file is verified before any is written.
85
+ function layerPatches(packageRoot, name, layers, { dryRun = false } = {}) {
86
+ const { parsePatch, applyPatch, reversePatch } = require("diff");
87
+ const files = new Map();
88
+ const add = (text, index, kind) => {
89
+ for (const patch of text ? parsePatch(text) : []) {
90
+ let relative = patch.newFileName.replace(/^b\//, "");
91
+ if (relative.startsWith(`node_modules/${name}/`)) relative = relative.slice(`node_modules/${name}/`.length);
92
+ const target = path.resolve(packageRoot, relative);
93
+ if (!target.startsWith(packageRoot + path.sep) || patch.newFileName === "/dev/null") throw new Error(`Invalid native patch target: ${relative}`);
94
+ if (!files.has(relative)) files.set(relative, { target, held: [], patches: [] });
95
+ files.get(relative)[kind][index] = patch;
96
+ }
97
+ };
98
+ layers.forEach((layer, index) => {
99
+ add(layer?.applied ?? layer?.text, index, "held");
100
+ if (layer?.apply) add(layer.text, index, "patches");
101
+ });
102
+ const created = patch => patch?.oldFileName === "/dev/null";
103
+ const undo = (text, patch) => {
104
+ if (text === false || !patch) return text;
105
+ const result = applyPatch(text, reversePatch(patch));
106
+ return created(patch) && result !== "" ? false : result;
107
+ };
108
+ const writes = [];
109
+ for (const [relative, { target, held, patches }] of files) {
110
+ let current = fs.existsSync(target) ? fs.readFileSync(target, "utf8") : "";
111
+ if (relative === "package.json") current = withoutReceipt(current);
112
+ let next = [[0, 1], [0], [1]].map(state => state.reduceRight((text, index) => undo(text, held[index]), current))
113
+ .find(text => text !== false) ?? current;
114
+ layers.forEach((layer, index) => {
115
+ if (!patches[index]) return;
116
+ next = created(patches[index]) && next !== "" ? false : applyPatch(next, patches[index]);
117
+ if (next === false) throw new Error(layer.error(relative));
118
+ });
119
+ if (next !== current) writes.push([target, next === "" && [...held, ...patches].some(created) ? null : next]);
120
+ }
121
+ if (dryRun) return;
122
+ // Rename rather than mutate package-manager cache hardlinks.
123
+ for (const [target, next] of writes) {
124
+ if (next === null) { fs.rmSync(target, { force: true }); continue; }
125
+ fs.mkdirSync(path.dirname(target), { recursive: true });
126
+ const temporary = `${target}.spark-${process.pid}.tmp`;
127
+ fs.writeFileSync(temporary, next); fs.renameSync(temporary, target);
128
+ }
129
+ }
130
+
131
+ function stamp(file, installed, update) {
132
+ const manifest = readManifest(file);
133
+ manifest.spark ??= {};
134
+ update(manifest);
135
+ const root = fs.realpathSync(path.dirname(file));
136
+ const pkg = installed.find(pkg => pkg.root === root);
137
+ if (pkg) pkg.json = manifest;
138
+ const serialized = JSON.stringify(manifest, null, 2) + "\n";
139
+ if (fs.readFileSync(file, "utf8") !== serialized) {
140
+ const temporary = `${file}.spark-${process.pid}.tmp`;
141
+ fs.writeFileSync(temporary, serialized); fs.renameSync(temporary, file);
142
+ }
143
+ }
144
+
145
+ function nativePatchInventory(sparkFile, hasCamera) {
146
+ const spark = readManifest(sparkFile);
147
+ const directory = path.dirname(sparkFile);
148
+ const patchesRoot = spark.spark?.bundledModuleRoot
149
+ ? path.join(directory, "patches") : path.resolve(__dirname, "../../patches");
150
+ const pins = {};
151
+ if (hasCamera) {
152
+ const cameraPins = JSON.parse(fs.readFileSync(path.join(patchesRoot, "camera/upstream.json"), "utf8"));
153
+ for (const name of ["react-native-nitro-modules", ...cameraPackages]) {
154
+ pins[name] = { ...cameraPins[name], patch: `camera/${name}.patch`,
155
+ requires: name === "react-native-vision-camera" ? ["react-native-nitro-modules", "react-native-nitro-image"] : ["react-native-nitro-modules"] };
156
+ }
157
+ }
158
+ const integrations = path.join(patchesRoot, "dependencies.json");
159
+ if (fs.existsSync(integrations)) Object.assign(pins, JSON.parse(fs.readFileSync(integrations, "utf8")));
160
+ const source = sourceFor(directory);
161
+ if (source) {
162
+ for (const [name, library] of Object.entries(source.registry.libraries)) {
163
+ if (library.kind === "patch" && (!cameraPackages.includes(name) && name !== "react-native-nitro-modules" || hasCamera)) {
164
+ pins[name] ??= library.versions[0];
165
+ }
166
+ }
167
+ }
168
+ return { pins, patchesRoot: source?.directory ?? patchesRoot, source };
169
+ }
170
+
171
+ // Use the same file checks as preparation, but never write patches or receipts into node_modules.
172
+ function appPatchIssues(root) {
173
+ const manifestFile = path.join(root, "package.json");
174
+ if (!fs.existsSync(manifestFile)) return [];
175
+ const app = readManifest(manifestFile);
176
+ if (app.name === "@legendapp/spark") return [];
177
+ const ownPatches = appPatchEntries(root, app);
178
+ if (!ownPatches.length) return [];
179
+ const req = createRequire(manifestFile);
180
+ let inventory;
181
+ try {
182
+ const sparkFile = req.resolve("@legendapp/spark/package.json");
183
+ const dependencies = { ...readManifest(sparkFile).dependencies, ...app.dependencies, ...app.devDependencies, ...app.optionalDependencies };
184
+ inventory = nativePatchInventory(sparkFile, cameraPackages.some(name => dependencies[name]));
185
+ } catch (error) { if (error.code !== "MODULE_NOT_FOUND") throw error; }
186
+ const issues = [];
187
+ for (const [name, own] of ownPatches) {
188
+ const remove = `Remove ${own.file}${own.thirdParty ? " and its package-manager patch declaration (patchedDependencies, if listed)" : ""}`;
189
+ const redo = `${remove}, reinstall ${name}, then run spark patch ${name} to recreate the app patch.`;
190
+ let file;
191
+ try { file = resolveManifest(req, name); }
192
+ catch (error) {
193
+ if (error.code !== "MODULE_NOT_FOUND") throw error;
194
+ issues.push(`${own.file} patches ${name}, which isn't installed.\n Fix: ${remove}, or install ${name}${own.version ? `@${own.version}` : ""}.`);
195
+ continue;
196
+ }
197
+ const manifest = readManifest(file);
198
+ if (own.version && own.version !== manifest.version) {
199
+ issues.push(`${own.file} patches ${name}@${own.version}, but ${manifest.version} is installed.\n Fix: ${redo}`);
200
+ continue;
201
+ }
202
+ const candidate = inventory?.source?.registry.libraries[name]?.kind === "patch"
203
+ ? selectPatch(inventory.source.registry.libraries[name], manifest.version, inventory.source.sparkVersion) : inventory?.pins[name];
204
+ const pin = candidate?.version === manifest.version ? candidate : undefined;
205
+ // Package-manager patches on other libraries remain the package manager's responsibility.
206
+ if (own.thirdParty && !pin) continue;
207
+ const packageRoot = fs.realpathSync(path.dirname(file));
208
+ const enabled = !!pin && app.spark?.patches?.[name] !== false;
209
+ const kept = path.join(packageRoot, ".spark-app.patch");
210
+ try {
211
+ layerPatches(packageRoot, name, [
212
+ pin ? {
213
+ text: (inventory.source ? readPatch(inventory.source, pin) : fs.readFileSync(path.join(inventory.patchesRoot, pin.patch))).toString("utf8"),
214
+ applied: fs.existsSync(path.join(packageRoot, ".spark-base.patch")) ? fs.readFileSync(path.join(packageRoot, ".spark-base.patch"), "utf8") : undefined, apply: enabled,
215
+ error: relative => `${own.file} conflicts with Spark's ${name} patch at ${relative}.`,
216
+ } : undefined,
217
+ { text: own.bytes.toString("utf8"), applied: fs.existsSync(kept) ? fs.readFileSync(kept, "utf8") : undefined, apply: true,
218
+ error: relative => `${own.file} ${enabled ? `conflicts with Spark's ${name} patch` : "cannot apply"} at ${relative}.` },
219
+ ], { dryRun: true });
220
+ } catch (error) { issues.push(`${error.message}\n Fix: ${redo}`); }
221
+ }
222
+ return issues;
223
+ }
224
+
13
225
  function prepareNativePatches(root, installed = []) {
14
226
  const manifestFile = path.join(root, "package.json");
15
227
  if (!fs.existsSync(manifestFile)) return {};
16
228
  const app = readManifest(manifestFile);
17
229
  if (app.name !== "@legendapp/spark" && !app.dependencies?.["@legendapp/spark"] && !app.devDependencies?.["@legendapp/spark"]) return {};
230
+ validatePackageSettings(app.spark, root);
231
+ assertRegistryVersions(root);
18
232
  const appRequire = createRequire(manifestFile);
19
233
  let sparkFile;
20
234
  try { sparkFile = appRequire.resolve("@legendapp/spark/package.json"); }
21
235
  catch (error) { if (error.code === "MODULE_NOT_FOUND") return {}; throw error; }
22
236
  const spark = readManifest(sparkFile);
23
- const directory = path.dirname(sparkFile);
24
- const patchesRoot = spark.spark?.bundledModuleRoot
25
- ? path.join(directory, "patches") : path.resolve(__dirname, "../../patches");
26
237
  const dependencies = { ...spark.dependencies, ...app.dependencies, ...app.devDependencies };
27
238
  for (const name of [...cameraPackages, ...optionalBackends]) {
28
239
  if (app.optionalDependencies?.[name] || installed.some(pkg => pkg.name === name)) dependencies[name] = true;
29
240
  }
30
- const hasCamera = cameraPackages.some(name => dependencies[name]);
31
- const pins = {};
32
- if (hasCamera) {
33
- const cameraPins = JSON.parse(fs.readFileSync(path.join(patchesRoot, "camera/upstream.json"), "utf8"));
34
- for (const name of ["react-native-nitro-modules", ...cameraPackages]) {
35
- pins[name] = { ...cameraPins[name], patch: `camera/${name}.patch`,
36
- requires: name === "react-native-vision-camera" ? ["react-native-nitro-modules", "react-native-nitro-image"] : ["react-native-nitro-modules"] };
241
+ const currentSource = sourceFor(root);
242
+ const registryPackages = currentSource ? installedRegistryPackages(root, currentSource) : [];
243
+ const hasCamera = cameraPackages.some(name => dependencies[name] || registryPackages.some(pkg => pkg.name === name));
244
+ const { pins, patchesRoot, source } = nativePatchInventory(sparkFile, hasCamera);
245
+ if (source) {
246
+ for (const pkg of registryPackages) {
247
+ if (source.registry.libraries[pkg.name].kind !== "patch" || pkg.name === "react-native-nitro-modules" && !hasCamera) continue;
248
+ dependencies[pkg.name] = true;
249
+ pins[pkg.name] ??= source.registry.libraries[pkg.name].versions[0];
250
+ if (!installed.some(entry => entry.root === pkg.root)) installed.push({ name: pkg.name, root: pkg.root, json: readManifest(pkg.file) });
37
251
  }
38
252
  }
39
- const integrations = path.join(patchesRoot, "dependencies.json");
40
- if (fs.existsSync(integrations)) Object.assign(pins, JSON.parse(fs.readFileSync(integrations, "utf8")));
253
+ for (const name of Object.keys(app.spark?.patches ?? {})) if (!Object.hasOwn(source?.registry.libraries ?? pins, name)) throw new SparkError(`Unknown package.json spark.patches package: ${name}`, "E_UNSUPPORTED_OPTION");
41
254
  const active = Object.keys(pins).filter(name => dependencies[name] ||
42
255
  (hasCamera && name === "react-native-nitro-modules") ||
43
256
  (dependencies["react-native-vision-camera"] && name === "react-native-nitro-image"));
44
- if (!active.length) return {};
45
- const { parsePatch, applyPatch, reversePatch } = require("diff");
257
+ const ownPatches = app.name === "@legendapp/spark" ? {} : appPatches(root, app);
258
+ const appPatch = (name, version) => {
259
+ const own = ownPatches[name];
260
+ if (own?.error) throw new Error(own.error);
261
+ if (own?.version && own.version !== version) throw new Error(`${own.file} patches ${name}@${own.version}, but ${version} is installed. Redo it with spark patch ${name}.`);
262
+ return own;
263
+ };
264
+ // Records which app root's patch an install carries; app roots sharing one install must agree on it.
265
+ const appRoot = (name, packageRoot, manifest, own) => {
266
+ const previous = manifest.spark?.dependencyPatch, appPatchHash = own && hash(own.bytes), self = path.resolve(root);
267
+ if (previous?.appRoot && previous.appRoot !== self && previous.appPatchHash !== appPatchHash) {
268
+ throw new Error(`${name} in ${packageRoot} carries the app patch from ${previous.appRoot}, not ${self}'s. App roots that share one install need one patch set: keep the patch at the shared root and give every app the same file, or reinstall ${name}.`);
269
+ }
270
+ return own && (previous?.appPatchHash === appPatchHash && previous.appRoot || self);
271
+ };
272
+ // The package keeps the app patch it carries, so an edited or removed patch is undone in place.
273
+ const layerApp = (packageRoot, name, spark, own, error) => {
274
+ const kept = path.join(packageRoot, ".spark-app.patch");
275
+ const applied = fs.existsSync(kept) ? fs.readFileSync(kept, "utf8") : undefined;
276
+ const text = own ? own.bytes.toString("utf8") : applied;
277
+ layerPatches(packageRoot, name, [spark, text !== undefined && { text, applied, apply: !!own, error }]);
278
+ if (!own) fs.rmSync(kept, { force: true });
279
+ else if (applied !== text) fs.writeFileSync(kept, own.bytes);
280
+ };
281
+ const layered = new Set(), skipped = new Set();
46
282
  const queue = [appRequire, createRequire(sparkFile)].map(req => ({ req, optionalOnly: false }));
47
- if (hasCamera || optionalBackends.some(name => dependencies[name])) queue.push(...installed.map(pkg => ({ req: createRequire(path.join(pkg.root, "package.json")), optionalOnly: true })));
283
+ if (source || hasCamera || optionalBackends.some(name => dependencies[name])) queue.push(...installed.map(pkg => ({ req: createRequire(path.join(pkg.root, "package.json")), optionalOnly: true })));
48
284
  const visited = new Set();
49
285
  const packages = {};
50
286
  for (const { req, optionalOnly } of queue) {
51
287
  for (const name of active) {
52
- if (optionalOnly && name !== "react-native-nitro-modules" && !cameraPackages.includes(name) && !optionalBackends.includes(name)) continue;
288
+ if (optionalOnly && !source && name !== "react-native-nitro-modules" && !cameraPackages.includes(name) && !optionalBackends.includes(name)) continue;
53
289
  let file;
54
- try { file = req.resolve(`${name}/package.json`); }
290
+ try { file = resolveManifest(req, name); }
55
291
  catch (error) {
56
292
  if (error.code !== "MODULE_NOT_FOUND") throw error;
57
293
  continue;
@@ -60,66 +296,77 @@ function prepareNativePatches(root, installed = []) {
60
296
  const packageRoot = fs.realpathSync(path.dirname(file));
61
297
  if (visited.has(packageRoot)) continue;
62
298
  visited.add(packageRoot);
299
+ const manifest = JSON.parse(fs.readFileSync(file, "utf8"));
300
+ const library = source?.registry.libraries[name];
301
+ const pin = library ? selectPatch(library, manifest.version, source.sparkVersion) : pins[name];
302
+ if (!pin && patchDisabled(root, name, file)) { skipped.add(name); continue; }
303
+ if (!pin) throw new Error(`No compatible Spark patch for ${name}@${manifest.version}. Run spark doctor.`);
304
+ if (pin.optional && manifest.version !== pin.version) {
305
+ if (patchDisabled(root, name, file)) continue;
306
+ throw new Error(`Spark's desktop patch for ${name} needs ${pin.version}; found ${manifest.version}. Install ${name}@${pin.version}, then retry.`);
307
+ }
63
308
  packages[name] = { root: packageRoot };
64
309
  queue.push({ req: createRequire(file), optionalOnly });
65
- const manifest = JSON.parse(fs.readFileSync(file, "utf8"));
66
- const pin = pins[name];
67
310
  if (manifest.version !== pin.version) {
68
311
  const owner = readManifest(req.resolve("./package.json"));
69
312
  throw new Error(`Spark needs ${name}@${pin.version}; found ${manifest.version} at ${packageRoot}, required by ${owner.name ?? root}. Add an override/resolution for the pinned version.`);
70
313
  }
71
- const bytes = fs.readFileSync(path.join(patchesRoot, pin.patch));
72
- const writes = [];
73
- for (const patch of parsePatch(bytes.toString("utf8"))) {
74
- const relative = patch.newFileName.replace(/^b\//, "");
75
- const target = path.resolve(packageRoot, relative);
76
- if (!target.startsWith(packageRoot + path.sep) || patch.newFileName === "/dev/null") throw new Error(`Invalid native patch target: ${relative}`);
77
- let current = fs.existsSync(target) ? fs.readFileSync(target, "utf8") : "";
78
- if (patch.oldFileName === "/dev/null") {
79
- const next = applyPatch("", patch);
80
- if (current === next) continue;
81
- if (current !== "") throw new Error(`Cannot apply Spark's ${name} patch to ${relative}. Reinstall dependencies before retrying.`);
82
- writes.push([target, next]);
83
- continue;
84
- }
85
- if (relative === "package.json" && manifest.spark?.dependencyPatch) {
86
- const original = JSON.parse(current);
87
- delete original.spark.dependencyPatch;
88
- delete original.spark.sdk;
89
- delete original.spark.requires;
90
- if (!Object.keys(original.spark).length) delete original.spark;
91
- current = JSON.stringify(original, null, 2) + "\n";
314
+ const bytes = source ? readPatch(source, pin) : fs.readFileSync(path.join(patchesRoot, pin.patch));
315
+ const own = appPatch(name, manifest.version);
316
+ const ownRoot = appRoot(name, packageRoot, manifest, own);
317
+ const enabled = !patchDisabled(root, name, file);
318
+ const keptSpark = path.join(packageRoot, ".spark-base.patch");
319
+ const appliedSpark = fs.existsSync(keptSpark) ? fs.readFileSync(keptSpark, "utf8") : undefined;
320
+ if (!enabled) warnOnce(`Spark's ${name} patch is disabled by spark.patches in package.json; desktop support for ${name} isn't guaranteed.`);
321
+ if (own?.thirdParty) warnOnce(`Spark applies its ${name} patch first, then ${own.file}.`);
322
+ layerApp(packageRoot, name,
323
+ { text: bytes.toString("utf8"), applied: appliedSpark, apply: enabled, error: relative => `Cannot apply Spark's ${name} patch to ${relative}. Reinstall dependencies before retrying.` },
324
+ own, relative => `Cannot apply ${own.file} to ${relative}${enabled ? " on top of Spark's patch" : ""}. Redo it with spark patch ${name}.`);
325
+ if (enabled) fs.writeFileSync(keptSpark, bytes);
326
+ else fs.rmSync(keptSpark, { force: true });
327
+ layered.add(name);
328
+ stamp(file, installed, manifest => {
329
+ if (name !== "react-native-nitro-modules" && !pin.optional) {
330
+ manifest.spark.sdk = true;
331
+ manifest.spark.requires = pin.requires ?? [];
92
332
  }
93
- if (applyPatch(current, reversePatch(patch)) !== false) continue;
94
- const next = applyPatch(current, patch);
95
- if (next === false) throw new Error(`Cannot apply Spark's ${name} patch to ${relative}. Reinstall dependencies before retrying.`);
96
- writes.push([target, next]);
97
- }
98
- // Verify every file before writing; rename rather than mutate package-manager cache hardlinks.
99
- for (const [target, next] of writes) {
100
- fs.mkdirSync(path.dirname(target), { recursive: true });
101
- const temporary = `${target}.spark-${process.pid}.tmp`;
102
- fs.writeFileSync(temporary, next); fs.renameSync(temporary, target);
103
- }
104
- const patched = JSON.parse(fs.readFileSync(file, "utf8"));
105
- patched.spark ??= {};
106
- if (name !== "react-native-nitro-modules") {
107
- patched.spark.sdk = true;
108
- patched.spark.requires = pin.requires ?? [];
109
- }
110
- patched.spark.dependencyPatch = { schema: 1, version: pin.version,
111
- patchHash: createHash("sha256").update(bytes).digest("hex"), upstreamIntegrity: pin.integrity };
112
- const pkg = installed.find(pkg => pkg.root === packageRoot);
113
- if (pkg) pkg.json = patched;
114
- const serialized = JSON.stringify(patched, null, 2) + "\n";
115
- if (fs.readFileSync(file, "utf8") !== serialized) {
116
- const temporary = `${file}.spark-${process.pid}.tmp`;
117
- fs.writeFileSync(temporary, serialized); fs.renameSync(temporary, file);
118
- }
333
+ manifest.spark.dependencyPatch = { schema: 1, version: pin.version, patchHash: enabled ? hash(bytes) : undefined,
334
+ appPatchHash: own && hash(own.bytes), appRoot: ownRoot, upstreamIntegrity: pin.integrity };
335
+ });
336
+ }
337
+ }
338
+ // App patches for libraries Spark doesn't patch apply alone; package managers own their own patches.
339
+ for (const [name, own] of Object.entries(ownPatches)) {
340
+ if (own.thirdParty || layered.has(name)) continue;
341
+ let file;
342
+ try { file = resolveManifest(appRequire, name); }
343
+ catch (error) {
344
+ if (error.code !== "MODULE_NOT_FOUND") throw error;
345
+ warnOnce(`${own.file} patches ${name}, which isn't installed.`);
346
+ continue;
119
347
  }
348
+ const manifest = readManifest(file), { version } = manifest, packageRoot = fs.realpathSync(path.dirname(file));
349
+ appPatch(name, version);
350
+ const ownRoot = appRoot(name, packageRoot, manifest, own);
351
+ layerApp(packageRoot, name, undefined, own, relative => `Cannot apply ${own.file} to ${relative}. Reinstall dependencies or redo it with spark patch ${name}.`);
352
+ stamp(file, installed, manifest => { manifest.spark.dependencyPatch = { schema: 1, version, appPatchHash: hash(own.bytes), appRoot: ownRoot }; });
353
+ }
354
+ // Undo app patches the app removed from libraries Spark doesn't patch.
355
+ for (const name of Object.keys({ ...app.dependencies, ...app.devDependencies })) {
356
+ if (ownPatches[name] || layered.has(name)) continue;
357
+ let file;
358
+ try { file = resolveManifest(appRequire, name); } catch { continue; }
359
+ if (!fs.existsSync(path.join(path.dirname(file), ".spark-app.patch"))) continue;
360
+ const packageRoot = fs.realpathSync(path.dirname(file));
361
+ appRoot(name, packageRoot, readManifest(file));
362
+ layerApp(packageRoot, name);
363
+ stamp(file, installed, manifest => {
364
+ delete manifest.spark.dependencyPatch;
365
+ if (!Object.keys(manifest.spark).length) delete manifest.spark;
366
+ });
120
367
  }
121
368
  for (const name of active) {
122
- if (!packages[name]) throw new Error(`Spark needs ${name}@${pins[name].version}. Finish installing dependencies before native preparation.`);
369
+ if (!packages[name] && !skipped.has(name) && !pins[name].optional && app.spark?.patches?.[name] !== false) throw new Error(`Spark needs ${name}@${pins[name].version}. Finish installing dependencies before native preparation.`);
123
370
  }
124
371
  return packages;
125
372
  }
@@ -138,4 +385,4 @@ function removeExpoApplicationAlias(rn, expo) {
138
385
  fs.renameSync(temporary, file); // Preserve package-manager cache hardlinks.
139
386
  }
140
387
 
141
- module.exports = { prepareNativePatches, removeExpoApplicationAlias };
388
+ module.exports = { appPatchIssues, prepareNativePatches, removeExpoApplicationAlias, appPatches, layerPatches, resolveManifest, withoutReceipt };
@@ -1,2 +1,9 @@
1
1
  export function prepareNativePatches(root: string, installed?: { name: string; root: string; json: any }[]): Record<string, { root: string }>;
2
2
  export function removeExpoApplicationAlias(reactNativeMacOSRoot: string, expoModulesCoreRoot: string): void;
3
+ export type AppPatch = { version?: string; file: string; thirdParty: boolean; error?: string; bytes: Buffer };
4
+ export function appPatches(root: string, app: any): Record<string, AppPatch>;
5
+ export type PatchLayer = { text: string; applied?: string; apply: boolean; error(relative: string): string } | undefined;
6
+ export function layerPatches(packageRoot: string, name: string, layers: PatchLayer[], options?: { dryRun?: boolean }): void;
7
+ export function resolveManifest(req: NodeJS.Require, name: string): string;
8
+ export function withoutReceipt(manifest: string): string;
9
+ export function appPatchIssues(root: string): string[];
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-desktop-config",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "license": "MIT",
5
5
  "main": "app.plugin.cjs",
6
6
  "files": [
@@ -11,8 +11,8 @@
11
11
  ],
12
12
  "dependencies": {
13
13
  "expo-desktop-config-plugins": "1.3.2",
14
- "@legendapp/spark-desktop-host": "0.0.2",
15
- "@legendapp/spark-window-options": "0.0.2",
14
+ "@legendapp/spark-desktop-host": "0.0.4",
15
+ "@legendapp/spark-window-options": "0.0.4",
16
16
  "@expo/config-plugins": "55.0.12",
17
17
  "diff": "8.0.4"
18
18
  },