MCPcopy Create free account
hub / github.com/Alphanimble/htmlstream / syncStreamingCaret

Function syncStreamingCaret

src/patch-streaming-html.ts:907–928  ·  view source on GitHub ↗
(
  container: HTMLElement,
  html: string,
  track?: string,
)

Source from the content-addressed store, hash-verified

905}
906
907export function syncStreamingCaret(
908 container: HTMLElement,
909 html: string,
910 track?: string,
911): void {
912 if (!CARET_RE.test(html)) {
913 removeStreamingCarets(container);
914 return;
915 }
916
917 const cleanTrack = stripCaret(track ?? html);
918 const caret = acquireStreamingCaret(container);
919
920 if (!shouldShowStreamingCaret(cleanTrack)) {
921 setStreamingCaretVisible(caret, false);
922 return;
923 }
924
925 setStreamingCaretVisible(caret, true);
926 const { range, fallback } = resolveStreamCaretRange(container, cleanTrack);
927 positionStreamingCaretAtRange(caret, container, range, fallback);
928}
929
930/** Reset patch state when doing a full innerHTML replace */
931export function resetPatchState(container: HTMLElement): void {

Callers 7

placeStreamingCaretFunction · 0.90
streamhtml.tsxFile · 0.90
patchPostTableTailFunction · 0.85
patchFirstTableStreamFunction · 0.85
patchStreamingHtmlFunction · 0.85
patchTableRowsFunction · 0.85

Calls 7

acquireStreamingCaretFunction · 0.90
setStreamingCaretVisibleFunction · 0.90
removeStreamingCaretsFunction · 0.85
shouldShowStreamingCaretFunction · 0.85
resolveStreamCaretRangeFunction · 0.85
stripCaretFunction · 0.70

Tested by

no test coverage detected