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,5 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var utils = require('./utils.cjs');
|
|
4
|
+
|
|
5
|
+
const checkDestroy = utils.createCheckDestroyed('TinyGamepad');
|
|
6
|
+
|
|
3
7
|
/**
|
|
4
8
|
* @typedef {Object} KeyStatus
|
|
5
9
|
* Describes the status of a key or button.
|
|
@@ -1219,6 +1223,7 @@ class TinyGamepad {
|
|
|
1219
1223
|
* - `gp`: the Gamepad object (only if the input source is a gamepad).
|
|
1220
1224
|
*/
|
|
1221
1225
|
awaitInputMapping({ timeout = 10000, eventName = 'MappingInput', canMove = false } = {}) {
|
|
1226
|
+
checkDestroy(this.#isDestroyed);
|
|
1222
1227
|
return new Promise((resolve, reject) => {
|
|
1223
1228
|
// Argument validation
|
|
1224
1229
|
if (typeof timeout !== 'number' || Number.isNaN(timeout) || timeout < 0)
|
|
@@ -1265,6 +1270,7 @@ class TinyGamepad {
|
|
|
1265
1270
|
* @param {string|string[]} physicalInput
|
|
1266
1271
|
*/
|
|
1267
1272
|
mapInput(logicalName, physicalInput) {
|
|
1273
|
+
checkDestroy(this.#isDestroyed);
|
|
1268
1274
|
if (typeof logicalName !== 'string' || !logicalName.trim())
|
|
1269
1275
|
throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${logicalName}`);
|
|
1270
1276
|
if (!(
|
|
@@ -1282,6 +1288,7 @@ class TinyGamepad {
|
|
|
1282
1288
|
* @param {string} logicalName
|
|
1283
1289
|
*/
|
|
1284
1290
|
unmapInput(logicalName) {
|
|
1291
|
+
checkDestroy(this.#isDestroyed);
|
|
1285
1292
|
if (typeof logicalName !== 'string' || !logicalName.trim())
|
|
1286
1293
|
throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${logicalName}`);
|
|
1287
1294
|
this.#inputMap.delete(logicalName);
|
|
@@ -1293,6 +1300,7 @@ class TinyGamepad {
|
|
|
1293
1300
|
* @returns {boolean}
|
|
1294
1301
|
*/
|
|
1295
1302
|
hasMappedInput(logicalName) {
|
|
1303
|
+
checkDestroy(this.#isDestroyed);
|
|
1296
1304
|
if (typeof logicalName !== 'string' || !logicalName.trim())
|
|
1297
1305
|
throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${logicalName}`);
|
|
1298
1306
|
return this.#inputMap.has(logicalName);
|
|
@@ -1304,6 +1312,7 @@ class TinyGamepad {
|
|
|
1304
1312
|
* @returns {string | string[]}
|
|
1305
1313
|
*/
|
|
1306
1314
|
getMappedInput(logicalName) {
|
|
1315
|
+
checkDestroy(this.#isDestroyed);
|
|
1307
1316
|
if (typeof logicalName !== 'string' || !logicalName.trim())
|
|
1308
1317
|
throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${logicalName}`);
|
|
1309
1318
|
const result = this.#inputMap.get(logicalName);
|
|
@@ -1315,6 +1324,7 @@ class TinyGamepad {
|
|
|
1315
1324
|
* Clears all mappings for all logical inputs.
|
|
1316
1325
|
*/
|
|
1317
1326
|
clearMapInputs() {
|
|
1327
|
+
checkDestroy(this.#isDestroyed);
|
|
1318
1328
|
this.#inputMap.clear();
|
|
1319
1329
|
}
|
|
1320
1330
|
|
|
@@ -1326,6 +1336,7 @@ class TinyGamepad {
|
|
|
1326
1336
|
* @param {InputSequenceCallback} callback - Function to invoke when the sequence is fully held
|
|
1327
1337
|
*/
|
|
1328
1338
|
registerInputSequence(sequence, callback) {
|
|
1339
|
+
checkDestroy(this.#isDestroyed);
|
|
1329
1340
|
if (!Array.isArray(sequence) || !sequence.every((s) => typeof s === 'string'))
|
|
1330
1341
|
throw new TypeError(
|
|
1331
1342
|
`'sequence' must be an array of strings, got: ${JSON.stringify(sequence)}`,
|
|
@@ -1342,6 +1353,7 @@ class TinyGamepad {
|
|
|
1342
1353
|
* @param {string[]} sequence - The sequence to remove from detection
|
|
1343
1354
|
*/
|
|
1344
1355
|
unregisterInputSequence(sequence) {
|
|
1356
|
+
checkDestroy(this.#isDestroyed);
|
|
1345
1357
|
if (!Array.isArray(sequence) || !sequence.every((s) => typeof s === 'string'))
|
|
1346
1358
|
throw new TypeError(
|
|
1347
1359
|
`'sequence' must be an array of strings, got: ${JSON.stringify(sequence)}`,
|
|
@@ -1354,6 +1366,7 @@ class TinyGamepad {
|
|
|
1354
1366
|
* Removes all registered input sequences.
|
|
1355
1367
|
*/
|
|
1356
1368
|
unregisterAllInputSequences() {
|
|
1369
|
+
checkDestroy(this.#isDestroyed);
|
|
1357
1370
|
this.#inputSequences.clear();
|
|
1358
1371
|
}
|
|
1359
1372
|
|
|
@@ -1363,6 +1376,7 @@ class TinyGamepad {
|
|
|
1363
1376
|
* @returns {boolean}
|
|
1364
1377
|
*/
|
|
1365
1378
|
hasInputSequence(sequence) {
|
|
1379
|
+
checkDestroy(this.#isDestroyed);
|
|
1366
1380
|
if (!Array.isArray(sequence) || !sequence.every((s) => typeof s === 'string'))
|
|
1367
1381
|
throw new TypeError(
|
|
1368
1382
|
`'sequence' must be an array of strings, got: ${JSON.stringify(sequence)}`,
|
|
@@ -1379,6 +1393,7 @@ class TinyGamepad {
|
|
|
1379
1393
|
* @param {InputSequenceCallback} callback - Function to invoke when the sequence is fully held
|
|
1380
1394
|
*/
|
|
1381
1395
|
registerKeySequence(sequence, callback) {
|
|
1396
|
+
checkDestroy(this.#isDestroyed);
|
|
1382
1397
|
if (!Array.isArray(sequence) || !sequence.every((s) => typeof s === 'string'))
|
|
1383
1398
|
throw new TypeError(
|
|
1384
1399
|
`'sequence' must be an array of strings, got: ${JSON.stringify(sequence)}`,
|
|
@@ -1395,6 +1410,7 @@ class TinyGamepad {
|
|
|
1395
1410
|
* @param {string[]} sequence - The sequence to remove from detection
|
|
1396
1411
|
*/
|
|
1397
1412
|
unregisterKeySequence(sequence) {
|
|
1413
|
+
checkDestroy(this.#isDestroyed);
|
|
1398
1414
|
if (!Array.isArray(sequence) || !sequence.every((s) => typeof s === 'string'))
|
|
1399
1415
|
throw new TypeError(
|
|
1400
1416
|
`'sequence' must be an array of strings, got: ${JSON.stringify(sequence)}`,
|
|
@@ -1407,6 +1423,7 @@ class TinyGamepad {
|
|
|
1407
1423
|
* Removes all registered input sequences.
|
|
1408
1424
|
*/
|
|
1409
1425
|
unregisterAllKeySequences() {
|
|
1426
|
+
checkDestroy(this.#isDestroyed);
|
|
1410
1427
|
this.#keySequences.clear();
|
|
1411
1428
|
}
|
|
1412
1429
|
|
|
@@ -1416,6 +1433,7 @@ class TinyGamepad {
|
|
|
1416
1433
|
* @returns {boolean}
|
|
1417
1434
|
*/
|
|
1418
1435
|
hasKeySequence(sequence) {
|
|
1436
|
+
checkDestroy(this.#isDestroyed);
|
|
1419
1437
|
if (!Array.isArray(sequence) || !sequence.every((s) => typeof s === 'string'))
|
|
1420
1438
|
throw new TypeError(
|
|
1421
1439
|
`'sequence' must be an array of strings, got: ${JSON.stringify(sequence)}`,
|
|
@@ -1430,6 +1448,7 @@ class TinyGamepad {
|
|
|
1430
1448
|
* Renew the currently held combo logical keys.
|
|
1431
1449
|
*/
|
|
1432
1450
|
renewComboMapped() {
|
|
1451
|
+
checkDestroy(this.#isDestroyed);
|
|
1433
1452
|
if (this.#intervalComboKeys) {
|
|
1434
1453
|
clearTimeout(this.#intervalComboKeys);
|
|
1435
1454
|
this.#intervalComboKeys = setTimeout(() => this.resetComboMapped(), this.#timeoutComboKeys);
|
|
@@ -1440,6 +1459,7 @@ class TinyGamepad {
|
|
|
1440
1459
|
* Resets the currently held key combo logical inputs.
|
|
1441
1460
|
*/
|
|
1442
1461
|
resetComboMapped() {
|
|
1462
|
+
checkDestroy(this.#isDestroyed);
|
|
1443
1463
|
if (this.#intervalComboKeys) clearTimeout(this.#intervalComboKeys);
|
|
1444
1464
|
this.#comboKeys = [];
|
|
1445
1465
|
this.#intervalComboKeys = null;
|
|
@@ -1455,6 +1475,7 @@ class TinyGamepad {
|
|
|
1455
1475
|
* @param {MappedInputCallback} callback
|
|
1456
1476
|
*/
|
|
1457
1477
|
onMappedKeyStart(callback) {
|
|
1478
|
+
checkDestroy(this.#isDestroyed);
|
|
1458
1479
|
return this.#onTemplate('', callback, 'mapped-key-start');
|
|
1459
1480
|
}
|
|
1460
1481
|
|
|
@@ -1464,6 +1485,7 @@ class TinyGamepad {
|
|
|
1464
1485
|
* @param {MappedInputCallback} callback
|
|
1465
1486
|
*/
|
|
1466
1487
|
onceMappedKeyStart(callback) {
|
|
1488
|
+
checkDestroy(this.#isDestroyed);
|
|
1467
1489
|
return this.#onceTemplate('', callback, 'mapped-key-start');
|
|
1468
1490
|
}
|
|
1469
1491
|
|
|
@@ -1472,6 +1494,7 @@ class TinyGamepad {
|
|
|
1472
1494
|
* @param {MappedInputCallback} callback
|
|
1473
1495
|
*/
|
|
1474
1496
|
prependMappedKeyStart(callback) {
|
|
1497
|
+
checkDestroy(this.#isDestroyed);
|
|
1475
1498
|
return this.#prependTemplate('', callback, 'mapped-key-start');
|
|
1476
1499
|
}
|
|
1477
1500
|
|
|
@@ -1480,6 +1503,7 @@ class TinyGamepad {
|
|
|
1480
1503
|
* @param {MappedInputCallback} callback
|
|
1481
1504
|
*/
|
|
1482
1505
|
offMappedKeyStart(callback) {
|
|
1506
|
+
checkDestroy(this.#isDestroyed);
|
|
1483
1507
|
return this.#offTemplate('', callback, 'mapped-key-start');
|
|
1484
1508
|
}
|
|
1485
1509
|
|
|
@@ -1487,6 +1511,7 @@ class TinyGamepad {
|
|
|
1487
1511
|
* Removes all callbacks from the "mapped-key-start" event.
|
|
1488
1512
|
*/
|
|
1489
1513
|
offAllMappedKeyStart() {
|
|
1514
|
+
checkDestroy(this.#isDestroyed);
|
|
1490
1515
|
this.#callbacks.delete('mapped-key-start');
|
|
1491
1516
|
}
|
|
1492
1517
|
|
|
@@ -1497,6 +1522,7 @@ class TinyGamepad {
|
|
|
1497
1522
|
* @param {MappedInputCallback} callback
|
|
1498
1523
|
*/
|
|
1499
1524
|
onMappedKeyEnd(callback) {
|
|
1525
|
+
checkDestroy(this.#isDestroyed);
|
|
1500
1526
|
return this.#onTemplate('', callback, 'mapped-key-end');
|
|
1501
1527
|
}
|
|
1502
1528
|
|
|
@@ -1506,6 +1532,7 @@ class TinyGamepad {
|
|
|
1506
1532
|
* @param {MappedInputCallback} callback
|
|
1507
1533
|
*/
|
|
1508
1534
|
onceMappedKeyEnd(callback) {
|
|
1535
|
+
checkDestroy(this.#isDestroyed);
|
|
1509
1536
|
return this.#onceTemplate('', callback, 'mapped-key-end');
|
|
1510
1537
|
}
|
|
1511
1538
|
|
|
@@ -1514,6 +1541,7 @@ class TinyGamepad {
|
|
|
1514
1541
|
* @param {MappedInputCallback} callback
|
|
1515
1542
|
*/
|
|
1516
1543
|
prependMappedKeyEnd(callback) {
|
|
1544
|
+
checkDestroy(this.#isDestroyed);
|
|
1517
1545
|
return this.#prependTemplate('', callback, 'mapped-key-end');
|
|
1518
1546
|
}
|
|
1519
1547
|
|
|
@@ -1522,6 +1550,7 @@ class TinyGamepad {
|
|
|
1522
1550
|
* @param {MappedInputCallback} callback
|
|
1523
1551
|
*/
|
|
1524
1552
|
offMappedKeyEnd(callback) {
|
|
1553
|
+
checkDestroy(this.#isDestroyed);
|
|
1525
1554
|
return this.#offTemplate('', callback, 'mapped-key-end');
|
|
1526
1555
|
}
|
|
1527
1556
|
|
|
@@ -1529,6 +1558,7 @@ class TinyGamepad {
|
|
|
1529
1558
|
* Removes all callbacks from the "mapped-key-end" event.
|
|
1530
1559
|
*/
|
|
1531
1560
|
offAllMappedKeyEnd() {
|
|
1561
|
+
checkDestroy(this.#isDestroyed);
|
|
1532
1562
|
this.#callbacks.delete('mapped-key-end');
|
|
1533
1563
|
}
|
|
1534
1564
|
|
|
@@ -1539,6 +1569,7 @@ class TinyGamepad {
|
|
|
1539
1569
|
* @param {MappedInputCallback} callback
|
|
1540
1570
|
*/
|
|
1541
1571
|
onMappedInputStart(callback) {
|
|
1572
|
+
checkDestroy(this.#isDestroyed);
|
|
1542
1573
|
return this.#onTemplate('', callback, 'mapped-input-start');
|
|
1543
1574
|
}
|
|
1544
1575
|
|
|
@@ -1548,6 +1579,7 @@ class TinyGamepad {
|
|
|
1548
1579
|
* @param {MappedInputCallback} callback
|
|
1549
1580
|
*/
|
|
1550
1581
|
onceMappedInputStart(callback) {
|
|
1582
|
+
checkDestroy(this.#isDestroyed);
|
|
1551
1583
|
return this.#onceTemplate('', callback, 'mapped-input-start');
|
|
1552
1584
|
}
|
|
1553
1585
|
|
|
@@ -1556,6 +1588,7 @@ class TinyGamepad {
|
|
|
1556
1588
|
* @param {MappedInputCallback} callback
|
|
1557
1589
|
*/
|
|
1558
1590
|
prependMappedInputStart(callback) {
|
|
1591
|
+
checkDestroy(this.#isDestroyed);
|
|
1559
1592
|
return this.#prependTemplate('', callback, 'mapped-input-start');
|
|
1560
1593
|
}
|
|
1561
1594
|
|
|
@@ -1564,6 +1597,7 @@ class TinyGamepad {
|
|
|
1564
1597
|
* @param {MappedInputCallback} callback
|
|
1565
1598
|
*/
|
|
1566
1599
|
offMappedInputStart(callback) {
|
|
1600
|
+
checkDestroy(this.#isDestroyed);
|
|
1567
1601
|
return this.#offTemplate('', callback, 'mapped-input-start');
|
|
1568
1602
|
}
|
|
1569
1603
|
|
|
@@ -1571,6 +1605,7 @@ class TinyGamepad {
|
|
|
1571
1605
|
* Removes all callbacks from the "mapped-input-start" event.
|
|
1572
1606
|
*/
|
|
1573
1607
|
offAllMappedInputStart() {
|
|
1608
|
+
checkDestroy(this.#isDestroyed);
|
|
1574
1609
|
this.#callbacks.delete('mapped-input-start');
|
|
1575
1610
|
}
|
|
1576
1611
|
|
|
@@ -1581,6 +1616,7 @@ class TinyGamepad {
|
|
|
1581
1616
|
* @param {MappedInputCallback} callback
|
|
1582
1617
|
*/
|
|
1583
1618
|
onMappedInputEnd(callback) {
|
|
1619
|
+
checkDestroy(this.#isDestroyed);
|
|
1584
1620
|
return this.#onTemplate('', callback, 'mapped-input-end');
|
|
1585
1621
|
}
|
|
1586
1622
|
|
|
@@ -1590,6 +1626,7 @@ class TinyGamepad {
|
|
|
1590
1626
|
* @param {MappedInputCallback} callback
|
|
1591
1627
|
*/
|
|
1592
1628
|
onceMappedInputEnd(callback) {
|
|
1629
|
+
checkDestroy(this.#isDestroyed);
|
|
1593
1630
|
return this.#onceTemplate('', callback, 'mapped-input-end');
|
|
1594
1631
|
}
|
|
1595
1632
|
|
|
@@ -1598,6 +1635,7 @@ class TinyGamepad {
|
|
|
1598
1635
|
* @param {MappedInputCallback} callback
|
|
1599
1636
|
*/
|
|
1600
1637
|
prependMappedInputEnd(callback) {
|
|
1638
|
+
checkDestroy(this.#isDestroyed);
|
|
1601
1639
|
return this.#prependTemplate('', callback, 'mapped-input-end');
|
|
1602
1640
|
}
|
|
1603
1641
|
|
|
@@ -1606,6 +1644,7 @@ class TinyGamepad {
|
|
|
1606
1644
|
* @param {MappedInputCallback} callback
|
|
1607
1645
|
*/
|
|
1608
1646
|
offMappedInputEnd(callback) {
|
|
1647
|
+
checkDestroy(this.#isDestroyed);
|
|
1609
1648
|
return this.#offTemplate('', callback, 'mapped-input-end');
|
|
1610
1649
|
}
|
|
1611
1650
|
|
|
@@ -1613,6 +1652,7 @@ class TinyGamepad {
|
|
|
1613
1652
|
* Removes all callbacks from the "mapped-input-end" event.
|
|
1614
1653
|
*/
|
|
1615
1654
|
offAllMappedInputEnd() {
|
|
1655
|
+
checkDestroy(this.#isDestroyed);
|
|
1616
1656
|
this.#callbacks.delete('mapped-input-end');
|
|
1617
1657
|
}
|
|
1618
1658
|
|
|
@@ -1624,6 +1664,7 @@ class TinyGamepad {
|
|
|
1624
1664
|
* @param {PayloadCallback} callback
|
|
1625
1665
|
*/
|
|
1626
1666
|
onInput(logicalName, callback) {
|
|
1667
|
+
checkDestroy(this.#isDestroyed);
|
|
1627
1668
|
return this.#onTemplate(logicalName, callback, 'input-{logicalName}');
|
|
1628
1669
|
}
|
|
1629
1670
|
|
|
@@ -1634,6 +1675,7 @@ class TinyGamepad {
|
|
|
1634
1675
|
* @param {PayloadCallback} callback
|
|
1635
1676
|
*/
|
|
1636
1677
|
onceInput(logicalName, callback) {
|
|
1678
|
+
checkDestroy(this.#isDestroyed);
|
|
1637
1679
|
return this.#onceTemplate(logicalName, callback, 'input-{logicalName}');
|
|
1638
1680
|
}
|
|
1639
1681
|
|
|
@@ -1643,6 +1685,7 @@ class TinyGamepad {
|
|
|
1643
1685
|
* @param {PayloadCallback} callback
|
|
1644
1686
|
*/
|
|
1645
1687
|
prependInput(logicalName, callback) {
|
|
1688
|
+
checkDestroy(this.#isDestroyed);
|
|
1646
1689
|
return this.#prependTemplate(logicalName, callback, 'input-{logicalName}');
|
|
1647
1690
|
}
|
|
1648
1691
|
|
|
@@ -1652,6 +1695,7 @@ class TinyGamepad {
|
|
|
1652
1695
|
* @param {PayloadCallback} callback
|
|
1653
1696
|
*/
|
|
1654
1697
|
offInput(logicalName, callback) {
|
|
1698
|
+
checkDestroy(this.#isDestroyed);
|
|
1655
1699
|
return this.#offTemplate(logicalName, callback, 'input-{logicalName}');
|
|
1656
1700
|
}
|
|
1657
1701
|
|
|
@@ -1663,6 +1707,7 @@ class TinyGamepad {
|
|
|
1663
1707
|
* @param {PayloadCallback} callback
|
|
1664
1708
|
*/
|
|
1665
1709
|
onInputStart(logicalName, callback) {
|
|
1710
|
+
checkDestroy(this.#isDestroyed);
|
|
1666
1711
|
return this.#onTemplate(logicalName, callback, 'input-down-{logicalName}');
|
|
1667
1712
|
}
|
|
1668
1713
|
|
|
@@ -1672,6 +1717,7 @@ class TinyGamepad {
|
|
|
1672
1717
|
* @param {PayloadCallback} callback
|
|
1673
1718
|
*/
|
|
1674
1719
|
onceInputStart(logicalName, callback) {
|
|
1720
|
+
checkDestroy(this.#isDestroyed);
|
|
1675
1721
|
return this.#onceTemplate(logicalName, callback, 'input-down-{logicalName}');
|
|
1676
1722
|
}
|
|
1677
1723
|
|
|
@@ -1681,6 +1727,7 @@ class TinyGamepad {
|
|
|
1681
1727
|
* @param {PayloadCallback} callback
|
|
1682
1728
|
*/
|
|
1683
1729
|
prependInputStart(logicalName, callback) {
|
|
1730
|
+
checkDestroy(this.#isDestroyed);
|
|
1684
1731
|
return this.#prependTemplate(logicalName, callback, 'input-down-{logicalName}');
|
|
1685
1732
|
}
|
|
1686
1733
|
|
|
@@ -1690,6 +1737,7 @@ class TinyGamepad {
|
|
|
1690
1737
|
* @param {PayloadCallback} callback
|
|
1691
1738
|
*/
|
|
1692
1739
|
offInputStart(logicalName, callback) {
|
|
1740
|
+
checkDestroy(this.#isDestroyed);
|
|
1693
1741
|
return this.#offTemplate(logicalName, callback, 'input-down-{logicalName}');
|
|
1694
1742
|
}
|
|
1695
1743
|
|
|
@@ -1701,6 +1749,7 @@ class TinyGamepad {
|
|
|
1701
1749
|
* @param {PayloadCallback} callback
|
|
1702
1750
|
*/
|
|
1703
1751
|
onInputEnd(logicalName, callback) {
|
|
1752
|
+
checkDestroy(this.#isDestroyed);
|
|
1704
1753
|
return this.#onTemplate(logicalName, callback, 'input-up-{logicalName}');
|
|
1705
1754
|
}
|
|
1706
1755
|
|
|
@@ -1710,6 +1759,7 @@ class TinyGamepad {
|
|
|
1710
1759
|
* @param {PayloadCallback} callback
|
|
1711
1760
|
*/
|
|
1712
1761
|
onceInputEnd(logicalName, callback) {
|
|
1762
|
+
checkDestroy(this.#isDestroyed);
|
|
1713
1763
|
return this.#onceTemplate(logicalName, callback, 'input-up-{logicalName}');
|
|
1714
1764
|
}
|
|
1715
1765
|
|
|
@@ -1719,6 +1769,7 @@ class TinyGamepad {
|
|
|
1719
1769
|
* @param {PayloadCallback} callback
|
|
1720
1770
|
*/
|
|
1721
1771
|
prependInputEnd(logicalName, callback) {
|
|
1772
|
+
checkDestroy(this.#isDestroyed);
|
|
1722
1773
|
return this.#prependTemplate(logicalName, callback, 'input-up-{logicalName}');
|
|
1723
1774
|
}
|
|
1724
1775
|
|
|
@@ -1728,6 +1779,7 @@ class TinyGamepad {
|
|
|
1728
1779
|
* @param {PayloadCallback} callback
|
|
1729
1780
|
*/
|
|
1730
1781
|
offInputEnd(logicalName, callback) {
|
|
1782
|
+
checkDestroy(this.#isDestroyed);
|
|
1731
1783
|
return this.#offTemplate(logicalName, callback, 'input-up-{logicalName}');
|
|
1732
1784
|
}
|
|
1733
1785
|
|
|
@@ -1739,6 +1791,7 @@ class TinyGamepad {
|
|
|
1739
1791
|
* @param {PayloadCallback} callback
|
|
1740
1792
|
*/
|
|
1741
1793
|
onInputHold(logicalName, callback) {
|
|
1794
|
+
checkDestroy(this.#isDestroyed);
|
|
1742
1795
|
return this.#onTemplate(logicalName, callback, 'input-hold-{logicalName}');
|
|
1743
1796
|
}
|
|
1744
1797
|
|
|
@@ -1748,6 +1801,7 @@ class TinyGamepad {
|
|
|
1748
1801
|
* @param {PayloadCallback} callback
|
|
1749
1802
|
*/
|
|
1750
1803
|
onceInputHold(logicalName, callback) {
|
|
1804
|
+
checkDestroy(this.#isDestroyed);
|
|
1751
1805
|
return this.#onceTemplate(logicalName, callback, 'input-hold-{logicalName}');
|
|
1752
1806
|
}
|
|
1753
1807
|
|
|
@@ -1757,6 +1811,7 @@ class TinyGamepad {
|
|
|
1757
1811
|
* @param {PayloadCallback} callback
|
|
1758
1812
|
*/
|
|
1759
1813
|
prependInputHold(logicalName, callback) {
|
|
1814
|
+
checkDestroy(this.#isDestroyed);
|
|
1760
1815
|
return this.#prependTemplate(logicalName, callback, 'input-hold-{logicalName}');
|
|
1761
1816
|
}
|
|
1762
1817
|
|
|
@@ -1766,6 +1821,7 @@ class TinyGamepad {
|
|
|
1766
1821
|
* @param {PayloadCallback} callback
|
|
1767
1822
|
*/
|
|
1768
1823
|
offInputHold(logicalName, callback) {
|
|
1824
|
+
checkDestroy(this.#isDestroyed);
|
|
1769
1825
|
return this.#offTemplate(logicalName, callback, 'input-hold-{logicalName}');
|
|
1770
1826
|
}
|
|
1771
1827
|
|
|
@@ -1777,6 +1833,7 @@ class TinyGamepad {
|
|
|
1777
1833
|
* @param {PayloadCallback} callback
|
|
1778
1834
|
*/
|
|
1779
1835
|
onInputChange(logicalName, callback) {
|
|
1836
|
+
checkDestroy(this.#isDestroyed);
|
|
1780
1837
|
return this.#onTemplate(logicalName, callback, 'input-change-{logicalName}');
|
|
1781
1838
|
}
|
|
1782
1839
|
|
|
@@ -1786,6 +1843,7 @@ class TinyGamepad {
|
|
|
1786
1843
|
* @param {PayloadCallback} callback
|
|
1787
1844
|
*/
|
|
1788
1845
|
onceInputChange(logicalName, callback) {
|
|
1846
|
+
checkDestroy(this.#isDestroyed);
|
|
1789
1847
|
return this.#onceTemplate(logicalName, callback, 'input-change-{logicalName}');
|
|
1790
1848
|
}
|
|
1791
1849
|
|
|
@@ -1795,6 +1853,7 @@ class TinyGamepad {
|
|
|
1795
1853
|
* @param {PayloadCallback} callback
|
|
1796
1854
|
*/
|
|
1797
1855
|
prependInputChange(logicalName, callback) {
|
|
1856
|
+
checkDestroy(this.#isDestroyed);
|
|
1798
1857
|
return this.#prependTemplate(logicalName, callback, 'input-change-{logicalName}');
|
|
1799
1858
|
}
|
|
1800
1859
|
|
|
@@ -1804,6 +1863,7 @@ class TinyGamepad {
|
|
|
1804
1863
|
* @param {PayloadCallback} callback
|
|
1805
1864
|
*/
|
|
1806
1865
|
offInputChange(logicalName, callback) {
|
|
1866
|
+
checkDestroy(this.#isDestroyed);
|
|
1807
1867
|
return this.#offTemplate(logicalName, callback, 'input-change-{logicalName}');
|
|
1808
1868
|
}
|
|
1809
1869
|
|
|
@@ -1815,6 +1875,7 @@ class TinyGamepad {
|
|
|
1815
1875
|
* @param {PayloadCallback} callback
|
|
1816
1876
|
*/
|
|
1817
1877
|
onInputMove(logicalName, callback) {
|
|
1878
|
+
checkDestroy(this.#isDestroyed);
|
|
1818
1879
|
return this.#onTemplate(logicalName, callback, 'input-move-{logicalName}');
|
|
1819
1880
|
}
|
|
1820
1881
|
|
|
@@ -1824,6 +1885,7 @@ class TinyGamepad {
|
|
|
1824
1885
|
* @param {PayloadCallback} callback
|
|
1825
1886
|
*/
|
|
1826
1887
|
onceInputMove(logicalName, callback) {
|
|
1888
|
+
checkDestroy(this.#isDestroyed);
|
|
1827
1889
|
return this.#onceTemplate(logicalName, callback, 'input-move-{logicalName}');
|
|
1828
1890
|
}
|
|
1829
1891
|
|
|
@@ -1833,6 +1895,7 @@ class TinyGamepad {
|
|
|
1833
1895
|
* @param {PayloadCallback} callback
|
|
1834
1896
|
*/
|
|
1835
1897
|
prependInputMove(logicalName, callback) {
|
|
1898
|
+
checkDestroy(this.#isDestroyed);
|
|
1836
1899
|
return this.#prependTemplate(logicalName, callback, 'input-move-{logicalName}');
|
|
1837
1900
|
}
|
|
1838
1901
|
|
|
@@ -1842,6 +1905,7 @@ class TinyGamepad {
|
|
|
1842
1905
|
* @param {PayloadCallback} callback
|
|
1843
1906
|
*/
|
|
1844
1907
|
offInputMove(logicalName, callback) {
|
|
1908
|
+
checkDestroy(this.#isDestroyed);
|
|
1845
1909
|
return this.#offTemplate(logicalName, callback, 'input-move-{logicalName}');
|
|
1846
1910
|
}
|
|
1847
1911
|
|
|
@@ -1854,6 +1918,7 @@ class TinyGamepad {
|
|
|
1854
1918
|
* @returns {Function[]}
|
|
1855
1919
|
*/
|
|
1856
1920
|
getCalls(logicalName, type = 'all') {
|
|
1921
|
+
checkDestroy(this.#isDestroyed);
|
|
1857
1922
|
if (typeof logicalName !== 'string' || logicalName.trim() === '')
|
|
1858
1923
|
throw new TypeError(`"logicalName" must be a non-empty string, received ${logicalName}`);
|
|
1859
1924
|
const validTypes = ['all', 'start', 'end', 'hold', 'change', 'move'];
|
|
@@ -1878,6 +1943,7 @@ class TinyGamepad {
|
|
|
1878
1943
|
* @param {'all'| 'start' | 'end' | 'hold' | 'change' | 'move'} [type='all']
|
|
1879
1944
|
*/
|
|
1880
1945
|
offAllInputs(logicalName, type = 'all') {
|
|
1946
|
+
checkDestroy(this.#isDestroyed);
|
|
1881
1947
|
if (typeof logicalName !== 'string' || logicalName.trim() === '')
|
|
1882
1948
|
throw new TypeError(`"logicalName" must be a non-empty string, received ${logicalName}`);
|
|
1883
1949
|
const validTypes = ['all', 'start', 'end', 'hold', 'change', 'move'];
|
|
@@ -1901,6 +1967,7 @@ class TinyGamepad {
|
|
|
1901
1967
|
* @returns {number}
|
|
1902
1968
|
*/
|
|
1903
1969
|
getCallSize(logicalName, type = 'all') {
|
|
1970
|
+
checkDestroy(this.#isDestroyed);
|
|
1904
1971
|
if (typeof logicalName !== 'string' || logicalName.trim() === '')
|
|
1905
1972
|
throw new TypeError(`"logicalName" must be a non-empty string, received ${logicalName}`);
|
|
1906
1973
|
const validTypes = ['all', 'start', 'end', 'hold', 'change', 'move'];
|
|
@@ -1946,6 +2013,7 @@ class TinyGamepad {
|
|
|
1946
2013
|
* @returns {{ type: GamepadHapticEffectType; params: GamepadEffectParameters; }} The default haptic effect settings.
|
|
1947
2014
|
*/
|
|
1948
2015
|
get defaultHapticEffect() {
|
|
2016
|
+
checkDestroy(this.#isDestroyed);
|
|
1949
2017
|
return {
|
|
1950
2018
|
type: this.#defaultHapticEffect.type,
|
|
1951
2019
|
params: { ...this.#defaultHapticEffect.params },
|
|
@@ -1958,6 +2026,7 @@ class TinyGamepad {
|
|
|
1958
2026
|
* @param {GamepadEffectParameters} params - Effect parameters.
|
|
1959
2027
|
*/
|
|
1960
2028
|
setDefaultHapticEffect(type, params) {
|
|
2029
|
+
checkDestroy(this.#isDestroyed);
|
|
1961
2030
|
if (typeof type !== 'string')
|
|
1962
2031
|
throw new TypeError(
|
|
1963
2032
|
`"type" must be a valid GamepadHapticEffectType string, received ${type}`,
|
|
@@ -1973,6 +2042,7 @@ class TinyGamepad {
|
|
|
1973
2042
|
* @returns {boolean}
|
|
1974
2043
|
*/
|
|
1975
2044
|
hasHapticEffect() {
|
|
2045
|
+
checkDestroy(this.#isDestroyed);
|
|
1976
2046
|
const gp = this.#connectedGamepad;
|
|
1977
2047
|
if (!gp) return false;
|
|
1978
2048
|
const vibrationActuator = gp.vibrationActuator;
|
|
@@ -1987,6 +2057,7 @@ class TinyGamepad {
|
|
|
1987
2057
|
* @returns {Promise<GamepadHapticsResult>}
|
|
1988
2058
|
*/
|
|
1989
2059
|
vibrate(params, type) {
|
|
2060
|
+
checkDestroy(this.#isDestroyed);
|
|
1990
2061
|
if (params !== undefined && (typeof params !== 'object' || params === null))
|
|
1991
2062
|
throw new TypeError(`"params" must be an object if provided, received ${params}`);
|
|
1992
2063
|
if (type !== undefined && typeof type !== 'string')
|
|
@@ -2011,6 +2082,7 @@ class TinyGamepad {
|
|
|
2011
2082
|
* @param {string} id
|
|
2012
2083
|
*/
|
|
2013
2084
|
ignoreId(id) {
|
|
2085
|
+
checkDestroy(this.#isDestroyed);
|
|
2014
2086
|
if (typeof id !== 'string' || id.trim() === '')
|
|
2015
2087
|
throw new TypeError(`"id" must be a non-empty string, received ${id}`);
|
|
2016
2088
|
this.#ignoreIds.add(id);
|
|
@@ -2021,6 +2093,7 @@ class TinyGamepad {
|
|
|
2021
2093
|
* @param {string} id
|
|
2022
2094
|
*/
|
|
2023
2095
|
unignoreId(id) {
|
|
2096
|
+
checkDestroy(this.#isDestroyed);
|
|
2024
2097
|
if (typeof id !== 'string' || id.trim() === '')
|
|
2025
2098
|
throw new TypeError(`"id" must be a non-empty string, received ${id}`);
|
|
2026
2099
|
this.#ignoreIds.delete(id);
|
|
@@ -2031,6 +2104,7 @@ class TinyGamepad {
|
|
|
2031
2104
|
* @param {ConnectionCallback} callback
|
|
2032
2105
|
*/
|
|
2033
2106
|
onConnected(callback) {
|
|
2107
|
+
checkDestroy(this.#isDestroyed);
|
|
2034
2108
|
return this.#onTemplate('', callback, 'connected');
|
|
2035
2109
|
}
|
|
2036
2110
|
|
|
@@ -2040,6 +2114,7 @@ class TinyGamepad {
|
|
|
2040
2114
|
* @param {ConnectionCallback} callback
|
|
2041
2115
|
*/
|
|
2042
2116
|
onceConnected(callback) {
|
|
2117
|
+
checkDestroy(this.#isDestroyed);
|
|
2043
2118
|
return this.#onceTemplate('', callback, 'connected');
|
|
2044
2119
|
}
|
|
2045
2120
|
|
|
@@ -2048,6 +2123,7 @@ class TinyGamepad {
|
|
|
2048
2123
|
* @param {ConnectionCallback} callback
|
|
2049
2124
|
*/
|
|
2050
2125
|
prependConnected(callback) {
|
|
2126
|
+
checkDestroy(this.#isDestroyed);
|
|
2051
2127
|
return this.#prependTemplate('', callback, 'connected');
|
|
2052
2128
|
}
|
|
2053
2129
|
|
|
@@ -2056,6 +2132,7 @@ class TinyGamepad {
|
|
|
2056
2132
|
* @param {ConnectionCallback} callback
|
|
2057
2133
|
*/
|
|
2058
2134
|
offConnected(callback) {
|
|
2135
|
+
checkDestroy(this.#isDestroyed);
|
|
2059
2136
|
return this.#offTemplate('', callback, 'connected');
|
|
2060
2137
|
}
|
|
2061
2138
|
|
|
@@ -2063,6 +2140,7 @@ class TinyGamepad {
|
|
|
2063
2140
|
* Removes all callbacks from the "connected" event.
|
|
2064
2141
|
*/
|
|
2065
2142
|
offAllConnected() {
|
|
2143
|
+
checkDestroy(this.#isDestroyed);
|
|
2066
2144
|
this.#callbacks.delete('connected');
|
|
2067
2145
|
}
|
|
2068
2146
|
|
|
@@ -2071,6 +2149,7 @@ class TinyGamepad {
|
|
|
2071
2149
|
* @param {ConnectionCallback} callback
|
|
2072
2150
|
*/
|
|
2073
2151
|
onDisconnected(callback) {
|
|
2152
|
+
checkDestroy(this.#isDestroyed);
|
|
2074
2153
|
return this.#onTemplate('', callback, 'disconnected');
|
|
2075
2154
|
}
|
|
2076
2155
|
|
|
@@ -2080,6 +2159,7 @@ class TinyGamepad {
|
|
|
2080
2159
|
* @param {ConnectionCallback} callback
|
|
2081
2160
|
*/
|
|
2082
2161
|
onceDisconnected(callback) {
|
|
2162
|
+
checkDestroy(this.#isDestroyed);
|
|
2083
2163
|
return this.#onceTemplate('', callback, 'disconnected');
|
|
2084
2164
|
}
|
|
2085
2165
|
|
|
@@ -2088,6 +2168,7 @@ class TinyGamepad {
|
|
|
2088
2168
|
* @param {ConnectionCallback} callback
|
|
2089
2169
|
*/
|
|
2090
2170
|
prependDisconnected(callback) {
|
|
2171
|
+
checkDestroy(this.#isDestroyed);
|
|
2091
2172
|
return this.#prependTemplate('', callback, 'disconnected');
|
|
2092
2173
|
}
|
|
2093
2174
|
|
|
@@ -2096,6 +2177,7 @@ class TinyGamepad {
|
|
|
2096
2177
|
* @param {ConnectionCallback} callback
|
|
2097
2178
|
*/
|
|
2098
2179
|
offDisconnected(callback) {
|
|
2180
|
+
checkDestroy(this.#isDestroyed);
|
|
2099
2181
|
return this.#offTemplate('', callback, 'disconnected');
|
|
2100
2182
|
}
|
|
2101
2183
|
|
|
@@ -2103,6 +2185,7 @@ class TinyGamepad {
|
|
|
2103
2185
|
* Removes all callbacks from the "disconnected" event.
|
|
2104
2186
|
*/
|
|
2105
2187
|
offAllDisconnected() {
|
|
2188
|
+
checkDestroy(this.#isDestroyed);
|
|
2106
2189
|
this.#callbacks.delete('disconnected');
|
|
2107
2190
|
}
|
|
2108
2191
|
|
|
@@ -2113,6 +2196,7 @@ class TinyGamepad {
|
|
|
2113
2196
|
* @returns {boolean}
|
|
2114
2197
|
*/
|
|
2115
2198
|
hasGamepad() {
|
|
2199
|
+
checkDestroy(this.#isDestroyed);
|
|
2116
2200
|
return this.#connectedGamepad instanceof Gamepad;
|
|
2117
2201
|
}
|
|
2118
2202
|
|
|
@@ -2122,6 +2206,7 @@ class TinyGamepad {
|
|
|
2122
2206
|
* @returns {Gamepad}
|
|
2123
2207
|
*/
|
|
2124
2208
|
getGamepad() {
|
|
2209
|
+
checkDestroy(this.#isDestroyed);
|
|
2125
2210
|
if (!this.#connectedGamepad) throw new Error('No gamepad is currently connected.');
|
|
2126
2211
|
return this.#connectedGamepad;
|
|
2127
2212
|
}
|
|
@@ -2132,6 +2217,7 @@ class TinyGamepad {
|
|
|
2132
2217
|
* @returns {boolean} True if a last state exists for the specified button index; otherwise, false.
|
|
2133
2218
|
*/
|
|
2134
2219
|
hasLastButtonState(index) {
|
|
2220
|
+
checkDestroy(this.#isDestroyed);
|
|
2135
2221
|
if (!this.#lastButtonStates[index]) return false;
|
|
2136
2222
|
return true;
|
|
2137
2223
|
}
|
|
@@ -2144,6 +2230,7 @@ class TinyGamepad {
|
|
|
2144
2230
|
* @throws {Error} If no last state exists for the specified button index.
|
|
2145
2231
|
*/
|
|
2146
2232
|
getLastButtonState(index) {
|
|
2233
|
+
checkDestroy(this.#isDestroyed);
|
|
2147
2234
|
if (!this.#lastButtonStates[index])
|
|
2148
2235
|
throw new Error(`No last button state found for index ${index}`);
|
|
2149
2236
|
return { ...this.#lastButtonStates[index] };
|
|
@@ -2157,6 +2244,7 @@ class TinyGamepad {
|
|
|
2157
2244
|
* @returns {ExportedConfig} The current configuration snapshot.
|
|
2158
2245
|
*/
|
|
2159
2246
|
exportConfig() {
|
|
2247
|
+
checkDestroy(this.#isDestroyed);
|
|
2160
2248
|
return {
|
|
2161
2249
|
expectedId: this.#expectedId,
|
|
2162
2250
|
ignoreIds: Array.from(this.#ignoreIds),
|
|
@@ -2175,6 +2263,7 @@ class TinyGamepad {
|
|
|
2175
2263
|
* or if any property has an incorrect type.
|
|
2176
2264
|
*/
|
|
2177
2265
|
importConfig(json) {
|
|
2266
|
+
checkDestroy(this.#isDestroyed);
|
|
2178
2267
|
if (typeof json !== 'string' && (typeof json !== 'object' || json === null))
|
|
2179
2268
|
throw new TypeError(`"json" must be a string or a non-null object, received: ${json}`);
|
|
2180
2269
|
|
|
@@ -2222,6 +2311,7 @@ class TinyGamepad {
|
|
|
2222
2311
|
* @returns {MappedInputCallback[]}
|
|
2223
2312
|
*/
|
|
2224
2313
|
get mappedKeyStartCalls() {
|
|
2314
|
+
checkDestroy(this.#isDestroyed);
|
|
2225
2315
|
/** @type {MappedInputCallback[]} */
|
|
2226
2316
|
// @ts-ignore
|
|
2227
2317
|
const list = this.#callbacks.get('mapped-key-start');
|
|
@@ -2233,6 +2323,7 @@ class TinyGamepad {
|
|
|
2233
2323
|
* @returns {MappedInputCallback[]}
|
|
2234
2324
|
*/
|
|
2235
2325
|
get mappedKeyEndCalls() {
|
|
2326
|
+
checkDestroy(this.#isDestroyed);
|
|
2236
2327
|
/** @type {MappedInputCallback[]} */
|
|
2237
2328
|
// @ts-ignore
|
|
2238
2329
|
const list = this.#callbacks.get('mapped-key-end');
|
|
@@ -2246,6 +2337,7 @@ class TinyGamepad {
|
|
|
2246
2337
|
* @returns {string[]}
|
|
2247
2338
|
*/
|
|
2248
2339
|
get comboMappedKeys() {
|
|
2340
|
+
checkDestroy(this.#isDestroyed);
|
|
2249
2341
|
return [...this.#comboKeys];
|
|
2250
2342
|
}
|
|
2251
2343
|
|
|
@@ -2254,6 +2346,7 @@ class TinyGamepad {
|
|
|
2254
2346
|
* @returns {string[]}
|
|
2255
2347
|
*/
|
|
2256
2348
|
get comboMappedInputs() {
|
|
2349
|
+
checkDestroy(this.#isDestroyed);
|
|
2257
2350
|
return [...this.#comboInputs];
|
|
2258
2351
|
}
|
|
2259
2352
|
|
|
@@ -2264,6 +2357,7 @@ class TinyGamepad {
|
|
|
2264
2357
|
* @returns {number}
|
|
2265
2358
|
*/
|
|
2266
2359
|
get keySequenceSize() {
|
|
2360
|
+
checkDestroy(this.#isDestroyed);
|
|
2267
2361
|
return this.#keySequences.size;
|
|
2268
2362
|
}
|
|
2269
2363
|
|
|
@@ -2272,6 +2366,7 @@ class TinyGamepad {
|
|
|
2272
2366
|
* @returns {InputSequenceCallback[]}
|
|
2273
2367
|
*/
|
|
2274
2368
|
get keySequences() {
|
|
2369
|
+
checkDestroy(this.#isDestroyed);
|
|
2275
2370
|
const result = [];
|
|
2276
2371
|
for (const [, data] of this.#keySequences.entries()) result.push(data.callback);
|
|
2277
2372
|
return result;
|
|
@@ -2282,6 +2377,7 @@ class TinyGamepad {
|
|
|
2282
2377
|
* @returns {string[]}
|
|
2283
2378
|
*/
|
|
2284
2379
|
get activeMappedKeys() {
|
|
2380
|
+
checkDestroy(this.#isDestroyed);
|
|
2285
2381
|
return [...this.#activeMappedKeys];
|
|
2286
2382
|
}
|
|
2287
2383
|
|
|
@@ -2292,6 +2388,7 @@ class TinyGamepad {
|
|
|
2292
2388
|
* @returns {MappedInputCallback[]}
|
|
2293
2389
|
*/
|
|
2294
2390
|
get mappedInputStartCalls() {
|
|
2391
|
+
checkDestroy(this.#isDestroyed);
|
|
2295
2392
|
/** @type {MappedInputCallback[]} */
|
|
2296
2393
|
// @ts-ignore
|
|
2297
2394
|
const list = this.#callbacks.get('mapped-input-start');
|
|
@@ -2303,6 +2400,7 @@ class TinyGamepad {
|
|
|
2303
2400
|
* @returns {MappedInputCallback[]}
|
|
2304
2401
|
*/
|
|
2305
2402
|
get mappedInputEndCalls() {
|
|
2403
|
+
checkDestroy(this.#isDestroyed);
|
|
2306
2404
|
/** @type {MappedInputCallback[]} */
|
|
2307
2405
|
// @ts-ignore
|
|
2308
2406
|
const list = this.#callbacks.get('mapped-input-end');
|
|
@@ -2316,6 +2414,7 @@ class TinyGamepad {
|
|
|
2316
2414
|
* @returns {number}
|
|
2317
2415
|
*/
|
|
2318
2416
|
get inputSequenceSize() {
|
|
2417
|
+
checkDestroy(this.#isDestroyed);
|
|
2319
2418
|
return this.#inputSequences.size;
|
|
2320
2419
|
}
|
|
2321
2420
|
|
|
@@ -2324,6 +2423,7 @@ class TinyGamepad {
|
|
|
2324
2423
|
* @returns {InputSequenceCallback[]}
|
|
2325
2424
|
*/
|
|
2326
2425
|
get inputSequences() {
|
|
2426
|
+
checkDestroy(this.#isDestroyed);
|
|
2327
2427
|
const result = [];
|
|
2328
2428
|
for (const [, data] of this.#inputSequences.entries()) result.push(data.callback);
|
|
2329
2429
|
return result;
|
|
@@ -2334,6 +2434,7 @@ class TinyGamepad {
|
|
|
2334
2434
|
* @returns {string[]}
|
|
2335
2435
|
*/
|
|
2336
2436
|
get activeMappedInputs() {
|
|
2437
|
+
checkDestroy(this.#isDestroyed);
|
|
2337
2438
|
return [...this.#activeMappedInputs];
|
|
2338
2439
|
}
|
|
2339
2440
|
|
|
@@ -2344,6 +2445,7 @@ class TinyGamepad {
|
|
|
2344
2445
|
* @returns {{ [logicalName: string]: string | string[] }}
|
|
2345
2446
|
*/
|
|
2346
2447
|
get mappedInputs() {
|
|
2448
|
+
checkDestroy(this.#isDestroyed);
|
|
2347
2449
|
/** @type {{ [logicalName: string]: string | string[] }} */
|
|
2348
2450
|
const result = {};
|
|
2349
2451
|
for (const [logicalName, physicalInput] of this.#inputMap.entries()) {
|
|
@@ -2357,6 +2459,7 @@ class TinyGamepad {
|
|
|
2357
2459
|
* @returns {number}
|
|
2358
2460
|
*/
|
|
2359
2461
|
get mappedInputSize() {
|
|
2462
|
+
checkDestroy(this.#isDestroyed);
|
|
2360
2463
|
return this.#inputMap.size;
|
|
2361
2464
|
}
|
|
2362
2465
|
|
|
@@ -2367,6 +2470,7 @@ class TinyGamepad {
|
|
|
2367
2470
|
* @returns {ConnectionCallback[]}
|
|
2368
2471
|
*/
|
|
2369
2472
|
get connectedCalls() {
|
|
2473
|
+
checkDestroy(this.#isDestroyed);
|
|
2370
2474
|
/** @type {ConnectionCallback[]} */
|
|
2371
2475
|
// @ts-ignore
|
|
2372
2476
|
const list = this.#callbacks.get('connected');
|
|
@@ -2378,6 +2482,7 @@ class TinyGamepad {
|
|
|
2378
2482
|
* @returns {ConnectionCallback[]}
|
|
2379
2483
|
*/
|
|
2380
2484
|
get disconnectedCalls() {
|
|
2485
|
+
checkDestroy(this.#isDestroyed);
|
|
2381
2486
|
/** @type {ConnectionCallback[]} */
|
|
2382
2487
|
// @ts-ignore
|
|
2383
2488
|
const list = this.#callbacks.get('disconnected');
|
|
@@ -2391,6 +2496,7 @@ class TinyGamepad {
|
|
|
2391
2496
|
* @returns {string[]}
|
|
2392
2497
|
*/
|
|
2393
2498
|
get ignoredDeviceIds() {
|
|
2499
|
+
checkDestroy(this.#isDestroyed);
|
|
2394
2500
|
return [...this.#ignoreIds];
|
|
2395
2501
|
}
|
|
2396
2502
|
|
|
@@ -2399,6 +2505,7 @@ class TinyGamepad {
|
|
|
2399
2505
|
* @returns {string[]}
|
|
2400
2506
|
*/
|
|
2401
2507
|
get heldKeys() {
|
|
2508
|
+
checkDestroy(this.#isDestroyed);
|
|
2402
2509
|
return [...this.#heldKeys];
|
|
2403
2510
|
}
|
|
2404
2511
|
|
|
@@ -2409,6 +2516,7 @@ class TinyGamepad {
|
|
|
2409
2516
|
* @returns {number}
|
|
2410
2517
|
*/
|
|
2411
2518
|
get eventsSize() {
|
|
2519
|
+
checkDestroy(this.#isDestroyed);
|
|
2412
2520
|
let total = 0;
|
|
2413
2521
|
this.#callbacks.forEach((values) => {
|
|
2414
2522
|
total += values.length;
|
|
@@ -2421,6 +2529,7 @@ class TinyGamepad {
|
|
|
2421
2529
|
* @returns {number}
|
|
2422
2530
|
*/
|
|
2423
2531
|
get callSize() {
|
|
2532
|
+
checkDestroy(this.#isDestroyed);
|
|
2424
2533
|
return this.#callbacks.size;
|
|
2425
2534
|
}
|
|
2426
2535
|
|
|
@@ -2429,6 +2538,7 @@ class TinyGamepad {
|
|
|
2429
2538
|
* @returns {number}
|
|
2430
2539
|
*/
|
|
2431
2540
|
get connectedCallSize() {
|
|
2541
|
+
checkDestroy(this.#isDestroyed);
|
|
2432
2542
|
const list = this.#callbacks.get('connected');
|
|
2433
2543
|
return Array.isArray(list) ? list.length : 0;
|
|
2434
2544
|
}
|
|
@@ -2438,6 +2548,7 @@ class TinyGamepad {
|
|
|
2438
2548
|
* @returns {number}
|
|
2439
2549
|
*/
|
|
2440
2550
|
get disconnectedCallSize() {
|
|
2551
|
+
checkDestroy(this.#isDestroyed);
|
|
2441
2552
|
const list = this.#callbacks.get('disconnected');
|
|
2442
2553
|
return Array.isArray(list) ? list.length : 0;
|
|
2443
2554
|
}
|
|
@@ -2447,6 +2558,7 @@ class TinyGamepad {
|
|
|
2447
2558
|
* @returns {number}
|
|
2448
2559
|
*/
|
|
2449
2560
|
get mappedKeyStartCallSize() {
|
|
2561
|
+
checkDestroy(this.#isDestroyed);
|
|
2450
2562
|
const list = this.#callbacks.get('mapped-key-start');
|
|
2451
2563
|
return Array.isArray(list) ? list.length : 0;
|
|
2452
2564
|
}
|
|
@@ -2456,6 +2568,7 @@ class TinyGamepad {
|
|
|
2456
2568
|
* @returns {number}
|
|
2457
2569
|
*/
|
|
2458
2570
|
get mappedKeyEndCallSize() {
|
|
2571
|
+
checkDestroy(this.#isDestroyed);
|
|
2459
2572
|
const list = this.#callbacks.get('mapped-key-end');
|
|
2460
2573
|
return Array.isArray(list) ? list.length : 0;
|
|
2461
2574
|
}
|
|
@@ -2465,6 +2578,7 @@ class TinyGamepad {
|
|
|
2465
2578
|
* @returns {number}
|
|
2466
2579
|
*/
|
|
2467
2580
|
get mappedInputStartCallSize() {
|
|
2581
|
+
checkDestroy(this.#isDestroyed);
|
|
2468
2582
|
const list = this.#callbacks.get('mapped-input-start');
|
|
2469
2583
|
return Array.isArray(list) ? list.length : 0;
|
|
2470
2584
|
}
|
|
@@ -2474,6 +2588,7 @@ class TinyGamepad {
|
|
|
2474
2588
|
* @returns {number}
|
|
2475
2589
|
*/
|
|
2476
2590
|
get mappedInputEndCallSize() {
|
|
2591
|
+
checkDestroy(this.#isDestroyed);
|
|
2477
2592
|
const list = this.#callbacks.get('mapped-input-end');
|
|
2478
2593
|
return Array.isArray(list) ? list.length : 0;
|
|
2479
2594
|
}
|
|
@@ -2486,6 +2601,7 @@ class TinyGamepad {
|
|
|
2486
2601
|
* @returns {KeyStatus[]} An array of button states from the last poll.
|
|
2487
2602
|
*/
|
|
2488
2603
|
get lastButtonStates() {
|
|
2604
|
+
checkDestroy(this.#isDestroyed);
|
|
2489
2605
|
/** @type {KeyStatus[]} */
|
|
2490
2606
|
const results = [];
|
|
2491
2607
|
this.#lastButtonStates.forEach((value) => {
|
|
@@ -2500,6 +2616,7 @@ class TinyGamepad {
|
|
|
2500
2616
|
* @returns {number[]} An array of axis values from the last poll.
|
|
2501
2617
|
*/
|
|
2502
2618
|
get lastAxes() {
|
|
2619
|
+
checkDestroy(this.#isDestroyed);
|
|
2503
2620
|
return [...this.#lastAxes];
|
|
2504
2621
|
}
|
|
2505
2622
|
|
|
@@ -2510,6 +2627,7 @@ class TinyGamepad {
|
|
|
2510
2627
|
* @returns {InputMode}
|
|
2511
2628
|
*/
|
|
2512
2629
|
get inputMode() {
|
|
2630
|
+
checkDestroy(this.#isDestroyed);
|
|
2513
2631
|
return this.#inputMode;
|
|
2514
2632
|
}
|
|
2515
2633
|
|
|
@@ -2518,6 +2636,7 @@ class TinyGamepad {
|
|
|
2518
2636
|
* @returns {Window|Element}
|
|
2519
2637
|
*/
|
|
2520
2638
|
get elementBase() {
|
|
2639
|
+
checkDestroy(this.#isDestroyed);
|
|
2521
2640
|
return this.#elementBase;
|
|
2522
2641
|
}
|
|
2523
2642
|
|
|
@@ -2526,6 +2645,7 @@ class TinyGamepad {
|
|
|
2526
2645
|
* @returns {number}
|
|
2527
2646
|
*/
|
|
2528
2647
|
get timeComboInputs() {
|
|
2648
|
+
checkDestroy(this.#isDestroyed);
|
|
2529
2649
|
return this.#timeComboInputs;
|
|
2530
2650
|
}
|
|
2531
2651
|
|
|
@@ -2534,6 +2654,7 @@ class TinyGamepad {
|
|
|
2534
2654
|
* @returns {number}
|
|
2535
2655
|
*/
|
|
2536
2656
|
get timeComboKeys() {
|
|
2657
|
+
checkDestroy(this.#isDestroyed);
|
|
2537
2658
|
return this.#timeComboKeys;
|
|
2538
2659
|
}
|
|
2539
2660
|
|
|
@@ -2542,6 +2663,7 @@ class TinyGamepad {
|
|
|
2542
2663
|
* @returns {number}
|
|
2543
2664
|
*/
|
|
2544
2665
|
get timeMappedInputs() {
|
|
2666
|
+
checkDestroy(this.#isDestroyed);
|
|
2545
2667
|
return this.#timeMappedInputs;
|
|
2546
2668
|
}
|
|
2547
2669
|
|
|
@@ -2550,6 +2672,7 @@ class TinyGamepad {
|
|
|
2550
2672
|
* @returns {number}
|
|
2551
2673
|
*/
|
|
2552
2674
|
get timeoutComboKeys() {
|
|
2675
|
+
checkDestroy(this.#isDestroyed);
|
|
2553
2676
|
return this.#timeoutComboKeys;
|
|
2554
2677
|
}
|
|
2555
2678
|
|
|
@@ -2559,6 +2682,7 @@ class TinyGamepad {
|
|
|
2559
2682
|
* @param {number} value
|
|
2560
2683
|
*/
|
|
2561
2684
|
set timeoutComboKeys(value) {
|
|
2685
|
+
checkDestroy(this.#isDestroyed);
|
|
2562
2686
|
if (typeof value !== 'number' || value < 0 || !Number.isFinite(value))
|
|
2563
2687
|
throw new TypeError('Timeout combo keys must be a non-negative finite number.');
|
|
2564
2688
|
this.#timeoutComboKeys = value;
|
|
@@ -2573,6 +2697,7 @@ class TinyGamepad {
|
|
|
2573
2697
|
* @returns {number} The current axis activity sensitivity (between 0 and 1).
|
|
2574
2698
|
*/
|
|
2575
2699
|
get axisActiveSensitivity() {
|
|
2700
|
+
checkDestroy(this.#isDestroyed);
|
|
2576
2701
|
return this.#axisActiveSensitivity;
|
|
2577
2702
|
}
|
|
2578
2703
|
|
|
@@ -2586,6 +2711,7 @@ class TinyGamepad {
|
|
|
2586
2711
|
* @param {number} value - The new sensitivity value between 0 and 1.
|
|
2587
2712
|
*/
|
|
2588
2713
|
set axisActiveSensitivity(value) {
|
|
2714
|
+
checkDestroy(this.#isDestroyed);
|
|
2589
2715
|
if (typeof value !== 'number' || value < 0 || value > 1)
|
|
2590
2716
|
throw new RangeError('Axis sensitivity must be a number between 0 and 1.');
|
|
2591
2717
|
this.#axisActiveSensitivity = value;
|
|
@@ -2596,6 +2722,7 @@ class TinyGamepad {
|
|
|
2596
2722
|
* @returns {number}
|
|
2597
2723
|
*/
|
|
2598
2724
|
get deadZone() {
|
|
2725
|
+
checkDestroy(this.#isDestroyed);
|
|
2599
2726
|
return this.#deadZone;
|
|
2600
2727
|
}
|
|
2601
2728
|
|
|
@@ -2605,6 +2732,7 @@ class TinyGamepad {
|
|
|
2605
2732
|
* @param {number} value
|
|
2606
2733
|
*/
|
|
2607
2734
|
set deadZone(value) {
|
|
2735
|
+
checkDestroy(this.#isDestroyed);
|
|
2608
2736
|
if (typeof value !== 'number' || value < 0 || value > 1)
|
|
2609
2737
|
throw new RangeError('Dead zone must be a number between 0 and 1.');
|
|
2610
2738
|
this.#deadZone = value;
|
|
@@ -2615,6 +2743,7 @@ class TinyGamepad {
|
|
|
2615
2743
|
* @returns {string|null}
|
|
2616
2744
|
*/
|
|
2617
2745
|
get expectedId() {
|
|
2746
|
+
checkDestroy(this.#isDestroyed);
|
|
2618
2747
|
return this.#expectedId;
|
|
2619
2748
|
}
|
|
2620
2749
|
|
|
@@ -2623,6 +2752,7 @@ class TinyGamepad {
|
|
|
2623
2752
|
* @returns {string}
|
|
2624
2753
|
*/
|
|
2625
2754
|
set expectedId(value) {
|
|
2755
|
+
checkDestroy(this.#isDestroyed);
|
|
2626
2756
|
if (typeof value !== 'string') throw new TypeError('Expected device id be a string.');
|
|
2627
2757
|
this.#expectedId = value;
|
|
2628
2758
|
}
|
|
@@ -2643,7 +2773,6 @@ class TinyGamepad {
|
|
|
2643
2773
|
*/
|
|
2644
2774
|
destroy() {
|
|
2645
2775
|
if (this.#isDestroyed) return;
|
|
2646
|
-
this.#isDestroyed = true;
|
|
2647
2776
|
|
|
2648
2777
|
if (this.#animationFrame) cancelAnimationFrame(this.#animationFrame);
|
|
2649
2778
|
if (this.#mouseKeyboardHoldLoop) cancelAnimationFrame(this.#mouseKeyboardHoldLoop);
|
|
@@ -2682,6 +2811,7 @@ class TinyGamepad {
|
|
|
2682
2811
|
this.#expectedId = null;
|
|
2683
2812
|
this.#allowMouse = false;
|
|
2684
2813
|
this.#timeMappedInputs = 0;
|
|
2814
|
+
this.#isDestroyed = true;
|
|
2685
2815
|
}
|
|
2686
2816
|
}
|
|
2687
2817
|
|