easyproctor 1.1.0 → 1.1.1

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.
package/esm/index.js CHANGED
@@ -24296,7 +24296,8 @@ var trackers = {
24296
24296
  registerUpload: (proctoringId, success, description, serviceType, uploadTime) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, success, description, serviceType, uploadTime }),
24297
24297
  registerUploadFile: (proctoringId, description, fileType) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, description, fileType }),
24298
24298
  registerChangeDevice: (proctoringId, inOrOut, devicesChanged) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, inOrOut, devicesChanged }),
24299
- registerStopSharingScreen: (proctoringId, description) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, description })
24299
+ registerStopSharingScreen: (proctoringId, description) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, description }),
24300
+ registerErrorRecorderRTC: (proctoringId, description) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, description })
24300
24301
  };
24301
24302
 
24302
24303
  // src/new-flow/upload/AzureUploadService.ts
@@ -24351,6 +24352,7 @@ var CameraRecorder = class {
24351
24352
  width: 640,
24352
24353
  height: 480
24353
24354
  };
24355
+ this.blobsRTC = [];
24354
24356
  this.imageCount = 0;
24355
24357
  this.options = options;
24356
24358
  this.videoOptions = videoOptions;
@@ -24370,7 +24372,13 @@ var CameraRecorder = class {
24370
24372
  frameRate: 15
24371
24373
  }
24372
24374
  };
24373
- this.cameraStream = await navigator.mediaDevices.getUserMedia(constraints);
24375
+ try {
24376
+ this.cameraStream = await navigator.mediaDevices.getUserMedia(constraints);
24377
+ } catch (error) {
24378
+ if (error.toString() == "NotReadableError: Could not start video source")
24379
+ throw "N\xE3o foi poss\xEDvel conectar a camera, ela pode estar sendo utilizada por outro programa";
24380
+ throw error;
24381
+ }
24374
24382
  const { startRecording, stopRecording, pauseRecording, resumeRecording } = recorder(this.cameraStream, this.blobs);
24375
24383
  this.recordingStart = startRecording;
24376
24384
  this.recordingStop = stopRecording;
@@ -24380,7 +24388,7 @@ var CameraRecorder = class {
24380
24388
  this.photoShotsCycle();
24381
24389
  }
24382
24390
  async stopRecording() {
24383
- await this.recordingStop();
24391
+ this.recordingStop && await this.recordingStop();
24384
24392
  clearInterval(this.imageInterval);
24385
24393
  }
