@myinterview/widget-react 1.1.6 → 1.1.7

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/cjs/index.js CHANGED
@@ -42296,14 +42296,6 @@ const recorderMachineV2 = createMachine({
42296
42296
  const options = { mimeType, videoBitsPerSecond };
42297
42297
  try {
42298
42298
  const mediaRecorder = new MediaRecorder(mediaStream, options);
42299
- // see https://bugs.chromium.org/p/chromium/issues/detail?id=642012
42300
- const fixVideoMetadata = (rawVideoBlob) => {
42301
- const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
42302
- if (isSafari) {
42303
- return Promise.resolve(rawVideoBlob);
42304
- }
42305
- return fixWebmDuration(rawVideoBlob, Date.now() - (startTime + ((resumeTime - pausedTime) || 0)));
42306
- };
42307
42299
  mediaRecorder.ondataavailable = (event) => {
42308
42300
  if (event.data && event.data.size > 0) {
42309
42301
  chunks.push(event.data);
@@ -42313,6 +42305,15 @@ const recorderMachineV2 = createMachine({
42313
42305
  }
42314
42306
  };
42315
42307
  mediaRecorder.onstop = () => {
42308
+ const videoLength = Date.now() - (startTime + ((resumeTime - pausedTime) || 0));
42309
+ // see https://bugs.chromium.org/p/chromium/issues/detail?id=642012
42310
+ const fixVideoMetadata = (rawVideoBlob) => {
42311
+ const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
42312
+ if (isSafari) {
42313
+ return Promise.resolve(rawVideoBlob);
42314
+ }
42315
+ return fixWebmDuration(rawVideoBlob, videoLength, { logger: false });
42316
+ };
42316
42317
  const superBuffer = new Blob(chunks, {
42317
42318
  type: mimeType,
42318
42319
  });
@@ -42324,7 +42325,7 @@ const recorderMachineV2 = createMachine({
42324
42325
  const webm = new File([blob], Date.now().toString(), {
42325
42326
  type: mimeType,
42326
42327
  });
42327
- callback({ type: 'SEND_CURRENT_TAKE', data: webm });
42328
+ callback({ type: 'SEND_CURRENT_TAKE', data: { webm, videoLength } });
42328
42329
  })
42329
42330
  .catch((error) => {
42330
42331
  console.error('fixVideoMetadata', error);
@@ -42792,10 +42793,11 @@ const storageMachine = createMachine({
42792
42793
  actions: {
42793
42794
  [ACTIONS$5.CONSOLE_LOG]: (context, event) => console.log('Storage Machine', context, event),
42794
42795
  [ACTIONS$5.STORE_TAKE]: assign((context, event) => {
42795
- const { takeType, currentQuestion = 0, take } = event.data;
42796
+ const { takeType, currentQuestion = 0, take, videoLength } = event.data;
42796
42797
  const objectToSave = {
42797
42798
  file: take,
42798
42799
  objectUrl: URL.createObjectURL(take),
42800
+ videoLength,
42799
42801
  };
42800
42802
  const fieldName = takeType === TAKE_TYPES.QUESTION ? 'questions' : 'practice';
42801
42803
  return {
@@ -42806,6 +42808,7 @@ const storageMachine = createMachine({
42806
42808
  type: EVENTS$5.TAKE_TO_UPLOAD_RECEIVED,
42807
42809
  data: {
42808
42810
  file: context.questions[data.currentQuestion][data.selectedTake - 1].file,
42811
+ videoLength: context.questions[data.currentQuestion][data.selectedTake - 1].videoLength,
42809
42812
  selectedTake: data.selectedTake,
42810
42813
  },
42811
42814
  })),
@@ -43604,7 +43607,7 @@ const accWidgetMachine = createMachine({
43604
43607
  var _a, _b, _c;
43605
43608
  return ({
43606
43609
  uploaderRefs: Object.assign(Object.assign({}, uploaderRefs), { [getUploaderName(currentQuestion)]: spawn(accUploaderMachine.withContext(Object.assign(Object.assign({}, accUploaderMachine.context), { isConnected,
43607
- currentQuestion, file: event.data.file || null, videoId: ((_a = widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.video) === null || _a === void 0 ? void 0 : _a.video_id) || '', videoFile: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, accUploaderMachine.context.videoFile), (_c = (_b = widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.video) === null || _b === void 0 ? void 0 : _b.videos) === null || _c === void 0 ? void 0 : _c[currentQuestion - 1]), { retakes: currentTake, selectedTake: event.data.selectedTake || 0 }), (event.data.answer && { answer: event.data.answer })), { originalDimensions: videoDimensions }) })), { name: getUploaderName(currentQuestion), autoForward: true }) }),
43610
+ currentQuestion, file: event.data.file || null, videoId: ((_a = widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.video) === null || _a === void 0 ? void 0 : _a.video_id) || '', videoFile: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, accUploaderMachine.context.videoFile), (_c = (_b = widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.video) === null || _b === void 0 ? void 0 : _b.videos) === null || _c === void 0 ? void 0 : _c[currentQuestion - 1]), { retakes: currentTake, selectedTake: event.data.selectedTake || 0 }), (event.data.answer && { answer: event.data.answer })), (event.data.videoLength && { videoLength: event.data.videoLength })), { originalDimensions: videoDimensions }) })), { name: getUploaderName(currentQuestion), autoForward: true }) }),
43608
43611
  });
