@legendapp/spark 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/init-template.cjs +7 -1
- package/package.json +11 -6
- 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 +174 -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 +59 -0
- package/skills/spark/ui.md +83 -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 +157 -106
- 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 +15 -8
- package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +35 -7
- package/vendor/node_modules/@legendapp/spark-cli/dist/package.js +4 -8
- 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/publish-directory.js +32 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/release-app.js +139 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +17 -17
- package/vendor/node_modules/@legendapp/spark-cli/dist/signing.js +61 -41
- 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.h +2 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.mm +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +2 -8
- package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.cjs +1 -0
- 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/rpaths.cjs +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/rpaths.d.cts +1 -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 +17 -5
- 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-settings-ui/src/index.tsx +122 -334
- package/vendor/node_modules/@legendapp/spark-settings-ui/src/rows.tsx +183 -0
- 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 +28 -13
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSelect.mm +17 -1
- 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 +438 -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 +6 -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 +72 -20
- package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +18 -12
- package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +21 -15
- package/vendor/node_modules/@legendapp/spark-ui/src/index.web.tsx +40 -16
- 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/native-select/NativeSelectNativeComponent.ts +1 -0
- 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/select.ts +4 -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/switch.tsx +13 -0
- 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 +52 -7
- 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
- /package/{settings-window.ts → ui-settings.ts} +0 -0
|
@@ -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
|
+
}
|
|
@@ -21,6 +21,7 @@ static inline BOOL SparkTestDriverStart(void)
|
|
|
21
21
|
}
|
|
22
22
|
static inline BOOL SparkTestDriverActive(void) { return NO; }
|
|
23
23
|
static inline void SparkTestDriverDidMount(void) {}
|
|
24
|
+
static inline void SparkTestDriverDidReload(void) {}
|
|
24
25
|
static inline BOOL SparkTestDriverEnding(void) { return NO; }
|
|
25
26
|
#else
|
|
26
27
|
|
|
@@ -30,6 +31,7 @@ FOUNDATION_EXPORT BOOL SparkTestDriverStart(void);
|
|
|
30
31
|
FOUNDATION_EXPORT BOOL SparkTestDriverActive(void);
|
|
31
32
|
// The host reports each mounted UI transaction; captures wait until mounts settle.
|
|
32
33
|
FOUNDATION_EXPORT void SparkTestDriverDidMount(void);
|
|
34
|
+
FOUNDATION_EXPORT void SparkTestDriverDidReload(void);
|
|
33
35
|
// YES once the runner's session has ended: that termination is teardown, not a user quit,
|
|
34
36
|
// so the host terminates without running the app's quit guards.
|
|
35
37
|
FOUNDATION_EXPORT BOOL SparkTestDriverEnding(void);
|
|
@@ -33,6 +33,7 @@ static void SparkDriverTerminate(void) { ending = YES; [NSApp terminate:nil]; }
|
|
|
33
33
|
BOOL SparkTestDriverActive(void) { return active; }
|
|
34
34
|
BOOL SparkTestDriverEnding(void) { return ending; }
|
|
35
35
|
void SparkTestDriverDidMount(void) { lastMount = CACurrentMediaTime(); }
|
|
36
|
+
void SparkTestDriverDidReload(void) { lastMount = 0; }
|
|
36
37
|
static NSArray<NSString *> *const SparkBuiltInCommands = @[@"ping", @"navigate", @"openFile", @"waitFor", @"setAppAppearance", @"capture", @"pointerEvents", @"restorePointer", @"quit"];
|
|
37
38
|
static NSMutableDictionary<NSString *, SparkTestDriverHandler> *SparkModuleCommands(void) {
|
|
38
39
|
static NSMutableDictionary *commands;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-desktop-app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"react-native": "src/index",
|
|
@@ -28,13 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"spark": {
|
|
30
30
|
"sdk": false,
|
|
31
|
-
"nativeModules":
|
|
32
|
-
"NativeDesktopApp"
|
|
33
|
-
],
|
|
34
|
-
"pod": "RNDesktopApp",
|
|
35
|
-
"platforms": [
|
|
36
|
-
"macos"
|
|
37
|
-
],
|
|
31
|
+
"nativeModules": true,
|
|
38
32
|
"requires": []
|
|
39
33
|
},
|
|
40
34
|
"private": true
|
|
@@ -92,6 +92,7 @@ module.exports = function withSparkDesktop(config) {
|
|
|
92
92
|
paths: [mod.modRequest.projectRoot],
|
|
93
93
|
})))).replace(/#\{/g, "\\#{");
|
|
94
94
|
mod.modResults.contents = mod.modResults.contents.replaceAll('"#{config[:reactNativePath]}-macos"', macOSPath);
|
|
95
|
+
mod.modResults.contents = require("./rpaths.cjs").stripSwiftToolchainRunpath(mod.modResults.contents);
|
|
95
96
|
const selectionFile = statePath(mod.modRequest.projectRoot, "native-selection.json", "macos");
|
|
96
97
|
const { included, excluded } = fs.existsSync(selectionFile) ? JSON.parse(fs.readFileSync(selectionFile, "utf8")) : { included: [], excluded: [] };
|
|
97
98
|
mod.modResults.contents = require("./autolinking.cjs").excludeNativeModules(mod.modResults.contents, excluded);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
const { validateOwned, validatePlatforms } = require("./validation.cjs");
|
|
1
|
+
const { validateOwned, validatePlatforms, validateSettings } = require("./validation.cjs");
|
|
2
2
|
const fs = require("node:fs");
|
|
3
3
|
const path = require("node:path");
|
|
4
4
|
const { createHash } = require("node:crypto");
|
|
5
|
-
const { validateWindow } = require("@legendapp/spark-window-options");
|
|
6
5
|
const { identity } = require("./identity.cjs");
|
|
7
6
|
const filename = "desktop.config.json";
|
|
8
7
|
const managedConfig = "// Generated by spark: universal Expo configuration";
|
|
@@ -51,7 +50,9 @@ function readConfig(root, target = process.env.SPARK_PLATFORM) {
|
|
|
51
50
|
if (!fs.existsSync(file)) {
|
|
52
51
|
const value = JSON.parse(fs.readFileSync(path.join(root, "app.json"), "utf8"));
|
|
53
52
|
if (!value?.expo || typeof value.expo !== "object" || Array.isArray(value.expo)) throw new Error("app.json needs an expo configuration object");
|
|
54
|
-
|
|
53
|
+
const platforms = validatePlatforms(value.expo.platforms ?? ["macos"]);
|
|
54
|
+
if (value.expo.extra?.spark !== undefined) validateSettings(value.expo.extra.spark, selectTarget(platforms, target));
|
|
55
|
+
return { ...value, expo: { ...value.expo, platforms } };
|
|
55
56
|
}
|
|
56
57
|
const result = toExpo(JSON.parse(fs.readFileSync(file, "utf8")), target);
|
|
57
58
|
return result;
|
|
@@ -93,15 +94,12 @@ function toExpo(value, target) {
|
|
|
93
94
|
for (const key of ["name", "projectId", "version"]) if (typeof value[key] !== "string" || !value[key].trim()) throw new Error(`Desktop config needs ${key}`);
|
|
94
95
|
const platforms = value.platforms ?? ["macos"];
|
|
95
96
|
validatePlatforms(platforms);
|
|
96
|
-
validateOwned(value);
|
|
97
|
+
validateOwned({ macos: value.macos });
|
|
97
98
|
const selected = selectTarget(platforms, target);
|
|
98
99
|
if (platforms.includes("macos") && (!value.macos || typeof value.macos.bundleIdentifier !== "string" || !/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/.test(value.macos.bundleIdentifier))) throw new Error("macos.bundleIdentifier must be a reverse-DNS identifier");
|
|
99
|
-
validateWindow(value.window ?? {});
|
|
100
|
-
if (value.include !== undefined && (!Array.isArray(value.include) || value.include.some(x => typeof x !== "string"))) throw new Error("include must be a list of package names");
|
|
101
|
-
require("./helpers.cjs").validateHelpers(value.helpers);
|
|
102
|
-
require("./customize.cjs").validateCustomize(value.customize);
|
|
103
100
|
const extra = { projectId: value.projectId };
|
|
104
101
|
for (const key of ["window", "documentTypes", "menuBarOnly", "updates", "include", "signing", "helpers", "customize"]) if (value[key] !== undefined) extra[key] = value[key];
|
|
102
|
+
validateSettings(extra, selected);
|
|
105
103
|
const overrides = value.expoByPlatform ?? {};
|
|
106
104
|
if (!overrides || typeof overrides !== "object" || Array.isArray(overrides) || Object.keys(overrides).some(p => !platforms.includes(p))) throw new Error("expoByPlatform keys must be supported platforms");
|
|
107
105
|
const backend = merge(value.expo ?? {}, overrides[selected] ?? {});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { nativeWindowOptions } = require("@legendapp/spark-window-options");
|
|
2
2
|
const { updatePlist } = require("./updates.cjs");
|
|
3
3
|
function identity(config) {
|
|
4
|
+
require("./validation.cjs").validateSettings(config.extra?.spark, "macos");
|
|
4
5
|
const projectId = config.extra?.spark?.projectId ?? config.macos?.bundleIdentifier;
|
|
5
6
|
if (typeof projectId !== "string" || !projectId.length || projectId.length > 200) throw new Error("Set extra.spark.projectId to a stable project identifier");
|
|
6
7
|
const schemes = config.scheme === undefined ? [] : Array.isArray(config.scheme) ? config.scheme : [config.scheme];
|
|
@@ -16,6 +17,7 @@ function identity(config) {
|
|
|
16
17
|
LSUIElement: config.extra?.spark?.menuBarOnly === true,
|
|
17
18
|
SparkMenuBarOnly: config.extra?.spark?.menuBarOnly === true,
|
|
18
19
|
SparkProjectIdentifier: projectId,
|
|
20
|
+
SparkDefaultBundleIdentifier: config.macos?.bundleIdentifier,
|
|
19
21
|
SparkLifecycleConfiguration: require("./lifecycle.cjs").validateLifecycle(config.macos?.lifecycle),
|
|
20
22
|
SparkWindowConfiguration: nativeWindowOptions(config.extra?.spark?.window ?? {}),
|
|
21
23
|
...updatePlist(config),
|