24386
24394
  async pauseRecording() {
@@ -25383,7 +25391,13 @@ var ProctoringRecorder = class {
25383
25391
  async startAll() {
25384
25392
  this.session.start();
25385
25393
  const startPromises = this.recorders.map((rec) => rec.startRecording());
25386
- await Promise.all(startPromises);
25394
+ await Promise.allSettled(startPromises).then((resp) => {
25395
+ resp.map((item) => {
25396
+ if (item.status === "rejected") {
25397
+ throw new Error(item.reason);
25398
+ }
25399
+ });
25400
+ });
25387
25401
  }
25388
25402
  async pauseAll() {
25389
25403
  this.session.pause();
@@ -25526,7 +25540,7 @@ var AlertRecorder = class {
25526
25540
  window.removeEventListener("blur", () => this.onLostFocus());
25527
25541
  window.removeEventListener("focus", () => this.onReturnFocus());
25528
25542
  window.removeEventListener("focus", () => this.onNoiseDetected());
25529
- this.volumeMeter.stop();
25543
+ this.volumeMeter && this.volumeMeter.stop();
25530
25544
  clearInterval(this.intervalNoiseDetection);
25531
25545
  }
25532
25546
  async saveOnSession(session) {
@@ -25871,23 +25885,27 @@ var Proctoring = class {
25871
25885
  return { cameraRecorder, audioRecorder, screenRecorder, alertRecorder };
25872
25886
  }
25873
25887
  async start(options = getDefaultProctoringOptions, _videoOptions = {}) {
25874
- this.extension = new Extension();
25875
- this.extension.addEventListener();
25876
- const baseURL = this.backend.selectBaseUrl(this.context.type);
25877
- const devices = await enumarateDevices();
25878
- await this.repositoryDevices.save({ ...devices, id: "devices" });
25879
- this.sessionOptions = { ...getDefaultProctoringOptions, ...options };
25880
- this.videoOptions = validatePartialVideoOptions(_videoOptions);
25881
- if (this.state != "Stop" /* Stop */) {
25882
- throw PROCTORING_ALREADY_STARTED;
25883
- }
25884
- this.state = "Starting" /* Starting */;
25885
- await this.initConfig();
25886
- await this.verifyMultipleMonitors(this.sessionOptions);
25887
- if (await this.repository.hasSessions()) {
25888
- await this.repository.clear();
25889
- }
25890
25888
  try {
25889
+ this.extension = new Extension();
25890
+ this.extension.addEventListener();
25891
+ const baseURL = this.backend.selectBaseUrl(this.context.type);
25892
+ const devices = await enumarateDevices();
25893
+ await this.repositoryDevices.save({ ...devices, id: "devices" });
25894
+ this.sessionOptions = { ...getDefaultProctoringOptions, ...options };
25895
+ this.videoOptions = validatePartialVideoOptions(_videoOptions);
25896
+ console.log("initConfig");
25897
+ await this.initConfig();
25898
+ await this.verifyMultipleMonitors(this.sessionOptions);
25899
+ if (this.state != "Stop" /* Stop */) {
25900
+ console.log("PROCTORING_ALREADY_STARTED");
25901
+ console.log("this.state", this.state);
25902
+ throw PROCTORING_ALREADY_STARTED;
25903
+ }
25904
+ this.state = "Starting" /* Starting */;
25905
+ console.log("this.state", this.state);
25906
+ if (await this.repository.hasSessions()) {
25907
+ await this.repository.clear();
25908
+ }
25891
25909
  const startResponse = await this.backend.confirmStart({
25892
25910
  clientId: this.context.clientId,
25893
25911
  examId: this.context.examId,
@@ -25914,7 +25932,7 @@ Error: ` + error);
25914
25932
  }
25915
25933
  }
25916
25934
  async cancel() {
25917
- if (this.state === "Recording" /* Recording */) {
25935
+ if (this.state === "Recording" /* Recording */ || this.state === "Starting" /* Starting */) {
25918
25936
  await this.recorder.stopAll();
25919
25937
  }
25920
25938
  this.state = "Stop" /* Stop */;
package/index.js CHANGED
@@ -35830,7 +35830,8 @@ var trackers = {
35830
35830
  registerUpload: (proctoringId, success, description, serviceType, uploadTime) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, success, description, serviceType, uploadTime }),
35831
35831
  registerUploadFile: (proctoringId, description, fileType) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, description, fileType }),
35832
35832
  registerChangeDevice: (proctoringId, inOrOut, devicesChanged) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, inOrOut, devicesChanged }),
35833
- registerStopSharingScreen: (proctoringId, description) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, description })
35833
+ registerStopSharingScreen: (proctoringId, description) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, description }),
35834
+ registerErrorRecorderRTC: (proctoringId, description) => registerCustomEvent(eventNames.UPLOAD_VIDEO, { proctoringId, description })
35834
35835
  };
35835
35836
 
35836
35837
  // src/new-flow/upload/AzureUploadService.ts
@@ -35885,6 +35886,7 @@ var CameraRecorder = class {
35885
35886
  width: 640,
35886
35887
  height: 480
35887
35888
  };
35889
+ this.blobsRTC = [];
35888
35890
  this.imageCount = 0;
35889
35891
  this.options = options;
35890
35892
  this.videoOptions = videoOptions;
@@ -35904,7 +35906,13 @@ var CameraRecorder = class {
35904
35906
  frameRate: 15
35905
35907
  }
35906
35908
  };
35907
- this.cameraStream = await navigator.mediaDevices.getUserMedia(constraints);
35909
+ try {
35910
+ this.cameraStream = await navigator.mediaDevices.getUserMedia(constraints);
35911
+ } catch (error) {
35912
+ if (error.toString() == "NotReadableError: Could not start video source")
35913
+ throw "N\xE3o foi poss\xEDvel conectar a camera, ela pode estar sendo utilizada por outro programa";
35914
+ throw error;
35915
+ }
35908
35916
  const { startRecording, stopRecording, pauseRecording, resumeRecording } = recorder(this.cameraStream, this.blobs);
35909
35917
  this.recordingStart = startRecording;
35910
35918
  this.recordingStop = stopRecording;
@@ -35914,7 +35922,7 @@ var CameraRecorder = class {
35914
35922
  this.photoShotsCycle();
35915
35923
  }
35916
35924
  async stopRecording() {
35917
- await this.recordingStop();
35925
+ this.recordingStop && await this.recordingStop();
35918
35926
  clearInterval(this.imageInterval);
35919
35927
  }
35920
35928
  async pauseRecording() {
@@ -36917,7 +36925,13 @@ var ProctoringRecorder = class {
36917
36925
  async startAll() {
36918
36926
  this.session.start();
36919
36927
  const startPromises = this.recorders.map((rec) => rec.startRecording());
36920
- await Promise.all(startPromises);
36928
+ await Promise.allSettled(startPromises).then((resp) => {
36929
+ resp.map((item) => {
36930
+ if (item.status === "rejected") {
36931
+ throw new Error(item.reason);
36932
+ }
36933
+ });
36934
+ });
36921
36935
  }
36922
36936
  async pauseAll() {
36923
36937
  this.session.pause();
@@ -37060,7 +37074,7 @@ var AlertRecorder = class {
37060
37074
  window.removeEventListener("blur", () => this.onLostFocus());
37061
37075
  window.removeEventListener("focus", () => this.onReturnFocus());
37062
37076
  window.removeEventListener("focus", () => this.onNoiseDetected());
37063
- this.volumeMeter.stop();
37077
+ this.volumeMeter && this.volumeMeter.stop();
37064
37078
  clearInterval(this.intervalNoiseDetection);
37065
37079
  }
37066
37080
  async saveOnSession(session) {
@@ -37405,23 +37419,27 @@ var Proctoring = class {
37405
37419
  return { cameraRecorder, audioRecorder, screenRecorder, alertRecorder };
37406
37420
  }
37407
37421
  async start(options = getDefaultProctoringOptions, _videoOptions = {}) {
37408
- this.extension = new Extension();
37409
- this.extension.addEventListener();
37410
- const baseURL = this.backend.selectBaseUrl(this.context.type);
37411
- const devices = await enumarateDevices();
37412
- await this.repositoryDevices.save({ ...devices, id: "devices" });
37413
- this.sessionOptions = { ...getDefaultProctoringOptions, ...options };
37414
- this.videoOptions = validatePartialVideoOptions(_videoOptions);
37415
- if (this.state != "Stop" /* Stop */) {
37416
- throw PROCTORING_ALREADY_STARTED;
37417
- }
37418
- this.state = "Starting" /* Starting */;
37419
- await this.initConfig();
37420
- await this.verifyMultipleMonitors(this.sessionOptions);
37421
- if (await this.repository.hasSessions()) {
37422
- await this.repository.clear();
37423
- }
37424
37422
  try {
37423
+ this.extension = new Extension();
37424
+ this.extension.addEventListener();
37425
+ const baseURL = this.backend.selectBaseUrl(this.context.type);
37426
+ const devices = await enumarateDevices();
37427
+ await this.repositoryDevices.save({ ...devices, id: "devices" });
37428
+ this.sessionOptions = { ...getDefaultProctoringOptions, ...options };
37429
+ this.videoOptions = validatePartialVideoOptions(_videoOptions);
37430
+ console.log("initConfig");
37431
+ await this.initConfig();
37432
+ await this.verifyMultipleMonitors(this.sessionOptions);
37433
+ if (this.state != "Stop" /* Stop */) {
37434
+ console.log("PROCTORING_ALREADY_STARTED");
37435
+ console.log("this.state", this.state);
37436
+ throw PROCTORING_ALREADY_STARTED;
37437
+ }
37438
+ this.state = "Starting" /* Starting */;
37439
+ console.log("this.state", this.state);
37440
+ if (await this.repository.hasSessions()) {
37441
+ await this.repository.clear();
37442
+ }
37425
37443
  const startResponse = await this.backend.confirmStart({
37426
37444
  clientId: this.context.clientId,
37427
37445
  examId: this.context.examId,
@@ -37448,7 +37466,7 @@ Error: ` + error);
37448
37466
  }
37449
37467
  }
37450
37468
  async cancel() {
37451
- if (this.state === "Recording" /* Recording */) {
37469
+ if (this.state === "Recording" /* Recording */ || this.state === "Starting" /* Starting */) {
37452
37470
  await this.recorder.stopAll();
37453
37471
  }
37454
37472
  this.state = "Stop" /* Stop */;
@@ -8,6 +8,7 @@ export declare class CameraRecorder implements IRecorder {
8
8
  private blobs;
9
9
  private options;
10
10
  private videoOptions;
11
+ private blobsRTC;
11
12
  recorder: RecordRTCPromisesHandler;
12
13
  cameraStream: MediaStream;
13
14
  imageCount: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easyproctor",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Modulo web de gravação do EasyProctor",
5
5
  "main": "./index.js",
6
6
  "module": "./esm/index.js",
@@ -14,5 +14,6 @@ declare const trackers: {
14
14
  registerUploadFile: (proctoringId: string, description: string, fileType: string) => void;
15
15
  registerChangeDevice: (proctoringId: string, inOrOut: string, devicesChanged: DevicesChanged) => void;
16
16
  registerStopSharingScreen: (proctoringId: string, description: string) => void;
17
+ registerErrorRecorderRTC: (proctoringId: string, description: string) => void;
17
18
  };
18
19
  export { trackers, init };