diginext-utils 1.0.1 → 1.0.5

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.
Files changed (68) hide show
  1. package/dist/README.md +3 -0
  2. package/dist/babel.config.json +21 -0
  3. package/dist/index.js +148 -0
  4. package/dist/package.json +34 -0
  5. package/dist/src/Camera.js +420 -0
  6. package/dist/src/Checker.js +34 -0
  7. package/dist/src/Color.js +102 -0
  8. package/dist/src/Device.js +67 -0
  9. package/dist/src/EventDispatcher.js +62 -0
  10. package/dist/src/FileUpload.js +73 -0
  11. package/dist/src/FileUtils.js +47 -0
  12. package/dist/src/Slug.js +384 -0
  13. package/dist/src/Timer.js +16 -0
  14. package/dist/src/UserLS.js +127 -0
  15. package/dist/src/Validation.js +46 -0
  16. package/dist/src/array/index.js +377 -0
  17. package/dist/src/backend/file/createDir.js +24 -0
  18. package/dist/src/backend/file/fileMove.js +42 -0
  19. package/dist/src/backend/file/findFilesByExt.js +55 -0
  20. package/dist/src/backend/zip/extractZip.js +55 -0
  21. package/dist/src/console/enableConsole.js +16 -0
  22. package/dist/src/console/index.js +20 -0
  23. package/dist/src/device/browser.js +52 -0
  24. package/dist/src/device/camera.js +238 -0
  25. package/dist/src/device/index.js +304 -0
  26. package/{src → dist/src}/math/index.js +57 -59
  27. package/dist/src/object/index.js +65 -0
  28. package/dist/src/permission/requestCamera.js +55 -0
  29. package/dist/src/permission/requestDeviceOrientationControl.js +36 -0
  30. package/dist/src/string/index.js +531 -0
  31. package/dist/src/string/url.js +128 -0
  32. package/package.json +17 -13
  33. package/.eslintrc.json +0 -21
  34. package/dist/main.js +0 -1611
  35. package/dist/main.js.map +0 -1
  36. package/dist/module.js +0 -1584
  37. package/dist/module.js.map +0 -1
  38. package/index.js +0 -13
  39. package/src/Browser.js +0 -297
  40. package/src/Camera.js +0 -412
  41. package/src/Checker.js +0 -24
  42. package/src/Color.js +0 -81
  43. package/src/Device.js +0 -56
  44. package/src/EventDispatcher.js +0 -58
  45. package/src/FileUpload.js +0 -59
  46. package/src/FileUtils.js +0 -30
  47. package/src/ReactUtils.js +0 -25
  48. package/src/ScrollPos.js +0 -31
  49. package/src/Slug.js +0 -383
  50. package/src/Timer.js +0 -7
  51. package/src/UserLS.js +0 -104
  52. package/src/Validation.js +0 -35
  53. package/src/array/index.js +0 -301
  54. package/src/backend/file/createDir.js +0 -13
  55. package/src/backend/file/fileMove.js +0 -35
  56. package/src/backend/file/findFilesByExt.js +0 -42
  57. package/src/backend/zip/extractZip.js +0 -58
  58. package/src/console/enableConsole.js +0 -6
  59. package/src/console/index.js +0 -10
  60. package/src/device/browser.js +0 -29
  61. package/src/device/camera.js +0 -228
  62. package/src/device/index.js +0 -233
  63. package/src/isMobileOrTablet.js +0 -28
  64. package/src/object/index.js +0 -41
  65. package/src/permission/requestCamera.js +0 -43
  66. package/src/permission/requestDeviceOrientationControl.js +0 -32
  67. package/src/string/index.js +0 -228
  68. package/src/string/url.js +0 -93
