diginext-utils 1.1.12 → 1.2.0
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/{array/index.js → array.js} +1 -1
- package/dist/{color/index.js → color.js} +4 -2
- package/dist/{device/index.js → device.js} +0 -0
- package/dist/{math/index.js → math.js} +0 -0
- package/dist/{object/index.js → object.js} +0 -0
- package/dist/string/name/vi.js +4 -4
- package/dist/string/url.js +2 -0
- package/dist/{string/index.js → string.js} +3 -1
- package/package.json +1 -1
- package/dist/Camera.js +0 -420
- package/dist/Device.js +0 -67
- package/dist/FileUtils.js +0 -43
- package/dist/UserLS.js +0 -127
|
@@ -11,10 +11,12 @@ require("core-js/modules/es.parse-int.js");
|
|
|
11
11
|
|
|
12
12
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
13
13
|
|
|
14
|
-
require("core-js/modules/es.parse-float.js");
|
|
15
|
-
|
|
16
14
|
require("core-js/modules/es.regexp.exec.js");
|
|
17
15
|
|
|
16
|
+
require("core-js/modules/es.string.split.js");
|
|
17
|
+
|
|
18
|
+
require("core-js/modules/es.parse-float.js");
|
|
19
|
+
|
|
18
20
|
const random = function random() {
|
|
19
21
|
let hex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
20
22
|
return (hex ? "#" : "") + Math.floor(Math.random() * 16777215).toString(16);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/string/name/vi.js
CHANGED
|
@@ -9,7 +9,7 @@ require("core-js/modules/es.promise.js");
|
|
|
9
9
|
|
|
10
10
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _array = require("../../array");
|
|
13
13
|
|
|
14
14
|
//prettier-ignore
|
|
15
15
|
const FIRST = ['Ân', 'Úc', 'Uất', 'Đàm', 'Đào', 'Đinh', 'Đoàn', 'An', 'Bành', 'Bạch', 'Cao', 'Châu', 'Chử', 'Chu', 'Chung', 'Dữu', 'Diệp', 'Doãn', 'Giang', 'Hà', 'Hàn', 'Kiều', 'Kim', 'Lâm', 'Lương', 'Lưu', 'Lạc', 'Lục', 'La', 'Liễu', 'Mã', 'Mạc', 'Mạch', 'Mai', 'Ngư', 'Nghiêm', 'Phí', 'Phó', 'Phùng', 'Quách', 'Quang', 'Quyền', 'Tô', 'Tôn', 'Tạ', 'Tống', 'Thái', 'Sái', 'Thân', 'Thạch', 'Thảo', 'Thủy', 'Thi', 'Tiêu', 'Trương', 'Trầm', 'Trịnh', 'Trang', 'Triệu', 'Văn', 'Vĩnh', 'Vương', 'Vưu', 'Nguyễn', 'Trần', 'Lê', 'Phạm', 'Huỳnh', 'Hoàng', 'Phan', 'Vũ', 'Võ', 'Đặng', 'Bùi', 'Đỗ', 'Hồ', 'Ngô', 'Dương', 'Lý', 'Nguyễn', 'Trần', 'Lê', 'Phạm', 'Huỳnh', 'Hoàng', 'Phan', 'Vũ', 'Võ', 'Đặng', 'Bùi', 'Đỗ', 'Hồ', 'Ngô', 'Dương', 'Lý', 'Nguyễn', 'Nguyễn', 'Nguyễn', 'Nguyễn', 'Nguyễn', 'Nguyễn', 'Nguyễn', 'Nguyễn', 'Nguyễn', 'Nguyễn', 'Nguyễn', 'Nguyễn', 'Nguyễn', 'Nguyễn', 'Nguyễn', 'Nguyễn', 'Nguyễn', 'Trần', 'Lê', 'Phạm', 'Huỳnh', 'Hoàng', 'Phan', 'Vũ', 'Võ', 'Đặng', 'Bùi', 'Đỗ', 'Hồ', 'Ngô', 'Dương', 'Lý', 'Nguyễn', 'Trần', 'Lê', 'Phạm', 'Huỳnh', 'Hoàng', 'Phan', 'Vũ', 'Võ', 'Đặng', 'Bùi', 'Đỗ', 'Hồ', 'Ngô', 'Dương', 'Lý']; //prettier-ignore
|
|
@@ -25,12 +25,12 @@ const generateName = async function generateName() {
|
|
|
25
25
|
//
|
|
26
26
|
if (useGender) {
|
|
27
27
|
if (male) {
|
|
28
|
-
return (0,
|
|
28
|
+
return (0, _array.randomElement)(MALE);
|
|
29
29
|
} else {
|
|
30
|
-
return (0,
|
|
30
|
+
return (0, _array.randomElement)(FEMALE);
|
|
31
31
|
}
|
|
32
32
|
} else {
|
|
33
|
-
return (0,
|
|
33
|
+
return (0, _array.randomElement)([...MALE, ...FEMALE]);
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
|
package/dist/string/url.js
CHANGED
|
@@ -7,6 +7,8 @@ exports.isLink = exports.isImage = exports.getUrlParams = exports.getFileNameWit
|
|
|
7
7
|
|
|
8
8
|
require("core-js/modules/es.regexp.exec.js");
|
|
9
9
|
|
|
10
|
+
require("core-js/modules/es.string.split.js");
|
|
11
|
+
|
|
10
12
|
require("core-js/modules/es.string.search.js");
|
|
11
13
|
|
|
12
14
|
require("core-js/modules/es.regexp.test.js");
|
|
@@ -15,7 +15,9 @@ require("core-js/modules/es.string.replace.js");
|
|
|
15
15
|
|
|
16
16
|
require("core-js/modules/es.string.trim.js");
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
require("core-js/modules/es.string.split.js");
|
|
19
|
+
|
|
20
|
+
var _object = require("./object");
|
|
19
21
|
|
|
20
22
|
// import { log } from "../../helper/log";
|
|
21
23
|
// import { startCase, toLower } from "lodash";
|
package/package.json
CHANGED
package/dist/Camera.js
DELETED
|
@@ -1,420 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/Device.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
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;
|
package/dist/FileUtils.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
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.array.includes.js");
|
|
9
|
-
|
|
10
|
-
require("core-js/modules/es.string.includes.js");
|
|
11
|
-
|
|
12
|
-
require("core-js/modules/es.regexp.to-string.js");
|
|
13
|
-
|
|
14
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
class FileUtils {
|
|
19
|
-
static getExtensionVideo(file) {
|
|
20
|
-
var extension = "";
|
|
21
|
-
if (file.type.indexOf("quicktime") >= 0) extension = ".mov";else if (file.type.indexOf("avi") >= 0) extension = ".avi";else if (file.type.indexOf("mpeg") >= 0) extension = ".mpg";else if (file.type.indexOf("wmv") >= 0) extension = ".wmv";else if (file.type.indexOf("ogg") >= 0) extension = ".ogg";else if (file.type.indexOf("webm") >= 0) extension = ".webm";else if (file.type.indexOf("mpeg-4") >= 0) extension = ".mp4";else if (file.type.indexOf("mp4") >= 0) extension = ".mp4";
|
|
22
|
-
return extension;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static getFileExtension(file) {
|
|
26
|
-
const fn = file.name || file.originalFilename;
|
|
27
|
-
|
|
28
|
-
let _f = fn.includes(".") ? fn.split(".") : [""];
|
|
29
|
-
|
|
30
|
-
return _f[_f.length - 1];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static getFileNameByUrl(urlStr) {
|
|
34
|
-
let _u = urlStr.toString();
|
|
35
|
-
|
|
36
|
-
let _a = _u.includes("/") ? _u.split("/") : [];
|
|
37
|
-
|
|
38
|
-
return _lodash.default.last(_a);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
exports.default = FileUtils;
|
package/dist/UserLS.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
require("core-js/modules/es.json.stringify.js");
|
|
11
|
-
|
|
12
|
-
require("core-js/modules/es.promise.js");
|
|
13
|
-
|
|
14
|
-
var _Api = _interopRequireWildcard(require("./Api"));
|
|
15
|
-
|
|
16
|
-
var _axios = _interopRequireDefault(require("axios"));
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
|
|
22
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
24
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
-
|
|
26
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
-
|
|
28
|
-
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; }
|
|
29
|
-
|
|
30
|
-
// upload hình -> login FB -> share
|
|
31
|
-
class UserLS {
|
|
32
|
-
static saveInfo(info) {
|
|
33
|
-
UserLS.info = _objectSpread({}, info);
|
|
34
|
-
window.localStorage.setItem("user_info", JSON.stringify(UserLS.info));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static getInfo() {
|
|
38
|
-
UserLS.info = JSON.parse(window.localStorage.getItem("user_info"));
|
|
39
|
-
console.log("getInfo", UserLS.info);
|
|
40
|
-
return UserLS.info;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
static saveAuthToken(code) {
|
|
44
|
-
let info = _objectSpread(_objectSpread({}, UserLS.info), {}, {
|
|
45
|
-
auth_token: code
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
window.localStorage.setItem("user_info", JSON.stringify(info));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
static getAuthToken() {
|
|
52
|
-
let info = UserLS.getInfo();
|
|
53
|
-
let authToken = info.auth_token || -1;
|
|
54
|
-
return authToken;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
static deleteAuthToken() {
|
|
58
|
-
let info = _objectSpread(_objectSpread({}, UserLS.info), {}, {
|
|
59
|
-
auth_token: undefined
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
window.localStorage.setItem("user_info", JSON.stringify(info));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
static clearStorage() {
|
|
66
|
-
console.log("clearStorage");
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
static async handleUploadImage(image) {
|
|
70
|
-
let _response = {
|
|
71
|
-
status: 0,
|
|
72
|
-
message: "",
|
|
73
|
-
data: {}
|
|
74
|
-
};
|
|
75
|
-
const param = {
|
|
76
|
-
image_user: image
|
|
77
|
-
};
|
|
78
|
-
const response = await _Api.default.post({
|
|
79
|
-
url: _Api.PROXY_URL + _Api.routes.upload,
|
|
80
|
-
isConvertToString: false,
|
|
81
|
-
param: param
|
|
82
|
-
});
|
|
83
|
-
console.log("response", response);
|
|
84
|
-
|
|
85
|
-
if (response.statusCode === 200) {
|
|
86
|
-
const responseData = response.data || {};
|
|
87
|
-
_response.data = responseData.post_id || -1;
|
|
88
|
-
_response.auth_token = responseData.auth_token || -1;
|
|
89
|
-
_response.message = response.responseMessage;
|
|
90
|
-
_response.status = 1;
|
|
91
|
-
UserLS.saveAuthToken(_response.auth_token);
|
|
92
|
-
} else {
|
|
93
|
-
_response.message = response.responseMessage;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return _response;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
_defineProperty(UserLS, "info", null);
|
|
102
|
-
|
|
103
|
-
_defineProperty(UserLS, "loginToGetAuthToken", async accessToken => {
|
|
104
|
-
// get jwt token by call api login/facebook/accesstoken....
|
|
105
|
-
// Axios.get(PROXY_URL + routes.loginNoQuery + "?access_token=" + accessToken, {
|
|
106
|
-
// }).then((res) => {
|
|
107
|
-
// console.log("axios login response", res);
|
|
108
|
-
// }
|
|
109
|
-
// )
|
|
110
|
-
const response = await _Api.default.get({
|
|
111
|
-
url: _Api.PROXY_URL + _Api.routes.loginNoQuery,
|
|
112
|
-
param: {
|
|
113
|
-
access_token: accessToken
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
console.log("loginToGet authToken", response);
|
|
117
|
-
|
|
118
|
-
if (response.statusCode === 200) {
|
|
119
|
-
const responseData = response.data || {};
|
|
120
|
-
const authToken = responseData.auth_token || -1; // save to local storage
|
|
121
|
-
|
|
122
|
-
UserLS.saveAuthToken(authToken);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
var _default = UserLS;
|
|
127
|
-
exports.default = _default;
|