expo-dev-launcher 1.1.0 → 1.2.1

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.
@@ -100,7 +100,7 @@ RCT_EXPORT_METHOD(getAuthSchemeAsync:(RCTPromiseResolveBlock)resolve
100
100
  NSArray<NSDictionary*> *urlTypes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleURLTypes"];
101
101
 
102
102
  if (urlTypes != nil) {
103
- for (int i = 1; i <= urlTypes.count; i++) {
103
+ for (int i = 0; i < urlTypes.count; i++) {
104
104
  NSDictionary *urlType = urlTypes[i];
105
105
  NSArray<NSString*> *schemes = urlType[@"CFBundleURLSchemes"];
106
106
 
@@ -116,24 +116,18 @@ RCT_EXPORT_METHOD(getAuthSchemeAsync:(RCTPromiseResolveBlock)resolve
116
116
  }
117
117
 
118
118
  RCT_EXPORT_METHOD(setSessionAsync:(NSString *)session
119
- resolver:(RCTPromiseResolveBlock)resolve
120
- rejecter:(RCTPromiseRejectBlock)reject)
121
- {
122
- [[NSUserDefaults standardUserDefaults] setObject:session forKey:@"expo-session-secret"];
123
- [DevMenuManager.shared setSession:session];
124
- resolve(nil);
125
- }
126
-
127
- RCT_EXPORT_METHOD(restoreSessionAsync:(RCTPromiseResolveBlock)resolve
128
- rejecter:(RCTPromiseRejectBlock)reject)
129
- {
130
- NSString *session = [[NSUserDefaults standardUserDefaults] objectForKey:@"expo-session-secret"];
131
-
132
- if (session != nil) {
133
- [DevMenuManager.shared setSession:session];
134
- }
135
-
136
- resolve(session);
137
- }
119
+ resolver:(RCTPromiseResolveBlock)resolve
120
+ rejecter:(RCTPromiseRejectBlock)reject)
121
+ {
122
+ [[NSUserDefaults standardUserDefaults] setObject:session forKey:@"expo-session-secret"];
123
+ resolve(nil);
124
+ }
125
+
126
+ RCT_EXPORT_METHOD(restoreSessionAsync:(RCTPromiseResolveBlock)resolve
127
+ rejecter:(RCTPromiseRejectBlock)reject)
128
+ {
129
+ NSString *session = [[NSUserDefaults standardUserDefaults] objectForKey:@"expo-session-secret"];
130
+ resolve(session);
131
+ }
138
132
 
139
133
  @end
@@ -263,6 +263,8 @@
263
263
 
264
264
  - (void)navigateToLauncher
265
265
  {
266
+ NSAssert([NSThread isMainThread], @"This function must be called on main thread");
267
+
266
268
  [_appBridge invalidate];
267
269
  [self invalidateDevMenuApp];
268
270
 
@@ -276,36 +278,10 @@
276
278
  [self _removeInitModuleObserver];
277
279
 
278
280
  _launcherBridge = [[EXDevLauncherRCTBridge alloc] initWithDelegate:self launchOptions:_launchOptions];
279
-
280
- NSMutableDictionary *insets = [NSMutableDictionary new];
281
- [insets setObject:@(0) forKey:@"top"];
282
- [insets setObject:@(0) forKey:@"right"];
283
- [insets setObject:@(0) forKey:@"bottom"];
284
- [insets setObject:@(0) forKey:@"left"];
285
-
286
- if (@available(iOS 11.0, *)) {
287
- UIWindow* window = [[UIApplication sharedApplication] keyWindow];
288
- UIEdgeInsets safeAreaInsets = window.safeAreaInsets;
289
-
290
- [insets setObject:@(safeAreaInsets.top) forKey:@"top"];
291
- [insets setObject:@(safeAreaInsets.right) forKey:@"right"];
292
- [insets setObject:@(safeAreaInsets.bottom) forKey:@"bottom"];
293
- [insets setObject:@(safeAreaInsets.left) forKey:@"left"];
294
- }
295
-
296
281
 
297
282
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:_launcherBridge
298
283
  moduleName:@"main"
299
- initialProperties:@{
300
- @"insets": insets,
301
- @"isSimulator":
302
- #if TARGET_IPHONE_SIMULATOR
303
- @YES
304
- #else
305
- @NO
306
- #endif
307
-
308
- }];
284
+ initialProperties:@{}];
309
285
 
310
286
  [self _ensureUserInterfaceStyleIsInSyncWithTraitEnv:rootView];
311
287
 
@@ -351,8 +327,11 @@
351
327
  if (!self) {
352
328
  return;
353
329
  }
354
-
355
- EXDevLauncherAppError *appError = [[EXDevLauncherAppError alloc] initWithMessage:error.description stack:nil];
330
+
331
+ EXDevLauncherUrl *devLauncherUrl = [[EXDevLauncherUrl alloc] init:url];
332
+ NSURL *appUrl = devLauncherUrl.url;
333
+ NSString *errorMessage = [NSString stringWithFormat:@"Failed to load app from %@ with error: %@", appUrl.absoluteString, error.localizedDescription];
334
+ EXDevLauncherAppError *appError = [[EXDevLauncherAppError alloc] initWithMessage:errorMessage stack:nil];
356
335
  [self.errorManager showError:appError];
357
336
  });
