-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.js
176 lines (172 loc) · 7.08 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import * as ui from './dist/videosdk-ui-toolkit.js'
let /** @type {HTMLElement} */ uitoolkitProvider
let /** @type {HTMLElement} */ uitoolKit
let /** @type {HTMLElement} */ previewKit
let /** @type {HTMLElement} */ videoLayoutComponent
let /** @type {HTMLElement} */ usersComponent
let /** @type {HTMLElement} */ controlsComponent
let /** @type {HTMLElement} */ settingsComponent
let /** @type {HTMLElement} */ chatComponent
export default {
openPreview: (/** @type {HTMLElement} */ container) => {
previewKit = document.createElement('app-previewkit')
container.append(previewKit)
},
closePreview: (/** @type {HTMLElement} */ container) => {
if(previewKit) {
container.removeChild(previewKit)
} else {
console.log('Cannot close preview since preview is not opened.')
}
},
joinSession: (/** @type {HTMLElement} */ container, /** @type {Object} */ config) => {
if (!uitoolKit) {
uitoolKit = document.createElement('app-uitoolkit')
uitoolKit.setAttribute("config", JSON.stringify(config))
container.append(uitoolKit)
} else {
console.log('Cannot join session since it is already joined.');
}
},
closeSession: (/** @type {HTMLElement} */ container) => {
if(uitoolKit) {
container.removeChild(uitoolKit);
uitoolKit = undefined;
} else {
console.log('Cannot close session since session is not joined.')
}
},
onSessionJoined: (/** @type {EventListenerOrEventListenerObject} */ callback) => {
if(uitoolKit) {
uitoolKit.addEventListener('sessionJoined', callback)
} else if (uitoolkitProvider) {
uitoolkitProvider.addEventListener('sessionJoined', callback)
} else {
console.log('Cannot use event listeners before joinSession is called.')
}
},
offSessionJoined: (/** @type {EventListenerOrEventListenerObject} */ callback) => {
if(uitoolKit) {
uitoolKit.removeEventListener('sessionJoined', callback)
} else if (uitoolkitProvider) {
uitoolkitProvider.removeEventListener('sessionJoined', callback)
} else {
console.log('Cannot use event listeners before joinSession is called.')
}
},
onSessionClosed: (/** @type {EventListenerOrEventListenerObject} */ callback) => {
if(uitoolKit) {
uitoolKit.addEventListener('sessionClosed', callback)
} else if (uitoolkitProvider) {
uitoolkitProvider.addEventListener('sessionClosed', callback)
} else {
console.log('Cannot use event listeners before joinSession is called.')
}
},
offSessionClosed: (/** @type {EventListenerOrEventListenerObject} */ callback) => {
if(uitoolKit) {
uitoolKit.removeEventListener('sessionClosed', callback)
} else if (uitoolkitProvider) {
uitoolkitProvider.removeEventListener('sessionClosed', callback)
} else {
console.log('Cannot use event listeners before joinSession is called.')
}
},
showUitoolkitComponents: (/** @type {HTMLElement} */ container, /** @type {Object} */ config) => {
if (!uitoolkitProvider) {
uitoolkitProvider = document.createElement('uitoolkit-components')
uitoolkitProvider.setAttribute("config", JSON.stringify(config))
container.append(uitoolkitProvider)
} else {
console.log('Cannot show wrapper since it is already shown.');
}
},
hideUitoolkitComponents: (/** @type {HTMLElement} */ container) => {
if(uitoolkitProvider) {
container.removeChild(uitoolkitProvider);
uitoolkitProvider = undefined;
} else {
console.log('Cannot close the provider since the provider is not open.')
}
},
showVideoComponent: (/** @type {HTMLElement} */ container) => {
if (!videoLayoutComponent) {
videoLayoutComponent = document.createElement('video-component')
container.append(videoLayoutComponent);
} else {
console.log('Cannot show video component since it is already shown.');
}
},
hideVideoComponent: (/** @type {HTMLElement} */ container) => {
if(videoLayoutComponent) {
container.removeChild(videoLayoutComponent);
videoLayoutComponent = undefined;
} else {
console.log('Cannot close the video wrapper since the video wrapper is not open.')
}
},
showChatComponent: (/** @type {HTMLElement} */ container) => {
if (!chatComponent) {
chatComponent = document.createElement('chat-component')
container.append(chatComponent);
} else {
console.log('Cannot show chat component since it is already shown.');
}
},
hideChatComponent: (/** @type {HTMLElement} */ container) => {
if(chatComponent) {
container.removeChild(chatComponent);
chatComponent = undefined;
} else {
console.log('Cannot close the chat component since it is not open.')
}
},
showControlsComponent: (/** @type {HTMLElement} */ container) => {
if (!controlsComponent) {
controlsComponent = document.createElement('controls-component');
container.append(controlsComponent);
} else {
console.log('Cannot show controls component since it is already shown.');
}
},
hideControlsComponent: (/** @type {HTMLElement} */ container) => {
if(controlsComponent) {
container.removeChild(controlsComponent);
controlsComponent = undefined;
} else {
console.log('Cannot close the controls since it is not open.')
}
},
showUsersComponent: (/** @type {HTMLElement} */ container) => {
if (!usersComponent) {
usersComponent = document.createElement('users-component')
container.append(usersComponent);
} else {
console.log('Cannot show users component since it is already shown.');
}
},
hideUsersComponent: (/** @type {HTMLElement} */ container) => {
if(usersComponent) {
container.removeChild(usersComponent);
usersComponent = undefined;
} else {
console.log('Cannot close the users component since it is not open.')
}
},
showSettingsComponent: (/** @type {HTMLElement} */ container) => {
if (!settingsComponent) {
settingsComponent = document.createElement('settings-component')
container.append(settingsComponent);
} else {
console.log('Cannot show settings component since it is already shown.');
}
},
hideSettingsComponent: (/** @type {HTMLElement} */ container) => {
if(settingsComponent) {
container.removeChild(settingsComponent);
settingsComponent = undefined;
} else {
console.log('Cannot close the settings component since it is not open.')
}
},
}