43609
43612
  }),
43610
43613
  [ACTIONS$6.SPAWN_COUNT_DOWN]: assign({
@@ -43618,7 +43621,12 @@ const accWidgetMachine = createMachine({
43618
43621
  }),
43619
43622
  [ACTIONS$6.STORE_TAKE]: send((context, event) => ({
43620
43623
  type: EVENTS$4.STORE_TAKE,
43621
- data: { takeType: context.recordingType, currentQuestion: context.currentQuestion, take: event.data },
43624
+ data: {
43625
+ takeType: context.recordingType,
43626
+ currentQuestion: context.currentQuestion,
43627
+ take: event.data.webm,
43628
+ videoLength: (event.data.videoLength || 0) / 1000, // convert videoLength from miliseconds to seconds
43629
+ },
43622
43630
  }), { to: (context) => context.storageRef }),
43623
43631
  [ACTIONS$6.GET_TAKE]: send(({ currentQuestion }, event) => ({
43624
43632
  type: EVENTS$4.GET_TAKE,
@@ -43748,7 +43756,7 @@ const accWidgetMachine = createMachine({
43748
43756
  [GUARDS$3.ARE_ALL_QUESTIONS_UPLOADED]: ({ widgetConfig }) => { var _a, _b; return !!((_b = (_a = widgetConfig.video) === null || _a === void 0 ? void 0 : _a.videos) === null || _b === void 0 ? void 0 : _b.every((video) => video.uploaded)); },
43749
43757
  [GUARDS$3.SHOULD_SHOW_WELCOME]: ({ widgetConfig }) => !!widgetConfig.config.introVideo || !!widgetConfig.config.welcomeTitle || !!widgetConfig.config.welcomeText,
43750
43758
  [GUARDS$3.IS_NO_SOUND_ERROR]: (_, { data }) => data.code === MICROPHONE_NO_SOUND_ERROR_CODE,
43751
- [GUARDS$3.IS_VIDEO_CORRUPTED]: (_, { data }) => !data.size,
43759
+ [GUARDS$3.IS_VIDEO_CORRUPTED]: (_, { data }) => !data.webm.size,
43752
43760
  [GUARDS$3.IS_AUDIO_ERROR]: (_, { data }) => data.type === TYPES_EXPLANATION.AUDIO || data.type === TYPES_EXPLANATION.VIDEO_AUDIO,
43753
43761
  [GUARDS$3.IS_VIDEO_ERROR]: (_, { data }) => data.type === TYPES_EXPLANATION.VIDEO || data.type === TYPES_EXPLANATION.VIDEO_AUDIO,
43754
43762
  [GUARDS$3.THERE_ARE_NO_VIDEO_QUESTIONS_TYPE]: ({ widgetConfig }) => { var _a, _b; return !!((_b = (_a = widgetConfig.job) === null || _a === void 0 ? void 0 : _a.questions) === null || _b === void 0 ? void 0 : _b.every((q) => q.answerType && q.answerType !== ANSWER_TYPES.VIDEO)); },