react-native-macos 0.0.0-1a2b7fe2e → 0.0.0-1b5cf312a

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.
@@ -17,5 +17,5 @@ exports.version = {
17
17
  major: 0,
18
18
  minor: 0,
19
19
  patch: 0,
20
- prerelease: '1a2b7fe2e',
20
+ prerelease: '1b5cf312a',
21
21
  };
@@ -493,7 +493,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
493
493
 
494
494
  if (range.location + range.length > backedTextInputView.attributedText.string.length) {
495
495
  _predictedText = backedTextInputView.attributedText.string;
496
- } else {
496
+ } else if (text != nil) { // TODO(macOS GH#774): -[NSString stringByReplacingCharactersInRange:withString:] doesn't like when the replacement string is nil
497
497
  _predictedText = [backedTextInputView.attributedText.string stringByReplacingCharactersInRange:range withString:text];
498
498
  }
499
499
 
@@ -28,7 +28,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
28
28
  RCTVersionMajor: @(0),
29
29
  RCTVersionMinor: @(0),
30
30
  RCTVersionPatch: @(0),
31
- RCTVersionPrerelease: @"1a2b7fe2e",
31
+ RCTVersionPrerelease: @"1b5cf312a",
32
32
  };
33
33
  });
34
34
  return __rnVersion;
@@ -43,7 +43,11 @@ NSSharingServicePickerDelegate
43
43
 
44
44
  RCT_EXPORT_MODULE()
45
45
 
46
+ #if TARGET_OS_OSX // [TODO(macOS GH#774)
47
+ @synthesize bridge = _bridge;
48
+ #else // TODO(macOS GH#774)
46
49
  @synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED;
50
+ #endif // ]TODO(macOS GH#774)
47
51
 
48
52
  - (dispatch_queue_t)methodQueue
49
53
  {
@@ -110,9 +110,21 @@ static void sendEventToAllConnections(NSString *event)
110
110
  }
111
111
 
112
112
  NSString *key = [inspectorURL absoluteString];
113
+ // [TODO(macOS GH#774) - safety check to avoid a crash
114
+ if (key == nil) {
115
+ RCTLogError(@"failed to get inspector URL");
116
+ return nil;
117
+ }
118
+ // ]TODO(macOS GH#774)
113
119
  RCTInspectorPackagerConnection *connection = socketConnections[key];
114
120
  if (!connection || !connection.isConnected) {
115
121
  connection = [[RCTInspectorPackagerConnection alloc] initWithURL:inspectorURL];
122
+ // [TODO(macOS GH#774) - safety check to avoid a crash
123
+ if (connection == nil) {
124
+ RCTLogError(@"failed to initialize RCTInspectorPackagerConnection");
125
+ return nil;
126
+ }
127
+ // ]TODO(macOS GH#774)
116
128
  socketConnections[key] = connection;
117
129
  [connection connect];
118
130
  }
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.0.0-1a2b7fe2e
1
+ VERSION_NAME=0.0.0-1b5cf312a
2
2
  GROUP=com.facebook.react
3
3
 
4
4
  POM_NAME=ReactNative
