Files
JiboSDK/node_modules/electron-prebuilt/dist/resources/atom.asar

4286 lines
135 KiB
Plaintext
Raw Normal View History

2026-03-22 03:21:45 +02:00
<00> <00> <00> {"files":{"browser":{"files":{"api":{"files":{"lib":{"files":{"app.js":{"size":2728,"offset":"0"},"atom-delegate.js":{"size":268,"offset":"2728"},"auto-updater":{"files":{"auto-updater-mac.js":{"size":299,"offset":"3381"},"auto-updater-win.js":{"size":2429,"offset":"3680"},"squirrel-update-win.js":{"size":2419,"offset":"6109"}}},"auto-updater.js":{"size":385,"offset":"2996"},"browser-window.js":{"size":6479,"offset":"8528"},"content-tracing.js":{"size":125,"offset":"15007"},"dialog.js":{"size":5703,"offset":"15132"},"global-shortcut.js":{"size":233,"offset":"20835"},"ipc.js":{"size":174,"offset":"21068"},"menu-item.js":{"size":3217,"offset":"21242"},"menu.js":{"size":9516,"offset":"24459"},"navigation-controller.js":{"size":5532,"offset":"33975"},"power-monitor.js":{"size":305,"offset":"39507"},"power-save-blocker.js":{"size":186,"offset":"39812"},"protocol.js":{"size":1165,"offset":"39998"},"screen.js":{"size":268,"offset":"41163"},"tray.js":{"size":486,"offset":"41431"},"web-contents.js":{"size":4682,"offset":"41917"}}}}},"lib":{"files":{"chrome-extension.js":{"size":4354,"offset":"46599"},"guest-view-manager.js":{"size":7081,"offset":"50953"},"guest-window-manager.js":{"size":4622,"offset":"58034"},"init.js":{"size":3399,"offset":"62656"},"objects-registry.js":{"size":2835,"offset":"66055"},"rpc-server.js":{"size":8644,"offset":"68890"}}}}},"common":{"files":{"api":{"files":{"lib":{"files":{"callbacks-registry.js":{"size":1783,"offset":"77534"},"clipboard.js":{"size":266,"offset":"79317"},"crash-reporter.js":{"size":2961,"offset":"79583"},"native-image.js":{"size":122,"offset":"82544"},"shell.js":{"size":292,"offset":"82666"}}}}},"lib":{"files":{"init.js":{"size":1119,"offset":"82958"},"reset-search-paths.js":{"size":924,"offset":"84077"}}}}},"renderer":{"files":{"api":{"files":{"lib":{"files":{"ipc.js":{"size":889,"offset":"85001"},"remote.js":{"size":7430,"offset":"85890"},"screen.js":{"size":122,"offset":"93320"},"web-frame.js":{"size":128,"offset":"93442"}}}}},"lib":{"files":{"chrome-api.js":{"size":379,"offset":"93570"},"init.js":{"size":3249,"offset":"93949"},"inspector.js":{"size":2446,"offset":"97198"},"override.js":{"size":6399,"offset":"99644"},"web-view":{"files":{"guest-view-internal.js":{"size":4339,"offset":"106043"},"web-view-attributes.js":{"size":12041,"offset":"110382"},"web-view-constants.js":{"size":1180,"offset":"122423"},"web-view.js":{"size":12191,"offset":"123603"}}}}}}}}}// Generated by CoffeeScript 1.10.0
(function() {
var EventEmitter, app, appPath, bindings, downloadItemBindings, sessionBindings, wrapDownloadItem, wrapSession;
EventEmitter = require('events').EventEmitter;
bindings = process.atomBinding('app');
sessionBindings = process.atomBinding('session');
downloadItemBindings = process.atomBinding('download_item');
app = bindings.app;
app.__proto__ = EventEmitter.prototype;
wrapSession = function(session) {
return session.__proto__ = EventEmitter.prototype;
};
wrapDownloadItem = function(download_item) {
download_item.__proto__ = EventEmitter.prototype;
download_item.url = download_item.getUrl();
download_item.filename = download_item.getFilename();
download_item.mimeType = download_item.getMimeType();
return download_item.hasUserGesture = download_item.hasUserGesture();
};
app.setApplicationMenu = function(menu) {
return require('menu').setApplicationMenu(menu);
};
app.getApplicationMenu = function() {
return require('menu').getApplicationMenu();
};
app.commandLine = {
appendSwitch: bindings.appendSwitch,
appendArgument: bindings.appendArgument
};
if (process.platform === 'darwin') {
app.dock = {
bounce: function(type) {
if (type == null) {
type = 'informational';
}
return bindings.dockBounce(type);
},
cancelBounce: bindings.dockCancelBounce,
setBadge: bindings.dockSetBadgeText,
getBadge: bindings.dockGetBadgeText,
hide: bindings.dockHide,
show: bindings.dockShow,
setMenu: bindings.dockSetMenu
};
}
appPath = null;
app.setAppPath = function(path) {
return appPath = path;
};
app.getAppPath = function() {
return appPath;
};
app.once('ready', function() {
return this.emit('finish-launching');
});
app.terminate = app.quit;
app.exit = process.exit;
app.getHomeDir = function() {
return this.getPath('home');
};
app.getDataPath = function() {
return this.getPath('userData');
};
app.setDataPath = function(path) {
return this.setPath('userData', path);
};
app.resolveProxy = function() {
return this.defaultSession.resolveProxy.apply(this.defaultSession, arguments);
};
app.on('activate', function(event, hasVisibleWindows) {
if (!hasVisibleWindows) {
return this.emit('activate-with-no-open-windows');
}
});
sessionBindings._setWrapSession(wrapSession);
process.once('exit', sessionBindings._clearWrapSession);
downloadItemBindings._setWrapDownloadItem(wrapDownloadItem);
process.once('exit', downloadItemBindings._clearWrapDownloadItem);
module.exports = app;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
module.exports = {
browserMainParts: {
preMainMessageLoopRun: function() {}
}
};
setImmediate(function() {
return module.exports.browserMainParts.preMainMessageLoopRun();
});
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
switch (process.platform) {
case 'win32':
module.exports = require('./auto-updater/auto-updater-win');
break;
case 'darwin':
module.exports = require('./auto-updater/auto-updater-mac');
break;
default:
throw new Error('auto-updater is not implemented on this platform');
}
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var EventEmitter, autoUpdater;
EventEmitter = require('events').EventEmitter;
autoUpdater = process.atomBinding('auto_updater').autoUpdater;
autoUpdater.__proto__ = EventEmitter.prototype;
module.exports = autoUpdater;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
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;
app = require('app');
url = require('url');
EventEmitter = require('events').EventEmitter;
squirrelUpdate = require('./squirrel-update-win');
AutoUpdater = (function(superClass) {
extend(AutoUpdater, superClass);
function AutoUpdater() {
return AutoUpdater.__super__.constructor.apply(this, arguments);
}
AutoUpdater.prototype.quitAndInstall = function() {
squirrelUpdate.processStart();
return app.quit();
};
AutoUpdater.prototype.setFeedUrl = function(updateUrl) {
return this.updateUrl = updateUrl;
};
AutoUpdater.prototype.checkForUpdates = function() {
if (!this.updateUrl) {
return this.emitError('Update URL is not set');
}
if (!squirrelUpdate.supported()) {
return this.emitError('Can not find Squirrel');
}
this.emit('checking-for-update');
return squirrelUpdate.download(this.updateUrl, (function(_this) {
return function(error, update) {
if (error != null) {
return _this.emitError(error);
}
if (update == null) {
return _this.emit('update-not-available');
}
_this.emit('update-available');
return squirrelUpdate.update(_this.updateUrl, function(error) {
var date, releaseNotes, version;
if (error != null) {
return _this.emitError(error);
}
releaseNotes = update.releaseNotes, version = update.version;
date = new Date;
url = _this.updateUrl;
return _this.emit('update-downloaded', {}, releaseNotes, version, date, url, function() {
return _this.quitAndInstall();
});
});
};
})(this));
};
AutoUpdater.prototype.emitError = function(message) {
return this.emit('error', new Error(message), message);
};
return AutoUpdater;
})(EventEmitter);
module.exports = new AutoUpdater;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var appFolder, exeName, fs, path, spawn, spawnUpdate, updateExe;
fs = require('fs');
path = require('path');
spawn = require('child_process').spawn;
appFolder = path.dirname(process.execPath);
updateExe = path.resolve(appFolder, '..', 'Update.exe');
exeName = path.basename(process.execPath);
spawnUpdate = function(args, detached, callback) {
var error, error1, errorEmitted, spawnedProcess, stderr, stdout;
try {
spawnedProcess = spawn(updateExe, args, {
detached: detached
});
} catch (error1) {
error = error1;
process.nextTick(function() {
return callback(error);
});
return;
}
stdout = '';
stderr = '';
spawnedProcess.stdout.on('data', function(data) {
return stdout += data;
});
spawnedProcess.stderr.on('data', function(data) {
return stderr += data;
});
errorEmitted = false;
spawnedProcess.on('error', function(error) {
errorEmitted = true;
return callback(error);
});
return spawnedProcess.on('exit', function(code, signal) {
if (errorEmitted) {
return;
}
if (code !== 0) {
return callback("Command failed: " + (signal != null ? signal : code) + "\n" + stderr);
}
return callback(null, stdout);
});
};
exports.processStart = function(callback) {
return spawnUpdate(['--processStart', exeName], true, function() {});
};
exports.download = function(updateUrl, callback) {
return spawnUpdate(['--download', updateUrl], false, function(error, stdout) {
var error1, json, ref, ref1, update;
if (error != null) {
return callback(error);
}
try {
json = stdout.trim().split('\n').pop();
update = (ref = JSON.parse(json)) != null ? (ref1 = ref.releasesToApply) != null ? typeof ref1.pop === "function" ? ref1.pop() : void 0 : void 0 : void 0;
} catch (error1) {
return callback("Invalid result:\n" + stdout);
}
return callback(null, update);
});
};
exports.update = function(updateUrl, callback) {
return spawnUpdate(['--update', updateUrl], false, callback);
};
exports.supported = function() {
var error1;
try {
fs.accessSync(updateExe, fs.R_OK);
return true;
} catch (error1) {
return false;
}
};
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var BrowserWindow, EventEmitter, app, ipc;
EventEmitter = require('events').EventEmitter;
app = require('app');
ipc = require('ipc');
BrowserWindow = process.atomBinding('window').BrowserWindow;
BrowserWindow.prototype.__proto__ = EventEmitter.prototype;
BrowserWindow.prototype._init = function() {
var menu;
if (process.platform !== 'darwin') {
menu = app.getApplicationMenu();
if (menu != null) {
this.setMenu(menu);
}
}
this.webContents.on('-new-window', function(event, url, frameName) {
var options;
options = {
show: true,
width: 800,
height: 600
};
return ipc.emit('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, options);
});
this.webContents.on('move', (function(_this) {
return function(event, size) {
return _this.setBounds(size);
};
})(this));
this.webContents.on('activate', (function(_this) {
return function() {
if (process.platform !== 'darwin' && _this.isMenuBarAutoHide() && _this.isMenuBarVisible()) {
return _this.setMenuBarVisibility(false);
}
};
})(this));
this.webContents.on('crashed', (function(_this) {
return function() {
return _this.emit('crashed');
};
})(this));
this.webContents.once('load-url', function() {
return this.focus();
});
this.on('blur', (function(_this) {
return function(event) {
return app.emit('browser-window-blur', event, _this);
};
})(this));
this.on('focus', (function(_this) {
return function(event) {
return app.emit('browser-window-focus', event, _this);
};
})(this));
app.emit('browser-window-created', {}, this);
this.webContents.on('devtools-focused', (function(_this) {
return function() {
return _this.emit('devtools-focused');
};
})(this));
this.webContents.on('devtools-opened', (function(_this) {
return function() {
return _this.emit('devtools-opened');
};
})(this));
this.webContents.on('devtools-closed', (function(_this) {
return function() {
return _this.emit('devtools-closed');
};
})(this));
return Object.defineProperty(this, 'devToolsWebContents', {
enumerable: true,
configurable: false,
get: function() {
return this.webContents.devToolsWebContents;
}
});
};
BrowserWindow.getFocusedWindow = function() {
var i, len, window, windows;
windows = BrowserWindow.getAllWindows();
for (i = 0, len = windows.length; i < len; i++) {
window = windows[i];
if (window.isFocused()) {
return window;
}
}
};
BrowserWindow.fromWebContents = function(webContents) {
var i, len, ref, window, windows;
windows = BrowserWindow.getAllWindows();
for (i = 0, len = windows.length; i < len; i++) {
window = windows[i];
if ((ref = window.webContents) != null ? ref.equal(webContents) : void 0) {
return window;
}
}
};
BrowserWindow.fromDevToolsWebContents = function(webContents) {
var i, len, ref, window, windows;
windows = BrowserWindow.getAllWindows();
for (i = 0, len = windows.length; i < len; i++) {
window = windows[i];
if ((ref = window.devToolsWebContents) != null ? ref.equal(webContents) : void 0) {
return window;
}
}
};
BrowserWindow.prototype.loadUrl = function() {
return this.webContents.loadUrl.apply(this.webContents, arguments);
};
BrowserWindow.prototype.send = function() {
return this.webContents.send.apply(this.webContents, arguments);
};
BrowserWindow.prototype.undo = function() {
return this.webContents.undo();
};
BrowserWindow.prototype.redo = function() {
return this.webContents.redo();
};
BrowserWindow.prototype.cut = function() {
return this.webContents.cut();
};
BrowserWindow.prototype.copy = function() {
return this.webContents.copy();
};
BrowserWindow.prototype.paste = function() {
return this.webContents.paste();
};
BrowserWindow.prototype.selectAll = function() {
return this.webContents.selectAll();
};
BrowserWindow.prototype.restart = function() {
return this.webContents.reload();
};
BrowserWindow.prototype.getUrl = function() {
return this.webContents.getUrl();
};
BrowserWindow.prototype.reload = function() {
return this.webContents.reload.apply(this.webContents, arguments);
};
BrowserWindow.prototype.reloadIgnoringCache = function() {
return this.webContents.reloadIgnoringCache.apply(this.webContents, arguments);
};
BrowserWindow.prototype.getPageTitle = function() {
return this.webContents.getTitle();
};
BrowserWindow.prototype.isLoading = function() {
return this.webContents.isLoading();
};
BrowserWindow.prototype.isWaitingForResponse = function() {
return this.webContents.isWaitingForResponse();
};
BrowserWindow.prototype.stop = function() {
return this.webContents.stop();
};
BrowserWindow.prototype.isCrashed = function() {
return this.webContents.isCrashed();
};
BrowserWindow.prototype.executeJavaScriptInDevTools = function(code) {
var ref;
return (ref = this.devToolsWebContents) != null ? ref.executeJavaScript(code) : void 0;
};
BrowserWindow.prototype.openDevTools = function() {
return this.webContents.openDevTools.apply(this.webContents, arguments);
};
BrowserWindow.prototype.closeDevTools = function() {
return this.webContents.closeDevTools();
};
BrowserWindow.prototype.isDevToolsOpened = function() {
return this.webContents.isDevToolsOpened();
};
BrowserWindow.prototype.toggleDevTools = function() {
return this.webContents.toggleDevTools();
};
BrowserWindow.prototype.inspectElement = function() {
return this.webContents.inspectElement.apply(this.webContents, arguments);
};
BrowserWindow.prototype.inspectServiceWorker = function() {
return this.webContents.inspectServiceWorker();
};
BrowserWindow.prototype.print = function() {
return this.webContents.print.apply(this.webContents, arguments);
};
BrowserWindow.prototype.printToPDF = function() {
return this.webContents.printToPDF.apply(this.webContents, arguments);
};
module.exports = BrowserWindow;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
module.exports = process.atomBinding('content_tracing');
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var BrowserWindow, api, app, binding, checkAppInitialized, fileDialogProperties, j, len, messageBoxOptions, messageBoxTypes, parseArgs, ref, 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; };
binding = process.atomBinding('dialog');
v8Util = process.atomBinding('v8_util');
app = require('app');
BrowserWindow = require('browser-window');
fileDialogProperties = {
openFile: 1 << 0,
openDirectory: 1 << 1,
multiSelections: 1 << 2,
createDirectory: 1 << 3
};
messageBoxTypes = ['none', 'info', 'warning', 'error', 'question'];
messageBoxOptions = {
noLink: 1 << 0
};
parseArgs = function(window, options, callback) {
if (!(window === null || (window != null ? window.constructor : void 0) === BrowserWindow)) {
callback = options;
options = window;
window = null;
}
if ((callback == null) && typeof options === 'function') {
callback = options;
options = null;
}
return [window, options, callback];
};
checkAppInitialized = function() {
if (!app.isReady()) {
throw new Error('dialog module can only be used after app is ready');
}
};
module.exports = {
showOpenDialog: function() {
var args, callback, options, prop, properties, ref, value, window, wrappedCallback;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
checkAppInitialized();
ref = parseArgs.apply(null, args), window = ref[0], options = ref[1], callback = ref[2];
if (options == null) {
options = {
title: 'Open',
properties: ['openFile']
};
}
if (options.properties == null) {
options.properties = ['openFile'];
}
if (!Array.isArray(options.properties)) {
throw new TypeError('Properties need to be array');
}
properties = 0;
for (prop in fileDialogProperties) {
value = fileDialogProperties[prop];
if (indexOf.call(options.properties, prop) >= 0) {
properties |= value;
}
}
if (options.title == null) {
options.title = '';
}
if (options.defaultPath == null) {
options.defaultPath = '';
}
if (options.filters == null) {
options.filters = [];
}
wrappedCallback = typeof callback === 'function' ? function(success, result) {
return callback(success ? result : void 0);
} : null;
return binding.showOpenDialog(String(options.title), String(options.defaultPath), options.filters, properties, window, wrappedCallback);
},
showSaveDialog: function() {
var args, callback, options, ref, window, wrappedCallback;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
checkAppInitialized();
ref = parseArgs.apply(null, args), window = ref[0], options = ref[1], callback = ref[2];
if (options == null) {
options = {
title: 'Save'
};
}
if (options.title == null) {
options.title = '';
}
if (options.defaultPath == null) {
options.defaultPath = '';
}
if (options.filters == null) {
options.filters = [];
}
wrappedCallback = typeof callback === 'function' ? function(success, result) {
return callback(success ? result : void 0);
} : 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, ref, ref1, ref2, text, window;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
checkAppInitialized();
ref = parseArgs.apply(null, args), window = ref[0], options = ref[1], callback = ref[2];
if (options == null) {
options = {
type: 'none'
};
}
if (options.type == null) {
options.type = 'none';
}
messageBoxType = messageBoxTypes.indexOf(options.type);
if (!(messageBoxType > -1)) {
throw new TypeError('Invalid message box type');
}
if (!Array.isArray(options.buttons)) {
throw new TypeError('Buttons need to be array');
}
if (options.title == null) {
options.title = '';
}
if (options.message == null) {
options.message = '';
}
if (options.detail == null) {
options.detail = '';
}
if (options.icon == null) {
options.icon = null;
}
if (options.cancelId == null) {
options.cancelId = 0;
ref1 = options.buttons;
for (i = j = 0, len = ref1.length; j < len; i = ++j) {
text = ref1[i];
if ((ref2 = text.toLowerCase()) === 'cancel' || ref2 === 'no') {
options.cancelId = i;
break;
}
}
}
flags = options.noLink ? messageBoxOptions.noLink : 0;
return binding.showMessageBox(messageBoxType, options.buttons, 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) : [];
return binding.showErrorBox.apply(binding, args);
}
};
ref = ['showMessageBox', 'showOpenDialog', 'showSaveDialog'];
for (j = 0, len = ref.length; j < len; j++) {
api = ref[j];
v8Util.setHiddenValue(module.exports[api], 'asynchronous', true);
}
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var bindings, globalShortcut;
bindings = process.atomBinding('global_shortcut');
globalShortcut = bindings.globalShortcut;
module.exports = globalShortcut;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var EventEmitter;
EventEmitter = require('events').EventEmitter;
module.exports = new EventEmitter;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var BrowserWindow, MenuItem, nextCommandId, rolesMap, v8Util;
BrowserWindow = require('browser-window');
v8Util = process.atomBinding('v8_util');
nextCommandId = 0;
rolesMap = {
undo: 'undo',
redo: 'redo',
cut: 'cut',
copy: 'copy',
paste: 'paste',
selectall: 'selectAll',
minimize: 'minimize',
close: 'close'
};
MenuItem = (function() {
MenuItem.types = ['normal', 'separator', 'submenu', 'checkbox', 'radio'];
function MenuItem(options) {
var Menu, click, ref;
Menu = require('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.type == null) && (this.submenu != null)) {
this.type = 'submenu';
}
if (this.type === 'submenu' && ((ref = this.submenu) != null ? ref.constructor : void 0) !== Menu) {
throw new Error('Invalid submenu');
}
this.overrideReadOnlyProperty('type', 'normal');
this.overrideReadOnlyProperty('role');
this.overrideReadOnlyProperty('accelerator');
this.overrideReadOnlyProperty('icon');
this.overrideReadOnlyProperty('submenu');
this.overrideProperty('label', '');
this.overrideProperty('sublabel', '');
this.overrideProperty('enabled', true);
this.overrideProperty('visible', true);
this.overrideProperty('checked', false);
if (MenuItem.types.indexOf(this.type) === -1) {
throw new Error("Unknown menu type " + this.type);
}
this.commandId = ++nextCommandId;
this.click = (function(_this) {
return function(focusedWindow) {
var ref1;
if ((ref1 = _this.type) === 'checkbox' || ref1 === 'radio') {
_this.checked = !_this.checked;
}
if (_this.role && rolesMap[_this.role] && process.platform !== 'darwin') {
return focusedWindow != null ? focusedWindow[rolesMap[_this.role]]() : void 0;
} else if (typeof click === 'function') {
return click(_this, focusedWindow);
} else if (typeof _this.selector === 'string') {
return Menu.sendActionToFirstResponder(_this.selector);
}
};
})(this);
}
MenuItem.prototype.overrideProperty = function(name, defaultValue) {
if (defaultValue == null) {
defaultValue = null;
}
return this[name] != null ? this[name] : this[name] = defaultValue;
};
MenuItem.prototype.overrideReadOnlyProperty = function(name, defaultValue) {
if (defaultValue == null) {
defaultValue = null;
}
if (this[name] == null) {
this[name] = defaultValue;
}
return Object.defineProperty(this, name, {
enumerable: true,
writable: false,
value: this[name]
});
};
return MenuItem;
})();
module.exports = MenuItem;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var BrowserWindow, EventEmitter, Menu, MenuItem, applicationMenu, bindings, generateGroupId, indexOfItemById, indexToInsertByPosition, nextGroupId, v8Util;
BrowserWindow = require('browser-window');
EventEmitter = require('events').EventEmitter;
MenuItem = require('menu-item');
v8Util = process.atomBinding('v8_util');
bindings = process.atomBinding('menu');
nextGroupId = 0;
generateGroupId = function(items, pos) {
var i, item, j, k, ref, ref1, ref2;
if (pos > 0) {
for (i = j = ref = pos - 1; ref <= 0 ? j <= 0 : j >= 0; i = ref <= 0 ? ++j : --j) {
item = items[i];
if (item.type === 'radio') {
return item.groupId;
}
if (item.type === 'separator') {
break;
}
}
} else if (pos < items.length) {
for (i = k = ref1 = pos, ref2 = items.length - 1; ref1 <= ref2 ? k <= ref2 : k >= ref2; i = ref1 <= ref2 ? ++k : --k) {
item = items[i];
if (item.type === 'radio') {
return item.groupId;
}
if (item.type === 'separator') {
break;
}
}
}
return ++nextGroupId;
};
indexOfItemById = function(items, id) {
var i, item, j, len;
for (i = j = 0, len = items.length; j < len; i = ++j) {
item = items[i];
if (item.id === id) {
return i;
}
}
return -1;
};
indexToInsertByPosition = function(items, position) {
var id, insertIndex, query, ref;
if (!position) {
return items.length;
}
ref = position.split('='), query = ref[0], id = ref[1];
insertIndex = indexOfItemById(items, id);
if (insertIndex === -1 && query !== 'endof') {
console.warn("Item with id '" + id + "' is not found");
return items.length;
}
switch (query) {
case 'after':
insertIndex++;
break;
case 'endof':
if (insertIndex === -1) {
items.push({
id: id,
type: 'separator'
});
insertIndex = items.length - 1;
}
insertIndex++;
while (insertIndex < items.length && items[insertIndex].type !== 'separator') {
insertIndex++;
}
}
return insertIndex;
};
Menu = bindings.Menu;
Menu.prototype.__proto__ = EventEmitter.prototype;
Menu.prototype._init = function() {
this.commandsMap = {};
this.groupsMap = {};
this.items = [];
return this.delegate = {
isCommandIdChecked: (function(_this) {
return function(commandId) {
var ref;
return (ref = _this.commandsMap[commandId]) != null ? ref.checked : void 0;
};
})(this),
isCommandIdEnabled: (function(_this) {
return function(commandId) {
var ref;
return (ref = _this.commandsMap[commandId]) != null ? ref.enabled : void 0;
};
})(this),
isCommandIdVisible: (function(_this) {
return function(commandId) {
var ref;
return (ref = _this.commandsMap[commandId]) != null ? ref.visible : void 0;
};
})(this),
getAcceleratorForCommandId: (function(_this) {
return function(commandId) {
var ref;
return (ref = _this.commandsMap[commandId]) != null ? ref.accelerator : void 0;
};
})(this),
getIconForCommandId: (function(_this) {
return function(commandId) {
var ref;
return (ref = _this.commandsMap[commandId]) != null ? ref.icon : void 0;
};
})(this),
executeCommand: (function(_this) {
return function(commandId) {
var ref;
return (ref = _this.commandsMap[commandId]) != null ? ref.click(BrowserWindow.getFocusedWindow()) : void 0;
};
})(this),
menuWillShow: (function(_this) {
return function() {
var checked, group, id, j, len, radioItem, ref, results;
ref = _this.groupsMap;
results = [];
for (id in ref) {
group = ref[id];
checked = false;
for (j = 0, len = group.length; j < len; j++) {
radioItem = group[j];
if (!radioItem.checked) {
continue;
}
checked = true;
break;
}
if (!checked) {
results.push(v8Util.setHiddenValue(group[0], 'checked', true));
} else {
results.push(void 0);
}
}
return results;
};
})(this)
};
};
Menu.prototype.popup = function(window, x, y) {
if ((window != null ? window.constructor : void 0) !== BrowserWindow) {
y = x;
x = window;
window = BrowserWindow.getFocusedWindow();
}
if ((x != null) && (y != null)) {
return this._popupAt(window, x, y);
} else {
return this._popup(window);
}
};
Menu.prototype.append = function(item) {
return this.insert(this.getItemCount(), item);
};
Menu.prototype.insert = function(pos, item) {
var base, name;
if ((item != null ? item.constructor : void 0) !== MenuItem) {
throw new TypeError('Invalid item');
}
switch (item.type) {
case 'normal':
this.insertItem(pos, item.commandId, item.label);
break;
case 'checkbox':
this.insertCheckItem(pos, item.commandId, item.label);
break;
case 'separator':
this.insertSeparator(pos);
break;
case 'submenu':
this.insertSubMenu(pos, item.commandId, item.label, item.submenu);
break;
case 'radio':
item.overrideReadOnlyProperty('groupId', generateGroupId(this.items, pos));
if ((base = this.groupsMap)[name = item.groupId] == null) {
base[name] = [];
}
this.groupsMap[item.groupId].push(item);
v8Util.setHiddenValue(item, 'checked', item.checked);
Object.defineProperty(item, 'checked', {
enumerable: true,
get: function() {
return v8Util.getHiddenValue(item, 'checked');
},
set: (function(_this) {
return function(val) {
var j, len, otherItem, ref;
ref = _this.groupsMap[item.groupId];
for (j = 0, len = ref.length; j < len; j++) {
otherItem = ref[j];
if (otherItem !== item) {
v8Util.setHiddenValue(otherItem, 'checked', false);
}
}
return v8Util.setHiddenValue(item, 'checked', true);
};
})(this)
});
this.insertRadioItem(pos, item.commandId, item.label, item.groupId);
}
if (item.sublabel != null) {
this.setSublabel(pos, item.sublabel);
}
if (item.icon != null) {
this.setIcon(pos, item.icon);
}
if (item.role != null) {
this.setRole(pos, item.role);
}
item.overrideReadOnlyProperty('menu', this);
this.items.splice(pos, 0, item);
return this.commandsMap[item.commandId] = item;
};
Menu.prototype._callMenuWillShow = function() {
var item, j, len, ref, ref1, results;
if ((ref = this.delegate) != null) {
ref.menuWillShow();
}
ref1 = this.items;
results = [];
for (j = 0, len = ref1.length; j < len; j++) {
item = ref1[j];
if (item.submenu != null) {
results.push(item.submenu._callMenuWillShow());
}
}
return results;
};
applicationMenu = null;
Menu.setApplicationMenu = function(menu) {
var j, len, results, w, windows;
if (!(menu === null || menu.constructor === Menu)) {
throw new TypeError('Invalid menu');
}
applicationMenu = menu;
if (process.platform === 'darwin') {
if (menu === null) {
return;
}
menu._callMenuWillShow();
return bindings.setApplicationMenu(menu);
} else {
windows = BrowserWindow.getAllWindows();
results = [];
for (j = 0, len = windows.length; j < len; j++) {
w = windows[j];
results.push(w.setMenu(menu));
}
return results;
}
};
Menu.getApplicationMenu = function() {
return applicationMenu;
};
Menu.sendActionToFirstResponder = bindings.sendActionToFirstResponder;
Menu.buildFromTemplate = function(template) {
var insertIndex, item, j, k, key, len, len1, menu, menuItem, positionedTemplate, value;
if (!Array.isArray(template)) {
throw new TypeError('Invalid template for Menu');
}
positionedTemplate = [];
insertIndex = 0;
for (j = 0, len = template.length; j < len; j++) {
item = template[j];
if (item.position) {
insertIndex = indexToInsertByPosition(positionedTemplate, item.position);
} else {
insertIndex++;
}
positionedTemplate.splice(insertIndex, 0, item);
}
menu = new Menu;
for (k = 0, len1 = positionedTemplate.length; k < len1; k++) {
item = positionedTemplate[k];
if (typeof item !== 'object') {
throw new TypeError('Invalid template for MenuItem');
}
if (item.submenu != null) {
item.submenu = Menu.buildFromTemplate(item.submenu);
}
menuItem = new MenuItem(item);
for (key in item) {
value = item[key];
if (menuItem[key] == null) {
menuItem[key] = value;
}
}
menu.append(menuItem);
}
return menu;
};
module.exports = Menu;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var NavigationController, ipc,
slice = [].slice;
ipc = require('ipc');
ipc.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) : [];
return (ref = event.sender)[method].apply(ref, args);
});
ipc.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) : [];
return event.returnValue = (ref = event.sender)[method].apply(ref, args);
});
NavigationController = (function() {
function NavigationController(webContents) {
this.webContents = webContents;
this.clearHistory();
if (this.webContents._getUrl()) {
this.currentIndex++;
this.history.push(this.webContents._getUrl());
}
this.webContents.on('navigation-entry-commited', (function(_this) {
return function(event, url, inPage, replaceEntry) {
var currentEntry;
if (_this.inPageIndex > -1 && !inPage) {
_this.inPageIndex = -1;
} else if (_this.inPageIndex === -1 && inPage) {
_this.inPageIndex = _this.currentIndex;
}
if (_this.pendingIndex >= 0) {
_this.currentIndex = _this.pendingIndex;
_this.pendingIndex = -1;
return _this.history[_this.currentIndex] = url;
} else if (replaceEntry) {
return _this.history[_this.currentIndex] = url;
} else {
_this.history = _this.history.slice(0, _this.currentIndex + 1);
currentEntry = _this.history[_this.currentIndex];
if ((currentEntry != null ? currentEntry.url : void 0) !== url) {
_this.currentIndex++;
return _this.history.push(url);
}
}
};
})(this));
}
NavigationController.prototype.loadUrl = function(url, options) {
if (options == null) {
options = {};
}
this.pendingIndex = -1;
this.webContents._loadUrl(url, options);
return this.webContents.emit('load-url', url, options);
};
NavigationController.prototype.getUrl = function() {
if (this.currentIndex === -1) {
return '';
} else {
return this.history[this.currentIndex];
}
};
NavigationController.prototype.stop = function() {
this.pendingIndex = -1;
return this.webContents._stop();
};
NavigationController.prototype.reload = function() {
this.pendingIndex = this.currentIndex;
return this.webContents._loadUrl(this.getUrl(), {});
};
NavigationController.prototype.reloadIgnoringCache = function() {
this.webContents._reloadIgnoringCache();
return this.reload();
};
NavigationController.prototype.canGoBack = function() {
return this.getActiveIndex() > 0;
};
NavigationController.prototype.canGoForward = function() {
return this.getActiveIndex() < this.history.length - 1;
};
NavigationController.prototype.canGoToIndex = function(index) {
return index >= 0 && index < this.history.length;
};
NavigationController.prototype.canGoToOffset = function(offset) {
return this.canGoToIndex(this.currentIndex + offset);
};
NavigationController.prototype.clearHistory = function() {
this.history = [];
this.currentIndex = -1;
this.pendingIndex = -1;
return this.inPageIndex = -1;
};
NavigationController.prototype.goBack = function() {
if (!this.canGoBack()) {
return;
}
this.pendingIndex = this.getActiveIndex() - 1;
if (this.inPageIndex > -1 && this.pendingIndex >= this.inPageIndex) {
return this.webContents._goBack();
} else {
return this.webContents._loadUrl(this.history[this.pendingIndex], {});
}
};
NavigationController.prototype.goForward = function() {
if (!this.canGoForward()) {
return;
}
this.pendingIndex = this.getActiveIndex() + 1;
if (this.inPageIndex > -1 && this.pendingIndex >= this.inPageIndex) {
return this.webContents._goForward();
} else {
return this.webContents._loadUrl(this.history[this.pendingIndex], {});
}
};
NavigationController.prototype.goToIndex = function(index) {
if (!this.canGoToIndex(index)) {
return;
}
this.pendingIndex = index;
return this.webContents._loadUrl(this.history[this.pendingIndex], {});
};
NavigationController.prototype.goToOffset = function(offset) {
var pendingIndex;
if (!this.canGoToOffset(offset)) {
return;
}
pendingIndex = this.currentIndex + offset;
if (this.inPageIndex > -1 && pendingIndex >= this.inPageIndex) {
this.pendingIndex = pendingIndex;
return this.webContents._goToOffset(offset);
} else {
return this.goToIndex(pendingIndex);
}
};
NavigationController.prototype.getActiveIndex = function() {
if (this.pendingIndex === -1) {
return this.currentIndex;
} else {
return this.pendingIndex;
}
};
NavigationController.prototype.length = function() {
return this.history.length;
};
return NavigationController;
})();
module.exports = NavigationController;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var EventEmitter, powerMonitor;
powerMonitor = process.atomBinding('power_monitor').powerMonitor;
EventEmitter = require('events').EventEmitter;
powerMonitor.__proto__ = EventEmitter.prototype;
module.exports = powerMonitor;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var bindings;
bindings = process.atomBinding('power_save_blocker');
module.exports = bindings.powerSaveBlocker;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var app, logAndThrow, protocol;
app = require('app');
if (!app.isReady()) {
throw new Error('Can not initialize protocol module before app is ready');
}
protocol = process.atomBinding('protocol').protocol;
logAndThrow = function(callback, message) {
console.error(message);
if (callback) {
return callback(new Error(message));
} else {
throw new Error(message);
}
};
protocol.registerProtocol = function(scheme, handler, callback) {
return logAndThrow(callback, 'registerProtocol API has been replaced by the register[File/Http/Buffer/String]Protocol API family, please switch to the new APIs.');
};
protocol.isHandledProtocol = function(scheme, callback) {
return logAndThrow(callback, 'isHandledProtocol API has been replaced by isProtocolHandled.');
};
protocol.interceptProtocol = function(scheme, handler, callback) {
return logAndThrow(callback, 'interceptProtocol API has been replaced by the intercept[File/Http/Buffer/String]Protocol API family, please switch to the new APIs.');
};
module.exports = protocol;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var EventEmitter, screen;
EventEmitter = require('events').EventEmitter;
screen = process.atomBinding('screen').screen;
screen.__proto__ = EventEmitter.prototype;
module.exports = screen;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var EventEmitter, Tray, bindings;
EventEmitter = require('events').EventEmitter;
bindings = process.atomBinding('tray');
Tray = bindings.Tray;
Tray.prototype.__proto__ = EventEmitter.prototype;
Tray.prototype.setContextMenu = function(menu) {
this._setContextMenu(menu);
return this.menu = menu;
};
Tray.prototype.popContextMenu = Tray.prototype.popUpContextMenu;
module.exports = Tray;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var EventEmitter, NavigationController, PDFPageSize, binding, getNextId, ipc, nextId, wrapWebContents,
slice = [].slice;
EventEmitter = require('events').EventEmitter;
NavigationController = require('./navigation-controller');
binding = process.atomBinding('web_contents');
ipc = require('ipc');
nextId = 0;
getNextId = function() {
return ++nextId;
};
PDFPageSize = {
A4: {
custom_display_name: "A4",
height_microns: 297000,
name: "ISO_A4",
is_default: "true",
width_microns: 210000
},
A3: {
custom_display_name: "A3",
height_microns: 420000,
name: "ISO_A3",
width_microns: 297000
},
Legal: {
custom_display_name: "Legal",
height_microns: 355600,
name: "NA_LEGAL",
width_microns: 215900
},
Letter: {
custom_display_name: "Letter",
height_microns: 279400,
name: "NA_LETTER",
width_microns: 215900
},
Tabloid: {
height_microns: 431800,
name: "NA_LEDGER",
width_microns: 279400,
custom_display_name: "Tabloid"
}
};
wrapWebContents = function(webContents) {
var controller, method, name, ref;
webContents.__proto__ = EventEmitter.prototype;
webContents.send = function() {
var args, channel;
channel = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
return this._send(channel, slice.call(args));
};
webContents.executeJavaScript = function(code, hasUserGesture) {
if (hasUserGesture == null) {
hasUserGesture = false;
}
if (this.getUrl() && !this.isLoading()) {
return this._executeJavaScript(code, hasUserGesture);
} else {
return webContents.once('did-finish-load', this._executeJavaScript.bind(this, code, hasUserGesture));
}
};
controller = new NavigationController(webContents);
ref = NavigationController.prototype;
for (name in ref) {
method = ref[name];
if (method instanceof Function) {
(function(name, method) {
return webContents[name] = function() {
return method.apply(controller, arguments);
};
})(name, method);
}
}
webContents.on('ipc-message', function(event, packed) {
var args, channel;
channel = packed[0], args = 2 <= packed.length ? slice.call(packed, 1) : [];
return ipc.emit.apply(ipc, [channel, event].concat(slice.call(args)));
});
webContents.on('ipc-message-sync', function(event, packed) {
var args, channel;
channel = packed[0], args = 2 <= packed.length ? slice.call(packed, 1) : [];
Object.defineProperty(event, 'returnValue', {
set: function(value) {
return event.sendReply(JSON.stringify(value));
}
});
return ipc.emit.apply(ipc, [channel, event].concat(slice.call(args)));
});
return webContents.printToPDF = function(options, callback) {
var printingSetting;
printingSetting = {
pageRage: [],
mediaSize: {},
landscape: false,
color: 2,
headerFooterEnabled: false,
marginsType: 0,
isFirstRequest: false,
requestID: getNextId(),
previewModifiable: true,
printToPDF: true,
printWithCloudPrint: false,
printWithPrivet: false,
printWithExtension: false,
deviceName: "Save as PDF",
generateDraftData: true,
fitToPageEnabled: false,
duplex: 0,
copies: 1,
collate: true,
shouldPrintBackgrounds: false,
shouldPrintSelectionOnly: false
};
if (options.landscape) {
printingSetting.landscape = options.landscape;
}
if (options.marginsType) {
printingSetting.marginsType = options.marginsType;
}
if (options.printSelectionOnly) {
printingSetting.shouldPrintSelectionOnly = options.printSelectionOnly;
}
if (options.printBackground) {
printingSetting.shouldPrintBackgrounds = options.printBackground;
}
if (options.pageSize && PDFPageSize[options.pageSize]) {
printingSetting.mediaSize = PDFPageSize[options.pageSize];
} else {
printingSetting.mediaSize = PDFPageSize['A4'];
}
return this._printToPDF(printingSetting, callback);
};
};
binding._setWrapWebContents(wrapWebContents);
process.once('exit', binding._clearWrapWebContents);
module.exports.create = function(options) {
if (options == null) {
options = {};
}
return binding.create(options);
};
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var app, extensionInfoMap, fs, getExtensionInfoFromPath, getHostForPath, getPathForHost, hostPathMap, hostPathMapNextKey, loadedExtensions, loadedExtensionsPath, path, url;
app = require('app');
fs = require('fs');
path = require('path');
url = require('url');
hostPathMap = {};
hostPathMapNextKey = 0;
getHostForPath = function(path) {
var key;
key = "extension-" + (++hostPathMapNextKey);
hostPathMap[key] = path;
return key;
};
getPathForHost = function(host) {
return hostPathMap[host];
};
extensionInfoMap = {};
getExtensionInfoFromPath = function(srcDirectory) {
var manifest, page;
manifest = JSON.parse(fs.readFileSync(path.join(srcDirectory, 'manifest.json')));
if (extensionInfoMap[manifest.name] == null) {
page = url.format({
protocol: 'chrome-extension',
slashes: true,
hostname: getHostForPath(srcDirectory),
pathname: manifest.devtools_page
});
extensionInfoMap[manifest.name] = {
startPage: page,
name: manifest.name,
srcDirectory: srcDirectory,
exposeExperimentalAPIs: true
};
return extensionInfoMap[manifest.name];
}
};
loadedExtensions = null;
loadedExtensionsPath = null;
app.on('will-quit', function() {
var e, error1, error2;
try {
loadedExtensions = Object.keys(extensionInfoMap).map(function(key) {
return extensionInfoMap[key].srcDirectory;
});
try {
fs.mkdirSync(path.dirname(loadedExtensionsPath));
} catch (error1) {
e = error1;
}
return fs.writeFileSync(loadedExtensionsPath, JSON.stringify(loadedExtensions));
} catch (error2) {
e = error2;
}
});
app.once('ready', function() {
var BrowserWindow, chromeExtensionHandler, e, error1, i, init, len, protocol, srcDirectory;
protocol = require('protocol');
BrowserWindow = require('browser-window');
loadedExtensionsPath = path.join(app.getDataPath(), 'DevTools Extensions');
try {
loadedExtensions = JSON.parse(fs.readFileSync(loadedExtensionsPath));
if (!Array.isArray(loadedExtensions)) {
loadedExtensions = [];
}
for (i = 0, len = loadedExtensions.length; i < len; i++) {
srcDirectory = loadedExtensions[i];
getExtensionInfoFromPath(srcDirectory);
}
} catch (error1) {
e = error1;
}
chromeExtensionHandler = function(request, callback) {
var directory, parsed;
parsed = url.parse(request.url);
if (!(parsed.hostname && (parsed.path != null))) {
return callback();
}
if (!/extension-\d+/.test(parsed.hostname)) {
return callback();
}
directory = getPathForHost(parsed.hostname);
if (directory == null) {
return callback();
}
return callback(path.join(directory, parsed.path));
};
protocol.registerFileProtocol('chrome-extension', chromeExtensionHandler, function(error) {
if (error) {
return console.error('Unable to register chrome-extension protocol');
}
});
BrowserWindow.prototype._loadDevToolsExtensions = function(extensionInfoArray) {
var ref;
return (ref = this.devToolsWebContents) != null ? ref.executeJavaScript("DevToolsAPI.addExtensions(" + (JSON.stringify(extensionInfoArray)) + ");") : void 0;
};
BrowserWindow.addDevToolsExtension = function(srcDirectory) {
var extensionInfo, j, len1, ref, window;
extensionInfo = getExtensionInfoFromPath(srcDirectory);
if (extensionInfo) {
ref = BrowserWindow.getAllWindows();
for (j = 0, len1 = ref.length; j < len1; j++) {
window = ref[j];
window._loadDevToolsExtensions([extensionInfo]);
}
return extensionInfo.name;
}
};
BrowserWindow.removeDevToolsExtension = function(name) {
return delete extensionInfoMap[name];
};
init = BrowserWindow.prototype._init;
return BrowserWindow.prototype._init = function() {
init.call(this);
return this.on('devtools-opened', function() {
return this._loadDevToolsExtensions(Object.keys(extensionInfoMap).map(function(key) {
return extensionInfoMap[key];
}));
});
};
});
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var attachGuest, createGuest, destroyGuest, embedderElementsMap, getNextInstanceId, guestInstances, ipc, moveLastToFirst, nextInstanceId, reverseEmbedderElementsMap, supportedWebViewEvents, webContents, webViewManager,
slice = [].slice;
ipc = require('ipc');
webContents = require('web-contents');
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', 'new-window', 'close', 'crashed', 'gpu-crashed', 'plugin-crashed', 'destroyed', 'page-title-set', 'page-favicon-updated', 'enter-html-full-screen', 'leave-html-full-screen'];
nextInstanceId = 0;
guestInstances = {};
embedderElementsMap = {};
reverseEmbedderElementsMap = {};
moveLastToFirst = function(list) {
return list.unshift(list.pop());
};
getNextInstanceId = function(webContents) {
return ++nextInstanceId;
};
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');
}
id = getNextInstanceId(embedder);
guest = webContents.create({
isGuest: true,
partition: params.partition,
embedder: embedder
});
guestInstances[id] = {
guest: guest,
embedder: embedder
};
destroyEvents = ['destroyed', 'crashed', 'did-navigate-to-different-page'];
destroy = function() {
if (guestInstances[id] != null) {
return destroyGuest(embedder, id);
}
};
for (i = 0, len = destroyEvents.length; i < len; i++) {
event = destroyEvents[i];
embedder.once(event, destroy);
listeners = embedder._events[event];
if (Array.isArray(listeners)) {
moveLastToFirst(listeners);
}
}
guest.once('destroyed', function() {
var j, len1, results;
results = [];
for (j = 0, len1 = destroyEvents.length; j < len1; j++) {
event = destroyEvents[j];
results.push(embedder.removeListener(event, destroy));
}
return results;
});
guest.once('did-attach', function() {
var opts;
params = this.attachParams;
delete this.attachParams;
this.viewInstanceId = params.instanceId;
this.setSize({
normal: {
width: params.elementWidth,
height: params.elementHeight
},
enableAutoSize: params.autosize,
min: {
width: params.minwidth,
height: params.minheight
},
max: {
width: params.maxwidth,
height: params.maxheight
}
});
if (params.src) {
opts = {};
if (params.httpreferrer) {
opts.httpReferrer = params.httpreferrer;
}
if (params.useragent) {
opts.userAgent = params.useragent;
}
this.loadUrl(params.src, opts);
}
if (params.allowtransparency != null) {
this.setAllowTransparency(params.allowtransparency);
}
return guest.allowPopups = params.allowpopups;
});
fn = function(event) {
return guest.on(event, function() {
var _, args;
_ = arguments[0], 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)));
});
};
for (j = 0, len1 = supportedWebViewEvents.length; j < len1; j++) {
event = supportedWebViewEvents[j];
fn(event);
}
guest.on('ipc-message-host', function(_, packed) {
var args, channel;
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(slice.call(args)));
});
guest.on('size-changed', function() {
var _, args;
_ = arguments[0], 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)));
});
return id;
};
attachGuest = function(embedder, elementInstanceId, guestInstanceId, params) {
var guest, key, oldGuestInstanceId, ref, webPreferences;
guest = guestInstances[guestInstanceId].guest;
key = (embedder.getId()) + "-" + elementInstanceId;
oldGuestInstanceId = embedderElementsMap[key];
if (oldGuestInstanceId != null) {
if (oldGuestInstanceId === guestInstanceId) {
return;
}
if (guestInstances[oldGuestInstanceId] == null) {
return;
}
destroyGuest(embedder, oldGuestInstanceId);
}
webPreferences = {
'guest-instance-id': guestInstanceId,
'node-integration': (ref = params.nodeintegration) != null ? ref : false,
'plugins': params.plugins,
'web-security': !params.disablewebsecurity
};
if (params.preload) {
webPreferences['preload-url'] = params.preload;
}
webViewManager.addGuest(guestInstanceId, elementInstanceId, embedder, guest, webPreferences);
guest.attachParams = params;
embedderElementsMap[key] = guestInstanceId;
return reverseEmbedderElementsMap[guestInstanceId] = key;
};
destroyGuest = function(embedder, id) {
var key;
webViewManager.removeGuest(embedder, id);
guestInstances[id].guest.destroy();
delete guestInstances[id];
key = reverseEmbedderElementsMap[id];
if (key != null) {
delete reverseEmbedderElementsMap[id];
return delete embedderElementsMap[key];
}
};
ipc.on('ATOM_SHELL_GUEST_VIEW_MANAGER_CREATE_GUEST', function(event, params, requestId) {
return event.sender.send("ATOM_SHELL_RESPONSE_" + requestId, createGuest(event.sender, params));
});
ipc.on('ATOM_SHELL_GUEST_VIEW_MANAGER_ATTACH_GUEST', function(event, elementInstanceId, guestInstanceId, params) {
return attachGuest(event.sender, elementInstanceId, guestInstanceId, params);
});
ipc.on('ATOM_SHELL_GUEST_VIEW_MANAGER_DESTROY_GUEST', function(event, id) {
return destroyGuest(event.sender, id);
});
ipc.on('ATOM_SHELL_GUEST_VIEW_MANAGER_SET_SIZE', function(event, id, params) {
var ref;
return (ref = guestInstances[id]) != null ? ref.guest.setSize(params) : void 0;
});
ipc.on('ATOM_SHELL_GUEST_VIEW_MANAGER_SET_ALLOW_TRANSPARENCY', function(event, id, allowtransparency) {
var ref;
return (ref = guestInstances[id]) != null ? ref.guest.setAllowTransparency(allowtransparency) : void 0;
});
exports.getGuest = function(id) {
var ref;
return (ref = guestInstances[id]) != null ? ref.guest : void 0;
};
exports.getEmbedder = function(id) {
var ref;
return (ref = guestInstances[id]) != null ? ref.embedder : void 0;
};
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var BrowserWindow, createGuest, frameToGuest, ipc, mergeBrowserWindowOptions, v8Util,
slice = [].slice;
ipc = require('ipc');
v8Util = process.atomBinding('v8_util');
BrowserWindow = require('browser-window');
frameToGuest = {};
mergeBrowserWindowOptions = function(embedder, options) {
if (embedder.browserWindowOptions != null) {
options.__proto__ = embedder.browserWindowOptions;
} else {
if (options['web-preferences'] == null) {
options['web-preferences'] = {};
}
options['web-preferences'].__proto__ = embedder.getWebPreferences();
}
return options;
};
createGuest = function(embedder, url, frameName, options) {
var closedByEmbedder, closedByUser, guest;
guest = frameToGuest[frameName];
if (frameName && (guest != null)) {
guest.loadUrl(url);
return guest.id;
}
guest = new BrowserWindow(options);
guest.loadUrl(url);
v8Util.setHiddenValue(guest.webContents, 'embedder', embedder);
closedByEmbedder = function() {
guest.removeListener('closed', closedByUser);
return guest.destroy();
};
closedByUser = function() {
embedder.send('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSED', guest.id);
return embedder.removeListener('render-view-deleted', closedByEmbedder);
};
embedder.once('render-view-deleted', closedByEmbedder);
guest.once('closed', closedByUser);
if (frameName) {
frameToGuest[frameName] = guest;
guest.frameName = frameName;
guest.once('closed', function() {
return delete frameToGuest[frameName];
});
}
return guest.id;
};
ipc.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) : [];
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);
if ((event.sender.isGuest() && !event.sender.allowPopups) || event.defaultPrevented) {
return event.returnValue = null;
} else {
return event.returnValue = createGuest(event.sender, url, frameName, options);
}
});
ipc.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', function(event, guestId) {
var ref;
return (ref = BrowserWindow.fromId(guestId)) != null ? ref.destroy() : void 0;
});
ipc.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', function() {
var args, event, guestId, method, ref;
event = arguments[0], guestId = arguments[1], method = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : [];
return (ref = BrowserWindow.fromId(guestId)) != null ? ref[method].apply(ref, args) : void 0;
});
ipc.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', function(event, guestId, message, targetOrigin) {
var guestContents, ref;
guestContents = (ref = BrowserWindow.fromId(guestId)) != null ? ref.webContents : void 0;
if ((guestContents != null ? guestContents.getUrl().indexOf(targetOrigin) : void 0) === 0 || targetOrigin === '*') {
return guestContents.send('ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', guestId, message, targetOrigin);
}
});
ipc.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPENER_POSTMESSAGE', function(event, guestId, message, targetOrigin, sourceOrigin) {
var embedder;
embedder = v8Util.getHiddenValue(event.sender, 'embedder');
if ((embedder != null ? embedder.getUrl().indexOf(targetOrigin) : void 0) === 0 || targetOrigin === '*') {
return embedder.send('ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', guestId, message, sourceOrigin);
}
});
ipc.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', function() {
var args, event, guestId, method, ref, ref1;
event = arguments[0], guestId = arguments[1], method = arguments[2], args = 4 <= arguments.length ? slice.call(arguments, 3) : [];
return (ref = BrowserWindow.fromId(guestId)) != null ? (ref1 = ref.webContents) != null ? ref1[method].apply(ref1, args) : void 0 : void 0;
});
ipc.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_GET_GUEST_ID', function(event) {
var embedder, guest;
embedder = v8Util.getHiddenValue(event.sender, 'embedder');
if (embedder != null) {
guest = BrowserWindow.fromWebContents(event.sender);
if (guest != null) {
event.returnValue = guest.id;
return;
}
}
return event.returnValue = null;
});
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var Module, Readable, app, consoleLog, e, error1, fs, globalPaths, i, len, mainStartupScript, packageJson, packagePath, path, searchPaths, stdin, streamWrite, util,
slice = [].slice;
fs = require('fs');
path = require('path');
util = require('util');
Module = require('module');
process.argv.splice(1, 1);
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths'));
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init'));
globalPaths = Module.globalPaths;
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib'));
if (process.platform === 'win32') {
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) {
if (Buffer.isBuffer(chunk)) {
chunk = chunk.toString(encoding);
}
process.log(chunk);
if (callback) {
callback();
}
return true;
};
console.log = console.error = console.warn = consoleLog;
process.stdout.write = process.stderr.write = streamWrite;
Readable = require('stream').Readable;
stdin = new Readable;
stdin.push(null);
process.__defineGetter__('stdin', function() {
return stdin;
});
}
process.on('uncaughtException', function(error) {
var message, ref, stack;
if (process.listeners('uncaughtException').length > 1) {
return;
}
stack = (ref = error.stack) != null ? ref : error.name + ": " + error.message;
message = "Uncaught Exception:\n" + stack;
return require('dialog').showErrorBox('A JavaScript error occurred in the main process', message);
});
app = require('app');
app.on('quit', function() {
return process.emit('exit');
});
require('./rpc-server');
require('./guest-view-manager');
require('./guest-window-manager');
packageJson = null;
searchPaths = ['app', 'app.asar', 'default_app'];
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;
continue;
}
}
if (packageJson == null) {
process.nextTick(function() {
return process.exit(1);
});
throw new Error("Unable to find a valid app");
}
if (packageJson.version != null) {
app.setVersion(packageJson.version);
}
if (packageJson.productName != null) {
app.setName(packageJson.productName);
} else if (packageJson.name != null) {
app.setName(packageJson.name);
}
if (packageJson.desktopName != null) {
app.setDesktopName(packageJson.desktopName);
} else {
app.setDesktopName((app.getName()) + ".desktop");
}
app.commandLine.appendSwitch('enable-npapi');
app.setPath('userData', path.join(app.getPath('appData'), app.getName()));
app.setPath('userCache', path.join(app.getPath('cache'), app.getName()));
app.setAppPath(packagePath);
require('./chrome-extension');
mainStartupScript = packageJson.main || 'index.js';
Module._load(path.join(packagePath, mainStartupScript), Module, true);
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
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;
EventEmitter = require('events').EventEmitter;
v8Util = process.atomBinding('v8_util');
ObjectsRegistry = (function(superClass) {
extend(ObjectsRegistry, superClass);
function ObjectsRegistry() {
this.setMaxListeners(Number.MAX_VALUE);
this.nextId = 0;
this.storage = {};
this.owners = {};
}
ObjectsRegistry.prototype.add = function(webContentsId, obj) {
var base, base1, id;
id = this.saveToStorage(obj);
if ((base = this.owners)[webContentsId] == null) {
base[webContentsId] = {};
}
if ((base1 = this.owners[webContentsId])[id] == null) {
base1[id] = 0;
}
this.owners[webContentsId][id]++;
return id;
};
ObjectsRegistry.prototype.get = function(id) {
var ref;
return (ref = this.storage[id]) != null ? ref.object : void 0;
};
ObjectsRegistry.prototype.remove = function(webContentsId, id) {
var pointer;
this.dereference(id, 1);
pointer = this.owners[webContentsId];
if (pointer == null) {
return;
}
--pointer[id];
if (pointer[id] === 0) {
return delete pointer[id];
}
};
ObjectsRegistry.prototype.clear = function(webContentsId) {
var count, id, ref;
this.emit("clear-" + webContentsId);
if (this.owners[webContentsId] == null) {
return;
}
ref = this.owners[webContentsId];
for (id in ref) {
count = ref[id];
this.dereference(id, count);
}
return delete this.owners[webContentsId];
};
ObjectsRegistry.prototype.saveToStorage = function(object) {
var id;
id = v8Util.getHiddenValue(object, 'atomId');
if (!id) {
id = ++this.nextId;
this.storage[id] = {
count: 0,
object: object
};
v8Util.setHiddenValue(object, 'atomId', id);
}
++this.storage[id].count;
return id;
};
ObjectsRegistry.prototype.dereference = function(id, count) {
var pointer;
pointer = this.storage[id];
if (pointer == null) {
return;
}
pointer.count -= count;
if (pointer.count === 0) {
v8Util.deleteHiddenValue(pointer.object, 'atomId');
return delete this.storage[id];
}
};
return ObjectsRegistry;
})(EventEmitter);
module.exports = new ObjectsRegistry;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var callFunction, exceptionToMeta, ipc, objectsRegistry, path, unwrapArgs, v8Util, valueToMeta;
ipc = require('ipc');
path = require('path');
objectsRegistry = require('./objects-registry.js');
v8Util = process.atomBinding('v8_util');
valueToMeta = function(sender, value, optimizeSimpleObject) {
var el, field, i, len, meta, prop;
if (optimizeSimpleObject == null) {
optimizeSimpleObject = false;
}
meta = {
type: typeof value
};
if (Buffer.isBuffer(value)) {
meta.type = 'buffer';
}
if (value === null) {
meta.type = 'value';
}
if (Array.isArray(value)) {
meta.type = 'array';
}
if (value instanceof Error) {
meta.type = 'error';
}
if (value instanceof Date) {
meta.type = 'date';
}
if ((value != null) && value.constructor.name === 'Promise') {
meta.type = 'promise';
}
if (optimizeSimpleObject && meta.type === 'object' && v8Util.getHiddenValue(value, 'simple')) {
meta.type = 'value';
}
if (meta.type === 'object' && (value.callee != null) && (value.length != null)) {
meta.type = 'array';
}
if (meta.type === 'array') {
meta.members = [];
for (i = 0, len = value.length; i < len; i++) {
el = value[i];
meta.members.push(valueToMeta(sender, el));
}
} else if (meta.type === 'object' || meta.type === 'function') {
meta.name = value.constructor.name;
meta.id = objectsRegistry.add(sender.getId(), value);
meta.members = [];
for (prop in value) {
field = value[prop];
meta.members.push({
name: prop,
type: typeof field
});
}
} else if (meta.type === 'buffer') {
meta.value = Array.prototype.slice.call(value, 0);
} else if (meta.type === 'promise') {
meta.then = valueToMeta(sender, value.then.bind(value));
} else if (meta.type === 'error') {
meta.message = value.message;
} else if (meta.type === 'date') {
meta.value = value.getTime();
} else {
meta.type = 'value';
meta.value = value;
}
return meta;
};
exceptionToMeta = function(error) {
return {
type: 'exception',
message: error.message,
stack: error.stack || error
};
};
unwrapArgs = function(sender, args) {
var metaToValue;
metaToValue = function(meta) {
var i, len, member, ref, rendererReleased, ret, returnValue;
switch (meta.type) {
case 'value':
return meta.value;
case 'remote-object':
return objectsRegistry.get(meta.id);
case 'array':
return unwrapArgs(sender, meta.value);
case 'buffer':
return new Buffer(meta.value);
case 'promise':
return Promise.resolve({
then: metaToValue(meta.then)
});
case 'object':
ret = v8Util.createObjectWithName(meta.name);
ref = meta.members;
for (i = 0, len = ref.length; i < len; i++) {
member = ref[i];
ret[member.name] = metaToValue(member.value);
}
return ret;
case 'function-with-return-value':
returnValue = metaToValue(meta.value);
return function() {
return returnValue;
};
case 'function':
rendererReleased = false;
objectsRegistry.once("clear-" + (sender.getId()), function() {
return rendererReleased = true;
});
ret = function() {
if (rendererReleased) {
throw new Error("Attempting to call a function in a renderer window that has been closed or released. Function provided here: " + meta.id + ".");
}
return sender.send('ATOM_RENDERER_CALLBACK', meta.id, valueToMeta(sender, arguments));
};
v8Util.setDestructor(ret, function() {
if (rendererReleased) {
return;
}
return sender.send('ATOM_RENDERER_RELEASE_CALLBACK', meta.id);
});
return ret;
default:
throw new TypeError("Unknown type: " + meta.type);
}
};
return args.map(metaToValue);
};
callFunction = function(event, func, caller, args) {
var ret;
if (v8Util.getHiddenValue(func, 'asynchronous') && typeof args[args.length - 1] !== 'function') {
args.push(function(ret) {
return event.returnValue = valueToMeta(event.sender, ret, true);
});
return func.apply(caller, args);
} else {
ret = func.apply(caller, args);
return event.returnValue = valueToMeta(event.sender, ret, true);
}
};
process.on('ATOM_BROWSER_RELEASE_RENDER_VIEW', function(id) {
return objectsRegistry.clear(id);
});
ipc.on('ATOM_BROWSER_REQUIRE', function(event, module) {
var e, error1;
try {
return event.returnValue = valueToMeta(event.sender, process.mainModule.require(module));
} catch (error1) {
e = error1;
return event.returnValue = exceptionToMeta(e);
}
});
ipc.on('ATOM_BROWSER_GLOBAL', function(event, name) {
var e, error1;
try {
return event.returnValue = valueToMeta(event.sender, global[name]);
} catch (error1) {
e = error1;
return event.returnValue = exceptionToMeta(e);
}
});
ipc.on('ATOM_BROWSER_CURRENT_WINDOW', function(event) {
var e, error1;
try {
return event.returnValue = valueToMeta(event.sender, event.sender.getOwnerBrowserWindow());
} catch (error1) {
e = error1;
return event.returnValue = exceptionToMeta(e);
}
});
ipc.on('ATOM_BROWSER_CURRENT_WEB_CONTENTS', function(event) {
return event.returnValue = valueToMeta(event.sender, event.sender);
});
ipc.on('ATOM_BROWSER_CONSTRUCTOR', function(event, id, args) {
var constructor, e, error1, obj;
try {
args = unwrapArgs(event.sender, args);
constructor = objectsRegistry.get(id);
obj = new (Function.prototype.bind.apply(constructor, [null].concat(args)));
return event.returnValue = valueToMeta(event.sender, obj);
} catch (error1) {
e = error1;
return event.returnValue = exceptionToMeta(e);
}
});
ipc.on('ATOM_BROWSER_FUNCTION_CALL', function(event, id, args) {
var e, error1, func;
try {
args = unwrapArgs(event.sender, args);
func = objectsRegistry.get(id);
return callFunction(event, func, global, args);
} catch (error1) {
e = error1;
return event.returnValue = exceptionToMeta(e);
}
});
ipc.on('ATOM_BROWSER_MEMBER_CONSTRUCTOR', function(event, id, method, args) {
var constructor, e, error1, obj;
try {
args = unwrapArgs(event.sender, args);
constructor = objectsRegistry.get(id)[method];
obj = new (Function.prototype.bind.apply(constructor, [null].concat(args)));
return event.returnValue = valueToMeta(event.sender, obj);
} catch (error1) {
e = error1;
return event.returnValue = exceptionToMeta(e);
}
});
ipc.on('ATOM_BROWSER_MEMBER_CALL', function(event, id, method, args) {
var e, error1, obj;
try {
args = unwrapArgs(event.sender, args);
obj = objectsRegistry.get(id);
return callFunction(event, obj[method], obj, args);
} catch (error1) {
e = error1;
return event.returnValue = exceptionToMeta(e);
}
});
ipc.on('ATOM_BROWSER_MEMBER_SET', function(event, id, name, value) {
var e, error1, obj;
try {
obj = objectsRegistry.get(id);
obj[name] = value;
return event.returnValue = null;
} catch (error1) {
e = error1;
return event.returnValue = exceptionToMeta(e);
}
});
ipc.on('ATOM_BROWSER_MEMBER_GET', function(event, id, name) {
var e, error1, obj;
try {
obj = objectsRegistry.get(id);
return event.returnValue = valueToMeta(event.sender, obj[name]);
} catch (error1) {
e = error1;
return event.returnValue = exceptionToMeta(e);
}
});
ipc.on('ATOM_BROWSER_DEREFERENCE', function(event, id) {
return objectsRegistry.remove(event.sender.getId(), id);
});
ipc.on('ATOM_BROWSER_GUEST_WEB_CONTENTS', function(event, guestInstanceId) {
var e, error1, guestViewManager;
try {
guestViewManager = require('./guest-view-manager');
return event.returnValue = valueToMeta(event.sender, guestViewManager.getGuest(guestInstanceId));
} catch (error1) {
e = error1;
return event.returnValue = exceptionToMeta(e);
}
});
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var CallbacksRegistry,
slice = [].slice;
module.exports = CallbacksRegistry = (function() {
function CallbacksRegistry() {
this.nextId = 0;
this.callbacks = {};
}
CallbacksRegistry.prototype.add = function(callback) {
var filenameAndLine, id, location, match, ref, regexp, stackString, x;
id = ++this.nextId;
regexp = /at (.*)/gi;
stackString = (new Error).stack;
while ((match = regexp.exec(stackString)) !== null) {
x = match[0], location = match[1];
if (location.indexOf('(native)') !== -1) {
continue;
}
if (location.indexOf('atom.asar') !== -1) {
continue;
}
ref = /([^\/^\)]*)\)?$/gi.exec(location), x = ref[0], filenameAndLine = ref[1];
id = filenameAndLine + " (" + id + ")";
break;
}
this.callbacks[id] = callback;
return id;
};
CallbacksRegistry.prototype.get = function(id) {
var ref;
return (ref = this.callbacks[id]) != null ? ref : function() {};
};
CallbacksRegistry.prototype.call = function() {
var args, id, ref;
id = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
return (ref = this.get(id)).call.apply(ref, [global].concat(slice.call(args)));
};
CallbacksRegistry.prototype.apply = function() {
var args, id, ref;
id = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
return (ref = this.get(id)).apply.apply(ref, [global].concat(slice.call(args)));
};
CallbacksRegistry.prototype.remove = function(id) {
return delete this.callbacks[id];
};
return CallbacksRegistry;
})();
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
if (process.platform === 'linux' && process.type === 'renderer') {
module.exports = require('remote').require('clipboard');
} else {
module.exports = process.atomBinding('clipboard');
}
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var CrashReporter, binding, crashRepoter, fs, os, path, spawn;
binding = process.atomBinding('crash_reporter');
fs = require('fs');
os = require('os');
path = require('path');
spawn = require('child_process').spawn;
CrashReporter = (function() {
function CrashReporter() {}
CrashReporter.prototype.start = function(options) {
var app, args, autoSubmit, companyName, env, extra, ignoreSystemCrashHandler, start, submitUrl;
if (options == null) {
options = {};
}
this.productName = options.productName, companyName = options.companyName, submitUrl = options.submitUrl, autoSubmit = options.autoSubmit, ignoreSystemCrashHandler = options.ignoreSystemCrashHandler, extra = options.extra;
app = process.type === 'browser' ? require('app') : require('remote').require('app');
if (this.productName == null) {
this.productName = app.getName();
}
if (companyName == null) {
companyName = 'GitHub, Inc';
}
if (submitUrl == null) {
submitUrl = 'http://54.249.141.255:1127/post';
}
if (autoSubmit == null) {
autoSubmit = true;
}
if (ignoreSystemCrashHandler == null) {
ignoreSystemCrashHandler = false;
}
if (extra == null) {
extra = {};
}
if (extra._productName == null) {
extra._productName = this.productName;
}
if (extra._companyName == null) {
extra._companyName = companyName;
}
if (extra._version == null) {
extra._version = app.getVersion();
}
start = (function(_this) {
return function() {
return binding.start(_this.productName, companyName, submitUrl, autoSubmit, ignoreSystemCrashHandler, extra);
};
})(this);
if (process.platform === 'win32') {
args = ["--reporter-url=" + submitUrl, "--application-name=" + this.productName, "--v=1"];
env = {
ATOM_SHELL_INTERNAL_CRASH_SERVICE: 1
};
spawn(process.execPath, args, {
env: env,
detached: true
});
return start();
} else {
return start();
}
};
CrashReporter.prototype.getLastCrashReport = function() {
var reports;
reports = this.getUploadedReports();
if (reports.length > 0) {
return reports[0];
} else {
return null;
}
};
CrashReporter.prototype.getUploadedReports = function() {
var log, tmpdir;
tmpdir = process.platform === 'win32' ? os.tmpdir() : '/tmp';
log = process.platform === 'darwin' ? path.join(tmpdir, this.productName + " Crashes") : path.join(tmpdir, this.productName + " Crashes", 'uploads.log');
return binding._getUploadedReports(log);
};
return CrashReporter;
})();
crashRepoter = new CrashReporter;
module.exports = crashRepoter;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
module.exports = process.atomBinding('native_image');
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
module.exports = process.atomBinding('shell');
if (process.platform === 'win32' && process.type === 'renderer') {
module.exports.showItemInFolder = require('remote').process.atomBinding('shell').showItemInFolder;
}
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var Module, fs, path, timers, wrapWithActivateUvLoop;
fs = require('fs');
path = require('path');
timers = require('timers');
Module = require('module');
process.atomBinding = function(name) {
var e, error;
try {
return process.binding("atom_" + process.type + "_" + name);
} catch (error) {
e = error;
if (/No such module/.test(e.message)) {
return process.binding("atom_common_" + name);
}
}
};
Module.globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib'));
wrapWithActivateUvLoop = function(func) {
return function() {
process.activateUvLoop();
return func.apply(this, arguments);
};
};
process.nextTick = wrapWithActivateUvLoop(process.nextTick);
global.setImmediate = wrapWithActivateUvLoop(timers.setImmediate);
global.clearImmediate = timers.clearImmediate;
if (process.type === 'browser') {
global.setTimeout = wrapWithActivateUvLoop(timers.setTimeout);
global.setInterval = wrapWithActivateUvLoop(timers.setInterval);
}
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var Module, path;
path = require('path');
Module = require('module');
Module.globalPaths.length = 0;
module.paths = [];
module.parent.paths = [];
Module._nodeModulePaths = function(from) {
var dir, i, part, parts, paths, skipOutsidePaths, splitRe, tip;
from = path.resolve(from);
skipOutsidePaths = from.startsWith(process.resourcesPath);
splitRe = process.platform === 'win32' ? /[\/\\]/ : /\//;
paths = [];
parts = from.split(splitRe);
for (tip = i = parts.length - 1; i >= 0; tip = i += -1) {
part = parts[tip];
if (part === 'node_modules') {
continue;
}
dir = parts.slice(0, tip + 1).join(path.sep);
if (skipOutsidePaths && !dir.startsWith(process.resourcesPath)) {
break;
}
paths.push(path.join(dir, 'node_modules'));
}
return paths;
};
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var binding, ipc, v8Util,
slice = [].slice;
binding = process.atomBinding('ipc');
v8Util = process.atomBinding('v8_util');
ipc = v8Util.getHiddenValue(global, 'ipc');
ipc.send = function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return binding.send('ipc-message', slice.call(args));
};
ipc.sendSync = function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return JSON.parse(binding.sendSync('ipc-message-sync', slice.call(args)));
};
ipc.sendToHost = function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return binding.send('ipc-message-host', slice.call(args));
};
ipc.sendChannel = ipc.send;
ipc.sendChannelSync = ipc.sendSync;
module.exports = ipc;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var CallbacksRegistry, callbacksRegistry, ipc, isCircular, metaToValue, moduleCache, processCache, v8Util, webContentsCache, windowCache, wrapArgs,
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; };
ipc = require('ipc');
v8Util = process.atomBinding('v8_util');
CallbacksRegistry = require('callbacks-registry');
callbacksRegistry = new CallbacksRegistry;
isCircular = function(field, visited) {
if (typeof field === 'object') {
if (indexOf.call(visited, field) >= 0) {
return true;
}
visited.push(field);
}
return false;
};
wrapArgs = function(args, visited) {
var valueToMeta;
if (visited == null) {
visited = [];
}
valueToMeta = function(value) {
var field, prop, ret;
if (Array.isArray(value)) {
return {
type: 'array',
value: wrapArgs(value, visited)
};
} else if (Buffer.isBuffer(value)) {
return {
type: 'buffer',
value: Array.prototype.slice.call(value, 0)
};
} else if ((value != null) && value.constructor.name === 'Promise') {
return {
type: 'promise',
then: valueToMeta(value.then.bind(value))
};
} else if ((value != null) && typeof value === 'object' && v8Util.getHiddenValue(value, 'atomId')) {
return {
type: 'remote-object',
id: v8Util.getHiddenValue(value, 'atomId')
};
} else if ((value != null) && typeof value === 'object') {
ret = {
type: 'object',
name: value.constructor.name,
members: []
};
for (prop in value) {
field = value[prop];
ret.members.push({
name: prop,
value: valueToMeta(isCircular(field, visited) ? null : field)
});
}
return ret;
} else if (typeof value === 'function' && v8Util.getHiddenValue(value, 'returnValue')) {
return {
type: 'function-with-return-value',
value: valueToMeta(value())
};
} else if (typeof value === 'function') {
return {
type: 'function',
id: callbacksRegistry.add(value)
};
} else {
return {
type: 'value',
value: value
};
}
};
return Array.prototype.slice.call(args).map(valueToMeta);
};
metaToValue = function(meta) {
var RemoteFunction, el, fn, i, j, len, len1, member, ref, ref1, results, ret;
switch (meta.type) {
case 'value':
return meta.value;
case 'array':
ref = meta.members;
results = [];
for (i = 0, len = ref.length; i < len; i++) {
el = ref[i];
results.push(metaToValue(el));
}
return results;
case 'buffer':
return new Buffer(meta.value);
case 'promise':
return Promise.resolve({
then: metaToValue(meta.then)
});
case 'error':
return new Error(meta.message);
case 'date':
return new Date(meta.value);
case 'exception':
throw new Error(meta.message + "\n" + meta.stack);
break;
default:
if (meta.type === 'function') {
ret = RemoteFunction = (function() {
function RemoteFunction() {
var obj;
if (this.constructor === RemoteFunction) {
obj = ipc.sendSync('ATOM_BROWSER_CONSTRUCTOR', meta.id, wrapArgs(arguments));
return metaToValue(obj);
} else {
ret = ipc.sendSync('ATOM_BROWSER_FUNCTION_CALL', meta.id, wrapArgs(arguments));
return metaToValue(ret);
}
}
return RemoteFunction;
})();
} else {
ret = v8Util.createObjectWithName(meta.name);
}
ref1 = meta.members;
fn = function(member) {
var RemoteMemberFunction;
if (member.type === 'function') {
return ret[member.name] = RemoteMemberFunction = (function() {
function RemoteMemberFunction() {
var obj;
if (this.constructor === RemoteMemberFunction) {
obj = ipc.sendSync('ATOM_BROWSER_MEMBER_CONSTRUCTOR', meta.id, member.name, wrapArgs(arguments));
return metaToValue(obj);
} else {
ret = ipc.sendSync('ATOM_BROWSER_MEMBER_CALL', meta.id, member.name, wrapArgs(arguments));
return metaToValue(ret);
}
}
return RemoteMemberFunction;
})();
} else {
return Object.defineProperty(ret, member.name, {
enumerable: true,
configurable: false,
set: function(value) {
ipc.sendSync('ATOM_BROWSER_MEMBER_SET', meta.id, member.name, value);
return value;
},
get: function() {
ret = ipc.sendSync('ATOM_BROWSER_MEMBER_GET', meta.id, member.name);
return metaToValue(ret);
}
});
}
};
for (j = 0, len1 = ref1.length; j < len1; j++) {
member = ref1[j];
fn(member);
}
v8Util.setDestructor(ret, function() {
return ipc.send('ATOM_BROWSER_DEREFERENCE', meta.id);
});
v8Util.setHiddenValue(ret, 'atomId', meta.id);
return ret;
}
};
ipc.on('ATOM_RENDERER_CALLBACK', function(id, args) {
return callbacksRegistry.apply(id, metaToValue(args));
});
ipc.on('ATOM_RENDERER_RELEASE_CALLBACK', function(id) {
return callbacksRegistry.remove(id);
});
moduleCache = {};
exports.require = function(module) {
var meta;
if (moduleCache[module] != null) {
return moduleCache[module];
}
meta = ipc.sendSync('ATOM_BROWSER_REQUIRE', module);
return moduleCache[module] = metaToValue(meta);
};
windowCache = null;
exports.getCurrentWindow = function() {
var meta;
if (windowCache != null) {
return windowCache;
}
meta = ipc.sendSync('ATOM_BROWSER_CURRENT_WINDOW');
return windowCache = metaToValue(meta);
};
webContentsCache = null;
exports.getCurrentWebContents = function() {
var meta;
if (webContentsCache != null) {
return webContentsCache;
}
meta = ipc.sendSync('ATOM_BROWSER_CURRENT_WEB_CONTENTS');
return webContentsCache = metaToValue(meta);
};
exports.getGlobal = function(name) {
var meta;
meta = ipc.sendSync('ATOM_BROWSER_GLOBAL', name);
return metaToValue(meta);
};
processCache = null;
exports.__defineGetter__('process', function() {
if (processCache == null) {
processCache = exports.getGlobal('process');
}
return processCache;
});
exports.createFunctionWithReturnValue = function(returnValue) {
var func;
func = function() {
return returnValue;
};
v8Util.setHiddenValue(func, 'returnValue', true);
return func;
};
exports.getGuestWebContents = function(guestInstanceId) {
var meta;
meta = ipc.sendSync('ATOM_BROWSER_GUEST_WEB_CONTENTS', guestInstanceId);
return metaToValue(meta);
};
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
module.exports = require('remote').require('screen');
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
module.exports = process.atomBinding('web_frame').webFrame;
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var chrome, url;
url = require('url');
chrome = window.chrome = window.chrome || {};
chrome.extension = {
getURL: function(path) {
return url.format({
protocol: location.protocol,
slashes: true,
hostname: location.hostname,
pathname: path
});
}
};
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var Module, arg, error, error1, events, globalPaths, i, len, nodeIntegration, path, pathname, preloadScript, ref, url, v8Util;
events = require('events');
path = require('path');
url = require('url');
Module = require('module');
process.argv.splice(1, 1);
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths'));
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init'));
globalPaths = Module.globalPaths;
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib'));
v8Util = process.atomBinding('v8_util');
v8Util.setHiddenValue(global, 'ipc', new events.EventEmitter);
nodeIntegration = 'false';
ref = process.argv;
for (i = 0, len = ref.length; i < len; i++) {
arg = ref[i];
if (arg.indexOf('--guest-instance-id=') === 0) {
process.guestInstanceId = parseInt(arg.substr(arg.indexOf('=') + 1));
} else if (arg.indexOf('--node-integration=') === 0) {
nodeIntegration = arg.substr(arg.indexOf('=') + 1);
} else if (arg.indexOf('--preload=') === 0) {
preloadScript = arg.substr(arg.indexOf('=') + 1);
}
}
if (location.protocol === 'chrome-devtools:') {
require('./inspector');
nodeIntegration = 'true';
} else if (location.protocol === 'chrome-extension:') {
require('./chrome-api');
nodeIntegration = 'true';
} else {
require('./override');
if (process.guestInstanceId == null) {
require('./web-view/web-view');
require('./web-view/web-view-attributes');
}
}
if (nodeIntegration === 'true' || nodeIntegration === 'all' || nodeIntegration === 'except-iframe' || nodeIntegration === 'manual-enable-iframe') {
global.require = require;
global.module = module;
if (window.location.protocol === 'file:') {
pathname = process.platform === 'win32' && window.location.pathname[0] === '/' ? window.location.pathname.substr(1) : window.location.pathname;
global.__filename = path.normalize(decodeURIComponent(pathname));
global.__dirname = path.dirname(global.__filename);
module.filename = global.__filename;
module.paths = module.paths.concat(Module._nodeModulePaths(global.__dirname));
} else {
global.__filename = __filename;
global.__dirname = __dirname;
}
window.onerror = function(message, filename, lineno, colno, error) {
if (global.process.listeners('uncaughtException').length > 0) {
global.process.emit('uncaughtException', error);
return true;
} else {
return false;
}
};
window.addEventListener('unload', function() {
return process.emit('exit');
});
} else {
process.once('loaded', function() {
delete global.process;
delete global.setImmediate;
delete global.clearImmediate;
return delete global.global;
});
}
if (preloadScript) {
try {
require(preloadScript);
} catch (error1) {
error = error1;
if (error.code === 'MODULE_NOT_FOUND') {
console.error("Unable to load preload script " + preloadScript);
} else {
console.error(error);
console.error(error.stack);
}
}
}
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var convertToMenuTemplate, createFileSelectorElement, createMenu, pathToHtml5FileObject, showFileChooserDialog;
window.onload = function() {
InspectorFrontendHost.showContextMenuAtPoint = createMenu;
return WebInspector.createFileSelectorElement = createFileSelectorElement;
};
convertToMenuTemplate = function(items) {
var fn, i, item, len, template;
template = [];
fn = function(item) {
var transformed;
transformed = item.type === 'subMenu' ? {
type: 'submenu',
label: item.label,
enabled: item.enabled,
submenu: convertToMenuTemplate(item.subItems)
} : item.type === 'separator' ? {
type: 'separator'
} : item.type === 'checkbox' ? {
type: 'checkbox',
label: item.label,
enabled: item.enabled,
checked: item.checked
} : {
type: 'normal',
label: item.label,
enabled: item.enabled
};
if (item.id != null) {
transformed.click = function() {
return DevToolsAPI.contextMenuItemSelected(item.id);
};
}
return template.push(transformed);
};
for (i = 0, len = items.length; i < len; i++) {
item = items[i];
fn(item);
}
return template;
};
createMenu = function(x, y, items, document) {
var Menu, menu, remote;
remote = require('remote');
Menu = remote.require('menu');
menu = Menu.buildFromTemplate(convertToMenuTemplate(items));
return setImmediate(function() {
menu.popup(remote.getCurrentWindow());
return DevToolsAPI.contextMenuCleared();
});
};
showFileChooserDialog = function(callback) {
var dialog, files, remote;
remote = require('remote');
dialog = remote.require('dialog');
files = dialog.showOpenDialog({});
if (files != null) {
return callback(pathToHtml5FileObject(files[0]));
}
};
pathToHtml5FileObject = function(path) {
var blob, fs;
fs = require('fs');
blob = new Blob([fs.readFileSync(path)]);
blob.name = path;
return blob;
};
createFileSelectorElement = function(callback) {
var fileSelectorElement;
fileSelectorElement = document.createElement('span');
fileSelectorElement.style.display = 'none';
fileSelectorElement.click = showFileChooserDialog.bind(this, callback);
return fileSelectorElement;
};
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var BrowserWindowProxy, a, getHistoryOperation, guestId, ipc, remote, resolveUrl, sendHistoryOperation,
slice = [].slice;
ipc = require('ipc');
remote = require('remote');
a = window.top.document.createElement('a');
resolveUrl = function(url) {
a.href = url;
return a.href;
};
BrowserWindowProxy = (function() {
function BrowserWindowProxy(guestId1) {
this.guestId = guestId1;
this.closed = false;
ipc.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSED', (function(_this) {
return function(guestId) {
if (guestId === _this.guestId) {
return _this.closed = true;
}
};
})(this));
}
BrowserWindowProxy.prototype.close = function() {
return ipc.send('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', this.guestId);
};
BrowserWindowProxy.prototype.focus = function() {
return ipc.send('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', this.guestId, 'focus');
};
BrowserWindowProxy.prototype.blur = function() {
return ipc.send('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', this.guestId, 'blur');
};
BrowserWindowProxy.prototype.postMessage = function(message, targetOrigin) {
if (targetOrigin == null) {
targetOrigin = '*';
}
return ipc.send('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', this.guestId, message, targetOrigin);
};
BrowserWindowProxy.prototype["eval"] = function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return ipc.send.apply(ipc, ['ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', this.guestId, 'executeJavaScript'].concat(slice.call(args)));
};
return BrowserWindowProxy;
})();
if (process.guestInstanceId == null) {
window.close = function() {
return remote.getCurrentWindow().close();
};
}
window.open = function(url, frameName, features) {
var arg, feature, guestId, i, ints, j, k, len, len1, len2, name, options, ref, ref1, ref2, value;
if (frameName == null) {
frameName = '';
}
if (features == null) {
features = '';
}
options = {};
ints = ['x', 'y', 'width', 'height', 'min-width', 'max-width', 'min-height', 'max-height', 'zoom-factor'];
ref = features.split(/,\s*/);
for (i = 0, len = ref.length; i < len; i++) {
feature = ref[i];
ref1 = feature.split(/\s*=/), name = ref1[0], value = ref1[1];
options[name] = value === 'yes' || value === '1' ? true : value === 'no' || value === '0' ? false : value;
}
if (options.left) {
if (options.x == null) {
options.x = options.left;
}
}
if (options.top) {
if (options.y == null) {
options.y = options.top;
}
}
if (options.title == null) {
options.title = frameName;
}
if (options.width == null) {
options.width = 800;
}
if (options.height == null) {
options.height = 600;
}
url = resolveUrl(url);
for (j = 0, len1 = ints.length; j < len1; j++) {
name = ints[j];
if (options[name] != null) {
options[name] = parseInt(options[name], 10);
}
}
if (options['node-integration'] == null) {
ref2 = process.argv;
for (k = 0, len2 = ref2.length; k < len2; k++) {
arg = ref2[k];
if (!(arg.indexOf('--node-integration=') === 0)) {
continue;
}
options['node-integration'] = arg.substr(-4) === 'true';
break;
}
}
guestId = ipc.sendSync('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', url, frameName, options);
if (guestId) {
return new BrowserWindowProxy(guestId);
} else {
return null;
}
};
window.alert = function(message, title) {
var buttons, dialog;
if (title == null) {
title = '';
}
dialog = remote.require('dialog');
buttons = ['OK'];
message = message.toString();
dialog.showMessageBox(remote.getCurrentWindow(), {
message: message,
title: title,
buttons: buttons
});
};
window.confirm = function(message, title) {
var buttons, cancelId, dialog;
if (title == null) {
title = '';
}
dialog = remote.require('dialog');
buttons = ['OK', 'Cancel'];
cancelId = 1;
return !dialog.showMessageBox(remote.getCurrentWindow(), {
message: message,
title: title,
buttons: buttons,
cancelId: cancelId
});
};
window.prompt = function() {
throw new Error('prompt() is and will not be supported.');
};
guestId = ipc.sendSync('ATOM_SHELL_GUEST_WINDOW_MANAGER_GET_GUEST_ID');
if (guestId != null) {
window.opener = {
postMessage: function(message, targetOrigin) {
if (targetOrigin == null) {
targetOrigin = '*';
}
return ipc.send('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPENER_POSTMESSAGE', guestId, message, targetOrigin, location.origin);
}
};
}
ipc.on('ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', function(guestId, message, sourceOrigin) {
var event;
event = document.createEvent('Event');
event.initEvent('message', false, false);
event.data = message;
event.origin = sourceOrigin;
event.source = new BrowserWindowProxy(guestId);
return window.dispatchEvent(event);
});
sendHistoryOperation = function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return ipc.send.apply(ipc, ['ATOM_SHELL_NAVIGATION_CONTROLLER'].concat(slice.call(args)));
};
getHistoryOperation = function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return ipc.sendSync.apply(ipc, ['ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER'].concat(slice.call(args)));
};
window.history.back = function() {
return sendHistoryOperation('goBack');
};
window.history.forward = function() {
return sendHistoryOperation('goForward');
};
window.history.go = function(offset) {
return sendHistoryOperation('goToOffset', offset);
};
Object.defineProperty(window.history, 'length', {
get: function() {
return getHistoryOperation('length');
}
});
Object.defineProperty(document, 'hidden', {
get: function() {
return !remote.getCurrentWindow().isVisible();
}
});
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var WEB_VIEW_EVENTS, dispatchEvent, ipc, requestId, webFrame,
slice = [].slice;
ipc = require('ipc');
webFrame = require('web-frame');
requestId = 0;
WEB_VIEW_EVENTS = {
'load-commit': ['url', 'isMainFrame'],
'did-finish-load': [],
'did-fail-load': ['errorCode', 'errorDescription', 'validatedUrl'],
'did-frame-finish-load': ['isMainFrame'],
'did-start-loading': [],
'did-stop-loading': [],
'did-get-response-details': ['status', 'newUrl', 'originalUrl', 'httpResponseCode', 'requestMethod', 'referrer', 'headers'],
'did-get-redirect-request': ['oldUrl', 'newUrl', 'isMainFrame'],
'dom-ready': [],
'console-message': ['level', 'message', 'line', 'sourceId'],
'new-window': ['url', 'frameName', 'disposition', 'options'],
'close': [],
'crashed': [],
'gpu-crashed': [],
'plugin-crashed': ['name', 'version'],
'destroyed': [],
'page-title-set': ['title', 'explicitSet'],
'page-favicon-updated': ['favicons'],
'enter-html-full-screen': [],
'leave-html-full-screen': []
};
dispatchEvent = function() {
var args, domEvent, event, f, i, j, len, ref, webView;
webView = arguments[0], event = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
if (WEB_VIEW_EVENTS[event] == null) {
throw new Error("Unknown event " + event);
}
domEvent = new Event(event);
ref = WEB_VIEW_EVENTS[event];
for (i = j = 0, len = ref.length; j < len; i = ++j) {
f = ref[i];
domEvent[f] = args[i];
}
webView.dispatchEvent(domEvent);
if (event === 'load-commit') {
return webView.onLoadCommit(domEvent);
}
};
module.exports = {
registerEvents: function(webView, viewInstanceId) {
ipc.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-" + viewInstanceId, function() {
var args, event;
event = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
return dispatchEvent.apply(null, [webView, event].concat(slice.call(args)));
});
ipc.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-" + viewInstanceId, function() {
var args, channel, domEvent;
channel = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
domEvent = new Event('ipc-message');
domEvent.channel = channel;
domEvent.args = slice.call(args);
return webView.dispatchEvent(domEvent);
});
return ipc.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-" + viewInstanceId, function() {
var args, domEvent, f, i, j, len, ref;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
domEvent = new Event('size-changed');
ref = ['oldWidth', 'oldHeight', 'newWidth', 'newHeight'];
for (i = j = 0, len = ref.length; j < len; i = ++j) {
f = ref[i];
domEvent[f] = args[i];
}
return webView.onSizeChanged(domEvent);
});
},
deregisterEvents: function(viewInstanceId) {
ipc.removeAllListeners("ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-" + viewInstanceId);
ipc.removeAllListeners("ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-" + viewInstanceId);
return ipc.removeAllListeners("ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-" + viewInstanceId);
},
createGuest: function(params, callback) {
requestId++;
ipc.send('ATOM_SHELL_GUEST_VIEW_MANAGER_CREATE_GUEST', params, requestId);
return ipc.once("ATOM_SHELL_RESPONSE_" + requestId, callback);
},
attachGuest: function(elementInstanceId, guestInstanceId, params) {
ipc.send('ATOM_SHELL_GUEST_VIEW_MANAGER_ATTACH_GUEST', elementInstanceId, guestInstanceId, params);
return webFrame.attachGuest(elementInstanceId);
},
destroyGuest: function(guestInstanceId) {
return ipc.send('ATOM_SHELL_GUEST_VIEW_MANAGER_DESTROY_GUEST', guestInstanceId);
},
setSize: function(guestInstanceId, params) {
return ipc.send('ATOM_SHELL_GUEST_VIEW_MANAGER_SET_SIZE', guestInstanceId, params);
},
setAllowTransparency: function(guestInstanceId, allowtransparency) {
return ipc.send('ATOM_SHELL_GUEST_VIEW_MANAGER_SET_ALLOW_TRANSPARENCY', guestInstanceId, allowtransparency);
}
};
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var AllowTransparencyAttribute, AutosizeAttribute, AutosizeDimensionAttribute, BooleanAttribute, HttpReferrerAttribute, PartitionAttribute, PreloadAttribute, SrcAttribute, UserAgentAttribute, WebViewAttribute, WebViewImpl, a, guestViewInternal, remote, resolveUrl, webViewConstants,
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;
WebViewImpl = require('./web-view');
guestViewInternal = require('./guest-view-internal');
webViewConstants = require('./web-view-constants');
remote = require('remote');
a = document.createElement('a');
resolveUrl = function(url) {
a.href = url;
return a.href;
};
WebViewAttribute = (function() {
function WebViewAttribute(name, webViewImpl) {
this.name = name;
this.webViewImpl = webViewImpl;
this.ignoreMutation = false;
this.defineProperty();
}
WebViewAttribute.prototype.getValue = function() {
return this.webViewImpl.webviewNode.getAttribute(this.name) || '';
};
WebViewAttribute.prototype.setValue = function(value) {
return this.webViewImpl.webviewNode.setAttribute(this.name, value || '');
};
WebViewAttribute.prototype.setValueIgnoreMutation = function(value) {
this.ignoreMutation = true;
this.setValue(value);
return this.ignoreMutation = false;
};
WebViewAttribute.prototype.defineProperty = function() {
return Object.defineProperty(this.webViewImpl.webviewNode, this.name, {
get: (function(_this) {
return function() {
return _this.getValue();
};
})(this),
set: (function(_this) {
return function(value) {
return _this.setValue(value);
};
})(this),
enumerable: true
});
};
WebViewAttribute.prototype.handleMutation = function() {};
return WebViewAttribute;
})();
BooleanAttribute = (function(superClass) {
extend(BooleanAttribute, superClass);
function BooleanAttribute(name, webViewImpl) {
BooleanAttribute.__super__.constructor.call(this, name, webViewImpl);
}
BooleanAttribute.prototype.getValue = function() {
return this.webViewImpl.webviewNode.hasAttribute(this.name);
};
BooleanAttribute.prototype.setValue = function(value) {
if (!value) {
return this.webViewImpl.webviewNode.removeAttribute(this.name);
} else {
return this.webViewImpl.webviewNode.setAttribute(this.name, '');
}
};
return BooleanAttribute;
})(WebViewAttribute);
AllowTransparencyAttribute = (function(superClass) {
extend(AllowTransparencyAttribute, superClass);
function AllowTransparencyAttribute(webViewImpl) {
AllowTransparencyAttribute.__super__.constructor.call(this, webViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY, webViewImpl);
}
AllowTransparencyAttribute.prototype.handleMutation = function(oldValue, newValue) {
if (!this.webViewImpl.guestInstanceId) {
return;
}
return guestViewInternal.setAllowTransparency(this.webViewImpl.guestInstanceId, this.getValue());
};
return AllowTransparencyAttribute;
})(BooleanAttribute);
AutosizeDimensionAttribute = (function(superClass) {
extend(AutosizeDimensionAttribute, superClass);
function AutosizeDimensionAttribute(name, webViewImpl) {
AutosizeDimensionAttribute.__super__.constructor.call(this, name, webViewImpl);
}
AutosizeDimensionAttribute.prototype.getValue = function() {
return parseInt(this.webViewImpl.webviewNode.getAttribute(this.name)) || 0;
};
AutosizeDimensionAttribute.prototype.handleMutation = function(oldValue, newValue) {
if (!this.webViewImpl.guestInstanceId) {
return;
}
return guestViewInternal.setSize(this.webViewImpl.guestInstanceId, {
enableAutoSize: this.webViewImpl.attributes[webViewConstants.ATTRIBUTE_AUTOSIZE].getValue(),
min: {
width: parseInt(this.webViewImpl.attributes[webViewConstants.ATTRIBUTE_MINWIDTH].getValue() || 0),
height: parseInt(this.webViewImpl.attributes[webViewConstants.ATTRIBUTE_MINHEIGHT].getValue() || 0)
},
max: {
width: parseInt(this.webViewImpl.attributes[webViewConstants.ATTRIBUTE_MAXWIDTH].getValue() || 0),
height: parseInt(this.webViewImpl.attributes[webViewConstants.ATTRIBUTE_MAXHEIGHT].getValue() || 0)
}
});
};
return AutosizeDimensionAttribute;
})(WebViewAttribute);
AutosizeAttribute = (function(superClass) {
extend(AutosizeAttribute, superClass);
function AutosizeAttribute(webViewImpl) {
AutosizeAttribute.__super__.constructor.call(this, webViewConstants.ATTRIBUTE_AUTOSIZE, webViewImpl);
}
AutosizeAttribute.prototype.handleMutation = AutosizeDimensionAttribute.prototype.handleMutation;
return AutosizeAttribute;
})(BooleanAttribute);
PartitionAttribute = (function(superClass) {
extend(PartitionAttribute, superClass);
function PartitionAttribute(webViewImpl) {
PartitionAttribute.__super__.constructor.call(this, webViewConstants.ATTRIBUTE_PARTITION, webViewImpl);
this.validPartitionId = true;
}
PartitionAttribute.prototype.handleMutation = function(oldValue, newValue) {
newValue = newValue || '';
if (!this.webViewImpl.beforeFirstNavigation) {
window.console.error(webViewConstants.ERROR_MSG_ALREADY_NAVIGATED);
this.setValueIgnoreMutation(oldValue);
return;
}
if (newValue === 'persist:') {
this.validPartitionId = false;
return window.console.error(webViewConstants.ERROR_MSG_INVALID_PARTITION_ATTRIBUTE);
}
};
return PartitionAttribute;
})(WebViewAttribute);
SrcAttribute = (function(superClass) {
extend(SrcAttribute, superClass);
function SrcAttribute(webViewImpl) {
SrcAttribute.__super__.constructor.call(this, webViewConstants.ATTRIBUTE_SRC, webViewImpl);
this.setupMutationObserver();
}
SrcAttribute.prototype.getValue = function() {
if (this.webViewImpl.webviewNode.hasAttribute(this.name)) {
return resolveUrl(this.webViewImpl.webviewNode.getAttribute(this.name));
} else {
return '';
}
};
SrcAttribute.prototype.setValueIgnoreMutation = function(value) {
WebViewAttribute.prototype.setValueIgnoreMutation.call(this, value);
return this.observer.takeRecords();
};
SrcAttribute.prototype.handleMutation = function(oldValue, newValue) {
if (!newValue && oldValue) {
this.setValueIgnoreMutation(oldValue);
return;
}
return this.parse();
};
SrcAttribute.prototype.setupMutationObserver = function() {
var params;
this.observer = new MutationObserver((function(_this) {
return function(mutations) {
var i, len, mutation, newValue, oldValue;
for (i = 0, len = mutations.length; i < len; i++) {
mutation = mutations[i];
oldValue = mutation.oldValue;
newValue = _this.getValue();
if (oldValue !== newValue) {
return;
}
_this.handleMutation(oldValue, newValue);
}
};
})(this));
params = {
attributes: true,
attributeOldValue: true,
attributeFilter: [this.name]
};
return this.observer.observe(this.webViewImpl.webviewNode, params);
};
SrcAttribute.prototype.parse = function() {
var guestContents, httpreferrer, opts, useragent;
if (!this.webViewImpl.elementAttached || !this.webViewImpl.attributes[webViewConstants.ATTRIBUTE_PARTITION].validPartitionId || !this.getValue()) {
return;
}
if (this.webViewImpl.guestInstanceId == null) {
if (this.webViewImpl.beforeFirstNavigation) {
this.webViewImpl.beforeFirstNavigation = false;
this.webViewImpl.createGuest();
}
return;
}
opts = {};
httpreferrer = this.webViewImpl.attributes[webViewConstants.ATTRIBUTE_HTTPREFERRER].getValue();
if (httpreferrer) {
opts.httpReferrer = httpreferrer;
}
useragent = this.webViewImpl.attributes[webViewConstants.ATTRIBUTE_USERAGENT].getValue();
if (useragent) {
opts.userAgent = useragent;
}
guestContents = remote.getGuestWebContents(this.webViewImpl.guestInstanceId);
return guestContents.loadUrl(this.getValue(), opts);
};
return SrcAttribute;
})(WebViewAttribute);
HttpReferrerAttribute = (function(superClass) {
extend(HttpReferrerAttribute, superClass);
function HttpReferrerAttribute(webViewImpl) {
HttpReferrerAttribute.__super__.constructor.call(this, webViewConstants.ATTRIBUTE_HTTPREFERRER, webViewImpl);
}
return HttpReferrerAttribute;
})(WebViewAttribute);
UserAgentAttribute = (function(superClass) {
extend(UserAgentAttribute, superClass);
function UserAgentAttribute(webViewImpl) {
UserAgentAttribute.__super__.constructor.call(this, webViewConstants.ATTRIBUTE_USERAGENT, webViewImpl);
}
return UserAgentAttribute;
})(WebViewAttribute);
PreloadAttribute = (function(superClass) {
extend(PreloadAttribute, superClass);
function PreloadAttribute(webViewImpl) {
PreloadAttribute.__super__.constructor.call(this, webViewConstants.ATTRIBUTE_PRELOAD, webViewImpl);
}
PreloadAttribute.prototype.getValue = function() {
var preload, protocol;
if (!this.webViewImpl.webviewNode.hasAttribute(this.name)) {
return '';
}
preload = resolveUrl(this.webViewImpl.webviewNode.getAttribute(this.name));
protocol = preload.substr(0, 5);
if (protocol !== 'file:') {
console.error(webViewConstants.ERROR_MSG_INVALID_PRELOAD_ATTRIBUTE);
preload = '';
}
return preload;
};
return PreloadAttribute;
})(WebViewAttribute);
WebViewImpl.prototype.setupWebViewAttributes = function() {
var attribute, autosizeAttributes, i, len, results;
this.attributes = {};
this.attributes[webViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY] = new AllowTransparencyAttribute(this);
this.attributes[webViewConstants.ATTRIBUTE_AUTOSIZE] = new AutosizeAttribute(this);
this.attributes[webViewConstants.ATTRIBUTE_PARTITION] = new PartitionAttribute(this);
this.attributes[webViewConstants.ATTRIBUTE_SRC] = new SrcAttribute(this);
this.attributes[webViewConstants.ATTRIBUTE_HTTPREFERRER] = new HttpReferrerAttribute(this);
this.attributes[webViewConstants.ATTRIBUTE_USERAGENT] = new UserAgentAttribute(this);
this.attributes[webViewConstants.ATTRIBUTE_NODEINTEGRATION] = new BooleanAttribute(webViewConstants.ATTRIBUTE_NODEINTEGRATION, this);
this.attributes[webViewConstants.ATTRIBUTE_PLUGINS] = new BooleanAttribute(webViewConstants.ATTRIBUTE_PLUGINS, this);
this.attributes[webViewConstants.ATTRIBUTE_DISABLEWEBSECURITY] = new BooleanAttribute(webViewConstants.ATTRIBUTE_DISABLEWEBSECURITY, this);
this.attributes[webViewConstants.ATTRIBUTE_ALLOWPOPUPS] = new BooleanAttribute(webViewConstants.ATTRIBUTE_ALLOWPOPUPS, this);
this.attributes[webViewConstants.ATTRIBUTE_PRELOAD] = new PreloadAttribute(this);
autosizeAttributes = [webViewConstants.ATTRIBUTE_MAXHEIGHT, webViewConstants.ATTRIBUTE_MAXWIDTH, webViewConstants.ATTRIBUTE_MINHEIGHT, webViewConstants.ATTRIBUTE_MINWIDTH];
results = [];
for (i = 0, len = autosizeAttributes.length; i < len; i++) {
attribute = autosizeAttributes[i];
results.push(this.attributes[attribute] = new AutosizeDimensionAttribute(attribute, this));
}
return results;
};
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
module.exports = {
ATTRIBUTE_ALLOWTRANSPARENCY: 'allowtransparency',
ATTRIBUTE_AUTOSIZE: 'autosize',
ATTRIBUTE_MAXHEIGHT: 'maxheight',
ATTRIBUTE_MAXWIDTH: 'maxwidth',
ATTRIBUTE_MINHEIGHT: 'minheight',
ATTRIBUTE_MINWIDTH: 'minwidth',
ATTRIBUTE_NAME: 'name',
ATTRIBUTE_PARTITION: 'partition',
ATTRIBUTE_SRC: 'src',
ATTRIBUTE_HTTPREFERRER: 'httpreferrer',
ATTRIBUTE_NODEINTEGRATION: 'nodeintegration',
ATTRIBUTE_PLUGINS: 'plugins',
ATTRIBUTE_DISABLEWEBSECURITY: 'disablewebsecurity',
ATTRIBUTE_ALLOWPOPUPS: 'allowpopups',
ATTRIBUTE_PRELOAD: 'preload',
ATTRIBUTE_USERAGENT: 'useragent',
ATTRIBUTE_INTERNALINSTANCEID: 'internalinstanceid',
ERROR_MSG_ALREADY_NAVIGATED: 'The object has already navigated, so its partition cannot be changed.',
ERROR_MSG_CANNOT_INJECT_SCRIPT: '<webview>: ' + 'Script cannot be injected into content until the page has loaded.',
ERROR_MSG_INVALID_PARTITION_ATTRIBUTE: 'Invalid partition attribute.',
ERROR_MSG_INVALID_PRELOAD_ATTRIBUTE: 'Only "file:" protocol is supported in "preload" attribute.'
};
}).call(this);
// Generated by CoffeeScript 1.10.0
(function() {
var WebViewImpl, getNextId, guestViewInternal, listener, nextId, registerBrowserPluginElement, registerWebViewElement, remote, useCapture, v8Util, webFrame, webViewConstants,
hasProp = {}.hasOwnProperty,
slice = [].slice;
v8Util = process.atomBinding('v8_util');
guestViewInternal = require('./guest-view-internal');
webViewConstants = require('./web-view-constants');
webFrame = require('web-frame');
remote = require('remote');
nextId = 0;
getNextId = function() {
return ++nextId;
};
WebViewImpl = (function() {
function WebViewImpl(webviewNode) {
var shadowRoot;
this.webviewNode = webviewNode;
v8Util.setHiddenValue(this.webviewNode, 'internal', this);
this.attached = false;
this.elementAttached = false;
this.beforeFirstNavigation = true;
this.on = {};
this.browserPluginNode = this.createBrowserPluginNode();
shadowRoot = this.webviewNode.createShadowRoot();
this.setupWebViewAttributes();
this.setupFocusPropagation();
this.viewInstanceId = getNextId();
shadowRoot.appendChild(this.browserPluginNode);
}
WebViewImpl.prototype.createBrowserPluginNode = function() {
var browserPluginNode;
browserPluginNode = new WebViewImpl.BrowserPlugin();
v8Util.setHiddenValue(browserPluginNode, 'internal', this);
return browserPluginNode;
};
WebViewImpl.prototype.reset = function() {
if (this.guestInstanceId) {
guestViewInternal.destroyGuest(this.guestInstanceId);
this.webContents = null;
this.guestInstanceId = void 0;
this.beforeFirstNavigation = true;
this.attributes[webViewConstants.ATTRIBUTE_PARTITION].validPartitionId = true;
}
return this.internalInstanceId = 0;
};
WebViewImpl.prototype.setRequestPropertyOnWebViewNode = function(request) {
return Object.defineProperty(this.webviewNode, 'request', {
value: request,
enumerable: true
});
};
WebViewImpl.prototype.setupFocusPropagation = function() {
if (!this.webviewNode.hasAttribute('tabIndex')) {
this.webviewNode.setAttribute('tabIndex', -1);
}
this.webviewNode.addEventListener('focus', (function(_this) {
return function(e) {
return _this.browserPluginNode.focus();
};
})(this));
return this.webviewNode.addEventListener('blur', (function(_this) {
return function(e) {
return _this.browserPluginNode.blur();
};
})(this));
};
WebViewImpl.prototype.handleWebviewAttributeMutation = function(attributeName, oldValue, newValue) {
if (!this.attributes[attributeName] || this.attributes[attributeName].ignoreMutation) {
return;
}
return this.attributes[attributeName].handleMutation(oldValue, newValue);
};
WebViewImpl.prototype.handleBrowserPluginAttributeMutation = function(attributeName, oldValue, newValue) {
if (attributeName === webViewConstants.ATTRIBUTE_INTERNALINSTANCEID && !oldValue && !!newValue) {
this.browserPluginNode.removeAttribute(webViewConstants.ATTRIBUTE_INTERNALINSTANCEID);
this.internalInstanceId = parseInt(newValue);
webFrame.registerElementResizeCallback(this.internalInstanceId, this.onElementResize.bind(this));
if (!this.guestInstanceId) {
return;
}
return guestViewInternal.attachGuest(this.internalInstanceId, this.guestInstanceId, this.buildParams());
}
};
WebViewImpl.prototype.onSizeChanged = function(webViewEvent) {
var height, maxHeight, maxWidth, minHeight, minWidth, newHeight, newWidth, node, width;
newWidth = webViewEvent.newWidth;
newHeight = webViewEvent.newHeight;
node = this.webviewNode;
width = node.offsetWidth;
height = node.offsetHeight;
maxWidth = this.attributes[webViewConstants.ATTRIBUTE_MAXWIDTH].getValue() | width;
maxHeight = this.attributes[webViewConstants.ATTRIBUTE_MAXHEIGHT].getValue() | width;
minWidth = this.attributes[webViewConstants.ATTRIBUTE_MINWIDTH].getValue() | width;
minHeight = this.attributes[webViewConstants.ATTRIBUTE_MINHEIGHT].getValue() | width;
minWidth = Math.min(minWidth, maxWidth);
minHeight = Math.min(minHeight, maxHeight);
if (!this.attributes[webViewConstants.ATTRIBUTE_AUTOSIZE].getValue() || (newWidth >= minWidth && newWidth <= maxWidth && newHeight >= minHeight && newHeight <= maxHeight)) {
node.style.width = newWidth + 'px';
node.style.height = newHeight + 'px';
return this.dispatchEvent(webViewEvent);
}
};
WebViewImpl.prototype.onElementResize = function(newSize) {
var resizeEvent;
resizeEvent = new Event('resize', {
bubbles: true
});
resizeEvent.newWidth = newSize.width;
resizeEvent.newHeight = newSize.height;
this.dispatchEvent(resizeEvent);
if (this.guestInstanceId) {
return guestViewInternal.setSize(this.guestInstanceId, {
normal: newSize
});
}
};
WebViewImpl.prototype.createGuest = function() {
return guestViewInternal.createGuest(this.buildParams(), (function(_this) {
return function(guestInstanceId) {
return _this.attachWindow(guestInstanceId);
};
})(this));
};
WebViewImpl.prototype.dispatchEvent = function(webViewEvent) {
return this.webviewNode.dispatchEvent(webViewEvent);
};
WebViewImpl.prototype.setupEventProperty = function(eventName) {
var propertyName;
propertyName = 'on' + eventName.toLowerCase();
return Object.defineProperty(this.webviewNode, propertyName, {
get: (function(_this) {
return function() {
return _this.on[propertyName];
};
})(this),
set: (function(_this) {
return function(value) {
if (_this.on[propertyName]) {
_this.webviewNode.removeEventListener(eventName, _this.on[propertyName]);
}
_this.on[propertyName] = value;
if (value) {
return _this.webviewNode.addEventListener(eventName, value);
}
};
})(this),
enumerable: true
});
};
WebViewImpl.prototype.onLoadCommit = function(webViewEvent) {
var newValue, oldValue;
oldValue = this.webviewNode.getAttribute(webViewConstants.ATTRIBUTE_SRC);
newValue = webViewEvent.url;
if (webViewEvent.isMainFrame && (oldValue !== newValue)) {
return this.attributes[webViewConstants.ATTRIBUTE_SRC].setValueIgnoreMutation(newValue);
}
};
WebViewImpl.prototype.onAttach = function(storagePartitionId) {
return this.attributes[webViewConstants.ATTRIBUTE_PARTITION].setValue(storagePartitionId);
};
WebViewImpl.prototype.buildParams = function() {
var attribute, attributeName, css, elementRect, params, ref;
params = {
instanceId: this.viewInstanceId,
userAgentOverride: this.userAgentOverride
};
ref = this.attributes;
for (attributeName in ref) {
if (!hasProp.call(ref, attributeName)) continue;
attribute = ref[attributeName];
params[attributeName] = attribute.getValue();
}
css = window.getComputedStyle(this.webviewNode, null);
elementRect = this.webviewNode.getBoundingClientRect();
params.elementWidth = parseInt(elementRect.width) || parseInt(css.getPropertyValue('width'));
params.elementHeight = parseInt(elementRect.height) || parseInt(css.getPropertyValue('height'));
return params;
};
WebViewImpl.prototype.attachWindow = function(guestInstanceId) {
this.guestInstanceId = guestInstanceId;
this.webContents = remote.getGuestWebContents(this.guestInstanceId);
if (!this.internalInstanceId) {
return true;
}
return guestViewInternal.attachGuest(this.internalInstanceId, this.guestInstanceId, this.buildParams());
};
return WebViewImpl;
})();
registerBrowserPluginElement = function() {
var proto;
proto = Object.create(HTMLObjectElement.prototype);
proto.createdCallback = function() {
this.setAttribute('type', 'application/browser-plugin');
this.setAttribute('id', 'browser-plugin-' + getNextId());
this.style.display = 'block';
this.style.width = '100%';
return this.style.height = '100%';
};
proto.attributeChangedCallback = function(name, oldValue, newValue) {
var internal;
internal = v8Util.getHiddenValue(this, 'internal');
if (!internal) {
return;
}
return internal.handleBrowserPluginAttributeMutation(name, oldValue, newValue);
};
proto.attachedCallback = function() {
var unused;
return unused = this.nonExistentAttribute;
};
WebViewImpl.BrowserPlugin = webFrame.registerEmbedderCustomElement('browserplugin', {
"extends": 'object',
prototype: proto
});
delete proto.createdCallback;
delete proto.attachedCallback;
delete proto.detachedCallback;
return delete proto.attributeChangedCallback;
};
registerWebViewElement = function() {
var createHandler, i, len, m, methods, proto;
proto = Object.create(HTMLObjectElement.prototype);
proto.createdCallback = function() {
return new WebViewImpl(this);
};
proto.attributeChangedCallback = function(name, oldValue, newValue) {
var internal;
internal = v8Util.getHiddenValue(this, 'internal');
if (!internal) {
return;
}
return internal.handleWebviewAttributeMutation(name, oldValue, newValue);
};
proto.detachedCallback = function() {
var internal;
internal = v8Util.getHiddenValue(this, 'internal');
if (!internal) {
return;
}
guestViewInternal.deregisterEvents(internal.viewInstanceId);
internal.elementAttached = false;
return internal.reset();
};
proto.attachedCallback = function() {
var internal;
internal = v8Util.getHiddenValue(this, 'internal');
if (!internal) {
return;
}
if (!internal.elementAttached) {
guestViewInternal.registerEvents(internal, internal.viewInstanceId);
internal.elementAttached = true;
return internal.attributes[webViewConstants.ATTRIBUTE_SRC].parse();
}
};
methods = ["getUrl", "getTitle", "isLoading", "isWaitingForResponse", "stop", "reload", "reloadIgnoringCache", "canGoBack", "canGoForward", "canGoToOffset", "clearHistory", "goBack", "goForward", "goToIndex", "goToOffset", "isCrashed", "setUserAgent", "getUserAgent", "executeJavaScript", "insertCSS", "openDevTools", "closeDevTools", "isDevToolsOpened", "inspectElement", "setAudioMuted", "isAudioMuted", "undo", "redo", "cut", "copy", "paste", "pasteAndMatchStyle", "delete", "selectAll", "unselect", "replace", "replaceMisspelling", "send", "getId", "inspectServiceWorker", "print", "printToPDF", "sendInputEvent"];
createHandler = function(m) {
return function() {
var args, internal, ref;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
internal = v8Util.getHiddenValue(this, 'internal');
return (ref = internal.webContents)[m].apply(ref, args);
};
};
for (i = 0, len = methods.length; i < len; i++) {
m = methods[i];
proto[m] = createHandler(m);
}
window.WebView = webFrame.registerEmbedderCustomElement('webview', {
prototype: proto
});
delete proto.createdCallback;
delete proto.attachedCallback;
delete proto.detachedCallback;
return delete proto.attributeChangedCallback;
};
useCapture = true;
listener = function(event) {
if (document.readyState === 'loading') {
return;
}
registerBrowserPluginElement();
registerWebViewElement();
return window.removeEventListener(event.type, listener, useCapture);
};
window.addEventListener('readystatechange', listener, true);
module.exports = WebViewImpl;
}).call(this);