@newtonschool/react_proctoring_library 0.0.110 → 0.0.112

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.
@@ -31,40 +31,31 @@ const OpenHeimdall = _ref => {
31
31
  } = (0, _react.useContext)(proctoredContext);
32
32
  (0, _react.useEffect)(() => {
33
33
  if (endTimeStamp) {
34
- var _window, _window$electron, _window$electron$acti;
35
- if ((_window = window) !== null && _window !== void 0 && (_window$electron = _window.electron) !== null && _window$electron !== void 0 && (_window$electron$acti = _window$electron.actions) !== null && _window$electron$acti !== void 0 && _window$electron$acti.sendExamMappingDetails) {
36
- window.electron.actions.sendExamMappingDetails({
37
- endTimeStamp
38
- });
39
- }
34
+ var _window$electron$acti;
35
+ (_window$electron$acti = window.electron.actions) === null || _window$electron$acti === void 0 ? void 0 : _window$electron$acti.sendExamMappingDetails({
36
+ endTimeStamp
37
+ });
40
38
  }
41
39
  }, [endTimeStamp]);
42
40
  (0, _react.useEffect)(() => {
41
+ var _window$electron$acti5;
43
42
  setAskPermissionAction(oldAskPermissionAction => _objectSpread(_objectSpread({}, oldAskPermissionAction), {}, {
44
43
  openHeimdall: async () => {
45
- const streams = await window.electron.streams.getScreenStream();
46
- if (streams.length > 1) {
47
- setPermissionErrors(oldErrors => _objectSpread(_objectSpread({}, oldErrors), {}, {
48
- openHeimdall: 'Multiple Screens found. Please use only one during proctoring'
49
- }));
50
- } else {
51
- await window.electron.actions.openHeimdall();
52
- window.electron.actions.sendFileUploadConfig(config.fileUploadConfig);
53
- setPermissionErrors(oldErrors => _objectSpread(_objectSpread({}, oldErrors), {}, {
54
- openHeimdall: null
55
- }));
56
- }
44
+ var _window$electron$acti2, _window$electron$acti3;
45
+ await ((_window$electron$acti2 = window.electron.actions) === null || _window$electron$acti2 === void 0 ? void 0 : _window$electron$acti2.openHeimdall());
46
+ (_window$electron$acti3 = window.electron.actions) === null || _window$electron$acti3 === void 0 ? void 0 : _window$electron$acti3.sendFileUploadConfig(config.fileUploadConfig);
57
47
  },
58
48
  downloadHeimdall: async () => {
59
49
  if (downloadHeimdallUrl.current) {
60
- const res = await window.electron.actions.downloadHeimdall(downloadHeimdallUrl.current);
50
+ var _window$electron$acti4;
51
+ const res = await ((_window$electron$acti4 = window.electron.actions) === null || _window$electron$acti4 === void 0 ? void 0 : _window$electron$acti4.downloadHeimdall(downloadHeimdallUrl.current));
61
52
  if (res.success) {
62
53
  setIsHeimdallSuccessfullyInstalledByScript(true);
63
54
  }
64
55
  }
65
56
  }
66
57
  }));
67
- window.electron.actions.onHeimdallStatusChange(status => {
58
+ (_window$electron$acti5 = window.electron.actions) === null || _window$electron$acti5 === void 0 ? void 0 : _window$electron$acti5.onHeimdallStatusChange(status => {
68
59
  try {
69
60
  permissionSetter.setOpenHeimdallAppPermission(status);
70
61
  setPermissionErrors(oldErrors => _objectSpread(_objectSpread({}, oldErrors), {}, {
@@ -11,7 +11,6 @@ require("core-js/modules/es.symbol.description.js");
11
11
  var _react = require("react");
12
12
  var _useGenericFullScreenData = _interopRequireDefault(require("../../hooks/useGenericFullScreenData"));
13
13
  var _ElectronContext = require("../../contexts/ElectronContext");
14
- var _useKioskMode = _interopRequireDefault(require("../../hooks/electron/useKioskMode"));
15
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
15
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
16
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -20,14 +19,12 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
20
19
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
21
20
  function FullScreen(_ref) {
22
21
  let {
23
- setAskPermissionAction,
24
- proctorParams
22
+ setAskPermissionAction
25
23
  } = _ref;
26
24
  const isElectronApp = (0, _react.useContext)(_ElectronContext.ElectronContext);
27
25
  const {
28
26
  setFullscreen
29
27
  } = (0, _useGenericFullScreenData.default)(isElectronApp);
30
- (0, _useKioskMode.default)(proctorParams);
31
28
  (0, _react.useEffect)(() => {
32
29
  setAskPermissionAction(oldAskPermissionAction => _objectSpread(_objectSpread({}, oldAskPermissionAction), {}, {
33
30
  fullscreen: () => {
@@ -48,6 +48,7 @@ const ProctorApp = _ref => {
48
48
  } = _ref;
49
49
  const context = (0, _react.useContext)(proctoredContext);
50
50
  const isElectronApp = (0, _react.useContext)(_ElectronContext.ElectronContext);
51
+ const calledAllPermissionHandler = (0, _react.useRef)(false);
51
52
  const {
52
53
  permissions,
53
54
  references,
@@ -73,6 +74,20 @@ const ProctorApp = _ref => {
73
74
  const CustomPermissionView = customPermissionView;
74
75
  const proctorParams = (0, _react.useMemo)(() => _objectSpread(_objectSpread({}, _defaults.defaultConfig), config.proctorParams), [config.proctorParams]);
75
76
  const shouldShowProctoredComponent = (0, _breachUtils.showProctoredComponent)(proctorParams, permissions);
77
+ const allPermissionsGrantedCallback = () => {
78
+ if (!calledAllPermissionHandler.current) {
79
+ if (isElectronApp) {
80
+ var _window$electron$acti;
81
+ (_window$electron$acti = window.electron.actions) === null || _window$electron$acti === void 0 ? void 0 : _window$electron$acti.gotAllPermissions();
82
+ }
83
+ calledAllPermissionHandler.current = true;
84
+ }
85
+ };
86
+ if (shouldShowProctoredComponent) {
87
+ allPermissionsGrantedCallback();
88
+ } else {
89
+ calledAllPermissionHandler.current = false;
90
+ }
76
91
  const askPermission = (0, _react.useCallback)(async requiredPermissions => {
77
92
  const allPromises = [];
78
93
  requiredPermissions.forEach(element => {
@@ -119,7 +134,6 @@ const ProctorApp = _ref => {
119
134
  proctoringIdentifier: proctoringIdentifier,
120
135
  setAskPermissionAction: setAskPermissionAction
121
136
  }), proctorParams.fullscreenExit && /*#__PURE__*/(0, _jsxRuntime.jsx)(_fullscreen.default, {
122
- proctorParams: proctorParams,
123
137
  setAskPermissionAction: setAskPermissionAction
124
138
  }), proctorParams.openHeimdall && isElectronApp && /*#__PURE__*/(0, _jsxRuntime.jsx)(_OpenHeimdall.OpenHeimdall, {
125
139
  config: config,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newtonschool/react_proctoring_library",
3
- "version": "0.0.110",
3
+ "version": "0.0.112",
4
4
  "description": "Used to proctor online tests",
5
5
  "author": "ayushkagrawal,shreyachandra,weastel",
6
6
  "main": "dist/index.js",
@@ -1,50 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = useKioskMode;
7
- require("core-js/modules/web.dom-collections.iterator.js");
8
- var _react = require("react");
9
- var _ElectronContext = require("../../contexts/ElectronContext");
10
- var _usePageVisibility = _interopRequireDefault(require("./usePageVisibility"));
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- function useKioskMode() {
13
- let proctorParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
14
- const [connectedToInternet, setConnectedToInternet] = (0, _react.useState)(true);
15
- const isElectronApp = (0, _react.useContext)(_ElectronContext.ElectronContext);
16
- const isPageVisible = (0, _usePageVisibility.default)();
17
- (0, _react.useEffect)(() => {
18
- if (!proctorParams.openHeimdall) {
19
- const updateOnlineStatus = () => {
20
- setConnectedToInternet(window.navigator.onLine);
21
- };
22
- window.addEventListener('online', updateOnlineStatus);
23
- window.addEventListener('offline', updateOnlineStatus);
24
- updateOnlineStatus();
25
- return () => {
26
- window.removeEventListener('online', updateOnlineStatus);
27
- window.removeEventListener('offline', updateOnlineStatus);
28
- };
29
- }
30
- }, []);
31
- (0, _react.useEffect)(() => {
32
- if (!proctorParams.openHeimdall) {
33
- if (isElectronApp && connectedToInternet) {
34
- window.electron.actions.enableKioskMode();
35
- } else {
36
- var _window$electron, _window$electron$acti;
37
- (_window$electron = window.electron) === null || _window$electron === void 0 ? void 0 : (_window$electron$acti = _window$electron.actions) === null || _window$electron$acti === void 0 ? void 0 : _window$electron$acti.disableKioskMode();
38
- }
39
- }
40
- }, [isElectronApp, connectedToInternet, isPageVisible]);
41
- (0, _react.useEffect)(() => {
42
- if (!proctorParams.openHeimdall) {
43
- if (isPageVisible && isElectronApp && connectedToInternet) {
44
- if (window.electron.actions.forceFocus) {
45
- window.electron.actions.forceFocus();
46
- }
47
- }
48
- }
49
- }, [isPageVisible, isElectronApp, connectedToInternet]);
50
- }