piclist 0.0.1
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/.eslintignore +2 -0
- package/.eslintrc.js +25 -0
- package/.github/workflows/alpha.yml +22 -0
- package/.github/workflows/main.yml +22 -0
- package/.github/workflows/manually.yml +19 -0
- package/CHANGELOG.md +549 -0
- package/License +21 -0
- package/README.md +116 -0
- package/bin/picgo +22 -0
- package/dist/core/Lifecycle.d.ts +15 -0
- package/dist/core/PicGo.d.ts +49 -0
- package/dist/i18n/en.d.ts +2 -0
- package/dist/i18n/index.d.ts +18 -0
- package/dist/i18n/zh-CN.d.ts +91 -0
- package/dist/i18n/zh-TW.d.ts +2 -0
- package/dist/index.cjs.js +3807 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.esm.js +3769 -0
- package/dist/lib/Commander.d.ts +22 -0
- package/dist/lib/LifecyclePlugins.d.ts +17 -0
- package/dist/lib/Logger.d.ts +19 -0
- package/dist/lib/PluginHandler.d.ts +10 -0
- package/dist/lib/PluginLoader.d.ts +27 -0
- package/dist/lib/Request.d.ts +12 -0
- package/dist/plugins/commander/config.d.ts +3 -0
- package/dist/plugins/commander/i18n.d.ts +3 -0
- package/dist/plugins/commander/index.d.ts +3 -0
- package/dist/plugins/commander/init.d.ts +3 -0
- package/dist/plugins/commander/pluginHandler.d.ts +3 -0
- package/dist/plugins/commander/proxy.d.ts +3 -0
- package/dist/plugins/commander/setting.d.ts +5 -0
- package/dist/plugins/commander/upload.d.ts +3 -0
- package/dist/plugins/commander/use.d.ts +3 -0
- package/dist/plugins/transformer/base64.d.ts +5 -0
- package/dist/plugins/transformer/index.d.ts +3 -0
- package/dist/plugins/transformer/path.d.ts +5 -0
- package/dist/plugins/uploader/aliyun.d.ts +2 -0
- package/dist/plugins/uploader/github.d.ts +2 -0
- package/dist/plugins/uploader/imgur.d.ts +2 -0
- package/dist/plugins/uploader/index.d.ts +3 -0
- package/dist/plugins/uploader/qiniu.d.ts +2 -0
- package/dist/plugins/uploader/smms.d.ts +2 -0
- package/dist/plugins/uploader/tcyun.d.ts +8 -0
- package/dist/plugins/uploader/upyun.d.ts +2 -0
- package/dist/types/index.d.ts +537 -0
- package/dist/types/oldRequest.d.ts +19 -0
- package/dist/utils/common.d.ts +106 -0
- package/dist/utils/createContext.d.ts +6 -0
- package/dist/utils/db.d.ts +15 -0
- package/dist/utils/enum.d.ts +27 -0
- package/dist/utils/eventBus.d.ts +4 -0
- package/dist/utils/getClipboardImage.d.ts +4 -0
- package/dist/utils/initUtils.d.ts +26 -0
- package/dist/utils/interfaces.d.ts +203 -0
- package/dist/utils/static.d.ts +1 -0
- package/logo.png +0 -0
- package/package.json +133 -0
- package/rollup.config.js +87 -0
|
@@ -0,0 +1,537 @@
|
|
|
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
|
+
/** 自定义存储路径,比如 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
|
+
/** GitHub 图床配置项 */
|
|
298
|
+
export interface IGithubConfig {
|
|
299
|
+
/** 仓库名,格式是 `username/reponame` */
|
|
300
|
+
repo: string;
|
|
301
|
+
/** github token */
|
|
302
|
+
token: string;
|
|
303
|
+
/** 自定义存储路径,比如 `img/` */
|
|
304
|
+
path: string;
|
|
305
|
+
/** 自定义域名,注意要加 `http://` 或者 `https://` */
|
|
306
|
+
customUrl: string;
|
|
307
|
+
/** 分支名,默认是 `main` */
|
|
308
|
+
branch: string;
|
|
309
|
+
}
|
|
310
|
+
/** 阿里云图床配置项 */
|
|
311
|
+
export interface IAliyunConfig {
|
|
312
|
+
accessKeyId: string;
|
|
313
|
+
accessKeySecret: string;
|
|
314
|
+
/** 存储空间名 */
|
|
315
|
+
bucket: string;
|
|
316
|
+
/** 存储区域代号 */
|
|
317
|
+
area: string;
|
|
318
|
+
/** 自定义存储路径 */
|
|
319
|
+
path: string;
|
|
320
|
+
/** 自定义域名,注意要加 `http://` 或者 `https://` */
|
|
321
|
+
customUrl: string;
|
|
322
|
+
/** 针对图片的一些后缀处理参数 PicGo 2.2.0+ PicGo-Core 1.4.0+ */
|
|
323
|
+
options: string;
|
|
324
|
+
}
|
|
325
|
+
/** Imgur 图床配置项 */
|
|
326
|
+
export interface IImgurConfig {
|
|
327
|
+
/** imgur 的 `clientId` */
|
|
328
|
+
clientId: string;
|
|
329
|
+
/** 代理地址,仅支持 http 代理 */
|
|
330
|
+
proxy: string;
|
|
331
|
+
}
|
|
332
|
+
/** PicGo 配置文件类型定义 */
|
|
333
|
+
export interface IConfig {
|
|
334
|
+
picBed: {
|
|
335
|
+
uploader: string;
|
|
336
|
+
current?: string;
|
|
337
|
+
smms?: ISmmsConfig;
|
|
338
|
+
qiniu?: IQiniuConfig;
|
|
339
|
+
upyun?: IUpyunConfig;
|
|
340
|
+
tcyun?: ITcyunConfig;
|
|
341
|
+
github?: IGithubConfig;
|
|
342
|
+
aliyun?: IAliyunConfig;
|
|
343
|
+
imgur?: IImgurConfig;
|
|
344
|
+
transformer?: string;
|
|
345
|
+
/** for uploader */
|
|
346
|
+
proxy?: string;
|
|
347
|
+
[others: string]: any;
|
|
348
|
+
};
|
|
349
|
+
picgoPlugins: {
|
|
350
|
+
[pluginName: string]: boolean;
|
|
351
|
+
};
|
|
352
|
+
debug?: boolean;
|
|
353
|
+
silent?: boolean;
|
|
354
|
+
settings?: {
|
|
355
|
+
logLevel?: string;
|
|
356
|
+
logPath?: string;
|
|
357
|
+
/** for npm */
|
|
358
|
+
registry?: string;
|
|
359
|
+
/** for npm */
|
|
360
|
+
proxy?: string;
|
|
361
|
+
[others: string]: any;
|
|
362
|
+
};
|
|
363
|
+
[configOptions: string]: any;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* for an uploader/transformer/beforeTransformHandler/beforeUploadHandler/afterUploadHandler
|
|
367
|
+
*/
|
|
368
|
+
export interface IPlugin {
|
|
369
|
+
handle: ((ctx: IPicGo) => Promise<any>) | ((ctx: IPicGo) => void);
|
|
370
|
+
/** The name of this handler */
|
|
371
|
+
name?: string;
|
|
372
|
+
/** The config of this handler */
|
|
373
|
+
config?: (ctx: IPicGo) => IPluginConfig[];
|
|
374
|
+
[propName: string]: any;
|
|
375
|
+
}
|
|
376
|
+
export declare type IPluginNameType = 'simple' | 'scope' | 'normal' | 'unknown';
|
|
377
|
+
export interface IPluginProcessResult {
|
|
378
|
+
success: boolean;
|
|
379
|
+
/**
|
|
380
|
+
* the package.json's name filed
|
|
381
|
+
*/
|
|
382
|
+
pkgName: string;
|
|
383
|
+
/**
|
|
384
|
+
* the plugin name or the fs absolute path
|
|
385
|
+
*/
|
|
386
|
+
fullName: string;
|
|
387
|
+
}
|
|
388
|
+
export interface IPluginHandler {
|
|
389
|
+
install: (plugins: string[], options: IPluginHandlerOptions, env?: IProcessEnv) => Promise<IPluginHandlerResult<boolean>>;
|
|
390
|
+
update: (plugins: string[], options: IPluginHandlerOptions, env?: IProcessEnv) => Promise<IPluginHandlerResult<boolean>>;
|
|
391
|
+
uninstall: (plugins: string[]) => Promise<IPluginHandlerResult<boolean>>;
|
|
392
|
+
}
|
|
393
|
+
export interface IPluginHandlerResult<T> {
|
|
394
|
+
success: T;
|
|
395
|
+
body: T extends true ? string[] : string;
|
|
396
|
+
}
|
|
397
|
+
export interface IPluginHandlerOptions {
|
|
398
|
+
proxy?: string;
|
|
399
|
+
registry?: string;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* for picgo npm plugins
|
|
403
|
+
*/
|
|
404
|
+
export declare type IPicGoPlugin = (ctx: IPicGo) => IPicGoPluginInterface;
|
|
405
|
+
/**
|
|
406
|
+
* interfaces for PicGo plugin
|
|
407
|
+
*/
|
|
408
|
+
export interface IPicGoPluginInterface {
|
|
409
|
+
/**
|
|
410
|
+
* since PicGo-Core v1.5, register will inject ctx
|
|
411
|
+
*/
|
|
412
|
+
register: (ctx: IPicGo) => void;
|
|
413
|
+
/**
|
|
414
|
+
* this plugin's config
|
|
415
|
+
*/
|
|
416
|
+
config?: (ctx: IPicGo) => IPluginConfig[];
|
|
417
|
+
/**
|
|
418
|
+
* register uploader name
|
|
419
|
+
*/
|
|
420
|
+
uploader?: string;
|
|
421
|
+
/**
|
|
422
|
+
* register transformer name
|
|
423
|
+
*/
|
|
424
|
+
transformer?: string;
|
|
425
|
+
/**
|
|
426
|
+
* for picgo gui plugins
|
|
427
|
+
*/
|
|
428
|
+
guiMenu?: (ctx: IPicGo) => IGuiMenuItem[];
|
|
429
|
+
/**
|
|
430
|
+
* for picgo gui plugins
|
|
431
|
+
* short key -> command
|
|
432
|
+
*/
|
|
433
|
+
commands?: (ctx: IPicGo) => ICommandItem[];
|
|
434
|
+
[propName: string]: any;
|
|
435
|
+
}
|
|
436
|
+
export interface IGuiMenuItem {
|
|
437
|
+
label: string;
|
|
438
|
+
handle: (ctx: IPicGo, guiApi: any) => Promise<void>;
|
|
439
|
+
}
|
|
440
|
+
export interface ICommandItem {
|
|
441
|
+
label: string;
|
|
442
|
+
name: string;
|
|
443
|
+
key: string;
|
|
444
|
+
handle: (ctx: IPicGo, guiApi: any) => Promise<void>;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* for spawn output
|
|
448
|
+
*/
|
|
449
|
+
export interface IResult {
|
|
450
|
+
code: number;
|
|
451
|
+
data: string;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* for transformer - path
|
|
455
|
+
*/
|
|
456
|
+
export interface IImgSize {
|
|
457
|
+
width: number;
|
|
458
|
+
height: number;
|
|
459
|
+
real?: boolean;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* for initUtils
|
|
463
|
+
*/
|
|
464
|
+
export interface IFileTree {
|
|
465
|
+
[filePath: string]: string | Buffer;
|
|
466
|
+
}
|
|
467
|
+
export interface IOptions {
|
|
468
|
+
template: string;
|
|
469
|
+
dest: string;
|
|
470
|
+
hasSlash: boolean;
|
|
471
|
+
inPlace: boolean;
|
|
472
|
+
clone: boolean;
|
|
473
|
+
offline: boolean;
|
|
474
|
+
tmp: string;
|
|
475
|
+
project: string;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* for clipboard image
|
|
479
|
+
*/
|
|
480
|
+
export interface IClipboardImage {
|
|
481
|
+
imgPath: string;
|
|
482
|
+
/**
|
|
483
|
+
* if the path is generate by picgo -> false
|
|
484
|
+
* if the path is a real file path in system -> true
|
|
485
|
+
*/
|
|
486
|
+
shouldKeepAfterUploading: boolean;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* for install command environment variable
|
|
490
|
+
*/
|
|
491
|
+
export interface IProcessEnv {
|
|
492
|
+
[propName: string]: Undefinable<string>;
|
|
493
|
+
}
|
|
494
|
+
export declare type ILogArgvType = string | number;
|
|
495
|
+
export declare type ILogArgvTypeWithError = ILogArgvType | Error;
|
|
496
|
+
export declare type Nullable<T> = T | null;
|
|
497
|
+
export declare type Undefinable<T> = T | undefined;
|
|
498
|
+
export interface ILogger {
|
|
499
|
+
success: (...msg: ILogArgvType[]) => void;
|
|
500
|
+
info: (...msg: ILogArgvType[]) => void;
|
|
501
|
+
error: (...msg: ILogArgvTypeWithError[]) => void;
|
|
502
|
+
warn: (...msg: ILogArgvType[]) => void;
|
|
503
|
+
debug: (...msg: ILogArgvType[]) => void;
|
|
504
|
+
}
|
|
505
|
+
export interface IConfigChangePayload<T> {
|
|
506
|
+
configName: string;
|
|
507
|
+
value: T;
|
|
508
|
+
}
|
|
509
|
+
export interface ILocale {
|
|
510
|
+
[key: string]: any;
|
|
511
|
+
}
|
|
512
|
+
export interface II18nManager {
|
|
513
|
+
/**
|
|
514
|
+
* translate text
|
|
515
|
+
*/
|
|
516
|
+
translate: <T extends string>(key: T, args?: IStringKeyMap<string>) => string;
|
|
517
|
+
/**
|
|
518
|
+
* add locale to current i18n language
|
|
519
|
+
* default locale list
|
|
520
|
+
* - zh-CN
|
|
521
|
+
* - en
|
|
522
|
+
*/
|
|
523
|
+
addLocale: (language: string, locales: ILocale) => boolean;
|
|
524
|
+
/**
|
|
525
|
+
* set current language
|
|
526
|
+
*/
|
|
527
|
+
setLanguage: (language: string) => void;
|
|
528
|
+
/**
|
|
529
|
+
* dynamic add new language & locales
|
|
530
|
+
*/
|
|
531
|
+
addLanguage: (language: string, locales: ILocale) => boolean;
|
|
532
|
+
/**
|
|
533
|
+
* get language list
|
|
534
|
+
*/
|
|
535
|
+
getLanguageList: () => string[];
|
|
536
|
+
}
|
|
537
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare type IMethod = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
2
|
+
export interface IHeaders {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
5
|
+
export interface IRequestPromiseOptions {
|
|
6
|
+
baseUrl?: string | undefined;
|
|
7
|
+
url?: string;
|
|
8
|
+
method?: IMethod;
|
|
9
|
+
formData?: {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
} | undefined;
|
|
12
|
+
qs?: any;
|
|
13
|
+
json?: boolean;
|
|
14
|
+
body?: any;
|
|
15
|
+
resolveWithFullResponse?: boolean;
|
|
16
|
+
headers?: IHeaders;
|
|
17
|
+
proxy?: any;
|
|
18
|
+
timeout?: number;
|
|
19
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { IImgSize, IPathTransformedImgInfo, IPluginNameType, ILogger, IPicGo } from '../types';
|
|
4
|
+
export declare const isUrl: (url: string) => boolean;
|
|
5
|
+
export declare const isUrlEncode: (url: string) => boolean;
|
|
6
|
+
export declare const handleUrlEncode: (url: string) => string;
|
|
7
|
+
export declare const getImageSize: (file: Buffer) => IImgSize;
|
|
8
|
+
export declare const getFSFile: (filePath: string) => Promise<IPathTransformedImgInfo>;
|
|
9
|
+
export declare const getURLFile: (url: string, ctx: IPicGo) => Promise<IPathTransformedImgInfo>;
|
|
10
|
+
/**
|
|
11
|
+
* detect the input string's type
|
|
12
|
+
* for example
|
|
13
|
+
* 1. @xxx/picgo-plugin-xxx -> scope
|
|
14
|
+
* 2. picgo-plugin-xxx -> normal
|
|
15
|
+
* 3. xxx -> simple
|
|
16
|
+
* 4. not exists or is a path -> unknown
|
|
17
|
+
* @param name
|
|
18
|
+
*/
|
|
19
|
+
export declare const getPluginNameType: (name: string) => IPluginNameType;
|
|
20
|
+
/**
|
|
21
|
+
* detect the input string is a simple plugin name or not
|
|
22
|
+
* for example
|
|
23
|
+
* 1. xxx -> true
|
|
24
|
+
* 2. /Usr/xx/xxxx/picgo-plugin-xxx -> false
|
|
25
|
+
* @param name pluginNameOrPath
|
|
26
|
+
*/
|
|
27
|
+
export declare const isSimpleName: (nameOrPath: string) => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* streamline the full plugin name to a simple one
|
|
30
|
+
* for example:
|
|
31
|
+
* 1. picgo-plugin-xxx -> xxx
|
|
32
|
+
* 2. @xxx/picgo-plugin-yyy -> yyy
|
|
33
|
+
* @param name pluginFullName
|
|
34
|
+
*/
|
|
35
|
+
export declare const handleStreamlinePluginName: (name: string) => string;
|
|
36
|
+
/**
|
|
37
|
+
* complete plugin name to full name
|
|
38
|
+
* for example:
|
|
39
|
+
* 1. xxx -> picgo-plugin-xxx
|
|
40
|
+
* 2. picgo-plugin-xxx -> picgo-plugin-xxx
|
|
41
|
+
* @param name pluginSimpleName
|
|
42
|
+
* @param scope pluginScope
|
|
43
|
+
*/
|
|
44
|
+
export declare const handleCompletePluginName: (name: string, scope?: string) => string;
|
|
45
|
+
/**
|
|
46
|
+
* handle install/uninstall/update plugin name or path
|
|
47
|
+
* for example
|
|
48
|
+
* 1. picgo-plugin-xxx -> picgo-plugin-xxx
|
|
49
|
+
* 2. @xxx/picgo-plugin-xxx -> @xxx/picgo-plugin-xxx
|
|
50
|
+
* 3. xxx -> picgo-plugin-xxx
|
|
51
|
+
* 4. ./xxxx/picgo-plugin-xxx -> /absolutePath/.../xxxx/picgo-plugin-xxx
|
|
52
|
+
* 5. /absolutePath/.../picgo-plugin-xxx -> /absolutePath/.../picgo-plugin-xxx
|
|
53
|
+
* @param nameOrPath pluginName or pluginPath
|
|
54
|
+
*/
|
|
55
|
+
export declare const getProcessPluginName: (nameOrPath: string, logger?: ILogger | Console) => string;
|
|
56
|
+
/**
|
|
57
|
+
* get the normal plugin name
|
|
58
|
+
* for example:
|
|
59
|
+
* 1. picgo-plugin-xxx -> picgo-plugin-xxx
|
|
60
|
+
* 2. @xxx/picgo-plugin-xxx -> @xxx/picgo-plugin-xxx
|
|
61
|
+
* 3. ./xxxx/picgo-plugin-xxx -> picgo-plugin-xxx
|
|
62
|
+
* 4. /absolutePath/.../picgo-plugin-xxx -> picgo-plugin-xxx
|
|
63
|
+
* 5. an exception: [package.json's name] !== [folder name]
|
|
64
|
+
* then use [package.json's name], usually match the scope package.
|
|
65
|
+
* 6. if plugin name has version: picgo-plugin-xxx@x.x.x then remove the version
|
|
66
|
+
* @param nameOrPath
|
|
67
|
+
*/
|
|
68
|
+
export declare const getNormalPluginName: (nameOrPath: string, logger?: ILogger | Console) => string;
|
|
69
|
+
/**
|
|
70
|
+
* handle transform the path to unix style
|
|
71
|
+
* for example
|
|
72
|
+
* 1. C:\\xxx\\xxx -> C:/xxx/xxx
|
|
73
|
+
* 2. /xxx/xxx -> /xxx/xxx
|
|
74
|
+
* @param path
|
|
75
|
+
*/
|
|
76
|
+
export declare const handleUnixStylePath: (pathStr: string) => string;
|
|
77
|
+
/**
|
|
78
|
+
* remove plugin version when register plugin name
|
|
79
|
+
* 1. picgo-plugin-xxx@1.0.0 -> picgo-plugin-xxx
|
|
80
|
+
* 2. @xxx/picgo-plugin-xxx@1.0.0 -> @xxx/picgo-plugin-xxx
|
|
81
|
+
* @param nameOrPath
|
|
82
|
+
* @param scope
|
|
83
|
+
*/
|
|
84
|
+
export declare const removePluginVersion: (nameOrPath: string, scope?: boolean) => string;
|
|
85
|
+
/**
|
|
86
|
+
* the config black item list which won't be setted
|
|
87
|
+
* only can be got
|
|
88
|
+
*/
|
|
89
|
+
export declare const configBlackList: never[];
|
|
90
|
+
/**
|
|
91
|
+
* check some config key is in blackList
|
|
92
|
+
* @param key
|
|
93
|
+
*/
|
|
94
|
+
export declare const isConfigKeyInBlackList: (key: string) => boolean;
|
|
95
|
+
/**
|
|
96
|
+
* check the input config is valid
|
|
97
|
+
* config must be object such as { xxx: 'xxx' }
|
|
98
|
+
* && can't be array
|
|
99
|
+
* @param config
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
export declare const isInputConfigValid: (config: any) => boolean;
|
|
103
|
+
export declare function safeParse<T>(str: string): T | string;
|
|
104
|
+
export declare const forceNumber: (num?: string | number) => number;
|
|
105
|
+
export declare const isDev: () => boolean;
|
|
106
|
+
export declare const isProd: () => boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IConfig, IPicGo } from '../types';
|
|
2
|
+
import { IJSON } from '@picgo/store/dist/types';
|
|
3
|
+
declare class DB {
|
|
4
|
+
private readonly ctx;
|
|
5
|
+
private readonly db;
|
|
6
|
+
constructor(ctx: IPicGo);
|
|
7
|
+
read(flush?: boolean): IJSON;
|
|
8
|
+
get(key?: string): any;
|
|
9
|
+
set(key: string, value: any): void;
|
|
10
|
+
has(key: string): boolean;
|
|
11
|
+
unset(key: string, value: any): boolean;
|
|
12
|
+
saveConfig(config: Partial<IConfig>): void;
|
|
13
|
+
removeConfig(config: IConfig): void;
|
|
14
|
+
}
|
|
15
|
+
export default DB;
|