@myinterview/widget-react 1.0.3 → 1.0.5

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/README.md CHANGED
@@ -27,7 +27,7 @@ import React from 'react';
27
27
  import { Widget } from '@myinterview/widget-react';
28
28
 
29
29
  const App = () => {
30
- const onCompleteCallback = () => {
30
+ const onFinish = () => {
31
31
  //...
32
32
  }
33
33
  const onError = () => {
@@ -38,7 +38,7 @@ const App = () => {
38
38
  <Widget
39
39
  job={{ job_id: "xxxxxxxxxxxxxxxxxx" }}
40
40
  candidate={{ email: "test@mail.com", username: "Max" }}
41
- config={{ onCompleteCallback, onError,
41
+ config={{ onFinish, onError,
42
42
  auth: "apikey xxxxxxxxxxxxxxxxx sig=xxxxxxxxxxxxxxxxxxxxxxxxxx" }}
43
43
  />
44
44
  )
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { IWidgetConfig } from '../interfaces/configInterface';
2
+ import { IClientWidgetConfig } from '../interfaces/configInterface';
3
3
  import '../assets/styles/global.scss';
4
4
  import { getToken } from '../utils/authToken.utils';
5
- export declare const Widget: React.FC<IWidgetConfig>;
5
+ export declare const Widget: React.FC<IClientWidgetConfig>;
6
6
  export { getToken };
@@ -1,4 +1,5 @@
1
- declare let config: {
1
+ import { IEnv } from '../interfaces/configInterface';
2
+ declare const config: (configEnv?: IEnv) => {
2
3
  serverUrl: string;
3
4
  INTERCOM_APP_ID: string;
4
5
  SENTRY_DSN: string;
package/dist/esm/index.js CHANGED
@@ -20979,29 +20979,23 @@ const prod_config = {
20979
20979
  };
20980
20980
 
20981
20981
  // eslint-disable-next-line import/no-mutable-exports
20982
- let config = prod_config;
20983
- switch (process.env.REACT_APP_ENV) {
20984
- case 'development':
20985
- case 'dev':
20986
- case 'local':
20987
- config = local_config;
20988
- break;
20989
- case 'staging':
20990
- config = staging_config;
20991
- break;
20992
- case 'production':
20993
- case 'prod':
20994
- config = prod_config;
20995
- break;
20996
- default:
20997
- console.log('Running in prod mode by default');
20998
- }
20999
- var configFile = config;
20982
+ const config = (configEnv) => {
20983
+ switch (configEnv || process.env.REACT_APP_ENV) {
20984
+ case 'development':
20985
+ case 'dev':
20986
+ case 'local':
20987
+ return local_config;
20988
+ case 'staging':
20989
+ return staging_config;
20990
+ default:
20991
+ return prod_config;
20992
+ }
20993
+ };
21000
20994
 
21001
20995
  const client = new BrowserClient({
21002
20996
  transport: makeFetchTransport,
21003
20997
  stackParser: defaultStackParser,
21004
- dsn: configFile.SENTRY_DSN,
20998
+ dsn: config().SENTRY_DSN,
21005
20999
  integrations: [...defaultIntegrations],
21006
21000
  });
21007
21001
  const SentryHub = new Hub(client);
@@ -28128,7 +28122,9 @@ const VideoTimeBar = ({ duration, currentTime, isThinkingTime, onChangeTime, })
28128
28122
 
28129
28123
  const DEFAULT_COUNT_DOWN = 3; // seconds
28130
28124
  const DEFAULT_DURATION = 60; // seconds
28131
- const ENOUGH_RECODING_TIME = 3; // seconds
28125
+ const DEFAULT_ATTEMPTS = 3; // number of attempts
28126
+ const DEFAULT_THINKING_TIME = 0; // seconds
28127
+ const ENOUGH_RECORDING_TIME = 3; // seconds
28132
28128
  const SPEED_TEST_FILE_SIZE = 5; // MB
28133
28129
  const FAST_UPLOAD_SPEED = 0.35; // MB/s
28134
28130
  const SLOW_UPLOAD_SPEED = 0.1; // MB/s
@@ -28390,10 +28386,10 @@ const InnerView = React__default.forwardRef(({ widgetMachine, sendToWidget, reco
28390
28386
  previewRef && isPreviewState && (React__default.createElement(PreviewList, { previewRef: previewRef, onNextQuestion: onNextQuestion, onNextRetake: onNextRetake, onQuestionMode: onQuestionMode, isRetakeAvailable: isRetakeAvailable, totalRetakes: totalRetakes, isQuestionMode: isQuestionMode, isLastQuestion: isLastQuestion, isConnected: isConnected, currentQuestion: currentQuestion, numberOfQuestions: questions.length })),
28391
28387
  canStartRecording && (React__default.createElement(StartRecordingButton, { onClick: () => sendToWidget(EVENTS$4.NEXT_STEP), disabled: !!(currentQuestionObj === null || currentQuestionObj === void 0 ? void 0 : currentQuestionObj.videoQuestion) && !isQuestionVideoWatched && isVideoQuestionState, isExplanationState: isExplanationState, isVideoQuestionState: isVideoQuestionState, isVideoQuestion: !!(currentQuestionObj === null || currentQuestionObj === void 0 ? void 0 : currentQuestionObj.videoQuestion) })),
28392
28388
  isCountDown && countdown > DEFAULT_COUNT_DOWN && (React__default.createElement(StartNowButton, { onClick: () => sendToRecorder(RECORDER_EVENTS.FORCE_START) })),
28393
- (isRecording && !RecorderError) && (React__default.createElement(StopRecordingButton, { onClick: () => sendToRecorder(RECORDER_EVENTS.STOP_RECORDING), disabled: recordingTime < ENOUGH_RECODING_TIME })))),
28389
+ (isRecording && !RecorderError) && (React__default.createElement(StopRecordingButton, { onClick: () => sendToRecorder(RECORDER_EVENTS.STOP_RECORDING), disabled: recordingTime < ENOUGH_RECORDING_TIME })))),
28394
28390
  canStartRecording && (React__default.createElement(StartRecordingButton, { onClick: () => sendToWidget(EVENTS$4.NEXT_STEP), disabled: !!(currentQuestionObj === null || currentQuestionObj === void 0 ? void 0 : currentQuestionObj.videoQuestion) && !isQuestionVideoWatched && isVideoQuestionState, isExplanationState: isExplanationState, isVideoQuestionState: isVideoQuestionState, isVideoQuestion: !!(currentQuestionObj === null || currentQuestionObj === void 0 ? void 0 : currentQuestionObj.videoQuestion) })),
28395
28391
  isCountDown && countdown > DEFAULT_COUNT_DOWN && (React__default.createElement(StartNowButton, { onClick: () => sendToRecorder(RECORDER_EVENTS.FORCE_START) })),
28396
- isRecording && (React__default.createElement(StopRecordingButton, { onClick: () => sendToRecorder(RECORDER_EVENTS.STOP_RECORDING), disabled: recordingTime < ENOUGH_RECODING_TIME }))));
28392
+ isRecording && (React__default.createElement(StopRecordingButton, { onClick: () => sendToRecorder(RECORDER_EVENTS.STOP_RECORDING), disabled: recordingTime < ENOUGH_RECORDING_TIME }))));
28397
28393
  });
