react-native-spalla-player 0.16.1 → 0.16.2

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/app.plugin.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./plugin/withPipAndroid');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-spalla-player",
3
- "version": "0.16.1",
3
+ "version": "0.16.2",
4
4
  "description": "Spalla SDK for RN",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",
@@ -15,7 +15,8 @@
15
15
  "types": "./lib/typescript/commonjs/src/index.d.ts",
16
16
  "default": "./lib/commonjs/index.js"
17
17
  }
18
- }
18
+ },
19
+ "./app.plugin.js": "./app.plugin.js"
19
20
  },
20
21
  "files": [
21
22
  "src",
@@ -23,6 +24,8 @@
23
24
  "android",
24
25
  "ios",
25
26
  "cpp",
27
+ "plugin",
28
+ "app.plugin.js",
26
29
  "*.podspec",
27
30
  "!ios/build",
28
31
  "!android/build",
@@ -79,6 +82,7 @@
79
82
  "react": "18.3.1",
80
83
  "react-native": "0.75.4",
81
84
  "react-native-builder-bob": "^0.30.2",
85
+ "react-native-safe-area-context": "^5.4.1",
82
86
  "release-it": "^15.0.0",
83
87
  "turbo": "^1.10.7",
84
88
  "typescript": "^5.2.2"
@@ -88,7 +92,8 @@
88
92
  },
89
93
  "peerDependencies": {
90
94
  "react": "*",
91
- "react-native": "*"
95
+ "react-native": "*",
96
+ "react-native-safe-area-context": "*"
92
97
  },
93
98
  "workspaces": [
94
99
  "example"
@@ -183,5 +188,11 @@
183
188
  "type": "view-legacy",
184
189
  "languages": "kotlin-swift",
185
190
  "version": "0.41.2"
191
+ },
192
+ "expo": {
193
+ "plugin": "./app.plugin.js"
194
+ },
195
+ "dependencies": {
196
+ "@expo/config-plugins": "^54.0.4"
186
197
  }
187
198
  }
@@ -0,0 +1,2 @@
1
+ module.exports = require('./withPipAndroid');
2
+ module.exports.default = module.exports;
@@ -0,0 +1,70 @@
1
+ const {
2
+ withAndroidManifest,
3
+ withMainActivity,
4
+ } = require('@expo/config-plugins');
5
+
6
+ /**
7
+ * Adds supportsPictureInPicture="true" to MainActivity
8
+ */
9
+ function withPipManifest(config) {
10
+ return withAndroidManifest(config, (config) => {
11
+ const manifest = config.modResults.manifest;
12
+ const app = manifest.application?.[0];
13
+
14
+ if (!app?.activity) return config;
15
+
16
+ const mainActivity = app.activity.find(
17
+ (activity) => activity.$?.['android:name'] === '.MainActivity'
18
+ );
19
+
20
+ if (!mainActivity) return config;
21
+
22
+ mainActivity.$['android:supportsPictureInPicture'] = 'true';
23
+ return config;
24
+ });
25
+ }
26
+
27
+ /**
28
+ * Injects onUserLeaveHint() into MainActivity.kt
29
+ */
30
+ function withPipMainActivity(config) {
31
+ return withMainActivity(config, (config) => {
32
+ let contents = config.modResults.contents;
33
+
34
+ if (contents.includes('override fun onUserLeaveHint()')) {
35
+ return config;
36
+ }
37
+
38
+ // Add necessary imports
39
+ if (!contents.includes('import com.spallaplayer.SpallaPlayerPipModule')) {
40
+ contents = contents.replace(
41
+ /import\s+android\.os\.Bundle/,
42
+ `import android.os.Bundle
43
+ import com.spallaplayer.SpallaPlayerPipModule`
44
+ );
45
+ }
46
+
47
+ const method = `
48
+ override fun onUserLeaveHint() {
49
+ super.onUserLeaveHint()
50
+ reactNativeHost.reactInstanceManager.currentReactContext?.let { context ->
51
+ context.getNativeModule(SpallaPlayerPipModule::class.java)?.onUserLeaveHint()
52
+ }
53
+ }
54
+ `;
55
+
56
+ contents = contents.replace(
57
+ /class MainActivity[^{]*\{/,
58
+ (match) => `${match}${method}`
59
+ );
60
+
61
+ config.modResults.contents = contents;
62
+ return config;
63
+ });
64
+ }
65
+
66
+ module.exports = function withPipAndroid(config) {
67
+ config = withPipManifest(config);
68
+ config = withPipMainActivity(config);
69
+ return config;
70
+ };