Init
This commit is contained in:
commit
4e066bffc9
10017 changed files with 1322084 additions and 0 deletions
149
node_modules/node-notifier/notifiers/balloon.js
generated
vendored
Normal file
149
node_modules/node-notifier/notifiers/balloon.js
generated
vendored
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
/**
|
||||
* Wrapper for the notifu 1.6 (http://www.paralint.com/projects/notifu/)
|
||||
|
||||
Usage
|
||||
/t <value> The type of message to display values are:
|
||||
info The message is an informational message
|
||||
warn The message is an warning message
|
||||
error The message is an error message
|
||||
/d <value> The number of milliseconds to display (omit or 0 for infinit)
|
||||
/p <value> The title (or prompt) of the ballon
|
||||
/m <value> The message text
|
||||
/i <value> Specify an icon to use ("parent" uses the icon of the parent process)
|
||||
/e Enable ballon tips in the registry (for this user only)
|
||||
/q Do not play a sound when the tooltip is displayed
|
||||
/w Show the tooltip even if the user is in the quiet period that follows his very first login (Windows 7 and up)
|
||||
/xp Use IUserNotification interface event when IUserNotification2 is available
|
||||
|
||||
|
||||
// Kill codes:
|
||||
2 = Timeout
|
||||
3 = Clicked
|
||||
4 = Closed or faded out
|
||||
|
||||
*/
|
||||
var path = require('path'),
|
||||
notifier = path.resolve(__dirname, '../vendor/notifu/notifu'),
|
||||
utils = require('../lib/utils'),
|
||||
checkGrowl = require('../lib/checkGrowl'),
|
||||
Toaster = require('./toaster'),
|
||||
Growl = require('./growl'),
|
||||
os = require('os'),
|
||||
cloneDeep = require('lodash.clonedeep');
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var util = require('util');
|
||||
|
||||
var hasGrowl = void 0;
|
||||
|
||||
module.exports = WindowsBalloon;
|
||||
|
||||
function WindowsBalloon (options) {
|
||||
options = cloneDeep(options || {});
|
||||
if (!(this instanceof WindowsBalloon)) {
|
||||
return new WindowsBalloon(options);
|
||||
}
|
||||
|
||||
this.options = options;
|
||||
|
||||
EventEmitter.call(this);
|
||||
}
|
||||
util.inherits(WindowsBalloon, EventEmitter);
|
||||
|
||||
WindowsBalloon.prototype.notify = function (options, callback) {
|
||||
var fallback, notifierOptions = this.options;
|
||||
options = cloneDeep(options || {});
|
||||
callback = callback || function () {};
|
||||
|
||||
if (typeof options === 'string') options = {
|
||||
title: 'node-notifier',
|
||||
message: options
|
||||
};
|
||||
|
||||
var actionJackedCallback = utils.actionJackerDecorator(this, options, callback, function (data) {
|
||||
if (data === 'activate') {
|
||||
return 'click';
|
||||
}
|
||||
if (data === 'timeout') {
|
||||
return 'timeout';
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!!this.options.withFallback && utils.isWin8()) {
|
||||
fallback = fallback || new Toaster(notifierOptions);
|
||||
return fallback.notify(options, callback);
|
||||
}
|
||||
|
||||
if (!!this.options.withFallback && (!utils.isLessThanWin8() || hasGrowl === true)) {
|
||||
fallback = fallback || new Growl(notifierOptions);
|
||||
return fallback.notify(options, callback);
|
||||
}
|
||||
|
||||
if (!this.options.withFallback || hasGrowl === false) {
|
||||
doNotification(options, notifierOptions, actionJackedCallback);
|
||||
return this;
|
||||
}
|
||||
|
||||
checkGrowl(notifierOptions, function (hasGrowlResult) {
|
||||
hasGrowl = hasGrowlResult;
|
||||
|
||||
if (hasGrowl) {
|
||||
fallback = fallback || new Growl(notifierOptions);
|
||||
return fallback.notify(options, callback);
|
||||
}
|
||||
|
||||
doNotification(options, notifierOptions, actionJackedCallback);
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
var allowedArguments = ["t", "d", "p", "m", "i", "e", "q", "w", "xp"];
|
||||
|
||||
function doNotification (options, notifierOptions, callback) {
|
||||
var is64Bit = os.arch() === 'x64';
|
||||
options = options || {};
|
||||
options = utils.mapToNotifu(options);
|
||||
options.p = options.p || 'Node Notification:';
|
||||
|
||||
var fullNotifierPath = notifier + (is64Bit ? '64' : '') + '.exe';
|
||||
var localNotifier = notifierOptions.customPath || fullNotifierPath;
|
||||
|
||||
if (!options.m) {
|
||||
callback(new Error('Message is required.'));
|
||||
return this;
|
||||
}
|
||||
|
||||
var argsList = utils.constructArgumentList(options, {
|
||||
wrapper: '',
|
||||
noEscape: true,
|
||||
explicitTrue: true,
|
||||
allowedArguments: allowedArguments
|
||||
});
|
||||
|
||||
if (!!options.wait) {
|
||||
return utils.fileCommand(localNotifier, argsList, function (error, data) {
|
||||
var action = fromErrorCodeToAction(error.code);
|
||||
if (action === 'error') return callback(error, data);
|
||||
|
||||
return callback(null, action);
|
||||
});
|
||||
}
|
||||
utils.immediateFileCommand(localNotifier, argsList, callback);
|
||||
}
|
||||
|
||||
function fromErrorCodeToAction (errorCode) {
|
||||
switch (errorCode) {
|
||||
case 2:
|
||||
return 'timeout';
|
||||
case 3:
|
||||
case 6:
|
||||
case 7:
|
||||
return 'activate';
|
||||
case 4:
|
||||
return 'close';
|
||||
default:
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
74
node_modules/node-notifier/notifiers/growl.js
generated
vendored
Normal file
74
node_modules/node-notifier/notifiers/growl.js
generated
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/**
|
||||
* Wrapper for the growly module
|
||||
*/
|
||||
var utils = require('../lib/utils'),
|
||||
checkGrowl = require('../lib/checkGrowl'),
|
||||
growly = require('growly'),
|
||||
cloneDeep = require('lodash.clonedeep');
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var util = require('util');
|
||||
|
||||
var errorMessageNotFound = 'Couldn\'t connect to growl (might be used as a fallback). Make sure it is running';
|
||||
|
||||
module.exports = Growl;
|
||||
|
||||
var hasGrowl = void 0;
|
||||
|
||||
function Growl (options) {
|
||||
options = cloneDeep(options || {});
|
||||
if (!(this instanceof Growl)) {
|
||||
return new Growl(options);
|
||||
}
|
||||
|
||||
growly.appname = options.name || 'Node';
|
||||
this.options = options;
|
||||
|
||||
EventEmitter.call(this);
|
||||
}
|
||||
util.inherits(Growl, EventEmitter);
|
||||
|
||||
|
||||
Growl.prototype.notify = function (options, callback) {
|
||||
growly.setHost(this.options.host, this.options.port);
|
||||
options = cloneDeep(options || {});
|
||||
|
||||
if (typeof options === 'string') options = {
|
||||
title: 'node-notifier',
|
||||
message: options
|
||||
};
|
||||
|
||||
callback = utils.actionJackerDecorator(this, options, callback, function (data) {
|
||||
if (data === 'click') {
|
||||
return 'click';
|
||||
}
|
||||
if (data === 'timedout') {
|
||||
return 'timeout';
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
options = utils.mapToGrowl(options);
|
||||
|
||||
if (!options.message) {
|
||||
callback(new Error('Message is required.'));
|
||||
return this;
|
||||
}
|
||||
|
||||
options.title = options.title || 'Node Notification:';
|
||||
|
||||
if (hasGrowl || !!options.wait) {
|
||||
var localCallback = !!options.wait ? callback : function () {};
|
||||
growly.notify(options.message, options, localCallback);
|
||||
if (!options.wait) callback();
|
||||
return this;
|
||||
}
|
||||
|
||||
checkGrowl(growly, function (didHaveGrowl) {
|
||||
hasGrowl = didHaveGrowl;
|
||||
if (!didHaveGrowl) return callback(new Error(errorMessageNotFound));
|
||||
growly.notify(options.message, options);
|
||||
callback();
|
||||
});
|
||||
return this;
|
||||
};
|
||||
81
node_modules/node-notifier/notifiers/notificationcenter.js
generated
vendored
Normal file
81
node_modules/node-notifier/notifiers/notificationcenter.js
generated
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/**
|
||||
* A Node.js wrapper for terminal-notify (with fallback).
|
||||
*/
|
||||
var path = require('path'),
|
||||
notifier = path.join(__dirname, '../vendor/terminal-notifier.app/Contents/MacOS/terminal-notifier'),
|
||||
utils = require('../lib/utils'),
|
||||
Growl = require('./growl'),
|
||||
cloneDeep = require('lodash.clonedeep');
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var util = require('util');
|
||||
|
||||
var errorMessageOsX = 'You need Mac OS X 10.8 or above to use NotificationCenter,' +
|
||||
' or use Growl fallback with constructor option {withFallback: true}.';
|
||||
|
||||
module.exports = NotificationCenter;
|
||||
|
||||
function NotificationCenter (options) {
|
||||
options = cloneDeep(options || {});
|
||||
if (!(this instanceof NotificationCenter)) {
|
||||
return new NotificationCenter(options);
|
||||
}
|
||||
this.options = options;
|
||||
|
||||
EventEmitter.call(this);
|
||||
}
|
||||
util.inherits(NotificationCenter, EventEmitter);
|
||||
var activeId = null;
|
||||
|
||||
NotificationCenter.prototype.notify = function (options, callback) {
|
||||
var fallbackNotifier = null, id = identificator();
|
||||
options = cloneDeep(options || {});
|
||||
activeId = id;
|
||||
|
||||
if (typeof options === 'string') options = {
|
||||
title: 'node-notifier',
|
||||
message: options
|
||||
};
|
||||
|
||||
callback = callback || function () {};
|
||||
var actionJackedCallback = utils.actionJackerDecorator(this, options, callback, function (data) {
|
||||
if (activeId !== id) return false;
|
||||
|
||||
if (data === 'activate') {
|
||||
return 'click';
|
||||
}
|
||||
if (data === 'timeout') {
|
||||
return 'timeout';
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
options = utils.mapToMac(options);
|
||||
if (!!options.wait) {
|
||||
options.wait = 'YES';
|
||||
}
|
||||
|
||||
if (!options.message && !options.group && !options.list && !options.remove) {
|
||||
callback(new Error('Message, group, remove or list property is required.'));
|
||||
return this;
|
||||
}
|
||||
|
||||
var argsList = utils.constructArgumentList(options);
|
||||
|
||||
if(utils.isMountainLion()) {
|
||||
utils.fileCommand(this.options.customPath || notifier, argsList, actionJackedCallback);
|
||||
return this;
|
||||
}
|
||||
|
||||
if (fallbackNotifier || !!this.options.withFallback) {
|
||||
fallbackNotifier = fallbackNotifier || new Growl(this.options);
|
||||
return fallbackNotifier.notify(options, callback);
|
||||
}
|
||||
|
||||
callback(new Error(errorMessageOsX));
|
||||
return this;
|
||||
};
|
||||
|
||||
function identificator () {
|
||||
return { _ref: 'val' };
|
||||
}
|
||||
93
node_modules/node-notifier/notifiers/notifysend.js
generated
vendored
Normal file
93
node_modules/node-notifier/notifiers/notifysend.js
generated
vendored
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/**
|
||||
* Node.js wrapper for "notify-send".
|
||||
*/
|
||||
var os = require('os'),
|
||||
which = require('which'),
|
||||
utils = require('../lib/utils'),
|
||||
cloneDeep = require('lodash.clonedeep');
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var util = require('util');
|
||||
|
||||
var notifier = 'notify-send', hasNotifier = void 0;
|
||||
|
||||
module.exports = NotifySend;
|
||||
|
||||
function NotifySend (options) {
|
||||
options = cloneDeep(options || {});
|
||||
if (!(this instanceof NotifySend)) {
|
||||
return new NotifySend(options);
|
||||
}
|
||||
|
||||
this.options = options;
|
||||
|
||||
EventEmitter.call(this);
|
||||
}
|
||||
util.inherits(NotifySend, EventEmitter);
|
||||
|
||||
NotifySend.prototype.notify = function (options, callback) {
|
||||
options = cloneDeep(options || {});
|
||||
callback = callback || function () {};
|
||||
|
||||
if (typeof options === 'string') options = {
|
||||
title: 'node-notifier',
|
||||
message: options
|
||||
};
|
||||
|
||||
if (!options.message) {
|
||||
callback(new Error('Message is required.'));
|
||||
return this;
|
||||
}
|
||||
|
||||
if (os.type() !== 'Linux') {
|
||||
callback(new Error('Only supported on Linux systems'));
|
||||
return this;
|
||||
}
|
||||
|
||||
if (hasNotifier === false) {
|
||||
callback(new Error('notify-send must be installed on the system.'));
|
||||
return this;
|
||||
}
|
||||
|
||||
if (hasNotifier || !!this.options.suppressOsdCheck) {
|
||||
doNotification(options, callback);
|
||||
return this;
|
||||
}
|
||||
|
||||
try {
|
||||
hasNotifier = !!which.sync(notifier);
|
||||
doNotification(options, callback);
|
||||
} catch (err) {
|
||||
hasNotifier = false;
|
||||
return callback(err);
|
||||
};
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
var allowedArguments = [
|
||||
"urgency",
|
||||
"expire-time",
|
||||
"icon",
|
||||
"category",
|
||||
"hint"
|
||||
];
|
||||
|
||||
function doNotification (options, callback) {
|
||||
var initial, argsList;
|
||||
|
||||
options = utils.mapToNotifySend(options);
|
||||
options.title = options.title || 'Node Notification:';
|
||||
|
||||
initial = [options.title, options.message];
|
||||
delete options.title;
|
||||
delete options.message;
|
||||
|
||||
argsList = utils.constructArgumentList(options, {
|
||||
initial: initial,
|
||||
keyExtra: '-',
|
||||
allowedArguments: allowedArguments
|
||||
});
|
||||
|
||||
utils.command(notifier, argsList, callback);
|
||||
}
|
||||
67
node_modules/node-notifier/notifiers/toaster.js
generated
vendored
Normal file
67
node_modules/node-notifier/notifiers/toaster.js
generated
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* Wrapper for the toaster (https://github.com/nels-o/toaster)
|
||||
*/
|
||||
var path = require('path'),
|
||||
notifier = path.resolve(__dirname, '../vendor/toaster/toast.exe'),
|
||||
utils = require('../lib/utils'),
|
||||
Balloon = require('./balloon'),
|
||||
cloneDeep = require('lodash.clonedeep');
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var util = require('util');
|
||||
|
||||
var fallback = void 0;
|
||||
|
||||
module.exports = WindowsToaster;
|
||||
|
||||
function WindowsToaster (options) {
|
||||
options = cloneDeep(options || {});
|
||||
if (!(this instanceof WindowsToaster)) {
|
||||
return new WindowsToaster(options);
|
||||
}
|
||||
|
||||
this.options = options;
|
||||
|
||||
EventEmitter.call(this);
|
||||
}
|
||||
util.inherits(WindowsToaster, EventEmitter);
|
||||
|
||||
WindowsToaster.prototype.notify = function (options, callback) {
|
||||
options = cloneDeep(options || {});
|
||||
callback = callback || function () {};
|
||||
|
||||
if (typeof options === 'string') options = {
|
||||
title: 'node-notifier',
|
||||
message: options
|
||||
};
|
||||
|
||||
var actionJackedCallback = utils.actionJackerDecorator(this, options, callback, function (data) {
|
||||
if (data === 'activate') {
|
||||
return 'click';
|
||||
}
|
||||
if (data === 'timeout') {
|
||||
return 'timeout';
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
options.title = options.title || 'Node Notification:';
|
||||
|
||||
if (!options.message) {
|
||||
callback(new Error('Message is required.'));
|
||||
return this;
|
||||
}
|
||||
|
||||
if (!utils.isWin8() && !!this.options.withFallback) {
|
||||
fallback = fallback || new Balloon(this.options);
|
||||
return fallback.notify(options, callback);
|
||||
}
|
||||
|
||||
options = utils.mapToWin8(options);
|
||||
var argsList = utils.constructArgumentList(options, {
|
||||
wrapper: '',
|
||||
noEscape: true
|
||||
});
|
||||
utils.fileCommand(this.options.customPath || notifier, argsList, actionJackedCallback);
|
||||
return this;
|
||||
};
|
||||
Loading…
Reference in a new issue