@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/esm/index.js
CHANGED
|
@@ -42270,14 +42270,6 @@ const recorderMachineV2 = createMachine({
|
|
|
42270
42270
|
const options = { mimeType, videoBitsPerSecond };
|
|
42271
42271
|
try {
|
|
42272
42272
|
const mediaRecorder = new MediaRecorder(mediaStream, options);
|
|
42273
|
-
// see https://bugs.chromium.org/p/chromium/issues/detail?id=642012
|
|
42274
|
-
const fixVideoMetadata = (rawVideoBlob) => {
|
|
42275
|
-
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
42276
|
-
if (isSafari) {
|
|
42277
|
-
return Promise.resolve(rawVideoBlob);
|
|
42278
|
-
}
|
|
42279
|
-
return fixWebmDuration(rawVideoBlob, Date.now() - (startTime + ((resumeTime - pausedTime) || 0)));
|
|
42280
|
-
};
|
|
42281
42273
|
mediaRecorder.ondataavailable = (event) => {
|
|
42282
42274
|
if (event.data && event.data.size > 0) {
|
|
42283
42275
|
chunks.push(event.data);
|
|
@@ -42287,6 +42279,15 @@ const recorderMachineV2 = createMachine({
|
|
|
42287
42279
|
}
|
|
42288
42280
|
};
|
|
42289
42281
|
mediaRecorder.onstop = () => {
|
|
42282
|
+
const videoLength = Date.now() - (startTime + ((resumeTime - pausedTime) || 0));
|
|
42283
|
+
// see https://bugs.chromium.org/p/chromium/issues/detail?id=642012
|
|
42284
|
+
const fixVideoMetadata = (rawVideoBlob) => {
|
|
42285
|
+
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
42286
|
+
if (isSafari) {
|
|
42287
|
+
return Promise.resolve(rawVideoBlob);
|
|
42288
|
+
}
|
|
42289
|
+
return fixWebmDuration(rawVideoBlob, videoLength, { logger: false });
|
|
42290
|
+
};
|
|
42290
42291
|
const superBuffer = new Blob(chunks, {
|
|
42291
42292
|
type: mimeType,
|
|
42292
42293
|
});
|
|
@@ -42298,7 +42299,7 @@ const recorderMachineV2 = createMachine({
|
|
|
42298
42299
|
const webm = new File([blob], Date.now().toString(), {
|
|
42299
42300
|
type: mimeType,
|
|
42300
42301
|
});
|
|
42301
|
-
callback({ type: 'SEND_CURRENT_TAKE', data: webm });
|
|
42302
|
+
callback({ type: 'SEND_CURRENT_TAKE', data: { webm, videoLength } });
|
|
42302
42303
|
})
|
|
42303
42304
|
.catch((error) => {
|
|
42304
42305
|
console.error('fixVideoMetadata', error);
|
|
@@ -42766,10 +42767,11 @@ const storageMachine = createMachine({
|
|
|
42766
42767
|
actions: {
|
|
42767
42768
|
[ACTIONS$5.CONSOLE_LOG]: (context, event) => console.log('Storage Machine', context, event),
|
|
42768
42769
|
[ACTIONS$5.STORE_TAKE]: assign((context, event) => {
|
|
42769
|
-
const { takeType, currentQuestion = 0, take } = event.data;
|
|
42770
|
+
const { takeType, currentQuestion = 0, take, videoLength } = event.data;
|
|
42770
42771
|
const objectToSave = {
|
|
42771
42772
|
file: take,
|
|
42772
42773
|
objectUrl: URL.createObjectURL(take),
|
|
42774
|
+
videoLength,
|
|
42773
42775
|
};
|
|
42774
42776
|
const fieldName = takeType === TAKE_TYPES.QUESTION ? 'questions' : 'practice';
|
|
42775
42777
|
return {
|
|
@@ -42780,6 +42782,7 @@ const storageMachine = createMachine({
|
|
|
42780
42782
|
type: EVENTS$5.TAKE_TO_UPLOAD_RECEIVED,
|
|
42781
42783
|
data: {
|
|
42782
42784
|
file: context.questions[data.currentQuestion][data.selectedTake - 1].file,
|
|
42785
|
+
videoLength: context.questions[data.currentQuestion][data.selectedTake - 1].videoLength,
|
|
42783
42786
|
selectedTake: data.selectedTake,
|
|
42784
42787
|
},
|
|
42785
42788
|
})),
|
|
@@ -43578,7 +43581,7 @@ const accWidgetMachine = createMachine({
|
|
|
43578
43581
|
var _a, _b, _c;
|
|
43579
43582
|
return ({
|
|
43580
43583
|
uploaderRefs: Object.assign(Object.assign({}, uploaderRefs), { [getUploaderName(currentQuestion)]: spawn(accUploaderMachine.withContext(Object.assign(Object.assign({}, accUploaderMachine.context), { isConnected,
|
|
43581
|
-
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 }) }),
|
|
43584
|
+
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 }) }),
|
|
43582
43585
|
});
|
|
43583
43586
|
}),
|
|
43584
43587
|
[ACTIONS$6.SPAWN_COUNT_DOWN]: assign({
|
|
@@ -43592,7 +43595,12 @@ const accWidgetMachine = createMachine({
|
|
|
43592
43595
|
}),
|
|
43593
43596
|
[ACTIONS$6.STORE_TAKE]: send((context, event) => ({
|
|
43594
43597
|
type: EVENTS$4.STORE_TAKE,
|
|
43595
|
-
data: {
|
|
43598
|
+
data: {
|
|
43599
|
+
takeType: context.recordingType,
|
|
43600
|
+
currentQuestion: context.currentQuestion,
|
|
43601
|
+
take: event.data.webm,
|
|
43602
|
+
videoLength: (event.data.videoLength || 0) / 1000, // convert videoLength from miliseconds to seconds
|
|
43603
|
+
},
|
|
43596
43604
|
}), { to: (context) => context.storageRef }),
|
|
43597
43605
|
[ACTIONS$6.GET_TAKE]: send(({ currentQuestion }, event) => ({
|
|
43598
43606
|
type: EVENTS$4.GET_TAKE,
|
|
@@ -43722,7 +43730,7 @@ const accWidgetMachine = createMachine({
|
|
|
43722
43730
|
[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)); },
|
|
43723
43731
|
[GUARDS$3.SHOULD_SHOW_WELCOME]: ({ widgetConfig }) => !!widgetConfig.config.introVideo || !!widgetConfig.config.welcomeTitle || !!widgetConfig.config.welcomeText,
|
|
43724
43732
|
[GUARDS$3.IS_NO_SOUND_ERROR]: (_, { data }) => data.code === MICROPHONE_NO_SOUND_ERROR_CODE,
|
|
43725
|
-
[GUARDS$3.IS_VIDEO_CORRUPTED]: (_, { data }) => !data.size,
|
|
43733
|
+
[GUARDS$3.IS_VIDEO_CORRUPTED]: (_, { data }) => !data.webm.size,
|
|
43726
43734
|
[GUARDS$3.IS_AUDIO_ERROR]: (_, { data }) => data.type === TYPES_EXPLANATION.AUDIO || data.type === TYPES_EXPLANATION.VIDEO_AUDIO,
|
|
43727
43735
|
[GUARDS$3.IS_VIDEO_ERROR]: (_, { data }) => data.type === TYPES_EXPLANATION.VIDEO || data.type === TYPES_EXPLANATION.VIDEO_AUDIO,
|
|
43728
43736
|
[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)); },
|