pdf-kalem 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{Page-Co_MgZDL.d.ts → Page-CsUKWyUj.d.ts} +1 -1
- package/dist/{PdfDoc-jjqPxRSC.d.ts → PdfDoc-BrQ03kn0.d.ts} +2 -2
- package/dist/{PdfPageSurface-1DVsuYJ2.d.ts → PdfPageSurface-Dzx68rek.d.ts} +1 -1
- package/dist/{PdfRenderContext-C12DDr-w.d.ts → PdfRenderContext-DdmsufQc.d.ts} +3 -3
- package/dist/{Table-DevmMUtU.d.ts → Table-B1JgJINU.d.ts} +1 -1
- package/dist/{Widget-DzXseZEZ.d.ts → Widget-D-wA9-fw.d.ts} +3 -0
- package/dist/{chunk-6VRKPGB5.js → chunk-2P5P7KF5.js} +156 -1
- package/dist/chunk-2P5P7KF5.js.map +1 -0
- package/dist/{chunk-5ZRRZRCD.js → chunk-2RBUCDMS.js} +5 -5
- package/dist/{chunk-SEKYHTYU.js → chunk-AITTHKEP.js} +31 -50
- package/dist/chunk-AITTHKEP.js.map +1 -0
- package/dist/{chunk-LYSHPJ3R.js → chunk-CKBKBBHC.js} +3 -5
- package/dist/{chunk-LYSHPJ3R.js.map → chunk-CKBKBBHC.js.map} +1 -1
- package/dist/chunk-MBZC4ZQH.js +457 -0
- package/dist/chunk-MBZC4ZQH.js.map +1 -0
- package/dist/{chunk-PIBYCKYY.js → chunk-SBH3Y5H7.js} +13 -14
- package/dist/chunk-SBH3Y5H7.js.map +1 -0
- package/dist/{chunk-OS4HN6KV.js → chunk-TWNM3K3Y.js} +4 -4
- package/dist/edit.d.ts +2 -2
- package/dist/edit.js +5 -6
- package/dist/edit.js.map +1 -1
- package/dist/forms.d.ts +2 -2
- package/dist/forms.js +3 -5
- package/dist/forms.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -6
- package/dist/index.js.map +1 -1
- package/dist/internals.d.ts +12 -4
- package/dist/internals.js +3 -3
- package/dist/markdown.d.ts +6 -6
- package/dist/markdown.js +7 -8
- package/dist/markdown.js.map +1 -1
- package/dist/preview.d.ts +11 -4
- package/dist/preview.js +17 -7
- package/dist/preview.js.map +1 -1
- package/dist/{surface-hkLPm11r.d.ts → surface-BJ7MIOTD.d.ts} +1 -1
- package/dist/widgets.d.ts +20 -13
- package/dist/widgets.js +18 -129
- package/dist/widgets.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-6VRKPGB5.js.map +0 -1
- package/dist/chunk-IGVDPDCZ.js +0 -258
- package/dist/chunk-IGVDPDCZ.js.map +0 -1
- package/dist/chunk-PCKIGCEJ.js +0 -198
- package/dist/chunk-PCKIGCEJ.js.map +0 -1
- package/dist/chunk-PIBYCKYY.js.map +0 -1
- package/dist/chunk-SEKYHTYU.js.map +0 -1
- /package/dist/{chunk-5ZRRZRCD.js.map → chunk-2RBUCDMS.js.map} +0 -0
- /package/dist/{chunk-OS4HN6KV.js.map → chunk-TWNM3K3Y.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/TextLayoutEngine.ts","../src/lib/TextPainter.ts","../src/lib/Text.ts","../src/lib/Container.ts","../src/lib/Row.ts","../src/lib/Column.ts","../src/lib/Image.ts","../src/lib/Table.ts","../src/lib/HLine.ts"],"sourcesContent":["import {\n layoutWithLines,\n measureNaturalWidth,\n prepareWithSegments,\n type PrepareOptions,\n type PreparedTextWithSegments,\n} from '@chenglou/pretext';\n\n/**\n * A single laid-out line of text: the substring to draw and its measured\n * width in the configured font/size.\n *\n * For rich-run text, `fragments` maps each styled piece of the line back to\n * its run (`runIndex` into the config's runs); the painter draws per-fragment\n * fonts/colors from it. Plain text lines carry no fragments.\n */\nexport interface TextLayoutLine {\n text: string;\n width: number;\n fragments?: LineFragment[];\n}\n\n/** A styled piece of a laid-out line, belonging to run `runIndex`. */\nexport interface LineFragment {\n runIndex: number;\n text: string;\n width: number;\n}\n\n/**\n * A run as the engine sees it: fully resolved down to a concrete font name.\n * Style flags (bold/italic/mono) are the caller's concern — the engine only\n * needs text plus the font that measures and draws it.\n */\nexport interface EngineRun {\n text: string;\n fontName: string;\n}\n\n/**\n * Result of laying out a block of text into lines.\n */\nexport interface TextLayoutResult {\n lines: TextLayoutLine[];\n maxLineWidth: number;\n}\n\n/**\n * How a text block should behave when it overflows its box.\n * - `visible`: no height-derived truncation — lines beyond the box stay\n * laid out. An explicit `maxLines` still clamps (CSS line-clamp\n * semantics); `overflow` only chooses the indicator for that clamp.\n * - `clip`: lines beyond the limit are dropped.\n * - `ellipsis`: the last visible line is truncated with an ellipsis.\n */\nexport type TextOverflow = 'visible' | 'clip' | 'ellipsis';\n\n/**\n * Pure configuration for {@link TextLayoutEngine}. Everything the engine\n * needs to measure and wrap text, with no dependency on theme, widgets, or\n * render context. Callers (e.g. {@link TextWidget}) are responsible for\n * resolving theme tokens into concrete values before constructing an engine.\n */\nexport interface TextLayoutConfig {\n /** The raw text to lay out. */\n text: string;\n /** Font size in PDF points. */\n size: number;\n /** Line height in PDF points. */\n lineHeight: number;\n /** Horizontal alignment of lines within the layout width. */\n align: 'left' | 'center' | 'right';\n /** Font ascent in PDF points, used to position the baseline. */\n ascent: number;\n /** `whiteSpace` mode forwarded to pretext. */\n whiteSpace: PrepareOptions['whiteSpace'];\n /** `wordBreak` mode forwarded to pretext. */\n wordBreak: PrepareOptions['wordBreak'];\n /** Max visible lines before overflow handling kicks in. */\n maxLines?: number;\n /** Overflow behavior when content exceeds `maxLines` / height. */\n overflow: TextOverflow;\n /**\n * Measures the width of a string in the configured font/size.\n * Implementations typically delegate to `RenderContext.measureTextWidth`.\n */\n measureTextWidth: (text: string) => number;\n /**\n * Rich runs to lay out instead of `text`. When present, the engine wraps\n * across run boundaries (including mid-word) and emits per-run fragments;\n * `text` is ignored for layout (it stays the flattened plain text for\n * font preloading and back-compat).\n */\n runs?: ReadonlyArray<EngineRun>;\n /**\n * Measures the width of a string in a specific run's font. Required when\n * `runs` is set; falls back to a per-character estimate otherwise.\n */\n measureRunWidth?: (text: string, fontName: string) => number;\n /**\n * Returns the natural (unwrapped) width of the text. Optional; defaults to\n * measuring the full string. Provided separately because pretext can\n * compute this more accurately than a naive measurement.\n */\n measureNaturalWidth?: () => number;\n}\n\n/** A piece of styled text: `runIndex` indexes into the config's runs. */\ninterface RichPiece {\n runIndex: number;\n text: string;\n}\n\n/** A word: consecutive non-whitespace pieces, possibly spanning several runs. */\ninterface RichWord {\n /** Whitespace pieces preceding the word (collapsed or preserved). */\n pre: RichPiece[];\n pieces: RichPiece[];\n}\n\n/** A hard-break segment (`\\n`) of rich text: words separated by whitespace. */\ninterface RichParagraph {\n words: RichWord[];\n}\n\n/**\n * Pure text layout engine: measures, wraps, and truncates text into lines.\n *\n * This is the shared core that used to be duplicated between `TextWidget`\n * and `LinkWidget`. It has no knowledge of themes, widgets, yoga, or render\n * contexts — it only knows how to turn a {@link TextLayoutConfig} into a\n * {@link TextLayoutResult}. Painting the result is the job of\n * {@link TextPainter}.\n */\nexport class TextLayoutEngine {\n private readonly config: TextLayoutConfig;\n private readonly graphemeSegmenter: Intl.Segmenter | undefined;\n private preparedText?: PreparedTextWithSegments;\n private preparedTextKey?: string;\n\n constructor(config: TextLayoutConfig) {\n this.config = config;\n this.graphemeSegmenter =\n typeof Intl !== 'undefined' && 'Segmenter' in Intl\n ? new Intl.Segmenter(undefined, { granularity: 'grapheme' })\n : undefined;\n }\n\n private canUsePretext(): boolean {\n if (typeof Intl === 'undefined' || !('Segmenter' in Intl)) {\n return false;\n }\n // Pretext measures through a canvas (OffscreenCanvas or DOM canvas).\n // Without one (e.g. Node) it throws, so fall back to the built-in wrapper.\n return (\n typeof OffscreenCanvas !== 'undefined' ||\n (typeof document !== 'undefined' && typeof document.createElement === 'function')\n );\n }\n\n /**\n * Lazily prepares the text with pretext (grapheme-aware segmentation) for\n * accurate wrapping. Cached by (text, font, whiteSpace, wordBreak).\n */\n ensurePreparedText(canvasFont: string): PreparedTextWithSegments | undefined {\n // Rich runs bypass pretext: they measure through `measureRunWidth` (the\n // same font that draws), so no canvas-backed preparation is needed.\n if (this.config.runs) {\n return undefined;\n }\n\n if (!this.canUsePretext()) {\n return undefined;\n }\n\n const key = JSON.stringify([\n this.config.text,\n canvasFont,\n this.config.whiteSpace,\n this.config.wordBreak,\n ]);\n\n if (this.preparedText && this.preparedTextKey === key) {\n return this.preparedText;\n }\n\n this.preparedText = prepareWithSegments(\n this.config.text,\n canvasFont,\n { whiteSpace: this.config.whiteSpace, wordBreak: this.config.wordBreak }\n );\n this.preparedTextKey = key;\n return this.preparedText;\n }\n\n /** Natural (unwrapped) width of the text. */\n getNaturalWidth(canvasFont: string): number {\n if (this.config.runs) {\n return this.getRichNaturalWidth();\n }\n\n const preparedText = this.ensurePreparedText(canvasFont);\n if (preparedText) {\n return measureNaturalWidth(preparedText);\n }\n return this.config.measureTextWidth(this.config.text);\n }\n\n /**\n * Maximum number of lines that fit in `height`, or `undefined` if height\n * is unbounded.\n */\n getHeightLineLimit(height: number): number | undefined {\n if (!Number.isFinite(height) || height <= 0) {\n return undefined;\n }\n return Math.max(0, Math.floor((height + 0.001) / this.config.lineHeight));\n }\n\n private getEffectiveMaxLines(heightLineLimit?: number): number | undefined {\n const limits: number[] = [];\n\n if (\n typeof this.config.maxLines === 'number' &&\n Number.isFinite(this.config.maxLines) &&\n this.config.maxLines >= 0\n ) {\n limits.push(Math.floor(this.config.maxLines));\n }\n\n if (this.config.overflow !== 'visible' && heightLineLimit !== undefined) {\n limits.push(heightLineLimit);\n }\n\n if (limits.length === 0) {\n return undefined;\n }\n\n return Math.max(0, Math.min(...limits));\n }\n\n private splitGraphemes(text: string): string[] {\n if (!this.graphemeSegmenter) {\n return Array.from(text);\n }\n return Array.from(this.graphemeSegmenter.segment(text), (segment) => segment.segment);\n }\n\n private ellipsizeLine(text: string, maxWidth: number): TextLayoutLine {\n if (maxWidth <= 0) {\n return { text: '', width: 0 };\n }\n\n const ellipsis = '…';\n const ellipsisWidth = this.config.measureTextWidth(ellipsis);\n if (ellipsisWidth > maxWidth) {\n return { text: '', width: 0 };\n }\n\n const trimmedText = text.replace(/\\s+$/u, '');\n const graphemes = this.splitGraphemes(trimmedText);\n let low = 0;\n let high = graphemes.length;\n let best = ellipsis;\n let bestWidth = ellipsisWidth;\n\n while (low <= high) {\n const mid = Math.floor((low + high) / 2);\n const prefix = graphemes.slice(0, mid).join('').replace(/\\s+$/u, '');\n const candidate = prefix ? `${prefix}${ellipsis}` : ellipsis;\n const candidateWidth = this.config.measureTextWidth(candidate);\n\n if (candidateWidth <= maxWidth) {\n best = candidate;\n bestWidth = candidateWidth;\n low = mid + 1;\n } else {\n high = mid - 1;\n }\n }\n\n return { text: best, width: bestWidth };\n }\n\n private appendFallbackLine(lines: TextLayoutLine[], lineText: string): void {\n lines.push({ text: lineText, width: this.config.measureTextWidth(lineText) });\n }\n\n private breakLongToken(token: string, maxWidth: number): TextLayoutLine[] {\n if (maxWidth <= 0) {\n return [{ text: token, width: this.config.measureTextWidth(token) }];\n }\n\n const graphemes = this.splitGraphemes(token);\n const lines: TextLayoutLine[] = [];\n let current = '';\n\n for (const grapheme of graphemes) {\n const candidate = current + grapheme;\n if (!current || this.config.measureTextWidth(candidate) <= maxWidth) {\n current = candidate;\n continue;\n }\n\n lines.push({ text: current, width: this.config.measureTextWidth(current) });\n current = grapheme;\n }\n\n if (current) {\n lines.push({ text: current, width: this.config.measureTextWidth(current) });\n }\n\n return lines;\n }\n\n private layoutFallback(maxWidth: number): TextLayoutLine[] {\n const normalizedText = this.config.text.replace(/\\r\\n?/g, '\\n');\n const paragraphs = normalizedText.split('\\n');\n const lines: TextLayoutLine[] = [];\n\n for (const paragraph of paragraphs) {\n const normalizedParagraph = this.config.whiteSpace === 'pre-wrap'\n ? paragraph.replace(/\\t/g, ' ')\n : paragraph.trim().replace(/\\s+/g, ' ');\n\n if (!normalizedParagraph) {\n this.appendFallbackLine(lines, '');\n continue;\n }\n\n const words = normalizedParagraph.split(' ');\n\n // pre-wrap preserves a whitespace-only paragraph literally (the rich\n // path keeps it as a space-only word); the split(' ') walk below\n // produces only empty words for it, so emit it as-is (B20).\n if (this.config.whiteSpace === 'pre-wrap' && words.every((word) => word === '')) {\n this.appendFallbackLine(lines, normalizedParagraph);\n continue;\n }\n\n let currentLine = '';\n\n for (const word of words) {\n const candidate = currentLine ? `${currentLine} ${word}` : word;\n if (maxWidth <= 0 || this.config.measureTextWidth(candidate) <= maxWidth) {\n currentLine = candidate;\n continue;\n }\n\n if (currentLine) {\n this.appendFallbackLine(lines, currentLine);\n currentLine = '';\n }\n\n if (this.config.measureTextWidth(word) <= maxWidth || maxWidth <= 0) {\n currentLine = word;\n continue;\n }\n\n const brokenWordLines = this.breakLongToken(word, maxWidth);\n lines.push(...brokenWordLines.slice(0, -1));\n currentLine = brokenWordLines[brokenWordLines.length - 1]?.text ?? '';\n }\n\n if (currentLine || normalizedParagraph.length === 0) {\n this.appendFallbackLine(lines, currentLine);\n }\n }\n\n if (paragraphs.length === 0) {\n return [];\n }\n\n return lines;\n }\n\n // --- Rich-run layout ---\n\n /** Lays out rich runs into lines constrained to `maxWidth`. */\n private layoutRichText(maxWidth: number, heightLineLimit?: number): TextLayoutResult {\n const effectiveWidth = maxWidth > 0 ? maxWidth : this.getRichNaturalWidth();\n let lines = this.layoutRichLines(effectiveWidth);\n\n const effectiveMaxLines = this.getEffectiveMaxLines(heightLineLimit);\n const visibleLines = effectiveMaxLines === undefined ? lines : lines.slice(0, effectiveMaxLines);\n const wasTruncated = effectiveMaxLines !== undefined && lines.length > visibleLines.length;\n\n if (wasTruncated && this.config.overflow === 'ellipsis' && visibleLines.length > 0) {\n const last = visibleLines.length - 1;\n visibleLines[last] = this.ellipsizeRichLine(visibleLines[last], effectiveWidth);\n }\n\n return {\n lines: visibleLines,\n maxLineWidth: visibleLines.reduce((max, line) => Math.max(max, line.width), 0),\n };\n }\n\n /**\n * Lays out the text into lines constrained to `maxWidth` (and optionally a\n * height-derived line limit). Applies `overflow` truncation.\n */\n layoutText(maxWidth: number, heightLineLimit?: number, canvasFont?: string): TextLayoutResult {\n if (this.config.runs) {\n return this.layoutRichText(maxWidth, heightLineLimit);\n }\n\n const preparedText = canvasFont ? this.ensurePreparedText(canvasFont) : undefined;\n const effectiveWidth = maxWidth > 0 ? maxWidth : this.getNaturalWidth(canvasFont ?? '');\n const rawLines = preparedText\n ? layoutWithLines(preparedText, effectiveWidth, this.config.lineHeight).lines.map((line) => ({\n text: line.text,\n width: line.width,\n }))\n : this.layoutFallback(effectiveWidth);\n\n const effectiveMaxLines = this.getEffectiveMaxLines(heightLineLimit);\n const visibleLines = effectiveMaxLines === undefined ? rawLines : rawLines.slice(0, effectiveMaxLines);\n const wasTruncated = effectiveMaxLines !== undefined && rawLines.length > visibleLines.length;\n const lines = [...visibleLines];\n\n if (wasTruncated && this.config.overflow === 'ellipsis' && lines.length > 0) {\n lines[lines.length - 1] = this.ellipsizeLine(lines[lines.length - 1].text, effectiveWidth);\n }\n\n return {\n lines,\n maxLineWidth: lines.reduce((max, line) => Math.max(max, line.width), 0),\n };\n }\n\n // --- Rich-run layout internals ---\n\n private richParagraphs?: RichParagraph[];\n\n /** The font name that measures and draws run `runIndex`. */\n private runFontName(runIndex: number): string {\n return this.config.runs![runIndex].fontName;\n }\n\n private measureRunWidthFor(runIndex: number, text: string): number {\n const measure = this.config.measureRunWidth;\n if (measure) {\n return measure(text, this.runFontName(runIndex));\n }\n return text.length * this.config.size * 0.6;\n }\n\n private measureRichPiece(piece: RichPiece): number {\n return this.measureRunWidthFor(piece.runIndex, piece.text);\n }\n\n /**\n * Tokenizes the runs into paragraphs (split at `\\n`), words (maximal\n * non-whitespace spans, possibly spanning several runs), and the whitespace\n * pieces preceding each word.\n *\n * `normal` whiteSpace collapses each whitespace span to a single space\n * owned by the first run contributing to it and drops paragraph-edge\n * spaces, matching the plain-text fallback. `pre-wrap` preserves\n * whitespace literally (tabs expand to 8 spaces), including at edges.\n */\n private getRichParagraphs(): RichParagraph[] {\n if (this.richParagraphs) {\n return this.richParagraphs;\n }\n\n const runs = this.config.runs ?? [];\n const preWrap = this.config.whiteSpace === 'pre-wrap';\n const paragraphs: RichParagraph[] = [];\n let words: RichWord[] = [];\n let word: RichPiece[] | null = null;\n let pendingPre: RichPiece[] = [];\n\n const flushWord = () => {\n if (word && word.length > 0) {\n words.push({ pre: pendingPre, pieces: word });\n pendingPre = [];\n }\n word = null;\n };\n\n const flushParagraph = () => {\n flushWord();\n if (preWrap && pendingPre.length > 0) {\n // pre-wrap keeps paragraph-edge whitespace as a space-only word.\n words.push({ pre: [], pieces: pendingPre });\n }\n pendingPre = [];\n paragraphs.push({ words });\n words = [];\n };\n\n for (let runIndex = 0; runIndex < runs.length; runIndex++) {\n let text = runs[runIndex].text.replace(/\\r\\n?/g, '\\n');\n if (preWrap) {\n text = text.replace(/\\t/g, ' ');\n }\n\n const segments = text.split('\\n');\n for (let s = 0; s < segments.length; s++) {\n if (s > 0) {\n flushParagraph();\n }\n\n const chunks = segments[s].split(/([^\\S\\n]+)/);\n for (let i = 0; i < chunks.length; i++) {\n const chunk = chunks[i];\n if (!chunk) {\n continue;\n }\n\n if (i % 2 === 1) {\n flushWord();\n if (preWrap) {\n const last = pendingPre[pendingPre.length - 1];\n if (last && last.runIndex === runIndex) {\n last.text += chunk;\n } else {\n pendingPre.push({ runIndex, text: chunk });\n }\n } else if (pendingPre.length === 0) {\n // Collapse the span to one space, owned by the first run\n // that contributed whitespace.\n pendingPre.push({ runIndex, text: ' ' });\n }\n } else if (word) {\n word.push({ runIndex, text: chunk });\n } else {\n word = [{ runIndex, text: chunk }];\n }\n }\n }\n }\n flushParagraph();\n\n this.richParagraphs = paragraphs;\n return paragraphs;\n }\n\n /** Natural (unwrapped) width: every piece measured in its own run's font. */\n private getRichNaturalWidth(): number {\n let total = 0;\n for (const paragraph of this.getRichParagraphs()) {\n for (const word of paragraph.words) {\n for (const piece of word.pre) {\n total += this.measureRichPiece(piece);\n }\n for (const piece of word.pieces) {\n total += this.measureRichPiece(piece);\n }\n }\n }\n return total;\n }\n\n /**\n * Greedy word-wrap across runs. A word's whitespace pieces travel with it;\n * when the word starts a fresh line they are dropped in `normal` mode\n * (trailing spaces never paint at line ends) and kept in `pre-wrap`.\n */\n private layoutRichLines(maxWidth: number): TextLayoutLine[] {\n const preWrap = this.config.whiteSpace === 'pre-wrap';\n const lines: TextLayoutLine[] = [];\n\n for (const paragraph of this.getRichParagraphs()) {\n let current: RichPiece[] = [];\n let currentWidth = 0;\n let producedLine = false;\n\n const startWithWord = (word: RichWord): void => {\n const pieces = preWrap ? [...word.pre, ...word.pieces] : [...word.pieces];\n const width = pieces.reduce((sum, piece) => sum + this.measureRichPiece(piece), 0);\n\n if (maxWidth <= 0 || width <= maxWidth) {\n current = pieces;\n currentWidth = width;\n return;\n }\n\n const broken = this.breakRichWord(pieces, maxWidth);\n for (const brokenPieces of broken.lines) {\n lines.push(this.finishRichLine(brokenPieces));\n producedLine = true;\n }\n current = broken.tail;\n currentWidth = broken.tail.reduce((sum, piece) => sum + this.measureRichPiece(piece), 0);\n };\n\n for (const word of paragraph.words) {\n if (current.length === 0) {\n startWithWord(word);\n continue;\n }\n\n const preWidth = word.pre.reduce((sum, piece) => sum + this.measureRichPiece(piece), 0);\n const wordWidth = word.pieces.reduce((sum, piece) => sum + this.measureRichPiece(piece), 0);\n\n if (maxWidth <= 0 || currentWidth + preWidth + wordWidth <= maxWidth) {\n current.push(...word.pre, ...word.pieces);\n currentWidth += preWidth + wordWidth;\n continue;\n }\n\n lines.push(this.finishRichLine(current));\n producedLine = true;\n current = [];\n currentWidth = 0;\n startWithWord(word);\n }\n\n if (current.length > 0) {\n lines.push(this.finishRichLine(current));\n producedLine = true;\n }\n\n if (!producedLine) {\n // Empty paragraph (no words after collapsing) — one blank line,\n // matching the plain-text fallback.\n lines.push({ text: '', width: 0 });\n }\n }\n\n return lines;\n }\n\n /**\n * Splits an over-long word into lines that fit `maxWidth`, breaking at\n * graphemes across piece (run) boundaries. The final partial line comes\n * back as `tail` so the caller can keep filling it with more words.\n */\n private breakRichWord(pieces: RichPiece[], maxWidth: number): { lines: RichPiece[][]; tail: RichPiece[] } {\n const lines: RichPiece[][] = [];\n let line: RichPiece[] = [];\n let lineWidth = 0;\n\n const flushLine = () => {\n if (line.length > 0) {\n lines.push(line);\n line = [];\n lineWidth = 0;\n }\n };\n\n for (const piece of pieces) {\n // Pending text of the piece being walked; committed to the line when\n // it overflows or the piece ends. Kept per-piece so committed text\n // always carries the run it came from.\n let builtText = '';\n let builtTextWidth = 0;\n\n for (const grapheme of this.splitGraphemes(piece.text)) {\n const candidate = builtText + grapheme;\n const candidateWidth = this.measureRunWidthFor(piece.runIndex, candidate);\n\n if (line.length === 0 || maxWidth <= 0 || lineWidth + candidateWidth <= maxWidth) {\n builtText = candidate;\n builtTextWidth = candidateWidth;\n continue;\n }\n\n if (builtText) {\n line.push({ runIndex: piece.runIndex, text: builtText });\n lineWidth += builtTextWidth;\n builtText = '';\n builtTextWidth = 0;\n }\n flushLine();\n builtText = grapheme;\n builtTextWidth = this.measureRunWidthFor(piece.runIndex, grapheme);\n }\n\n if (builtText) {\n line.push({ runIndex: piece.runIndex, text: builtText });\n lineWidth += builtTextWidth;\n }\n }\n\n return { lines, tail: line };\n }\n\n /** Merges consecutive same-run pieces into fragments and measures the line. */\n private finishRichLine(pieces: RichPiece[]): TextLayoutLine {\n const fragments: LineFragment[] = [];\n let width = 0;\n\n for (const piece of pieces) {\n const pieceWidth = this.measureRichPiece(piece);\n width += pieceWidth;\n const last = fragments[fragments.length - 1];\n if (last && last.runIndex === piece.runIndex) {\n last.text += piece.text;\n last.width += pieceWidth;\n } else {\n fragments.push({ runIndex: piece.runIndex, text: piece.text, width: pieceWidth });\n }\n }\n\n return { text: pieces.map((piece) => piece.text).join(''), width, fragments };\n }\n\n /**\n * Truncates a rich line to fit `maxWidth`, appending `…` in the font of\n * the fragment it truncates. Walks fragments left to right and keeps the\n * cut that preserves the most text.\n */\n private ellipsizeRichLine(line: TextLayoutLine, maxWidth: number): TextLayoutLine {\n const fragments = line.fragments ?? [];\n if (maxWidth <= 0) {\n return { text: '', width: 0 };\n }\n\n // A blank last line (no fragments) still shows the ellipsis, in the\n // first run's font — matching the plain path (B20).\n if (fragments.length === 0) {\n const ellipsisWidth = this.measureRunWidthFor(0, '…');\n if (ellipsisWidth <= maxWidth) {\n return {\n text: '…',\n width: ellipsisWidth,\n fragments: [{ runIndex: 0, text: '…', width: ellipsisWidth }],\n };\n }\n return { text: '', width: 0 };\n }\n\n let prefixWidth = 0;\n let best: { index: number; keep: string } | undefined;\n\n for (let index = 0; index < fragments.length; index++) {\n const fragment = fragments[index];\n const ellipsisWidth = this.measureRunWidthFor(fragment.runIndex, '…');\n if (ellipsisWidth > maxWidth) {\n continue;\n }\n\n const graphemes = this.splitGraphemes(fragment.text);\n let low = 0;\n let high = graphemes.length;\n let found = -1;\n while (low <= high) {\n const mid = Math.floor((low + high) / 2);\n const kept = graphemes.slice(0, mid).join('');\n const keptWidth = this.measureRunWidthFor(fragment.runIndex, kept);\n if (prefixWidth + keptWidth + ellipsisWidth <= maxWidth) {\n found = mid;\n low = mid + 1;\n } else {\n high = mid - 1;\n }\n }\n\n if (found >= 0) {\n best = { index, keep: graphemes.slice(0, found).join('') };\n }\n prefixWidth += fragment.width;\n }\n\n if (!best) {\n // No cut fits under the accumulated prefixes — fall back to a bare\n // ellipsis in the first fragment's font (the plain path keeps one).\n const ellipsisWidth = this.measureRunWidthFor(fragments[0].runIndex, '…');\n if (ellipsisWidth <= maxWidth) {\n const runIndex = fragments[0].runIndex;\n return {\n text: '…',\n width: ellipsisWidth,\n fragments: [{ runIndex, text: '…', width: ellipsisWidth }],\n };\n }\n return { text: '', width: 0 };\n }\n\n const kept: LineFragment[] = [];\n for (let index = 0; index <= best.index; index++) {\n const fragment = fragments[index];\n if (index < best.index) {\n kept.push({ ...fragment });\n continue;\n }\n const text = `${best.keep}…`;\n kept.push({ runIndex: fragment.runIndex, text, width: this.measureRunWidthFor(fragment.runIndex, text) });\n }\n\n return {\n text: kept.map((fragment) => fragment.text).join(''),\n width: kept.reduce((sum, fragment) => sum + fragment.width, 0),\n fragments: kept,\n };\n }\n}\n","import type { RenderContext } from './RenderContextInterface';\nimport type { RenderColor } from './RenderContextTypes';\nimport type { LineFragment, TextLayoutLine } from './TextLayoutEngine';\n\n/**\n * A laid-out line positioned for drawing: the substring, its width, and the\n * x/y of its baseline in PDF coordinates. Rich-run lines also carry their\n * fragments positioned at absolute x (whitespace pieces included).\n */\nexport interface PositionedTextLine extends TextLayoutLine {\n x: number;\n y: number;\n fragments?: PositionedFragment[];\n}\n\n/** A {@link LineFragment} resolved to an absolute x position. */\nexport interface PositionedFragment extends LineFragment {\n x: number;\n}\n\n/**\n * Per-run paint style, indexed by fragment `runIndex`. The painter draws\n * each fragment with its own font/color and renders strikethrough/underline\n * for flagged runs.\n */\nexport interface PaintRun {\n fontName: string;\n color: RenderColor;\n strike: boolean;\n underline: boolean;\n}\n\n/**\n * A fully resolved text layout ready to paint: the layout box, the positioned\n * lines, and the max line width.\n */\nexport interface RenderedTextLayout {\n box: { x: number; y: number; width: number; height: number };\n lines: PositionedTextLine[];\n maxWidth: number;\n}\n\n/**\n * Paints a {@link RenderedTextLayout} onto a {@link RenderContext}.\n *\n * This is the shared drawing concern that used to be duplicated between\n * `TextWidget` and `LinkWidget`. It knows nothing about themes or widgets —\n * callers hand it concrete font name, size, color, and an optional underline.\n */\nexport class TextPainter {\n /** Strikethrough sits ~0.28em above the baseline. */\n private static strikeOffset(size: number): number {\n return size * 0.28;\n }\n\n /**\n * Draws each line of `layout` at its baseline. Lines carrying fragments\n * draw per-fragment fonts/colors/strikethrough from `options.runs`; plain\n * lines draw whole with `options.fontName`/`color`, optionally underlined.\n */\n static async paint(\n context: RenderContext,\n layout: RenderedTextLayout,\n options: {\n size: number;\n color: RenderColor;\n fontName: string;\n underline?: boolean;\n underlineColor?: RenderColor;\n runs?: ReadonlyArray<PaintRun>;\n }\n ): Promise<void> {\n for (const line of layout.lines) {\n if (line.fragments && options.runs) {\n for (const fragment of line.fragments) {\n const run = options.runs[fragment.runIndex];\n if (!run) {\n continue;\n }\n\n await context.drawText({\n text: fragment.text,\n x: fragment.x,\n y: line.y,\n size: options.size,\n color: run.color,\n fontName: run.fontName,\n });\n\n if (run.strike) {\n // PDF y grows up: the strike sits ~0.28em ABOVE the baseline\n // (subtracting would draw it below the baseline, like an\n // underline).\n const strikeY = line.y + TextPainter.strikeOffset(options.size);\n context.drawLine({\n start: { x: fragment.x, y: strikeY },\n end: { x: fragment.x + fragment.width, y: strikeY },\n thickness: Math.max(0.5, options.size * 0.06),\n color: run.color,\n });\n }\n\n if (options.underline || run.underline) {\n const underlineY = line.y - Math.max(1, options.size * 0.08);\n context.drawLine({\n start: { x: fragment.x, y: underlineY },\n end: { x: fragment.x + fragment.width, y: underlineY },\n thickness: Math.max(0.5, options.size * 0.06),\n color: options.underlineColor ?? run.color,\n });\n }\n }\n continue;\n }\n\n await context.drawText({\n text: line.text,\n x: line.x,\n y: line.y,\n size: options.size,\n color: options.color,\n fontName: options.fontName,\n });\n\n if (options.underline) {\n const underlineY = line.y - Math.max(1, options.size * 0.08);\n context.drawLine({\n start: { x: line.x, y: underlineY },\n end: { x: line.x + line.width, y: underlineY },\n thickness: Math.max(0.5, options.size * 0.06),\n color: options.underlineColor ?? options.color,\n });\n }\n }\n }\n\n /**\n * Positions a {@link TextLayoutResult} inside a layout box.\n *\n * Lines are placed from the bottom of the box upward (PDF y grows upward).\n * Each line's baseline sits `halfLeading + ascent` below the line's top —\n * the CSS line-box model: the extra leading (`lineHeight - fontHeight`)\n * splits half above and half below the text, so single-line text is\n * optically centered in its line box instead of hugging the top with all\n * the slack below the baseline. Horizontal alignment is applied per line.\n */\n static position(\n box: { x: number; y: number; width: number; height: number },\n lines: TextLayoutLine[],\n maxWidth: number,\n options: {\n lineHeight: number;\n ascent: number;\n /** Full font height (ascent + descent); half-leading derives from it. */\n fontHeight: number;\n align: 'left' | 'center' | 'right';\n }\n ): RenderedTextLayout {\n const topY = box.y + box.height;\n const halfLeading = (options.lineHeight - options.fontHeight) / 2;\n\n return {\n box,\n maxWidth,\n lines: lines.map((line, index) => {\n let x = box.x;\n if (options.align === 'center') {\n x = box.x + (maxWidth - line.width) / 2;\n } else if (options.align === 'right') {\n x = box.x + (maxWidth - line.width);\n }\n\n let cursor = x;\n const fragments = line.fragments?.map((fragment) => {\n const fragmentX = cursor;\n cursor += fragment.width;\n return { ...fragment, x: fragmentX };\n });\n\n return {\n ...line,\n x,\n y: topY - index * options.lineHeight - halfLeading - options.ascent,\n fragments,\n };\n }),\n };\n }\n}\n","import { MeasureMode } from 'yoga-layout';\nimport { resolveThemeFont, resolveThemeTextStyle, type ThemeColorValue } from './Theme';\nimport { resolveColor, resolveFont } from './theme-resolve';\nimport { Widget, WidgetOptions } from './Widget';\nimport type { RenderContext } from './RenderContextInterface';\nimport type { RenderColor } from './RenderContextTypes';\nimport {\n BuiltinPdfFonts,\n builtinPdfNameFace,\n resolveBuiltinPdfFont,\n type BuiltinPdfFontName,\n} from './types/doc-fonts';\nimport { faceId, parseFaceId, resolveFaceStyle } from './fonts/face';\nimport type { FontStyle, FontStyleValue, FontWeightValue } from './fonts/types';\nimport { fromHex } from './utils/color-utils';\nimport {\n TextLayoutEngine,\n type EngineRun,\n type TextLayoutResult,\n type TextOverflow,\n type TextLayoutConfig,\n} from './TextLayoutEngine';\nimport { TextPainter, type PaintRun, type RenderedTextLayout } from './TextPainter';\nimport type { BreakUnit } from './pagination/types';\nimport type { PrepareOptions } from '@chenglou/pretext';\n\nexport type { TextOverflow } from './TextLayoutEngine';\n\n/**\n * A styled inline run inside a `Text`. Typography is CSS-like: `fontWeight`\n * (100–900, 'normal', 'bold') and `fontStyle` ('normal', 'italic') pick the\n * matching face of the run's family, replacing the base style per axis and\n * falling back down the face chain when a face is missing. `mono` switches\n * to the builtin `mono` family, and `font` overrides the family outright\n * (theme token or family name) while inheriting the block's typography.\n */\nexport interface Run {\n text: string;\n fontWeight?: FontWeightValue;\n fontStyle?: FontStyleValue;\n strike?: boolean;\n href?: string;\n mono?: boolean;\n font?: string;\n color?: ThemeColorValue;\n underline?: boolean;\n}\n\nexport interface TextOptions extends WidgetOptions {\n size?: number;\n color?: ThemeColorValue;\n align?: 'left' | 'center' | 'right';\n font?: string;\n /** Block-level weight, overriding the theme variant's. Runs replace it per axis. */\n fontWeight?: FontWeightValue;\n /** Block-level style, overriding the theme variant's. Runs replace it per axis. */\n fontStyle?: FontStyleValue;\n /**\n * Line height in POINTS — the vertical distance between line baselines.\n * This is not a CSS multiplier: `lineHeight: 1.4` means 1.4pt (lines pile\n * on top of each other). For the CSS `line-height: 1.4` behavior use\n * {@link lineHeightMultiplier}.\n */\n lineHeight?: number;\n /**\n * Line height as a CSS-like multiplier of the font size — `1.4` at size 12\n * gives a 16.8pt line height. Ignored when {@link lineHeight} (points) is\n * set; the theme variant's value applies when neither is.\n */\n lineHeightMultiplier?: number;\n maxLines?: number;\n overflow?: TextOverflow;\n whiteSpace?: PrepareOptions['whiteSpace'];\n wordBreak?: PrepareOptions['wordBreak'];\n variant?: string;\n}\n\n/**\n * Quotes a single font family for a canvas font string. Comma-separated\n * lists (the builtin canvas stacks) are already valid font-family lists and\n * stay unquoted; only single names containing whitespace get quoted.\n */\nfunction toCanvasFontFamily(family: string): string {\n if (!/\\s/.test(family) || family.includes(',')) {\n return family;\n }\n return `\"${family.replace(/\"/g, '\\\\\"')}\"`;\n}\n\n/**\n * The canvas font string that measures the same face `face` draws: builtin\n * faces get the weight/style keywords over their canvas stack; custom\n * families measure under the face id — browser `FontFace`s register per face\n * id (`inter-bold`), so measuring under the plain family name would use the\n * regular face for styled text (B17).\n */\nfunction canvasFontForFace(face: string, size: number): string {\n const builtin = BuiltinPdfFonts[face as BuiltinPdfFontName];\n if (builtin) {\n const style = parseFaceId(face)?.style ?? 'regular';\n const bold = style === 'bold' || style === 'boldItalic';\n const italic = style === 'italic' || style === 'boldItalic';\n const prefix = `${bold ? 'bold ' : ''}${italic ? 'italic ' : ''}`;\n return `${prefix}${size}px ${builtin.canvas}`;\n }\n return `${size}px ${toCanvasFontFamily(face)}`;\n}\n\n/** A run fully resolved to concrete fonts and colors for measure/draw. */\ninterface ResolvedRun extends PaintRun {\n text: string;\n canvasFont: string;\n href?: string;\n}\n\nexport class TextWidget extends Widget {\n private readonly runs?: readonly Run[];\n private readonly plainText: string;\n private readonly sizeOverride?: number;\n private readonly colorOverride?: ThemeColorValue;\n private readonly alignOverride?: 'left' | 'center' | 'right';\n private readonly fontNameOverride?: string;\n private readonly fontWeightOverride?: FontWeightValue;\n private readonly fontStyleOverride?: FontStyleValue;\n private readonly lineHeightOverride?: number;\n private readonly lineHeightMultiplierOverride?: number;\n private readonly maxLines?: number;\n private readonly overflow: TextOverflow;\n private readonly whiteSpace: PrepareOptions['whiteSpace'];\n private readonly wordBreak: PrepareOptions['wordBreak'];\n private readonly variant?: string;\n private measureConfigured = false;\n private engine?: TextLayoutEngine;\n private engineRuns?: readonly EngineRun[];\n private paintRuns?: readonly ResolvedRun[];\n\n constructor(text: string | Run[], options: TextOptions) {\n super(options);\n this.runs = Array.isArray(text) ? text : undefined;\n this.plainText = Array.isArray(text) ? text.map((run) => run.text).join('') : text;\n this.sizeOverride = options.size;\n this.colorOverride = options.color;\n this.alignOverride = options.align;\n this.fontNameOverride = options.font;\n this.fontWeightOverride = options.fontWeight;\n this.fontStyleOverride = options.fontStyle;\n this.lineHeightOverride = options.lineHeight;\n this.lineHeightMultiplierOverride = options.lineHeightMultiplier;\n this.maxLines = options.maxLines;\n this.overflow = options.overflow ?? 'visible';\n this.whiteSpace = options.whiteSpace ?? 'normal';\n this.wordBreak = options.wordBreak ?? 'normal';\n this.variant = options.variant;\n }\n\n protected getThemeVariantNames(): string[] {\n return ['body', this.variant ?? ''];\n }\n\n protected getVariantName(): string | undefined {\n return this.variant;\n }\n\n protected getThemeTextStyle() {\n return resolveThemeTextStyle(this.context?.getTheme(), this.getThemeVariantNames());\n }\n\n protected getFallbackColor(): RenderColor {\n return fromHex('#000000');\n }\n\n protected getFallbackLineHeightMultiplier(): number {\n return 1.15;\n }\n\n protected getSize(): number {\n return this.sizeOverride ?? this.getThemeTextStyle()?.size ?? 12;\n }\n\n protected getColor(): RenderColor {\n return resolveColor(this.context?.getTheme(), this.colorOverride, this.getThemeTextStyle()?.color, this.getFallbackColor());\n }\n\n protected getAlign(): 'left' | 'center' | 'right' {\n return this.alignOverride ?? this.getThemeTextStyle()?.align ?? 'left';\n }\n\n protected getLineHeight(): number {\n const theme = this.getThemeTextStyle();\n // User-level (either form) beats the theme variant; within a level,\n // explicit points win over the multiplier.\n if (this.lineHeightOverride !== undefined) {\n return this.lineHeightOverride;\n }\n if (this.lineHeightMultiplierOverride !== undefined) {\n return this.lineHeightMultiplierOverride * this.getSize();\n }\n if (theme?.lineHeight !== undefined) {\n return theme.lineHeight;\n }\n if (theme?.lineHeightMultiplier !== undefined) {\n return theme.lineHeightMultiplier * this.getSize();\n }\n\n if (this.context) {\n return this.context.measureDefaultLineHeight(this.getSize(), this.getFontName());\n }\n\n return this.getSize() * this.getFallbackLineHeightMultiplier();\n }\n\n protected getFontName(): string {\n const base = resolveBuiltinPdfFont(\n resolveFont(this.context?.getTheme(), this.fontNameOverride, this.getThemeTextStyle()?.font)\n ) ?? 'Helvetica';\n return this.applyBlockTypography(base);\n }\n\n /** The face style implied by block/variant typography over `base`. */\n private blockFaceStyle(base: FontStyle = 'regular'): FontStyle {\n const variant = this.getThemeTextStyle();\n return resolveFaceStyle(\n base,\n this.fontWeightOverride ?? variant?.fontWeight,\n this.fontStyleOverride ?? variant?.fontStyle,\n );\n }\n\n /**\n * Applies block/variant typography onto a resolved font name. Each axis is\n * replaced when set (block wins over variant); unset axes keep the base\n * name's own style — so `font: 'inter-bold'` keeps working, and a block\n * `fontStyle: 'italic'` on it yields `inter-bold-italic`.\n */\n private applyBlockTypography(base: string): string {\n const variant = this.getThemeTextStyle();\n const weight = this.fontWeightOverride ?? variant?.fontWeight;\n const style = this.fontStyleOverride ?? variant?.fontStyle;\n if (weight === undefined && style === undefined) {\n return base;\n }\n\n const builtin = builtinPdfNameFace(base);\n const parsed = builtin ?? parseFaceId(base);\n const family = parsed?.family ?? base;\n const baseStyle = parsed?.style ?? 'regular';\n return faceId(family, resolveFaceStyle(baseStyle, weight, style));\n }\n\n /**\n * Resolves a run to the pdf font name + canvas font that measure and draw\n * it. `font`/`mono` overrides swap the family but inherit the block's\n * typography (CSS inheritance); otherwise the base font — already styled\n * by the block — is decomposed into family + style and the run's\n * weight/style replace their axis (an explicit weight of 400 un-bolds a\n * bold base), falling back down the face chain when a face is missing.\n */\n private resolveRunFont(run: Run): { fontName: string; canvasFont: string } {\n let family: string;\n let baseStyle: FontStyle;\n\n if (run.font || run.mono) {\n family = run.font\n ? resolveThemeFont(this.context?.getTheme(), run.font) ?? run.font\n : 'mono';\n const overrideParsed = parseFaceId(family);\n if (overrideParsed) {\n // The override name carries its own style ('inter-bold') — it is the\n // more specific base that block typography and the run's axes\n // replace, so an explicit 400 un-bolds it like the block path (B20).\n family = overrideParsed.family;\n baseStyle = this.blockFaceStyle(overrideParsed.style);\n } else {\n // Inherit the block's fully-styled face (the base name's own style +\n // block typography) — the same decomposition non-override runs use.\n const blockFaceName = this.getFontName();\n const parsed = builtinPdfNameFace(blockFaceName) ?? parseFaceId(blockFaceName);\n baseStyle = parsed?.style ?? 'regular';\n }\n } else {\n const basePdfName = this.getFontName();\n const builtin = builtinPdfNameFace(basePdfName);\n if (builtin) {\n family = builtin.family;\n baseStyle = builtin.style;\n } else {\n const parsed = parseFaceId(basePdfName);\n family = parsed?.family ?? basePdfName;\n baseStyle = parsed?.style ?? 'regular';\n }\n }\n\n const face = faceId(family, resolveFaceStyle(baseStyle, run.fontWeight, run.fontStyle));\n const pdfFamily = resolveBuiltinPdfFont(face) ?? face;\n return { fontName: pdfFamily, canvasFont: canvasFontForFace(face, this.getSize()) };\n }\n\n /** Runs as the engine sees them (text + measuring font), memoized. */\n private getEngineRuns(): readonly EngineRun[] | undefined {\n if (!this.runs) {\n return undefined;\n }\n if (this.engineRuns) {\n return this.engineRuns;\n }\n this.engineRuns = this.runs.map((run) => ({\n text: run.text,\n fontName: this.resolveRunFont(run).fontName,\n }));\n return this.engineRuns;\n }\n\n /** Runs fully resolved for painting (fonts, colors, strike, hrefs). */\n private getPaintRuns(): readonly ResolvedRun[] {\n if (!this.runs) {\n return [];\n }\n if (this.paintRuns) {\n return this.paintRuns;\n }\n this.paintRuns = this.runs.map((run) => {\n const { fontName, canvasFont } = this.resolveRunFont(run);\n return {\n text: run.text,\n fontName,\n canvasFont,\n color: resolveColor(this.context?.getTheme(), run.color, undefined, this.getColor()),\n strike: run.strike ?? false,\n underline: run.underline ?? false,\n href: run.href,\n };\n });\n return this.paintRuns;\n }\n\n /** True when this text was built from runs (even if currently empty). */\n protected hasRuns(): boolean {\n return this.runs !== undefined && this.runs.length > 0;\n }\n\n /** The flattened plain text (runs concatenated in order). */\n getText(): string {\n return this.plainText;\n }\n\n protected getFontAscent(): number {\n if (this.context) {\n return this.context.measureFontAscent(this.getSize(), this.getFontName());\n }\n\n return this.getSize();\n }\n\n /** Full font height (ascent + descent) — half-leading derives from it. */\n protected getFontHeight(): number {\n if (this.context) {\n return this.context.measureFontHeight(this.getSize(), this.getFontName());\n }\n\n return this.getSize();\n }\n\n protected getCanvasFont(): string {\n // Measure with the same face that draws (B17) — getFontName() is the\n // fully-styled face id (e.g. 'sans-bold', 'inter-bold').\n return canvasFontForFace(this.getFontName(), this.getSize());\n }\n\n /**\n * Builds (and caches) the pure {@link TextLayoutEngine} for this widget's\n * resolved theme/style. The engine is rebuilt only when the context is\n * first available; once built it captures concrete values so callers don't\n * need to re-resolve theme tokens per layout pass.\n */\n private getEngine(): TextLayoutEngine {\n if (this.engine) {\n return this.engine;\n }\n\n const context = this.context;\n const size = this.getSize();\n const fontName = this.getFontName();\n const runs = this.getEngineRuns();\n\n const config: TextLayoutConfig = {\n text: this.plainText,\n size,\n lineHeight: this.getLineHeight(),\n align: this.getAlign(),\n ascent: this.getFontAscent(),\n whiteSpace: this.whiteSpace,\n wordBreak: this.wordBreak,\n maxLines: this.maxLines,\n overflow: this.overflow,\n runs,\n measureTextWidth: (text: string) =>\n context\n ? context.measureTextWidth(text, size, fontName)\n : text.length * size * 0.6,\n measureRunWidth: runs\n ? (text: string, runFontName: string) =>\n context\n ? context.measureTextWidth(text, size, runFontName)\n : text.length * size * 0.6\n : undefined,\n };\n\n this.engine = new TextLayoutEngine(config);\n return this.engine;\n }\n\n protected getNaturalWidth(): number {\n return this.getEngine().getNaturalWidth(this.getCanvasFont());\n }\n\n protected getHeightLineLimit(height: number): number | undefined {\n return this.getEngine().getHeightLineLimit(height);\n }\n\n protected layoutText(maxWidth: number, heightLineLimit?: number): TextLayoutResult {\n // Yoga stores computed sizes as float32 while the measurements that\n // produced them are float64 — a shrink-wrapped block's stored width can\n // sit a ~1e-6pt hair UNDER its own measured text width, and re-wrapping\n // at the stored width would phantom-wrap ('1.' → '1' / '.'). Tolerate\n // sub-0.01pt overflow: invisible at any zoom, and exactly the noise\n // floor of the float32 boundary. Zero stays the natural-width sentinel.\n const effectiveMaxWidth = maxWidth > 0 ? maxWidth + 0.01 : maxWidth;\n return this.getEngine().layoutText(effectiveMaxWidth, heightLineLimit, this.getCanvasFont());\n }\n\n protected getRenderedTextLayout(context: RenderContext): RenderedTextLayout {\n const box = context.getLayoutBox(this);\n const maxWidth = box.width > 0 ? box.width : this.getWidth();\n const lineHeight = this.getLineHeight();\n const flowOffset = context.getFlowOffset(this);\n const flowHeight = this.node.getComputedHeight();\n\n // A pagination slice: a continuation (flowOffset > 0), or a first slice\n // whose fragment box is shorter than the block's flow height. Sliced\n // blocks draw a window of the full layout — no overflow truncation, the\n // block continues on the next page.\n if (lineHeight > 0 && (flowOffset > 0 || box.height + 0.01 < flowHeight)) {\n const block = this.layoutText(maxWidth);\n const skip = Math.max(0, Math.floor((flowOffset + 0.001) / lineHeight));\n const visible = Math.max(0, Math.floor((box.height + 0.001) / lineHeight));\n const lines = block.lines.slice(skip, skip + visible);\n\n return TextPainter.position(box, lines, maxWidth, {\n lineHeight,\n ascent: this.getFontAscent(),\n fontHeight: this.getFontHeight(),\n align: this.getAlign(),\n });\n }\n\n const heightLineLimit = this.getHeightLineLimit(box.height);\n const layout = this.layoutText(maxWidth, heightLineLimit);\n\n return TextPainter.position(box, layout.lines, maxWidth, {\n lineHeight,\n ascent: this.getFontAscent(),\n fontHeight: this.getFontHeight(),\n align: this.getAlign(),\n });\n }\n\n protected async drawRenderedTextLayout(\n context: RenderContext,\n renderedLayout: RenderedTextLayout,\n options?: { underline?: boolean; underlineColor?: RenderColor; linkHref?: string },\n ): Promise<void> {\n const paintRuns = this.getPaintRuns();\n\n await TextPainter.paint(context, renderedLayout, {\n size: this.getSize(),\n color: this.getColor(),\n fontName: this.getFontName(),\n underline: options?.underline,\n underlineColor: options?.underlineColor,\n runs: paintRuns.length > 0 ? paintRuns : undefined,\n });\n\n this.addRunLinkAnnotations(context, renderedLayout, options?.linkHref);\n }\n\n /**\n * Link annotations for run hrefs: one rect per line fragment, since a run\n * can wrap across lines (a whole-box rect would cover unrelated text).\n * `defaultHref` (set by Link) applies to runs without their own href.\n */\n private addRunLinkAnnotations(\n context: RenderContext,\n renderedLayout: RenderedTextLayout,\n defaultHref?: string,\n ): void {\n if (!this.runs) {\n return;\n }\n\n const paintRuns = this.getPaintRuns();\n const lineHeight = this.getLineHeight();\n const ascent = this.getFontAscent();\n // The line box spans baseline ± (halfLeading + ascent) top / (lineHeight\n // - halfLeading - ascent) bottom — the same model TextPainter.position\n // uses. The previous rect dropped the half-leading and sat one notch\n // below the line box (B20).\n const halfLeading = (lineHeight - this.getFontHeight()) / 2;\n\n for (const line of renderedLayout.lines) {\n if (!line.fragments) {\n continue;\n }\n for (const fragment of line.fragments) {\n const href = paintRuns[fragment.runIndex]?.href ?? defaultHref;\n if (!href) {\n continue;\n }\n context.addLinkAnnotation({\n href,\n rect: [\n fragment.x,\n line.y - (lineHeight - halfLeading - ascent),\n fragment.x + fragment.width,\n line.y + halfLeading + ascent,\n ],\n });\n }\n }\n }\n\n override async prepareLayout(context: RenderContext): Promise<void> {\n const paintRuns = this.getPaintRuns();\n const fontNames = paintRuns.length > 0\n ? [...new Set(paintRuns.map((run) => run.fontName))]\n : [this.getFontName()];\n await Promise.all(fontNames.map((fontName) => context.preloadFont(fontName)));\n\n // The engine captures ascent/lineHeight and measurement closures. If it\n // was built before fonts were embedded (a getPageCount dry run), drop it\n // so it rebuilds with the real metrics now that preloading has embedded\n // them (B9).\n this.engine = undefined;\n\n if (typeof document !== 'undefined' && 'fonts' in document) {\n if (paintRuns.length > 0) {\n const textByCanvasFont = new Map<string, string>();\n for (const run of paintRuns) {\n textByCanvasFont.set(run.canvasFont, (textByCanvasFont.get(run.canvasFont) ?? '') + run.text);\n }\n await Promise.all(\n [...textByCanvasFont].map(([canvasFont, text]) => document.fonts.load(canvasFont, text))\n );\n } else {\n await document.fonts.load(this.getCanvasFont(), this.plainText);\n }\n }\n\n // Prime the engine + pretext cache.\n this.getEngine().ensurePreparedText(this.getCanvasFont());\n\n if (!this.measureConfigured) {\n this.node.setMeasureFunc((width, widthMode, height, heightMode) => {\n const maxWidth =\n widthMode === MeasureMode.Exactly || widthMode === MeasureMode.AtMost\n ? width\n : this.getNaturalWidth();\n\n const heightLineLimit =\n heightMode === MeasureMode.Exactly || heightMode === MeasureMode.AtMost\n ? this.getHeightLineLimit(height)\n : undefined;\n\n const layout = this.layoutText(Math.max(0, maxWidth), heightLineLimit);\n const measuredHeight = layout.lines.length * this.getLineHeight();\n\n const measuredWidth =\n widthMode === MeasureMode.Exactly\n ? Math.max(0, width)\n : layout.maxLineWidth;\n\n return { width: measuredWidth, height: measuredHeight };\n });\n this.measureConfigured = true;\n }\n\n await super.prepareLayout(context);\n }\n\n /**\n * Line units: one break opportunity per laid-out line, so the paginator\n * never splits mid-line. `breakable: false` (inherited option) makes the\n * block atomic via the base-class check.\n */\n override getBreakUnits(): BreakUnit[] | null {\n if (this.breakableOption === false) return null;\n const lineHeight = this.getLineHeight();\n if (lineHeight <= 0) return null;\n\n const computedWidth = this.node.getComputedWidth();\n const maxWidth = computedWidth > 0 ? computedWidth : this.getWidth();\n const lines = this.layoutText(maxWidth).lines;\n if (lines.length === 0) return null;\n\n return lines.map((_, index) => ({ offset: index * lineHeight, height: lineHeight }));\n }\n\n async render(context: RenderContext): Promise<void> {\n await this.drawRenderedTextLayout(context, this.getRenderedTextLayout(context));\n }\n\n getWidth(): number {\n const w = this.node.getComputedWidth();\n return w > 0 ? w : this.getNaturalWidth();\n }\n\n getHeight(): number {\n const computedW = this.node.getComputedWidth();\n const maxWidth = computedW > 0 ? computedW : this.getWidth();\n return this.layoutText(maxWidth).lines.length * this.getLineHeight();\n }\n}\n\nexport function Text(text: string | Run[], options: TextOptions = {}): TextWidget {\n return new TextWidget(text, options);\n}\n","import { type ThemeColorValue } from './Theme';\nimport { resolveColor } from './theme-resolve';\nimport { resolveSpacingEdges, type Spacing } from './utils/spacing';\nimport { Widget, WidgetOptions, type YogaStyle } from './Widget';\nimport type { RenderContext } from './RenderContextInterface';\nimport type { RenderColor } from './RenderContextTypes';\nimport { fromHex } from './utils/color-utils';\nimport { Edge } from 'yoga-layout';\n\ninterface BorderOptions {\n width?: number;\n color?: ThemeColorValue;\n radius?: number;\n}\n\nconst borderDefaults: BorderOptions = {\n width: 1,\n color: '',\n radius: 0,\n};\n\ninterface ContainerOptions extends WidgetOptions {\n bgColor?: ThemeColorValue;\n width?: YogaStyle['width'];\n height?: YogaStyle['height'];\n /** Inner spacing. A number for all sides, or per-side (I11). */\n padding?: Spacing;\n border?: BorderOptions;\n child?: Widget; // Accept single child for convenience\n /**\n * Per-key override of the Container's built-in Yoga style — the same\n * escape hatch FlexContainer has (I11). Applied after the defaults.\n */\n style?: YogaStyle;\n}\n\nexport class ContainerWidget extends Widget {\n private bgColor?: ThemeColorValue;\n private border?: BorderOptions;\n private padding?: Spacing;\n private readonly styleOptions?: YogaStyle;\n\n constructor(options: ContainerOptions) {\n // Copy: the caller's array must not gain `child` (B20).\n const children = options.children ? [...options.children] : [];\n if (options.child) {\n children.push(options.child);\n }\n super({ ...options, children });\n this.styleOptions = options.style;\n this.border = options.border;\n this.bgColor = options.bgColor;\n this.padding = options.padding;\n\n // Size to content unless told otherwise — a fixed default box silently\n // overflows (or pads) whenever content differs from the default.\n // No alignSelf hardcode (I11): the container respects its parent's\n // alignItems like any other box; shrink-wrap explicitly via style.\n // Padding is applied in prepareLayout (per-side + theme fallback).\n this.setYogaStyle({\n width: options.width ?? 'auto',\n height: options.height ?? 'auto',\n flexDirection: 'column',\n justifyContent: 'flex-start',\n alignItems: 'flex-start',\n ...options.style,\n });\n }\n\n private getThemeContainerStyle() {\n return this.context?.getTheme()?.container;\n }\n\n private getResolvedPaddingEdges(): { top: number; right: number; bottom: number; left: number } {\n return resolveSpacingEdges(this.padding, this.getThemeContainerStyle()?.padding ?? 0);\n }\n\n private getResolvedBackgroundColor(): RenderColor {\n return resolveColor(this.context?.getTheme(), this.bgColor, this.getThemeContainerStyle()?.bgColor, fromHex('#FFFFFF'));\n }\n\n private getResolvedBorder(): { width?: number; color?: RenderColor; radius?: number } | undefined {\n const themeBorder = this.getThemeContainerStyle();\n const width = this.border?.width ?? themeBorder?.borderWidth;\n const color = resolveColor(this.context?.getTheme(), this.border?.color, themeBorder?.borderColor);\n const radius = this.border?.radius ?? themeBorder?.borderRadius;\n\n if (width === undefined && color === undefined && radius === undefined) {\n return undefined;\n }\n\n return { width, color, radius };\n }\n\n override async prepareLayout(context: RenderContext): Promise<void> {\n const padding = this.getResolvedPaddingEdges();\n this.node.setPadding(Edge.Top, padding.top);\n this.node.setPadding(Edge.Right, padding.right);\n this.node.setPadding(Edge.Bottom, padding.bottom);\n this.node.setPadding(Edge.Left, padding.left);\n // The style escape hatch is the last word (B14 contract): re-apply any\n // padding keys it sets, or the resolved edges above would clobber them\n // at layout time (B20). Per-edge sets, not the `All` slot — Yoga gives\n // explicit per-edge values precedence over `All`.\n const style = this.styleOptions;\n if (style) {\n if (style.padding !== undefined) {\n this.node.setPadding(Edge.Top, style.padding);\n this.node.setPadding(Edge.Right, style.padding);\n this.node.setPadding(Edge.Bottom, style.padding);\n this.node.setPadding(Edge.Left, style.padding);\n }\n if (style.paddingTop !== undefined) this.node.setPadding(Edge.Top, style.paddingTop);\n if (style.paddingRight !== undefined) this.node.setPadding(Edge.Right, style.paddingRight);\n if (style.paddingBottom !== undefined) this.node.setPadding(Edge.Bottom, style.paddingBottom);\n if (style.paddingLeft !== undefined) this.node.setPadding(Edge.Left, style.paddingLeft);\n }\n await super.prepareLayout(context);\n }\n\n async render(context: RenderContext): Promise<void> {\n const { x, y, width, height } = context.getLayoutBox(this);\n\n // Draw background\n context.drawRectangle({\n x,\n y,\n width,\n height,\n color: this.getResolvedBackgroundColor(),\n });\n\n // Draw border if specified\n const border = this.getResolvedBorder();\n if (border) {\n // `??` not `||`: an explicit width of 0 means no border (B20) — skip\n // the draw entirely, pdf-lib would still emit a zero-width stroke op.\n const borderWidth = border.width ?? borderDefaults.width;\n const borderColor = border.color ?? fromHex('#000000');\n if (borderWidth !== undefined && borderWidth > 0) {\n context.drawRectangle({\n x,\n y,\n width,\n height,\n borderWidth,\n borderColor,\n color: undefined, // No fill, just border\n });\n }\n }\n\n // Render all children (now always uses children array)\n await this.renderChildren(context);\n }\n}\n\nexport function Container(options: ContainerOptions): ContainerWidget {\n return new ContainerWidget(options);\n}\n","import { FlexContainer, FlexContainerOptions } from './FlexContainer';\nimport {\n alignCenter,\n alignEnd,\n alignStart,\n alignStretch,\n AlignValue,\n justifyAround,\n justifyBetween,\n justifyCenter,\n justifyEnd,\n justifyEvenly,\n justifyStart,\n JustifyValue,\n} from './types/styles';\nimport { YogaStyle } from './Widget';\n\n/**\n * Options for configuring a Row widget\n */\nexport interface RowOptions extends FlexContainerOptions {\n mainAxisAlignment?: JustifyValue;\n\n crossAxisAlignment?: Exclude<AlignValue, 'auto'>;\n}\n\nconst rowStatics = {\n justifyStart,\n justifyCenter,\n justifyEnd,\n justifyBetween,\n justifyAround,\n justifyEvenly,\n alignStart,\n alignCenter,\n alignEnd,\n alignStretch,\n} as const;\n\nexport type RowComponent = ((options?: RowOptions) => FlexContainer) &\n typeof rowStatics;\n\n/**\n * Creates a Row widget that arranges its children horizontally\n */\nfunction createRow(options: RowOptions = {}): FlexContainer {\n // Prop-derived values first, `style` last (the escape hatch wins per key,\n // same contract as Container — B14). The direction stays pinned: it is the\n // widget's identity, not a default.\n const style: YogaStyle = {\n justifyContent: options.mainAxisAlignment || justifyStart,\n alignItems: options.crossAxisAlignment || alignStart,\n ...options.style,\n flexDirection: 'row',\n };\n\n return new FlexContainer({\n ...options,\n style,\n });\n}\n\nexport const Row: RowComponent = Object.assign(createRow, rowStatics);\n","import { FlexContainer, FlexContainerOptions } from './FlexContainer';\nimport {\n alignCenter,\n alignEnd,\n alignStart,\n alignStretch,\n AlignValue,\n justifyAround,\n justifyBetween,\n justifyCenter,\n justifyEnd,\n justifyEvenly,\n justifyStart,\n JustifyValue,\n} from './types/styles';\nimport { YogaStyle } from './Widget';\n\n/**\n * Options for configuring a Column widget\n */\nexport interface ColumnOptions extends FlexContainerOptions {\n mainAxisAlignment?: JustifyValue;\n crossAxisAlignment?: Exclude<AlignValue, 'auto'>;\n gap?: number;\n}\n\nconst columnStatics = {\n justifyStart,\n justifyCenter,\n justifyEnd,\n justifyBetween,\n justifyAround,\n justifyEvenly,\n alignStart,\n alignCenter,\n alignEnd,\n alignStretch,\n} as const;\n\nexport type ColumnComponent = ((options?: ColumnOptions) => FlexContainer) & typeof columnStatics;\n\n/**\n * Creates a Column widget that arranges its children vertically\n */\nfunction createColumn(options: ColumnOptions = {}): FlexContainer {\n // Prop-derived values first, `style` last (the escape hatch wins per key,\n // same contract as Container — B14). The direction stays pinned: it is the\n // widget's identity, not a default.\n const style: YogaStyle = {\n gap: options?.gap || 0,\n justifyContent: options.mainAxisAlignment || justifyStart,\n alignItems: options.crossAxisAlignment || alignStart,\n ...options.style,\n flexDirection: 'column',\n };\n\n return new FlexContainer({\n ...options,\n style,\n });\n}\n\nexport const Column: ColumnComponent = Object.assign(createColumn, columnStatics);\n","import { Widget, WidgetOptions, type YogaStyleValue } from './Widget';\nimport type { RenderContext } from './RenderContextInterface';\nimport type { RenderImage } from './RenderContextTypes';\nimport {\n ImageSizing,\n aspectFitMeasure,\n aspectFitPlacement,\n type FitSpec,\n} from './aspect-fit';\nimport { sniffImageFormat } from './utils/image-format';\n\n// Compat re-export: ImageSizing is the shared fit vocabulary (defined in\n// aspect-fit.ts) but was first shipped from this module.\nexport { ImageSizing };\n\n/** True when running under Node — the runtime that can read file paths. */\nfunction isNode(): boolean {\n return typeof (globalThis as { process?: { versions?: { node?: string } } }).process?.versions?.node === 'string';\n}\n\n/** Node fs via the same `new Function` escape hatch `doc-output.ts` uses. */\nasync function readNodeFile(path: string): Promise<Uint8Array> {\n const loadFs = new Function(\"return import('node:fs/promises')\") as () => Promise<{\n readFile(path: string): Promise<Uint8Array>;\n }>;\n return loadFs().then((fs) => fs.readFile(path));\n}\n\n/**\n * Resolves an image source to bytes: in Node, bare paths and `file://` URLs\n * read from disk (I13); real URLs (http/https/data/blob) fetch in every\n * runtime. Shared with the markdown renderer so its images resolve the same\n * way (B20).\n */\nexport async function fetchImageBytes(url: string): Promise<ArrayBuffer> {\n // A single-letter \"scheme\" is a Windows drive letter (`C:\\\\img.png`), not\n // a URL scheme (B20).\n const hasScheme = /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(url) && !/^[a-zA-Z]:/.test(url);\n const isFileUrl = url.startsWith('file://');\n\n if (isNode() && (!hasScheme || isFileUrl)) {\n const path = isFileUrl ? url.slice('file://'.length) : url;\n const bytes = await readNodeFile(path);\n return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength) as ArrayBuffer;\n }\n\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`fetch failed: ${response.status} ${response.statusText}`);\n }\n return response.arrayBuffer();\n}\n\ninterface ImageOptions extends WidgetOptions {\n url: string;\n /** Pre-fetched image bytes; when set, `loadImage` skips the fetch. */\n bytes?: ArrayBuffer;\n scale?: number;\n width?: YogaStyleValue;\n height?: YogaStyleValue;\n sizing?: ImageSizing;\n format: 'png' | 'jpeg';\n}\n\nexport class ImageWidget extends Widget {\n private url: string;\n private bytes?: ArrayBuffer;\n private scale: number;\n private format: 'png' | 'jpeg';\n private pdfImage?: RenderImage;\n private resolvedFormat?: 'png' | 'jpeg';\n private imageWidth: number = 0;\n private imageHeight: number = 0;\n private sizing: ImageSizing;\n private measureConfigured = false;\n\n constructor(options: ImageOptions) {\n super(options);\n this.url = options.url;\n this.bytes = options.bytes;\n this.scale = options.scale ?? 1;\n if (!Number.isFinite(this.scale) || this.scale <= 0) {\n // Same guard SVGPath has — scale 0 used to silently become 1 and a\n // negative scale silently drew nothing (B20).\n throw new Error('Image: scale must be a positive number');\n }\n this.format = options.format;\n\n this.sizing = options.sizing ?? ImageSizing.Fit;\n\n // Media shrink-wraps: a stretching parent (Page sets alignItems:\n // stretch) would blow the box up to the full column width and center\n // the drawn content inside it — an unsized image draws at its intrinsic\n // size, at the flow position, unless the user sizes it (width/height,\n // e.g. '100%'). The fit measure caps ambient (AtMost) space at the\n // intrinsic size, so a parent-provided box only ever shrinks it.\n this.setYogaStyle({\n alignSelf: 'flex-start',\n width: options.width,\n height: options.height,\n });\n }\n\n /**\n * The fit spec is only known once the image bytes are embedded — before\n * that the measure function measures zero (aspect-fit module contract).\n */\n private spec(): FitSpec | null {\n if (this.imageWidth <= 0 || this.imageHeight <= 0) {\n return null;\n }\n return {\n // imageWidth/Height already include the scale multiplier.\n intrinsicWidth: this.imageWidth,\n intrinsicHeight: this.imageHeight,\n baseScale: 1,\n sizing: this.sizing,\n };\n }\n\n async loadImage(context: RenderContext): Promise<void> {\n if (!this.bytes) {\n this.bytes = await fetchImageBytes(this.url);\n }\n const bytes = this.bytes;\n\n // The bytes are ground truth: when the signature disagrees with the\n // declared format (Image.jpeg on png data), the sniffed format wins —\n // embedImage reports unsupported signatures itself. The decision is\n // memoized so re-loads within/across saves warn once, not per call.\n const sniffed = sniffImageFormat(bytes);\n const format = sniffed ?? this.format;\n if (sniffed && sniffed !== this.format && this.resolvedFormat !== format) {\n console.warn(`Image: declared format '${this.format}' does not match the bytes (sniffed '${sniffed}') — using the sniffed format.`);\n }\n this.resolvedFormat = format;\n // No widget-level embed cache: the backend dedupes per document, and a\n // cached PDFImage would point into a discarded document on a second\n // save (B8).\n this.pdfImage = await context.embedImage(bytes, format);\n this.imageWidth = this.pdfImage.width * this.scale;\n this.imageHeight = this.pdfImage.height * this.scale;\n\n // The node's size is the measure function's job, never a pinned\n // intrinsic size: a node with definite dimensions never consults its\n // measure func, so a pinned image would ignore the parent's box and\n // overflow it (a 360pt image in a Container({ width: 180 }) drew at\n // natural size). Unconstrained contexts measure at the intrinsic size;\n // definite parent boxes (Container width/height, percent widths) fit\n // into the available space; one explicit dimension derives the other\n // (B12). loadImage runs in prepareLayout — before any layout — so the\n // spec is always known by measure time.\n if (!this.measureConfigured) {\n this.node.setMeasureFunc(aspectFitMeasure(() => this.spec()));\n this.measureConfigured = true;\n }\n }\n\n override async prepareLayout(context: RenderContext): Promise<void> {\n await this.loadImage(context);\n await super.prepareLayout(context);\n }\n\n async render(context: RenderContext): Promise<void> {\n await this.loadImage(context);\n const spec = this.spec();\n if (!this.pdfImage || !spec) return;\n\n const box = context.getLayoutBox(this);\n const placement = aspectFitPlacement(spec, box);\n\n context.drawImage(this.pdfImage, {\n x: placement.left,\n y: placement.bottom,\n width: placement.drawnWidth,\n height: placement.drawnHeight,\n });\n }\n}\n\nexport const Image = {\n png(url: string, options: Omit<ImageOptions, 'url' | 'format'> = {}): ImageWidget {\n return new ImageWidget({ ...options, url, format: 'png' });\n },\n jpeg(url: string, options: Omit<ImageOptions, 'url' | 'format'> = {}): ImageWidget {\n return new ImageWidget({ ...options, url, format: 'jpeg' });\n },\n /**\n * Builds an image from already-fetched bytes (no internal fetch). Copies\n * typed-array views into an exact ArrayBuffer first. `format` is optional\n * when the bytes carry a recognizable png/jpeg signature (sniffed; a\n * passed format that disagrees is overridden with a warning).\n */\n fromBytes(\n bytes: ArrayBuffer | Uint8Array,\n format?: 'png' | 'jpeg',\n options: Omit<ImageOptions, 'url' | 'format' | 'bytes'> = {},\n ): ImageWidget {\n const buffer = ArrayBuffer.isView(bytes)\n ? (bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength) as ArrayBuffer)\n : (bytes as ArrayBuffer);\n const resolved = format ?? sniffImageFormat(buffer);\n if (!resolved) {\n throw new Error(\"Image.fromBytes: could not sniff the format from the bytes — pass 'png' or 'jpeg' explicitly.\");\n }\n return new ImageWidget({ ...options, url: '', format: resolved, bytes: buffer });\n },\n}","\nimport type { RenderContext } from './RenderContextInterface';\nimport type { RenderColor } from './RenderContextTypes';\nimport { type ThemeColorValue } from './Theme';\nimport { resolveColor } from './theme-resolve';\nimport { fromHex } from './utils/color-utils';\nimport { Widget, WidgetOptions, type YogaStyleValue } from './Widget';\nimport type { BreakUnit } from './pagination/types';\nimport { Text } from './Text';\n\nexport interface TableOptions extends WidgetOptions {\n head?: TableHeadWidget;\n body?: TableBodyWidget;\n width?: YogaStyleValue;\n rowHeight?: number;\n cellPadding?: number;\n borderColor?: ThemeColorValue;\n borderWidth?: number;\n headBgColor?: ThemeColorValue;\n rowBgColor?: ThemeColorValue;\n alternateRowBgColor?: ThemeColorValue;\n columnWidths?: YogaStyleValue[];\n columnWeights?: number[];\n}\n\ninterface TableSectionOptions extends WidgetOptions {\n rows?: TableRowWidget[];\n}\n\ninterface TableRowOptions extends WidgetOptions {\n cells?: Widget[];\n bgColor?: ThemeColorValue;\n minHeight?: number;\n}\n\ninterface TableCellOptions extends WidgetOptions {\n child?: Widget;\n width?: YogaStyleValue;\n weight?: number;\n padding?: number;\n bgColor?: ThemeColorValue;\n borderColor?: ThemeColorValue;\n borderWidth?: number;\n}\n\nabstract class TableSectionWidget extends Widget {\n protected readonly rows: TableRowWidget[];\n\n constructor(options: TableSectionOptions = {}) {\n const rows = options.rows ?? ((options.children as TableRowWidget[] | undefined) ?? []);\n super({ ...options, children: rows });\n this.rows = rows;\n\n this.setYogaStyle({\n width: '100%',\n flexDirection: 'column',\n alignItems: 'stretch',\n alignSelf: 'stretch',\n });\n }\n\n getRowIndex(row: TableRowWidget): number {\n return this.rows.indexOf(row);\n }\n\n /** Rows in this section (head or body). */\n getRows(): TableRowWidget[] {\n return this.rows;\n }\n\n getTable(): TableWidget | undefined {\n return this.parent instanceof TableWidget ? this.parent : undefined;\n }\n\n getHeight(): number {\n const computedHeight = this.node.getComputedHeight();\n if (computedHeight > 0) {\n return computedHeight;\n }\n\n return this.rows.reduce((height, row) => height + row.getHeight(), 0);\n }\n\n async render(context: RenderContext): Promise<void> {\n await this.renderChildren(context);\n }\n}\n\nexport class TableHeadWidget extends TableSectionWidget { }\n\nexport class TableBodyWidget extends TableSectionWidget { }\n\nexport class TableRowWidget extends Widget {\n private readonly cells: TableCellWidget[];\n private readonly bgColor?: ThemeColorValue;\n private readonly minHeight?: number;\n\n constructor(options: TableRowOptions = {}) {\n const rawCells = options.cells ?? options.children ?? [];\n const cells = rawCells.map((cell) =>\n cell instanceof TableCellWidget ? cell : new TableCellWidget({ child: cell })\n );\n\n super({ ...options, children: cells });\n this.cells = cells;\n this.bgColor = options.bgColor;\n this.minHeight = options.minHeight;\n\n this.setYogaStyle({\n width: '100%',\n flexDirection: 'row',\n alignItems: 'stretch',\n alignSelf: 'stretch',\n });\n }\n\n getCellIndex(cell: TableCellWidget): number {\n return this.cells.indexOf(cell);\n }\n\n getResolvedBackgroundColor(): RenderColor | undefined {\n const theme = this.context?.getTheme();\n if (this.bgColor) {\n return resolveColor(theme, this.bgColor);\n }\n\n const table = this.getTable();\n const section = this.getSection();\n if (!table || !section) {\n return undefined;\n }\n\n if (section instanceof TableHeadWidget) {\n return table.getHeadBgColor();\n }\n\n const rowIndex = section.getRowIndex(this);\n if (rowIndex >= 0 && rowIndex % 2 === 1) {\n return table.getAlternateRowBgColor() ?? table.getRowBgColor();\n }\n\n return table.getRowBgColor();\n }\n\n getSection(): TableSectionWidget | undefined {\n return this.parent instanceof TableSectionWidget ? this.parent : undefined;\n }\n\n getTable(): TableWidget | undefined {\n const section = this.getSection();\n return section?.getTable();\n }\n\n override async prepareLayout(context: RenderContext): Promise<void> {\n const minHeight = this.minHeight ?? this.getTable()?.getRowHeight();\n if (typeof minHeight === 'number' && Number.isFinite(minHeight) && minHeight > 0) {\n this.node.setMinHeight(minHeight);\n }\n\n await super.prepareLayout(context);\n }\n\n getHeight(): number {\n const computedHeight = this.node.getComputedHeight();\n if (computedHeight > 0) {\n return computedHeight;\n }\n\n return this.minHeight ?? 0;\n }\n\n async render(context: RenderContext): Promise<void> {\n await this.renderChildren(context);\n }\n}\n\nexport class TableCellWidget extends Widget {\n private readonly width?: YogaStyleValue;\n private readonly weight?: number;\n private readonly padding?: number;\n private readonly bgColor?: ThemeColorValue;\n private readonly borderColor?: ThemeColorValue;\n private readonly borderWidth?: number;\n\n constructor(options: TableCellOptions = {}) {\n const children = options.children ?? (options.child ? [options.child] : []);\n super({ ...options, children });\n this.width = options.width;\n this.weight = options.weight;\n this.padding = options.padding;\n this.bgColor = options.bgColor;\n this.borderColor = options.borderColor;\n this.borderWidth = options.borderWidth;\n\n this.setYogaStyle({\n flexDirection: 'column',\n justifyContent: 'center',\n alignItems: 'stretch',\n alignSelf: 'stretch',\n });\n }\n\n private getRow(): TableRowWidget | undefined {\n return this.parent instanceof TableRowWidget ? this.parent : undefined;\n }\n\n private getTable(): TableWidget | undefined {\n return this.getRow()?.getTable();\n }\n\n private getResolvedBorderColor(): RenderColor | undefined {\n return resolveColor(this.context?.getTheme(), this.borderColor) ?? this.getTable()?.getBorderColor();\n }\n\n private getResolvedBorderWidth(): number {\n return this.borderWidth ?? this.getTable()?.getBorderWidth() ?? 0;\n }\n\n private getResolvedPadding(): number {\n return this.padding ?? this.getTable()?.getCellPadding() ?? 0;\n }\n\n private getResolvedBackgroundColor(): RenderColor | undefined {\n return resolveColor(this.context?.getTheme(), this.bgColor) ?? this.getRow()?.getResolvedBackgroundColor();\n }\n\n override async prepareLayout(context: RenderContext): Promise<void> {\n const table = this.getTable();\n const row = this.getRow();\n const columnIndex = row?.getCellIndex(this) ?? -1;\n\n this.node.setPadding(0, this.getResolvedPadding());\n this.node.setPadding(1, this.getResolvedPadding());\n this.node.setPadding(2, this.getResolvedPadding());\n this.node.setPadding(3, this.getResolvedPadding());\n\n const width = this.width ?? (columnIndex >= 0 ? table?.getColumnWidth(columnIndex) : undefined);\n if (width !== undefined) {\n this.setYogaStyle({\n width,\n flexGrow: 0,\n flexShrink: 0,\n });\n } else {\n const weight = this.weight ?? (columnIndex >= 0 ? table?.getColumnWeight(columnIndex) : undefined) ?? 1;\n this.setYogaStyle({\n flexBasis: 0,\n flexGrow: weight,\n flexShrink: 1,\n });\n }\n\n await super.prepareLayout(context);\n }\n\n async render(context: RenderContext): Promise<void> {\n const { x, y, width, height } = context.getLayoutBox(this);\n const bgColor = this.getResolvedBackgroundColor();\n const borderColor = this.getResolvedBorderColor();\n const borderWidth = this.getResolvedBorderWidth();\n\n context.drawRectangle({\n x,\n y,\n width,\n height,\n color: bgColor,\n borderColor,\n borderWidth,\n });\n\n await this.renderChildren(context);\n }\n}\n\nexport class TableWidget extends Widget {\n private readonly head?: TableHeadWidget;\n private readonly body?: TableBodyWidget;\n private readonly width?: YogaStyleValue;\n private readonly rowHeight?: number;\n private readonly cellPadding?: number;\n private readonly borderColor?: ThemeColorValue;\n private readonly borderWidth?: number;\n private readonly headBgColor?: ThemeColorValue;\n private readonly rowBgColor?: ThemeColorValue;\n private readonly alternateRowBgColor?: ThemeColorValue;\n private readonly columnWidths?: YogaStyleValue[];\n private readonly columnWeights?: number[];\n\n constructor(options: TableOptions) {\n if (options.children && options.children.length > 0) {\n throw new Error(\n 'Table: children are not supported — compose rows via head/body (TableHead/TableBody/TableRow/TableCell) or Table.fromRows.'\n );\n }\n const children = [options.head, options.body].filter(Boolean) as Widget[];\n super({ ...options, children });\n this.head = options.head;\n this.body = options.body;\n this.width = options.width;\n this.rowHeight = options.rowHeight;\n this.cellPadding = options.cellPadding;\n this.borderColor = options.borderColor;\n this.borderWidth = options.borderWidth;\n this.headBgColor = options.headBgColor;\n this.rowBgColor = options.rowBgColor;\n this.alternateRowBgColor = options.alternateRowBgColor;\n this.columnWidths = options.columnWidths;\n this.columnWeights = options.columnWeights;\n\n this.setYogaStyle({\n width: this.width ?? '100%',\n flexDirection: 'column',\n alignItems: 'stretch',\n alignSelf: 'stretch',\n });\n }\n\n getRowHeight(): number | undefined {\n return this.rowHeight ?? this.context?.getTheme()?.table?.rowHeight;\n }\n\n getCellPadding(): number {\n return this.cellPadding ?? this.context?.getTheme()?.table?.cellPadding ?? 0;\n }\n\n getBorderColor(): RenderColor {\n // Soft gray, not pure black: unthemed tables sit in slate-ish documents,\n // and a full-black grid is harsh (the theme's table.borderColor overrides).\n return resolveColor(this.context?.getTheme(), this.borderColor, this.context?.getTheme()?.table?.borderColor, fromHex('#d1d5db'));\n }\n\n getBorderWidth(): number {\n return this.borderWidth ?? this.context?.getTheme()?.table?.borderWidth ?? 1;\n }\n\n getHeadBgColor(): RenderColor | undefined {\n return resolveColor(this.context?.getTheme(), this.headBgColor, this.context?.getTheme()?.table?.headBgColor);\n }\n\n getRowBgColor(): RenderColor | undefined {\n return resolveColor(this.context?.getTheme(), this.rowBgColor, this.context?.getTheme()?.table?.rowBgColor);\n }\n\n getAlternateRowBgColor(): RenderColor | undefined {\n return resolveColor(this.context?.getTheme(), this.alternateRowBgColor, this.context?.getTheme()?.table?.alternateRowBgColor);\n }\n\n getColumnWidth(index: number): YogaStyleValue | undefined {\n return this.columnWidths?.[index];\n }\n\n getColumnWeight(index: number): number | undefined {\n return this.columnWeights?.[index];\n }\n\n /**\n * Row units: the head is marked `repeat` (re-emitted atop every\n * continuation page) and `keepWithNext` (never orphaned at a page bottom);\n * rows are atomic because a TableRow is row-direction, so the base-class\n * default returns null for them and the paginator moves rows whole. The\n * render side needs no pagination awareness — rows are real widgets the\n * plan places like any other.\n */\n override getBreakUnits(): BreakUnit[] | null {\n if (this.breakableOption === false) return null;\n\n const units: BreakUnit[] = [];\n const tableTop = this.getAbsoluteLayoutBox().y;\n\n if (this.head) {\n const headHeight = this.head.getHeight();\n if (headHeight > 0) {\n units.push({\n offset: this.head.getAbsoluteLayoutBox().y - tableTop,\n height: headHeight,\n widget: this.head,\n repeat: true,\n keepWithNext: true,\n });\n }\n }\n\n if (this.body) {\n for (const row of this.body.getRows()) {\n const rowHeight = row.getHeight();\n if (rowHeight <= 0) continue;\n units.push({\n offset: row.getAbsoluteLayoutBox().y - tableTop,\n height: rowHeight,\n widget: row,\n });\n }\n }\n\n return units.length > 0 ? units : null;\n }\n\n getHeight(): number {\n const computedHeight = this.node.getComputedHeight();\n if (computedHeight > 0) {\n return computedHeight;\n }\n\n return (this.head?.getHeight() ?? 0) + (this.body?.getHeight() ?? 0);\n }\n\n async render(context: RenderContext): Promise<void> {\n await this.renderChildren(context);\n }\n}\n\nexport function TableHead(options: TableSectionOptions = {}): TableHeadWidget {\n return new TableHeadWidget(options);\n}\n\nexport function TableBody(options: TableSectionOptions = {}): TableBodyWidget {\n return new TableBodyWidget(options);\n}\n\nexport function TableRow(options: TableRowOptions = {}): TableRowWidget {\n return new TableRowWidget(options);\n}\n\nexport function TableCell(options: TableCellOptions = {}): TableCellWidget {\n return new TableCellWidget(options);\n}\n\nfunction createTable(options: TableOptions): TableWidget {\n return new TableWidget(options);\n}\n\n/**\n * Options for {@link Table.fromRows}.\n */\nexport interface TableFromRowsOptions extends Omit<TableOptions, 'head' | 'body'> {\n /**\n * When true, the first row is rendered as a table head using the head\n * background color from the table options or theme.\n */\n header?: boolean;\n}\n\n/**\n * Convenience constructor for the common case: a list of rows where every\n * cell is plain text. The first row can be promoted to a header via\n * `{ header: true }`. This collapses the verbose\n * `TableHead({ rows: [TableRow({ children: [...].map(v => TableCell({ child: Text(v) })) })] })`\n * ceremony into a single call.\n *\n * @example\n * Table.fromRows([['KPI', 'Value', 'Change'], ['$42k', '+12%']], {\n * header: true,\n * columnWeights: [2, 1, 1],\n * })\n */\nexport function fromRows(\n rows: Array<Array<string | Widget>>,\n options: TableFromRowsOptions = {}\n): TableWidget {\n const { header = false, ...tableOptions } = options;\n const toCell = (value: string | Widget) =>\n TableCell({ child: typeof value === 'string' ? Text(value, {}) : value });\n const toRow = (cells: Array<string | Widget>) =>\n TableRow({ children: cells.map(toCell) });\n\n const bodyRows = rows.map(toRow);\n // No rows → nothing to promote to the head; `shift()` on an empty array\n // would otherwise crash with an opaque TypeError (B20).\n const head = header && bodyRows.length > 0 ? TableHead({ rows: [bodyRows.shift()!] }) : undefined;\n const body = TableBody({ rows: bodyRows });\n\n return createTable({ ...tableOptions, head, body });\n}\n\nexport type TableComponent = ((options: TableOptions) => TableWidget) & {\n fromRows: typeof fromRows;\n};\n\nexport const Table: TableComponent = Object.assign(createTable, { fromRows });\n","import type { RenderContext } from './RenderContextInterface';\nimport type { RenderColor } from './RenderContextTypes';\nimport { type ThemeColorValue } from './Theme';\nimport { resolveColor } from './theme-resolve';\nimport { fromHex } from './utils/color-utils';\nimport { Widget, WidgetOptions, YogaStyleValue } from './Widget';\n\nexport interface HLineOptions extends WidgetOptions {\n color?: ThemeColorValue;\n thickness?: number;\n width?: YogaStyleValue;\n}\n\nexport class HLineWidget extends Widget {\n private color?: ThemeColorValue;\n private thickness: number;\n\n constructor(options: HLineOptions = {}) {\n super(options);\n this.color = options.color ?? fromHex('#000000');\n this.thickness = Number.isFinite(options.thickness) && (options.thickness as number) > 0\n ? options.thickness as number\n : 1;\n\n this.setYogaStyle({\n width: options.width ?? '100%',\n height: this.thickness,\n alignSelf: 'stretch',\n });\n }\n\n private getColor(): RenderColor {\n return resolveColor(this.context?.getTheme(), this.color, undefined, fromHex('#000000'));\n }\n\n async render(context: RenderContext): Promise<void> {\n const { x, y, width, height } = context.getLayoutBox(this);\n const lineY = y + height / 2;\n\n context.drawLine({\n start: { x, y: lineY },\n end: { x: x + width, y: lineY },\n thickness: this.thickness,\n color: this.getColor()\n });\n }\n}\n\nexport function HLine(options: HLineOptions = {}): HLineWidget {\n return new HLineWidget(options);\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAgIA,IAAM,mBAAN,MAAuB;AAAA,EACX;AAAA,EACA;AAAA,EACT;AAAA,EACA;AAAA,EAER,YAAY,QAA0B;AACpC,SAAK,SAAS;AACd,SAAK,oBACH,OAAO,SAAS,eAAe,eAAe,OAC1C,IAAI,KAAK,UAAU,QAAW,EAAE,aAAa,WAAW,CAAC,IACzD;AAAA,EACR;AAAA,EAEQ,gBAAyB;AAC/B,QAAI,OAAO,SAAS,eAAe,EAAE,eAAe,OAAO;AACzD,aAAO;AAAA,IACT;AAGA,WACE,OAAO,oBAAoB,eAC1B,OAAO,aAAa,eAAe,OAAO,SAAS,kBAAkB;AAAA,EAE1E;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,mBAAmB,YAA0D;AAG3E,QAAI,KAAK,OAAO,MAAM;AACpB,aAAO;AAAA,IACT;AAEA,QAAI,CAAC,KAAK,cAAc,GAAG;AACzB,aAAO;AAAA,IACT;AAEA,UAAM,MAAM,KAAK,UAAU;AAAA,MACzB,KAAK,OAAO;AAAA,MACZ;AAAA,MACA,KAAK,OAAO;AAAA,MACZ,KAAK,OAAO;AAAA,IACd,CAAC;AAED,QAAI,KAAK,gBAAgB,KAAK,oBAAoB,KAAK;AACrD,a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,QAAQ,SAAS;AAAA,MACxB,QAAQ,KAAK;AAAA,MACb,WAAW;AAAA,IACb,CAAC;AAAA,EACH;AAAA,EAEQ,WAAwB;AAC9B,WAAO,aAAa,KAAK,SAAS,SAAS,GAAG,KAAK,OAAO,QAAW,QAAQ,SAAS,CAAC;AAAA,EACzF;AAAA,EAEA,MAAM,OAAO,SAAuC;AAClD,UAAM,EAAE,GAAG,GAAG,OAAO,OAAO,IAAI,QAAQ,aAAa,IAAI;AACzD,UAAM,QAAQ,IAAI,SAAS;AAE3B,YAAQ,SAAS;AAAA,MACf,OAAO,EAAE,GAAG,GAAG,MAAM;AAAA,MACrB,KAAK,EAAE,GAAG,IAAI,OAAO,GAAG,MAAM;AAAA,MAC9B,WAAW,KAAK;AAAA,MAChB,OAAO,KAAK,SAAS;AAAA,IACvB,CAAC;AAAA,EACH;AACF;AAEO,SAAS,MAAM,UAAwB,CAAC,GAAgB;AAC7D,SAAO,IAAI,YAAY,OAAO;AAChC;","names":["kept"]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Widget
|
|
3
|
-
} from "./chunk-PCKIGCEJ.js";
|
|
4
|
-
import {
|
|
2
|
+
Widget,
|
|
5
3
|
resolveColor
|
|
6
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MBZC4ZQH.js";
|
|
7
5
|
import {
|
|
8
6
|
toPdfLibColor
|
|
9
7
|
} from "./chunk-JU7VYYBJ.js";
|
|
@@ -104,4 +102,4 @@ export {
|
|
|
104
102
|
FormWidget,
|
|
105
103
|
PlacedFormWidget
|
|
106
104
|
};
|
|
107
|
-
//# sourceMappingURL=chunk-
|
|
105
|
+
//# sourceMappingURL=chunk-CKBKBBHC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/forms/surface.ts","../src/lib/forms/FormWidget.ts"],"sourcesContent":["import type { PDFForm, PDFPage } from 'pdf-lib';\nimport type { RenderContext } from '../RenderContextInterface';\n\n/**\n * The PDF-typed surface form widgets need (ADR 0001: PDF features get\n * PDF-typed modules, never interface widening).\n *\n * Form fields are pure PDF mechanics — an AcroForm field lives in the\n * document's catalog and its widget annotations live on pages — so the seam\n * stays out of the backend-neutral `RenderContext`. `PdfRenderContext`\n * supplies both members; form widgets narrow to this surface at render time,\n * the same runtime narrowing `LoadedPage` uses for `PdfPageSurface`.\n */\nexport interface PdfFormSurface {\n /** The document's interactive form (created in the catalog on first use). */\n getForm(): PDFForm;\n /** The page being painted by the current render walk. */\n getCurrentPage(): PDFPage | null;\n}\n\n/** Structural check: does this context expose the form surface? */\nexport function isPdfFormSurface(context: RenderContext): context is RenderContext & PdfFormSurface {\n // The unknown bridge mirrors `isPdfPageSurface`: `RenderContext` does not\n // declare these members, so the check probes at runtime.\n const candidate = context as unknown as Partial<PdfFormSurface>;\n return (\n typeof candidate.getForm === 'function' &&\n typeof candidate.getCurrentPage === 'function'\n );\n}\n","import type { PDFForm, PDFPage } from 'pdf-lib';\nimport type { RenderContext } from '../RenderContextInterface';\nimport type { ThemeColorValue } from '../Theme';\nimport { resolveColor } from '../theme-resolve';\nimport type { Color as PdfLibColor } from 'pdf-lib';\nimport { toPdfLibColor } from '../utils/color-utils';\nimport { Widget, type WidgetOptions, type YogaStyleValue } from '../Widget';\nimport { isPdfFormSurface } from './surface';\n\n/**\n * Appearance options pdf-lib's field appearance generation supports. The\n * default appearance font is Helvetica (a pdf-lib limitation — embedded-font\n * faces can come later); unset options leave pdf-lib's own defaults in place.\n */\nexport interface FormFieldAppearance {\n fontSize?: number;\n textColor?: ThemeColorValue;\n backgroundColor?: ThemeColorValue;\n borderColor?: ThemeColorValue;\n borderWidth?: number;\n}\n\n/**\n * Options every form field shares. `width`/`height` size the field's box —\n * the box IS the widget, so every field ships a usable default instead of\n * shrink-wrapping to zero.\n */\nexport interface FormFieldOptions extends WidgetOptions, FormFieldAppearance {\n /** Field cannot be edited in the PDF reader. */\n readOnly?: boolean;\n /** Box size overrides (defaults per field type). */\n width?: YogaStyleValue;\n height?: YogaStyleValue;\n}\n\n/**\n * Appearance args handed to pdf-lib's `addToPage` — the subset of its\n * (unexported) `FieldAppearanceOptions` form widgets set.\n */\ninterface FieldAppearanceArgs {\n textColor?: PdfLibColor;\n backgroundColor?: PdfLibColor;\n borderColor?: PdfLibColor;\n borderWidth?: number;\n}\n\n/**\n * Base class for widgets that create AcroForm fields.\n *\n * Form widgets are PDF-typed (ADR 0001): at render time they narrow the\n * backend-neutral context to {@link PdfFormSurface} and place their field at\n * the widget's layout box — which `getLayoutBox` already returns in PDF\n * coordinates (bottom-left origin; the Y-flip lives in the backend), exactly\n * what pdf-lib's `addToPage` wants. Because `PageScope` answers\n * `getLayoutBox` from the pagination plan, fields compose with pagination and\n * absolute positioning for free.\n *\n * Fields are created fresh on every render walk: a second save builds a fresh\n * `PDFDocument`, so nothing pdf-lib-owned is cached on the widget.\n */\nexport abstract class FormWidget extends Widget {\n /** The AcroForm field name — unique per document (pdf-lib enforces it). */\n readonly name: string;\n protected readonly readOnly: boolean;\n protected readonly appearance: FormFieldAppearance;\n\n constructor(name: string, options: FormFieldOptions = {}) {\n super(options);\n if (typeof name !== 'string' || name.trim().length === 0) {\n throw new Error(\n 'Form widgets require a non-empty `name` — it is the AcroForm field name (and the data-binding key).',\n );\n }\n this.name = name;\n this.readOnly = options.readOnly ?? false;\n this.appearance = {\n fontSize: options.fontSize,\n textColor: options.textColor,\n backgroundColor: options.backgroundColor,\n borderColor: options.borderColor,\n borderWidth: options.borderWidth,\n };\n }\n\n /** Readable widget name for error messages. */\n protected abstract get kind(): string;\n\n /**\n * Applies a formData value by field name (PdfDoc's binding walk). The base\n * refuses: only value-carrying fields (text, check, dropdown, radio group)\n * accept bindings — a Button, for instance, carries no value.\n *\n * @internal — package-internal: PdfDoc's formData walk applies values here.\n */\n bindValue(value: string | boolean): void {\n throw new Error(\n `${this.kind} has no value to bind (got ${typeof value}) — only text, check, dropdown, and radio fields accept formData values.`,\n );\n }\n\n /**\n * Narrows the backend-neutral context to the PDF form surface at render\n * time — the `LoadedPage` narrowing pattern (ADR 0001: PDF-typed modules,\n * never interface widening).\n */\n protected requireSurface(context: RenderContext): { form: PDFForm; page: PDFPage } {\n if (!isPdfFormSurface(context)) {\n throw new Error(\n `${this.kind} requires the PDF render context (pdf-kalem/forms renders through pdf-lib).`,\n );\n }\n const page = context.getCurrentPage();\n if (!page) {\n throw new Error(\n `${this.kind} rendered with no open page — form fields are placed on the page being painted.`,\n );\n }\n return { form: context.getForm(), page };\n }\n\n /**\n * Resolves appearance overrides against the theme (no theme tokens yet).\n * Unset options are OMITTED, not passed as undefined — pdf-lib's\n * `addToPage` only applies its own defaults (black text, white background,\n * black 1pt border) for keys that are absent, and a visible box is the\n * right default for a form field.\n *\n * @internal — package-internal: Radio reads its group's resolved appearance.\n */\n appearanceArgs(context: RenderContext): FieldAppearanceArgs {\n const theme = context.getTheme();\n const appearance = this.appearance;\n const args: FieldAppearanceArgs = {};\n const textColor = toPdfLibColor(resolveColor(theme, appearance.textColor));\n const backgroundColor = toPdfLibColor(resolveColor(theme, appearance.backgroundColor));\n const borderColor = toPdfLibColor(resolveColor(theme, appearance.borderColor));\n if (textColor) args.textColor = textColor;\n if (backgroundColor) args.backgroundColor = backgroundColor;\n if (borderColor) args.borderColor = borderColor;\n if (appearance.borderWidth !== undefined) args.borderWidth = appearance.borderWidth;\n return args;\n }\n}\n\n/**\n * A form field placed at its own layout box — the leaf fields. Field-owning\n * containers ({@link RadioGroup}) extend {@link FormWidget} directly and\n * override `render` instead: their box holds children, not a field.\n */\nexport abstract class PlacedFormWidget extends FormWidget {\n async render(context: RenderContext): Promise<void> {\n const { form, page } = this.requireSurface(context);\n const box = context.getLayoutBox(this);\n this.placeField(form, page, box, context);\n }\n\n /**\n * Create the pdf-lib field and place it at `box` (PDF coordinates:\n * bottom-left origin). Configure field state (value, flags) before\n * `addToPage` so the generated appearance reflects it; `setFontSize` must\n * come AFTER `addToPage` (it needs the /DA entry `addToPage` creates).\n */\n protected abstract placeField(\n form: PDFForm,\n page: PDFPage,\n box: { x: number; y: number; width: number; height: number },\n context: RenderContext,\n ): void;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/lib/forms/surface.ts","../src/lib/forms/FormWidget.ts"],"sourcesContent":["import type { PDFForm, PDFPage } from 'pdf-lib';\nimport type { RenderContext } from '../RenderContextInterface';\n\n/**\n * The PDF-typed surface form widgets need (ADR 0001: PDF features get\n * PDF-typed modules, never interface widening).\n *\n * Form fields are pure PDF mechanics — an AcroForm field lives in the\n * document's catalog and its widget annotations live on pages — so the seam\n * stays out of the backend-neutral `RenderContext`. `PdfRenderContext`\n * supplies both members; form widgets narrow to this surface at render time,\n * the same runtime narrowing `LoadedPage` uses for `PdfPageSurface`.\n */\nexport interface PdfFormSurface {\n /** The document's interactive form (created in the catalog on first use). */\n getForm(): PDFForm;\n /** The page being painted by the current render walk. */\n getCurrentPage(): PDFPage | null;\n}\n\n/** Structural check: does this context expose the form surface? */\nexport function isPdfFormSurface(context: RenderContext): context is RenderContext & PdfFormSurface {\n // The unknown bridge mirrors `isPdfPageSurface`: `RenderContext` does not\n // declare these members, so the check probes at runtime.\n const candidate = context as unknown as Partial<PdfFormSurface>;\n return (\n typeof candidate.getForm === 'function' &&\n typeof candidate.getCurrentPage === 'function'\n );\n}\n","import type { PDFForm, PDFPage } from 'pdf-lib';\nimport type { RenderContext } from '../RenderContextInterface';\nimport type { ThemeColorValue } from '../Theme';\nimport { resolveColor } from '../theme-resolve';\nimport type { Color as PdfLibColor } from 'pdf-lib';\nimport { toPdfLibColor } from '../utils/color-utils';\nimport { Widget, type WidgetOptions, type YogaStyleValue } from '../Widget';\nimport { isPdfFormSurface } from './surface';\n\n/**\n * Appearance options pdf-lib's field appearance generation supports. The\n * default appearance font is Helvetica (a pdf-lib limitation — embedded-font\n * faces can come later); unset options leave pdf-lib's own defaults in place.\n */\nexport interface FormFieldAppearance {\n fontSize?: number;\n textColor?: ThemeColorValue;\n backgroundColor?: ThemeColorValue;\n borderColor?: ThemeColorValue;\n borderWidth?: number;\n}\n\n/**\n * Options every form field shares. `width`/`height` size the field's box —\n * the box IS the widget, so every field ships a usable default instead of\n * shrink-wrapping to zero.\n */\nexport interface FormFieldOptions extends WidgetOptions, FormFieldAppearance {\n /** Field cannot be edited in the PDF reader. */\n readOnly?: boolean;\n /** Box size overrides (defaults per field type). */\n width?: YogaStyleValue;\n height?: YogaStyleValue;\n}\n\n/**\n * Appearance args handed to pdf-lib's `addToPage` — the subset of its\n * (unexported) `FieldAppearanceOptions` form widgets set.\n */\ninterface FieldAppearanceArgs {\n textColor?: PdfLibColor;\n backgroundColor?: PdfLibColor;\n borderColor?: PdfLibColor;\n borderWidth?: number;\n}\n\n/**\n * Base class for widgets that create AcroForm fields.\n *\n * Form widgets are PDF-typed (ADR 0001): at render time they narrow the\n * backend-neutral context to {@link PdfFormSurface} and place their field at\n * the widget's layout box — which `getLayoutBox` already returns in PDF\n * coordinates (bottom-left origin; the Y-flip lives in the backend), exactly\n * what pdf-lib's `addToPage` wants. Because `PageScope` answers\n * `getLayoutBox` from the pagination plan, fields compose with pagination and\n * absolute positioning for free.\n *\n * Fields are created fresh on every render walk: a second save builds a fresh\n * `PDFDocument`, so nothing pdf-lib-owned is cached on the widget.\n */\nexport abstract class FormWidget extends Widget {\n /** The AcroForm field name — unique per document (pdf-lib enforces it). */\n readonly name: string;\n protected readonly readOnly: boolean;\n protected readonly appearance: FormFieldAppearance;\n\n constructor(name: string, options: FormFieldOptions = {}) {\n super(options);\n if (typeof name !== 'string' || name.trim().length === 0) {\n throw new Error(\n 'Form widgets require a non-empty `name` — it is the AcroForm field name (and the data-binding key).',\n );\n }\n this.name = name;\n this.readOnly = options.readOnly ?? false;\n this.appearance = {\n fontSize: options.fontSize,\n textColor: options.textColor,\n backgroundColor: options.backgroundColor,\n borderColor: options.borderColor,\n borderWidth: options.borderWidth,\n };\n }\n\n /** Readable widget name for error messages. */\n protected abstract get kind(): string;\n\n /**\n * Applies a formData value by field name (PdfDoc's binding walk). The base\n * refuses: only value-carrying fields (text, check, dropdown, radio group)\n * accept bindings — a Button, for instance, carries no value.\n *\n * @internal — package-internal: PdfDoc's formData walk applies values here.\n */\n bindValue(value: string | boolean): void {\n throw new Error(\n `${this.kind} has no value to bind (got ${typeof value}) — only text, check, dropdown, and radio fields accept formData values.`,\n );\n }\n\n /**\n * Narrows the backend-neutral context to the PDF form surface at render\n * time — the `LoadedPage` narrowing pattern (ADR 0001: PDF-typed modules,\n * never interface widening).\n */\n protected requireSurface(context: RenderContext): { form: PDFForm; page: PDFPage } {\n if (!isPdfFormSurface(context)) {\n throw new Error(\n `${this.kind} requires the PDF render context (pdf-kalem/forms renders through pdf-lib).`,\n );\n }\n const page = context.getCurrentPage();\n if (!page) {\n throw new Error(\n `${this.kind} rendered with no open page — form fields are placed on the page being painted.`,\n );\n }\n return { form: context.getForm(), page };\n }\n\n /**\n * Resolves appearance overrides against the theme (no theme tokens yet).\n * Unset options are OMITTED, not passed as undefined — pdf-lib's\n * `addToPage` only applies its own defaults (black text, white background,\n * black 1pt border) for keys that are absent, and a visible box is the\n * right default for a form field.\n *\n * @internal — package-internal: Radio reads its group's resolved appearance.\n */\n appearanceArgs(context: RenderContext): FieldAppearanceArgs {\n const theme = context.getTheme();\n const appearance = this.appearance;\n const args: FieldAppearanceArgs = {};\n const textColor = toPdfLibColor(resolveColor(theme, appearance.textColor));\n const backgroundColor = toPdfLibColor(resolveColor(theme, appearance.backgroundColor));\n const borderColor = toPdfLibColor(resolveColor(theme, appearance.borderColor));\n if (textColor) args.textColor = textColor;\n if (backgroundColor) args.backgroundColor = backgroundColor;\n if (borderColor) args.borderColor = borderColor;\n if (appearance.borderWidth !== undefined) args.borderWidth = appearance.borderWidth;\n return args;\n }\n}\n\n/**\n * A form field placed at its own layout box — the leaf fields. Field-owning\n * containers ({@link RadioGroup}) extend {@link FormWidget} directly and\n * override `render` instead: their box holds children, not a field.\n */\nexport abstract class PlacedFormWidget extends FormWidget {\n async render(context: RenderContext): Promise<void> {\n const { form, page } = this.requireSurface(context);\n const box = context.getLayoutBox(this);\n this.placeField(form, page, box, context);\n }\n\n /**\n * Create the pdf-lib field and place it at `box` (PDF coordinates:\n * bottom-left origin). Configure field state (value, flags) before\n * `addToPage` so the generated appearance reflects it; `setFontSize` must\n * come AFTER `addToPage` (it needs the /DA entry `addToPage` creates).\n */\n protected abstract placeField(\n form: PDFForm,\n page: PDFPage,\n box: { x: number; y: number; width: number; height: number },\n context: RenderContext,\n ): void;\n}\n"],"mappings":";;;;;;;;;AAqBO,SAAS,iBAAiB,SAAmE;AAGlG,QAAM,YAAY;AAClB,SACE,OAAO,UAAU,YAAY,cAC7B,OAAO,UAAU,mBAAmB;AAExC;;;AC+BO,IAAe,aAAf,cAAkC,OAAO;AAAA;AAAA,EAErC;AAAA,EACU;AAAA,EACA;AAAA,EAEnB,YAAY,MAAc,UAA4B,CAAC,GAAG;AACxD,UAAM,OAAO;AACb,QAAI,OAAO,SAAS,YAAY,KAAK,KAAK,EAAE,WAAW,GAAG;AACxD,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AACA,SAAK,OAAO;AACZ,SAAK,WAAW,QAAQ,YAAY;AACpC,SAAK,aAAa;AAAA,MAChB,UAAU,QAAQ;AAAA,MAClB,WAAW,QAAQ;AAAA,MACnB,iBAAiB,QAAQ;AAAA,MACzB,aAAa,QAAQ;AAAA,MACrB,aAAa,QAAQ;AAAA,IACvB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,UAAU,OAA+B;AACvC,UAAM,IAAI;AAAA,MACR,GAAG,KAAK,IAAI,8BAA8B,OAAO,KAAK;AAAA,IACxD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOU,eAAe,SAA0D;AACjF,QAAI,CAAC,iBAAiB,OAAO,GAAG;AAC9B,YAAM,IAAI;AAAA,QACR,GAAG,KAAK,I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