diginext-utils 1.2.3 → 1.2.4

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.
@@ -4,16 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = fileMove;
7
-
8
7
  const fs = require("fs");
8
+
9
9
  /**
10
10
  *
11
11
  * @param {string} oldPath
12
12
  * @param {string} newPath
13
13
  * @param {Function} callback
14
14
  */
15
-
16
-
17
15
  function fileMove(oldPath, newPath, callback) {
18
16
  fs.rename(oldPath, newPath, function (err) {
19
17
  if (err) {
@@ -22,13 +20,10 @@ function fileMove(oldPath, newPath, callback) {
22
20
  } else {
23
21
  callback(err);
24
22
  }
25
-
26
23
  return;
27
24
  }
28
-
29
25
  callback();
30
26
  });
31
-
32
27
  function copy() {
33
28
  var readStream = fs.createReadStream(oldPath);
34
29
  var writeStream = fs.createWriteStream(newPath);
@@ -4,18 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var path = require("path");
9
-
10
8
  var fs = require("fs");
9
+
11
10
  /**
12
11
  *
13
12
  * @param {string} base
14
13
  * @param {string} ext
15
14
  * @param {Function} cb
16
15
  */
17
-
18
-
19
16
  const forEachFileByExt = (base, ext, cb) => {
20
17
  var walk = function walk(directoryName) {
21
18
  try {
@@ -24,7 +21,6 @@ const forEachFileByExt = (base, ext, cb) => {
24
21
  console.log("Error: ", e);
25
22
  return;
26
23
  }
27
-
28
24
  files.forEach(function (file) {
29
25
  var fullPath = path.join(directoryName, file);
30
26
  fs.stat(fullPath, function (e, f) {
@@ -32,7 +28,6 @@ const forEachFileByExt = (base, ext, cb) => {
32
28
  console.log("Error: ", e);
33
29
  return;
34
30
  }
35
-
36
31
  if (f.isDirectory()) {
37
32
  walk(fullPath);
38
33
  } else {
@@ -47,9 +42,7 @@ const forEachFileByExt = (base, ext, cb) => {
47
42
  console.log("error", error);
48
43
  }
49
44
  };
50
-
51
45
  walk(base);
52
46
  };
53
-
54
47
  var _default = forEachFileByExt;
55
48
  exports.default = _default;
@@ -3,6 +3,7 @@
3
3
  // import createDir from "../file/createDir";
4
4
  // const fs = require("fs");
5
5
  // const path = require("path");
6
+
6
7
  // /**
7
8
  // *
8
9
  // * @param {string} zipPath
@@ -26,6 +27,7 @@
26
27
  // if (fileName.indexOf("__MACOSX/") >= 0) {
27
28
  // return;
28
29
  // }
30
+
29
31
  // // console.log(fileName)
30
32
  // if (fileObj.dir) {
31
33
  // createDir(fileName);
@@ -35,6 +37,7 @@
35
37
  // fileObj.async("nodebuffer").then((buff) => {
36
38
  // fs.writeFileSync(fileName, buff);
37
39
  // if (forEach) forEach(fileName, true);
40
+
38
41
  // // id++;
39
42
  // // if (id >= _length) if (callback && !isCallcb) {
40
43
  // // console.log("4")
@@ -51,5 +54,6 @@
51
54
  // .then(function () {});
52
55
  // });
53
56
  // };
57
+
54
58
  // export default extractZip;
55
59
  "use strict";
package/dist/color.js CHANGED
@@ -4,47 +4,36 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.random = exports.pSBC = exports.hexToRgb = exports.hexLighten = exports.hexDarken = exports.RGBToHex = void 0;
7
-
8
7
  require("core-js/modules/es.regexp.to-string.js");
9
-
10
8
  require("core-js/modules/es.parse-int.js");
11
-
12
9
  require("core-js/modules/web.dom-collections.iterator.js");
13
-
14
- require("core-js/modules/es.regexp.exec.js");
15
-
16
- require("core-js/modules/es.string.split.js");
17
-
18
10
  require("core-js/modules/es.parse-float.js");
19
-
11
+ require("core-js/modules/es.regexp.exec.js");
20
12
  const random = function random() {
21
13
  let hex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
22
14
  return (hex ? "#" : "") + Math.floor(Math.random() * 16777215).toString(16);
23
- }; // This function (pSBC) will take a HEX or RGB web color.
15
+ };
16
+
17
+ // This function (pSBC) will take a HEX or RGB web color.
24
18
  // 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
19
  // All without you even knowing what color format you are using.
26
20
  // Version 4.0 (pref: https://github.com/PimpTrizkit/PJs/wiki/12.-Shade,-Blend-and-Convert-a-Web-Color-(pSBC.js));
27
-
28
-
29
21
  exports.random = random;
30
-
31
22
  const pSBC = (p, c0, c1, l) => {
32
23
  let r,
33
- g,
34
- b,
35
- P,
36
- f,
37
- t,
38
- h,
39
- i = parseInt,
40
- m = Math.round,
41
- a = typeof c1 == "string";
24
+ g,
25
+ b,
26
+ P,
27
+ f,
28
+ t,
29
+ h,
30
+ i = parseInt,
31
+ m = Math.round,
32
+ a = typeof c1 == "string";
42
33
  if (typeof p != "number" || p < -1 || p > 1 || typeof c0 != "string" || c0[0] != "r" && c0[0] != "#" || c1 && !a) return null;
43
-
44
34
  const pSBCr = d => {
45
35
  let n = d.length,
46
- x = {};
47
-
36
+ x = {};
48
37
  if (n > 9) {
49
38
  [r, g, b, a] = d = d.split(","), n = d.length;
50
39
  if (n < 3 || n > 4) return null;
@@ -55,10 +44,8 @@ const pSBC = (p, c0, c1, l) => {
55
44
  d = i(d.slice(1), 16);
56
45
  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;
57
46
  }
58
-
59
47
  return x;
60
48
  };
61
-
62
49
  h = c0.length > 9, h = a ? c1.length > 9 ? true : c1 == "c" ? !h : false : h, f = pSBCr(c0), P = p < 0, t = c1 && c1 != "c" ? pSBCr(c1) : P ? {
63
50
  r: 0,
64
51
  g: 0,
@@ -75,9 +62,7 @@ const pSBC = (p, c0, c1, l) => {
75
62
  a = f.a, t = t.a, f = a >= 0 || t >= 0, a = f ? a < 0 ? t : t < 0 ? a : a * P + t * p : 0;
76
63
  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);
77
64
  };
78
-
79
65
  exports.pSBC = pSBC;
80
-
81
66
  const hexToRgb = hex => {
82
67
  var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
83
68
  return result ? {
@@ -86,23 +71,16 @@ const hexToRgb = hex => {
86
71
  b: parseInt(result[3], 16)
87
72
  } : null;
88
73
  };
89
-
90
74
  exports.hexToRgb = hexToRgb;
91
-
92
75
  const hexDarken = (hex, amount) => {
93
76
  return pSBC(-amount, hex);
94
77
  };
95
-
96
78
  exports.hexDarken = hexDarken;
97
-
98
79
  const hexLighten = (hex, amount) => {
99
80
  return pSBC(amount, hex);
100
81
  };
101
-
102
82
  exports.hexLighten = hexLighten;
103
-
104
83
  const RGBToHex = rgb => {
105
84
  return pSBC(0, rgb, "c", true);
106
85
  };
107
-
108
86
  exports.RGBToHex = RGBToHex;
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = enableConsole;
7
-
8
7
  var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
9
-
10
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
9
  const _console = (0, _cloneDeep.default)(console);
13
-
14
10
  function enableConsole(params) {
15
11
  return _console;
16
12
  }
@@ -4,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.showCredit = exports.disableConsole = void 0;
7
-
8
7
  const disableConsole = params => {
9
8
  for (var i in console) {
10
9
  console[i] = function () {};
11
10
  }
12
11
  };
13
-
14
12
  exports.disableConsole = disableConsole;
15
-
16
13
  const showCredit = params => {
17
14
  console.log("Developed by Digitop | https://www.wearetopgroup.com/?utm_src=console");
18
15
  };
19
-
20
16
  exports.showCredit = showCredit;
@@ -4,49 +4,35 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ua = exports.isPotrait = exports.isLandscape = exports.isInAppWebview = exports.isFacebookWebview = void 0;
7
-
8
7
  require("core-js/modules/es.regexp.constructor.js");
9
-
10
8
  require("core-js/modules/es.regexp.exec.js");
11
-
12
9
  require("core-js/modules/es.regexp.to-string.js");
13
-
14
10
  require("core-js/modules/es.string.match.js");
15
-
16
11
  const isPotrait = params => {
17
12
  if (typeof window == "undefined") return false;
18
13
  if (!window.orientation) return window.matchMedia("(orientation: portrait)").matches;
19
14
  return !(window.orientation === 90 || window.orientation === -90);
20
15
  };
21
-
22
16
  exports.isPotrait = isPotrait;
23
-
24
17
  const isLandscape = params => {
25
18
  return !isPotrait();
26
19
  };
27
-
28
20
  exports.isLandscape = isLandscape;
29
-
30
21
  const ua = params => {
31
22
  if (typeof navigator == "undefined") return null;
32
23
  if (typeof window == "undefined") return null;
33
24
  return navigator.userAgent || navigator.vendor || window.opera;
34
25
  };
35
-
36
26
  exports.ua = ua;
37
-
38
27
  const isFacebookWebview = params => {
39
28
  var ua = ua();
40
29
  if (ua) return ua.indexOf("FBAN") > -1 || ua.indexOf("FBAV") > -1;
41
30
  };
42
-
43
31
  exports.isFacebookWebview = isFacebookWebview;
44
-
45
32
  const isInAppWebview = params => {
46
33
  const rules = ["WebView", "(iPhone|iPod|iPad)(?!.*Safari/)", "Android.*(wv|.0.0.0)"];
47
34
  const regex = new RegExp("(".concat(rules.join("|"), ")"), "ig");
48
35
  if (ua()) return Boolean(ua().match(regex));
49
36
  return false;
50
37
  };
51
-
52
38
  exports.isInAppWebview = isInAppWebview;
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getWebcam = getWebcam;
7
-
8
7
  require("core-js/modules/es.promise.js");
9
-
10
8
  require("core-js/modules/es.json.stringify.js");
11
-
12
9
  require("core-js/modules/web.dom-collections.iterator.js");
13
-
14
10
  require("core-js/modules/web.url.js");
15
-
16
11
  require("core-js/modules/web.url-search-params.js");
17
-
18
12
  var _requestCamera = _interopRequireDefault(require("../permission/requestCamera"));
19
-
20
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
14
  /**
23
15
  *
24
16
  * @param {{
@@ -47,10 +39,10 @@ function getWebcam(_ref) {
47
39
  container.append(video);
48
40
  let inputCameras = [];
49
41
  let currentCamera;
42
+
50
43
  /**
51
44
  * @type {MediaStreamConstraints}
52
45
  */
53
-
54
46
  const requestedMediaConstraints = {
55
47
  video: {
56
48
  facingMode: {
@@ -59,17 +51,16 @@ function getWebcam(_ref) {
59
51
  },
60
52
  audio
61
53
  };
54
+
62
55
  /**
63
56
  * @type {MediaStream}
64
57
  */
65
-
66
58
  let stream;
67
59
  let isAllowed = false;
68
60
  console.log("[Camera.js] Requesting:", requestedMediaConstraints);
69
61
  const res = await (0, _requestCamera.default)({
70
62
  audio
71
63
  });
72
-
73
64
  if (!res) {
74
65
  setTimeout(function () {
75
66
  handleError({
@@ -77,21 +68,23 @@ function getWebcam(_ref) {
77
68
  message: "NotSupported"
78
69
  });
79
70
  }, 50);
80
- } // start requesting media permissions:
71
+ }
72
+
73
+ // start requesting media permissions:
74
+
81
75
  // console.log("[Camera.js] Requesting:", requestedMediaConstraints);
76
+
82
77
  // if (navigator.mediaDevices.enumerateDevices === undefined) {
83
78
  // setTimeout(function () {
84
79
  // handleError({ name: "Error", message: "NotSupported" });
85
80
  // }, 50);
86
81
  // } else {
87
-
88
-
89
- navigator.mediaDevices.enumerateDevices().then(parseDevices).catch(handleError); // }
82
+ navigator.mediaDevices.enumerateDevices().then(parseDevices).catch(handleError);
83
+ // }
90
84
 
91
85
  /**
92
86
  * @param {MediaDeviceInfo[]} devices
93
87
  */
94
-
95
88
  function parseDevices(devices) {
96
89
  inputCameras = [];
97
90
  let backCameras = [];
@@ -99,39 +92,34 @@ function getWebcam(_ref) {
99
92
  if (device.kind == "videoinput" && typeof device.deviceId != "undefined" && device.deviceId != "") {
100
93
  inputCameras.push(device);
101
94
  }
102
- }); // //alert (JSON.stringify (devices));
103
-
95
+ });
96
+ // //alert (JSON.stringify (devices));
104
97
  console.log("[Camera.js] inputCameras:", inputCameras);
105
-
106
98
  if (inputCameras.length > 0) {
107
99
  let cams = "";
108
100
  let backCamera;
109
101
  inputCameras.map((cam, index) => {
110
- cams += "[".concat(cam.deviceId, "] ").concat(cam.kind, " | ").concat(cam.label, "\n"); // console.log(cam);
111
-
102
+ cams += "[".concat(cam.deviceId, "] ").concat(cam.kind, " | ").concat(cam.label, "\n");
103
+ // console.log(cam);
112
104
  let label = cam.label.toLowerCase();
113
-
114
105
  if (label.indexOf("back") > -1 || label.indexOf("facetime") > -1) {
115
106
  backCamera = cam;
116
107
  backCameras.push(backCamera);
117
108
  }
118
109
  });
119
-
120
110
  if (backCameras.length > 1) {
121
111
  backCamera = backCameras[backCameras.length - 1];
122
112
  }
123
-
124
113
  console.log("[Camera.js] All input sources:", cams);
125
114
  console.log("[Camera.js] This device has ".concat(backCameras.length, " back camera").concat(backCameras.length > 1 ? "s" : "", "."));
126
115
  console.log("[Camera.js] backCameras:", JSON.stringify(backCameras));
127
116
  currentCamera = backCamera;
128
-
129
117
  if (scope.onGotDevices) {
130
118
  scope.onGotDevices(devices);
131
- } // Lấy stream của camera sau
132
- // (Lấy cái cuối cùng trong danh sách trước, thường sẽ là camera chính trên Android)
133
-
119
+ }
134
120
 
121
+ // Lấy stream của camera sau
122
+ // (Lấy cái cuối cùng trong danh sách trước, thường sẽ là camera chính trên Android)
135
123
  getStreamOfCameraId(backCamera.deviceId).then(onStreamReceived).catch(e => {
136
124
  if (backCameras.length > 1) {
137
125
  // nếu thiết bị có nhiều hơn 1 camera sau -> thử lấy camera khác
@@ -147,32 +135,30 @@ function getWebcam(_ref) {
147
135
  }
148
136
  });
149
137
  } else {
150
- navigator.mediaDevices.getUserMedia(requestedMediaConstraints).then(onStreamReceived).catch(handleError); // if (scope.onGotDevicesFailed) scope.onGotDevicesFailed();
138
+ navigator.mediaDevices.getUserMedia(requestedMediaConstraints).then(onStreamReceived).catch(handleError);
139
+
140
+ // if (scope.onGotDevicesFailed) scope.onGotDevicesFailed();
151
141
  }
152
142
  }
143
+
153
144
  /**
154
145
  * @param {MediaStream} stream
155
146
  */
156
-
157
-
158
147
  function onStreamReceived(stream) {
159
148
  if (inputCameras.length == 0) {
160
149
  console.log("[Camera.js] Not found any back cameras, request again?");
161
150
  navigator.mediaDevices.enumerateDevices().then(parseDevices).catch(handleError);
162
151
  return;
163
152
  }
164
-
165
153
  isAllowed = true;
166
154
  playWebcamVideo(stream);
167
155
  }
156
+
168
157
  /**
169
158
  * @param {MediaStream} _stream
170
159
  */
171
-
172
-
173
160
  function playWebcamVideo(_stream) {
174
161
  stream = _stream;
175
-
176
162
  if ("srcObject" in video) {
177
163
  // //alert ('GOT STREAM VIDEO OBJECT');
178
164
  video.srcObject = _stream;
@@ -180,20 +166,23 @@ function getWebcam(_ref) {
180
166
  // //alert ('GOT STREAM VIDEO SOURCE URL');
181
167
  // Avoid using this in new browsers, as it is going away.
182
168
  video.src = window.URL.createObjectURL(_stream);
183
- } // required to tell iOS safari we don't want fullscreen
184
-
169
+ }
185
170
 
171
+ // required to tell iOS safari we don't want fullscreen
186
172
  video.setAttribute("playsinline", true);
187
173
  video.setAttribute("muted", true);
188
174
  video.setAttribute("autoplay", true);
189
175
  video.muted = true;
190
176
  video.autoplay = true;
191
177
  video.style.objectFit = "cover";
192
- video.play(); // auto play
178
+ video.play();
193
179
 
194
- video.addEventListener("canplay", function (e) {// //alert ('CAN PLAY');
180
+ // auto play
181
+ video.addEventListener("canplay", function (e) {
182
+ // //alert ('CAN PLAY');
195
183
  });
196
- video.addEventListener("canplaythrough", function (e) {// //alert ('CAN PLAY THROUGH');
184
+ video.addEventListener("canplaythrough", function (e) {
185
+ // //alert ('CAN PLAY THROUGH');
197
186
  });
198
187
  video.addEventListener("error", e => console.log("[Camera.js] <video> error:", e));
199
188
  video.addEventListener("stalled", function (e) {
@@ -207,12 +196,10 @@ function getWebcam(_ref) {
207
196
  video.style.transform = "scaleX(-1)";
208
197
  video.style.webkitTransform = "scaleX(-1)";
209
198
  }
210
-
211
199
  video.play();
212
200
  resolve(video);
213
201
  });
214
202
  }
215
-
216
203
  function getStreamOfCameraId(id) {
217
204
  const constraints = {
218
205
  video: {
@@ -226,7 +213,6 @@ function getWebcam(_ref) {
226
213
  navigator.mediaDevices.getUserMedia(constraints).then(resolve).catch(reject);
227
214
  });
228
215
  }
229
-
230
216
  function handleError(err) {
231
217
  console.error(err);
232
218
  const errMsg = "[Camera.js] " + err.name + ": " + err.message;