picgo 1.4.26 → 1.5.0-alpha.2

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 (101) hide show
  1. package/.eslintignore +2 -0
  2. package/.github/workflows/alpha.yml +22 -0
  3. package/CHANGELOG.md +43 -0
  4. package/README.md +14 -1
  5. package/bin/picgo +1 -1
  6. package/dist/{src/core → core}/Lifecycle.d.ts +15 -15
  7. package/dist/{src/core → core}/PicGo.d.ts +44 -44
  8. package/dist/i18n/en.d.ts +2 -0
  9. package/dist/i18n/index.d.ts +16 -0
  10. package/dist/i18n/zh-CN.d.ts +65 -0
  11. package/dist/index.cjs.js +2 -0
  12. package/dist/index.d.ts +9 -0
  13. package/dist/index.esm.js +2 -0
  14. package/dist/{src/lib → lib}/Commander.d.ts +16 -16
  15. package/dist/{src/lib → lib}/LifecyclePlugins.d.ts +16 -16
  16. package/dist/{src/lib → lib}/Logger.d.ts +16 -16
  17. package/dist/{src/lib → lib}/PluginHandler.d.ts +10 -10
  18. package/dist/{src/lib → lib}/PluginLoader.d.ts +27 -27
  19. package/dist/{src/lib → lib}/Request.d.ts +11 -11
  20. package/dist/{src/plugins → plugins}/commander/config.d.ts +3 -3
  21. package/dist/plugins/commander/i18n.d.ts +3 -0
  22. package/dist/{src/plugins → plugins}/commander/index.d.ts +3 -3
  23. package/dist/{src/plugins → plugins}/commander/init.d.ts +3 -3
  24. package/dist/{src/plugins → plugins}/commander/pluginHandler.d.ts +3 -3
  25. package/dist/{src/plugins → plugins}/commander/proxy.d.ts +3 -3
  26. package/dist/{src/plugins → plugins}/commander/setting.d.ts +5 -5
  27. package/dist/{src/plugins → plugins}/commander/upload.d.ts +3 -3
  28. package/dist/{src/plugins → plugins}/commander/use.d.ts +3 -3
  29. package/dist/{src/plugins → plugins}/transformer/base64.d.ts +5 -5
  30. package/dist/{src/plugins → plugins}/transformer/index.d.ts +3 -3
  31. package/dist/{src/plugins → plugins}/transformer/path.d.ts +5 -5
  32. package/dist/plugins/uploader/aliyun.d.ts +2 -0
  33. package/dist/plugins/uploader/github.d.ts +2 -0
  34. package/dist/plugins/uploader/imgur.d.ts +2 -0
  35. package/dist/{src/plugins → plugins}/uploader/index.d.ts +3 -3
  36. package/dist/plugins/uploader/qiniu.d.ts +2 -0
  37. package/dist/plugins/uploader/smms.d.ts +2 -0
  38. package/dist/plugins/uploader/tcyun.d.ts +8 -0
  39. package/dist/plugins/uploader/upyun.d.ts +2 -0
  40. package/dist/types/index.d.ts +468 -0
  41. package/dist/{src/utils → utils}/common.d.ts +102 -101
  42. package/dist/{src/utils → utils}/createContext.d.ts +6 -6
  43. package/dist/{src/utils → utils}/db.d.ts +15 -15
  44. package/dist/{src/utils → utils}/enum.d.ts +27 -27
  45. package/dist/{src/utils → utils}/eventBus.d.ts +4 -4
  46. package/dist/{src/utils → utils}/getClipboardImage.d.ts +4 -3
  47. package/dist/{src/utils → utils}/initUtils.d.ts +26 -26
  48. package/dist/{src/utils → utils}/interfaces.d.ts +203 -203
  49. package/package.json +27 -22
  50. package/rollup.config.js +82 -0
  51. package/dist/package.json +0 -127
  52. package/dist/src/core/Lifecycle.js +0 -123
  53. package/dist/src/core/PicGo.js +0 -210
  54. package/dist/src/index.d.ts +0 -2
  55. package/dist/src/index.js +0 -6
  56. package/dist/src/lib/Commander.js +0 -56
  57. package/dist/src/lib/LifecyclePlugins.js +0 -52
  58. package/dist/src/lib/Logger.js +0 -82
  59. package/dist/src/lib/PluginHandler.js +0 -260
  60. package/dist/src/lib/PluginLoader.js +0 -145
  61. package/dist/src/lib/Request.js +0 -42
  62. package/dist/src/plugins/commander/config.js +0 -11
  63. package/dist/src/plugins/commander/index.js +0 -21
  64. package/dist/src/plugins/commander/init.js +0 -122
  65. package/dist/src/plugins/commander/pluginHandler.js +0 -43
  66. package/dist/src/plugins/commander/proxy.js +0 -14
  67. package/dist/src/plugins/commander/setting.js +0 -102
  68. package/dist/src/plugins/commander/upload.js +0 -35
  69. package/dist/src/plugins/commander/use.js +0 -87
  70. package/dist/src/plugins/transformer/base64.js +0 -9
  71. package/dist/src/plugins/transformer/index.js +0 -16
  72. package/dist/src/plugins/transformer/path.js +0 -42
  73. package/dist/src/plugins/uploader/aliyun.d.ts +0 -7
  74. package/dist/src/plugins/uploader/aliyun.js +0 -129
  75. package/dist/src/plugins/uploader/github.d.ts +0 -7
  76. package/dist/src/plugins/uploader/github.js +0 -101
  77. package/dist/src/plugins/uploader/imgur.d.ts +0 -7
  78. package/dist/src/plugins/uploader/imgur.js +0 -81
  79. package/dist/src/plugins/uploader/index.js +0 -26
  80. package/dist/src/plugins/uploader/qiniu.d.ts +0 -7
  81. package/dist/src/plugins/uploader/qiniu.js +0 -132
  82. package/dist/src/plugins/uploader/smms.d.ts +0 -7
  83. package/dist/src/plugins/uploader/smms.js +0 -74
  84. package/dist/src/plugins/uploader/tcyun.d.ts +0 -13
  85. package/dist/src/plugins/uploader/tcyun.js +0 -218
  86. package/dist/src/plugins/uploader/upyun.d.ts +0 -7
  87. package/dist/src/plugins/uploader/upyun.js +0 -128
  88. package/dist/src/types/index.d.ts +0 -471
  89. package/dist/src/utils/clipboard/linux.sh +0 -18
  90. package/dist/src/utils/clipboard/mac.applescript +0 -0
  91. package/dist/src/utils/clipboard/windows.ps1 +0 -26
  92. package/dist/src/utils/clipboard/windows10.ps1 +0 -47
  93. package/dist/src/utils/clipboard/wsl.sh +0 -18
  94. package/dist/src/utils/common.js +0 -353
  95. package/dist/src/utils/createContext.js +0 -45
  96. package/dist/src/utils/db.js +0 -85
  97. package/dist/src/utils/enum.js +0 -33
  98. package/dist/src/utils/eventBus.js +0 -6
  99. package/dist/src/utils/getClipboardImage.js +0 -101
  100. package/dist/src/utils/initUtils.js +0 -120
  101. package/dist/src/utils/interfaces.js +0 -3
