import { EventHandler } from 'playcanvas'; type FunctionCallback = (...args: any[]) => any; class Events extends EventHandler { functions = new Map(); // declare an editor function function(name: string, fn: FunctionCallback) { if (this.functions.has(name)) { throw new Error(`error: function ${name} already exists`); } this.functions.set(name, fn); } // invoke an editor function invoke(name: string, ...args: any[]) { const fn = this.functions.get(name); if (!fn) { console.error(`error: function not found '${name}'`); return; } return fn(...args); } } export { Events };