@kernelift/ai-chat 1.0.1-beta.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/README.md +711 -0
- package/SSE-Client.md +451 -0
- package/dist/ai-chat.css +10 -0
- package/dist/index.d.ts +361 -0
- package/dist/index.js +137813 -0
- package/dist/markdown-D2pK0c45-D2pK0c45.js +235 -0
- package/package.json +52 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/*!-----------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Version: 0.54.0(7c2310116c57517348bbd868a21139f32454be22)
|
|
4
|
+
* Released under the MIT license
|
|
5
|
+
* https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
|
|
6
|
+
*-----------------------------------------------------------------------------*/
|
|
7
|
+
var e = {
|
|
8
|
+
comments: {
|
|
9
|
+
blockComment: ["<!--", "-->"]
|
|
10
|
+
},
|
|
11
|
+
brackets: [
|
|
12
|
+
["{", "}"],
|
|
13
|
+
["[", "]"],
|
|
14
|
+
["(", ")"]
|
|
15
|
+
],
|
|
16
|
+
autoClosingPairs: [
|
|
17
|
+
{ open: "{", close: "}" },
|
|
18
|
+
{ open: "[", close: "]" },
|
|
19
|
+
{ open: "(", close: ")" },
|
|
20
|
+
{ open: "<", close: ">", notIn: ["string"] }
|
|
21
|
+
],
|
|
22
|
+
surroundingPairs: [
|
|
23
|
+
{ open: "(", close: ")" },
|
|
24
|
+
{ open: "[", close: "]" },
|
|
25
|
+
{ open: "`", close: "`" }
|
|
26
|
+
],
|
|
27
|
+
folding: {
|
|
28
|
+
markers: {
|
|
29
|
+
start: new RegExp("^\\s*<!--\\s*#?region\\b.*-->"),
|
|
30
|
+
end: new RegExp("^\\s*<!--\\s*#?endregion\\b.*-->")
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}, t = {
|
|
34
|
+
defaultToken: "",
|
|
35
|
+
tokenPostfix: ".md",
|
|
36
|
+
// escape codes
|
|
37
|
+
control: /[\\`*_\[\]{}()#+\-\.!]/,
|
|
38
|
+
noncontrol: /[^\\`*_\[\]{}()#+\-\.!]/,
|
|
39
|
+
escapes: /\\(?:@control)/,
|
|
40
|
+
// escape codes for javascript/CSS strings
|
|
41
|
+
jsescapes: /\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/,
|
|
42
|
+
// non matched elements
|
|
43
|
+
empty: [
|
|
44
|
+
"area",
|
|
45
|
+
"base",
|
|
46
|
+
"basefont",
|
|
47
|
+
"br",
|
|
48
|
+
"col",
|
|
49
|
+
"frame",
|
|
50
|
+
"hr",
|
|
51
|
+
"img",
|
|
52
|
+
"input",
|
|
53
|
+
"isindex",
|
|
54
|
+
"link",
|
|
55
|
+
"meta",
|
|
56
|
+
"param"
|
|
57
|
+
],
|
|
58
|
+
tokenizer: {
|
|
59
|
+
root: [
|
|
60
|
+
// markdown tables
|
|
61
|
+
[/^\s*\|/, "@rematch", "@table_header"],
|
|
62
|
+
// headers (with #)
|
|
63
|
+
[/^(\s{0,3})(#+)((?:[^\\#]|@escapes)+)((?:#+)?)/, ["white", "keyword", "keyword", "keyword"]],
|
|
64
|
+
// headers (with =)
|
|
65
|
+
[/^\s*(=+|\-+)\s*$/, "keyword"],
|
|
66
|
+
// headers (with ***)
|
|
67
|
+
[/^\s*((\*[ ]?)+)\s*$/, "meta.separator"],
|
|
68
|
+
// quote
|
|
69
|
+
[/^\s*>+/, "comment"],
|
|
70
|
+
// list (starting with * or number)
|
|
71
|
+
[/^\s*([\*\-+:]|\d+\.)\s/, "keyword"],
|
|
72
|
+
// code block (4 spaces indent)
|
|
73
|
+
[/^(\t|[ ]{4})[^ ].*$/, "string"],
|
|
74
|
+
// code block (3 tilde)
|
|
75
|
+
[/^\s*~~~\s*((?:\w|[\/\-#])+)?\s*$/, { token: "string", next: "@codeblock" }],
|
|
76
|
+
// github style code blocks (with backticks and language)
|
|
77
|
+
[
|
|
78
|
+
/^\s*```\s*((?:\w|[\/\-#])+).*$/,
|
|
79
|
+
{ token: "string", next: "@codeblockgh", nextEmbedded: "$1" }
|
|
80
|
+
],
|
|
81
|
+
// github style code blocks (with backticks but no language)
|
|
82
|
+
[/^\s*```\s*$/, { token: "string", next: "@codeblock" }],
|
|
83
|
+
// markup within lines
|
|
84
|
+
{ include: "@linecontent" }
|
|
85
|
+
],
|
|
86
|
+
table_header: [
|
|
87
|
+
{ include: "@table_common" },
|
|
88
|
+
[/[^\|]+/, "keyword.table.header"]
|
|
89
|
+
// table header
|
|
90
|
+
],
|
|
91
|
+
table_body: [{ include: "@table_common" }, { include: "@linecontent" }],
|
|
92
|
+
table_common: [
|
|
93
|
+
[/\s*[\-:]+\s*/, { token: "keyword", switchTo: "table_body" }],
|
|
94
|
+
// header-divider
|
|
95
|
+
[/^\s*\|/, "keyword.table.left"],
|
|
96
|
+
// opening |
|
|
97
|
+
[/^\s*[^\|]/, "@rematch", "@pop"],
|
|
98
|
+
// exiting
|
|
99
|
+
[/^\s*$/, "@rematch", "@pop"],
|
|
100
|
+
// exiting
|
|
101
|
+
[
|
|
102
|
+
/\|/,
|
|
103
|
+
{
|
|
104
|
+
cases: {
|
|
105
|
+
"@eos": "keyword.table.right",
|
|
106
|
+
// closing |
|
|
107
|
+
"@default": "keyword.table.middle"
|
|
108
|
+
// inner |
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
],
|
|
113
|
+
codeblock: [
|
|
114
|
+
[/^\s*~~~\s*$/, { token: "string", next: "@pop" }],
|
|
115
|
+
[/^\s*```\s*$/, { token: "string", next: "@pop" }],
|
|
116
|
+
[/.*$/, "variable.source"]
|
|
117
|
+
],
|
|
118
|
+
// github style code blocks
|
|
119
|
+
codeblockgh: [
|
|
120
|
+
[/```\s*$/, { token: "string", next: "@pop", nextEmbedded: "@pop" }],
|
|
121
|
+
[/[^`]+/, "variable.source"]
|
|
122
|
+
],
|
|
123
|
+
linecontent: [
|
|
124
|
+
// escapes
|
|
125
|
+
[/&\w+;/, "string.escape"],
|
|
126
|
+
[/@escapes/, "escape"],
|
|
127
|
+
// various markup
|
|
128
|
+
[/\b__([^\\_]|@escapes|_(?!_))+__\b/, "strong"],
|
|
129
|
+
[/\*\*([^\\*]|@escapes|\*(?!\*))+\*\*/, "strong"],
|
|
130
|
+
[/\b_[^_]+_\b/, "emphasis"],
|
|
131
|
+
[/\*([^\\*]|@escapes)+\*/, "emphasis"],
|
|
132
|
+
[/`([^\\`]|@escapes)+`/, "variable"],
|
|
133
|
+
// links
|
|
134
|
+
[/\{+[^}]+\}+/, "string.target"],
|
|
135
|
+
[/(!?\[)((?:[^\]\\]|@escapes)*)(\]\([^\)]+\))/, ["string.link", "", "string.link"]],
|
|
136
|
+
[/(!?\[)((?:[^\]\\]|@escapes)*)(\])/, "string.link"],
|
|
137
|
+
// or html
|
|
138
|
+
{ include: "html" }
|
|
139
|
+
],
|
|
140
|
+
// Note: it is tempting to rather switch to the real HTML mode instead of building our own here
|
|
141
|
+
// but currently there is a limitation in Monarch that prevents us from doing it: The opening
|
|
142
|
+
// '<' would start the HTML mode, however there is no way to jump 1 character back to let the
|
|
143
|
+
// HTML mode also tokenize the opening angle bracket. Thus, even though we could jump to HTML,
|
|
144
|
+
// we cannot correctly tokenize it in that mode yet.
|
|
145
|
+
html: [
|
|
146
|
+
// html tags
|
|
147
|
+
[/<(\w+)\/>/, "tag"],
|
|
148
|
+
[
|
|
149
|
+
/<(\w+)(\-|\w)*/,
|
|
150
|
+
{
|
|
151
|
+
cases: {
|
|
152
|
+
"@empty": { token: "tag", next: "@tag.$1" },
|
|
153
|
+
"@default": { token: "tag", next: "@tag.$1" }
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
[/<\/(\w+)(\-|\w)*\s*>/, { token: "tag" }],
|
|
158
|
+
[/<!--/, "comment", "@comment"]
|
|
159
|
+
],
|
|
160
|
+
comment: [
|
|
161
|
+
[/[^<\-]+/, "comment.content"],
|
|
162
|
+
[/-->/, "comment", "@pop"],
|
|
163
|
+
[/<!--/, "comment.content.invalid"],
|
|
164
|
+
[/[<\-]/, "comment.content"]
|
|
165
|
+
],
|
|
166
|
+
// Almost full HTML tag matching, complete with embedded scripts & styles
|
|
167
|
+
tag: [
|
|
168
|
+
[/[ \t\r\n]+/, "white"],
|
|
169
|
+
[
|
|
170
|
+
/(type)(\s*=\s*)(")([^"]+)(")/,
|
|
171
|
+
[
|
|
172
|
+
"attribute.name.html",
|
|
173
|
+
"delimiter.html",
|
|
174
|
+
"string.html",
|
|
175
|
+
{ token: "string.html", switchTo: "@tag.$S2.$4" },
|
|
176
|
+
"string.html"
|
|
177
|
+
]
|
|
178
|
+
],
|
|
179
|
+
[
|
|
180
|
+
/(type)(\s*=\s*)(')([^']+)(')/,
|
|
181
|
+
[
|
|
182
|
+
"attribute.name.html",
|
|
183
|
+
"delimiter.html",
|
|
184
|
+
"string.html",
|
|
185
|
+
{ token: "string.html", switchTo: "@tag.$S2.$4" },
|
|
186
|
+
"string.html"
|
|
187
|
+
]
|
|
188
|
+
],
|
|
189
|
+
[/(\w+)(\s*=\s*)("[^"]*"|'[^']*')/, ["attribute.name.html", "delimiter.html", "string.html"]],
|
|
190
|
+
[/\w+/, "attribute.name.html"],
|
|
191
|
+
[/\/>/, "tag", "@pop"],
|
|
192
|
+
[
|
|
193
|
+
/>/,
|
|
194
|
+
{
|
|
195
|
+
cases: {
|
|
196
|
+
"$S2==style": {
|
|
197
|
+
token: "tag",
|
|
198
|
+
switchTo: "embeddedStyle",
|
|
199
|
+
nextEmbedded: "text/css"
|
|
200
|
+
},
|
|
201
|
+
"$S2==script": {
|
|
202
|
+
cases: {
|
|
203
|
+
$S3: {
|
|
204
|
+
token: "tag",
|
|
205
|
+
switchTo: "embeddedScript",
|
|
206
|
+
nextEmbedded: "$S3"
|
|
207
|
+
},
|
|
208
|
+
"@default": {
|
|
209
|
+
token: "tag",
|
|
210
|
+
switchTo: "embeddedScript",
|
|
211
|
+
nextEmbedded: "text/javascript"
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"@default": { token: "tag", next: "@pop" }
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
],
|
|
220
|
+
embeddedStyle: [
|
|
221
|
+
[/[^<]+/, ""],
|
|
222
|
+
[/<\/style\s*>/, { token: "@rematch", next: "@pop", nextEmbedded: "@pop" }],
|
|
223
|
+
[/</, ""]
|
|
224
|
+
],
|
|
225
|
+
embeddedScript: [
|
|
226
|
+
[/[^<]+/, ""],
|
|
227
|
+
[/<\/script\s*>/, { token: "@rematch", next: "@pop", nextEmbedded: "@pop" }],
|
|
228
|
+
[/</, ""]
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
export {
|
|
233
|
+
e as conf,
|
|
234
|
+
t as language
|
|
235
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kernelift/ai-chat",
|
|
3
|
+
"version": "1.0.1-beta.0",
|
|
4
|
+
"description": "kernelift 前端 AI chat 聊天框组件",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"author": "charles-chan <charleschan2016@m.scnu.edu.cn>",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md",
|
|
10
|
+
"SSE-Client.md"
|
|
11
|
+
],
|
|
12
|
+
"private": false,
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"module": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"typings": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./style.css": "./dist/ai-chat.css"
|
|
22
|
+
},
|
|
23
|
+
"license": "GPL-3.0-only",
|
|
24
|
+
"keywords": [
|
|
25
|
+
"kernelift",
|
|
26
|
+
"vue3",
|
|
27
|
+
"frontend",
|
|
28
|
+
"chat",
|
|
29
|
+
"ai-chat"
|
|
30
|
+
],
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"element-plus": "^2.11.5",
|
|
33
|
+
"@kernelift/icons": "1.0.1-beta.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"sass": "^1.93.2",
|
|
37
|
+
"vite-plugin-dts": "^4.5.0",
|
|
38
|
+
"@kernelift/configs": "1.0.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@vueuse/core": "^14.0.0",
|
|
42
|
+
"@kernelift/utils": "1.0.1-beta.0",
|
|
43
|
+
"@kernelift/markdown": "1.0.1-beta.0"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "run-p type-check \"build-only {@}\" --",
|
|
47
|
+
"format": "prettier --write src/",
|
|
48
|
+
"test:unit": "vitest",
|
|
49
|
+
"build-only": "vite build",
|
|
50
|
+
"type-check": "vue-tsc --build"
|
|
51
|
+
}
|
|
52
|
+
}
|