@xiongtao.xt/tau-plugins 0.12.0 → 0.14.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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # 更新记录
2
+
3
+ ## 0.14.0
4
+
5
+ - 移除 `PluginServices.tikz` 和 `context.services.tikz.compile`。TikZ 编译、字体与文档块由独立插件 tau.tikz 提供,宿主不再保留编译实现或转发入口。
6
+ - 插件作者如需 TikZ 绘图,应由自己的插件携带实现;其他宿主编译与转换服务保持不变。
7
+ - 保留 0.13.0 的 TTS、资源上传及其生命周期接口。
package/EDITOR.md CHANGED
@@ -93,7 +93,7 @@ export default definePlugin({
93
93
 
94
94
  ## 块会在哪里显示
95
95
 
96
- 块除了显示在桌面编辑器里,还会出现在移动端、浏览器扩展和用户发布的网页中,这些地方都直接使用你在 `elements.render` 中写的同一个组件,不需要另写入口。因此渲染代码要满足:
96
+ 块显示在桌面编辑器和用户发布的博客中,两处直接使用 `elements.render` 中的同一个组件,不需要另写入口。移动端与浏览器扩展不加载插件,遇到插件节点保留原数据并显示通用占位。因此渲染代码要满足:
97
97
 
98
98
  - 模块顶层和渲染组件能在浏览器中运行,不导入 Electron、Node 或 Tau 客户端内部路径。
99
99
  - 不依赖 `activate` 中才赋值的变量,也不调用 `context` 的存储、页面、服务等桌面能力。
package/SERVICES.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 编译与转换服务
2
2
 
3
- 需要在插件里编译 Tailwind、Typst、TikZ,转换 Markdown,或处理音视频时,可以使用这些服务。通过 `context.services` 调用,类型从 `@tau/plugins` 导入,需要 Tau 0.59.0 或更高版本。
3
+ 需要在插件里编译 Tailwind、Typst,转换 Markdown,或处理音视频时,可以使用这些服务。通过 `context.services` 调用,类型从 `@tau/plugins` 导入,需要 Tau 0.59.0 或更高版本。TikZ 编译属于独立绘图插件,不再提供宿主服务。
4
4
 
5
5
  所有服务都是异步方法,只处理传入数据并返回结果,不读写笔记、不选择或保存文件、不自动注入样式。
6
6
 
@@ -13,7 +13,6 @@
13
13
  | `markdown.deserialize(source, options?)` | Markdown 字符串 | `{ nodes: Descendant[], warnings }` |
14
14
  | `markdown.serialize(nodes, options?)` | `Descendant[]` | `{ markdown, warnings }` |
15
15
  | `markdown.render(source, options?)` | Markdown 字符串 | `{ html, css, warnings }` |
16
- | `tikz.compile(input, options?)` | `{ source }`,包含 `tikzpicture` 环境 | `{ svg }` |
17
16
  | `ffmpeg.probe(file, options?)` | `{ name, data: Blob }` | `{ format, streams }` |
18
17
  | `ffmpeg.run(input, options?)` | `{ files, args, outputs }` | `{ files, log }` |
19
18
 
@@ -99,18 +98,6 @@ const result = await context.services.markdown.serialize(nodes, {
99
98
 
100
99
  HTML 渲染不自动执行 TikZ、Typst、Mermaid 编译器;相关节点可能显示源码并返回 `DISPLAY_FALLBACK`,音视频可能显示链接。原始 HTML 和远程资源按客户端导出规则保留,输出不是经过净化的 HTML。`css` 是本次生成内容附带的样式,不包含完整 Tau 页面主题,也不打包图片附件。
101
100
 
102
- ## TikZ
103
-
104
- ```ts
105
- const { svg } = await context.services.tikz.compile({
106
- source: String.raw`\begin{tikzpicture}
107
- \draw (0,0) -- (1,1);
108
- \end{tikzpicture}`,
109
- });
110
- ```
111
-
112
- 不要添加 `documentclass` 或 `document` 环境。服务负责包装,返回包含字体样式的 SVG 字符串。这不是完整 LaTeX 文档编译器,不提供任意宏包安装。语法或宏包不支持时明确报错;单次最长 120 秒,可通过 signal 提前取消。
113
-
114
101
  ## FFmpeg
115
102
 
116
103
  `ServiceFile` 为 `{ name: string, data: Blob }`;文件名仅在任务内使用,不是客户端路径。输入输出名称不得重复,目录使用 `/`。文件整体经内存传输,适合可以放进内存的素材,不支持大文件流式处理。
package/TTS.md ADDED
@@ -0,0 +1,20 @@
1
+ # 语音提供方
2
+
3
+ 需要 SDK 0.13.0 和包含语音插件能力的 Tau 0.59.0 客户端。
4
+
5
+ 在activate中调用context.tts.register({id: context.pluginId, name, create})。create(config, modelId)同步创建任务实例,固定该账号配置和模型,不发送网络请求。每个插件可对应多个用户账号,不能用插件全局变量保存“当前API Key”。
6
+
7
+ | 方法或字段 | 职责 |
8
+ | -------------------------------------------------- | ----------------------------------------------------------------------------------- |
9
+ | getVoices(signal) | 返回id、name、type(system/cloned/custom)、可选description组成的音色数组 |
10
+ | synthesize({text,voiceId,options},signal) | 返回{audio:Uint8Array,mime:string};options仅含speed、volume、pitch |
11
+ | cloneVoice({file,requestedId?,name?},signal),可选 | 每次一个{name,mimeType,content}参考文件,返回实际创建的音色;不返回上传文件ID或void |
12
+ | textInstructions,可选 | 当前模型的合成文本规则;供宿主播客脚本使用,缺省为纯文本 |
13
+
14
+ 请求使用context.fetch并传入方法收到的signal。服务商超时用AbortSignal.any组合,不能覆盖取消信号;退避等待也须取消,不把AbortError当作可重试错误。
15
+
16
+ 配置通过settings.register的target:"tts"挂载。组件接收ttsConfig.instanceId、value、models和save(value,models),只保存当前账号,不自动选为默认,不覆盖同插件其他账号。模型项为{id,label?};用户可填写自定义模型。保存失败保留表单并显示错误,不另存一份凭据到context.storage。
17
+
18
+ 需要公开上传参考音频时调用context.upload.uploadRemote(file,{signal}),复用用户选定的远端上传配置。本地模式明确报错;MiniMax自有文件上传不需要图床。不要自行选择用户的上传插件、读取上传凭据或修改桶权限。
19
+
20
+ 主进程只转发数据和提供宿主能力。插件在主窗口渲染进程执行,不使用Node后台入口。宿主负责音频播放、合并和保存;插件不直接写笔记或文件。
package/UPLOAD.md CHANGED
@@ -2,16 +2,18 @@
2
2
 
3
3
  需要 SDK 0.12.0 和包含资源上传插件能力的 Tau 0.59.0 客户端。上传返回正文可直接引用的 HTTP(S) 地址;数据库和资源目录同步使用 SYNC.md 的另一套接口。
4
4
 
5
+ SDK 0.13.0 增加第三个signal参数与context.upload.uploadRemote(file,{signal})。提供方应将signal合并进context.fetch请求;调用方使用uploadRemote时,本地目标明确报错,不自动更换存储。signal取消会结束等待并通知提供方,不代表撤回已经上传的远端对象。
6
+
5
7
  在 activate 中注册提供方:
6
8
 
7
9
  ```tsx
8
10
  context.upload.register({
9
11
  id: context.pluginId,
10
12
  name: "我的资源存储",
11
- async upload(file, config) {
13
+ async upload(file, config, signal) {
12
14
  // 用 context.fetch 请求服务商,认证与路径由本次 config 决定。
13
15
  // file.name 已唯一命名,file.mimeType 是 MIME,file.content 为 Uint8Array。
14
- return uploadToStorage(context.fetch, file, config);
16
+ return uploadToStorage(context.fetch, file, config, signal);
15
17
  },
16
18
  });
17
19
  context.settings.register({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiongtao.xt/tau-plugins",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,6 +9,7 @@ import type { MarkdownCodec } from "../../markdown/src/index";
9
9
  import type { PluginSettings } from "./settings";
10
10
  import type { PluginSync } from "./sync";
11
11
  import type { PluginUpload } from "./upload";
12
+ import type { PluginTTS } from "./tts";
12
13
  import type { PluginSidebar } from "./sidebar";
13
14
  import type { PluginExcerpts, PluginMaterials } from "./excerpts";
14
15
  import type { PluginMCP } from "./mcp";
@@ -41,6 +42,7 @@ export interface PluginContext {
41
42
  readonly settings: PluginSettings;
42
43
  readonly sync: PluginSync;
43
44
  readonly upload: PluginUpload;
45
+ readonly tts: PluginTTS;
44
46
  readonly sidebar: PluginSidebar;
45
47
  readonly excerpts: PluginExcerpts;
46
48
  readonly materials: PluginMaterials;
@@ -1,5 +1,6 @@
1
1
  import type { PluginDefinition } from "./contract";
2
2
  export type * from "./upload";
3
+ export type * from "./tts";
3
4
  export type { JsonValue, Disposable, PluginStorage, PluginCommand, PluginContext, PluginInstance, PluginDefinition, } from "./contract";
4
5
  export type { PluginSettings, PluginSettingsDefinition, PluginSettingsProps, PluginSettingsHandle, } from "./settings";
5
6
  export * from "./editor";
@@ -74,13 +74,6 @@ export interface PluginServices {
74
74
  warnings: ServiceWarning[];
75
75
  }>;
76
76
  };
77
- tikz: {
78
- compile(input: {
79
- source: string;
80
- }, options?: ServiceOptions): Promise<{
81
- svg: string;
82
- }>;
83
- };
84
77
  ffmpeg: {
85
78
  probe(input: ServiceFile, options?: ServiceOptions): Promise<MediaInfo>;
86
79
  /** args 中用任务文件名引用输入和输出;不接受 shell 命令。 */
@@ -3,6 +3,18 @@ import type { Disposable, PluginContext } from "./index";
3
3
  import type { JsonValue } from "./json";
4
4
  export interface PluginSettingsProps {
5
5
  readonly context: PluginContext;
6
+ readonly ttsConfig?: {
7
+ readonly instanceId: string;
8
+ readonly value: JsonValue;
9
+ readonly models: readonly {
10
+ id: string;
11
+ label?: string;
12
+ }[];
13
+ save(value: JsonValue, models: readonly {
14
+ id: string;
15
+ label?: string;
16
+ }[]): Promise<void>;
17
+ };
6
18
  readonly uploadConfig?: {
7
19
  readonly value: JsonValue;
8
20
  save(value: JsonValue): Promise<void>;
@@ -16,8 +28,8 @@ export interface PluginSettingsDefinition {
16
28
  id: string;
17
29
  title: string;
18
30
  description?: string;
19
- /** 同步提供方的配置表单挂载到宿主同步设置。 */
20
- target?: "sync" | "upload";
31
+ /** 提供方配置表单挂载到对应宿主设置;普通插件设置省略。 */
32
+ target?: "sync" | "upload" | "tts";
21
33
  component: ComponentType<PluginSettingsProps>;
22
34
  }
23
35
  export interface PluginSettingsHandle extends Disposable {
@@ -25,6 +37,6 @@ export interface PluginSettingsHandle extends Disposable {
25
37
  open(): Promise<void>;
26
38
  }
27
39
  export interface PluginSettings {
28
- /** 分区随本次激活回收,保存使用 context.storage。 */
40
+ /** 分区随本次激活回收;提供方保存使用配置属性,普通设置使用 context.storage。 */
29
41
  register(definition: PluginSettingsDefinition): PluginSettingsHandle;
30
42
  }
@@ -0,0 +1,42 @@
1
+ import type { Disposable, JsonValue } from "./contract";
2
+ import type { UploadFile } from "./upload";
3
+ export interface TTSVoice {
4
+ id: string;
5
+ name: string;
6
+ type: "system" | "cloned" | "custom";
7
+ description?: string;
8
+ }
9
+ export interface TTSSynthesizeOptions {
10
+ speed?: number;
11
+ volume?: number;
12
+ pitch?: number;
13
+ }
14
+ export interface TTSSynthesizeRequest {
15
+ text: string;
16
+ voiceId: string;
17
+ options?: TTSSynthesizeOptions;
18
+ }
19
+ export interface TTSAudio {
20
+ audio: Uint8Array;
21
+ mime: string;
22
+ }
23
+ export interface TTSCloneRequest {
24
+ file: UploadFile;
25
+ requestedId?: string;
26
+ name?: string;
27
+ }
28
+ export interface TTSInstance {
29
+ readonly textInstructions?: string;
30
+ getVoices(signal: AbortSignal): Promise<TTSVoice[]>;
31
+ synthesize(request: TTSSynthesizeRequest, signal: AbortSignal): Promise<TTSAudio>;
32
+ cloneVoice?(request: TTSCloneRequest, signal: AbortSignal): Promise<TTSVoice>;
33
+ }
34
+ export interface TTSProviderDefinition {
35
+ id: string;
36
+ name: string;
37
+ /** 每次任务固定配置和模型,创建时不发网络请求。 */
38
+ create(config: JsonValue, modelId: string): TTSInstance;
39
+ }
40
+ export interface PluginTTS {
41
+ register(definition: TTSProviderDefinition): Disposable;
42
+ }
@@ -1,6 +1,6 @@
1
1
  import type { Disposable, JsonValue } from "./contract";
2
2
  export interface UploadFile {
3
- /** 宿主已完成压缩和唯一命名,插件只负责追加远端路径前缀。 */
3
+ /** 提供方收到宿主唯一命名后的文件;uploadRemote的调用者传原始文件名。 */
4
4
  name: string;
5
5
  mimeType: string;
6
6
  content: Uint8Array;
@@ -9,8 +9,12 @@ export interface UploadProviderDefinition {
9
9
  id: string;
10
10
  name: string;
11
11
  /** 返回可供正文直接引用的HTTP(S)地址,不返回临时签名URL。 */
12
- upload(file: UploadFile, config: JsonValue): Promise<string>;
12
+ upload(file: UploadFile, config: JsonValue, signal: AbortSignal): Promise<string>;
13
13
  }
14
14
  export interface PluginUpload {
15
15
  register(definition: UploadProviderDefinition): Disposable;
16
+ /** 使用用户当前远端配置;本地模式明确失败,不自动选择其他存储。 */
17
+ uploadRemote(file: UploadFile, options?: {
18
+ signal?: AbortSignal;
19
+ }): Promise<string>;
16
20
  }