easyproctor-hml 2.5.36 → 2.5.38

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
@@ -9202,6 +9202,7 @@ var BaseDetection = class {
9202
9202
  console.log("BaseDetection enableCam OK");
9203
9203
  }
9204
9204
  async predictWebcam() {
9205
+ if (this.detecting == false) return;
9205
9206
  if (this.lastVideoTime === -1) {
9206
9207
  await this.detector.setOptions({ runningMode: "VIDEO" });
9207
9208
  }
@@ -9497,8 +9498,6 @@ var FaceDetection = class extends BaseDetection {
9497
9498
  }
9498
9499
  verify(result) {
9499
9500
  var _a2;
9500
- console.log("this.numFacesSent", this.numFacesSent);
9501
- console.log("result.detections.length", result.detections.length);
9502
9501
  if (((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.detectFace) && result.detections.length !== this.numFacesSent) {
9503
9502
  this.numFacesSent = result.detections.length;
9504
9503
  if (result.detections.length === 0) {
@@ -12715,6 +12714,7 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12715
12714
  let bufferSize;
12716
12715
  bufferSize = 0;
12717
12716
  let startTime;
12717
+ let duration = 0;
12718
12718
  let recorderOptions = {
12719
12719
  // eslint-disable-next-line no-useless-escape
12720
12720
  mimeType: "video/webm",
@@ -12754,6 +12754,8 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12754
12754
  if (stopped) {
12755
12755
  console.log("buildMediaRecorder ondataavailable stopped");
12756
12756
  resolvePromise && resolvePromise();
12757
+ const duration2 = Date.now() - startTime.getTime() || 0;
12758
+ console.log("duration no ondataavailable", duration2);
12757
12759
  }
12758
12760
  };
12759
12761
  return mediaRecorder2;
@@ -12766,6 +12768,7 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12766
12768
  recorder2.onstart = () => {
12767
12769
  started = true;
12768
12770
  console.log("recorder onstart");
12771
+ startTime = new Date(Date.now());
12769
12772
  resolve();
12770
12773
  };
12771
12774
  recorder2.onerror = (ev) => {
@@ -12824,9 +12827,13 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12824
12827
  resolvePromise = resolve;
12825
12828
  mediaRecorder.onstop = () => {
12826
12829
  console.log("recorder onstop");
12830
+ const duration2 = Date.now() - startTime.getTime() || 0;
12831
+ console.log("duration no onstop", duration2);
12827
12832
  };
12828
12833
  stopped = true;
12829
12834
  mediaRecorder.stop();
12835
+ duration = Date.now() - startTime.getTime() || 0;
12836
+ console.log("duration imediatamente ap\xF3s mediaRecorder.stop()", duration);
12830
12837
  } else {
12831
12838
  console.log("stopRecording Recorder n\xE3o est\xE1 em estado recording");
12832
12839
  resolve();
@@ -12862,6 +12869,9 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12862
12869
  function getStartTime() {
12863
12870
  return startTime;
12864
12871
  }
12872
+ function getDuration() {
12873
+ return duration;
12874
+ }
12865
12875
  return {
12866
12876
  startRecording,
12867
12877
  stopRecording,
@@ -12869,7 +12879,8 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12869
12879
  resumeRecording,
12870
12880
  recorderOptions,
12871
12881
  getBufferSize,
12872
- getStartTime
12882
+ getStartTime,
12883
+ getDuration
12873
12884
  };
12874
12885
  }
12875
12886
 
@@ -13468,7 +13479,8 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13468
13479
  resumeRecording,
13469
13480
  recorderOptions,
13470
13481
  getBufferSize,
13471
- getStartTime
13482
+ getStartTime,
13483
+ getDuration
13472
13484
  } = recorder(
13473
13485
  this.cameraStream,
13474
13486
  // streamToRecord,
@@ -13484,6 +13496,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13484
13496
  this.recorderOptions = recorderOptions;
13485
13497
  this.getBufferSize = getBufferSize;
13486
13498
  this.getStartTime = getStartTime;
13499
+ this.getDuration = getDuration;
13487
13500
  try {
13488
13501
  await new Promise((r3) => setTimeout(r3, 500));
13489
13502
  await this.recordingStart();
@@ -13516,7 +13529,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13516
13529
  console.log("Camera Recorder started OK");
13517
13530
  }
13518
13531
  async stopRecording() {
13519
- var _a2, _b, _c2, _d;
13532
+ var _a2, _b, _c2;
13520
13533
  console.log("Camera Recorder stopRecording");
13521
13534
  this.isCanvasLoopActive = false;
13522
13535
  this.faceDetection && this.faceDetection.detecting && this.faceDetection.stopDetection();
@@ -13526,7 +13539,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13526
13539
  this.volumeMeter && this.volumeMeter.stop();
13527
13540
  this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
13528
13541
  this.recordingStop && await this.recordingStop();
13529
- this.duration = Date.now() - ((_a2 = this.getStartTime()) == null ? void 0 : _a2.getTime()) || 0;
13542
+ this.duration = this.getDuration();
13530
13543
  try {
13531
13544
  if (this.animationFrameId) {
13532
13545
  cancelAnimationFrame(this.animationFrameId);
@@ -13544,14 +13557,14 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13544
13557
  this.hardwareStream = null;
13545
13558
  }
13546
13559
  if (this.videoElement) {
13547
- (_b = this.videoElement) == null ? void 0 : _b.remove();
13560
+ (_a2 = this.videoElement) == null ? void 0 : _a2.remove();
13548
13561
  this.videoElement = null;
13549
13562
  }
13550
13563
  if (this.video) {
13551
- (_c2 = this.video) == null ? void 0 : _c2.remove();
13564
+ (_b = this.video) == null ? void 0 : _b.remove();
13552
13565
  }
13553
13566
  if (this.canvas) {
13554
- (_d = this.canvas) == null ? void 0 : _d.remove();
13567
+ (_c2 = this.canvas) == null ? void 0 : _c2.remove();
13555
13568
  }
13556
13569
  } catch (e3) {
13557
13570
  console.error("Erro ao parar os streams de m\xEDdia.");
@@ -13698,7 +13711,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13698
13711
  });
13699
13712
  const fixedBlob = await (0, import_fix_webm_duration.default)(rawBlob, this.duration);
13700
13713
  const file = new File(
13701
- [fixedBlob],
13714
+ [rawBlob],
13702
13715
  `EP_${session.id}_camera_0.webm`,
13703
13716
  { type: rawBlob.type }
13704
13717
  );
@@ -13712,6 +13725,21 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13712
13725
  file,
13713
13726
  origin: "Camera" /* Camera */
13714
13727
  });
13728
+ const fileWithDuration = new File(
13729
+ [fixedBlob],
13730
+ `EP_${session.id}_camera_with_duration.webm`,
13731
+ { type: rawBlob.type }
13732
+ );
13733
+ session.addRecording({
13734
+ device: `Audio
13735
+ Sample Rate: ${settingsAudio.sampleRate}
13736
+ Sample Size: ${settingsAudio.sampleSize}
13737
+
13738
+ Video:
13739
+ ${JSON.stringify(this.recorderOptions)}`,
13740
+ file: fileWithDuration,
13741
+ origin: "Camera" /* Camera */
13742
+ });
13715
13743
  }
13716
13744
  }
13717
13745
  async getFile(file, name, type) {
@@ -22386,7 +22414,8 @@ var Proctoring = class {
22386
22414
  this.onChangeDevicesCallback = (devices) => {
22387
22415
  return;
22388
22416
  };
22389
- this.onRealtimeAlertsCallback = (response) => {
22417
+ this.onRealtimeAlertsCallback = async (response) => {
22418
+ await this.internalOnRealtimeAlerts(response);
22390
22419
  return;
22391
22420
  };
22392
22421
  this.onBufferSizeErrorCallback = (cameraStream) => {
@@ -22524,23 +22553,26 @@ var Proctoring = class {
22524
22553
  };
22525
22554
  await verifyFace(1);
22526
22555
  }
22556
+ async internalOnRealtimeAlerts(response) {
22557
+ if (this.sessionOptions.proctoringType === "REALTIME" && (response.type === "face_detection_on_stream" || response.type === "person_detection_on_stream" || response.type === "lost_focus" || response.type === "focus")) {
22558
+ if (response.status === "ALERT") {
22559
+ await this.backend.startRealtimeAlert({
22560
+ proctoringId: this.proctoringId,
22561
+ begin: response.begin,
22562
+ end: response.end,
22563
+ alert: this.convertRealtimeCategoryToAlertCategory(response.category)
22564
+ });
22565
+ } else if (response.status === "OK") {
22566
+ await this.stopRealtimeAlert(response);
22567
+ }
22568
+ }
22569
+ }
22527
22570
  async onRealtimeAlerts(options = {}) {
22528
22571
  this.setOnLostFocusAlertRecorderCallback();
22529
22572
  this.setOnFocusAlertRecorderCallback();
22530
22573
  this.onRealtimeAlertsCallback = async (response) => {
22574
+ await this.internalOnRealtimeAlerts(response);
22531
22575
  options.data && options.data(response);
22532
- if (this.sessionOptions.proctoringType === "REALTIME" && (response.type === "face_detection_on_stream" || response.type === "person_detection_on_stream" || response.type === "lost_focus" || response.type === "focus")) {
22533
- if (response.status === "ALERT") {
22534
- await this.backend.startRealtimeAlert({
22535
- proctoringId: this.proctoringId,
22536
- begin: response.begin,
22537
- end: response.end,
22538
- alert: this.convertRealtimeCategoryToAlertCategory(response.category)
22539
- });
22540
- } else if (response.status === "OK") {
22541
- await this.stopRealtimeAlert(response);
22542
- }
22543
- }
22544
22576
  };
22545
22577
  }
22546
22578
  setOnBufferSizeErrorCallback(cb) {
package/index.js CHANGED
@@ -26487,6 +26487,7 @@ var BaseDetection = class {
26487
26487
  console.log("BaseDetection enableCam OK");
26488
26488
  }
26489
26489
  async predictWebcam() {
26490
+ if (this.detecting == false) return;
26490
26491
  if (this.lastVideoTime === -1) {
26491
26492
  await this.detector.setOptions({ runningMode: "VIDEO" });
26492
26493
  }
@@ -26782,8 +26783,6 @@ var FaceDetection = class extends BaseDetection {
26782
26783
  }
26783
26784
  verify(result) {
26784
26785
  var _a2;
26785
- console.log("this.numFacesSent", this.numFacesSent);
26786
- console.log("result.detections.length", result.detections.length);
26787
26786
  if (((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.detectFace) && result.detections.length !== this.numFacesSent) {
26788
26787
  this.numFacesSent = result.detections.length;
26789
26788
  if (result.detections.length === 0) {
@@ -30812,6 +30811,7 @@ function recorder(stream4, buffer, onBufferSizeError = false, onBufferSizeErrorC
30812
30811
  let bufferSize;
30813
30812
  bufferSize = 0;
30814
30813
  let startTime;
30814
+ let duration = 0;
30815
30815
  let recorderOptions = {
30816
30816
  // eslint-disable-next-line no-useless-escape
30817
30817
  mimeType: "video/webm",
@@ -30851,6 +30851,8 @@ function recorder(stream4, buffer, onBufferSizeError = false, onBufferSizeErrorC
30851
30851
  if (stopped) {
30852
30852
  console.log("buildMediaRecorder ondataavailable stopped");
30853
30853
  resolvePromise && resolvePromise();
30854
+ const duration2 = Date.now() - startTime.getTime() || 0;
30855
+ console.log("duration no ondataavailable", duration2);
30854
30856
  }
30855
30857
  };
30856
30858
  return mediaRecorder2;
@@ -30863,6 +30865,7 @@ function recorder(stream4, buffer, onBufferSizeError = false, onBufferSizeErrorC
30863
30865
  recorder2.onstart = () => {
30864
30866
  started = true;
30865
30867
  console.log("recorder onstart");
30868
+ startTime = new Date(Date.now());
30866
30869
  resolve();
30867
30870
  };
30868
30871
  recorder2.onerror = (ev) => {
@@ -30921,9 +30924,13 @@ function recorder(stream4, buffer, onBufferSizeError = false, onBufferSizeErrorC
30921
30924
  resolvePromise = resolve;
30922
30925
  mediaRecorder.onstop = () => {
30923
30926
  console.log("recorder onstop");
30927
+ const duration2 = Date.now() - startTime.getTime() || 0;
30928
+ console.log("duration no onstop", duration2);
30924
30929
  };
30925
30930
  stopped = true;
30926
30931
  mediaRecorder.stop();
30932
+ duration = Date.now() - startTime.getTime() || 0;
30933
+ console.log("duration imediatamente ap\xF3s mediaRecorder.stop()", duration);
30927
30934
  } else {
30928
30935
  console.log("stopRecording Recorder n\xE3o est\xE1 em estado recording");
30929
30936
  resolve();
@@ -30959,6 +30966,9 @@ function recorder(stream4, buffer, onBufferSizeError = false, onBufferSizeErrorC
30959
30966
  function getStartTime() {
30960
30967
  return startTime;
30961
30968
  }
30969
+ function getDuration() {
30970
+ return duration;
30971
+ }
30962
30972
  return {
30963
30973
  startRecording,
30964
30974
  stopRecording,
@@ -30966,7 +30976,8 @@ function recorder(stream4, buffer, onBufferSizeError = false, onBufferSizeErrorC
30966
30976
  resumeRecording,
30967
30977
  recorderOptions,
30968
30978
  getBufferSize,
30969
- getStartTime
30979
+ getStartTime,
30980
+ getDuration
30970
30981
  };
30971
30982
  }
30972
30983
 
@@ -31565,7 +31576,8 @@ Setting: ${JSON.stringify(settings, null, 2)}`
31565
31576
  resumeRecording,
31566
31577
  recorderOptions,
31567
31578
  getBufferSize,
31568
- getStartTime
31579
+ getStartTime,
31580
+ getDuration
31569
31581
  } = recorder(
31570
31582
  this.cameraStream,
31571
31583
  // streamToRecord,
@@ -31581,6 +31593,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
31581
31593
  this.recorderOptions = recorderOptions;
31582
31594
  this.getBufferSize = getBufferSize;
31583
31595
  this.getStartTime = getStartTime;
31596
+ this.getDuration = getDuration;
31584
31597
  try {
31585
31598
  await new Promise((r3) => setTimeout(r3, 500));
31586
31599
  await this.recordingStart();
@@ -31613,7 +31626,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
31613
31626
  console.log("Camera Recorder started OK");
31614
31627
  }
31615
31628
  async stopRecording() {
31616
- var _a2, _b, _c2, _d;
31629
+ var _a2, _b, _c2;
31617
31630
  console.log("Camera Recorder stopRecording");
31618
31631
  this.isCanvasLoopActive = false;
31619
31632
  this.faceDetection && this.faceDetection.detecting && this.faceDetection.stopDetection();
@@ -31623,7 +31636,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
31623
31636
  this.volumeMeter && this.volumeMeter.stop();
31624
31637
  this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
31625
31638
  this.recordingStop && await this.recordingStop();
31626
- this.duration = Date.now() - ((_a2 = this.getStartTime()) == null ? void 0 : _a2.getTime()) || 0;
31639
+ this.duration = this.getDuration();
31627
31640
  try {
31628
31641
  if (this.animationFrameId) {
31629
31642
  cancelAnimationFrame(this.animationFrameId);
@@ -31641,14 +31654,14 @@ Setting: ${JSON.stringify(settings, null, 2)}`
31641
31654
  this.hardwareStream = null;
31642
31655
  }
31643
31656
  if (this.videoElement) {
31644
- (_b = this.videoElement) == null ? void 0 : _b.remove();
31657
+ (_a2 = this.videoElement) == null ? void 0 : _a2.remove();
31645
31658
  this.videoElement = null;
31646
31659
  }
31647
31660
  if (this.video) {
31648
- (_c2 = this.video) == null ? void 0 : _c2.remove();
31661
+ (_b = this.video) == null ? void 0 : _b.remove();
31649
31662
  }
31650
31663
  if (this.canvas) {
31651
- (_d = this.canvas) == null ? void 0 : _d.remove();
31664
+ (_c2 = this.canvas) == null ? void 0 : _c2.remove();
31652
31665
  }
31653
31666
  } catch {
31654
31667
  console.error("Erro ao parar os streams de m\xEDdia.");
@@ -31795,7 +31808,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
31795
31808
  });
31796
31809
  const fixedBlob = await (0, import_fix_webm_duration.default)(rawBlob, this.duration);
31797
31810
  const file = new File(
31798
- [fixedBlob],
31811
+ [rawBlob],
31799
31812
  `EP_${session.id}_camera_0.webm`,
31800
31813
  { type: rawBlob.type }
31801
31814
  );
@@ -31809,6 +31822,21 @@ Setting: ${JSON.stringify(settings, null, 2)}`
31809
31822
  file,
31810
31823
  origin: "Camera" /* Camera */
31811
31824
  });
31825
+ const fileWithDuration = new File(
31826
+ [fixedBlob],
31827
+ `EP_${session.id}_camera_with_duration.webm`,
31828
+ { type: rawBlob.type }
31829
+ );
31830
+ session.addRecording({
31831
+ device: `Audio
31832
+ Sample Rate: ${settingsAudio.sampleRate}
31833
+ Sample Size: ${settingsAudio.sampleSize}
31834
+
31835
+ Video:
31836
+ ${JSON.stringify(this.recorderOptions)}`,
31837
+ file: fileWithDuration,
31838
+ origin: "Camera" /* Camera */
31839
+ });
31812
31840
  }
31813
31841
  }
31814
31842
  async getFile(file, name, type) {
@@ -37635,7 +37663,8 @@ var Proctoring = class {
37635
37663
  this.onChangeDevicesCallback = (devices) => {
37636
37664
  return;
37637
37665
  };
37638
- this.onRealtimeAlertsCallback = (response) => {
37666
+ this.onRealtimeAlertsCallback = async (response) => {
37667
+ await this.internalOnRealtimeAlerts(response);
37639
37668
  return;
37640
37669
  };
37641
37670
  this.onBufferSizeErrorCallback = (cameraStream) => {
@@ -37773,23 +37802,26 @@ var Proctoring = class {
37773
37802
  };
37774
37803
  await verifyFace(1);
37775
37804
  }
37805
+ async internalOnRealtimeAlerts(response) {
37806
+ if (this.sessionOptions.proctoringType === "REALTIME" && (response.type === "face_detection_on_stream" || response.type === "person_detection_on_stream" || response.type === "lost_focus" || response.type === "focus")) {
37807
+ if (response.status === "ALERT") {
37808
+ await this.backend.startRealtimeAlert({
37809
+ proctoringId: this.proctoringId,
37810
+ begin: response.begin,
37811
+ end: response.end,
37812
+ alert: this.convertRealtimeCategoryToAlertCategory(response.category)
37813
+ });
37814
+ } else if (response.status === "OK") {
37815
+ await this.stopRealtimeAlert(response);
37816
+ }
37817
+ }
37818
+ }
37776
37819
  async onRealtimeAlerts(options = {}) {
37777
37820
  this.setOnLostFocusAlertRecorderCallback();
37778
37821
  this.setOnFocusAlertRecorderCallback();
37779
37822
  this.onRealtimeAlertsCallback = async (response) => {
37823
+ await this.internalOnRealtimeAlerts(response);
37780
37824
  options.data && options.data(response);
37781
- if (this.sessionOptions.proctoringType === "REALTIME" && (response.type === "face_detection_on_stream" || response.type === "person_detection_on_stream" || response.type === "lost_focus" || response.type === "focus")) {
37782
- if (response.status === "ALERT") {
37783
- await this.backend.startRealtimeAlert({
37784
- proctoringId: this.proctoringId,
37785
- begin: response.begin,
37786
- end: response.end,
37787
- alert: this.convertRealtimeCategoryToAlertCategory(response.category)
37788
- });
37789
- } else if (response.status === "OK") {
37790
- await this.stopRealtimeAlert(response);
37791
- }
37792
- }
37793
37825
  };
37794
37826
  }
37795
37827
  setOnBufferSizeErrorCallback(cb) {
@@ -54,6 +54,7 @@ export declare class CameraRecorder implements IRecorder {
54
54
  recordingResume: () => any;
55
55
  getBufferSize: () => any;
56
56
  getStartTime: () => any;
57
+ getDuration: () => any;
57
58
  setProctoringId(proctoringId: string): void;
58
59
  initializeDetectors(): Promise<void>;
59
60
  configImageCapture(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easyproctor-hml",
3
- "version": "2.5.36",
3
+ "version": "2.5.38",
4
4
  "description": "Modulo web de gravação do EasyProctor",
5
5
  "main": "./index.js",
6
6
  "module": "./esm/index.js",
@@ -7,4 +7,5 @@ export default function recorder(stream: MediaStream, buffer: Blob[], onBufferSi
7
7
  recorderOptions: MediaRecorderOptions;
8
8
  getBufferSize: () => number;
9
9
  getStartTime: () => Date | undefined;
10
+ getDuration: () => number;
10
11
  };
@@ -73,6 +73,7 @@ export declare class Proctoring {
73
73
  private convertRealtimeTypeToWarningType;
74
74
  private stopRealtimeAlert;
75
75
  private onRealtimeAlertsCallback;
76
+ private internalOnRealtimeAlerts;
76
77
  onRealtimeAlerts(options?: ProctoringRealtimeAlertsOptions): Promise<void>;
77
78
  private onBufferSizeErrorCallback;
78
79
  setOnBufferSizeErrorCallback(cb: (cameraStream?: any) => void): void;