@aspan-corporation/ac-shared 1.2.36 → 1.2.37

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.
@@ -49,6 +49,14 @@ export declare const parseDiaryKeyDate: (key: string) => {
49
49
  * words. Strips markdown syntax (code fences, image/link targets, formatting),
50
50
  * drops stop-words and tokens shorter than 2 chars, and caps the result at
51
51
  * `MAX_TEXT_TOKENS` to bound the meta-item size. No stemming (exact-word match).
52
+ *
53
+ * Word boundaries and lowercasing are Unicode-aware: tokens are split on any
54
+ * run of characters that are neither a Unicode letter (`\p{L}`) nor number
55
+ * (`\p{N}`), so non-Latin scripts (e.g. Cyrillic) survive as searchable words
56
+ * rather than being discarded. `toLowerCase()` is likewise Unicode-aware; we
57
+ * deliberately avoid `toLocaleLowerCase()` so tokenisation is deterministic and
58
+ * independent of the host locale (the indexer lambda and the browser that
59
+ * builds search queries must produce identical tokens).
52
60
  */
53
61
  export declare const tokenizeText: (markdown: string) => string[];
54
62
  /** Plain-text preview: strip markdown, collapse whitespace, truncate. */
@@ -91,6 +91,14 @@ const STOP_WORDS = new Set([
91
91
  * words. Strips markdown syntax (code fences, image/link targets, formatting),
92
92
  * drops stop-words and tokens shorter than 2 chars, and caps the result at
93
93
  * `MAX_TEXT_TOKENS` to bound the meta-item size. No stemming (exact-word match).
94
+ *
95
+ * Word boundaries and lowercasing are Unicode-aware: tokens are split on any
96
+ * run of characters that are neither a Unicode letter (`\p{L}`) nor number
97
+ * (`\p{N}`), so non-Latin scripts (e.g. Cyrillic) survive as searchable words
98
+ * rather than being discarded. `toLowerCase()` is likewise Unicode-aware; we
99
+ * deliberately avoid `toLocaleLowerCase()` so tokenisation is deterministic and
100
+ * independent of the host locale (the indexer lambda and the browser that
101
+ * builds search queries must produce identical tokens).
94
102
  */
95
103
  export const tokenizeText = (markdown) => {
96
104
  if (!markdown)
@@ -109,11 +117,12 @@ export const tokenizeText = (markdown) => {
109
117
  // leftover markdown punctuation
110
118
  .replace(/[#>*_~\-]+/g, " ");
111
119
  const seen = new Set();
112
- for (const raw of stripped.toLowerCase().split(/[^a-z0-9]+/)) {
120
+ for (const raw of stripped.toLowerCase().split(/[^\p{L}\p{N}]+/u)) {
113
121
  if (raw.length < 2)
114
122
  continue;
115
- // Drop pure numbers (dates/counts add noise); keep alphanumerics like "v2".
116
- if (/^\d+$/.test(raw))
123
+ // Drop pure-number tokens (dates/counts add noise) in any script; keep
124
+ // alphanumerics like "v2".
125
+ if (/^\p{N}+$/u.test(raw))
117
126
  continue;
118
127
  if (STOP_WORDS.has(raw))
119
128
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aspan-corporation/ac-shared",
3
- "version": "1.2.36",
3
+ "version": "1.2.37",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "exports": {