Changes of osx stable v0.0.257 3
55
app/Constants.js
Normal file
|
@ -0,0 +1,55 @@
|
|||
'use strict';
|
||||
|
||||
// before we can set up (and export) our constants, we first need to grab bootstrap's constants
|
||||
// so we can merge them in with our constants
|
||||
function init(bootstrapConstants) {
|
||||
const APP_NAME = bootstrapConstants.APP_NAME;
|
||||
const API_ENDPOINT = bootstrapConstants.API_ENDPOINT;
|
||||
const UPDATE_ENDPOINT = bootstrapConstants.UPDATE_ENDPOINT;
|
||||
const APP_ID = bootstrapConstants.APP_ID;
|
||||
|
||||
const DEFAULT_MAIN_WINDOW_ID = 0;
|
||||
const MAIN_APP_DIRNAME = __dirname;
|
||||
|
||||
const UpdaterEvents = {
|
||||
UPDATE_NOT_AVAILABLE: 'UPDATE_NOT_AVAILABLE',
|
||||
CHECKING_FOR_UPDATES: 'CHECKING_FOR_UPDATES',
|
||||
UPDATE_ERROR: 'UPDATE_ERROR',
|
||||
UPDATE_MANUALLY: 'UPDATE_MANUALLY',
|
||||
UPDATE_AVAILABLE: 'UPDATE_AVAILABLE',
|
||||
MODULE_INSTALL_PROGRESS: 'MODULE_INSTALL_PROGRESS',
|
||||
UPDATE_DOWNLOADED: 'UPDATE_DOWNLOADED',
|
||||
MODULE_INSTALLED: 'MODULE_INSTALLED',
|
||||
CHECK_FOR_UPDATES: 'CHECK_FOR_UPDATES',
|
||||
QUIT_AND_INSTALL: 'QUIT_AND_INSTALL',
|
||||
MODULE_INSTALL: 'MODULE_INSTALL',
|
||||
MODULE_QUERY: 'MODULE_QUERY',
|
||||
UPDATER_HISTORY_QUERY_AND_TRUNCATE: 'UPDATER_HISTORY_QUERY_AND_TRUNCATE',
|
||||
UPDATER_HISTORY_RESPONSE: 'UPDATER_HISTORY_RESPONSE'
|
||||
};
|
||||
|
||||
const MenuEvents = {
|
||||
OPEN_HELP: 'menu:open-help',
|
||||
OPEN_SETTINGS: 'menu:open-settings',
|
||||
CHECK_FOR_UPDATES: 'menu:check-for-updates'
|
||||
};
|
||||
|
||||
const exported = {
|
||||
APP_NAME,
|
||||
DEFAULT_MAIN_WINDOW_ID,
|
||||
MAIN_APP_DIRNAME,
|
||||
APP_ID,
|
||||
API_ENDPOINT,
|
||||
UPDATE_ENDPOINT,
|
||||
UpdaterEvents,
|
||||
MenuEvents
|
||||
};
|
||||
|
||||
for (const key of Object.keys(exported)) {
|
||||
module.exports[key] = exported[key];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
init
|
||||
};
|
26
app/GPUSettings.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getEnableHardwareAcceleration = getEnableHardwareAcceleration;
|
||||
exports.setEnableHardwareAcceleration = setEnableHardwareAcceleration;
|
||||
|
||||
var _electron = require('electron');
|
||||
|
||||
var _appSettings = require('./appSettings');
|
||||
|
||||
const settings = (0, _appSettings.getSettings)();
|
||||
|
||||
function getEnableHardwareAcceleration() {
|
||||
// TODO: This should probably a constant
|
||||
return settings.get('enableHardwareAcceleration', true);
|
||||
}
|
||||
|
||||
function setEnableHardwareAcceleration(enableHardwareAcceleration) {
|
||||
settings.set('enableHardwareAcceleration', enableHardwareAcceleration);
|
||||
settings.save();
|
||||
|
||||
_electron.app.relaunch();
|
||||
_electron.app.exit(0);
|
||||
}
|
97
app/appBadge.js
Normal file
|
@ -0,0 +1,97 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.hasInit = undefined;
|
||||
exports.init = init;
|
||||
|
||||
var _electron = require('electron');
|
||||
|
||||
var _utils = require('./utils');
|
||||
|
||||
var _mainScreen = require('./mainScreen');
|
||||
|
||||
var _ipcMain = require('./ipcMain');
|
||||
|
||||
var _ipcMain2 = _interopRequireDefault(_ipcMain);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
let hasInit = exports.hasInit = false;
|
||||
|
||||
let lastIndex;
|
||||
let appIcons;
|
||||
|
||||
/**
|
||||
* Used on Windows to set the taskbar icon
|
||||
*/
|
||||
function init() {
|
||||
// Only init on win32 platforms
|
||||
if (process.platform !== 'win32') return;
|
||||
|
||||
if (hasInit) {
|
||||
console.warn('appBadge: Has already init! Cancelling init.');
|
||||
return;
|
||||
}
|
||||
exports.hasInit = hasInit = true;
|
||||
|
||||
lastIndex = null;
|
||||
appIcons = [];
|
||||
|
||||
const resourcePath = `app/images/badges`;
|
||||
|
||||
for (let i = 1; i <= 11; i++) {
|
||||
appIcons.push((0, _utils.exposeModuleResource)(resourcePath, `badge-${i}.ico`));
|
||||
}
|
||||
|
||||
_ipcMain2.default.on('APP_BADGE_SET', (_event, count) => setAppBadge(count));
|
||||
}
|
||||
|
||||
function setAppBadge(count) {
|
||||
const win = _electron.BrowserWindow.fromId((0, _mainScreen.getMainWindowId)());
|
||||
|
||||
const { index, description } = getOverlayIconData(count);
|
||||
|
||||
// Prevent setting a new icon when the icon is the same
|
||||
if (lastIndex !== index) {
|
||||
if (index == null) {
|
||||
win.setOverlayIcon(null, description);
|
||||
} else {
|
||||
win.setOverlayIcon(appIcons[index], description);
|
||||
}
|
||||
|
||||
lastIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* -1 is bullet
|
||||
* 0 is nothing
|
||||
* 1-9 is a number badge
|
||||
* 10+ is `9+`
|
||||
*/
|
||||
function getOverlayIconData(count) {
|
||||
// Unread message badge
|
||||
if (count === -1) {
|
||||
return {
|
||||
index: 10, // this.appIcons.length - 1
|
||||
description: `Unread messages`
|
||||
};
|
||||
}
|
||||
|
||||
// Clear overlay icon
|
||||
if (count === 0) {
|
||||
return {
|
||||
index: null, // null is used to clear the overlay icon
|
||||
description: 'No Notifications'
|
||||
};
|
||||
}
|
||||
|
||||
// Notification badge
|
||||
const index = Math.max(1, Math.min(count, 10)) - 1; // arrays are 0 based
|
||||
return {
|
||||
index,
|
||||
description: `${index} notifications`
|
||||
};
|
||||
}
|
62
app/appConfig.js
Normal file
|
@ -0,0 +1,62 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.hasInit = undefined;
|
||||
exports.init = init;
|
||||
|
||||
var _autoStart = require('./autoStart');
|
||||
|
||||
var autoStart = _interopRequireWildcard(_autoStart);
|
||||
|
||||
var _appSettings = require('./appSettings');
|
||||
|
||||
var _ipcMain = require('./ipcMain');
|
||||
|
||||
var _ipcMain2 = _interopRequireDefault(_ipcMain);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||||
|
||||
const settings = (0, _appSettings.getSettings)();
|
||||
const NOOP = () => {};
|
||||
|
||||
let hasInit = exports.hasInit = false;
|
||||
|
||||
function init() {
|
||||
if (hasInit) {
|
||||
console.warn('appConfig: Has already init! Cancelling init.');
|
||||
return;
|
||||
}
|
||||
exports.hasInit = hasInit = true;
|
||||
|
||||
_ipcMain2.default.on('TOGGLE_MINIMIZE_TO_TRAY', (_event, value) => setMinimizeOnClose(value));
|
||||
_ipcMain2.default.on('TOGGLE_OPEN_ON_STARTUP', (_event, value) => toggleRunOnStartup(value));
|
||||
_ipcMain2.default.on('TOGGLE_START_MINIMIZED', (_event, value) => toggleStartMinimized(value));
|
||||
}
|
||||
|
||||
function setMinimizeOnClose(minimizeToTray) {
|
||||
settings.set('MINIMIZE_TO_TRAY', minimizeToTray);
|
||||
}
|
||||
|
||||
function toggleRunOnStartup(openOnStartup) {
|
||||
settings.set('OPEN_ON_STARTUP', openOnStartup);
|
||||
|
||||
if (openOnStartup) {
|
||||
autoStart.install(NOOP);
|
||||
} else {
|
||||
autoStart.uninstall(NOOP);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleStartMinimized(startMinimized) {
|
||||
settings.set('START_MINIMIZED', startMinimized);
|
||||
autoStart.isInstalled(installed => {
|
||||
// Only update the registry for this toggle if the app was already set to autorun
|
||||
if (installed) {
|
||||
autoStart.install(NOOP);
|
||||
}
|
||||
});
|
||||
}
|
23
app/appFeatures.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.init = init;
|
||||
exports.getFeatures = getFeatures;
|
||||
|
||||
var _FeatureFlags = require('../common/FeatureFlags');
|
||||
|
||||
var _FeatureFlags2 = _interopRequireDefault(_FeatureFlags);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
let features;
|
||||
|
||||
function init() {
|
||||
features = new _FeatureFlags2.default();
|
||||
}
|
||||
|
||||
function getFeatures() {
|
||||
return features;
|
||||
}
|
3
app/appSettings.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = require('./bootstrapModules').appSettings;
|
143
app/applicationMenu/darwin.js
Normal file
|
@ -0,0 +1,143 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _electron = require('electron');
|
||||
|
||||
var _Constants = require('../Constants');
|
||||
|
||||
var Constants = _interopRequireWildcard(_Constants);
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||||
|
||||
const { MenuEvents } = Constants;
|
||||
const SEPARATOR = { type: 'separator' };
|
||||
|
||||
function getWindow() {
|
||||
let window = _electron.BrowserWindow.getFocusedWindow();
|
||||
if (!window) {
|
||||
const windowList = _electron.BrowserWindow.getAllWindows();
|
||||
if (windowList && windowList[0]) {
|
||||
window = windowList[0];
|
||||
window.show();
|
||||
window.focus();
|
||||
}
|
||||
}
|
||||
return window;
|
||||
}
|
||||
|
||||
exports.default = [{
|
||||
label: 'Discord',
|
||||
submenu: [{
|
||||
label: 'About Discord',
|
||||
selector: 'orderFrontStandardAboutPanel:'
|
||||
}, {
|
||||
label: 'Check for Updates...',
|
||||
click: () => _electron.app.emit(MenuEvents.CHECK_FOR_UPDATES)
|
||||
}, {
|
||||
label: 'Acknowledgements',
|
||||
click: () => _electron.shell.openExternal('https://discordapp.com/acknowledgements')
|
||||
}, SEPARATOR, {
|
||||
label: 'Preferences',
|
||||
click: () => _electron.app.emit(MenuEvents.OPEN_SETTINGS),
|
||||
accelerator: 'Command+,'
|
||||
}, SEPARATOR, {
|
||||
label: 'Services',
|
||||
submenu: []
|
||||
}, SEPARATOR, {
|
||||
label: 'Hide Discord',
|
||||
selector: 'hide:',
|
||||
accelerator: 'Command+H'
|
||||
}, {
|
||||
label: 'Hide Others',
|
||||
selector: 'hideOtherApplications:',
|
||||
accelerator: 'Command+Alt+H'
|
||||
}, {
|
||||
label: 'Show All',
|
||||
selector: 'unhideAllApplications:'
|
||||
}, SEPARATOR, {
|
||||
label: 'Quit',
|
||||
click: () => _electron.app.quit(),
|
||||
accelerator: 'Command+Q'
|
||||
}]
|
||||
}, {
|
||||
label: 'Edit',
|
||||
submenu: [{
|
||||
role: 'undo',
|
||||
accelerator: 'Command+Z'
|
||||
}, {
|
||||
role: 'redo',
|
||||
accelerator: 'Shift+Command+Z'
|
||||
}, SEPARATOR, {
|
||||
role: 'cut',
|
||||
accelerator: 'Command+X'
|
||||
}, {
|
||||
role: 'copy',
|
||||
accelerator: 'Command+C'
|
||||
}, {
|
||||
role: 'paste',
|
||||
accelerator: 'Command+V'
|
||||
}, {
|
||||
role: 'selectAll',
|
||||
accelerator: 'Command+A'
|
||||
}]
|
||||
}, {
|
||||
label: 'View',
|
||||
submenu: [{
|
||||
label: 'Reload',
|
||||
click: () => {
|
||||
const window = getWindow();
|
||||
if (window) {
|
||||
window.webContents.reloadIgnoringCache();
|
||||
}
|
||||
},
|
||||
accelerator: 'Command+R'
|
||||
}, {
|
||||
label: 'Toggle Full Screen',
|
||||
click: () => {
|
||||
const window = getWindow();
|
||||
if (window) {
|
||||
window.setFullScreen(!window.isFullScreen());
|
||||
}
|
||||
},
|
||||
accelerator: 'Command+Control+F'
|
||||
}, SEPARATOR, {
|
||||
label: 'Developer',
|
||||
submenu: [{
|
||||
label: 'Toggle Developer Tools',
|
||||
click: () => {
|
||||
const window = getWindow();
|
||||
if (window) {
|
||||
window.toggleDevTools();
|
||||
}
|
||||
},
|
||||
accelerator: 'Alt+Command+I'
|
||||
}]
|
||||
}]
|
||||
}, {
|
||||
label: 'Window',
|
||||
submenu: [{
|
||||
label: 'Minimize',
|
||||
selector: 'performMiniaturize:',
|
||||
accelerator: 'Command+M'
|
||||
}, {
|
||||
label: 'Zoom',
|
||||
selector: 'performZoom:'
|
||||
}, {
|
||||
label: 'Close',
|
||||
accelerator: 'Command+W',
|
||||
selector: 'hide:'
|
||||
}, SEPARATOR, {
|
||||
label: 'Bring All to Front',
|
||||
selector: 'arrangeInFront:'
|
||||
}]
|
||||
}, {
|
||||
label: 'Help',
|
||||
submenu: [{
|
||||
label: 'Discord Help',
|
||||
click: () => _electron.app.emit(MenuEvents.OPEN_HELP)
|
||||
}]
|
||||
}];
|
||||
module.exports = exports.default;
|
12
app/applicationMenu/index.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _electron = require('electron');
|
||||
|
||||
const menu = require('./' + process.platform);
|
||||
|
||||
exports.default = _electron.Menu.buildFromTemplate(menu);
|
||||
module.exports = exports.default;
|
78
app/applicationMenu/linux.js
Normal file
|
@ -0,0 +1,78 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _electron = require('electron');
|
||||
|
||||
var _Constants = require('../Constants');
|
||||
|
||||
var Constants = _interopRequireWildcard(_Constants);
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||||
|
||||
const { MenuEvents } = Constants;
|
||||
const SEPARATOR = { type: 'separator' };
|
||||
|
||||
exports.default = [{
|
||||
label: '&File',
|
||||
submenu: [{
|
||||
label: '&Options',
|
||||
click: () => _electron.app.emit(MenuEvents.OPEN_SETTINGS),
|
||||
accelerator: 'Control+,'
|
||||
}, SEPARATOR, {
|
||||
label: 'E&xit',
|
||||
click: () => _electron.app.quit(),
|
||||
accelerator: 'Control+Q'
|
||||
}]
|
||||
}, {
|
||||
label: '&Edit',
|
||||
submenu: [{
|
||||
role: 'undo',
|
||||
accelerator: 'Control+Z'
|
||||
}, {
|
||||
role: 'redo',
|
||||
accelerator: 'Shift+Control+Z'
|
||||
}, SEPARATOR, {
|
||||
role: 'cut',
|
||||
accelerator: 'Control+X'
|
||||
}, {
|
||||
role: 'copy',
|
||||
accelerator: 'Control+C'
|
||||
}, {
|
||||
role: 'paste',
|
||||
accelerator: 'Control+V'
|
||||
}, {
|
||||
role: 'selectAll',
|
||||
accelerator: 'Control+A'
|
||||
}]
|
||||
}, {
|
||||
label: '&View',
|
||||
submenu: [{
|
||||
label: '&Reload',
|
||||
click: () => _electron.BrowserWindow.getFocusedWindow().webContents.reloadIgnoringCache(),
|
||||
accelerator: 'Control+R'
|
||||
}, {
|
||||
label: 'Toggle &Full Screen',
|
||||
click: () => _electron.BrowserWindow.getFocusedWindow().setFullScreen(!_electron.BrowserWindow.getFocusedWindow().isFullScreen()),
|
||||
accelerator: 'Control+Shift+F'
|
||||
}, SEPARATOR, {
|
||||
label: '&Developer',
|
||||
submenu: [{
|
||||
label: 'Toggle Developer &Tools',
|
||||
click: () => _electron.BrowserWindow.getFocusedWindow().toggleDevTools(),
|
||||
accelerator: 'Control+Shift+I'
|
||||
}]
|
||||
}]
|
||||
}, {
|
||||
label: '&Help',
|
||||
submenu: [{
|
||||
label: 'Check for Updates',
|
||||
click: () => _electron.app.emit(MenuEvents.CHECK_FOR_UPDATES)
|
||||
}, SEPARATOR, {
|
||||
label: 'Discord Help',
|
||||
click: () => _electron.app.emit(MenuEvents.OPEN_HELP)
|
||||
}]
|
||||
}];
|
||||
module.exports = exports.default;
|
57
app/applicationMenu/win32.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _electron = require('electron');
|
||||
|
||||
var _Constants = require('../Constants');
|
||||
|
||||
var Constants = _interopRequireWildcard(_Constants);
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||||
|
||||
const { MenuEvents } = Constants;
|
||||
const SEPARATOR = { type: 'separator' };
|
||||
|
||||
exports.default = [{
|
||||
label: '&File',
|
||||
submenu: [{
|
||||
label: '&Options',
|
||||
click: () => _electron.app.emit(MenuEvents.OPEN_SETTINGS),
|
||||
accelerator: 'Ctrl+,'
|
||||
}, SEPARATOR, {
|
||||
label: '&Exit',
|
||||
click: () => _electron.app.quit(),
|
||||
accelerator: 'Alt+F4'
|
||||
}]
|
||||
}, {
|
||||
label: '&View',
|
||||
submenu: [{
|
||||
label: '&Reload',
|
||||
click: () => _electron.BrowserWindow.getFocusedWindow().webContents.reloadIgnoringCache(),
|
||||
accelerator: 'Control+R'
|
||||
}, {
|
||||
label: 'Toggle &Full Screen',
|
||||
click: () => _electron.BrowserWindow.getFocusedWindow().setFullScreen(!_electron.BrowserWindow.getFocusedWindow().isFullScreen()),
|
||||
accelerator: 'Control+Shift+F'
|
||||
}, SEPARATOR, {
|
||||
label: '&Developer',
|
||||
submenu: [{
|
||||
label: 'Toggle Developer &Tools',
|
||||
click: () => _electron.BrowserWindow.getFocusedWindow().toggleDevTools(),
|
||||
accelerator: 'Control+Shift+I'
|
||||
}]
|
||||
}]
|
||||
}, {
|
||||
label: '&Help',
|
||||
submenu: [{
|
||||
label: 'Check for Updates',
|
||||
click: () => _electron.app.emit(MenuEvents.CHECK_FOR_UPDATES)
|
||||
}, SEPARATOR, {
|
||||
label: 'Discord Help',
|
||||
click: () => _electron.app.emit(MenuEvents.OPEN_HELP)
|
||||
}]
|
||||
}];
|
||||
module.exports = exports.default;
|
3
app/autoStart.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = require('./bootstrapModules').autoStart;
|
13
app/bootstrapModules.js
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
"use strict";
|
||||
|
||||
let hasInit = false;
|
||||
|
||||
exports.init = function (bootstrapModules) {
|
||||
if (hasInit) {
|
||||
throw new Error(`bootstrapModules has already init`);
|
||||
}
|
||||
for (const mod of Object.keys(bootstrapModules)) {
|
||||
exports[mod] = bootstrapModules[mod];
|
||||
}
|
||||
hasInit = true;
|
||||
};
|
3
app/buildInfo.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = require('./bootstrapModules').buildInfo;
|
3865
app/data/cacert.pem
Normal file
17
app/discord_native/browser/accessibility.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
'use strict';
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
|
||||
const { ACCESSIBILITY_GET_ENABLED } = require('../common/constants').IPCEvents;
|
||||
|
||||
electron.ipcMain.handle(ACCESSIBILITY_GET_ENABLED, (() => {
|
||||
var _ref = _asyncToGenerator(function* (_) {
|
||||
return electron.app.accessibilitySupportEnabled;
|
||||
});
|
||||
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})());
|
137
app/discord_native/browser/app.js
Normal file
|
@ -0,0 +1,137 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.injectBuildInfo = injectBuildInfo;
|
||||
exports.injectModuleUpdater = injectModuleUpdater;
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
|
||||
const {
|
||||
APP_GET_RELEASE_CHANNEL_SYNC,
|
||||
APP_GET_HOST_VERSION_SYNC,
|
||||
APP_GET_MODULE_VERSIONS,
|
||||
APP_GET_PATH,
|
||||
APP_SET_BADGE_COUNT,
|
||||
APP_DOCK_SET_BADGE,
|
||||
APP_DOCK_BOUNCE,
|
||||
APP_DOCK_CANCEL_BOUNCE,
|
||||
APP_RELAUNCH,
|
||||
APP_GET_DEFAULT_DOUBLE_CLICK_ACTION
|
||||
} = require('../common/constants').IPCEvents;
|
||||
|
||||
let injectedBuildInfo = null;
|
||||
let injectedModuleUpdater = null;
|
||||
|
||||
function injectBuildInfo(buildInfo) {
|
||||
injectedBuildInfo = buildInfo;
|
||||
}
|
||||
|
||||
function injectModuleUpdater(moduleUpdater) {
|
||||
injectedModuleUpdater = moduleUpdater;
|
||||
}
|
||||
|
||||
electron.ipcMain.on(APP_GET_RELEASE_CHANNEL_SYNC, event => {
|
||||
event.returnValue = injectedBuildInfo.releaseChannel;
|
||||
});
|
||||
|
||||
electron.ipcMain.on(APP_GET_HOST_VERSION_SYNC, event => {
|
||||
event.returnValue = electron.app.getVersion();
|
||||
});
|
||||
|
||||
electron.ipcMain.handle(APP_GET_MODULE_VERSIONS, (() => {
|
||||
var _ref = _asyncToGenerator(function* (_) {
|
||||
const versions = {};
|
||||
const installed = injectedModuleUpdater != null ? injectedModuleUpdater.getInstalled() : {};
|
||||
for (const name of Object.keys(installed)) {
|
||||
versions[name] = installed[name].installedVersion;
|
||||
}
|
||||
return versions;
|
||||
});
|
||||
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(APP_GET_PATH, (() => {
|
||||
var _ref2 = _asyncToGenerator(function* (_, path) {
|
||||
return electron.app.getPath(path);
|
||||
});
|
||||
|
||||
return function (_x2, _x3) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(APP_SET_BADGE_COUNT, (() => {
|
||||
var _ref3 = _asyncToGenerator(function* (_, count) {
|
||||
electron.app.setBadgeCount(count);
|
||||
});
|
||||
|
||||
return function (_x4, _x5) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(APP_DOCK_SET_BADGE, (() => {
|
||||
var _ref4 = _asyncToGenerator(function* (_, badge) {
|
||||
if (electron.app.dock != null) {
|
||||
electron.app.dock.setBadge(badge);
|
||||
}
|
||||
});
|
||||
|
||||
return function (_x6, _x7) {
|
||||
return _ref4.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(APP_DOCK_BOUNCE, (() => {
|
||||
var _ref5 = _asyncToGenerator(function* (_, type) {
|
||||
if (electron.app.dock != null) {
|
||||
return electron.app.dock.bounce(type);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
});
|
||||
|
||||
return function (_x8, _x9) {
|
||||
return _ref5.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(APP_DOCK_CANCEL_BOUNCE, (() => {
|
||||
var _ref6 = _asyncToGenerator(function* (_, id) {
|
||||
if (electron.app.dock != null) {
|
||||
electron.app.dock.cancelBounce(id);
|
||||
}
|
||||
});
|
||||
|
||||
return function (_x10, _x11) {
|
||||
return _ref6.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(APP_RELAUNCH, (() => {
|
||||
var _ref7 = _asyncToGenerator(function* (_) {
|
||||
electron.app.relaunch();
|
||||
electron.app.exit(0);
|
||||
});
|
||||
|
||||
return function (_x12) {
|
||||
return _ref7.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(APP_GET_DEFAULT_DOUBLE_CLICK_ACTION, (() => {
|
||||
var _ref8 = _asyncToGenerator(function* (_) {
|
||||
return electron.systemPreferences.getUserDefault('AppleActionOnDoubleClick', 'string');
|
||||
});
|
||||
|
||||
return function (_x13) {
|
||||
return _ref8.apply(this, arguments);
|
||||
};
|
||||
})());
|
37
app/discord_native/browser/clipboard.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
'use strict';
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
|
||||
const { CLIPBOARD_COPY, CLIPBOARD_CUT, CLIPBOARD_PASTE } = require('../common/constants').IPCEvents;
|
||||
|
||||
electron.ipcMain.handle(CLIPBOARD_COPY, (() => {
|
||||
var _ref = _asyncToGenerator(function* (_) {
|
||||
electron.webContents.getFocusedWebContents().copy();
|
||||
});
|
||||
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(CLIPBOARD_CUT, (() => {
|
||||
var _ref2 = _asyncToGenerator(function* (_) {
|
||||
electron.webContents.getFocusedWebContents().cut();
|
||||
});
|
||||
|
||||
return function (_x2) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(CLIPBOARD_PASTE, (() => {
|
||||
var _ref3 = _asyncToGenerator(function* (_) {
|
||||
electron.webContents.getFocusedWebContents().paste();
|
||||
});
|
||||
|
||||
return function (_x3) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
})());
|
77
app/discord_native/browser/crashReporter.js
Normal file
|
@ -0,0 +1,77 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.injectBuildInfo = injectBuildInfo;
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
const lodash = require('lodash');
|
||||
const childProcess = require('child_process');
|
||||
const { getElectronMajorVersion, flatten, reconcileCrashReporterMetadata } = require('../common/utility');
|
||||
|
||||
const { CRASH_REPORTER_UPDATE_METADATA } = require('../common/constants').IPCEvents;
|
||||
|
||||
const metadata = exports.metadata = {};
|
||||
|
||||
function injectBuildInfo(buildInfo) {
|
||||
metadata['channel'] = buildInfo.releaseChannel;
|
||||
const sentryMetadata = metadata['sentry'] != null ? metadata['sentry'] : {};
|
||||
sentryMetadata['environment'] = buildInfo.releaseChannel;
|
||||
sentryMetadata['release'] = buildInfo.version;
|
||||
metadata['sentry'] = sentryMetadata;
|
||||
}
|
||||
|
||||
if (process.platform === 'linux') {
|
||||
const XDG_CURRENT_DESKTOP = process.env.XDG_CURRENT_DESKTOP || 'unknown';
|
||||
const GDMSESSION = process.env.GDMSESSION || 'unknown';
|
||||
metadata['wm'] = `${XDG_CURRENT_DESKTOP},${GDMSESSION}`;
|
||||
try {
|
||||
metadata['distro'] = childProcess.execFileSync('lsb_release', ['-ds'], { timeout: 100, maxBuffer: 512, encoding: 'utf-8' }).trim();
|
||||
} catch (_) {} // just in case lsb_release doesn't exist
|
||||
}
|
||||
|
||||
function getCrashReporterArgs(metadata) {
|
||||
// NB: we need to flatten the metadata because modern electron caps metadata values at 127 bytes,
|
||||
// which our sentry subobject can easily exceed.
|
||||
let flat_metadata = flatten(metadata);
|
||||
|
||||
return {
|
||||
productName: 'Discord',
|
||||
companyName: 'Discord Inc.',
|
||||
submitURL: 'https://sentry.io/api/146342/minidump/?sentry_key=384ce4413de74fe0be270abe03b2b35a',
|
||||
uploadToServer: true,
|
||||
ignoreSystemCrashHandler: false,
|
||||
extra: flat_metadata
|
||||
};
|
||||
}
|
||||
|
||||
electron.crashReporter.start(getCrashReporterArgs(metadata));
|
||||
|
||||
electron.ipcMain.handle(CRASH_REPORTER_UPDATE_METADATA, (() => {
|
||||
var _ref = _asyncToGenerator(function* (_, additional_metadata) {
|
||||
const final_metadata = lodash.defaultsDeep({}, metadata, additional_metadata || {});
|
||||
const result = {
|
||||
metadata: final_metadata
|
||||
};
|
||||
|
||||
// In Electron 9 we only start the crashReporter once and let reconcileCrashReporterMetadata
|
||||
// do the work of keeping `extra` up-to-date. Prior to this we would simply start crashReporter
|
||||
// again to apply new metadata as well as pass the full arguments back to the renderer so it
|
||||
// could do similarly.
|
||||
if (getElectronMajorVersion() < 9) {
|
||||
const args = getCrashReporterArgs(final_metadata);
|
||||
electron.crashReporter.start(args);
|
||||
result.args = args;
|
||||
}
|
||||
|
||||
reconcileCrashReporterMetadata(electron.crashReporter, final_metadata);
|
||||
return result;
|
||||
});
|
||||
|
||||
return function (_x, _x2) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})());
|
31
app/discord_native/browser/features.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.injectFeaturesBackend = injectFeaturesBackend;
|
||||
const electron = require('electron');
|
||||
|
||||
const { FEATURES_GET_BROWSER_FEATURES } = require('../common/constants').IPCEvents;
|
||||
|
||||
let injectedFeatures = null;
|
||||
|
||||
function getFeatures() {
|
||||
return injectedFeatures != null ? injectedFeatures : {
|
||||
getSupported: () => {
|
||||
return [];
|
||||
},
|
||||
supports: () => {
|
||||
return false;
|
||||
},
|
||||
declareSupported: () => {}
|
||||
};
|
||||
}
|
||||
|
||||
function injectFeaturesBackend(features) {
|
||||
injectedFeatures = features;
|
||||
}
|
||||
|
||||
electron.ipcMain.on(FEATURES_GET_BROWSER_FEATURES, event => {
|
||||
event.returnValue = getFeatures().getSupported();
|
||||
});
|
52
app/discord_native/browser/fileManager.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
'use strict';
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
|
||||
const {
|
||||
FILE_MANAGER_GET_MODULE_PATH,
|
||||
FILE_MANAGER_SHOW_SAVE_DIALOG,
|
||||
FILE_MANAGER_SHOW_OPEN_DIALOG,
|
||||
FILE_MANAGER_SHOW_ITEM_IN_FOLDER
|
||||
} = require('../common/constants').IPCEvents;
|
||||
|
||||
electron.ipcMain.handle(FILE_MANAGER_GET_MODULE_PATH, (() => {
|
||||
var _ref = _asyncToGenerator(function* (_) {
|
||||
return global.modulePath;
|
||||
});
|
||||
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(FILE_MANAGER_SHOW_SAVE_DIALOG, (() => {
|
||||
var _ref2 = _asyncToGenerator(function* (_, dialogOptions) {
|
||||
return yield electron.dialog.showSaveDialog(dialogOptions);
|
||||
});
|
||||
|
||||
return function (_x2, _x3) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(FILE_MANAGER_SHOW_OPEN_DIALOG, (() => {
|
||||
var _ref3 = _asyncToGenerator(function* (_, dialogOptions) {
|
||||
return yield electron.dialog.showOpenDialog(dialogOptions);
|
||||
});
|
||||
|
||||
return function (_x4, _x5) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(FILE_MANAGER_SHOW_ITEM_IN_FOLDER, (() => {
|
||||
var _ref4 = _asyncToGenerator(function* (_, path) {
|
||||
electron.shell.showItemInFolder(path);
|
||||
});
|
||||
|
||||
return function (_x6, _x7) {
|
||||
return _ref4.apply(this, arguments);
|
||||
};
|
||||
})());
|
37
app/discord_native/browser/gpuSettings.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.injectGpuSettingsBackend = injectGpuSettingsBackend;
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
|
||||
const {
|
||||
GPU_SETTINGS_SET_ENABLE_HWACCEL,
|
||||
GPU_SETTINGS_GET_ENABLE_HWACCEL_SYNC
|
||||
} = require('../common/constants').IPCEvents;
|
||||
|
||||
let injectedGpuSettings = null;
|
||||
|
||||
function injectGpuSettingsBackend(gpuSettings) {
|
||||
injectedGpuSettings = gpuSettings;
|
||||
}
|
||||
|
||||
electron.ipcMain.handle(GPU_SETTINGS_SET_ENABLE_HWACCEL, (() => {
|
||||
var _ref = _asyncToGenerator(function* (_, enable) {
|
||||
if (injectedGpuSettings) {
|
||||
injectedGpuSettings.setEnableHardwareAcceleration(enable);
|
||||
}
|
||||
});
|
||||
|
||||
return function (_x, _x2) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.on(GPU_SETTINGS_GET_ENABLE_HWACCEL_SYNC, event => {
|
||||
event.returnValue = injectedGpuSettings != null ? injectedGpuSettings.getEnableHardwareAcceleration() : false;
|
||||
});
|
57
app/discord_native/browser/nativeModules.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.injectModuleUpdater = injectModuleUpdater;
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
const { once } = require('events');
|
||||
|
||||
const { NATIVE_MODULES_GET_PATHS, NATIVE_MODULES_INSTALL } = require('../common/constants').IPCEvents;
|
||||
|
||||
let injectedModuleUpdater = null;
|
||||
|
||||
function injectModuleUpdater(moduleUpdater) {
|
||||
injectedModuleUpdater = moduleUpdater;
|
||||
}
|
||||
|
||||
electron.ipcMain.on(NATIVE_MODULES_GET_PATHS, event => {
|
||||
event.returnValue = {
|
||||
mainAppDirname: global.mainAppDirname,
|
||||
browserModulePaths: require('module').globalPaths
|
||||
};
|
||||
});
|
||||
|
||||
electron.ipcMain.handle(NATIVE_MODULES_INSTALL, (() => {
|
||||
var _ref = _asyncToGenerator(function* (_, moduleName) {
|
||||
const updater = injectedModuleUpdater;
|
||||
if (!updater) {
|
||||
throw new Error('Module updater is not available!');
|
||||
}
|
||||
|
||||
const waitForInstall = new Promise(function (resolve, reject) {
|
||||
let installedHandler = function (installedModuleEvent) {
|
||||
if (installedModuleEvent.name === moduleName) {
|
||||
updater.events.removeListener(updater.INSTALLED_MODULE, installedHandler);
|
||||
if (installedModuleEvent.succeeded) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(new Error(`Failed to install ${moduleName}`));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
updater.events.on(updater.INSTALLED_MODULE, installedHandler);
|
||||
});
|
||||
|
||||
updater.install(moduleName, false);
|
||||
yield waitForInstall;
|
||||
});
|
||||
|
||||
return function (_x, _x2) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})());
|
48
app/discord_native/browser/powerMonitor.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
'use strict';
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
|
||||
const {
|
||||
POWER_MONITOR_RESUME,
|
||||
POWER_MONITOR_SUSPEND,
|
||||
POWER_MONITOR_LOCK_SCREEN,
|
||||
POWER_MONITOR_UNLOCK_SCREEN,
|
||||
POWER_MONITOR_GET_SYSTEM_IDLE_TIME
|
||||
} = require('../common/constants').IPCEvents;
|
||||
|
||||
electron.ipcMain.handle(POWER_MONITOR_GET_SYSTEM_IDLE_TIME, (() => {
|
||||
var _ref = _asyncToGenerator(function* (_) {
|
||||
return electron.powerMonitor.getSystemIdleTime() * 1000;
|
||||
});
|
||||
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
function sendToAllWindows(channel) {
|
||||
electron.BrowserWindow.getAllWindows().forEach(win => {
|
||||
const contents = win.webContents;
|
||||
if (contents != null) {
|
||||
contents.send(channel);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
electron.powerMonitor.on('resume', () => {
|
||||
sendToAllWindows(POWER_MONITOR_RESUME);
|
||||
});
|
||||
|
||||
electron.powerMonitor.on('suspend', () => {
|
||||
sendToAllWindows(POWER_MONITOR_SUSPEND);
|
||||
});
|
||||
|
||||
electron.powerMonitor.on('lock-screen', () => {
|
||||
sendToAllWindows(POWER_MONITOR_LOCK_SCREEN);
|
||||
});
|
||||
|
||||
electron.powerMonitor.on('unlock-screen', () => {
|
||||
sendToAllWindows(POWER_MONITOR_UNLOCK_SCREEN);
|
||||
});
|
50
app/discord_native/browser/powerSaveBlocker.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
'use strict';
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
|
||||
const {
|
||||
POWER_SAVE_BLOCKER_BLOCK_DISPLAY_SLEEP,
|
||||
POWER_SAVE_BLOCKER_UNBLOCK_DISPLAY_SLEEP,
|
||||
POWER_SAVE_BLOCKER_CLEANUP_DISPLAY_SLEEP
|
||||
} = require('../common/constants').IPCEvents;
|
||||
|
||||
const powerSaveBlockerIds = new Set();
|
||||
|
||||
electron.ipcMain.handle(POWER_SAVE_BLOCKER_BLOCK_DISPLAY_SLEEP, (() => {
|
||||
var _ref = _asyncToGenerator(function* (_) {
|
||||
const newId = electron.powerSaveBlocker.start('prevent-display-sleep');
|
||||
powerSaveBlockerIds.add(newId);
|
||||
return newId;
|
||||
});
|
||||
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(POWER_SAVE_BLOCKER_UNBLOCK_DISPLAY_SLEEP, (() => {
|
||||
var _ref2 = _asyncToGenerator(function* (_, id) {
|
||||
electron.powerSaveBlocker.stop(id);
|
||||
powerSaveBlockerIds.delete(id);
|
||||
});
|
||||
|
||||
return function (_x2, _x3) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(POWER_SAVE_BLOCKER_CLEANUP_DISPLAY_SLEEP, (() => {
|
||||
var _ref3 = _asyncToGenerator(function* (_) {
|
||||
// cleanup all previous sleeps
|
||||
for (const id of powerSaveBlockerIds) {
|
||||
electron.powerSaveBlocker.stop(id);
|
||||
}
|
||||
powerSaveBlockerIds.clear();
|
||||
});
|
||||
|
||||
return function (_x4) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
})());
|
75
app/discord_native/browser/processUtils.js
Normal file
|
@ -0,0 +1,75 @@
|
|||
'use strict';
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
const process = require('process');
|
||||
|
||||
const {
|
||||
PROCESS_UTILS_GET_CPU_USAGE,
|
||||
PROCESS_UTILS_GET_MEMORY_INFO,
|
||||
PROCESS_UTILS_FLUSH_DNS_CACHE,
|
||||
PROCESS_UTILS_FLUSH_COOKIES,
|
||||
PROCESS_UTILS_FLUSH_STORAGE_DATA,
|
||||
PROCESS_UTILS_GET_MAIN_ARGV_SYNC
|
||||
} = require('../common/constants').IPCEvents;
|
||||
|
||||
electron.ipcMain.handle(PROCESS_UTILS_GET_CPU_USAGE, (() => {
|
||||
var _ref = _asyncToGenerator(function* (_) {
|
||||
let totalProcessorUsagePercent = 0.0;
|
||||
for (const processMetric of electron.app.getAppMetrics()) {
|
||||
totalProcessorUsagePercent += processMetric.cpu.percentCPUUsage;
|
||||
}
|
||||
return totalProcessorUsagePercent;
|
||||
});
|
||||
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(PROCESS_UTILS_GET_MEMORY_INFO, (() => {
|
||||
var _ref2 = _asyncToGenerator(function* (_) {
|
||||
return process.getProcessMemoryInfo();
|
||||
});
|
||||
|
||||
return function (_x2) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(PROCESS_UTILS_FLUSH_DNS_CACHE, (() => {
|
||||
var _ref3 = _asyncToGenerator(function* (_) {
|
||||
const defaultSession = electron.session.defaultSession;
|
||||
if (!defaultSession || !defaultSession.clearHostResolverCache) return;
|
||||
defaultSession.clearHostResolverCache();
|
||||
});
|
||||
|
||||
return function (_x3) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(PROCESS_UTILS_FLUSH_COOKIES, (() => {
|
||||
var _ref4 = _asyncToGenerator(function* (_) {
|
||||
return electron.session.defaultSession.cookies.flushStore();
|
||||
});
|
||||
|
||||
return function (_x4) {
|
||||
return _ref4.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(PROCESS_UTILS_FLUSH_STORAGE_DATA, (() => {
|
||||
var _ref5 = _asyncToGenerator(function* (_) {
|
||||
electron.session.defaultSession.flushStorageData();
|
||||
});
|
||||
|
||||
return function (_x5) {
|
||||
return _ref5.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.on(PROCESS_UTILS_GET_MAIN_ARGV_SYNC, event => {
|
||||
event.returnValue = process.argv;
|
||||
});
|
39
app/discord_native/browser/settings.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.injectSettingsBackend = injectSettingsBackend;
|
||||
const electron = require('electron');
|
||||
|
||||
const { SETTINGS_GET, SETTINGS_SET, SETTINGS_GET_SYNC } = require('../common/constants').IPCEvents;
|
||||
|
||||
let injectedSettings = null;
|
||||
|
||||
function getSettings() {
|
||||
return injectedSettings != null ? injectedSettings : {
|
||||
get: () => {},
|
||||
set: () => {},
|
||||
save: () => {}
|
||||
};
|
||||
}
|
||||
|
||||
function injectSettingsBackend(settings) {
|
||||
injectedSettings = settings;
|
||||
}
|
||||
|
||||
electron.ipcMain.handle(SETTINGS_GET, (_, name, defaultValue) => {
|
||||
const settings = getSettings();
|
||||
return settings.get(name, defaultValue);
|
||||
});
|
||||
|
||||
electron.ipcMain.handle(SETTINGS_SET, (_, name, value) => {
|
||||
const settings = getSettings();
|
||||
settings.set(name, value);
|
||||
settings.save();
|
||||
});
|
||||
|
||||
electron.ipcMain.on(SETTINGS_GET_SYNC, (event, name, defaultValue) => {
|
||||
const settings = getSettings();
|
||||
event.returnValue = settings.get(name, defaultValue);
|
||||
});
|
75
app/discord_native/browser/spellCheck.js
Normal file
|
@ -0,0 +1,75 @@
|
|||
'use strict';
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
|
||||
const {
|
||||
SPELLCHECK_REPLACE_MISSPELLING,
|
||||
SPELLCHECK_GET_AVAILABLE_DICTIONARIES,
|
||||
SPELLCHECK_SET_LOCALE,
|
||||
SPELLCHECK_SET_LEARNED_WORDS
|
||||
} = require('../common/constants').IPCEvents;
|
||||
|
||||
let _learnedWords = new Set();
|
||||
let _hasLoadedLearnedWords = false;
|
||||
|
||||
electron.ipcMain.handle(SPELLCHECK_REPLACE_MISSPELLING, (() => {
|
||||
var _ref = _asyncToGenerator(function* (event, correction) {
|
||||
event.sender.replaceMisspelling(correction);
|
||||
});
|
||||
|
||||
return function (_x, _x2) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(SPELLCHECK_GET_AVAILABLE_DICTIONARIES, (() => {
|
||||
var _ref2 = _asyncToGenerator(function* (_) {
|
||||
return electron.session.defaultSession.availableSpellCheckerLanguages;
|
||||
});
|
||||
|
||||
return function (_x3) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(SPELLCHECK_SET_LOCALE, (() => {
|
||||
var _ref3 = _asyncToGenerator(function* (_, locale) {
|
||||
electron.session.defaultSession.setSpellCheckerLanguages([locale]);
|
||||
});
|
||||
|
||||
return function (_x4, _x5) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(SPELLCHECK_SET_LEARNED_WORDS, (() => {
|
||||
var _ref4 = _asyncToGenerator(function* (_, newLearnedWords) {
|
||||
const session = electron.session.defaultSession;
|
||||
|
||||
if (!_hasLoadedLearnedWords) {
|
||||
const dictionaryContents = yield session.listWordsInSpellCheckerDictionary();
|
||||
_learnedWords = new Set(dictionaryContents);
|
||||
_hasLoadedLearnedWords = true;
|
||||
}
|
||||
|
||||
_learnedWords.forEach(function (word) {
|
||||
if (!newLearnedWords.has(word)) {
|
||||
session.removeWordFromSpellCheckerDictionary(word);
|
||||
}
|
||||
});
|
||||
|
||||
newLearnedWords.forEach(function (word) {
|
||||
if (!_learnedWords.has(word)) {
|
||||
session.addWordToSpellCheckerDictionary(word);
|
||||
}
|
||||
});
|
||||
|
||||
_learnedWords = new Set(newLearnedWords);
|
||||
});
|
||||
|
||||
return function (_x6, _x7) {
|
||||
return _ref4.apply(this, arguments);
|
||||
};
|
||||
})());
|
186
app/discord_native/browser/window.js
Normal file
|
@ -0,0 +1,186 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.injectGetWindow = injectGetWindow;
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
const process = require('process');
|
||||
|
||||
const {
|
||||
WINDOW_BLUR,
|
||||
WINDOW_CLOSE,
|
||||
WINDOW_FOCUS,
|
||||
WINDOW_MAXIMIZE,
|
||||
WINDOW_MINIMIZE,
|
||||
WINDOW_RESTORE,
|
||||
WINDOW_FLASH_FRAME,
|
||||
WINDOW_TOGGLE_FULLSCREEN,
|
||||
WINDOW_SET_BACKGROUND_THROTTLING,
|
||||
WINDOW_SET_PROGRESS_BAR,
|
||||
WINDOW_IS_ALWAYS_ON_TOP,
|
||||
WINDOW_SET_ALWAYS_ON_TOP
|
||||
} = require('../common/constants').IPCEvents;
|
||||
|
||||
let injectedGetWindow = _key => {
|
||||
return null;
|
||||
};
|
||||
|
||||
function injectGetWindow(getWindow) {
|
||||
injectedGetWindow = getWindow;
|
||||
}
|
||||
|
||||
electron.ipcMain.handle(WINDOW_FLASH_FRAME, (() => {
|
||||
var _ref = _asyncToGenerator(function* (_, flag) {
|
||||
const currentWindow = injectedGetWindow();
|
||||
if (currentWindow == null || currentWindow.flashFrame == null) return;
|
||||
currentWindow.flashFrame(!currentWindow.isFocused() && flag);
|
||||
});
|
||||
|
||||
return function (_x, _x2) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(WINDOW_MINIMIZE, (() => {
|
||||
var _ref2 = _asyncToGenerator(function* (_, key) {
|
||||
const win = injectedGetWindow(key);
|
||||
if (win == null) return;
|
||||
win.minimize();
|
||||
});
|
||||
|
||||
return function (_x3, _x4) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(WINDOW_RESTORE, (() => {
|
||||
var _ref3 = _asyncToGenerator(function* (_, key) {
|
||||
const win = injectedGetWindow(key);
|
||||
if (win == null) return;
|
||||
win.restore();
|
||||
});
|
||||
|
||||
return function (_x5, _x6) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(WINDOW_MAXIMIZE, (() => {
|
||||
var _ref4 = _asyncToGenerator(function* (_, key) {
|
||||
const win = injectedGetWindow(key);
|
||||
if (win == null) return;
|
||||
if (win.isMaximized()) {
|
||||
win.unmaximize();
|
||||
} else {
|
||||
win.maximize();
|
||||
}
|
||||
});
|
||||
|
||||
return function (_x7, _x8) {
|
||||
return _ref4.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(WINDOW_FOCUS, (() => {
|
||||
var _ref5 = _asyncToGenerator(function* (_, key) {
|
||||
const win = injectedGetWindow(key);
|
||||
if (win == null) return;
|
||||
win.show();
|
||||
});
|
||||
|
||||
return function (_x9, _x10) {
|
||||
return _ref5.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(WINDOW_SET_ALWAYS_ON_TOP, (() => {
|
||||
var _ref6 = _asyncToGenerator(function* (_, key, enabled) {
|
||||
const win = injectedGetWindow(key);
|
||||
if (win == null) return;
|
||||
win.setAlwaysOnTop(enabled);
|
||||
});
|
||||
|
||||
return function (_x11, _x12, _x13) {
|
||||
return _ref6.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(WINDOW_IS_ALWAYS_ON_TOP, (() => {
|
||||
var _ref7 = _asyncToGenerator(function* (_, key) {
|
||||
const win = injectedGetWindow(key);
|
||||
if (win == null) return false;
|
||||
return win.isAlwaysOnTop();
|
||||
});
|
||||
|
||||
return function (_x14, _x15) {
|
||||
return _ref7.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(WINDOW_BLUR, (() => {
|
||||
var _ref8 = _asyncToGenerator(function* (_, key) {
|
||||
const win = injectedGetWindow(key);
|
||||
if (win != null && !win.isDestroyed()) {
|
||||
win.blur();
|
||||
}
|
||||
});
|
||||
|
||||
return function (_x16, _x17) {
|
||||
return _ref8.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(WINDOW_SET_PROGRESS_BAR, (() => {
|
||||
var _ref9 = _asyncToGenerator(function* (_, key, progress) {
|
||||
const win = injectedGetWindow(key);
|
||||
if (win == null) return;
|
||||
win.setProgressBar(progress);
|
||||
});
|
||||
|
||||
return function (_x18, _x19, _x20) {
|
||||
return _ref9.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(WINDOW_TOGGLE_FULLSCREEN, (() => {
|
||||
var _ref10 = _asyncToGenerator(function* (_, key) {
|
||||
const currentWindow = injectedGetWindow(key);
|
||||
currentWindow.setFullScreen(!currentWindow.isFullScreen());
|
||||
});
|
||||
|
||||
return function (_x21, _x22) {
|
||||
return _ref10.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(WINDOW_CLOSE, (() => {
|
||||
var _ref11 = _asyncToGenerator(function* (_, key) {
|
||||
if (key == null && process.platform === 'darwin') {
|
||||
electron.Menu.sendActionToFirstResponder('hide:');
|
||||
} else {
|
||||
const win = injectedGetWindow(key);
|
||||
if (win == null) return;
|
||||
win.close();
|
||||
}
|
||||
});
|
||||
|
||||
return function (_x23, _x24) {
|
||||
return _ref11.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcMain.handle(WINDOW_SET_BACKGROUND_THROTTLING, (() => {
|
||||
var _ref12 = _asyncToGenerator(function* (_, enabled) {
|
||||
const win = injectedGetWindow();
|
||||
if (win == null) return;
|
||||
win.webContents.setBackgroundThrottling(enabled);
|
||||
});
|
||||
|
||||
return function (_x25, _x26) {
|
||||
return _ref12.apply(this, arguments);
|
||||
};
|
||||
})());
|
92
app/discord_native/common/constants.js
Normal file
|
@ -0,0 +1,92 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getDiscordIPCEvent = getDiscordIPCEvent;
|
||||
function sanitizeIPCEvents(events) {
|
||||
for (const key of Object.keys(events)) {
|
||||
events[key] = getDiscordIPCEvent(key);
|
||||
}
|
||||
|
||||
return events;
|
||||
}
|
||||
|
||||
function getDiscordIPCEvent(ev) {
|
||||
return `DISCORD_${ev}`;
|
||||
}
|
||||
|
||||
const IPCEvents = exports.IPCEvents = sanitizeIPCEvents({
|
||||
ACCESSIBILITY_GET_ENABLED: null,
|
||||
|
||||
APP_GET_RELEASE_CHANNEL_SYNC: null,
|
||||
APP_GET_HOST_VERSION_SYNC: null,
|
||||
APP_GET_MODULE_VERSIONS: null,
|
||||
APP_GET_PATH: null,
|
||||
APP_SET_BADGE_COUNT: null,
|
||||
APP_DOCK_SET_BADGE: null,
|
||||
APP_DOCK_BOUNCE: null,
|
||||
APP_DOCK_CANCEL_BOUNCE: null,
|
||||
APP_RELAUNCH: null,
|
||||
APP_GET_DEFAULT_DOUBLE_CLICK_ACTION: null,
|
||||
|
||||
CLIPBOARD_COPY: null,
|
||||
CLIPBOARD_CUT: null,
|
||||
CLIPBOARD_PASTE: null,
|
||||
|
||||
CRASH_REPORTER_UPDATE_METADATA: null,
|
||||
|
||||
FEATURES_GET_BROWSER_FEATURES: null,
|
||||
|
||||
FILE_MANAGER_GET_MODULE_PATH: null,
|
||||
FILE_MANAGER_SHOW_SAVE_DIALOG: null,
|
||||
FILE_MANAGER_SHOW_OPEN_DIALOG: null,
|
||||
FILE_MANAGER_SHOW_ITEM_IN_FOLDER: null,
|
||||
|
||||
GPU_SETTINGS_SET_ENABLE_HWACCEL: null,
|
||||
GPU_SETTINGS_GET_ENABLE_HWACCEL_SYNC: null,
|
||||
|
||||
NATIVE_MODULES_GET_PATHS: null,
|
||||
NATIVE_MODULES_INSTALL: null,
|
||||
|
||||
POWER_MONITOR_RESUME: null,
|
||||
POWER_MONITOR_SUSPEND: null,
|
||||
POWER_MONITOR_LOCK_SCREEN: null,
|
||||
POWER_MONITOR_UNLOCK_SCREEN: null,
|
||||
POWER_MONITOR_GET_SYSTEM_IDLE_TIME: null,
|
||||
POWER_SAVE_BLOCKER_BLOCK_DISPLAY_SLEEP: null,
|
||||
POWER_SAVE_BLOCKER_UNBLOCK_DISPLAY_SLEEP: null,
|
||||
POWER_SAVE_BLOCKER_CLEANUP_DISPLAY_SLEEP: null,
|
||||
|
||||
PROCESS_UTILS_GET_CPU_USAGE: null,
|
||||
PROCESS_UTILS_GET_MEMORY_INFO: null,
|
||||
PROCESS_UTILS_FLUSH_DNS_CACHE: null,
|
||||
PROCESS_UTILS_FLUSH_COOKIES: null,
|
||||
PROCESS_UTILS_FLUSH_STORAGE_DATA: null,
|
||||
PROCESS_UTILS_GET_MAIN_ARGV_SYNC: null,
|
||||
|
||||
SETTINGS_GET: null,
|
||||
SETTINGS_SET: null,
|
||||
SETTINGS_GET_SYNC: null,
|
||||
|
||||
SPELLCHECK_RESULT: null,
|
||||
SPELLCHECK_REPLACE_MISSPELLING: null,
|
||||
SPELLCHECK_GET_AVAILABLE_DICTIONARIES: null,
|
||||
SPELLCHECK_SET_LOCALE: null,
|
||||
SPELLCHECK_SET_LEARNED_WORDS: null,
|
||||
|
||||
WINDOW_BLUR: null,
|
||||
WINDOW_CLOSE: null,
|
||||
WINDOW_FOCUS: null,
|
||||
WINDOW_MAXIMIZE: null,
|
||||
WINDOW_MINIMIZE: null,
|
||||
WINDOW_RESTORE: null,
|
||||
WINDOW_FLASH_FRAME: null,
|
||||
WINDOW_TOGGLE_FULLSCREEN: null,
|
||||
WINDOW_SET_BACKGROUND_THROTTLING: null,
|
||||
WINDOW_SET_PROGRESS_BAR: null,
|
||||
WINDOW_IS_ALWAYS_ON_TOP: null,
|
||||
WINDOW_SET_ALWAYS_ON_TOP: null,
|
||||
WINDOW_DEVTOOLS_OPENED: null,
|
||||
WINDOW_DEVTOOLS_CLOSED: null
|
||||
});
|
50
app/discord_native/common/utility.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
'use strict';
|
||||
|
||||
const process = require('process');
|
||||
|
||||
function getElectronMajorVersion() {
|
||||
return process.versions.electron != null ? parseInt(process.versions.electron.split('.')[0]) : 0;
|
||||
}
|
||||
|
||||
function flatten(metadata, prefix, root) {
|
||||
root = root ? root : {};
|
||||
prefix = prefix ? prefix : '';
|
||||
|
||||
if (typeof metadata === 'object') {
|
||||
for (const key in metadata) {
|
||||
const next_prefix = prefix === '' ? key : `${prefix}[${key}]`;
|
||||
flatten(metadata[key], next_prefix, root);
|
||||
}
|
||||
} else {
|
||||
root[prefix] = metadata;
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
function reconcileCrashReporterMetadata(crashReporter, metadata) {
|
||||
if (getElectronMajorVersion() < 9) {
|
||||
return;
|
||||
}
|
||||
|
||||
const new_metadata = flatten(metadata);
|
||||
const old_metadata = crashReporter.getParameters();
|
||||
|
||||
for (const key in old_metadata) {
|
||||
if (!new_metadata.hasOwnProperty(key)) {
|
||||
crashReporter.removeExtraParameter(key);
|
||||
}
|
||||
}
|
||||
|
||||
for (const key in new_metadata) {
|
||||
if (!old_metadata.hasOwnProperty(key)) {
|
||||
crashReporter.addExtraParameter(key, new_metadata[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getElectronMajorVersion,
|
||||
flatten,
|
||||
reconcileCrashReporterMetadata
|
||||
};
|
21
app/discord_native/renderer/accessibility.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
'use strict';
|
||||
|
||||
let isAccessibilitySupportEnabled = (() => {
|
||||
var _ref = _asyncToGenerator(function* () {
|
||||
return electron.ipcRenderer.invoke(ACCESSIBILITY_GET_ENABLED);
|
||||
});
|
||||
|
||||
return function isAccessibilitySupportEnabled() {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
|
||||
const { ACCESSIBILITY_GET_ENABLED } = require('../common/constants').IPCEvents;
|
||||
|
||||
module.exports = {
|
||||
isAccessibilitySupportEnabled
|
||||
};
|
139
app/discord_native/renderer/app.js
Normal file
|
@ -0,0 +1,139 @@
|
|||
'use strict';
|
||||
|
||||
let getPath = (() => {
|
||||
var _ref2 = _asyncToGenerator(function* (path) {
|
||||
if (!allowedAppPaths.has(path)) {
|
||||
throw new Error(`${path} is not an allowed app path`);
|
||||
}
|
||||
|
||||
return electron.ipcRenderer.invoke(APP_GET_PATH, path);
|
||||
});
|
||||
|
||||
return function getPath(_x2) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let setBadgeCount = (() => {
|
||||
var _ref3 = _asyncToGenerator(function* (count) {
|
||||
electron.ipcRenderer.invoke(APP_SET_BADGE_COUNT, count);
|
||||
});
|
||||
|
||||
return function setBadgeCount(_x3) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let dockSetBadge = (() => {
|
||||
var _ref4 = _asyncToGenerator(function* (badge) {
|
||||
electron.ipcRenderer.invoke(APP_DOCK_SET_BADGE, badge);
|
||||
});
|
||||
|
||||
return function dockSetBadge(_x4) {
|
||||
return _ref4.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let dockBounce = (() => {
|
||||
var _ref5 = _asyncToGenerator(function* (type) {
|
||||
return electron.ipcRenderer.invoke(APP_DOCK_BOUNCE, type);
|
||||
});
|
||||
|
||||
return function dockBounce(_x5) {
|
||||
return _ref5.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let dockCancelBounce = (() => {
|
||||
var _ref6 = _asyncToGenerator(function* (id) {
|
||||
electron.ipcRenderer.invoke(APP_DOCK_CANCEL_BOUNCE, id);
|
||||
});
|
||||
|
||||
return function dockCancelBounce(_x6) {
|
||||
return _ref6.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let relaunch = (() => {
|
||||
var _ref7 = _asyncToGenerator(function* () {
|
||||
electron.ipcRenderer.invoke(APP_RELAUNCH);
|
||||
});
|
||||
|
||||
return function relaunch() {
|
||||
return _ref7.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let getDefaultDoubleClickAction = (() => {
|
||||
var _ref8 = _asyncToGenerator(function* () {
|
||||
return electron.ipcRenderer.invoke(APP_GET_DEFAULT_DOUBLE_CLICK_ACTION);
|
||||
});
|
||||
|
||||
return function getDefaultDoubleClickAction() {
|
||||
return _ref8.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
const { UpdaterEvents } = require('../../Constants');
|
||||
|
||||
const allowedAppPaths = new Set(['home', 'appData', 'desktop', 'documents', 'downloads']);
|
||||
const {
|
||||
APP_GET_RELEASE_CHANNEL_SYNC,
|
||||
APP_GET_HOST_VERSION_SYNC,
|
||||
APP_GET_MODULE_VERSIONS,
|
||||
APP_GET_PATH,
|
||||
APP_SET_BADGE_COUNT,
|
||||
APP_DOCK_SET_BADGE,
|
||||
APP_DOCK_BOUNCE,
|
||||
APP_DOCK_CANCEL_BOUNCE,
|
||||
APP_RELAUNCH,
|
||||
APP_GET_DEFAULT_DOUBLE_CLICK_ACTION
|
||||
} = require('../common/constants').IPCEvents;
|
||||
|
||||
let releaseChannel = electron.ipcRenderer.sendSync(APP_GET_RELEASE_CHANNEL_SYNC);
|
||||
let hostVersion = electron.ipcRenderer.sendSync(APP_GET_HOST_VERSION_SYNC);
|
||||
let moduleVersions = {};
|
||||
|
||||
electron.ipcRenderer.invoke(APP_GET_MODULE_VERSIONS).then(versions => {
|
||||
moduleVersions = versions;
|
||||
});
|
||||
|
||||
electron.ipcRenderer.on('DISCORD_MODULE_INSTALLED', (() => {
|
||||
var _ref = _asyncToGenerator(function* (_) {
|
||||
moduleVersions = yield electron.ipcRenderer.invoke(APP_GET_MODULE_VERSIONS);
|
||||
});
|
||||
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
function getReleaseChannel() {
|
||||
return releaseChannel;
|
||||
}
|
||||
|
||||
function getVersion() {
|
||||
return hostVersion;
|
||||
}
|
||||
|
||||
function getModuleVersions() {
|
||||
return moduleVersions;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getReleaseChannel,
|
||||
getVersion,
|
||||
getModuleVersions,
|
||||
getPath,
|
||||
setBadgeCount,
|
||||
dock: {
|
||||
setBadge: dockSetBadge,
|
||||
bounce: dockBounce,
|
||||
cancelBounce: dockCancelBounce
|
||||
},
|
||||
relaunch,
|
||||
getDefaultDoubleClickAction
|
||||
};
|
41
app/discord_native/renderer/clipboard.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
'use strict';
|
||||
|
||||
const electron = require('electron');
|
||||
const invariant = require('invariant');
|
||||
|
||||
const { CLIPBOARD_COPY, CLIPBOARD_CUT, CLIPBOARD_PASTE } = require('../common/constants').IPCEvents;
|
||||
|
||||
function copy(text) {
|
||||
if (text) {
|
||||
electron.clipboard.writeText(text);
|
||||
} else {
|
||||
electron.ipcRenderer.invoke(CLIPBOARD_COPY);
|
||||
}
|
||||
}
|
||||
|
||||
function copyImage(imageArrayBuffer, imageSrc) {
|
||||
invariant(imageArrayBuffer != null, 'Image data is empty');
|
||||
|
||||
const nativeImg = electron.nativeImage.createFromBuffer(imageArrayBuffer);
|
||||
electron.clipboard.write({ html: `<img src="${imageSrc}">`, image: nativeImg });
|
||||
}
|
||||
|
||||
function cut() {
|
||||
electron.ipcRenderer.invoke(CLIPBOARD_CUT);
|
||||
}
|
||||
|
||||
function paste() {
|
||||
electron.ipcRenderer.invoke(CLIPBOARD_PASTE);
|
||||
}
|
||||
|
||||
function read() {
|
||||
return electron.clipboard.readText();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
copy,
|
||||
copyImage,
|
||||
cut,
|
||||
paste,
|
||||
read
|
||||
};
|
38
app/discord_native/renderer/crashReporter.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
'use strict';
|
||||
|
||||
let updateCrashReporter = (() => {
|
||||
var _ref = _asyncToGenerator(function* (additional_metadata) {
|
||||
const result = yield electron.ipcRenderer.invoke(CRASH_REPORTER_UPDATE_METADATA, additional_metadata);
|
||||
// Calling crashReporter.start from a renderer process was deprecated in Electron 9.
|
||||
if (getElectronMajorVersion() < 9) {
|
||||
electron.crashReporter.start(result.args);
|
||||
}
|
||||
metadata = result.metadata || {};
|
||||
|
||||
reconcileCrashReporterMetadata(electron.crashReporter, metadata);
|
||||
});
|
||||
|
||||
return function updateCrashReporter(_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
const { getElectronMajorVersion, reconcileCrashReporterMetadata } = require('../common/utility');
|
||||
|
||||
const { CRASH_REPORTER_UPDATE_METADATA } = require('../common/constants').IPCEvents;
|
||||
|
||||
let metadata = {};
|
||||
|
||||
updateCrashReporter(metadata);
|
||||
|
||||
function getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
updateCrashReporter,
|
||||
getMetadata
|
||||
};
|
21
app/discord_native/renderer/desktopCapture.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
'use strict';
|
||||
|
||||
const electron = require('electron');
|
||||
|
||||
function getDesktopCaptureSources(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
electron.desktopCapturer.getSources(options).then(sources => {
|
||||
return resolve(sources.map(source => {
|
||||
return {
|
||||
id: source.id,
|
||||
name: source.name,
|
||||
url: source.thumbnail.toDataURL()
|
||||
};
|
||||
}));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getDesktopCaptureSources
|
||||
};
|
20
app/discord_native/renderer/features.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
'use strict';
|
||||
|
||||
const electron = require('electron');
|
||||
|
||||
const { FEATURES_GET_BROWSER_FEATURES } = require('../common/constants').IPCEvents;
|
||||
|
||||
let supportedFeatures = new Set(electron.ipcRenderer.sendSync(FEATURES_GET_BROWSER_FEATURES));
|
||||
|
||||
function supports(feature) {
|
||||
return supportedFeatures.has(feature);
|
||||
}
|
||||
|
||||
function declareSupported(feature) {
|
||||
supportedFeatures.add(feature);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
supports,
|
||||
declareSupported
|
||||
};
|
201
app/discord_native/renderer/fileManager.js
Normal file
|
@ -0,0 +1,201 @@
|
|||
'use strict';
|
||||
|
||||
let saveWithDialog = (() => {
|
||||
var _ref = _asyncToGenerator(function* (fileContents, fileName, filePath) {
|
||||
if (INVALID_FILENAME_CHAR_REGEX.test(fileName)) {
|
||||
throw new Error(`fileName has invalid characters`);
|
||||
}
|
||||
const defaultPath = filePath != null ? path.join(os.homedir(), filePath, fileName) : path.join(os.homedir(), fileName);
|
||||
|
||||
const writeFileToDisk = function (selectedFileName) {
|
||||
selectedFileName && fs.writeFileSync(selectedFileName, fileContents);
|
||||
};
|
||||
|
||||
const results = yield electron.ipcRenderer.invoke(FILE_MANAGER_SHOW_SAVE_DIALOG, { defaultPath });
|
||||
if (results && results.filePath) {
|
||||
fs.writeFileSync(results.filePath, fileContents);
|
||||
}
|
||||
});
|
||||
|
||||
return function saveWithDialog(_x, _x2, _x3) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let showOpenDialog = (() => {
|
||||
var _ref2 = _asyncToGenerator(function* (dialogOptions) {
|
||||
const results = yield electron.ipcRenderer.invoke(FILE_MANAGER_SHOW_OPEN_DIALOG, dialogOptions);
|
||||
return results.filePaths;
|
||||
});
|
||||
|
||||
return function showOpenDialog(_x4) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let orderedFiles = (() => {
|
||||
var _ref3 = _asyncToGenerator(function* (folder) {
|
||||
try {
|
||||
const filenames = yield readdir(folder);
|
||||
const times = yield getTimes(filenames.map(function (filename) {
|
||||
return path.join(folder, filename);
|
||||
}));
|
||||
return times.filter(function (result) {
|
||||
return result.status === 'fulfilled';
|
||||
}).map(function (result) {
|
||||
return result.value;
|
||||
}).sort(function (a, b) {
|
||||
return b.mtime.getTime() - a.mtime.getTime();
|
||||
}).map(function (a) {
|
||||
return a.filename;
|
||||
});
|
||||
} catch (err) {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
return function orderedFiles(_x5) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let readLogFiles = (() => {
|
||||
var _ref4 = _asyncToGenerator(function* (maxSize, makeFile) {
|
||||
const modulePath = yield getModulePath();
|
||||
const webrtcLog0 = path.join(modulePath, 'discord_voice', 'discord-webrtc_0');
|
||||
const webrtcLog1 = path.join(modulePath, 'discord_voice', 'discord-webrtc_1');
|
||||
const webrtcLog2 = path.join(modulePath, 'discord_voice', 'discord-last-webrtc_0');
|
||||
const webrtcLog3 = path.join(modulePath, 'discord_voice', 'discord-last-webrtc_1');
|
||||
const hookLog = path.join(modulePath, 'discord_hook', 'hook.log');
|
||||
const audioState = path.join(modulePath, 'discord_voice', 'audio_state.json');
|
||||
const filesToUpload = [webrtcLog0, webrtcLog1, webrtcLog2, webrtcLog3, hookLog, audioState];
|
||||
|
||||
const crashFolder = process.platform === 'win32' ? path.join(os.tmpdir(), 'Discord Crashes', 'reports') : path.join(os.tmpdir(), 'Discord Crashes', 'completed');
|
||||
const crashFiles = yield orderedFiles(crashFolder);
|
||||
if (crashFiles.length > 0) {
|
||||
filesToUpload.push(crashFiles[0]);
|
||||
}
|
||||
|
||||
const files = yield readFiles(filesToUpload, maxSize, function (data, filename) {
|
||||
return makeFile(data, filename, 'application/octet-stream');
|
||||
});
|
||||
return files.filter(function (result) {
|
||||
return result.status === 'fulfilled';
|
||||
}).map(function (result) {
|
||||
return result.value;
|
||||
});
|
||||
});
|
||||
|
||||
return function readLogFiles(_x6, _x7) {
|
||||
return _ref4.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let showItemInFolder = (() => {
|
||||
var _ref5 = _asyncToGenerator(function* (path) {
|
||||
electron.ipcRenderer.invoke(FILE_MANAGER_SHOW_ITEM_IN_FOLDER, path);
|
||||
});
|
||||
|
||||
return function showItemInFolder(_x8) {
|
||||
return _ref5.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let openFiles = (() => {
|
||||
var _ref6 = _asyncToGenerator(function* (dialogOptions, maxSize, makeFile) {
|
||||
const filenames = yield showOpenDialog(dialogOptions);
|
||||
if (filenames == null) {
|
||||
return;
|
||||
}
|
||||
const files = yield readFiles(filenames, maxSize, makeFile);
|
||||
files.forEach(function (result) {
|
||||
if (result.status === 'rejected') {
|
||||
throw result.reason;
|
||||
}
|
||||
});
|
||||
return files.map(function (result) {
|
||||
return result.value;
|
||||
});
|
||||
});
|
||||
|
||||
return function openFiles(_x9, _x10, _x11) {
|
||||
return _ref6.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let getModulePath = (() => {
|
||||
var _ref7 = _asyncToGenerator(function* () {
|
||||
return electron.ipcRenderer.invoke(FILE_MANAGER_GET_MODULE_PATH);
|
||||
});
|
||||
|
||||
return function getModulePath() {
|
||||
return _ref7.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const originalFs = require('original-fs');
|
||||
const util = require('util');
|
||||
|
||||
const {
|
||||
FILE_MANAGER_GET_MODULE_PATH,
|
||||
FILE_MANAGER_SHOW_SAVE_DIALOG,
|
||||
FILE_MANAGER_SHOW_OPEN_DIALOG,
|
||||
FILE_MANAGER_SHOW_ITEM_IN_FOLDER
|
||||
} = require('../common/constants').IPCEvents;
|
||||
|
||||
const INVALID_FILENAME_CHAR_REGEX = /[^a-zA-Z0-9-_.]/g;
|
||||
|
||||
const readdir = util.promisify(originalFs.readdir);
|
||||
|
||||
function getTimes(filenames) {
|
||||
return Promise.allSettled(filenames.map(filename => new Promise((resolve, reject) => {
|
||||
originalFs.stat(filename, (err, stats) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
if (!stats.isFile()) {
|
||||
return reject(new Error('Not a file'));
|
||||
}
|
||||
return resolve({ filename, mtime: stats.mtime });
|
||||
});
|
||||
})));
|
||||
}
|
||||
|
||||
function readFiles(filenames, maxSize, makeFile) {
|
||||
return Promise.allSettled(filenames.map(filename => new Promise((resolve, reject) => {
|
||||
originalFs.stat(filename, (err, stats) => {
|
||||
if (err) return reject(err);
|
||||
|
||||
if (stats.size > maxSize) {
|
||||
const err = new Error('upload too large');
|
||||
// used to help determine why openFiles failed
|
||||
err.code = 'ETOOLARGE';
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
originalFs.readFile(filename, (err, data) => {
|
||||
if (err) return reject(err);
|
||||
return resolve(makeFile(data.buffer, path.basename(filename)));
|
||||
});
|
||||
});
|
||||
})));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
readLogFiles,
|
||||
saveWithDialog,
|
||||
openFiles,
|
||||
showOpenDialog,
|
||||
showItemInFolder,
|
||||
getModulePath,
|
||||
extname: path.extname,
|
||||
basename: path.basename,
|
||||
dirname: path.dirname,
|
||||
join: path.join
|
||||
};
|
28
app/discord_native/renderer/gpuSettings.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
'use strict';
|
||||
|
||||
let setEnableHardwareAcceleration = (() => {
|
||||
var _ref = _asyncToGenerator(function* (enable) {
|
||||
electron.ipcRenderer.invoke(GPU_SETTINGS_SET_ENABLE_HWACCEL, enable);
|
||||
});
|
||||
|
||||
return function setEnableHardwareAcceleration(_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
|
||||
const { GPU_SETTINGS_SET_ENABLE_HWACCEL, GPU_SETTINGS_GET_ENABLE_HWACCEL_SYNC } = require('../common/constants').IPCEvents;
|
||||
|
||||
const hardwareAccelerationEnabled = electron.ipcRenderer.sendSync(GPU_SETTINGS_GET_ENABLE_HWACCEL_SYNC);
|
||||
|
||||
function getEnableHardwareAcceleration() {
|
||||
return hardwareAccelerationEnabled;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getEnableHardwareAcceleration,
|
||||
setEnableHardwareAcceleration
|
||||
};
|
79
app/discord_native/renderer/http.js
Normal file
|
@ -0,0 +1,79 @@
|
|||
'use strict';
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
|
||||
function makeChunkedRequest(route, chunks, options, callback) {
|
||||
/**
|
||||
* Given an array of chunks, make a slow request, only writing chunks
|
||||
* after a specified amount of time
|
||||
*
|
||||
* route: string
|
||||
* options: object
|
||||
* method: the method of the request
|
||||
* contentType: the content type of the request
|
||||
* chunkInterval: how long to wait to upload a chunk after the last chunk was flushed
|
||||
* token: the token to make an authorized request from
|
||||
* chunks: chunked body of the request to upload
|
||||
*/
|
||||
|
||||
const { method, chunkInterval, token, contentType } = options;
|
||||
|
||||
let httpModule = http;
|
||||
if (route.startsWith('https')) {
|
||||
httpModule = https;
|
||||
}
|
||||
|
||||
const requestPromise = new Promise((() => {
|
||||
var _ref = _asyncToGenerator(function* (resolve, reject) {
|
||||
let writeTimeout;
|
||||
const req = httpModule.request(route, {
|
||||
method,
|
||||
headers: {
|
||||
authorization: token,
|
||||
'Content-Type': contentType,
|
||||
'Content-Length': Buffer.byteLength(chunks.join(''))
|
||||
}
|
||||
}, function (res) {
|
||||
let responseData = '';
|
||||
res.setEncoding('utf8');
|
||||
res.on('data', function (chunk) {
|
||||
responseData += chunk;
|
||||
});
|
||||
|
||||
res.on('end', function () {
|
||||
resolve({ status: res.statusCode, body: responseData });
|
||||
});
|
||||
});
|
||||
|
||||
req.on('error', function (e) {
|
||||
if (writeTimeout != null) {
|
||||
clearTimeout(writeTimeout);
|
||||
}
|
||||
reject(e);
|
||||
});
|
||||
|
||||
for (let i = 0; i < chunks.length; i++) {
|
||||
yield new Promise(function (resolve) {
|
||||
req.write(chunks[i], function () {
|
||||
writeTimeout = setTimeout(resolve, chunkInterval);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
req.end();
|
||||
});
|
||||
|
||||
return function (_x, _x2) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
requestPromise.then(body => callback(null, body)).catch(callback);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
makeChunkedRequest
|
||||
};
|
19
app/discord_native/renderer/ipc.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
'use strict';
|
||||
|
||||
const electron = require('electron');
|
||||
const { getDiscordIPCEvent } = require('../common/constants');
|
||||
|
||||
const ipcRenderer = electron.ipcRenderer;
|
||||
|
||||
function send(ev, ...args) {
|
||||
ipcRenderer.send(getDiscordIPCEvent(ev), ...args);
|
||||
}
|
||||
|
||||
function on(ev, callback) {
|
||||
ipcRenderer.on(getDiscordIPCEvent(ev), callback);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
send,
|
||||
on
|
||||
};
|
67
app/discord_native/renderer/nativeModules.js
Normal file
|
@ -0,0 +1,67 @@
|
|||
'use strict';
|
||||
|
||||
let ensureModule = (() => {
|
||||
var _ref = _asyncToGenerator(function* (name) {
|
||||
let modulePromise = modulePromises[name];
|
||||
if (modulePromise == null) {
|
||||
modulePromise = electron.ipcRenderer.invoke(NATIVE_MODULES_INSTALL, name);
|
||||
}
|
||||
return modulePromise;
|
||||
});
|
||||
|
||||
return function ensureModule(_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
// TODO: remove this sandboxing when we turn contextIsolation on
|
||||
// sandbox this function in a new context, else it's susceptible to prototype attacks
|
||||
// - RegExp.prototype.test = () => true
|
||||
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
const vm = require('vm');
|
||||
|
||||
const { NATIVE_MODULES_GET_PATHS, NATIVE_MODULES_INSTALL } = require('../common/constants').IPCEvents;
|
||||
|
||||
const modulePromises = {};
|
||||
|
||||
function getSanitizedModulePaths() {
|
||||
let sanitizedModulePaths = [];
|
||||
|
||||
const { mainAppDirname, browserModulePaths } = electron.ipcRenderer.sendSync(NATIVE_MODULES_GET_PATHS);
|
||||
|
||||
browserModulePaths.forEach(modulePath => {
|
||||
if (!modulePath.includes('electron.asar')) {
|
||||
sanitizedModulePaths.push(modulePath);
|
||||
}
|
||||
});
|
||||
|
||||
const rendererModulePaths = require('module')._nodeModulePaths(mainAppDirname);
|
||||
sanitizedModulePaths = sanitizedModulePaths.concat(rendererModulePaths.slice(0, 2));
|
||||
|
||||
return sanitizedModulePaths;
|
||||
}
|
||||
|
||||
const context = vm.createContext(Object.create(null));
|
||||
const _requireModule = vm.runInContext(`
|
||||
function requireModule(localRequire, name) {
|
||||
if (!/^discord_[a-z0-9_-]+$/.test(name) && name !== 'erlpack') {
|
||||
throw new Error('"' + String(name) + '" is not a whitelisted native module');
|
||||
}
|
||||
return localRequire(name);
|
||||
}
|
||||
requireModule
|
||||
`, context);
|
||||
|
||||
function requireModule(name) {
|
||||
return _requireModule(require, name);
|
||||
}
|
||||
|
||||
module.paths = getSanitizedModulePaths();
|
||||
module.exports = {
|
||||
ensureModule,
|
||||
requireModule
|
||||
};
|
14
app/discord_native/renderer/os.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
const os = require('os');
|
||||
const process = require('process');
|
||||
|
||||
let arch = os.arch();
|
||||
if (process.platform === 'win32' && process.env['PROCESSOR_ARCHITEW6432'] != null) {
|
||||
arch = 'x64';
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
release: os.release(),
|
||||
arch
|
||||
};
|
61
app/discord_native/renderer/powerMonitor.js
Normal file
|
@ -0,0 +1,61 @@
|
|||
'use strict';
|
||||
|
||||
let getSystemIdleTimeMs = (() => {
|
||||
var _ref = _asyncToGenerator(function* () {
|
||||
return electron.ipcRenderer.invoke(POWER_MONITOR_GET_SYSTEM_IDLE_TIME);
|
||||
});
|
||||
|
||||
return function getSystemIdleTimeMs() {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
const EventEmitter = require('events');
|
||||
|
||||
const {
|
||||
POWER_MONITOR_RESUME,
|
||||
POWER_MONITOR_SUSPEND,
|
||||
POWER_MONITOR_LOCK_SCREEN,
|
||||
POWER_MONITOR_UNLOCK_SCREEN,
|
||||
POWER_MONITOR_GET_SYSTEM_IDLE_TIME
|
||||
} = require('../common/constants').IPCEvents;
|
||||
|
||||
const events = new EventEmitter();
|
||||
|
||||
electron.ipcRenderer.on(POWER_MONITOR_RESUME, () => {
|
||||
events.emit('resume');
|
||||
});
|
||||
|
||||
electron.ipcRenderer.on(POWER_MONITOR_SUSPEND, () => {
|
||||
events.emit('suspend');
|
||||
});
|
||||
|
||||
electron.ipcRenderer.on(POWER_MONITOR_LOCK_SCREEN, () => {
|
||||
events.emit('lock-screen');
|
||||
});
|
||||
|
||||
electron.ipcRenderer.on(POWER_MONITOR_UNLOCK_SCREEN, () => {
|
||||
events.emit('unlock-screen');
|
||||
});
|
||||
|
||||
function on() {
|
||||
events.on.apply(events, arguments);
|
||||
}
|
||||
|
||||
function removeListener() {
|
||||
events.removeListener.apply(events, arguments);
|
||||
}
|
||||
|
||||
function removeAllListeners() {
|
||||
events.removeAllListeners.apply(events, arguments);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
on,
|
||||
removeListener,
|
||||
removeAllListeners,
|
||||
getSystemIdleTimeMs
|
||||
};
|
47
app/discord_native/renderer/powerSaveBlocker.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
'use strict';
|
||||
|
||||
let blockDisplaySleep = (() => {
|
||||
var _ref = _asyncToGenerator(function* () {
|
||||
return electron.ipcRenderer.invoke(POWER_SAVE_BLOCKER_BLOCK_DISPLAY_SLEEP);
|
||||
});
|
||||
|
||||
return function blockDisplaySleep() {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let unblockDisplaySleep = (() => {
|
||||
var _ref2 = _asyncToGenerator(function* (id) {
|
||||
return electron.ipcRenderer.invoke(POWER_SAVE_BLOCKER_UNBLOCK_DISPLAY_SLEEP, id);
|
||||
});
|
||||
|
||||
return function unblockDisplaySleep(_x) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let cleanupDisplaySleep = (() => {
|
||||
var _ref3 = _asyncToGenerator(function* () {
|
||||
return electron.ipcRenderer.invoke(POWER_SAVE_BLOCKER_CLEANUP_DISPLAY_SLEEP);
|
||||
});
|
||||
|
||||
return function cleanupDisplaySleep() {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
|
||||
const {
|
||||
POWER_SAVE_BLOCKER_BLOCK_DISPLAY_SLEEP,
|
||||
POWER_SAVE_BLOCKER_UNBLOCK_DISPLAY_SLEEP,
|
||||
POWER_SAVE_BLOCKER_CLEANUP_DISPLAY_SLEEP
|
||||
} = require('../common/constants').IPCEvents;
|
||||
|
||||
module.exports = {
|
||||
blockDisplaySleep,
|
||||
unblockDisplaySleep,
|
||||
cleanupDisplaySleep
|
||||
};
|
17
app/discord_native/renderer/process.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
'use strict';
|
||||
|
||||
const electron = require('electron');
|
||||
const process = require('process');
|
||||
const env = process.env;
|
||||
|
||||
module.exports = {
|
||||
platform: process.platform,
|
||||
arch: process.arch,
|
||||
env: {
|
||||
LOCALAPPDATA: env['LOCALAPPDATA'],
|
||||
'PROGRAMFILES(X86)': env['PROGRAMFILES(X86)'],
|
||||
PROGRAMFILES: env['PROGRAMFILES'],
|
||||
PROGRAMW6432: env['PROGRAMW6432'],
|
||||
PROGRAMDATA: env['PROGRAMDATA']
|
||||
}
|
||||
};
|
103
app/discord_native/renderer/processUtils.js
Normal file
|
@ -0,0 +1,103 @@
|
|||
'use strict';
|
||||
|
||||
let flushDNSCache = (() => {
|
||||
var _ref = _asyncToGenerator(function* () {
|
||||
electron.ipcRenderer.invoke(PROCESS_UTILS_FLUSH_DNS_CACHE);
|
||||
});
|
||||
|
||||
return function flushDNSCache() {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let flushCookies = (() => {
|
||||
var _ref2 = _asyncToGenerator(function* (callback) {
|
||||
try {
|
||||
yield electron.ipcRenderer.invoke(PROCESS_UTILS_FLUSH_COOKIES);
|
||||
callback();
|
||||
} catch (err) {
|
||||
callback(err);
|
||||
}
|
||||
});
|
||||
|
||||
return function flushCookies(_x) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let flushStorageData = (() => {
|
||||
var _ref3 = _asyncToGenerator(function* (callback) {
|
||||
try {
|
||||
yield electron.ipcRenderer.invoke(PROCESS_UTILS_FLUSH_STORAGE_DATA);
|
||||
callback();
|
||||
} catch (err) {
|
||||
callback(err);
|
||||
}
|
||||
});
|
||||
|
||||
return function flushStorageData(_x2) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let purgeMemory = (() => {
|
||||
var _ref4 = _asyncToGenerator(function* () {
|
||||
electron.webFrame.clearCache();
|
||||
});
|
||||
|
||||
return function purgeMemory() {
|
||||
return _ref4.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
const process = require('process');
|
||||
|
||||
const {
|
||||
PROCESS_UTILS_GET_CPU_USAGE,
|
||||
PROCESS_UTILS_GET_MEMORY_INFO,
|
||||
PROCESS_UTILS_FLUSH_DNS_CACHE,
|
||||
PROCESS_UTILS_FLUSH_COOKIES,
|
||||
PROCESS_UTILS_FLUSH_STORAGE_DATA,
|
||||
PROCESS_UTILS_GET_MAIN_ARGV_SYNC
|
||||
} = require('../common/constants').IPCEvents;
|
||||
const CPU_USAGE_GATHER_INTERVAL = 1000;
|
||||
const MEMORY_USAGE_GATHER_INTERVAL = 5000;
|
||||
|
||||
const mainArgv = electron.ipcRenderer.sendSync(PROCESS_UTILS_GET_MAIN_ARGV_SYNC);
|
||||
let totalProcessorUsagePercent = 0;
|
||||
let totalMemoryUsageKB = 0;
|
||||
|
||||
setInterval(() => {
|
||||
electron.ipcRenderer.invoke(PROCESS_UTILS_GET_CPU_USAGE).then(usage => totalProcessorUsagePercent = usage);
|
||||
}, CPU_USAGE_GATHER_INTERVAL);
|
||||
|
||||
setInterval(() => {
|
||||
Promise.all([process.getProcessMemoryInfo(), electron.ipcRenderer.invoke(PROCESS_UTILS_GET_MEMORY_INFO)].map(x => x.catch(() => 0))).then(usages => {
|
||||
totalMemoryUsageKB = usages.reduce((total, usage) => total + usage.private, 0);
|
||||
});
|
||||
}, MEMORY_USAGE_GATHER_INTERVAL);
|
||||
|
||||
function getCurrentCPUUsagePercent() {
|
||||
return totalProcessorUsagePercent;
|
||||
}
|
||||
|
||||
function getCurrentMemoryUsageKB() {
|
||||
return totalMemoryUsageKB;
|
||||
}
|
||||
|
||||
function getMainArgvSync() {
|
||||
return mainArgv;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
flushDNSCache,
|
||||
flushCookies,
|
||||
flushStorageData,
|
||||
purgeMemory,
|
||||
getCurrentCPUUsagePercent,
|
||||
getCurrentMemoryUsageKB,
|
||||
getMainArgvSync
|
||||
};
|
37
app/discord_native/renderer/settings.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
'use strict';
|
||||
|
||||
let get = (() => {
|
||||
var _ref = _asyncToGenerator(function* (name, defaultValue) {
|
||||
return electron.ipcRenderer.invoke(SETTINGS_GET, name, defaultValue);
|
||||
});
|
||||
|
||||
return function get(_x, _x2) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let set = (() => {
|
||||
var _ref2 = _asyncToGenerator(function* (name, value) {
|
||||
return electron.ipcRenderer.invoke(SETTINGS_SET, name, value);
|
||||
});
|
||||
|
||||
return function set(_x3, _x4) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
|
||||
const { SETTINGS_GET, SETTINGS_SET, SETTINGS_GET_SYNC } = require('../common/constants').IPCEvents;
|
||||
|
||||
function getSync(name, defaultValue) {
|
||||
return electron.ipcRenderer.sendSync(SETTINGS_GET_SYNC, name, defaultValue);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
get,
|
||||
set,
|
||||
getSync
|
||||
};
|
121
app/discord_native/renderer/spellCheck.js
Normal file
|
@ -0,0 +1,121 @@
|
|||
'use strict';
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
const EventEmitter = require('events');
|
||||
const { getElectronMajorVersion } = require('../common/utility');
|
||||
|
||||
const {
|
||||
SPELLCHECK_RESULT,
|
||||
SPELLCHECK_REPLACE_MISSPELLING,
|
||||
SPELLCHECK_GET_AVAILABLE_DICTIONARIES,
|
||||
SPELLCHECK_SET_LOCALE,
|
||||
SPELLCHECK_SET_LEARNED_WORDS
|
||||
} = require('../common/constants').IPCEvents;
|
||||
|
||||
if (getElectronMajorVersion() < 8) {
|
||||
let setSpellCheckProvider = (() => {
|
||||
var _ref = _asyncToGenerator(function* (locale, autoCorrectWord, provider) {
|
||||
const asyncProvider = {
|
||||
spellCheck: function (words, callback) {
|
||||
return callback(words.filter(function (word) {
|
||||
return !provider.spellCheck(word);
|
||||
}));
|
||||
}
|
||||
};
|
||||
electron.webFrame.setSpellCheckProvider(locale, asyncProvider);
|
||||
});
|
||||
|
||||
return function setSpellCheckProvider(_x, _x2, _x3) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let replaceMisspelling = (() => {
|
||||
var _ref2 = _asyncToGenerator(function* (word) {
|
||||
electron.ipcRenderer.invoke(SPELLCHECK_REPLACE_MISSPELLING, word);
|
||||
});
|
||||
|
||||
return function replaceMisspelling(_x4) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
module.exports = {
|
||||
setSpellCheckProvider,
|
||||
replaceMisspelling
|
||||
};
|
||||
} else {
|
||||
let getAvailableDictionaries = (() => {
|
||||
var _ref3 = _asyncToGenerator(function* () {
|
||||
return electron.ipcRenderer.invoke(SPELLCHECK_GET_AVAILABLE_DICTIONARIES);
|
||||
});
|
||||
|
||||
return function getAvailableDictionaries() {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let setLocale = (() => {
|
||||
var _ref4 = _asyncToGenerator(function* (locale) {
|
||||
let succeeded = true;
|
||||
try {
|
||||
yield electron.ipcRenderer.invoke(SPELLCHECK_SET_LOCALE, locale);
|
||||
} catch (_) {
|
||||
succeeded = false;
|
||||
}
|
||||
|
||||
return succeeded;
|
||||
});
|
||||
|
||||
return function setLocale(_x5) {
|
||||
return _ref4.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let setLearnedWords = (() => {
|
||||
var _ref5 = _asyncToGenerator(function* (learnedWords) {
|
||||
return electron.ipcRenderer.invoke(SPELLCHECK_SET_LEARNED_WORDS, learnedWords);
|
||||
});
|
||||
|
||||
return function setLearnedWords(_x6) {
|
||||
return _ref5.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let replaceMisspelling = (() => {
|
||||
var _ref6 = _asyncToGenerator(function* (correction) {
|
||||
return electron.ipcRenderer.invoke(SPELLCHECK_REPLACE_MISSPELLING, correction);
|
||||
});
|
||||
|
||||
return function replaceMisspelling(_x7) {
|
||||
return _ref6.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
const events = new EventEmitter();
|
||||
|
||||
electron.ipcRenderer.on(SPELLCHECK_RESULT, handleSpellcheckData);
|
||||
|
||||
function handleSpellcheckData(_, misspelledWord, dictionarySuggestions) {
|
||||
events.emit('spellcheck-result', misspelledWord, dictionarySuggestions);
|
||||
}
|
||||
|
||||
function on() {
|
||||
events.on.apply(events, arguments);
|
||||
}
|
||||
|
||||
function removeListener() {
|
||||
events.removeListener.apply(events, arguments);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
on,
|
||||
removeListener,
|
||||
getAvailableDictionaries,
|
||||
setLocale,
|
||||
setLearnedWords,
|
||||
replaceMisspelling
|
||||
};
|
||||
}
|
208
app/discord_native/renderer/window.js
Normal file
|
@ -0,0 +1,208 @@
|
|||
'use strict';
|
||||
|
||||
let flashFrame = (() => {
|
||||
var _ref3 = _asyncToGenerator(function* (flag) {
|
||||
electron.ipcRenderer.invoke(WINDOW_FLASH_FRAME, flag);
|
||||
});
|
||||
|
||||
return function flashFrame(_x3) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let minimize = (() => {
|
||||
var _ref4 = _asyncToGenerator(function* (key) {
|
||||
electron.ipcRenderer.invoke(WINDOW_MINIMIZE, key);
|
||||
});
|
||||
|
||||
return function minimize(_x4) {
|
||||
return _ref4.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let restore = (() => {
|
||||
var _ref5 = _asyncToGenerator(function* (key) {
|
||||
electron.ipcRenderer.invoke(WINDOW_RESTORE, key);
|
||||
});
|
||||
|
||||
return function restore(_x5) {
|
||||
return _ref5.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let maximize = (() => {
|
||||
var _ref6 = _asyncToGenerator(function* (key) {
|
||||
electron.ipcRenderer.invoke(WINDOW_MAXIMIZE, key);
|
||||
});
|
||||
|
||||
return function maximize(_x6) {
|
||||
return _ref6.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let focus = (() => {
|
||||
var _ref7 = _asyncToGenerator(function* (_hack, key) {
|
||||
electron.ipcRenderer.invoke(WINDOW_FOCUS, key);
|
||||
});
|
||||
|
||||
return function focus(_x7, _x8) {
|
||||
return _ref7.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let setAlwaysOnTop = (() => {
|
||||
var _ref8 = _asyncToGenerator(function* (key, enabled) {
|
||||
return electron.ipcRenderer.invoke(WINDOW_SET_ALWAYS_ON_TOP, key, enabled);
|
||||
});
|
||||
|
||||
return function setAlwaysOnTop(_x9, _x10) {
|
||||
return _ref8.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let isAlwaysOnTop = (() => {
|
||||
var _ref9 = _asyncToGenerator(function* (key) {
|
||||
return electron.ipcRenderer.invoke(WINDOW_IS_ALWAYS_ON_TOP, key);
|
||||
});
|
||||
|
||||
return function isAlwaysOnTop(_x11) {
|
||||
return _ref9.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let blur = (() => {
|
||||
var _ref10 = _asyncToGenerator(function* (key) {
|
||||
electron.ipcRenderer.invoke(WINDOW_BLUR, key);
|
||||
});
|
||||
|
||||
return function blur(_x12) {
|
||||
return _ref10.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let setProgressBar = (() => {
|
||||
var _ref11 = _asyncToGenerator(function* (progress, key) {
|
||||
electron.ipcRenderer.invoke(WINDOW_SET_PROGRESS_BAR, key, progress);
|
||||
});
|
||||
|
||||
return function setProgressBar(_x13, _x14) {
|
||||
return _ref11.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let fullscreen = (() => {
|
||||
var _ref12 = _asyncToGenerator(function* (key) {
|
||||
electron.ipcRenderer.invoke(WINDOW_TOGGLE_FULLSCREEN, key);
|
||||
});
|
||||
|
||||
return function fullscreen(_x15) {
|
||||
return _ref12.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let close = (() => {
|
||||
var _ref13 = _asyncToGenerator(function* (key) {
|
||||
electron.ipcRenderer.invoke(WINDOW_CLOSE, key);
|
||||
});
|
||||
|
||||
return function close(_x16) {
|
||||
return _ref13.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let setZoomFactor = (() => {
|
||||
var _ref14 = _asyncToGenerator(function* (factor) {
|
||||
if (!electron.webFrame.setZoomFactor) return;
|
||||
electron.webFrame.setZoomFactor(factor / 100);
|
||||
});
|
||||
|
||||
return function setZoomFactor(_x17) {
|
||||
return _ref14.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let setBackgroundThrottling = (() => {
|
||||
var _ref15 = _asyncToGenerator(function* (enabled) {
|
||||
electron.ipcRenderer.invoke(WINDOW_SET_BACKGROUND_THROTTLING, enabled);
|
||||
});
|
||||
|
||||
return function setBackgroundThrottling(_x18) {
|
||||
return _ref15.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
let setDevtoolsCallbacks = (() => {
|
||||
var _ref16 = _asyncToGenerator(function* (onOpened, onClosed) {
|
||||
devtoolsOpenedCallback = onOpened;
|
||||
devtoolsClosedCallback = onClosed;
|
||||
});
|
||||
|
||||
return function setDevtoolsCallbacks(_x19, _x20) {
|
||||
return _ref16.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
||||
|
||||
const electron = require('electron');
|
||||
|
||||
const {
|
||||
WINDOW_BLUR,
|
||||
WINDOW_CLOSE,
|
||||
WINDOW_FOCUS,
|
||||
WINDOW_MAXIMIZE,
|
||||
WINDOW_MINIMIZE,
|
||||
WINDOW_RESTORE,
|
||||
WINDOW_FLASH_FRAME,
|
||||
WINDOW_TOGGLE_FULLSCREEN,
|
||||
WINDOW_SET_BACKGROUND_THROTTLING,
|
||||
WINDOW_SET_PROGRESS_BAR,
|
||||
WINDOW_IS_ALWAYS_ON_TOP,
|
||||
WINDOW_SET_ALWAYS_ON_TOP,
|
||||
WINDOW_DEVTOOLS_OPENED,
|
||||
WINDOW_DEVTOOLS_CLOSED
|
||||
} = require('../common/constants').IPCEvents;
|
||||
|
||||
let devtoolsOpenedCallback = () => {};
|
||||
let devtoolsClosedCallback = () => {};
|
||||
|
||||
electron.ipcRenderer.on(WINDOW_DEVTOOLS_OPENED, (() => {
|
||||
var _ref = _asyncToGenerator(function* (_) {
|
||||
if (devtoolsOpenedCallback != null) {
|
||||
devtoolsOpenedCallback();
|
||||
}
|
||||
});
|
||||
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
electron.ipcRenderer.on(WINDOW_DEVTOOLS_CLOSED, (() => {
|
||||
var _ref2 = _asyncToGenerator(function* (_) {
|
||||
if (devtoolsOpenedCallback != null) {
|
||||
devtoolsOpenedCallback();
|
||||
}
|
||||
});
|
||||
|
||||
return function (_x2) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
})());
|
||||
|
||||
module.exports = {
|
||||
flashFrame,
|
||||
minimize,
|
||||
restore,
|
||||
maximize,
|
||||
focus,
|
||||
blur,
|
||||
fullscreen,
|
||||
close,
|
||||
setAlwaysOnTop,
|
||||
isAlwaysOnTop,
|
||||
setZoomFactor,
|
||||
setBackgroundThrottling,
|
||||
setProgressBar,
|
||||
setDevtoolsCallbacks
|
||||
};
|
BIN
app/images/badges/badge-1.ico
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
app/images/badges/badge-10.ico
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
app/images/badges/badge-11.ico
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
app/images/badges/badge-2.ico
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
app/images/badges/badge-3.ico
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
app/images/badges/badge-4.ico
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
app/images/badges/badge-5.ico
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
app/images/badges/badge-6.ico
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
app/images/badges/badge-7.ico
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
app/images/badges/badge-8.ico
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
app/images/badges/badge-9.ico
Normal file
After Width: | Height: | Size: 15 KiB |
15
app/images/close.svg
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 17.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="20px" height="20px"
|
||||
viewBox="40 40 20 20" enable-background="new 40 40 20 20" xml:space="preserve">
|
||||
<title>Slice 1</title>
|
||||
<description>Created with Sketch (http://www.bohemiancoding.com/sketch)</description>
|
||||
<g id="Page_1">
|
||||
<path id="Close" fill="#99aab5" d="M40.445,42.853l2.408-2.408c0.593-0.593,1.555-0.593,2.147,0l5,5l5-5
|
||||
c0.593-0.593,1.554-0.593,2.147,0l2.408,2.408c0.593,0.593,0.593,1.554,0,2.147l-5,5l5,5c0.593,0.593,0.592,1.554,0,2.147
|
||||
l-2.408,2.408c-0.593,0.593-1.555,0.593-2.147,0l-5-5l-5,5c-0.593,0.593-1.554,0.593-2.147,0l-2.408-2.408
|
||||
c-0.593-0.593-0.593-1.554,0-2.147l5-5l-5-5C39.852,44.407,39.852,43.445,40.445,42.853z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
34
app/images/discord.svg
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 168 190" enable-background="new 0 0 168 190" xml:space="preserve">
|
||||
<g>
|
||||
<rect x="14.4" y="46.1" fill="#FFFFFF" width="139.2" height="97.7"/>
|
||||
<g>
|
||||
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="66.6616" y1="79.7119" x2="66.6616" y2="100.7434">
|
||||
<stop offset="0" style="stop-color:#7491D5"/>
|
||||
<stop offset="1" style="stop-color:#4E68A0"/>
|
||||
</linearGradient>
|
||||
<path fill="url(#SVGID_1_)" d="M66.7,79.7c-5.4,0-9.8,4.7-9.8,10.5c0,5.8,4.4,10.5,9.8,10.5c5.4,0,9.8-4.7,9.8-10.5
|
||||
C76.5,84.4,72.1,79.7,66.7,79.7z"/>
|
||||
<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="101.661" y1="79.7119" x2="101.661" y2="100.7434">
|
||||
<stop offset="0" style="stop-color:#7491D5"/>
|
||||
<stop offset="1" style="stop-color:#4E68A0"/>
|
||||
</linearGradient>
|
||||
<path fill="url(#SVGID_2_)" d="M101.7,79.7c-5.4,0-9.8,4.7-9.8,10.5c0,5.8,4.4,10.5,9.8,10.5c5.4,0,9.8-4.7,9.8-10.5
|
||||
C111.5,84.4,107.1,79.7,101.7,79.7z"/>
|
||||
<linearGradient id="SVGID_3_" gradientUnits="userSpaceOnUse" x1="84" y1="-4.545736e-07" x2="84" y2="190">
|
||||
<stop offset="0" style="stop-color:#7491D5"/>
|
||||
<stop offset="1" style="stop-color:#4E68A0"/>
|
||||
</linearGradient>
|
||||
<path fill="url(#SVGID_3_)" d="M148.4,0H19.6C8.8,0,0,8.8,0,19.6v128.4c0,10.8,8.8,19.6,19.6,19.6h108.9l-5.1-17.5l12.3,11.3
|
||||
l11.6,10.7L168,190v-41.9v-9.5V19.6C168,8.8,159.2,0,148.4,0z M111.3,124.1c0,0-3.4-4.1-6.3-7.7c12.6-3.5,17.4-11.3,17.4-11.3
|
||||
c-4,2.6-7.7,4.4-11.1,5.6c-4.8,2-9.5,3.3-14,4.1c-9.2,1.7-17.6,1.3-24.9-0.1c-5.5-1-10.2-2.5-14.1-4.1c-2.2-0.8-4.6-1.9-7.1-3.3
|
||||
c-0.3-0.2-0.6-0.3-0.9-0.5c-0.1-0.1-0.3-0.2-0.4-0.2c-1.7-1-2.6-1.6-2.6-1.6s4.6,7.6,16.8,11.2c-2.9,3.6-6.4,7.9-6.4,7.9
|
||||
c-21.2-0.6-29.3-14.5-29.3-14.5c0-30.6,13.8-55.4,13.8-55.4c13.8-10.3,26.9-10,26.9-10l1,1.1C52.8,50.3,45,57.9,45,57.9
|
||||
s2.1-1.2,5.7-2.7c10.3-4.5,18.4-5.7,21.8-6c0.5-0.1,1.1-0.2,1.6-0.2c5.9-0.7,12.5-0.9,19.4-0.2c9.1,1,18.9,3.7,28.9,9.1
|
||||
c0,0-7.5-7.2-23.9-12.1l1.3-1.5c0,0,13.1-0.3,26.9,10c0,0,13.8,24.8,13.8,55.4C140.6,109.6,132.5,123.5,111.3,124.1z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.3 KiB |
BIN
app/images/systemtray/darwin/tray-connectedTemplate.png
Normal file
After Width: | Height: | Size: 153 B |
BIN
app/images/systemtray/darwin/tray-connectedTemplate@1.25x.png
Normal file
After Width: | Height: | Size: 189 B |
BIN
app/images/systemtray/darwin/tray-connectedTemplate@1.33x.png
Normal file
After Width: | Height: | Size: 232 B |
BIN
app/images/systemtray/darwin/tray-connectedTemplate@1.4x.png
Normal file
After Width: | Height: | Size: 238 B |
BIN
app/images/systemtray/darwin/tray-connectedTemplate@1.5x.png
Normal file
After Width: | Height: | Size: 205 B |
BIN
app/images/systemtray/darwin/tray-connectedTemplate@1.8x.png
Normal file
After Width: | Height: | Size: 281 B |
BIN
app/images/systemtray/darwin/tray-connectedTemplate@2.5x.png
Normal file
After Width: | Height: | Size: 294 B |
BIN
app/images/systemtray/darwin/tray-connectedTemplate@2x.png
Normal file
After Width: | Height: | Size: 229 B |
BIN
app/images/systemtray/darwin/tray-connectedTemplate@3x.png
Normal file
After Width: | Height: | Size: 301 B |
BIN
app/images/systemtray/darwin/tray-connectedTemplate@4x.png
Normal file
After Width: | Height: | Size: 421 B |
BIN
app/images/systemtray/darwin/tray-connectedTemplate@5x.png
Normal file
After Width: | Height: | Size: 540 B |
BIN
app/images/systemtray/darwin/tray-deafenedTemplate.png
Normal file
After Width: | Height: | Size: 233 B |
BIN
app/images/systemtray/darwin/tray-deafenedTemplate@1.25x.png
Normal file
After Width: | Height: | Size: 291 B |
BIN
app/images/systemtray/darwin/tray-deafenedTemplate@1.33x.png
Normal file
After Width: | Height: | Size: 308 B |
BIN
app/images/systemtray/darwin/tray-deafenedTemplate@1.4x.png
Normal file
After Width: | Height: | Size: 313 B |
BIN
app/images/systemtray/darwin/tray-deafenedTemplate@1.5x.png
Normal file
After Width: | Height: | Size: 305 B |
BIN
app/images/systemtray/darwin/tray-deafenedTemplate@1.8x.png
Normal file
After Width: | Height: | Size: 383 B |
BIN
app/images/systemtray/darwin/tray-deafenedTemplate@2.5x.png
Normal file
After Width: | Height: | Size: 470 B |
BIN
app/images/systemtray/darwin/tray-deafenedTemplate@2x.png
Normal file
After Width: | Height: | Size: 385 B |
BIN
app/images/systemtray/darwin/tray-deafenedTemplate@3x.png
Normal file
After Width: | Height: | Size: 491 B |
BIN
app/images/systemtray/darwin/tray-deafenedTemplate@4x.png
Normal file
After Width: | Height: | Size: 668 B |
BIN
app/images/systemtray/darwin/tray-deafenedTemplate@5x.png
Normal file
After Width: | Height: | Size: 834 B |
BIN
app/images/systemtray/darwin/tray-mutedTemplate.png
Normal file
After Width: | Height: | Size: 216 B |
BIN
app/images/systemtray/darwin/tray-mutedTemplate@1.25x.png
Normal file
After Width: | Height: | Size: 271 B |
BIN
app/images/systemtray/darwin/tray-mutedTemplate@1.33x.png
Normal file
After Width: | Height: | Size: 284 B |
BIN
app/images/systemtray/darwin/tray-mutedTemplate@1.4x.png
Normal file
After Width: | Height: | Size: 298 B |
BIN
app/images/systemtray/darwin/tray-mutedTemplate@1.5x.png
Normal file
After Width: | Height: | Size: 293 B |
BIN
app/images/systemtray/darwin/tray-mutedTemplate@1.8x.png
Normal file
After Width: | Height: | Size: 368 B |
BIN
app/images/systemtray/darwin/tray-mutedTemplate@2.5x.png
Normal file
After Width: | Height: | Size: 454 B |
BIN
app/images/systemtray/darwin/tray-mutedTemplate@2x.png
Normal file
After Width: | Height: | Size: 354 B |
BIN
app/images/systemtray/darwin/tray-mutedTemplate@3x.png
Normal file
After Width: | Height: | Size: 496 B |
BIN
app/images/systemtray/darwin/tray-mutedTemplate@4x.png
Normal file
After Width: | Height: | Size: 609 B |
BIN
app/images/systemtray/darwin/tray-mutedTemplate@5x.png
Normal file
After Width: | Height: | Size: 753 B |
BIN
app/images/systemtray/darwin/tray-speakingTemplate.png
Normal file
After Width: | Height: | Size: 199 B |
BIN
app/images/systemtray/darwin/tray-speakingTemplate@1.25x.png
Normal file
After Width: | Height: | Size: 261 B |
BIN
app/images/systemtray/darwin/tray-speakingTemplate@1.33x.png
Normal file
After Width: | Height: | Size: 297 B |
BIN
app/images/systemtray/darwin/tray-speakingTemplate@1.4x.png
Normal file
After Width: | Height: | Size: 325 B |
BIN
app/images/systemtray/darwin/tray-speakingTemplate@1.5x.png
Normal file
After Width: | Height: | Size: 303 B |