easyproctor-hml 2.5.34 → 2.5.36

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; }) {
@@ -9005,6 +9497,8 @@ var FaceDetection = class extends BaseDetection {
9005
9497
  }
9006
9498
  verify(result) {
9007
9499
  var _a2;
9500
+ console.log("this.numFacesSent", this.numFacesSent);
9501
+ console.log("result.detections.length", result.detections.length);
9008
9502
  if (((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.detectFace) && result.detections.length !== this.numFacesSent) {
9009
9503
  this.numFacesSent = result.detections.length;
9010
9504
  if (result.detections.length === 0) {
@@ -12258,6 +12752,7 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12258
12752
  buffer.push(e3.data);
12259
12753
  }
12260
12754
  if (stopped) {
12755
+ console.log("buildMediaRecorder ondataavailable stopped");
12261
12756
  resolvePromise && resolvePromise();
12262
12757
  }
12263
12758
  };
@@ -12327,6 +12822,9 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12327
12822
  if (mediaRecorder.state == "recording") {
12328
12823
  console.log("stopRecording Recorder est\xE1 em estado recording, iniciando stop");
12329
12824
  resolvePromise = resolve;
12825
+ mediaRecorder.onstop = () => {
12826
+ console.log("recorder onstop");
12827
+ };
12330
12828
  stopped = true;
12331
12829
  mediaRecorder.stop();
12332
12830
  } else {
@@ -12742,6 +13240,7 @@ var VolumeMeter = class {
12742
13240
 
12743
13241
  // src/new-flow/recorders/CameraRecorder.ts
12744
13242
  var import_jszip_min = __toESM(require_jszip_min());
13243
+ var import_fix_webm_duration = __toESM(require_fix_webm_duration());
12745
13244
  var CameraRecorder = class {
12746
13245
  constructor(options, videoOptions, paramsConfig, backend, backendToken) {
12747
13246
  this.blobs = [];
@@ -12792,6 +13291,7 @@ var CameraRecorder = class {
12792
13291
  this.hardwareStream = null;
12793
13292
  this.internalClonedStream = null;
12794
13293
  this.videoElement = null;
13294
+ this.duration = 0;
12795
13295
  this.currentRetries = 0;
12796
13296
  this.packageCount = 0;
12797
13297
  this.noiseWait = 20;
@@ -13016,10 +13516,17 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13016
13516
  console.log("Camera Recorder started OK");
13017
13517
  }
13018
13518
  async stopRecording() {
13019
- var _a2, _b, _c2;
13519
+ var _a2, _b, _c2, _d;
13020
13520
  console.log("Camera Recorder stopRecording");
13021
13521
  this.isCanvasLoopActive = false;
13522
+ this.faceDetection && this.faceDetection.detecting && this.faceDetection.stopDetection();
13523
+ this.objectDetection && this.objectDetection.detecting && this.objectDetection.stopDetection();
13524
+ clearInterval(this.imageInterval);
13525
+ clearInterval(this.sendFrameInterval);
13526
+ this.volumeMeter && this.volumeMeter.stop();
13527
+ this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
13022
13528
  this.recordingStop && await this.recordingStop();
13529
+ this.duration = Date.now() - ((_a2 = this.getStartTime()) == null ? void 0 : _a2.getTime()) || 0;
13023
13530
  try {
13024
13531
  if (this.animationFrameId) {
13025
13532
  cancelAnimationFrame(this.animationFrameId);
@@ -13037,28 +13544,22 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13037
13544
  this.hardwareStream = null;
13038
13545
  }
13039
13546
  if (this.videoElement) {
13040
- (_a2 = this.videoElement) == null ? void 0 : _a2.remove();
13547
+ (_b = this.videoElement) == null ? void 0 : _b.remove();
13041
13548
  this.videoElement = null;
13042
13549
  }
13043
13550
  if (this.video) {
13044
- (_b = this.video) == null ? void 0 : _b.remove();
13551
+ (_c2 = this.video) == null ? void 0 : _c2.remove();
13045
13552
  }
13046
13553
  if (this.canvas) {
13047
- (_c2 = this.canvas) == null ? void 0 : _c2.remove();
13554
+ (_d = this.canvas) == null ? void 0 : _d.remove();
13048
13555
  }
13049
13556
  } catch (e3) {
13050
13557
  console.error("Erro ao parar os streams de m\xEDdia.");
13051
13558
  }
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
13559
  if (this.options.proctoringType == "REALTIME" && this.upload && this.backendToken) {
13057
13560
  await this.sendPackage(this.filesToUpload);
13058
13561
  await this.filesToUpload.splice(0, this.filesToUpload.length);
13059
13562
  }
13060
- this.volumeMeter && this.volumeMeter.stop();
13061
- this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
13062
13563
  }
13063
13564
  async pauseRecording() {
13064
13565
  await this.recordingPause();
@@ -13192,6 +13693,15 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13192
13693
  const settings = this.cameraStream.getVideoTracks()[0].getSettings();
13193
13694
  const settingsAudio = this.cameraStream.getAudioTracks()[0].getSettings();
13194
13695
  if (this.options.proctoringType == "VIDEO" || this.options.proctoringType == "REALTIME" || this.options.proctoringType == "IMAGE" && ((_a2 = this.paramsConfig.imageBehaviourParameters) == null ? void 0 : _a2.saveVideo)) {
13696
+ const rawBlob = new Blob(this.blobs, {
13697
+ type: ((_b = this.recorderOptions) == null ? void 0 : _b.mimeType) || "video/webm"
13698
+ });
13699
+ const fixedBlob = await (0, import_fix_webm_duration.default)(rawBlob, this.duration);
13700
+ const file = new File(
13701
+ [fixedBlob],
13702
+ `EP_${session.id}_camera_0.webm`,
13703
+ { type: rawBlob.type }
13704
+ );
13195
13705
  session.addRecording({
13196
13706
  device: `Audio
13197
13707
  Sample Rate: ${settingsAudio.sampleRate}
@@ -13199,9 +13709,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13199
13709
 
13200
13710
  Video:
13201
13711
  ${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
- }),
13712
+ file,
13205
13713
  origin: "Camera" /* Camera */
13206
13714
  });
13207
13715
  }
@@ -15251,6 +15759,22 @@ var ProctoringUploader = class {
15251
15759
  }
15252
15760
  },
15253
15761
  token
15762
+ ).catch(
15763
+ async (e3) => {
15764
+ console.log("Upload File Error", e3), trackers.registerError(this.proctoringId, `Upload File
15765
+ Name: ${rec.file.name}
15766
+ Error: ${e3.message}
15767
+ Size: ${e3.error}`);
15768
+ await uploadService.upload(
15769
+ {
15770
+ file: rec.file,
15771
+ onProgress: (progress) => {
15772
+ if (onProgress) onProgress(progress);
15773
+ }
15774
+ },
15775
+ token
15776
+ );
15777
+ }
15254
15778
  );
15255
15779
  if (result) {
15256
15780
  let fileType = "";
@@ -17959,10 +18483,12 @@ registerProcessor("audio-processor", AudioProcessor);
17959
18483
  `;
17960
18484
 
17961
18485
  // src/new-flow/recorders/ScreenRecorder.ts
18486
+ var import_fix_webm_duration2 = __toESM(require_fix_webm_duration());
17962
18487
  var ScreenRecorder = class {
17963
18488
  constructor(options) {
17964
18489
  this.blobs = [];
17965
18490
  this.blobsFinal = [];
18491
+ this.duration = 0;
17966
18492
  this.options = options;
17967
18493
  }
17968
18494
  setProctoringId(proctoringId2) {
@@ -18044,15 +18570,24 @@ var ScreenRecorder = class {
18044
18570
  async resumeRecording() {
18045
18571
  }
18046
18572
  async stopRecording() {
18573
+ var _a2;
18047
18574
  this.recordingStop && await this.recordingStop();
18575
+ this.duration = Date.now() - ((_a2 = this.startTime) == null ? void 0 : _a2.getTime()) || 0;
18048
18576
  }
18049
18577
  async saveOnSession(session) {
18050
18578
  if (isMobileDevice()) return;
18579
+ const rawBlob = new Blob(this.blobs, {
18580
+ type: "video/webm"
18581
+ });
18582
+ const fixedBlob = await (0, import_fix_webm_duration2.default)(rawBlob, this.duration);
18583
+ const file = new File(
18584
+ [fixedBlob],
18585
+ `EP_${session.id}_screen_0.webm`,
18586
+ { type: rawBlob.type }
18587
+ );
18051
18588
  session.addRecording({
18052
18589
  device: "",
18053
- file: new File(this.blobs, `EP_${session.id}_screen_0.webm`, {
18054
- type: "video/webm"
18055
- }),
18590
+ file,
18056
18591
  origin: "Screen" /* Screen */
18057
18592
  });
18058
18593
  }
@@ -21978,7 +22513,7 @@ var Proctoring = class {
21978
22513
  begin: alert.begin,
21979
22514
  end: alert.end,
21980
22515
  warningCategoryEnum: this.convertRealtimeTypeToWarningType(alert.type),
21981
- alertImageBase64: await this.allRecorders.cameraRecorder.getCurrentImageBase64(),
22516
+ alertImageBase64: alert.description !== "face_stop" ? await this.allRecorders.cameraRecorder.getCurrentImageBase64() : "",
21982
22517
  retry: verifyCount < verifyMaxRetries - 1 ? true : false
21983
22518
  });
21984
22519
  return response;
@@ -22183,7 +22718,7 @@ Navigator: ${JSON.stringify(_navigator2)}`
22183
22718
  verifyingFace = true;
22184
22719
  verifyFirstFaceIntervalCount++;
22185
22720
  try {
22186
- var response = await this.backend.verifyFace(this.proctoringId, await this.allRecorders.cameraRecorder.getCurrentImageBase64(), verifyFirstFaceIntervalCount > 5 ? false : true);
22721
+ var response = await this.backend.verifyFace(this.proctoringId, await this.allRecorders.cameraRecorder.getCurrentImageBase64(), verifyFirstFaceIntervalCount > 2 ? false : true);
22187
22722
  verifyingFace = false;
22188
22723
  clearInterval(this.verifyFirstFaceInterval);
22189
22724
  } catch (error) {
@@ -22191,7 +22726,7 @@ Navigator: ${JSON.stringify(_navigator2)}`
22191
22726
  return;
22192
22727
  }
22193
22728
  }
22194
- }, 1500);
22729
+ }, 5e3);
22195
22730
  return startResponse;
22196
22731
  } catch (error) {
22197
22732
  console.log(error);