@newtonschool/react_proctoring_library 0.0.46 → 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.
@@ -174,13 +174,22 @@ const captureWebcamSnapshot = webcamReference => {
174
174
  exports.captureWebcamSnapshot = captureWebcamSnapshot;
175
175
  const captureScreenshot = async elementIdSelector => {
176
176
  try {
177
- const canvas = document.createElement("canvas");
178
177
  const video = document.querySelector(elementIdSelector);
179
- canvas.width = video.videoWidth;
180
- canvas.height = video.videoHeight;
181
- canvas.getContext("2d").drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
182
- const blob = await new Promise(resolve => canvas.toBlob(resolve));
183
- return blob;
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
+ }
184
193
  } catch (e) {
185
194
  // pass
186
195
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newtonschool/react_proctoring_library",
3
- "version": "0.0.46",
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",