@newtonschool/react_proctoring_library 0.0.45 → 0.0.47
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.
|
@@ -12,9 +12,7 @@ require("core-js/modules/es.typed-array.sort.js");
|
|
|
12
12
|
require("core-js/modules/es.typed-array.to-locale-string.js");
|
|
13
13
|
require("core-js/modules/es.promise.js");
|
|
14
14
|
var _ = require(".");
|
|
15
|
-
var _html2canvas = _interopRequireDefault(require("html2canvas"));
|
|
16
15
|
var _defaults = require("../constants/defaults");
|
|
17
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
16
|
const isWebcamVideoValid = webcamReference => webcamReference !== null && webcamReference !== undefined && typeof webcamReference.current !== "undefined" && webcamReference.current !== null && webcamReference.current.video.readyState === 4;
|
|
19
17
|
exports.isWebcamVideoValid = isWebcamVideoValid;
|
|
20
18
|
const updateStatistics = (statistics, currentStats, proctorParams) => {
|
|
@@ -176,9 +174,22 @@ const captureWebcamSnapshot = webcamReference => {
|
|
|
176
174
|
exports.captureWebcamSnapshot = captureWebcamSnapshot;
|
|
177
175
|
const captureScreenshot = async elementIdSelector => {
|
|
178
176
|
try {
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
|
|
177
|
+
const video = document.querySelector(elementIdSelector);
|
|
178
|
+
const canvas = document.createElement("canvas");
|
|
179
|
+
if (window.createImageBitmap) {
|
|
180
|
+
const bitmap = await createImageBitmap(video);
|
|
181
|
+
canvas.width = bitmap.width;
|
|
182
|
+
canvas.height = bitmap.height;
|
|
183
|
+
canvas.getContext("bitmaprenderer").transferFromImageBitmap(bitmap);
|
|
184
|
+
const blob = await new Promise(res => canvas.toBlob(res));
|
|
185
|
+
return blob;
|
|
186
|
+
} else {
|
|
187
|
+
canvas.width = video.videoWidth;
|
|
188
|
+
canvas.height = video.videoHeight;
|
|
189
|
+
canvas.getContext("2d").drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
|
|
190
|
+
const blob = await new Promise(resolve => canvas.toBlob(resolve));
|
|
191
|
+
return blob;
|
|
192
|
+
}
|
|
182
193
|
} catch (e) {
|
|
183
194
|
// pass
|
|
184
195
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newtonschool/react_proctoring_library",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.47",
|
|
4
4
|
"description": "Used to proctor online tests",
|
|
5
5
|
"author": "ayushkagrawal,shreyachandra,weastel",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
"@tensorflow/tfjs": "^3.9.0",
|
|
18
18
|
"bootstrap": "^5.1.3",
|
|
19
19
|
"core-js": "^3.22.7",
|
|
20
|
-
"html2canvas": "^1.4.1",
|
|
21
20
|
"react-bootstrap": "^2.0.4",
|
|
22
21
|
"react-webcam": "^6.0.0"
|
|
23
22
|
},
|