@aparte/core 1.0.0 → 1.0.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.
@@ -2738,8 +2738,12 @@ const textRenderer = {
2738
2738
  setup: (el2, segment) => {
2739
2739
  const contentEl = el2.querySelector(".aparte-segment-content");
2740
2740
  if (!contentEl) return;
2741
- renderCodeLanguages(contentEl, { streaming: segment.isStreaming === true });
2742
- if (segment.isStreaming !== true) highlightMarkdownFences(contentEl);
2741
+ if (segment.isStreaming === true) {
2742
+ writeStreamedMarkdown(el2, contentEl, segment.content, true);
2743
+ } else {
2744
+ renderCodeLanguages(contentEl, { streaming: false });
2745
+ highlightMarkdownFences(contentEl);
2746
+ }
2743
2747
  renderCitations(contentEl, segment);
2744
2748
  },
2745
2749
  update: (el2, segment) => {
@@ -2826,7 +2830,9 @@ const thinkingRenderer = {
2826
2830
  /** A block restored from storage is drawn here: `update` only runs on one that changes. */
2827
2831
  setup: (el2, segment) => {
2828
2832
  const contentEl = el2.querySelector(".aparte-thinking-content");
2829
- if (contentEl) renderCodeLanguages(contentEl, { streaming: arriving(segment) });
2833
+ if (!contentEl) return;
2834
+ if (arriving(segment)) writeStreamedMarkdown(el2, contentEl, segment.content, true);
2835
+ else renderCodeLanguages(contentEl, { streaming: false });
2830
2836
  },
2831
2837
  update: (el2, segment) => {
2832
2838
  setLabel(el2, segment);
@@ -6557,6 +6563,13 @@ function defineMountedSegmentRenderer(type, mount) {
6557
6563
  mountedRenderers.add(renderer);
6558
6564
  return renderer;
6559
6565
  }
6566
+ function withLastArriving(message) {
6567
+ const segments = message.segments;
6568
+ const last = segments[segments.length - 1];
6569
+ if (message.status !== "streaming" || !last || last.isStreaming !== void 0) return segments;
6570
+ if (last.type !== "text" && last.type !== "thinking") return segments;
6571
+ return [...segments.slice(0, -1), { ...last, isStreaming: true }];
6572
+ }
6560
6573
  function populateBubbleFromMessage(bubble, message, siblingInfo) {
6561
6574
  if (message.segments && message.segments.length > 0) {
6562
6575
  const existing = bubble.getSegments?.() ?? [];
@@ -6572,7 +6585,7 @@ function populateBubbleFromMessage(bubble, message, siblingInfo) {
6572
6585
  }
6573
6586
  }
6574
6587
  } else {
6575
- bubble.setSegments?.(message.segments);
6588
+ bubble.setSegments?.(withLastArriving(message));
6576
6589
  }
6577
6590
  } else if (message.content !== void 0) {
6578
6591
  bubble.setContent?.(message.content);
@@ -11312,4 +11325,4 @@ export {
11312
11325
  collectRendererStyles as y,
11313
11326
  contentToText as z
11314
11327
  };
11315
- //# sourceMappingURL=defer-hydration-Dw5D80FC.js.map
11328
+ //# sourceMappingURL=defer-hydration-_SZv5PeY.js.map