initial commit

This commit is contained in:
2026-03-22 03:21:45 +02:00
commit 897fea9f4e
15431 changed files with 2548840 additions and 0 deletions

20
node_modules/emissary/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,20 @@
Copyright (c) 2013 GitHub Inc.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

49
node_modules/emissary/README.md generated vendored Normal file
View File

@@ -0,0 +1,49 @@
# Emissary Mixins for Events [![Build Status](https://travis-ci.org/atom/emissary.svg?branch=master)](https://travis-ci.org/atom/emissary)
**Achtung!** This library is currently used in Atom and various Atom dependencies, but our long-term plan is to transition away from it in favor of the simpler [event-kit](https://github.com/atom/event-kit) library. Don't depend on supporting this library forever.
**Achtung Again!** The Subscriber mixin requires ES6 Harmony WeakMaps. To enable them, run your program with the `node --harmony_collections` flag. If you're using it in a node framework such as jasmine, run its script with the flag enabled as follows: `node --harmony-collections .bin/jasmine-node specs`.
## Emitter
Emitter is backward-compatible with Node's event emitter, but offers more functionality. You can construct standalone `Emitter` instances or use it as a mixin.
* `Emitter.extend(object)`
Turns the given object into an emitter by adding the appropriate methods.
* `Emitter.includeInto(class)`
Turns the class into an emitter by extending its prototype.
* `::on(eventNames, handler)`
Subscribe to one or more events. Events names are separated by spaces, and can optionally be namespaced with a dot-suffix. E.g. `event1 event2.namespace`.
* `::once(eventName, handler)`
Like `::on`, but only fires the handler once before unsubscribing automatically.
* `::off(eventNames[, handler])`
Unsubscribe to one or more events. Event names are separated by spaces. Passing a non-namespaced event name unsubscribes from every namespace for that event. Passing only a namespace unsubscribes from that entire namespace. Passing a handler removes only a subscription corresponding to the given event name(s) and that handler.
* `::emit(eventName[, data...])`
Emit an event with the given name. If the event name is namespaced, only calls handlers for the event associated with the namespace, otherwise it fires all handlers. Handlers are called with zero or more data arguments provided after the event name.
* `::pauseEvents()`
Buffers events instead of emitting them until `::resumeEvents` is called.
* `::resumeEvents()`
Emits all events buffered since pausing and resumes normal emitting behavior.
* `::getSubscriptionCount()`
Get the total number of handlers registered on the emitter.
## Subscriber
Subscriber works in partnership with an emitter or any object supporting subscription cancellation with `.off`. This includes standard Node event emitters and jQuery objects.
* `::subscribe(object, eventNames, handler)`
Subscribe to the given event name(s) on the given object.
* `::subscribeWith(object, methodName, eventNames, handler)`
Subscribe to the given object with a method other than `.on`.
* `::unsubscribe([object])`
Cancel subscriptions previously registered with `::subscribe`. If an object is given, only unsubscribe from that object. If called without an object, unsubscribe from everything.

120
node_modules/emissary/lib/behavior.js generated vendored Normal file
View File

@@ -0,0 +1,120 @@
(function() {
var Behavior, PropertyAccessors, Signal, helpers, isEqual,
__hasProp = {}.hasOwnProperty,
__extends = 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; },
__slice = [].slice;
isEqual = require('underscore-plus').isEqual;
PropertyAccessors = require('property-accessors');
Signal = require('./signal');
module.exports = Behavior = (function(_super) {
__extends(Behavior, _super);
PropertyAccessors.includeInto(Behavior);
function Behavior() {
var args, subscribeCallback, _ref;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (typeof ((_ref = args[0]) != null ? _ref.call : void 0) !== 'function') {
this.value = args.shift();
}
Behavior.__super__.constructor.call(this, subscribeCallback = args.shift());
}
Behavior.prototype.retained = function() {
var _this = this;
this.subscribe(this, 'value-internal', function(value) {
return _this.value = value;
});
this.subscribe(this, 'value-subscription-added', function(handler) {
return handler(_this.value);
});
return typeof this.subscribeCallback === "function" ? this.subscribeCallback() : void 0;
};
Behavior.prototype.emit = function() {
var args, name;
name = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
if (name === 'value') {
this.emit.apply(this, ['value-internal'].concat(__slice.call(args)));
}
return Behavior.__super__.emit.apply(this, arguments);
};
Behavior.prototype.getValue = function() {
if (!(this.retainCount > 0)) {
throw new Error("Subscribe to or retain this behavior before calling getValue");
}
return this.value;
};
Behavior.prototype.and = function(right) {
return helpers.combine(this, right, (function(leftValue, rightValue) {
return leftValue && rightValue;
})).distinctUntilChanged();
};
Behavior.prototype.or = function(right) {
return helpers.combine(this, right, (function(leftValue, rightValue) {
return leftValue || rightValue;
})).distinctUntilChanged();
};
Behavior.prototype.toBehavior = function() {
return this;
};
Behavior.prototype.lazyAccessor('changes', function() {
var source;
source = this;
return new Signal(function() {
var gotFirst,
_this = this;
gotFirst = false;
return this.subscribe(source, 'value', function() {
var metadata, value;
value = arguments[0], metadata = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
if (gotFirst) {
_this.emitValue.apply(_this, [value].concat(__slice.call(metadata)));
}
return gotFirst = true;
});
});
});
Behavior.prototype.becomes = function(predicateOrTargetValue) {
var predicate, targetValue;
if (typeof predicateOrTargetValue !== 'function') {
targetValue = predicateOrTargetValue;
return this.becomes(function(value) {
return isEqual(value, targetValue);
});
}
predicate = predicateOrTargetValue;
return this.map(function(value) {
return !!predicate(value);
}).distinctUntilChanged().changes;
};
Behavior.prototype.becomesLessThan = function(targetValue) {
return this.becomes(function(value) {
return value < targetValue;
});
};
Behavior.prototype.becomesGreaterThan = function(targetValue) {
return this.becomes(function(value) {
return value > targetValue;
});
};
return Behavior;
})(Signal);
helpers = require('./helpers');
}).call(this);

