universal-picgo 2.0.1 → 2.1.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/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "universal-picgo",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "type": "module",
5
5
  "description": "picgo lib for node, browser and electron",
6
6
  "main": "./dist/index.js",
@@ -0,0 +1,50 @@
1
+ import { IImgInfo, IPicGo } from '../types';
2
+ import { default as ExternalPicgoConfigDb } from '../db/externalPicGo';
3
+
4
+ /**
5
+ * 远程 PicList 上传 API
6
+ *
7
+ * 对接远程 PicList 容器的图片上传接口。
8
+ * 与本地 ExternalPicgo 不同,此上传器通过 multipart/form-data 直接携带图片二进制数据。
9
+ *
10
+ * 接口规范:
11
+ * - URL: POST {apiUrl}?key={apiKey}
12
+ * - Content-Type: multipart/form-data
13
+ * - Body: file 字段,包含图片文件
14
+ * - 响应: { success: true, result: "https://..." }
15
+ *
16
+ * @author terwer
17
+ */
18
+ declare class PicListUploader {
19
+ private readonly logger;
20
+ readonly db: ExternalPicgoConfigDb;
21
+ constructor(ctx: IPicGo, isDev?: boolean);
22
+ /**
23
+ * 上传图片到远程 PicList 服务
24
+ *
25
+ * @param input 文件路径、URL、Blob 或 File 数组。为空则上传剪贴板(不支持,会抛错)
26
+ * @returns 上传结果数组
27
+ */
28
+ upload(input?: any[]): Promise<IImgInfo[] | Error>;
29
+ /**
30
+ * 检查当前是否配置了 PicList(有远程 URL 和 API Key)
31
+ */
32
+ isPicListConfigured(): boolean;
33
+ /**
34
+ * 将输入项解析为 Blob 和文件名
35
+ */
36
+ private resolveFileData;
37
+ /**
38
+ * Node.js 环境:从文件系统读取图片
39
+ */
40
+ private resolveNodeFilePath;
41
+ /**
42
+ * 浏览器环境:通过 URL 获取图片数据
43
+ */
44
+ private resolveBrowserUrlOrPath;
45
+ /**
46
+ * 构建带 API Key 的请求 URL
47
+ */
48
+ private buildRequestUrl;
49
+ }
50
+ export { PicListUploader };
@@ -0,0 +1 @@
1
+ export {};
@@ -10,6 +10,8 @@ declare class ExternalPicgoConfigDb implements IPicgoDb<IExternalPicgoConfig> {
10
10
  useBundledPicgo: boolean;
11
11
  picgoType: PicgoTypeEnum;
12
12
  extPicgoApiUrl: string;
13
+ picListApiUrl: string;
14
+ picListApiKey: string;
13
15
  };
14
16
  constructor(ctx: IPicGo);
15
17
  read(flush?: boolean): IJSON;
@@ -9,10 +9,11 @@ import { picgoEventBus } from './utils/picgoEventBus';
9
9
  import { default as ExternalPicgoConfigDb } from './db/externalPicGo';
10
10
  import { default as PluginLoaderDb } from './db/pluginLoder';
11
11
  import { default as ConfigDb } from './db/config';
12
+ import { PicListUploader } from './core/PicListUploader';
12
13
  import { ExternalPicgo } from './core/ExternalPicgo';
13
14
  import { UniversalPicGo } from './core/UniversalPicGo';
14
15
 
15
- export { UniversalPicGo, ExternalPicgo, picgoEventBus };
16
+ export { UniversalPicGo, ExternalPicgo, PicListUploader, picgoEventBus };
16
17
  export { UniversalPicGoHeadlessManager, createPicGoHeadlessManager };
17
18
  export { ConfigDb, PluginLoaderDb, ExternalPicgoConfigDb };
18
19
  export { PicgoTypeEnum, IBusEvent };
@@ -5,7 +5,6 @@ declare class PicGoRequestWrapper {
5
5
  private readonly ctx;
6
6
  private readonly logger;
7
7
  private proxy;
8
- private siyuanProxy;
9
8
  private options;
10
9
  constructor(ctx: IPicGo);
11
10
  private init;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,7 @@
1
- import { IPicGo } from '../../../types';
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { IAliyunConfig, IPicGo } from '../../../types';
2
3
 
4
+ declare const generateSignature: (options: IAliyunConfig, fileName: string, date: string) => string;
5
+ declare const postOptions: (options: IAliyunConfig, fileName: string, signature: string, image: Buffer, date: string) => AxiosRequestConfig;
3
6
  declare const handleWeb: (ctx: IPicGo) => Promise<IPicGo>;
4
- export { handleWeb };
7
+ export { handleWeb, generateSignature, postOptions };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { ILogger } from 'zhi-lib-base';
2
2
  import { Buffer } from './nodePolyfill';
3
3
  import { win } from 'universal-picgo-store';
4
- import { IImgSize, IPathTransformedImgInfo, IPicGo, IPluginNameType, Undefinable } from '../types';
4
+ import { IImgSize, IPathTransformedImgInfo, IPicGo, IPluginNameType } from '../types';
5
5
 
6
6
  export declare const isUrl: (url: string) => boolean;
7
7
  /**
@@ -128,8 +128,10 @@ export declare const getProcessPluginName: (nameOrPath: string, logger: ILogger)
128
128
  */
129
129
  export declare const getNormalPluginName: (nameOrPath: string, logger: ILogger) => string;
130
130
  /**
131
- * 思源笔记代理是否可用
131
+ * 思源笔记内置代理是否可用。
132
132
  *
133
- * @param siyuanProxy
133
+ * `siyuan.proxy` 中保存的端口会随思源重启失效,因此这里不再依赖落盘 origin,
134
+ * 只判断当前运行时 window 是否为思源环境。
134
135
  */
135
- export declare const isSiyuanProxyAvailable: (siyuanProxy: Undefinable<string>) => boolean | "" | undefined;
136
+ export declare const isSiyuanProxyAvailable: () => boolean;
137
+ export declare const getSiyuanProxyUrl: () => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "universal-picgo",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "type": "module",
5
5
  "description": "picgo lib for node, browser and electron",
6
6
  "main": "./dist/index.js",
@@ -38,7 +38,7 @@
38
38
  "mime": "^4.0.3",
39
39
  "queue": "^7.0.0",
40
40
  "zhi-lib-base": "^0.8.0",
41
- "universal-picgo-store": "2.0.1"
41
+ "universal-picgo-store": "2.1.1"
42
42
  },
43
43
  "publishConfig": {
44
44
  "access": "public"