This commit is contained in:
Francisco Hodge 2025-04-01 12:36:08 -04:00
parent f82ae2369b
commit 485292ce68
2 changed files with 15 additions and 1 deletions

View File

@ -1614,7 +1614,9 @@ class SimpleKeyboard {
loadModules() {
if (Array.isArray(this.options.modules)) {
this.options.modules.forEach((KeyboardModule) => {
const keyboardModule = new KeyboardModule(this);
const keyboardModule = this.utilities.isConstructor(KeyboardModule) ?
new KeyboardModule(this) : KeyboardModule(this);
keyboardModule.init && keyboardModule.init(this);
});

View File

@ -561,6 +561,18 @@ class Utilities {
* Reusable empty function
*/
static noop = () => {};
/**
* Check if a function is a constructor
*/
isConstructor(f: any) {
try {
Reflect.construct(String, [], f);
} catch (e) {
return false;
}
return true;
}
}
export default Utilities;