@jayfong/x-utils 1.0.0-202510061015 → 3.4.0
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/lib/ai.d.mts +103 -0
- package/lib/ai.mjs +75 -0
- package/lib/cache.d.mts +464 -0
- package/lib/cache.mjs +531 -0
- package/lib/captcha.d.mts +259 -0
- package/lib/captcha.mjs +174 -0
- package/lib/case.d.mts +184 -0
- package/lib/case.mjs +120 -0
- package/lib/chinese.d.mts +57 -0
- package/lib/chinese.mjs +79 -0
- package/lib/cli.d.mts +52 -0
- package/lib/cli.mjs +62 -0
- package/lib/clipboard.d.mts +50 -0
- package/lib/clipboard.mjs +122 -0
- package/lib/cmd.d.mts +38 -0
- package/lib/cmd.mjs +52 -0
- package/lib/crawler.d.mts +330 -0
- package/lib/crawler.mjs +313 -0
- package/lib/crypto.d.mts +158 -0
- package/lib/crypto.mjs +213 -0
- package/lib/csv.d.mts +67 -0
- package/lib/csv.mjs +76 -0
- package/lib/data_set.d.mts +76 -0
- package/lib/data_set.mjs +104 -0
- package/lib/db_value.d.mts +213 -0
- package/lib/db_value.mjs +208 -0
- package/lib/dispose.d.mts +98 -0
- package/lib/dispose.mjs +107 -0
- package/lib/file_store.d.mts +167 -0
- package/lib/file_store.mjs +120 -0
- package/lib/fs.d.mts +111 -0
- package/lib/fs.mjs +127 -0
- package/lib/html.d.mts +103 -0
- package/lib/html.mjs +112 -0
- package/lib/json.d.mts +50 -0
- package/lib/json.mjs +74 -0
- package/lib/jwt.d.mts +128 -0
- package/lib/jwt.mjs +104 -0
- package/lib/mail.d.mts +125 -0
- package/lib/mail.mjs +108 -0
- package/lib/pay.d.mts +394 -0
- package/lib/pay.mjs +343 -0
- package/lib/puppeteer.d.mts +88 -0
- package/lib/puppeteer.mjs +219 -0
- package/lib/random.d.mts +71 -0
- package/lib/random.mjs +92 -0
- package/lib/redis.d.mts +32 -0
- package/lib/redis.mjs +24 -0
- package/lib/runner.d.mts +80 -0
- package/lib/runner.mjs +66 -0
- package/lib/sensitive_words.d.mts +82 -0
- package/lib/sensitive_words.mjs +73 -0
- package/lib/sms.d.mts +133 -0
- package/lib/sms.mjs +100 -0
- package/lib/task.d.mts +37 -0
- package/lib/task.mjs +43 -0
- package/lib/text.d.mts +84 -0
- package/lib/text.mjs +141 -0
- package/lib/yaml.d.mts +51 -0
- package/lib/yaml.mjs +64 -0
- package/package.json +82 -164
- package/_cjs/ai.js +0 -80
- package/_cjs/alipan.js +0 -173
- package/_cjs/cli.js +0 -51
- package/_cjs/clipboard.js +0 -65
- package/_cjs/cmd.js +0 -42
- package/_cjs/compressor.js +0 -47
- package/_cjs/crawler.js +0 -341
- package/_cjs/csv.js +0 -97
- package/_cjs/data_set.js +0 -115
- package/_cjs/env.js +0 -82
- package/_cjs/fs.js +0 -86
- package/_cjs/html.js +0 -62
- package/_cjs/http_server.js +0 -79
- package/_cjs/json.js +0 -49
- package/_cjs/ksb.js +0 -218
- package/_cjs/number.js +0 -39
- package/_cjs/ocr.js +0 -74
- package/_cjs/package.json +0 -3
- package/_cjs/path.js +0 -35
- package/_cjs/pinyin.js +0 -37
- package/_cjs/puppeteer.js +0 -271
- package/_cjs/runner.js +0 -88
- package/_cjs/task.js +0 -41
- package/_cjs/text.js +0 -136
- package/_cjs/unicode/lib_unicode.js +0 -58643
- package/_cjs/unicode/unicode.js +0 -441
- package/_cjs/upload.js +0 -101
- package/_cjs/yaml.js +0 -52
- package/ai.d.ts +0 -26
- package/ai.js +0 -60
- package/alipan.d.ts +0 -209
- package/alipan.js +0 -153
- package/cli.d.ts +0 -14
- package/cli.js +0 -21
- package/clipboard.d.ts +0 -6
- package/clipboard.js +0 -35
- package/cmd.d.ts +0 -5
- package/cmd.js +0 -22
- package/compressor.d.ts +0 -5
- package/compressor.js +0 -17
- package/crawler.d.ts +0 -162
- package/crawler.js +0 -332
- package/csv.d.ts +0 -14
- package/csv.js +0 -67
- package/data_set.d.ts +0 -22
- package/data_set.js +0 -85
- package/env.d.ts +0 -6
- package/env.js +0 -52
- package/fs.d.ts +0 -23
- package/fs.js +0 -56
- package/html.d.ts +0 -7
- package/html.js +0 -45
- package/http_server.d.ts +0 -13
- package/http_server.js +0 -49
- package/json.d.ts +0 -6
- package/json.js +0 -19
- package/ksb.d.ts +0 -37
- package/ksb.js +0 -198
- package/number.d.ts +0 -3
- package/number.js +0 -9
- package/ocr.d.ts +0 -17
- package/ocr.js +0 -54
- package/path.d.ts +0 -2
- package/path.js +0 -5
- package/pinyin.d.ts +0 -8
- package/pinyin.js +0 -17
- package/puppeteer.d.ts +0 -38
- package/puppeteer.js +0 -241
- package/runner.d.ts +0 -13
- package/runner.js +0 -58
- package/task.d.ts +0 -6
- package/task.js +0 -21
- package/text.d.ts +0 -63
- package/text.js +0 -119
- package/unicode/lib_unicode.d.ts +0 -4
- package/unicode/lib_unicode.js +0 -58623
- package/unicode/unicode.d.ts +0 -347
- package/unicode/unicode.js +0 -426
- package/upload.d.ts +0 -34
- package/upload.js +0 -71
- package/yaml.d.ts +0 -6
- package/yaml.js +0 -22
package/package.json
CHANGED
|
@@ -1,177 +1,95 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jayfong/x-utils",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"version": "3.4.0",
|
|
4
|
+
"license": "ISC",
|
|
5
|
+
"sideEffects": false,
|
|
5
6
|
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib"
|
|
9
|
+
],
|
|
6
10
|
"dependencies": {
|
|
7
|
-
"
|
|
8
|
-
"@
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"@
|
|
12
|
-
"clipboardy": "^4.0.0",
|
|
13
|
-
"execa": "^8.0.1",
|
|
14
|
-
"sharp": "^0.32.5",
|
|
15
|
-
"node-html-parser": "^6.1.12",
|
|
16
|
-
"csv": "^6.3.6",
|
|
17
|
-
"exit-hook": "^4.0.0",
|
|
18
|
-
"fs-extra": "^11.2.0",
|
|
11
|
+
"@aws-sdk/client-s3": "^3.1166.0",
|
|
12
|
+
"@aws-sdk/s3-request-presigner": "^3.1166.0",
|
|
13
|
+
"@inquirer/prompts": "^8.8.0",
|
|
14
|
+
"@jayfong/x-request": "^3.4.0",
|
|
15
|
+
"@paralleldrive/cuid2": "^3.3.0",
|
|
19
16
|
"@types/fs-extra": "^11.0.4",
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
17
|
+
"alipay-sdk": "^4.14.0",
|
|
18
|
+
"change-case": "^5.4.4",
|
|
19
|
+
"cli-table3": "^0.6.5",
|
|
20
|
+
"clipboardy": "^5.3.2",
|
|
21
|
+
"consola": "^3.4.2",
|
|
22
|
+
"csv": "^6.6.4",
|
|
23
|
+
"exit-hook": "^5.1.0",
|
|
24
|
+
"fast-escape-html": "^1.1.0",
|
|
25
|
+
"fs-extra": "^11.4.1",
|
|
26
|
+
"globby": "^16.2.4",
|
|
27
|
+
"html-entities": "^2.6.0",
|
|
28
|
+
"ioredis": "^6.0.0",
|
|
29
|
+
"jsonwebtoken": "^9.0.3",
|
|
30
|
+
"lru-cache": "^11.5.3",
|
|
31
|
+
"mime": "^4.1.2",
|
|
32
|
+
"mini-svg-data-uri": "^1.4.4",
|
|
33
|
+
"node-html-parser": "^9.0.7",
|
|
34
|
+
"nodemailer": "^10.5.0",
|
|
35
|
+
"pinyin-pro": "^3.26.0",
|
|
36
|
+
"randomstring": "^1.3.1",
|
|
37
|
+
"superjson": "^2.2.6",
|
|
38
|
+
"svg-captcha": "^1.4.0",
|
|
39
|
+
"tencentcloud-sdk-nodejs-sms": "^4.0.681",
|
|
40
|
+
"vtils": "^4.138.0",
|
|
41
|
+
"yaml": "^2.9.1"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
45
|
+
"@types/randomstring": "^1.3.0",
|
|
46
|
+
"puppeteer": "^25.17.0"
|
|
37
47
|
},
|
|
38
48
|
"peerDependencies": {
|
|
39
|
-
"puppeteer": "^
|
|
49
|
+
"puppeteer": "^25.17.0"
|
|
40
50
|
},
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
"require": "./_cjs/ai.js",
|
|
45
|
-
"import": "./ai.js",
|
|
46
|
-
"types": "./ai.d.ts"
|
|
47
|
-
},
|
|
48
|
-
"./alipan": {
|
|
49
|
-
"require": "./_cjs/alipan.js",
|
|
50
|
-
"import": "./alipan.js",
|
|
51
|
-
"types": "./alipan.d.ts"
|
|
52
|
-
},
|
|
53
|
-
"./cli": {
|
|
54
|
-
"require": "./_cjs/cli.js",
|
|
55
|
-
"import": "./cli.js",
|
|
56
|
-
"types": "./cli.d.ts"
|
|
57
|
-
},
|
|
58
|
-
"./clipboard": {
|
|
59
|
-
"require": "./_cjs/clipboard.js",
|
|
60
|
-
"import": "./clipboard.js",
|
|
61
|
-
"types": "./clipboard.d.ts"
|
|
62
|
-
},
|
|
63
|
-
"./cmd": {
|
|
64
|
-
"require": "./_cjs/cmd.js",
|
|
65
|
-
"import": "./cmd.js",
|
|
66
|
-
"types": "./cmd.d.ts"
|
|
67
|
-
},
|
|
68
|
-
"./compressor": {
|
|
69
|
-
"require": "./_cjs/compressor.js",
|
|
70
|
-
"import": "./compressor.js",
|
|
71
|
-
"types": "./compressor.d.ts"
|
|
72
|
-
},
|
|
73
|
-
"./crawler": {
|
|
74
|
-
"require": "./_cjs/crawler.js",
|
|
75
|
-
"import": "./crawler.js",
|
|
76
|
-
"types": "./crawler.d.ts"
|
|
77
|
-
},
|
|
78
|
-
"./csv": {
|
|
79
|
-
"require": "./_cjs/csv.js",
|
|
80
|
-
"import": "./csv.js",
|
|
81
|
-
"types": "./csv.d.ts"
|
|
82
|
-
},
|
|
83
|
-
"./data_set": {
|
|
84
|
-
"require": "./_cjs/data_set.js",
|
|
85
|
-
"import": "./data_set.js",
|
|
86
|
-
"types": "./data_set.d.ts"
|
|
87
|
-
},
|
|
88
|
-
"./env": {
|
|
89
|
-
"require": "./_cjs/env.js",
|
|
90
|
-
"import": "./env.js",
|
|
91
|
-
"types": "./env.d.ts"
|
|
92
|
-
},
|
|
93
|
-
"./fs": {
|
|
94
|
-
"require": "./_cjs/fs.js",
|
|
95
|
-
"import": "./fs.js",
|
|
96
|
-
"types": "./fs.d.ts"
|
|
97
|
-
},
|
|
98
|
-
"./html": {
|
|
99
|
-
"require": "./_cjs/html.js",
|
|
100
|
-
"import": "./html.js",
|
|
101
|
-
"types": "./html.d.ts"
|
|
102
|
-
},
|
|
103
|
-
"./http_server": {
|
|
104
|
-
"require": "./_cjs/http_server.js",
|
|
105
|
-
"import": "./http_server.js",
|
|
106
|
-
"types": "./http_server.d.ts"
|
|
107
|
-
},
|
|
108
|
-
"./json": {
|
|
109
|
-
"require": "./_cjs/json.js",
|
|
110
|
-
"import": "./json.js",
|
|
111
|
-
"types": "./json.d.ts"
|
|
112
|
-
},
|
|
113
|
-
"./ksb": {
|
|
114
|
-
"require": "./_cjs/ksb.js",
|
|
115
|
-
"import": "./ksb.js",
|
|
116
|
-
"types": "./ksb.d.ts"
|
|
117
|
-
},
|
|
118
|
-
"./number": {
|
|
119
|
-
"require": "./_cjs/number.js",
|
|
120
|
-
"import": "./number.js",
|
|
121
|
-
"types": "./number.d.ts"
|
|
122
|
-
},
|
|
123
|
-
"./ocr": {
|
|
124
|
-
"require": "./_cjs/ocr.js",
|
|
125
|
-
"import": "./ocr.js",
|
|
126
|
-
"types": "./ocr.d.ts"
|
|
127
|
-
},
|
|
128
|
-
"./path": {
|
|
129
|
-
"require": "./_cjs/path.js",
|
|
130
|
-
"import": "./path.js",
|
|
131
|
-
"types": "./path.d.ts"
|
|
132
|
-
},
|
|
133
|
-
"./pinyin": {
|
|
134
|
-
"require": "./_cjs/pinyin.js",
|
|
135
|
-
"import": "./pinyin.js",
|
|
136
|
-
"types": "./pinyin.d.ts"
|
|
137
|
-
},
|
|
138
|
-
"./puppeteer": {
|
|
139
|
-
"require": "./_cjs/puppeteer.js",
|
|
140
|
-
"import": "./puppeteer.js",
|
|
141
|
-
"types": "./puppeteer.d.ts"
|
|
142
|
-
},
|
|
143
|
-
"./runner": {
|
|
144
|
-
"require": "./_cjs/runner.js",
|
|
145
|
-
"import": "./runner.js",
|
|
146
|
-
"types": "./runner.d.ts"
|
|
147
|
-
},
|
|
148
|
-
"./task": {
|
|
149
|
-
"require": "./_cjs/task.js",
|
|
150
|
-
"import": "./task.js",
|
|
151
|
-
"types": "./task.d.ts"
|
|
152
|
-
},
|
|
153
|
-
"./text": {
|
|
154
|
-
"require": "./_cjs/text.js",
|
|
155
|
-
"import": "./text.js",
|
|
156
|
-
"types": "./text.d.ts"
|
|
157
|
-
},
|
|
158
|
-
"./upload": {
|
|
159
|
-
"require": "./_cjs/upload.js",
|
|
160
|
-
"import": "./upload.js",
|
|
161
|
-
"types": "./upload.d.ts"
|
|
162
|
-
},
|
|
163
|
-
"./yaml": {
|
|
164
|
-
"require": "./_cjs/yaml.js",
|
|
165
|
-
"import": "./yaml.js",
|
|
166
|
-
"types": "./yaml.d.ts"
|
|
167
|
-
},
|
|
168
|
-
"./unicode": {
|
|
169
|
-
"require": "./_cjs/unicode/unicode.js",
|
|
170
|
-
"import": "./unicode/unicode.js",
|
|
171
|
-
"types": "./unicode/unicode.d.ts"
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"puppeteer": {
|
|
53
|
+
"optional": true
|
|
172
54
|
}
|
|
173
55
|
},
|
|
174
56
|
"publishConfig": {
|
|
175
57
|
"access": "public"
|
|
58
|
+
},
|
|
59
|
+
"exports": {
|
|
60
|
+
"./ai": "./lib/ai.mjs",
|
|
61
|
+
"./cache": "./lib/cache.mjs",
|
|
62
|
+
"./captcha": "./lib/captcha.mjs",
|
|
63
|
+
"./case": "./lib/case.mjs",
|
|
64
|
+
"./chinese": "./lib/chinese.mjs",
|
|
65
|
+
"./cli": "./lib/cli.mjs",
|
|
66
|
+
"./clipboard": "./lib/clipboard.mjs",
|
|
67
|
+
"./cmd": "./lib/cmd.mjs",
|
|
68
|
+
"./crawler": "./lib/crawler.mjs",
|
|
69
|
+
"./crypto": "./lib/crypto.mjs",
|
|
70
|
+
"./csv": "./lib/csv.mjs",
|
|
71
|
+
"./data_set": "./lib/data_set.mjs",
|
|
72
|
+
"./db_value": "./lib/db_value.mjs",
|
|
73
|
+
"./dispose": "./lib/dispose.mjs",
|
|
74
|
+
"./file_store": "./lib/file_store.mjs",
|
|
75
|
+
"./fs": "./lib/fs.mjs",
|
|
76
|
+
"./html": "./lib/html.mjs",
|
|
77
|
+
"./json": "./lib/json.mjs",
|
|
78
|
+
"./jwt": "./lib/jwt.mjs",
|
|
79
|
+
"./mail": "./lib/mail.mjs",
|
|
80
|
+
"./pay": "./lib/pay.mjs",
|
|
81
|
+
"./puppeteer": "./lib/puppeteer.mjs",
|
|
82
|
+
"./random": "./lib/random.mjs",
|
|
83
|
+
"./redis": "./lib/redis.mjs",
|
|
84
|
+
"./runner": "./lib/runner.mjs",
|
|
85
|
+
"./sensitive_words": "./lib/sensitive_words.mjs",
|
|
86
|
+
"./sms": "./lib/sms.mjs",
|
|
87
|
+
"./task": "./lib/task.mjs",
|
|
88
|
+
"./text": "./lib/text.mjs",
|
|
89
|
+
"./yaml": "./lib/yaml.mjs",
|
|
90
|
+
"./package.json": "./package.json"
|
|
91
|
+
},
|
|
92
|
+
"scripts": {
|
|
93
|
+
"build": "tsdown"
|
|
176
94
|
}
|
|
177
|
-
}
|
|
95
|
+
}
|
package/_cjs/ai.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var ai_exports = {};
|
|
20
|
-
__export(ai_exports, {
|
|
21
|
-
CozeAiProvider: () => CozeAiProvider,
|
|
22
|
-
XAi: () => XAi
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(ai_exports);
|
|
25
|
-
var import_vtils = require("vtils");
|
|
26
|
-
var import_puppeteer = require("./puppeteer.js");
|
|
27
|
-
class AiProvider {
|
|
28
|
-
}
|
|
29
|
-
class CozeAiProvider extends AiProvider {
|
|
30
|
-
constructor(options) {
|
|
31
|
-
super();
|
|
32
|
-
this.options = options;
|
|
33
|
-
}
|
|
34
|
-
xp;
|
|
35
|
-
page;
|
|
36
|
-
async prepare() {
|
|
37
|
-
this.xp = new import_puppeteer.XPuppeteer();
|
|
38
|
-
await this.xp.connectSystemBrowser();
|
|
39
|
-
this.page = await this.xp.openPage(this.options.botUrl);
|
|
40
|
-
}
|
|
41
|
-
async ask(question) {
|
|
42
|
-
const page = this.page;
|
|
43
|
-
await page.evaluate(
|
|
44
|
-
() => document.querySelector("textarea:not([placeholder])").parentElement.parentElement.previousElementSibling.firstElementChild.click()
|
|
45
|
-
);
|
|
46
|
-
await (0, import_vtils.wait)(300);
|
|
47
|
-
await this.page.type("textarea:not([placeholder])", question);
|
|
48
|
-
await (0, import_vtils.wait)(500);
|
|
49
|
-
await this.page.keyboard.press("Enter");
|
|
50
|
-
await (0, import_vtils.wait)(1e3);
|
|
51
|
-
await (0, import_vtils.loopUntil)(
|
|
52
|
-
() => page.$$eval(
|
|
53
|
-
"button",
|
|
54
|
-
(els) => !els.find((el) => el.textContent.includes("Stop Responding"))?.parentElement.getBoundingClientRect().height
|
|
55
|
-
),
|
|
56
|
-
{
|
|
57
|
-
retryDelay: 300
|
|
58
|
-
}
|
|
59
|
-
);
|
|
60
|
-
await (0, import_vtils.wait)(300);
|
|
61
|
-
const code = await page.$$eval(
|
|
62
|
-
'div[class^="code-area"]',
|
|
63
|
-
(els) => els.pop().querySelector('[class^="content"]').textContent
|
|
64
|
-
);
|
|
65
|
-
return code;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
class XAi {
|
|
69
|
-
constructor(options) {
|
|
70
|
-
this.options = options;
|
|
71
|
-
this.provider = options.provider;
|
|
72
|
-
}
|
|
73
|
-
provider;
|
|
74
|
-
prepare = (0, import_vtils.memoize)(() => this.provider.prepare());
|
|
75
|
-
async ask(question) {
|
|
76
|
-
await this.prepare();
|
|
77
|
-
const answer = await this.provider.ask(question);
|
|
78
|
-
return answer;
|
|
79
|
-
}
|
|
80
|
-
}
|
package/_cjs/alipan.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var alipan_exports = {};
|
|
20
|
-
__export(alipan_exports, {
|
|
21
|
-
XAlipan: () => XAlipan
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(alipan_exports);
|
|
24
|
-
var import_x_request = require("@jayfong/x-request");
|
|
25
|
-
var import_vtils = require("vtils");
|
|
26
|
-
var import_path = require("./path.js");
|
|
27
|
-
class XAlipan {
|
|
28
|
-
constructor(options) {
|
|
29
|
-
this.options = options;
|
|
30
|
-
this.xr = import_x_request.xr.extend({
|
|
31
|
-
baseUrl: "https://open.aliyundrive.com",
|
|
32
|
-
headers: {
|
|
33
|
-
Authorization: `Bearer ${options.accessToken}`
|
|
34
|
-
},
|
|
35
|
-
timeoutMs: (0, import_vtils.ms)("30s")
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
xr;
|
|
39
|
-
getUserInfo = (0, import_vtils.memoize)(async () => {
|
|
40
|
-
const res = await this.xr.postJson({
|
|
41
|
-
url: "/adrive/v1.0/user/getDriveInfo"
|
|
42
|
-
});
|
|
43
|
-
return res.data;
|
|
44
|
-
});
|
|
45
|
-
async createFile(payload) {
|
|
46
|
-
const res = await this.xr.postJson({
|
|
47
|
-
url: "/adrive/v1.0/openFile/create",
|
|
48
|
-
data: payload
|
|
49
|
-
});
|
|
50
|
-
return res.data;
|
|
51
|
-
}
|
|
52
|
-
async uploadFile(payload) {
|
|
53
|
-
await this.xr.post({
|
|
54
|
-
method: "PUT",
|
|
55
|
-
url: payload.useIntranet ? payload.uploadUrl.replace(
|
|
56
|
-
"https://cn-beijing-data.aliyundrive.net/",
|
|
57
|
-
"http://ccp-bj29-bj-1592982087.oss-cn-beijing-internal.aliyuncs.com/"
|
|
58
|
-
) : payload.uploadUrl,
|
|
59
|
-
data: payload.file,
|
|
60
|
-
headers: {
|
|
61
|
-
"Content-Type": ""
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
async completeFile(payload) {
|
|
66
|
-
await this.xr.post({
|
|
67
|
-
url: "/adrive/v1.0/openFile/complete",
|
|
68
|
-
data: payload
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
async getFileInfoByPath(payload) {
|
|
72
|
-
const res = await this.xr.postJson({
|
|
73
|
-
url: "/adrive/v1.0/openFile/get_by_path",
|
|
74
|
-
data: payload
|
|
75
|
-
});
|
|
76
|
-
return res.data;
|
|
77
|
-
}
|
|
78
|
-
async getFileDownloadUrl(payload) {
|
|
79
|
-
const res = await this.xr.postJson({
|
|
80
|
-
url: "/adrive/v1.0/openFile/getDownloadUrl",
|
|
81
|
-
data: payload
|
|
82
|
-
});
|
|
83
|
-
return res.data;
|
|
84
|
-
}
|
|
85
|
-
getDriveId = (0, import_vtils.memoize)(
|
|
86
|
-
async (payload) => {
|
|
87
|
-
{
|
|
88
|
-
const userInfo = await this.getUserInfo();
|
|
89
|
-
return payload.drive === "backup" ? userInfo.backup_drive_id : payload.drive === "resource" ? userInfo.resource_drive_id : payload.drive === "album" ? userInfo.album_drive_id : "";
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
(payload) => payload.drive
|
|
93
|
-
);
|
|
94
|
-
async existsFileHuman(payload) {
|
|
95
|
-
try {
|
|
96
|
-
const driveId = await this.getDriveId(payload);
|
|
97
|
-
const res = await this.getFileInfoByPath({
|
|
98
|
-
drive_id: driveId,
|
|
99
|
-
file_path: payload.path
|
|
100
|
-
});
|
|
101
|
-
return res.file_id;
|
|
102
|
-
} catch {
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
ensurePathHuman = (0, import_vtils.memoize)(
|
|
107
|
-
async (payload) => {
|
|
108
|
-
const driveId = await this.getDriveId(payload);
|
|
109
|
-
const pathParts = payload.path.split("/");
|
|
110
|
-
let prevFileId = "root";
|
|
111
|
-
for (let i = 1; i < pathParts.length; i++) {
|
|
112
|
-
const path = pathParts.slice(0, i + 1).join("/");
|
|
113
|
-
const fileId = await this.existsFileHuman({
|
|
114
|
-
drive: payload.drive,
|
|
115
|
-
path
|
|
116
|
-
});
|
|
117
|
-
if (!fileId) {
|
|
118
|
-
const createRes = await this.createFile({
|
|
119
|
-
drive_id: driveId,
|
|
120
|
-
parent_file_id: prevFileId,
|
|
121
|
-
type: "folder",
|
|
122
|
-
check_name_mode: "refuse",
|
|
123
|
-
name: pathParts[i]
|
|
124
|
-
});
|
|
125
|
-
prevFileId = createRes.file_id;
|
|
126
|
-
} else {
|
|
127
|
-
prevFileId = fileId;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return prevFileId;
|
|
131
|
-
},
|
|
132
|
-
(payload) => `${payload.drive}:${payload.path}`
|
|
133
|
-
);
|
|
134
|
-
async uploadFileHuman(payload) {
|
|
135
|
-
const driveId = await this.getDriveId(payload);
|
|
136
|
-
const fileId = await this.ensurePathHuman({
|
|
137
|
-
drive: payload.drive,
|
|
138
|
-
path: import_path.XPath.dirname(payload.path)
|
|
139
|
-
});
|
|
140
|
-
const createRes = await this.createFile({
|
|
141
|
-
drive_id: driveId,
|
|
142
|
-
parent_file_id: fileId,
|
|
143
|
-
type: "file",
|
|
144
|
-
check_name_mode: "refuse",
|
|
145
|
-
name: import_path.XPath.basename(payload.path)
|
|
146
|
-
});
|
|
147
|
-
if (!createRes.exist && createRes.part_info_list?.length === 1) {
|
|
148
|
-
await this.uploadFile({
|
|
149
|
-
uploadUrl: createRes.part_info_list[0].upload_url,
|
|
150
|
-
file: payload.file,
|
|
151
|
-
useIntranet: payload.useIntranet
|
|
152
|
-
});
|
|
153
|
-
await this.completeFile({
|
|
154
|
-
drive_id: createRes.drive_id,
|
|
155
|
-
file_id: createRes.file_id,
|
|
156
|
-
upload_id: createRes.upload_id
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
async getFileDownloadUrlHuman(payload) {
|
|
161
|
-
const driveId = await this.getDriveId(payload);
|
|
162
|
-
const fileInfo = await this.getFileInfoByPath({
|
|
163
|
-
drive_id: driveId,
|
|
164
|
-
file_path: payload.path
|
|
165
|
-
});
|
|
166
|
-
const downloadInfo = await this.getFileDownloadUrl({
|
|
167
|
-
drive_id: driveId,
|
|
168
|
-
file_id: fileInfo.file_id,
|
|
169
|
-
expire_sec: 900
|
|
170
|
-
});
|
|
171
|
-
return downloadInfo.url;
|
|
172
|
-
}
|
|
173
|
-
}
|
package/_cjs/cli.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var cli_exports = {};
|
|
30
|
-
__export(cli_exports, {
|
|
31
|
-
XCli: () => XCli
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(cli_exports);
|
|
34
|
-
var import_cli_table3 = __toESM(require("cli-table3"), 1);
|
|
35
|
-
var import_inquirer = __toESM(require("inquirer"), 1);
|
|
36
|
-
class XCli {
|
|
37
|
-
static async prompt(options) {
|
|
38
|
-
const { x } = await import_inquirer.default.prompt({
|
|
39
|
-
name: "x",
|
|
40
|
-
message: options.message,
|
|
41
|
-
type: options.type,
|
|
42
|
-
default: options.default
|
|
43
|
-
});
|
|
44
|
-
return x;
|
|
45
|
-
}
|
|
46
|
-
static table(data) {
|
|
47
|
-
const table = new import_cli_table3.default();
|
|
48
|
-
table.push(...data);
|
|
49
|
-
return table.toString();
|
|
50
|
-
}
|
|
51
|
-
}
|
package/_cjs/clipboard.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var clipboard_exports = {};
|
|
30
|
-
__export(clipboard_exports, {
|
|
31
|
-
XClipboard: () => XClipboard
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(clipboard_exports);
|
|
34
|
-
var import_clipboardy = __toESM(require("clipboardy"), 1);
|
|
35
|
-
var import_cmd = require("./cmd.js");
|
|
36
|
-
class XClipboard {
|
|
37
|
-
static async readText() {
|
|
38
|
-
return import_clipboardy.default.read();
|
|
39
|
-
}
|
|
40
|
-
static async readHtml() {
|
|
41
|
-
const hex = await import_cmd.XCmd.exec(
|
|
42
|
-
// 读取剪切板为 HTML
|
|
43
|
-
// https://stackoverflow.com/questions/2545289/getting-rtf-data-out-of-mac-os-x-pasteboard-clipboard
|
|
44
|
-
// https://stackoverflow.com/a/17217886
|
|
45
|
-
`osascript -e "the clipboard as \xABclass HTML\xBB"`
|
|
46
|
-
);
|
|
47
|
-
const html = Buffer.from(
|
|
48
|
-
hex.substring(10, hex.length - 1),
|
|
49
|
-
"hex"
|
|
50
|
-
).toString();
|
|
51
|
-
return html;
|
|
52
|
-
}
|
|
53
|
-
static async writeText(text) {
|
|
54
|
-
await import_clipboardy.default.write(text);
|
|
55
|
-
}
|
|
56
|
-
static async writeHtml(html) {
|
|
57
|
-
const hex = Buffer.from(html).toString("hex");
|
|
58
|
-
await import_cmd.XCmd.exec(
|
|
59
|
-
// 设置剪切板为 HTML
|
|
60
|
-
// https://stackoverflow.com/questions/11085654/apple-script-how-can-i-copy-html-content-to-the-clipboard
|
|
61
|
-
// https://stackoverflow.com/a/11089226
|
|
62
|
-
`osascript -e "set the clipboard to \xABdata HTML${hex}\xBB"`
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
}
|
package/_cjs/cmd.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var cmd_exports = {};
|
|
20
|
-
__export(cmd_exports, {
|
|
21
|
-
XCmd: () => XCmd
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(cmd_exports);
|
|
24
|
-
var import_execa = require("execa");
|
|
25
|
-
class XCmd {
|
|
26
|
-
static execDivider = "clrue91c60000e6rl7w03b40p";
|
|
27
|
-
static async exec(command, options) {
|
|
28
|
-
const { stdout } = await (0, import_execa.execa)(
|
|
29
|
-
"zsh",
|
|
30
|
-
[
|
|
31
|
-
"-c",
|
|
32
|
-
`
|
|
33
|
-
echo ${XCmd.execDivider}
|
|
34
|
-
${command}
|
|
35
|
-
echo ${XCmd.execDivider}
|
|
36
|
-
`
|
|
37
|
-
],
|
|
38
|
-
options
|
|
39
|
-
);
|
|
40
|
-
return stdout.split(XCmd.execDivider)[1].trim();
|
|
41
|
-
}
|
|
42
|
-
}
|