universal-picgo 2.1.1 → 3.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.
@@ -13,6 +13,7 @@ declare class ExternalPicgoConfigDb implements IPicgoDb<IExternalPicgoConfig> {
13
13
  picListApiUrl: string;
14
14
  picListApiKey: string;
15
15
  };
16
+ private initReady;
16
17
  constructor(ctx: IPicGo);
17
18
  read(flush?: boolean): IJSON;
18
19
  get(key: string): any;
@@ -21,6 +22,21 @@ declare class ExternalPicgoConfigDb implements IPicgoDb<IExternalPicgoConfig> {
21
22
  unset(key: string, value: any): boolean;
22
23
  saveConfig(config: Partial<IExternalPicgoConfig>): void;
23
24
  removeConfig(config: IExternalPicgoConfig): void;
25
+ get isAsync(): boolean;
26
+ /**
27
+ * Wait for async backend to load remote data.
28
+ *
29
+ * PicGo 3.0: Local defaults are seeded immediately in the constructor
30
+ * for UI display. When ensureReady() resolves:
31
+ * - If remote data exists, it replaces the local defaults.
32
+ * - If remote data is missing, local defaults are kept and persisted.
33
+ *
34
+ * This prevents the v2 bug where constructor-time safeSet would
35
+ * overwrite real remote user configuration with generated defaults.
36
+ */
37
+ ensureReady(): Promise<void>;
38
+ flush(): Promise<void>;
39
+ private doSafeSet;
24
40
  safeSet(key: string, value: any): void;
25
41
  }
26
42
  export default ExternalPicgoConfigDb;
