xshell 0.0.16 → 0.0.17
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/chalk.browser.d.ts +2 -0
- package/chalk.browser.js +21 -0
- package/chalk.browser.js.map +1 -0
- package/net.browser.d.ts +23 -0
- package/net.browser.js +70 -0
- package/net.browser.js.map +1 -0
- package/package.json +1 -1
- package/prototype.browser.d.ts +130 -0
- package/prototype.browser.js +421 -0
- package/prototype.browser.js.map +1 -0
- package/toaster.browser.d.ts +9 -0
- package/toaster.browser.js +45 -0
- package/toaster.browser.js.map +1 -0
- package/tsconfig.json +0 -1
- package/utils.browser.d.ts +3 -0
- package/utils.browser.js +27 -0
- package/utils.browser.js.map +1 -0
- package/chalk.browser.ts +0 -41
- package/net.browser.ts +0 -141
- package/prototype.browser.ts +0 -728
- package/toaster.browser.ts +0 -50
- package/utils.browser.ts +0 -25
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const red: import("chalk").Chalk, green: import("chalk").Chalk, yellow: import("chalk").Chalk, blue: import("chalk").Chalk, magenta: import("chalk").Chalk, cyan: import("chalk").Chalk, grey: import("chalk").Chalk, red_: import("chalk").Chalk, green_: import("chalk").Chalk, yellow_: import("chalk").Chalk, blue_: import("chalk").Chalk, magenta_: import("chalk").Chalk, cyan_: import("chalk").Chalk, underline: import("chalk").Chalk;
|
|
2
|
+
export { red, green, yellow, blue, magenta, cyan, grey, red_, green_, yellow_, blue_, magenta_, cyan_, underline };
|
package/chalk.browser.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.underline = exports.cyan_ = exports.magenta_ = exports.blue_ = exports.yellow_ = exports.green_ = exports.red_ = exports.grey = exports.cyan = exports.magenta = exports.blue = exports.yellow = exports.green = exports.red = void 0;
|
|
4
|
+
const chalk_1 = require("chalk");
|
|
5
|
+
const chalk = new chalk_1.Instance({ level: 2 });
|
|
6
|
+
const { red, green, yellow, blue, magenta, cyan, grey, redBright: red_, greenBright: green_, yellowBright: yellow_, blueBright: blue_, magentaBright: magenta_, cyanBright: cyan_, underline, } = chalk;
|
|
7
|
+
exports.red = red;
|
|
8
|
+
exports.green = green;
|
|
9
|
+
exports.yellow = yellow;
|
|
10
|
+
exports.blue = blue;
|
|
11
|
+
exports.magenta = magenta;
|
|
12
|
+
exports.cyan = cyan;
|
|
13
|
+
exports.grey = grey;
|
|
14
|
+
exports.red_ = red_;
|
|
15
|
+
exports.green_ = green_;
|
|
16
|
+
exports.yellow_ = yellow_;
|
|
17
|
+
exports.blue_ = blue_;
|
|
18
|
+
exports.magenta_ = magenta_;
|
|
19
|
+
exports.cyan_ = cyan_;
|
|
20
|
+
exports.underline = underline;
|
|
21
|
+
//# sourceMappingURL=chalk.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chalk.browser.js","sourceRoot":"","sources":["chalk.browser.ts"],"names":[],"mappings":";;;AAAA,iCAAyC;AAEzC,MAAM,KAAK,GAAG,IAAI,gBAAK,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAA;AAErC,MAAM,EACF,GAAG,EACH,KAAK,EACL,MAAM,EACN,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,IAAI,EAEJ,SAAS,EAAE,IAAI,EACf,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,OAAO,EACrB,UAAU,EAAE,KAAK,EACjB,aAAa,EAAE,QAAQ,EACvB,UAAU,EAAE,KAAK,EAEjB,SAAS,GACZ,GAAG,KAAK,CAAA;AAGL,kBAAG;AACH,sBAAK;AACL,wBAAM;AACN,oBAAI;AACJ,0BAAO;AACP,oBAAI;AACJ,oBAAI;AAEJ,oBAAI;AACJ,wBAAM;AACN,0BAAO;AACP,sBAAK;AACL,4BAAQ;AACR,sBAAK;AAEL,8BAAS","sourcesContent":["import { Instance as Chalk } from 'chalk'\n\nconst chalk = new Chalk({ level: 2 })\n\nconst {\n red, \n green, \n yellow, \n blue, \n magenta, \n cyan, \n grey,\n \n redBright: red_, \n greenBright: green_, \n yellowBright: yellow_, \n blueBright: blue_, \n magentaBright: magenta_,\n cyanBright: cyan_,\n \n underline,\n} = chalk\n\nexport {\n red,\n green,\n yellow,\n blue,\n magenta,\n cyan,\n grey,\n \n red_,\n green_,\n yellow_,\n blue_,\n magenta_,\n cyan_,\n \n underline\n}\n"]}
|
package/net.browser.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface RequestOptions {
|
|
2
|
+
method?: 'get' | 'post' | 'put' | 'head' | 'delete' | 'patch';
|
|
3
|
+
queries?: Record<string, any>;
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
body?: string | object | HTMLFormElement;
|
|
6
|
+
type?: 'application/json' | 'application/x-www-form-urlencoded' | 'multipart/form-data';
|
|
7
|
+
cors?: boolean;
|
|
8
|
+
by?: 'fetch' | 'GM_xmlhttpRequest';
|
|
9
|
+
}
|
|
10
|
+
export interface RequestRawOptions extends RequestOptions {
|
|
11
|
+
raw: true;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
- url: 可以只有 pathname 部分
|
|
15
|
+
- options:
|
|
16
|
+
- type: `'application/json'` 请求的 content-type 头 (如果有 body)
|
|
17
|
+
- by: `window.GM_xmlhttpRequest ? 'GM_xmlhttpRequest' : 'fetch'` 发起请求所使用的底层方法
|
|
18
|
+
*/
|
|
19
|
+
export declare function request(url: string | URL): Promise<string>;
|
|
20
|
+
export declare function request(url: string | URL, options: RequestRawOptions): Promise<Response>;
|
|
21
|
+
export declare function request(url: string | URL, options: RequestOptions): Promise<string>;
|
|
22
|
+
/** 发起 http 请求并将响应体作为 json 解析 */
|
|
23
|
+
export declare function request_json<T = any>(url: string, options?: RequestOptions): Promise<T>;
|
package/net.browser.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.request_json = exports.request = void 0;
|
|
4
|
+
async function request(url, { method, queries, headers, body, type = 'application/json', cors, by = window.GM_xmlhttpRequest ? 'GM_xmlhttpRequest' : 'fetch', raw, } = {}) {
|
|
5
|
+
url = new URL(url, location.href);
|
|
6
|
+
if (queries)
|
|
7
|
+
for (const key in queries) {
|
|
8
|
+
let value = queries[key];
|
|
9
|
+
if (typeof value === 'boolean')
|
|
10
|
+
value = value ? '1' : '0';
|
|
11
|
+
url.searchParams.append(key, value);
|
|
12
|
+
}
|
|
13
|
+
if (body && !method)
|
|
14
|
+
method = 'post';
|
|
15
|
+
if (type === 'application/json' && typeof body !== 'undefined' && typeof body !== 'string')
|
|
16
|
+
body = JSON.stringify(body);
|
|
17
|
+
url = url.toString();
|
|
18
|
+
if (by === 'fetch') {
|
|
19
|
+
const options = {
|
|
20
|
+
...method ? { method: method.toUpperCase() } : {},
|
|
21
|
+
...cors ? { mode: 'cors' } : {},
|
|
22
|
+
credentials: 'include',
|
|
23
|
+
headers: {
|
|
24
|
+
...body ? { 'content-type': type } : {},
|
|
25
|
+
...headers,
|
|
26
|
+
},
|
|
27
|
+
...body ? { body: body } : {},
|
|
28
|
+
};
|
|
29
|
+
const response = await fetch(url, options);
|
|
30
|
+
if (!response.ok)
|
|
31
|
+
throw Object.assign(new Error(`StatusCodeError: ${response.status}`), { url, response, ...options });
|
|
32
|
+
if (raw)
|
|
33
|
+
return response;
|
|
34
|
+
return response.text();
|
|
35
|
+
}
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
GM_xmlhttpRequest({
|
|
38
|
+
...method ? { method: method.toUpperCase() } : {},
|
|
39
|
+
url: url,
|
|
40
|
+
headers: {
|
|
41
|
+
...body ? { 'content-type': type } : {},
|
|
42
|
+
...headers,
|
|
43
|
+
},
|
|
44
|
+
...body ? { data: body, } : {},
|
|
45
|
+
onload(response) {
|
|
46
|
+
if (!(200 <= response.status && response.status <= 299)) {
|
|
47
|
+
reject(Object.assign(new Error(`StatusCodeError: ${response.status}`), { url, queries, method, headers, body, response }));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
resolve(response.responseText);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
exports.request = request;
|
|
56
|
+
/** 发起 http 请求并将响应体作为 json 解析 */
|
|
57
|
+
async function request_json(url, options) {
|
|
58
|
+
const resp = await request(url, options);
|
|
59
|
+
if (!resp)
|
|
60
|
+
return;
|
|
61
|
+
try {
|
|
62
|
+
return JSON.parse(resp);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
console.error(resp);
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.request_json = request_json;
|
|
70
|
+
//# sourceMappingURL=net.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"net.browser.js","sourceRoot":"","sources":["net.browser.ts"],"names":[],"mappings":";;;AA6BO,KAAK,UAAU,OAAO,CAAE,GAAiB,EAAE,EAC9C,MAAM,EAEN,OAAO,EAEP,OAAO,EAEP,IAAI,EAEJ,IAAI,GAAG,kBAAkB,EAEzB,IAAI,EAEJ,EAAE,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,OAAO,EAE7D,GAAG,MACiC,EAAG;IACvC,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;IAEjC,IAAI,OAAO;QACP,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE;YACvB,IAAI,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;YACxB,IAAI,OAAO,KAAK,KAAK,SAAS;gBAC1B,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;YAC7B,GAAG,CAAC,YAAY,CAA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A;KACd;AACL,CAAC;AATD,oCASC","sourcesContent":["export interface RequestOptions {\n method?: 'get' | 'post' | 'put' | 'head' | 'delete' | 'patch'\n \n queries?: Record<string, any>\n \n headers?: Record<string, string>\n \n body?: string | object | HTMLFormElement\n \n type?: 'application/json' | 'application/x-www-form-urlencoded' | 'multipart/form-data'\n \n cors?: boolean\n \n by?: 'fetch' | 'GM_xmlhttpRequest'\n}\n\nexport interface RequestRawOptions extends RequestOptions {\n raw: true\n}\n\n/**\n - url: 可以只有 pathname 部分\n - options:\n - type: `'application/json'` 请求的 content-type 头 (如果有 body)\n - by: `window.GM_xmlhttpRequest ? 'GM_xmlhttpRequest' : 'fetch'` 发起请求所使用的底层方法\n*/\nexport async function request (url: string | URL): Promise<string>\nexport async function request (url: string | URL, options: RequestRawOptions): Promise<Response>\nexport async function request (url: string | URL, options: RequestOptions): Promise<string>\nexport async function request (url: string | URL, {\n method,\n \n queries,\n \n headers,\n \n body,\n \n type = 'application/json',\n \n cors,\n \n by = window.GM_xmlhttpRequest ? 'GM_xmlhttpRequest' : 'fetch',\n \n raw,\n}: RequestOptions & { raw?: boolean } = { }) {\n url = new URL(url, location.href)\n \n if (queries)\n for (const key in queries) {\n let value = queries[key]\n if (typeof value === 'boolean')\n value = value ? '1' : '0'\n url.searchParams.append(key, value)\n }\n \n if (body && !method)\n method = 'post'\n \n if (type === 'application/json' && typeof body !== 'undefined' && typeof body !== 'string')\n body = JSON.stringify(body)\n \n url = url.toString()\n \n if (by === 'fetch') {\n const options: RequestInit = {\n ... method ? { method: method.toUpperCase() } : { },\n \n ... cors ? { mode: 'cors' } : { },\n \n credentials: 'include',\n \n headers: {\n ... body ? { 'content-type': type } : { },\n ... headers,\n },\n \n ... body ? { body: body as string } : { },\n }\n \n const response = await fetch(\n url,\n options\n )\n \n if (!response.ok)\n throw Object.assign(\n new Error(`StatusCodeError: ${response.status}`),\n { url, response, ...options }\n )\n \n if (raw)\n return response\n \n return response.text()\n }\n \n \n return new Promise((resolve, reject) => {\n GM_xmlhttpRequest({\n ... method ? { method: (method as any).toUpperCase() } : { },\n \n url: url as string,\n \n headers: {\n ... body ? { 'content-type': type } : { },\n ... headers,\n },\n \n ... body ? { data: body as string, } : { },\n \n onload (response) {\n if (!(200 <= response.status && response.status <= 299)) {\n reject(\n Object.assign(\n new Error(`StatusCodeError: ${response.status}`), \n { url, queries, method, headers, body, response }\n )\n )\n return\n }\n \n resolve(response.responseText)\n }\n })\n })\n}\n\n\n/** 发起 http 请求并将响应体作为 json 解析 */\nexport async function request_json <T = any> (url: string, options?: RequestOptions): Promise<T> {\n const resp = await request(url, options)\n if (!resp) return\n try {\n return JSON.parse(resp)\n } catch (error) {\n console.error(resp)\n throw error\n }\n}\n\n"]}
|
package/package.json
CHANGED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/** 在浏览器端修改 prototype,需要更加小心 */
|
|
2
|
+
declare global {
|
|
3
|
+
interface String {
|
|
4
|
+
readonly width: number;
|
|
5
|
+
/** 截取字符串不超过 width 显示宽度的部分,并保留颜色
|
|
6
|
+
找到并记录能容纳 字符串 + … 的最后一个字符的位置 i_fitted
|
|
7
|
+
若完整的字符串长度超过 width,返回 slice(0, i_fitted + 1) + …
|
|
8
|
+
否则 返回 this
|
|
9
|
+
*/
|
|
10
|
+
truncate(this: string, width: number): string;
|
|
11
|
+
pad(this: string, width: number, { character, position }?: {
|
|
12
|
+
character?: string;
|
|
13
|
+
position?: 'left' | 'right';
|
|
14
|
+
}): string;
|
|
15
|
+
limit(this: string, width: number, { character, position }?: {
|
|
16
|
+
character?: string;
|
|
17
|
+
position?: 'left' | 'right';
|
|
18
|
+
}): string;
|
|
19
|
+
to_regx(this: string, preservations?: string, flags?: string): RegExp;
|
|
20
|
+
/** ```ts
|
|
21
|
+
'g:/acgn/海贼王/[Skytree][海贼王][One_Piece][893][GB_BIG5_JP][X264_AAC][1080P][CRRIP][天空树双语字幕组].mkv'.refmt(
|
|
22
|
+
'{dirp}/[Skytree][海贼王][{ en_name: \\w+ }][{ episode: \\d+ }][GB_BIG5_JP][{encoding}_AAC][1080P][CRRIP][天空树双语字幕组].{format}',
|
|
23
|
+
'g:/acgn/海贼王/{episode} {encoding}.{format}',
|
|
24
|
+
'\\+',
|
|
25
|
+
'i',
|
|
26
|
+
(name, value) => name === 'episode' ? String(+value + 1) : value.toLowerCase()
|
|
27
|
+
)
|
|
28
|
+
```
|
|
29
|
+
*/
|
|
30
|
+
refmt(this: string, pattern: string, pattern_: string,
|
|
31
|
+
/** `''` 保留的正则表达式字符 */
|
|
32
|
+
preservations?: string,
|
|
33
|
+
/** `''` 正则匹配选项 */
|
|
34
|
+
flags?: string,
|
|
35
|
+
/** `(name, matched) => matched || ''` placeholder transformer */
|
|
36
|
+
transformer?: (name: string, value: string, placeholders: {
|
|
37
|
+
[name: string]: string;
|
|
38
|
+
}) => string,
|
|
39
|
+
/** `/\{.*?\}/g` */
|
|
40
|
+
pattern_placeholder?: RegExp): string;
|
|
41
|
+
/** 字符串模式搜索
|
|
42
|
+
```ts
|
|
43
|
+
'git+https://github.com/tamino-martinius/node-ts-dedent-123.git'.find(
|
|
44
|
+
'^{protocol:[\\w+]+}://{hostname:[\\w\\.]+}/{username}/{project}-{index:\\d+}.{suffix}', '^', 'i'
|
|
45
|
+
)
|
|
46
|
+
{
|
|
47
|
+
protocol: 'git+https',
|
|
48
|
+
hostname: 'github.com',
|
|
49
|
+
...
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- preservations?: `''` 保留的正则表达式字符
|
|
54
|
+
- flags?: `''` 正则匹配选项
|
|
55
|
+
- pattern_placeholder?: `/\{.*?\}/g`
|
|
56
|
+
*/
|
|
57
|
+
find(this: string, pattern: string, preservations?: string, flags?: string, pattern_placeholder?: RegExp): {
|
|
58
|
+
[name: string]: string;
|
|
59
|
+
};
|
|
60
|
+
/** - type?: `'single'` */
|
|
61
|
+
quote(this: string, type?: keyof typeof quotes | 'psh'): string;
|
|
62
|
+
/** - shape?: `'parenthesis'` */
|
|
63
|
+
bracket(this: string, shape?: keyof typeof brackets): string;
|
|
64
|
+
surround(this: string, left: string, right?: string): string;
|
|
65
|
+
surround_tag(this: string, tag_name: string): string;
|
|
66
|
+
to_lf(this: string): string;
|
|
67
|
+
to_crlf(this: string): string;
|
|
68
|
+
/** 'xxx'.replace(/pattern/g, '')
|
|
69
|
+
如果 pattern 是 string 则在创建 RegExp 时自动加上 flags (默认 'g'), 否则忽略 flags
|
|
70
|
+
*/
|
|
71
|
+
rm(this: string, pattern: string | RegExp, flags?: string): string;
|
|
72
|
+
split_lines(this: string): string[];
|
|
73
|
+
trim_doc_comment(this: string): string;
|
|
74
|
+
split_indent(this: string): {
|
|
75
|
+
indent: number;
|
|
76
|
+
text: string;
|
|
77
|
+
};
|
|
78
|
+
space(this: string): string;
|
|
79
|
+
to_slash(this: string): string;
|
|
80
|
+
to_backslash(this: string): string;
|
|
81
|
+
}
|
|
82
|
+
interface Date {
|
|
83
|
+
to_str(this: Date): string;
|
|
84
|
+
to_date_str(this: Date): string;
|
|
85
|
+
to_time_str(this: Date): string;
|
|
86
|
+
}
|
|
87
|
+
interface Number {
|
|
88
|
+
to_bin_str(this: number): string;
|
|
89
|
+
to_hex_str(this: number): string;
|
|
90
|
+
to_oct_str(this: number): string;
|
|
91
|
+
}
|
|
92
|
+
interface Array<T> {
|
|
93
|
+
indent(this: string[], width: number, c?: string): string[];
|
|
94
|
+
/**
|
|
95
|
+
- trim_line?: `true`
|
|
96
|
+
- rm_empty_lines?: `true`
|
|
97
|
+
- rm_last_empty_lines?: `false`
|
|
98
|
+
*/
|
|
99
|
+
trim_lines(this: string[], { trim_line, rm_empty_lines, rm_last_empty_lines }?: {
|
|
100
|
+
trim_line?: boolean;
|
|
101
|
+
rm_empty_lines?: boolean;
|
|
102
|
+
rm_last_empty_lines?: boolean;
|
|
103
|
+
}): string[];
|
|
104
|
+
join_lines(): string;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export declare const emoji_regex: RegExp;
|
|
108
|
+
export declare function to_method_property_descriptors(methods: {
|
|
109
|
+
[name: string]: Function;
|
|
110
|
+
}): PropertyDescriptorMap;
|
|
111
|
+
export declare function to_getter_property_descriptors(getters: {
|
|
112
|
+
[name: string]: Function;
|
|
113
|
+
}): PropertyDescriptorMap;
|
|
114
|
+
export declare const cjk = "([\u2E80-\u9FFF\uF900-\uFAFF])";
|
|
115
|
+
export declare const quotes: {
|
|
116
|
+
single: string;
|
|
117
|
+
double: string;
|
|
118
|
+
backtick: string;
|
|
119
|
+
};
|
|
120
|
+
export declare const brackets: {
|
|
121
|
+
readonly round: readonly ["(", ")"];
|
|
122
|
+
readonly square: readonly ["[", "]"];
|
|
123
|
+
readonly curly: readonly ["{", "}"];
|
|
124
|
+
readonly pointy: readonly ["<", ">"];
|
|
125
|
+
readonly corner: readonly ["「", "」"];
|
|
126
|
+
readonly fat: readonly ["【", "】"];
|
|
127
|
+
readonly tortoise_shell: readonly ["〔", "〕"];
|
|
128
|
+
};
|
|
129
|
+
export declare function to_json(object: any, replacer?: any): string;
|
|
130
|
+
export declare function is_codepoint_fullwidth(codepoint: number): boolean;
|