@loaders.gl/video 4.4.2 → 5.0.0-alpha.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.
- package/dist/bundled.d.ts +3 -0
- package/dist/bundled.d.ts.map +1 -0
- package/dist/bundled.js +5 -0
- package/dist/bundled.js.map +1 -0
- package/dist/dist.dev.js +120 -51
- package/dist/dist.min.js +1 -1
- package/dist/gif-builder.d.ts +1 -1
- package/dist/gif-builder.js +2 -2
- package/dist/gif-builder.js.map +1 -1
- package/dist/index.cjs +118 -51
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/gifshot/gifshot.d.ts.map +1 -1
- package/dist/lib/gifshot/gifshot.js +40 -28
- package/dist/lib/gifshot/gifshot.js.map +1 -1
- package/dist/unbundled.d.ts +3 -0
- package/dist/unbundled.d.ts.map +1 -0
- package/dist/unbundled.js +5 -0
- package/dist/unbundled.js.map +1 -0
- package/dist/video-format.d.ts +13 -0
- package/dist/video-format.d.ts.map +1 -0
- package/dist/video-format.js +16 -0
- package/dist/video-format.js.map +1 -0
- package/dist/video-loader-with-parser.d.ts +27 -0
- package/dist/video-loader-with-parser.d.ts.map +1 -0
- package/dist/video-loader-with-parser.js +14 -0
- package/dist/video-loader-with-parser.js.map +1 -0
- package/dist/video-loader.d.ts +30 -9
- package/dist/video-loader.d.ts.map +1 -1
- package/dist/video-loader.js +10 -11
- package/dist/video-loader.js.map +1 -1
- package/package.json +13 -5
- package/src/bundled.ts +6 -0
- package/src/gif-builder.ts +2 -2
- package/src/index.ts +2 -0
- package/src/lib/gifshot/gifshot.ts +39 -28
- package/src/unbundled.ts +6 -0
- package/src/video-format.ts +18 -0
- package/src/video-loader-with-parser.ts +21 -0
- package/src/video-loader.ts +12 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundled.d.ts","sourceRoot":"","sources":["../src/bundled.ts"],"names":[],"mappings":"AAIA,YAAY,EAAC,kBAAkB,EAAC,sCAAmC;AACnE,OAAO,EAAC,qBAAqB,IAAI,WAAW,EAAC,sCAAmC"}
|
package/dist/bundled.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundled.js","sourceRoot":"","sources":["../src/bundled.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,qBAAqB,IAAI,WAAW,EAAC,sCAAmC"}
|
package/dist/dist.dev.js
CHANGED
|
@@ -12,6 +12,9 @@ var __exports__ = (() => {
|
|
|
12
12
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
13
|
var __getProtoOf = Object.getPrototypeOf;
|
|
14
14
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
15
|
+
var __esm = (fn, res) => function __init() {
|
|
16
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
17
|
+
};
|
|
15
18
|
var __commonJS = (cb, mod) => function __require() {
|
|
16
19
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
20
|
};
|
|
@@ -45,13 +48,24 @@ var __exports__ = (() => {
|
|
|
45
48
|
}
|
|
46
49
|
});
|
|
47
50
|
|
|
48
|
-
//
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
// src/video-format.ts
|
|
52
|
+
var VideoFormat;
|
|
53
|
+
var init_video_format = __esm({
|
|
54
|
+
"src/video-format.ts"() {
|
|
55
|
+
"use strict";
|
|
56
|
+
VideoFormat = {
|
|
57
|
+
name: "Video",
|
|
58
|
+
id: "video",
|
|
59
|
+
module: "video",
|
|
60
|
+
encoding: "video",
|
|
61
|
+
format: "video",
|
|
62
|
+
extensions: ["mp4"],
|
|
63
|
+
mimeTypes: ["video/mp4"],
|
|
64
|
+
category: "video",
|
|
65
|
+
binary: true
|
|
66
|
+
};
|
|
67
|
+
}
|
|
53
68
|
});
|
|
54
|
-
__reExport(bundle_exports, __toESM(require_core(), 1));
|
|
55
69
|
|
|
56
70
|
// src/lib/parsers/parse-video.ts
|
|
57
71
|
async function parseVideo(arrayBuffer) {
|
|
@@ -60,24 +74,68 @@ var __exports__ = (() => {
|
|
|
60
74
|
video.src = URL.createObjectURL(blob2);
|
|
61
75
|
return video;
|
|
62
76
|
}
|
|
77
|
+
var init_parse_video = __esm({
|
|
78
|
+
"src/lib/parsers/parse-video.ts"() {
|
|
79
|
+
"use strict";
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// src/video-loader-with-parser.ts
|
|
84
|
+
var video_loader_with_parser_exports = {};
|
|
85
|
+
__export(video_loader_with_parser_exports, {
|
|
86
|
+
VideoLoaderWithParser: () => VideoLoaderWithParser
|
|
87
|
+
});
|
|
88
|
+
var _VideoLoaderPreload, VideoLoaderMetadataWithoutPreload, VideoLoaderWithParser;
|
|
89
|
+
var init_video_loader_with_parser = __esm({
|
|
90
|
+
"src/video-loader-with-parser.ts"() {
|
|
91
|
+
"use strict";
|
|
92
|
+
init_parse_video();
|
|
93
|
+
init_video_loader();
|
|
94
|
+
({ preload: _VideoLoaderPreload, ...VideoLoaderMetadataWithoutPreload } = VideoLoader);
|
|
95
|
+
VideoLoaderWithParser = {
|
|
96
|
+
...VideoLoaderMetadataWithoutPreload,
|
|
97
|
+
parse: parseVideo
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
});
|
|
63
101
|
|
|
64
102
|
// src/video-loader.ts
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
103
|
+
async function preload() {
|
|
104
|
+
const { VideoLoaderWithParser: VideoLoaderWithParser2 } = await Promise.resolve().then(() => (init_video_loader_with_parser(), video_loader_with_parser_exports));
|
|
105
|
+
return VideoLoaderWithParser2;
|
|
106
|
+
}
|
|
107
|
+
var VERSION, VideoLoader;
|
|
108
|
+
var init_video_loader = __esm({
|
|
109
|
+
"src/video-loader.ts"() {
|
|
110
|
+
"use strict";
|
|
111
|
+
init_video_format();
|
|
112
|
+
VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
113
|
+
VideoLoader = {
|
|
114
|
+
dataType: null,
|
|
115
|
+
batchType: null,
|
|
116
|
+
...VideoFormat,
|
|
117
|
+
version: VERSION,
|
|
118
|
+
// tests: arrayBuffer => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer))),
|
|
119
|
+
options: {
|
|
120
|
+
video: {}
|
|
121
|
+
},
|
|
122
|
+
preload
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// bundle.ts
|
|
128
|
+
var bundle_exports = {};
|
|
129
|
+
__export(bundle_exports, {
|
|
130
|
+
GIFBuilder: () => GIFBuilder,
|
|
131
|
+
VideoFormat: () => VideoFormat,
|
|
132
|
+
VideoLoader: () => VideoLoader
|
|
133
|
+
});
|
|
134
|
+
__reExport(bundle_exports, __toESM(require_core(), 1));
|
|
135
|
+
|
|
136
|
+
// src/index.ts
|
|
137
|
+
init_video_format();
|
|
138
|
+
init_video_loader();
|
|
81
139
|
|
|
82
140
|
// src/lib/utils/assert.ts
|
|
83
141
|
function assert(condition, message) {
|
|
@@ -109,7 +167,11 @@ var __exports__ = (() => {
|
|
|
109
167
|
const loop = function loop2() {
|
|
110
168
|
const current = new Date().getTime();
|
|
111
169
|
const delta = current - start;
|
|
112
|
-
delta >= delay
|
|
170
|
+
if (delta >= delay) {
|
|
171
|
+
callback.call();
|
|
172
|
+
} else {
|
|
173
|
+
handle.value = requestAnimFrame(loop2);
|
|
174
|
+
}
|
|
113
175
|
};
|
|
114
176
|
handle.value = requestAnimFrame(loop);
|
|
115
177
|
return handle;
|
|
@@ -136,9 +198,9 @@ var __exports__ = (() => {
|
|
|
136
198
|
enc2 = (chr1 & 3) << 4 | chr2 >> 4;
|
|
137
199
|
enc3 = (chr2 & 15) << 2 | chr3 >> 6;
|
|
138
200
|
enc4 = chr3 & 63;
|
|
139
|
-
if (isNaN(chr2)) {
|
|
201
|
+
if (Number.isNaN(chr2)) {
|
|
140
202
|
enc3 = enc4 = 64;
|
|
141
|
-
} else if (isNaN(chr3)) {
|
|
203
|
+
} else if (Number.isNaN(chr3)) {
|
|
142
204
|
enc4 = 64;
|
|
143
205
|
}
|
|
144
206
|
output = output + key.charAt(enc1) + key.charAt(enc2) + key.charAt(enc3) + key.charAt(enc4);
|
|
@@ -162,6 +224,12 @@ var __exports__ = (() => {
|
|
|
162
224
|
isElement: function isElement(elem) {
|
|
163
225
|
return elem && elem.nodeType === 1;
|
|
164
226
|
},
|
|
227
|
+
isImageBitmap: function isImageBitmap(image) {
|
|
228
|
+
return typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap;
|
|
229
|
+
},
|
|
230
|
+
isDrawable: function isDrawable(image) {
|
|
231
|
+
return utils.isElement(image) || utils.isImageBitmap(image);
|
|
232
|
+
},
|
|
165
233
|
isString: function isString(value) {
|
|
166
234
|
return typeof value === "string" || Object.prototype.toString.call(value) === "[object String]";
|
|
167
235
|
},
|
|
@@ -199,7 +267,7 @@ var __exports__ = (() => {
|
|
|
199
267
|
supportObj.ogg = testEl.canPlayType('video/ogg; codecs="theora"') !== "";
|
|
200
268
|
supportObj.webm = testEl.canPlayType('video/webm; codecs="vp8, vorbis"') !== -1;
|
|
201
269
|
}
|
|
202
|
-
} catch (
|
|
270
|
+
} catch (_e) {
|
|
203
271
|
}
|
|
204
272
|
return supportObj;
|
|
205
273
|
}()
|
|
@@ -465,7 +533,7 @@ var __exports__ = (() => {
|
|
|
465
533
|
const intbiasshift = 16;
|
|
466
534
|
const intbias = 1 << intbiasshift;
|
|
467
535
|
const gammashift = 10;
|
|
468
|
-
const
|
|
536
|
+
const _gamma = 1 << gammashift;
|
|
469
537
|
const betashift = 10;
|
|
470
538
|
const beta = intbias >> betashift;
|
|
471
539
|
const betagamma = intbias << gammashift - betashift;
|
|
@@ -542,7 +610,7 @@ var __exports__ = (() => {
|
|
|
542
610
|
}
|
|
543
611
|
}
|
|
544
612
|
q = network[smallpos];
|
|
545
|
-
if (i
|
|
613
|
+
if (i !== smallpos) {
|
|
546
614
|
j = q[0];
|
|
547
615
|
q[0] = p[0];
|
|
548
616
|
p[0] = j;
|
|
@@ -556,7 +624,7 @@ var __exports__ = (() => {
|
|
|
556
624
|
q[3] = p[3];
|
|
557
625
|
p[3] = j;
|
|
558
626
|
}
|
|
559
|
-
if (smallval
|
|
627
|
+
if (smallval !== previouscol) {
|
|
560
628
|
netindex[previouscol] = startpos + i >> 1;
|
|
561
629
|
for (j = previouscol + 1; j < smallval; j++) {
|
|
562
630
|
netindex[j] = i;
|
|
@@ -725,7 +793,7 @@ var __exports__ = (() => {
|
|
|
725
793
|
}
|
|
726
794
|
function unbiasnet() {
|
|
727
795
|
let i;
|
|
728
|
-
let
|
|
796
|
+
let _j;
|
|
729
797
|
for (i = 0; i < netsize; i++) {
|
|
730
798
|
network[i][0] >>= netbiasshift;
|
|
731
799
|
network[i][1] >>= netbiasshift;
|
|
@@ -760,7 +828,7 @@ var __exports__ = (() => {
|
|
|
760
828
|
p[0] -= a * (p[0] - b) / alpharadbias | 0;
|
|
761
829
|
p[1] -= a * (p[1] - g) / alpharadbias | 0;
|
|
762
830
|
p[2] -= a * (p[2] - r) / alpharadbias | 0;
|
|
763
|
-
} catch (
|
|
831
|
+
} catch (_e) {
|
|
764
832
|
}
|
|
765
833
|
}
|
|
766
834
|
if (k > lo) {
|
|
@@ -769,7 +837,7 @@ var __exports__ = (() => {
|
|
|
769
837
|
p[0] -= a * (p[0] - b) / alpharadbias | 0;
|
|
770
838
|
p[1] -= a * (p[1] - g) / alpharadbias | 0;
|
|
771
839
|
p[2] -= a * (p[2] - r) / alpharadbias | 0;
|
|
772
|
-
} catch (
|
|
840
|
+
} catch (_e) {
|
|
773
841
|
}
|
|
774
842
|
}
|
|
775
843
|
}
|
|
@@ -836,7 +904,7 @@ var __exports__ = (() => {
|
|
|
836
904
|
return exports;
|
|
837
905
|
}
|
|
838
906
|
function workerCode() {
|
|
839
|
-
const
|
|
907
|
+
const _self = this;
|
|
840
908
|
try {
|
|
841
909
|
globalThis.onmessage = function(ev) {
|
|
842
910
|
const data = ev.data || {};
|
|
@@ -846,7 +914,7 @@ var __exports__ = (() => {
|
|
|
846
914
|
postMessage(response);
|
|
847
915
|
}
|
|
848
916
|
};
|
|
849
|
-
} catch (
|
|
917
|
+
} catch (_e) {
|
|
850
918
|
}
|
|
851
919
|
var workerMethods = {
|
|
852
920
|
dataToRGB: function dataToRGB(data, width, height) {
|
|
@@ -896,7 +964,7 @@ var __exports__ = (() => {
|
|
|
896
964
|
frame = frame || {};
|
|
897
965
|
const _frame = frame;
|
|
898
966
|
const height = _frame.height;
|
|
899
|
-
const
|
|
967
|
+
const _palette = _frame.palette;
|
|
900
968
|
const sampleInterval = _frame.sampleInterval;
|
|
901
969
|
const width = _frame.width;
|
|
902
970
|
const imageData = frame.data;
|
|
@@ -980,8 +1048,10 @@ var __exports__ = (() => {
|
|
|
980
1048
|
throw "Must supply either a local or global palette.";
|
|
981
1049
|
let num_colors = check_palette_and_num_colors(palette);
|
|
982
1050
|
let min_code_size = 0;
|
|
983
|
-
|
|
1051
|
+
num_colors >>= 1;
|
|
1052
|
+
while (num_colors) {
|
|
984
1053
|
++min_code_size;
|
|
1054
|
+
num_colors >>= 1;
|
|
985
1055
|
}
|
|
986
1056
|
num_colors = 1 << min_code_size;
|
|
987
1057
|
const delay = opts.delay === void 0 ? 0 : opts.delay;
|
|
@@ -1204,7 +1274,6 @@ var __exports__ = (() => {
|
|
|
1204
1274
|
},
|
|
1205
1275
|
processFrame: function processFrame(position) {
|
|
1206
1276
|
const AnimatedGifContext = this;
|
|
1207
|
-
const options = this.options;
|
|
1208
1277
|
const _options = this.options;
|
|
1209
1278
|
const progressCallback = _options.progressCallback;
|
|
1210
1279
|
const sampleInterval = _options.sampleInterval;
|
|
@@ -1316,8 +1385,8 @@ var __exports__ = (() => {
|
|
|
1316
1385
|
const fontColor = _gifshotOptions.fontColor;
|
|
1317
1386
|
const fontFamily = _gifshotOptions.fontFamily;
|
|
1318
1387
|
const fontWeight = _gifshotOptions.fontWeight;
|
|
1319
|
-
const
|
|
1320
|
-
const
|
|
1388
|
+
const _gifHeight = _gifshotOptions.gifHeight;
|
|
1389
|
+
const _gifWidth = _gifshotOptions.gifWidth;
|
|
1321
1390
|
const text = _gifshotOptions.text;
|
|
1322
1391
|
const textAlign = _gifshotOptions.textAlign;
|
|
1323
1392
|
const textBaseline = _gifshotOptions.textBaseline;
|
|
@@ -1397,7 +1466,7 @@ var __exports__ = (() => {
|
|
|
1397
1466
|
}
|
|
1398
1467
|
function existingImages() {
|
|
1399
1468
|
const obj = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1400
|
-
const
|
|
1469
|
+
const _self = this;
|
|
1401
1470
|
const callback = obj.callback;
|
|
1402
1471
|
const images = obj.images;
|
|
1403
1472
|
const options = obj.options;
|
|
@@ -1417,7 +1486,7 @@ var __exports__ = (() => {
|
|
|
1417
1486
|
ag = new AnimatedGIF(options);
|
|
1418
1487
|
utils.each(images, function(index, image) {
|
|
1419
1488
|
const currentImage = image;
|
|
1420
|
-
if (utils.
|
|
1489
|
+
if (utils.isDrawable(currentImage)) {
|
|
1421
1490
|
if (options.crossOrigin) {
|
|
1422
1491
|
currentImage.crossOrigin = options.crossOrigin;
|
|
1423
1492
|
}
|
|
@@ -1499,7 +1568,7 @@ var __exports__ = (() => {
|
|
|
1499
1568
|
const fontFamily = options.fontFamily;
|
|
1500
1569
|
const fontWeight = options.fontWeight;
|
|
1501
1570
|
const keepCameraOn = options.keepCameraOn;
|
|
1502
|
-
const
|
|
1571
|
+
const _numWorkers = options.numWorkers;
|
|
1503
1572
|
const progressCallback = options.progressCallback;
|
|
1504
1573
|
const saveRenderingContexts = options.saveRenderingContexts;
|
|
1505
1574
|
const savedRenderingContexts = options.savedRenderingContexts;
|
|
@@ -1513,7 +1582,7 @@ var __exports__ = (() => {
|
|
|
1513
1582
|
const gifWidth = Number(options.gifWidth);
|
|
1514
1583
|
const gifHeight = Number(options.gifHeight);
|
|
1515
1584
|
let interval = Number(options.interval);
|
|
1516
|
-
const
|
|
1585
|
+
const _sampleInterval = Number(options.sampleInterval);
|
|
1517
1586
|
const waitBetweenFrames = hasExistingImages ? 0 : interval * 1e3;
|
|
1518
1587
|
const renderingContextsToSave = [];
|
|
1519
1588
|
let numFrames = savedRenderingContexts.length ? savedRenderingContexts.length : options.numFrames;
|
|
@@ -1706,7 +1775,7 @@ var __exports__ = (() => {
|
|
|
1706
1775
|
} else if (existingVideo2 instanceof Blob) {
|
|
1707
1776
|
try {
|
|
1708
1777
|
videoElement.src = utils.URL.createObjectURL(existingVideo2);
|
|
1709
|
-
} catch (
|
|
1778
|
+
} catch (_e) {
|
|
1710
1779
|
}
|
|
1711
1780
|
videoElement.innerHTML = `<source src="${existingVideo2}" type="${existingVideo2.type}" />`;
|
|
1712
1781
|
}
|
|
@@ -1716,7 +1785,7 @@ var __exports__ = (() => {
|
|
|
1716
1785
|
try {
|
|
1717
1786
|
videoElement.srcObject = cameraStream;
|
|
1718
1787
|
videoElement.src = utils.URL.createObjectURL(cameraStream);
|
|
1719
|
-
} catch (
|
|
1788
|
+
} catch (_e) {
|
|
1720
1789
|
videoElement.srcObject = cameraStream;
|
|
1721
1790
|
}
|
|
1722
1791
|
}
|
|
@@ -1754,7 +1823,7 @@ var __exports__ = (() => {
|
|
|
1754
1823
|
const options = obj.options;
|
|
1755
1824
|
const webcamVideoElement = obj.webcamVideoElement;
|
|
1756
1825
|
const videoElement = utils.isElement(existingVideo2) ? existingVideo2 : webcamVideoElement ? webcamVideoElement : document2.createElement("video");
|
|
1757
|
-
const
|
|
1826
|
+
const _cameraStream = void 0;
|
|
1758
1827
|
if (crossOrigin) {
|
|
1759
1828
|
videoElement.crossOrigin = options.crossOrigin;
|
|
1760
1829
|
}
|
|
@@ -1876,7 +1945,7 @@ var __exports__ = (() => {
|
|
|
1876
1945
|
const video = options.video;
|
|
1877
1946
|
const gifWidth = Number(options.gifWidth);
|
|
1878
1947
|
const gifHeight = Number(options.gifHeight);
|
|
1879
|
-
const
|
|
1948
|
+
const _numFrames = Number(options.numFrames);
|
|
1880
1949
|
const cameraStream = obj.cameraStream;
|
|
1881
1950
|
const videoElement = obj.videoElement;
|
|
1882
1951
|
const videoWidth = obj.videoWidth;
|
|
@@ -1923,11 +1992,11 @@ var __exports__ = (() => {
|
|
|
1923
1992
|
"globalThis.URL": true
|
|
1924
1993
|
};
|
|
1925
1994
|
const errorObj = error.validate(skipObj);
|
|
1926
|
-
const
|
|
1995
|
+
const _loadedImages = 0;
|
|
1927
1996
|
let videoType = void 0;
|
|
1928
1997
|
let videoSrc = void 0;
|
|
1929
|
-
const
|
|
1930
|
-
const
|
|
1998
|
+
const _tempImage = void 0;
|
|
1999
|
+
const _ag = void 0;
|
|
1931
2000
|
if (errorObj.error) {
|
|
1932
2001
|
return callback(errorObj);
|
|
1933
2002
|
}
|
|
@@ -2067,7 +2136,7 @@ var __exports__ = (() => {
|
|
|
2067
2136
|
crossOrigin: "Anonymous",
|
|
2068
2137
|
// Options are 'Anonymous', 'use-credentials', or a falsy value to not set a CORS attribute.
|
|
2069
2138
|
// CALLBACKS
|
|
2070
|
-
progressCallback: (
|
|
2139
|
+
progressCallback: (_captureProgress) => {
|
|
2071
2140
|
},
|
|
2072
2141
|
// Callback that provides the current progress of the current image
|
|
2073
2142
|
completeCallback: () => {
|
package/dist/dist.min.js
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['loaders'] = factory();
|
|
6
6
|
else root['loaders'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var Re=Object.create;var de=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var Me=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,Le=Object.prototype.hasOwnProperty;var He=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Be=(t,e)=>{for(var n in e)de(t,n,{get:e[n],enumerable:!0})},ce=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Me(e))!Le.call(t,i)&&i!==n&&de(t,i,{get:()=>e[i],enumerable:!(o=Ue(e,i))||o.enumerable});return t},fe=(t,e,n)=>(ce(t,e,"default"),n&&ce(n,e,"default")),Ge=(t,e,n)=>(n=t!=null?Re(Ve(t)):{},ce(e||!t||!t.__esModule?de(n,"default",{value:t,enumerable:!0}):n,t)),Pe=t=>ce(de({},"__esModule",{value:!0}),t);var ye=He((rt,we)=>{we.exports=globalThis.loaders});var se={};Be(se,{GIFBuilder:()=>K,VideoLoader:()=>Ce});fe(se,Ge(ye(),1));async function he(t){let e=new Blob([t]),n=document.createElement("video");return n.src=URL.createObjectURL(e),n}var _e="4.4.2",Ce={dataType:null,batchType:null,name:"Video",id:"video",module:"video",version:_e,extensions:["mp4"],mimeTypes:["video/mp4"],options:{video:{}},parse:he};function Se(t,e){if(!t)throw new Error(e)}var D=globalThis.document||{},r={URL:globalThis.URL||globalThis.webkitURL||globalThis.mozURL||globalThis.msURL,getUserMedia:function(){if(!globalThis.navigator)return globalThis.navigator;let t=globalThis.navigator.getUserMedia||globalThis.navigator.webkitGetUserMedia||globalThis.navigator.mozGetUserMedia||globalThis.navigator.msGetUserMedia;return t&&t.bind(globalThis.navigator)}(),requestAnimFrame:globalThis.requestAnimationFrame||globalThis.webkitRequestAnimationFrame||globalThis.mozRequestAnimationFrame||globalThis.oRequestAnimationFrame||globalThis.msRequestAnimationFrame,requestTimeout:function(e,n){if(e=e||r.noop,n=n||0,!r.requestAnimFrame)return setTimeout(e,n);let o=new Date().getTime(),i=new Object,s=r.requestAnimFrame,a=function l(){new Date().getTime()-o>=n?e.call():i.value=s(l)};return i.value=s(a),i},Blob:globalThis.Blob||globalThis.BlobBuilder||globalThis.WebKitBlobBuilder||globalThis.MozBlobBuilder||globalThis.MSBlobBuilder,btoa:function(){let t=globalThis.btoa||function(e){let n="",o=0,i=e.length,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a,l,c,u,x,k,m;for(;o<i;)a=e.charCodeAt(o++),l=e.charCodeAt(o++),c=e.charCodeAt(o++),u=a>>2,x=(a&3)<<4|l>>4,k=(l&15)<<2|c>>6,m=c&63,isNaN(l)?k=m=64:isNaN(c)&&(m=64),n=n+s.charAt(u)+s.charAt(x)+s.charAt(k)+s.charAt(m);return n};return t?t.bind(globalThis):r.noop}(),isObject:function(e){return e&&Object.prototype.toString.call(e)==="[object Object]"},isEmptyObject:function(e){return r.isObject(e)&&!Object.keys(e).length},isArray:function(e){return e&&Array.isArray(e)},isFunction:function(e){return e&&typeof e=="function"},isElement:function(e){return e&&e.nodeType===1},isString:function(e){return typeof e=="string"||Object.prototype.toString.call(e)==="[object String]"},isSupported:{canvas:function(){let e=D.createElement("canvas");return e&&e.getContext&&e.getContext("2d")},webworkers:function(){return globalThis.Worker},blob:function(){return r.Blob},Uint8Array:function(){return globalThis.Uint8Array},Uint32Array:function(){return globalThis.Uint32Array},videoCodecs:function(){let t=D.createElement("video"),e={mp4:!1,h264:!1,ogv:!1,ogg:!1,webm:!1};try{t&&t.canPlayType&&(e.mp4=t.canPlayType('video/mp4; codecs="mp4v.20.8"')!=="",e.h264=(t.canPlayType('video/mp4; codecs="avc1.42E01E"')||t.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"'))!=="",e.ogv=t.canPlayType('video/ogg; codecs="theora"')!=="",e.ogg=t.canPlayType('video/ogg; codecs="theora"')!=="",e.webm=t.canPlayType('video/webm; codecs="vp8, vorbis"')!==-1)}catch{}return e}()},noop:function(){},each:function(e,n){let o,i;if(r.isArray(e))for(o=-1,i=e.length;++o<i&&n(o,e[o])!==!1;);else if(r.isObject(e)){for(o in e)if(e.hasOwnProperty(o)&&n(o,e[o])===!1)break}},normalizeOptions:function(e,n){if(!r.isObject(e)||!r.isObject(n)||!Object.keys)return;let o={};return r.each(e,function(i,s){o[i]=e[i]}),r.each(n,function(i,s){let a=n[i];r.isObject(a)&&e[i]?o[i]=r.normalizeOptions(e[i],a):o[i]=a}),o},setCSSAttr:function(e,n,o){r.isElement(e)&&(r.isString(n)&&r.isString(o)?e.style[n]=o:r.isObject(n)&&r.each(n,function(i,s){e.style[i]=s}))},removeElement:function(e){r.isElement(e)&&e.parentNode&&e.parentNode.removeChild(e)},createWebWorker:function(e){if(!r.isString(e))return{};try{let n=new r.Blob([e],{type:"text/javascript"}),o=r.URL.createObjectURL(n),i=new Worker(o);return{objectUrl:o,worker:i}}catch(n){return`${n}`}},getExtension:function(e){return e.substr(e.lastIndexOf(".")+1,e.length)},getFontSize:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!D.body||e.resizeFont===!1)return e.fontSize;let n=e.text,o=e.gifWidth,i=parseInt(e.fontSize,10),s=parseInt(e.minFontSize,10),a=D.createElement("div"),l=D.createElement("span");for(a.setAttribute("width",o),a.appendChild(l),l.innerHTML=n,l.style.fontSize=`${i}px`,l.style.textIndent="-9999px",l.style.visibility="hidden",D.body.appendChild(l);l.offsetWidth>o&&i>=s;)l.style.fontSize=`${--i}px`;return D.body.removeChild(l),`${i}px`},webWorkerError:!1},je=Object.freeze({default:r}),q={validate:function(e){e=r.isObject(e)?e:{};let n={};return r.each(q.validators,function(o,i){let s=i.errorCode;if(!e[s]&&!i.condition)return n=i,n.error=!0,!1}),delete n.condition,n},isValid:function(e){return q.validate(e).error!==!0},validators:[{condition:r.isFunction(r.getUserMedia),errorCode:"getUserMedia",errorMsg:"The getUserMedia API is not supported in your browser"},{condition:r.isSupported.canvas(),errorCode:"canvas",errorMsg:"Canvas elements are not supported in your browser"},{condition:r.isSupported.webworkers(),errorCode:"webworkers",errorMsg:"The Web Workers API is not supported in your browser"},{condition:r.isFunction(r.URL),errorCode:"globalThis.URL",errorMsg:"The globalThis.URL API is not supported in your browser"},{condition:r.isSupported.blob(),errorCode:"globalThis.Blob",errorMsg:"The globalThis.Blob File API is not supported in your browser"},{condition:r.isSupported.Uint8Array(),errorCode:"globalThis.Uint8Array",errorMsg:"The globalThis.Uint8Array function constructor is not supported in your browser"},{condition:r.isSupported.Uint32Array(),errorCode:"globalThis.Uint32Array",errorMsg:"The globalThis.Uint32Array function constructor is not supported in your browser"}],messages:{videoCodecs:{errorCode:"videocodec",errorMsg:"The video codec you are trying to use is not supported in your browser"}}},De=Object.freeze({default:q}),Fe=function(){},be={sampleInterval:10,numWorkers:2,filter:"",gifWidth:200,gifHeight:200,interval:.1,numFrames:10,frameDuration:1,keepCameraOn:!1,images:[],video:null,webcamVideoElement:null,cameraStream:null,text:"",fontWeight:"normal",fontSize:"16px",minFontSize:"10px",resizeFont:!1,fontFamily:"sans-serif",fontColor:"#ffffff",textAlign:"center",textBaseline:"bottom",textXCoordinate:null,textYCoordinate:null,progressCallback:Fe,completeCallback:Fe,saveRenderingContexts:!1,savedRenderingContexts:[],crossOrigin:"Anonymous"},Ne=Object.freeze({default:be});function $e(){return q.isValid()}function We(){return q.isValid()}function qe(){let t={getUserMedia:!0};return q.isValid(t)}function Xe(t){let e=!1;if(r.isArray(t)&&t.length){if(r.each(t,function(n,o){r.isSupported.videoCodecs[o]&&(e=!0)}),!e)return!1}else if(r.isString(t)&&t.length&&!r.isSupported.videoCodecs[t])return!1;return q.isValid({getUserMedia:!0})}function Ee(){let U,G,j,X,S,P=[],Q=[],Z=[],ee=[];function me(g,p,W){let h,b;for(G=g,j=p,X=W,S=new Array(256),h=0;h<256;h++)S[h]=new Array(4),b=S[h],b[0]=b[1]=b[2]=(h<<4+8)/256|0,Z[h]=65536/256|0,Q[h]=0}function ue(){let g=[],p=new Array(256);for(let h=0;h<256;h++)p[S[h][3]]=h;let W=0;for(let h=0;h<256;h++){let b=p[h];g[W++]=S[b][0],g[W++]=S[b][1],g[W++]=S[b][2]}return g}function te(){let g,p,W,h,b,d,f,F;for(f=0,F=0,g=0;g<256;g++){for(b=S[g],W=g,h=b[1],p=g+1;p<256;p++)d=S[p],d[1]<h&&(W=p,h=d[1]);if(d=S[W],g!=W&&(p=d[0],d[0]=b[0],b[0]=p,p=d[1],d[1]=b[1],b[1]=p,p=d[2],d[2]=b[2],b[2]=p,p=d[3],d[3]=b[3],b[3]=p),h!=f){for(P[f]=F+g>>1,p=f+1;p<h;p++)P[p]=g;f=h,F=g}}for(P[f]=F+255>>1,p=f+1;p<256;p++)P[p]=255}function ie(){let g,p,W,h,b,d,f,F,T,O,$,A,_,xe;for(j<1509&&(X=1),U=30+(X-1)/3,A=G,_=0,xe=j,$=j/(3*X),O=$/100|0,F=1024,d=2048,f=d>>6,f<=1&&(f=0),g=0;g<f;g++)ee[g]=F*((f*f-g*g)*256/(f*f));for(j<1509?T=3:j%499!==0?T=3*499:j%491!==0?T=3*491:j%487!==0?T=3*487:T=3*503,g=0;g<$;)if(W=(A[_+0]&255)<<4,h=(A[_+1]&255)<<4,b=(A[_+2]&255)<<4,p=le(W,h,b),ae(F,p,W,h,b),f!==0&&re(f,p,W,h,b),_+=T,_>=xe&&(_-=j),g++,O===0&&(O=1),g%O===0)for(F-=F/U,d-=d/30,f=d>>6,f<=1&&(f=0),p=0;p<f;p++)ee[p]=F*((f*f-p*p)*256/(f*f))}function ne(g,p,W){let h,b,d,f,F,T,O;for(F=1e3,O=-1,h=P[p],b=h-1;h<256||b>=0;)h<256&&(T=S[h],d=T[1]-p,d>=F?h=256:(h++,d<0&&(d=-d),f=T[0]-g,f<0&&(f=-f),d+=f,d<F&&(f=T[2]-W,f<0&&(f=-f),d+=f,d<F&&(F=d,O=T[3])))),b>=0&&(T=S[b],d=p-T[1],d>=F?b=-1:(b--,d<0&&(d=-d),f=T[0]-g,f<0&&(f=-f),d+=f,d<F&&(f=T[2]-W,f<0&&(f=-f),d+=f,d<F&&(F=d,O=T[3]))));return O}function oe(){return ie(),ge(),te(),ue()}function ge(){let g,p;for(g=0;g<256;g++)S[g][0]>>=4,S[g][1]>>=4,S[g][2]>>=4,S[g][3]=g}function re(g,p,W,h,b){let d,f,F,T,O,$,A;for(F=p-g,F<-1&&(F=-1),T=p+g,T>256&&(T=256),d=p+1,f=p-1,$=1;d<T||f>F;){if(O=ee[$++],d<T){A=S[d++];try{A[0]-=O*(A[0]-W)/262144|0,A[1]-=O*(A[1]-h)/262144|0,A[2]-=O*(A[2]-b)/262144|0}catch{}}if(f>F){A=S[f--];try{A[0]-=O*(A[0]-W)/262144|0,A[1]-=O*(A[1]-h)/262144|0,A[2]-=O*(A[2]-b)/262144|0}catch{}}}}function ae(g,p,W,h,b){let d=S[p],f=g/1024;d[0]-=f*(d[0]-W)|0,d[1]-=f*(d[1]-h)|0,d[2]-=f*(d[2]-b)|0}function le(g,p,W){let h,b,d,f,F,T,O,$,A,_;for($=~(1<<31),A=$,T=-1,O=T,h=0;h<256;h++)_=S[h],b=_[0]-g,b<0&&(b=-b),d=_[1]-p,d<0&&(d=-d),b+=d,d=_[2]-W,d<0&&(d=-d),b+=d,b<$&&($=b,T=h),f=b-(Q[h]>>16-4),f<A&&(A=f,O=h),F=Z[h]>>10,Z[h]-=F,Q[h]+=F<<10;return Z[T]+=64,Q[T]-=65536,O}me.apply(this,arguments);let J={};return J.map=ne,J.process=oe,J}function ke(){let t=this;try{globalThis.onmessage=function(n){let o=n.data||{},i;o.gifshot&&(i=e.run(o),postMessage(i))}}catch{}var e={dataToRGB:function(o,i,s){let a=i*s*4,l=0,c=[];for(;l<a;)c.push(o[l++]),c.push(o[l++]),c.push(o[l++]),l++;return c},componentizedPaletteToArray:function(o){o=o||[];let i=[];for(let s=0;s<o.length;s+=3){let a=o[s],l=o[s+1],c=o[s+2];i.push(a<<16|l<<8|c)}return i},processFrameWithQuantizer:function(o,i,s,a){let l=this.dataToRGB(o,i,s),c=new Ee(l,l.length,a),u=c.process(),x=new Uint32Array(this.componentizedPaletteToArray(u)),k=i*s,m=new Uint8Array(k),v=0;for(let w=0;w<k;w++){let E=l[v++],y=l[v++],C=l[v++];m[w]=c.map(E,y,C)}return{pixels:m,palette:x}},run:function(o){o=o||{};let i=o,s=i.height,a=i.palette,l=i.sampleInterval,c=i.width,u=o.data;return this.processFrameWithQuantizer(u,c,s,l)}};return e}function Ye(t,e,n,o){let i=0;o=o===void 0?{}:o;let s=o.loop===void 0?null:o.loop,a=o.palette===void 0?null:o.palette;if(e<=0||n<=0||e>65535||n>65535)throw"Width/Height invalid.";function l(m){let v=m.length;if(v<2||v>256||v&v-1)throw"Invalid code/color length, must be power of 2 and 2 .. 256.";return v}t[i++]=71,t[i++]=73,t[i++]=70,t[i++]=56,t[i++]=57,t[i++]=97;let c=0,u=0;if(t[i++]=e&255,t[i++]=e>>8&255,t[i++]=n&255,t[i++]=n>>8&255,t[i++]=(a!==null?128:0)|c,t[i++]=u,t[i++]=0,s!==null){if(s<0||s>65535)throw"Loop count invalid.";t[i++]=33,t[i++]=255,t[i++]=11,t[i++]=78,t[i++]=69,t[i++]=84,t[i++]=83,t[i++]=67,t[i++]=65,t[i++]=80,t[i++]=69,t[i++]=50,t[i++]=46,t[i++]=48,t[i++]=3,t[i++]=1,t[i++]=s&255,t[i++]=s>>8&255,t[i++]=0}let x=!1;this.addFrame=function(m,v,w,E,y,C){if(x===!0&&(--i,x=!1),C=C===void 0?{}:C,m<0||v<0||m>65535||v>65535)throw"x/y invalid.";if(w<=0||E<=0||w>65535||E>65535)throw"Width/Height invalid.";if(y.length<w*E)throw"Not enough pixels for the frame size.";let z=!0,I=C.palette;if(I==null&&(z=!1,I=a),I==null)throw"Must supply either a local or global palette.";let M=l(I),V=0;for(;M>>=1;)++V;M=1<<V;let R=C.delay===void 0?0:C.delay,U=C.disposal===void 0?0:C.disposal;if(U<0||U>3)throw"Disposal out of range.";let Y=!1,L=0;if(C.transparent!==void 0&&C.transparent!==null&&(Y=!0,L=C.transparent,L<0||L>=M))throw"Transparent color index.";if((U!==0||Y||R!==0)&&(t[i++]=33,t[i++]=249,t[i++]=4,t[i++]=U<<2|(Y===!0?1:0),t[i++]=R&255,t[i++]=R>>8&255,t[i++]=L,t[i++]=0),t[i++]=44,t[i++]=m&255,t[i++]=m>>8&255,t[i++]=v&255,t[i++]=v>>8&255,t[i++]=w&255,t[i++]=w>>8&255,t[i++]=E&255,t[i++]=E>>8&255,t[i++]=z===!0?128|V-1:0,z===!0)for(let H=0,N=I.length;H<N;++H){let G=I[H];t[i++]=G>>16&255,t[i++]=G>>8&255,t[i++]=G&255}i=k(t,i,V<2?2:V,y)},this.end=function(){return x===!1&&(t[i++]=59,x=!0),i};function k(m,v,w,E){m[v++]=w;let y=v++,C=1<<w,z=C-1,I=C+1,M=I+1,V=w+1,R=0,U=0;function Y(G){for(;R>=G;)m[v++]=U&255,U>>=8,R-=8,v===y+256&&(m[y]=255,y=v++)}function L(G){U|=G<<R,R+=V,Y(8)}let H=E[0]&z,N={};L(C);for(let G=1,j=E.length;G<j;++G){let X=E[G]&z,S=H<<8|X,P=N[S];if(P===void 0){for(U|=H<<R,R+=V;R>=8;)m[v++]=U&255,U>>=8,R-=8,v===y+256&&(m[y]=255,y=v++);M===4096?(L(C),M=I+1,V=w+1,N={}):(M>=1<<V&&++V,N[S]=M++),H=X}else H=P}return L(H),L(I),Y(1),y+1===v?m[y]=0:(m[y]=v-y-1,m[v++]=0),v}}var Te=function(){},ve=function(e){this.canvas=null,this.ctx=null,this.repeat=0,this.frames=[],this.numRenderedFrames=0,this.onRenderCompleteCallback=Te,this.onRenderProgressCallback=Te,this.workers=[],this.availableWorkers=[],this.generatingGIF=!1,this.options=e,this.initializeWebWorkers(e)};ve.prototype={workerMethods:ke(),initializeWebWorkers:function(e){let n=this,o=`${Ee.toString()}(${ke.toString()}());`,i,s,a,l,c=-1,u="";for(l=e.numWorkers;++c<l;)i=r.createWebWorker(o),r.isObject(i)?(s=i.objectUrl,a=i.worker,n.workers.push({worker:a,objectUrl:s}),n.availableWorkers.push(a)):(u=i,r.webWorkerError=Boolean(i));this.workerError=u,this.canvas=D.createElement("canvas"),this.canvas.width=e.gifWidth,this.canvas.height=e.gifHeight,this.ctx=this.canvas.getContext("2d"),this.frames=[]},getWorker:function(){return this.availableWorkers.pop()},freeWorker:function(e){this.availableWorkers.push(e)},byteMap:function(){let t=[];for(let e=0;e<256;e++)t[e]=String.fromCharCode(e);return t}(),bufferToString:function(e){let n=e.length,o="",i=-1;for(;++i<n;)o+=this.byteMap[e[i]];return o},onFrameFinished:function(e){let n=this,o=n.frames,i=n.options,s=Boolean((i.images||[]).length),a=o.every(function(l){return!l.beingProcessed&&l.done});n.numRenderedFrames++,s&&e(n.numRenderedFrames/o.length),n.onRenderProgressCallback(n.numRenderedFrames*.75/o.length),a?n.generatingGIF||n.generateGIF(o,n.onRenderCompleteCallback):r.requestTimeout(function(){n.processNextFrame()},1)},processFrame:function(e){let n=this,o=this.options,i=this.options,s=i.progressCallback,a=i.sampleInterval,l=this.frames,c,u,x=function(){let v=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).data;delete c.data,c.pixels=Array.prototype.slice.call(v.pixels),c.palette=Array.prototype.slice.call(v.palette),c.done=!0,c.beingProcessed=!1,n.freeWorker(u),n.onFrameFinished(s)};if(c=l[e],c.beingProcessed||c.done){this.onFrameFinished();return}c.sampleInterval=a,c.beingProcessed=!0,c.gifshot=!0,u=this.getWorker(),u?(u.onmessage=x,u.postMessage(c)):x({data:n.workerMethods.run(c)})},startRendering:function(e){this.onRenderCompleteCallback=e;for(let n=0;n<this.options.numWorkers&&n<this.frames.length;n++)this.processFrame(n)},processNextFrame:function(){let e=-1;for(let n=0;n<this.frames.length;n++){let o=this.frames[n];if(!o.done&&!o.beingProcessed){e=n;break}}e>=0&&this.processFrame(e)},generateGIF:function(e,n){let o=[],i={loop:this.repeat},s=this.options,a=s.interval,l=s.frameDuration,c=s.images,u=Boolean(c.length),x=s.gifHeight,k=s.gifWidth,m=new Ye(o,k,x,i),v=this.onRenderProgressCallback,w=u?a*100:0,E,y;this.generatingGIF=!0,r.each(e,function(C,z){let I=z.palette;v(.75+.25*z.position*1/e.length);for(let M=0;M<l;M++)m.addFrame(0,0,k,x,z.pixels,{palette:I,delay:w})}),m.end(),v(1),this.frames=[],this.generatingGIF=!1,r.isFunction(n)&&(E=this.bufferToString(o),y=`data:image/gif;base64,${r.btoa(E)}`,n(y))},setRepeat:function(e){this.repeat=e},addFrame:function(e,n){n=r.isObject(n)?n:{};let o=this,i=o.ctx,s=o.options,a=s.gifWidth,l=s.gifHeight,c=r.getFontSize(n),u=n,x=u.filter,k=u.fontColor,m=u.fontFamily,v=u.fontWeight,w=u.gifHeight,E=u.gifWidth,y=u.text,C=u.textAlign,z=u.textBaseline,I=n.textXCoordinate?n.textXCoordinate:C==="left"?1:C==="right"?a:a/2,M=n.textYCoordinate?n.textYCoordinate:z==="top"?1:z==="center"?l/2:l,V=`${v} ${c} ${m}`,R;try{i.filter=x,i.drawImage(e,0,0,a,l),y&&(i.font=V,i.fillStyle=k,i.textAlign=C,i.textBaseline=z,i.fillText(y,I,M)),R=i.getImageData(0,0,a,l),o.addFrameImageData(R)}catch(U){return`${U}`}},addFrameImageData:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=this.frames,o=e.data;this.frames.push({data:o,width:e.width,height:e.height,palette:null,dithering:null,done:!1,beingProcessed:!1,position:n.length})},onRenderProgress:function(e){this.onRenderProgressCallback=e},isRendering:function(){return this.generatingGIF},getBase64GIF:function(e){let n=this,o=function(s){n.destroyWorkers(),r.requestTimeout(function(){e(s)},0)};n.startRendering(o)},destroyWorkers:function(){if(this.workerError)return;let e=this.workers;r.each(e,function(n,o){let i=o.worker,s=o.objectUrl;i.terminate(),r.URL.revokeObjectURL(s)})}};function Qe(t,e){t.getBase64GIF(function(n){e({error:!1,errorCode:"",errorMsg:"",image:n})})}function Ke(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=this,n=t.callback,o=t.images,i=t.options,s=t.imagesLength,a={getUserMedia:!0,"globalThis.URL":!0},l=q.validate(a),c=[],u=0,x,k;if(l.error)return n(l);k=new ve(i),r.each(o,function(v,w){let E=w;r.isElement(E)?(i.crossOrigin&&(E.crossOrigin=i.crossOrigin),c[v]=E,u+=1,u===s&&m()):r.isString(E)&&(x=new Image,i.crossOrigin&&(x.crossOrigin=i.crossOrigin),function(y){w.text&&(y.text=w.text),y.onerror=function(C){let z;if(--s,s===0)return z={},z.error="None of the requested images was capable of being retrieved",n(z)},y.onload=function(C){w.text?c[v]={img:y,text:y.text}:c[v]=y,u+=1,u===s&&m(),r.removeElement(y)},y.src=E}(x),r.setCSSAttr(x,{position:"fixed",opacity:"0"}),D.body.appendChild(x))});function m(){r.each(c,function(v,w){w&&(w.text?k.addFrame(w.img,i,w.text):k.addFrame(w,i))}),Qe(k,n)}}var Ze=function(){},pe={getGIF:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments[1];n=r.isFunction(n)?n:Ze;let o=D.createElement("canvas"),i,s=e.images,a=Boolean(s.length),l=e.cameraStream,c=e.crop,u=e.filter,x=e.fontColor,k=e.fontFamily,m=e.fontWeight,v=e.keepCameraOn,w=e.numWorkers,E=e.progressCallback,y=e.saveRenderingContexts,C=e.savedRenderingContexts,z=e.text,I=e.textAlign,M=e.textBaseline,V=e.videoElement,R=e.videoHeight,U=e.videoWidth,Y=e.webcamVideoElement,L=Number(e.gifWidth),H=Number(e.gifHeight),N=Number(e.interval),G=Number(e.sampleInterval),j=a?0:N*1e3,X=[],S=C.length?C.length:e.numFrames,P=S,Q=new ve(e),Z=r.getFontSize(e),ee=e.textXCoordinate?e.textXCoordinate:I==="left"?1:I==="right"?L:L/2,me=e.textYCoordinate?e.textYCoordinate:M==="top"?1:M==="center"?H/2:H,ue=`${m} ${Z} ${k}`,te=c?Math.floor(c.scaledWidth/2):0,ie=c?U-c.scaledWidth:0,ne=c?Math.floor(c.scaledHeight/2):0,oe=c?R-c.scaledHeight:0,ge=function re(){let ae=P-1;C.length?(i.putImageData(C[S-P],0,0),J()):le();function le(){try{ie>U&&(ie=U),oe>R&&(oe=R),te<0&&(te=0),ne<0&&(ne=0),i.filter=u,i.drawImage(V,te,ne,ie,oe,0,0,L,H),J()}catch(g){if(g.name==="NS_ERROR_NOT_AVAILABLE")r.requestTimeout(le,100);else throw g}}function J(){let g;y&&X.push(i.getImageData(0,0,L,H)),z&&(i.font=ue,i.fillStyle=x,i.textAlign=I,i.textBaseline=M,i.fillText(z,ee,me)),g=i.getImageData(0,0,L,H),Q.addFrameImageData(g),P=ae,E((S-P)/S),ae>0&&r.requestTimeout(re,j),P||Q.getBase64GIF(function(p){n({error:!1,errorCode:"",errorMsg:"",image:p,cameraStream:l,videoElement:V,webcamVideoElement:Y,savedRenderingContexts:X,keepCameraOn:v})})}};S=S!==void 0?S:10,N=N!==void 0?N:.1,o.width=L,o.height=H,i=o.getContext("2d"),function re(){if(!C.length&&V.currentTime===0){r.requestTimeout(re,100);return}ge()}()},getCropDimensions:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=e.videoWidth,o=e.videoHeight,i=e.gifWidth,s=e.gifHeight,a={width:0,height:0,scaledWidth:0,scaledHeight:0};return n>o?(a.width=Math.round(n*(s/o))-i,a.scaledWidth=Math.round(a.width*(o/s))):(a.height=Math.round(o*(i/n))-s,a.scaledHeight=Math.round(a.height*(n/i))),a}},B={loadedData:!1,defaultVideoDimensions:{width:640,height:480},findVideoSize:function t(e){t.attempts=t.attempts||0;let n=e.cameraStream,o=e.completedCallback,i=e.videoElement;i&&(i.videoWidth>0&&i.videoHeight>0?(i.removeEventListener("loadeddata",B.findVideoSize),o({videoElement:i,cameraStream:n,videoWidth:i.videoWidth,videoHeight:i.videoHeight})):t.attempts<10?(t.attempts+=1,r.requestTimeout(function(){B.findVideoSize(e)},400)):o({videoElement:i,cameraStream:n,videoWidth:B.defaultVideoDimensions.width,videoHeight:B.defaultVideoDimensions.height}))},onStreamingTimeout:function(e){r.isFunction(e)&&e({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - Timed out while trying to start streaming",image:null,cameraStream:{}})},stream:function(e){let n=r.isArray(e.existingVideo)?e.existingVideo[0]:e.existingVideo,o=e.cameraStream,i=e.completedCallback,s=e.streamedCallback,a=e.videoElement;if(r.isFunction(s)&&s(),n){if(r.isString(n))a.src=n,a.innerHTML=`<source src="${n}" type="video/${r.getExtension(n)}" />`;else if(n instanceof Blob){try{a.src=r.URL.createObjectURL(n)}catch{}a.innerHTML=`<source src="${n}" type="${n.type}" />`}}else if(a.mozSrcObject)a.mozSrcObject=o;else if(r.URL)try{a.srcObject=o,a.src=r.URL.createObjectURL(o)}catch{a.srcObject=o}a.play(),r.requestTimeout(function l(){l.count=l.count||0,B.loadedData===!0?(B.findVideoSize({videoElement:a,cameraStream:o,completedCallback:i}),B.loadedData=!1):(l.count+=1,l.count>10?B.findVideoSize({videoElement:a,cameraStream:o,completedCallback:i}):l())},0)},startStreaming:function(e){let n=r.isFunction(e.error)?e.error:r.noop,o=r.isFunction(e.streamed)?e.streamed:r.noop,i=r.isFunction(e.completed)?e.completed:r.noop,s=e.crossOrigin,a=e.existingVideo,l=e.lastCameraStream,c=e.options,u=e.webcamVideoElement,x=r.isElement(a)?a:u||D.createElement("video"),k=void 0;s&&(x.crossOrigin=c.crossOrigin),x.autoplay=!0,x.loop=!0,x.muted=!0,x.addEventListener("loadeddata",function(m){B.loadedData=!0,c.offset&&(x.currentTime=c.offset)}),a?B.stream({videoElement:x,existingVideo:a,completedCallback:i}):l?B.stream({videoElement:x,cameraStream:l,streamedCallback:o,completedCallback:i}):r.getUserMedia({video:!0},function(m){B.stream({videoElement:x,cameraStream:m,streamedCallback:o,completedCallback:i})},n)},startVideoStreaming:function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=n.timeout!==void 0?n.timeout:0,i=n.callback,s=n.webcamVideoElement,a;o>0&&(a=r.requestTimeout(function(){B.onStreamingTimeout(i)},1e4)),B.startStreaming({error:function(){i({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - the user probably denied permission",image:null,cameraStream:{}})},streamed:function(){clearTimeout(a)},completed:function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},u=c.cameraStream,x=c.videoElement,k=c.videoHeight,m=c.videoWidth;e({cameraStream:u,videoElement:x,videoHeight:k,videoWidth:m})},lastCameraStream:n.lastCameraStream,webcamVideoElement:s,crossOrigin:n.crossOrigin,options:n})},stopVideoStreaming:function(e){e=r.isObject(e)?e:{};let n=e,o=n.keepCameraOn,i=n.videoElement,s=n.webcamVideoElement,a=e.cameraStream||{},l=a.getTracks?a.getTracks()||[]:[],c=Boolean(l.length),u=l[0];!o&&c&&r.isFunction(u.stop)&&u.stop(),r.isElement(i)&&!s&&(i.pause(),r.isFunction(r.URL.revokeObjectURL)&&!r.webWorkerError&&i.src&&r.URL.revokeObjectURL(i.src),r.removeElement(i))}};function Ae(t){t=r.isObject(t)?t:{},B.stopVideoStreaming(t)}function ze(t,e){let n=t.options||{},o=n.images,i=n.video,s=Number(n.gifWidth),a=Number(n.gifHeight),l=Number(n.numFrames),c=t.cameraStream,u=t.videoElement,x=t.videoWidth,k=t.videoHeight,m=pe.getCropDimensions({videoWidth:x,videoHeight:k,gifHeight:a,gifWidth:s}),v=e;n.crop=m,n.videoElement=u,n.videoWidth=x,n.videoHeight=k,n.cameraStream=c,r.isElement(u)&&(u.width=s+m.width,u.height=a+m.height,n.webcamVideoElement||(r.setCSSAttr(u,{position:"fixed",opacity:"0"}),D.body.appendChild(u)),u.play(),pe.getGIF(n,function(w){(!o||!o.length)&&(!i||!i.length)&&Ae(w),v(w)}))}function Je(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=t.callback,n=t.existingVideo,o=t.options,i={getUserMedia:!0,"globalThis.URL":!0},s=q.validate(i),a=0,l,c,u=void 0,x=void 0;if(s.error)return e(s);if(r.isElement(n)&&n.src){if(c=n.src,l=r.getExtension(c),!r.isSupported.videoCodecs[l])return e(q.messages.videoCodecs)}else r.isArray(n)&&r.each(n,function(k,m){if(m instanceof Blob?l=m.type.substr(m.type.lastIndexOf("/")+1,m.length):l=m.substr(m.lastIndexOf(".")+1,m.length),r.isSupported.videoCodecs[l])return n=m,!1});B.startStreaming({completed:function(m){m.options=o||{},ze(m,e)},existingVideo:n,crossOrigin:o.crossOrigin,options:o})}function et(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=t.callback,n=t.lastCameraStream,o=t.options,i=t.webcamVideoElement;if(!We())return e(q.validate());if(o.savedRenderingContexts.length){pe.getGIF(o,function(s){e(s)});return}B.startVideoStreaming(function(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};s.options=o||{},ze(s,e)},{lastCameraStream:n,callback:e,webcamVideoElement:i,crossOrigin:o.crossOrigin})}function Ie(t,e){if(e=r.isFunction(t)?t:e,t=r.isObject(t)?t:{},!r.isFunction(e))return;let n=r.normalizeOptions(be,t)||{},o=t.cameraStream,i=n.images,s=i?i.length:0,a=n.video,l=n.webcamVideoElement;n=r.normalizeOptions(n,{gifWidth:Math.floor(n.gifWidth),gifHeight:Math.floor(n.gifHeight)}),s?Ke({images:i,imagesLength:s,callback:e,options:n}):a?Je({existingVideo:a,callback:e,options:n}):et({lastCameraStream:o,callback:e,webcamVideoElement:l,options:n})}function tt(t,e){if(e=r.isFunction(t)?t:e,t=r.isObject(t)?t:{},!r.isFunction(e))return;let n=r.normalizeOptions(be,t),o=r.normalizeOptions(n,{interval:.1,numFrames:1,gifWidth:Math.floor(n.gifWidth),gifHeight:Math.floor(n.gifHeight)});Ie(o,e)}var it={utils:je,error:De,defaultOptions:Ne,createGIF:Ie,takeSnapShot:tt,stopVideoStreaming:Ae,isSupported:$e,isWebCamGIFSupported:We,isExistingVideoGIFSupported:Xe,isExistingImagesGIFSupported:qe,VERSION:"0.4.5"},Oe=it;var nt={source:"images",width:200,height:200,crossOrigin:"Anonymous",progressCallback:t=>{},completeCallback:()=>{},numWorkers:2,sampleInterval:10,interval:.1,offset:null,numFrames:10,frameDuration:1,filter:"",waterMark:null,waterMarkHeight:null,waterMarkWidth:null,waterMarkXCoordinate:1,waterMarkYCoordinate:1,text:"",showFrameText:!0,fontWeight:"normal",fontSize:"16px",minFontSize:"10px",resizeFont:!1,fontFamily:"sans-serif",fontColor:"#ffffff",textAlign:"center",textBaseline:"bottom",textXCoordinate:null,textYCoordinate:null,webcamVideoElement:null,keepCameraOn:!1,cameraStream:null,saveRenderingContexts:!1,savedRenderingContexts:[]},K=class{static get properties(){return{id:"gif",name:"GIF",extensions:["gif"],mimeTypes:["image/gif"],builder:K,options:nt}}constructor(e){this.options={...e},this.source=e.source,delete e.source,this.files=[],this.gifshot=Oe}async initialize(e){}async add(e){await this.initialize(),this.files.push(e)}async build(){switch(await this.initialize(),this._cleanOptions(this.options),this.source){case"images":this.options.images=this.files;break;case"video":this.options.video=this.files;break;case"webcam":Se(this.files.length===0);break;default:throw new Error("GIFBuilder: invalid source")}return await this._createGIF()}async _createGIF(){return new Promise((e,n)=>{this.gifshot.createGIF(this.options,o=>{if(o.error){n(o.errorMsg);return}e(o.image)})})}_cleanOptions(e){(e.video||e.images||e.gifWidth||e.gifHeight)&&console.warn("GIFBuilder: ignoring options"),delete e.video,delete e.images,e.gifWidth=e.width,e.gifHeight=e.height,delete e.width,delete e.height}};return Pe(se);})();
|
|
7
|
+
"use strict";var __exports__=(()=>{var Pe=Object.create;var de=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var je=Object.getPrototypeOf,Ne=Object.prototype.hasOwnProperty;var fe=(t,e)=>()=>(t&&(e=t(t=0)),e);var $e=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ke=(t,e)=>{for(var n in e)de(t,n,{get:e[n],enumerable:!0})},ce=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ge(e))!Ne.call(t,i)&&i!==n&&de(t,i,{get:()=>e[i],enumerable:!(o=De(e,i))||o.enumerable});return t},me=(t,e,n)=>(ce(t,e,"default"),n&&ce(n,e,"default")),qe=(t,e,n)=>(n=t!=null?Pe(je(t)):{},ce(e||!t||!t.__esModule?de(n,"default",{value:t,enumerable:!0}):n,t)),Xe=t=>ce(de({},"__esModule",{value:!0}),t);var We=$e((ht,Te)=>{Te.exports=globalThis.loaders});var ue,ve=fe(()=>{"use strict";ue={name:"Video",id:"video",module:"video",encoding:"video",format:"video",extensions:["mp4"],mimeTypes:["video/mp4"],category:"video",binary:!0}});async function xe(t){let e=new Blob([t]),n=document.createElement("video");return n.src=URL.createObjectURL(e),n}var Ee=fe(()=>{"use strict"});var Ae={};ke(Ae,{VideoLoaderWithParser:()=>Qe});var wt,Ye,Qe,Ie=fe(()=>{"use strict";Ee();we();({preload:wt,...Ye}=ge),Qe={...Ye,parse:xe}});async function Ze(){let{VideoLoaderWithParser:t}=await Promise.resolve().then(()=>(Ie(),Ae));return t}var Ke,ge,we=fe(()=>{"use strict";ve();Ke="5.0.0-alpha.1";ge={dataType:null,batchType:null,...ue,version:Ke,options:{video:{}},preload:Ze}});var se={};ke(se,{GIFBuilder:()=>K,VideoFormat:()=>ue,VideoLoader:()=>ge});me(se,qe(We(),1));ve();we();function ze(t,e){if(!t)throw new Error(e)}var j=globalThis.document||{},r={URL:globalThis.URL||globalThis.webkitURL||globalThis.mozURL||globalThis.msURL,getUserMedia:function(){if(!globalThis.navigator)return globalThis.navigator;let t=globalThis.navigator.getUserMedia||globalThis.navigator.webkitGetUserMedia||globalThis.navigator.mozGetUserMedia||globalThis.navigator.msGetUserMedia;return t&&t.bind(globalThis.navigator)}(),requestAnimFrame:globalThis.requestAnimationFrame||globalThis.webkitRequestAnimationFrame||globalThis.mozRequestAnimationFrame||globalThis.oRequestAnimationFrame||globalThis.msRequestAnimationFrame,requestTimeout:function(e,n){if(e=e||r.noop,n=n||0,!r.requestAnimFrame)return setTimeout(e,n);let o=new Date().getTime(),i=new Object,a=r.requestAnimFrame,l=function s(){new Date().getTime()-o>=n?e.call():i.value=a(s)};return i.value=a(l),i},Blob:globalThis.Blob||globalThis.BlobBuilder||globalThis.WebKitBlobBuilder||globalThis.MozBlobBuilder||globalThis.MSBlobBuilder,btoa:function(){let t=globalThis.btoa||function(e){let n="",o=0,i=e.length,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l,s,c,h,x,k,m;for(;o<i;)l=e.charCodeAt(o++),s=e.charCodeAt(o++),c=e.charCodeAt(o++),h=l>>2,x=(l&3)<<4|s>>4,k=(s&15)<<2|c>>6,m=c&63,Number.isNaN(s)?k=m=64:Number.isNaN(c)&&(m=64),n=n+a.charAt(h)+a.charAt(x)+a.charAt(k)+a.charAt(m);return n};return t?t.bind(globalThis):r.noop}(),isObject:function(e){return e&&Object.prototype.toString.call(e)==="[object Object]"},isEmptyObject:function(e){return r.isObject(e)&&!Object.keys(e).length},isArray:function(e){return e&&Array.isArray(e)},isFunction:function(e){return e&&typeof e=="function"},isElement:function(e){return e&&e.nodeType===1},isImageBitmap:function(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap},isDrawable:function(e){return r.isElement(e)||r.isImageBitmap(e)},isString:function(e){return typeof e=="string"||Object.prototype.toString.call(e)==="[object String]"},isSupported:{canvas:function(){let e=j.createElement("canvas");return e&&e.getContext&&e.getContext("2d")},webworkers:function(){return globalThis.Worker},blob:function(){return r.Blob},Uint8Array:function(){return globalThis.Uint8Array},Uint32Array:function(){return globalThis.Uint32Array},videoCodecs:function(){let t=j.createElement("video"),e={mp4:!1,h264:!1,ogv:!1,ogg:!1,webm:!1};try{t&&t.canPlayType&&(e.mp4=t.canPlayType('video/mp4; codecs="mp4v.20.8"')!=="",e.h264=(t.canPlayType('video/mp4; codecs="avc1.42E01E"')||t.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"'))!=="",e.ogv=t.canPlayType('video/ogg; codecs="theora"')!=="",e.ogg=t.canPlayType('video/ogg; codecs="theora"')!=="",e.webm=t.canPlayType('video/webm; codecs="vp8, vorbis"')!==-1)}catch{}return e}()},noop:function(){},each:function(e,n){let o,i;if(r.isArray(e))for(o=-1,i=e.length;++o<i&&n(o,e[o])!==!1;);else if(r.isObject(e)){for(o in e)if(e.hasOwnProperty(o)&&n(o,e[o])===!1)break}},normalizeOptions:function(e,n){if(!r.isObject(e)||!r.isObject(n)||!Object.keys)return;let o={};return r.each(e,function(i,a){o[i]=e[i]}),r.each(n,function(i,a){let l=n[i];r.isObject(l)&&e[i]?o[i]=r.normalizeOptions(e[i],l):o[i]=l}),o},setCSSAttr:function(e,n,o){r.isElement(e)&&(r.isString(n)&&r.isString(o)?e.style[n]=o:r.isObject(n)&&r.each(n,function(i,a){e.style[i]=a}))},removeElement:function(e){r.isElement(e)&&e.parentNode&&e.parentNode.removeChild(e)},createWebWorker:function(e){if(!r.isString(e))return{};try{let n=new r.Blob([e],{type:"text/javascript"}),o=r.URL.createObjectURL(n),i=new Worker(o);return{objectUrl:o,worker:i}}catch(n){return`${n}`}},getExtension:function(e){return e.substr(e.lastIndexOf(".")+1,e.length)},getFontSize:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!j.body||e.resizeFont===!1)return e.fontSize;let n=e.text,o=e.gifWidth,i=parseInt(e.fontSize,10),a=parseInt(e.minFontSize,10),l=j.createElement("div"),s=j.createElement("span");for(l.setAttribute("width",o),l.appendChild(s),s.innerHTML=n,s.style.fontSize=`${i}px`,s.style.textIndent="-9999px",s.style.visibility="hidden",j.body.appendChild(s);s.offsetWidth>o&&i>=a;)s.style.fontSize=`${--i}px`;return j.body.removeChild(s),`${i}px`},webWorkerError:!1},Je=Object.freeze({default:r}),q={validate:function(e){e=r.isObject(e)?e:{};let n={};return r.each(q.validators,function(o,i){let a=i.errorCode;if(!e[a]&&!i.condition)return n=i,n.error=!0,!1}),delete n.condition,n},isValid:function(e){return q.validate(e).error!==!0},validators:[{condition:r.isFunction(r.getUserMedia),errorCode:"getUserMedia",errorMsg:"The getUserMedia API is not supported in your browser"},{condition:r.isSupported.canvas(),errorCode:"canvas",errorMsg:"Canvas elements are not supported in your browser"},{condition:r.isSupported.webworkers(),errorCode:"webworkers",errorMsg:"The Web Workers API is not supported in your browser"},{condition:r.isFunction(r.URL),errorCode:"globalThis.URL",errorMsg:"The globalThis.URL API is not supported in your browser"},{condition:r.isSupported.blob(),errorCode:"globalThis.Blob",errorMsg:"The globalThis.Blob File API is not supported in your browser"},{condition:r.isSupported.Uint8Array(),errorCode:"globalThis.Uint8Array",errorMsg:"The globalThis.Uint8Array function constructor is not supported in your browser"},{condition:r.isSupported.Uint32Array(),errorCode:"globalThis.Uint32Array",errorMsg:"The globalThis.Uint32Array function constructor is not supported in your browser"}],messages:{videoCodecs:{errorCode:"videocodec",errorMsg:"The video codec you are trying to use is not supported in your browser"}}},et=Object.freeze({default:q}),Oe=function(){},Ce={sampleInterval:10,numWorkers:2,filter:"",gifWidth:200,gifHeight:200,interval:.1,numFrames:10,frameDuration:1,keepCameraOn:!1,images:[],video:null,webcamVideoElement:null,cameraStream:null,text:"",fontWeight:"normal",fontSize:"16px",minFontSize:"10px",resizeFont:!1,fontFamily:"sans-serif",fontColor:"#ffffff",textAlign:"center",textBaseline:"bottom",textXCoordinate:null,textYCoordinate:null,progressCallback:Oe,completeCallback:Oe,saveRenderingContexts:!1,savedRenderingContexts:[],crossOrigin:"Anonymous"},tt=Object.freeze({default:Ce});function it(){return q.isValid()}function Me(){return q.isValid()}function nt(){let t={getUserMedia:!0};return q.isValid(t)}function ot(t){let e=!1;if(r.isArray(t)&&t.length){if(r.each(t,function(n,o){r.isSupported.videoCodecs[o]&&(e=!0)}),!e)return!1}else if(r.isString(t)&&t.length&&!r.isSupported.videoCodecs[t])return!1;return q.isValid({getUserMedia:!0})}function Ue(){let M,H,G,X,F,P=[],Q=[],Z=[],ee=[];function he(u,p,W){let g,b;for(H=u,G=p,X=W,F=new Array(256),g=0;g<256;g++)F[g]=new Array(4),b=F[g],b[0]=b[1]=b[2]=(g<<4+8)/256|0,Z[g]=65536/256|0,Q[g]=0}function pe(){let u=[],p=new Array(256);for(let g=0;g<256;g++)p[F[g][3]]=g;let W=0;for(let g=0;g<256;g++){let b=p[g];u[W++]=F[b][0],u[W++]=F[b][1],u[W++]=F[b][2]}return u}function te(){let u,p,W,g,b,d,f,S;for(f=0,S=0,u=0;u<256;u++){for(b=F[u],W=u,g=b[1],p=u+1;p<256;p++)d=F[p],d[1]<g&&(W=p,g=d[1]);if(d=F[W],u!==W&&(p=d[0],d[0]=b[0],b[0]=p,p=d[1],d[1]=b[1],b[1]=p,p=d[2],d[2]=b[2],b[2]=p,p=d[3],d[3]=b[3],b[3]=p),g!==f){for(P[f]=S+u>>1,p=f+1;p<g;p++)P[p]=u;f=g,S=u}}for(P[f]=S+255>>1,p=f+1;p<256;p++)P[p]=255}function ie(){let u,p,W,g,b,d,f,S,T,O,$,A,D,Se;for(G<1509&&(X=1),M=30+(X-1)/3,A=H,D=0,Se=G,$=G/(3*X),O=$/100|0,S=1024,d=2048,f=d>>6,f<=1&&(f=0),u=0;u<f;u++)ee[u]=S*((f*f-u*u)*256/(f*f));for(G<1509?T=3:G%499!==0?T=3*499:G%491!==0?T=3*491:G%487!==0?T=3*487:T=3*503,u=0;u<$;)if(W=(A[D+0]&255)<<4,g=(A[D+1]&255)<<4,b=(A[D+2]&255)<<4,p=le(W,g,b),ae(S,p,W,g,b),f!==0&&re(f,p,W,g,b),D+=T,D>=Se&&(D-=G),u++,O===0&&(O=1),u%O===0)for(S-=S/M,d-=d/30,f=d>>6,f<=1&&(f=0),p=0;p<f;p++)ee[p]=S*((f*f-p*p)*256/(f*f))}function ne(u,p,W){let g,b,d,f,S,T,O;for(S=1e3,O=-1,g=P[p],b=g-1;g<256||b>=0;)g<256&&(T=F[g],d=T[1]-p,d>=S?g=256:(g++,d<0&&(d=-d),f=T[0]-u,f<0&&(f=-f),d+=f,d<S&&(f=T[2]-W,f<0&&(f=-f),d+=f,d<S&&(S=d,O=T[3])))),b>=0&&(T=F[b],d=p-T[1],d>=S?b=-1:(b--,d<0&&(d=-d),f=T[0]-u,f<0&&(f=-f),d+=f,d<S&&(f=T[2]-W,f<0&&(f=-f),d+=f,d<S&&(S=d,O=T[3]))));return O}function oe(){return ie(),be(),te(),pe()}function be(){let u,p;for(u=0;u<256;u++)F[u][0]>>=4,F[u][1]>>=4,F[u][2]>>=4,F[u][3]=u}function re(u,p,W,g,b){let d,f,S,T,O,$,A;for(S=p-u,S<-1&&(S=-1),T=p+u,T>256&&(T=256),d=p+1,f=p-1,$=1;d<T||f>S;){if(O=ee[$++],d<T){A=F[d++];try{A[0]-=O*(A[0]-W)/262144|0,A[1]-=O*(A[1]-g)/262144|0,A[2]-=O*(A[2]-b)/262144|0}catch{}}if(f>S){A=F[f--];try{A[0]-=O*(A[0]-W)/262144|0,A[1]-=O*(A[1]-g)/262144|0,A[2]-=O*(A[2]-b)/262144|0}catch{}}}}function ae(u,p,W,g,b){let d=F[p],f=u/1024;d[0]-=f*(d[0]-W)|0,d[1]-=f*(d[1]-g)|0,d[2]-=f*(d[2]-b)|0}function le(u,p,W){let g,b,d,f,S,T,O,$,A,D;for($=~(1<<31),A=$,T=-1,O=T,g=0;g<256;g++)D=F[g],b=D[0]-u,b<0&&(b=-b),d=D[1]-p,d<0&&(d=-d),b+=d,d=D[2]-W,d<0&&(d=-d),b+=d,b<$&&($=b,T=g),f=b-(Q[g]>>16-4),f<A&&(A=f,O=g),S=Z[g]>>10,Z[g]-=S,Q[g]+=S<<10;return Z[T]+=64,Q[T]-=65536,O}he.apply(this,arguments);let J={};return J.map=ne,J.process=oe,J}function Ve(){let t=this;try{globalThis.onmessage=function(n){let o=n.data||{},i;o.gifshot&&(i=e.run(o),postMessage(i))}}catch{}var e={dataToRGB:function(o,i,a){let l=i*a*4,s=0,c=[];for(;s<l;)c.push(o[s++]),c.push(o[s++]),c.push(o[s++]),s++;return c},componentizedPaletteToArray:function(o){o=o||[];let i=[];for(let a=0;a<o.length;a+=3){let l=o[a],s=o[a+1],c=o[a+2];i.push(l<<16|s<<8|c)}return i},processFrameWithQuantizer:function(o,i,a,l){let s=this.dataToRGB(o,i,a),c=new Ue(s,s.length,l),h=c.process(),x=new Uint32Array(this.componentizedPaletteToArray(h)),k=i*a,m=new Uint8Array(k),v=0;for(let w=0;w<k;w++){let E=s[v++],y=s[v++],C=s[v++];m[w]=c.map(E,y,C)}return{pixels:m,palette:x}},run:function(o){o=o||{};let i=o,a=i.height,l=i.palette,s=i.sampleInterval,c=i.width,h=o.data;return this.processFrameWithQuantizer(h,c,a,s)}};return e}function rt(t,e,n,o){let i=0;o=o===void 0?{}:o;let a=o.loop===void 0?null:o.loop,l=o.palette===void 0?null:o.palette;if(e<=0||n<=0||e>65535||n>65535)throw"Width/Height invalid.";function s(m){let v=m.length;if(v<2||v>256||v&v-1)throw"Invalid code/color length, must be power of 2 and 2 .. 256.";return v}t[i++]=71,t[i++]=73,t[i++]=70,t[i++]=56,t[i++]=57,t[i++]=97;let c=0,h=0;if(t[i++]=e&255,t[i++]=e>>8&255,t[i++]=n&255,t[i++]=n>>8&255,t[i++]=(l!==null?128:0)|c,t[i++]=h,t[i++]=0,a!==null){if(a<0||a>65535)throw"Loop count invalid.";t[i++]=33,t[i++]=255,t[i++]=11,t[i++]=78,t[i++]=69,t[i++]=84,t[i++]=83,t[i++]=67,t[i++]=65,t[i++]=80,t[i++]=69,t[i++]=50,t[i++]=46,t[i++]=48,t[i++]=3,t[i++]=1,t[i++]=a&255,t[i++]=a>>8&255,t[i++]=0}let x=!1;this.addFrame=function(m,v,w,E,y,C){if(x===!0&&(--i,x=!1),C=C===void 0?{}:C,m<0||v<0||m>65535||v>65535)throw"x/y invalid.";if(w<=0||E<=0||w>65535||E>65535)throw"Width/Height invalid.";if(y.length<w*E)throw"Not enough pixels for the frame size.";let I=!0,z=C.palette;if(z==null&&(I=!1,z=l),z==null)throw"Must supply either a local or global palette.";let V=s(z),U=0;for(V>>=1;V;)++U,V>>=1;V=1<<U;let R=C.delay===void 0?0:C.delay,M=C.disposal===void 0?0:C.disposal;if(M<0||M>3)throw"Disposal out of range.";let Y=!1,_=0;if(C.transparent!==void 0&&C.transparent!==null&&(Y=!0,_=C.transparent,_<0||_>=V))throw"Transparent color index.";if((M!==0||Y||R!==0)&&(t[i++]=33,t[i++]=249,t[i++]=4,t[i++]=M<<2|(Y===!0?1:0),t[i++]=R&255,t[i++]=R>>8&255,t[i++]=_,t[i++]=0),t[i++]=44,t[i++]=m&255,t[i++]=m>>8&255,t[i++]=v&255,t[i++]=v>>8&255,t[i++]=w&255,t[i++]=w>>8&255,t[i++]=E&255,t[i++]=E>>8&255,t[i++]=I===!0?128|U-1:0,I===!0)for(let L=0,N=z.length;L<N;++L){let H=z[L];t[i++]=H>>16&255,t[i++]=H>>8&255,t[i++]=H&255}i=k(t,i,U<2?2:U,y)},this.end=function(){return x===!1&&(t[i++]=59,x=!0),i};function k(m,v,w,E){m[v++]=w;let y=v++,C=1<<w,I=C-1,z=C+1,V=z+1,U=w+1,R=0,M=0;function Y(H){for(;R>=H;)m[v++]=M&255,M>>=8,R-=8,v===y+256&&(m[y]=255,y=v++)}function _(H){M|=H<<R,R+=U,Y(8)}let L=E[0]&I,N={};_(C);for(let H=1,G=E.length;H<G;++H){let X=E[H]&I,F=L<<8|X,P=N[F];if(P===void 0){for(M|=L<<R,R+=U;R>=8;)m[v++]=M&255,M>>=8,R-=8,v===y+256&&(m[y]=255,y=v++);V===4096?(_(C),V=z+1,U=w+1,N={}):(V>=1<<U&&++U,N[F]=V++),L=X}else L=P}return _(L),_(z),Y(1),y+1===v?m[y]=0:(m[y]=v-y-1,m[v++]=0),v}}var Re=function(){},Fe=function(e){this.canvas=null,this.ctx=null,this.repeat=0,this.frames=[],this.numRenderedFrames=0,this.onRenderCompleteCallback=Re,this.onRenderProgressCallback=Re,this.workers=[],this.availableWorkers=[],this.generatingGIF=!1,this.options=e,this.initializeWebWorkers(e)};Fe.prototype={workerMethods:Ve(),initializeWebWorkers:function(e){let n=this,o=`${Ue.toString()}(${Ve.toString()}());`,i,a,l,s,c=-1,h="";for(s=e.numWorkers;++c<s;)i=r.createWebWorker(o),r.isObject(i)?(a=i.objectUrl,l=i.worker,n.workers.push({worker:l,objectUrl:a}),n.availableWorkers.push(l)):(h=i,r.webWorkerError=Boolean(i));this.workerError=h,this.canvas=j.createElement("canvas"),this.canvas.width=e.gifWidth,this.canvas.height=e.gifHeight,this.ctx=this.canvas.getContext("2d"),this.frames=[]},getWorker:function(){return this.availableWorkers.pop()},freeWorker:function(e){this.availableWorkers.push(e)},byteMap:function(){let t=[];for(let e=0;e<256;e++)t[e]=String.fromCharCode(e);return t}(),bufferToString:function(e){let n=e.length,o="",i=-1;for(;++i<n;)o+=this.byteMap[e[i]];return o},onFrameFinished:function(e){let n=this,o=n.frames,i=n.options,a=Boolean((i.images||[]).length),l=o.every(function(s){return!s.beingProcessed&&s.done});n.numRenderedFrames++,a&&e(n.numRenderedFrames/o.length),n.onRenderProgressCallback(n.numRenderedFrames*.75/o.length),l?n.generatingGIF||n.generateGIF(o,n.onRenderCompleteCallback):r.requestTimeout(function(){n.processNextFrame()},1)},processFrame:function(e){let n=this,o=this.options,i=o.progressCallback,a=o.sampleInterval,l=this.frames,s,c,h=function(){let m=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).data;delete s.data,s.pixels=Array.prototype.slice.call(m.pixels),s.palette=Array.prototype.slice.call(m.palette),s.done=!0,s.beingProcessed=!1,n.freeWorker(c),n.onFrameFinished(i)};if(s=l[e],s.beingProcessed||s.done){this.onFrameFinished();return}s.sampleInterval=a,s.beingProcessed=!0,s.gifshot=!0,c=this.getWorker(),c?(c.onmessage=h,c.postMessage(s)):h({data:n.workerMethods.run(s)})},startRendering:function(e){this.onRenderCompleteCallback=e;for(let n=0;n<this.options.numWorkers&&n<this.frames.length;n++)this.processFrame(n)},processNextFrame:function(){let e=-1;for(let n=0;n<this.frames.length;n++){let o=this.frames[n];if(!o.done&&!o.beingProcessed){e=n;break}}e>=0&&this.processFrame(e)},generateGIF:function(e,n){let o=[],i={loop:this.repeat},a=this.options,l=a.interval,s=a.frameDuration,c=a.images,h=Boolean(c.length),x=a.gifHeight,k=a.gifWidth,m=new rt(o,k,x,i),v=this.onRenderProgressCallback,w=h?l*100:0,E,y;this.generatingGIF=!0,r.each(e,function(C,I){let z=I.palette;v(.75+.25*I.position*1/e.length);for(let V=0;V<s;V++)m.addFrame(0,0,k,x,I.pixels,{palette:z,delay:w})}),m.end(),v(1),this.frames=[],this.generatingGIF=!1,r.isFunction(n)&&(E=this.bufferToString(o),y=`data:image/gif;base64,${r.btoa(E)}`,n(y))},setRepeat:function(e){this.repeat=e},addFrame:function(e,n){n=r.isObject(n)?n:{};let o=this,i=o.ctx,a=o.options,l=a.gifWidth,s=a.gifHeight,c=r.getFontSize(n),h=n,x=h.filter,k=h.fontColor,m=h.fontFamily,v=h.fontWeight,w=h.gifHeight,E=h.gifWidth,y=h.text,C=h.textAlign,I=h.textBaseline,z=n.textXCoordinate?n.textXCoordinate:C==="left"?1:C==="right"?l:l/2,V=n.textYCoordinate?n.textYCoordinate:I==="top"?1:I==="center"?s/2:s,U=`${v} ${c} ${m}`,R;try{i.filter=x,i.drawImage(e,0,0,l,s),y&&(i.font=U,i.fillStyle=k,i.textAlign=C,i.textBaseline=I,i.fillText(y,z,V)),R=i.getImageData(0,0,l,s),o.addFrameImageData(R)}catch(M){return`${M}`}},addFrameImageData:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=this.frames,o=e.data;this.frames.push({data:o,width:e.width,height:e.height,palette:null,dithering:null,done:!1,beingProcessed:!1,position:n.length})},onRenderProgress:function(e){this.onRenderProgressCallback=e},isRendering:function(){return this.generatingGIF},getBase64GIF:function(e){let n=this,o=function(a){n.destroyWorkers(),r.requestTimeout(function(){e(a)},0)};n.startRendering(o)},destroyWorkers:function(){if(this.workerError)return;let e=this.workers;r.each(e,function(n,o){let i=o.worker,a=o.objectUrl;i.terminate(),r.URL.revokeObjectURL(a)})}};function st(t,e){t.getBase64GIF(function(n){e({error:!1,errorCode:"",errorMsg:"",image:n})})}function at(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=this,n=t.callback,o=t.images,i=t.options,a=t.imagesLength,l={getUserMedia:!0,"globalThis.URL":!0},s=q.validate(l),c=[],h=0,x,k;if(s.error)return n(s);k=new Fe(i),r.each(o,function(v,w){let E=w;r.isDrawable(E)?(i.crossOrigin&&(E.crossOrigin=i.crossOrigin),c[v]=E,h+=1,h===a&&m()):r.isString(E)&&(x=new Image,i.crossOrigin&&(x.crossOrigin=i.crossOrigin),function(y){w.text&&(y.text=w.text),y.onerror=function(C){let I;if(--a,a===0)return I={},I.error="None of the requested images was capable of being retrieved",n(I)},y.onload=function(C){w.text?c[v]={img:y,text:y.text}:c[v]=y,h+=1,h===a&&m(),r.removeElement(y)},y.src=E}(x),r.setCSSAttr(x,{position:"fixed",opacity:"0"}),j.body.appendChild(x))});function m(){r.each(c,function(v,w){w&&(w.text?k.addFrame(w.img,i,w.text):k.addFrame(w,i))}),st(k,n)}}var lt=function(){},ye={getGIF:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments[1];n=r.isFunction(n)?n:lt;let o=j.createElement("canvas"),i,a=e.images,l=Boolean(a.length),s=e.cameraStream,c=e.crop,h=e.filter,x=e.fontColor,k=e.fontFamily,m=e.fontWeight,v=e.keepCameraOn,w=e.numWorkers,E=e.progressCallback,y=e.saveRenderingContexts,C=e.savedRenderingContexts,I=e.text,z=e.textAlign,V=e.textBaseline,U=e.videoElement,R=e.videoHeight,M=e.videoWidth,Y=e.webcamVideoElement,_=Number(e.gifWidth),L=Number(e.gifHeight),N=Number(e.interval),H=Number(e.sampleInterval),G=l?0:N*1e3,X=[],F=C.length?C.length:e.numFrames,P=F,Q=new Fe(e),Z=r.getFontSize(e),ee=e.textXCoordinate?e.textXCoordinate:z==="left"?1:z==="right"?_:_/2,he=e.textYCoordinate?e.textYCoordinate:V==="top"?1:V==="center"?L/2:L,pe=`${m} ${Z} ${k}`,te=c?Math.floor(c.scaledWidth/2):0,ie=c?M-c.scaledWidth:0,ne=c?Math.floor(c.scaledHeight/2):0,oe=c?R-c.scaledHeight:0,be=function re(){let ae=P-1;C.length?(i.putImageData(C[F-P],0,0),J()):le();function le(){try{ie>M&&(ie=M),oe>R&&(oe=R),te<0&&(te=0),ne<0&&(ne=0),i.filter=h,i.drawImage(U,te,ne,ie,oe,0,0,_,L),J()}catch(u){if(u.name==="NS_ERROR_NOT_AVAILABLE")r.requestTimeout(le,100);else throw u}}function J(){let u;y&&X.push(i.getImageData(0,0,_,L)),I&&(i.font=pe,i.fillStyle=x,i.textAlign=z,i.textBaseline=V,i.fillText(I,ee,he)),u=i.getImageData(0,0,_,L),Q.addFrameImageData(u),P=ae,E((F-P)/F),ae>0&&r.requestTimeout(re,G),P||Q.getBase64GIF(function(p){n({error:!1,errorCode:"",errorMsg:"",image:p,cameraStream:s,videoElement:U,webcamVideoElement:Y,savedRenderingContexts:X,keepCameraOn:v})})}};F=F!==void 0?F:10,N=N!==void 0?N:.1,o.width=_,o.height=L,i=o.getContext("2d"),function re(){if(!C.length&&U.currentTime===0){r.requestTimeout(re,100);return}be()}()},getCropDimensions:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=e.videoWidth,o=e.videoHeight,i=e.gifWidth,a=e.gifHeight,l={width:0,height:0,scaledWidth:0,scaledHeight:0};return n>o?(l.width=Math.round(n*(a/o))-i,l.scaledWidth=Math.round(l.width*(o/a))):(l.height=Math.round(o*(i/n))-a,l.scaledHeight=Math.round(l.height*(n/i))),l}},B={loadedData:!1,defaultVideoDimensions:{width:640,height:480},findVideoSize:function t(e){t.attempts=t.attempts||0;let n=e.cameraStream,o=e.completedCallback,i=e.videoElement;i&&(i.videoWidth>0&&i.videoHeight>0?(i.removeEventListener("loadeddata",B.findVideoSize),o({videoElement:i,cameraStream:n,videoWidth:i.videoWidth,videoHeight:i.videoHeight})):t.attempts<10?(t.attempts+=1,r.requestTimeout(function(){B.findVideoSize(e)},400)):o({videoElement:i,cameraStream:n,videoWidth:B.defaultVideoDimensions.width,videoHeight:B.defaultVideoDimensions.height}))},onStreamingTimeout:function(e){r.isFunction(e)&&e({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - Timed out while trying to start streaming",image:null,cameraStream:{}})},stream:function(e){let n=r.isArray(e.existingVideo)?e.existingVideo[0]:e.existingVideo,o=e.cameraStream,i=e.completedCallback,a=e.streamedCallback,l=e.videoElement;if(r.isFunction(a)&&a(),n){if(r.isString(n))l.src=n,l.innerHTML=`<source src="${n}" type="video/${r.getExtension(n)}" />`;else if(n instanceof Blob){try{l.src=r.URL.createObjectURL(n)}catch{}l.innerHTML=`<source src="${n}" type="${n.type}" />`}}else if(l.mozSrcObject)l.mozSrcObject=o;else if(r.URL)try{l.srcObject=o,l.src=r.URL.createObjectURL(o)}catch{l.srcObject=o}l.play(),r.requestTimeout(function s(){s.count=s.count||0,B.loadedData===!0?(B.findVideoSize({videoElement:l,cameraStream:o,completedCallback:i}),B.loadedData=!1):(s.count+=1,s.count>10?B.findVideoSize({videoElement:l,cameraStream:o,completedCallback:i}):s())},0)},startStreaming:function(e){let n=r.isFunction(e.error)?e.error:r.noop,o=r.isFunction(e.streamed)?e.streamed:r.noop,i=r.isFunction(e.completed)?e.completed:r.noop,a=e.crossOrigin,l=e.existingVideo,s=e.lastCameraStream,c=e.options,h=e.webcamVideoElement,x=r.isElement(l)?l:h||j.createElement("video"),k=void 0;a&&(x.crossOrigin=c.crossOrigin),x.autoplay=!0,x.loop=!0,x.muted=!0,x.addEventListener("loadeddata",function(m){B.loadedData=!0,c.offset&&(x.currentTime=c.offset)}),l?B.stream({videoElement:x,existingVideo:l,completedCallback:i}):s?B.stream({videoElement:x,cameraStream:s,streamedCallback:o,completedCallback:i}):r.getUserMedia({video:!0},function(m){B.stream({videoElement:x,cameraStream:m,streamedCallback:o,completedCallback:i})},n)},startVideoStreaming:function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=n.timeout!==void 0?n.timeout:0,i=n.callback,a=n.webcamVideoElement,l;o>0&&(l=r.requestTimeout(function(){B.onStreamingTimeout(i)},1e4)),B.startStreaming({error:function(){i({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - the user probably denied permission",image:null,cameraStream:{}})},streamed:function(){clearTimeout(l)},completed:function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},h=c.cameraStream,x=c.videoElement,k=c.videoHeight,m=c.videoWidth;e({cameraStream:h,videoElement:x,videoHeight:k,videoWidth:m})},lastCameraStream:n.lastCameraStream,webcamVideoElement:a,crossOrigin:n.crossOrigin,options:n})},stopVideoStreaming:function(e){e=r.isObject(e)?e:{};let n=e,o=n.keepCameraOn,i=n.videoElement,a=n.webcamVideoElement,l=e.cameraStream||{},s=l.getTracks?l.getTracks()||[]:[],c=Boolean(s.length),h=s[0];!o&&c&&r.isFunction(h.stop)&&h.stop(),r.isElement(i)&&!a&&(i.pause(),r.isFunction(r.URL.revokeObjectURL)&&!r.webWorkerError&&i.src&&r.URL.revokeObjectURL(i.src),r.removeElement(i))}};function _e(t){t=r.isObject(t)?t:{},B.stopVideoStreaming(t)}function Le(t,e){let n=t.options||{},o=n.images,i=n.video,a=Number(n.gifWidth),l=Number(n.gifHeight),s=Number(n.numFrames),c=t.cameraStream,h=t.videoElement,x=t.videoWidth,k=t.videoHeight,m=ye.getCropDimensions({videoWidth:x,videoHeight:k,gifHeight:l,gifWidth:a}),v=e;n.crop=m,n.videoElement=h,n.videoWidth=x,n.videoHeight=k,n.cameraStream=c,r.isElement(h)&&(h.width=a+m.width,h.height=l+m.height,n.webcamVideoElement||(r.setCSSAttr(h,{position:"fixed",opacity:"0"}),j.body.appendChild(h)),h.play(),ye.getGIF(n,function(w){(!o||!o.length)&&(!i||!i.length)&&_e(w),v(w)}))}function ct(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=t.callback,n=t.existingVideo,o=t.options,i={getUserMedia:!0,"globalThis.URL":!0},a=q.validate(i),l=0,s,c,h=void 0,x=void 0;if(a.error)return e(a);if(r.isElement(n)&&n.src){if(c=n.src,s=r.getExtension(c),!r.isSupported.videoCodecs[s])return e(q.messages.videoCodecs)}else r.isArray(n)&&r.each(n,function(k,m){if(m instanceof Blob?s=m.type.substr(m.type.lastIndexOf("/")+1,m.length):s=m.substr(m.lastIndexOf(".")+1,m.length),r.isSupported.videoCodecs[s])return n=m,!1});B.startStreaming({completed:function(m){m.options=o||{},Le(m,e)},existingVideo:n,crossOrigin:o.crossOrigin,options:o})}function dt(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=t.callback,n=t.lastCameraStream,o=t.options,i=t.webcamVideoElement;if(!Me())return e(q.validate());if(o.savedRenderingContexts.length){ye.getGIF(o,function(a){e(a)});return}B.startVideoStreaming(function(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};a.options=o||{},Le(a,e)},{lastCameraStream:n,callback:e,webcamVideoElement:i,crossOrigin:o.crossOrigin})}function Be(t,e){if(e=r.isFunction(t)?t:e,t=r.isObject(t)?t:{},!r.isFunction(e))return;let n=r.normalizeOptions(Ce,t)||{},o=t.cameraStream,i=n.images,a=i?i.length:0,l=n.video,s=n.webcamVideoElement;n=r.normalizeOptions(n,{gifWidth:Math.floor(n.gifWidth),gifHeight:Math.floor(n.gifHeight)}),a?at({images:i,imagesLength:a,callback:e,options:n}):l?ct({existingVideo:l,callback:e,options:n}):dt({lastCameraStream:o,callback:e,webcamVideoElement:s,options:n})}function ft(t,e){if(e=r.isFunction(t)?t:e,t=r.isObject(t)?t:{},!r.isFunction(e))return;let n=r.normalizeOptions(Ce,t),o=r.normalizeOptions(n,{interval:.1,numFrames:1,gifWidth:Math.floor(n.gifWidth),gifHeight:Math.floor(n.gifHeight)});Be(o,e)}var mt={utils:Je,error:et,defaultOptions:tt,createGIF:Be,takeSnapShot:ft,stopVideoStreaming:_e,isSupported:it,isWebCamGIFSupported:Me,isExistingVideoGIFSupported:ot,isExistingImagesGIFSupported:nt,VERSION:"0.4.5"},He=mt;var ut={source:"images",width:200,height:200,crossOrigin:"Anonymous",progressCallback:t=>{},completeCallback:()=>{},numWorkers:2,sampleInterval:10,interval:.1,offset:null,numFrames:10,frameDuration:1,filter:"",waterMark:null,waterMarkHeight:null,waterMarkWidth:null,waterMarkXCoordinate:1,waterMarkYCoordinate:1,text:"",showFrameText:!0,fontWeight:"normal",fontSize:"16px",minFontSize:"10px",resizeFont:!1,fontFamily:"sans-serif",fontColor:"#ffffff",textAlign:"center",textBaseline:"bottom",textXCoordinate:null,textYCoordinate:null,webcamVideoElement:null,keepCameraOn:!1,cameraStream:null,saveRenderingContexts:!1,savedRenderingContexts:[]},K=class{static get properties(){return{id:"gif",name:"GIF",extensions:["gif"],mimeTypes:["image/gif"],builder:K,options:ut}}constructor(e){this.options={...e},this.source=e.source,delete e.source,this.files=[],this.gifshot=He}async initialize(e){}async add(e){await this.initialize(),this.files.push(e)}async build(){switch(await this.initialize(),this._cleanOptions(this.options),this.source){case"images":this.options.images=this.files;break;case"video":this.options.video=this.files;break;case"webcam":ze(this.files.length===0);break;default:throw new Error("GIFBuilder: invalid source")}return await this._createGIF()}async _createGIF(){return new Promise((e,n)=>{this.gifshot.createGIF(this.options,o=>{if(o.error){n(o.errorMsg);return}e(o.image)})})}_cleanOptions(e){(e.video||e.images||e.gifWidth||e.gifHeight)&&console.warn("GIFBuilder: ignoring options"),delete e.video,delete e.images,e.gifWidth=e.width,e.gifHeight=e.height,delete e.width,delete e.height}};return Xe(se);})();
|
|
8
8
|
return __exports__;
|
|
9
9
|
});
|
package/dist/gif-builder.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export default class GIFBuilder {
|
|
|
10
10
|
width: number;
|
|
11
11
|
height: number;
|
|
12
12
|
crossOrigin: string;
|
|
13
|
-
progressCallback: (
|
|
13
|
+
progressCallback: (_captureProgress: any) => void;
|
|
14
14
|
completeCallback: () => void;
|
|
15
15
|
numWorkers: number;
|
|
16
16
|
sampleInterval: number;
|
package/dist/gif-builder.js
CHANGED
|
@@ -12,7 +12,7 @@ const GIF_BUILDER_OPTIONS = {
|
|
|
12
12
|
height: 200, // Desired height of the image
|
|
13
13
|
crossOrigin: 'Anonymous', // Options are 'Anonymous', 'use-credentials', or a falsy value to not set a CORS attribute.
|
|
14
14
|
// CALLBACKS
|
|
15
|
-
progressCallback:
|
|
15
|
+
progressCallback: _captureProgress => { }, // Callback that provides the current progress of the current image
|
|
16
16
|
completeCallback: () => { }, // Callback function that is called when the current image is completed
|
|
17
17
|
// QUALITY SETTINGS
|
|
18
18
|
numWorkers: 2, // how many web workers to use to process the animated GIF frames. Default is 2.
|
|
@@ -100,7 +100,7 @@ export default class GIFBuilder {
|
|
|
100
100
|
// PRIVATE
|
|
101
101
|
async _createGIF() {
|
|
102
102
|
return new Promise((resolve, reject) => {
|
|
103
|
-
this.gifshot.createGIF(this.options,
|
|
103
|
+
this.gifshot.createGIF(this.options, result => {
|
|
104
104
|
// callback object properties
|
|
105
105
|
// --------------------------
|
|
106
106
|
// image - Base 64 image
|
package/dist/gif-builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gif-builder.js","sourceRoot":"","sources":["../src/gif-builder.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,2CAA2C;AAC3C,cAAc;AACd,OAAO,EAAC,MAAM,EAAC,8BAA2B;AAC1C,OAAO,OAAO,iCAA8B,CAAC,4CAA4C;AAEzF,mCAAmC;AACnC,MAAM,mBAAmB,GAAG;IAC1B,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,GAAG,EAAE,6BAA6B;IACzC,MAAM,EAAE,GAAG,EAAE,8BAA8B;IAE3C,WAAW,EAAE,WAAW,EAAE,4FAA4F;IAEtH,YAAY;IACZ,gBAAgB,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"gif-builder.js","sourceRoot":"","sources":["../src/gif-builder.ts"],"names":[],"mappings":"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"}
|