@aparte/core 0.17.1 → 0.17.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/dist/config/aparte-config.d.ts +16 -7
- package/dist/config/aparte-config.d.ts.map +1 -1
- package/dist/custom-elements.json +5905 -5905
- package/dist/{dialog-triggers-CJWw0P3l.js → dialog-triggers-DwTGKWeU.js} +27 -8
- package/dist/dialog-triggers-DwTGKWeU.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.node.js +1 -1
- package/dist/renderers/markdown-stream.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/dialog-triggers-CJWw0P3l.js.map +0 -1
|
@@ -1416,11 +1416,12 @@ class AparteConfig {
|
|
|
1416
1416
|
* Set an incremental (streaming) Markdown renderer provider. Optional —
|
|
1417
1417
|
* when set, the chat bubble uses it to render the assistant message
|
|
1418
1418
|
* token-by-token DURING streaming (incremental parse + DOM append, O(n)),
|
|
1419
|
-
* instead of re-parsing the whole string on every token.
|
|
1420
|
-
*
|
|
1421
|
-
*
|
|
1422
|
-
*
|
|
1423
|
-
*
|
|
1419
|
+
* instead of re-parsing the whole string on every token. With no one-shot
|
|
1420
|
+
* `setMarkdownProvider` registered, it also renders a COMPLETE string
|
|
1421
|
+
* (`renderMarkdown`): a restored reply, a non-streaming provider's answer, a
|
|
1422
|
+
* stored segment — so a reply renders the same however it arrived. A registered
|
|
1423
|
+
* one-shot provider takes over for those, and re-renders the finished message
|
|
1424
|
+
* at full fidelity.
|
|
1424
1425
|
*/
|
|
1425
1426
|
setStreamingMarkdownProvider(fn) {
|
|
1426
1427
|
this._streamingMarkdownProvider = fn;
|
|
@@ -2034,8 +2035,16 @@ class AparteConfig {
|
|
|
2034
2035
|
return val === void 0 ? "" : val;
|
|
2035
2036
|
}
|
|
2036
2037
|
/**
|
|
2037
|
-
* Render Markdown to HTML
|
|
2038
|
-
*
|
|
2038
|
+
* Render a complete Markdown string to HTML: the one-shot provider when one is
|
|
2039
|
+
* registered, else the incremental provider run over the whole string, else core's
|
|
2040
|
+
* default (escape + `<br>`).
|
|
2041
|
+
*
|
|
2042
|
+
* The middle step is what makes the incremental provider enough on its own. Without
|
|
2043
|
+
* it a reply rendered two ways depending on how it arrived: rich while it streamed,
|
|
2044
|
+
* escaped source once it came back complete — a restored conversation, a
|
|
2045
|
+
* non-streaming provider, a stored segment. Same parser, same sanitizer, so the two
|
|
2046
|
+
* cannot disagree. It needs a `document` to write into; without one (a server render)
|
|
2047
|
+
* the default answers, as before.
|
|
2039
2048
|
*/
|
|
2040
2049
|
renderMarkdown(raw) {
|
|
2041
2050
|
if (this._markdownProvider) {
|
|
@@ -2044,6 +2053,16 @@ class AparteConfig {
|
|
|
2044
2053
|
} catch (error) {
|
|
2045
2054
|
console.warn("[AparteConfig] Markdown provider failed, using fallback:", error);
|
|
2046
2055
|
}
|
|
2056
|
+
} else if (this._streamingMarkdownProvider && typeof document !== "undefined") {
|
|
2057
|
+
try {
|
|
2058
|
+
const target = document.createElement("div");
|
|
2059
|
+
const renderer = this._streamingMarkdownProvider(target);
|
|
2060
|
+
renderer.write(raw);
|
|
2061
|
+
renderer.end();
|
|
2062
|
+
return this.sanitizeHtml(target.innerHTML);
|
|
2063
|
+
} catch (error) {
|
|
2064
|
+
console.warn("[AparteConfig] Streaming Markdown provider failed on a complete string, using fallback:", error);
|
|
2065
|
+
}
|
|
2047
2066
|
}
|
|
2048
2067
|
return this._defaultMarkdownRenderer(raw);
|
|
2049
2068
|
}
|
|
@@ -6996,4 +7015,4 @@ export {
|
|
|
6996
7015
|
collectRendererStyles as y,
|
|
6997
7016
|
contentToText as z
|
|
6998
7017
|
};
|
|
6999
|
-
//# sourceMappingURL=dialog-triggers-
|
|
7018
|
+
//# sourceMappingURL=dialog-triggers-DwTGKWeU.js.map
|