@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.
Files changed (143) hide show
  1. package/lib/ai.d.mts +103 -0
  2. package/lib/ai.mjs +75 -0
  3. package/lib/cache.d.mts +464 -0
  4. package/lib/cache.mjs +531 -0
  5. package/lib/captcha.d.mts +259 -0
  6. package/lib/captcha.mjs +174 -0
  7. package/lib/case.d.mts +184 -0
  8. package/lib/case.mjs +120 -0
  9. package/lib/chinese.d.mts +57 -0
  10. package/lib/chinese.mjs +79 -0
  11. package/lib/cli.d.mts +52 -0
  12. package/lib/cli.mjs +62 -0
  13. package/lib/clipboard.d.mts +50 -0
  14. package/lib/clipboard.mjs +122 -0
  15. package/lib/cmd.d.mts +38 -0
  16. package/lib/cmd.mjs +52 -0
  17. package/lib/crawler.d.mts +330 -0
  18. package/lib/crawler.mjs +313 -0
  19. package/lib/crypto.d.mts +158 -0
  20. package/lib/crypto.mjs +213 -0
  21. package/lib/csv.d.mts +67 -0
  22. package/lib/csv.mjs +76 -0
  23. package/lib/data_set.d.mts +76 -0
  24. package/lib/data_set.mjs +104 -0
  25. package/lib/db_value.d.mts +213 -0
  26. package/lib/db_value.mjs +208 -0
  27. package/lib/dispose.d.mts +98 -0
  28. package/lib/dispose.mjs +107 -0
  29. package/lib/file_store.d.mts +167 -0
  30. package/lib/file_store.mjs +120 -0
  31. package/lib/fs.d.mts +111 -0
  32. package/lib/fs.mjs +127 -0
  33. package/lib/html.d.mts +103 -0
  34. package/lib/html.mjs +112 -0
  35. package/lib/json.d.mts +50 -0
  36. package/lib/json.mjs +74 -0
  37. package/lib/jwt.d.mts +128 -0
  38. package/lib/jwt.mjs +104 -0
  39. package/lib/mail.d.mts +125 -0
  40. package/lib/mail.mjs +108 -0
  41. package/lib/pay.d.mts +394 -0
  42. package/lib/pay.mjs +343 -0
  43. package/lib/puppeteer.d.mts +88 -0
  44. package/lib/puppeteer.mjs +219 -0
  45. package/lib/random.d.mts +71 -0
  46. package/lib/random.mjs +92 -0
  47. package/lib/redis.d.mts +32 -0
  48. package/lib/redis.mjs +24 -0
  49. package/lib/runner.d.mts +80 -0
  50. package/lib/runner.mjs +66 -0
  51. package/lib/sensitive_words.d.mts +82 -0
  52. package/lib/sensitive_words.mjs +73 -0
  53. package/lib/sms.d.mts +133 -0
  54. package/lib/sms.mjs +100 -0
  55. package/lib/task.d.mts +37 -0
  56. package/lib/task.mjs +43 -0
  57. package/lib/text.d.mts +84 -0
  58. package/lib/text.mjs +141 -0
  59. package/lib/yaml.d.mts +51 -0
  60. package/lib/yaml.mjs +64 -0
  61. package/package.json +82 -164
  62. package/_cjs/ai.js +0 -80
  63. package/_cjs/alipan.js +0 -173
  64. package/_cjs/cli.js +0 -51
  65. package/_cjs/clipboard.js +0 -65
  66. package/_cjs/cmd.js +0 -42
  67. package/_cjs/compressor.js +0 -47
  68. package/_cjs/crawler.js +0 -341
  69. package/_cjs/csv.js +0 -97
  70. package/_cjs/data_set.js +0 -115
  71. package/_cjs/env.js +0 -82
  72. package/_cjs/fs.js +0 -86
  73. package/_cjs/html.js +0 -62
  74. package/_cjs/http_server.js +0 -79
  75. package/_cjs/json.js +0 -49
  76. package/_cjs/ksb.js +0 -218
  77. package/_cjs/number.js +0 -39
  78. package/_cjs/ocr.js +0 -74
  79. package/_cjs/package.json +0 -3
  80. package/_cjs/path.js +0 -35
  81. package/_cjs/pinyin.js +0 -37
  82. package/_cjs/puppeteer.js +0 -271
  83. package/_cjs/runner.js +0 -88
  84. package/_cjs/task.js +0 -41
  85. package/_cjs/text.js +0 -136
  86. package/_cjs/unicode/lib_unicode.js +0 -58643
  87. package/_cjs/unicode/unicode.js +0 -441
  88. package/_cjs/upload.js +0 -101
  89. package/_cjs/yaml.js +0 -52
  90. package/ai.d.ts +0 -26
  91. package/ai.js +0 -60
  92. package/alipan.d.ts +0 -209
  93. package/alipan.js +0 -153
  94. package/cli.d.ts +0 -14
  95. package/cli.js +0 -21
  96. package/clipboard.d.ts +0 -6
  97. package/clipboard.js +0 -35
  98. package/cmd.d.ts +0 -5
  99. package/cmd.js +0 -22
  100. package/compressor.d.ts +0 -5
  101. package/compressor.js +0 -17
  102. package/crawler.d.ts +0 -162
  103. package/crawler.js +0 -332
  104. package/csv.d.ts +0 -14
  105. package/csv.js +0 -67
  106. package/data_set.d.ts +0 -22
  107. package/data_set.js +0 -85
  108. package/env.d.ts +0 -6
  109. package/env.js +0 -52
  110. package/fs.d.ts +0 -23
  111. package/fs.js +0 -56
  112. package/html.d.ts +0 -7
  113. package/html.js +0 -45
  114. package/http_server.d.ts +0 -13
  115. package/http_server.js +0 -49
  116. package/json.d.ts +0 -6
  117. package/json.js +0 -19
  118. package/ksb.d.ts +0 -37
  119. package/ksb.js +0 -198
  120. package/number.d.ts +0 -3
  121. package/number.js +0 -9
  122. package/ocr.d.ts +0 -17
  123. package/ocr.js +0 -54
  124. package/path.d.ts +0 -2
  125. package/path.js +0 -5
  126. package/pinyin.d.ts +0 -8
  127. package/pinyin.js +0 -17
  128. package/puppeteer.d.ts +0 -38
  129. package/puppeteer.js +0 -241
  130. package/runner.d.ts +0 -13
  131. package/runner.js +0 -58
  132. package/task.d.ts +0 -6
  133. package/task.js +0 -21
  134. package/text.d.ts +0 -63
  135. package/text.js +0 -119
  136. package/unicode/lib_unicode.d.ts +0 -4
  137. package/unicode/lib_unicode.js +0 -58623
  138. package/unicode/unicode.d.ts +0 -347
  139. package/unicode/unicode.js +0 -426
  140. package/upload.d.ts +0 -34
  141. package/upload.js +0 -71
  142. package/yaml.d.ts +0 -6
  143. package/yaml.js +0 -22
