@novaqore/atom 0.0.1 → 0.1.1
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/package.json +1 -1
- package/src/screens/chat.js +4 -4
- package/src/utils/markdown.js +12 -2
package/package.json
CHANGED
package/src/screens/chat.js
CHANGED
|
@@ -292,9 +292,9 @@ export function ChatScreen({ version, unhinged }) {
|
|
|
292
292
|
React.createElement(
|
|
293
293
|
Text,
|
|
294
294
|
{ bold: true, color: "cyan" },
|
|
295
|
-
"Atom:
|
|
295
|
+
"Atom:"
|
|
296
296
|
),
|
|
297
|
-
React.createElement(Text, null, firstLine)
|
|
297
|
+
React.createElement(Text, null, " ", firstLine)
|
|
298
298
|
),
|
|
299
299
|
rest ? React.createElement(Text, null, rest) : null
|
|
300
300
|
)
|
|
@@ -327,9 +327,9 @@ export function ChatScreen({ version, unhinged }) {
|
|
|
327
327
|
React.createElement(
|
|
328
328
|
Text,
|
|
329
329
|
{ color: "cyan", bold: true },
|
|
330
|
-
"Atom:
|
|
330
|
+
"Atom:"
|
|
331
331
|
),
|
|
332
|
-
React.createElement(Text, null, firstLine)
|
|
332
|
+
React.createElement(Text, null, " ", firstLine)
|
|
333
333
|
),
|
|
334
334
|
rest ? React.createElement(Text, null, rest) : null
|
|
335
335
|
);
|
package/src/utils/markdown.js
CHANGED
|
@@ -40,8 +40,18 @@ function balanceForStreaming(buffer) {
|
|
|
40
40
|
return out;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
const cache = new Map();
|
|
44
|
+
const MAX_CACHE = 500;
|
|
45
|
+
|
|
43
46
|
export function renderMarkdown(text, { streaming = false } = {}) {
|
|
44
47
|
if (!text) return "";
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
if (streaming) {
|
|
49
|
+
return marked.parse(balanceForStreaming(text)).trim();
|
|
50
|
+
}
|
|
51
|
+
const cached = cache.get(text);
|
|
52
|
+
if (cached !== undefined) return cached;
|
|
53
|
+
const result = marked.parse(text).trim();
|
|
54
|
+
if (cache.size >= MAX_CACHE) cache.clear();
|
|
55
|
+
cache.set(text, result);
|
|
56
|
+
return result;
|
|
47
57
|
}
|