28398
28394
 
28399
28395
  var VIDEO_STATUS;
@@ -30769,13 +30765,16 @@ axios$2.exports.default = axios$1;
30769
30765
  var axios = /*@__PURE__*/getDefaultExportFromCjs(axios$3.exports);
30770
30766
 
30771
30767
  const videoAxiosInstance = axios.create({
30772
- baseURL: configFile.serverUrl,
30768
+ baseURL: config().serverUrl,
30773
30769
  withCredentials: true,
30774
30770
  });
30775
30771
  const s3AxiosInstance = axios.create({});
30776
30772
  const updateVideoAxiosAuth = (auth) => {
30777
30773
  videoAxiosInstance.defaults.headers.common.Authorization = auth;
30778
30774
  };
30775
+ const updateVideoAxiosBaseURL = (url) => {
30776
+ videoAxiosInstance.defaults.baseURL = url;
30777
+ };
30779
30778
 
30780
30779
  const uploadToS3 = (url, data, onProgress, timeout = 0) => s3AxiosInstance.put(url, data, {
30781
30780
  headers: { 'Content-Type': 'video/webm' }, onUploadProgress: onProgress, timeout,
@@ -31956,7 +31955,7 @@ const recorderMachineV2 = createMachine({
31956
31955
  on: {
31957
31956
  [RECORDER_EVENTS.RETRY]: {
31958
31957
  target: [STATES$5.INIT],
31959
- actions: [ACTIONS$6.RESET],
31958
+ actions: [ACTIONS$6.STOP_MIC, ACTIONS$6.RESET],
31960
31959
  },
31961
31960
  },
31962
31961
  },
@@ -32074,8 +32073,7 @@ const recorderMachineV2 = createMachine({
32074
32073
  };
32075
32074
  mediaRecorder.start(10000);
32076
32075
  callback({ type: RECORDER_EVENTS.INIT_RECORDER, data: mediaRecorder });
32077
- if (context.isMicError)
32078
- callback(RECORDER_EVENTS.PAUSE);
32076
+ // if (context.isMicError) callback(RECORDER_EVENTS.PAUSE); its not gonna work , until we will fix staging
32079
32077
  return () => {
32080
32078
  // if (mediaRecorder?.state !== 'inactive') mediaRecorder?.stop();
32081
32079
  };
@@ -32134,7 +32132,7 @@ const recorderMachineV2 = createMachine({
32134
32132
  durations: (_, event) => event.data.duration,
32135
32133
  }),
32136
32134
  [ACTIONS$6.CLEAN]: assign((context, event) => (Object.assign(Object.assign({}, initialState), { selectedAudioDevice: context.selectedAudioDevice, selectedVideoDevice: context.selectedVideoDevice, videoRef: context.videoRef, microphoneRef: context.microphoneRef, facingMode: context.facingMode, autoStart: event.data.autoStart || context.autoStart }))),
32137
- [ACTIONS$6.RESET]: assign((context) => (Object.assign(Object.assign({}, initialState), { videoRef: context.videoRef }))),
32135
+ [ACTIONS$6.RESET]: assign((context) => (Object.assign(Object.assign({}, initialState), { videoRef: context.videoRef, microphoneRef: context.microphoneRef }))),
32138
32136
  [ACTIONS$6.SET_MEDIA_STREAM]: assign({
32139
32137
  selectedVideoDevice: (_, event) => event.data.selectedVideoDevice,
32140
32138
  selectedAudioDevice: (_, event) => event.data.selectedAudioDevice,
@@ -33110,7 +33108,7 @@ const accWidgetMachine = createMachine({
33110
33108
  company_id: (_d = context.widgetConfig.job) === null || _d === void 0 ? void 0 : _d.company_id,
33111
33109
  apiKey: (_e = context.widgetConfig.job) === null || _e === void 0 ? void 0 : _e.apiKey,
33112
33110
  widget_shown: new Date(),
33113
- }, configFile.serverUrl).then(() => { });
33111
+ }, config(context.widgetConfig.config.env).serverUrl).then(() => { });
33114
33112
  },
33115
33113
  [ACTIONS$5.SENTRY]: (context, event, meta) => { var _a; return SentryTrackingFn(event, context, ((_a = meta.action.data) === null || _a === void 0 ? void 0 : _a.eventName) || 'accWidgetMachine'); },
33116
33114
  [ACTIONS$5.CONSOLE_LOG]: (context, event, meta) => console.log('%c [WidgetMachine]', CONSOLE_LOG_STYLE, context, event, meta),
@@ -33403,7 +33401,7 @@ const Main = ({ widgetConfig, setShouldShowWaterMark }) => {
33403
33401
  useEffect(() => {
33404
33402
  var _a, _b;
33405
33403
  if (machine.done) {
33406
- (_b = (_a = widgetConfig.config).onCompleteCallback) === null || _b === void 0 ? void 0 : _b.call(_a, { redirectUrl: candidate.redirectUrl, video_id: (video === null || video === void 0 ? void 0 : video.video_id) || '' });
33404
+ (_b = (_a = widgetConfig.config).onFinish) === null || _b === void 0 ? void 0 : _b.call(_a, { redirectUrl: candidate.redirectUrl, video_id: (video === null || video === void 0 ? void 0 : video.video_id) || '' });
33407
33405
  }
33408
33406
  }, [machine.done]);
33409
33407
  useEffect(() => {
@@ -40479,7 +40477,7 @@ var Crypto = cryptoJs.exports;
40479
40477
 
40480
40478
  const getToken = ({ type = 'apikey', value = '', secretKey = '' }) => `${type} ${value} sig=${Crypto.HmacSHA256(`${type + value}sig=`, secretKey).toString()}`;
40481
40479
 
40482
- const Widget = ({ candidate, job, video, config, disabled = false, buttonText = 'START INTERVIEW', buttonStyle = {}, }) => {
40480
+ const Widget = ({ candidate, job, video, config: config$1, disabled = false, buttonText = 'START INTERVIEW', buttonStyle = {}, }) => {
40483
40481
  const [isWidgetOpen, setIsWidgetOpen] = useState(false);
40484
40482
  const [isIncognitoMode, setIsIncognitoMode] = useState(false);
40485
40483
  const myinterviewRef = useRef(null);
@@ -40498,6 +40496,9 @@ const Widget = ({ candidate, job, video, config, disabled = false, buttonText =
40498
40496
  });
40499
40497
  });
40500
40498
  }, [candidate.email]);
40499
+ useEffect(() => {
40500
+ updateVideoAxiosBaseURL(config(config$1.env).serverUrl);
40501
+ }, [config$1.env]);
40501
40502
  const setLayoutStyleProperties = () => {
40502
40503
  if (myinterviewRef.current) {
40503
40504
  const { x, y, width, height, } = myinterviewRef.current.getBoundingClientRect();
@@ -40505,9 +40506,9 @@ const Widget = ({ candidate, job, video, config, disabled = false, buttonText =
40505
40506
  myinterviewRef.current.style.setProperty('--myinterview-widget-layout-right', `${window.innerWidth - x - width}px`);
40506
40507
  myinterviewRef.current.style.setProperty('--myinterview-widget-layout-bottom', `${window.innerHeight - y - height}px`);
40507
40508
  myinterviewRef.current.style.setProperty('--myinterview-widget-layout-left', `${x}px`);
40508
- if (config.overlay) {
40509
- myinterviewRef.current.style.setProperty('--color-primary', config.overlay);
40510
- myinterviewRef.current.style.setProperty('--color-special', config.overlay);
40509
+ if (config$1.overlay) {
40510
+ myinterviewRef.current.style.setProperty('--color-primary', config$1.overlay);
40511
+ myinterviewRef.current.style.setProperty('--color-special', config$1.overlay);
40511
40512
  }
40512
40513
  }
40513
40514
  };
@@ -40518,18 +40519,18 @@ const Widget = ({ candidate, job, video, config, disabled = false, buttonText =
40518
40519
  };
40519
40520
  const onInterviewCompleted = (data) => {
40520
40521
  var _a;
40521
- (_a = config.onCompleteCallback) === null || _a === void 0 ? void 0 : _a.call(config, data);
40522
+ (_a = config$1.onFinish) === null || _a === void 0 ? void 0 : _a.call(config$1, data);
40522
40523
  onCloseWidget();
40523
40524
  };
40524
40525
  const onError = (data) => {
40525
40526
  var _a;
40526
- (_a = config.onError) === null || _a === void 0 ? void 0 : _a.call(config, data);
40527
+ (_a = config$1.onError) === null || _a === void 0 ? void 0 : _a.call(config$1, data);
40527
40528
  onCloseWidget();
40528
40529
  };
40529
40530
  const openWidget = () => {
40530
40531
  var _a;
40531
- (_a = config.onWidgetClicked) === null || _a === void 0 ? void 0 : _a.call(config);
40532
- if (![candidate.username, candidate.email, config.auth].every(Boolean))
40532
+ (_a = config$1.onWidgetClicked) === null || _a === void 0 ? void 0 : _a.call(config$1);
40533
+ if (![candidate.username, candidate.email, config$1.auth].every(Boolean))
40533
40534
  return;
40534
40535
  setLayoutStyleProperties();
40535
40536
  document.body.style.maxHeight = '100vh';
@@ -40540,10 +40541,10 @@ const Widget = ({ candidate, job, video, config, disabled = false, buttonText =
40540
40541
  const layoutClassNames = classNames({
40541
40542
  'myinterview-widget__layout': true,
40542
40543
  'myinterview-widget-no-select': true,
40543
- 'myinterview-widget__layout--animated': isWidgetOpen && !!config.openAnimation,
40544
+ 'myinterview-widget__layout--animated': isWidgetOpen && !!config$1.openAnimation,
40544
40545
  });
40545
40546
  return (React__default.createElement(ErrorBoundary, null,
40546
- React__default.createElement(IntercomProvider, { appId: configFile.INTERCOM_APP_ID },
40547
+ React__default.createElement(IntercomProvider, { appId: config(config$1.env).INTERCOM_APP_ID },
40547
40548
  React__default.createElement("div", { ref: myinterviewRef, className: "myinterview-widget" },
40548
40549
  React__default.createElement(Button, { className: "myinterview-widget__button", onClick: openWidget, disabled: disabled, style: buttonStyle }, buttonText),
40549
40550
  isWidgetOpen && (React__default.createElement("div", { className: layoutClassNames },
@@ -40555,8 +40556,8 @@ const Widget = ({ candidate, job, video, config, disabled = false, buttonText =
40555
40556
  (!isSupportedDevice || isIncognitoMode) && React__default.createElement(UnsupportedModal, { messageType: !isSupportedIosDevice ? 'IOS' : !isSupportedDevice ? 'BROWSER' : 'INCOGNITO' }),
40556
40557
  isSupportedDevice && (React__default.createElement("div", { className: "myinterview-widget__wrapper" },
40557
40558
  React__default.createElement(Main, { widgetConfig: {
40558
- config: Object.assign(Object.assign({}, config), { onCompleteCallback: onInterviewCompleted, onError }),
40559
- job,
40559
+ config: Object.assign(Object.assign({}, config$1), { onFinish: onInterviewCompleted, onError, practiceQuestions: config$1.practiceQuestions.map((q) => (Object.assign(Object.assign({}, q), { numOfRetakes: q.attempts || DEFAULT_ATTEMPTS, partDuration: q.duration || DEFAULT_DURATION, thinkingTime: q.thinkingTime || DEFAULT_THINKING_TIME }))) }),
40560
+ 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 }))) }),
40560
40561
  video,
40561
40562
  candidate,
40562
40563
  }, setShouldShowWaterMark: setShouldShowWaterMark })))))))));