@@ -156,12 +156,14 @@ public class ReactInstanceManager {
156
156
  /* accessed from any thread */
157
157
  private final JavaScriptExecutorFactory mJavaScriptExecutorFactory;
158
158
 
159
+ // See {@code ReactInstanceManagerBuilder} for description of all flags here.
159
160
  private @Nullable List<String> mViewManagerNames = null;
160
161
  private final @Nullable JSBundleLoader mBundleLoader;
161
162
  private final @Nullable String mJSMainModulePath; /* path to JS bundle root on Metro */
162
163
  private final List<ReactPackage> mPackages;
163
164
  private final DevSupportManager mDevSupportManager;
164
165
  private final boolean mUseDeveloperSupport;
166
+ private final boolean mRequireActivity;
165
167
  private @Nullable ComponentNameResolverManager mComponentNameResolverManager;
166
168
  private @Nullable RuntimeSchedulerManager mRuntimeSchedulerManager;
167
169
  private final @Nullable NotThreadSafeBridgeIdleDebugListener mBridgeIdleDebugListener;
@@ -216,6 +218,7 @@ public class ReactInstanceManager {
216
218
  @Nullable String jsMainModulePath,
217
219
  List<ReactPackage> packages,
218
220
  boolean useDeveloperSupport,
221
+ boolean requireActivity,
219
222
  @Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
220
223
  LifecycleState initialLifecycleState,
221
224
  @Nullable UIImplementationProvider mUIImplementationProvider,
@@ -233,6 +236,7 @@ public class ReactInstanceManager {
233
236
 
234
237
  DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(applicationContext);
235
238
 
239
+ // See {@code ReactInstanceManagerBuilder} for description of all flags here.
236
240
  mApplicationContext = applicationContext;
237
241
  mCurrentActivity = currentActivity;
238
242
  mDefaultBackButtonImpl = defaultHardwareBackBtnHandler;
@@ -241,6 +245,7 @@ public class ReactInstanceManager {
241
245
  mJSMainModulePath = jsMainModulePath;
242
246
  mPackages = new ArrayList<>();
243
247
  mUseDeveloperSupport = useDeveloperSupport;
248
+ mRequireActivity = requireActivity;
244
249
  Systrace.beginSection(
245
250
  Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstanceManager.initDevSupportManager");
246
251
  mDevSupportManager =
@@ -558,16 +563,20 @@ public class ReactInstanceManager {
558
563
  * @param activity the activity being paused
559
564
  */
560
565
  @ThreadConfined(UI)
561
- public void onHostPause(Activity activity) {
562
- Assertions.assertNotNull(mCurrentActivity);
563
- Assertions.assertCondition(
564
- activity == mCurrentActivity,
565
- "Pausing an activity that is not the current activity, this is incorrect! "
566
- + "Current activity: "
567
- + mCurrentActivity.getClass().getSimpleName()
568
- + " "
569
- + "Paused activity: "
570
- + activity.getClass().getSimpleName());
566
+ public void onHostPause(@Nullable Activity activity) {
567
+ if (mRequireActivity) {
568
+ Assertions.assertCondition(mCurrentActivity != null);
569
+ }
570
+ if (mCurrentActivity != null) {
571
+ Assertions.assertCondition(
572
+ activity == mCurrentActivity,
573
+ "Pausing an activity that is not the current activity, this is incorrect! "
574
+ + "Current activity: "
575
+ + mCurrentActivity.getClass().getSimpleName()
576
+ + " "
577
+ + "Paused activity: "
578
+ + activity.getClass().getSimpleName());
579
+ }
571
580
  onHostPause();
572
581
  }
573
582
 
@@ -583,7 +592,8 @@ public class ReactInstanceManager {
583
592
  * this instance of {@link ReactInstanceManager}.
584
593
  */
585
594
  @ThreadConfined(UI)
586
- public void onHostResume(Activity activity, DefaultHardwareBackBtnHandler defaultBackButtonImpl) {
595
+ public void onHostResume(
596
+ @Nullable Activity activity, DefaultHardwareBackBtnHandler defaultBackButtonImpl) {
587
597
  UiThreadUtil.assertOnUiThread();
588
598
 
589
599
  mDefaultBackButtonImpl = defaultBackButtonImpl;
@@ -592,7 +602,7 @@ public class ReactInstanceManager {
592
602
 
593
603
  /** Use this method when the activity resumes. */
594
604
  @ThreadConfined(UI)
595
- public void onHostResume(Activity activity) {
605
+ public void onHostResume(@Nullable Activity activity) {
596
606
  UiThreadUtil.assertOnUiThread();
597
607
 
598
608
  mCurrentActivity = activity;
@@ -631,8 +641,8 @@ public class ReactInstanceManager {
631
641
  // activity is attached to window, we can enable dev support immediately
632
642
  mDevSupportManager.setDevSupportEnabled(true);
633
643
  }
634
- } else {
635
- // there is no activity, we can enable dev support
644
+ } else if (!mRequireActivity) {
645
+ // there is no activity, but we can enable dev support
636
646
  mDevSupportManager.setDevSupportEnabled(true);
637
647
  }
638
648
  }
@@ -666,7 +676,9 @@ public class ReactInstanceManager {
666
676
  * @param activity the activity being destroyed
667
677
  */
668
678
  @ThreadConfined(UI)
669
- public void onHostDestroy(Activity activity) {
679
+ public void onHostDestroy(@Nullable Activity activity) {
680
+ // In some cases, Activity may (correctly) be null.
681
+ // See mRequireActivity flag.
670
682
  if (activity == mCurrentActivity) {
671
683
  onHostDestroy();
672
684
  }
@@ -45,6 +45,7 @@ public class ReactInstanceManagerBuilder {
45
45
  private @Nullable NotThreadSafeBridgeIdleDebugListener mBridgeIdleDebugListener;
46
46
  private @Nullable Application mApplication;
47
47
  private boolean mUseDeveloperSupport;
48
+ private boolean mRequireActivity;
48
49
  private @Nullable LifecycleState mInitialLifecycleState;
49
50
  private @Nullable UIImplementationProvider mUIImplementationProvider;
50
51
  private @Nullable NativeModuleCallExceptionHandler mNativeModuleCallExceptionHandler;
@@ -171,6 +172,16 @@ public class ReactInstanceManagerBuilder {
171
172
  return this;
172
173
  }
173
174
 
175
+ /**
176
+ * When {@code false}, indicates that correct usage of React Native will NOT involve an Activity.
177
+ * For the vast majority of Android apps in the ecosystem, this will not need to change. Unless
178
+ * you really know what you're doing, you should probably not change this!
179
+ */
180
+ public ReactInstanceManagerBuilder setRequireActivity(boolean requireActivity) {
181
+ mRequireActivity = requireActivity;
182
+ return this;
183
+ }
184
+
174
185
  /**
175
186
  * Sets the initial lifecycle state of the host. For example, if the host is already resumed at
176
187
  * creation time, we wouldn't expect an onResume call until we get an onPause call.
@@ -283,6 +294,7 @@ public class ReactInstanceManagerBuilder {
283
294
  mJSMainModulePath,
284
295
  mPackages,
285
296
  mUseDeveloperSupport,
297
+ mRequireActivity,
286
298
  mBridgeIdleDebugListener,
287
299
  Assertions.assertNotNull(mInitialLifecycleState, "Initial lifecycle state was not set"),
288
300
  mUIImplementationProvider,
@@ -68,6 +68,7 @@ public abstract class ReactNativeHost {
68
68
  .setApplication(mApplication)
69
69
  .setJSMainModulePath(getJSMainModuleName())
70
70
  .setUseDeveloperSupport(getUseDeveloperSupport())
71
+ .setRequireActivity(getShouldRequireActivity())
71
72
  .setRedBoxHandler(getRedBoxHandler())
72
73
  .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
73
74
  .setUIImplementationProvider(getUIImplementationProvider())
@@ -124,6 +125,11 @@ public abstract class ReactNativeHost {
124
125
  return null;
125
126
  }
126
127
 
128
+ /** Returns whether or not to treat it as normal if Activity is null. */
129
+ public boolean getShouldRequireActivity() {
130
+ return true;
131
+ }
132
+
127
133
  /**
128
134
  * Returns the name of the main module. Determines the URL used to fetch the JS bundle from Metro.
129
135
  * It is only used when dev support is enabled. This is the first file to be executed once the
@@ -22,5 +22,5 @@ public class ReactNativeVersion {
22
22
  "major", 0,
23
23
  "minor", 0,
24
24
  "patch", 0,
25
- "prerelease", "1a2b7fe2e");
25
+ "prerelease", "1b5cf312a");
26
26
  }
@@ -22,7 +22,7 @@ constexpr struct {
22
22
  int32_t Major = 0;
23
23
  int32_t Minor = 0;
24
24
  int32_t Patch = 0;
25
- std::string_view Prerelease = "1a2b7fe2e";
25
+ std::string_view Prerelease = "1b5cf312a";
26
26
  } ReactNativeVersion;
27
27
 
28
28
  } // namespace facebook::react
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "devtools-protocol": "0.0.730699",
36
- "yargs": "^14.2.0"
36
+ "yargs": "^15.3.0"
37
37
  },
38
38
  "beachball": {
39
39
  "shouldPublish": false