@legendapp/spark 0.0.1-next.3 → 0.0.1-next.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 (161) hide show
  1. package/README.md +1 -1
  2. package/camera.ts +13 -0
  3. package/customize.ts +2 -0
  4. package/html.ts +1 -0
  5. package/markdown.ts +1 -0
  6. package/package.json +34 -15
  7. package/patches/camera/react-native-nitro-image.patch +320 -0
  8. package/patches/camera/react-native-nitro-modules.patch +50 -0
  9. package/patches/camera/react-native-vision-camera.patch +2662 -0
  10. package/patches/camera/upstream.json +22 -0
  11. package/patches/dependencies.json +14 -0
  12. package/patches/react-native-enriched-html@1.1.1.patch +854 -0
  13. package/patches/react-native-enriched-markdown@1.1.1.patch +9261 -0
  14. package/postinstall.cjs +1 -0
  15. package/schema.json +104 -0
  16. package/skills/spark/SKILL.md +56 -0
  17. package/skills/spark/UPGRADING.md +246 -0
  18. package/ui-swipe.ts +1 -0
  19. package/vendor/node_modules/@legendapp/spark-ai/package.json +4 -4
  20. package/vendor/node_modules/@legendapp/spark-ai/src/invocation-command.cjs +11 -0
  21. package/vendor/node_modules/@legendapp/spark-ai/src/invocation-command.d.cts +2 -0
  22. package/vendor/node_modules/@legendapp/spark-ai/src/invocations.ts +2 -19
  23. package/vendor/node_modules/@legendapp/spark-audio/package.json +3 -3
  24. package/vendor/node_modules/@legendapp/spark-auth-session/package.json +3 -3
  25. package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +4 -4
  26. package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +65 -11
  27. package/vendor/node_modules/@legendapp/spark-cli/dist/cli-arguments.js +2 -1
  28. package/vendor/node_modules/@legendapp/spark-cli/dist/commands.js +3 -2
  29. package/vendor/node_modules/@legendapp/spark-cli/dist/create.js +36 -13
  30. package/vendor/node_modules/@legendapp/spark-cli/dist/credentials.js +41 -26
  31. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-ai.cjs +108 -0
  32. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-artifacts.js +315 -0
  33. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-cli.cjs +75 -0
  34. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-github.cjs +133 -0
  35. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-policy.cjs +102 -0
  36. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-provider.cjs +2 -0
  37. package/vendor/node_modules/@legendapp/spark-cli/dist/customize-worker.cjs +273 -0
  38. package/vendor/node_modules/@legendapp/spark-cli/dist/dependency-pins.js +157 -0
  39. package/vendor/node_modules/@legendapp/spark-cli/dist/dev-command.js +3 -1
  40. package/vendor/node_modules/@legendapp/spark-cli/dist/dev.js +1 -1
  41. package/vendor/node_modules/@legendapp/spark-cli/dist/enriched-html-pins.js +128 -0
  42. package/vendor/node_modules/@legendapp/spark-cli/dist/errors.js +100 -0
  43. package/vendor/node_modules/@legendapp/spark-cli/dist/examples.js +1 -1
  44. package/vendor/node_modules/@legendapp/spark-cli/dist/expo-dev-patch.cjs +30 -1
  45. package/vendor/node_modules/@legendapp/spark-cli/dist/expo-native.cjs +5 -1
  46. package/vendor/node_modules/@legendapp/spark-cli/dist/helpers.js +1 -1
  47. package/vendor/node_modules/@legendapp/spark-cli/dist/index.js +52 -7
  48. package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.d.cts +1 -0
  49. package/vendor/node_modules/@legendapp/spark-cli/dist/js-runtime.cjs +96 -0
  50. package/vendor/node_modules/@legendapp/spark-cli/dist/json.js +16 -0
  51. package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.cjs +152 -0
  52. package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.d.cts +15 -0
  53. package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.cjs +184 -0
  54. package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.d.cts +16 -0
  55. package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +5 -1
  56. package/vendor/node_modules/@legendapp/spark-cli/dist/package-manager-config.js +41 -0
  57. package/vendor/node_modules/@legendapp/spark-cli/dist/package-manager.js +13 -0
  58. package/vendor/node_modules/@legendapp/spark-cli/dist/process.js +7 -0
  59. package/vendor/node_modules/@legendapp/spark-cli/dist/project-version.js +12 -0
  60. package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +66 -30
  61. package/vendor/node_modules/@legendapp/spark-cli/dist/release.js +2 -1
  62. package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +20 -20
  63. package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-bootstrap.ps1 +87 -0
  64. package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-bootstrap.sh +107 -0
  65. package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-downloads.tsv +13 -0
  66. package/vendor/node_modules/@legendapp/spark-cli/dist/sdk-install.js +8 -3
  67. package/vendor/node_modules/@legendapp/spark-cli/dist/universal.cjs +2 -1
  68. package/vendor/node_modules/@legendapp/spark-cli/dist/upgrade.js +102 -0
  69. package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +1 -8
  70. package/vendor/node_modules/@legendapp/spark-cli/package.json +6 -4
  71. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/.claude/skills/spark/SKILL.md +9 -0
  72. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/AGENTS.md +4 -0
  73. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/CLAUDE.md +4 -0
  74. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/README.md +15 -0
  75. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +47 -3
  76. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/.claude/skills/spark/SKILL.md +9 -0
  77. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/AGENTS.md +4 -0
  78. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/CLAUDE.md +4 -0
  79. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/README.md +15 -0
  80. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +46 -3
  81. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/.claude/skills/spark/SKILL.md +9 -0
  82. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/AGENTS.md +4 -0
  83. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/CLAUDE.md +4 -0
  84. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/README.md +15 -0
  85. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +47 -3
  86. package/vendor/node_modules/@legendapp/spark-clipboard/package.json +3 -3
  87. package/vendor/node_modules/@legendapp/spark-codex/package.json +4 -4
  88. package/vendor/node_modules/@legendapp/spark-commands/package.json +6 -6
  89. package/vendor/node_modules/@legendapp/spark-context-menu/package.json +3 -3
  90. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/RNDesktopApp.mm +14 -1
  91. package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +2 -2
  92. package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/menu.ts +6 -4
  93. package/vendor/node_modules/@legendapp/spark-desktop-app/src/customize-hooks.ts +17 -0
  94. package/vendor/node_modules/@legendapp/spark-desktop-app/src/customize.ts +117 -0
  95. package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.cjs +20 -1
  96. package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +5 -2
  97. package/vendor/node_modules/@legendapp/spark-desktop-config/config.d.cts +14 -0
  98. package/vendor/node_modules/@legendapp/spark-desktop-config/customize-provider.cjs +16 -0
  99. package/vendor/node_modules/@legendapp/spark-desktop-config/customize.cjs +16 -0
  100. package/vendor/node_modules/@legendapp/spark-desktop-config/expo.cjs +1 -0
  101. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs +106 -0
  102. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.d.cts +1 -0
  103. package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +5 -4
  104. package/vendor/node_modules/@legendapp/spark-desktop-config/schema.json +104 -0
  105. package/vendor/node_modules/@legendapp/spark-desktop-host/SparkCustomize.mm +517 -0
  106. package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +4 -3
  107. package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +3 -3
  108. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/RNDesktopShortcuts.mm +3 -1
  109. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/keyboard-manager/RNKeyboardManager.h +3 -0
  110. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/keyboard-manager/RNKeyboardManager.mm +1 -1
  111. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +3 -3
  112. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +44 -4
  113. package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +4 -4
  114. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/api.ts +65 -26
  115. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +8 -6
  116. package/vendor/node_modules/@legendapp/spark-documents/package.json +8 -8
  117. package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +3 -3
  118. package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +3 -3
  119. package/vendor/node_modules/@legendapp/spark-file-system/macos/SparkFileMutations.h +1 -0
  120. package/vendor/node_modules/@legendapp/spark-file-system/macos/SparkFileMutations.mm +11 -10
  121. package/vendor/node_modules/@legendapp/spark-file-system/package.json +3 -3
  122. package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +3 -3
  123. package/vendor/node_modules/@legendapp/spark-html/package.json +24 -0
  124. package/vendor/node_modules/@legendapp/spark-html/src/Html.tsx +22 -0
  125. package/vendor/node_modules/@legendapp/spark-html/src/HtmlInput.tsx +102 -0
  126. package/vendor/node_modules/@legendapp/spark-html/src/index.ts +4 -0
  127. package/vendor/node_modules/@legendapp/spark-html/src/types.ts +4 -0
  128. package/vendor/node_modules/@legendapp/spark-markdown/package.json +24 -0
  129. package/vendor/node_modules/@legendapp/spark-markdown/src/Markdown.tsx +24 -0
  130. package/vendor/node_modules/@legendapp/spark-markdown/src/MarkdownInput.tsx +111 -0
  131. package/vendor/node_modules/@legendapp/spark-markdown/src/index.ts +4 -0
  132. package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +3 -3
  133. package/vendor/node_modules/@legendapp/spark-native-menu/package.json +3 -3
  134. package/vendor/node_modules/@legendapp/spark-notifications/package.json +3 -3
  135. package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/SparkNotifications.h +16 -11
  136. package/vendor/node_modules/@legendapp/spark-processes/package.json +3 -3
  137. package/vendor/node_modules/@legendapp/spark-rich-text/package.json +18 -0
  138. package/vendor/node_modules/@legendapp/spark-rich-text/src/components.tsx +52 -0
  139. package/vendor/node_modules/@legendapp/spark-rich-text/src/index.ts +4 -0
  140. package/vendor/node_modules/@legendapp/spark-rich-text/src/types.ts +24 -0
  141. package/vendor/node_modules/@legendapp/spark-rich-text/src/useInputShortcuts.macos.ts +55 -0
  142. package/vendor/node_modules/@legendapp/spark-rich-text/src/useInputShortcuts.ts +13 -0
  143. package/vendor/node_modules/@legendapp/spark-rich-text/src/useInputValue.ts +14 -0
  144. package/vendor/node_modules/@legendapp/spark-rich-text/src/value.ts +16 -0
  145. package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +3 -3
  146. package/vendor/node_modules/@legendapp/spark-settings/package.json +3 -3
  147. package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +5 -5
  148. package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
  149. package/vendor/node_modules/@legendapp/spark-system/package.json +3 -3
  150. package/vendor/node_modules/@legendapp/spark-tray/package.json +3 -3
  151. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +360 -35
  152. package/vendor/node_modules/@legendapp/spark-ui/macos/swipe-actions/RNSwipeActions.h +10 -0
  153. package/vendor/node_modules/@legendapp/spark-ui/macos/swipe-actions/RNSwipeActions.mm +422 -0
  154. package/vendor/node_modules/@legendapp/spark-ui/package.json +4 -3
  155. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +11 -0
  156. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +30 -13
  157. package/vendor/node_modules/@legendapp/spark-ui/src/swipe-actions/SwipeActionsNativeComponent.ts +11 -0
  158. package/vendor/node_modules/@legendapp/spark-ui/src/swipe-actions/index.tsx +41 -0
  159. package/vendor/node_modules/@legendapp/spark-updates/package.json +3 -3
  160. package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
  161. package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
