easyproctor 2.5.6 → 2.5.8

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
@@ -2400,6 +2400,493 @@ var require_jszip_min = __commonJS({
2400
2400
  }
2401
2401
  });
2402
2402
 
2403
+ // node_modules/fix-webm-duration/fix-webm-duration.js
2404
+ var require_fix_webm_duration = __commonJS({
2405
+ "node_modules/fix-webm-duration/fix-webm-duration.js"(exports, module) {
2406
+ (function(name, definition) {
2407
+ if (typeof define === "function" && define.amd) {
2408
+ define(definition);
2409
+ } else if (typeof module !== "undefined" && module.exports) {
2410
+ module.exports = definition();
2411
+ } else {
2412
+ window.ysFixWebmDuration = definition();
2413
+ }
2414
+ })("fix-webm-duration", function() {
2415
+ var sections = {
2416
+ 172351395: { name: "EBML", type: "Container" },
2417
+ 646: { name: "EBMLVersion", type: "Uint" },
2418
+ 759: { name: "EBMLReadVersion", type: "Uint" },
2419
+ 754: { name: "EBMLMaxIDLength", type: "Uint" },
2420
+ 755: { name: "EBMLMaxSizeLength", type: "Uint" },
2421
+ 642: { name: "DocType", type: "String" },
2422
+ 647: { name: "DocTypeVersion", type: "Uint" },
2423
+ 645: { name: "DocTypeReadVersion", type: "Uint" },
2424
+ 108: { name: "Void", type: "Binary" },
2425
+ 63: { name: "CRC-32", type: "Binary" },
2426
+ 190023271: { name: "SignatureSlot", type: "Container" },
2427
+ 16010: { name: "SignatureAlgo", type: "Uint" },
2428
+ 16026: { name: "SignatureHash", type: "Uint" },
2429
+ 16037: { name: "SignaturePublicKey", type: "Binary" },
2430
+ 16053: { name: "Signature", type: "Binary" },
2431
+ 15963: { name: "SignatureElements", type: "Container" },
2432
+ 15995: { name: "SignatureElementList", type: "Container" },
2433
+ 9522: { name: "SignedElement", type: "Binary" },
2434
+ 139690087: { name: "Segment", type: "Container" },
2435
+ 21863284: { name: "SeekHead", type: "Container" },
2436
+ 3515: { name: "Seek", type: "Container" },
2437
+ 5035: { name: "SeekID", type: "Binary" },
2438
+ 5036: { name: "SeekPosition", type: "Uint" },
2439
+ 88713574: { name: "Info", type: "Container" },
2440
+ 13220: { name: "SegmentUID", type: "Binary" },
2441
+ 13188: { name: "SegmentFilename", type: "String" },
2442
+ 1882403: { name: "PrevUID", type: "Binary" },
2443
+ 1868715: { name: "PrevFilename", type: "String" },
2444
+ 2013475: { name: "NextUID", type: "Binary" },
2445
+ 1999803: { name: "NextFilename", type: "String" },
2446
+ 1092: { name: "SegmentFamily", type: "Binary" },
2447
+ 10532: { name: "ChapterTranslate", type: "Container" },
2448
+ 10748: { name: "ChapterTranslateEditionUID", type: "Uint" },
2449
+ 10687: { name: "ChapterTranslateCodec", type: "Uint" },
2450
+ 10661: { name: "ChapterTranslateID", type: "Binary" },
2451
+ 710577: { name: "TimecodeScale", type: "Uint" },
2452
+ 1161: { name: "Duration", type: "Float" },
2453
+ 1121: { name: "DateUTC", type: "Date" },
2454
+ 15273: { name: "Title", type: "String" },
2455
+ 3456: { name: "MuxingApp", type: "String" },
2456
+ 5953: { name: "WritingApp", type: "String" },
2457
+ // 0xf43b675: { name: 'Cluster', type: 'Container' },
2458
+ 103: { name: "Timecode", type: "Uint" },
2459
+ 6228: { name: "SilentTracks", type: "Container" },
2460
+ 6359: { name: "SilentTrackNumber", type: "Uint" },
2461
+ 39: { name: "Position", type: "Uint" },
2462
+ 43: { name: "PrevSize", type: "Uint" },
2463
+ 35: { name: "SimpleBlock", type: "Binary" },
2464
+ 32: { name: "BlockGroup", type: "Container" },
2465
+ 33: { name: "Block", type: "Binary" },
2466
+ 34: { name: "BlockVirtual", type: "Binary" },
2467
+ 13729: { name: "BlockAdditions", type: "Container" },
2468
+ 38: { name: "BlockMore", type: "Container" },
2469
+ 110: { name: "BlockAddID", type: "Uint" },
2470
+ 37: { name: "BlockAdditional", type: "Binary" },
2471
+ 27: { name: "BlockDuration", type: "Uint" },
2472
+ 122: { name: "ReferencePriority", type: "Uint" },
2473
+ 123: { name: "ReferenceBlock", type: "Int" },
2474
+ 125: { name: "ReferenceVirtual", type: "Int" },
2475
+ 36: { name: "CodecState", type: "Binary" },
2476
+ 13730: { name: "DiscardPadding", type: "Int" },
2477
+ 14: { name: "Slices", type: "Container" },
2478
+ 104: { name: "TimeSlice", type: "Container" },
2479
+ 76: { name: "LaceNumber", type: "Uint" },
2480
+ 77: { name: "FrameNumber", type: "Uint" },
2481
+ 75: { name: "BlockAdditionID", type: "Uint" },
2482
+ 78: { name: "Delay", type: "Uint" },
2483
+ 79: { name: "SliceDuration", type: "Uint" },
2484
+ 72: { name: "ReferenceFrame", type: "Container" },
2485
+ 73: { name: "ReferenceOffset", type: "Uint" },
2486
+ 74: { name: "ReferenceTimeCode", type: "Uint" },
2487
+ 47: { name: "EncryptedBlock", type: "Binary" },
2488
+ 106212971: { name: "Tracks", type: "Container" },
2489
+ 46: { name: "TrackEntry", type: "Container" },
2490
+ 87: { name: "TrackNumber", type: "Uint" },
2491
+ 13253: { name: "TrackUID", type: "Uint" },
2492
+ 3: { name: "TrackType", type: "Uint" },
2493
+ 57: { name: "FlagEnabled", type: "Uint" },
2494
+ 8: { name: "FlagDefault", type: "Uint" },
2495
+ 5546: { name: "FlagForced", type: "Uint" },
2496
+ 28: { name: "FlagLacing", type: "Uint" },
2497
+ 11751: { name: "MinCache", type: "Uint" },
2498
+ 11768: { name: "MaxCache", type: "Uint" },
2499
+ 254851: { name: "DefaultDuration", type: "Uint" },
2500
+ 216698: { name: "DefaultDecodedFieldDuration", type: "Uint" },
2501
+ 209231: { name: "TrackTimecodeScale", type: "Float" },
2502
+ 4991: { name: "TrackOffset", type: "Int" },
2503
+ 5614: { name: "MaxBlockAdditionID", type: "Uint" },
2504
+ 4974: { name: "Name", type: "String" },
2505
+ 177564: { name: "Language", type: "String" },
2506
+ 6: { name: "CodecID", type: "String" },
2507
+ 9122: { name: "CodecPrivate", type: "Binary" },
2508
+ 362120: { name: "CodecName", type: "String" },
2509
+ 13382: { name: "AttachmentLink", type: "Uint" },
2510
+ 1742487: { name: "CodecSettings", type: "String" },
2511
+ 1785920: { name: "CodecInfoURL", type: "String" },
2512
+ 438848: { name: "CodecDownloadURL", type: "String" },
2513
+ 42: { name: "CodecDecodeAll", type: "Uint" },
2514
+ 12203: { name: "TrackOverlay", type: "Uint" },
2515
+ 5802: { name: "CodecDelay", type: "Uint" },
2516
+ 5819: { name: "SeekPreRoll", type: "Uint" },
2517
+ 9764: { name: "TrackTranslate", type: "Container" },
2518
+ 9980: { name: "TrackTranslateEditionUID", type: "Uint" },
2519
+ 9919: { name: "TrackTranslateCodec", type: "Uint" },
2520
+ 9893: { name: "TrackTranslateTrackID", type: "Binary" },
2521
+ 96: { name: "Video", type: "Container" },
2522
+ 26: { name: "FlagInterlaced", type: "Uint" },
2523
+ 5048: { name: "StereoMode", type: "Uint" },
2524
+ 5056: { name: "AlphaMode", type: "Uint" },
2525
+ 5049: { name: "OldStereoMode", type: "Uint" },
2526
+ 48: { name: "PixelWidth", type: "Uint" },
2527
+ 58: { name: "PixelHeight", type: "Uint" },
2528
+ 5290: { name: "PixelCropBottom", type: "Uint" },
2529
+ 5307: { name: "PixelCropTop", type: "Uint" },
2530
+ 5324: { name: "PixelCropLeft", type: "Uint" },
2531
+ 5341: { name: "PixelCropRight", type: "Uint" },
2532
+ 5296: { name: "DisplayWidth", type: "Uint" },
2533
+ 5306: { name: "DisplayHeight", type: "Uint" },
2534
+ 5298: { name: "DisplayUnit", type: "Uint" },
2535
+ 5299: { name: "AspectRatioType", type: "Uint" },
2536
+ 963876: { name: "ColourSpace", type: "Binary" },
2537
+ 1029411: { name: "GammaValue", type: "Float" },
2538
+ 230371: { name: "FrameRate", type: "Float" },
2539
+ 97: { name: "Audio", type: "Container" },
2540
+ 53: { name: "SamplingFrequency", type: "Float" },
2541
+ 14517: { name: "OutputSamplingFrequency", type: "Float" },
2542
+ 31: { name: "Channels", type: "Uint" },
2543
+ 15739: { name: "ChannelPositions", type: "Binary" },
2544
+ 8804: { name: "BitDepth", type: "Uint" },
2545
+ 98: { name: "TrackOperation", type: "Container" },
2546
+ 99: { name: "TrackCombinePlanes", type: "Container" },
2547
+ 100: { name: "TrackPlane", type: "Container" },
2548
+ 101: { name: "TrackPlaneUID", type: "Uint" },
2549
+ 102: { name: "TrackPlaneType", type: "Uint" },
2550
+ 105: { name: "TrackJoinBlocks", type: "Container" },
2551
+ 109: { name: "TrackJoinUID", type: "Uint" },
2552
+ 64: { name: "TrickTrackUID", type: "Uint" },
2553
+ 65: { name: "TrickTrackSegmentUID", type: "Binary" },
2554
+ 70: { name: "TrickTrackFlag", type: "Uint" },
2555
+ 71: { name: "TrickMasterTrackUID", type: "Uint" },
2556
+ 68: { name: "TrickMasterTrackSegmentUID", type: "Binary" },
2557
+ 11648: { name: "ContentEncodings", type: "Container" },
2558
+ 8768: { name: "ContentEncoding", type: "Container" },
2559
+ 4145: { name: "ContentEncodingOrder", type: "Uint" },
2560
+ 4146: { name: "ContentEncodingScope", type: "Uint" },
2561
+ 4147: { name: "ContentEncodingType", type: "Uint" },
2562
+ 4148: { name: "ContentCompression", type: "Container" },
2563
+ 596: { name: "ContentCompAlgo", type: "Uint" },
2564
+ 597: { name: "ContentCompSettings", type: "Binary" },
2565
+ 4149: { name: "ContentEncryption", type: "Container" },
2566
+ 2017: { name: "ContentEncAlgo", type: "Uint" },
2567
+ 2018: { name: "ContentEncKeyID", type: "Binary" },
2568
+ 2019: { name: "ContentSignature", type: "Binary" },
2569
+ 2020: { name: "ContentSigKeyID", type: "Binary" },
2570
+ 2021: { name: "ContentSigAlgo", type: "Uint" },
2571
+ 2022: { name: "ContentSigHashAlgo", type: "Uint" },
2572
+ 206814059: { name: "Cues", type: "Container" },
2573
+ 59: { name: "CuePoint", type: "Container" },
2574
+ 51: { name: "CueTime", type: "Uint" },
2575
+ 55: { name: "CueTrackPositions", type: "Container" },
2576
+ 119: { name: "CueTrack", type: "Uint" },
2577
+ 113: { name: "CueClusterPosition", type: "Uint" },
2578
+ 112: { name: "CueRelativePosition", type: "Uint" },
2579
+ 50: { name: "CueDuration", type: "Uint" },
2580
+ 4984: { name: "CueBlockNumber", type: "Uint" },
2581
+ 106: { name: "CueCodecState", type: "Uint" },
2582
+ 91: { name: "CueReference", type: "Container" },
2583
+ 22: { name: "CueRefTime", type: "Uint" },
2584
+ 23: { name: "CueRefCluster", type: "Uint" },
2585
+ 4959: { name: "CueRefNumber", type: "Uint" },
2586
+ 107: { name: "CueRefCodecState", type: "Uint" },
2587
+ 155296873: { name: "Attachments", type: "Container" },
2588
+ 8615: { name: "AttachedFile", type: "Container" },
2589
+ 1662: { name: "FileDescription", type: "String" },
2590
+ 1646: { name: "FileName", type: "String" },
2591
+ 1632: { name: "FileMimeType", type: "String" },
2592
+ 1628: { name: "FileData", type: "Binary" },
2593
+ 1710: { name: "FileUID", type: "Uint" },
2594
+ 1653: { name: "FileReferral", type: "Binary" },
2595
+ 1633: { name: "FileUsedStartTime", type: "Uint" },
2596
+ 1634: { name: "FileUsedEndTime", type: "Uint" },
2597
+ 4433776: { name: "Chapters", type: "Container" },
2598
+ 1465: { name: "EditionEntry", type: "Container" },
2599
+ 1468: { name: "EditionUID", type: "Uint" },
2600
+ 1469: { name: "EditionFlagHidden", type: "Uint" },
2601
+ 1499: { name: "EditionFlagDefault", type: "Uint" },
2602
+ 1501: { name: "EditionFlagOrdered", type: "Uint" },
2603
+ 54: { name: "ChapterAtom", type: "Container" },
2604
+ 13252: { name: "ChapterUID", type: "Uint" },
2605
+ 5716: { name: "ChapterStringUID", type: "String" },
2606
+ 17: { name: "ChapterTimeStart", type: "Uint" },
2607
+ 18: { name: "ChapterTimeEnd", type: "Uint" },
2608
+ 24: { name: "ChapterFlagHidden", type: "Uint" },
2609
+ 1432: { name: "ChapterFlagEnabled", type: "Uint" },
2610
+ 11879: { name: "ChapterSegmentUID", type: "Binary" },
2611
+ 11964: { name: "ChapterSegmentEditionUID", type: "Uint" },
2612
+ 9155: { name: "ChapterPhysicalEquiv", type: "Uint" },
2613
+ 15: { name: "ChapterTrack", type: "Container" },
2614
+ 9: { name: "ChapterTrackNumber", type: "Uint" },
2615
+ 0: { name: "ChapterDisplay", type: "Container" },
2616
+ 5: { name: "ChapString", type: "String" },
2617
+ 892: { name: "ChapLanguage", type: "String" },
2618
+ 894: { name: "ChapCountry", type: "String" },
2619
+ 10564: { name: "ChapProcess", type: "Container" },
2620
+ 10581: { name: "ChapProcessCodecID", type: "Uint" },
2621
+ 1293: { name: "ChapProcessPrivate", type: "Binary" },
2622
+ 10513: { name: "ChapProcessCommand", type: "Container" },
2623
+ 10530: { name: "ChapProcessTime", type: "Uint" },
2624
+ 10547: { name: "ChapProcessData", type: "Binary" },
2625
+ 39109479: { name: "Tags", type: "Container" },
2626
+ 13171: { name: "Tag", type: "Container" },
2627
+ 9152: { name: "Targets", type: "Container" },
2628
+ 10442: { name: "TargetTypeValue", type: "Uint" },
2629
+ 9162: { name: "TargetType", type: "String" },
2630
+ 9157: { name: "TagTrackUID", type: "Uint" },
2631
+ 9161: { name: "TagEditionUID", type: "Uint" },
2632
+ 9156: { name: "TagChapterUID", type: "Uint" },
2633
+ 9158: { name: "TagAttachmentUID", type: "Uint" },
2634
+ 10184: { name: "SimpleTag", type: "Container" },
2635
+ 1443: { name: "TagName", type: "String" },
2636
+ 1146: { name: "TagLanguage", type: "String" },
2637
+ 1156: { name: "TagDefault", type: "Uint" },
2638
+ 1159: { name: "TagString", type: "String" },
2639
+ 1157: { name: "TagBinary", type: "Binary" }
2640
+ };
2641
+ function doInherit(newClass, baseClass) {
2642
+ newClass.prototype = Object.create(baseClass.prototype);
2643
+ newClass.prototype.constructor = newClass;
2644
+ }
2645
+ function WebmBase(name, type) {
2646
+ this.name = name || "Unknown";
2647
+ this.type = type || "Unknown";
2648
+ }
2649
+ WebmBase.prototype.updateBySource = function() {
2650
+ };
2651
+ WebmBase.prototype.setSource = function(source) {
2652
+ this.source = source;
2653
+ this.updateBySource();
2654
+ };
2655
+ WebmBase.prototype.updateByData = function() {
2656
+ };
2657
+ WebmBase.prototype.setData = function(data) {
2658
+ this.data = data;
2659
+ this.updateByData();
2660
+ };
2661
+ function WebmUint(name, type) {
2662
+ WebmBase.call(this, name, type || "Uint");
2663
+ }
2664
+ doInherit(WebmUint, WebmBase);
2665
+ function padHex(hex) {
2666
+ return hex.length % 2 === 1 ? "0" + hex : hex;
2667
+ }
2668
+ WebmUint.prototype.updateBySource = function() {
2669
+ this.data = "";
2670
+ for (var i3 = 0; i3 < this.source.length; i3++) {
2671
+ var hex = this.source[i3].toString(16);
2672
+ this.data += padHex(hex);
2673
+ }
2674
+ };
2675
+ WebmUint.prototype.updateByData = function() {
2676
+ var length = this.data.length / 2;
2677
+ this.source = new Uint8Array(length);
2678
+ for (var i3 = 0; i3 < length; i3++) {
2679
+ var hex = this.data.substr(i3 * 2, 2);
2680
+ this.source[i3] = parseInt(hex, 16);
2681
+ }
2682
+ };
2683
+ WebmUint.prototype.getValue = function() {
2684
+ return parseInt(this.data, 16);
2685
+ };
2686
+ WebmUint.prototype.setValue = function(value) {
2687
+ this.setData(padHex(value.toString(16)));
2688
+ };
2689
+ function WebmFloat(name, type) {
2690
+ WebmBase.call(this, name, type || "Float");
2691
+ }
2692
+ doInherit(WebmFloat, WebmBase);
2693
+ WebmFloat.prototype.getFloatArrayType = function() {
2694
+ return this.source && this.source.length === 4 ? Float32Array : Float64Array;
2695
+ };
2696
+ WebmFloat.prototype.updateBySource = function() {
2697
+ var byteArray = this.source.reverse();
2698
+ var floatArrayType = this.getFloatArrayType();
2699
+ var floatArray = new floatArrayType(byteArray.buffer);
2700
+ this.data = floatArray[0];
2701
+ };
2702
+ WebmFloat.prototype.updateByData = function() {
2703
+ var floatArrayType = this.getFloatArrayType();
2704
+ var floatArray = new floatArrayType([this.data]);
2705
+ var byteArray = new Uint8Array(floatArray.buffer);
2706
+ this.source = byteArray.reverse();
2707
+ };
2708
+ WebmFloat.prototype.getValue = function() {
2709
+ return this.data;
2710
+ };
2711
+ WebmFloat.prototype.setValue = function(value) {
2712
+ this.setData(value);
2713
+ };
2714
+ function WebmContainer(name, type) {
2715
+ WebmBase.call(this, name, type || "Container");
2716
+ }
2717
+ doInherit(WebmContainer, WebmBase);
2718
+ WebmContainer.prototype.readByte = function() {
2719
+ return this.source[this.offset++];
2720
+ };
2721
+ WebmContainer.prototype.readUint = function() {
2722
+ var firstByte = this.readByte();
2723
+ var bytes = 8 - firstByte.toString(2).length;
2724
+ var value = firstByte - (1 << 7 - bytes);
2725
+ for (var i3 = 0; i3 < bytes; i3++) {
2726
+ value *= 256;
2727
+ value += this.readByte();
2728
+ }
2729
+ return value;
2730
+ };
2731
+ WebmContainer.prototype.updateBySource = function() {
2732
+ this.data = [];
2733
+ for (this.offset = 0; this.offset < this.source.length; this.offset = end) {
2734
+ var id = this.readUint();
2735
+ var len = this.readUint();
2736
+ var end = Math.min(this.offset + len, this.source.length);
2737
+ var data = this.source.slice(this.offset, end);
2738
+ var info = sections[id] || { name: "Unknown", type: "Unknown" };
2739
+ var ctr = WebmBase;
2740
+ switch (info.type) {
2741
+ case "Container":
2742
+ ctr = WebmContainer;
2743
+ break;
2744
+ case "Uint":
2745
+ ctr = WebmUint;
2746
+ break;
2747
+ case "Float":
2748
+ ctr = WebmFloat;
2749
+ break;
2750
+ }
2751
+ var section = new ctr(info.name, info.type);
2752
+ section.setSource(data);
2753
+ this.data.push({
2754
+ id,
2755
+ idHex: id.toString(16),
2756
+ data: section
2757
+ });
2758
+ }
2759
+ };
2760
+ WebmContainer.prototype.writeUint = function(x3, draft) {
2761
+ for (var bytes = 1, flag = 128; x3 >= flag && bytes < 8; bytes++, flag *= 128) {
2762
+ }
2763
+ if (!draft) {
2764
+ var value = flag + x3;
2765
+ for (var i3 = bytes - 1; i3 >= 0; i3--) {
2766
+ var c3 = value % 256;
2767
+ this.source[this.offset + i3] = c3;
2768
+ value = (value - c3) / 256;
2769
+ }
2770
+ }
2771
+ this.offset += bytes;
2772
+ };
2773
+ WebmContainer.prototype.writeSections = function(draft) {
2774
+ this.offset = 0;
2775
+ for (var i3 = 0; i3 < this.data.length; i3++) {
2776
+ var section = this.data[i3], content = section.data.source, contentLength = content.length;
2777
+ this.writeUint(section.id, draft);
2778
+ this.writeUint(contentLength, draft);
2779
+ if (!draft) {
2780
+ this.source.set(content, this.offset);
2781
+ }
2782
+ this.offset += contentLength;
2783
+ }
2784
+ return this.offset;
2785
+ };
2786
+ WebmContainer.prototype.updateByData = function() {
2787
+ var length = this.writeSections("draft");
2788
+ this.source = new Uint8Array(length);
2789
+ this.writeSections();
2790
+ };
2791
+ WebmContainer.prototype.getSectionById = function(id) {
2792
+ for (var i3 = 0; i3 < this.data.length; i3++) {
2793
+ var section = this.data[i3];
2794
+ if (section.id === id) {
2795
+ return section.data;
2796
+ }
2797
+ }
2798
+ return null;
2799
+ };
2800
+ function WebmFile(source) {
2801
+ WebmContainer.call(this, "File", "File");
2802
+ this.setSource(source);
2803
+ }
2804
+ doInherit(WebmFile, WebmContainer);
2805
+ WebmFile.prototype.fixDuration = function(duration, options) {
2806
+ var logger = options && options.logger;
2807
+ if (logger === void 0) {
2808
+ logger = function(message) {
2809
+ console.log(message);
2810
+ };
2811
+ } else if (!logger) {
2812
+ logger = function() {
2813
+ };
2814
+ }
2815
+ var segmentSection = this.getSectionById(139690087);
2816
+ if (!segmentSection) {
2817
+ logger("[fix-webm-duration] Segment section is missing");
2818
+ return false;
2819
+ }
2820
+ var infoSection = segmentSection.getSectionById(88713574);
2821
+ if (!infoSection) {
2822
+ logger("[fix-webm-duration] Info section is missing");
2823
+ return false;
2824
+ }
2825
+ var timeScaleSection = infoSection.getSectionById(710577);
2826
+ if (!timeScaleSection) {
2827
+ logger("[fix-webm-duration] TimecodeScale section is missing");
2828
+ return false;
2829
+ }
2830
+ var durationSection = infoSection.getSectionById(1161);
2831
+ if (durationSection) {
2832
+ if (durationSection.getValue() <= 0) {
2833
+ logger(`[fix-webm-duration] Duration section is present, but the value is ${durationSection.getValue()}`);
2834
+ durationSection.setValue(duration);
2835
+ } else {
2836
+ logger(`[fix-webm-duration] Duration section is present, and the value is ${durationSection.getValue()}`);
2837
+ return false;
2838
+ }
2839
+ } else {
2840
+ logger("[fix-webm-duration] Duration section is missing");
2841
+ durationSection = new WebmFloat("Duration", "Float");
2842
+ durationSection.setValue(duration);
2843
+ infoSection.data.push({
2844
+ id: 1161,
2845
+ data: durationSection
2846
+ });
2847
+ }
2848
+ timeScaleSection.setValue(1e6);
2849
+ infoSection.updateByData();
2850
+ segmentSection.updateByData();
2851
+ this.updateByData();
2852
+ return true;
2853
+ };
2854
+ WebmFile.prototype.toBlob = function(mimeType) {
2855
+ return new Blob([this.source.buffer], { type: mimeType || "video/webm" });
2856
+ };
2857
+ function fixWebmDuration3(blob, duration, callback, options) {
2858
+ if (typeof callback === "object") {
2859
+ options = callback;
2860
+ callback = void 0;
2861
+ }
2862
+ if (!callback) {
2863
+ return new Promise(function(resolve) {
2864
+ fixWebmDuration3(blob, duration, resolve, options);
2865
+ });
2866
+ }
2867
+ try {
2868
+ var reader = new FileReader();
2869
+ reader.onloadend = function() {
2870
+ try {
2871
+ var file = new WebmFile(new Uint8Array(reader.result));
2872
+ if (file.fixDuration(duration, options)) {
2873
+ blob = file.toBlob(blob.type);
2874
+ }
2875
+ } catch (ex) {
2876
+ }
2877
+ callback(blob);
2878
+ };
2879
+ reader.readAsArrayBuffer(blob);
2880
+ } catch (ex) {
2881
+ callback(blob);
2882
+ }
2883
+ }
2884
+ fixWebmDuration3.default = fixWebmDuration3;
2885
+ return fixWebmDuration3;
2886
+ });
2887
+ }
2888
+ });
2889
+
2403
2890
  // node_modules/file-saver/dist/FileSaver.min.js
