@snapcall/stream-ui 1.25.0 → 1.26.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/dist/stream-ui.esm.js +105 -19
- package/dist/stream-ui.js +105 -19
- package/dist/types.d.ts +695 -0
- package/package.json +3 -3
package/dist/stream-ui.esm.js
CHANGED
|
@@ -1135,6 +1135,48 @@ const $120418cdeb6706cf$export$de363e709c412c8a = (fn, wait = 300)=>{
|
|
|
1135
1135
|
};
|
|
1136
1136
|
|
|
1137
1137
|
|
|
1138
|
+
const $8042747316a8a88d$export$deda6dde1c58aa97 = async (apiUrl, { file: file, token: token, stepToken: stepToken, sessionId: sessionId, userId: userId, peerId: peerId })=>{
|
|
1139
|
+
if (!file) throw new Error(`Missing file on "${file}"`);
|
|
1140
|
+
const upload = await fetch(`${apiUrl}/public/streams/${token}/events/upload`, {
|
|
1141
|
+
method: "POST",
|
|
1142
|
+
headers: {
|
|
1143
|
+
"Content-Type": "application/json"
|
|
1144
|
+
},
|
|
1145
|
+
body: JSON.stringify({
|
|
1146
|
+
filename: file.name,
|
|
1147
|
+
contentLength: file.size
|
|
1148
|
+
})
|
|
1149
|
+
});
|
|
1150
|
+
const { url: url, headers: headers, filename: filename } = await upload.json();
|
|
1151
|
+
const uploadResponse = await fetch(url, {
|
|
1152
|
+
method: "PUT",
|
|
1153
|
+
headers: {
|
|
1154
|
+
...headers,
|
|
1155
|
+
"Content-Type": file.type,
|
|
1156
|
+
"Content-Length": String(file.size)
|
|
1157
|
+
},
|
|
1158
|
+
body: file
|
|
1159
|
+
});
|
|
1160
|
+
if (!uploadResponse.ok) throw new Error("Upload failed");
|
|
1161
|
+
const type = file.type.split("/")[0];
|
|
1162
|
+
const eventRequest = await fetch(`${apiUrl}/public/streams/${token}/events`, {
|
|
1163
|
+
method: "POST",
|
|
1164
|
+
headers: {
|
|
1165
|
+
"Content-Type": "application/json"
|
|
1166
|
+
},
|
|
1167
|
+
body: JSON.stringify({
|
|
1168
|
+
filename: filename,
|
|
1169
|
+
type: type,
|
|
1170
|
+
stepToken: stepToken,
|
|
1171
|
+
session_id: sessionId,
|
|
1172
|
+
user_id: userId,
|
|
1173
|
+
peer_id: peerId
|
|
1174
|
+
})
|
|
1175
|
+
});
|
|
1176
|
+
return eventRequest.json();
|
|
1177
|
+
};
|
|
1178
|
+
|
|
1179
|
+
|
|
1138
1180
|
const $c31e3fb4360572af$var$log = new (0, $0f65a9eaf4a1e910$export$2e2bcd8739ae039)("StreamerClient");
|
|
1139
1181
|
const $c31e3fb4360572af$export$103bedf43ba882db = {
|
|
1140
1182
|
WEBRTC_FAILED: "WRTC1",
|
|
@@ -1357,10 +1399,7 @@ class $c31e3fb4360572af$export$2e2bcd8739ae039 extends $c31e3fb4360572af$var$Str
|
|
|
1357
1399
|
}
|
|
1358
1400
|
}
|
|
1359
1401
|
async init(room = this.roomId, options = this.joinOptions) {
|
|
1360
|
-
const initResult = {
|
|
1361
|
-
flow: undefined,
|
|
1362
|
-
flowV0: undefined
|
|
1363
|
-
};
|
|
1402
|
+
const initResult = {};
|
|
1364
1403
|
this.roomId = room;
|
|
1365
1404
|
this.peerId = (0, $3Sbms$v4)();
|
|
1366
1405
|
this.joinOptions = options;
|
|
@@ -1370,7 +1409,7 @@ class $c31e3fb4360572af$export$2e2bcd8739ae039 extends $c31e3fb4360572af$var$Str
|
|
|
1370
1409
|
const urlParams = new URLSearchParams();
|
|
1371
1410
|
if (options.flowToken) urlParams.append("flowToken", options.flowToken);
|
|
1372
1411
|
if (options.languageCode) urlParams.append("languageCode", options.languageCode);
|
|
1373
|
-
const { streamer_instance: instanceId, plan: { permissions: permissions, name: name }, flow: flow, flow_v0: flow_v0, recordings: recordings, company_id: company_id, company: company, defaultPublicPage: defaultPublicPage } = await fetch(`${this.config.apiUrl}/streams/${room}/info?${urlParams}`, {
|
|
1412
|
+
const { streamer_instance: instanceId, plan: { permissions: permissions, name: name }, flow: flow, flow_v0: flow_v0, recordings: recordings, video_upload: video_upload, company_id: company_id, company: company, defaultPublicPage: defaultPublicPage } = await fetch(`${this.config.apiUrl}/streams/${room}/info?${urlParams}`, {
|
|
1374
1413
|
method: "get",
|
|
1375
1414
|
headers: {
|
|
1376
1415
|
"Content-Type": "application/json"
|
|
@@ -1379,6 +1418,7 @@ class $c31e3fb4360572af$export$2e2bcd8739ae039 extends $c31e3fb4360572af$var$Str
|
|
|
1379
1418
|
if (response.ok) return response.json();
|
|
1380
1419
|
throw new Error("Invalid room ID");
|
|
1381
1420
|
});
|
|
1421
|
+
initResult.videoUpload = video_upload;
|
|
1382
1422
|
if (flow_v0) initResult.flowV0 = flow_v0;
|
|
1383
1423
|
if (flow && flow.steps.length > 0) {
|
|
1384
1424
|
options.recorder = true;
|
|
@@ -2478,6 +2518,15 @@ class $c31e3fb4360572af$export$2e2bcd8739ae039 extends $c31e3fb4360572af$var$Str
|
|
|
2478
2518
|
stepToken: this.stepToken
|
|
2479
2519
|
});
|
|
2480
2520
|
}
|
|
2521
|
+
async uploadEvent(file) {
|
|
2522
|
+
return (0, $8042747316a8a88d$export$deda6dde1c58aa97)(this.config.apiUrl, {
|
|
2523
|
+
token: this.roomId,
|
|
2524
|
+
file: file,
|
|
2525
|
+
peerId: this.peerId,
|
|
2526
|
+
userId: this.agentIdentity?.id,
|
|
2527
|
+
stepToken: this.stepToken
|
|
2528
|
+
});
|
|
2529
|
+
}
|
|
2481
2530
|
async deleteCapture(assetId) {
|
|
2482
2531
|
const res = await this.protoo?.request("deleteCapture", {
|
|
2483
2532
|
assetId: assetId
|
|
@@ -11183,6 +11232,7 @@ const $946223bbb2c552ef$export$5a5695b638d078e7 = ()=>{
|
|
|
11183
11232
|
};
|
|
11184
11233
|
|
|
11185
11234
|
|
|
11235
|
+
|
|
11186
11236
|
const $20431dc869bb21e0$var$fileToDataUrl = (file)=>{
|
|
11187
11237
|
return new Promise((resolve, reject)=>{
|
|
11188
11238
|
const reader = new FileReader();
|
|
@@ -11191,7 +11241,26 @@ const $20431dc869bb21e0$var$fileToDataUrl = (file)=>{
|
|
|
11191
11241
|
reader.readAsDataURL(file);
|
|
11192
11242
|
});
|
|
11193
11243
|
};
|
|
11244
|
+
const $20431dc869bb21e0$var$generateVideoThumbnail = (file)=>{
|
|
11245
|
+
return new Promise((resolve)=>{
|
|
11246
|
+
const canvas = document.createElement("canvas");
|
|
11247
|
+
const video = document.createElement("video");
|
|
11248
|
+
video.autoplay = true;
|
|
11249
|
+
video.muted = true;
|
|
11250
|
+
video.currentTime = 3;
|
|
11251
|
+
video.src = URL.createObjectURL(file);
|
|
11252
|
+
video.onloadeddata = ()=>{
|
|
11253
|
+
let ctx = canvas.getContext("2d");
|
|
11254
|
+
canvas.width = video.videoWidth;
|
|
11255
|
+
canvas.height = video.videoHeight;
|
|
11256
|
+
ctx?.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
|
|
11257
|
+
video.pause();
|
|
11258
|
+
return resolve(canvas.toDataURL("image/png"));
|
|
11259
|
+
};
|
|
11260
|
+
});
|
|
11261
|
+
};
|
|
11194
11262
|
const $20431dc869bb21e0$export$b3fd96a52c80b3af = ()=>{
|
|
11263
|
+
const { recorderOptions: recorderOptions, videoUpload: videoUpload } = (0, $3Sbms$useContext)((0, $5f30d8bf4f04621e$export$2e2bcd8739ae039));
|
|
11195
11264
|
const { t: t } = (0, $3Sbms$useTranslation)();
|
|
11196
11265
|
const { openAssetsModal: openAssetsModal, addAsset: addAsset, setIncomingAsset: setIncomingAsset, isRecording: isRecording } = (0, $75812785bb101fee$export$2174f25d572f9f31)();
|
|
11197
11266
|
const reportError = (0, $946223bbb2c552ef$export$5a5695b638d078e7)();
|
|
@@ -11200,24 +11269,40 @@ const $20431dc869bb21e0$export$b3fd96a52c80b3af = ()=>{
|
|
|
11200
11269
|
const onUploadClick = async (event)=>{
|
|
11201
11270
|
const file = event.target.files?.[0];
|
|
11202
11271
|
if (file && !isRecording) {
|
|
11272
|
+
const type = file.type.split("/")[0];
|
|
11203
11273
|
const createdAt = Date.now();
|
|
11274
|
+
const mode = type === "image" ? "photo" : type;
|
|
11204
11275
|
setIncomingAsset({
|
|
11205
|
-
mode:
|
|
11276
|
+
mode: mode,
|
|
11206
11277
|
createdAt: createdAt
|
|
11207
11278
|
});
|
|
11208
11279
|
openAssetsModal();
|
|
11209
11280
|
try {
|
|
11210
|
-
|
|
11211
|
-
|
|
11281
|
+
let url;
|
|
11282
|
+
let thumbnailUrl;
|
|
11283
|
+
let id;
|
|
11284
|
+
if (type === "image") {
|
|
11285
|
+
const dataUrl = await $20431dc869bb21e0$var$fileToDataUrl(file);
|
|
11286
|
+
const data = await (0, $c9e496369b59be7a$export$2f377c2162fd02b2).saveCapture(dataUrl);
|
|
11287
|
+
url = data.url;
|
|
11288
|
+
id = data.assetId;
|
|
11289
|
+
} else {
|
|
11290
|
+
const data = await (0, $c9e496369b59be7a$export$2f377c2162fd02b2).uploadEvent(file);
|
|
11291
|
+
url = data.url;
|
|
11292
|
+
id = data.id;
|
|
11293
|
+
if (type === "video") thumbnailUrl = await $20431dc869bb21e0$var$generateVideoThumbnail(file);
|
|
11294
|
+
if (!url || !id) throw new Error("upload failed");
|
|
11295
|
+
}
|
|
11212
11296
|
addAsset({
|
|
11213
|
-
id:
|
|
11214
|
-
mode:
|
|
11297
|
+
id: id,
|
|
11298
|
+
mode: mode,
|
|
11215
11299
|
url: url,
|
|
11216
|
-
thumbnailUrl: url,
|
|
11300
|
+
thumbnailUrl: thumbnailUrl || url,
|
|
11217
11301
|
createdAt: createdAt
|
|
11218
11302
|
});
|
|
11219
11303
|
openAssetsModal();
|
|
11220
11304
|
} catch (error) {
|
|
11305
|
+
console.log(error);
|
|
11221
11306
|
reportError({
|
|
11222
11307
|
code: "UPLD_1",
|
|
11223
11308
|
error: error
|
|
@@ -11231,13 +11316,13 @@ const $20431dc869bb21e0$export$b3fd96a52c80b3af = ()=>{
|
|
|
11231
11316
|
/*#__PURE__*/ (0, $3Sbms$jsx)("input", {
|
|
11232
11317
|
ref: fileInputRef,
|
|
11233
11318
|
type: "file",
|
|
11234
|
-
accept: "
|
|
11319
|
+
accept: videoUpload ? "image/*,video/*,audio/*" : "image/*",
|
|
11235
11320
|
className: "hidden",
|
|
11236
11321
|
onChange: onUploadClick
|
|
11237
11322
|
}),
|
|
11238
11323
|
/*#__PURE__*/ (0, $3Sbms$jsxs)((0, $3Sbms$Button), {
|
|
11239
11324
|
className: (0, $3Sbms$classnames)("bg-gray-25/50 hover:bg-gray-25/60 active:bg-gray-25/70 rounded-full", {
|
|
11240
|
-
invisible: isRecording
|
|
11325
|
+
invisible: isRecording || !recorderOptions?.enabledModes.includes("photo") && !videoUpload
|
|
11241
11326
|
}),
|
|
11242
11327
|
icon: !isMedium,
|
|
11243
11328
|
onClick: ()=>fileInputRef.current?.click(),
|
|
@@ -14298,6 +14383,7 @@ const $26ed036cbc17809a$var$StreamUI = ({ options: options })=>{
|
|
|
14298
14383
|
const [permissions, setPermissions] = (0, $3Sbms$useState)([]);
|
|
14299
14384
|
const [plan, setPlan] = (0, $3Sbms$useState)(undefined);
|
|
14300
14385
|
const [flows, setFlows] = (0, $3Sbms$useState)({});
|
|
14386
|
+
const [videoUpload, setVideoUpload] = (0, $3Sbms$useState)(false);
|
|
14301
14387
|
const [recorderOptions, setRecorderOptions] = (0, $3Sbms$useState)(options.recorder);
|
|
14302
14388
|
const isFirstRender = (0, $648652ea36cc4fd9$export$5964c316e853650f)();
|
|
14303
14389
|
const orientation = (containerWidth || window.screen.width) > (containerHeight || window.screen.height) ? "landscape" : "portrait";
|
|
@@ -14405,16 +14491,15 @@ const $26ed036cbc17809a$var$StreamUI = ({ options: options })=>{
|
|
|
14405
14491
|
});
|
|
14406
14492
|
};
|
|
14407
14493
|
const onClientInitialized = (0, $3Sbms$useCallback)(async (event)=>{
|
|
14408
|
-
const { flow: flow, flowV0: flowV0 } = event.detail;
|
|
14494
|
+
const { flow: flow, flowV0: flowV0, videoUpload: videoUpload } = event.detail;
|
|
14495
|
+
setVideoUpload(videoUpload || false);
|
|
14409
14496
|
const flowStep = flow?.steps[0];
|
|
14410
14497
|
if (flowStep) {
|
|
14411
|
-
const flowStepMode = flowStep.type === "image" ? "photo" :
|
|
14498
|
+
const flowStepMode = flowStep.types.map((type)=>type === "image" ? "photo" : type);
|
|
14412
14499
|
setRecorderOptions({
|
|
14413
|
-
enabledModes:
|
|
14414
|
-
flowStepMode
|
|
14415
|
-
],
|
|
14500
|
+
enabledModes: flowStepMode,
|
|
14416
14501
|
enabled: true,
|
|
14417
|
-
defaultMode: flowStepMode,
|
|
14502
|
+
defaultMode: (flowStep.default_type === "image" ? "photo" : flowStep.default_type) || flowStepMode[0],
|
|
14418
14503
|
skipOnboarding: false
|
|
14419
14504
|
});
|
|
14420
14505
|
await (0, $c9e496369b59be7a$export$2f377c2162fd02b2).setStep(flowStep.token);
|
|
@@ -14595,6 +14680,7 @@ const $26ed036cbc17809a$var$StreamUI = ({ options: options })=>{
|
|
|
14595
14680
|
orientation: orientation,
|
|
14596
14681
|
flow: flows.flow,
|
|
14597
14682
|
flowV0: flows.flowV0,
|
|
14683
|
+
videoUpload: videoUpload,
|
|
14598
14684
|
recorderOptions: recorderOptions
|
|
14599
14685
|
},
|
|
14600
14686
|
children: /*#__PURE__*/ (0, $3Sbms$jsxs)((0, $3Sbms$ThemeProvider), {
|
package/dist/stream-ui.js
CHANGED
|
@@ -1141,6 +1141,48 @@ const $3898fb88b880f5ba$export$de363e709c412c8a = (fn, wait = 300)=>{
|
|
|
1141
1141
|
};
|
|
1142
1142
|
|
|
1143
1143
|
|
|
1144
|
+
const $e28f3021384abb82$export$deda6dde1c58aa97 = async (apiUrl, { file: file, token: token, stepToken: stepToken, sessionId: sessionId, userId: userId, peerId: peerId })=>{
|
|
1145
|
+
if (!file) throw new Error(`Missing file on "${file}"`);
|
|
1146
|
+
const upload = await fetch(`${apiUrl}/public/streams/${token}/events/upload`, {
|
|
1147
|
+
method: "POST",
|
|
1148
|
+
headers: {
|
|
1149
|
+
"Content-Type": "application/json"
|
|
1150
|
+
},
|
|
1151
|
+
body: JSON.stringify({
|
|
1152
|
+
filename: file.name,
|
|
1153
|
+
contentLength: file.size
|
|
1154
|
+
})
|
|
1155
|
+
});
|
|
1156
|
+
const { url: url, headers: headers, filename: filename } = await upload.json();
|
|
1157
|
+
const uploadResponse = await fetch(url, {
|
|
1158
|
+
method: "PUT",
|
|
1159
|
+
headers: {
|
|
1160
|
+
...headers,
|
|
1161
|
+
"Content-Type": file.type,
|
|
1162
|
+
"Content-Length": String(file.size)
|
|
1163
|
+
},
|
|
1164
|
+
body: file
|
|
1165
|
+
});
|
|
1166
|
+
if (!uploadResponse.ok) throw new Error("Upload failed");
|
|
1167
|
+
const type = file.type.split("/")[0];
|
|
1168
|
+
const eventRequest = await fetch(`${apiUrl}/public/streams/${token}/events`, {
|
|
1169
|
+
method: "POST",
|
|
1170
|
+
headers: {
|
|
1171
|
+
"Content-Type": "application/json"
|
|
1172
|
+
},
|
|
1173
|
+
body: JSON.stringify({
|
|
1174
|
+
filename: filename,
|
|
1175
|
+
type: type,
|
|
1176
|
+
stepToken: stepToken,
|
|
1177
|
+
session_id: sessionId,
|
|
1178
|
+
user_id: userId,
|
|
1179
|
+
peer_id: peerId
|
|
1180
|
+
})
|
|
1181
|
+
});
|
|
1182
|
+
return eventRequest.json();
|
|
1183
|
+
};
|
|
1184
|
+
|
|
1185
|
+
|
|
1144
1186
|
const $1dedebd5ff3002eb$var$log = new (0, $d0c6baf97675ab49$export$2e2bcd8739ae039)("StreamerClient");
|
|
1145
1187
|
const $1dedebd5ff3002eb$export$103bedf43ba882db = {
|
|
1146
1188
|
WEBRTC_FAILED: "WRTC1",
|
|
@@ -1363,10 +1405,7 @@ class $1dedebd5ff3002eb$export$2e2bcd8739ae039 extends $1dedebd5ff3002eb$var$Str
|
|
|
1363
1405
|
}
|
|
1364
1406
|
}
|
|
1365
1407
|
async init(room = this.roomId, options = this.joinOptions) {
|
|
1366
|
-
const initResult = {
|
|
1367
|
-
flow: undefined,
|
|
1368
|
-
flowV0: undefined
|
|
1369
|
-
};
|
|
1408
|
+
const initResult = {};
|
|
1370
1409
|
this.roomId = room;
|
|
1371
1410
|
this.peerId = (0, $jQDcL$uuid.v4)();
|
|
1372
1411
|
this.joinOptions = options;
|
|
@@ -1376,7 +1415,7 @@ class $1dedebd5ff3002eb$export$2e2bcd8739ae039 extends $1dedebd5ff3002eb$var$Str
|
|
|
1376
1415
|
const urlParams = new URLSearchParams();
|
|
1377
1416
|
if (options.flowToken) urlParams.append("flowToken", options.flowToken);
|
|
1378
1417
|
if (options.languageCode) urlParams.append("languageCode", options.languageCode);
|
|
1379
|
-
const { streamer_instance: instanceId, plan: { permissions: permissions, name: name }, flow: flow, flow_v0: flow_v0, recordings: recordings, company_id: company_id, company: company, defaultPublicPage: defaultPublicPage } = await fetch(`${this.config.apiUrl}/streams/${room}/info?${urlParams}`, {
|
|
1418
|
+
const { streamer_instance: instanceId, plan: { permissions: permissions, name: name }, flow: flow, flow_v0: flow_v0, recordings: recordings, video_upload: video_upload, company_id: company_id, company: company, defaultPublicPage: defaultPublicPage } = await fetch(`${this.config.apiUrl}/streams/${room}/info?${urlParams}`, {
|
|
1380
1419
|
method: "get",
|
|
1381
1420
|
headers: {
|
|
1382
1421
|
"Content-Type": "application/json"
|
|
@@ -1385,6 +1424,7 @@ class $1dedebd5ff3002eb$export$2e2bcd8739ae039 extends $1dedebd5ff3002eb$var$Str
|
|
|
1385
1424
|
if (response.ok) return response.json();
|
|
1386
1425
|
throw new Error("Invalid room ID");
|
|
1387
1426
|
});
|
|
1427
|
+
initResult.videoUpload = video_upload;
|
|
1388
1428
|
if (flow_v0) initResult.flowV0 = flow_v0;
|
|
1389
1429
|
if (flow && flow.steps.length > 0) {
|
|
1390
1430
|
options.recorder = true;
|
|
@@ -2484,6 +2524,15 @@ class $1dedebd5ff3002eb$export$2e2bcd8739ae039 extends $1dedebd5ff3002eb$var$Str
|
|
|
2484
2524
|
stepToken: this.stepToken
|
|
2485
2525
|
});
|
|
2486
2526
|
}
|
|
2527
|
+
async uploadEvent(file) {
|
|
2528
|
+
return (0, $e28f3021384abb82$export$deda6dde1c58aa97)(this.config.apiUrl, {
|
|
2529
|
+
token: this.roomId,
|
|
2530
|
+
file: file,
|
|
2531
|
+
peerId: this.peerId,
|
|
2532
|
+
userId: this.agentIdentity?.id,
|
|
2533
|
+
stepToken: this.stepToken
|
|
2534
|
+
});
|
|
2535
|
+
}
|
|
2487
2536
|
async deleteCapture(assetId) {
|
|
2488
2537
|
const res = await this.protoo?.request("deleteCapture", {
|
|
2489
2538
|
assetId: assetId
|
|
@@ -11189,6 +11238,7 @@ const $8dfcca373a03b9e8$export$5a5695b638d078e7 = ()=>{
|
|
|
11189
11238
|
};
|
|
11190
11239
|
|
|
11191
11240
|
|
|
11241
|
+
|
|
11192
11242
|
const $ccbd73eb953b0bd0$var$fileToDataUrl = (file)=>{
|
|
11193
11243
|
return new Promise((resolve, reject)=>{
|
|
11194
11244
|
const reader = new FileReader();
|
|
@@ -11197,7 +11247,26 @@ const $ccbd73eb953b0bd0$var$fileToDataUrl = (file)=>{
|
|
|
11197
11247
|
reader.readAsDataURL(file);
|
|
11198
11248
|
});
|
|
11199
11249
|
};
|
|
11250
|
+
const $ccbd73eb953b0bd0$var$generateVideoThumbnail = (file)=>{
|
|
11251
|
+
return new Promise((resolve)=>{
|
|
11252
|
+
const canvas = document.createElement("canvas");
|
|
11253
|
+
const video = document.createElement("video");
|
|
11254
|
+
video.autoplay = true;
|
|
11255
|
+
video.muted = true;
|
|
11256
|
+
video.currentTime = 3;
|
|
11257
|
+
video.src = URL.createObjectURL(file);
|
|
11258
|
+
video.onloadeddata = ()=>{
|
|
11259
|
+
let ctx = canvas.getContext("2d");
|
|
11260
|
+
canvas.width = video.videoWidth;
|
|
11261
|
+
canvas.height = video.videoHeight;
|
|
11262
|
+
ctx?.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
|
|
11263
|
+
video.pause();
|
|
11264
|
+
return resolve(canvas.toDataURL("image/png"));
|
|
11265
|
+
};
|
|
11266
|
+
});
|
|
11267
|
+
};
|
|
11200
11268
|
const $ccbd73eb953b0bd0$export$b3fd96a52c80b3af = ()=>{
|
|
11269
|
+
const { recorderOptions: recorderOptions, videoUpload: videoUpload } = (0, $jQDcL$react.useContext)((0, $8b39f32976a7698a$export$2e2bcd8739ae039));
|
|
11201
11270
|
const { t: t } = (0, $jQDcL$reacti18next.useTranslation)();
|
|
11202
11271
|
const { openAssetsModal: openAssetsModal, addAsset: addAsset, setIncomingAsset: setIncomingAsset, isRecording: isRecording } = (0, $098350f721a0bb52$export$2174f25d572f9f31)();
|
|
11203
11272
|
const reportError = (0, $8dfcca373a03b9e8$export$5a5695b638d078e7)();
|
|
@@ -11206,24 +11275,40 @@ const $ccbd73eb953b0bd0$export$b3fd96a52c80b3af = ()=>{
|
|
|
11206
11275
|
const onUploadClick = async (event)=>{
|
|
11207
11276
|
const file = event.target.files?.[0];
|
|
11208
11277
|
if (file && !isRecording) {
|
|
11278
|
+
const type = file.type.split("/")[0];
|
|
11209
11279
|
const createdAt = Date.now();
|
|
11280
|
+
const mode = type === "image" ? "photo" : type;
|
|
11210
11281
|
setIncomingAsset({
|
|
11211
|
-
mode:
|
|
11282
|
+
mode: mode,
|
|
11212
11283
|
createdAt: createdAt
|
|
11213
11284
|
});
|
|
11214
11285
|
openAssetsModal();
|
|
11215
11286
|
try {
|
|
11216
|
-
|
|
11217
|
-
|
|
11287
|
+
let url;
|
|
11288
|
+
let thumbnailUrl;
|
|
11289
|
+
let id;
|
|
11290
|
+
if (type === "image") {
|
|
11291
|
+
const dataUrl = await $ccbd73eb953b0bd0$var$fileToDataUrl(file);
|
|
11292
|
+
const data = await (0, $c48c1ecc38fed4e9$export$2f377c2162fd02b2).saveCapture(dataUrl);
|
|
11293
|
+
url = data.url;
|
|
11294
|
+
id = data.assetId;
|
|
11295
|
+
} else {
|
|
11296
|
+
const data = await (0, $c48c1ecc38fed4e9$export$2f377c2162fd02b2).uploadEvent(file);
|
|
11297
|
+
url = data.url;
|
|
11298
|
+
id = data.id;
|
|
11299
|
+
if (type === "video") thumbnailUrl = await $ccbd73eb953b0bd0$var$generateVideoThumbnail(file);
|
|
11300
|
+
if (!url || !id) throw new Error("upload failed");
|
|
11301
|
+
}
|
|
11218
11302
|
addAsset({
|
|
11219
|
-
id:
|
|
11220
|
-
mode:
|
|
11303
|
+
id: id,
|
|
11304
|
+
mode: mode,
|
|
11221
11305
|
url: url,
|
|
11222
|
-
thumbnailUrl: url,
|
|
11306
|
+
thumbnailUrl: thumbnailUrl || url,
|
|
11223
11307
|
createdAt: createdAt
|
|
11224
11308
|
});
|
|
11225
11309
|
openAssetsModal();
|
|
11226
11310
|
} catch (error) {
|
|
11311
|
+
console.log(error);
|
|
11227
11312
|
reportError({
|
|
11228
11313
|
code: "UPLD_1",
|
|
11229
11314
|
error: error
|
|
@@ -11237,13 +11322,13 @@ const $ccbd73eb953b0bd0$export$b3fd96a52c80b3af = ()=>{
|
|
|
11237
11322
|
/*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsx)("input", {
|
|
11238
11323
|
ref: fileInputRef,
|
|
11239
11324
|
type: "file",
|
|
11240
|
-
accept: "
|
|
11325
|
+
accept: videoUpload ? "image/*,video/*,audio/*" : "image/*",
|
|
11241
11326
|
className: "hidden",
|
|
11242
11327
|
onChange: onUploadClick
|
|
11243
11328
|
}),
|
|
11244
11329
|
/*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsxs)((0, $jQDcL$snapcalldesignsystem.Button), {
|
|
11245
11330
|
className: (0, ($parcel$interopDefault($jQDcL$classnames)))("bg-gray-25/50 hover:bg-gray-25/60 active:bg-gray-25/70 rounded-full", {
|
|
11246
|
-
invisible: isRecording
|
|
11331
|
+
invisible: isRecording || !recorderOptions?.enabledModes.includes("photo") && !videoUpload
|
|
11247
11332
|
}),
|
|
11248
11333
|
icon: !isMedium,
|
|
11249
11334
|
onClick: ()=>fileInputRef.current?.click(),
|
|
@@ -14304,6 +14389,7 @@ const $ee8cb448c2c74888$var$StreamUI = ({ options: options })=>{
|
|
|
14304
14389
|
const [permissions, setPermissions] = (0, $jQDcL$react.useState)([]);
|
|
14305
14390
|
const [plan, setPlan] = (0, $jQDcL$react.useState)(undefined);
|
|
14306
14391
|
const [flows, setFlows] = (0, $jQDcL$react.useState)({});
|
|
14392
|
+
const [videoUpload, setVideoUpload] = (0, $jQDcL$react.useState)(false);
|
|
14307
14393
|
const [recorderOptions, setRecorderOptions] = (0, $jQDcL$react.useState)(options.recorder);
|
|
14308
14394
|
const isFirstRender = (0, $67040444b405b263$export$5964c316e853650f)();
|
|
14309
14395
|
const orientation = (containerWidth || window.screen.width) > (containerHeight || window.screen.height) ? "landscape" : "portrait";
|
|
@@ -14411,16 +14497,15 @@ const $ee8cb448c2c74888$var$StreamUI = ({ options: options })=>{
|
|
|
14411
14497
|
});
|
|
14412
14498
|
};
|
|
14413
14499
|
const onClientInitialized = (0, $jQDcL$react.useCallback)(async (event)=>{
|
|
14414
|
-
const { flow: flow, flowV0: flowV0 } = event.detail;
|
|
14500
|
+
const { flow: flow, flowV0: flowV0, videoUpload: videoUpload } = event.detail;
|
|
14501
|
+
setVideoUpload(videoUpload || false);
|
|
14415
14502
|
const flowStep = flow?.steps[0];
|
|
14416
14503
|
if (flowStep) {
|
|
14417
|
-
const flowStepMode = flowStep.type === "image" ? "photo" :
|
|
14504
|
+
const flowStepMode = flowStep.types.map((type)=>type === "image" ? "photo" : type);
|
|
14418
14505
|
setRecorderOptions({
|
|
14419
|
-
enabledModes:
|
|
14420
|
-
flowStepMode
|
|
14421
|
-
],
|
|
14506
|
+
enabledModes: flowStepMode,
|
|
14422
14507
|
enabled: true,
|
|
14423
|
-
defaultMode: flowStepMode,
|
|
14508
|
+
defaultMode: (flowStep.default_type === "image" ? "photo" : flowStep.default_type) || flowStepMode[0],
|
|
14424
14509
|
skipOnboarding: false
|
|
14425
14510
|
});
|
|
14426
14511
|
await (0, $c48c1ecc38fed4e9$export$2f377c2162fd02b2).setStep(flowStep.token);
|
|
@@ -14601,6 +14686,7 @@ const $ee8cb448c2c74888$var$StreamUI = ({ options: options })=>{
|
|
|
14601
14686
|
orientation: orientation,
|
|
14602
14687
|
flow: flows.flow,
|
|
14603
14688
|
flowV0: flows.flowV0,
|
|
14689
|
+
videoUpload: videoUpload,
|
|
14604
14690
|
recorderOptions: recorderOptions
|
|
14605
14691
|
},
|
|
14606
14692
|
children: /*#__PURE__*/ (0, $jQDcL$reactjsxruntime.jsxs)((0, $jQDcL$styledcomponents.ThemeProvider), {
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,695 @@
|
|
|
1
|
+
import * as mediasoupClient from "mediasoup-client";
|
|
2
|
+
import { types } from "mediasoup-client";
|
|
3
|
+
import * as protooClient from "protoo-client";
|
|
4
|
+
import { Transport } from "mediasoup-client/lib/Transport";
|
|
5
|
+
import { CSSProperties } from "react";
|
|
6
|
+
type VideoResolution = 'qvga' | 'vga' | 'hd';
|
|
7
|
+
type PeerId = string;
|
|
8
|
+
type DeviceType = 'webcam' | 'screen' | 'microphone';
|
|
9
|
+
interface Profile {
|
|
10
|
+
name?: string;
|
|
11
|
+
image?: string;
|
|
12
|
+
}
|
|
13
|
+
interface Step {
|
|
14
|
+
types: Array<'video' | 'audio' | 'screen' | 'image'>;
|
|
15
|
+
default_type: 'video' | 'audio' | 'screen' | 'image';
|
|
16
|
+
token: string;
|
|
17
|
+
title: string;
|
|
18
|
+
description: string;
|
|
19
|
+
image_url: string;
|
|
20
|
+
translation: {
|
|
21
|
+
title?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
button?: string;
|
|
24
|
+
languageCode?: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
interface Flow {
|
|
28
|
+
token: string;
|
|
29
|
+
name: string;
|
|
30
|
+
is_default: number;
|
|
31
|
+
steps: Array<Step>;
|
|
32
|
+
}
|
|
33
|
+
interface FlowV0 {
|
|
34
|
+
logo_url?: string;
|
|
35
|
+
image_url?: string;
|
|
36
|
+
title?: string;
|
|
37
|
+
text?: string;
|
|
38
|
+
}
|
|
39
|
+
interface InitResult {
|
|
40
|
+
flow?: Flow;
|
|
41
|
+
flowV0?: FlowV0;
|
|
42
|
+
videoUpload?: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface JoinOptions {
|
|
45
|
+
languageCode?: string;
|
|
46
|
+
flowToken?: string;
|
|
47
|
+
recorder?: boolean;
|
|
48
|
+
apiKey?: string;
|
|
49
|
+
email?: string;
|
|
50
|
+
displayName?: string;
|
|
51
|
+
profile?: Profile;
|
|
52
|
+
authKey?: string;
|
|
53
|
+
}
|
|
54
|
+
interface PeerState {
|
|
55
|
+
peerId: string;
|
|
56
|
+
profile: Profile;
|
|
57
|
+
deviceState: DevicesState;
|
|
58
|
+
}
|
|
59
|
+
interface CompanyInfo {
|
|
60
|
+
name?: string;
|
|
61
|
+
company_name?: string;
|
|
62
|
+
avatar_url?: string;
|
|
63
|
+
terminate_enabled?: boolean;
|
|
64
|
+
}
|
|
65
|
+
type WaitingRequests = Array<{
|
|
66
|
+
id: string;
|
|
67
|
+
profile?: Profile;
|
|
68
|
+
}>;
|
|
69
|
+
interface GetRoomPeersResult {
|
|
70
|
+
peers: Array<{
|
|
71
|
+
id: string;
|
|
72
|
+
displayName?: string;
|
|
73
|
+
profile: Profile;
|
|
74
|
+
muted: boolean;
|
|
75
|
+
producersIds: string[];
|
|
76
|
+
producersData: ProducerData[];
|
|
77
|
+
}>;
|
|
78
|
+
videoRecordStarted: boolean;
|
|
79
|
+
videoRecording: {
|
|
80
|
+
requested: boolean;
|
|
81
|
+
started: boolean;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
interface StreamerState extends PeerState {
|
|
85
|
+
roomId: string;
|
|
86
|
+
plan?: string;
|
|
87
|
+
permissions: Permissions;
|
|
88
|
+
company?: CompanyInfo;
|
|
89
|
+
companyId: number;
|
|
90
|
+
waitingRoomAccess: boolean;
|
|
91
|
+
peers: Array<PeerState>;
|
|
92
|
+
joinOptions: JoinOptions;
|
|
93
|
+
}
|
|
94
|
+
interface ProducerData {
|
|
95
|
+
producerId: string;
|
|
96
|
+
deviceType: DeviceType;
|
|
97
|
+
paused: boolean;
|
|
98
|
+
}
|
|
99
|
+
interface PeerInfo {
|
|
100
|
+
id?: PeerId;
|
|
101
|
+
peerId: PeerId;
|
|
102
|
+
muted: boolean;
|
|
103
|
+
profile: Profile;
|
|
104
|
+
displayName?: string;
|
|
105
|
+
producersData: Array<ProducerData>;
|
|
106
|
+
}
|
|
107
|
+
type ConsumerId = string;
|
|
108
|
+
type ProducerId = string;
|
|
109
|
+
interface ConsumerData {
|
|
110
|
+
mediaSoupConsumer: types.Consumer;
|
|
111
|
+
deviceType?: DeviceType;
|
|
112
|
+
}
|
|
113
|
+
interface DevicesState {
|
|
114
|
+
microphone: {
|
|
115
|
+
enabled: boolean;
|
|
116
|
+
muted: boolean;
|
|
117
|
+
device?: MediaDeviceInfo | null;
|
|
118
|
+
};
|
|
119
|
+
camera: {
|
|
120
|
+
enabled: boolean;
|
|
121
|
+
device?: MediaDeviceInfo | null;
|
|
122
|
+
};
|
|
123
|
+
screenshare: {
|
|
124
|
+
enabled: boolean;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
interface Config {
|
|
128
|
+
apiUrl: string;
|
|
129
|
+
streamerServer: string;
|
|
130
|
+
streamerApi: string;
|
|
131
|
+
iceServers: RTCIceServer[];
|
|
132
|
+
streamApiURL: string;
|
|
133
|
+
}
|
|
134
|
+
type Permission = 'share_link' | 'direct_pay' | 'quick_connect' | 'virtual_background' | 'screen_sharing' | 'instant_picture' | 'request_input' | 'recording' | 'record_video_on_demand';
|
|
135
|
+
type Permissions = Array<Permission>;
|
|
136
|
+
declare global {
|
|
137
|
+
interface Window {
|
|
138
|
+
webkitAudioContext: Function;
|
|
139
|
+
}
|
|
140
|
+
interface MediaTrackConstraintSet {
|
|
141
|
+
displaySurface?: ConstrainDOMString;
|
|
142
|
+
logicalSurface?: ConstrainBoolean;
|
|
143
|
+
zoom?: number;
|
|
144
|
+
focusMode?: 'none' | 'manual' | 'single-shot' | 'continuous';
|
|
145
|
+
}
|
|
146
|
+
interface MediaTrackCapabilities {
|
|
147
|
+
zoom: {
|
|
148
|
+
min: number;
|
|
149
|
+
max: number;
|
|
150
|
+
step: number;
|
|
151
|
+
};
|
|
152
|
+
focusMode?: Array<'none' | 'manual' | 'single-shot' | 'continuous'>;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
interface MenuItem {
|
|
156
|
+
id: string;
|
|
157
|
+
title: string;
|
|
158
|
+
jsxIcon?: JSX.Element;
|
|
159
|
+
srcIcon?: string;
|
|
160
|
+
action: () => void;
|
|
161
|
+
danger?: boolean;
|
|
162
|
+
isNew?: boolean;
|
|
163
|
+
}
|
|
164
|
+
interface MenuCategory {
|
|
165
|
+
id: string;
|
|
166
|
+
title?: string;
|
|
167
|
+
items: MenuItem[];
|
|
168
|
+
}
|
|
169
|
+
type DisplayType = 'icon' | 'full';
|
|
170
|
+
interface SettingShortcut {
|
|
171
|
+
id: string;
|
|
172
|
+
displayType: DisplayType;
|
|
173
|
+
}
|
|
174
|
+
interface SettingsCategory extends MenuCategory {
|
|
175
|
+
position?: number;
|
|
176
|
+
items: SettingsItem[];
|
|
177
|
+
}
|
|
178
|
+
interface SettingsItem extends MenuItem {
|
|
179
|
+
position?: number;
|
|
180
|
+
}
|
|
181
|
+
interface AudioLevelListener {
|
|
182
|
+
onAudioLevel?(audioLevel: number, id: string): void;
|
|
183
|
+
onMuteDetection?(id: string): void;
|
|
184
|
+
onStartSpeak(): void;
|
|
185
|
+
onStopSpeak(): void;
|
|
186
|
+
}
|
|
187
|
+
declare class AudioLevel {
|
|
188
|
+
readonly id: string;
|
|
189
|
+
constructor(stream: MediaStream, listener?: AudioLevelListener);
|
|
190
|
+
/**
|
|
191
|
+
* return the median of the audio levels (60 per second) for the
|
|
192
|
+
* current second
|
|
193
|
+
*/
|
|
194
|
+
getAudioLevelMedian(): number;
|
|
195
|
+
getCurrentAudioLevel(): number;
|
|
196
|
+
analyse(): void;
|
|
197
|
+
startAverageAnalysis(): void;
|
|
198
|
+
stopAverageAnalysis(): number;
|
|
199
|
+
getFrequencyData(): Uint8Array;
|
|
200
|
+
clearListeners(): void;
|
|
201
|
+
release(): void;
|
|
202
|
+
static isAPIAvailable(): boolean;
|
|
203
|
+
}
|
|
204
|
+
declare class AudioRenderer {
|
|
205
|
+
constructor({ consumerId }: {
|
|
206
|
+
consumerId: string;
|
|
207
|
+
});
|
|
208
|
+
destroy(): void;
|
|
209
|
+
setSource(srcObject: MediaStream): void;
|
|
210
|
+
setSink(sinkId: string): Promise<void>;
|
|
211
|
+
getSink(): string;
|
|
212
|
+
play(): Promise<void>;
|
|
213
|
+
}
|
|
214
|
+
interface MediapipeOptions {
|
|
215
|
+
type: 'blur' | 'background';
|
|
216
|
+
fillColor?: string;
|
|
217
|
+
background?: CanvasImageSource;
|
|
218
|
+
blurLevel?: number;
|
|
219
|
+
}
|
|
220
|
+
interface DeviceRequest {
|
|
221
|
+
requestId: string;
|
|
222
|
+
deviceType: DeviceType;
|
|
223
|
+
}
|
|
224
|
+
interface CustomMessage {
|
|
225
|
+
chunks: Array<{
|
|
226
|
+
index: number;
|
|
227
|
+
data: string;
|
|
228
|
+
}>;
|
|
229
|
+
totalChunks: number;
|
|
230
|
+
}
|
|
231
|
+
declare global {
|
|
232
|
+
export namespace SnapCall {
|
|
233
|
+
export { Permissions, Permission };
|
|
234
|
+
export type SnapcallEvent<T> = CustomEvent<T>;
|
|
235
|
+
export type PeersInfoEvent = SnapcallEvent<{
|
|
236
|
+
videoRecordStarted: boolean;
|
|
237
|
+
videoRecording?: {
|
|
238
|
+
requested: boolean;
|
|
239
|
+
started: boolean;
|
|
240
|
+
};
|
|
241
|
+
peerId: string;
|
|
242
|
+
plan?: string;
|
|
243
|
+
permissions: Permissions;
|
|
244
|
+
peers: {
|
|
245
|
+
peerId: string;
|
|
246
|
+
muted: boolean;
|
|
247
|
+
displayName?: string;
|
|
248
|
+
profile: Profile;
|
|
249
|
+
}[];
|
|
250
|
+
}>;
|
|
251
|
+
export type PeerInfoEvent = SnapcallEvent<{
|
|
252
|
+
peerId: string;
|
|
253
|
+
displayName?: string;
|
|
254
|
+
profile: Profile;
|
|
255
|
+
}>;
|
|
256
|
+
export type RequestAccessEvent = SnapcallEvent<{
|
|
257
|
+
success: string;
|
|
258
|
+
message?: string;
|
|
259
|
+
}>;
|
|
260
|
+
export type RequestAccessRequestEvent = SnapcallEvent<WaitingRequests[number]>;
|
|
261
|
+
export type RequestAccessCancelEvent = SnapcallEvent<{
|
|
262
|
+
id: string;
|
|
263
|
+
}>;
|
|
264
|
+
export type ProfileUpdateEvent = SnapcallEvent<{
|
|
265
|
+
peerId: string;
|
|
266
|
+
profile: Profile;
|
|
267
|
+
}>;
|
|
268
|
+
export type RequestDeviceEvent = SnapcallEvent<{
|
|
269
|
+
peerId: string;
|
|
270
|
+
deviceType: DeviceType;
|
|
271
|
+
}>;
|
|
272
|
+
export type RequestDeviceResultEvent = SnapcallEvent<{
|
|
273
|
+
result: {
|
|
274
|
+
peerId: string;
|
|
275
|
+
result: boolean;
|
|
276
|
+
};
|
|
277
|
+
}>;
|
|
278
|
+
export type BaseEvent = SnapcallEvent<{}>;
|
|
279
|
+
export type StreamEvent = SnapcallEvent<{
|
|
280
|
+
peerId: string;
|
|
281
|
+
}>;
|
|
282
|
+
export type RequestResultEvent = SnapcallEvent<{
|
|
283
|
+
success: Boolean;
|
|
284
|
+
}>;
|
|
285
|
+
export type AudioDeviceEvent = SnapcallEvent<MediaDeviceInfo>;
|
|
286
|
+
export type MediaEvent = SnapcallEvent<{
|
|
287
|
+
peerId: string;
|
|
288
|
+
mediaId?: string;
|
|
289
|
+
deviceType: DeviceType;
|
|
290
|
+
paused: boolean;
|
|
291
|
+
}>;
|
|
292
|
+
export type WebcamUpdateEvent = SnapcallEvent<{
|
|
293
|
+
numberOfAvailableWebcams: number;
|
|
294
|
+
}>;
|
|
295
|
+
export type CriticalErrorEvent = SnapcallEvent<{
|
|
296
|
+
code: string;
|
|
297
|
+
}>;
|
|
298
|
+
export type CustomMessageEvent = SnapcallEvent<{
|
|
299
|
+
peerId: string;
|
|
300
|
+
event: {
|
|
301
|
+
type: string;
|
|
302
|
+
} & Record<string, any>;
|
|
303
|
+
}>;
|
|
304
|
+
export type localVideoChangeEvent = SnapcallEvent<{
|
|
305
|
+
camera: {
|
|
306
|
+
device: MediaDeviceInfo | null;
|
|
307
|
+
resolution: VideoResolution;
|
|
308
|
+
};
|
|
309
|
+
}>;
|
|
310
|
+
export type AgentIdentityEvent = SnapcallEvent<{
|
|
311
|
+
success: boolean;
|
|
312
|
+
email?: string;
|
|
313
|
+
name?: string;
|
|
314
|
+
avatarUrl?: string;
|
|
315
|
+
}>;
|
|
316
|
+
export type RecordStoppedEvent = SnapcallEvent<{
|
|
317
|
+
url: string;
|
|
318
|
+
assetId: number;
|
|
319
|
+
}>;
|
|
320
|
+
export type AudioLevelEvent = SnapcallEvent<{
|
|
321
|
+
audioLevel: number;
|
|
322
|
+
}>;
|
|
323
|
+
export type InitializedEvent = SnapcallEvent<InitResult>;
|
|
324
|
+
}
|
|
325
|
+
export interface PublicPage {
|
|
326
|
+
token: string;
|
|
327
|
+
logo_url: string;
|
|
328
|
+
title: string;
|
|
329
|
+
description: string;
|
|
330
|
+
data: {
|
|
331
|
+
links: {
|
|
332
|
+
id: 'recordVideo' | 'takePicture' | 'scheduleCall' | 'recordScreen';
|
|
333
|
+
active: boolean;
|
|
334
|
+
user_ids?: number[];
|
|
335
|
+
team_ids?: number[];
|
|
336
|
+
schedule_ids?: string[];
|
|
337
|
+
}[];
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
interface StreamerEventMap {
|
|
342
|
+
audioLevel: SnapCall.AudioLevelEvent['detail'];
|
|
343
|
+
localStartSpeak?: SnapCall.BaseEvent['detail'];
|
|
344
|
+
localStopSpeak?: SnapCall.BaseEvent['detail'];
|
|
345
|
+
leaveRoom: SnapCall.BaseEvent['detail'];
|
|
346
|
+
terminateRoom: SnapCall.BaseEvent['detail'];
|
|
347
|
+
invalidRoom: SnapCall.BaseEvent['detail'];
|
|
348
|
+
accessRequest: SnapCall.RequestAccessRequestEvent['detail'];
|
|
349
|
+
cancelAccessRequest: SnapCall.RequestAccessCancelEvent['detail'];
|
|
350
|
+
requestAccessResult: SnapCall.RequestAccessEvent['detail'];
|
|
351
|
+
localVideoUnavailable: SnapCall.BaseEvent['detail'];
|
|
352
|
+
localVideoAvailable: SnapCall.BaseEvent['detail'];
|
|
353
|
+
microphoneEnabled: SnapCall.BaseEvent['detail'];
|
|
354
|
+
agentIdentity: SnapCall.AgentIdentityEvent['detail'];
|
|
355
|
+
peerClosed: SnapCall.StreamEvent['detail'];
|
|
356
|
+
newPeer: SnapCall.PeerInfoEvent['detail'];
|
|
357
|
+
selfDisplayName: SnapCall.PeerInfoEvent['detail'];
|
|
358
|
+
selfProfileUpdate: SnapCall.ProfileUpdateEvent['detail'];
|
|
359
|
+
profileUpdate: SnapCall.ProfileUpdateEvent['detail'];
|
|
360
|
+
webcamsUpdate: SnapCall.WebcamUpdateEvent['detail'];
|
|
361
|
+
customMessage: SnapCall.CustomMessageEvent['detail'];
|
|
362
|
+
mediaStart: SnapCall.MediaEvent['detail'];
|
|
363
|
+
mediaStop: SnapCall.MediaEvent['detail'];
|
|
364
|
+
mediaPause: SnapCall.MediaEvent['detail'];
|
|
365
|
+
mediaResume: SnapCall.MediaEvent['detail'];
|
|
366
|
+
microphoneMute: SnapCall.BaseEvent['detail'];
|
|
367
|
+
microphoneUnmute: SnapCall.BaseEvent['detail'];
|
|
368
|
+
defaultAudioDeviceChange: SnapCall.AudioDeviceEvent['detail'];
|
|
369
|
+
screenshareEnabled: SnapCall.BaseEvent['detail'];
|
|
370
|
+
screenshareDisabled: SnapCall.BaseEvent['detail'];
|
|
371
|
+
localVideoRotate: SnapCall.BaseEvent['detail'];
|
|
372
|
+
enterRoom: SnapCall.PeersInfoEvent['detail'];
|
|
373
|
+
displayName: SnapCall.PeerInfoEvent['detail'];
|
|
374
|
+
peerStartSpeak: SnapCall.StreamEvent['detail'];
|
|
375
|
+
peerStopSpeak: SnapCall.StreamEvent['detail'];
|
|
376
|
+
criticalError: SnapCall.CriticalErrorEvent['detail'];
|
|
377
|
+
requestDevice: SnapCall.RequestDeviceEvent['detail'];
|
|
378
|
+
requestDeviceResult: SnapCall.RequestDeviceResultEvent['detail'];
|
|
379
|
+
devicesListChange: SnapCall.BaseEvent['detail'];
|
|
380
|
+
localVideoChange: SnapCall.localVideoChangeEvent['detail'];
|
|
381
|
+
recordStopped: SnapCall.RecordStoppedEvent['detail'];
|
|
382
|
+
videoRecordingStarted: SnapCall.BaseEvent['detail'];
|
|
383
|
+
videoRecordingStopped: SnapCall.BaseEvent['detail'];
|
|
384
|
+
videoRecordingRequested: SnapCall.BaseEvent['detail'];
|
|
385
|
+
initialized: SnapCall.InitializedEvent['detail'];
|
|
386
|
+
}
|
|
387
|
+
declare class SnapcallEvent<T extends keyof StreamerEventMap> extends CustomEvent<StreamerEventMap[T]> {
|
|
388
|
+
constructor(name: T, data: CustomEventInit & {
|
|
389
|
+
detail: StreamerEventMap[T];
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
interface StreamerEventTarget extends EventTarget {
|
|
393
|
+
addEventListener<T extends keyof StreamerEventMap>(type: T, listener: (event: CustomEvent<StreamerEventMap[T]>) => void, options?: boolean | AddEventListenerOptions): void;
|
|
394
|
+
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;
|
|
395
|
+
removeEventListener<T extends keyof StreamerEventMap>(type: T, listener: (event: CustomEvent<StreamerEventMap[T]>) => void): void;
|
|
396
|
+
removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null): void;
|
|
397
|
+
dispatchEvent<T extends keyof StreamerEventMap>(ev: SnapcallEvent<T>): boolean;
|
|
398
|
+
}
|
|
399
|
+
declare const StreamerEventTargetType: {
|
|
400
|
+
new (): StreamerEventTarget;
|
|
401
|
+
prototype: StreamerEventTarget;
|
|
402
|
+
};
|
|
403
|
+
declare class StreamerClient extends StreamerEventTargetType implements AudioLevelListener {
|
|
404
|
+
peers: Map<PeerId, PeerInfo>;
|
|
405
|
+
consumers: Map<ConsumerId, ConsumerData>;
|
|
406
|
+
webcams: Map<string, MediaDeviceInfo>;
|
|
407
|
+
webcam: {
|
|
408
|
+
device: MediaDeviceInfo | null;
|
|
409
|
+
facingMode?: string;
|
|
410
|
+
resolution: VideoResolution;
|
|
411
|
+
framerate?: number;
|
|
412
|
+
};
|
|
413
|
+
microphone: {
|
|
414
|
+
device: MediaDeviceInfo | null;
|
|
415
|
+
muted: boolean;
|
|
416
|
+
};
|
|
417
|
+
webcamTrack: MediaStreamTrack | null;
|
|
418
|
+
webcamZoom: {
|
|
419
|
+
available: boolean;
|
|
420
|
+
min: number;
|
|
421
|
+
max: number;
|
|
422
|
+
};
|
|
423
|
+
audioLevel: AudioLevel | undefined;
|
|
424
|
+
roomId: string;
|
|
425
|
+
companyId: number;
|
|
426
|
+
defaultPublicPage?: {
|
|
427
|
+
token: string;
|
|
428
|
+
};
|
|
429
|
+
peerId: PeerId;
|
|
430
|
+
clientId: string;
|
|
431
|
+
profile: Profile;
|
|
432
|
+
protooTransport?: protooClient.WebSocketTransport;
|
|
433
|
+
protoo?: protooClient.Peer;
|
|
434
|
+
micProducer?: mediasoupClient.types.Producer;
|
|
435
|
+
webcamProducer: mediasoupClient.types.Producer | null;
|
|
436
|
+
screenshareVideoProducer?: mediasoupClient.types.Producer;
|
|
437
|
+
screenshareAudioProducer?: mediasoupClient.types.Producer;
|
|
438
|
+
pendingDeviceRequest: Record<string, DeviceRequest>;
|
|
439
|
+
joinOptions: JoinOptions;
|
|
440
|
+
audioInputDefaultDevice?: MediaDeviceInfo;
|
|
441
|
+
devicesList: Array<MediaDeviceInfo>;
|
|
442
|
+
customMessages: Map<string, CustomMessage>;
|
|
443
|
+
audioRenderers: Record<string, AudioRenderer>;
|
|
444
|
+
constructor();
|
|
445
|
+
getState(): StreamerState;
|
|
446
|
+
onAudioLevel: (this: any) => void;
|
|
447
|
+
onStartSpeak(): void;
|
|
448
|
+
onStopSpeak(): void;
|
|
449
|
+
generateToken(bid: string): Promise<string>;
|
|
450
|
+
init(room?: string, options?: JoinOptions): Promise<InitResult>;
|
|
451
|
+
setAgentIdentity({ apiKey, email }: {
|
|
452
|
+
apiKey: string;
|
|
453
|
+
email?: string;
|
|
454
|
+
}): Promise<void>;
|
|
455
|
+
acceptAccessRequest(id: string): Promise<any>;
|
|
456
|
+
setStep(stepToken: string): Promise<void>;
|
|
457
|
+
denyAccessRequest(id: string): Promise<any>;
|
|
458
|
+
requestRoomAccess(): Promise<void>;
|
|
459
|
+
joinRoom(): Promise<void>;
|
|
460
|
+
getRoomPeers(): Promise<GetRoomPeersResult>;
|
|
461
|
+
onEnterRoom(): Promise<void>;
|
|
462
|
+
joinRecorder(): Promise<void>;
|
|
463
|
+
switchMicrophone(deviceId?: string): Promise<void>;
|
|
464
|
+
closeMicrophoneProducer(): Promise<void>;
|
|
465
|
+
onDeviceChange(): Promise<void>;
|
|
466
|
+
enableMicrophone({ deviceId }?: {
|
|
467
|
+
deviceId?: string;
|
|
468
|
+
}): Promise<void>;
|
|
469
|
+
muteMicrophone(): void;
|
|
470
|
+
unMuteMicrophone(): void;
|
|
471
|
+
toggleMute(): Promise<{
|
|
472
|
+
muted: boolean;
|
|
473
|
+
}>;
|
|
474
|
+
release(): void;
|
|
475
|
+
endCall(): void;
|
|
476
|
+
terminateRoom(): void;
|
|
477
|
+
updateWebcams(): Promise<void>;
|
|
478
|
+
isVideoZoomAvailable(): boolean;
|
|
479
|
+
handleGetUserMediaError(deviceType: DeviceType, getUserMediaPromise: Promise<MediaStream>): Promise<MediaStream>;
|
|
480
|
+
restartIce(transport: Transport): Promise<void>;
|
|
481
|
+
setVideoBackground(options: MediapipeOptions): void;
|
|
482
|
+
initVideoBackground(): Promise<void>;
|
|
483
|
+
stopVideoBackground(): Promise<void>;
|
|
484
|
+
switchWebcam({ device, resolution, rotate, frameRate, facingMode, }: {
|
|
485
|
+
device?: MediaDeviceInfo;
|
|
486
|
+
resolution?: VideoResolution;
|
|
487
|
+
rotate?: boolean;
|
|
488
|
+
frameRate?: number;
|
|
489
|
+
facingMode?: string;
|
|
490
|
+
}): Promise<void>;
|
|
491
|
+
enableVideo(config?: {
|
|
492
|
+
device?: MediaDeviceInfo;
|
|
493
|
+
facingMode?: string;
|
|
494
|
+
resolution?: VideoResolution;
|
|
495
|
+
frameRate?: number;
|
|
496
|
+
}): Promise<void>;
|
|
497
|
+
rotateVideo(): Promise<void>;
|
|
498
|
+
zoomVideo(): Promise<void>;
|
|
499
|
+
unzoomVideo(): Promise<void>;
|
|
500
|
+
disableVideo(): Promise<void>;
|
|
501
|
+
enableScreenshare(options?: {
|
|
502
|
+
mediaStream?: MediaStream;
|
|
503
|
+
audioTransportOption: 'mix' | 'none' | 'classic';
|
|
504
|
+
}): Promise<void>;
|
|
505
|
+
disableScreenshare(): Promise<void>;
|
|
506
|
+
onConsumerClose({ consumerId }: {
|
|
507
|
+
consumerId: ConsumerId;
|
|
508
|
+
}): void;
|
|
509
|
+
requestVideo({ mediaId, element }: {
|
|
510
|
+
mediaId: string;
|
|
511
|
+
element: HTMLVideoElement;
|
|
512
|
+
}): void;
|
|
513
|
+
saveCapture(base64Image: string): Promise<{
|
|
514
|
+
url: string;
|
|
515
|
+
assetId: number;
|
|
516
|
+
}>;
|
|
517
|
+
uploadEvent(file: any): Promise<{
|
|
518
|
+
url?: string;
|
|
519
|
+
id?: number;
|
|
520
|
+
success: boolean;
|
|
521
|
+
}>;
|
|
522
|
+
deleteCapture(assetId: number): Promise<number>;
|
|
523
|
+
captureVideo(videoElement?: HTMLVideoElement): Promise<string>;
|
|
524
|
+
requestLocalVideo(element: HTMLVideoElement): {
|
|
525
|
+
facingMode: string;
|
|
526
|
+
};
|
|
527
|
+
requestLocalScreenshare(element: HTMLVideoElement): void;
|
|
528
|
+
consumePeer({ peerId, producersData, }: {
|
|
529
|
+
peerId: PeerId;
|
|
530
|
+
producersData: Array<ProducerData>;
|
|
531
|
+
}): void;
|
|
532
|
+
consumeProducer({ peerId, producerId, deviceType, paused, }: {
|
|
533
|
+
peerId: PeerId;
|
|
534
|
+
producerId: ProducerId;
|
|
535
|
+
deviceType: DeviceType;
|
|
536
|
+
paused: boolean;
|
|
537
|
+
}): Promise<void>;
|
|
538
|
+
setDisplayName(displayName: string): Promise<void>;
|
|
539
|
+
setProfile(profile: Profile): Promise<void>;
|
|
540
|
+
requestPeerDevice(remotePeerId: string, deviceType: DeviceType): Promise<void>;
|
|
541
|
+
denyDeviceRequest(deviceType: DeviceType): void;
|
|
542
|
+
getConsumers(): Map<string, ConsumerData>;
|
|
543
|
+
getDevicesState(): DevicesState;
|
|
544
|
+
sendCustomMessageToAll(event: any): Promise<void>;
|
|
545
|
+
sendCustomMessage(peerId: string, event: any): Promise<void>;
|
|
546
|
+
listAudioDevices(): Promise<MediaDeviceInfo[]>;
|
|
547
|
+
listVideoDevices(): Promise<MediaDeviceInfo[]>;
|
|
548
|
+
isListDevicesSupported(): boolean;
|
|
549
|
+
getCurrentWebcam(): {
|
|
550
|
+
device: MediaDeviceInfo | null;
|
|
551
|
+
resolution: VideoResolution;
|
|
552
|
+
};
|
|
553
|
+
getCurrentMicrophoneId(): string | MediaTrackSettings | undefined;
|
|
554
|
+
getCurrentSpeakerId(): string;
|
|
555
|
+
setWebcamResolution(resolution: VideoResolution): Promise<void>;
|
|
556
|
+
createAudioRenderer(consumerId: string): AudioRenderer;
|
|
557
|
+
deleteAudioRenderer(consumerId: string): void;
|
|
558
|
+
playAudioRenderer(consumerId: string): Promise<void>;
|
|
559
|
+
setAudioSink(sinkId: string): Promise<void>;
|
|
560
|
+
dispatchEvent(event: SnapcallEvent<keyof StreamerEventMap>): boolean;
|
|
561
|
+
setConfig(config: Partial<Config>): void;
|
|
562
|
+
getPermissions(): Permissions;
|
|
563
|
+
startRecord(): Promise<void>;
|
|
564
|
+
stopRecord(): Promise<void>;
|
|
565
|
+
getPublicPage(token: string): Promise<PublicPage>;
|
|
566
|
+
getWaitingRequests(): Promise<WaitingRequests>;
|
|
567
|
+
}
|
|
568
|
+
declare const streamerClient: StreamerClient;
|
|
569
|
+
interface NotificationOptions {
|
|
570
|
+
icon?: JSX.Element | string;
|
|
571
|
+
subText?: string;
|
|
572
|
+
button?: {
|
|
573
|
+
icon?: JSX.Element | string;
|
|
574
|
+
text: string;
|
|
575
|
+
action: () => void;
|
|
576
|
+
style?: CSSProperties;
|
|
577
|
+
};
|
|
578
|
+
status?: {
|
|
579
|
+
icon?: JSX.Element | string;
|
|
580
|
+
text?: string;
|
|
581
|
+
boldText?: string;
|
|
582
|
+
};
|
|
583
|
+
width?: string;
|
|
584
|
+
backgroundColor?: string;
|
|
585
|
+
messageStyle?: CSSProperties;
|
|
586
|
+
ellipsis?: boolean;
|
|
587
|
+
}
|
|
588
|
+
type NotificationButton = NonNullable<NotificationOptions['button']>;
|
|
589
|
+
interface CustomNotificationButton extends Omit<NotificationButton, 'action'> {
|
|
590
|
+
action: ({ close }: {
|
|
591
|
+
close: () => void;
|
|
592
|
+
}) => void;
|
|
593
|
+
}
|
|
594
|
+
interface SendNotificationOptions extends Omit<NotificationOptions, 'button'> {
|
|
595
|
+
button?: CustomNotificationButton;
|
|
596
|
+
duration?: number;
|
|
597
|
+
}
|
|
598
|
+
declare const sendNotification: (message: string, options?: SendNotificationOptions) => void;
|
|
599
|
+
interface StreamUIMethods {
|
|
600
|
+
initV2: (options: StreamUIInitOptions) => Promise<void>;
|
|
601
|
+
init: (options: StreamUIInitOptions) => void;
|
|
602
|
+
joinRoom: (token: string, options: StreamUIInitOptions) => Promise<void>;
|
|
603
|
+
setAgentIdentity: typeof streamerClient.setAgentIdentity;
|
|
604
|
+
enableScreenshare: typeof streamerClient.enableScreenshare;
|
|
605
|
+
setExtraSettingsOptions: (extraOptions: SettingsCategory[]) => void;
|
|
606
|
+
sendNotification: typeof sendNotification;
|
|
607
|
+
startRecord: typeof streamerClient.startRecord;
|
|
608
|
+
stopRecord: typeof streamerClient.stopRecord;
|
|
609
|
+
leaveRoom: typeof streamerClient.endCall;
|
|
610
|
+
terminateRoom: typeof streamerClient.terminateRoom;
|
|
611
|
+
generateToken: typeof streamerClient.generateToken;
|
|
612
|
+
addEventListener: typeof streamerClient.addEventListener;
|
|
613
|
+
removeEventListener: typeof streamerClient.removeEventListener;
|
|
614
|
+
dispatchEvent: typeof streamerClient.dispatchEvent;
|
|
615
|
+
getState: typeof streamerClient.getState;
|
|
616
|
+
setProfile: typeof streamerClient.setProfile;
|
|
617
|
+
setConfig: typeof streamerClient.setConfig;
|
|
618
|
+
setLogLevel: (level: number) => void;
|
|
619
|
+
getPermissions: () => Permissions;
|
|
620
|
+
streamerClient: StreamerClient;
|
|
621
|
+
}
|
|
622
|
+
interface ControlSettings {
|
|
623
|
+
available?: boolean;
|
|
624
|
+
enabled?: boolean;
|
|
625
|
+
}
|
|
626
|
+
interface StreamUIBaseOptions {
|
|
627
|
+
token?: string;
|
|
628
|
+
flowToken?: string;
|
|
629
|
+
authKey?: string;
|
|
630
|
+
profile?: Profile;
|
|
631
|
+
apiKey?: string;
|
|
632
|
+
email?: string;
|
|
633
|
+
headless?: boolean;
|
|
634
|
+
greeting?: boolean;
|
|
635
|
+
recorder?: {
|
|
636
|
+
enabledModes: Array<'video' | 'screen' | 'photo' | 'audio'>;
|
|
637
|
+
enabled: boolean;
|
|
638
|
+
defaultMode?: 'photo' | 'video' | 'audio' | 'screen';
|
|
639
|
+
skipOnboarding?: boolean;
|
|
640
|
+
};
|
|
641
|
+
sharedURL?: string;
|
|
642
|
+
audioTiles?: boolean;
|
|
643
|
+
settingsShortcuts?: Array<SettingShortcut>;
|
|
644
|
+
extraSettingsOptions?: SettingsCategory[];
|
|
645
|
+
controls?: {
|
|
646
|
+
microphone?: ControlSettings;
|
|
647
|
+
camera?: ControlSettings;
|
|
648
|
+
screenshare?: ControlSettings;
|
|
649
|
+
};
|
|
650
|
+
logo?: {
|
|
651
|
+
text?: string;
|
|
652
|
+
size?: 'small' | 'medium' | 'large';
|
|
653
|
+
};
|
|
654
|
+
showMenuButton?: boolean;
|
|
655
|
+
GDPRDisclaimer?: {
|
|
656
|
+
enabled: boolean;
|
|
657
|
+
text: string;
|
|
658
|
+
closeText: string;
|
|
659
|
+
};
|
|
660
|
+
streamApiURL?: string;
|
|
661
|
+
apiUrl?: string;
|
|
662
|
+
tracking?: boolean;
|
|
663
|
+
language?: string;
|
|
664
|
+
}
|
|
665
|
+
interface StreamUIInitOptions extends StreamUIBaseOptions {
|
|
666
|
+
element: HTMLElement;
|
|
667
|
+
}
|
|
668
|
+
declare global {
|
|
669
|
+
interface Window {
|
|
670
|
+
streamUI: StreamUIMethods;
|
|
671
|
+
snapcallAPI: {
|
|
672
|
+
endCall: typeof streamerClient.endCall;
|
|
673
|
+
terminateRoom: typeof streamerClient.terminateRoom;
|
|
674
|
+
generateToken: typeof streamerClient.generateToken;
|
|
675
|
+
setDisplayName: typeof streamerClient.setDisplayName;
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
interface MediaSession {
|
|
679
|
+
setMicrophoneActive?: (active: boolean) => void;
|
|
680
|
+
setCameraActive?: (active: boolean) => void;
|
|
681
|
+
setActionHandler(action: MediaSessionAction | 'togglemicrophone' | 'togglecamera' | 'hangup', handler: MediaSessionActionHandler | null): void;
|
|
682
|
+
}
|
|
683
|
+
interface WindowEventMap {
|
|
684
|
+
streamUISetExtraSettingsOptions: CustomEvent;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
declare global {
|
|
688
|
+
interface Window {
|
|
689
|
+
onYouTubeIframeAPIReady: () => void;
|
|
690
|
+
YT?: {
|
|
691
|
+
loaded?: boolean;
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
export const streamUI: StreamUIMethods;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snapcall/stream-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"source": "src/index.tsx",
|
|
6
6
|
"main": "dist/stream-ui.js",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"dev": "npm run serve",
|
|
40
40
|
"serve": "APP_ENV=local parcel serve --https --host 0.0.0.0 --target html",
|
|
41
41
|
"build": "parcel build",
|
|
42
|
-
"build:npm": "parcel build --no-source-maps --target main --target module",
|
|
42
|
+
"build:npm": "parcel build --no-source-maps --target main --target module --target types",
|
|
43
43
|
"build:s3": "parcel build --no-source-maps --target umd --target html",
|
|
44
|
-
"build:streamerClient": "parcel build --target streamerClient",
|
|
44
|
+
"build:streamerClient": "parcel build --target streamerClient --target types",
|
|
45
45
|
"typecheck": "tsc --noEmit",
|
|
46
46
|
"lint": "eslint src streamerClient --ext .ts,.tsx",
|
|
47
47
|
"prettier": "prettier --check .",
|