@bitbaum/chatkit 0.15.2 → 0.15.3

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
@@ -506,3 +506,5 @@ catalogue access belong to the app's media tools: this renderer does not
506
506
  create a song or grant rights to redistribute it. Copy and speech preserve the
507
507
  track's title, creator and caption. The demo WAV is an original synthesized
508
508
  fixture; it is not a commercial track or a model-generated recording.
509
+
510
+ The browser word-layout audit uses Unicode word boundaries. Chinese, Japanese and Korean may wrap between characters; those legal breaks are accepted while squeezed Latin words, including words embedded in CJK text, are still reported. Whole-page and chart overflow checks remain separate.
package/dist/audit.d.ts CHANGED
@@ -21,7 +21,8 @@
21
21
  * Exempt, because a break there is legal: a word beside a hyphen, slash, dot,
22
22
  * at-sign, colon or underscore, and anything over `maxWord` characters (a URL
23
23
  * or an identifier has to break somewhere). Hidden text has no boxes and is
24
- * skipped.
24
+ * skipped. CJK scripts permit line breaks between characters; their wrapping
25
+ * is not a broken word. Other scripts use Unicode word boundaries.
25
26
  */
26
27
  export declare function findBrokenWords(root?: ParentNode, options?: {
27
28
  maxWord?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,IAAI,GAAE,UAAqB,EAC3B,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GACjC,MAAM,EAAE,CA0BV;AAED,6DAA6D;AAC7D,eAAO,MAAM,mBAAmB,EAAE,MAAmC,CAAC"}
1
+ {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,IAAI,GAAE,UAAqB,EAC3B,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GACjC,MAAM,EAAE,CA+BV;AAED,6DAA6D;AAC7D,eAAO,MAAM,mBAAmB,EAAE,MAAmC,CAAC"}
package/dist/audit.js CHANGED
@@ -21,25 +21,28 @@
21
21
  * Exempt, because a break there is legal: a word beside a hyphen, slash, dot,
22
22
  * at-sign, colon or underscore, and anything over `maxWord` characters (a URL
23
23
  * or an identifier has to break somewhere). Hidden text has no boxes and is
24
- * skipped.
24
+ * skipped. CJK scripts permit line breaks between characters; their wrapping
25
+ * is not a broken word. Other scripts use Unicode word boundaries.
25
26
  */
26
27
  export function findBrokenWords(root = document, options = {}) {
27
28
  const maxWord = options.maxWord ?? 24;
28
29
  const found = [];
29
30
  const near = /[-‐‑–—/_.@:]/;
31
+ const characterWrapping = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u;
32
+ const words = new Intl.Segmenter(undefined, { granularity: "word" });
30
33
  const walker = document.createTreeWalker(root instanceof Document ? root.body : root, NodeFilter.SHOW_TEXT);
31
34
  for (let n = walker.nextNode(); n; n = walker.nextNode()) {
32
35
  const text = n.nodeValue ?? "";
33
- const re = /[\p{L}\p{N}']+/gu;
34
- for (let m = re.exec(text); m; m = re.exec(text)) {
35
- const word = m[0];
36
- if (word.length > maxWord)
36
+ for (const { segment: word, index, isWordLike } of words.segment(text)) {
37
+ if (!isWordLike || characterWrapping.test(word) || word.length > maxWord)
37
38
  continue;
38
- if (near.test(text[m.index - 1] ?? "") || near.test(text[m.index + word.length] ?? ""))
39
+ if (near.test(word) ||
40
+ near.test(text[index - 1] ?? "") ||
41
+ near.test(text[index + word.length] ?? ""))
39
42
  continue;
40
43
  const range = document.createRange();
41
- range.setStart(n, m.index);
42
- range.setEnd(n, m.index + word.length);
44
+ range.setStart(n, index);
45
+ range.setEnd(n, index + word.length);
43
46
  const tops = Array.from(range.getClientRects())
44
47
  .filter((r) => r.width > 0)
45
48
  .map((r) => Math.round(r.top));
package/dist/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K,GAAG,CAAC,CAAC;iBAC1B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACjC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;gBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,6DAA6D;AAC7D,MAAM,CAAC,MAAM,mBAAmB,GAAW,eAAe,CAAC,QAAQ,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitbaum/chatkit",
3
- "version": "0.15.2",
3
+ "version": "0.15.3",
4
4
  "description": "One chat for every product: a composer with a microphone that always works, a thread that does not fight the reader, messages with copy and retry, and LLM markdown \u2014 the fleet's chat standard as a package.",
5
5
  "license": "MIT",
6
6
  "author": "Cato",
@@ -74,7 +74,7 @@
74
74
  "test:browser": "pnpm run demo && node test/browser.mjs"
75
75
  },
76
76
  "devDependencies": {
77
- "@bitbaum/design-tokens": "^1.1.0",
77
+ "@bitbaum/design-tokens": "github:bitbaum/design-tokens#5c31f48743dabf9294bf9380a15862b4efbc68a0",
78
78
  "@eslint/js": "^10.0.1",
79
79
  "@types/node": "^26.4.0",
80
80
  "@types/react": "^19.2.18",