@volar/typescript 1.6.9 → 1.7.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.
- package/out/documentRegistry.d.ts +2 -0
- package/out/documentRegistry.js +14 -0
- package/out/dtsHost.d.ts +26 -0
- package/out/dtsHost.js +190 -0
- package/out/getProgram.d.ts +1 -1
- package/out/getProgram.js +8 -8
- package/out/index.d.ts +5 -8
- package/out/index.js +19 -285
- package/out/languageService.d.ts +9 -0
- package/out/languageService.js +292 -0
- package/out/languageServiceHost.d.ts +5 -0
- package/out/languageServiceHost.js +210 -0
- package/out/sys.d.ts +7 -0
- package/out/sys.js +325 -0
- package/out/typescript/core.d.ts +83 -0
- package/out/typescript/core.js +320 -0
- package/out/typescript/corePublic.d.ts +91 -0
- package/out/typescript/corePublic.js +51 -0
- package/out/typescript/path.d.ts +112 -0
- package/out/typescript/path.js +417 -0
- package/out/typescript/types.d.ts +129 -0
- package/out/typescript/types.js +3 -0
- package/out/typescript/utilities.d.ts +7 -0
- package/out/typescript/utilities.js +250 -0
- package/package.json +6 -3
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startsWith = exports.createGetCanonicalFileName = exports.stringContains = exports.endsWith = exports.getStringComparer = exports.compareStringsCaseSensitive = exports.equateStringsCaseSensitive = exports.equateStringsCaseInsensitive = exports.last = exports.lastOrUndefined = exports.sort = exports.some = exports.flatMap = exports.flatten = exports.map = exports.indexOfAnyCharCode = exports.findIndex = exports.every = void 0;
|
|
4
|
+
const emptyArray = [];
|
|
5
|
+
/**
|
|
6
|
+
* Iterates through `array` by index and performs the callback on each element of array until the callback
|
|
7
|
+
* returns a falsey value, then returns false.
|
|
8
|
+
* If no such value is found, the callback is applied to each element of array and `true` is returned.
|
|
9
|
+
*/
|
|
10
|
+
function every(array, callback) {
|
|
11
|
+
if (array) {
|
|
12
|
+
for (let i = 0; i < array.length; i++) {
|
|
13
|
+
if (!callback(array[i], i)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
exports.every = every;
|
|
21
|
+
/** Works like Array.prototype.findIndex, returning `-1` if no element satisfying the predicate is found. */
|
|
22
|
+
function findIndex(array, predicate, startIndex) {
|
|
23
|
+
if (array === undefined)
|
|
24
|
+
return -1;
|
|
25
|
+
for (let i = startIndex ?? 0; i < array.length; i++) {
|
|
26
|
+
if (predicate(array[i], i)) {
|
|
27
|
+
return i;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return -1;
|
|
31
|
+
}
|
|
32
|
+
exports.findIndex = findIndex;
|
|
33
|
+
function contains(array, value, equalityComparer = equateValues) {
|
|
34
|
+
if (array) {
|
|
35
|
+
for (const v of array) {
|
|
36
|
+
if (equalityComparer(v, value)) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
function indexOfAnyCharCode(text, charCodes, start) {
|
|
44
|
+
for (let i = start || 0; i < text.length; i++) {
|
|
45
|
+
if (contains(charCodes, text.charCodeAt(i))) {
|
|
46
|
+
return i;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return -1;
|
|
50
|
+
}
|
|
51
|
+
exports.indexOfAnyCharCode = indexOfAnyCharCode;
|
|
52
|
+
function map(array, f) {
|
|
53
|
+
let result;
|
|
54
|
+
if (array) {
|
|
55
|
+
result = [];
|
|
56
|
+
for (let i = 0; i < array.length; i++) {
|
|
57
|
+
result.push(f(array[i], i));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
exports.map = map;
|
|
63
|
+
/**
|
|
64
|
+
* Flattens an array containing a mix of array or non-array elements.
|
|
65
|
+
*
|
|
66
|
+
* @param array The array to flatten.
|
|
67
|
+
*/
|
|
68
|
+
function flatten(array) {
|
|
69
|
+
const result = [];
|
|
70
|
+
for (const v of array) {
|
|
71
|
+
if (v) {
|
|
72
|
+
if (isArray(v)) {
|
|
73
|
+
addRange(result, v);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
result.push(v);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
exports.flatten = flatten;
|
|
83
|
+
/**
|
|
84
|
+
* Maps an array. If the mapped value is an array, it is spread into the result.
|
|
85
|
+
*
|
|
86
|
+
* @param array The array to map.
|
|
87
|
+
* @param mapfn The callback used to map the result into one or more values.
|
|
88
|
+
*/
|
|
89
|
+
function flatMap(array, mapfn) {
|
|
90
|
+
let result;
|
|
91
|
+
if (array) {
|
|
92
|
+
for (let i = 0; i < array.length; i++) {
|
|
93
|
+
const v = mapfn(array[i], i);
|
|
94
|
+
if (v) {
|
|
95
|
+
if (isArray(v)) {
|
|
96
|
+
result = addRange(result, v);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
result = append(result, v);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return result || emptyArray;
|
|
105
|
+
}
|
|
106
|
+
exports.flatMap = flatMap;
|
|
107
|
+
function some(array, predicate) {
|
|
108
|
+
if (array) {
|
|
109
|
+
if (predicate) {
|
|
110
|
+
for (const v of array) {
|
|
111
|
+
if (predicate(v)) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
return array.length > 0;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
exports.some = some;
|
|
123
|
+
// function append<T>(to: T[] | undefined, value: T): T[];
|
|
124
|
+
// function append<T>(to: T[] | undefined, value: T | undefined): T[] | undefined;
|
|
125
|
+
// function append<T>(to: Push<T>, value: T | undefined): void;
|
|
126
|
+
function append(to, value) {
|
|
127
|
+
if (value === undefined)
|
|
128
|
+
return to;
|
|
129
|
+
if (to === undefined)
|
|
130
|
+
return [value];
|
|
131
|
+
to.push(value);
|
|
132
|
+
return to;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Gets the actual offset into an array for a relative offset. Negative offsets indicate a
|
|
136
|
+
* position offset from the end of the array.
|
|
137
|
+
*/
|
|
138
|
+
function toOffset(array, offset) {
|
|
139
|
+
return offset < 0 ? array.length + offset : offset;
|
|
140
|
+
}
|
|
141
|
+
function addRange(to, from, start, end) {
|
|
142
|
+
if (from === undefined || from.length === 0)
|
|
143
|
+
return to;
|
|
144
|
+
if (to === undefined)
|
|
145
|
+
return from.slice(start, end);
|
|
146
|
+
start = start === undefined ? 0 : toOffset(from, start);
|
|
147
|
+
end = end === undefined ? from.length : toOffset(from, end);
|
|
148
|
+
for (let i = start; i < end && i < from.length; i++) {
|
|
149
|
+
if (from[i] !== undefined) {
|
|
150
|
+
to.push(from[i]);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return to;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Returns a new sorted array.
|
|
157
|
+
*/
|
|
158
|
+
function sort(array, comparer) {
|
|
159
|
+
return (array.length === 0 ? array : array.slice().sort(comparer));
|
|
160
|
+
}
|
|
161
|
+
exports.sort = sort;
|
|
162
|
+
/**
|
|
163
|
+
* Returns the last element of an array if non-empty, `undefined` otherwise.
|
|
164
|
+
*/
|
|
165
|
+
function lastOrUndefined(array) {
|
|
166
|
+
return array === undefined || array.length === 0 ? undefined : array[array.length - 1];
|
|
167
|
+
}
|
|
168
|
+
exports.lastOrUndefined = lastOrUndefined;
|
|
169
|
+
function last(array) {
|
|
170
|
+
// Debug.assert(array.length !== 0);
|
|
171
|
+
return array[array.length - 1];
|
|
172
|
+
}
|
|
173
|
+
exports.last = last;
|
|
174
|
+
/**
|
|
175
|
+
* Tests whether a value is an array.
|
|
176
|
+
*/
|
|
177
|
+
function isArray(value) {
|
|
178
|
+
return Array.isArray ? Array.isArray(value) : value instanceof Array;
|
|
179
|
+
}
|
|
180
|
+
/** Returns its argument. */
|
|
181
|
+
function identity(x) {
|
|
182
|
+
return x;
|
|
183
|
+
}
|
|
184
|
+
/** Returns lower case string */
|
|
185
|
+
function toLowerCase(x) {
|
|
186
|
+
return x.toLowerCase();
|
|
187
|
+
}
|
|
188
|
+
// We convert the file names to lower case as key for file name on case insensitive file system
|
|
189
|
+
// While doing so we need to handle special characters (eg \u0130) to ensure that we dont convert
|
|
190
|
+
// it to lower case, fileName with its lowercase form can exist along side it.
|
|
191
|
+
// Handle special characters and make those case sensitive instead
|
|
192
|
+
//
|
|
193
|
+
// |-#--|-Unicode--|-Char code-|-Desc-------------------------------------------------------------------|
|
|
194
|
+
// | 1. | i | 105 | Ascii i |
|
|
195
|
+
// | 2. | I | 73 | Ascii I |
|
|
196
|
+
// |-------- Special characters ------------------------------------------------------------------------|
|
|
197
|
+
// | 3. | \u0130 | 304 | Upper case I with dot above |
|
|
198
|
+
// | 4. | i,\u0307 | 105,775 | i, followed by 775: Lower case of (3rd item) |
|
|
199
|
+
// | 5. | I,\u0307 | 73,775 | I, followed by 775: Upper case of (4th item), lower case is (4th item) |
|
|
200
|
+
// | 6. | \u0131 | 305 | Lower case i without dot, upper case is I (2nd item) |
|
|
201
|
+
// | 7. | \u00DF | 223 | Lower case sharp s |
|
|
202
|
+
//
|
|
203
|
+
// Because item 3 is special where in its lowercase character has its own
|
|
204
|
+
// upper case form we cant convert its case.
|
|
205
|
+
// Rest special characters are either already in lower case format or
|
|
206
|
+
// they have corresponding upper case character so they dont need special handling
|
|
207
|
+
//
|
|
208
|
+
// But to avoid having to do string building for most common cases, also ignore
|
|
209
|
+
// a-z, 0-9, \u0131, \u00DF, \, /, ., : and space
|
|
210
|
+
const fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g;
|
|
211
|
+
/**
|
|
212
|
+
* Case insensitive file systems have descripencies in how they handle some characters (eg. turkish Upper case I with dot on top - \u0130)
|
|
213
|
+
* This function is used in places where we want to make file name as a key on these systems
|
|
214
|
+
* It is possible on mac to be able to refer to file name with I with dot on top as a fileName with its lower case form
|
|
215
|
+
* But on windows we cannot. Windows can have fileName with I with dot on top next to its lower case and they can not each be referred with the lowercase forms
|
|
216
|
+
* Technically we would want this function to be platform sepcific as well but
|
|
217
|
+
* our api has till now only taken caseSensitive as the only input and just for some characters we dont want to update API and ensure all customers use those api
|
|
218
|
+
* We could use upper case and we would still need to deal with the descripencies but
|
|
219
|
+
* we want to continue using lower case since in most cases filenames are lowercasewe and wont need any case changes and avoid having to store another string for the key
|
|
220
|
+
* So for this function purpose, we go ahead and assume character I with dot on top it as case sensitive since its very unlikely to use lower case form of that special character
|
|
221
|
+
*/
|
|
222
|
+
function toFileNameLowerCase(x) {
|
|
223
|
+
return fileNameLowerCaseRegExp.test(x) ?
|
|
224
|
+
x.replace(fileNameLowerCaseRegExp, toLowerCase) :
|
|
225
|
+
x;
|
|
226
|
+
}
|
|
227
|
+
function equateValues(a, b) {
|
|
228
|
+
return a === b;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Compare the equality of two strings using a case-sensitive ordinal comparison.
|
|
232
|
+
*
|
|
233
|
+
* Case-sensitive comparisons compare both strings one code-point at a time using the integer
|
|
234
|
+
* value of each code-point after applying `toUpperCase` to each string. We always map both
|
|
235
|
+
* strings to their upper-case form as some unicode characters do not properly round-trip to
|
|
236
|
+
* lowercase (such as `ẞ` (German sharp capital s)).
|
|
237
|
+
*/
|
|
238
|
+
function equateStringsCaseInsensitive(a, b) {
|
|
239
|
+
return a === b
|
|
240
|
+
|| a !== undefined
|
|
241
|
+
&& b !== undefined
|
|
242
|
+
&& a.toUpperCase() === b.toUpperCase();
|
|
243
|
+
}
|
|
244
|
+
exports.equateStringsCaseInsensitive = equateStringsCaseInsensitive;
|
|
245
|
+
/**
|
|
246
|
+
* Compare the equality of two strings using a case-sensitive ordinal comparison.
|
|
247
|
+
*
|
|
248
|
+
* Case-sensitive comparisons compare both strings one code-point at a time using the
|
|
249
|
+
* integer value of each code-point.
|
|
250
|
+
*/
|
|
251
|
+
function equateStringsCaseSensitive(a, b) {
|
|
252
|
+
return equateValues(a, b);
|
|
253
|
+
}
|
|
254
|
+
exports.equateStringsCaseSensitive = equateStringsCaseSensitive;
|
|
255
|
+
function compareComparableValues(a, b) {
|
|
256
|
+
return a === b ? 0 /* Comparison.EqualTo */ :
|
|
257
|
+
a === undefined ? -1 /* Comparison.LessThan */ :
|
|
258
|
+
b === undefined ? 1 /* Comparison.GreaterThan */ :
|
|
259
|
+
a < b ? -1 /* Comparison.LessThan */ :
|
|
260
|
+
1 /* Comparison.GreaterThan */;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Compare two strings using a case-insensitive ordinal comparison.
|
|
264
|
+
*
|
|
265
|
+
* Ordinal comparisons are based on the difference between the unicode code points of both
|
|
266
|
+
* strings. Characters with multiple unicode representations are considered unequal. Ordinal
|
|
267
|
+
* comparisons provide predictable ordering, but place "a" after "B".
|
|
268
|
+
*
|
|
269
|
+
* Case-insensitive comparisons compare both strings one code-point at a time using the integer
|
|
270
|
+
* value of each code-point after applying `toUpperCase` to each string. We always map both
|
|
271
|
+
* strings to their upper-case form as some unicode characters do not properly round-trip to
|
|
272
|
+
* lowercase (such as `ẞ` (German sharp capital s)).
|
|
273
|
+
*/
|
|
274
|
+
function compareStringsCaseInsensitive(a, b) {
|
|
275
|
+
if (a === b)
|
|
276
|
+
return 0 /* Comparison.EqualTo */;
|
|
277
|
+
if (a === undefined)
|
|
278
|
+
return -1 /* Comparison.LessThan */;
|
|
279
|
+
if (b === undefined)
|
|
280
|
+
return 1 /* Comparison.GreaterThan */;
|
|
281
|
+
a = a.toUpperCase();
|
|
282
|
+
b = b.toUpperCase();
|
|
283
|
+
return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Compare two strings using a case-sensitive ordinal comparison.
|
|
287
|
+
*
|
|
288
|
+
* Ordinal comparisons are based on the difference between the unicode code points of both
|
|
289
|
+
* strings. Characters with multiple unicode representations are considered unequal. Ordinal
|
|
290
|
+
* comparisons provide predictable ordering, but place "a" after "B".
|
|
291
|
+
*
|
|
292
|
+
* Case-sensitive comparisons compare both strings one code-point at a time using the integer
|
|
293
|
+
* value of each code-point.
|
|
294
|
+
*/
|
|
295
|
+
function compareStringsCaseSensitive(a, b) {
|
|
296
|
+
return compareComparableValues(a, b);
|
|
297
|
+
}
|
|
298
|
+
exports.compareStringsCaseSensitive = compareStringsCaseSensitive;
|
|
299
|
+
function getStringComparer(ignoreCase) {
|
|
300
|
+
return ignoreCase ? compareStringsCaseInsensitive : compareStringsCaseSensitive;
|
|
301
|
+
}
|
|
302
|
+
exports.getStringComparer = getStringComparer;
|
|
303
|
+
function endsWith(str, suffix) {
|
|
304
|
+
const expectedPos = str.length - suffix.length;
|
|
305
|
+
return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
|
|
306
|
+
}
|
|
307
|
+
exports.endsWith = endsWith;
|
|
308
|
+
function stringContains(str, substring) {
|
|
309
|
+
return str.indexOf(substring) !== -1;
|
|
310
|
+
}
|
|
311
|
+
exports.stringContains = stringContains;
|
|
312
|
+
function createGetCanonicalFileName(useCaseSensitiveFileNames) {
|
|
313
|
+
return useCaseSensitiveFileNames ? identity : toFileNameLowerCase;
|
|
314
|
+
}
|
|
315
|
+
exports.createGetCanonicalFileName = createGetCanonicalFileName;
|
|
316
|
+
function startsWith(str, prefix) {
|
|
317
|
+
return str.lastIndexOf(prefix, 0) === 0;
|
|
318
|
+
}
|
|
319
|
+
exports.startsWith = startsWith;
|
|
320
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export declare const versionMajorMinor = "4.9";
|
|
2
|
+
/** The version of the TypeScript compiler release */
|
|
3
|
+
export declare const version: string;
|
|
4
|
+
/**
|
|
5
|
+
* Type of objects whose values are all of the same type.
|
|
6
|
+
* The `in` and `for-in` operators can *not* be safely used,
|
|
7
|
+
* since `Object.prototype` may be modified by outside code.
|
|
8
|
+
*/
|
|
9
|
+
export interface MapLike<T> {
|
|
10
|
+
[index: string]: T;
|
|
11
|
+
}
|
|
12
|
+
export interface SortedReadonlyArray<T> extends ReadonlyArray<T> {
|
|
13
|
+
" __sortedArrayBrand": any;
|
|
14
|
+
}
|
|
15
|
+
export interface SortedArray<T> extends Array<T> {
|
|
16
|
+
" __sortedArrayBrand": any;
|
|
17
|
+
}
|
|
18
|
+
/** Common read methods for ES6 Map/Set. */
|
|
19
|
+
export interface ReadonlyCollection<K> {
|
|
20
|
+
readonly size: number;
|
|
21
|
+
has(key: K): boolean;
|
|
22
|
+
keys(): Iterator<K>;
|
|
23
|
+
}
|
|
24
|
+
/** Common write methods for ES6 Map/Set. */
|
|
25
|
+
export interface Collection<K> extends ReadonlyCollection<K> {
|
|
26
|
+
delete(key: K): boolean;
|
|
27
|
+
clear(): void;
|
|
28
|
+
}
|
|
29
|
+
/** ES6 Map interface, only read methods included. */
|
|
30
|
+
export interface ReadonlyESMap<K, V> extends ReadonlyCollection<K> {
|
|
31
|
+
get(key: K): V | undefined;
|
|
32
|
+
values(): Iterator<V>;
|
|
33
|
+
entries(): Iterator<[K, V]>;
|
|
34
|
+
forEach(action: (value: V, key: K) => void): void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* ES6 Map interface, only read methods included.
|
|
38
|
+
*/
|
|
39
|
+
export interface ReadonlyMap<T> extends ReadonlyESMap<string, T> {
|
|
40
|
+
}
|
|
41
|
+
/** ES6 Map interface. */
|
|
42
|
+
export interface ESMap<K, V> extends ReadonlyESMap<K, V>, Collection<K> {
|
|
43
|
+
set(key: K, value: V): this;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* ES6 Map interface.
|
|
47
|
+
*/
|
|
48
|
+
export interface Map<T> extends ESMap<string, T> {
|
|
49
|
+
}
|
|
50
|
+
export interface MapConstructor {
|
|
51
|
+
new <K, V>(iterable?: readonly (readonly [K, V])[] | ReadonlyESMap<K, V>): ESMap<K, V>;
|
|
52
|
+
}
|
|
53
|
+
/** ES6 Set interface, only read methods included. */
|
|
54
|
+
export interface ReadonlySet<T> extends ReadonlyCollection<T> {
|
|
55
|
+
has(value: T): boolean;
|
|
56
|
+
values(): Iterator<T>;
|
|
57
|
+
entries(): Iterator<[T, T]>;
|
|
58
|
+
forEach(action: (value: T, key: T) => void): void;
|
|
59
|
+
}
|
|
60
|
+
/** ES6 Set interface. */
|
|
61
|
+
export interface Set<T> extends ReadonlySet<T>, Collection<T> {
|
|
62
|
+
add(value: T): this;
|
|
63
|
+
delete(value: T): boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface SetConstructor {
|
|
66
|
+
new <T>(iterable?: readonly T[] | ReadonlySet<T>): Set<T>;
|
|
67
|
+
}
|
|
68
|
+
/** ES6 Iterator type. */
|
|
69
|
+
export interface Iterator<T> {
|
|
70
|
+
next(): {
|
|
71
|
+
value: T;
|
|
72
|
+
done?: false;
|
|
73
|
+
} | {
|
|
74
|
+
value: void;
|
|
75
|
+
done: true;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** Array that is only intended to be pushed to, never read. */
|
|
79
|
+
export interface Push<T> {
|
|
80
|
+
push(...values: T[]): void;
|
|
81
|
+
readonly length: number;
|
|
82
|
+
}
|
|
83
|
+
export type EqualityComparer<T> = (a: T, b: T) => boolean;
|
|
84
|
+
export type Comparer<T> = (a: T, b: T) => Comparison;
|
|
85
|
+
export declare const enum Comparison {
|
|
86
|
+
LessThan = -1,
|
|
87
|
+
EqualTo = 0,
|
|
88
|
+
GreaterThan = 1
|
|
89
|
+
}
|
|
90
|
+
export declare const Map: MapConstructor;
|
|
91
|
+
export declare const Set: SetConstructor;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Set = exports.Map = exports.version = exports.versionMajorMinor = void 0;
|
|
4
|
+
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
|
|
5
|
+
// If changing the text in this section, be sure to test `configurePrerelease` too.
|
|
6
|
+
exports.versionMajorMinor = "4.9";
|
|
7
|
+
// The following is baselined as a literal template type without intervention
|
|
8
|
+
/** The version of the TypeScript compiler release */
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
10
|
+
exports.version = `${exports.versionMajorMinor}.0-dev`;
|
|
11
|
+
/* @internal */
|
|
12
|
+
var NativeCollections;
|
|
13
|
+
(function (NativeCollections) {
|
|
14
|
+
const globals = typeof globalThis !== "undefined" ? globalThis :
|
|
15
|
+
typeof global !== "undefined" ? global :
|
|
16
|
+
typeof self !== "undefined" ? self :
|
|
17
|
+
undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the native Map implementation if it is available and compatible (i.e. supports iteration).
|
|
20
|
+
*/
|
|
21
|
+
function tryGetNativeMap() {
|
|
22
|
+
// Internet Explorer's Map doesn't support iteration, so don't use it.
|
|
23
|
+
const gMap = globals?.Map;
|
|
24
|
+
// eslint-disable-next-line local/no-in-operator
|
|
25
|
+
const constructor = typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
|
|
26
|
+
if (!constructor) {
|
|
27
|
+
throw new Error("No compatible Map implementation found.");
|
|
28
|
+
}
|
|
29
|
+
return constructor;
|
|
30
|
+
}
|
|
31
|
+
NativeCollections.tryGetNativeMap = tryGetNativeMap;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the native Set implementation if it is available and compatible (i.e. supports iteration).
|
|
34
|
+
*/
|
|
35
|
+
function tryGetNativeSet() {
|
|
36
|
+
// Internet Explorer's Set doesn't support iteration, so don't use it.
|
|
37
|
+
const gSet = globals?.Set;
|
|
38
|
+
// eslint-disable-next-line local/no-in-operator
|
|
39
|
+
const constructor = typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
|
|
40
|
+
if (!constructor) {
|
|
41
|
+
throw new Error("No compatible Set implementation found.");
|
|
42
|
+
}
|
|
43
|
+
return constructor;
|
|
44
|
+
}
|
|
45
|
+
NativeCollections.tryGetNativeSet = tryGetNativeSet;
|
|
46
|
+
})(NativeCollections || (NativeCollections = {}));
|
|
47
|
+
/* @internal */
|
|
48
|
+
exports.Map = NativeCollections.tryGetNativeMap();
|
|
49
|
+
/* @internal */
|
|
50
|
+
exports.Set = NativeCollections.tryGetNativeSet();
|
|
51
|
+
//# sourceMappingURL=corePublic.js.map
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Path } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Internally, we represent paths as strings with '/' as the directory separator.
|
|
4
|
+
* When we make system calls (eg: LanguageServiceHost.getDirectory()),
|
|
5
|
+
* we expect the host to correctly handle paths in our specified format.
|
|
6
|
+
*/
|
|
7
|
+
export declare const directorySeparator = "/";
|
|
8
|
+
/**
|
|
9
|
+
* Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path
|
|
10
|
+
* like `c:`, `c:\` or `c:/`).
|
|
11
|
+
*/
|
|
12
|
+
export declare function isRootedDiskPath(path: string): boolean;
|
|
13
|
+
export declare function hasExtension(fileName: string): boolean;
|
|
14
|
+
export declare function fileExtensionIsOneOf(path: string, extensions: readonly string[]): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the path except for its basename. Semantics align with NodeJS's `path.dirname`
|
|
17
|
+
* except that we support URLs as well.
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* // POSIX
|
|
21
|
+
* getDirectoryPath("/path/to/file.ext") === "/path/to"
|
|
22
|
+
* getDirectoryPath("/path/to/") === "/path"
|
|
23
|
+
* getDirectoryPath("/") === "/"
|
|
24
|
+
* // DOS
|
|
25
|
+
* getDirectoryPath("c:/path/to/file.ext") === "c:/path/to"
|
|
26
|
+
* getDirectoryPath("c:/path/to/") === "c:/path"
|
|
27
|
+
* getDirectoryPath("c:/") === "c:/"
|
|
28
|
+
* getDirectoryPath("c:") === "c:"
|
|
29
|
+
* // URL
|
|
30
|
+
* getDirectoryPath("http://typescriptlang.org/path/to/file.ext") === "http://typescriptlang.org/path/to"
|
|
31
|
+
* getDirectoryPath("http://typescriptlang.org/path/to") === "http://typescriptlang.org/path"
|
|
32
|
+
* getDirectoryPath("http://typescriptlang.org/") === "http://typescriptlang.org/"
|
|
33
|
+
* getDirectoryPath("http://typescriptlang.org") === "http://typescriptlang.org"
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function getDirectoryPath(path: Path): Path;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the path except for its basename. Semantics align with NodeJS's `path.dirname`
|
|
39
|
+
* except that we support URLs as well.
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* // POSIX
|
|
43
|
+
* getDirectoryPath("/path/to/file.ext") === "/path/to"
|
|
44
|
+
* getDirectoryPath("/path/to/") === "/path"
|
|
45
|
+
* getDirectoryPath("/") === "/"
|
|
46
|
+
* // DOS
|
|
47
|
+
* getDirectoryPath("c:/path/to/file.ext") === "c:/path/to"
|
|
48
|
+
* getDirectoryPath("c:/path/to/") === "c:/path"
|
|
49
|
+
* getDirectoryPath("c:/") === "c:/"
|
|
50
|
+
* getDirectoryPath("c:") === "c:"
|
|
51
|
+
* // URL
|
|
52
|
+
* getDirectoryPath("http://typescriptlang.org/path/to/file.ext") === "http://typescriptlang.org/path/to"
|
|
53
|
+
* getDirectoryPath("http://typescriptlang.org/path/to") === "http://typescriptlang.org/path"
|
|
54
|
+
* getDirectoryPath("http://typescriptlang.org/") === "http://typescriptlang.org/"
|
|
55
|
+
* getDirectoryPath("http://typescriptlang.org") === "http://typescriptlang.org"
|
|
56
|
+
* getDirectoryPath("file://server/path/to/file.ext") === "file://server/path/to"
|
|
57
|
+
* getDirectoryPath("file://server/path/to") === "file://server/path"
|
|
58
|
+
* getDirectoryPath("file://server/") === "file://server/"
|
|
59
|
+
* getDirectoryPath("file://server") === "file://server"
|
|
60
|
+
* getDirectoryPath("file:///path/to/file.ext") === "file:///path/to"
|
|
61
|
+
* getDirectoryPath("file:///path/to") === "file:///path"
|
|
62
|
+
* getDirectoryPath("file:///") === "file:///"
|
|
63
|
+
* getDirectoryPath("file://") === "file://"
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function getDirectoryPath(path: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* // Non-rooted
|
|
72
|
+
* combinePaths("path", "to", "file.ext") === "path/to/file.ext"
|
|
73
|
+
* combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext"
|
|
74
|
+
* // POSIX
|
|
75
|
+
* combinePaths("/path", "to", "file.ext") === "/path/to/file.ext"
|
|
76
|
+
* combinePaths("/path", "/to", "file.ext") === "/to/file.ext"
|
|
77
|
+
* // DOS
|
|
78
|
+
* combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext"
|
|
79
|
+
* combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext"
|
|
80
|
+
* // URL
|
|
81
|
+
* combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext"
|
|
82
|
+
* combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext"
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare function combinePaths(path: string, ...paths: (string | undefined)[]): string;
|
|
86
|
+
/**
|
|
87
|
+
* Parse a path into an array containing a root component (at index 0) and zero or more path
|
|
88
|
+
* components (at indices > 0). The result is normalized.
|
|
89
|
+
* If the path is relative, the root component is `""`.
|
|
90
|
+
* If the path is absolute, the root component includes the first path separator (`/`).
|
|
91
|
+
*
|
|
92
|
+
* ```ts
|
|
93
|
+
* getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare function getNormalizedPathComponents(path: string, currentDirectory: string | undefined): string[];
|
|
97
|
+
export declare function normalizePath(path: string): string;
|
|
98
|
+
/**
|
|
99
|
+
* Removes a trailing directory separator from a path, if it does not already have one.
|
|
100
|
+
*
|
|
101
|
+
* ```ts
|
|
102
|
+
* removeTrailingDirectorySeparator("/path/to/file.ext") === "/path/to/file.ext"
|
|
103
|
+
* removeTrailingDirectorySeparator("/path/to/file.ext/") === "/path/to/file.ext"
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare function removeTrailingDirectorySeparator(path: Path): Path;
|
|
107
|
+
export declare function removeTrailingDirectorySeparator(path: string): string;
|
|
108
|
+
/**
|
|
109
|
+
* Determines whether a `parent` path contains a `child` path using the provide case sensitivity.
|
|
110
|
+
*/
|
|
111
|
+
export declare function containsPath(parent: string, child: string, ignoreCase?: boolean): boolean;
|
|
112
|
+
export declare function containsPath(parent: string, child: string, currentDirectory: string, ignoreCase?: boolean): boolean;
|