@theia/vsx-registry 1.45.1 → 1.46.0-next.72
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/README.md +45 -45
- package/lib/browser/recommended-extensions/preference-provider-overrides.d.ts +17 -17
- package/lib/browser/recommended-extensions/preference-provider-overrides.js +95 -95
- package/lib/browser/recommended-extensions/recommended-extensions-json-schema.d.ts +14 -14
- package/lib/browser/recommended-extensions/recommended-extensions-json-schema.js +94 -94
- package/lib/browser/recommended-extensions/recommended-extensions-preference-contribution.d.ts +11 -11
- package/lib/browser/recommended-extensions/recommended-extensions-preference-contribution.js +59 -59
- package/lib/browser/vsx-extension-commands.d.ts +14 -13
- package/lib/browser/vsx-extension-commands.d.ts.map +1 -1
- package/lib/browser/vsx-extension-commands.js +68 -63
- package/lib/browser/vsx-extension-commands.js.map +1 -1
- package/lib/browser/vsx-extension-editor-manager.d.ts +9 -9
- package/lib/browser/vsx-extension-editor-manager.js +49 -49
- package/lib/browser/vsx-extension-editor.d.ts +21 -21
- package/lib/browser/vsx-extension-editor.js +109 -109
- package/lib/browser/vsx-extension.d.ts +146 -143
- package/lib/browser/vsx-extension.d.ts.map +1 -1
- package/lib/browser/vsx-extension.js +616 -596
- package/lib/browser/vsx-extension.js.map +1 -1
- package/lib/browser/vsx-extensions-contribution.d.ts +70 -60
- package/lib/browser/vsx-extensions-contribution.d.ts.map +1 -1
- package/lib/browser/vsx-extensions-contribution.js +375 -344
- package/lib/browser/vsx-extensions-contribution.js.map +1 -1
- package/lib/browser/vsx-extensions-model.d.ts +75 -72
- package/lib/browser/vsx-extensions-model.d.ts.map +1 -1
- package/lib/browser/vsx-extensions-model.js +437 -391
- package/lib/browser/vsx-extensions-model.js.map +1 -1
- package/lib/browser/vsx-extensions-preferences.d.ts +12 -0
- package/lib/browser/vsx-extensions-preferences.d.ts.map +1 -0
- package/lib/browser/vsx-extensions-preferences.js +47 -0
- package/lib/browser/vsx-extensions-preferences.js.map +1 -0
- package/lib/browser/vsx-extensions-search-bar.d.ts +22 -14
- package/lib/browser/vsx-extensions-search-bar.d.ts.map +1 -1
- package/lib/browser/vsx-extensions-search-bar.js +106 -75
- package/lib/browser/vsx-extensions-search-bar.js.map +1 -1
- package/lib/browser/vsx-extensions-search-model.d.ts +21 -21
- package/lib/browser/vsx-extensions-search-model.js +70 -70
- package/lib/browser/vsx-extensions-source.d.ts +19 -19
- package/lib/browser/vsx-extensions-source.js +102 -102
- package/lib/browser/vsx-extensions-view-container.d.ts +49 -49
- package/lib/browser/vsx-extensions-view-container.js +179 -179
- package/lib/browser/vsx-extensions-widget.d.ts +35 -34
- package/lib/browser/vsx-extensions-widget.d.ts.map +1 -1
- package/lib/browser/vsx-extensions-widget.js +164 -156
- package/lib/browser/vsx-extensions-widget.js.map +1 -1
- package/lib/browser/vsx-language-quick-pick-service.d.ts +15 -15
- package/lib/browser/vsx-language-quick-pick-service.js +121 -121
- package/lib/browser/vsx-registry-frontend-module.d.ts +4 -4
- package/lib/browser/vsx-registry-frontend-module.d.ts.map +1 -1
- package/lib/browser/vsx-registry-frontend-module.js +99 -97
- package/lib/browser/vsx-registry-frontend-module.js.map +1 -1
- package/lib/common/index.d.ts +3 -3
- package/lib/common/index.js +25 -25
- package/lib/common/ovsx-client-provider.d.ts +13 -13
- package/lib/common/ovsx-client-provider.js +29 -29
- package/lib/common/vsx-environment.d.ts +9 -9
- package/lib/common/vsx-environment.js +20 -20
- package/lib/common/vsx-extension-uri.d.ts +3 -3
- package/lib/common/vsx-extension-uri.js +20 -20
- package/lib/common/vsx-registry-common-module.d.ts +3 -3
- package/lib/common/vsx-registry-common-module.js +57 -57
- package/lib/node/vsx-cli.d.ts +9 -9
- package/lib/node/vsx-cli.js +41 -41
- package/lib/node/vsx-environment-impl.d.ts +14 -14
- package/lib/node/vsx-environment-impl.js +61 -61
- package/lib/node/vsx-extension-resolver.d.ts +20 -20
- package/lib/node/vsx-extension-resolver.js +154 -154
- package/lib/node/vsx-registry-backend-module.d.ts +3 -3
- package/lib/node/vsx-registry-backend-module.js +35 -35
- package/lib/package.spec.js +25 -25
- package/package.json +12 -12
- package/src/browser/recommended-extensions/preference-provider-overrides.ts +99 -99
- package/src/browser/recommended-extensions/recommended-extensions-json-schema.ts +74 -74
- package/src/browser/recommended-extensions/recommended-extensions-preference-contribution.ts +68 -68
- package/src/browser/style/extensions.svg +4 -4
- package/src/browser/style/index.css +436 -373
- package/src/browser/vsx-extension-commands.ts +68 -63
- package/src/browser/vsx-extension-editor-manager.ts +42 -42
- package/src/browser/vsx-extension-editor.tsx +96 -96
- package/src/browser/vsx-extension.tsx +704 -675
- package/src/browser/vsx-extensions-contribution.ts +361 -327
- package/src/browser/vsx-extensions-model.ts +436 -389
- package/src/browser/vsx-extensions-preferences.ts +58 -0
- package/src/browser/vsx-extensions-search-bar.tsx +107 -69
- package/src/browser/vsx-extensions-search-model.ts +61 -61
- package/src/browser/vsx-extensions-source.ts +83 -83
- package/src/browser/vsx-extensions-view-container.ts +179 -179
- package/src/browser/vsx-extensions-widget.tsx +165 -156
- package/src/browser/vsx-language-quick-pick-service.ts +110 -110
- package/src/browser/vsx-registry-frontend-module.ts +108 -106
- package/src/common/index.ts +19 -19
- package/src/common/ovsx-client-provider.ts +35 -35
- package/src/common/vsx-environment.ts +27 -27
- package/src/common/vsx-extension-uri.ts +20 -20
- package/src/common/vsx-registry-common-module.ts +63 -63
- package/src/node/vsx-cli.ts +38 -38
- package/src/node/vsx-environment-impl.ts +50 -50
- package/src/node/vsx-extension-resolver.ts +125 -125
- package/src/node/vsx-registry-backend-module.ts +35 -35
- package/src/package.spec.ts +29 -29
|
@@ -1,392 +1,438 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2020 TypeFox and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.VSXExtensionsModel = void 0;
|
|
28
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
29
|
-
const p_debounce_1 = require("p-debounce");
|
|
30
|
-
const markdownit = require("@theia/core/shared/markdown-it");
|
|
31
|
-
const DOMPurify = require("@theia/core/shared/dompurify");
|
|
32
|
-
const event_1 = require("@theia/core/lib/common/event");
|
|
33
|
-
const cancellation_1 = require("@theia/core/lib/common/cancellation");
|
|
34
|
-
const hosted_plugin_1 = require("@theia/plugin-ext/lib/hosted/browser/hosted-plugin");
|
|
35
|
-
const vsx_extension_1 = require("./vsx-extension");
|
|
36
|
-
const progress_service_1 = require("@theia/core/lib/common/progress-service");
|
|
37
|
-
const vsx_extensions_search_model_1 = require("./vsx-extensions-search-model");
|
|
38
|
-
const browser_1 = require("@theia/core/lib/browser");
|
|
39
|
-
const browser_2 = require("@theia/workspace/lib/browser");
|
|
40
|
-
const ovsx_types_1 = require("@theia/ovsx-client/lib/ovsx-types");
|
|
41
|
-
const ovsx_client_provider_1 = require("../common/ovsx-client-provider");
|
|
42
|
-
const request_1 = require("@theia/core/shared/@theia/request");
|
|
43
|
-
const ovsx_client_1 = require("@theia/ovsx-client");
|
|
44
|
-
let VSXExtensionsModel = class VSXExtensionsModel {
|
|
45
|
-
constructor() {
|
|
46
|
-
/**
|
|
47
|
-
* Single source for all extensions
|
|
48
|
-
*/
|
|
49
|
-
this.extensions = new Map();
|
|
50
|
-
this.onDidChangeEmitter = new event_1.Emitter();
|
|
51
|
-
this._installed = new Set();
|
|
52
|
-
this._recommended = new Set();
|
|
53
|
-
this._searchResult = new Set();
|
|
54
|
-
this.searchCancellationTokenSource = new cancellation_1.CancellationTokenSource();
|
|
55
|
-
this.updateSearchResult = (0, p_debounce_1.default)(async () => {
|
|
56
|
-
const { token } = this.resetSearchCancellationTokenSource();
|
|
57
|
-
await this.doUpdateSearchResult({ query: this.search.query, includeAllVersions: true }, token);
|
|
58
|
-
}, 500);
|
|
59
|
-
}
|
|
60
|
-
init() {
|
|
61
|
-
this.initialized = this.doInit().catch(console.error);
|
|
62
|
-
}
|
|
63
|
-
async doInit() {
|
|
64
|
-
await Promise.all([
|
|
65
|
-
this.initInstalled(),
|
|
66
|
-
this.initSearchResult(),
|
|
67
|
-
this.initRecommended(),
|
|
68
|
-
]);
|
|
69
|
-
}
|
|
70
|
-
get onDidChange() {
|
|
71
|
-
return this.onDidChangeEmitter.event;
|
|
72
|
-
}
|
|
73
|
-
get installed() {
|
|
74
|
-
return this._installed.values();
|
|
75
|
-
}
|
|
76
|
-
get searchError() {
|
|
77
|
-
return this._searchError;
|
|
78
|
-
}
|
|
79
|
-
get searchResult() {
|
|
80
|
-
return this._searchResult.values();
|
|
81
|
-
}
|
|
82
|
-
get recommended() {
|
|
83
|
-
return this._recommended.values();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return this.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
]
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2020 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.VSXExtensionsModel = void 0;
|
|
28
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
29
|
+
const p_debounce_1 = require("p-debounce");
|
|
30
|
+
const markdownit = require("@theia/core/shared/markdown-it");
|
|
31
|
+
const DOMPurify = require("@theia/core/shared/dompurify");
|
|
32
|
+
const event_1 = require("@theia/core/lib/common/event");
|
|
33
|
+
const cancellation_1 = require("@theia/core/lib/common/cancellation");
|
|
34
|
+
const hosted_plugin_1 = require("@theia/plugin-ext/lib/hosted/browser/hosted-plugin");
|
|
35
|
+
const vsx_extension_1 = require("./vsx-extension");
|
|
36
|
+
const progress_service_1 = require("@theia/core/lib/common/progress-service");
|
|
37
|
+
const vsx_extensions_search_model_1 = require("./vsx-extensions-search-model");
|
|
38
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
39
|
+
const browser_2 = require("@theia/workspace/lib/browser");
|
|
40
|
+
const ovsx_types_1 = require("@theia/ovsx-client/lib/ovsx-types");
|
|
41
|
+
const ovsx_client_provider_1 = require("../common/ovsx-client-provider");
|
|
42
|
+
const request_1 = require("@theia/core/shared/@theia/request");
|
|
43
|
+
const ovsx_client_1 = require("@theia/ovsx-client");
|
|
44
|
+
let VSXExtensionsModel = class VSXExtensionsModel {
|
|
45
|
+
constructor() {
|
|
46
|
+
/**
|
|
47
|
+
* Single source for all extensions
|
|
48
|
+
*/
|
|
49
|
+
this.extensions = new Map();
|
|
50
|
+
this.onDidChangeEmitter = new event_1.Emitter();
|
|
51
|
+
this._installed = new Set();
|
|
52
|
+
this._recommended = new Set();
|
|
53
|
+
this._searchResult = new Set();
|
|
54
|
+
this.searchCancellationTokenSource = new cancellation_1.CancellationTokenSource();
|
|
55
|
+
this.updateSearchResult = (0, p_debounce_1.default)(async () => {
|
|
56
|
+
const { token } = this.resetSearchCancellationTokenSource();
|
|
57
|
+
await this.doUpdateSearchResult({ query: this.search.query, includeAllVersions: true }, token);
|
|
58
|
+
}, 500);
|
|
59
|
+
}
|
|
60
|
+
init() {
|
|
61
|
+
this.initialized = this.doInit().catch(console.error);
|
|
62
|
+
}
|
|
63
|
+
async doInit() {
|
|
64
|
+
await Promise.all([
|
|
65
|
+
this.initInstalled(),
|
|
66
|
+
this.initSearchResult(),
|
|
67
|
+
this.initRecommended(),
|
|
68
|
+
]);
|
|
69
|
+
}
|
|
70
|
+
get onDidChange() {
|
|
71
|
+
return this.onDidChangeEmitter.event;
|
|
72
|
+
}
|
|
73
|
+
get installed() {
|
|
74
|
+
return this._installed.values();
|
|
75
|
+
}
|
|
76
|
+
get searchError() {
|
|
77
|
+
return this._searchError;
|
|
78
|
+
}
|
|
79
|
+
get searchResult() {
|
|
80
|
+
return this._searchResult.values();
|
|
81
|
+
}
|
|
82
|
+
get recommended() {
|
|
83
|
+
return this._recommended.values();
|
|
84
|
+
}
|
|
85
|
+
setOnlyShowVerifiedExtensions(bool) {
|
|
86
|
+
if (this.preferences.get('extensions.onlyShowVerifiedExtensions') !== bool) {
|
|
87
|
+
this.preferences.updateValue('extensions.onlyShowVerifiedExtensions', bool);
|
|
88
|
+
}
|
|
89
|
+
this.updateSearchResult();
|
|
90
|
+
}
|
|
91
|
+
isInstalled(id) {
|
|
92
|
+
return this._installed.has(id);
|
|
93
|
+
}
|
|
94
|
+
getExtension(id) {
|
|
95
|
+
return this.extensions.get(id);
|
|
96
|
+
}
|
|
97
|
+
resolve(id) {
|
|
98
|
+
return this.doChange(async () => {
|
|
99
|
+
await this.initialized;
|
|
100
|
+
const extension = await this.refresh(id);
|
|
101
|
+
if (!extension) {
|
|
102
|
+
throw new Error(`Failed to resolve ${id} extension.`);
|
|
103
|
+
}
|
|
104
|
+
if (extension.readmeUrl) {
|
|
105
|
+
try {
|
|
106
|
+
const rawReadme = request_1.RequestContext.asText(await this.request.request({ url: extension.readmeUrl }));
|
|
107
|
+
const readme = this.compileReadme(rawReadme);
|
|
108
|
+
extension.update({ readme });
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
if (!ovsx_types_1.VSXResponseError.is(e) || e.statusCode !== 404) {
|
|
112
|
+
console.error(`[${id}]: failed to compile readme, reason:`, e);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return extension;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async initInstalled() {
|
|
120
|
+
await this.pluginSupport.willStart;
|
|
121
|
+
this.pluginSupport.onDidChangePlugins(() => this.updateInstalled());
|
|
122
|
+
try {
|
|
123
|
+
await this.updateInstalled();
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
console.error(e);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async initSearchResult() {
|
|
130
|
+
this.search.onDidChangeQuery(() => this.updateSearchResult());
|
|
131
|
+
try {
|
|
132
|
+
await this.updateSearchResult();
|
|
133
|
+
}
|
|
134
|
+
catch (e) {
|
|
135
|
+
console.error(e);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async initRecommended() {
|
|
139
|
+
this.preferences.onPreferenceChanged(change => {
|
|
140
|
+
if (change.preferenceName === 'extensions') {
|
|
141
|
+
this.updateRecommended();
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
await this.preferences.ready;
|
|
145
|
+
try {
|
|
146
|
+
await this.updateRecommended();
|
|
147
|
+
}
|
|
148
|
+
catch (e) {
|
|
149
|
+
console.error(e);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
resetSearchCancellationTokenSource() {
|
|
153
|
+
this.searchCancellationTokenSource.cancel();
|
|
154
|
+
return this.searchCancellationTokenSource = new cancellation_1.CancellationTokenSource();
|
|
155
|
+
}
|
|
156
|
+
setExtension(id) {
|
|
157
|
+
let extension = this.extensions.get(id);
|
|
158
|
+
if (!extension) {
|
|
159
|
+
extension = this.extensionFactory({ id });
|
|
160
|
+
this.extensions.set(id, extension);
|
|
161
|
+
}
|
|
162
|
+
return extension;
|
|
163
|
+
}
|
|
164
|
+
doChange(task, token = cancellation_1.CancellationToken.None) {
|
|
165
|
+
return this.progressService.withProgress('', 'extensions', async () => {
|
|
166
|
+
if (token && token.isCancellationRequested) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const result = await task();
|
|
170
|
+
if (token && token.isCancellationRequested) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
this.onDidChangeEmitter.fire();
|
|
174
|
+
return result;
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
doUpdateSearchResult(param, token) {
|
|
178
|
+
return this.doChange(async () => {
|
|
179
|
+
this._searchResult = new Set();
|
|
180
|
+
if (!param.query) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const client = await this.clientProvider();
|
|
184
|
+
const result = await client.search(param);
|
|
185
|
+
this._searchError = result.error;
|
|
186
|
+
if (token.isCancellationRequested) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
for (const data of result.extensions) {
|
|
190
|
+
const id = data.namespace.toLowerCase() + '.' + data.name.toLowerCase();
|
|
191
|
+
const allVersions = this.vsxApiFilter.getLatestCompatibleVersion(data);
|
|
192
|
+
if (!allVersions) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if (this.preferences.get('extensions.onlyShowVerifiedExtensions')) {
|
|
196
|
+
this.fetchVerifiedStatus(id, client, allVersions).then(verified => {
|
|
197
|
+
this.doChange(() => {
|
|
198
|
+
this.addExtensions(data, id, allVersions, !!verified);
|
|
199
|
+
return Promise.resolve();
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
this.addExtensions(data, id, allVersions);
|
|
205
|
+
this.fetchVerifiedStatus(id, client, allVersions).then(verified => {
|
|
206
|
+
this.doChange(() => {
|
|
207
|
+
let extension = this.getExtension(id);
|
|
208
|
+
extension = this.setExtension(id);
|
|
209
|
+
extension.update(Object.assign({
|
|
210
|
+
verified: verified
|
|
211
|
+
}));
|
|
212
|
+
return Promise.resolve();
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}, token);
|
|
218
|
+
}
|
|
219
|
+
async fetchVerifiedStatus(id, client, allVersions) {
|
|
220
|
+
var _a, _b;
|
|
221
|
+
const res = await client.query({ extensionId: id, extensionVersion: allVersions.version, includeAllVersions: true });
|
|
222
|
+
let verified = (_a = res.extensions) === null || _a === void 0 ? void 0 : _a[0].verified;
|
|
223
|
+
if (!verified && ((_b = res.extensions) === null || _b === void 0 ? void 0 : _b[0].publishedBy.loginName) === 'open-vsx') {
|
|
224
|
+
verified = true;
|
|
225
|
+
}
|
|
226
|
+
return verified;
|
|
227
|
+
}
|
|
228
|
+
addExtensions(data, id, allVersions, verified) {
|
|
229
|
+
if (!this.preferences.get('extensions.onlyShowVerifiedExtensions') || verified) {
|
|
230
|
+
const extension = this.setExtension(id);
|
|
231
|
+
extension.update(Object.assign(data, {
|
|
232
|
+
publisher: data.namespace,
|
|
233
|
+
downloadUrl: data.files.download,
|
|
234
|
+
iconUrl: data.files.icon,
|
|
235
|
+
readmeUrl: data.files.readme,
|
|
236
|
+
licenseUrl: data.files.license,
|
|
237
|
+
version: allVersions.version,
|
|
238
|
+
verified: verified
|
|
239
|
+
}));
|
|
240
|
+
this._searchResult.add(id);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
async updateInstalled() {
|
|
244
|
+
const prevInstalled = this._installed;
|
|
245
|
+
return this.doChange(async () => {
|
|
246
|
+
const plugins = this.pluginSupport.plugins;
|
|
247
|
+
const currInstalled = new Set();
|
|
248
|
+
const refreshing = [];
|
|
249
|
+
for (const plugin of plugins) {
|
|
250
|
+
if (plugin.model.engine.type === 'vscode') {
|
|
251
|
+
const version = plugin.model.version;
|
|
252
|
+
const id = plugin.model.id;
|
|
253
|
+
this._installed.delete(id);
|
|
254
|
+
const extension = this.setExtension(id);
|
|
255
|
+
currInstalled.add(extension.id);
|
|
256
|
+
refreshing.push(this.refresh(id, version));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
for (const id of this._installed) {
|
|
260
|
+
const extension = this.getExtension(id);
|
|
261
|
+
if (!extension) {
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
refreshing.push(this.refresh(id, extension.version));
|
|
265
|
+
}
|
|
266
|
+
const installed = new Set([...prevInstalled, ...currInstalled]);
|
|
267
|
+
const installedSorted = Array.from(installed).sort((a, b) => this.compareExtensions(a, b));
|
|
268
|
+
this._installed = new Set(installedSorted.values());
|
|
269
|
+
await Promise.all(refreshing);
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
updateRecommended() {
|
|
273
|
+
return this.doChange(async () => {
|
|
274
|
+
const allRecommendations = new Set();
|
|
275
|
+
const allUnwantedRecommendations = new Set();
|
|
276
|
+
const updateRecommendationsForScope = (scope, root) => {
|
|
277
|
+
const { recommendations, unwantedRecommendations } = this.getRecommendationsForScope(scope, root);
|
|
278
|
+
recommendations.forEach(recommendation => allRecommendations.add(recommendation));
|
|
279
|
+
unwantedRecommendations.forEach(unwantedRecommendation => allUnwantedRecommendations.add(unwantedRecommendation));
|
|
280
|
+
};
|
|
281
|
+
updateRecommendationsForScope('defaultValue'); // In case there are application-default recommendations.
|
|
282
|
+
const roots = await this.workspaceService.roots;
|
|
283
|
+
for (const root of roots) {
|
|
284
|
+
updateRecommendationsForScope('workspaceFolderValue', root.resource);
|
|
285
|
+
}
|
|
286
|
+
if (this.workspaceService.saved) {
|
|
287
|
+
updateRecommendationsForScope('workspaceValue');
|
|
288
|
+
}
|
|
289
|
+
const recommendedSorted = new Set(Array.from(allRecommendations).sort((a, b) => this.compareExtensions(a, b)));
|
|
290
|
+
allUnwantedRecommendations.forEach(unwantedRecommendation => recommendedSorted.delete(unwantedRecommendation));
|
|
291
|
+
this._recommended = recommendedSorted;
|
|
292
|
+
return Promise.all(Array.from(recommendedSorted, plugin => this.refresh(plugin)));
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
getRecommendationsForScope(scope, root) {
|
|
296
|
+
var _a, _b, _c;
|
|
297
|
+
const configuredValue = (_a = this.preferences.inspect('extensions', root === null || root === void 0 ? void 0 : root.toString())) === null || _a === void 0 ? void 0 : _a[scope];
|
|
298
|
+
return {
|
|
299
|
+
recommendations: (_b = configuredValue === null || configuredValue === void 0 ? void 0 : configuredValue.recommendations) !== null && _b !== void 0 ? _b : [],
|
|
300
|
+
unwantedRecommendations: (_c = configuredValue === null || configuredValue === void 0 ? void 0 : configuredValue.unwantedRecommendations) !== null && _c !== void 0 ? _c : [],
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
compileReadme(readmeMarkdown) {
|
|
304
|
+
const readmeHtml = markdownit({ html: true }).render(readmeMarkdown);
|
|
305
|
+
return DOMPurify.sanitize(readmeHtml);
|
|
306
|
+
}
|
|
307
|
+
async refresh(id, version) {
|
|
308
|
+
try {
|
|
309
|
+
let extension = this.getExtension(id);
|
|
310
|
+
if (!this.shouldRefresh(extension)) {
|
|
311
|
+
return extension;
|
|
312
|
+
}
|
|
313
|
+
const client = await this.clientProvider();
|
|
314
|
+
let data;
|
|
315
|
+
if (version === undefined) {
|
|
316
|
+
const { extensions } = await client.query({ extensionId: id, includeAllVersions: true });
|
|
317
|
+
if (extensions === null || extensions === void 0 ? void 0 : extensions.length) {
|
|
318
|
+
data = this.vsxApiFilter.getLatestCompatibleExtension(extensions);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
const { extensions } = await client.query({ extensionId: id, extensionVersion: version, includeAllVersions: true });
|
|
323
|
+
if (extensions === null || extensions === void 0 ? void 0 : extensions.length) {
|
|
324
|
+
data = extensions === null || extensions === void 0 ? void 0 : extensions[0];
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (!data) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
if (data.error) {
|
|
331
|
+
return this.onDidFailRefresh(id, data.error);
|
|
332
|
+
}
|
|
333
|
+
if (!data.verified) {
|
|
334
|
+
if (data.publishedBy.loginName === 'open-vsx') {
|
|
335
|
+
data.verified = true;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
extension = this.setExtension(id);
|
|
339
|
+
extension.update(Object.assign(data, {
|
|
340
|
+
publisher: data.namespace,
|
|
341
|
+
downloadUrl: data.files.download,
|
|
342
|
+
iconUrl: data.files.icon,
|
|
343
|
+
readmeUrl: data.files.readme,
|
|
344
|
+
licenseUrl: data.files.license,
|
|
345
|
+
version: data.version,
|
|
346
|
+
verified: data.verified
|
|
347
|
+
}));
|
|
348
|
+
return extension;
|
|
349
|
+
}
|
|
350
|
+
catch (e) {
|
|
351
|
+
return this.onDidFailRefresh(id, e);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Determines if the given extension should be refreshed.
|
|
356
|
+
* @param extension the extension to refresh.
|
|
357
|
+
*/
|
|
358
|
+
shouldRefresh(extension) {
|
|
359
|
+
if (extension === undefined) {
|
|
360
|
+
return true;
|
|
361
|
+
}
|
|
362
|
+
return !extension.builtin;
|
|
363
|
+
}
|
|
364
|
+
onDidFailRefresh(id, error) {
|
|
365
|
+
const cached = this.getExtension(id);
|
|
366
|
+
if (cached && cached.installed) {
|
|
367
|
+
return cached;
|
|
368
|
+
}
|
|
369
|
+
console.error(`[${id}]: failed to refresh, reason:`, error);
|
|
370
|
+
return undefined;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Compare two extensions based on their display name, and publisher if applicable.
|
|
374
|
+
* @param a the first extension id for comparison.
|
|
375
|
+
* @param b the second extension id for comparison.
|
|
376
|
+
*/
|
|
377
|
+
compareExtensions(a, b) {
|
|
378
|
+
const extensionA = this.getExtension(a);
|
|
379
|
+
const extensionB = this.getExtension(b);
|
|
380
|
+
if (!extensionA || !extensionB) {
|
|
381
|
+
return 0;
|
|
382
|
+
}
|
|
383
|
+
if (extensionA.displayName && extensionB.displayName) {
|
|
384
|
+
return extensionA.displayName.localeCompare(extensionB.displayName);
|
|
385
|
+
}
|
|
386
|
+
if (extensionA.publisher && extensionB.publisher) {
|
|
387
|
+
return extensionA.publisher.localeCompare(extensionB.publisher);
|
|
388
|
+
}
|
|
389
|
+
return 0;
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
__decorate([
|
|
393
|
+
(0, inversify_1.inject)(ovsx_client_provider_1.OVSXClientProvider),
|
|
394
|
+
__metadata("design:type", Function)
|
|
395
|
+
], VSXExtensionsModel.prototype, "clientProvider", void 0);
|
|
396
|
+
__decorate([
|
|
397
|
+
(0, inversify_1.inject)(hosted_plugin_1.HostedPluginSupport),
|
|
398
|
+
__metadata("design:type", hosted_plugin_1.HostedPluginSupport)
|
|
399
|
+
], VSXExtensionsModel.prototype, "pluginSupport", void 0);
|
|
400
|
+
__decorate([
|
|
401
|
+
(0, inversify_1.inject)(vsx_extension_1.VSXExtensionFactory),
|
|
402
|
+
__metadata("design:type", Function)
|
|
403
|
+
], VSXExtensionsModel.prototype, "extensionFactory", void 0);
|
|
404
|
+
__decorate([
|
|
405
|
+
(0, inversify_1.inject)(progress_service_1.ProgressService),
|
|
406
|
+
__metadata("design:type", progress_service_1.ProgressService)
|
|
407
|
+
], VSXExtensionsModel.prototype, "progressService", void 0);
|
|
408
|
+
__decorate([
|
|
409
|
+
(0, inversify_1.inject)(browser_1.PreferenceService),
|
|
410
|
+
__metadata("design:type", Object)
|
|
411
|
+
], VSXExtensionsModel.prototype, "preferences", void 0);
|
|
412
|
+
__decorate([
|
|
413
|
+
(0, inversify_1.inject)(browser_2.WorkspaceService),
|
|
414
|
+
__metadata("design:type", browser_2.WorkspaceService)
|
|
415
|
+
], VSXExtensionsModel.prototype, "workspaceService", void 0);
|
|
416
|
+
__decorate([
|
|
417
|
+
(0, inversify_1.inject)(vsx_extensions_search_model_1.VSXExtensionsSearchModel),
|
|
418
|
+
__metadata("design:type", vsx_extensions_search_model_1.VSXExtensionsSearchModel)
|
|
419
|
+
], VSXExtensionsModel.prototype, "search", void 0);
|
|
420
|
+
__decorate([
|
|
421
|
+
(0, inversify_1.inject)(request_1.RequestService),
|
|
422
|
+
__metadata("design:type", Object)
|
|
423
|
+
], VSXExtensionsModel.prototype, "request", void 0);
|
|
424
|
+
__decorate([
|
|
425
|
+
(0, inversify_1.inject)(ovsx_client_1.OVSXApiFilter),
|
|
426
|
+
__metadata("design:type", Object)
|
|
427
|
+
], VSXExtensionsModel.prototype, "vsxApiFilter", void 0);
|
|
428
|
+
__decorate([
|
|
429
|
+
(0, inversify_1.postConstruct)(),
|
|
430
|
+
__metadata("design:type", Function),
|
|
431
|
+
__metadata("design:paramtypes", []),
|
|
432
|
+
__metadata("design:returntype", void 0)
|
|
433
|
+
], VSXExtensionsModel.prototype, "init", null);
|
|
434
|
+
VSXExtensionsModel = __decorate([
|
|
435
|
+
(0, inversify_1.injectable)()
|
|
436
|
+
], VSXExtensionsModel);
|
|
437
|
+
exports.VSXExtensionsModel = VSXExtensionsModel;
|
|
392
438
|
//# sourceMappingURL=vsx-extensions-model.js.map
|