@tslite/parser 1.10.0 → 1.13.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.
Files changed (47) hide show
  1. package/LICENSE +55 -0
  2. package/NOTICE +14 -0
  3. package/dist/_namespaces/ts.d.ts +18 -0
  4. package/dist/_namespaces/ts.js +21 -0
  5. package/dist/_namespaces/ts.performance.d.ts +1 -0
  6. package/dist/_namespaces/ts.performance.js +2 -0
  7. package/dist/core.d.ts +450 -0
  8. package/dist/core.js +1394 -0
  9. package/dist/corePublic.d.ts +62 -0
  10. package/dist/corePublic.js +31 -0
  11. package/dist/debug.d.ts +74 -0
  12. package/dist/debug.js +326 -0
  13. package/dist/diagnosticInformationMap.generated.d.ts +1435 -0
  14. package/dist/diagnosticInformationMap.generated.js +1441 -0
  15. package/dist/factory.d.ts +78 -0
  16. package/dist/factory.js +622 -0
  17. package/dist/factoryPublic.d.ts +314 -0
  18. package/dist/factoryPublic.js +1796 -0
  19. package/dist/index.d.ts +1 -249
  20. package/dist/index.js +4 -6
  21. package/dist/parser.d.ts +59 -0
  22. package/dist/parser.js +5075 -0
  23. package/dist/path.d.ts +312 -0
  24. package/dist/path.js +475 -0
  25. package/dist/perfLogger.d.ts +4 -0
  26. package/dist/perfLogger.js +38 -0
  27. package/dist/performance.d.ts +20 -0
  28. package/dist/performance.js +49 -0
  29. package/dist/performanceTimestamp.d.ts +2 -0
  30. package/dist/performanceTimestamp.js +2 -0
  31. package/dist/scanner.d.ts +80 -0
  32. package/dist/scanner.js +1984 -0
  33. package/dist/shims/mapShim.d.ts +23 -0
  34. package/dist/shims/mapShim.js +156 -0
  35. package/dist/types.d.ts +2626 -0
  36. package/dist/types.js +1074 -0
  37. package/dist/utilities.d.ts +473 -0
  38. package/dist/utilities.js +2632 -0
  39. package/dist/utilitiesPublic.d.ts +274 -0
  40. package/dist/utilitiesPublic.js +1049 -0
  41. package/dist/visitor.d.ts +15 -0
  42. package/dist/visitor.js +64 -0
  43. package/dist/visitorPublic.d.ts +82 -0
  44. package/dist/visitorPublic.js +352 -0
  45. package/package.json +14 -42
  46. package/dist/index.cjs +0 -6
  47. package/dist/index.d.cts +0 -249
