import { EventEmitter } from 'events';
// import { AntCube } from './index';
// import { ACSocketSession } from './cube-socket';

// const AntCubeTool = require('antcube-inspector/lib/inspector').default;

export default class ACInspect extends EventEmitter {
    async open(): Promise<void> {
        return Promise.resolve();
        // const url = await this.launch();
        // return new Promise((resolve, reject) => {
        //     AntCubeTool.open(url, (value:any)=>{
        //         resolve();
        //     }, (reason:any) => {
        //         reject(new Error('打开JS调试窗口失败'));
        //     });
        // });
    }
    async dealmsg(token:string, message:string): Promise<void> {
        return Promise.resolve();
        // return new Promise((resolve, rejects)=>{
        //     AntCubeTool.dealwithReceivedMsg(token, message);
        //     resolve();
        // });
    }
    async launch(): Promise<string> {
        return Promise.resolve('');
        // return new Promise((resolve, reject) => {
        //     if (this.isready()) {
        //         AntCubeTool.launch(AntCube.socket, () => {
        //             return this.curtoken();
        //         }, (server:any, url:any) => {
        //             resolve(url);
        //         }, ()=>{
        //             reject(new Error('加载JS调试模块失败'));
        //         });
        //     } else {
        //         reject(new Error('启动JS调试模块前请先连接设备'));
        //     }
        // });
    }
    inspectHTML(root?: string): string {
        return '';
        // return AntCubeTool.indexHTML(root);
    }
    // private isready(): boolean {
    //     return AntCube.socket.clients().length > 0 ? true : false;
    // }
    // private curtoken(): string {
    //     const sessions: ACSocketSession[] = AntCube.socket.clients();
    //     return sessions.length > 0 ? sessions[0].token : '';
    // }
}