one-design-next 0.0.17 → 0.0.19
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/README.md +7 -28
- package/dist/_genui-types.d.ts +30 -9
- package/dist/_genui-types.js +47 -1
- package/dist/composer/index.js +2 -3
- package/dist/composer/segments.d.ts +4 -2
- package/dist/composer/segments.js +6 -3
- package/dist/composer/send-meta.d.ts +1 -1
- package/dist/composer/send-meta.js +3 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
通用业务控件 / 平台布局 / GenUI 对话组件 / AI Skill 工程化流水线
|
|
8
8
|
|
|
9
|
-
[](https://www.npmjs.com/package/one-design-next)
|
|
10
10
|
[](https://react.dev)
|
|
11
11
|
[](./LICENSE)
|
|
12
12
|
|
|
@@ -30,11 +30,10 @@ One Design Next 是腾讯 TAD / WXAD 团队维护的 React 组件库,提供 **
|
|
|
30
30
|
### 安装
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
|
|
34
|
-
npm install one-design-next --registry http://mirrors.tencent.com/npm/
|
|
33
|
+
npm install one-design-next
|
|
35
34
|
|
|
36
35
|
# 或使用 pnpm
|
|
37
|
-
pnpm add one-design-next
|
|
36
|
+
pnpm add one-design-next
|
|
38
37
|
```
|
|
39
38
|
|
|
40
39
|
### 使用
|
|
@@ -96,7 +95,7 @@ pnpm run docs:build
|
|
|
96
95
|
### 常用脚本
|
|
97
96
|
|
|
98
97
|
| 命令 | 说明 |
|
|
99
|
-
|
|
98
|
+
|:-----|:-----|·
|
|
100
99
|
| `pnpm run dev` | 启动本地开发文档站 |
|
|
101
100
|
| `pnpm run build` | 构建组件库(father + 样式) |
|
|
102
101
|
| `pnpm run docs:build` | 静态构建文档站(含 LLM 知识生成) |
|
|
@@ -178,11 +177,7 @@ bash skills/build.sh huxuan # 只构建互选
|
|
|
178
177
|
|
|
179
178
|
### 环境准备
|
|
180
179
|
|
|
181
|
-
|
|
182
|
-
npm config set registry http://mirrors.tencent.com/npm/
|
|
183
|
-
pnpm config set registry http://mirrors.tencent.com/npm/
|
|
184
|
-
# 在 ~/.npmrc 配置 mirrors 的 _authToken(发布权限)
|
|
185
|
-
```
|
|
180
|
+
在 `~/.npmrc` 中配置 npm 账号的 `_authToken`(需有 `one-design-next` 包的发布权限)。
|
|
186
181
|
|
|
187
182
|
### 发布流程
|
|
188
183
|
|
|
@@ -192,30 +187,14 @@ git checkout master && git pull origin master
|
|
|
192
187
|
# 更新 package.json 版本号后:
|
|
193
188
|
pnpm install
|
|
194
189
|
pnpm run build
|
|
195
|
-
npm publish
|
|
190
|
+
npm publish
|
|
196
191
|
```
|
|
197
192
|
|
|
198
193
|
提交信息遵循 [Conventional Commits](https://www.conventionalcommits.org/) 规范(通过 `commitlint` + `husky` 钩子校验)。
|
|
199
194
|
|
|
200
|
-
### 同步到 tad-universal-components
|
|
201
|
-
|
|
202
|
-
```bash
|
|
203
|
-
cd tad-universal-components
|
|
204
|
-
git checkout odn-update && git merge origin/main --no-edit
|
|
205
|
-
|
|
206
|
-
# 更新 packages/lib-od/package.json 中的 one-design-next 版本
|
|
207
|
-
pnpm install
|
|
208
|
-
git add packages/lib-od/package.json pnpm-lock.yaml
|
|
209
|
-
git commit -m "chore(od): update one-design-next to <版本号>"
|
|
210
|
-
git push origin odn-update
|
|
211
|
-
# 在工蜂创建 MR:odn-update → main
|
|
212
|
-
```
|
|
213
|
-
|
|
214
195
|
## 相关链接
|
|
215
196
|
|
|
216
|
-
-
|
|
217
|
-
- **tad-universal-components** — https://git.woa.com/tad-ag/tad-universal-components
|
|
218
|
-
- **npm 包** — `one-design-next` @ [mirrors.tencent.com/npm](http://mirrors.tencent.com/npm/)
|
|
197
|
+
- **npm 包** — [one-design-next](https://www.npmjs.com/package/one-design-next)
|
|
219
198
|
|
|
220
199
|
## 协议
|
|
221
200
|
|
package/dist/_genui-types.d.ts
CHANGED
|
@@ -64,12 +64,14 @@ export type InlineRefState = 'pending' | 'complete';
|
|
|
64
64
|
/**
|
|
65
65
|
* Composer 正文内 `/` 触发的内联引用(Invocation 组件数据契约)。
|
|
66
66
|
*
|
|
67
|
-
* 库只关心 UI
|
|
68
|
-
*
|
|
67
|
+
* 库只关心 UI 渲染必需字段;业务方自行扩展 `payload` 以携带参数、上下文等。
|
|
68
|
+
* 库**不约定 payload 内部结构**,发送时原样透传。
|
|
69
69
|
*/
|
|
70
70
|
export interface InvocationData {
|
|
71
71
|
/** chip 实例唯一 id(库内部 DOM 锚定、segments 去重用) */
|
|
72
72
|
id: string;
|
|
73
|
+
/** 业务侧资源唯一 id(来自 SkillItem.id,原样透传至 onSend segments) */
|
|
74
|
+
refId?: string;
|
|
73
75
|
/** 业务子类型('skill' / 'command' / 自定义);当前仅 'skill' 使用,预留扩展 */
|
|
74
76
|
kind: string;
|
|
75
77
|
/** 显示文字 */
|
|
@@ -78,12 +80,14 @@ export interface InvocationData {
|
|
|
78
80
|
icon?: string;
|
|
79
81
|
/** 视觉态。`active`(参数面板打开)由组件 prop 控制,不进 data。 */
|
|
80
82
|
state?: InlineRefState;
|
|
81
|
-
/**
|
|
83
|
+
/** 业务自定义任意字段:参数、上下文等,库不消费 */
|
|
82
84
|
payload?: Record<string, unknown>;
|
|
83
85
|
}
|
|
84
86
|
/** Composer 正文内 `@` 触发的内联引用(Mention 组件数据契约)。结构同 Invocation。 */
|
|
85
87
|
export interface MentionData {
|
|
86
88
|
id: string;
|
|
89
|
+
/** 业务侧资源唯一 id,原样透传至 onSend segments */
|
|
90
|
+
refId?: string;
|
|
87
91
|
kind: string;
|
|
88
92
|
label: string;
|
|
89
93
|
icon?: string;
|
|
@@ -97,6 +101,8 @@ export interface MentionData {
|
|
|
97
101
|
export interface ChipData {
|
|
98
102
|
/** chip 实例唯一 id(与 value marker 中的 id 对应) */
|
|
99
103
|
id: string;
|
|
104
|
+
/** 业务侧资源唯一 id,透传至 InvocationData / MentionData */
|
|
105
|
+
refId?: string;
|
|
100
106
|
label: string;
|
|
101
107
|
icon?: string;
|
|
102
108
|
/**
|
|
@@ -132,18 +138,33 @@ export interface SkillItem {
|
|
|
132
138
|
* 三种分支拆成命名 interface 导出,业务可直接 `import` 单一形态,
|
|
133
139
|
* 无需再写 `Extract<ComposerSegment, { type: 'xxx' }>`。
|
|
134
140
|
*/
|
|
141
|
+
/** Composer 文本片段携带的数据。 */
|
|
142
|
+
export interface TextData {
|
|
143
|
+
text: string;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Composer segment 的 type 字面量集合。
|
|
147
|
+
*
|
|
148
|
+
* 用 `as const` 对象 + 同名类型 alias 取代 TS `enum`:
|
|
149
|
+
* - 业务方可写 `seg.type === ComposerSegmentType.Invocation` 取代裸字符串
|
|
150
|
+
* - 底层仍是字符串字面量 union,自动收窄、JSON 兼容、tree-shake 友好
|
|
151
|
+
*/
|
|
152
|
+
export declare const ComposerSegmentType: {
|
|
153
|
+
readonly Text: "text";
|
|
154
|
+
readonly Invocation: "invocation";
|
|
155
|
+
readonly Mention: "mention";
|
|
156
|
+
};
|
|
157
|
+
export type ComposerSegmentType = (typeof ComposerSegmentType)[keyof typeof ComposerSegmentType];
|
|
135
158
|
export interface ComposerTextSegment {
|
|
136
|
-
type:
|
|
137
|
-
data:
|
|
138
|
-
text: string;
|
|
139
|
-
};
|
|
159
|
+
type: typeof ComposerSegmentType.Text;
|
|
160
|
+
data: TextData;
|
|
140
161
|
}
|
|
141
162
|
export interface ComposerInvocationSegment {
|
|
142
|
-
type:
|
|
163
|
+
type: typeof ComposerSegmentType.Invocation;
|
|
143
164
|
data: InvocationData;
|
|
144
165
|
}
|
|
145
166
|
export interface ComposerMentionSegment {
|
|
146
|
-
type:
|
|
167
|
+
type: typeof ComposerSegmentType.Mention;
|
|
147
168
|
data: MentionData;
|
|
148
169
|
}
|
|
149
170
|
export type ComposerSegment = ComposerTextSegment | ComposerInvocationSegment | ComposerMentionSegment;
|
package/dist/_genui-types.js
CHANGED
|
@@ -1 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 内联引用三态:
|
|
3
|
+
* - complete:默认稳态(无参数 / 参数已填)
|
|
4
|
+
* - pending:邀请补充参数(业务自定,不强制)
|
|
5
|
+
* - active:参数面板打开(最高优先级,由组件内部根据 `active` prop 控制)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Composer 正文内 `/` 触发的内联引用(Invocation 组件数据契约)。
|
|
10
|
+
*
|
|
11
|
+
* 库只关心 UI 渲染必需字段;业务方自行扩展 `payload` 以携带参数、上下文等。
|
|
12
|
+
* 库**不约定 payload 内部结构**,发送时原样透传。
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** Composer 正文内 `@` 触发的内联引用(Mention 组件数据契约)。结构同 Invocation。 */
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Composer 编辑器内 chip 实例数据(DOM host + Portal 渲染用)。
|
|
19
|
+
* 发送时经 `rawValueToSegments` 转为 `ComposerSegment` 的 invocation / mention。
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Composer 发送时的有序内容 IR(与编辑器内出现顺序一致)。
|
|
24
|
+
*
|
|
25
|
+
* 这是 `onSend` 的**主出口**:业务按此数组顺序自定义拼后端(可选用
|
|
26
|
+
* `segmentsToReadableText` 工具函数兜底拼成一句话)。
|
|
27
|
+
*
|
|
28
|
+
* 三种分支拆成命名 interface 导出,业务可直接 `import` 单一形态,
|
|
29
|
+
* 无需再写 `Extract<ComposerSegment, { type: 'xxx' }>`。
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/** Composer 文本片段携带的数据。 */
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Composer segment 的 type 字面量集合。
|
|
36
|
+
*
|
|
37
|
+
* 用 `as const` 对象 + 同名类型 alias 取代 TS `enum`:
|
|
38
|
+
* - 业务方可写 `seg.type === ComposerSegmentType.Invocation` 取代裸字符串
|
|
39
|
+
* - 底层仍是字符串字面量 union,自动收窄、JSON 兼容、tree-shake 友好
|
|
40
|
+
*/
|
|
41
|
+
export var ComposerSegmentType = {
|
|
42
|
+
Text: 'text',
|
|
43
|
+
Invocation: 'invocation',
|
|
44
|
+
Mention: 'mention'
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** `onSend(segments, meta?)` 第二参数:非正文的附加数据。 */
|
package/dist/composer/index.js
CHANGED
|
@@ -31,9 +31,8 @@ function createInvocationChipData(skill) {
|
|
|
31
31
|
icon: skill.icon,
|
|
32
32
|
kind: 'invocation',
|
|
33
33
|
state: skill.initialState,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
34
|
+
refId: skill.id,
|
|
35
|
+
payload: {}
|
|
37
36
|
};
|
|
38
37
|
}
|
|
39
38
|
var TOOL_BTN_ACTIVE = 'color-mix(in srgb, var(--odn-color-brand-6) 10%, transparent)';
|
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
* 一句话(默认 `[Skill: label]` / `[@label]`,与 ComposerMention 兼容)。
|
|
10
10
|
* - `segmentsHasContent`:是否含可见内容;库内 send 校验用,业务可复用。
|
|
11
11
|
*/
|
|
12
|
-
import type { ChipData, ComposerInvocationSegment, ComposerMentionSegment, ComposerSegment, ComposerTextSegment } from '../_genui-types';
|
|
13
|
-
|
|
12
|
+
import type { ChipData, ComposerInvocationSegment, ComposerMentionSegment, ComposerSegment, ComposerTextSegment, TextData } from '../_genui-types';
|
|
13
|
+
import { ComposerSegmentType } from '../_genui-types';
|
|
14
|
+
export type { ComposerInvocationSegment, ComposerMentionSegment, ComposerSegment, ComposerTextSegment, TextData, };
|
|
15
|
+
export { ComposerSegmentType };
|
|
14
16
|
export declare const isTextSegment: (s: ComposerSegment) => s is ComposerTextSegment;
|
|
15
17
|
export declare const isInvocationSegment: (s: ComposerSegment) => s is ComposerInvocationSegment;
|
|
16
18
|
export declare const isMentionSegment: (s: ComposerSegment) => s is ComposerMentionSegment;
|
|
@@ -10,8 +10,11 @@
|
|
|
10
10
|
* - `segmentsHasContent`:是否含可见内容;库内 send 校验用,业务可复用。
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import { ComposerSegmentType } from "../_genui-types";
|
|
13
14
|
import { chipToInvocationData, chipToMentionData } from "./send-meta";
|
|
14
15
|
import { forEachMarkerSegment } from "./utils";
|
|
16
|
+
export { ComposerSegmentType };
|
|
17
|
+
|
|
15
18
|
/* ────────────────────────────────────────────────────────────────────
|
|
16
19
|
* Type guards · 给业务方 filter / find 用,避免现场写 Extract<…>。
|
|
17
20
|
*
|
|
@@ -19,13 +22,13 @@ import { forEachMarkerSegment } from "./utils";
|
|
|
19
22
|
* ──────────────────────────────────────────────────────────────────── */
|
|
20
23
|
|
|
21
24
|
export var isTextSegment = function isTextSegment(s) {
|
|
22
|
-
return s.type ===
|
|
25
|
+
return s.type === ComposerSegmentType.Text;
|
|
23
26
|
};
|
|
24
27
|
export var isInvocationSegment = function isInvocationSegment(s) {
|
|
25
|
-
return s.type ===
|
|
28
|
+
return s.type === ComposerSegmentType.Invocation;
|
|
26
29
|
};
|
|
27
30
|
export var isMentionSegment = function isMentionSegment(s) {
|
|
28
|
-
return s.type ===
|
|
31
|
+
return s.type === ComposerSegmentType.Mention;
|
|
29
32
|
};
|
|
30
33
|
|
|
31
34
|
/** 从含零宽 marker 的 raw value + chip 列表构建有序 segments。 */
|
|
@@ -2,7 +2,7 @@ import type { ChipData, InvocationData, MentionData } from '../_genui-types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Chip → Invocation/Mention 派发。
|
|
4
4
|
*
|
|
5
|
-
* 库只搬运 UI 字段(id/kind/label/icon/state)与业务字段(payload),
|
|
5
|
+
* 库只搬运 UI 字段(id/refId/kind/label/icon/state)与业务字段(payload),
|
|
6
6
|
* 不对 payload 内容做任何假设。
|
|
7
7
|
*/
|
|
8
8
|
export declare function chipToInvocationData(chip: ChipData): InvocationData;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Chip → Invocation/Mention 派发。
|
|
3
3
|
*
|
|
4
|
-
* 库只搬运 UI 字段(id/kind/label/icon/state)与业务字段(payload),
|
|
4
|
+
* 库只搬运 UI 字段(id/refId/kind/label/icon/state)与业务字段(payload),
|
|
5
5
|
* 不对 payload 内容做任何假设。
|
|
6
6
|
*/
|
|
7
7
|
export function chipToInvocationData(chip) {
|
|
8
8
|
return {
|
|
9
9
|
id: chip.id,
|
|
10
|
+
refId: chip.refId,
|
|
10
11
|
kind: chip.kind === 'mention' || !chip.kind ? 'skill' : chip.kind,
|
|
11
12
|
label: chip.label,
|
|
12
13
|
icon: chip.icon,
|
|
@@ -18,6 +19,7 @@ export function chipToMentionData(chip) {
|
|
|
18
19
|
var _chip$kind;
|
|
19
20
|
return {
|
|
20
21
|
id: chip.id,
|
|
22
|
+
refId: chip.refId,
|
|
21
23
|
kind: (_chip$kind = chip.kind) !== null && _chip$kind !== void 0 ? _chip$kind : 'mention',
|
|
22
24
|
label: chip.label,
|
|
23
25
|
icon: chip.icon,
|
package/dist/index.d.ts
CHANGED
|
@@ -73,5 +73,6 @@ export { default as StreamText, type StreamTextProps, type TypographyOverrides }
|
|
|
73
73
|
export { default as Suggestions, type SuggestionsProps } from './suggestions';
|
|
74
74
|
export { default as UserBubble, type UserBubbleProps } from './user-bubble';
|
|
75
75
|
export { default as Welcome, type WelcomeProps } from './welcome';
|
|
76
|
-
export type { ToolCall, ToolStatus, Source, Attachment, PreviewTarget, PreviewTab, SendMeta, ComposerSegment, ComposerTextSegment, ComposerInvocationSegment, ComposerMentionSegment, InvocationData, MentionData, InlineRefState, SkillItem, AgentEvent, Conversation, MessageSnapshot, ChatMessage } from './_genui-types';
|
|
76
|
+
export type { ToolCall, ToolStatus, Source, Attachment, PreviewTarget, PreviewTab, SendMeta, ComposerSegment, ComposerTextSegment, ComposerInvocationSegment, ComposerMentionSegment, TextData, InvocationData, MentionData, InlineRefState, SkillItem, AgentEvent, Conversation, MessageSnapshot, ChatMessage } from './_genui-types';
|
|
77
|
+
export { ComposerSegmentType } from './_genui-types';
|
|
77
78
|
export { rawValueToSegments, segmentsToReadableText, segmentsHasContent, isTextSegment, isInvocationSegment, isMentionSegment, type SegmentsToReadableTextOptions, } from './composer/segments';
|
package/dist/index.js
CHANGED
|
@@ -81,4 +81,5 @@ export { default as Welcome } from "./welcome";
|
|
|
81
81
|
|
|
82
82
|
// GenUI shared modules
|
|
83
83
|
|
|
84
|
+
export { ComposerSegmentType } from "./_genui-types";
|
|
84
85
|
export { rawValueToSegments, segmentsToReadableText, segmentsHasContent, isTextSegment, isInvocationSegment, isMentionSegment } from "./composer/segments";
|