Merge pull request #11301 from vector-im/t3chguy/remove_bluebird

get rid of bluebird
This commit is contained in:
Michael Telatynski 2019-11-25 13:31:03 +00:00 committed by GitHub
commit 6b1ba5e150
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 41 additions and 63 deletions

View File

@ -13,7 +13,6 @@
],
"transform-class-properties",
"transform-object-rest-spread",
"transform-async-to-bluebird",
"transform-runtime",
"add-module-exports",
"syntax-dynamic-import"

View File

@ -66,7 +66,6 @@
"dependencies": {
"babel-polyfill": "^6.26.0",
"babel-runtime": "^6.26.0",
"bluebird": "^3.5.2",
"browser-request": "^0.3.3",
"draft-js": "^0.11.0-alpha",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
@ -93,7 +92,6 @@
"babel-loader": "^7.1.5",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-async-to-bluebird": "^1.1.1",
"babel-plugin-transform-builtin-extend": "^1.1.2",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",

View File

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import Promise from 'bluebird';
import request from 'browser-request';
// Load the config file. First try to load up a domain-specific config of the

View File

@ -40,7 +40,6 @@ import sdk from 'matrix-react-sdk';
import PlatformPeg from 'matrix-react-sdk/lib/PlatformPeg';
sdk.loadSkin(require('../component-index'));
import VectorConferenceHandler from 'matrix-react-sdk/lib/VectorConferenceHandler';
import Promise from 'bluebird';
import * as languageHandler from 'matrix-react-sdk/lib/languageHandler';
import {_t, _td, newTranslatableError} from 'matrix-react-sdk/lib/languageHandler';
import AutoDiscoveryUtils from 'matrix-react-sdk/lib/utils/AutoDiscoveryUtils';
@ -65,10 +64,6 @@ import CallHandler from 'matrix-react-sdk/lib/CallHandler';
let lastLocationHashSet = null;
// Disable warnings for now: we use deprecated bluebird functions
// and need to migrate, but they spam the console with warnings.
Promise.config({warnings: false});
function checkBrowserFeatures(featureList) {
if (!window.Modernizr) {
console.error("Cannot check features - Modernizr global is missing.");

View File

@ -22,7 +22,6 @@ limitations under the License.
import VectorBasePlatform, {updateCheckStatusEnum} from './VectorBasePlatform';
import dis from 'matrix-react-sdk/lib/dispatcher';
import { _t } from 'matrix-react-sdk/lib/languageHandler';
import Promise from 'bluebird';
import rageshake from 'matrix-react-sdk/lib/rageshake/rageshake';
const ipcRenderer = window.ipcRenderer;

View File

@ -21,7 +21,6 @@ import VectorBasePlatform, {updateCheckStatusEnum} from './VectorBasePlatform';
import request from 'browser-request';
import dis from 'matrix-react-sdk/lib/dispatcher.js';
import { _t } from 'matrix-react-sdk/lib/languageHandler';
import Promise from 'bluebird';
import url from 'url';
import UAParser from 'ua-parser-js';

View File

@ -24,9 +24,6 @@ require('skin-sdk');
const jssdk = require('matrix-js-sdk');
const sdk = require('matrix-react-sdk');
const peg = require('matrix-react-sdk/lib/MatrixClientPeg');
const dis = require('matrix-react-sdk/lib/dispatcher');
const PageTypes = require('matrix-react-sdk/lib/PageTypes');
const MatrixChat = sdk.getComponent('structures.MatrixChat');
const RoomDirectory = sdk.getComponent('structures.RoomDirectory');
const RoomPreviewBar = sdk.getComponent('rooms.RoomPreviewBar');
@ -36,9 +33,9 @@ const React = require('react');
const ReactDOM = require('react-dom');
const ReactTestUtils = require('react-dom/test-utils');
const expect = require('expect');
import Promise from 'bluebird';
import {makeType} from "matrix-react-sdk/lib/utils/TypeUtils";
import {ValidatedServerConfig} from "matrix-react-sdk/lib/utils/AutoDiscoveryUtils";
import {sleep} from "../test-utils";
const test_utils = require('../test-utils');
const MockHttpBackend = require('matrix-mock-request');
@ -173,7 +170,7 @@ describe('joining a room', function() {
matrixChat, RoomView);
// the preview bar may take a tick to be displayed
return Promise.delay(1);
return sleep(1);
}).then(() => {
const previewBar = ReactTestUtils.findRenderedComponentWithType(
roomView, RoomPreviewBar);
@ -187,14 +184,14 @@ describe('joining a room', function() {
.respond(200, {room_id: ROOM_ID});
}).then(() => {
// wait for the join request to be made
return Promise.delay(1);
return sleep(1);
}).then(() => {
// and again, because the state update has to go to the store and
// then one dispatch within the store, then to the view
// XXX: This is *super flaky*: a better way would be to declare
// that we expect a certain state transition to happen, then wait
// for that transition to occur.
return Promise.delay(1);
return sleep(1);
}).then(() => {
// the roomview should now be loading
expect(roomView.state.room).toBe(null);
@ -209,7 +206,7 @@ describe('joining a room', function() {
}).then(() => {
httpBackend.verifyNoOutstandingExpectation();
return Promise.delay(1);
return sleep(1);
}).then(() => {
// NB. we don't expect the 'joining' flag to reset at any point:
// it will stay set and we observe whether we have Room object for

View File

@ -25,7 +25,6 @@ import React from 'react';
import ReactDOM from 'react-dom';
import ReactTestUtils from 'react-dom/test-utils';
import expect from 'expect';
import Promise from 'bluebird';
import MatrixReactTestUtils from 'matrix-react-test-utils';
import jssdk from 'matrix-js-sdk';
@ -41,6 +40,7 @@ import MockHttpBackend from 'matrix-mock-request';
import {parseQs, parseQsFromFragment} from '../../src/vector/url_utils';
import {makeType} from "matrix-react-sdk/lib/utils/TypeUtils";
import {ValidatedServerConfig} from "matrix-react-sdk/lib/utils/AutoDiscoveryUtils";
import {sleep} from "../test-utils";
const DEFAULT_HS_URL='http://my_server';
const DEFAULT_IS_URL='http://my_is';
@ -213,10 +213,10 @@ describe('loading:', function() {
}
describe("Clean load with no stored credentials:", function() {
it('gives a welcome page by default', function(done) {
it('gives a welcome page by default', function() {
loadApp();
Promise.delay(1).then(() => {
return sleep(1).then(() => {
// at this point, we're trying to do a guest registration;
// we expect a spinner
assertAtLoadingSpinner(matrixChat);
@ -231,10 +231,10 @@ describe('loading:', function() {
return awaitWelcomeComponent(matrixChat);
}).then(() => {
expect(windowLocation.hash).toEqual("#/welcome");
}).done(done, done);
});
});
it('should follow the original link after successful login', function(done) {
it('should follow the original link after successful login', function() {
loadApp({
uriFragment: "#/room/!room:id",
});
@ -243,7 +243,7 @@ describe('loading:', function() {
httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]});
httpBackend.when("GET", "/api/v1").respond(200, {});
Promise.delay(1).then(() => {
return sleep(1).then(() => {
// at this point, we're trying to do a guest registration;
// we expect a spinner
assertAtLoadingSpinner(matrixChat);
@ -255,7 +255,7 @@ describe('loading:', function() {
return httpBackend.flush();
}).then(() => {
// Wait for another trip around the event loop for the UI to update
return Promise.delay(10);
return sleep(10);
}).then(() => {
return moveFromWelcomeToLogin(matrixChat);
}).then(() => {
@ -272,7 +272,7 @@ describe('loading:', function() {
expect(localStorage.getItem('mx_access_token')).toEqual('access_token');
expect(localStorage.getItem('mx_hs_url')).toEqual(DEFAULT_HS_URL);
expect(localStorage.getItem('mx_is_url')).toEqual(DEFAULT_IS_URL);
}).done(done, done);
});
});
it('should not register as a guest when using a #/login link', function() {
@ -348,7 +348,7 @@ describe('loading:', function() {
});
});
it('shows a home page by default if we have no joined rooms', function(done) {
it('shows a home page by default if we have no joined rooms', function() {
localStorage.removeItem("mx_last_room_id");
httpBackend.when('GET', '/pushrules').respond(200, {});
@ -365,10 +365,10 @@ describe('loading:', function() {
ReactTestUtils.findRenderedComponentWithType(
matrixChat, sdk.getComponent('structures.EmbeddedPage'));
expect(windowLocation.hash).toEqual("#/home");
}).done(done, done);
});
});
it('shows a room view if we followed a room link', function(done) {
it('shows a room view if we followed a room link', function() {
httpBackend.when('GET', '/pushrules').respond(200, {});
httpBackend.when('POST', '/filter').respond(200, { filter_id: 'fid' });
@ -385,7 +385,7 @@ describe('loading:', function() {
}).then(() => {
httpBackend.verifyNoOutstandingExpectation();
expect(windowLocation.hash).toEqual("#/room/!room:id");
}).done(done, done);
});
});
describe('/#/login link:', function() {
@ -442,10 +442,10 @@ describe('loading:', function() {
});
describe('Guest auto-registration:', function() {
it('shows a welcome page by default', function(done) {
it('shows a welcome page by default', function() {
loadApp();
Promise.delay(1).then(() => {
return sleep(1).then(() => {
// at this point, we're trying to do a guest registration;
// we expect a spinner
assertAtLoadingSpinner(matrixChat);
@ -469,13 +469,13 @@ describe('loading:', function() {
ReactTestUtils.findRenderedComponentWithType(
matrixChat, sdk.getComponent('auth.Welcome'));
expect(windowLocation.hash).toEqual("#/welcome");
}).done(done, done);
});
});
it('uses the default homeserver to register with', function(done) {
it('uses the default homeserver to register with', function() {
loadApp();
Promise.delay(1).then(() => {
return sleep(1).then(() => {
// at this point, we're trying to do a guest registration;
// we expect a spinner
assertAtLoadingSpinner(matrixChat);
@ -503,14 +503,14 @@ describe('loading:', function() {
expect(windowLocation.hash).toEqual("#/welcome");
expect(MatrixClientPeg.get().baseUrl).toEqual(DEFAULT_HS_URL);
expect(MatrixClientPeg.get().idBaseUrl).toEqual(DEFAULT_IS_URL);
}).done(done, done);
});
});
it('shows a room view if we followed a room link', function(done) {
it('shows a room view if we followed a room link', function() {
loadApp({
uriFragment: "#/room/!room:id",
});
Promise.delay(1).then(() => {
return sleep(1).then(() => {
// at this point, we're trying to do a guest registration;
// we expect a spinner
assertAtLoadingSpinner(matrixChat);
@ -533,7 +533,7 @@ describe('loading:', function() {
}).then(() => {
httpBackend.verifyNoOutstandingExpectation();
expect(windowLocation.hash).toEqual("#/room/!room:id");
}).done(done, done);
});
});
describe('Login as user', function() {
@ -600,7 +600,7 @@ describe('loading:', function() {
ReactTestUtils.Simulate.click(returnToApp);
return Promise.delay(1).then(() => {
return sleep(1).then(() => {
// we should be straight back into the home page
ReactTestUtils.findRenderedComponentWithType(
matrixChat, sdk.getComponent('structures.EmbeddedPage'));
@ -611,12 +611,12 @@ describe('loading:', function() {
});
describe('Token login:', function() {
it('logs in successfully', function(done) {
it('logs in successfully', function() {
loadApp({
queryString: "?loginToken=secretToken&homeserver=https%3A%2F%2Fhomeserver&identityServer=https%3A%2F%2Fidserver",
});
Promise.delay(1).then(() => {
return sleep(1).then(() => {
// we expect a spinner while we're logging in
assertAtLoadingSpinner(matrixChat);
@ -645,7 +645,7 @@ describe('loading:', function() {
expect(localStorage.getItem('mx_access_token')).toEqual('access_token');
expect(localStorage.getItem('mx_hs_url')).toEqual('https://homeserver');
expect(localStorage.getItem('mx_is_url')).toEqual('https://idserver');
}).done(done, done);
});
});
});
@ -664,7 +664,7 @@ describe('loading:', function() {
// Give the component some time to finish processing the login flows before
// continuing.
await Promise.delay(100);
await sleep(100);
httpBackend.when('POST', '/login').check(function(req) {
expect(req.data.type).toEqual('m.login.password');
@ -680,7 +680,7 @@ describe('loading:', function() {
return httpBackend.flush().then(() => {
// Wait for another trip around the event loop for the UI to update
return Promise.delay(1);
return sleep(1);
}).then(() => {
// we expect a spinner
ReactTestUtils.findRenderedComponentWithType(
@ -738,7 +738,7 @@ function awaitRoomView(matrixChat, retryLimit, retryCount) {
throw new Error("MatrixChat still not ready after " +
retryCount + " tries");
}
return Promise.delay(0).then(() => {
return sleep(0).then(() => {
return awaitRoomView(matrixChat, retryLimit, retryCount + 1);
});
}

View File

@ -1,7 +1,5 @@
"use strict";
import Promise from 'bluebird';
/**
* Perform common actions before each test case, e.g. printing the test case
* name to stdout.
@ -58,3 +56,7 @@ export function deleteIndexedDB(dbName) {
throw e;
});
}
export function sleep(ms) {
return new Promise((resolve) => { setTimeout(resolve, ms); });
}

View File

@ -919,7 +919,7 @@ babel-helper-explode-class@^6.24.1:
babel-traverse "^6.24.1"
babel-types "^6.24.1"
babel-helper-function-name@^6.24.1, babel-helper-function-name@^6.8.0:
babel-helper-function-name@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9"
integrity sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=
@ -1081,16 +1081,6 @@ babel-plugin-transform-async-generator-functions@^6.24.1:
babel-plugin-syntax-async-generators "^6.5.0"
babel-runtime "^6.22.0"
babel-plugin-transform-async-to-bluebird@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-to-bluebird/-/babel-plugin-transform-async-to-bluebird-1.1.1.tgz#46ea3e7c5af629782ac9f1ed1b7cd38f8425afd4"
integrity sha1-Ruo+fFr2KXgqyfHtG3zTj4Qlr9Q=
dependencies:
babel-helper-function-name "^6.8.0"
babel-plugin-syntax-async-functions "^6.8.0"
babel-template "^6.9.0"
babel-traverse "^6.10.4"
babel-plugin-transform-async-to-generator@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz#6536e378aff6cb1d5517ac0e40eb3e9fc8d08761"
@ -1513,7 +1503,7 @@ babel-runtime@^6.0.0, babel-runtime@^6.18.0, babel-runtime@^6.2.0, babel-runtime
core-js "^2.4.0"
regenerator-runtime "^0.11.0"
babel-template@^6.24.1, babel-template@^6.26.0, babel-template@^6.3.0, babel-template@^6.9.0:
babel-template@^6.24.1, babel-template@^6.26.0, babel-template@^6.3.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02"
integrity sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=
@ -1524,7 +1514,7 @@ babel-template@^6.24.1, babel-template@^6.26.0, babel-template@^6.3.0, babel-tem
babylon "^6.18.0"
lodash "^4.17.4"
babel-traverse@^6.10.4, babel-traverse@^6.24.1, babel-traverse@^6.26.0:
babel-traverse@^6.24.1, babel-traverse@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee"
integrity sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=
@ -1657,7 +1647,7 @@ bluebird-lst@^1.0.9:
dependencies:
bluebird "^3.5.5"
bluebird@3.5.5, bluebird@^3.3.0, bluebird@^3.5.0, bluebird@^3.5.2, bluebird@^3.5.5:
bluebird@3.5.5, bluebird@^3.3.0, bluebird@^3.5.0, bluebird@^3.5.5:
version "3.5.5"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.5.tgz#a8d0afd73251effbbd5fe384a77d73003c17a71f"
integrity sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==