xshell 1.0.23 → 1.0.24

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/process.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"process.js","sourceRoot":"","sources":["process.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EAGR,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAA;AAE7B,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AAEtC,OAAO,gBAAgB,CAAA;AAEvB,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAGnD,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAA;AA0CrD;;;;;;;;;;EAUE;AACF,MAAM,CAAC,KAAK,UAAU,KAAK,CAAE,GAAW,EAAE,OAAiB,EAAG,EAAE,EAC5D,GAAG,EAEH,QAAQ,GAAG,OAAO,EAElB,KAAK,GAAG,IAAI,EAEZ,KAAK,GAAG,MAAM,EAEd,QAAQ,GAAG,KAAK,EAEhB,GAAG,EAEH,MAAM,EAAE,OAAO,GAAG,IAAI,MACR,EAAG;IACjB,MAAM,OAAO,GAAiB;QAC1B,GAAG;QACH,KAAK,EAAE,KAAK;QACZ,WAAW,EAAE,CAAC,OAAO;QACrB,KAAK;QACL,GAAI,GAAG,CAAC,CAAC,CAAC;YACN,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE;SAClC,CAAC,CAAC,CAAC,EAAG;KACV,CAAA;IAED,IAAI,OAAO,KAAK,KAAK,SAAS;QAC1B,KAAK,GAAG;YACJ,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,KAAK;SACd,CAAA;IAEL,IAAI,OAAO,KAAK,KAAK,QAAQ;QACzB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AC,CAAC;YACV,MAAM,CAAC,CAAC,CAAC,yBAAyB,OAAO,EAAE,CAAC,CAAC,CAAC,qBAAqB,OAAO,EAAE;SAC/E,CAAC,CAAC,CAAC,EAAG;QACP,GAAI,MAAM,CAAC,CAAC,CAAC;YACT,sBAAsB;YACtB,0CAA0C;SAC7C,CAAC,CAAC,CAAC,EAAG;QACP,KAAK;QACL,GAAI,IAAI;KACX,EAAE;QACC,KAAK;QACL,GAAG,QAAQ;KACd,CAAC,CAAA;AACN,CAAC;AAGD,MAAM,eAAe,GAAG;IACpB,CAAC,WAAW,CAAC,EAAE,MAAM;IACrB,CAAC,UAAU,CAAC,EAAE,MAAM;CACd,CAAA","sourcesContent":["import {\n spawn,\n type SpawnOptions,\n type ChildProcess\n} from 'child_process'\nimport { userInfo } from 'os'\n\nimport { t } from './i18n/instance.js'\n\nimport './prototype.js'\nimport { Encoding } from './file.js'\nimport { inspect, DecoderStream } from './utils.js'\n\n\nexport const exe_nodejs = process.execPath.to_slash()\n\n\n// ------------------------------------ start & call\ninterface StartOptions {\n /** `继承当前工作目录 process.cwd()` 子进程的工作目录 `inherit the cwd` cwd of the child process. */\n cwd?: string\n \n /** `process.env` 覆盖/添加到 process.env 的环境变量 overwrite/add to process.env */\n env?: Record<string, string>\n \n /** `'utf-8'` 子进程输出编码 child output encoding */\n encoding?: Encoding | 'binary'\n \n /** `true` print 选项,支持设置细项 print option (with details) */\n print?: boolean | {\n stdout: boolean\n stderr: boolean\n command: boolean\n code: boolean\n }\n \n /** `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing */\n stdio?: 'pipe' | 'ignore' | ['pipe' | 'ignore' | 'inherit', 'pipe' | 'ignore' | 'inherit', 'pipe' | 'ignore' | 'inherit']\n \n /** `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref) */\n detached?: boolean\n \n /** 为 true 时会设置 UV_PROCESS_WINDOWS_HIDE \n 然后设置启动进程的参数 CREATE_NO_WINDOW, 和 SW_HIDE \n d:/0/libuv/src/win/process.c \n CREATE_NO_WINDOW:\n The process is a console application that is being run without a console window. \n Therefore, the console handle for the application is not set.\n This flag is ignored if the application is not a console application, or \n if it is used with either CREATE_NEW_CONSOLE or DETACHED_PROCESS.\n \n 具体有什么用还不清楚\n */\n window?: boolean\n}\n\n/** start process \n - exe: .exe 路径或文件名 (建议使用完整路径,跳过 path 搜索,性能更高) path or filename (full path is recommanded to skip path searching for better perf)\n - args: `[]` 参数列表 arguments list\n - options\n - cwd?: `fp_root`\n - env?: `process.env` 覆盖/添加到 process.env 的环境变量 overwrite/add to process.env\n - encoding?: `'utf-8'` 子进程输出编码 child output encoding\n - print?: `true` print 选项,支持设置细项 print option (with details)\n - stdio?: `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing\n - detached?: `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref)\n*/\nexport async function start (exe: string, args: string[] = [ ], {\n cwd,\n \n encoding = 'utf-8',\n \n print = true,\n \n stdio = 'pipe',\n \n detached = false,\n \n env,\n \n window: _window = true,\n}: StartOptions = { }): Promise<ChildProcess> {\n const options: SpawnOptions = {\n cwd,\n shell: false,\n windowsHide: !_window,\n stdio,\n ... env ? {\n env: { ...process.env, ...env }\n } : { },\n }\n \n if (typeof print === 'boolean')\n print = {\n stdout: print,\n stderr: print,\n command: print,\n code: print,\n }\n \n if (typeof stdio === 'string')\n stdio = [stdio, stdio, stdio]\n \n if (print.command)\n console.log((\n (short_exe_names[exe] || (exe.includes(' ') ? exe.quote() : exe)) +\n (args.length ? \n ' ' + args.filter(arg => arg !== '--suppressApplicationTitle')\n .map(arg => arg.includes(' ') ? arg.quote() : arg)\n .join(' ')\n :\n '')\n ).blue)\n \n if (detached) {\n let child = spawn(exe, args, {\n ...options,\n stdio: 'ignore',\n detached: true,\n })\n \n child.unref()\n return child\n }\n \n let child = spawn(exe, args, options)\n \n // 防止 child spawn 失败时 crash nodejs 进程\n child.on('error', error => {\n console.error(error)\n })\n \n if (stdio[0] === 'pipe')\n child.stdin.setDefaultEncoding('utf8')\n \n if (\n stdio.every(s => \n s === 'ignore')\n )\n return child\n \n if (encoding !== 'binary') {\n if (stdio[1] === 'pipe') {\n if (encoding === 'utf-8')\n child.stdout.setEncoding('utf-8')\n else\n child.stdout = child.stdout.pipe(new DecoderStream(encoding))\n \n if (print.stdout)\n child.stdout.pipe(process.stdout, { end: false })\n }\n \n if (stdio[2] === 'pipe') {\n if (encoding === 'utf-8')\n child.stderr.setEncoding('utf-8')\n else\n child.stderr = child.stderr.pipe(new DecoderStream(encoding))\n \n if (print.stderr)\n child.stderr.pipe(process.stderr, { end: false })\n }\n }\n \n return child\n}\n\n\nexport interface CallOptions extends StartOptions {\n throw_code?: boolean\n input?: string\n}\n\nexport interface CallResult <TOutput extends string | Buffer = string> {\n pid: number\n stdout: TOutput\n stderr: TOutput\n code: number | null\n signal: NodeJS.Signals | null\n child: ChildProcess\n [inspect.custom] (): string\n}\n\n\n/** call process for result\n - exe: .exe 路径或文件名 (建议使用路径,跳过 path 搜索,性能更高) path or filename (full path is recommanded to skip path searching for better perf)\n - args: `[]` 参数列表 arguments list\n - options?:\n - cwd?: `'d:/'`\n - env?: `process.env` 覆盖/添加到 process.env 的环境变量 overwrite/add to process.env\n - encoding?: `'utf-8'` 子进程输出编码, 设置为 binary 时返回 stdout, stderr 类型为 Buffer; 否则是 string \n child output encoding. When set to binary, return stdout, stderr is of type Buffer; otherwise it is string\n - print?: `true` print 选项,支持设置细项 print option (with details)\n - stdio?: `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing\n - input?: string, start 子进程之后写入到子进程 stdin 中的内容 After starting the sub-process, write to the content of the sub-process STDIN\n - detached?: `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref)\n - throw_code?: `true` code 不为 0 时是否抛出异常 whether to throw Error when code is not 0 */\nexport async function call (exe: string, args?: string[]): Promise<CallResult<string>>\nexport async function call (exe: string, args?: string[], options?: CallOptions & { encoding: 'binary' }): Promise<CallResult<Buffer>>\nexport async function call (exe: string, args?: string[], options?: CallOptions): Promise<CallResult<string>>\nexport async function call (exe: string, args: string[] = [ ], options: CallOptions = { }): Promise<CallResult<string | Buffer>> {\n const {\n encoding = 'utf-8', \n throw_code = true,\n input,\n } = options\n \n let {\n stdio = 'pipe',\n print = true\n } = options\n \n if (typeof print === 'boolean')\n print = {\n command: print,\n stdout: print,\n stderr: print,\n code: print,\n }\n \n if (typeof stdio === 'string')\n stdio = [stdio, stdio, stdio]\n \n const cmd = \n (short_exe_names[exe] || (exe.includes(' ') ? exe.quote() : exe)) + \n (args.length ? (\n ' ' + args.map(arg => arg.includes(' ') ? arg.quote() : arg)\n .join(' '))\n :\n '')\n \n if (print.command)\n console.log(cmd.blue)\n \n let child = await start(exe, args, {\n ...options,\n print: false,\n })\n \n if (input)\n child.stdin.write(input)\n \n // --- collect output\n let stdouts: (string | Buffer)[] = [ ]\n let stderrs: (string | Buffer)[] = [ ]\n \n let code: number | null, \n signal: NodeJS.Signals\n \n await Promise.all([\n new Promise<void>(resolve => {\n child.once('exit', (_code, _signal) => {\n code = _code\n signal = _signal\n resolve()\n })\n }),\n (async () => {\n if (stdio[1] === 'pipe')\n for await (const chunk of child.stdout as AsyncIterable<string | Buffer>) {\n if (encoding !== 'binary' && print.stdout)\n process.stdout.write(chunk)\n stdouts.push(chunk)\n }\n })(),\n (async () => {\n if (stdio[2] === 'pipe')\n for await (const chunk of child.stderr as AsyncIterable<string | Buffer>) {\n if (encoding !== 'binary' && print.stderr)\n process.stderr.write(chunk)\n stderrs.push(chunk)\n }\n })()\n ])\n \n const message = `${t('进程')} ${cmd} ` + (\n code ? \n `(pid: ${child.pid}) ${ throw_code ? t('异常结束') : t('结束') }, code: ${code}${ signal ? `, signal: ${ signal }` : '' }`\n :\n t('正常结束'))\n \n if (print.code || (throw_code && (code || signal)))\n console.log(message[(throw_code && (code || signal)) ? 'red' : 'blue'])\n \n const result = {\n pid: child.pid,\n \n stdout: encoding === 'binary' ?\n Buffer.concat(stdouts as Buffer[])\n :\n (stdouts as string[]).join(''),\n \n stderr: encoding === 'binary' ?\n Buffer.concat(stderrs as Buffer[])\n :\n (stderrs as string[]).join(''),\n \n code,\n \n signal,\n \n child,\n \n [inspect.custom] () {\n return inspect(this, { omit: ['child'] })\n }\n }\n \n if (code && throw_code)\n throw Object.assign(new Error(message), { result })\n \n return result\n}\n\n\n/** call node <js> for result\n - js: .js 路径 (相对路径根据 cwd 解析) path (relative path will resolve based on cwd)\n - args: `[]` 参数列表 arguments list\n - options\n - cwd?: `'d:/'`\n - env?: `process.env` 覆盖/添加到 process.env 的环境变量 overwrite/add to process.env\n - encoding?: `'utf-8'` 子进程输出编码 child process output encoding\n - print?: `true` print 选项,支持设置细项 print option (with details)\n - stdio?: `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing\n - detached?: `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref)\n - throw_code?: `true` code 不为 0 时是否抛出异常 whether to throw Error when code is not 0 */\nexport async function call_nodejs (js: string, args: string[] = [], options?: CallOptions) {\n return call(exe_nodejs, [js, ...args], options)\n}\n\n\n// ------------------------------------ term\nexport interface TermOptions {\n /** `d:/t/` */\n cwd?: string\n \n /** `true` 打印参数 */\n print?: boolean\n \n title?: string\n \n // 不支持 background, 在 WinTerm 中后台创建标签页,而非创建并切换到该标签页\n // 不支持 icon\n // 不支持 env, WindowsTerminal 在调用 CreateProcess API 时没有传入 env\n}\n\nexport const exe_winterm = `C:/Users/${userInfo().username}/AppData/Local/Microsoft/WindowsApps/wt.exe`\n\n/** 新建 terminal 窗口执行进程 New Terminal window execution process\n - exe: exe 文件路径 exe file path\n - args: 调用参数 call parameter\n - options?: WinTermOptions\n*/\nexport function term (exe: string, args: string[] = [], {\n cwd = 'd:/t/',\n \n print = true,\n \n title,\n \n // env\n}: TermOptions = { }) {\n \n \n return start(\n exe_winterm,\n [\n 'new-tab',\n \n '-d', cwd,\n \n ... title ? ['--suppressApplicationTitle', '--title', title] : [ ],\n \n exe,\n \n ...args.map(arg => \n arg.replaceAll(';', '\\\\;')), \n ],\n {\n print,\n detached: true,\n cwd,\n // env\n }\n )\n}\n\n\nexport interface TermNodeOptions extends TermOptions {\n /** nodejs debugger port */\n inspect?: number\n \n /** break at first line */\n break?: boolean\n \n /** 使用 ts-node 直接运行 use ts-node to run directly */\n tsnode?: boolean\n \n /** `false` --experimental-specifier-resolution=node */\n resolve?: boolean\n \n /** `false` --trace-warnings */\n trace_warnings?: boolean\n}\n\n\n/** 在 term tab 中创建 node.exe 进程 create the node.exe process in term tab */\nexport async function term_nodejs (\n fp_js: string, \n args: string[] = [ ],\n {\n title, \n inspect, \n tsnode = false,\n break: _break,\n resolve = false,\n trace_warnings = false,\n ..._options\n }: TermNodeOptions = { }\n) {\n return term(exe_nodejs, [\n ... trace_warnings ? ['--trace-warnings'] : [ ],\n ... resolve ? ['--experimental-specifier-resolution=node'] : [ ],\n ... title ? [`--title=${title}`] : [ ],\n ... inspect ? [\n _break ? `--inspect-brk=0.0.0.0:${inspect}` : `--inspect=0.0.0.0:${inspect}`\n ] : [ ],\n ... tsnode ? [\n '--loader=ts-node/esm',\n '--experimental-specifier-resolution=node'\n ] : [ ],\n fp_js,\n ... args\n ], {\n title,\n ..._options,\n })\n}\n\n\nconst short_exe_names = {\n [exe_winterm]: 'term',\n [exe_nodejs]: 'node',\n} as const\n\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"prototype.browser.js","sourceRoot":"","sources":["prototype.browser.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAgL/B,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,UAAU,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AAEtC,MAAM,CAAC,MAAM,WAA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AI,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":["/** 在浏览器端修改 prototype,需要更加小心 */\n\ndeclare global {\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 // --- 文本处理\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 space (this: string): 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 indent (this: string[], width: number, c?: string): string[]\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 /** - 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\nimport byte_size from 'byte-size'\nimport EmojiRegex from 'emoji-regex'\n\nimport { t } from './i18n/instance.js'\n\nexport const emoji_regex = EmojiRegex()\n\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\n\n\n// ------------------------------------ String.prototype\nObject.defineProperties(String.prototype, {\n ... to_getter_property_descriptors({\n width (this: string) {\n const s = this.replace(emoji_regex, ' ')\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 // ------------ 文本处理工具方法\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 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 < this.length; i++) {\n const code = this.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 = this.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 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 textBak = text_\n \n text_ = text_.replace(new RegExp(cjk + '([\\\\(\\\\[\\\\{<\\u201c]+(.*?)[\\\\)\\\\]\\\\}>\\u201d]+)' + cjk, 'g'), '$1 $2 $4')\n \n if (text_ === textBak)\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 to_slash (this: string) {\n return this.replaceAll('\\\\', '/')\n },\n \n to_backslash (this: string) {\n return this.replaceAll('/', '\\\\')\n },\n })\n})\n\n\n// ------------------------------------ Date.prototype\nObject.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\nObject.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\nObject.defineProperties(Array.prototype, {\n // --- 文本处理工具方法\n ... to_method_property_descriptors({\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 indent (this: string[], width?: number, character: string = ' ') {\n return this.map(line => \n character.repeat(width) + line\n )\n },\n \n \n join_lines (this: string[], append = true) {\n return `${this.join('\\n')}${append ? '\\n' : ''}`\n }\n })\n})\n\n\nObject.defineProperties(BigInt.prototype, to_method_property_descriptors({\n toJSON (this: bigint) {\n return this.toString()\n }\n}))\n\nObject.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 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/prototype.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"prototype.js","sourceRoot":"","sources":["prototype.ts"],"names":[],"mappings":"AA2OA,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,WA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AAM,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 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)}${this.endsWith('/') ? '/' : ''}`\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.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"repl.js","sourceRoot":"","sources":["repl.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,IAAI,CAAA;AACpB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAGnC,OAAO,IAAI,MAAM,OAAO,CAAA;AAExB,OAAO,EAAE,MAAM,YAAY,CAAA;AAM3B,MAAM,EACF,OAAO,EAAE,aAAa,EAEtB,UAAU,EAAE,SAAS,EAAE,aAAa,EAEpC,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,iBAAiB,EACpE,qBAAqB,EAAE,mBAAmB,EAC1C,iBAAiB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,iBAAiB,E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AO,MAAM,CAAA;QACjB,CAAC;QACD,OAAO,EAAE,MAAM;KAClB,CAAC,CAAA;IAEF,MAAM,OAAO,CAAC,GAAG,CAAC;QACd,6BAA6B,CAAC,OAAO,EAAE,MAAM,CAAC;QAE9C,6BAA6B,CAAC,gBAAgB,EAAM,MAAM,CAAC;QAC3D,6BAA6B,CAAC,kBAAkB,EAAI,SAAS,CAAC;QAC9D,6BAA6B,CAAC,mBAAmB,EAAG,UAAU,CAAC;QAE/D,6BAA6B,CAAC,IAAI,EAAE,IAAI,CAAC;QAEzC,sBAAsB,CAAC,gBAAgB,CAAC;QACxC,sBAAsB,CAAC,YAAY,CAAC;QACpC,sBAAsB,CAAC,cAAc,CAAC;QACtC,sBAAsB,CAAC,WAAW,CAAC;QACnC,sBAAsB,CAAC,UAAU,CAAC;QAClC,sBAAsB,CAAC,aAAa,CAAC;QACrC,sBAAsB,CAAC,WAAW,CAAC;KACtC,CAAC,CAAA;IAEF,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAA;AAC9B,CAAC;AAGD,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAE,MAAc;IACxD,MAAM,CAAC,MAAM,CACT,MAAM,EACN,MAAM,MAAM,CAAC,MAAM,CAAC,CACvB,CAAA;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAAE,MAAc,EAAE,IAAY;IAC7E,MAAM,CAAC,IAAI,CAAC,GAAG,CACX,MAAM,MAAM,CAAC,MAAM,CAAC,CACvB,CAAC,OAAO,CAAA;AACb,CAAC","sourcesContent":["import nvm from 'vm'\nimport repl from 'repl'\nimport process from 'process'\nimport { fileURLToPath } from 'url'\n\n\nimport path from 'upath'\n\nimport ts from 'typescript'\nimport type {\n SourceFile, Node, Statement, Modifier, Identifier, StringLiteral,\n ExpressionStatement, ObjectBindingPattern, BindingElement,\n SyntaxKind as TSyntaxKind\n} from 'typescript'\nconst {\n factory, createPrinter,\n \n SyntaxKind, NodeFlags, ModifierFlags,\n \n isIdentifier, isNamedImports, isImportDeclaration, isAwaitExpression,\n isExpressionStatement, isVariableStatement,\n isNamespaceImport, isClassDeclaration, isCallExpression, isReturnStatement,\n isBinaryExpression, isFunctionDeclaration,\n} = ts\n\nimport type { Context } from 'koa'\n\n\nimport { t } from './i18n/instance.js'\nimport './prototype.js'\nimport { log_line, delay, inspect, set_inspect_options, Timer, delta2str } from './utils.js'\nimport { fread, fwrite } from './file.js'\nimport { Remote } from './net.js'\n\n\ndeclare global {\n var __: any\n \n var started_at: Date\n \n var repl_router: (ctx: Context) => Promise<boolean>\n}\n\n\n\nset_inspect_options()\n\n\n\nlet server: import('./server.js').Server\n\nlet inspection_limit = 10000\nlet printing_compiled_js = false\n\n\n/** 谨慎使用,webpack 打包后可能会变成 /d:/1/mod/node_modules/xshell/ 这样的编译期路径 */\nexport const fpd_root = path.dirname(fileURLToPath(import.meta.url)) + '/'\n\n\nexport function set_inspection_limit (limit: number = 10000) {\n if (limit === -1)\n limit = 50 * 10**4\n inspection_limit = limit\n}\n\n\nexport function set_printing_compiled_js (enabled: boolean) {\n printing_compiled_js = enabled\n}\n\n\n// ------------------------------------ Code Compilers, Transformers\nfunction resolve_kind (kind: TSyntaxKind) {\n return kind === SyntaxKind.VariableStatement ? 'VariableStatement' : SyntaxKind[kind]\n}\n\n\nfunction print_ast (nodes: Node[] | Node, sourceFile: SourceFile) {\n function print_node (node: Node) {\n console.log(`${ resolve_kind(node.kind) }: ${ node.getText(sourceFile) }`)\n }\n if (Array.isArray(nodes))\n nodes.forEach( node => { print_node(node) })\n else\n print_node(nodes)\n}\n\n\nexport function parse_code (code: string) {\n return ts.createSourceFile('repl.ts', code, ts.ScriptTarget.ESNext)\n}\n\n\nexport function generate_code (stmts: Statement[]) {\n return createPrinter({ omitTrailingSemicolon: true, removeComments: false, newLine: ts.NewLineKind.LineFeed })\n .printFile(\n factory.updateSourceFile(\n ts.createSourceFile('output.ts', '', ts.ScriptTarget.ESNext),\n stmts\n )\n )\n}\n\n\n\nfunction trans_import_2_require (import_decl: Statement) {\n if (!isImportDeclaration(import_decl))\n return import_decl\n \n const { importClause: import_clause, moduleSpecifier: module_specifier } = import_decl\n \n // require('module_specifier')\n const require_module_stmt = factory.createCallExpression( factory.createIdentifier('require'), [ ], [ module_specifier ])\n \n // aaa, bbb as ccc, default as ddd, ...\n // (import_clause.namedBindings as NamedImports).elements\n \n return [\n // import mod from 'mod'\n // global.mod = __importDefault(require(\"mod\")).default\n ... import_clause.name ? [\n factory.createExpressionStatement( factory.createAssignment(\n factory.createPropertyAccessExpression( factory.createIdentifier('global'), import_clause.name),\n factory.createPropertyAccessExpression( factory.createCallExpression( factory.createIdentifier('__importDefault'), [ ], [ require_module_stmt ]), 'default'),\n )\n ) ] : [ ],\n \n // import * as mod from 'mod'\n // global.mod = __importStar(require(\"mod\"))\n ... import_clause.namedBindings && isNamespaceImport(import_clause.namedBindings) ? [\n factory.createExpressionStatement( factory.createAssignment(\n factory.createPropertyAccessExpression( factory.createIdentifier('global'), import_clause.namedBindings.name),\n factory.createCallExpression( factory.createIdentifier('__importStar'), [ ], [ require_module_stmt ])\n ))\n ] : [ ],\n \n \n // import { element2 as element2_, element3 as element3_, other, default as mod2 } from 'mod2'\n ... import_clause.namedBindings && isNamedImports(import_clause.namedBindings) ? [\n // var { element2: element2_, element3 } = __importDefault(require(\"mod\"))\n factory.createVariableStatement([ ], [ factory.createVariableDeclaration(\n factory.createObjectBindingPattern(\n // ImportSpecifier[] -> ObjectBindingPattern.BindingElement[]\n import_clause.namedBindings.elements.map( import_specifier => \n factory.createBindingElement(\n undefined, \n import_specifier.propertyName, \n import_specifier.name, \n import_specifier.propertyName?.text === 'default' ? require_module_stmt : undefined\n ))),\n undefined,\n undefined,\n require_module_stmt\n ) ]),\n \n // Object.assign(global, { element2_, element3 })\n factory.createExpressionStatement( factory.createCallExpression(\n factory.createPropertyAccessExpression( factory.createIdentifier('Object'), 'assign'),\n [ ],\n // ImportSpecifier[] -> ObjectBindingPattern.BindingElement[]\n [ factory.createIdentifier('global'), factory.createObjectLiteralExpression( import_clause.namedBindings.elements.map( import_specifier => factory.createShorthandPropertyAssignment(import_specifier.name) ), false) ]\n )),\n \n factory.createExpressionStatement(\n import_clause.namedBindings.elements.length === 1 ? \n // (a)\n factory.createParenthesizedExpression(import_clause.namedBindings.elements[0].name)\n : // ({ a: xxx, b: xxx })\n factory.createObjectLiteralExpression( import_clause.namedBindings.elements.map( import_specifier => factory.createShorthandPropertyAssignment(import_specifier.name) ), false)\n )\n ] : [ ],\n ]\n}\n\n\n/** export function foo () { } */\nfunction trans_export_stmt (stmt: Statement) {\n if (ts.isExportAssignment(stmt))\n return factory.createExpressionStatement(stmt.expression)\n \n function is_export_modifier (modifier: Modifier) {\n return modifier.flags & ModifierFlags.Export || modifier.flags & ModifierFlags.ExportDefault || modifier.kind === SyntaxKind.ExportKeyword\n }\n \n // @ts-ignore\n if (stmt.modifiers?.some( modifier => is_export_modifier(modifier) )) {\n // @ts-ignore\n stmt.modifiers = factory.createNodeArray<Modifier>(\n // @ts-ignore\n stmt.modifiers.filter( modifier => !is_export_modifier(modifier) )\n )\n return stmt\n }\n \n return stmt\n}\n\n\n/** const a = 123, b = 234, { c, d: e } = obj */\nfunction trans_variable_decl_2_var (var_decl: Statement) {\n if (!isVariableStatement(var_decl)) return var_decl\n // @ts-ignore\n var_decl.declarationList.flags = NodeFlags.None\n return var_decl\n}\n\n\nfunction trans_class_decl_2_expr (class_decl: Statement) {\n if (!isClassDeclaration(class_decl)) return class_decl\n \n // export class C { } 这样的语句已经在 trans_export_stmt 中被去掉了 export modifier\n \n return factory.createVariableStatement(\n [ ],\n factory.createVariableDeclarationList([\n factory.createVariableDeclaration(\n class_decl.name, \n undefined, \n undefined, \n factory.createClassExpression(undefined, class_decl.name, undefined, undefined, class_decl.members)\n )\n ]))\n}\n\n\nfunction get_expr_of_stmt (statement: Statement): ExpressionStatement | Statement {\n if (isExpressionStatement(statement))\n return statement\n \n if (isVariableStatement(statement)) {\n const { declarations } = statement.declarationList\n return factory.createExpressionStatement(\n declarations.length === 1 ?\n (() => {\n const { name } = declarations[0]\n if (isIdentifier(name)) // const a = c\n return name\n else // const { a, b } = c\n return factory.createObjectLiteralExpression(\n name.elements\n .filter(({ name }: BindingElement) => name && isIdentifier(name))\n .map(({ name }: BindingElement) => \n factory.createShorthandPropertyAssignment(name as Identifier))\n )\n })()\n :\n factory.createObjectLiteralExpression(\n declarations.map( var_decl => \n factory.createShorthandPropertyAssignment(var_decl.name as Identifier)),\n true)\n )\n }\n \n if (isFunctionDeclaration(statement))\n return factory.createExpressionStatement(statement.name)\n \n return statement\n}\n\nfunction trans_return_2_expr (stmt: Statement): Statement {\n if (!isReturnStatement(stmt)) return stmt\n return factory.createExpressionStatement(stmt.expression)\n}\n\n\nfunction assign_var_decl (var_decl: Statement, destination: string = 'global') {\n if (!isVariableStatement(var_decl))\n return [var_decl]\n \n // VariableDeclaration[] -> ObjectLiteral[]\n // const a = 123, b = 234, { c, d: e } = obj\n const obj_literal =\n factory.createObjectLiteralExpression(\n var_decl.declarationList.declarations.map( declaration => \n isIdentifier(declaration.name) ?\n [ factory.createShorthandPropertyAssignment(declaration.name) ]\n : // ObjectBindingPattern\n (declaration.name as ObjectBindingPattern).elements.map( (element: BindingElement) => factory.createShorthandPropertyAssignment(element.name as Identifier))\n ).flat()\n , true\n )\n \n \n return [\n var_decl,\n factory.createExpressionStatement( factory.createCallExpression(\n factory.createPropertyAccessExpression( factory.createIdentifier('Object'), 'assign'),\n [ ],\n [ factory.createIdentifier(destination), obj_literal ]\n )),\n factory.createExpressionStatement(obj_literal)\n ]\n}\n\n\nfunction return_last_expr (statements: Statement[]) {\n if (!statements.length) return statements\n \n const last_expr = get_expr_of_stmt(statements.last)\n if (isExpressionStatement(last_expr))\n return [ ...statements.slice(0, -1), factory.createReturnStatement(last_expr.expression) ]\n else\n return statements\n}\n\n\nfunction wrap_await_stmt (statements: Statement[], code: string) {\n function wrap (stmts: Statement[]) {\n return [\n factory.createExpressionStatement(\n factory.createCallExpression(\n factory.createFunctionExpression(\n [ factory.createModifier(SyntaxKind.AsyncKeyword) ],\n undefined,\n 'async_wrapper',\n [ ],\n [ ],\n undefined,\n factory.createBlock(\n return_last_expr(\n stmts.map(statement => assign_var_decl(statement)).flat()\n )\n , true)\n ),\n [ ],\n [ ]\n )\n ),\n ]\n }\n \n if (!code.includes('await')) return statements\n \n if (code.includes('await') && !code.includes('async ')) return wrap(statements)\n \n if (statements.some( stmt => (\n isExpressionStatement(stmt) && isAwaitExpression(stmt.expression) ||\n isVariableStatement(stmt) && stmt.declarationList.declarations.some( var_decl => \n var_decl.initializer && isAwaitExpression(var_decl.initializer)\n ) ||\n isExpressionStatement(stmt) && isCallExpression(stmt.expression) && stmt.expression.arguments.some( expr => isAwaitExpression(expr)) ||\n isExpressionStatement(stmt) && isBinaryExpression(stmt.expression) && isAwaitExpression(stmt.expression.right)\n )))\n return wrap(statements)\n \n return statements\n}\n\n\nexport async function compile_ts ({\n fp, \n code, \n print = printing_compiled_js, \n save = false,\n}: {\n fp?: string\n code?: string\n print?: boolean\n save?: boolean\n} = { }): Promise<string> {\n if (!code && fp)\n code = await fread(fp)\n \n const source_file = parse_code(code)\n \n let statements: Statement[] = [...source_file.statements]\n statements = statements.map(trans_import_2_require).flat()\n statements = statements.map(trans_export_stmt)\n statements = statements.map(trans_class_decl_2_expr)\n statements = wrap_await_stmt(statements, code)\n statements = statements.map(trans_variable_decl_2_var)\n statements = statements.map(trans_return_2_expr)\n \n if (statements.length) {\n const last_stmt = statements[statements.length - 1]\n const last_expr = get_expr_of_stmt(last_stmt)\n if (last_expr !== last_stmt)\n statements = [...statements, last_expr]\n }\n \n \n code = generate_code(statements)\n \n let { diagnostics, outputText: output_text } = ts.transpileModule(code, { compilerOptions: ts_options_commonjs_repl })\n \n if (diagnostics.length) {\n console.log(diagnostics.join('\\n\\n\\n'))\n log_line()\n }\n \n if (print) {\n console.log(output_text)\n log_line()\n }\n \n if (fp && save)\n await fwrite(fp.replace(/\\.ts(x?)$/, '.js$1'), output_text)\n \n return output_text\n}\n\n\n/** tsconfig.compilerOptions */\nexport let ts_options: any\nexport let ts_options_commonjs: any\nexport let ts_options_commonjs_repl: any\n\nexport async function load_tsconfig () {\n const fp = `${fpd_root}tsconfig.json`\n ;({ config: { compilerOptions: ts_options } } = ts.parseConfigFileTextToJson(\n fp, \n await fread(fp, { print: false })\n ))\n \n ts_options_commonjs = {\n ...ts_options,\n \n module: 'CommonJS',\n incremental: false,\n \n // determine CommonJS module require method\n esModuleInterop: true,\n }\n \n ts_options_commonjs_repl = {\n ...ts_options,\n \n module: 'CommonJS',\n esModuleInterop: true,\n \n // nvm.runInThisContext doesn't support inline source map\n sourceMap: false,\n }\n}\n\n\nlet eval_id = 0\n\nexport async function eval_ts (code: string) {\n return nvm.runInThisContext(\n await compile_ts({ code }),\n `repl/${eval_id++}.ts`\n )\n}\n\n\n// ------------------------------------ repl\nexport async function repl_ts (code: string) {\n console.log() // 离之前的输出有一个空行\n \n const timer = new Timer()\n const __ = global.__ = await eval_ts(code)\n timer.stop()\n \n console.log(inspect(__, { limit: inspection_limit }))\n if (timer.get() >= 500)\n timer.print()\n \n return __\n}\n\n\nexport async function start_repl () {\n // ------------ 加载库\n console.log(t('xshell 开始启动').yellow)\n \n // --- prevent from exiting\n process.on('uncaughtException', error => {\n console.error(error)\n })\n \n // --- start nodejs repl\n repl.start({\n prompt: '',\n replMode: repl.REPL_MODE_SLOPPY,\n useGlobal: true,\n useColors: true,\n terminal: true,\n })\n \n console.log(t('nodejs.repl 启动成功'))\n \n process.title = 'xshell'\n \n await Promise.all([\n pollute_global(),\n \n load_tsconfig(),\n \n (async () => {\n // --- http server\n let { Server } = await import('./server.js')\n server = new Server(8421, {\n remote: new Remote({\n funcs: {\n echo ({ data: [data] }) {\n console.log('echo:', data)\n return [data]\n },\n \n async repl_ts ({ data: [code] }) {\n return [await repl_ts(code)]\n }\n }\n })\n })\n await server.start()\n console.log(t('server 启动成功'))\n })(),\n ])\n \n console.log((\n '-'.repeat(30) + '\\n' +\n t('xshell 启动成功,用时 ') + delta2str(new Date().getTime() - global.started_at.getTime()) + '\\n' +\n t('正在监听: http://localhost:8421\\n') +\n '-'.repeat(30)\n ).green)\n}\n\n\nexport async function stop () {\n console.log(t('xshell 正在退出').red)\n \n server.stop()\n}\n\nexport async function exit () {\n await stop()\n await delay(100)\n process.exit()\n}\n\n\nexport async function pollute_global () {\n Object.assign(global, {\n __importDefault: (mod: any) => ((mod?.__esModule) ? mod : { default: mod }),\n __importStar: (mod: any) => {\n if (mod?.__esModule) return mod\n let result: { default?: any } = { }\n if (mod != null)\n for (let k in mod)\n if (Object.hasOwnProperty.call(mod, k))\n result[k] = mod[k]\n result.default = mod\n return result\n },\n exports: global\n })\n \n await Promise.all([\n pollute_module_default_export('upath', 'path'),\n \n pollute_module_default_export('lodash/omit.js', 'omit'),\n pollute_module_default_export('lodash/sortBy.js', 'sort_by'),\n pollute_module_default_export('lodash/groupBy.js', 'group_by'),\n \n pollute_module_default_export('qs', 'qs'),\n \n pollute_module_exports('./prototype.js'),\n pollute_module_exports('./utils.js'),\n pollute_module_exports('./process.js'),\n pollute_module_exports('./file.js'),\n pollute_module_exports('./net.js'),\n pollute_module_exports('./server.js'),\n pollute_module_exports('./repl.js'),\n ])\n \n console.log(t('所有模块加载成功'))\n}\n\n\nexport async function pollute_module_exports (fp_mod: string) {\n Object.assign(\n global,\n await import(fp_mod)\n )\n}\n\nexport async function pollute_module_default_export (fp_mod: string, name: string) {\n global[name] = (\n await import(fp_mod)\n ).default\n}\n\n"]}
package/server.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAA6B,MAAM,MAAM,CAAA;AACpF,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,gBAAgB,EAAE,MA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AAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;iBAC/B;gBAED,MAAM,SAAS,GAAG,CAAC,GAAG,GAAG,KAAK,GAAG,CAAC,CAAC,CAAA;gBAEnC,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAA;gBACrB,QAAQ,CAAC,GAAG,CAAC,gBAAgB,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAA;gBACjD,QAAQ,CAAC,GAAG,CAAC,eAAe,EAAE,SAAS,KAAK,IAAI,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;gBACpE,QAAQ,CAAC,IAAI,GAAG,gBAAgB,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;aACzD;YAAC,OAAO,GAAG,EAAE;gBACV,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAA;gBACrB,QAAQ,CAAC,GAAG,CAAC,gBAAgB,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;gBAClD,QAAQ,CAAC,GAAG,CAAC,eAAe,EAAE,WAAW,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;gBACtD,QAAQ,CAAC,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAA;aACzC;aACA;YACD,QAAQ,CAAC,GAAG,CAAC,gBAAgB,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;YAClD,QAAQ,CAAC,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAA;SACzC;QAED,OAAO,IAAI,CAAA;IACf,CAAC;CACJ","sourcesContent":["import { createServer as http_create_server, type Server as HttpServer } from 'http'\nimport zlib from 'zlib'\nimport { createReadStream } from 'fs'\n\n// --- 3rd party\nimport upath from 'upath'\nimport qs from 'qs'\nimport resolve_safely from 'resolve-path'\nimport { WebSocketServer, type WebSocket } from 'ws'\n\n// --- koa & koa middleware\nimport { default as Koa, type Context, type Next } from 'koa'\n\nimport KoaCors from '@koa/cors'\nimport KoaCompress from 'koa-compress'\nimport { userAgent as KoaUserAgent, type UserAgentContext } from 'koa-useragent'\n\n\ndeclare module 'koa' {\n interface Request {\n /** 经过 decodeURIComponent 后,在路径重写之前的路径 */\n _path: string\n \n body: any\n }\n \n interface Context {\n compress: boolean\n userAgent: UserAgentContext['userAgent'] & { isWechat: boolean }\n }\n}\n\n// --- my libs\nimport { request as _request, type Remote } from './net.js'\nimport { stream_to_buffer, inspect, output_width, assert } from './utils.js'\nimport { fstat, type FStats } from './file.js'\n\n\ndeclare module 'http' {\n interface IncomingMessage {\n body?: Buffer\n }\n \n interface ServerResponse {\n body?: Buffer\n }\n}\n\n\n// ------------ my server\nexport class Server {\n app: Koa\n \n handler: ReturnType<Koa['callback']>\n \n port: number\n \n server_http: HttpServer\n \n server_ws?: WebSocketServer\n \n remote?: Remote\n \n \n constructor (port: number, { remote }: { remote?: Remote } = { }) {\n this.port = port\n \n if (remote)\n this.remote = remote\n }\n \n \n /** start http server and listen */\n async start () {\n // --- init koa app\n let app = new Koa()\n \n app.on('error', (error, ctx) => {\n console.error(error)\n console.log(ctx)\n })\n \n app.use(this.entry.bind(this))\n \n app.use(KoaCompress({\n br: {\n chunkSize: 64 * 1024,\n \n // https://nodejs.org/api/zlib.html#zlib_class_brotlioptions\n params: {\n [zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_TEXT,\n [zlib.constants.BROTLI_PARAM_QUALITY]: 3 // 默认为 11 (最大压缩),会导致 news/get 生成的 14 mb 的 json 压缩时长高达 24s\n },\n },\n threshold: 512\n }))\n \n app.use(KoaCors({ credentials: true }))\n app.use(KoaUserAgent)\n \n app.use(this._router.bind(this))\n \n this.app = app\n \n this.handler = this.app.callback()\n \n this.server_http = http_create_server(this.handler)\n \n \n // websocket rpc\n if (this.remote) {\n this.server_ws = new WebSocketServer({\n noServer: true,\n skipUTF8Validation: true,\n perMessageDeflate: true\n })\n \n this.server_ws.on('connection', (ws: WebSocket, request) => {\n ws.addEventListener('message', ({ data }) => {\n this.remote.handle(new Uint8Array(data as ArrayBuffer), ws)\n })\n })\n \n this.server_http.on('upgrade', (request, socket, head) => {\n // url 只有路径部分\n const {\n url, \n headers: { host = '', 'user-agent': ua },\n } = request\n \n const ip = (request.socket.remoteAddress as string).replace(/^::ffff:/, '')\n \n console.log(`${new Date().to_time_str()} ${(ip || '').pad(40)} ${(ua || '').limit(40)} ${'websocket'.pad(10).magenta} ${'connect'.pad(10).magenta}${host.pad(20)} ${url.pad(60).yellow}`)\n \n switch (url) {\n case '/':\n this.server_ws.handleUpgrade(request, socket, head, ws => {\n ws.binaryType = 'arraybuffer'\n this.server_ws.emit('connection', ws, request)\n })\n return\n \n default:\n console.log(`${' '.repeat(13)} connect 404: ${url}`.red)\n socket.destroy()\n }\n })\n }\n \n \n await new Promise<void>(resolve => {\n this.server_http.listen(this.port, resolve)\n })\n }\n \n \n stop () {\n this.server_http.close()\n }\n \n \n async entry (ctx: Context, next: Next) {\n let { response } = ctx\n \n await this.parse(ctx)\n \n // ------------ next\n try {\n await next()\n } catch (error) {\n if (error.status !== 404)\n console.error(error)\n response.status = error.status || 500\n response.body = inspect(error, { colors: false })\n response.type = 'text/plain'\n }\n }\n \n \n /** \n parse req.body to request.body \n process request.ip\n */\n async parse (ctx: Context) {\n let { req, request } = ctx\n \n const buf = await stream_to_buffer(req)\n if (buf.length)\n req.body = buf\n \n // --- parse request.ip\n request.ip = (request.headers['x-real-ip'] as string || request.ip).replace(/^::ffff:/, '')\n \n \n // --- parse body\n if (!req.body)\n return\n \n if (ctx.is('application/json') || ctx.is('text/plain'))\n request.body = JSON.parse(\n req.body.toString()\n )\n else if (ctx.is('application/x-www-form-urlencoded'))\n request.body = qs.parse(\n req.body.toString()\n )\n else if (ctx.is('multipart/form-data')) {\n throw new Error('multipart/form-data is not supported')\n } else\n request.body = req.body\n }\n \n \n async _router (ctx: Context, next: Next) {\n let { request } = ctx\n const _path = request._path = decodeURIComponent(request.path)\n Object.defineProperty(request, 'path', {\n value: _path,\n configurable: true,\n enumerable: true,\n writable: true\n })\n \n // ------------ log\n this.logger(ctx)\n \n // ------------ repl_router hook\n if (await global.repl_router?.(ctx))\n return\n \n if (await this.router(ctx))\n return\n \n await next?.()\n }\n \n \n async router (ctx: Context): Promise<boolean> {\n return false\n }\n \n \n logger (ctx: Context) {\n const { request } = ctx\n const {\n query, \n body, \n path, _path, \n protocol,\n host,\n req: { httpVersion: http_version },\n ip,\n } = request\n \n let { method } = request\n \n const ua = ctx.userAgent\n \n \n let s = ''\n \n // --- time\n s += `${new Date().to_time_str()} `\n \n \n // --- ip\n s += (ip || '').pad(40) + ' '\n \n \n // --- ua\n s += (() => {\n let t = ''\n if (ua.isMobile)\n t += 'mobile'\n if (ua.isDesktop)\n t += 'desktop'\n if (ua.isBot)\n t += `${ t ? ' ' : '' }${'robot'.blue}`\n if (ua.platform !== 'unknown' && !ua.os.startsWith('Windows'))\n t += '/' + ua.platform.toLowerCase().replace('apple mac', 'mac')\n if (ua.os !== 'unknown' && ua.platform !== 'Android')\n t += '/' + ua.os.toLowerCase()\n if (ua.browser !== 'unknown')\n t += '/' + ua.browser.toLowerCase()\n if (ua.isWechat)\n t += '/weixin'\n if (ua.version !== 'unknown')\n t += '/' + ua.version.split('.').slice(0, 2).join('.')\n return t\n })().pad(40) + ' '\n \n \n // --- https/2.0\n s += `${`${protocol.pad(5)}/${http_version}`.pad(10)} `\n \n \n // --- method\n method = method.toLowerCase()\n s += method === 'get' ? method.pad(10) : method.pad(10).yellow\n \n \n // --- host\n s += `${host.pad(20)} `\n \n \n // --- path\n s += (() => {\n if (path.toLowerCase() !== _path.toLowerCase())\n return `${_path.blue} → ${path}`\n if (!path.includes('.'))\n return path.yellow\n return path\n })()\n \n \n // --- query\n if (Object.keys(query).length) {\n let t = inspect(query, { compact: true })\n .replace('[Object: null prototype] ', '')\n \n if (t.endsWith('\\n'))\n t = t.slice(0, -1)\n \n s += (s + t).width > output_width ? '\\n' : ' '\n \n s += t\n }\n \n \n // --- body\n if (body && Object.keys(body).length)\n s += '\\n' + inspect(body).replace('[Object: null prototype] ', '')\n \n \n // --- print log\n console.log(s)\n }\n \n \n async try_send (\n ctx: Context, \n fp: string,\n {\n root,\n log_404,\n }: {\n root: string\n log_404?: boolean\n }) {\n const {\n request: { _path, path, method },\n response,\n } = ctx\n \n if (!(typeof response.body === 'undefined') || response.status !== 404)\n return true\n \n if (method !== 'HEAD' && method !== 'GET')\n return false\n \n function _log_404 () {\n let s = `${' '.repeat(13)} ${method.toLowerCase()} 404: ${path}`\n if (_path !== path)\n s += ` ${_path.bracket()}`\n console.log(s.red)\n }\n \n try {\n await this.fsend(ctx, fp, { root })\n return true\n } catch (error) {\n if (error.status !== 404)\n throw error\n if (log_404)\n _log_404()\n return false\n }\n }\n \n \n /** send file at `path` with the given `options` to the koa `ctx`. */\n async fsend (\n ctx: Context,\n path: string,\n {\n root,\n absolute\n }: {\n root?: string\n \n /** `false` */\n absolute?: boolean\n \n } = { } as any\n ) {\n const { request } = ctx\n let { response } = ctx\n \n if (!absolute && !root)\n throw new Error('fsend with `!absolute && !root`')\n \n if (absolute)\n path = upath.resolve(path)\n else {\n if (path.startsWith(root))\n path = path.slice(root.length)\n \n if (path.startsWith('/'))\n path = path.slice(1)\n \n try {\n path = upath.normalize(\n resolve_safely(root, path)\n )\n } catch (error) {\n error.message += `, path: ${path}`\n throw error\n }\n }\n \n \n // stat\n let stats: FStats\n try {\n stats = await fstat(path)\n } catch (error) {\n if (['ENOENT', 'ENAMETOOLONG', 'ENOTDIR'].includes(error.code)) {\n error.status = 404\n throw error\n }\n \n error.status = 500\n error.message = `fs.stat 出错: ${error.message}`\n throw error\n }\n \n \n // size limit\n // if (stats.size >= 100 * 2**20) {\n // let error = new Error('body.length >= 100 mb')\n // ;(error as any).status = 500\n // throw error\n // }\n \n \n // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Ranges\n // advertise server support of partial requests\n response.set('accept-ranges', 'bytes')\n \n if (!response.get('cache-control'))\n response.set('cache-control', 'max-age=0, must-revalidate')\n \n if (!response.get('last-modified'))\n response.set('last-modified', stats.mtime.toUTCString())\n \n const fext = path.fext\n \n if (!response.type)\n response.type = fext\n \n if (fext === '.pdf')\n response.set('content-disposition', `attachment; filename=\"${encodeURIComponent(path.fname)}\"`)\n \n if (request.fresh) {\n response.status = 304\n // 以上会自动设置 response.body = null\n return path\n }\n \n if (request.headers.range)\n try {\n const range_header = request.headers.range\n const range_value = /=(.*)$/.exec(range_header)[1]\n const range = /^[\\w]*?(\\d*)-(\\d*)$/.exec(range_value)\n \n assert(stats.size <= Number.MAX_SAFE_INTEGER)\n \n let start = range[1] ? parseInt(range[1]) : undefined\n let end = range[2] ? parseInt(range[2]) : Number(stats.size) - 1\n \n if (typeof start == 'undefined') {\n start = Number(stats.size) - end\n end = Number(stats.size) - 1\n }\n \n const chunksize = (end - start + 1)\n \n response.status = 206\n response.set('content-length', String(chunksize))\n response.set('content-range', `bytes ${start}-${end}/${stats.size}`)\n response.body = createReadStream(path, { start, end })\n } catch (err) {\n response.status = 416\n response.set('content-length', String(stats.size))\n response.set('content-range', `bytes */${stats.size}`)\n response.body = createReadStream(path)\n }\n else {\n response.set('content-length', String(stats.size))\n response.body = createReadStream(path)\n }\n \n return path\n }\n}\n\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"toaster.browser.js","sourceRoot":"","sources":["toaster.browser.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAA;AAEvB,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,MAAM,CAAC,IAAI,OAAO,GAAG;IACjB,QAAQ,EAAE,EAAe;IAEzB,KAAK,EAAE,MAAyB;IAEhC,KAAK,CAAC,KAAK,CAAE,OAAe;QACxB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC3B,IAAI,CAAC,IAAI,EAAE,CAAA;IACf,CA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IACvB,CAAC;CACJ,CAAA;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAA8B,CAAA","sourcesContent":["import './toaster.sass'\n\nimport { delay } from './utils.browser.js'\n\nexport let toaster = {\n messages: [ ] as string[],\n \n state: 'IDLE' as 'IDLE' | 'SHOW',\n \n async toast (message: string) {\n this.messages.push(message)\n this.show()\n },\n \n async show () {\n if (this.state === 'SHOW') return\n this.state = 'SHOW'\n \n let div = document.createElement('div')\n div.className = 'toast'\n document.body.appendChild(div)\n \n for (let i = 0; i < this.messages.length; i++) {\n const message = this.messages[i]\n let span: HTMLSpanElement\n if (i === 0) {\n span = document.createElement('span')\n span.className = 'text'\n span.textContent = message\n div.appendChild(span)\n } else {\n span = div.children[0] as HTMLSpanElement\n span.textContent = message\n }\n \n div.classList.add('active')\n await delay(2 * 1000)\n div.classList.remove('active')\n await delay(500)\n }\n \n document.body.removeChild(div)\n this.messages = [ ]\n this.state = 'IDLE'\n },\n}\n\nexport const toast = toaster.toast.bind(toaster) as (typeof toaster)['toast']\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.browser.js","sourceRoot":"","sources":["utils.browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AAGtC,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,EAAE,GAAG,CAAC,CAAA;AAG7B,MAAM,UAAU,MAAM,CAAE,SAAc,EAAE,OAAgB;IACpD,IAAI,SAAS;QACT,OAAM;IAEV,QAAQ,CAAA;IAER,MAAM,MAAM,CAAC,MAAM,CACf,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,EAAG,GAAG,SAAS,EAAE,CAAC,EACzE,EAAE,SAAS,EAAE,CAChB,CAAA;AACL,CAAC;AAGD,MAAM,CAAC,K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IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;IAC9B,CAAC;CACJ","sourcesContent":["import { t } from './i18n/instance.js'\n\n\nexport const noop = () => { }\n\n\nexport function assert (assertion: any, message?: string): never | void {\n if (assertion)\n return\n \n debugger\n \n throw Object.assign(\n new Error(`${t('断言失败')}: ${ message ? `${message}: ` : '' }${assertion}`),\n { assertion }\n )\n}\n\n\nexport async function delay (milliseconds: number) {\n return new Promise<void>(resolve => {\n setTimeout(resolve, milliseconds)\n })\n}\n\n\nexport async function timeout (milliseconds: number) {\n const error = new Error(t('超时错误'))\n await delay(milliseconds)\n throw error\n}\n\n\n/** https://stackoverflow.com/questions/63297164/how-to-only-accept-arraybuffer-as-parameter */\nexport type StrictArrayBuffer = ArrayBuffer & { buffer?: undefined }\n\n\nexport interface Deferred <TValue> extends Promise<TValue> {\n resolve (value: TValue | PromiseLike<TValue>): void\n reject (reason?: Error): void\n}\n\n/** 创建一个 promise,后续可调用 promise.resolve, promise.reject 方法设置其状态和值 \n - initial?: `undefined` 传入非 undefined 值(包括 null)时直接设置为 resolved 状态 */\nexport function defer <TValue> (initial?: TValue): Deferred<TValue> {\n if (initial === undefined) {\n let resolve: (value: TValue | PromiseLike<TValue>) => void\n let reject: (reason?: Error) => void\n \n let promise = new Promise<TValue>((_resolve, _reject) => {\n resolve = _resolve\n reject = _reject\n })\n \n return Object.assign(promise, { resolve, reject })\n } else\n return Object.assign(Promise.resolve(initial), {\n resolve () { },\n reject () { }\n })\n}\n\n\nexport interface LockedAction <TResource, TResult> {\n (resource: TResource): Promise<TResult>\n}\n\n\n/** @example\n let lock = new Lock(redis)\n \n // 锁定资源后在 action 回调中操作资源,回调 promise 完成后自动释放资源,\n // 三秒内未成功独占资源直接抛出 TimeoutError (开始执行后不受 signal abort 影响)\n await lock.request(async redis => {\n const value = await redis.get('key')\n await redis.set('key', value * 2)\n }, AbortSignal.timeout(3000)) \n \n 参考:\n https://developer.mozilla.org/en-US/docs/Web/API/Web_Locks_API \n https://github.com/metarhia/web-locks \n https://www.npmjs.com/package/async-lock */\nexport class Lock <TResource = void> {\n /** 如果操作不需要独占资源,可以直接通过 lock.resource 访问,否则需要通过 await lock.request() 独占资源后再访问 */\n resource: TResource\n \n /** 等待链,新的 await lock.request() 调用会等待当前等待链尾部的 promise 完成,并作为新的尾部 */\n ptail = defer<void>(null)\n \n /** 查询当前资源是否属于被锁定的状态,方便在资源闲置时做一些可选操作(操作前仍需锁定),或者做一些状态展示 */\n locked = false\n \n \n /** 可以不传 resource,表示管理某个抽象或虚拟的资源 */\n constructor (resource?: TResource) {\n this.resource = resource\n }\n \n \n /** 通过 await lock.request() 锁定资源以便独占访问\n 成功返回之后由调用方负责调用 release 方法释放资源\n 在 signal aborted 时抛出错误结束等待,且由内部实现自动释放资源 */\n // async request (action: (resource: TResource) => Promise<void>, signal?: AbortSignal): Promise<void>\n // async request <TResult> (action: <TResult> (resource: TResource) => Promise<TResult>, signal?: AbortSignal): Promise<TResult>\n async request <TResult> (action: LockedAction<TResource, TResult>, signal?: AbortSignal): Promise<TResult> {\n signal?.throwIfAborted()\n \n const ptail = this.ptail\n \n let pcurrent = this.ptail = defer<void>()\n \n this.locked = true\n \n return new Promise<TResult>((resolve, reject) => {\n // 下面两种情况,先发生的决定 request 返回的 promise 状态\n // 不管是否 aborted, 都要等资源被前一次调用释放,先 aborted 只是将控制权交回给调用者,在锁定资源后不执行 action, 直接释放\n \n /** 防止执行过程中 signal abort */\n let executing = false\n \n signal?.addEventListener('abort', () => {\n if (!executing)\n // 这里不能释放锁,需要等 ptail resolve 后拿到资源再释放\n reject(signal.reason)\n }, { once: true })\n \n ptail.then(async () => {\n // 这里已经能保证独占访问资源\n \n // 如果 aborted, 可以理解为独占资源失败,调用者不会使用资源,直接释放\n if (signal?.aborted)\n reject(signal.reason)\n else\n // 由调用者去操作资源\n try {\n executing = true\n resolve(await action(this.resource))\n } catch (error) {\n reject(error)\n }\n \n \n // 下面开始释放锁\n \n // assert(this.locked)\n if (!this.locked)\n reject(new Error(t('尝试释放未锁定的锁,这不应该发生')))\n \n this.locked = false\n \n pcurrent.resolve()\n }\n )})\n }\n}\n\n\nexport async function debug (milliseconds: number = 3000) {\n await delay(milliseconds)\n debugger\n}\n\nglobalThis.debug = debug\n\n\n/** 字符串字典序比较 */\nexport function strcmp (l: string, r: string) {\n if (l === r) return 0\n if (l < r) return -1\n return 1\n}\n\n\n/** 拼接 TypedArrays 生成一个完整的 Uint8Array */\nexport function concat (arrays: ArrayBufferView[]) {\n let length = 0\n for (const a of arrays)\n length += a.byteLength\n \n let buf = new Uint8Array(length)\n let offset = 0\n for (const a of arrays) {\n const uint8view = new Uint8Array(a.buffer, a.byteOffset, a.byteLength)\n buf.set(uint8view, offset)\n offset += uint8view.byteLength\n }\n \n return buf\n}\n\n\n/** 时间间隔 (milliseconds) 格式化 */\nexport function delta2str (delta: number) {\n if (delta < 1)\n return '0 ms'\n \n // [1, 1000) ms\n if (delta < 1000)\n return `${delta} ms`\n \n // 1.123 s\n if (1000 <= delta && delta < 1000 * 60)\n return `${(delta / 1000).toFixed(1)} s`\n \n // 1 min 12 s [1 min 0s, 60 min)\n const seconds = Math.trunc(delta / 1000)\n \n if (seconds < 60 * 60)\n return `${Math.trunc(seconds / 60)} min ${seconds % 60} s`\n \n const hour = Math.trunc(seconds / 3600)\n \n return `${hour} h ${Math.trunc((seconds - 3600 * hour) / 60)} min ${seconds % 60} s`\n}\n\n\n/** generate random id */\nexport function genid () {\n return Math.random() * 2**53\n}\n\n\nexport class Timer {\n started = new Date().getTime()\n \n ended: number\n \n /** 停止秒表,保存读数 */\n stop () {\n this.ended = new Date().getTime()\n }\n \n /** 如果秒表未停止,获取当前秒表读数;\n 如果秒表已停止,获取停止时的秒表读数; */\n get () {\n return (this.ended || new Date().getTime()) - this.started\n }\n \n getstr () {\n return `(${delta2str(this.get())})`\n }\n \n print () {\n console.log(this.getstr())\n }\n}\n\n"]}