@zoom/videosdk-ui-toolkit 1.8.18 → 1.9.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 CHANGED
@@ -16,14 +16,19 @@ In your frontend project, install the Video SDK UI toolkit:
16
16
  $ npm install @zoom/videosdk-ui-toolkit --save
17
17
  ```
18
18
 
19
- ## Setup
19
+ Or, for Vanilla JS applications, download the package and add it to your project. Then, add the following script and CSS style to the HTML page you want the UI toolkit to live on:
20
+
21
+ ```html
22
+ <link rel="stylesheet" href="@zoom/videosdk-ui-toolkit/dist/videosdk-ui-toolkit.css">
23
+ <script src="@zoom/videosdk-ui-toolkit/index.js" type="module"></script>
24
+ ```
20
25
 
21
- In the component file where you want to use the Video SDK UI, import the JavaScript package and the CSS styles.
26
+ ## Setup
22
27
 
23
- For webpack / single page applications like Angular, Vue, React, etc, use the import syntax:
28
+ For webpack / single page applications like Angular, Vue, React, etc, import the UI toolkit, package and styles:
24
29
 
25
30
  ```js
26
- import * as UIToolkit from '@zoom/videosdk-ui-toolkit'
31
+ import uitoolkit from '@zoom/videosdk-ui-toolkit'
27
32
  import '@zoom/videosdk-ui-toolkit/dist/videosdk-ui-toolkit.css'
28
33
  ```
29
34
 
@@ -35,89 +40,118 @@ In Angular, CSS can't be imported directly into the component, instead, add the
35
40
  ]
36
41
  ```
37
42
 
38
- For Vanilla JS applications, use the link and script tag syntax in your html file:
43
+ Or, for Vanilla JS applications, import the JS file directly:
39
44
 
40
- ```html
41
- <link rel="stylesheet" href="videosdk-ui-toolkit.css">
42
- <script src="videosdk-ui-toolkit.js"></script>
45
+ ```js
46
+ import uitoolkit from './@zoom/videosdk-ui-toolkit/index.js'
43
47
  ```
44
48
 
49
+ > [JS imports](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#applying_the_module_to_your_html) work if your script tag has the `type="module"` attribute.
50
+
51
+ > UI toolkit CDN is coming soon to make vanilla JS usage easier.
52
+
45
53
  ## Usage
46
54
 
47
- ### Preview
55
+ ### Open Preview
48
56
 
49
- To preview your local camera, microphone, and speaker, render the following HTML element:
57
+ To open the preview kit, to preview your camera, microphone, and speaker, create an HTML container that it will be render in:
50
58
 
51
59
  ```html
52
- <app-previewkit></app-previewkit>
60
+ <div id='previewContainer'></div>
53
61
  ```
54
62
 
55
- ### Join Session
63
+ Then, call the `uitoolkit.openPreview` function, passing in the container reference:
56
64
 
57
- To join a Video SDK session, add the following HTML element to where you want the UI Toolkit to be rendered:
65
+ ```js
66
+ var previewContainer = document.getElementById('previewContainer')
58
67
 
59
- ```html
60
- <div id='UIToolkit'></div>
68
+ uitoolkit.openPreview(previewContainer)
61
69
  ```
62
70
 
63
- Then, create your UIToolkit instance and render it to your DOM:
71
+ ### Close Preview
72
+
73
+ To close the preview kit, call the `uitoolkit.closePreview` function:
64
74
 
65
75
  ```js
66
- let UIToolKit = document.createElement('app-uitoolkit');
76
+ uitoolkit.closePreview(previewContainer)
77
+ ```
67
78
 
68
- document.getElementById('UIToolkit')?.append(UIToolKit);
79
+ ### Join Session
80
+
81
+ To join a Video SDK session, create an HTML container that it will be render in:
82
+
83
+ ```html
84
+ <div id='sessionContainer'></div>
69
85
  ```
70
86
 
