diginext-utils 1.0.0 → 1.0.3

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.
@@ -0,0 +1,21 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/env",
5
+ {
6
+ "targets": {
7
+ "edge": "17",
8
+ "firefox": "60",
9
+ "chrome": "67",
10
+ "safari": "11.1"
11
+ },
12
+ "useBuiltIns": "usage",
13
+ "corejs": "3.6.5"
14
+ }
15
+ ],
16
+ "@babel/preset-react"
17
+ ],
18
+ "ignore": [
19
+ "node_modules"
20
+ ]
21
+ }
package/dist/Camera.js ADDED
@@ -0,0 +1,420 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isWebcamSupport = void 0;
7
+ exports.requestWebcam = requestWebcam;
8
+ exports.stopWebcam = stopWebcam;
9
+ exports.webcam = exports.video = void 0;
10
+
11
+ require("core-js/modules/es.promise.js");
12
+
13
+ require("core-js/modules/es.json.stringify.js");
14
+
15
+ require("core-js/modules/web.dom-collections.iterator.js");
16
+
17
+ require("core-js/modules/web.url.js");
18
+
19
+ require("core-js/modules/web.url-search-params.js");
20
+
21
+ var _gsap = _interopRequireDefault(require("gsap"));
22
+
23
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
+
25
+ // check for device orientation support
26
+ var DEVICE_ORIENTATION = {
27
+ VERTICAL: "vertical",
28
+ HORIZONTAL: "horizontal"
29
+ };
30
+ var deviceOrientation = DEVICE_ORIENTATION.VERTICAL;
31
+ var video;
32
+ /**
33
+ * @type {AppWebcam}
34
+ */
35
+
36
+ exports.video = video;
37
+ var webcam;
38
+ exports.webcam = webcam;
39
+ var isWebcamSupport = false; // var onSetupComplete;
40
+
41
+ exports.isWebcamSupport = isWebcamSupport;
42
+
43
+ function requestWebcam(_ref) {
44
+ let {
45
+ container,
46
+ onRejected,
47
+ onReady
48
+ } = _ref;
49
+ // options = options || {};
50
+ var video = document.createElement("video");
51
+ video.style.position = "absolute";
52
+ video.style.top = 0;
53
+ video.style.left = 0;
54
+ video.style.width = "100%";
55
+ video.style.height = "100%";
56
+ container.append(video);
57
+
58
+ _gsap.default.set(video, {
59
+ opacity: 1
60
+ }); // $(video).css("z-index", "-2");
61
+ // $(video).css("position", "absolute");
62
+ // $(video).css("top", "0px");
63
+ // $(video).css("left", "0px");
64
+
65
+
66
+ stopWebcam();
67
+ exports.webcam = webcam = new AppWebcam(video);
68
+
69
+ webcam.onReady = function (e) {
70
+ setupApp();
71
+ exports.isWebcamSupport = isWebcamSupport = true;
72
+ if (onReady) onReady(e);
73
+ };
74
+
75
+ webcam.onRejected = function (e) {
76
+ setupApp();
77
+ exports.isWebcamSupport = isWebcamSupport = false; // if (typeof gaTrackingClick != "undefined") gaTrackingClick('request_permission', 'reject_camera');
78
+
79
+ if (onRejected) onRejected(e);
80
+ };
81
+
82
+ return webcam;
83
+ }
84
+
85
+ function setupApp() {
86
+ var _isAllow = false;
87
+
88
+ if (typeof webcam != "undefined") {
89
+ if (webcam.isAllowed) {
90
+ _gsap.default.to(video, {
91
+ duration: 2,
92
+ opacity: 1
93
+ });
94
+
95
+ _isAllow = true;
96
+ }
97
+ }
98
+ }
99
+
100
+ function stopWebcam() {
101
+ if (webcam) webcam.remove();
102
+ }
103
+ /**
104
+ * @param {HTMLVideoElement} videoElement
105
+ */
106
+
107
+
108
+ function AppWebcam(videoElement) {
109
+ // define scope
110
+ var scope = this; // private vars
111
+
112
+ /**
113
+ * @type {MediaDeviceInfo[]}
114
+ */
115
+
116
+ var inputCameras = [];
117
+ /**
118
+ * @type {MediaStreamConstraints}
119
+ */
120
+
121
+ var requestedMediaConstraints = {
122
+ video: {
123
+ // width: 640,
124
+ // height: 480,
125
+ facingMode: {
126
+ exact: "environment"
127
+ } // facingMode: 'environment'
128
+
129
+ },
130
+ audio: false
131
+ };
132
+ /**
133
+ * @type {MediaStream}
134
+ */
135
+
136
+ var stream;
137
+ var isAllowed = false;
138
+ /**
139
+ * @type {HTMLVideoElement}
140
+ */
141
+
142
+ var video;
143
+ var canvas = document.createElement("canvas");
144
+ canvas.setAttribute("id", "AppWebcam" + new Date().getTime()); // var requestWidth = deviceOrientation == DEVICE_ORIENTATION.VERTICAL
145
+ // ? 360
146
+ // : 640;
147
+ // var requestHeight = deviceOrientation == DEVICE_ORIENTATION.VERTICAL
148
+ // ? 640
149
+ // : 360;
150
+
151
+ this.currentCamera = null; // initialise
152
+
153
+ init(); // constructor
154
+
155
+ function init() {
156
+ if (!videoElement) {
157
+ video = document.createElement("video");
158
+ } else {
159
+ video = videoElement;
160
+ } //alert("!");
161
+ // canvasElement = document.getElementById ('canvas');
162
+ // canvasElement.width = window.innerWidth - 50;
163
+ // canvasElement.height = canvasElement.width;
164
+ // canvas = canvasElement.getContext ('2d');
165
+ // loadingMessage = document.getElementById ('loadingMessage');
166
+ // Older browsers might not implement mediaDevices at all, so we set an empty object first
167
+
168
+
169
+ if (navigator.mediaDevices === undefined) {
170
+ navigator.mediaDevices = {};
171
+ } // Some browsers partially implement mediaDevices. We can't just assign an object
172
+ // with getUserMedia as it would overwrite existing properties.
173
+ // Here, we will just add the getUserMedia property if it's missing.
174
+
175
+
176
+ if (navigator.mediaDevices.getUserMedia === undefined) {
177
+ navigator.mediaDevices.getUserMedia = function (constraints) {
178
+ // First get ahold of the legacy getUserMedia, if present
179
+ var getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia; // Some browsers just don't implement it - return a rejected promise with an error
180
+ // to keep a consistent interface
181
+
182
+ if (!getUserMedia) {
183
+ return Promise.reject(new Error("getUserMedia is not implemented in this browser"));
184
+ } // Otherwise, wrap the call to the old navigator.getUserMedia with a Promise
185
+
186
+
187
+ return new Promise(function (resolve, reject) {
188
+ getUserMedia.call(navigator, constraints, resolve, reject);
189
+ });
190
+ };
191
+ } // start requesting media permissions:
192
+
193
+
194
+ console.log("[Camera.js] Requesting:", requestedMediaConstraints);
195
+
196
+ if (navigator.mediaDevices.enumerateDevices === undefined) {
197
+ setTimeout(function () {
198
+ handleError({
199
+ name: "Error",
200
+ message: "NotSupported"
201
+ });
202
+ }, 50);
203
+ } else {
204
+ navigator.mediaDevices.enumerateDevices().then(parseDevices).catch(handleError);
205
+ } // navigator.mediaDevices.getUserMedia(requestedMediaConstraints).then(() => {
206
+ // if (typeof navigator.mediaDevices.enumerateDevices == "undefined") {
207
+ // setTimeout(function () {
208
+ // handleError({ name: 'Error', message: 'NotSupported' });
209
+ // }, 50);
210
+ // } else {
211
+ // navigator.mediaDevices
212
+ // .enumerateDevices()
213
+ // .then(parseDevices)
214
+ // .catch(handleError);
215
+ // }
216
+ // }).catch(handleError);
217
+
218
+ }
219
+ /**
220
+ * @param {MediaDeviceInfo[]} devices
221
+ */
222
+
223
+
224
+ function parseDevices(devices) {
225
+ inputCameras = [];
226
+ var backCameras = [];
227
+ devices.forEach(function (device) {
228
+ if (device.kind == "videoinput" && typeof device.deviceId != "undefined" && device.deviceId != "") {
229
+ inputCameras.push(device);
230
+ }
231
+ }); // //alert (JSON.stringify (devices));
232
+
233
+ console.log("[Camera.js] inputCameras:", inputCameras);
234
+
235
+ if (inputCameras.length > 0) {
236
+ var cams = "";
237
+ var backCamera;
238
+ inputCameras.map((cam, index) => {
239
+ cams += "[".concat(cam.deviceId, "] ").concat(cam.kind, " | ").concat(cam.label, "\n"); // console.log(cam);
240
+
241
+ var label = cam.label.toLowerCase();
242
+
243
+ if (label.indexOf("back") > -1 || label.indexOf("facetime") > -1) {
244
+ backCamera = cam;
245
+ backCameras.push(backCamera);
246
+ }
247
+ });
248
+
249
+ if (backCameras.length > 1) {
250
+ backCamera = backCameras[backCameras.length - 1];
251
+ }
252
+
253
+ console.log("[Camera.js] All input sources:", cams);
254
+ console.log("[Camera.js] This device has ".concat(backCameras.length, " back camera").concat(backCameras.length > 1 ? "s" : "", "."));
255
+ console.log("[Camera.js] backCameras:", JSON.stringify(backCameras));
256
+ scope.currentCamera = backCamera;
257
+
258
+ if (scope.onGotDevices) {
259
+ scope.onGotDevices(devices);
260
+ } // Lấy stream của camera sau
261
+ // (Lấy cái cuối cùng trong danh sách trước, thường sẽ là camera chính trên Android)
262
+
263
+
264
+ getStreamOfCameraId(backCamera.deviceId).then(onStreamReceived).catch(e => {
265
+ if (backCameras.length > 1) {
266
+ // nếu thiết bị có nhiều hơn 1 camera sau -> thử lấy camera khác
267
+ backCamera = backCameras[backCameras.length - 2];
268
+ getStreamOfCameraId(backCamera.deviceId).then(onStreamReceived).catch(handleError);
269
+ } else if (backCameras.length > 2) {
270
+ // nếu thiết bị có nhiều hơn 2 camera sau -> thử lấy camera khác nữa
271
+ backCamera = backCameras[backCameras.length - 3];
272
+ getStreamOfCameraId(backCamera.deviceId).then(onStreamReceived).catch(handleError);
273
+ } else {
274
+ // nếu thiết bị đéo có camera sau...
275
+ handleError(e);
276
+ }
277
+ });
278
+ } else {
279
+ navigator.mediaDevices.getUserMedia(requestedMediaConstraints).then(onStreamReceived).catch(handleError);
280
+ if (scope.onGotDevicesFailed) scope.onGotDevicesFailed();
281
+ }
282
+ }
283
+
284
+ function getStreamOfCameraId(id) {
285
+ var constraints = {
286
+ video: {
287
+ deviceId: {
288
+ exact: id
289
+ }
290
+ },
291
+ audio: false
292
+ };
293
+ return new Promise((resolve, reject) => {
294
+ navigator.mediaDevices.getUserMedia(constraints).then(resolve).catch(reject);
295
+ });
296
+ }
297
+ /**
298
+ * @param {MediaStream} stream
299
+ */
300
+
301
+
302
+ function onStreamReceived(stream) {
303
+ if (inputCameras.length == 0) {
304
+ console.log("[Camera.js] Not found any back cameras, request again?");
305
+ navigator.mediaDevices.enumerateDevices().then(parseDevices).catch(handleError);
306
+ return;
307
+ }
308
+
309
+ isAllowed = true;
310
+ playWebcamVideo(stream);
311
+ }
312
+ /**
313
+ * @param {MediaStream} _stream
314
+ */
315
+
316
+
317
+ function playWebcamVideo(_stream) {
318
+ stream = _stream;
319
+
320
+ if ("srcObject" in video) {
321
+ // //alert ('GOT STREAM VIDEO OBJECT');
322
+ video.srcObject = _stream;
323
+ } else {
324
+ // //alert ('GOT STREAM VIDEO SOURCE URL');
325
+ // Avoid using this in new browsers, as it is going away.
326
+ video.src = window.URL.createObjectURL(_stream);
327
+ } // required to tell iOS safari we don't want fullscreen
328
+
329
+
330
+ video.setAttribute("playsinline", true);
331
+ video.setAttribute("muted", true);
332
+ video.setAttribute("autoplay", true);
333
+ video.muted = true;
334
+ video.autoplay = true;
335
+ video.style.objectFit = "cover";
336
+ video.play(); // auto play
337
+
338
+ video.addEventListener("canplay", function (e) {// //alert ('CAN PLAY');
339
+ });
340
+ video.addEventListener("canplaythrough", function (e) {// //alert ('CAN PLAY THROUGH');
341
+ });
342
+ video.addEventListener("error", e => console.log("[Camera.js] <video> error:", e));
343
+ video.addEventListener("stalled", function (e) {
344
+ // //alert ('CANNOT GET METADATA');
345
+ isAllowed = false;
346
+ console.log("[Camera.js] <video> stalled:", e);
347
+ if (scope.onRejected != null) scope.onRejected(e);
348
+ });
349
+ video.addEventListener("loadedmetadata", function (e) {
350
+ canvas.width = video.videoWidth;
351
+ canvas.height = video.videoHeight;
352
+ canvas.style.width = window.outerWidth + "px";
353
+ canvas.style.height = window.outerHeight + "px";
354
+
355
+ if (scope.currentCamera.label.toLowerCase().indexOf("facetime") > -1) {
356
+ video.style.transform = "scaleX(-1)";
357
+ video.style.webkitTransform = "scaleX(-1)";
358
+ }
359
+
360
+ video.play();
361
+ if (scope.onReady) scope.onReady(video);
362
+ });
363
+ }
364
+
365
+ function handleError(err) {
366
+ console.error(err);
367
+ var errMsg = "[Camera.js] " + err.name + ": " + err.message;
368
+ console.error(errMsg);
369
+ isAllowed = false;
370
+ if (scope.onRejected != null) scope.onRejected(err);
371
+ }
372
+
373
+ function drawVideo() {
374
+ var ctx = canvas.getContext("2d");
375
+ canvas.width = video.videoWidth;
376
+ canvas.height = video.videoHeight;
377
+ ctx.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
378
+ }
379
+
380
+ function captureAsBase64(callback) {
381
+ console.log("[Camera.js] Base64 captured -> ".concat(video.videoWidth, "x").concat(video.videoHeight));
382
+ drawVideo();
383
+ TweenMax.delayedCall(0.2, function () {
384
+ var screenshot = canvas.toDataURL("image/png");
385
+ if (callback) callback(screenshot);
386
+ });
387
+ }
388
+
389
+ function captureAsImageData() {
390
+ drawVideo();
391
+ var ctx = canvas.getContext("2d");
392
+ return ctx.getImageData(0, 0, video.videoWidth, video.videoHeight);
393
+ }
394
+
395
+ function dispose() {}
396
+
397
+ function enable() {}
398
+
399
+ function disable() {}
400
+
401
+ function remove() {
402
+ if (stream) stream.getTracks().forEach(track => track.stop());
403
+ } // exports
404
+
405
+
406
+ this.enable = enable;
407
+ this.disable = disable;
408
+ this.video = video;
409
+ this.inputCameras = inputCameras;
410
+ this.canvas = canvas;
411
+ this.captureAsBase64 = captureAsBase64;
412
+ this.captureAsImageData = captureAsImageData;
413
+ this.onReady = null;
414
+ this.onRejected = null;
415
+ this.onGotDevices = null;
416
+ this.onGotDevicesFailed = null;
417
+ this.init = init;
418
+ this.remove = remove;
419
+ this.stream = stream;
420
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isJSON = void 0;
7
+
8
+ require("core-js/modules/es.json.stringify.js");
9
+
10
+ const isJSON = content => {
11
+ if (typeof content == "object") {
12
+ try {
13
+ content = JSON.stringify(content);
14
+ } catch (err) {
15
+ return false;
16
+ }
17
+ }
18
+
19
+ if (typeof content == "string") {
20
+ try {
21
+ content = JSON.parse(content);
22
+ } catch (err) {
23
+ return false;
24
+ }
25
+ }
26
+
27
+ if (typeof content != "object") {
28
+ return false;
29
+ }
30
+
31
+ return true;
32
+ };
33
+
34
+ exports.isJSON = isJSON;
package/dist/Color.js ADDED
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ require("core-js/modules/es.regexp.exec.js");
9
+
10
+ require("core-js/modules/es.parse-int.js");
11
+
12
+ require("core-js/modules/es.regexp.to-string.js");
13
+
14
+ require("core-js/modules/web.dom-collections.iterator.js");
15
+
16
+ require("core-js/modules/es.string.split.js");
17
+
18
+ require("core-js/modules/es.parse-float.js");
19
+
20
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
+
22
+ class Color {
23
+ // This function (pSBC) will take a HEX or RGB web color.
24
+ // pSBC can shade it darker or lighter, or blend it with a second color, and can also pass it right thru but convert from Hex to RGB (Hex2RGB) or RGB to Hex (RGB2Hex).
25
+ // All without you even knowing what color format you are using.
26
+ // Version 4.0 (pref: https://github.com/PimpTrizkit/PJs/wiki/12.-Shade,-Blend-and-Convert-a-Web-Color-(pSBC.js));
27
+ static hexToRgb(hex) {
28
+ var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
29
+ return result ? {
30
+ r: parseInt(result[1], 16),
31
+ g: parseInt(result[2], 16),
32
+ b: parseInt(result[3], 16)
33
+ } : null;
34
+ }
35
+
36
+ static hexDarken(hex, amount) {
37
+ return Color.pSBC(-amount, hex);
38
+ }
39
+
40
+ static hexLighten(hex, amount) {
41
+ return Color.pSBC(amount, hex);
42
+ }
43
+
44
+ static RGBToHex(rgb) {
45
+ return Color.pSBC(0, rgb, "c", true);
46
+ }
47
+
48
+ }
49
+
50
+ _defineProperty(Color, "random", function () {
51
+ let hex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
52
+ return (hex ? "#" : "") + Math.floor(Math.random() * 16777215).toString(16);
53
+ });
54
+
55
+ _defineProperty(Color, "pSBC", (p, c0, c1, l) => {
56
+ let r,
57
+ g,
58
+ b,
59
+ P,
60
+ f,
61
+ t,
62
+ h,
63
+ i = parseInt,
64
+ m = Math.round,
65
+ a = typeof c1 == "string";
66
+ if (typeof p != "number" || p < -1 || p > 1 || typeof c0 != "string" || c0[0] != "r" && c0[0] != "#" || c1 && !a) return null;
67
+ if (!Color.pSBCr) Color.pSBCr = d => {
68
+ let n = d.length,
69
+ x = {};
70
+
71
+ if (n > 9) {
72
+ [r, g, b, a] = d = d.split(","), n = d.length;
73
+ if (n < 3 || n > 4) return null;
74
+ x.r = i(r[3] == "a" ? r.slice(5) : r.slice(4)), x.g = i(g), x.b = i(b), x.a = a ? parseFloat(a) : -1;
75
+ } else {
76
+ if (n == 8 || n == 6 || n < 4) return null;
77
+ if (n < 6) d = "#" + d[1] + d[1] + d[2] + d[2] + d[3] + d[3] + (n > 4 ? d[4] + d[4] : "");
78
+ d = i(d.slice(1), 16);
79
+ if (n == 9 || n == 5) x.r = d >> 24 & 255, x.g = d >> 16 & 255, x.b = d >> 8 & 255, x.a = m((d & 255) / 0.255) / 1000;else x.r = d >> 16, x.g = d >> 8 & 255, x.b = d & 255, x.a = -1;
80
+ }
81
+
82
+ return x;
83
+ };
84
+ h = c0.length > 9, h = a ? c1.length > 9 ? true : c1 == "c" ? !h : false : h, f = Color.pSBCr(c0), P = p < 0, t = c1 && c1 != "c" ? Color.pSBCr(c1) : P ? {
85
+ r: 0,
86
+ g: 0,
87
+ b: 0,
88
+ a: -1
89
+ } : {
90
+ r: 255,
91
+ g: 255,
92
+ b: 255,
93
+ a: -1
94
+ }, p = P ? p * -1 : p, P = 1 - p;
95
+ if (!f || !t) return null;
96
+ if (l) r = m(P * f.r + p * t.r), g = m(P * f.g + p * t.g), b = m(P * f.b + p * t.b);else r = m((P * f.r ** 2 + p * t.r ** 2) ** 0.5), g = m((P * f.g ** 2 + p * t.g ** 2) ** 0.5), b = m((P * f.b ** 2 + p * t.b ** 2) ** 0.5);
97
+ a = f.a, t = t.a, f = a >= 0 || t >= 0, a = f ? a < 0 ? t : t < 0 ? a : a * P + t * p : 0;
98
+ if (h) return "rgb" + (f ? "a(" : "(") + r + "," + g + "," + b + (f ? "," + m(a * 1000) / 1000 : "") + ")";else return "#" + (4294967296 + r * 16777216 + g * 65536 + b * 256 + (f ? m(a * 255) : 0)).toString(16).slice(1, f ? undefined : -2);
99
+ });
100
+
101
+ var _default = Color;
102
+ exports.default = _default;
package/dist/Device.js ADDED
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ require("core-js/modules/es.promise.js");
9
+
10
+ var _requestedDeviceOrientation = false;
11
+ var _isDeviceOrientationSupport = false;
12
+ var _default = {
13
+ get isPotrait() {
14
+ if (window && !window.orientation) return window.matchMedia("(orientation: portrait)").matches;
15
+ return !(window && window.orientation === 90 || window && window.orientation === -90);
16
+ },
17
+
18
+ get isLandscape() {
19
+ return !this.isPotrait;
20
+ },
21
+
22
+ get isDeviceOrientationSupport() {
23
+ // if (!_requestedDeviceOrientation) {
24
+ // await this.requestDeviceOrientationData()
25
+ // }
26
+ return _isDeviceOrientationSupport;
27
+ },
28
+
29
+ async requestDeviceOrientationData() {
30
+ if (!window) {
31
+ // not supported
32
+ console.warn("`window` not found");
33
+ _isDeviceOrientationSupport = false;
34
+ return;
35
+ } // console.log(window)
36
+
37
+
38
+ if (window.DeviceOrientationEvent !== undefined && typeof window.DeviceOrientationEvent.requestPermission === "function") {
39
+ console.log("This browser can be requested for `DeviceOrientationEvent` permission");
40
+
41
+ try {
42
+ const response = await window.DeviceOrientationEvent.requestPermission(); // console.log(response)
43
+
44
+ if (response == "granted") {
45
+ console.log("`DeviceOrientationEvent` permission -> granted!");
46
+ _isDeviceOrientationSupport = true;
47
+ } else {
48
+ // rejected
49
+ console.log("`DeviceOrientationEvent` permission ->", response);
50
+ _isDeviceOrientationSupport = false;
51
+ }
52
+ } catch (error) {
53
+ // not supported
54
+ console.log(error);
55
+ _isDeviceOrientationSupport = false;
56
+ }
57
+ } else {
58
+ // not supported
59
+ console.warn("`window.DeviceOrientationEvent` not found");
60
+ _isDeviceOrientationSupport = false;
61
+ }
62
+
63
+ return _isDeviceOrientationSupport;
64
+ }
65
+
66
+ };
67
+ exports.default = _default;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ class EventDispatcher {
9
+ constructor() {}
10
+
11
+ addEventListener(type, listener) {
12
+ if (this._listeners === undefined) this._listeners = {};
13
+ const listeners = this._listeners;
14
+
15
+ if (listeners[type] === undefined) {
16
+ listeners[type] = [];
17
+ }
18
+
19
+ if (listeners[type].indexOf(listener) === -1) {
20
+ listeners[type].push(listener);
21
+ }
22
+ }
23
+
24
+ hasEventListener(type, listener) {
25
+ if (this._listeners === undefined) return false;
26
+ const listeners = this._listeners;
27
+ return listeners[type] !== undefined && listeners[type].indexOf(listener) !== -1;
28
+ }
29
+
30
+ removeEventListener(type, listener) {
31
+ if (this._listeners === undefined) return;
32
+ const listeners = this._listeners;
33
+ const listenerArray = listeners[type];
34
+
35
+ if (listenerArray !== undefined) {
36
+ const index = listenerArray.indexOf(listener);
37
+
38
+ if (index !== -1) {
39
+ listenerArray.splice(index, 1);
40
+ }
41
+ }
42
+ }
43
+
44
+ dispatchEvent(event) {
45
+ if (this._listeners === undefined) return;
46
+ const listeners = this._listeners;
47
+ const listenerArray = listeners[event.type];
48
+
49
+ if (listenerArray !== undefined) {
50
+ event.target = this; // Make a copy, in case listeners are removed while iterating.
51
+
52
+ const array = listenerArray.slice(0);
53
+
54
+ for (let i = 0, l = array.length; i < l; i++) {
55
+ array[i].call(this, event);
56
+ }
57
+ }
58
+ }
59
+
60
+ }
61
+
62
+ exports.default = EventDispatcher;