@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.
- package/init-template.cjs +7 -1
- package/package.json +10 -5
- package/patches/dependencies.json +252 -0
- package/patches/expo-application@55.0.19.patch +54 -0
- package/patches/expo-blur@55.0.18.patch +130 -0
- package/patches/expo-device@55.0.21.patch +149 -0
- package/patches/expo-font@55.0.8.patch +55 -0
- package/patches/expo-glass-effect@55.0.11.patch +304 -0
- package/patches/expo-haptics@55.0.18.patch +54 -0
- package/patches/expo-image-manipulator@55.0.21.patch +312 -0
- package/patches/expo-image-picker@55.0.24.patch +327 -0
- package/patches/expo-image@55.0.11.patch +158 -0
- package/patches/expo-keep-awake@55.0.8.patch +41 -0
- package/patches/expo-localization@55.0.19.patch +32 -0
- package/patches/expo-location@55.1.15.patch +190 -0
- package/patches/expo-symbols@55.0.9.patch +286 -0
- package/patches/expo-system-ui@55.0.22.patch +61 -0
- package/patches/expo-web-browser@55.0.20.patch +13 -0
- package/patches/react-native-app-logs@0.3.1.patch +20 -0
- package/patches/react-native-blurhash@2.1.3.patch +318 -0
- package/patches/react-native-community-blur@4.4.1.patch +415 -0
- package/patches/react-native-community-datetimepicker@9.2.2.patch +320 -0
- package/patches/react-native-fast-image@10.9.9.patch +131 -0
- package/patches/react-native-graph@1.4.0.patch +157 -0
- package/patches/react-native-keyboard-controller@1.22.9.patch +16 -0
- package/patches/react-native-masked-view-masked-view@0.3.2.patch +140 -0
- package/patches/react-native-mmkv@4.3.2.patch +40 -0
- package/patches/react-native-nitro-fetch@1.9.0.patch +130 -0
- package/patches/react-native-nitro-zxing@0.3.0.patch +13 -0
- package/patches/react-native-nitro-zxing@0.3.1.patch +22 -0
- package/patches/react-native-quick-base64@3.0.1.patch +13 -0
- package/patches/react-native-quick-crypto@1.1.9.patch +31 -0
- package/patches/react-native-release-profiler@0.4.5.patch +37 -0
- package/patches/react-native-screen-corner-radius@0.2.3.patch +13 -0
- package/patches/react-native-screens@4.23.0.patch +160 -0
- package/patches/react-native-svg@15.15.3.patch +31 -0
- package/patches/react-native-unistyles@3.6.0.patch +203 -0
- package/patches/react-native-worklets-core@1.6.3.patch +13 -0
- package/patches/react-navigation-native-stack@7.21.0.patch +16 -0
- package/patches/registry.json +615 -0
- package/patches/sentry-react-native@8.32.0.patch +76 -0
- package/patches/workspace/expo-audio@55.0.18.patch +159 -0
- package/patches/workspace/op-engineering-op-sqlite@18.2.1.patch +796 -0
- package/patches/workspace/react-native-nitro-modules@0.37.0.patch +1348 -0
- package/patches/workspace/react-native-runtimes-core@0.1.0-alpha.2.patch +276 -0
- package/patches/workspace/react-native-webview@16.0.0.patch +208 -0
- package/postinstall.cjs +10 -1
- package/skills/spark/SKILL.md +37 -4
- package/skills/spark/UPGRADING.md +150 -1
- package/skills/spark/ai-customize.md +39 -0
- package/skills/spark/app-and-documents.md +56 -0
- package/skills/spark/external-libraries.md +87 -0
- package/skills/spark/files.md +64 -0
- package/skills/spark/integrations.md +69 -0
- package/skills/spark/keyboard.md +54 -0
- package/skills/spark/library-compat.md +76 -0
- package/skills/spark/menus-tray-dock.md +83 -0
- package/skills/spark/storage-settings.md +85 -0
- package/skills/spark/ui.md +57 -0
- package/skills/spark/windows.md +91 -0
- package/ui-popover.ts +1 -0
- package/ui-progress.ts +1 -0
- package/ui-sheet.ts +1 -0
- package/ui-split-view.ts +1 -0
- package/ui-table.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-ai/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-audio/package.json +3 -13
- package/vendor/node_modules/@legendapp/spark-auth-session/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +5 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +139 -104
- package/vendor/node_modules/@legendapp/spark-cli/dist/cli-arguments.js +4 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/commands.js +16 -7
- package/vendor/node_modules/@legendapp/spark-cli/dist/dependency-pins.js +19 -3
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev-command.js +2 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev.js +10 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/enriched-html-pins.js +2 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/errors.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/index.js +57 -9
- package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.cjs +12 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.d.cts +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/metro.cjs +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/migrate.js +65 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.cjs +4 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.d.cts +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.cjs +15 -8
- package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +35 -7
- package/vendor/node_modules/@legendapp/spark-cli/dist/patch.js +92 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/project-version.js +12 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +20 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +20 -20
- package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-input-cache.js +140 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/upgrade.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +3 -0
- package/vendor/node_modules/@legendapp/spark-cli/package.json +5 -4
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-clipboard/macos/RNDesktopClipboard.mm +1 -1
- package/vendor/node_modules/@legendapp/spark-clipboard/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-clipboard/src/desktop.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-codex/package.json +3 -7
- package/vendor/node_modules/@legendapp/spark-commands/package.json +5 -5
- package/vendor/node_modules/@legendapp/spark-context-menu/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.h +3 -1
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +51 -10
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.h +4 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.mm +82 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.mm +64 -2
- package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +2 -8
- package/vendor/node_modules/@legendapp/spark-desktop-config/autolinking.cjs +3 -2
- package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +6 -8
- package/vendor/node_modules/@legendapp/spark-desktop-config/identity.cjs +2 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs +315 -68
- package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.d.cts +7 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.cjs +318 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.d.cts +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/validation.cjs +66 -9
- package/vendor/node_modules/@legendapp/spark-desktop-config/windows.plugin.cjs +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.mm +7 -2
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +235 -240
- package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +4 -11
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/api.ts +9 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +7 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/types.ts +32 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/validation.ts +28 -11
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/createWindowsNavigator.tsx +15 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/primaryWindowLifecycle.ts +12 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/usePrimaryWindowLifecycle.ts +2 -1
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/useWindowFocusEffect.ts +4 -1
- package/vendor/node_modules/@legendapp/spark-documents/package.json +7 -7
- package/vendor/node_modules/@legendapp/spark-drag-drop/macos/RNDesktopDragView.mm +77 -17
- package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +3 -8
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/DesktopDragViewNativeComponent.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/contracts.ts +13 -4
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/index.tsx +5 -3
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.h +6 -1
- package/vendor/node_modules/@legendapp/spark-expo-compat/metro.cjs +44 -0
- package/vendor/node_modules/@legendapp/spark-expo-compat/package.json +20 -0
- package/vendor/node_modules/@legendapp/spark-expo-compat/src/clipboard.ts +40 -0
- package/vendor/node_modules/@legendapp/spark-expo-compat/src/document-picker.ts +52 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/options.ts +5 -2
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/types.ts +3 -3
- package/vendor/node_modules/@legendapp/spark-file-system/macos/RNDesktopFileSystem.mm +1 -1
- package/vendor/node_modules/@legendapp/spark-file-system/package.json +3 -11
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-html/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-markdown/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-message-dialog/src/index.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-native-menu/package.json +3 -9
- package/vendor/node_modules/@legendapp/spark-native-menu/src/hooks.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-notifications/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-processes/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-rich-text/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-settings/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +4 -4
- package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-system/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-tray/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-tray/src/index.ts +2 -1
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.mm +82 -14
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.h +1 -1
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.mm +94 -11
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +235 -18
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.h +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.mm +216 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.h +4 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.mm +212 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewUpdates.h +6 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +26 -13
- package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.mm +126 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.mm +66 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.mm +118 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.mm +4 -12
- package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.mm +109 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +418 -102
- package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.mm +179 -0
- package/vendor/node_modules/@legendapp/spark-ui/package.json +9 -8
- package/vendor/node_modules/@legendapp/spark-ui/src/SparkButtonNativeComponent.ts +10 -2
- package/vendor/node_modules/@legendapp/spark-ui/src/SparkTextInputNativeComponent.ts +2 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitView.tsx +99 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitViewNativeComponent.ts +29 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +34 -17
- package/vendor/node_modules/@legendapp/spark-ui/src/availability.ts +5 -4
- package/vendor/node_modules/@legendapp/spark-ui/src/checkbox-unavailable.tsx +20 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/control.ts +24 -3
- package/vendor/node_modules/@legendapp/spark-ui/src/desktop.tsx +63 -13
- package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +12 -7
- package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +12 -7
- package/vendor/node_modules/@legendapp/spark-ui/src/index.web.tsx +35 -13
- package/vendor/node_modules/@legendapp/spark-ui/src/mobile-input.tsx +2 -2
- package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSegmentedControlNativeComponent.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-ui/src/popover/PopoverNativeComponent.ts +20 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/popover/index.tsx +45 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/progress/ProgressIndicatorNativeComponent.ts +13 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/progress/index.tsx +32 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/radio-group/RadioGroupNativeComponent.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sheet/SheetNativeComponent.ts +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sheet/index.tsx +38 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarItemNativeComponent.ts +9 -1
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarNativeComponent.ts +17 -2
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/index.tsx +106 -22
- package/vendor/node_modules/@legendapp/spark-ui/src/table/TableNativeComponent.ts +22 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/table/index.tsx +118 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/types.ts +39 -6
- package/vendor/node_modules/@legendapp/spark-ui/uniwind.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-ui/uniwind.web.ts +2 -1
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.h +46 -15
- package/vendor/node_modules/@legendapp/spark-updates/package.json +3 -9
- package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ensurePatchRegistry } from "@legendapp/spark-desktop-config/patch-registry.cjs";
|
|
1
2
|
import { restoreNativeMetadata } from "./native-metadata.js";
|
|
2
3
|
import { assertNativePatchPreflight } from "./native-patch-preflight.js";
|
|
3
4
|
import { missingNativeFrameworks, preparationChanges, preserveMacOSPods } from "./native-preparation.js";
|
|
@@ -8,13 +9,14 @@ import { macOSXcodeArchitecture, projectPlatform } from "./platform.js";
|
|
|
8
9
|
import { isUniversal, isExpoProject } from "@legendapp/spark-desktop-config/config.cjs";
|
|
9
10
|
import { buildWindows } from "./windows.js";
|
|
10
11
|
import { copyHelpers } from "./helpers.js";
|
|
11
|
-
import { readAppConfig } from "./project.js";
|
|
12
|
+
import { lacksMacOSPod, readAppConfig } from "./project.js";
|
|
12
13
|
import { cpSync, existsSync, mkdirSync, readFileSync, realpathSync, readdirSync, rmSync, writeFileSync, openSync, closeSync, } from "node:fs";
|
|
13
14
|
import path from "node:path";
|
|
14
15
|
import { registerRuntime } from "./local.js";
|
|
15
16
|
import { binary, doctor, run } from "./commands.js";
|
|
16
17
|
import { prepareConfig, entryFile, digest, hashFiles, nativePreparationInputs, nativeProjectFingerprint, localSigningIdentity, nativePackages, readJson, runtimeFor, selection, stateFile, writeJson, validateBuildModules, goConfigurationIssues, } from "./project.js";
|
|
17
18
|
export async function analyze(root) {
|
|
19
|
+
await ensurePatchRegistry(root);
|
|
18
20
|
assertNativePatchPreflight(root);
|
|
19
21
|
if (projectPlatform(root) === "windows")
|
|
20
22
|
throw new Error("Windows production analysis is not implemented; use spark build --dev.");
|
|
@@ -140,6 +142,29 @@ export function warnExampleBundleId(config) {
|
|
|
140
142
|
console.warn(`Warning: the bundle ID is still the placeholder ${id}. Change bundleIdentifier in desktop.config.json to an ID you own before you distribute this app.`);
|
|
141
143
|
}
|
|
142
144
|
export async function build(root, mode, force = false) {
|
|
145
|
+
return withBuildLock(root, async () => {
|
|
146
|
+
const result = await buildUnlocked(root, mode, force);
|
|
147
|
+
if (mode === "go") {
|
|
148
|
+
registerRuntime(result.app);
|
|
149
|
+
console.log("Spark Runner registered. Apps will discover it automatically.");
|
|
150
|
+
}
|
|
151
|
+
return result;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
export async function prebuild(root) {
|
|
155
|
+
if (projectPlatform(root) !== "macos")
|
|
156
|
+
throw new Error("macOS preparation requires --platform macos.");
|
|
157
|
+
await withBuildLock(root, async () => {
|
|
158
|
+
prepareConfig(root);
|
|
159
|
+
await doctor(root, { nativeBuild: false });
|
|
160
|
+
const chosen = { included: nativePackages(root), excluded: [] };
|
|
161
|
+
validateBuildModules("dev", chosen.included);
|
|
162
|
+
await prepareMacOS(root, chosen, false);
|
|
163
|
+
console.log("macOS native project and CocoaPods dependencies are ready.");
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
async function withBuildLock(root, action) {
|
|
167
|
+
await ensurePatchRegistry(root);
|
|
143
168
|
assertNativePatchPreflight(root);
|
|
144
169
|
const lock = stateFile(root, "build.lock");
|
|
145
170
|
mkdirSync(path.dirname(lock), { recursive: true });
|
|
@@ -153,25 +178,20 @@ export async function build(root, mode, force = false) {
|
|
|
153
178
|
throw error;
|
|
154
179
|
const pid = Number(readFileSync(lock, "utf8"));
|
|
155
180
|
if (!Number.isInteger(pid) || pid <= 0)
|
|
156
|
-
throw new Error(`Invalid build lock: ${lock}. Check for an active build before removing it.`);
|
|
181
|
+
throw new Error(`Invalid build lock: ${lock}. Check for an active build or prebuild before removing it.`);
|
|
157
182
|
try {
|
|
158
183
|
process.kill(pid, 0);
|
|
159
184
|
}
|
|
160
185
|
catch (signalError) {
|
|
161
186
|
if (signalError.code === "ESRCH") {
|
|
162
187
|
rmSync(lock);
|
|
163
|
-
return
|
|
188
|
+
return withBuildLock(root, action);
|
|
164
189
|
}
|
|
165
190
|
}
|
|
166
|
-
throw new Error(`Another build owns this project (PID ${pid}). Wait for it to finish.`);
|
|
191
|
+
throw new Error(`Another build or prebuild owns this project (PID ${pid}). Wait for it to finish.`);
|
|
167
192
|
}
|
|
168
193
|
try {
|
|
169
|
-
|
|
170
|
-
if (mode === "go") {
|
|
171
|
-
registerRuntime(result.app);
|
|
172
|
-
console.log("Spark Runner registered. Apps will discover it automatically.");
|
|
173
|
-
}
|
|
174
|
-
return result;
|
|
194
|
+
return await action();
|
|
175
195
|
}
|
|
176
196
|
finally {
|
|
177
197
|
rmSync(lock, { force: true });
|
|
@@ -201,41 +221,7 @@ async function buildUnlocked(root, mode, force) {
|
|
|
201
221
|
if (productionHash)
|
|
202
222
|
runtime.fingerprint = digest(runtime.fingerprint + productionHash);
|
|
203
223
|
const resultFile = stateFile(root, `${mode}-build.json`);
|
|
204
|
-
|
|
205
|
-
const excludedNames = [...new Set([
|
|
206
|
-
"react-native-windows",
|
|
207
|
-
...(readAppConfig(root).expo.autolinking?.exclude ?? []),
|
|
208
|
-
...chosen.excluded.map((p) => p.name),
|
|
209
|
-
])];
|
|
210
|
-
writeJson(stateFile(root, "native-selection.json"), {
|
|
211
|
-
excluded: excludedNames,
|
|
212
|
-
included: chosen.included.map((p) => ({ name: p.name, root: p.root })),
|
|
213
|
-
});
|
|
214
|
-
const rnConfig = path.join(root, "react-native.config.js");
|
|
215
|
-
const marker = "// Generated by spark; extend with configuration plugins.";
|
|
216
|
-
if (!isUniversal(root) && (existsSync(rnConfig) &&
|
|
217
|
-
!readFileSync(rnConfig, "utf8").startsWith(marker) &&
|
|
218
|
-
!(isExpoProject(root) && readFileSync(rnConfig, "utf8").includes("// spark: existing Expo project"))))
|
|
219
|
-
throw new Error("Existing react-native.config.js is not spark-managed. Compose the native selection explicitly before building.");
|
|
220
|
-
if (!isUniversal(root))
|
|
221
|
-
writeFileSync(rnConfig, `${marker}\nconst selection = require('./.spark/native-selection.json');\nmodule.exports = { dependencies: Object.fromEntries([\n...selection.included.map(p => [p.name, { root: p.root }]),\n...selection.excluded.map(name => [name, { platforms: { ios: null, macos: null, android: null } }])\n]) };\n`);
|
|
222
|
-
const pkg = readJson(path.join(root, "package.json"));
|
|
223
|
-
if (!isUniversal(root)) {
|
|
224
|
-
pkg.expo ??= {};
|
|
225
|
-
pkg.expo.autolinking ??= {};
|
|
226
|
-
pkg.expo.autolinking.exclude = excludedNames;
|
|
227
|
-
writeJson(path.join(root, "package.json"), pkg);
|
|
228
|
-
}
|
|
229
|
-
const inputs = nativePreparationInputs(root, chosen.included);
|
|
230
|
-
const preparation = { fingerprint: digest(JSON.stringify(inputs)), inputs, projectFingerprint: nativeProjectFingerprint(inputs, chosen.included) };
|
|
231
|
-
const preparedFile = stateFile(root, "native-preparation.json");
|
|
232
|
-
const prepared = existsSync(preparedFile) ? readJson(preparedFile) : undefined;
|
|
233
|
-
const nativeRoot = path.join(root, "macos");
|
|
234
|
-
const hasNativeProject = existsSync(nativeRoot) && readdirSync(nativeRoot).some(name => name.endsWith(".xcodeproj") && existsSync(path.join(nativeRoot, name, "project.pbxproj")));
|
|
235
|
-
const needsProject = force || !hasNativeProject || prepared?.projectFingerprint !== preparation.projectFingerprint;
|
|
236
|
-
const needsPreparation = needsProject ||
|
|
237
|
-
prepared?.fingerprint !== preparation.fingerprint ||
|
|
238
|
-
!existsSync(path.join(root, "macos/Pods/Manifest.lock"));
|
|
224
|
+
const { preparation, nativeConfig, nativeRoot, workspace } = await prepareMacOS(root, chosen, force);
|
|
239
225
|
const existing = existsSync(resultFile) ? readJson(resultFile) : undefined;
|
|
240
226
|
if (!force && existing) {
|
|
241
227
|
if (existing.runtime.fingerprint === runtime.fingerprint &&
|
|
@@ -253,65 +239,6 @@ async function buildUnlocked(root, mode, force) {
|
|
|
253
239
|
...(existing.product !== path.basename(existing.app) ? ["cached app product is unverified"] : []),
|
|
254
240
|
];
|
|
255
241
|
console.log(`Building ${mode} runtime: ${reasons.join("; ")}.`);
|
|
256
|
-
const nativeConfig = readAppConfig(root).expo;
|
|
257
|
-
if (needsPreparation)
|
|
258
|
-
rmSync(preparedFile, { force: true });
|
|
259
|
-
if (needsProject) {
|
|
260
|
-
console.log(`Preparing native project (preserving CocoaPods cache): ${force ? "forced build" : !hasNativeProject ? "native project missing" : preparationChanges(prepared, preparation).join("; ") || "native project provenance missing"}.`);
|
|
261
|
-
const manifest = readFileSync(path.join(root, "package.json"), "utf8");
|
|
262
|
-
const appJson = path.join(root, "app.json");
|
|
263
|
-
const originalAppJson = existsSync(appJson) ? readFileSync(appJson, "utf8") : undefined;
|
|
264
|
-
try {
|
|
265
|
-
await preserveMacOSPods(root, () => run(root, [
|
|
266
|
-
binary(root, "expo-desktop"),
|
|
267
|
-
"prebuild",
|
|
268
|
-
"--platform",
|
|
269
|
-
"macos",
|
|
270
|
-
"--template",
|
|
271
|
-
"expo-desktop-template-bare-minimum@55.83.10",
|
|
272
|
-
"--no-install",
|
|
273
|
-
// Template renaming is not idempotent (HelloWorld becomes
|
|
274
|
-
// LegendHelloWorld, then LegendLegendHelloWorld). Native projects
|
|
275
|
-
// are generated output; recreate them only when project inputs change.
|
|
276
|
-
"--clean",
|
|
277
|
-
], { env: { CI: "1" }, label: "Generating native project" }));
|
|
278
|
-
// Expo Desktop copies all-platform template dependencies even for macOS. Preserve this
|
|
279
|
-
// platform's installed manifest instead of silently adding uninstalled Windows packages.
|
|
280
|
-
}
|
|
281
|
-
finally {
|
|
282
|
-
writeFileSync(path.join(root, "package.json"), manifest);
|
|
283
|
-
// Upstream template replacement also rewrites app.json substrings.
|
|
284
|
-
if (originalAppJson !== undefined)
|
|
285
|
-
writeFileSync(appJson, originalAppJson);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
if (needsPreparation) {
|
|
289
|
-
// ReactCodegen's source glob must not pick up bindings from a previously larger graph.
|
|
290
|
-
rmSync(path.join(root, "macos/build/generated"), {
|
|
291
|
-
recursive: true,
|
|
292
|
-
force: true,
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
const missing = missingNativeFrameworks(root);
|
|
296
|
-
if (needsPreparation || missing.length) {
|
|
297
|
-
if (needsPreparation && !needsProject)
|
|
298
|
-
console.log(`Updating CocoaPods dependencies: ${prepared?.fingerprint !== preparation.fingerprint ? preparationChanges(prepared, preparation).join("; ") : "CocoaPods state missing"}.`);
|
|
299
|
-
if (missing.length && !needsPreparation)
|
|
300
|
-
console.log(`Restoring missing native frameworks:\n${missing.join("\n")}`);
|
|
301
|
-
await run(root, ["pod", "install"], {
|
|
302
|
-
cwd: path.join(root, "macos"),
|
|
303
|
-
env: { RCT_NEW_ARCH_ENABLED: "1" },
|
|
304
|
-
label: "Installing CocoaPods dependencies",
|
|
305
|
-
});
|
|
306
|
-
const remaining = missingNativeFrameworks(root);
|
|
307
|
-
if (remaining.length)
|
|
308
|
-
throw new Error(`Native frameworks are missing after pod install. Restore the package's native artifacts and retry:\n${remaining.join("\n")}`);
|
|
309
|
-
writeJson(preparedFile, preparation);
|
|
310
|
-
}
|
|
311
|
-
await restoreNativeMetadata(root, nativeConfig);
|
|
312
|
-
const workspace = readdirSync(nativeRoot).find((name) => name.endsWith(".xcworkspace"));
|
|
313
|
-
if (!workspace)
|
|
314
|
-
throw new Error("Prebuild did not produce a macOS workspace.");
|
|
315
242
|
const name = workspace.slice(0, -".xcworkspace".length);
|
|
316
243
|
const configuration = mode === "release" ? "Release" : "Debug";
|
|
317
244
|
const xcodeArch = macOSXcodeArchitecture(runtime.arch);
|
|
@@ -386,3 +313,111 @@ async function buildUnlocked(root, mode, force) {
|
|
|
386
313
|
console.log(`Built ${destination}`);
|
|
387
314
|
return result;
|
|
388
315
|
}
|
|
316
|
+
async function prepareMacOS(root, chosen, force) {
|
|
317
|
+
// RNW's CLI config probes for PowerShell when Expo autolinking loads it on macOS.
|
|
318
|
+
const excludedNames = [...new Set([
|
|
319
|
+
"react-native-windows",
|
|
320
|
+
...(readAppConfig(root).expo.autolinking?.exclude ?? []),
|
|
321
|
+
...chosen.excluded.map((p) => p.name),
|
|
322
|
+
])];
|
|
323
|
+
// Only the macOS Podfile drops these; iOS and Android builds reading the shared config keep them.
|
|
324
|
+
const withoutMacOSPod = chosen.included.filter(lacksMacOSPod).map((p) => p.name).filter((name) => !excludedNames.includes(name));
|
|
325
|
+
writeJson(stateFile(root, "native-selection.json"), {
|
|
326
|
+
excluded: [...excludedNames, ...withoutMacOSPod],
|
|
327
|
+
withoutMacOSPod,
|
|
328
|
+
included: chosen.included.map((p) => ({ name: p.name, root: p.root })),
|
|
329
|
+
});
|
|
330
|
+
const rnConfig = path.join(root, "react-native.config.js");
|
|
331
|
+
const marker = "// Generated by spark; extend with configuration plugins.";
|
|
332
|
+
if (!isUniversal(root) && (existsSync(rnConfig) &&
|
|
333
|
+
!readFileSync(rnConfig, "utf8").startsWith(marker) &&
|
|
334
|
+
!(isExpoProject(root) && readFileSync(rnConfig, "utf8").includes("// spark: existing Expo project"))))
|
|
335
|
+
throw new Error("Existing react-native.config.js is not spark-managed. Compose the native selection explicitly before building.");
|
|
336
|
+
if (!isUniversal(root))
|
|
337
|
+
writeFileSync(rnConfig, `${marker}\nconst selection = require('./.spark/native-selection.json');\nmodule.exports = { dependencies: Object.fromEntries([\n...selection.included.map(p => [p.name, { root: p.root }]),\n...selection.excluded.map(name => [name, { platforms: selection.withoutMacOSPod.includes(name) ? { macos: null } : { ios: null, macos: null, android: null } }])\n]) };\n`);
|
|
338
|
+
const pkg = readJson(path.join(root, "package.json"));
|
|
339
|
+
if (!isUniversal(root)) {
|
|
340
|
+
pkg.expo ??= {};
|
|
341
|
+
pkg.expo.autolinking ??= {};
|
|
342
|
+
pkg.expo.autolinking.exclude = excludedNames;
|
|
343
|
+
writeJson(path.join(root, "package.json"), pkg);
|
|
344
|
+
}
|
|
345
|
+
const currentPreparation = () => {
|
|
346
|
+
const inputs = nativePreparationInputs(root, chosen.included);
|
|
347
|
+
return { fingerprint: digest(JSON.stringify(inputs)), inputs, projectFingerprint: nativeProjectFingerprint(inputs, chosen.included) };
|
|
348
|
+
};
|
|
349
|
+
let preparation = currentPreparation();
|
|
350
|
+
const preparedFile = stateFile(root, "native-preparation.json");
|
|
351
|
+
const prepared = existsSync(preparedFile) ? readJson(preparedFile) : undefined;
|
|
352
|
+
const nativeRoot = path.join(root, "macos");
|
|
353
|
+
const hasNativeProject = existsSync(nativeRoot) && readdirSync(nativeRoot).some(name => name.endsWith(".xcodeproj") && existsSync(path.join(nativeRoot, name, "project.pbxproj")));
|
|
354
|
+
const needsProject = force || !hasNativeProject || prepared?.projectFingerprint !== preparation.projectFingerprint;
|
|
355
|
+
const needsPreparation = needsProject ||
|
|
356
|
+
prepared?.fingerprint !== preparation.fingerprint ||
|
|
357
|
+
!existsSync(path.join(nativeRoot, "Podfile.lock")) ||
|
|
358
|
+
!existsSync(path.join(nativeRoot, "Pods/Manifest.lock")) ||
|
|
359
|
+
readFileSync(path.join(nativeRoot, "Podfile.lock"), "utf8") !== readFileSync(path.join(nativeRoot, "Pods/Manifest.lock"), "utf8");
|
|
360
|
+
const nativeConfig = readAppConfig(root).expo;
|
|
361
|
+
const missing = needsProject ? [] : missingNativeFrameworks(root);
|
|
362
|
+
if (needsPreparation || missing.length)
|
|
363
|
+
rmSync(preparedFile, { force: true });
|
|
364
|
+
if (needsProject) {
|
|
365
|
+
console.log(`Preparing native project (preserving CocoaPods cache): ${force ? "forced build" : !hasNativeProject ? "native project missing" : preparationChanges(prepared, preparation).join("; ") || "native project provenance missing"}.`);
|
|
366
|
+
const manifest = readFileSync(path.join(root, "package.json"), "utf8");
|
|
367
|
+
const appJson = path.join(root, "app.json");
|
|
368
|
+
const originalAppJson = existsSync(appJson) ? readFileSync(appJson, "utf8") : undefined;
|
|
369
|
+
try {
|
|
370
|
+
await preserveMacOSPods(root, () => run(root, [
|
|
371
|
+
binary(root, "expo-desktop"),
|
|
372
|
+
"prebuild",
|
|
373
|
+
"--platform",
|
|
374
|
+
"macos",
|
|
375
|
+
"--template",
|
|
376
|
+
"expo-desktop-template-bare-minimum@55.83.10",
|
|
377
|
+
"--no-install",
|
|
378
|
+
// Template renaming is not idempotent (HelloWorld becomes
|
|
379
|
+
// LegendHelloWorld, then LegendLegendHelloWorld). Native projects
|
|
380
|
+
// are generated output; recreate them only when project inputs change.
|
|
381
|
+
"--clean",
|
|
382
|
+
], { env: { CI: "1" }, label: "Generating native project" }));
|
|
383
|
+
// Expo Desktop copies all-platform template dependencies even for macOS. Preserve this
|
|
384
|
+
// platform's installed manifest instead of silently adding uninstalled Windows packages.
|
|
385
|
+
}
|
|
386
|
+
finally {
|
|
387
|
+
writeFileSync(path.join(root, "package.json"), manifest);
|
|
388
|
+
// Upstream template replacement also rewrites app.json substrings.
|
|
389
|
+
if (originalAppJson !== undefined)
|
|
390
|
+
writeFileSync(appJson, originalAppJson);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (needsPreparation) {
|
|
394
|
+
// ReactCodegen's source glob must not pick up bindings from a previously larger graph.
|
|
395
|
+
rmSync(path.join(root, "macos/build/generated"), {
|
|
396
|
+
recursive: true,
|
|
397
|
+
force: true,
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
if (needsPreparation || missing.length) {
|
|
401
|
+
if (needsPreparation && !needsProject)
|
|
402
|
+
console.log(`Updating CocoaPods dependencies: ${prepared?.fingerprint !== preparation.fingerprint ? preparationChanges(prepared, preparation).join("; ") : "CocoaPods state missing or stale"}.`);
|
|
403
|
+
if (missing.length && !needsPreparation)
|
|
404
|
+
console.log(`Restoring missing native frameworks:\n${missing.join("\n")}`);
|
|
405
|
+
await run(root, ["pod", "install"], {
|
|
406
|
+
cwd: path.join(root, "macos"),
|
|
407
|
+
env: { RCT_NEW_ARCH_ENABLED: "1" },
|
|
408
|
+
label: "Installing CocoaPods dependencies",
|
|
409
|
+
});
|
|
410
|
+
const remaining = missingNativeFrameworks(root);
|
|
411
|
+
if (remaining.length)
|
|
412
|
+
throw new Error(`Native frameworks are missing after pod install. Restore the package's native artifacts and retry:\n${remaining.join("\n")}`);
|
|
413
|
+
}
|
|
414
|
+
await restoreNativeMetadata(root, nativeConfig);
|
|
415
|
+
const workspace = readdirSync(nativeRoot).find((name) => name.endsWith(".xcworkspace"));
|
|
416
|
+
if (!workspace)
|
|
417
|
+
throw new Error("Prebuild did not produce a macOS workspace.");
|
|
418
|
+
if (needsPreparation || missing.length) {
|
|
419
|
+
preparation = currentPreparation();
|
|
420
|
+
writeJson(preparedFile, preparation);
|
|
421
|
+
}
|
|
422
|
+
return { preparation, nativeConfig, nativeRoot, workspace };
|
|
423
|
+
}
|
|
@@ -6,7 +6,8 @@ const options = {
|
|
|
6
6
|
device: { type: "string" }, project: { type: "string" }, platform: { type: "string" },
|
|
7
7
|
packages: { type: "string" }, port: { type: "string" }, runner: { type: "boolean" },
|
|
8
8
|
dev: { type: "boolean" }, release: { type: "boolean" }, preview: { type: "boolean" },
|
|
9
|
-
|
|
9
|
+
root: { type: "string" }, out: { type: "string" },
|
|
10
|
+
init: { type: "boolean" }, force: { type: "boolean" }, done: { type: "boolean" }, "dry-run": { type: "boolean" }, "submission-id": { type: "string" }, help: { type: "boolean", short: "h" },
|
|
10
11
|
};
|
|
11
12
|
const commands = {
|
|
12
13
|
create: { flags: ["example", "package-manager", "bundle-id", "universal", "platform", "packages"], arguments: [1, 1] },
|
|
@@ -20,7 +21,9 @@ const commands = {
|
|
|
20
21
|
build: { flags: ["project", "platform", "device", "port", "runner", "dev", "release", "preview", "force"], arguments: [0, 0] },
|
|
21
22
|
prebuild: { flags: ["project", "platform"], arguments: [0, 0] },
|
|
22
23
|
doctor: { flags: ["project"], arguments: [0, 0] },
|
|
24
|
+
migrate: { flags: ["project", "dry-run", "init"], arguments: [0, 0] },
|
|
23
25
|
upgrade: { flags: ["project", "dry-run"], arguments: [0, 0] },
|
|
26
|
+
patch: { flags: ["project", "root", "out", "done", "force"], arguments: [1, 1] },
|
|
24
27
|
"updates init": { flags: ["project", "platform"], arguments: [1, 1] },
|
|
25
28
|
credentials: { flags: ["project", "platform"], arguments: [0, 0] },
|
|
26
29
|
package: { flags: ["project", "platform", "force", "submission-id"], arguments: [0, 0] },
|
|
@@ -89,7 +89,16 @@ export function binary(root, name) {
|
|
|
89
89
|
throw new Error(`${name} does not expose its CLI entry point`);
|
|
90
90
|
return path.resolve(path.dirname(manifest), entry);
|
|
91
91
|
}
|
|
92
|
-
export async function doctor(root) {
|
|
92
|
+
export async function doctor(root, { nativeBuild = true, readOnly = false } = {}) {
|
|
93
|
+
const probe = async (argv) => {
|
|
94
|
+
if (!readOnly)
|
|
95
|
+
return run(root, argv, { capture: true });
|
|
96
|
+
const child = spawnProcess(argv, { cwd: root, stdout: "pipe", stderr: "pipe" });
|
|
97
|
+
const [out, err, code] = await Promise.all([new Response(child.stdout).text(), new Response(child.stderr).text(), child.exited]);
|
|
98
|
+
if (code)
|
|
99
|
+
throw new Error(`${argv[0]} failed: ${err || out}`);
|
|
100
|
+
return out;
|
|
101
|
+
};
|
|
93
102
|
if (process.platform === "win32") {
|
|
94
103
|
for (const tool of ["node", "pwsh.exe", "dotnet.exe"])
|
|
95
104
|
if (!which(tool))
|
|
@@ -97,17 +106,17 @@ export async function doctor(root) {
|
|
|
97
106
|
await checkExpoDesktopNode(root);
|
|
98
107
|
const require = createRequire(path.join(root, "package.json"));
|
|
99
108
|
const windows = path.dirname(require.resolve("react-native-windows/package.json"));
|
|
100
|
-
|
|
109
|
+
if (!readOnly)
|
|
110
|
+
await run(root, ["pwsh.exe", "-File", path.join(windows, "Scripts/rnw-dependencies.ps1")]);
|
|
101
111
|
return;
|
|
102
112
|
}
|
|
103
113
|
if (process.platform !== "darwin")
|
|
104
114
|
throw new Error("Native macOS builds require macOS.");
|
|
105
|
-
for (const tool of ["node", "pod", "xcodebuild"])
|
|
115
|
+
for (const tool of ["node", "pod", ...(nativeBuild ? ["xcodebuild"] : [])])
|
|
106
116
|
if (!which(tool))
|
|
107
117
|
throw new Error(`Missing ${tool}. Install the macOS native prerequisites described in docs/development.md, then retry the build.`);
|
|
108
118
|
await checkExpoDesktopNode(root);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
});
|
|
119
|
+
if (nativeBuild)
|
|
120
|
+
await probe(["xcodebuild", "-version"]);
|
|
121
|
+
await probe(["xcrun", "--sdk", "macosx", "--show-sdk-path"]);
|
|
113
122
|
}
|
|
@@ -8,16 +8,32 @@ const packages = ["react", "react-native", "react-native-macos", "expo"];
|
|
|
8
8
|
// create/refreshLocalPackages use this starter's tested compatibility matrix too.
|
|
9
9
|
const defaults = JSON.parse(readFileSync(new URL("../templates/blank-typescript/package.json", import.meta.url), "utf8"));
|
|
10
10
|
export const expectedDependencyPins = Object.fromEntries(packages.map(name => [name, defaults.dependencies[name]]));
|
|
11
|
+
export function projectDependencies(root, inherited = false) {
|
|
12
|
+
const pkg = JSON.parse(readFileSync(path.join(root, "package.json"), "utf8"));
|
|
13
|
+
const dependencies = { ...pkg.dependencies, ...pkg.devDependencies, ...pkg.optionalDependencies };
|
|
14
|
+
if (inherited) {
|
|
15
|
+
for (let directory = path.dirname(root);; directory = path.dirname(directory)) {
|
|
16
|
+
const file = path.join(directory, "package.json");
|
|
17
|
+
if (existsSync(file)) {
|
|
18
|
+
const owner = JSON.parse(readFileSync(file, "utf8"));
|
|
19
|
+
for (const [name, spec] of Object.entries({ ...owner.dependencies, ...owner.devDependencies, ...owner.optionalDependencies }))
|
|
20
|
+
dependencies[name] ??= spec;
|
|
21
|
+
}
|
|
22
|
+
if (path.dirname(directory) === directory)
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return dependencies;
|
|
27
|
+
}
|
|
11
28
|
/** Optional feature backends belong to the app, even when Spark supplies the API. */
|
|
12
|
-
export function optionalBackendIssues(root) {
|
|
29
|
+
export function optionalBackendIssues(root, inherited = false) {
|
|
13
30
|
const backends = {
|
|
14
31
|
"@legendapp/spark/markdown": "react-native-enriched-markdown",
|
|
15
32
|
"@legendapp/spark/html": "react-native-enriched-html",
|
|
16
33
|
"@legendapp/spark/webview": "react-native-webview",
|
|
17
34
|
"@legendapp/spark/sqlite": "@op-engineering/op-sqlite",
|
|
18
35
|
};
|
|
19
|
-
const
|
|
20
|
-
const dependencies = { ...pkg.dependencies, ...pkg.devDependencies, ...pkg.optionalDependencies };
|
|
36
|
+
const dependencies = projectDependencies(root, inherited);
|
|
21
37
|
const platforms = supportedPlatforms(root);
|
|
22
38
|
const req = createRequire(path.join(root, "package.json"));
|
|
23
39
|
const issues = new Map();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ensurePatchRegistry } from "@legendapp/spark-desktop-config/patch-registry.cjs";
|
|
1
2
|
import { spawnProcess } from "./process.js";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { prepareConfig, selectTarget, supportedPlatforms } from "@legendapp/spark-desktop-config/config.cjs";
|
|
@@ -61,6 +62,7 @@ export async function devCommand(args) {
|
|
|
61
62
|
}
|
|
62
63
|
const root = findProject(start);
|
|
63
64
|
ensureProjectVersion(root);
|
|
65
|
+
await ensurePatchRegistry(root);
|
|
64
66
|
const { desktop, initial } = devTargets(supportedPlatforms(root), options.platform ?? process.env.SPARK_PLATFORM);
|
|
65
67
|
// This selects only desktop build/signature state in the supervisor. Expo's
|
|
66
68
|
// child uses shared development config and chooses each JS graph per request.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { ensurePatchRegistry } from "@legendapp/spark-desktop-config/patch-registry.cjs";
|
|
1
2
|
import { installedRelease } from "./release.js";
|
|
3
|
+
import { createRuntimeInputCache } from "./runtime-input-cache.js";
|
|
2
4
|
import { acquireRunner } from "./runner-install.js";
|
|
3
5
|
import { spawnProcess } from "./process.js";
|
|
4
6
|
import { windowsMetroPort, stopWindowsMetro } from "./windows-metro.js";
|
|
@@ -17,6 +19,7 @@ import { watchmanStalls } from "./watchman.js";
|
|
|
17
19
|
import { assertNativePatchPreflight } from "./native-patch-preflight.js";
|
|
18
20
|
import { prepareConfig, dependencyStamp, goConfigurationIssues, incompatible, nativePackages, readJson, projectEnvironment, runtimeFor, stateFile, writeJson, } from "./project.js";
|
|
19
21
|
export async function launch(root, app, port, options = {}) {
|
|
22
|
+
await ensurePatchRegistry(root);
|
|
20
23
|
assertNativePatchPreflight(root);
|
|
21
24
|
if (readRuntime(app)?.platform === "windows") {
|
|
22
25
|
if (process.platform !== "win32")
|
|
@@ -53,6 +56,7 @@ export async function launch(root, app, port, options = {}) {
|
|
|
53
56
|
});
|
|
54
57
|
}
|
|
55
58
|
export async function dev(root, goApp, expoArgs = [], noOpen = false, appArgs = []) {
|
|
59
|
+
await ensurePatchRegistry(root);
|
|
56
60
|
assertNativePatchPreflight(root);
|
|
57
61
|
const platform = projectPlatform(root);
|
|
58
62
|
preparePatch(root);
|
|
@@ -79,6 +83,7 @@ export async function dev(root, goApp, expoArgs = [], noOpen = false, appArgs =
|
|
|
79
83
|
let restartPending = false;
|
|
80
84
|
let reopenPending = false;
|
|
81
85
|
let closing = false;
|
|
86
|
+
const runtimeInputs = createRuntimeInputCache(root);
|
|
82
87
|
// Without --no-open the session opens the desktop app itself, so a missing Runner downloads without a keypress.
|
|
83
88
|
let autoOpen = !noOpen;
|
|
84
89
|
let metro;
|
|
@@ -178,7 +183,8 @@ export async function dev(root, goApp, expoArgs = [], noOpen = false, appArgs =
|
|
|
178
183
|
}
|
|
179
184
|
}
|
|
180
185
|
async function inspectRuntime(report) {
|
|
181
|
-
const
|
|
186
|
+
const inputs = runtimeInputs.read();
|
|
187
|
+
const native = inputs.native;
|
|
182
188
|
current = undefined;
|
|
183
189
|
if (target === "go") {
|
|
184
190
|
if (explicitGo) {
|
|
@@ -200,7 +206,7 @@ export async function dev(root, goApp, expoArgs = [], noOpen = false, appArgs =
|
|
|
200
206
|
}
|
|
201
207
|
const issues = current ? incompatible(current.runtime, native, platform) : [];
|
|
202
208
|
if (current && target === "dev" &&
|
|
203
|
-
current.runtime.fingerprint !== runtimeFor(root, native, "dev").fingerprint)
|
|
209
|
+
current.runtime.fingerprint !== (inputs.development ??= runtimeFor(root, native, "dev")).fingerprint)
|
|
204
210
|
issues.push("Native configuration or host changed.");
|
|
205
211
|
if (target === "go") {
|
|
206
212
|
for (let i = 0; i < issues.length; i++) {
|
|
@@ -326,6 +332,7 @@ export async function dev(root, goApp, expoArgs = [], noOpen = false, appArgs =
|
|
|
326
332
|
if (closing)
|
|
327
333
|
return;
|
|
328
334
|
closing = true;
|
|
335
|
+
runtimeInputs.close();
|
|
329
336
|
clearInterval(timer);
|
|
330
337
|
clearTimeout(debounce);
|
|
331
338
|
watcher.close();
|
|
@@ -373,6 +380,7 @@ export async function dev(root, goApp, expoArgs = [], noOpen = false, appArgs =
|
|
|
373
380
|
try {
|
|
374
381
|
const next = dependencyStamp(root);
|
|
375
382
|
if (next !== stamp) {
|
|
383
|
+
runtimeInputs.invalidate();
|
|
376
384
|
restartPending = true;
|
|
377
385
|
stamp = next;
|
|
378
386
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ensurePatchRegistry } from "@legendapp/spark-desktop-config/patch-registry.cjs";
|
|
1
2
|
import { existsSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
2
3
|
import { createRequire } from "node:module";
|
|
3
4
|
import path from "node:path";
|
|
@@ -125,4 +126,5 @@ export async function installWithEnrichedHtmlPins(root, manager, policy = enrich
|
|
|
125
126
|
if (repairEnrichedHtmlPins(root, manager, false, policy).length)
|
|
126
127
|
await run(root, managerCommand(manager, ["install"]));
|
|
127
128
|
assertEnrichedHtmlPins(root, policy);
|
|
129
|
+
await ensurePatchRegistry(root);
|
|
128
130
|
}
|
|
@@ -23,7 +23,7 @@ export function errorPresentation(error) {
|
|
|
23
23
|
const message = error instanceof Error ? error.message : String(error);
|
|
24
24
|
const command = error instanceof CommandError ? error.argv.join(" ") : "";
|
|
25
25
|
const details = error instanceof CommandError ? error.output : message;
|
|
26
|
-
let summary = message.split("\n")[0] || "An unexpected error occurred.";
|
|
26
|
+
let summary = (message.includes("\nFix:") ? message : message.split("\n")[0]) || "An unexpected error occurred.";
|
|
27
27
|
let next;
|
|
28
28
|
if (isNetworkError(error)) {
|
|
29
29
|
summary = command.includes("notarytool") ? "Could not reach Apple’s notarization service." : "Could not reach the remote service.";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ensurePatchRegistry, fetchRegistry, registryFindings } from "@legendapp/spark-desktop-config/patch-registry.cjs";
|
|
1
2
|
import { enrichedHtmlPinIssues } from "./enriched-html-pins.js";
|
|
2
3
|
import { publishCustomize } from "./customize-artifacts.js";
|
|
3
4
|
import { nodeCommand, spawnProcess } from "./process.js";
|
|
@@ -17,14 +18,17 @@ import { buildMode } from "./build-mode.js";
|
|
|
17
18
|
import { initializeUpdates } from "./updates.js";
|
|
18
19
|
import { packageApp } from "./package.js";
|
|
19
20
|
import { credentials } from "./credentials.js";
|
|
20
|
-
import { build, analyze } from "./build.js";
|
|
21
|
+
import { build, analyze, prebuild } from "./build.js";
|
|
21
22
|
import { launch } from "./dev.js";
|
|
23
|
+
import { appPatchIssues } from "@legendapp/spark-desktop-config/native-patches.cjs";
|
|
22
24
|
import { doctor, run } from "./commands.js";
|
|
23
25
|
import { findFramework, findProject, sparkHome, creationManifest, packageManifest, registerRuntime } from "./local.js";
|
|
24
26
|
import { readJson, stateFile, VERSION, writeJson } from "./project.js";
|
|
25
27
|
import { devCommand } from "./dev-command.js";
|
|
26
28
|
import { optionalBackendIssues, printDependencyPins, upgradeDependencyPins } from "./dependency-pins.js";
|
|
29
|
+
import { migrate } from "./migrate.js";
|
|
27
30
|
import { upgrade } from "./upgrade.js";
|
|
31
|
+
import { patchLibrary, patchRoot } from "./patch.js";
|
|
28
32
|
import { ensureProjectVersion } from "./project-version.js";
|
|
29
33
|
import { reportError } from "./errors.js";
|
|
30
34
|
async function main() {
|
|
@@ -48,6 +52,7 @@ async function main() {
|
|
|
48
52
|
if (!values.help && ["build", "prebuild"].includes(command ?? "")) {
|
|
49
53
|
const root = project();
|
|
50
54
|
ensureProjectVersion(root);
|
|
55
|
+
await ensurePatchRegistry(root);
|
|
51
56
|
const selected = readConfig(root).expo.platforms[0];
|
|
52
57
|
if (!["ios", "android", "web"].includes(selected) && (values.device || values.port))
|
|
53
58
|
throw new Error("--device and --port are mobile build options; use spark dev for desktop launch options.");
|
|
@@ -84,10 +89,13 @@ async function main() {
|
|
|
84
89
|
spark add desktop Add desktop to an existing Expo app without replacing its entry point
|
|
85
90
|
spark dev Develop with Fast Refresh
|
|
86
91
|
spark build Build a standalone desktop app
|
|
87
|
-
spark prebuild Generate a
|
|
92
|
+
spark prebuild Generate a native project (macOS also installs Pods; no app build)
|
|
88
93
|
spark package Sign and notarize a distribution archive
|
|
89
|
-
spark doctor Check
|
|
94
|
+
spark doctor Check dependency pins, app patches, and native tooling (exits 1 on issues)
|
|
95
|
+
spark migrate Apply installed-version migrations (--project <dir>, --dry-run; --init stamps a newly generated project)
|
|
90
96
|
spark upgrade Update Spark on its current release channel (--dry-run previews changes)
|
|
97
|
+
spark patch <lib> Copy a library with Spark's patch for editing; --done saves patches/<lib>@<version>.patch
|
|
98
|
+
in the nearest app or patches/ owner (--root: where it's installed, --out: where patches/ goes)
|
|
91
99
|
spark customize publish Upload prepared customization artifacts to existing GitHub releases
|
|
92
100
|
|
|
93
101
|
Inside an app: npm run dev, npm run build, npm run package (or pnpm, yarn, bun)
|
|
@@ -107,6 +115,10 @@ Overrides: --project <directory>, --port <number>, dev --runner-binary <runtime
|
|
|
107
115
|
await addDesktop(start, creationManifest(values.packages));
|
|
108
116
|
break;
|
|
109
117
|
}
|
|
118
|
+
case "migrate": {
|
|
119
|
+
migrate(projectOption ? start : project(), { dryRun: !!values["dry-run"], init: !!values.init });
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
110
122
|
case "create": {
|
|
111
123
|
if (!positionals[1])
|
|
112
124
|
throw new Error("Usage: spark create MyApp");
|
|
@@ -196,9 +208,10 @@ Overrides: --project <directory>, --port <number>, dev --runner-binary <runtime
|
|
|
196
208
|
break;
|
|
197
209
|
}
|
|
198
210
|
case "prebuild":
|
|
199
|
-
if (readConfig(project()).expo.platforms[0]
|
|
200
|
-
|
|
201
|
-
|
|
211
|
+
if (readConfig(project()).expo.platforms[0] === "windows")
|
|
212
|
+
await prepareWindows(project(), "dev");
|
|
213
|
+
else
|
|
214
|
+
await prebuild(project());
|
|
202
215
|
break;
|
|
203
216
|
case "doctor": {
|
|
204
217
|
let root;
|
|
@@ -210,7 +223,22 @@ Overrides: --project <directory>, --port <number>, dev --runner-binary <runtime
|
|
|
210
223
|
console.log("No Spark app found; skipping dependency pin check.");
|
|
211
224
|
}
|
|
212
225
|
if (root) {
|
|
213
|
-
ensureProjectVersion(root);
|
|
226
|
+
ensureProjectVersion(root, { readOnly: true });
|
|
227
|
+
try {
|
|
228
|
+
const source = await fetchRegistry(root, { writeCache: false });
|
|
229
|
+
const findings = registryFindings(root, source);
|
|
230
|
+
for (const issue of findings)
|
|
231
|
+
console.error(`${issue.message}\nFix: cd ${JSON.stringify(issue.owner)} && ${issue.fix}`);
|
|
232
|
+
if (findings.length) {
|
|
233
|
+
process.exitCode = 1;
|
|
234
|
+
pinIssues = true;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
console.error(`Patch registry check failed: ${error instanceof Error ? error.message : String(error)}\nFix: repair the registry metadata or reinstall Spark.`);
|
|
239
|
+
process.exitCode = 1;
|
|
240
|
+
pinIssues = true;
|
|
241
|
+
}
|
|
214
242
|
try {
|
|
215
243
|
const issues = [...upgradeDependencyPins(root, true), ...enrichedHtmlPinIssues(root), ...optionalBackendIssues(root)];
|
|
216
244
|
printDependencyPins(issues);
|
|
@@ -225,7 +253,19 @@ Overrides: --project <directory>, --port <number>, dev --runner-binary <runtime
|
|
|
225
253
|
pinIssues = true;
|
|
226
254
|
}
|
|
227
255
|
}
|
|
228
|
-
|
|
256
|
+
try {
|
|
257
|
+
const patchIssues = appPatchIssues(root ?? start);
|
|
258
|
+
if (patchIssues.length) {
|
|
259
|
+
console.error(`App patch issues:\n${patchIssues.map(issue => `- ${issue}`).join("\n")}`);
|
|
260
|
+
process.exitCode = 1;
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
console.error(`App patch check failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
266
|
+
process.exitCode = 1;
|
|
267
|
+
}
|
|
268
|
+
await doctor(root ?? start, { readOnly: true });
|
|
229
269
|
console.log("Native toolchain available.");
|
|
230
270
|
if (pinIssues)
|
|
231
271
|
console.log("Dependency pin issues found; run spark upgrade.");
|
|
@@ -235,6 +275,11 @@ Overrides: --project <directory>, --port <number>, dev --runner-binary <runtime
|
|
|
235
275
|
await upgrade(project(), !!values["dry-run"]);
|
|
236
276
|
break;
|
|
237
277
|
}
|
|
278
|
+
case "patch": {
|
|
279
|
+
const root = values.root ? path.resolve(values.root) : patchRoot(start);
|
|
280
|
+
patchLibrary(root, positionals[1], { done: !!values.done, force: !!values.force, out: values.out ? path.resolve(values.out) : root });
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
238
283
|
case "customize": {
|
|
239
284
|
if (positionals[1] !== "publish")
|
|
240
285
|
throw new Error("Usage: spark customize publish (after a customize release build)");
|
|
@@ -294,6 +339,9 @@ try {
|
|
|
294
339
|
await main();
|
|
295
340
|
}
|
|
296
341
|
catch (error) {
|
|
297
|
-
|
|
342
|
+
if (process.argv[2] === "doctor")
|
|
343
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
344
|
+
else
|
|
345
|
+
reportError(process.cwd(), error, "Spark");
|
|
298
346
|
process.exitCode = 1;
|
|
299
347
|
}
|