tiny-essentials 1.28.0 → 1.28.1
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/changelog/1/28/1.md +23 -0
- package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
- package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
- package/dist/v1/TinyAnalogClock.min.js +1 -1
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyDayNightCycle.min.js +1 -1
- package/dist/v1/TinyDragDropDetector.min.js +1 -1
- package/dist/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyElementObserver.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyGamepad.min.js +1 -1
- package/dist/v1/TinyHtml.min.js +1 -1
- package/dist/v1/TinyI18.min.js +1 -1
- package/dist/v1/TinyIframeEvents.min.js +1 -1
- package/dist/v1/TinyLocalStorage.min.js +1 -1
- package/dist/v1/TinyMediaPlayer.min.js +1 -1
- package/dist/v1/TinyNewWinEvents.min.js +1 -1
- package/dist/v1/TinyNotifyCenter.min.js +1 -1
- package/dist/v1/TinyRadioFm.min.js +1 -1
- package/dist/v1/TinyRateLimiter.min.js +1 -1
- package/dist/v1/TinySmartScroller.min.js +1 -1
- package/dist/v1/TinyTextDiffer.min.js +1 -1
- package/dist/v1/TinyTextarea.min.js +1 -1
- package/dist/v1/TinyTimeout.min.js +1 -1
- package/dist/v1/TinyToastNotify.min.js +1 -1
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/UltraRandomMsgGen.min.js +1 -1
- package/dist/v1/basics/array.cjs +57 -9
- package/dist/v1/basics/array.d.mts +27 -11
- package/dist/v1/basics/array.mjs +51 -9
- package/dist/v1/basics/clock.cjs +94 -42
- package/dist/v1/basics/clock.d.mts +10 -10
- package/dist/v1/basics/clock.mjs +91 -54
- package/dist/v1/basics/deprecated/html.cjs +246 -0
- package/dist/v1/basics/deprecated/html.d.mts +63 -0
- package/dist/v1/basics/deprecated/html.mjs +190 -0
- package/dist/v1/basics/html.cjs +149 -130
- package/dist/v1/basics/html.d.mts +26 -61
- package/dist/v1/basics/html.mjs +113 -105
- package/dist/v1/basics/index.cjs +2 -0
- package/dist/v1/basics/index.d.mts +3 -1
- package/dist/v1/basics/index.mjs +3 -3
- package/dist/v1/basics/mediaContent.cjs +51 -9
- package/dist/v1/basics/mediaContent.d.mts +0 -87
- package/dist/v1/basics/mediaContent.mjs +40 -10
- package/dist/v1/basics/objChecker.cjs +7 -5
- package/dist/v1/basics/objChecker.d.mts +3 -2
- package/dist/v1/basics/objChecker.mjs +6 -6
- package/dist/v1/basics/objFilter.cjs +40 -7
- package/dist/v1/basics/objFilter.d.mts +6 -6
- package/dist/v1/basics/objFilter.mjs +32 -7
- package/dist/v1/basics/simpleMath.cjs +81 -25
- package/dist/v1/basics/simpleMath.d.mts +2 -2
- package/dist/v1/basics/simpleMath.mjs +70 -27
- package/dist/v1/basics/text.cjs +76 -31
- package/dist/v1/basics/text.d.mts +69 -7
- package/dist/v1/basics/text.mjs +62 -31
- package/dist/v1/index.cjs +4 -0
- package/dist/v1/index.d.mts +4 -1
- package/dist/v1/index.mjs +4 -3
- package/dist/v1/libs/TinyAdvancedRaffle.cjs +64 -50
- package/dist/v1/libs/TinyAdvancedRaffle.d.mts +4 -13
- package/dist/v1/libs/TinyAdvancedRaffle.mjs +62 -49
- package/dist/v1/libs/TinyAfterScrollWatcher.cjs +17 -1
- package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +4 -1
- package/dist/v1/libs/TinyAfterScrollWatcher.mjs +15 -1
- package/dist/v1/libs/TinyAnalogClock.cjs +60 -0
- package/dist/v1/libs/TinyAnalogClock.d.mts +6 -0
- package/dist/v1/libs/TinyAnalogClock.mjs +57 -0
- package/dist/v1/libs/TinyClipboard.cjs +2 -0
- package/dist/v1/libs/TinyClipboard.d.mts +4 -2
- package/dist/v1/libs/TinyClipboard.mjs +2 -0
- package/dist/v1/libs/TinyColorConverter.cjs +1 -0
- package/dist/v1/libs/TinyColorConverter.d.mts +2 -1
- package/dist/v1/libs/TinyColorConverter.mjs +1 -0
- package/dist/v1/libs/TinyDayNightCycle.cjs +67 -42
- package/dist/v1/libs/TinyDayNightCycle.d.mts +2 -7
- package/dist/v1/libs/TinyDayNightCycle.mjs +65 -41
- package/dist/v1/libs/TinyDragDropDetector.cjs +25 -0
- package/dist/v1/libs/TinyDragDropDetector.d.mts +6 -0
- package/dist/v1/libs/TinyDragDropDetector.mjs +22 -0
- package/dist/v1/libs/TinyDragger.cjs +46 -19
- package/dist/v1/libs/TinyDragger.mjs +45 -18
- package/dist/v1/libs/TinyElementObserver.cjs +39 -0
- package/dist/v1/libs/TinyElementObserver.d.mts +6 -0
- package/dist/v1/libs/TinyElementObserver.mjs +36 -0
- package/dist/v1/libs/TinyGamepad.cjs +131 -1
- package/dist/v1/libs/TinyGamepad.mjs +129 -1
- package/dist/v1/libs/TinyHtml.cjs +1 -1
- package/dist/v1/libs/TinyHtml.mjs +2 -2
- package/dist/v1/libs/TinyI18.cjs +61 -0
- package/dist/v1/libs/TinyI18.d.mts +14 -0
- package/dist/v1/libs/TinyI18.mjs +55 -0
- package/dist/v1/libs/TinyIframeEvents.cjs +18 -1
- package/dist/v1/libs/TinyIframeEvents.mjs +18 -1
- package/dist/v1/libs/TinyLocalStorage.cjs +48 -0
- package/dist/v1/libs/TinyLocalStorage.d.mts +6 -0
- package/dist/v1/libs/TinyLocalStorage.mjs +45 -0
- package/dist/v1/libs/TinyMediaPlayer.cjs +72 -0
- package/dist/v1/libs/TinyMediaPlayer.d.mts +10 -0
- package/dist/v1/libs/TinyMediaPlayer.mjs +66 -0
- package/dist/v1/libs/TinyNewWinEvents.cjs +29 -0
- package/dist/v1/libs/TinyNewWinEvents.d.mts +6 -0
- package/dist/v1/libs/TinyNewWinEvents.mjs +26 -0
- package/dist/v1/libs/TinyNotifyCenter.cjs +36 -0
- package/dist/v1/libs/TinyNotifyCenter.d.mts +6 -0
- package/dist/v1/libs/TinyNotifyCenter.mjs +32 -0
- package/dist/v1/libs/TinyRadioFm.cjs +38 -0
- package/dist/v1/libs/TinyRadioFm.d.mts +1 -0
- package/dist/v1/libs/TinyRadioFm.mjs +35 -0
- package/dist/v1/libs/TinyRateLimiter.cjs +52 -0
- package/dist/v1/libs/TinyRateLimiter.d.mts +6 -0
- package/dist/v1/libs/TinyRateLimiter.mjs +48 -0
- package/dist/v1/libs/TinySmartScroller.cjs +52 -3
- package/dist/v1/libs/TinySmartScroller.d.mts +17 -15
- package/dist/v1/libs/TinySmartScroller.mjs +51 -5
- package/dist/v1/libs/TinyTextDiffer.cjs +19 -18
- package/dist/v1/libs/TinyTextDiffer.d.mts +1 -0
- package/dist/v1/libs/TinyTextDiffer.mjs +16 -17
- package/dist/v1/libs/TinyTextarea.cjs +19 -0
- package/dist/v1/libs/TinyTextarea.d.mts +6 -0
- package/dist/v1/libs/TinyTextarea.mjs +17 -0
- package/dist/v1/libs/TinyTimeout.cjs +11 -1
- package/dist/v1/libs/TinyTimeout.mjs +9 -1
- package/dist/v1/libs/TinyToastNotify.cjs +35 -0
- package/dist/v1/libs/TinyToastNotify.d.mts +6 -0
- package/dist/v1/libs/TinyToastNotify.mjs +31 -0
- package/dist/v1/libs/TinyUploadClicker.cjs +19 -0
- package/dist/v1/libs/TinyUploadClicker.d.mts +6 -0
- package/dist/v1/libs/TinyUploadClicker.mjs +17 -0
- package/dist/v1/libs/UltraRandomMsgGen.cjs +148 -35
- package/dist/v1/libs/UltraRandomMsgGen.d.mts +17 -3
- package/dist/v1/libs/UltraRandomMsgGen.mjs +133 -34
- package/dist/v1/libs/utils.cjs +21 -0
- package/dist/v1/libs/utils.d.mts +2 -0
- package/dist/v1/libs/utils.mjs +16 -0
- package/docs/v1/README.md +1 -0
- package/docs/v1/basics/array.md +2 -2
- package/docs/v1/basics/deprecated/html.md +17 -0
- package/docs/v1/basics/fullScreen.md +1 -1
- package/docs/v1/basics/html.md +12 -26
- package/docs/v1/basics/mediaContent.md +1 -1
- package/docs/v1/basics/objChecker.md +1 -1
- package/docs/v1/basics/text.md +2 -2
- package/docs/v1/fileManager/main.md +1 -1
- package/docs/v1/libs/ColorSafeStringify.md +1 -1
- package/docs/v1/libs/TinyAfterScrollWatcher.md +1 -1
- package/docs/v1/libs/TinyAnalogClock.md +1 -1
- package/docs/v1/libs/TinyArrayComparator.md +1 -1
- package/docs/v1/libs/TinyArrayPaginator.md +1 -1
- package/docs/v1/libs/TinyClassManager/TinyPluginInliner.md +2 -2
- package/docs/v1/libs/TinyClassManager.md +1 -1
- package/docs/v1/libs/TinyClipboard.md +1 -1
- package/docs/v1/libs/TinyCookieConsent.md +1 -1
- package/docs/v1/libs/TinyDomReadyManager.md +1 -1
- package/docs/v1/libs/TinyDragDropDetector.md +1 -1
- package/docs/v1/libs/TinyDragger.md +1 -1
- package/docs/v1/libs/TinyElementObserver.md +1 -1
- package/docs/v1/libs/TinyHtml.md +1 -1
- package/docs/v1/libs/TinyIframeEvents.md +2 -2
- package/docs/v1/libs/TinyLevelUp.md +1 -1
- package/docs/v1/libs/TinyLoadingScreen.md +1 -1
- package/docs/v1/libs/TinyNewWinEvents.md +2 -2
- package/docs/v1/libs/TinyNotifications.md +1 -1
- package/docs/v1/libs/TinyPromiseQueue.md +2 -2
- package/docs/v1/libs/TinyTextDiffer.md +1 -1
- package/docs/v1/libs/TinyTextarea.md +1 -1
- package/package.json +10 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createCheckDestroyed } from './utils.mjs';
|
|
2
|
+
const checkDestroy = createCheckDestroyed('TinyGamepad');
|
|
1
3
|
/**
|
|
2
4
|
* @typedef {Object} KeyStatus
|
|
3
5
|
* Describes the status of a key or button.
|
|
@@ -1098,6 +1100,7 @@ class TinyGamepad {
|
|
|
1098
1100
|
* - `gp`: the Gamepad object (only if the input source is a gamepad).
|
|
1099
1101
|
*/
|
|
1100
1102
|
awaitInputMapping({ timeout = 10000, eventName = 'MappingInput', canMove = false } = {}) {
|
|
1103
|
+
checkDestroy(this.#isDestroyed);
|
|
1101
1104
|
return new Promise((resolve, reject) => {
|
|
1102
1105
|
// Argument validation
|
|
1103
1106
|
if (typeof timeout !== 'number' || Number.isNaN(timeout) || timeout < 0)
|
|
@@ -1137,6 +1140,7 @@ class TinyGamepad {
|
|
|
1137
1140
|
* @param {string|string[]} physicalInput
|
|
1138
1141
|
*/
|
|
1139
1142
|
mapInput(logicalName, physicalInput) {
|
|
1143
|
+
checkDestroy(this.#isDestroyed);
|
|
1140
1144
|
if (typeof logicalName !== 'string' || !logicalName.trim())
|
|
1141
1145
|
throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${logicalName}`);
|
|
1142
1146
|
if (!(typeof physicalInput === 'string' ||
|
|
@@ -1149,6 +1153,7 @@ class TinyGamepad {
|
|
|
1149
1153
|
* @param {string} logicalName
|
|
1150
1154
|
*/
|
|
1151
1155
|
unmapInput(logicalName) {
|
|
1156
|
+
checkDestroy(this.#isDestroyed);
|
|
1152
1157
|
if (typeof logicalName !== 'string' || !logicalName.trim())
|
|
1153
1158
|
throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${logicalName}`);
|
|
1154
1159
|
this.#inputMap.delete(logicalName);
|
|
@@ -1159,6 +1164,7 @@ class TinyGamepad {
|
|
|
1159
1164
|
* @returns {boolean}
|
|
1160
1165
|
*/
|
|
1161
1166
|
hasMappedInput(logicalName) {
|
|
1167
|
+
checkDestroy(this.#isDestroyed);
|
|
1162
1168
|
if (typeof logicalName !== 'string' || !logicalName.trim())
|
|
1163
1169
|
throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${logicalName}`);
|
|
1164
1170
|
return this.#inputMap.has(logicalName);
|
|
@@ -1169,6 +1175,7 @@ class TinyGamepad {
|
|
|
1169
1175
|
* @returns {string | string[]}
|
|
1170
1176
|
*/
|
|
1171
1177
|
getMappedInput(logicalName) {
|
|
1178
|
+
checkDestroy(this.#isDestroyed);
|
|
1172
1179
|
if (typeof logicalName !== 'string' || !logicalName.trim())
|
|
1173
1180
|
throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${logicalName}`);
|
|
1174
1181
|
const result = this.#inputMap.get(logicalName);
|
|
@@ -1180,6 +1187,7 @@ class TinyGamepad {
|
|
|
1180
1187
|
* Clears all mappings for all logical inputs.
|
|
1181
1188
|
*/
|
|
1182
1189
|
clearMapInputs() {
|
|
1190
|
+
checkDestroy(this.#isDestroyed);
|
|
1183
1191
|
this.#inputMap.clear();
|
|
1184
1192
|
}
|
|
1185
1193
|
//////////////////////////////////////////////////////////////
|
|
@@ -1189,6 +1197,7 @@ class TinyGamepad {
|
|
|
1189
1197
|
* @param {InputSequenceCallback} callback - Function to invoke when the sequence is fully held
|
|
1190
1198
|
*/
|
|
1191
1199
|
registerInputSequence(sequence, callback) {
|
|
1200
|
+
checkDestroy(this.#isDestroyed);
|
|
1192
1201
|
if (!Array.isArray(sequence) || !sequence.every((s) => typeof s === 'string'))
|
|
1193
1202
|
throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(sequence)}`);
|
|
1194
1203
|
if (typeof callback !== 'function')
|
|
@@ -1203,6 +1212,7 @@ class TinyGamepad {
|
|
|
1203
1212
|
* @param {string[]} sequence - The sequence to remove from detection
|
|
1204
1213
|
*/
|
|
1205
1214
|
unregisterInputSequence(sequence) {
|
|
1215
|
+
checkDestroy(this.#isDestroyed);
|
|
1206
1216
|
if (!Array.isArray(sequence) || !sequence.every((s) => typeof s === 'string'))
|
|
1207
1217
|
throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(sequence)}`);
|
|
1208
1218
|
const key = sequence.join('+');
|
|
@@ -1212,6 +1222,7 @@ class TinyGamepad {
|
|
|
1212
1222
|
* Removes all registered input sequences.
|
|
1213
1223
|
*/
|
|
1214
1224
|
unregisterAllInputSequences() {
|
|
1225
|
+
checkDestroy(this.#isDestroyed);
|
|
1215
1226
|
this.#inputSequences.clear();
|
|
1216
1227
|
}
|
|
1217
1228
|
/**
|
|
@@ -1220,6 +1231,7 @@ class TinyGamepad {
|
|
|
1220
1231
|
* @returns {boolean}
|
|
1221
1232
|
*/
|
|
1222
1233
|
hasInputSequence(sequence) {
|
|
1234
|
+
checkDestroy(this.#isDestroyed);
|
|
1223
1235
|
if (!Array.isArray(sequence) || !sequence.every((s) => typeof s === 'string'))
|
|
1224
1236
|
throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(sequence)}`);
|
|
1225
1237
|
const key = sequence.join('+');
|
|
@@ -1232,6 +1244,7 @@ class TinyGamepad {
|
|
|
1232
1244
|
* @param {InputSequenceCallback} callback - Function to invoke when the sequence is fully held
|
|
1233
1245
|
*/
|
|
1234
1246
|
registerKeySequence(sequence, callback) {
|
|
1247
|
+
checkDestroy(this.#isDestroyed);
|
|
1235
1248
|
if (!Array.isArray(sequence) || !sequence.every((s) => typeof s === 'string'))
|
|
1236
1249
|
throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(sequence)}`);
|
|
1237
1250
|
if (typeof callback !== 'function')
|
|
@@ -1246,6 +1259,7 @@ class TinyGamepad {
|
|
|
1246
1259
|
* @param {string[]} sequence - The sequence to remove from detection
|
|
1247
1260
|
*/
|
|
1248
1261
|
unregisterKeySequence(sequence) {
|
|
1262
|
+
checkDestroy(this.#isDestroyed);
|
|
1249
1263
|
if (!Array.isArray(sequence) || !sequence.every((s) => typeof s === 'string'))
|
|
1250
1264
|
throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(sequence)}`);
|
|
1251
1265
|
const key = sequence.join('+');
|
|
@@ -1255,6 +1269,7 @@ class TinyGamepad {
|
|
|
1255
1269
|
* Removes all registered input sequences.
|
|
1256
1270
|
*/
|
|
1257
1271
|
unregisterAllKeySequences() {
|
|
1272
|
+
checkDestroy(this.#isDestroyed);
|
|
1258
1273
|
this.#keySequences.clear();
|
|
1259
1274
|
}
|
|
1260
1275
|
/**
|
|
@@ -1263,6 +1278,7 @@ class TinyGamepad {
|
|
|
1263
1278
|
* @returns {boolean}
|
|
1264
1279
|
*/
|
|
1265
1280
|
hasKeySequence(sequence) {
|
|
1281
|
+
checkDestroy(this.#isDestroyed);
|
|
1266
1282
|
if (!Array.isArray(sequence) || !sequence.every((s) => typeof s === 'string'))
|
|
1267
1283
|
throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(sequence)}`);
|
|
1268
1284
|
const key = sequence.join('+');
|
|
@@ -1273,6 +1289,7 @@ class TinyGamepad {
|
|
|
1273
1289
|
* Renew the currently held combo logical keys.
|
|
1274
1290
|
*/
|
|
1275
1291
|
renewComboMapped() {
|
|
1292
|
+
checkDestroy(this.#isDestroyed);
|
|
1276
1293
|
if (this.#intervalComboKeys) {
|
|
1277
1294
|
clearTimeout(this.#intervalComboKeys);
|
|
1278
1295
|
this.#intervalComboKeys = setTimeout(() => this.resetComboMapped(), this.#timeoutComboKeys);
|
|
@@ -1282,6 +1299,7 @@ class TinyGamepad {
|
|
|
1282
1299
|
* Resets the currently held key combo logical inputs.
|
|
1283
1300
|
*/
|
|
1284
1301
|
resetComboMapped() {
|
|
1302
|
+
checkDestroy(this.#isDestroyed);
|
|
1285
1303
|
if (this.#intervalComboKeys)
|
|
1286
1304
|
clearTimeout(this.#intervalComboKeys);
|
|
1287
1305
|
this.#comboKeys = [];
|
|
@@ -1296,6 +1314,7 @@ class TinyGamepad {
|
|
|
1296
1314
|
* @param {MappedInputCallback} callback
|
|
1297
1315
|
*/
|
|
1298
1316
|
onMappedKeyStart(callback) {
|
|
1317
|
+
checkDestroy(this.#isDestroyed);
|
|
1299
1318
|
return this.#onTemplate('', callback, 'mapped-key-start');
|
|
1300
1319
|
}
|
|
1301
1320
|
/**
|
|
@@ -1304,6 +1323,7 @@ class TinyGamepad {
|
|
|
1304
1323
|
* @param {MappedInputCallback} callback
|
|
1305
1324
|
*/
|
|
1306
1325
|
onceMappedKeyStart(callback) {
|
|
1326
|
+
checkDestroy(this.#isDestroyed);
|
|
1307
1327
|
return this.#onceTemplate('', callback, 'mapped-key-start');
|
|
1308
1328
|
}
|
|
1309
1329
|
/**
|
|
@@ -1311,6 +1331,7 @@ class TinyGamepad {
|
|
|
1311
1331
|
* @param {MappedInputCallback} callback
|
|
1312
1332
|
*/
|
|
1313
1333
|
prependMappedKeyStart(callback) {
|
|
1334
|
+
checkDestroy(this.#isDestroyed);
|
|
1314
1335
|
return this.#prependTemplate('', callback, 'mapped-key-start');
|
|
1315
1336
|
}
|
|
1316
1337
|
/**
|
|
@@ -1318,12 +1339,14 @@ class TinyGamepad {
|
|
|
1318
1339
|
* @param {MappedInputCallback} callback
|
|
1319
1340
|
*/
|
|
1320
1341
|
offMappedKeyStart(callback) {
|
|
1342
|
+
checkDestroy(this.#isDestroyed);
|
|
1321
1343
|
return this.#offTemplate('', callback, 'mapped-key-start');
|
|
1322
1344
|
}
|
|
1323
1345
|
/**
|
|
1324
1346
|
* Removes all callbacks from the "mapped-key-start" event.
|
|
1325
1347
|
*/
|
|
1326
1348
|
offAllMappedKeyStart() {
|
|
1349
|
+
checkDestroy(this.#isDestroyed);
|
|
1327
1350
|
this.#callbacks.delete('mapped-key-start');
|
|
1328
1351
|
}
|
|
1329
1352
|
//////////////////////////////////////////////////////////////////
|
|
@@ -1332,6 +1355,7 @@ class TinyGamepad {
|
|
|
1332
1355
|
* @param {MappedInputCallback} callback
|
|
1333
1356
|
*/
|
|
1334
1357
|
onMappedKeyEnd(callback) {
|
|
1358
|
+
checkDestroy(this.#isDestroyed);
|
|
1335
1359
|
return this.#onTemplate('', callback, 'mapped-key-end');
|
|
1336
1360
|
}
|
|
1337
1361
|
/**
|
|
@@ -1340,6 +1364,7 @@ class TinyGamepad {
|
|
|
1340
1364
|
* @param {MappedInputCallback} callback
|
|
1341
1365
|
*/
|
|
1342
1366
|
onceMappedKeyEnd(callback) {
|
|
1367
|
+
checkDestroy(this.#isDestroyed);
|
|
1343
1368
|
return this.#onceTemplate('', callback, 'mapped-key-end');
|
|
1344
1369
|
}
|
|
1345
1370
|
/**
|
|
@@ -1347,6 +1372,7 @@ class TinyGamepad {
|
|
|
1347
1372
|
* @param {MappedInputCallback} callback
|
|
1348
1373
|
*/
|
|
1349
1374
|
prependMappedKeyEnd(callback) {
|
|
1375
|
+
checkDestroy(this.#isDestroyed);
|
|
1350
1376
|
return this.#prependTemplate('', callback, 'mapped-key-end');
|
|
1351
1377
|
}
|
|
1352
1378
|
/**
|
|
@@ -1354,12 +1380,14 @@ class TinyGamepad {
|
|
|
1354
1380
|
* @param {MappedInputCallback} callback
|
|
1355
1381
|
*/
|
|
1356
1382
|
offMappedKeyEnd(callback) {
|
|
1383
|
+
checkDestroy(this.#isDestroyed);
|
|
1357
1384
|
return this.#offTemplate('', callback, 'mapped-key-end');
|
|
1358
1385
|
}
|
|
1359
1386
|
/**
|
|
1360
1387
|
* Removes all callbacks from the "mapped-key-end" event.
|
|
1361
1388
|
*/
|
|
1362
1389
|
offAllMappedKeyEnd() {
|
|
1390
|
+
checkDestroy(this.#isDestroyed);
|
|
1363
1391
|
this.#callbacks.delete('mapped-key-end');
|
|
1364
1392
|
}
|
|
1365
1393
|
/////////////////////////////////////////////////////////////////
|
|
@@ -1368,6 +1396,7 @@ class TinyGamepad {
|
|
|
1368
1396
|
* @param {MappedInputCallback} callback
|
|
1369
1397
|
*/
|
|
1370
1398
|
onMappedInputStart(callback) {
|
|
1399
|
+
checkDestroy(this.#isDestroyed);
|
|
1371
1400
|
return this.#onTemplate('', callback, 'mapped-input-start');
|
|
1372
1401
|
}
|
|
1373
1402
|
/**
|
|
@@ -1376,6 +1405,7 @@ class TinyGamepad {
|
|
|
1376
1405
|
* @param {MappedInputCallback} callback
|
|
1377
1406
|
*/
|
|
1378
1407
|
onceMappedInputStart(callback) {
|
|
1408
|
+
checkDestroy(this.#isDestroyed);
|
|
1379
1409
|
return this.#onceTemplate('', callback, 'mapped-input-start');
|
|
1380
1410
|
}
|
|
1381
1411
|
/**
|
|
@@ -1383,6 +1413,7 @@ class TinyGamepad {
|
|
|
1383
1413
|
* @param {MappedInputCallback} callback
|
|
1384
1414
|
*/
|
|
1385
1415
|
prependMappedInputStart(callback) {
|
|
1416
|
+
checkDestroy(this.#isDestroyed);
|
|
1386
1417
|
return this.#prependTemplate('', callback, 'mapped-input-start');
|
|
1387
1418
|
}
|
|
1388
1419
|
/**
|
|
@@ -1390,12 +1421,14 @@ class TinyGamepad {
|
|
|
1390
1421
|
* @param {MappedInputCallback} callback
|
|
1391
1422
|
*/
|
|
1392
1423
|
offMappedInputStart(callback) {
|
|
1424
|
+
checkDestroy(this.#isDestroyed);
|
|
1393
1425
|
return this.#offTemplate('', callback, 'mapped-input-start');
|
|
1394
1426
|
}
|
|
1395
1427
|
/**
|
|
1396
1428
|
* Removes all callbacks from the "mapped-input-start" event.
|
|
1397
1429
|
*/
|
|
1398
1430
|
offAllMappedInputStart() {
|
|
1431
|
+
checkDestroy(this.#isDestroyed);
|
|
1399
1432
|
this.#callbacks.delete('mapped-input-start');
|
|
1400
1433
|
}
|
|
1401
1434
|
//////////////////////////////////////////////////////////////////
|
|
@@ -1404,6 +1437,7 @@ class TinyGamepad {
|
|
|
1404
1437
|
* @param {MappedInputCallback} callback
|
|
1405
1438
|
*/
|
|
1406
1439
|
onMappedInputEnd(callback) {
|
|
1440
|
+
checkDestroy(this.#isDestroyed);
|
|
1407
1441
|
return this.#onTemplate('', callback, 'mapped-input-end');
|
|
1408
1442
|
}
|
|
1409
1443
|
/**
|
|
@@ -1412,6 +1446,7 @@ class TinyGamepad {
|
|
|
1412
1446
|
* @param {MappedInputCallback} callback
|
|
1413
1447
|
*/
|
|
1414
1448
|
onceMappedInputEnd(callback) {
|
|
1449
|
+
checkDestroy(this.#isDestroyed);
|
|
1415
1450
|
return this.#onceTemplate('', callback, 'mapped-input-end');
|
|
1416
1451
|
}
|
|
1417
1452
|
/**
|
|
@@ -1419,6 +1454,7 @@ class TinyGamepad {
|
|
|
1419
1454
|
* @param {MappedInputCallback} callback
|
|
1420
1455
|
*/
|
|
1421
1456
|
prependMappedInputEnd(callback) {
|
|
1457
|
+
checkDestroy(this.#isDestroyed);
|
|
1422
1458
|
return this.#prependTemplate('', callback, 'mapped-input-end');
|
|
1423
1459
|
}
|
|
1424
1460
|
/**
|
|
@@ -1426,12 +1462,14 @@ class TinyGamepad {
|
|
|
1426
1462
|
* @param {MappedInputCallback} callback
|
|
1427
1463
|
*/
|
|
1428
1464
|
offMappedInputEnd(callback) {
|
|
1465
|
+
checkDestroy(this.#isDestroyed);
|
|
1429
1466
|
return this.#offTemplate('', callback, 'mapped-input-end');
|
|
1430
1467
|
}
|
|
1431
1468
|
/**
|
|
1432
1469
|
* Removes all callbacks from the "mapped-input-end" event.
|
|
1433
1470
|
*/
|
|
1434
1471
|
offAllMappedInputEnd() {
|
|
1472
|
+
checkDestroy(this.#isDestroyed);
|
|
1435
1473
|
this.#callbacks.delete('mapped-input-end');
|
|
1436
1474
|
}
|
|
1437
1475
|
/////////////////////////////////////////////////////////////
|
|
@@ -1441,6 +1479,7 @@ class TinyGamepad {
|
|
|
1441
1479
|
* @param {PayloadCallback} callback
|
|
1442
1480
|
*/
|
|
1443
1481
|
onInput(logicalName, callback) {
|
|
1482
|
+
checkDestroy(this.#isDestroyed);
|
|
1444
1483
|
return this.#onTemplate(logicalName, callback, 'input-{logicalName}');
|
|
1445
1484
|
}
|
|
1446
1485
|
/**
|
|
@@ -1450,6 +1489,7 @@ class TinyGamepad {
|
|
|
1450
1489
|
* @param {PayloadCallback} callback
|
|
1451
1490
|
*/
|
|
1452
1491
|
onceInput(logicalName, callback) {
|
|
1492
|
+
checkDestroy(this.#isDestroyed);
|
|
1453
1493
|
return this.#onceTemplate(logicalName, callback, 'input-{logicalName}');
|
|
1454
1494
|
}
|
|
1455
1495
|
/**
|
|
@@ -1458,6 +1498,7 @@ class TinyGamepad {
|
|
|
1458
1498
|
* @param {PayloadCallback} callback
|
|
1459
1499
|
*/
|
|
1460
1500
|
prependInput(logicalName, callback) {
|
|
1501
|
+
checkDestroy(this.#isDestroyed);
|
|
1461
1502
|
return this.#prependTemplate(logicalName, callback, 'input-{logicalName}');
|
|
1462
1503
|
}
|
|
1463
1504
|
/**
|
|
@@ -1466,6 +1507,7 @@ class TinyGamepad {
|
|
|
1466
1507
|
* @param {PayloadCallback} callback
|
|
1467
1508
|
*/
|
|
1468
1509
|
offInput(logicalName, callback) {
|
|
1510
|
+
checkDestroy(this.#isDestroyed);
|
|
1469
1511
|
return this.#offTemplate(logicalName, callback, 'input-{logicalName}');
|
|
1470
1512
|
}
|
|
1471
1513
|
/////////////////////////////////////////////////////////
|
|
@@ -1475,6 +1517,7 @@ class TinyGamepad {
|
|
|
1475
1517
|
* @param {PayloadCallback} callback
|
|
1476
1518
|
*/
|
|
1477
1519
|
onInputStart(logicalName, callback) {
|
|
1520
|
+
checkDestroy(this.#isDestroyed);
|
|
1478
1521
|
return this.#onTemplate(logicalName, callback, 'input-down-{logicalName}');
|
|
1479
1522
|
}
|
|
1480
1523
|
/**
|
|
@@ -1483,6 +1526,7 @@ class TinyGamepad {
|
|
|
1483
1526
|
* @param {PayloadCallback} callback
|
|
1484
1527
|
*/
|
|
1485
1528
|
onceInputStart(logicalName, callback) {
|
|
1529
|
+
checkDestroy(this.#isDestroyed);
|
|
1486
1530
|
return this.#onceTemplate(logicalName, callback, 'input-down-{logicalName}');
|
|
1487
1531
|
}
|
|
1488
1532
|
/**
|
|
@@ -1491,6 +1535,7 @@ class TinyGamepad {
|
|
|
1491
1535
|
* @param {PayloadCallback} callback
|
|
1492
1536
|
*/
|
|
1493
1537
|
prependInputStart(logicalName, callback) {
|
|
1538
|
+
checkDestroy(this.#isDestroyed);
|
|
1494
1539
|
return this.#prependTemplate(logicalName, callback, 'input-down-{logicalName}');
|
|
1495
1540
|
}
|
|
1496
1541
|
/**
|
|
@@ -1499,6 +1544,7 @@ class TinyGamepad {
|
|
|
1499
1544
|
* @param {PayloadCallback} callback
|
|
1500
1545
|
*/
|
|
1501
1546
|
offInputStart(logicalName, callback) {
|
|
1547
|
+
checkDestroy(this.#isDestroyed);
|
|
1502
1548
|
return this.#offTemplate(logicalName, callback, 'input-down-{logicalName}');
|
|
1503
1549
|
}
|
|
1504
1550
|
/////////////////////////////////////////////////////////////////////////
|
|
@@ -1508,6 +1554,7 @@ class TinyGamepad {
|
|
|
1508
1554
|
* @param {PayloadCallback} callback
|
|
1509
1555
|
*/
|
|
1510
1556
|
onInputEnd(logicalName, callback) {
|
|
1557
|
+
checkDestroy(this.#isDestroyed);
|
|
1511
1558
|
return this.#onTemplate(logicalName, callback, 'input-up-{logicalName}');
|
|
1512
1559
|
}
|
|
1513
1560
|
/**
|
|
@@ -1516,6 +1563,7 @@ class TinyGamepad {
|
|
|
1516
1563
|
* @param {PayloadCallback} callback
|
|
1517
1564
|
*/
|
|
1518
1565
|
onceInputEnd(logicalName, callback) {
|
|
1566
|
+
checkDestroy(this.#isDestroyed);
|
|
1519
1567
|
return this.#onceTemplate(logicalName, callback, 'input-up-{logicalName}');
|
|
1520
1568
|
}
|
|
1521
1569
|
/**
|
|
@@ -1524,6 +1572,7 @@ class TinyGamepad {
|
|
|
1524
1572
|
* @param {PayloadCallback} callback
|
|
1525
1573
|
*/
|
|
1526
1574
|
prependInputEnd(logicalName, callback) {
|
|
1575
|
+
checkDestroy(this.#isDestroyed);
|
|
1527
1576
|
return this.#prependTemplate(logicalName, callback, 'input-up-{logicalName}');
|
|
1528
1577
|
}
|
|
1529
1578
|
/**
|
|
@@ -1532,6 +1581,7 @@ class TinyGamepad {
|
|
|
1532
1581
|
* @param {PayloadCallback} callback
|
|
1533
1582
|
*/
|
|
1534
1583
|
offInputEnd(logicalName, callback) {
|
|
1584
|
+
checkDestroy(this.#isDestroyed);
|
|
1535
1585
|
return this.#offTemplate(logicalName, callback, 'input-up-{logicalName}');
|
|
1536
1586
|
}
|
|
1537
1587
|
///////////////////////////////////////////////////////////////////
|
|
@@ -1541,6 +1591,7 @@ class TinyGamepad {
|
|
|
1541
1591
|
* @param {PayloadCallback} callback
|
|
1542
1592
|
*/
|
|
1543
1593
|
onInputHold(logicalName, callback) {
|
|
1594
|
+
checkDestroy(this.#isDestroyed);
|
|
1544
1595
|
return this.#onTemplate(logicalName, callback, 'input-hold-{logicalName}');
|
|
1545
1596
|
}
|
|
1546
1597
|
/**
|
|
@@ -1549,6 +1600,7 @@ class TinyGamepad {
|
|
|
1549
1600
|
* @param {PayloadCallback} callback
|
|
1550
1601
|
*/
|
|
1551
1602
|
onceInputHold(logicalName, callback) {
|
|
1603
|
+
checkDestroy(this.#isDestroyed);
|
|
1552
1604
|
return this.#onceTemplate(logicalName, callback, 'input-hold-{logicalName}');
|
|
1553
1605
|
}
|
|
1554
1606
|
/**
|
|
@@ -1557,6 +1609,7 @@ class TinyGamepad {
|
|
|
1557
1609
|
* @param {PayloadCallback} callback
|
|
1558
1610
|
*/
|
|
1559
1611
|
prependInputHold(logicalName, callback) {
|
|
1612
|
+
checkDestroy(this.#isDestroyed);
|
|
1560
1613
|
return this.#prependTemplate(logicalName, callback, 'input-hold-{logicalName}');
|
|
1561
1614
|
}
|
|
1562
1615
|
/**
|
|
@@ -1565,6 +1618,7 @@ class TinyGamepad {
|
|
|
1565
1618
|
* @param {PayloadCallback} callback
|
|
1566
1619
|
*/
|
|
1567
1620
|
offInputHold(logicalName, callback) {
|
|
1621
|
+
checkDestroy(this.#isDestroyed);
|
|
1568
1622
|
return this.#offTemplate(logicalName, callback, 'input-hold-{logicalName}');
|
|
1569
1623
|
}
|
|
1570
1624
|
////////////////////////////////////////////////////////////
|
|
@@ -1574,6 +1628,7 @@ class TinyGamepad {
|
|
|
1574
1628
|
* @param {PayloadCallback} callback
|
|
1575
1629
|
*/
|
|
1576
1630
|
onInputChange(logicalName, callback) {
|
|
1631
|
+
checkDestroy(this.#isDestroyed);
|
|
1577
1632
|
return this.#onTemplate(logicalName, callback, 'input-change-{logicalName}');
|
|
1578
1633
|
}
|
|
1579
1634
|
/**
|
|
@@ -1582,6 +1637,7 @@ class TinyGamepad {
|
|
|
1582
1637
|
* @param {PayloadCallback} callback
|
|
1583
1638
|
*/
|
|
1584
1639
|
onceInputChange(logicalName, callback) {
|
|
1640
|
+
checkDestroy(this.#isDestroyed);
|
|
1585
1641
|
return this.#onceTemplate(logicalName, callback, 'input-change-{logicalName}');
|
|
1586
1642
|
}
|
|
1587
1643
|
/**
|
|
@@ -1590,6 +1646,7 @@ class TinyGamepad {
|
|
|
1590
1646
|
* @param {PayloadCallback} callback
|
|
1591
1647
|
*/
|
|
1592
1648
|
prependInputChange(logicalName, callback) {
|
|
1649
|
+
checkDestroy(this.#isDestroyed);
|
|
1593
1650
|
return this.#prependTemplate(logicalName, callback, 'input-change-{logicalName}');
|
|
1594
1651
|
}
|
|
1595
1652
|
/**
|
|
@@ -1598,6 +1655,7 @@ class TinyGamepad {
|
|
|
1598
1655
|
* @param {PayloadCallback} callback
|
|
1599
1656
|
*/
|
|
1600
1657
|
offInputChange(logicalName, callback) {
|
|
1658
|
+
checkDestroy(this.#isDestroyed);
|
|
1601
1659
|
return this.#offTemplate(logicalName, callback, 'input-change-{logicalName}');
|
|
1602
1660
|
}
|
|
1603
1661
|
////////////////////////////////////////////////////////////
|
|
@@ -1607,6 +1665,7 @@ class TinyGamepad {
|
|
|
1607
1665
|
* @param {PayloadCallback} callback
|
|
1608
1666
|
*/
|
|
1609
1667
|
onInputMove(logicalName, callback) {
|
|
1668
|
+
checkDestroy(this.#isDestroyed);
|
|
1610
1669
|
return this.#onTemplate(logicalName, callback, 'input-move-{logicalName}');
|
|
1611
1670
|
}
|
|
1612
1671
|
/**
|
|
@@ -1615,6 +1674,7 @@ class TinyGamepad {
|
|
|
1615
1674
|
* @param {PayloadCallback} callback
|
|
1616
1675
|
*/
|
|
1617
1676
|
onceInputMove(logicalName, callback) {
|
|
1677
|
+
checkDestroy(this.#isDestroyed);
|
|
1618
1678
|
return this.#onceTemplate(logicalName, callback, 'input-move-{logicalName}');
|
|
1619
1679
|
}
|
|
1620
1680
|
/**
|
|
@@ -1623,6 +1683,7 @@ class TinyGamepad {
|
|
|
1623
1683
|
* @param {PayloadCallback} callback
|
|
1624
1684
|
*/
|
|
1625
1685
|
prependInputMove(logicalName, callback) {
|
|
1686
|
+
checkDestroy(this.#isDestroyed);
|
|
1626
1687
|
return this.#prependTemplate(logicalName, callback, 'input-move-{logicalName}');
|
|
1627
1688
|
}
|
|
1628
1689
|
/**
|
|
@@ -1631,6 +1692,7 @@ class TinyGamepad {
|
|
|
1631
1692
|
* @param {PayloadCallback} callback
|
|
1632
1693
|
*/
|
|
1633
1694
|
offInputMove(logicalName, callback) {
|
|
1695
|
+
checkDestroy(this.#isDestroyed);
|
|
1634
1696
|
return this.#offTemplate(logicalName, callback, 'input-move-{logicalName}');
|
|
1635
1697
|
}
|
|
1636
1698
|
////////////////////////////////////////////////////////////
|
|
@@ -1641,6 +1703,7 @@ class TinyGamepad {
|
|
|
1641
1703
|
* @returns {Function[]}
|
|
1642
1704
|
*/
|
|
1643
1705
|
getCalls(logicalName, type = 'all') {
|
|
1706
|
+
checkDestroy(this.#isDestroyed);
|
|
1644
1707
|
if (typeof logicalName !== 'string' || logicalName.trim() === '')
|
|
1645
1708
|
throw new TypeError(`"logicalName" must be a non-empty string, received ${logicalName}`);
|
|
1646
1709
|
const validTypes = ['all', 'start', 'end', 'hold', 'change', 'move'];
|
|
@@ -1664,6 +1727,7 @@ class TinyGamepad {
|
|
|
1664
1727
|
* @param {'all'| 'start' | 'end' | 'hold' | 'change' | 'move'} [type='all']
|
|
1665
1728
|
*/
|
|
1666
1729
|
offAllInputs(logicalName, type = 'all') {
|
|
1730
|
+
checkDestroy(this.#isDestroyed);
|
|
1667
1731
|
if (typeof logicalName !== 'string' || logicalName.trim() === '')
|
|
1668
1732
|
throw new TypeError(`"logicalName" must be a non-empty string, received ${logicalName}`);
|
|
1669
1733
|
const validTypes = ['all', 'start', 'end', 'hold', 'change', 'move'];
|
|
@@ -1687,6 +1751,7 @@ class TinyGamepad {
|
|
|
1687
1751
|
* @returns {number}
|
|
1688
1752
|
*/
|
|
1689
1753
|
getCallSize(logicalName, type = 'all') {
|
|
1754
|
+
checkDestroy(this.#isDestroyed);
|
|
1690
1755
|
if (typeof logicalName !== 'string' || logicalName.trim() === '')
|
|
1691
1756
|
throw new TypeError(`"logicalName" must be a non-empty string, received ${logicalName}`);
|
|
1692
1757
|
const validTypes = ['all', 'start', 'end', 'hold', 'change', 'move'];
|
|
@@ -1729,6 +1794,7 @@ class TinyGamepad {
|
|
|
1729
1794
|
* @returns {{ type: GamepadHapticEffectType; params: GamepadEffectParameters; }} The default haptic effect settings.
|
|
1730
1795
|
*/
|
|
1731
1796
|
get defaultHapticEffect() {
|
|
1797
|
+
checkDestroy(this.#isDestroyed);
|
|
1732
1798
|
return {
|
|
1733
1799
|
type: this.#defaultHapticEffect.type,
|
|
1734
1800
|
params: { ...this.#defaultHapticEffect.params },
|
|
@@ -1740,6 +1806,7 @@ class TinyGamepad {
|
|
|
1740
1806
|
* @param {GamepadEffectParameters} params - Effect parameters.
|
|
1741
1807
|
*/
|
|
1742
1808
|
setDefaultHapticEffect(type, params) {
|
|
1809
|
+
checkDestroy(this.#isDestroyed);
|
|
1743
1810
|
if (typeof type !== 'string')
|
|
1744
1811
|
throw new TypeError(`"type" must be a valid GamepadHapticEffectType string, received ${type}`);
|
|
1745
1812
|
if (typeof params !== 'object' || params === null)
|
|
@@ -1752,6 +1819,7 @@ class TinyGamepad {
|
|
|
1752
1819
|
* @returns {boolean}
|
|
1753
1820
|
*/
|
|
1754
1821
|
hasHapticEffect() {
|
|
1822
|
+
checkDestroy(this.#isDestroyed);
|
|
1755
1823
|
const gp = this.#connectedGamepad;
|
|
1756
1824
|
if (!gp)
|
|
1757
1825
|
return false;
|
|
@@ -1767,6 +1835,7 @@ class TinyGamepad {
|
|
|
1767
1835
|
* @returns {Promise<GamepadHapticsResult>}
|
|
1768
1836
|
*/
|
|
1769
1837
|
vibrate(params, type) {
|
|
1838
|
+
checkDestroy(this.#isDestroyed);
|
|
1770
1839
|
if (params !== undefined && (typeof params !== 'object' || params === null))
|
|
1771
1840
|
throw new TypeError(`"params" must be an object if provided, received ${params}`);
|
|
1772
1841
|
if (type !== undefined && typeof type !== 'string')
|
|
@@ -1788,6 +1857,7 @@ class TinyGamepad {
|
|
|
1788
1857
|
* @param {string} id
|
|
1789
1858
|
*/
|
|
1790
1859
|
ignoreId(id) {
|
|
1860
|
+
checkDestroy(this.#isDestroyed);
|
|
1791
1861
|
if (typeof id !== 'string' || id.trim() === '')
|
|
1792
1862
|
throw new TypeError(`"id" must be a non-empty string, received ${id}`);
|
|
1793
1863
|
this.#ignoreIds.add(id);
|
|
@@ -1797,6 +1867,7 @@ class TinyGamepad {
|
|
|
1797
1867
|
* @param {string} id
|
|
1798
1868
|
*/
|
|
1799
1869
|
unignoreId(id) {
|
|
1870
|
+
checkDestroy(this.#isDestroyed);
|
|
1800
1871
|
if (typeof id !== 'string' || id.trim() === '')
|
|
1801
1872
|
throw new TypeError(`"id" must be a non-empty string, received ${id}`);
|
|
1802
1873
|
this.#ignoreIds.delete(id);
|
|
@@ -1806,6 +1877,7 @@ class TinyGamepad {
|
|
|
1806
1877
|
* @param {ConnectionCallback} callback
|
|
1807
1878
|
*/
|
|
1808
1879
|
onConnected(callback) {
|
|
1880
|
+
checkDestroy(this.#isDestroyed);
|
|
1809
1881
|
return this.#onTemplate('', callback, 'connected');
|
|
1810
1882
|
}
|
|
1811
1883
|
/**
|
|
@@ -1814,6 +1886,7 @@ class TinyGamepad {
|
|
|
1814
1886
|
* @param {ConnectionCallback} callback
|
|
1815
1887
|
*/
|
|
1816
1888
|
onceConnected(callback) {
|
|
1889
|
+
checkDestroy(this.#isDestroyed);
|
|
1817
1890
|
return this.#onceTemplate('', callback, 'connected');
|
|
1818
1891
|
}
|
|
1819
1892
|
/**
|
|
@@ -1821,6 +1894,7 @@ class TinyGamepad {
|
|
|
1821
1894
|
* @param {ConnectionCallback} callback
|
|
1822
1895
|
*/
|
|
1823
1896
|
prependConnected(callback) {
|
|
1897
|
+
checkDestroy(this.#isDestroyed);
|
|
1824
1898
|
return this.#prependTemplate('', callback, 'connected');
|
|
1825
1899
|
}
|
|
1826
1900
|
/**
|
|
@@ -1828,12 +1902,14 @@ class TinyGamepad {
|
|
|
1828
1902
|
* @param {ConnectionCallback} callback
|
|
1829
1903
|
*/
|
|
1830
1904
|
offConnected(callback) {
|
|
1905
|
+
checkDestroy(this.#isDestroyed);
|
|
1831
1906
|
return this.#offTemplate('', callback, 'connected');
|
|
1832
1907
|
}
|
|
1833
1908
|
/**
|
|
1834
1909
|
* Removes all callbacks from the "connected" event.
|
|
1835
1910
|
*/
|
|
1836
1911
|
offAllConnected() {
|
|
1912
|
+
checkDestroy(this.#isDestroyed);
|
|
1837
1913
|
this.#callbacks.delete('connected');
|
|
1838
1914
|
}
|
|
1839
1915
|
/**
|
|
@@ -1841,6 +1917,7 @@ class TinyGamepad {
|
|
|
1841
1917
|
* @param {ConnectionCallback} callback
|
|
1842
1918
|
*/
|
|
1843
1919
|
onDisconnected(callback) {
|
|
1920
|
+
checkDestroy(this.#isDestroyed);
|
|
1844
1921
|
return this.#onTemplate('', callback, 'disconnected');
|
|
1845
1922
|
}
|
|
1846
1923
|
/**
|
|
@@ -1849,6 +1926,7 @@ class TinyGamepad {
|
|
|
1849
1926
|
* @param {ConnectionCallback} callback
|
|
1850
1927
|
*/
|
|
1851
1928
|
onceDisconnected(callback) {
|
|
1929
|
+
checkDestroy(this.#isDestroyed);
|
|
1852
1930
|
return this.#onceTemplate('', callback, 'disconnected');
|
|
1853
1931
|
}
|
|
1854
1932
|
/**
|
|
@@ -1856,6 +1934,7 @@ class TinyGamepad {
|
|
|
1856
1934
|
* @param {ConnectionCallback} callback
|
|
1857
1935
|
*/
|
|
1858
1936
|
prependDisconnected(callback) {
|
|
1937
|
+
checkDestroy(this.#isDestroyed);
|
|
1859
1938
|
return this.#prependTemplate('', callback, 'disconnected');
|
|
1860
1939
|
}
|
|
1861
1940
|
/**
|
|
@@ -1863,12 +1942,14 @@ class TinyGamepad {
|
|
|
1863
1942
|
* @param {ConnectionCallback} callback
|
|
1864
1943
|
*/
|
|
1865
1944
|
offDisconnected(callback) {
|
|
1945
|
+
checkDestroy(this.#isDestroyed);
|
|
1866
1946
|
return this.#offTemplate('', callback, 'disconnected');
|
|
1867
1947
|
}
|
|
1868
1948
|
/**
|
|
1869
1949
|
* Removes all callbacks from the "disconnected" event.
|
|
1870
1950
|
*/
|
|
1871
1951
|
offAllDisconnected() {
|
|
1952
|
+
checkDestroy(this.#isDestroyed);
|
|
1872
1953
|
this.#callbacks.delete('disconnected');
|
|
1873
1954
|
}
|
|
1874
1955
|
//////////////////////////////////////////
|
|
@@ -1877,6 +1958,7 @@ class TinyGamepad {
|
|
|
1877
1958
|
* @returns {boolean}
|
|
1878
1959
|
*/
|
|
1879
1960
|
hasGamepad() {
|
|
1961
|
+
checkDestroy(this.#isDestroyed);
|
|
1880
1962
|
return this.#connectedGamepad instanceof Gamepad;
|
|
1881
1963
|
}
|
|
1882
1964
|
/**
|
|
@@ -1885,6 +1967,7 @@ class TinyGamepad {
|
|
|
1885
1967
|
* @returns {Gamepad}
|
|
1886
1968
|
*/
|
|
1887
1969
|
getGamepad() {
|
|
1970
|
+
checkDestroy(this.#isDestroyed);
|
|
1888
1971
|
if (!this.#connectedGamepad)
|
|
1889
1972
|
throw new Error('No gamepad is currently connected.');
|
|
1890
1973
|
return this.#connectedGamepad;
|
|
@@ -1895,6 +1978,7 @@ class TinyGamepad {
|
|
|
1895
1978
|
* @returns {boolean} True if a last state exists for the specified button index; otherwise, false.
|
|
1896
1979
|
*/
|
|
1897
1980
|
hasLastButtonState(index) {
|
|
1981
|
+
checkDestroy(this.#isDestroyed);
|
|
1898
1982
|
if (!this.#lastButtonStates[index])
|
|
1899
1983
|
return false;
|
|
1900
1984
|
return true;
|
|
@@ -1907,6 +1991,7 @@ class TinyGamepad {
|
|
|
1907
1991
|
* @throws {Error} If no last state exists for the specified button index.
|
|
1908
1992
|
*/
|
|
1909
1993
|
getLastButtonState(index) {
|
|
1994
|
+
checkDestroy(this.#isDestroyed);
|
|
1910
1995
|
if (!this.#lastButtonStates[index])
|
|
1911
1996
|
throw new Error(`No last button state found for index ${index}`);
|
|
1912
1997
|
return { ...this.#lastButtonStates[index] };
|
|
@@ -1918,6 +2003,7 @@ class TinyGamepad {
|
|
|
1918
2003
|
* @returns {ExportedConfig} The current configuration snapshot.
|
|
1919
2004
|
*/
|
|
1920
2005
|
exportConfig() {
|
|
2006
|
+
checkDestroy(this.#isDestroyed);
|
|
1921
2007
|
return {
|
|
1922
2008
|
expectedId: this.#expectedId,
|
|
1923
2009
|
ignoreIds: Array.from(this.#ignoreIds),
|
|
@@ -1935,6 +2021,7 @@ class TinyGamepad {
|
|
|
1935
2021
|
* or if any property has an incorrect type.
|
|
1936
2022
|
*/
|
|
1937
2023
|
importConfig(json) {
|
|
2024
|
+
checkDestroy(this.#isDestroyed);
|
|
1938
2025
|
if (typeof json !== 'string' && (typeof json !== 'object' || json === null))
|
|
1939
2026
|
throw new TypeError(`"json" must be a string or a non-null object, received: ${json}`);
|
|
1940
2027
|
const config = typeof json === 'string' ? JSON.parse(json) : json;
|
|
@@ -1972,6 +2059,7 @@ class TinyGamepad {
|
|
|
1972
2059
|
* @returns {MappedInputCallback[]}
|
|
1973
2060
|
*/
|
|
1974
2061
|
get mappedKeyStartCalls() {
|
|
2062
|
+
checkDestroy(this.#isDestroyed);
|
|
1975
2063
|
/** @type {MappedInputCallback[]} */
|
|
1976
2064
|
// @ts-ignore
|
|
1977
2065
|
const list = this.#callbacks.get('mapped-key-start');
|
|
@@ -1982,6 +2070,7 @@ class TinyGamepad {
|
|
|
1982
2070
|
* @returns {MappedInputCallback[]}
|
|
1983
2071
|
*/
|
|
1984
2072
|
get mappedKeyEndCalls() {
|
|
2073
|
+
checkDestroy(this.#isDestroyed);
|
|
1985
2074
|
/** @type {MappedInputCallback[]} */
|
|
1986
2075
|
// @ts-ignore
|
|
1987
2076
|
const list = this.#callbacks.get('mapped-key-end');
|
|
@@ -1993,6 +2082,7 @@ class TinyGamepad {
|
|
|
1993
2082
|
* @returns {string[]}
|
|
1994
2083
|
*/
|
|
1995
2084
|
get comboMappedKeys() {
|
|
2085
|
+
checkDestroy(this.#isDestroyed);
|
|
1996
2086
|
return [...this.#comboKeys];
|
|
1997
2087
|
}
|
|
1998
2088
|
/**
|
|
@@ -2000,6 +2090,7 @@ class TinyGamepad {
|
|
|
2000
2090
|
* @returns {string[]}
|
|
2001
2091
|
*/
|
|
2002
2092
|
get comboMappedInputs() {
|
|
2093
|
+
checkDestroy(this.#isDestroyed);
|
|
2003
2094
|
return [...this.#comboInputs];
|
|
2004
2095
|
}
|
|
2005
2096
|
////////////////////////////////////
|
|
@@ -2008,6 +2099,7 @@ class TinyGamepad {
|
|
|
2008
2099
|
* @returns {number}
|
|
2009
2100
|
*/
|
|
2010
2101
|
get keySequenceSize() {
|
|
2102
|
+
checkDestroy(this.#isDestroyed);
|
|
2011
2103
|
return this.#keySequences.size;
|
|
2012
2104
|
}
|
|
2013
2105
|
/**
|
|
@@ -2015,6 +2107,7 @@ class TinyGamepad {
|
|
|
2015
2107
|
* @returns {InputSequenceCallback[]}
|
|
2016
2108
|
*/
|
|
2017
2109
|
get keySequences() {
|
|
2110
|
+
checkDestroy(this.#isDestroyed);
|
|
2018
2111
|
const result = [];
|
|
2019
2112
|
for (const [, data] of this.#keySequences.entries())
|
|
2020
2113
|
result.push(data.callback);
|
|
@@ -2025,6 +2118,7 @@ class TinyGamepad {
|
|
|
2025
2118
|
* @returns {string[]}
|
|
2026
2119
|
*/
|
|
2027
2120
|
get activeMappedKeys() {
|
|
2121
|
+
checkDestroy(this.#isDestroyed);
|
|
2028
2122
|
return [...this.#activeMappedKeys];
|
|
2029
2123
|
}
|
|
2030
2124
|
////////////////////////////////////
|
|
@@ -2033,6 +2127,7 @@ class TinyGamepad {
|
|
|
2033
2127
|
* @returns {MappedInputCallback[]}
|
|
2034
2128
|
*/
|
|
2035
2129
|
get mappedInputStartCalls() {
|
|
2130
|
+
checkDestroy(this.#isDestroyed);
|
|
2036
2131
|
/** @type {MappedInputCallback[]} */
|
|
2037
2132
|
// @ts-ignore
|
|
2038
2133
|
const list = this.#callbacks.get('mapped-input-start');
|
|
@@ -2043,6 +2138,7 @@ class TinyGamepad {
|
|
|
2043
2138
|
* @returns {MappedInputCallback[]}
|
|
2044
2139
|
*/
|
|
2045
2140
|
get mappedInputEndCalls() {
|
|
2141
|
+
checkDestroy(this.#isDestroyed);
|
|
2046
2142
|
/** @type {MappedInputCallback[]} */
|
|
2047
2143
|
// @ts-ignore
|
|
2048
2144
|
const list = this.#callbacks.get('mapped-input-end');
|
|
@@ -2054,6 +2150,7 @@ class TinyGamepad {
|
|
|
2054
2150
|
* @returns {number}
|
|
2055
2151
|
*/
|
|
2056
2152
|
get inputSequenceSize() {
|
|
2153
|
+
checkDestroy(this.#isDestroyed);
|
|
2057
2154
|
return this.#inputSequences.size;
|
|
2058
2155
|
}
|
|
2059
2156
|
/**
|
|
@@ -2061,6 +2158,7 @@ class TinyGamepad {
|
|
|
2061
2158
|
* @returns {InputSequenceCallback[]}
|
|
2062
2159
|
*/
|
|
2063
2160
|
get inputSequences() {
|
|
2161
|
+
checkDestroy(this.#isDestroyed);
|
|
2064
2162
|
const result = [];
|
|
2065
2163
|
for (const [, data] of this.#inputSequences.entries())
|
|
2066
2164
|
result.push(data.callback);
|
|
@@ -2071,6 +2169,7 @@ class TinyGamepad {
|
|
|
2071
2169
|
* @returns {string[]}
|
|
2072
2170
|
*/
|
|
2073
2171
|
get activeMappedInputs() {
|
|
2172
|
+
checkDestroy(this.#isDestroyed);
|
|
2074
2173
|
return [...this.#activeMappedInputs];
|
|
2075
2174
|
}
|
|
2076
2175
|
////////////////////////////////////
|
|
@@ -2079,6 +2178,7 @@ class TinyGamepad {
|
|
|
2079
2178
|
* @returns {{ [logicalName: string]: string | string[] }}
|
|
2080
2179
|
*/
|
|
2081
2180
|
get mappedInputs() {
|
|
2181
|
+
checkDestroy(this.#isDestroyed);
|
|
2082
2182
|
/** @type {{ [logicalName: string]: string | string[] }} */
|
|
2083
2183
|
const result = {};
|
|
2084
2184
|
for (const [logicalName, physicalInput] of this.#inputMap.entries()) {
|
|
@@ -2091,6 +2191,7 @@ class TinyGamepad {
|
|
|
2091
2191
|
* @returns {number}
|
|
2092
2192
|
*/
|
|
2093
2193
|
get mappedInputSize() {
|
|
2194
|
+
checkDestroy(this.#isDestroyed);
|
|
2094
2195
|
return this.#inputMap.size;
|
|
2095
2196
|
}
|
|
2096
2197
|
////////////////////////////////////
|
|
@@ -2099,6 +2200,7 @@ class TinyGamepad {
|
|
|
2099
2200
|
* @returns {ConnectionCallback[]}
|
|
2100
2201
|
*/
|
|
2101
2202
|
get connectedCalls() {
|
|
2203
|
+
checkDestroy(this.#isDestroyed);
|
|
2102
2204
|
/** @type {ConnectionCallback[]} */
|
|
2103
2205
|
// @ts-ignore
|
|
2104
2206
|
const list = this.#callbacks.get('connected');
|
|
@@ -2109,6 +2211,7 @@ class TinyGamepad {
|
|
|
2109
2211
|
* @returns {ConnectionCallback[]}
|
|
2110
2212
|
*/
|
|
2111
2213
|
get disconnectedCalls() {
|
|
2214
|
+
checkDestroy(this.#isDestroyed);
|
|
2112
2215
|
/** @type {ConnectionCallback[]} */
|
|
2113
2216
|
// @ts-ignore
|
|
2114
2217
|
const list = this.#callbacks.get('disconnected');
|
|
@@ -2120,6 +2223,7 @@ class TinyGamepad {
|
|
|
2120
2223
|
* @returns {string[]}
|
|
2121
2224
|
*/
|
|
2122
2225
|
get ignoredDeviceIds() {
|
|
2226
|
+
checkDestroy(this.#isDestroyed);
|
|
2123
2227
|
return [...this.#ignoreIds];
|
|
2124
2228
|
}
|
|
2125
2229
|
/**
|
|
@@ -2127,6 +2231,7 @@ class TinyGamepad {
|
|
|
2127
2231
|
* @returns {string[]}
|
|
2128
2232
|
*/
|
|
2129
2233
|
get heldKeys() {
|
|
2234
|
+
checkDestroy(this.#isDestroyed);
|
|
2130
2235
|
return [...this.#heldKeys];
|
|
2131
2236
|
}
|
|
2132
2237
|
////////////////////////////////////
|
|
@@ -2135,6 +2240,7 @@ class TinyGamepad {
|
|
|
2135
2240
|
* @returns {number}
|
|
2136
2241
|
*/
|
|
2137
2242
|
get eventsSize() {
|
|
2243
|
+
checkDestroy(this.#isDestroyed);
|
|
2138
2244
|
let total = 0;
|
|
2139
2245
|
this.#callbacks.forEach((values) => {
|
|
2140
2246
|
total += values.length;
|
|
@@ -2146,6 +2252,7 @@ class TinyGamepad {
|
|
|
2146
2252
|
* @returns {number}
|
|
2147
2253
|
*/
|
|
2148
2254
|
get callSize() {
|
|
2255
|
+
checkDestroy(this.#isDestroyed);
|
|
2149
2256
|
return this.#callbacks.size;
|
|
2150
2257
|
}
|
|
2151
2258
|
/**
|
|
@@ -2153,6 +2260,7 @@ class TinyGamepad {
|
|
|
2153
2260
|
* @returns {number}
|
|
2154
2261
|
*/
|
|
2155
2262
|
get connectedCallSize() {
|
|
2263
|
+
checkDestroy(this.#isDestroyed);
|
|
2156
2264
|
const list = this.#callbacks.get('connected');
|
|
2157
2265
|
return Array.isArray(list) ? list.length : 0;
|
|
2158
2266
|
}
|
|
@@ -2161,6 +2269,7 @@ class TinyGamepad {
|
|
|
2161
2269
|
* @returns {number}
|
|
2162
2270
|
*/
|
|
2163
2271
|
get disconnectedCallSize() {
|
|
2272
|
+
checkDestroy(this.#isDestroyed);
|
|
2164
2273
|
const list = this.#callbacks.get('disconnected');
|
|
2165
2274
|
return Array.isArray(list) ? list.length : 0;
|
|
2166
2275
|
}
|
|
@@ -2169,6 +2278,7 @@ class TinyGamepad {
|
|
|
2169
2278
|
* @returns {number}
|
|
2170
2279
|
*/
|
|
2171
2280
|
get mappedKeyStartCallSize() {
|
|
2281
|
+
checkDestroy(this.#isDestroyed);
|
|
2172
2282
|
const list = this.#callbacks.get('mapped-key-start');
|
|
2173
2283
|
return Array.isArray(list) ? list.length : 0;
|
|
2174
2284
|
}
|
|
@@ -2177,6 +2287,7 @@ class TinyGamepad {
|
|
|
2177
2287
|
* @returns {number}
|
|
2178
2288
|
*/
|
|
2179
2289
|
get mappedKeyEndCallSize() {
|
|
2290
|
+
checkDestroy(this.#isDestroyed);
|
|
2180
2291
|
const list = this.#callbacks.get('mapped-key-end');
|
|
2181
2292
|
return Array.isArray(list) ? list.length : 0;
|
|
2182
2293
|
}
|
|
@@ -2185,6 +2296,7 @@ class TinyGamepad {
|
|
|
2185
2296
|
* @returns {number}
|
|
2186
2297
|
*/
|
|
2187
2298
|
get mappedInputStartCallSize() {
|
|
2299
|
+
checkDestroy(this.#isDestroyed);
|
|
2188
2300
|
const list = this.#callbacks.get('mapped-input-start');
|
|
2189
2301
|
return Array.isArray(list) ? list.length : 0;
|
|
2190
2302
|
}
|
|
@@ -2193,6 +2305,7 @@ class TinyGamepad {
|
|
|
2193
2305
|
* @returns {number}
|
|
2194
2306
|
*/
|
|
2195
2307
|
get mappedInputEndCallSize() {
|
|
2308
|
+
checkDestroy(this.#isDestroyed);
|
|
2196
2309
|
const list = this.#callbacks.get('mapped-input-end');
|
|
2197
2310
|
return Array.isArray(list) ? list.length : 0;
|
|
2198
2311
|
}
|
|
@@ -2203,6 +2316,7 @@ class TinyGamepad {
|
|
|
2203
2316
|
* @returns {KeyStatus[]} An array of button states from the last poll.
|
|
2204
2317
|
*/
|
|
2205
2318
|
get lastButtonStates() {
|
|
2319
|
+
checkDestroy(this.#isDestroyed);
|
|
2206
2320
|
/** @type {KeyStatus[]} */
|
|
2207
2321
|
const results = [];
|
|
2208
2322
|
this.#lastButtonStates.forEach((value) => {
|
|
@@ -2216,6 +2330,7 @@ class TinyGamepad {
|
|
|
2216
2330
|
* @returns {number[]} An array of axis values from the last poll.
|
|
2217
2331
|
*/
|
|
2218
2332
|
get lastAxes() {
|
|
2333
|
+
checkDestroy(this.#isDestroyed);
|
|
2219
2334
|
return [...this.#lastAxes];
|
|
2220
2335
|
}
|
|
2221
2336
|
//////////////////////////////////////
|
|
@@ -2224,6 +2339,7 @@ class TinyGamepad {
|
|
|
2224
2339
|
* @returns {InputMode}
|
|
2225
2340
|
*/
|
|
2226
2341
|
get inputMode() {
|
|
2342
|
+
checkDestroy(this.#isDestroyed);
|
|
2227
2343
|
return this.#inputMode;
|
|
2228
2344
|
}
|
|
2229
2345
|
/**
|
|
@@ -2231,6 +2347,7 @@ class TinyGamepad {
|
|
|
2231
2347
|
* @returns {Window|Element}
|
|
2232
2348
|
*/
|
|
2233
2349
|
get elementBase() {
|
|
2350
|
+
checkDestroy(this.#isDestroyed);
|
|
2234
2351
|
return this.#elementBase;
|
|
2235
2352
|
}
|
|
2236
2353
|
/**
|
|
@@ -2238,6 +2355,7 @@ class TinyGamepad {
|
|
|
2238
2355
|
* @returns {number}
|
|
2239
2356
|
*/
|
|
2240
2357
|
get timeComboInputs() {
|
|
2358
|
+
checkDestroy(this.#isDestroyed);
|
|
2241
2359
|
return this.#timeComboInputs;
|
|
2242
2360
|
}
|
|
2243
2361
|
/**
|
|
@@ -2245,6 +2363,7 @@ class TinyGamepad {
|
|
|
2245
2363
|
* @returns {number}
|
|
2246
2364
|
*/
|
|
2247
2365
|
get timeComboKeys() {
|
|
2366
|
+
checkDestroy(this.#isDestroyed);
|
|
2248
2367
|
return this.#timeComboKeys;
|
|
2249
2368
|
}
|
|
2250
2369
|
/**
|
|
@@ -2252,6 +2371,7 @@ class TinyGamepad {
|
|
|
2252
2371
|
* @returns {number}
|
|
2253
2372
|
*/
|
|
2254
2373
|
get timeMappedInputs() {
|
|
2374
|
+
checkDestroy(this.#isDestroyed);
|
|
2255
2375
|
return this.#timeMappedInputs;
|
|
2256
2376
|
}
|
|
2257
2377
|
/**
|
|
@@ -2259,6 +2379,7 @@ class TinyGamepad {
|
|
|
2259
2379
|
* @returns {number}
|
|
2260
2380
|
*/
|
|
2261
2381
|
get timeoutComboKeys() {
|
|
2382
|
+
checkDestroy(this.#isDestroyed);
|
|
2262
2383
|
return this.#timeoutComboKeys;
|
|
2263
2384
|
}
|
|
2264
2385
|
/**
|
|
@@ -2267,6 +2388,7 @@ class TinyGamepad {
|
|
|
2267
2388
|
* @param {number} value
|
|
2268
2389
|
*/
|
|
2269
2390
|
set timeoutComboKeys(value) {
|
|
2391
|
+
checkDestroy(this.#isDestroyed);
|
|
2270
2392
|
if (typeof value !== 'number' || value < 0 || !Number.isFinite(value))
|
|
2271
2393
|
throw new TypeError('Timeout combo keys must be a non-negative finite number.');
|
|
2272
2394
|
this.#timeoutComboKeys = value;
|
|
@@ -2280,6 +2402,7 @@ class TinyGamepad {
|
|
|
2280
2402
|
* @returns {number} The current axis activity sensitivity (between 0 and 1).
|
|
2281
2403
|
*/
|
|
2282
2404
|
get axisActiveSensitivity() {
|
|
2405
|
+
checkDestroy(this.#isDestroyed);
|
|
2283
2406
|
return this.#axisActiveSensitivity;
|
|
2284
2407
|
}
|
|
2285
2408
|
/**
|
|
@@ -2292,6 +2415,7 @@ class TinyGamepad {
|
|
|
2292
2415
|
* @param {number} value - The new sensitivity value between 0 and 1.
|
|
2293
2416
|
*/
|
|
2294
2417
|
set axisActiveSensitivity(value) {
|
|
2418
|
+
checkDestroy(this.#isDestroyed);
|
|
2295
2419
|
if (typeof value !== 'number' || value < 0 || value > 1)
|
|
2296
2420
|
throw new RangeError('Axis sensitivity must be a number between 0 and 1.');
|
|
2297
2421
|
this.#axisActiveSensitivity = value;
|
|
@@ -2301,6 +2425,7 @@ class TinyGamepad {
|
|
|
2301
2425
|
* @returns {number}
|
|
2302
2426
|
*/
|
|
2303
2427
|
get deadZone() {
|
|
2428
|
+
checkDestroy(this.#isDestroyed);
|
|
2304
2429
|
return this.#deadZone;
|
|
2305
2430
|
}
|
|
2306
2431
|
/**
|
|
@@ -2309,6 +2434,7 @@ class TinyGamepad {
|
|
|
2309
2434
|
* @param {number} value
|
|
2310
2435
|
*/
|
|
2311
2436
|
set deadZone(value) {
|
|
2437
|
+
checkDestroy(this.#isDestroyed);
|
|
2312
2438
|
if (typeof value !== 'number' || value < 0 || value > 1)
|
|
2313
2439
|
throw new RangeError('Dead zone must be a number between 0 and 1.');
|
|
2314
2440
|
this.#deadZone = value;
|
|
@@ -2318,6 +2444,7 @@ class TinyGamepad {
|
|
|
2318
2444
|
* @returns {string|null}
|
|
2319
2445
|
*/
|
|
2320
2446
|
get expectedId() {
|
|
2447
|
+
checkDestroy(this.#isDestroyed);
|
|
2321
2448
|
return this.#expectedId;
|
|
2322
2449
|
}
|
|
2323
2450
|
/**
|
|
@@ -2325,6 +2452,7 @@ class TinyGamepad {
|
|
|
2325
2452
|
* @returns {string}
|
|
2326
2453
|
*/
|
|
2327
2454
|
set expectedId(value) {
|
|
2455
|
+
checkDestroy(this.#isDestroyed);
|
|
2328
2456
|
if (typeof value !== 'string')
|
|
2329
2457
|
throw new TypeError('Expected device id be a string.');
|
|
2330
2458
|
this.#expectedId = value;
|
|
@@ -2344,7 +2472,6 @@ class TinyGamepad {
|
|
|
2344
2472
|
destroy() {
|
|
2345
2473
|
if (this.#isDestroyed)
|
|
2346
2474
|
return;
|
|
2347
|
-
this.#isDestroyed = true;
|
|
2348
2475
|
if (this.#animationFrame)
|
|
2349
2476
|
cancelAnimationFrame(this.#animationFrame);
|
|
2350
2477
|
if (this.#mouseKeyboardHoldLoop)
|
|
@@ -2381,6 +2508,7 @@ class TinyGamepad {
|
|
|
2381
2508
|
this.#expectedId = null;
|
|
2382
2509
|
this.#allowMouse = false;
|
|
2383
2510
|
this.#timeMappedInputs = 0;
|
|
2511
|
+
this.#isDestroyed = true;
|
|
2384
2512
|
}
|
|
2385
2513
|
}
|
|
2386
2514
|
export default TinyGamepad;
|