14
node_modules/emissary/lib/emissary.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
(function() {
var combine;
combine = require('./helpers').combine;
module.exports = {
Emitter: require('./emitter'),
Subscriber: require('./subscriber'),
Signal: require('./signal'),
Behavior: require('./behavior'),
combine: combine
};
}).call(this);

384
node_modules/emissary/lib/emitter.js generated vendored Normal file
View File

@@ -0,0 +1,384 @@
(function() {
var Emitter, Mixin, Signal, Subscription, removeFromArray, subscriptionRemovedPattern, _ref,
__hasProp = {}.hasOwnProperty,
__extends = 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; },
__slice = [].slice;
Mixin = require('mixto');
Signal = null;
Subscription = null;
subscriptionRemovedPattern = /^(last-)?.+-subscription-removed$/;
module.exports = Emitter = (function(_super) {
__extends(Emitter, _super);
function Emitter() {
_ref = Emitter.__super__.constructor.apply(this, arguments);
return _ref;
}
Emitter.prototype.eventHandlersByEventName = null;
Emitter.prototype.eventHandlersByNamespace = null;
Emitter.prototype.subscriptionCounts = null;
Emitter.prototype.pauseCountsByEventName = null;
Emitter.prototype.queuedEventsByEventName = null;
Emitter.prototype.globalPauseCount = null;
Emitter.prototype.globalQueuedEvents = null;
Emitter.prototype.signalsByEventName = null;
Emitter.prototype.on = function(eventNames, handler) {
var eventName, namespace, _base, _base1, _base2, _i, _len, _ref1, _ref2;
_ref1 = eventNames.split(/\s+/);
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
eventName = _ref1[_i];
if (!(eventName !== '')) {
continue;
}
_ref2 = eventName.split('.'), eventName = _ref2[0], namespace = _ref2[1];
this.emit("" + eventName + "-subscription-will-be-added", handler);
if (this.incrementSubscriptionCount(eventName) === 1) {
this.emit("first-" + eventName + "-subscription-will-be-added", handler);
}
if (this.eventHandlersByEventName == null) {
this.eventHandlersByEventName = {};
}
if ((_base = this.eventHandlersByEventName)[eventName] == null) {
_base[eventName] = [];
}
this.eventHandlersByEventName[eventName].push(handler);
if (namespace) {
if (this.eventHandlersByNamespace == null) {
this.eventHandlersByNamespace = {};
}
if ((_base1 = this.eventHandlersByNamespace)[namespace] == null) {
_base1[namespace] = {};
}
if ((_base2 = this.eventHandlersByNamespace[namespace])[eventName] == null) {
_base2[eventName] = [];
}
this.eventHandlersByNamespace[namespace][eventName].push(handler);
}
this.emit("" + eventName + "-subscription-added", handler);
}
if (Subscription == null) {
Subscription = require('./subscription');
}
return new Subscription(this, eventNames, handler);
};
Emitter.prototype.once = function(eventName, handler) {
var subscription;
return subscription = this.on(eventName, function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
subscription.off();
return handler.apply(null, args);
});
};
Emitter.prototype.signal = function(eventName) {
var _base;
if (Signal == null) {
Signal = require('./signal');
}
if (this.signalsByEventName == null) {
this.signalsByEventName = {};
}
return (_base = this.signalsByEventName)[eventName] != null ? (_base = this.signalsByEventName)[eventName] : _base[eventName] = Signal.fromEmitter(this, eventName);
};
Emitter.prototype.behavior = function(eventName, initialValue) {
return this.signal(eventName).toBehavior(initialValue);
};
Emitter.prototype.emit = function(eventName, payload) {
var handler, handlers, queuedEvents, _i, _len, _ref1, _ref2, _ref3;
if (arguments.length > 2 || /\s|\./.test(eventName)) {
return this.emitSlow.apply(this, arguments);
} else {
if (this.globalQueuedEvents != null) {
return this.globalQueuedEvents.push([eventName, payload]);
} else {
if (queuedEvents = (_ref1 = this.queuedEventsByEventName) != null ? _ref1[eventName] : void 0) {
return queuedEvents.push([eventName, payload]);
} else if (handlers = (_ref2 = this.eventHandlersByEventName) != null ? _ref2[eventName] : void 0) {
_ref3 = handlers.slice();
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
handler = _ref3[_i];
handler(payload);
}
return this.emit("after-" + eventName, payload);
}
}
}
};
Emitter.prototype.emitSlow = function() {
var args, eventName, handlers, namespace, queuedEvents, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6;
eventName = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
if (this.globalQueuedEvents) {
return this.globalQueuedEvents.push([eventName].concat(__slice.call(args)));
} else {
_ref1 = eventName.split('.'), eventName = _ref1[0], namespace = _ref1[1];
if (namespace) {
if (queuedEvents = (_ref2 = this.queuedEventsByEventName) != null ? _ref2[eventName] : void 0) {
return queuedEvents.push(["" + eventName + "." + namespace].concat(__slice.call(args)));
} else if (handlers = (_ref3 = this.eventHandlersByNamespace) != null ? (_ref4 = _ref3[namespace]) != null ? _ref4[eventName] : void 0 : void 0) {
(function(func, args, ctor) {
ctor.prototype = func.prototype;
var child = new ctor, result = func.apply(child, args);
return Object(result) === result ? result : child;
})(Array, handlers, function(){}).forEach(function(handler) {
return handler.apply(null, args);
});
return this.emit.apply(this, ["after-" + eventName].concat(__slice.call(args)));
}
} else {
if (queuedEvents = (_ref5 = this.queuedEventsByEventName) != null ? _ref5[eventName] : void 0) {
return queuedEvents.push([eventName].concat(__slice.call(args)));
} else if (handlers = (_ref6 = this.eventHandlersByEventName) != null ? _ref6[eventName] : void 0) {
(function(func, args, ctor) {
ctor.prototype = func.prototype;
var child = new ctor, result = func.apply(child, args);
return Object(result) === result ? result : child;
})(Array, handlers, function(){}).forEach(function(handler) {
return handler.apply(null, args);
});
return this.emit.apply(this, ["after-" + eventName].concat(__slice.call(args)));
}
}
}
};
Emitter.prototype.off = function(eventNames, handler) {
var eventHandlers, eventName, handlers, namespace, namespaceHandlers, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref1, _ref10, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
if (eventNames) {
_ref1 = eventNames.split(/\s+/);
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
eventName = _ref1[_i];
if (!(eventName !== '')) {
continue;
}
_ref2 = eventName.split('.'), eventName = _ref2[0], namespace = _ref2[1];
if (eventName === '') {
eventName = void 0;
}
if (namespace) {
if (eventName) {
handlers = (_ref3 = (_ref4 = this.eventHandlersByNamespace) != null ? (_ref5 = _ref4[namespace]) != null ? _ref5[eventName] : void 0 : void 0) != null ? _ref3 : [];
if (handler != null) {
removeFromArray(handlers, handler);
this.off(eventName, handler);
} else {
_ref6 = (function(func, args, ctor) {
ctor.prototype = func.prototype;
var child = new ctor, result = func.apply(child, args);
return Object(result) === result ? result : child;
})(Array, handlers, function(){});
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
handler = _ref6[_j];
removeFromArray(handlers, handler);
this.off(eventName, handler);
}
}
} else {
namespaceHandlers = (_ref7 = (_ref8 = this.eventHandlersByNamespace) != null ? _ref8[namespace] : void 0) != null ? _ref7 : {};
if (handler != null) {
for (eventName in namespaceHandlers) {
handlers = namespaceHandlers[eventName];
removeFromArray(handlers, handler);
this.off(eventName, handler);
}
} else {
for (eventName in namespaceHandlers) {
handlers = namespaceHandlers[eventName];
_ref9 = (function(func, args, ctor) {
ctor.prototype = func.prototype;
var child = new ctor, result = func.apply(child, args);
return Object(result) === result ? result : child;
})(Array, handlers, function(){});
for (_k = 0, _len2 = _ref9.length; _k < _len2; _k++) {
handler = _ref9[_k];
removeFromArray(handlers, handler);
this.off(eventName, handler);
}
}
}
}
} else {
eventHandlers = (_ref10 = this.eventHandlersByEventName) != null ? _ref10[eventName] : void 0;
if (eventHandlers == null) {
return;
}
if (handler == null) {
for (_l = 0, _len3 = eventHandlers.length; _l < _len3; _l++) {
handler = eventHandlers[_l];
this.off(eventName, handler);
}
return;
}
if (removeFromArray(eventHandlers, handler)) {
this.decrementSubscriptionCount(eventName);
this.emit("" + eventName + "-subscription-removed", handler);
if (this.getSubscriptionCount(eventName) === 0) {
this.emit("last-" + eventName + "-subscription-removed", handler);
delete this.eventHandlersByEventName[eventName];
}
}
}
}
} else {
for (eventName in this.eventHandlersByEventName) {
if (!subscriptionRemovedPattern.test(eventName)) {
this.off(eventName);
}
}
for (eventName in this.eventHandlersByEventName) {
this.off(eventName);
}
return this.eventHandlersByNamespace = {};
}
};
Emitter.prototype.pauseEvents = function(eventNames) {
var eventName, _base, _base1, _i, _len, _ref1, _results;
if (eventNames) {
_ref1 = eventNames.split(/\s+/);
_results = [];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
eventName = _ref1[_i];
if (!(eventName !== '')) {
continue;
}
if (this.pauseCountsByEventName == null) {
this.pauseCountsByEventName = {};
}
if (this.queuedEventsByEventName == null) {
this.queuedEventsByEventName = {};
}
if ((_base = this.pauseCountsByEventName)[eventName] == null) {
_base[eventName] = 0;
}
this.pauseCountsByEventName[eventName]++;
_results.push((_base1 = this.queuedEventsByEventName)[eventName] != null ? (_base1 = this.queuedEventsByEventName)[eventName] : _base1[eventName] = []);
}
return _results;
} else {
if (this.globalPauseCount == null) {
this.globalPauseCount = 0;
}
if (this.globalQueuedEvents == null) {
this.globalQueuedEvents = [];
}
return this.globalPauseCount++;
}
};
Emitter.prototype.resumeEvents = function(eventNames) {
var event, eventName, queuedEvents, _i, _j, _len, _len1, _ref1, _ref2, _results, _results1;
if (eventNames) {
_ref1 = eventNames.split(/\s+/);
_results = [];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
eventName = _ref1[_i];
if (eventName !== '') {
if (((_ref2 = this.pauseCountsByEventName) != null ? _ref2[eventName] : void 0) > 0 && --this.pauseCountsByEventName[eventName] === 0) {
queuedEvents = this.queuedEventsByEventName[eventName];
this.queuedEventsByEventName[eventName] = null;
_results.push((function() {
var _j, _len1, _results1;
_results1 = [];
for (_j = 0, _len1 = queuedEvents.length; _j < _len1; _j++) {
event = queuedEvents[_j];
_results1.push(this.emit.apply(this, event));
}
return _results1;
}).call(this));
} else {
_results.push(void 0);
}
}
}
return _results;
} else {
for (eventName in this.pauseCountsByEventName) {
this.resumeEvents(eventName);
}
if (this.globalPauseCount > 0 && --this.globalPauseCount === 0) {
queuedEvents = this.globalQueuedEvents;
this.globalQueuedEvents = null;
_results1 = [];
for (_j = 0, _len1 = queuedEvents.length; _j < _len1; _j++) {
event = queuedEvents[_j];
_results1.push(this.emit.apply(this, event));
}
return _results1;
}
}
};
Emitter.prototype.incrementSubscriptionCount = function(eventName) {
var _base;
if (this.subscriptionCounts == null) {
this.subscriptionCounts = {};
}
if ((_base = this.subscriptionCounts)[eventName] == null) {
_base[eventName] = 0;
}
return ++this.subscriptionCounts[eventName];
};
Emitter.prototype.decrementSubscriptionCount = function(eventName) {
var count;
count = --this.subscriptionCounts[eventName];
if (count === 0) {
delete this.subscriptionCounts[eventName];
}
return count;
};
Emitter.prototype.getSubscriptionCount = function(eventName) {
var count, name, total, _ref1, _ref2, _ref3;
if (eventName != null) {
return (_ref1 = (_ref2 = this.subscriptionCounts) != null ? _ref2[eventName] : void 0) != null ? _ref1 : 0;
} else {
total = 0;
_ref3 = this.subscriptionCounts;
for (name in _ref3) {
count = _ref3[name];
total += count;
}
return total;
}
};
Emitter.prototype.hasSubscriptions = function(eventName) {
return this.getSubscriptionCount(eventName) > 0;
};
return Emitter;
})(Mixin);
removeFromArray = function(array, element) {
var index;
index = array.indexOf(element);
if (index > -1) {
array.splice(index, 1);
return true;
} else {
return false;
}
};
}).call(this);

