Innovenergy_trunk/frontend/node_modules/chrome-remote-interface/chrome-remote-interface.js

1 line
623 KiB
JavaScript
Raw Normal View History

(()=>{var e={6010:(e,t,r)=>{"use strict";var n=r(4155);const i=r(7187),o=r(4782),a=r(7996),s=r(8855);o.setDefaultResultOrder&&o.setDefaultResultOrder("ipv4first"),e.exports=function(e,t){"function"==typeof e&&(t=e,e=void 0);const r=new i;return"function"==typeof t?(n.nextTick((()=>{new s(e,r)})),r.once("connect",t)):new Promise(((t,n)=>{r.once("connect",t),r.once("error",n),new s(e,r)}))},e.exports.Protocol=a.Protocol,e.exports.List=a.List,e.exports.New=a.New,e.exports.Activate=a.Activate,e.exports.Close=a.Close,e.exports.Version=a.Version},7249:e=>{"use strict";function t(e,t,r){e.category=t,Object.keys(r).forEach((n=>{"name"!==n&&(e[n]="type"===t&&"properties"===n||"parameters"===n?function(e){const t={};return e.forEach((e=>{const r=e.name;delete e.name,t[r]=e})),t}(r[n]):r[n])}))}e.exports.prepare=function(e,r){e.protocol=r,r.domains.forEach((r=>{const n=r.domain;e[n]={},(r.commands||[]).forEach((r=>{!function(e,r,n){const i=`${r}.${n.name}`,o=(t,r,n)=>e.send(i,t,r,n);t(o,"command",n),e[i]=e[r][n.name]=o}(e,n,r)})),(r.events||[]).forEach((r=>{!function(e,r,n){const i=`${r}.${n.name}`,o=(t,r)=>{"function"==typeof t&&(r=t,t=void 0);const n=t?`${i}.${t}`:i;return"function"==typeof r?(e.on(n,r),()=>e.removeListener(n,r)):new Promise(((t,r)=>{e.once(n,t)}))};t(o,"event",n),e[i]=e[r][n.name]=o}(e,n,r)})),(r.types||[]).forEach((r=>{!function(e,r,n){const i=`${r}.${n.id}`,o={};t(o,"type",n),e[i]=e[r][n.id]=o}(e,n,r)})),e[n].on=(t,r)=>e[n][t](r)}))}},8855:(e,t,r)=>{"use strict";var n=r(4155);const i=r(7187),o=r(1588),a=r(8575).WU,s=r(8575).Qc,p=r(5529),c=r(7249),d=r(5372),l=r(7996);class u extends Error{constructor(e,t){let{message:r}=t;t.data&&(r+=` (${t.data})`),super(r),this.request=e,this.response=t}}e.exports=class extends i{constructor(e,t){super();e=e||{},this.host=e.host||d.HOST,this.port=e.port||d.PORT,this.secure=!!e.secure,this.useHostName=!!e.useHostName,this.alterPath=e.alterPath||(e=>e),this.protocol=e.protocol,this.local=!!e.local,this.target=e.target||(e=>{let t,r=e.find((e=>!!e.webSocketDebuggerUrl&&(t=t||e,"page"===e.type)));if(r=r||t,r)return r;throw new Error("No inspectable targets")}),this._notifier=t,this._callbacks={},this._nextCommandId=1,this.webSocketUrl=void 0,this._start()}inspect(e,t){return t.customInspect=!1,o.inspect(this,t)}send(e,t,r,n){const i=Array.from(arguments).slice(1);return t=i.find((e=>"object"==typeof e)),r=i.find((e=>"string"==typeof e)),"function"==typeof(n=i.find((e=>"function"==typeof e)))?void this._enqueueCommand(e,t,r,n):new Promise(((n,i)=>{this._enqueueCommand(e,t,r,((o,a)=>{if(o){const n={method:e,params:t,sessionId:r};i(o instanceof Error?o:new u(n,a))}else n(a)}))}))}close(e){const t=e=>{3===this._ws.readyState?e():(this._ws.removeAllListeners("close"),this._ws.once("close",(()=>{this._ws.removeAllListeners(),e()})),this._ws.close())};return"function"==typeof e?void t(e):new Promise(((e,r)=>{t(e)}))}async _start(){const e={host:this.host,port:this.port,secure:this.secure,useHostName:this.useHostName,alterPath:this.alterPath};try{const t=await this._fetchDebuggerURL(e),r=s(t);r.pathname=e.alterPath(r.pathname),this.webSocketUrl=a(r),e.host=r.hostname,e.port=r.port||e.port;const i=await this._fetchProtocol(e);c.prepare(this,i),await this._connectToWebSocket(),n.nextTick((()=>{this._notifier.emit("connect",this)}))}catch(e){this._notifier.emit("error",e)}}async _fetchDebuggerURL(e){const t=this.target;switch(typeof t){case"string":{let r=t;if(r.startsWith("/")&&(r=`ws://${this.host}:${this.port}${r}`),r.match(/^wss?:/i))return r;return(await l.List(e)).find((e=>e.id===r)).webSocketDebuggerUrl}case"object":return t.webSocketDebuggerUrl;case"function":{const r=t,n=await l.List(e),i=r(n);return("number"==typeof i?n[i]:i).webSocketDebuggerUrl}default:throw new Error(`Invalid target argument "${this.target}"`)}}async _fetchProtocol(e){return this.protocol?this.protocol:(e.local=this.local,await l.Protocol(e))}_connectToWebSocket(){return new Promise(((e,t)=>{try{this.secure&&(this.webSocketUrl=this.webSocketUrl.replace(/^ws:/i,"wss:")),this._ws=new p(this.webSocketUrl)}catch(e