remove winjs-promise - fixes #53526
This commit is contained in:
parent
a99079f13a
commit
11fb2c1389
26
.vscode/launch.json
vendored
26
.vscode/launch.json
vendored
|
@ -133,24 +133,22 @@
|
|||
},
|
||||
"urlFilter": "*workbench.html*",
|
||||
"runtimeArgs": [
|
||||
"--inspect=5875", "--no-cached-data"
|
||||
],
|
||||
"skipFiles": [
|
||||
"**/winjs*.js"
|
||||
"--inspect=5875",
|
||||
"--no-cached-data"
|
||||
],
|
||||
"webRoot": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch VS Code (Main Process)",
|
||||
"runtimeExecutable": "${workspaceFolder}/scripts/code.sh",
|
||||
"runtimeArgs": [
|
||||
"--no-cached-data"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/out/**/*.js"
|
||||
]
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch VS Code (Main Process)",
|
||||
"runtimeExecutable": "${workspaceFolder}/scripts/code.sh",
|
||||
"runtimeArgs": [
|
||||
"--no-cached-data"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/out/**/*.js"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
|
|
|
@ -50,7 +50,6 @@ const indentationFilter = [
|
|||
'!src/vs/css.build.js',
|
||||
'!src/vs/loader.js',
|
||||
'!src/vs/base/common/marked/marked.js',
|
||||
'!src/vs/base/common/winjs.base.js',
|
||||
'!src/vs/base/node/terminateProcess.sh',
|
||||
'!src/vs/base/node/cpuUsage.sh',
|
||||
'!test/assert.js',
|
||||
|
@ -128,7 +127,6 @@ const eslintFilter = [
|
|||
'!src/vs/nls.js',
|
||||
'!src/vs/css.build.js',
|
||||
'!src/vs/nls.build.js',
|
||||
'!src/**/winjs.base.js',
|
||||
'!src/**/marked.js',
|
||||
'!**/test/**'
|
||||
];
|
||||
|
|
|
@ -136,7 +136,6 @@
|
|||
"./vs/base/test/common/types.test.ts",
|
||||
"./vs/base/test/common/utils.ts",
|
||||
"./vs/base/test/common/uuid.test.ts",
|
||||
"./vs/base/test/common/winjs.promise.test.ts",
|
||||
"./vs/base/test/node/console.test.ts",
|
||||
"./vs/base/test/node/decoder.test.ts",
|
||||
"./vs/base/test/node/encoding/encoding.test.ts",
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
{
|
||||
"name": "vs/base",
|
||||
"dependencies": [
|
||||
{ "name": "vs", "internal": false }
|
||||
{
|
||||
"name": "vs",
|
||||
"internal": false
|
||||
}
|
||||
],
|
||||
"libs": [
|
||||
"lib.core.d.ts"
|
||||
|
@ -9,7 +12,5 @@
|
|||
"sources": [
|
||||
"**/*.ts"
|
||||
],
|
||||
"declares": [
|
||||
"vs/base/winjs.base.d.ts"
|
||||
]
|
||||
}
|
||||
"declares": []
|
||||
}
|
||||
|
|
53
src/vs/base/common/winjs.base.d.ts
vendored
53
src/vs/base/common/winjs.base.d.ts
vendored
|
@ -1,53 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
/// Interfaces for WinJS
|
||||
|
||||
export type ErrorCallback = (error: any) => void;
|
||||
|
||||
export class Promise<T = any> {
|
||||
constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason: any) => void) => void);
|
||||
|
||||
public then<TResult1 = T, TResult2 = never>(
|
||||
onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,
|
||||
onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
||||
|
||||
|
||||
public static as(value: null): Promise<null>;
|
||||
public static as(value: undefined): Promise<undefined>;
|
||||
public static as<T>(value: PromiseLike<T>): PromiseLike<T>;
|
||||
public static as<T, SomePromise extends PromiseLike<T>>(value: SomePromise): SomePromise;
|
||||
public static as<T>(value: T): Promise<T>;
|
||||
|
||||
public static join<T1, T2>(promises: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
|
||||
public static join<T>(promises: (T | PromiseLike<T>)[]): Promise<T[]>;
|
||||
|
||||
public static wrap<T>(value: T | PromiseLike<T>): Promise<T>;
|
||||
|
||||
public static wrapError<T = never>(error: Error): Promise<T>;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public static addEventListener(event: 'error', promiseErrorHandler: (e: IPromiseError) => void): void;
|
||||
}
|
||||
|
||||
export type TValueCallback<T = any> = (value: T | PromiseLike<T>) => void;
|
||||
|
||||
export {
|
||||
Promise as TPromise,
|
||||
TValueCallback as ValueCallback
|
||||
};
|
||||
|
||||
export interface IPromiseErrorDetail {
|
||||
parent: Promise;
|
||||
error: any;
|
||||
id: number;
|
||||
handler: Function;
|
||||
exception: Error;
|
||||
}
|
||||
|
||||
export interface IPromiseError {
|
||||
detail: IPromiseErrorDetail;
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -39,17 +39,6 @@ suite('Async', () => {
|
|||
return result;
|
||||
});
|
||||
|
||||
// test('Cancel callback behaviour', async function () {
|
||||
// let withCancelCallback = new WinJsPromise(() => { }, () => { });
|
||||
// let withoutCancelCallback = new TPromise(() => { });
|
||||
|
||||
// withCancelCallback.cancel();
|
||||
// (withoutCancelCallback as WinJsPromise).cancel();
|
||||
|
||||
// await withCancelCallback.then(undefined, err => { assert.ok(isPromiseCanceledError(err)); });
|
||||
// await withoutCancelCallback.then(undefined, err => { assert.ok(isPromiseCanceledError(err)); });
|
||||
// });
|
||||
|
||||
// Cancelling a sync cancelable promise will fire the cancelled token.
|
||||
// Also, every `then` callback runs in another execution frame.
|
||||
test('CancelablePromise execution order (sync)', function () {
|
||||
|
@ -95,50 +84,6 @@ suite('Async', () => {
|
|||
return promise.then(() => assert.deepEqual(order, ['in callback', 'afterCreate', 'cancelled', 'afterCancel', 'finally']));
|
||||
});
|
||||
|
||||
// // Cancelling a sync tpromise will NOT cancel the promise, since it has resolved already.
|
||||
// // Every `then` callback runs sync in the same execution frame, thus `finally` executes
|
||||
// // before `afterCancel`.
|
||||
// test('TPromise execution order (sync)', function () {
|
||||
// const order = [];
|
||||
// let promise = new WinJsPromise(resolve => {
|
||||
// order.push('in executor');
|
||||
// resolve(1234);
|
||||
// }, () => order.push('cancelled'));
|
||||
|
||||
// order.push('afterCreate');
|
||||
|
||||
// promise = promise
|
||||
// .then(void 0, err => null)
|
||||
// .then(() => order.push('finally'));
|
||||
|
||||
// promise.cancel();
|
||||
// order.push('afterCancel');
|
||||
|
||||
// return promise.then(() => assert.deepEqual(order, ['in executor', 'afterCreate', 'finally', 'afterCancel']));
|
||||
// });
|
||||
|
||||
// // Cancelling an async tpromise will cancel the promise.
|
||||
// // Every `then` callback runs sync on the same execution frame as the `cancel` call,
|
||||
// // so finally still executes before `afterCancel`.
|
||||
// test('TPromise execution order (async)', function () {
|
||||
// const order = [];
|
||||
// let promise = new WinJsPromise(resolve => {
|
||||
// order.push('in executor');
|
||||
// setTimeout(() => resolve(1234));
|
||||
// }, () => order.push('cancelled'));
|
||||
|
||||
// order.push('afterCreate');
|
||||
|
||||
// promise = promise
|
||||
// .then(void 0, err => null)
|
||||
// .then(() => order.push('finally'));
|
||||
|
||||
// promise.cancel();
|
||||
// order.push('afterCancel');
|
||||
|
||||
// return promise.then(() => assert.deepEqual(order, ['in executor', 'afterCreate', 'cancelled', 'finally', 'afterCancel']));
|
||||
// });
|
||||
|
||||
test('cancelablePromise - get inner result', async function () {
|
||||
let promise = async.createCancelablePromise(token => {
|
||||
return async.timeout(12).then(_ => 1234);
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import * as winjs from 'vs/base/common/winjs.base';
|
||||
|
||||
suite('WinJS and ES6 Promises', function () {
|
||||
|
||||
test('Promise.resolve', () => {
|
||||
let resolveTPromise;
|
||||
const tPromise = new winjs.Promise((c, e) => {
|
||||
resolveTPromise = c;
|
||||
});
|
||||
|
||||
const es6Promise = Promise.resolve(tPromise);
|
||||
|
||||
const done = es6Promise.then(function (result) {
|
||||
assert.equal(result, 'passed');
|
||||
});
|
||||
|
||||
resolveTPromise('passed');
|
||||
|
||||
return done;
|
||||
});
|
||||
|
||||
test('new Promise', function () {
|
||||
let resolveTPromise;
|
||||
const tPromise = new winjs.Promise((c, e) => {
|
||||
resolveTPromise = c;
|
||||
});
|
||||
|
||||
const es6Promise = new Promise(function (c, e) {
|
||||
c(tPromise);
|
||||
});
|
||||
|
||||
const done = es6Promise.then(function (result) {
|
||||
assert.equal(result, 'passed');
|
||||
});
|
||||
|
||||
resolveTPromise('passed');
|
||||
|
||||
return done;
|
||||
});
|
||||
|
||||
test('1. Uncaught TypeError: this._state.then is not a function', () => {
|
||||
let p1 = winjs.Promise.wrap<number>(new Promise<number>(function (c, e) { c(1); }));
|
||||
Promise.all([p1]);
|
||||
});
|
||||
|
||||
test('2. Uncaught TypeError: this._state.then is not a function', () => {
|
||||
let p1 = winjs.Promise.wrap<number>(new Promise<number>(function (c, e) { c(1); }));
|
||||
let thenFunc = p1.then.bind(p1);
|
||||
setTimeout(() => {
|
||||
thenFunc(() => 0);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
test('3. Uncaught TypeError: this._state.then is not a function', () => {
|
||||
let c;
|
||||
let p1 = new winjs.Promise(function (_c, e) { c = _c; });
|
||||
let thenFunc = p1.then.bind(p1);
|
||||
setTimeout(() => {
|
||||
c(1);
|
||||
thenFunc(() => 0);
|
||||
}, 0);
|
||||
});
|
||||
});
|
|
@ -10,7 +10,6 @@ import { assign } from 'vs/base/common/objects';
|
|||
import { toDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { flatten } from 'vs/base/common/arrays';
|
||||
import { extract, ExtractError, zip, IFile } from 'vs/platform/node/zip';
|
||||
import { ValueCallback, ErrorCallback } from 'vs/base/common/winjs.base';
|
||||
import {
|
||||
IExtensionManagementService, IExtensionGalleryService, ILocalExtension,
|
||||
IGalleryExtension, IExtensionManifest, IGalleryMetadata,
|
||||
|
@ -292,7 +291,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
|
|||
if (!cancellablePromise) {
|
||||
|
||||
let operation: InstallOperation = InstallOperation.Install;
|
||||
let cancellationToken: CancellationToken, successCallback: ValueCallback<void>, errorCallback: ErrorCallback;
|
||||
let cancellationToken: CancellationToken, successCallback: (a?: any) => void, errorCallback: (e?: any) => any;
|
||||
cancellablePromise = createCancelablePromise(token => { cancellationToken = token; return new Promise((c, e) => { successCallback = c; errorCallback = e; }); });
|
||||
this.installingExtensions.set(key, cancellablePromise);
|
||||
|
||||
|
|
36
test/all.js
36
test/all.js
|
@ -50,9 +50,9 @@ function main() {
|
|||
baseUrl: path.join(path.dirname(__dirname), 'src'),
|
||||
paths: {
|
||||
'vs/css': '../test/css.mock',
|
||||
'vs': `../${ out }/vs`,
|
||||
'lib': `../${ out }/lib`,
|
||||
'bootstrap-fork': `../${ out }/bootstrap-fork`
|
||||
'vs': `../${out}/vs`,
|
||||
'lib': `../${out}/lib`,
|
||||
'bootstrap-fork': `../${out}/bootstrap-fork`
|
||||
},
|
||||
catchError: true
|
||||
};
|
||||
|
@ -79,10 +79,10 @@ function main() {
|
|||
|
||||
if (argv.forceLoad) {
|
||||
var allFiles = glob.sync(out + '/vs/**/*.js');
|
||||
allFiles = allFiles.map(function(source) {
|
||||
allFiles = allFiles.map(function (source) {
|
||||
return path.join(__dirname, '..', source);
|
||||
});
|
||||
allFiles = allFiles.filter(function(source) {
|
||||
allFiles = allFiles.filter(function (source) {
|
||||
if (seenSources[source]) {
|
||||
return false;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ function main() {
|
|||
}
|
||||
return true;
|
||||
});
|
||||
allFiles.forEach(function(source, index) {
|
||||
allFiles.forEach(function (source, index) {
|
||||
var contents = fs.readFileSync(source).toString();
|
||||
contents = instrumenter.instrumentSync(contents, source);
|
||||
var stopAt = contents.indexOf('}\n__cov');
|
||||
|
@ -106,18 +106,18 @@ function main() {
|
|||
});
|
||||
}
|
||||
|
||||
let remapIgnores = /\b((winjs\.base)|(marked)|(raw\.marked)|(nls)|(css))\.js$/;
|
||||
let remapIgnores = /\b((marked)|(raw\.marked)|(nls)|(css))\.js$/;
|
||||
|
||||
var remappedCoverage = i_remap(global.__coverage__, { exclude: remapIgnores }).getFinalCoverage();
|
||||
|
||||
// The remapped coverage comes out with broken paths
|
||||
var toUpperDriveLetter = function(str) {
|
||||
var toUpperDriveLetter = function (str) {
|
||||
if (/^[a-z]:/.test(str)) {
|
||||
return str.charAt(0).toUpperCase() + str.substr(1);
|
||||
}
|
||||
return str;
|
||||
};
|
||||
var toLowerDriveLetter = function(str) {
|
||||
var toLowerDriveLetter = function (str) {
|
||||
if (/^[A-Z]:/.test(str)) {
|
||||
return str.charAt(0).toLowerCase() + str.substr(1);
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ function main() {
|
|||
};
|
||||
|
||||
var REPO_PATH = toUpperDriveLetter(path.join(__dirname, '..'));
|
||||
var fixPath = function(brokenPath) {
|
||||
var fixPath = function (brokenPath) {
|
||||
var startIndex = brokenPath.indexOf(REPO_PATH);
|
||||
if (startIndex === -1) {
|
||||
return toLowerDriveLetter(brokenPath);
|
||||
|
@ -154,7 +154,7 @@ function main() {
|
|||
}
|
||||
var reporter = new istanbul.Reporter(null, coveragePath);
|
||||
reporter.addAll(reportTypes);
|
||||
reporter.write(collector, true, function () {});
|
||||
reporter.write(collector, true, function () { });
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ function main() {
|
|||
};
|
||||
} else if (argv.run) {
|
||||
var tests = (typeof argv.run === 'string') ? [argv.run] : argv.run;
|
||||
var modulesToLoad = tests.map(function(test) {
|
||||
var modulesToLoad = tests.map(function (test) {
|
||||
test = test.replace(/^src/, 'out');
|
||||
test = test.replace(/\.ts$/, '.js');
|
||||
return path.relative(src, path.resolve(test)).replace(/(\.js)|(\.js\.map)$/, '').replace(/\\/g, '/');
|
||||
|
@ -205,12 +205,12 @@ function main() {
|
|||
define(modulesToLoad, () => cb(null), cb);
|
||||
};
|
||||
} else if (argv['only-monaco-editor']) {
|
||||
loadFunc = function(cb) {
|
||||
loadFunc = function (cb) {
|
||||
glob(TEST_GLOB, { cwd: src }, function (err, files) {
|
||||
var modulesToLoad = files.map(function (file) {
|
||||
return file.replace(/\.js$/, '');
|
||||
});
|
||||
modulesToLoad = modulesToLoad.filter(function(module) {
|
||||
modulesToLoad = modulesToLoad.filter(function (module) {
|
||||
if (/^vs\/workbench\//.test(module)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ function main() {
|
|||
});
|
||||
};
|
||||
} else {
|
||||
loadFunc = function(cb) {
|
||||
loadFunc = function (cb) {
|
||||
glob(TEST_GLOB, { cwd: src }, function (err, files) {
|
||||
var modulesToLoad = files.map(function (file) {
|
||||
return file.replace(/\.js$/, '');
|
||||
|
@ -237,7 +237,7 @@ function main() {
|
|||
};
|
||||
}
|
||||
|
||||
loadFunc(function(err) {
|
||||
loadFunc(function (err) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return process.exit(1);
|
||||
|
@ -270,7 +270,7 @@ function main() {
|
|||
});
|
||||
|
||||
// replace the default unexpected error handler to be useful during tests
|
||||
loader(['vs/base/common/errors'], function(errors) {
|
||||
loader(['vs/base/common/errors'], function (errors) {
|
||||
errors.setUnexpectedErrorHandler(function (err) {
|
||||
let stack = (err && err.stack) || (new Error().stack);
|
||||
unexpectedErrors.push((err && err.message ? err.message : err) + '\n' + stack);
|
||||
|
@ -286,4 +286,4 @@ if (process.argv.some(function (a) { return /^--browser/.test(a); })) {
|
|||
require('./browser');
|
||||
} else {
|
||||
main();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ function createCoverageReport(opts) {
|
|||
return resolve(undefined);
|
||||
}
|
||||
|
||||
const exclude = /\b((winjs\.base)|(marked)|(raw\.marked)|(nls)|(css))\.js$/;
|
||||
const exclude = /\b((marked)|(raw\.marked)|(nls)|(css))\.js$/;
|
||||
const remappedCoverage = i_remap(global.__coverage__, { exclude: exclude }).getFinalCoverage();
|
||||
|
||||
// The remapped coverage comes out with broken paths
|
||||
|
|
Loading…
Reference in a new issue