2404
2891
  var require_FileSaver_min = __commonJS({
2405
2892
  "node_modules/file-saver/dist/FileSaver.min.js"(exports, module) {
@@ -8658,6 +9145,7 @@ var BaseDetection = class {
8658
9145
  // objectDetection
8659
9146
  runningMode: this.runningMode
8660
9147
  });
9148
+ console.log("BaseDetection initializeDetector", this.detectorType);
8661
9149
  }
8662
9150
  stopDetection() {
8663
9151
  this.animationFrameId && clearTimeout(this.animationFrameId);
@@ -8669,6 +9157,7 @@ var BaseDetection = class {
8669
9157
  }
8670
9158
  enableCam(cameraStream) {
8671
9159
  var _a2;
9160
+ console.log("BaseDetection enableCam");
8672
9161
  if (!this.detector) {
8673
9162
  console.log("Wait! Detector not loaded yet.");
8674
9163
  return;
@@ -8710,6 +9199,7 @@ var BaseDetection = class {
8710
9199
  }
8711
9200
  `;
8712
9201
  document.getElementsByTagName("head")[0].appendChild(style);
9202
+ console.log("BaseDetection enableCam OK");
8713
9203
  }
8714
9204
  async predictWebcam() {
8715
9205
  if (this.lastVideoTime === -1) {
@@ -8838,11 +9328,13 @@ var FaceDetection = class extends BaseDetection {
8838
9328
  );
8839
9329
  this.emmitedPositionAlert = false;
8840
9330
  this.emmitedFaceAlert = false;
9331
+ console.log("FaceDetection constructor");
9332
+ this.numFacesSent = -1;
8841
9333
  }
8842
9334
  stopDetection() {
8843
9335
  super.stopDetection();
8844
9336
  if (this.emmitedFaceAlert) {
8845
- this.handleOk("face_ok", "face_detection_on_stream");
9337
+ this.handleOk("face_stop", "face_detection_on_stream");
8846
9338
  }
8847
9339
  }
8848
9340
  // displayVideoDetections(result: { detections: any; }) {
@@ -12258,6 +12750,7 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12258
12750
  buffer.push(e3.data);
12259
12751
  }
12260
12752
  if (stopped) {
12753
+ console.log("buildMediaRecorder ondataavailable stopped");
12261
12754
  resolvePromise && resolvePromise();
12262
12755
  }
12263
12756
  };
@@ -12327,6 +12820,9 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12327
12820
  if (mediaRecorder.state == "recording") {
12328
12821
  console.log("stopRecording Recorder est\xE1 em estado recording, iniciando stop");
12329
12822
  resolvePromise = resolve;
12823
+ mediaRecorder.onstop = () => {
12824
+ console.log("recorder onstop");
12825
+ };
12330
12826
  stopped = true;
12331
12827
  mediaRecorder.stop();
12332
12828
  } else {
@@ -12742,6 +13238,7 @@ var VolumeMeter = class {
12742
13238
 
12743
13239
  // src/new-flow/recorders/CameraRecorder.ts
12744
13240
  var import_jszip_min = __toESM(require_jszip_min());
13241
+ var import_fix_webm_duration = __toESM(require_fix_webm_duration());
12745
13242
  var CameraRecorder = class {
12746
13243
  constructor(options, videoOptions, paramsConfig, backend, backendToken) {
12747
13244
  this.blobs = [];
@@ -12792,6 +13289,7 @@ var CameraRecorder = class {
12792
13289
  this.hardwareStream = null;
12793
13290
  this.internalClonedStream = null;
12794
13291
  this.videoElement = null;
13292
+ this.duration = 0;
12795
13293
  this.currentRetries = 0;
12796
13294
  this.packageCount = 0;
12797
13295
  this.noiseWait = 20;
@@ -13016,10 +13514,17 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13016
13514
  console.log("Camera Recorder started OK");
13017
13515
  }
13018
13516
  async stopRecording() {
13019
- var _a2, _b, _c2;
13517
+ var _a2, _b, _c2, _d;
13020
13518
  console.log("Camera Recorder stopRecording");
13021
13519
  this.isCanvasLoopActive = false;
13520
+ this.faceDetection && this.faceDetection.detecting && this.faceDetection.stopDetection();
13521
+ this.objectDetection && this.objectDetection.detecting && this.objectDetection.stopDetection();
13522
+ clearInterval(this.imageInterval);
13523
+ clearInterval(this.sendFrameInterval);
13524
+ this.volumeMeter && this.volumeMeter.stop();
13525
+ this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
13022
13526
  this.recordingStop && await this.recordingStop();
13527
+ this.duration = Date.now() - ((_a2 = this.getStartTime()) == null ? void 0 : _a2.getTime()) || 0;
13023
13528
  try {
13024
13529
  if (this.animationFrameId) {
13025
13530
  cancelAnimationFrame(this.animationFrameId);
@@ -13037,28 +13542,22 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13037
13542
  this.hardwareStream = null;
13038
13543
  }
13039
13544
  if (this.videoElement) {
13040
- (_a2 = this.videoElement) == null ? void 0 : _a2.remove();
13545
+ (_b = this.videoElement) == null ? void 0 : _b.remove();
13041
13546
  this.videoElement = null;
13042
13547
  }
13043
13548
  if (this.video) {
13044
- (_b = this.video) == null ? void 0 : _b.remove();
13549
+ (_c2 = this.video) == null ? void 0 : _c2.remove();
13045
13550
  }
13046
13551
  if (this.canvas) {
13047
- (_c2 = this.canvas) == null ? void 0 : _c2.remove();
13552
+ (_d = this.canvas) == null ? void 0 : _d.remove();
13048
13553
  }
13049
13554
  } catch (e3) {
13050
13555
  console.error("Erro ao parar os streams de m\xEDdia.");
13051
13556
  }
13052
- this.faceDetection && this.faceDetection.detecting && this.faceDetection.stopDetection();
13053
- this.objectDetection && this.objectDetection.detecting && this.objectDetection.stopDetection();
13054
- clearInterval(this.imageInterval);
13055
- clearInterval(this.sendFrameInterval);
13056
13557
  if (this.options.proctoringType == "REALTIME" && this.upload && this.backendToken) {
13057
13558
  await this.sendPackage(this.filesToUpload);
13058
13559
  await this.filesToUpload.splice(0, this.filesToUpload.length);
13059
13560
  }
13060
- this.volumeMeter && this.volumeMeter.stop();
13061
- this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
13062
13561
  }
13063
13562
  async pauseRecording() {
13064
13563
  await this.recordingPause();
@@ -13192,6 +13691,15 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13192
13691
  const settings = this.cameraStream.getVideoTracks()[0].getSettings();
13193
13692
  const settingsAudio = this.cameraStream.getAudioTracks()[0].getSettings();
13194
13693
  if (this.options.proctoringType == "VIDEO" || this.options.proctoringType == "REALTIME" || this.options.proctoringType == "IMAGE" && ((_a2 = this.paramsConfig.imageBehaviourParameters) == null ? void 0 : _a2.saveVideo)) {
13694
+ const rawBlob = new Blob(this.blobs, {
13695
+ type: ((_b = this.recorderOptions) == null ? void 0 : _b.mimeType) || "video/webm"
13696
+ });
13697
+ const fixedBlob = await (0, import_fix_webm_duration.default)(rawBlob, this.duration);
13698
+ const file = new File(
13699
+ [rawBlob],
13700
+ `EP_${session.id}_camera_0.webm`,
13701
+ { type: rawBlob.type }
13702
+ );
13195
13703
  session.addRecording({
13196
13704
  device: `Audio
13197
13705
  Sample Rate: ${settingsAudio.sampleRate}
@@ -13199,9 +13707,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13199
13707
 
13200
13708
  Video:
13201
13709
  ${JSON.stringify(this.recorderOptions)}`,
13202
- file: new File(this.blobs, `EP_${session.id}_camera_0.webm`, {
13203
- type: ((_b = this.recorderOptions) == null ? void 0 : _b.mimeType) || "video/webm"
13204
- }),
13710
+ file,
13205
13711
  origin: "Camera" /* Camera */
13206
13712
  });
13207
13713
  }
@@ -15168,6 +15674,22 @@ var ProctoringUploader = class {
15168
15674
  }
15169
15675
  },
15170
15676
  token
15677
+ ).catch(
15678
+ async (e3) => {
15679
+ console.log("Upload File Error", e3), trackers.registerError(this.proctoringId, `Upload File
15680
+ Name: ${rec.file.name}
15681
+ Error: ${e3.message}
15682
+ Size: ${e3.error}`);
15683
+ await uploadService.upload(
15684
+ {
15685
+ file: rec.file,
15686
+ onProgress: (progress) => {
15687
+ if (onProgress) onProgress(progress);
15688
+ }
15689
+ },
15690
+ token
15691
+ );
15692
+ }
15171
15693
  );
15172
15694
  if (result) {
15173
15695
  let fileType = "";
@@ -17876,10 +18398,12 @@ registerProcessor("audio-processor", AudioProcessor);
17876
18398
  `;
17877
18399
 
17878
18400
  // src/new-flow/recorders/ScreenRecorder.ts
18401
+ var import_fix_webm_duration2 = __toESM(require_fix_webm_duration());
17879
18402
  var ScreenRecorder = class {
17880
18403
  constructor(options) {
17881
18404
  this.blobs = [];
17882
18405
  this.blobsFinal = [];
18406
+ this.duration = 0;
17883
18407
  this.options = options;
17884
18408
  }
17885
18409
  setProctoringId(proctoringId2) {
@@ -17961,15 +18485,24 @@ var ScreenRecorder = class {
17961
18485
  async resumeRecording() {
17962
18486
  }
17963
18487
  async stopRecording() {
18488
+ var _a2;
17964
18489
  this.recordingStop && await this.recordingStop();
18490
+ this.duration = Date.now() - ((_a2 = this.startTime) == null ? void 0 : _a2.getTime()) || 0;
17965
18491
  }
17966
18492
  async saveOnSession(session) {
17967
18493
  if (isMobileDevice()) return;
18494
+ const rawBlob = new Blob(this.blobs, {
18495
+ type: "video/webm"
18496
+ });
18497
+ const fixedBlob = await (0, import_fix_webm_duration2.default)(rawBlob, this.duration);
18498
+ const file = new File(
18499
+ [fixedBlob],
18500
+ `EP_${session.id}_screen_0.webm`,
18501
+ { type: rawBlob.type }
18502
+ );
17968
18503
  session.addRecording({
17969
18504
  device: "",
17970
- file: new File(this.blobs, `EP_${session.id}_screen_0.webm`, {
17971
- type: "video/webm"
17972
- }),
18505
+ file,
17973
18506
  origin: "Screen" /* Screen */
17974
18507
  });
17975
18508
  }
@@ -21768,7 +22301,8 @@ var Proctoring = class {
21768
22301
  this.onChangeDevicesCallback = (devices) => {
21769
22302
  return;
21770
22303
  };
21771
- this.onRealtimeAlertsCallback = (response) => {
22304
+ this.onRealtimeAlertsCallback = async (response) => {
22305
+ await this.internalOnRealtimeAlerts(response);
21772
22306
  return;
21773
22307
  };
21774
22308
  this.onBufferSizeErrorCallback = (cameraStream) => {
@@ -21895,7 +22429,7 @@ var Proctoring = class {
21895
22429
  begin: alert.begin,
21896
22430
  end: alert.end,
21897
22431
  warningCategoryEnum: this.convertRealtimeTypeToWarningType(alert.type),
21898
- alertImageBase64: await this.allRecorders.cameraRecorder.getCurrentImageBase64(),
22432
+ alertImageBase64: alert.description !== "face_stop" ? await this.allRecorders.cameraRecorder.getCurrentImageBase64() : "",
21899
22433
  retry: verifyCount < verifyMaxRetries - 1 ? true : false
21900
22434
  });
21901
22435
  return response;
@@ -21906,23 +22440,26 @@ var Proctoring = class {
21906
22440
  };
21907
22441
  await verifyFace(1);
21908
22442
  }
22443
+ async internalOnRealtimeAlerts(response) {
22444
+ if (this.sessionOptions.proctoringType === "REALTIME" && (response.type === "face_detection_on_stream" || response.type === "person_detection_on_stream" || response.type === "lost_focus" || response.type === "focus")) {
22445
+ if (response.status === "ALERT") {
22446
+ await this.backend.startRealtimeAlert({
22447
+ proctoringId: this.proctoringId,
22448
+ begin: response.begin,
22449
+ end: response.end,
22450
+ alert: this.convertRealtimeCategoryToAlertCategory(response.category)
22451
+ });
22452
+ } else if (response.status === "OK") {
22453
+ await this.stopRealtimeAlert(response);
22454
+ }
22455
+ }
22456
+ }
21909
22457
  async onRealtimeAlerts(options = {}) {
21910
22458
  this.setOnLostFocusAlertRecorderCallback();
21911
22459
  this.setOnFocusAlertRecorderCallback();
21912
22460
  this.onRealtimeAlertsCallback = async (response) => {
22461
+ await this.internalOnRealtimeAlerts(response);
21913
22462
  options.data && options.data(response);
21914
- if (this.sessionOptions.proctoringType === "REALTIME" && (response.type === "face_detection_on_stream" || response.type === "person_detection_on_stream" || response.type === "lost_focus" || response.type === "focus")) {
21915
- if (response.status === "ALERT") {
21916
- await this.backend.startRealtimeAlert({
21917
- proctoringId: this.proctoringId,
21918
- begin: response.begin,
21919
- end: response.end,
21920
- alert: this.convertRealtimeCategoryToAlertCategory(response.category)
21921
- });
21922
- } else if (response.status === "OK") {
21923
- await this.stopRealtimeAlert(response);
21924
- }
21925
- }
21926
22463
  };
21927
22464
  }
21928
22465
  setOnBufferSizeErrorCallback(cb) {
@@ -22097,7 +22634,7 @@ Navigator: ${JSON.stringify(_navigator2)}`
22097
22634
  verifyingFace = true;
22098
22635
  verifyFirstFaceIntervalCount++;
22099
22636
  try {
22100
- var response = await this.backend.verifyFace(this.proctoringId, await this.allRecorders.cameraRecorder.getCurrentImageBase64(), verifyFirstFaceIntervalCount > 5 ? false : true);
22637
+ var response = await this.backend.verifyFace(this.proctoringId, await this.allRecorders.cameraRecorder.getCurrentImageBase64(), verifyFirstFaceIntervalCount > 2 ? false : true);
22101
22638
  verifyingFace = false;
22102
22639
  clearInterval(this.verifyFirstFaceInterval);
22103
22640
  } catch (error) {
@@ -22105,7 +22642,7 @@ Navigator: ${JSON.stringify(_navigator2)}`
22105
22642
  return;
22106
22643
  }
22107
22644
  }
22108
- }, 1500);
22645
+ }, 5e3);
22109
22646
  return startResponse;
22110
22647
  } catch (error) {
22111
22648
  console.log(error);