71
- Next, create your Video SDK config object, with your [Video SDK session info](https://developers.zoom.us/docs/video-sdk/web/sessions/#prerequisites), [Video SDK JWT](https://developers.zoom.us/docs/video-sdk/auth/), and features you want to render. Pass this object into the `window.ZoomUIToolKit.init()` function and call the `window.ZoomUIToolKit.join()` function to start or join a Video SDK Session:
87
+ Create your Video SDK session config object, with your [Video SDK JWT](https://developers.zoom.us/docs/video-sdk/auth/), and [Video SDK session info](https://developers.zoom.us/docs/video-sdk/web/sessions/#prerequisites) features you want to render.
72
88
 
73
89
  ```js
74
- let UIToolKitConfig = {
90
+ var config = {
75
91
  videoSDKJWT: '',
76
- sessionName: '',
77
- userName: '',
78
- sessionPasscode: '',
92
+ sessionName: 'SessionA',
93
+ userName: 'UserA',
94
+ sessionPasscode: 'abc123',
79
95
  features: ['video', 'audio', 'settings', 'users', 'chat']
80
- };
96
+ }
97
+ ```
81
98
 
82
- window.ZoomUIToolKit.init(UIToolKitConfig);
99
+ Then, call the `uitoolkit.joinSession` function, passing in the container reference, and the Video SDK session config object:
83
100
 
84
- window.ZoomUIToolKit.join();
101
+ ```js
102
+ var sessionContainer = document.getElementById('sessionContainer')
103
+
104
+ uitoolkit.joinSession(sessionContainer, config)
85
105
  ```
86
106
 
87
- ### Leave/End Session
107
+ ### Leave Session
88
108
 
89
109
  To leave a Video SDK session, the user can click the red leave button. The host can also end the session for everyone, by clicking their red end button.
90
110
 
91
- You can also leave/end a session programatically by calling the `window.ZoomUIToolKit.destroy()` function, the session will be left or ended based on the user's role in their [Video SDK JWT](https://developers.zoom.us/docs/video-sdk/auth/):
111
+ You can also leave a session programatically by calling the `uitoolkit.closeSession` function:
92
112
 
93
113
  ```js
94
- window.ZoomUIToolKit.destroy(); //Leaves the meeting
95
- //or
96
- window.ZoomUIToolKit.destroy(true); //If you're a host you can end the meeting by passing in 'true'
114
+ uitoolkit.closeSession(sessionContainer)
97
115
  ```
98
116
 
99
- Use the `uikit-destroy` event listener to be notified when the session is left or ended by a user:
117
+ ### Event Listeners
118
+
119
+ To subscribe to event listeners, define a callback function that you want to execute when the respective event is triggered:
100
120
 
101
121
  ```js
102
- window.ZoomUIToolKit.subscribe("uikit-destroy", () => {
103
- // session left/ended, post session business logic...
104
- });
122
+ var sessionJoined = (() => {
123
+ console.log('session joined')
124
+ })
125
+
126
+ var sessionClosed = (() => {
127
+ console.log('session closed')
128
+ })
105
129
  ```
106
130
 
107
- You can also subscribe directly to the [Zoom Video SDK Events](https://marketplacefront.zoom.us/sdk/custom/web/modules/VideoClient.html#on) using the `window.ZoomUIToolKit.vsdkSubscribe()` method. Pass in the name of the Video SDK event and a callback function as shown:
108
- ```js
109
- window.ZoomUIToolKit.vsdkSubscribe("user-added", () => {
110
- console.log("USER ADDED!")
111
- });
131
+ Then, pass the callback function to the respective **on** event listener (after calling the `uitoolkit.joinSession` function).
132
+
133
+ ```js
134
+ uitoolkit.onSessionJoined(sessionJoined)
135
+
136
+ uitoolkit.onSessionClosed(sessionClosed)
112
137
  ```
113
138
 
114
- Subscribe to the `loader-switch` event to better sync your loaders to the join flow of the UIToolKit! You only need to pass in a callback function that controls the state of your loader. The UIToolKit will fire the event and execute your loader callback logic once the meeting has been joined:
139
+ To unsubscribe to event listeners, pass the callback function to the respective **off** event listener.
140
+
115
141
  ```js
116
- window.ZoomUIToolKit.subscribe("loader-switch", () => {
117
- setLoader(loader => !loader)
118
- });
142
+ uitoolkit.offSessionJoined(sessionJoined)
143
+
144
+ uitoolkit.offSessionClosed(sessionClosed)
119
145
  ```
120
146
 
147
+ Currently, we support the following event listeners:
148
+
149
+ | Event Listener | Description |
150
+ | ------------------ | -------------------------------------------------- |
151
+ | `onSessionJoined` | Fires when the user joins the session succesfully. |
152
+ | `onSessionClosed` | Fires when the session is left or ended. |
153
+ | `offSessionJoined` | Unsubscribes to the `onSessionJoined` event. |
154
+ | `offSessionClosed` | Unsubscribes to the `onSessionClosed` event. |
121
155
 
122
156
  ## Sample Apps
123
157