movius-chats 1.3.10 → 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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "movius-chats",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.13",
|
|
4
4
|
"description": "A highly customizable, feature-rich chat interface component for React Native applications",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"src",
|
|
12
12
|
"lib",
|
|
13
|
+
"scripts",
|
|
13
14
|
"!**/__tests__",
|
|
14
15
|
"!**/__fixtures__",
|
|
15
16
|
"!**/__mocks__"
|
|
@@ -24,7 +25,8 @@
|
|
|
24
25
|
"build:js": "rollup -c rollup.config.mjs",
|
|
25
26
|
"clean": "rimraf lib",
|
|
26
27
|
"release": "release-it",
|
|
27
|
-
"example": "yarn --cwd example"
|
|
28
|
+
"example": "yarn --cwd example",
|
|
29
|
+
"postinstall": "node scripts/patchSound.js"
|
|
28
30
|
},
|
|
29
31
|
"repository": {
|
|
30
32
|
"type": "git",
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
const candidates = [
|
|
9
|
+
// standard flat node_modules layout
|
|
10
|
+
path.resolve(__dirname, '..', '..', 'react-native-sound', 'Sound.js'),
|
|
11
|
+
// hoisted monorepo layout (yarn workspaces / pnpm)
|
|
12
|
+
path.resolve(__dirname, '..', '..', '..', 'react-native-sound', 'Sound.js'),
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const OLD_IMPORT =
|
|
16
|
+
"var resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');";
|
|
17
|
+
|
|
18
|
+
const NEW_IMPORT = [
|
|
19
|
+
"var _ras = require('react-native/Libraries/Image/resolveAssetSource');",
|
|
20
|
+
'// movius-chats patch: support New Architecture (resolveAssetSource moved to Image)',
|
|
21
|
+
"var resolveAssetSource = typeof _ras === 'function'",
|
|
22
|
+
" ? _ras",
|
|
23
|
+
" : (_ras && typeof _ras.default === 'function'",
|
|
24
|
+
" ? _ras.default",
|
|
25
|
+
" : require('react-native').Image.resolveAssetSource.bind(require('react-native').Image));",
|
|
26
|
+
].join('\n');
|
|
27
|
+
|
|
28
|
+
const PATCH_MARKER = '// movius-chats patch:';
|
|
29
|
+
|
|
30
|
+
let patched = false;
|
|
31
|
+
|
|
32
|
+
for (const soundPath of candidates) {
|
|
33
|
+
if (!fs.existsSync(soundPath)) continue;
|
|
34
|
+
|
|
35
|
+
let src = fs.readFileSync(soundPath, 'utf8');
|
|
36
|
+
|
|
37
|
+
if (src.includes(PATCH_MARKER)) {
|
|
38
|
+
console.log('[movius-chats] react-native-sound already patched — skipping.');
|
|
39
|
+
patched = true;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!src.includes(OLD_IMPORT)) {
|
|
44
|
+
// Different version of react-native-sound; the import line changed.
|
|
45
|
+
console.warn(
|
|
46
|
+
'[movius-chats] Could not locate the resolveAssetSource import in ' +
|
|
47
|
+
soundPath +
|
|
48
|
+
'.\n' +
|
|
49
|
+
'If you see a "resolveAssetSource is not a function" error, apply the\n' +
|
|
50
|
+
'patch manually — see the movius-chats README Troubleshooting section.'
|
|
51
|
+
);
|
|
52
|
+
patched = true; // don't repeat the warning for every candidate
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
src = src.replace(OLD_IMPORT, NEW_IMPORT);
|
|
57
|
+
fs.writeFileSync(soundPath, src, 'utf8');
|
|
58
|
+
console.log('[movius-chats] ✅ react-native-sound patched for New Architecture compatibility.');
|
|
59
|
+
patched = true;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!patched) {
|
|
64
|
+
// react-native-sound is not installed yet (peer dep, optional dep, etc.)
|
|
65
|
+
// Silently skip — the patch will run again if the user installs it later.
|
|
66
|
+
}
|
|
@@ -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;
|