react-peer-chat 0.8.1 → 0.8.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/README.md CHANGED
@@ -255,10 +255,18 @@ function Chat({ text = true, audio = true, onMessageReceived, dialogOptions, pro
255
255
  </dialog>
256
256
  </div>
257
257
  )}
258
- {audio && <button>{audioEnabled ? <BsFillMicFill title="Turn mic off" onClick={() => setAudio(false)} /> : <BsFillMicMuteFill title="Turn mic on" onClick={() => setAudio(true)} />}</button>}
258
+ {audio && (
259
+ <button>
260
+ {audioEnabled ? <BsFillMicFill title="Turn mic off" onClick={() => setAudio(false)} /> : <BsFillMicMuteFill title="Turn mic on" onClick={() => setAudio(true)} />}
261
+ </button>
262
+ )}
259
263
  </>
260
264
  )}
261
- {audio && audioEnabled && <audio ref={audioStreamRef} autoPlay style={{ display: "none" }} />}
265
+ {audio && (
266
+ <button className="rpc-button" onClick={() => setAudio(!audioEnabled)}>
267
+ {audioEnabled ? <BsFillMicFill title="Turn mic off" /> : <BsFillMicMuteFill title="Turn mic on" />}
268
+ </button>
269
+ )}
262
270
  </div>
263
271
  );
264
272
  }
@@ -55,7 +55,15 @@ function BiSolidMessageX(props) {
55
55
  return /* @__PURE__ */ React.createElement("span", __spreadValues({ className: "rpc-icon-container" }, props), /* @__PURE__ */ React.createElement("svg", { viewBox: "0 0 24 24", width: "1.25rem", height: "1.25rem" }, /* @__PURE__ */ React.createElement("path", { d: "M20 2H4c-1.103 0-2 .894-2 1.992v12.016C2 17.106 2.897 18 4 18h3v4l6.351-4H20c1.103 0 2-.894 2-1.992V3.992A1.998 1.998 0 0 0 20 2zm-3.293 11.293-1.414 1.414L12 11.414l-3.293 3.293-1.414-1.414L10.586 10 7.293 6.707l1.414-1.414L12 8.586l3.293-3.293 1.414 1.414L13.414 10l3.293 3.293z" })));
56
56
  }
57
57
  function GrSend(props) {
58
- return /* @__PURE__ */ React.createElement("span", __spreadValues({ className: "rpc-icon-container" }, props), /* @__PURE__ */ React.createElement("svg", { viewBox: "0 0 24 24", width: "1.25rem", height: "1.25rem", className: "rpc-invert" }, /* @__PURE__ */ React.createElement("path", { fill: "none", stroke: "#000", strokeWidth: 2, d: "M22,3 L2,11 L20.5,19 L22,3 Z M10,20.5 L13,16 M15.5,9.5 L9,14 L9.85884537,20.0119176 C9.93680292,20.5576204 10.0751625,20.5490248 10.1651297,20.009222 L11,15 L15.5,9.5 Z" })));
58
+ return /* @__PURE__ */ React.createElement("span", __spreadValues({ className: "rpc-icon-container" }, props), /* @__PURE__ */ React.createElement("svg", { viewBox: "0 0 24 24", width: "1.25rem", height: "1.25rem", className: "rpc-invert" }, /* @__PURE__ */ React.createElement(
59
+ "path",
60
+ {
61
+ fill: "none",
62
+ stroke: "#000",
63
+ strokeWidth: 2,
64
+ d: "M22,3 L2,11 L20.5,19 L22,3 Z M10,20.5 L13,16 M15.5,9.5 L9,14 L9.85884537,20.0119176 C9.93680292,20.5576204 10.0751625,20.5490248 10.1651297,20.009222 L11,15 L15.5,9.5 Z"
65
+ }
66
+ )));
59
67
  }
