@myinterview/widget-react 1.0.3 → 1.0.4

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.
@@ -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);
@@ -30769,13 +30763,16 @@ axios$2.exports.default = axios$1;
30769
30763
  var axios = /*@__PURE__*/getDefaultExportFromCjs(axios$3.exports);
30770
30764
 
30771
30765
  const videoAxiosInstance = axios.create({
30772
- baseURL: configFile.serverUrl,
30766
+ baseURL: config().serverUrl,
30773
30767
  withCredentials: true,
30774
30768
  });
30775
30769
  const s3AxiosInstance = axios.create({});
30776
30770
  const updateVideoAxiosAuth = (auth) => {
30777
30771
  videoAxiosInstance.defaults.headers.common.Authorization = auth;
30778
30772
  };
30773
+ const updateVideoAxiosBaseURL = (url) => {
30774
+ videoAxiosInstance.defaults.baseURL = url;
30775
+ };
30779
30776
 
30780
30777
  const uploadToS3 = (url, data, onProgress, timeout = 0) => s3AxiosInstance.put(url, data, {
30781
30778
  headers: { 'Content-Type': 'video/webm' }, onUploadProgress: onProgress, timeout,
@@ -31956,7 +31953,7 @@ const recorderMachineV2 = createMachine({
31956
31953
  on: {
31957
31954
  [RECORDER_EVENTS.RETRY]: {
31958
31955
  target: [STATES$5.INIT],
31959
- actions: [ACTIONS$6.RESET],
31956
+ actions: [ACTIONS$6.STOP_MIC, ACTIONS$6.RESET],
31960
31957
  },
31961
31958
  },
31962
31959
  },
@@ -32074,8 +32071,7 @@ const recorderMachineV2 = createMachine({
32074
32071
  };
32075
32072
  mediaRecorder.start(10000);
32076
32073
  callback({ type: RECORDER_EVENTS.INIT_RECORDER, data: mediaRecorder });
32077
- if (context.isMicError)
32078
- callback(RECORDER_EVENTS.PAUSE);
32074
+ // if (context.isMicError) callback(RECORDER_EVENTS.PAUSE); its not gonna work , until we will fix staging
32079
32075
  return () => {
32080
32076
  // if (mediaRecorder?.state !== 'inactive') mediaRecorder?.stop();
32081
32077
  };
@@ -32134,7 +32130,7 @@ const recorderMachineV2 = createMachine({
32134
32130
  durations: (_, event) => event.data.duration,
32135
32131
  }),
32136
32132
  [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 }))),
32133
+ [ACTIONS$6.RESET]: assign((context) => (Object.assign(Object.assign({}, initialState), { videoRef: context.videoRef, microphoneRef: context.microphoneRef }))),
32138
32134
  [ACTIONS$6.SET_MEDIA_STREAM]: assign({
32139
32135
  selectedVideoDevice: (_, event) => event.data.selectedVideoDevice,
32140
32136
  selectedAudioDevice: (_, event) => event.data.selectedAudioDevice,
@@ -33110,7 +33106,7 @@ const accWidgetMachine = createMachine({
33110
33106
  company_id: (_d = context.widgetConfig.job) === null || _d === void 0 ? void 0 : _d.company_id,
33111
33107
  apiKey: (_e = context.widgetConfig.job) === null || _e === void 0 ? void 0 : _e.apiKey,
33112
33108
  widget_shown: new Date(),
33113
- }, configFile.serverUrl).then(() => { });
33109
+ }, config(context.widgetConfig.config.env).serverUrl).then(() => { });
33114
33110
  },
33115
33111
  [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
33112
  [ACTIONS$5.CONSOLE_LOG]: (context, event, meta) => console.log('%c [WidgetMachine]', CONSOLE_LOG_STYLE, context, event, meta),
@@ -40479,7 +40475,7 @@ var Crypto = cryptoJs.exports;
40479
40475
 
40480
40476
  const getToken = ({ type = 'apikey', value = '', secretKey = '' }) => `${type} ${value} sig=${Crypto.HmacSHA256(`${type + value}sig=`, secretKey).toString()}`;
40481
40477
 
40482
- const Widget = ({ candidate, job, video, config, disabled = false, buttonText = 'START INTERVIEW', buttonStyle = {}, }) => {
40478
+ const Widget = ({ candidate, job, video, config: config$1, disabled = false, buttonText = 'START INTERVIEW', buttonStyle = {}, }) => {
40483
40479
  const [isWidgetOpen, setIsWidgetOpen] = useState(false);
40484
40480
  const [isIncognitoMode, setIsIncognitoMode] = useState(false);
40485
40481
  const myinterviewRef = useRef(null);
@@ -40498,6 +40494,9 @@ const Widget = ({ candidate, job, video, config, disabled = false, buttonText =
40498
40494
  });
40499
40495
  });
40500
40496
  }, [candidate.email]);