package/package.json CHANGED
@@ -1,177 +1,95 @@
1
1
  {
2
2
  "name": "@jayfong/x-utils",
3
- "description": "123456",
4
- "version": "1.0.0-202510061015",
3
+ "version": "3.4.0",
4
+ "license": "ISC",
5
+ "sideEffects": false,
5
6
  "type": "module",
7
+ "files": [
8
+ "lib"
9
+ ],
6
10
  "dependencies": {
7
- "vtils": "^4.115.0",
8
- "@jayfong/x-request": "^2.35.2",
9
- "cli-table3": "^0.6.3",
10
- "inquirer": "^9.2.13",
11
- "@types/inquirer": "^9.0.7",
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
- "dotenv": "^16.4.5",
21
- "mime": "^4.0.3",
22
- "probe-image-size": "^7.2.3",
23
- "@types/probe-image-size": "^7.2.5",
24
- "docx": "^8.5.0",
25
- "image-dimensions": "^2.3.0",
26
- "posthtml-parser": "^0.11.0",
27
- "@fastify/cookie": "^9.4.0",
28
- "@fastify/cors": "^9.0.1",
29
- "fastify": "^4.26.0",
30
- "nzh": "^1.0.12",
31
- "pathe": "^1.1.2",
32
- "pinyin-pro": "^3.19.4",
33
- "consola": "^3.2.3",
34
- "html-entities": "^2.5.2",
35
- "file-type": "^19.0.0",
36
- "yaml": "^2.3.4"
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": "^22.3.0"
49
+ "puppeteer": "^25.17.0"
40
50
  },
41
- "exports": {
42
- "./package.json": "./package.json",
43
- "./ai": {
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
- }