@@ -0,0 +1,9 @@
1
+ ---
2
+ name: spark
3
+ description: Develop, build, diagnose, or upgrade a Legend Spark desktop app.
4
+ ---
5
+
6
+ <!-- spark:skill:start -->
7
+ From the app root, read [Spark's app development skill](node_modules/@legendapp/spark/skills/spark/SKILL.md) before working on this app.
8
+ The installed Spark version owns these instructions; do not copy them here.
9
+ <!-- spark:skill:end -->
@@ -0,0 +1,4 @@
1
+ <!-- spark:skill:start -->
2
+ From the app root, read [Spark's app development skill](node_modules/@legendapp/spark/skills/spark/SKILL.md) before working on this app.
3
+ The installed Spark version owns these instructions; do not copy them here.
4
+ <!-- spark:skill:end -->
@@ -0,0 +1,4 @@
1
+ <!-- spark:skill:start -->
2
+ From the app root, read [Spark's app development skill](node_modules/@legendapp/spark/skills/spark/SKILL.md) before working on this app.
3
+ The installed Spark version owns these instructions; do not copy them here.
4
+ <!-- spark:skill:end -->
@@ -0,0 +1,15 @@
1
+ # Spark app
2
+
3
+ Run the app with `windows` using your chosen package manager:
4
+
5
+ ```sh
6
+ npm run windows
7
+ ```
8
+
9
+ macOS opens in Spark Runner. Windows requires a custom development build and is
10
+ an unverified preview. JavaScript edits use Fast Refresh. Use `npm run build` for
11
+ a standalone macOS app; native builds require Xcode and CocoaPods.
12
+
13
+ Use the equivalent `bun run`, `pnpm run`, or `yarn` commands for those managers.
14
+ See [Spark documentation](https://legend.so/spark) for configuration, upgrades,
15
+ platform prerequisites, and distribution.
@@ -20,6 +20,7 @@
20
20
  "expo-desktop-metro-config": "54.81.0",
21
21
  "expo-desktop-template-bare-minimum": "54.81.1",
22
22
  "react": "19.1.4",
23
+ "react-dom": "19.1.4",
23
24
  "react-native": "0.81.6",
24
25
  "@react-native-community/cli": "20.1.3",
25
26
  "typescript": "5.9.3",
@@ -27,11 +28,11 @@
27
28
  "react-native-windows": "0.81.35",
28
29
  "expo-desktop-modules-core": "54.0.14",
29
30
  "expo-desktop-stubs": "54.0.14",
30
- "@legendapp/spark": "0.0.1-next.3"
31
+ "@legendapp/spark": "0.0.1-next.5"
31
32
  },
32
33
  "overrides": {
33
34
  "@expo/cli": "54.0.27",
34
- "react-native-nitro-modules": "0.35.7",
35
+ "react-native-nitro-modules": "0.37.0",
35
36
  "react-native-webview": "16.0.0",
36
37
  "@op-engineering/op-sqlite": "18.2.1",
37
38
  "expo-asset": "12.0.13",
@@ -45,14 +46,57 @@
45
46
  "react": "19.1.4",
46
47
  "react-native": "0.81.6",
47
48
  "react-native-macos": "0.81.7",
48
- "react-native-windows": "0.81.35"
49
+ "react-native-windows": "0.81.35",
50
+ "postcss": "8.5.31",
51
+ "dompurify": "3.4.17",
52
+ "@tiptap/core": "3.32.0",
53
+ "@tiptap/extension-blockquote": "3.32.0",
54
+ "@tiptap/extension-bold": "3.32.0",
55
+ "@tiptap/extension-code": "3.32.0",
56
+ "@tiptap/extension-document": "3.32.0",
57
+ "@tiptap/extension-heading": "3.32.0",
58
+ "@tiptap/extension-history": "3.32.0",
59
+ "@tiptap/extension-image": "3.32.0",
60
+ "@tiptap/extension-italic": "3.32.0",
61
+ "@tiptap/extension-link": "3.32.0",
62
+ "@tiptap/extension-list": "3.32.0",
63
+ "@tiptap/extension-paragraph": "3.32.0",
64
+ "@tiptap/extension-strike": "3.32.0",
65
+ "@tiptap/extension-text": "3.32.0",
66
+ "@tiptap/extension-text-align": "3.32.0",
67
+ "@tiptap/extension-underline": "3.32.0",
68
+ "@tiptap/extensions": "3.32.0",
69
+ "@tiptap/pm": "3.32.0",
70
+ "@tiptap/react": "3.32.0",
71
+ "@tiptap/extension-bubble-menu": "3.32.0",
72
+ "@tiptap/extension-floating-menu": "3.32.0",
73
+ "fast-xml-parser": "5.11.2",
74
+ "react-dom": "19.1.4"
49
75
  },
50
76
  "expo": {
51
77
  "install": {
52
78
  "exclude": [
53
79
  "react",
80
+ "react-dom",
54
81
  "react-native"
55
82
  ]
56
83
  }
84
+ },
85
+ "allowScripts": {
86
+ "@legendapp/spark": true,
87
+ "react-native-enriched-markdown": true,
88
+ "fsevents": true
89
+ },
90
+ "trustedDependencies": [
91
+ "@legendapp/spark",
92
+ "react-native-enriched-markdown",
93
+ "fsevents"
94
+ ],
95
+ "pnpm": {
96
+ "onlyBuiltDependencies": [
97
+ "@legendapp/spark",
98
+ "react-native-enriched-markdown",
99
+ "fsevents"
100
+ ]
57
101
  }
58
102
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-clipboard",
3
- "version": "0.0.1-next.3",
3
+ "version": "0.0.1-next.5",
4
4
  "license": "MIT",
5
5
  "main": "src/index",
6
6
  "react-native": "src/index",
@@ -12,7 +12,7 @@
12
12
  "windows"
13
13
  ],
14
14
  "peerDependencies": {
15
- "react": "19.1.4",
15
+ "react": "^19.1.0",
16
16
  "react-native": "0.81.6",
17
17
  "expo-clipboard": "~8.0.8"
18
18
  },
@@ -41,7 +41,7 @@
41
41
  ]
42
42
  },
