@fleetagent/pi-tui 0.1.8 → 0.2.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/README.md +47 -7
- package/dist/autocomplete.d.ts +17 -23
- package/dist/autocomplete.d.ts.map +1 -1
- package/dist/autocomplete.js +129 -195
- package/dist/autocomplete.js.map +1 -1
- package/dist/components/alt-screen-flash.d.ts +13 -0
- package/dist/components/alt-screen-flash.d.ts.map +1 -0
- package/dist/components/alt-screen-flash.js +37 -0
- package/dist/components/alt-screen-flash.js.map +1 -0
- package/dist/components/editor.d.ts +47 -4
- package/dist/components/editor.d.ts.map +1 -1
- package/dist/components/editor.js +615 -585
- package/dist/components/editor.js.map +1 -1
- package/dist/components/h-stack.d.ts +7 -0
- package/dist/components/h-stack.d.ts.map +1 -0
- package/dist/components/h-stack.js +43 -0
- package/dist/components/h-stack.js.map +1 -0
- package/dist/components/image.d.ts +4 -0
- package/dist/components/image.d.ts.map +1 -1
- package/dist/components/image.js +38 -51
- package/dist/components/image.js.map +1 -1
- package/dist/components/input.d.ts +9 -0
- package/dist/components/input.d.ts.map +1 -1
- package/dist/components/input.js +121 -147
- package/dist/components/input.js.map +1 -1
- package/dist/components/markdown.d.ts +34 -0
- package/dist/components/markdown.d.ts.map +1 -1
- package/dist/components/markdown.js +491 -429
- package/dist/components/markdown.js.map +1 -1
- package/dist/components/scroll-view.d.ts +53 -0
- package/dist/components/scroll-view.d.ts.map +1 -0
- package/dist/components/scroll-view.js +173 -0
- package/dist/components/scroll-view.js.map +1 -0
- package/dist/components/select-list.d.ts.map +1 -1
- package/dist/components/select-list.js.map +1 -1
- package/dist/components/settings-list.d.ts +2 -0
- package/dist/components/settings-list.d.ts.map +1 -1
- package/dist/components/settings-list.js +31 -29
- package/dist/components/settings-list.js.map +1 -1
- package/dist/components/stack.d.ts +32 -0
- package/dist/components/stack.d.ts.map +1 -0
- package/dist/components/stack.js +122 -0
- package/dist/components/stack.js.map +1 -0
- package/dist/components/v-stack.d.ts +8 -0
- package/dist/components/v-stack.d.ts.map +1 -0
- package/dist/components/v-stack.js +27 -0
- package/dist/components/v-stack.js.map +1 -0
- package/dist/fuzzy.d.ts.map +1 -1
- package/dist/fuzzy.js +37 -46
- package/dist/fuzzy.js.map +1 -1
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/keybindings.d.ts +54 -4
- package/dist/keybindings.d.ts.map +1 -1
- package/dist/keybindings.js +39 -4
- package/dist/keybindings.js.map +1 -1
- package/dist/keys.d.ts.map +1 -1
- package/dist/keys.js +359 -479
- package/dist/keys.js.map +1 -1
- package/dist/kill-ring.d.ts +6 -4
- package/dist/kill-ring.d.ts.map +1 -1
- package/dist/kill-ring.js +0 -7
- package/dist/kill-ring.js.map +1 -1
- package/dist/latex.d.ts +10 -0
- package/dist/latex.d.ts.map +1 -0
- package/dist/latex.js +1406 -0
- package/dist/latex.js.map +1 -0
- package/dist/layout-node.d.ts +43 -0
- package/dist/layout-node.d.ts.map +1 -0
- package/dist/layout-node.js +6 -0
- package/dist/layout-node.js.map +1 -0
- package/dist/layout.d.ts +40 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +386 -0
- package/dist/layout.js.map +1 -0
- package/dist/stdin-buffer.d.ts +8 -0
- package/dist/stdin-buffer.d.ts.map +1 -1
- package/dist/stdin-buffer.js +116 -159
- package/dist/stdin-buffer.js.map +1 -1
- package/dist/terminal-image.d.ts +41 -19
- package/dist/terminal-image.d.ts.map +1 -1
- package/dist/terminal-image.js +171 -32
- package/dist/terminal-image.js.map +1 -1
- package/dist/terminal.d.ts +3 -0
- package/dist/terminal.d.ts.map +1 -1
- package/dist/terminal.js +27 -23
- package/dist/terminal.js.map +1 -1
- package/dist/tui-alt-screen.d.ts +114 -0
- package/dist/tui-alt-screen.d.ts.map +1 -0
- package/dist/tui-alt-screen.js +950 -0
- package/dist/tui-alt-screen.js.map +1 -0
- package/dist/tui-main-screen.d.ts +52 -0
- package/dist/tui-main-screen.d.ts.map +1 -0
- package/dist/tui-main-screen.js +511 -0
- package/dist/tui-main-screen.js.map +1 -0
- package/dist/tui.d.ts +112 -44
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +489 -699
- package/dist/tui.js.map +1 -1
- package/dist/utils.d.ts +29 -17
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +605 -528
- package/dist/utils.js.map +1 -1
- package/dist/word-navigation.d.ts.map +1 -1
- package/dist/word-navigation.js +37 -39
- package/dist/word-navigation.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/components/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,SAAS,EAAe,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE/E,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpF,MAAM,0BAA0B,GAAG,8DAA8D,CAAC;AAClG,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAE9C,SAAS,iBAAiB,CAAC,IAAY,EAAU;IAChD,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;AAAA,CAC5C;AAED,MAAM,4BAA6B,SAAQ,SAAS;IAC1C,GAAG,CAAC,GAAW,EAA0B;QACjD,MAAM,KAAK,GAAG,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnD,IAAI,CAAC,KAAK,EAAE,CAAC;YACZ,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,OAAO;YACN,IAAI,EAAE,KAAK;YACX,GAAG,EAAE,KAAK,CAAC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EAAE,EAAE,CAAC,KAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACjE,KAAK,CAAC,IAAI,CAAC,SAAK,iBAAiB,CAAC,IAAI,CAAC,WAAK,CAAC,QAAI,CAAC,CAAC;QAEnD,IAAI,aAAa,IAAI,aAAa,KAAK,OAAO,EAAE,CAAC;YAChD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,0BAA0B;QAC3C,CAAC;QACD,OAAO,KAAK,CAAC;IAAA,CACb;CACD","sourcesContent":["import { Marked, type Token, Tokenizer, type Tokens } from \"marked\";\nimport { getCapabilities, hyperlink, isImageLine } from \"../terminal-image.ts\";\nimport type { Component } from \"../tui.ts\";\nimport { applyBackgroundToLine, visibleWidth, wrapTextWithAnsi } from \"../utils.ts\";\n\nconst STRICT_STRIKETHROUGH_REGEX = /^(~~)(?=[^\\s~])((?:\\\\.|[^\\\\])*?(?:\\\\.|[^\\s~\\\\]))\\1(?=[^~]|$)/;\nconst HTML_COMMENT_REGEX = /<!--[\\s\\S]*?-->/g;\n\nfunction stripHtmlComments(html: string): string {\n\treturn html.replace(HTML_COMMENT_REGEX, \"\");\n}\n\nclass StrictStrikethroughTokenizer extends Tokenizer {\n\toverride del(src: string): Tokens.Del | undefined {\n\t\tconst match = STRICT_STRIKETHROUGH_REGEX.exec(src);\n\t\tif (!match) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst text = match[2];\n\t\treturn {\n\t\t\ttype: \"del\",\n\t\t\traw: match[0],\n\t\t\ttext,\n\t\t\ttokens: this.lexer.inlineTokens(text),\n\t\t};\n\t}\n}\n\nconst markdownParser = new Marked();\nmarkdownParser.setOptions({\n\ttokenizer: new StrictStrikethroughTokenizer(),\n});\n\n/**\n * Default text styling for markdown content.\n * Applied to all text unless overridden by markdown formatting.\n */\nexport interface DefaultTextStyle {\n\t/** Foreground color function */\n\tcolor?: (text: string) => string;\n\t/** Background color function */\n\tbgColor?: (text: string) => string;\n\t/** Bold text */\n\tbold?: boolean;\n\t/** Italic text */\n\titalic?: boolean;\n\t/** Strikethrough text */\n\tstrikethrough?: boolean;\n\t/** Underline text */\n\tunderline?: boolean;\n}\n\n/**\n * Theme functions for markdown elements.\n * Each function takes text and returns styled text with ANSI codes.\n */\nexport interface MarkdownTheme {\n\theading: (text: string) => string;\n\tlink: (text: string) => string;\n\tlinkUrl: (text: string) => string;\n\tcode: (text: string) => string;\n\tcodeBlock: (text: string) => string;\n\tcodeBlockBorder: (text: string) => string;\n\tquote: (text: string) => string;\n\tquoteBorder: (text: string) => string;\n\thr: (text: string) => string;\n\tlistBullet: (text: string) => string;\n\tbold: (text: string) => string;\n\titalic: (text: string) => string;\n\tstrikethrough: (text: string) => string;\n\tunderline: (text: string) => string;\n\thighlightCode?: (code: string, lang?: string) => string[];\n\t/** Prefix applied to each rendered code block line (default: \" \") */\n\tcodeBlockIndent?: string;\n}\n\nexport interface MarkdownOptions {\n\t/** Preserve source ordered-list markers instead of normalizing them from the list start. */\n\tpreserveOrderedListMarkers?: boolean;\n\t/** Preserve source backslash escapes instead of normalizing escaped punctuation. */\n\tpreserveBackslashEscapes?: boolean;\n}\n\ninterface InlineStyleContext {\n\tapplyText: (text: string) => string;\n\tstylePrefix: string;\n}\n\nexport class Markdown implements Component {\n\tprivate text: string;\n\tprivate paddingX: number; // Left/right padding\n\tprivate paddingY: number; // Top/bottom padding\n\tprivate defaultTextStyle?: DefaultTextStyle;\n\tprivate theme: MarkdownTheme;\n\tprivate options: MarkdownOptions;\n\tprivate defaultStylePrefix?: string;\n\n\t// Cache for rendered output\n\tprivate cachedText?: string;\n\tprivate cachedWidth?: number;\n\tprivate cachedLines?: string[];\n\n\tconstructor(\n\t\ttext: string,\n\t\tpaddingX: number,\n\t\tpaddingY: number,\n\t\ttheme: MarkdownTheme,\n\t\tdefaultTextStyle?: DefaultTextStyle,\n\t\toptions?: MarkdownOptions,\n\t) {\n\t\tthis.text = text;\n\t\tthis.paddingX = paddingX;\n\t\tthis.paddingY = paddingY;\n\t\tthis.theme = theme;\n\t\tthis.defaultTextStyle = defaultTextStyle;\n\t\tthis.options = options ? { ...options } : {};\n\t}\n\n\tsetText(text: string): void {\n\t\tthis.text = text;\n\t\tthis.invalidate();\n\t}\n\n\tinvalidate(): void {\n\t\tthis.cachedText = undefined;\n\t\tthis.cachedWidth = undefined;\n\t\tthis.cachedLines = undefined;\n\t}\n\n\trender(width: number): string[] {\n\t\t// Check cache\n\t\tif (this.cachedLines && this.cachedText === this.text && this.cachedWidth === width) {\n\t\t\treturn this.cachedLines;\n\t\t}\n\n\t\t// Calculate available width for content (subtract horizontal padding)\n\t\tconst contentWidth = Math.max(1, width - this.paddingX * 2);\n\n\t\t// Don't render anything if there's no actual text\n\t\tif (!this.text || this.text.trim() === \"\") {\n\t\t\tconst result: string[] = [];\n\t\t\t// Update cache\n\t\t\tthis.cachedText = this.text;\n\t\t\tthis.cachedWidth = width;\n\t\t\tthis.cachedLines = result;\n\t\t\treturn result;\n\t\t}\n\n\t\t// Replace tabs with 3 spaces for consistent rendering\n\t\tconst normalizedText = this.text.replace(/\\t/g, \" \");\n\n\t\t// Parse markdown to HTML-like tokens\n\t\tconst tokens = markdownParser.lexer(normalizedText);\n\n\t\t// Convert tokens to styled terminal output\n\t\tconst renderedLines: string[] = [];\n\n\t\tfor (let i = 0; i < tokens.length; i++) {\n\t\t\tconst token = tokens[i];\n\t\t\tconst nextToken = tokens[i + 1];\n\t\t\tconst tokenLines = this.renderToken(token, contentWidth, nextToken?.type);\n\t\t\tfor (const tokenLine of tokenLines) {\n\t\t\t\trenderedLines.push(tokenLine);\n\t\t\t}\n\t\t}\n\n\t\t// Wrap lines (NO padding, NO background yet)\n\t\tconst wrappedLines: string[] = [];\n\t\tfor (const line of renderedLines) {\n\t\t\tif (isImageLine(line)) {\n\t\t\t\twrappedLines.push(line);\n\t\t\t} else {\n\t\t\t\tfor (const wrappedLine of wrapTextWithAnsi(line, contentWidth)) {\n\t\t\t\t\twrappedLines.push(wrappedLine);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Add margins and background to each wrapped line\n\t\tconst leftMargin = \" \".repeat(this.paddingX);\n\t\tconst rightMargin = \" \".repeat(this.paddingX);\n\t\tconst bgFn = this.defaultTextStyle?.bgColor;\n\t\tconst contentLines: string[] = [];\n\n\t\tfor (const line of wrappedLines) {\n\t\t\tif (isImageLine(line)) {\n\t\t\t\tcontentLines.push(line);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst lineWithMargins = leftMargin + line + rightMargin;\n\n\t\t\tif (bgFn) {\n\t\t\t\tcontentLines.push(applyBackgroundToLine(lineWithMargins, width, bgFn));\n\t\t\t} else {\n\t\t\t\t// No background - just pad to width\n\t\t\t\tconst visibleLen = visibleWidth(lineWithMargins);\n\t\t\t\tconst paddingNeeded = Math.max(0, width - visibleLen);\n\t\t\t\tcontentLines.push(lineWithMargins + \" \".repeat(paddingNeeded));\n\t\t\t}\n\t\t}\n\n\t\t// Add top/bottom padding (empty lines)\n\t\tconst emptyLine = \" \".repeat(width);\n\t\tconst emptyLines: string[] = [];\n\t\tfor (let i = 0; i < this.paddingY; i++) {\n\t\t\tconst line = bgFn ? applyBackgroundToLine(emptyLine, width, bgFn) : emptyLine;\n\t\t\temptyLines.push(line);\n\t\t}\n\n\t\t// Combine top padding, content, and bottom padding\n\t\tconst result = emptyLines.concat(contentLines, emptyLines);\n\n\t\t// Update cache\n\t\tthis.cachedText = this.text;\n\t\tthis.cachedWidth = width;\n\t\tthis.cachedLines = result;\n\n\t\treturn result.length > 0 ? result : [\"\"];\n\t}\n\n\t/**\n\t * Apply default text style to a string.\n\t * This is the base styling applied to all text content.\n\t * NOTE: Background color is NOT applied here - it's applied at the padding stage\n\t * to ensure it extends to the full line width.\n\t */\n\tprivate applyDefaultStyle(text: string): string {\n\t\tif (!this.defaultTextStyle) {\n\t\t\treturn text;\n\t\t}\n\n\t\tlet styled = text;\n\n\t\t// Apply foreground color (NOT background - that's applied at padding stage)\n\t\tif (this.defaultTextStyle.color) {\n\t\t\tstyled = this.defaultTextStyle.color(styled);\n\t\t}\n\n\t\t// Apply text decorations using this.theme\n\t\tif (this.defaultTextStyle.bold) {\n\t\t\tstyled = this.theme.bold(styled);\n\t\t}\n\t\tif (this.defaultTextStyle.italic) {\n\t\t\tstyled = this.theme.italic(styled);\n\t\t}\n\t\tif (this.defaultTextStyle.strikethrough) {\n\t\t\tstyled = this.theme.strikethrough(styled);\n\t\t}\n\t\tif (this.defaultTextStyle.underline) {\n\t\t\tstyled = this.theme.underline(styled);\n\t\t}\n\n\t\treturn styled;\n\t}\n\n\tprivate getDefaultStylePrefix(): string {\n\t\tif (!this.defaultTextStyle) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\tif (this.defaultStylePrefix !== undefined) {\n\t\t\treturn this.defaultStylePrefix;\n\t\t}\n\n\t\tconst sentinel = \"\\u0000\";\n\t\tlet styled = sentinel;\n\n\t\tif (this.defaultTextStyle.color) {\n\t\t\tstyled = this.defaultTextStyle.color(styled);\n\t\t}\n\n\t\tif (this.defaultTextStyle.bold) {\n\t\t\tstyled = this.theme.bold(styled);\n\t\t}\n\t\tif (this.defaultTextStyle.italic) {\n\t\t\tstyled = this.theme.italic(styled);\n\t\t}\n\t\tif (this.defaultTextStyle.strikethrough) {\n\t\t\tstyled = this.theme.strikethrough(styled);\n\t\t}\n\t\tif (this.defaultTextStyle.underline) {\n\t\t\tstyled = this.theme.underline(styled);\n\t\t}\n\n\t\tconst sentinelIndex = styled.indexOf(sentinel);\n\t\tthis.defaultStylePrefix = sentinelIndex >= 0 ? styled.slice(0, sentinelIndex) : \"\";\n\t\treturn this.defaultStylePrefix;\n\t}\n\n\tprivate getStylePrefix(styleFn: (text: string) => string): string {\n\t\tconst sentinel = \"\\u0000\";\n\t\tconst styled = styleFn(sentinel);\n\t\tconst sentinelIndex = styled.indexOf(sentinel);\n\t\treturn sentinelIndex >= 0 ? styled.slice(0, sentinelIndex) : \"\";\n\t}\n\n\tprivate getDefaultInlineStyleContext(): InlineStyleContext {\n\t\treturn {\n\t\t\tapplyText: (text: string) => this.applyDefaultStyle(text),\n\t\t\tstylePrefix: this.getDefaultStylePrefix(),\n\t\t};\n\t}\n\n\tprivate renderToken(\n\t\ttoken: Token,\n\t\twidth: number,\n\t\tnextTokenType?: string,\n\t\tstyleContext?: InlineStyleContext,\n\t): string[] {\n\t\tconst lines: string[] = [];\n\n\t\tswitch (token.type) {\n\t\t\tcase \"heading\": {\n\t\t\t\tconst headingLevel = token.depth;\n\t\t\t\tconst headingPrefix = `${\"#\".repeat(headingLevel)} `;\n\n\t\t\t\t// Build a heading-specific style context so inline tokens (codespan, bold, etc.)\n\t\t\t\t// restore heading styling after their own ANSI resets instead of falling back to\n\t\t\t\t// the default text style.\n\t\t\t\tlet headingStyleFn: (text: string) => string;\n\t\t\t\tif (headingLevel === 1) {\n\t\t\t\t\theadingStyleFn = (text: string) => this.theme.heading(this.theme.bold(this.theme.underline(text)));\n\t\t\t\t} else {\n\t\t\t\t\theadingStyleFn = (text: string) => this.theme.heading(this.theme.bold(text));\n\t\t\t\t}\n\n\t\t\t\tconst headingStyleContext: InlineStyleContext = {\n\t\t\t\t\tapplyText: headingStyleFn,\n\t\t\t\t\tstylePrefix: this.getStylePrefix(headingStyleFn),\n\t\t\t\t};\n\n\t\t\t\tconst headingText = this.renderInlineTokens(token.tokens || [], headingStyleContext);\n\t\t\t\tconst styledHeading = headingLevel >= 3 ? headingStyleFn(headingPrefix) + headingText : headingText;\n\t\t\t\tlines.push(styledHeading);\n\t\t\t\tif (nextTokenType && nextTokenType !== \"space\") {\n\t\t\t\t\tlines.push(\"\"); // Add spacing after headings (unless space token follows)\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"paragraph\": {\n\t\t\t\tconst paragraphText = this.renderInlineTokens(token.tokens || [], styleContext);\n\t\t\t\tlines.push(paragraphText);\n\t\t\t\t// Don't add spacing if next token is space or list\n\t\t\t\tif (nextTokenType && nextTokenType !== \"list\" && nextTokenType !== \"space\") {\n\t\t\t\t\tlines.push(\"\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"text\":\n\t\t\t\tlines.push(this.renderInlineTokens([token], styleContext));\n\t\t\t\tbreak;\n\n\t\t\tcase \"code\": {\n\t\t\t\tconst indent = this.theme.codeBlockIndent ?? \" \";\n\t\t\t\tlines.push(this.theme.codeBlockBorder(`\\`\\`\\`${token.lang || \"\"}`));\n\t\t\t\tif (this.theme.highlightCode) {\n\t\t\t\t\tconst highlightedLines = this.theme.highlightCode(token.text, token.lang);\n\t\t\t\t\tfor (const hlLine of highlightedLines) {\n\t\t\t\t\t\tlines.push(`${indent}${hlLine}`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Split code by newlines and style each line\n\t\t\t\t\tconst codeLines = token.text.split(\"\\n\");\n\t\t\t\t\tfor (const codeLine of codeLines) {\n\t\t\t\t\t\tlines.push(`${indent}${this.theme.codeBlock(codeLine)}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tlines.push(this.theme.codeBlockBorder(\"```\"));\n\t\t\t\tif (nextTokenType && nextTokenType !== \"space\") {\n\t\t\t\t\tlines.push(\"\"); // Add spacing after code blocks (unless space token follows)\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"list\": {\n\t\t\t\tconst listLines = this.renderList(token as Tokens.List, 0, width, styleContext);\n\t\t\t\tlines.push(...listLines);\n\t\t\t\t// Don't add spacing after lists if a space token follows\n\t\t\t\t// (the space token will handle it)\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"table\": {\n\t\t\t\tconst tableLines = this.renderTable(token as Tokens.Table, width, nextTokenType, styleContext);\n\t\t\t\tlines.push(...tableLines);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"blockquote\": {\n\t\t\t\tconst quoteStyle = (text: string) => this.theme.quote(this.theme.italic(text));\n\t\t\t\tconst quoteStylePrefix = this.getStylePrefix(quoteStyle);\n\t\t\t\tconst applyQuoteStyle = (line: string): string => {\n\t\t\t\t\tif (!quoteStylePrefix) {\n\t\t\t\t\t\treturn quoteStyle(line);\n\t\t\t\t\t}\n\t\t\t\t\tconst lineWithReappliedStyle = line.replace(/\\x1b\\[0m/g, `\\x1b[0m${quoteStylePrefix}`);\n\t\t\t\t\treturn quoteStyle(lineWithReappliedStyle);\n\t\t\t\t};\n\n\t\t\t\t// Calculate available width for quote content (subtract border \"│ \" = 2 chars)\n\t\t\t\tconst quoteContentWidth = Math.max(1, width - 2);\n\n\t\t\t\t// Blockquotes contain block-level tokens (paragraph, list, code, etc.), so render\n\t\t\t\t// children with renderToken() instead of renderInlineTokens().\n\t\t\t\t// Default message style should not apply inside blockquotes.\n\t\t\t\tconst quoteInlineStyleContext: InlineStyleContext = {\n\t\t\t\t\tapplyText: (text: string) => text,\n\t\t\t\t\tstylePrefix: quoteStylePrefix,\n\t\t\t\t};\n\t\t\t\tconst quoteTokens = token.tokens || [];\n\t\t\t\tconst renderedQuoteLines: string[] = [];\n\t\t\t\tfor (let i = 0; i < quoteTokens.length; i++) {\n\t\t\t\t\tconst quoteToken = quoteTokens[i];\n\t\t\t\t\tconst nextQuoteToken = quoteTokens[i + 1];\n\t\t\t\t\trenderedQuoteLines.push(\n\t\t\t\t\t\t...this.renderToken(quoteToken, quoteContentWidth, nextQuoteToken?.type, quoteInlineStyleContext),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Avoid rendering an extra empty quote line before the outer blockquote spacing.\n\t\t\t\twhile (renderedQuoteLines.length > 0 && renderedQuoteLines[renderedQuoteLines.length - 1] === \"\") {\n\t\t\t\t\trenderedQuoteLines.pop();\n\t\t\t\t}\n\n\t\t\t\tfor (const quoteLine of renderedQuoteLines) {\n\t\t\t\t\tconst styledLine = applyQuoteStyle(quoteLine);\n\t\t\t\t\tconst wrappedLines = wrapTextWithAnsi(styledLine, quoteContentWidth);\n\t\t\t\t\tfor (const wrappedLine of wrappedLines) {\n\t\t\t\t\t\tlines.push(this.theme.quoteBorder(\"│ \") + wrappedLine);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (nextTokenType && nextTokenType !== \"space\") {\n\t\t\t\t\tlines.push(\"\"); // Add spacing after blockquotes (unless space token follows)\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"hr\":\n\t\t\t\tlines.push(this.theme.hr(\"─\".repeat(Math.min(width, 80))));\n\t\t\t\tif (nextTokenType && nextTokenType !== \"space\") {\n\t\t\t\t\tlines.push(\"\"); // Add spacing after horizontal rules (unless space token follows)\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase \"html\":\n\t\t\t\t// HTML comments are invisible in Markdown; render other HTML as plain text.\n\t\t\t\tif (\"raw\" in token && typeof token.raw === \"string\") {\n\t\t\t\t\tconst visibleHtml = stripHtmlComments(token.raw).trim();\n\t\t\t\t\tif (visibleHtml) lines.push(this.applyDefaultStyle(visibleHtml));\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase \"space\":\n\t\t\t\t// Space tokens represent blank lines in markdown\n\t\t\t\tlines.push(\"\");\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\t// Handle any other token types as plain text\n\t\t\t\tif (\"text\" in token && typeof token.text === \"string\") {\n\t\t\t\t\tlines.push(token.text);\n\t\t\t\t}\n\t\t}\n\n\t\treturn lines;\n\t}\n\n\tprivate renderInlineTokens(tokens: Token[], styleContext?: InlineStyleContext): string {\n\t\tlet result = \"\";\n\t\tconst resolvedStyleContext = styleContext ?? this.getDefaultInlineStyleContext();\n\t\tconst { applyText, stylePrefix } = resolvedStyleContext;\n\t\tconst applyTextWithNewlines = (text: string): string => {\n\t\t\tconst segments: string[] = text.split(\"\\n\");\n\t\t\treturn segments.map((segment: string) => applyText(segment)).join(\"\\n\");\n\t\t};\n\n\t\tfor (const token of tokens) {\n\t\t\tswitch (token.type) {\n\t\t\t\tcase \"escape\":\n\t\t\t\t\tresult += applyTextWithNewlines(this.options.preserveBackslashEscapes ? token.raw : token.text);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"text\":\n\t\t\t\t\t// Text tokens in list items can have nested tokens for inline formatting\n\t\t\t\t\tif (token.tokens && token.tokens.length > 0) {\n\t\t\t\t\t\tresult += this.renderInlineTokens(token.tokens, resolvedStyleContext);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult += applyTextWithNewlines(token.text);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"paragraph\":\n\t\t\t\t\t// Paragraph tokens contain nested inline tokens\n\t\t\t\t\tresult += this.renderInlineTokens(token.tokens || [], resolvedStyleContext);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"strong\": {\n\t\t\t\t\tconst boldContent = this.renderInlineTokens(token.tokens || [], resolvedStyleContext);\n\t\t\t\t\tresult += this.theme.bold(boldContent) + stylePrefix;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"em\": {\n\t\t\t\t\tconst italicContent = this.renderInlineTokens(token.tokens || [], resolvedStyleContext);\n\t\t\t\t\tresult += this.theme.italic(italicContent) + stylePrefix;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"codespan\":\n\t\t\t\t\tresult += this.theme.code(token.text) + stylePrefix;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"link\": {\n\t\t\t\t\tconst linkText = this.renderInlineTokens(token.tokens || [], resolvedStyleContext);\n\t\t\t\t\tconst styledLink = this.theme.link(this.theme.underline(linkText));\n\t\t\t\t\tif (getCapabilities().hyperlinks) {\n\t\t\t\t\t\t// OSC 8: render as a clickable hyperlink. The URL is not printed inline,\n\t\t\t\t\t\t// so we always show only the link text regardless of whether it matches href.\n\t\t\t\t\t\tresult += hyperlink(styledLink, token.href) + stylePrefix;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Fallback: print URL in parentheses when text differs from href.\n\t\t\t\t\t\t// Compare raw token.text (not styled) against href for the equality check.\n\t\t\t\t\t\t// For mailto: links strip the prefix (autolinked emails use text=\"foo@bar.com\"\n\t\t\t\t\t\t// but href=\"mailto:foo@bar.com\").\n\t\t\t\t\t\tconst hrefForComparison = token.href.startsWith(\"mailto:\") ? token.href.slice(7) : token.href;\n\t\t\t\t\t\tif (token.text === token.href || token.text === hrefForComparison) {\n\t\t\t\t\t\t\tresult += styledLink + stylePrefix;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tresult += styledLink + this.theme.linkUrl(` (${token.href})`) + stylePrefix;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"br\":\n\t\t\t\t\tresult += \"\\n\";\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"del\": {\n\t\t\t\t\tconst delContent = this.renderInlineTokens(token.tokens || [], resolvedStyleContext);\n\t\t\t\t\tresult += this.theme.strikethrough(delContent) + stylePrefix;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"html\":\n\t\t\t\t\t// HTML comments are invisible in Markdown; render other inline HTML as plain text.\n\t\t\t\t\tif (\"raw\" in token && typeof token.raw === \"string\") {\n\t\t\t\t\t\tconst visibleHtml = stripHtmlComments(token.raw);\n\t\t\t\t\t\tif (visibleHtml) result += applyTextWithNewlines(visibleHtml);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\t// Handle any other inline token types as plain text\n\t\t\t\t\tif (\"text\" in token && typeof token.text === \"string\") {\n\t\t\t\t\t\tresult += applyTextWithNewlines(token.text);\n\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\twhile (stylePrefix && result.endsWith(stylePrefix)) {\n\t\t\tresult = result.slice(0, -stylePrefix.length);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprivate getOrderedListMarker(item: Tokens.ListItem): string | undefined {\n\t\tconst match = /^(?: {0,3})(\\d{1,9}[.)])[ \\t]+/.exec(item.raw);\n\t\treturn match ? `${match[1]} ` : undefined;\n\t}\n\n\t/**\n\t * Render a list with proper nesting support\n\t */\n\tprivate renderList(token: Tokens.List, depth: number, width: number, styleContext?: InlineStyleContext): string[] {\n\t\tconst lines: string[] = [];\n\t\tconst indent = \" \".repeat(depth);\n\t\t// Use the list's start property (defaults to 1 for ordered lists)\n\t\tconst startNumber = typeof token.start === \"number\" ? token.start : 1;\n\n\t\tfor (let i = 0; i < token.items.length; i++) {\n\t\t\tconst item = token.items[i];\n\t\t\tconst bullet = token.ordered\n\t\t\t\t? this.options.preserveOrderedListMarkers\n\t\t\t\t\t? (this.getOrderedListMarker(item) ?? `${startNumber + i}. `)\n\t\t\t\t\t: `${startNumber + i}. `\n\t\t\t\t: \"- \";\n\t\t\tconst taskMarker = item.task ? `[${item.checked ? \"x\" : \" \"}] ` : \"\";\n\t\t\tconst marker = bullet + taskMarker;\n\t\t\tconst firstPrefix = indent + this.theme.listBullet(marker);\n\t\t\tconst continuationPrefix = indent + \" \".repeat(visibleWidth(marker));\n\t\t\tconst itemWidth = Math.max(1, width - visibleWidth(firstPrefix));\n\t\t\tlet renderedAnyLine = false;\n\n\t\t\tfor (const itemToken of item.tokens) {\n\t\t\t\tif (itemToken.type === \"list\") {\n\t\t\t\t\tlines.push(...this.renderList(itemToken as Tokens.List, depth + 1, width, styleContext));\n\t\t\t\t\trenderedAnyLine = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst itemLines = this.renderToken(itemToken, itemWidth, undefined, styleContext);\n\t\t\t\tfor (const line of itemLines) {\n\t\t\t\t\tfor (const wrappedLine of wrapTextWithAnsi(line, itemWidth)) {\n\t\t\t\t\t\tconst linePrefix = renderedAnyLine ? continuationPrefix : firstPrefix;\n\t\t\t\t\t\tlines.push(linePrefix + wrappedLine);\n\t\t\t\t\t\trenderedAnyLine = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!renderedAnyLine) {\n\t\t\t\tlines.push(firstPrefix);\n\t\t\t}\n\t\t}\n\n\t\treturn lines;\n\t}\n\n\t/**\n\t * Get the visible width of the longest word in a string.\n\t */\n\tprivate getLongestWordWidth(text: string, maxWidth?: number): number {\n\t\tconst words = text.split(/\\s+/).filter((word) => word.length > 0);\n\t\tlet longest = 0;\n\t\tfor (const word of words) {\n\t\t\tlongest = Math.max(longest, visibleWidth(word));\n\t\t}\n\t\tif (maxWidth === undefined) {\n\t\t\treturn longest;\n\t\t}\n\t\treturn Math.min(longest, maxWidth);\n\t}\n\n\t/**\n\t * Wrap a table cell to fit into a column.\n\t *\n\t * Delegates to wrapTextWithAnsi() so ANSI codes + long tokens are handled\n\t * consistently with the rest of the renderer.\n\t */\n\tprivate wrapCellText(text: string, maxWidth: number): string[] {\n\t\treturn wrapTextWithAnsi(text, Math.max(1, maxWidth));\n\t}\n\n\t/**\n\t * Render a table with width-aware cell wrapping.\n\t * Cells that don't fit are wrapped to multiple lines.\n\t */\n\tprivate renderTable(\n\t\ttoken: Tokens.Table,\n\t\tavailableWidth: number,\n\t\tnextTokenType?: string,\n\t\tstyleContext?: InlineStyleContext,\n\t): string[] {\n\t\tconst lines: string[] = [];\n\t\tconst numCols = token.header.length;\n\n\t\tif (numCols === 0) {\n\t\t\treturn lines;\n\t\t}\n\n\t\t// Calculate border overhead: \"│ \" + (n-1) * \" │ \" + \" │\"\n\t\t// = 2 + (n-1) * 3 + 2 = 3n + 1\n\t\tconst borderOverhead = 3 * numCols + 1;\n\t\tconst availableForCells = availableWidth - borderOverhead;\n\t\tif (availableForCells < numCols) {\n\t\t\t// Too narrow to render a stable table. Fall back to raw markdown.\n\t\t\tconst fallbackLines = token.raw ? wrapTextWithAnsi(token.raw, availableWidth) : [];\n\t\t\tif (nextTokenType && nextTokenType !== \"space\") {\n\t\t\t\tfallbackLines.push(\"\");\n\t\t\t}\n\t\t\treturn fallbackLines;\n\t\t}\n\n\t\tconst maxUnbrokenWordWidth = 30;\n\n\t\t// Calculate natural column widths (what each column needs without constraints)\n\t\tconst naturalWidths: number[] = [];\n\t\tconst minWordWidths: number[] = [];\n\t\tfor (let i = 0; i < numCols; i++) {\n\t\t\tconst headerText = this.renderInlineTokens(token.header[i].tokens || [], styleContext);\n\t\t\tnaturalWidths[i] = visibleWidth(headerText);\n\t\t\tminWordWidths[i] = Math.max(1, this.getLongestWordWidth(headerText, maxUnbrokenWordWidth));\n\t\t}\n\t\tfor (const row of token.rows) {\n\t\t\tfor (let i = 0; i < row.length; i++) {\n\t\t\t\tconst cellText = this.renderInlineTokens(row[i].tokens || [], styleContext);\n\t\t\t\tnaturalWidths[i] = Math.max(naturalWidths[i] || 0, visibleWidth(cellText));\n\t\t\t\tminWordWidths[i] = Math.max(\n\t\t\t\t\tminWordWidths[i] || 1,\n\t\t\t\t\tthis.getLongestWordWidth(cellText, maxUnbrokenWordWidth),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tlet minColumnWidths = minWordWidths;\n\t\tlet minCellsWidth = minColumnWidths.reduce((a, b) => a + b, 0);\n\n\t\tif (minCellsWidth > availableForCells) {\n\t\t\tminColumnWidths = new Array(numCols).fill(1);\n\t\t\tconst remaining = availableForCells - numCols;\n\n\t\t\tif (remaining > 0) {\n\t\t\t\tconst totalWeight = minWordWidths.reduce((total, width) => total + Math.max(0, width - 1), 0);\n\t\t\t\tconst growth = minWordWidths.map((width) => {\n\t\t\t\t\tconst weight = Math.max(0, width - 1);\n\t\t\t\t\treturn totalWeight > 0 ? Math.floor((weight / totalWeight) * remaining) : 0;\n\t\t\t\t});\n\n\t\t\t\tfor (let i = 0; i < numCols; i++) {\n\t\t\t\t\tminColumnWidths[i] += growth[i] ?? 0;\n\t\t\t\t}\n\n\t\t\t\tconst allocated = growth.reduce((total, width) => total + width, 0);\n\t\t\t\tlet leftover = remaining - allocated;\n\t\t\t\tfor (let i = 0; leftover > 0 && i < numCols; i++) {\n\t\t\t\t\tminColumnWidths[i]++;\n\t\t\t\t\tleftover--;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tminCellsWidth = minColumnWidths.reduce((a, b) => a + b, 0);\n\t\t}\n\n\t\t// Calculate column widths that fit within available width\n\t\tconst totalNaturalWidth = naturalWidths.reduce((a, b) => a + b, 0) + borderOverhead;\n\t\tlet columnWidths: number[];\n\n\t\tif (totalNaturalWidth <= availableWidth) {\n\t\t\t// Everything fits naturally\n\t\t\tcolumnWidths = naturalWidths.map((width, index) => Math.max(width, minColumnWidths[index]));\n\t\t} else {\n\t\t\t// Need to shrink columns to fit\n\t\t\tconst totalGrowPotential = naturalWidths.reduce((total, width, index) => {\n\t\t\t\treturn total + Math.max(0, width - minColumnWidths[index]);\n\t\t\t}, 0);\n\t\t\tconst extraWidth = Math.max(0, availableForCells - minCellsWidth);\n\t\t\tcolumnWidths = minColumnWidths.map((minWidth, index) => {\n\t\t\t\tconst naturalWidth = naturalWidths[index];\n\t\t\t\tconst minWidthDelta = Math.max(0, naturalWidth - minWidth);\n\t\t\t\tlet grow = 0;\n\t\t\t\tif (totalGrowPotential > 0) {\n\t\t\t\t\tgrow = Math.floor((minWidthDelta / totalGrowPotential) * extraWidth);\n\t\t\t\t}\n\t\t\t\treturn minWidth + grow;\n\t\t\t});\n\n\t\t\t// Adjust for rounding errors - distribute remaining space\n\t\t\tconst allocated = columnWidths.reduce((a, b) => a + b, 0);\n\t\t\tlet remaining = availableForCells - allocated;\n\t\t\twhile (remaining > 0) {\n\t\t\t\tlet grew = false;\n\t\t\t\tfor (let i = 0; i < numCols && remaining > 0; i++) {\n\t\t\t\t\tif (columnWidths[i] < naturalWidths[i]) {\n\t\t\t\t\t\tcolumnWidths[i]++;\n\t\t\t\t\t\tremaining--;\n\t\t\t\t\t\tgrew = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!grew) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Render top border\n\t\tconst topBorderCells = columnWidths.map((w) => \"─\".repeat(w));\n\t\tlines.push(`┌─${topBorderCells.join(\"─┬─\")}─┐`);\n\n\t\t// Render header with wrapping\n\t\tconst headerCellLines: string[][] = token.header.map((cell, i) => {\n\t\t\tconst text = this.renderInlineTokens(cell.tokens || [], styleContext);\n\t\t\treturn this.wrapCellText(text, columnWidths[i]);\n\t\t});\n\t\tconst headerLineCount = Math.max(...headerCellLines.map((c) => c.length));\n\n\t\tfor (let lineIdx = 0; lineIdx < headerLineCount; lineIdx++) {\n\t\t\tconst rowParts = headerCellLines.map((cellLines, colIdx) => {\n\t\t\t\tconst text = cellLines[lineIdx] || \"\";\n\t\t\t\tconst padded = text + \" \".repeat(Math.max(0, columnWidths[colIdx] - visibleWidth(text)));\n\t\t\t\treturn this.theme.bold(padded);\n\t\t\t});\n\t\t\tlines.push(`│ ${rowParts.join(\" │ \")} │`);\n\t\t}\n\n\t\t// Render separator\n\t\tconst separatorCells = columnWidths.map((w) => \"─\".repeat(w));\n\t\tconst separatorLine = `├─${separatorCells.join(\"─┼─\")}─┤`;\n\t\tlines.push(separatorLine);\n\n\t\t// Render rows with wrapping\n\t\tfor (let rowIndex = 0; rowIndex < token.rows.length; rowIndex++) {\n\t\t\tconst row = token.rows[rowIndex];\n\t\t\tconst rowCellLines: string[][] = row.map((cell, i) => {\n\t\t\t\tconst text = this.renderInlineTokens(cell.tokens || [], styleContext);\n\t\t\t\treturn this.wrapCellText(text, columnWidths[i]);\n\t\t\t});\n\t\t\tconst rowLineCount = Math.max(...rowCellLines.map((c) => c.length));\n\n\t\t\tfor (let lineIdx = 0; lineIdx < rowLineCount; lineIdx++) {\n\t\t\t\tconst rowParts = rowCellLines.map((cellLines, colIdx) => {\n\t\t\t\t\tconst text = cellLines[lineIdx] || \"\";\n\t\t\t\t\treturn text + \" \".repeat(Math.max(0, columnWidths[colIdx] - visibleWidth(text)));\n\t\t\t\t});\n\t\t\t\tlines.push(`│ ${rowParts.join(\" │ \")} │`);\n\t\t\t}\n\n\t\t\tif (rowIndex < token.rows.length - 1) {\n\t\t\t\tlines.push(separatorLine);\n\t\t\t}\n\t\t}\n\n\t\t// Render bottom border\n\t\tconst bottomBorderCells = columnWidths.map((w) => \"─\".repeat(w));\n\t\tlines.push(`└─${bottomBorderCells.join(\"─┴─\")}─┘`);\n\n\t\tif (nextTokenType && nextTokenType !== \"space\") {\n\t\t\tlines.push(\"\"); // Add spacing after table\n\t\t}\n\t\treturn lines;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/components/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,SAAS,EAAwC,MAAM,QAAQ,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE/E,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpF,MAAM,0BAA0B,GAAG,8DAA8D,CAAC;AAClG,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAE9C,SAAS,iBAAiB,CAAC,IAAY,EAAU;IAChD,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;AAAA,CAC5C;AAED,MAAM,4BAA6B,SAAQ,SAAS;IAC1C,GAAG,CAAC,GAAW,EAA0B;QACjD,MAAM,KAAK,GAAG,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnD,IAAI,CAAC,KAAK,EAAE,CAAC;YACZ,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,OAAO;YACN,IAAI,EAAE,KAAK;YACX,GAAG,EAAE,KAAK,CAAC,C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,YAAY,EAAE,KAAG,EAAE,KAAG,EAAE,KAAG,CAAC,CAAC,CAAC;QAChE,IAAI,aAAa,IAAI,aAAa,KAAK,OAAO;YAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/D,OAAO,KAAK,CAAC;IAAA,CACb;CACD","sourcesContent":["import { Marked, type Token, Tokenizer, type TokenizerExtension, type Tokens } from \"marked\";\nimport { renderLatex } from \"../latex.ts\";\nimport { getCapabilities, hyperlink, isImageLine } from \"../terminal-image.ts\";\nimport type { Component } from \"../tui.ts\";\nimport { applyBackgroundToLine, visibleWidth, wrapTextWithAnsi } from \"../utils.ts\";\n\nconst STRICT_STRIKETHROUGH_REGEX = /^(~~)(?=[^\\s~])((?:\\\\.|[^\\\\])*?(?:\\\\.|[^\\s~\\\\]))\\1(?=[^~]|$)/;\nconst HTML_COMMENT_REGEX = /<!--[\\s\\S]*?-->/g;\n\nfunction stripHtmlComments(html: string): string {\n\treturn html.replace(HTML_COMMENT_REGEX, \"\");\n}\n\nclass StrictStrikethroughTokenizer extends Tokenizer {\n\toverride del(src: string): Tokens.Del | undefined {\n\t\tconst match = STRICT_STRIKETHROUGH_REGEX.exec(src);\n\t\tif (!match) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst text = match[2];\n\t\treturn {\n\t\t\ttype: \"del\",\n\t\t\traw: match[0],\n\t\t\ttext,\n\t\t\ttokens: this.lexer.inlineTokens(text),\n\t\t};\n\t}\n}\n\ntype LatexTokenType = \"latex\" | \"latexBlock\";\n\ninterface LatexToken extends Tokens.Generic {\n\ttype: LatexTokenType;\n\ttext: string;\n\tpending?: boolean;\n}\n\nfunction isEscaped(source: string, index: number): boolean {\n\tlet backslashes = 0;\n\tfor (let position = index - 1; position >= 0 && source[position] === \"\\\\\"; position--) {\n\t\tbackslashes++;\n\t}\n\treturn backslashes % 2 === 1;\n}\n\nfunction findClosingDelimiter(source: string, closing: string, start: number): number {\n\tlet index = source.indexOf(closing, start);\n\twhile (index >= 0 && isEscaped(source, index)) {\n\t\tindex = source.indexOf(closing, index + closing.length);\n\t}\n\treturn index;\n}\n\nfunction looksLikePendingDollarMath(source: string): boolean {\n\treturn /\\\\[A-Za-z]+|[_^=+*/<>()[\\]|±≤≥≠≈∈→⇒∞∫∑√-]/.test(source);\n}\n\nfunction looksLikeShellVariableChain(content: string, following: string): boolean {\n\treturn /^[A-Z_][A-Z0-9_]*(?:[/:.-][A-Za-z0-9_./:-]*)*$/.test(content) && /^[A-Za-z_][A-Za-z0-9_]*/.test(following);\n}\n\nfunction tokenizeInlineLatex(source: string): LatexToken | undefined {\n\tlet opening = \"\";\n\tlet closing = \"\";\n\tif (source.startsWith(\"$$\")) {\n\t\topening = \"$$\";\n\t\tclosing = \"$$\";\n\t} else if (source.startsWith(\"\\\\(\")) {\n\t\topening = \"\\\\(\";\n\t\tclosing = \"\\\\)\";\n\t} else if (source.startsWith(\"\\\\[\")) {\n\t\topening = \"\\\\[\";\n\t\tclosing = \"\\\\]\";\n\t} else if (source.startsWith(\"$\") && !/^\\$\\s/.test(source)) {\n\t\topening = \"$\";\n\t\tclosing = \"$\";\n\t} else {\n\t\treturn undefined;\n\t}\n\n\tconst closingIndex = findClosingDelimiter(source, closing, opening.length);\n\tif (\n\t\tclosingIndex >= 0 &&\n\t\topening === \"$\" &&\n\t\t(/\\s$/.test(source.slice(opening.length, closingIndex)) ||\n\t\t\t/^\\d/.test(source.slice(closingIndex + 1)) ||\n\t\t\tlooksLikeShellVariableChain(\n\t\t\t\tsource.slice(opening.length, closingIndex),\n\t\t\t\tsource.slice(closingIndex + closing.length),\n\t\t\t) ||\n\t\t\tsource.slice(opening.length, closingIndex).includes(\"`\"))\n\t) {\n\t\treturn undefined;\n\t}\n\n\tif (closingIndex < 0) {\n\t\tconst pendingSource = source.slice(opening.length);\n\t\tif (opening.startsWith(\"\\\\\") || looksLikePendingDollarMath(pendingSource)) {\n\t\t\treturn { type: \"latex\", raw: source, text: pendingSource, pending: true };\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconst text = source.slice(opening.length, closingIndex);\n\tif (!text || text.includes(\"\\n\")) {\n\t\treturn undefined;\n\t}\n\n\tconst raw = source.slice(0, closingIndex + closing.length);\n\treturn { type: \"latex\", raw, text };\n}\n\nfunction tokenizeBlockLatex(source: string): LatexToken | undefined {\n\tconst dollarMatch = /^ {0,3}\\$\\$[ \\t]*(?:\\n)?([\\s\\S]*?)\\$\\$[ \\t]*(?:\\n|$)/.exec(source);\n\tif (dollarMatch?.[1]) {\n\t\treturn { type: \"latexBlock\", raw: dollarMatch[0], text: dollarMatch[1].trim() };\n\t}\n\n\tconst bracketMatch = /^ {0,3}\\\\\\[[ \\t]*(?:\\n)?([\\s\\S]*?)\\\\\\][ \\t]*(?:\\n|$)/.exec(source);\n\tif (bracketMatch?.[1]) {\n\t\treturn { type: \"latexBlock\", raw: bracketMatch[0], text: bracketMatch[1].trim() };\n\t}\n\n\tconst pendingBracket = /^ {0,3}\\\\\\[[ \\t]*(?:\\n)?([\\s\\S]*)$/.exec(source);\n\tif (pendingBracket) {\n\t\treturn { type: \"latexBlock\", raw: pendingBracket[0], text: pendingBracket[1], pending: true };\n\t}\n\tconst pendingDollar = /^ {0,3}\\$\\$[ \\t]*(?:\\n)?([\\s\\S]*)$/.exec(source);\n\tif (pendingDollar?.[1] && looksLikePendingDollarMath(pendingDollar[1])) {\n\t\treturn { type: \"latexBlock\", raw: pendingDollar[0], text: pendingDollar[1], pending: true };\n\t}\n\treturn undefined;\n}\n\nconst LATEX_MARKDOWN_EXTENSIONS: readonly TokenizerExtension[] = [\n\t{\n\t\tname: \"latexBlock\",\n\t\tlevel: \"block\",\n\t\tstart(source) {\n\t\t\tconst match = /(?:^|\\n) {0,3}(?:\\$\\$|\\\\\\[)/.exec(source);\n\t\t\treturn match ? match.index + (match[0].startsWith(\"\\n\") ? 1 : 0) : undefined;\n\t\t},\n\t\ttokenizer: tokenizeBlockLatex,\n\t},\n\t{\n\t\tname: \"latex\",\n\t\tlevel: \"inline\",\n\t\tstart(source) {\n\t\t\tconst indices = [source.indexOf(\"$\"), source.indexOf(\"\\\\(\"), source.indexOf(\"\\\\[\")].filter(\n\t\t\t\t(index) => index >= 0,\n\t\t\t);\n\t\t\treturn indices.length > 0 ? Math.min(...indices) : undefined;\n\t\t},\n\t\ttokenizer: tokenizeInlineLatex,\n\t},\n];\n\nconst markdownParser = new Marked();\nmarkdownParser.setOptions({\n\ttokenizer: new StrictStrikethroughTokenizer(),\n});\nmarkdownParser.use({ extensions: [...LATEX_MARKDOWN_EXTENSIONS] });\n\n/**\n * Default text styling for markdown content.\n * Applied to all text unless overridden by markdown formatting.\n */\nexport interface DefaultTextStyle {\n\t/** Foreground color function */\n\tcolor?: (text: string) => string;\n\t/** Background color function */\n\tbgColor?: (text: string) => string;\n\t/** Bold text */\n\tbold?: boolean;\n\t/** Italic text */\n\titalic?: boolean;\n\t/** Strikethrough text */\n\tstrikethrough?: boolean;\n\t/** Underline text */\n\tunderline?: boolean;\n}\n\n/**\n * Theme functions for markdown elements.\n * Each function takes text and returns styled text with ANSI codes.\n */\nexport interface MarkdownTheme {\n\theading: (text: string) => string;\n\tlink: (text: string) => string;\n\tlinkUrl: (text: string) => string;\n\tcode: (text: string) => string;\n\tcodeBlock: (text: string) => string;\n\tcodeBlockBorder: (text: string) => string;\n\tquote: (text: string) => string;\n\tquoteBorder: (text: string) => string;\n\thr: (text: string) => string;\n\tlistBullet: (text: string) => string;\n\tbold: (text: string) => string;\n\titalic: (text: string) => string;\n\tstrikethrough: (text: string) => string;\n\tunderline: (text: string) => string;\n\thighlightCode?: (code: string, lang?: string) => string[];\n\t/** Prefix applied to each rendered code block line (default: \" \") */\n\tcodeBlockIndent?: string;\n}\n\nexport interface MarkdownOptions {\n\t/** Preserve source ordered-list markers instead of normalizing them from the list start. */\n\tpreserveOrderedListMarkers?: boolean;\n\t/** Preserve source backslash escapes instead of normalizing escaped punctuation. */\n\tpreserveBackslashEscapes?: boolean;\n\t/** Transform source Markdown before parsing, with the exact width available for content. */\n\ttransform?: (markdown: string, availableWidth: number) => string;\n\t/** Render supported LaTeX math expressions as Unicode text (default: true). */\n\trenderLatex?: boolean;\n}\n\ninterface InlineStyleContext {\n\tapplyText: (text: string) => string;\n\tstylePrefix: string;\n}\n\ninterface TableColumnMeasurements {\n\tnaturalWidths: number[];\n\tminimumWidths: number[];\n}\n\nexport class Markdown implements Component {\n\tprivate text: string;\n\tprivate paddingX: number; // Left/right padding\n\tprivate paddingY: number; // Top/bottom padding\n\tprivate defaultTextStyle?: DefaultTextStyle;\n\tprivate theme: MarkdownTheme;\n\tprivate options: MarkdownOptions;\n\tprivate defaultStylePrefix?: string;\n\n\t// Cache for rendered output\n\tprivate cachedText?: string;\n\tprivate cachedWidth?: number;\n\tprivate cachedLines?: string[];\n\n\tconstructor(\n\t\ttext: string,\n\t\tpaddingX: number,\n\t\tpaddingY: number,\n\t\ttheme: MarkdownTheme,\n\t\tdefaultTextStyle?: DefaultTextStyle,\n\t\toptions?: MarkdownOptions,\n\t) {\n\t\tthis.text = text;\n\t\tthis.paddingX = paddingX;\n\t\tthis.paddingY = paddingY;\n\t\tthis.theme = theme;\n\t\tthis.defaultTextStyle = defaultTextStyle;\n\t\tthis.options = options ? { ...options } : {};\n\t}\n\n\tsetText(text: string): void {\n\t\tthis.text = text;\n\t\tthis.invalidate();\n\t}\n\n\tinvalidate(): void {\n\t\tthis.cachedText = undefined;\n\t\tthis.cachedWidth = undefined;\n\t\tthis.cachedLines = undefined;\n\t}\n\n\tprivate renderMarkdownTokens(text: string, contentWidth: number): string[] {\n\t\tconst tokens = markdownParser.lexer(text);\n\t\tconst renderedLines: string[] = [];\n\t\tfor (let index = 0; index < tokens.length; index++) {\n\t\t\tconst tokenLines = this.renderToken(tokens[index], contentWidth, tokens[index + 1]?.type);\n\t\t\tfor (const tokenLine of tokenLines) renderedLines.push(tokenLine);\n\t\t}\n\t\treturn renderedLines;\n\t}\n\n\tprivate wrapRenderedLines(renderedLines: string[], contentWidth: number): string[] {\n\t\tconst wrappedLines: string[] = [];\n\t\tfor (const line of renderedLines) {\n\t\t\tif (isImageLine(line)) {\n\t\t\t\twrappedLines.push(line);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor (const wrappedLine of wrapTextWithAnsi(line, contentWidth)) wrappedLines.push(wrappedLine);\n\t\t}\n\t\treturn wrappedLines;\n\t}\n\n\tprivate padRenderedLines(lines: string[], width: number, paddingX: number): string[] {\n\t\tconst margin = \" \".repeat(paddingX);\n\t\tconst bgFn = this.defaultTextStyle?.bgColor;\n\t\tconst contentLines: string[] = [];\n\t\tfor (const line of lines) {\n\t\t\tif (isImageLine(line)) {\n\t\t\t\tcontentLines.push(line);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst lineWithMargins = margin + line + margin;\n\t\t\tif (bgFn) {\n\t\t\t\tcontentLines.push(applyBackgroundToLine(lineWithMargins, width, bgFn));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst paddingNeeded = Math.max(0, width - visibleWidth(lineWithMargins));\n\t\t\tcontentLines.push(lineWithMargins + \" \".repeat(paddingNeeded));\n\t\t}\n\t\treturn contentLines;\n\t}\n\n\tprivate createVerticalPadding(width: number): string[] {\n\t\tconst bgFn = this.defaultTextStyle?.bgColor;\n\t\tconst emptyLine = \" \".repeat(width);\n\t\tconst emptyLines: string[] = [];\n\t\tfor (let index = 0; index < this.paddingY; index++) {\n\t\t\temptyLines.push(bgFn ? applyBackgroundToLine(emptyLine, width, bgFn) : emptyLine);\n\t\t}\n\t\treturn emptyLines;\n\t}\n\n\tprivate cacheRenderedLines(width: number, lines: string[]): void {\n\t\tthis.cachedText = this.text;\n\t\tthis.cachedWidth = width;\n\t\tthis.cachedLines = lines;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (this.cachedLines && this.cachedText === this.text && this.cachedWidth === width) {\n\t\t\treturn this.cachedLines;\n\t\t}\n\n\t\tconst effectivePaddingX = Math.min(this.paddingX, Math.floor(Math.max(0, width - 1) / 2));\n\t\tconst contentWidth = Math.max(1, width - effectivePaddingX * 2);\n\t\tconst text = this.options.transform?.(this.text, contentWidth) ?? this.text;\n\t\tif (!text || text.trim() === \"\") {\n\t\t\tconst result: string[] = [];\n\t\t\tthis.cacheRenderedLines(width, result);\n\t\t\treturn result;\n\t\t}\n\n\t\tconst normalizedText = text.replace(/\\t/g, \" \");\n\t\tconst renderedLines = this.renderMarkdownTokens(normalizedText, contentWidth);\n\t\tconst wrappedLines = this.wrapRenderedLines(renderedLines, contentWidth);\n\t\tconst contentLines = this.padRenderedLines(wrappedLines, width, effectivePaddingX);\n\t\tconst verticalPadding = this.createVerticalPadding(width);\n\t\tconst result = verticalPadding.concat(contentLines, verticalPadding);\n\t\tthis.cacheRenderedLines(width, result);\n\t\treturn result.length > 0 ? result : [\"\"];\n\t}\n\n\t/**\n\t * Apply default text style to a string.\n\t * This is the base styling applied to all text content.\n\t * NOTE: Background color is NOT applied here - it's applied at the padding stage\n\t * to ensure it extends to the full line width.\n\t */\n\tprivate applyDefaultStyle(text: string): string {\n\t\tif (!this.defaultTextStyle) {\n\t\t\treturn text;\n\t\t}\n\n\t\tlet styled = text;\n\n\t\t// Apply foreground color (NOT background - that's applied at padding stage)\n\t\tif (this.defaultTextStyle.color) {\n\t\t\tstyled = this.defaultTextStyle.color(styled);\n\t\t}\n\n\t\t// Apply text decorations using this.theme\n\t\tif (this.defaultTextStyle.bold) {\n\t\t\tstyled = this.theme.bold(styled);\n\t\t}\n\t\tif (this.defaultTextStyle.italic) {\n\t\t\tstyled = this.theme.italic(styled);\n\t\t}\n\t\tif (this.defaultTextStyle.strikethrough) {\n\t\t\tstyled = this.theme.strikethrough(styled);\n\t\t}\n\t\tif (this.defaultTextStyle.underline) {\n\t\t\tstyled = this.theme.underline(styled);\n\t\t}\n\n\t\treturn styled;\n\t}\n\n\tprivate getDefaultStylePrefix(): string {\n\t\tif (!this.defaultTextStyle) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\tif (this.defaultStylePrefix !== undefined) {\n\t\t\treturn this.defaultStylePrefix;\n\t\t}\n\n\t\tconst sentinel = \"\\u0000\";\n\t\tlet styled = sentinel;\n\n\t\tif (this.defaultTextStyle.color) {\n\t\t\tstyled = this.defaultTextStyle.color(styled);\n\t\t}\n\n\t\tif (this.defaultTextStyle.bold) {\n\t\t\tstyled = this.theme.bold(styled);\n\t\t}\n\t\tif (this.defaultTextStyle.italic) {\n\t\t\tstyled = this.theme.italic(styled);\n\t\t}\n\t\tif (this.defaultTextStyle.strikethrough) {\n\t\t\tstyled = this.theme.strikethrough(styled);\n\t\t}\n\t\tif (this.defaultTextStyle.underline) {\n\t\t\tstyled = this.theme.underline(styled);\n\t\t}\n\n\t\tconst sentinelIndex = styled.indexOf(sentinel);\n\t\tthis.defaultStylePrefix = sentinelIndex >= 0 ? styled.slice(0, sentinelIndex) : \"\";\n\t\treturn this.defaultStylePrefix;\n\t}\n\n\tprivate getStylePrefix(styleFn: (text: string) => string): string {\n\t\tconst sentinel = \"\\u0000\";\n\t\tconst styled = styleFn(sentinel);\n\t\tconst sentinelIndex = styled.indexOf(sentinel);\n\t\treturn sentinelIndex >= 0 ? styled.slice(0, sentinelIndex) : \"\";\n\t}\n\n\tprivate getDefaultInlineStyleContext(): InlineStyleContext {\n\t\treturn {\n\t\t\tapplyText: (text: string) => this.applyDefaultStyle(text),\n\t\t\tstylePrefix: this.getDefaultStylePrefix(),\n\t\t};\n\t}\n\n\tprivate shouldAppendBlockSpacing(nextTokenType?: string): boolean {\n\t\treturn Boolean(nextTokenType && nextTokenType !== \"space\");\n\t}\n\n\tprivate renderHeadingToken(token: Tokens.Heading, nextTokenType?: string): string[] {\n\t\tconst headingPrefix = `${\"#\".repeat(token.depth)} `;\n\t\tconst headingStyle =\n\t\t\ttoken.depth === 1\n\t\t\t\t? (text: string) => this.theme.heading(this.theme.bold(this.theme.underline(text)))\n\t\t\t\t: (text: string) => this.theme.heading(this.theme.bold(text));\n\t\tconst styleContext: InlineStyleContext = {\n\t\t\tapplyText: headingStyle,\n\t\t\tstylePrefix: this.getStylePrefix(headingStyle),\n\t\t};\n\t\tconst headingText = this.renderInlineTokens(token.tokens || [], styleContext);\n\t\tconst styledHeading = token.depth >= 3 ? headingStyle(headingPrefix) + headingText : headingText;\n\t\treturn this.shouldAppendBlockSpacing(nextTokenType) ? [styledHeading, \"\"] : [styledHeading];\n\t}\n\n\tprivate renderParagraphToken(\n\t\ttoken: Tokens.Paragraph,\n\t\tnextTokenType?: string,\n\t\tstyleContext?: InlineStyleContext,\n\t): string[] {\n\t\tconst lines = [this.renderInlineTokens(token.tokens || [], styleContext)];\n\t\tif (nextTokenType && nextTokenType !== \"list\" && nextTokenType !== \"space\") lines.push(\"\");\n\t\treturn lines;\n\t}\n\n\tprivate renderLatexBlockToken(token: LatexToken, width: number, nextTokenType?: string): string[] {\n\t\tconst candidate =\n\t\t\t!token.pending && this.options.renderLatex !== false ? renderLatex(token.text, { display: true }) : undefined;\n\t\tconst rendered = candidate?.split(\"\\n\").every((line) => visibleWidth(line) <= width)\n\t\t\t? candidate\n\t\t\t: token.raw.trim();\n\t\tconst lines = rendered.split(\"\\n\").map((line) => this.applyDefaultStyle(line));\n\t\tif (this.shouldAppendBlockSpacing(nextTokenType)) lines.push(\"\");\n\t\treturn lines;\n\t}\n\n\tprivate renderCodeToken(token: Tokens.Code, nextTokenType?: string): string[] {\n\t\tconst indent = this.theme.codeBlockIndent ?? \" \";\n\t\tconst lines = [this.theme.codeBlockBorder(`\\`\\`\\`${token.lang || \"\"}`)];\n\t\tif (this.theme.highlightCode) {\n\t\t\tfor (const highlightedLine of this.theme.highlightCode(token.text, token.lang)) {\n\t\t\t\tlines.push(`${indent}${highlightedLine}`);\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const codeLine of token.text.split(\"\\n\")) {\n\t\t\t\tlines.push(`${indent}${this.theme.codeBlock(codeLine)}`);\n\t\t\t}\n\t\t}\n\t\tlines.push(this.theme.codeBlockBorder(\"```\"));\n\t\tif (this.shouldAppendBlockSpacing(nextTokenType)) lines.push(\"\");\n\t\treturn lines;\n\t}\n\n\tprivate renderBlockquoteToken(token: Tokens.Blockquote, width: number, nextTokenType?: string): string[] {\n\t\tconst quoteStyle = (text: string) => this.theme.quote(this.theme.italic(text));\n\t\tconst quoteStylePrefix = this.getStylePrefix(quoteStyle);\n\t\tconst quoteContentWidth = Math.max(1, width - 2);\n\t\tconst quoteStyleContext: InlineStyleContext = {\n\t\t\tapplyText: (text: string) => text,\n\t\t\tstylePrefix: quoteStylePrefix,\n\t\t};\n\t\tconst renderedQuoteLines: string[] = [];\n\t\tconst quoteTokens = token.tokens || [];\n\t\tfor (let index = 0; index < quoteTokens.length; index++) {\n\t\t\trenderedQuoteLines.push(\n\t\t\t\t...this.renderToken(quoteTokens[index], quoteContentWidth, quoteTokens[index + 1]?.type, quoteStyleContext),\n\t\t\t);\n\t\t}\n\t\twhile (renderedQuoteLines.length > 0 && renderedQuoteLines[renderedQuoteLines.length - 1] === \"\") {\n\t\t\trenderedQuoteLines.pop();\n\t\t}\n\n\t\tconst lines: string[] = [];\n\t\tfor (const quoteLine of renderedQuoteLines) {\n\t\t\tconst lineWithReappliedStyle = quoteStylePrefix\n\t\t\t\t? quoteLine.replace(/\\x1b\\[0m/g, `\\x1b[0m${quoteStylePrefix}`)\n\t\t\t\t: quoteLine;\n\t\t\tfor (const wrappedLine of wrapTextWithAnsi(quoteStyle(lineWithReappliedStyle), quoteContentWidth)) {\n\t\t\t\tlines.push(this.theme.quoteBorder(\"│ \") + wrappedLine);\n\t\t\t}\n\t\t}\n\t\tif (this.shouldAppendBlockSpacing(nextTokenType)) lines.push(\"\");\n\t\treturn lines;\n\t}\n\n\tprivate renderHorizontalRule(width: number, nextTokenType?: string): string[] {\n\t\tconst lines = [this.theme.hr(\"─\".repeat(Math.min(width, 80)))];\n\t\tif (this.shouldAppendBlockSpacing(nextTokenType)) lines.push(\"\");\n\t\treturn lines;\n\t}\n\n\tprivate renderHtmlBlock(token: Token): string[] {\n\t\tif (!(\"raw\" in token) || typeof token.raw !== \"string\") return [];\n\t\tconst visibleHtml = stripHtmlComments(token.raw).trim();\n\t\treturn visibleHtml ? [this.applyDefaultStyle(visibleHtml)] : [];\n\t}\n\n\tprivate renderFallbackToken(token: Token): string[] {\n\t\treturn \"text\" in token && typeof token.text === \"string\" ? [token.text] : [];\n\t}\n\n\tprivate renderToken(\n\t\ttoken: Token,\n\t\twidth: number,\n\t\tnextTokenType?: string,\n\t\tstyleContext?: InlineStyleContext,\n\t): string[] {\n\t\tswitch (token.type) {\n\t\t\tcase \"heading\":\n\t\t\t\treturn this.renderHeadingToken(token as Tokens.Heading, nextTokenType);\n\t\t\tcase \"paragraph\":\n\t\t\t\treturn this.renderParagraphToken(token as Tokens.Paragraph, nextTokenType, styleContext);\n\t\t\tcase \"text\":\n\t\t\t\treturn [this.renderInlineTokens([token], styleContext)];\n\t\t\tcase \"latexBlock\":\n\t\t\t\treturn this.renderLatexBlockToken(token as LatexToken, width, nextTokenType);\n\t\t\tcase \"code\":\n\t\t\t\treturn this.renderCodeToken(token as Tokens.Code, nextTokenType);\n\t\t\tcase \"list\":\n\t\t\t\treturn this.renderList(token as Tokens.List, 0, width, styleContext);\n\t\t\tcase \"table\":\n\t\t\t\treturn this.renderTable(token as Tokens.Table, width, nextTokenType, styleContext);\n\t\t\tcase \"blockquote\":\n\t\t\t\treturn this.renderBlockquoteToken(token as Tokens.Blockquote, width, nextTokenType);\n\t\t\tcase \"hr\":\n\t\t\t\treturn this.renderHorizontalRule(width, nextTokenType);\n\t\t\tcase \"html\":\n\t\t\t\treturn this.renderHtmlBlock(token);\n\t\t\tcase \"space\":\n\t\t\t\treturn [\"\"];\n\t\t\tdefault:\n\t\t\t\treturn this.renderFallbackToken(token);\n\t\t}\n\t}\n\n\tprivate applyInlineText(text: string, styleContext: InlineStyleContext): string {\n\t\treturn text\n\t\t\t.split(\"\\n\")\n\t\t\t.map((segment) => styleContext.applyText(segment))\n\t\t\t.join(\"\\n\");\n\t}\n\n\tprivate renderInlineLinkToken(token: Tokens.Link, styleContext: InlineStyleContext): string {\n\t\tconst linkText = this.renderInlineTokens(token.tokens || [], styleContext);\n\t\tconst styledLink = this.theme.link(this.theme.underline(linkText));\n\t\tif (getCapabilities().hyperlinks) {\n\t\t\t// OSC 8: render as a clickable hyperlink. The URL is not printed inline,\n\t\t\t// so we always show only the link text regardless of whether it matches href.\n\t\t\treturn hyperlink(styledLink, token.href) + styleContext.stylePrefix;\n\t\t}\n\n\t\t// Fallback: print URL in parentheses when text differs from href.\n\t\t// Compare raw token.text (not styled) against href for the equality check.\n\t\t// For mailto: links strip the prefix (autolinked emails use text=\"foo@bar.com\"\n\t\t// but href=\"mailto:foo@bar.com\").\n\t\tconst hrefForComparison = token.href.startsWith(\"mailto:\") ? token.href.slice(7) : token.href;\n\t\tif (token.text === token.href || token.text === hrefForComparison) {\n\t\t\treturn styledLink + styleContext.stylePrefix;\n\t\t}\n\t\treturn styledLink + this.theme.linkUrl(` (${token.href})`) + styleContext.stylePrefix;\n\t}\n\n\tprivate renderInlineLatexToken(token: LatexToken, styleContext: InlineStyleContext): string {\n\t\tconst rendered =\n\t\t\t!token.pending && this.options.renderLatex !== false ? (renderLatex(token.text) ?? token.raw) : token.raw;\n\t\treturn this.applyInlineText(rendered, styleContext);\n\t}\n\n\tprivate renderInlineTextToken(token: Tokens.Text, styleContext: InlineStyleContext): string {\n\t\t// Text tokens in list items can have nested tokens for inline formatting.\n\t\treturn token.tokens?.length\n\t\t\t? this.renderInlineTokens(token.tokens, styleContext)\n\t\t\t: this.applyInlineText(token.text, styleContext);\n\t}\n\n\tprivate renderInlineHtmlToken(token: Token, styleContext: InlineStyleContext): string {\n\t\tif (!(\"raw\" in token) || typeof token.raw !== \"string\") return \"\";\n\t\tconst visibleHtml = stripHtmlComments(token.raw);\n\t\treturn visibleHtml ? this.applyInlineText(visibleHtml, styleContext) : \"\";\n\t}\n\n\tprivate renderInlineFallbackToken(token: Token, styleContext: InlineStyleContext): string {\n\t\tif (!(\"text\" in token) || typeof token.text !== \"string\") return \"\";\n\t\treturn this.applyInlineText(token.text, styleContext);\n\t}\n\n\tprivate renderInlineToken(token: Token, styleContext: InlineStyleContext): string {\n\t\tconst { stylePrefix } = styleContext;\n\t\tswitch (token.type) {\n\t\t\tcase \"latex\":\n\t\t\t\treturn this.renderInlineLatexToken(token as LatexToken, styleContext);\n\t\t\tcase \"escape\":\n\t\t\t\treturn this.applyInlineText(this.options.preserveBackslashEscapes ? token.raw : token.text, styleContext);\n\t\t\tcase \"text\":\n\t\t\t\treturn this.renderInlineTextToken(token as Tokens.Text, styleContext);\n\t\t\tcase \"paragraph\":\n\t\t\t\treturn this.renderInlineTokens(token.tokens || [], styleContext);\n\t\t\tcase \"strong\":\n\t\t\t\treturn this.theme.bold(this.renderInlineTokens(token.tokens || [], styleContext)) + stylePrefix;\n\t\t\tcase \"em\":\n\t\t\t\treturn this.theme.italic(this.renderInlineTokens(token.tokens || [], styleContext)) + stylePrefix;\n\t\t\tcase \"codespan\":\n\t\t\t\treturn this.theme.code(token.text) + stylePrefix;\n\t\t\tcase \"link\":\n\t\t\t\treturn this.renderInlineLinkToken(token as Tokens.Link, styleContext);\n\t\t\tcase \"br\":\n\t\t\t\treturn \"\\n\";\n\t\t\tcase \"del\":\n\t\t\t\treturn this.theme.strikethrough(this.renderInlineTokens(token.tokens || [], styleContext)) + stylePrefix;\n\t\t\tcase \"html\":\n\t\t\t\treturn this.renderInlineHtmlToken(token, styleContext);\n\t\t\tdefault:\n\t\t\t\treturn this.renderInlineFallbackToken(token, styleContext);\n\t\t}\n\t}\n\n\tprivate renderInlineTokens(tokens: Token[], styleContext?: InlineStyleContext): string {\n\t\tconst resolvedStyleContext = styleContext ?? this.getDefaultInlineStyleContext();\n\t\tlet result = \"\";\n\t\tfor (const token of tokens) {\n\t\t\tresult += this.renderInlineToken(token, resolvedStyleContext);\n\t\t}\n\n\t\twhile (resolvedStyleContext.stylePrefix && result.endsWith(resolvedStyleContext.stylePrefix)) {\n\t\t\tresult = result.slice(0, -resolvedStyleContext.stylePrefix.length);\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate getOrderedListMarker(item: Tokens.ListItem): string | undefined {\n\t\tconst match = /^(?: {0,3})(\\d{1,9}[.)])[ \\t]+/.exec(item.raw);\n\t\treturn match ? `${match[1]} ` : undefined;\n\t}\n\n\tprivate getListItemMarker(token: Tokens.List, item: Tokens.ListItem, index: number, startNumber: number): string {\n\t\tif (!token.ordered) return \"- \";\n\t\tif (this.options.preserveOrderedListMarkers) {\n\t\t\treturn this.getOrderedListMarker(item) ?? `${startNumber + index}. `;\n\t\t}\n\t\treturn `${startNumber + index}. `;\n\t}\n\n\tprivate renderListItem(\n\t\ttoken: Tokens.List,\n\t\titem: Tokens.ListItem,\n\t\tindex: number,\n\t\tstartNumber: number,\n\t\tdepth: number,\n\t\twidth: number,\n\t\tstyleContext?: InlineStyleContext,\n\t): string[] {\n\t\tconst indent = \" \".repeat(depth);\n\t\tconst bullet = this.getListItemMarker(token, item, index, startNumber);\n\t\tconst taskMarker = item.task ? `[${item.checked ? \"x\" : \" \"}] ` : \"\";\n\t\tconst marker = bullet + taskMarker;\n\t\tconst firstPrefix = indent + this.theme.listBullet(marker);\n\t\tconst continuationPrefix = indent + \" \".repeat(visibleWidth(marker));\n\t\tconst itemWidth = Math.max(1, width - visibleWidth(firstPrefix));\n\t\tconst lines: string[] = [];\n\t\tlet renderedAnyLine = false;\n\n\t\tfor (const itemToken of item.tokens) {\n\t\t\tif (itemToken.type === \"list\") {\n\t\t\t\tlines.push(...this.renderList(itemToken as Tokens.List, depth + 1, width, styleContext));\n\t\t\t\trenderedAnyLine = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst itemLines = this.renderToken(itemToken, itemWidth, undefined, styleContext);\n\t\t\tconst wrappedItemLines = itemLines.flatMap((line) => wrapTextWithAnsi(line, itemWidth));\n\t\t\tfor (const wrappedLine of wrappedItemLines) {\n\t\t\t\tconst linePrefix = renderedAnyLine ? continuationPrefix : firstPrefix;\n\t\t\t\tlines.push(linePrefix + wrappedLine);\n\t\t\t\trenderedAnyLine = true;\n\t\t\t}\n\t\t}\n\n\t\tif (!renderedAnyLine) lines.push(firstPrefix);\n\t\treturn lines;\n\t}\n\n\t/**\n\t * Render a list with proper nesting support\n\t */\n\tprivate renderList(token: Tokens.List, depth: number, width: number, styleContext?: InlineStyleContext): string[] {\n\t\tconst lines: string[] = [];\n\t\tconst startNumber = typeof token.start === \"number\" ? token.start : 1;\n\t\tfor (let index = 0; index < token.items.length; index++) {\n\t\t\tlines.push(...this.renderListItem(token, token.items[index], index, startNumber, depth, width, styleContext));\n\t\t}\n\t\treturn lines;\n\t}\n\n\t/**\n\t * Get the visible width of the longest word in a string.\n\t */\n\tprivate getLongestWordWidth(text: string, maxWidth?: number): number {\n\t\tconst words = text.split(/\\s+/).filter((word) => word.length > 0);\n\t\tlet longest = 0;\n\t\tfor (const word of words) {\n\t\t\tlongest = Math.max(longest, visibleWidth(word));\n\t\t}\n\t\tif (maxWidth === undefined) {\n\t\t\treturn longest;\n\t\t}\n\t\treturn Math.min(longest, maxWidth);\n\t}\n\n\t/**\n\t * Wrap a table cell to fit into a column.\n\t *\n\t * Delegates to wrapTextWithAnsi() so ANSI codes + long tokens are handled\n\t * consistently with the rest of the renderer.\n\t */\n\tprivate wrapCellText(text: string, maxWidth: number): string[] {\n\t\treturn wrapTextWithAnsi(text, Math.max(1, maxWidth));\n\t}\n\n\t/**\n\t * Render a table with width-aware cell wrapping.\n\t * Cells that don't fit are wrapped to multiple lines.\n\t */\n\tprivate measureTableColumns(\n\t\ttoken: Tokens.Table,\n\t\tstyleContext: InlineStyleContext | undefined,\n\t): TableColumnMeasurements {\n\t\tconst naturalWidths: number[] = [];\n\t\tconst minimumWidths: number[] = [];\n\t\tconst maxUnbrokenWordWidth = 30;\n\t\tfor (let column = 0; column < token.header.length; column++) {\n\t\t\tconst headerText = this.renderInlineTokens(token.header[column].tokens || [], styleContext);\n\t\t\tnaturalWidths[column] = visibleWidth(headerText);\n\t\t\tminimumWidths[column] = Math.max(1, this.getLongestWordWidth(headerText, maxUnbrokenWordWidth));\n\t\t}\n\t\tfor (const row of token.rows) {\n\t\t\tfor (let column = 0; column < row.length; column++) {\n\t\t\t\tconst cellText = this.renderInlineTokens(row[column].tokens || [], styleContext);\n\t\t\t\tnaturalWidths[column] = Math.max(naturalWidths[column] || 0, visibleWidth(cellText));\n\t\t\t\tminimumWidths[column] = Math.max(\n\t\t\t\t\tminimumWidths[column] || 1,\n\t\t\t\t\tthis.getLongestWordWidth(cellText, maxUnbrokenWordWidth),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn { naturalWidths, minimumWidths };\n\t}\n\n\tprivate fitMinimumTableColumnWidths(minimumWidths: number[], availableForCells: number): number[] {\n\t\tif (minimumWidths.reduce((total, width) => total + width, 0) <= availableForCells) return minimumWidths;\n\t\tconst fittedWidths = new Array(minimumWidths.length).fill(1);\n\t\tconst remaining = availableForCells - minimumWidths.length;\n\t\tif (remaining <= 0) return fittedWidths;\n\t\tconst totalWeight = minimumWidths.reduce((total, width) => total + Math.max(0, width - 1), 0);\n\t\tconst growth = minimumWidths.map((width) => {\n\t\t\tconst weight = Math.max(0, width - 1);\n\t\t\treturn totalWeight > 0 ? Math.floor((weight / totalWeight) * remaining) : 0;\n\t\t});\n\t\tfor (let column = 0; column < minimumWidths.length; column++) fittedWidths[column] += growth[column] ?? 0;\n\t\tconst allocated = growth.reduce((total, width) => total + width, 0);\n\t\tlet leftover = remaining - allocated;\n\t\tfor (let column = 0; leftover > 0 && column < minimumWidths.length; column++) {\n\t\t\tfittedWidths[column]++;\n\t\t\tleftover--;\n\t\t}\n\t\treturn fittedWidths;\n\t}\n\n\tprivate distributeRemainingTableWidth(\n\t\tcolumnWidths: number[],\n\t\tnaturalWidths: number[],\n\t\tremainingWidth: number,\n\t): void {\n\t\tlet remaining = remainingWidth;\n\t\twhile (remaining > 0) {\n\t\t\tlet grew = false;\n\t\t\tfor (let column = 0; column < columnWidths.length && remaining > 0; column++) {\n\t\t\t\tif (columnWidths[column] >= naturalWidths[column]) continue;\n\t\t\t\tcolumnWidths[column]++;\n\t\t\t\tremaining--;\n\t\t\t\tgrew = true;\n\t\t\t}\n\t\t\tif (!grew) break;\n\t\t}\n\t}\n\n\tprivate calculateTableColumnWidths(\n\t\tnaturalWidths: number[],\n\t\tminimumWidths: number[],\n\t\tavailableForCells: number,\n\t\tborderOverhead: number,\n\t): number[] {\n\t\tconst fittedMinimumWidths = this.fitMinimumTableColumnWidths(minimumWidths, availableForCells);\n\t\tconst totalNaturalWidth = naturalWidths.reduce((total, width) => total + width, 0) + borderOverhead;\n\t\tif (totalNaturalWidth <= availableForCells + borderOverhead) {\n\t\t\treturn naturalWidths.map((width, column) => Math.max(width, fittedMinimumWidths[column]));\n\t\t}\n\t\tconst minimumCellsWidth = fittedMinimumWidths.reduce((total, width) => total + width, 0);\n\t\tconst totalGrowPotential = naturalWidths.reduce(\n\t\t\t(total, width, column) => total + Math.max(0, width - fittedMinimumWidths[column]),\n\t\t\t0,\n\t\t);\n\t\tconst extraWidth = Math.max(0, availableForCells - minimumCellsWidth);\n\t\tconst columnWidths = fittedMinimumWidths.map((minimumWidth, column) => {\n\t\t\tconst growthPotential = Math.max(0, naturalWidths[column] - minimumWidth);\n\t\t\tconst growth = totalGrowPotential > 0 ? Math.floor((growthPotential / totalGrowPotential) * extraWidth) : 0;\n\t\t\treturn minimumWidth + growth;\n\t\t});\n\t\tconst allocated = columnWidths.reduce((total, width) => total + width, 0);\n\t\tthis.distributeRemainingTableWidth(columnWidths, naturalWidths, availableForCells - allocated);\n\t\treturn columnWidths;\n\t}\n\n\tprivate renderTableBorder(columnWidths: number[], left: string, junction: string, right: string): string {\n\t\treturn `${left}─${columnWidths.map((width) => \"─\".repeat(width)).join(`─${junction}─`)}─${right}`;\n\t}\n\n\tprivate renderTableCellLines(\n\t\tcells: Tokens.TableCell[],\n\t\tcolumnWidths: number[],\n\t\tstyleContext: InlineStyleContext | undefined,\n\t): string[][] {\n\t\treturn cells.map((cell, column) => {\n\t\t\tconst text = this.renderInlineTokens(cell.tokens || [], styleContext);\n\t\t\treturn this.wrapCellText(text, columnWidths[column]);\n\t\t});\n\t}\n\n\t// pi-ignore noExcessiveCollectionIterations: Every rendered table line must format each column once, so this rectangular traversal is linear in the emitted cell slots.\n\tprivate appendTableRow(lines: string[], cellLines: string[][], columnWidths: number[], bold: boolean): void {\n\t\tconst lineCount = Math.max(...cellLines.map((cell) => cell.length));\n\t\tfor (let lineIndex = 0; lineIndex < lineCount; lineIndex++) {\n\t\t\tconst rowParts = cellLines.map((columnLines, column) => {\n\t\t\t\tconst text = columnLines[lineIndex] || \"\";\n\t\t\t\tconst padded = text + \" \".repeat(Math.max(0, columnWidths[column] - visibleWidth(text)));\n\t\t\t\treturn bold ? this.theme.bold(padded) : padded;\n\t\t\t});\n\t\t\tlines.push(`│ ${rowParts.join(\" │ \")} │`);\n\t\t}\n\t}\n\n\tprivate renderTable(\n\t\ttoken: Tokens.Table,\n\t\tavailableWidth: number,\n\t\tnextTokenType?: string,\n\t\tstyleContext?: InlineStyleContext,\n\t): string[] {\n\t\tconst columnCount = token.header.length;\n\t\tif (columnCount === 0) return [];\n\t\tconst borderOverhead = 3 * columnCount + 1;\n\t\tconst availableForCells = availableWidth - borderOverhead;\n\t\tif (availableForCells < columnCount) {\n\t\t\tconst fallbackLines = token.raw ? wrapTextWithAnsi(token.raw, availableWidth) : [];\n\t\t\tif (nextTokenType && nextTokenType !== \"space\") fallbackLines.push(\"\");\n\t\t\treturn fallbackLines;\n\t\t}\n\n\t\tconst measurements = this.measureTableColumns(token, styleContext);\n\t\tconst columnWidths = this.calculateTableColumnWidths(\n\t\t\tmeasurements.naturalWidths,\n\t\t\tmeasurements.minimumWidths,\n\t\t\tavailableForCells,\n\t\t\tborderOverhead,\n\t\t);\n\t\tconst lines = [this.renderTableBorder(columnWidths, \"┌\", \"┬\", \"┐\")];\n\t\tthis.appendTableRow(\n\t\t\tlines,\n\t\t\tthis.renderTableCellLines(token.header, columnWidths, styleContext),\n\t\t\tcolumnWidths,\n\t\t\ttrue,\n\t\t);\n\t\tconst separator = this.renderTableBorder(columnWidths, \"├\", \"┼\", \"┤\");\n\t\tlines.push(separator);\n\t\tfor (let rowIndex = 0; rowIndex < token.rows.length; rowIndex++) {\n\t\t\tthis.appendTableRow(\n\t\t\t\tlines,\n\t\t\t\tthis.renderTableCellLines(token.rows[rowIndex], columnWidths, styleContext),\n\t\t\t\tcolumnWidths,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t\tif (rowIndex < token.rows.length - 1) lines.push(separator);\n\t\t}\n\t\tlines.push(this.renderTableBorder(columnWidths, \"└\", \"┴\", \"┘\"));\n\t\tif (nextTokenType && nextTokenType !== \"space\") lines.push(\"\");\n\t\treturn lines;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { LAYOUT_NODE, type ScrollLayoutNode, type ScrollViewOverscrollBehavior } from "../layout-node.ts";
|
|
2
|
+
import { type Component, Container } from "../tui.ts";
|
|
3
|
+
export type ScrollViewFollowMode = "none" | "end";
|
|
4
|
+
export type { ScrollViewOverscrollBehavior } from "../layout-node.ts";
|
|
5
|
+
export type ScrollViewScrollbar = "hidden" | "auto" | "always";
|
|
6
|
+
export interface ScrollViewOptions {
|
|
7
|
+
axis?: "vertical";
|
|
8
|
+
follow?: ScrollViewFollowMode;
|
|
9
|
+
primary?: boolean;
|
|
10
|
+
overscroll?: ScrollViewOverscrollBehavior;
|
|
11
|
+
scrollbar?: ScrollViewScrollbar;
|
|
12
|
+
scrollbarStyle?: (text: string) => string;
|
|
13
|
+
scrollbarHideDelayMs?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare class ScrollView extends Container {
|
|
16
|
+
private readonly child;
|
|
17
|
+
private readonly followEnd;
|
|
18
|
+
readonly primary: boolean;
|
|
19
|
+
readonly overscroll: ScrollViewOverscrollBehavior;
|
|
20
|
+
readonly scrollbarStyle: (text: string) => string;
|
|
21
|
+
private currentScrollbar;
|
|
22
|
+
private readonly scrollbarHideDelayMs;
|
|
23
|
+
private currentScrollTop;
|
|
24
|
+
private contentHeight;
|
|
25
|
+
private currentViewportHeight;
|
|
26
|
+
private followingEnd;
|
|
27
|
+
private requestRenderCallback;
|
|
28
|
+
private transientScrollbarVisible;
|
|
29
|
+
private scrollbarActive;
|
|
30
|
+
private scrollbarHideTimer;
|
|
31
|
+
constructor(component: Component, options?: ScrollViewOptions);
|
|
32
|
+
get scrollTop(): number;
|
|
33
|
+
get isFollowingEnd(): boolean;
|
|
34
|
+
get viewportHeight(): number;
|
|
35
|
+
get scrollbar(): ScrollViewScrollbar;
|
|
36
|
+
get isScrollbarVisible(): boolean;
|
|
37
|
+
setScrollbar(scrollbar: ScrollViewScrollbar): void;
|
|
38
|
+
getContentWidth(width: number): number;
|
|
39
|
+
private markScrollbarActivity;
|
|
40
|
+
private hideTransientScrollbar;
|
|
41
|
+
setScrollbarActive(active: boolean): void;
|
|
42
|
+
scrollTo(scrollTop: number): void;
|
|
43
|
+
scrollBy(lines: number): number;
|
|
44
|
+
scrollToStart(): void;
|
|
45
|
+
scrollToEnd(): void;
|
|
46
|
+
updateLayout(contentHeight: number, viewportHeight: number, requestRender: () => void): void;
|
|
47
|
+
addChild(_component: Component): void;
|
|
48
|
+
removeChild(_component: Component): void;
|
|
49
|
+
clear(): void;
|
|
50
|
+
render(width: number): string[];
|
|
51
|
+
[LAYOUT_NODE](): ScrollLayoutNode;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=scroll-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll-view.d.ts","sourceRoot":"","sources":["../../src/components/scroll-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,4BAA4B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AEvD,YAAY,SAAS,EAAE,SAAS,EAAE,OAAO,GAAE,iBAAsB,EAchE;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,cAAc,IAAI,OAAO,CAE5B;IAED,IAAI,cAAc,IAAI,MAAM,CAE3B;IAED,IAAI,SAAS,IAAI,mBAAmB,CAEnC;IAED,IAAI,kBAAkB,IAAI,OAAO,CAKhC;IAED,YAAY,CAAC,SAAS,EAAE,mBAAmB,GAAG,IAAI,CAMjD;IAED,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErC;IAED,OAAO,CAAC,qBAAqB;IAgB7B,OAAO,CAAC,sBAAsB;IAO9B,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAIxC;IAED,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAShC;IAED,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAc9B;IAED,aAAa,IAAI,IAAI,CAUpB;IAED,WAAW,IAAI,IAAI,CASlB;IAED,YAAY,CAAC,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,IAAI,GAAG,IAAI,CAS3F;IAEQ,QAAQ,CAAC,UAAU,EAAE,SAAS,GAAG,IAAI,CAE7C;IAEQ,WAAW,CAAC,UAAU,EAAE,SAAS,GAAG,IAAI,CAEhD;IAEQ,KAAK,IAAI,IAAI,CAErB;IAEQ,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAIvC;IAED,CAAC,WAAW,CAAC,IAAI,gBAAgB,CAEhC;CACD","sourcesContent":["import { LAYOUT_NODE, type ScrollLayoutNode, type ScrollViewOverscrollBehavior } from \"../layout-node.ts\";\nimport { type Component, Container } from \"../tui.ts\";\n\nexport type ScrollViewFollowMode = \"none\" | \"end\";\nexport type { ScrollViewOverscrollBehavior } from \"../layout-node.ts\";\nexport type ScrollViewScrollbar = \"hidden\" | \"auto\" | \"always\";\n\nexport interface ScrollViewOptions {\n\taxis?: \"vertical\";\n\tfollow?: ScrollViewFollowMode;\n\tprimary?: boolean;\n\toverscroll?: ScrollViewOverscrollBehavior;\n\tscrollbar?: ScrollViewScrollbar;\n\tscrollbarStyle?: (text: string) => string;\n\tscrollbarHideDelayMs?: number;\n}\n\nexport class ScrollView extends Container {\n\tprivate readonly child: Component;\n\tprivate readonly followEnd: boolean;\n\treadonly primary: boolean;\n\treadonly overscroll: ScrollViewOverscrollBehavior;\n\treadonly scrollbarStyle: (text: string) => string;\n\tprivate currentScrollbar: ScrollViewScrollbar;\n\tprivate readonly scrollbarHideDelayMs: number;\n\tprivate currentScrollTop = 0;\n\tprivate contentHeight = 0;\n\tprivate currentViewportHeight = 0;\n\tprivate followingEnd: boolean;\n\tprivate requestRenderCallback: (() => void) | undefined;\n\tprivate transientScrollbarVisible = false;\n\tprivate scrollbarActive = false;\n\tprivate scrollbarHideTimer: NodeJS.Timeout | undefined;\n\n\tconstructor(component: Component, options: ScrollViewOptions = {}) {\n\t\tsuper();\n\t\tif (options.axis !== undefined && options.axis !== \"vertical\") {\n\t\t\tthrow new Error(`Unsupported ScrollView axis: ${options.axis}`);\n\t\t}\n\t\tthis.child = component;\n\t\tthis.children.push(component);\n\t\tthis.followEnd = (options.follow ?? \"none\") === \"end\";\n\t\tthis.followingEnd = this.followEnd;\n\t\tthis.primary = options.primary ?? false;\n\t\tthis.overscroll = options.overscroll ?? \"chain\";\n\t\tthis.currentScrollbar = options.scrollbar ?? \"hidden\";\n\t\tthis.scrollbarStyle = options.scrollbarStyle ?? ((text) => `\\x1b[100m${text}\\x1b[49m`);\n\t\tthis.scrollbarHideDelayMs = Math.max(0, Math.floor(options.scrollbarHideDelayMs ?? 1000));\n\t}\n\n\tget scrollTop(): number {\n\t\treturn this.currentScrollTop;\n\t}\n\n\tget isFollowingEnd(): boolean {\n\t\treturn this.followingEnd;\n\t}\n\n\tget viewportHeight(): number {\n\t\treturn this.currentViewportHeight;\n\t}\n\n\tget scrollbar(): ScrollViewScrollbar {\n\t\treturn this.currentScrollbar;\n\t}\n\n\tget isScrollbarVisible(): boolean {\n\t\tif (this.scrollbar === \"always\") return this.currentViewportHeight > 0;\n\t\treturn (\n\t\t\tthis.scrollbar === \"auto\" && this.contentHeight > this.currentViewportHeight && this.transientScrollbarVisible\n\t\t);\n\t}\n\n\tsetScrollbar(scrollbar: ScrollViewScrollbar): void {\n\t\tif (scrollbar === this.currentScrollbar) return;\n\t\tthis.currentScrollbar = scrollbar;\n\t\tif (scrollbar !== \"auto\") this.hideTransientScrollbar();\n\t\telse if (this.scrollbarActive) this.markScrollbarActivity();\n\t\tthis.requestRenderCallback?.();\n\t}\n\n\tgetContentWidth(width: number): number {\n\t\treturn this.scrollbar === \"always\" && width > 1 ? width - 1 : width;\n\t}\n\n\tprivate markScrollbarActivity(): void {\n\t\tif (this.scrollbar !== \"auto\" || this.contentHeight <= this.currentViewportHeight) return;\n\t\tthis.transientScrollbarVisible = true;\n\t\tif (this.scrollbarHideTimer) {\n\t\t\tclearTimeout(this.scrollbarHideTimer);\n\t\t\tthis.scrollbarHideTimer = undefined;\n\t\t}\n\t\tif (this.scrollbarActive) return;\n\t\tthis.scrollbarHideTimer = setTimeout(() => {\n\t\t\tthis.scrollbarHideTimer = undefined;\n\t\t\tthis.transientScrollbarVisible = false;\n\t\t\tthis.requestRenderCallback?.();\n\t\t}, this.scrollbarHideDelayMs);\n\t\tthis.scrollbarHideTimer.unref();\n\t}\n\n\tprivate hideTransientScrollbar(): void {\n\t\tthis.transientScrollbarVisible = false;\n\t\tif (!this.scrollbarHideTimer) return;\n\t\tclearTimeout(this.scrollbarHideTimer);\n\t\tthis.scrollbarHideTimer = undefined;\n\t}\n\n\tsetScrollbarActive(active: boolean): void {\n\t\tif (active === this.scrollbarActive) return;\n\t\tthis.scrollbarActive = active;\n\t\tthis.markScrollbarActivity();\n\t}\n\n\tscrollTo(scrollTop: number): void {\n\t\tconst requested = Number.isFinite(scrollTop) ? Math.trunc(scrollTop) : this.currentScrollTop;\n\t\tconst maxScrollTop = Math.max(0, this.contentHeight - this.currentViewportHeight);\n\t\tconst next = Math.max(0, Math.min(maxScrollTop, requested));\n\t\tif (next === this.currentScrollTop) return;\n\t\tthis.currentScrollTop = next;\n\t\tthis.followingEnd = this.followEnd && next === maxScrollTop;\n\t\tthis.markScrollbarActivity();\n\t\tthis.requestRenderCallback?.();\n\t}\n\n\tscrollBy(lines: number): number {\n\t\tconst requested = Number.isFinite(lines) ? Math.trunc(lines) : 0;\n\t\tif (requested === 0) return 0;\n\t\tconst maxScrollTop = Math.max(0, this.contentHeight - this.currentViewportHeight);\n\t\tconst start = this.followingEnd ? maxScrollTop : this.currentScrollTop;\n\t\tconst next = Math.max(0, Math.min(maxScrollTop, start + requested));\n\t\tconst moved = next - start;\n\t\tthis.currentScrollTop = next;\n\t\tthis.followingEnd = this.followEnd && next === maxScrollTop;\n\t\tif (moved !== 0) {\n\t\t\tthis.markScrollbarActivity();\n\t\t\tthis.requestRenderCallback?.();\n\t\t}\n\t\treturn requested - moved;\n\t}\n\n\tscrollToStart(): void {\n\t\tconst changed =\n\t\t\tthis.currentScrollTop !== 0 ||\n\t\t\tthis.followingEnd !== (this.followEnd && this.contentHeight <= this.currentViewportHeight);\n\t\tthis.currentScrollTop = 0;\n\t\tthis.followingEnd = this.followEnd && this.contentHeight <= this.currentViewportHeight;\n\t\tif (changed) {\n\t\t\tthis.markScrollbarActivity();\n\t\t\tthis.requestRenderCallback?.();\n\t\t}\n\t}\n\n\tscrollToEnd(): void {\n\t\tconst next = Math.max(0, this.contentHeight - this.currentViewportHeight);\n\t\tconst changed = this.currentScrollTop !== next || this.followingEnd !== this.followEnd;\n\t\tthis.currentScrollTop = next;\n\t\tthis.followingEnd = this.followEnd;\n\t\tif (changed) {\n\t\t\tthis.markScrollbarActivity();\n\t\t\tthis.requestRenderCallback?.();\n\t\t}\n\t}\n\n\tupdateLayout(contentHeight: number, viewportHeight: number, requestRender: () => void): void {\n\t\tthis.contentHeight = Math.max(0, Math.floor(contentHeight));\n\t\tthis.currentViewportHeight = Math.max(0, Math.floor(viewportHeight));\n\t\tthis.requestRenderCallback = requestRender;\n\t\tconst maxScrollTop = Math.max(0, this.contentHeight - this.currentViewportHeight);\n\t\tif (this.followingEnd) this.currentScrollTop = maxScrollTop;\n\t\telse this.currentScrollTop = Math.max(0, Math.min(this.currentScrollTop, maxScrollTop));\n\t\tif (this.followEnd && this.currentScrollTop === maxScrollTop) this.followingEnd = true;\n\t\tif (this.contentHeight <= this.currentViewportHeight) this.hideTransientScrollbar();\n\t}\n\n\toverride addChild(_component: Component): void {\n\t\tthrow new Error(\"ScrollView has exactly one child\");\n\t}\n\n\toverride removeChild(_component: Component): void {\n\t\tthrow new Error(\"ScrollView child cannot be removed\");\n\t}\n\n\toverride clear(): void {\n\t\tthrow new Error(\"ScrollView child cannot be cleared\");\n\t}\n\n\toverride render(width: number): string[] {\n\t\tconst contentWidth = this.getContentWidth(width);\n\t\tconst lines = this.child.render(contentWidth);\n\t\treturn contentWidth === width ? lines : lines.map((line) => `${line} `);\n\t}\n\n\t[LAYOUT_NODE](): ScrollLayoutNode {\n\t\treturn { type: \"scroll\", component: this.child, state: this };\n\t}\n}\n"]}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { LAYOUT_NODE } from "../layout-node.js";
|
|
2
|
+
import { Container } from "../tui.js";
|
|
3
|
+
export class ScrollView extends Container {
|
|
4
|
+
child;
|
|
5
|
+
followEnd;
|
|
6
|
+
primary;
|
|
7
|
+
overscroll;
|
|
8
|
+
scrollbarStyle;
|
|
9
|
+
currentScrollbar;
|
|
10
|
+
scrollbarHideDelayMs;
|
|
11
|
+
currentScrollTop = 0;
|
|
12
|
+
contentHeight = 0;
|
|
13
|
+
currentViewportHeight = 0;
|
|
14
|
+
followingEnd;
|
|
15
|
+
requestRenderCallback;
|
|
16
|
+
transientScrollbarVisible = false;
|
|
17
|
+
scrollbarActive = false;
|
|
18
|
+
scrollbarHideTimer;
|
|
19
|
+
constructor(component, options = {}) {
|
|
20
|
+
super();
|
|
21
|
+
if (options.axis !== undefined && options.axis !== "vertical") {
|
|
22
|
+
throw new Error(`Unsupported ScrollView axis: ${options.axis}`);
|
|
23
|
+
}
|
|
24
|
+
this.child = component;
|
|
25
|
+
this.children.push(component);
|
|
26
|
+
this.followEnd = (options.follow ?? "none") === "end";
|
|
27
|
+
this.followingEnd = this.followEnd;
|
|
28
|
+
this.primary = options.primary ?? false;
|
|
29
|
+
this.overscroll = options.overscroll ?? "chain";
|
|
30
|
+
this.currentScrollbar = options.scrollbar ?? "hidden";
|
|
31
|
+
this.scrollbarStyle = options.scrollbarStyle ?? ((text) => `\x1b[100m${text}\x1b[49m`);
|
|
32
|
+
this.scrollbarHideDelayMs = Math.max(0, Math.floor(options.scrollbarHideDelayMs ?? 1000));
|
|
33
|
+
}
|
|
34
|
+
get scrollTop() {
|
|
35
|
+
return this.currentScrollTop;
|
|
36
|
+
}
|
|
37
|
+
get isFollowingEnd() {
|
|
38
|
+
return this.followingEnd;
|
|
39
|
+
}
|
|
40
|
+
get viewportHeight() {
|
|
41
|
+
return this.currentViewportHeight;
|
|
42
|
+
}
|
|
43
|
+
get scrollbar() {
|
|
44
|
+
return this.currentScrollbar;
|
|
45
|
+
}
|
|
46
|
+
get isScrollbarVisible() {
|
|
47
|
+
if (this.scrollbar === "always")
|
|
48
|
+
return this.currentViewportHeight > 0;
|
|
49
|
+
return (this.scrollbar === "auto" && this.contentHeight > this.currentViewportHeight && this.transientScrollbarVisible);
|
|
50
|
+
}
|
|
51
|
+
setScrollbar(scrollbar) {
|
|
52
|
+
if (scrollbar === this.currentScrollbar)
|
|
53
|
+
return;
|
|
54
|
+
this.currentScrollbar = scrollbar;
|
|
55
|
+
if (scrollbar !== "auto")
|
|
56
|
+
this.hideTransientScrollbar();
|
|
57
|
+
else if (this.scrollbarActive)
|
|
58
|
+
this.markScrollbarActivity();
|
|
59
|
+
this.requestRenderCallback?.();
|
|
60
|
+
}
|
|
61
|
+
getContentWidth(width) {
|
|
62
|
+
return this.scrollbar === "always" && width > 1 ? width - 1 : width;
|
|
63
|
+
}
|
|
64
|
+
markScrollbarActivity() {
|
|
65
|
+
if (this.scrollbar !== "auto" || this.contentHeight <= this.currentViewportHeight)
|
|
66
|
+
return;
|
|
67
|
+
this.transientScrollbarVisible = true;
|
|
68
|
+
if (this.scrollbarHideTimer) {
|
|
69
|
+
clearTimeout(this.scrollbarHideTimer);
|
|
70
|
+
this.scrollbarHideTimer = undefined;
|
|
71
|
+
}
|
|
72
|
+
if (this.scrollbarActive)
|
|
73
|
+
return;
|
|
74
|
+
this.scrollbarHideTimer = setTimeout(() => {
|
|
75
|
+
this.scrollbarHideTimer = undefined;
|
|
76
|
+
this.transientScrollbarVisible = false;
|
|
77
|
+
this.requestRenderCallback?.();
|
|
78
|
+
}, this.scrollbarHideDelayMs);
|
|
79
|
+
this.scrollbarHideTimer.unref();
|
|
80
|
+
}
|
|
81
|
+
hideTransientScrollbar() {
|
|
82
|
+
this.transientScrollbarVisible = false;
|
|
83
|
+
if (!this.scrollbarHideTimer)
|
|
84
|
+
return;
|
|
85
|
+
clearTimeout(this.scrollbarHideTimer);
|
|
86
|
+
this.scrollbarHideTimer = undefined;
|
|
87
|
+
}
|
|
88
|
+
setScrollbarActive(active) {
|
|
89
|
+
if (active === this.scrollbarActive)
|
|
90
|
+
return;
|
|
91
|
+
this.scrollbarActive = active;
|
|
92
|
+
this.markScrollbarActivity();
|
|
93
|
+
}
|
|
94
|
+
scrollTo(scrollTop) {
|
|
95
|
+
const requested = Number.isFinite(scrollTop) ? Math.trunc(scrollTop) : this.currentScrollTop;
|
|
96
|
+
const maxScrollTop = Math.max(0, this.contentHeight - this.currentViewportHeight);
|
|
97
|
+
const next = Math.max(0, Math.min(maxScrollTop, requested));
|
|
98
|
+
if (next === this.currentScrollTop)
|
|
99
|
+
return;
|
|
100
|
+
this.currentScrollTop = next;
|
|
101
|
+
this.followingEnd = this.followEnd && next === maxScrollTop;
|
|
102
|
+
this.markScrollbarActivity();
|
|
103
|
+
this.requestRenderCallback?.();
|
|
104
|
+
}
|
|
105
|
+
scrollBy(lines) {
|
|
106
|
+
const requested = Number.isFinite(lines) ? Math.trunc(lines) : 0;
|
|
107
|
+
if (requested === 0)
|
|
108
|
+
return 0;
|
|
109
|
+
const maxScrollTop = Math.max(0, this.contentHeight - this.currentViewportHeight);
|
|
110
|
+
const start = this.followingEnd ? maxScrollTop : this.currentScrollTop;
|
|
111
|
+
const next = Math.max(0, Math.min(maxScrollTop, start + requested));
|
|
112
|
+
const moved = next - start;
|
|
113
|
+
this.currentScrollTop = next;
|
|
114
|
+
this.followingEnd = this.followEnd && next === maxScrollTop;
|
|
115
|
+
if (moved !== 0) {
|
|
116
|
+
this.markScrollbarActivity();
|
|
117
|
+
this.requestRenderCallback?.();
|
|
118
|
+
}
|
|
119
|
+
return requested - moved;
|
|
120
|
+
}
|
|
121
|
+
scrollToStart() {
|
|
122
|
+
const changed = this.currentScrollTop !== 0 ||
|
|
123
|
+
this.followingEnd !== (this.followEnd && this.contentHeight <= this.currentViewportHeight);
|
|
124
|
+
this.currentScrollTop = 0;
|
|
125
|
+
this.followingEnd = this.followEnd && this.contentHeight <= this.currentViewportHeight;
|
|
126
|
+
if (changed) {
|
|
127
|
+
this.markScrollbarActivity();
|
|
128
|
+
this.requestRenderCallback?.();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
scrollToEnd() {
|
|
132
|
+
const next = Math.max(0, this.contentHeight - this.currentViewportHeight);
|
|
133
|
+
const changed = this.currentScrollTop !== next || this.followingEnd !== this.followEnd;
|
|
134
|
+
this.currentScrollTop = next;
|
|
135
|
+
this.followingEnd = this.followEnd;
|
|
136
|
+
if (changed) {
|
|
137
|
+
this.markScrollbarActivity();
|
|
138
|
+
this.requestRenderCallback?.();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
updateLayout(contentHeight, viewportHeight, requestRender) {
|
|
142
|
+
this.contentHeight = Math.max(0, Math.floor(contentHeight));
|
|
143
|
+
this.currentViewportHeight = Math.max(0, Math.floor(viewportHeight));
|
|
144
|
+
this.requestRenderCallback = requestRender;
|
|
145
|
+
const maxScrollTop = Math.max(0, this.contentHeight - this.currentViewportHeight);
|
|
146
|
+
if (this.followingEnd)
|
|
147
|
+
this.currentScrollTop = maxScrollTop;
|
|
148
|
+
else
|
|
149
|
+
this.currentScrollTop = Math.max(0, Math.min(this.currentScrollTop, maxScrollTop));
|
|
150
|
+
if (this.followEnd && this.currentScrollTop === maxScrollTop)
|
|
151
|
+
this.followingEnd = true;
|
|
152
|
+
if (this.contentHeight <= this.currentViewportHeight)
|
|
153
|
+
this.hideTransientScrollbar();
|
|
154
|
+
}
|
|
155
|
+
addChild(_component) {
|
|
156
|
+
throw new Error("ScrollView has exactly one child");
|
|
157
|
+
}
|
|
158
|
+
removeChild(_component) {
|
|
159
|
+
throw new Error("ScrollView child cannot be removed");
|
|
160
|
+
}
|
|
161
|
+
clear() {
|
|
162
|
+
throw new Error("ScrollView child cannot be cleared");
|
|
163
|
+
}
|
|
164
|
+
render(width) {
|
|
165
|
+
const contentWidth = this.getContentWidth(width);
|
|
166
|
+
const lines = this.child.render(contentWidth);
|
|
167
|
+
return contentWidth === width ? lines : lines.map((line) => `${line} `);
|
|
168
|
+
}
|
|
169
|
+
[LAYOUT_NODE]() {
|
|
170
|
+
return { type: "scroll", component: this.child, state: this };
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=scroll-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll-view.js","sourceRoot":"","sources":["../../src/components/scroll-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA4D,MAAM,mBAAmB,CAAC;AAC1G,OAAO,EAAkB,SAAS,EAAE,MAAM,WAAW,CAAC;AAgBtD,MAAM,OAAO,UAAW,SAAQ,SAAS;IACvB,KAAK,CAAY;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C,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAC9C,OAAO,YAAY,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;IAAA,CACxE;IAED,CAAC,WAAW,CAAC,GAAqB;QACjC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAAA,CAC9D;CACD","sourcesContent":["import { LAYOUT_NODE, type ScrollLayoutNode, type ScrollViewOverscrollBehavior } from \"../layout-node.ts\";\nimport { type Component, Container } from \"../tui.ts\";\n\nexport type ScrollViewFollowMode = \"none\" | \"end\";\nexport type { ScrollViewOverscrollBehavior } from \"../layout-node.ts\";\nexport type ScrollViewScrollbar = \"hidden\" | \"auto\" | \"always\";\n\nexport interface ScrollViewOptions {\n\taxis?: \"vertical\";\n\tfollow?: ScrollViewFollowMode;\n\tprimary?: boolean;\n\toverscroll?: ScrollViewOverscrollBehavior;\n\tscrollbar?: ScrollViewScrollbar;\n\tscrollbarStyle?: (text: string) => string;\n\tscrollbarHideDelayMs?: number;\n}\n\nexport class ScrollView extends Container {\n\tprivate readonly child: Component;\n\tprivate readonly followEnd: boolean;\n\treadonly primary: boolean;\n\treadonly overscroll: ScrollViewOverscrollBehavior;\n\treadonly scrollbarStyle: (text: string) => string;\n\tprivate currentScrollbar: ScrollViewScrollbar;\n\tprivate readonly scrollbarHideDelayMs: number;\n\tprivate currentScrollTop = 0;\n\tprivate contentHeight = 0;\n\tprivate currentViewportHeight = 0;\n\tprivate followingEnd: boolean;\n\tprivate requestRenderCallback: (() => void) | undefined;\n\tprivate transientScrollbarVisible = false;\n\tprivate scrollbarActive = false;\n\tprivate scrollbarHideTimer: NodeJS.Timeout | undefined;\n\n\tconstructor(component: Component, options: ScrollViewOptions = {}) {\n\t\tsuper();\n\t\tif (options.axis !== undefined && options.axis !== \"vertical\") {\n\t\t\tthrow new Error(`Unsupported ScrollView axis: ${options.axis}`);\n\t\t}\n\t\tthis.child = component;\n\t\tthis.children.push(component);\n\t\tthis.followEnd = (options.follow ?? \"none\") === \"end\";\n\t\tthis.followingEnd = this.followEnd;\n\t\tthis.primary = options.primary ?? false;\n\t\tthis.overscroll = options.overscroll ?? \"chain\";\n\t\tthis.currentScrollbar = options.scrollbar ?? \"hidden\";\n\t\tthis.scrollbarStyle = options.scrollbarStyle ?? ((text) => `\\x1b[100m${text}\\x1b[49m`);\n\t\tthis.scrollbarHideDelayMs = Math.max(0, Math.floor(options.scrollbarHideDelayMs ?? 1000));\n\t}\n\n\tget scrollTop(): number {\n\t\treturn this.currentScrollTop;\n\t}\n\n\tget isFollowingEnd(): boolean {\n\t\treturn this.followingEnd;\n\t}\n\n\tget viewportHeight(): number {\n\t\treturn this.currentViewportHeight;\n\t}\n\n\tget scrollbar(): ScrollViewScrollbar {\n\t\treturn this.currentScrollbar;\n\t}\n\n\tget isScrollbarVisible(): boolean {\n\t\tif (this.scrollbar === \"always\") return this.currentViewportHeight > 0;\n\t\treturn (\n\t\t\tthis.scrollbar === \"auto\" && this.contentHeight > this.currentViewportHeight && this.transientScrollbarVisible\n\t\t);\n\t}\n\n\tsetScrollbar(scrollbar: ScrollViewScrollbar): void {\n\t\tif (scrollbar === this.currentScrollbar) return;\n\t\tthis.currentScrollbar = scrollbar;\n\t\tif (scrollbar !== \"auto\") this.hideTransientScrollbar();\n\t\telse if (this.scrollbarActive) this.markScrollbarActivity();\n\t\tthis.requestRenderCallback?.();\n\t}\n\n\tgetContentWidth(width: number): number {\n\t\treturn this.scrollbar === \"always\" && width > 1 ? width - 1 : width;\n\t}\n\n\tprivate markScrollbarActivity(): void {\n\t\tif (this.scrollbar !== \"auto\" || this.contentHeight <= this.currentViewportHeight) return;\n\t\tthis.transientScrollbarVisible = true;\n\t\tif (this.scrollbarHideTimer) {\n\t\t\tclearTimeout(this.scrollbarHideTimer);\n\t\t\tthis.scrollbarHideTimer = undefined;\n\t\t}\n\t\tif (this.scrollbarActive) return;\n\t\tthis.scrollbarHideTimer = setTimeout(() => {\n\t\t\tthis.scrollbarHideTimer = undefined;\n\t\t\tthis.transientScrollbarVisible = false;\n\t\t\tthis.requestRenderCallback?.();\n\t\t}, this.scrollbarHideDelayMs);\n\t\tthis.scrollbarHideTimer.unref();\n\t}\n\n\tprivate hideTransientScrollbar(): void {\n\t\tthis.transientScrollbarVisible = false;\n\t\tif (!this.scrollbarHideTimer) return;\n\t\tclearTimeout(this.scrollbarHideTimer);\n\t\tthis.scrollbarHideTimer = undefined;\n\t}\n\n\tsetScrollbarActive(active: boolean): void {\n\t\tif (active === this.scrollbarActive) return;\n\t\tthis.scrollbarActive = active;\n\t\tthis.markScrollbarActivity();\n\t}\n\n\tscrollTo(scrollTop: number): void {\n\t\tconst requested = Number.isFinite(scrollTop) ? Math.trunc(scrollTop) : this.currentScrollTop;\n\t\tconst maxScrollTop = Math.max(0, this.contentHeight - this.currentViewportHeight);\n\t\tconst next = Math.max(0, Math.min(maxScrollTop, requested));\n\t\tif (next === this.currentScrollTop) return;\n\t\tthis.currentScrollTop = next;\n\t\tthis.followingEnd = this.followEnd && next === maxScrollTop;\n\t\tthis.markScrollbarActivity();\n\t\tthis.requestRenderCallback?.();\n\t}\n\n\tscrollBy(lines: number): number {\n\t\tconst requested = Number.isFinite(lines) ? Math.trunc(lines) : 0;\n\t\tif (requested === 0) return 0;\n\t\tconst maxScrollTop = Math.max(0, this.contentHeight - this.currentViewportHeight);\n\t\tconst start = this.followingEnd ? maxScrollTop : this.currentScrollTop;\n\t\tconst next = Math.max(0, Math.min(maxScrollTop, start + requested));\n\t\tconst moved = next - start;\n\t\tthis.currentScrollTop = next;\n\t\tthis.followingEnd = this.followEnd && next === maxScrollTop;\n\t\tif (moved !== 0) {\n\t\t\tthis.markScrollbarActivity();\n\t\t\tthis.requestRenderCallback?.();\n\t\t}\n\t\treturn requested - moved;\n\t}\n\n\tscrollToStart(): void {\n\t\tconst changed =\n\t\t\tthis.currentScrollTop !== 0 ||\n\t\t\tthis.followingEnd !== (this.followEnd && this.contentHeight <= this.currentViewportHeight);\n\t\tthis.currentScrollTop = 0;\n\t\tthis.followingEnd = this.followEnd && this.contentHeight <= this.currentViewportHeight;\n\t\tif (changed) {\n\t\t\tthis.markScrollbarActivity();\n\t\t\tthis.requestRenderCallback?.();\n\t\t}\n\t}\n\n\tscrollToEnd(): void {\n\t\tconst next = Math.max(0, this.contentHeight - this.currentViewportHeight);\n\t\tconst changed = this.currentScrollTop !== next || this.followingEnd !== this.followEnd;\n\t\tthis.currentScrollTop = next;\n\t\tthis.followingEnd = this.followEnd;\n\t\tif (changed) {\n\t\t\tthis.markScrollbarActivity();\n\t\t\tthis.requestRenderCallback?.();\n\t\t}\n\t}\n\n\tupdateLayout(contentHeight: number, viewportHeight: number, requestRender: () => void): void {\n\t\tthis.contentHeight = Math.max(0, Math.floor(contentHeight));\n\t\tthis.currentViewportHeight = Math.max(0, Math.floor(viewportHeight));\n\t\tthis.requestRenderCallback = requestRender;\n\t\tconst maxScrollTop = Math.max(0, this.contentHeight - this.currentViewportHeight);\n\t\tif (this.followingEnd) this.currentScrollTop = maxScrollTop;\n\t\telse this.currentScrollTop = Math.max(0, Math.min(this.currentScrollTop, maxScrollTop));\n\t\tif (this.followEnd && this.currentScrollTop === maxScrollTop) this.followingEnd = true;\n\t\tif (this.contentHeight <= this.currentViewportHeight) this.hideTransientScrollbar();\n\t}\n\n\toverride addChild(_component: Component): void {\n\t\tthrow new Error(\"ScrollView has exactly one child\");\n\t}\n\n\toverride removeChild(_component: Component): void {\n\t\tthrow new Error(\"ScrollView child cannot be removed\");\n\t}\n\n\toverride clear(): void {\n\t\tthrow new Error(\"ScrollView child cannot be cleared\");\n\t}\n\n\toverride render(width: number): string[] {\n\t\tconst contentWidth = this.getContentWidth(width);\n\t\tconst lines = this.child.render(contentWidth);\n\t\treturn contentWidth === width ? lines : lines.map((line) => `${line} `);\n\t}\n\n\t[LAYOUT_NODE](): ScrollLayoutNode {\n\t\treturn { type: \"scroll\", component: this.child, state: this };\n\t}\n}\n"]}
|