@vscode/test-web 0.0.17 → 0.0.21

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.
@@ -11,189 +11,189 @@
11
11
  /***/ ((module) => {
12
12
 
13
13
  "use strict";
14
- module.exports = require("vscode");;
14
+ module.exports = require("vscode");
15
15
 
16
16
  /***/ }),
17
17
  /* 3 */
18
18
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
19
19
 
20
20
  "use strict";
21
-
22
- /*---------------------------------------------------------------------------------------------
23
- * Copyright (c) Microsoft Corporation. All rights reserved.
24
- * Licensed under the MIT License. See License.txt in the project root for license information.
25
- *--------------------------------------------------------------------------------------------*/
26
- Object.defineProperty(exports, "__esModule", ({ value: true }));
27
- exports.MemFileSystemProvider = void 0;
28
- const vscode_1 = __webpack_require__(2);
29
- const vscode_uri_1 = __webpack_require__(4);
30
- function newFileStat(type, size) {
31
- return Promise.resolve({ type, ctime: Date.now(), mtime: Date.now(), size });
32
- }
33
- function modifiedFileStat(stats, size) {
34
- return Promise.resolve({ type: stats.type, ctime: stats.ctime, mtime: Date.now(), size: size !== null && size !== void 0 ? size : stats.size });
35
- }
36
- class MemFileSystemProvider {
37
- constructor(scheme, root) {
38
- this.scheme = scheme;
39
- this.root = root;
40
- // --- manage file events
41
- this._onDidChangeFile = new vscode_1.EventEmitter();
42
- this.onDidChangeFile = this._onDidChangeFile.event;
43
- this._bufferedChanges = [];
44
- }
45
- // --- manage file metadata
46
- async stat(resource) {
47
- const entry = await this._lookup(resource, false);
48
- return entry.stats;
49
- }
50
- async readDirectory(resource) {
51
- const entry = await this._lookupAsDirectory(resource, false);
52
- const entries = await entry.entries;
53
- const result = [];
54
- entries.forEach((child, name) => result.push([name, child.type]));
55
- return result;
56
- }
57
- // --- manage file contents
58
- async readFile(resource) {
59
- const entry = await this._lookupAsFile(resource, false);
60
- return entry.content;
61
- }
62
- async writeFile(uri, content, opts) {
63
- const basename = vscode_uri_1.Utils.basename(uri);
64
- const parent = await this._lookupParentDirectory(uri);
65
- const entries = await parent.entries;
66
- let entry = entries.get(basename);
67
- if (entry && entry.type === vscode_1.FileType.Directory) {
68
- throw vscode_1.FileSystemError.FileIsADirectory(uri);
69
- }
70
- if (!entry && !opts.create) {
71
- throw vscode_1.FileSystemError.FileNotFound(uri);
72
- }
73
- if (entry && opts.create && !opts.overwrite) {
74
- throw vscode_1.FileSystemError.FileExists(uri);
75
- }
76
- const stats = newFileStat(vscode_1.FileType.File, content.byteLength);
77
- if (!entry) {
78
- entry = { type: vscode_1.FileType.File, name: basename, stats, content: Promise.resolve(content) };
79
- entries.set(basename, entry);
80
- this._fireSoon({ type: vscode_1.FileChangeType.Created, uri });
81
- }
82
- else {
83
- entry.stats = stats;
84
- entry.content = Promise.resolve(content);
85
- }
86
- this._fireSoon({ type: vscode_1.FileChangeType.Changed, uri });
87
- }
88
- // --- manage files/folders
89
- async rename(from, to, opts) {
90
- if (!opts.overwrite && await this._lookup(to, true)) {
91
- throw vscode_1.FileSystemError.FileExists(to);
92
- }
93
- const entry = await this._lookup(from, false);
94
- const oldParent = await this._lookupParentDirectory(from);
95
- const newParent = await this._lookupParentDirectory(to);
96
- const newName = vscode_uri_1.Utils.basename(to);
97
- const oldParentEntries = await oldParent.entries;
98
- oldParentEntries.delete(entry.name);
99
- entry.name = newName;
100
- const newParentEntries = await newParent.entries;
101
- newParentEntries.set(newName, entry);
102
- this._fireSoon({ type: vscode_1.FileChangeType.Deleted, uri: from }, { type: vscode_1.FileChangeType.Created, uri: to });
103
- }
104
- async delete(uri, opts) {
105
- const dirname = vscode_uri_1.Utils.dirname(uri);
106
- const basename = vscode_uri_1.Utils.basename(uri);
107
- const parent = await this._lookupAsDirectory(dirname, false);
108
- const parentEntries = await parent.entries;
109
- if (parentEntries.has(basename)) {
110
- parentEntries.delete(basename);
111
- parent.stats = newFileStat(parent.type, -1);
112
- this._fireSoon({ type: vscode_1.FileChangeType.Changed, uri: dirname }, { uri, type: vscode_1.FileChangeType.Deleted });
113
- }
114
- }
115
- async createDirectory(uri) {
116
- const basename = vscode_uri_1.Utils.basename(uri);
117
- const dirname = vscode_uri_1.Utils.dirname(uri);
118
- const parent = await this._lookupAsDirectory(dirname, false);
119
- const parentEntries = await parent.entries;
120
- const entry = { type: vscode_1.FileType.Directory, name: basename, stats: newFileStat(vscode_1.FileType.Directory, 0), entries: Promise.resolve(new Map()) };
121
- parentEntries.set(entry.name, entry);
122
- const stats = await parent.stats;
123
- parent.stats = modifiedFileStat(stats, stats.size + 1);
124
- this._fireSoon({ type: vscode_1.FileChangeType.Changed, uri: dirname }, { type: vscode_1.FileChangeType.Created, uri });
125
- }
126
- async _lookup(uri, silent) {
127
- if (uri.scheme !== this.scheme) {
128
- if (!silent) {
129
- throw vscode_1.FileSystemError.FileNotFound(uri);
130
- }
131
- else {
132
- return undefined;
133
- }
134
- }
135
- let entry = this.root;
136
- const parts = uri.path.split('/');
137
- for (const part of parts) {
138
- if (!part) {
139
- continue;
140
- }
141
- let child;
142
- if (entry.type === vscode_1.FileType.Directory) {
143
- child = (await entry.entries).get(part);
144
- }
145
- if (!child) {
146
- if (!silent) {
147
- throw vscode_1.FileSystemError.FileNotFound(uri);
148
- }
149
- else {
150
- return undefined;
151
- }
152
- }
153
- entry = child;
154
- }
155
- return entry;
156
- }
157
- async _lookupAsDirectory(uri, silent) {
158
- const entry = await this._lookup(uri, silent);
159
- if ((entry === null || entry === void 0 ? void 0 : entry.type) === vscode_1.FileType.Directory) {
160
- return entry;
161
- }
162
- throw vscode_1.FileSystemError.FileNotADirectory(uri);
163
- }
164
- async _lookupAsFile(uri, silent) {
165
- const entry = await this._lookup(uri, silent);
166
- if (!entry) {
167
- throw vscode_1.FileSystemError.FileNotFound(uri);
168
- }
169
- if (entry.type === vscode_1.FileType.File) {
170
- return entry;
171
- }
172
- throw vscode_1.FileSystemError.FileIsADirectory(uri);
173
- }
174
- _lookupParentDirectory(uri) {
175
- const dirname = vscode_uri_1.Utils.dirname(uri);
176
- return this._lookupAsDirectory(dirname, false);
177
- }
178
- watch(resource, opts) {
179
- // ignore, fires for all changes...
180
- return vscode_1.Disposable.from();
181
- }
182
- _fireSoon(...changes) {
183
- this._bufferedChanges.push(...changes);
184
- if (this._fireSoonHandle) {
185
- clearTimeout(this._fireSoonHandle);
186
- }
187
- this._fireSoonHandle = setTimeout(() => {
188
- this._onDidChangeFile.fire(this._bufferedChanges);
189
- this._bufferedChanges.length = 0;
190
- }, 5);
191
- }
192
- dispose() {
193
- this._onDidChangeFile.dispose();
194
- }
195
- }
196
- exports.MemFileSystemProvider = MemFileSystemProvider;
21
+
22
+ /*---------------------------------------------------------------------------------------------
23
+ * Copyright (c) Microsoft Corporation. All rights reserved.
24
+ * Licensed under the MIT License. See License.txt in the project root for license information.
25
+ *--------------------------------------------------------------------------------------------*/
26
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
27
+ exports.MemFileSystemProvider = void 0;
28
+ const vscode_1 = __webpack_require__(2);
29
+ const vscode_uri_1 = __webpack_require__(4);
30
+ function newFileStat(type, size) {
31
+ return Promise.resolve({ type, ctime: Date.now(), mtime: Date.now(), size });
32
+ }
33
+ function modifiedFileStat(stats, size) {
34
+ return Promise.resolve({ type: stats.type, ctime: stats.ctime, mtime: Date.now(), size: size !== null && size !== void 0 ? size : stats.size });
35
+ }
36
+ class MemFileSystemProvider {
37
+ constructor(scheme, root) {
38
+ this.scheme = scheme;
39
+ this.root = root;
40
+ // --- manage file events
41
+ this._onDidChangeFile = new vscode_1.EventEmitter();
42
+ this.onDidChangeFile = this._onDidChangeFile.event;
43
+ this._bufferedChanges = [];
44
+ }
45
+ // --- manage file metadata
46
+ async stat(resource) {
47
+ const entry = await this._lookup(resource, false);
48
+ return entry.stats;
49
+ }
50
+ async readDirectory(resource) {
51
+ const entry = await this._lookupAsDirectory(resource, false);
52
+ const entries = await entry.entries;
53
+ const result = [];
54
+ entries.forEach((child, name) => result.push([name, child.type]));
55
+ return result;
56
+ }
57
+ // --- manage file contents
58
+ async readFile(resource) {
59
+ const entry = await this._lookupAsFile(resource, false);
60
+ return entry.content;
61
+ }
62
+ async writeFile(uri, content, opts) {
63
+ const basename = vscode_uri_1.Utils.basename(uri);
64
+ const parent = await this._lookupParentDirectory(uri);
65
+ const entries = await parent.entries;
66
+ let entry = entries.get(basename);
67
+ if (entry && entry.type === vscode_1.FileType.Directory) {
68
+ throw vscode_1.FileSystemError.FileIsADirectory(uri);
69
+ }
70
+ if (!entry && !opts.create) {
71
+ throw vscode_1.FileSystemError.FileNotFound(uri);
72
+ }
73
+ if (entry && opts.create && !opts.overwrite) {
74
+ throw vscode_1.FileSystemError.FileExists(uri);
75
+ }
76
+ const stats = newFileStat(vscode_1.FileType.File, content.byteLength);
77
+ if (!entry) {
78
+ entry = { type: vscode_1.FileType.File, name: basename, stats, content: Promise.resolve(content) };
79
+ entries.set(basename, entry);
80
+ this._fireSoon({ type: vscode_1.FileChangeType.Created, uri });
81
+ }
82
+ else {
83
+ entry.stats = stats;
84
+ entry.content = Promise.resolve(content);
85
+ }
86
+ this._fireSoon({ type: vscode_1.FileChangeType.Changed, uri });
87
+ }
88
+ // --- manage files/folders
89
+ async rename(from, to, opts) {
90
+ if (!opts.overwrite && await this._lookup(to, true)) {
91
+ throw vscode_1.FileSystemError.FileExists(to);
92
+ }
93
+ const entry = await this._lookup(from, false);
94
+ const oldParent = await this._lookupParentDirectory(from);
95
+ const newParent = await this._lookupParentDirectory(to);
96
+ const newName = vscode_uri_1.Utils.basename(to);
97
+ const oldParentEntries = await oldParent.entries;
98
+ oldParentEntries.delete(entry.name);
99
+ entry.name = newName;
100
+ const newParentEntries = await newParent.entries;
101
+ newParentEntries.set(newName, entry);
102
+ this._fireSoon({ type: vscode_1.FileChangeType.Deleted, uri: from }, { type: vscode_1.FileChangeType.Created, uri: to });
103
+ }
104
+ async delete(uri, opts) {
105
+ const dirname = vscode_uri_1.Utils.dirname(uri);
106
+ const basename = vscode_uri_1.Utils.basename(uri);
107
+ const parent = await this._lookupAsDirectory(dirname, false);
108
+ const parentEntries = await parent.entries;
109
+ if (parentEntries.has(basename)) {
110
+ parentEntries.delete(basename);
111
+ parent.stats = newFileStat(parent.type, -1);
112
+ this._fireSoon({ type: vscode_1.FileChangeType.Changed, uri: dirname }, { uri, type: vscode_1.FileChangeType.Deleted });
113
+ }
114
+ }
115
+ async createDirectory(uri) {
116
+ const basename = vscode_uri_1.Utils.basename(uri);
117
+ const dirname = vscode_uri_1.Utils.dirname(uri);
118
+ const parent = await this._lookupAsDirectory(dirname, false);
119
+ const parentEntries = await parent.entries;
120
+ const entry = { type: vscode_1.FileType.Directory, name: basename, stats: newFileStat(vscode_1.FileType.Directory, 0), entries: Promise.resolve(new Map()) };
121
+ parentEntries.set(entry.name, entry);
122
+ const stats = await parent.stats;
123
+ parent.stats = modifiedFileStat(stats, stats.size + 1);
124
+ this._fireSoon({ type: vscode_1.FileChangeType.Changed, uri: dirname }, { type: vscode_1.FileChangeType.Created, uri });
125
+ }
126
+ async _lookup(uri, silent) {
127
+ if (uri.scheme !== this.scheme) {
128
+ if (!silent) {
129
+ throw vscode_1.FileSystemError.FileNotFound(uri);
130
+ }
131
+ else {
132
+ return undefined;
133
+ }
134
+ }
135
+ let entry = this.root;
136
+ const parts = uri.path.split('/');
137
+ for (const part of parts) {
138
+ if (!part) {
139
+ continue;
140
+ }
141
+ let child;
142
+ if (entry.type === vscode_1.FileType.Directory) {
143
+ child = (await entry.entries).get(part);
144
+ }
145
+ if (!child) {
146
+ if (!silent) {
147
+ throw vscode_1.FileSystemError.FileNotFound(uri);
148
+ }
149
+ else {
150
+ return undefined;
151
+ }
152
+ }
153
+ entry = child;
154
+ }
155
+ return entry;
156
+ }
157
+ async _lookupAsDirectory(uri, silent) {
158
+ const entry = await this._lookup(uri, silent);
159
+ if ((entry === null || entry === void 0 ? void 0 : entry.type) === vscode_1.FileType.Directory) {
160
+ return entry;
161
+ }
162
+ throw vscode_1.FileSystemError.FileNotADirectory(uri);
163
+ }
164
+ async _lookupAsFile(uri, silent) {
165
+ const entry = await this._lookup(uri, silent);
166
+ if (!entry) {
167
+ throw vscode_1.FileSystemError.FileNotFound(uri);
168
+ }
169
+ if (entry.type === vscode_1.FileType.File) {
170
+ return entry;
171
+ }
172
+ throw vscode_1.FileSystemError.FileIsADirectory(uri);
173
+ }
174
+ _lookupParentDirectory(uri) {
175
+ const dirname = vscode_uri_1.Utils.dirname(uri);
176
+ return this._lookupAsDirectory(dirname, false);
177
+ }
178
+ watch(resource, opts) {
179
+ // ignore, fires for all changes...
180
+ return vscode_1.Disposable.from();
181
+ }
182
+ _fireSoon(...changes) {
183
+ this._bufferedChanges.push(...changes);
184
+ if (this._fireSoonHandle) {
185
+ clearTimeout(this._fireSoonHandle);
186
+ }
187
+ this._fireSoonHandle = setTimeout(() => {
188
+ this._onDidChangeFile.fire(this._bufferedChanges);
189
+ this._bufferedChanges.length = 0;
190
+ }, 5);
191
+ }
192
+ dispose() {
193
+ this._onDidChangeFile.dispose();
194
+ }
195
+ }
196
+ exports.MemFileSystemProvider = MemFileSystemProvider;
197
197
 
