mediasfu-shared 1.0.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/LICENSE +21 -0
- package/README.md +228 -0
- package/dist/index.cjs +7707 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +7285 -0
- package/dist/index.js +7690 -0
- package/dist/index.js.map +1 -0
- package/package.json +78 -0
- package/src/ProducerClient/producerClientEmits/createDeviceClient.ts +68 -0
- package/src/consumers/addVideosGrid.ts +18 -0
- package/src/consumers/autoAdjust.ts +100 -0
- package/src/consumers/calculateRowsAndColumns.ts +51 -0
- package/src/consumers/changeVids.ts +753 -0
- package/src/consumers/checkGrid.ts +100 -0
- package/src/consumers/checkPermission.ts +89 -0
- package/src/consumers/checkScreenShare.ts +114 -0
- package/src/consumers/closeAndResize.ts +401 -0
- package/src/consumers/compareActiveNames.ts +122 -0
- package/src/consumers/compareScreenStates.ts +117 -0
- package/src/consumers/connectIps.ts +175 -0
- package/src/consumers/connectLocalIps.ts +103 -0
- package/src/consumers/connectRecvTransport.ts +158 -0
- package/src/consumers/connectSendTransport.ts +150 -0
- package/src/consumers/connectSendTransportAudio.ts +161 -0
- package/src/consumers/connectSendTransportScreen.ts +169 -0
- package/src/consumers/connectSendTransportVideo.ts +149 -0
- package/src/consumers/consumerResume.ts +25 -0
- package/src/consumers/controlMedia.ts +118 -0
- package/src/consumers/createSendTransport.ts +312 -0
- package/src/consumers/disconnectSendTransportAudio.ts +170 -0
- package/src/consumers/disconnectSendTransportScreen.ts +130 -0
- package/src/consumers/disconnectSendTransportVideo.ts +161 -0
- package/src/consumers/dispStreams.ts +694 -0
- package/src/consumers/generatePageContent.ts +118 -0
- package/src/consumers/getEstimate.ts +124 -0
- package/src/consumers/getPipedProducersAlt.ts +96 -0
- package/src/consumers/getProducersPiped.ts +89 -0
- package/src/consumers/getVideos.ts +107 -0
- package/src/consumers/mixStreams.ts +97 -0
- package/src/consumers/onScreenChanges.ts +106 -0
- package/src/consumers/prepopulateUserMedia.ts +18 -0
- package/src/consumers/processConsumerTransports.ts +157 -0
- package/src/consumers/processConsumerTransportsAudio.ts +121 -0
- package/src/consumers/rePort.ts +123 -0
- package/src/consumers/reUpdateInter.ts +289 -0
- package/src/consumers/readjust.ts +170 -0
- package/src/consumers/receiveAllPipedTransports.ts +77 -0
- package/src/consumers/receiveRoomMessages.ts +55 -0
- package/src/consumers/reorderStreams.ts +246 -0
- package/src/consumers/requestScreenShare.ts +103 -0
- package/src/consumers/resumePauseAudioStreams.ts +174 -0
- package/src/consumers/resumePauseStreams.ts +110 -0
- package/src/consumers/resumeSendTransportAudio.ts +143 -0
- package/src/consumers/signalNewConsumerTransport.ts +179 -0
- package/src/consumers/socketReceiveMethods/joinConsumeRoom.ts +130 -0
- package/src/consumers/socketReceiveMethods/newPipeProducer.ts +138 -0
- package/src/consumers/socketReceiveMethods/producerClosed.ts +102 -0
- package/src/consumers/startShareScreen.ts +124 -0
- package/src/consumers/stopShareScreen.ts +241 -0
- package/src/consumers/streamSuccessAudio.ts +297 -0
- package/src/consumers/streamSuccessAudioSwitch.ts +315 -0
- package/src/consumers/streamSuccessScreen.ts +255 -0
- package/src/consumers/streamSuccessVideo.ts +373 -0
- package/src/consumers/switchUserAudio.ts +140 -0
- package/src/consumers/switchUserVideo.ts +201 -0
- package/src/consumers/switchUserVideoAlt.ts +331 -0
- package/src/consumers/trigger.ts +250 -0
- package/src/consumers/updateMiniCardsGrid.ts +150 -0
- package/src/consumers/updateParticipantAudioDecibels.ts +56 -0
- package/src/index.ts +119 -0
- package/src/methods/background/launchBackground.ts +16 -0
- package/src/methods/breakoutRooms/breakoutRoomUpdated.ts +161 -0
- package/src/methods/breakoutRooms/handleStartBreakout.ts +96 -0
- package/src/methods/breakoutRooms/handleStopBreakout.ts +72 -0
- package/src/methods/breakoutRooms/index.ts +4 -0
- package/src/methods/breakoutRooms/launchBreakoutRooms.ts +31 -0
- package/src/methods/coHost/launchCoHost.ts +28 -0
- package/src/methods/coHostMethods/index.ts +2 -0
- package/src/methods/coHostMethods/modifyCoHostSettings.ts +94 -0
- package/src/methods/displaySettings/index.ts +1 -0
- package/src/methods/displaySettings/launchDisplaySettings.ts +31 -0
- package/src/methods/displaySettings/modifyDisplaySettings.ts +242 -0
- package/src/methods/exit/confirmExit.ts +60 -0
- package/src/methods/exit/index.ts +2 -0
- package/src/methods/exit/launchConfirmExit.ts +29 -0
- package/src/methods/index.ts +5 -0
- package/src/methods/mediaSettings/launchMediaSettings.ts +61 -0
- package/src/methods/menu/launchMenuModal.ts +28 -0
- package/src/methods/message/index.ts +1 -0
- package/src/methods/message/launchMessages.ts +27 -0
- package/src/methods/message/sendMessage.ts +175 -0
- package/src/methods/participants/index.ts +3 -0
- package/src/methods/participants/launchParticipants.ts +25 -0
- package/src/methods/participants/messageParticipants.ts +78 -0
- package/src/methods/participants/muteParticipants.ts +79 -0
- package/src/methods/participants/removeParticipants.ts +97 -0
- package/src/methods/polls/handleCreatePoll.ts +66 -0
- package/src/methods/polls/handleEndPoll.ts +64 -0
- package/src/methods/polls/handleVotePoll.ts +76 -0
- package/src/methods/polls/index.ts +3 -0
- package/src/methods/polls/launchPoll.ts +25 -0
- package/src/methods/prejoin/handleCreateRoom.ts +441 -0
- package/src/methods/prejoin/handleJoinRoom.ts +153 -0
- package/src/methods/prejoin/index.ts +14 -0
- package/src/methods/recording/checkPauseState.ts +57 -0
- package/src/methods/recording/checkResumeState.ts +42 -0
- package/src/methods/recording/confirmRecording.ts +241 -0
- package/src/methods/recording/launchRecording.ts +114 -0
- package/src/methods/recording/recordPauseTimer.ts +52 -0
- package/src/methods/recording/recordResumeTimer.ts +92 -0
- package/src/methods/recording/recordStartTimer.ts +106 -0
- package/src/methods/recording/recordUpdateTimer.ts +49 -0
- package/src/methods/recording/startRecording.ts +268 -0
- package/src/methods/recording/stopRecording.ts +124 -0
- package/src/methods/recording/updateRecording.ts +245 -0
- package/src/methods/requests/index.ts +1 -0
- package/src/methods/requests/launchRequests.ts +25 -0
- package/src/methods/requests/respondToRequests.ts +108 -0
- package/src/methods/settings/index.ts +2 -0
- package/src/methods/settings/launchSettings.ts +25 -0
- package/src/methods/settings/modifySettings.ts +99 -0
- package/src/methods/stream/clickVideo.ts +337 -0
- package/src/methods/stream/index.ts +3 -0
- package/src/methods/stream/switchAudio.ts +73 -0
- package/src/methods/stream/switchVideo.ts +148 -0
- package/src/methods/stream/switchVideoAlt.ts +152 -0
- package/src/methods/utils/checkLimitsAndMakeRequest.ts +103 -0
- package/src/methods/utils/validateAlphanumeric.ts +41 -0
- package/src/methods/waiting/index.ts +1 -0
- package/src/methods/waiting/launchWaiting.ts +26 -0
- package/src/methods/waiting/respondToWaiting.ts +82 -0
- package/src/methods/welcome/handleWelcomeRequest.ts +189 -0
- package/src/methods/welcome/index.ts +5 -0
- package/src/methods/whiteboard/handleStartWhiteboard.ts +65 -0
- package/src/methods/whiteboard/handleStopWhiteboard.ts +48 -0
- package/src/methods/whiteboard/index.ts +4 -0
- package/src/methods/whiteboard/launchConfigureWhiteboard.ts +29 -0
- package/src/producers/producerEmits/joinConRoom.ts +153 -0
- package/src/sockets/SocketManager.ts +232 -0
- package/src/types/shared-base-types.ts +752 -0
- package/src/types/types.ts +84 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 MediaSFU
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://www.mediasfu.com/logo192.png" width="100" alt="MediaSFU Logo">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://twitter.com/media_sfu">
|
|
7
|
+
<img src="https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white" alt="Twitter" />
|
|
8
|
+
</a>
|
|
9
|
+
<a href="https://www.mediasfu.com/forums">
|
|
10
|
+
<img src="https://img.shields.io/badge/Community-Forum-blue?style=for-the-badge&logo=discourse&logoColor=white" alt="Community Forum" />
|
|
11
|
+
</a>
|
|
12
|
+
<a href="https://github.com/MediaSFU">
|
|
13
|
+
<img src="https://img.shields.io/badge/GitHub-181717?style=for-the-badge&logo=github&logoColor=white" alt="Github" />
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://www.mediasfu.com/">
|
|
16
|
+
<img src="https://img.shields.io/badge/Website-4285F4?style=for-the-badge&logo=google-chrome&logoColor=white" alt="Website" />
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://www.youtube.com/channel/UCELghZRPKMgjih5qrmXLtqw">
|
|
19
|
+
<img src="https://img.shields.io/badge/YouTube-FF0000?style=for-the-badge&logo=youtube&logoColor=white" alt="Youtube" />
|
|
20
|
+
</a>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
<p align="center">
|
|
24
|
+
<a href="https://opensource.org/licenses/MIT">
|
|
25
|
+
<img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square" alt="License: MIT" />
|
|
26
|
+
</a>
|
|
27
|
+
<a href="https://mediasfu.com">
|
|
28
|
+
<img src="https://img.shields.io/badge/Built%20with-MediaSFU-blue?style=flat-square" alt="Built with MediaSFU" />
|
|
29
|
+
</a>
|
|
30
|
+
<a href="https://www.typescriptlang.org">
|
|
31
|
+
<img src="https://img.shields.io/badge/TypeScript-007ACC?style=flat-square&logo=typescript&logoColor=white" alt="TypeScript" />
|
|
32
|
+
</a>
|
|
33
|
+
<a href="https://www.npmjs.com/package/mediasfu-shared">
|
|
34
|
+
<img src="https://img.shields.io/npm/v/mediasfu-shared.svg?style=flat-square" alt="npm version" />
|
|
35
|
+
</a>
|
|
36
|
+
<a href="https://www.npmjs.com/package/mediasfu-shared">
|
|
37
|
+
<img src="https://img.shields.io/npm/dm/mediasfu-shared.svg?style=flat-square" alt="npm downloads" />
|
|
38
|
+
</a>
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
<h1 align="center">mediasfu-shared</h1>
|
|
42
|
+
|
|
43
|
+
<p align="center">
|
|
44
|
+
<strong>Core Shared Library for MediaSFU SDKs</strong>
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 📦 About
|
|
50
|
+
|
|
51
|
+
`mediasfu-shared` is the universal shared library that powers all MediaSFU framework-specific SDKs (React, Vue, Angular, etc.). It provides the core WebRTC functionality, media handling, socket communication, and state management that enables real-time video conferencing, screen sharing, recording, and interactive features across all MediaSFU implementations.
|
|
52
|
+
|
|
53
|
+
This package contains framework-agnostic implementations of:
|
|
54
|
+
- **Media Consumers** - WebRTC transport and stream management
|
|
55
|
+
- **Core Methods** - Room creation, participant handling, recording controls
|
|
56
|
+
- **Socket Management** - Real-time communication with MediaSFU servers
|
|
57
|
+
- **Type Definitions** - Comprehensive TypeScript types for all MediaSFU features
|
|
58
|
+
- **Utility Functions** - Helper methods for media processing and state management
|
|
59
|
+
|
|
60
|
+
## 🎯 Key Features
|
|
61
|
+
|
|
62
|
+
- ✅ **Framework Agnostic** - Pure TypeScript/JavaScript implementation
|
|
63
|
+
- ✅ **WebRTC Integration** - Full mediasoup-client support for advanced WebRTC features
|
|
64
|
+
- ✅ **Type-Safe** - Complete TypeScript definitions for all APIs
|
|
65
|
+
- ✅ **Real-Time Communication** - Socket.io integration for instant updates
|
|
66
|
+
- ✅ **Modular Architecture** - Import only what you need for optimal bundle size
|
|
67
|
+
- ✅ **Production Ready** - Battle-tested in MediaSFU's production environment
|
|
68
|
+
|
|
69
|
+
## 📥 Installation
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm install mediasfu-shared
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Peer Dependencies
|
|
76
|
+
|
|
77
|
+
This package requires the following peer dependencies:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npm install socket.io-client mediasoup-client
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## 🚀 Usage
|
|
84
|
+
|
|
85
|
+
### Importing Core Functions
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import {
|
|
89
|
+
connectSocket,
|
|
90
|
+
joinRoomClient,
|
|
91
|
+
updateRoomParametersClient,
|
|
92
|
+
createDeviceClient,
|
|
93
|
+
SocketManager
|
|
94
|
+
} from 'mediasfu-shared';
|
|
95
|
+
|
|
96
|
+
// Initialize socket connection
|
|
97
|
+
const socket = await connectSocket({
|
|
98
|
+
apiUserName: 'your-api-username',
|
|
99
|
+
apiKey: 'your-api-key',
|
|
100
|
+
apiToken: 'your-api-token',
|
|
101
|
+
link: 'https://mediasfu.com/socket'
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Create SocketManager instance
|
|
105
|
+
const socketManager = new SocketManager({ socket });
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Using Consumers
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import {
|
|
112
|
+
consumerResume,
|
|
113
|
+
addVideosGrid,
|
|
114
|
+
prepopulateUserMedia
|
|
115
|
+
} from 'mediasfu-shared';
|
|
116
|
+
|
|
117
|
+
// Resume a paused consumer
|
|
118
|
+
await consumerResume({
|
|
119
|
+
id: 'consumer-id',
|
|
120
|
+
parameters: roomParameters,
|
|
121
|
+
socket: socketManager.socket
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Add video streams to grid
|
|
125
|
+
await addVideosGrid({
|
|
126
|
+
consumers: activeConsumers,
|
|
127
|
+
parameters: roomParameters
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Type Definitions
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
import type {
|
|
135
|
+
Participant,
|
|
136
|
+
Transport,
|
|
137
|
+
Stream,
|
|
138
|
+
EventType,
|
|
139
|
+
ShowAlert,
|
|
140
|
+
CoHostResponsibility,
|
|
141
|
+
Settings
|
|
142
|
+
} from 'mediasfu-shared';
|
|
143
|
+
|
|
144
|
+
const participant: Participant = {
|
|
145
|
+
id: 'participant-123',
|
|
146
|
+
name: 'John Doe',
|
|
147
|
+
audioID: 'audio-stream-id',
|
|
148
|
+
videoID: 'video-stream-id',
|
|
149
|
+
islevel: '1'
|
|
150
|
+
};
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## 🏗️ Package Structure
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
mediasfu-shared/
|
|
157
|
+
├── consumers/ # WebRTC consumer management
|
|
158
|
+
│ ├── addVideosGrid
|
|
159
|
+
│ ├── consumerResume
|
|
160
|
+
│ └── prepopulateUserMedia
|
|
161
|
+
├── methods/ # Core functionality methods
|
|
162
|
+
│ ├── breakoutRoomsMethods/
|
|
163
|
+
│ ├── recordingMethods/
|
|
164
|
+
│ ├── participantsMethods/
|
|
165
|
+
│ ├── messageMethods/
|
|
166
|
+
│ ├── mediaMethods/
|
|
167
|
+
│ └── utils/
|
|
168
|
+
├── producers/ # Producer client implementations
|
|
169
|
+
├── sockets/ # Socket.io management
|
|
170
|
+
├── types/ # TypeScript type definitions
|
|
171
|
+
└── index.ts # Main entry point
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## 📚 Documentation
|
|
175
|
+
|
|
176
|
+
For detailed documentation on specific methods and types, please visit:
|
|
177
|
+
|
|
178
|
+
- **Main Documentation**: [https://mediasfu.com/documentation](https://mediasfu.com/documentation)
|
|
179
|
+
- **API Reference**: [https://mediasfu.com/developers/reference](https://mediasfu.com/developers/reference)
|
|
180
|
+
- **React SDK**: [@mediasfu/reactjs](https://www.npmjs.com/package/@mediasfu/reactjs)
|
|
181
|
+
- **Vue SDK**: [@mediasfu/vue](https://www.npmjs.com/package/@mediasfu/vue)
|
|
182
|
+
|
|
183
|
+
## 🔗 Related Packages
|
|
184
|
+
|
|
185
|
+
`mediasfu-shared` is used by all MediaSFU framework-specific packages:
|
|
186
|
+
|
|
187
|
+
- **[@mediasfu/reactjs](https://www.npmjs.com/package/@mediasfu/reactjs)** - React components and hooks
|
|
188
|
+
- **[@mediasfu/vue](https://www.npmjs.com/package/@mediasfu/vue)** - Vue 3 components and composables
|
|
189
|
+
- **[@mediasfu/angular](https://www.npmjs.com/package/@mediasfu/angular)** - Angular components and services (coming soon)
|
|
190
|
+
|
|
191
|
+
## 🤝 Integration with MediaSFU Community Edition (CE)
|
|
192
|
+
|
|
193
|
+
This package is designed to work seamlessly with [MediaSFU CE](https://github.com/MediaSFU/MediaSFUOpen), our open-source community edition server. MediaSFU CE provides:
|
|
194
|
+
|
|
195
|
+
- Complete WebRTC SFU server implementation
|
|
196
|
+
- Recording and streaming capabilities
|
|
197
|
+
- Breakout rooms and advanced features
|
|
198
|
+
- Free for self-hosting
|
|
199
|
+
|
|
200
|
+
## 💬 Support
|
|
201
|
+
|
|
202
|
+
Need help? We're here for you!
|
|
203
|
+
|
|
204
|
+
- **Community Discord**: [Join our Discord](https://discord.gg/mediasfu)
|
|
205
|
+
- **GitHub Issues**: [Report bugs or request features](https://github.com/MediaSFU/MediaSFU/issues)
|
|
206
|
+
- **Email Support**: support@mediasfu.com
|
|
207
|
+
- **Enterprise Support**: enterprise@mediasfu.com
|
|
208
|
+
|
|
209
|
+
## 📄 License
|
|
210
|
+
|
|
211
|
+
This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.
|
|
212
|
+
|
|
213
|
+
## 🌟 Contributing
|
|
214
|
+
|
|
215
|
+
We welcome contributions! Please see our [Contributing Guidelines](https://github.com/MediaSFU/MediaSFU/blob/main/CONTRIBUTING.md) for details.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
<p align="center">
|
|
220
|
+
Made with ❤️ by the <a href="https://mediasfu.com">MediaSFU</a> Team
|
|
221
|
+
</p>
|
|
222
|
+
|
|
223
|
+
<p align="center">
|
|
224
|
+
<a href="https://mediasfu.com">Website</a> •
|
|
225
|
+
<a href="https://twitter.com/mediasfu">Twitter</a> •
|
|
226
|
+
<a href="https://github.com/MediaSFU">GitHub</a> •
|
|
227
|
+
<a href="https://www.linkedin.com/company/mediasfu">LinkedIn</a>
|
|
228
|
+
</p>
|