package/dist/README.md ADDED
@@ -0,0 +1,3 @@
1
+ ## Support
2
+
3
+ Liên hệ [TOP GROUP Developers](mailto:dev@wearetopgroup.com) nếu cần hỗ trợ.
@@ -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/index.js ADDED
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ Timer: true,
8
+ requestCamera: true,
9
+ requestDeviceOrientationControl: true
10
+ };
11
+ Object.defineProperty(exports, "Timer", {
12
+ enumerable: true,
13
+ get: function get() {
14
+ return _Timer.default;
15
+ }
16
+ });
17
+ Object.defineProperty(exports, "requestCamera", {
18
+ enumerable: true,
19
+ get: function get() {
20
+ return _requestCamera.default;
21
+ }
22
+ });
23
+ Object.defineProperty(exports, "requestDeviceOrientationControl", {
24
+ enumerable: true,
25
+ get: function get() {
26
+ return _requestDeviceOrientationControl.default;
27
+ }
28
+ });
29
+
30
+ var _array = require("./src/array");
31
+
32
+ Object.keys(_array).forEach(function (key) {
33
+ if (key === "default" || key === "__esModule") return;
34
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
35
+ if (key in exports && exports[key] === _array[key]) return;
36
+ Object.defineProperty(exports, key, {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _array[key];
40
+ }
41
+ });
42
+ });
43
+
44
+ var _device = require("./src/device");
45
+
46
+ Object.keys(_device).forEach(function (key) {
47
+ if (key === "default" || key === "__esModule") return;
48
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
49
+ if (key in exports && exports[key] === _device[key]) return;
50
+ Object.defineProperty(exports, key, {
51
+ enumerable: true,
52
+ get: function get() {
53
+ return _device[key];
54
+ }
55
+ });
56
+ });
57
+
58
+ var _browser = require("./src/device/browser");
59
+
60
+ Object.keys(_browser).forEach(function (key) {
61
+ if (key === "default" || key === "__esModule") return;
62
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
63
+ if (key in exports && exports[key] === _browser[key]) return;
64
+ Object.defineProperty(exports, key, {
65
+ enumerable: true,
66
+ get: function get() {
67
+ return _browser[key];
68
+ }
69
+ });
70
+ });
71
+
72
+ var _camera = require("./src/device/camera");
73
+
74
+ Object.keys(_camera).forEach(function (key) {
75
+ if (key === "default" || key === "__esModule") return;
76
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
77
+ if (key in exports && exports[key] === _camera[key]) return;
78
+ Object.defineProperty(exports, key, {
79
+ enumerable: true,
80
+ get: function get() {
81
+ return _camera[key];
82
+ }
83
+ });
84
+ });
85
+
86
+ var _math = require("./src/math");
87
+
88
+ Object.keys(_math).forEach(function (key) {
89
+ if (key === "default" || key === "__esModule") return;
90
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
91
+ if (key in exports && exports[key] === _math[key]) return;
92
+ Object.defineProperty(exports, key, {
93
+ enumerable: true,
94
+ get: function get() {
95
+ return _math[key];
96
+ }
97
+ });
98
+ });
99
+
100
+ var _object = require("./src/object");
101
+
102
+ Object.keys(_object).forEach(function (key) {
103
+ if (key === "default" || key === "__esModule") return;
104
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
105
+ if (key in exports && exports[key] === _object[key]) return;
106
+ Object.defineProperty(exports, key, {
107
+ enumerable: true,
108
+ get: function get() {
109
+ return _object[key];
110
+ }
111
+ });
112
+ });
113
+
114
+ var _string = require("./src/string");
115
+
116
+ Object.keys(_string).forEach(function (key) {
117
+ if (key === "default" || key === "__esModule") return;
118
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
119
+ if (key in exports && exports[key] === _string[key]) return;
120
+ Object.defineProperty(exports, key, {
121
+ enumerable: true,
122
+ get: function get() {
123
+ return _string[key];
124
+ }
125
+ });
126
+ });
127
+
128
+ var _url = require("./src/string/url");
129
+
130
+ Object.keys(_url).forEach(function (key) {
131
+ if (key === "default" || key === "__esModule") return;
132
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
133
+ if (key in exports && exports[key] === _url[key]) return;
134
+ Object.defineProperty(exports, key, {
135
+ enumerable: true,
136
+ get: function get() {
137
+ return _url[key];
138
+ }
139
+ });
140
+ });
141
+
142
+ var _Timer = _interopRequireDefault(require("./src/Timer"));
143
+
144
+ var _requestCamera = _interopRequireDefault(require("./src/permission/requestCamera"));
145
+
146
+ var _requestDeviceOrientationControl = _interopRequireDefault(require("./src/permission/requestDeviceOrientationControl"));
147
+
148
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "diginext-utils",
3
+ "version": "1.0.5",
4
+ "author": {
5
+ "name": "TOP GROUP (a.k.a Digitop)",
6
+ "email": "dev@wearetopgroup.com"
7
+ },
8
+ "main": "dist/index.js",
9
+ "module": "dist/index.js",
10
+ "files": [
11
+ "dist",
12
+ "README.md"
13
+ ],
14
+ "scripts": {
15
+ "publish": "npm publish",
16
+ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
17
+ "build": "rm -rf dist && NODE_ENV=production babel . --out-dir dist --copy-files"
18
+ },
19
+ "dependencies": {
20
+ "@babel/polyfill": "^7.12.1",
21
+ "@babel/preset-react": "^7.18.6",
22
+ "@babel/runtime": "^7.18.9",
23
+ "gsap": "^3.10.4",
24
+ "lodash": "^4.17.21"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "devDependencies": {
30
+ "@babel/cli": "^7.18.10",
31
+ "@babel/core": "^7.18.10",
32
+ "@babel/preset-env": "^7.18.10"
33
+ }
34
+ }
@@ -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;