UNPKG

noflo

Version:

Flow-Based Programming environment for JavaScript

1,805 lines (1,554 loc) 649 kB
/******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) /******/ return installedModules[moduleId].exports; /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ // Flag the module as loaded /******/ module.l = true; /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ // identity function for calling harmony imports with the correct context /******/ __webpack_require__.i = function(value) { return value; }; /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 56); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports) { // Copyright Joyent, Inc. and other Node contributors. // // 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. function EventEmitter() { this._events = this._events || {}; this._maxListeners = this._maxListeners || undefined; } module.exports = EventEmitter; // Backwards-compat with node 0.10.x EventEmitter.EventEmitter = EventEmitter; EventEmitter.prototype._events = undefined; EventEmitter.prototype._maxListeners = undefined; // By default EventEmitters will print a warning if more than 10 listeners are // added to it. This is a useful default which helps finding memory leaks. EventEmitter.defaultMaxListeners = 10; // Obviously not all Emitters should be limited to 10. This function allows // that to be increased. Set to zero for unlimited. EventEmitter.prototype.setMaxListeners = function(n) { if (!isNumber(n) || n < 0 || isNaN(n)) throw TypeError('n must be a positive number'); this._maxListeners = n; return this; }; EventEmitter.prototype.emit = function(type) { var er, handler, len, args, i, listeners; if (!this._events) this._events = {}; // If there is no 'error' event listener then throw. if (type === 'error') { if (!this._events.error || (isObject(this._events.error) && !this._events.error.length)) { er = arguments[1]; if (er instanceof Error) { throw er; // Unhandled 'error' event } else { // At least give some kind of context to the user var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); err.context = er; throw err; } } } handler = this._events[type]; if (isUndefined(handler)) return false; if (isFunction(handler)) { switch (arguments.length) { // fast cases case 1: handler.call(this); break; case 2: handler.call(this, arguments[1]); break; case 3: handler.call(this, arguments[1], arguments[2]); break; // slower default: args = Array.prototype.slice.call(arguments, 1); handler.apply(this, args); } } else if (isObject(handler)) { args = Array.prototype.slice.call(arguments, 1); listeners = handler.slice(); len = listeners.length; for (i = 0; i < len; i++) listeners[i].apply(this, args); } return true; }; EventEmitter.prototype.addListener = function(type, listener) { var m; if (!isFunction(listener)) throw TypeError('listener must be a function'); if (!this._events) this._events = {}; // To avoid recursion in the case that type === "newListener"! Before // adding it to the listeners, first emit "newListener". if (this._events.newListener) this.emit('newListener', type, isFunction(listener.listener) ? listener.listener : listener); if (!this._events[type]) // Optimize the case of one listener. Don't need the extra array object. this._events[type] = listener; else if (isObject(this._events[type])) // If we've already got an array, just append. this._events[type].push(listener); else // Adding the second element, need to change to array. this._events[type] = [this._events[type], listener]; // Check for listener leak if (isObject(this._events[type]) && !this._events[type].warned) { if (!isUndefined(this._maxListeners)) { m = this._maxListeners; } else { m = EventEmitter.defaultMaxListeners; } if (m && m > 0 && this._events[type].length > m) { this._events[type].warned = true; console.error('(node) warning: possible EventEmitter memory ' + 'leak detected. %d listeners added. ' + 'Use emitter.setMaxListeners() to increase limit.', this._events[type].length); if (typeof console.trace === 'function') { // not supported in IE 10 console.trace(); } } } return this; }; EventEmitter.prototype.on = EventEmitter.prototype.addListener; EventEmitter.prototype.once = function(type, listener) { if (!isFunction(listener)) throw TypeError('listener must be a function'); var fired = false; function g() { this.removeListener(type, g); if (!fired) { fired = true; listener.apply(this, arguments); } } g.listener = listener; this.on(type, g); return this; }; // emits a 'removeListener' event iff the listener was removed EventEmitter.prototype.removeListener = function(type, listener) { var list, position, length, i; if (!isFunction(listener)) throw TypeError('listener must be a function'); if (!this._events || !this._events[type]) return this; list = this._events[type]; length = list.length; position = -1; if (list === listener || (isFunction(list.listener) && list.listener === listener)) { delete this._events[type]; if (this._events.removeListener) this.emit('removeListener', type, listener); } else if (isObject(list)) { for (i = length; i-- > 0;) { if (list[i] === listener || (list[i].listener && list[i].listener === listener)) { position = i; break; } } if (position < 0) return this; if (list.length === 1) { list.length = 0; delete this._events[type]; } else { list.splice(position, 1); } if (this._events.removeListener) this.emit('removeListener', type, listener); } return this; }; EventEmitter.prototype.removeAllListeners = function(type) { var key, listeners; if (!this._events) return this; // not listening for removeListener, no need to emit if (!this._events.removeListener) { if (arguments.length === 0) this._events = {}; else if (this._events[type]) delete this._events[type]; return this; } // emit removeListener for all listeners on all events if (arguments.length === 0) { for (key in this._events) { if (key === 'removeListener') continue; this.removeAllListeners(key); } this.removeAllListeners('removeListener'); this._events = {}; return this; } listeners = this._events[type]; if (isFunction(listeners)) { this.removeListener(type, listeners); } else if (listeners) { // LIFO order while (listeners.length) this.removeListener(type, listeners[listeners.length - 1]); } delete this._events[type]; return this; }; EventEmitter.prototype.listeners = function(type) { var ret; if (!this._events || !this._events[type]) ret = []; else if (isFunction(this._events[type])) ret = [this._events[type]]; else ret = this._events[type].slice(); return ret; }; EventEmitter.prototype.listenerCount = function(type) { if (this._events) { var evlistener = this._events[type]; if (isFunction(evlistener)) return 1; else if (evlistener) return evlistener.length; } return 0; }; EventEmitter.listenerCount = function(emitter, type) { return emitter.listenerCount(type); }; function isFunction(arg) { return typeof arg === 'function'; } function isNumber(arg) { return typeof arg === 'number'; } function isObject(arg) { return typeof arg === 'object' && arg !== null; } function isUndefined(arg) { return arg === void 0; } /***/ }), /* 1 */ /***/ (function(module, exports) { // shim for using process in browser var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it // don't break things. But we need to wrap it in a try catch in case it is // wrapped in strict mode code which doesn't define any globals. It's inside a // function because try/catches deoptimize in certain engines. var cachedSetTimeout; var cachedClearTimeout; function defaultSetTimout() { throw new Error('setTimeout has not been defined'); } function defaultClearTimeout () { throw new Error('clearTimeout has not been defined'); } (function () { try { if (typeof setTimeout === 'function') { cachedSetTimeout = setTimeout; } else { cachedSetTimeout = defaultSetTimout; } } catch (e) { cachedSetTimeout = defaultSetTimout; } try { if (typeof clearTimeout === 'function') { cachedClearTimeout = clearTimeout; } else { cachedClearTimeout = defaultClearTimeout; } } catch (e) { cachedClearTimeout = defaultClearTimeout; } } ()) function runTimeout(fun) { if (cachedSetTimeout === setTimeout) { //normal enviroments in sane situations return setTimeout(fun, 0); } // if setTimeout wasn't available but was latter defined if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { cachedSetTimeout = setTimeout; return setTimeout(fun, 0); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedSetTimeout(fun, 0); } catch(e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedSetTimeout.call(null, fun, 0); } catch(e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error return cachedSetTimeout.call(this, fun, 0); } } } function runClearTimeout(marker) { if (cachedClearTimeout === clearTimeout) { //normal enviroments in sane situations return clearTimeout(marker); } // if clearTimeout wasn't available but was latter defined if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { cachedClearTimeout = clearTimeout; return clearTimeout(marker); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedClearTimeout(marker); } catch (e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedClearTimeout.call(null, marker); } catch (e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. // Some versions of I.E. have different rules for clearTimeout vs setTimeout return cachedClearTimeout.call(this, marker); } } } var queue = []; var draining = false; var currentQueue; var queueIndex = -1; function cleanUpNextTick() { if (!draining || !currentQueue) { return; } draining = false; if (currentQueue.length) { queue = currentQueue.concat(queue); } else { queueIndex = -1; } if (queue.length) { drainQueue(); } } function drainQueue() { if (draining) { return; } var timeout = runTimeout(cleanUpNextTick); draining = true; var len = queue.length; while(len) { currentQueue = queue; queue = []; while (++queueIndex < len) { if (currentQueue) { currentQueue[queueIndex].run(); } } queueIndex = -1; len = queue.length; } currentQueue = null; draining = false; runClearTimeout(timeout); } process.nextTick = function (fun) { var args = new Array(arguments.length - 1); if (arguments.length > 1) { for (var i = 1; i < arguments.length; i++) { args[i - 1] = arguments[i]; } } queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) { runTimeout(drainQueue); } }; // v8 likes predictible objects function Item(fun, array) { this.fun = fun; this.array = array; } Item.prototype.run = function () { this.fun.apply(null, this.array); }; process.title = 'browser'; process.browser = true; process.env = {}; process.argv = []; process.version = ''; // empty string to avoid regexp issues process.versions = {}; function noop() {} process.on = noop; process.addListener = noop; process.once = noop; process.off = noop; process.removeListener = noop; process.removeAllListeners = noop; process.emit = noop; process.binding = function (name) { throw new Error('process.binding is not supported'); }; process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function() { return 0; }; /***/ }), /* 2 */ /***/ (function(module, exports) { (function() { var IP; module.exports = IP = (function() { IP.types = ['data', 'openBracket', 'closeBracket']; IP.isIP = function(obj) { return obj && typeof obj === 'object' && obj._isIP === true; }; function IP(type, data, options) { var key, val; this.type = type != null ? type : 'data'; this.data = data != null ? data : null; if (options == null) { options = {}; } this._isIP = true; this.scope = null; this.owner = null; this.clonable = false; this.index = null; for (key in options) { val = options[key]; this[key] = val; } } IP.prototype.clone = function() { var ip, key, val; ip = new IP(this.type); for (key in this) { val = this[key]; if (['owner'].indexOf(key) !== -1) { continue; } if (val === null) { continue; } if (typeof val === 'object') { ip[key] = JSON.parse(JSON.stringify(val)); } else { ip[key] = val; } } return ip; }; IP.prototype.move = function(owner) { this.owner = owner; }; IP.prototype.drop = function() { var key, results, val; results = []; for (key in this) { val = this[key]; results.push(delete this[key]); } return results; }; return IP; })(); }).call(this); /***/ }), /* 3 */ /***/ (function(module, exports) { var IP; module.exports = IP = (function() { IP.types = ['data', 'openBracket', 'closeBracket']; IP.isIP = function(obj) { return obj && typeof obj === 'object' && obj._isIP === true; }; function IP(type, data, options) { var key, val; this.type = type != null ? type : 'data'; this.data = data != null ? data : null; if (options == null) { options = {}; } this._isIP = true; this.scope = null; this.owner = null; this.clonable = false; this.index = null; for (key in options) { val = options[key]; this[key] = val; } } IP.prototype.clone = function() { var ip, key, ref, val; ip = new IP(this.type); ref = this; for (key in ref) { val = ref[key]; if (['owner'].indexOf(key) !== -1) { continue; } if (val === null) { continue; } if (typeof val === 'object') { ip[key] = JSON.parse(JSON.stringify(val)); } else { ip[key] = val; } } return ip; }; IP.prototype.move = function(owner) { this.owner = owner; }; IP.prototype.drop = function() { var key, ref, results, val; ref = this; results = []; for (key in ref) { val = ref[key]; results.push(delete this[key]); } return results; }; return IP; })(); /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {/** * This is the web browser implementation of `debug()`. * * Expose `debug()` as the module. */ exports = module.exports = __webpack_require__(45); exports.log = log; exports.formatArgs = formatArgs; exports.save = save; exports.load = load; exports.useColors = useColors; exports.storage = 'undefined' != typeof chrome && 'undefined' != typeof chrome.storage ? chrome.storage.local : localstorage(); /** * Colors. */ exports.colors = [ 'lightseagreen', 'forestgreen', 'goldenrod', 'dodgerblue', 'darkorchid', 'crimson' ]; /** * Currently only WebKit-based Web Inspectors, Firefox >= v31, * and the Firebug extension (any Firefox version) are known * to support "%c" CSS customizations. * * TODO: add a `localStorage` variable to explicitly enable/disable colors */ function useColors() { // NB: In an Electron preload script, document will be defined but not fully // initialized. Since we know we're in Chrome, we'll just detect this case // explicitly if (typeof window !== 'undefined' && window && typeof window.process !== 'undefined' && window.process.type === 'renderer') { return true; } // is webkit? http://stackoverflow.com/a/16459606/376773 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 return (typeof document !== 'undefined' && document && 'WebkitAppearance' in document.documentElement.style) || // is firebug? http://stackoverflow.com/a/398120/376773 (typeof window !== 'undefined' && window && window.console && (console.firebug || (console.exception && console.table))) || // is firefox >= v31? // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages (typeof navigator !== 'undefined' && navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || // double check webkit in userAgent just in case we are in a worker (typeof navigator !== 'undefined' && navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } /** * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. */ exports.formatters.j = function(v) { try { return JSON.stringify(v); } catch (err) { return '[UnexpectedJSONParseError]: ' + err.message; } }; /** * Colorize log arguments if enabled. * * @api public */ function formatArgs(args) { var useColors = this.useColors; args[0] = (useColors ? '%c' : '') + this.namespace + (useColors ? ' %c' : ' ') + args[0] + (useColors ? '%c ' : ' ') + '+' + exports.humanize(this.diff); if (!useColors) return; var c = 'color: ' + this.color; args.splice(1, 0, c, 'color: inherit') // the final "%c" is somewhat tricky, because there could be other // arguments passed either before or after the %c, so we need to // figure out the correct index to insert the CSS into var index = 0; var lastC = 0; args[0].replace(/%[a-zA-Z%]/g, function(match) { if ('%%' === match) return; index++; if ('%c' === match) { // we only are interested in the *last* %c // (the user may have provided their own) lastC = index; } }); args.splice(lastC, 0, c); } /** * Invokes `console.log()` when available. * No-op when `console.log` is not a "function". * * @api public */ function log() { // this hackery is required for IE8/9, where // the `console.log` function doesn't have 'apply' return 'object' === typeof console && console.log && Function.prototype.apply.call(console.log, console, arguments); } /** * Save `namespaces`. * * @param {String} namespaces * @api private */ function save(namespaces) { try { if (null == namespaces) { exports.storage.removeItem('debug'); } else { exports.storage.debug = namespaces; } } catch(e) {} } /** * Load `namespaces`. * * @return {String} returns the previously persisted debug modes * @api private */ function load() { try { return exports.storage.debug; } catch(e) {} // If debug isn't set in LS, and we're in Electron, try to load $DEBUG if (typeof process !== 'undefined' && 'env' in process) { return process.env.DEBUG; } } /** * Enable namespaces listed in `localStorage.debug` initially. */ exports.enable(load()); /** * Localstorage attempts to return the localstorage. * * This is necessary because safari throws * when a user disables cookies/localstorage * and you attempt to access it. * * @return {LocalStorage} * @api private */ function localstorage() { try { return window.localStorage; } catch (e) {} } /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { exports.graph = __webpack_require__(46); exports.Graph = exports.graph.Graph; exports.journal = __webpack_require__(47); exports.Journal = exports.journal.Journal; /***/ }), /* 6 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {(function() { exports.isBrowser = function() { if (typeof process !== 'undefined' && process.execPath && process.execPath.match(/node|iojs/)) { return false; } return true; }; exports.deprecated = function(message) { if (exports.isBrowser()) { if (window.NOFLO_FATAL_DEPRECATED) { throw new Error(message); } console.warn(message); return; } if (process.env.NOFLO_FATAL_DEPRECATED) { throw new Error(message); } return console.warn(message); }; }).call(this); /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), /* 7 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {exports.isBrowser = function() { if (typeof process !== 'undefined' && process.execPath && process.execPath.match(/node|iojs/)) { return false; } return true; }; exports.deprecated = function(message) { if (exports.isBrowser()) { if (window.NOFLO_FATAL_DEPRECATED) { throw new Error(message); } console.warn(message); return; } if (process.env.NOFLO_FATAL_DEPRECATED) { throw new Error(message); } return console.warn(message); }; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), /* 8 */ /***/ (function(module, exports, __webpack_require__) { (function() { var EventEmitter, IP, InternalSocket, 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 = __webpack_require__(0).EventEmitter; IP = __webpack_require__(2); InternalSocket = (function(superClass) { extend(InternalSocket, superClass); InternalSocket.prototype.regularEmitEvent = function(event, data) { return this.emit(event, data); }; InternalSocket.prototype.debugEmitEvent = function(event, data) { var error, error1; try { return this.emit(event, data); } catch (error1) { error = error1; if (error.id && error.metadata && error.error) { if (this.listeners('error').length === 0) { throw error.error; } this.emit('error', error); return; } if (this.listeners('error').length === 0) { throw error; } return this.emit('error', { id: this.to.process.id, error: error, metadata: this.metadata }); } }; function InternalSocket(metadata) { this.metadata = metadata != null ? metadata : {}; this.brackets = []; this.connected = false; this.dataDelegate = null; this.debug = false; this.emitEvent = this.regularEmitEvent; } InternalSocket.prototype.connect = function() { if (this.connected) { return; } this.connected = true; return this.emitEvent('connect', null); }; InternalSocket.prototype.disconnect = function() { if (!this.connected) { return; } this.connected = false; return this.emitEvent('disconnect', null); }; InternalSocket.prototype.isConnected = function() { return this.connected; }; InternalSocket.prototype.send = function(data) { if (data === void 0 && typeof this.dataDelegate === 'function') { data = this.dataDelegate(); } return this.handleSocketEvent('data', data); }; InternalSocket.prototype.post = function(ip, autoDisconnect) { if (autoDisconnect == null) { autoDisconnect = true; } if (ip === void 0 && typeof this.dataDelegate === 'function') { ip = this.dataDelegate(); } if (!this.isConnected() && this.brackets.length === 0) { this.connect(); } this.handleSocketEvent('ip', ip, false); if (autoDisconnect && this.isConnected() && this.brackets.length === 0) { return this.disconnect(); } }; InternalSocket.prototype.beginGroup = function(group) { return this.handleSocketEvent('begingroup', group); }; InternalSocket.prototype.endGroup = function() { return this.handleSocketEvent('endgroup'); }; InternalSocket.prototype.setDataDelegate = function(delegate) { if (typeof delegate !== 'function') { throw Error('A data delegate must be a function.'); } return this.dataDelegate = delegate; }; InternalSocket.prototype.setDebug = function(active) { this.debug = active; return this.emitEvent = this.debug ? this.debugEmitEvent : this.regularEmitEvent; }; InternalSocket.prototype.getId = function() { var fromStr, toStr; fromStr = function(from) { return from.process.id + "() " + (from.port.toUpperCase()); }; toStr = function(to) { return (to.port.toUpperCase()) + " " + to.process.id + "()"; }; if (!(this.from || this.to)) { return "UNDEFINED"; } if (this.from && !this.to) { return (fromStr(this.from)) + " -> ANON"; } if (!this.from) { return "DATA -> " + (toStr(this.to)); } return (fromStr(this.from)) + " -> " + (toStr(this.to)); }; InternalSocket.prototype.legacyToIp = function(event, payload) { if (IP.isIP(payload)) { return payload; } switch (event) { case 'begingroup': return new IP('openBracket', payload); case 'endgroup': return new IP('closeBracket'); case 'data': return new IP('data', payload); default: return null; } }; InternalSocket.prototype.ipToLegacy = function(ip) { var legacy; switch (ip.type) { case 'openBracket': return legacy = { event: 'begingroup', payload: ip.data }; case 'data': return legacy = { event: 'data', payload: ip.data }; case 'closeBracket': return legacy = { event: 'endgroup', payload: ip.data }; } }; InternalSocket.prototype.handleSocketEvent = function(event, payload, autoConnect) { var ip, isIP, legacy; if (autoConnect == null) { autoConnect = true; } isIP = event === 'ip' && IP.isIP(payload); ip = isIP ? payload : this.legacyToIp(event, payload); if (!ip) { return; } if (!this.isConnected() && autoConnect && this.brackets.length === 0) { this.connect(); } if (event === 'begingroup') { this.brackets.push(payload); } if (isIP && ip.type === 'openBracket') { this.brackets.push(ip.data); } if (event === 'endgroup') { if (this.brackets.length === 0) { return; } ip.data = this.brackets.pop(); payload = ip.data; } if (isIP && payload.type === 'closeBracket') { if (this.brackets.length === 0) { return; } this.brackets.pop(); } this.emitEvent('ip', ip); if (!(ip && ip.type)) { return; } if (isIP) { legacy = this.ipToLegacy(ip); event = legacy.event; payload = legacy.payload; } if (event === 'connect') { this.connected = true; } if (event === 'disconnect') { this.connected = false; } return this.emitEvent(event, payload); }; return InternalSocket; })(EventEmitter); exports.InternalSocket = InternalSocket; exports.createSocket = function() { return new InternalSocket; }; }).call(this); /***/ }), /* 9 */ /***/ (function(module, exports, __webpack_require__) { var EventEmitter, IP, InternalSocket, 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 = __webpack_require__(0).EventEmitter; IP = __webpack_require__(3); InternalSocket = (function(superClass) { extend(InternalSocket, superClass); InternalSocket.prototype.regularEmitEvent = function(event, data) { return this.emit(event, data); }; InternalSocket.prototype.debugEmitEvent = function(event, data) { var error; try { return this.emit(event, data); } catch (error1) { error = error1; if (error.id && error.metadata && error.error) { if (this.listeners('error').length === 0) { throw error.error; } this.emit('error', error); return; } if (this.listeners('error').length === 0) { throw error; } return this.emit('error', { id: this.to.process.id, error: error, metadata: this.metadata }); } }; function InternalSocket(metadata) { this.metadata = metadata != null ? metadata : {}; this.brackets = []; this.connected = false; this.dataDelegate = null; this.debug = false; this.emitEvent = this.regularEmitEvent; } InternalSocket.prototype.connect = function() { if (this.connected) { return; } this.connected = true; return this.emitEvent('connect', null); }; InternalSocket.prototype.disconnect = function() { if (!this.connected) { return; } this.connected = false; return this.emitEvent('disconnect', null); }; InternalSocket.prototype.isConnected = function() { return this.connected; }; InternalSocket.prototype.send = function(data) { if (data === void 0 && typeof this.dataDelegate === 'function') { data = this.dataDelegate(); } return this.handleSocketEvent('data', data); }; InternalSocket.prototype.post = function(ip, autoDisconnect) { if (autoDisconnect == null) { autoDisconnect = true; } if (ip === void 0 && typeof this.dataDelegate === 'function') { ip = this.dataDelegate(); } if (!this.isConnected() && this.brackets.length === 0) { this.connect(); } this.handleSocketEvent('ip', ip, false); if (autoDisconnect && this.isConnected() && this.brackets.length === 0) { return this.disconnect(); } }; InternalSocket.prototype.beginGroup = function(group) { return this.handleSocketEvent('begingroup', group); }; InternalSocket.prototype.endGroup = function() { return this.handleSocketEvent('endgroup'); }; InternalSocket.prototype.setDataDelegate = function(delegate) { if (typeof delegate !== 'function') { throw Error('A data delegate must be a function.'); } return this.dataDelegate = delegate; }; InternalSocket.prototype.setDebug = function(active) { this.debug = active; return this.emitEvent = this.debug ? this.debugEmitEvent : this.regularEmitEvent; }; InternalSocket.prototype.getId = function() { var fromStr, toStr; fromStr = function(from) { return from.process.id + "() " + (from.port.toUpperCase()); }; toStr = function(to) { return (to.port.toUpperCase()) + " " + to.process.id + "()"; }; if (!(this.from || this.to)) { return "UNDEFINED"; } if (this.from && !this.to) { return (fromStr(this.from)) + " -> ANON"; } if (!this.from) { return "DATA -> " + (toStr(this.to)); } return (fromStr(this.from)) + " -> " + (toStr(this.to)); }; InternalSocket.prototype.legacyToIp = function(event, payload) { if (IP.isIP(payload)) { return payload; } switch (event) { case 'begingroup': return new IP('openBracket', payload); case 'endgroup': return new IP('closeBracket'); case 'data': return new IP('data', payload); default: return null; } }; InternalSocket.prototype.ipToLegacy = function(ip) { var legacy; switch (ip.type) { case 'openBracket': return legacy = { event: 'begingroup', payload: ip.data }; case 'data': return legacy = { event: 'data', payload: ip.data }; case 'closeBracket': return legacy = { event: 'endgroup', payload: ip.data }; } }; InternalSocket.prototype.handleSocketEvent = function(event, payload, autoConnect) { var ip, isIP, legacy; if (autoConnect == null) { autoConnect = true; } isIP = event === 'ip' && IP.isIP(payload); ip = isIP ? payload : this.legacyToIp(event, payload); if (!ip) { return; } if (!this.isConnected() && autoConnect && this.brackets.length === 0) { this.connect(); } if (event === 'begingroup') { this.brackets.push(payload); } if (isIP && ip.type === 'openBracket') { this.brackets.push(ip.data); } if (event === 'endgroup') { if (this.brackets.length === 0) { return; } ip.data = this.brackets.pop(); payload = ip.data; } if (isIP && payload.type === 'closeBracket') { if (this.brackets.length === 0) { return; } this.brackets.pop(); } this.emitEvent('ip', ip); if (!(ip && ip.type)) { return; } if (isIP) { legacy = this.ipToLegacy(ip); event = legacy.event; payload = legacy.payload; } if (event === 'connect') { this.connected = true; } if (event === 'disconnect') { this.connected = false; } return this.emitEvent(event, payload); }; return InternalSocket; })(EventEmitter); exports.InternalSocket = InternalSocket; exports.createSocket = function() { return new InternalSocket; }; /***/ }), /* 10 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {(function() { var ComponentLoader, EventEmitter, fbpGraph, internalSocket, registerLoader, 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; internalSocket = __webpack_require__(8); fbpGraph = __webpack_require__(5); EventEmitter = __webpack_require__(0).EventEmitter; registerLoader = __webpack_require__(32); ComponentLoader = (function(superClass) { extend(ComponentLoader, superClass); function ComponentLoader(baseDir, options) { this.baseDir = baseDir; this.options = options != null ? options : {}; this.components = null; this.libraryIcons = {}; this.processing = false; this.ready = false; if (typeof this.setMaxListeners === 'function') { this.setMaxListeners(0); } } ComponentLoader.prototype.getModulePrefix = function(name) { if (!name) { return ''; } if (name === 'noflo') { return ''; } if (name[0] === '@') { name = name.replace(/\@[a-z\-]+\//, ''); } return name.replace('noflo-', ''); }; ComponentLoader.prototype.listComponents = function(callback) { if (this.processing) { this.once('ready', (function(_this) { return function() { return callback(null, _this.components); }; })(this)); return; } if (this.components) { return callback(null, this.components); } this.ready = false; this.processing = true; this.components = {}; registerLoader.register(this, (function(_this) { return function(err) { if (err) { if (callback) { return callback(err); } throw err; } _this.processing = false; _this.ready = true; _this.emit('ready', true); if (callback) { return callback(null, _this.components); } }; })(this)); }; ComponentLoader.prototype.load = function(name, callback, metadata) { var component, componentName; if (!this.ready) { this.listComponents((function(_this) { return function(err) { if (err) { return callback(err); } return _this.load(name, callback, metadata); }; })(this)); return; } component = this.components[name]; if (!component) { for (componentName in this.components) { if (componentName.split('/')[1] === name) { component = this.components[componentName]; break; } } if (!component) { callback(new Error("Component " + name + " not available with base " + this.baseDir)); return; } } if (this.isGraph(component)) { if (typeof process !== 'undefined' && process.execPath && process.execPath.indexOf('node') !== -1) { process.nextTick((function(_this) { return function() { return _this.loadGraph(name, component, callback, metadata); }; })(this)); } else { setTimeout((function(_this) { return function() { return _this.loadGraph(name, component, callback, metadata); }; })(this), 0); } return; } return this.createComponent(name, component, metadata, (function(_this) { return function(err, instance) { if (err) { return callback(err); } if (!instance) { callback(new Error("Component " + name + " could not be loaded.")); return; } if (name === 'Graph') { instance.baseDir = _this.baseDir; } if (typeof name === 'string') { instance.componentName = name; } _this.setIcon(name, instance); return callback(null, instance); }; })(this)); }; ComponentLoader.prototype.createComponent = function(name, component, metadata, callback) { var implementation, instance; implementation = component; if (!implementation) { return callback(new Error("Component " + name + " not available")); } if (typeof implementation === 'string') { if (typeof registerLoader.dynamicLoad === 'function') { registerLoader.dynamicLoad(name, implementation, metadata, callback); return; } return callback(Error("Dynamic loading of " + implementation + " for component " + name + " not available on this platform.")); } if (typeof implementation.getComponent === 'function') { instance = implementation.getComponent(metadata); } else if (typeof implementation === 'function') { instance = implementation(metadata); } else { callback(new Error("Invalid type " + (typeof implementation) + " for component " + name + ".")); return; } return callback(null, instance); }; ComponentLoader.prototype.isGraph = function(cPath) { if (typeof cPath === 'object' && cPath instanceof fbpGraph.Graph) { return true; } if (typeof cPath === 'object' && cPath.processes && cPath.connections) { return true; } if (typeof cPath !== 'string') { return false; } return cPath.indexOf('.fbp') !== -1 || cPath.indexOf('.json') !== -1; }; ComponentLoader.prototype.loadGraph = function(name, component, callback, metadata) { this.createComponent(name, this.components['Graph'], metadata, (function(_this) { return function(err, graph) { var graphSocket; if (err) { return callback(err); } graphSocket = internalSocket.createSocket(); graph.loader = _this; graph.baseDir = _this.baseDir; graph.inPorts.remove('graph'); graph.setGraph(component, function(err) { if (err) { return callback(err); } _this.setIcon(name, graph); return callback(null, graph); }); }; })(this)); }; ComponentLoader.prototype.setIcon = function(name, instance) { var componentName, library, ref; if (!instance.getIcon || instance.getIcon()) { return; } ref = name.split('/'), library = ref[0], componentName = ref[1]; if (componentName && this.getLibraryIcon(library)) { instance.setIcon(this.getLibraryIcon(library)); return; } if (instance.isSubgraph()) { instance.setIcon('sitemap'); return; } instance.setIcon('square'); }; ComponentLoader.prototype.getLibraryIcon = function(prefix) { if (this.libraryIcons[prefix]) { return this.libraryIcons[prefix]; } return null; }; ComponentLoader.prototype.setLibraryIcon = function(prefix, icon) { return this.libraryIcons[prefix] = icon; }; ComponentLoader.prototype.normalizeName = function(packageId, name) { var fullName, prefix; prefix = this.getModulePrefix(packageId); fullName = prefix + "/" + name; if (!packageId) { fullName = name; } return fullName; }; ComponentLoader.prototype.registerComponent = function(packageId, name, cPath, callback) { var fullName; fullName = this.normalizeName(packageId, name); this.components[fullName] = cPath; if (callback) { return callback(); } }; ComponentLoader.prototype.registerGraph = function(packageId, name, gPath, callback) { return this.registerComponent(packageId, name, gPath, callback); }; ComponentLoader.prototype.registerLoader = function(loader, callback) { return loader(this, callback); }; ComponentLoader.prototype.setSource = function(packageId, name, source, language, callback) { if (!registerLoader.setSource) { return callback(new Error('setSource not allowed')); } if (!this.ready) { this.listComponents((function(_this) { return function(err) { if (err) { return callback(err); } return _this.setSource(packageId, name, source, language, callback); }; })(this)); return; } return registerLoader.setSource(this, packageId, name, source, language, callback); }; ComponentLoader.prototype.getSource = function(name, callback) { if (!registerLoader.getSource) { return callback(new Error('getSource not allowed')); } if (!this.ready) { this.listComponents((function(_this) { return function(err) { if (err) { return callback(err); } return _this.getSource(name, callback); }; })(this)); return; } return registerLoader.getSource(this, name, callback); }; ComponentLoader.prototype.clear = function() { this.components = null; this.ready = false; return this.processing = false; }; return ComponentLoader; })(EventEmitter); exports.ComponentLoader = ComponentLoader; }).call(this); /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), /* 11 */ /***/ (function(module, exports, __webpack_require__) { (function() { var EventEmitter, Port, platform, 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 = __webpack_require__(0).EventEmitter; platform = __webpack_require__(6); Port = (function(superClass) { extend(Port, superClass); Port.prototype.description = ''; Port.prototype.required = true; function Port(type) { this.type = type; platform.deprecated('noflo.Port is deprecated. Please port to noflo.InPort/noflo.OutPort'); if (!this.type) { this.type = 'all'; } if (this.type === 'integer') { this.type = 'int'; } this.sockets = []; this.from = null; this.node = null; this.name = null; } Port.prototype.getId = function() { if (!(this.node && this.name)) { return 'Port'; } return this.node + " " + (this.name.toUpperCase()); }; Port.prototype.getDataType = function() { return this.type; }; Port.prototype.getDescription = function() { return this.description; }; Port.prototype.attach = function(socket) { this.sockets.push(socket); return this.attachSocket(socket); }; Port.prototype.attachSocket = function(socket, localId) { if (localId == null) { localId = null; } this.emit("attach", socket, localId); this.from = socket.from; if (socket.setMaxListeners) { socket.setMaxListeners(0); }