Skip to content

Commit 6946e80

Browse files
committed
feat: add multi-window support (#117)
* feat: add multi-window support * feat: introduce WindowManager fix: RCTReactViewController properly check props to update fix: use clearColor instead of systemBackgroundColor for visionOS (#125) feat: allow to use WindowHandlingModifier outside of RCTMainWindow fix: deep and universal links when app is running (#140) Co-authored-by: Thiago Brezinski <thiagobrez@gmail.com> fix: remove window init feat: add support for ornaments & dev menu trigger (#149) * feat: add support for ornaments * feat: add ornaments support to second window fix: allow to manually move dev menu to avoid conflicts (#150) fix: remove unnecessary diff after upstreaming changes (#151) Make CMake 3.29.0 as minimum required version (#155) fix: move visionOS codegen specs, sync with upstream chore: sync with upstream fix: remove template Move template to a separate repo fix: update oot-release scripts chore: remove unnecessary diff (#159) fix: react-native-config chore: sync with upstream chore: sync with upstrteam
1 parent da11704 commit 6946e80

File tree

76 files changed

+1254
-1876
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1254
-1876
lines changed

.github/workflows/test-all.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
name: Test All
22

3-
on:
4-
workflow_dispatch:
5-
pull_request:
6-
push:
7-
branches:
8-
- main
9-
- "*-stable"
3+
# on:
4+
# workflow_dispatch:
5+
# pull_request:
6+
# push:
7+
# tags:
8+
# - 'v*'
9+
# # nightly build @ 2:15 AM UTC
10+
# schedule:
11+
# - cron: '15 2 * * *'
1012

1113
concurrency:
1214
group: ${{ github.workflow }}-${{ github.ref }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The source for the React Native visionOS documentation and website is hosted on
3131

3232
Prerequisites:
3333
- Download the latest Xcode (at least 15.2)
34-
- Install the latest version of CMake (at least v3.28.0)
34+
- Install the latest version of CMake (at least v3.29.0)
3535

3636
Check out `rn-tester` [README.md](./packages/rn-tester/README.md) to build React Native from the source.
3737

packages/helloworld/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"test": "jest"
1313
},
1414
"dependencies": {
15-
"react": "18.3.1",
16-
"react-native": "0.76.0-rc.0"
15+
"react": "19.0.0-rc-fb9a90fa48-20240614",
16+
"@callstack/react-native-visionos": "0.76.0-rc.0"
1717
},
1818
"devDependencies": {
1919
"@babel/core": "^7.25.2",

packages/out-of-tree-platforms/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@callstack/out-of-tree-platforms",
3-
"version": "0.75.0-main",
3+
"version": "0.76.0-main",
44
"description": "Utils for React Native out of tree platforms.",
55
"keywords": ["out-of-tree", "react-native"],
66
"homepage": "https://github.com/callstack/react-native-visionos/tree/HEAD/packages/out-of-tree-platforms#readme",

packages/react-native-test-library/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"devDependencies": {
2828
"@babel/core": "^7.25.2",
2929
"@react-native/babel-preset": "0.76.0-rc.0",
30-
"react-native": "0.76.0-rc.0"
30+
"@callstack/react-native-visionos": "0.76.0-rc.0"
3131
},
3232
"peerDependencies": {
3333
"react": "*",

packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ NS_ASSUME_NONNULL_BEGIN
5959

6060
/// The window object, used to render the UViewControllers
6161
@property (nonatomic, strong, nonnull) UIWindow *window;
62-
@property (nonatomic, nullable) RCTBridge *bridge;
62+
/// Store last focused window to properly handle multi-window scenarios
63+
@property (nonatomic, weak, nullable) UIWindow *lastFocusedWindow;
64+
@property (nonatomic, strong, nullable) RCTBridge *bridge;
6365
@property (nonatomic, strong, nullable) NSString *moduleName;
6466
@property (nonatomic, strong, nullable) NSDictionary *initialProps;
6567
@property (nonatomic, strong, nonnull) RCTRootViewFactory *rootViewFactory;

packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
5353
[RCTComponentViewFactory currentComponentViewFactory].thirdPartyFabricComponentsProvider = self;
5454
}
5555

56-
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
57-
UIViewController *rootViewController = [self createRootViewController];
58-
[self setRootView:rootView toRootViewController:rootViewController];
59-
self.window.rootViewController = rootViewController;
60-
self.window.windowScene.delegate = self;
61-
[self.window makeKeyAndVisible];
62-
6356
return YES;
6457
}
6558

@@ -87,7 +80,11 @@ - (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
8780
BOOL enableFabric = self.fabricEnabled;
8881
UIView *rootView = RCTAppSetupDefaultRootView(bridge, moduleName, initProps, enableFabric);
8982

83+
#if TARGET_OS_VISION
84+
rootView.backgroundColor = [UIColor clearColor];
85+
#else
9086
rootView.backgroundColor = [UIColor systemBackgroundColor];
87+
#endif
9188

9289
return rootView;
9390
}

packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.mm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ - (UIView *)viewWithModuleName:(NSString *)moduleName
149149
initWithSurface:surface
150150
sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact];
151151

152+
#if TARGET_OS_VISION
153+
surfaceHostingProxyRootView.backgroundColor = [UIColor clearColor];
154+
#else
152155
surfaceHostingProxyRootView.backgroundColor = [UIColor systemBackgroundColor];
156+
#endif
153157
if (self->_configuration.customizeRootView != nil) {
154158
self->_configuration.customizeRootView(surfaceHostingProxyRootView);
155159
}
@@ -183,7 +187,11 @@ - (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
183187
BOOL enableFabric = self->_configuration.fabricEnabled;
184188
UIView *rootView = RCTAppSetupDefaultRootView(bridge, moduleName, initProps, enableFabric);
185189

190+
#if TARGET_OS_VISION
191+
rootView.backgroundColor = [UIColor clearColor];
192+
#else
186193
rootView.backgroundColor = [UIColor systemBackgroundColor];
194+
#endif
187195

188196
return rootView;
189197
}

packages/react-native/Libraries/LinkingIOS/RCTLinkingManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@
2424
continueUserActivity:(nonnull NSUserActivity *)userActivity
2525
restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> *_Nullable))restorationHandler;
2626

