easyproctor 0.0.24 → 0.0.25

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.
@@ -7,5 +7,5 @@ export default interface StartProctoringDTO {
7
7
  examEndTime: string;
8
8
  status: number;
9
9
  cameraStream: MediaStream;
10
- screenStream: MediaStream;
10
+ screenStream: MediaStream | undefined;
11
11
  }
package/esm/index.js CHANGED
@@ -8277,7 +8277,8 @@ var defaultProctoringOptions = {
8277
8277
  cameraId: void 0,
8278
8278
  microphoneId: void 0,
8279
8279
  allowMultipleMonitors: false,
8280
- allowOnlyFirstMonitor: true
8280
+ allowOnlyFirstMonitor: true,
8281
+ captureScreen: true
8281
8282
  };
8282
8283
  var azureBlobUrl = "";
8283
8284
  function useProctoring(proctoringOptions, proctoringConfig) {
@@ -8328,20 +8329,31 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8328
8329
  }
8329
8330
  let cancelCameraCapture = null;
8330
8331
  let cancelScreenCapture = null;
8331
- const { cameraId, microphoneId, allowOnlyFirstMonitor } = options;
8332
+ const { cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen } = options;
8332
8333
  try {
8333
- const { screenStream, stopScreenRecorder } = await startScreenCapture(screenBuffer, {
8334
- allowOnlyFirstMonitor,
8335
- onStopSharingScreenCallback: () => onStopSharingScreenCallback && onStopSharingScreenCallback()
8336
- });
8334
+ let _screenStream = void 0;
8335
+ if (captureScreen) {
8336
+ const { screenStream, stopScreenRecorder } = await startScreenCapture(screenBuffer, {
8337
+ allowOnlyFirstMonitor,
8338
+ onStopSharingScreenCallback: () => onStopSharingScreenCallback && onStopSharingScreenCallback()
8339
+ });
8340
+ cancelScreenCapture = stopScreenRecorder;
8341
+ _screenStream = screenStream;
8342
+ }
8337
8343
  const { cameraStream, stopCameraRecording } = await startCameraCapture(cameraBuffer, { cameraId, microphoneId });
8338
- cancelScreenCapture = stopScreenRecorder;
8339
8344
  cancelCameraCapture = stopCameraRecording;
8340
- cancelCallback = async function() {
8341
- await Promise.all([cancelCameraCapture(), cancelScreenCapture()]);
8342
- cancelCallback = null;
8343
- };
8344
- return { screenStream, cameraStream };
8345
+ if (captureScreen) {
8346
+ cancelCallback = async function() {
8347
+ await Promise.all([cancelCameraCapture(), cancelScreenCapture()]);
8348
+ cancelCallback = null;
8349
+ };
8350
+ } else {
8351
+ cancelCallback = async function() {
8352
+ await Promise.all([cancelCameraCapture()]);
8353
+ cancelCallback = null;
8354
+ };
8355
+ }
8356
+ return { _screenStream, cameraStream };
8345
8357
  } catch (error) {
8346
8358
  cancelCallback = null;
8347
8359
  cancelScreenCapture && await cancelScreenCapture();
@@ -8377,7 +8389,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8377
8389
  const _closeSession = (index) => {
8378
8390
  const finalCameraBuffer = cameraBuffer;
8379
8391
  const finalScreenBuffer = screenBuffer;
8380
- if (finalCameraBuffer.length == 0 || finalScreenBuffer.length == 0) {
8392
+ if (finalCameraBuffer.length == 0) {
8381
8393
  throw PROCTORING_NOT_STARTED;
8382
8394
  }
8383
8395
  const cameraFileName = `EP_${proctoringId}_camera_${index}.webm`;
@@ -8387,7 +8399,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8387
8399
  return { cameraFile, screenFile };
8388
8400
  };
8389
8401
  async function start(options = defaultProctoringOptions) {
8390
- const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false } = options;
8402
+ const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true } = options;
8391
8403
  if (proctoringConfig != void 0) {
8392
8404
  setConfiguration(proctoringConfig.account, proctoringConfig.containerName, proctoringConfig.sas);
8393
8405
  azureBlobUrl = proctoringConfig.azureBlobUrl;
@@ -8408,7 +8420,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8408
8420
  throw PROCTORING_ALREADY_STARTED;
8409
8421
  }
8410
8422
  try {
8411
- const { cameraStream, screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor });
8423
+ const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen });
8412
8424
  startTime = Date.now();
