@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,7 +1,9 @@
|
|
|
1
|
+
const { SparkError, validatePackageSettings } = require("./validation.cjs");
|
|
1
2
|
const { createHash } = require("node:crypto");
|
|
2
3
|
const fs = require("node:fs");
|
|
3
4
|
const path = require("node:path");
|
|
4
5
|
const { createRequire } = require("node:module");
|
|
6
|
+
const { sourceFor, selectPatch, assertRegistryVersions, patchDisabled, installedRegistryPackages, readPatch } = require("./patch-registry.cjs");
|
|
5
7
|
|
|
6
8
|
const optionalBackends = ["react-native-enriched-markdown", "react-native-enriched-html", "react-native-webview", "@op-engineering/op-sqlite"];
|
|
7
9
|
const cameraPackages = ["react-native-nitro-image", "react-native-vision-camera"];
|
|
@@ -21,46 +23,269 @@ function resolveManifest(req, name) {
|
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
const hash = bytes => createHash("sha256").update(bytes).digest("hex");
|
|
27
|
+
const warned = new Set();
|
|
28
|
+
function warnOnce(message) {
|
|
29
|
+
if (!warned.has(message)) console.warn(message);
|
|
30
|
+
warned.add(message);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// App patches by convention: patches/<name>@<version>.patch, with + for / in scoped names. patch-package's
|
|
34
|
+
// <name>+<version>.patch files and bun/pnpm patchedDependencies are third-party: the package manager installs them.
|
|
35
|
+
function appPatchEntries(root, app) {
|
|
36
|
+
const patches = [];
|
|
37
|
+
const add = (name, version, file, thirdParty) => {
|
|
38
|
+
patches.push([name, { version, file, thirdParty, bytes: fs.readFileSync(path.join(root, file)) }]);
|
|
39
|
+
};
|
|
40
|
+
const listed = { ...app.pnpm?.patchedDependencies, ...app.patchedDependencies };
|
|
41
|
+
for (const [key, file] of Object.entries(listed)) {
|
|
42
|
+
const at = key.lastIndexOf("@");
|
|
43
|
+
add(at > 0 ? key.slice(0, at) : key, at > 0 ? key.slice(at + 1) : undefined, path.normalize(file), true);
|
|
44
|
+
}
|
|
45
|
+
const files = new Set(Object.values(listed).map(file => path.normalize(file)));
|
|
46
|
+
const directory = path.join(root, "patches");
|
|
47
|
+
// Spark's own repository keeps Spark's patches there, under the same names.
|
|
48
|
+
const appFolder = fs.existsSync(directory) && !fs.existsSync(path.join(directory, "dependencies.json"));
|
|
49
|
+
for (const entry of appFolder ? fs.readdirSync(directory).sort() : []) {
|
|
50
|
+
const file = path.join("patches", entry);
|
|
51
|
+
const own = /^(.+?)@([^@]+)\.patch$/.exec(entry);
|
|
52
|
+
const match = own ?? /^((?:@[^+]+\+)?[^+@]+)\+([^+]+?)(?:\.dev)?(?:\+.*)?\.patch$/.exec(entry);
|
|
53
|
+
if (match && !files.has(file)) add(match[1].replace("+", "/"), match[2], file, !own);
|
|
54
|
+
}
|
|
55
|
+
return patches;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function appPatches(root, app) {
|
|
59
|
+
const patches = {};
|
|
60
|
+
for (const [name, own] of appPatchEntries(root, app)) {
|
|
61
|
+
const error = patches[name] && `Both ${patches[name].file} and ${own.file} patch ${name}; combine them into one.`;
|
|
62
|
+
// patch-package may split one library's patch in several files; that only matters where Spark layers it.
|
|
63
|
+
if (error && !(own.thirdParty && patches[name].thirdParty)) throw new Error(error);
|
|
64
|
+
patches[name] = { ...own, error };
|
|
65
|
+
}
|
|
66
|
+
return patches;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// The receipt rewrites package.json with two-space JSON, so patch hunks target that form without the receipt.
|
|
70
|
+
function withoutReceipt(text) {
|
|
71
|
+
const manifest = JSON.parse(text);
|
|
72
|
+
if (manifest.spark?.dependencyPatch) {
|
|
73
|
+
delete manifest.spark.dependencyPatch;
|
|
74
|
+
delete manifest.spark.sdk;
|
|
75
|
+
delete manifest.spark.requires;
|
|
76
|
+
if (!Object.keys(manifest.spark).length) delete manifest.spark;
|
|
77
|
+
}
|
|
78
|
+
return JSON.stringify(manifest, null, 2) + "\n";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Layers are [Spark's patch, the app's patch], each { text, applied, apply, error }, where applied is the
|
|
82
|
+
// layer's text the package may hold when it differs from text. A file may hold both layers, Spark's alone,
|
|
83
|
+
// the app's alone (installed by a package manager) or neither: undo what it holds, then apply the enabled
|
|
84
|
+
// layers. Every file is verified before any is written.
|
|
85
|
+
function layerPatches(packageRoot, name, layers, { dryRun = false } = {}) {
|
|
86
|
+
const { parsePatch, applyPatch, reversePatch } = require("diff");
|
|
87
|
+
const files = new Map();
|
|
88
|
+
const add = (text, index, kind) => {
|
|
89
|
+
for (const patch of text ? parsePatch(text) : []) {
|
|
90
|
+
let relative = patch.newFileName.replace(/^b\//, "");
|
|
91
|
+
if (relative.startsWith(`node_modules/${name}/`)) relative = relative.slice(`node_modules/${name}/`.length);
|
|
92
|
+
const target = path.resolve(packageRoot, relative);
|
|
93
|
+
if (!target.startsWith(packageRoot + path.sep) || patch.newFileName === "/dev/null") throw new Error(`Invalid native patch target: ${relative}`);
|
|
94
|
+
if (!files.has(relative)) files.set(relative, { target, held: [], patches: [] });
|
|
95
|
+
files.get(relative)[kind][index] = patch;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
layers.forEach((layer, index) => {
|
|
99
|
+
add(layer?.applied ?? layer?.text, index, "held");
|
|
100
|
+
if (layer?.apply) add(layer.text, index, "patches");
|
|
101
|
+
});
|
|
102
|
+
const created = patch => patch?.oldFileName === "/dev/null";
|
|
103
|
+
const undo = (text, patch) => {
|
|
104
|
+
if (text === false || !patch) return text;
|
|
105
|
+
const result = applyPatch(text, reversePatch(patch));
|
|
106
|
+
return created(patch) && result !== "" ? false : result;
|
|
107
|
+
};
|
|
108
|
+
const writes = [];
|
|
109
|
+
for (const [relative, { target, held, patches }] of files) {
|
|
110
|
+
let current = fs.existsSync(target) ? fs.readFileSync(target, "utf8") : "";
|
|
111
|
+
if (relative === "package.json") current = withoutReceipt(current);
|
|
112
|
+
let next = [[0, 1], [0], [1]].map(state => state.reduceRight((text, index) => undo(text, held[index]), current))
|
|
113
|
+
.find(text => text !== false) ?? current;
|
|
114
|
+
layers.forEach((layer, index) => {
|
|
115
|
+
if (!patches[index]) return;
|
|
116
|
+
next = created(patches[index]) && next !== "" ? false : applyPatch(next, patches[index]);
|
|
117
|
+
if (next === false) throw new Error(layer.error(relative));
|
|
118
|
+
});
|
|
119
|
+
if (next !== current) writes.push([target, next === "" && [...held, ...patches].some(created) ? null : next]);
|
|
120
|
+
}
|
|
121
|
+
if (dryRun) return;
|
|
122
|
+
// Rename rather than mutate package-manager cache hardlinks.
|
|
123
|
+
for (const [target, next] of writes) {
|
|
124
|
+
if (next === null) { fs.rmSync(target, { force: true }); continue; }
|
|
125
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
126
|
+
const temporary = `${target}.spark-${process.pid}.tmp`;
|
|
127
|
+
fs.writeFileSync(temporary, next); fs.renameSync(temporary, target);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function stamp(file, installed, update) {
|
|
132
|
+
const manifest = readManifest(file);
|
|
133
|
+
manifest.spark ??= {};
|
|
134
|
+
update(manifest);
|
|
135
|
+
const root = fs.realpathSync(path.dirname(file));
|
|
136
|
+
const pkg = installed.find(pkg => pkg.root === root);
|
|
137
|
+
if (pkg) pkg.json = manifest;
|
|
138
|
+
const serialized = JSON.stringify(manifest, null, 2) + "\n";
|
|
139
|
+
if (fs.readFileSync(file, "utf8") !== serialized) {
|
|
140
|
+
const temporary = `${file}.spark-${process.pid}.tmp`;
|
|
141
|
+
fs.writeFileSync(temporary, serialized); fs.renameSync(temporary, file);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function nativePatchInventory(sparkFile, hasCamera) {
|
|
146
|
+
const spark = readManifest(sparkFile);
|
|
147
|
+
const directory = path.dirname(sparkFile);
|
|
148
|
+
const patchesRoot = spark.spark?.bundledModuleRoot
|
|
149
|
+
? path.join(directory, "patches") : path.resolve(__dirname, "../../patches");
|
|
150
|
+
const pins = {};
|
|
151
|
+
if (hasCamera) {
|
|
152
|
+
const cameraPins = JSON.parse(fs.readFileSync(path.join(patchesRoot, "camera/upstream.json"), "utf8"));
|
|
153
|
+
for (const name of ["react-native-nitro-modules", ...cameraPackages]) {
|
|
154
|
+
pins[name] = { ...cameraPins[name], patch: `camera/${name}.patch`,
|
|
155
|
+
requires: name === "react-native-vision-camera" ? ["react-native-nitro-modules", "react-native-nitro-image"] : ["react-native-nitro-modules"] };
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const integrations = path.join(patchesRoot, "dependencies.json");
|
|
159
|
+
if (fs.existsSync(integrations)) Object.assign(pins, JSON.parse(fs.readFileSync(integrations, "utf8")));
|
|
160
|
+
const source = sourceFor(directory);
|
|
161
|
+
if (source) {
|
|
162
|
+
for (const [name, library] of Object.entries(source.registry.libraries)) {
|
|
163
|
+
if (library.kind === "patch" && (!cameraPackages.includes(name) && name !== "react-native-nitro-modules" || hasCamera)) {
|
|
164
|
+
pins[name] ??= library.versions[0];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return { pins, patchesRoot: source?.directory ?? patchesRoot, source };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Use the same file checks as preparation, but never write patches or receipts into node_modules.
|
|
172
|
+
function appPatchIssues(root) {
|
|
173
|
+
const manifestFile = path.join(root, "package.json");
|
|
174
|
+
if (!fs.existsSync(manifestFile)) return [];
|
|
175
|
+
const app = readManifest(manifestFile);
|
|
176
|
+
if (app.name === "@legendapp/spark") return [];
|
|
177
|
+
const ownPatches = appPatchEntries(root, app);
|
|
178
|
+
if (!ownPatches.length) return [];
|
|
179
|
+
const req = createRequire(manifestFile);
|
|
180
|
+
let inventory;
|
|
181
|
+
try {
|
|
182
|
+
const sparkFile = req.resolve("@legendapp/spark/package.json");
|
|
183
|
+
const dependencies = { ...readManifest(sparkFile).dependencies, ...app.dependencies, ...app.devDependencies, ...app.optionalDependencies };
|
|
184
|
+
inventory = nativePatchInventory(sparkFile, cameraPackages.some(name => dependencies[name]));
|
|
185
|
+
} catch (error) { if (error.code !== "MODULE_NOT_FOUND") throw error; }
|
|
186
|
+
const issues = [];
|
|
187
|
+
for (const [name, own] of ownPatches) {
|
|
188
|
+
const remove = `Remove ${own.file}${own.thirdParty ? " and its package-manager patch declaration (patchedDependencies, if listed)" : ""}`;
|
|
189
|
+
const redo = `${remove}, reinstall ${name}, then run spark patch ${name} to recreate the app patch.`;
|
|
190
|
+
let file;
|
|
191
|
+
try { file = resolveManifest(req, name); }
|
|
192
|
+
catch (error) {
|
|
193
|
+
if (error.code !== "MODULE_NOT_FOUND") throw error;
|
|
194
|
+
issues.push(`${own.file} patches ${name}, which isn't installed.\n Fix: ${remove}, or install ${name}${own.version ? `@${own.version}` : ""}.`);
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
const manifest = readManifest(file);
|
|
198
|
+
if (own.version && own.version !== manifest.version) {
|
|
199
|
+
issues.push(`${own.file} patches ${name}@${own.version}, but ${manifest.version} is installed.\n Fix: ${redo}`);
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
const candidate = inventory?.source?.registry.libraries[name]?.kind === "patch"
|
|
203
|
+
? selectPatch(inventory.source.registry.libraries[name], manifest.version, inventory.source.sparkVersion) : inventory?.pins[name];
|
|
204
|
+
const pin = candidate?.version === manifest.version ? candidate : undefined;
|
|
205
|
+
// Package-manager patches on other libraries remain the package manager's responsibility.
|
|
206
|
+
if (own.thirdParty && !pin) continue;
|
|
207
|
+
const packageRoot = fs.realpathSync(path.dirname(file));
|
|
208
|
+
const enabled = !!pin && app.spark?.patches?.[name] !== false;
|
|
209
|
+
const kept = path.join(packageRoot, ".spark-app.patch");
|
|
210
|
+
try {
|
|
211
|
+
layerPatches(packageRoot, name, [
|
|
212
|
+
pin ? {
|
|
213
|
+
text: (inventory.source ? readPatch(inventory.source, pin) : fs.readFileSync(path.join(inventory.patchesRoot, pin.patch))).toString("utf8"),
|
|
214
|
+
applied: fs.existsSync(path.join(packageRoot, ".spark-base.patch")) ? fs.readFileSync(path.join(packageRoot, ".spark-base.patch"), "utf8") : undefined, apply: enabled,
|
|
215
|
+
error: relative => `${own.file} conflicts with Spark's ${name} patch at ${relative}.`,
|
|
216
|
+
} : undefined,
|
|
217
|
+
{ text: own.bytes.toString("utf8"), applied: fs.existsSync(kept) ? fs.readFileSync(kept, "utf8") : undefined, apply: true,
|
|
218
|
+
error: relative => `${own.file} ${enabled ? `conflicts with Spark's ${name} patch` : "cannot apply"} at ${relative}.` },
|
|
219
|
+
], { dryRun: true });
|
|
220
|
+
} catch (error) { issues.push(`${error.message}\n Fix: ${redo}`); }
|
|
221
|
+
}
|
|
222
|
+
return issues;
|
|
223
|
+
}
|
|
224
|
+
|
|
24
225
|
function prepareNativePatches(root, installed = []) {
|
|
25
226
|
const manifestFile = path.join(root, "package.json");
|
|
26
227
|
if (!fs.existsSync(manifestFile)) return {};
|
|
27
228
|
const app = readManifest(manifestFile);
|
|
28
229
|
if (app.name !== "@legendapp/spark" && !app.dependencies?.["@legendapp/spark"] && !app.devDependencies?.["@legendapp/spark"]) return {};
|
|
230
|
+
validatePackageSettings(app.spark, root);
|
|
231
|
+
assertRegistryVersions(root);
|
|
29
232
|
const appRequire = createRequire(manifestFile);
|
|
30
233
|
let sparkFile;
|
|
31
234
|
try { sparkFile = appRequire.resolve("@legendapp/spark/package.json"); }
|
|
32
235
|
catch (error) { if (error.code === "MODULE_NOT_FOUND") return {}; throw error; }
|
|
33
236
|
const spark = readManifest(sparkFile);
|
|
34
|
-
const directory = path.dirname(sparkFile);
|
|
35
|
-
const patchesRoot = spark.spark?.bundledModuleRoot
|
|
36
|
-
? path.join(directory, "patches") : path.resolve(__dirname, "../../patches");
|
|
37
237
|
const dependencies = { ...spark.dependencies, ...app.dependencies, ...app.devDependencies };
|
|
38
238
|
for (const name of [...cameraPackages, ...optionalBackends]) {
|
|
39
239
|
if (app.optionalDependencies?.[name] || installed.some(pkg => pkg.name === name)) dependencies[name] = true;
|
|
40
240
|
}
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
241
|
+
const currentSource = sourceFor(root);
|
|
242
|
+
const registryPackages = currentSource ? installedRegistryPackages(root, currentSource) : [];
|
|
243
|
+
const hasCamera = cameraPackages.some(name => dependencies[name] || registryPackages.some(pkg => pkg.name === name));
|
|
244
|
+
const { pins, patchesRoot, source } = nativePatchInventory(sparkFile, hasCamera);
|
|
245
|
+
if (source) {
|
|
246
|
+
for (const pkg of registryPackages) {
|
|
247
|
+
if (source.registry.libraries[pkg.name].kind !== "patch" || pkg.name === "react-native-nitro-modules" && !hasCamera) continue;
|
|
248
|
+
dependencies[pkg.name] = true;
|
|
249
|
+
pins[pkg.name] ??= source.registry.libraries[pkg.name].versions[0];
|
|
250
|
+
if (!installed.some(entry => entry.root === pkg.root)) installed.push({ name: pkg.name, root: pkg.root, json: readManifest(pkg.file) });
|
|
48
251
|
}
|
|
49
252
|
}
|
|
50
|
-
const
|
|
51
|
-
if (fs.existsSync(integrations)) Object.assign(pins, JSON.parse(fs.readFileSync(integrations, "utf8")));
|
|
253
|
+
for (const name of Object.keys(app.spark?.patches ?? {})) if (!Object.hasOwn(source?.registry.libraries ?? pins, name)) throw new SparkError(`Unknown package.json spark.patches package: ${name}`, "E_UNSUPPORTED_OPTION");
|
|
52
254
|
const active = Object.keys(pins).filter(name => dependencies[name] ||
|
|
53
255
|
(hasCamera && name === "react-native-nitro-modules") ||
|
|
54
256
|
(dependencies["react-native-vision-camera"] && name === "react-native-nitro-image"));
|
|
55
|
-
|
|
56
|
-
const
|
|
257
|
+
const ownPatches = app.name === "@legendapp/spark" ? {} : appPatches(root, app);
|
|
258
|
+
const appPatch = (name, version) => {
|
|
259
|
+
const own = ownPatches[name];
|
|
260
|
+
if (own?.error) throw new Error(own.error);
|
|
261
|
+
if (own?.version && own.version !== version) throw new Error(`${own.file} patches ${name}@${own.version}, but ${version} is installed. Redo it with spark patch ${name}.`);
|
|
262
|
+
return own;
|
|
263
|
+
};
|
|
264
|
+
// Records which app root's patch an install carries; app roots sharing one install must agree on it.
|
|
265
|
+
const appRoot = (name, packageRoot, manifest, own) => {
|
|
266
|
+
const previous = manifest.spark?.dependencyPatch, appPatchHash = own && hash(own.bytes), self = path.resolve(root);
|
|
267
|
+
if (previous?.appRoot && previous.appRoot !== self && previous.appPatchHash !== appPatchHash) {
|
|
268
|
+
throw new Error(`${name} in ${packageRoot} carries the app patch from ${previous.appRoot}, not ${self}'s. App roots that share one install need one patch set: keep the patch at the shared root and give every app the same file, or reinstall ${name}.`);
|
|
269
|
+
}
|
|
270
|
+
return own && (previous?.appPatchHash === appPatchHash && previous.appRoot || self);
|
|
271
|
+
};
|
|
272
|
+
// The package keeps the app patch it carries, so an edited or removed patch is undone in place.
|
|
273
|
+
const layerApp = (packageRoot, name, spark, own, error) => {
|
|
274
|
+
const kept = path.join(packageRoot, ".spark-app.patch");
|
|
275
|
+
const applied = fs.existsSync(kept) ? fs.readFileSync(kept, "utf8") : undefined;
|
|
276
|
+
const text = own ? own.bytes.toString("utf8") : applied;
|
|
277
|
+
layerPatches(packageRoot, name, [spark, text !== undefined && { text, applied, apply: !!own, error }]);
|
|
278
|
+
if (!own) fs.rmSync(kept, { force: true });
|
|
279
|
+
else if (applied !== text) fs.writeFileSync(kept, own.bytes);
|
|
280
|
+
};
|
|
281
|
+
const layered = new Set(), skipped = new Set();
|
|
57
282
|
const queue = [appRequire, createRequire(sparkFile)].map(req => ({ req, optionalOnly: false }));
|
|
58
|
-
if (hasCamera || optionalBackends.some(name => dependencies[name])) queue.push(...installed.map(pkg => ({ req: createRequire(path.join(pkg.root, "package.json")), optionalOnly: true })));
|
|
283
|
+
if (source || hasCamera || optionalBackends.some(name => dependencies[name])) queue.push(...installed.map(pkg => ({ req: createRequire(path.join(pkg.root, "package.json")), optionalOnly: true })));
|
|
59
284
|
const visited = new Set();
|
|
60
285
|
const packages = {};
|
|
61
286
|
for (const { req, optionalOnly } of queue) {
|
|
62
287
|
for (const name of active) {
|
|
63
|
-
if (optionalOnly && name !== "react-native-nitro-modules" && !cameraPackages.includes(name) && !optionalBackends.includes(name)) continue;
|
|
288
|
+
if (optionalOnly && !source && name !== "react-native-nitro-modules" && !cameraPackages.includes(name) && !optionalBackends.includes(name)) continue;
|
|
64
289
|
let file;
|
|
65
290
|
try { file = resolveManifest(req, name); }
|
|
66
291
|
catch (error) {
|
|
@@ -72,10 +297,13 @@ function prepareNativePatches(root, installed = []) {
|
|
|
72
297
|
if (visited.has(packageRoot)) continue;
|
|
73
298
|
visited.add(packageRoot);
|
|
74
299
|
const manifest = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
75
|
-
const
|
|
300
|
+
const library = source?.registry.libraries[name];
|
|
301
|
+
const pin = library ? selectPatch(library, manifest.version, source.sparkVersion) : pins[name];
|
|
302
|
+
if (!pin && patchDisabled(root, name, file)) { skipped.add(name); continue; }
|
|
303
|
+
if (!pin) throw new Error(`No compatible Spark patch for ${name}@${manifest.version}. Run spark doctor.`);
|
|
76
304
|
if (pin.optional && manifest.version !== pin.version) {
|
|
77
|
-
|
|
78
|
-
|
|
305
|
+
if (patchDisabled(root, name, file)) continue;
|
|
306
|
+
throw new Error(`Spark's desktop patch for ${name} needs ${pin.version}; found ${manifest.version}. Install ${name}@${pin.version}, then retry.`);
|
|
79
307
|
}
|
|
80
308
|
packages[name] = { root: packageRoot };
|
|
81
309
|
queue.push({ req: createRequire(file), optionalOnly });
|
|
@@ -83,61 +311,62 @@ function prepareNativePatches(root, installed = []) {
|
|
|
83
311
|
const owner = readManifest(req.resolve("./package.json"));
|
|
84
312
|
throw new Error(`Spark needs ${name}@${pin.version}; found ${manifest.version} at ${packageRoot}, required by ${owner.name ?? root}. Add an override/resolution for the pinned version.`);
|
|
85
313
|
}
|
|
86
|
-
const bytes = fs.readFileSync(path.join(patchesRoot, pin.patch));
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
314
|
+
const bytes = source ? readPatch(source, pin) : fs.readFileSync(path.join(patchesRoot, pin.patch));
|
|
315
|
+
const own = appPatch(name, manifest.version);
|
|
316
|
+
const ownRoot = appRoot(name, packageRoot, manifest, own);
|
|
317
|
+
const enabled = !patchDisabled(root, name, file);
|
|
318
|
+
const keptSpark = path.join(packageRoot, ".spark-base.patch");
|
|
319
|
+
const appliedSpark = fs.existsSync(keptSpark) ? fs.readFileSync(keptSpark, "utf8") : undefined;
|
|
320
|
+
if (!enabled) warnOnce(`Spark's ${name} patch is disabled by spark.patches in package.json; desktop support for ${name} isn't guaranteed.`);
|
|
321
|
+
if (own?.thirdParty) warnOnce(`Spark applies its ${name} patch first, then ${own.file}.`);
|
|
322
|
+
layerApp(packageRoot, name,
|
|
323
|
+
{ text: bytes.toString("utf8"), applied: appliedSpark, apply: enabled, error: relative => `Cannot apply Spark's ${name} patch to ${relative}. Reinstall dependencies before retrying.` },
|
|
324
|
+
own, relative => `Cannot apply ${own.file} to ${relative}${enabled ? " on top of Spark's patch" : ""}. Redo it with spark patch ${name}.`);
|
|
325
|
+
if (enabled) fs.writeFileSync(keptSpark, bytes);
|
|
326
|
+
else fs.rmSync(keptSpark, { force: true });
|
|
327
|
+
layered.add(name);
|
|
328
|
+
stamp(file, installed, manifest => {
|
|
329
|
+
if (name !== "react-native-nitro-modules" && !pin.optional) {
|
|
330
|
+
manifest.spark.sdk = true;
|
|
331
|
+
manifest.spark.requires = pin.requires ?? [];
|
|
99
332
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
writes.push([target, next]);
|
|
115
|
-
}
|
|
116
|
-
// Verify every file before writing; rename rather than mutate package-manager cache hardlinks.
|
|
117
|
-
for (const [target, next] of writes) {
|
|
118
|
-
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
119
|
-
const temporary = `${target}.spark-${process.pid}.tmp`;
|
|
120
|
-
fs.writeFileSync(temporary, next); fs.renameSync(temporary, target);
|
|
121
|
-
}
|
|
122
|
-
const patched = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
123
|
-
patched.spark ??= {};
|
|
124
|
-
if (name !== "react-native-nitro-modules" && !pin.optional) {
|
|
125
|
-
patched.spark.sdk = true;
|
|
126
|
-
patched.spark.requires = pin.requires ?? [];
|
|
127
|
-
}
|
|
128
|
-
patched.spark.dependencyPatch = { schema: 1, version: pin.version,
|
|
129
|
-
patchHash: createHash("sha256").update(bytes).digest("hex"), upstreamIntegrity: pin.integrity };
|
|
130
|
-
const pkg = installed.find(pkg => pkg.root === packageRoot);
|
|
131
|
-
if (pkg) pkg.json = patched;
|
|
132
|
-
const serialized = JSON.stringify(patched, null, 2) + "\n";
|
|
133
|
-
if (fs.readFileSync(file, "utf8") !== serialized) {
|
|
134
|
-
const temporary = `${file}.spark-${process.pid}.tmp`;
|
|
135
|
-
fs.writeFileSync(temporary, serialized); fs.renameSync(temporary, file);
|
|
136
|
-
}
|
|
333
|
+
manifest.spark.dependencyPatch = { schema: 1, version: pin.version, patchHash: enabled ? hash(bytes) : undefined,
|
|
334
|
+
appPatchHash: own && hash(own.bytes), appRoot: ownRoot, upstreamIntegrity: pin.integrity };
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
// App patches for libraries Spark doesn't patch apply alone; package managers own their own patches.
|
|
339
|
+
for (const [name, own] of Object.entries(ownPatches)) {
|
|
340
|
+
if (own.thirdParty || layered.has(name)) continue;
|
|
341
|
+
let file;
|
|
342
|
+
try { file = resolveManifest(appRequire, name); }
|
|
343
|
+
catch (error) {
|
|
344
|
+
if (error.code !== "MODULE_NOT_FOUND") throw error;
|
|
345
|
+
warnOnce(`${own.file} patches ${name}, which isn't installed.`);
|
|
346
|
+
continue;
|
|
137
347
|
}
|
|
348
|
+
const manifest = readManifest(file), { version } = manifest, packageRoot = fs.realpathSync(path.dirname(file));
|
|
349
|
+
appPatch(name, version);
|
|
350
|
+
const ownRoot = appRoot(name, packageRoot, manifest, own);
|
|
351
|
+
layerApp(packageRoot, name, undefined, own, relative => `Cannot apply ${own.file} to ${relative}. Reinstall dependencies or redo it with spark patch ${name}.`);
|
|
352
|
+
stamp(file, installed, manifest => { manifest.spark.dependencyPatch = { schema: 1, version, appPatchHash: hash(own.bytes), appRoot: ownRoot }; });
|
|
353
|
+
}
|
|
354
|
+
// Undo app patches the app removed from libraries Spark doesn't patch.
|
|
355
|
+
for (const name of Object.keys({ ...app.dependencies, ...app.devDependencies })) {
|
|
356
|
+
if (ownPatches[name] || layered.has(name)) continue;
|
|
357
|
+
let file;
|
|
358
|
+
try { file = resolveManifest(appRequire, name); } catch { continue; }
|
|
359
|
+
if (!fs.existsSync(path.join(path.dirname(file), ".spark-app.patch"))) continue;
|
|
360
|
+
const packageRoot = fs.realpathSync(path.dirname(file));
|
|
361
|
+
appRoot(name, packageRoot, readManifest(file));
|
|
362
|
+
layerApp(packageRoot, name);
|
|
363
|
+
stamp(file, installed, manifest => {
|
|
364
|
+
delete manifest.spark.dependencyPatch;
|
|
365
|
+
if (!Object.keys(manifest.spark).length) delete manifest.spark;
|
|
366
|
+
});
|
|
138
367
|
}
|
|
139
368
|
for (const name of active) {
|
|
140
|
-
if (!packages[name] && !pins[name].optional) throw new Error(`Spark needs ${name}@${pins[name].version}. Finish installing dependencies before native preparation.`);
|
|
369
|
+
if (!packages[name] && !skipped.has(name) && !pins[name].optional && app.spark?.patches?.[name] !== false) throw new Error(`Spark needs ${name}@${pins[name].version}. Finish installing dependencies before native preparation.`);
|
|
141
370
|
}
|
|
142
371
|
return packages;
|
|
143
372
|
}
|
|
@@ -156,4 +385,4 @@ function removeExpoApplicationAlias(rn, expo) {
|
|
|
156
385
|
fs.renameSync(temporary, file); // Preserve package-manager cache hardlinks.
|
|
157
386
|
}
|
|
158
387
|
|
|
159
|
-
module.exports = { prepareNativePatches, removeExpoApplicationAlias };
|
|
388
|
+
module.exports = { appPatchIssues, prepareNativePatches, removeExpoApplicationAlias, appPatches, layerPatches, resolveManifest, withoutReceipt };
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
export function prepareNativePatches(root: string, installed?: { name: string; root: string; json: any }[]): Record<string, { root: string }>;
|
|
2
2
|
export function removeExpoApplicationAlias(reactNativeMacOSRoot: string, expoModulesCoreRoot: string): void;
|
|
3
|
+
export type AppPatch = { version?: string; file: string; thirdParty: boolean; error?: string; bytes: Buffer };
|
|
4
|
+
export function appPatches(root: string, app: any): Record<string, AppPatch>;
|
|
5
|
+
export type PatchLayer = { text: string; applied?: string; apply: boolean; error(relative: string): string } | undefined;
|
|
6
|
+
export function layerPatches(packageRoot: string, name: string, layers: PatchLayer[], options?: { dryRun?: boolean }): void;
|
|
7
|
+
export function resolveManifest(req: NodeJS.Require, name: string): string;
|
|
8
|
+
export function withoutReceipt(manifest: string): string;
|
|
9
|
+
export function appPatchIssues(root: string): string[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-desktop-config",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "app.plugin.cjs",
|
|
6
6
|
"files": [
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"expo-desktop-config-plugins": "1.3.2",
|
|
14
|
-
"@legendapp/spark-desktop-host": "0.0.
|
|
15
|
-
"@legendapp/spark-window-options": "0.0.
|
|
14
|
+
"@legendapp/spark-desktop-host": "0.0.4",
|
|
15
|
+
"@legendapp/spark-window-options": "0.0.4",
|
|
16
16
|
"@expo/config-plugins": "55.0.12",
|
|
17
17
|
"diff": "8.0.4"
|
|
18
18
|
},
|