picgo 1.5.11 → 1.6.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/.github/workflows/release.yml +60 -0
- package/.node-version +1 -1
- package/CHANGELOG.md +10 -0
- package/README.md +1 -1
- package/dist/core/Lifecycle.d.ts +14 -15
- package/dist/core/PicGo.d.ts +48 -49
- package/dist/i18n/en.d.ts +2 -2
- package/dist/i18n/index.d.ts +18 -18
- package/dist/i18n/zh-CN.d.ts +97 -97
- package/dist/i18n/zh-TW.d.ts +2 -2
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +10 -10
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +1 -0
- package/dist/lib/Commander.d.ts +22 -22
- package/dist/lib/LifecyclePlugins.d.ts +17 -17
- package/dist/lib/Logger.d.ts +19 -19
- package/dist/lib/PluginHandler.d.ts +10 -10
- package/dist/lib/PluginLoader.d.ts +27 -27
- package/dist/lib/Request.d.ts +12 -12
- package/dist/plugins/commander/config.d.ts +3 -3
- package/dist/plugins/commander/i18n.d.ts +3 -3
- package/dist/plugins/commander/index.d.ts +3 -3
- package/dist/plugins/commander/init.d.ts +3 -3
- package/dist/plugins/commander/pluginHandler.d.ts +3 -3
- package/dist/plugins/commander/proxy.d.ts +3 -3
- package/dist/plugins/commander/setting.d.ts +5 -5
- package/dist/plugins/commander/upload.d.ts +3 -3
- package/dist/plugins/commander/use.d.ts +3 -3
- package/dist/plugins/transformer/base64.d.ts +5 -5
- package/dist/plugins/transformer/index.d.ts +3 -3
- package/dist/plugins/transformer/path.d.ts +5 -5
- package/dist/plugins/uploader/aliyun.d.ts +2 -2
- package/dist/plugins/uploader/github.d.ts +2 -2
- package/dist/plugins/uploader/imgur.d.ts +2 -2
- package/dist/plugins/uploader/index.d.ts +3 -3
- package/dist/plugins/uploader/qiniu.d.ts +2 -2
- package/dist/plugins/uploader/smms.d.ts +2 -2
- package/dist/plugins/uploader/tcyun.d.ts +8 -8
- package/dist/plugins/uploader/upyun.d.ts +2 -2
- package/dist/types/index.d.ts +540 -542
- package/dist/types/oldRequest.d.ts +19 -19
- package/dist/utils/common.d.ts +118 -120
- package/dist/utils/createContext.d.ts +6 -6
- package/dist/utils/db.d.ts +15 -15
- package/dist/utils/enum.d.ts +27 -27
- package/dist/utils/eventBus.d.ts +3 -4
- package/dist/utils/getClipboardImage.d.ts +4 -4
- package/dist/utils/initUtils.d.ts +26 -26
- package/dist/utils/interfaces.d.ts +202 -203
- package/dist/utils/static.d.ts +1 -1
- package/eslint.config.js +134 -0
- package/package.json +39 -37
- package/rollup.config.js +59 -66
- package/.eslintignore +0 -2
- package/.eslintrc.js +0 -25
- package/.github/workflows/alpha.yml +0 -22
- package/.github/workflows/main.yml +0 -22
- package/.github/workflows/manually.yml +0 -19
package/dist/types/index.d.ts
CHANGED
|
@@ -1,542 +1,540 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
/** for npm */
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
/** The
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
export
|
|
500
|
-
export
|
|
501
|
-
export
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
}
|
|
542
|
-
export {};
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { Inquirer } from 'inquirer';
|
|
3
|
+
import { IRequestPromiseOptions } from './oldRequest';
|
|
4
|
+
export interface IPicGo extends NodeJS.EventEmitter {
|
|
5
|
+
/**
|
|
6
|
+
* picgo configPath
|
|
7
|
+
*
|
|
8
|
+
* if do not provide, then it will use default configPath
|
|
9
|
+
*/
|
|
10
|
+
configPath: string;
|
|
11
|
+
/**
|
|
12
|
+
* the picgo configPath's baseDir
|
|
13
|
+
*/
|
|
14
|
+
baseDir: string;
|
|
15
|
+
/**
|
|
16
|
+
* picgo logger factory
|
|
17
|
+
*/
|
|
18
|
+
log: ILogger;
|
|
19
|
+
/**
|
|
20
|
+
* picgo commander, for cli
|
|
21
|
+
*/
|
|
22
|
+
cmd: ICommander;
|
|
23
|
+
/**
|
|
24
|
+
* after transformer, the input will be output
|
|
25
|
+
*/
|
|
26
|
+
output: IImgInfo[];
|
|
27
|
+
/**
|
|
28
|
+
* the origin input
|
|
29
|
+
*/
|
|
30
|
+
input: any[];
|
|
31
|
+
/**
|
|
32
|
+
* register\unregister\get picgo's plugin
|
|
33
|
+
*/
|
|
34
|
+
pluginLoader: IPluginLoader;
|
|
35
|
+
/**
|
|
36
|
+
* install\uninstall\update picgo's plugin via npm
|
|
37
|
+
*/
|
|
38
|
+
pluginHandler: IPluginHandler;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated will be removed in v1.5.0+
|
|
41
|
+
*
|
|
42
|
+
* use request instead.
|
|
43
|
+
*
|
|
44
|
+
* http request tool
|
|
45
|
+
*/
|
|
46
|
+
Request: IRequest;
|
|
47
|
+
/**
|
|
48
|
+
* plugin system core part transformer\uploader\beforeTransformPlugins...
|
|
49
|
+
*/
|
|
50
|
+
helper: IHelper;
|
|
51
|
+
/**
|
|
52
|
+
* picgo-core version
|
|
53
|
+
*/
|
|
54
|
+
VERSION: string;
|
|
55
|
+
/**
|
|
56
|
+
* electron picgo's version
|
|
57
|
+
*/
|
|
58
|
+
GUI_VERSION?: string;
|
|
59
|
+
/**
|
|
60
|
+
* will be released in v1.5.0+
|
|
61
|
+
*
|
|
62
|
+
* replace old Request
|
|
63
|
+
*
|
|
64
|
+
* http request tool
|
|
65
|
+
*/
|
|
66
|
+
request: IRequest['request'];
|
|
67
|
+
i18n: II18nManager;
|
|
68
|
+
/**
|
|
69
|
+
* get picgo config
|
|
70
|
+
*/
|
|
71
|
+
getConfig: <T>(name?: string) => T;
|
|
72
|
+
/**
|
|
73
|
+
* save picgo config to configPath
|
|
74
|
+
*/
|
|
75
|
+
saveConfig: (config: IStringKeyMap<any>) => void;
|
|
76
|
+
/**
|
|
77
|
+
* remove some [propName] in config[key] && save config to configPath
|
|
78
|
+
*/
|
|
79
|
+
removeConfig: (key: string, propName: string) => void;
|
|
80
|
+
/**
|
|
81
|
+
* set picgo config to ctx && will not save to configPath
|
|
82
|
+
*/
|
|
83
|
+
setConfig: (config: IStringKeyMap<any>) => void;
|
|
84
|
+
/**
|
|
85
|
+
* unset picgo config to ctx && will not save to configPath
|
|
86
|
+
*/
|
|
87
|
+
unsetConfig: (key: string, propName: string) => void;
|
|
88
|
+
/**
|
|
89
|
+
* upload gogogo
|
|
90
|
+
*/
|
|
91
|
+
upload: (input?: any[]) => Promise<IImgInfo[] | Error>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* for plugin config
|
|
95
|
+
*/
|
|
96
|
+
export interface IPluginConfig {
|
|
97
|
+
name: string;
|
|
98
|
+
type: string;
|
|
99
|
+
required: boolean;
|
|
100
|
+
default?: any;
|
|
101
|
+
alias?: string;
|
|
102
|
+
message?: string;
|
|
103
|
+
prefix?: string;
|
|
104
|
+
[propName: string]: any;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* for lifecycle plugins
|
|
108
|
+
*/
|
|
109
|
+
export interface ILifecyclePlugins {
|
|
110
|
+
register: (id: string, plugin: IPlugin) => void;
|
|
111
|
+
unregister: (id: string) => void;
|
|
112
|
+
getName: () => string;
|
|
113
|
+
get: (id: string) => IPlugin | undefined;
|
|
114
|
+
getList: () => IPlugin[];
|
|
115
|
+
getIdList: () => string[];
|
|
116
|
+
}
|
|
117
|
+
export interface IHelper {
|
|
118
|
+
transformer: ILifecyclePlugins;
|
|
119
|
+
uploader: ILifecyclePlugins;
|
|
120
|
+
beforeTransformPlugins: ILifecyclePlugins;
|
|
121
|
+
beforeUploadPlugins: ILifecyclePlugins;
|
|
122
|
+
afterUploadPlugins: ILifecyclePlugins;
|
|
123
|
+
}
|
|
124
|
+
export interface ICommander extends ILifecyclePlugins {
|
|
125
|
+
program: Command;
|
|
126
|
+
inquirer: Inquirer;
|
|
127
|
+
}
|
|
128
|
+
export interface IPluginLoader {
|
|
129
|
+
/**
|
|
130
|
+
* register [local plugin] or [provided plugin]
|
|
131
|
+
*
|
|
132
|
+
* if the second param (plugin) is provided
|
|
133
|
+
*
|
|
134
|
+
* then picgo will register this plugin and enable it by default
|
|
135
|
+
*
|
|
136
|
+
* but picgo won't write any config to config file
|
|
137
|
+
*
|
|
138
|
+
* you should use ctx.setConfig to change the config context
|
|
139
|
+
*/
|
|
140
|
+
registerPlugin: (name: string, plugin?: IPicGoPlugin) => void;
|
|
141
|
+
unregisterPlugin: (name: string) => void;
|
|
142
|
+
getPlugin: (name: string) => IPicGoPluginInterface | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* get enabled plugin list
|
|
145
|
+
*/
|
|
146
|
+
getList: () => string[];
|
|
147
|
+
/**
|
|
148
|
+
* get all plugin list (enabled or not)
|
|
149
|
+
*/
|
|
150
|
+
getFullList: () => string[];
|
|
151
|
+
hasPlugin: (name: string) => boolean;
|
|
152
|
+
}
|
|
153
|
+
export interface IRequestOld {
|
|
154
|
+
request: import('axios').AxiosInstance;
|
|
155
|
+
}
|
|
156
|
+
export type IOldReqOptions = Omit<IRequestPromiseOptions & {
|
|
157
|
+
url: string;
|
|
158
|
+
}, 'auth'>;
|
|
159
|
+
export type IOldReqOptionsWithFullResponse = IOldReqOptions & {
|
|
160
|
+
resolveWithFullResponse: true;
|
|
161
|
+
};
|
|
162
|
+
export type IOldReqOptionsWithJSON = IOldReqOptions & {
|
|
163
|
+
json: true;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* for PicGo new request api, the response will be json format
|
|
167
|
+
*/
|
|
168
|
+
export type IReqOptions<T = any> = AxiosRequestConfig<T> & {
|
|
169
|
+
resolveWithFullResponse: true;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* for PicGo new request api, the response will be Buffer
|
|
173
|
+
*/
|
|
174
|
+
export type IReqOptionsWithArrayBufferRes<T = any> = IReqOptions<T> & {
|
|
175
|
+
responseType: 'arraybuffer';
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* for PicGo new request api, the response will be just response data. (not statusCode, headers, etc.)
|
|
179
|
+
*/
|
|
180
|
+
export type IReqOptionsWithBodyResOnly<T = any> = AxiosRequestConfig<T>;
|
|
181
|
+
export type IFullResponse<T = any, U = any> = AxiosResponse<T, U> & {
|
|
182
|
+
statusCode: number;
|
|
183
|
+
body: T;
|
|
184
|
+
};
|
|
185
|
+
type AxiosResponse<T = any, U = any> = import('axios').AxiosResponse<T, U>;
|
|
186
|
+
type AxiosRequestConfig<T = any> = import('axios').AxiosRequestConfig<T>;
|
|
187
|
+
interface IRequestOptionsWithFullResponse {
|
|
188
|
+
resolveWithFullResponse: true;
|
|
189
|
+
}
|
|
190
|
+
interface IRequestOptionsWithJSON {
|
|
191
|
+
json: true;
|
|
192
|
+
}
|
|
193
|
+
interface IRequestOptionsWithResponseTypeArrayBuffer {
|
|
194
|
+
responseType: 'arraybuffer';
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* T is the response data type
|
|
198
|
+
* U is the config type
|
|
199
|
+
*/
|
|
200
|
+
export type IResponse<T, U> = U extends IRequestOptionsWithFullResponse ? IFullResponse<T, U> : U extends IRequestOptionsWithJSON ? T : U extends IRequestOptionsWithResponseTypeArrayBuffer ? Buffer : U extends IOldReqOptionsWithFullResponse ? IFullResponse<T, U> : U extends IOldReqOptionsWithJSON ? T : U extends IOldReqOptions ? string : U extends IReqOptionsWithBodyResOnly ? T : string;
|
|
201
|
+
/**
|
|
202
|
+
* the old request lib will be removed in v1.5.0+
|
|
203
|
+
* the request options have the following properties
|
|
204
|
+
*/
|
|
205
|
+
export interface IRequestLibOnlyOptions {
|
|
206
|
+
proxy?: string;
|
|
207
|
+
body?: any;
|
|
208
|
+
formData?: {
|
|
209
|
+
[key: string]: any;
|
|
210
|
+
} | undefined;
|
|
211
|
+
form?: {
|
|
212
|
+
[key: string]: any;
|
|
213
|
+
} | string | undefined;
|
|
214
|
+
}
|
|
215
|
+
export type IRequestConfig<T> = T extends IRequestLibOnlyOptions ? IOldReqOptions : AxiosRequestConfig;
|
|
216
|
+
export interface IRequest {
|
|
217
|
+
request: <T, U extends (IRequestConfig<U> extends IOldReqOptions ? IOldReqOptions : IRequestConfig<U> extends AxiosRequestConfig ? AxiosRequestConfig : never)>(config: U) => Promise<IResponse<T, U>>;
|
|
218
|
+
}
|
|
219
|
+
export type ILogColor = 'blue' | 'green' | 'yellow' | 'red';
|
|
220
|
+
/**
|
|
221
|
+
* for uploading image info
|
|
222
|
+
*/
|
|
223
|
+
export interface IImgInfo {
|
|
224
|
+
buffer?: Buffer;
|
|
225
|
+
base64Image?: string;
|
|
226
|
+
fileName?: string;
|
|
227
|
+
width?: number;
|
|
228
|
+
height?: number;
|
|
229
|
+
extname?: string;
|
|
230
|
+
imgUrl?: string;
|
|
231
|
+
[propName: string]: any;
|
|
232
|
+
}
|
|
233
|
+
export interface IPathTransformedImgInfo extends IImgInfo {
|
|
234
|
+
success: boolean;
|
|
235
|
+
}
|
|
236
|
+
export interface IStringKeyMap<T> {
|
|
237
|
+
[key: string]: T extends T ? T : any;
|
|
238
|
+
}
|
|
239
|
+
export interface ICLIConfigs {
|
|
240
|
+
[module: string]: IStringKeyMap<any>;
|
|
241
|
+
}
|
|
242
|
+
/** SM.MS 图床配置项 */
|
|
243
|
+
export interface ISmmsConfig {
|
|
244
|
+
token: string;
|
|
245
|
+
backupDomain?: string;
|
|
246
|
+
}
|
|
247
|
+
/** 七牛云图床配置项 */
|
|
248
|
+
export interface IQiniuConfig {
|
|
249
|
+
accessKey: string;
|
|
250
|
+
secretKey: string;
|
|
251
|
+
/** 存储空间名 */
|
|
252
|
+
bucket: string;
|
|
253
|
+
/** 自定义域名 */
|
|
254
|
+
url: string;
|
|
255
|
+
/** 存储区域编号 */
|
|
256
|
+
area: 'z0' | 'z1' | 'z2' | 'na0' | 'as0' | string;
|
|
257
|
+
/** 网址后缀,比如使用 `?imageslim` 可进行[图片瘦身](https://developer.qiniu.com/dora/api/1271/image-thin-body-imageslim) */
|
|
258
|
+
options: string;
|
|
259
|
+
/** 自定义存储路径,比如 `img/` */
|
|
260
|
+
path: string;
|
|
261
|
+
}
|
|
262
|
+
/** 又拍云图床配置项 */
|
|
263
|
+
export interface IUpyunConfig {
|
|
264
|
+
/** 存储空间名,及你的服务名 */
|
|
265
|
+
bucket: string;
|
|
266
|
+
/** 操作员 */
|
|
267
|
+
operator: string;
|
|
268
|
+
/** 密码 */
|
|
269
|
+
password: string;
|
|
270
|
+
/** 针对图片的一些后缀处理参数 */
|
|
271
|
+
options: string;
|
|
272
|
+
/** 自定义存储路径,比如 `img/` */
|
|
273
|
+
path: string;
|
|
274
|
+
/** 加速域名,注意要加 `http://` 或者 `https://` */
|
|
275
|
+
url: string;
|
|
276
|
+
}
|
|
277
|
+
/** 腾讯云图床配置项 */
|
|
278
|
+
export interface ITcyunConfig {
|
|
279
|
+
secretId: string;
|
|
280
|
+
secretKey: string;
|
|
281
|
+
/** 存储桶名,v4 和 v5 版本不一样 */
|
|
282
|
+
bucket: string;
|
|
283
|
+
appId: string;
|
|
284
|
+
/** 存储区域,例如 ap-beijing-1 */
|
|
285
|
+
area: string;
|
|
286
|
+
/** 请求的 ENDPOINT,设置后 `area` 字段会失效 */
|
|
287
|
+
endpoint: string;
|
|
288
|
+
/** 自定义存储路径,比如 img/ */
|
|
289
|
+
path: string;
|
|
290
|
+
/** 自定义域名,注意要加 `http://` 或者 `https://` */
|
|
291
|
+
customUrl: string;
|
|
292
|
+
/** COS 版本,v4 或者 v5 */
|
|
293
|
+
version: 'v5' | 'v4';
|
|
294
|
+
/** 针对图片的一些后缀处理参数 PicGo 2.4.0+ PicGo-Core 1.5.0+ */
|
|
295
|
+
options: string;
|
|
296
|
+
/** 是否支持极智压缩 */
|
|
297
|
+
slim: boolean;
|
|
298
|
+
}
|
|
299
|
+
/** GitHub 图床配置项 */
|
|
300
|
+
export interface IGithubConfig {
|
|
301
|
+
/** 仓库名,格式是 `username/reponame` */
|
|
302
|
+
repo: string;
|
|
303
|
+
/** github token */
|
|
304
|
+
token: string;
|
|
305
|
+
/** 自定义存储路径,比如 `img/` */
|
|
306
|
+
path: string;
|
|
307
|
+
/** 自定义域名,注意要加 `http://` 或者 `https://` */
|
|
308
|
+
customUrl: string;
|
|
309
|
+
/** 分支名,默认是 `main` */
|
|
310
|
+
branch: string;
|
|
311
|
+
}
|
|
312
|
+
/** 阿里云图床配置项 */
|
|
313
|
+
export interface IAliyunConfig {
|
|
314
|
+
accessKeyId: string;
|
|
315
|
+
accessKeySecret: string;
|
|
316
|
+
/** 存储空间名 */
|
|
317
|
+
bucket: string;
|
|
318
|
+
/** 存储区域代号 */
|
|
319
|
+
area: string;
|
|
320
|
+
/** 自定义存储路径 */
|
|
321
|
+
path: string;
|
|
322
|
+
/** 自定义域名,注意要加 `http://` 或者 `https://` */
|
|
323
|
+
customUrl: string;
|
|
324
|
+
/** 针对图片的一些后缀处理参数 PicGo 2.2.0+ PicGo-Core 1.4.0+ */
|
|
325
|
+
options: string;
|
|
326
|
+
}
|
|
327
|
+
/** Imgur 图床配置项 */
|
|
328
|
+
export interface IImgurConfig {
|
|
329
|
+
/** imgur 的 `clientId` */
|
|
330
|
+
clientId: string;
|
|
331
|
+
/** 代理地址,仅支持 http 代理 */
|
|
332
|
+
proxy: string;
|
|
333
|
+
}
|
|
334
|
+
/** PicGo 配置文件类型定义 */
|
|
335
|
+
export interface IConfig {
|
|
336
|
+
picBed: {
|
|
337
|
+
uploader: string;
|
|
338
|
+
current?: string;
|
|
339
|
+
smms?: ISmmsConfig;
|
|
340
|
+
qiniu?: IQiniuConfig;
|
|
341
|
+
upyun?: IUpyunConfig;
|
|
342
|
+
tcyun?: ITcyunConfig;
|
|
343
|
+
github?: IGithubConfig;
|
|
344
|
+
aliyun?: IAliyunConfig;
|
|
345
|
+
imgur?: IImgurConfig;
|
|
346
|
+
transformer?: string;
|
|
347
|
+
/** for uploader */
|
|
348
|
+
proxy?: string;
|
|
349
|
+
[others: string]: any;
|
|
350
|
+
};
|
|
351
|
+
picgoPlugins: {
|
|
352
|
+
[pluginName: string]: boolean;
|
|
353
|
+
};
|
|
354
|
+
debug?: boolean;
|
|
355
|
+
silent?: boolean;
|
|
356
|
+
settings?: {
|
|
357
|
+
logLevel?: string[];
|
|
358
|
+
logPath?: string;
|
|
359
|
+
/** for npm */
|
|
360
|
+
npmRegistry?: string;
|
|
361
|
+
/** for npm */
|
|
362
|
+
npmProxy?: string;
|
|
363
|
+
[others: string]: any;
|
|
364
|
+
};
|
|
365
|
+
[configOptions: string]: any;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* for an uploader/transformer/beforeTransformHandler/beforeUploadHandler/afterUploadHandler
|
|
369
|
+
*/
|
|
370
|
+
export interface IPlugin {
|
|
371
|
+
handle: ((ctx: IPicGo) => Promise<any>) | ((ctx: IPicGo) => void);
|
|
372
|
+
/** The name of this handler */
|
|
373
|
+
name?: string;
|
|
374
|
+
/** The config of this handler */
|
|
375
|
+
config?: (ctx: IPicGo) => IPluginConfig[];
|
|
376
|
+
[propName: string]: any;
|
|
377
|
+
}
|
|
378
|
+
export type IPluginNameType = 'simple' | 'scope' | 'normal' | 'unknown';
|
|
379
|
+
export interface IPluginProcessResult {
|
|
380
|
+
success: boolean;
|
|
381
|
+
/**
|
|
382
|
+
* the package.json's name filed
|
|
383
|
+
*/
|
|
384
|
+
pkgName: string;
|
|
385
|
+
/**
|
|
386
|
+
* the plugin name or the fs absolute path
|
|
387
|
+
*/
|
|
388
|
+
fullName: string;
|
|
389
|
+
}
|
|
390
|
+
export interface IPluginHandler {
|
|
391
|
+
install: (plugins: string[], options: IPluginHandlerOptions, env?: IProcessEnv) => Promise<IPluginHandlerResult<boolean>>;
|
|
392
|
+
update: (plugins: string[], options: IPluginHandlerOptions, env?: IProcessEnv) => Promise<IPluginHandlerResult<boolean>>;
|
|
393
|
+
uninstall: (plugins: string[]) => Promise<IPluginHandlerResult<boolean>>;
|
|
394
|
+
}
|
|
395
|
+
export interface IPluginHandlerResult<T> {
|
|
396
|
+
success: T;
|
|
397
|
+
body: T extends true ? string[] : string;
|
|
398
|
+
}
|
|
399
|
+
export interface IPluginHandlerOptions {
|
|
400
|
+
npmProxy?: string;
|
|
401
|
+
npmRegistry?: string;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* for picgo npm plugins
|
|
405
|
+
*/
|
|
406
|
+
export type IPicGoPlugin = (ctx: IPicGo) => IPicGoPluginInterface;
|
|
407
|
+
/**
|
|
408
|
+
* interfaces for PicGo plugin
|
|
409
|
+
*/
|
|
410
|
+
export interface IPicGoPluginInterface {
|
|
411
|
+
/**
|
|
412
|
+
* since PicGo-Core v1.5, register will inject ctx
|
|
413
|
+
*/
|
|
414
|
+
register: (ctx: IPicGo) => void;
|
|
415
|
+
/**
|
|
416
|
+
* this plugin's config
|
|
417
|
+
*/
|
|
418
|
+
config?: (ctx: IPicGo) => IPluginConfig[];
|
|
419
|
+
/**
|
|
420
|
+
* register uploader name
|
|
421
|
+
*/
|
|
422
|
+
uploader?: string;
|
|
423
|
+
/**
|
|
424
|
+
* register transformer name
|
|
425
|
+
*/
|
|
426
|
+
transformer?: string;
|
|
427
|
+
/**
|
|
428
|
+
* for picgo gui plugins
|
|
429
|
+
*/
|
|
430
|
+
guiMenu?: (ctx: IPicGo) => IGuiMenuItem[];
|
|
431
|
+
/**
|
|
432
|
+
* for picgo gui plugins
|
|
433
|
+
* short key -> command
|
|
434
|
+
*/
|
|
435
|
+
commands?: (ctx: IPicGo) => ICommandItem[];
|
|
436
|
+
[propName: string]: any;
|
|
437
|
+
}
|
|
438
|
+
export interface IGuiMenuItem {
|
|
439
|
+
label: string;
|
|
440
|
+
handle: (ctx: IPicGo, guiApi: any) => Promise<void>;
|
|
441
|
+
}
|
|
442
|
+
export interface ICommandItem {
|
|
443
|
+
label: string;
|
|
444
|
+
name: string;
|
|
445
|
+
key: string;
|
|
446
|
+
handle: (ctx: IPicGo, guiApi: any) => Promise<void>;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* for spawn output
|
|
450
|
+
*/
|
|
451
|
+
export interface IResult {
|
|
452
|
+
code: number;
|
|
453
|
+
data: string;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* for transformer - path
|
|
457
|
+
*/
|
|
458
|
+
export interface IImgSize {
|
|
459
|
+
width: number;
|
|
460
|
+
height: number;
|
|
461
|
+
real?: boolean;
|
|
462
|
+
extname?: string;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* for initUtils
|
|
466
|
+
*/
|
|
467
|
+
export interface IFileTree {
|
|
468
|
+
[filePath: string]: string | Buffer;
|
|
469
|
+
}
|
|
470
|
+
export interface IOptions {
|
|
471
|
+
template: string;
|
|
472
|
+
dest: string;
|
|
473
|
+
hasSlash: boolean;
|
|
474
|
+
inPlace: boolean;
|
|
475
|
+
clone: boolean;
|
|
476
|
+
offline: boolean;
|
|
477
|
+
tmp: string;
|
|
478
|
+
project: string;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* for clipboard image
|
|
482
|
+
*/
|
|
483
|
+
export interface IClipboardImage {
|
|
484
|
+
imgPath: string;
|
|
485
|
+
/**
|
|
486
|
+
* if the path is generate by picgo -> false
|
|
487
|
+
* if the path is a real file path in system -> true
|
|
488
|
+
*/
|
|
489
|
+
shouldKeepAfterUploading: boolean;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* for install command environment variable
|
|
493
|
+
*/
|
|
494
|
+
export interface IProcessEnv {
|
|
495
|
+
[propName: string]: Undefinable<string>;
|
|
496
|
+
}
|
|
497
|
+
export type ILogArgvType = string | number;
|
|
498
|
+
export type ILogArgvTypeWithError = ILogArgvType | Error;
|
|
499
|
+
export type Nullable<T> = T | null;
|
|
500
|
+
export type Undefinable<T> = T | undefined;
|
|
501
|
+
export interface ILogger {
|
|
502
|
+
success: (...msg: ILogArgvType[]) => void;
|
|
503
|
+
info: (...msg: ILogArgvType[]) => void;
|
|
504
|
+
error: (...msg: ILogArgvTypeWithError[]) => void;
|
|
505
|
+
warn: (...msg: ILogArgvType[]) => void;
|
|
506
|
+
debug: (...msg: ILogArgvType[]) => void;
|
|
507
|
+
}
|
|
508
|
+
export interface IConfigChangePayload<T> {
|
|
509
|
+
configName: string;
|
|
510
|
+
value: T;
|
|
511
|
+
}
|
|
512
|
+
export interface ILocale {
|
|
513
|
+
[key: string]: any;
|
|
514
|
+
}
|
|
515
|
+
export interface II18nManager {
|
|
516
|
+
/**
|
|
517
|
+
* translate text
|
|
518
|
+
*/
|
|
519
|
+
translate: <T extends string>(key: T, args?: IStringKeyMap<string>) => string;
|
|
520
|
+
/**
|
|
521
|
+
* add locale to current i18n language
|
|
522
|
+
* default locale list
|
|
523
|
+
* - zh-CN
|
|
524
|
+
* - en
|
|
525
|
+
*/
|
|
526
|
+
addLocale: (language: string, locales: ILocale) => boolean;
|
|
527
|
+
/**
|
|
528
|
+
* set current language
|
|
529
|
+
*/
|
|
530
|
+
setLanguage: (language: string) => void;
|
|
531
|
+
/**
|
|
532
|
+
* dynamic add new language & locales
|
|
533
|
+
*/
|
|
534
|
+
addLanguage: (language: string, locales: ILocale) => boolean;
|
|
535
|
+
/**
|
|
536
|
+
* get language list
|
|
537
|
+
*/
|
|
538
|
+
getLanguageList: () => string[];
|
|
539
|
+
}
|
|
540
|
+
export {};
|