43
43
  "dependencies": {
44
- "@legendapp/spark-desktop-app": "0.0.1-next.3"
44
+ "@legendapp/spark-desktop-app": "0.0.1-next.5"
45
45
  },
46
46
  "peerDependenciesMeta": {
47
47
  "expo-clipboard": {
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@legendapp/spark-codex",
3
- "version": "0.0.1-next.3",
3
+ "version": "0.0.1-next.5",
4
4
  "private": true,
5
5
  "main": "src/index.ts",
6
6
  "react-native": "src/index.ts",
7
7
  "peerDependencies": {
8
- "react": "19.1.4",
8
+ "react": "^19.1.0",
9
9
  "react-native": "0.81.6"
10
10
  },
11
11
  "license": "MIT",
12
12
  "dependencies": {
13
- "@legendapp/spark-desktop-app": "0.0.1-next.3",
14
- "react-native-nitro-modules": "0.35.7"
13
+ "@legendapp/spark-desktop-app": "0.0.1-next.5",
14
+ "react-native-nitro-modules": "0.37.0"
15
15
  },
16
16
  "files": [
17
17
  "src",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-commands",
3
- "version": "0.0.1-next.3",
3
+ "version": "0.0.1-next.5",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "main": "src/index.tsx",
@@ -8,14 +8,14 @@
8
8
  "src"
9
9
  ],
10
10
  "dependencies": {
11
- "@legendapp/spark-ui": "0.0.1-next.3",
12
- "@legendapp/spark-desktop-shortcuts": "0.0.1-next.3",
13
- "@legendapp/spark-settings": "0.0.1-next.3",
11
+ "@legendapp/spark-ui": "0.0.1-next.5",
12
+ "@legendapp/spark-desktop-shortcuts": "0.0.1-next.5",
13
+ "@legendapp/spark-settings": "0.0.1-next.5",
14
14
  "@legendapp/state": "^3.0.0-beta.42",
15
- "@legendapp/spark-desktop-app": "0.0.1-next.3"
15
+ "@legendapp/spark-desktop-app": "0.0.1-next.5"
16
16
  },
17
17
  "peerDependencies": {
18
- "react": "19.1.4",
18
+ "react": "^19.1.0",
19
19
  "react-native": "0.81.6"
20
20
  }
21
21
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-context-menu",
3
- "version": "0.0.1-next.3",
3
+ "version": "0.0.1-next.5",
4
4
  "license": "MIT",
5
5
  "main": "src/index.ts",
6
6
  "react-native": "src/index.ts",
@@ -12,7 +12,7 @@
12
12
  "react-native.config.js"
13
13
  ],
14
14
  "peerDependencies": {
15
- "react": "19.1.4",
15
+ "react": "^19.1.0",
16
16
  "react-native": "0.81.6"
17
17
  },
18
18
  "codegenConfig": {
@@ -41,7 +41,7 @@
41
41
  ]
42
42
  },
