picgo 1.5.10 → 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 +20 -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 -106
  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,19 +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
- }
1
+ export 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
+ }
@@ -1,106 +1,118 @@
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;
1
+ import { IImgSize, IPathTransformedImgInfo, IPluginNameType, ILogger, IPicGo } from '../types';
2
+ export declare const isUrl: (url: string) => boolean;
3
+ export declare const isUrlEncode: (url: string) => boolean;
4
+ /**
5
+ * just encode the url with encodeURI
6
+ */
7
+ export declare const handleUrlEncode: (url: string) => string;
8
+ /**
9
+ * @param urlPath the url path need to be encoded safely
10
+ * @returns the safely encoded url path
11
+ *
12
+ * for example:
13
+ *
14
+ * /a b/, /c d.jpg -> /a%20b/c%20d.jpg
15
+ *
16
+ * /a/b, /c#d.jpg -> /a/b/c%23d.jpg
17
+ */
18
+ export declare const handleUrlPathSafeEncode: (...urlPathList: string[]) => string;
19
+ export declare const getImageSize: (file: Buffer) => IImgSize;
20
+ export declare const getFSFile: (filePath: string) => Promise<IPathTransformedImgInfo>;
21
+ export declare const getURLFile: (url: string, ctx: IPicGo) => Promise<IPathTransformedImgInfo>;
22
+ /**
23
+ * detect the input string's type
24
+ * for example
25
+ * 1. @xxx/picgo-plugin-xxx -> scope
26
+ * 2. picgo-plugin-xxx -> normal
27
+ * 3. xxx -> simple
28
+ * 4. not exists or is a path -> unknown
29
+ * @param name
30
+ */
31
+ export declare const getPluginNameType: (name: string) => IPluginNameType;
32
+ /**
33
+ * detect the input string is a simple plugin name or not
34
+ * for example
35
+ * 1. xxx -> true
36
+ * 2. /Usr/xx/xxxx/picgo-plugin-xxx -> false
37
+ * @param name pluginNameOrPath
38
+ */
39
+ export declare const isSimpleName: (nameOrPath: string) => boolean;
40
+ /**
41
+ * streamline the full plugin name to a simple one
42
+ * for example:
43
+ * 1. picgo-plugin-xxx -> xxx
44
+ * 2. @xxx/picgo-plugin-yyy -> yyy
45
+ * @param name pluginFullName
46
+ */
47
+ export declare const handleStreamlinePluginName: (name: string) => string;
48
+ /**
49
+ * complete plugin name to full name
50
+ * for example:
51
+ * 1. xxx -> picgo-plugin-xxx
52
+ * 2. picgo-plugin-xxx -> picgo-plugin-xxx
53
+ * @param name pluginSimpleName
54
+ * @param scope pluginScope
55
+ */
56
+ export declare const handleCompletePluginName: (name: string, scope?: string) => string;
57
+ /**
58
+ * handle install/uninstall/update plugin name or path
59
+ * for example
60
+ * 1. picgo-plugin-xxx -> picgo-plugin-xxx
61
+ * 2. @xxx/picgo-plugin-xxx -> @xxx/picgo-plugin-xxx
62
+ * 3. xxx -> picgo-plugin-xxx
63
+ * 4. ./xxxx/picgo-plugin-xxx -> /absolutePath/.../xxxx/picgo-plugin-xxx
64
+ * 5. /absolutePath/.../picgo-plugin-xxx -> /absolutePath/.../picgo-plugin-xxx
65
+ * @param nameOrPath pluginName or pluginPath
66
+ */
67
+ export declare const getProcessPluginName: (nameOrPath: string, logger?: ILogger | Console) => string;
68
+ /**
69
+ * get the normal plugin name
70
+ * for example:
71
+ * 1. picgo-plugin-xxx -> picgo-plugin-xxx
72
+ * 2. @xxx/picgo-plugin-xxx -> @xxx/picgo-plugin-xxx
73
+ * 3. ./xxxx/picgo-plugin-xxx -> picgo-plugin-xxx
74
+ * 4. /absolutePath/.../picgo-plugin-xxx -> picgo-plugin-xxx
75
+ * 5. an exception: [package.json's name] !== [folder name]
76
+ * then use [package.json's name], usually match the scope package.
77
+ * 6. if plugin name has version: picgo-plugin-xxx@x.x.x then remove the version
78
+ * @param nameOrPath
79
+ */
80
+ export declare const getNormalPluginName: (nameOrPath: string, logger?: ILogger | Console) => string;
81
+ /**
82
+ * handle transform the path to unix style
83
+ * for example
84
+ * 1. C:\\xxx\\xxx -> C:/xxx/xxx
85
+ * 2. /xxx/xxx -> /xxx/xxx
86
+ * @param path
87
+ */
88
+ export declare const handleUnixStylePath: (pathStr: string) => string;
89
+ /**
90
+ * remove plugin version when register plugin name
91
+ * 1. picgo-plugin-xxx@1.0.0 -> picgo-plugin-xxx
92
+ * 2. @xxx/picgo-plugin-xxx@1.0.0 -> @xxx/picgo-plugin-xxx
93
+ * @param nameOrPath
94
+ * @param scope
95
+ */
96
+ export declare const removePluginVersion: (nameOrPath: string, scope?: boolean) => string;
97
+ /**
98
+ * the config black item list which won't be setted
99
+ * only can be got
100
+ */
101
+ export declare const configBlackList: never[];
102
+ /**
103
+ * check some config key is in blackList
104
+ * @param key
105
+ */
106
+ export declare const isConfigKeyInBlackList: (key: string) => boolean;
107
+ /**
108
+ * check the input config is valid
109
+ * config must be object such as { xxx: 'xxx' }
110
+ * && can't be array
111
+ * @param config
112
+ * @returns
113
+ */
114
+ export declare const isInputConfigValid: (config: any) => boolean;
115
+ export declare function safeParse<T>(str: string): T | string;
116
+ export declare const forceNumber: (num?: string | number) => number;
117
+ export declare const isDev: () => boolean;
118
+ export declare const isProd: () => boolean;
@@ -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;
@@ -1,15 +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;
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;
@@ -1,27 +1,27 @@
1
- export declare enum ILogType {
2
- success = "success",
3
- info = "info",
4
- warn = "warn",
5
- error = "error"
6
- }
7
- /**
8
- * these events will be catched by users
9
- */
10
- export declare enum IBuildInEvent {
11
- UPLOAD_PROGRESS = "uploadProgress",
12
- FAILED = "failed",
13
- BEFORE_TRANSFORM = "beforeTransform",
14
- BEFORE_UPLOAD = "beforeUpload",
15
- AFTER_UPLOAD = "afterUpload",
16
- FINISHED = "finished",
17
- INSTALL = "install",
18
- UNINSTALL = "uninstall",
19
- UPDATE = "update",
20
- NOTIFICATION = "notification"
21
- }
22
- /**
23
- * these events will be catched only by picgo
24
- */
25
- export declare enum IBusEvent {
26
- CONFIG_CHANGE = "CONFIG_CHANGE"
27
- }
1
+ export declare enum ILogType {
2
+ success = "success",
3
+ info = "info",
4
+ warn = "warn",
5
+ error = "error"
6
+ }
7
+ /**
8
+ * these events will be catched by users
9
+ */
10
+ export declare enum IBuildInEvent {
11
+ UPLOAD_PROGRESS = "uploadProgress",
12
+ FAILED = "failed",
13
+ BEFORE_TRANSFORM = "beforeTransform",
14
+ BEFORE_UPLOAD = "beforeUpload",
15
+ AFTER_UPLOAD = "afterUpload",
16
+ FINISHED = "finished",
17
+ INSTALL = "install",
18
+ UNINSTALL = "uninstall",
19
+ UPDATE = "update",
20
+ NOTIFICATION = "notification"
21
+ }
22
+ /**
23
+ * these events will be catched only by picgo
24
+ */
25
+ export declare enum IBusEvent {
26
+ CONFIG_CHANGE = "CONFIG_CHANGE"
27
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from 'events';
3
- declare const eventBus: EventEmitter;
4
- export { eventBus };
1
+ import { EventEmitter } from 'events';
2
+ declare const eventBus: EventEmitter<[never]>;
3
+ export { eventBus };
@@ -1,4 +1,4 @@
1
- import { IPicGo, IClipboardImage } from '../types';
2
- export declare type Platform = 'darwin' | 'win32' | 'win10' | 'linux' | 'wsl';
3
- declare const getClipboardImage: (ctx: IPicGo) => Promise<IClipboardImage>;
4
- export default getClipboardImage;
1
+ import { IPicGo, IClipboardImage } from '../types';
2
+ export type Platform = 'darwin' | 'win32' | 'win10' | 'linux' | 'wsl';
3
+ declare const getClipboardImage: (ctx: IPicGo) => Promise<IClipboardImage>;
4
+ export default getClipboardImage;
@@ -1,26 +1,26 @@
1
- import { IPicGo, IOptions } from '../types';
2
- /**
3
- * Generate template files to destination files.
4
- * @param {PicGo} ctx
5
- * @param {IOptions} options
6
- */
7
- declare const generate: (ctx: IPicGo, options: IOptions) => Promise<any>;
8
- /**
9
- * Return the filters' result
10
- * @param ctx PicGo
11
- * @param exp condition expression
12
- * @param data options data
13
- */
14
- declare const filters: (ctx: IPicGo, exp: any, data: any) => boolean;
15
- /**
16
- * Render files to a virtual tree object
17
- * @param {array} files
18
- */
19
- declare const render: (files: string[], source: string, options: any) => any;
20
- /**
21
- * Write rendered files' content to real file
22
- * @param {string} dir
23
- * @param {object} files
24
- */
25
- declare const writeFileTree: (dir: string, files: any) => void;
26
- export { filters, generate, render, writeFileTree };
1
+ import { IPicGo, IOptions } from '../types';
2
+ /**
3
+ * Generate template files to destination files.
4
+ * @param {PicGo} ctx
5
+ * @param {IOptions} options
6
+ */
7
+ declare const generate: (ctx: IPicGo, options: IOptions) => Promise<any>;
8
+ /**
9
+ * Return the filters' result
10
+ * @param ctx PicGo
11
+ * @param exp condition expression
12
+ * @param data options data
13
+ */
14
+ declare const filters: (ctx: IPicGo, exp: any, data: any) => boolean;
15
+ /**
16
+ * Render files to a virtual tree object
17
+ * @param {array} files
18
+ */
19
+ declare const render: (files: string[], source: string, options: any) => any;
20
+ /**
21
+ * Write rendered files' content to real file
22
+ * @param {string} dir
23
+ * @param {object} files
24
+ */
25
+ declare const writeFileTree: (dir: string, files: any) => void;
26
+ export { filters, generate, render, writeFileTree };