27+
+ (void)onOpenURL:(nonnull NSURL *)url NS_SWIFT_NAME(onOpenURL(url:));
28+
2729
@end

packages/react-native/Libraries/LinkingIOS/RCTLinkingManager.mm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#import "RCTLinkingPlugins.h"
1616

1717
static NSString *const kOpenURLNotification = @"RCTOpenURLNotification";
18+
static NSURL *initialURL = nil;
1819

1920
static void postNotificationWithURL(NSURL *URL, id sender)
2021
{
@@ -81,6 +82,16 @@ + (BOOL)application:(UIApplication *)application
8182
return YES;
8283
}
8384

85+
86+
+ (void)onOpenURL:(NSURL *)url
87+
{
88+
if (initialURL == nil) {
89+
initialURL = url;
90+
} else {
91+
postNotificationWithURL(url, self);
92+
}
93+
}
94+
8495
- (void)handleOpenURLNotification:(NSNotification *)notification
8596
{
8697
[self sendEventWithName:@"url" body:notification.userInfo];
@@ -153,6 +164,7 @@ - (void)handleOpenURLNotification:(NSNotification *)notification
153164

154165
RCT_EXPORT_METHOD(getInitialURL : (RCTPromiseResolveBlock)resolve reject : (__unused RCTPromiseRejectBlock)reject)
155166
{
167+
#if !TARGET_OS_VISION
156168
NSURL *initialURL = nil;
157169
if (self.bridge.launchOptions[UIApplicationLaunchOptionsURLKey]) {
158170
initialURL = self.bridge.launchOptions[UIApplicationLaunchOptionsURLKey];
@@ -163,6 +175,8 @@ - (void)handleOpenURLNotification:(NSNotification *)notification
163175
initialURL = ((NSUserActivity *)userActivityDictionary[@"UIApplicationLaunchOptionsUserActivityKey"]).webpageURL;
164176
}
165177
}
178+
#endif
179+
// React Native visionOS uses static property to retrieve initialURL.
166180
resolve(RCTNullIfNil(initialURL.absoluteString));
167181
}
168182

0 commit comments

Comments
 (0)