8413
8425
  startDate = new Date();
8414
8426
  const resp = await makeRequest({
@@ -8418,7 +8430,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8418
8430
  jwt: proctoringOptions.token
8419
8431
  });
8420
8432
  resp.cameraStream = cameraStream;
8421
- resp.screenStream = screenStream;
8433
+ resp.screenStream = _screenStream;
8422
8434
  await insertRecord("exams", {
8423
8435
  id: resp.id,
8424
8436
  sessions: []
@@ -8454,7 +8466,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8454
8466
  }
8455
8467
  async function resume(options = defaultProctoringOptions) {
8456
8468
  _clear();
8457
- const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false } = options;
8469
+ const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true } = options;
8458
8470
  if (!allowMultipleMonitors) {
8459
8471
  const hasMultipleMonitors = await checkIfhasMultipleMonitors();
8460
8472
  if (hasMultipleMonitors) {
@@ -8468,16 +8480,17 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8468
8480
  if (!record) {
8469
8481
  throw PROCTORING_NOT_STARTED;
8470
8482
  }
8471
- const { cameraStream, screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor });
8483
+ const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen });
8472
8484
  proctoringId = record.id;
8473
8485
  startTime = Date.now();
8474
8486
  startDate = new Date();
8475
- return { cameraStream, screenStream };
8487
+ return { cameraStream, _screenStream };
8476
8488
  }
