diginext-utils 2.1.18 → 2.1.20
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/Checker.d.ts +8 -8
- package/dist/Checker.js +31 -31
- package/dist/EventDispatcher.d.ts +13 -13
- package/dist/EventDispatcher.js +51 -51
- package/dist/FileUpload.d.ts +12 -12
- package/dist/FileUpload.js +64 -64
- package/dist/Slug.d.ts +9 -9
- package/dist/Slug.js +333 -333
- package/dist/Timer.d.ts +4 -4
- package/dist/Timer.js +8 -8
- package/dist/Validation.d.ts +5 -5
- package/dist/Validation.js +38 -38
- package/dist/array.d.ts +113 -113
- package/dist/array.js +297 -297
- package/dist/color.d.ts +25 -25
- package/dist/color.js +95 -95
- package/dist/console/enableConsole.d.ts +2 -2
- package/dist/console/enableConsole.js +13 -13
- package/dist/console/index.d.ts +11 -11
- package/dist/console/index.js +17 -17
- package/dist/console/log.d.ts +15 -15
- package/dist/console/log.js +44 -44
- package/dist/device/browser.d.ts +5 -5
- package/dist/device/browser.js +37 -37
- package/dist/device/camera.d.ts +7 -7
- package/dist/device/camera.js +171 -171
- package/dist/device/index.d.ts +5 -5
- package/dist/device/index.js +224 -224
- package/dist/device/os.d.ts +11 -11
- package/dist/device/os.js +37 -37
- package/dist/file/createDir.d.ts +5 -5
- package/dist/file/createDir.js +15 -15
- package/dist/file/fileMove.d.ts +4 -4
- package/dist/file/fileMove.js +32 -32
- package/dist/file/findFilesByExt.d.ts +13 -13
- package/dist/file/findFilesByExt.js +49 -49
- package/dist/file/index.d.ts +9 -9
- package/dist/file/index.js +10 -10
- package/dist/gameboi/index.d.ts +10 -10
- package/dist/gameboi/index.js +64 -67
- package/dist/gameboi/index.js.map +1 -1
- package/dist/images/downloadByUrl.d.ts +1 -1
- package/dist/images/downloadByUrl.js +55 -55
- package/dist/images/index.d.ts +2 -2
- package/dist/images/index.js +8 -8
- package/dist/images/loadImage.d.ts +1 -1
- package/dist/images/loadImage.js +17 -17
- package/dist/images/resize.d.ts +2 -2
- package/dist/images/resize.js +37 -37
- package/dist/images/upload.d.ts +10 -10
- package/dist/images/upload.js +26 -26
- package/dist/index.d.ts +37 -37
- package/dist/index.js +62 -62
- package/dist/json.d.ts +8 -8
- package/dist/json.js +31 -31
- package/dist/math/diffDate.d.ts +5 -5
- package/dist/math/diffDate.js +13 -13
- package/dist/math/index.d.ts +30 -30
- package/dist/math/index.js +92 -92
- package/dist/math/positiveNumber.d.ts +2 -2
- package/dist/math/positiveNumber.js +16 -16
- package/dist/name/en.d.ts +5 -5
- package/dist/name/en.js +25 -25
- package/dist/name/index.d.ts +12 -12
- package/dist/name/index.js +12 -12
- package/dist/name/vi.d.ts +5 -5
- package/dist/name/vi.js +27 -27
- package/dist/object.d.ts +59 -59
- package/dist/object.js +79 -79
- package/dist/permission/index.d.ts +8 -8
- package/dist/permission/index.js +6 -6
- package/dist/permission/requestCamera.d.ts +5 -5
- package/dist/permission/requestCamera.js +42 -42
- package/dist/permission/requestDeviceOrientationControl.d.ts +2 -2
- package/dist/permission/requestDeviceOrientationControl.js +38 -38
- package/dist/response/index.d.ts +49 -49
- package/dist/response/index.js +51 -51
- package/dist/string/convertPathnameAndQuery.d.ts +4 -4
- package/dist/string/convertPathnameAndQuery.js +24 -24
- package/dist/string/formatNumber.d.ts +6 -6
- package/dist/string/formatNumber.js +14 -14
- package/dist/string/generatePassword.d.ts +9 -9
- package/dist/string/generatePassword.js +23 -23
- package/dist/string/generateUUID.d.ts +2 -2
- package/dist/string/generateUUID.js +36 -36
- package/dist/string/getTextBetweenCharByIndex.d.ts +1 -1
- package/dist/string/getTextBetweenCharByIndex.js +20 -20
- package/dist/string/index.d.ts +65 -65
- package/dist/string/index.js +161 -161
- package/dist/string/indexesOf.d.ts +1 -1
- package/dist/string/indexesOf.js +14 -14
- package/dist/string/makeDaySlug.d.ts +31 -31
- package/dist/string/makeDaySlug.js +22 -22
- package/dist/string/random.d.ts +18 -18
- package/dist/string/random.js +40 -40
- package/dist/string/trimNull.d.ts +2 -2
- package/dist/string/trimNull.js +20 -20
- package/dist/string/url.d.ts +22 -22
- package/dist/string/url.js +74 -74
- package/esm/Checker.d.ts +8 -8
- package/esm/Checker.js +27 -27
- package/esm/EventDispatcher.d.ts +13 -13
- package/esm/EventDispatcher.js +48 -48
- package/esm/FileUpload.d.ts +12 -12
- package/esm/FileUpload.js +61 -61
- package/esm/Slug.d.ts +9 -9
- package/esm/Slug.js +329 -329
- package/esm/Timer.d.ts +4 -4
- package/esm/Timer.js +6 -6
- package/esm/Validation.d.ts +5 -5
- package/esm/Validation.js +36 -36
- package/esm/array.d.ts +113 -113
- package/esm/array.js +275 -275
- package/esm/color.d.ts +25 -25
- package/esm/color.js +85 -85
- package/esm/console/enableConsole.d.ts +2 -2
- package/esm/console/enableConsole.js +6 -6
- package/esm/console/index.d.ts +11 -11
- package/esm/console/index.js +12 -12
- package/esm/console/log.d.ts +15 -15
- package/esm/console/log.js +32 -32
- package/esm/device/browser.d.ts +5 -5
- package/esm/device/browser.js +29 -29
- package/esm/device/camera.d.ts +7 -7
- package/esm/device/camera.js +167 -167
- package/esm/device/index.d.ts +5 -5
- package/esm/device/index.js +216 -216
- package/esm/device/os.d.ts +11 -11
- package/esm/device/os.js +27 -27
- package/esm/file/createDir.d.ts +5 -5
- package/esm/file/createDir.js +12 -12
- package/esm/file/fileMove.d.ts +4 -4
- package/esm/file/fileMove.js +28 -28
- package/esm/file/findFilesByExt.d.ts +13 -13
- package/esm/file/findFilesByExt.js +45 -45
- package/esm/file/index.d.ts +9 -9
- package/esm/file/index.js +5 -5
- package/esm/gameboi/index.d.ts +10 -10
- package/esm/gameboi/index.js +61 -61
- package/esm/gameboi/index.js.map +1 -1
- package/esm/images/downloadByUrl.d.ts +1 -1
- package/esm/images/downloadByUrl.js +52 -52
- package/esm/images/index.d.ts +2 -2
- package/esm/images/index.js +3 -3
- package/esm/images/loadImage.d.ts +1 -1
- package/esm/images/loadImage.js +14 -14
- package/esm/images/resize.d.ts +2 -2
- package/esm/images/resize.js +30 -30
- package/esm/images/upload.d.ts +10 -10
- package/esm/images/upload.js +19 -19
- package/esm/index.d.ts +37 -37
- package/esm/index.js +37 -37
- package/esm/json.d.ts +8 -8
- package/esm/json.js +27 -27
- package/esm/math/diffDate.d.ts +5 -5
- package/esm/math/diffDate.js +9 -9
- package/esm/math/index.d.ts +30 -30
- package/esm/math/index.js +77 -77
- package/esm/math/positiveNumber.d.ts +2 -2
- package/esm/math/positiveNumber.js +12 -12
- package/esm/name/en.d.ts +5 -5
- package/esm/name/en.js +21 -21
- package/esm/name/index.d.ts +12 -12
- package/esm/name/index.js +5 -5
- package/esm/name/vi.d.ts +5 -5
- package/esm/name/vi.js +23 -23
- package/esm/object.d.ts +59 -59
- package/esm/object.js +69 -69
- package/esm/permission/index.d.ts +8 -8
- package/esm/permission/index.js +4 -4
- package/esm/permission/requestCamera.d.ts +5 -5
- package/esm/permission/requestCamera.js +38 -38
- package/esm/permission/requestDeviceOrientationControl.d.ts +2 -2
- package/esm/permission/requestDeviceOrientationControl.js +34 -34
- package/esm/response/index.d.ts +49 -49
- package/esm/response/index.js +45 -45
- package/esm/string/convertPathnameAndQuery.d.ts +4 -4
- package/esm/string/convertPathnameAndQuery.js +21 -21
- package/esm/string/formatNumber.d.ts +6 -6
- package/esm/string/formatNumber.js +10 -10
- package/esm/string/generatePassword.d.ts +9 -9
- package/esm/string/generatePassword.js +19 -19
- package/esm/string/generateUUID.d.ts +2 -2
- package/esm/string/generateUUID.js +32 -32
- package/esm/string/getTextBetweenCharByIndex.d.ts +1 -1
- package/esm/string/getTextBetweenCharByIndex.js +14 -14
- package/esm/string/index.d.ts +65 -65
- package/esm/string/index.js +150 -150
- package/esm/string/indexesOf.d.ts +1 -1
- package/esm/string/indexesOf.js +11 -11
- package/esm/string/makeDaySlug.d.ts +31 -31
- package/esm/string/makeDaySlug.js +15 -15
- package/esm/string/random.d.ts +18 -18
- package/esm/string/random.js +33 -33
- package/esm/string/trimNull.d.ts +2 -2
- package/esm/string/trimNull.js +13 -13
- package/esm/string/url.d.ts +22 -22
- package/esm/string/url.js +64 -64
- package/package.json +4 -4
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
var path = require("path");
|
|
2
|
-
var fs = require("fs");
|
|
3
|
-
/**
|
|
4
|
-
* This is an alias of "findFileByExt()"
|
|
5
|
-
*/
|
|
6
|
-
export const forEachFileByExt = (base, ext, cb) => {
|
|
7
|
-
var walk = function (directoryName) {
|
|
8
|
-
try {
|
|
9
|
-
fs.readdir(directoryName, function (e, files) {
|
|
10
|
-
if (e) {
|
|
11
|
-
console.log("Error: ", e);
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
files.forEach(function (file) {
|
|
15
|
-
var fullPath = path.join(directoryName, file);
|
|
16
|
-
fs.stat(fullPath, function (e, f) {
|
|
17
|
-
if (e) {
|
|
18
|
-
console.log("Error: ", e);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (f.isDirectory()) {
|
|
22
|
-
walk(fullPath);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
if (fullPath.toLowerCase().indexOf(ext.toLowerCase()) > -1) {
|
|
26
|
-
if (cb)
|
|
27
|
-
cb(fullPath);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
console.log("error", error);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
walk(base);
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* This is an alias of "forEachFileByExt()"
|
|
42
|
-
*/
|
|
43
|
-
export const findFileByExt = forEachFileByExt;
|
|
44
|
-
const fileExt = { findFileByExt, forEachFileByExt };
|
|
45
|
-
export default fileExt;
|
|
1
|
+
var path = require("path");
|
|
2
|
+
var fs = require("fs");
|
|
3
|
+
/**
|
|
4
|
+
* This is an alias of "findFileByExt()"
|
|
5
|
+
*/
|
|
6
|
+
export const forEachFileByExt = (base, ext, cb) => {
|
|
7
|
+
var walk = function (directoryName) {
|
|
8
|
+
try {
|
|
9
|
+
fs.readdir(directoryName, function (e, files) {
|
|
10
|
+
if (e) {
|
|
11
|
+
console.log("Error: ", e);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
files.forEach(function (file) {
|
|
15
|
+
var fullPath = path.join(directoryName, file);
|
|
16
|
+
fs.stat(fullPath, function (e, f) {
|
|
17
|
+
if (e) {
|
|
18
|
+
console.log("Error: ", e);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (f.isDirectory()) {
|
|
22
|
+
walk(fullPath);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
if (fullPath.toLowerCase().indexOf(ext.toLowerCase()) > -1) {
|
|
26
|
+
if (cb)
|
|
27
|
+
cb(fullPath);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.log("error", error);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
walk(base);
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* This is an alias of "forEachFileByExt()"
|
|
42
|
+
*/
|
|
43
|
+
export const findFileByExt = forEachFileByExt;
|
|
44
|
+
const fileExt = { findFileByExt, forEachFileByExt };
|
|
45
|
+
export default fileExt;
|
|
46
46
|
//# sourceMappingURL=findFilesByExt.js.map
|
package/esm/file/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createDir } from "./createDir";
|
|
2
|
-
import { fileMove } from "./fileMove";
|
|
3
|
-
declare const xfile: {
|
|
4
|
-
findFileByExt: (base: string, ext: string, cb: (path: string) => {}) => void;
|
|
5
|
-
forEachFileByExt: (base: string, ext: string, cb: (path: string) => {}) => void;
|
|
6
|
-
createDir: typeof createDir;
|
|
7
|
-
fileMove: typeof fileMove;
|
|
8
|
-
};
|
|
9
|
-
export default xfile;
|
|
1
|
+
import { createDir } from "./createDir";
|
|
2
|
+
import { fileMove } from "./fileMove";
|
|
3
|
+
declare const xfile: {
|
|
4
|
+
findFileByExt: (base: string, ext: string, cb: (path: string) => {}) => void;
|
|
5
|
+
forEachFileByExt: (base: string, ext: string, cb: (path: string) => {}) => void;
|
|
6
|
+
createDir: typeof createDir;
|
|
7
|
+
fileMove: typeof fileMove;
|
|
8
|
+
};
|
|
9
|
+
export default xfile;
|
package/esm/file/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createDir } from "./createDir";
|
|
2
|
-
import { fileMove } from "./fileMove";
|
|
3
|
-
import fileExt from "./findFilesByExt";
|
|
4
|
-
const xfile = { createDir, fileMove, ...fileExt };
|
|
5
|
-
export default xfile;
|
|
1
|
+
import { createDir } from "./createDir";
|
|
2
|
+
import { fileMove } from "./fileMove";
|
|
3
|
+
import fileExt from "./findFilesByExt";
|
|
4
|
+
const xfile = { createDir, fileMove, ...fileExt };
|
|
5
|
+
export default xfile;
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/esm/gameboi/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import EventEmitter from "events";
|
|
3
|
-
export default class GameBoi extends EventEmitter {
|
|
4
|
-
#private;
|
|
5
|
-
constructor();
|
|
6
|
-
onConnect(e: GamepadEvent): void;
|
|
7
|
-
onDisconnect(): void;
|
|
8
|
-
gameLoop(): void;
|
|
9
|
-
dispose(): void;
|
|
10
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from "events";
|
|
3
|
+
export default class GameBoi extends EventEmitter {
|
|
4
|
+
#private;
|
|
5
|
+
constructor();
|
|
6
|
+
onConnect(e: GamepadEvent): void;
|
|
7
|
+
onDisconnect(): void;
|
|
8
|
+
gameLoop(): void;
|
|
9
|
+
dispose(): void;
|
|
10
|
+
}
|
package/esm/gameboi/index.js
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
-
};
|
|
6
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
-
};
|
|
12
|
-
var _GameBoi_instances, _GameBoi___onConnect, _GameBoi___onDisconnect, _GameBoi___start, _GameBoi_time, _GameBoi_awake;
|
|
13
|
-
import EventEmitter from "events";
|
|
14
|
-
export default class GameBoi extends EventEmitter {
|
|
15
|
-
constructor() {
|
|
16
|
-
super();
|
|
17
|
-
_GameBoi_instances.add(this);
|
|
18
|
-
_GameBoi___onConnect.set(this, void 0);
|
|
19
|
-
_GameBoi___onDisconnect.set(this, void 0);
|
|
20
|
-
_GameBoi___start.set(this, void 0);
|
|
21
|
-
_GameBoi_time.set(this, +new Date());
|
|
22
|
-
__classPrivateFieldGet(this, _GameBoi_instances, "m", _GameBoi_awake).call(this);
|
|
23
|
-
}
|
|
24
|
-
onConnect(e) {
|
|
25
|
-
const gp = navigator.getGamepads()[e.gamepad.index];
|
|
26
|
-
console.log(`Gamepad connected at index ${gp.index}: ${gp.id}. It has ${gp.buttons.length} buttons and ${gp.axes.length} axes.`);
|
|
27
|
-
__classPrivateFieldSet(this, _GameBoi_time, +new Date(), "f");
|
|
28
|
-
this.gameLoop();
|
|
29
|
-
}
|
|
30
|
-
onDisconnect() {
|
|
31
|
-
console.log("onDisconnect");
|
|
32
|
-
window.cancelAnimationFrame(__classPrivateFieldGet(this, _GameBoi___start, "f"));
|
|
33
|
-
}
|
|
34
|
-
gameLoop() {
|
|
35
|
-
const gamepads = navigator.getGamepads();
|
|
36
|
-
if (!gamepads) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const deltaTime = (+new Date() - __classPrivateFieldGet(this, _GameBoi_time, "f")) / 1000;
|
|
40
|
-
const item = gamepads[0];
|
|
41
|
-
item.deltaTime = deltaTime;
|
|
42
|
-
this.emit("update", item);
|
|
43
|
-
__classPrivateFieldSet(this, _GameBoi_time, +new Date(), "f");
|
|
44
|
-
__classPrivateFieldSet(this, _GameBoi___start, requestAnimationFrame(this.gameLoop.bind(this)), "f");
|
|
45
|
-
}
|
|
46
|
-
dispose() {
|
|
47
|
-
//
|
|
48
|
-
this.onDisconnect();
|
|
49
|
-
window.removeEventListener("gamepadconnected", __classPrivateFieldGet(this, _GameBoi___onConnect, "f"));
|
|
50
|
-
window.removeEventListener("gamepaddisconnected", __classPrivateFieldGet(this, _GameBoi___onDisconnect, "f"));
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
_GameBoi___onConnect = new WeakMap(), _GameBoi___onDisconnect = new WeakMap(), _GameBoi___start = new WeakMap(), _GameBoi_time = new WeakMap(), _GameBoi_instances = new WeakSet(), _GameBoi_awake = function _GameBoi_awake() {
|
|
54
|
-
if (typeof window == "undefined")
|
|
55
|
-
return;
|
|
56
|
-
const scope = this;
|
|
57
|
-
__classPrivateFieldSet(this, _GameBoi___onConnect, this.onConnect.bind(this), "f");
|
|
58
|
-
window.addEventListener("gamepadconnected", __classPrivateFieldGet(this, _GameBoi___onConnect, "f"));
|
|
59
|
-
__classPrivateFieldSet(this, _GameBoi___onDisconnect, this.onDisconnect.bind(this), "f");
|
|
60
|
-
window.addEventListener("gamepaddisconnected", __classPrivateFieldGet(this, _GameBoi___onDisconnect, "f"));
|
|
61
|
-
};
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
+
};
|
|
12
|
+
var _GameBoi_instances, _GameBoi___onConnect, _GameBoi___onDisconnect, _GameBoi___start, _GameBoi_time, _GameBoi_awake;
|
|
13
|
+
import { EventEmitter } from "events";
|
|
14
|
+
export default class GameBoi extends EventEmitter {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
_GameBoi_instances.add(this);
|
|
18
|
+
_GameBoi___onConnect.set(this, void 0);
|
|
19
|
+
_GameBoi___onDisconnect.set(this, void 0);
|
|
20
|
+
_GameBoi___start.set(this, void 0);
|
|
21
|
+
_GameBoi_time.set(this, +new Date());
|
|
22
|
+
__classPrivateFieldGet(this, _GameBoi_instances, "m", _GameBoi_awake).call(this);
|
|
23
|
+
}
|
|
24
|
+
onConnect(e) {
|
|
25
|
+
const gp = navigator.getGamepads()[e.gamepad.index];
|
|
26
|
+
console.log(`Gamepad connected at index ${gp.index}: ${gp.id}. It has ${gp.buttons.length} buttons and ${gp.axes.length} axes.`);
|
|
27
|
+
__classPrivateFieldSet(this, _GameBoi_time, +new Date(), "f");
|
|
28
|
+
this.gameLoop();
|
|
29
|
+
}
|
|
30
|
+
onDisconnect() {
|
|
31
|
+
console.log("onDisconnect");
|
|
32
|
+
window.cancelAnimationFrame(__classPrivateFieldGet(this, _GameBoi___start, "f"));
|
|
33
|
+
}
|
|
34
|
+
gameLoop() {
|
|
35
|
+
const gamepads = navigator.getGamepads();
|
|
36
|
+
if (!gamepads) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const deltaTime = (+new Date() - __classPrivateFieldGet(this, _GameBoi_time, "f")) / 1000;
|
|
40
|
+
const item = gamepads[0];
|
|
41
|
+
item.deltaTime = deltaTime;
|
|
42
|
+
this.emit("update", item);
|
|
43
|
+
__classPrivateFieldSet(this, _GameBoi_time, +new Date(), "f");
|
|
44
|
+
__classPrivateFieldSet(this, _GameBoi___start, requestAnimationFrame(this.gameLoop.bind(this)), "f");
|
|
45
|
+
}
|
|
46
|
+
dispose() {
|
|
47
|
+
//
|
|
48
|
+
this.onDisconnect();
|
|
49
|
+
window.removeEventListener("gamepadconnected", __classPrivateFieldGet(this, _GameBoi___onConnect, "f"));
|
|
50
|
+
window.removeEventListener("gamepaddisconnected", __classPrivateFieldGet(this, _GameBoi___onDisconnect, "f"));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
_GameBoi___onConnect = new WeakMap(), _GameBoi___onDisconnect = new WeakMap(), _GameBoi___start = new WeakMap(), _GameBoi_time = new WeakMap(), _GameBoi_instances = new WeakSet(), _GameBoi_awake = function _GameBoi_awake() {
|
|
54
|
+
if (typeof window == "undefined")
|
|
55
|
+
return;
|
|
56
|
+
const scope = this;
|
|
57
|
+
__classPrivateFieldSet(this, _GameBoi___onConnect, this.onConnect.bind(this), "f");
|
|
58
|
+
window.addEventListener("gamepadconnected", __classPrivateFieldGet(this, _GameBoi___onConnect, "f"));
|
|
59
|
+
__classPrivateFieldSet(this, _GameBoi___onDisconnect, this.onDisconnect.bind(this), "f");
|
|
60
|
+
window.addEventListener("gamepaddisconnected", __classPrivateFieldGet(this, _GameBoi___onDisconnect, "f"));
|
|
61
|
+
};
|
|
62
62
|
//# sourceMappingURL=index.js.map
|
package/esm/gameboi/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gameboi/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gameboi/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,YAAY;IAChD;QACC,KAAK,EAAE,CAAC;;QAKT,uCAAkB;QAClB,0CAAqB;QACrB,mCAAc;QAEd,wBAAQ,CAAC,IAAI,IAAI,EAAE,EAAC;QAPnB,uBAAA,IAAI,0CAAO,MAAX,IAAI,CAAS,CAAC;IACf,CAAC;IAmBD,SAAS,CAAC,CAAe;QACxB,MAAM,EAAE,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAY,CAAC;QAC/D,OAAO,CAAC,GAAG,CAAC,8BAA8B,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,OAAO,CAAC,MAAM,gBAAgB,EAAE,CAAC,IAAI,CAAC,MAAM,QAAQ,CAAC,CAAC;QAEjI,uBAAA,IAAI,iBAAS,CAAC,IAAI,IAAI,EAAE,MAAA,CAAC;QACzB,IAAI,CAAC,QAAQ,EAAE,CAAC;IACjB,CAAC;IAED,YAAY;QACX,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC3B,MAAc,CAAC,oBAAoB,CAAC,uBAAA,IAAI,wBAAS,CAAC,CAAC;IACrD,CAAC;IAED,QAAQ;QACP,MAAM,QAAQ,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;QACzC,IAAI,CAAC,QAAQ,EAAE;YACd,OAAO;SACP;QAED,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,IAAI,EAAE,GAAG,uBAAA,IAAI,qBAAM,CAAC,GAAG,IAAI,CAAC;QAEpD,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAQ,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAE1B,uBAAA,IAAI,iBAAS,CAAC,IAAI,IAAI,EAAE,MAAA,CAAC;QAEzB,uBAAA,IAAI,oBAAY,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAA,CAAC;IACjE,CAAC;IAED,OAAO;QACN,EAAE;QAEF,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,MAAM,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,uBAAA,IAAI,4BAAa,CAAC,CAAC;QAClE,MAAM,CAAC,mBAAmB,CAAC,qBAAqB,EAAE,uBAAA,IAAI,+BAAgB,CAAC,CAAC;IACzE,CAAC;CACD;;IAhDC,IAAI,OAAO,MAAM,IAAI,WAAW;QAAE,OAAO;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC;IAEnB,uBAAA,IAAI,wBAAgB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAA,CAAC;IAC9C,MAAM,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,uBAAA,IAAI,4BAAa,CAAC,CAAC;IAE/D,uBAAA,IAAI,2BAAmB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,MAAA,CAAC;IACpD,MAAM,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,uBAAA,IAAI,+BAAgB,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function downloadByUrl(url: string, name?: string, title?: string): Promise<unknown>;
|
|
1
|
+
export default function downloadByUrl(url: string, name?: string, title?: string): Promise<unknown>;
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { saveAs } from "file-saver";
|
|
2
|
-
import { makeSlug } from "../Slug";
|
|
3
|
-
import { isIos } from "../device/index";
|
|
4
|
-
// import { getFileExtension } from "../string/url";
|
|
5
|
-
export default async function downloadByUrl(url, name, title) {
|
|
6
|
-
//
|
|
7
|
-
return new Promise(async (resolve, reject) => {
|
|
8
|
-
var _a, _b, _c, _d, _e;
|
|
9
|
-
const blob = await fetch(url).then((r) => r.blob());
|
|
10
|
-
if (!blob)
|
|
11
|
-
reject(false);
|
|
12
|
-
const fileExt = (_a = blob.type) === null || _a === void 0 ? void 0 : _a.substring(((_b = blob.type) === null || _b === void 0 ? void 0 : _b.indexOf("/")) + 1, (_c = blob.type) === null || _c === void 0 ? void 0 : _c.length);
|
|
13
|
-
const fileName = `${name !== null && name !== void 0 ? name : `image-${+new Date()}`}.${fileExt}`;
|
|
14
|
-
if (isIos()) {
|
|
15
|
-
//
|
|
16
|
-
try {
|
|
17
|
-
//
|
|
18
|
-
const file = new File([blob], fileName, { type: blob.type });
|
|
19
|
-
const files = [file];
|
|
20
|
-
if ((navigator === null || navigator === void 0 ? void 0 : navigator.canShare) && (navigator === null || navigator === void 0 ? void 0 : navigator.canShare({ files }))) {
|
|
21
|
-
(_d = navigator === null || navigator === void 0 ? void 0 : navigator.share) === null || _d === void 0 ? void 0 : _d.call(navigator, {
|
|
22
|
-
files,
|
|
23
|
-
title: (_e = title !== null && title !== void 0 ? title : name) !== null && _e !== void 0 ? _e : fileName,
|
|
24
|
-
text: title ? makeSlug(title) : name !== null && name !== void 0 ? name : fileName,
|
|
25
|
-
}).then((e) => {
|
|
26
|
-
// console.log("e---->", e);
|
|
27
|
-
resolve(true);
|
|
28
|
-
}).catch((err) => {
|
|
29
|
-
var _a;
|
|
30
|
-
if (((_a = err.message) === null || _a === void 0 ? void 0 : _a.indexOf("cancellation")) >= 0) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
// console.log("err---->", err);
|
|
34
|
-
saveAs(url, fileName);
|
|
35
|
-
resolve(true);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
saveAs(url, fileName);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
console.error(`downloadByUrl error`, error);
|
|
44
|
-
reject(error);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
saveAs(url, fileName);
|
|
49
|
-
resolve(true);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
1
|
+
import { saveAs } from "file-saver";
|
|
2
|
+
import { makeSlug } from "../Slug";
|
|
3
|
+
import { isIos } from "../device/index";
|
|
4
|
+
// import { getFileExtension } from "../string/url";
|
|
5
|
+
export default async function downloadByUrl(url, name, title) {
|
|
6
|
+
//
|
|
7
|
+
return new Promise(async (resolve, reject) => {
|
|
8
|
+
var _a, _b, _c, _d, _e;
|
|
9
|
+
const blob = await fetch(url).then((r) => r.blob());
|
|
10
|
+
if (!blob)
|
|
11
|
+
reject(false);
|
|
12
|
+
const fileExt = (_a = blob.type) === null || _a === void 0 ? void 0 : _a.substring(((_b = blob.type) === null || _b === void 0 ? void 0 : _b.indexOf("/")) + 1, (_c = blob.type) === null || _c === void 0 ? void 0 : _c.length);
|
|
13
|
+
const fileName = `${name !== null && name !== void 0 ? name : `image-${+new Date()}`}.${fileExt}`;
|
|
14
|
+
if (isIos()) {
|
|
15
|
+
//
|
|
16
|
+
try {
|
|
17
|
+
//
|
|
18
|
+
const file = new File([blob], fileName, { type: blob.type });
|
|
19
|
+
const files = [file];
|
|
20
|
+
if ((navigator === null || navigator === void 0 ? void 0 : navigator.canShare) && (navigator === null || navigator === void 0 ? void 0 : navigator.canShare({ files }))) {
|
|
21
|
+
(_d = navigator === null || navigator === void 0 ? void 0 : navigator.share) === null || _d === void 0 ? void 0 : _d.call(navigator, {
|
|
22
|
+
files,
|
|
23
|
+
title: (_e = title !== null && title !== void 0 ? title : name) !== null && _e !== void 0 ? _e : fileName,
|
|
24
|
+
text: title ? makeSlug(title) : name !== null && name !== void 0 ? name : fileName,
|
|
25
|
+
}).then((e) => {
|
|
26
|
+
// console.log("e---->", e);
|
|
27
|
+
resolve(true);
|
|
28
|
+
}).catch((err) => {
|
|
29
|
+
var _a;
|
|
30
|
+
if (((_a = err.message) === null || _a === void 0 ? void 0 : _a.indexOf("cancellation")) >= 0) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
// console.log("err---->", err);
|
|
34
|
+
saveAs(url, fileName);
|
|
35
|
+
resolve(true);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
saveAs(url, fileName);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.error(`downloadByUrl error`, error);
|
|
44
|
+
reject(error);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
saveAs(url, fileName);
|
|
49
|
+
resolve(true);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
53
|
//# sourceMappingURL=downloadByUrl.js.map
|
package/esm/images/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { upload } from "./upload";
|
|
2
|
-
export { resize } from "./resize";
|
|
1
|
+
export { upload } from "./upload";
|
|
2
|
+
export { resize } from "./resize";
|
package/esm/images/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// export { default as AdminIcon } from "diginext-dashkit/dist/Icon";
|
|
2
|
-
export { upload } from "./upload";
|
|
3
|
-
export { resize } from "./resize";
|
|
1
|
+
// export { default as AdminIcon } from "diginext-dashkit/dist/Icon";
|
|
2
|
+
export { upload } from "./upload";
|
|
3
|
+
export { resize } from "./resize";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function loadImage(list: Array<string>): Promise<unknown[] | undefined>;
|
|
1
|
+
export default function loadImage(list: Array<string>): Promise<unknown[] | undefined>;
|
package/esm/images/loadImage.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export default async function loadImage(list) {
|
|
2
|
-
//
|
|
3
|
-
if (!(list === null || list === void 0 ? void 0 : list.length))
|
|
4
|
-
return;
|
|
5
|
-
return await Promise.all(list.map((url) => {
|
|
6
|
-
return new Promise((resolve, reject) => {
|
|
7
|
-
const img = new Image();
|
|
8
|
-
img.onload = resolve;
|
|
9
|
-
img.onerror = resolve;
|
|
10
|
-
img.src = url;
|
|
11
|
-
return;
|
|
12
|
-
});
|
|
13
|
-
}));
|
|
14
|
-
}
|
|
1
|
+
export default async function loadImage(list) {
|
|
2
|
+
//
|
|
3
|
+
if (!(list === null || list === void 0 ? void 0 : list.length))
|
|
4
|
+
return;
|
|
5
|
+
return await Promise.all(list.map((url) => {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const img = new Image();
|
|
8
|
+
img.onload = resolve;
|
|
9
|
+
img.onerror = resolve;
|
|
10
|
+
img.src = url;
|
|
11
|
+
return;
|
|
12
|
+
});
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
15
|
//# sourceMappingURL=loadImage.js.map
|
package/esm/images/resize.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const resize: (file: File) => Promise<{} | undefined>;
|
|
2
|
-
export default resize;
|
|
1
|
+
export declare const resize: (file: File) => Promise<{} | undefined>;
|
|
2
|
+
export default resize;
|
package/esm/images/resize.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import loadImage from "blueimp-load-image";
|
|
2
|
-
export const resize = async (file) => {
|
|
3
|
-
if (!file) {
|
|
4
|
-
console.error("NO FILE AVAIABLE!");
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
const { type } = file;
|
|
8
|
-
const data = await loadImage(file, {
|
|
9
|
-
//
|
|
10
|
-
meta: false,
|
|
11
|
-
canvas: true,
|
|
12
|
-
maxWidth: 2048,
|
|
13
|
-
maxHeight: 2048,
|
|
14
|
-
});
|
|
15
|
-
const blob = await new Promise(function (resolve) {
|
|
16
|
-
try {
|
|
17
|
-
const canvas = data.image;
|
|
18
|
-
canvas.toBlob(function (blob) {
|
|
19
|
-
resolve(blob);
|
|
20
|
-
}, type);
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
console.error(`diginext-utils/src/images/resize.ts canvas.toBlob error`, error);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
if (blob)
|
|
27
|
-
return blob;
|
|
28
|
-
return data;
|
|
29
|
-
};
|
|
30
|
-
export default resize;
|
|
1
|
+
import loadImage from "blueimp-load-image";
|
|
2
|
+
export const resize = async (file) => {
|
|
3
|
+
if (!file) {
|
|
4
|
+
console.error("NO FILE AVAIABLE!");
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const { type } = file;
|
|
8
|
+
const data = await loadImage(file, {
|
|
9
|
+
//
|
|
10
|
+
meta: false,
|
|
11
|
+
canvas: true,
|
|
12
|
+
maxWidth: 2048,
|
|
13
|
+
maxHeight: 2048,
|
|
14
|
+
});
|
|
15
|
+
const blob = await new Promise(function (resolve) {
|
|
16
|
+
try {
|
|
17
|
+
const canvas = data.image;
|
|
18
|
+
canvas.toBlob(function (blob) {
|
|
19
|
+
resolve(blob);
|
|
20
|
+
}, type);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.error(`diginext-utils/src/images/resize.ts canvas.toBlob error`, error);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
if (blob)
|
|
27
|
+
return blob;
|
|
28
|
+
return data;
|
|
29
|
+
};
|
|
30
|
+
export default resize;
|
|
31
31
|
//# sourceMappingURL=resize.js.map
|
package/esm/images/upload.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare const upload: (file: File) => Promise<{
|
|
2
|
-
status: number;
|
|
3
|
-
error: boolean;
|
|
4
|
-
messages: any[];
|
|
5
|
-
data: null;
|
|
6
|
-
} | {
|
|
7
|
-
blob: any;
|
|
8
|
-
url: string;
|
|
9
|
-
}>;
|
|
10
|
-
export default upload;
|
|
1
|
+
export declare const upload: (file: File) => Promise<{
|
|
2
|
+
status: number;
|
|
3
|
+
error: boolean;
|
|
4
|
+
messages: any[];
|
|
5
|
+
data: null;
|
|
6
|
+
} | {
|
|
7
|
+
blob: any;
|
|
8
|
+
url: string;
|
|
9
|
+
}>;
|
|
10
|
+
export default upload;
|
package/esm/images/upload.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { getFailedResponse } from "./../response/index";
|
|
2
|
-
import resize from "./resize";
|
|
3
|
-
import { isImage } from "./../string/url";
|
|
4
|
-
export const upload = async (file) => {
|
|
5
|
-
const { name } = file;
|
|
6
|
-
if (!isImage(name)) {
|
|
7
|
-
const err = "Please Choose Image!";
|
|
8
|
-
console.error(err);
|
|
9
|
-
return getFailedResponse(err);
|
|
10
|
-
}
|
|
11
|
-
const blob = (await resize(file));
|
|
12
|
-
const url = URL.createObjectURL(blob);
|
|
13
|
-
blob.name = name;
|
|
14
|
-
return {
|
|
15
|
-
blob,
|
|
16
|
-
url,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export default upload;
|
|
1
|
+
import { getFailedResponse } from "./../response/index";
|
|
2
|
+
import resize from "./resize";
|
|
3
|
+
import { isImage } from "./../string/url";
|
|
4
|
+
export const upload = async (file) => {
|
|
5
|
+
const { name } = file;
|
|
6
|
+
if (!isImage(name)) {
|
|
7
|
+
const err = "Please Choose Image!";
|
|
8
|
+
console.error(err);
|
|
9
|
+
return getFailedResponse(err);
|
|
10
|
+
}
|
|
11
|
+
const blob = (await resize(file));
|
|
12
|
+
const url = URL.createObjectURL(blob);
|
|
13
|
+
blob.name = name;
|
|
14
|
+
return {
|
|
15
|
+
blob,
|
|
16
|
+
url,
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export default upload;
|
|
20
20
|
//# sourceMappingURL=upload.js.map
|