358
337
  }];
@@ -565,9 +544,6 @@
565
544
 
566
545
  [self _ensureUserInterfaceStyleIsInSyncWithTraitEnv:self.window.rootViewController];
567
546
 
568
- [[UIDevice currentDevice] setValue:@(orientation) forKey:@"orientation"];
569
- [UIViewController attemptRotationToDeviceOrientation];
570
-
571
547
  if (backgroundColor) {
572
548
  self.window.rootViewController.view.backgroundColor = backgroundColor;
573
549
  self.window.backgroundColor = backgroundColor;
@@ -60,6 +60,8 @@ public class EXDevLauncherErrorViewController: UIViewController, UITableViewData
60
60
  }
61
61
 
62
62
  private func navigateToLauncher() {
63
- manager?.controller?.navigateToLauncher()
63
+ RCTExecuteOnMainQueue { [self]
64
+ self.manager?.controller?.navigateToLauncher()
65
+ }
64
66
  }
65
67
  }
@@ -5,7 +5,9 @@ import UIKit
5
5
  @objc
6
6
  public class EXDevLauncherManifestHelper: NSObject {
7
7
  private static func defaultOrientationForOrientationMask(_ orientationMask: UIInterfaceOrientationMask) -> UIInterfaceOrientation {
8
- if orientationMask.contains(.portrait) {
8
+ if orientationMask.contains(.all) {
9
+ return UIInterfaceOrientation.unknown
10
+ } else if orientationMask.contains(.portrait) {
9
11
  return UIInterfaceOrientation.portrait
10
12
  } else if orientationMask.contains(.landscapeLeft) {
11
13
  return UIInterfaceOrientation.landscapeLeft
@@ -73,14 +73,30 @@ public class ExpoDevLauncherReactDelegateHandler: ExpoReactDelegateHandler, RCTB
73
73
  // MARK: EXDevelopmentClientControllerDelegate implementations
74
74
 
75
75
  public func devLauncherController(_ developmentClientController: EXDevLauncherController, didStartWithSuccess success: Bool) {
76
- let bridge = RCTBridge(delegate: self.bridgeDelegate, launchOptions: self.launchOptions)
76
+ var launchOptions: [AnyHashable: Any] = [:]
77
+
78
+ if let initialLaunchOptions = self.launchOptions {
79
+ for (key, value) in initialLaunchOptions {
80
+ launchOptions[key] = value
81
+ }
82
+ }
83
+
84
+ for (key, value) in developmentClientController.getLaunchOptions() {
85
+ launchOptions[key] = value
86
+ }
87
+
88
+ let bridge = RCTBridge(delegate: self.bridgeDelegate, launchOptions: launchOptions)
77
89
  developmentClientController.appBridge = bridge
78
90
 
79
91
  let rootView = RCTRootView(bridge: bridge!, moduleName: self.rootViewModuleName!, initialProperties: self.rootViewInitialProperties)
80
92
  rootView.backgroundColor = self.deferredRootView?.backgroundColor ?? UIColor.white
81
93
  let window = getWindow()
82
- window.rootViewController = self.reactDelegate?.createRootViewController()
83
- window.rootViewController!.view = rootView
94
+
95
+ // NOTE: this order of assignment seems to actually have an effect on behaviour
96
+ // direct assignment of window.rootViewController.view = rootView does not work
97
+ let rootViewController = self.reactDelegate?.createRootViewController()
98
+ rootViewController!.view = rootView
99
+ window.rootViewController = rootViewController
84
100
  window.makeKeyAndVisible()
85
101
 
86
102
  // it is purposeful that we don't clean up saved properties here, because we may initialize
@@ -8,8 +8,8 @@ class EXDevLauncherManifestHelperTests: XCTestCase {
8
8
  func testExportManifestOrientation() {
9
9
  XCTAssertEqual(UIInterfaceOrientation.portrait, EXDevLauncherManifestHelper.exportManifestOrientation("portrait"))
10
10
  XCTAssertEqual(UIInterfaceOrientation.landscapeLeft, EXDevLauncherManifestHelper.exportManifestOrientation("landscape"))
11
- XCTAssertEqual(UIInterfaceOrientation.portrait, EXDevLauncherManifestHelper.exportManifestOrientation("default"))
12
- XCTAssertEqual(UIInterfaceOrientation.portrait, EXDevLauncherManifestHelper.exportManifestOrientation("unsupported-value"))
11
+ XCTAssertEqual(UIInterfaceOrientation.unknown, EXDevLauncherManifestHelper.exportManifestOrientation("default"))
12
+ XCTAssertEqual(UIInterfaceOrientation.unknown, EXDevLauncherManifestHelper.exportManifestOrientation("unsupported-value"))
13
13
  }
14
14
 
15
15
  func testExportManifestUserInterfaceStyle() {
@@ -1,9 +1,9 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
2
+ <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
3
3
  <device id="retina5_9" orientation="portrait" appearance="light"/>
4
4
  <dependencies>
5
5
  <deployment identifier="iOS"/>
6
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
6
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
7
7
  <capability name="Safe area layout guides" minToolsVersion="9.0"/>
8
8
  <capability name="System colors in document resources" minToolsVersion="11.0"/>
9
9
  <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -21,7 +21,7 @@
21
21
  <rect key="frame" x="20" y="64" width="335" height="594"/>
22
22
  <subviews>
23
23
  <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="12" translatesAutoresizingMaskIntoConstraints="NO" id="1Bh-aT-q2c" userLabel="Header Stack View">
24
- <rect key="frame" x="0.0" y="0.0" width="335" height="86.333333333333329"/>
24
+ <rect key="frame" x="0.0" y="0.0" width="335" height="103"/>
25
25
  <subviews>
26
26
  <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="There was a problem loading the project." lineBreakMode="wordWrap" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yz7-qW-osQ">
27
27
  <rect key="frame" x="0.0" y="0.0" width="335" height="57.333333333333336"/>
@@ -29,8 +29,8 @@
29
29
  <color key="textColor" red="0.10588235294117647" green="0.12156862745098039" blue="0.13725490196078433" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
30
30
  <nil key="highlightedColor"/>
31
31
  </label>
32
- <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="This development build encountered the following error." textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NuU-oV-ttb">
33
- <rect key="frame" x="0.0" y="69.333333333333343" width="335" height="17"/>
32
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="This development build encountered the following error:" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NuU-oV-ttb">
33
+ <rect key="frame" x="0.0" y="69.333333333333343" width="335" height="33.666666666666657"/>
34
34
  <fontDescription key="fontDescription" type="system" pointSize="14"/>
35
35
  <color key="textColor" red="0.10588235294117647" green="0.12156862745098039" blue="0.13725490196078433" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
36
36
  <nil key="highlightedColor"/>
@@ -38,7 +38,7 @@
38
38
  </subviews>
39
39
  </stackView>
40
40
  <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="12" translatesAutoresizingMaskIntoConstraints="NO" id="Yt5-QM-Cuc" userLabel="Error Stack View">
41
- <rect key="frame" x="0.0" y="104.33333333333334" width="335" height="489.66666666666663"/>
41
+ <rect key="frame" x="0.0" y="121" width="335" height="473"/>
42
42
  <subviews>
43
43
  <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Error infromation" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VXA-BB-Jf6">
44
44
  <rect key="frame" x="0.0" y="0.0" width="335" height="17"/>
@@ -47,7 +47,7 @@
47
47
  <nil key="highlightedColor"/>
48
48
  </label>
49
49
  <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="YTm-Ru-mwN">
50
- <rect key="frame" x="0.0" y="29.000000000000028" width="335" height="460.66666666666674"/>
50
+ <rect key="frame" x="0.0" y="29" width="335" height="444"/>
51
51
  <color key="backgroundColor" white="1" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
52
52
  <color key="separatorColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
53
53
  <color key="sectionIndexColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>