@snapcall/stream-ui 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/README.md ADDED
@@ -0,0 +1,132 @@
1
+ # SnapCall Stream UI
2
+
3
+ The Stream UI is a library that will help you to quickly integrate [SnapCall](https://www.snapcall.io/) on your application.
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ npm install @snapcall/stream-ui
9
+ ```
10
+
11
+ The NPM package is distributed both as a CommonJS and ES module.
12
+
13
+ We also distrubute a UMD build of the package, which can be used directly in the browser.
14
+
15
+ ```html
16
+ <script src="https://unpkg.com/@snapcall/stream-ui@latest/dist/stream-ui.umd.js"></script>
17
+ ```
18
+
19
+ ## Basic usage
20
+
21
+ ```js
22
+ import { streamUI } from '@snapcall/stream-ui';
23
+
24
+ const container = document.getElementById('container');
25
+ const roomToken = '123';
26
+
27
+ streamUI.init({ element: container });
28
+ streamUI.joinRoom(roomToken);
29
+ ```
30
+
31
+ ## Methods
32
+
33
+ ### `init(options: InitOptions): void`
34
+
35
+ Initializes the UI, this function must be called **before** you join a room.
36
+
37
+ See [InitOptions](#initoptions) for more details.
38
+
39
+ ### `joinRoom(token: string): Promise<void>`
40
+
41
+ Joins a room.
42
+
43
+ ### `leaveRoom(): void`
44
+
45
+ Leaves a room.
46
+
47
+ ### `terminateRoom(): void`
48
+
49
+ Terminates the room, all participants will be disconnected and the room won't be usable anymore.
50
+
51
+ ### `generateToken(buttonId: string): Promise<string>`
52
+
53
+ Generate a room token with a SnapCall button ID.
54
+
55
+ ## API
56
+
57
+ ### `InitOptions`
58
+
59
+ ```ts
60
+ {
61
+ element: HTMLElement;
62
+ sharedURL?: string;
63
+ audioTiles?: boolean;
64
+ settingsShortcuts?: string[];
65
+ controls?: {
66
+ microphone?: ControlSettings;
67
+ camera?: ControlSettings;
68
+ screenshare?: ControlSettings;
69
+ };
70
+ showMenuButton?: boolean;
71
+ }
72
+ ```
73
+
74
+ ### `element`
75
+
76
+ ##### **Required**
77
+
78
+ The HTML element where the UI will be rendered.
79
+
80
+ ### `sharedURL`
81
+
82
+ ##### Default value: `window.location.href`
83
+
84
+ The URL used for features such as "Open new tab" or "QR Code".
85
+
86
+ ### `audioTiles`
87
+
88
+ ##### Default value: `false`
89
+
90
+ Enable audio-only tiles.
91
+
92
+ ### `settingsShortcuts`
93
+
94
+ ##### Default value: `[]`
95
+
96
+ Specified options are added as a small shortcut next to the menu button.
97
+ Possible values are: `openNewTab`, `copyLink`, `qrCode`, `settings` and `pip`.
98
+
99
+ ### `controls`
100
+
101
+ Allows to manage the available and enabled devices
102
+
103
+ ```ts
104
+ type Device = 'microphone' | 'camera' | 'screenshare';
105
+
106
+ {
107
+ controls: {
108
+ <Device>: {
109
+ available: boolean; // Display or hide the corresponding device button
110
+ enabled: boolean; // Enable or disable the default state of the device (when entering a room)
111
+ }
112
+ }
113
+ }
114
+ ```
115
+
116
+ #### `controls.microphone`
117
+
118
+ ##### Default value: `{ available: true, enabled: true }`
119
+
120
+ #### `controls.camera`
121
+
122
+ ##### Default value: `{ available: true, enabled: false }`
123
+
124
+ #### `controls.screenshare`
125
+
126
+ ##### Default value: `{ available: true, enabled: false }`
127
+
128
+ ### `showMenuButton`
129
+
130
+ ##### Default value: `true`
131
+
132
+ Display or hide the top-right menu button