55
node_modules/emissary/lib/helpers.js generated vendored Normal file
View File

@@ -0,0 +1,55 @@
(function() {
var Behavior, combineArray, combineWithFunction,
__slice = [].slice;
Behavior = require('./behavior');
exports.combine = function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (args.length === 1 && Array.isArray(args[0])) {
return combineArray(args[0]);
} else if (typeof args[args.length - 1] === 'function') {
return combineWithFunction(args);
} else {
throw new Error("Invalid object type");
}
};
combineArray = function(array) {
var behavior;
return behavior = new Behavior(function() {
var element, i, outputArray, ready, _i, _len,
_this = this;
outputArray = array.slice();
ready = false;
for (i = _i = 0, _len = array.length; _i < _len; i = ++_i) {
element = array[i];
if (element.constructor.name === 'Behavior') {
(function(element, i) {
return _this.subscribe(element.onValue(function(value, metadata) {
if (ready) {
outputArray = outputArray.slice();
}
outputArray[i] = value;
if (ready) {
return _this.emitValue(outputArray, metadata);
}
}));
})(element, i);
}
}
ready = true;
return this.emitValue(outputArray);
});
};
combineWithFunction = function(args) {
var fn;
fn = args.pop();
return combineArray(args).map(function(argsArray) {
return fn.apply(null, argsArray);
});
};
}).call(this);

