@cspell/cspell-types 6.19.2 → 6.20.1

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.
Files changed (62) hide show
  1. package/{ajv.config.js → ajv.config.cjs} +0 -0
  2. package/dist/{CSpellReporter.d.ts → cjs/CSpellReporter.d.ts} +1 -1
  3. package/dist/{CSpellSettingsDef.d.ts → cjs/CSpellSettingsDef.d.ts} +4 -4
  4. package/dist/{DictionaryDefinition.d.ts → cjs/DictionaryDefinition.d.ts} +1 -1
  5. package/dist/{DictionaryInformation.d.ts → cjs/DictionaryInformation.d.ts} +1 -1
  6. package/dist/cjs/Parser/CSpellReporter.d.ts +103 -0
  7. package/dist/cjs/Parser/CSpellSettingsDef.d.ts +689 -0
  8. package/dist/cjs/Parser/DictionaryDefinition.d.ts +184 -0
  9. package/dist/cjs/Parser/DictionaryInformation.d.ts +210 -0
  10. package/dist/{Parser.d.ts → cjs/Parser/Parser/index.d.ts} +1 -1
  11. package/dist/{TextMap.d.ts → cjs/Parser/TextMap.d.ts} +0 -0
  12. package/dist/{TextOffset.d.ts → cjs/Parser/TextOffset.d.ts} +0 -0
  13. package/dist/{configFields.d.ts → cjs/Parser/configFields.d.ts} +1 -1
  14. package/dist/{features.d.ts → cjs/Parser/features.d.ts} +0 -0
  15. package/dist/cjs/Parser/index.cjs +3 -0
  16. package/dist/{index.d.ts → cjs/Parser/index.d.ts} +12 -12
  17. package/dist/{suggestionCostsDef.d.ts → cjs/Parser/suggestionCostsDef.d.ts} +0 -0
  18. package/dist/{types.d.ts → cjs/Parser/types.d.ts} +0 -0
  19. package/dist/cjs/TextMap.d.ts +36 -0
  20. package/dist/cjs/TextOffset.d.ts +23 -0
  21. package/dist/cjs/configFields.d.ts +7 -0
  22. package/dist/cjs/features.d.ts +38 -0
  23. package/dist/cjs/index.cjs +68 -0
  24. package/dist/cjs/index.d.ts +13 -0
  25. package/dist/cjs/suggestionCostsDef.d.ts +88 -0
  26. package/dist/cjs/types.d.ts +9 -0
  27. package/dist/esm/CSpellReporter.d.ts +103 -0
  28. package/dist/esm/CSpellReporter.js +11 -0
  29. package/dist/esm/CSpellSettingsDef.d.ts +689 -0
  30. package/dist/esm/CSpellSettingsDef.js +2 -0
  31. package/dist/esm/DictionaryDefinition.d.ts +184 -0
  32. package/dist/esm/DictionaryDefinition.js +2 -0
  33. package/dist/esm/DictionaryInformation.d.ts +210 -0
  34. package/dist/esm/DictionaryInformation.js +2 -0
  35. package/dist/esm/Parser/index.d.ts +126 -0
  36. package/dist/esm/Parser/index.js +2 -0
  37. package/dist/esm/TextMap.d.ts +36 -0
  38. package/dist/esm/TextMap.js +2 -0
  39. package/dist/esm/TextOffset.d.ts +23 -0
  40. package/dist/esm/TextOffset.js +2 -0
  41. package/dist/esm/configFields.d.ts +7 -0
  42. package/dist/{configFields.js → esm/configFields.js} +1 -4
  43. package/dist/esm/features.d.ts +38 -0
  44. package/dist/esm/features.js +3 -0
  45. package/dist/esm/index.d.ts +13 -0
  46. package/dist/esm/index.js +3 -0
  47. package/dist/esm/suggestionCostsDef.d.ts +88 -0
  48. package/dist/esm/suggestionCostsDef.js +2 -0
  49. package/dist/esm/types.d.ts +9 -0
  50. package/dist/esm/types.js +4 -0
  51. package/package.json +53 -27
  52. package/dist/CSpellReporter.js +0 -14
  53. package/dist/CSpellSettingsDef.js +0 -3
  54. package/dist/DictionaryDefinition.js +0 -3
  55. package/dist/DictionaryInformation.js +0 -3
  56. package/dist/Parser.js +0 -3
  57. package/dist/TextMap.js +0 -3
  58. package/dist/TextOffset.js +0 -3
  59. package/dist/features.js +0 -4
  60. package/dist/index.js +0 -9
  61. package/dist/suggestionCostsDef.js +0 -3
  62. package/dist/types.js +0 -5
