@xiongtao.xt/tau-plugins 0.15.0 → 0.17.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # 更新记录
2
2
 
3
+ ## 0.17.0
4
+
5
+ - 新增通用行内源码 API:useInlineSource、insertInlineSource 和 InlineSourceBoundary,复用宿主 Slate 实例与浏览器行内边界处理。
6
+ - 行内源码更新和删除遵守只读、卸载/停驻、目标替换及编辑器提交守卫;不修改 useSourceBlock、EditorKit 或已有节点格式。
7
+ - 保留已有 TTS、上传、聊天、独立服务入口与 TikZ 服务移除边界;客户端版本不变。
8
+
9
+ ## 0.16.0
10
+
11
+ - 新增独立 `usePluginServices()`,由插件渲染运行时提供已有编译与转换服务;博客及无服务的宿主返回 undefined。
12
+ - 服务按当前窗口和工作区绑定取消与失效保护,静态编辑器组件无需调用 activate;原有 context.services 保持不变。
13
+ - 不修改 useSourceBlock、EditorKit、文档节点协议或编译接口;保留 TTS、上传、聊天工具展示及 TikZ 服务删除边界。
14
+
3
15
  ## 0.15.0
4
16
 
5
17
  - 新增 `context.chat.registerToolRenderer`,按本插件 MCP ID 与原始工具名异步登记 React 工具渲染器,激活成功后发布,停用、重载或切库时回收。
package/EDITOR.md CHANGED
@@ -157,6 +157,10 @@ function SourceView({ element, children }: { element: SourceElement; children: R
157
157
 
158
158
  ## 动态样式与静态导出
159
159
 
160
+ SDK 0.17.0 提供 `useInlineSource(element)`:返回 readOnly、可选 compiler、update(properties) 与 remove(),只读、停驻、卸载及旧目标回调不会写入文档。行内源码组件通过 `InlineSourceBoundary` 复用宿主的浏览器边界处理;菜单用 `insertInlineSource(editor, element)` 插入节点。行内输入弹层由插件通过公共 UI 组件承载,只读时只显示预览,不打开编辑器。
161
+
162
+ 静态导出也按 styleSources 编译节点字段并向导出 CSS 收集器提供样式;插件只负责把节点序列化为 HTML,宿主不维护具体节点类型的样式名单。
163
+
160
164
  若节点源码中包含动态 Tailwind 类名,在同一个扩展上声明字段:
161
165
 
162
166
  ```ts
package/SERVICES.md CHANGED
@@ -16,6 +16,12 @@
16
16
  | `ffmpeg.probe(file, options?)` | `{ name, data: Blob }` | `{ format, streams }` |
17
17
  | `ffmpeg.run(input, options?)` | `{ files, args, outputs }` | `{ files, log }` |
18
18
 
19
+ ## 在静态组件中获取服务
20
+
21
+ SDK 0.16.0 的 `usePluginServices()` 返回当前插件可用的同一组服务,类型为 `PluginServices | undefined`。服务由插件运行时提供,独立编辑窗口无需 activate;博客和未包裹的普通组件返回 undefined,组件应显示已保存结果或源码。它不属于源码块或 EditorKit,不要将服务存入模块全局变量。
22
+
23
+ 组件需用自己的 AbortSignal 取消过期或卸载的调用,宿主同时处理窗口与工作区失效。内容插件的启停按现有重启生效规则处理;写入启停意图不会提前拆掉当前窗口已生效的贡献。
24
+
19
25
  ## 取消与错误
20
26
 
21
27
  第二个参数均支持 `{ signal: AbortSignal }`。插件停用会自动取消本实例的任务,不必重复传入 `context.signal`。用户主动取消可使用单次任务的 `AbortController`。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiongtao.xt/tau-plugins",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -6,9 +6,11 @@ export type { PluginSettings, PluginSettingsDefinition, PluginSettingsProps, Plu
6
6
  export * from "./editor";
7
7
  export { SourceBlockEditor, useSourceBlock, useReportPreviewError, insertSourceBlock, sourceBlockParagraphBehavior, } from "./source-editor";
8
8
  export type { SourceBlockEditorProps, PluginRuntimeStyleCompiler } from "./source-editor";
9
+ export { useInlineSource, insertInlineSource, InlineSourceBoundary } from "./inline-source";
9
10
  export * from "./sidebar";
10
11
  export type * from "./excerpts";
11
12
  export type * from "./services";
13
+ export { usePluginServices } from "./service-access";
12
14
  export type { PluginSkill } from "./skills";
13
15
  export type { PluginMCP, PluginMCPDefinition, PluginMCPTool, PluginMCPTransport } from "./mcp";
14
16
  export type { PluginMCPToolResult } from "./mcp";
@@ -0,0 +1,17 @@
1
+ import type { ReactElement } from "react";
2
+ import type { Editor, Element } from "slate";
3
+ import type { PluginRuntimeStyleCompiler } from "./source-editor";
4
+ export interface InlineSourceRuntime {
5
+ useInlineSource(element: Element): {
6
+ readOnly: boolean;
7
+ compiler: PluginRuntimeStyleCompiler | undefined;
8
+ update(properties: Record<string, unknown>): void;
9
+ remove(): void;
10
+ };
11
+ insertInlineSource(editor: Editor, element: Element): void;
12
+ InlineSourceBoundary(): ReactElement;
13
+ }
14
+ export declare function configureInlineSource(value: InlineSourceRuntime): void;
15
+ export declare const useInlineSource: InlineSourceRuntime["useInlineSource"];
16
+ export declare const insertInlineSource: InlineSourceRuntime["insertInlineSource"];
17
+ export declare const InlineSourceBoundary: InlineSourceRuntime["InlineSourceBoundary"];
@@ -0,0 +1,7 @@
1
+ import type { PluginServices } from "./services";
2
+ declare let useServices: () => PluginServices | undefined;
3
+ /** 宿主绑定 React 上下文,作者只消费 usePluginServices。 */
4
+ export declare function configurePluginServiceAccess(read: typeof useServices): void;
5
+ /** 当前插件渲染作用域的服务;博客和无界面宿主不提供服务。 */
6
+ export declare function usePluginServices(): PluginServices | undefined;
7
+ export {};