@@ -5,17 +5,18 @@ declare class UniversalPicGoHeadlessManager implements IPicGoHeadlessManager {
5
5
  private readonly ctx;
6
6
  constructor(options?: PicGoHeadlessManagerOptions);
7
7
  getContext(): IPicGo;
8
- getConfig(): IConfig;
9
- getCurrentUploader(): string;
10
- setCurrentUploader(uploaderId: string): PicGoValidationResult;
8
+ getConfig(): Promise<IConfig>;
9
+ getCurrentUploader(): Promise<string>;
10
+ setCurrentUploader(uploaderId: string): Promise<PicGoValidationResult>;
11
11
  listUploaders(): PicGoUploaderListItem[];
12
12
  getUploaderSchema(uploaderId: string): PicGoUploaderConfigSchema;
13
- getUploaderConfig<T extends Record<string, unknown> = Record<string, unknown>>(uploaderId: string): T;
13
+ getUploaderConfig<T extends Record<string, unknown> = Record<string, unknown>>(uploaderId: string): Promise<T>;
14
14
  validateUploaderConfig(uploaderId: string, config: Record<string, unknown>): PicGoValidationResult;
15
- saveUploaderConfig(uploaderId: string, config: Record<string, unknown>, options?: PicGoHeadlessSaveUploaderConfigOptions): PicGoValidationResult;
15
+ saveUploaderConfig(uploaderId: string, config: Record<string, unknown>, options?: PicGoHeadlessSaveUploaderConfigOptions): Promise<PicGoValidationResult>;
16
16
  auditUploaderSchemas(): PicGoUploaderSchemaAuditResult;
17
17
  upload(input?: any[]): Promise<IImgInfo[]>;
18
18
  private hasUploader;
19
+ private ensureReady;
19
20
  private withSchemaDefaults;
20
21
  private unknownUploaderResult;
21
22
  private unknownUploaderError;
@@ -79,14 +79,14 @@ export interface PicGoHeadlessSaveUploaderConfigOptions {
79
79
  }
80
80
  export interface IPicGoHeadlessManager {
81
81
  getContext(): IPicGo;
82
- getConfig(): IConfig;
83
- getCurrentUploader(): string;
84
- setCurrentUploader(uploaderId: string): PicGoValidationResult;
82
+ getConfig(): Promise<IConfig>;
83
+ getCurrentUploader(): Promise<string>;
84
+ setCurrentUploader(uploaderId: string): Promise<PicGoValidationResult>;
85
85
  listUploaders(): PicGoUploaderListItem[];
86
86
  getUploaderSchema(uploaderId: string): PicGoUploaderConfigSchema;
87
- getUploaderConfig<T extends Record<string, unknown> = Record<string, unknown>>(uploaderId: string): T;
87
+ getUploaderConfig<T extends Record<string, unknown> = Record<string, unknown>>(uploaderId: string): Promise<T>;
88
88
  validateUploaderConfig(uploaderId: string, config: Record<string, unknown>): PicGoValidationResult;
89
- saveUploaderConfig(uploaderId: string, config: Record<string, unknown>, options?: PicGoHeadlessSaveUploaderConfigOptions): PicGoValidationResult;
89
+ saveUploaderConfig(uploaderId: string, config: Record<string, unknown>, options?: PicGoHeadlessSaveUploaderConfigOptions): Promise<PicGoValidationResult>;
90
90
  auditUploaderSchemas(): PicGoUploaderSchemaAuditResult;
91
91
  upload(input?: any[]): Promise<IImgInfo[]>;
92
92
  }
@@ -3,7 +3,7 @@ import { IPicGo } from '../types';
3
3
 
4
4
  export declare const BUILT_IN_UPLOADER_IDS: readonly ["github", "gitlab", "aliyun", "tcyun", "qiniu", "upyun", "smms", "imgur", "awss3", "lsky"];
5
5
  export type BuiltInUploaderId = (typeof BUILT_IN_UPLOADER_IDS)[number];
6
- export declare const isBuiltInUploaderId: (uploaderId: string) => uploaderId is "smms" | "github" | "gitlab" | "aliyun" | "tcyun" | "qiniu" | "upyun" | "imgur" | "awss3" | "lsky";
6
+ export declare const isBuiltInUploaderId: (uploaderId: string) => uploaderId is "smms" | "lsky" | "github" | "gitlab" | "aliyun" | "tcyun" | "qiniu" | "upyun" | "imgur" | "awss3";
7
7
  export declare const listPicGoUploaders: (ctx: IPicGo) => PicGoUploaderListItem[];
8
8
  export declare const getPicGoUploaderSchema: (ctx: IPicGo, uploaderId: string) => PicGoUploaderConfigSchema | undefined;
9
9
  export declare const auditBuiltInUploaderSchemas: (ctx: IPicGo) => PicGoUploaderSchemaAuditResult;
@@ -21,5 +21,6 @@ export { isFileOrBlob, calculateMD5, isSiyuanProxyAvailable };
21
21
  export { deepMerge, getByPath, setByPath, unsetByPath };
22
22
  export { isElectronRuntime, isPicGoPluginPackageName, isThirdPartyPluginRuntimeAvailable };
23
23
  export { win, currentWin, parentWin, hasNodeEnv };
24
+ export { createUnifiedPicGoConfigFacade, type ConfigDomain, type ReadyUnifiedPicGoConfigFacade, type UnifiedConfigSnapshot, type UnifiedConfigMigrationState, type UnifiedPicGoConfigFacadeOptions, type UnifiedConfigPaths, type PasteTakeoverSnapshot, type SiyuanConfigLike, UNIFIED_CONFIG_MIGRATION_VERSION, ConfigReadError, ConfigFlushError, ConfigNotReadyError, } from './config';
24
25
  export { type IPicGo, type IImgInfo, type IPicgoDb, type IConfig, type IExternalPicgoConfig, type IPicBedType, type IUploaderConfigItem, type IUploaderConfigListItem, type IPluginConfig, type IPicGoPlugin, type IUniversalPicGoOptions, };
25
26
  export { BUILT_IN_UPLOADER_IDS, PICGO_HEADLESS_ERROR_CODES, PicGoHeadlessError, auditBuiltInUploaderSchemas, getPicGoUploaderSchema, isBuiltInUploaderId, listPicGoUploaders, type BuiltInUploaderId, type IPicGoHeadlessManager, type PicGoHeadlessErrorCode, type PicGoHeadlessErrorInput, type PicGoHeadlessManagerOptions, type PicGoHeadlessSaveUploaderConfigOptions, type PicGoUploaderConfigSchema, type PicGoUploaderListItem, type PicGoUploaderSchemaAuditResult, type PicGoUploaderSchemaChoice, type PicGoUploaderSchemaField, type PicGoUploaderSchemaFieldType, type PicGoValidationFieldError, type PicGoValidationResult, } from './headless';
@@ -130,8 +130,8 @@ export declare const getNormalPluginName: (nameOrPath: string, logger: ILogger)
130
130
  /**
131
131
  * 思源笔记内置代理是否可用。
132
132
  *
133
- * `siyuan.proxy` 中保存的端口会随思源重启失效,因此这里不再依赖落盘 origin,
134
- * 只判断当前运行时 window 是否为思源环境。
133
+ * 快速路径:`win.siyuan` 全局对象存在(iframe / Electron)→ 直接 true。
134
+ * 回退路径:同域浏览器直开时通过同步 HEAD 请求验证 API 可达性。
135
135
  */
136
136
  export declare const isSiyuanProxyAvailable: () => boolean;
137
137
  export declare const getSiyuanProxyUrl: () => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "universal-picgo",
3
- "version": "2.1.1",
3
+ "version": "3.0.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.1.1"
41
+ "universal-picgo-store": "3.0.1"
42
42
  },
43
43
  "publishConfig": {
44
44
  "access": "public"
@@ -48,6 +48,7 @@
48
48
  "dev": "vite build --watch",
49
49
  "build": "vite build",
50
50
  "start": "vite preview",
51
- "test": "npx vitest --watch"
51
+ "test": "vitest run",
52
+ "test:watch": "npx vitest --watch"
52
53
  }
53
54
  }