198
198
 
199
199
  /***/ }),
@@ -462,130 +462,130 @@ var __webpack_exports__ = {};
462
462
  (() => {
463
463
  "use strict";
464
464
  var exports = __webpack_exports__;
465
-
466
- /*---------------------------------------------------------------------------------------------
467
- * Copyright (c) Microsoft Corporation. All rights reserved.
468
- * Licensed under the MIT License. See License.txt in the project root for license information.
469
- *--------------------------------------------------------------------------------------------*/
470
- Object.defineProperty(exports, "__esModule", ({ value: true }));
471
- exports.activate = void 0;
472
- const request_light_1 = __webpack_require__(1);
473
- const vscode_1 = __webpack_require__(2);
474
- const fsProvider_1 = __webpack_require__(3);
475
- const SCHEME = 'vscode-test-web';
476
- function activate(context) {
477
- const serverUri = context.extensionUri.with({ path: '/static/mount', query: undefined });
478
- const serverBackedRootDirectory = new ServerBackedDirectory(serverUri, '');
479
- const disposable = vscode_1.workspace.registerFileSystemProvider(SCHEME, new fsProvider_1.MemFileSystemProvider(SCHEME, serverBackedRootDirectory));
480
- context.subscriptions.push(disposable);
481
- console.log(`vscode-test-web-support fs provider registers for ${SCHEME}, initial content from ${serverUri.toString()}`);
482
- }
483
- exports.activate = activate;
484
- class ServerBackedFile {
485
- constructor(_serverUri, name) {
486
- this._serverUri = _serverUri;
487
- this.name = name;
488
- this.type = vscode_1.FileType.File;
489
- }
490
- get stats() {
491
- if (this._stats === undefined) {
492
- this._stats = getStats(this._serverUri);
493
- }
494
- return this._stats;
495
- }
496
- set stats(stats) {
497
- this._stats = stats;
498
- }
499
- get content() {
500
- if (this._content === undefined) {
501
- this._content = getContent(this._serverUri);
502
- }
503
- return this._content;
504
- }
505
- set content(content) {
506
- this._content = content;
507
- }
508
- }
509
- class ServerBackedDirectory {
510
- constructor(_serverUri, name) {
511
- this._serverUri = _serverUri;
512
- this.name = name;
513
- this.type = vscode_1.FileType.Directory;
514
- }
515
- get stats() {
516
- if (this._stats === undefined) {
517
- this._stats = getStats(this._serverUri);
518
- }
519
- return this._stats;
520
- }
521
- set stats(stats) {
522
- this._stats = stats;
523
- }
524
- get entries() {
525
- if (this._entries === undefined) {
526
- this._entries = getEntries(this._serverUri);
527
- }
528
- return this._entries;
529
- }
530
- set entries(entries) {
531
- this._entries = entries;
532
- }
533
- }
534
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
535
- function isEntry(e) {
536
- return e && (e.type === vscode_1.FileType.Directory || e.type === vscode_1.FileType.File) && typeof e.name === 'string' && e.name.length > 0;
537
- }
538
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
539
- function isStat(e) {
540
- return e && (e.type === vscode_1.FileType.Directory || e.type === vscode_1.FileType.File) && typeof e.ctime === 'number' && typeof e.mtime === 'number' && typeof e.size === 'number';
541
- }
542
- async function getEntries(serverUri) {
543
- const url = serverUri.with({ query: 'readdir' }).toString();
544
- const response = await request_light_1.xhr({ url });
545
- if (response.status === 200 && response.status <= 204) {
546
- try {
547
- const res = JSON.parse(response.responseText);
548
- if (Array.isArray(res)) {
549
- const entries = new Map();
550
- for (const r of res) {
551
- if (isEntry(r)) {
552
- const childPath = vscode_1.Uri.joinPath(serverUri, r.name);
553
- const newEntry = r.type === vscode_1.FileType.Directory ? new ServerBackedDirectory(childPath, r.name) : new ServerBackedFile(childPath, r.name);
554
- entries.set(newEntry.name, newEntry);
555
- }
556
- }
557
- return entries;
558
- }
559
- }
560
- catch {
561
- // ignore
562
- }
563
- console.log(`Invalid server response format for ${url.toString()}.`);
564
- }
565
- else {
566
- console.log(`Invalid server response for ${url.toString()}. Status ${response.status}`);
567
- }
568
- return new Map();
569
- }
570
- async function getStats(serverUri) {
571
- const url = serverUri.with({ query: 'stat' }).toString();
572
- const response = await request_light_1.xhr({ url });
573
- if (response.status === 200 && response.status <= 204) {
574
- const res = JSON.parse(response.responseText);
575
- if (isStat(res)) {
576
- return res;
577
- }
578
- throw vscode_1.FileSystemError.FileNotFound(`Invalid server response for ${serverUri.toString()}.`);
579
- }
580
- throw vscode_1.FileSystemError.FileNotFound(`Invalid server response for ${serverUri.toString()}. Status ${response.status}.`);
581
- }
582
- async function getContent(serverUri) {
583
- const response = await request_light_1.xhr({ url: serverUri.toString() });
584
- if (response.status >= 200 && response.status <= 204) {
585
- return response.body;
586
- }
587
- throw vscode_1.FileSystemError.FileNotFound(`Invalid server response for ${serverUri.toString()}. Status ${response.status}.`);
588
- }
465
+
466
+ /*---------------------------------------------------------------------------------------------
467
+ * Copyright (c) Microsoft Corporation. All rights reserved.
468
+ * Licensed under the MIT License. See License.txt in the project root for license information.
469
+ *--------------------------------------------------------------------------------------------*/
470
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
471
+ exports.activate = void 0;
472
+ const request_light_1 = __webpack_require__(1);
473
+ const vscode_1 = __webpack_require__(2);
474
+ const fsProvider_1 = __webpack_require__(3);
475
+ const SCHEME = 'vscode-test-web';
476
+ function activate(context) {
477
+ const serverUri = context.extensionUri.with({ path: '/static/mount', query: undefined });
478
+ const serverBackedRootDirectory = new ServerBackedDirectory(serverUri, '');
479
+ const disposable = vscode_1.workspace.registerFileSystemProvider(SCHEME, new fsProvider_1.MemFileSystemProvider(SCHEME, serverBackedRootDirectory));
480
+ context.subscriptions.push(disposable);
481
+ console.log(`vscode-test-web-support fs provider registers for ${SCHEME}, initial content from ${serverUri.toString()}`);
482
+ }
483
+ exports.activate = activate;
484
+ class ServerBackedFile {
485
+ constructor(_serverUri, name) {
486
+ this._serverUri = _serverUri;
487
+ this.name = name;
488
+ this.type = vscode_1.FileType.File;
489
+ }
490
+ get stats() {
491
+ if (this._stats === undefined) {
492
+ this._stats = getStats(this._serverUri);
493
+ }
494
+ return this._stats;
495
+ }
496
+ set stats(stats) {
497
+ this._stats = stats;
498
+ }
499
+ get content() {
500
+ if (this._content === undefined) {
501
+ this._content = getContent(this._serverUri);
502
+ }
503
+ return this._content;
504
+ }
505
+ set content(content) {
506
+ this._content = content;
507
+ }
508
+ }
509
+ class ServerBackedDirectory {
510
+ constructor(_serverUri, name) {
511
+ this._serverUri = _serverUri;
512
+ this.name = name;
513
+ this.type = vscode_1.FileType.Directory;
514
+ }
515
+ get stats() {
516
+ if (this._stats === undefined) {
517
+ this._stats = getStats(this._serverUri);
518
+ }
519
+ return this._stats;
520
+ }
521
+ set stats(stats) {
522
+ this._stats = stats;
523
+ }
524
+ get entries() {
525
+ if (this._entries === undefined) {
526
+ this._entries = getEntries(this._serverUri);
527
+ }
528
+ return this._entries;
529
+ }
530
+ set entries(entries) {
531
+ this._entries = entries;
532
+ }
533
+ }
534
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
535
+ function isEntry(e) {
536
+ return e && (e.type === vscode_1.FileType.Directory || e.type === vscode_1.FileType.File) && typeof e.name === 'string' && e.name.length > 0;
537
+ }
538
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
539
+ function isStat(e) {
540
+ return e && (e.type === vscode_1.FileType.Directory || e.type === vscode_1.FileType.File) && typeof e.ctime === 'number' && typeof e.mtime === 'number' && typeof e.size === 'number';
541
+ }
542
+ async function getEntries(serverUri) {
543
+ const url = serverUri.with({ query: 'readdir' }).toString();
544
+ const response = await (0, request_light_1.xhr)({ url });
545
+ if (response.status === 200 && response.status <= 204) {
546
+ try {
547
+ const res = JSON.parse(response.responseText);
548
+ if (Array.isArray(res)) {
549
+ const entries = new Map();
550
+ for (const r of res) {
551
+ if (isEntry(r)) {
552
+ const childPath = vscode_1.Uri.joinPath(serverUri, r.name);
553
+ const newEntry = r.type === vscode_1.FileType.Directory ? new ServerBackedDirectory(childPath, r.name) : new ServerBackedFile(childPath, r.name);
554
+ entries.set(newEntry.name, newEntry);
555
+ }
556
+ }
557
+ return entries;
558
+ }
559
+ }
560
+ catch {
561
+ // ignore
562
+ }
563
+ console.log(`Invalid server response format for ${url.toString()}.`);
564
+ }
565
+ else {
566
+ console.log(`Invalid server response for ${url.toString()}. Status ${response.status}`);
567
+ }
568
+ return new Map();
569
+ }
570
+ async function getStats(serverUri) {
571
+ const url = serverUri.with({ query: 'stat' }).toString();
572
+ const response = await (0, request_light_1.xhr)({ url });
573
+ if (response.status === 200 && response.status <= 204) {
574
+ const res = JSON.parse(response.responseText);
575
+ if (isStat(res)) {
576
+ return res;
577
+ }
578
+ throw vscode_1.FileSystemError.FileNotFound(`Invalid server response for ${serverUri.toString()}.`);
579
+ }
580
+ throw vscode_1.FileSystemError.FileNotFound(`Invalid server response for ${serverUri.toString()}. Status ${response.status}.`);
581
+ }
582
+ async function getContent(serverUri) {
583
+ const response = await (0, request_light_1.xhr)({ url: serverUri.toString() });
584
+ if (response.status >= 200 && response.status <= 204) {
585
+ return response.body;
586
+ }
587
+ throw vscode_1.FileSystemError.FileNotFound(`Invalid server response for ${serverUri.toString()}. Status ${response.status}.`);
588
+ }
589
589
 
590
590
  })();
591
591