@newtonschool/react_proctoring_library 0.0.50 → 0.0.52
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.
|
@@ -15,7 +15,9 @@ function useFullscreenData(isProctorParam) {
|
|
|
15
15
|
if (!fullScreenElement || !fullScreenElement.current) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
fullScreenElement.current.requestFullscreen(
|
|
18
|
+
fullScreenElement.current.requestFullscreen({
|
|
19
|
+
navigationUI: "hide"
|
|
20
|
+
}).then(() => {
|
|
19
21
|
setIsFullscreen(document[browserFullscreenElementProp] != null);
|
|
20
22
|
}).catch(err => {
|
|
21
23
|
setIsFullscreen(false);
|
|
@@ -13,7 +13,7 @@ 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
15
|
var _defaults = require("../constants/defaults");
|
|
16
|
-
const isWebcamVideoValid = webcamReference => webcamReference !== null && webcamReference !== undefined && typeof webcamReference.current !==
|
|
16
|
+
const isWebcamVideoValid = webcamReference => webcamReference !== null && webcamReference !== undefined && typeof webcamReference.current !== 'undefined' && webcamReference.current !== null && webcamReference.current.video.readyState === 4;
|
|
17
17
|
exports.isWebcamVideoValid = isWebcamVideoValid;
|
|
18
18
|
const updateStatistics = (statistics, currentStats, proctorParams) => {
|
|
19
19
|
const {
|
|
@@ -71,12 +71,12 @@ const getGlancePercentage = partSegmentation => {
|
|
|
71
71
|
};
|
|
72
72
|
exports.getGlancePercentage = getGlancePercentage;
|
|
73
73
|
const getVideoPermission = function getVideoPermission(stream) {
|
|
74
|
-
let exludeTrackId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
74
|
+
let exludeTrackId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
75
75
|
return stream.getVideoTracks().filter(track => track.enabled && track.label && track.id !== exludeTrackId).length > 0;
|
|
76
76
|
};
|
|
77
77
|
exports.getVideoPermission = getVideoPermission;
|
|
78
78
|
const getAudioPermission = function getAudioPermission(stream) {
|
|
79
|
-
let exludeTrackId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
79
|
+
let exludeTrackId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
80
80
|
return stream.getAudioTracks().filter(track => track.enabled && track.label && !track.muted && track.id !== exludeTrackId).length > 0;
|
|
81
81
|
};
|
|
82
82
|
exports.getAudioPermission = getAudioPermission;
|
|
@@ -108,10 +108,14 @@ const updateVideoPermissions = setVideoPermission => {
|
|
|
108
108
|
};
|
|
109
109
|
exports.updateVideoPermissions = updateVideoPermissions;
|
|
110
110
|
const setupScreensharePermission = (setScreensharePermission, screenshareReference, setScreenshareStream) => navigator.mediaDevices.getDisplayMedia({
|
|
111
|
+
video: {
|
|
112
|
+
displaySurface: 'monitor'
|
|
113
|
+
}
|
|
114
|
+
}).catch(() => navigator.mediaDevices.getDisplayMedia({
|
|
111
115
|
video: true
|
|
112
|
-
}).then(stream => {
|
|
116
|
+
})).then(stream => {
|
|
113
117
|
const track = stream.getTracks()[0];
|
|
114
|
-
if (track.getSettings().displaySurface ===
|
|
118
|
+
if (track.getSettings().displaySurface === 'monitor') {
|
|
115
119
|
setScreensharePermission(true);
|
|
116
120
|
setScreenshareStream(stream);
|
|
117
121
|
collectScreenshare(screenshareReference, stream);
|
|
@@ -145,16 +149,16 @@ const resetWebcamReference = webcamReference => {
|
|
|
145
149
|
};
|
|
146
150
|
exports.resetWebcamReference = resetWebcamReference;
|
|
147
151
|
const getVideoPermissionQuery = () => navigator.permissions.query({
|
|
148
|
-
name:
|
|
152
|
+
name: 'camera'
|
|
149
153
|
});
|
|
150
154
|
exports.getVideoPermissionQuery = getVideoPermissionQuery;
|
|
151
155
|
const getAudioPermissionQuery = () => navigator.permissions.query({
|
|
152
|
-
name:
|
|
156
|
+
name: 'microphone'
|
|
153
157
|
});
|
|
154
158
|
exports.getAudioPermissionQuery = getAudioPermissionQuery;
|
|
155
159
|
const b64DataURItoBlob = dataURI => {
|
|
156
|
-
const byteString = window.atob(dataURI.split(
|
|
157
|
-
const mimeString = dataURI.split(
|
|
160
|
+
const byteString = window.atob(dataURI.split(',')[1]);
|
|
161
|
+
const mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
|
|
158
162
|
const u8arr = new Uint8Array(byteString.length);
|
|
159
163
|
for (let i = 0; i < byteString.length; i += 1) {
|
|
160
164
|
u8arr[i] = byteString.charCodeAt(i);
|
|
@@ -175,18 +179,18 @@ exports.captureWebcamSnapshot = captureWebcamSnapshot;
|
|
|
175
179
|
const captureScreenshot = async elementIdSelector => {
|
|
176
180
|
try {
|
|
177
181
|
const video = document.querySelector(elementIdSelector);
|
|
178
|
-
const canvas = document.createElement(
|
|
182
|
+
const canvas = document.createElement('canvas');
|
|
179
183
|
if (window.createImageBitmap) {
|
|
180
184
|
const bitmap = await createImageBitmap(video);
|
|
181
185
|
canvas.width = bitmap.width;
|
|
182
186
|
canvas.height = bitmap.height;
|
|
183
|
-
canvas.getContext(
|
|
187
|
+
canvas.getContext('bitmaprenderer').transferFromImageBitmap(bitmap);
|
|
184
188
|
const blob = await new Promise(res => canvas.toBlob(res));
|
|
185
189
|
return blob;
|
|
186
190
|
} else {
|
|
187
191
|
canvas.width = video.videoWidth;
|
|
188
192
|
canvas.height = video.videoHeight;
|
|
189
|
-
canvas.getContext(
|
|
193
|
+
canvas.getContext('2d').drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
|
|
190
194
|
const blob = await new Promise(resolve => canvas.toBlob(resolve));
|
|
191
195
|
return blob;
|
|
192
196
|
}
|