@legendapp/spark 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/init-template.cjs +7 -1
- package/package.json +10 -5
- package/patches/dependencies.json +4 -4
- package/patches/react-native-mmkv@4.3.2.patch +2 -2
- package/patches/react-native-nitro-zxing@0.3.1.patch +22 -0
- package/patches/registry.json +615 -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 +116 -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 +137 -105
- 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 +3 -0
- 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 +12 -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 +8 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +20 -20
- 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/package.json +2 -8
- 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 +300 -71
- 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,10 +1,11 @@
|
|
|
1
1
|
const fs = require('node:fs');
|
|
2
2
|
const path = require('node:path');
|
|
3
|
+
const { installedSparkVersion, planMigrations, applyMigrationPlan } = require('./migrations.cjs');
|
|
3
4
|
const { prepareConfig, toExpo } = require('@legendapp/spark-desktop-config/config.cjs');
|
|
4
5
|
|
|
5
6
|
// Expo Desktop assigns the application names and native IDs. Initialize only
|
|
6
7
|
// spark-owned configuration, once, after its template dependencies are installed.
|
|
7
|
-
function initializeTemplate(root) {
|
|
8
|
+
function initializeTemplate(root, recordVersion = true) {
|
|
8
9
|
const file = path.join(root, 'desktop.config.json');
|
|
9
10
|
if (!fs.existsSync(file)) return;
|
|
10
11
|
const config = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
@@ -13,6 +14,8 @@ function initializeTemplate(root) {
|
|
|
13
14
|
if (!expo?.windows?.projectGuid || !expo.name || !expo.macos?.bundleIdentifier) {
|
|
14
15
|
throw new Error('Create this template with expo-desktop create-app so its application identity is initialized.');
|
|
15
16
|
}
|
|
17
|
+
const installed = recordVersion ? installedSparkVersion(root) : undefined;
|
|
18
|
+
const plan = installed ? planMigrations(root, installed, { automatic: true, fromVersion: installed }) : undefined;
|
|
16
19
|
config.name = expo.name;
|
|
17
20
|
config.projectId = expo.windows.projectGuid;
|
|
18
21
|
config.expo = { ...expo, ...config.expo };
|
|
@@ -21,6 +24,13 @@ function initializeTemplate(root) {
|
|
|
21
24
|
toExpo(config);
|
|
22
25
|
fs.writeFileSync(file, JSON.stringify(config, null, 2) + '\n');
|
|
23
26
|
prepareConfig(root);
|
|
27
|
+
if (plan) applyMigrationPlan(root, plan);
|
|
24
28
|
}
|
|
25
29
|
module.exports = { initializeTemplate };
|
|
26
|
-
if (require.main === module)
|
|
30
|
+
if (require.main === module) {
|
|
31
|
+
const root = process.cwd();
|
|
32
|
+
require('@legendapp/spark-desktop-config/patch-registry.cjs').ensurePatchRegistry(root).then(() => {
|
|
33
|
+
initializeTemplate(root);
|
|
34
|
+
require('@legendapp/spark-desktop-config/native-patches.cjs').prepareNativePatches(root);
|
|
35
|
+
}).catch(error => { console.error(error.message); process.exitCode = 1; });
|
|
36
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function initializeTemplate(root: string): void;
|
|
1
|
+
export function initializeTemplate(root: string, recordVersion?: boolean): void;
|
|
@@ -31,6 +31,7 @@ function withDesktop(config, options = {}) {
|
|
|
31
31
|
// spark dev found Watchman unresponsive; crawl and watch with Node instead.
|
|
32
32
|
...(process.env.SPARK_METRO_NO_WATCHMAN === "1" ? { useWatchman: false } : {}) } };
|
|
33
33
|
const root = path.resolve(config.projectRoot || process.cwd());
|
|
34
|
+
config = require("@legendapp/spark-expo-compat/metro.cjs").withExpoCompat(config);
|
|
34
35
|
// Keep the configured workspace root so lazy imports outside the app have
|
|
35
36
|
// valid URLs. Only the prebuilt host's fixed entry URLs are app-relative.
|
|
36
37
|
const serverRoot = path.resolve(config.server?.unstable_serverRoot || root);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { supportedPlatforms } from "@legendapp/spark-desktop-config/config.cjs";
|
|
5
|
+
import { dependencyPinIssues, expectedDependencyPins, optionalBackendIssues, projectDependencies } from "./dependency-pins.js";
|
|
6
|
+
import { applyMigrationPlan, planMigrations, printMigrationPlan } from "./migrations.cjs";
|
|
7
|
+
import { projectSparkVersion } from "./project-version.js";
|
|
8
|
+
import { readJson } from "./json.js";
|
|
9
|
+
export function migrate(root, { dryRun = false, init = false } = {}) {
|
|
10
|
+
readJson(path.join(root, "package.json"));
|
|
11
|
+
const version = projectSparkVersion(root);
|
|
12
|
+
const plan = planMigrations(root, version, { fromVersion: init ? version : undefined });
|
|
13
|
+
if (init && plan.previous !== version)
|
|
14
|
+
throw new Error("spark migrate --init is only for newly generated projects without a receipt, or projects already at the installed version. Run spark migrate --dry-run to review the existing receipt's migrations.");
|
|
15
|
+
console.log(`Spark ${plan.previous ?? "(unrecorded)"} → ${version}${init ? " — initialize generated project" : ""}${dryRun ? " — dry run" : ""}`);
|
|
16
|
+
printMigrationPlan(plan);
|
|
17
|
+
const blocked = plan.manualSteps.filter(step => step.requires).map(step => `${step.requires}: ${step.message}`);
|
|
18
|
+
for (const change of plan.changes) {
|
|
19
|
+
if (/(^|\/)(package\.json|(?:bun|package|npm-shrinkwrap|pnpm|yarn).*lock.*|pnpm-workspace\.yaml|\.npmrc|\.yarnrc\.yml|(?:desktop\.config|app|app\.config|metro\.config|react-native\.config)\.(?:json|[cm]?[jt]s))$/.test(change.file)) {
|
|
20
|
+
blocked.push(`Install inputs or configuration would change: ${change.file}.`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const configFile = path.join(root, "desktop.config.json");
|
|
24
|
+
if (existsSync(configFile) && !readJson(configFile).projectId)
|
|
25
|
+
blocked.push("Template configuration is uninitialized. Create the project with expo-desktop create-app, then run node node_modules/@legendapp/spark/init-template.cjs.");
|
|
26
|
+
if (plan.versions.includes("0.0.2")) {
|
|
27
|
+
const req = createRequire(path.join(root, "package.json"));
|
|
28
|
+
const platforms = supportedPlatforms(root);
|
|
29
|
+
const pins = { ...expectedDependencyPins };
|
|
30
|
+
if (platforms.includes("windows"))
|
|
31
|
+
pins["react-native-windows"] = readJson(path.resolve(import.meta.dirname, "../templates/windows/package.json")).dependencies["react-native-windows"];
|
|
32
|
+
for (const issue of dependencyPinIssues({ dependencies: projectDependencies(root, true) }, platforms, pins))
|
|
33
|
+
blocked.push(`Install inputs: pin ${issue.package} to ${issue.expected} in its owning manifest (found ${issue.found}).`);
|
|
34
|
+
for (const [name, expected] of Object.entries(pins)) {
|
|
35
|
+
if (name === "react-native-macos" && !platforms.includes("macos"))
|
|
36
|
+
continue;
|
|
37
|
+
let installed;
|
|
38
|
+
try {
|
|
39
|
+
installed = readJson(req.resolve(`${name}/package.json`)).version;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (error.code !== "MODULE_NOT_FOUND")
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
if (installed !== expected)
|
|
46
|
+
blocked.push(`Install ${name}@${expected}; resolved ${installed ?? "(missing)"}.`);
|
|
47
|
+
}
|
|
48
|
+
for (const issue of optionalBackendIssues(root, true))
|
|
49
|
+
blocked.push(`Install ${issue.package}@${issue.expected}: ${issue.where.join(" → ")}.`);
|
|
50
|
+
}
|
|
51
|
+
for (const reason of blocked)
|
|
52
|
+
console.log(`Blocked: ${reason}`);
|
|
53
|
+
if (blocked.length) {
|
|
54
|
+
const guidance = "Migrations require an install or configuration changes. Resolve the listed requirements in the owning project, or run spark upgrade to update release inputs and install, then retry spark migrate.";
|
|
55
|
+
if (!dryRun)
|
|
56
|
+
throw new Error(`${guidance} No app files changed.`);
|
|
57
|
+
console.log(guidance);
|
|
58
|
+
}
|
|
59
|
+
else if (!dryRun) {
|
|
60
|
+
applyMigrationPlan(root, plan);
|
|
61
|
+
console.log(`Migrated to installed Spark ${version}. Review .spark/upgrade-notes.md if present.`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
console.log("No app files changed.");
|
|
65
|
+
}
|
|
@@ -50,7 +50,7 @@ function createMigrationContext(root, version, changes, manualSteps) {
|
|
|
50
50
|
try {
|
|
51
51
|
const value = JSON.parse(before);
|
|
52
52
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
53
|
-
context.manualStep(`Edit ${file} manually; expected a JSON object
|
|
53
|
+
context.manualStep(`Edit ${file} manually; expected a JSON object.`, 'configuration');
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
const original = JSON.stringify(value);
|
|
@@ -62,7 +62,7 @@ function createMigrationContext(root, version, changes, manualSteps) {
|
|
|
62
62
|
}
|
|
63
63
|
} catch (error) {
|
|
64
64
|
if (!(error instanceof SyntaxError)) throw error;
|
|
65
|
-
context.manualStep(`Edit ${file} manually; it is not valid JSON: ${error.message}
|
|
65
|
+
context.manualStep(`Edit ${file} manually; it is not valid JSON: ${error.message}`, 'configuration');
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
renameFile(from, to) {
|
|
@@ -83,9 +83,9 @@ function createMigrationContext(root, version, changes, manualSteps) {
|
|
|
83
83
|
if (content === null || content === previous) context.writeFile(file, next);
|
|
84
84
|
else if (content !== next) context.manualStep(`Merge the new template for ${file}; the app has customized it.`);
|
|
85
85
|
},
|
|
86
|
-
manualStep(message) {
|
|
86
|
+
manualStep(message, requires) {
|
|
87
87
|
const notes = `${upgradeNotesPath}#${version.replaceAll('.', '')}`;
|
|
88
|
-
if (!manualSteps.some(step => step.version === version && step.message === message)) manualSteps.push({ version, message, notes });
|
|
88
|
+
if (!manualSteps.some(step => step.version === version && step.message === message)) manualSteps.push({ version, message, notes, ...(requires ? { requires } : {}) });
|
|
89
89
|
},
|
|
90
90
|
replaceImport(from, to, names = {}) {
|
|
91
91
|
/** @type {typeof import('typescript')} */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue };
|
|
2
2
|
export type JsonObject = { [key: string]: JsonValue };
|
|
3
3
|
export interface FileChange { file: string; before: string | null; after: string | null }
|
|
4
|
-
export interface ManualStep { version: string; message: string; notes: string }
|
|
4
|
+
export interface ManualStep { version: string; message: string; notes: string; requires?: "configuration" | "install" }
|
|
5
5
|
export interface MigrationContext {
|
|
6
6
|
readFile(file: string): string | null;
|
|
7
7
|
writeFile(file: string, content: string): void;
|
|
@@ -9,7 +9,7 @@ export interface MigrationContext {
|
|
|
9
9
|
renameFile(from: string, to: string): void;
|
|
10
10
|
updateTemplate(file: string, previous: string, next: string): void;
|
|
11
11
|
replaceImport(from: string, to: string, names?: Readonly<Record<string, string>>): void;
|
|
12
|
-
manualStep(message: string): void;
|
|
12
|
+
manualStep(message: string, requires?: ManualStep["requires"]): void;
|
|
13
13
|
}
|
|
14
14
|
export const upgradeNotesPath: string;
|
|
15
15
|
export function createMigrationContext(root: string, version: string, changes: Map<string, FileChange>, manualSteps: ManualStep[]): MigrationContext;
|
|
@@ -51,24 +51,24 @@ function upgradeWindowConfig(context) {
|
|
|
51
51
|
context.editJson(file, /** @param {{ window?: import('./migration-helpers.cjs').JsonObject; expo?: { extra?: { spark?: { window?: import('./migration-helpers.cjs').JsonObject } } } }} config */ config => {
|
|
52
52
|
const options = file === 'desktop.config.json' ? config.window : config.expo?.extra?.spark?.window;
|
|
53
53
|
if (!options) return;
|
|
54
|
-
if (typeof options !== 'object' || Array.isArray(options)) { context.manualStep(`Repair window configuration in ${file}; expected an object
|
|
54
|
+
if (typeof options !== 'object' || Array.isArray(options)) { context.manualStep(`Repair window configuration in ${file}; expected an object.`, 'configuration'); return; }
|
|
55
55
|
for (const [nested, width, height] of [['size', 'width', 'height'], ['minSize', 'minWidth', 'minHeight'], ['maxSize', 'maxWidth', 'maxHeight']]) {
|
|
56
56
|
if (!(width in options) && !(height in options)) continue;
|
|
57
57
|
if (typeof options[width] !== 'number' || typeof options[height] !== 'number' || options[nested] !== undefined) {
|
|
58
|
-
context.manualStep(`Merge legacy ${width}/${height} into window.${nested} in ${file}; incomplete or conflicting dimensions need review
|
|
58
|
+
context.manualStep(`Merge legacy ${width}/${height} into window.${nested} in ${file}; incomplete or conflicting dimensions need review.`, 'configuration');
|
|
59
59
|
} else {
|
|
60
60
|
options[nested] = { width: options[width], height: options[height] };
|
|
61
61
|
delete options[width]; delete options[height];
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
if ('restoreFrame' in options) {
|
|
65
|
-
if ('restoreBounds' in options && options.restoreBounds !== options.restoreFrame) context.manualStep(`Resolve window.restoreFrame/restoreBounds in ${file}
|
|
65
|
+
if ('restoreBounds' in options && options.restoreBounds !== options.restoreFrame) context.manualStep(`Resolve window.restoreFrame/restoreBounds in ${file}.`, 'configuration');
|
|
66
66
|
else { options.restoreBounds = options.restoreFrame; delete options.restoreFrame; }
|
|
67
67
|
}
|
|
68
68
|
for (const [legacy, nested] of [['material', 'backgroundMaterial'], ['trafficLights', 'titleBar']]) {
|
|
69
69
|
if (!(legacy in options)) continue;
|
|
70
70
|
const macos = /** @type {import('./migration-helpers.cjs').JsonObject} */ (options.macos ?? {});
|
|
71
|
-
if (typeof macos !== 'object' || Array.isArray(macos) || macos[nested] !== undefined) context.manualStep(`Merge window.${legacy} into window.macos.${nested} in ${file}
|
|
71
|
+
if (typeof macos !== 'object' || Array.isArray(macos) || macos[nested] !== undefined) context.manualStep(`Merge window.${legacy} into window.macos.${nested} in ${file}.`, 'configuration');
|
|
72
72
|
else {
|
|
73
73
|
macos[nested] = legacy === 'trafficLights' ? { trafficLights: options[legacy] } : options[legacy];
|
|
74
74
|
options.macos = macos; delete options[legacy];
|
|
@@ -103,6 +103,9 @@ const migrations = [
|
|
|
103
103
|
{ version: '0.0.3', automatic: false, breaking: true, apply(context) {
|
|
104
104
|
context.manualStep('Apps using the default macOS react-native-mmkv@4.3.2 store must plan data migration from ~/Documents/mmkv to ~/Library/Application Support/<Spark namespace>/mmkv before deployment. Existing files are not moved automatically and the old folder can contain other apps\' data. Back up the store, preserve IDs and encryption keys, and validate values and relaunch persistence; see the linked upgrade notes.');
|
|
105
105
|
} },
|
|
106
|
+
{ version: '0.0.4', automatic: false, breaking: true, apply(context) {
|
|
107
|
+
context.manualStep('Quit older builds, back up macOS file/MMKV data, keep bundle identifiers stable, and rebuild custom hosts. First launch automatically migrates owned legacy data to ~/Library/Application Support/<bundle id>/Spark; ambiguous sources and IO errors stop startup. Review any reported conflict without overwriting data, then verify file/MMKV values and relaunch persistence; see the linked upgrade notes.');
|
|
108
|
+
} },
|
|
106
109
|
];
|
|
107
110
|
|
|
108
111
|
/** @param {string} root */
|
|
@@ -114,13 +117,13 @@ function installedSparkVersion(root) {
|
|
|
114
117
|
/** @type {typeof import('./migrations.cjs').planMigrations} */
|
|
115
118
|
function planMigrations(root, version, { automatic = false, fromVersion } = {}) {
|
|
116
119
|
const { compare, valid } = createRequire(resolveDependency(root, 'npm/package.json'))('semver');
|
|
117
|
-
const
|
|
118
|
-
const previous =
|
|
120
|
+
const receipt = createMigrationContext(root, version, new Map(), []).readFile('.spark/version');
|
|
121
|
+
const previous = receipt === null ? fromVersion : receipt.trim();
|
|
119
122
|
if (!valid(version) || (previous !== undefined && (!valid(previous) || compare(previous, version) > 0))) {
|
|
120
123
|
throw new Error(`Spark project version ${previous ?? '(unrecorded)'} cannot migrate to ${version}. Run spark upgrade.`);
|
|
121
124
|
}
|
|
122
125
|
const pending = migrations.filter(step => (!previous || compare(step.version, previous) > 0) && compare(step.version, version) <= 0).sort((a, b) => compare(a.version, b.version));
|
|
123
|
-
if (automatic && pending.some(step => !step.automatic)) throw new Error('Spark has pending migrations
|
|
126
|
+
if (automatic && pending.some(step => !step.automatic)) throw new Error('Spark has pending migrations. Run spark migrate --dry-run, then spark migrate to apply at the installed version. Run spark upgrade if an install or configuration changes are required.');
|
|
124
127
|
const changes = new Map();
|
|
125
128
|
/** @type {import('./migration-helpers.cjs').ManualStep[]} */
|
|
126
129
|
const manualSteps = [];
|
|
@@ -165,8 +168,9 @@ function applyMigrationPlan(root, plan, recordVersion = true) {
|
|
|
165
168
|
|
|
166
169
|
/** @type {typeof import('./migrations.cjs').recordProjectVersion} */
|
|
167
170
|
function recordProjectVersion(root, version) {
|
|
171
|
+
const context = createMigrationContext(root, version, new Map(), []);
|
|
168
172
|
const file = path.join(root, '.spark/version');
|
|
169
|
-
if (
|
|
173
|
+
if (context.readFile('.spark/version') === version + '\n') return;
|
|
170
174
|
// Record only successful migrations. A failed/partial attempt is safe to retry.
|
|
171
175
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
172
176
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
+
import { patchDisabled } from "@legendapp/spark-desktop-config/patch-registry.cjs";
|
|
1
2
|
import { assertEnrichedHtmlPins } from "./enriched-html-pins.js";
|
|
2
3
|
import { createHash } from "node:crypto";
|
|
3
4
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
5
|
import path from "node:path";
|
|
5
|
-
import { prepareNativePatches } from "@legendapp/spark-desktop-config/native-patches.cjs";
|
|
6
|
+
import { appPatches, prepareNativePatches } from "@legendapp/spark-desktop-config/native-patches.cjs";
|
|
6
7
|
import { findFramework } from "./local.js";
|
|
7
8
|
import { installedPackages, readJson, VERSION } from "./project.js";
|
|
8
9
|
const required = ["@react-native-runtimes/core", "react-native-nitro-modules"];
|
|
9
10
|
const optional = ["@op-engineering/op-sqlite", "react-native-webview", "expo-audio"];
|
|
10
|
-
export function validatePackedNativePatches(packages, requirements, frameworkVersion = VERSION) {
|
|
11
|
+
export function validatePackedNativePatches(packages, requirements, frameworkVersion = VERSION, disabled = []) {
|
|
11
12
|
if (!requirements || requirements.schema !== 1 || requirements.frameworkVersion !== frameworkVersion || !requirements.packages || typeof requirements.packages !== "object")
|
|
12
13
|
return [`The installed @legendapp/spark SDK does not include native patch provenance for ${frameworkVersion}. Run spark add desktop to install the matching SDK packages, then retry.`];
|
|
13
14
|
const installed = new Map(packages.map(pkg => [pkg.name, pkg.json]));
|
|
14
15
|
const errors = [];
|
|
15
16
|
for (const name of required)
|
|
16
|
-
if (!installed.has(name))
|
|
17
|
+
if (!disabled.includes(name) && !installed.has(name))
|
|
17
18
|
errors.push(`${name} is missing; reinstall the dependencies from this Spark SDK.`);
|
|
18
19
|
for (const name of [...required, ...optional]) {
|
|
20
|
+
if (disabled.includes(name))
|
|
21
|
+
continue;
|
|
19
22
|
const actual = installed.get(name);
|
|
20
23
|
if (!actual)
|
|
21
24
|
continue;
|
|
@@ -29,7 +32,7 @@ export function validatePackedNativePatches(packages, requirements, frameworkVer
|
|
|
29
32
|
}
|
|
30
33
|
return errors;
|
|
31
34
|
}
|
|
32
|
-
export function validateWorkspaceNativePatches(root, packages) {
|
|
35
|
+
export function validateWorkspaceNativePatches(root, packages, disabled = []) {
|
|
33
36
|
const framework = findFramework(root);
|
|
34
37
|
if (!framework)
|
|
35
38
|
return ["The Spark SDK is missing native patch provenance. Run spark add desktop to install matching SDK packages, then retry."];
|
|
@@ -41,6 +44,8 @@ export function validateWorkspaceNativePatches(root, packages) {
|
|
|
41
44
|
const installed = new Map(packages.map(pkg => [pkg.name, pkg]));
|
|
42
45
|
const errors = [];
|
|
43
46
|
for (const name of [...required, ...optional]) {
|
|
47
|
+
if (disabled.includes(name))
|
|
48
|
+
continue;
|
|
44
49
|
const pkg = installed.get(name);
|
|
45
50
|
if (!pkg) {
|
|
46
51
|
if (required.includes(name))
|
|
@@ -68,6 +73,24 @@ export function validateWorkspaceNativePatches(root, packages) {
|
|
|
68
73
|
}
|
|
69
74
|
return errors;
|
|
70
75
|
}
|
|
76
|
+
/** Each patched package's receipt must name the Spark and app patch layers the app currently declares. */
|
|
77
|
+
export function validateAppPatches(root, packages) {
|
|
78
|
+
const app = readJson(path.join(root, "package.json"));
|
|
79
|
+
const patches = app.name === "@legendapp/spark" ? {} : appPatches(root, app);
|
|
80
|
+
const errors = [];
|
|
81
|
+
for (const pkg of packages) {
|
|
82
|
+
const receipt = pkg.json.spark?.dependencyPatch;
|
|
83
|
+
if (!receipt)
|
|
84
|
+
continue;
|
|
85
|
+
const own = patches[pkg.name];
|
|
86
|
+
const appPatchHash = own && createHash("sha256").update(own.bytes).digest("hex");
|
|
87
|
+
if (receipt.appPatchHash !== appPatchHash)
|
|
88
|
+
errors.push(`${pkg.name}@${pkg.json.version} does not carry ${own?.file ?? "the app's current patches"}. Reinstall ${pkg.name}, then retry.`);
|
|
89
|
+
if (app.spark?.patches?.[pkg.name] === false && receipt.patchHash)
|
|
90
|
+
errors.push(`${pkg.name}@${pkg.json.version} still has Spark's patch, which spark.patches disables. Reinstall ${pkg.name}, then retry.`);
|
|
91
|
+
}
|
|
92
|
+
return errors;
|
|
93
|
+
}
|
|
71
94
|
export function assertNativePatchPreflight(root) {
|
|
72
95
|
assertEnrichedHtmlPins(root);
|
|
73
96
|
const packages = installedPackages(root);
|
|
@@ -76,13 +99,18 @@ export function assertNativePatchPreflight(root) {
|
|
|
76
99
|
let errors;
|
|
77
100
|
const spark = packages.find(pkg => pkg.name === "@legendapp/spark");
|
|
78
101
|
const requirements = spark?.json.spark?.nativePatchRequirements;
|
|
102
|
+
const disabled = [...required, ...optional].filter(name => {
|
|
103
|
+
const pkg = packages.find(pkg => pkg.name === name);
|
|
104
|
+
return patchDisabled(root, name, pkg && path.join(pkg.root, "package.json"));
|
|
105
|
+
});
|
|
79
106
|
if (requirements)
|
|
80
|
-
errors = validatePackedNativePatches(packages, requirements);
|
|
107
|
+
errors = validatePackedNativePatches(packages, requirements, VERSION, disabled);
|
|
81
108
|
else if (framework)
|
|
82
|
-
errors = validateWorkspaceNativePatches(root, packages);
|
|
109
|
+
errors = validateWorkspaceNativePatches(root, packages, disabled);
|
|
83
110
|
else {
|
|
84
|
-
errors = validatePackedNativePatches(packages, requirements);
|
|
111
|
+
errors = validatePackedNativePatches(packages, requirements, VERSION, disabled);
|
|
85
112
|
}
|
|
113
|
+
errors.push(...validateAppPatches(root, packages));
|
|
86
114
|
if (errors.length)
|
|
87
115
|
throw new Error(`Native patch preparation stopped before changing project files:\n${errors.map(error => `- ${error}`).join("\n")}`);
|
|
88
116
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { createTwoFilesPatch } from "diff";
|
|
7
|
+
import { appPatches, layerPatches, prepareNativePatches, resolveManifest, withoutReceipt } from "@legendapp/spark-desktop-config/native-patches.cjs";
|
|
8
|
+
import { readJson } from "./project.js";
|
|
9
|
+
function files(directory, relative = "") {
|
|
10
|
+
if (!existsSync(path.join(directory, relative)))
|
|
11
|
+
return [];
|
|
12
|
+
return readdirSync(path.join(directory, relative), { withFileTypes: true }).flatMap(entry => {
|
|
13
|
+
const child = relative ? `${relative}/${entry.name}` : entry.name;
|
|
14
|
+
if (entry.name === "node_modules" || entry.name === ".git")
|
|
15
|
+
return [];
|
|
16
|
+
return entry.isDirectory() ? files(directory, child) : [child];
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const read = (file) => existsSync(file) ? readFileSync(file, "utf8") : undefined;
|
|
20
|
+
/** The nearest folder from start that owns app patches: a Spark app, a patches/ folder or a package.json with a spark field. */
|
|
21
|
+
export function patchRoot(start) {
|
|
22
|
+
for (let dir = path.resolve(start);; dir = path.dirname(dir)) {
|
|
23
|
+
const manifest = path.join(dir, "package.json");
|
|
24
|
+
if (existsSync(path.join(dir, "patches")) || (existsSync(manifest) &&
|
|
25
|
+
(existsSync(path.join(dir, "app.json")) || existsSync(path.join(dir, "desktop.config.json")) || readJson(manifest).spark)))
|
|
26
|
+
return dir;
|
|
27
|
+
if (path.dirname(dir) === dir)
|
|
28
|
+
throw new Error("No patches/ folder or Spark app found. Run spark patch inside your app or pass --root.");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Two steps, like patch-package: the first copies the library installed for root with Spark's patch (and
|
|
33
|
+
* without the app's) to a temporary folder for editing; `done` saves the edits as <out>/patches/<name>@<version>.patch.
|
|
34
|
+
* The installed copy follows only patches saved in root's own patches/.
|
|
35
|
+
*/
|
|
36
|
+
export function patchLibrary(root, name, { done = false, force = false, out = root } = {}) {
|
|
37
|
+
prepareNativePatches(root);
|
|
38
|
+
let manifest;
|
|
39
|
+
try {
|
|
40
|
+
manifest = resolveManifest(createRequire(path.join(root, "package.json")), name);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
throw new Error(`${name} is not installed in ${root}.`);
|
|
44
|
+
}
|
|
45
|
+
const installed = realpathSync(path.dirname(manifest));
|
|
46
|
+
const { version } = readJson(manifest);
|
|
47
|
+
const manifestOut = path.join(out, "package.json");
|
|
48
|
+
const own = appPatches(out, existsSync(manifestOut) ? readJson(manifestOut) : {})[name];
|
|
49
|
+
if (own?.thirdParty)
|
|
50
|
+
throw new Error(`${own.file} already patches ${name} through your package manager. Remove it and reinstall ${name} before using spark patch.`);
|
|
51
|
+
const file = path.join("patches", `${name.replace("/", "+")}@${version}.patch`);
|
|
52
|
+
const work = path.join(os.tmpdir(), "spark-patch", createHash("sha256").update(root).digest("hex").slice(0, 12), `${name.replace("/", "+")}@${version}`);
|
|
53
|
+
const base = path.join(work, "base"), edit = path.join(work, "edit");
|
|
54
|
+
if (!done) {
|
|
55
|
+
if (existsSync(edit) && !force) {
|
|
56
|
+
console.log(`${name} is already prepared for editing in ${edit}\nRun spark patch ${name} --done to save it, or --force to start over.`);
|
|
57
|
+
return edit;
|
|
58
|
+
}
|
|
59
|
+
rmSync(work, { recursive: true, force: true });
|
|
60
|
+
cpSync(installed, base, { recursive: true, filter: source => !["node_modules", ".git", ".spark-app.patch"].includes(path.relative(installed, source).split(path.sep)[0]) });
|
|
61
|
+
writeFileSync(path.join(base, "package.json"), withoutReceipt(readFileSync(path.join(base, "package.json"), "utf8")));
|
|
62
|
+
if (own)
|
|
63
|
+
layerPatches(base, name, [undefined, { text: own.bytes.toString("utf8"), apply: false, error: () => "" }]);
|
|
64
|
+
cpSync(base, edit, { recursive: true });
|
|
65
|
+
console.log(`Edit ${name}@${version} in ${edit}\nThen run spark patch ${name} --done to save ${file}.`);
|
|
66
|
+
return edit;
|
|
67
|
+
}
|
|
68
|
+
if (!existsSync(edit))
|
|
69
|
+
throw new Error(`Run spark patch ${name} first, edit the copy it prints, then rerun with --done.`);
|
|
70
|
+
let diff = "";
|
|
71
|
+
for (const relative of [...new Set([...files(base), ...files(edit)])].sort()) {
|
|
72
|
+
const before = read(path.join(base, relative)), after = read(path.join(edit, relative));
|
|
73
|
+
if (before === after)
|
|
74
|
+
continue;
|
|
75
|
+
if (after === undefined)
|
|
76
|
+
throw new Error(`App patches can't delete ${relative}; empty it instead.`);
|
|
77
|
+
if (after.includes("\0"))
|
|
78
|
+
throw new Error(`App patches can't change binary file ${relative}.`);
|
|
79
|
+
diff += `diff --git a/${relative} b/${relative}\n` + createTwoFilesPatch(before === undefined ? "/dev/null" : `a/${relative}`, `b/${relative}`, before ?? "", after).replace(/^=+\n/, "");
|
|
80
|
+
}
|
|
81
|
+
if (diff) {
|
|
82
|
+
mkdirSync(path.join(out, "patches"), { recursive: true });
|
|
83
|
+
writeFileSync(path.join(out, file), diff);
|
|
84
|
+
}
|
|
85
|
+
else
|
|
86
|
+
rmSync(path.join(out, file), { force: true });
|
|
87
|
+
if (out === root)
|
|
88
|
+
prepareNativePatches(root);
|
|
89
|
+
rmSync(work, { recursive: true, force: true });
|
|
90
|
+
console.log(diff ? `Saved ${file}.` : `No changes to ${name}; ${file} is absent.`);
|
|
91
|
+
return path.join(out, file);
|
|
92
|
+
}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { initializeTemplate } from "./init-template.cjs";
|
|
2
|
-
import { installedSparkVersion, migrateProject } from "./migrations.cjs";
|
|
2
|
+
import { installedSparkVersion, migrateProject, planMigrations } from "./migrations.cjs";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { readJson } from "./json.js";
|
|
5
5
|
const version = readJson(fileURLToPath(new URL("../package.json", import.meta.url))).version;
|
|
6
|
-
export function
|
|
6
|
+
export function projectSparkVersion(root) {
|
|
7
7
|
const installed = installedSparkVersion(root);
|
|
8
8
|
if (installed !== version)
|
|
9
9
|
throw new Error(`This CLI is Spark ${version}, but the app has ${installed}. Run spark upgrade using the app's installed CLI.`);
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
return installed;
|
|
11
|
+
}
|
|
12
|
+
export function ensureProjectVersion(root, { readOnly = false } = {}) {
|
|
13
|
+
const version = projectSparkVersion(root);
|
|
14
|
+
if (readOnly)
|
|
15
|
+
planMigrations(root, version);
|
|
16
|
+
else {
|
|
17
|
+
migrateProject(root, version);
|
|
18
|
+
initializeTemplate(root, false);
|
|
19
|
+
}
|
|
12
20
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { patchSourceSHA } from "@legendapp/spark-desktop-config/patch-registry.cjs";
|
|
2
|
+
import { SparkError, validatePackageSettings } from "@legendapp/spark-desktop-config/validation.cjs";
|
|
1
3
|
import { assertEnrichedHtmlPins } from "./enriched-html-pins.js";
|
|
2
4
|
import { nativeWindowOptions } from "@legendapp/spark-window-options";
|
|
3
5
|
import { prepareNativePatches, removeExpoApplicationAlias } from "@legendapp/spark-desktop-config/native-patches.cjs";
|
|
@@ -12,7 +14,7 @@ import { existsSync, readFileSync, readdirSync, realpathSync, } from "node:fs";
|
|
|
12
14
|
import path from "node:path";
|
|
13
15
|
import { readJson, writeJson } from "./json.js";
|
|
14
16
|
export { readJson, writeJson };
|
|
15
|
-
export const VERSION = "0.0.
|
|
17
|
+
export const VERSION = "0.0.4";
|
|
16
18
|
export function digest(value) {
|
|
17
19
|
return createHash("sha256").update(value).digest("hex");
|
|
18
20
|
}
|
|
@@ -35,6 +37,7 @@ export function installedPackages(root) {
|
|
|
35
37
|
const visited = new Set();
|
|
36
38
|
while (queue.length) {
|
|
37
39
|
const current = queue.shift();
|
|
40
|
+
validatePackageSettings(current.json.spark, current.root);
|
|
38
41
|
const contextualRequire = createRequire(path.join(current.root, current.json.spark?.bundledModuleRoot ?? ".", "package.json"));
|
|
39
42
|
const bundled = current.json.spark?.bundledModules ?? current.json.bundledDependencies ?? current.json.bundleDependencies;
|
|
40
43
|
const names = Object.keys({
|
|
@@ -77,6 +80,8 @@ export function installedPackages(root) {
|
|
|
77
80
|
catch { }
|
|
78
81
|
}
|
|
79
82
|
if (!file || !existsSync(file)) {
|
|
83
|
+
if (current.json.spark?.bundledModules?.includes(name))
|
|
84
|
+
throw new SparkError(`package.json spark.bundledModules includes missing package ${name}`);
|
|
80
85
|
if (current.app &&
|
|
81
86
|
(current.json.dependencies?.[name] || current.json.devDependencies?.[name]))
|
|
82
87
|
throw new Error(`Dependency ${name} is not installed yet. Finish the package installation, then retry.`);
|
|
@@ -337,6 +342,7 @@ export function runtimeFor(root, packages, mode) {
|
|
|
337
342
|
return {
|
|
338
343
|
schema: 1,
|
|
339
344
|
framework: VERSION,
|
|
345
|
+
patchSourceSHA: patchSourceSHA(root),
|
|
340
346
|
platform,
|
|
341
347
|
arch: architecture(platform),
|
|
342
348
|
mode,
|
|
@@ -412,6 +418,7 @@ export function projectEnvironment(root) {
|
|
|
412
418
|
return {
|
|
413
419
|
SPARK_WINDOW_CONFIG: JSON.stringify(nativeWindowOptions(config.extra?.spark?.window ?? {})),
|
|
414
420
|
SPARK_PROJECT_ID: projectId,
|
|
421
|
+
...(typeof config.macos?.bundleIdentifier === "string" ? { SPARK_PROJECT_BUNDLE_IDENTIFIER: config.macos.bundleIdentifier } : {}),
|
|
415
422
|
SPARK_PROJECT_NAME: typeof config.name === "string" ? config.name : path.basename(root),
|
|
416
423
|
SPARK_PROJECT_VERSION: typeof config.version === "string" ? config.version : "0.0.0",
|
|
417
424
|
};
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"revision": "
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"revision": "6daf2825b0db8f7457cb09a2b90f71d2fa8dd356",
|
|
5
5
|
"packages": {
|
|
6
6
|
"@react-native-runtimes/core": {
|
|
7
|
-
"url": "https://github.com/LegendApp/legend-spark/releases/download/v0.0.
|
|
8
|
-
"size":
|
|
9
|
-
"sha256": "
|
|
7
|
+
"url": "https://github.com/LegendApp/legend-spark/releases/download/v0.0.4/runtimes-4df45cb5ea74.tgz",
|
|
8
|
+
"size": 54063,
|
|
9
|
+
"sha256": "307db9a8283e1f3b38e26eacb68bf987d36d4d3470a398547a5507240ff0a1aa"
|
|
10
10
|
},
|
|
11
11
|
"react-native-nitro-modules": {
|
|
12
|
-
"url": "https://github.com/LegendApp/legend-spark/releases/download/v0.0.
|
|
13
|
-
"size":
|
|
14
|
-
"sha256": "
|
|
12
|
+
"url": "https://github.com/LegendApp/legend-spark/releases/download/v0.0.4/react-native-nitro-modules-0.37.0-44c3fb99d6c3.tgz",
|
|
13
|
+
"size": 145645,
|
|
14
|
+
"sha256": "44c3fb99d6c3b6020faad2a267ee4b8c91d7ca485cb09bcd1a65844dc52c0317"
|
|
15
15
|
},
|
|
16
16
|
"@op-engineering/op-sqlite": {
|
|
17
|
-
"url": "https://github.com/LegendApp/legend-spark/releases/download/v0.0.
|
|
18
|
-
"size":
|
|
19
|
-
"sha256": "
|
|
17
|
+
"url": "https://github.com/LegendApp/legend-spark/releases/download/v0.0.4/op-engineering-op-sqlite-18.2.1-fb6a308a316d.tgz",
|
|
18
|
+
"size": 5847611,
|
|
19
|
+
"sha256": "fb6a308a316d9a6604a91d289d5ebede75d42a5a621cd321d967db2ca9591804"
|
|
20
20
|
},
|
|
21
21
|
"react-native-webview": {
|
|
22
|
-
"url": "https://github.com/LegendApp/legend-spark/releases/download/v0.0.
|
|
22
|
+
"url": "https://github.com/LegendApp/legend-spark/releases/download/v0.0.4/react-native-webview-16.0.0-89b78ee0b037.tgz",
|
|
23
23
|
"size": 116285,
|
|
24
|
-
"sha256": "
|
|
24
|
+
"sha256": "89b78ee0b0378e5c2bc77f298ff1e2bbe2a79210d4f2fe27f062c4eea56fa147"
|
|
25
25
|
},
|
|
26
26
|
"expo-audio": {
|
|
27
|
-
"url": "https://github.com/LegendApp/legend-spark/releases/download/v0.0.
|
|
28
|
-
"size":
|
|
29
|
-
"sha256": "
|
|
27
|
+
"url": "https://github.com/LegendApp/legend-spark/releases/download/v0.0.4/expo-audio-55.0.18-87b2ad9f530c.tgz",
|
|
28
|
+
"size": 610157,
|
|
29
|
+
"sha256": "87b2ad9f530c36617bcd6f31d65cd947f39aa2788249667378655c0f6e02a911"
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"runners": {
|
|
33
33
|
"macos-arm64": {
|
|
34
|
-
"url": "https://github.com/LegendApp/legend-spark/releases/download/v0.0.
|
|
35
|
-
"size":
|
|
36
|
-
"sha256": "
|
|
34
|
+
"url": "https://github.com/LegendApp/legend-spark/releases/download/v0.0.4/spark-runner-macos-arm64.zip",
|
|
35
|
+
"size": 13490443,
|
|
36
|
+
"sha256": "e392bb31bf84a40e09e793549ec1f43dc8b01fabf748b65b280a6c9532f70885",
|
|
37
37
|
"app": "SparkRunner.app",
|
|
38
38
|
"teamId": "56DD97VT22",
|
|
39
|
-
"fingerprint": "
|
|
39
|
+
"fingerprint": "4a85a1cf3d2680b2cf5314c75d34154de1f19f58d55a1deedc27fec9fcef7dee"
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -91,7 +91,7 @@ export async function upgrade(root, dryRun = false) {
|
|
|
91
91
|
const updatedCLI = cliRoot(installed);
|
|
92
92
|
const { initializeTemplate } = createRequire(path.join(updatedCLI, "package.json"))("./dist/init-template.cjs");
|
|
93
93
|
const { recordProjectVersion, refreshPointers } = createRequire(path.join(updatedCLI, "package.json"))("./dist/migrations.cjs");
|
|
94
|
-
initializeTemplate(root);
|
|
94
|
+
initializeTemplate(root, false);
|
|
95
95
|
refreshPointers(root);
|
|
96
96
|
recordProjectVersion(root, version);
|
|
97
97
|
console.log(`Updated Spark to ${version}.`);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ensurePatchRegistry } from "@legendapp/spark-desktop-config/patch-registry.cjs";
|
|
1
2
|
import { which, nodeCommand } from "./process.js";
|
|
2
3
|
import { prepareWindowsGeometry } from "./windows-geometry.js";
|
|
3
4
|
import { copyHelpers } from "./helpers.js";
|
|
@@ -48,6 +49,7 @@ export async function preserveWindowsBuildOutputs(root, prepare) {
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
export async function prepareWindows(root, mode) {
|
|
52
|
+
await ensurePatchRegistry(root);
|
|
51
53
|
assertNativePatchPreflight(root);
|
|
52
54
|
await checkExpoDesktopNode(root);
|
|
53
55
|
prepareConfig(root);
|
|
@@ -77,6 +79,7 @@ export async function prepareWindows(root, mode) {
|
|
|
77
79
|
export async function buildWindows(root, mode, force) {
|
|
78
80
|
if (mode !== "go" && mode !== "dev")
|
|
79
81
|
throw new Error("Windows currently supports Spark Runner runtimes and development builds. Use spark build --dev; production builds and packaging are not implemented.");
|
|
82
|
+
await ensurePatchRegistry(root);
|
|
80
83
|
assertNativePatchPreflight(root);
|
|
81
84
|
if (process.platform !== "win32")
|
|
82
85
|
throw new Error("Windows native builds require Windows x64 or ARM64. Project generation and Metro bundle checks can run on macOS.");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -11,15 +11,16 @@
|
|
|
11
11
|
"node": ">=24.19.0"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@legendapp/spark-desktop-config": "0.0.
|
|
14
|
+
"@legendapp/spark-desktop-config": "0.0.4",
|
|
15
15
|
"ws": "8.21.0",
|
|
16
16
|
"expo-desktop": "1.0.6",
|
|
17
17
|
"npm": "11.21.1",
|
|
18
18
|
"typescript": "5.9.3",
|
|
19
19
|
"cross-spawn": "7.0.6",
|
|
20
|
-
"@legendapp/spark-window-options": "0.0.
|
|
20
|
+
"@legendapp/spark-window-options": "0.0.4",
|
|
21
21
|
"diff": "8.0.4",
|
|
22
|
-
"yaml": "2.9.1"
|
|
22
|
+
"yaml": "2.9.1",
|
|
23
|
+
"@legendapp/spark-expo-compat": "0.0.4"
|
|
23
24
|
},
|
|
24
25
|
"private": true
|
|
25
26
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spark-template-blank-typescript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"private": true,
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"postinstall": "node node_modules/@legendapp/spark/init-template.cjs"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@legendapp/spark": "0.0.
|
|
16
|
+
"@legendapp/spark": "0.0.4",
|
|
17
17
|
"expo": "55.0.32",
|
|
18
18
|
"expo-desktop": "1.0.6",
|
|
19
19
|
"expo-desktop-prebuild-config": "1.1.3",
|