292
node_modules/emissary/lib/signal.js generated vendored Normal file
View File

@@ -0,0 +1,292 @@
(function() {
var Behavior, Emitter, Signal, Subscriber, isEqual,
__hasProp = {}.hasOwnProperty,
__extends = 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; },
__slice = [].slice;
isEqual = require('underscore-plus').isEqual;
Emitter = require('./emitter');
Subscriber = require('./subscriber');
Behavior = null;
module.exports = Signal = (function(_super) {
__extends(Signal, _super);
Subscriber.includeInto(Signal);
Signal.fromEmitter = function(emitter, eventName) {
return new Signal(function() {
var _this = this;
return this.subscribe(emitter, eventName, function() {
var metadata, value;
value = arguments[0], metadata = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return _this.emitValue.apply(_this, [value].concat(__slice.call(metadata)));
});
});
};
function Signal(subscribeCallback) {
var _this = this;
this.subscribeCallback = subscribeCallback;
this.retainCount = 0;
this.on('value-subscription-will-be-added', function() {
return _this.retain();
});
this.on('value-subscription-removed', function() {
return _this.release();
});
}
Signal.prototype.isSignal = true;
Signal.prototype.retained = function() {
return typeof this.subscribeCallback === "function" ? this.subscribeCallback() : void 0;
};
Signal.prototype.released = function() {
return this.unsubscribe();
};
Signal.prototype.retain = function() {
if (++this.retainCount === 1) {
if (typeof this.retained === "function") {
this.retained();
}
}
return this;
};
Signal.prototype.release = function() {
if (--this.retainCount === 0) {
if (typeof this.released === "function") {
this.released();
}
}
return this;
};
Signal.prototype.onValue = function(handler) {
return this.on('value', handler);
};
Signal.prototype.emitValue = function(value, metadata) {
if (metadata == null) {
metadata = {};
}
if (metadata.source == null) {
metadata.source = this;
}
return this.emit('value', value, metadata);
};
Signal.prototype.toBehavior = function(initialValue) {
var source;
source = this;
return this.buildBehavior(initialValue, function() {
var _this = this;
return this.subscribe(source, 'value', function() {
var metadata, value;
value = arguments[0], metadata = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return _this.emitValue.apply(_this, [value].concat(__slice.call(metadata)));
});
});
};
Signal.prototype.changes = function() {
return this;
};
Signal.prototype.injectMetadata = function(fn) {
var source;
source = this;
return new this.constructor(function() {
var _this = this;
return this.subscribe(source, 'value', function(value, metadata) {
var k, newMetadata, v;
newMetadata = fn(value, metadata);
for (k in newMetadata) {
v = newMetadata[k];
metadata[k] = v;
}
return _this.emitValue(value, metadata);
});
});
};
Signal.prototype.filter = function(predicate) {
var source;
source = this;
return new this.constructor(function() {
var _this = this;
return this.subscribe(source, 'value', function() {
var metadata, value;
value = arguments[0], metadata = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
if (predicate.call(value, value)) {
return _this.emitValue.apply(_this, [value].concat(__slice.call(metadata)));
}
});
});
};
Signal.prototype.filterDefined = function() {
return this.filter(function(value) {
return value != null;
});
};
Signal.prototype.map = function(fn) {
var property, source;
if (typeof fn === 'string') {
property = fn;
fn = function(value) {
return value != null ? value[property] : void 0;
};
}
source = this;
return new this.constructor(function() {
var _this = this;
return this.subscribe(source, 'value', function() {
var metadata, value;
value = arguments[0], metadata = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return _this.emitValue.apply(_this, [fn.call(value, value)].concat(__slice.call(metadata)));
});
});
};
Signal.prototype["switch"] = function(fn) {
var source;
source = this.map(fn);
return new this.constructor(function() {
var currentSignal,
_this = this;
currentSignal = null;
return this.subscribe(source, 'value', function(newSignal, outerMetadata) {
if (currentSignal != null) {
_this.unsubscribe(currentSignal);
}
currentSignal = newSignal;
if (currentSignal != null) {
return _this.subscribe(currentSignal, 'value', function(value, innerMetadata) {
return _this.emitValue(value, innerMetadata);
});
} else {
return _this.emitValue(void 0, outerMetadata);
}
});
});
};
Signal.prototype.skipUntil = function(predicateOrTargetValue) {
var doneSkipping, predicate, targetValue;
if (typeof predicateOrTargetValue !== 'function') {
targetValue = predicateOrTargetValue;
return this.skipUntil(function(value) {
return isEqual(value, targetValue);
});
}
predicate = predicateOrTargetValue;
doneSkipping = false;
return this.filter(function(value) {
if (doneSkipping) {
return true;
}
if (predicate(value)) {
return doneSkipping = true;
} else {
return false;
}
});
};
Signal.prototype.scan = function(initialValue, fn) {
var source;
source = this;
return this.buildBehavior(initialValue, function() {
var oldValue,
_this = this;
oldValue = initialValue;
return this.subscribe(source, 'value', function() {
var metadata, newValue;
newValue = arguments[0], metadata = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return _this.emitValue.apply(_this, [(oldValue = fn(oldValue, newValue))].concat(__slice.call(metadata)));
});
});
};
Signal.prototype.diff = function(initialValue, fn) {
var source;
source = this;
return this.buildBehavior(function() {
var oldValue,
_this = this;
oldValue = initialValue;
return this.subscribe(source, 'value', function() {
var fnOldValue, metadata, newValue;
newValue = arguments[0], metadata = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
fnOldValue = oldValue;
oldValue = newValue;
return _this.emitValue.apply(_this, [fn(fnOldValue, newValue)].concat(__slice.call(metadata)));
});
});
};
Signal.prototype.distinctUntilChanged = function() {
var source;
source = this;
return new this.constructor(function() {
var oldValue, receivedValue,
_this = this;
receivedValue = false;
oldValue = void 0;
return this.subscribe(source, 'value', function() {
var metadata, newValue;
newValue = arguments[0], metadata = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
if (receivedValue) {
if (isEqual(oldValue, newValue)) {
return oldValue = newValue;
} else {
oldValue = newValue;
return _this.emitValue.apply(_this, [newValue].concat(__slice.call(metadata)));
}
} else {
receivedValue = true;
oldValue = newValue;
return _this.emitValue.apply(_this, [newValue].concat(__slice.call(metadata)));
}
});
});
};
Signal.prototype.equals = function(expected) {
return this.map(function(actual) {
return isEqual(actual, expected);
}).distinctUntilChanged();
};
Signal.prototype.isDefined = function() {
return this.map(function(value) {
return value != null;
}).distinctUntilChanged();
};
Signal.prototype.buildBehavior = function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (Behavior == null) {
Behavior = require('./behavior');
}
return (function(func, args, ctor) {
ctor.prototype = func.prototype;
var child = new ctor, result = func.apply(child, args);
return Object(result) === result ? result : child;
})(Behavior, args, function(){});
};
return Signal;
})(Emitter);
}).call(this);

