@newtonschool/react_proctoring_library 0.0.8 → 0.0.11
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.
|
@@ -53,6 +53,16 @@ const ProctorApp = _ref => {
|
|
|
53
53
|
} = (0, _hooks.useFullscreenData)(firstFullScreenDone);
|
|
54
54
|
const [userCount, lookedAwayCount] = (0, _useWebcamData.default)(webcamReference, canvasReference);
|
|
55
55
|
const tabSwitchCount = (0, _hooks.useTabSwitchCount)(firstFullScreenDone);
|
|
56
|
+
(0, _react.useEffect)(() => {
|
|
57
|
+
if (shouldSendDataOnBreach && (userCount < 0 || lookedAwayCount < 0)) {
|
|
58
|
+
(0, _utils.sendDataOnBreach)(statistics, {
|
|
59
|
+
userCount,
|
|
60
|
+
tabSwitchCount,
|
|
61
|
+
fullScreenExitCount,
|
|
62
|
+
lookedAwayCount
|
|
63
|
+
}, proctoringIdentifier, sendData);
|
|
64
|
+
}
|
|
65
|
+
}, []);
|
|
56
66
|
(0, _react.useEffect)(() => {
|
|
57
67
|
(0, _utils.removeStatsFromLocalStorage)(proctoringIdentifier);
|
|
58
68
|
}, [proctoringIdentifier]);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.initialValues = exports.glancePercentageToPass = exports.evaluateVideoIntervalInSeconds = exports.bodyPixConfigs = exports.INITIAL_STATISTICS = void 0;
|
|
6
|
+
exports.initialValues = exports.gpuTypes = exports.glancePercentageToPass = exports.evaluateVideoIntervalInSeconds = exports.bodyPixConfigs = exports.INITIAL_STATISTICS = void 0;
|
|
7
7
|
const initialValues = {
|
|
8
8
|
tabSwitchCount: 0,
|
|
9
9
|
userCount: 0,
|
|
@@ -35,4 +35,6 @@ exports.bodyPixConfigs = bodyPixConfigs;
|
|
|
35
35
|
const glancePercentageToPass = 60;
|
|
36
36
|
exports.glancePercentageToPass = glancePercentageToPass;
|
|
37
37
|
const evaluateVideoIntervalInSeconds = 1;
|
|
38
|
-
exports.evaluateVideoIntervalInSeconds = evaluateVideoIntervalInSeconds;
|
|
38
|
+
exports.evaluateVideoIntervalInSeconds = evaluateVideoIntervalInSeconds;
|
|
39
|
+
const gpuTypes = ["apple", "amd", "radeon", "nvidia", "geforce"];
|
|
40
|
+
exports.gpuTypes = gpuTypes;
|
package/dist/hooks/index.js
CHANGED
|
@@ -3,12 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "useAudioVideoPermissions", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _useAudioVideoPermissions.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
6
|
Object.defineProperty(exports, "useFullscreenData", {
|
|
13
7
|
enumerable: true,
|
|
14
8
|
get: function get() {
|
|
@@ -34,6 +28,4 @@ var _usePageVisibility = _interopRequireDefault(require("./usePageVisibility"));
|
|
|
34
28
|
|
|
35
29
|
var _useTabSwitchCount = _interopRequireDefault(require("./useTabSwitchCount"));
|
|
36
30
|
|
|
37
|
-
var _useAudioVideoPermissions = _interopRequireDefault(require("./useAudioVideoPermissions"));
|
|
38
|
-
|
|
39
31
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -42,45 +42,49 @@ const getIsWatching = async (network, video) => {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
+
const gpuAvailable = (0, _utils.isGPUAvailable)();
|
|
46
|
+
|
|
45
47
|
function useWebcamData(webcamReference, canvasReference) {
|
|
46
|
-
const [userCount, setUserCount] = (0, _react.useState)(_defaults.initialValues.userCount);
|
|
47
|
-
const [isWatching, setIsWatching] = (0, _react.useState)(_defaults.initialValues.isWatching);
|
|
48
|
+
const [userCount, setUserCount] = (0, _react.useState)(gpuAvailable ? _defaults.initialValues.userCount : -1);
|
|
49
|
+
const [isWatching, setIsWatching] = (0, _react.useState)(gpuAvailable ? _defaults.initialValues.isWatching : -1);
|
|
48
50
|
const [lookedAwayCount, setLookedAwayCount] = (0, _react.useState)(_defaults.initialValues.lookedAwayCount);
|
|
49
51
|
(0, _react.useEffect)(() => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
52
|
+
if (gpuAvailable) {
|
|
53
|
+
const loadBodyPixModel = async () => {
|
|
54
|
+
try {
|
|
55
|
+
const network = await bodyPix.load();
|
|
56
|
+
setInterval(async () => {
|
|
57
|
+
if ((0, _utils.isWebcamVideoValid)(webcamReference)) {
|
|
58
|
+
var _users$length;
|
|
59
|
+
|
|
60
|
+
const video = webcamReference.current.video;
|
|
61
|
+
const {
|
|
62
|
+
videoWidth,
|
|
63
|
+
videoHeight
|
|
64
|
+
} = video;
|
|
65
|
+
video.width = videoWidth;
|
|
66
|
+
video.height = videoHeight;
|
|
67
|
+
canvasReference.current.width = videoWidth;
|
|
68
|
+
canvasReference.current.height = videoHeight;
|
|
69
|
+
const users = await getUsers(network, video);
|
|
70
|
+
const count = (_users$length = users === null || users === void 0 ? void 0 : users.length) !== null && _users$length !== void 0 ? _users$length : 0;
|
|
71
|
+
setUserCount(count);
|
|
72
|
+
|
|
73
|
+
if (count) {
|
|
74
|
+
setIsWatching(getIsWatching(network, video));
|
|
75
|
+
} else {
|
|
76
|
+
setIsWatching(false);
|
|
77
|
+
}
|
|
74
78
|
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
}, _defaults.evaluateVideoIntervalInSeconds * 1000);
|
|
80
|
+
} catch (err) {
|
|
81
|
+
console.log("Error Trace:", err);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
loadBodyPixModel();
|
|
87
|
+
}
|
|
84
88
|
}, [webcamReference, canvasReference]);
|
|
85
89
|
(0, _react.useEffect)(() => {
|
|
86
90
|
if (!isWatching) {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isGPUAvailable = void 0;
|
|
7
|
+
|
|
8
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
|
+
|
|
10
|
+
require("core-js/modules/es.array.includes.js");
|
|
11
|
+
|
|
12
|
+
require("core-js/modules/es.string.includes.js");
|
|
13
|
+
|
|
14
|
+
var _defaults = require("../constants/defaults");
|
|
15
|
+
|
|
16
|
+
const isGPUAvailable = () => {
|
|
17
|
+
const canvas = document.createElement("canvas");
|
|
18
|
+
const webgl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
|
|
19
|
+
const debugInfo = webgl.getExtension("webgl_debug_renderer_info");
|
|
20
|
+
const gpu = webgl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL).toLowerCase();
|
|
21
|
+
|
|
22
|
+
for (const gpuType of _defaults.gpuTypes) {
|
|
23
|
+
if (gpu.includes(gpuType)) return true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return false;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.isGPUAvailable = isGPUAvailable;
|
package/dist/utils/index.js
CHANGED
|
@@ -63,6 +63,12 @@ Object.defineProperty(exports, "isArrayValid", {
|
|
|
63
63
|
return _arrayUtils.isArrayValid;
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
+
Object.defineProperty(exports, "isGPUAvailable", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function get() {
|
|
69
|
+
return _gpuUtils.isGPUAvailable;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
66
72
|
Object.defineProperty(exports, "isWebcamVideoValid", {
|
|
67
73
|
enumerable: true,
|
|
68
74
|
get: function get() {
|
|
@@ -102,4 +108,6 @@ var _browserUtils = require("./browserUtils");
|
|
|
102
108
|
|
|
103
109
|
var _breachUtils = require("./breachUtils");
|
|
104
110
|
|
|
105
|
-
var _arrayUtils = require("./arrayUtils");
|
|
111
|
+
var _arrayUtils = require("./arrayUtils");
|
|
112
|
+
|
|
113
|
+
var _gpuUtils = require("./gpuUtils");
|