@loaders.gl/video 3.3.0-alpha.4 → 3.3.0-alpha.6

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.
@@ -1,3 +1,5 @@
1
+
2
+
1
3
  var utils = {
2
4
  URL: globalThis.URL || globalThis.webkitURL || globalThis.mozURL || globalThis.msURL,
3
5
  getUserMedia: function () {
@@ -9,21 +11,17 @@ var utils = {
9
11
  requestTimeout: function requestTimeout(callback, delay) {
10
12
  callback = callback || utils.noop;
11
13
  delay = delay || 0;
12
-
13
14
  if (!utils.requestAnimFrame) {
14
15
  return setTimeout(callback, delay);
15
16
  }
16
-
17
17
  const start = new Date().getTime();
18
18
  const handle = new Object();
19
19
  const requestAnimFrame = utils.requestAnimFrame;
20
-
21
20
  const loop = function loop() {
22
21
  const current = new Date().getTime();
23
22
  const delta = current - start;
24
23
  delta >= delay ? callback.call() : handle.value = requestAnimFrame(loop);
25
24
  };
26
-
27
25
  handle.value = requestAnimFrame(loop);
28
26
  return handle;
29
27
  },
@@ -41,7 +39,6 @@ var utils = {
41
39
  let enc2 = void 0;
42
40
  let enc3 = void 0;
43
41
  let enc4 = void 0;
44
-
45
42
  while (i < l) {
46
43
  chr1 = input.charCodeAt(i++);
47
44
  chr2 = input.charCodeAt(i++);
@@ -50,19 +47,15 @@ var utils = {
50
47
  enc2 = (chr1 & 3) << 4 | chr2 >> 4;
51
48
  enc3 = (chr2 & 15) << 2 | chr3 >> 6;
52
49
  enc4 = chr3 & 63;
53
-
54
50
  if (isNaN(chr2)) {
55
51
  enc3 = enc4 = 64;
56
52
  } else if (isNaN(chr3)) {
57
53
  enc4 = 64;
58
54
  }
59
-
60
55
  output = output + key.charAt(enc1) + key.charAt(enc2) + key.charAt(enc3) + key.charAt(enc4);
61
56
  }
62
-
63
57
  return output;
64
58
  };
65
-
66
59
  return btoa ? btoa.bind(globalThis) : utils.noop;
67
60
  }(),
68
61
  isObject: function isObject(obj) {
@@ -109,7 +102,6 @@ var utils = {
109
102
  ogg: false,
110
103
  webm: false
111
104
  };
112
-
113
105
  try {
114
106
  if (testEl && testEl.canPlayType) {
115
107
  supportObj.mp4 = testEl.canPlayType('video/mp4; codecs="mp4v.20.8"') !== '';
@@ -119,7 +111,6 @@ var utils = {
119
111
  supportObj.webm = testEl.canPlayType('video/webm; codecs="vp8, vorbis"') !== -1;
120
112
  }
121
113
  } catch (e) {}
122
-
123
114
  return supportObj;
124
115
  }()
125
116
  },
@@ -127,11 +118,9 @@ var utils = {
127
118
  each: function each(collection, callback) {
128
119
  let x = void 0;
129
120
  let len = void 0;
130
-
131
121
  if (utils.isArray(collection)) {
132
122
  x = -1;
133
123
  len = collection.length;
134
-
135
124
  while (++x < len) {
136
125
  if (callback(x, collection[x]) === false) {
137
126
  break;
@@ -151,14 +140,12 @@ var utils = {
151
140
  if (!utils.isObject(defaultOptions) || !utils.isObject(userOptions) || !Object.keys) {
152
141
  return;
153
142
  }
154
-
155
143
  const newObj = {};
156
144
  utils.each(defaultOptions, function (key, val) {
157
145
  newObj[key] = defaultOptions[key];
158
146
  });
159
147
  utils.each(userOptions, function (key, val) {
160
148
  const currentUserOption = userOptions[key];
161
-
162
149
  if (!utils.isObject(currentUserOption)) {
163
150
  newObj[key] = currentUserOption;
164
151
  } else if (!defaultOptions[key]) {
@@ -173,7 +160,6 @@ var utils = {
173
160
  if (!utils.isElement(elem)) {
174
161
  return;
175
162
  }
176
-
177
163
  if (utils.isString(attr) && utils.isString(val)) {
178
164
  elem.style[attr] = val;
179
165
  } else if (utils.isObject(attr)) {
@@ -186,7 +172,6 @@ var utils = {
186
172
  if (!utils.isElement(node)) {
187
173
  return;
188
174
  }
189
-
190
175
  if (node.parentNode) {
191
176
  node.parentNode.removeChild(node);
192
177
  }
@@ -195,7 +180,6 @@ var utils = {
195
180
  if (!utils.isString(content)) {
196
181
  return {};
197
182
  }
198
-
199
183
  try {
200
184
  const blob = new utils.Blob([content], {
201
185
  type: 'text/javascript'
@@ -215,11 +199,9 @@ var utils = {
215
199
  },
216
200
  getFontSize: function getFontSize() {
217
201
  const options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
218
-
219
202
  if (!document.body || options.resizeFont === false) {
220
203
  return options.fontSize;
221
204
  }
222
-
223
205
  const text = options.text;
224
206
  const containerWidth = options.gifWidth;
225
207
  let fontSize = parseInt(options.fontSize, 10);
@@ -233,11 +215,9 @@ var utils = {
233
215
  span.style.textIndent = '-9999px';
234
216
  span.style.visibility = 'hidden';
235
217
  document.body.appendChild(span);
236
-
237
218
  while (span.offsetWidth > containerWidth && fontSize >= minFontSize) {
238
219
  span.style.fontSize = "".concat(--fontSize, "px");
239
220
  }
240
-
241
221
  document.body.removeChild(span);
242
222
  return "".concat(fontSize, "px");
243
223
  },
@@ -252,7 +232,6 @@ var error = {
252
232
  let errorObj = {};
253
233
  utils.each(error.validators, function (indece, currentValidator) {
254
234
  const errorCode = currentValidator.errorCode;
255
-
256
235
  if (!skipObj[errorCode] && !currentValidator.condition) {
257
236
  errorObj = currentValidator;
258
237
  errorObj.error = true;
@@ -306,9 +285,7 @@ var error = {
306
285
  const error$2 = Object.freeze({
307
286
  default: error
308
287
  });
309
-
310
288
  const noop = function noop() {};
311
-
312
289
  const defaultOptions = {
313
290
  sampleInterval: 10,
314
291
  numWorkers: 2,
@@ -343,32 +320,26 @@ const defaultOptions = {
343
320
  const defaultOptions$2 = Object.freeze({
344
321
  default: defaultOptions
345
322
  });
346
-
347
323
  function isSupported() {
348
324
  return error.isValid();
349
325
  }
350
-
351
326
  function isWebCamGIFSupported() {
352
327
  return error.isValid();
353
328
  }
354
-
355
329
  function isSupported$1() {
356
330
  const options = {
357
331
  getUserMedia: true
358
332
  };
359
333
  return error.isValid(options);
360
334
  }
361
-
362
335
  function isExistingVideoGIFSupported(codecs) {
363
336
  let hasValidCodec = false;
364
-
365
337
  if (utils.isArray(codecs) && codecs.length) {
366
338
  utils.each(codecs, function (indece, currentCodec) {
367
339
  if (utils.isSupported.videoCodecs[currentCodec]) {
368
340
  hasValidCodec = true;
369
341
  }
370
342
  });
371
-
372
343
  if (!hasValidCodec) {
373
344
  return false;
374
345
  }
@@ -377,12 +348,10 @@ function isExistingVideoGIFSupported(codecs) {
377
348
  return false;
378
349
  }
379
350
  }
380
-
381
351
  return error.isValid({
382
352
  getUserMedia: true
383
353
  });
384
354
  }
385
-
386
355
  function NeuQuant() {
387
356
  const netsize = 256;
388
357
  const prime1 = 499;
@@ -420,7 +389,6 @@ function NeuQuant() {
420
389
  const bias = [];
421
390
  const freq = [];
422
391
  const radpower = [];
423
-
424
392
  function NeuQuantConstructor(thepic, len, sample) {
425
393
  let i;
426
394
  let p;
@@ -428,7 +396,6 @@ function NeuQuant() {
428
396
  lengthcount = len;
429
397
  samplefac = sample;
430
398
  network = new Array(netsize);
431
-
432
399
  for (i = 0; i < netsize; i++) {
433
400
  network[i] = new Array(4);
434
401
  p = network[i];
@@ -437,27 +404,21 @@ function NeuQuant() {
437
404
  bias[i] = 0;
438
405
  }
439
406
  }
440
-
441
407
  function colorMap() {
442
408
  const map = [];
443
409
  const index = new Array(netsize);
444
-
445
410
  for (let i = 0; i < netsize; i++) {
446
411
  index[network[i][3]] = i;
447
412
  }
448
-
449
413
  let k = 0;
450
-
451
414
  for (let l = 0; l < netsize; l++) {
452
415
  const j = index[l];
453
416
  map[k++] = network[j][0];
454
417
  map[k++] = network[j][1];
455
418
  map[k++] = network[j][2];
456
419
  }
457
-
458
420
  return map;
459
421
  }
460
-
461
422
  function inxbuild() {
462
423
  let i;
463
424
  let j;
@@ -469,15 +430,12 @@ function NeuQuant() {
469
430
  let startpos;
470
431
  previouscol = 0;
471
432
  startpos = 0;
472
-
473
433
  for (i = 0; i < netsize; i++) {
474
434
  p = network[i];
475
435
  smallpos = i;
476
436
  smallval = p[1];
477
-
478
437
  for (j = i + 1; j < netsize; j++) {
479
438
  q = network[j];
480
-
481
439
  if (q[1] < smallval) {
482
440
  smallpos = j;
483
441
  smallval = q[1];
@@ -485,7 +443,6 @@ function NeuQuant() {
485
443
  }
486
444
 
487
445
  q = network[smallpos];
488
-
489
446
  if (i != smallpos) {
490
447
  j = q[0];
491
448
  q[0] = p[0];
@@ -500,26 +457,20 @@ function NeuQuant() {
500
457
  q[3] = p[3];
501
458
  p[3] = j;
502
459
  }
503
-
504
460
  if (smallval != previouscol) {
505
461
  netindex[previouscol] = startpos + i >> 1;
506
-
507
462
  for (j = previouscol + 1; j < smallval; j++) {
508
463
  netindex[j] = i;
509
464
  }
510
-
511
465
  previouscol = smallval;
512
466
  startpos = i;
513
467
  }
514
468
  }
515
-
516
469
  netindex[previouscol] = startpos + maxnetpos >> 1;
517
-
518
470
  for (j = previouscol + 1; j < 256; j++) {
519
471
  netindex[j] = maxnetpos;
520
472
  }
521
473
  }
522
-
523
474
  function learn() {
524
475
  let i;
525
476
  let j;
@@ -535,11 +486,9 @@ function NeuQuant() {
535
486
  let p;
536
487
  let pix;
537
488
  let lim;
538
-
539
489
  if (lengthcount < minpicturebytes) {
540
490
  samplefac = 1;
541
491
  }
542
-
543
492
  alphadec = 30 + (samplefac - 1) / 3;
544
493
  p = thepicture;
545
494
  pix = 0;
@@ -549,15 +498,12 @@ function NeuQuant() {
549
498
  alpha = initalpha;
550
499
  radius = initradius;
551
500
  rad = radius >> radiusbiasshift;
552
-
553
501
  if (rad <= 1) {
554
502
  rad = 0;
555
503
  }
556
-
557
504
  for (i = 0; i < rad; i++) {
558
505
  radpower[i] = alpha * ((rad * rad - i * i) * radbias / (rad * rad));
559
506
  }
560
-
561
507
  if (lengthcount < minpicturebytes) {
562
508
  step = 3;
563
509
  } else if (lengthcount % prime1 !== 0) {
@@ -569,48 +515,37 @@ function NeuQuant() {
569
515
  } else {
570
516
  step = 3 * prime4;
571
517
  }
572
-
573
518
  i = 0;
574
-
575
519
  while (i < samplepixels) {
576
520
  b = (p[pix + 0] & 0xff) << netbiasshift;
577
521
  g = (p[pix + 1] & 0xff) << netbiasshift;
578
522
  r = (p[pix + 2] & 0xff) << netbiasshift;
579
523
  j = contest(b, g, r);
580
524
  altersingle(alpha, j, b, g, r);
581
-
582
525
  if (rad !== 0) {
583
526
  alterneigh(rad, j, b, g, r);
584
527
  }
585
-
586
528
  pix += step;
587
-
588
529
  if (pix >= lim) {
589
530
  pix -= lengthcount;
590
531
  }
591
-
592
532
  i++;
593
-
594
533
  if (delta === 0) {
595
534
  delta = 1;
596
535
  }
597
-
598
536
  if (i % delta === 0) {
599
537
  alpha -= alpha / alphadec;
600
538
  radius -= radius / radiusdec;
601
539
  rad = radius >> radiusbiasshift;
602
-
603
540
  if (rad <= 1) {
604
541
  rad = 0;
605
542
  }
606
-
607
543
  for (j = 0; j < rad; j++) {
608
544
  radpower[j] = alpha * ((rad * rad - j * j) * radbias / (rad * rad));
609
545
  }
610
546
  }
611
547
  }
612
548
  }
613
-
614
549
  function map(b, g, r) {
615
550
  let i;
616
551
  let j;
@@ -623,38 +558,28 @@ function NeuQuant() {
623
558
  best = -1;
624
559
  i = netindex[g];
625
560
  j = i - 1;
626
-
627
561
  while (i < netsize || j >= 0) {
628
562
  if (i < netsize) {
629
563
  p = network[i];
630
564
  dist = p[1] - g;
631
-
632
565
  if (dist >= bestd) {
633
566
  i = netsize;
634
567
  } else {
635
568
  i++;
636
-
637
569
  if (dist < 0) {
638
570
  dist = -dist;
639
571
  }
640
-
641
572
  a = p[0] - b;
642
-
643
573
  if (a < 0) {
644
574
  a = -a;
645
575
  }
646
-
647
576
  dist += a;
648
-
649
577
  if (dist < bestd) {
650
578
  a = p[2] - r;
651
-
652
579
  if (a < 0) {
653
580
  a = -a;
654
581
  }
655
-
656
582
  dist += a;
657
-
658
583
  if (dist < bestd) {
659
584
  bestd = dist;
660
585
  best = p[3];
@@ -662,37 +587,27 @@ function NeuQuant() {
662
587
  }
663
588
  }
664
589
  }
665
-
666
590
  if (j >= 0) {
667
591
  p = network[j];
668
592
  dist = g - p[1];
669
-
670
593
  if (dist >= bestd) {
671
594
  j = -1;
672
595
  } else {
673
596
  j--;
674
-
675
597
  if (dist < 0) {
676
598
  dist = -dist;
677
599
  }
678
-
679
600
  a = p[0] - b;
680
-
681
601
  if (a < 0) {
682
602
  a = -a;
683
603
  }
684
-
685
604
  dist += a;
686
-
687
605
  if (dist < bestd) {
688
606
  a = p[2] - r;
689
-
690
607
  if (a < 0) {
691
608
  a = -a;
692
609
  }
693
-
694
610
  dist += a;
695
-
696
611
  if (dist < bestd) {
697
612
  bestd = dist;
698
613
  best = p[3];
@@ -701,21 +616,17 @@ function NeuQuant() {
701
616
  }
702
617
  }
703
618
  }
704
-
705
619
  return best;
706
620
  }
707
-
708
621
  function process() {
709
622
  learn();
710
623
  unbiasnet();
711
624
  inxbuild();
712
625
  return colorMap();
713
626
  }
714
-
715
627
  function unbiasnet() {
716
628
  let i;
717
629
  let j;
718
-
719
630
  for (i = 0; i < netsize; i++) {
720
631
  network[i][0] >>= netbiasshift;
721
632
  network[i][1] >>= netbiasshift;
@@ -723,7 +634,6 @@ function NeuQuant() {
723
634
  network[i][3] = i;
724
635
  }
725
636
  }
726
-
727
637
  function alterneigh(rad, i, b, g, r) {
728
638
  let j;
729
639
  let k;
@@ -733,37 +643,28 @@ function NeuQuant() {
733
643
  let m;
734
644
  let p;
735
645
  lo = i - rad;
736
-
737
646
  if (lo < -1) {
738
647
  lo = -1;
739
648
  }
740
-
741
649
  hi = i + rad;
742
-
743
650
  if (hi > netsize) {
744
651
  hi = netsize;
745
652
  }
746
-
747
653
  j = i + 1;
748
654
  k = i - 1;
749
655
  m = 1;
750
-
751
656
  while (j < hi || k > lo) {
752
657
  a = radpower[m++];
753
-
754
658
  if (j < hi) {
755
659
  p = network[j++];
756
-
757
660
  try {
758
661
  p[0] -= a * (p[0] - b) / alpharadbias | 0;
759
662
  p[1] -= a * (p[1] - g) / alpharadbias | 0;
760
663
  p[2] -= a * (p[2] - r) / alpharadbias | 0;
761
664
  } catch (e) {}
762
665
  }
763
-
764
666
  if (k > lo) {
765
667
  p = network[k--];
766
-
767
668
  try {
768
669
  p[0] -= a * (p[0] - b) / alpharadbias | 0;
769
670
  p[1] -= a * (p[1] - g) / alpharadbias | 0;
@@ -772,7 +673,6 @@ function NeuQuant() {
772
673
  }
773
674
  }
774
675
  }
775
-
776
676
  function altersingle(alpha, i, b, g, r) {
777
677
  const n = network[i];
778
678
  const alphaMult = alpha / initalpha;
@@ -780,7 +680,6 @@ function NeuQuant() {
780
680
  n[1] -= alphaMult * (n[1] - g) | 0;
781
681
  n[2] -= alphaMult * (n[2] - r) | 0;
782
682
  }
783
-
784
683
  function contest(b, g, r) {
785
684
  let i;
786
685
  let dist;
@@ -796,80 +695,62 @@ function NeuQuant() {
796
695
  bestbiasd = bestd;
797
696
  bestpos = -1;
798
697
  bestbiaspos = bestpos;
799
-
800
698
  for (i = 0; i < netsize; i++) {
801
699
  n = network[i];
802
700
  dist = n[0] - b;
803
-
804
701
  if (dist < 0) {
805
702
  dist = -dist;
806
703
  }
807
-
808
704
  a = n[1] - g;
809
-
810
705
  if (a < 0) {
811
706
  a = -a;
812
707
  }
813
-
814
708
  dist += a;
815
709
  a = n[2] - r;
816
-
817
710
  if (a < 0) {
818
711
  a = -a;
819
712
  }
820
-
821
713
  dist += a;
822
-
823
714
  if (dist < bestd) {
824
715
  bestd = dist;
825
716
  bestpos = i;
826
717
  }
827
-
828
718
  biasdist = dist - (bias[i] >> intbiasshift - netbiasshift);
829
-
830
719
  if (biasdist < bestbiasd) {
831
720
  bestbiasd = biasdist;
832
721
  bestbiaspos = i;
833
722
  }
834
-
835
723
  betafreq = freq[i] >> betashift;
836
724
  freq[i] -= betafreq;
837
725
  bias[i] += betafreq << gammashift;
838
726
  }
839
-
840
727
  freq[bestpos] += beta;
841
728
  bias[bestpos] -= betagamma;
842
729
  return bestbiaspos;
843
730
  }
844
-
845
731
  NeuQuantConstructor.apply(this, arguments);
846
732
  const exports = {};
847
733
  exports.map = map;
848
734
  exports.process = process;
849
735
  return exports;
850
736
  }
851
-
852
737
  function workerCode() {
853
738
  const self = this;
854
-
855
739
  try {
856
740
  globalThis.onmessage = function (ev) {
857
741
  const data = ev.data || {};
858
742
  let response;
859
-
860
743
  if (data.gifshot) {
861
744
  response = workerMethods.run(data);
862
745
  postMessage(response);
863
746
  }
864
747
  };
865
748
  } catch (e) {}
866
-
867
749
  var workerMethods = {
868
750
  dataToRGB: function dataToRGB(data, width, height) {
869
751
  const length = width * height * 4;
870
752
  let i = 0;
871
753
  const rgb = [];
872
-
873
754
  while (i < length) {
874
755
  rgb.push(data[i++]);
875
756
  rgb.push(data[i++]);
@@ -882,14 +763,12 @@ function workerCode() {
882
763
  componentizedPaletteToArray: function componentizedPaletteToArray(paletteRGB) {
883
764
  paletteRGB = paletteRGB || [];
884
765
  const paletteArray = [];
885
-
886
766
  for (let i = 0; i < paletteRGB.length; i += 3) {
887
767
  const r = paletteRGB[i];
888
768
  const g = paletteRGB[i + 1];
889
769
  const b = paletteRGB[i + 2];
890
770
  paletteArray.push(r << 16 | g << 8 | b);
891
771
  }
892
-
893
772
  return paletteArray;
894
773
  },
895
774
  processFrameWithQuantizer: function processFrameWithQuantizer(imageData, width, height, sampleInterval) {
@@ -900,14 +779,12 @@ function workerCode() {
900
779
  const numberPixels = width * height;
901
780
  const indexedPixels = new Uint8Array(numberPixels);
902
781
  let k = 0;
903
-
904
782
  for (let i = 0; i < numberPixels; i++) {
905
783
  const r = rgbComponents[k++];
906
784
  const g = rgbComponents[k++];
907
785
  const b = rgbComponents[k++];
908
786
  indexedPixels[i] = nq.map(r, g, b);
909
787
  }
910
-
911
788
  return {
912
789
  pixels: indexedPixels,
913
790
  palette: paletteArray
@@ -926,20 +803,17 @@ function workerCode() {
926
803
  };
927
804
  return workerMethods;
928
805
  }
929
-
930
806
  function gifWriter(buf, width, height, gopts) {
931
807
  let p = 0;
932
808
  gopts = gopts === undefined ? {} : gopts;
933
809
  const loop_count = gopts.loop === undefined ? null : gopts.loop;
934
810
  const global_palette = gopts.palette === undefined ? null : gopts.palette;
935
811
  if (width <= 0 || height <= 0 || width > 65535 || height > 65535) throw 'Width/Height invalid.';
936
-
937
812
  function check_palette_and_num_colors(palette) {
938
813
  const num_colors = palette.length;
939
814
  if (num_colors < 2 || num_colors > 256 || num_colors & num_colors - 1) throw 'Invalid code/color length, must be power of 2 and 2 .. 256.';
940
815
  return num_colors;
941
816
  }
942
-
943
817
  buf[p++] = 0x47;
944
818
  buf[p++] = 0x49;
945
819
  buf[p++] = 0x46;
@@ -952,10 +826,10 @@ function gifWriter(buf, width, height, gopts) {
952
826
  buf[p++] = width >> 8 & 0xff;
953
827
  buf[p++] = height & 0xff;
954
828
  buf[p++] = height >> 8 & 0xff;
955
- buf[p++] = (global_palette !== null ? 0x80 : 0) | gp_num_colors_pow2;
829
+ buf[p++] = (global_palette !== null ? 0x80 : 0) |
830
+ gp_num_colors_pow2;
956
831
  buf[p++] = background;
957
832
  buf[p++] = 0;
958
-
959
833
  if (loop_count !== null) {
960
834
  if (loop_count < 0 || loop_count > 65535) throw 'Loop count invalid.';
961
835
  buf[p++] = 0x21;
@@ -980,46 +854,39 @@ function gifWriter(buf, width, height, gopts) {
980
854
  }
981
855
 
982
856
  let ended = false;
983
-
984
857
  this.addFrame = function (x, y, w, h, indexed_pixels, opts) {
985
858
  if (ended === true) {
986
859
  --p;
987
860
  ended = false;
988
861
  }
989
-
990
862
  opts = opts === undefined ? {} : opts;
991
863
  if (x < 0 || y < 0 || x > 65535 || y > 65535) throw 'x/y invalid.';
992
864
  if (w <= 0 || h <= 0 || w > 65535 || h > 65535) throw 'Width/Height invalid.';
993
865
  if (indexed_pixels.length < w * h) throw 'Not enough pixels for the frame size.';
994
866
  let using_local_palette = true;
995
867
  let palette = opts.palette;
996
-
997
868
  if (palette === undefined || palette === null) {
998
869
  using_local_palette = false;
999
870
  palette = global_palette;
1000
871
  }
1001
-
1002
872
  if (palette === undefined || palette === null) throw 'Must supply either a local or global palette.';
1003
873
  let num_colors = check_palette_and_num_colors(palette);
1004
874
  let min_code_size = 0;
1005
-
1006
875
  while (num_colors >>= 1) {
1007
876
  ++min_code_size;
1008
877
  }
1009
-
1010
878
  num_colors = 1 << min_code_size;
1011
879
  const delay = opts.delay === undefined ? 0 : opts.delay;
1012
880
  const disposal = opts.disposal === undefined ? 0 : opts.disposal;
1013
- if (disposal < 0 || disposal > 3) throw 'Disposal out of range.';
881
+ if (disposal < 0 || disposal > 3)
882
+ throw 'Disposal out of range.';
1014
883
  let use_transparency = false;
1015
884
  let transparent_index = 0;
1016
-
1017
885
  if (opts.transparent !== undefined && opts.transparent !== null) {
1018
886
  use_transparency = true;
1019
887
  transparent_index = opts.transparent;
1020
888
  if (transparent_index < 0 || transparent_index >= num_colors) throw 'Transparent color index.';
1021
889
  }
1022
-
1023
890
  if (disposal !== 0 || use_transparency || delay !== 0) {
1024
891
  buf[p++] = 0x21;
1025
892
  buf[p++] = 0xf9;
@@ -1030,7 +897,6 @@ function gifWriter(buf, width, height, gopts) {
1030
897
  buf[p++] = transparent_index;
1031
898
  buf[p++] = 0;
1032
899
  }
1033
-
1034
900
  buf[p++] = 0x2c;
1035
901
  buf[p++] = x & 0xff;
1036
902
  buf[p++] = x >> 8 & 0xff;
@@ -1041,7 +907,6 @@ function gifWriter(buf, width, height, gopts) {
1041
907
  buf[p++] = h & 0xff;
1042
908
  buf[p++] = h >> 8 & 0xff;
1043
909
  buf[p++] = using_local_palette === true ? 0x80 | min_code_size - 1 : 0;
1044
-
1045
910
  if (using_local_palette === true) {
1046
911
  for (let i = 0, il = palette.length; i < il; ++i) {
1047
912
  const rgb = palette[i];
@@ -1050,19 +915,15 @@ function gifWriter(buf, width, height, gopts) {
1050
915
  buf[p++] = rgb & 0xff;
1051
916
  }
1052
917
  }
1053
-
1054
918
  p = GifWriterOutputLZWCodeStream(buf, p, min_code_size < 2 ? 2 : min_code_size, indexed_pixels);
1055
919
  };
1056
-
1057
920
  this.end = function () {
1058
921
  if (ended === false) {
1059
922
  buf[p++] = 0x3b;
1060
923
  ended = true;
1061
924
  }
1062
-
1063
925
  return p;
1064
926
  };
1065
-
1066
927
  function GifWriterOutputLZWCodeStream(buf, p, min_code_size, index_stream) {
1067
928
  buf[p++] = min_code_size;
1068
929
  let cur_subblock = p++;
@@ -1073,50 +934,41 @@ function gifWriter(buf, width, height, gopts) {
1073
934
  let cur_code_size = min_code_size + 1;
1074
935
  let cur_shift = 0;
1075
936
  let cur = 0;
1076
-
1077
937
  function emit_bytes_to_buffer(bit_block_size) {
1078
938
  while (cur_shift >= bit_block_size) {
1079
939
  buf[p++] = cur & 0xff;
1080
940
  cur >>= 8;
1081
941
  cur_shift -= 8;
1082
-
1083
942
  if (p === cur_subblock + 256) {
1084
943
  buf[cur_subblock] = 255;
1085
944
  cur_subblock = p++;
1086
945
  }
1087
946
  }
1088
947
  }
1089
-
1090
948
  function emit_code(c) {
1091
949
  cur |= c << cur_shift;
1092
950
  cur_shift += cur_code_size;
1093
951
  emit_bytes_to_buffer(8);
1094
952
  }
1095
-
1096
953
  let ib_code = index_stream[0] & code_mask;
1097
954
  let code_table = {};
1098
955
  emit_code(clear_code);
1099
-
1100
956
  for (let i = 1, il = index_stream.length; i < il; ++i) {
1101
957
  const k = index_stream[i] & code_mask;
1102
958
  const cur_key = ib_code << 8 | k;
1103
959
  const cur_code = code_table[cur_key];
1104
-
1105
960
  if (cur_code === undefined) {
1106
961
  cur |= ib_code << cur_shift;
1107
962
  cur_shift += cur_code_size;
1108
-
1109
963
  while (cur_shift >= 8) {
1110
964
  buf[p++] = cur & 0xff;
1111
965
  cur >>= 8;
1112
966
  cur_shift -= 8;
1113
-
1114
967
  if (p === cur_subblock + 256) {
1115
968
  buf[cur_subblock] = 255;
1116
969
  cur_subblock = p++;
1117
970
  }
1118
971
  }
1119
-
1120
972
  if (next_code === 4096) {
1121
973
  emit_code(clear_code);
1122
974
  next_code = eoi_code + 1;
@@ -1136,20 +988,16 @@ function gifWriter(buf, width, height, gopts) {
1136
988
  emit_code(ib_code);
1137
989
  emit_code(eoi_code);
1138
990
  emit_bytes_to_buffer(1);
1139
-
1140
991
  if (cur_subblock + 1 === p) {
1141
992
  buf[cur_subblock] = 0;
1142
993
  } else {
1143
994
  buf[cur_subblock] = p - cur_subblock - 1;
1144
995
  buf[p++] = 0;
1145
996
  }
1146
-
1147
997
  return p;
1148
998
  }
1149
999
  }
1150
-
1151
1000
  const noop$2 = function noop() {};
1152
-
1153
1001
  const AnimatedGIF = function AnimatedGIF(options) {
1154
1002
  this.canvas = null;
1155
1003
  this.ctx = null;
@@ -1164,7 +1012,6 @@ const AnimatedGIF = function AnimatedGIF(options) {
1164
1012
  this.options = options;
1165
1013
  this.initializeWebWorkers(options);
1166
1014
  };
1167
-
1168
1015
  AnimatedGIF.prototype = {
1169
1016
  workerMethods: workerCode(),
1170
1017
  initializeWebWorkers: function initializeWebWorkers(options) {
@@ -1177,10 +1024,8 @@ AnimatedGIF.prototype = {
1177
1024
  let x = -1;
1178
1025
  let workerError = '';
1179
1026
  numWorkers = options.numWorkers;
1180
-
1181
1027
  while (++x < numWorkers) {
1182
1028
  webWorkerObj = utils.createWebWorker(processFrameWorkerCode);
1183
-
1184
1029
  if (utils.isObject(webWorkerObj)) {
1185
1030
  objectUrl = webWorkerObj.objectUrl;
1186
1031
  webWorker = webWorkerObj.worker;
@@ -1194,7 +1039,6 @@ AnimatedGIF.prototype = {
1194
1039
  utils.webWorkerError = Boolean(webWorkerObj);
1195
1040
  }
1196
1041
  }
1197
-
1198
1042
  this.workerError = workerError;
1199
1043
  this.canvas = document.createElement('canvas');
1200
1044
  this.canvas.width = options.gifWidth;
@@ -1210,22 +1054,18 @@ AnimatedGIF.prototype = {
1210
1054
  },
1211
1055
  byteMap: function () {
1212
1056
  const byteMap = [];
1213
-
1214
1057
  for (let i = 0; i < 256; i++) {
1215
1058
  byteMap[i] = String.fromCharCode(i);
1216
1059
  }
1217
-
1218
1060
  return byteMap;
1219
1061
  }(),
1220
1062
  bufferToString: function bufferToString(buffer) {
1221
1063
  const numberValues = buffer.length;
1222
1064
  let str = '';
1223
1065
  let x = -1;
1224
-
1225
1066
  while (++x < numberValues) {
1226
1067
  str += this.byteMap[buffer[x]];
1227
1068
  }
1228
-
1229
1069
  return str;
1230
1070
  },
1231
1071
  onFrameFinished: function onFrameFinished(progressCallback) {
@@ -1237,13 +1077,10 @@ AnimatedGIF.prototype = {
1237
1077
  return !frame.beingProcessed && frame.done;
1238
1078
  });
1239
1079
  self.numRenderedFrames++;
1240
-
1241
1080
  if (hasExistingImages) {
1242
1081
  progressCallback(self.numRenderedFrames / frames.length);
1243
1082
  }
1244
-
1245
1083
  self.onRenderProgressCallback(self.numRenderedFrames * 0.75 / frames.length);
1246
-
1247
1084
  if (allDone) {
1248
1085
  if (!self.generatingGIF) {
1249
1086
  self.generateGIF(frames, self.onRenderCompleteCallback);
@@ -1263,7 +1100,6 @@ AnimatedGIF.prototype = {
1263
1100
  const frames = this.frames;
1264
1101
  let frame = void 0;
1265
1102
  let worker = void 0;
1266
-
1267
1103
  const done = function done() {
1268
1104
  const ev = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1269
1105
  const data = ev.data;
@@ -1275,19 +1111,15 @@ AnimatedGIF.prototype = {
1275
1111
  AnimatedGifContext.freeWorker(worker);
1276
1112
  AnimatedGifContext.onFrameFinished(progressCallback);
1277
1113
  };
1278
-
1279
1114
  frame = frames[position];
1280
-
1281
1115
  if (frame.beingProcessed || frame.done) {
1282
1116
  this.onFrameFinished();
1283
1117
  return;
1284
1118
  }
1285
-
1286
1119
  frame.sampleInterval = sampleInterval;
1287
1120
  frame.beingProcessed = true;
1288
1121
  frame.gifshot = true;
1289
1122
  worker = this.getWorker();
1290
-
1291
1123
  if (worker) {
1292
1124
  worker.onmessage = done;
1293
1125
  worker.postMessage(frame);
@@ -1299,23 +1131,19 @@ AnimatedGIF.prototype = {
1299
1131
  },
1300
1132
  startRendering: function startRendering(completeCallback) {
1301
1133
  this.onRenderCompleteCallback = completeCallback;
1302
-
1303
1134
  for (let i = 0; i < this.options.numWorkers && i < this.frames.length; i++) {
1304
1135
  this.processFrame(i);
1305
1136
  }
1306
1137
  },
1307
1138
  processNextFrame: function processNextFrame() {
1308
1139
  let position = -1;
1309
-
1310
1140
  for (let i = 0; i < this.frames.length; i++) {
1311
1141
  const frame = this.frames[i];
1312
-
1313
1142
  if (!frame.done && !frame.beingProcessed) {
1314
1143
  position = i;
1315
1144
  break;
1316
1145
  }
1317
1146
  }
1318
-
1319
1147
  if (position >= 0) {
1320
1148
  this.processFrame(position);
1321
1149
  }
@@ -1341,7 +1169,6 @@ AnimatedGIF.prototype = {
1341
1169
  utils.each(frames, function (iterator, frame) {
1342
1170
  const framePalette = frame.palette;
1343
1171
  onRenderProgressCallback(0.75 + 0.25 * frame.position * 1.0 / frames.length);
1344
-
1345
1172
  for (let i = 0; i < frameDuration; i++) {
1346
1173
  gifWriter$$1.addFrame(0, 0, width, height, frame.pixels, {
1347
1174
  palette: framePalette,
@@ -1353,7 +1180,6 @@ AnimatedGIF.prototype = {
1353
1180
  onRenderProgressCallback(1.0);
1354
1181
  this.frames = [];
1355
1182
  this.generatingGIF = false;
1356
-
1357
1183
  if (utils.isFunction(callback)) {
1358
1184
  bufferToString = this.bufferToString(buffer);
1359
1185
  gif = "data:image/gif;base64,".concat(utils.btoa(bufferToString));
@@ -1385,11 +1211,9 @@ AnimatedGIF.prototype = {
1385
1211
  const textYCoordinate = gifshotOptions.textYCoordinate ? gifshotOptions.textYCoordinate : textBaseline === 'top' ? 1 : textBaseline === 'center' ? height / 2 : height;
1386
1212
  const font = "".concat(fontWeight, " ").concat(fontSize, " ").concat(fontFamily);
1387
1213
  let imageData = void 0;
1388
-
1389
1214
  try {
1390
1215
  ctx.filter = filter;
1391
1216
  ctx.drawImage(element, 0, 0, width, height);
1392
-
1393
1217
  if (text) {
1394
1218
  ctx.font = font;
1395
1219
  ctx.fillStyle = fontColor;
@@ -1397,7 +1221,6 @@ AnimatedGIF.prototype = {
1397
1221
  ctx.textBaseline = textBaseline;
1398
1222
  ctx.fillText(text, textXCoordinate, textYCoordinate);
1399
1223
  }
1400
-
1401
1224
  imageData = ctx.getImageData(0, 0, width, height);
1402
1225
  self.addFrameImageData(imageData);
1403
1226
  } catch (e) {
@@ -1427,21 +1250,18 @@ AnimatedGIF.prototype = {
1427
1250
  },
1428
1251
  getBase64GIF: function getBase64GIF(completeCallback) {
1429
1252
  const self = this;
1430
-
1431
1253
  const onRenderComplete = function onRenderComplete(gif) {
1432
1254
  self.destroyWorkers();
1433
1255
  utils.requestTimeout(function () {
1434
1256
  completeCallback(gif);
1435
1257
  }, 0);
1436
1258
  };
1437
-
1438
1259
  self.startRendering(onRenderComplete);
1439
1260
  },
1440
1261
  destroyWorkers: function destroyWorkers() {
1441
1262
  if (this.workerError) {
1442
1263
  return;
1443
1264
  }
1444
-
1445
1265
  const workers = this.workers;
1446
1266
  utils.each(workers, function (iterator, workerObj) {
1447
1267
  const worker = workerObj.worker;
@@ -1451,7 +1271,6 @@ AnimatedGIF.prototype = {
1451
1271
  });
1452
1272
  }
1453
1273
  };
1454
-
1455
1274
  function getBase64GIF(animatedGifInstance, callback) {
1456
1275
  animatedGifInstance.getBase64GIF(function (image) {
1457
1276
  callback({
@@ -1462,7 +1281,6 @@ function getBase64GIF(animatedGifInstance, callback) {
1462
1281
  });
1463
1282
  });
1464
1283
  }
1465
-
1466
1284
  function existingImages() {
1467
1285
  const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1468
1286
  const self = this;
@@ -1479,49 +1297,39 @@ function existingImages() {
1479
1297
  let loadedImagesLength = 0;
1480
1298
  let tempImage = void 0;
1481
1299
  let ag = void 0;
1482
-
1483
1300
  if (errorObj.error) {
1484
1301
  return callback(errorObj);
1485
1302
  }
1486
-
1487
1303
  ag = new AnimatedGIF(options);
1488
1304
  utils.each(images, function (index, image) {
1489
1305
  const currentImage = image;
1490
-
1491
1306
  if (utils.isElement(currentImage)) {
1492
1307
  if (options.crossOrigin) {
1493
1308
  currentImage.crossOrigin = options.crossOrigin;
1494
1309
  }
1495
-
1496
1310
  loadedImages[index] = currentImage;
1497
1311
  loadedImagesLength += 1;
1498
-
1499
1312
  if (loadedImagesLength === imagesLength) {
1500
1313
  addLoadedImagesToGif();
1501
1314
  }
1502
1315
  } else if (utils.isString(currentImage)) {
1503
1316
  tempImage = new Image();
1504
-
1505
1317
  if (options.crossOrigin) {
1506
1318
  tempImage.crossOrigin = options.crossOrigin;
1507
1319
  }
1508
-
1509
1320
  (function (tempImage) {
1510
1321
  if (image.text) {
1511
1322
  tempImage.text = image.text;
1512
1323
  }
1513
-
1514
1324
  tempImage.onerror = function (e) {
1515
1325
  let obj = void 0;
1516
1326
  --imagesLength;
1517
-
1518
1327
  if (imagesLength === 0) {
1519
1328
  obj = {};
1520
1329
  obj.error = 'None of the requested images was capable of being retrieved';
1521
1330
  return callback(obj);
1522
1331
  }
1523
1332
  };
1524
-
1525
1333
  tempImage.onload = function (e) {
1526
1334
  if (image.text) {
1527
1335
  loadedImages[index] = {
@@ -1531,19 +1339,14 @@ function existingImages() {
1531
1339
  } else {
1532
1340
  loadedImages[index] = tempImage;
1533
1341
  }
1534
-
1535
1342
  loadedImagesLength += 1;
1536
-
1537
1343
  if (loadedImagesLength === imagesLength) {
1538
1344
  addLoadedImagesToGif();
1539
1345
  }
1540
-
1541
1346
  utils.removeElement(tempImage);
1542
1347
  };
1543
-
1544
1348
  tempImage.src = currentImage;
1545
1349
  })(tempImage);
1546
-
1547
1350
  utils.setCSSAttr(tempImage, {
1548
1351
  position: 'fixed',
1549
1352
  opacity: '0'
@@ -1551,7 +1354,6 @@ function existingImages() {
1551
1354
  document.body.appendChild(tempImage);
1552
1355
  }
1553
1356
  });
1554
-
1555
1357
  function addLoadedImagesToGif() {
1556
1358
  utils.each(loadedImages, function (index, loadedImage) {
1557
1359
  if (loadedImage) {
@@ -1565,9 +1367,7 @@ function existingImages() {
1565
1367
  getBase64GIF(ag, callback);
1566
1368
  }
1567
1369
  }
1568
-
1569
1370
  const noop$3 = function noop() {};
1570
-
1571
1371
  const screenShot = {
1572
1372
  getGIF: function getGIF() {
1573
1373
  const options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -1612,35 +1412,28 @@ const screenShot = {
1612
1412
  let sourceWidth = crop ? videoWidth - crop.scaledWidth : 0;
1613
1413
  let sourceY = crop ? Math.floor(crop.scaledHeight / 2) : 0;
1614
1414
  let sourceHeight = crop ? videoHeight - crop.scaledHeight : 0;
1615
-
1616
1415
  const captureFrames = function captureSingleFrame() {
1617
1416
  const framesLeft = pendingFrames - 1;
1618
-
1619
1417
  if (savedRenderingContexts.length) {
1620
1418
  context.putImageData(savedRenderingContexts[numFrames - pendingFrames], 0, 0);
1621
1419
  finishCapture();
1622
1420
  } else {
1623
1421
  drawVideo();
1624
1422
  }
1625
-
1626
1423
  function drawVideo() {
1627
1424
  try {
1628
1425
  if (sourceWidth > videoWidth) {
1629
1426
  sourceWidth = videoWidth;
1630
1427
  }
1631
-
1632
1428
  if (sourceHeight > videoHeight) {
1633
1429
  sourceHeight = videoHeight;
1634
1430
  }
1635
-
1636
1431
  if (sourceX < 0) {
1637
1432
  sourceX = 0;
1638
1433
  }
1639
-
1640
1434
  if (sourceY < 0) {
1641
1435
  sourceY = 0;
1642
1436
  }
1643
-
1644
1437
  context.filter = filter;
1645
1438
  context.drawImage(videoElement, sourceX, sourceY, sourceWidth, sourceHeight, 0, 0, gifWidth, gifHeight);
1646
1439
  finishCapture();
@@ -1652,14 +1445,11 @@ const screenShot = {
1652
1445
  }
1653
1446
  }
1654
1447
  }
1655
-
1656
1448
  function finishCapture() {
1657
1449
  let imageData = void 0;
1658
-
1659
1450
  if (saveRenderingContexts) {
1660
1451
  renderingContextsToSave.push(context.getImageData(0, 0, gifWidth, gifHeight));
1661
1452
  }
1662
-
1663
1453
  if (text) {
1664
1454
  context.font = font;
1665
1455
  context.fillStyle = fontColor;
@@ -1667,16 +1457,13 @@ const screenShot = {
1667
1457
  context.textBaseline = textBaseline;
1668
1458
  context.fillText(text, textXCoordinate, textYCoordinate);
1669
1459
  }
1670
-
1671
1460
  imageData = context.getImageData(0, 0, gifWidth, gifHeight);
1672
1461
  ag.addFrameImageData(imageData);
1673
1462
  pendingFrames = framesLeft;
1674
1463
  progressCallback((numFrames - pendingFrames) / numFrames);
1675
-
1676
1464
  if (framesLeft > 0) {
1677
1465
  utils.requestTimeout(captureSingleFrame, waitBetweenFrames);
1678
1466
  }
1679
-
1680
1467
  if (!pendingFrames) {
1681
1468
  ag.getBase64GIF(function (image) {
1682
1469
  callback({
@@ -1694,19 +1481,16 @@ const screenShot = {
1694
1481
  }
1695
1482
  }
1696
1483
  };
1697
-
1698
1484
  numFrames = numFrames !== undefined ? numFrames : 10;
1699
1485
  interval = interval !== undefined ? interval : 0.1;
1700
1486
  canvas.width = gifWidth;
1701
1487
  canvas.height = gifHeight;
1702
1488
  context = canvas.getContext('2d');
1703
-
1704
1489
  (function capture() {
1705
1490
  if (!savedRenderingContexts.length && videoElement.currentTime === 0) {
1706
1491
  utils.requestTimeout(capture, 100);
1707
1492
  return;
1708
1493
  }
1709
-
1710
1494
  captureFrames();
1711
1495
  })();
1712
1496
  },
@@ -1722,7 +1506,6 @@ const screenShot = {
1722
1506
  scaledWidth: 0,
1723
1507
  scaledHeight: 0
1724
1508
  };
1725
-
1726
1509
  if (width > height) {
1727
1510
  result.width = Math.round(width * (gifHeight / height)) - gifWidth;
1728
1511
  result.scaledWidth = Math.round(result.width * (height / gifHeight));
@@ -1730,7 +1513,6 @@ const screenShot = {
1730
1513
  result.height = Math.round(height * (gifWidth / width)) - gifHeight;
1731
1514
  result.scaledHeight = Math.round(result.height * (width / gifWidth));
1732
1515
  }
1733
-
1734
1516
  return result;
1735
1517
  }
1736
1518
  };
@@ -1745,11 +1527,9 @@ var videoStream = {
1745
1527
  const cameraStream = obj.cameraStream;
1746
1528
  const completedCallback = obj.completedCallback;
1747
1529
  const videoElement = obj.videoElement;
1748
-
1749
1530
  if (!videoElement) {
1750
1531
  return;
1751
1532
  }
1752
-
1753
1533
  if (videoElement.videoWidth > 0 && videoElement.videoHeight > 0) {
1754
1534
  videoElement.removeEventListener('loadeddata', videoStream.findVideoSize);
1755
1535
  completedCallback({
@@ -1789,11 +1569,9 @@ var videoStream = {
1789
1569
  const completedCallback = obj.completedCallback;
1790
1570
  const streamedCallback = obj.streamedCallback;
1791
1571
  const videoElement = obj.videoElement;
1792
-
1793
1572
  if (utils.isFunction(streamedCallback)) {
1794
1573
  streamedCallback();
1795
1574
  }
1796
-
1797
1575
  if (existingVideo) {
1798
1576
  if (utils.isString(existingVideo)) {
1799
1577
  videoElement.src = existingVideo;
@@ -1802,7 +1580,6 @@ var videoStream = {
1802
1580
  try {
1803
1581
  videoElement.src = utils.URL.createObjectURL(existingVideo);
1804
1582
  } catch (e) {}
1805
-
1806
1583
  videoElement.innerHTML = "<source src=\"".concat(existingVideo, "\" type=\"").concat(existingVideo.type, "\" />");
1807
1584
  }
1808
1585
  } else if (videoElement.mozSrcObject) {
@@ -1815,11 +1592,9 @@ var videoStream = {
1815
1592
  videoElement.srcObject = cameraStream;
1816
1593
  }
1817
1594
  }
1818
-
1819
1595
  videoElement.play();
1820
1596
  utils.requestTimeout(function checkLoadedData() {
1821
1597
  checkLoadedData.count = checkLoadedData.count || 0;
1822
-
1823
1598
  if (videoStream.loadedData === true) {
1824
1599
  videoStream.findVideoSize({
1825
1600
  videoElement,
@@ -1829,7 +1604,6 @@ var videoStream = {
1829
1604
  videoStream.loadedData = false;
1830
1605
  } else {
1831
1606
  checkLoadedData.count += 1;
1832
-
1833
1607
  if (checkLoadedData.count > 10) {
1834
1608
  videoStream.findVideoSize({
1835
1609
  videoElement,
@@ -1853,22 +1627,18 @@ var videoStream = {
1853
1627
  const webcamVideoElement = obj.webcamVideoElement;
1854
1628
  const videoElement = utils.isElement(existingVideo) ? existingVideo : webcamVideoElement ? webcamVideoElement : document.createElement('video');
1855
1629
  const cameraStream = void 0;
1856
-
1857
1630
  if (crossOrigin) {
1858
1631
  videoElement.crossOrigin = options.crossOrigin;
1859
1632
  }
1860
-
1861
1633
  videoElement.autoplay = true;
1862
1634
  videoElement.loop = true;
1863
1635
  videoElement.muted = true;
1864
1636
  videoElement.addEventListener('loadeddata', function (event) {
1865
1637
  videoStream.loadedData = true;
1866
-
1867
1638
  if (options.offset) {
1868
1639
  videoElement.currentTime = options.offset;
1869
1640
  }
1870
1641
  });
1871
-
1872
1642
  if (existingVideo) {
1873
1643
  videoStream.stream({
1874
1644
  videoElement,
@@ -1901,13 +1671,11 @@ var videoStream = {
1901
1671
  const originalCallback = options.callback;
1902
1672
  const webcamVideoElement = options.webcamVideoElement;
1903
1673
  let noGetUserMediaSupportTimeout = void 0;
1904
-
1905
1674
  if (timeoutLength > 0) {
1906
1675
  noGetUserMediaSupportTimeout = utils.requestTimeout(function () {
1907
1676
  videoStream.onStreamingTimeout(originalCallback);
1908
1677
  }, 10000);
1909
1678
  }
1910
-
1911
1679
  videoStream.startStreaming({
1912
1680
  error: function error() {
1913
1681
  originalCallback({
@@ -1950,32 +1718,26 @@ var videoStream = {
1950
1718
  const cameraStreamTracks = cameraStream.getTracks ? cameraStream.getTracks() || [] : [];
1951
1719
  const hasCameraStreamTracks = Boolean(cameraStreamTracks.length);
1952
1720
  const firstCameraStreamTrack = cameraStreamTracks[0];
1953
-
1954
1721
  if (!keepCameraOn && hasCameraStreamTracks) {
1955
1722
  if (utils.isFunction(firstCameraStreamTrack.stop)) {
1956
1723
  firstCameraStreamTrack.stop();
1957
1724
  }
1958
1725
  }
1959
-
1960
1726
  if (utils.isElement(videoElement) && !webcamVideoElement) {
1961
1727
  videoElement.pause();
1962
-
1963
1728
  if (utils.isFunction(utils.URL.revokeObjectURL) && !utils.webWorkerError) {
1964
1729
  if (videoElement.src) {
1965
1730
  utils.URL.revokeObjectURL(videoElement.src);
1966
1731
  }
1967
1732
  }
1968
-
1969
1733
  utils.removeElement(videoElement);
1970
1734
  }
1971
1735
  }
1972
1736
  };
1973
-
1974
1737
  function stopVideoStreaming(options) {
1975
1738
  options = utils.isObject(options) ? options : {};
1976
1739
  videoStream.stopVideoStreaming(options);
1977
1740
  }
1978
-
1979
1741
  function createAndGetGIF(obj, callback) {
1980
1742
  const options = obj.options || {};
1981
1743
  const images = options.images;
@@ -1999,14 +1761,11 @@ function createAndGetGIF(obj, callback) {
1999
1761
  options.videoWidth = videoWidth;
2000
1762
  options.videoHeight = videoHeight;
2001
1763
  options.cameraStream = cameraStream;
2002
-
2003
1764
  if (!utils.isElement(videoElement)) {
2004
1765
  return;
2005
1766
  }
2006
-
2007
1767
  videoElement.width = gifWidth + cropDimensions.width;
2008
1768
  videoElement.height = gifHeight + cropDimensions.height;
2009
-
2010
1769
  if (!options.webcamVideoElement) {
2011
1770
  utils.setCSSAttr(videoElement, {
2012
1771
  position: 'fixed',
@@ -2014,17 +1773,14 @@ function createAndGetGIF(obj, callback) {
2014
1773
  });
2015
1774
  document.body.appendChild(videoElement);
2016
1775
  }
2017
-
2018
1776
  videoElement.play();
2019
1777
  screenShot.getGIF(options, function (obj) {
2020
1778
  if ((!images || !images.length) && (!video || !video.length)) {
2021
1779
  stopVideoStreaming(obj);
2022
1780
  }
2023
-
2024
1781
  completeCallback(obj);
2025
1782
  });
2026
1783
  }
2027
-
2028
1784
  function existingVideo() {
2029
1785
  const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2030
1786
  const callback = obj.callback;
@@ -2040,15 +1796,12 @@ function existingVideo() {
2040
1796
  let videoSrc = void 0;
2041
1797
  const tempImage = void 0;
2042
1798
  const ag = void 0;
2043
-
2044
1799
  if (errorObj.error) {
2045
1800
  return callback(errorObj);
2046
1801
  }
2047
-
2048
1802
  if (utils.isElement(existingVideo) && existingVideo.src) {
2049
1803
  videoSrc = existingVideo.src;
2050
1804
  videoType = utils.getExtension(videoSrc);
2051
-
2052
1805
  if (!utils.isSupported.videoCodecs[videoType]) {
2053
1806
  return callback(error.messages.videoCodecs);
2054
1807
  }
@@ -2059,14 +1812,12 @@ function existingVideo() {
2059
1812
  } else {
2060
1813
  videoType = videoSrc.substr(videoSrc.lastIndexOf('.') + 1, videoSrc.length);
2061
1814
  }
2062
-
2063
1815
  if (utils.isSupported.videoCodecs[videoType]) {
2064
1816
  existingVideo = videoSrc;
2065
1817
  return false;
2066
1818
  }
2067
1819
  });
2068
1820
  }
2069
-
2070
1821
  videoStream.startStreaming({
2071
1822
  completed: function completed(obj) {
2072
1823
  obj.options = options || {};
@@ -2077,25 +1828,21 @@ function existingVideo() {
2077
1828
  options
2078
1829
  });
2079
1830
  }
2080
-
2081
1831
  function existingWebcam() {
2082
1832
  const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2083
1833
  const callback = obj.callback;
2084
1834
  const lastCameraStream = obj.lastCameraStream;
2085
1835
  const options = obj.options;
2086
1836
  const webcamVideoElement = obj.webcamVideoElement;
2087
-
2088
1837
  if (!isWebCamGIFSupported()) {
2089
1838
  return callback(error.validate());
2090
1839
  }
2091
-
2092
1840
  if (options.savedRenderingContexts.length) {
2093
1841
  screenShot.getGIF(options, function (obj) {
2094
1842
  callback(obj);
2095
1843
  });
2096
1844
  return;
2097
1845
  }
2098
-
2099
1846
  videoStream.startVideoStreaming(function () {
2100
1847
  const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2101
1848
  obj.options = options || {};
@@ -2107,15 +1854,12 @@ function existingWebcam() {
2107
1854
  crossOrigin: options.crossOrigin
2108
1855
  });
2109
1856
  }
2110
-
2111
1857
  function createGIF(userOptions, callback) {
2112
1858
  callback = utils.isFunction(userOptions) ? userOptions : callback;
2113
1859
  userOptions = utils.isObject(userOptions) ? userOptions : {};
2114
-
2115
1860
  if (!utils.isFunction(callback)) {
2116
1861
  return;
2117
1862
  }
2118
-
2119
1863
  let options = utils.normalizeOptions(defaultOptions, userOptions) || {};
2120
1864
  const lastCameraStream = userOptions.cameraStream;
2121
1865
  const images = options.images;
@@ -2126,7 +1870,6 @@ function createGIF(userOptions, callback) {
2126
1870
  gifWidth: Math.floor(options.gifWidth),
2127
1871
  gifHeight: Math.floor(options.gifHeight)
2128
1872
  });
2129
-
2130
1873
  if (imagesLength) {
2131
1874
  existingImages({
2132
1875
  images,
@@ -2149,15 +1892,12 @@ function createGIF(userOptions, callback) {
2149
1892
  });
2150
1893
  }
2151
1894
  }
2152
-
2153
1895
  function takeSnapShot(userOptions, callback) {
2154
1896
  callback = utils.isFunction(userOptions) ? userOptions : callback;
2155
1897
  userOptions = utils.isObject(userOptions) ? userOptions : {};
2156
-
2157
1898
  if (!utils.isFunction(callback)) {
2158
1899
  return;
2159
1900
  }
2160
-
2161
1901
  const mergedOptions = utils.normalizeOptions(defaultOptions, userOptions);
2162
1902
  const options = utils.normalizeOptions(mergedOptions, {
2163
1903
  interval: 0.1,
@@ -2167,7 +1907,6 @@ function takeSnapShot(userOptions, callback) {
2167
1907
  });
2168
1908
  createGIF(options, callback);
2169
1909
  }
2170
-
2171
1910
  const API = {
2172
1911
  utils: utils$2,
2173
1912
  error: error$2,