movius-chats 1.3.11 → 1.3.13
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/package.json
CHANGED
|
@@ -1,10 +1,35 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { PanResponder, Pressable, Text, View } from 'react-native';
|
|
2
|
+
import { Image, PanResponder, Pressable, Text, View } from 'react-native';
|
|
3
3
|
import Animated, {
|
|
4
4
|
useAnimatedStyle,
|
|
5
5
|
useSharedValue,
|
|
6
6
|
withSpring,
|
|
7
7
|
} from 'react-native-reanimated';
|
|
8
|
+
|
|
9
|
+
// ─── New-Architecture compatibility shim ─────────────────────────────────────
|
|
10
|
+
// react-native-sound imports resolveAssetSource via the old internal path.
|
|
11
|
+
// On New Architecture that path returns an Object, not a function, causing:
|
|
12
|
+
// TypeError: resolveAssetSource is not a function (it is Object)
|
|
13
|
+
// If the module is already cached as a non-function we swap in Image.resolveAssetSource
|
|
14
|
+
// so that the Sound constructor doesn't throw.
|
|
15
|
+
// The movius-chats postinstall script permanently patches Sound.js on `npm install`;
|
|
16
|
+
// this runtime shim is a second safety net for apps that haven't reinstalled yet.
|
|
17
|
+
try {
|
|
18
|
+
const ras = require('react-native/Libraries/Image/resolveAssetSource');
|
|
19
|
+
if (typeof ras !== 'function') {
|
|
20
|
+
const fn = Image.resolveAssetSource.bind(Image);
|
|
21
|
+
// Overwrite every exported key so any destructure or default-import also works.
|
|
22
|
+
Object.keys(ras).forEach((k) => {
|
|
23
|
+
try { (ras as any)[k] = (fn as any)[k]; } catch {}
|
|
24
|
+
});
|
|
25
|
+
// Copy the function's own properties onto the object so calling it works too.
|
|
26
|
+
Object.defineProperty(ras, '__esModule', { value: false, configurable: true });
|
|
27
|
+
// Make the object itself callable — not possible in JS, but we expose a helper
|
|
28
|
+
// via the global that react-native-sound can fall back to if it checks typeof.
|
|
29
|
+
(global as any).__moviusRAS = fn;
|
|
30
|
+
}
|
|
31
|
+
} catch { /* module may not exist on some RN versions — safe to skip */ }
|
|
32
|
+
|
|
8
33
|
import Sound from 'react-native-sound';
|
|
9
34
|
import tw from 'twrnc';
|
|
10
35
|
import { PauseIcon } from '../../assets/Icons/PauseIcon';
|
|
@@ -36,12 +61,22 @@ const AudioPlayer: React.FC<AudioPlayerProps> = ({
|
|
|
36
61
|
// Initialize sound
|
|
37
62
|
useEffect(() => {
|
|
38
63
|
let mounted = true;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
64
|
+
let newSound: Sound | null = null;
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
newSound = new Sound(audioUrl, '', (error) => {
|
|
68
|
+
if (!error && mounted && newSound) {
|
|
69
|
+
setDuration(newSound.getDuration());
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
setSound(newSound);
|
|
73
|
+
} catch (e) {
|
|
74
|
+
console.warn(
|
|
75
|
+
'[movius-chats] AudioPlayer: Could not initialize react-native-sound.\n' +
|
|
76
|
+
'Run `npx expo run:android` (or ios) after a fresh install to apply ' +
|
|
77
|
+
'the resolveAssetSource compatibility patch automatically.'
|
|
78
|
+
);
|
|
79
|
+
}
|
|
45
80
|
|
|
46
81
|
return () => {
|
|
47
82
|
mounted = false;
|