@unif/react-native-chat-markdown 0.1.1 → 0.1.2
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/lib/commonjs/index.js +41 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/markdown-bubble/MarkdownBubble.js +90 -0
- package/lib/commonjs/markdown-bubble/MarkdownBubble.js.map +1 -0
- package/lib/commonjs/markdown-bubble/index.md +61 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/streaming-bubble/StreamingBubble.js +64 -0
- package/lib/commonjs/streaming-bubble/StreamingBubble.js.map +1 -0
- package/lib/commonjs/streaming-bubble/index.md +47 -0
- package/lib/commonjs/think-block/ThinkBlock.js +92 -0
- package/lib/commonjs/think-block/ThinkBlock.js.map +1 -0
- package/lib/commonjs/think-block/index.md +57 -0
- package/lib/commonjs/utils/thinkTagParser.js +42 -0
- package/lib/commonjs/utils/thinkTagParser.js.map +1 -0
- package/lib/module/index.js +12 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/markdown-bubble/MarkdownBubble.js +84 -0
- package/lib/module/markdown-bubble/MarkdownBubble.js.map +1 -0
- package/lib/module/markdown-bubble/index.md +61 -0
- package/lib/module/package.json +1 -0
- package/lib/module/streaming-bubble/StreamingBubble.js +59 -0
- package/lib/module/streaming-bubble/StreamingBubble.js.map +1 -0
- package/lib/module/streaming-bubble/index.md +47 -0
- package/lib/module/think-block/ThinkBlock.js +87 -0
- package/lib/module/think-block/ThinkBlock.js.map +1 -0
- package/lib/module/think-block/index.md +57 -0
- package/lib/module/utils/thinkTagParser.js +37 -0
- package/lib/module/utils/thinkTagParser.js.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +13 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/markdown-bubble/MarkdownBubble.d.ts +15 -0
- package/lib/typescript/commonjs/markdown-bubble/MarkdownBubble.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/streaming-bubble/StreamingBubble.d.ts +16 -0
- package/lib/typescript/commonjs/streaming-bubble/StreamingBubble.d.ts.map +1 -0
- package/lib/typescript/commonjs/think-block/ThinkBlock.d.ts +24 -0
- package/lib/typescript/commonjs/think-block/ThinkBlock.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/thinkTagParser.d.ts +20 -0
- package/lib/typescript/commonjs/utils/thinkTagParser.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +13 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/markdown-bubble/MarkdownBubble.d.ts +15 -0
- package/lib/typescript/module/markdown-bubble/MarkdownBubble.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/streaming-bubble/StreamingBubble.d.ts +16 -0
- package/lib/typescript/module/streaming-bubble/StreamingBubble.d.ts.map +1 -0
- package/lib/typescript/module/think-block/ThinkBlock.d.ts +24 -0
- package/lib/typescript/module/think-block/ThinkBlock.d.ts.map +1 -0
- package/lib/typescript/module/utils/thinkTagParser.d.ts +20 -0
- package/lib/typescript/module/utils/thinkTagParser.d.ts.map +1 -0
- package/package.json +41 -10
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: MarkdownBubble Markdown 渲染
|
|
3
|
+
nav:
|
|
4
|
+
title: 组件
|
|
5
|
+
path: /components
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# MarkdownBubble Markdown 渲染
|
|
9
|
+
|
|
10
|
+
完整的 Markdown 渲染气泡,自动解析 `<think>` 标签并渲染为 ThinkBlock。
|
|
11
|
+
|
|
12
|
+
## 何时使用
|
|
13
|
+
|
|
14
|
+
- AI 回复完成后(status === 'success')渲染完整内容
|
|
15
|
+
- 内容包含 Markdown 格式(标题、代码、链接、列表等)
|
|
16
|
+
- 内容包含 `<think>` 标签需要折叠展示
|
|
17
|
+
|
|
18
|
+
## 代码示例
|
|
19
|
+
|
|
20
|
+
### 基本用法
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { MarkdownBubble } from '@unif/react-native-chat-markdown';
|
|
24
|
+
|
|
25
|
+
<MarkdownBubble text="**加粗** 和 `代码` 以及[链接](https://example.com)" />
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 包含思考内容
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
<MarkdownBubble
|
|
32
|
+
text="<think>分析用户意图...</think>根据您的需求,推荐以下方案..."
|
|
33
|
+
/>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 自定义 Markdown 样式
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
<MarkdownBubble
|
|
40
|
+
text={messageText}
|
|
41
|
+
markdownStyles={{
|
|
42
|
+
body: { fontSize: 16, color: '#333' },
|
|
43
|
+
code_inline: { backgroundColor: '#F0F0F0' },
|
|
44
|
+
}}
|
|
45
|
+
/>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
### MarkdownBubbleProps
|
|
51
|
+
|
|
52
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
53
|
+
|------|------|------|--------|
|
|
54
|
+
| text | Markdown 文本 | `string` | - |
|
|
55
|
+
| markdownStyles | 覆盖默认 Markdown 样式 | `Record<string, unknown>` | 内置样式 |
|
|
56
|
+
| style | 容器样式 | `ViewStyle` | - |
|
|
57
|
+
| testID | 测试标识 | `string` | `'markdown-bubble'` |
|
|
58
|
+
|
|
59
|
+
### 依赖
|
|
60
|
+
|
|
61
|
+
- `@ronradtke/react-native-markdown-display` — Markdown 渲染引擎
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* StreamingBubble — 流式文本气泡
|
|
5
|
+
* 显示正在流入的文本 + 呼吸动画光标
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React, { useEffect, useRef } from 'react';
|
|
9
|
+
import { View, Text, Animated, StyleSheet } from 'react-native';
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
const StreamingBubble = ({
|
|
12
|
+
text,
|
|
13
|
+
cursorColor = '#1677FF',
|
|
14
|
+
cursorChar = '▌',
|
|
15
|
+
style,
|
|
16
|
+
testID = 'streaming-bubble'
|
|
17
|
+
}) => {
|
|
18
|
+
const opacity = useRef(new Animated.Value(1)).current;
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const animation = Animated.loop(Animated.sequence([Animated.timing(opacity, {
|
|
21
|
+
toValue: 0,
|
|
22
|
+
duration: 400,
|
|
23
|
+
useNativeDriver: true
|
|
24
|
+
}), Animated.timing(opacity, {
|
|
25
|
+
toValue: 1,
|
|
26
|
+
duration: 400,
|
|
27
|
+
useNativeDriver: true
|
|
28
|
+
})]));
|
|
29
|
+
animation.start();
|
|
30
|
+
return () => animation.stop();
|
|
31
|
+
}, [opacity]);
|
|
32
|
+
return /*#__PURE__*/_jsx(View, {
|
|
33
|
+
style: [defaultStyles.container, style],
|
|
34
|
+
testID: testID,
|
|
35
|
+
children: /*#__PURE__*/_jsxs(Text, {
|
|
36
|
+
style: defaultStyles.text,
|
|
37
|
+
children: [text, /*#__PURE__*/_jsx(Animated.Text, {
|
|
38
|
+
style: [{
|
|
39
|
+
color: cursorColor
|
|
40
|
+
}, {
|
|
41
|
+
opacity
|
|
42
|
+
}],
|
|
43
|
+
children: cursorChar
|
|
44
|
+
})]
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
const defaultStyles = StyleSheet.create({
|
|
49
|
+
container: {
|
|
50
|
+
paddingVertical: 4
|
|
51
|
+
},
|
|
52
|
+
text: {
|
|
53
|
+
fontSize: 15,
|
|
54
|
+
color: '#1F2937',
|
|
55
|
+
lineHeight: 22
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
export default /*#__PURE__*/React.memo(StreamingBubble);
|
|
59
|
+
//# sourceMappingURL=StreamingBubble.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useEffect","useRef","View","Text","Animated","StyleSheet","jsx","_jsx","jsxs","_jsxs","StreamingBubble","text","cursorColor","cursorChar","style","testID","opacity","Value","current","animation","loop","sequence","timing","toValue","duration","useNativeDriver","start","stop","defaultStyles","container","children","color","create","paddingVertical","fontSize","lineHeight","memo"],"sourceRoot":"../../../src","sources":["streaming-bubble/StreamingBubble.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,IAAGC,SAAS,EAAEC,MAAM,QAAO,OAAO;AAC9C,SACEC,IAAI,EACJC,IAAI,EACJC,QAAQ,EACRC,UAAU,QAEL,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAUtB,MAAMC,eAA+C,GAAGA,CAAC;EACvDC,IAAI;EACJC,WAAW,GAAG,SAAS;EACvBC,UAAU,GAAG,GAAG;EAChBC,KAAK;EACLC,MAAM,GAAG;AACX,CAAC,KAAK;EACJ,MAAMC,OAAO,GAAGf,MAAM,CAAC,IAAIG,QAAQ,CAACa,KAAK,CAAC,CAAC,CAAC,CAAC,CAACC,OAAO;EAErDlB,SAAS,CAAC,MAAM;IACd,MAAMmB,SAAS,GAAGf,QAAQ,CAACgB,IAAI,CAC7BhB,QAAQ,CAACiB,QAAQ,CAAC,CAChBjB,QAAQ,CAACkB,MAAM,CAACN,OAAO,EAAE;MACvBO,OAAO,EAAE,CAAC;MACVC,QAAQ,EAAE,GAAG;MACbC,eAAe,EAAE;IACnB,CAAC,CAAC,EACFrB,QAAQ,CAACkB,MAAM,CAACN,OAAO,EAAE;MACvBO,OAAO,EAAE,CAAC;MACVC,QAAQ,EAAE,GAAG;MACbC,eAAe,EAAE;IACnB,CAAC,CAAC,CACH,CACH,CAAC;IACDN,SAAS,CAACO,KAAK,CAAC,CAAC;IACjB,OAAO,MAAMP,SAAS,CAACQ,IAAI,CAAC,CAAC;EAC/B,CAAC,EAAE,CAACX,OAAO,CAAC,CAAC;EAEb,oBACET,IAAA,CAACL,IAAI;IAACY,KAAK,EAAE,CAACc,aAAa,CAACC,SAAS,EAAEf,KAAK,CAAE;IAACC,MAAM,EAAEA,MAAO;IAAAe,QAAA,eAC5DrB,KAAA,CAACN,IAAI;MAACW,KAAK,EAAEc,aAAa,CAACjB,IAAK;MAAAmB,QAAA,GAC7BnB,IAAI,eACLJ,IAAA,CAACH,QAAQ,CAACD,IAAI;QAACW,KAAK,EAAE,CAAC;UAACiB,KAAK,EAAEnB;QAAW,CAAC,EAAE;UAACI;QAAO,CAAC,CAAE;QAAAc,QAAA,EACrDjB;MAAU,CACE,CAAC;IAAA,CACZ;EAAC,CACH,CAAC;AAEX,CAAC;AAED,MAAMe,aAAa,GAAGvB,UAAU,CAAC2B,MAAM,CAAC;EACtCH,SAAS,EAAE;IACTI,eAAe,EAAE;EACnB,CAAC;EACDtB,IAAI,EAAE;IACJuB,QAAQ,EAAE,EAAE;IACZH,KAAK,EAAE,SAAS;IAChBI,UAAU,EAAE;EACd;AACF,CAAC,CAAC;AAEF,4BAAepC,KAAK,CAACqC,IAAI,CAAC1B,eAAe,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: StreamingBubble 流式气泡
|
|
3
|
+
nav:
|
|
4
|
+
title: 组件
|
|
5
|
+
path: /components
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# StreamingBubble 流式气泡
|
|
9
|
+
|
|
10
|
+
展示正在流入的文本内容,附带闪烁光标动画。
|
|
11
|
+
|
|
12
|
+
## 何时使用
|
|
13
|
+
|
|
14
|
+
- AI 正在流式输出回复时(status === 'updating')
|
|
15
|
+
- 需要视觉上表示内容仍在生成中
|
|
16
|
+
|
|
17
|
+
## 代码示例
|
|
18
|
+
|
|
19
|
+
### 基本用法
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { StreamingBubble } from '@unif/react-native-chat-markdown';
|
|
23
|
+
|
|
24
|
+
<StreamingBubble text="正在生成的文本内容..." />
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 自定义光标
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
<StreamingBubble
|
|
31
|
+
text={streamingText}
|
|
32
|
+
cursorColor="#FF6B00"
|
|
33
|
+
cursorChar="●"
|
|
34
|
+
/>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## API
|
|
38
|
+
|
|
39
|
+
### StreamingBubbleProps
|
|
40
|
+
|
|
41
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
42
|
+
|------|------|------|--------|
|
|
43
|
+
| text | 当前流式文本 | `string` | - |
|
|
44
|
+
| cursorColor | 光标颜色 | `string` | `'#1677FF'` |
|
|
45
|
+
| cursorChar | 光标字符 | `string` | `'▌'` |
|
|
46
|
+
| style | 容器样式 | `ViewStyle` | - |
|
|
47
|
+
| testID | 测试标识 | `string` | `'streaming-bubble'` |
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ThinkBlock — 思考折叠块
|
|
5
|
+
* 卡片式,圆角 12px
|
|
6
|
+
* 标题:🧠 已深度思考(展开) ▾
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import React, { useState } from 'react';
|
|
10
|
+
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
const ThinkBlock = ({
|
|
13
|
+
content,
|
|
14
|
+
defaultExpanded = false,
|
|
15
|
+
label = '深度思考',
|
|
16
|
+
style,
|
|
17
|
+
styles: semanticStyles,
|
|
18
|
+
testID = 'think-block'
|
|
19
|
+
}) => {
|
|
20
|
+
const [expanded, setExpanded] = useState(defaultExpanded);
|
|
21
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
22
|
+
style: [defaultStyles.container, semanticStyles?.root, style],
|
|
23
|
+
children: [/*#__PURE__*/_jsxs(TouchableOpacity, {
|
|
24
|
+
style: [defaultStyles.header, semanticStyles?.header],
|
|
25
|
+
onPress: () => setExpanded(!expanded),
|
|
26
|
+
activeOpacity: 0.7,
|
|
27
|
+
testID: `${testID}-toggle`,
|
|
28
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
29
|
+
style: defaultStyles.titleRow,
|
|
30
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
31
|
+
style: defaultStyles.brainIcon,
|
|
32
|
+
children: "\uD83E\uDDE0"
|
|
33
|
+
}), /*#__PURE__*/_jsxs(Text, {
|
|
34
|
+
style: [defaultStyles.label, semanticStyles?.label],
|
|
35
|
+
children: ["\u5DF2", label, expanded ? '(展开)' : '(收起)']
|
|
36
|
+
})]
|
|
37
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
38
|
+
style: defaultStyles.chevron,
|
|
39
|
+
children: expanded ? '▲' : '▼'
|
|
40
|
+
})]
|
|
41
|
+
}), expanded && /*#__PURE__*/_jsx(Text, {
|
|
42
|
+
style: [defaultStyles.content, semanticStyles?.content],
|
|
43
|
+
testID: `${testID}-content`,
|
|
44
|
+
children: content
|
|
45
|
+
})]
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
const defaultStyles = StyleSheet.create({
|
|
49
|
+
container: {
|
|
50
|
+
backgroundColor: '#F9FAFB',
|
|
51
|
+
borderRadius: 12,
|
|
52
|
+
marginBottom: 8,
|
|
53
|
+
overflow: 'hidden'
|
|
54
|
+
},
|
|
55
|
+
header: {
|
|
56
|
+
flexDirection: 'row',
|
|
57
|
+
alignItems: 'center',
|
|
58
|
+
justifyContent: 'space-between',
|
|
59
|
+
paddingHorizontal: 14,
|
|
60
|
+
paddingVertical: 10
|
|
61
|
+
},
|
|
62
|
+
titleRow: {
|
|
63
|
+
flexDirection: 'row',
|
|
64
|
+
alignItems: 'center'
|
|
65
|
+
},
|
|
66
|
+
brainIcon: {
|
|
67
|
+
fontSize: 14
|
|
68
|
+
},
|
|
69
|
+
label: {
|
|
70
|
+
marginLeft: 6,
|
|
71
|
+
fontSize: 12,
|
|
72
|
+
color: '#6B7280'
|
|
73
|
+
},
|
|
74
|
+
chevron: {
|
|
75
|
+
fontSize: 10,
|
|
76
|
+
color: '#6B7280'
|
|
77
|
+
},
|
|
78
|
+
content: {
|
|
79
|
+
fontSize: 12,
|
|
80
|
+
color: '#6B7280',
|
|
81
|
+
lineHeight: 20,
|
|
82
|
+
paddingHorizontal: 14,
|
|
83
|
+
paddingBottom: 12
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
export default /*#__PURE__*/React.memo(ThinkBlock);
|
|
87
|
+
//# sourceMappingURL=ThinkBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useState","View","Text","StyleSheet","TouchableOpacity","jsx","_jsx","jsxs","_jsxs","ThinkBlock","content","defaultExpanded","label","style","styles","semanticStyles","testID","expanded","setExpanded","defaultStyles","container","root","children","header","onPress","activeOpacity","titleRow","brainIcon","chevron","create","backgroundColor","borderRadius","marginBottom","overflow","flexDirection","alignItems","justifyContent","paddingHorizontal","paddingVertical","fontSize","marginLeft","color","lineHeight","paddingBottom","memo"],"sourceRoot":"../../../src","sources":["think-block/ThinkBlock.tsx"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ThinkBlock 思考折叠块
|
|
3
|
+
nav:
|
|
4
|
+
title: 组件
|
|
5
|
+
path: /components
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# ThinkBlock 思考折叠块
|
|
9
|
+
|
|
10
|
+
展示 AI 的思考过程,可折叠/展开。
|
|
11
|
+
|
|
12
|
+
## 何时使用
|
|
13
|
+
|
|
14
|
+
- AI 回复中包含 `<think>` 标签的思考内容
|
|
15
|
+
- 需要可折叠展示推理过程(如 DeepSeek 的 reasoning_content)
|
|
16
|
+
|
|
17
|
+
## 代码示例
|
|
18
|
+
|
|
19
|
+
### 基本用法
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { ThinkBlock } from '@unif/react-native-chat-markdown';
|
|
23
|
+
|
|
24
|
+
<ThinkBlock content="用户询问的是账户余额,需要调用查询接口..." />
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 默认展开
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
<ThinkBlock
|
|
31
|
+
content="分析用户意图..."
|
|
32
|
+
defaultExpanded={true}
|
|
33
|
+
label="思考过程"
|
|
34
|
+
/>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## API
|
|
38
|
+
|
|
39
|
+
### ThinkBlockProps
|
|
40
|
+
|
|
41
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
42
|
+
|------|------|------|--------|
|
|
43
|
+
| content | 思考内容 | `string` | - |
|
|
44
|
+
| defaultExpanded | 默认展开 | `boolean` | `false` |
|
|
45
|
+
| label | 标题文字 | `string` | `'深度思考'` |
|
|
46
|
+
| style | 容器样式 | `ViewStyle` | - |
|
|
47
|
+
| styles | 语义样式 | `Partial<ThinkBlockSemanticStyles>` | - |
|
|
48
|
+
| testID | 测试标识 | `string` | `'think-block'` |
|
|
49
|
+
|
|
50
|
+
### ThinkBlockSemanticStyles
|
|
51
|
+
|
|
52
|
+
| 属性 | 说明 | 类型 |
|
|
53
|
+
|------|------|------|
|
|
54
|
+
| root | 外层容器 | `ViewStyle` |
|
|
55
|
+
| header | 标题栏 | `ViewStyle` |
|
|
56
|
+
| label | 标题文字 | `TextStyle` |
|
|
57
|
+
| content | 内容文字 | `TextStyle` |
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* <think> 标签解析器
|
|
5
|
+
* 将文本中的 <think>...</think> 提取出来,分离为普通内容和思考内容
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const THINK_REGEX = /<think>([\s\S]*?)<\/think>/g;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 解析文本中的 <think> 标签
|
|
12
|
+
* 支持多个 <think> 块,返回分离后的正文和思考内容
|
|
13
|
+
*/
|
|
14
|
+
export function parseThinkTags(text) {
|
|
15
|
+
const thinks = [];
|
|
16
|
+
const body = text.replace(THINK_REGEX, (_match, content) => {
|
|
17
|
+
const trimmed = content.trim();
|
|
18
|
+
if (trimmed) {
|
|
19
|
+
thinks.push(trimmed);
|
|
20
|
+
}
|
|
21
|
+
return '';
|
|
22
|
+
}).trim();
|
|
23
|
+
return {
|
|
24
|
+
body,
|
|
25
|
+
thinks
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 检查文本中是否包含未闭合的 <think> 标签(流式场景)
|
|
31
|
+
*/
|
|
32
|
+
export function hasUnclosedThink(text) {
|
|
33
|
+
const opens = (text.match(/<think>/g) || []).length;
|
|
34
|
+
const closes = (text.match(/<\/think>/g) || []).length;
|
|
35
|
+
return opens > closes;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=thinkTagParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["THINK_REGEX","parseThinkTags","text","thinks","body","replace","_match","content","trimmed","trim","push","hasUnclosedThink","opens","match","length","closes"],"sourceRoot":"../../../src","sources":["utils/thinkTagParser.ts"],"mappings":";;AAAA;AACA;AACA;AACA;;AASA,MAAMA,WAAW,GAAG,6BAA6B;;AAEjD;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,IAAY,EAAiB;EAC1D,MAAMC,MAAgB,GAAG,EAAE;EAC3B,MAAMC,IAAI,GAAGF,IAAI,CACdG,OAAO,CAACL,WAAW,EAAE,CAACM,MAAM,EAAEC,OAAe,KAAK;IACjD,MAAMC,OAAO,GAAGD,OAAO,CAACE,IAAI,CAAC,CAAC;IAC9B,IAAID,OAAO,EAAE;MACXL,MAAM,CAACO,IAAI,CAACF,OAAO,CAAC;IACtB;IACA,OAAO,EAAE;EACX,CAAC,CAAC,CACDC,IAAI,CAAC,CAAC;EAET,OAAO;IAACL,IAAI;IAAED;EAAM,CAAC;AACvB;;AAEA;AACA;AACA;AACA,OAAO,SAASQ,gBAAgBA,CAACT,IAAY,EAAW;EACtD,MAAMU,KAAK,GAAG,CAACV,IAAI,CAACW,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,EAAEC,MAAM;EACnD,MAAMC,MAAM,GAAG,CAACb,IAAI,CAACW,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,EAAEC,MAAM;EACtD,OAAOF,KAAK,GAAGG,MAAM;AACvB","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @unif/react-native-chat-markdown
|
|
3
|
+
* Markdown 渲染、ThinkBlock、流式气泡
|
|
4
|
+
*/
|
|
5
|
+
export { default as ThinkBlock } from './think-block/ThinkBlock';
|
|
6
|
+
export type { ThinkBlockProps, ThinkBlockSemanticStyles } from './think-block/ThinkBlock';
|
|
7
|
+
export { default as StreamingBubble } from './streaming-bubble/StreamingBubble';
|
|
8
|
+
export type { StreamingBubbleProps } from './streaming-bubble/StreamingBubble';
|
|
9
|
+
export { default as MarkdownBubble } from './markdown-bubble/MarkdownBubble';
|
|
10
|
+
export type { MarkdownBubbleProps } from './markdown-bubble/MarkdownBubble';
|
|
11
|
+
export { parseThinkTags, hasUnclosedThink } from './utils/thinkTagParser';
|
|
12
|
+
export type { ParsedContent } from './utils/thinkTagParser';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,0BAA0B,CAAC;AAC/D,YAAY,EAAC,eAAe,EAAE,wBAAwB,EAAC,MAAM,0BAA0B,CAAC;AAExF,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,oCAAoC,CAAC;AAC9E,YAAY,EAAC,oBAAoB,EAAC,MAAM,oCAAoC,CAAC;AAE7E,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,kCAAkC,CAAC;AAC3E,YAAY,EAAC,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AAE1E,OAAO,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AACxE,YAAY,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MarkdownBubble — Markdown 渲染气泡
|
|
3
|
+
* 完成的消息用 Markdown 渲染 + think 折叠
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { type ViewStyle } from 'react-native';
|
|
7
|
+
export interface MarkdownBubbleProps {
|
|
8
|
+
text: string;
|
|
9
|
+
markdownStyles?: Record<string, unknown>;
|
|
10
|
+
style?: ViewStyle;
|
|
11
|
+
testID?: string;
|
|
12
|
+
}
|
|
13
|
+
declare const _default: React.NamedExoticComponent<MarkdownBubbleProps>;
|
|
14
|
+
export default _default;
|
|
15
|
+
//# sourceMappingURL=MarkdownBubble.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkdownBubble.d.ts","sourceRoot":"","sources":["../../../../src/markdown-bubble/MarkdownBubble.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAgB,MAAM,OAAO,CAAC;AACrC,OAAO,EAAmB,KAAK,SAAS,EAAC,MAAM,cAAc,CAAC;AAK9D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;AAyED,wBAA0C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StreamingBubble — 流式文本气泡
|
|
3
|
+
* 显示正在流入的文本 + 呼吸动画光标
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { type ViewStyle } from 'react-native';
|
|
7
|
+
export interface StreamingBubbleProps {
|
|
8
|
+
text: string;
|
|
9
|
+
cursorColor?: string;
|
|
10
|
+
cursorChar?: string;
|
|
11
|
+
style?: ViewStyle;
|
|
12
|
+
testID?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const _default: React.NamedExoticComponent<StreamingBubbleProps>;
|
|
15
|
+
export default _default;
|
|
16
|
+
//# sourceMappingURL=StreamingBubble.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamingBubble.d.ts","sourceRoot":"","sources":["../../../../src/streaming-bubble/StreamingBubble.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAA0B,MAAM,OAAO,CAAC;AAC/C,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;AAqDD,wBAA2C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ThinkBlock — 思考折叠块
|
|
3
|
+
* 卡片式,圆角 12px
|
|
4
|
+
* 标题:🧠 已深度思考(展开) ▾
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { type ViewStyle, type TextStyle } from 'react-native';
|
|
8
|
+
export interface ThinkBlockSemanticStyles {
|
|
9
|
+
root?: ViewStyle;
|
|
10
|
+
header?: ViewStyle;
|
|
11
|
+
label?: TextStyle;
|
|
12
|
+
content?: TextStyle;
|
|
13
|
+
}
|
|
14
|
+
export interface ThinkBlockProps {
|
|
15
|
+
content: string;
|
|
16
|
+
defaultExpanded?: boolean;
|
|
17
|
+
label?: string;
|
|
18
|
+
style?: ViewStyle;
|
|
19
|
+
styles?: Partial<ThinkBlockSemanticStyles>;
|
|
20
|
+
testID?: string;
|
|
21
|
+
}
|
|
22
|
+
declare const _default: React.NamedExoticComponent<ThinkBlockProps>;
|
|
23
|
+
export default _default;
|
|
24
|
+
//# sourceMappingURL=ThinkBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThinkBlock.d.ts","sourceRoot":"","sources":["../../../../src/think-block/ThinkBlock.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAiB,MAAM,OAAO,CAAC;AACtC,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;AAgFD,wBAAsC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <think> 标签解析器
|
|
3
|
+
* 将文本中的 <think>...</think> 提取出来,分离为普通内容和思考内容
|
|
4
|
+
*/
|
|
5
|
+
export interface ParsedContent {
|
|
6
|
+
/** 去除 think 标签后的正文 */
|
|
7
|
+
body: string;
|
|
8
|
+
/** think 标签内的内容(可能多段) */
|
|
9
|
+
thinks: string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 解析文本中的 <think> 标签
|
|
13
|
+
* 支持多个 <think> 块,返回分离后的正文和思考内容
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseThinkTags(text: string): ParsedContent;
|
|
16
|
+
/**
|
|
17
|
+
* 检查文本中是否包含未闭合的 <think> 标签(流式场景)
|
|
18
|
+
*/
|
|
19
|
+
export declare function hasUnclosedThink(text: string): boolean;
|
|
20
|
+
//# sourceMappingURL=thinkTagParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinkTagParser.d.ts","sourceRoot":"","sources":["../../../../src/utils/thinkTagParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,aAAa;IAC5B,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAID;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAa1D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAItD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @unif/react-native-chat-markdown
|
|
3
|
+
* Markdown 渲染、ThinkBlock、流式气泡
|
|
4
|
+
*/
|
|
5
|
+
export { default as ThinkBlock } from './think-block/ThinkBlock';
|
|
6
|
+
export type { ThinkBlockProps, ThinkBlockSemanticStyles } from './think-block/ThinkBlock';
|
|
7
|
+
export { default as StreamingBubble } from './streaming-bubble/StreamingBubble';
|
|
8
|
+
export type { StreamingBubbleProps } from './streaming-bubble/StreamingBubble';
|
|
9
|
+
export { default as MarkdownBubble } from './markdown-bubble/MarkdownBubble';
|
|
10
|
+
export type { MarkdownBubbleProps } from './markdown-bubble/MarkdownBubble';
|
|
11
|
+
export { parseThinkTags, hasUnclosedThink } from './utils/thinkTagParser';
|
|
12
|
+
export type { ParsedContent } from './utils/thinkTagParser';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,0BAA0B,CAAC;AAC/D,YAAY,EAAC,eAAe,EAAE,wBAAwB,EAAC,MAAM,0BAA0B,CAAC;AAExF,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,oCAAoC,CAAC;AAC9E,YAAY,EAAC,oBAAoB,EAAC,MAAM,oCAAoC,CAAC;AAE7E,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,kCAAkC,CAAC;AAC3E,YAAY,EAAC,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AAE1E,OAAO,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AACxE,YAAY,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MarkdownBubble — Markdown 渲染气泡
|
|
3
|
+
* 完成的消息用 Markdown 渲染 + think 折叠
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { type ViewStyle } from 'react-native';
|
|
7
|
+
export interface MarkdownBubbleProps {
|
|
8
|
+
text: string;
|
|
9
|
+
markdownStyles?: Record<string, unknown>;
|
|
10
|
+
style?: ViewStyle;
|
|
11
|
+
testID?: string;
|
|
12
|
+
}
|
|
13
|
+
declare const _default: React.NamedExoticComponent<MarkdownBubbleProps>;
|
|
14
|
+
export default _default;
|
|
15
|
+
//# sourceMappingURL=MarkdownBubble.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkdownBubble.d.ts","sourceRoot":"","sources":["../../../../src/markdown-bubble/MarkdownBubble.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAgB,MAAM,OAAO,CAAC;AACrC,OAAO,EAAmB,KAAK,SAAS,EAAC,MAAM,cAAc,CAAC;AAK9D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;AAyED,wBAA0C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StreamingBubble — 流式文本气泡
|
|
3
|
+
* 显示正在流入的文本 + 呼吸动画光标
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { type ViewStyle } from 'react-native';
|
|
7
|
+
export interface StreamingBubbleProps {
|
|
8
|
+
text: string;
|
|
9
|
+
cursorColor?: string;
|
|
10
|
+
cursorChar?: string;
|
|
11
|
+
style?: ViewStyle;
|
|
12
|
+
testID?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const _default: React.NamedExoticComponent<StreamingBubbleProps>;
|
|
15
|
+
export default _default;
|
|
16
|
+
//# sourceMappingURL=StreamingBubble.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamingBubble.d.ts","sourceRoot":"","sources":["../../../../src/streaming-bubble/StreamingBubble.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAA0B,MAAM,OAAO,CAAC;AAC/C,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;AAqDD,wBAA2C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ThinkBlock — 思考折叠块
|
|
3
|
+
* 卡片式,圆角 12px
|
|
4
|
+
* 标题:🧠 已深度思考(展开) ▾
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { type ViewStyle, type TextStyle } from 'react-native';
|
|
8
|
+
export interface ThinkBlockSemanticStyles {
|
|
9
|
+
root?: ViewStyle;
|
|
10
|
+
header?: ViewStyle;
|
|
11
|
+
label?: TextStyle;
|
|
12
|
+
content?: TextStyle;
|
|
13
|
+
}
|
|
14
|
+
export interface ThinkBlockProps {
|
|
15
|
+
content: string;
|
|
16
|
+
defaultExpanded?: boolean;
|
|
17
|
+
label?: string;
|
|
18
|
+
style?: ViewStyle;
|
|
19
|
+
styles?: Partial<ThinkBlockSemanticStyles>;
|
|
20
|
+
testID?: string;
|
|
21
|
+
}
|
|
22
|
+
declare const _default: React.NamedExoticComponent<ThinkBlockProps>;
|
|
23
|
+
export default _default;
|
|
24
|
+
//# sourceMappingURL=ThinkBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThinkBlock.d.ts","sourceRoot":"","sources":["../../../../src/think-block/ThinkBlock.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAiB,MAAM,OAAO,CAAC;AACtC,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;AAgFD,wBAAsC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <think> 标签解析器
|
|
3
|
+
* 将文本中的 <think>...</think> 提取出来,分离为普通内容和思考内容
|
|
4
|
+
*/
|
|
5
|
+
export interface ParsedContent {
|
|
6
|
+
/** 去除 think 标签后的正文 */
|
|
7
|
+
body: string;
|
|
8
|
+
/** think 标签内的内容(可能多段) */
|
|
9
|
+
thinks: string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 解析文本中的 <think> 标签
|
|
13
|
+
* 支持多个 <think> 块,返回分离后的正文和思考内容
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseThinkTags(text: string): ParsedContent;
|
|
16
|
+
/**
|
|
17
|
+
* 检查文本中是否包含未闭合的 <think> 标签(流式场景)
|
|
18
|
+
*/
|
|
19
|
+
export declare function hasUnclosedThink(text: string): boolean;
|
|
20
|
+
//# sourceMappingURL=thinkTagParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinkTagParser.d.ts","sourceRoot":"","sources":["../../../../src/utils/thinkTagParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,aAAa;IAC5B,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAID;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAa1D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAItD"}
|