fixnow 1.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.
@@ -0,0 +1,107 @@
1
+ declare const SUPPORTED_LANGUAGES: readonly ["ar", "de", "es", "fr", "vi"];
2
+ type LanguageCode = (typeof SUPPORTED_LANGUAGES)[number];
3
+ interface LanguageInfo {
4
+ /** ISO 639-1 code used everywhere in the public API. */
5
+ code: LanguageCode;
6
+ /** Human-readable language name. */
7
+ name: string;
8
+ /** Gzipped trie file shipped under `dictionaries/<code>/`. */
9
+ trie: string;
10
+ /** SPDX identifier of the bundled dictionary data. */
11
+ license: string;
12
+ /** Enable cspell's compound-word matching (needed for German). */
13
+ compound?: boolean;
14
+ }
15
+ declare const LANGUAGES: Record<LanguageCode, LanguageInfo>;
16
+ declare function isSupportedLanguage(code: string): code is LanguageCode;
17
+
18
+ interface SpellIssue {
19
+ /** Character offset of the word in the checked text. */
20
+ offset: number;
21
+ /** Length of the flagged word. */
22
+ length: number;
23
+ /** The flagged word, exactly as it appeared. */
24
+ word: string;
25
+ /** Correction candidates, present only when `suggestions` is requested. */
26
+ suggestions?: string[];
27
+ }
28
+ interface CheckOptions {
29
+ /** Dictionary to check against. Defaults to `'es'`. */
30
+ language?: LanguageCode;
31
+ /**
32
+ * Spanish only: when true, accent omissions (e.g. "codigo" for "código") are
33
+ * flagged. When false (default) they are accepted as harmless.
34
+ */
35
+ strict?: boolean;
36
+ /** Attach correction suggestions to every issue. Defaults to false. */
37
+ suggestions?: boolean;
38
+ /** Maximum suggestions per issue. Defaults to 5. */
39
+ maxSuggestions?: number;
40
+ /** Words shorter than this are never flagged. Defaults to 3. */
41
+ minWordLength?: number;
42
+ /** Words to always accept (case-insensitive), e.g. an app-specific allowlist. */
43
+ ignoreWords?: Iterable<string>;
44
+ /**
45
+ * Words to always flag as misspelled (case-insensitive), even when the
46
+ * dictionary contains them — e.g. your own list of common personal typos.
47
+ * Applies unless the word is also in `ignoreWords` / `isProtectedWord`.
48
+ */
49
+ flagWords?: Iterable<string>;
50
+ /** Custom predicate to skip a word before it is checked (e.g. protected terms). */
51
+ isProtectedWord?: (word: string) => boolean;
52
+ }
53
+ /** A loaded, decoded dictionary. Membership and suggestion lookups are synchronous. */
54
+ interface Dictionary {
55
+ /** True when the word is in the dictionary (compound-aware for German). */
56
+ has(word: string): boolean;
57
+ /** Correction candidates ordered best-first. */
58
+ suggest(word: string, max?: number): string[];
59
+ }
60
+
61
+ /** Finds misspelled words in `text` for the given language. */
62
+ declare function checkText(text: string, options?: CheckOptions): Promise<SpellIssue[]>;
63
+ /** Whether a single word is correctly spelled in the given language. */
64
+ declare function isCorrect(word: string, language?: LanguageCode, strict?: boolean): Promise<boolean>;
65
+
66
+ /** Loads and decodes a language dictionary, caching the result. */
67
+ declare function loadDictionary(language: LanguageCode): Promise<Dictionary>;
68
+ /**
69
+ * Pre-loads dictionaries so the first check isn't slowed by trie decoding.
70
+ * Pass nothing to warm every supported language.
71
+ */
72
+ declare function warmup(language?: LanguageCode | LanguageCode[]): Promise<void>;
73
+
74
+ interface Token {
75
+ word: string;
76
+ offset: number;
77
+ }
78
+ /**
79
+ * Yields candidate words from `text`, skipping anything inside a protected
80
+ * segment (code, URLs, paths, acronyms, …).
81
+ */
82
+ declare function tokenize(text: string): Generator<Token>;
83
+
84
+ /** A checker bound to a single language, for convenient repeated use. */
85
+ interface BoundChecker {
86
+ readonly language: LanguageCode;
87
+ check(text: string, options?: Omit<CheckOptions, 'language'>): Promise<SpellIssue[]>;
88
+ suggest(word: string, max?: number): Promise<string[]>;
89
+ isCorrect(word: string, strict?: boolean): Promise<boolean>;
90
+ warmup(): Promise<void>;
91
+ }
92
+ /**
93
+ * Creates a checker locked to one language.
94
+ *
95
+ * ```ts
96
+ * const es = createChecker('es');
97
+ * const issues = await es.check('Este texto tiene un herror', { suggestions: true });
98
+ * ```
99
+ */
100
+ declare function createChecker(language: LanguageCode): BoundChecker;
101
+ /** Correction suggestions for a single word. */
102
+ declare function suggest(word: string, options?: {
103
+ language?: LanguageCode;
104
+ max?: number;
105
+ }): Promise<string[]>;
106
+
107
+ export { type BoundChecker, type CheckOptions, type Dictionary, LANGUAGES, type LanguageCode, type LanguageInfo, SUPPORTED_LANGUAGES, type SpellIssue, checkText, createChecker, isCorrect, isSupportedLanguage, loadDictionary, suggest, tokenize, warmup };
@@ -0,0 +1,107 @@
1
+ declare const SUPPORTED_LANGUAGES: readonly ["ar", "de", "es", "fr", "vi"];
2
+ type LanguageCode = (typeof SUPPORTED_LANGUAGES)[number];
3
+ interface LanguageInfo {
4
+ /** ISO 639-1 code used everywhere in the public API. */
5
+ code: LanguageCode;
6
+ /** Human-readable language name. */
7
+ name: string;
8
+ /** Gzipped trie file shipped under `dictionaries/<code>/`. */
9
+ trie: string;
10
+ /** SPDX identifier of the bundled dictionary data. */
11
+ license: string;
12
+ /** Enable cspell's compound-word matching (needed for German). */
13
+ compound?: boolean;
14
+ }
15
+ declare const LANGUAGES: Record<LanguageCode, LanguageInfo>;
16
+ declare function isSupportedLanguage(code: string): code is LanguageCode;
17
+
18
+ interface SpellIssue {
19
+ /** Character offset of the word in the checked text. */
20
+ offset: number;
21
+ /** Length of the flagged word. */
22
+ length: number;
23
+ /** The flagged word, exactly as it appeared. */
24
+ word: string;
25
+ /** Correction candidates, present only when `suggestions` is requested. */
26
+ suggestions?: string[];
27
+ }
28
+ interface CheckOptions {
29
+ /** Dictionary to check against. Defaults to `'es'`. */
30
+ language?: LanguageCode;
31
+ /**
32
+ * Spanish only: when true, accent omissions (e.g. "codigo" for "código") are
33
+ * flagged. When false (default) they are accepted as harmless.
34
+ */
35
+ strict?: boolean;
36
+ /** Attach correction suggestions to every issue. Defaults to false. */
37
+ suggestions?: boolean;
38
+ /** Maximum suggestions per issue. Defaults to 5. */
39
+ maxSuggestions?: number;
40
+ /** Words shorter than this are never flagged. Defaults to 3. */
41
+ minWordLength?: number;
42
+ /** Words to always accept (case-insensitive), e.g. an app-specific allowlist. */
43
+ ignoreWords?: Iterable<string>;
44
+ /**
45
+ * Words to always flag as misspelled (case-insensitive), even when the
46
+ * dictionary contains them — e.g. your own list of common personal typos.
47
+ * Applies unless the word is also in `ignoreWords` / `isProtectedWord`.
48
+ */
49
+ flagWords?: Iterable<string>;
50
+ /** Custom predicate to skip a word before it is checked (e.g. protected terms). */
51
+ isProtectedWord?: (word: string) => boolean;
52
+ }
53
+ /** A loaded, decoded dictionary. Membership and suggestion lookups are synchronous. */
54
+ interface Dictionary {
55
+ /** True when the word is in the dictionary (compound-aware for German). */
56
+ has(word: string): boolean;
57
+ /** Correction candidates ordered best-first. */
58
+ suggest(word: string, max?: number): string[];
59
+ }
60
+
61
+ /** Finds misspelled words in `text` for the given language. */
62
+ declare function checkText(text: string, options?: CheckOptions): Promise<SpellIssue[]>;
63
+ /** Whether a single word is correctly spelled in the given language. */
64
+ declare function isCorrect(word: string, language?: LanguageCode, strict?: boolean): Promise<boolean>;
65
+
66
+ /** Loads and decodes a language dictionary, caching the result. */
67
+ declare function loadDictionary(language: LanguageCode): Promise<Dictionary>;
68
+ /**
69
+ * Pre-loads dictionaries so the first check isn't slowed by trie decoding.
70
+ * Pass nothing to warm every supported language.
71
+ */
72
+ declare function warmup(language?: LanguageCode | LanguageCode[]): Promise<void>;
73
+
74
+ interface Token {
75
+ word: string;
76
+ offset: number;
77
+ }
78
+ /**
79
+ * Yields candidate words from `text`, skipping anything inside a protected
80
+ * segment (code, URLs, paths, acronyms, …).
81
+ */
82
+ declare function tokenize(text: string): Generator<Token>;
83
+
84
+ /** A checker bound to a single language, for convenient repeated use. */
85
+ interface BoundChecker {
86
+ readonly language: LanguageCode;
87
+ check(text: string, options?: Omit<CheckOptions, 'language'>): Promise<SpellIssue[]>;
88
+ suggest(word: string, max?: number): Promise<string[]>;
89
+ isCorrect(word: string, strict?: boolean): Promise<boolean>;
90
+ warmup(): Promise<void>;
91
+ }
92
+ /**
93
+ * Creates a checker locked to one language.
94
+ *
95
+ * ```ts
96
+ * const es = createChecker('es');
97
+ * const issues = await es.check('Este texto tiene un herror', { suggestions: true });
98
+ * ```
99
+ */
100
+ declare function createChecker(language: LanguageCode): BoundChecker;
101
+ /** Correction suggestions for a single word. */
102
+ declare function suggest(word: string, options?: {
103
+ language?: LanguageCode;
104
+ max?: number;
105
+ }): Promise<string[]>;
106
+
107
+ export { type BoundChecker, type CheckOptions, type Dictionary, LANGUAGES, type LanguageCode, type LanguageInfo, SUPPORTED_LANGUAGES, type SpellIssue, checkText, createChecker, isCorrect, isSupportedLanguage, loadDictionary, suggest, tokenize, warmup };