Use destructuring assigment
This commit is contained in:
parent
baa566adae
commit
4f4dc2f4d8
3 changed files with 40 additions and 48 deletions
|
@ -9,7 +9,6 @@ const Menu = require('electron').Menu;
|
||||||
const binding = process.atomBinding('web_contents');
|
const binding = process.atomBinding('web_contents');
|
||||||
const debuggerBinding = process.atomBinding('debugger');
|
const debuggerBinding = process.atomBinding('debugger');
|
||||||
|
|
||||||
let slice = [].slice;
|
|
||||||
let nextId = 0;
|
let nextId = 0;
|
||||||
|
|
||||||
let getNextId = function() {
|
let getNextId = function() {
|
||||||
|
@ -126,19 +125,17 @@ let wrapWebContents = function(webContents) {
|
||||||
|
|
||||||
// Dispatch IPC messages to the ipc module.
|
// Dispatch IPC messages to the ipc module.
|
||||||
webContents.on('ipc-message', function(event, packed) {
|
webContents.on('ipc-message', function(event, packed) {
|
||||||
var args, channel;
|
const [channel, ...args] = packed;
|
||||||
channel = packed[0], args = 2 <= packed.length ? slice.call(packed, 1) : [];
|
return ipcMain.emit.apply(ipcMain, [channel, event].concat(args));
|
||||||
return ipcMain.emit.apply(ipcMain, [channel, event].concat(slice.call(args)));
|
|
||||||
});
|
});
|
||||||
webContents.on('ipc-message-sync', function(event, packed) {
|
webContents.on('ipc-message-sync', function(event, packed) {
|
||||||
var args, channel;
|
const [channel, ...args] = packed;
|
||||||
channel = packed[0], args = 2 <= packed.length ? slice.call(packed, 1) : [];
|
|
||||||
Object.defineProperty(event, 'returnValue', {
|
Object.defineProperty(event, 'returnValue', {
|
||||||
set: function(value) {
|
set: function(value) {
|
||||||
return event.sendReply(JSON.stringify(value));
|
return event.sendReply(JSON.stringify(value));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return ipcMain.emit.apply(ipcMain, [channel, event].concat(slice.call(args)));
|
return ipcMain.emit.apply(ipcMain, [channel, event].concat(args));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle context menu action request from pepper plugin.
|
// Handle context menu action request from pepper plugin.
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
const ipcMain = require('electron').ipcMain;
|
const ipcMain = require('electron').ipcMain;
|
||||||
const webContents = require('electron').webContents;
|
const webContents = require('electron').webContents;
|
||||||
|
|
||||||
var slice = [].slice;
|
|
||||||
|
|
||||||
// Doesn't exist in early initialization.
|
// Doesn't exist in early initialization.
|
||||||
var webViewManager = null;
|
var webViewManager = null;
|
||||||
|
|
||||||
|
@ -149,9 +147,8 @@ var createGuest = function(embedder, params) {
|
||||||
|
|
||||||
// Dispatch guest's IPC messages to embedder.
|
// Dispatch guest's IPC messages to embedder.
|
||||||
guest.on('ipc-message-host', function(_, packed) {
|
guest.on('ipc-message-host', function(_, packed) {
|
||||||
var args, channel;
|
const [channel, ...args] = packed;
|
||||||
channel = packed[0], args = 2 <= packed.length ? slice.call(packed, 1) : [];
|
return embedder.send.apply(embedder, ["ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-" + guest.viewInstanceId, channel].concat(args));
|
||||||
return embedder.send.apply(embedder, ["ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-" + guest.viewInstanceId, channel].concat(slice.call(args)));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Autosize.
|
// Autosize.
|
||||||
|
|
|
@ -150,9 +150,9 @@
|
||||||
}
|
}
|
||||||
old = module[name];
|
old = module[name];
|
||||||
return module[name] = function() {
|
return module[name] = function() {
|
||||||
var archive, asarPath, filePath, isAsar, newPath, p, ref;
|
var archive, newPath, p;
|
||||||
p = arguments[arg];
|
p = arguments[arg];
|
||||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||||
if (!isAsar) {
|
if (!isAsar) {
|
||||||
return old.apply(this, arguments);
|
return old.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
@ -176,9 +176,9 @@
|
||||||
}
|
}
|
||||||
old = module[name];
|
old = module[name];
|
||||||
return module[name] = function() {
|
return module[name] = function() {
|
||||||
var archive, asarPath, callback, filePath, isAsar, newPath, p, ref;
|
var archive, callback, newPath, p;
|
||||||
p = arguments[arg];
|
p = arguments[arg];
|
||||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||||
if (!isAsar) {
|
if (!isAsar) {
|
||||||
return old.apply(this, arguments);
|
return old.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
@ -221,8 +221,8 @@
|
||||||
|
|
||||||
lstatSync = fs.lstatSync;
|
lstatSync = fs.lstatSync;
|
||||||
fs.lstatSync = function(p) {
|
fs.lstatSync = function(p) {
|
||||||
var archive, asarPath, filePath, isAsar, ref, stats;
|
var archive, stats;
|
||||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||||
if (!isAsar) {
|
if (!isAsar) {
|
||||||
return lstatSync(p);
|
return lstatSync(p);
|
||||||
}
|
}
|
||||||
|
@ -238,8 +238,8 @@
|
||||||
};
|
};
|
||||||
lstat = fs.lstat;
|
lstat = fs.lstat;
|
||||||
fs.lstat = function(p, callback) {
|
fs.lstat = function(p, callback) {
|
||||||
var archive, asarPath, filePath, isAsar, ref, stats;
|
var archive, stats;
|
||||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||||
if (!isAsar) {
|
if (!isAsar) {
|
||||||
return lstat(p, callback);
|
return lstat(p, callback);
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@
|
||||||
};
|
};
|
||||||
statSync = fs.statSync;
|
statSync = fs.statSync;
|
||||||
fs.statSync = function(p) {
|
fs.statSync = function(p) {
|
||||||
var isAsar = splitPath(p)[0];
|
const [isAsar] = splitPath(p);
|
||||||
if (!isAsar) {
|
if (!isAsar) {
|
||||||
return statSync(p);
|
return statSync(p);
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@
|
||||||
};
|
};
|
||||||
stat = fs.stat;
|
stat = fs.stat;
|
||||||
fs.stat = function(p, callback) {
|
fs.stat = function(p, callback) {
|
||||||
var isAsar = splitPath(p)[0];
|
const [isAsar] = splitPath(p);
|
||||||
if (!isAsar) {
|
if (!isAsar) {
|
||||||
return stat(p, callback);
|
return stat(p, callback);
|
||||||
}
|
}
|
||||||
|
@ -279,8 +279,8 @@
|
||||||
};
|
};
|
||||||
statSyncNoException = fs.statSyncNoException;
|
statSyncNoException = fs.statSyncNoException;
|
||||||
fs.statSyncNoException = function(p) {
|
fs.statSyncNoException = function(p) {
|
||||||
var archive, asarPath, filePath, isAsar, ref, stats;
|
var archive, stats;
|
||||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||||
if (!isAsar) {
|
if (!isAsar) {
|
||||||
return statSyncNoException(p);
|
return statSyncNoException(p);
|
||||||
}
|
}
|
||||||
|
@ -296,8 +296,8 @@
|
||||||
};
|
};
|
||||||
realpathSync = fs.realpathSync;
|
realpathSync = fs.realpathSync;
|
||||||
fs.realpathSync = function(p) {
|
fs.realpathSync = function(p) {
|
||||||
var archive, asarPath, filePath, isAsar, real, ref;
|
var archive, real;
|
||||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||||
if (!isAsar) {
|
if (!isAsar) {
|
||||||
return realpathSync.apply(this, arguments);
|
return realpathSync.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
@ -313,8 +313,8 @@
|
||||||
};
|
};
|
||||||
realpath = fs.realpath;
|
realpath = fs.realpath;
|
||||||
fs.realpath = function(p, cache, callback) {
|
fs.realpath = function(p, cache, callback) {
|
||||||
var archive, asarPath, filePath, isAsar, real, ref;
|
var archive, real;
|
||||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||||
if (!isAsar) {
|
if (!isAsar) {
|
||||||
return realpath.apply(this, arguments);
|
return realpath.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
@ -339,8 +339,8 @@
|
||||||
};
|
};
|
||||||
exists = fs.exists;
|
exists = fs.exists;
|
||||||
fs.exists = function(p, callback) {
|
fs.exists = function(p, callback) {
|
||||||
var archive, asarPath, filePath, isAsar, ref;
|
var archive;
|
||||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||||
if (!isAsar) {
|
if (!isAsar) {
|
||||||
return exists(p, callback);
|
return exists(p, callback);
|
||||||
}
|
}
|
||||||
|
@ -354,8 +354,8 @@
|
||||||
};
|
};
|
||||||
existsSync = fs.existsSync;
|
existsSync = fs.existsSync;
|
||||||
fs.existsSync = function(p) {
|
fs.existsSync = function(p) {
|
||||||
var archive, asarPath, filePath, isAsar, ref;
|
var archive;
|
||||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||||
if (!isAsar) {
|
if (!isAsar) {
|
||||||
return existsSync(p);
|
return existsSync(p);
|
||||||
}
|
}
|
||||||
|
@ -367,8 +367,8 @@
|
||||||
};
|
};
|
||||||
readFile = fs.readFile;
|
readFile = fs.readFile;
|
||||||
fs.readFile = function(p, options, callback) {
|
fs.readFile = function(p, options, callback) {
|
||||||
var archive, asarPath, buffer, encoding, fd, filePath, info, isAsar, realPath, ref;
|
var archive, buffer, encoding, fd, info, realPath;
|
||||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||||
if (!isAsar) {
|
if (!isAsar) {
|
||||||
return readFile.apply(this, arguments);
|
return readFile.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
@ -418,9 +418,9 @@
|
||||||
readFileSync = fs.readFileSync;
|
readFileSync = fs.readFileSync;
|
||||||
fs.readFileSync = function(p, opts) {
|
fs.readFileSync = function(p, opts) {
|
||||||
// this allows v8 to optimize this function
|
// this allows v8 to optimize this function
|
||||||
var archive, asarPath, buffer, encoding, fd, filePath, info, isAsar, options, realPath, ref;
|
var archive, buffer, encoding, fd, info, options, realPath;
|
||||||
options = opts;
|
options = opts;
|
||||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||||
if (!isAsar) {
|
if (!isAsar) {
|
||||||
return readFileSync.apply(this, arguments);
|
return readFileSync.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
@ -470,8 +470,8 @@
|
||||||
};
|
};
|
||||||
readdir = fs.readdir;
|
readdir = fs.readdir;
|
||||||
fs.readdir = function(p, callback) {
|
fs.readdir = function(p, callback) {
|
||||||
var archive, asarPath, filePath, files, isAsar, ref;
|
var archive, files;
|
||||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||||
if (!isAsar) {
|
if (!isAsar) {
|
||||||
return readdir.apply(this, arguments);
|
return readdir.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
@ -489,8 +489,8 @@
|
||||||
};
|
};
|
||||||
readdirSync = fs.readdirSync;
|
readdirSync = fs.readdirSync;
|
||||||
fs.readdirSync = function(p) {
|
fs.readdirSync = function(p) {
|
||||||
var archive, asarPath, filePath, files, isAsar, ref;
|
var archive, files;
|
||||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||||
if (!isAsar) {
|
if (!isAsar) {
|
||||||
return readdirSync.apply(this, arguments);
|
return readdirSync.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
@ -506,8 +506,8 @@
|
||||||
};
|
};
|
||||||
internalModuleReadFile = process.binding('fs').internalModuleReadFile;
|
internalModuleReadFile = process.binding('fs').internalModuleReadFile;
|
||||||
process.binding('fs').internalModuleReadFile = function(p) {
|
process.binding('fs').internalModuleReadFile = function(p) {
|
||||||
var archive, asarPath, buffer, fd, filePath, info, isAsar, realPath, ref;
|
var archive, buffer, fd, info, realPath;
|
||||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||||
if (!isAsar) {
|
if (!isAsar) {
|
||||||
return internalModuleReadFile(p);
|
return internalModuleReadFile(p);
|
||||||
}
|
}
|
||||||
|
@ -539,8 +539,8 @@
|
||||||
};
|
};
|
||||||
internalModuleStat = process.binding('fs').internalModuleStat;
|
internalModuleStat = process.binding('fs').internalModuleStat;
|
||||||
process.binding('fs').internalModuleStat = function(p) {
|
process.binding('fs').internalModuleStat = function(p) {
|
||||||
var archive, asarPath, filePath, isAsar, ref, stats;
|
var archive, stats;
|
||||||
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
|
const [isAsar, asarPath, filePath] = splitPath(p);
|
||||||
if (!isAsar) {
|
if (!isAsar) {
|
||||||
return internalModuleStat(p);
|
return internalModuleStat(p);
|
||||||
}
|
}
|
||||||
|
@ -570,11 +570,10 @@
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
mkdir = fs.mkdir;
|
mkdir = fs.mkdir;
|
||||||
fs.mkdir = function(p, mode, callback) {
|
fs.mkdir = function(p, mode, callback) {
|
||||||
var filePath, isAsar, ref;
|
|
||||||
if (typeof mode === 'function') {
|
if (typeof mode === 'function') {
|
||||||
callback = mode;
|
callback = mode;
|
||||||
}
|
}
|
||||||
ref = splitPath(p), isAsar = ref[0], filePath = ref[2];
|
const [isAsar, , filePath] = splitPath(p);
|
||||||
if (isAsar && filePath.length) {
|
if (isAsar && filePath.length) {
|
||||||
return notDirError(callback);
|
return notDirError(callback);
|
||||||
}
|
}
|
||||||
|
@ -582,8 +581,7 @@
|
||||||
};
|
};
|
||||||
mkdirSync = fs.mkdirSync;
|
mkdirSync = fs.mkdirSync;
|
||||||
fs.mkdirSync = function(p, mode) {
|
fs.mkdirSync = function(p, mode) {
|
||||||
var filePath, isAsar, ref;
|
const [isAsar, , filePath] = splitPath(p);
|
||||||
ref = splitPath(p), isAsar = ref[0], filePath = ref[2];
|
|
||||||
if (isAsar && filePath.length) {
|
if (isAsar && filePath.length) {
|
||||||
notDirError();
|
notDirError();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue