@legendapp/spark 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/init-template.cjs +7 -1
- package/package.json +10 -5
- package/patches/dependencies.json +252 -0
- package/patches/expo-application@55.0.19.patch +54 -0
- package/patches/expo-blur@55.0.18.patch +130 -0
- package/patches/expo-device@55.0.21.patch +149 -0
- package/patches/expo-font@55.0.8.patch +55 -0
- package/patches/expo-glass-effect@55.0.11.patch +304 -0
- package/patches/expo-haptics@55.0.18.patch +54 -0
- package/patches/expo-image-manipulator@55.0.21.patch +312 -0
- package/patches/expo-image-picker@55.0.24.patch +327 -0
- package/patches/expo-image@55.0.11.patch +158 -0
- package/patches/expo-keep-awake@55.0.8.patch +41 -0
- package/patches/expo-localization@55.0.19.patch +32 -0
- package/patches/expo-location@55.1.15.patch +190 -0
- package/patches/expo-symbols@55.0.9.patch +286 -0
- package/patches/expo-system-ui@55.0.22.patch +61 -0
- package/patches/expo-web-browser@55.0.20.patch +13 -0
- package/patches/react-native-app-logs@0.3.1.patch +20 -0
- package/patches/react-native-blurhash@2.1.3.patch +318 -0
- package/patches/react-native-community-blur@4.4.1.patch +415 -0
- package/patches/react-native-community-datetimepicker@9.2.2.patch +320 -0
- package/patches/react-native-fast-image@10.9.9.patch +131 -0
- package/patches/react-native-graph@1.4.0.patch +157 -0
- package/patches/react-native-keyboard-controller@1.22.9.patch +16 -0
- package/patches/react-native-masked-view-masked-view@0.3.2.patch +140 -0
- package/patches/react-native-mmkv@4.3.2.patch +40 -0
- package/patches/react-native-nitro-fetch@1.9.0.patch +130 -0
- package/patches/react-native-nitro-zxing@0.3.0.patch +13 -0
- package/patches/react-native-nitro-zxing@0.3.1.patch +22 -0
- package/patches/react-native-quick-base64@3.0.1.patch +13 -0
- package/patches/react-native-quick-crypto@1.1.9.patch +31 -0
- package/patches/react-native-release-profiler@0.4.5.patch +37 -0
- package/patches/react-native-screen-corner-radius@0.2.3.patch +13 -0
- package/patches/react-native-screens@4.23.0.patch +160 -0
- package/patches/react-native-svg@15.15.3.patch +31 -0
- package/patches/react-native-unistyles@3.6.0.patch +203 -0
- package/patches/react-native-worklets-core@1.6.3.patch +13 -0
- package/patches/react-navigation-native-stack@7.21.0.patch +16 -0
- package/patches/registry.json +615 -0
- package/patches/sentry-react-native@8.32.0.patch +76 -0
- package/patches/workspace/expo-audio@55.0.18.patch +159 -0
- package/patches/workspace/op-engineering-op-sqlite@18.2.1.patch +796 -0
- package/patches/workspace/react-native-nitro-modules@0.37.0.patch +1348 -0
- package/patches/workspace/react-native-runtimes-core@0.1.0-alpha.2.patch +276 -0
- package/patches/workspace/react-native-webview@16.0.0.patch +208 -0
- package/postinstall.cjs +10 -1
- package/skills/spark/SKILL.md +37 -4
- package/skills/spark/UPGRADING.md +150 -1
- package/skills/spark/ai-customize.md +39 -0
- package/skills/spark/app-and-documents.md +56 -0
- package/skills/spark/external-libraries.md +87 -0
- package/skills/spark/files.md +64 -0
- package/skills/spark/integrations.md +69 -0
- package/skills/spark/keyboard.md +54 -0
- package/skills/spark/library-compat.md +76 -0
- package/skills/spark/menus-tray-dock.md +83 -0
- package/skills/spark/storage-settings.md +85 -0
- package/skills/spark/ui.md +57 -0
- package/skills/spark/windows.md +91 -0
- package/ui-popover.ts +1 -0
- package/ui-progress.ts +1 -0
- package/ui-sheet.ts +1 -0
- package/ui-split-view.ts +1 -0
- package/ui-table.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-ai/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-audio/package.json +3 -13
- package/vendor/node_modules/@legendapp/spark-auth-session/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +5 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +139 -104
- package/vendor/node_modules/@legendapp/spark-cli/dist/cli-arguments.js +4 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/commands.js +16 -7
- package/vendor/node_modules/@legendapp/spark-cli/dist/dependency-pins.js +19 -3
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev-command.js +2 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev.js +10 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/enriched-html-pins.js +2 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/errors.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/index.js +57 -9
- package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.cjs +12 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.d.cts +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/metro.cjs +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/migrate.js +65 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.cjs +4 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.d.cts +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.cjs +15 -8
- package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +35 -7
- package/vendor/node_modules/@legendapp/spark-cli/dist/patch.js +92 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/project-version.js +12 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +20 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +20 -20
- package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-input-cache.js +140 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/upgrade.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +3 -0
- package/vendor/node_modules/@legendapp/spark-cli/package.json +5 -4
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-clipboard/macos/RNDesktopClipboard.mm +1 -1
- package/vendor/node_modules/@legendapp/spark-clipboard/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-clipboard/src/desktop.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-codex/package.json +3 -7
- package/vendor/node_modules/@legendapp/spark-commands/package.json +5 -5
- package/vendor/node_modules/@legendapp/spark-context-menu/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.h +3 -1
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +51 -10
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.h +4 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.mm +82 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.mm +64 -2
- package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +2 -8
- package/vendor/node_modules/@legendapp/spark-desktop-config/autolinking.cjs +3 -2
- package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +6 -8
- package/vendor/node_modules/@legendapp/spark-desktop-config/identity.cjs +2 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs +315 -68
- package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.d.cts +7 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.cjs +318 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.d.cts +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/validation.cjs +66 -9
- package/vendor/node_modules/@legendapp/spark-desktop-config/windows.plugin.cjs +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.mm +7 -2
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +235 -240
- package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +4 -11
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/api.ts +9 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +7 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/types.ts +32 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/validation.ts +28 -11
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/createWindowsNavigator.tsx +15 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/primaryWindowLifecycle.ts +12 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/usePrimaryWindowLifecycle.ts +2 -1
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/useWindowFocusEffect.ts +4 -1
- package/vendor/node_modules/@legendapp/spark-documents/package.json +7 -7
- package/vendor/node_modules/@legendapp/spark-drag-drop/macos/RNDesktopDragView.mm +77 -17
- package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +3 -8
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/DesktopDragViewNativeComponent.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/contracts.ts +13 -4
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/index.tsx +5 -3
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.h +6 -1
- package/vendor/node_modules/@legendapp/spark-expo-compat/metro.cjs +44 -0
- package/vendor/node_modules/@legendapp/spark-expo-compat/package.json +20 -0
- package/vendor/node_modules/@legendapp/spark-expo-compat/src/clipboard.ts +40 -0
- package/vendor/node_modules/@legendapp/spark-expo-compat/src/document-picker.ts +52 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/options.ts +5 -2
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/types.ts +3 -3
- package/vendor/node_modules/@legendapp/spark-file-system/macos/RNDesktopFileSystem.mm +1 -1
- package/vendor/node_modules/@legendapp/spark-file-system/package.json +3 -11
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-html/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-markdown/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-message-dialog/src/index.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-native-menu/package.json +3 -9
- package/vendor/node_modules/@legendapp/spark-native-menu/src/hooks.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-notifications/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-processes/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-rich-text/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-settings/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +4 -4
- package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-system/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-tray/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-tray/src/index.ts +2 -1
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.mm +82 -14
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.h +1 -1
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.mm +94 -11
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +235 -18
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.h +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.mm +216 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.h +4 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.mm +212 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewUpdates.h +6 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +26 -13
- package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.mm +126 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.mm +66 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.mm +118 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.mm +4 -12
- package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.mm +109 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +418 -102
- package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.mm +179 -0
- package/vendor/node_modules/@legendapp/spark-ui/package.json +9 -8
- package/vendor/node_modules/@legendapp/spark-ui/src/SparkButtonNativeComponent.ts +10 -2
- package/vendor/node_modules/@legendapp/spark-ui/src/SparkTextInputNativeComponent.ts +2 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitView.tsx +99 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitViewNativeComponent.ts +29 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +34 -17
- package/vendor/node_modules/@legendapp/spark-ui/src/availability.ts +5 -4
- package/vendor/node_modules/@legendapp/spark-ui/src/checkbox-unavailable.tsx +20 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/control.ts +24 -3
- package/vendor/node_modules/@legendapp/spark-ui/src/desktop.tsx +63 -13
- package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +12 -7
- package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +12 -7
- package/vendor/node_modules/@legendapp/spark-ui/src/index.web.tsx +35 -13
- package/vendor/node_modules/@legendapp/spark-ui/src/mobile-input.tsx +2 -2
- package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSegmentedControlNativeComponent.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-ui/src/popover/PopoverNativeComponent.ts +20 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/popover/index.tsx +45 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/progress/ProgressIndicatorNativeComponent.ts +13 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/progress/index.tsx +32 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/radio-group/RadioGroupNativeComponent.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sheet/SheetNativeComponent.ts +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sheet/index.tsx +38 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarItemNativeComponent.ts +9 -1
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarNativeComponent.ts +17 -2
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/index.tsx +106 -22
- package/vendor/node_modules/@legendapp/spark-ui/src/table/TableNativeComponent.ts +22 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/table/index.tsx +118 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/types.ts +39 -6
- package/vendor/node_modules/@legendapp/spark-ui/uniwind.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-ui/uniwind.web.ts +2 -1
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.h +46 -15
- package/vendor/node_modules/@legendapp/spark-updates/package.json +3 -9
- package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { realpathSync, statSync, watch } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { installedPackages, nativePackages } from "./project.js";
|
|
5
|
+
import { isExpoProject } from "@legendapp/spark-desktop-config/config.cjs";
|
|
6
|
+
/** Native compatibility inputs stay stable until a source or resolution path changes. */
|
|
7
|
+
export function createRuntimeInputCache(root) {
|
|
8
|
+
let value;
|
|
9
|
+
let dirty = true;
|
|
10
|
+
let disabled = false;
|
|
11
|
+
let watchers = [];
|
|
12
|
+
let resolutionPaths = new Map();
|
|
13
|
+
let observedRoots = "";
|
|
14
|
+
let readiness;
|
|
15
|
+
function identity(location) {
|
|
16
|
+
try {
|
|
17
|
+
const stat = statSync(location, { throwIfNoEntry: false });
|
|
18
|
+
return stat ? `${stat.dev}:${stat.ino}` : null;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (error.code === "ENOTDIR")
|
|
22
|
+
return null;
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function stop() {
|
|
27
|
+
clearImmediate(readiness);
|
|
28
|
+
readiness = undefined;
|
|
29
|
+
for (const watcher of watchers)
|
|
30
|
+
watcher.close();
|
|
31
|
+
watchers = [];
|
|
32
|
+
}
|
|
33
|
+
const invalidate = () => { dirty = true; };
|
|
34
|
+
function fail() {
|
|
35
|
+
disabled = true;
|
|
36
|
+
dirty = true;
|
|
37
|
+
stop();
|
|
38
|
+
}
|
|
39
|
+
const calculate = () => ({ native: nativePackages(root) });
|
|
40
|
+
function observe(installed) {
|
|
41
|
+
const realRoot = realpathSync(root);
|
|
42
|
+
const requested = new Map();
|
|
43
|
+
const add = (location, recursive) => {
|
|
44
|
+
const directory = realpathSync(location);
|
|
45
|
+
requested.set(directory, recursive || requested.get(directory) || false);
|
|
46
|
+
};
|
|
47
|
+
const paths = new Map();
|
|
48
|
+
for (const pkg of [{ root, json: {} }, ...installed]) {
|
|
49
|
+
add(pkg.root, true);
|
|
50
|
+
add(path.dirname(pkg.root), false);
|
|
51
|
+
const context = path.join(pkg.root, pkg.json.spark?.bundledModuleRoot ?? ".", "package.json");
|
|
52
|
+
for (const search of createRequire(context).resolve.paths("__spark_runtime_inputs__") ?? []) {
|
|
53
|
+
if (!paths.has(search)) {
|
|
54
|
+
const current = identity(search);
|
|
55
|
+
paths.set(search, current);
|
|
56
|
+
if (current !== null)
|
|
57
|
+
add(search, true);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const recursiveRoots = [...requested].filter(([, recursive]) => recursive).map(([directory]) => directory);
|
|
62
|
+
const roots = [...requested].filter(([directory]) => !recursiveRoots.some(parent => parent !== directory && directory.startsWith(parent + path.sep)));
|
|
63
|
+
const key = JSON.stringify(roots.map(([directory, recursive]) => [directory, recursive, identity(directory)]));
|
|
64
|
+
if (key === observedRoots) {
|
|
65
|
+
resolutionPaths = paths;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const next = [];
|
|
69
|
+
try {
|
|
70
|
+
for (const [directory, recursive] of roots) {
|
|
71
|
+
const watcher = watch(directory, { recursive }, (_event, filename) => {
|
|
72
|
+
const relative = filename === null ? null : path.relative(realRoot, path.join(directory, String(filename))).split(path.sep).join("/");
|
|
73
|
+
// Session status is output of the check, never an input to it.
|
|
74
|
+
if (relative && /^\.spark\/(?:platforms\/[^/]+\/)?session\.json(?:\.\d+\.tmp)?$/.test(relative))
|
|
75
|
+
return;
|
|
76
|
+
invalidate();
|
|
77
|
+
});
|
|
78
|
+
watcher.on("error", fail);
|
|
79
|
+
next.push(watcher);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
for (const watcher of next)
|
|
84
|
+
watcher.close();
|
|
85
|
+
fail();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
stop();
|
|
89
|
+
watchers = next;
|
|
90
|
+
resolutionPaths = paths;
|
|
91
|
+
observedRoots = key;
|
|
92
|
+
// A watch may start asynchronously. Recheck after its first event-loop turn.
|
|
93
|
+
readiness = setImmediate(() => { readiness = undefined; invalidate(); });
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
invalidate,
|
|
97
|
+
read() {
|
|
98
|
+
// Expo configuration can depend on arbitrary external modules or environment.
|
|
99
|
+
if (disabled || isExpoProject(root))
|
|
100
|
+
return calculate();
|
|
101
|
+
if (!dirty) {
|
|
102
|
+
try {
|
|
103
|
+
// Installs can replace a watched directory before its event is delivered.
|
|
104
|
+
for (const [location, previous] of resolutionPaths) {
|
|
105
|
+
if (identity(location) !== previous) {
|
|
106
|
+
dirty = true;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
fail();
|
|
113
|
+
return calculate();
|
|
114
|
+
}
|
|
115
|
+
if (!dirty)
|
|
116
|
+
return value;
|
|
117
|
+
}
|
|
118
|
+
dirty = false;
|
|
119
|
+
try {
|
|
120
|
+
const installed = installedPackages(root);
|
|
121
|
+
try {
|
|
122
|
+
observe(installed);
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
fail();
|
|
126
|
+
}
|
|
127
|
+
value = calculate();
|
|
128
|
+
// A concurrent graph change needs a fresh set of source watches next poll.
|
|
129
|
+
if (JSON.stringify(installed) !== JSON.stringify(installedPackages(root)))
|
|
130
|
+
dirty = true;
|
|
131
|
+
return value;
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
dirty = true;
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
close() { disabled = true; stop(); },
|
|
139
|
+
};
|
|
140
|
+
}
|
|
@@ -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",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spark-template-universal",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"private": true,
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"react-native-web": "0.21.0",
|
|
42
42
|
"uniwind": "1.6.3",
|
|
43
43
|
"tailwindcss": "4.2.4",
|
|
44
|
-
"@legendapp/spark": "0.0.
|
|
44
|
+
"@legendapp/spark": "0.0.4"
|
|
45
45
|
},
|
|
46
46
|
"overrides": {
|
|
47
47
|
"expo": "55.0.32",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spark-template-windows",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"private": true,
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"react-native-windows": "0.83.2",
|
|
29
29
|
"expo-desktop-modules-core": "55.0.2",
|
|
30
30
|
"expo-desktop-stubs": "55.0.2",
|
|
31
|
-
"@legendapp/spark": "0.0.
|
|
31
|
+
"@legendapp/spark": "0.0.4"
|
|
32
32
|
},
|
|
33
33
|
"overrides": {
|
|
34
34
|
"expo": "55.0.32",
|
|
@@ -70,7 +70,7 @@ RCT_EXPORT_MODULE(NativeDesktopClipboard)
|
|
|
70
70
|
if (item.types.count) [objects addObject:item];
|
|
71
71
|
}
|
|
72
72
|
[board clearContents]; if (objects.count && ![board writeObjects:objects]) { reject(@"E_CLIPBOARD", @"Could not write clipboard", nil); return; }
|
|
73
|
-
resolve(@"null"); return;
|
|
73
|
+
resolve(binary ? NSNull.null : @"null"); return;
|
|
74
74
|
}
|
|
75
75
|
SparkInvalid(reject, @"Unknown clipboard operation");
|
|
76
76
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-clipboard",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"react-native": "src/index",
|
|
@@ -28,20 +28,13 @@
|
|
|
28
28
|
},
|
|
29
29
|
"spark": {
|
|
30
30
|
"sdk": true,
|
|
31
|
-
"nativeModules":
|
|
32
|
-
"NativeDesktopClipboard"
|
|
33
|
-
],
|
|
34
|
-
"pod": "RNDesktopClipboard",
|
|
35
|
-
"platforms": [
|
|
36
|
-
"macos",
|
|
37
|
-
"windows"
|
|
38
|
-
],
|
|
31
|
+
"nativeModules": true,
|
|
39
32
|
"requires": [
|
|
40
33
|
"@legendapp/spark-desktop-app"
|
|
41
34
|
]
|
|
42
35
|
},
|
|
43
36
|
"dependencies": {
|
|
44
|
-
"@legendapp/spark-desktop-app": "0.0.
|
|
37
|
+
"@legendapp/spark-desktop-app": "0.0.4"
|
|
45
38
|
},
|
|
46
39
|
"peerDependenciesMeta": {
|
|
47
40
|
"expo-clipboard": {
|
|
@@ -58,6 +58,7 @@ export async function writeClipboard(content: ClipboardWriteContent): Promise<vo
|
|
|
58
58
|
const files = content.files?.map(path => nativePath(path, Platform.OS));
|
|
59
59
|
const { image, ...rest } = content;
|
|
60
60
|
if (image !== undefined && (!image || image.format !== "png" || !(image.bytes instanceof Uint8Array))) throw new SparkError("E_INVALID_ARGUMENT", "Expected PNG image bytes");
|
|
61
|
+
if (image !== undefined) for (const key of Object.keys(image)) if (key !== "format" && key !== "bytes") throw new SparkError("E_UNSUPPORTED_OPTION", `Unsupported clipboard image option: ${key}`);
|
|
61
62
|
const response = await invokeNative(() => callBinary(native(), "__sparkClipboardBinary", "write", { ...rest, files }, image?.bytes));
|
|
62
63
|
if (response !== null) throw new SparkError("E_INVALID_DATA", "Invalid native clipboard response");
|
|
63
64
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-codex",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"private": true,
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@legendapp/spark-desktop-app": "0.0.
|
|
13
|
+
"@legendapp/spark-desktop-app": "0.0.4",
|
|
14
14
|
"react-native-nitro-modules": "0.37.0"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
@@ -23,11 +23,7 @@
|
|
|
23
23
|
],
|
|
24
24
|
"spark": {
|
|
25
25
|
"sdk": true,
|
|
26
|
-
"nativeModules":
|
|
27
|
-
"pod": "RNCodex",
|
|
28
|
-
"platforms": [
|
|
29
|
-
"macos"
|
|
30
|
-
],
|
|
26
|
+
"nativeModules": true,
|
|
31
27
|
"requires": [
|
|
32
28
|
"react-native-nitro-modules"
|
|
33
29
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-commands",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"private": true,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "src/index.tsx",
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
"src"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@legendapp/spark-ui": "0.0.
|
|
12
|
-
"@legendapp/spark-desktop-shortcuts": "0.0.
|
|
13
|
-
"@legendapp/spark-settings": "0.0.
|
|
11
|
+
"@legendapp/spark-ui": "0.0.4",
|
|
12
|
+
"@legendapp/spark-desktop-shortcuts": "0.0.4",
|
|
13
|
+
"@legendapp/spark-settings": "0.0.4",
|
|
14
14
|
"@legendapp/state": "^3.0.0-beta.42",
|
|
15
|
-
"@legendapp/spark-desktop-app": "0.0.
|
|
15
|
+
"@legendapp/spark-desktop-app": "0.0.4"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"react": "^19.2.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-context-menu",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -28,20 +28,13 @@
|
|
|
28
28
|
},
|
|
29
29
|
"spark": {
|
|
30
30
|
"sdk": true,
|
|
31
|
-
"nativeModules":
|
|
32
|
-
"NativeContextMenu"
|
|
33
|
-
],
|
|
34
|
-
"pod": "RNContextMenu",
|
|
35
|
-
"platforms": [
|
|
36
|
-
"macos",
|
|
37
|
-
"windows"
|
|
38
|
-
],
|
|
31
|
+
"nativeModules": true,
|
|
39
32
|
"requires": [
|
|
40
33
|
"@legendapp/spark-desktop-app"
|
|
41
34
|
]
|
|
42
35
|
},
|
|
43
36
|
"dependencies": {
|
|
44
|
-
"@legendapp/spark-desktop-app": "0.0.
|
|
37
|
+
"@legendapp/spark-desktop-app": "0.0.4"
|
|
45
38
|
},
|
|
46
39
|
"private": true
|
|
47
40
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#import <React/RCTBridgeModule.h>
|
|
4
4
|
|
|
5
5
|
FOUNDATION_EXPORT NSString * const SparkDesktopEvent;
|
|
6
|
-
// Call in applicationWillFinishLaunching:. YES: this process owns the
|
|
6
|
+
// Call in applicationWillFinishLaunching:. YES: this process owns the app's
|
|
7
7
|
// instance. NO: another process does; this one forwards its launch and exits.
|
|
8
8
|
FOUNDATION_EXPORT BOOL SparkAcquireInstance(void);
|
|
9
9
|
// Latched on first call during launch: --spark-safe-mode, or Shift held at launch.
|
|
@@ -15,6 +15,8 @@ FOUNDATION_EXPORT void SparkRelaunch(NSArray<NSString *> *arguments, void (^comp
|
|
|
15
15
|
FOUNDATION_EXPORT NSDictionary *SparkContext(void);
|
|
16
16
|
FOUNDATION_EXPORT NSDictionary *SparkInitialProps(NSString *windowID, NSDictionary *props);
|
|
17
17
|
FOUNDATION_EXPORT NSString *SparkNamespace(void);
|
|
18
|
+
FOUNDATION_EXPORT NSString *SparkStorageNamespace(void);
|
|
19
|
+
FOUNDATION_EXPORT void SparkPrepareStorage(void);
|
|
18
20
|
FOUNDATION_EXPORT void SparkEmit(NSDictionary *event);
|
|
19
21
|
FOUNDATION_EXPORT void SparkOpenURLs(NSArray<NSURL *> *urls);
|
|
20
22
|
FOUNDATION_EXPORT NSArray *SparkPendingURLs(void);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#import "SparkDesktopError.h"
|
|
3
3
|
#import "SparkQuitCoordinator.h"
|
|
4
4
|
#import "SparkInstance.h"
|
|
5
|
+
#import "SparkStorage.h"
|
|
5
6
|
#import "SparkTestDriver.h"
|
|
6
7
|
#import <sys/wait.h>
|
|
7
8
|
#import <CommonCrypto/CommonDigest.h>
|
|
@@ -26,6 +27,14 @@ void SparkInvalid(RCTPromiseRejectBlock reject, NSString *message) { reject(@"E_
|
|
|
26
27
|
void SparkReject(RCTPromiseRejectBlock reject, NSError *error) {
|
|
27
28
|
reject(SparkDesktopErrorCode(error), error.localizedDescription ?: @"Native operation failed", error);
|
|
28
29
|
}
|
|
30
|
+
static NSString *SparkHashedNamespace(NSString *identifier) {
|
|
31
|
+
NSData *data = [identifier dataUsingEncoding:NSUTF8StringEncoding];
|
|
32
|
+
unsigned char hash[CC_SHA256_DIGEST_LENGTH];
|
|
33
|
+
CC_SHA256(data.bytes, (CC_LONG)data.length, hash);
|
|
34
|
+
NSMutableString *result = [NSMutableString stringWithString:@"spark.desktop."];
|
|
35
|
+
for (int i = 0; i < CC_SHA256_DIGEST_LENGTH; i++) [result appendFormat:@"%02x", hash[i]];
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
29
38
|
NSDictionary *SparkContext(void) {
|
|
30
39
|
static NSDictionary *context;
|
|
31
40
|
static dispatch_once_t once;
|
|
@@ -57,14 +66,29 @@ NSDictionary *SparkContext(void) {
|
|
|
57
66
|
});
|
|
58
67
|
return context;
|
|
59
68
|
}
|
|
60
|
-
NSString *SparkNamespace(void) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
NSString *SparkNamespace(void) { return SparkHashedNamespace(SparkContext()[@"projectId"]); }
|
|
70
|
+
static NSString *SparkBundleIdentifier(void) {
|
|
71
|
+
NSString *identifier = NSBundle.mainBundle.bundleIdentifier;
|
|
72
|
+
if (!identifier.length || [identifier containsString:@"/"] || [identifier isEqual:@"."] || [identifier isEqual:@".."]) {
|
|
73
|
+
[NSException raise:NSInvalidArgumentException format:@"Spark requires a valid CFBundleIdentifier"];
|
|
74
|
+
}
|
|
75
|
+
return identifier;
|
|
76
|
+
}
|
|
77
|
+
static NSString *SparkConfiguredBundleIdentifier(void) {
|
|
78
|
+
#if DEBUG
|
|
79
|
+
if ([SparkContext()[@"runtime"][@"mode"] isEqual:@"go"]) return NSProcessInfo.processInfo.environment[@"SPARK_PROJECT_BUNDLE_IDENTIFIER"];
|
|
80
|
+
#endif
|
|
81
|
+
return [NSBundle.mainBundle objectForInfoDictionaryKey:@"SparkDefaultBundleIdentifier"];
|
|
82
|
+
}
|
|
83
|
+
NSString *SparkStorageNamespace(void) {
|
|
84
|
+
NSString *value = [SparkBundleIdentifier() stringByAppendingPathComponent:@"Spark"];
|
|
85
|
+
if ([SparkContext()[@"runtime"][@"mode"] isEqual:@"go"]) value = [value stringByAppendingPathComponent:SparkNamespace()];
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
static NSString *SparkInstanceNamespace(void) {
|
|
89
|
+
NSString *identifier = SparkBundleIdentifier();
|
|
90
|
+
if ([SparkContext()[@"runtime"][@"mode"] isEqual:@"go"]) identifier = [identifier stringByAppendingFormat:@":%@", SparkContext()[@"projectId"]];
|
|
91
|
+
return SparkHashedNamespace(identifier);
|
|
68
92
|
}
|
|
69
93
|
NSDictionary *SparkInitialProps(NSString *windowID, NSDictionary *props) {
|
|
70
94
|
NSMutableDictionary *result = [SparkContext() mutableCopy];
|
|
@@ -153,7 +177,7 @@ static void SparkForwardLaunch(void) {
|
|
|
153
177
|
for (NSURL *url in forwardedURLs) { if (url.isFileURL) [files addObject:url.path]; else [urls addObject:url.absoluteString]; }
|
|
154
178
|
NSDictionary *launch = @{ @"arguments": NSProcessInfo.processInfo.arguments, @"workingDirectory": NSFileManager.defaultManager.currentDirectoryPath ?: @"/", @"files": files, @"urls": urls };
|
|
155
179
|
NSError *error;
|
|
156
|
-
if (!SparkInstanceForward(NSTemporaryDirectory(),
|
|
180
|
+
if (!SparkInstanceForward(NSTemporaryDirectory(), SparkInstanceNamespace(), launch, 10, &error)) SparkLaunchFailed(@"The running app did not accept this launch", error);
|
|
157
181
|
exit(0);
|
|
158
182
|
}];
|
|
159
183
|
}
|
|
@@ -172,6 +196,23 @@ NSDictionary *SparkLaunchState(void) {
|
|
|
172
196
|
return @{ @"safeMode": SparkSafeMode() ? safeModeTrigger : NSNull.null, @"relaunched": @(relaunched),
|
|
173
197
|
@"instance": instanceOwner ? @"primary" : @"test-driver" };
|
|
174
198
|
}
|
|
199
|
+
void SparkPrepareStorage(void) {
|
|
200
|
+
NSError *error = nil;
|
|
201
|
+
NSFileManager *fm = NSFileManager.defaultManager;
|
|
202
|
+
NSURL *base = [fm URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:&error];
|
|
203
|
+
if (!base) SparkLaunchFailed(@"Unable to locate the app storage directory", error);
|
|
204
|
+
NSMutableOrderedSet<NSURL *> *legacy = [NSMutableOrderedSet orderedSetWithObject:[base URLByAppendingPathComponent:SparkNamespace() isDirectory:YES]];
|
|
205
|
+
if (![SparkContext()[@"runtime"][@"mode"] isEqual:@"go"]) {
|
|
206
|
+
NSString *name = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleDisplayName"] ?: [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleName"];
|
|
207
|
+
if ([name containsString:@"/"] || [name isEqual:@"."] || [name isEqual:@".."]) {
|
|
208
|
+
SparkLaunchFailed(@"Unable to migrate legacy app storage", [NSError errorWithDomain:@"SparkStorage" code:1 userInfo:@{ NSLocalizedDescriptionKey: @"The legacy display name must be a single directory name. Migrate its data explicitly." }]);
|
|
209
|
+
}
|
|
210
|
+
if (name.length) [legacy addObject:[base URLByAppendingPathComponent:name isDirectory:YES]];
|
|
211
|
+
}
|
|
212
|
+
SparkMigrateStorage([base URLByAppendingPathComponent:SparkStorageNamespace() isDirectory:YES], legacy.array,
|
|
213
|
+
SparkBundleIdentifier(), SparkConfiguredBundleIdentifier(), &error);
|
|
214
|
+
if (error) SparkLaunchFailed(@"Unable to prepare the app's storage", error);
|
|
215
|
+
}
|
|
175
216
|
BOOL SparkAcquireInstance(void) {
|
|
176
217
|
SparkSafeMode();
|
|
177
218
|
NSString *parent = NSProcessInfo.processInfo.environment[@"SPARK_RELAUNCH_PARENT"];
|
|
@@ -182,7 +223,7 @@ BOOL SparkAcquireInstance(void) {
|
|
|
182
223
|
// The previous instance holds the lock until it exits; it kills this process if its quit is vetoed.
|
|
183
224
|
if (!SparkInstanceWaitForExit(parent.intValue, &error)) SparkLaunchFailed(@"Unable to relaunch", error);
|
|
184
225
|
}
|
|
185
|
-
instanceOwner = SparkInstanceAcquire(NSTemporaryDirectory(),
|
|
226
|
+
instanceOwner = SparkInstanceAcquire(NSTemporaryDirectory(), SparkInstanceNamespace(), ^(NSDictionary *launch) { SparkReceiveLaunch(launch); }, &error);
|
|
186
227
|
if (error) SparkLaunchFailed(@"Unable to establish the app instance lock", error);
|
|
187
228
|
if (!instanceOwner) SparkForwardLaunch();
|
|
188
229
|
return instanceOwner;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#import "SparkStorage.h"
|
|
2
|
+
#import <sys/stdio.h>
|
|
3
|
+
#import <errno.h>
|
|
4
|
+
|
|
5
|
+
static NSString * const SparkStorageOwnerFile = @".spark-bundle-identifier";
|
|
6
|
+
static BOOL SparkStorageFail(NSError **error, NSString *message) {
|
|
7
|
+
if (error) *error = [NSError errorWithDomain:@"SparkStorage" code:1 userInfo:@{ NSLocalizedDescriptionKey: message }];
|
|
8
|
+
return NO;
|
|
9
|
+
}
|
|
10
|
+
static BOOL SparkStorageDirectory(NSURL *url, BOOL *exists, NSError **error) {
|
|
11
|
+
NSDictionary *attributes = [NSFileManager.defaultManager attributesOfItemAtPath:url.path error:error];
|
|
12
|
+
if (!attributes) {
|
|
13
|
+
if ([(*error).domain isEqual:NSCocoaErrorDomain] && ((*error).code == NSFileNoSuchFileError || (*error).code == NSFileReadNoSuchFileError)) { *error = nil; *exists = NO; return YES; }
|
|
14
|
+
return NO;
|
|
15
|
+
}
|
|
16
|
+
*exists = YES;
|
|
17
|
+
return [attributes[NSFileType] isEqual:NSFileTypeDirectory] || SparkStorageFail(error, [@"Expected a storage directory, not a file or symlink: " stringByAppendingString:url.path]);
|
|
18
|
+
}
|
|
19
|
+
static NSString *SparkStorageOwner(NSURL *directory, NSError **error) {
|
|
20
|
+
NSURL *marker = [directory URLByAppendingPathComponent:SparkStorageOwnerFile];
|
|
21
|
+
NSString *owner = [NSString stringWithContentsOfURL:marker encoding:NSUTF8StringEncoding error:error];
|
|
22
|
+
if (!owner && [(*error).domain isEqual:NSCocoaErrorDomain] && (*error).code == NSFileReadNoSuchFileError) *error = nil;
|
|
23
|
+
if (owner && !owner.length) SparkStorageFail(error, [@"Invalid storage owner marker: " stringByAppendingString:marker.path]);
|
|
24
|
+
return owner;
|
|
25
|
+
}
|
|
26
|
+
static BOOL SparkStorageClaim(NSURL *directory, NSString *bundleIdentifier, NSError **error) {
|
|
27
|
+
NSString *owner = SparkStorageOwner(directory, error);
|
|
28
|
+
if (*error) return NO;
|
|
29
|
+
if (!owner) {
|
|
30
|
+
NSFileManager *fm = NSFileManager.defaultManager;
|
|
31
|
+
NSURL *marker = [directory URLByAppendingPathComponent:SparkStorageOwnerFile];
|
|
32
|
+
NSURL *temporary = [directory URLByAppendingPathComponent:[@".spark-owner-" stringByAppendingString:NSUUID.UUID.UUIDString]];
|
|
33
|
+
NSData *data = [bundleIdentifier dataUsingEncoding:NSUTF8StringEncoding];
|
|
34
|
+
if (![data writeToURL:temporary options:NSDataWritingAtomic error:error]) return NO;
|
|
35
|
+
// Link a complete marker without replacing a concurrent owner's claim.
|
|
36
|
+
BOOL claimed = [fm linkItemAtURL:temporary toURL:marker error:error];
|
|
37
|
+
NSError *cleanup;
|
|
38
|
+
if (![fm removeItemAtURL:temporary error:&cleanup]) NSLog(@"Unable to remove storage owner staging file %@: %@", temporary.path, cleanup);
|
|
39
|
+
if (claimed) owner = bundleIdentifier;
|
|
40
|
+
else {
|
|
41
|
+
if (![(*error).domain isEqual:NSCocoaErrorDomain] || (*error).code != NSFileWriteFileExistsError) return NO;
|
|
42
|
+
*error = nil;
|
|
43
|
+
owner = SparkStorageOwner(directory, error);
|
|
44
|
+
if (*error) return NO;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return [owner isEqual:bundleIdentifier] || SparkStorageFail(error, [@"Storage belongs to another bundle: " stringByAppendingString:directory.path]);
|
|
48
|
+
}
|
|
49
|
+
BOOL SparkMigrateStorage(NSURL *destination, NSArray<NSURL *> *legacyDirectories,
|
|
50
|
+
NSString *bundleIdentifier, NSString *configuredIdentifier, NSError **error) {
|
|
51
|
+
NSError *__autoreleasing failure = nil;
|
|
52
|
+
if (!error) error = &failure;
|
|
53
|
+
*error = nil;
|
|
54
|
+
NSFileManager *fm = NSFileManager.defaultManager;
|
|
55
|
+
BOOL exists;
|
|
56
|
+
if (!SparkStorageDirectory(destination, &exists, error)) return NO;
|
|
57
|
+
if (exists) return SparkStorageClaim(destination, bundleIdentifier, error);
|
|
58
|
+
NSURL *source = nil;
|
|
59
|
+
for (NSURL *legacy in legacyDirectories) {
|
|
60
|
+
if ([legacy isEqual:destination]) continue;
|
|
61
|
+
if (!SparkStorageDirectory(legacy, &exists, error)) return NO;
|
|
62
|
+
if (!exists) continue;
|
|
63
|
+
NSString *owner = SparkStorageOwner(legacy, error);
|
|
64
|
+
if (*error) return NO;
|
|
65
|
+
if (!owner && !configuredIdentifier.length)
|
|
66
|
+
return SparkStorageFail(error, @"Unmarked storage needs SparkDefaultBundleIdentifier from a rebuilt custom host, or macos.bundleIdentifier supplied by the current Go CLI. Configure/rebuild the app or migrate explicitly.");
|
|
67
|
+
if (owner ? ![owner isEqual:bundleIdentifier] : ![configuredIdentifier isEqual:bundleIdentifier]) continue;
|
|
68
|
+
if (source) return SparkStorageFail(error, @"Multiple legacy storage directories need migration. Resolve them explicitly before launching the app.");
|
|
69
|
+
source = legacy;
|
|
70
|
+
}
|
|
71
|
+
if (![fm createDirectoryAtURL:destination.URLByDeletingLastPathComponent withIntermediateDirectories:YES attributes:nil error:error]) return NO;
|
|
72
|
+
if (!source) return [fm createDirectoryAtURL:destination withIntermediateDirectories:NO attributes:nil error:error] && SparkStorageClaim(destination, bundleIdentifier, error);
|
|
73
|
+
if ([destination.path hasPrefix:[source.path stringByAppendingString:@"/"]])
|
|
74
|
+
return SparkStorageFail(error, @"Legacy storage contains the destination. Resolve its data layout explicitly before launching the app.");
|
|
75
|
+
if (!SparkStorageClaim(source, bundleIdentifier, error)) return NO;
|
|
76
|
+
// Both paths are in Application Support. Rename the owned folder atomically so
|
|
77
|
+
// clearing the new store cannot resurrect an old snapshot on the next launch.
|
|
78
|
+
if (renamex_np(source.fileSystemRepresentation, destination.fileSystemRepresentation, RENAME_EXCL) == 0) return YES;
|
|
79
|
+
int code = errno;
|
|
80
|
+
*error = [NSError errorWithDomain:NSPOSIXErrorDomain code:code userInfo:@{ NSFilePathErrorKey: source.path }];
|
|
81
|
+
return NO;
|
|
82
|
+
}
|