@blocksuite/store
Advanced tools
Comparing version 0.3.0-20221218162424-d362663 to 0.3.0-20221219152633-59209d4
{ | ||
"name": "@blocksuite/store", | ||
"version": "0.3.0-20221218162424-d362663", | ||
"version": "0.3.0-20221219152633-59209d4", | ||
"description": "BlockSuite data store built for general purpose state management.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -1,2 +0,6 @@ | ||
import { Document as DocumentIndexer, DocumentSearchOptions } from 'flexsearch'; | ||
import { | ||
Document as DocumentIndexer, | ||
DocumentSearchOptions, | ||
Index, | ||
} from 'flexsearch'; | ||
import { Doc, Map as YMap, Text as YText } from 'yjs'; | ||
@@ -13,7 +17,26 @@ import type { YBlock } from './page'; | ||
if (tokenizer) { | ||
// extract the latin encoder inside flexsearch | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const latinIndexer: any = new Index({ charset: 'latin:advanced' }); | ||
const latinEncoder = latinIndexer.encode.bind(latinIndexer); | ||
// check latin characters | ||
const latinChecker = /^[\p{Script=Latin}\p{Mark}\d]+$/u; | ||
const segmenter = new tokenizer([locale], { granularity: 'word' }); | ||
return (text: string) => | ||
Array.from(segmenter.segment(text)) | ||
.filter(s => s.isWordLike) | ||
return (text: string) => { | ||
const latinChars: string[] = []; | ||
const cjkChars = Array.from(segmenter.segment(text)) | ||
.filter(s => { | ||
if (s.isWordLike) { | ||
if (!latinChecker.test(s.segment)) { | ||
return true; | ||
} | ||
latinChars.push(s.segment); | ||
} | ||
return false; | ||
}) | ||
.map(s => s.segment); | ||
return [...cjkChars, ...latinEncoder(latinChars.join(' '))]; | ||
}; | ||
} | ||
@@ -20,0 +43,0 @@ return (text: string) => { |
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "./src/", | ||
"baseUrl": ".", | ||
"outDir": "./dist/", | ||
@@ -6,0 +6,0 @@ "noEmit": false |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
443825
178
7085
2