Use rest parameters
This commit is contained in:
parent
e05804848f
commit
8889c29866
14 changed files with 88 additions and 143 deletions
|
@ -9,8 +9,6 @@ const bindings = process.atomBinding('app');
|
|||
const downloadItemBindings = process.atomBinding('download_item');
|
||||
const app = bindings.app;
|
||||
|
||||
var slice = [].slice;
|
||||
|
||||
app.__proto__ = EventEmitter.prototype;
|
||||
|
||||
app.setApplicationMenu = function(menu) {
|
||||
|
@ -57,10 +55,8 @@ app.getAppPath = function() {
|
|||
// Routes the events to webContents.
|
||||
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)));
|
||||
return app.on(name, function(event, webContents, ...args) {
|
||||
return webContents.emit.apply(webContents, [name, event].concat(args));
|
||||
});
|
||||
};
|
||||
var i, len;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
const app = require('electron').app;
|
||||
const BrowserWindow = require('electron').BrowserWindow;
|
||||
const binding = process.atomBinding('dialog');
|
||||
const v8Util = process.atomBinding('v8_util');
|
||||
|
||||
var slice = [].slice;
|
||||
var includes = [].includes;
|
||||
|
||||
var fileDialogProperties = {
|
||||
|
@ -41,9 +42,8 @@ var checkAppInitialized = function() {
|
|||
};
|
||||
|
||||
module.exports = {
|
||||
showOpenDialog: function() {
|
||||
var args, callback, options, prop, properties, ref1, value, window, wrappedCallback;
|
||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||
showOpenDialog: function(...args) {
|
||||
var callback, options, prop, properties, ref1, value, window, wrappedCallback;
|
||||
checkAppInitialized();
|
||||
ref1 = parseArgs.apply(null, args), window = ref1[0], options = ref1[1], callback = ref1[2];
|
||||
if (options == null) {
|
||||
|
@ -79,9 +79,9 @@ module.exports = {
|
|||
} : null;
|
||||
return binding.showOpenDialog(String(options.title), String(options.defaultPath), options.filters, properties, window, wrappedCallback);
|
||||
},
|
||||
showSaveDialog: function() {
|
||||
var args, callback, options, ref1, window, wrappedCallback;
|
||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||
|
||||
showSaveDialog: function(...args) {
|
||||
var callback, options, ref1, window, wrappedCallback;
|
||||
checkAppInitialized();
|
||||
ref1 = parseArgs.apply(null, args), window = ref1[0], options = ref1[1], callback = ref1[2];
|
||||
if (options == null) {
|
||||
|
@ -103,9 +103,9 @@ module.exports = {
|
|||
} : null;
|
||||
return binding.showSaveDialog(String(options.title), String(options.defaultPath), options.filters, window, wrappedCallback);
|
||||
},
|
||||
showMessageBox: function() {
|
||||
var args, callback, flags, i, j, len, messageBoxType, options, ref1, ref2, ref3, text, window;
|
||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||
|
||||
showMessageBox: function(...args) {
|
||||
var callback, flags, i, j, len, messageBoxType, options, ref1, ref2, ref3, text, window;
|
||||
checkAppInitialized();
|
||||
ref1 = parseArgs.apply(null, args), window = ref1[0], options = ref1[1], callback = ref1[2];
|
||||
if (options == null) {
|
||||
|
@ -154,9 +154,8 @@ module.exports = {
|
|||
flags = options.noLink ? messageBoxOptions.noLink : 0;
|
||||
return binding.showMessageBox(messageBoxType, options.buttons, options.defaultId, options.cancelId, flags, options.title, options.message, options.detail, options.icon, window, callback);
|
||||
},
|
||||
showErrorBox: function() {
|
||||
var args;
|
||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||
|
||||
showErrorBox: function(...args) {
|
||||
return binding.showErrorBox.apply(binding, args);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2,18 +2,14 @@
|
|||
|
||||
const ipcMain = require('electron').ipcMain;
|
||||
|
||||
var slice = [].slice;
|
||||
|
||||
// The history operation in renderer is redirected to browser.
|
||||
ipcMain.on('ATOM_SHELL_NAVIGATION_CONTROLLER', function() {
|
||||
var args, event, method, ref;
|
||||
event = arguments[0], method = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
|
||||
ipcMain.on('ATOM_SHELL_NAVIGATION_CONTROLLER', function(event, method, ...args) {
|
||||
var ref;
|
||||
return (ref = event.sender)[method].apply(ref, args);
|
||||
});
|
||||
|
||||
ipcMain.on('ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER', function() {
|
||||
var args, event, method, ref;
|
||||
event = arguments[0], method = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
|
||||
ipcMain.on('ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER', function(event, method, ...args) {
|
||||
var ref;
|
||||
return event.returnValue = (ref = event.sender)[method].apply(ref, args);
|
||||
});
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ const Menu = require('electron').Menu;
|
|||
const binding = process.atomBinding('web_contents');
|
||||
const debuggerBinding = process.atomBinding('debugger');
|
||||
|
||||
let slice = [].slice;
|
||||
let slice = [].slice;
|
||||
let nextId = 0;
|
||||
|
||||
let getNextId = function() {
|
||||
|
@ -74,13 +74,11 @@ let wrapWebContents = function(webContents) {
|
|||
webContents.setMaxListeners(0);
|
||||
|
||||
// WebContents::send(channel, args..)
|
||||
webContents.send = function() {
|
||||
var args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
||||
var channel = arguments[0];
|
||||
webContents.send = function(channel, ...args) {
|
||||
if (channel == null) {
|
||||
throw new Error('Missing required channel argument');
|
||||
}
|
||||
return this._send(channel, slice.call(args));
|
||||
return this._send(channel, args);
|
||||
};
|
||||
|
||||
// The navigation controller.
|
||||
|
@ -99,8 +97,7 @@ let wrapWebContents = function(webContents) {
|
|||
|
||||
// Mapping webFrame methods.
|
||||
for (let method of webFrameMethods) {
|
||||
webContents[method] = function() {
|
||||
let args = Array.prototype.slice.call(arguments);
|
||||
webContents[method] = function(...args) {
|
||||
this.send('ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', method, args);
|
||||
};
|
||||
}
|
||||
|
@ -152,30 +149,26 @@ let wrapWebContents = function(webContents) {
|
|||
});
|
||||
|
||||
// This error occurs when host could not be found.
|
||||
webContents.on('did-fail-provisional-load', function() {
|
||||
var args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||
|
||||
webContents.on('did-fail-provisional-load', function(...args) {
|
||||
// Calling loadURL during this event might cause crash, so delay the event
|
||||
// until next tick.
|
||||
setImmediate(() => {
|
||||
this.emit.apply(this, ['did-fail-load'].concat(slice.call(args)));
|
||||
this.emit.apply(this, ['did-fail-load'].concat(args));
|
||||
});
|
||||
});
|
||||
|
||||
// Delays the page-title-updated event to next tick.
|
||||
webContents.on('-page-title-updated', function() {
|
||||
var args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||
webContents.on('-page-title-updated', function(...args) {
|
||||
setImmediate(() => {
|
||||
this.emit.apply(this, ['page-title-updated'].concat(slice.call(args)));
|
||||
this.emit.apply(this, ['page-title-updated'].concat(args));
|
||||
});
|
||||
});
|
||||
|
||||
// Deprecated.
|
||||
deprecate.rename(webContents, 'loadUrl', 'loadURL');
|
||||
deprecate.rename(webContents, 'getUrl', 'getURL');
|
||||
deprecate.event(webContents, 'page-title-set', 'page-title-updated', function() {
|
||||
var args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||
return this.emit.apply(this, ['page-title-set'].concat(slice.call(args)));
|
||||
deprecate.event(webContents, 'page-title-set', 'page-title-updated', function(...args) {
|
||||
return this.emit.apply(this, ['page-title-set'].concat(args));
|
||||
});
|
||||
return webContents.printToPDF = function(options, callback) {
|
||||
var printingSetting;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
const ipcMain = require('electron').ipcMain;
|
||||
const webContents = require('electron').webContents;
|
||||
|
||||
|
@ -136,9 +138,8 @@ var createGuest = function(embedder, params) {
|
|||
|
||||
// Dispatch events to embedder.
|
||||
fn = function(event) {
|
||||
return guest.on(event, function() {
|
||||
var args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
||||
return embedder.send.apply(embedder, ["ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-" + guest.viewInstanceId, event].concat(slice.call(args)));
|
||||
return guest.on(event, function(_, ...args) {
|
||||
return embedder.send.apply(embedder, ["ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-" + guest.viewInstanceId, event].concat(args));
|
||||
});
|
||||
};
|
||||
for (j = 0, len1 = supportedWebViewEvents.length; j < len1; j++) {
|
||||
|
@ -154,9 +155,8 @@ var createGuest = function(embedder, params) {
|
|||
});
|
||||
|
||||
// Autosize.
|
||||
guest.on('size-changed', function() {
|
||||
var args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
||||
return embedder.send.apply(embedder, ["ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-" + guest.viewInstanceId].concat(slice.call(args)));
|
||||
guest.on('size-changed', function(_, ...args) {
|
||||
return embedder.send.apply(embedder, ["ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-" + guest.viewInstanceId].concat(args));
|
||||
});
|
||||
return id;
|
||||
};
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
const ipcMain = require('electron').ipcMain;
|
||||
const BrowserWindow = require('electron').BrowserWindow;
|
||||
|
||||
var hasProp = {}.hasOwnProperty;
|
||||
var slice = [].slice;
|
||||
var frameToGuest = {};
|
||||
|
||||
// Copy attribute of |parent| to |child| if it is not defined in |child|.
|
||||
|
@ -81,9 +82,8 @@ var createGuest = function(embedder, url, frameName, options) {
|
|||
};
|
||||
|
||||
// Routed window.open messages.
|
||||
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', function() {
|
||||
var args, event, frameName, options, url;
|
||||
event = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
||||
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', function(event, ...args) {
|
||||
var frameName, options, url;
|
||||
url = args[0], frameName = args[1], options = args[2];
|
||||
options = mergeBrowserWindowOptions(event.sender, options);
|
||||
event.sender.emit('new-window', event, url, frameName, 'new-window', options);
|
||||
|
@ -99,9 +99,8 @@ ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', function(event, guest
|
|||
return (ref1 = BrowserWindow.fromId(guestId)) != null ? ref1.destroy() : void 0;
|
||||
});
|
||||
|
||||
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', function() {
|
||||
var args, guestId, method, ref1;
|
||||
event = arguments[0], guestId = arguments[1], method = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : [];
|
||||
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', function(event, guestId, method, ...args) {
|
||||
var ref1;
|
||||
return event.returnValue = (ref1 = BrowserWindow.fromId(guestId)) != null ? ref1[method].apply(ref1, args) : void 0;
|
||||
});
|
||||
|
||||
|
@ -117,8 +116,7 @@ ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', function(event,
|
|||
}
|
||||
});
|
||||
|
||||
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', function() {
|
||||
var args, guestId, method, ref1, ref2;
|
||||
guestId = arguments[1], method = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : [];
|
||||
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', function(event, guestId, method, ...args) {
|
||||
var ref1, ref2;
|
||||
return (ref1 = BrowserWindow.fromId(guestId)) != null ? (ref2 = ref1.webContents) != null ? ref2[method].apply(ref2, args) : void 0 : void 0;
|
||||
});
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const util = require('util');
|
||||
const Module = require('module');
|
||||
const v8 = require('v8');
|
||||
|
||||
var slice = [].slice;
|
||||
|
||||
// We modified the original process.argv to let node.js load the atom.js,
|
||||
// we need to restore it here.
|
||||
process.argv.splice(1, 1);
|
||||
|
@ -28,9 +28,7 @@ globalPaths.push(path.join(__dirname, 'api', '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.
|
||||
var consoleLog = function() {
|
||||
var args;
|
||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||
var consoleLog = function(...args) {
|
||||
return process.log(util.format.apply(util, args) + "\n");
|
||||
};
|
||||
var streamWrite = function(chunk, encoding, callback) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue