@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,276 @@
|
|
|
1
|
+
diff --git a/NativeComposeThreadedRuntime.podspec b/NativeComposeThreadedRuntime.podspec
|
|
2
|
+
index 40210f6..c6596e7 100644
|
|
3
|
+
--- a/NativeComposeThreadedRuntime.podspec
|
|
4
|
+
+++ b/NativeComposeThreadedRuntime.podspec
|
|
5
|
+
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
|
|
6
|
+
s.license = "MIT"
|
|
7
|
+
s.authors = "Native Compose"
|
|
8
|
+
|
|
9
|
+
- s.platforms = { :ios => min_ios_version_supported }
|
|
10
|
+
+ s.platforms = { :ios => min_ios_version_supported, :osx => "14.0" }
|
|
11
|
+
s.source = { :git => "https://github.com/react-native-runtimes/core.git", :tag => "#{s.version}" }
|
|
12
|
+
|
|
13
|
+
s.source_files = [
|
|
14
|
+
diff --git a/ios/ThreadedRuntime.mm b/ios/ThreadedRuntime.mm
|
|
15
|
+
index a8f28db..7a29500 100644
|
|
16
|
+
--- a/ios/ThreadedRuntime.mm
|
|
17
|
+
+++ b/ios/ThreadedRuntime.mm
|
|
18
|
+
@@ -1,3 +1,4 @@
|
|
19
|
+
+#include "../cpp/nativecompose/threadedruntime/RuntimeFunctionScheduler.h"
|
|
20
|
+
#import "ThreadedRuntime.h"
|
|
21
|
+
|
|
22
|
+
#import <React/RCTConvert.h>
|
|
23
|
+
@@ -609,6 +610,7 @@ + (void)destroyRuntime:(NSString *)runtimeName
|
|
24
|
+
resultJson:nil
|
|
25
|
+
errorJson:ThreadedRuntimeErrorJson(message)];
|
|
26
|
+
}
|
|
27
|
+
+ nativecompose::threadedruntime::unregisterRuntimeDispatcher(normalizedRuntimeName.UTF8String);
|
|
28
|
+
[ThreadedRuntimeHosts() removeObjectForKey:normalizedRuntimeName];
|
|
29
|
+
[ThreadedRuntimeHostDelegates() removeObjectForKey:normalizedRuntimeName];
|
|
30
|
+
[ThreadedRuntimeTurboModuleDelegates() removeObjectForKey:normalizedRuntimeName];
|
|
31
|
+
@@ -619,6 +621,7 @@ + (void)destroyRuntime:(NSString *)runtimeName
|
|
32
|
+
|
|
33
|
+
+ (void)destroyAllRuntimes
|
|
34
|
+
{
|
|
35
|
+
+ for (NSString *name in [self runtimeNames]) [self destroyRuntime:name];
|
|
36
|
+
[ThreadedRuntimeHosts() removeAllObjects];
|
|
37
|
+
[ThreadedRuntimeHostDelegates() removeAllObjects];
|
|
38
|
+
[ThreadedRuntimeTurboModuleDelegates() removeAllObjects];
|
|
39
|
+
diff --git a/ios/ThreadedRuntimeSurfaceManager.mm b/ios/ThreadedRuntimeSurfaceManager.mm
|
|
40
|
+
index 5e13760..fdc7d84 100644
|
|
41
|
+
--- a/ios/ThreadedRuntimeSurfaceManager.mm
|
|
42
|
+
+++ b/ios/ThreadedRuntimeSurfaceManager.mm
|
|
43
|
+
@@ -9,7 +9,11 @@ @implementation ThreadedRuntimeSurfaceManager
|
|
44
|
+
|
|
45
|
+
RCT_EXPORT_MODULE(ThreadedRuntimeSurface)
|
|
46
|
+
|
|
47
|
+
+#if TARGET_OS_OSX
|
|
48
|
+
+- (NSView *)view
|
|
49
|
+
+#else
|
|
50
|
+
- (UIView *)view
|
|
51
|
+
+#endif
|
|
52
|
+
{
|
|
53
|
+
return [ThreadedRuntimeSurfaceView new];
|
|
54
|
+
}
|
|
55
|
+
diff --git a/ios/ThreadedRuntimeSurfaceView.h b/ios/ThreadedRuntimeSurfaceView.h
|
|
56
|
+
index 9c1d205..f528c39 100644
|
|
57
|
+
--- a/ios/ThreadedRuntimeSurfaceView.h
|
|
58
|
+
+++ b/ios/ThreadedRuntimeSurfaceView.h
|
|
59
|
+
@@ -1,8 +1,17 @@
|
|
60
|
+
+#import <TargetConditionals.h>
|
|
61
|
+
+#if TARGET_OS_OSX
|
|
62
|
+
+#import <React/RCTUIKit.h>
|
|
63
|
+
+#else
|
|
64
|
+
#import <UIKit/UIKit.h>
|
|
65
|
+
+#endif
|
|
66
|
+
|
|
67
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
68
|
+
|
|
69
|
+
+#if TARGET_OS_OSX
|
|
70
|
+
+@interface ThreadedRuntimeSurfaceView : RCTUIView
|
|
71
|
+
+#else
|
|
72
|
+
@interface ThreadedRuntimeSurfaceView : UIView
|
|
73
|
+
+#endif
|
|
74
|
+
|
|
75
|
+
@property (nonatomic, copy) NSString *appName;
|
|
76
|
+
@property (nonatomic, copy) NSString *blockStatus;
|
|
77
|
+
diff --git a/ios/ThreadedRuntimeSurfaceView.mm b/ios/ThreadedRuntimeSurfaceView.mm
|
|
78
|
+
index 0764a63..ff00d43 100644
|
|
79
|
+
--- a/ios/ThreadedRuntimeSurfaceView.mm
|
|
80
|
+
+++ b/ios/ThreadedRuntimeSurfaceView.mm
|
|
81
|
+
@@ -26,7 +26,9 @@ - (instancetype)initWithFrame:(CGRect)frame
|
|
82
|
+
_mode = @"";
|
|
83
|
+
_runtimeName = ThreadedRuntimeSurfaceDefaultRuntimeName;
|
|
84
|
+
_surfaceKey = @"";
|
|
85
|
+
+#if !TARGET_OS_OSX
|
|
86
|
+
self.backgroundColor = UIColor.clearColor;
|
|
87
|
+
+#endif
|
|
88
|
+
}
|
|
89
|
+
return self;
|
|
90
|
+
}
|
|
91
|
+
@@ -196,7 +198,14 @@ - (void)ensureSurface
|
|
92
|
+
_surfaceView = [[RCTSurfaceHostingView alloc] initWithSurface:_surface
|
|
93
|
+
sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact |
|
|
94
|
+
RCTSurfaceSizeMeasureModeHeightExact];
|
|
95
|
+
+#if TARGET_OS_OSX
|
|
96
|
+
+ // RCTSurfaceHostingView starts white. RCTUIView copies a background color over drawRect:'s rect, which on macOS is
|
|
97
|
+
+ // not clipped to the view: it can be the enclosing clip view's whole visible rect. Any color, clear included, then
|
|
98
|
+
+ // covers or erases a ScrollView's content around the surface, so on macOS neither view has one (nil draws nothing).
|
|
99
|
+
+ _surfaceView.backgroundColor = nil;
|
|
100
|
+
+#else
|
|
101
|
+
_surfaceView.backgroundColor = UIColor.clearColor;
|
|
102
|
+
+#endif
|
|
103
|
+
_surfaceView.frame = self.bounds;
|
|
104
|
+
[self addSubview:_surfaceView];
|
|
105
|
+
[_surface setSize:self.bounds.size];
|
|
106
|
+
diff --git a/metro.js b/metro.js
|
|
107
|
+
index 364b9a5..187b9ed 100644
|
|
108
|
+
--- a/metro.js
|
|
109
|
+
+++ b/metro.js
|
|
110
|
+
@@ -175,6 +175,7 @@ function generateThreadedRuntimeEntry({
|
|
111
|
+
generatedEntry,
|
|
112
|
+
projectRoot = process.cwd(),
|
|
113
|
+
roots = ['App.tsx', 'src'],
|
|
114
|
+
+ runtimeEntries: selectedRuntimeEntries,
|
|
115
|
+
}) {
|
|
116
|
+
const root = path.resolve(projectRoot);
|
|
117
|
+
const files = collectSourceFiles(root, roots);
|
|
118
|
+
@@ -182,7 +183,7 @@ function generateThreadedRuntimeEntry({
|
|
119
|
+
const runtimeFunctions = files.flatMap(file =>
|
|
120
|
+
scanRuntimeFunctions(file, root),
|
|
121
|
+
);
|
|
122
|
+
- const runtimeEntries = collectRuntimeEntryFiles(root);
|
|
123
|
+
+ const runtimeEntries = selectedRuntimeEntries ?? collectRuntimeEntryFiles(root);
|
|
124
|
+
const seenNames = new Map();
|
|
125
|
+
const seenRuntimeFunctionIds = new Map();
|
|
126
|
+
|
|
127
|
+
diff --git a/package.json b/package.json
|
|
128
|
+
index 1fea5aa..5b5ffea 100644
|
|
129
|
+
--- a/package.json
|
|
130
|
+
+++ b/package.json
|
|
131
|
+
@@ -48,8 +48,8 @@
|
|
132
|
+
"url": "https://github.com/Szymon20000/react-native-runtimes.git",
|
|
133
|
+
"directory": "packages/core"
|
|
134
|
+
},
|
|
135
|
+
- "main": "lib/index.js",
|
|
136
|
+
- "types": "lib/index.d.ts",
|
|
137
|
+
+ "main": "src/index.ts",
|
|
138
|
+
+ "types": "src/index.ts",
|
|
139
|
+
"react-native": "src/index.ts",
|
|
140
|
+
"source": "src/index.ts",
|
|
141
|
+
"expo": {
|
|
142
|
+
@@ -83,7 +83,9 @@
|
|
143
|
+
"plugin/build",
|
|
144
|
+
"README.md",
|
|
145
|
+
"runtime-function-babel-plugin.js",
|
|
146
|
+
- "src"
|
|
147
|
+
+ "src",
|
|
148
|
+
+ "windows",
|
|
149
|
+
+ "react-native.config.js"
|
|
150
|
+
],
|
|
151
|
+
"typesVersions": {
|
|
152
|
+
"*": {
|
|
153
|
+
@@ -114,5 +116,15 @@
|
|
154
|
+
},
|
|
155
|
+
"engines": {
|
|
156
|
+
"node": ">=18.0.0"
|
|
157
|
+
+ },
|
|
158
|
+
+ "spark": {
|
|
159
|
+
+ "sdk": true,
|
|
160
|
+
+ "upstreamRevision": "58710c25c6e505dcc1292ee54d855408a6f7a42d",
|
|
161
|
+
+ "patchHash": "985164a87eb04010a8d849f5b0ca22a76548dc3f73a64a6183683ca90932ec2c"
|
|
162
|
+
+ },
|
|
163
|
+
+ "dependencies": {
|
|
164
|
+
+ "@babel/parser": "7.28.5",
|
|
165
|
+
+ "@babel/traverse": "7.28.5",
|
|
166
|
+
+ "react-native-nitro-modules": "0.37.0"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
diff --git a/react-native.config.js b/react-native.config.js
|
|
170
|
+
new file mode 100644
|
|
171
|
+
index 0000000..2737a4a
|
|
172
|
+
--- /dev/null
|
|
173
|
+
+++ b/react-native.config.js
|
|
174
|
+
@@ -0,0 +1 @@
|
|
175
|
+
+module.exports = { dependency: { platforms: { windows: null } } };
|
|
176
|
+
diff --git a/src/NativeThreadedRuntimeSurface.windows.tsx b/src/NativeThreadedRuntimeSurface.windows.tsx
|
|
177
|
+
new file mode 100644
|
|
178
|
+
index 0000000..0fa719e
|
|
179
|
+
--- /dev/null
|
|
180
|
+
+++ b/src/NativeThreadedRuntimeSurface.windows.tsx
|
|
181
|
+
@@ -0,0 +1,12 @@
|
|
182
|
+
+import React, { useState } from 'react';
|
|
183
|
+
+import { NativeModules, requireNativeComponent, Text, View, type NativeSyntheticEvent } from 'react-native';
|
|
184
|
+
+import type { NativeProps } from './NativeThreadedRuntimeSurface';
|
|
185
|
+
+export type { NativeProps } from './NativeThreadedRuntimeSurface';
|
|
186
|
+
+const Surface = requireNativeComponent<NativeProps & { onRuntimeError?: (event: NativeSyntheticEvent<{ message: string }>) => void }>('ThreadedRuntimeSurface');
|
|
187
|
+
+export default function ThreadedRuntimeSurface(props: NativeProps) {
|
|
188
|
+
+ const [failure, setFailure] = useState('');
|
|
189
|
+
+ if (!NativeModules.ThreadedRuntime || failure) return <View style={props.style} testID={props.testID} accessibilityLabel={props.accessibilityLabel}>
|
|
190
|
+
+ <Text>Threaded surface unavailable: {failure || 'Rebuild the desktop runtime with Runtimes included.'}</Text>
|
|
191
|
+
+ </View>;
|
|
192
|
+
+ return <Surface {...props} onRuntimeError={event => setFailure(event.nativeEvent.message)} />;
|
|
193
|
+
+}
|
|
194
|
+
diff --git a/src/ThreadedRuntime.tsx b/src/ThreadedRuntime.tsx
|
|
195
|
+
index 2d9c936..a7917d0 100644
|
|
196
|
+
--- a/src/ThreadedRuntime.tsx
|
|
197
|
+
+++ b/src/ThreadedRuntime.tsx
|
|
198
|
+
@@ -185,6 +185,7 @@ function callRuntimeFunctionBinding(functionId: string, argsJson: string) {
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function getRuntimeFunctionsNitro() {
|
|
202
|
+
+ if (Platform.OS === "windows") return null; // RNW uses the upstream native-call transport.
|
|
203
|
+
if (runtimeFunctionsNitro !== undefined) {
|
|
204
|
+
return runtimeFunctionsNitro;
|
|
205
|
+
}
|
|
206
|
+
@@ -686,7 +687,7 @@ function prewarmRuntime(
|
|
207
|
+
runtimeName: ThreadedRuntimeName = DEFAULT_RUNTIME_NAME,
|
|
208
|
+
options: ThreadedRuntimePrewarmOptions = {},
|
|
209
|
+
) {
|
|
210
|
+
- if (Platform.OS !== 'android' && Platform.OS !== 'ios') {
|
|
211
|
+
+ if (!['android', 'ios', 'macos', 'windows'].includes(Platform.OS)) {
|
|
212
|
+
return Promise.resolve();
|
|
213
|
+
}
|
|
214
|
+
const kind = options.kind ?? DEFAULT_RUNTIME_KIND;
|
|
215
|
+
@@ -736,7 +737,7 @@ export const ThreadedRuntime = {
|
|
216
|
+
taskName: string,
|
|
217
|
+
options: ThreadedHeadlessTaskOptions<Payload> = {},
|
|
218
|
+
) {
|
|
219
|
+
- if (Platform.OS !== 'android' && Platform.OS !== 'ios') {
|
|
220
|
+
+ if (!['android', 'ios', 'macos', 'windows'].includes(Platform.OS)) {
|
|
221
|
+
return Promise.resolve();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@@ -759,7 +760,7 @@ export const ThreadedRuntime = {
|
|
225
|
+
fn: RuntimeFunction<TFunction>,
|
|
226
|
+
...args: Parameters<TFunction>
|
|
227
|
+
): Promise<Awaited<ReturnType<TFunction>>> {
|
|
228
|
+
- if (Platform.OS !== 'android' && Platform.OS !== 'ios') {
|
|
229
|
+
+ if (!['android', 'ios', 'macos', 'windows'].includes(Platform.OS)) {
|
|
230
|
+
return Promise.resolve(fn(...args)) as Promise<
|
|
231
|
+
Awaited<ReturnType<TFunction>>
|
|
232
|
+
>;
|
|
233
|
+
@@ -829,21 +830,21 @@ export const ThreadedRuntime = {
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
destroy(runtimeName: ThreadedRuntimeName = DEFAULT_RUNTIME_NAME) {
|
|
237
|
+
- if (Platform.OS !== 'android' && Platform.OS !== 'ios') {
|
|
238
|
+
+ if (!['android', 'ios', 'macos', 'windows'].includes(Platform.OS)) {
|
|
239
|
+
return Promise.resolve();
|
|
240
|
+
}
|
|
241
|
+
return nativeRuntime?.destroyRuntime?.(runtimeName) ?? Promise.resolve();
|
|
242
|
+
},
|
|
243
|
+
|
|
244
|
+
destroyAll() {
|
|
245
|
+
- if (Platform.OS !== 'android' && Platform.OS !== 'ios') {
|
|
246
|
+
+ if (!['android', 'ios', 'macos', 'windows'].includes(Platform.OS)) {
|
|
247
|
+
return Promise.resolve();
|
|
248
|
+
}
|
|
249
|
+
return nativeRuntime?.destroyAllRuntimes?.() ?? Promise.resolve();
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
getRuntimeNames() {
|
|
253
|
+
- if (Platform.OS !== 'android' && Platform.OS !== 'ios') {
|
|
254
|
+
+ if (!['android', 'ios', 'macos', 'windows'].includes(Platform.OS)) {
|
|
255
|
+
return Promise.resolve([] as string[]);
|
|
256
|
+
}
|
|
257
|
+
return (
|
|
258
|
+
@@ -859,7 +860,10 @@ const registerCallableModule =
|
|
259
|
+
) => void;
|
|
260
|
+
|
|
261
|
+
function installThreadedRuntimeEventEmitterFallback() {
|
|
262
|
+
- if (Platform.OS !== 'ios' || didInstallThreadedRuntimeEventEmitterFallback) {
|
|
263
|
+
+ // A headless worker has no renderer. Never replace the main renderer's event
|
|
264
|
+
+ // receiver when this module is imported after the UI is already mounted.
|
|
265
|
+
+ if (isMainRuntime()) return;
|
|
266
|
+
+ if (!['ios', 'macos'].includes(Platform.OS) || didInstallThreadedRuntimeEventEmitterFallback) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
diff --git a/windows/README.md b/windows/README.md
|
|
271
|
+
new file mode 100644
|
|
272
|
+
index 0000000..9aca0c8
|
|
273
|
+
--- /dev/null
|
|
274
|
+
+++ b/windows/README.md
|
|
275
|
+
@@ -0,0 +1 @@
|
|
276
|
+
+Windows native implementation lives in @legendapp/spark-desktop-host/windows/runtimes.inc.
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
diff --git a/package.json b/package.json
|
|
2
|
+
index 7310e4e..46dd0b7 100644
|
|
3
|
+
--- a/package.json
|
|
4
|
+
+++ b/package.json
|
|
5
|
+
@@ -114,5 +114,9 @@
|
|
6
|
+
"rn-docs": {
|
|
7
|
+
"title": "Webview",
|
|
8
|
+
"type": "Component"
|
|
9
|
+
+ },
|
|
10
|
+
+ "spark": {
|
|
11
|
+
+ "sdk": true,
|
|
12
|
+
+ "upstreamIntegrity": "sha512-KIg5Yhy04lQfHdXC1JQPM+0kftMfPnH6AqDH7v6YskQ9kzfUacooofOFRmbaZHASq/0WY87Fx0peiFETFjOcCg=="
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
diff --git a/windows/ReactNativeWebView/RCTWebView2ComponentView.cpp b/windows/ReactNativeWebView/RCTWebView2ComponentView.cpp
|
|
16
|
+
index 3910258..6cdbe7f 100644
|
|
17
|
+
--- a/windows/ReactNativeWebView/RCTWebView2ComponentView.cpp
|
|
18
|
+
+++ b/windows/ReactNativeWebView/RCTWebView2ComponentView.cpp
|
|
19
|
+
@@ -38,8 +38,9 @@ void RegisterRCTWebView2ComponentView(
|
|
20
|
+
builder.SetContentIslandComponentViewInitializer(
|
|
21
|
+
[](const winrt::Microsoft::ReactNative::Composition::ContentIslandComponentView &islandView) noexcept {
|
|
22
|
+
auto userData = winrt::make_self<RCTWebView2ComponentView>();
|
|
23
|
+
- userData->InitializeContentIsland(islandView);
|
|
24
|
+
islandView.UserData(*userData);
|
|
25
|
+
+ try { userData->InitializeContentIsland(islandView); }
|
|
26
|
+
+ catch (...) { userData->ReportError(winrt::to_string(winrt::to_message())); }
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Set up initial state with zero size
|
|
30
|
+
@@ -147,6 +148,18 @@ void RCTWebView2ComponentView::Cleanup() noexcept {
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
+void RCTWebView2ComponentView::ReportError(std::string const &message) noexcept {
|
|
35
|
+
+ m_initializationError = message;
|
|
36
|
+
+ if (auto emitter = EventEmitter()) {
|
|
37
|
+
+ RNCWebViewCodegen::RCTWebView2EventEmitter::OnLoadingError error;
|
|
38
|
+
+ error.description = message; error.code = -1; error.loading = false;
|
|
39
|
+
+ emitter->onLoadingError(error);
|
|
40
|
+
+ }
|
|
41
|
+
+}
|
|
42
|
+
+void RCTWebView2ComponentView::UpdateEventEmitter(const std::shared_ptr<RNCWebViewCodegen::RCTWebView2EventEmitter> &emitter) noexcept {
|
|
43
|
+
+ BaseRCTWebView2::UpdateEventEmitter(emitter);
|
|
44
|
+
+ if (!m_initializationError.empty()) ReportError(m_initializationError);
|
|
45
|
+
+}
|
|
46
|
+
void RCTWebView2ComponentView::UpdateProps(
|
|
47
|
+
const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
48
|
+
const winrt::com_ptr<RNCWebViewCodegen::RCTWebView2Props> &newProps,
|
|
49
|
+
@@ -185,27 +198,20 @@ void RCTWebView2ComponentView::UpdateProps(
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
- // Handle source navigation
|
|
54
|
+
- if (newProps->newSource.uri.has_value() && !newProps->newSource.uri.value().empty()) {
|
|
55
|
+
- try {
|
|
56
|
+
- auto uri = winrt::Windows::Foundation::Uri(winrt::to_hstring(newProps->newSource.uri.value()));
|
|
57
|
+
- m_webView.Source(uri);
|
|
58
|
+
- } catch (...) {
|
|
59
|
+
- // Invalid URI
|
|
60
|
+
- }
|
|
61
|
+
- } else if (newProps->newSource.html.has_value() && !newProps->newSource.html.value().empty()) {
|
|
62
|
+
+ // ContentIsland initialization is asynchronous. Replay either source once
|
|
63
|
+
+ // the Core exists, and do not reload on unrelated React prop updates.
|
|
64
|
+
+ if (!oldProps || newProps->newSource.uri != oldProps->newSource.uri || newProps->newSource.html != oldProps->newSource.html) {
|
|
65
|
+
+ m_pendingUri = newProps->newSource.uri.value_or("");
|
|
66
|
+
+ m_pendingHtml = newProps->newSource.html.value_or("");
|
|
67
|
+
if (m_webView.CoreWebView2()) {
|
|
68
|
+
try {
|
|
69
|
+
- m_webView.NavigateToString(winrt::to_hstring(newProps->newSource.html.value()));
|
|
70
|
+
- } catch (...) {
|
|
71
|
+
- // Navigation failed
|
|
72
|
+
- }
|
|
73
|
+
- } else {
|
|
74
|
+
- // CoreWebView2 not ready yet - save HTML for later navigation in OnCoreWebView2Initialized
|
|
75
|
+
- m_pendingHtml = newProps->newSource.html.value();
|
|
76
|
+
+ if (!m_pendingUri.empty()) m_webView.CoreWebView2().Navigate(winrt::to_hstring(m_pendingUri));
|
|
77
|
+
+ else m_webView.NavigateToString(winrt::to_hstring(m_pendingHtml));
|
|
78
|
+
+ m_pendingUri.clear(); m_pendingHtml.clear();
|
|
79
|
+
+ } catch (...) { ReportError(winrt::to_string(winrt::to_message())); }
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
-
|
|
83
|
+
+
|
|
84
|
+
// Apply debugging enabled
|
|
85
|
+
if (newProps->webviewDebuggingEnabled.has_value() && m_webView.CoreWebView2()) {
|
|
86
|
+
m_webView.CoreWebView2().Settings().AreDevToolsEnabled(newProps->webviewDebuggingEnabled.value());
|
|
87
|
+
@@ -377,29 +383,14 @@ void RCTWebView2ComponentView::OnNavigationCompleted(
|
|
88
|
+
// Event dispatch failure is non-fatal
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
- if (m_messagingEnabled && m_webView) {
|
|
92
|
+
- try {
|
|
93
|
+
- winrt::hstring message = LR"(
|
|
94
|
+
- window.alert = function (msg) {window.chrome.webview.postMessage(`{"type":"__alert","message":"${msg}"}`)};
|
|
95
|
+
- window.ReactNativeWebView = {postMessage: function (data) {window.chrome.webview.postMessage(String(data))}};
|
|
96
|
+
- const originalPostMessage = globalThis.postMessage;
|
|
97
|
+
- globalThis.postMessage = function (data) { originalPostMessage(data); globalThis.ReactNativeWebView.postMessage(typeof data == 'string' ? data : JSON.stringify(data));};
|
|
98
|
+
- window.chrome.webview.addEventListener('message', function(e) {
|
|
99
|
+
- window.dispatchEvent(new MessageEvent('message', {data: e.data}));
|
|
100
|
+
- document.dispatchEvent(new MessageEvent('message', {data: e.data}));
|
|
101
|
+
- });
|
|
102
|
+
- )";
|
|
103
|
+
- m_webView.ExecuteScriptAsync(message);
|
|
104
|
+
- } catch (...) {
|
|
105
|
+
- // JS injection failure
|
|
106
|
+
- }
|
|
107
|
+
- }
|
|
108
|
+
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
void RCTWebView2ComponentView::OnCoreWebView2Initialized(
|
|
112
|
+
- winrt::Microsoft::UI::Xaml::Controls::CoreWebView2InitializedEventArgs const& /*args*/) {
|
|
113
|
+
+ winrt::Microsoft::UI::Xaml::Controls::CoreWebView2InitializedEventArgs const& args) {
|
|
114
|
+
|
|
115
|
+
- if (!m_webView || !m_webView.CoreWebView2()) return;
|
|
116
|
+
+ if (!m_webView) return;
|
|
117
|
+
+ if (!m_webView.CoreWebView2()) { ReportError("WebView2 could not initialize. Install or repair the Microsoft Edge WebView2 Runtime."); return; }
|
|
118
|
+
|
|
119
|
+
RegisterCoreWebView2Events();
|
|
120
|
+
|
|
121
|
+
@@ -408,15 +399,11 @@ void RCTWebView2ComponentView::OnCoreWebView2Initialized(
|
|
122
|
+
m_webView.CoreWebView2().Settings().UserAgent(m_userAgent);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
- // Navigate to deferred HTML source if pending
|
|
126
|
+
- if (!m_pendingHtml.empty()) {
|
|
127
|
+
- try {
|
|
128
|
+
- m_webView.NavigateToString(winrt::to_hstring(m_pendingHtml));
|
|
129
|
+
- } catch (...) {
|
|
130
|
+
- // Deferred navigation failed
|
|
131
|
+
- }
|
|
132
|
+
- m_pendingHtml.clear();
|
|
133
|
+
- }
|
|
134
|
+
+ try {
|
|
135
|
+
+ if (!m_pendingUri.empty()) m_webView.CoreWebView2().Navigate(winrt::to_hstring(m_pendingUri));
|
|
136
|
+
+ else if (!m_pendingHtml.empty()) m_webView.NavigateToString(winrt::to_hstring(m_pendingHtml));
|
|
137
|
+
+ m_pendingUri.clear(); m_pendingHtml.clear();
|
|
138
|
+
+ } catch (...) { ReportError(winrt::to_string(winrt::to_message())); }
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
void RCTWebView2ComponentView::OnCoreWebView2ResourceRequested(
|
|
142
|
+
@@ -429,9 +416,19 @@ void RCTWebView2ComponentView::OnCoreWebView2DOMContentLoaded(
|
|
143
|
+
winrt::Microsoft::Web::WebView2::Core::CoreWebView2 const& sender,
|
|
144
|
+
winrt::Microsoft::Web::WebView2::Core::CoreWebView2DOMContentLoadedEventArgs const& /*args*/) {
|
|
145
|
+
|
|
146
|
+
- if (!m_injectedJavascript.empty()) {
|
|
147
|
+
- sender.ExecuteScriptAsync(m_injectedJavascript);
|
|
148
|
+
- }
|
|
149
|
+
+ winrt::hstring script;
|
|
150
|
+
+ if (m_messagingEnabled) script = LR"(
|
|
151
|
+
+ window.alert = function (msg) {window.chrome.webview.postMessage(`{"type":"__alert","message":"${msg}"}`)};
|
|
152
|
+
+ window.ReactNativeWebView = {postMessage: function (data) {window.chrome.webview.postMessage(String(data))}};
|
|
153
|
+
+ const originalPostMessage = globalThis.postMessage;
|
|
154
|
+
+ globalThis.postMessage = function (data) { originalPostMessage(data); globalThis.ReactNativeWebView.postMessage(typeof data == 'string' ? data : JSON.stringify(data));};
|
|
155
|
+
+ window.chrome.webview.addEventListener('message', function(e) {
|
|
156
|
+
+ window.dispatchEvent(new MessageEvent('message', {data: e.data}));
|
|
157
|
+
+ document.dispatchEvent(new MessageEvent('message', {data: e.data}));
|
|
158
|
+
+ });
|
|
159
|
+
+ )";
|
|
160
|
+
+ script = script + m_injectedJavascript;
|
|
161
|
+
+ if (!script.empty()) sender.ExecuteScriptAsync(script);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
void RCTWebView2ComponentView::OnCoreWebView2SourceChanged(
|
|
165
|
+
diff --git a/windows/ReactNativeWebView/RCTWebView2ComponentView.h b/windows/ReactNativeWebView/RCTWebView2ComponentView.h
|
|
166
|
+
index 11379a2..c658633 100644
|
|
167
|
+
--- a/windows/ReactNativeWebView/RCTWebView2ComponentView.h
|
|
168
|
+
+++ b/windows/ReactNativeWebView/RCTWebView2ComponentView.h
|
|
169
|
+
@@ -29,6 +29,8 @@ struct RCTWebView2ComponentView : winrt::implements<RCTWebView2ComponentView, wi
|
|
170
|
+
void InitializeContentIsland(
|
|
171
|
+
const winrt::Microsoft::ReactNative::Composition::ContentIslandComponentView &islandView);
|
|
172
|
+
|
|
173
|
+
+ void ReportError(std::string const &message) noexcept;
|
|
174
|
+
+ void UpdateEventEmitter(const std::shared_ptr<RNCWebViewCodegen::RCTWebView2EventEmitter> &emitter) noexcept override;
|
|
175
|
+
void UpdateProps(
|
|
176
|
+
const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
177
|
+
const winrt::com_ptr<RNCWebViewCodegen::RCTWebView2Props> &newProps,
|
|
178
|
+
@@ -103,7 +105,7 @@ private:
|
|
179
|
+
winrt::hstring m_injectedJavascript{L""};
|
|
180
|
+
winrt::hstring m_userAgent{L""};
|
|
181
|
+
bool m_updating{false};
|
|
182
|
+
- std::string m_pendingHtml{};
|
|
183
|
+
+ std::string m_pendingHtml{}, m_pendingUri{}, m_initializationError{};
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
void RegisterRCTWebView2ComponentView(
|
|
187
|
+
diff --git a/windows/ReactNativeWebView/ReactNativeWebView.vcxproj b/windows/ReactNativeWebView/ReactNativeWebView.vcxproj
|
|
188
|
+
index ad5af71..2087e47 100644
|
|
189
|
+
--- a/windows/ReactNativeWebView/ReactNativeWebView.vcxproj
|
|
190
|
+
+++ b/windows/ReactNativeWebView/ReactNativeWebView.vcxproj
|
|
191
|
+
@@ -50,7 +50,7 @@
|
|
192
|
+
<PropertyGroup Label="Configuration">
|
|
193
|
+
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
194
|
+
<CharacterSet>Unicode</CharacterSet>
|
|
195
|
+
- <PlatformToolset>v143</PlatformToolset>
|
|
196
|
+
+ <PlatformToolset>v145</PlatformToolset>
|
|
197
|
+
<GenerateManifest>false</GenerateManifest>
|
|
198
|
+
</PropertyGroup>
|
|
199
|
+
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
|
|
200
|
+
@@ -87,7 +87,7 @@
|
|
201
|
+
</AdditionalIncludeDirectories>
|
|
202
|
+
</ClCompile>
|
|
203
|
+
<Link>
|
|
204
|
+
- <AdditionalDependencies>shell32.lib;user32.lib;windowsapp.lib;%(AdditionalDependenices)</AdditionalDependencies>
|
|
205
|
+
+ <AdditionalDependencies>shell32.lib;user32.lib;windowsapp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
206
|
+
<SubSystem>Console</SubSystem>
|
|
207
|
+
<GenerateWindowsMetadata>true</GenerateWindowsMetadata>
|
|
208
|
+
<ModuleDefinitionFile>ReactNativeWebview.def</ModuleDefinitionFile>
|
package/postinstall.cjs
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
require("
|
|
1
|
+
const path = require("node:path");
|
|
2
|
+
const fs = require("node:fs");
|
|
3
|
+
const { ensurePatchRegistry } = require("./vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.cjs");
|
|
4
|
+
const { prepareNativePatches } = require("./vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs");
|
|
5
|
+
const initial = process.env.INIT_CWD;
|
|
6
|
+
const root = initial && fs.existsSync(path.join(initial, "package.json")) ? initial : __dirname;
|
|
7
|
+
ensurePatchRegistry(root).then(() => prepareNativePatches(root)).catch(error => {
|
|
8
|
+
console.error(error.message);
|
|
9
|
+
process.exitCode = 1;
|
|
10
|
+
});
|
package/skills/spark/SKILL.md
CHANGED
|
@@ -7,6 +7,25 @@ description: Create, develop, build, package, diagnose, or upgrade a Legend Spar
|
|
|
7
7
|
|
|
8
8
|
Spark adds native macOS/Windows capabilities and desktop build orchestration to React Native and Expo Desktop. This skill covers desktop development. Universal starters also declare mobile/web targets, but Expo owns their runtime and distribution workflows. Do not assume every desktop API works on mobile/web. Windows currently supports development builds; production packaging and native acceptance remain pending. macOS ARM64 is the published preview target; Intel acceptance is pending.
|
|
9
9
|
|
|
10
|
+
## Using Spark's APIs
|
|
11
|
+
|
|
12
|
+
Before writing code against a `@legendapp/spark/*` import, read the reference for that area:
|
|
13
|
+
|
|
14
|
+
| Task | Read |
|
|
15
|
+
| --- | --- |
|
|
16
|
+
| Open, show, focus or close windows; close guards; macOS title bar/toolbar | [windows.md](windows.md) |
|
|
17
|
+
| Quit/relaunch, single instance, opening files and URLs, recent documents | [app-and-documents.md](app-and-documents.md) |
|
|
18
|
+
| App menu, context menu, tray / menu-bar item, Dock or taskbar menu | [menus-tray-dock.md](menus-tray-dock.md) |
|
|
19
|
+
| Keyboard shortcuts, commands, global hotkeys | [keyboard.md](keyboard.md) |
|
|
20
|
+
| Reading/writing files, where app data goes, open/save panels, drag and drop | [files.md](files.md) |
|
|
21
|
+
| Preferences, secure storage, SQLite, settings window | [storage-settings.md](storage-settings.md) |
|
|
22
|
+
| Notifications, clipboard, badges/power/system info, app updates, child processes, auth, audio | [integrations.md](integrations.md) |
|
|
23
|
+
| Native controls, macOS sidebar/search/glass views, WebView, Markdown/HTML | [ui.md](ui.md) |
|
|
24
|
+
| Third-party libraries (camera, images, storage…), Spark errors and availability | [library-compat.md](library-compat.md) |
|
|
25
|
+
| Running Claude/Codex CLIs, in-app customization | [ai-customize.md](ai-customize.md) |
|
|
26
|
+
|
|
27
|
+
macOS is the shipped target; Windows is development-only; Spark's desktop APIs do not cover mobile/web beyond the Expo-shaped adapters.
|
|
28
|
+
|
|
10
29
|
## Create and develop
|
|
11
30
|
|
|
12
31
|
- Require Node 24.19.0 or newer. Create with `npm create @legendapp/spark@next MyApp` (stable releases use `@latest`). Names must be alphanumeric. `npx @legendapp/create-spark@next MyApp` is equivalent; an installed CLI also supports `spark create MyApp`.
|
|
@@ -19,11 +38,22 @@ Spark adds native macOS/Windows capabilities and desktop build orchestration to
|
|
|
19
38
|
|
|
20
39
|
Edit `desktop.config.json` when present; single-target starters generate `app.json` from it. Universal starters use a managed `app.config.js`. Existing Expo apps can use `spark add desktop`; preserve their Expo entry point and compose configuration as the integration guide requires.
|
|
21
40
|
|
|
41
|
+
Configuration precedence is shared `expo`, then `expoByPlatform[buildTarget]`, then Spark-owned canonical fields. Other target overrides stay inactive; valid `window.macos` config has no effect on a Windows build. Runtime macOS capability calls on Windows still reject. Native-package metadata is checked on every build, including cache reuse: use `nativeModules: true` as a marker, keep binding names in codegen, and remove unused `pod`, `platforms` and `windowsAdapter` fields. Unknown keys or invalid values throw a clear `SparkError`.
|
|
42
|
+
|
|
22
43
|
Install native dependencies with the app's manager and use their documented imports. JavaScript changes Fast Refresh; native code, native configuration, or plugins require a custom build. Press `b`, or run `spark build --dev` then `spark dev`. Use `--force` only when regeneration/compilation must be forced. Put durable native changes in packages/config plugins, not disposable generated native projects.
|
|
23
44
|
|
|
24
45
|
`spark analyze` reports native production selection in `.spark/selection-report.json`. Only SDK modules are pruned automatically; unknown third-party native dependencies stay included. Use package names in `expo.extra.spark.include` for native-only requirements; custom native configuration can require a custom runtime even without extra modules.
|
|
25
46
|
|
|
26
|
-
##
|
|
47
|
+
## Prepare, build and package
|
|
48
|
+
|
|
49
|
+
`spark prebuild --platform macos [--project <directory>]` generates the native
|
|
50
|
+
macOS project and installs Pods using the development native selection. It shares
|
|
51
|
+
build's lock, migration preflight, config plugins, cache recovery, and provenance.
|
|
52
|
+
Missing/stale Pods are repaired even with a cached app; a second unchanged run
|
|
53
|
+
skips generation and pod install. It runs no xcodebuild, app signing/packaging, or
|
|
54
|
+
Metro, installs no JS dependencies, and changes no pins. Pod prepare commands can
|
|
55
|
+
compile dependency artifacts. Build flags such as `--dev` and `--force` are rejected.
|
|
56
|
+
Follow pending-migration guidance; never stamp `.spark/version` to bypass it.
|
|
27
57
|
|
|
28
58
|
`spark build` creates a standalone macOS `.app` with bundled JavaScript; `spark open` opens the last standalone build. `spark build --dev` creates the custom Debug runtime. `spark build --preview` uses production module selection in Debug.
|
|
29
59
|
|
|
@@ -31,11 +61,14 @@ Native macOS builds need full Xcode (license/first-launch setup and selected dev
|
|
|
31
61
|
|
|
32
62
|
## Diagnose and upgrade
|
|
33
63
|
|
|
34
|
-
- Run `spark doctor` for dependency pins and native tooling; it exits 1 on issues.
|
|
64
|
+
- Run `spark doctor` for dependency pins, stale/missing/conflicting app patches, and native tooling; it exits 1 on issues and prints patch fixes without changing installed files.
|
|
35
65
|
- Direct `react`, `react-native`, `expo`, and (for macOS apps) `react-native-macos` specs must match the installed CLI's exact template pins. Ranges are drift even when they include the expected version. Check npm/Bun `overrides`, Yarn `resolutions`, and `pnpm.overrides` too. Do not upgrade React/Expo independently of Spark's tested matrix.
|
|
36
66
|
- `catalog:` and `workspace:` baseline specs are left to their owner; validate their resolved versions yourself. Only the app manifest is checked, not workspace-root overrides. Workspace-managed Spark versions need updating at their owner.
|
|
37
67
|
- `spark upgrade --dry-run` previews the newest release on the installed version's channel (`next` or `latest`), target pins, install command, and migrations without modifying the app. `spark upgrade` updates Spark and its release inputs, runs the detected manager's install, then applies versioned migrations and refreshes the AI pointers. Both support `--project <directory>`.
|
|
38
|
-
-
|
|
68
|
+
- `spark patch <lib>` then `spark patch <lib> --done` saves an app patch layered on Spark's; see [library-compat.md](library-compat.md#patch-a-library).
|
|
69
|
+
- `spark migrate --project <directory> --dry-run` previews migrations at the target's installed Spark version; `spark migrate` applies them without registry access, pin changes, or installs. Required installs or configuration changes block apply before any writes. Keep manual steps in `.spark/upgrade-notes.md` until reviewed.
|
|
70
|
+
- External generators using the current installed version must finish generation, then call `spark migrate --init --project <generated-directory>` before startup. It stamps the baseline and refreshes pointers, including for consumers inheriting root dependencies. Never use `--init` to skip an existing app's migrations. Spark creation/template initialization and new desktop adoption stamp successful generation themselves. See [UPGRADING.md](UPGRADING.md#migrate-at-the-installed-version).
|
|
71
|
+
- `.spark/version` records successful migrations. `dev`, `build`, `prebuild`, and `doctor` apply safe idempotent migrations after a manual version change; unsafe pending changes stop with `spark migrate` guidance; downgrades remain blocked. Lifecycle scripts are not required for this check.
|
|
39
72
|
- Keep the generated Spark sections in `AGENTS.md` / `CLAUDE.md` and the `.claude/skills/spark/SKILL.md` pointer thin. Instructions live in this installed package, so updating Spark updates the skill.
|
|
40
73
|
|
|
41
74
|
## Upgrade an app
|
|
@@ -49,7 +82,7 @@ After installation, read this skill and `UPGRADING.md` from the **new installed
|
|
|
49
82
|
- Missing/stale Runner or extra native modules: follow the terminal's compatibility message; build a custom runtime with `b` or `spark build --dev`. A local SDK without release metadata needs a registered local Runner.
|
|
50
83
|
- Expo Desktop config import failures: check the actual Node on PATH; Node 24.12.0 is incompatible with this pinned Expo Desktop setup. Use Node 24.19.0 or newer.
|
|
51
84
|
- Missing `pod` / `xcodebuild`: install the documented native prerequisites, then retry. Spark does not install Xcode or accept licenses.
|
|
52
|
-
-
|
|
85
|
+
- Pending migrations with fixed installed dependencies: preview `spark migrate --dry-run`, then apply. For pin drift or a stale Expo terminal patch, inspect `spark doctor`, preview `spark upgrade --dry-run`, then upgrade. If install fails, fix the manager error and rerun upgrade; the migration version is not advanced by a failed install.
|
|
53
86
|
- Malformed `spark:skill` markers: repair the paired marked section without removing user instructions, then rerun upgrade.
|
|
54
87
|
- Build details live in `.spark/logs/` and `.spark/commands.jsonl`. Keep `.spark/` (except `.spark/version`), generated native outputs, and dependency directories out of version control; commit source/configuration, AI pointer files, vendored release inputs, and the manager lockfile.
|
|
55
88
|
|