chat-layout 1.1.1 → 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 +4 -1
- package/index.d.mts +8 -6
- package/index.mjs +1512 -438
- package/index.mjs.map +1 -1
- package/package.json +2 -4
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"`,
|
|
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.
|
|
@@ -108,6 +108,7 @@ Notes:
|
|
|
108
108
|
## Migration notes
|
|
109
109
|
|
|
110
110
|
- Use `memoRenderItemBy(keyOf, renderItem)` when list items are primitives.
|
|
111
|
+
- `memoRenderItemBy()` now uses a bounded LRU cache by default; pass `{ maxEntries: Infinity }` to keep the old unbounded behavior explicitly.
|
|
111
112
|
- `FlexItem` exposes `grow`, `shrink`, and `alignSelf`; `basis` is no longer public.
|
|
112
113
|
- `MultilineText` now uses `align` / `physicalAlign` instead of `alignment`.
|
|
113
114
|
- `ListState.position` uses `undefined` for the renderer default anchor.
|
|
@@ -138,3 +139,5 @@ Build the chat example:
|
|
|
138
139
|
```bash
|
|
139
140
|
bun run example
|
|
140
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
|
|
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;
|
|
77
|
+
/** Default: normal; uses canvas-first CSS-style collapsible whitespace behavior. */
|
|
78
78
|
whiteSpace?: TextWhiteSpaceMode;
|
|
79
|
-
/** Default: normal; use keep-all
|
|
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
|
|
94
|
+
/** Optional break hint for atomic inline spans. */
|
|
95
95
|
break?: "normal" | "never";
|
|
96
|
-
/** Optional extra occupied width
|
|
96
|
+
/** Optional extra occupied width appended after the span's rendered text. */
|
|
97
97
|
extraWidth?: number;
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
@@ -518,7 +518,9 @@ declare function memoRenderItem<C extends CanvasRenderingContext2D, T extends ob
|
|
|
518
518
|
/**
|
|
519
519
|
* Memoizes `renderItem` by a caller-provided cache key.
|
|
520
520
|
*/
|
|
521
|
-
declare function memoRenderItemBy<C extends CanvasRenderingContext2D, T, K>(keyOf: (item: T) => K, renderItem: (item: T) => Node<C
|
|
521
|
+
declare function memoRenderItemBy<C extends CanvasRenderingContext2D, T, K>(keyOf: (item: T) => K, renderItem: (item: T) => Node<C>, options?: {
|
|
522
|
+
maxEntries?: number;
|
|
523
|
+
}): ((item: T) => Node<C>) & {
|
|
522
524
|
reset: (item: T) => boolean;
|
|
523
525
|
resetKey: (key: K) => boolean;
|
|
524
526
|
};
|