@pipecat-ai/react-native-small-webrtc-transport 1.4.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.
Files changed (47) hide show
  1. package/LICENSE.md +24 -0
  2. package/README.md +114 -0
  3. package/lib/commonjs/index.js +40 -0
  4. package/lib/commonjs/index.js.map +1 -0
  5. package/lib/commonjs/media-manager/mediaManager.js +38 -0
  6. package/lib/commonjs/media-manager/mediaManager.js.map +1 -0
  7. package/lib/commonjs/package.json +1 -0
  8. package/lib/commonjs/transport.js +838 -0
  9. package/lib/commonjs/transport.js.map +1 -0
  10. package/lib/commonjs/view/PipecatClientVideoView.js +44 -0
  11. package/lib/commonjs/view/PipecatClientVideoView.js.map +1 -0
  12. package/lib/module/index.js +7 -0
  13. package/lib/module/index.js.map +1 -0
  14. package/lib/module/media-manager/mediaManager.js +33 -0
  15. package/lib/module/media-manager/mediaManager.js.map +1 -0
  16. package/lib/module/package.json +1 -0
  17. package/lib/module/transport.js +832 -0
  18. package/lib/module/transport.js.map +1 -0
  19. package/lib/module/view/PipecatClientVideoView.js +40 -0
  20. package/lib/module/view/PipecatClientVideoView.js.map +1 -0
  21. package/lib/typescript/commonjs/package.json +1 -0
  22. package/lib/typescript/commonjs/transports/smallwebrtc/src/__tests__/index.test.d.ts +1 -0
  23. package/lib/typescript/commonjs/transports/smallwebrtc/src/__tests__/index.test.d.ts.map +1 -0
  24. package/lib/typescript/commonjs/transports/smallwebrtc/src/index.d.ts +5 -0
  25. package/lib/typescript/commonjs/transports/smallwebrtc/src/index.d.ts.map +1 -0
  26. package/lib/typescript/commonjs/transports/smallwebrtc/src/media-manager/mediaManager.d.ts +42 -0
  27. package/lib/typescript/commonjs/transports/smallwebrtc/src/media-manager/mediaManager.d.ts.map +1 -0
  28. package/lib/typescript/commonjs/transports/smallwebrtc/src/transport.d.ts +130 -0
  29. package/lib/typescript/commonjs/transports/smallwebrtc/src/transport.d.ts.map +1 -0
  30. package/lib/typescript/commonjs/transports/smallwebrtc/src/view/PipecatClientVideoView.d.ts +13 -0
  31. package/lib/typescript/commonjs/transports/smallwebrtc/src/view/PipecatClientVideoView.d.ts.map +1 -0
  32. package/lib/typescript/commonjs/types/react-native-webrtc/extraTypes.d.ts +20 -0
  33. package/lib/typescript/commonjs/types/react-native-webrtc/extraTypes.d.ts.map +1 -0
  34. package/lib/typescript/module/package.json +1 -0
  35. package/lib/typescript/module/transports/smallwebrtc/src/__tests__/index.test.d.ts +1 -0
  36. package/lib/typescript/module/transports/smallwebrtc/src/__tests__/index.test.d.ts.map +1 -0
  37. package/lib/typescript/module/transports/smallwebrtc/src/index.d.ts +5 -0
  38. package/lib/typescript/module/transports/smallwebrtc/src/index.d.ts.map +1 -0
  39. package/lib/typescript/module/transports/smallwebrtc/src/media-manager/mediaManager.d.ts +42 -0
  40. package/lib/typescript/module/transports/smallwebrtc/src/media-manager/mediaManager.d.ts.map +1 -0
  41. package/lib/typescript/module/transports/smallwebrtc/src/transport.d.ts +130 -0
  42. package/lib/typescript/module/transports/smallwebrtc/src/transport.d.ts.map +1 -0
  43. package/lib/typescript/module/transports/smallwebrtc/src/view/PipecatClientVideoView.d.ts +13 -0
  44. package/lib/typescript/module/transports/smallwebrtc/src/view/PipecatClientVideoView.d.ts.map +1 -0
  45. package/lib/typescript/module/types/react-native-webrtc/extraTypes.d.ts +20 -0
  46. package/lib/typescript/module/types/react-native-webrtc/extraTypes.d.ts.map +1 -0
  47. package/package.json +90 -0
