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;
|
var deepEqual = function(opt1, opt2) {
|
||||||
|
|
||||||
desktopCapturer = process.atomBinding('desktop_capturer').desktopCapturer;
|
|
||||||
|
|
||||||
deepEqual = function(opt1, opt2) {
|
|
||||||
return JSON.stringify(opt1) === JSON.stringify(opt2);
|
return JSON.stringify(opt1) === JSON.stringify(opt2);
|
||||||
};
|
};
|
||||||
|
|
||||||
// A queue for holding all requests from renderer process.
|
// 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) {
|
ipcMain.on('ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', function(event, captureWindow, captureScreen, thumbnailSize, id) {
|
||||||
var request;
|
var request;
|
||||||
|
|
|
@ -1,33 +1,30 @@
|
||||||
var attachGuest, createGuest, destroyGuest, embedderElementsMap, getNextInstanceId, guestInstances, ipcMain, moveLastToFirst, nextInstanceId, ref, reverseEmbedderElementsMap, supportedWebViewEvents, webContents, webViewManager,
|
const ipcMain = require('electron').ipcMain;
|
||||||
slice = [].slice;
|
const webContents = require('electron').webContents;
|
||||||
|
|
||||||
ref = require('electron'), ipcMain = ref.ipcMain, webContents = ref.webContents;
|
var slice = [].slice;
|
||||||
|
|
||||||
// Doesn't exist in early initialization.
|
// 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;
|
var nextInstanceId = 0;
|
||||||
|
var guestInstances = {};
|
||||||
guestInstances = {};
|
var embedderElementsMap = {};
|
||||||
|
var reverseEmbedderElementsMap = {};
|
||||||
embedderElementsMap = {};
|
|
||||||
|
|
||||||
reverseEmbedderElementsMap = {};
|
|
||||||
|
|
||||||
// Moves the last element of array to the first one.
|
// Moves the last element of array to the first one.
|
||||||
moveLastToFirst = function(list) {
|
var moveLastToFirst = function(list) {
|
||||||
return list.unshift(list.pop());
|
return list.unshift(list.pop());
|
||||||
};
|
};
|
||||||
|
|
||||||
// Generate guestInstanceId.
|
// Generate guestInstanceId.
|
||||||
getNextInstanceId = function(webContents) {
|
var getNextInstanceId = function(webContents) {
|
||||||
return ++nextInstanceId;
|
return ++nextInstanceId;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create a new guest instance.
|
// 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;
|
var destroy, destroyEvents, event, fn, guest, i, id, j, len, len1, listeners;
|
||||||
if (webViewManager == null) {
|
if (webViewManager == null) {
|
||||||
webViewManager = process.atomBinding('web_view_manager');
|
webViewManager = process.atomBinding('web_view_manager');
|
||||||
|
@ -139,7 +136,7 @@ createGuest = function(embedder, params) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Attach the guest to an element of embedder.
|
// 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;
|
var guest, key, oldGuestInstanceId, ref1, webPreferences;
|
||||||
guest = guestInstances[guestInstanceId].guest;
|
guest = guestInstances[guestInstanceId].guest;
|
||||||
|
|
||||||
|
@ -173,7 +170,7 @@ attachGuest = function(embedder, elementInstanceId, guestInstanceId, params) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Destroy an existing guest instance.
|
// Destroy an existing guest instance.
|
||||||
destroyGuest = function(embedder, id) {
|
var destroyGuest = function(embedder, id) {
|
||||||
var key;
|
var key;
|
||||||
webViewManager.removeGuest(embedder, id);
|
webViewManager.removeGuest(embedder, id);
|
||||||
guestInstances[id].guest.destroy();
|
guestInstances[id].guest.destroy();
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
var BrowserWindow, createGuest, frameToGuest, ipcMain, mergeBrowserWindowOptions, mergeOptions, ref, v8Util,
|
const ipcMain = require('electron').ipcMain;
|
||||||
hasProp = {}.hasOwnProperty,
|
const BrowserWindow = require('electron').BrowserWindow;
|
||||||
slice = [].slice;
|
|
||||||
|
|
||||||
ref = require('electron'), ipcMain = ref.ipcMain, BrowserWindow = ref.BrowserWindow;
|
const v8Util = process.atomBinding('v8_util');
|
||||||
|
|
||||||
v8Util = process.atomBinding('v8_util');
|
var hasProp = {}.hasOwnProperty;
|
||||||
|
var slice = [].slice;
|
||||||
frameToGuest = {};
|
var frameToGuest = {};
|
||||||
|
|
||||||
// Copy attribute of |parent| to |child| if it is not defined in |child|.
|
// 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;
|
var key, value;
|
||||||
for (key in parent) {
|
for (key in parent) {
|
||||||
if (!hasProp.call(parent, key)) continue;
|
if (!hasProp.call(parent, key)) continue;
|
||||||
|
@ -26,7 +25,7 @@ mergeOptions = function(child, parent) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Merge |options| with the |embedder|'s window's options.
|
// Merge |options| with the |embedder|'s window's options.
|
||||||
mergeBrowserWindowOptions = function(embedder, options) {
|
var mergeBrowserWindowOptions = function(embedder, options) {
|
||||||
if (embedder.browserWindowOptions != null) {
|
if (embedder.browserWindowOptions != null) {
|
||||||
|
|
||||||
// Inherit the original options if it is a BrowserWindow.
|
// 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|.
|
// 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;
|
var closedByEmbedder, closedByUser, guest, guestId, ref1;
|
||||||
guest = frameToGuest[frameName];
|
guest = frameToGuest[frameName];
|
||||||
if (frameName && (guest != null)) {
|
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,
|
const fs = require('fs');
|
||||||
slice = [].slice;
|
const path = require('path');
|
||||||
|
const util = require('util');
|
||||||
|
const Module = require('module');
|
||||||
|
|
||||||
fs = require('fs');
|
var slice = [].slice;
|
||||||
|
|
||||||
path = require('path');
|
|
||||||
|
|
||||||
util = require('util');
|
|
||||||
|
|
||||||
Module = require('module');
|
|
||||||
|
|
||||||
// We modified the original process.argv to let node.js load the atom.js,
|
// We modified the original process.argv to let node.js load the atom.js,
|
||||||
// we need to restore it here.
|
// we need to restore it here.
|
||||||
|
@ -19,7 +15,7 @@ require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths
|
||||||
// Import common settings.
|
// Import common settings.
|
||||||
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init'));
|
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init'));
|
||||||
|
|
||||||
globalPaths = Module.globalPaths;
|
var globalPaths = Module.globalPaths;
|
||||||
|
|
||||||
if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) {
|
if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) {
|
||||||
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib'));
|
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib'));
|
||||||
|
@ -31,12 +27,12 @@ globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib', 'exports'));
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
// Redirect node's console to use our own implementations, since node can not
|
// Redirect node's console to use our own implementations, since node can not
|
||||||
// handle console output when running as GUI program.
|
// handle console output when running as GUI program.
|
||||||
consoleLog = function() {
|
var consoleLog = function() {
|
||||||
var args;
|
var args;
|
||||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||||
return process.log(util.format.apply(util, args) + "\n");
|
return process.log(util.format.apply(util, args) + "\n");
|
||||||
};
|
};
|
||||||
streamWrite = function(chunk, encoding, callback) {
|
var streamWrite = function(chunk, encoding, callback) {
|
||||||
if (Buffer.isBuffer(chunk)) {
|
if (Buffer.isBuffer(chunk)) {
|
||||||
chunk = chunk.toString(encoding);
|
chunk = chunk.toString(encoding);
|
||||||
}
|
}
|
||||||
|
@ -50,8 +46,8 @@ if (process.platform === 'win32') {
|
||||||
process.stdout.write = process.stderr.write = streamWrite;
|
process.stdout.write = process.stderr.write = streamWrite;
|
||||||
|
|
||||||
// Always returns EOF for stdin stream.
|
// Always returns EOF for stdin stream.
|
||||||
Readable = require('stream').Readable;
|
var Readable = require('stream').Readable;
|
||||||
stdin = new Readable;
|
var stdin = new Readable;
|
||||||
stdin.push(null);
|
stdin.push(null);
|
||||||
process.__defineGetter__('stdin', function() {
|
process.__defineGetter__('stdin', function() {
|
||||||
return stdin;
|
return stdin;
|
||||||
|
@ -75,7 +71,7 @@ process.on('uncaughtException', function(error) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Emit 'exit' event on quit.
|
// Emit 'exit' event on quit.
|
||||||
app = require('electron').app;
|
var app = require('electron').app;
|
||||||
|
|
||||||
app.on('quit', function(event, exitCode) {
|
app.on('quit', function(event, exitCode) {
|
||||||
return process.emit('exit', exitCode);
|
return process.emit('exit', exitCode);
|
||||||
|
@ -92,20 +88,17 @@ require('./guest-view-manager');
|
||||||
|
|
||||||
require('./guest-window-manager');
|
require('./guest-window-manager');
|
||||||
|
|
||||||
|
|
||||||
// Now we try to load app's package.json.
|
// Now we try to load app's package.json.
|
||||||
packageJson = null;
|
var packageJson = null;
|
||||||
|
var searchPaths = ['app', 'app.asar', 'default_app'];
|
||||||
searchPaths = ['app', 'app.asar', 'default_app'];
|
var i, len;
|
||||||
|
|
||||||
for (i = 0, len = searchPaths.length; i < len; i++) {
|
for (i = 0, len = searchPaths.length; i < len; i++) {
|
||||||
packagePath = searchPaths[i];
|
var packagePath = searchPaths[i];
|
||||||
try {
|
try {
|
||||||
packagePath = path.join(process.resourcesPath, packagePath);
|
packagePath = path.join(process.resourcesPath, packagePath);
|
||||||
packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json')));
|
packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json')));
|
||||||
break;
|
break;
|
||||||
} catch (error1) {
|
} catch (error) {
|
||||||
e = error1;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,7 +146,7 @@ require('./chrome-extension');
|
||||||
require('./desktop-capturer');
|
require('./desktop-capturer');
|
||||||
|
|
||||||
// Set main startup script of the app.
|
// 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++.
|
// Finally load app's main.js and transfer control to C++.
|
||||||
Module._load(path.join(packagePath, mainStartupScript), Module, true);
|
Module._load(path.join(packagePath, mainStartupScript), Module, true);
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
var EventEmitter, ObjectsRegistry, v8Util,
|
const EventEmitter = require('events').EventEmitter;
|
||||||
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; },
|
const v8Util = process.atomBinding('v8_util');
|
||||||
hasProp = {}.hasOwnProperty;
|
|
||||||
|
|
||||||
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');
|
var ObjectsRegistry = (function(superClass) {
|
||||||
|
|
||||||
ObjectsRegistry = (function(superClass) {
|
|
||||||
extend(ObjectsRegistry, superClass);
|
extend(ObjectsRegistry, superClass);
|
||||||
|
|
||||||
function ObjectsRegistry() {
|
function ObjectsRegistry() {
|
||||||
|
|
|
@ -1,20 +1,14 @@
|
||||||
var IDWeakMap, callFunction, electron, exceptionToMeta, ipcMain, objectsRegistry, path, plainObjectToMeta, unwrapArgs, v8Util, valueToMeta,
|
const path = require('path');
|
||||||
slice = [].slice;
|
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');
|
var slice = [].slice;
|
||||||
|
|
||||||
electron = require('electron');
|
|
||||||
|
|
||||||
ipcMain = electron.ipcMain;
|
|
||||||
|
|
||||||
objectsRegistry = require('./objects-registry');
|
|
||||||
|
|
||||||
v8Util = process.atomBinding('v8_util');
|
|
||||||
|
|
||||||
IDWeakMap = process.atomBinding('id_weak_map').IDWeakMap;
|
|
||||||
|
|
||||||
// Convert a real value into meta data.
|
// 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;
|
var el, field, i, len, meta, name;
|
||||||
if (optimizeSimpleObject == null) {
|
if (optimizeSimpleObject == null) {
|
||||||
optimizeSimpleObject = false;
|
optimizeSimpleObject = false;
|
||||||
|
@ -97,7 +91,7 @@ valueToMeta = function(sender, value, optimizeSimpleObject) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convert object to meta by value.
|
// Convert object to meta by value.
|
||||||
plainObjectToMeta = function(obj) {
|
var plainObjectToMeta = function(obj) {
|
||||||
return Object.getOwnPropertyNames(obj).map(function(name) {
|
return Object.getOwnPropertyNames(obj).map(function(name) {
|
||||||
return {
|
return {
|
||||||
name: name,
|
name: name,
|
||||||
|
@ -107,7 +101,7 @@ plainObjectToMeta = function(obj) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convert Error into meta data.
|
// Convert Error into meta data.
|
||||||
exceptionToMeta = function(error) {
|
var exceptionToMeta = function(error) {
|
||||||
return {
|
return {
|
||||||
type: 'exception',
|
type: 'exception',
|
||||||
message: error.message,
|
message: error.message,
|
||||||
|
@ -116,7 +110,7 @@ exceptionToMeta = function(error) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convert array of meta data from renderer into array of real values.
|
// Convert array of meta data from renderer into array of real values.
|
||||||
unwrapArgs = function(sender, args) {
|
var unwrapArgs = function(sender, args) {
|
||||||
var metaToValue;
|
var metaToValue;
|
||||||
metaToValue = function(meta) {
|
metaToValue = function(meta) {
|
||||||
var i, len, member, ref, rendererReleased, ret, returnValue;
|
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
|
// Call a function and send reply asynchronously if it's a an asynchronous
|
||||||
// style function and the caller didn't pass a callback.
|
// 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;
|
var e, error1, funcMarkedAsync, funcName, funcPassedCallback, ref, ret;
|
||||||
funcMarkedAsync = v8Util.getHiddenValue(func, 'asynchronous');
|
funcMarkedAsync = v8Util.getHiddenValue(func, 'asynchronous');
|
||||||
funcPassedCallback = typeof args[args.length - 1] === 'function';
|
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');
|
var CrashReporter = (function() {
|
||||||
|
|
||||||
os = require('os');
|
|
||||||
|
|
||||||
path = require('path');
|
|
||||||
|
|
||||||
spawn = require('child_process').spawn;
|
|
||||||
|
|
||||||
electron = require('electron');
|
|
||||||
|
|
||||||
binding = process.atomBinding('crash_reporter');
|
|
||||||
|
|
||||||
CrashReporter = (function() {
|
|
||||||
function CrashReporter() {}
|
function CrashReporter() {}
|
||||||
|
|
||||||
CrashReporter.prototype.start = function(options) {
|
CrashReporter.prototype.start = function(options) {
|
||||||
|
@ -99,6 +92,4 @@ CrashReporter = (function() {
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
crashRepoter = new CrashReporter;
|
module.exports = new CrashReporter;
|
||||||
|
|
||||||
module.exports = crashRepoter;
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Do not expose the internal modules to `require`.
|
// Do not expose the internal modules to `require`.
|
||||||
exports.hideInternalModules = function() {
|
exports.hideInternalModules = function() {
|
||||||
var globalPaths;
|
var globalPaths = require('module').globalPaths;
|
||||||
globalPaths = require('module').globalPaths;
|
|
||||||
if (globalPaths.length === 3) {
|
if (globalPaths.length === 3) {
|
||||||
|
|
||||||
// Remove the "common/api/lib" and "browser-or-renderer/api/lib".
|
// Remove the "common/api/lib" and "browser-or-renderer/api/lib".
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
var deprecate, nativeImage;
|
const deprecate = require('electron').deprecate;
|
||||||
|
const nativeImage = process.atomBinding('native_image');
|
||||||
deprecate = require('electron').deprecate;
|
|
||||||
|
|
||||||
nativeImage = process.atomBinding('native_image');
|
|
||||||
|
|
||||||
// Deprecated.
|
// Deprecated.
|
||||||
deprecate.rename(nativeImage, 'createFromDataUrl', 'createFromDataURL');
|
deprecate.rename(nativeImage, 'createFromDataUrl', 'createFromDataURL');
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
(function () {
|
(function () {
|
||||||
var asar, asarStatsToFsStats, cachedArchives, child_process, fakeTime, getOrCreateArchive, gid, invalidArchiveError, nextInode, notDirError, notFoundError, overrideAPI, overrideAPISync, path, splitPath, uid, util,
|
const asar = process.binding('atom_common_asar');
|
||||||
hasProp = {}.hasOwnProperty;
|
const child_process = require('child_process');
|
||||||
|
const path = require('path');
|
||||||
|
const util = require('util');
|
||||||
|
|
||||||
asar = process.binding('atom_common_asar');
|
var hasProp = {}.hasOwnProperty;
|
||||||
|
|
||||||
child_process = require('child_process');
|
|
||||||
|
|
||||||
path = require('path');
|
|
||||||
|
|
||||||
util = require('util');
|
|
||||||
|
|
||||||
// Cache asar archive objects.
|
// Cache asar archive objects.
|
||||||
cachedArchives = {};
|
var cachedArchives = {};
|
||||||
|
|
||||||
getOrCreateArchive = function(p) {
|
var getOrCreateArchive = function(p) {
|
||||||
var archive;
|
var archive;
|
||||||
archive = cachedArchives[p];
|
archive = cachedArchives[p];
|
||||||
if (archive != null) {
|
if (archive != null) {
|
||||||
|
@ -39,13 +35,14 @@ process.on('exit', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Separate asar package's path from full path.
|
// Separate asar package's path from full path.
|
||||||
splitPath = function(p) {
|
var splitPath = function(p) {
|
||||||
|
var index;
|
||||||
|
|
||||||
// shortcut to disable asar.
|
// shortcut to disable asar.
|
||||||
var index;
|
|
||||||
if (process.noAsar) {
|
if (process.noAsar) {
|
||||||
return [false];
|
return [false];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof p !== 'string') {
|
if (typeof p !== 'string') {
|
||||||
return [false];
|
return [false];
|
||||||
}
|
}
|
||||||
|
@ -61,15 +58,15 @@ splitPath = function(p) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convert asar archive's Stats object to fs's Stats object.
|
// 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 {
|
return {
|
||||||
dev: 1,
|
dev: 1,
|
||||||
ino: ++nextInode,
|
ino: ++nextInode,
|
||||||
|
@ -108,7 +105,7 @@ asarStatsToFsStats = function(stats) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create a ENOENT error.
|
// Create a ENOENT error.
|
||||||
notFoundError = function(asarPath, filePath, callback) {
|
var notFoundError = function(asarPath, filePath, callback) {
|
||||||
var error;
|
var error;
|
||||||
error = new Error("ENOENT, " + filePath + " not found in " + asarPath);
|
error = new Error("ENOENT, " + filePath + " not found in " + asarPath);
|
||||||
error.code = "ENOENT";
|
error.code = "ENOENT";
|
||||||
|
@ -122,7 +119,7 @@ notFoundError = function(asarPath, filePath, callback) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create a ENOTDIR error.
|
// Create a ENOTDIR error.
|
||||||
notDirError = function(callback) {
|
var notDirError = function(callback) {
|
||||||
var error;
|
var error;
|
||||||
error = new Error('ENOTDIR, not a directory');
|
error = new Error('ENOTDIR, not a directory');
|
||||||
error.code = 'ENOTDIR';
|
error.code = 'ENOTDIR';
|
||||||
|
@ -136,7 +133,7 @@ notDirError = function(callback) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create invalid archive error.
|
// Create invalid archive error.
|
||||||
invalidArchiveError = function(asarPath, callback) {
|
var invalidArchiveError = function(asarPath, callback) {
|
||||||
var error;
|
var error;
|
||||||
error = new Error("Invalid package " + asarPath);
|
error = new Error("Invalid package " + asarPath);
|
||||||
if (typeof callback !== 'function') {
|
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++.
|
// 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;
|
var old;
|
||||||
if (arg == null) {
|
if (arg == null) {
|
||||||
arg = 0;
|
arg = 0;
|
||||||
|
@ -174,7 +171,7 @@ overrideAPISync = function(module, name, arg) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
overrideAPI = function(module, name, arg) {
|
var overrideAPI = function(module, name, arg) {
|
||||||
var old;
|
var old;
|
||||||
if (arg == null) {
|
if (arg == null) {
|
||||||
arg = 0;
|
arg = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue