import msgHandler from '../utils/iframe/messageHandler'; interface IMiniAppViewCallback { name: string; type: string; id: string; } export class MiniAppView { key: string; url: string; id?: string; callbacks: IMiniAppViewCallback[]; constructor(url: string) { this.url = url; this.callbacks = []; this.key = Math.random().toString(36).substring(5) + '-' + Date.now(); } handleEvent(event: string, type: string) { let cbFound = false; this.callbacks.filter((cb) => { if (cb.name === event && cb.type === type) { msgHandler(this.id!, cb.id!); cbFound = true; } return null; }); return cbFound; } }