react-native-spalla-player 0.16.2 → 0.16.3

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.
@@ -11,6 +11,7 @@ class SpallaPlayerPipModule(reactContext: ReactApplicationContext) : ReactContex
11
11
  companion object {
12
12
  const val NAME = "SpallaPlayerPipModule"
13
13
  private var activePlayerManager: RNSpallaPlayerManager? = null
14
+ private var instance: SpallaPlayerPipModule? = null
14
15
 
15
16
  fun registerPlayerManager(manager: RNSpallaPlayerManager) {
16
17
  activePlayerManager = manager
@@ -21,12 +22,27 @@ class SpallaPlayerPipModule(reactContext: ReactApplicationContext) : ReactContex
21
22
  activePlayerManager = null
22
23
  }
23
24
  }
25
+
26
+ /**
27
+ * A static method that MainActivity can call without needing a ReactContext.
28
+ * It safely forwards the call to the active module instance.
29
+ */
30
+ fun triggerUserLeaveHint() {
31
+ // Check if an instance exists before calling the method
32
+ instance?.onUserLeaveHint()
33
+ }
24
34
  }
25
35
 
26
36
  override fun getName(): String = NAME
27
37
 
38
+ init {
39
+ // When React Native creates the module, assign it to our static property
40
+ instance = this
41
+ }
42
+
28
43
  @ReactMethod
29
44
  fun onUserLeaveHint() {
30
45
  activePlayerManager?.triggerPipImmediate()
31
46
  }
47
+
32
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-spalla-player",
3
- "version": "0.16.2",
3
+ "version": "0.16.3",
4
4
  "description": "Spalla SDK for RN",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",
@@ -82,7 +82,6 @@
82
82
  "react": "18.3.1",
83
83
  "react-native": "0.75.4",
84
84
  "react-native-builder-bob": "^0.30.2",
85
- "react-native-safe-area-context": "^5.4.1",
86
85
  "release-it": "^15.0.0",
87
86
  "turbo": "^1.10.7",
88
87
  "typescript": "^5.2.2"
@@ -92,8 +91,7 @@
92
91
  },
93
92
  "peerDependencies": {
94
93
  "react": "*",
95
- "react-native": "*",
96
- "react-native-safe-area-context": "*"
94
+ "react-native": "*"
97
95
  },
98
96
  "workspaces": [
99
97
  "example"
@@ -47,9 +47,7 @@ import com.spallaplayer.SpallaPlayerPipModule`
47
47
  const method = `
48
48
  override fun onUserLeaveHint() {
49
49
  super.onUserLeaveHint()
50
- reactNativeHost.reactInstanceManager.currentReactContext?.let { context ->
51
- context.getNativeModule(SpallaPlayerPipModule::class.java)?.onUserLeaveHint()
52
- }
50
+ SpallaPlayerPipModule.triggerUserLeaveHint()
53
51
  }
54
52
  `;
55
53