@copilotkit/react-ui 0.21.0-mme-esm-error.1 → 0.21.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/.turbo/turbo-build.log +38 -38
- package/CHANGELOG.md +30 -0
- package/dist/{chunk-BJ75DW3Z.mjs → chunk-6U3O2JZP.mjs} +2 -2
- package/dist/{chunk-3SXQEFGW.mjs → chunk-73EBDGYK.mjs} +2 -2
- package/dist/chunk-MBYUBR3F.mjs +395 -0
- package/dist/chunk-MBYUBR3F.mjs.map +1 -0
- package/dist/{chunk-7UK4MYTF.mjs → chunk-T3WYKWNC.mjs} +2 -2
- package/dist/{chunk-PGPR52GM.mjs → chunk-WDHLWSSU.mjs} +2 -2
- package/dist/{chunk-OTE2PMAQ.mjs → chunk-YAORLSQ3.mjs} +2 -2
- package/dist/components/chat/Chat.js +283 -2
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +4 -4
- package/dist/components/chat/CodeBlock.js +283 -2
- package/dist/components/chat/CodeBlock.js.map +1 -1
- package/dist/components/chat/CodeBlock.mjs +1 -1
- package/dist/components/chat/Markdown.js +283 -2
- package/dist/components/chat/Markdown.js.map +1 -1
- package/dist/components/chat/Markdown.mjs +2 -2
- package/dist/components/chat/Messages.js +283 -2
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +3 -3
- package/dist/components/chat/Popup.js +283 -2
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +5 -5
- package/dist/components/chat/Sidebar.js +283 -2
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +5 -5
- package/dist/components/chat/index.js +283 -2
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +6 -6
- package/dist/components/index.js +283 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +6 -6
- package/dist/index.css +6 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +283 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/package.json +6 -6
- package/src/components/chat/CodeBlock.tsx +287 -2
- package/dist/chunk-ZRJSYYXC.mjs +0 -114
- package/dist/chunk-ZRJSYYXC.mjs.map +0 -1
- /package/dist/{chunk-BJ75DW3Z.mjs.map → chunk-6U3O2JZP.mjs.map} +0 -0
- /package/dist/{chunk-3SXQEFGW.mjs.map → chunk-73EBDGYK.mjs.map} +0 -0
- /package/dist/{chunk-7UK4MYTF.mjs.map → chunk-T3WYKWNC.mjs.map} +0 -0
- /package/dist/{chunk-PGPR52GM.mjs.map → chunk-WDHLWSSU.mjs.map} +0 -0
- /package/dist/{chunk-OTE2PMAQ.mjs.map → chunk-YAORLSQ3.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -4,17 +4,17 @@ import "./chunk-UGQQ4WEQ.mjs";
|
|
|
4
4
|
import "./chunk-WB3YULQ4.mjs";
|
|
5
5
|
import {
|
|
6
6
|
CopilotPopup
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YAORLSQ3.mjs";
|
|
8
8
|
import {
|
|
9
9
|
CopilotSidebar
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-T3WYKWNC.mjs";
|
|
11
|
+
import "./chunk-6U3O2JZP.mjs";
|
|
12
|
+
import "./chunk-73EBDGYK.mjs";
|
|
13
|
+
import "./chunk-WDHLWSSU.mjs";
|
|
14
14
|
import "./chunk-YEHO5VMA.mjs";
|
|
15
15
|
import "./chunk-B7DNOYVQ.mjs";
|
|
16
16
|
import "./chunk-YTIGBBTC.mjs";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-MBYUBR3F.mjs";
|
|
18
18
|
import "./chunk-7JYUCW7H.mjs";
|
|
19
19
|
import "./chunk-KE3N45ZY.mjs";
|
|
20
20
|
import "./chunk-WM6BS77F.mjs";
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.21.0
|
|
7
|
+
"version": "0.21.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"**/*.css"
|
|
10
10
|
],
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"ts-jest": "^29.1.1",
|
|
36
36
|
"tsup": "^6.7.0",
|
|
37
37
|
"typescript": "^5.2.3",
|
|
38
|
-
"eslint-config-custom": "0.9.0
|
|
39
|
-
"tailwind-config": "0.8.0
|
|
40
|
-
"tsconfig": "0.13.0
|
|
38
|
+
"eslint-config-custom": "0.9.0",
|
|
39
|
+
"tailwind-config": "0.8.0",
|
|
40
|
+
"tsconfig": "0.13.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"nanoid": "^4.0.2",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"react-syntax-highlighter": "^15.5.0",
|
|
46
46
|
"remark-gfm": "^3.0.1",
|
|
47
47
|
"remark-math": "^5.1.1",
|
|
48
|
-
"@copilotkit/shared": "0.8.0
|
|
49
|
-
"@copilotkit/react-core": "0.24.0
|
|
48
|
+
"@copilotkit/shared": "0.8.0",
|
|
49
|
+
"@copilotkit/react-core": "0.24.0"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsup --clean",
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { FC, memo } from "react";
|
|
2
2
|
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
|
|
3
|
-
import { vscDarkPlus as highlightStyle } from "react-syntax-highlighter/dist/esm/styles/prism";
|
|
4
|
-
|
|
5
3
|
import { useCopyToClipboard } from "../../hooks/use-copy-to-clipboard";
|
|
6
4
|
import { CheckIcon, CopyIcon, DownloadIcon } from "./Icons";
|
|
7
5
|
|
|
@@ -121,3 +119,290 @@ const CodeBlock: FC<Props> = memo(({ language, value }) => {
|
|
|
121
119
|
CodeBlock.displayName = "CodeBlock";
|
|
122
120
|
|
|
123
121
|
export { CodeBlock };
|
|
122
|
+
|
|
123
|
+
// import { vscDarkPlus as highlightStyle } from "react-syntax-highlighter/dist/esm/styles/prism";
|
|
124
|
+
// As a workaround, we inline the vscDarkPlus from react-syntax-highlighter.
|
|
125
|
+
// Importing it as recommended in the documentation leads to build errors in the non app router
|
|
126
|
+
// (Next.js classic) setup.
|
|
127
|
+
const highlightStyle: any = {
|
|
128
|
+
'pre[class*="language-"]': {
|
|
129
|
+
color: "#d4d4d4",
|
|
130
|
+
fontSize: "13px",
|
|
131
|
+
textShadow: "none",
|
|
132
|
+
fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
|
|
133
|
+
direction: "ltr",
|
|
134
|
+
textAlign: "left",
|
|
135
|
+
whiteSpace: "pre",
|
|
136
|
+
wordSpacing: "normal",
|
|
137
|
+
wordBreak: "normal",
|
|
138
|
+
lineHeight: "1.5",
|
|
139
|
+
MozTabSize: "4",
|
|
140
|
+
OTabSize: "4",
|
|
141
|
+
tabSize: "4",
|
|
142
|
+
WebkitHyphens: "none",
|
|
143
|
+
MozHyphens: "none",
|
|
144
|
+
msHyphens: "none",
|
|
145
|
+
hyphens: "none",
|
|
146
|
+
padding: "1em",
|
|
147
|
+
margin: ".5em 0",
|
|
148
|
+
overflow: "auto",
|
|
149
|
+
background: "#1e1e1e",
|
|
150
|
+
},
|
|
151
|
+
'code[class*="language-"]': {
|
|
152
|
+
color: "#d4d4d4",
|
|
153
|
+
fontSize: "13px",
|
|
154
|
+
textShadow: "none",
|
|
155
|
+
fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
|
|
156
|
+
direction: "ltr",
|
|
157
|
+
textAlign: "left",
|
|
158
|
+
whiteSpace: "pre",
|
|
159
|
+
wordSpacing: "normal",
|
|
160
|
+
wordBreak: "normal",
|
|
161
|
+
lineHeight: "1.5",
|
|
162
|
+
MozTabSize: "4",
|
|
163
|
+
OTabSize: "4",
|
|
164
|
+
tabSize: "4",
|
|
165
|
+
WebkitHyphens: "none",
|
|
166
|
+
MozHyphens: "none",
|
|
167
|
+
msHyphens: "none",
|
|
168
|
+
hyphens: "none",
|
|
169
|
+
},
|
|
170
|
+
'pre[class*="language-"]::selection': {
|
|
171
|
+
textShadow: "none",
|
|
172
|
+
background: "#264F78",
|
|
173
|
+
},
|
|
174
|
+
'code[class*="language-"]::selection': {
|
|
175
|
+
textShadow: "none",
|
|
176
|
+
background: "#264F78",
|
|
177
|
+
},
|
|
178
|
+
'pre[class*="language-"] *::selection': {
|
|
179
|
+
textShadow: "none",
|
|
180
|
+
background: "#264F78",
|
|
181
|
+
},
|
|
182
|
+
'code[class*="language-"] *::selection': {
|
|
183
|
+
textShadow: "none",
|
|
184
|
+
background: "#264F78",
|
|
185
|
+
},
|
|
186
|
+
':not(pre) > code[class*="language-"]': {
|
|
187
|
+
padding: ".1em .3em",
|
|
188
|
+
borderRadius: ".3em",
|
|
189
|
+
color: "#db4c69",
|
|
190
|
+
background: "#1e1e1e",
|
|
191
|
+
},
|
|
192
|
+
".namespace": {
|
|
193
|
+
Opacity: ".7",
|
|
194
|
+
},
|
|
195
|
+
"doctype.doctype-tag": {
|
|
196
|
+
color: "#569CD6",
|
|
197
|
+
},
|
|
198
|
+
"doctype.name": {
|
|
199
|
+
color: "#9cdcfe",
|
|
200
|
+
},
|
|
201
|
+
comment: {
|
|
202
|
+
color: "#6a9955",
|
|
203
|
+
},
|
|
204
|
+
prolog: {
|
|
205
|
+
color: "#6a9955",
|
|
206
|
+
},
|
|
207
|
+
punctuation: {
|
|
208
|
+
color: "#d4d4d4",
|
|
209
|
+
},
|
|
210
|
+
".language-html .language-css .token.punctuation": {
|
|
211
|
+
color: "#d4d4d4",
|
|
212
|
+
},
|
|
213
|
+
".language-html .language-javascript .token.punctuation": {
|
|
214
|
+
color: "#d4d4d4",
|
|
215
|
+
},
|
|
216
|
+
property: {
|
|
217
|
+
color: "#9cdcfe",
|
|
218
|
+
},
|
|
219
|
+
tag: {
|
|
220
|
+
color: "#569cd6",
|
|
221
|
+
},
|
|
222
|
+
boolean: {
|
|
223
|
+
color: "#569cd6",
|
|
224
|
+
},
|
|
225
|
+
number: {
|
|
226
|
+
color: "#b5cea8",
|
|
227
|
+
},
|
|
228
|
+
constant: {
|
|
229
|
+
color: "#9cdcfe",
|
|
230
|
+
},
|
|
231
|
+
symbol: {
|
|
232
|
+
color: "#b5cea8",
|
|
233
|
+
},
|
|
234
|
+
inserted: {
|
|
235
|
+
color: "#b5cea8",
|
|
236
|
+
},
|
|
237
|
+
unit: {
|
|
238
|
+
color: "#b5cea8",
|
|
239
|
+
},
|
|
240
|
+
selector: {
|
|
241
|
+
color: "#d7ba7d",
|
|
242
|
+
},
|
|
243
|
+
"attr-name": {
|
|
244
|
+
color: "#9cdcfe",
|
|
245
|
+
},
|
|
246
|
+
string: {
|
|
247
|
+
color: "#ce9178",
|
|
248
|
+
},
|
|
249
|
+
char: {
|
|
250
|
+
color: "#ce9178",
|
|
251
|
+
},
|
|
252
|
+
builtin: {
|
|
253
|
+
color: "#ce9178",
|
|
254
|
+
},
|
|
255
|
+
deleted: {
|
|
256
|
+
color: "#ce9178",
|
|
257
|
+
},
|
|
258
|
+
".language-css .token.string.url": {
|
|
259
|
+
textDecoration: "underline",
|
|
260
|
+
},
|
|
261
|
+
operator: {
|
|
262
|
+
color: "#d4d4d4",
|
|
263
|
+
},
|
|
264
|
+
entity: {
|
|
265
|
+
color: "#569cd6",
|
|
266
|
+
},
|
|
267
|
+
"operator.arrow": {
|
|
268
|
+
color: "#569CD6",
|
|
269
|
+
},
|
|
270
|
+
atrule: {
|
|
271
|
+
color: "#ce9178",
|
|
272
|
+
},
|
|
273
|
+
"atrule.rule": {
|
|
274
|
+
color: "#c586c0",
|
|
275
|
+
},
|
|
276
|
+
"atrule.url": {
|
|
277
|
+
color: "#9cdcfe",
|
|
278
|
+
},
|
|
279
|
+
"atrule.url.function": {
|
|
280
|
+
color: "#dcdcaa",
|
|
281
|
+
},
|
|
282
|
+
"atrule.url.punctuation": {
|
|
283
|
+
color: "#d4d4d4",
|
|
284
|
+
},
|
|
285
|
+
keyword: {
|
|
286
|
+
color: "#569CD6",
|
|
287
|
+
},
|
|
288
|
+
"keyword.module": {
|
|
289
|
+
color: "#c586c0",
|
|
290
|
+
},
|
|
291
|
+
"keyword.control-flow": {
|
|
292
|
+
color: "#c586c0",
|
|
293
|
+
},
|
|
294
|
+
function: {
|
|
295
|
+
color: "#dcdcaa",
|
|
296
|
+
},
|
|
297
|
+
"function.maybe-class-name": {
|
|
298
|
+
color: "#dcdcaa",
|
|
299
|
+
},
|
|
300
|
+
regex: {
|
|
301
|
+
color: "#d16969",
|
|
302
|
+
},
|
|
303
|
+
important: {
|
|
304
|
+
color: "#569cd6",
|
|
305
|
+
},
|
|
306
|
+
italic: {
|
|
307
|
+
fontStyle: "italic",
|
|
308
|
+
},
|
|
309
|
+
"class-name": {
|
|
310
|
+
color: "#4ec9b0",
|
|
311
|
+
},
|
|
312
|
+
"maybe-class-name": {
|
|
313
|
+
color: "#4ec9b0",
|
|
314
|
+
},
|
|
315
|
+
console: {
|
|
316
|
+
color: "#9cdcfe",
|
|
317
|
+
},
|
|
318
|
+
parameter: {
|
|
319
|
+
color: "#9cdcfe",
|
|
320
|
+
},
|
|
321
|
+
interpolation: {
|
|
322
|
+
color: "#9cdcfe",
|
|
323
|
+
},
|
|
324
|
+
"punctuation.interpolation-punctuation": {
|
|
325
|
+
color: "#569cd6",
|
|
326
|
+
},
|
|
327
|
+
variable: {
|
|
328
|
+
color: "#9cdcfe",
|
|
329
|
+
},
|
|
330
|
+
"imports.maybe-class-name": {
|
|
331
|
+
color: "#9cdcfe",
|
|
332
|
+
},
|
|
333
|
+
"exports.maybe-class-name": {
|
|
334
|
+
color: "#9cdcfe",
|
|
335
|
+
},
|
|
336
|
+
escape: {
|
|
337
|
+
color: "#d7ba7d",
|
|
338
|
+
},
|
|
339
|
+
"tag.punctuation": {
|
|
340
|
+
color: "#808080",
|
|
341
|
+
},
|
|
342
|
+
cdata: {
|
|
343
|
+
color: "#808080",
|
|
344
|
+
},
|
|
345
|
+
"attr-value": {
|
|
346
|
+
color: "#ce9178",
|
|
347
|
+
},
|
|
348
|
+
"attr-value.punctuation": {
|
|
349
|
+
color: "#ce9178",
|
|
350
|
+
},
|
|
351
|
+
"attr-value.punctuation.attr-equals": {
|
|
352
|
+
color: "#d4d4d4",
|
|
353
|
+
},
|
|
354
|
+
namespace: {
|
|
355
|
+
color: "#4ec9b0",
|
|
356
|
+
},
|
|
357
|
+
'pre[class*="language-javascript"]': {
|
|
358
|
+
color: "#9cdcfe",
|
|
359
|
+
},
|
|
360
|
+
'code[class*="language-javascript"]': {
|
|
361
|
+
color: "#9cdcfe",
|
|
362
|
+
},
|
|
363
|
+
'pre[class*="language-jsx"]': {
|
|
364
|
+
color: "#9cdcfe",
|
|
365
|
+
},
|
|
366
|
+
'code[class*="language-jsx"]': {
|
|
367
|
+
color: "#9cdcfe",
|
|
368
|
+
},
|
|
369
|
+
'pre[class*="language-typescript"]': {
|
|
370
|
+
color: "#9cdcfe",
|
|
371
|
+
},
|
|
372
|
+
'code[class*="language-typescript"]': {
|
|
373
|
+
color: "#9cdcfe",
|
|
374
|
+
},
|
|
375
|
+
'pre[class*="language-tsx"]': {
|
|
376
|
+
color: "#9cdcfe",
|
|
377
|
+
},
|
|
378
|
+
'code[class*="language-tsx"]': {
|
|
379
|
+
color: "#9cdcfe",
|
|
380
|
+
},
|
|
381
|
+
'pre[class*="language-css"]': {
|
|
382
|
+
color: "#ce9178",
|
|
383
|
+
},
|
|
384
|
+
'code[class*="language-css"]': {
|
|
385
|
+
color: "#ce9178",
|
|
386
|
+
},
|
|
387
|
+
'pre[class*="language-html"]': {
|
|
388
|
+
color: "#d4d4d4",
|
|
389
|
+
},
|
|
390
|
+
'code[class*="language-html"]': {
|
|
391
|
+
color: "#d4d4d4",
|
|
392
|
+
},
|
|
393
|
+
".language-regex .token.anchor": {
|
|
394
|
+
color: "#dcdcaa",
|
|
395
|
+
},
|
|
396
|
+
".language-html .token.punctuation": {
|
|
397
|
+
color: "#808080",
|
|
398
|
+
},
|
|
399
|
+
'pre[class*="language-"] > code[class*="language-"]': {
|
|
400
|
+
position: "relative",
|
|
401
|
+
zIndex: "1",
|
|
402
|
+
},
|
|
403
|
+
".line-highlight.line-highlight": {
|
|
404
|
+
background: "#f7ebc6",
|
|
405
|
+
boxShadow: "inset 5px 0 0 #f7d87c",
|
|
406
|
+
zIndex: "0",
|
|
407
|
+
},
|
|
408
|
+
};
|
package/dist/chunk-ZRJSYYXC.mjs
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CheckIcon,
|
|
3
|
-
CopyIcon,
|
|
4
|
-
DownloadIcon
|
|
5
|
-
} from "./chunk-7YXG7D47.mjs";
|
|
6
|
-
import {
|
|
7
|
-
useCopyToClipboard
|
|
8
|
-
} from "./chunk-54JAUBUJ.mjs";
|
|
9
|
-
|
|
10
|
-
// src/components/chat/CodeBlock.tsx
|
|
11
|
-
import { memo } from "react";
|
|
12
|
-
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
|
|
13
|
-
import { vscDarkPlus as highlightStyle } from "react-syntax-highlighter/dist/esm/styles/prism";
|
|
14
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
var programmingLanguages = {
|
|
16
|
-
javascript: ".js",
|
|
17
|
-
python: ".py",
|
|
18
|
-
java: ".java",
|
|
19
|
-
c: ".c",
|
|
20
|
-
cpp: ".cpp",
|
|
21
|
-
"c++": ".cpp",
|
|
22
|
-
"c#": ".cs",
|
|
23
|
-
ruby: ".rb",
|
|
24
|
-
php: ".php",
|
|
25
|
-
swift: ".swift",
|
|
26
|
-
"objective-c": ".m",
|
|
27
|
-
kotlin: ".kt",
|
|
28
|
-
typescript: ".ts",
|
|
29
|
-
go: ".go",
|
|
30
|
-
perl: ".pl",
|
|
31
|
-
rust: ".rs",
|
|
32
|
-
scala: ".scala",
|
|
33
|
-
haskell: ".hs",
|
|
34
|
-
lua: ".lua",
|
|
35
|
-
shell: ".sh",
|
|
36
|
-
sql: ".sql",
|
|
37
|
-
html: ".html",
|
|
38
|
-
css: ".css"
|
|
39
|
-
// add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
|
|
40
|
-
};
|
|
41
|
-
var generateRandomString = (length, lowercase = false) => {
|
|
42
|
-
const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
|
|
43
|
-
let result = "";
|
|
44
|
-
for (let i = 0; i < length; i++) {
|
|
45
|
-
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
46
|
-
}
|
|
47
|
-
return lowercase ? result.toLowerCase() : result;
|
|
48
|
-
};
|
|
49
|
-
var CodeBlock = memo(({ language, value }) => {
|
|
50
|
-
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
|
|
51
|
-
const downloadAsFile = () => {
|
|
52
|
-
if (typeof window === "undefined") {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const fileExtension = programmingLanguages[language] || ".file";
|
|
56
|
-
const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;
|
|
57
|
-
const fileName = window.prompt("Enter file name", suggestedFileName);
|
|
58
|
-
if (!fileName) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const blob = new Blob([value], { type: "text/plain" });
|
|
62
|
-
const url = URL.createObjectURL(blob);
|
|
63
|
-
const link = document.createElement("a");
|
|
64
|
-
link.download = fileName;
|
|
65
|
-
link.href = url;
|
|
66
|
-
link.style.display = "none";
|
|
67
|
-
document.body.appendChild(link);
|
|
68
|
-
link.click();
|
|
69
|
-
document.body.removeChild(link);
|
|
70
|
-
URL.revokeObjectURL(url);
|
|
71
|
-
};
|
|
72
|
-
const onCopy = () => {
|
|
73
|
-
if (isCopied)
|
|
74
|
-
return;
|
|
75
|
-
copyToClipboard(value);
|
|
76
|
-
};
|
|
77
|
-
return /* @__PURE__ */ jsxs("div", { className: "copilotKitCodeBlock", children: [
|
|
78
|
-
/* @__PURE__ */ jsxs("div", { className: "copilotKitCodeBlockToolbar", children: [
|
|
79
|
-
/* @__PURE__ */ jsx("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
|
|
80
|
-
/* @__PURE__ */ jsxs("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
|
|
81
|
-
/* @__PURE__ */ jsxs("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: [
|
|
82
|
-
/* @__PURE__ */ jsx(DownloadIcon, {}),
|
|
83
|
-
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Download" })
|
|
84
|
-
] }),
|
|
85
|
-
/* @__PURE__ */ jsxs("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: [
|
|
86
|
-
isCopied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {}),
|
|
87
|
-
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Copy code" })
|
|
88
|
-
] })
|
|
89
|
-
] })
|
|
90
|
-
] }),
|
|
91
|
-
/* @__PURE__ */ jsx(
|
|
92
|
-
SyntaxHighlighter,
|
|
93
|
-
{
|
|
94
|
-
language,
|
|
95
|
-
style: highlightStyle,
|
|
96
|
-
PreTag: "div",
|
|
97
|
-
customStyle: {
|
|
98
|
-
margin: 0,
|
|
99
|
-
borderBottomLeftRadius: "0.375rem",
|
|
100
|
-
borderBottomRightRadius: "0.375rem"
|
|
101
|
-
},
|
|
102
|
-
children: value
|
|
103
|
-
}
|
|
104
|
-
)
|
|
105
|
-
] });
|
|
106
|
-
});
|
|
107
|
-
CodeBlock.displayName = "CodeBlock";
|
|
108
|
-
|
|
109
|
-
export {
|
|
110
|
-
programmingLanguages,
|
|
111
|
-
generateRandomString,
|
|
112
|
-
CodeBlock
|
|
113
|
-
};
|
|
114
|
-
//# sourceMappingURL=chunk-ZRJSYYXC.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/chat/CodeBlock.tsx"],"sourcesContent":["import { FC, memo } from \"react\";\nimport { Prism as SyntaxHighlighter } from \"react-syntax-highlighter\";\nimport { vscDarkPlus as highlightStyle } from \"react-syntax-highlighter/dist/esm/styles/prism\";\n\nimport { useCopyToClipboard } from \"../../hooks/use-copy-to-clipboard\";\nimport { CheckIcon, CopyIcon, DownloadIcon } from \"./Icons\";\n\ninterface CodeActionButtonProps {\n onClick: () => void;\n children: React.ReactNode;\n}\n\ninterface Props {\n language: string;\n value: string;\n}\n\ninterface languageMap {\n [key: string]: string | undefined;\n}\n\nexport const programmingLanguages: languageMap = {\n javascript: \".js\",\n python: \".py\",\n java: \".java\",\n c: \".c\",\n cpp: \".cpp\",\n \"c++\": \".cpp\",\n \"c#\": \".cs\",\n ruby: \".rb\",\n php: \".php\",\n swift: \".swift\",\n \"objective-c\": \".m\",\n kotlin: \".kt\",\n typescript: \".ts\",\n go: \".go\",\n perl: \".pl\",\n rust: \".rs\",\n scala: \".scala\",\n haskell: \".hs\",\n lua: \".lua\",\n shell: \".sh\",\n sql: \".sql\",\n html: \".html\",\n css: \".css\",\n // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component\n};\n\nexport const generateRandomString = (length: number, lowercase = false) => {\n const chars = \"ABCDEFGHJKLMNPQRSTUVWXY3456789\"; // excluding similar looking characters like Z, 2, I, 1, O, 0\n let result = \"\";\n for (let i = 0; i < length; i++) {\n result += chars.charAt(Math.floor(Math.random() * chars.length));\n }\n return lowercase ? result.toLowerCase() : result;\n};\n\nconst CodeBlock: FC<Props> = memo(({ language, value }) => {\n const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 });\n\n const downloadAsFile = () => {\n if (typeof window === \"undefined\") {\n return;\n }\n const fileExtension = programmingLanguages[language] || \".file\";\n const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;\n const fileName = window.prompt(\"Enter file name\" || \"\", suggestedFileName);\n\n if (!fileName) {\n // User pressed cancel on prompt.\n return;\n }\n\n const blob = new Blob([value], { type: \"text/plain\" });\n const url = URL.createObjectURL(blob);\n const link = document.createElement(\"a\");\n link.download = fileName;\n link.href = url;\n link.style.display = \"none\";\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n URL.revokeObjectURL(url);\n };\n\n const onCopy = () => {\n if (isCopied) return;\n copyToClipboard(value);\n };\n\n return (\n <div className=\"copilotKitCodeBlock\">\n <div className=\"copilotKitCodeBlockToolbar\">\n <span className=\"copilotKitCodeBlockToolbarLanguage\">{language}</span>\n <div className=\"copilotKitCodeBlockToolbarButtons\">\n <button className=\"copilotKitCodeBlockToolbarButton\" onClick={downloadAsFile}>\n <DownloadIcon />\n <span className=\"sr-only\">Download</span>\n </button>\n <button className=\"copilotKitCodeBlockToolbarButton\" onClick={onCopy}>\n {isCopied ? <CheckIcon /> : <CopyIcon />}\n <span className=\"sr-only\">Copy code</span>\n </button>\n </div>\n </div>\n <SyntaxHighlighter\n language={language}\n style={highlightStyle}\n PreTag=\"div\"\n customStyle={{\n margin: 0,\n borderBottomLeftRadius: \"0.375rem\",\n borderBottomRightRadius: \"0.375rem\",\n }}\n >\n {value}\n </SyntaxHighlighter>\n </div>\n );\n});\nCodeBlock.displayName = \"CodeBlock\";\n\nexport { CodeBlock };\n"],"mappings":";;;;;;;;;;AAAA,SAAa,YAAY;AACzB,SAAS,SAAS,yBAAyB;AAC3C,SAAS,eAAe,sBAAsB;AA2FtC,cAEE,YAFF;AAxED,IAAM,uBAAoC;AAAA,EAC/C,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,GAAG;AAAA,EACH,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,KAAK;AAAA,EACL,OAAO;AAAA,EACP,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA;AAEP;AAEO,IAAM,uBAAuB,CAAC,QAAgB,YAAY,UAAU;AACzE,QAAM,QAAQ;AACd,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,QAAQ,KAAK;AAC/B,cAAU,MAAM,OAAO,KAAK,MAAM,KAAK,OAAO,IAAI,MAAM,MAAM,CAAC;AAAA,EACjE;AACA,SAAO,YAAY,OAAO,YAAY,IAAI;AAC5C;AAEA,IAAM,YAAuB,KAAK,CAAC,EAAE,UAAU,MAAM,MAAM;AACzD,QAAM,EAAE,UAAU,gBAAgB,IAAI,mBAAmB,EAAE,SAAS,IAAK,CAAC;AAE1E,QAAM,iBAAiB,MAAM;AAC3B,QAAI,OAAO,WAAW,aAAa;AACjC;AAAA,IACF;AACA,UAAM,gBAAgB,qBAAqB,QAAQ,KAAK;AACxD,UAAM,oBAAoB,QAAQ,qBAAqB,GAAG,IAAI,IAAI;AAClE,UAAM,WAAW,OAAO,OAAO,mBAAyB,iBAAiB;AAEzE,QAAI,CAAC,UAAU;AAEb;AAAA,IACF;AAEA,UAAM,OAAO,IAAI,KAAK,CAAC,KAAK,GAAG,EAAE,MAAM,aAAa,CAAC;AACrD,UAAM,MAAM,IAAI,gBAAgB,IAAI;AACpC,UAAM,OAAO,SAAS,cAAc,GAAG;AACvC,SAAK,WAAW;AAChB,SAAK,OAAO;AACZ,SAAK,MAAM,UAAU;AACrB,aAAS,KAAK,YAAY,IAAI;AAC9B,SAAK,MAAM;AACX,aAAS,KAAK,YAAY,IAAI;AAC9B,QAAI,gBAAgB,GAAG;AAAA,EACzB;AAEA,QAAM,SAAS,MAAM;AACnB,QAAI;AAAU;AACd,oBAAgB,KAAK;AAAA,EACvB;AAEA,SACE,qBAAC,SAAI,WAAU,uBACb;AAAA,yBAAC,SAAI,WAAU,8BACb;AAAA,0BAAC,UAAK,WAAU,sCAAsC,oBAAS;AAAA,MAC/D,qBAAC,SAAI,WAAU,qCACb;AAAA,6BAAC,YAAO,WAAU,oCAAmC,SAAS,gBAC5D;AAAA,8BAAC,gBAAa;AAAA,UACd,oBAAC,UAAK,WAAU,WAAU,sBAAQ;AAAA,WACpC;AAAA,QACA,qBAAC,YAAO,WAAU,oCAAmC,SAAS,QAC3D;AAAA,qBAAW,oBAAC,aAAU,IAAK,oBAAC,YAAS;AAAA,UACtC,oBAAC,UAAK,WAAU,WAAU,uBAAS;AAAA,WACrC;AAAA,SACF;AAAA,OACF;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,OAAO;AAAA,QACP,QAAO;AAAA,QACP,aAAa;AAAA,UACX,QAAQ;AAAA,UACR,wBAAwB;AAAA,UACxB,yBAAyB;AAAA,QAC3B;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,KACF;AAEJ,CAAC;AACD,UAAU,cAAc;","names":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|