@newtonschool/react_proctoring_library 0.0.9 → 0.0.10
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.
|
@@ -43,6 +43,7 @@ const ProctorApp = _ref => {
|
|
|
43
43
|
const webcamReference = (0, _react.useRef)(null);
|
|
44
44
|
const canvasReference = (0, _react.useRef)(null);
|
|
45
45
|
const statistics = (0, _react.useRef)(_defaults.INITIAL_STATISTICS);
|
|
46
|
+
const gpuAvailable = (0, _utils.isGPUAvailable)();
|
|
46
47
|
const [audioPermission, setAudioPermission] = (0, _react.useState)(false);
|
|
47
48
|
const [videoPermission, setVideoPermission] = (0, _react.useState)(false);
|
|
48
49
|
const firstFullScreenDone = (0, _react.useRef)(false);
|
|
@@ -51,8 +52,18 @@ const ProctorApp = _ref => {
|
|
|
51
52
|
setFullscreen,
|
|
52
53
|
fullScreenExitCount
|
|
53
54
|
} = (0, _hooks.useFullscreenData)(firstFullScreenDone);
|
|
54
|
-
const [userCount, lookedAwayCount] = (0, _useWebcamData.default)(webcamReference, canvasReference);
|
|
55
|
+
const [userCount, lookedAwayCount] = gpuAvailable ? (0, _useWebcamData.default)(webcamReference, canvasReference) : [-1, -1];
|
|
55
56
|
const tabSwitchCount = (0, _hooks.useTabSwitchCount)(firstFullScreenDone);
|
|
57
|
+
(0, _react.useEffect)(() => {
|
|
58
|
+
if (!gpuAvailable & shouldSendDataOnBreach) {
|
|
59
|
+
(0, _utils.sendDataOnBreach)(statistics, {
|
|
60
|
+
userCount,
|
|
61
|
+
tabSwitchCount,
|
|
62
|
+
fullScreenExitCount,
|
|
63
|
+
lookedAwayCount
|
|
64
|
+
}, proctoringIdentifier, sendData);
|
|
65
|
+
}
|
|
66
|
+
}, []);
|
|
56
67
|
(0, _react.useEffect)(() => {
|
|
57
68
|
(0, _utils.removeStatsFromLocalStorage)(proctoringIdentifier);
|
|
58
69
|
}, [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;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.array.includes.js");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.string.includes.js");
|
|
8
|
+
|
|
9
|
+
var _defaults = require("../constants/defaults");
|
|
10
|
+
|
|
11
|
+
const isGPUAvailable = () => {
|
|
12
|
+
const canvas = document.createElement("canvas");
|
|
13
|
+
const webgl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
|
|
14
|
+
const debugInfo = webgl.getExtension("webgl_debug_renderer_info");
|
|
15
|
+
const gpu = webgl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL).toLowerCase();
|
|
16
|
+
|
|
17
|
+
for (const gpuType of _defaults.gpuTypes) {
|
|
18
|
+
if (gpu.includes(gpuType)) return true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return false;
|
|
22
|
+
};
|
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");
|