chore(vscode): update to 1.56.0

This commit is contained in:
Akash Satheesan
2021-04-30 20:25:17 +05:30
1749 changed files with 88014 additions and 43316 deletions

View File

@@ -29,8 +29,8 @@ export interface IJSONContribution {
resolveSuggestion?(resourceUri: Uri | undefined, item: CompletionItem): Thenable<CompletionItem | null> | null;
}
export function addJSONProviders(xhr: XHRRequest, canRunNPM: boolean): Disposable {
const contributions = [new PackageJSONContribution(xhr, canRunNPM), new BowerJSONContribution(xhr)];
export function addJSONProviders(xhr: XHRRequest, npmCommandPath: string | undefined): Disposable {
const contributions = [new PackageJSONContribution(xhr, npmCommandPath), new BowerJSONContribution(xhr)];
const subscriptions: Disposable[] = [];
contributions.forEach(contribution => {
const selector = contribution.getDocumentSelector();
@@ -136,7 +136,7 @@ export class JSONCompletionItemProvider implements CompletionItemProvider {
}
if (collectPromise) {
return collectPromise.then(() => {
if (items.length > 0) {
if (items.length > 0 || isIncomplete) {
return new CompletionList(items, isIncomplete);
}
return null;

View File

@@ -14,7 +14,6 @@ import { dirname } from 'path';
const localize = nls.loadMessageBundle();
const LIMIT = 40;
const SCOPED_LIMIT = 250;
const USER_AGENT = 'Visual Studio Code';
@@ -33,7 +32,7 @@ export class PackageJSONContribution implements IJSONContribution {
return [{ language: 'json', scheme: '*', pattern: '**/package.json' }];
}
public constructor(private xhr: XHRRequest, private canRunNPM: boolean) {
public constructor(private xhr: XHRRequest, private npmCommandPath: string | undefined) {
}
public collectDefaultSuggestions(_resource: Uri, result: ISuggestionsCollector): Thenable<any> {
@@ -53,7 +52,7 @@ export class PackageJSONContribution implements IJSONContribution {
}
private isEnabled() {
return this.canRunNPM || this.onlineEnabled();
return this.npmCommandPath || this.onlineEnabled();
}
private onlineEnabled() {
@@ -94,7 +93,7 @@ export class PackageJSONContribution implements IJSONContribution {
collector.setAsIncomplete();
}
queryUrl = `https://api.npms.io/v2/search/suggestions?size=${LIMIT}&q=${encodeURIComponent(currentWord)}`;
queryUrl = `https://registry.npmjs.org/-/v1/search?size=${LIMIT}&text=${encodeURIComponent(currentWord)}`;
return this.xhr({
url: queryUrl,
agent: USER_AGENT
@@ -102,18 +101,17 @@ export class PackageJSONContribution implements IJSONContribution {
if (success.status === 200) {
try {
const obj = JSON.parse(success.responseText);
if (obj && Array.isArray(obj)) {
const results = <{ package: SearchPackageInfo; }[]>obj;
if (obj && obj.objects && Array.isArray(obj.objects)) {
const results = <{ package: SearchPackageInfo; }[]>obj.objects;
for (const result of results) {
this.processPackage(result.package, addValue, isLast, collector);
}
if (results.length === LIMIT) {
collector.setAsIncomplete();
}
}
} catch (e) {
// ignore
}
collector.setAsIncomplete();
} else {
collector.error(localize('json.npm.error.repoaccess', 'Request to the NPM repository failed: {0}', success.responseText));
return 0;
@@ -155,7 +153,7 @@ export class PackageJSONContribution implements IJSONContribution {
if (name.length < 4) {
name = '';
}
let queryUrl = `https://api.npms.io/v2/search?q=scope:${scope}%20${name}&size=250`;
let queryUrl = `https://registry.npmjs.com/-/v1/search?text=scope:${scope}%20${name}&size=250`;
return this.xhr({
url: queryUrl,
agent: USER_AGENT
@@ -163,18 +161,16 @@ export class PackageJSONContribution implements IJSONContribution {
if (success.status === 200) {
try {
const obj = JSON.parse(success.responseText);
if (obj && Array.isArray(obj.results)) {
const objects = <{ package: SearchPackageInfo }[]>obj.results;
if (obj && Array.isArray(obj.objects)) {
const objects = <{ package: SearchPackageInfo; }[]>obj.objects;
for (let object of objects) {
this.processPackage(object.package, addValue, isLast, collector);
}
if (objects.length === SCOPED_LIMIT) {
collector.setAsIncomplete();
}
}
} catch (e) {
// ignore
}
collector.setAsIncomplete();
} else {
collector.error(localize('json.npm.error.repoaccess', 'Request to the NPM repository failed: {0}', success.responseText));
}
@@ -272,8 +268,8 @@ export class PackageJSONContribution implements IJSONContribution {
return undefined; // avoid unnecessary lookups
}
let info: ViewPackageInfo | undefined;
if (this.canRunNPM) {
info = await this.npmView(pack, resource);
if (this.npmCommandPath) {
info = await this.npmView(this.npmCommandPath, pack, resource);
}
if (!info && this.onlineEnabled()) {
info = await this.npmjsView(pack);
@@ -281,11 +277,11 @@ export class PackageJSONContribution implements IJSONContribution {
return info;
}
private npmView(pack: string, resource: Uri | undefined): Promise<ViewPackageInfo | undefined> {
private npmView(npmCommandPath: string, pack: string, resource: Uri | undefined): Promise<ViewPackageInfo | undefined> {
return new Promise((resolve, _reject) => {
const args = ['view', '--json', pack, 'description', 'dist-tags.latest', 'homepage', 'version'];
let cwd = resource && resource.scheme === 'file' ? dirname(resource.fsPath) : undefined;
cp.execFile(process.platform === 'win32' ? 'npm.cmd' : 'npm', args, { cwd }, (error, stdout) => {
cp.execFile(npmCommandPath, args, { cwd }, (error, stdout) => {
if (!error) {
try {
const content = JSON.parse(stdout);
@@ -305,21 +301,18 @@ export class PackageJSONContribution implements IJSONContribution {
}
private async npmjsView(pack: string): Promise<ViewPackageInfo | undefined> {
const queryUrl = 'https://api.npms.io/v2/package/' + encodeURIComponent(pack);
const queryUrl = 'https://registry.npmjs.org/' + encodeURIComponent(pack);
try {
const success = await this.xhr({
url: queryUrl,
agent: USER_AGENT
});
const obj = JSON.parse(success.responseText);
const metadata = obj?.collected?.metadata;
if (metadata) {
return {
description: metadata.description || '',
version: metadata.version,
homepage: metadata.links?.homepage || ''
};
}
return {
description: obj.description || '',
version: Object.keys(obj.versions).pop(),
homepage: obj.homepage || ''
};
}
catch (e) {
//ignore