109
node_modules/emissary/lib/subscriber.js generated vendored Normal file
View File

@@ -0,0 +1,109 @@
(function() {
var Mixin, Signal, Subscriber, Subscription, WeakMap, _ref, _ref1,
__hasProp = {}.hasOwnProperty,
__extends = 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; },
__slice = [].slice;
Mixin = require('mixto');
Signal = null;
WeakMap = (_ref = global.WeakMap) != null ? _ref : require('es6-weak-map');
Subscription = require('./subscription');
module.exports = Subscriber = (function(_super) {
__extends(Subscriber, _super);
function Subscriber() {
_ref1 = Subscriber.__super__.constructor.apply(this, arguments);
return _ref1;
}
Subscriber.prototype.subscribeWith = function(eventEmitter, methodName, args) {
var callback, eventNames;
if (eventEmitter[methodName] == null) {
throw new Error("Object does not have method '" + methodName + "' with which to subscribe");
}
eventEmitter[methodName].apply(eventEmitter, args);
eventNames = args[0];
callback = args[args.length - 1];
return this.addSubscription(new Subscription(eventEmitter, eventNames, callback));
};
Subscriber.prototype.addSubscription = function(subscription) {
var emitter;
if (this._subscriptions == null) {
this._subscriptions = [];
}
this._subscriptions.push(subscription);
emitter = subscription.emitter;
if (emitter != null) {
if (this._subscriptionsByObject == null) {
this._subscriptionsByObject = new WeakMap;
}
if (this._subscriptionsByObject.has(emitter)) {
this._subscriptionsByObject.get(emitter).push(subscription);
} else {
this._subscriptionsByObject.set(emitter, [subscription]);
}
}
return subscription;
};
Subscriber.prototype.subscribe = function() {
var args, eventEmitterOrSubscription;
eventEmitterOrSubscription = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
if (args.length === 0) {
return this.addSubscription(eventEmitterOrSubscription);
} else {
if (args.length === 1 && eventEmitterOrSubscription.isSignal) {
args.unshift('value');
}
return this.subscribeWith(eventEmitterOrSubscription, 'on', args);
}
};
Subscriber.prototype.subscribeToCommand = function() {
var args, eventEmitter;
eventEmitter = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return this.subscribeWith(eventEmitter, 'command', args);
};
Subscriber.prototype.unsubscribe = function(object) {
var index, subscription, _i, _j, _len, _len1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7;
if (object != null) {
_ref4 = (_ref2 = (_ref3 = this._subscriptionsByObject) != null ? _ref3.get(object) : void 0) != null ? _ref2 : [];
for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
subscription = _ref4[_i];
if (typeof subscription.dispose === 'function') {
subscription.dispose();
} else {
subscription.off();
}
index = this._subscriptions.indexOf(subscription);
if (index >= 0) {
this._subscriptions.splice(index, 1);
}
}
return (_ref5 = this._subscriptionsByObject) != null ? _ref5["delete"](object) : void 0;
} else {
_ref7 = (_ref6 = this._subscriptions) != null ? _ref6 : [];
for (_j = 0, _len1 = _ref7.length; _j < _len1; _j++) {
subscription = _ref7[_j];
if (typeof subscription.dispose === 'function') {
subscription.dispose();
} else {
subscription.off();
}
}
this._subscriptions = null;
return this._subscriptionsByObject = null;
}
};
return Subscriber;
})(Mixin);
}).call(this);