package/LICENSE.md ADDED
@@ -0,0 +1,24 @@
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2024, Daily
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,114 @@
1
+ <h1><div align="center">
2
+ <img alt="pipecat client react native" width="500px" height="auto" src="https://github.com/pipecat-ai/pipecat-client-react-native-transports/blob/main/pipecat-react-native.png">
3
+ </div></h1>
4
+
5
+ [![Docs](https://img.shields.io/badge/documentation-blue)](https://docs.pipecat.ai/client/introduction)
6
+ ![NPM Version](https://img.shields.io/npm/v/@pipecat-ai/react-native-daily-transport)
7
+
8
+ The Pipecat client React Native Transport library exports a `RNSmallWebRTCTransport` that has the [SmallWebRTCTransport](https://docs.pipecat.ai/client/js/transports/small-webrtc) transport associated.
9
+
10
+ ## Minimum OS/SDK versions
11
+
12
+ This package introduces some constraints on what OS/SDK versions your project can support:
13
+
14
+ - **iOS**: Deployment target >= 15
15
+ - **Android**: `minSdkVersion` >= 24
16
+
17
+ ## Installation
18
+
19
+ Install `@pipecat-ai/react-native-small-webrtc-transport`.
20
+
21
+ ```bash
22
+ npm i @pipecat-ai/react-native-small-webrtc-transport
23
+ ```
24
+
25
+ If you are using the [DailyMediaManager](../../libs/daily-media-manager/README.md), you will also need to install it along with its peer dependencies:
26
+
27
+ ```bash
28
+ npm i @pipecat-ai/react-native-daily-media-manager
29
+ npm i @daily-co/react-native-daily-js@^0.82.0
30
+ npm i @daily-co/react-native-webrtc@^124.0.6-daily.1
31
+ npm i @react-native-async-storage/async-storage@^1.24.0
32
+ npm i react-native-background-timer@^2.4.1
33
+ npm i react-native-get-random-values@^1.11.0
34
+ ```
35
+
36
+ If you are using Expo, you will also need to add the following dependencies:
37
+
38
+ ```bash
39
+ npm i @daily-co/config-plugin-rn-daily-js@0.0.10
40
+ ```
41
+
42
+ All the details about Expo can be found [here](https://github.com/daily-co/rn-daily-js-expo-config-plugin).
43
+
44
+ A full demo can be found [here](https://github.com/pipecat-ai/pipecat-examples/tree/main/p2p-webrtc/video-transform/client/react-native)
45
+
46
+ ## Quick Start
47
+
48
+ Instantiate an `RTVIClient` instance, wire up the bot's audio, and start the conversation:
49
+
50
+ ```typescript
51
+ const options: SmallWebRTCTransportConstructorOptions = {
52
+ mediaManager: new DailyMediaManager(),
53
+ };
54
+ let pipecatClient = new PipecatClient({
55
+ transport: new RNSmallWebRTCTransport(options),
56
+ enableMic: true,
57
+ enableCam: false,
58
+ callbacks: {
59
+ onConnected: () => {
60
+ setInCall(true);
61
+ },
62
+ onDisconnected: () => {
63
+ setInCall(false);
64
+ },
65
+ onTransportStateChanged: (state) => {
66
+ console.log(`Transport state changed: ${state}`);
67
+ setCurrentState(state);
68
+ },
69
+ onError: (error) => {
70
+ console.log('Error:', JSON.stringify(error));
71
+ },
72
+ },
73
+ });
74
+
75
+ await client?.startBotAndConnect({
76
+ endpoint: baseUrl + '/start',
77
+ });
78
+ ```
79
+
80
+ > Note: To enable screen sharing on iOS, follow the instructions in the [Daily Framework RN Screen Share extension](https://github.com/daily-co/rn-screen-share-extension/).
81
+
82
+ ## Documentation
83
+
84
+ Pipecat Client React Native implements a client instance that:
85
+
86
+ - Facilitates requests to an endpoint you create.
87
+ - Dispatches single-turn actions to a HTTP bot service when disconnected.
88
+ - Provides methods that handle the connectivity state and realtime interaction with your bot service.
89
+ - Manages media transport (such as audio and video).
90
+ - Provides callbacks and events for handling bot messages and actions.
91
+ - Optionally configures your AI services and pipeline.
92
+
93
+ Docs and API reference can be found at https://docs.pipecat.ai/client/introduction.
94
+
95
+ ## Contributing
96
+
97
+ We welcome contributions from the community! Whether you're fixing bugs, improving documentation, or adding new features, here's how you can help:
98
+
99
+ - **Found a bug?** Open an [issue](https://github.com/pipecat-ai/pipecat-client-react-native-transports/issues)
100
+ - **Have a feature idea?** Start a [discussion](https://discord.gg/pipecat)
101
+ - **Want to contribute code?** Check our [CONTRIBUTING.md](CONTRIBUTING.md) guide
102
+ - **Documentation improvements?** [Docs](https://github.com/pipecat-ai/docs) PRs are always welcome
103
+
104
+ Before submitting a pull request, please check existing issues and PRs to avoid duplicates.
105
+
106
+ We aim to review all contributions promptly and provide constructive feedback to help get your changes merged.
107
+
108
+ ## Getting help
109
+
110
+ ➡️ [Join our Discord](https://discord.gg/pipecat)
111
+
112
+ ➡️ [Read the docs](https://docs.pipecat.ai)
113
+
114
+ ➡️ [Reach us on X](https://x.com/pipecat_ai)
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "MediaManager", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _mediaManager.MediaManager;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "PipecatClientVideoView", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _PipecatClientVideoView.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "RNSmallWebRTCTransport", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _transport.RNSmallWebRTCTransport;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "SmallWebRTCTransportConstructorOptions", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _transport.SmallWebRTCTransportConstructorOptions;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "TrackEvent", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _mediaManager.TrackEvent;
34
+ }
35
+ });
36
+ var _transport = require("./transport.js");
37
+ var _mediaManager = require("./media-manager/mediaManager.js");
38
+ var _PipecatClientVideoView = _interopRequireDefault(require("./view/PipecatClientVideoView.js"));
39
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_transport","require","_mediaManager","_PipecatClientVideoView","_interopRequireDefault","e","__esModule","default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAIA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,uBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAmE,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MediaManager = void 0;
7
+ class MediaManager {
8
+ _callbacks = {};
9
+ constructor() {
10
+ this._micEnabled = true;
11
+ this._camEnabled = false;
12
+ this._supportsScreenShare = false;
13
+ }
14
+ setClientOptions(options, override = false) {
15
+ if (this._options && !override) return;
16
+ this._options = options;
17
+ this._callbacks = options.callbacks ?? {};
18
+ this._micEnabled = options.enableMic ?? true;
19
+ this._camEnabled = options.enableCam ?? false;
20
+ }
21
+ get supportsScreenShare() {
22
+ return this._supportsScreenShare;
23
+ }
24
+ get onTrackStarted() {
25
+ return this._onTrackStartedCallback;
26
+ }
27
+ set onTrackStarted(callback) {
28
+ this._onTrackStartedCallback = callback;
29
+ }
30
+ get onTrackStopped() {
31
+ return this._onTrackStoppedCallback;
32
+ }
33
+ set onTrackStopped(callback) {
34
+ this._onTrackStoppedCallback = callback;
35
+ }
36
+ }
37
+ exports.MediaManager = MediaManager;
38
+ //# sourceMappingURL=mediaManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MediaManager","_callbacks","constructor","_micEnabled","_camEnabled","_supportsScreenShare","setClientOptions","options","override","_options","callbacks","enableMic","enableCam","supportsScreenShare","onTrackStarted","_onTrackStartedCallback","callback","onTrackStopped","_onTrackStoppedCallback","exports"],"sourceRoot":"../../../src","sources":["media-manager/mediaManager.ts"],"mappings":";;;;;;AAeO,MAAeA,YAAY,CAAC;EAEvBC,UAAU,GAAuB,CAAC,CAAC;EAU7CC,WAAWA,CAAA,EAAG;IACZ,IAAI,CAACC,WAAW,GAAG,IAAI;IACvB,IAAI,CAACC,WAAW,GAAG,KAAK;IACxB,IAAI,CAACC,oBAAoB,GAAG,KAAK;EACnC;EAEAC,gBAAgBA,CAACC,OAA6B,EAAEC,QAAiB,GAAG,KAAK,EAAE;IACzE,IAAI,IAAI,CAACC,QAAQ,IAAI,CAACD,QAAQ,EAAE;IAChC,IAAI,CAACC,QAAQ,GAAGF,OAAO;IACvB,IAAI,CAACN,UAAU,GAAGM,OAAO,CAACG,SAAS,IAAI,CAAC,CAAC;IACzC,IAAI,CAACP,WAAW,GAAGI,OAAO,CAACI,SAAS,IAAI,IAAI;IAC5C,IAAI,CAACP,WAAW,GAAGG,OAAO,CAACK,SAAS,IAAI,KAAK;EAC/C;EA4BA,IAAIC,mBAAmBA,CAAA,EAAY;IACjC,OAAO,IAAI,CAACR,oBAAoB;EAClC;EAEA,IAAIS,cAAcA,CAAA,EAA8C;IAC9D,OAAO,IAAI,CAACC,uBAAuB;EACrC;EAEA,IAAID,cAAcA,CAACE,QAAmD,EAAE;IACtE,IAAI,CAACD,uBAAuB,GAAGC,QAAQ;EACzC;EAEA,IAAIC,cAAcA,CAAA,EAA8C;IAC9D,OAAO,IAAI,CAACC,uBAAuB;EACrC;EAEA,IAAID,cAAcA,CAACD,QAAmD,EAAE;IACtE,IAAI,CAACE,uBAAuB,GAAGF,QAAQ;EACzC;AACF;AAACG,OAAA,CAAAnB,YAAA,GAAAA,YAAA","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}