xshell 0.0.72 → 0.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/net.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"net.js","sourceRoot":"","sources":["net.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAqB,MAAM,wBAAwB,CAAA;AACtF,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAE/D,OAAO,aAAa,MAAM,eAAe,CAAA;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAA;AAE9B,OAAO,KAAK,MAAM,YAAY,CAAA;AAC9B,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AASxD,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AACtC,OAAO,gBAAgB,CAAA;AAEvB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAE3D,MAAM,CAAN,IAAY,OAGX;AAHD,WAAY,OAAO;IACf,4CAAkC,CAAA;IAClC,4CAAiC,CAAA;AACrC,CAAC,EAHW,OAAO,GAAP,OAAO,KAAP,OAAO,QAGlB;AAGD,sDAAsD;AACtD,MAAM,YAAY,GAAG,IAAI,iBAAiB,EAAE,CAAA;AAE5C,MAAM,CAAC,MAAM,OAAO,GAAG;IACnB,KAAK,EAAE,YAAY;IAEnB,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC;IAEtC,GAAG,CAAE,aAAqB,EAAE,GAAG,GAAG,KAAK;QACnC,IAAI,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC;YAChC,IAAI,GAAG;gBACH,OAAO,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,aAAa,CAAC,CAAA;;gBAE9C,OAAO,IAAI,CAAC,GA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EAAE;YACZ,6DAA6D;YAE7D,IACI,SAAS,CAAC,UAAU,KAAK,SAAS,CAAC,IAAI;gBACvC,CAAC,OAAO,CAAC,KAAK,CAAC,oCAAoC;;gBAEnD,IAAI;oBAAE,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,kCAAkC,EAAE,EAAE,SAAS,CAAC,CAAA;iBAAE;gBAAC,MAAM,GAAG;YAEnG,mDAAmD;YACnD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;SACrB;IACL,CAAC;IAGD,iDAAiD;IACjD,KAAK,CAAC,IAAI,CAAkC,IAAY,EAAE,IAAY;QAClE,OAAO,IAAI,OAAO,CAAU,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;YAClD,MAAM,EAAE,GAAG,KAAK,EAAE,CAAA;YAElB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,OAAyB,EAAE,EAAE;gBAChD,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAA;gBAC/B,IAAI,KAAK;oBACL,MAAM,CAAC,KAAK,CAAC,CAAA;;oBAEb,OAAO,CAAC,IAAI,CAAC,CAAA;gBACjB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;YAC5B,CAAC,CAAC,CAAA;YAEF,IAAI;gBACA,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA,CAAE,4DAA4D;aAC1G;YAAC,OAAO,KAAK,EAAE;gBACZ,MAAM,CAAC,KAAK,CAAC,CAAA;aAChB;QACL,CAAC,CAAC,CAAA;IACN,CAAC;CACJ","sourcesContent":["import type { InspectOptions } from 'util'\n\n// todo: 等 fetch-h2 支持 proxy 后迁移\nimport { default as request_lib, type OptionsWithUri, type OptionsWithUrl } from 'request'\n\nimport { default as request_promise, type FullResponse } from 'request-promise-native'\nimport { RequestError } from 'request-promise-native/errors.js'\n\nimport promise_retry from 'promise-retry'\n\nimport { WebSocket } from 'ws'\n\nimport iconv from 'iconv-lite'\nimport qs from 'qs'\n\nimport { Cookie, MemoryCookieStore } from 'tough-cookie'\n\ndeclare module 'tough-cookie' {\n interface MemoryCookieStore {\n idx: Record<string, any>\n }\n}\n\n\nimport { t } from './i18n/instance.js'\nimport './prototype.js'\nimport type { Encoding } from './file.js'\nimport { inspect, concat, assert, genid } from './utils.js'\n\nexport enum MyProxy {\n socks5 = 'http://localhost:10080',\n whistle = 'http://localhost:8899',\n}\n\n\n// ------------------------------------ Fetch, Request\nconst cookie_store = new MemoryCookieStore()\n\nexport const cookies = {\n store: cookie_store,\n \n jar: request_promise.jar(cookie_store),\n \n get (domain_or_url: string, str = false) {\n if (domain_or_url.startsWith('http'))\n if (str)\n return this.jar.getCookieString(domain_or_url)\n else\n return this.jar.getCookies(domain_or_url)\n \n let cookies: Cookie[]\n this.store.findCookies(domain_or_url, null, true, (error, _cookies) => {\n if (error) throw error\n cookies = _cookies\n })\n return cookies\n },\n}\n\nexport { Cookie }\n\n\nexport const _request = request_promise.defaults({\n // rejectUnauthorized: false,\n \n /** 防止 302 重定向产生错误 (prevent 302 redirect cause error), which is a boolean to set whether status codes other than 2xx should also reject the promise */\n simple: false,\n \n jar: cookies.jar\n})\n\n\nexport async function request_retry (retries: number, request_options: request_promise.OptionsWithUrl) {\n return promise_retry<FullResponse>({\n retries,\n minTimeout: 1000,\n maxTimeout: Infinity,\n factor: 2\n }, async (retry, count) => {\n try {\n return await _request(request_options)\n } catch (error) {\n if (!['ECONNRESET', 'ETIMEDOUT', 'ESOCKETTIMEDOUT'].includes(error.cause?.code)) throw error\n if (count <= retries)\n console.log(`${`retry (${count}) …`.yellow} ${request_options.url.toString().blue.underline}`)\n return retry(error)\n }\n })\n}\n\n\nexport interface RequestOptions {\n method?: 'get' | 'post' | 'put' | 'head' | 'delete' | 'patch'\n \n queries?: Record<string, any>\n \n headers?: Record<string, string>\n \n body?: string | Record<string, any>\n \n type?: 'application/json' | 'application/x-www-form-urlencoded' | 'multipart/form-data'\n \n \n proxy?: boolean | MyProxy | string\n \n encoding?: Encoding\n \n retries?: true | number\n \n timeout?: number\n \n auth?: {\n username: string\n password: string\n }\n \n gzip?: boolean\n \n cookies?: Record<string, string>\n}\n\nexport interface RequestRawOptions extends RequestOptions {\n raw: true\n}\n\n\n/** \n - url: 必须是完整 url must be full url\n - options:\n - raw: `false` 传入后返回整个 response\n - encoding: `(网页 content-type: charset=gb18030) || 'utf-8'` 传入 'binary' 时返回 buffer `(response content-type: charset=gb18030) || 'utf-8'` when 'binary' then return buffer\n - type: `'application/json'` 请求的 content-type 头 (如有 body) request content-type header (if has body)\n - proxy: `false`\n - 为 true 时使用 MyProxy.socks5 Use MyProxy.socks5 when true\n - 为非空 string 作为代理地址 A non-empty string as proxy address\n - 为 falsy 值时设为 false set to false for a falsy value\n - retries: `false` 可以传入 true (默认 3 次) 或 重试次数 could be true (default 3 times) or retry times\n - timeout: `20 * 1000`\n - gzip: `raw -> false; else -> true`\n*/\nexport async function request (url: string | URL): Promise<string>\nexport async function request (url: string | URL, options: RequestRawOptions): Promise<request_lib.Response>\nexport async function request (url: string | URL, options: RequestOptions & { encoding: 'binary' }): Promise<Buffer>\nexport async function request (url: string | URL, options: RequestOptions): Promise<string>\nexport async function request (url: string | URL, {\n queries,\n \n body,\n \n type = 'application/json',\n \n proxy,\n \n method,\n \n headers,\n \n encoding,\n \n raw = false,\n \n retries,\n \n timeout = 20 * 1000,\n \n auth,\n \n gzip,\n \n cookies,\n \n}: RequestOptions & { raw?: boolean } = { }) {\n url = url.toString()\n \n const _body = body // for 错误日志\n \n if (body && !method)\n method = 'post'\n \n if (type === 'application/json' && typeof body !== 'undefined' && (typeof body !== 'string' && !Buffer.isBuffer(body)))\n body = JSON.stringify(body)\n \n // --- proxy\n if (proxy) {\n if (proxy === true)\n proxy = MyProxy.socks5\n } else\n proxy = false\n \n // --- gzip\n if (gzip === undefined)\n gzip = !raw\n \n \n const options: request_lib.Options & { resolveWithFullResponse: boolean } = {\n url,\n \n ... method ? { method: method.toUpperCase() } : { },\n \n proxy,\n \n gzip,\n \n encoding: null,\n \n resolveWithFullResponse: true,\n \n headers: {\n 'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja-JP;q=0.6,ja;q=0.5',\n 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',\n ... body ? { 'content-type': type } : { }, \n ... cookies ? {\n cookie: Object.entries(cookies)\n .map(([key, value]) => \n `${encodeURIComponent(key)}=${encodeURIComponent(value)}`\n ).join('; ')\n } : { },\n ... headers ? \n Object.fromEntries(\n Object.entries(headers)\n .filter(([key, value]) => !key.startsWith(':'))\n ) : { }\n },\n \n ... queries ? { qs: queries } : { },\n \n // --- body\n ... (() => {\n if (!body) return { }\n if (type === 'application/x-www-form-urlencoded') return { form: body }\n if (type === 'multipart/form-data') return { formData: body as Record<string, any> }\n return { body }\n })(),\n \n ... timeout ? { timeout } : { },\n \n ... auth ? { auth } : { },\n }\n \n let response: request_lib.Response\n \n try {\n if (retries) {\n if (retries === true)\n retries = 3\n \n response = await request_retry(retries, options)\n } else\n response = await _request(options)\n \n if (!(200 <= response.statusCode && response.statusCode <= 299))\n throw Object.assign(new Error(t('状态码 {{code}}, 非 2xx', { code: response.statusCode })), {\n name: 'StatusCodeError',\n response,\n options\n })\n } catch (error) {\n const {\n name, \n options: { method, url, uri, qs }, \n response,\n }: {\n options: OptionsWithUri & OptionsWithUrl\n response: FullResponse\n } & Error = error\n \n error[inspect.custom] = (depth: number, options: InspectOptions, inspect: Function) => {\n const { colors } = options\n \n let _method = (method || 'get').toLowerCase()\n if (colors)\n _method = _method.red\n \n let _url = String(url || uri)\n if (colors)\n _url = _url.blue.underline\n \n let s = '\\n' +\n `${_method} ${_url}\\n`\n \n if (qs && Object.keys(qs).length) {\n let _query = t('请求参数:')\n if (colors)\n _query = _query.blue\n \n s += _query + '\\n' +\n inspect(qs, options) + '\\n'\n }\n \n if (_body) {\n let _body = t('请求体:')\n if (colors)\n _body = _body.blue\n \n s += _body + '\\n' +\n inspect(body, options) + '\\n'\n }\n \n \n if (name === 'StatusCodeError') {\n let _status = t('响应状态码:')\n if (colors)\n _status = _status.yellow\n \n let _code = String(response.statusCode)\n if (colors)\n _code = _code.red\n \n s += _status + ' ' + _code\n } else if (error instanceof RequestError) {\n let _cause = t('响应错误:')\n if (colors)\n _cause = _cause.yellow\n \n s += _cause + '\\n' +\n inspect(error.cause, options)\n } else\n s += inspect(error, options)\n s += '\\n'\n \n if (response) {\n let _headers = t('响应头:')\n if (colors)\n _headers = _headers.yellow\n \n s += _headers + '\\n' +\n inspect(response.headers) + '\\n'\n \n if (response.body) {\n let _body = t('响应体:')\n if (colors)\n _body = _body.yellow\n \n s += _body + '\\n' +\n inspect(response.body.toString(), options) + '\\n'\n }\n }\n \n let _stack = t('调用栈:')\n if (colors)\n _stack = _stack.yellow\n \n s += _stack + '\\n' +\n error.stack + '\\n' +\n '\\n'\n \n return s\n }\n \n throw error\n }\n \n if (raw)\n return response\n \n if (!response.body)\n return response.body\n \n // --- decode body\n if (encoding === 'binary')\n return response.body\n \n encoding ||= /charset=(.*)/.exec(response.headers['content-type'])?.[1] as Encoding || 'utf-8'\n \n if (/utf-?8/i.test(encoding))\n return (response.body as Buffer).toString('utf-8')\n \n return iconv.decode((response.body as Buffer), encoding)\n}\n\n\n/** 发起 http 请求并将响应体作为 json 解析 make http request and parse body as json */\nexport async function request_json <T = any> (url: string | URL, options?: RequestOptions): Promise<T> {\n const resp = await request(url, options)\n if (!resp)\n return\n try {\n return JSON.parse(resp)\n } catch (error) {\n console.error(resp)\n throw error\n }\n}\n\n\n/** 使用 $.html(cheerio_element) 来获取 outer html use $.html(cheerio_element) to get outer html */\nexport async function parse_html (html: string) {\n const { default: cheerio } = await import('cheerio')\n \n let $ = cheerio.load(html, { decodeEntities: false })\n \n Object.defineProperty($, inspect.custom, {\n configurable: true,\n enumerable: false,\n value () {\n return this.html()\n }\n })\n \n Object.defineProperty($.prototype, inspect.custom, {\n configurable: true,\n enumerable: false,\n value (this: cheerio.Cheerio) {\n if (this.length > 1)\n return this.map((index, element) => {\n if (typeof element === 'string') return element\n return $.html(element)\n }).get().join_lines()\n \n return this.toString()\n }\n })\n \n return $\n}\n\n\n/** 使用 $.html(cheerio_element) 来获取 outer html use $.html(cheerio_element) to get outer html */\nexport async function request_page (url: string | URL, options?: RequestOptions) {\n return parse_html(\n await request(url, options)\n )\n}\n\n\nexport function to_curl (url: string | URL, { queries, headers, method, body, proxy, exe = true }: RequestOptions & { exe?: boolean } = { }) {\n if (proxy === true)\n proxy = process.env.http_proxy\n \n url = url.toString()\n \n if (!url.startsWith('http'))\n url = `http://${url}`\n \n return (exe ? 'curl.exe' : 'curl') + \n ' ' + ( url + (queries ? '?' : '') + qs.stringify(queries) ).quote() +\n // ( typeof proxy === 'undefined' ?\n // ''\n // :\n // ( proxy ? ' --proxy ' + proxy.quote() : ' --noproxy ' + '*'.quote())\n // ) +\n ( proxy ? ` --proxy ${proxy.quote()}` : '' ) +\n ( method && method !== 'get' ? ` -X ${method.toUpperCase()}` : '' ) +\n ( headers ? Object.entries(headers).map( ([key, value]) => ' -H ' + `${key}: ${value}`.quote() ).join('') : '' ) +\n ( body ? ' -H ' + 'content-type: application/json'.quote() : '') +\n ( body ? ' --data ' + JSON.stringify(body).quote() : '')\n}\n\n\n\n\n// ------------------------------------ rpc client\n/** post json to http://localhost:8421/api/rpc\n - func: function name\n - args?: argument array\n - options?:\n - ignore?: `false` wait for execution but do not serialize result to response\n - async?: `false` do not wait for exec\n*/\nexport async function rpc (\n func: string, \n args?: any[], \n { url = 'http://localhost:8421/api/rpc', async: _async = false, ignore = false }: { url?: string, async?: boolean, ignore?: boolean } = { }\n) {\n if (!func)\n throw new Error('rpc argument error: no func')\n \n return request_json(url, {\n body: {\n func,\n args,\n async: _async,\n ignore,\n }\n })\n}\n\n\n\nlet decoder = new TextDecoder()\n\nlet encoder = new TextEncoder()\n\n\n/** 连接 websocket url, 设置各种事件监听器。在 open 事件后 resolve, 返回 websocket \n - url\n - options:\n - on_message: 根据 websocket frame 的 opcode 不同 (text frame 或 binary frame) event 中的 data 对应为 ArrayBuffer 或者 string\n https://datatracker.ietf.org/doc/html/rfc6455#section-5.2\n*/\nexport async function connect_websocket (\n url: string | URL,\n {\n protocols,\n max_payload = 2 ** 33, // 8 GB\n on_close,\n on_error,\n on_message\n }: {\n protocols?: string | string[]\n max_payload?: number\n on_close? (event: { code: number, reason: string }, websocket: WebSocket): any\n on_error? (event: any, websocket: WebSocket): any\n on_message (event: { data: ArrayBuffer | string }, websocket: WebSocket): any\n }\n) {\n let websocket = new WebSocket(\n url,\n protocols,\n {\n maxPayload: max_payload,\n skipUTF8Validation: true\n }\n )\n \n // https://stackoverflow.com/questions/11821096/what-is-the-difference-between-an-arraybuffer-and-a-blob/39951543\n websocket.binaryType = 'arraybuffer'\n \n return new Promise<WebSocket>((resolve, reject) => {\n websocket.addEventListener('open', async event => {\n console.log(\n new Date().to_time_str() + ': ' +\n t('websocket 已连接: ') +\n (protocols ? \n typeof protocols === 'string' ? `protocol: ${protocols}, url: ` : `protocol: [${protocols.join(', ')}], url: `\n :\n '') +\n websocket.url\n )\n \n resolve(websocket)\n })\n \n websocket.addEventListener('close', event => {\n console.log(`${new Date().to_time_str()}: ${t('websocket 已关闭')}: url: ${websocket.url}, code: ${event.code}, reason: ${event.reason}`)\n on_close?.(event, websocket)\n })\n \n websocket.addEventListener('error', event => {\n const message = `${new Date().to_time_str()}: ${t('websocket 出错了')}: ${websocket.url}`\n try {\n on_error?.(event, websocket)\n reject(Object.assign(new Error(message), { event }))\n } catch (error) {\n reject(error)\n }\n })\n \n websocket.addEventListener('message', event => {\n on_message(event as any, websocket)\n })\n })\n}\n\n\n/** 接收到消息后的处理函数 \n 返回值可以是:\n - 数组: 会自动被封装为 { id: 相同, data: 返回值, done: true } 这样的消息并调用 websocket.send 将其发送\n - void: 什么都不做\n - 以上的 promise */\nexport type MessageHandler = (message: Message, websocket?: WebSocket) => void | any[] | Promise<void | any[]>\n\n\n/** 二进制消息格式 \n - json.length (小端序): 4 字节\n - json 数据\n - binary 数据\n*/\nexport interface Message <TData extends any[] = any[]> {\n /** rpc id: 在 rpc 系统中认为是唯一的。用来在单个 websocket 连接上复用多个 rpc 请求。多个相同 id 的 message 组成一个请求流 */\n id?: number\n \n /** 只在 rpc 发起时指定被调用的 function name,发起时 rpc 时必传 */\n func?: string\n \n /** 通过这个 flag 主动表明这是发往对方的最后一个 message, 对方可以销毁 handler 了 \n 并非强制,可以不说明,由双方的函数自己约定\n */\n done?: boolean\n \n /** 通知对方这里产生的错误,本质上类似 data 也是一种数据,并不代表 rpc 的结束,后续可能继续有 rpc message 交换 */\n error?: Error\n \n /** data 是一个数组, 作为:\n - rpc 发起方调用 func 的参数,或者请求流 message 携带的数据\n - 结果或者响应流的数据,传给请求发起方\n \n 里面是可序列化为 json 的 js 变量,或者是 Uint8Array \n Uint8Array 的参数处理后被替换为 Uint8Array.byteLength, 并将下标记录在 bins 中\n \n 注意: 数组中如果有 undefined 值,传输到对面会变成 null 值\n */\n data?: TData\n \n /** bins: data 中哪些下标对应的原始值是 Uint8Array 类型的,如: [0, 3] */\n bins?: number[]\n}\n\n/** 通过创建 remote 对象对 websocket rpc 进行抽象 \n 调用方使用 remote.call 进行调用 \n 被调方在创建 remote 对象时传入 funcs 注册处理函数,并使用 remote.handle 方法处理 websocket message \n 未连接时自动连接,断开后自动重连 (保证执行 send 时已连接,否则报错) */\nexport class Remote {\n url: string\n \n /** 主动发起 websocket 连接的客户端 (构造函数传 url) 有这个属性 */\n websocket?: WebSocket\n \n /** 通过 rpc message.func 被调用的 rpc 函数 */\n funcs: Record<string, MessageHandler>\n \n /** map<id, message handler>: 通过 rpc message.id 找到对应的 handler, unary rpc 接收方不需要设置 handlers, 发送方需要 */\n handlers = new Map<number, MessageHandler>()\n \n \n print = false\n \n pconnect: Promise<any>\n \n \n get connected () {\n return this.websocket?.readyState === WebSocket.OPEN\n }\n \n \n static parse <TData extends any[] = any[]> (array_buffer: ArrayBuffer) {\n const buf = new Uint8Array(array_buffer as ArrayBuffer)\n const dv = new DataView(array_buffer)\n \n const len_json = dv.getUint32(0, true)\n \n let offset = 4 + len_json\n \n let message: Message<TData> = JSON.parse(decoder.decode(buf.subarray(4, offset)))\n \n if (message.bins) {\n const { bins } = message\n let { data } = message\n \n for (const ibin of bins) {\n const len_buf = data[ibin]\n data[ibin] = buf.subarray(offset, offset + len_buf)\n offset += len_buf\n }\n }\n \n if (message.error)\n message.error = Object.assign(new Error(), message.error)\n \n return message\n }\n \n \n static pack ({ id, func, data = [ ], done, error }: Message) {\n let data_ = new Array(data.length)\n let bins: number[] = [ ]\n let bufs: Uint8Array[] = [ ]\n \n for (let i = 0; i < data.length; i++) {\n const item = data[i]\n if (item instanceof Uint8Array) {\n bins.push(i)\n bufs.push(item)\n data_[i] = item.length\n } else\n data_[i] = item\n }\n \n const data_json = {\n id,\n ... func ? { func } : { },\n ... done ? { done } : { },\n ... error ? { error } : { },\n ... data_.length ? { data: data_ } : { },\n ... bins.length ? { bins } : { },\n }\n \n const str_json = encoder.encode(JSON.stringify(data_json))\n \n let dv = new DataView(new ArrayBuffer(4))\n \n dv.setUint32(0, str_json.length, true)\n \n return concat([dv, str_json, ... bufs])\n }\n \n \n constructor ({\n url, funcs = { }, websocket\n }: {\n url?: string, funcs?: Remote['funcs'], websocket?: WebSocket\n } = { }) {\n this.url = url\n this.funcs = funcs\n this.websocket = websocket\n }\n \n \n /** 幂等,保证 websocket 已连接,否则抛出异常,不需要手动调用,在其它方法中已默认自动重连 */\n async connect () {\n if (this.connected)\n return\n \n const ptail = this.pconnect\n \n let resolve: () => void\n this.pconnect = new Promise<void>((_resolve, _reject) => {\n resolve = _resolve\n })\n \n await ptail\n \n try {\n if (!this.connected)\n // 保存的 rpc 状态在 this.handlers, 与 websocket 无关,因此即使断开重连也不影响 rpc 的运行,即\n // 底层连接断开后自动重连对上层应该是无感知的,除非再次连接时失败\n this.websocket = await connect_websocket(this.url, { on_message: this.handle.bind(this) })\n } finally {\n resolve()\n }\n }\n \n \n disconnect () {\n this.websocket?.close(1000)\n }\n \n \n /** 接收 websocket 连接的 remote 端必传 websocket 参数;发起端选传,如果传了必须等于 this.websocket \n 发送或连接出错时自动清理 message.id 对应的 handler */\n async send (message: Message, websocket?: WebSocket) {\n try {\n if (this.url) {\n assert(!websocket || websocket === this.websocket)\n await this.connect()\n websocket = this.websocket\n } else {\n assert(websocket)\n if (websocket.readyState !== WebSocket.OPEN)\n throw new Error(t('remote.send(): websocket client 已断开'))\n }\n \n if (!message.id)\n message.id = genid()\n \n websocket.send(Remote.pack(message))\n } catch (error) {\n if (message.id)\n this.handlers.delete(message.id)\n throw error\n }\n }\n \n \n /** 处理接收到的 websocket message 并解析, 根据 id dispatch 到对应的 handler 进行处理 \n 如果 message.done == true 则清理 handler \n 如果 handler 返回了值,则包装为 message 发送 */\n async handle (event: { data: ArrayBuffer }, websocket: WebSocket) {\n const message = Remote.parse(event.data)\n \n const { id, func, done } = message\n \n if (this.print)\n console.log(message)\n \n let handler: MessageHandler\n \n if (func)\n handler = this.funcs[func]\n else {\n handler = this.handlers.get(id)\n if (done)\n this.handlers.delete(id)\n }\n \n try {\n if (handler) {\n const data = await handler(message, websocket)\n if (data)\n await this.send({ id, data }, websocket)\n } else if (message.error)\n throw message.error\n else\n throw new Error(`${t('找不到 rpc handler')}: ${func ? `func: ${func.quote()}` : `id: ${id}`}`)\n } catch (error) {\n // handle 出错并不意味着 rpc 一定会结束,可能 error 是运行中的正常数据,所以不能清理 handler\n \n if (\n websocket.readyState === WebSocket.OPEN &&\n !message.error // 防止无限循环往对方发送 error, 只有在对方无错误时才可以发送\n )\n try { await this.send({ id, error, /* 不能设置 done 清理对面 handler, 理由同上 */ }, websocket) } catch { }\n \n // 再往上层抛出错误没有意义了,上层调用栈是 websocket.on('message') 之类的\n console.log(error)\n }\n }\n \n \n /** 调用 remote 中的 func, 只适用于最简单的一元 rpc (请求, 响应) */\n async call <TReturn extends any[] = any[]> (func: string, args?: any[]) {\n return new Promise<TReturn>(async (resolve, reject) => {\n const id = genid()\n \n this.handlers.set(id, (message: Message<TReturn>) => {\n const { error, data } = message\n if (error)\n reject(error)\n else\n resolve(data)\n this.handlers.delete(id)\n })\n \n try {\n await this.send({ id, func, data: args }) // 不需要 done: true, 因为对面的 remote.handlers 中不会有这个 id 的 handler\n } catch (error) {\n reject(error)\n }\n })\n }\n}\n\n"]}
1
+ {"version":3,"file":"net.js","sourceRoot":"","sources":["net.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAqB,MAAM,wBAAwB,CAAA;AACtF,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAE/D,OAAO,aAAa,MAAM,eAAe,CAAA;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAA;AAE9B,OAAO,KAAK,MAAM,YAAY,CAAA;AAC9B,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AASxD,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AACtC,OAAO,gBAAgB,CAAA;AAEvB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAE3D,MAAM,CAAN,IAAY,OAGX;AAHD,WAAY,OAAO;IACf,4CAAkC,CAAA;IAClC,4CAAiC,CAAA;AACrC,CAAC,EAHW,OAAO,GAAP,OAAO,KAAP,OAAO,QAGlB;AAGD,sDAAsD;AACtD,MAAM,YAAY,GAAG,IAAI,iBAAiB,EAAE,CAAA;AAE5C,MAAM,CAAC,MAAM,O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AAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;YAC5B,CAAC,CAAC,CAAA;YAEF,IAAI;gBACA,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA,CAAE,4DAA4D;aAC1G;YAAC,OAAO,KAAK,EAAE;gBACZ,MAAM,CAAC,KAAK,CAAC,CAAA;aAChB;QACL,CAAC,CAAC,CAAA;IACN,CAAC;CACJ","sourcesContent":["import type { InspectOptions } from 'util'\n\n// todo: 等 fetch-h2 支持 proxy 后迁移\nimport { default as request_lib, type OptionsWithUri, type OptionsWithUrl } from 'request'\n\nimport { default as request_promise, type FullResponse } from 'request-promise-native'\nimport { RequestError } from 'request-promise-native/errors.js'\n\nimport promise_retry from 'promise-retry'\n\nimport { WebSocket } from 'ws'\n\nimport iconv from 'iconv-lite'\nimport qs from 'qs'\n\nimport { Cookie, MemoryCookieStore } from 'tough-cookie'\n\ndeclare module 'tough-cookie' {\n interface MemoryCookieStore {\n idx: Record<string, any>\n }\n}\n\n\nimport { t } from './i18n/instance.js'\nimport './prototype.js'\nimport type { Encoding } from './file.js'\nimport { inspect, concat, assert, genid } from './utils.js'\n\nexport enum MyProxy {\n socks5 = 'http://localhost:10080',\n whistle = 'http://localhost:8899',\n}\n\n\n// ------------------------------------ Fetch, Request\nconst cookie_store = new MemoryCookieStore()\n\nexport const cookies = {\n store: cookie_store,\n \n jar: request_promise.jar(cookie_store),\n \n get (domain_or_url: string, str = false) {\n if (domain_or_url.startsWith('http'))\n if (str)\n return this.jar.getCookieString(domain_or_url)\n else\n return this.jar.getCookies(domain_or_url)\n \n let cookies: Cookie[]\n this.store.findCookies(domain_or_url, null, true, (error, _cookies) => {\n if (error) throw error\n cookies = _cookies\n })\n return cookies\n },\n}\n\nexport { Cookie }\n\n\nexport const _request = request_promise.defaults({\n // rejectUnauthorized: false,\n \n /** 防止 302 重定向产生错误 (prevent 302 redirect cause error), which is a boolean to set whether status codes other than 2xx should also reject the promise */\n simple: false,\n \n jar: cookies.jar\n})\n\n\nexport async function request_retry (retries: number, request_options: request_promise.OptionsWithUrl) {\n return promise_retry<FullResponse>({\n retries,\n minTimeout: 1000,\n maxTimeout: Infinity,\n factor: 2\n }, async (retry, count) => {\n try {\n return await _request(request_options)\n } catch (error) {\n if (!['ECONNRESET', 'ETIMEDOUT', 'ESOCKETTIMEDOUT'].includes(error.cause?.code)) throw error\n if (count <= retries)\n console.log(`${`retry (${count}) …`.yellow} ${request_options.url.toString().blue.underline}`)\n return retry(error)\n }\n })\n}\n\n\nexport interface RequestOptions {\n method?: 'get' | 'post' | 'put' | 'head' | 'delete' | 'patch'\n \n queries?: Record<string, any>\n \n headers?: Record<string, string>\n \n body?: string | Record<string, any>\n \n type?: 'application/json' | 'application/x-www-form-urlencoded' | 'multipart/form-data'\n \n \n proxy?: boolean | MyProxy | string\n \n encoding?: Encoding\n \n retries?: true | number\n \n timeout?: number\n \n auth?: {\n username: string\n password: string\n }\n \n gzip?: boolean\n \n cookies?: Record<string, string>\n}\n\nexport interface RequestRawOptions extends RequestOptions {\n raw: true\n}\n\n\n/** \n - url: 必须是完整 url must be full url\n - options:\n - raw: `false` 传入后返回整个 response\n - encoding: `(网页 content-type: charset=gb18030) || 'utf-8'` 传入 'binary' 时返回 buffer `(response content-type: charset=gb18030) || 'utf-8'` when 'binary' then return buffer\n - type: `'application/json'` 请求的 content-type 头 (如有 body) request content-type header (if has body)\n - proxy: `false`\n - 为 true 时使用 MyProxy.socks5 Use MyProxy.socks5 when true\n - 为非空 string 作为代理地址 A non-empty string as proxy address\n - 为 falsy 值时设为 false set to false for a falsy value\n - retries: `false` 可以传入 true (默认 3 次) 或 重试次数 could be true (default 3 times) or retry times\n - timeout: `20 * 1000`\n - gzip: `raw -> false; else -> true`\n*/\nexport async function request (url: string | URL): Promise<string>\nexport async function request (url: string | URL, options: RequestRawOptions): Promise<request_lib.Response>\nexport async function request (url: string | URL, options: RequestOptions & { encoding: 'binary' }): Promise<Buffer>\nexport async function request (url: string | URL, options: RequestOptions): Promise<string>\nexport async function request (url: string | URL, {\n queries,\n \n body,\n \n type = 'application/json',\n \n proxy,\n \n method,\n \n headers,\n \n encoding,\n \n raw = false,\n \n retries,\n \n timeout = 20 * 1000,\n \n auth,\n \n gzip,\n \n cookies,\n \n}: RequestOptions & { raw?: boolean } = { }) {\n url = url.toString()\n \n const _body = body // for 错误日志\n \n if (body && !method)\n method = 'post'\n \n if (type === 'application/json' && typeof body !== 'undefined' && (typeof body !== 'string' && !Buffer.isBuffer(body)))\n body = JSON.stringify(body)\n \n // --- proxy\n if (proxy) {\n if (proxy === true)\n proxy = MyProxy.socks5\n } else\n proxy = false\n \n // --- gzip\n if (gzip === undefined)\n gzip = !raw\n \n \n const options: request_lib.Options & { resolveWithFullResponse: boolean } = {\n url,\n \n ... method ? { method: method.toUpperCase() } : { },\n \n proxy,\n \n gzip,\n \n encoding: null,\n \n resolveWithFullResponse: true,\n \n headers: {\n 'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja-JP;q=0.6,ja;q=0.5',\n 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',\n ... body ? { 'content-type': type } : { }, \n ... cookies ? {\n cookie: Object.entries(cookies)\n .map(([key, value]) => \n `${encodeURIComponent(key)}=${encodeURIComponent(value)}`\n ).join('; ')\n } : { },\n ... headers ? \n Object.fromEntries(\n Object.entries(headers)\n .filter(([key, value]) => !key.startsWith(':'))\n ) : { }\n },\n \n ... queries ? { qs: queries } : { },\n \n // --- body\n ... (() => {\n if (!body) return { }\n if (type === 'application/x-www-form-urlencoded') return { form: body }\n if (type === 'multipart/form-data') return { formData: body as Record<string, any> }\n return { body }\n })(),\n \n ... timeout ? { timeout } : { },\n \n ... auth ? { auth } : { },\n }\n \n let response: request_lib.Response\n \n try {\n if (retries) {\n if (retries === true)\n retries = 3\n \n response = await request_retry(retries, options)\n } else\n response = await _request(options)\n \n if (!(200 <= response.statusCode && response.statusCode <= 299))\n throw Object.assign(new Error(t('状态码 {{code}}, 非 2xx', { code: response.statusCode })), {\n name: 'StatusCodeError',\n response,\n options\n })\n } catch (error) {\n const {\n name, \n options: { method, url, uri, qs }, \n response,\n }: {\n options: OptionsWithUri & OptionsWithUrl\n response: FullResponse\n } & Error = error\n \n error[inspect.custom] = (depth: number, options: InspectOptions, inspect: Function) => {\n const { colors } = options\n \n let _method = (method || 'get').toLowerCase()\n if (colors)\n _method = _method.red\n \n let _url = String(url || uri)\n if (colors)\n _url = _url.blue.underline\n \n let s = '\\n' +\n `${_method} ${_url}\\n`\n \n if (qs && Object.keys(qs).length) {\n let _query = t('请求参数:')\n if (colors)\n _query = _query.blue\n \n s += _query + '\\n' +\n inspect(qs, options) + '\\n'\n }\n \n if (_body) {\n let _body = t('请求体:')\n if (colors)\n _body = _body.blue\n \n s += _body + '\\n' +\n inspect(body, options) + '\\n'\n }\n \n \n if (name === 'StatusCodeError') {\n let _status = t('响应状态码:')\n if (colors)\n _status = _status.yellow\n \n let _code = String(response.statusCode)\n if (colors)\n _code = _code.red\n \n s += _status + ' ' + _code\n } else if (error instanceof RequestError) {\n let _cause = t('响应错误:')\n if (colors)\n _cause = _cause.yellow\n \n s += _cause + '\\n' +\n inspect(error.cause, options)\n } else\n s += inspect(error, options)\n s += '\\n'\n \n if (response) {\n let _headers = t('响应头:')\n if (colors)\n _headers = _headers.yellow\n \n s += _headers + '\\n' +\n inspect(response.headers) + '\\n'\n \n if (response.body) {\n let _body = t('响应体:')\n if (colors)\n _body = _body.yellow\n \n s += _body + '\\n' +\n inspect(response.body.toString(), options) + '\\n'\n }\n }\n \n let _stack = t('调用栈:')\n if (colors)\n _stack = _stack.yellow\n \n s += _stack + '\\n' +\n error.stack + '\\n' +\n '\\n'\n \n return s\n }\n \n throw error\n }\n \n if (raw)\n return response\n \n if (!response.body)\n return response.body\n \n // --- decode body\n if (encoding === 'binary')\n return response.body\n \n encoding ||= /charset=(.*)/.exec(response.headers['content-type'])?.[1] as Encoding || 'utf-8'\n \n if (/utf-?8/i.test(encoding))\n return (response.body as Buffer).toString('utf-8')\n \n return iconv.decode((response.body as Buffer), encoding)\n}\n\n\n/** 发起 http 请求并将响应体作为 json 解析 make http request and parse body as json */\nexport async function request_json <T = any> (url: string | URL, options?: RequestOptions): Promise<T> {\n const resp = await request(url, options)\n if (!resp)\n return\n try {\n return JSON.parse(resp)\n } catch (error) {\n console.error(resp)\n throw error\n }\n}\n\n\n/** 使用 $.html(cheerio_element) 来获取 outer html use $.html(cheerio_element) to get outer html */\nexport async function parse_html (html: string) {\n const { default: cheerio } = await import('cheerio')\n \n let $ = cheerio.load(html, { decodeEntities: false })\n \n Object.defineProperty($, inspect.custom, {\n configurable: true,\n enumerable: false,\n value () {\n return this.html()\n }\n })\n \n Object.defineProperty($.prototype, inspect.custom, {\n configurable: true,\n enumerable: false,\n value (this: cheerio.Cheerio) {\n if (this.length > 1)\n return this.map((index, element) => {\n if (typeof element === 'string') return element\n return $.html(element)\n }).get().join_lines()\n \n return this.toString()\n }\n })\n \n return $\n}\n\n\n/** 使用 $.html(cheerio_element) 来获取 outer html use $.html(cheerio_element) to get outer html */\nexport async function request_page (url: string | URL, options?: RequestOptions) {\n return parse_html(\n await request(url, options)\n )\n}\n\n\nexport function to_curl (url: string | URL, { queries, headers, method, body, proxy, exe = true }: RequestOptions & { exe?: boolean } = { }) {\n if (proxy === true)\n proxy = process.env.http_proxy\n \n url = url.toString()\n \n if (!url.startsWith('http'))\n url = `http://${url}`\n \n return (exe ? 'curl.exe' : 'curl') + \n ' ' + ( url + (queries ? '?' : '') + qs.stringify(queries) ).quote() +\n // ( typeof proxy === 'undefined' ?\n // ''\n // :\n // ( proxy ? ' --proxy ' + proxy.quote() : ' --noproxy ' + '*'.quote())\n // ) +\n ( proxy ? ` --proxy ${proxy.quote()}` : '' ) +\n ( method && method !== 'get' ? ` -X ${method.toUpperCase()}` : '' ) +\n ( headers ? Object.entries(headers).map( ([key, value]) => ' -H ' + `${key}: ${value}`.quote() ).join('') : '' ) +\n ( body ? ' -H ' + 'content-type: application/json'.quote() : '') +\n ( body ? ' --data ' + JSON.stringify(body).quote() : '')\n}\n\n\n\n\n// ------------------------------------ rpc client\n/** post json to http://localhost:8421/api/rpc\n - func: function name\n - args?: argument array\n - options?:\n - ignore?: `false` wait for execution but do not serialize result to response\n - async?: `false` do not wait for exec\n*/\nexport async function rpc (\n func: string, \n args?: any[], \n { url = 'http://localhost:8421/api/rpc', async: _async = false, ignore = false }: { url?: string, async?: boolean, ignore?: boolean } = { }\n) {\n if (!func)\n throw new Error('rpc argument error: no func')\n \n return request_json(url, {\n body: {\n func,\n args,\n async: _async,\n ignore,\n }\n })\n}\n\n\n\nlet decoder = new TextDecoder()\n\nlet encoder = new TextEncoder()\n\n\n/** 连接 websocket url, 设置各种事件监听器。在 open 事件后 resolve, 返回 websocket \n - url\n - options:\n - on_message: 根据 websocket frame 的 opcode 不同 (text frame 或 binary frame) event 中的 data 对应为 ArrayBuffer 或者 string\n https://datatracker.ietf.org/doc/html/rfc6455#section-5.2\n*/\nexport async function connect_websocket (\n url: string | URL,\n {\n protocols,\n max_payload = 2 ** 33, // 8 GB\n on_close,\n on_error,\n on_message\n }: {\n protocols?: string | string[]\n max_payload?: number\n on_close? (event: { code: number, reason: string }, websocket: WebSocket): any\n on_error? (event: any, websocket: WebSocket): any\n on_message (event: { data: ArrayBuffer | string }, websocket: WebSocket): any\n }\n) {\n let websocket = new WebSocket(\n url,\n protocols,\n {\n maxPayload: max_payload,\n skipUTF8Validation: true\n }\n )\n \n // https://stackoverflow.com/questions/11821096/what-is-the-difference-between-an-arraybuffer-and-a-blob/39951543\n websocket.binaryType = 'arraybuffer'\n \n return new Promise<WebSocket>((resolve, reject) => {\n websocket.addEventListener('open', async event => {\n console.log(\n websocket.url +\n (protocols ? \n ' ' + (\n typeof protocols === 'string' ? protocols : protocols.join(', ').bracket('square')\n ).bracket()\n :\n '') +\n t(' 已连接')\n )\n \n resolve(websocket)\n })\n \n websocket.addEventListener('close', event => {\n if (event.code === 1000)\n console.log(websocket.url + t(' 已正常关闭'))\n else\n console.log(`${websocket.url} ${t('被关闭')}, code: ${event.code}${ event.reason ? `, ${t('原因')}: ${event.reason}` : '' }`)\n on_close?.(event, websocket)\n })\n \n websocket.addEventListener('error', event => {\n const message = `${websocket.url} ${t('出错了')}`\n try {\n on_error?.(event, websocket)\n reject(Object.assign(new Error(message), { event }))\n } catch (error) {\n reject(error)\n }\n })\n \n websocket.addEventListener('message', event => {\n on_message(event as any, websocket)\n })\n })\n}\n\n\n/** 接收到消息后的处理函数 \n 返回值可以是:\n - 数组: 会自动被封装为 { id: 相同, data: 返回值, done: true } 这样的消息并调用 websocket.send 将其发送\n - void: 什么都不做\n - 以上的 promise */\nexport type MessageHandler = (message: Message, websocket?: WebSocket) => void | any[] | Promise<void | any[]>\n\n\n/** 二进制消息格式 \n - json.length (小端序): 4 字节\n - json 数据\n - binary 数据\n*/\nexport interface Message <TData extends any[] = any[]> {\n /** rpc id: 在 rpc 系统中认为是唯一的。用来在单个 websocket 连接上复用多个 rpc 请求。多个相同 id 的 message 组成一个请求流 */\n id?: number\n \n /** 只在 rpc 发起时指定被调用的 function name,发起时 rpc 时必传 */\n func?: string\n \n /** 通过这个 flag 主动表明这是发往对方的最后一个 message, 对方可以销毁 handler 了 \n 并非强制,可以不说明,由双方的函数自己约定\n */\n done?: boolean\n \n /** 通知对方这里产生的错误,本质上类似 data 也是一种数据,并不代表 rpc 的结束,后续可能继续有 rpc message 交换 */\n error?: Error\n \n /** data 是一个数组, 作为:\n - rpc 发起方调用 func 的参数,或者请求流 message 携带的数据\n - 结果或者响应流的数据,传给请求发起方\n \n 里面是可序列化为 json 的 js 变量,或者是 Uint8Array \n Uint8Array 的参数处理后被替换为 Uint8Array.byteLength, 并将下标记录在 bins 中\n \n 注意: 数组中如果有 undefined 值,传输到对面会变成 null 值\n */\n data?: TData\n \n /** bins: data 中哪些下标对应的原始值是 Uint8Array 类型的,如: [0, 3] */\n bins?: number[]\n}\n\n/** 通过创建 remote 对象对 websocket rpc 进行抽象 \n 调用方使用 remote.call 进行调用 \n 被调方在创建 remote 对象时传入 funcs 注册处理函数,并使用 remote.handle 方法处理 websocket message \n 未连接时自动连接,断开后自动重连 (保证执行 send 时已连接,否则报错) */\nexport class Remote {\n url: string\n \n /** 主动发起 websocket 连接的客户端 (构造函数传 url) 有这个属性 */\n websocket?: WebSocket\n \n /** 通过 rpc message.func 被调用的 rpc 函数 */\n funcs: Record<string, MessageHandler>\n \n /** map<id, message handler>: 通过 rpc message.id 找到对应的 handler, unary rpc 接收方不需要设置 handlers, 发送方需要 */\n handlers = new Map<number, MessageHandler>()\n \n \n print = false\n \n pconnect: Promise<any>\n \n \n get connected () {\n return this.websocket?.readyState === WebSocket.OPEN\n }\n \n \n static parse <TData extends any[] = any[]> (array_buffer: ArrayBuffer) {\n const buf = new Uint8Array(array_buffer as ArrayBuffer)\n const dv = new DataView(array_buffer)\n \n const len_json = dv.getUint32(0, true)\n \n let offset = 4 + len_json\n \n let message: Message<TData> = JSON.parse(decoder.decode(buf.subarray(4, offset)))\n \n if (message.bins) {\n const { bins } = message\n let { data } = message\n \n for (const ibin of bins) {\n const len_buf = data[ibin]\n data[ibin] = buf.subarray(offset, offset + len_buf)\n offset += len_buf\n }\n }\n \n if (message.error)\n message.error = Object.assign(new Error(), message.error)\n \n return message\n }\n \n \n static pack ({ id, func, data = [ ], done, error }: Message) {\n let data_ = new Array(data.length)\n let bins: number[] = [ ]\n let bufs: Uint8Array[] = [ ]\n \n for (let i = 0; i < data.length; i++) {\n const item = data[i]\n if (item instanceof Uint8Array) {\n bins.push(i)\n bufs.push(item)\n data_[i] = item.length\n } else\n data_[i] = item\n }\n \n const data_json = {\n id,\n ... func ? { func } : { },\n ... done ? { done } : { },\n ... error ? { error } : { },\n ... data_.length ? { data: data_ } : { },\n ... bins.length ? { bins } : { },\n }\n \n const str_json = encoder.encode(JSON.stringify(data_json))\n \n let dv = new DataView(new ArrayBuffer(4))\n \n dv.setUint32(0, str_json.length, true)\n \n return concat([dv, str_json, ... bufs])\n }\n \n \n constructor ({\n url, funcs = { }, websocket\n }: {\n url?: string, funcs?: Remote['funcs'], websocket?: WebSocket\n } = { }) {\n this.url = url\n this.funcs = funcs\n this.websocket = websocket\n }\n \n \n /** 幂等,保证 websocket 已连接,否则抛出异常,不需要手动调用,在其它方法中已默认自动重连 */\n async connect () {\n if (this.connected)\n return\n \n const ptail = this.pconnect\n \n let resolve: () => void\n this.pconnect = new Promise<void>((_resolve, _reject) => {\n resolve = _resolve\n })\n \n await ptail\n \n try {\n if (!this.connected)\n // 保存的 rpc 状态在 this.handlers, 与 websocket 无关,因此即使断开重连也不影响 rpc 的运行,即\n // 底层连接断开后自动重连对上层应该是无感知的,除非再次连接时失败\n this.websocket = await connect_websocket(this.url, { on_message: this.handle.bind(this) })\n } finally {\n resolve()\n }\n }\n \n \n disconnect () {\n this.websocket?.close(1000)\n }\n \n \n /** 接收 websocket 连接的 remote 端必传 websocket 参数;发起端选传,如果传了必须等于 this.websocket \n 发送或连接出错时自动清理 message.id 对应的 handler */\n async send (message: Message, websocket?: WebSocket) {\n try {\n if (this.url) {\n assert(!websocket || websocket === this.websocket)\n await this.connect()\n websocket = this.websocket\n } else {\n assert(websocket)\n if (websocket.readyState !== WebSocket.OPEN)\n throw new Error(t('remote.send(): websocket client 已断开'))\n }\n \n if (!message.id)\n message.id = genid()\n \n websocket.send(Remote.pack(message))\n } catch (error) {\n if (message.id)\n this.handlers.delete(message.id)\n throw error\n }\n }\n \n \n /** 处理接收到的 websocket message 并解析, 根据 id dispatch 到对应的 handler 进行处理 \n 如果 message.done == true 则清理 handler \n 如果 handler 返回了值,则包装为 message 发送 */\n async handle (event: { data: ArrayBuffer }, websocket: WebSocket) {\n const message = Remote.parse(event.data)\n \n const { id, func, done } = message\n \n if (this.print)\n console.log(message)\n \n let handler: MessageHandler\n \n if (func)\n handler = this.funcs[func]\n else {\n handler = this.handlers.get(id)\n if (done)\n this.handlers.delete(id)\n }\n \n try {\n if (handler) {\n const data = await handler(message, websocket)\n if (data)\n await this.send({ id, data }, websocket)\n } else if (message.error)\n throw message.error\n else\n throw new Error(`${t('找不到 rpc handler')}: ${func ? `func: ${func.quote()}` : `id: ${id}`}`)\n } catch (error) {\n // handle 出错并不意味着 rpc 一定会结束,可能 error 是运行中的正常数据,所以不能清理 handler\n \n if (\n websocket.readyState === WebSocket.OPEN &&\n !message.error // 防止无限循环往对方发送 error, 只有在对方无错误时才可以发送\n )\n try { await this.send({ id, error, /* 不能设置 done 清理对面 handler, 理由同上 */ }, websocket) } catch { }\n \n // 再往上层抛出错误没有意义了,上层调用栈是 websocket.on('message') 之类的\n console.log(error)\n }\n }\n \n \n /** 调用 remote 中的 func, 只适用于最简单的一元 rpc (请求, 响应) */\n async call <TReturn extends any[] = any[]> (func: string, args?: any[]) {\n return new Promise<TReturn>(async (resolve, reject) => {\n const id = genid()\n \n this.handlers.set(id, (message: Message<TReturn>) => {\n const { error, data } = message\n if (error)\n reject(error)\n else\n resolve(data)\n this.handlers.delete(id)\n })\n \n try {\n await this.send({ id, func, data: args }) // 不需要 done: true, 因为对面的 remote.handlers 中不会有这个 id 的 handler\n } catch (error) {\n reject(error)\n }\n })\n }\n}\n\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "0.0.72",
3
+ "version": "0.0.74",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -16,7 +16,7 @@
16
16
  "interactive programming"
17
17
  ],
18
18
  "engines": {
19
- "node": ">=19.2.0",
19
+ "node": ">=19.3.0",
20
20
  "vscode": ">=1.74.0"
21
21
  },
22
22
  "scripts": {
@@ -77,13 +77,12 @@
77
77
  "cli-truncate": "^3.1.0",
78
78
  "colors": "^1.4.0",
79
79
  "commander": "^9.4.1",
80
- "ejs": "^3.1.8",
81
80
  "emoji-regex": "^10.2.1",
82
81
  "fs-extra": "^11.1.0",
83
82
  "fs-monkey": "^1.0.3",
84
83
  "gulp-sort": "^2.0.0",
85
84
  "hash-string": "^1.0.0",
86
- "i18next": "^22.4.4",
85
+ "i18next": "^22.4.6",
87
86
  "i18next-scanner": "^4.1.0",
88
87
  "iconv-lite": "^0.6.3",
89
88
  "js-cookie": "^3.0.1",
@@ -117,14 +116,13 @@
117
116
  "@types/byte-size": "^8.1.0",
118
117
  "@types/chardet": "^0.8.1",
119
118
  "@types/cheerio": "^0.22.31",
120
- "@types/ejs": "^3.1.1",
121
119
  "@types/fs-extra": "^9.0.13",
122
120
  "@types/gulp-sort": "2.0.0",
123
121
  "@types/js-cookie": "^3.0.2",
124
122
  "@types/koa": "^2.13.5",
125
123
  "@types/koa-compress": "^4.0.3",
126
124
  "@types/lodash": "^4.14.191",
127
- "@types/node": "^18.11.14",
125
+ "@types/node": "^18.11.17",
128
126
  "@types/promise-retry": "^1.1.3",
129
127
  "@types/qs": "^6.9.7",
130
128
  "@types/react": "^18.0.26",
package/prototype.d.ts CHANGED
@@ -103,8 +103,8 @@ declare global {
103
103
  space(this: string): string;
104
104
  fdir: string;
105
105
  /** path.basename, 如:
106
- - D:/0/aaa.txt -> aaa.txt
107
- - D:/aaa/ -> aaa
106
+ - d:/0/aaa.txt -> aaa.txt
107
+ - d:/aaa/ -> aaa
108
108
  */
109
109
  fname: string;
110
110
  /** .txt */
package/prototype.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"prototype.js","sourceRoot":"","sources":["prototype.ts"],"names":[],"mappings":"AA4OA,OAAO,IAAI,MAAM,OAAO,CAAA;AACxB,OAAO,SAAS,MAAM,WAAW,CAAA;AAEjC,OAAO,UAAU,MAAM,aAAa,CAAA;AAEpC,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,KAAK,CAAC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MAAM,IAAI,SAAS,IAAI,SAAS,IAAI,MAAM,CAAC;YAE5C,mBAAmB;YACnB,CAAC,MAAM,IAAI,SAAS,IAAI,SAAS,IAAI,MAAM,CAAC;YAE5C,+BAA+B;YAC/B,CAAC,MAAM,IAAI,SAAS,IAAI,SAAS,IAAI,MAAM,CAAC;YAE5C,iBAAiB;YACjB,CAAC,MAAM,IAAI,SAAS,IAAI,SAAS,IAAI,MAAM,CAAC;YAE5C,iDAAiD;YACjD,CAAC,MAAM,IAAI,SAAS,IAAI,SAAS,IAAI,MAAM,CAAC;YAE5C,gCAAgC;YAChC,CAAC,MAAM,IAAI,SAAS,IAAI,SAAS,IAAI,MAAM,CAAC;YAC5C,CAAC,MAAM,IAAI,SAAS,IAAI,SAAS,IAAI,MAAM,CAAC;YAE5C,kBAAkB;YAClB,CAAC,OAAO,IAAI,SAAS,IAAI,SAAS,IAAI,OAAO,CAAC;YAE9C,kCAAkC;YAClC,CAAC,OAAO,IAAI,SAAS,IAAI,SAAS,IAAI,OAAO,CAAC;YAE9C,mEAAmE;YACnE,CAAC,OAAO,IAAI,SAAS,IAAI,SAAS,IAAI,OAAO,CAAC,CACjD,CACJ,CAAA;AACL,CAAC","sourcesContent":["declare global {\n var my_prototype_defined: boolean\n \n interface String {\n readonly width: number\n \n // --- 工具方法\n /** 截取字符串不超过 width 显示宽度的部分,并保留颜色 \n 找到并记录能容纳 字符串 + … 的最后一个字符的位置 i_fitted \n 若完整的字符串长度超过 width,返回 slice(0, i_fitted + 1) + … \n 否则 返回 this \n */\n truncate (this: string, width: number): string\n \n /** pad string to `<width>` \n - character?: `' '`\n - position?: `'right'`\n */\n pad (this: string, width: number, { character, position }?: { character?: string, position?: 'left' | 'right'}): string\n \n limit (this: string, width: number, { character, position }?: { character?: string, position?: 'left' | 'right'}): string\n \n to_regexp (this: string, preservations?: string, flags?: string): RegExp\n \n to_bool (this: string): boolean\n \n /** 字符串模式替换 \n - pattern: 匹配部分的格式\n - pattern_: 替换后的格式\n - preservations?: `''` 保留的正则表达式字符\n - flags?: `''` 正则匹配选项\n - transformer?: `(name, matched) => matched || ''` placeholder transformer\n - pattern_placeholder?: `/\\{.*?\\}/g`\n \n ```ts\n 'g:/acgn/海贼王/[Skytree][海贼王][One_Piece][893][GB_BIG5_JP][X264_AAC][1080P][CRRIP][天空树双语字幕组].mkv'.refmt( \n '{dirp}/[Skytree][海贼王][{ en_name: \\\\w+ }][{ episode: \\\\d+ }][GB_BIG5_JP][{encoding}_AAC][1080P][CRRIP][天空树双语字幕组].{format}', \n 'g:/acgn/海贼王/{episode} {encoding}.{format}', \n '\\\\+', \n 'i', \n (name, value) => name === 'episode' ? String(+value + 1) : value.toLowerCase() \n )\n ```\n */\n refmt ( this: string,\n pattern: string,\n \n pattern_: string,\n \n preservations?: string,\n \n flags?: string,\n \n transformer?: (name: string, value: string, placeholders: { [name: string]: string }) => string,\n \n pattern_placeholder?: RegExp\n \n ): string\n \n \n /** 字符串模式搜索\n ```ts\n 'git+https://github.com/tamino-martinius/node-ts-dedent-123.git'.find(\n '^{protocol:[\\\\w+]+}://{hostname:[\\\\w\\\\.]+}/{username}/{project}-{index:\\\\d+}.{suffix}', '^', 'i'\n )\n {\n protocol: 'git+https',\n hostname: 'github.com',\n ...\n }\n ```\n \n - preservations?: `''` 保留的正则表达式字符\n - flags?: `''` 正则匹配选项\n - pattern_placeholder?: `/\\{.*?\\}/g`\n */\n find (this: string,\n \n pattern: string, \n \n preservations?: string, \n \n flags?: string, \n \n pattern_placeholder?: RegExp\n \n ): Record<string, string>\n \n \n /** - type?: `'single'` */\n quote (this: string, type?: keyof typeof quotes | 'psh'): string\n \n /** - shape?: `'parenthesis'` */\n bracket (this: string, shape?: keyof typeof brackets): string\n \n surround (this: string, left: string, right?: string): string\n \n surround_tag (this: string, tag_name: string): string\n \n to_lf (this: string): string\n \n to_crlf (this: string): string\n \n /** 'xxx'.replace(/pattern/g, '') \n 如果 pattern 是 string 则在创建 RegExp 时自动加上 flags (默认 'g'), 否则忽略 flags\n */\n rm (this: string, pattern: string | RegExp, flags?: string): string\n \n \n // --- chalk colors\n readonly red: string\n readonly red_: string\n \n readonly green: string\n readonly green_: string\n \n readonly yellow: string\n readonly yellow_: string\n \n readonly blue: string\n readonly blue_: string\n \n readonly magenta: string\n readonly magenta_: string\n \n readonly cyan: string\n readonly cyan_: string\n \n readonly grey: string\n \n readonly underline: string\n \n strip_ansi (this: string): string\n \n \n // --- 文本处理\n /** 将 string 划分为行,并去掉最后一个 \\n 之后的 '' */\n split_lines (this: string): string[]\n \n trim_doc_comment (this: string): string\n \n split_indent (this: string): { indent: number, text: string }\n \n \n to_base64 (this: string): string\n \n \n /** - buffer: `false` 直接返回 Buffer */\n decode_base64 (this: string): string\n decode_base64 (this: string, buffer: true): Buffer\n decode_base64 (this: string, buffer?: boolean): string | Buffer\n \n \n space (this: string): string\n \n \n // --- 文件路径操作\n fdir: string\n \n /** path.basename, 如: \n - D:/0/aaa.txt -> aaa.txt\n - D:/aaa/ -> aaa\n */\n fname: string\n \n /** .txt */\n fext: string\n \n to_slash (this: string): string\n \n to_backslash (this: string): string\n }\n \n \n interface Date {\n /** - ms?: `false` 显示到 ms */\n to_str (this: Date, ms?: boolean): string\n \n to_date_str (this: Date): string\n \n /** - ms?: `false` 显示到 ms */\n to_time_str (this: Date, ms?: boolean): string\n }\n \n \n interface Number {\n /** 12.4 KB (1 KB = 1024 B) */\n to_fsize_str (this: number, units?: 'iec' | 'metric'): string\n \n \n to_bin_str (this: number): string\n \n to_hex_str (this: number, length?: number): string\n \n to_oct_str (this: number): string\n }\n \n \n interface Array<T> {\n last: T\n \n log (this: string[], limit?: number): void\n \n indent (this: string[], width: number, c?: string): string[]\n \n indent2to4 (this: string[]): string[]\n \n \n // --- 文本处理\n /**\n - trim_line?: `true`\n - rm_empty_lines?: `true`\n - rm_last_empty_lines?: `false`\n */\n trim_lines (this: string[], { trim_line, rm_empty_lines, rm_last_empty_lines }?: { trim_line?: boolean, rm_empty_lines?: boolean, rm_last_empty_lines?: boolean }): string[]\n \n trim_license (this: string[]): string[]\n \n split_indents (this: string[]): { indent: number, text: string }[]\n \n /** - append?: `true` 是否在 join 之后增加 \\n */\n join_lines (append?: boolean): string\n }\n \n \n interface BigInt {\n toJSON (this: bigint): string\n }\n \n \n interface Error {\n toJSON (this: Error): string\n }\n}\n\n\nimport path from 'upath'\nimport byte_size from 'byte-size'\n\nimport EmojiRegex from 'emoji-regex'\n\nimport strip_ansi from 'strip-ansi'\nimport chalk from 'chalk'\nchalk.level = 2\n\nimport { t } from './i18n/instance.js'\n\n\nexport const emoji_regex = EmojiRegex()\n\nexport { chalk }\n\nexport function to_method_property_descriptors (methods: { [name: string]: Function }): PropertyDescriptorMap {\n return Object.fromEntries(\n Object.entries(methods)\n .map(([name, value]) => ([name, {\n configurable: true,\n writable: true,\n enumerable: false,\n value,\n } as PropertyDescriptor])\n ))\n}\n\n\nexport function to_getter_property_descriptors (getters: { [name: string]: Function }): PropertyDescriptorMap {\n return Object.fromEntries(\n Object.entries(getters)\n .map(([name, get]) => ([name, {\n configurable: true,\n enumerable: false,\n get,\n } as PropertyDescriptor])\n ))\n}\n\n\nexport const cjk = '([\\u2e80-\\u9fff\\uf900-\\ufaff])'\n\nexport const quotes = {\n single: \"'\",\n double: '\"',\n backtick: '`',\n}\n\nexport const brackets = {\n round: ['(', ')'],\n square: ['[', ']'],\n curly: ['{', '}'],\n pointy: ['<', '>'],\n corner: ['「', '」'],\n fat: ['【', '】'],\n tortoise_shell: ['〔', '〕'],\n} as const\n\nconst color_map = Object.fromEntries(\n ['red_', 'green_', 'yellow_', 'blue_', 'magenta_', 'cyan_'].map(color =>\n [color, `${color.slice(0, -1)}Bright`])\n)\n\n\nif (!global.my_prototype_defined) {\n // ------------------------------------ String.prototype\n Object.defineProperties(String.prototype, {\n ... to_getter_property_descriptors({\n width (this: string) {\n const s = strip_ansi(\n this.replace(emoji_regex, ' ')\n )\n let width = 0\n for (let i = 0; i < s.length; i++) {\n const code = s.codePointAt(i)\n \n if (\n (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) || // ignore control characters\n code >= 0x300 && code <= 0x36f // ignore combining characters\n ) continue\n \n // surrogates\n if (code > 0xffff)\n i++\n \n width += is_codepoint_fullwidth(code) ? 2 : 1\n }\n return width\n }\n }),\n \n \n // ------------ 文本处理工具方法\n ... to_method_property_descriptors({\n /** 截取字符串不超过 width 显示宽度的部分,并保留颜色 \n 找到并记录能容纳 字符串 + … 的最后一个字符的位置 i_fitted \n - 若完整的字符串长度超过 width,返回 slice(0, i_fitted + 1) + … \n - 否则 返回 this \n */\n truncate (this: string, width: number) {\n const color_bak = this.startsWith('\\u001b') ? this.slice(0, 5) : ''\n const s = strip_ansi(this)\n if (width <= 2) return this.slice(0, width)\n let i_fitted = 0\n let fitted_width = 0\n let cur_width = 0\n for (let i = 0; i < s.length; i++) {\n const code = s.codePointAt(i)\n \n if (\n (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) || // Ignore control characters\n code >= 0x300 && code <= 0x36F // Ignore combining characters\n ) continue\n \n // surrogates (codepoint 需要用两个 utf-16 编码单位表示,因此这里跳过第二个编码单位,防止重复计算显示宽度)\n if (code > 0xFFFF)\n i++\n \n const w = is_codepoint_fullwidth(code) ? 2 : 1\n \n if (cur_width + w + 2 <= width) {\n i_fitted = i\n fitted_width += w\n }\n \n cur_width += w\n \n if (cur_width > width) {\n const i_fitted_next = i_fitted + 1\n const t = s.slice(0, i_fitted_next) + ' '.repeat(width - 2 - fitted_width) + '…' \n return color_bak ? color_bak + t + '\\u001b[39m' : t\n }\n }\n return this\n },\n \n \n pad (this: string, width: number, { character = ' ', position = 'right' }: { character?: string, position?: 'left' | 'right'} = { }) {\n const _width = this.width\n if (_width >= width) return this\n if (position === 'right') return this + character.repeat( (width - _width) / character.width )\n return character.repeat(width - _width) + this\n },\n \n \n limit (this: string, width: number, { character = ' ', position = 'right' }: { character?: string, position?: 'left' | 'right'} = { }) {\n return this.pad(width, { character, position }).truncate(width)\n },\n \n \n to_regexp (this: string, preservations: string, flags = ''): RegExp {\n const preserved_chars = new Set(preservations)\n const replace_chars: string = Array.prototype.filter.call('|\\\\{}()[]^$+*?.-', (c: string) => !preserved_chars.has(c))\n .map((c: string) =>\n c === ']' ? '\\\\]' : c\n ).join('')\n \n return new RegExp(\n this.replace(\n new RegExp(`[${replace_chars}]`, 'g'),\n '\\\\$&'\n ), \n flags\n )\n },\n \n \n to_bool (this: string) {\n return this.length && this !== '0' && this.toLowerCase() !== 'false'\n },\n \n refmt (this: string, \n pattern : string,\n pattern_: string,\n preservations: string = '',\n flags = '',\n transformer: (name: string, value: string, placeholders: { [name: string]: string }) => string = (name, value) => value || '',\n pattern_placeholder = /\\{.*?\\}/g,\n ): string {\n // --- 转换 pattern 为 pattern_regx\n let last_end = 0\n \n // placeholder matched group indexes\n let $placeholders: Record<string, number> = { }\n \n let regx_parts = [ ]\n \n function add_part (left: number, right?: number) {\n const part = pattern.slice(left, right)\n if (part)\n regx_parts.push(\n part.to_regexp(preservations).source.bracket()\n )\n }\n \n pattern.replace(pattern_placeholder, ($0, offset) => {\n add_part(last_end, offset)\n last_end = offset + $0.length\n \n const placeholder = $0.slice(1, -1)\n let [placeholder_name, placeholder_pattern] = placeholder.split(':').map(s => s.trim())\n let optional = false\n if (placeholder_name.endsWith('?')) {\n placeholder_name = placeholder_name.slice(0, -1)\n optional = true\n }\n $placeholders[placeholder_name] = regx_parts.push(\n placeholder_pattern ? \n `${placeholder_pattern.bracket()}${optional ? '?' : ''}`\n :\n '(.*?)'\n )\n return ''\n })\n \n add_part(last_end)\n \n // 最后一个 (.*?) 改为贪心匹配,满足 .{suffix} 的需要\n regx_parts = regx_parts.filter(part => part)\n if (regx_parts.last === '(.*?)')\n regx_parts[regx_parts.length - 1] = '(.*)'\n \n const pattern_regx = new RegExp(regx_parts.join(''), flags)\n \n \n // --- 根据 pattern_regx 去匹配原有字符串,获取匹配结果,生成 placeholders 词典\n const matches = pattern_regx.exec(this)\n \n if (!matches) return this\n \n const placeholders = Object.fromEntries(\n Object.entries($placeholders)\n .map(([name, $i]) => [\n [name, matches[$i]],\n [`${name}.before`, matches[$i - 1] || ''],\n [`${name}.after`, matches[$i + 1] || ''],\n ])\n .flat()\n )\n \n \n // --- 转换 pattern_ 为 replacement_str,如果有 transformer 则在遇到 placeholder 时应用\n last_end = 0\n let replacement_parts = [ ]\n \n pattern_.replace(pattern_placeholder, ($0, offset) => {\n replacement_parts.push(\n pattern_.slice(last_end, offset)\n )\n last_end = offset + $0.length\n \n const placeholder_name = $0.slice(1, -1)\n \n replacement_parts.push(\n transformer(placeholder_name, placeholders[placeholder_name], placeholders)\n )\n \n return ''\n })\n replacement_parts.push(\n pattern_.slice(last_end)\n )\n \n return this.replace(pattern_regx, replacement_parts.join(''))\n },\n \n \n find (this: string,\n pattern: string, \n preservations: string = '', \n flags = '', \n pattern_placeholder = /\\{.*?\\}/g\n ): Record<string, string> {\n // --- 转换 pattern 为 pattern_regx\n let last_end = 0\n \n // placeholder matched group index\n let $placeholders: Record<string, number> = { }\n \n let regx_parts = [ ]\n \n function add_part (left: number, right?: number) {\n const part = pattern.slice(left, right)\n if (part)\n regx_parts.push(\n part.to_regexp(preservations).source.bracket()\n )\n }\n \n pattern.replace(pattern_placeholder, ($0, offset) => {\n add_part(last_end, offset)\n last_end = offset + $0.length\n \n const placeholder = $0.slice(1, -1)\n let [placeholder_name, placeholder_pattern] = placeholder.split(':').map(s => s.trim())\n let optional = false\n if (placeholder_name.endsWith('?')) {\n placeholder_name = placeholder_name.slice(0, -1)\n optional = true\n }\n \n $placeholders[placeholder_name] = regx_parts.push(\n placeholder_pattern ? \n `${placeholder_pattern.bracket()}${optional ? '?' : ''}`\n :\n '(.*?)'\n )\n return ''\n })\n \n add_part(last_end)\n \n // 最后一个 (.*?) 改为贪心匹配,满足 .{suffix} 的需要\n regx_parts = regx_parts.filter(part => part)\n if (regx_parts[regx_parts.length - 1] === '(.*?)')\n regx_parts[regx_parts.length - 1] = '(.*)'\n \n const pattern_regx = new RegExp(regx_parts.join(''), flags)\n \n \n // --- 根据 pattern_regx 去匹配原有字符串,获取匹配结果,生成 placeholders 词典\n const matches = pattern_regx.exec(this)\n \n if (!matches) return { }\n \n return Object.fromEntries(\n Object.entries($placeholders)\n .map(([name, $i]) => \n [name, matches[$i] || '']\n )\n )\n },\n \n quote (this: string, type: keyof typeof quotes | 'psh' = 'single') {\n if (type === 'psh')\n return `& ${this.quote()}`\n return this.surround(quotes[type])\n },\n \n \n bracket (this: string, shape: keyof typeof brackets = 'round') {\n return this.surround(...brackets[shape] as [string, string])\n },\n \n \n surround (this: string, left: string, right?: string) {\n return left + this + (right || left)\n },\n \n surround_tag (this: string, tag_name: string): string {\n return '<' + tag_name + '>' + this + '</' + tag_name + '>'\n },\n \n \n to_lf (this: string) {\n return this.replace(/\\r\\n/g, '\\n')\n },\n \n \n to_crlf (this: string) {\n return this.replace(/\\n/g, '\\r\\n')\n },\n \n \n rm (this: string, pattern: string | RegExp, flags: string = 'g') {\n if (typeof pattern === 'string')\n pattern = new RegExp(pattern, flags)\n \n return this.replace(pattern, '')\n },\n \n \n split_lines (this: string, delimiter: string | RegExp = /\\r?\\n/) {\n let lines = this.split(delimiter)\n if (lines.last === '')\n lines.pop()\n return lines\n },\n \n \n split_indent (this: string): { indent: number, text: string } {\n let i = 0\n let indent = 0\n for (; i < this.length; i++)\n if (this[i] === ' ')\n indent += 1\n else if (this[i] === '\\t')\n indent += 4\n else\n break\n \n return {\n indent,\n text: this.slice(i)\n }\n },\n \n \n trim_doc_comment (this: string) {\n return `/** ${this.slice(3, -2).replace(/\\s*\\*\\s*/g, ' ').replace(/@(param|params|return) \\{.*?\\}\\s*/g, '').trim()} */`\n },\n \n \n to_base64 (this: string) {\n return Buffer.from(this).toString('base64')\n },\n \n \n decode_base64 (this: string, buffer = false) {\n const buf = Buffer.from(this, 'base64')\n if (buffer)\n return buf\n return buf.toString()\n },\n \n \n strip_ansi (this: string) {\n return strip_ansi(this)\n },\n \n \n space (this: string) {\n if (!this) return this\n let text_: string\n text_ = this\n .replace(new RegExp(cjk + `(['\"])`, 'g'), '$1 $2')\n .replace(new RegExp(`(['\"])` + cjk, 'g'), '$1 $2')\n \n .replace(/([\"']+)\\s*(.+?)\\s*([\"']+)/g, '$1$2$3')\n \n .replace(new RegExp(cjk + '([\\\\+\\\\-\\\\*\\\\/=&\\\\\\\\\\\\|<>])([A-Za-z0-9])', 'g'), '$1 $2 $3')\n .replace(new RegExp('([A-Za-z0-9])([\\\\+\\\\-\\\\*\\\\/=&\\\\\\\\\\\\|<>])' + cjk, 'g'), '$1 $2 $3')\n \n const text_bak = text_\n \n text_ = text_.replace(new RegExp(cjk + '([\\\\(\\\\[\\\\{<\\u201c]+(.*?)[\\\\)\\\\]\\\\}>\\u201d]+)' + cjk, 'g'), '$1 $2 $4')\n \n if (text_ === text_bak)\n text_ = text_\n .replace(new RegExp(cjk + '([\\\\(\\\\[\\\\{<\\u201c>])', 'g'), '$1 $2')\n .replace(new RegExp('([\\\\)\\\\]\\\\}>\\u201d<])' + cjk, 'g'), '$1 $2')\n \n return text_\n .replace(/([\\(\\[\\{<\\u201c]+)(\\s*)(.+?)(\\s*)([\\)\\]\\}>\\u201d]+)/g, '$1$3$5')\n .replace(new RegExp(cjk + '([~!;:,\\\\.\\\\?\\u2026])([A-Za-z0-9])', 'g'), '$1$2 $3')\n .replace(new RegExp(cjk + '([A-Za-z0-9`\\\\$%\\\\^&\\\\*\\\\-=\\\\+\\\\\\\\\\\\|\\\\/@\\u00a1-\\u00ff\\u2022\\u2027\\u2150-\\u218f])', 'g'), '$1 $2')\n .replace(new RegExp('([A-Za-z0-9`\\\\$%\\\\^&\\\\*\\\\-=\\\\+\\\\\\\\\\\\|\\\\/@\\u00a1-\\u00ff\\u2022\\u2027\\u2150-\\u218f])' + cjk, 'g'), '$1 $2')\n }\n }),\n \n \n // ------------ chalk colors\n ... Object.fromEntries(\n [\n 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'grey', \n 'red_', 'green_', 'yellow_', 'blue_', 'magenta_', 'cyan_',\n 'underline',\n ].map(color =>\n ([color, {\n configurable: true,\n get (this: string) {\n return chalk[color_map[color] || color](this)\n }\n }]))\n ),\n \n \n // ------------ 文件路径操作\n ... to_getter_property_descriptors({\n fdir (this: string) {\n const dir = path.dirname(this)\n return dir.endsWith('/') ? dir : `${dir}/`\n },\n \n fname (this: string) {\n return path.basename(this)\n },\n \n fext (this: string) {\n return path.extname(this)\n },\n }),\n \n ... to_method_property_descriptors({\n to_slash (this: string) {\n if (!this)\n return this\n return path.normalizeSafe(this)\n },\n \n to_backslash (this: string) {\n return this.replaceAll('/', '\\\\')\n },\n })\n })\n \n \n // ------------------------------------ Date.prototype\n Object.defineProperties(Date.prototype, to_method_property_descriptors({\n to_str (this: Date, ms?: boolean) {\n const [ampm, hour] = (() => {\n let hour = this.getHours()\n if (hour <= 6)\n return [t('凌晨'), hour]\n \n if (hour <= 8)\n return [t('清晨'), hour]\n \n if (hour <= 9)\n return [t('早上'), hour]\n \n if (hour <= 10)\n return [t('上午'), hour]\n \n if (hour <= 12)\n return [t('中午'), hour]\n \n hour -= 12\n \n if (hour <= 5)\n return [t('下午'), hour]\n \n if (hour <= 10)\n return [t('晚上'), hour]\n \n return [t('深夜'), hour]\n })()\n \n const zero_padding = { character: '0', position: 'left' } as const\n \n return '' +\n // year.month.date\n this.getFullYear() + '.' + \n String(this.getMonth() + 1).pad(2, zero_padding) + '.' + \n String(this.getDate()).pad(2, zero_padding) + ' ' +\n \n // 上午\n ampm + ' ' +\n \n // 10:03:02\n String(hour).pad(2, zero_padding) + ':' +\n String(this.getMinutes()).pad(2, zero_padding) + ':' +\n String(this.getSeconds()).pad(2, zero_padding) + \n \n (ms ?\n '.' + String(this.getMilliseconds()).pad(3, zero_padding)\n :\n ''\n )\n },\n \n to_date_str (this: Date) {\n return this.to_str().split(' ')[0]\n },\n \n to_time_str (this: Date, ms?: boolean) {\n const [, ampm, time] = this.to_str(ms).split(' ')\n return `${ampm} ${time}`\n },\n }))\n \n \n \n // ------------------------------------ Number.prototype\n Object.defineProperties(Number.prototype, to_method_property_descriptors({\n to_fsize_str (this: number, units: 'iec' | 'metric' = 'iec') {\n const { value, unit } = byte_size(this, { units })\n return `${value} ${unit.replace('i', '')}`\n },\n \n to_bin_str (this: number) {\n return `0b${this.toString(2)}`\n },\n \n to_hex_str (this: number, length?: number) {\n const s = this.toString(16)\n // 长度自动对齐到 4 的倍数\n if (!length)\n length = Math.ceil(s.length / 4) * 4\n return `0x${'0'.repeat(length - s.length)}${s}`\n },\n \n to_oct_str (this: number) {\n return `0o${this.toString(8)}`\n },\n }))\n \n \n \n // ------------------------------------ Array.prototype\n Object.defineProperties(Array.prototype, {\n ... to_getter_property_descriptors({\n last (this: any[]) {\n return this[this.length - 1]\n }\n }),\n \n \n // --- 文本处理工具方法\n ... to_method_property_descriptors({\n log (this: string[], limit: number = 10000) {\n const text = this.join('\\n') + '\\n'\n if (limit === -1 || this.length <= limit)\n console.log(text)\n else if (limit > 0)\n console.log(text.slice(0, limit) + '\\n...'.blue)\n else \n console.log('...\\n'.blue + text.slice(limit))\n },\n \n trim_lines (this: string[], { trim_line = true, rm_empty_lines = true, rm_last_empty_lines = false }: { trim_line?: boolean, rm_empty_lines?: boolean, rm_last_empty_lines?: boolean } = { }) {\n if (!this.length)\n return this\n let lines = this\n \n if (trim_line)\n lines = lines.map(line => line.trim())\n \n if (rm_empty_lines)\n return lines.filter( line => line )\n \n if (rm_last_empty_lines) {\n lines.reverse()\n const i_not_empty = lines.findIndex( line => line )\n if (i_not_empty !== -1)\n lines = lines.slice(i_not_empty)\n lines.reverse()\n return lines\n }\n \n return lines\n },\n \n \n trim_license (this: string[]) {\n const i = this.indexOf('/*')\n const j = this.indexOf('*/')\n if (i === 0 && this[i+1].includes('License'))\n return this.slice(j+1)\n else\n return this\n },\n \n split_indents (this: string[]): { indent: number, text: string }[] {\n return this.map(line => \n line.split_indent()\n )\n },\n \n indent (this: string[], width?: number, character: string = ' ') {\n return this.map(line => \n character.repeat(width) + line\n )\n },\n \n indent2to4 (this: string[]) {\n return this.split_indents()\n .map(line => \n ' '.repeat(\n Math.floor(line.indent / 2) * 4\n ) + line.text\n )\n },\n \n join_lines (this: string[], append = true) {\n return `${this.join('\\n')}${append ? '\\n' : ''}`\n }\n })\n })\n \n \n Object.defineProperties(BigInt.prototype, to_method_property_descriptors({\n toJSON (this: bigint) {\n return this.toString()\n }\n }))\n \n Object.defineProperties(Error.prototype, to_method_property_descriptors({\n toJSON (this: Error) {\n return Object.fromEntries(\n Object.getOwnPropertyNames(this)\n .map(name => \n [name, this[name]])\n )\n }\n }))\n}\n\n\nexport function to_json (obj: any, replacer?: any) {\n return JSON.stringify(obj, replacer, 4) + '\\n'\n}\n\nexport function to_json_safely (obj: any, replacer?: any) {\n return to_json(obj, replacer)\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029')\n .replace(/<\\/script>/g, '<\\\\/script>')\n}\n\n\nexport function is_codepoint_fullwidth (codepoint: number) {\n // code points are derived from:\n // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt\n return (\n !Number.isNaN(codepoint) &&\n codepoint >= 0x1100 &&\n (\n codepoint <= 0x115f || // hangul jamo\n \n codepoint === 0x201c || codepoint === 0x201d || // \n codepoint === 0x2026 || // …\n codepoint === 0x203b || // ※\n \n // arrows\n (0x2190 <= codepoint && codepoint <= 0x21FF) ||\n \n codepoint === 0x2329 || // left-pointing angle bracket\n codepoint === 0x232a || // right-pointing angle bracket\n \n // ①\n (0x2460 <= codepoint && codepoint <= 0x24ff) ||\n \n // box drawing\n (0x2500 <= codepoint && codepoint <= 0x257f) ||\n \n // shapes, symbols, …\n (0x2580 <= codepoint && codepoint <= 0x2bef) ||\n \n // cjk radicals supplement .. enclosed cjk letters and months\n (0x2e80 <= codepoint && codepoint <= 0x3247 && codepoint !== 0x303f) ||\n \n // enclosed cjk letters and months .. cjk unified ideographs extension a\n (0x3250 <= codepoint && codepoint <= 0x4dbf) ||\n \n // cjk unified ideographs .. yi radicals\n (0x4E00 <= codepoint && codepoint <= 0xA4C6) ||\n \n // hangul jamo extended-a\n (0xa960 <= codepoint && codepoint <= 0xa97c) ||\n \n // hangul syllables\n (0xac00 <= codepoint && codepoint <= 0xd7a3) ||\n \n // cjk compatibility ideographs\n (0xf900 <= codepoint && codepoint <= 0xfaff) ||\n \n // vertical forms\n (0xfe10 <= codepoint && codepoint <= 0xfe19) ||\n \n // cjk compatibility forms .. small form variants\n (0xfe30 <= codepoint && codepoint <= 0xfe6b) ||\n \n // halfwidth and fullwidth forms\n (0xff01 <= codepoint && codepoint <= 0xff60) ||\n (0xffe0 <= codepoint && codepoint <= 0xffe6) ||\n \n // kana supplement\n (0x1b000 <= codepoint && codepoint <= 0x1b001) ||\n \n // enclosed ideographic supplement\n (0x1f200 <= codepoint && codepoint <= 0x1f251) ||\n \n // cjk unified ideographs extension b .. tertiary ideographic plane\n (0x20000 <= codepoint && codepoint <= 0x3fffd)\n )\n )\n}\n"]}
1
+ {"version":3,"file":"prototype.js","sourceRoot":"","sources":["prototype.ts"],"names":[],"mappings":"AA4OA,OAAO,IAAI,MAAM,OAAO,CAAA;AACxB,OAAO,SAAS,MAAM,WAAW,CAAA;AAEjC,OAAO,UAAU,MAAM,aAAa,CAAA;AAEpC,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,KAAK,CAAC,KAAK,GAAG,CAAC,CAAA;AAEf,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AAGtC,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,EAAE,CAAA;AAEvC,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,MAAM,UAAU,8BAA8B,CAAE,OAAqC;IACjF,OAAO,MAAM,CAAC,WAAW,CACrB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;SAClB,GAAG,CAAC,CA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C,MAAM,IAAI,SAAS,IAAI,SAAS,IAAI,MAAM,CAAC;YAE5C,gCAAgC;YAChC,CAAC,MAAM,IAAI,SAAS,IAAI,SAAS,IAAI,MAAM,CAAC;YAC5C,CAAC,MAAM,IAAI,SAAS,IAAI,SAAS,IAAI,MAAM,CAAC;YAE5C,kBAAkB;YAClB,CAAC,OAAO,IAAI,SAAS,IAAI,SAAS,IAAI,OAAO,CAAC;YAE9C,kCAAkC;YAClC,CAAC,OAAO,IAAI,SAAS,IAAI,SAAS,IAAI,OAAO,CAAC;YAE9C,mEAAmE;YACnE,CAAC,OAAO,IAAI,SAAS,IAAI,SAAS,IAAI,OAAO,CAAC,CACjD,CACJ,CAAA;AACL,CAAC","sourcesContent":["declare global {\n var my_prototype_defined: boolean\n \n interface String {\n readonly width: number\n \n // --- 工具方法\n /** 截取字符串不超过 width 显示宽度的部分,并保留颜色 \n 找到并记录能容纳 字符串 + … 的最后一个字符的位置 i_fitted \n 若完整的字符串长度超过 width,返回 slice(0, i_fitted + 1) + … \n 否则 返回 this \n */\n truncate (this: string, width: number): string\n \n /** pad string to `<width>` \n - character?: `' '`\n - position?: `'right'`\n */\n pad (this: string, width: number, { character, position }?: { character?: string, position?: 'left' | 'right'}): string\n \n limit (this: string, width: number, { character, position }?: { character?: string, position?: 'left' | 'right'}): string\n \n to_regexp (this: string, preservations?: string, flags?: string): RegExp\n \n to_bool (this: string): boolean\n \n /** 字符串模式替换 \n - pattern: 匹配部分的格式\n - pattern_: 替换后的格式\n - preservations?: `''` 保留的正则表达式字符\n - flags?: `''` 正则匹配选项\n - transformer?: `(name, matched) => matched || ''` placeholder transformer\n - pattern_placeholder?: `/\\{.*?\\}/g`\n \n ```ts\n 'g:/acgn/海贼王/[Skytree][海贼王][One_Piece][893][GB_BIG5_JP][X264_AAC][1080P][CRRIP][天空树双语字幕组].mkv'.refmt( \n '{dirp}/[Skytree][海贼王][{ en_name: \\\\w+ }][{ episode: \\\\d+ }][GB_BIG5_JP][{encoding}_AAC][1080P][CRRIP][天空树双语字幕组].{format}', \n 'g:/acgn/海贼王/{episode} {encoding}.{format}', \n '\\\\+', \n 'i', \n (name, value) => name === 'episode' ? String(+value + 1) : value.toLowerCase() \n )\n ```\n */\n refmt ( this: string,\n pattern: string,\n \n pattern_: string,\n \n preservations?: string,\n \n flags?: string,\n \n transformer?: (name: string, value: string, placeholders: { [name: string]: string }) => string,\n \n pattern_placeholder?: RegExp\n \n ): string\n \n \n /** 字符串模式搜索\n ```ts\n 'git+https://github.com/tamino-martinius/node-ts-dedent-123.git'.find(\n '^{protocol:[\\\\w+]+}://{hostname:[\\\\w\\\\.]+}/{username}/{project}-{index:\\\\d+}.{suffix}', '^', 'i'\n )\n {\n protocol: 'git+https',\n hostname: 'github.com',\n ...\n }\n ```\n \n - preservations?: `''` 保留的正则表达式字符\n - flags?: `''` 正则匹配选项\n - pattern_placeholder?: `/\\{.*?\\}/g`\n */\n find (this: string,\n \n pattern: string, \n \n preservations?: string, \n \n flags?: string, \n \n pattern_placeholder?: RegExp\n \n ): Record<string, string>\n \n \n /** - type?: `'single'` */\n quote (this: string, type?: keyof typeof quotes | 'psh'): string\n \n /** - shape?: `'parenthesis'` */\n bracket (this: string, shape?: keyof typeof brackets): string\n \n surround (this: string, left: string, right?: string): string\n \n surround_tag (this: string, tag_name: string): string\n \n to_lf (this: string): string\n \n to_crlf (this: string): string\n \n /** 'xxx'.replace(/pattern/g, '') \n 如果 pattern 是 string 则在创建 RegExp 时自动加上 flags (默认 'g'), 否则忽略 flags\n */\n rm (this: string, pattern: string | RegExp, flags?: string): string\n \n \n // --- chalk colors\n readonly red: string\n readonly red_: string\n \n readonly green: string\n readonly green_: string\n \n readonly yellow: string\n readonly yellow_: string\n \n readonly blue: string\n readonly blue_: string\n \n readonly magenta: string\n readonly magenta_: string\n \n readonly cyan: string\n readonly cyan_: string\n \n readonly grey: string\n \n readonly underline: string\n \n strip_ansi (this: string): string\n \n \n // --- 文本处理\n /** 将 string 划分为行,并去掉最后一个 \\n 之后的 '' */\n split_lines (this: string): string[]\n \n trim_doc_comment (this: string): string\n \n split_indent (this: string): { indent: number, text: string }\n \n \n to_base64 (this: string): string\n \n \n /** - buffer: `false` 直接返回 Buffer */\n decode_base64 (this: string): string\n decode_base64 (this: string, buffer: true): Buffer\n decode_base64 (this: string, buffer?: boolean): string | Buffer\n \n \n space (this: string): string\n \n \n // --- 文件路径操作\n fdir: string\n \n /** path.basename, 如: \n - d:/0/aaa.txt -> aaa.txt\n - d:/aaa/ -> aaa\n */\n fname: string\n \n /** .txt */\n fext: string\n \n to_slash (this: string): string\n \n to_backslash (this: string): string\n }\n \n \n interface Date {\n /** - ms?: `false` 显示到 ms */\n to_str (this: Date, ms?: boolean): string\n \n to_date_str (this: Date): string\n \n /** - ms?: `false` 显示到 ms */\n to_time_str (this: Date, ms?: boolean): string\n }\n \n \n interface Number {\n /** 12.4 KB (1 KB = 1024 B) */\n to_fsize_str (this: number, units?: 'iec' | 'metric'): string\n \n \n to_bin_str (this: number): string\n \n to_hex_str (this: number, length?: number): string\n \n to_oct_str (this: number): string\n }\n \n \n interface Array<T> {\n last: T\n \n log (this: string[], limit?: number): void\n \n indent (this: string[], width: number, c?: string): string[]\n \n indent2to4 (this: string[]): string[]\n \n \n // --- 文本处理\n /**\n - trim_line?: `true`\n - rm_empty_lines?: `true`\n - rm_last_empty_lines?: `false`\n */\n trim_lines (this: string[], { trim_line, rm_empty_lines, rm_last_empty_lines }?: { trim_line?: boolean, rm_empty_lines?: boolean, rm_last_empty_lines?: boolean }): string[]\n \n trim_license (this: string[]): string[]\n \n split_indents (this: string[]): { indent: number, text: string }[]\n \n /** - append?: `true` 是否在 join 之后增加 \\n */\n join_lines (append?: boolean): string\n }\n \n \n interface BigInt {\n toJSON (this: bigint): string\n }\n \n \n interface Error {\n toJSON (this: Error): string\n }\n}\n\n\nimport path from 'upath'\nimport byte_size from 'byte-size'\n\nimport EmojiRegex from 'emoji-regex'\n\nimport strip_ansi from 'strip-ansi'\nimport chalk from 'chalk'\nchalk.level = 2\n\nimport { t } from './i18n/instance.js'\n\n\nexport const emoji_regex = EmojiRegex()\n\nexport { chalk }\n\nexport function to_method_property_descriptors (methods: { [name: string]: Function }): PropertyDescriptorMap {\n return Object.fromEntries(\n Object.entries(methods)\n .map(([name, value]) => ([name, {\n configurable: true,\n writable: true,\n enumerable: false,\n value,\n } as PropertyDescriptor])\n ))\n}\n\n\nexport function to_getter_property_descriptors (getters: { [name: string]: Function }): PropertyDescriptorMap {\n return Object.fromEntries(\n Object.entries(getters)\n .map(([name, get]) => ([name, {\n configurable: true,\n enumerable: false,\n get,\n } as PropertyDescriptor])\n ))\n}\n\n\nexport const cjk = '([\\u2e80-\\u9fff\\uf900-\\ufaff])'\n\nexport const quotes = {\n single: \"'\",\n double: '\"',\n backtick: '`',\n}\n\nexport const brackets = {\n round: ['(', ')'],\n square: ['[', ']'],\n curly: ['{', '}'],\n pointy: ['<', '>'],\n corner: ['「', '」'],\n fat: ['【', '】'],\n tortoise_shell: ['〔', '〕'],\n} as const\n\nconst color_map = Object.fromEntries(\n ['red_', 'green_', 'yellow_', 'blue_', 'magenta_', 'cyan_'].map(color =>\n [color, `${color.slice(0, -1)}Bright`])\n)\n\n\nif (!global.my_prototype_defined) {\n // ------------------------------------ String.prototype\n Object.defineProperties(String.prototype, {\n ... to_getter_property_descriptors({\n width (this: string) {\n const s = strip_ansi(\n this.replace(emoji_regex, ' ')\n )\n let width = 0\n for (let i = 0; i < s.length; i++) {\n const code = s.codePointAt(i)\n \n if (\n (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) || // ignore control characters\n code >= 0x300 && code <= 0x36f // ignore combining characters\n ) continue\n \n // surrogates\n if (code > 0xffff)\n i++\n \n width += is_codepoint_fullwidth(code) ? 2 : 1\n }\n return width\n }\n }),\n \n \n // ------------ 文本处理工具方法\n ... to_method_property_descriptors({\n /** 截取字符串不超过 width 显示宽度的部分,并保留颜色 \n 找到并记录能容纳 字符串 + … 的最后一个字符的位置 i_fitted \n - 若完整的字符串长度超过 width,返回 slice(0, i_fitted + 1) + … \n - 否则 返回 this \n */\n truncate (this: string, width: number) {\n const color_bak = this.startsWith('\\u001b') ? this.slice(0, 5) : ''\n const s = strip_ansi(this)\n if (width <= 2) return this.slice(0, width)\n let i_fitted = 0\n let fitted_width = 0\n let cur_width = 0\n for (let i = 0; i < s.length; i++) {\n const code = s.codePointAt(i)\n \n if (\n (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) || // Ignore control characters\n code >= 0x300 && code <= 0x36F // Ignore combining characters\n ) continue\n \n // surrogates (codepoint 需要用两个 utf-16 编码单位表示,因此这里跳过第二个编码单位,防止重复计算显示宽度)\n if (code > 0xFFFF)\n i++\n \n const w = is_codepoint_fullwidth(code) ? 2 : 1\n \n if (cur_width + w + 2 <= width) {\n i_fitted = i\n fitted_width += w\n }\n \n cur_width += w\n \n if (cur_width > width) {\n const i_fitted_next = i_fitted + 1\n const t = s.slice(0, i_fitted_next) + ' '.repeat(width - 2 - fitted_width) + '…' \n return color_bak ? color_bak + t + '\\u001b[39m' : t\n }\n }\n return this\n },\n \n \n pad (this: string, width: number, { character = ' ', position = 'right' }: { character?: string, position?: 'left' | 'right'} = { }) {\n const _width = this.width\n if (_width >= width) return this\n if (position === 'right') return this + character.repeat( (width - _width) / character.width )\n return character.repeat(width - _width) + this\n },\n \n \n limit (this: string, width: number, { character = ' ', position = 'right' }: { character?: string, position?: 'left' | 'right'} = { }) {\n return this.pad(width, { character, position }).truncate(width)\n },\n \n \n to_regexp (this: string, preservations: string, flags = ''): RegExp {\n const preserved_chars = new Set(preservations)\n const replace_chars: string = Array.prototype.filter.call('|\\\\{}()[]^$+*?.-', (c: string) => !preserved_chars.has(c))\n .map((c: string) =>\n c === ']' ? '\\\\]' : c\n ).join('')\n \n return new RegExp(\n this.replace(\n new RegExp(`[${replace_chars}]`, 'g'),\n '\\\\$&'\n ), \n flags\n )\n },\n \n \n to_bool (this: string) {\n return this.length && this !== '0' && this.toLowerCase() !== 'false'\n },\n \n refmt (this: string, \n pattern : string,\n pattern_: string,\n preservations: string = '',\n flags = '',\n transformer: (name: string, value: string, placeholders: { [name: string]: string }) => string = (name, value) => value || '',\n pattern_placeholder = /\\{.*?\\}/g,\n ): string {\n // --- 转换 pattern 为 pattern_regx\n let last_end = 0\n \n // placeholder matched group indexes\n let $placeholders: Record<string, number> = { }\n \n let regx_parts = [ ]\n \n function add_part (left: number, right?: number) {\n const part = pattern.slice(left, right)\n if (part)\n regx_parts.push(\n part.to_regexp(preservations).source.bracket()\n )\n }\n \n pattern.replace(pattern_placeholder, ($0, offset) => {\n add_part(last_end, offset)\n last_end = offset + $0.length\n \n const placeholder = $0.slice(1, -1)\n let [placeholder_name, placeholder_pattern] = placeholder.split(':').map(s => s.trim())\n let optional = false\n if (placeholder_name.endsWith('?')) {\n placeholder_name = placeholder_name.slice(0, -1)\n optional = true\n }\n $placeholders[placeholder_name] = regx_parts.push(\n placeholder_pattern ? \n `${placeholder_pattern.bracket()}${optional ? '?' : ''}`\n :\n '(.*?)'\n )\n return ''\n })\n \n add_part(last_end)\n \n // 最后一个 (.*?) 改为贪心匹配,满足 .{suffix} 的需要\n regx_parts = regx_parts.filter(part => part)\n if (regx_parts.last === '(.*?)')\n regx_parts[regx_parts.length - 1] = '(.*)'\n \n const pattern_regx = new RegExp(regx_parts.join(''), flags)\n \n \n // --- 根据 pattern_regx 去匹配原有字符串,获取匹配结果,生成 placeholders 词典\n const matches = pattern_regx.exec(this)\n \n if (!matches) return this\n \n const placeholders = Object.fromEntries(\n Object.entries($placeholders)\n .map(([name, $i]) => [\n [name, matches[$i]],\n [`${name}.before`, matches[$i - 1] || ''],\n [`${name}.after`, matches[$i + 1] || ''],\n ])\n .flat()\n )\n \n \n // --- 转换 pattern_ 为 replacement_str,如果有 transformer 则在遇到 placeholder 时应用\n last_end = 0\n let replacement_parts = [ ]\n \n pattern_.replace(pattern_placeholder, ($0, offset) => {\n replacement_parts.push(\n pattern_.slice(last_end, offset)\n )\n last_end = offset + $0.length\n \n const placeholder_name = $0.slice(1, -1)\n \n replacement_parts.push(\n transformer(placeholder_name, placeholders[placeholder_name], placeholders)\n )\n \n return ''\n })\n replacement_parts.push(\n pattern_.slice(last_end)\n )\n \n return this.replace(pattern_regx, replacement_parts.join(''))\n },\n \n \n find (this: string,\n pattern: string, \n preservations: string = '', \n flags = '', \n pattern_placeholder = /\\{.*?\\}/g\n ): Record<string, string> {\n // --- 转换 pattern 为 pattern_regx\n let last_end = 0\n \n // placeholder matched group index\n let $placeholders: Record<string, number> = { }\n \n let regx_parts = [ ]\n \n function add_part (left: number, right?: number) {\n const part = pattern.slice(left, right)\n if (part)\n regx_parts.push(\n part.to_regexp(preservations).source.bracket()\n )\n }\n \n pattern.replace(pattern_placeholder, ($0, offset) => {\n add_part(last_end, offset)\n last_end = offset + $0.length\n \n const placeholder = $0.slice(1, -1)\n let [placeholder_name, placeholder_pattern] = placeholder.split(':').map(s => s.trim())\n let optional = false\n if (placeholder_name.endsWith('?')) {\n placeholder_name = placeholder_name.slice(0, -1)\n optional = true\n }\n \n $placeholders[placeholder_name] = regx_parts.push(\n placeholder_pattern ? \n `${placeholder_pattern.bracket()}${optional ? '?' : ''}`\n :\n '(.*?)'\n )\n return ''\n })\n \n add_part(last_end)\n \n // 最后一个 (.*?) 改为贪心匹配,满足 .{suffix} 的需要\n regx_parts = regx_parts.filter(part => part)\n if (regx_parts[regx_parts.length - 1] === '(.*?)')\n regx_parts[regx_parts.length - 1] = '(.*)'\n \n const pattern_regx = new RegExp(regx_parts.join(''), flags)\n \n \n // --- 根据 pattern_regx 去匹配原有字符串,获取匹配结果,生成 placeholders 词典\n const matches = pattern_regx.exec(this)\n \n if (!matches) return { }\n \n return Object.fromEntries(\n Object.entries($placeholders)\n .map(([name, $i]) => \n [name, matches[$i] || '']\n )\n )\n },\n \n quote (this: string, type: keyof typeof quotes | 'psh' = 'single') {\n if (type === 'psh')\n return `& ${this.quote()}`\n return this.surround(quotes[type])\n },\n \n \n bracket (this: string, shape: keyof typeof brackets = 'round') {\n return this.surround(...brackets[shape] as [string, string])\n },\n \n \n surround (this: string, left: string, right?: string) {\n return left + this + (right || left)\n },\n \n surround_tag (this: string, tag_name: string): string {\n return '<' + tag_name + '>' + this + '</' + tag_name + '>'\n },\n \n \n to_lf (this: string) {\n return this.replace(/\\r\\n/g, '\\n')\n },\n \n \n to_crlf (this: string) {\n return this.replace(/\\n/g, '\\r\\n')\n },\n \n \n rm (this: string, pattern: string | RegExp, flags: string = 'g') {\n if (typeof pattern === 'string')\n pattern = new RegExp(pattern, flags)\n \n return this.replace(pattern, '')\n },\n \n \n split_lines (this: string, delimiter: string | RegExp = /\\r?\\n/) {\n let lines = this.split(delimiter)\n if (lines.last === '')\n lines.pop()\n return lines\n },\n \n \n split_indent (this: string): { indent: number, text: string } {\n let i = 0\n let indent = 0\n for (; i < this.length; i++)\n if (this[i] === ' ')\n indent += 1\n else if (this[i] === '\\t')\n indent += 4\n else\n break\n \n return {\n indent,\n text: this.slice(i)\n }\n },\n \n \n trim_doc_comment (this: string) {\n return `/** ${this.slice(3, -2).replace(/\\s*\\*\\s*/g, ' ').replace(/@(param|params|return) \\{.*?\\}\\s*/g, '').trim()} */`\n },\n \n \n to_base64 (this: string) {\n return Buffer.from(this).toString('base64')\n },\n \n \n decode_base64 (this: string, buffer = false) {\n const buf = Buffer.from(this, 'base64')\n if (buffer)\n return buf\n return buf.toString()\n },\n \n \n strip_ansi (this: string) {\n return strip_ansi(this)\n },\n \n \n space (this: string) {\n if (!this) return this\n let text_: string\n text_ = this\n .replace(new RegExp(cjk + `(['\"])`, 'g'), '$1 $2')\n .replace(new RegExp(`(['\"])` + cjk, 'g'), '$1 $2')\n \n .replace(/([\"']+)\\s*(.+?)\\s*([\"']+)/g, '$1$2$3')\n \n .replace(new RegExp(cjk + '([\\\\+\\\\-\\\\*\\\\/=&\\\\\\\\\\\\|<>])([A-Za-z0-9])', 'g'), '$1 $2 $3')\n .replace(new RegExp('([A-Za-z0-9])([\\\\+\\\\-\\\\*\\\\/=&\\\\\\\\\\\\|<>])' + cjk, 'g'), '$1 $2 $3')\n \n const text_bak = text_\n \n text_ = text_.replace(new RegExp(cjk + '([\\\\(\\\\[\\\\{<\\u201c]+(.*?)[\\\\)\\\\]\\\\}>\\u201d]+)' + cjk, 'g'), '$1 $2 $4')\n \n if (text_ === text_bak)\n text_ = text_\n .replace(new RegExp(cjk + '([\\\\(\\\\[\\\\{<\\u201c>])', 'g'), '$1 $2')\n .replace(new RegExp('([\\\\)\\\\]\\\\}>\\u201d<])' + cjk, 'g'), '$1 $2')\n \n return text_\n .replace(/([\\(\\[\\{<\\u201c]+)(\\s*)(.+?)(\\s*)([\\)\\]\\}>\\u201d]+)/g, '$1$3$5')\n .replace(new RegExp(cjk + '([~!;:,\\\\.\\\\?\\u2026])([A-Za-z0-9])', 'g'), '$1$2 $3')\n .replace(new RegExp(cjk + '([A-Za-z0-9`\\\\$%\\\\^&\\\\*\\\\-=\\\\+\\\\\\\\\\\\|\\\\/@\\u00a1-\\u00ff\\u2022\\u2027\\u2150-\\u218f])', 'g'), '$1 $2')\n .replace(new RegExp('([A-Za-z0-9`\\\\$%\\\\^&\\\\*\\\\-=\\\\+\\\\\\\\\\\\|\\\\/@\\u00a1-\\u00ff\\u2022\\u2027\\u2150-\\u218f])' + cjk, 'g'), '$1 $2')\n }\n }),\n \n \n // ------------ chalk colors\n ... Object.fromEntries(\n [\n 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'grey', \n 'red_', 'green_', 'yellow_', 'blue_', 'magenta_', 'cyan_',\n 'underline',\n ].map(color =>\n ([color, {\n configurable: true,\n get (this: string) {\n return chalk[color_map[color] || color](this)\n }\n }]))\n ),\n \n \n // ------------ 文件路径操作\n ... to_getter_property_descriptors({\n fdir (this: string) {\n const dir = path.dirname(this)\n return dir.endsWith('/') ? dir : `${dir}/`\n },\n \n fname (this: string) {\n return path.basename(this)\n },\n \n fext (this: string) {\n return path.extname(this)\n },\n }),\n \n ... to_method_property_descriptors({\n to_slash (this: string) {\n if (!this)\n return this\n return path.normalizeSafe(this)\n },\n \n to_backslash (this: string) {\n return this.replaceAll('/', '\\\\')\n },\n })\n })\n \n \n // ------------------------------------ Date.prototype\n Object.defineProperties(Date.prototype, to_method_property_descriptors({\n to_str (this: Date, ms?: boolean) {\n const [ampm, hour] = (() => {\n let hour = this.getHours()\n if (hour <= 6)\n return [t('凌晨'), hour]\n \n if (hour <= 8)\n return [t('清晨'), hour]\n \n if (hour <= 9)\n return [t('早上'), hour]\n \n if (hour <= 10)\n return [t('上午'), hour]\n \n if (hour <= 12)\n return [t('中午'), hour]\n \n hour -= 12\n \n if (hour <= 5)\n return [t('下午'), hour]\n \n if (hour <= 10)\n return [t('晚上'), hour]\n \n return [t('深夜'), hour]\n })()\n \n const zero_padding = { character: '0', position: 'left' } as const\n \n return '' +\n // year.month.date\n this.getFullYear() + '.' + \n String(this.getMonth() + 1).pad(2, zero_padding) + '.' + \n String(this.getDate()).pad(2, zero_padding) + ' ' +\n \n // 上午\n ampm + ' ' +\n \n // 10:03:02\n String(hour).pad(2, zero_padding) + ':' +\n String(this.getMinutes()).pad(2, zero_padding) + ':' +\n String(this.getSeconds()).pad(2, zero_padding) + \n \n (ms ?\n '.' + String(this.getMilliseconds()).pad(3, zero_padding)\n :\n ''\n )\n },\n \n to_date_str (this: Date) {\n return this.to_str().split(' ')[0]\n },\n \n to_time_str (this: Date, ms?: boolean) {\n const [, ampm, time] = this.to_str(ms).split(' ')\n return `${ampm} ${time}`\n },\n }))\n \n \n \n // ------------------------------------ Number.prototype\n Object.defineProperties(Number.prototype, to_method_property_descriptors({\n to_fsize_str (this: number, units: 'iec' | 'metric' = 'iec') {\n const { value, unit } = byte_size(this, { units })\n return `${value} ${unit.replace('i', '')}`\n },\n \n to_bin_str (this: number) {\n return `0b${this.toString(2)}`\n },\n \n to_hex_str (this: number, length?: number) {\n const s = this.toString(16)\n // 长度自动对齐到 4 的倍数\n if (!length)\n length = Math.ceil(s.length / 4) * 4\n return `0x${'0'.repeat(length - s.length)}${s}`\n },\n \n to_oct_str (this: number) {\n return `0o${this.toString(8)}`\n },\n }))\n \n \n \n // ------------------------------------ Array.prototype\n Object.defineProperties(Array.prototype, {\n ... to_getter_property_descriptors({\n last (this: any[]) {\n return this[this.length - 1]\n }\n }),\n \n \n // --- 文本处理工具方法\n ... to_method_property_descriptors({\n log (this: string[], limit: number = 10000) {\n const text = this.join('\\n') + '\\n'\n if (limit === -1 || this.length <= limit)\n console.log(text)\n else if (limit > 0)\n console.log(text.slice(0, limit) + '\\n...'.blue)\n else \n console.log('...\\n'.blue + text.slice(limit))\n },\n \n trim_lines (this: string[], { trim_line = true, rm_empty_lines = true, rm_last_empty_lines = false }: { trim_line?: boolean, rm_empty_lines?: boolean, rm_last_empty_lines?: boolean } = { }) {\n if (!this.length)\n return this\n let lines = this\n \n if (trim_line)\n lines = lines.map(line => line.trim())\n \n if (rm_empty_lines)\n return lines.filter( line => line )\n \n if (rm_last_empty_lines) {\n lines.reverse()\n const i_not_empty = lines.findIndex( line => line )\n if (i_not_empty !== -1)\n lines = lines.slice(i_not_empty)\n lines.reverse()\n return lines\n }\n \n return lines\n },\n \n \n trim_license (this: string[]) {\n const i = this.indexOf('/*')\n const j = this.indexOf('*/')\n if (i === 0 && this[i+1].includes('License'))\n return this.slice(j+1)\n else\n return this\n },\n \n split_indents (this: string[]): { indent: number, text: string }[] {\n return this.map(line => \n line.split_indent()\n )\n },\n \n indent (this: string[], width?: number, character: string = ' ') {\n return this.map(line => \n character.repeat(width) + line\n )\n },\n \n indent2to4 (this: string[]) {\n return this.split_indents()\n .map(line => \n ' '.repeat(\n Math.floor(line.indent / 2) * 4\n ) + line.text\n )\n },\n \n join_lines (this: string[], append = true) {\n return `${this.join('\\n')}${append ? '\\n' : ''}`\n }\n })\n })\n \n \n Object.defineProperties(BigInt.prototype, to_method_property_descriptors({\n toJSON (this: bigint) {\n return this.toString()\n }\n }))\n \n Object.defineProperties(Error.prototype, to_method_property_descriptors({\n toJSON (this: Error) {\n return Object.fromEntries(\n Object.getOwnPropertyNames(this)\n .map(name => \n [name, this[name]])\n )\n }\n }))\n}\n\n\nexport function to_json (obj: any, replacer?: any) {\n return JSON.stringify(obj, replacer, 4) + '\\n'\n}\n\nexport function to_json_safely (obj: any, replacer?: any) {\n return to_json(obj, replacer)\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029')\n .replace(/<\\/script>/g, '<\\\\/script>')\n}\n\n\nexport function is_codepoint_fullwidth (codepoint: number) {\n // code points are derived from:\n // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt\n return (\n !Number.isNaN(codepoint) &&\n codepoint >= 0x1100 &&\n (\n codepoint <= 0x115f || // hangul jamo\n \n codepoint === 0x201c || codepoint === 0x201d || // \n codepoint === 0x2026 || // …\n codepoint === 0x203b || // ※\n \n // arrows\n (0x2190 <= codepoint && codepoint <= 0x21FF) ||\n \n codepoint === 0x2329 || // left-pointing angle bracket\n codepoint === 0x232a || // right-pointing angle bracket\n \n // ①\n (0x2460 <= codepoint && codepoint <= 0x24ff) ||\n \n // box drawing\n (0x2500 <= codepoint && codepoint <= 0x257f) ||\n \n // shapes, symbols, …\n (0x2580 <= codepoint && codepoint <= 0x2bef) ||\n \n // cjk radicals supplement .. enclosed cjk letters and months\n (0x2e80 <= codepoint && codepoint <= 0x3247 && codepoint !== 0x303f) ||\n \n // enclosed cjk letters and months .. cjk unified ideographs extension a\n (0x3250 <= codepoint && codepoint <= 0x4dbf) ||\n \n // cjk unified ideographs .. yi radicals\n (0x4E00 <= codepoint && codepoint <= 0xA4C6) ||\n \n // hangul jamo extended-a\n (0xa960 <= codepoint && codepoint <= 0xa97c) ||\n \n // hangul syllables\n (0xac00 <= codepoint && codepoint <= 0xd7a3) ||\n \n // cjk compatibility ideographs\n (0xf900 <= codepoint && codepoint <= 0xfaff) ||\n \n // vertical forms\n (0xfe10 <= codepoint && codepoint <= 0xfe19) ||\n \n // cjk compatibility forms .. small form variants\n (0xfe30 <= codepoint && codepoint <= 0xfe6b) ||\n \n // halfwidth and fullwidth forms\n (0xff01 <= codepoint && codepoint <= 0xff60) ||\n (0xffe0 <= codepoint && codepoint <= 0xffe6) ||\n \n // kana supplement\n (0x1b000 <= codepoint && codepoint <= 0x1b001) ||\n \n // enclosed ideographic supplement\n (0x1f200 <= codepoint && codepoint <= 0x1f251) ||\n \n // cjk unified ideographs extension b .. tertiary ideographic plane\n (0x20000 <= codepoint && codepoint <= 0x3fffd)\n )\n )\n}\n"]}
package/repl.js CHANGED
@@ -354,7 +354,4 @@ export async function pollute_module_exports(fp_mod) {
354
354
  export async function pollute_module_default_export(fp_mod, name) {
355
355
  global[name] = (await import(fp_mod)).default;
356
356
  }
357
- function log_mod_loaded(id) {
358
- console.log(id.pad(40) + t('已加载'));
359
- }
360
357
  //# sourceMappingURL=repl.js.map