40497
+ useEffect(() => {
40498
+ updateVideoAxiosBaseURL(config(config$1.env).serverUrl);
40499
+ }, [config$1.env]);
40501
40500
  const setLayoutStyleProperties = () => {
40502
40501
  if (myinterviewRef.current) {
40503
40502
  const { x, y, width, height, } = myinterviewRef.current.getBoundingClientRect();
@@ -40505,9 +40504,9 @@ const Widget = ({ candidate, job, video, config, disabled = false, buttonText =
40505
40504
  myinterviewRef.current.style.setProperty('--myinterview-widget-layout-right', `${window.innerWidth - x - width}px`);
40506
40505
  myinterviewRef.current.style.setProperty('--myinterview-widget-layout-bottom', `${window.innerHeight - y - height}px`);
40507
40506
  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);
40507
+ if (config$1.overlay) {
40508
+ myinterviewRef.current.style.setProperty('--color-primary', config$1.overlay);
40509
+ myinterviewRef.current.style.setProperty('--color-special', config$1.overlay);
40511
40510
  }
40512
40511
  }
40513
40512
  };
@@ -40518,18 +40517,18 @@ const Widget = ({ candidate, job, video, config, disabled = false, buttonText =
40518
40517
  };
40519
40518
  const onInterviewCompleted = (data) => {
40520
40519
  var _a;
40521
- (_a = config.onCompleteCallback) === null || _a === void 0 ? void 0 : _a.call(config, data);
40520
+ (_a = config$1.onCompleteCallback) === null || _a === void 0 ? void 0 : _a.call(config$1, data);
40522
40521
  onCloseWidget();
40523
40522
  };
40524
40523
  const onError = (data) => {
40525
40524
  var _a;
40526
- (_a = config.onError) === null || _a === void 0 ? void 0 : _a.call(config, data);
40525
+ (_a = config$1.onError) === null || _a === void 0 ? void 0 : _a.call(config$1, data);
40527
40526
  onCloseWidget();
40528
40527
  };
40529
40528
  const openWidget = () => {
40530
40529
  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))
40530
+ (_a = config$1.onWidgetClicked) === null || _a === void 0 ? void 0 : _a.call(config$1);
40531
+ if (![candidate.username, candidate.email, config$1.auth].every(Boolean))
40533
40532
  return;
40534
40533
  setLayoutStyleProperties();
40535
40534
  document.body.style.maxHeight = '100vh';
@@ -40540,10 +40539,10 @@ const Widget = ({ candidate, job, video, config, disabled = false, buttonText =
40540
40539
  const layoutClassNames = classNames({
40541
40540
  'myinterview-widget__layout': true,
40542
40541
  'myinterview-widget-no-select': true,
40543
- 'myinterview-widget__layout--animated': isWidgetOpen && !!config.openAnimation,
40542
+ 'myinterview-widget__layout--animated': isWidgetOpen && !!config$1.openAnimation,
40544
40543
  });
40545
40544
  return (React__default.createElement(ErrorBoundary, null,
40546
- React__default.createElement(IntercomProvider, { appId: configFile.INTERCOM_APP_ID },
40545
+ React__default.createElement(IntercomProvider, { appId: config(config$1.env).INTERCOM_APP_ID },
40547
40546
  React__default.createElement("div", { ref: myinterviewRef, className: "myinterview-widget" },
40548
40547
  React__default.createElement(Button, { className: "myinterview-widget__button", onClick: openWidget, disabled: disabled, style: buttonStyle }, buttonText),
40549
40548
  isWidgetOpen && (React__default.createElement("div", { className: layoutClassNames },
@@ -40555,7 +40554,7 @@ const Widget = ({ candidate, job, video, config, disabled = false, buttonText =
40555
40554
  (!isSupportedDevice || isIncognitoMode) && React__default.createElement(UnsupportedModal, { messageType: !isSupportedIosDevice ? 'IOS' : !isSupportedDevice ? 'BROWSER' : 'INCOGNITO' }),
40556
40555
  isSupportedDevice && (React__default.createElement("div", { className: "myinterview-widget__wrapper" },
40557
40556
  React__default.createElement(Main, { widgetConfig: {
40558
- config: Object.assign(Object.assign({}, config), { onCompleteCallback: onInterviewCompleted, onError }),
40557
+ config: Object.assign(Object.assign({}, config$1), { onCompleteCallback: onInterviewCompleted, onError }),
40559
40558
  job,
40560
40559
  video,
40561
40560
  candidate,