40
node_modules/emissary/lib/subscription.js generated vendored Normal file
View File

@@ -0,0 +1,40 @@
(function() {
var Emitter, Subscription,
__hasProp = {}.hasOwnProperty,
__extends = 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; };
Emitter = require('./emitter');
module.exports = Subscription = (function(_super) {
__extends(Subscription, _super);
Subscription.prototype.cancelled = false;
function Subscription(emitter, eventNames, handler) {
this.emitter = emitter;
this.eventNames = eventNames;
this.handler = handler;
}
Subscription.prototype.off = function() {
return this.dispose();
};
Subscription.prototype.dispose = function() {
var unsubscribe, _ref;
if (this.cancelled) {
return;
}
unsubscribe = (_ref = this.emitter.off) != null ? _ref : this.emitter.removeListener;
unsubscribe.call(this.emitter, this.eventNames, this.handler);
this.emitter = null;
this.handler = null;
this.cancelled = true;
return this.emit('cancelled');
};
return Subscription;
})(Emitter);
}).call(this);

46
node_modules/emissary/package.json generated vendored Normal file
View File

@@ -0,0 +1,46 @@
{
"name": "emissary",
"version": "1.3.3",
"description": "Utility mixins for subscribing to and emitting events.",
"main": "lib/emissary.js",
"scripts": {
"test": "grunt test",
"prepublish": "grunt clean lint coffee"
},
"repository": {
"type": "git",
"url": "http://github.com/atom/emissary.git"
},
"bugs": {
"url": "https://github.com/atom/emissary/issues"
},
"homepage": "http://atom.github.io/emissary",
"keywords": [
"event-emitter",
"events",
"subscribe",
"subscriber"
],
"author": "Nathan Sobo",
"licenses": [
{
"type": "MIT",
"url": "http://github.com/atom/emissary/raw/master/LICENSE.md"
}
],
"dependencies": {
"underscore-plus": "1.x",
"mixto": "1.x",
"property-accessors": "^1.1",
"es6-weak-map": "^0.1.2"
},
"devDependencies": {
"jasmine-focused": "1.x",
"grunt-contrib-coffee": "~0.7.0",
"grunt-cli": "~0.1.8",
"grunt": "~0.4.1",
"grunt-shell": "~0.2.2",
"grunt-coffeelint": "0.0.6",
"rimraf": "~2.2.2"
}
}