expo-modules-core 0.6.0 → 0.6.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/CHANGELOG.md CHANGED
@@ -10,6 +10,28 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.6.4 — 2022-01-05
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - Fix `ReactInstanceManager.onHostPause` exception from moving Android apps to background. ([#15748](https://github.com/expo/expo/pull/15748) by [@kudo](https://github.com/kudo))
18
+
19
+ ## 0.6.3 — 2021-12-16
20
+
21
+ ### 🐛 Bug fixes
22
+
23
+ - Fixed the deep link wasn't passed to the application if the application wasn't running when the deep link was sent. ([#15593](https://github.com/expo/expo/pull/15593) by [@lukmccall](https://github.com/lukmccall))
24
+
25
+ ## 0.6.2 — 2021-12-15
26
+
27
+ ### 🎉 New features
28
+
29
+ - Add `onNewIntent` and `onBackPressed` support to `ReactActivityLifecycleListener`. ([#15550](https://github.com/expo/expo/pull/15550) by [@Kudo](https://github.com/Kudo))
30
+
31
+ ## 0.6.1 — 2021-12-08
32
+
33
+ _This version does not introduce any user-facing changes._
34
+
13
35
  ## 0.6.0 — 2021-12-03
14
36
 
15
37
  ### 🎉 New features
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '0.6.0'
6
+ version = '0.6.4'
7
7
 
8
8
  buildscript {
9
9
  // Simple helper that allows the root project to override versions declared by this library.
@@ -58,7 +58,7 @@ android {
58
58
  targetSdkVersion safeExtGet("targetSdkVersion", 30)
59
59
  consumerProguardFiles 'proguard-rules.pro'
60
60
  versionCode 1
61
- versionName "0.6.0"
61
+ versionName "0.6.4"
62
62
  }
63
63
  lintOptions {
64
64
  abortOnError false
@@ -15,6 +15,7 @@ import expo.modules.core.ModuleRegistry;
15
15
  import expo.modules.core.interfaces.InternalModule;
16
16
  import expo.modules.core.interfaces.Package;
17
17
  import expo.modules.kotlin.KotlinInteropModuleRegistry;
18
+ import expo.modules.kotlin.ModulesProvider;
18
19
  import expo.modules.kotlin.views.ViewWrapperDelegateHolder;
19
20
 
20
21
  /**
@@ -24,6 +25,7 @@ import expo.modules.kotlin.views.ViewWrapperDelegateHolder;
24
25
  */
25
26
  public class ModuleRegistryAdapter implements ReactPackage {
26
27
  protected ReactModuleRegistryProvider mModuleRegistryProvider;
28
+ protected ModulesProvider mModulesProvider;
27
29
  protected ReactAdapterPackage mReactAdapterPackage = new ReactAdapterPackage();
28
30
  private NativeModulesProxy mModulesProxy;
29
31
  // We need to save all view holders to update them when the new kotlin module registry will be created.
@@ -37,6 +39,11 @@ public class ModuleRegistryAdapter implements ReactPackage {
37
39
  mModuleRegistryProvider = moduleRegistryProvider;
38
40
  }
39
41
 
42
+ public ModuleRegistryAdapter(ReactModuleRegistryProvider moduleRegistryProvider, ModulesProvider modulesProvider) {
43
+ mModuleRegistryProvider = moduleRegistryProvider;
44
+ mModulesProvider = modulesProvider;
45
+ }
46
+
40
47
  @Override
41
48
  public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
42
49
  ModuleRegistry moduleRegistry = mModuleRegistryProvider.get(reactContext);
@@ -57,7 +64,7 @@ public class ModuleRegistryAdapter implements ReactPackage {
57
64
  protected List<NativeModule> getNativeModulesFromModuleRegistry(ReactApplicationContext reactContext, ModuleRegistry moduleRegistry) {
58
65
  List<NativeModule> nativeModulesList = new ArrayList<>(2);
59
66
 
60
- mModulesProxy = new NativeModulesProxy(reactContext, moduleRegistry);
67
+ mModulesProxy = createNativeModulesProxy(reactContext, moduleRegistry);
61
68
  nativeModulesList.add(mModulesProxy);
62
69
 
63
70
  // Add listener that will notify expo.modules.core.ModuleRegistry when all modules are ready
@@ -97,4 +104,12 @@ public class ModuleRegistryAdapter implements ReactPackage {
97
104
 
98
105
  return viewManagerList;
99
106
  }
107
+
108
+ private NativeModulesProxy createNativeModulesProxy(ReactApplicationContext reactContext, ModuleRegistry moduleRegistry) {
109
+ if (mModulesProvider != null) {
110
+ return new NativeModulesProxy(reactContext, moduleRegistry, mModulesProvider);
111
+ } else {
112
+ return new NativeModulesProxy(reactContext, moduleRegistry);
113
+ }
114
+ }
100
115
  }
@@ -3,6 +3,7 @@ package expo.modules.adapters.react.apploader
3
3
  import android.content.Context
4
4
  import com.facebook.react.ReactApplication
5
5
  import com.facebook.react.ReactInstanceManager
6
+ import com.facebook.react.common.LifecycleState
6
7
  import expo.modules.apploader.HeadlessAppLoader
7
8
  import expo.modules.core.interfaces.Consumer
8
9
  import expo.modules.core.interfaces.DoNotStrip
@@ -43,7 +44,12 @@ class RNHeadlessAppLoader @DoNotStrip constructor(private val context: Context)
43
44
  return if (appRecords.containsKey(appScopeKey) && appRecords[appScopeKey] != null) {
44
45
  val appRecord: ReactInstanceManager = appRecords[appScopeKey]!!
45
46
  android.os.Handler(context.mainLooper).post {
46
- appRecord.destroy()
47
+ // Only destroy the `ReactInstanceManager` if it does not bind with an Activity.
48
+ // And The Activity would take over the ownership of `ReactInstanceManager`.
49
+ // This case happens when a user clicks a background task triggered notification immediately.
50
+ if (appRecord.lifecycleState == LifecycleState.BEFORE_CREATE) {
51
+ appRecord.destroy()
52
+ }
47
53
  HeadlessAppLoaderNotifier.notifyAppDestroyed(appScopeKey)
48
54
  appRecords.remove(appScopeKey)
49
55
  }
@@ -1,6 +1,7 @@
1
1
  package expo.modules.core.interfaces;
2
2
 
3
3
  import android.app.Activity;
4
+ import android.content.Intent;
4
5
  import android.os.Bundle;
5
6
 
6
7
  public interface ReactActivityLifecycleListener {
@@ -11,4 +12,26 @@ public interface ReactActivityLifecycleListener {
11
12
  default void onPause(Activity activity) {}
12
13
 
13
14
  default void onDestroy(Activity activity) {}
15
+
16
+ /**
17
+ * Called when {@link com.facebook.react.ReactActivity} received `onNewIntent`
18
+ * Every listener will receive this callback.
19
+ * `ReactActivityDelegateWrapper.onNewIntent` will get `true` if there's some module returns `true`
20
+ *
21
+ * @return true if this module wants to return `true` from `ReactActivityDelegateWrapper.onNewIntent`
22
+ */
23
+ default boolean onNewIntent(Intent intent) {
24
+ return false;
25
+ }
26
+
27
+ /**
28
+ * Called when {@link com.facebook.react.ReactActivity} received `onBackPressed`
29
+ * Every listener will receive this callback.
30
+ * `ReactActivityDelegateWrapper.onBackPressed` will get `true` if there's some module returns `true`
31
+ *
32
+ * @return true if this module wants to return `true` from `ReactActivityDelegateWrapper.onBackPressed`
33
+ */
34
+ default boolean onBackPressed() {
35
+ return false;
36
+ }
14
37
  }
@@ -21,8 +21,19 @@ open class ExpoAppDelegate: UIResponder, UIApplicationDelegate {
21
21
  // MARK: - Initializing the App
22
22
 
23
23
  open func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
24
- return subscribers.reduce(false) { result, subscriber in
25
- return subscriber.application?(application, willFinishLaunchingWithOptions: launchOptions) ?? false || result
24
+ let parsedSubscribers = subscribers.filter {
25
+ $0.responds(to: #selector(application(_:willFinishLaunchingWithOptions:)))
26
+ }
27
+
28
+ // If we can't find a subscriber that implements `willFinishLaunchingWithOptions`, we will delegate the decision if we can handel the passed URL to
29
+ // the `didFinishLaunchingWithOptions` method by returning `true` here.
30
+ // You can read more about how iOS handles deep links here: https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623112-application#discussion
31
+ if (parsedSubscribers.isEmpty) {
32
+ return true;
33
+ }
34
+
35
+ return parsedSubscribers.reduce(false) { result, subscriber in
36
+ return subscriber.application!(application, willFinishLaunchingWithOptions: launchOptions) || result
26
37
  }
27
38
  }
28
39
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-core",
3
- "version": "0.6.0",
3
+ "version": "0.6.4",
4
4
  "description": "The core of Expo Modules architecture",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -42,5 +42,5 @@
42
42
  "@testing-library/react-hooks": "^7.0.1",
43
43
  "expo-module-scripts": "^2.0.0"
44
44
  },
45
- "gitHead": "2e5c6983b86d5ecfca028ba64002897d8adc2cc4"
45
+ "gitHead": "81d318c3ac2db24ba192d2b3fc5a2dd1bbd8bd4d"
46
46
  }