diginext-utils 2.0.40 → 2.1.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/gameboi/index.d.ts +10 -0
- package/dist/gameboi/index.js +68 -0
- package/dist/gameboi/index.js.map +1 -0
- package/dist/string/index.d.ts +1 -1
- package/dist/string/random.d.ts +2 -0
- package/dist/string/random.js +10 -2
- package/dist/string/random.js.map +1 -1
- package/dist/string/url.d.ts +2 -11
- package/dist/string/url.js +6 -32
- package/dist/string/url.js.map +1 -1
- package/esm/gameboi/index.d.ts +10 -0
- package/esm/gameboi/index.js +62 -0
- package/esm/gameboi/index.js.map +1 -0
- package/esm/string/index.d.ts +1 -1
- package/esm/string/random.d.ts +2 -0
- package/esm/string/random.js +8 -1
- package/esm/string/random.js.map +1 -1
- package/esm/string/url.d.ts +2 -11
- package/esm/string/url.js +6 -32
- package/esm/string/url.js.map +1 -1
- package/package.json +1 -1
- package/src/gameboi/index.ts +65 -0
- package/src/string/random.ts +10 -1
- package/src/string/url.ts +1 -27
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
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");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10
|
+
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");
|
|
11
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
var _GameBoi_instances, _GameBoi___onConnect, _GameBoi___onDisconnect, _GameBoi___start, _GameBoi_time, _GameBoi_awake;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const events_1 = __importDefault(require("events"));
|
|
19
|
+
class GameBoi extends events_1.default {
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
_GameBoi_instances.add(this);
|
|
23
|
+
_GameBoi___onConnect.set(this, void 0);
|
|
24
|
+
_GameBoi___onDisconnect.set(this, void 0);
|
|
25
|
+
_GameBoi___start.set(this, void 0);
|
|
26
|
+
_GameBoi_time.set(this, +new Date());
|
|
27
|
+
__classPrivateFieldGet(this, _GameBoi_instances, "m", _GameBoi_awake).call(this);
|
|
28
|
+
}
|
|
29
|
+
onConnect(e) {
|
|
30
|
+
const gp = navigator.getGamepads()[e.gamepad.index];
|
|
31
|
+
console.log(`Gamepad connected at index ${gp.index}: ${gp.id}. It has ${gp.buttons.length} buttons and ${gp.axes.length} axes.`);
|
|
32
|
+
__classPrivateFieldSet(this, _GameBoi_time, +new Date(), "f");
|
|
33
|
+
this.gameLoop();
|
|
34
|
+
}
|
|
35
|
+
onDisconnect() {
|
|
36
|
+
console.log("onDisconnect");
|
|
37
|
+
window.cancelAnimationFrame(__classPrivateFieldGet(this, _GameBoi___start, "f"));
|
|
38
|
+
}
|
|
39
|
+
gameLoop() {
|
|
40
|
+
const gamepads = navigator.getGamepads();
|
|
41
|
+
if (!gamepads) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const deltaTime = (+new Date() - __classPrivateFieldGet(this, _GameBoi_time, "f")) / 1000;
|
|
45
|
+
const item = gamepads[0];
|
|
46
|
+
item.deltaTime = deltaTime;
|
|
47
|
+
this.emit("update", item);
|
|
48
|
+
__classPrivateFieldSet(this, _GameBoi_time, +new Date(), "f");
|
|
49
|
+
__classPrivateFieldSet(this, _GameBoi___start, requestAnimationFrame(this.gameLoop.bind(this)), "f");
|
|
50
|
+
}
|
|
51
|
+
dispose() {
|
|
52
|
+
//
|
|
53
|
+
this.onDisconnect();
|
|
54
|
+
window.removeEventListener("gamepadconnected", __classPrivateFieldGet(this, _GameBoi___onConnect, "f"));
|
|
55
|
+
window.removeEventListener("gamepaddisconnected", __classPrivateFieldGet(this, _GameBoi___onDisconnect, "f"));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.default = GameBoi;
|
|
59
|
+
_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() {
|
|
60
|
+
if (typeof window == "undefined")
|
|
61
|
+
return;
|
|
62
|
+
const scope = this;
|
|
63
|
+
__classPrivateFieldSet(this, _GameBoi___onConnect, this.onConnect.bind(this), "f");
|
|
64
|
+
window.addEventListener("gamepadconnected", __classPrivateFieldGet(this, _GameBoi___onConnect, "f"));
|
|
65
|
+
__classPrivateFieldSet(this, _GameBoi___onDisconnect, this.onDisconnect.bind(this), "f");
|
|
66
|
+
window.addEventListener("gamepaddisconnected", __classPrivateFieldGet(this, _GameBoi___onDisconnect, "f"));
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gameboi/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,oDAAkC;AAElC,MAAqB,OAAQ,SAAQ,gBAAY;IAChD;QACC,KAAK,EAAE,CAAC;;QAKT,uCAAkB;QAClB,0CAAqB;QACrB,mCAA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ACN,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;AA9DD,0BA8DC;;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"}
|
package/dist/string/index.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ declare const xstring: {
|
|
|
57
57
|
addQueryParam: (_url: string, key: string, value: any) => string;
|
|
58
58
|
getUrlParams: (parameter: string, staticURL?: string | undefined, decode?: boolean) => string | false | undefined;
|
|
59
59
|
isLink: (str: string) => boolean;
|
|
60
|
-
getFileNameWithoutExtension: (url: string) => string
|
|
60
|
+
getFileNameWithoutExtension: (url: string) => string;
|
|
61
61
|
getFileNameWithExtension: (url: string) => string;
|
|
62
62
|
getFileExtension: (url: string) => string | undefined;
|
|
63
63
|
isImage: (url: string) => boolean;
|
package/dist/string/random.d.ts
CHANGED
|
@@ -7,8 +7,10 @@ export declare const allCharacter = "\u0111\u0110a\u00E1\u00E0\u1EA3\u00E3\u1EA1
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const randAllCharacterByLength: (length?: number) => string;
|
|
9
9
|
export declare const randomStringByLength: (length: number, str?: string) => string;
|
|
10
|
+
export declare const randomStringAndNumberByLength: (length: number, str?: string) => string;
|
|
10
11
|
declare const random: {
|
|
11
12
|
randAllCharacterByLength: (length?: number) => string;
|
|
12
13
|
randomStringByLength: (length: number, str?: string) => string;
|
|
14
|
+
randomStringAndNumberByLength: (length: number, str?: string) => string;
|
|
13
15
|
};
|
|
14
16
|
export default random;
|
package/dist/string/random.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randomStringByLength = exports.randAllCharacterByLength = exports.allCharacter = exports.punctuation = exports.numeric = exports.textLowCase = void 0;
|
|
3
|
+
exports.randomStringAndNumberByLength = exports.randomStringByLength = exports.randAllCharacterByLength = exports.allCharacter = exports.punctuation = exports.numeric = exports.textLowCase = void 0;
|
|
4
4
|
exports.textLowCase = "abcdefghijklmnopqrstuvwxyz";
|
|
5
5
|
exports.numeric = "0123456789";
|
|
6
6
|
exports.punctuation = "!@#$%^&*()_+~|}{[];?><,./-=";
|
|
@@ -20,6 +20,14 @@ const randomStringByLength = (length, str = exports.textLowCase) => {
|
|
|
20
20
|
return result;
|
|
21
21
|
};
|
|
22
22
|
exports.randomStringByLength = randomStringByLength;
|
|
23
|
-
const
|
|
23
|
+
const randomStringAndNumberByLength = (length, str = `${exports.textLowCase}${exports.numeric}`) => {
|
|
24
|
+
let result = "";
|
|
25
|
+
for (let i = 0; i < length; i++) {
|
|
26
|
+
result += str.charAt(Math.floor(Math.random() * str.length));
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
exports.randomStringAndNumberByLength = randomStringAndNumberByLength;
|
|
31
|
+
const random = { randAllCharacterByLength: exports.randAllCharacterByLength, randomStringByLength: exports.randomStringByLength, randomStringAndNumberByLength: exports.randomStringAndNumberByLength };
|
|
24
32
|
exports.default = random;
|
|
25
33
|
//# sourceMappingURL=random.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.js","sourceRoot":"","sources":["../../src/string/random.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,4BAA4B,CAAC;AAC3C,QAAA,OAAO,GAAG,YAAY,CAAC;AACvB,QAAA,WAAW,GAAG,6BAA6B,CAAC;AAC5C,QAAA,YAAY,GAAG,gPAAgP,CAAC;AAE7Q;;GAEG;AACI,MAAM,wBAAwB,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE;IACtD,OAAO,IAAA,4BAAoB,EAAC,MAAM,EAAE,oBAAY,CAAC,CAAC;AACnD,CAAC,CAAC;AAFW,QAAA,wBAAwB,4BAEnC;AAEK,MAAM,oBAAoB,GAAG,CAAC,MAAc,EAAE,GAAG,GAAG,mBAAW,EAAE,EAAE;IACzE,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAChC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;KAC7D;IACD,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AAPW,QAAA,oBAAoB,wBAO/B;AAEF,MAAM,MAAM,GAAG,EAAE,wBAAwB,EAAxB,gCAAwB,EAAE,oBAAoB,EAApB,4BAAoB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"random.js","sourceRoot":"","sources":["../../src/string/random.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,4BAA4B,CAAC;AAC3C,QAAA,OAAO,GAAG,YAAY,CAAC;AACvB,QAAA,WAAW,GAAG,6BAA6B,CAAC;AAC5C,QAAA,YAAY,GAAG,gPAAgP,CAAC;AAE7Q;;GAEG;AACI,MAAM,wBAAwB,GAAG,CAAC,MAAM,GAA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are const getUrlParams: (parameter: string, staticURL?: string, decode?: boolean) => string | false | undefined;
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @return {boolean}
|
|
6
|
-
*/
|
|
7
3
|
export declare const isLink: (str: string) => boolean;
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* @param {string} url
|
|
11
|
-
* @return {string}
|
|
12
|
-
*/
|
|
13
|
-
export declare const getFileNameWithoutExtension: (url: string) => string | undefined;
|
|
4
|
+
export declare const getFileNameWithoutExtension: (url: string) => string;
|
|
14
5
|
export declare const getFileNameWithExtension: (url: string) => string;
|
|
15
6
|
/**
|
|
16
7
|
*
|
|
@@ -28,7 +19,7 @@ declare const xurl: {
|
|
|
28
19
|
addQueryParam: (_url: string, key: string, value: any) => string;
|
|
29
20
|
getUrlParams: (parameter: string, staticURL?: string, decode?: boolean) => string | false | undefined;
|
|
30
21
|
isLink: (str: string) => boolean;
|
|
31
|
-
getFileNameWithoutExtension: (url: string) => string
|
|
22
|
+
getFileNameWithoutExtension: (url: string) => string;
|
|
32
23
|
getFileNameWithExtension: (url: string) => string;
|
|
33
24
|
getFileExtension: (url: string) => string | undefined;
|
|
34
25
|
isImage: (url: string) => boolean;
|
package/dist/string/url.js
CHANGED
|
@@ -30,48 +30,22 @@ const getUrlParams = (parameter, staticURL, decode = true) => {
|
|
|
30
30
|
return false;
|
|
31
31
|
};
|
|
32
32
|
exports.getUrlParams = getUrlParams;
|
|
33
|
-
/**
|
|
34
|
-
*
|
|
35
|
-
* @return {boolean}
|
|
36
|
-
*/
|
|
37
33
|
const isLink = (str) => {
|
|
38
34
|
return urlRegex.test(str);
|
|
39
35
|
};
|
|
40
36
|
exports.isLink = isLink;
|
|
41
|
-
// /**
|
|
42
|
-
// *
|
|
43
|
-
// * @return {JSX.Element}
|
|
44
|
-
// */
|
|
45
|
-
// export const strToJsxLink = (str, altText) => {
|
|
46
|
-
// return isLink(str) ? <a href={src}>{altText || src}</a> : str;
|
|
47
|
-
// };
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
* @param {string} url
|
|
51
|
-
* @return {string}
|
|
52
|
-
*/
|
|
53
37
|
const getFileNameWithoutExtension = (url) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const m = url.toString().match(/.*\/(.+?)\./);
|
|
57
|
-
if (m && m.length > 1) {
|
|
58
|
-
return m[1];
|
|
59
|
-
}
|
|
60
|
-
if (!(0, object_1.isNull)(url)) {
|
|
61
|
-
return url.split(".").shift();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
38
|
+
var _a, _b, _c;
|
|
39
|
+
url = ((_c = (_b = (_a = (0, exports.getFileNameWithExtension)(url)) === null || _a === void 0 ? void 0 : _a.split(".")) === null || _b === void 0 ? void 0 : _b.splice(0, 1)) === null || _c === void 0 ? void 0 : _c[0]) || "";
|
|
64
40
|
return "";
|
|
65
41
|
};
|
|
66
42
|
exports.getFileNameWithoutExtension = getFileNameWithoutExtension;
|
|
67
43
|
const getFileNameWithExtension = (url) => {
|
|
68
|
-
var _a
|
|
44
|
+
var _a;
|
|
69
45
|
const _url = decodeURIComponent(url);
|
|
70
|
-
const m = _url.toString().match(/.*\/(.*)$/)
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
const b = (_b = a.split("?")) === null || _b === void 0 ? void 0 : _b.shift();
|
|
74
|
-
return b || (m === null || m === void 0 ? void 0 : m[1]) || "";
|
|
46
|
+
const m = `${_url.toString().match(/.*\/(.*)$/)}`;
|
|
47
|
+
if (m && m.length > 1) {
|
|
48
|
+
return ((_a = m[1].split("/").pop()) === null || _a === void 0 ? void 0 : _a.split("?")[0]) || "";
|
|
75
49
|
}
|
|
76
50
|
if (!(0, object_1.isNull)(_url))
|
|
77
51
|
return url;
|
package/dist/string/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/string/url.ts"],"names":[],"mappings":";;;AACA,sCAAmC;AAEnC,IAAI,QAAQ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BAAY,EAAE,MAAM,EAAN,cAAM,EAAE,2BAA2B,EAA3B,mCAA2B,EAAE,wBAAwB,EAAxB,gCAAwB,EAAE,gBAAgB,EAAhB,wBAAgB,EAAE,OAAO,EAAP,eAAO,EAAE,CAAC;AAEvI,kBAAe,IAAI,CAAC"}
|
|
@@ -0,0 +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
|
+
};
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gameboi/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAElC,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,C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gB,CAAC,CAAC;AACtE,CAAC"}
|
package/esm/string/index.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ declare const xstring: {
|
|
|
57
57
|
addQueryParam: (_url: string, key: string, value: any) => string;
|
|
58
58
|
getUrlParams: (parameter: string, staticURL?: string | undefined, decode?: boolean) => string | false | undefined;
|
|
59
59
|
isLink: (str: string) => boolean;
|
|
60
|
-
getFileNameWithoutExtension: (url: string) => string
|
|
60
|
+
getFileNameWithoutExtension: (url: string) => string;
|
|
61
61
|
getFileNameWithExtension: (url: string) => string;
|
|
62
62
|
getFileExtension: (url: string) => string | undefined;
|
|
63
63
|
isImage: (url: string) => boolean;
|
package/esm/string/random.d.ts
CHANGED
|
@@ -7,8 +7,10 @@ export declare const allCharacter = "\u0111\u0110a\u00E1\u00E0\u1EA3\u00E3\u1EA1
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const randAllCharacterByLength: (length?: number) => string;
|
|
9
9
|
export declare const randomStringByLength: (length: number, str?: string) => string;
|
|
10
|
+
export declare const randomStringAndNumberByLength: (length: number, str?: string) => string;
|
|
10
11
|
declare const random: {
|
|
11
12
|
randAllCharacterByLength: (length?: number) => string;
|
|
12
13
|
randomStringByLength: (length: number, str?: string) => string;
|
|
14
|
+
randomStringAndNumberByLength: (length: number, str?: string) => string;
|
|
13
15
|
};
|
|
14
16
|
export default random;
|
package/esm/string/random.js
CHANGED
|
@@ -15,6 +15,13 @@ export const randomStringByLength = (length, str = textLowCase) => {
|
|
|
15
15
|
}
|
|
16
16
|
return result;
|
|
17
17
|
};
|
|
18
|
-
const
|
|
18
|
+
export const randomStringAndNumberByLength = (length, str = `${textLowCase}${numeric}`) => {
|
|
19
|
+
let result = "";
|
|
20
|
+
for (let i = 0; i < length; i++) {
|
|
21
|
+
result += str.charAt(Math.floor(Math.random() * str.length));
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
const random = { randAllCharacterByLength, randomStringByLength, randomStringAndNumberByLength };
|
|
19
26
|
export default random;
|
|
20
27
|
//# sourceMappingURL=random.js.map
|
package/esm/string/random.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.js","sourceRoot":"","sources":["../../src/string/random.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,4BAA4B,CAAC;AACxD,MAAM,CAAC,MAAM,OAAO,GAAG,YAAY,CAAC;AACpC,MAAM,CAAC,MAAM,WAAW,GAAG,6BAA6B,CAAC;AACzD,MAAM,CAAC,MAAM,YAAY,GAAG,gPAAgP,CAAC;AAE7Q;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE;IACtD,OAAO,oBAAoB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAc,EAAE,GAAG,GAAG,WAAW,EAAE,EAAE;IACzE,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAChC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;KAC7D;IACD,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"random.js","sourceRoot":"","sources":["../../src/string/random.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,4BAA4B,CAAC;AACxD,MAAM,CAAC,MAAM,OAAO,GAAG,YAAY,CAAC;AACpC,MAAM,CAAC,MAAM,WAAW,GAAG,6BAA6B,CAAC;AACzD,MAAM,CAAC,MAAM,YAAY,GAAG,gPAAgP,CAAC;AAE7Q;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE;IACtD,OAAO,oBAAoB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAc,EAAE,GAAG,GAAG,WAAW,EAAE,EAAE;IACzE,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAChC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;KAC7D;IACD,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,MAAc,EAAE,GAAG,GAAG,GAAG,WAAW,GAAG,OAAO,EAAE,EAAE,EAAE;IACjG,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAChC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;KAC7D;IACD,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,6BAA6B,EAAE,CAAC;AAEjG,eAAe,MAAM,CAAC"}
|
package/esm/string/url.d.ts
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
export declare const addQueryParam: (_url: string, key: string, value: any) => string;
|
|
2
2
|
export declare const getUrlParams: (parameter: string, staticURL?: string, decode?: boolean) => string | false | undefined;
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @return {boolean}
|
|
6
|
-
*/
|
|
7
3
|
export declare const isLink: (str: string) => boolean;
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* @param {string} url
|
|
11
|
-
* @return {string}
|
|
12
|
-
*/
|
|
13
|
-
export declare const getFileNameWithoutExtension: (url: string) => string | undefined;
|
|
4
|
+
export declare const getFileNameWithoutExtension: (url: string) => string;
|
|
14
5
|
export declare const getFileNameWithExtension: (url: string) => string;
|
|
15
6
|
/**
|
|
16
7
|
*
|
|
@@ -28,7 +19,7 @@ declare const xurl: {
|
|
|
28
19
|
addQueryParam: (_url: string, key: string, value: any) => string;
|
|
29
20
|
getUrlParams: (parameter: string, staticURL?: string, decode?: boolean) => string | false | undefined;
|
|
30
21
|
isLink: (str: string) => boolean;
|
|
31
|
-
getFileNameWithoutExtension: (url: string) => string
|
|
22
|
+
getFileNameWithoutExtension: (url: string) => string;
|
|
32
23
|
getFileNameWithExtension: (url: string) => string;
|
|
33
24
|
getFileExtension: (url: string) => string | undefined;
|
|
34
25
|
isImage: (url: string) => boolean;
|
package/esm/string/url.js
CHANGED
|
@@ -25,46 +25,20 @@ export const getUrlParams = (parameter, staticURL, decode = true) => {
|
|
|
25
25
|
if (!returnBool)
|
|
26
26
|
return false;
|
|
27
27
|
};
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @return {boolean}
|
|
31
|
-
*/
|
|
32
28
|
export const isLink = (str) => {
|
|
33
29
|
return urlRegex.test(str);
|
|
34
30
|
};
|
|
35
|
-
// /**
|
|
36
|
-
// *
|
|
37
|
-
// * @return {JSX.Element}
|
|
38
|
-
// */
|
|
39
|
-
// export const strToJsxLink = (str, altText) => {
|
|
40
|
-
// return isLink(str) ? <a href={src}>{altText || src}</a> : str;
|
|
41
|
-
// };
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
* @param {string} url
|
|
45
|
-
* @return {string}
|
|
46
|
-
*/
|
|
47
31
|
export const getFileNameWithoutExtension = (url) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const m = url.toString().match(/.*\/(.+?)\./);
|
|
51
|
-
if (m && m.length > 1) {
|
|
52
|
-
return m[1];
|
|
53
|
-
}
|
|
54
|
-
if (!isNull(url)) {
|
|
55
|
-
return url.split(".").shift();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
32
|
+
var _a, _b, _c;
|
|
33
|
+
url = ((_c = (_b = (_a = getFileNameWithExtension(url)) === null || _a === void 0 ? void 0 : _a.split(".")) === null || _b === void 0 ? void 0 : _b.splice(0, 1)) === null || _c === void 0 ? void 0 : _c[0]) || "";
|
|
58
34
|
return "";
|
|
59
35
|
};
|
|
60
36
|
export const getFileNameWithExtension = (url) => {
|
|
61
|
-
var _a
|
|
37
|
+
var _a;
|
|
62
38
|
const _url = decodeURIComponent(url);
|
|
63
|
-
const m = _url.toString().match(/.*\/(.*)$/)
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
const b = (_b = a.split("?")) === null || _b === void 0 ? void 0 : _b.shift();
|
|
67
|
-
return b || (m === null || m === void 0 ? void 0 : m[1]) || "";
|
|
39
|
+
const m = `${_url.toString().match(/.*\/(.*)$/)}`;
|
|
40
|
+
if (m && m.length > 1) {
|
|
41
|
+
return ((_a = m[1].split("/").pop()) === null || _a === void 0 ? void 0 : _a.split("?")[0]) || "";
|
|
68
42
|
}
|
|
69
43
|
if (!isNull(_url))
|
|
70
44
|
return url;
|
package/esm/string/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/string/url.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,IAAI,QAAQ,GAAG,sBAAsB,CAAC;AAEtC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,GAAW,EAAE,KAAU,EAAE,EAAE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+
super();
|
|
6
|
+
|
|
7
|
+
this.#awake();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
#__onConnect: any;
|
|
11
|
+
#__onDisconnect: any;
|
|
12
|
+
#__start: any;
|
|
13
|
+
|
|
14
|
+
#time = +new Date();
|
|
15
|
+
|
|
16
|
+
#awake() {
|
|
17
|
+
if (typeof window == "undefined") return;
|
|
18
|
+
const scope = this;
|
|
19
|
+
|
|
20
|
+
this.#__onConnect = this.onConnect.bind(this);
|
|
21
|
+
window.addEventListener("gamepadconnected", this.#__onConnect);
|
|
22
|
+
|
|
23
|
+
this.#__onDisconnect = this.onDisconnect.bind(this);
|
|
24
|
+
window.addEventListener("gamepaddisconnected", this.#__onDisconnect);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
onConnect(e: GamepadEvent) {
|
|
28
|
+
const gp = navigator.getGamepads()[e.gamepad.index] as Gamepad;
|
|
29
|
+
console.log(`Gamepad connected at index ${gp.index}: ${gp.id}. It has ${gp.buttons.length} buttons and ${gp.axes.length} axes.`);
|
|
30
|
+
|
|
31
|
+
this.#time = +new Date();
|
|
32
|
+
this.gameLoop();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
onDisconnect() {
|
|
36
|
+
console.log("onDisconnect");
|
|
37
|
+
(window as any).cancelAnimationFrame(this.#__start);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
gameLoop() {
|
|
41
|
+
const gamepads = navigator.getGamepads();
|
|
42
|
+
if (!gamepads) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const deltaTime = (+new Date() - this.#time) / 1000;
|
|
47
|
+
|
|
48
|
+
const item = gamepads[0] as any;
|
|
49
|
+
item.deltaTime = deltaTime;
|
|
50
|
+
|
|
51
|
+
this.emit("update", item);
|
|
52
|
+
|
|
53
|
+
this.#time = +new Date();
|
|
54
|
+
|
|
55
|
+
this.#__start = requestAnimationFrame(this.gameLoop.bind(this));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
dispose() {
|
|
59
|
+
//
|
|
60
|
+
|
|
61
|
+
this.onDisconnect();
|
|
62
|
+
window.removeEventListener("gamepadconnected", this.#__onConnect);
|
|
63
|
+
window.removeEventListener("gamepaddisconnected", this.#__onDisconnect);
|
|
64
|
+
}
|
|
65
|
+
}
|
package/src/string/random.ts
CHANGED
|
@@ -19,6 +19,15 @@ export const randomStringByLength = (length: number, str = textLowCase) => {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
export const randomStringAndNumberByLength = (length: number, str = `${textLowCase}${numeric}`) => {
|
|
23
|
+
let result = "";
|
|
24
|
+
|
|
25
|
+
for (let i = 0; i < length; i++) {
|
|
26
|
+
result += str.charAt(Math.floor(Math.random() * str.length));
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const random = { randAllCharacterByLength, randomStringByLength, randomStringAndNumberByLength };
|
|
23
32
|
|
|
24
33
|
export default random;
|
package/src/string/url.ts
CHANGED
|
@@ -33,39 +33,13 @@ export const getUrlParams = (parameter: string, staticURL?: string, decode: bool
|
|
|
33
33
|
if (!returnBool) return false;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
* @return {boolean}
|
|
39
|
-
*/
|
|
40
36
|
export const isLink = (str: string) => {
|
|
41
37
|
return urlRegex.test(str);
|
|
42
38
|
};
|
|
43
39
|
|
|
44
|
-
// /**
|
|
45
|
-
// *
|
|
46
|
-
// * @return {JSX.Element}
|
|
47
|
-
// */
|
|
48
|
-
// export const strToJsxLink = (str, altText) => {
|
|
49
|
-
// return isLink(str) ? <a href={src}>{altText || src}</a> : str;
|
|
50
|
-
// };
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
*
|
|
54
|
-
* @param {string} url
|
|
55
|
-
* @return {string}
|
|
56
|
-
*/
|
|
57
40
|
export const getFileNameWithoutExtension = (url: string) => {
|
|
58
|
-
url =
|
|
59
|
-
if (url) {
|
|
60
|
-
const m = url.toString().match(/.*\/(.+?)\./);
|
|
61
|
-
if (m && m.length > 1) {
|
|
62
|
-
return m[1];
|
|
63
|
-
}
|
|
41
|
+
url = getFileNameWithExtension(url)?.split(".")?.splice(0, 1)?.[0] || "";
|
|
64
42
|
|
|
65
|
-
if (!isNull(url)) {
|
|
66
|
-
return url.split(".").shift();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
43
|
return "";
|
|
70
44
|
};
|
|
71
45
|
|