react-peer-chat 0.5.4 → 0.6.0
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/dist/index.d.ts +8 -8
- package/dist/index.js +22 -1
- package/package.json +8 -3
package/dist/index.d.ts
CHANGED
|
@@ -3,27 +3,27 @@ import { PeerOptions as ImportedPeerOptions } from 'peerjs';
|
|
|
3
3
|
export type RemotePeerId = string | string[];
|
|
4
4
|
export type PeerOptions = ImportedPeerOptions;
|
|
5
5
|
export type DialogPosition = 'left' | 'center' | 'right';
|
|
6
|
-
export
|
|
6
|
+
export type DialogOptions = {
|
|
7
7
|
position?: DialogPosition;
|
|
8
8
|
style?: CSSProperties;
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
10
|
export type RemotePeers = {
|
|
11
11
|
[id: string]: string;
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export type Message = {
|
|
14
14
|
id: string;
|
|
15
15
|
text: string;
|
|
16
|
-
}
|
|
17
|
-
export
|
|
16
|
+
};
|
|
17
|
+
export type ChildrenOptions = {
|
|
18
18
|
remotePeers?: RemotePeers;
|
|
19
19
|
messages?: Message[];
|
|
20
20
|
addMessage?: (message: Message, sendToRemotePeer?: boolean) => void;
|
|
21
21
|
audio?: boolean;
|
|
22
22
|
setAudio?: (audio: boolean) => void;
|
|
23
|
-
}
|
|
23
|
+
};
|
|
24
24
|
export type Children = (childrenOptions: ChildrenOptions) => ReactNode;
|
|
25
25
|
export type Props = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
26
|
-
export
|
|
26
|
+
export type ChatProps = {
|
|
27
27
|
name?: string;
|
|
28
28
|
peerId: string;
|
|
29
29
|
remotePeerId?: RemotePeerId;
|
|
@@ -36,7 +36,7 @@ export interface ChatProps {
|
|
|
36
36
|
onMicError?: Function;
|
|
37
37
|
children?: Children;
|
|
38
38
|
props?: Props;
|
|
39
|
-
}
|
|
39
|
+
};
|
|
40
40
|
export type { IconProps } from './icons.js';
|
|
41
41
|
export default function Chat({ name, peerId, remotePeerId, peerOptions, text, recoverChat, voice, dialogOptions, onError, onMicError, children, props }: ChatProps): React.JSX.Element;
|
|
42
42
|
export declare const clearChat: () => void;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import useStorage, { removeStorage } from './storage.js';
|
|
3
3
|
import { BiSolidMessageDetail, BiSolidMessageX, BsFillMicFill, BsFillMicMuteFill, GrSend } from './icons.js';
|
|
4
|
+
const turnAccounts = [
|
|
5
|
+
{ username: "85057be497c4a2abf5217397", credential: "5q+3qaVjpoCBt9Dm" },
|
|
6
|
+
{ username: "5b01145c9a5d422eaafcc038", credential: "469knsKDfV4YVHlY" },
|
|
7
|
+
{ username: "497c3ba46efa43c87910feee", credential: "xtQekYrNSUm2bFTG" },
|
|
8
|
+
{ username: "1d0ec99bb76eae3e0a33f124", credential: "1a72ULwxpT7yhmA3" },
|
|
9
|
+
{ username: "49a002173f35f8a72344e702", credential: "I1KFRZ2aea+bZvNf" },
|
|
10
|
+
{ username: "3c25ba948daeab04f9b66187", credential: "FQB3GQwd27Y0dPeK" }
|
|
11
|
+
];
|
|
12
|
+
const defaultConfig = {
|
|
13
|
+
iceServers: [{
|
|
14
|
+
urls: [
|
|
15
|
+
"stun:stun.l.google.com:19302",
|
|
16
|
+
"stun:stun.relay.metered.ca:80"
|
|
17
|
+
]
|
|
18
|
+
}].concat(turnAccounts.map(account => (Object.assign({ urls: [
|
|
19
|
+
"turn:standard.relay.metered.ca:80",
|
|
20
|
+
"turn:standard.relay.metered.ca:80?transport=tcp",
|
|
21
|
+
"turn:standard.relay.metered.ca:443",
|
|
22
|
+
"turns:standard.relay.metered.ca:443?transport=tcp"
|
|
23
|
+
] }, account))))
|
|
24
|
+
};
|
|
4
25
|
function closeConnection(conn) {
|
|
5
26
|
conn.removeAllListeners();
|
|
6
27
|
conn.close();
|
|
@@ -63,7 +84,7 @@ export default function Chat({ name, peerId, remotePeerId = [], peerOptions, tex
|
|
|
63
84
|
const { Peer, util: { supports: { audioVideo, data } } } = await import('peerjs');
|
|
64
85
|
if (!data || !audioVideo)
|
|
65
86
|
return onError();
|
|
66
|
-
const peer = new Peer(peerId, peerOptions);
|
|
87
|
+
const peer = new Peer(peerId, Object.assign({ config: defaultConfig }, peerOptions));
|
|
67
88
|
setPeer(peer);
|
|
68
89
|
})();
|
|
69
90
|
}, [audio]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-peer-chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "An easy to use react component for impleting peer-to-peer chatting.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,7 +18,12 @@
|
|
|
18
18
|
"p2p",
|
|
19
19
|
"peer-to-peer",
|
|
20
20
|
"webrtc",
|
|
21
|
-
"react-peer-chat"
|
|
21
|
+
"react-peer-chat",
|
|
22
|
+
"typescript",
|
|
23
|
+
"voice-chat",
|
|
24
|
+
"p2p-chat",
|
|
25
|
+
"text-chat",
|
|
26
|
+
"peerjs-webrtc"
|
|
22
27
|
],
|
|
23
28
|
"author": "Sahil Aggarwal",
|
|
24
29
|
"license": "MIT",
|
|
@@ -31,7 +36,7 @@
|
|
|
31
36
|
"react-dom": ">=16.0.0"
|
|
32
37
|
},
|
|
33
38
|
"devDependencies": {
|
|
34
|
-
"@types/react": "^18.2.
|
|
39
|
+
"@types/react": "^18.2.47"
|
|
35
40
|
},
|
|
36
41
|
"dependencies": {
|
|
37
42
|
"peerjs": "^1.5.2"
|