Use const
This commit is contained in:
parent
3a0fb42737
commit
1779701445
10 changed files with 92 additions and 130 deletions
|
@ -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;
|
||||
for (i = 0, len = searchPaths.length; i < len; i++) {
|
||||
packagePath = searchPaths[i];
|
||||
var 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';
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
var CrashReporter, binding, crashRepoter, electron, fs, os, path, spawn;
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const spawn = require('child_process').spawn;
|
||||
const electron = require('electron');
|
||||
const binding = process.atomBinding('crash_reporter');
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
os = require('os');
|
||||
|
||||
path = require('path');
|
||||
|
||||
spawn = require('child_process').spawn;
|
||||
|
||||
electron = require('electron');
|
||||
|
||||
binding = process.atomBinding('crash_reporter');
|
||||
|
||||
CrashReporter = (function() {
|
||||
var CrashReporter = (function() {
|
||||
function CrashReporter() {}
|
||||
|
||||
CrashReporter.prototype.start = function(options) {
|
||||
|
@ -99,6 +92,4 @@ CrashReporter = (function() {
|
|||
|
||||
})();
|
||||
|
||||
crashRepoter = new CrashReporter;
|
||||
|
||||
module.exports = crashRepoter;
|
||||
module.exports = new CrashReporter;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Do not expose the internal modules to `require`.
|
||||
exports.hideInternalModules = function() {
|
||||
var globalPaths;
|
||||
globalPaths = require('module').globalPaths;
|
||||
var globalPaths = require('module').globalPaths;
|
||||
if (globalPaths.length === 3) {
|
||||
|
||||
// Remove the "common/api/lib" and "browser-or-renderer/api/lib".
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
var deprecate, nativeImage;
|
||||
|
||||
deprecate = require('electron').deprecate;
|
||||
|
||||
nativeImage = process.atomBinding('native_image');
|
||||
const deprecate = require('electron').deprecate;
|
||||
const nativeImage = process.atomBinding('native_image');
|
||||
|
||||
// Deprecated.
|
||||
deprecate.rename(nativeImage, 'createFromDataUrl', 'createFromDataURL');
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
(function () {
|
||||
var asar, asarStatsToFsStats, cachedArchives, child_process, fakeTime, getOrCreateArchive, gid, invalidArchiveError, nextInode, notDirError, notFoundError, overrideAPI, overrideAPISync, path, splitPath, uid, util,
|
||||
hasProp = {}.hasOwnProperty;
|
||||
const asar = process.binding('atom_common_asar');
|
||||
const child_process = require('child_process');
|
||||
const path = require('path');
|
||||
const util = require('util');
|
||||
|
||||
asar = process.binding('atom_common_asar');
|
||||
|
||||
child_process = require('child_process');
|
||||
|
||||
path = require('path');
|
||||
|
||||
util = require('util');
|
||||
var hasProp = {}.hasOwnProperty;
|
||||
|
||||
// Cache asar archive objects.
|
||||
cachedArchives = {};
|
||||
var cachedArchives = {};
|
||||
|
||||
getOrCreateArchive = function(p) {
|
||||
var getOrCreateArchive = function(p) {
|
||||
var archive;
|
||||
archive = cachedArchives[p];
|
||||
if (archive != null) {
|
||||
|
@ -39,13 +35,14 @@ process.on('exit', function() {
|
|||
});
|
||||
|
||||
// Separate asar package's path from full path.
|
||||
splitPath = function(p) {
|
||||
var splitPath = function(p) {
|
||||
var index;
|
||||
|
||||
// shortcut to disable asar.
|
||||
var index;
|
||||
if (process.noAsar) {
|
||||
return [false];
|
||||
}
|
||||
|
||||
if (typeof p !== 'string') {
|
||||
return [false];
|
||||
}
|
||||
|
@ -61,15 +58,15 @@ splitPath = function(p) {
|
|||
};
|
||||
|
||||
// Convert asar archive's Stats object to fs's Stats object.
|
||||
nextInode = 0;
|
||||
var nextInode = 0;
|
||||
|
||||
uid = process.getuid != null ? process.getuid() : 0;
|
||||
var uid = process.getuid != null ? process.getuid() : 0;
|
||||
|
||||
gid = process.getgid != null ? process.getgid() : 0;
|
||||
var gid = process.getgid != null ? process.getgid() : 0;
|
||||
|
||||
fakeTime = new Date();
|
||||
var fakeTime = new Date();
|
||||
|
||||
asarStatsToFsStats = function(stats) {
|
||||
var asarStatsToFsStats = function(stats) {
|
||||
return {
|
||||
dev: 1,
|
||||
ino: ++nextInode,
|
||||
|
@ -108,7 +105,7 @@ asarStatsToFsStats = function(stats) {
|
|||
};
|
||||
|
||||
// Create a ENOENT error.
|
||||
notFoundError = function(asarPath, filePath, callback) {
|
||||
var notFoundError = function(asarPath, filePath, callback) {
|
||||
var error;
|
||||
error = new Error("ENOENT, " + filePath + " not found in " + asarPath);
|
||||
error.code = "ENOENT";
|
||||
|
@ -122,7 +119,7 @@ notFoundError = function(asarPath, filePath, callback) {
|
|||
};
|
||||
|
||||
// Create a ENOTDIR error.
|
||||
notDirError = function(callback) {
|
||||
var notDirError = function(callback) {
|
||||
var error;
|
||||
error = new Error('ENOTDIR, not a directory');
|
||||
error.code = 'ENOTDIR';
|
||||
|
@ -136,7 +133,7 @@ notDirError = function(callback) {
|
|||
};
|
||||
|
||||
// Create invalid archive error.
|
||||
invalidArchiveError = function(asarPath, callback) {
|
||||
var invalidArchiveError = function(asarPath, callback) {
|
||||
var error;
|
||||
error = new Error("Invalid package " + asarPath);
|
||||
if (typeof callback !== 'function') {
|
||||
|
@ -148,7 +145,7 @@ invalidArchiveError = function(asarPath, callback) {
|
|||
};
|
||||
|
||||
// Override APIs that rely on passing file path instead of content to C++.
|
||||
overrideAPISync = function(module, name, arg) {
|
||||
var overrideAPISync = function(module, name, arg) {
|
||||
var old;
|
||||
if (arg == null) {
|
||||
arg = 0;
|
||||
|
@ -174,7 +171,7 @@ overrideAPISync = function(module, name, arg) {
|
|||
};
|
||||
};
|
||||
|
||||
overrideAPI = function(module, name, arg) {
|
||||
var overrideAPI = function(module, name, arg) {
|
||||
var old;
|
||||
if (arg == null) {
|
||||
arg = 0;
|
||||
|
|
Loading…
Reference in a new issue