@@ -0,0 +1,468 @@
1
+ /// <reference types="node" />
2
+ import { RequestPromiseAPI } from 'request-promise-native';
3
+ import { Command } from 'commander';
4
+ import { Inquirer } from 'inquirer';
5
+ export interface IPicGo extends NodeJS.EventEmitter {
6
+ /**
7
+ * picgo configPath
8
+ *
9
+ * if do not provide, then it will use default configPath
10
+ */
11
+ configPath: string;
12
+ /**
13
+ * the picgo configPath's baseDir
14
+ */
15
+ baseDir: string;
16
+ /**
17
+ * picgo logger factory
18
+ */
19
+ log: ILogger;
20
+ /**
21
+ * picgo commander, for cli
22
+ */
23
+ cmd: ICommander;
24
+ /**
25
+ * after transformer, the input will be output
26
+ */
27
+ output: IImgInfo[];
28
+ /**
29
+ * the origin input
30
+ */
31
+ input: any[];
32
+ /**
33
+ * register\unregister\get picgo's plugin
34
+ */
35
+ pluginLoader: IPluginLoader;
36
+ /**
37
+ * install\uninstall\update picgo's plugin via npm
38
+ */
39
+ pluginHandler: IPluginHandler;
40
+ /**
41
+ * @deprecated will be removed in v1.5.0+
42
+ *
43
+ * use request instead.
44
+ *
45
+ * http request tool
46
+ */
47
+ Request: IRequest;
48
+ /**
49
+ * plugin system core part transformer\uploader\beforeTransformPlugins...
50
+ */
51
+ helper: IHelper;
52
+ /**
53
+ * picgo-core version
54
+ */
55
+ VERSION: string;
56
+ /**
57
+ * electron picgo's version
58
+ */
59
+ GUI_VERSION?: string;
60
+ /**
61
+ * will be released in v1.5.0+
62
+ *
63
+ * replace old Request
64
+ *
65
+ * http request tool
66
+ */
67
+ request: RequestPromiseAPI;
68
+ i18n: II18nManager;
69
+ /**
70
+ * get picgo config
71
+ */
72
+ getConfig: <T>(name?: string) => T;
73
+ /**
74
+ * save picgo config to configPath
75
+ */
76
+ saveConfig: (config: IStringKeyMap<any>) => void;
77
+ /**
78
+ * remove some [propName] in config[key] && save config to configPath
79
+ */
80
+ removeConfig: (key: string, propName: string) => void;
81
+ /**
82
+ * set picgo config to ctx && will not save to configPath
83
+ */
84
+ setConfig: (config: IStringKeyMap<any>) => void;
85
+ /**
86
+ * unset picgo config to ctx && will not save to configPath
87
+ */
88
+ unsetConfig: (key: string, propName: string) => void;
89
+ /**
90
+ * upload gogogo
91
+ */
92
+ upload: (input?: any[]) => Promise<IImgInfo[] | Error>;
93
+ }
94
+ /**
95
+ * for plugin config
96
+ */
97
+ export interface IPluginConfig {
98
+ name: string;
99
+ type: string;
100
+ required: boolean;
101
+ default?: any;
102
+ alias?: string;
103
+ [propName: string]: any;
104
+ }
105
+ /**
106
+ * for lifecycle plugins
107
+ */
108
+ export interface ILifecyclePlugins {
109
+ register: (id: string, plugin: IPlugin) => void;
110
+ unregister: (id: string) => void;
111
+ getName: () => string;
112
+ get: (id: string) => IPlugin | undefined;
113
+ getList: () => IPlugin[];
114
+ getIdList: () => string[];
115
+ }
116
+ export interface IHelper {
117
+ transformer: ILifecyclePlugins;
118
+ uploader: ILifecyclePlugins;
119
+ beforeTransformPlugins: ILifecyclePlugins;
120
+ beforeUploadPlugins: ILifecyclePlugins;
121
+ afterUploadPlugins: ILifecyclePlugins;
122
+ }
123
+ export interface ICommander {
124
+ program: Command;
125
+ inquirer: Inquirer;
126
+ get: (name: string) => IPlugin;
127
+ getList: () => IPlugin[];
128
+ register: (name: string, plugin: IPlugin) => void;
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 IRequest {
156
+ request: RequestPromiseAPI;
157
+ }
158
+ export declare type ILogColor = 'blue' | 'green' | 'yellow' | 'red';
159
+ /**
160
+ * for uploading image info
161
+ */
162
+ export interface IImgInfo {
163
+ buffer?: Buffer;
164
+ base64Image?: string;
165
+ fileName?: string;
166
+ width?: number;
167
+ height?: number;
168
+ extname?: string;
169
+ imgUrl?: string;
170
+ [propName: string]: any;
171
+ }
172
+ export interface IPathTransformedImgInfo extends IImgInfo {
173
+ success: boolean;
174
+ }
175
+ export interface IStringKeyMap<T> {
176
+ [key: string]: T extends T ? T : any;
177
+ }
178
+ export interface ICLIConfigs {
179
+ [module: string]: IStringKeyMap<any>;
180
+ }
181
+ /** SM.MS 图床配置项 */
182
+ export interface ISmmsConfig {
183
+ token: string;
184
+ }
185
+ /** 七牛云图床配置项 */
186
+ export interface IQiniuConfig {
187
+ accessKey: string;
188
+ secretKey: string;
189
+ /** 存储空间名 */
190
+ bucket: string;
191
+ /** 自定义域名 */
192
+ url: string;
193
+ /** 存储区域编号 */
194
+ area: 'z0' | 'z1' | 'z2' | 'na0' | 'as0' | string;
195
+ /** 网址后缀,比如使用 `?imageslim` 可进行[图片瘦身](https://developer.qiniu.com/dora/api/1271/image-thin-body-imageslim) */
196
+ options: string;
197
+ /** 自定义存储路径,比如 `img/` */
198
+ path: string;
199
+ }
200
+ /** 又拍云图床配置项 */
201
+ export interface IUpyunConfig {
202
+ /** 存储空间名,及你的服务名 */
203
+ bucket: string;
204
+ /** 操作员 */
205
+ operator: string;
206
+ /** 密码 */
207
+ password: string;
208
+ /** 针对图片的一些后缀处理参数 */
209
+ options: string;
210
+ /** 自定义存储路径,比如 `img/` */
211
+ path: string;
212
+ /** 加速域名,注意要加 `http://` 或者 `https://` */
213
+ url: string;
214
+ }
215
+ /** 腾讯云图床配置项 */
216
+ export interface ITcyunConfig {
217
+ secretId: string;
218
+ secretKey: string;
219
+ /** 存储桶名,v4 和 v5 版本不一样 */
220
+ bucket: string;
221
+ appId: string;
222
+ /** 存储区域,例如 ap-beijing-1 */
223
+ area: string;
224
+ /** 自定义存储路径,比如 img/ */
225
+ path: string;
226
+ /** 自定义域名,注意要加 `http://` 或者 `https://` */
227
+ customUrl: string;
228
+ /** COS 版本,v4 或者 v5 */
229
+ version: 'v5' | 'v4';
230
+ /** 针对图片的一些后缀处理参数 PicGo 2.4.0+ PicGo-Core 1.5.0+ */
231
+ options: string;
232
+ }
233
+ /** GitHub 图床配置项 */
234
+ export interface IGithubConfig {
235
+ /** 仓库名,格式是 `username/reponame` */
236
+ repo: string;
237
+ /** github token */
238
+ token: string;
239
+ /** 自定义存储路径,比如 `img/` */
240
+ path: string;
241
+ /** 自定义域名,注意要加 `http://` 或者 `https://` */
242
+ customUrl: string;
243
+ /** 分支名,默认是 `main` */
244
+ branch: string;
245
+ }
246
+ /** 阿里云图床配置项 */
247
+ export interface IAliyunConfig {
248
+ accessKeyId: string;
249
+ accessKeySecret: string;
250
+ /** 存储空间名 */
251
+ bucket: string;
252
+ /** 存储区域代号 */
253
+ area: string;
254
+ /** 自定义存储路径 */
255
+ path: string;
256
+ /** 自定义域名,注意要加 `http://` 或者 `https://` */
257
+ customUrl: string;
258
+ /** 针对图片的一些后缀处理参数 PicGo 2.2.0+ PicGo-Core 1.4.0+ */
259
+ options: string;
260
+ }
261
+ /** Imgur 图床配置项 */
262
+ export interface IImgurConfig {
263
+ /** imgur 的 `clientId` */
264
+ clientId: string;
265
+ /** 代理地址,仅支持 http 代理 */
266
+ proxy: string;
267
+ }
268
+ /** PicGo 配置文件类型定义 */
269
+ export interface IConfig {
270
+ picBed: {
271
+ uploader: string;
272
+ current?: string;
273
+ smms?: ISmmsConfig;
274
+ qiniu?: IQiniuConfig;
275
+ upyun?: IUpyunConfig;
276
+ tcyun?: ITcyunConfig;
277
+ github?: IGithubConfig;
278
+ aliyun?: IAliyunConfig;
279
+ imgur?: IImgurConfig;
280
+ transformer?: string;
281
+ /** for uploader */
282
+ proxy?: string;
283
+ [others: string]: any;
284
+ };
285
+ picgoPlugins: {
286
+ [pluginName: string]: boolean;
287
+ };
288
+ debug?: boolean;
289
+ silent?: boolean;
290
+ settings?: {
291
+ logLevel?: string;
292
+ logPath?: string;
293
+ /** for npm */
294
+ registry?: string;
295
+ /** for npm */
296
+ proxy?: string;
297
+ [others: string]: any;
298
+ };
299
+ [configOptions: string]: any;
300
+ }
301
+ /**
302
+ * for an uploader/transformer/beforeTransformHandler/beforeUploadHandler/afterUploadHandler
303
+ */
304
+ export interface IPlugin {
305
+ handle: ((ctx: IPicGo) => Promise<any>) | ((ctx: IPicGo) => void);
306
+ /** The name of this handler */
307
+ name?: string;
308
+ /** The config of this handler */
309
+ config?: (ctx: IPicGo) => IPluginConfig[];
310
+ [propName: string]: any;
311
+ }
312
+ export declare type IPluginNameType = 'simple' | 'scope' | 'normal' | 'unknown';
313
+ export interface IPluginProcessResult {
314
+ success: boolean;
315
+ /**
316
+ * the package.json's name filed
317
+ */
318
+ pkgName: string;
319
+ /**
320
+ * the plugin name or the fs absolute path
321
+ */
322
+ fullName: string;
323
+ }
324
+ export interface IPluginHandler {
325
+ install: (plugins: string[], options: IPluginHandlerOptions, env?: IProcessEnv) => Promise<IPluginHandlerResult<boolean>>;
326
+ update: (plugins: string[], options: IPluginHandlerOptions, env?: IProcessEnv) => Promise<IPluginHandlerResult<boolean>>;
327
+ uninstall: (plugins: string[]) => Promise<IPluginHandlerResult<boolean>>;
328
+ }
329
+ export interface IPluginHandlerResult<T> {
330
+ success: T;
331
+ body: T extends true ? string[] : string;
332
+ }
333
+ export interface IPluginHandlerOptions {
334
+ proxy?: string;
335
+ registry?: string;
336
+ }
337
+ /**
338
+ * for picgo npm plugins
339
+ */
340
+ export declare type IPicGoPlugin = (ctx: IPicGo) => IPicGoPluginInterface;
341
+ /**
342
+ * interfaces for PicGo plugin
343
+ */
344
+ export interface IPicGoPluginInterface {
345
+ /**
346
+ * since PicGo-Core v1.5, register will inject ctx
347
+ */
348
+ register: (ctx: IPicGo) => void;
349
+ /**
350
+ * this plugin's config
351
+ */
352
+ config?: (ctx: IPicGo) => IPluginConfig[];
353
+ /**
354
+ * register uploader name
355
+ */
356
+ uploader?: string;
357
+ /**
358
+ * register transformer name
359
+ */
360
+ transformer?: string;
361
+ /**
362
+ * for picgo gui plugins
363
+ */
364
+ guiMenu?: (ctx: IPicGo) => IGuiMenuItem[];
365
+ /**
366
+ * for picgo gui plugins
367
+ * short key -> command
368
+ */
369
+ commands?: (ctx: IPicGo) => ICommandItem[];
370
+ [propName: string]: any;
371
+ }
372
+ export interface IGuiMenuItem {
373
+ label: string;
374
+ handle: (ctx: IPicGo, guiApi: any) => Promise<void>;
375
+ }
376
+ export interface ICommandItem {
377
+ label: string;
378
+ name: string;
379
+ key: string;
380
+ handle: (ctx: IPicGo, guiApi: any) => Promise<void>;
381
+ }
382
+ /**
383
+ * for spawn output
384
+ */
385
+ export interface IResult {
386
+ code: number;
387
+ data: string;
388
+ }
389
+ /**
390
+ * for transformer - path
391
+ */
392
+ export interface IImgSize {
393
+ width: number;
394
+ height: number;
395
+ real?: boolean;
396
+ }
397
+ /**
398
+ * for initUtils
399
+ */
400
+ export interface IFileTree {
401
+ [filePath: string]: string | Buffer;
402
+ }
403
+ export interface IOptions {
404
+ template: string;
405
+ dest: string;
406
+ hasSlash: boolean;
407
+ inPlace: boolean;
408
+ clone: boolean;
409
+ offline: boolean;
410
+ tmp: string;
411
+ project: string;
412
+ }
413
+ /**
414
+ * for clipboard image
415
+ */
416
+ export interface IClipboardImage {
417
+ imgPath: string;
418
+ /**
419
+ * if the path is generate by picgo -> false
420
+ * if the path is a real file path in system -> true
421
+ */
422
+ shouldKeepAfterUploading: boolean;
423
+ }
424
+ /**
425
+ * for install command environment variable
426
+ */
427
+ export interface IProcessEnv {
428
+ [propName: string]: Undefinable<string>;
429
+ }
430
+ export declare type ILogArgvType = string | number;
431
+ export declare type ILogArgvTypeWithError = ILogArgvType | Error;
432
+ export declare type Nullable<T> = T | null;
433
+ export declare type Undefinable<T> = T | undefined;
434
+ export interface ILogger {
435
+ success: (...msg: ILogArgvType[]) => void;
436
+ info: (...msg: ILogArgvType[]) => void;
437
+ error: (...msg: ILogArgvTypeWithError[]) => void;
438
+ warn: (...msg: ILogArgvType[]) => void;
439
+ }
440
+ export interface IConfigChangePayload<T> {
441
+ configName: string;
442
+ value: T;
443
+ }
444
+ export interface II18nManager {
445
+ /**
446
+ * translate text
447
+ */
448
+ translate: <T extends string>(key: T, args?: IStringKeyMap<string>) => string;
449
+ /**
450
+ * add locale to current i18n language
451
+ * default locale list
452
+ * - zh-CN
453
+ * - en
454
+ */
455
+ addLocale: (language: string, locales: ILocale) => boolean;
456
+ /**
457
+ * set current language
458
+ */
459
+ setLanguage: (language: string) => void;
460
+ /**
461
+ * dynamic add new language & locales
462
+ */
463
+ addLanguage: (language: string, locales: ILocale) => boolean;
464
+ /**
465
+ * get language list
466
+ */
467
+ getLanguageList: () => string[];
468
+ }
@@ -1,101 +1,102 @@
1
- /// <reference types="node" />
2
- import { IImgSize, IPathTransformedImgInfo, IPluginNameType, ILogger } from '../types';
3
- export declare const isUrl: (url: string) => boolean;
4
- export declare const isUrlEncode: (url: string) => boolean;
5
- export declare const handleUrlEncode: (url: string) => string;
6
- export declare const getImageSize: (file: Buffer) => IImgSize;
7
- export declare const getFSFile: (filePath: string) => Promise<IPathTransformedImgInfo>;
8
- export declare const getURLFile: (url: string) => Promise<IPathTransformedImgInfo>;
9
- /**
10
- * detect the input string's type
11
- * for example
12
- * 1. @xxx/picgo-plugin-xxx -> scope
13
- * 2. picgo-plugin-xxx -> normal
14
- * 3. xxx -> simple
15
- * 4. not exists or is a path -> unknown
16
- * @param name
17
- */
18
- export declare const getPluginNameType: (name: string) => IPluginNameType;
19
- /**
20
- * detect the input string is a simple plugin name or not
21
- * for example
22
- * 1. xxx -> true
23
- * 2. /Usr/xx/xxxx/picgo-plugin-xxx -> false
24
- * @param name pluginNameOrPath
25
- */
26
- export declare const isSimpleName: (nameOrPath: string) => boolean;
27
- /**
28
- * streamline the full plugin name to a simple one
29
- * for example:
30
- * 1. picgo-plugin-xxx -> xxx
31
- * 2. @xxx/picgo-plugin-yyy -> yyy
32
- * @param name pluginFullName
33
- */
34
- export declare const handleStreamlinePluginName: (name: string) => string;
35
- /**
36
- * complete plugin name to full name
37
- * for example:
38
- * 1. xxx -> picgo-plugin-xxx
39
- * 2. picgo-plugin-xxx -> picgo-plugin-xxx
40
- * @param name pluginSimpleName
41
- * @param scope pluginScope
42
- */
43
- export declare const handleCompletePluginName: (name: string, scope?: string) => string;
44
- /**
45
- * handle install/uninstall/update plugin name or path
46
- * for example
47
- * 1. picgo-plugin-xxx -> picgo-plugin-xxx
48
- * 2. @xxx/picgo-plugin-xxx -> @xxx/picgo-plugin-xxx
49
- * 3. xxx -> picgo-plugin-xxx
50
- * 4. ./xxxx/picgo-plugin-xxx -> /absolutePath/.../xxxx/picgo-plugin-xxx
51
- * 5. /absolutePath/.../picgo-plugin-xxx -> /absolutePath/.../picgo-plugin-xxx
52
- * @param nameOrPath pluginName or pluginPath
53
- */
54
- export declare const getProcessPluginName: (nameOrPath: string, logger?: ILogger | Console) => string;
55
- /**
56
- * get the normal plugin name
57
- * for example:
58
- * 1. picgo-plugin-xxx -> picgo-plugin-xxx
59
- * 2. @xxx/picgo-plugin-xxx -> @xxx/picgo-plugin-xxx
60
- * 3. ./xxxx/picgo-plugin-xxx -> picgo-plugin-xxx
61
- * 4. /absolutePath/.../picgo-plugin-xxx -> picgo-plugin-xxx
62
- * 5. an exception: [package.json's name] !== [folder name]
63
- * then use [package.json's name], usually match the scope package.
64
- * 6. if plugin name has version: picgo-plugin-xxx@x.x.x then remove the version
65
- * @param nameOrPath
66
- */
67
- export declare const getNormalPluginName: (nameOrPath: string, logger?: ILogger | Console) => string;
68
- /**
69
- * handle transform the path to unix style
70
- * for example
71
- * 1. C:\\xxx\\xxx -> C:/xxx/xxx
72
- * 2. /xxx/xxx -> /xxx/xxx
73
- * @param path
74
- */
75
- export declare const handleUnixStylePath: (pathStr: string) => string;
76
- /**
77
- * remove plugin version when register plugin name
78
- * 1. picgo-plugin-xxx@1.0.0 -> picgo-plugin-xxx
79
- * 2. @xxx/picgo-plugin-xxx@1.0.0 -> @xxx/picgo-plugin-xxx
80
- * @param nameOrPath
81
- * @param scope
82
- */
83
- export declare const removePluginVersion: (nameOrPath: string, scope?: boolean) => string;
84
- /**
85
- * the config black item list which won't be setted
86
- * only can be got
87
- */
88
- export declare const configBlackList: never[];
89
- /**
90
- * check some config key is in blackList
91
- * @param key
92
- */
93
- export declare const isConfigKeyInBlackList: (key: string) => boolean;
94
- /**
95
- * check the input config is valid
96
- * config must be object such as { xxx: 'xxx' }
97
- * && can't be array
98
- * @param config
99
- * @returns
100
- */
101
- export declare const isInputConfigValid: (config: any) => boolean;
1
+ /// <reference types="node" />
2
+ import { IImgSize, IPathTransformedImgInfo, IPluginNameType, ILogger } from '../types';
3
+ export declare const isUrl: (url: string) => boolean;
4
+ export declare const isUrlEncode: (url: string) => boolean;
5
+ export declare const handleUrlEncode: (url: string) => string;
6
+ export declare const getImageSize: (file: Buffer) => IImgSize;
7
+ export declare const getFSFile: (filePath: string) => Promise<IPathTransformedImgInfo>;
8
+ export declare const getURLFile: (url: string) => Promise<IPathTransformedImgInfo>;
9
+ /**
10
+ * detect the input string's type
11
+ * for example
12
+ * 1. @xxx/picgo-plugin-xxx -> scope
13
+ * 2. picgo-plugin-xxx -> normal
14
+ * 3. xxx -> simple
15
+ * 4. not exists or is a path -> unknown
16
+ * @param name
17
+ */
18
+ export declare const getPluginNameType: (name: string) => IPluginNameType;
19
+ /**
20
+ * detect the input string is a simple plugin name or not
21
+ * for example
22
+ * 1. xxx -> true
23
+ * 2. /Usr/xx/xxxx/picgo-plugin-xxx -> false
24
+ * @param name pluginNameOrPath
25
+ */
26
+ export declare const isSimpleName: (nameOrPath: string) => boolean;
27
+ /**
28
+ * streamline the full plugin name to a simple one
29
+ * for example:
30
+ * 1. picgo-plugin-xxx -> xxx
31
+ * 2. @xxx/picgo-plugin-yyy -> yyy
32
+ * @param name pluginFullName
33
+ */
34
+ export declare const handleStreamlinePluginName: (name: string) => string;
35
+ /**
36
+ * complete plugin name to full name
37
+ * for example:
38
+ * 1. xxx -> picgo-plugin-xxx
39
+ * 2. picgo-plugin-xxx -> picgo-plugin-xxx
40
+ * @param name pluginSimpleName
41
+ * @param scope pluginScope
42
+ */
43
+ export declare const handleCompletePluginName: (name: string, scope?: string) => string;
44
+ /**
45
+ * handle install/uninstall/update plugin name or path
46
+ * for example
47
+ * 1. picgo-plugin-xxx -> picgo-plugin-xxx
48
+ * 2. @xxx/picgo-plugin-xxx -> @xxx/picgo-plugin-xxx
49
+ * 3. xxx -> picgo-plugin-xxx
50
+ * 4. ./xxxx/picgo-plugin-xxx -> /absolutePath/.../xxxx/picgo-plugin-xxx
51
+ * 5. /absolutePath/.../picgo-plugin-xxx -> /absolutePath/.../picgo-plugin-xxx
52
+ * @param nameOrPath pluginName or pluginPath
53
+ */
54
+ export declare const getProcessPluginName: (nameOrPath: string, logger?: ILogger | Console) => string;
55
+ /**
56
+ * get the normal plugin name
57
+ * for example:
58
+ * 1. picgo-plugin-xxx -> picgo-plugin-xxx
59
+ * 2. @xxx/picgo-plugin-xxx -> @xxx/picgo-plugin-xxx
60
+ * 3. ./xxxx/picgo-plugin-xxx -> picgo-plugin-xxx
61
+ * 4. /absolutePath/.../picgo-plugin-xxx -> picgo-plugin-xxx
62
+ * 5. an exception: [package.json's name] !== [folder name]
63
+ * then use [package.json's name], usually match the scope package.
64
+ * 6. if plugin name has version: picgo-plugin-xxx@x.x.x then remove the version
65
+ * @param nameOrPath
66
+ */
67
+ export declare const getNormalPluginName: (nameOrPath: string, logger?: ILogger | Console) => string;
68
+ /**
69
+ * handle transform the path to unix style
70
+ * for example
71
+ * 1. C:\\xxx\\xxx -> C:/xxx/xxx
72
+ * 2. /xxx/xxx -> /xxx/xxx
73
+ * @param path
74
+ */
75
+ export declare const handleUnixStylePath: (pathStr: string) => string;
76
+ /**
77
+ * remove plugin version when register plugin name
78
+ * 1. picgo-plugin-xxx@1.0.0 -> picgo-plugin-xxx
79
+ * 2. @xxx/picgo-plugin-xxx@1.0.0 -> @xxx/picgo-plugin-xxx
80
+ * @param nameOrPath
81
+ * @param scope
82
+ */
83
+ export declare const removePluginVersion: (nameOrPath: string, scope?: boolean) => string;
84
+ /**
85
+ * the config black item list which won't be setted
86
+ * only can be got
87
+ */
88
+ export declare const configBlackList: never[];
89
+ /**
90
+ * check some config key is in blackList
91
+ * @param key
92
+ */
93
+ export declare const isConfigKeyInBlackList: (key: string) => boolean;
94
+ /**
95
+ * check the input config is valid
96
+ * config must be object such as { xxx: 'xxx' }
97
+ * && can't be array
98
+ * @param config
99
+ * @returns
100
+ */
101
+ export declare const isInputConfigValid: (config: any) => boolean;
102
+ export declare function safeParse<T>(str: string): T | string;
@@ -1,6 +1,6 @@
1
- import { IPicGo } from '../types';
2
- /**
3
- * create an unique context for each upload process
4
- * @param ctx
5
- */
6
- export declare const createContext: (ctx: IPicGo) => IPicGo;
1
+ import { IPicGo } from '../types';
2
+ /**
3
+ * create an unique context for each upload process
4
+ * @param ctx
5
+ */
6
+ export declare const createContext: (ctx: IPicGo) => IPicGo;