@xiongtao.xt/tau-plugins 0.46.0 → 0.48.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiongtao.xt/tau-plugins",
3
- "version": "0.46.0",
3
+ "version": "0.48.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,5 +1,5 @@
1
1
  import type { JsonValue } from "./json";
2
- /** 存储提供方配置表单:插件只声明字段,桌面与移动宿主各自渲染、保存与校验。 */
2
+ /** 提供方配置表单:插件只声明字段,桌面与移动宿主各自渲染、保存与校验。 */
3
3
  export type ProviderFormValues = Readonly<Record<string, string>>;
4
4
  interface ProviderFieldBase {
5
5
  key: string;
@@ -10,9 +10,31 @@ interface ProviderFieldBase {
10
10
  optional?: boolean;
11
11
  /** 按声明顺序拼成服务列表里的配置摘要;secret 字段不能作摘要 */
12
12
  summary?: boolean;
13
+ /** 仅当另一字段取指定值时显示;隐藏的字段不参与必填校验,已存值保留 */
14
+ visibleWhen?: {
15
+ key: string;
16
+ equals: string;
17
+ };
13
18
  }
14
19
  export interface ProviderTextField extends ProviderFieldBase {
15
20
  type: "text" | "secret" | "url";
21
+ default?: string;
22
+ }
23
+ /** 开关字段:取值为 "true" / "false",与其它字段一样按字符串保存;不参与必填校验。 */
24
+ export interface ProviderSwitchField extends ProviderFieldBase {
25
+ type: "switch";
26
+ default?: boolean;
27
+ }
28
+ /** 可由宿主提供选择界面的服务;不支持的宿主把字段显示为不可用。 */
29
+ export type ProviderHostService = "git.cacheDirectory";
30
+ /**
31
+ * 宿主服务选择:值由宿主服务给出(如选择 Git 缓存目录),用户不直接输入。
32
+ * key 存服务返回的标识,labelKey 存显示名;留空表示使用宿主默认,placeholder 为默认时的说明。
33
+ */
34
+ export interface ProviderServiceChoiceField extends ProviderFieldBase {
35
+ type: "service-choice";
36
+ service: ProviderHostService;
37
+ labelKey: string;
16
38
  }
17
39
  export interface ProviderChoiceOption {
18
40
  value: string;
@@ -31,12 +53,23 @@ export interface ProviderRemoteChoiceField extends ProviderFieldBase {
31
53
  /** 其中任一字段变化时清空本字段 */
32
54
  dependsOn?: readonly string[];
33
55
  }
34
- export type ProviderField = ProviderTextField | ProviderChoiceField | ProviderRemoteChoiceField;
56
+ export type ProviderField = ProviderTextField | ProviderChoiceField | ProviderRemoteChoiceField | ProviderSwitchField | ProviderServiceChoiceField;
35
57
  export interface ProviderFieldGroup {
36
58
  title: string;
37
59
  description?: string;
60
+ /** 外部链接(如服务商控制台),由宿主在分组旁展示 */
61
+ link?: {
62
+ label: string;
63
+ url: string;
64
+ };
38
65
  fields: readonly ProviderField[];
39
66
  }
67
+ /** beforeSave 抛出此错误时,宿主把文案标在对应字段上。 */
68
+ export declare class ProviderFieldError extends Error {
69
+ readonly key: string;
70
+ constructor(key: string, message: string);
71
+ }
72
+ export declare function isProviderFieldError(error: unknown): error is ProviderFieldError;
40
73
  export interface ProviderForm {
41
74
  groups: readonly ProviderFieldGroup[];
42
75
  /** 保存前调用:可补全字段(如按令牌取用户名)或抛错拒绝保存 */
@@ -44,7 +77,9 @@ export interface ProviderForm {
44
77
  }
45
78
  export declare function providerFormFields(form: ProviderForm): readonly ProviderField[];
46
79
  export declare function assertProviderForm(form: ProviderForm): void;
47
- /** 从已存配置读出表单初值:只取声明字段的字符串值,choice 缺省时取 default。 */
80
+ /** 字段在当前取值下是否显示。 */
81
+ export declare function isProviderFieldVisible(field: ProviderField, values: ProviderFormValues): boolean;
82
+ /** 从已存配置读出表单初值:只取声明字段的字符串值,字段缺省时取声明的 default。 */
48
83
  export declare function readProviderFormValues(form: ProviderForm, stored: JsonValue | undefined): Record<string, string>;
49
84
  /** 改一个字段并清空依赖它的远程选择字段。 */
50
85
  export declare function patchProviderFormValues(form: ProviderForm, values: ProviderFormValues, key: string, value: string): Record<string, string>;
@@ -40,15 +40,20 @@ interface PluginSettingsBase {
40
40
  id: string;
41
41
  title: string;
42
42
  description?: string;
43
+ /** 提供方可用的模型目录;账号已保存的模型优先于此初始目录。 */
44
+ models?: readonly {
45
+ id: string;
46
+ label?: string;
47
+ }[];
43
48
  }
44
- /** 存储提供方的连接配置:只声明字段,由宿主在插件设置页按平台渲染与保存。 */
49
+ /** 提供方的连接配置:只声明字段,由宿主在插件设置页按平台渲染与保存。 */
45
50
  export interface PluginProviderSettingsDefinition extends PluginSettingsBase {
46
- target: "sync" | "upload";
51
+ target: "sync" | "upload" | "tts" | "asr" | "images" | "video" | "publish";
47
52
  form: ProviderForm;
48
53
  component?: never;
49
54
  }
50
55
  export interface PluginComponentSettingsDefinition extends PluginSettingsBase {
51
- /** 提供方配置表单挂载到对应宿主设置;普通插件设置省略。 */
56
+ /** 特殊交互在插件页承载;普通插件设置省略。 */
52
57
  target?: "tts" | "asr" | "images" | "video" | "publish";
53
58
  component: ComponentType<PluginSettingsProps>;
54
59
  form?: never;