Merge pull request #3761 from matrix-org/travis/babel7-wp-es6-export

Convert CommonJS exports to ES6 exports
This commit is contained in:
Travis Ralston 2020-01-08 09:09:11 -07:00 committed by GitHub
commit 59f608ffd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
159 changed files with 745 additions and 717 deletions

View file

@ -432,77 +432,73 @@ function selectQuery(store, keyRange, resultMapper) {
});
}
module.exports = {
/**
* Configure rage shaking support for sending bug reports.
* Modifies globals.
* @return {Promise} Resolves when set up.
*/
init: function() {
if (global.mx_rage_initPromise) {
return global.mx_rage_initPromise;
}
global.mx_rage_logger = new ConsoleLogger();
global.mx_rage_logger.monkeyPatch(window.console);
// just *accessing* indexedDB throws an exception in firefox with
// indexeddb disabled.
let indexedDB;
try {
indexedDB = window.indexedDB;
} catch (e) {}
if (indexedDB) {
global.mx_rage_store = new IndexedDBLogStore(indexedDB, global.mx_rage_logger);
global.mx_rage_initPromise = global.mx_rage_store.connect();
return global.mx_rage_initPromise;
}
global.mx_rage_initPromise = Promise.resolve();
/**
* Configure rage shaking support for sending bug reports.
* Modifies globals.
* @return {Promise} Resolves when set up.
*/
export function init() {
if (global.mx_rage_initPromise) {
return global.mx_rage_initPromise;
},
}
global.mx_rage_logger = new ConsoleLogger();
global.mx_rage_logger.monkeyPatch(window.console);
flush: function() {
if (!global.mx_rage_store) {
return;
}
global.mx_rage_store.flush();
},
// just *accessing* indexedDB throws an exception in firefox with
// indexeddb disabled.
let indexedDB;
try {
indexedDB = window.indexedDB;
} catch (e) {}
/**
* Clean up old logs.
* @return Promise Resolves if cleaned logs.
*/
cleanup: async function() {
if (!global.mx_rage_store) {
return;
}
await global.mx_rage_store.consume();
},
if (indexedDB) {
global.mx_rage_store = new IndexedDBLogStore(indexedDB, global.mx_rage_logger);
global.mx_rage_initPromise = global.mx_rage_store.connect();
return global.mx_rage_initPromise;
}
global.mx_rage_initPromise = Promise.resolve();
return global.mx_rage_initPromise;
}
/**
* Get a recent snapshot of the logs, ready for attaching to a bug report
*
* @return {Array<{lines: string, id, string}>} list of log data
*/
getLogsForReport: async function() {
if (!global.mx_rage_logger) {
throw new Error(
"No console logger, did you forget to call init()?",
);
}
// If in incognito mode, store is null, but we still want bug report
// sending to work going off the in-memory console logs.
if (global.mx_rage_store) {
// flush most recent logs
await global.mx_rage_store.flush();
return await global.mx_rage_store.consume();
} else {
return [{
lines: global.mx_rage_logger.flush(true),
id: "-",
}];
}
},
};
export function flush() {
if (!global.mx_rage_store) {
return;
}
global.mx_rage_store.flush();
}
/**
* Clean up old logs.
* @return Promise Resolves if cleaned logs.
*/
export async function cleanup() {
if (!global.mx_rage_store) {
return;
}
await global.mx_rage_store.consume();
}
/**
* Get a recent snapshot of the logs, ready for attaching to a bug report
*
* @return {Array<{lines: string, id, string}>} list of log data
*/
export async function getLogsForReport() {
if (!global.mx_rage_logger) {
throw new Error(
"No console logger, did you forget to call init()?",
);
}
// If in incognito mode, store is null, but we still want bug report
// sending to work going off the in-memory console logs.
if (global.mx_rage_store) {
// flush most recent logs
await global.mx_rage_store.flush();
return await global.mx_rage_store.consume();
} else {
return [{
lines: global.mx_rage_logger.flush(true),
id: "-",
}];
}
}

View file

@ -22,7 +22,7 @@ import {MatrixClientPeg} from '../MatrixClientPeg';
import PlatformPeg from '../PlatformPeg';
import { _t } from '../languageHandler';
import rageshake from './rageshake';
import * as rageshake from './rageshake';
// polyfill textencoder if necessary