diginext-utils 2.1.22 → 2.1.23
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/README.md +162 -162
- package/dist/Checker.mjs +29 -0
- package/dist/EventDispatcher.mjs +54 -0
- package/dist/FileUpload.mjs +62 -0
- package/dist/Slug.mjs +9 -0
- package/dist/Timer-7b0c4e7c.d.ts +11 -0
- package/dist/Timer.mjs +7 -0
- package/dist/Validation.mjs +35 -0
- package/dist/array-c38eff4c.d.ts +158 -0
- package/dist/array.mjs +49 -0
- package/dist/browser-8d042ffe.d.ts +22 -0
- package/dist/camera-1a859d72.d.ts +15 -0
- package/dist/chunk-24DHBJAC.mjs +35 -0
- package/dist/chunk-32BJ2V3H.mjs +195 -0
- package/dist/chunk-32PJ3FML.mjs +57 -0
- package/dist/chunk-3OYOTSDB.mjs +339 -0
- package/dist/chunk-4CWVMQ53.mjs +167 -0
- package/dist/chunk-4VQ25N7H.mjs +43 -0
- package/dist/chunk-6OZHYD5H.mjs +91 -0
- package/dist/chunk-76AY2CWV.mjs +22 -0
- package/dist/chunk-7MK72U4O.mjs +19 -0
- package/dist/chunk-7SOQVGCL.mjs +12 -0
- package/dist/chunk-7XKT3AQX.mjs +17 -0
- package/dist/chunk-AT5ZUBQL.mjs +151 -0
- package/dist/chunk-CKILLYAP.mjs +16 -0
- package/dist/chunk-D5JDP7JB.mjs +56 -0
- package/dist/chunk-DEOVENCJ.mjs +15 -0
- package/dist/chunk-FILFH56Y.mjs +21 -0
- package/dist/chunk-FTXB3IBS.mjs +20 -0
- package/dist/chunk-GJMNV2OC.mjs +35 -0
- package/dist/chunk-GNJDIUYM.mjs +40 -0
- package/dist/chunk-HN4EHJ2H.mjs +39 -0
- package/dist/chunk-HTAKHCLC.mjs +43 -0
- package/dist/chunk-JAP2EUEW.mjs +86 -0
- package/dist/chunk-JFASFX5Y.mjs +16 -0
- package/dist/chunk-JIMOWRMS.mjs +118 -0
- package/dist/chunk-K4KENOE6.mjs +20 -0
- package/dist/chunk-LGBBKRBU.mjs +40 -0
- package/dist/chunk-PMJLVOEM.mjs +25 -0
- package/dist/chunk-PSVXSTS4.mjs +51 -0
- package/dist/chunk-SNYWQI35.mjs +41 -0
- package/dist/chunk-TV4YHUBU.mjs +23 -0
- package/dist/chunk-UHUY6K7N.mjs +24 -0
- package/dist/chunk-UZ7BFUDR.mjs +258 -0
- package/dist/chunk-YLZC36RI.mjs +32 -0
- package/dist/chunk-ZNIXVHZT.mjs +24 -0
- package/dist/color.mjs +85 -0
- package/dist/console/enableConsole.mjs +9 -0
- package/dist/console/index.mjs +14 -0
- package/dist/console/log.mjs +19 -0
- package/dist/createDir-220e0081.d.ts +13 -0
- package/dist/device/browser.mjs +15 -0
- package/dist/device/camera.mjs +8 -0
- package/dist/device/index.mjs +15 -0
- package/dist/device/os.mjs +33 -0
- package/dist/enableConsole-ddc24282.d.ts +11 -0
- package/dist/file/createDir.mjs +7 -0
- package/dist/file/fileMove.mjs +7 -0
- package/dist/file/findFilesByExt.mjs +11 -0
- package/dist/file/index.mjs +17 -0
- package/dist/fileMove-3a09e429.d.ts +13 -0
- package/dist/findFilesByExt-753e91d7.d.ts +24 -0
- package/dist/gameboi/index.d.ts +2 -0
- package/dist/gameboi/index.js +5 -0
- package/dist/gameboi/index.js.map +1 -1
- package/dist/gameboi/index.mjs +65 -0
- package/dist/images/downloadByUrl.mjs +53 -0
- package/dist/images/index.mjs +14 -0
- package/dist/images/loadImage.js +1 -1
- package/dist/images/loadImage.js.map +1 -1
- package/dist/images/loadImage.mjs +21 -0
- package/dist/images/resize.mjs +9 -0
- package/dist/images/upload.mjs +13 -0
- package/dist/index-1e114d55.d.ts +26 -0
- package/dist/index-1f738e52.d.ts +22 -0
- package/dist/index-22309f0c.d.ts +23 -0
- package/dist/index-3eeb7834.d.ts +90 -0
- package/dist/index-6ae3c86b.d.ts +63 -0
- package/dist/index.mjs +87 -0
- package/dist/json.mjs +29 -0
- package/dist/math/diffDate.mjs +9 -0
- package/dist/math/index.mjs +34 -0
- package/dist/math/positiveNumber.mjs +10 -0
- package/dist/name/en.mjs +9 -0
- package/dist/name/index.mjs +20 -0
- package/dist/name/vi.mjs +14 -0
- package/dist/object-43aaaf92.d.ts +80 -0
- package/dist/object.mjs +21 -0
- package/dist/permission/index.mjs +15 -0
- package/dist/permission/requestCamera.mjs +9 -0
- package/dist/permission/requestDeviceOrientationControl.mjs +10 -0
- package/dist/requestCamera-32b7dfc7.d.ts +14 -0
- package/dist/requestDeviceOrientationControl-b6458660.d.ts +11 -0
- package/dist/response/index.mjs +16 -0
- package/dist/string/convertPathnameAndQuery.mjs +28 -0
- package/dist/string/formatNumber.mjs +10 -0
- package/dist/string/generatePassword.mjs +10 -0
- package/dist/string/generateUUID.mjs +9 -0
- package/dist/string/getTextBetweenCharByIndex.mjs +22 -0
- package/dist/string/index.mjs +31 -0
- package/dist/string/indexesOf.mjs +7 -0
- package/dist/string/makeDaySlug.mjs +9 -0
- package/dist/string/random.mjs +23 -0
- package/dist/string/trimNull.mjs +9 -0
- package/dist/string/url.mjs +21 -0
- package/dist/url-0da0be84.d.ts +43 -0
- package/esm/gameboi/index.d.ts +2 -0
- package/esm/gameboi/index.js +5 -0
- package/esm/gameboi/index.js.map +1 -1
- package/esm/images/loadImage.js +1 -1
- package/esm/images/loadImage.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import {
|
|
2
|
+
randInt
|
|
3
|
+
} from "./chunk-JIMOWRMS.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__export
|
|
6
|
+
} from "./chunk-4VQ25N7H.mjs";
|
|
7
|
+
|
|
8
|
+
// src/array.ts
|
|
9
|
+
var array_exports = {};
|
|
10
|
+
__export(array_exports, {
|
|
11
|
+
allMatchInArray: () => allMatchInArray,
|
|
12
|
+
averageArray: () => averageArray,
|
|
13
|
+
default: () => array_default,
|
|
14
|
+
firstElement: () => firstElement,
|
|
15
|
+
getHalfRandom: () => getHalfRandom,
|
|
16
|
+
getRandom: () => getRandom,
|
|
17
|
+
lastElement: () => lastElement,
|
|
18
|
+
maxArray: () => maxArray,
|
|
19
|
+
mergeAndMakeUniqueElement: () => mergeAndMakeUniqueElement,
|
|
20
|
+
minArray: () => minArray,
|
|
21
|
+
moveArray: () => moveArray,
|
|
22
|
+
moveIndex: () => moveIndex,
|
|
23
|
+
randomElement: () => randomElement,
|
|
24
|
+
randomIndex: () => randomIndex,
|
|
25
|
+
removeItem: () => removeItem,
|
|
26
|
+
removeItemByKey: () => removeItemByKey,
|
|
27
|
+
shuffle: () => shuffle,
|
|
28
|
+
sortElementByNumber: () => sortElementByNumber,
|
|
29
|
+
sortElementByString: () => sortElementByString,
|
|
30
|
+
sumArray: () => sumArray
|
|
31
|
+
});
|
|
32
|
+
var sumArray = (array, key) => {
|
|
33
|
+
if (!array) {
|
|
34
|
+
console.warn("ARRAY NOT EXITED !");
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
if (key)
|
|
38
|
+
return array.reduce((c, v) => c + v[key], 0);
|
|
39
|
+
else
|
|
40
|
+
return array.reduce((c, v) => c + v, 0);
|
|
41
|
+
};
|
|
42
|
+
var averageArray = (array, key) => {
|
|
43
|
+
if (!array) {
|
|
44
|
+
console.warn("ARRAY NOT EXITED !");
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
return sumArray(array, key) / array.length || 0;
|
|
48
|
+
};
|
|
49
|
+
var minArray = (array, key) => {
|
|
50
|
+
if (!array) {
|
|
51
|
+
console.warn("ARRAY NOT EXITED !");
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
if (array.length > 0) {
|
|
55
|
+
if (key)
|
|
56
|
+
return array.reduce((c, v) => c < v[key] ? c : v[key]);
|
|
57
|
+
else
|
|
58
|
+
return array.reduce((c, v) => c < v ? c : v);
|
|
59
|
+
}
|
|
60
|
+
return 0;
|
|
61
|
+
};
|
|
62
|
+
var maxArray = (array, key) => {
|
|
63
|
+
if (!array) {
|
|
64
|
+
console.warn("ARRAY NOT EXITED !");
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
if (array.length > 0) {
|
|
68
|
+
if (key)
|
|
69
|
+
return array.reduce((c, v) => c > v[key] ? c : v[key]);
|
|
70
|
+
else
|
|
71
|
+
return array.reduce((c, v) => c > v ? c : v);
|
|
72
|
+
}
|
|
73
|
+
return 0;
|
|
74
|
+
};
|
|
75
|
+
var sortElementByString = (array, key) => {
|
|
76
|
+
if (!Array.isArray(array))
|
|
77
|
+
return [];
|
|
78
|
+
if (key)
|
|
79
|
+
return array.sort((x, y) => {
|
|
80
|
+
var a = x[key].toUpperCase(), b = y[key].toUpperCase();
|
|
81
|
+
return a == b ? 0 : a > b ? 1 : -1;
|
|
82
|
+
});
|
|
83
|
+
console.log("NO KEY");
|
|
84
|
+
};
|
|
85
|
+
var sortElementByNumber = (array, key) => {
|
|
86
|
+
if (!Array.isArray(array))
|
|
87
|
+
return [];
|
|
88
|
+
if (key)
|
|
89
|
+
return array.sort((a, b) => {
|
|
90
|
+
return a[key] - b[key];
|
|
91
|
+
});
|
|
92
|
+
console.log("NO KEY");
|
|
93
|
+
};
|
|
94
|
+
var firstElement = (array) => {
|
|
95
|
+
if (array) {
|
|
96
|
+
if (array.length || array.length > 0)
|
|
97
|
+
return array[0];
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
};
|
|
101
|
+
var lastElement = (array) => {
|
|
102
|
+
if (array) {
|
|
103
|
+
if (array.length || array.length > 0)
|
|
104
|
+
return array[array.length - 1];
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
};
|
|
108
|
+
var randomIndex = (array) => {
|
|
109
|
+
if (array)
|
|
110
|
+
return randInt(0, array.length - 1);
|
|
111
|
+
return -1;
|
|
112
|
+
};
|
|
113
|
+
var randomElement = (array) => {
|
|
114
|
+
if (array)
|
|
115
|
+
return array[randomIndex(array)];
|
|
116
|
+
return null;
|
|
117
|
+
};
|
|
118
|
+
var mergeAndMakeUniqueElement = (list1, list2, key) => {
|
|
119
|
+
if (!list1 || !list2)
|
|
120
|
+
return;
|
|
121
|
+
if (key) {
|
|
122
|
+
return list1.concat(list2).filter((item, index, self) => {
|
|
123
|
+
return self.findIndex((x) => x[key] == item[key]) === index;
|
|
124
|
+
});
|
|
125
|
+
} else {
|
|
126
|
+
return list1.concat(list2).filter((x, index, self) => {
|
|
127
|
+
return self.indexOf(x) === index;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
var allMatchInArray = (target, toMatch) => {
|
|
132
|
+
if (!target || !toMatch)
|
|
133
|
+
return false;
|
|
134
|
+
const found = toMatch.every((item) => {
|
|
135
|
+
return target.includes(item);
|
|
136
|
+
});
|
|
137
|
+
return found;
|
|
138
|
+
};
|
|
139
|
+
var removeItem = (item, array) => {
|
|
140
|
+
const index = array.indexOf(item);
|
|
141
|
+
if (index == -1) {
|
|
142
|
+
console.warn("[ArrayExtra.removeItem] Item not found.");
|
|
143
|
+
return array;
|
|
144
|
+
}
|
|
145
|
+
array.splice(index, 1);
|
|
146
|
+
return array;
|
|
147
|
+
};
|
|
148
|
+
var removeItemByKey = (key, value, array) => {
|
|
149
|
+
const foundIndex = array.findIndex((item) => {
|
|
150
|
+
return item[key] == value;
|
|
151
|
+
});
|
|
152
|
+
if (foundIndex < 0) {
|
|
153
|
+
console.warn("[ArrayExtra.removeItemByKey] Item not found.", key, value);
|
|
154
|
+
return array;
|
|
155
|
+
}
|
|
156
|
+
array.splice(foundIndex, 1);
|
|
157
|
+
return array;
|
|
158
|
+
};
|
|
159
|
+
var getRandom = (array, n) => {
|
|
160
|
+
n = n || array.length;
|
|
161
|
+
var result = new Array(n), len = array.length, taken = new Array(len);
|
|
162
|
+
if (n > len)
|
|
163
|
+
throw new RangeError("getRandom: more elements taken than available");
|
|
164
|
+
while (n--) {
|
|
165
|
+
var x = Math.floor(Math.random() * len);
|
|
166
|
+
result[n] = array[x in taken ? taken[x] : x];
|
|
167
|
+
taken[x] = --len in taken ? taken[len] : len;
|
|
168
|
+
}
|
|
169
|
+
return result;
|
|
170
|
+
};
|
|
171
|
+
var getHalfRandom = (array, n) => {
|
|
172
|
+
var n = Math.ceil(array.length / 2);
|
|
173
|
+
return getRandom(array, n);
|
|
174
|
+
};
|
|
175
|
+
var shuffle = (array) => {
|
|
176
|
+
var i = array.length, j, temp;
|
|
177
|
+
if (array.length < 1)
|
|
178
|
+
return array;
|
|
179
|
+
while (--i) {
|
|
180
|
+
j = Math.floor(Math.random() * (i + 1));
|
|
181
|
+
temp = array[i];
|
|
182
|
+
array[i] = array[j];
|
|
183
|
+
array[j] = temp;
|
|
184
|
+
}
|
|
185
|
+
return array;
|
|
186
|
+
};
|
|
187
|
+
var moveIndex = (array, oldIndex, newIndex) => {
|
|
188
|
+
if (newIndex >= array.length) {
|
|
189
|
+
var k = newIndex - array.length + 1;
|
|
190
|
+
while (k--) {
|
|
191
|
+
array.push(void 0);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
array.splice(newIndex, 0, array.splice(oldIndex, 1)[0]);
|
|
195
|
+
return array;
|
|
196
|
+
};
|
|
197
|
+
var moveArray = (array, oldIndex, newIndex) => {
|
|
198
|
+
while (oldIndex < 0) {
|
|
199
|
+
oldIndex += array.length;
|
|
200
|
+
}
|
|
201
|
+
while (newIndex < 0) {
|
|
202
|
+
newIndex += array.length;
|
|
203
|
+
}
|
|
204
|
+
if (newIndex >= array.length) {
|
|
205
|
+
var k = newIndex - array.length;
|
|
206
|
+
while (k-- + 1) {
|
|
207
|
+
array.push(999);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
array.splice(newIndex, 0, array.splice(oldIndex, 1)[0]);
|
|
211
|
+
return array;
|
|
212
|
+
};
|
|
213
|
+
var xarray = {
|
|
214
|
+
sumArray,
|
|
215
|
+
averageArray,
|
|
216
|
+
minArray,
|
|
217
|
+
maxArray,
|
|
218
|
+
sortElementByString,
|
|
219
|
+
sortElementByNumber,
|
|
220
|
+
firstElement,
|
|
221
|
+
lastElement,
|
|
222
|
+
randomIndex,
|
|
223
|
+
randomElement,
|
|
224
|
+
mergeAndMakeUniqueElement,
|
|
225
|
+
allMatchInArray,
|
|
226
|
+
removeItem,
|
|
227
|
+
removeItemByKey,
|
|
228
|
+
getRandom,
|
|
229
|
+
getHalfRandom,
|
|
230
|
+
shuffle,
|
|
231
|
+
moveIndex,
|
|
232
|
+
moveArray
|
|
233
|
+
};
|
|
234
|
+
var array_default = xarray;
|
|
235
|
+
|
|
236
|
+
export {
|
|
237
|
+
sumArray,
|
|
238
|
+
averageArray,
|
|
239
|
+
minArray,
|
|
240
|
+
maxArray,
|
|
241
|
+
sortElementByString,
|
|
242
|
+
sortElementByNumber,
|
|
243
|
+
firstElement,
|
|
244
|
+
lastElement,
|
|
245
|
+
randomIndex,
|
|
246
|
+
randomElement,
|
|
247
|
+
mergeAndMakeUniqueElement,
|
|
248
|
+
allMatchInArray,
|
|
249
|
+
removeItem,
|
|
250
|
+
removeItemByKey,
|
|
251
|
+
getRandom,
|
|
252
|
+
getHalfRandom,
|
|
253
|
+
shuffle,
|
|
254
|
+
moveIndex,
|
|
255
|
+
moveArray,
|
|
256
|
+
array_default,
|
|
257
|
+
array_exports
|
|
258
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getFailedResponse
|
|
3
|
+
} from "./chunk-32PJ3FML.mjs";
|
|
4
|
+
import {
|
|
5
|
+
resize_default
|
|
6
|
+
} from "./chunk-GJMNV2OC.mjs";
|
|
7
|
+
import {
|
|
8
|
+
isImage
|
|
9
|
+
} from "./chunk-JAP2EUEW.mjs";
|
|
10
|
+
|
|
11
|
+
// src/images/upload.ts
|
|
12
|
+
var upload = async (file) => {
|
|
13
|
+
const { name } = file;
|
|
14
|
+
if (!isImage(name)) {
|
|
15
|
+
const err = "Please Choose Image!";
|
|
16
|
+
console.error(err);
|
|
17
|
+
return getFailedResponse(err);
|
|
18
|
+
}
|
|
19
|
+
const blob = await resize_default(file);
|
|
20
|
+
const url = URL.createObjectURL(blob);
|
|
21
|
+
blob.name = name;
|
|
22
|
+
return {
|
|
23
|
+
blob,
|
|
24
|
+
url
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
var upload_default = upload;
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
upload,
|
|
31
|
+
upload_default
|
|
32
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
numeric,
|
|
3
|
+
punctuation,
|
|
4
|
+
randomStringByLength,
|
|
5
|
+
textLowCase
|
|
6
|
+
} from "./chunk-HTAKHCLC.mjs";
|
|
7
|
+
|
|
8
|
+
// src/string/generatePassword.ts
|
|
9
|
+
function generatePassword(length = 6, hard = true) {
|
|
10
|
+
if (!Number.isFinite(length))
|
|
11
|
+
length = 6;
|
|
12
|
+
if (length <= 0)
|
|
13
|
+
length = 6;
|
|
14
|
+
let pass = randomStringByLength(length, textLowCase + textLowCase.toUpperCase() + numeric);
|
|
15
|
+
if (hard)
|
|
16
|
+
pass = pass.replace(pass[Math.floor(pass.length / 2)], randomStringByLength(1, punctuation));
|
|
17
|
+
return pass;
|
|
18
|
+
}
|
|
19
|
+
var generatePassword_default = generatePassword;
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
generatePassword,
|
|
23
|
+
generatePassword_default
|
|
24
|
+
};
|
package/dist/color.mjs
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import "./chunk-4VQ25N7H.mjs";
|
|
2
|
+
|
|
3
|
+
// src/color.ts
|
|
4
|
+
var random = (hex = false) => {
|
|
5
|
+
return (hex ? "#" : "") + Math.floor(Math.random() * 16777215).toString(16);
|
|
6
|
+
};
|
|
7
|
+
var pSBC = (p, c0, c1, l) => {
|
|
8
|
+
let r, g, b, P, f, t, h, i = parseInt, m = Math.round, a = typeof c1 == "string";
|
|
9
|
+
if (typeof p != "number" || p < -1 || p > 1 || typeof c0 != "string" || c0[0] != "r" && c0[0] != "#" || c1 && !a)
|
|
10
|
+
return null;
|
|
11
|
+
const pSBCr = (d) => {
|
|
12
|
+
let n = d.length, x = { r: 0, g: 0, b: 0, a: 1 };
|
|
13
|
+
if (n > 9) {
|
|
14
|
+
[r, g, b, a] = d = d.split(","), n = d.length;
|
|
15
|
+
if (n < 3 || n > 4)
|
|
16
|
+
return null;
|
|
17
|
+
x.r = i(r[3] == "a" ? r.slice(5) : r.slice(4)), x.g = i(g), x.b = i(b), x.a = a ? parseFloat(a.toString()) : -1;
|
|
18
|
+
} else {
|
|
19
|
+
if (n == 8 || n == 6 || n < 4)
|
|
20
|
+
return null;
|
|
21
|
+
if (n < 6)
|
|
22
|
+
d = "#" + d[1] + d[1] + d[2] + d[2] + d[3] + d[3] + (n > 4 ? d[4] + d[4] : "");
|
|
23
|
+
d = i(d.slice(1), 16);
|
|
24
|
+
if (n == 9 || n == 5)
|
|
25
|
+
x.r = d >> 24 & 255, x.g = d >> 16 & 255, x.b = d >> 8 & 255, x.a = m((d & 255) / 0.255) / 1e3;
|
|
26
|
+
else
|
|
27
|
+
x.r = d >> 16, x.g = d >> 8 & 255, x.b = d & 255, x.a = -1;
|
|
28
|
+
}
|
|
29
|
+
return x;
|
|
30
|
+
};
|
|
31
|
+
h = c0.length > 9, h = a ? c1.length > 9 ? true : c1 == "c" ? !h : false : h, f = pSBCr(c0), P = p < 0, t = c1 && c1 != "c" ? pSBCr(c1) : P ? { r: 0, g: 0, b: 0, a: -1 } : { r: 255, g: 255, b: 255, a: -1 }, p = P ? p * -1 : p, P = 1 - p;
|
|
32
|
+
if (!f || !t || typeof f == "undefined")
|
|
33
|
+
return null;
|
|
34
|
+
else if (l)
|
|
35
|
+
r = m(P * f.r + p * t.r), g = m(P * f.g + p * t.g), b = m(P * f.b + p * t.b);
|
|
36
|
+
else
|
|
37
|
+
r = m((P * f.r ** 2 + p * t.r ** 2) ** 0.5), g = m((P * f.g ** 2 + p * t.g ** 2) ** 0.5), b = m((P * f.b ** 2 + p * t.b ** 2) ** 0.5);
|
|
38
|
+
a = f.a, t = t.a, f = a >= 0 || t >= 0, a = f ? a < 0 ? t : t < 0 ? a : a * P + t * p : 0;
|
|
39
|
+
if (h)
|
|
40
|
+
return "rgb" + (f ? "a(" : "(") + r + "," + g + "," + b + (f ? "," + m(a * 1e3) / 1e3 : "") + ")";
|
|
41
|
+
else
|
|
42
|
+
return "#" + (4294967296 + r * 16777216 + g * 65536 + b * 256 + (f ? m(a * 255) : 0)).toString(16).slice(1, f ? void 0 : -2);
|
|
43
|
+
};
|
|
44
|
+
var hexToRgb = (hex) => {
|
|
45
|
+
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
46
|
+
return result ? {
|
|
47
|
+
r: parseInt(result[1], 16),
|
|
48
|
+
g: parseInt(result[2], 16),
|
|
49
|
+
b: parseInt(result[3], 16)
|
|
50
|
+
} : null;
|
|
51
|
+
};
|
|
52
|
+
var hexDarken = (hex, amount) => {
|
|
53
|
+
return pSBC(-amount, hex);
|
|
54
|
+
};
|
|
55
|
+
var hexLighten = (hex, amount) => {
|
|
56
|
+
return pSBC(amount, hex);
|
|
57
|
+
};
|
|
58
|
+
var RGBToHex = (rgb) => {
|
|
59
|
+
return pSBC(0, rgb, "c", true);
|
|
60
|
+
};
|
|
61
|
+
var hexToVBColor = (rrggbb) => {
|
|
62
|
+
rrggbb = rrggbb.replace("#", "");
|
|
63
|
+
const bbggrr = rrggbb.substring(4, 2) + rrggbb.substring(2, 2) + rrggbb.substring(0, 2);
|
|
64
|
+
return parseInt(bbggrr, 16);
|
|
65
|
+
};
|
|
66
|
+
var color = {
|
|
67
|
+
random,
|
|
68
|
+
pSBC,
|
|
69
|
+
hexToRgb,
|
|
70
|
+
hexDarken,
|
|
71
|
+
hexLighten,
|
|
72
|
+
RGBToHex,
|
|
73
|
+
hexToVBColor
|
|
74
|
+
};
|
|
75
|
+
var color_default = color;
|
|
76
|
+
export {
|
|
77
|
+
RGBToHex,
|
|
78
|
+
color_default as default,
|
|
79
|
+
hexDarken,
|
|
80
|
+
hexLighten,
|
|
81
|
+
hexToRgb,
|
|
82
|
+
hexToVBColor,
|
|
83
|
+
pSBC,
|
|
84
|
+
random
|
|
85
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
console_default,
|
|
3
|
+
disableConsole,
|
|
4
|
+
removeConsole,
|
|
5
|
+
showCredit
|
|
6
|
+
} from "../chunk-24DHBJAC.mjs";
|
|
7
|
+
import "../chunk-76AY2CWV.mjs";
|
|
8
|
+
import "../chunk-4VQ25N7H.mjs";
|
|
9
|
+
export {
|
|
10
|
+
console_default as default,
|
|
11
|
+
disableConsole,
|
|
12
|
+
removeConsole,
|
|
13
|
+
showCredit
|
|
14
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
log,
|
|
3
|
+
logError,
|
|
4
|
+
logFull,
|
|
5
|
+
logRes,
|
|
6
|
+
logSuccess,
|
|
7
|
+
logWarn,
|
|
8
|
+
log_default
|
|
9
|
+
} from "../chunk-GNJDIUYM.mjs";
|
|
10
|
+
import "../chunk-4VQ25N7H.mjs";
|
|
11
|
+
export {
|
|
12
|
+
log_default as default,
|
|
13
|
+
log,
|
|
14
|
+
logError,
|
|
15
|
+
logFull,
|
|
16
|
+
logRes,
|
|
17
|
+
logSuccess,
|
|
18
|
+
logWarn
|
|
19
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create new directory
|
|
3
|
+
*/
|
|
4
|
+
declare function createDir(path: string): true | undefined;
|
|
5
|
+
|
|
6
|
+
declare const createDir$1_createDir: typeof createDir;
|
|
7
|
+
declare namespace createDir$1 {
|
|
8
|
+
export {
|
|
9
|
+
createDir$1_createDir as createDir,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { createDir as a, createDir$1 as c };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import "../chunk-4VQ25N7H.mjs";
|
|
2
|
+
|
|
3
|
+
// src/device/os.ts
|
|
4
|
+
import os from "os";
|
|
5
|
+
function getOS() {
|
|
6
|
+
const osvar = os.platform();
|
|
7
|
+
if (osvar == "darwin") {
|
|
8
|
+
return "mac";
|
|
9
|
+
} else if (osvar == "win32") {
|
|
10
|
+
return "win";
|
|
11
|
+
} else if (osvar == "linux") {
|
|
12
|
+
return "linux";
|
|
13
|
+
} else {
|
|
14
|
+
return osvar;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function isWin() {
|
|
18
|
+
return os.platform() == "win32";
|
|
19
|
+
}
|
|
20
|
+
function isMac() {
|
|
21
|
+
return os.platform() == "darwin";
|
|
22
|
+
}
|
|
23
|
+
function isLinux() {
|
|
24
|
+
return os.platform() == "linux";
|
|
25
|
+
}
|
|
26
|
+
var os_default = { getOS, isWin, isMac, isLinux };
|
|
27
|
+
export {
|
|
28
|
+
os_default as default,
|
|
29
|
+
getOS,
|
|
30
|
+
isLinux,
|
|
31
|
+
isMac,
|
|
32
|
+
isWin
|
|
33
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare function enableConsole(): Console;
|
|
2
|
+
|
|
3
|
+
declare const enableConsole$1_enableConsole: typeof enableConsole;
|
|
4
|
+
declare namespace enableConsole$1 {
|
|
5
|
+
export {
|
|
6
|
+
enableConsole as default,
|
|
7
|
+
enableConsole$1_enableConsole as enableConsole,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { enableConsole as a, enableConsole$1 as e };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createDir
|
|
3
|
+
} from "../chunk-TV4YHUBU.mjs";
|
|
4
|
+
import {
|
|
5
|
+
fileMove
|
|
6
|
+
} from "../chunk-HN4EHJ2H.mjs";
|
|
7
|
+
import {
|
|
8
|
+
findFilesByExt_default
|
|
9
|
+
} from "../chunk-D5JDP7JB.mjs";
|
|
10
|
+
import "../chunk-4VQ25N7H.mjs";
|
|
11
|
+
|
|
12
|
+
// src/file/index.ts
|
|
13
|
+
var xfile = { createDir, fileMove, ...findFilesByExt_default };
|
|
14
|
+
var file_default = xfile;
|
|
15
|
+
export {
|
|
16
|
+
file_default as default
|
|
17
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Move file to another location.
|
|
3
|
+
*/
|
|
4
|
+
declare function fileMove(oldPath: string, newPath: string, callback: any): void;
|
|
5
|
+
|
|
6
|
+
declare const fileMove$1_fileMove: typeof fileMove;
|
|
7
|
+
declare namespace fileMove$1 {
|
|
8
|
+
export {
|
|
9
|
+
fileMove$1_fileMove as fileMove,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { fileMove as a, fileMove$1 as f };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is an alias of "findFileByExt()"
|
|
3
|
+
*/
|
|
4
|
+
declare const forEachFileByExt: (base: string, ext: string, cb: (path: string) => {}) => void;
|
|
5
|
+
/**
|
|
6
|
+
* This is an alias of "forEachFileByExt()"
|
|
7
|
+
*/
|
|
8
|
+
declare const findFileByExt: (base: string, ext: string, cb: (path: string) => {}) => void;
|
|
9
|
+
declare const fileExt: {
|
|
10
|
+
findFileByExt: (base: string, ext: string, cb: (path: string) => {}) => void;
|
|
11
|
+
forEachFileByExt: (base: string, ext: string, cb: (path: string) => {}) => void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
declare const findFilesByExt_findFileByExt: typeof findFileByExt;
|
|
15
|
+
declare const findFilesByExt_forEachFileByExt: typeof forEachFileByExt;
|
|
16
|
+
declare namespace findFilesByExt {
|
|
17
|
+
export {
|
|
18
|
+
fileExt as default,
|
|
19
|
+
findFilesByExt_findFileByExt as findFileByExt,
|
|
20
|
+
findFilesByExt_forEachFileByExt as forEachFileByExt,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { fileExt as a, forEachFileByExt as b, findFileByExt as c, findFilesByExt as f };
|
package/dist/gameboi/index.d.ts
CHANGED
package/dist/gameboi/index.js
CHANGED
|
@@ -24,6 +24,8 @@ class GameBoi extends events_1.default {
|
|
|
24
24
|
_GameBoi___onDisconnect.set(this, void 0);
|
|
25
25
|
_GameBoi___start.set(this, void 0);
|
|
26
26
|
_GameBoi_time.set(this, +new Date());
|
|
27
|
+
this.isConnect = false;
|
|
28
|
+
this.status = "";
|
|
27
29
|
__classPrivateFieldGet(this, _GameBoi_instances, "m", _GameBoi_awake).call(this);
|
|
28
30
|
}
|
|
29
31
|
onConnect(e) {
|
|
@@ -31,9 +33,11 @@ class GameBoi extends events_1.default {
|
|
|
31
33
|
console.log(`Gamepad connected at index ${gp.index}: ${gp.id}. It has ${gp.buttons.length} buttons and ${gp.axes.length} axes.`);
|
|
32
34
|
__classPrivateFieldSet(this, _GameBoi_time, +new Date(), "f");
|
|
33
35
|
this.gameLoop();
|
|
36
|
+
this.isConnect = true;
|
|
34
37
|
}
|
|
35
38
|
onDisconnect() {
|
|
36
39
|
console.log("onDisconnect");
|
|
40
|
+
this.isConnect = false;
|
|
37
41
|
window.cancelAnimationFrame(__classPrivateFieldGet(this, _GameBoi___start, "f"));
|
|
38
42
|
}
|
|
39
43
|
gameLoop() {
|
|
@@ -50,6 +54,7 @@ class GameBoi extends events_1.default {
|
|
|
50
54
|
}
|
|
51
55
|
dispose() {
|
|
52
56
|
//
|
|
57
|
+
this.isConnect = false;
|
|
53
58
|
this.onDisconnect();
|
|
54
59
|
window.removeEventListener("gamepadconnected", __classPrivateFieldGet(this, _GameBoi___onConnect, "f"));
|
|
55
60
|
window.removeEventListener("gamepaddisconnected", __classPrivateFieldGet(this, _GameBoi___onDisconnect, "f"));
|
|
@@ -1 +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,mCAAc;QAEd,wBAAQ,CAAC,IAAI,IAAI,EAAE,EAAC;
|
|
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,mCAAc;QAEd,wBAAQ,CAAC,IAAI,IAAI,EAAE,EAAC;QAEpB,cAAS,GAAG,KAAK,CAAC;QAElB,WAAM,GAAG,EAAE,CAAC;QAXX,uBAAA,IAAI,0CAAO,MAAX,IAAI,CAAS,CAAC;IACf,CAAC;IAuBD,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;QAEhB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,CAAC;IAED,YAAY;QACX,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAE5B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QAEtB,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;QACF,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QAEvB,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;AAxED,0BAwEC;;IAtDC,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"}
|