@loaders.gl/video 3.1.0-beta.3 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
  var utils = {
8
8
  URL: window.URL || window.webkitURL || window.mozURL || window.msURL,
9
9
  getUserMedia: function () {
10
- const getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
10
+ var getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
11
11
  return getUserMedia ? getUserMedia.bind(navigator) : getUserMedia;
12
12
  }(),
13
13
  requestAnimFrame: window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame,
@@ -19,13 +19,13 @@ var utils = {
19
19
  return setTimeout(callback, delay);
20
20
  }
21
21
 
22
- const start = new Date().getTime();
23
- const handle = new Object();
24
- const requestAnimFrame = utils.requestAnimFrame;
22
+ var start = new Date().getTime();
23
+ var handle = new Object();
24
+ var requestAnimFrame = utils.requestAnimFrame;
25
25
 
26
- const loop = function loop() {
27
- const current = new Date().getTime();
28
- const delta = current - start;
26
+ var loop = function loop() {
27
+ var current = new Date().getTime();
28
+ var delta = current - start;
29
29
  delta >= delay ? callback.call() : handle.value = requestAnimFrame(loop);
30
30
  };
31
31
 
@@ -34,18 +34,18 @@ var utils = {
34
34
  },
35
35
  Blob: window.Blob || window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder,
36
36
  btoa: function () {
37
- const btoa = window.btoa || function (input) {
38
- let output = '';
39
- let i = 0;
40
- const l = input.length;
41
- const key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
42
- let chr1 = void 0;
43
- let chr2 = void 0;
44
- let chr3 = void 0;
45
- let enc1 = void 0;
46
- let enc2 = void 0;
47
- let enc3 = void 0;
48
- let enc4 = void 0;
37
+ var btoa = window.btoa || function (input) {
38
+ var output = '';
39
+ var i = 0;
40
+ var l = input.length;
41
+ var key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
42
+ var chr1 = void 0;
43
+ var chr2 = void 0;
44
+ var chr3 = void 0;
45
+ var enc1 = void 0;
46
+ var enc2 = void 0;
47
+ var enc3 = void 0;
48
+ var enc4 = void 0;
49
49
 
50
50
  while (i < l) {
51
51
  chr1 = input.charCodeAt(i++);
@@ -90,7 +90,7 @@ var utils = {
90
90
  },
91
91
  isSupported: {
92
92
  canvas: function canvas() {
93
- const el = document.createElement('canvas');
93
+ var el = document.createElement('canvas');
94
94
  return el && el.getContext && el.getContext('2d');
95
95
  },
96
96
  webworkers: function webworkers() {
@@ -106,8 +106,8 @@ var utils = {
106
106
  return window.Uint32Array;
107
107
  },
108
108
  videoCodecs: function () {
109
- const testEl = document.createElement('video');
110
- const supportObj = {
109
+ var testEl = document.createElement('video');
110
+ var supportObj = {
111
111
  mp4: false,
112
112
  h264: false,
113
113
  ogv: false,
@@ -130,8 +130,8 @@ var utils = {
130
130
  },
131
131
  noop: function noop() {},
132
132
  each: function each(collection, callback) {
133
- let x = void 0;
134
- let len = void 0;
133
+ var x = void 0;
134
+ var len = void 0;
135
135
 
136
136
  if (utils.isArray(collection)) {
137
137
  x = -1;
@@ -157,12 +157,12 @@ var utils = {
157
157
  return;
158
158
  }
159
159
 
160
- const newObj = {};
160
+ var newObj = {};
161
161
  utils.each(defaultOptions, function (key, val) {
162
162
  newObj[key] = defaultOptions[key];
163
163
  });
164
164
  utils.each(userOptions, function (key, val) {
165
- const currentUserOption = userOptions[key];
165
+ var currentUserOption = userOptions[key];
166
166
 
167
167
  if (!utils.isObject(currentUserOption)) {
168
168
  newObj[key] = currentUserOption;
@@ -202,14 +202,14 @@ var utils = {
202
202
  }
203
203
 
204
204
  try {
205
- const blob = new utils.Blob([content], {
205
+ var blob = new utils.Blob([content], {
206
206
  type: 'text/javascript'
207
207
  });
208
- const objectUrl = utils.URL.createObjectURL(blob);
209
- const worker = new Worker(objectUrl);
208
+ var objectUrl = utils.URL.createObjectURL(blob);
209
+ var worker = new Worker(objectUrl);
210
210
  return {
211
- objectUrl,
212
- worker
211
+ objectUrl: objectUrl,
212
+ worker: worker
213
213
  };
214
214
  } catch (e) {
215
215
  return "".concat(e);
@@ -219,18 +219,18 @@ var utils = {
219
219
  return src.substr(src.lastIndexOf('.') + 1, src.length);
220
220
  },
221
221
  getFontSize: function getFontSize() {
222
- const options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
222
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
223
223
 
224
224
  if (!document.body || options.resizeFont === false) {
225
225
  return options.fontSize;
226
226
  }
227
227
 
228
- const text = options.text;
229
- const containerWidth = options.gifWidth;
230
- let fontSize = parseInt(options.fontSize, 10);
231
- const minFontSize = parseInt(options.minFontSize, 10);
232
- const div = document.createElement('div');
233
- const span = document.createElement('span');
228
+ var text = options.text;
229
+ var containerWidth = options.gifWidth;
230
+ var fontSize = parseInt(options.fontSize, 10);
231
+ var minFontSize = parseInt(options.minFontSize, 10);
232
+ var div = document.createElement('div');
233
+ var span = document.createElement('span');
234
234
  div.setAttribute('width', containerWidth);
235
235
  div.appendChild(span);
236
236
  span.innerHTML = text;
@@ -248,15 +248,15 @@ var utils = {
248
248
  },
249
249
  webWorkerError: false
250
250
  };
251
- const utils$2 = Object.freeze({
251
+ var utils$2 = Object.freeze({
252
252
  default: utils
253
253
  });
254
254
  var error = {
255
255
  validate: function validate(skipObj) {
256
256
  skipObj = utils.isObject(skipObj) ? skipObj : {};
257
- let errorObj = {};
257
+ var errorObj = {};
258
258
  utils.each(error.validators, function (indece, currentValidator) {
259
- const errorCode = currentValidator.errorCode;
259
+ var errorCode = currentValidator.errorCode;
260
260
 
261
261
  if (!skipObj[errorCode] && !currentValidator.condition) {
262
262
  errorObj = currentValidator;
@@ -268,8 +268,8 @@ var error = {
268
268
  return errorObj;
269
269
  },
270
270
  isValid: function isValid(skipObj) {
271
- const errorObj = error.validate(skipObj);
272
- const isValid = errorObj.error !== true;
271
+ var errorObj = error.validate(skipObj);
272
+ var isValid = errorObj.error !== true;
273
273
  return isValid;
274
274
  },
275
275
  validators: [{
@@ -308,13 +308,13 @@ var error = {
308
308
  }
309
309
  }
310
310
  };
311
- const error$2 = Object.freeze({
311
+ var error$2 = Object.freeze({
312
312
  default: error
313
313
  });
314
314
 
315
- const noop = function noop() {};
315
+ var noop = function noop() {};
316
316
 
317
- const defaultOptions = {
317
+ var defaultOptions = {
318
318
  sampleInterval: 10,
319
319
  numWorkers: 2,
320
320
  filter: '',
@@ -345,7 +345,7 @@ const defaultOptions = {
345
345
  savedRenderingContexts: [],
346
346
  crossOrigin: 'Anonymous'
347
347
  };
348
- const defaultOptions$2 = Object.freeze({
348
+ var defaultOptions$2 = Object.freeze({
349
349
  default: defaultOptions
350
350
  });
351
351
 
@@ -358,14 +358,14 @@ function isWebCamGIFSupported() {
358
358
  }
359
359
 
360
360
  function isSupported$1() {
361
- const options = {
361
+ var options = {
362
362
  getUserMedia: true
363
363
  };
364
364
  return error.isValid(options);
365
365
  }
366
366
 
367
367
  function isExistingVideoGIFSupported(codecs) {
368
- let hasValidCodec = false;
368
+ var hasValidCodec = false;
369
369
 
370
370
  if (utils.isArray(codecs) && codecs.length) {
371
371
  utils.each(codecs, function (indece, currentCodec) {
@@ -389,46 +389,46 @@ function isExistingVideoGIFSupported(codecs) {
389
389
  }
390
390
 
391
391
  function NeuQuant() {
392
- const netsize = 256;
393
- const prime1 = 499;
394
- const prime2 = 491;
395
- const prime3 = 487;
396
- const prime4 = 503;
397
- const minpicturebytes = 3 * prime4;
398
- const maxnetpos = netsize - 1;
399
- const netbiasshift = 4;
400
- const ncycles = 100;
401
- const intbiasshift = 16;
402
- const intbias = 1 << intbiasshift;
403
- const gammashift = 10;
404
- const gamma = 1 << gammashift;
405
- const betashift = 10;
406
- const beta = intbias >> betashift;
407
- const betagamma = intbias << gammashift - betashift;
408
- const initrad = netsize >> 3;
409
- const radiusbiasshift = 6;
410
- const radiusbias = 1 << radiusbiasshift;
411
- const initradius = initrad * radiusbias;
412
- const radiusdec = 30;
413
- const alphabiasshift = 10;
414
- const initalpha = 1 << alphabiasshift;
415
- let alphadec;
416
- const radbiasshift = 8;
417
- const radbias = 1 << radbiasshift;
418
- const alpharadbshift = alphabiasshift + radbiasshift;
419
- const alpharadbias = 1 << alpharadbshift;
420
- let thepicture;
421
- let lengthcount;
422
- let samplefac;
423
- let network;
424
- const netindex = [];
425
- const bias = [];
426
- const freq = [];
427
- const radpower = [];
392
+ var netsize = 256;
393
+ var prime1 = 499;
394
+ var prime2 = 491;
395
+ var prime3 = 487;
396
+ var prime4 = 503;
397
+ var minpicturebytes = 3 * prime4;
398
+ var maxnetpos = netsize - 1;
399
+ var netbiasshift = 4;
400
+ var ncycles = 100;
401
+ var intbiasshift = 16;
402
+ var intbias = 1 << intbiasshift;
403
+ var gammashift = 10;
404
+ var gamma = 1 << gammashift;
405
+ var betashift = 10;
406
+ var beta = intbias >> betashift;
407
+ var betagamma = intbias << gammashift - betashift;
408
+ var initrad = netsize >> 3;
409
+ var radiusbiasshift = 6;
410
+ var radiusbias = 1 << radiusbiasshift;
411
+ var initradius = initrad * radiusbias;
412
+ var radiusdec = 30;
413
+ var alphabiasshift = 10;
414
+ var initalpha = 1 << alphabiasshift;
415
+ var alphadec;
416
+ var radbiasshift = 8;
417
+ var radbias = 1 << radbiasshift;
418
+ var alpharadbshift = alphabiasshift + radbiasshift;
419
+ var alpharadbias = 1 << alpharadbshift;
420
+ var thepicture;
421
+ var lengthcount;
422
+ var samplefac;
423
+ var network;
424
+ var netindex = [];
425
+ var bias = [];
426
+ var freq = [];
427
+ var radpower = [];
428
428
 
429
429
  function NeuQuantConstructor(thepic, len, sample) {
430
- let i;
431
- let p;
430
+ var i;
431
+ var p;
432
432
  thepicture = thepic;
433
433
  lengthcount = len;
434
434
  samplefac = sample;
@@ -444,17 +444,17 @@ function NeuQuant() {
444
444
  }
445
445
 
446
446
  function colorMap() {
447
- const map = [];
448
- const index = new Array(netsize);
447
+ var map = [];
448
+ var index = new Array(netsize);
449
449
 
450
- for (let i = 0; i < netsize; i++) {
450
+ for (var i = 0; i < netsize; i++) {
451
451
  index[network[i][3]] = i;
452
452
  }
453
453
 
454
- let k = 0;
454
+ var k = 0;
455
455
 
456
- for (let l = 0; l < netsize; l++) {
457
- const j = index[l];
456
+ for (var l = 0; l < netsize; l++) {
457
+ var j = index[l];
458
458
  map[k++] = network[j][0];
459
459
  map[k++] = network[j][1];
460
460
  map[k++] = network[j][2];
@@ -464,14 +464,14 @@ function NeuQuant() {
464
464
  }
465
465
 
466
466
  function inxbuild() {
467
- let i;
468
- let j;
469
- let smallpos;
470
- let smallval;
471
- let p;
472
- let q;
473
- let previouscol;
474
- let startpos;
467
+ var i;
468
+ var j;
469
+ var smallpos;
470
+ var smallval;
471
+ var p;
472
+ var q;
473
+ var previouscol;
474
+ var startpos;
475
475
  previouscol = 0;
476
476
  startpos = 0;
477
477
 
@@ -526,20 +526,20 @@ function NeuQuant() {
526
526
  }
527
527
 
528
528
  function learn() {
529
- let i;
530
- let j;
531
- let b;
532
- let g;
533
- let r;
534
- let radius;
535
- let rad;
536
- let alpha;
537
- let step;
538
- let delta;
539
- let samplepixels;
540
- let p;
541
- let pix;
542
- let lim;
529
+ var i;
530
+ var j;
531
+ var b;
532
+ var g;
533
+ var r;
534
+ var radius;
535
+ var rad;
536
+ var alpha;
537
+ var step;
538
+ var delta;
539
+ var samplepixels;
540
+ var p;
541
+ var pix;
542
+ var lim;
543
543
 
544
544
  if (lengthcount < minpicturebytes) {
545
545
  samplefac = 1;
@@ -617,13 +617,13 @@ function NeuQuant() {
617
617
  }
618
618
 
619
619
  function map(b, g, r) {
620
- let i;
621
- let j;
622
- let dist;
623
- let a;
624
- let bestd;
625
- let p;
626
- let best;
620
+ var i;
621
+ var j;
622
+ var dist;
623
+ var a;
624
+ var bestd;
625
+ var p;
626
+ var best;
627
627
  bestd = 1000;
628
628
  best = -1;
629
629
  i = netindex[g];
@@ -718,8 +718,8 @@ function NeuQuant() {
718
718
  }
719
719
 
720
720
  function unbiasnet() {
721
- let i;
722
- let j;
721
+ var i;
722
+ var j;
723
723
 
724
724
  for (i = 0; i < netsize; i++) {
725
725
  network[i][0] >>= netbiasshift;
@@ -730,13 +730,13 @@ function NeuQuant() {
730
730
  }
731
731
 
732
732
  function alterneigh(rad, i, b, g, r) {
733
- let j;
734
- let k;
735
- let lo;
736
- let hi;
737
- let a;
738
- let m;
739
- let p;
733
+ var j;
734
+ var k;
735
+ var lo;
736
+ var hi;
737
+ var a;
738
+ var m;
739
+ var p;
740
740
  lo = i - rad;
741
741
 
742
742
  if (lo < -1) {
@@ -779,24 +779,24 @@ function NeuQuant() {
779
779
  }
780
780
 
781
781
  function altersingle(alpha, i, b, g, r) {
782
- const n = network[i];
783
- const alphaMult = alpha / initalpha;
782
+ var n = network[i];
783
+ var alphaMult = alpha / initalpha;
784
784
  n[0] -= alphaMult * (n[0] - b) | 0;
785
785
  n[1] -= alphaMult * (n[1] - g) | 0;
786
786
  n[2] -= alphaMult * (n[2] - r) | 0;
787
787
  }
788
788
 
789
789
  function contest(b, g, r) {
790
- let i;
791
- let dist;
792
- let a;
793
- let biasdist;
794
- let betafreq;
795
- let bestpos;
796
- let bestbiaspos;
797
- let bestd;
798
- let bestbiasd;
799
- let n;
790
+ var i;
791
+ var dist;
792
+ var a;
793
+ var biasdist;
794
+ var betafreq;
795
+ var bestpos;
796
+ var bestbiaspos;
797
+ var bestd;
798
+ var bestbiasd;
799
+ var n;
800
800
  bestd = ~(1 << 31);
801
801
  bestbiasd = bestd;
802
802
  bestpos = -1;
@@ -848,19 +848,19 @@ function NeuQuant() {
848
848
  }
849
849
 
850
850
  NeuQuantConstructor.apply(this, arguments);
851
- const exports = {};
851
+ var exports = {};
852
852
  exports.map = map;
853
853
  exports.process = process;
854
854
  return exports;
855
855
  }
856
856
 
857
857
  function workerCode() {
858
- const self = this;
858
+ var self = this;
859
859
 
860
860
  try {
861
861
  self.onmessage = function (ev) {
862
- const data = ev.data || {};
863
- let response;
862
+ var data = ev.data || {};
863
+ var response;
864
864
 
865
865
  if (data.gifshot) {
866
866
  response = workerMethods.run(data);
@@ -871,9 +871,9 @@ function workerCode() {
871
871
 
872
872
  var workerMethods = {
873
873
  dataToRGB: function dataToRGB(data, width, height) {
874
- const length = width * height * 4;
875
- let i = 0;
876
- const rgb = [];
874
+ var length = width * height * 4;
875
+ var i = 0;
876
+ var rgb = [];
877
877
 
878
878
  while (i < length) {
879
879
  rgb.push(data[i++]);
@@ -886,30 +886,30 @@ function workerCode() {
886
886
  },
887
887
  componentizedPaletteToArray: function componentizedPaletteToArray(paletteRGB) {
888
888
  paletteRGB = paletteRGB || [];
889
- const paletteArray = [];
889
+ var paletteArray = [];
890
890
 
891
- for (let i = 0; i < paletteRGB.length; i += 3) {
892
- const r = paletteRGB[i];
893
- const g = paletteRGB[i + 1];
894
- const b = paletteRGB[i + 2];
891
+ for (var i = 0; i < paletteRGB.length; i += 3) {
892
+ var r = paletteRGB[i];
893
+ var g = paletteRGB[i + 1];
894
+ var b = paletteRGB[i + 2];
895
895
  paletteArray.push(r << 16 | g << 8 | b);
896
896
  }
897
897
 
898
898
  return paletteArray;
899
899
  },
900
900
  processFrameWithQuantizer: function processFrameWithQuantizer(imageData, width, height, sampleInterval) {
901
- const rgbComponents = this.dataToRGB(imageData, width, height);
902
- const nq = new NeuQuant(rgbComponents, rgbComponents.length, sampleInterval);
903
- const paletteRGB = nq.process();
904
- const paletteArray = new Uint32Array(this.componentizedPaletteToArray(paletteRGB));
905
- const numberPixels = width * height;
906
- const indexedPixels = new Uint8Array(numberPixels);
907
- let k = 0;
908
-
909
- for (let i = 0; i < numberPixels; i++) {
910
- const r = rgbComponents[k++];
911
- const g = rgbComponents[k++];
912
- const b = rgbComponents[k++];
901
+ var rgbComponents = this.dataToRGB(imageData, width, height);
902
+ var nq = new NeuQuant(rgbComponents, rgbComponents.length, sampleInterval);
903
+ var paletteRGB = nq.process();
904
+ var paletteArray = new Uint32Array(this.componentizedPaletteToArray(paletteRGB));
905
+ var numberPixels = width * height;
906
+ var indexedPixels = new Uint8Array(numberPixels);
907
+ var k = 0;
908
+
909
+ for (var i = 0; i < numberPixels; i++) {
910
+ var r = rgbComponents[k++];
911
+ var g = rgbComponents[k++];
912
+ var b = rgbComponents[k++];
913
913
  indexedPixels[i] = nq.map(r, g, b);
914
914
  }
915
915
 
@@ -920,12 +920,12 @@ function workerCode() {
920
920
  },
921
921
  run: function run(frame) {
922
922
  frame = frame || {};
923
- const _frame = frame;
924
- const height = _frame.height;
925
- const palette = _frame.palette;
926
- const sampleInterval = _frame.sampleInterval;
927
- const width = _frame.width;
928
- const imageData = frame.data;
923
+ var _frame = frame;
924
+ var height = _frame.height;
925
+ var palette = _frame.palette;
926
+ var sampleInterval = _frame.sampleInterval;
927
+ var width = _frame.width;
928
+ var imageData = frame.data;
929
929
  return this.processFrameWithQuantizer(imageData, width, height, sampleInterval);
930
930
  }
931
931
  };
@@ -933,14 +933,14 @@ function workerCode() {
933
933
  }
934
934
 
935
935
  function gifWriter(buf, width, height, gopts) {
936
- let p = 0;
936
+ var p = 0;
937
937
  gopts = gopts === undefined ? {} : gopts;
938
- const loop_count = gopts.loop === undefined ? null : gopts.loop;
939
- const global_palette = gopts.palette === undefined ? null : gopts.palette;
938
+ var loop_count = gopts.loop === undefined ? null : gopts.loop;
939
+ var global_palette = gopts.palette === undefined ? null : gopts.palette;
940
940
  if (width <= 0 || height <= 0 || width > 65535 || height > 65535) throw 'Width/Height invalid.';
941
941
 
942
942
  function check_palette_and_num_colors(palette) {
943
- const num_colors = palette.length;
943
+ var num_colors = palette.length;
944
944
  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.';
945
945
  return num_colors;
946
946
  }
@@ -951,8 +951,8 @@ function gifWriter(buf, width, height, gopts) {
951
951
  buf[p++] = 0x38;
952
952
  buf[p++] = 0x39;
953
953
  buf[p++] = 0x61;
954
- const gp_num_colors_pow2 = 0;
955
- const background = 0;
954
+ var gp_num_colors_pow2 = 0;
955
+ var background = 0;
956
956
  buf[p++] = width & 0xff;
957
957
  buf[p++] = width >> 8 & 0xff;
958
958
  buf[p++] = height & 0xff;
@@ -984,7 +984,7 @@ function gifWriter(buf, width, height, gopts) {
984
984
  buf[p++] = 0x00;
985
985
  }
986
986
 
987
- let ended = false;
987
+ var ended = false;
988
988
 
989
989
  this.addFrame = function (x, y, w, h, indexed_pixels, opts) {
990
990
  if (ended === true) {
@@ -996,8 +996,8 @@ function gifWriter(buf, width, height, gopts) {
996
996
  if (x < 0 || y < 0 || x > 65535 || y > 65535) throw 'x/y invalid.';
997
997
  if (w <= 0 || h <= 0 || w > 65535 || h > 65535) throw 'Width/Height invalid.';
998
998
  if (indexed_pixels.length < w * h) throw 'Not enough pixels for the frame size.';
999
- let using_local_palette = true;
1000
- let palette = opts.palette;
999
+ var using_local_palette = true;
1000
+ var palette = opts.palette;
1001
1001
 
1002
1002
  if (palette === undefined || palette === null) {
1003
1003
  using_local_palette = false;
@@ -1005,19 +1005,19 @@ function gifWriter(buf, width, height, gopts) {
1005
1005
  }
1006
1006
 
1007
1007
  if (palette === undefined || palette === null) throw 'Must supply either a local or global palette.';
1008
- let num_colors = check_palette_and_num_colors(palette);
1009
- let min_code_size = 0;
1008
+ var num_colors = check_palette_and_num_colors(palette);
1009
+ var min_code_size = 0;
1010
1010
 
1011
1011
  while (num_colors >>= 1) {
1012
1012
  ++min_code_size;
1013
1013
  }
1014
1014
 
1015
1015
  num_colors = 1 << min_code_size;
1016
- const delay = opts.delay === undefined ? 0 : opts.delay;
1017
- const disposal = opts.disposal === undefined ? 0 : opts.disposal;
1016
+ var delay = opts.delay === undefined ? 0 : opts.delay;
1017
+ var disposal = opts.disposal === undefined ? 0 : opts.disposal;
1018
1018
  if (disposal < 0 || disposal > 3) throw 'Disposal out of range.';
1019
- let use_transparency = false;
1020
- let transparent_index = 0;
1019
+ var use_transparency = false;
1020
+ var transparent_index = 0;
1021
1021
 
1022
1022
  if (opts.transparent !== undefined && opts.transparent !== null) {
1023
1023
  use_transparency = true;
@@ -1048,8 +1048,8 @@ function gifWriter(buf, width, height, gopts) {
1048
1048
  buf[p++] = using_local_palette === true ? 0x80 | min_code_size - 1 : 0;
1049
1049
 
1050
1050
  if (using_local_palette === true) {
1051
- for (let i = 0, il = palette.length; i < il; ++i) {
1052
- const rgb = palette[i];
1051
+ for (var i = 0, il = palette.length; i < il; ++i) {
1052
+ var rgb = palette[i];
1053
1053
  buf[p++] = rgb >> 16 & 0xff;
1054
1054
  buf[p++] = rgb >> 8 & 0xff;
1055
1055
  buf[p++] = rgb & 0xff;
@@ -1070,14 +1070,14 @@ function gifWriter(buf, width, height, gopts) {
1070
1070
 
1071
1071
  function GifWriterOutputLZWCodeStream(buf, p, min_code_size, index_stream) {
1072
1072
  buf[p++] = min_code_size;
1073
- let cur_subblock = p++;
1074
- const clear_code = 1 << min_code_size;
1075
- const code_mask = clear_code - 1;
1076
- const eoi_code = clear_code + 1;
1077
- let next_code = eoi_code + 1;
1078
- let cur_code_size = min_code_size + 1;
1079
- let cur_shift = 0;
1080
- let cur = 0;
1073
+ var cur_subblock = p++;
1074
+ var clear_code = 1 << min_code_size;
1075
+ var code_mask = clear_code - 1;
1076
+ var eoi_code = clear_code + 1;
1077
+ var next_code = eoi_code + 1;
1078
+ var cur_code_size = min_code_size + 1;
1079
+ var cur_shift = 0;
1080
+ var cur = 0;
1081
1081
 
1082
1082
  function emit_bytes_to_buffer(bit_block_size) {
1083
1083
  while (cur_shift >= bit_block_size) {
@@ -1098,14 +1098,14 @@ function gifWriter(buf, width, height, gopts) {
1098
1098
  emit_bytes_to_buffer(8);
1099
1099
  }
1100
1100
 
1101
- let ib_code = index_stream[0] & code_mask;
1102
- let code_table = {};
1101
+ var ib_code = index_stream[0] & code_mask;
1102
+ var code_table = {};
1103
1103
  emit_code(clear_code);
1104
1104
 
1105
- for (let i = 1, il = index_stream.length; i < il; ++i) {
1106
- const k = index_stream[i] & code_mask;
1107
- const cur_key = ib_code << 8 | k;
1108
- const cur_code = code_table[cur_key];
1105
+ for (var i = 1, il = index_stream.length; i < il; ++i) {
1106
+ var k = index_stream[i] & code_mask;
1107
+ var cur_key = ib_code << 8 | k;
1108
+ var cur_code = code_table[cur_key];
1109
1109
 
1110
1110
  if (cur_code === undefined) {
1111
1111
  cur |= ib_code << cur_shift;
@@ -1153,9 +1153,9 @@ function gifWriter(buf, width, height, gopts) {
1153
1153
  }
1154
1154
  }
1155
1155
 
1156
- const noop$2 = function noop() {};
1156
+ var noop$2 = function noop() {};
1157
1157
 
1158
- const AnimatedGIF = function AnimatedGIF(options) {
1158
+ var AnimatedGIF = function AnimatedGIF(options) {
1159
1159
  this.canvas = null;
1160
1160
  this.ctx = null;
1161
1161
  this.repeat = 0;
@@ -1173,14 +1173,14 @@ const AnimatedGIF = function AnimatedGIF(options) {
1173
1173
  AnimatedGIF.prototype = {
1174
1174
  workerMethods: workerCode(),
1175
1175
  initializeWebWorkers: function initializeWebWorkers(options) {
1176
- const self = this;
1177
- const processFrameWorkerCode = "".concat(NeuQuant.toString(), "(").concat(workerCode.toString(), "());");
1178
- let webWorkerObj = void 0;
1179
- let objectUrl = void 0;
1180
- let webWorker = void 0;
1181
- let numWorkers = void 0;
1182
- let x = -1;
1183
- let workerError = '';
1176
+ var self = this;
1177
+ var processFrameWorkerCode = "".concat(NeuQuant.toString(), "(").concat(workerCode.toString(), "());");
1178
+ var webWorkerObj = void 0;
1179
+ var objectUrl = void 0;
1180
+ var webWorker = void 0;
1181
+ var numWorkers = void 0;
1182
+ var x = -1;
1183
+ var workerError = '';
1184
1184
  numWorkers = options.numWorkers;
1185
1185
 
1186
1186
  while (++x < numWorkers) {
@@ -1191,7 +1191,7 @@ AnimatedGIF.prototype = {
1191
1191
  webWorker = webWorkerObj.worker;
1192
1192
  self.workers.push({
1193
1193
  worker: webWorker,
1194
- objectUrl
1194
+ objectUrl: objectUrl
1195
1195
  });
1196
1196
  self.availableWorkers.push(webWorker);
1197
1197
  } else {
@@ -1214,18 +1214,18 @@ AnimatedGIF.prototype = {
1214
1214
  this.availableWorkers.push(worker);
1215
1215
  },
1216
1216
  byteMap: function () {
1217
- const byteMap = [];
1217
+ var byteMap = [];
1218
1218
 
1219
- for (let i = 0; i < 256; i++) {
1219
+ for (var i = 0; i < 256; i++) {
1220
1220
  byteMap[i] = String.fromCharCode(i);
1221
1221
  }
1222
1222
 
1223
1223
  return byteMap;
1224
1224
  }(),
1225
1225
  bufferToString: function bufferToString(buffer) {
1226
- const numberValues = buffer.length;
1227
- let str = '';
1228
- let x = -1;
1226
+ var numberValues = buffer.length;
1227
+ var str = '';
1228
+ var x = -1;
1229
1229
 
1230
1230
  while (++x < numberValues) {
1231
1231
  str += this.byteMap[buffer[x]];
@@ -1234,11 +1234,11 @@ AnimatedGIF.prototype = {
1234
1234
  return str;
1235
1235
  },
1236
1236
  onFrameFinished: function onFrameFinished(progressCallback) {
1237
- const self = this;
1238
- const frames = self.frames;
1239
- const options = self.options;
1240
- const hasExistingImages = Boolean((options.images || []).length);
1241
- const allDone = frames.every(function (frame) {
1237
+ var self = this;
1238
+ var frames = self.frames;
1239
+ var options = self.options;
1240
+ var hasExistingImages = Boolean((options.images || []).length);
1241
+ var allDone = frames.every(function (frame) {
1242
1242
  return !frame.beingProcessed && frame.done;
1243
1243
  });
1244
1244
  self.numRenderedFrames++;
@@ -1260,18 +1260,18 @@ AnimatedGIF.prototype = {
1260
1260
  }
1261
1261
  },
1262
1262
  processFrame: function processFrame(position) {
1263
- const AnimatedGifContext = this;
1264
- const options = this.options;
1265
- const _options = this.options;
1266
- const progressCallback = _options.progressCallback;
1267
- const sampleInterval = _options.sampleInterval;
1268
- const frames = this.frames;
1269
- let frame = void 0;
1270
- let worker = void 0;
1271
-
1272
- const done = function done() {
1273
- const ev = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1274
- const data = ev.data;
1263
+ var AnimatedGifContext = this;
1264
+ var options = this.options;
1265
+ var _options = this.options;
1266
+ var progressCallback = _options.progressCallback;
1267
+ var sampleInterval = _options.sampleInterval;
1268
+ var frames = this.frames;
1269
+ var frame = void 0;
1270
+ var worker = void 0;
1271
+
1272
+ var done = function done() {
1273
+ var ev = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1274
+ var data = ev.data;
1275
1275
  delete frame.data;
1276
1276
  frame.pixels = Array.prototype.slice.call(data.pixels);
1277
1277
  frame.palette = Array.prototype.slice.call(data.palette);
@@ -1305,15 +1305,15 @@ AnimatedGIF.prototype = {
1305
1305
  startRendering: function startRendering(completeCallback) {
1306
1306
  this.onRenderCompleteCallback = completeCallback;
1307
1307
 
1308
- for (let i = 0; i < this.options.numWorkers && i < this.frames.length; i++) {
1308
+ for (var i = 0; i < this.options.numWorkers && i < this.frames.length; i++) {
1309
1309
  this.processFrame(i);
1310
1310
  }
1311
1311
  },
1312
1312
  processNextFrame: function processNextFrame() {
1313
- let position = -1;
1313
+ var position = -1;
1314
1314
 
1315
- for (let i = 0; i < this.frames.length; i++) {
1316
- const frame = this.frames[i];
1315
+ for (var i = 0; i < this.frames.length; i++) {
1316
+ var frame = this.frames[i];
1317
1317
 
1318
1318
  if (!frame.done && !frame.beingProcessed) {
1319
1319
  position = i;
@@ -1326,31 +1326,31 @@ AnimatedGIF.prototype = {
1326
1326
  }
1327
1327
  },
1328
1328
  generateGIF: function generateGIF(frames, callback) {
1329
- const buffer = [];
1330
- const gifOptions = {
1329
+ var buffer = [];
1330
+ var gifOptions = {
1331
1331
  loop: this.repeat
1332
1332
  };
1333
- const options = this.options;
1334
- const interval = options.interval;
1335
- const frameDuration = options.frameDuration;
1336
- const existingImages = options.images;
1337
- const hasExistingImages = Boolean(existingImages.length);
1338
- const height = options.gifHeight;
1339
- const width = options.gifWidth;
1340
- const gifWriter$$1 = new gifWriter(buffer, width, height, gifOptions);
1341
- const onRenderProgressCallback = this.onRenderProgressCallback;
1342
- const delay = hasExistingImages ? interval * 100 : 0;
1343
- let bufferToString = void 0;
1344
- let gif = void 0;
1333
+ var options = this.options;
1334
+ var interval = options.interval;
1335
+ var frameDuration = options.frameDuration;
1336
+ var existingImages = options.images;
1337
+ var hasExistingImages = Boolean(existingImages.length);
1338
+ var height = options.gifHeight;
1339
+ var width = options.gifWidth;
1340
+ var gifWriter$$1 = new gifWriter(buffer, width, height, gifOptions);
1341
+ var onRenderProgressCallback = this.onRenderProgressCallback;
1342
+ var delay = hasExistingImages ? interval * 100 : 0;
1343
+ var bufferToString = void 0;
1344
+ var gif = void 0;
1345
1345
  this.generatingGIF = true;
1346
1346
  utils.each(frames, function (iterator, frame) {
1347
- const framePalette = frame.palette;
1347
+ var framePalette = frame.palette;
1348
1348
  onRenderProgressCallback(0.75 + 0.25 * frame.position * 1.0 / frames.length);
1349
1349
 
1350
- for (let i = 0; i < frameDuration; i++) {
1350
+ for (var i = 0; i < frameDuration; i++) {
1351
1351
  gifWriter$$1.addFrame(0, 0, width, height, frame.pixels, {
1352
1352
  palette: framePalette,
1353
- delay
1353
+ delay: delay
1354
1354
  });
1355
1355
  }
1356
1356
  });
@@ -1370,26 +1370,26 @@ AnimatedGIF.prototype = {
1370
1370
  },
1371
1371
  addFrame: function addFrame(element, gifshotOptions) {
1372
1372
  gifshotOptions = utils.isObject(gifshotOptions) ? gifshotOptions : {};
1373
- const self = this;
1374
- const ctx = self.ctx;
1375
- const options = self.options;
1376
- const width = options.gifWidth;
1377
- const height = options.gifHeight;
1378
- const fontSize = utils.getFontSize(gifshotOptions);
1379
- const _gifshotOptions = gifshotOptions;
1380
- const filter = _gifshotOptions.filter;
1381
- const fontColor = _gifshotOptions.fontColor;
1382
- const fontFamily = _gifshotOptions.fontFamily;
1383
- const fontWeight = _gifshotOptions.fontWeight;
1384
- const gifHeight = _gifshotOptions.gifHeight;
1385
- const gifWidth = _gifshotOptions.gifWidth;
1386
- const text = _gifshotOptions.text;
1387
- const textAlign = _gifshotOptions.textAlign;
1388
- const textBaseline = _gifshotOptions.textBaseline;
1389
- const textXCoordinate = gifshotOptions.textXCoordinate ? gifshotOptions.textXCoordinate : textAlign === 'left' ? 1 : textAlign === 'right' ? width : width / 2;
1390
- const textYCoordinate = gifshotOptions.textYCoordinate ? gifshotOptions.textYCoordinate : textBaseline === 'top' ? 1 : textBaseline === 'center' ? height / 2 : height;
1391
- const font = "".concat(fontWeight, " ").concat(fontSize, " ").concat(fontFamily);
1392
- let imageData = void 0;
1373
+ var self = this;
1374
+ var ctx = self.ctx;
1375
+ var options = self.options;
1376
+ var width = options.gifWidth;
1377
+ var height = options.gifHeight;
1378
+ var fontSize = utils.getFontSize(gifshotOptions);
1379
+ var _gifshotOptions = gifshotOptions;
1380
+ var filter = _gifshotOptions.filter;
1381
+ var fontColor = _gifshotOptions.fontColor;
1382
+ var fontFamily = _gifshotOptions.fontFamily;
1383
+ var fontWeight = _gifshotOptions.fontWeight;
1384
+ var gifHeight = _gifshotOptions.gifHeight;
1385
+ var gifWidth = _gifshotOptions.gifWidth;
1386
+ var text = _gifshotOptions.text;
1387
+ var textAlign = _gifshotOptions.textAlign;
1388
+ var textBaseline = _gifshotOptions.textBaseline;
1389
+ var textXCoordinate = gifshotOptions.textXCoordinate ? gifshotOptions.textXCoordinate : textAlign === 'left' ? 1 : textAlign === 'right' ? width : width / 2;
1390
+ var textYCoordinate = gifshotOptions.textYCoordinate ? gifshotOptions.textYCoordinate : textBaseline === 'top' ? 1 : textBaseline === 'center' ? height / 2 : height;
1391
+ var font = "".concat(fontWeight, " ").concat(fontSize, " ").concat(fontFamily);
1392
+ var imageData = void 0;
1393
1393
 
1394
1394
  try {
1395
1395
  ctx.filter = filter;
@@ -1410,9 +1410,9 @@ AnimatedGIF.prototype = {
1410
1410
  }
1411
1411
  },
1412
1412
  addFrameImageData: function addFrameImageData() {
1413
- const imageData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1414
- const frames = this.frames;
1415
- const imageDataArray = imageData.data;
1413
+ var imageData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1414
+ var frames = this.frames;
1415
+ var imageDataArray = imageData.data;
1416
1416
  this.frames.push({
1417
1417
  data: imageDataArray,
1418
1418
  width: imageData.width,
@@ -1431,9 +1431,9 @@ AnimatedGIF.prototype = {
1431
1431
  return this.generatingGIF;
1432
1432
  },
1433
1433
  getBase64GIF: function getBase64GIF(completeCallback) {
1434
- const self = this;
1434
+ var self = this;
1435
1435
 
1436
- const onRenderComplete = function onRenderComplete(gif) {
1436
+ var onRenderComplete = function onRenderComplete(gif) {
1437
1437
  self.destroyWorkers();
1438
1438
  utils.requestTimeout(function () {
1439
1439
  completeCallback(gif);
@@ -1447,10 +1447,10 @@ AnimatedGIF.prototype = {
1447
1447
  return;
1448
1448
  }
1449
1449
 
1450
- const workers = this.workers;
1450
+ var workers = this.workers;
1451
1451
  utils.each(workers, function (iterator, workerObj) {
1452
- const worker = workerObj.worker;
1453
- const objectUrl = workerObj.objectUrl;
1452
+ var worker = workerObj.worker;
1453
+ var objectUrl = workerObj.objectUrl;
1454
1454
  worker.terminate();
1455
1455
  utils.URL.revokeObjectURL(objectUrl);
1456
1456
  });
@@ -1463,27 +1463,27 @@ function getBase64GIF(animatedGifInstance, callback) {
1463
1463
  error: false,
1464
1464
  errorCode: '',
1465
1465
  errorMsg: '',
1466
- image
1466
+ image: image
1467
1467
  });
1468
1468
  });
1469
1469
  }
1470
1470
 
1471
1471
  function existingImages() {
1472
- const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1473
- const self = this;
1474
- const callback = obj.callback;
1475
- const images = obj.images;
1476
- const options = obj.options;
1477
- let imagesLength = obj.imagesLength;
1478
- const skipObj = {
1472
+ var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1473
+ var self = this;
1474
+ var callback = obj.callback;
1475
+ var images = obj.images;
1476
+ var options = obj.options;
1477
+ var imagesLength = obj.imagesLength;
1478
+ var skipObj = {
1479
1479
  getUserMedia: true,
1480
1480
  'window.URL': true
1481
1481
  };
1482
- const errorObj = error.validate(skipObj);
1483
- const loadedImages = [];
1484
- let loadedImagesLength = 0;
1485
- let tempImage = void 0;
1486
- let ag = void 0;
1482
+ var errorObj = error.validate(skipObj);
1483
+ var loadedImages = [];
1484
+ var loadedImagesLength = 0;
1485
+ var tempImage = void 0;
1486
+ var ag = void 0;
1487
1487
 
1488
1488
  if (errorObj.error) {
1489
1489
  return callback(errorObj);
@@ -1491,7 +1491,7 @@ function existingImages() {
1491
1491
 
1492
1492
  ag = new AnimatedGIF(options);
1493
1493
  utils.each(images, function (index, image) {
1494
- const currentImage = image;
1494
+ var currentImage = image;
1495
1495
 
1496
1496
  if (utils.isElement(currentImage)) {
1497
1497
  if (options.crossOrigin) {
@@ -1517,7 +1517,7 @@ function existingImages() {
1517
1517
  }
1518
1518
 
1519
1519
  tempImage.onerror = function (e) {
1520
- let obj = void 0;
1520
+ var obj = void 0;
1521
1521
  --imagesLength;
1522
1522
 
1523
1523
  if (imagesLength === 0) {
@@ -1571,55 +1571,55 @@ function existingImages() {
1571
1571
  }
1572
1572
  }
1573
1573
 
1574
- const noop$3 = function noop() {};
1574
+ var noop$3 = function noop() {};
1575
1575
 
1576
- const screenShot = {
1576
+ var screenShot = {
1577
1577
  getGIF: function getGIF() {
1578
- const options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1579
- let callback = arguments[1];
1578
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1579
+ var callback = arguments[1];
1580
1580
  callback = utils.isFunction(callback) ? callback : noop$3;
1581
- const canvas = document.createElement('canvas');
1582
- let context = void 0;
1583
- const existingImages = options.images;
1584
- const hasExistingImages = Boolean(existingImages.length);
1585
- const cameraStream = options.cameraStream;
1586
- const crop = options.crop;
1587
- const filter = options.filter;
1588
- const fontColor = options.fontColor;
1589
- const fontFamily = options.fontFamily;
1590
- const fontWeight = options.fontWeight;
1591
- const keepCameraOn = options.keepCameraOn;
1592
- const numWorkers = options.numWorkers;
1593
- const progressCallback = options.progressCallback;
1594
- const saveRenderingContexts = options.saveRenderingContexts;
1595
- const savedRenderingContexts = options.savedRenderingContexts;
1596
- const text = options.text;
1597
- const textAlign = options.textAlign;
1598
- const textBaseline = options.textBaseline;
1599
- const videoElement = options.videoElement;
1600
- const videoHeight = options.videoHeight;
1601
- const videoWidth = options.videoWidth;
1602
- const webcamVideoElement = options.webcamVideoElement;
1603
- const gifWidth = Number(options.gifWidth);
1604
- const gifHeight = Number(options.gifHeight);
1605
- let interval = Number(options.interval);
1606
- const sampleInterval = Number(options.sampleInterval);
1607
- const waitBetweenFrames = hasExistingImages ? 0 : interval * 1000;
1608
- const renderingContextsToSave = [];
1609
- let numFrames = savedRenderingContexts.length ? savedRenderingContexts.length : options.numFrames;
1610
- let pendingFrames = numFrames;
1611
- const ag = new AnimatedGIF(options);
1612
- const fontSize = utils.getFontSize(options);
1613
- const textXCoordinate = options.textXCoordinate ? options.textXCoordinate : textAlign === 'left' ? 1 : textAlign === 'right' ? gifWidth : gifWidth / 2;
1614
- const textYCoordinate = options.textYCoordinate ? options.textYCoordinate : textBaseline === 'top' ? 1 : textBaseline === 'center' ? gifHeight / 2 : gifHeight;
1615
- const font = "".concat(fontWeight, " ").concat(fontSize, " ").concat(fontFamily);
1616
- let sourceX = crop ? Math.floor(crop.scaledWidth / 2) : 0;
1617
- let sourceWidth = crop ? videoWidth - crop.scaledWidth : 0;
1618
- let sourceY = crop ? Math.floor(crop.scaledHeight / 2) : 0;
1619
- let sourceHeight = crop ? videoHeight - crop.scaledHeight : 0;
1620
-
1621
- const captureFrames = function captureSingleFrame() {
1622
- const framesLeft = pendingFrames - 1;
1581
+ var canvas = document.createElement('canvas');
1582
+ var context = void 0;
1583
+ var existingImages = options.images;
1584
+ var hasExistingImages = Boolean(existingImages.length);
1585
+ var cameraStream = options.cameraStream;
1586
+ var crop = options.crop;
1587
+ var filter = options.filter;
1588
+ var fontColor = options.fontColor;
1589
+ var fontFamily = options.fontFamily;
1590
+ var fontWeight = options.fontWeight;
1591
+ var keepCameraOn = options.keepCameraOn;
1592
+ var numWorkers = options.numWorkers;
1593
+ var progressCallback = options.progressCallback;
1594
+ var saveRenderingContexts = options.saveRenderingContexts;
1595
+ var savedRenderingContexts = options.savedRenderingContexts;
1596
+ var text = options.text;
1597
+ var textAlign = options.textAlign;
1598
+ var textBaseline = options.textBaseline;
1599
+ var videoElement = options.videoElement;
1600
+ var videoHeight = options.videoHeight;
1601
+ var videoWidth = options.videoWidth;
1602
+ var webcamVideoElement = options.webcamVideoElement;
1603
+ var gifWidth = Number(options.gifWidth);
1604
+ var gifHeight = Number(options.gifHeight);
1605
+ var interval = Number(options.interval);
1606
+ var sampleInterval = Number(options.sampleInterval);
1607
+ var waitBetweenFrames = hasExistingImages ? 0 : interval * 1000;
1608
+ var renderingContextsToSave = [];
1609
+ var numFrames = savedRenderingContexts.length ? savedRenderingContexts.length : options.numFrames;
1610
+ var pendingFrames = numFrames;
1611
+ var ag = new AnimatedGIF(options);
1612
+ var fontSize = utils.getFontSize(options);
1613
+ var textXCoordinate = options.textXCoordinate ? options.textXCoordinate : textAlign === 'left' ? 1 : textAlign === 'right' ? gifWidth : gifWidth / 2;
1614
+ var textYCoordinate = options.textYCoordinate ? options.textYCoordinate : textBaseline === 'top' ? 1 : textBaseline === 'center' ? gifHeight / 2 : gifHeight;
1615
+ var font = "".concat(fontWeight, " ").concat(fontSize, " ").concat(fontFamily);
1616
+ var sourceX = crop ? Math.floor(crop.scaledWidth / 2) : 0;
1617
+ var sourceWidth = crop ? videoWidth - crop.scaledWidth : 0;
1618
+ var sourceY = crop ? Math.floor(crop.scaledHeight / 2) : 0;
1619
+ var sourceHeight = crop ? videoHeight - crop.scaledHeight : 0;
1620
+
1621
+ var captureFrames = function captureSingleFrame() {
1622
+ var framesLeft = pendingFrames - 1;
1623
1623
 
1624
1624
  if (savedRenderingContexts.length) {
1625
1625
  context.putImageData(savedRenderingContexts[numFrames - pendingFrames], 0, 0);
@@ -1659,7 +1659,7 @@ const screenShot = {
1659
1659
  }
1660
1660
 
1661
1661
  function finishCapture() {
1662
- let imageData = void 0;
1662
+ var imageData = void 0;
1663
1663
 
1664
1664
  if (saveRenderingContexts) {
1665
1665
  renderingContextsToSave.push(context.getImageData(0, 0, gifWidth, gifHeight));
@@ -1688,12 +1688,12 @@ const screenShot = {
1688
1688
  error: false,
1689
1689
  errorCode: '',
1690
1690
  errorMsg: '',
1691
- image,
1692
- cameraStream,
1693
- videoElement,
1694
- webcamVideoElement,
1691
+ image: image,
1692
+ cameraStream: cameraStream,
1693
+ videoElement: videoElement,
1694
+ webcamVideoElement: webcamVideoElement,
1695
1695
  savedRenderingContexts: renderingContextsToSave,
1696
- keepCameraOn
1696
+ keepCameraOn: keepCameraOn
1697
1697
  });
1698
1698
  });
1699
1699
  }
@@ -1716,12 +1716,12 @@ const screenShot = {
1716
1716
  })();
1717
1717
  },
1718
1718
  getCropDimensions: function getCropDimensions() {
1719
- const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1720
- const width = obj.videoWidth;
1721
- const height = obj.videoHeight;
1722
- const gifWidth = obj.gifWidth;
1723
- const gifHeight = obj.gifHeight;
1724
- const result = {
1719
+ var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1720
+ var width = obj.videoWidth;
1721
+ var height = obj.videoHeight;
1722
+ var gifWidth = obj.gifWidth;
1723
+ var gifHeight = obj.gifHeight;
1724
+ var result = {
1725
1725
  width: 0,
1726
1726
  height: 0,
1727
1727
  scaledWidth: 0,
@@ -1747,9 +1747,9 @@ var videoStream = {
1747
1747
  },
1748
1748
  findVideoSize: function findVideoSizeMethod(obj) {
1749
1749
  findVideoSizeMethod.attempts = findVideoSizeMethod.attempts || 0;
1750
- const cameraStream = obj.cameraStream;
1751
- const completedCallback = obj.completedCallback;
1752
- const videoElement = obj.videoElement;
1750
+ var cameraStream = obj.cameraStream;
1751
+ var completedCallback = obj.completedCallback;
1752
+ var videoElement = obj.videoElement;
1753
1753
 
1754
1754
  if (!videoElement) {
1755
1755
  return;
@@ -1758,8 +1758,8 @@ var videoStream = {
1758
1758
  if (videoElement.videoWidth > 0 && videoElement.videoHeight > 0) {
1759
1759
  videoElement.removeEventListener('loadeddata', videoStream.findVideoSize);
1760
1760
  completedCallback({
1761
- videoElement,
1762
- cameraStream,
1761
+ videoElement: videoElement,
1762
+ cameraStream: cameraStream,
1763
1763
  videoWidth: videoElement.videoWidth,
1764
1764
  videoHeight: videoElement.videoHeight
1765
1765
  });
@@ -1770,8 +1770,8 @@ var videoStream = {
1770
1770
  }, 400);
1771
1771
  } else {
1772
1772
  completedCallback({
1773
- videoElement,
1774
- cameraStream,
1773
+ videoElement: videoElement,
1774
+ cameraStream: cameraStream,
1775
1775
  videoWidth: videoStream.defaultVideoDimensions.width,
1776
1776
  videoHeight: videoStream.defaultVideoDimensions.height
1777
1777
  });
@@ -1789,11 +1789,11 @@ var videoStream = {
1789
1789
  }
1790
1790
  },
1791
1791
  stream: function stream(obj) {
1792
- const existingVideo = utils.isArray(obj.existingVideo) ? obj.existingVideo[0] : obj.existingVideo;
1793
- const cameraStream = obj.cameraStream;
1794
- const completedCallback = obj.completedCallback;
1795
- const streamedCallback = obj.streamedCallback;
1796
- const videoElement = obj.videoElement;
1792
+ var existingVideo = utils.isArray(obj.existingVideo) ? obj.existingVideo[0] : obj.existingVideo;
1793
+ var cameraStream = obj.cameraStream;
1794
+ var completedCallback = obj.completedCallback;
1795
+ var streamedCallback = obj.streamedCallback;
1796
+ var videoElement = obj.videoElement;
1797
1797
 
1798
1798
  if (utils.isFunction(streamedCallback)) {
1799
1799
  streamedCallback();
@@ -1827,9 +1827,9 @@ var videoStream = {
1827
1827
 
1828
1828
  if (videoStream.loadedData === true) {
1829
1829
  videoStream.findVideoSize({
1830
- videoElement,
1831
- cameraStream,
1832
- completedCallback
1830
+ videoElement: videoElement,
1831
+ cameraStream: cameraStream,
1832
+ completedCallback: completedCallback
1833
1833
  });
1834
1834
  videoStream.loadedData = false;
1835
1835
  } else {
@@ -1837,9 +1837,9 @@ var videoStream = {
1837
1837
 
1838
1838
  if (checkLoadedData.count > 10) {
1839
1839
  videoStream.findVideoSize({
1840
- videoElement,
1841
- cameraStream,
1842
- completedCallback
1840
+ videoElement: videoElement,
1841
+ cameraStream: cameraStream,
1842
+ completedCallback: completedCallback
1843
1843
  });
1844
1844
  } else {
1845
1845
  checkLoadedData();
@@ -1848,16 +1848,16 @@ var videoStream = {
1848
1848
  }, 0);
1849
1849
  },
1850
1850
  startStreaming: function startStreaming(obj) {
1851
- const errorCallback = utils.isFunction(obj.error) ? obj.error : utils.noop;
1852
- const streamedCallback = utils.isFunction(obj.streamed) ? obj.streamed : utils.noop;
1853
- const completedCallback = utils.isFunction(obj.completed) ? obj.completed : utils.noop;
1854
- const crossOrigin = obj.crossOrigin;
1855
- const existingVideo = obj.existingVideo;
1856
- const lastCameraStream = obj.lastCameraStream;
1857
- const options = obj.options;
1858
- const webcamVideoElement = obj.webcamVideoElement;
1859
- const videoElement = utils.isElement(existingVideo) ? existingVideo : webcamVideoElement ? webcamVideoElement : document.createElement('video');
1860
- const cameraStream = void 0;
1851
+ var errorCallback = utils.isFunction(obj.error) ? obj.error : utils.noop;
1852
+ var streamedCallback = utils.isFunction(obj.streamed) ? obj.streamed : utils.noop;
1853
+ var completedCallback = utils.isFunction(obj.completed) ? obj.completed : utils.noop;
1854
+ var crossOrigin = obj.crossOrigin;
1855
+ var existingVideo = obj.existingVideo;
1856
+ var lastCameraStream = obj.lastCameraStream;
1857
+ var options = obj.options;
1858
+ var webcamVideoElement = obj.webcamVideoElement;
1859
+ var videoElement = utils.isElement(existingVideo) ? existingVideo : webcamVideoElement ? webcamVideoElement : document.createElement('video');
1860
+ var cameraStream = void 0;
1861
1861
 
1862
1862
  if (crossOrigin) {
1863
1863
  videoElement.crossOrigin = options.crossOrigin;
@@ -1876,36 +1876,36 @@ var videoStream = {
1876
1876
 
1877
1877
  if (existingVideo) {
1878
1878
  videoStream.stream({
1879
- videoElement,
1880
- existingVideo,
1881
- completedCallback
1879
+ videoElement: videoElement,
1880
+ existingVideo: existingVideo,
1881
+ completedCallback: completedCallback
1882
1882
  });
1883
1883
  } else if (lastCameraStream) {
1884
1884
  videoStream.stream({
1885
- videoElement,
1885
+ videoElement: videoElement,
1886
1886
  cameraStream: lastCameraStream,
1887
- streamedCallback,
1888
- completedCallback
1887
+ streamedCallback: streamedCallback,
1888
+ completedCallback: completedCallback
1889
1889
  });
1890
1890
  } else {
1891
1891
  utils.getUserMedia({
1892
1892
  video: true
1893
1893
  }, function (stream) {
1894
1894
  videoStream.stream({
1895
- videoElement,
1895
+ videoElement: videoElement,
1896
1896
  cameraStream: stream,
1897
- streamedCallback,
1898
- completedCallback
1897
+ streamedCallback: streamedCallback,
1898
+ completedCallback: completedCallback
1899
1899
  });
1900
1900
  }, errorCallback);
1901
1901
  }
1902
1902
  },
1903
1903
  startVideoStreaming: function startVideoStreaming(callback) {
1904
- const options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1905
- const timeoutLength = options.timeout !== undefined ? options.timeout : 0;
1906
- const originalCallback = options.callback;
1907
- const webcamVideoElement = options.webcamVideoElement;
1908
- let noGetUserMediaSupportTimeout = void 0;
1904
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1905
+ var timeoutLength = options.timeout !== undefined ? options.timeout : 0;
1906
+ var originalCallback = options.callback;
1907
+ var webcamVideoElement = options.webcamVideoElement;
1908
+ var noGetUserMediaSupportTimeout = void 0;
1909
1909
 
1910
1910
  if (timeoutLength > 0) {
1911
1911
  noGetUserMediaSupportTimeout = utils.requestTimeout(function () {
@@ -1927,34 +1927,34 @@ var videoStream = {
1927
1927
  clearTimeout(noGetUserMediaSupportTimeout);
1928
1928
  },
1929
1929
  completed: function completed() {
1930
- const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1931
- const cameraStream = obj.cameraStream;
1932
- const videoElement = obj.videoElement;
1933
- const videoHeight = obj.videoHeight;
1934
- const videoWidth = obj.videoWidth;
1930
+ var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1931
+ var cameraStream = obj.cameraStream;
1932
+ var videoElement = obj.videoElement;
1933
+ var videoHeight = obj.videoHeight;
1934
+ var videoWidth = obj.videoWidth;
1935
1935
  callback({
1936
- cameraStream,
1937
- videoElement,
1938
- videoHeight,
1939
- videoWidth
1936
+ cameraStream: cameraStream,
1937
+ videoElement: videoElement,
1938
+ videoHeight: videoHeight,
1939
+ videoWidth: videoWidth
1940
1940
  });
1941
1941
  },
1942
1942
  lastCameraStream: options.lastCameraStream,
1943
- webcamVideoElement,
1943
+ webcamVideoElement: webcamVideoElement,
1944
1944
  crossOrigin: options.crossOrigin,
1945
- options
1945
+ options: options
1946
1946
  });
1947
1947
  },
1948
1948
  stopVideoStreaming: function stopVideoStreaming(obj) {
1949
1949
  obj = utils.isObject(obj) ? obj : {};
1950
- const _obj = obj;
1951
- const keepCameraOn = _obj.keepCameraOn;
1952
- const videoElement = _obj.videoElement;
1953
- const webcamVideoElement = _obj.webcamVideoElement;
1954
- const cameraStream = obj.cameraStream || {};
1955
- const cameraStreamTracks = cameraStream.getTracks ? cameraStream.getTracks() || [] : [];
1956
- const hasCameraStreamTracks = Boolean(cameraStreamTracks.length);
1957
- const firstCameraStreamTrack = cameraStreamTracks[0];
1950
+ var _obj = obj;
1951
+ var keepCameraOn = _obj.keepCameraOn;
1952
+ var videoElement = _obj.videoElement;
1953
+ var webcamVideoElement = _obj.webcamVideoElement;
1954
+ var cameraStream = obj.cameraStream || {};
1955
+ var cameraStreamTracks = cameraStream.getTracks ? cameraStream.getTracks() || [] : [];
1956
+ var hasCameraStreamTracks = Boolean(cameraStreamTracks.length);
1957
+ var firstCameraStreamTrack = cameraStreamTracks[0];
1958
1958
 
1959
1959
  if (!keepCameraOn && hasCameraStreamTracks) {
1960
1960
  if (utils.isFunction(firstCameraStreamTrack.stop)) {
@@ -1982,23 +1982,23 @@ function stopVideoStreaming(options) {
1982
1982
  }
1983
1983
 
1984
1984
  function createAndGetGIF(obj, callback) {
1985
- const options = obj.options || {};
1986
- const images = options.images;
1987
- const video = options.video;
1988
- const gifWidth = Number(options.gifWidth);
1989
- const gifHeight = Number(options.gifHeight);
1990
- const numFrames = Number(options.numFrames);
1991
- const cameraStream = obj.cameraStream;
1992
- const videoElement = obj.videoElement;
1993
- const videoWidth = obj.videoWidth;
1994
- const videoHeight = obj.videoHeight;
1995
- const cropDimensions = screenShot.getCropDimensions({
1996
- videoWidth,
1997
- videoHeight,
1998
- gifHeight,
1999
- gifWidth
1985
+ var options = obj.options || {};
1986
+ var images = options.images;
1987
+ var video = options.video;
1988
+ var gifWidth = Number(options.gifWidth);
1989
+ var gifHeight = Number(options.gifHeight);
1990
+ var numFrames = Number(options.numFrames);
1991
+ var cameraStream = obj.cameraStream;
1992
+ var videoElement = obj.videoElement;
1993
+ var videoWidth = obj.videoWidth;
1994
+ var videoHeight = obj.videoHeight;
1995
+ var cropDimensions = screenShot.getCropDimensions({
1996
+ videoWidth: videoWidth,
1997
+ videoHeight: videoHeight,
1998
+ gifHeight: gifHeight,
1999
+ gifWidth: gifWidth
2000
2000
  });
2001
- const completeCallback = callback;
2001
+ var completeCallback = callback;
2002
2002
  options.crop = cropDimensions;
2003
2003
  options.videoElement = videoElement;
2004
2004
  options.videoWidth = videoWidth;
@@ -2031,20 +2031,20 @@ function createAndGetGIF(obj, callback) {
2031
2031
  }
2032
2032
 
2033
2033
  function existingVideo() {
2034
- const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2035
- const callback = obj.callback;
2036
- let existingVideo = obj.existingVideo;
2037
- const options = obj.options;
2038
- const skipObj = {
2034
+ var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2035
+ var callback = obj.callback;
2036
+ var existingVideo = obj.existingVideo;
2037
+ var options = obj.options;
2038
+ var skipObj = {
2039
2039
  getUserMedia: true,
2040
2040
  'window.URL': true
2041
2041
  };
2042
- const errorObj = error.validate(skipObj);
2043
- const loadedImages = 0;
2044
- let videoType = void 0;
2045
- let videoSrc = void 0;
2046
- const tempImage = void 0;
2047
- const ag = void 0;
2042
+ var errorObj = error.validate(skipObj);
2043
+ var loadedImages = 0;
2044
+ var videoType = void 0;
2045
+ var videoSrc = void 0;
2046
+ var tempImage = void 0;
2047
+ var ag = void 0;
2048
2048
 
2049
2049
  if (errorObj.error) {
2050
2050
  return callback(errorObj);
@@ -2077,18 +2077,18 @@ function existingVideo() {
2077
2077
  obj.options = options || {};
2078
2078
  createAndGetGIF(obj, callback);
2079
2079
  },
2080
- existingVideo,
2080
+ existingVideo: existingVideo,
2081
2081
  crossOrigin: options.crossOrigin,
2082
- options
2082
+ options: options
2083
2083
  });
2084
2084
  }
2085
2085
 
2086
2086
  function existingWebcam() {
2087
- const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2088
- const callback = obj.callback;
2089
- const lastCameraStream = obj.lastCameraStream;
2090
- const options = obj.options;
2091
- const webcamVideoElement = obj.webcamVideoElement;
2087
+ var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2088
+ var callback = obj.callback;
2089
+ var lastCameraStream = obj.lastCameraStream;
2090
+ var options = obj.options;
2091
+ var webcamVideoElement = obj.webcamVideoElement;
2092
2092
 
2093
2093
  if (!isWebCamGIFSupported()) {
2094
2094
  return callback(error.validate());
@@ -2102,13 +2102,13 @@ function existingWebcam() {
2102
2102
  }
2103
2103
 
2104
2104
  videoStream.startVideoStreaming(function () {
2105
- const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2105
+ var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2106
2106
  obj.options = options || {};
2107
2107
  createAndGetGIF(obj, callback);
2108
2108
  }, {
2109
- lastCameraStream,
2110
- callback,
2111
- webcamVideoElement,
2109
+ lastCameraStream: lastCameraStream,
2110
+ callback: callback,
2111
+ webcamVideoElement: webcamVideoElement,
2112
2112
  crossOrigin: options.crossOrigin
2113
2113
  });
2114
2114
  }
@@ -2121,12 +2121,12 @@ function createGIF(userOptions, callback) {
2121
2121
  return;
2122
2122
  }
2123
2123
 
2124
- let options = utils.normalizeOptions(defaultOptions, userOptions) || {};
2125
- const lastCameraStream = userOptions.cameraStream;
2126
- const images = options.images;
2127
- const imagesLength = images ? images.length : 0;
2128
- const video = options.video;
2129
- const webcamVideoElement = options.webcamVideoElement;
2124
+ var options = utils.normalizeOptions(defaultOptions, userOptions) || {};
2125
+ var lastCameraStream = userOptions.cameraStream;
2126
+ var images = options.images;
2127
+ var imagesLength = images ? images.length : 0;
2128
+ var video = options.video;
2129
+ var webcamVideoElement = options.webcamVideoElement;
2130
2130
  options = utils.normalizeOptions(options, {
2131
2131
  gifWidth: Math.floor(options.gifWidth),
2132
2132
  gifHeight: Math.floor(options.gifHeight)
@@ -2134,23 +2134,23 @@ function createGIF(userOptions, callback) {
2134
2134
 
2135
2135
  if (imagesLength) {
2136
2136
  existingImages({
2137
- images,
2138
- imagesLength,
2139
- callback,
2140
- options
2137
+ images: images,
2138
+ imagesLength: imagesLength,
2139
+ callback: callback,
2140
+ options: options
2141
2141
  });
2142
2142
  } else if (video) {
2143
2143
  existingVideo({
2144
2144
  existingVideo: video,
2145
- callback,
2146
- options
2145
+ callback: callback,
2146
+ options: options
2147
2147
  });
2148
2148
  } else {
2149
2149
  existingWebcam({
2150
- lastCameraStream,
2151
- callback,
2152
- webcamVideoElement,
2153
- options
2150
+ lastCameraStream: lastCameraStream,
2151
+ callback: callback,
2152
+ webcamVideoElement: webcamVideoElement,
2153
+ options: options
2154
2154
  });
2155
2155
  }
2156
2156
  }
@@ -2163,8 +2163,8 @@ function takeSnapShot(userOptions, callback) {
2163
2163
  return;
2164
2164
  }
2165
2165
 
2166
- const mergedOptions = utils.normalizeOptions(defaultOptions, userOptions);
2167
- const options = utils.normalizeOptions(mergedOptions, {
2166
+ var mergedOptions = utils.normalizeOptions(defaultOptions, userOptions);
2167
+ var options = utils.normalizeOptions(mergedOptions, {
2168
2168
  interval: 0.1,
2169
2169
  numFrames: 1,
2170
2170
  gifWidth: Math.floor(mergedOptions.gifWidth),
@@ -2173,16 +2173,16 @@ function takeSnapShot(userOptions, callback) {
2173
2173
  createGIF(options, callback);
2174
2174
  }
2175
2175
 
2176
- const API = {
2176
+ var API = {
2177
2177
  utils: utils$2,
2178
2178
  error: error$2,
2179
2179
  defaultOptions: defaultOptions$2,
2180
- createGIF,
2181
- takeSnapShot,
2182
- stopVideoStreaming,
2183
- isSupported,
2184
- isWebCamGIFSupported,
2185
- isExistingVideoGIFSupported,
2180
+ createGIF: createGIF,
2181
+ takeSnapShot: takeSnapShot,
2182
+ stopVideoStreaming: stopVideoStreaming,
2183
+ isSupported: isSupported,
2184
+ isWebCamGIFSupported: isWebCamGIFSupported,
2185
+ isExistingVideoGIFSupported: isExistingVideoGIFSupported,
2186
2186
  isExistingImagesGIFSupported: isSupported$1,
2187
2187
  VERSION: '0.4.5'
2188
2188
  };