@@ -0,0 +1,88 @@
1
+ /**
2
+ * A WeightedMapDef enables setting weights for edits between related characters and substrings.
3
+ *
4
+ * Multiple groups can be defined using a `|`.
5
+ * A multi-character substring is defined using `()`.
6
+ *
7
+ * For example, in some languages, some letters sound alike.
8
+ *
9
+ * ```yaml
10
+ * map: 'sc(sh)(sch)(ss)|t(tt)' # two groups.
11
+ * replace: 50 # Make it 1/2 the cost of a normal edit to replace a `t` with `tt`.
12
+ * ```
13
+ *
14
+ * The following could be used to make inserting, removing, or replacing vowels cheaper.
15
+ * ```yaml
16
+ * map: 'aeiouy'
17
+ * insDel: 50 # Make it is cheaper to insert or delete a vowel.
18
+ * replace: 45 # It is even cheaper to replace one with another.
19
+ * ```
20
+ *
21
+ * Note: the default edit distance is 100.
22
+ */
23
+ export type SuggestionCostMapDef = CostMapDefReplace | CostMapDefInsDel | CostMapDefSwap;
24
+ export type SuggestionCostsDefs = SuggestionCostMapDef[];
25
+ interface CostMapDefBase {
26
+ /**
27
+ * The set of substrings to map, these are generally single character strings.
28
+ *
29
+ * Multiple sets can be defined by using a `|` to separate them.
30
+ *
31
+ * Example: `"eéê|aåá"` contains two different sets.
32
+ *
33
+ * To add a multi-character substring use `()`.
34
+ *
35
+ * Example: `"f(ph)(gh)"` results in the following set: `f`, `ph`, `gh`.
36
+ *
37
+ * - To match the beginning of a word, use `^`: `"(^I)""`.
38
+ * - To match the end of a word, use `$`: `"(e$)(ing$)"`.
39
+ *
40
+ */
41
+ map: string;
42
+ /** The cost to insert/delete one of the substrings in the map. Note: insert/delete costs are symmetrical. */
43
+ insDel?: number;
44
+ /**
45
+ * The cost to replace of of the substrings in the map with another substring in the map.
46
+ * Example: Map['a', 'i']
47
+ * This would be the cost to substitute `a` with `i`: Like `bat` to `bit` or the reverse.
48
+ */
49
+ replace?: number;
50
+ /**
51
+ * The cost to swap two adjacent substrings found in the map.
52
+ * Example: Map['e', 'i']
53
+ * This represents the cost to change `ei` to `ie` or the reverse.
54
+ */
55
+ swap?: number;
56
+ /**
57
+ * A description to describe the purpose of the map.
58
+ */
59
+ description?: string;
60
+ /**
61
+ * Add a penalty to the final cost.
62
+ * This is used to discourage certain suggestions.
63
+ *
64
+ * Example:
65
+ * ```yaml
66
+ * # Match adding/removing `-` to the end of a word.
67
+ * map: "$(-$)"
68
+ * replace: 50
69
+ * penalty: 100
70
+ * ```
71
+ *
72
+ * This makes adding a `-` to the end of a word more expensive.
73
+ *
74
+ * Think of it as taking the toll way for speed but getting the bill later.
75
+ */
76
+ penalty?: number;
77
+ }
78
+ export interface CostMapDefReplace extends CostMapDefBase {
79
+ replace: number;
80
+ }
81
+ export interface CostMapDefInsDel extends CostMapDefBase {
82
+ insDel: number;
83
+ }
84
+ export interface CostMapDefSwap extends CostMapDefBase {
85
+ swap: number;
86
+ }
87
+ export {};
88
+ //# sourceMappingURL=suggestionCostsDef.d.ts.map
@@ -0,0 +1,9 @@
1
+ export type Serialize<T> = T extends Function ? never : T extends null ? null : T extends any[] ? SerializeArray<T> : T extends object ? SerializeObj<T> : Primitives<T>;
2
+ type SerializeObj<T extends object> = {
3
+ [K in keyof T]: K extends string | number ? Serialize<T[K]> : never;
4
+ };
5
+ type SerializeArray<T extends Array<any>> = T extends [infer R] ? [Serialize<R>] : T extends [infer R0, infer R1] ? [Serialize<R0>, Serialize<R1>] : T extends [infer R0, infer R1, infer R2] ? [Serialize<R0>, Serialize<R1>, Serialize<R2>] : T extends Array<infer R> ? Serialize<R>[] : never;
6
+ type Primitives<T> = Extract<T, number | string | null | boolean>;
7
+ export type Serializable = number | string | boolean | null | object;
8
+ export {};
9
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,103 @@
1
+ import type { TextDocumentOffset, TextOffset } from './TextOffset.js';
2
+ export interface Suggestion {
3
+ /**
4
+ * Word to suggest.
5
+ */
6
+ word: string;
7
+ /**
8
+ * `true` - if this suggestion can be an automatic fix.
9
+ */
10
+ isPreferred?: boolean;
11
+ }
12
+ export interface Issue extends Omit<TextDocumentOffset, 'doc'> {
13
+ /** text surrounding the issue text */
14
+ context: TextOffset;
15
+ /**
16
+ * true if the issue has been flagged as a forbidden word.
17
+ */
18
+ isFlagged?: boolean;
19
+ /**
20
+ * An optional array of replacement strings.
21
+ */
22
+ suggestions?: string[];
23
+ /**
24
+ * An optional array of suggestions.
25
+ */
26
+ suggestionsEx?: Suggestion[];
27
+ /**
28
+ * Issues are spelling issues unless otherwise specified.
29
+ */
30
+ issueType?: IssueType;
31
+ /**
32
+ * Optional message to show.
33
+ */
34
+ message?: string;
35
+ }
36
+ export declare enum IssueType {
37
+ spelling = 0,
38
+ directive = 1
39
+ }
40
+ export type MessageType = 'Debug' | 'Info' | 'Warning';
41
+ export type MessageTypeLookup = {
42
+ [key in MessageType]: key;
43
+ };
44
+ export declare const MessageTypes: MessageTypeLookup;
45
+ export type MessageEmitter = (message: string, msgType: MessageType) => void;
46
+ export type DebugEmitter = (message: string) => void;
47
+ export type ErrorLike = Error | {
48
+ message: string;
49
+ name: string;
50
+ toString: () => string;
51
+ };
52
+ export type ErrorEmitter = (message: string, error: ErrorLike) => void;
53
+ export type SpellingErrorEmitter = (issue: Issue) => void;
54
+ export type ProgressTypes = 'ProgressFileBegin' | 'ProgressFileComplete';
55
+ export type ProgressItem = ProgressFileBegin | ProgressFileComplete;
56
+ export interface ProgressBase {
57
+ type: ProgressTypes;
58
+ }
59
+ export interface ProgressFileBase extends ProgressBase {
60
+ type: ProgressTypes;
61
+ fileNum: number;
62
+ fileCount: number;
63
+ filename: string;
64
+ }
65
+ export interface ProgressFileComplete extends ProgressFileBase {
66
+ type: 'ProgressFileComplete';
67
+ elapsedTimeMs: number | undefined;
68
+ processed: boolean | undefined;
69
+ numErrors: number | undefined;
70
+ cached?: boolean;
71
+ }
72
+ /**
73
+ * Notification sent just before processing a file.
74
+ */
75
+ export interface ProgressFileBegin extends ProgressFileBase {
76
+ type: 'ProgressFileBegin';
77
+ }
78
+ export type ProgressEmitter = (p: ProgressItem | ProgressFileComplete) => void;
79
+ export interface RunResult {
80
+ /** Number of files processed. */
81
+ files: number;
82
+ /** Set of files where issues were found. */
83
+ filesWithIssues: Set<string>;
84
+ /** Number of issues found. */
85
+ issues: number;
86
+ /** Number of processing errors. */
87
+ errors: number;
88
+ /** Number files that used results from the cache. */
89
+ cachedFiles?: number;
90
+ }
91
+ export type ResultEmitter = (result: RunResult) => void | Promise<void>;
92
+ export interface CSpellReporter {
93
+ issue: SpellingErrorEmitter;
94
+ info: MessageEmitter;
95
+ debug: DebugEmitter;
96
+ error: ErrorEmitter;
97
+ progress: ProgressEmitter;
98
+ result: ResultEmitter;
99
+ }
100
+ export interface CSpellReporterModule {
101
+ getReporter: (settings: unknown) => CSpellReporter;
102
+ }
103
+ //# sourceMappingURL=CSpellReporter.d.ts.map
@@ -0,0 +1,11 @@
1
+ export var IssueType;
2
+ (function (IssueType) {
3
+ IssueType[IssueType["spelling"] = 0] = "spelling";
4
+ IssueType[IssueType["directive"] = 1] = "directive";
5
+ })(IssueType = IssueType || (IssueType = {}));
6
+ export const MessageTypes = {
7
+ Debug: 'Debug',
8
+ Info: 'Info',
9
+ Warning: 'Warning',
10
+ };
11
+ //# sourceMappingURL=CSpellReporter.js.map