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