@myinterview/widget-react 1.0.32 → 1.0.33

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/esm/index.js CHANGED
@@ -27919,7 +27919,7 @@ const StopRecordingButton = ({ onClick, disabled }) => {
27919
27919
  };
27920
27920
 
27921
27921
  const InnerView = React__default.forwardRef(({ widgetMachine, sendToWidget, recorderRef, isSliderModalOpen, isWidgetMinimized, onOpenSliderModal, onCloseSliderModal, onRecorderRetry, onReInitRecorder, }, videoRef) => {
27922
- var _a;
27922
+ var _a, _b;
27923
27923
  const [recorderMachine, sendToRecorder] = useActor(recorderRef);
27924
27924
  const [isQuestionVideoWatched, setIsQuestionVideoWatched] = useState(false);
27925
27925
  const innerRef = useRef(null);
@@ -27936,7 +27936,7 @@ const InnerView = React__default.forwardRef(({ widgetMachine, sendToWidget, reco
27936
27936
  const isRetakeAvailable = currentTake < (currentQuestionObj === null || currentQuestionObj === void 0 ? void 0 : currentQuestionObj.numOfRetakes);
27937
27937
  const totalRetakes = currentQuestionObj === null || currentQuestionObj === void 0 ? void 0 : currentQuestionObj.numOfRetakes;
27938
27938
  const isQuestionMode = recordingType === TAKE_TYPES.QUESTION;
27939
- const lastUnuploadedQuestion = (_a = widgetConfig.video) === null || _a === void 0 ? void 0 : _a.videos.reduce((acc, v, idx) => (!v.uploaded ? idx + 1 : acc), 0);
27939
+ const lastUnuploadedQuestion = (_b = (_a = widgetConfig.video) === null || _a === void 0 ? void 0 : _a.videos) === null || _b === void 0 ? void 0 : _b.reduce((acc, v, idx) => (!v.uploaded ? idx + 1 : acc), 0);
27940
27940
  const isLastQuestion = currentQuestion === (isQuestionMode ? lastUnuploadedQuestion : questions.length);
27941
27941
  const isUploadingState = widgetMachine.matches(STATES$4.UPLOADING);
27942
27942
  const isConfirmState = widgetMachine.matches(STATES$4.CONFIRM);
@@ -30479,6 +30479,7 @@ const Upload = ({ isConnected, totalFileSize, totalUploadedFilesSize, totalUploa
30479
30479
  };
30480
30480
 
30481
30481
  const OuterView = ({ widgetMachine, sendToWidget, recorderRef }) => {
30482
+ var _a;
30482
30483
  const { questions, currentQuestion, widgetConfig: { job, video, company }, recordingType, isConnected, totalFileSize, totalUploadedFilesSize, totalUploadSpeed, } = widgetMachine.context;
30483
30484
  const [recorderMachine] = useActor(recorderRef);
30484
30485
  const { countdown } = recorderMachine.context;
@@ -30492,7 +30493,7 @@ const OuterView = ({ widgetMachine, sendToWidget, recorderRef }) => {
30492
30493
  const isRecording = recorderMachine.matches({ [STATES$5.RECORDING]: STATES$5.COLLECTING_BLOBS });
30493
30494
  const isCountDown = recorderMachine.matches({ [STATES$5.RECORDING]: STATES$5.COUNT_DOWN });
30494
30495
  const isPracticeMode = recordingType === TAKE_TYPES.PRACTICE;
30495
- const questionsStatus = (video === null || video === void 0 ? void 0 : video.videos.map((v, idx) => (v.uploaded || (v.completed && currentQuestion > idx + 1) ? VIDEO_STATUS.COMPLETED : VIDEO_STATUS.INCOMPLETED))) || [];
30496
+ const questionsStatus = ((_a = video === null || video === void 0 ? void 0 : video.videos) === null || _a === void 0 ? void 0 : _a.map((v, idx) => (v.uploaded || (v.completed && currentQuestion > idx + 1) ? VIDEO_STATUS.COMPLETED : VIDEO_STATUS.INCOMPLETED))) || [];
30496
30497
  const outerViewClassNames = classNames({
30497
30498
  'myinterview-widget-outer': true,
30498
30499
  'myinterview-widget-outer--hidden': !isOuterViewDisplayed,
@@ -33100,6 +33101,10 @@ const recorderMachineV2 = createMachine({
33100
33101
  initial: STATES$5.INIT,
33101
33102
  context: initialState,
33102
33103
  entry: [ACTIONS$6.SET_MIC_MACHINE],
33104
+ exit: [
33105
+ ACTIONS$6.STOP_MEDIA_STREAM,
33106
+ ACTIONS$6.STOP_MICROPHONE_MACHINE,
33107
+ ],
33103
33108
  // global events !! THOSE events triggered from all possible states!!!!
33104
33109
  on: {
33105
33110
  // when received info from mic, tell parent , that all good
@@ -33813,7 +33818,7 @@ const accUploaderMachine = createMachine({
33813
33818
  {
33814
33819
  actions: [ACTIONS$2.SET_VIDEO_FILE],
33815
33820
  target: STATES$2.FINISHED,
33816
- cond: (context, event) => event.data.data.data.video.videos[Number(context.currentQuestion) - 1].uploaded,
33821
+ cond: (context, event) => (event.data.data.data.video.videos || [])[Number(context.currentQuestion) - 1].uploaded,
33817
33822
  },
33818
33823
  {
33819
33824
  actions: [ACTIONS$2.SET_VIDEO_FILE],
@@ -33844,9 +33849,12 @@ const accUploaderMachine = createMachine({
33844
33849
  [ACTIONS$2.SET_SIGNED_URL]: assign((_, event) => ({
33845
33850
  signedUrl: event.data.data.data.uploadUrl || '',
33846
33851
  })),
33847
- [ACTIONS$2.SET_VIDEO_FILE]: assign((context, event) => ({
33848
- videoFile: (Object.assign(Object.assign({}, context.videoFile), event.data.data.data.video.videos[Number(context.currentQuestion) - 1])),
33849
- })),
33852
+ [ACTIONS$2.SET_VIDEO_FILE]: assign((context, event) => {
33853
+ var _a;
33854
+ return ({
33855
+ videoFile: (Object.assign(Object.assign({}, context.videoFile), (_a = event.data.data.data.video.videos) === null || _a === void 0 ? void 0 : _a[Number(context.currentQuestion) - 1])),
33856
+ });
33857
+ }),
33850
33858
  [ACTIONS$2.INITIAL_UPLOAD_TIMESTAMP]: assign(({ lastUploadChunk }) => ({ lastUploadChunk: Object.assign(Object.assign({}, lastUploadChunk), { timeStamp: performance.now() }) })),
33851
33859
  // @ts-ignore
33852
33860
  [ACTIONS$2.UPDATE_UPLOAD_SPEED]: assign(({ lastUploadChunk }, { total, loaded, timeStamp }) => ({
@@ -34641,10 +34649,10 @@ const accWidgetMachine = createMachine({
34641
34649
  };
34642
34650
  }),
34643
34651
  [ACTIONS$5.SPAWN_UPLOADER]: assign(({ widgetConfig, uploaderRefs, isConnected, currentQuestion, currentTake, }, event) => {
34644
- var _a, _b;
34652
+ var _a, _b, _c;
34645
34653
  return ({
34646
34654
  uploaderRefs: Object.assign(Object.assign({}, uploaderRefs), { [getUploaderName(currentQuestion)]: spawn(accUploaderMachine.withContext(Object.assign(Object.assign({}, accUploaderMachine.context), { isConnected,
34647
- currentQuestion, file: event.data.file, 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({}, accUploaderMachine.context.videoFile), (_b = widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.video) === null || _b === void 0 ? void 0 : _b.videos[currentQuestion - 1]), { retakes: currentTake, selectedTake: event.data.selectedTake }) })), { name: getUploaderName(currentQuestion), autoForward: true }) }),
34655
+ currentQuestion, file: event.data.file, 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({}, 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 }) })), { name: getUploaderName(currentQuestion), autoForward: true }) }),
34648
34656
  });
34649
34657
  }),
34650
34658
  [ACTIONS$5.STORE_TAKE]: send((context, event) => ({
@@ -34664,9 +34672,9 @@ const accWidgetMachine = createMachine({
34664
34672
  data: event.data,
34665
34673
  }), { to: (context) => context.previewRef }),
34666
34674
  [ACTIONS$5.UPDATE_VIDEO_FILE_COMPLETED]: assign(({ widgetConfig, currentQuestion }) => {
34667
- var _a;
34675
+ var _a, _b;
34668
34676
  return ({
34669
- widgetConfig: Object.assign(Object.assign({}, widgetConfig), { video: Object.assign(Object.assign({}, widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.video), { videos: (_a = widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.video) === null || _a === void 0 ? void 0 : _a.videos.map((video, idx) => (idx !== currentQuestion - 1 ? video : (Object.assign(Object.assign({}, video), { completed: true })))) }) }),
34677
+ widgetConfig: Object.assign(Object.assign({}, widgetConfig), { video: Object.assign(Object.assign({}, widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.video), { videos: (_b = (_a = widgetConfig === null || widgetConfig === void 0 ? void 0 : widgetConfig.video) === null || _a === void 0 ? void 0 : _a.videos) === null || _b === void 0 ? void 0 : _b.map((video, idx) => (idx !== currentQuestion - 1 ? video : (Object.assign(Object.assign({}, video), { completed: true })))) }) }),
34670
34678
  });
34671
34679
  }),
34672
34680
  [ACTIONS$5.UPDATE_TOTAL_FILES_SIZE]: assign(({ totalFileSize }, event) => ({
@@ -34677,9 +34685,9 @@ const accWidgetMachine = createMachine({
34677
34685
  totalUploadSpeed: Object.assign(Object.assign({}, totalUploadSpeed), { [event.data.questionNumber]: event.data.uploadSpeed }),
34678
34686
  })),
34679
34687
  [ACTIONS$5.UPDATE_QUESTION_NUMBER]: assign(({ currentQuestion, questions, widgetConfig, recordingType, }) => {
34680
- var _a, _b;
34688
+ var _a, _b, _c;
34681
34689
  const questionNumberIdx = recordingType === TAKE_TYPES.QUESTION
34682
- ? (_b = (_a = widgetConfig.video) === null || _a === void 0 ? void 0 : _a.videos.findIndex((video, idx) => !video.uploaded && idx > currentQuestion - 1)) !== null && _b !== void 0 ? _b : questions.length
34690
+ ? (_c = (_b = (_a = widgetConfig.video) === null || _a === void 0 ? void 0 : _a.videos) === null || _b === void 0 ? void 0 : _b.findIndex((video, idx) => !video.uploaded && idx > currentQuestion - 1)) !== null && _c !== void 0 ? _c : questions.length
34683
34691
  : Math.min(currentQuestion + 1, questions.length);
34684
34692
  return {
34685
34693
  currentQuestion: Math.min(questionNumberIdx + 1, questions.length || 0),
@@ -34699,9 +34707,9 @@ const accWidgetMachine = createMachine({
34699
34707
  },
34700
34708
  }), { to: (context) => context.recorderRef }),
34701
34709
  [ACTIONS$5.UPDATE_TOTAL_UPLOADED]: assign(({ widgetConfig }, { data: { questionNumber, videoFile } }) => {
34702
- var _a;
34710
+ var _a, _b;
34703
34711
  return ({
34704
- widgetConfig: Object.assign(Object.assign({}, widgetConfig), { video: Object.assign(Object.assign({}, widgetConfig.video), { videos: (_a = widgetConfig.video) === null || _a === void 0 ? void 0 : _a.videos.map((video, idx) => ((idx !== questionNumber - 1) ? video : videoFile)) }) }),
34712
+ widgetConfig: Object.assign(Object.assign({}, widgetConfig), { video: Object.assign(Object.assign({}, widgetConfig.video), { videos: (_b = (_a = widgetConfig.video) === null || _a === void 0 ? void 0 : _a.videos) === null || _b === void 0 ? void 0 : _b.map((video, idx) => ((idx !== questionNumber - 1) ? video : videoFile)) }) }),
34705
34713
  });
34706
34714
  }),
34707
34715
  [ACTIONS$5.SET_VIDEO_ERROR]: assign((_, event) => ({
@@ -34709,9 +34717,9 @@ const accWidgetMachine = createMachine({
34709
34717
  })),
34710
34718
  [ACTIONS$5.REVOKE_MEMORY]: send((_, event) => ({ type: EVENTS$3.REMOVE_TAKES, data: { questionToRemove: event.data.questionNumber } }), { to: ({ storageRef }) => storageRef }),
34711
34719
  [ACTIONS$5.UPDATE_VIDEO_OBJECT]: assign(({ widgetConfig, recordingType }) => {
34712
- var _a;
34720
+ var _a, _b;
34713
34721
  return ({
34714
- widgetConfig: Object.assign(Object.assign({}, widgetConfig), { video: Object.assign(Object.assign({}, widgetConfig.video), { started: recordingType === TAKE_TYPES.QUESTION, completed: !!((_a = widgetConfig.video) === null || _a === void 0 ? void 0 : _a.videos.every((v) => v.completed)) }) }),
34722
+ widgetConfig: Object.assign(Object.assign({}, widgetConfig), { video: Object.assign(Object.assign({}, widgetConfig.video), { started: recordingType === TAKE_TYPES.QUESTION, completed: !!((_b = (_a = widgetConfig.video) === null || _a === void 0 ? void 0 : _a.videos) === null || _b === void 0 ? void 0 : _b.every((v) => v.completed)) }) }),
34715
34723
  });
34716
34724
  }),
34717
34725
  [ACTIONS$5.UPDATE_VIDEO_PART]: assign(({ widgetConfig, recordingType, currentQuestion }, event) => {
@@ -34742,9 +34750,10 @@ const accWidgetMachine = createMachine({
34742
34750
  return updateVideo(Object.assign(Object.assign({}, video), { bandwidth: `${speedTestResult} MB/s` }));
34743
34751
  },
34744
34752
  [SERVICES$1.UPDATE_VIDEO_PART_CALL]: ({ widgetConfig: { video }, recordingType, currentQuestion }) => (callback, onReceive) => {
34753
+ var _a;
34745
34754
  if (recordingType === TAKE_TYPES.PRACTICE)
34746
34755
  return Promise.resolve();
34747
- return updateVideoFile((video === null || video === void 0 ? void 0 : video.video_id) || '', video === null || video === void 0 ? void 0 : video.videos[currentQuestion - 1]);
34756
+ return updateVideoFile((video === null || video === void 0 ? void 0 : video.video_id) || '', (_a = video === null || video === void 0 ? void 0 : video.videos) === null || _a === void 0 ? void 0 : _a[currentQuestion - 1]);
34748
34757
  },
34749
34758
  },
34750
34759
  guards: {
@@ -34755,12 +34764,12 @@ const accWidgetMachine = createMachine({
34755
34764
  [GUARDS$2.IS_QUESTION_MODE]: ({ recordingType }) => recordingType === TAKE_TYPES.QUESTION,
34756
34765
  [GUARDS$2.IS_PRACTICE_MODE]: ({ recordingType }) => recordingType === TAKE_TYPES.PRACTICE,
34757
34766
  [GUARDS$2.IS_NOT_LAST_TAKE]: ({ questions, currentQuestion, currentTake }) => currentTake < questions[currentQuestion - 1].numOfRetakes,
34758
- [GUARDS$2.IS_LAST_INTERVIEW_QUESTION]: ({ widgetConfig, currentQuestion, recordingType }) => { var _a; return recordingType === TAKE_TYPES.QUESTION && (((_a = widgetConfig.video) === null || _a === void 0 ? void 0 : _a.videos.reduce((acc, v, idx) => (!v.uploaded ? idx + 1 : acc), 0)) || 0) === currentQuestion; },
34767
+ [GUARDS$2.IS_LAST_INTERVIEW_QUESTION]: ({ widgetConfig, currentQuestion, recordingType }) => { var _a, _b; return recordingType === TAKE_TYPES.QUESTION && (((_b = (_a = widgetConfig.video) === null || _a === void 0 ? void 0 : _a.videos) === null || _b === void 0 ? void 0 : _b.reduce((acc, v, idx) => (!v.uploaded ? idx + 1 : acc), 0)) || 0) === currentQuestion; },
34759
34768
  [GUARDS$2.CAN_RETEST_SPEED_CONNECTION]: ({ speedTestResult }) => (speedTestResult || 0) < FAST_UPLOAD_SPEED,
34760
34769
  [GUARDS$2.IS_CONNECTED]: ({ isConnected }) => isConnected,
34761
34770
  [GUARDS$2.IS_DISCONNECTED]: ({ isConnected }) => !isConnected,
34762
34771
  [GUARDS$2.CAN_START_INTERVIEW]: ({ checksState }) => checksState.camera === CAMERA_STATES.READY && checksState.microphone === MICROPHONE_STATES.READY && [INTERNET_STATES.CONNECTED, INTERNET_STATES.SLOW_CONNECTION].includes(checksState.internet),
34763
- [GUARDS$2.ARE_ALL_QUESTIONS_UPLOADED]: ({ widgetConfig }) => { var _a; return !!((_a = widgetConfig.video) === null || _a === void 0 ? void 0 : _a.videos.every((video) => video.uploaded)); },
34772
+ [GUARDS$2.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)); },
34764
34773
  [GUARDS$2.SHOULD_SHOW_WELCOME]: ({ widgetConfig }) => !!widgetConfig.config.introVideo,
34765
34774
  [GUARDS$2.IS_NO_SOUND_ERROR]: (_, { data }) => data.code === MICROPHONE_NO_SOUND_ERROR_CODE,
34766
34775
  [GUARDS$2.IS_VIDEO_CORRUPTED]: (_, { data }) => !data.size,
@@ -34921,7 +34930,7 @@ const Main = ({ widgetConfig, setShouldShowWaterMark, isWidgetMinimized, onMinim
34921
34930
  (_b = (_a = widgetConfig.config).onError) === null || _b === void 0 ? void 0 : _b.call(_a, { messageType: 'applied' });
34922
34931
  }
34923
34932
  }, [isErrorState]);
34924
- const isResumed = useMemo(() => { var _a; return !!((_a = widgetConfig.video) === null || _a === void 0 ? void 0 : _a.videos.some((v) => v.uploaded)); }, [widgetConfig.video]);
34933
+ const isResumed = useMemo(() => { var _a, _b; return !!((_b = (_a = widgetConfig.video) === null || _a === void 0 ? void 0 : _a.videos) === null || _b === void 0 ? void 0 : _b.some((v) => v.uploaded)); }, [widgetConfig.video]);
34925
34934
  const handleScroll = (e) => {
34926
34935
  var _a, _b;
34927
34936
  const { scrollTop } = e.target;
@@ -42051,9 +42060,11 @@ const Widget = ({ candidate, job, video, config, disabled = false, buttonText =
42051
42060
  // TODO: Analytics
42052
42061
  };
42053
42062
  const onMinimize = () => {
42063
+ var _a;
42054
42064
  setLayoutStyleProperties();
42055
42065
  revertBodyStyling();
42056
42066
  setIsWidgetMinimized(true);
42067
+ (_a = config.onWidgetClose) === null || _a === void 0 ? void 0 : _a.call(config);
42057
42068
  };
42058
42069
  const layoutClassNames = classNames({
42059
42070
  'myinterview-widget__layout': true,
@@ -42080,7 +42091,7 @@ const Widget = ({ candidate, job, video, config, disabled = false, buttonText =
42080
42091
  React__default.createElement(Main, { widgetConfig: {
42081
42092
  config: Object.assign(Object.assign({}, config), { onFinish: onInterviewCompleted, onError, practiceQuestions: (config.practiceQuestions || []).map((q) => (Object.assign(Object.assign({}, q), { numOfRetakes: q.attempts || DEFAULT_ATTEMPTS, partDuration: q.duration || DEFAULT_DURATION, thinkingTime: q.thinkingTime || DEFAULT_THINKING_TIME }))) }),
42082
42093
  job: Object.assign(Object.assign({}, job), { questions: (job.questions || []).map((q) => (Object.assign(Object.assign({}, q), { numOfRetakes: q.attempts || DEFAULT_ATTEMPTS, partDuration: q.duration || DEFAULT_DURATION, thinkingTime: q.thinkingTime || DEFAULT_THINKING_TIME }))) }),
42083
- video,
42094
+ video: Object.assign(Object.assign({}, video), { referrer: (video === null || video === void 0 ? void 0 : video.referrer) || window.location.href }),
42084
42095
  candidate,
42085
42096
  }, setShouldShowWaterMark: setShouldShowWaterMark, isWidgetMinimized: isWidgetMinimized, onMinimize: onMinimize })))))))));
42086
42097
  };