package/dist/path.d.ts ADDED
@@ -0,0 +1,312 @@
1
+ import { Comparison } from "./_namespaces/ts.js";
2
+ import type { GetCanonicalFileName, Path } from "./_namespaces/ts.js";
3
+ /**
4
+ * Internally, we represent paths as strings with '/' as the directory separator.
5
+ * When we make system calls (eg: LanguageServiceHost.getDirectory()),
6
+ * we expect the host to correctly handle paths in our specified format.
7
+ */
8
+ export declare const directorySeparator = "/";
9
+ /**
10
+ * Determines whether a charCode corresponds to `/` or `\`.
11
+ */
12
+ export declare function isAnyDirectorySeparator(charCode: number): boolean;
13
+ /**
14
+ * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path
15
+ * like `c:`, `c:\` or `c:/`).
16
+ */
17
+ export declare function isRootedDiskPath(path: string): boolean;
18
+ /**
19
+ * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.).
20
+ *
21
+ * ```ts
22
+ * // POSIX
23
+ * pathIsAbsolute("/path/to/file.ext") === true
24
+ * // DOS
25
+ * pathIsAbsolute("c:/path/to/file.ext") === true
26
+ * // URL
27
+ * pathIsAbsolute("file:///path/to/file.ext") === true
28
+ * // Non-absolute
29
+ * pathIsAbsolute("path/to/file.ext") === false
30
+ * pathIsAbsolute("./path/to/file.ext") === false
31
+ * ```
32
+ */
33
+ export declare function pathIsAbsolute(path: string): boolean;
34
+ /**
35
+ * Determines whether a path starts with a relative path component (i.e. `.` or `..`).
36
+ */
37
+ export declare function pathIsRelative(path: string): boolean;
38
+ export declare function fileExtensionIs(path: string, extension: string): boolean;
39
+ /**
40
+ * Determines whether a path has a trailing separator (`/` or `\\`).
41
+ */
42
+ export declare function hasTrailingDirectorySeparator(path: string): boolean;
43
+ /**
44
+ * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
45
+ *
46
+ * For example:
47
+ * ```ts
48
+ * getRootLength("a") === 0 // ""
49
+ * getRootLength("/") === 1 // "/"
50
+ * getRootLength("c:") === 2 // "c:"
51
+ * getRootLength("c:d") === 0 // ""
52
+ * getRootLength("c:/") === 3 // "c:/"
53
+ * getRootLength("c:\\") === 3 // "c:\\"
54
+ * getRootLength("//server") === 7 // "//server"
55
+ * getRootLength("//server/share") === 8 // "//server/"
56
+ * getRootLength("\\\\server") === 7 // "\\\\server"
57
+ * getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
58
+ * getRootLength("file:///path") === 8 // "file:///"
59
+ * getRootLength("file:///c:") === 10 // "file:///c:"
60
+ * getRootLength("file:///c:d") === 8 // "file:///"
61
+ * getRootLength("file:///c:/path") === 11 // "file:///c:/"
62
+ * getRootLength("file://server") === 13 // "file://server"
63
+ * getRootLength("file://server/path") === 14 // "file://server/"
64
+ * getRootLength("http://server") === 13 // "http://server"
65
+ * getRootLength("http://server/path") === 14 // "http://server/"
66
+ * ```
67
+ */
68
+ export declare function getRootLength(path: string): number;
69
+ /**
70
+ * Returns the path except for its basename. Semantics align with NodeJS's `path.dirname`
71
+ * except that we support URLs as well.
72
+ *
73
+ * ```ts
74
+ * // POSIX
75
+ * getDirectoryPath("/path/to/file.ext") === "/path/to"
76
+ * getDirectoryPath("/path/to/") === "/path"
77
+ * getDirectoryPath("/") === "/"
78
+ * // DOS
79
+ * getDirectoryPath("c:/path/to/file.ext") === "c:/path/to"
80
+ * getDirectoryPath("c:/path/to/") === "c:/path"
81
+ * getDirectoryPath("c:/") === "c:/"
82
+ * getDirectoryPath("c:") === "c:"
83
+ * // URL
84
+ * getDirectoryPath("http://typescriptlang.org/path/to/file.ext") === "http://typescriptlang.org/path/to"
85
+ * getDirectoryPath("http://typescriptlang.org/path/to") === "http://typescriptlang.org/path"
86
+ * getDirectoryPath("http://typescriptlang.org/") === "http://typescriptlang.org/"
87
+ * getDirectoryPath("http://typescriptlang.org") === "http://typescriptlang.org"
88
+ * ```
89
+ */
90
+ export declare function getDirectoryPath(path: Path): Path;
91
+ /**
92
+ * Returns the path except for its basename. Semantics align with NodeJS's `path.dirname`
93
+ * except that we support URLs as well.
94
+ *
95
+ * ```ts
96
+ * // POSIX
97
+ * getDirectoryPath("/path/to/file.ext") === "/path/to"
98
+ * getDirectoryPath("/path/to/") === "/path"
99
+ * getDirectoryPath("/") === "/"
100
+ * // DOS
101
+ * getDirectoryPath("c:/path/to/file.ext") === "c:/path/to"
102
+ * getDirectoryPath("c:/path/to/") === "c:/path"
103
+ * getDirectoryPath("c:/") === "c:/"
104
+ * getDirectoryPath("c:") === "c:"
105
+ * // URL
106
+ * getDirectoryPath("http://typescriptlang.org/path/to/file.ext") === "http://typescriptlang.org/path/to"
107
+ * getDirectoryPath("http://typescriptlang.org/path/to") === "http://typescriptlang.org/path"
108
+ * getDirectoryPath("http://typescriptlang.org/") === "http://typescriptlang.org/"
109
+ * getDirectoryPath("http://typescriptlang.org") === "http://typescriptlang.org"
110
+ * getDirectoryPath("file://server/path/to/file.ext") === "file://server/path/to"
111
+ * getDirectoryPath("file://server/path/to") === "file://server/path"
112
+ * getDirectoryPath("file://server/") === "file://server/"
113
+ * getDirectoryPath("file://server") === "file://server"
114
+ * getDirectoryPath("file:///path/to/file.ext") === "file:///path/to"
115
+ * getDirectoryPath("file:///path/to") === "file:///path"
116
+ * getDirectoryPath("file:///") === "file:///"
117
+ * getDirectoryPath("file://") === "file://"
118
+ * ```
119
+ */
120
+ export declare function getDirectoryPath(path: string): string;
121
+ /**
122
+ * Returns the path except for its containing directory name.
123
+ * Semantics align with NodeJS's `path.basename` except that we support URL's as well.
124
+ *
125
+ * ```ts
126
+ * // POSIX
127
+ * getBaseFileName("/path/to/file.ext") === "file.ext"
128
+ * getBaseFileName("/path/to/") === "to"
129
+ * getBaseFileName("/") === ""
130
+ * // DOS
131
+ * getBaseFileName("c:/path/to/file.ext") === "file.ext"
132
+ * getBaseFileName("c:/path/to/") === "to"
133
+ * getBaseFileName("c:/") === ""
134
+ * getBaseFileName("c:") === ""
135
+ * // URL
136
+ * getBaseFileName("http://typescriptlang.org/path/to/file.ext") === "file.ext"
137
+ * getBaseFileName("http://typescriptlang.org/path/to/") === "to"
138
+ * getBaseFileName("http://typescriptlang.org/") === ""
139
+ * getBaseFileName("http://typescriptlang.org") === ""
140
+ * getBaseFileName("file://server/path/to/file.ext") === "file.ext"
141
+ * getBaseFileName("file://server/path/to/") === "to"
142
+ * getBaseFileName("file://server/") === ""
143
+ * getBaseFileName("file://server") === ""
144
+ * getBaseFileName("file:///path/to/file.ext") === "file.ext"
145
+ * getBaseFileName("file:///path/to/") === "to"
146
+ * getBaseFileName("file:///") === ""
147
+ * getBaseFileName("file://") === ""
148
+ * ```
149
+ */
150
+ export declare function getBaseFileName(path: string): string;
151
+ /**
152
+ * Gets the portion of a path following the last (non-terminal) separator (`/`).
153
+ * Semantics align with NodeJS's `path.basename` except that we support URL's as well.
154
+ * If the base name has any one of the provided extensions, it is removed.
155
+ *
156
+ * ```ts
157
+ * getBaseFileName("/path/to/file.ext", ".ext", true) === "file"
158
+ * getBaseFileName("/path/to/file.js", ".ext", true) === "file.js"
159
+ * getBaseFileName("/path/to/file.js", [".ext", ".js"], true) === "file"
160
+ * getBaseFileName("/path/to/file.ext", ".EXT", false) === "file.ext"
161
+ * ```
162
+ */
163
+ export declare function getBaseFileName(path: string, extensions: string | readonly string[], ignoreCase: boolean): string;
164
+ /**
165
+ * Gets the file extension for a path.
166
+ *
167
+ * ```ts
168
+ * getAnyExtensionFromPath("/path/to/file.ext") === ".ext"
169
+ * getAnyExtensionFromPath("/path/to/file.ext/") === ".ext"
170
+ * getAnyExtensionFromPath("/path/to/file") === ""
171
+ * getAnyExtensionFromPath("/path/to.ext/file") === ""
172
+ * ```
173
+ */
174
+ export declare function getAnyExtensionFromPath(path: string): string;
175
+ /**
176
+ * Gets the file extension for a path, provided it is one of the provided extensions.
177
+ *
178
+ * ```ts
179
+ * getAnyExtensionFromPath("/path/to/file.ext", ".ext", true) === ".ext"
180
+ * getAnyExtensionFromPath("/path/to/file.js", ".ext", true) === ""
181
+ * getAnyExtensionFromPath("/path/to/file.js", [".ext", ".js"], true) === ".js"
182
+ * getAnyExtensionFromPath("/path/to/file.ext", ".EXT", false) === ""
183
+ */
184
+ export declare function getAnyExtensionFromPath(path: string, extensions: string | readonly string[], ignoreCase: boolean): string;
185
+ /**
186
+ * Parse a path into an array containing a root component (at index 0) and zero or more path
187
+ * components (at indices > 0). The result is not normalized.
188
+ * If the path is relative, the root component is `""`.
189
+ * If the path is absolute, the root component includes the first path separator (`/`).
190
+ *
191
+ * ```ts
192
+ * // POSIX
193
+ * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"]
194
+ * getPathComponents("/path/to/") === ["/", "path", "to"]
195
+ * getPathComponents("/") === ["/"]
196
+ * // DOS
197
+ * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"]
198
+ * getPathComponents("c:/path/to/") === ["c:/", "path", "to"]
199
+ * getPathComponents("c:/") === ["c:/"]
200
+ * getPathComponents("c:") === ["c:"]
201
+ * // URL
202
+ * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"]
203
+ * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"]
204
+ * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"]
205
+ * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"]
206
+ * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"]
207
+ * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"]
208
+ * getPathComponents("file://server/") === ["file://server/"]
209
+ * getPathComponents("file://server") === ["file://server"]
210
+ * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"]
211
+ * getPathComponents("file:///path/to/") === ["file:///", "path", "to"]
212
+ * getPathComponents("file:///") === ["file:///"]
213
+ * getPathComponents("file://") === ["file://"]
214
+ */
215
+ export declare function getPathComponents(path: string, currentDirectory?: string): string[];
216
+ /**
217
+ * Formats a parsed path consisting of a root component (at index 0) and zero or more path
218
+ * segments (at indices > 0).
219
+ *
220
+ * ```ts
221
+ * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext"
222
+ * ```
223
+ */
224
+ export declare function getPathFromPathComponents(pathComponents: readonly string[]): string;
225
+ /**
226
+ * Normalize path separators, converting `\` into `/`.
227
+ */
228
+ export declare function normalizeSlashes(path: string): string;
229
+ /**
230
+ * Reduce an array of path components to a more simplified path by navigating any
231
+ * `"."` or `".."` entries in the path.
232
+ */
233
+ export declare function reducePathComponents(components: readonly string[]): string[];
234
+ /**
235
+ * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
236
+ *
237
+ * ```ts
238
+ * // Non-rooted
239
+ * combinePaths("path", "to", "file.ext") === "path/to/file.ext"
240
+ * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext"
241
+ * // POSIX
242
+ * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext"
243
+ * combinePaths("/path", "/to", "file.ext") === "/to/file.ext"
244
+ * // DOS
245
+ * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext"
246
+ * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext"
247
+ * // URL
248
+ * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext"
249
+ * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext"
250
+ * ```
251
+ */
252
+ export declare function combinePaths(path: string, ...paths: (string | undefined)[]): string;
253
+ /**
254
+ * Parse a path into an array containing a root component (at index 0) and zero or more path
255
+ * components (at indices > 0). The result is normalized.
256
+ * If the path is relative, the root component is `""`.
257
+ * If the path is absolute, the root component includes the first path separator (`/`).
258
+ *
259
+ * ```ts
260
+ * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]
261
+ * ```
262
+ */
263
+ export declare function getNormalizedPathComponents(path: string, currentDirectory: string | undefined): string[];
264
+ export declare function getNormalizedAbsolutePath(fileName: string, currentDirectory: string | undefined): string;
265
+ export declare function normalizePath(path: string): string;
266
+ export declare function toPath(fileName: string, basePath: string | undefined, getCanonicalFileName: (path: string) => string): Path;
267
+ /**
268
+ * Removes a trailing directory separator from a path, if it does not already have one.
269
+ *
270
+ * ```ts
271
+ * removeTrailingDirectorySeparator("/path/to/file.ext") === "/path/to/file.ext"
272
+ * removeTrailingDirectorySeparator("/path/to/file.ext/") === "/path/to/file.ext"
273
+ * ```
274
+ */
275
+ export declare function removeTrailingDirectorySeparator(path: Path): Path;
276
+ export declare function removeTrailingDirectorySeparator(path: string): string;
277
+ /**
278
+ * Adds a trailing directory separator to a path, if it does not already have one.
279
+ *
280
+ * ```ts
281
+ * ensureTrailingDirectorySeparator("/path/to/file.ext") === "/path/to/file.ext/"
282
+ * ensureTrailingDirectorySeparator("/path/to/file.ext/") === "/path/to/file.ext/"
283
+ * ```
284
+ */
285
+ export declare function ensureTrailingDirectorySeparator(path: Path): Path;
286
+ export declare function ensureTrailingDirectorySeparator(path: string): string;
287
+ /**
288
+ * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed
289
+ * with `./` or `../`) so as not to be confused with an unprefixed module name.
290
+ *
291
+ * ```ts
292
+ * ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext"
293
+ * ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext"
294
+ * ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext"
295
+ * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext"
296
+ * ```
297
+ */
298
+ export declare function ensurePathIsNonModuleName(path: string): string;
299
+ /**
300
+ * Compare two paths using the provided case sensitivity.
301
+ */
302
+ export declare function comparePaths(a: string, b: string, ignoreCase?: boolean): Comparison;
303
+ export declare function comparePaths(a: string, b: string, currentDirectory: string, ignoreCase?: boolean): Comparison;
304
+ export declare function getPathComponentsRelativeTo(from: string, to: string, stringEqualityComparer: (a: string, b: string) => boolean, getCanonicalFileName: GetCanonicalFileName): string[];
305
+ /**
306
+ * Gets a relative path that can be used to traverse between `from` and `to`.
307
+ */
308
+ export declare function getRelativePathFromDirectory(from: string, to: string, ignoreCase: boolean): string;
309
+ /**
310
+ * Gets a relative path that can be used to traverse between `from` and `to`.
311
+ */
312
+ export declare function getRelativePathFromDirectory(fromDirectory: string, to: string, getCanonicalFileName: GetCanonicalFileName): string;