@volar/language-server 1.7.5 → 1.7.7
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/common/project.d.ts +1 -1
- package/out/common/project.js +1 -1
- package/out/common/workspace.d.ts +9 -9
- package/out/common/workspaces.d.ts +11 -11
- package/out/node/index.js +19 -10
- package/package.json +6 -6
- package/out/browser/fileSystems.d.ts +0 -2
- package/out/browser/fileSystems.js +0 -287
- package/out/browser/typescript/core.d.ts +0 -83
- package/out/browser/typescript/core.js +0 -320
- package/out/browser/typescript/corePublic.d.ts +0 -91
- package/out/browser/typescript/corePublic.js +0 -51
- package/out/browser/typescript/path.d.ts +0 -112
- package/out/browser/typescript/path.js +0 -417
- package/out/browser/typescript/types.d.ts +0 -129
- package/out/browser/typescript/types.js +0 -3
- package/out/browser/typescript/utilities.d.ts +0 -7
- package/out/browser/typescript/utilities.js +0 -250
- package/out/common/schemaRequestHandlers/file.d.ts +0 -2
- package/out/common/schemaRequestHandlers/file.js +0 -13
- package/out/node/fileSystem.d.ts +0 -3
- package/out/node/fileSystem.js +0 -100
package/out/common/project.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface ProjectContext extends WorkspaceContext {
|
|
|
13
13
|
export type Project = ReturnType<typeof createProject>;
|
|
14
14
|
export declare function createProject(context: ProjectContext): Promise<{
|
|
15
15
|
context: ProjectContext;
|
|
16
|
-
tsConfig:
|
|
16
|
+
tsConfig: path.PosixPath | ts.CompilerOptions;
|
|
17
17
|
scripts: {
|
|
18
18
|
clear: () => void;
|
|
19
19
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
package/out/common/project.js
CHANGED
|
@@ -157,7 +157,7 @@ exports.createProject = createProject;
|
|
|
157
157
|
async function createParsedCommandLine(ts, env, rootPath, tsConfig, plugins, existingOptions) {
|
|
158
158
|
const extraFileExtensions = plugins.map(plugin => plugin.extraFileExtensions ?? []).flat();
|
|
159
159
|
if (ts) {
|
|
160
|
-
const sys = (0, typescript_1.createSys)(
|
|
160
|
+
const sys = (0, typescript_1.createSys)(ts, {
|
|
161
161
|
...env,
|
|
162
162
|
onDidChangeWatchedFiles: undefined,
|
|
163
163
|
});
|
|
@@ -14,7 +14,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
|
|
|
14
14
|
clear: () => void;
|
|
15
15
|
values: () => IterableIterator<Promise<{
|
|
16
16
|
context: import("./project").ProjectContext;
|
|
17
|
-
tsConfig:
|
|
17
|
+
tsConfig: path.PosixPath | ts.CompilerOptions;
|
|
18
18
|
scripts: {
|
|
19
19
|
clear: () => void;
|
|
20
20
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -153,7 +153,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
|
|
|
153
153
|
uriDelete: (_uri: string) => boolean;
|
|
154
154
|
uriGet: (_uri: string) => Promise<{
|
|
155
155
|
context: import("./project").ProjectContext;
|
|
156
|
-
tsConfig:
|
|
156
|
+
tsConfig: path.PosixPath | ts.CompilerOptions;
|
|
157
157
|
scripts: {
|
|
158
158
|
clear: () => void;
|
|
159
159
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -292,7 +292,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
|
|
|
292
292
|
uriHas: (_uri: string) => boolean;
|
|
293
293
|
uriSet: (_uri: string, item: Promise<{
|
|
294
294
|
context: import("./project").ProjectContext;
|
|
295
|
-
tsConfig:
|
|
295
|
+
tsConfig: path.PosixPath | ts.CompilerOptions;
|
|
296
296
|
scripts: {
|
|
297
297
|
clear: () => void;
|
|
298
298
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -431,7 +431,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
|
|
|
431
431
|
pathDelete: (path: string) => boolean;
|
|
432
432
|
pathGet: (path: string) => Promise<{
|
|
433
433
|
context: import("./project").ProjectContext;
|
|
434
|
-
tsConfig:
|
|
434
|
+
tsConfig: path.PosixPath | ts.CompilerOptions;
|
|
435
435
|
scripts: {
|
|
436
436
|
clear: () => void;
|
|
437
437
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -569,7 +569,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
|
|
|
569
569
|
}> | undefined;
|
|
570
570
|
pathHas: (path: string) => Promise<{
|
|
571
571
|
context: import("./project").ProjectContext;
|
|
572
|
-
tsConfig:
|
|
572
|
+
tsConfig: path.PosixPath | ts.CompilerOptions;
|
|
573
573
|
scripts: {
|
|
574
574
|
clear: () => void;
|
|
575
575
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -707,7 +707,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
|
|
|
707
707
|
}> | undefined;
|
|
708
708
|
pathSet: (path: string, item: Promise<{
|
|
709
709
|
context: import("./project").ProjectContext;
|
|
710
|
-
tsConfig:
|
|
710
|
+
tsConfig: path.PosixPath | ts.CompilerOptions;
|
|
711
711
|
scripts: {
|
|
712
712
|
clear: () => void;
|
|
713
713
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -848,7 +848,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
|
|
|
848
848
|
tsconfig: string;
|
|
849
849
|
project: {
|
|
850
850
|
context: import("./project").ProjectContext;
|
|
851
|
-
tsConfig:
|
|
851
|
+
tsConfig: path.PosixPath | ts.CompilerOptions;
|
|
852
852
|
scripts: {
|
|
853
853
|
clear: () => void;
|
|
854
854
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -987,7 +987,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
|
|
|
987
987
|
} | undefined>;
|
|
988
988
|
getInferredProject: () => Promise<{
|
|
989
989
|
context: import("./project").ProjectContext;
|
|
990
|
-
tsConfig:
|
|
990
|
+
tsConfig: path.PosixPath | ts.CompilerOptions;
|
|
991
991
|
scripts: {
|
|
992
992
|
clear: () => void;
|
|
993
993
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -1125,7 +1125,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
|
|
|
1125
1125
|
}>;
|
|
1126
1126
|
getInferredProjectDontCreate: () => Promise<{
|
|
1127
1127
|
context: import("./project").ProjectContext;
|
|
1128
|
-
tsConfig:
|
|
1128
|
+
tsConfig: path.PosixPath | ts.CompilerOptions;
|
|
1129
1129
|
scripts: {
|
|
1130
1130
|
clear: () => void;
|
|
1131
1131
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -25,7 +25,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
|
|
|
25
25
|
clear: () => void;
|
|
26
26
|
values: () => IterableIterator<Promise<{
|
|
27
27
|
context: import("./project").ProjectContext;
|
|
28
|
-
tsConfig:
|
|
28
|
+
tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
|
|
29
29
|
scripts: {
|
|
30
30
|
clear: () => void;
|
|
31
31
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -164,7 +164,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
|
|
|
164
164
|
uriDelete: (_uri: string) => boolean;
|
|
165
165
|
uriGet: (_uri: string) => Promise<{
|
|
166
166
|
context: import("./project").ProjectContext;
|
|
167
|
-
tsConfig:
|
|
167
|
+
tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
|
|
168
168
|
scripts: {
|
|
169
169
|
clear: () => void;
|
|
170
170
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -303,7 +303,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
|
|
|
303
303
|
uriHas: (_uri: string) => boolean;
|
|
304
304
|
uriSet: (_uri: string, item: Promise<{
|
|
305
305
|
context: import("./project").ProjectContext;
|
|
306
|
-
tsConfig:
|
|
306
|
+
tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
|
|
307
307
|
scripts: {
|
|
308
308
|
clear: () => void;
|
|
309
309
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -442,7 +442,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
|
|
|
442
442
|
pathDelete: (path: string) => boolean;
|
|
443
443
|
pathGet: (path: string) => Promise<{
|
|
444
444
|
context: import("./project").ProjectContext;
|
|
445
|
-
tsConfig:
|
|
445
|
+
tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
|
|
446
446
|
scripts: {
|
|
447
447
|
clear: () => void;
|
|
448
448
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -580,7 +580,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
|
|
|
580
580
|
}> | undefined;
|
|
581
581
|
pathHas: (path: string) => Promise<{
|
|
582
582
|
context: import("./project").ProjectContext;
|
|
583
|
-
tsConfig:
|
|
583
|
+
tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
|
|
584
584
|
scripts: {
|
|
585
585
|
clear: () => void;
|
|
586
586
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -718,7 +718,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
|
|
|
718
718
|
}> | undefined;
|
|
719
719
|
pathSet: (path: string, item: Promise<{
|
|
720
720
|
context: import("./project").ProjectContext;
|
|
721
|
-
tsConfig:
|
|
721
|
+
tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
|
|
722
722
|
scripts: {
|
|
723
723
|
clear: () => void;
|
|
724
724
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -859,7 +859,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
|
|
|
859
859
|
tsconfig: string;
|
|
860
860
|
project: {
|
|
861
861
|
context: import("./project").ProjectContext;
|
|
862
|
-
tsConfig:
|
|
862
|
+
tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
|
|
863
863
|
scripts: {
|
|
864
864
|
clear: () => void;
|
|
865
865
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -998,7 +998,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
|
|
|
998
998
|
} | undefined>;
|
|
999
999
|
getInferredProject: () => Promise<{
|
|
1000
1000
|
context: import("./project").ProjectContext;
|
|
1001
|
-
tsConfig:
|
|
1001
|
+
tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
|
|
1002
1002
|
scripts: {
|
|
1003
1003
|
clear: () => void;
|
|
1004
1004
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -1136,7 +1136,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
|
|
|
1136
1136
|
}>;
|
|
1137
1137
|
getInferredProjectDontCreate: () => Promise<{
|
|
1138
1138
|
context: import("./project").ProjectContext;
|
|
1139
|
-
tsConfig:
|
|
1139
|
+
tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
|
|
1140
1140
|
scripts: {
|
|
1141
1141
|
clear: () => void;
|
|
1142
1142
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -1279,7 +1279,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
|
|
|
1279
1279
|
tsconfig: string;
|
|
1280
1280
|
project: {
|
|
1281
1281
|
context: import("./project").ProjectContext;
|
|
1282
|
-
tsConfig:
|
|
1282
|
+
tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
|
|
1283
1283
|
scripts: {
|
|
1284
1284
|
clear: () => void;
|
|
1285
1285
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
|
@@ -1419,7 +1419,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
|
|
|
1419
1419
|
tsconfig: undefined;
|
|
1420
1420
|
project: {
|
|
1421
1421
|
context: import("./project").ProjectContext;
|
|
1422
|
-
tsConfig:
|
|
1422
|
+
tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
|
|
1423
1423
|
scripts: {
|
|
1424
1424
|
clear: () => void;
|
|
1425
1425
|
values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
|
package/out/node/index.js
CHANGED
|
@@ -78,7 +78,9 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
catch {
|
|
81
|
+
catch {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
82
84
|
}
|
|
83
85
|
},
|
|
84
86
|
readFile(uri, encoding) {
|
|
@@ -93,7 +95,9 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
93
95
|
}
|
|
94
96
|
return fs.readFileSync(uriToFileName(uri), { encoding: encoding ?? 'utf-8' });
|
|
95
97
|
}
|
|
96
|
-
catch {
|
|
98
|
+
catch {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
97
101
|
}
|
|
98
102
|
if (uri.startsWith('http://') || uri.startsWith('https://')) {
|
|
99
103
|
return (0, http_1.default)(uri);
|
|
@@ -101,14 +105,19 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
101
105
|
},
|
|
102
106
|
readDirectory(uri) {
|
|
103
107
|
if (uri.startsWith('file://')) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return
|
|
108
|
-
|
|
109
|
-
: file.
|
|
110
|
-
: language_service_1.FileType.
|
|
111
|
-
|
|
108
|
+
try {
|
|
109
|
+
const dirName = uriToFileName(uri);
|
|
110
|
+
const files = fs.readdirSync(dirName, { withFileTypes: true });
|
|
111
|
+
return files.map(file => {
|
|
112
|
+
return [file.name, file.isFile() ? language_service_1.FileType.File
|
|
113
|
+
: file.isDirectory() ? language_service_1.FileType.Directory
|
|
114
|
+
: file.isSymbolicLink() ? language_service_1.FileType.SymbolicLink
|
|
115
|
+
: language_service_1.FileType.Unknown];
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
112
121
|
}
|
|
113
122
|
return [];
|
|
114
123
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-server",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.7",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"directory": "packages/language-server"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@volar/language-core": "1.7.
|
|
19
|
-
"@volar/language-service": "1.7.
|
|
20
|
-
"@volar/typescript": "1.7.
|
|
18
|
+
"@volar/language-core": "1.7.7",
|
|
19
|
+
"@volar/language-service": "1.7.7",
|
|
20
|
+
"@volar/typescript": "1.7.7",
|
|
21
21
|
"@vscode/l10n": "^0.0.11",
|
|
22
22
|
"request-light": "^0.7.0",
|
|
23
23
|
"typesafe-path": "^0.2.2",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"vscode-uri": "^3.0.7"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@volar/source-map": "1.7.
|
|
30
|
+
"@volar/source-map": "1.7.7"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "ad13290da9f223f6d198d858faf5349933112200"
|
|
33
33
|
}
|
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createWebFileSystemHost = void 0;
|
|
4
|
-
const path = require("typesafe-path");
|
|
5
|
-
const vscode_html_languageservice_1 = require("vscode-html-languageservice");
|
|
6
|
-
const vscode = require("vscode-languageserver");
|
|
7
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
8
|
-
const protocol_1 = require("../protocol");
|
|
9
|
-
const utilities_1 = require("./typescript/utilities");
|
|
10
|
-
const uriMap_1 = require("../common/utils/uriMap");
|
|
11
|
-
function createWebFileSystemHost(_0, _1, env, initOptions) {
|
|
12
|
-
const instances = (0, uriMap_1.createUriMap)(env.fileNameToUri);
|
|
13
|
-
const onDidChangeWatchedFilesCb = new Set();
|
|
14
|
-
const root = {
|
|
15
|
-
dirs: new Map(),
|
|
16
|
-
files: new Map(),
|
|
17
|
-
requested: false,
|
|
18
|
-
};
|
|
19
|
-
const fetchTasks = [];
|
|
20
|
-
const changes = [];
|
|
21
|
-
const onReadyCb = [];
|
|
22
|
-
let runningRead = false;
|
|
23
|
-
let runningStat = false;
|
|
24
|
-
let connection;
|
|
25
|
-
return {
|
|
26
|
-
ready(_connection) {
|
|
27
|
-
connection = _connection;
|
|
28
|
-
connection.onDidChangeWatchedFiles(params => {
|
|
29
|
-
for (const change of params.changes) {
|
|
30
|
-
const fsPath = env.uriToFileName(change.uri);
|
|
31
|
-
const dir = getDir(path.dirname(fsPath));
|
|
32
|
-
const name = path.basename(fsPath);
|
|
33
|
-
if (!dir.files.has(name)) {
|
|
34
|
-
dir.files.set(name, {});
|
|
35
|
-
}
|
|
36
|
-
if (change.type === vscode.FileChangeType.Created || change.type === vscode.FileChangeType.Changed) {
|
|
37
|
-
dir.files.get(name).exists = true;
|
|
38
|
-
}
|
|
39
|
-
else if (change.type === vscode.FileChangeType.Deleted) {
|
|
40
|
-
if (!dir.files.has(name)) {
|
|
41
|
-
dir.files.set(name, {});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
changes.push(...params.changes);
|
|
46
|
-
fireChanges();
|
|
47
|
-
});
|
|
48
|
-
for (const cb of onReadyCb) {
|
|
49
|
-
cb(connection);
|
|
50
|
-
}
|
|
51
|
-
onReadyCb.length = 0;
|
|
52
|
-
},
|
|
53
|
-
reload() {
|
|
54
|
-
root.dirs.clear();
|
|
55
|
-
root.files.clear();
|
|
56
|
-
root.requested = false;
|
|
57
|
-
},
|
|
58
|
-
getWorkspaceFileSystem(rootUri) {
|
|
59
|
-
let sys = instances.uriGet(rootUri.toString());
|
|
60
|
-
if (!sys) {
|
|
61
|
-
sys = createWorkspaceFileSystem(rootUri);
|
|
62
|
-
instances.uriSet(rootUri.toString(), sys);
|
|
63
|
-
}
|
|
64
|
-
return sys;
|
|
65
|
-
},
|
|
66
|
-
onDidChangeWatchedFiles: cb => {
|
|
67
|
-
onDidChangeWatchedFilesCb.add(cb);
|
|
68
|
-
return () => onDidChangeWatchedFilesCb.delete(cb);
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
function createWorkspaceFileSystem(rootUri) {
|
|
72
|
-
const rootPath = env.uriToFileName(rootUri.toString());
|
|
73
|
-
return {
|
|
74
|
-
args: [],
|
|
75
|
-
newLine: '\n',
|
|
76
|
-
useCaseSensitiveFileNames: false,
|
|
77
|
-
getCurrentDirectory: () => env.uriToFileName(rootUri.toString()),
|
|
78
|
-
fileExists,
|
|
79
|
-
readFile,
|
|
80
|
-
readDirectory,
|
|
81
|
-
getDirectories,
|
|
82
|
-
resolvePath,
|
|
83
|
-
// ignore
|
|
84
|
-
write: () => { },
|
|
85
|
-
writeFile: () => { },
|
|
86
|
-
createDirectory: () => { },
|
|
87
|
-
realpath: path => path,
|
|
88
|
-
directoryExists: () => true,
|
|
89
|
-
exit: () => { },
|
|
90
|
-
getExecutingFilePath: () => rootPath + '/__fake__.js',
|
|
91
|
-
};
|
|
92
|
-
function resolvePath(fsPath) {
|
|
93
|
-
return path.resolve(fsPath);
|
|
94
|
-
}
|
|
95
|
-
function fileExists(fsPath) {
|
|
96
|
-
fsPath = resolvePath(fsPath);
|
|
97
|
-
const uri = env.fileNameToUri(fsPath);
|
|
98
|
-
const dirPath = path.dirname(fsPath);
|
|
99
|
-
if (initOptions.typescript?.cdn && uri.startsWith(initOptions.typescript.cdn)) {
|
|
100
|
-
if (!(uri.endsWith('.d.ts') || uri.endsWith('/package.json'))) {
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
readFile(fsPath);
|
|
104
|
-
const file = getDir(dirPath).files.get(path.basename(fsPath));
|
|
105
|
-
return file?.exists ?? false;
|
|
106
|
-
}
|
|
107
|
-
readDirectory(dirPath);
|
|
108
|
-
const file = getDir(path.dirname(fsPath)).files.get(path.basename(fsPath));
|
|
109
|
-
return file?.exists ?? false;
|
|
110
|
-
}
|
|
111
|
-
function readFile(fsPath) {
|
|
112
|
-
fsPath = resolvePath(fsPath);
|
|
113
|
-
const uri = env.fileNameToUri(fsPath);
|
|
114
|
-
const dirPath = path.dirname(fsPath);
|
|
115
|
-
const dir = getDir(dirPath);
|
|
116
|
-
const name = path.basename(fsPath);
|
|
117
|
-
if (initOptions.typescript?.cdn && uri.startsWith(initOptions.typescript.cdn)) {
|
|
118
|
-
if (!(uri.endsWith('.d.ts') || uri.endsWith('/package.json'))) {
|
|
119
|
-
return dir.files.get(name)?.text || '';
|
|
120
|
-
}
|
|
121
|
-
readFileWorker();
|
|
122
|
-
return dir.files.get(name)?.text || '';
|
|
123
|
-
}
|
|
124
|
-
readFileWorker();
|
|
125
|
-
return dir.files.get(name)?.text || '';
|
|
126
|
-
function readFileWorker() {
|
|
127
|
-
if (connection) {
|
|
128
|
-
fetch('load', fsPath, readFileAsync(connection, fsPath, dir));
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
onReadyCb.push((connection) => fetch('load', fsPath, readFileAsync(connection, fsPath, dir)));
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
async function readFileAsync(connection, fsPath, dir) {
|
|
135
|
-
const name = path.basename(fsPath);
|
|
136
|
-
if (!dir.files.has(name)) {
|
|
137
|
-
dir.files.set(name, {});
|
|
138
|
-
}
|
|
139
|
-
const file = dir.files.get(name);
|
|
140
|
-
if (file.requested) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
file.requested = true;
|
|
144
|
-
const uri = env.fileNameToUri(fsPath);
|
|
145
|
-
const data = await connection.sendRequest(protocol_1.FsReadFileRequest.type, resolveRequestUrl(uri));
|
|
146
|
-
const text = data ? new TextDecoder('utf8').decode(data) : undefined;
|
|
147
|
-
if (text?.length) {
|
|
148
|
-
file.exists = true;
|
|
149
|
-
file.text = text;
|
|
150
|
-
changes.push({ uri, type: vscode.FileChangeType.Changed });
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
function readDirectory(fsPath, extensions, exclude, include, depth) {
|
|
155
|
-
fsPath = resolvePath(fsPath);
|
|
156
|
-
return (0, utilities_1.matchFiles)(fsPath, extensions, exclude, include, false, rootPath, depth, (dirPath) => {
|
|
157
|
-
dirPath = resolvePath(dirPath);
|
|
158
|
-
readDirectoryWorker(dirPath);
|
|
159
|
-
const dir = getDir(dirPath);
|
|
160
|
-
return {
|
|
161
|
-
files: [...dir.files.entries()].filter(([_, file]) => file.exists).map(([name]) => name),
|
|
162
|
-
directories: [...dir.dirs.entries()].filter(([_, dir]) => dir.exists).map(([name]) => name),
|
|
163
|
-
};
|
|
164
|
-
}, path => path);
|
|
165
|
-
}
|
|
166
|
-
// for import path completion
|
|
167
|
-
function getDirectories(fsPath) {
|
|
168
|
-
fsPath = resolvePath(fsPath);
|
|
169
|
-
readDirectoryWorker(fsPath);
|
|
170
|
-
const dir = getDir(fsPath);
|
|
171
|
-
return [...dir.dirs.entries()].filter(([_, dir]) => dir.exists).map(([name]) => name);
|
|
172
|
-
}
|
|
173
|
-
function readDirectoryWorker(fsPath) {
|
|
174
|
-
if (connection) {
|
|
175
|
-
fetch('directory', fsPath, readDirectoryAsync(connection, fsPath));
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
onReadyCb.push((connection) => fetch('directory', fsPath, readDirectoryAsync(connection, fsPath)));
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
async function readDirectoryAsync(connection, fsPath) {
|
|
182
|
-
const dir = getDir(fsPath);
|
|
183
|
-
if (dir.requested) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
dir.requested = true;
|
|
187
|
-
const uri = env.fileNameToUri(fsPath);
|
|
188
|
-
const result = await connection.sendRequest(protocol_1.FsReadDirectoryRequest.type, resolveRequestUrl(uri));
|
|
189
|
-
for (const [name, fileType] of result) {
|
|
190
|
-
if (fileType === vscode_html_languageservice_1.FileType.File || fileType === vscode_html_languageservice_1.FileType.SymbolicLink) {
|
|
191
|
-
if (!dir.files.has(name)) {
|
|
192
|
-
dir.files.set(name, {});
|
|
193
|
-
}
|
|
194
|
-
const file = dir.files.get(name);
|
|
195
|
-
if (!file.exists) {
|
|
196
|
-
file.exists = true;
|
|
197
|
-
changes.push({
|
|
198
|
-
uri: env.fileNameToUri(path.join(fsPath, name)),
|
|
199
|
-
type: vscode.FileChangeType.Created,
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
else if (fileType === vscode_html_languageservice_1.FileType.Directory && !dir.dirs.has(name)) {
|
|
204
|
-
const childDir = getDirFromDir(dir, name);
|
|
205
|
-
childDir.exists = true;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
async function fetch(action, fileName, p) {
|
|
211
|
-
fetchTasks.push([action, fileName, p]);
|
|
212
|
-
if (runningRead === false) {
|
|
213
|
-
let toUpdate;
|
|
214
|
-
runningRead = true;
|
|
215
|
-
const progress = await connection?.window.createWorkDoneProgress();
|
|
216
|
-
progress?.begin('');
|
|
217
|
-
while (fetchTasks.length) {
|
|
218
|
-
const current = fetchTasks.shift();
|
|
219
|
-
updateProgress(current[0] + ' ' + vscode_uri_1.URI.parse(env.fileNameToUri(current[1])).fsPath);
|
|
220
|
-
await current[2];
|
|
221
|
-
}
|
|
222
|
-
progress?.done();
|
|
223
|
-
runningRead = false;
|
|
224
|
-
fireChanges();
|
|
225
|
-
function updateProgress(text) {
|
|
226
|
-
clearTimeout(toUpdate);
|
|
227
|
-
toUpdate = setTimeout(() => {
|
|
228
|
-
progress?.report(text);
|
|
229
|
-
toUpdate = undefined;
|
|
230
|
-
}, 0);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
function resolveRequestUrl(uri) {
|
|
235
|
-
if (initOptions.typescript?.cdn && uri.startsWith(initOptions.typescript.cdn)) {
|
|
236
|
-
let fileName = env.uriToFileName(uri);
|
|
237
|
-
for (const [key, version] of Object.entries(initOptions.typescript.versions || {})) {
|
|
238
|
-
if (fileName.startsWith(`/node_modules/${key}/`)) {
|
|
239
|
-
fileName = fileName.replace(`/node_modules/${key}/`, `/node_modules/${key}@${version}/`);
|
|
240
|
-
return env.fileNameToUri(fileName);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return uri;
|
|
245
|
-
}
|
|
246
|
-
async function fireChanges() {
|
|
247
|
-
if (runningRead || runningStat) {
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
const _changes = [...changes];
|
|
251
|
-
changes.length = 0;
|
|
252
|
-
for (const cb of [...onDidChangeWatchedFilesCb]) {
|
|
253
|
-
if (onDidChangeWatchedFilesCb.has(cb)) {
|
|
254
|
-
await cb({ changes: _changes });
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
function getDir(dirPath) {
|
|
259
|
-
const dirNames = [];
|
|
260
|
-
let currentDirPath = dirPath;
|
|
261
|
-
let currentDirName = path.basename(currentDirPath);
|
|
262
|
-
while (currentDirName !== '') {
|
|
263
|
-
dirNames.push(currentDirName);
|
|
264
|
-
currentDirPath = path.dirname(currentDirPath);
|
|
265
|
-
currentDirName = path.basename(currentDirPath);
|
|
266
|
-
}
|
|
267
|
-
let currentDir = root;
|
|
268
|
-
for (let i = dirNames.length - 1; i >= 0; i--) {
|
|
269
|
-
const nextDirName = dirNames[i];
|
|
270
|
-
currentDir = getDirFromDir(currentDir, nextDirName);
|
|
271
|
-
}
|
|
272
|
-
return currentDir;
|
|
273
|
-
}
|
|
274
|
-
function getDirFromDir(dir, name) {
|
|
275
|
-
let target = dir.dirs.get(name);
|
|
276
|
-
if (!target) {
|
|
277
|
-
target = {
|
|
278
|
-
dirs: new Map(),
|
|
279
|
-
files: new Map(),
|
|
280
|
-
};
|
|
281
|
-
dir.dirs.set(name, target);
|
|
282
|
-
}
|
|
283
|
-
return target;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
exports.createWebFileSystemHost = createWebFileSystemHost;
|
|
287
|
-
//# sourceMappingURL=fileSystems.js.map
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { Comparer, Comparison, SortedReadonlyArray } from "./corePublic";
|
|
2
|
-
/**
|
|
3
|
-
* Iterates through `array` by index and performs the callback on each element of array until the callback
|
|
4
|
-
* returns a falsey value, then returns false.
|
|
5
|
-
* If no such value is found, the callback is applied to each element of array and `true` is returned.
|
|
6
|
-
*/
|
|
7
|
-
export declare function every<T>(array: readonly T[] | undefined, callback: (element: T, index: number) => boolean): boolean;
|
|
8
|
-
/** Works like Array.prototype.findIndex, returning `-1` if no element satisfying the predicate is found. */
|
|
9
|
-
export declare function findIndex<T>(array: readonly T[] | undefined, predicate: (element: T, index: number) => boolean, startIndex?: number): number;
|
|
10
|
-
export declare function indexOfAnyCharCode(text: string, charCodes: readonly number[], start?: number): number;
|
|
11
|
-
export declare function map<T, U>(array: readonly T[], f: (x: T, i: number) => U): U[];
|
|
12
|
-
export declare function map<T, U>(array: readonly T[] | undefined, f: (x: T, i: number) => U): U[] | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* Flattens an array containing a mix of array or non-array elements.
|
|
15
|
-
*
|
|
16
|
-
* @param array The array to flatten.
|
|
17
|
-
*/
|
|
18
|
-
export declare function flatten<T>(array: T[][] | readonly (T | readonly T[] | undefined)[]): T[];
|
|
19
|
-
/**
|
|
20
|
-
* Maps an array. If the mapped value is an array, it is spread into the result.
|
|
21
|
-
*
|
|
22
|
-
* @param array The array to map.
|
|
23
|
-
* @param mapfn The callback used to map the result into one or more values.
|
|
24
|
-
*/
|
|
25
|
-
export declare function flatMap<T, U>(array: readonly T[] | undefined, mapfn: (x: T, i: number) => U | readonly U[] | undefined): readonly U[];
|
|
26
|
-
export declare function some<T>(array: readonly T[] | undefined): array is readonly T[];
|
|
27
|
-
export declare function some<T>(array: readonly T[] | undefined, predicate: (value: T) => boolean): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Returns a new sorted array.
|
|
30
|
-
*/
|
|
31
|
-
export declare function sort<T>(array: readonly T[], comparer?: Comparer<T>): SortedReadonlyArray<T>;
|
|
32
|
-
/**
|
|
33
|
-
* Returns the last element of an array if non-empty, `undefined` otherwise.
|
|
34
|
-
*/
|
|
35
|
-
export declare function lastOrUndefined<T>(array: readonly T[] | undefined): T | undefined;
|
|
36
|
-
export declare function last<T>(array: readonly T[]): T;
|
|
37
|
-
/**
|
|
38
|
-
* Compare the equality of two strings using a case-sensitive ordinal comparison.
|
|
39
|
-
*
|
|
40
|
-
* Case-sensitive comparisons compare both strings one code-point at a time using the integer
|
|
41
|
-
* value of each code-point after applying `toUpperCase` to each string. We always map both
|
|
42
|
-
* strings to their upper-case form as some unicode characters do not properly round-trip to
|
|
43
|
-
* lowercase (such as `ẞ` (German sharp capital s)).
|
|
44
|
-
*/
|
|
45
|
-
export declare function equateStringsCaseInsensitive(a: string, b: string): boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Compare the equality of two strings using a case-sensitive ordinal comparison.
|
|
48
|
-
*
|
|
49
|
-
* Case-sensitive comparisons compare both strings one code-point at a time using the
|
|
50
|
-
* integer value of each code-point.
|
|
51
|
-
*/
|
|
52
|
-
export declare function equateStringsCaseSensitive(a: string, b: string): boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Compare two strings using a case-insensitive ordinal comparison.
|
|
55
|
-
*
|
|
56
|
-
* Ordinal comparisons are based on the difference between the unicode code points of both
|
|
57
|
-
* strings. Characters with multiple unicode representations are considered unequal. Ordinal
|
|
58
|
-
* comparisons provide predictable ordering, but place "a" after "B".
|
|
59
|
-
*
|
|
60
|
-
* Case-insensitive comparisons compare both strings one code-point at a time using the integer
|
|
61
|
-
* value of each code-point after applying `toUpperCase` to each string. We always map both
|
|
62
|
-
* strings to their upper-case form as some unicode characters do not properly round-trip to
|
|
63
|
-
* lowercase (such as `ẞ` (German sharp capital s)).
|
|
64
|
-
*/
|
|
65
|
-
declare function compareStringsCaseInsensitive(a: string, b: string): Comparison;
|
|
66
|
-
/**
|
|
67
|
-
* Compare two strings using a case-sensitive ordinal comparison.
|
|
68
|
-
*
|
|
69
|
-
* Ordinal comparisons are based on the difference between the unicode code points of both
|
|
70
|
-
* strings. Characters with multiple unicode representations are considered unequal. Ordinal
|
|
71
|
-
* comparisons provide predictable ordering, but place "a" after "B".
|
|
72
|
-
*
|
|
73
|
-
* Case-sensitive comparisons compare both strings one code-point at a time using the integer
|
|
74
|
-
* value of each code-point.
|
|
75
|
-
*/
|
|
76
|
-
export declare function compareStringsCaseSensitive(a: string | undefined, b: string | undefined): Comparison;
|
|
77
|
-
export declare function getStringComparer(ignoreCase?: boolean): typeof compareStringsCaseInsensitive;
|
|
78
|
-
export declare function endsWith(str: string, suffix: string): boolean;
|
|
79
|
-
export declare function stringContains(str: string, substring: string): boolean;
|
|
80
|
-
type GetCanonicalFileName = (fileName: string) => string;
|
|
81
|
-
export declare function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): GetCanonicalFileName;
|
|
82
|
-
export declare function startsWith(str: string, prefix: string): boolean;
|
|
83
|
-
export {};
|