universal-picgo 1.8.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 (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +52 -0
  3. package/dist/README.md +52 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +72224 -0
  6. package/dist/package.json +47 -0
  7. package/dist/src/core/ExternalPicgo.d.ts +24 -0
  8. package/dist/src/core/Lifecycle.d.ts +15 -0
  9. package/dist/src/core/UniversalPicGo.d.ts +47 -0
  10. package/dist/src/db/config/index.d.ts +25 -0
  11. package/dist/src/db/externalPicGo/index.d.ts +24 -0
  12. package/dist/src/db/pluginLoder/index.d.ts +24 -0
  13. package/dist/src/i18n/browserI18nDb.d.ts +16 -0
  14. package/dist/src/i18n/en.d.ts +3 -0
  15. package/dist/src/i18n/index.d.ts +18 -0
  16. package/dist/src/i18n/zh-CN.d.ts +111 -0
  17. package/dist/src/i18n/zh-TW.d.ts +3 -0
  18. package/dist/src/index.d.ts +17 -0
  19. package/dist/src/index.spec.d.ts +1 -0
  20. package/dist/src/lib/LifecyclePlugins.d.ts +18 -0
  21. package/dist/src/lib/PicGoRequest.d.ts +21 -0
  22. package/dist/src/lib/PluginHandler.d.ts +20 -0
  23. package/dist/src/lib/PluginLoader.d.ts +29 -0
  24. package/dist/src/plugins/transformer/base64.d.ts +6 -0
  25. package/dist/src/plugins/transformer/index.d.ts +4 -0
  26. package/dist/src/plugins/transformer/path.d.ts +6 -0
  27. package/dist/src/plugins/uploader/aliyun/index.d.ts +3 -0
  28. package/dist/src/plugins/uploader/aliyun/node.d.ts +4 -0
  29. package/dist/src/plugins/uploader/aliyun/web.d.ts +4 -0
  30. package/dist/src/plugins/uploader/github.d.ts +3 -0
  31. package/dist/src/plugins/uploader/gitlab.d.ts +3 -0
  32. package/dist/src/plugins/uploader/imgur.d.ts +3 -0
  33. package/dist/src/plugins/uploader/index.d.ts +4 -0
  34. package/dist/src/plugins/uploader/qiniu/digest.d.ts +7 -0
  35. package/dist/src/plugins/uploader/qiniu/index.d.ts +3 -0
  36. package/dist/src/plugins/uploader/qiniu/rs.d.ts +13 -0
  37. package/dist/src/plugins/uploader/qiniu/util.d.ts +8 -0
  38. package/dist/src/plugins/uploader/smms.d.ts +3 -0
  39. package/dist/src/plugins/uploader/tcyun.d.ts +9 -0
  40. package/dist/src/plugins/uploader/upyun/index.d.ts +3 -0
  41. package/dist/src/utils/CodingUtil.d.ts +39 -0
  42. package/dist/src/utils/CodingUtil.spec.d.ts +1 -0
  43. package/dist/src/utils/browserUtils.d.ts +12 -0
  44. package/dist/src/utils/clipboard/browser.d.ts +4 -0
  45. package/dist/src/utils/clipboard/electron.d.ts +4 -0
  46. package/dist/src/utils/cmd/index.d.ts +37 -0
  47. package/dist/src/utils/common.d.ts +135 -0
  48. package/dist/src/utils/constants.d.ts +1 -0
  49. package/dist/src/utils/createContext.d.ts +9 -0
  50. package/dist/src/utils/enums.d.ts +32 -0
  51. package/dist/src/utils/eventBus.d.ts +4 -0
  52. package/dist/src/utils/getClipboardImage.d.ts +4 -0
  53. package/dist/src/utils/hashUtil.d.ts +2 -0
  54. package/dist/src/utils/image-size/detector.d.ts +4 -0
  55. package/dist/src/utils/image-size/index.d.ts +12 -0
  56. package/dist/src/utils/image-size/types/bmp.d.ts +3 -0
  57. package/dist/src/utils/image-size/types/cur.d.ts +3 -0
  58. package/dist/src/utils/image-size/types/dds.d.ts +3 -0
  59. package/dist/src/utils/image-size/types/gif.d.ts +3 -0
  60. package/dist/src/utils/image-size/types/heif.d.ts +3 -0
  61. package/dist/src/utils/image-size/types/icns.d.ts +3 -0
  62. package/dist/src/utils/image-size/types/ico.d.ts +3 -0
  63. package/dist/src/utils/image-size/types/index.d.ts +21 -0
  64. package/dist/src/utils/image-size/types/interface.d.ts +15 -0
  65. package/dist/src/utils/image-size/types/j2c.d.ts +3 -0
  66. package/dist/src/utils/image-size/types/jp2.d.ts +3 -0
  67. package/dist/src/utils/image-size/types/jpg.d.ts +3 -0
  68. package/dist/src/utils/image-size/types/ktx.d.ts +3 -0
  69. package/dist/src/utils/image-size/types/png.d.ts +3 -0
  70. package/dist/src/utils/image-size/types/pnm.d.ts +3 -0
  71. package/dist/src/utils/image-size/types/psd.d.ts +3 -0
  72. package/dist/src/utils/image-size/types/svg.d.ts +3 -0
  73. package/dist/src/utils/image-size/types/tga.d.ts +3 -0
  74. package/dist/src/utils/image-size/types/tiff.d.ts +3 -0
  75. package/dist/src/utils/image-size/types/utils.d.ts +17 -0
  76. package/dist/src/utils/image-size/types/webp.d.ts +3 -0
  77. package/dist/src/utils/nodePolyfill.d.ts +4 -0
  78. package/dist/src/utils/nodeUtils.d.ts +31 -0
  79. package/dist/src/utils/os/index.d.ts +3 -0
  80. package/dist/src/utils/os/is-docker/index.d.ts +2 -0
  81. package/dist/src/utils/os/is-inside-container/index.d.ts +1 -0
  82. package/dist/src/utils/os/is-wsl/index.d.ts +2 -0
  83. package/dist/src/utils/picgoEventBus.d.ts +4 -0
  84. package/dist/vite.config.d.ts +2 -0
  85. package/package.json +47 -0
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "universal-picgo",
3
+ "version": "1.8.0",
4
+ "type": "module",
5
+ "description": "picgo lib for node, browser and electron",
6
+ "main": "./dist/index.js",
7
+ "typings": "./dist/index.d.ts",
8
+ "repository": "terwer/siyuan-plugin-picgo",
9
+ "homepage": "https://github.com/terwer/siyuan-plugin-picgo/tree/main/libs/Universal-PicGo-Core",
10
+ "author": "terwer",
11
+ "license": "MIT",
12
+ "files": [
13
+ "dist",
14
+ "README.md"
15
+ ],
16
+ "keywords": [
17
+ "zhi",
18
+ "lib"
19
+ ],
20
+ "scripts": {
21
+ "serve": "vite",
22
+ "dev": "vite build --watch",
23
+ "build": "vite build",
24
+ "start": "vite preview",
25
+ "test": "npx vitest --watch"
26
+ },
27
+ "devDependencies": {
28
+ "@terwer/eslint-config-custom": "^1.3.6",
29
+ "@terwer/vite-config-custom": "^0.7.6",
30
+ "@types/mime-types": "^2.1.4",
31
+ "vite-plugin-node-polyfills": "^0.21.0"
32
+ },
33
+ "dependencies": {
34
+ "@picgo/i18n": "^1.0.0",
35
+ "ali-oss": "^6.20.0",
36
+ "axios": "^1.6.8",
37
+ "dayjs": "^1.11.10",
38
+ "js-yaml": "^4.1.0",
39
+ "mime-types": "^2.1.35",
40
+ "queue": "^7.0.0",
41
+ "universal-picgo-store": "workspace:*",
42
+ "zhi-lib-base": "^0.8.0"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ }
47
+ }
@@ -0,0 +1,24 @@
1
+ import { IImgInfo, IPicGo } from '../types';
2
+ import { default as ExternalPicgoConfigDb } from '../db/externalPicGo';
3
+
4
+ /**
5
+ *外部的PicGO 上传 Api
6
+ *
7
+ * @since 0.6.0
8
+ * @version 1.6.0
9
+ * @author terwer
10
+ */
11
+ declare class ExternalPicgo {
12
+ private logger;
13
+ private requestUrl;
14
+ private readonly endpointUrl;
15
+ db: ExternalPicgoConfigDb;
16
+ constructor(ctx: IPicGo, isDev?: boolean);
17
+ /**
18
+ * 上传图片到PicGO
19
+ *
20
+ * @param input 路径数组,可为空,为空上传剪贴板
21
+ */
22
+ upload(input?: any[]): Promise<IImgInfo[] | Error>;
23
+ }
24
+ export { ExternalPicgo };
@@ -0,0 +1,15 @@
1
+ import { IPicGo } from '../types';
2
+ import { EventEmitter } from '../utils/nodePolyfill';
3
+
4
+ export declare class Lifecycle extends EventEmitter {
5
+ private readonly ctx;
6
+ private readonly logger;
7
+ constructor(ctx: IPicGo);
8
+ start(input: any[]): Promise<IPicGo>;
9
+ private beforeTransform;
10
+ private doTransform;
11
+ private beforeUpload;
12
+ private doUpload;
13
+ private afterUpload;
14
+ private handlePlugins;
15
+ }
@@ -0,0 +1,47 @@
1
+ import { PicGoRequestWrapper } from '../lib/PicGoRequest';
2
+ import { PluginHandler } from '../lib/PluginHandler';
3
+ import { IHelper, II18nManager, IImgInfo, IPicGo, IPicGoPlugin, IPicGoPluginInterface, IPluginLoader, IStringKeyMap } from '../types';
4
+ import { EventEmitter } from '../utils/nodePolyfill';
5
+ import { ILogger } from 'zhi-lib-base';
6
+
7
+ declare class UniversalPicGo extends EventEmitter implements IPicGo {
8
+ private _config;
9
+ private lifecycle;
10
+ private db;
11
+ private _pluginLoader;
12
+ configPath: string;
13
+ zhiNpmPath: string;
14
+ baseDir: string;
15
+ pluginBaseDir: string;
16
+ helper: IHelper;
17
+ log: ILogger;
18
+ output: IImgInfo[];
19
+ input: any[];
20
+ pluginHandler: PluginHandler;
21
+ requestWrapper: PicGoRequestWrapper;
22
+ i18n: II18nManager;
23
+ VERSION: string;
24
+ private readonly isDev;
25
+ get pluginLoader(): IPluginLoader;
26
+ getLogger(name?: string): ILogger;
27
+ get request(): PicGoRequestWrapper["PicGoRequest"];
28
+ constructor(configPath?: string, pluginBaseDir?: string, zhiNpmPath?: string, isDev?: boolean);
29
+ /**
30
+ * easily mannually load a plugin
31
+ * if provide plugin name, will register plugin by name
32
+ * or just instantiate a plugin
33
+ */
34
+ use(plugin: IPicGoPlugin, name?: string): IPicGoPluginInterface;
35
+ getConfig<T>(name?: string, defaultValue?: any): T;
36
+ saveConfig(config: IStringKeyMap<any>): void;
37
+ removeConfig(key: string, propName: string): void;
38
+ setConfig(config: IStringKeyMap<any>): void;
39
+ unsetConfig(key: string, propName: string): void;
40
+ upload(input?: any[]): Promise<IImgInfo[] | Error>;
41
+ private getDefautBaseDir;
42
+ private initConfigPath;
43
+ private initZhiNpmPath;
44
+ private initConfig;
45
+ private init;
46
+ }
47
+ export { UniversalPicGo };
@@ -0,0 +1,25 @@
1
+ import { IJSON } from 'universal-picgo-store';
2
+ import { IConfig, IPicGo, IPicgoDb } from '../../types';
3
+
4
+ declare class ConfigDb implements IPicgoDb<IConfig> {
5
+ private readonly ctx;
6
+ private readonly db;
7
+ readonly key: string;
8
+ readonly initialValue: {
9
+ picBed: {
10
+ uploader: string;
11
+ current: string;
12
+ };
13
+ picgoPlugins: {};
14
+ };
15
+ constructor(ctx: IPicGo);
16
+ read(flush?: boolean): IJSON;
17
+ get(key: string): any;
18
+ set(key: string, value: any): void;
19
+ has(key: string): boolean;
20
+ unset(key: string, value: any): boolean;
21
+ saveConfig(config: Partial<IConfig>): void;
22
+ removeConfig(config: IConfig): void;
23
+ safeSet(key: string, value: any): void;
24
+ }
25
+ export default ConfigDb;
@@ -0,0 +1,24 @@
1
+ import { PicgoTypeEnum } from '../../utils/enums';
2
+ import { IJSON } from 'universal-picgo-store';
3
+ import { IExternalPicgoConfig, IPicGo, IPicgoDb } from '../../types';
4
+
5
+ declare class ExternalPicgoConfigDb implements IPicgoDb<IExternalPicgoConfig> {
6
+ private readonly ctx;
7
+ private readonly db;
8
+ readonly key: string;
9
+ readonly initialValue: {
10
+ useBundledPicgo: boolean;
11
+ picgoType: PicgoTypeEnum;
12
+ extPicgoApiUrl: string;
13
+ };
14
+ constructor(ctx: IPicGo);
15
+ read(flush?: boolean): IJSON;
16
+ get(key: string): any;
17
+ set(key: string, value: any): void;
18
+ has(key: string): boolean;
19
+ unset(key: string, value: any): boolean;
20
+ saveConfig(config: Partial<IExternalPicgoConfig>): void;
21
+ removeConfig(config: IExternalPicgoConfig): void;
22
+ safeSet(key: string, value: any): void;
23
+ }
24
+ export default ExternalPicgoConfigDb;
@@ -0,0 +1,24 @@
1
+ import { IJSON } from 'universal-picgo-store';
2
+ import { IPicGo, IPicgoDb } from '../../types';
3
+
4
+ declare class PluginLoaderDb implements IPicgoDb<any> {
5
+ private readonly ctx;
6
+ private readonly db;
7
+ readonly key: string;
8
+ readonly initialValue: {
9
+ name: string;
10
+ description: string;
11
+ repository: string;
12
+ license: string;
13
+ };
14
+ constructor(ctx: IPicGo);
15
+ read(flush?: boolean): IJSON;
16
+ get(key: string): any;
17
+ set(key: string, value: any): void;
18
+ has(key: string): boolean;
19
+ unset(key: string, value: any): boolean;
20
+ saveConfig(config: Partial<any>): void;
21
+ removeConfig(config: any): void;
22
+ safeSet(key: string, value: any): void;
23
+ }
24
+ export default PluginLoaderDb;
@@ -0,0 +1,16 @@
1
+ import { IBrowserLocal, IPicGo } from '../types';
2
+
3
+ declare class BrowserI18nDb {
4
+ private readonly ctx;
5
+ private readonly db;
6
+ private readonly hasRead;
7
+ private readonly i18nKey;
8
+ constructor(ctx: IPicGo);
9
+ read(flush?: boolean): IBrowserLocal[];
10
+ unset(): boolean;
11
+ get(key: string): any;
12
+ set(key: string, value: any): void;
13
+ has(key: string): boolean;
14
+ safeSet(key: string, value: any): void;
15
+ }
16
+ export default BrowserI18nDb;
@@ -0,0 +1,3 @@
1
+ import { ILocales } from './zh-CN';
2
+
3
+ export declare const EN: ILocales;
@@ -0,0 +1,18 @@
1
+ import { ILocalesKey } from './zh-CN';
2
+ import { II18nManager, ILocale, IPicGo, IStringKeyMap } from '../types';
3
+
4
+ declare class I18nManager implements II18nManager {
5
+ private readonly i18n;
6
+ private readonly objectAdapter;
7
+ private readonly ctx;
8
+ private readonly browserI18nDb?;
9
+ constructor(ctx: IPicGo);
10
+ translate<T extends string>(key: ILocalesKey | T, args?: IStringKeyMap<string>): string;
11
+ setLanguage(language: string): void;
12
+ addLocale(language: string, locales: ILocale): boolean;
13
+ addLanguage(language: string, locales: ILocale): boolean;
14
+ getLanguageList(): string[];
15
+ private getOutterI18nFolder;
16
+ private loadOutterI18n;
17
+ }
18
+ export { I18nManager };
@@ -0,0 +1,111 @@
1
+ export declare const ZH_CN: {
2
+ UPLOAD_FAILED: string;
3
+ CHECK_SETTINGS: string;
4
+ CHECK_SETTINGS_AND_NETWORK: string;
5
+ UPLOAD_FAILED_REASON: string;
6
+ SERVER_ERROR: string;
7
+ AUTH_FAILED: string;
8
+ PICBED_SMMS: string;
9
+ PICBED_SMMS_TOKEN: string;
10
+ PICBED_SMMS_BACKUP_DOMAIN: string;
11
+ PICBED_SMMS_MESSAGE_BACKUP_DOMAIN: string;
12
+ PICBED_ALICLOUD: string;
13
+ PICBED_ALICLOUD_ACCESSKEYID: string;
14
+ PICBED_ALICLOUD_ACCESSKEYSECRET: string;
15
+ PICBED_ALICLOUD_BUCKET: string;
16
+ PICBED_ALICLOUD_AREA: string;
17
+ PICBED_ALICLOUD_PATH: string;
18
+ PICBED_ALICLOUD_CUSTOMURL: string;
19
+ PICBED_ALICLOUD_OPTIONS: string;
20
+ PICBED_ALICLOUD_MESSAGE_AREA: string;
21
+ PICBED_ALICLOUD_MESSAGE_PATH: string;
22
+ PICBED_ALICLOUD_MESSAGE_OPTIONS: string;
23
+ PICBED_ALICLOUD_MESSAGE_CUSTOMURL: string;
24
+ PICBED_TENCENTCLOUD: string;
25
+ PICBED_TENCENTCLOUD_VERSION: string;
26
+ PICBED_TENCENTCLOUD_SECRETID: string;
27
+ PICBED_TENCENTCLOUD_SECRETKEY: string;
28
+ PICBED_TENCENTCLOUD_APPID: string;
29
+ PICBED_TENCENTCLOUD_BUCKET: string;
30
+ PICBED_TENCENTCLOUD_AREA: string;
31
+ PICBED_TENCENTCLOUD_ENDPOINT: string;
32
+ PICBED_TENCENTCLOUD_PATH: string;
33
+ PICBED_TENCENTCLOUD_OPTIONS: string;
34
+ PICBED_TENCENTCLOUD_CUSTOMURL: string;
35
+ PICBED_TENCENTCLOUD_SLIM: string;
36
+ PICBED_TENCENTCLOUD_SLIM_TIP: string;
37
+ PICBED_TENCENTCLOUD_SLIM_CONFIRM: string;
38
+ PICBED_TENCENTCLOUD_SLIM_CANCEL: string;
39
+ PICBED_TENCENTCLOUD_MESSAGE_APPID: string;
40
+ PICBED_TENCENTCLOUD_MESSAGE_AREA: string;
41
+ PICBED_TENCENTCLOUD_MESSAGE_ENDPOINT: string;
42
+ PICBED_TENCENTCLOUD_MESSAGE_PATH: string;
43
+ PICBED_TENCENTCLOUD_MESSAGE_CUSTOMURL: string;
44
+ PICBED_TENCENTCLOUD_MESSAGE_OPTIONS: string;
45
+ PICBED_GITHUB: string;
46
+ PICBED_GITHUB_TOKEN: string;
47
+ PICBED_GITHUB_REPO: string;
48
+ PICBED_GITHUB_PATH: string;
49
+ PICBED_GITHUB_BRANCH: string;
50
+ PICBED_GITHUB_CUSTOMURL: string;
51
+ PICBED_GITHUB_MESSAGE_REPO: string;
52
+ PICBED_GITHUB_MESSAGE_BRANCH: string;
53
+ PICBED_GITHUB_MESSAGE_PATH: string;
54
+ PICBED_GITHUB_MESSAGE_CUSTOMURL: string;
55
+ PICBED_GITLAB: string;
56
+ PICBED_GITLAB_URL: string;
57
+ PICBED_GITLAB_TOKEN: string;
58
+ PICBED_GITLAB_REPO: string;
59
+ PICBED_GITLAB_BRANCH: string;
60
+ PICBED_GITLAB_PATH: string;
61
+ PICBED_GITLAB_AUTHOR_MAIL: string;
62
+ PICBED_GITLAB_AUTHOR_NAME: string;
63
+ PICBED_GITLAB_COMMIT_MESSAGE: string;
64
+ PICBED_GITLAB_MESSAGE_URL: string;
65
+ PICBED_GITLAB_MESSAGE_REPO: string;
66
+ PICBED_GITLAB_MESSAGE_BRANCH: string;
67
+ PICBED_QINIU: string;
68
+ PICBED_QINIU_ACCESSKEY: string;
69
+ PICBED_QINIU_SECRETKEY: string;
70
+ PICBED_QINIU_BUCKET: string;
71
+ PICBED_QINIU_PATH: string;
72
+ PICBED_QINIU_URL: string;
73
+ PICBED_QINIU_OPTIONS: string;
74
+ PICBED_QINIU_AREA: string;
75
+ PICBED_QINIU_MESSAGE_PATH: string;
76
+ PICBED_QINIU_MESSAGE_AREA: string;
77
+ PICBED_QINIU_MESSAGE_OPTIONS: string;
78
+ PICBED_QINIU_MESSAGE_URL: string;
79
+ PICBED_IMGUR: string;
80
+ PICBED_IMGUR_CLIENTID: string;
81
+ PICBED_IMGUR_PROXY: string;
82
+ PICBED_IMGUR_MESSAGE_PROXY: string;
83
+ PICBED_UPYUN: string;
84
+ PICBED_UPYUN_BUCKET: string;
85
+ PICBED_UPYUN_OPERATOR: string;
86
+ PICBED_UPYUN_PASSWORD: string;
87
+ PICBED_UPYUN_PATH: string;
88
+ PICBED_UPYUN_URL: string;
89
+ PICBED_UPYUN_OPTIONS: string;
90
+ PICBED_UPYUN_MESSAGE_OPERATOR: string;
91
+ PICBED_UPYUN_MESSAGE_PASSWORD: string;
92
+ PICBED_UPYUN_MESSAGE_URL: string;
93
+ PICBED_UPYUN_MESSAGE_OPTIONS: string;
94
+ PICBED_UPYUN_MESSAGE_PATH: string;
95
+ PLUGIN_HANDLER_PLUGIN_INSTALL_SUCCESS: string;
96
+ PLUGIN_HANDLER_PLUGIN_INSTALL_FAILED: string;
97
+ PLUGIN_HANDLER_PLUGIN_INSTALL_FAILED_REASON: string;
98
+ PLUGIN_HANDLER_PLUGIN_INSTALL_FAILED_PATH: string;
99
+ PLUGIN_HANDLER_PLUGIN_UNINSTALL_SUCCESS: string;
100
+ PLUGIN_HANDLER_PLUGIN_UNINSTALL_FAILED: string;
101
+ PLUGIN_HANDLER_PLUGIN_UNINSTALL_FAILED_REASON: string;
102
+ PLUGIN_HANDLER_PLUGIN_UNINSTALL_FAILED_VALID: string;
103
+ PLUGIN_HANDLER_PLUGIN_UPDATE_SUCCESS: string;
104
+ PLUGIN_HANDLER_PLUGIN_UPDATE_FAILED: string;
105
+ PLUGIN_HANDLER_PLUGIN_UPDATE_FAILED_REASON: string;
106
+ PLUGIN_HANDLER_PLUGIN_UPDATE_FAILED_VALID: string;
107
+ CORS_ANYWHERE_REQUIRED: string;
108
+ CORS_ANYWHERE_REQUIRED_LOCALHOST: string;
109
+ };
110
+ export type ILocalesKey = keyof typeof ZH_CN;
111
+ export type ILocales = typeof ZH_CN;
@@ -0,0 +1,3 @@
1
+ import { ILocales } from './zh-CN';
2
+
3
+ export declare const ZH_TW: ILocales;
@@ -0,0 +1,17 @@
1
+ import { calculateMD5, isFileOrBlob, isSiyuanProxyAvailable } from './utils/common';
2
+ import { IConfig, IExternalPicgoConfig, IImgInfo, IPicBedType, IPicGo, IPicgoDb, IPicGoPlugin, IPluginConfig, IUploaderConfigItem, IUploaderConfigListItem } from './types';
3
+ import { IBusEvent, PicgoTypeEnum } from './utils/enums';
4
+ import { currentWin, hasNodeEnv, parentWin, win } from 'universal-picgo-store';
5
+ import { picgoEventBus } from './utils/picgoEventBus';
6
+ import { default as ExternalPicgoConfigDb } from './db/externalPicGo';
7
+ import { default as PluginLoaderDb } from './db/pluginLoder';
8
+ import { default as ConfigDb } from './db/config';
9
+ import { ExternalPicgo } from './core/ExternalPicgo';
10
+ import { UniversalPicGo } from './core/UniversalPicGo';
11
+
12
+ export { UniversalPicGo, ExternalPicgo, picgoEventBus };
13
+ export { ConfigDb, PluginLoaderDb, ExternalPicgoConfigDb };
14
+ export { PicgoTypeEnum, IBusEvent };
15
+ export { isFileOrBlob, calculateMD5, isSiyuanProxyAvailable };
16
+ export { win, currentWin, parentWin, hasNodeEnv };
17
+ export { type IPicGo, type IImgInfo, type IPicgoDb, type IConfig, type IExternalPicgoConfig, type IPicBedType, type IUploaderConfigItem, type IUploaderConfigListItem, type IPluginConfig, type IPicGoPlugin, };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import { ILifecyclePlugins, IPlugin } from '../types';
2
+
3
+ declare class LifecyclePlugins implements ILifecyclePlugins {
4
+ static currentPlugin: string | null;
5
+ private readonly list;
6
+ private readonly pluginIdMap;
7
+ private readonly name;
8
+ constructor(name: string);
9
+ getName(): string;
10
+ get(id: string): IPlugin | undefined;
11
+ getList(): IPlugin[];
12
+ getIdList(): string[];
13
+ register(id: string, plugin: IPlugin): void;
14
+ unregister(pluginName: string): void;
15
+ }
16
+ export declare const setCurrentPluginName: (name?: string | null) => void;
17
+ export declare const getCurrentPluginName: () => string | null;
18
+ export { LifecyclePlugins };
@@ -0,0 +1,21 @@
1
+ import { IPicGo, IResponse } from '../types';
2
+ import { AxiosRequestConfig } from 'axios';
3
+
4
+ declare class PicGoRequestWrapper {
5
+ private readonly ctx;
6
+ private readonly logger;
7
+ private proxy;
8
+ private siyuanProxy;
9
+ private options;
10
+ constructor(ctx: IPicGo);
11
+ private init;
12
+ private handleProxy;
13
+ /**
14
+ * PicGo 统一请求封装,基于 axios
15
+ *
16
+ * @param userOptions
17
+ * @constructor
18
+ */
19
+ PicGoRequest<T, U extends AxiosRequestConfig>(userOptions: U): Promise<IResponse<T, U>>;
20
+ }
21
+ export { PicGoRequestWrapper };
@@ -0,0 +1,20 @@
1
+ import { IPicGo, IPluginHandler, IPluginHandlerOptions, IPluginHandlerResult, IProcessEnv } from '../types';
2
+
3
+ export declare class PluginHandler implements IPluginHandler {
4
+ private readonly ctx;
5
+ constructor(ctx: IPicGo);
6
+ install(plugins: string[], options: IPluginHandlerOptions, env: IProcessEnv | undefined): Promise<IPluginHandlerResult<boolean>>;
7
+ uninstall(plugins: string[]): Promise<IPluginHandlerResult<boolean>>;
8
+ update(plugins: string[], options: IPluginHandlerOptions, env: IProcessEnv | undefined): Promise<IPluginHandlerResult<boolean>>;
9
+ /**
10
+ * 执行 NPM 命令
11
+ *
12
+ * @param subCommand - 要执行的 NPM 命令
13
+ * @param modules - 模块数组
14
+ * @param cwd 当前路径
15
+ * @param options
16
+ * @param env 环境变量
17
+ * @returns 执行结果的 Promise
18
+ */
19
+ private execCommand;
20
+ }
@@ -0,0 +1,29 @@
1
+ import { IPicGo, IPicGoPlugin, IPicGoPluginInterface, IPluginLoader } from '../types';
2
+
3
+ /**
4
+ * Local plugin loader, file system is required
5
+ */
6
+ export declare class PluginLoader implements IPluginLoader {
7
+ private readonly ctx;
8
+ private readonly logger;
9
+ private db;
10
+ private list;
11
+ private readonly fullList;
12
+ private readonly pluginMap;
13
+ constructor(ctx: IPicGo);
14
+ load(): boolean;
15
+ registerPlugin(name: string, plugin?: IPicGoPlugin): void;
16
+ unregisterPlugin(name: string): void;
17
+ getPlugin(name: string): IPicGoPluginInterface | undefined;
18
+ /**
19
+ * Get the list of enabled plugins
20
+ */
21
+ getList(): string[];
22
+ hasPlugin(name: string): boolean;
23
+ /**
24
+ * Get the full list of plugins, whether it is enabled or not
25
+ */
26
+ getFullList(): string[];
27
+ private init;
28
+ private resolvePlugin;
29
+ }
@@ -0,0 +1,6 @@
1
+ import { IPicGo } from '../../types';
2
+
3
+ declare const _default: {
4
+ handle: (ctx: IPicGo) => Promise<IPicGo>;
5
+ };
6
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import { IPicGoPlugin } from '../../types';
2
+
3
+ declare const buildInTransformers: IPicGoPlugin;
4
+ export default buildInTransformers;
@@ -0,0 +1,6 @@
1
+ import { IPicGo } from '../../types';
2
+
3
+ declare const _default: {
4
+ handle: (ctx: IPicGo) => Promise<IPicGo>;
5
+ };
6
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { IPicGo } from '../../../types';
2
+
3
+ export default function register(ctx: IPicGo): void;
@@ -0,0 +1,4 @@
1
+ import { IPicGo } from '../../../types';
2
+
3
+ declare const handleNode: (ctx: IPicGo) => Promise<IPicGo>;
4
+ export { handleNode };
@@ -0,0 +1,4 @@
1
+ import { IPicGo } from '../../../types';
2
+
3
+ declare const handleWeb: (ctx: IPicGo) => Promise<IPicGo>;
4
+ export { handleWeb };
@@ -0,0 +1,3 @@
1
+ import { IPicGo } from '../../types';
2
+
3
+ export default function register(ctx: IPicGo): void;
@@ -0,0 +1,3 @@
1
+ import { IPicGo } from '../../types';
2
+
3
+ export default function register(ctx: IPicGo): void;
@@ -0,0 +1,3 @@
1
+ import { IPicGo } from '../../types';
2
+
3
+ export default function register(ctx: IPicGo): void;
@@ -0,0 +1,4 @@
1
+ import { IPicGoPlugin } from '../../types';
2
+
3
+ declare const buildInUploaders: IPicGoPlugin;
4
+ export default buildInUploaders;
@@ -0,0 +1,7 @@
1
+ declare class Mac {
2
+ accessKey: string;
3
+ secretKey: string;
4
+ options: any;
5
+ constructor(accessKey: string, secretKey: string, options?: Partial<any>);
6
+ }
7
+ export { Mac };
@@ -0,0 +1,3 @@
1
+ import { IPicGo } from '../../../types';
2
+
3
+ export default function register(ctx: IPicGo): void;
@@ -0,0 +1,13 @@
1
+ import { Mac } from './digest';
2
+
3
+ /**
4
+ * 上传策略
5
+ * @link https://developer.qiniu.com/kodo/manual/1206/put-policy
6
+ */
7
+ declare class PutPolicy {
8
+ private readonly expires;
9
+ constructor(options: any);
10
+ getFlags(): any;
11
+ uploadToken(mac: Mac): string;
12
+ }
13
+ export { PutPolicy };
@@ -0,0 +1,8 @@
1
+ declare const util: {
2
+ urlsafeBase64Encode: (jsonFlags: string) => string;
3
+ urlSafeBase64Decode: (fromStr: string) => string;
4
+ base64ToUrlSafe: (v: string) => string;
5
+ urlSafeToBase64: (v: string) => string;
6
+ hmacSha1: (encodedFlags: string, secretKey: string) => string;
7
+ };
8
+ export { util };
@@ -0,0 +1,3 @@
1
+ import { IPicGo } from '../../types';
2
+
3
+ export default function register(ctx: IPicGo): void;
@@ -0,0 +1,9 @@
1
+ import { IPicGo } from '../../types';
2
+
3
+ export interface ISignature {
4
+ signature: string;
5
+ appId: string;
6
+ bucket: string;
7
+ signTime: string;
8
+ }
9
+ export default function register(ctx: IPicGo): void;
@@ -0,0 +1,3 @@
1
+ import { IPicGo } from '../../../types';
2
+
3
+ export default function register(ctx: IPicGo): void;
@@ -0,0 +1,39 @@
1
+ import { Buffer } from './nodePolyfill';
2
+
3
+ /**
4
+ * 提供编码和解码相关的实用方法
5
+ *
6
+ * @author terwer
7
+ * @since 1.8.0
8
+ */
9
+ declare class CodingUtil {
10
+ /**
11
+ * 编码字符串为 base64 格式
12
+ *
13
+ * @returns 编码后的 base64 字符串
14
+ * @param input - string | Uint8Array | ArrayBuffer
15
+ */
16
+ static encodeToBase64String(input: any): string;
17
+ /**
18
+ * 解码 base64
19
+ *
20
+ * @returns 解码后的值
21
+ * @param input - 要解码的 base64 字符串
22
+ */
23
+ static decodeBase64(input: string): Buffer;
24
+ /**
25
+ * 编码字符串为十六进制格式
26
+ *
27
+ * @param input 要编码的字符串
28
+ * @returns 编码后的十六进制字符串
29
+ */
30
+ static encodeToHexString(input: string): string;
31
+ /**
32
+ * 解码十六进制
33
+ *
34
+ * @param input 要解码的十六进制字符串
35
+ * @returns 解码后的值
36
+ */
37
+ static decodeHex(input: string): Buffer;
38
+ }
39
+ export { CodingUtil };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 获取浏览器目录
3
+ *
4
+ * @param path 完整的路径
5
+ */
6
+ export declare const getBrowserDirectoryPath: (path: string) => string;
7
+ /**
8
+ * 浏览器路径拼接
9
+ *
10
+ * @param paths 路径数组
11
+ */
12
+ export declare const browserPathJoin: (...paths: string[]) => string;