43
43
  "dependencies": {
44
- "@legendapp/spark-desktop-app": "0.0.1-next.3"
44
+ "@legendapp/spark-desktop-app": "0.0.1-next.5"
45
45
  },
46
46
  "private": true
47
47
  }
@@ -13,7 +13,20 @@ RCT_EXPORT_MODULE(NativeDesktopApp)
13
13
  - (void)call:(NSString *)method args:(NSString *)json resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
14
14
  dispatch_async(dispatch_get_main_queue(), ^{
15
15
  NSDictionary *args = SparkArgs(json);
16
- if ([method isEqual:@"context"]) resolve(SparkJSON(SparkContext()));
16
+ if ([method hasPrefix:@"customize."]) {
17
+ // Only opted-in hosts register this handler; keep the desktop module small.
18
+ __block BOOL handled = NO;
19
+ void (^claim)(void) = ^{ handled = YES; };
20
+ void (^reply)(NSString *, NSString *, NSString *) = ^(NSString *value, NSString *code, NSString *message) {
21
+ if (code) reject(code, message, nil); else resolve(value ?: @"null");
22
+ };
23
+ [NSNotificationCenter.defaultCenter postNotificationName:@"SparkCustomizeCall" object:nil userInfo:@{@"method":[method substringFromIndex:10], @"args":args, @"claim":claim, @"reply":reply}];
24
+ if (!handled) {
25
+ if ([method isEqual:@"customize.state"]) resolve(SparkJSON(@{@"enabled":@NO,@"busy":@NO,@"phase":@"idle",@"message":@"Customization is not enabled in this app",@"ready":@NO,@"customized":@NO,@"previewing":@NO,@"migrationAvailable":@NO}));
26
+ else reject(@"E_UNAVAILABLE", @"Customization is not enabled in this app", nil);
27
+ }
28
+ }
29
+ else if ([method isEqual:@"context"]) resolve(SparkJSON(SparkContext()));
17
30
  else if ([method isEqual:@"initialURL"]) resolve(SparkJSON(SparkInitialURL()));
18
31
  else if ([method isEqual:@"pendingURLs"]) resolve(SparkJSON(SparkPendingURLs()));
19
32
  else if ([method isEqual:@"quit"]) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-desktop-app",
3
- "version": "0.0.1-next.3",
3
+ "version": "0.0.1-next.5",
4
4
  "license": "MIT",
5
5
  "main": "src/index",
6
6
  "react-native": "src/index",
@@ -12,7 +12,7 @@
12
12
  "cpp"
13
13
  ],
14
14
  "peerDependencies": {
15
- "react": "19.1.4",
15
+ "react": "^19.1.0",
16
16
  "react-native": "0.81.6"
17
17
  },
18
18
  "codegenConfig": {
@@ -11,6 +11,7 @@ export type MenuItem =
11
11
  | { type: "separator" }
12
12
  | (MenuEntry & { type: "action"; shortcut?: string })
13
13
  | (MenuEntry & { type: "checkbox"; checked: boolean; shortcut?: string })
14
+ | (MenuEntry & { type: "radio"; checked: boolean; shortcut?: string })
14
15
  | (MenuEntry & { type: "submenu"; items: readonly MenuItem[] })
15
16
  | (Omit<MenuEntry, "label"> & { type: "role"; role: MenuRole; label?: string; shortcut?: string })
16
17
  | (MenuEntry & { type: "slider"; min: number; max: number; value: number; suffix?: string });
@@ -20,7 +21,7 @@ export type MenuItemTree<Leaf extends Exclude<MenuItem, { type: "submenu" }>> =
20
21
  /** Internal transport shape; never reexported from feature entry points. */
21
22
  export interface MenuWireItem {
22
23
  id?: string; title?: string; target?: MenuTarget; placement?: MenuPlacement; _sparkOwner?: string; _sparkIdentity?: string; enabled?: boolean; hidden?: boolean; checked?: boolean; separator?: boolean;
23
- shortcut?: Accelerator; items?: MenuWireItem[]; role?: MenuRole;
24
+ shortcut?: Accelerator; items?: MenuWireItem[]; role?: MenuRole; radio?: boolean;
24
25
  systemImageName?: string; imagePath?: string; slider?: { min: number; max: number; value: number; suffix?: string };
25
26
  }
26
27
  export interface MenuSupport { types: readonly MenuItem["type"][]; shortcuts?: boolean; icons?: readonly MenuIcon["type"][]; targeting?: boolean }
@@ -43,7 +44,7 @@ export function menuItems(input: readonly MenuItem[], support: MenuSupport, plat
43
44
  if (typeof item.id !== "string" || !item.id.length || item.id.length > 200 || item.id.includes("\0") || ids.has(item.id)) throw new SparkError("E_INVALID_ARGUMENT", "Menu item ids must be nonempty and unique");
44
45
  ids.add(item.id);
45
46
  const common = ["type", "id", "label", "disabled", "hidden", "icon", "target", "placement"];
46
- keys(item, [...common, ...(item.type === "submenu" ? ["items"] : item.type === "slider" ? ["min", "max", "value", "suffix"] : item.type === "role" ? ["role", "shortcut"] : item.type === "checkbox" ? ["checked", "shortcut"] : ["shortcut"])]);
47
+ keys(item, [...common, ...(item.type === "submenu" ? ["items"] : item.type === "slider" ? ["min", "max", "value", "suffix"] : item.type === "role" ? ["role", "shortcut"] : item.type === "checkbox" || item.type === "radio" ? ["checked", "shortcut"] : ["shortcut"])]);
47
48
  if ((item.type !== "role" || item.label !== undefined) && (typeof item.label !== "string" || !item.label.trim())) throw new SparkError("E_INVALID_ARGUMENT", "Menu items need a label");
48
49
  if ([item.disabled, item.hidden].some(value => value !== undefined && typeof value !== "boolean")) throw new SparkError("E_INVALID_ARGUMENT", "Menu flags must be boolean");
49
50
  const result: MenuWireItem = { id: item.id, title: item.label, enabled: !item.disabled };
@@ -57,9 +58,10 @@ export function menuItems(input: readonly MenuItem[], support: MenuSupport, plat
57
58
  result.placement = item.placement.before !== undefined ? { before: menuTarget(item.placement.before) } : { after: menuTarget(item.placement.after!) };
58
59
  }
59
60
  }
60
- if (item.type === "checkbox") {
61
- if (typeof item.checked !== "boolean") throw new SparkError("E_INVALID_ARGUMENT", "Checkbox menus require checked state");
61
+ if (item.type === "checkbox" || item.type === "radio") {
62
+ if (typeof item.checked !== "boolean") throw new SparkError("E_INVALID_ARGUMENT", "Checkbox and radio menus require checked state");
62
63
  result.checked = item.checked;
64
+ if (item.type === "radio") result.radio = true;
63
65
  }
64
66
  if (item.type === "submenu") result.items = visit(item.items, depth + 1);
65
67
  if (item.type === "role") {
@@ -0,0 +1,17 @@
1
+ import { useEffect, useState } from "react";
2
+ import { getCustomizeState, onCustomizeState, type CustomizeState } from "./customize";
3
+
4
+ export type CustomizeHookState = { status: "loading" } | { status: "ready"; state: CustomizeState } | { status: "error"; error: unknown };
5
+ /** Observes the app-owned customization session. Unmount removes observation, never cancels an operation. */
6
+ export function useCustomizeState(): CustomizeHookState {
7
+ const [current, setCurrent] = useState<CustomizeHookState>({ status: "loading" });
8
+ useEffect(() => {
9
+ let active = true, receivedEvent = false;
10
+ try {
11
+ const subscription = onCustomizeState(state => { receivedEvent = true; setCurrent({ status: "ready", state }); });
12
+ getCustomizeState().then(state => { if (active && !receivedEvent) setCurrent({ status: "ready", state }); }, error => { if (active && !receivedEvent) setCurrent({ status: "error", error }); });
13
+ return () => { active = false; subscription.remove(); };
14
+ } catch (error) { setCurrent({ status: "error", error }); }
15
+ }, []);
16
+ return current;
17
+ }
@@ -0,0 +1,117 @@
1
+ import { Platform, TurboModuleRegistry } from "react-native";
2
+ import type { Spec } from "./NativeDesktopApp";
3
+ import { SparkError, invokeNative, parseNativeResult } from "./contracts";
4
+ import { onDesktopEvent } from "./events";
5
+
6
+ export type CustomizeProvider =
7
+ | { kind: "cli"; tool: "codex" | "claude"; model?: string }
8
+ | { kind: "local"; endpoint: string; model: string }
9
+ | { kind: "remote"; endpoint: string; model: string; apiKey?: string };
10
+ export type CustomizePhase = "idle" | "preparing" | "generating" | "migrating" | "previewing" | "applying" | "authenticating" | "submitting" | "error";
11
+ export type CustomizeState = {
12
+ enabled: boolean;
13
+ busy: boolean;
14
+ phase: CustomizePhase;
15
+ message: string;
16
+ ready: boolean;
17
+ customized: boolean;
18
+ previewing: boolean;
19
+ migrationAvailable: boolean;
20
+ githubAuthenticated?: boolean;
21
+ repository?: string;
22
+ provider?: Exclude<CustomizeProvider, { kind: "remote" }> | { kind: "remote"; endpoint: string; model: string };
23
+ };
24
+ export type CustomizePromptOptions = {
25
+ provider?: CustomizeProvider;
26
+ /** Required for CLI and remote providers. Explain what source/context is shared. */
27
+ allowSourceSharing?: boolean;
28
+ migration?: boolean;
29
+ };
30
+ export type CustomizeResult = { candidate: string; summary: string; changedFiles: string[]; status: "needs-review" };
31
+ export type CustomizePrompt = { id?: string; prompt: string; baseRelease?: string; created?: string; model?: string; provider?: string; providerKind?: "cli" | "local" | "remote"; status?: string; summary?: string; error?: string };
32
+ export type CustomizeReview = { text: string; prompts: CustomizePrompt[]; candidate?: string };
33
+ export type CustomizeMigrationResult = { candidate?: string; from?: string; conflicts: string[]; status: "none" | "needs-review" };
34
+ export type CustomizeSubscription = { remove(): void };
35
+ export type CustomizeGitHubAuthorization = { userCode: string; verificationUri: string; expiresIn: number };
36
+ export type CustomizePullRequestOptions = { title: string };
37
+ export type CustomizePullRequest = { url: string; number: number; repository: string; branch: string };
38
+
39
+ const disabled: CustomizeState = { enabled: false, busy: false, phase: "idle", message: "Customization is not enabled in this app", ready: false, customized: false, previewing: false, migrationAvailable: false };
40
+ function native() {
41
+ return Platform.OS === "macos" ? TurboModuleRegistry.get<Spec>("NativeDesktopApp") : null;
42
+ }
43
+ function record(value: unknown): value is Record<string, unknown> { return !!value && typeof value === "object" && !Array.isArray(value); }
44
+ function options(value: unknown, allowed: string[]): asserts value is Record<string, unknown> {
45
+ if (!record(value)) throw new SparkError("E_INVALID_ARGUMENT", "Customize options must be an object");
46
+ if (Object.keys(value).some(key => !allowed.includes(key))) throw new SparkError("E_UNSUPPORTED_OPTION", "Unknown customize option");
47
+ }
48
+ function provider(value: unknown): asserts value is CustomizeProvider {
49
+ if (!record(value)) throw new SparkError("E_INVALID_ARGUMENT", "Invalid customize provider");
50
+ options(value, value.kind === "cli" ? ["kind", "tool", "model"] : ["kind", "endpoint", "model", "apiKey"]);
51
+ const valid = value.kind === "cli"
52
+ ? ["codex", "claude"].includes(value.tool as string) && (value.model === undefined || (typeof value.model === "string" && !!value.model))
53
+ : ["local", "remote"].includes(value.kind as string) && typeof value.endpoint === "string" && typeof value.model === "string" && !!value.model && (value.apiKey === undefined || (value.kind === "remote" && typeof value.apiKey === "string"));
54
+ if (!valid) throw new SparkError("E_INVALID_ARGUMENT", "Invalid customize provider");
55
+ }
56
+ function state(value: unknown): value is CustomizeState {
57
+ return record(value) && ["enabled", "busy", "ready", "customized", "previewing", "migrationAvailable"].every(key => typeof value[key] === "boolean")
58
+ && ["idle", "preparing", "generating", "migrating", "previewing", "applying", "authenticating", "submitting", "error"].includes(value.phase as string) && typeof value.message === "string";
59
+ }
60
+ const strings = (value: unknown): value is string[] => Array.isArray(value) && value.every(item => typeof item === "string");
61
+ const validators: Record<string, (value: unknown) => boolean> = {
62
+ state,
63
+ prompt: value => record(value) && typeof value.candidate === "string" && typeof value.summary === "string" && strings(value.changedFiles) && value.status === "needs-review",
64
+ review: value => record(value) && typeof value.text === "string" && Array.isArray(value.prompts) && value.prompts.every(item => record(item) && typeof item.prompt === "string") && (value.candidate === undefined || typeof value.candidate === "string"),
65
+ migrate: value => record(value) && ["none", "needs-review"].includes(value.status as string) && strings(value.conflicts),
66
+ githubBegin: value => record(value) && typeof value.userCode === "string" && value.userCode.length > 0 && value.verificationUri === "https://github.com/login/device" && typeof value.expiresIn === "number" && value.expiresIn > 0,
67
+ submitPR: value => record(value) && typeof value.url === "string" && /^https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/pull\/\d+$/.test(value.url) && Number.isSafeInteger(value.number) && typeof value.repository === "string" && typeof value.branch === "string",
68
+ };
69
+ async function call<T>(method: string, args: object = {}): Promise<T> {
70
+ const module = native();
71
+ if (!module) throw new SparkError(Platform.OS === "macos" ? "E_MODULE_UNAVAILABLE" : "E_UNSUPPORTED_PLATFORM", "Customize requires a Spark macOS app");
72
+ const validate = validators[method] ?? (value => value === null);
73
+ const value = parseNativeResult(await invokeNative(() => module.call(`customize.${method}`, JSON.stringify(args))), (value): value is T => validate(value));
74
+ return value === null ? undefined as T : value;
75
+ }
76
+ /** Availability is safe on unsupported platforms and in apps that did not opt in. */
77
+ export async function getCustomizeState(): Promise<CustomizeState> {
78
+ return native() ? call<CustomizeState>("state") : { ...disabled };
79
+ }
80
+ /** Opens Spark's built-in editor, including when automatic entry points are disabled. */
81
+ export const showEditor = (): Promise<void> => call("show");
82
+ /** Saves provider settings; remote keys go to Keychain and are never returned in state. */
83
+ export async function configureCustomize(value: CustomizeProvider): Promise<void> { provider(value); return call("configure", { provider: value }); }
84
+ export async function generateEdit(prompt: string, value: CustomizePromptOptions = {}): Promise<CustomizeResult> {
85
+ if (typeof prompt !== "string" || !prompt.trim() || prompt.length > 32000) throw new SparkError("E_INVALID_ARGUMENT", "Enter a prompt of at most 32000 characters");
86
+ options(value, ["provider", "allowSourceSharing", "migration"]);
87
+ if (value.provider !== undefined) provider(value.provider);
88
+ for (const key of ["allowSourceSharing", "migration"] as const) if (value[key] !== undefined && typeof value[key] !== "boolean") throw new SparkError("E_INVALID_ARGUMENT", `${key} must be boolean`);
89
+ return call("prompt", { prompt, ...value });
90
+ }
91
+ export const getEditReview = (): Promise<CustomizeReview> => call("review");
92
+ /** Performs a three-way merge; conflicts can be resolved with generateEdit(..., { migration: true }). */
93
+ export const prepareEditMigration = (): Promise<CustomizeMigrationResult> => call("migrate");
94
+ /** Reloads the current app/data with the candidate for this session. */
95
+ export const previewEdit = (): Promise<void> => call("preview");
96
+ /** Accepts the candidate and reloads. The app owns its confirmation/save-work UI. */
97
+ export const applyEdit = (): Promise<void> => call("apply");
98
+ export const restoreOriginal = (): Promise<void> => call("original");
99
+ /** Stops current customization work. Partial candidates and prompt history are retained. */
100
+ export const cancelEdit = (): Promise<void> => call("cancel");
101
+ /** Starts GitHub's device flow; client ID comes from the developer's customize config. */
102
+ export const beginCustomizeGitHubAuth = (): Promise<CustomizeGitHubAuthorization> => call("githubBegin");
103
+ /** Waits for device authorization. The token stays in the app's macOS Keychain. cancelEdit stops waiting. */
104
+ export const completeCustomizeGitHubAuth = (): Promise<void> => call("githubComplete");
105
+ export const signOutCustomizeGitHub = (): Promise<void> => call("githubSignOut");
106
+ /** Publishes the reviewed candidate's cumulative patch and saved prompts to customize.repository. */
107
+ export async function submitEditPullRequest(value: CustomizePullRequestOptions): Promise<CustomizePullRequest> {
108
+ options(value, ["title"]);
109
+ if (typeof value.title !== "string" || !value.title.trim() || value.title.length > 256) throw new SparkError("E_INVALID_ARGUMENT", "Enter a PR title of at most 256 characters");
110
+ return call("submitPR", value);
111
+ }
112
+ /** Live events only: subscribe before requesting getCustomizeState() for an initial snapshot. */
113
+ export function onCustomizeState(listener: (state: CustomizeState) => void): CustomizeSubscription {
114
+ if (typeof listener !== "function") throw new SparkError("E_INVALID_ARGUMENT", "Customize state listener must be a function");
115
+ if (!native()) return { remove() {} };
116
+ return onDesktopEvent(event => { if (state(event.state)) listener(event.state); }, { types: ["customizeState"] });
117
+ }
@@ -6,6 +6,7 @@ const {
6
6
  withPodfile,
7
7
  withInfoPlist,
8
8
  withEntitlementsPlist,
9
+ withXcodeProject,
9
10
  } = require("expo-desktop-config-plugins");
10
11
  const { identity } = require("./identity.cjs");
11
12
  const { resolveEntitlements } = require("./entitlements.cjs");
@@ -15,6 +16,12 @@ module.exports = function withSparkDesktop(config) {
15
16
  if (config.platforms?.length === 1 && config.platforms[0] === "windows") return require("./windows.plugin.cjs")(config);
16
17
  // The upstream base mod merges template entitlements into config before
17
18
  // callbacks run. Capture the declared values before that mutation.
19
+ const customize = require("./customize.cjs").validateCustomize(config.extra?.spark?.customize);
20
+ if (customize && config.macos?.entitlements?.["com.apple.security.app-sandbox"]) throw new Error("Customizable apps require direct distribution without App Sandbox");
21
+ if (customize) config = withXcodeProject(config, mod => {
22
+ if (!mod.modResults.hasFile("Security.framework")) mod.modResults.addFramework("Security.framework", { target: mod.modResults.getFirstTarget().uuid });
23
+ return mod;
24
+ });
18
25
  const declaredEntitlements = structuredClone(config.macos?.entitlements ?? {});
19
26
  config = withEntitlementsPlist(config, (mod) => {
20
27
  const selection = statePath(mod.modRequest.projectRoot, "native-selection.json", "macos");
@@ -28,7 +35,19 @@ module.exports = function withSparkDesktop(config) {
28
35
  });
29
36
  config = withAppDelegate(config, (mod) => {
30
37
  // Own this adapter; application customizations belong in configuration/plugins.
31
- mod.modResults.contents = fs.readFileSync(require.resolve("@legendapp/spark-desktop-host/AppDelegate.mm"), "utf8");
38
+ mod.modResults.contents = fs.readFileSync(
39
+ require.resolve("@legendapp/spark-desktop-host/AppDelegate.mm"),
40
+ "utf8",
41
+ );
42
+ if (customize) {
43
+ const native = fs.readFileSync(require.resolve("@legendapp/spark-desktop-host/SparkCustomize.mm"), "utf8");
44
+ mod.modResults.contents = '#import <React/RCTReloadCommand.h>\n' + native + '\n' + mod.modResults.contents
45
+ .replace(' SparkMarkLaunchComplete();', ` SparkCustomizeStart();
46
+ [NSNotificationCenter.defaultCenter addObserverForName:@"SparkCustomizeReload" object:nil queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification *note) { RCTTriggerReloadCommandListeners(@"Spark customization"); }];
47
+ SparkMarkLaunchComplete();`)
48
+ .replace('return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];', 'return SparkCustomizeBundleURL();')
49
+ .replace('return SparkDockMenu;', 'return SparkCustomizeDockMenu(SparkDockMenu);');
50
+ }
32
51
  return mod;
33
52
  });
34
53
  config = withInfoPlist(config, (mod) => {
@@ -69,6 +69,7 @@ function developmentConfig(value, target) {
69
69
  return result;
70
70
  }
71
71
  function expoConfig(root) {
72
+ require("./native-patches.cjs").prepareNativePatches(root);
72
73
  if (process.env.SPARK_DEV_SESSION === "1") {
73
74
  return developmentConfig(JSON.parse(fs.readFileSync(path.join(root, filename), "utf8")), process.env.SPARK_PLATFORM);
74
75
  }
@@ -87,7 +88,7 @@ function applySelection(root, expo) {
87
88
  }
88
89
  function toExpo(value, target) {
89
90
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Desktop config must be an object");
90
- const allowed = ["$schema", "name", "projectId", "version", "window", "macos", "platforms", "scheme", "documentTypes", "menuBarOnly", "updates", "include", "signing", "helpers", "expo", "expoByPlatform"];
91
+ const allowed = ["$schema", "name", "projectId", "version", "window", "macos", "platforms", "scheme", "documentTypes", "menuBarOnly", "updates", "include", "signing", "helpers", "customize", "expo", "expoByPlatform"];
91
92
  for (const key of Object.keys(value)) if (!allowed.includes(key)) throw new Error(`Unknown desktop configuration field: ${key}`);
92
93
  for (const key of ["name", "projectId", "version"]) if (typeof value[key] !== "string" || !value[key].trim()) throw new Error(`Desktop config needs ${key}`);
93
94
  const platforms = value.platforms ?? ["macos"];
@@ -98,8 +99,9 @@ function toExpo(value, target) {
98
99
  validateWindow(value.window ?? {});
99
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");
100
101
  require("./helpers.cjs").validateHelpers(value.helpers);
102
+ require("./customize.cjs").validateCustomize(value.customize);
101
103
  const extra = { projectId: value.projectId };
102
- for (const key of ["window", "documentTypes", "menuBarOnly", "updates", "include", "signing", "helpers"]) if (value[key] !== undefined) extra[key] = value[key];
104
+ for (const key of ["window", "documentTypes", "menuBarOnly", "updates", "include", "signing", "helpers", "customize"]) if (value[key] !== undefined) extra[key] = value[key];
103
105
  const overrides = value.expoByPlatform ?? {};
104
106
  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");
105
107
  const backend = merge(value.expo ?? {}, overrides[selected] ?? {});
@@ -137,6 +139,7 @@ function merge(base, override) {
137
139
  // Expo tools read this generated transport file. All framework consumers resolve
138
140
  // the canonical source; the generated file is never edited by SDK commands.
139
141
  function prepareConfig(root) {
142
+ require("./native-patches.cjs").prepareNativePatches(root);
140
143
  if (isExpoProject(root)) return readConfig(root);
141
144
  if (isUniversal(root)) {
142
145
  const file = path.join(root, "app.config.js");
@@ -17,6 +17,19 @@ export interface MacOSConfiguration {
17
17
  export interface SigningConfiguration {
18
18
  macos?: { identity?: string; teamId?: string; entitlementsByPath?: Record<string, Record<string, JsonValue>> };
19
19
  }
20
+ export type CustomizeProvider = { kind: 'cli'; tool: 'codex' | 'claude'; model?: string } | { kind: 'local' | 'remote'; endpoint: string; model: string };
21
+ export interface CustomizeConfiguration {
22
+ repository: string;
23
+ tag?: string;
24
+ /** Source snapshot root, relative to and an ancestor of the app project. files are relative to this root. */
25
+ sourceRoot?: string;
26
+ files: string[];
27
+ githubClientId?: string;
28
+ toolkitRepository?: string;
29
+ toolkitTag?: string;
30
+ ui?: 'default' | 'custom';
31
+ provider?: CustomizeProvider;
32
+ }
20
33
  /** Spark-owned settings carried inside Expo's extra.spark. */
21
34
  export interface SparkSettings {
22
35
  projectId: string;
@@ -27,6 +40,7 @@ export interface SparkSettings {
27
40
  include?: string[];
28
41
  signing?: SigningConfiguration;
29
42
  helpers?: Record<string, HelperConfiguration>;
43
+ customize?: false | CustomizeConfiguration;
30
44
  supportedPlatforms?: SparkPlatform[];
31
45
  }
32
46
  /** Expo retains ownership of its configuration; Spark only adds desktop fields. */
@@ -0,0 +1,16 @@
1
+ // Shared by release configuration and the downloaded customize worker.
2
+ function validateProvider(value) {
3
+ if (value?.kind === 'cli') {
4
+ if (!['codex', 'claude'].includes(value.tool) || (value.model !== undefined && (typeof value.model !== 'string' || (!value.model.trim() || /[\0\r\n]/.test(value.model)))) || Object.keys(value).some(key => !['kind', 'tool', 'model'].includes(key))) throw new Error('CLI customize provider requires codex or claude and an optional model');
5
+ return { kind: 'cli', tool: value.tool, ...(value.model ? { model: value.model } : {}) };
6
+ }
7
+ if (!value || !['local', 'remote'].includes(value.kind) || typeof value.model !== 'string' || (!value.model.trim() || /[\0\r\n]/.test(value.model))) throw new Error('Customize provider requires kind, endpoint and model');
8
+ if (Object.keys(value).some(key => !['kind', 'endpoint', 'model'].includes(key))) throw new Error('Unknown customize provider option; never publish API keys');
9
+ const url = new URL(value.endpoint);
10
+ const loopback = ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);
11
+ if (url.username || url.password || url.search || url.hash || (value.kind === 'local' ? !loopback || !['http:', 'https:'].includes(url.protocol) : url.protocol !== 'https:')) throw new Error('Remote customization requires HTTPS; local customization requires a loopback HTTP(S) endpoint without credentials, query or fragment');
12
+ // Do not resolve localhost through DNS or a modified hosts file.
13
+ if (value.kind === 'local' && url.hostname === 'localhost') url.hostname = '127.0.0.1';
14
+ return { kind: value.kind, endpoint: url.href, model: value.model };
15
+ }
16
+ module.exports = { validateProvider };
@@ -0,0 +1,16 @@
1
+ const path = require('node:path');
2
+ function validateCustomize(value) {
3
+ if (value === undefined || value === false) return undefined;
4
+ if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('customize must be false or an object');
5
+ const allowed = ['repository', 'tag', 'files', 'sourceRoot', 'githubClientId', 'toolkitRepository', 'toolkitTag', 'ui', 'provider'];
6
+ for (const key of Object.keys(value)) if (!allowed.includes(key)) throw new Error(`Unknown customize option: ${key}`);
7
+ for (const key of ['repository', 'toolkitRepository']) if ((key === 'repository' || value[key] !== undefined) && !/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(value[key] ?? '')) throw new Error(`customize.${key} must be owner/repository`);
8
+ for (const key of ['tag', 'toolkitTag']) if (value[key] !== undefined && !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(value[key])) throw new Error(`customize.${key} must be a fixed release tag`);
9
+ if (!Array.isArray(value.files) || !value.files.length || value.files.some(file => typeof file !== 'string' || !file || path.isAbsolute(file) || file.split(/[\\/]/).some(part => !part || part === '..' || (part.startsWith('.') && !/^\.babelrc(?:\.[cm]?js|\.json)?$/.test(part)) || ['node_modules', 'macos', 'ios', 'android', 'windows'].includes(part)))) throw new Error('customize.files must explicitly list relative source files/directories, without hidden files or native projects');
10
+ if (value.sourceRoot !== undefined && (typeof value.sourceRoot !== 'string' || !value.sourceRoot || path.isAbsolute(value.sourceRoot) || value.sourceRoot.includes('\\') || value.sourceRoot.split('/').some(part => !part || (part !== '.' && part !== '..')))) throw new Error('customize.sourceRoot must be a relative ancestor of the app project (for example ../..)');
11
+ if (value.githubClientId !== undefined && (typeof value.githubClientId !== 'string' || !/^[A-Za-z0-9_]+$/.test(value.githubClientId))) throw new Error('customize.githubClientId must be a GitHub OAuth app client ID');
12
+ if (value.ui !== undefined && !['default', 'custom'].includes(value.ui)) throw new Error('customize.ui must be default or custom');
13
+ if (value.provider !== undefined) require('./customize-provider.cjs').validateProvider(value.provider);
14
+ return value;
15
+ }
16
+ module.exports = { validateCustomize };
@@ -5,6 +5,7 @@ const path = require('node:path');
5
5
  // Only an explicitly selected desktop command applies the Spark overlay.
6
6
  function withSparkExpo(original, root) {
7
7
  return context => {
8
+ require('./native-patches.cjs').prepareNativePatches(root);
8
9
  const base = typeof original === 'function' ? original(context) : original;
9
10
  const target = process.env.SPARK_PLATFORM;
10
11
  const development = process.env.SPARK_DEV_SESSION === '1';