60
68
  function BsFillMicFill(props) {
61
69
  return /* @__PURE__ */ React.createElement("span", __spreadValues({ className: "rpc-icon-container" }, props), /* @__PURE__ */ React.createElement("svg", { viewBox: "0 0 16 16", fill: "currentColor", width: "1.25rem", height: "1.25rem" }, /* @__PURE__ */ React.createElement("path", { d: "M5 3a3 3 0 0 1 6 0v5a3 3 0 0 1-6 0V3z" }), /* @__PURE__ */ React.createElement("path", { d: "M3.5 6.5A.5.5 0 0 1 4 7v1a4 4 0 0 0 8 0V7a.5.5 0 0 1 1 0v1a5 5 0 0 1-4.5 4.975V15h3a.5.5 0 0 1 0 1h-7a.5.5 0 0 1 0-1h3v-2.025A5 5 0 0 1 3 8V7a.5.5 0 0 1 .5-.5z" })));
package/dist/icons.js CHANGED
@@ -1 +1 @@
1
- export { BiSolidMessageDetail, BiSolidMessageX, BsFillMicFill, BsFillMicMuteFill, GrSend } from './chunks/chunk-65736FR2.js';
1
+ export { BiSolidMessageDetail, BiSolidMessageX, BsFillMicFill, BsFillMicMuteFill, GrSend } from './chunks/chunk-4CBQRGQ3.js';
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import React__default from 'react';
3
3
  import { useChatProps, RemotePeers, Message, ChatProps } from './types.js';
4
4
  import 'peerjs';
5
5
 
6
- declare function useChat({ name, peerId, remotePeerId, peerOptions, text, recoverChat, audio: allowed, onError, onMicError, onMessageSent, onMessageReceived }: useChatProps): {
6
+ declare function useChat({ name, peerId, remotePeerId, peerOptions, text, recoverChat, audio: allowed, onError, onMicError, onMessageSent, onMessageReceived, }: useChatProps): {
7
7
  peerId: string;
8
8
  audioStreamRef: React.RefObject<HTMLMediaElement | null>;
9
9
  remotePeers: RemotePeers;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { __spreadValues, __async, __objRest, BiSolidMessageX, BiSolidMessageDetail, GrSend, BsFillMicFill, BsFillMicMuteFill } from './chunks/chunk-65736FR2.js';
1
+ import { __spreadValues, __async, __objRest, BiSolidMessageX, BiSolidMessageDetail, GrSend, BsFillMicFill, BsFillMicMuteFill } from './chunks/chunk-4CBQRGQ3.js';
2
2
  import React, { useRef, useState, useEffect } from 'react';
3
3
 
4
4
  // src/connection.tsx
@@ -23,7 +23,12 @@ var defaultConfig = {
23
23
  }
24
24
  ].concat(
25
25
  turnAccounts.map((account) => __spreadValues({
26
- urls: ["turn:standard.relay.metered.ca:80", "turn:standard.relay.metered.ca:80?transport=tcp", "turn:standard.relay.metered.ca:443", "turns:standard.relay.metered.ca:443?transport=tcp"]
26
+ urls: [
27
+ "turn:standard.relay.metered.ca:80",
28
+ "turn:standard.relay.metered.ca:80?transport=tcp",
29
+ "turn:standard.relay.metered.ca:443",
30
+ "turns:standard.relay.metered.ca:443?transport=tcp"
31
+ ]
27
32
  }, account))
28
33
  )
29
34
  };
@@ -56,7 +61,19 @@ var clearChat = () => {
56
61
  var addPrefix = (str) => `rpc-${str}`;
57
62
 
58
63
  // src/hooks.tsx
59
- function useChat({ name, peerId, remotePeerId = [], peerOptions, text = true, recoverChat = false, audio: allowed = true, onError = () => alert("Browser not supported! Try some other browser."), onMicError = () => alert("Microphone not accessible!"), onMessageSent, onMessageReceived }) {
64
+ function useChat({
65
+ name,
66
+ peerId,
67
+ remotePeerId = [],
68
+ peerOptions,
69
+ text = true,
70
+ recoverChat = false,
71
+ audio: allowed = true,
72
+ onError = () => alert("Browser not supported! Try some other browser."),
73
+ onMicError = () => alert("Microphone not accessible!"),
74
+ onMessageSent,
75
+ onMessageReceived
76
+ }) {
60
77
  const [audio, setAudio] = useAudio(allowed);
61
78
  const audioStreamRef = useRef(null);
62
79
  const connRef = useRef({});
@@ -197,7 +214,7 @@ function useStorage(key, initialValue, local = false) {
197
214
  }
198
215
  function useAudio(allowed) {
199
216
  const [audio, setAudio] = useStorage("rpc-audio", false, true);
200
- const enabled = audio || allowed;
217
+ const enabled = audio && allowed;
201
218
  return [enabled, setAudio];
202
219
  }
203
220
 
@@ -273,7 +290,7 @@ function Chat(_a) {
273
290
  },
274
291
  /* @__PURE__ */ React.createElement("input", { ref: inputRef, className: "rpc-input rpc-font", placeholder: "Enter a message" }),
275
292
  /* @__PURE__ */ React.createElement("button", { type: "submit", className: "rpc-button" }, /* @__PURE__ */ React.createElement(GrSend, { title: "Send message" }))
276
- )))), audio && /* @__PURE__ */ React.createElement("button", { className: "rpc-button" }, audioEnabled ? /* @__PURE__ */ React.createElement(BsFillMicFill, { title: "Turn mic off", onClick: () => setAudio(false) }) : /* @__PURE__ */ React.createElement(BsFillMicMuteFill, { title: "Turn mic on", onClick: () => setAudio(true) }))), audio && audioEnabled && /* @__PURE__ */ React.createElement("audio", { ref: audioStreamRef, autoPlay: true, style: { display: "none" } }));
293
+ )))), audio && /* @__PURE__ */ React.createElement("button", { className: "rpc-button", onClick: () => setAudio(!audioEnabled) }, audioEnabled ? /* @__PURE__ */ React.createElement(BsFillMicFill, { title: "Turn mic off" }) : /* @__PURE__ */ React.createElement(BsFillMicMuteFill, { title: "Turn mic on" }))), audio && audioEnabled && /* @__PURE__ */ React.createElement("audio", { ref: audioStreamRef, autoPlay: true, style: { display: "none" } }));
277
294
  }
278
295
 
279
296
  export { clearChat, Chat as default, useChat };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-peer-chat",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "An easy to use react component for impleting peer-to-peer chatting.",
5
5
  "license": "MIT",
6
6
  "author": "Sahil Aggarwal <aggarwalsahil2004@gmail.com>",