UNPKG

nativescript-fabric

Version:
1,766 lines (1,579 loc) 99.8 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 = 15); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /* unknown exports provided */ /* all exports used */ /*!***************************!*\ !*** external "readline" ***! \***************************/ /***/ (function(module, exports) { module.exports = require("readline"); /***/ }), /* 1 */ /* unknown exports provided */ /* all exports used */ /*!*************************************!*\ !*** ./~/prompt-lite/lib/prompt.js ***! \*************************************/ /***/ (function(module, exports, __webpack_require__) { /* * prompt.js: Simple prompt for prompting information from the command line * * (C) 2010, Nodejitsu Inc. * */ var events = __webpack_require__(/*! events */ 12), readline = __webpack_require__(/*! readline */ 0), util = __webpack_require__(/*! util */ 14), async = __webpack_require__(/*! async */ 4), read = __webpack_require__(/*! read */ 9), validate = __webpack_require__(/*! revalidator */ 10).validate, colors = __webpack_require__(/*! colors */ 7); // // Monkey-punch readline.Interface to work-around // https://github.com/joyent/node/issues/3860 // readline.Interface.prototype.setPrompt = function(prompt, length) { this._prompt = prompt; if (length) { this._promptLength = length; } else { var lines = prompt.split(/[\r\n]/); var lastLine = lines[lines.length - 1]; this._promptLength = lastLine.replace(/\u001b\[(\d+(;\d+)*)?m/g, '').length; } }; var stdin = process.stdin, stdout = process.stdout, history = []; var prompt = module.exports = Object.create(events.EventEmitter.prototype); var logger = prompt.logger = { help: 'cyan', error: 'red' }; Object.keys(logger).forEach(function (lvl) { var color = logger[lvl]; logger[lvl] = function () { var argv = [].slice.call(arguments), str = argv.shift(), head = lvl; if (prompt.colors) { head = lvl[color] || lvl; } head += ': '; argv.unshift(head + (str || '')); // // For compatibility with prompt's use of winston. // // TODO: Writing to an uncontrolled stream is wrong. // if (lvl === 'error') { return console.error.apply(null, argv); } stdout.write(util.format.apply(null, argv) + '\n'); } }); prompt.started = false; prompt.paused = false; prompt.allowEmpty = false; prompt.message = 'prompt'; prompt.delimiter = ': '; prompt.colors = true; // // Create an empty object for the properties // known to `prompt` // prompt.properties = {}; // // ### function start (options) // #### @options {Object} **Optional** Options to consume by prompt // Starts the prompt by listening to the appropriate events on `options.stdin` // and `options.stdout`. If no streams are supplied, then `process.stdin` // and `process.stdout` are used, respectively. // prompt.start = function (options) { if (prompt.started) { return; } options = options || {}; stdin = options.stdin || process.stdin; stdout = options.stdout || process.stdout; // // By default: Remember the last `10` prompt property / // answer pairs and don't allow empty responses globally. // prompt.memory = options.memory || 10; prompt.allowEmpty = options.allowEmpty || false; prompt.message = options.message || prompt.message; prompt.delimiter = options.delimiter || prompt.delimiter; prompt.colors = options.colors || prompt.colors; if (process.platform !== 'win32') { // windows falls apart trying to deal with SIGINT process.on('SIGINT', function () { stdout.write('\n'); process.exit(1); }); } prompt.emit('start'); prompt.started = true; return prompt; }; // // ### function pause () // Pauses input coming in from stdin // prompt.pause = function () { if (!prompt.started || prompt.paused) { return; } stdin.pause(); prompt.emit('pause'); prompt.paused = true; return prompt; }; // // ### function resume () // Resumes input coming in from stdin // prompt.resume = function () { if (!prompt.started || !prompt.paused) { return; } stdin.resume(); prompt.emit('resume'); prompt.paused = false; return prompt; }; // // ### function history (search) // #### @search {Number|string} Index or property name to find. // Returns the `property:value` pair from within the prompts // `history` array. // prompt.history = function (search) { if (typeof search === 'number') { return history[search] || {}; } var names = history.map(function (pair) { return typeof pair.property === 'string' ? pair.property : pair.property.name; }); if (~names.indexOf(search)) { return null; } return history.filter(function (pair) { return typeof pair.property === 'string' ? pair.property === search : pair.property.name === search; })[0]; }; // // ### function get (schema, callback) // #### @schema {Array|Object|string} Set of variables to get input for. // #### @callback {function} Continuation to pass control to when complete. // Gets input from the user via stdin for the specified message(s) `msg`. // prompt.get = function (schema, callback) { // // Transforms a full JSON-schema into an array describing path and sub-schemas. // Used for iteration purposes. // function untangle(schema, path) { var results = []; path = path || []; if (schema.properties) { // // Iterate over the properties in the schema and use recursion // to process sub-properties. // Object.keys(schema.properties).forEach(function (key) { var obj = {}; obj[key] = schema.properties[key]; // // Concat a sub-untangling to the results. // results = results.concat(untangle(obj[key], path.concat(key))); }); // Return the results. return results; } // // This is a schema "leaf". // return { path: path, schema: schema }; } // // Iterate over the values in the schema, represented as // a legit single-property object subschemas. Accepts `schema` // of the forms: // // 'prop-name' // // ['string-name', { path: ['or-well-formed-subschema'], properties: ... }] // // { path: ['or-well-formed-subschema'], properties: ... ] } // // { properties: { 'schema-with-no-path' } } // // And transforms them all into // // { path: ['path', 'to', 'property'], properties: { path: { to: ...} } } // function iterate(schema, get, done) { var iterator = [], result = {}; if (typeof schema === 'string') { // // We can iterate over a single string. // iterator.push({ path: [schema], schema: prompt.properties[schema.toLowerCase()] || {} }); } else if (Array.isArray(schema)) { // // An array of strings and/or single-prop schema and/or no-prop schema. // iterator = schema.map(function (element) { if (typeof element === 'string') { return { path: [element], schema: prompt.properties[element.toLowerCase()] || {} }; } else if (element.properties) { return { path: [Object.keys(element.properties)[0]], schema: element.properties[Object.keys(element.properties)[0]] }; } else if (element.path && element.schema) { return element; } else { return { path: [element.name || 'question'], schema: element }; } }); } else if (schema.properties) { // // Or a complete schema `untangle` it for use. // iterator = untangle(schema); } else { // // Or a partial schema and path. // TODO: Evaluate need for this option. // iterator = [{ schema: schema.schema ? schema.schema : schema, path: schema.path || [schema.name || 'question'] }]; } // // Now, iterate and assemble the result. // async.forEachSeries(iterator, function (branch, next) { get(branch, function assembler(err, line) { if (err) { return next(err); } function build(path, line) { var obj = {}; if (path.length) { obj[path[0]] = build(path.slice(1), line); return obj; } return line; } function attach(obj, attr) { var keys; if (typeof attr !== 'object' || attr instanceof Array) { return attr; } keys = Object.keys(attr); if (keys.length) { if (!obj[keys[0]]) { obj[keys[0]] = {}; } obj[keys[0]] = attach(obj[keys[0]], attr[keys[0]]); } return obj; } result = attach(result, build(branch.path, line)); next(); }); }, function (err) { return err ? done(err) : done(null, result); }); } iterate(schema, function get(target, next) { prompt.getInput(target, function (err, line) { return err ? next(err) : next(null, line); }); }, callback); return prompt; }; // // ### function confirm (msg, callback) // #### @msg {Array|Object|string} set of message to confirm // #### @callback {function} Continuation to pass control to when complete. // Confirms a single or series of messages by prompting the user for a Y/N response. // Returns `true` if ALL messages are answered in the affirmative, otherwise `false` // // `msg` can be a string, or object (or array of strings/objects). // An object may have the following properties: // // { // description: 'yes/no' // message to prompt user // pattern: /^[yntf]{1}/i // optional - regex defining acceptable responses // yes: /^[yt]{1}/i // optional - regex defining `affirmative` responses // message: 'yes/no' // optional - message to display for invalid responses // } // prompt.confirm = function (/* msg, options, callback */) { var args = Array.prototype.slice.call(arguments), msg = args.shift(), callback = args.pop(), opts = args.shift(), vars = !Array.isArray(msg) ? [msg] : msg, RX_Y = /^[yt]{1}/i, RX_YN = /^[yntf]{1}/i; function confirm(target, next) { var yes = target.yes || RX_Y, options = mixin({ description: typeof target === 'string' ? target : target.description||'yes/no', pattern: target.pattern || RX_YN, name: 'confirm', message: target.message || 'yes/no' }, opts || {}); prompt.get([options], function (err, result) { next(err ? false : yes.test(result[options.name])); }); } async.rejectSeries(vars, confirm, function(result) { callback(null, result.length===0); }); }; // Variables needed outside of getInput for multiline arrays. var tmp = []; // ### function getInput (prop, callback) // #### @prop {Object|string} Variable to get input for. // #### @callback {function} Continuation to pass control to when complete. // Gets input from the user via stdin for the specified message `msg`. // prompt.getInput = function (prop, callback) { var schema = prop.schema || prop, propName = prop.path && prop.path.join(':') || prop, storedSchema = prompt.properties[propName.toLowerCase()], delim = prompt.delimiter, defaultLine, against, hidden, length, valid, name, raw, msg; // // If there is a stored schema for `propName` in `propmpt.properties` // then use it. // if (schema instanceof Object && !Object.keys(schema).length && typeof storedSchema !== 'undefined') { schema = storedSchema; } // // Build a proper validation schema if we just have a string // and no `storedSchema`. // if (typeof prop === 'string' && !storedSchema) { schema = {}; } schema = convert(schema); defaultLine = schema.default; name = prop.description || schema.description || propName; raw = prompt.colors ? [prompt.message, delim + name.grey, delim.grey] : [prompt.message, delim + name, delim]; prop = { schema: schema, path: propName.split(':') }; // // If the schema has no `properties` value then set // it to an object containing the current schema // for `propName`. // if (!schema.properties) { schema = (function () { var obj = { properties: {} }; obj.properties[propName] = schema; return obj; })(); } // // Handle overrides here. // TODO: Make overrides nestable // if (prompt.override && prompt.override[propName]) { if (prompt._performValidation(name, prop, prompt.override, schema, -1, callback)) { return callback(null, prompt.override[propName]); } delete prompt.override[propName]; } var type = (schema.properties && schema.properties[name] && schema.properties[name].type || '').toLowerCase().trim(), wait = type === 'array'; if (type === 'array') { length = prop.schema.maxItems; if (length) { msg = (tmp.length + 1).toString() + '/' + length.toString(); } else { msg = (tmp.length + 1).toString(); } msg += delim; raw.push(prompt.colors ? msg.grey : msg); } // // Calculate the raw length and colorize the prompt // length = raw.join('').length; raw[0] = raw[0]; msg = raw.join(''); if (schema.help) { schema.help.forEach(function (line) { logger.help(line); }); } // // Emit a "prompting" event // prompt.emit('prompt', prop); // // If there is no default line, set it to an empty string // if(typeof defaultLine === 'undefined') { defaultLine = ''; } // // set to string for readline ( will not accept Numbers ) // defaultLine = defaultLine.toString(); // // Make the actual read // read({ prompt: msg, silent: prop.schema && prop.schema.hidden, default: defaultLine, input: stdin, output: stdout }, function (err, line) { if (err && wait === false) { return callback(err); } var against = {}, numericInput, isValid; if (line !== '') { if (schema.properties[propName]) { var type = (schema.properties[propName].type || '').toLowerCase().trim() || undefined; // // Attempt to parse input as a float if the schema expects a number. // if (type == 'number') { numericInput = parseFloat(line, 10); if (!isNaN(numericInput)) { line = numericInput; } } // // Attempt to parse input as a boolean if the schema expects a boolean // if (type == 'boolean') { if(line === "true") { line = true; } if(line === "false") { line = false; } } // // If the type is an array, wait for the end. Fixes #54 // if (type == 'array') { var length = prop.schema.maxItems; if (err) { if (err.message == 'canceled') { wait = false; stdout.write('\n'); } } else { if (length) { if (tmp.length + 1 < length) { isValid = false; wait = true; } else { isValid = true; wait = false; } } else { isValid = false; wait = true; } tmp.push(line); } line = tmp; } } against[propName] = line; } if (prop && prop.schema.before) { line = prop.schema.before(line); } // Validate if (isValid === undefined) isValid = prompt._performValidation(name, prop, against, schema, line, callback); if (!isValid) { return prompt.getInput(prop, callback); } // // Append this `property:value` pair to the history for `prompt` // and respond to the callback. // prompt._remember(propName, line); callback(null, line); // Make sure `tmp` is emptied tmp = []; }); }; // // ### function performValidation (name, prop, against, schema, line, callback) // #### @name {Object} Variable name // #### @prop {Object|string} Variable to get input for. // #### @against {Object} Input // #### @schema {Object} Validation schema // #### @line {String|Boolean} Input line // #### @callback {function} Continuation to pass control to when complete. // Perfoms user input validation, print errors if needed and returns value according to validation // prompt._performValidation = function (name, prop, against, schema, line, callback) { var numericInput, valid, msg; try { valid = validate(against, schema); } catch (err) { return (line !== -1) ? callback(err) : false; } if (!valid.valid) { msg = line !== -1 ? 'Invalid input for ' : 'Invalid command-line input for '; if (prompt.colors) { logger.error(msg + name.grey); } else { logger.error(msg + name); } if (prop.schema.message) { logger.error(prop.schema.message); } prompt.emit('invalid', prop, line); } return valid.valid; }; // // ### function addProperties (obj, properties, callback) // #### @obj {Object} Object to add properties to // #### @properties {Array} List of properties to get values for // #### @callback {function} Continuation to pass control to when complete. // Prompts the user for values each of the `properties` if `obj` does not already // have a value for the property. Responds with the modified object. // prompt.addProperties = function (obj, properties, callback) { properties = properties.filter(function (prop) { return typeof obj[prop] === 'undefined'; }); if (properties.length === 0) { return callback(obj); } prompt.get(properties, function (err, results) { if (err) { return callback(err); } else if (!results) { return callback(null, obj); } function putNested (obj, path, value) { var last = obj, key; while (path.length > 1) { key = path.shift(); if (!last[key]) { last[key] = {}; } last = last[key]; } last[path.shift()] = value; } Object.keys(results).forEach(function (key) { putNested(obj, key.split('.'), results[key]); }); callback(null, obj); }); return prompt; }; // // ### @private function _remember (property, value) // #### @property {Object|string} Property that the value is in response to. // #### @value {string} User input captured by `prompt`. // Prepends the `property:value` pair into the private `history` Array // for `prompt` so that it can be accessed later. // prompt._remember = function (property, value) { history.unshift({ property: property, value: value }); // // If the length of the `history` Array // has exceeded the specified length to remember, // `prompt.memory`, truncate it. // if (history.length > prompt.memory) { history.splice(prompt.memory, history.length - prompt.memory); } }; // // ### @private function convert (schema) // #### @schema {Object} Schema for a property // Converts the schema into new format if it is in old format // function convert(schema) { var newProps = Object.keys(validate.messages), newSchema = false, key; newProps = newProps.concat(['description', 'dependencies']); for (key in schema) { if (newProps.indexOf(key) > 0) { newSchema = true; break; } } if (!newSchema || schema.validator || schema.warning || typeof schema.empty !== 'undefined') { schema.description = schema.message; schema.message = schema.warning; if (typeof schema.validator === 'function') { schema.conform = schema.validator; } else { schema.pattern = schema.validator; } if (typeof schema.empty !== 'undefined') { schema.required = !(schema.empty); } delete schema.warning; delete schema.validator; delete schema.empty; } return schema; } // // The only piece of utile I need // // ### function mixin (target [source0, source1, ...]) // Copies enumerable properties from `source0 ... sourceN` // onto `target` and returns the resulting object. // function mixin(target) { [].slice.call(arguments, 1).forEach(function (o) { Object.getOwnPropertyNames(o).forEach(function(attr) { var getter = Object.getOwnPropertyDescriptor(o, attr).get, setter = Object.getOwnPropertyDescriptor(o, attr).set; if (!getter && !setter) { target[attr] = o[attr]; } else { Object.defineProperty(target, attr, { get: getter, set: setter }); } }); }); return target; }; /***/ }), /* 2 */ /* unknown exports provided */ /* all exports used */ /*!*********************!*\ !*** external "fs" ***! \*********************/ /***/ (function(module, exports) { module.exports = require("fs"); /***/ }), /* 3 */ /* unknown exports provided */ /* all exports used */ /*!***********************!*\ !*** external "path" ***! \***********************/ /***/ (function(module, exports) { module.exports = require("path"); /***/ }), /* 4 */ /* unknown exports provided */ /* all exports used */ /*!**************************!*\ !*** ./~/async/index.js ***! \**************************/ /***/ (function(module, exports, __webpack_require__) { // This file is just added for convenience so this repository can be // directly checked out into a project's deps folder module.exports = __webpack_require__(/*! ./lib/async */ 5); /***/ }), /* 5 */ /* unknown exports provided */ /* all exports used */ /*!******************************!*\ !*** ./~/async/lib/async.js ***! \******************************/ /***/ (function(module, exports) { /*global setTimeout: false, console: false */ (function () { var async = {}; // global on the server, window in the browser var root = this, previous_async = root.async; if (typeof module !== 'undefined' && module.exports) { module.exports = async; } else { root.async = async; } async.noConflict = function () { root.async = previous_async; return async; }; //// cross-browser compatiblity functions //// var _forEach = function (arr, iterator) { if (arr.forEach) { return arr.forEach(iterator); } for (var i = 0; i < arr.length; i += 1) { iterator(arr[i], i, arr); } }; var _map = function (arr, iterator) { if (arr.map) { return arr.map(iterator); } var results = []; _forEach(arr, function (x, i, a) { results.push(iterator(x, i, a)); }); return results; }; var _reduce = function (arr, iterator, memo) { if (arr.reduce) { return arr.reduce(iterator, memo); } _forEach(arr, function (x, i, a) { memo = iterator(memo, x, i, a); }); return memo; }; var _keys = function (obj) { if (Object.keys) { return Object.keys(obj); } var keys = []; for (var k in obj) { if (obj.hasOwnProperty(k)) { keys.push(k); } } return keys; }; //// exported async module functions //// //// nextTick implementation with browser-compatible fallback //// if (typeof process === 'undefined' || !(process.nextTick)) { async.nextTick = function (fn) { setTimeout(fn, 0); }; } else { async.nextTick = process.nextTick; } async.forEach = function (arr, iterator, callback) { callback = callback || function () {}; if (!arr.length) { return callback(); } var completed = 0; _forEach(arr, function (x) { iterator(x, function (err) { if (err) { callback(err); callback = function () {}; } else { completed += 1; if (completed === arr.length) { callback(null); } } }); }); }; async.forEachSeries = function (arr, iterator, callback) { callback = callback || function () {}; if (!arr.length) { return callback(); } var completed = 0; var iterate = function () { iterator(arr[completed], function (err) { if (err) { callback(err); callback = function () {}; } else { completed += 1; if (completed === arr.length) { callback(null); } else { iterate(); } } }); }; iterate(); }; async.forEachLimit = function (arr, limit, iterator, callback) { callback = callback || function () {}; if (!arr.length || limit <= 0) { return callback(); } var completed = 0; var started = 0; var running = 0; (function replenish () { if (completed === arr.length) { return callback(); } while (running < limit && started < arr.length) { started += 1; running += 1; iterator(arr[started - 1], function (err) { if (err) { callback(err); callback = function () {}; } else { completed += 1; running -= 1; if (completed === arr.length) { callback(); } else { replenish(); } } }); } })(); }; var doParallel = function (fn) { return function () { var args = Array.prototype.slice.call(arguments); return fn.apply(null, [async.forEach].concat(args)); }; }; var doSeries = function (fn) { return function () { var args = Array.prototype.slice.call(arguments); return fn.apply(null, [async.forEachSeries].concat(args)); }; }; var _asyncMap = function (eachfn, arr, iterator, callback) { var results = []; arr = _map(arr, function (x, i) { return {index: i, value: x}; }); eachfn(arr, function (x, callback) { iterator(x.value, function (err, v) { results[x.index] = v; callback(err); }); }, function (err) { callback(err, results); }); }; async.map = doParallel(_asyncMap); async.mapSeries = doSeries(_asyncMap); // reduce only has a series version, as doing reduce in parallel won't // work in many situations. async.reduce = function (arr, memo, iterator, callback) { async.forEachSeries(arr, function (x, callback) { iterator(memo, x, function (err, v) { memo = v; callback(err); }); }, function (err) { callback(err, memo); }); }; // inject alias async.inject = async.reduce; // foldl alias async.foldl = async.reduce; async.reduceRight = function (arr, memo, iterator, callback) { var reversed = _map(arr, function (x) { return x; }).reverse(); async.reduce(reversed, memo, iterator, callback); }; // foldr alias async.foldr = async.reduceRight; var _filter = function (eachfn, arr, iterator, callback) { var results = []; arr = _map(arr, function (x, i) { return {index: i, value: x}; }); eachfn(arr, function (x, callback) { iterator(x.value, function (v) { if (v) { results.push(x); } callback(); }); }, function (err) { callback(_map(results.sort(function (a, b) { return a.index - b.index; }), function (x) { return x.value; })); }); }; async.filter = doParallel(_filter); async.filterSeries = doSeries(_filter); // select alias async.select = async.filter; async.selectSeries = async.filterSeries; var _reject = function (eachfn, arr, iterator, callback) { var results = []; arr = _map(arr, function (x, i) { return {index: i, value: x}; }); eachfn(arr, function (x, callback) { iterator(x.value, function (v) { if (!v) { results.push(x); } callback(); }); }, function (err) { callback(_map(results.sort(function (a, b) { return a.index - b.index; }), function (x) { return x.value; })); }); }; async.reject = doParallel(_reject); async.rejectSeries = doSeries(_reject); var _detect = function (eachfn, arr, iterator, main_callback) { eachfn(arr, function (x, callback) { iterator(x, function (result) { if (result) { main_callback(x); main_callback = function () {}; } else { callback(); } }); }, function (err) { main_callback(); }); }; async.detect = doParallel(_detect); async.detectSeries = doSeries(_detect); async.some = function (arr, iterator, main_callback) { async.forEach(arr, function (x, callback) { iterator(x, function (v) { if (v) { main_callback(true); main_callback = function () {}; } callback(); }); }, function (err) { main_callback(false); }); }; // any alias async.any = async.some; async.every = function (arr, iterator, main_callback) { async.forEach(arr, function (x, callback) { iterator(x, function (v) { if (!v) { main_callback(false); main_callback = function () {}; } callback(); }); }, function (err) { main_callback(true); }); }; // all alias async.all = async.every; async.sortBy = function (arr, iterator, callback) { async.map(arr, function (x, callback) { iterator(x, function (err, criteria) { if (err) { callback(err); } else { callback(null, {value: x, criteria: criteria}); } }); }, function (err, results) { if (err) { return callback(err); } else { var fn = function (left, right) { var a = left.criteria, b = right.criteria; return a < b ? -1 : a > b ? 1 : 0; }; callback(null, _map(results.sort(fn), function (x) { return x.value; })); } }); }; async.auto = function (tasks, callback) { callback = callback || function () {}; var keys = _keys(tasks); if (!keys.length) { return callback(null); } var results = {}; var listeners = []; var addListener = function (fn) { listeners.unshift(fn); }; var removeListener = function (fn) { for (var i = 0; i < listeners.length; i += 1) { if (listeners[i] === fn) { listeners.splice(i, 1); return; } } }; var taskComplete = function () { _forEach(listeners.slice(0), function (fn) { fn(); }); }; addListener(function () { if (_keys(results).length === keys.length) { callback(null, results); callback = function () {}; } }); _forEach(keys, function (k) { var task = (tasks[k] instanceof Function) ? [tasks[k]]: tasks[k]; var taskCallback = function (err) { if (err) { callback(err); // stop subsequent errors hitting callback multiple times callback = function () {}; } else { var args = Array.prototype.slice.call(arguments, 1); if (args.length <= 1) { args = args[0]; } results[k] = args; taskComplete(); } }; var requires = task.slice(0, Math.abs(task.length - 1)) || []; var ready = function () { return _reduce(requires, function (a, x) { return (a && results.hasOwnProperty(x)); }, true) && !results.hasOwnProperty(k); }; if (ready()) { task[task.length - 1](taskCallback, results); } else { var listener = function () { if (ready()) { removeListener(listener); task[task.length - 1](taskCallback, results); } }; addListener(listener); } }); }; async.waterfall = function (tasks, callback) { callback = callback || function () {}; if (!tasks.length) { return callback(); } var wrapIterator = function (iterator) { return function (err) { if (err) { callback(err); callback = function () {}; } else { var args = Array.prototype.slice.call(arguments, 1); var next = iterator.next(); if (next) { args.push(wrapIterator(next)); } else { args.push(callback); } async.nextTick(function () { iterator.apply(null, args); }); } }; }; wrapIterator(async.iterator(tasks))(); }; async.parallel = function (tasks, callback) { callback = callback || function () {}; if (tasks.constructor === Array) { async.map(tasks, function (fn, callback) { if (fn) { fn(function (err) { var args = Array.prototype.slice.call(arguments, 1); if (args.length <= 1) { args = args[0]; } callback.call(null, err, args); }); } }, callback); } else { var results = {}; async.forEach(_keys(tasks), function (k, callback) { tasks[k](function (err) { var args = Array.prototype.slice.call(arguments, 1); if (args.length <= 1) { args = args[0]; } results[k] = args; callback(err); }); }, function (err) { callback(err, results); }); } }; async.series = function (tasks, callback) { callback = callback || function () {}; if (tasks.constructor === Array) { async.mapSeries(tasks, function (fn, callback) { if (fn) { fn(function (err) { var args = Array.prototype.slice.call(arguments, 1); if (args.length <= 1) { args = args[0]; } callback.call(null, err, args); }); } }, callback); } else { var results = {}; async.forEachSeries(_keys(tasks), function (k, callback) { tasks[k](function (err) { var args = Array.prototype.slice.call(arguments, 1); if (args.length <= 1) { args = args[0]; } results[k] = args; callback(err); }); }, function (err) { callback(err, results); }); } }; async.iterator = function (tasks) { var makeCallback = function (index) { var fn = function () { if (tasks.length) { tasks[index].apply(null, arguments); } return fn.next(); }; fn.next = function () { return (index < tasks.length - 1) ? makeCallback(index + 1): null; }; return fn; }; return makeCallback(0); }; async.apply = function (fn) { var args = Array.prototype.slice.call(arguments, 1); return function () { return fn.apply( null, args.concat(Array.prototype.slice.call(arguments)) ); }; }; var _concat = function (eachfn, arr, fn, callback) { var r = []; eachfn(arr, function (x, cb) { fn(x, function (err, y) { r = r.concat(y || []); cb(err); }); }, function (err) { callback(err, r); }); }; async.concat = doParallel(_concat); async.concatSeries = doSeries(_concat); async.whilst = function (test, iterator, callback) { if (test()) { iterator(function (err) { if (err) { return callback(err); } async.whilst(test, iterator, callback); }); } else { callback(); } }; async.until = function (test, iterator, callback) { if (!test()) { iterator(function (err) { if (err) { return callback(err); } async.until(test, iterator, callback); }); } else { callback(); } }; async.queue = function (worker, concurrency) { var workers = 0; var q = { tasks: [], concurrency: concurrency, saturated: null, empty: null, drain: null, push: function (data, callback) { if(data.constructor !== Array) { data = [data]; } _forEach(data, function(task) { q.tasks.push({ data: task, callback: typeof callback === 'function' ? callback : null }); if (q.saturated && q.tasks.length == concurrency) { q.saturated(); } async.nextTick(q.process); }); }, process: function () { if (workers < q.concurrency && q.tasks.length) { var task = q.tasks.shift(); if(q.empty && q.tasks.length == 0) q.empty(); workers += 1; worker(task.data, function () { workers -= 1; if (task.callback) { task.callback.apply(task, arguments); } if(q.drain && q.tasks.length + workers == 0) q.drain(); q.process(); }); } }, length: function () { return q.tasks.length; }, running: function () { return workers; } }; return q; }; var _console_fn = function (name) { return function (fn) { var args = Array.prototype.slice.call(arguments, 1); fn.apply(null, args.concat([function (err) { var args = Array.prototype.slice.call(arguments, 1); if (typeof console !== 'undefined') { if (err) { if (console.error) { console.error(err); } } else if (console[name]) { _forEach(args, function (x) { console[name](x); }); } } }])); }; }; async.log = _console_fn('log'); async.dir = _console_fn('dir'); /*async.info = _console_fn('info'); async.warn = _console_fn('warn'); async.error = _console_fn('error');*/ async.memoize = function (fn, hasher) { var memo = {}; var queues = {}; hasher = hasher || function (x) { return x; }; var memoized = function () { var args = Array.prototype.slice.call(arguments); var callback = args.pop(); var key = hasher.apply(null, args); if (key in memo) { callback.apply(null, memo[key]); } else if (key in queues) { queues[key].push(callback); } else { queues[key] = [callback]; fn.apply(null, args.concat([function () { memo[key] = arguments; var q = queues[key]; delete queues[key]; for (var i = 0, l = q.length; i < l; i++) { q[i].apply(null, arguments); } }])); } }; memoized.unmemoized = fn; return memoized; }; async.unmemoize = function (fn) { return function () { return (fn.unmemoized || fn).apply(null, arguments); }; }; }()); /***/ }), /* 6 */ /* unknown exports provided */ /* all exports used */ /*!******************!*\ !*** ./~/colors ***! \******************/ /***/ (function(module, exports) { function webpackEmptyContext(req) { throw new Error("Cannot find module '" + req + "'."); } webpackEmptyContext.keys = function() { return []; }; webpackEmptyContext.resolve = webpackEmptyContext; module.exports = webpackEmptyContext; webpackEmptyContext.id = 6; /***/ }), /* 7 */ /* unknown exports provided */ /* all exports used */ /*!****************************!*\ !*** ./~/colors/colors.js ***! \****************************/ /***/ (function(module, exports, __webpack_require__) { /* colors.js Copyright (c) 2010 Marak Squires Alexis Sellier (cloudhead) 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. */ var isHeadless = false; if (true) { isHeadless = true; } if (!isHeadless) { var exports = {}; var module = {}; var colors = exports; exports.mode = "browser"; } else { exports.mode = "console"; } // // Prototypes the string object to have additional method calls that add terminal colors // var addProperty = function (color, func) { exports[color] = function (str) { return func.apply(str); }; String.prototype.__defineGetter__(color, func); }; function stylize(str, style) { var styles; if (exports.mode === 'console') { styles = { //styles 'bold' : ['\x1B[1m', '\x1B[22m'], 'italic' : ['\x1B[3m', '\x1B[23m'], 'underline' : ['\x1B[4m', '\x1B[24m'], 'inverse' : ['\x1B[7m', '\x1B[27m'], 'strikethrough' : ['\x1B[9m', '\x1B[29m'], //text colors //grayscale 'white' : ['\x1B[37m', '\x1B[39m'], 'grey' : ['\x1B[90m', '\x1B[39m'], 'black' : ['\x1B[30m', '\x1B[39m'], //colors 'blue' : ['\x1B[34m', '\x1B[39m'], 'cyan' : ['\x1B[36m', '\x1B[39m'], 'green' : ['\x1B[32m', '\x1B[39m'], 'magenta' : ['\x1B[35m', '\x1B[39m'], 'red' : ['\x1B[31m', '\x1B[39m'], 'yellow' : ['\x1B[33m', '\x1B[39m'], //background colors //grayscale 'whiteBG' : ['\x1B[47m', '\x1B[49m'], 'greyBG' : ['\x1B[49;5;8m', '\x1B[49m'], 'blackBG' : ['\x1B[40m', '\x1B[49m'], //colors 'blueBG' : ['\x1B[44m', '\x1B[49m'], 'cyanBG' : ['\x1B[46m', '\x1B[49m'], 'greenBG' : ['\x1B[42m', '\x1B[49m'], 'magentaBG' : ['\x1B[45m', '\x1B[49m'], 'redBG' : ['\x1B[41m', '\x1B[49m'], 'yellowBG' : ['\x1B[43m', '\x1B[49m'] }; } else if (exports.mode === 'browser') { styles = { //styles 'bold' : ['<b>', '</b>'], 'italic' : ['<i>', '</i>'], 'underline' : ['<u>', '</u>'], 'inverse' : ['<span style="background-color:black;color:white;">', '</span>'], 'strikethrough' : ['<del>', '</del>'], //text colors //grayscale 'white' : ['<span style="color:white;">', '</span>'], 'grey' : ['<span style="color:gray;">', '</span>'], 'black' : ['<span style="color:black;">', '</span>'], //colors 'blue' : ['<span style="color:blue;">', '</span>'], 'cyan