@farris/x-ui 0.2.2 → 0.2.3
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/bubble/src/composition/use-widget-content.d.ts +9 -25
- package/common/index.d.ts +1 -0
- package/common/src/use-toolicon.d.ts +5 -0
- package/farris.x-ui.esm.js +2310 -2217
- package/farris.x-ui.umd.cjs +40 -38
- package/index.css +1 -1
- package/package.json +1 -1
|
@@ -6,48 +6,32 @@
|
|
|
6
6
|
* 主要处理流式渲染场景下文本被截断的情况,支持识别完整和不完整的 widget 结构。
|
|
7
7
|
*
|
|
8
8
|
* @支持格式
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* ```
|
|
14
|
-
* import { formatDisplayText, parseAssistantWidget, getWidgetImplOptions, isWidgetBlock } from './use-widget-content';
|
|
15
|
-
*
|
|
16
|
-
* // 1. 分割含 widget 的文本为多个部分
|
|
17
|
-
* const parts = formatDisplayText('Hello ``` assistant-widget {...} ``` World');
|
|
18
|
-
*
|
|
19
|
-
* // 2. 判断文本是否为 widget 代码块
|
|
20
|
-
* const isWidget = isWidgetBlock('``` assistant-widget {...} ```'); // true
|
|
21
|
-
*
|
|
22
|
-
* // 3. 解析 widget JSON 数据
|
|
23
|
-
* const widgetData = parseAssistantWidget('``` assistant-widget\n{...}\n```');
|
|
24
|
-
*
|
|
25
|
-
* // 4. 获取 widget 实现选项
|
|
26
|
-
* const options = getWidgetImplOptions('``` assistant-widget\n{"renderer":{"widgetImplOptions":{...}}}\n```');
|
|
27
|
-
* ```
|
|
9
|
+
* - 标准:``` assistant-widget {...} ```
|
|
10
|
+
* - 紧凑:```assistant-widget{...}```(围栏 / 语言标 / 正文 / 闭围栏之间空白均可选)
|
|
11
|
+
* - 换行:```\nassistant-widget\n{...}\n```
|
|
12
|
+
* - 内联后缀:``` assistant-widget {...}```后续正文(闭围栏后同段仍有文字,如业务 JSON 样例)
|
|
13
|
+
* - 流式前缀:``` / ```assistant / ```assistant-widget(未闭合)
|
|
28
14
|
*
|
|
29
15
|
* @module
|
|
30
16
|
* - `formatDisplayText`: 将含 widget 的文本分割为数组
|
|
31
17
|
* - `isWidgetBlock`: 判断文本是否为完整/不完整的 widget 代码块
|
|
18
|
+
* - `isWidgetBlockComplete`: 判断 widget 是否已闭合
|
|
32
19
|
* - `parseAssistantWidget`: 解析 widget 代码块为 JSON 对象
|
|
33
20
|
* - `getWidgetImplOptions`: 从 widget 数据提取 renderer.widgetImplOptions
|
|
34
21
|
*/
|
|
35
22
|
/**
|
|
36
23
|
* 判断文本是否为完整的 widget 代码块
|
|
37
|
-
* 用于区分流式过程中的 pending / complete 状态:单纯 `endsWith('```')` 会把
|
|
38
|
-
* 仅有一个开围栏 `` ``` `` 的中间态误判为完整 widget。
|
|
39
24
|
*/
|
|
40
25
|
export declare function isWidgetBlockComplete(text: string): boolean;
|
|
41
26
|
/**
|
|
42
|
-
* 判断文本是否为 widget
|
|
43
|
-
* 支持标准格式、不完整格式(流式渲染中途被截断),以及流式起步时仅有围栏前缀的情况
|
|
27
|
+
* 判断文本是否为 widget 代码块(完整 / 未闭合 / 流式前缀)
|
|
44
28
|
*/
|
|
45
29
|
export declare function isWidgetBlock(text: string): boolean;
|
|
46
30
|
/**
|
|
47
31
|
* 解析 displayText,将包含 assistant-widget 代码块的内容分割成多个部分
|
|
48
|
-
* 支持完整和不完整的 widget 结构
|
|
49
|
-
* 支持 ``` 后紧跟换行符 + 空格 + widget类型 的格式
|
|
50
32
|
*/
|
|
51
33
|
export declare function formatDisplayText(displayText: string): string[];
|
|
34
|
+
/** 解析 assistant-widget 内容 */
|
|
52
35
|
export declare function parseAssistantWidget(input: string): any;
|
|
36
|
+
/** 获取 Widget 实现选项 */
|
|
53
37
|
export declare function getWidgetImplOptions(input: string): any;
|
package/common/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export * from '../../src/use-streaming-output';
|
|
|
5
5
|
export * from '../../src/use-sequential-streaming';
|
|
6
6
|
export * from '../../src/use-timer';
|
|
7
7
|
export * from '../../src/types';
|
|
8
|
+
export * from '../../src/use-toolicon';
|
|
8
9
|
export { default as overflowTooltipDirective } from '../../src/overflow-tooltip.directive';
|