8477
8489
  async function finish(options = {}) {
8478
8490
  const { onProgress } = options;
8479
8491
  const record = await getRecord("exams");
8480
8492
  if (!record) {
8493
+ console.log("OXE");
8481
8494
  throw PROCTORING_NOT_STARTED;
8482
8495
  }
8483
8496
  onStopSharingScreenCallback = void 0;
package/index.d.ts CHANGED
@@ -6,6 +6,7 @@ interface ProctoringOptions {
6
6
  microphoneId?: string;
7
7
  allowMultipleMonitors?: boolean;
8
8
  allowOnlyFirstMonitor?: boolean;
9
+ captureScreen?: boolean;
9
10
  }
10
11
  interface ProctoringConfig {
11
12
  azureBlobUrl: string;
@@ -26,7 +27,7 @@ export declare function useProctoring(proctoringOptions: {
26
27
  pause: () => Promise<void>;
27
28
  resume: (options?: ProctoringOptions) => Promise<{
28
29
  cameraStream: MediaStream;
29
- screenStream: MediaStream;
30
+ _screenStream: MediaStream | undefined;
30
31
  }>;
31
32
  onFocus: (cb: () => void) => void;
32
33
  onLostFocus: (cb: () => void) => void;
package/index.js CHANGED
@@ -8617,7 +8617,8 @@ var defaultProctoringOptions = {
8617
8617
  cameraId: void 0,
8618
8618
  microphoneId: void 0,
8619
8619
  allowMultipleMonitors: false,
8620
- allowOnlyFirstMonitor: true
8620
+ allowOnlyFirstMonitor: true,
8621
+ captureScreen: true
8621
8622
  };
8622
8623
  var azureBlobUrl = "";
8623
8624
  function useProctoring(proctoringOptions, proctoringConfig) {
@@ -8668,20 +8669,31 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8668
8669
  }
8669
8670
  let cancelCameraCapture = null;
8670
8671
  let cancelScreenCapture = null;
8671
- const { cameraId, microphoneId, allowOnlyFirstMonitor } = options;
8672
+ const { cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen } = options;
8672
8673
  try {
8673
- const { screenStream, stopScreenRecorder } = await startScreenCapture(screenBuffer, {
8674
- allowOnlyFirstMonitor,
8675
- onStopSharingScreenCallback: () => onStopSharingScreenCallback && onStopSharingScreenCallback()
8676
- });
8674
+ let _screenStream = void 0;
8675
+ if (captureScreen) {
8676
+ const { screenStream, stopScreenRecorder } = await startScreenCapture(screenBuffer, {
8677
+ allowOnlyFirstMonitor,
8678
+ onStopSharingScreenCallback: () => onStopSharingScreenCallback && onStopSharingScreenCallback()
8679
+ });
8680
+ cancelScreenCapture = stopScreenRecorder;
8681
+ _screenStream = screenStream;
8682
+ }
8677
8683
  const { cameraStream, stopCameraRecording } = await startCameraCapture(cameraBuffer, { cameraId, microphoneId });
8678
- cancelScreenCapture = stopScreenRecorder;
8679
8684
  cancelCameraCapture = stopCameraRecording;
8680
- cancelCallback = async function() {
8681
- await Promise.all([cancelCameraCapture(), cancelScreenCapture()]);
8682
- cancelCallback = null;
8683
- };
8684
- return { screenStream, cameraStream };
8685
+ if (captureScreen) {
8686
+ cancelCallback = async function() {
8687
+ await Promise.all([cancelCameraCapture(), cancelScreenCapture()]);
8688
+ cancelCallback = null;
8689
+ };
8690
+ } else {
8691
+ cancelCallback = async function() {
8692
+ await Promise.all([cancelCameraCapture()]);
8693
+ cancelCallback = null;
8694
+ };
8695
+ }
8696
+ return { _screenStream, cameraStream };
8685
8697
  } catch (error) {
8686
8698
  cancelCallback = null;
8687
8699
  cancelScreenCapture && await cancelScreenCapture();
@@ -8717,7 +8729,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8717
8729
  const _closeSession = (index) => {
8718
8730
  const finalCameraBuffer = cameraBuffer;
8719
8731
  const finalScreenBuffer = screenBuffer;
8720
- if (finalCameraBuffer.length == 0 || finalScreenBuffer.length == 0) {
8732
+ if (finalCameraBuffer.length == 0) {
8721
8733
  throw PROCTORING_NOT_STARTED;
8722
8734
  }
8723
8735
  const cameraFileName = `EP_${proctoringId}_camera_${index}.webm`;
@@ -8727,7 +8739,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8727
8739
  return { cameraFile, screenFile };
8728
8740
  };
8729
8741
  async function start(options = defaultProctoringOptions) {
8730
- const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false } = options;
8742
+ const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true } = options;
8731
8743
  if (proctoringConfig != void 0) {
8732
8744
  setConfiguration(proctoringConfig.account, proctoringConfig.containerName, proctoringConfig.sas);
8733
8745
  azureBlobUrl = proctoringConfig.azureBlobUrl;
@@ -8748,7 +8760,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8748
8760
  throw PROCTORING_ALREADY_STARTED;
8749
8761
  }
8750
8762
  try {
8751
- const { cameraStream, screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor });
8763
+ const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen });
8752
8764
  startTime = Date.now();
8753
8765
  startDate = new Date();
8754
8766
  const resp = await makeRequest({
@@ -8758,7 +8770,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8758
8770
  jwt: proctoringOptions.token
8759
8771
  });
8760
8772
  resp.cameraStream = cameraStream;
8761
- resp.screenStream = screenStream;
8773
+ resp.screenStream = _screenStream;
8762
8774
  await insertRecord("exams", {
8763
8775
  id: resp.id,
8764
8776
  sessions: []
@@ -8794,7 +8806,7 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8794
8806
  }
8795
8807
  async function resume(options = defaultProctoringOptions) {
8796
8808
  _clear();
8797
- const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false } = options;
8809
+ const { cameraId, microphoneId, allowOnlyFirstMonitor = true, allowMultipleMonitors = false, captureScreen = true } = options;
8798
8810
  if (!allowMultipleMonitors) {
8799
8811
  const hasMultipleMonitors = await checkIfhasMultipleMonitors();
8800
8812
  if (hasMultipleMonitors) {
@@ -8808,16 +8820,17 @@ function useProctoring(proctoringOptions, proctoringConfig) {
8808
8820
  if (!record) {
8809
8821
  throw PROCTORING_NOT_STARTED;
8810
8822
  }
8811
- const { cameraStream, screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor });
8823
+ const { cameraStream, _screenStream } = await _startCapture({ cameraId, microphoneId, allowOnlyFirstMonitor, captureScreen });
8812
8824
  proctoringId = record.id;
8813
8825
  startTime = Date.now();
8814
8826
  startDate = new Date();
8815
- return { cameraStream, screenStream };
8827
+ return { cameraStream, _screenStream };
8816
8828
  }
8817
8829
  async function finish(options = {}) {
8818
8830
  const { onProgress } = options;
8819
8831
  const record = await getRecord("exams");
8820
8832
  if (!record) {
8833
+ console.log("OXE");
8821
8834
  throw PROCTORING_NOT_STARTED;
8822
8835
  }
8823
8836
  onStopSharingScreenCallback = void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easyproctor",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "description": "Modulo web de gravação do EasyProctor",
5
5
  "main": "./index.js",
6
6
  "module": "./esm/index.js",