Merge pull request #4109 from atom/const
[WIP] Use `const` for requires
This commit is contained in:
commit
3875b30fcf
44 changed files with 314 additions and 437 deletions
|
@ -1,15 +1,13 @@
|
|||
var EventEmitter, Menu, app, appPath, bindings, deprecate, downloadItemBindings, fn, i, len, name, ref, ref1, session, wrapDownloadItem,
|
||||
slice = [].slice;
|
||||
const deprecate = require('electron').deprecate;
|
||||
const session = require('electron').session;
|
||||
const Menu = require('electron').Menu;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
|
||||
ref = require('electron'), deprecate = ref.deprecate, session = ref.session, Menu = ref.Menu;
|
||||
const bindings = process.atomBinding('app');
|
||||
const downloadItemBindings = process.atomBinding('download_item');
|
||||
const app = bindings.app;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
bindings = process.atomBinding('app');
|
||||
|
||||
downloadItemBindings = process.atomBinding('download_item');
|
||||
|
||||
app = bindings.app;
|
||||
var slice = [].slice;
|
||||
|
||||
app.__proto__ = EventEmitter.prototype;
|
||||
|
||||
|
@ -43,7 +41,7 @@ if (process.platform === 'darwin') {
|
|||
};
|
||||
}
|
||||
|
||||
appPath = null;
|
||||
var appPath = null;
|
||||
|
||||
app.setAppPath = function(path) {
|
||||
return appPath = path;
|
||||
|
@ -54,17 +52,18 @@ app.getAppPath = function() {
|
|||
};
|
||||
|
||||
// Routes the events to webContents.
|
||||
ref1 = ['login', 'certificate-error', 'select-client-certificate'];
|
||||
fn = function(name) {
|
||||
var ref1 = ['login', 'certificate-error', 'select-client-certificate'];
|
||||
var fn = function(name) {
|
||||
return app.on(name, function() {
|
||||
var args, event, webContents;
|
||||
event = arguments[0], webContents = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
|
||||
return webContents.emit.apply(webContents, [name, event].concat(slice.call(args)));
|
||||
});
|
||||
};
|
||||
var i, len, name;
|
||||
for (i = 0, len = ref1.length; i < len; i++) {
|
||||
name = ref1[i];
|
||||
fn(name);
|
||||
fn(ref1[i]);
|
||||
}
|
||||
|
||||
// Deprecated.
|
||||
|
@ -106,7 +105,7 @@ deprecate.event(app, 'activate-with-no-open-windows', 'activate', function(event
|
|||
deprecate.event(app, 'select-certificate', 'select-client-certificate');
|
||||
|
||||
// Wrappers for native classes.
|
||||
wrapDownloadItem = function(downloadItem) {
|
||||
var wrapDownloadItem = function(downloadItem) {
|
||||
|
||||
// downloadItem is an EventEmitter.
|
||||
downloadItem.__proto__ = EventEmitter.prototype;
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
var autoUpdater, deprecate;
|
||||
|
||||
deprecate = require('electron').deprecate;
|
||||
|
||||
autoUpdater = process.platform === 'win32' ? require('./auto-updater/auto-updater-win') : require('./auto-updater/auto-updater-native');
|
||||
const deprecate = require('electron').deprecate;
|
||||
const autoUpdater = process.platform === 'win32' ? require('./auto-updater/auto-updater-win') : require('./auto-updater/auto-updater-native');
|
||||
|
||||
// Deprecated.
|
||||
deprecate.rename(autoUpdater, 'setFeedUrl', 'setFeedURL');
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
var EventEmitter, autoUpdater;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
autoUpdater = process.atomBinding('auto_updater').autoUpdater;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const autoUpdater = process.atomBinding('auto_updater').autoUpdater;
|
||||
|
||||
autoUpdater.__proto__ = EventEmitter.prototype;
|
||||
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
var AutoUpdater, EventEmitter, app, squirrelUpdate, url,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
const app = require('electron').app;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const url = require('url');
|
||||
const squirrelUpdate = require('./squirrel-update-win');
|
||||
|
||||
app = require('electron').app;
|
||||
var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
url = require('url');
|
||||
|
||||
squirrelUpdate = require('./squirrel-update-win');
|
||||
|
||||
AutoUpdater = (function(superClass) {
|
||||
var AutoUpdater = (function(superClass) {
|
||||
extend(AutoUpdater, superClass);
|
||||
|
||||
function AutoUpdater() {
|
||||
|
|
|
@ -1,22 +1,18 @@
|
|||
var appFolder, exeName, fs, path, spawn, spawnUpdate, updateExe;
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
path = require('path');
|
||||
|
||||
spawn = require('child_process').spawn;
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const spawn = require('child_process').spawn;
|
||||
|
||||
// i.e. my-app/app-0.1.13/
|
||||
appFolder = path.dirname(process.execPath);
|
||||
const appFolder = path.dirname(process.execPath);
|
||||
|
||||
// i.e. my-app/Update.exe
|
||||
updateExe = path.resolve(appFolder, '..', 'Update.exe');
|
||||
const updateExe = path.resolve(appFolder, '..', 'Update.exe');
|
||||
|
||||
exeName = path.basename(process.execPath);
|
||||
const exeName = path.basename(process.execPath);
|
||||
|
||||
// Spawn a command and invoke the callback when it completes with an error
|
||||
// and the output from standard out.
|
||||
spawnUpdate = function(args, detached, callback) {
|
||||
var spawnUpdate = function(args, detached, callback) {
|
||||
var error, error1, errorEmitted, spawnedProcess, stderr, stdout;
|
||||
try {
|
||||
spawnedProcess = spawn(updateExe, args, {
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
var BrowserWindow, EventEmitter, deprecate, ipcMain, ref;
|
||||
|
||||
ref = require('electron'), ipcMain = ref.ipcMain, deprecate = ref.deprecate;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
BrowserWindow = process.atomBinding('window').BrowserWindow;
|
||||
const ipcMain = require('electron').ipcMain;
|
||||
const deprecate = require('electron').deprecate;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const BrowserWindow = process.atomBinding('window').BrowserWindow;
|
||||
|
||||
BrowserWindow.prototype.__proto__ = EventEmitter.prototype;
|
||||
|
||||
|
|
|
@ -1,27 +1,25 @@
|
|||
var BrowserWindow, api, app, binding, checkAppInitialized, fileDialogProperties, j, len, messageBoxOptions, messageBoxTypes, parseArgs, ref, ref1, v8Util,
|
||||
slice = [].slice,
|
||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
const app = require('electron').app;
|
||||
const BrowserWindow = require('electron').BrowserWindow;
|
||||
const binding = process.atomBinding('dialog');
|
||||
const v8Util = process.atomBinding('v8_util');
|
||||
|
||||
ref = require('electron'), app = ref.app, BrowserWindow = ref.BrowserWindow;
|
||||
var slice = [].slice;
|
||||
var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
||||
binding = process.atomBinding('dialog');
|
||||
|
||||
v8Util = process.atomBinding('v8_util');
|
||||
|
||||
fileDialogProperties = {
|
||||
var fileDialogProperties = {
|
||||
openFile: 1 << 0,
|
||||
openDirectory: 1 << 1,
|
||||
multiSelections: 1 << 2,
|
||||
createDirectory: 1 << 3
|
||||
};
|
||||
|
||||
messageBoxTypes = ['none', 'info', 'warning', 'error', 'question'];
|
||||
var messageBoxTypes = ['none', 'info', 'warning', 'error', 'question'];
|
||||
|
||||
messageBoxOptions = {
|
||||
var messageBoxOptions = {
|
||||
noLink: 1 << 0
|
||||
};
|
||||
|
||||
parseArgs = function(window, options, callback) {
|
||||
var parseArgs = function(window, options, callback) {
|
||||
if (!(window === null || (window != null ? window.constructor : void 0) === BrowserWindow)) {
|
||||
// Shift.
|
||||
callback = options;
|
||||
|
@ -36,7 +34,7 @@ parseArgs = function(window, options, callback) {
|
|||
return [window, options, callback];
|
||||
};
|
||||
|
||||
checkAppInitialized = function() {
|
||||
var checkAppInitialized = function() {
|
||||
if (!app.isReady()) {
|
||||
throw new Error('dialog module can only be used after app is ready');
|
||||
}
|
||||
|
@ -164,7 +162,8 @@ module.exports = {
|
|||
};
|
||||
|
||||
// Mark standard asynchronous functions.
|
||||
ref1 = ['showMessageBox', 'showOpenDialog', 'showSaveDialog'];
|
||||
var ref1 = ['showMessageBox', 'showOpenDialog', 'showSaveDialog'];
|
||||
var j, len, api;
|
||||
for (j = 0, len = ref1.length; j < len; j++) {
|
||||
api = ref1[j];
|
||||
v8Util.setHiddenValue(module.exports[api], 'asynchronous', true);
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
var common;
|
||||
|
||||
common = require('../../../../common/api/lib/exports/electron');
|
||||
const common = require('../../../../common/api/lib/exports/electron');
|
||||
|
||||
|
||||
// Import common modules.
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
var EventEmitter;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
|
||||
module.exports = new EventEmitter;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
var deprecate, ipcMain, ref;
|
||||
|
||||
ref = require('electron'), deprecate = ref.deprecate, ipcMain = ref.ipcMain;
|
||||
const deprecate = require('electron').deprecate;
|
||||
const ipcMain = require('electron').ipcMain;
|
||||
|
||||
// This module is deprecated, we mirror everything from ipcMain.
|
||||
deprecate.warn('ipc module', 'require("electron").ipcMain');
|
||||
|
|
|
@ -26,8 +26,8 @@ MenuItem = (function() {
|
|||
MenuItem.types = ['normal', 'separator', 'submenu', 'checkbox', 'radio'];
|
||||
|
||||
function MenuItem(options) {
|
||||
var Menu, click, ref;
|
||||
Menu = require('electron').Menu;
|
||||
var click, ref;
|
||||
const Menu = require('electron').Menu;
|
||||
click = options.click, this.selector = options.selector, this.type = options.type, this.role = options.role, this.label = options.label, this.sublabel = options.sublabel, this.accelerator = options.accelerator, this.icon = options.icon, this.enabled = options.enabled, this.visible = options.visible, this.checked = options.checked, this.submenu = options.submenu;
|
||||
if ((this.submenu != null) && this.submenu.constructor !== Menu) {
|
||||
this.submenu = Menu.buildFromTemplate(this.submenu);
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
var BrowserWindow, EventEmitter, Menu, MenuItem, applicationMenu, bindings, generateGroupId, indexOfItemById, indexToInsertByPosition, nextGroupId, ref, v8Util;
|
||||
|
||||
ref = require('electron'), BrowserWindow = ref.BrowserWindow, MenuItem = ref.MenuItem;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
v8Util = process.atomBinding('v8_util');
|
||||
|
||||
bindings = process.atomBinding('menu');
|
||||
const BrowserWindow = require('electron').BrowserWindow;
|
||||
const MenuItem = require('electron').MenuItem;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const v8Util = process.atomBinding('v8_util');
|
||||
const bindings = process.atomBinding('menu');
|
||||
|
||||
// Automatically generated radio menu item's group id.
|
||||
nextGroupId = 0;
|
||||
var nextGroupId = 0;
|
||||
|
||||
// Search between seperators to find a radio menu item and return its group id,
|
||||
// otherwise generate a group id.
|
||||
generateGroupId = function(items, pos) {
|
||||
var generateGroupId = function(items, pos) {
|
||||
var i, item, j, k, ref1, ref2, ref3;
|
||||
if (pos > 0) {
|
||||
for (i = j = ref1 = pos - 1; ref1 <= 0 ? j <= 0 : j >= 0; i = ref1 <= 0 ? ++j : --j) {
|
||||
|
@ -40,7 +36,7 @@ generateGroupId = function(items, pos) {
|
|||
};
|
||||
|
||||
// Returns the index of item according to |id|.
|
||||
indexOfItemById = function(items, id) {
|
||||
var indexOfItemById = function(items, id) {
|
||||
var i, item, j, len;
|
||||
for (i = j = 0, len = items.length; j < len; i = ++j) {
|
||||
item = items[i];
|
||||
|
@ -52,7 +48,7 @@ indexOfItemById = function(items, id) {
|
|||
};
|
||||
|
||||
// Returns the index of where to insert the item according to |position|.
|
||||
indexToInsertByPosition = function(items, position) {
|
||||
var indexToInsertByPosition = function(items, position) {
|
||||
var id, insertIndex, query, ref1;
|
||||
if (!position) {
|
||||
return items.length;
|
||||
|
@ -87,7 +83,7 @@ indexToInsertByPosition = function(items, position) {
|
|||
return insertIndex;
|
||||
};
|
||||
|
||||
Menu = bindings.Menu;
|
||||
const Menu = bindings.Menu;
|
||||
|
||||
Menu.prototype.__proto__ = EventEmitter.prototype;
|
||||
|
||||
|
@ -265,7 +261,7 @@ Menu.prototype._callMenuWillShow = function() {
|
|||
return results;
|
||||
};
|
||||
|
||||
applicationMenu = null;
|
||||
var applicationMenu = null;
|
||||
|
||||
Menu.setApplicationMenu = function(menu) {
|
||||
var j, len, results, w, windows;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
var NavigationController, ipcMain,
|
||||
slice = [].slice;
|
||||
const ipcMain = require('electron').ipcMain;
|
||||
|
||||
ipcMain = require('electron').ipcMain;
|
||||
var slice = [].slice;
|
||||
|
||||
// The history operation in renderer is redirected to browser.
|
||||
ipcMain.on('ATOM_SHELL_NAVIGATION_CONTROLLER', function() {
|
||||
|
@ -21,7 +20,7 @@ ipcMain.on('ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER', function() {
|
|||
// control on user land, and only rely on WebContents.loadURL for navigation.
|
||||
// This helps us avoid Chromium's various optimizations so we can ensure renderer
|
||||
// process is restarted everytime.
|
||||
NavigationController = (function() {
|
||||
var NavigationController = (function() {
|
||||
function NavigationController(webContents) {
|
||||
this.webContents = webContents;
|
||||
this.clearHistory();
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
var EventEmitter, powerMonitor;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
powerMonitor = process.atomBinding('power_monitor').powerMonitor;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const powerMonitor = process.atomBinding('power_monitor').powerMonitor;
|
||||
|
||||
powerMonitor.__proto__ = EventEmitter.prototype;
|
||||
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
var app, logAndThrow, protocol;
|
||||
|
||||
app = require('electron').app;
|
||||
const app = require('electron').app;
|
||||
|
||||
if (!app.isReady()) {
|
||||
throw new Error('Can not initialize protocol module before app is ready');
|
||||
}
|
||||
|
||||
protocol = process.atomBinding('protocol').protocol;
|
||||
const protocol = process.atomBinding('protocol').protocol;
|
||||
|
||||
// Warn about removed APIs.
|
||||
logAndThrow = function(callback, message) {
|
||||
var logAndThrow = function(callback, message) {
|
||||
console.error(message);
|
||||
if (callback) {
|
||||
return callback(new Error(message));
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
var EventEmitter, screen;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
screen = process.atomBinding('screen').screen;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const screen = process.atomBinding('screen').screen;
|
||||
|
||||
screen.__proto__ = EventEmitter.prototype;
|
||||
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
var EventEmitter, PERSIST_PERFIX, bindings, wrapSession;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
bindings = process.atomBinding('session');
|
||||
|
||||
PERSIST_PERFIX = 'persist:';
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const bindings = process.atomBinding('session');
|
||||
const PERSIST_PERFIX = 'persist:';
|
||||
|
||||
// Returns the Session from |partition| string.
|
||||
exports.fromPartition = function(partition) {
|
||||
|
@ -29,7 +25,7 @@ Object.defineProperty(exports, 'defaultSession', {
|
|||
}
|
||||
});
|
||||
|
||||
wrapSession = function(session) {
|
||||
var wrapSession = function(session) {
|
||||
// session is an EventEmitter.
|
||||
return session.__proto__ = EventEmitter.prototype;
|
||||
};
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
var EventEmitter, Tray, deprecate;
|
||||
|
||||
deprecate = require('electron').deprecate;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
Tray = process.atomBinding('tray').Tray;
|
||||
const deprecate = require('electron').deprecate;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const Tray = process.atomBinding('tray').Tray;
|
||||
|
||||
Tray.prototype.__proto__ = EventEmitter.prototype;
|
||||
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
'use strict';
|
||||
|
||||
var EventEmitter, Menu, NavigationController, PDFPageSize, binding, deprecate, getNextId, ipcMain, nextId, ref, session, wrapWebContents,
|
||||
slice = [].slice;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const deprecate = require('electron').deprecate;
|
||||
const ipcMain = require('electron').ipcMain;
|
||||
const session = require('electron').session;
|
||||
const NavigationController = require('electron').NavigationController;
|
||||
const Menu = require('electron').Menu;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
const binding = process.atomBinding('web_contents');
|
||||
|
||||
ref = require('electron'), deprecate = ref.deprecate, ipcMain = ref.ipcMain, session = ref.session, NavigationController = ref.NavigationController, Menu = ref.Menu;
|
||||
let slice = [].slice;
|
||||
let nextId = 0;
|
||||
|
||||
binding = process.atomBinding('web_contents');
|
||||
|
||||
nextId = 0;
|
||||
|
||||
getNextId = function() {
|
||||
let getNextId = function() {
|
||||
return ++nextId;
|
||||
};
|
||||
|
||||
PDFPageSize = {
|
||||
let PDFPageSize = {
|
||||
A5: {
|
||||
custom_display_name: "A5",
|
||||
height_microns: 210000,
|
||||
|
@ -64,7 +65,7 @@ const webFrameMethods = [
|
|||
'setZoomLevelLimits',
|
||||
];
|
||||
|
||||
wrapWebContents = function(webContents) {
|
||||
let wrapWebContents = function(webContents) {
|
||||
// webContents is an EventEmitter.
|
||||
var controller, method, name, ref1;
|
||||
webContents.__proto__ = EventEmitter.prototype;
|
||||
|
|
|
@ -1,33 +1,28 @@
|
|||
var app, electron, extensionInfoMap, fs, getExtensionInfoFromPath, getHostForPath, getPathForHost, hostPathMap, hostPathMapNextKey, loadedExtensions, loadedExtensionsPath, path, url;
|
||||
|
||||
electron = require('electron');
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
path = require('path');
|
||||
|
||||
url = require('url');
|
||||
const electron = require('electron');
|
||||
const app = electron.app;
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const url = require('url');
|
||||
|
||||
// Mapping between hostname and file path.
|
||||
hostPathMap = {};
|
||||
var hostPathMap = {};
|
||||
var hostPathMapNextKey = 0;
|
||||
|
||||
hostPathMapNextKey = 0;
|
||||
|
||||
getHostForPath = function(path) {
|
||||
var getHostForPath = function(path) {
|
||||
var key;
|
||||
key = "extension-" + (++hostPathMapNextKey);
|
||||
hostPathMap[key] = path;
|
||||
return key;
|
||||
};
|
||||
|
||||
getPathForHost = function(host) {
|
||||
var getPathForHost = function(host) {
|
||||
return hostPathMap[host];
|
||||
};
|
||||
|
||||
// Cache extensionInfo.
|
||||
extensionInfoMap = {};
|
||||
var extensionInfoMap = {};
|
||||
|
||||
getExtensionInfoFromPath = function(srcDirectory) {
|
||||
var getExtensionInfoFromPath = function(srcDirectory) {
|
||||
var manifest, page;
|
||||
manifest = JSON.parse(fs.readFileSync(path.join(srcDirectory, 'manifest.json')));
|
||||
if (extensionInfoMap[manifest.name] == null) {
|
||||
|
@ -51,11 +46,8 @@ getExtensionInfoFromPath = function(srcDirectory) {
|
|||
};
|
||||
|
||||
// The loaded extensions cache and its persistent path.
|
||||
loadedExtensions = null;
|
||||
loadedExtensionsPath = null;
|
||||
|
||||
// Persistent loaded extensions.
|
||||
app = electron.app;
|
||||
var loadedExtensions = null;
|
||||
var loadedExtensionsPath = null;
|
||||
|
||||
app.on('will-quit', function() {
|
||||
var e, error1, error2;
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
var deepEqual, desktopCapturer, ipcMain, requestsQueue;
|
||||
const ipcMain = require('electron').ipcMain;
|
||||
const desktopCapturer = process.atomBinding('desktop_capturer').desktopCapturer;
|
||||
|
||||
ipcMain = require('electron').ipcMain;
|
||||
|
||||
desktopCapturer = process.atomBinding('desktop_capturer').desktopCapturer;
|
||||
|
||||
deepEqual = function(opt1, opt2) {
|
||||
var deepEqual = function(opt1, opt2) {
|
||||
return JSON.stringify(opt1) === JSON.stringify(opt2);
|
||||
};
|
||||
|
||||
// A queue for holding all requests from renderer process.
|
||||
requestsQueue = [];
|
||||
var requestsQueue = [];
|
||||
|
||||
ipcMain.on('ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', function(event, captureWindow, captureScreen, thumbnailSize, id) {
|
||||
var request;
|
||||
|
|
|
@ -1,33 +1,30 @@
|
|||
var attachGuest, createGuest, destroyGuest, embedderElementsMap, getNextInstanceId, guestInstances, ipcMain, moveLastToFirst, nextInstanceId, ref, reverseEmbedderElementsMap, supportedWebViewEvents, webContents, webViewManager,
|
||||
slice = [].slice;
|
||||
const ipcMain = require('electron').ipcMain;
|
||||
const webContents = require('electron').webContents;
|
||||
|
||||
ref = require('electron'), ipcMain = ref.ipcMain, webContents = ref.webContents;
|
||||
var slice = [].slice;
|
||||
|
||||
// Doesn't exist in early initialization.
|
||||
webViewManager = null;
|
||||
var webViewManager = null;
|
||||
|
||||
supportedWebViewEvents = ['load-commit', 'did-finish-load', 'did-fail-load', 'did-frame-finish-load', 'did-start-loading', 'did-stop-loading', 'did-get-response-details', 'did-get-redirect-request', 'dom-ready', 'console-message', 'devtools-opened', 'devtools-closed', 'devtools-focused', 'new-window', 'will-navigate', 'did-navigate', 'did-navigate-in-page', 'close', 'crashed', 'gpu-crashed', 'plugin-crashed', 'destroyed', 'page-title-updated', 'page-favicon-updated', 'enter-html-full-screen', 'leave-html-full-screen', 'media-started-playing', 'media-paused', 'found-in-page', 'did-change-theme-color'];
|
||||
var supportedWebViewEvents = ['load-commit', 'did-finish-load', 'did-fail-load', 'did-frame-finish-load', 'did-start-loading', 'did-stop-loading', 'did-get-response-details', 'did-get-redirect-request', 'dom-ready', 'console-message', 'devtools-opened', 'devtools-closed', 'devtools-focused', 'new-window', 'will-navigate', 'did-navigate', 'did-navigate-in-page', 'close', 'crashed', 'gpu-crashed', 'plugin-crashed', 'destroyed', 'page-title-updated', 'page-favicon-updated', 'enter-html-full-screen', 'leave-html-full-screen', 'media-started-playing', 'media-paused', 'found-in-page', 'did-change-theme-color'];
|
||||
|
||||
nextInstanceId = 0;
|
||||
|
||||
guestInstances = {};
|
||||
|
||||
embedderElementsMap = {};
|
||||
|
||||
reverseEmbedderElementsMap = {};
|
||||
var nextInstanceId = 0;
|
||||
var guestInstances = {};
|
||||
var embedderElementsMap = {};
|
||||
var reverseEmbedderElementsMap = {};
|
||||
|
||||
// Moves the last element of array to the first one.
|
||||
moveLastToFirst = function(list) {
|
||||
var moveLastToFirst = function(list) {
|
||||
return list.unshift(list.pop());
|
||||
};
|
||||
|
||||
// Generate guestInstanceId.
|
||||
getNextInstanceId = function(webContents) {
|
||||
var getNextInstanceId = function(webContents) {
|
||||
return ++nextInstanceId;
|
||||
};
|
||||
|
||||
// Create a new guest instance.
|
||||
createGuest = function(embedder, params) {
|
||||
var createGuest = function(embedder, params) {
|
||||
var destroy, destroyEvents, event, fn, guest, i, id, j, len, len1, listeners;
|
||||
if (webViewManager == null) {
|
||||
webViewManager = process.atomBinding('web_view_manager');
|
||||
|
@ -139,7 +136,7 @@ createGuest = function(embedder, params) {
|
|||
};
|
||||
|
||||
// Attach the guest to an element of embedder.
|
||||
attachGuest = function(embedder, elementInstanceId, guestInstanceId, params) {
|
||||
var attachGuest = function(embedder, elementInstanceId, guestInstanceId, params) {
|
||||
var guest, key, oldGuestInstanceId, ref1, webPreferences;
|
||||
guest = guestInstances[guestInstanceId].guest;
|
||||
|
||||
|
@ -173,7 +170,7 @@ attachGuest = function(embedder, elementInstanceId, guestInstanceId, params) {
|
|||
};
|
||||
|
||||
// Destroy an existing guest instance.
|
||||
destroyGuest = function(embedder, id) {
|
||||
var destroyGuest = function(embedder, id) {
|
||||
var key;
|
||||
webViewManager.removeGuest(embedder, id);
|
||||
guestInstances[id].guest.destroy();
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
var BrowserWindow, createGuest, frameToGuest, ipcMain, mergeBrowserWindowOptions, mergeOptions, ref, v8Util,
|
||||
hasProp = {}.hasOwnProperty,
|
||||
slice = [].slice;
|
||||
const ipcMain = require('electron').ipcMain;
|
||||
const BrowserWindow = require('electron').BrowserWindow;
|
||||
|
||||
ref = require('electron'), ipcMain = ref.ipcMain, BrowserWindow = ref.BrowserWindow;
|
||||
const v8Util = process.atomBinding('v8_util');
|
||||
|
||||
v8Util = process.atomBinding('v8_util');
|
||||
|
||||
frameToGuest = {};
|
||||
var hasProp = {}.hasOwnProperty;
|
||||
var slice = [].slice;
|
||||
var frameToGuest = {};
|
||||
|
||||
// Copy attribute of |parent| to |child| if it is not defined in |child|.
|
||||
mergeOptions = function(child, parent) {
|
||||
var mergeOptions = function(child, parent) {
|
||||
var key, value;
|
||||
for (key in parent) {
|
||||
if (!hasProp.call(parent, key)) continue;
|
||||
|
@ -26,7 +25,7 @@ mergeOptions = function(child, parent) {
|
|||
};
|
||||
|
||||
// Merge |options| with the |embedder|'s window's options.
|
||||
mergeBrowserWindowOptions = function(embedder, options) {
|
||||
var mergeBrowserWindowOptions = function(embedder, options) {
|
||||
if (embedder.browserWindowOptions != null) {
|
||||
|
||||
// Inherit the original options if it is a BrowserWindow.
|
||||
|
@ -43,7 +42,7 @@ mergeBrowserWindowOptions = function(embedder, options) {
|
|||
};
|
||||
|
||||
// Create a new guest created by |embedder| with |options|.
|
||||
createGuest = function(embedder, url, frameName, options) {
|
||||
var createGuest = function(embedder, url, frameName, options) {
|
||||
var closedByEmbedder, closedByUser, guest, guestId, ref1;
|
||||
guest = frameToGuest[frameName];
|
||||
if (frameName && (guest != null)) {
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
var Module, Readable, app, consoleLog, e, error1, fs, globalPaths, i, len, mainStartupScript, packageJson, packagePath, path, searchPaths, stdin, streamWrite, util,
|
||||
slice = [].slice;
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const util = require('util');
|
||||
const Module = require('module');
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
path = require('path');
|
||||
|
||||
util = require('util');
|
||||
|
||||
Module = require('module');
|
||||
var slice = [].slice;
|
||||
|
||||
// We modified the original process.argv to let node.js load the atom.js,
|
||||
// we need to restore it here.
|
||||
|
@ -19,7 +15,7 @@ require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths
|
|||
// Import common settings.
|
||||
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init'));
|
||||
|
||||
globalPaths = Module.globalPaths;
|
||||
var globalPaths = Module.globalPaths;
|
||||
|
||||
if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) {
|
||||
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib'));
|
||||
|
@ -31,12 +27,12 @@ globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib', 'exports'));
|
|||
if (process.platform === 'win32') {
|
||||
// Redirect node's console to use our own implementations, since node can not
|
||||
// handle console output when running as GUI program.
|
||||
consoleLog = function() {
|
||||
var consoleLog = function() {
|
||||
var args;
|
||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||
return process.log(util.format.apply(util, args) + "\n");
|
||||
};
|
||||
streamWrite = function(chunk, encoding, callback) {
|
||||
var streamWrite = function(chunk, encoding, callback) {
|
||||
if (Buffer.isBuffer(chunk)) {
|
||||
chunk = chunk.toString(encoding);
|
||||
}
|
||||
|
@ -50,8 +46,8 @@ if (process.platform === 'win32') {
|
|||
process.stdout.write = process.stderr.write = streamWrite;
|
||||
|
||||
// Always returns EOF for stdin stream.
|
||||
Readable = require('stream').Readable;
|
||||
stdin = new Readable;
|
||||
var Readable = require('stream').Readable;
|
||||
var stdin = new Readable;
|
||||
stdin.push(null);
|
||||
process.__defineGetter__('stdin', function() {
|
||||
return stdin;
|
||||
|
@ -75,7 +71,7 @@ process.on('uncaughtException', function(error) {
|
|||
});
|
||||
|
||||
// Emit 'exit' event on quit.
|
||||
app = require('electron').app;
|
||||
var app = require('electron').app;
|
||||
|
||||
app.on('quit', function(event, exitCode) {
|
||||
return process.emit('exit', exitCode);
|
||||
|
@ -92,20 +88,17 @@ require('./guest-view-manager');
|
|||
|
||||
require('./guest-window-manager');
|
||||
|
||||
|
||||
// Now we try to load app's package.json.
|
||||
packageJson = null;
|
||||
|
||||
searchPaths = ['app', 'app.asar', 'default_app'];
|
||||
|
||||
var packageJson = null;
|
||||
var searchPaths = ['app', 'app.asar', 'default_app'];
|
||||
var i, len, packagePath;
|
||||
for (i = 0, len = searchPaths.length; i < len; i++) {
|
||||
packagePath = searchPaths[i];
|
||||
try {
|
||||
packagePath = path.join(process.resourcesPath, packagePath);
|
||||
packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json')));
|
||||
break;
|
||||
} catch (error1) {
|
||||
e = error1;
|
||||
} catch (error) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +146,7 @@ require('./chrome-extension');
|
|||
require('./desktop-capturer');
|
||||
|
||||
// Set main startup script of the app.
|
||||
mainStartupScript = packageJson.main || 'index.js';
|
||||
var mainStartupScript = packageJson.main || 'index.js';
|
||||
|
||||
// Finally load app's main.js and transfer control to C++.
|
||||
Module._load(path.join(packagePath, mainStartupScript), Module, true);
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
var EventEmitter, ObjectsRegistry, v8Util,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const v8Util = process.atomBinding('v8_util');
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
var hasProp = {}.hasOwnProperty;
|
||||
|
||||
v8Util = process.atomBinding('v8_util');
|
||||
|
||||
ObjectsRegistry = (function(superClass) {
|
||||
var ObjectsRegistry = (function(superClass) {
|
||||
extend(ObjectsRegistry, superClass);
|
||||
|
||||
function ObjectsRegistry() {
|
||||
|
|
|
@ -1,20 +1,14 @@
|
|||
var IDWeakMap, callFunction, electron, exceptionToMeta, ipcMain, objectsRegistry, path, plainObjectToMeta, unwrapArgs, v8Util, valueToMeta,
|
||||
slice = [].slice;
|
||||
const path = require('path');
|
||||
const electron = require('electron');
|
||||
const ipcMain = electron.ipcMain;
|
||||
const objectsRegistry = require('./objects-registry');
|
||||
const v8Util = process.atomBinding('v8_util');
|
||||
const IDWeakMap = process.atomBinding('id_weak_map').IDWeakMap;
|
||||
|
||||
path = require('path');
|
||||
|
||||
electron = require('electron');
|
||||
|
||||
ipcMain = electron.ipcMain;
|
||||
|
||||
objectsRegistry = require('./objects-registry');
|
||||
|
||||
v8Util = process.atomBinding('v8_util');
|
||||
|
||||
IDWeakMap = process.atomBinding('id_weak_map').IDWeakMap;
|
||||
var slice = [].slice;
|
||||
|
||||
// Convert a real value into meta data.
|
||||
valueToMeta = function(sender, value, optimizeSimpleObject) {
|
||||
var valueToMeta = function(sender, value, optimizeSimpleObject) {
|
||||
var el, field, i, len, meta, name;
|
||||
if (optimizeSimpleObject == null) {
|
||||
optimizeSimpleObject = false;
|
||||
|
@ -97,7 +91,7 @@ valueToMeta = function(sender, value, optimizeSimpleObject) {
|
|||
};
|
||||
|
||||
// Convert object to meta by value.
|
||||
plainObjectToMeta = function(obj) {
|
||||
var plainObjectToMeta = function(obj) {
|
||||
return Object.getOwnPropertyNames(obj).map(function(name) {
|
||||
return {
|
||||
name: name,
|
||||
|
@ -107,7 +101,7 @@ plainObjectToMeta = function(obj) {
|
|||
};
|
||||
|
||||
// Convert Error into meta data.
|
||||
exceptionToMeta = function(error) {
|
||||
var exceptionToMeta = function(error) {
|
||||
return {
|
||||
type: 'exception',
|
||||
message: error.message,
|
||||
|
@ -116,7 +110,7 @@ exceptionToMeta = function(error) {
|
|||
};
|
||||
|
||||
// Convert array of meta data from renderer into array of real values.
|
||||
unwrapArgs = function(sender, args) {
|
||||
var unwrapArgs = function(sender, args) {
|
||||
var metaToValue;
|
||||
metaToValue = function(meta) {
|
||||
var i, len, member, ref, rendererReleased, ret, returnValue;
|
||||
|
@ -187,7 +181,7 @@ unwrapArgs = function(sender, args) {
|
|||
|
||||
// Call a function and send reply asynchronously if it's a an asynchronous
|
||||
// style function and the caller didn't pass a callback.
|
||||
callFunction = function(event, func, caller, args) {
|
||||
var callFunction = function(event, func, caller, args) {
|
||||
var e, error1, funcMarkedAsync, funcName, funcPassedCallback, ref, ret;
|
||||
funcMarkedAsync = v8Util.getHiddenValue(func, 'asynchronous');
|
||||
funcPassedCallback = typeof args[args.length - 1] === 'function';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue