@cspell/cspell-types 6.1.2 → 6.1.3-alpha.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.
@@ -1,5 +1,6 @@
1
1
  import type { DictionaryInformation } from './DictionaryInformation';
2
2
  import type { Features } from './features';
3
+ import { Parser, ParserName } from './Parser';
3
4
  export declare type ReplaceEntry = [string, string];
4
5
  export declare type ReplaceMap = ReplaceEntry[];
5
6
  /**
@@ -24,7 +25,7 @@ export interface CSpellSettingsWithSourceTrace extends CSpellSettings {
24
25
  __importRef?: ImportFileRef;
25
26
  __imports?: Map<string, ImportFileRef>;
26
27
  }
27
- export interface FileSettings extends ExtendableSettings, CommandLineSettings {
28
+ export interface FileSettings extends ExtendableSettings, CommandLineSettings, ExperimentalFileSettings {
28
29
  /**
29
30
  * Configuration format version of the settings file.
30
31
  *
@@ -347,7 +348,7 @@ export interface OverrideFilterFields {
347
348
  /** Glob pattern or patterns to match against. */
348
349
  filename: Glob | Glob[];
349
350
  }
350
- export interface BaseSetting {
351
+ export interface BaseSetting extends ExperimentalBaseSettings {
351
352
  /** Optional identifier. */
352
353
  id?: string;
353
354
  /** Optional name of configuration. */
@@ -802,5 +803,43 @@ interface BaseSource {
802
803
  * Reporter name or reporter name + reporter config.
803
804
  */
804
805
  export declare type ReporterSettings = string | [string] | [string, unknown];
806
+ /**
807
+ * Experimental Configuration / Options
808
+ *
809
+ * This Configuration is subject to change without warning.
810
+ * @experimental
811
+ * @hidden
812
+ */
813
+ export interface ExperimentalFileSettings {
814
+ /**
815
+ * Future Plugin support
816
+ * @experimental
817
+ * @version 6.2.0
818
+ */
819
+ plugins?: Plugin[] | undefined;
820
+ }
821
+ /**
822
+ * Experimental Configuration / Options
823
+ *
824
+ * This Configuration is subject to change without warning.
825
+ * @experimental
826
+ * @hidden
827
+ */
828
+ export interface ExperimentalBaseSettings {
829
+ /**
830
+ * Parser to use for the file content
831
+ * @experimental
832
+ * @version 6.2.0
833
+ */
834
+ parser?: ParserName | Parser | undefined;
835
+ }
836
+ /**
837
+ * Plugin API
838
+ * @experimental
839
+ * @version 6.2.0
840
+ */
841
+ export interface Plugin {
842
+ parsers?: Parser[] | undefined;
843
+ }
805
844
  export {};
806
845
  //# sourceMappingURL=CSpellSettingsDef.d.ts.map
@@ -0,0 +1,122 @@
1
+ export declare type ParserOptions = Record<string, unknown>;
2
+ export declare type ParserName = string;
3
+ export interface Parser {
4
+ /** Name of parser */
5
+ name: ParserName;
6
+ /**
7
+ * Parse Method
8
+ * @param content - full content of the file
9
+ * @param filename - filename
10
+ */
11
+ parse(content: string, filename: string): ParseResult;
12
+ }
13
+ export interface ParseResult {
14
+ content: string;
15
+ filename: string;
16
+ parsedTexts: Iterable<ParsedText>;
17
+ }
18
+ export interface ParsedText {
19
+ /**
20
+ * The text extracted and possibly transformed
21
+ */
22
+ text: string;
23
+ /**
24
+ * start and end offsets of the text
25
+ */
26
+ range: Range;
27
+ /**
28
+ * The Scope annotation for a segment of text.
29
+ * Used by the spell checker to apply spell checking options
30
+ * based upon the value of the scope.
31
+ */
32
+ scope?: Scope | undefined;
33
+ /**
34
+ * The source map is used to support text transformations.
35
+ *
36
+ * See: {@link SourceMap}
37
+ */
38
+ map?: SourceMap | undefined;
39
+ /**
40
+ * Used to delegate parsing the contents of `text` to another parser.
41
+ *
42
+ */
43
+ delegate?: DelegateInfo | undefined;
44
+ }
45
+ /**
46
+ * A SourceMap is used to map transform a piece of text back to its original text.
47
+ * This is necessary in order to report the correct location of a spelling issue.
48
+ * An empty source map indicates that it was a 1:1 transformation.
49
+ *
50
+ * The values in a source map are number pairs (even, odd) relative to the beginning of each
51
+ * string segment.
52
+ * - even - offset in the source text
53
+ * - odd - offset in the transformed text
54
+ *
55
+ * Offsets start a 0
56
+ *
57
+ * Example:
58
+ *
59
+ * - Original text: `Grand Caf\u00e9 Bj\u00f8rvika`
60
+ * - Transformed text: `Grand Café Bjørvika`
61
+ * - Map: [9, 9, 15, 10, 18, 13, 24, 14]
62
+ *
63
+ * | offset | original | offset | transformed |
64
+ * | ------ | ----------- | ------ | ----------- |
65
+ * | 0-9 | `Grand Caf` | 0-9 | `Grand Caf` |
66
+ * | 9-15 | `\u00e9` | 9-10 | `é` |
67
+ * | 15-18 | ` Bj` | 10-13 | ` Bj` |
68
+ * | 18-24 | `\u00f8` | 13-14 | `ø` |
69
+ * | 24-29 | `rvika` | 14-19 | `rvika` |
70
+ *
71
+ * <!--- cspell:ignore Bjørvika rvika --->
72
+ */
73
+ export declare type SourceMap = number[];
74
+ export declare type Range = readonly [start: number, end: number];
75
+ /**
76
+ * DelegateInfo is used by a parser to delegate parsing a subsection of a document to
77
+ * another parser. The following information is used by the spell checker to match
78
+ * the parser.
79
+ */
80
+ export interface DelegateInfo {
81
+ /**
82
+ * Proposed virtual file name including the extension.
83
+ * Format: `./${source_filename}/${block_number}.${ext}
84
+ * Example: `./README.md/1.js`
85
+ */
86
+ filename: string;
87
+ /**
88
+ * The filename of the origin of the virtual file block.
89
+ * Example: `./README.md`
90
+ */
91
+ originFilename: string;
92
+ /**
93
+ * Proposed file extension
94
+ * Example: `.js`
95
+ */
96
+ extension: string;
97
+ /**
98
+ * Filetype to use
99
+ * Example: `javascript`
100
+ */
101
+ fileType: string;
102
+ }
103
+ /**
104
+ * Scope - chain of scope going from local to global
105
+ *
106
+ * Example:
107
+ * ```
108
+ * `comment.block.documentation.ts` -> `meta.interface.ts` -> `source.ts`
109
+ * ```
110
+ */
111
+ export interface ScopeChain {
112
+ readonly value: string;
113
+ readonly parent?: ScopeChain | undefined;
114
+ }
115
+ /**
116
+ * A string representing a scope chain separated by spaces
117
+ *
118
+ * Example: `comment.block.documentation.ts meta.interface.ts source.ts`
119
+ */
120
+ export declare type ScopeString = string;
121
+ export declare type Scope = ScopeChain | ScopeString;
122
+ //# sourceMappingURL=Parser.d.ts.map
package/dist/Parser.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Parser.js.map
@@ -47,6 +47,9 @@ exports.ConfigFields = {
47
47
  usePnP: 'usePnP',
48
48
  userWords: 'userWords',
49
49
  words: 'words',
50
+ // Experimental
51
+ parser: 'parser',
52
+ plugins: 'plugins',
50
53
  };
51
54
  // export const ConfigKeysNames = Object.values(ConfigKeysByField);
52
55
  //# sourceMappingURL=configFields.js.map
package/dist/index.d.ts CHANGED
@@ -6,4 +6,5 @@ export type { CharacterSet, CharacterSetCosts, DictionaryInformation, EditCosts
6
6
  export type { Feature, Features } from './features';
7
7
  export type { SuggestionCostMapDef, SuggestionCostsDefs } from './suggestionCostsDef';
8
8
  export type { TextDocumentOffset, TextOffset } from './TextOffset';
9
+ export type { ParseResult, ParsedText, Parser, ParserName, ParserOptions } from './Parser';
9
10
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -3,12 +3,28 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "6.1.2",
6
+ "version": "6.1.3-alpha.0",
7
7
  "description": "Types for cspell and cspell-lib",
8
+ "type": "commonjs",
8
9
  "main": "dist/index.js",
9
10
  "typings": "dist/index.d.ts",
11
+ "typesVersions": {
12
+ "*": {
13
+ "*": [
14
+ "dist/*"
15
+ ],
16
+ "dist/index.d.ts": [
17
+ "dist/index.d.ts"
18
+ ],
19
+ "index.d.ts": [
20
+ "dist/index.d.ts"
21
+ ]
22
+ }
23
+ },
10
24
  "exports": {
11
25
  ".": "./dist/index.js",
26
+ "./Parser": "./dist/Parser.js",
27
+ "./Parser.js": "./dist/Parser.js",
12
28
  "./cspell.schema.json": "./cspell.schema.json",
13
29
  "./ajv.config": "./ajv.config.js",
14
30
  "./ajv.config.js": "./ajv.config.js"
@@ -53,5 +69,5 @@
53
69
  "ts-json-schema-generator": "^1.0.0",
54
70
  "typescript": "^4.7.3"
55
71
  },
56
- "gitHead": "5ef579108a81bf7206cf53e301374467a3bbde06"
72
+ "gitHead": "b3cde7e463fd8a6f2c03f990adc70b913239baeb"
57
73
  }