@snapcall/stream-ui 1.25.1 → 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.
@@ -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: "photo",
11276
+ mode: mode,
11206
11277
  createdAt: createdAt
11207
11278
  });
11208
11279
  openAssetsModal();
11209
11280
  try {
11210
- const dataUrl = await $20431dc869bb21e0$var$fileToDataUrl(file);
11211
- const { url: url, assetId: assetId } = await (0, $c9e496369b59be7a$export$2f377c2162fd02b2).saveCapture(dataUrl);
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: assetId,
11214
- mode: "photo",
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: ".jpg,.JPG,.png,.PNG,.jpeg,.JPEG",
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" : flowStep.type;
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: "photo",
11282
+ mode: mode,
11212
11283
  createdAt: createdAt
11213
11284
  });
11214
11285
  openAssetsModal();
11215
11286
  try {
11216
- const dataUrl = await $ccbd73eb953b0bd0$var$fileToDataUrl(file);
11217
- const { url: url, assetId: assetId } = await (0, $c48c1ecc38fed4e9$export$2f377c2162fd02b2).saveCapture(dataUrl);
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: assetId,
11220
- mode: "photo",
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: ".jpg,.JPG,.png,.PNG,.jpeg,.JPEG",
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" : flowStep.type;
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 CHANGED
@@ -11,7 +11,8 @@ interface Profile {
11
11
  image?: string;
12
12
  }
13
13
  interface Step {
14
- type: 'video' | 'audio' | 'screen' | 'image';
14
+ types: Array<'video' | 'audio' | 'screen' | 'image'>;
15
+ default_type: 'video' | 'audio' | 'screen' | 'image';
15
16
  token: string;
16
17
  title: string;
17
18
  description: string;
@@ -38,6 +39,7 @@ interface FlowV0 {
38
39
  interface InitResult {
39
40
  flow?: Flow;
40
41
  flowV0?: FlowV0;
42
+ videoUpload?: boolean;
41
43
  }
42
44
  interface JoinOptions {
43
45
  languageCode?: string;
@@ -512,6 +514,11 @@ declare class StreamerClient extends StreamerEventTargetType implements AudioLev
512
514
  url: string;
513
515
  assetId: number;
514
516
  }>;
517
+ uploadEvent(file: any): Promise<{
518
+ url?: string;
519
+ id?: number;
520
+ success: boolean;
521
+ }>;
515
522
  deleteCapture(assetId: number): Promise<number>;
516
523
  captureVideo(videoElement?: HTMLVideoElement): Promise<string>;
517
524
  requestLocalVideo(element: HTMLVideoElement): {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapcall/stream-ui",
3
- "version": "1.25.1",
3
+ "version": "1.26.0",
4
4
  "description": "",
5
5
  "source": "src/index.tsx",
6
6
  "main": "dist/stream-ui.js",