react-peer-chat 0.8.1 → 0.8.3

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/.env ADDED
@@ -0,0 +1 @@
1
+ GITHUB_TOKEN=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
package/.release-it.js ADDED
@@ -0,0 +1,86 @@
1
+ const COMMIT_HASH_LENGTH = 7;
2
+
3
+ const typeMap = {
4
+ feat: "Features",
5
+ fix: "Bug Fixes",
6
+ chore: "Chores",
7
+ perf: "Performance Improvements",
8
+ revert: "Reverts",
9
+ docs: "Documentation",
10
+ style: "Styles",
11
+ refactor: "Code Refactoring",
12
+ test: "Tests",
13
+ build: "Build System",
14
+ ci: "Continuous Integration",
15
+ };
16
+
17
+ module.exports = {
18
+ git: {
19
+ commit: true,
20
+ tag: true,
21
+ push: true,
22
+ commitMessage: "release: ${version}",
23
+ tagName: "v${version}",
24
+ },
25
+ github: {
26
+ release: true,
27
+ },
28
+ hooks: {
29
+ "after:bump": "pnpm run compile",
30
+ },
31
+ npm: {
32
+ publish: false,
33
+ },
34
+ plugins: {
35
+ "@release-it/conventional-changelog": {
36
+ preset: "conventionalcommits",
37
+ infile: "CHANGELOG.md",
38
+ writerOpts: {
39
+ transform: (commit, context) => {
40
+ const notes = commit.notes.map((note) => ({ ...note, title: "BREAKING CHANGES" }));
41
+ const type = typeMap[commit.type] || "Other";
42
+ const scope = commit.scope === "*" ? "" : commit.scope;
43
+ const shortHash = typeof commit.hash === "string" ? commit.hash.substring(0, COMMIT_HASH_LENGTH) : commit.shortHash;
44
+ const issues = [];
45
+
46
+ let message = commit.subject || "";
47
+ if (message) {
48
+ if (!/[.!?]$/.test(message)) message += ".";
49
+ message += " ";
50
+ }
51
+ if (commit.body) message += commit.body.trim();
52
+
53
+ let url = context.repository ? `${context.host}/${context.owner}/${context.repository}` : context.repoUrl;
54
+ if (url) {
55
+ url = `${url}/issues/`;
56
+ // Issue URLs
57
+ message = message.replace(/#([0-9]+)/g, (_, issue) => {
58
+ issues.push(issue);
59
+ return `[#${issue}](${url}${issue})`;
60
+ });
61
+ }
62
+
63
+ if (context.host) {
64
+ // User URLs
65
+ message = message.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
66
+ if (username.includes("/")) return `@${username}`;
67
+ return `[@${username}](${context.host}/${username})`;
68
+ });
69
+ }
70
+
71
+ // remove references that already appear in the subject/body
72
+ const references = commit.references.filter((reference) => !issues.includes(reference.issue));
73
+
74
+ return {
75
+ notes,
76
+ type,
77
+ scope,
78
+ shortHash,
79
+ subject: message,
80
+ references,
81
+ };
82
+ },
83
+ },
84
+ },
85
+ },
86
+ };
package/README.md CHANGED
@@ -33,7 +33,7 @@ To install `react-peer-chat`:
33
33
 
34
34
  ## Usage
35
35
 
36
- `react-peer-chat` provides two primary methods to integrate chat functionality into your React apps: through the `<Chat>` component and the `useSpeech` hook.
36
+ `react-peer-chat` provides two primary methods to integrate chat functionality into your React apps: through the `<Chat>` component and the `useChat` hook.
37
37
 
38
38
  It also exports a `clearChat` function that clears the text chat from the browser's session storage when called.
39
39
 
@@ -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
  }
@@ -345,4 +353,4 @@ type Children = (childrenOptions: ChildrenOptions) => ReactNode;
345
353
 
346
354
  ## Author
347
355
 
348
- [Sahil Aggarwal](https://www.github.com/SahilAggarwal2004)
356
+ [Sahil Aggarwal](https://github.com/SahilAggarwal2004)
@@ -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.3",
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>",
@@ -22,12 +22,14 @@
22
22
  "main": "dist/index.js",
23
23
  "types": "dist/index.d.ts",
24
24
  "dependencies": {
25
- "peerjs": "^1.5.4"
25
+ "peerjs": "^1.5.5"
26
26
  },
27
27
  "devDependencies": {
28
- "@types/react": "^19.0.10",
29
- "tsup": "^8.4.0",
30
- "typescript": "^5.8.2"
28
+ "@release-it/conventional-changelog": "^10.0.4",
29
+ "@types/react": "^19.2.7",
30
+ "release-it": "^19.2.2",
31
+ "tsup": "^8.5.1",
32
+ "typescript": "^5.9.3"
31
33
  },
32
34
  "peerDependencies": {
33
35
  "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
@@ -52,6 +54,8 @@
52
54
  "scripts": {
53
55
  "build": "pnpm i && pnpm run compile",
54
56
  "compile": "tsup",
55
- "dev": "tsup --watch"
57
+ "dev": "tsup --watch",
58
+ "dry-release": "release-it --ci --dry-run",
59
+ "release": "release-it --ci"
56
60
  }
57
61
  }
@@ -0,0 +1,2 @@
1
+ onlyBuiltDependencies:
2
+ - esbuild