(t, s)
| 2275 | |
| 2276 | // prettier-ignore |
| 2277 | function Env(t, s) { |
| 2278 | return new(class { |
| 2279 | constructor(t, s) { |
| 2280 | (this.name = t), |
| 2281 | (this.data = null), |
| 2282 | (this.dataFile = 'box.dat'), |
| 2283 | (this.logs = []), |
| 2284 | (this.logSeparator = '\n'), |
| 2285 | (this.startTime = new Date().getTime()), |
| 2286 | Object.assign(this, s), |
| 2287 | this.log('', `\ud83d\udd14${this.name}, \u5f00\u59cb!`); |
| 2288 | } |
| 2289 | isNode() { |
| 2290 | return 'undefined' != typeof module && !!module.exports; |
| 2291 | } |
| 2292 | isQuanX() { |
| 2293 | return 'undefined' != typeof $task; |
| 2294 | } |
| 2295 | isSurge() { |
| 2296 | return 'undefined' != typeof $httpClient && 'undefined' == typeof $loon; |
| 2297 | } |
| 2298 | isLoon() { |
| 2299 | return 'undefined' != typeof $loon; |
| 2300 | } |
| 2301 | getScript(t) { |
| 2302 | return new Promise((s) => { |
| 2303 | $.get({ |
| 2304 | url: t |
| 2305 | }, (t, e, i) => s(i)); |
| 2306 | }); |
| 2307 | } |
| 2308 | runScript(t, s) { |
| 2309 | return new Promise((e) => { |
| 2310 | let i = this.getdata('@chavy_boxjs_userCfgs.httpapi'); |
| 2311 | i = i ? i.replace(/\n/g, '').trim() : i; |
| 2312 | let o = this.getdata('@chavy_boxjs_userCfgs.httpapi_timeout'); |
| 2313 | (o = o ? 1 * o : 20), |
| 2314 | (o = s && s.timeout ? s.timeout : o); |
| 2315 | const[h, a] = i.split('@'), |
| 2316 | r = { |
| 2317 | url: `http://${a}/v1/scripting/evaluate`, |
| 2318 | body: { |
| 2319 | script_text: t, |
| 2320 | mock_type: 'cron', |
| 2321 | timeout: o |
| 2322 | }, |
| 2323 | headers: { |
| 2324 | 'X-Key': h, |
| 2325 | Accept: '*/*' |
| 2326 | }, |
| 2327 | }; |
| 2328 | $.post(r, (t, s, i) => e(i)); |
| 2329 | }).catch((t) => this.logErr(t)); |
| 2330 | } |
| 2331 | loaddata() { |
| 2332 | if (!this.isNode()) |
| 2333 | return {}; { |
| 2334 | (this.fs = this.fs ? this.fs : require('fs')), |
nothing calls this directly
no outgoing calls
no test coverage detected