chat-layout 1.1.2 → 1.2.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -49,7 +49,7 @@ See [example/chat.ts](./example/chat.ts) for a full chat example.
49
49
  - `Place` is the simplest way to align a single bubble left, center, or right.
50
50
  - `MultilineText.align` uses logical values: `start`, `center`, `end`.
51
51
  - `MultilineText.physicalAlign` uses physical values: `left`, `center`, `right`.
52
- - `Text` and `MultilineText` default to `whiteSpace: "normal"`, matching pretext and CSS-style collapsible whitespace.
52
+ - `Text` and `MultilineText` default to `whiteSpace: "normal"`, using the library's canvas-first collapsible whitespace behavior.
53
53
  - Use `whiteSpace: "pre-wrap"` when blank lines, hard breaks, or edge spaces must stay visible.
54
54
  - `Text` and `MultilineText` default to `overflowWrap: "break-word"`, which preserves compatibility-first min-content sizing for shrink layouts.
55
55
  - Use `overflowWrap: "anywhere"` when long unspaced strings should contribute grapheme-level breakpoints to min-content sizing.
@@ -139,3 +139,5 @@ Build the chat example:
139
139
  ```bash
140
140
  bun run example
141
141
  ```
142
+
143
+ 文本性能观测基线见 `docs/text-performance.md`。
package/index.d.mts CHANGED
@@ -53,7 +53,7 @@ type TextWhiteSpaceMode = "normal" | "pre-wrap";
53
53
  */
54
54
  type TextOverflowMode = "clip" | "ellipsis";
55
55
  /**
56
- * Word breaking mode used by pretext during segmentation and line breaking.
56
+ * Word breaking mode used by the internal canvas text layout engine.
57
57
  */
58
58
  type TextWordBreakMode = "normal" | "keep-all";
59
59
  /**
@@ -74,9 +74,9 @@ interface TextStyleOptions<C extends CanvasRenderingContext2D> {
74
74
  font: string;
75
75
  /** Color or resolver used when drawing the text. */
76
76
  color: DynValue<C, string>;
77
- /** Default: normal; matches pretext and CSS-style collapsible whitespace behavior. */
77
+ /** Default: normal; uses canvas-first CSS-style collapsible whitespace behavior. */
78
78
  whiteSpace?: TextWhiteSpaceMode;
79
- /** Default: normal; use keep-all to match pretext's CJK-friendly line breaking mode. */
79
+ /** Default: normal; use keep-all for CJK-friendly line breaking. */
80
80
  wordBreak?: TextWordBreakMode;
81
81
  /** Default: break-word; use anywhere when min-content should honor grapheme break opportunities. */
82
82
  overflowWrap?: TextOverflowWrapMode;
@@ -91,9 +91,9 @@ interface InlineSpan<C extends CanvasRenderingContext2D> {
91
91
  font?: string;
92
92
  /** Color override for this fragment. Falls back to the node-level color. */
93
93
  color?: DynValue<C, string>;
94
- /** Optional break hint forwarded to pretext rich-inline layout. */
94
+ /** Optional break hint for atomic inline spans. */
95
95
  break?: "normal" | "never";
96
- /** Optional extra occupied width forwarded to pretext rich-inline layout. */
96
+ /** Optional extra occupied width appended after the span's rendered text. */
97
97
  extraWidth?: number;
98
98
  }
99
99
  /**