diff --git a/README.md b/README.md index f1447ec..91b4178 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,19 @@ As an example you can have a look at this [plugin](https://github.com/akofman/co If the `cordova-plugin-add-swift-support` plugin is already installed to your project, then you can add your own Swift plugin as usual, its prefixed Bridging-Header will be automatically found and merged. +## Importing Swift into ObjectiveC code + +Because **ProductModuleName** of application using some Swift Cordova plugin is different than **ProductModuleName** of the +plugin itself, you need to modify your ***.m*** files imports to: + +``` +#import "Swift2Objc-Header.h" +``` + +\* instead of ~~#import "ProductModuleName-Swift.h"~~ + +This header will be created by this plugin and automatically registered with xcode project. + ## Contributing The src folder contains ECMAScript 2015 source files. diff --git a/add-swift-support.js b/add-swift-support.js index a3dee94..b30e97d 100644 --- a/add-swift-support.js +++ b/add-swift-support.js @@ -78,7 +78,7 @@ return /******/ (function(modules) { // webpackBootstrap /************************************************************************/ /******/ ([ /* 0 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { /** * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. @@ -110,13 +110,13 @@ function isObject(value) { module.exports = isObject; -/***/ }, +/***/ }), /* 1 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { -var baseAssign = __webpack_require__(18), - baseCreate = __webpack_require__(55), - isIterateeCall = __webpack_require__(14); +var baseAssign = __webpack_require__(26), + baseCreate = __webpack_require__(73), + isIterateeCall = __webpack_require__(15); /** * Creates an object that inherits from the given `prototype` object. If a @@ -163,9 +163,9 @@ function create(prototype, properties, guard) { module.exports = create; -/***/ }, +/***/ }), /* 2 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { var isObject = __webpack_require__(0); @@ -183,12 +183,12 @@ function toObject(value) { module.exports = toObject; -/***/ }, +/***/ }), /* 3 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { -var getNative = __webpack_require__(24), - isLength = __webpack_require__(6), +var getNative = __webpack_require__(32), + isLength = __webpack_require__(7), isObjectLike = __webpack_require__(4); /** `Object#toString` result references. */ @@ -229,9 +229,9 @@ var isArray = nativeIsArray || function(value) { module.exports = isArray; -/***/ }, +/***/ }), /* 4 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { /** * Checks if `value` is object-like. @@ -247,92 +247,15 @@ function isObjectLike(value) { module.exports = isObjectLike; -/***/ }, +/***/ }), /* 5 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { module.exports = require("util"); -/***/ }, +/***/ }), /* 6 */ -/***/ function(module, exports) { - -/** - * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) - * of an array-like value. - */ -var MAX_SAFE_INTEGER = 9007199254740991; - -/** - * Checks if `value` is a valid array-like length. - * - * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - */ -function isLength(value) { - return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; -} - -module.exports = isLength; - - -/***/ }, -/* 7 */ -/***/ function(module, exports, __webpack_require__) { - -var getNative = __webpack_require__(24), - isArrayLike = __webpack_require__(10), - isObject = __webpack_require__(0), - shimKeys = __webpack_require__(74); - -/* Native method references for those with the same name as other `lodash` methods. */ -var nativeKeys = getNative(Object, 'keys'); - -/** - * Creates an array of the own enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) - * for more details. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keys(new Foo); - * // => ['a', 'b'] (iteration order is not guaranteed) - * - * _.keys('hi'); - * // => ['0', '1'] - */ -var keys = !nativeKeys ? shimKeys : function(object) { - var Ctor = object == null ? undefined : object.constructor; - if ((typeof Ctor == 'function' && Ctor.prototype === object) || - (typeof object != 'function' && isArrayLike(object))) { - return shimKeys(object); - } - return isObject(object) ? nativeKeys(object) : []; -}; - -module.exports = keys; - - -/***/ }, -/* 8 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { // Generated by CoffeeScript 1.9.1 (function() { @@ -343,7 +266,7 @@ module.exports = keys; isFunction = __webpack_require__(11); - isEmpty = __webpack_require__(75); + isEmpty = __webpack_require__(93); XMLElement = null; @@ -365,13 +288,13 @@ module.exports = keys; this.options = this.parent.options; this.stringify = this.parent.stringify; if (XMLElement === null) { - XMLElement = __webpack_require__(33); - XMLCData = __webpack_require__(29); - XMLComment = __webpack_require__(30); - XMLDeclaration = __webpack_require__(31); - XMLDocType = __webpack_require__(32); - XMLRaw = __webpack_require__(89); - XMLText = __webpack_require__(91); + XMLElement = __webpack_require__(24); + XMLCData = __webpack_require__(20); + XMLComment = __webpack_require__(21); + XMLDeclaration = __webpack_require__(22); + XMLDocType = __webpack_require__(23); + XMLRaw = __webpack_require__(61); + XMLText = __webpack_require__(63); } } @@ -667,18 +590,95 @@ module.exports = keys; }).call(this); -/***/ }, +/***/ }), +/* 7 */ +/***/ (function(module, exports) { + +/** + * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) + * of an array-like value. + */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** + * Checks if `value` is a valid array-like length. + * + * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + */ +function isLength(value) { + return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; +} + +module.exports = isLength; + + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + +var getNative = __webpack_require__(32), + isArrayLike = __webpack_require__(10), + isObject = __webpack_require__(0), + shimKeys = __webpack_require__(92); + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeKeys = getNative(Object, 'keys'); + +/** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) + * for more details. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ +var keys = !nativeKeys ? shimKeys : function(object) { + var Ctor = object == null ? undefined : object.constructor; + if ((typeof Ctor == 'function' && Ctor.prototype === object) || + (typeof object != 'function' && isArrayLike(object))) { + return shimKeys(object); + } + return isObject(object) ? nativeKeys(object) : []; +}; + +module.exports = keys; + + +/***/ }), /* 9 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { module.exports = require("fs"); -/***/ }, +/***/ }), /* 10 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { -var getLength = __webpack_require__(23), - isLength = __webpack_require__(6); +var getLength = __webpack_require__(31), + isLength = __webpack_require__(7); /** * Checks if `value` is array-like. @@ -694,9 +694,9 @@ function isArrayLike(value) { module.exports = isArrayLike; -/***/ }, +/***/ }), /* 11 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { var isObject = __webpack_require__(0); @@ -738,15 +738,27 @@ function isFunction(value) { module.exports = isFunction; -/***/ }, +/***/ }), /* 12 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { module.exports = require("path"); -/***/ }, +/***/ }), /* 13 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { + +module.exports = { + DEFAULT_INITIAL_SIZE: (8 * 1024), + DEFAULT_INCREMENT_AMOUNT: (8 * 1024), + DEFAULT_FREQUENCY: 1, + DEFAULT_CHUNK_SIZE: 1024 +}; + + +/***/ }), +/* 14 */ +/***/ (function(module, exports) { /** Used to detect unsigned integer values. */ var reIsUint = /^\d+$/; @@ -774,12 +786,12 @@ function isIndex(value, length) { module.exports = isIndex; -/***/ }, -/* 14 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { var isArrayLike = __webpack_require__(10), - isIndex = __webpack_require__(13), + isIndex = __webpack_require__(14), isObject = __webpack_require__(0); /** @@ -808,9 +820,9 @@ function isIterateeCall(value, index, object) { module.exports = isIterateeCall; -/***/ }, -/* 15 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { var isArrayLike = __webpack_require__(10), isObjectLike = __webpack_require__(4); @@ -848,28 +860,16 @@ function isArguments(value) { module.exports = isArguments; -/***/ }, -/* 16 */ -/***/ function(module, exports) { - -module.exports = { - DEFAULT_INITIAL_SIZE: (8 * 1024), - DEFAULT_INCREMENT_AMOUNT: (8 * 1024), - DEFAULT_FREQUENCY: 1, - DEFAULT_CHUNK_SIZE: 1024 -}; - - -/***/ }, +/***/ }), /* 17 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { /** * Module dependencies. */ -var deprecate = __webpack_require__(35); +var deprecate = __webpack_require__(18); var DOMParser = __webpack_require__(101).DOMParser; /** @@ -1066,3054 +1066,3054 @@ function parsePlistXML (node) { } -/***/ }, +/***/ }), /* 18 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { -var baseCopy = __webpack_require__(54), - keys = __webpack_require__(7); /** - * The base implementation of `_.assign` without support for argument juggling, - * multiple sources, and `customizer` functions. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @returns {Object} Returns `object`. + * For Node.js, simply re-export the core `util.deprecate` function. */ -function baseAssign(object, source) { - return source == null - ? object - : baseCopy(source, keys(source), object); -} -module.exports = baseAssign; +module.exports = __webpack_require__(5).deprecate; -/***/ }, +/***/ }), /* 19 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { -var toObject = __webpack_require__(2); +/* WEBPACK VAR INJECTION */(function(__dirname) {var util = __webpack_require__(5), + f = util.format, + EventEmitter = __webpack_require__(38).EventEmitter, + path = __webpack_require__(12), + uuid = __webpack_require__(44), + fork = __webpack_require__(103).fork, + pbxWriter = __webpack_require__(54), + pbxFile = __webpack_require__(53), + fs = __webpack_require__(9), + parser = __webpack_require__(52), + plist = __webpack_require__(48), + COMMENT_KEY = /_comment$/ -/** - * The base implementation of `get` without support for string paths - * and default values. - * - * @private - * @param {Object} object The object to query. - * @param {Array} path The path of the property to get. - * @param {string} [pathKey] The key representation of path. - * @returns {*} Returns the resolved value. - */ -function baseGet(object, path, pathKey) { - if (object == null) { - return; - } - if (pathKey !== undefined && pathKey in toObject(object)) { - path = [pathKey]; - } - var index = 0, - length = path.length; +function pbxProject(filename) { + if (!(this instanceof pbxProject)) + return new pbxProject(filename); - while (object != null && index < length) { - object = object[path[index++]]; - } - return (index && index == length) ? object : undefined; + this.filepath = path.resolve(filename) } -module.exports = baseGet; +util.inherits(pbxProject, EventEmitter) +pbxProject.prototype.parse = function(cb) { + var worker = fork(__dirname + '/parseJob.js', [this.filepath]) -/***/ }, -/* 20 */ -/***/ function(module, exports, __webpack_require__) { + worker.on('message', function(msg) { + if (msg.name == 'SyntaxError' || msg.code) { + this.emit('error', msg); + } else { + this.hash = msg; + this.emit('end', null, msg) + } + }.bind(this)); -var baseIsEqualDeep = __webpack_require__(60), - isObject = __webpack_require__(0), - isObjectLike = __webpack_require__(4); + if (cb) { + this.on('error', cb); + this.on('end', cb); + } -/** - * The base implementation of `_.isEqual` without support for `this` binding - * `customizer` functions. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {Function} [customizer] The function to customize comparing values. - * @param {boolean} [isLoose] Specify performing partial comparisons. - * @param {Array} [stackA] Tracks traversed `value` objects. - * @param {Array} [stackB] Tracks traversed `other` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - */ -function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) { - if (value === other) { - return true; - } - if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) { - return value !== value && other !== other; - } - return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB); + return this; } -module.exports = baseIsEqual; - - -/***/ }, -/* 21 */ -/***/ function(module, exports) { +pbxProject.prototype.parseSync = function() { + var file_contents = fs.readFileSync(this.filepath, 'utf-8'); -/** - * The base implementation of `_.property` without support for deep paths. - * - * @private - * @param {string} key The key of the property to get. - * @returns {Function} Returns the new function. - */ -function baseProperty(key) { - return function(object) { - return object == null ? undefined : object[key]; - }; + this.hash = parser.parse(file_contents); + return this; } -module.exports = baseProperty; +pbxProject.prototype.writeSync = function() { + this.writer = new pbxWriter(this.hash); + return this.writer.writeSync(); +} +pbxProject.prototype.allUuids = function() { + var sections = this.hash.project.objects, + uuids = [], + section; -/***/ }, -/* 22 */ -/***/ function(module, exports, __webpack_require__) { + for (key in sections) { + section = sections[key] + uuids = uuids.concat(Object.keys(section)) + } -var identity = __webpack_require__(28); + uuids = uuids.filter(function(str) { + return !COMMENT_KEY.test(str) && str.length == 24; + }); -/** - * A specialized version of `baseCallback` which only supports `this` binding - * and specifying the number of arguments to provide to `func`. - * - * @private - * @param {Function} func The function to bind. - * @param {*} thisArg The `this` binding of `func`. - * @param {number} [argCount] The number of arguments to provide to `func`. - * @returns {Function} Returns the callback. - */ -function bindCallback(func, thisArg, argCount) { - if (typeof func != 'function') { - return identity; - } - if (thisArg === undefined) { - return func; - } - switch (argCount) { - case 1: return function(value) { - return func.call(thisArg, value); - }; - case 3: return function(value, index, collection) { - return func.call(thisArg, value, index, collection); - }; - case 4: return function(accumulator, value, index, collection) { - return func.call(thisArg, accumulator, value, index, collection); - }; - case 5: return function(value, other, key, object, source) { - return func.call(thisArg, value, other, key, object, source); - }; - } - return function() { - return func.apply(thisArg, arguments); - }; + return uuids; } -module.exports = bindCallback; - - -/***/ }, -/* 23 */ -/***/ function(module, exports, __webpack_require__) { +pbxProject.prototype.generateUuid = function() { + var id = uuid.v4() + .replace(/-/g, '') + .substr(0, 24) + .toUpperCase() -var baseProperty = __webpack_require__(21); + if (this.allUuids().indexOf(id) >= 0) { + return this.generateUuid(); + } else { + return id; + } +} -/** - * Gets the "length" property value of `object`. - * - * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) - * that affects Safari on at least iOS 8.1-8.3 ARM64. - * - * @private - * @param {Object} object The object to query. - * @returns {*} Returns the "length" value. - */ -var getLength = baseProperty('length'); +pbxProject.prototype.addPluginFile = function(path, opt) { + var file = new pbxFile(path, opt); -module.exports = getLength; + file.plugin = true; // durr + correctForPluginsPath(file, this); + // null is better for early errors + if (this.hasFile(file.path)) return null; -/***/ }, -/* 24 */ -/***/ function(module, exports, __webpack_require__) { + file.fileRef = this.generateUuid(); -var isNative = __webpack_require__(76); + this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToPluginsPbxGroup(file); // PBXGroup -/** - * Gets the native function at `key` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {string} key The key of the method to get. - * @returns {*} Returns the function if it's native, else `undefined`. - */ -function getNative(object, key) { - var value = object == null ? undefined : object[key]; - return isNative(value) ? value : undefined; + return file; } -module.exports = getNative; +pbxProject.prototype.removePluginFile = function(path, opt) { + var file = new pbxFile(path, opt); + correctForPluginsPath(file, this); + this.removeFromPbxFileReferenceSection(file); // PBXFileReference + this.removeFromPluginsPbxGroup(file); // PBXGroup -/***/ }, -/* 25 */ -/***/ function(module, exports, __webpack_require__) { + return file; +} -var isArray = __webpack_require__(3), - toObject = __webpack_require__(2); +pbxProject.prototype.addProductFile = function(targetPath, opt) { + var file = new pbxFile(targetPath, opt); -/** Used to match property names within property paths. */ -var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/, - reIsPlainProp = /^\w*$/; + file.includeInIndex = 0; + file.fileRef = this.generateUuid(); + file.target = opt ? opt.target : undefined; + file.group = opt ? opt.group : undefined; + file.uuid = this.generateUuid(); + file.path = file.basename; -/** - * Checks if `value` is a property name and not a property path. - * - * @private - * @param {*} value The value to check. - * @param {Object} [object] The object to query keys on. - * @returns {boolean} Returns `true` if `value` is a property name, else `false`. - */ -function isKey(value, object) { - var type = typeof value; - if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') { - return true; - } - if (isArray(value)) { - return false; - } - var result = !reIsDeepProp.test(value); - return result || (object != null && value in toObject(object)); -} + this.addToPbxFileReferenceSection(file); + this.addToProductsPbxGroup(file); // PBXGroup -module.exports = isKey; + return file; +} +pbxProject.prototype.removeProductFile = function(path, opt) { + var file = new pbxFile(path, opt); -/***/ }, -/* 26 */ -/***/ function(module, exports, __webpack_require__) { + this.removeFromProductsPbxGroup(file); // PBXGroup -var isObject = __webpack_require__(0); + return file; +} /** - * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` if suitable for strict - * equality comparisons, else `false`. + * @param path {String} + * @param opt {Object} see pbxFile for avail options + * @param group {String} group key + * @returns {Object} file; see pbxFile */ -function isStrictComparable(value) { - return value === value && !isObject(value); -} - -module.exports = isStrictComparable; - +pbxProject.prototype.addSourceFile = function (path, opt, group) { + var file; + if (group) { + file = this.addFile(path, group, opt); + } + else { + file = this.addPluginFile(path, opt); + } -/***/ }, -/* 27 */ -/***/ function(module, exports, __webpack_require__) { + if (!file) return false; -var baseToString = __webpack_require__(66), - isArray = __webpack_require__(3); + file.target = opt ? opt.target : undefined; + file.uuid = this.generateUuid(); -/** Used to match property names within property paths. */ -var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g; + this.addToPbxBuildFileSection(file); // PBXBuildFile + this.addToPbxSourcesBuildPhase(file); // PBXSourcesBuildPhase -/** Used to match backslashes in property paths. */ -var reEscapeChar = /\\(\\)?/g; + return file; +} /** - * Converts `value` to property path array if it's not one. * - * @private - * @param {*} value The value to process. - * @returns {Array} Returns the property path array. + * @param path {String} + * @param opt {Object} see pbxFile for avail options + * @param group {String} group key + * @returns {Object} file; see pbxFile */ -function toPath(value) { - if (isArray(value)) { - return value; - } - var result = []; - baseToString(value).replace(rePropName, function(match, number, quote, string) { - result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); - }); - return result; -} - -module.exports = toPath; - +pbxProject.prototype.removeSourceFile = function (path, opt, group) { + var file; + if (group) { + file = this.removeFile(path, group, opt); + } + else { + file = this.removePluginFile(path, opt); + } + file.target = opt ? opt.target : undefined; + this.removeFromPbxBuildFileSection(file); // PBXBuildFile + this.removeFromPbxSourcesBuildPhase(file); // PBXSourcesBuildPhase -/***/ }, -/* 28 */ -/***/ function(module, exports) { + return file; +} /** - * This method returns the first argument provided to it. - * - * @static - * @memberOf _ - * @category Utility - * @param {*} value Any value. - * @returns {*} Returns `value`. - * @example - * - * var object = { 'user': 'fred' }; * - * _.identity(object) === object; - * // => true + * @param path {String} + * @param opt {Object} see pbxFile for avail options + * @param group {String} group key + * @returns {Object} file; see pbxFile */ -function identity(value) { - return value; +pbxProject.prototype.addHeaderFile = function (path, opt, group) { + if (group) { + return this.addFile(path, group, opt); + } + else { + return this.addPluginFile(path, opt); + } } -module.exports = identity; +/** + * + * @param path {String} + * @param opt {Object} see pbxFile for avail options + * @param group {String} group key + * @returns {Object} file; see pbxFile + */ +pbxProject.prototype.removeHeaderFile = function (path, opt, group) { + if (group) { + return this.removeFile(path, group, opt); + } + else { + return this.removePluginFile(path, opt); + } +} +/** + * + * @param path {String} + * @param opt {Object} see pbxFile for avail options + * @param group {String} group key + * @returns {Object} file; see pbxFile + */ +pbxProject.prototype.addResourceFile = function(path, opt, group) { + opt = opt || {}; -/***/ }, -/* 29 */ -/***/ function(module, exports, __webpack_require__) { + var file; -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLCData, XMLNode, create, - 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; + if (opt.plugin) { + file = this.addPluginFile(path, opt); + if (!file) return false; + } else { + file = new pbxFile(path, opt); + if (this.hasFile(file.path)) return false; + } - create = __webpack_require__(1); + file.uuid = this.generateUuid(); + file.target = opt ? opt.target : undefined; - XMLNode = __webpack_require__(8); + if (!opt.plugin) { + correctForResourcesPath(file, this); + file.fileRef = this.generateUuid(); + } - module.exports = XMLCData = (function(superClass) { - extend(XMLCData, superClass); + if (!opt.variantGroup) { + this.addToPbxBuildFileSection(file); // PBXBuildFile + this.addToPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase + } + + if (!opt.plugin) { + this.addToPbxFileReferenceSection(file); // PBXFileReference + if (group) { + if (this.getPBXGroupByKey(group)) { + this.addToPbxGroup(file, group); //Group other than Resources (i.e. 'splash') + } + else if (this.getPBXVariantGroupByKey(group)) { + this.addToPbxVariantGroup(file, group); // PBXVariantGroup + } + } + else { + this.addToResourcesPbxGroup(file); // PBXGroup + } - function XMLCData(parent, text) { - XMLCData.__super__.constructor.call(this, parent); - if (text == null) { - throw new Error("Missing CDATA text"); - } - this.text = this.stringify.cdata(text); } - XMLCData.prototype.clone = function() { - return create(XMLCData.prototype, this); - }; + return file; +} - XMLCData.prototype.toString = function(options, level) { - var indent, newline, offset, pretty, r, ref, ref1, ref2, space; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - level || (level = 0); - space = new Array(level + offset + 1).join(indent); - r = ''; - if (pretty) { - r += space; - } - r += ''; - if (pretty) { - r += newline; - } - return r; - }; +/** + * + * @param path {String} + * @param opt {Object} see pbxFile for avail options + * @param group {String} group key + * @returns {Object} file; see pbxFile + */ +pbxProject.prototype.removeResourceFile = function(path, opt, group) { + var file = new pbxFile(path, opt); + file.target = opt ? opt.target : undefined; - return XMLCData; + correctForResourcesPath(file, this); - })(XMLNode); + this.removeFromPbxBuildFileSection(file); // PBXBuildFile + this.removeFromPbxFileReferenceSection(file); // PBXFileReference + if (group) { + if (this.getPBXGroupByKey(group)) { + this.removeFromPbxGroup(file, group); //Group other than Resources (i.e. 'splash') + } + else if (this.getPBXVariantGroupByKey(group)) { + this.removeFromPbxVariantGroup(file, group); // PBXVariantGroup + } + } + else { + this.removeFromResourcesPbxGroup(file); // PBXGroup + } + this.removeFromPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase -}).call(this); + return file; +} +pbxProject.prototype.addFramework = function(fpath, opt) { + var customFramework = opt && opt.customFramework == true; + var link = !opt || (opt.link == undefined || opt.link); //defaults to true if not specified + var embed = opt && opt.embed; //defaults to false if not specified -/***/ }, -/* 30 */ -/***/ function(module, exports, __webpack_require__) { + if (opt) { + delete opt.embed; + } -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLComment, XMLNode, create, - 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; + var file = new pbxFile(fpath, opt); - create = __webpack_require__(1); + file.uuid = this.generateUuid(); + file.fileRef = this.generateUuid(); + file.target = opt ? opt.target : undefined; - XMLNode = __webpack_require__(8); + if (this.hasFile(file.path)) return false; - module.exports = XMLComment = (function(superClass) { - extend(XMLComment, superClass); + this.addToPbxBuildFileSection(file); // PBXBuildFile + this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToFrameworksPbxGroup(file); // PBXGroup - function XMLComment(parent, text) { - XMLComment.__super__.constructor.call(this, parent); - if (text == null) { - throw new Error("Missing comment text"); - } - this.text = this.stringify.comment(text); + if (link) { + this.addToPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase } - XMLComment.prototype.clone = function() { - return create(XMLComment.prototype, this); - }; - - XMLComment.prototype.toString = function(options, level) { - var indent, newline, offset, pretty, r, ref, ref1, ref2, space; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - level || (level = 0); - space = new Array(level + offset + 1).join(indent); - r = ''; - if (pretty) { - r += space; - } - r += ''; - if (pretty) { - r += newline; - } - return r; - }; + if (customFramework) { + this.addToFrameworkSearchPaths(file); - return XMLComment; + if (embed) { + opt.embed = embed; + var embeddedFile = new pbxFile(fpath, opt); - })(XMLNode); + embeddedFile.uuid = this.generateUuid(); + embeddedFile.fileRef = file.fileRef; -}).call(this); + //keeping a separate PBXBuildFile entry for Embed Frameworks + this.addToPbxBuildFileSection(embeddedFile); // PBXBuildFile + this.addToPbxEmbedFrameworksBuildPhase(embeddedFile); // PBXCopyFilesBuildPhase -/***/ }, -/* 31 */ -/***/ function(module, exports, __webpack_require__) { + return embeddedFile; + } + } -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLDeclaration, XMLNode, create, isObject, - 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; + return file; +} - create = __webpack_require__(1); +pbxProject.prototype.removeFramework = function(fpath, opt) { + var embed = opt && opt.embed; - isObject = __webpack_require__(0); + if (opt) { + delete opt.embed; + } - XMLNode = __webpack_require__(8); + var file = new pbxFile(fpath, opt); + file.target = opt ? opt.target : undefined; - module.exports = XMLDeclaration = (function(superClass) { - extend(XMLDeclaration, superClass); + this.removeFromPbxBuildFileSection(file); // PBXBuildFile + this.removeFromPbxFileReferenceSection(file); // PBXFileReference + this.removeFromFrameworksPbxGroup(file); // PBXGroup + this.removeFromPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase - function XMLDeclaration(parent, version, encoding, standalone) { - var ref; - XMLDeclaration.__super__.constructor.call(this, parent); - if (isObject(version)) { - ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone; - } - if (!version) { - version = '1.0'; - } - this.version = this.stringify.xmlVersion(version); - if (encoding != null) { - this.encoding = this.stringify.xmlEncoding(encoding); - } - if (standalone != null) { - this.standalone = this.stringify.xmlStandalone(standalone); - } + if (opt && opt.customFramework) { + this.removeFromFrameworkSearchPaths(file); } - XMLDeclaration.prototype.toString = function(options, level) { - var indent, newline, offset, pretty, r, ref, ref1, ref2, space; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - level || (level = 0); - space = new Array(level + offset + 1).join(indent); - r = ''; - if (pretty) { - r += space; - } - r += ''; - if (pretty) { - r += newline; - } - return r; - }; - - return XMLDeclaration; + opt = opt || {}; + opt.embed = true; + var embeddedFile = new pbxFile(fpath, opt); - })(XMLNode); + embeddedFile.fileRef = file.fileRef; -}).call(this); + this.removeFromPbxBuildFileSection(embeddedFile); // PBXBuildFile + this.removeFromPbxEmbedFrameworksBuildPhase(embeddedFile); // PBXCopyFilesBuildPhase + return file; +} -/***/ }, -/* 32 */ -/***/ function(module, exports, __webpack_require__) { -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLProcessingInstruction, create, isObject; +pbxProject.prototype.addCopyfile = function(fpath, opt) { + var file = new pbxFile(fpath, opt); - create = __webpack_require__(1); + // catch duplicates + if (this.hasFile(file.path)) { + file = this.hasFile(file.path); + } - isObject = __webpack_require__(0); + file.fileRef = file.uuid = this.generateUuid(); + file.target = opt ? opt.target : undefined; - XMLCData = __webpack_require__(29); + this.addToPbxBuildFileSection(file); // PBXBuildFile + this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToPbxCopyfilesBuildPhase(file); // PBXCopyFilesBuildPhase - XMLComment = __webpack_require__(30); + return file; +} - XMLDTDAttList = __webpack_require__(85); +pbxProject.prototype.pbxCopyfilesBuildPhaseObj = function(target) { + return this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Copy Files', target); +} - XMLDTDEntity = __webpack_require__(87); +pbxProject.prototype.addToPbxCopyfilesBuildPhase = function(file) { + var sources = this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Copy Files', file.target); + sources.files.push(pbxBuildPhaseObj(file)); +} - XMLDTDElement = __webpack_require__(86); +pbxProject.prototype.removeCopyfile = function(fpath, opt) { + var file = new pbxFile(fpath, opt); + file.target = opt ? opt.target : undefined; - XMLDTDNotation = __webpack_require__(88); + this.removeFromPbxBuildFileSection(file); // PBXBuildFile + this.removeFromPbxFileReferenceSection(file); // PBXFileReference + this.removeFromPbxCopyfilesBuildPhase(file); // PBXFrameworksBuildPhase - XMLProcessingInstruction = __webpack_require__(34); + return file; +} - module.exports = XMLDocType = (function() { - function XMLDocType(parent, pubID, sysID) { - var ref, ref1; - this.documentObject = parent; - this.stringify = this.documentObject.stringify; - this.children = []; - if (isObject(pubID)) { - ref = pubID, pubID = ref.pubID, sysID = ref.sysID; - } - if (sysID == null) { - ref1 = [pubID, sysID], sysID = ref1[0], pubID = ref1[1]; - } - if (pubID != null) { - this.pubID = this.stringify.dtdPubID(pubID); - } - if (sysID != null) { - this.sysID = this.stringify.dtdSysID(sysID); - } +pbxProject.prototype.removeFromPbxCopyfilesBuildPhase = function(file) { + var sources = this.pbxCopyfilesBuildPhaseObj(file.target); + for (i in sources.files) { + if (sources.files[i].comment == longComment(file)) { + sources.files.splice(i, 1); + break; + } } +} - XMLDocType.prototype.element = function(name, value) { - var child; - child = new XMLDTDElement(this, name, value); - this.children.push(child); - return this; - }; +pbxProject.prototype.addStaticLibrary = function(path, opt) { + opt = opt || {}; - XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { - var child; - child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue); - this.children.push(child); - return this; - }; + var file; - XMLDocType.prototype.entity = function(name, value) { - var child; - child = new XMLDTDEntity(this, false, name, value); - this.children.push(child); - return this; - }; + if (opt.plugin) { + file = this.addPluginFile(path, opt); + if (!file) return false; + } else { + file = new pbxFile(path, opt); + if (this.hasFile(file.path)) return false; + } - XMLDocType.prototype.pEntity = function(name, value) { - var child; - child = new XMLDTDEntity(this, true, name, value); - this.children.push(child); - return this; - }; + file.uuid = this.generateUuid(); + file.target = opt ? opt.target : undefined; - XMLDocType.prototype.notation = function(name, value) { - var child; - child = new XMLDTDNotation(this, name, value); - this.children.push(child); - return this; - }; + if (!opt.plugin) { + file.fileRef = this.generateUuid(); + this.addToPbxFileReferenceSection(file); // PBXFileReference + } - XMLDocType.prototype.cdata = function(value) { - var child; - child = new XMLCData(this, value); - this.children.push(child); - return this; - }; + this.addToPbxBuildFileSection(file); // PBXBuildFile + this.addToPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase + this.addToLibrarySearchPaths(file); // make sure it gets built! - XMLDocType.prototype.comment = function(value) { - var child; - child = new XMLComment(this, value); - this.children.push(child); - return this; - }; + return file; +} - XMLDocType.prototype.instruction = function(target, value) { - var child; - child = new XMLProcessingInstruction(this, target, value); - this.children.push(child); - return this; - }; +// helper addition functions +pbxProject.prototype.addToPbxBuildFileSection = function(file) { + var commentKey = f("%s_comment", file.uuid); - XMLDocType.prototype.root = function() { - return this.documentObject.root(); - }; + this.pbxBuildFileSection()[file.uuid] = pbxBuildFileObj(file); + this.pbxBuildFileSection()[commentKey] = pbxBuildFileComment(file); +} - XMLDocType.prototype.document = function() { - return this.documentObject; - }; +pbxProject.prototype.removeFromPbxBuildFileSection = function(file) { + var uuid; - XMLDocType.prototype.toString = function(options, level) { - var child, i, indent, len, newline, offset, pretty, r, ref, ref1, ref2, ref3, space; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - level || (level = 0); - space = new Array(level + offset + 1).join(indent); - r = ''; - if (pretty) { - r += space; - } - r += ' 0) { - r += ' ['; - if (pretty) { - r += newline; - } - ref3 = this.children; - for (i = 0, len = ref3.length; i < len; i++) { - child = ref3[i]; - r += child.toString(options, level + 1); + for (uuid in this.pbxBuildFileSection()) { + if (this.pbxBuildFileSection()[uuid].fileRef_comment == file.basename) { + file.uuid = uuid; + delete this.pbxBuildFileSection()[uuid]; } - r += ']'; - } - r += '>'; - if (pretty) { - r += newline; - } - return r; - }; - - XMLDocType.prototype.ele = function(name, value) { - return this.element(name, value); - }; + } + var commentKey = f("%s_comment", file.uuid); + delete this.pbxBuildFileSection()[commentKey]; +} - XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { - return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue); - }; +pbxProject.prototype.addPbxGroup = function(filePathsArray, name, path, sourceTree) { + var groups = this.hash.project.objects['PBXGroup'], + pbxGroupUuid = this.generateUuid(), + commentKey = f("%s_comment", pbxGroupUuid), + pbxGroup = { + isa: 'PBXGroup', + children: [], + name: name, + path: path, + sourceTree: sourceTree ? sourceTree : '""' + }, + fileReferenceSection = this.pbxFileReferenceSection(), + filePathToReference = {}; - XMLDocType.prototype.ent = function(name, value) { - return this.entity(name, value); - }; + for (var key in fileReferenceSection) { + // only look for comments + if (!COMMENT_KEY.test(key)) continue; - XMLDocType.prototype.pent = function(name, value) { - return this.pEntity(name, value); - }; + var fileReferenceKey = key.split(COMMENT_KEY)[0], + fileReference = fileReferenceSection[fileReferenceKey]; - XMLDocType.prototype.not = function(name, value) { - return this.notation(name, value); - }; + filePathToReference[fileReference.path] = { fileRef: fileReferenceKey, basename: fileReferenceSection[key] }; + } - XMLDocType.prototype.dat = function(value) { - return this.cdata(value); - }; + for (var index = 0; index < filePathsArray.length; index++) { + var filePath = filePathsArray[index], + filePathQuoted = "\"" + filePath + "\""; + if (filePathToReference[filePath]) { + pbxGroup.children.push(pbxGroupChild(filePathToReference[filePath])); + continue; + } else if (filePathToReference[filePathQuoted]) { + pbxGroup.children.push(pbxGroupChild(filePathToReference[filePathQuoted])); + continue; + } - XMLDocType.prototype.com = function(value) { - return this.comment(value); - }; + var file = new pbxFile(filePath); + file.uuid = this.generateUuid(); + file.fileRef = this.generateUuid(); + this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToPbxBuildFileSection(file); // PBXBuildFile + pbxGroup.children.push(pbxGroupChild(file)); + } - XMLDocType.prototype.ins = function(target, value) { - return this.instruction(target, value); - }; + if (groups) { + groups[pbxGroupUuid] = pbxGroup; + groups[commentKey] = name; + } - XMLDocType.prototype.up = function() { - return this.root(); - }; + return { uuid: pbxGroupUuid, pbxGroup: pbxGroup }; +} - XMLDocType.prototype.doc = function() { - return this.document(); - }; +pbxProject.prototype.removePbxGroup = function (groupName) { + var section = this.hash.project.objects['PBXGroup'], + key, itemKey; - return XMLDocType; + for (key in section) { + // only look for comments + if (!COMMENT_KEY.test(key)) continue; - })(); + if (section[key] == groupName) { + itemKey = key.split(COMMENT_KEY)[0]; + delete section[itemKey]; + } + } +} -}).call(this); +pbxProject.prototype.addToPbxProjectSection = function(target) { + var newTarget = { + value: target.uuid, + comment: pbxNativeTargetComment(target.pbxNativeTarget) + }; -/***/ }, -/* 33 */ -/***/ function(module, exports, __webpack_require__) { + this.pbxProjectSection()[this.getFirstProject()['uuid']]['targets'].push(newTarget); +} -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLAttribute, XMLElement, XMLNode, XMLProcessingInstruction, create, every, isFunction, isObject, - 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; +pbxProject.prototype.addToPbxNativeTargetSection = function(target) { + var commentKey = f("%s_comment", target.uuid); - create = __webpack_require__(1); + this.pbxNativeTargetSection()[target.uuid] = target.pbxNativeTarget; + this.pbxNativeTargetSection()[commentKey] = target.pbxNativeTarget.name; +} - isObject = __webpack_require__(0); +pbxProject.prototype.addToPbxFileReferenceSection = function(file) { + var commentKey = f("%s_comment", file.fileRef); - isFunction = __webpack_require__(11); + this.pbxFileReferenceSection()[file.fileRef] = pbxFileReferenceObj(file); + this.pbxFileReferenceSection()[commentKey] = pbxFileReferenceComment(file); +} - every = __webpack_require__(48); +pbxProject.prototype.removeFromPbxFileReferenceSection = function(file) { - XMLNode = __webpack_require__(8); + var i; + var refObj = pbxFileReferenceObj(file); + for (i in this.pbxFileReferenceSection()) { + if (this.pbxFileReferenceSection()[i].name == refObj.name || + ('"' + this.pbxFileReferenceSection()[i].name + '"') == refObj.name || + this.pbxFileReferenceSection()[i].path == refObj.path || + ('"' + this.pbxFileReferenceSection()[i].path + '"') == refObj.path) { + file.fileRef = file.uuid = i; + delete this.pbxFileReferenceSection()[i]; + break; + } + } + var commentKey = f("%s_comment", file.fileRef); + if (this.pbxFileReferenceSection()[commentKey] != undefined) { + delete this.pbxFileReferenceSection()[commentKey]; + } - XMLAttribute = __webpack_require__(83); + return file; +} - XMLProcessingInstruction = __webpack_require__(34); +pbxProject.prototype.addToXcVersionGroupSection = function(file) { + if (!file.models || !file.currentModel) { + throw new Error("Cannot create a XCVersionGroup section from not a data model document file"); + } - module.exports = XMLElement = (function(superClass) { - extend(XMLElement, superClass); + var commentKey = f("%s_comment", file.fileRef); - function XMLElement(parent, name, attributes) { - XMLElement.__super__.constructor.call(this, parent); - if (name == null) { - throw new Error("Missing element name"); - } - this.name = this.stringify.eleName(name); - this.children = []; - this.instructions = []; - this.attributes = {}; - if (attributes != null) { - this.attribute(attributes); - } + if (!this.xcVersionGroupSection()[file.fileRef]) { + this.xcVersionGroupSection()[file.fileRef] = { + isa: 'XCVersionGroup', + children: file.models.map(function (el) { return el.fileRef; }), + currentVersion: file.currentModel.fileRef, + name: path.basename(file.path), + path: file.path, + sourceTree: '""', + versionGroupType: 'wrapper.xcdatamodel' + }; + this.xcVersionGroupSection()[commentKey] = path.basename(file.path); } +} - XMLElement.prototype.clone = function() { - var att, attName, clonedSelf, i, len, pi, ref, ref1; - clonedSelf = create(XMLElement.prototype, this); - if (clonedSelf.isRoot) { - clonedSelf.documentObject = null; - } - clonedSelf.attributes = {}; - ref = this.attributes; - for (attName in ref) { - if (!hasProp.call(ref, attName)) continue; - att = ref[attName]; - clonedSelf.attributes[attName] = att.clone(); - } - clonedSelf.instructions = []; - ref1 = this.instructions; - for (i = 0, len = ref1.length; i < len; i++) { - pi = ref1[i]; - clonedSelf.instructions.push(pi.clone()); - } - clonedSelf.children = []; - this.children.forEach(function(child) { - var clonedChild; - clonedChild = child.clone(); - clonedChild.parent = clonedSelf; - return clonedSelf.children.push(clonedChild); - }); - return clonedSelf; - }; +pbxProject.prototype.addToPluginsPbxGroup = function(file) { + var pluginsGroup = this.pbxGroupByName('Plugins'); + pluginsGroup.children.push(pbxGroupChild(file)); +} - XMLElement.prototype.attribute = function(name, value) { - var attName, attValue; - if (name != null) { - name = name.valueOf(); - } - if (isObject(name)) { - for (attName in name) { - if (!hasProp.call(name, attName)) continue; - attValue = name[attName]; - this.attribute(attName, attValue); +pbxProject.prototype.removeFromPluginsPbxGroup = function(file) { + var pluginsGroupChildren = this.pbxGroupByName('Plugins').children, i; + for (i in pluginsGroupChildren) { + if (pbxGroupChild(file).value == pluginsGroupChildren[i].value && + pbxGroupChild(file).comment == pluginsGroupChildren[i].comment) { + pluginsGroupChildren.splice(i, 1); + break; } - } else { - if (isFunction(value)) { - value = value.apply(); + } +} + +pbxProject.prototype.addToResourcesPbxGroup = function(file) { + var pluginsGroup = this.pbxGroupByName('Resources'); + pluginsGroup.children.push(pbxGroupChild(file)); +} + +pbxProject.prototype.removeFromResourcesPbxGroup = function(file) { + var pluginsGroupChildren = this.pbxGroupByName('Resources').children, i; + for (i in pluginsGroupChildren) { + if (pbxGroupChild(file).value == pluginsGroupChildren[i].value && + pbxGroupChild(file).comment == pluginsGroupChildren[i].comment) { + pluginsGroupChildren.splice(i, 1); + break; } - if (!this.options.skipNullAttributes || (value != null)) { - this.attributes[name] = new XMLAttribute(this, name, value); + } +} + +pbxProject.prototype.addToFrameworksPbxGroup = function(file) { + var pluginsGroup = this.pbxGroupByName('Frameworks'); + pluginsGroup.children.push(pbxGroupChild(file)); +} + +pbxProject.prototype.removeFromFrameworksPbxGroup = function(file) { + var pluginsGroupChildren = this.pbxGroupByName('Frameworks').children; + + for (i in pluginsGroupChildren) { + if (pbxGroupChild(file).value == pluginsGroupChildren[i].value && + pbxGroupChild(file).comment == pluginsGroupChildren[i].comment) { + pluginsGroupChildren.splice(i, 1); + break; } - } - return this; - }; + } +} - XMLElement.prototype.removeAttribute = function(name) { - var attName, i, len; - if (name == null) { - throw new Error("Missing attribute name"); - } - name = name.valueOf(); - if (Array.isArray(name)) { - for (i = 0, len = name.length; i < len; i++) { - attName = name[i]; - delete this.attributes[attName]; +pbxProject.prototype.addToPbxEmbedFrameworksBuildPhase = function (file) { + var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target); + if (sources) { + sources.files.push(pbxBuildPhaseObj(file)); + } +} + +pbxProject.prototype.removeFromPbxEmbedFrameworksBuildPhase = function (file) { + var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target); + if (sources) { + var files = []; + for (i in sources.files) { + if (sources.files[i].comment != longComment(file)) { + files.push(sources.files[i]); + } } - } else { - delete this.attributes[name]; - } - return this; - }; + sources.files = files; + } +} - XMLElement.prototype.instruction = function(target, value) { - var i, insTarget, insValue, instruction, len; - if (target != null) { - target = target.valueOf(); - } - if (value != null) { - value = value.valueOf(); - } - if (Array.isArray(target)) { - for (i = 0, len = target.length; i < len; i++) { - insTarget = target[i]; - this.instruction(insTarget); - } - } else if (isObject(target)) { - for (insTarget in target) { - if (!hasProp.call(target, insTarget)) continue; - insValue = target[insTarget]; - this.instruction(insTarget, insValue); - } - } else { - if (isFunction(value)) { - value = value.apply(); - } - instruction = new XMLProcessingInstruction(this, target, value); - this.instructions.push(instruction); - } - return this; - }; +pbxProject.prototype.addToProductsPbxGroup = function(file) { + var productsGroup = this.pbxGroupByName('Products'); + productsGroup.children.push(pbxGroupChild(file)); +} - XMLElement.prototype.toString = function(options, level) { - var att, child, i, indent, instruction, j, len, len1, name, newline, offset, pretty, r, ref, ref1, ref2, ref3, ref4, ref5, space; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - level || (level = 0); - space = new Array(level + offset + 1).join(indent); - r = ''; - ref3 = this.instructions; - for (i = 0, len = ref3.length; i < len; i++) { - instruction = ref3[i]; - r += instruction.toString(options, level); - } - if (pretty) { - r += space; - } - r += '<' + this.name; - ref4 = this.attributes; - for (name in ref4) { - if (!hasProp.call(ref4, name)) continue; - att = ref4[name]; - r += att.toString(options); - } - if (this.children.length === 0 || every(this.children, function(e) { - return e.value === ''; - })) { - r += '/>'; - if (pretty) { - r += newline; - } - } else if (pretty && this.children.length === 1 && (this.children[0].value != null)) { - r += '>'; - r += this.children[0].value; - r += ''; - r += newline; - } else { - r += '>'; - if (pretty) { - r += newline; - } - ref5 = this.children; - for (j = 0, len1 = ref5.length; j < len1; j++) { - child = ref5[j]; - r += child.toString(options, level + 1); - } - if (pretty) { - r += space; - } - r += ''; - if (pretty) { - r += newline; +pbxProject.prototype.removeFromProductsPbxGroup = function(file) { + var productsGroupChildren = this.pbxGroupByName('Products').children, i; + for (i in productsGroupChildren) { + if (pbxGroupChild(file).value == productsGroupChildren[i].value && + pbxGroupChild(file).comment == productsGroupChildren[i].comment) { + productsGroupChildren.splice(i, 1); + break; } - } - return r; - }; - - XMLElement.prototype.att = function(name, value) { - return this.attribute(name, value); - }; + } +} - XMLElement.prototype.ins = function(target, value) { - return this.instruction(target, value); - }; +pbxProject.prototype.addToPbxSourcesBuildPhase = function(file) { + var sources = this.pbxSourcesBuildPhaseObj(file.target); + sources.files.push(pbxBuildPhaseObj(file)); +} - XMLElement.prototype.a = function(name, value) { - return this.attribute(name, value); - }; +pbxProject.prototype.removeFromPbxSourcesBuildPhase = function(file) { - XMLElement.prototype.i = function(target, value) { - return this.instruction(target, value); - }; + var sources = this.pbxSourcesBuildPhaseObj(file.target), i; + for (i in sources.files) { + if (sources.files[i].comment == longComment(file)) { + sources.files.splice(i, 1); + break; + } + } +} - return XMLElement; +pbxProject.prototype.addToPbxResourcesBuildPhase = function(file) { + var sources = this.pbxResourcesBuildPhaseObj(file.target); + sources.files.push(pbxBuildPhaseObj(file)); +} - })(XMLNode); +pbxProject.prototype.removeFromPbxResourcesBuildPhase = function(file) { + var sources = this.pbxResourcesBuildPhaseObj(file.target), i; -}).call(this); + for (i in sources.files) { + if (sources.files[i].comment == longComment(file)) { + sources.files.splice(i, 1); + break; + } + } +} +pbxProject.prototype.addToPbxFrameworksBuildPhase = function(file) { + var sources = this.pbxFrameworksBuildPhaseObj(file.target); + sources.files.push(pbxBuildPhaseObj(file)); +} -/***/ }, -/* 34 */ -/***/ function(module, exports, __webpack_require__) { +pbxProject.prototype.removeFromPbxFrameworksBuildPhase = function(file) { + var sources = this.pbxFrameworksBuildPhaseObj(file.target); + for (i in sources.files) { + if (sources.files[i].comment == longComment(file)) { + sources.files.splice(i, 1); + break; + } + } +} -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLProcessingInstruction, create; +pbxProject.prototype.addXCConfigurationList = function(configurationObjectsArray, defaultConfigurationName, comment) { + var pbxBuildConfigurationSection = this.pbxXCBuildConfigurationSection(), + pbxXCConfigurationListSection = this.pbxXCConfigurationList(), + xcConfigurationListUuid = this.generateUuid(), + commentKey = f("%s_comment", xcConfigurationListUuid), + xcConfigurationList = { + isa: 'XCConfigurationList', + buildConfigurations: [], + defaultConfigurationIsVisible: 0, + defaultConfigurationName: defaultConfigurationName + }; - create = __webpack_require__(1); + for (var index = 0; index < configurationObjectsArray.length; index++) { + var configuration = configurationObjectsArray[index], + configurationUuid = this.generateUuid(), + configurationCommentKey = f("%s_comment", configurationUuid); - module.exports = XMLProcessingInstruction = (function() { - function XMLProcessingInstruction(parent, target, value) { - this.stringify = parent.stringify; - if (target == null) { - throw new Error("Missing instruction target"); - } - this.target = this.stringify.insTarget(target); - if (value) { - this.value = this.stringify.insValue(value); - } + pbxBuildConfigurationSection[configurationUuid] = configuration; + pbxBuildConfigurationSection[configurationCommentKey] = configuration.name; + xcConfigurationList.buildConfigurations.push({ value: configurationUuid, comment: configuration.name }); } - XMLProcessingInstruction.prototype.clone = function() { - return create(XMLProcessingInstruction.prototype, this); - }; - - XMLProcessingInstruction.prototype.toString = function(options, level) { - var indent, newline, offset, pretty, r, ref, ref1, ref2, space; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - level || (level = 0); - space = new Array(level + offset + 1).join(indent); - r = ''; - if (pretty) { - r += space; - } - r += ''; - if (pretty) { - r += newline; - } - return r; - }; + if (pbxXCConfigurationListSection) { + pbxXCConfigurationListSection[xcConfigurationListUuid] = xcConfigurationList; + pbxXCConfigurationListSection[commentKey] = comment; + } - return XMLProcessingInstruction; + return { uuid: xcConfigurationListUuid, xcConfigurationList: xcConfigurationList }; +} - })(); +pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) { + if (!target) + return undefined; -}).call(this); + var nativeTargets = this.pbxNativeTargetSection(); + if (typeof nativeTargets[target] == "undefined") + throw new Error("Invalid target: " + target); -/***/ }, -/* 35 */ -/***/ function(module, exports, __webpack_require__) { + for (var index = 0; index < dependencyTargets.length; index++) { + var dependencyTarget = dependencyTargets[index]; + if (typeof nativeTargets[dependencyTarget] == "undefined") + throw new Error("Invalid target: " + dependencyTarget); + } + var pbxTargetDependency = 'PBXTargetDependency', + pbxContainerItemProxy = 'PBXContainerItemProxy', + pbxTargetDependencySection = this.hash.project.objects[pbxTargetDependency], + pbxContainerItemProxySection = this.hash.project.objects[pbxContainerItemProxy]; -/** - * For Node.js, simply re-export the core `util.deprecate` function. - */ + for (var index = 0; index < dependencyTargets.length; index++) { + var dependencyTargetUuid = dependencyTargets[index], + dependencyTargetCommentKey = f("%s_comment", dependencyTargetUuid), + targetDependencyUuid = this.generateUuid(), + targetDependencyCommentKey = f("%s_comment", targetDependencyUuid), + itemProxyUuid = this.generateUuid(), + itemProxyCommentKey = f("%s_comment", itemProxyUuid), + itemProxy = { + isa: pbxContainerItemProxy, + containerPortal: this.hash.project['rootObject'], + containerPortal_comment: this.hash.project['rootObject_comment'], + proxyType: 1, + remoteGlobalIDString: dependencyTargetUuid, + remoteInfo: nativeTargets[dependencyTargetUuid].name + }, + targetDependency = { + isa: pbxTargetDependency, + target: dependencyTargetUuid, + target_comment: nativeTargets[dependencyTargetCommentKey], + targetProxy: itemProxyUuid, + targetProxy_comment: pbxContainerItemProxy + }; -module.exports = __webpack_require__(5).deprecate; - - -/***/ }, -/* 36 */ -/***/ function(module, exports, __webpack_require__) { + if (pbxContainerItemProxySection && pbxTargetDependencySection) { + pbxContainerItemProxySection[itemProxyUuid] = itemProxy; + pbxContainerItemProxySection[itemProxyCommentKey] = pbxContainerItemProxy; + pbxTargetDependencySection[targetDependencyUuid] = targetDependency; + pbxTargetDependencySection[targetDependencyCommentKey] = pbxTargetDependency; + nativeTargets[target].dependencies.push({ value: targetDependencyUuid, comment: pbxTargetDependency }) + } + } -/* WEBPACK VAR INJECTION */(function(__dirname) {var util = __webpack_require__(5), - f = util.format, - EventEmitter = __webpack_require__(38).EventEmitter, - path = __webpack_require__(12), - uuid = __webpack_require__(100), - fork = __webpack_require__(103).fork, - pbxWriter = __webpack_require__(99), - pbxFile = __webpack_require__(98), - fs = __webpack_require__(9), - parser = __webpack_require__(97), - plist = __webpack_require__(93), - COMMENT_KEY = /_comment$/ + return { uuid: target, target: nativeTargets[target] }; +} -function pbxProject(filename) { - if (!(this instanceof pbxProject)) - return new pbxProject(filename); +pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, comment, target, optionsOrFolderType, subfolderPath) { + var buildPhaseSection, + fileReferenceSection = this.pbxFileReferenceSection(), + buildFileSection = this.pbxBuildFileSection(), + buildPhaseUuid = this.generateUuid(), + buildPhaseTargetUuid = target || this.getFirstTarget().uuid, + commentKey = f("%s_comment", buildPhaseUuid), + buildPhase = { + isa: buildPhaseType, + buildActionMask: 2147483647, + files: [], + runOnlyForDeploymentPostprocessing: 0 + }, + filePathToBuildFile = {}; - this.filepath = path.resolve(filename) -} + if (buildPhaseType === 'PBXCopyFilesBuildPhase') { + buildPhase = pbxCopyFilesBuildPhaseObj(buildPhase, optionsOrFolderType, subfolderPath, comment); + } else if (buildPhaseType === 'PBXShellScriptBuildPhase') { + buildPhase = pbxShellScriptBuildPhaseObj(buildPhase, optionsOrFolderType, comment) + } -util.inherits(pbxProject, EventEmitter) + if (!this.hash.project.objects[buildPhaseType]) { + this.hash.project.objects[buildPhaseType] = new Object(); + } -pbxProject.prototype.parse = function(cb) { - var worker = fork(__dirname + '/parseJob.js', [this.filepath]) + if (!this.hash.project.objects[buildPhaseType][buildPhaseUuid]) { + this.hash.project.objects[buildPhaseType][buildPhaseUuid] = buildPhase; + this.hash.project.objects[buildPhaseType][commentKey] = comment; + } - worker.on('message', function(msg) { - if (msg.name == 'SyntaxError' || msg.code) { - this.emit('error', msg); - } else { - this.hash = msg; - this.emit('end', null, msg) - } - }.bind(this)); + if (this.hash.project.objects['PBXNativeTarget'][buildPhaseTargetUuid]['buildPhases']) { + this.hash.project.objects['PBXNativeTarget'][buildPhaseTargetUuid]['buildPhases'].push({ + value: buildPhaseUuid, + comment: comment + }) - if (cb) { - this.on('error', cb); - this.on('end', cb); } - return this; -} -pbxProject.prototype.parseSync = function() { - var file_contents = fs.readFileSync(this.filepath, 'utf-8'); + for (var key in buildFileSection) { + // only look for comments + if (!COMMENT_KEY.test(key)) continue; - this.hash = parser.parse(file_contents); - return this; -} + var buildFileKey = key.split(COMMENT_KEY)[0], + buildFile = buildFileSection[buildFileKey]; + fileReference = fileReferenceSection[buildFile.fileRef]; -pbxProject.prototype.writeSync = function() { - this.writer = new pbxWriter(this.hash); - return this.writer.writeSync(); -} + if (!fileReference) continue; -pbxProject.prototype.allUuids = function() { - var sections = this.hash.project.objects, - uuids = [], - section; + var pbxFileObj = new pbxFile(fileReference.path); - for (key in sections) { - section = sections[key] - uuids = uuids.concat(Object.keys(section)) + filePathToBuildFile[fileReference.path] = { uuid: buildFileKey, basename: pbxFileObj.basename, group: pbxFileObj.group }; } - uuids = uuids.filter(function(str) { - return !COMMENT_KEY.test(str) && str.length == 24; - }); - - return uuids; -} + for (var index = 0; index < filePathsArray.length; index++) { + var filePath = filePathsArray[index], + filePathQuoted = "\"" + filePath + "\"", + file = new pbxFile(filePath); -pbxProject.prototype.generateUuid = function() { - var id = uuid.v4() - .replace(/-/g, '') - .substr(0, 24) - .toUpperCase() + if (filePathToBuildFile[filePath]) { + buildPhase.files.push(pbxBuildPhaseObj(filePathToBuildFile[filePath])); + continue; + } else if (filePathToBuildFile[filePathQuoted]) { + buildPhase.files.push(pbxBuildPhaseObj(filePathToBuildFile[filePathQuoted])); + continue; + } - if (this.allUuids().indexOf(id) >= 0) { - return this.generateUuid(); - } else { - return id; + file.uuid = this.generateUuid(); + file.fileRef = this.generateUuid(); + this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToPbxBuildFileSection(file); // PBXBuildFile + buildPhase.files.push(pbxBuildPhaseObj(file)); } -} -pbxProject.prototype.addPluginFile = function(path, opt) { - var file = new pbxFile(path, opt); + if (buildPhaseSection) { + buildPhaseSection[buildPhaseUuid] = buildPhase; + buildPhaseSection[commentKey] = comment; + } - file.plugin = true; // durr - correctForPluginsPath(file, this); + return { uuid: buildPhaseUuid, buildPhase: buildPhase }; +} - // null is better for early errors - if (this.hasFile(file.path)) return null; +// helper access functions +pbxProject.prototype.pbxProjectSection = function() { + return this.hash.project.objects['PBXProject']; +} +pbxProject.prototype.pbxBuildFileSection = function() { + return this.hash.project.objects['PBXBuildFile']; +} - file.fileRef = this.generateUuid(); +pbxProject.prototype.pbxXCBuildConfigurationSection = function() { + return this.hash.project.objects['XCBuildConfiguration']; +} - this.addToPbxFileReferenceSection(file); // PBXFileReference - this.addToPluginsPbxGroup(file); // PBXGroup +pbxProject.prototype.pbxFileReferenceSection = function() { + return this.hash.project.objects['PBXFileReference']; +} - return file; +pbxProject.prototype.pbxNativeTargetSection = function() { + return this.hash.project.objects['PBXNativeTarget']; } -pbxProject.prototype.removePluginFile = function(path, opt) { - var file = new pbxFile(path, opt); - correctForPluginsPath(file, this); +pbxProject.prototype.xcVersionGroupSection = function () { + if (typeof this.hash.project.objects['XCVersionGroup'] !== 'object') { + this.hash.project.objects['XCVersionGroup'] = {}; + } - this.removeFromPbxFileReferenceSection(file); // PBXFileReference - this.removeFromPluginsPbxGroup(file); // PBXGroup + return this.hash.project.objects['XCVersionGroup']; +} - return file; +pbxProject.prototype.pbxXCConfigurationList = function() { + return this.hash.project.objects['XCConfigurationList']; } -pbxProject.prototype.addProductFile = function(targetPath, opt) { - var file = new pbxFile(targetPath, opt); +pbxProject.prototype.pbxGroupByName = function(name) { + var groups = this.hash.project.objects['PBXGroup'], + key, groupKey; - file.includeInIndex = 0; - file.fileRef = this.generateUuid(); - file.target = opt ? opt.target : undefined; - file.group = opt ? opt.group : undefined; - file.uuid = this.generateUuid(); - file.path = file.basename; + for (key in groups) { + // only look for comments + if (!COMMENT_KEY.test(key)) continue; - this.addToPbxFileReferenceSection(file); - this.addToProductsPbxGroup(file); // PBXGroup + if (groups[key] == name) { + groupKey = key.split(COMMENT_KEY)[0]; + return groups[groupKey]; + } + } - return file; + return null; } -pbxProject.prototype.removeProductFile = function(path, opt) { - var file = new pbxFile(path, opt); +pbxProject.prototype.pbxTargetByName = function(name) { + return this.pbxItemByComment(name, 'PBXNativeTarget'); +} - this.removeFromProductsPbxGroup(file); // PBXGroup +pbxProject.prototype.findTargetKey = function(name) { + var targets = this.hash.project.objects['PBXNativeTarget']; - return file; -} + for (var key in targets) { + // only look for comments + if (COMMENT_KEY.test(key)) continue; -/** - * - * @param path {String} - * @param opt {Object} see pbxFile for avail options - * @param group {String} group key - * @returns {Object} file; see pbxFile - */ -pbxProject.prototype.addSourceFile = function (path, opt, group) { - var file; - if (group) { - file = this.addFile(path, group, opt); - } - else { - file = this.addPluginFile(path, opt); + var target = targets[key]; + if (target.name === name) { + return key; + } } - if (!file) return false; + return null; +} - file.target = opt ? opt.target : undefined; - file.uuid = this.generateUuid(); +pbxProject.prototype.pbxItemByComment = function(name, pbxSectionName) { + var section = this.hash.project.objects[pbxSectionName], + key, itemKey; - this.addToPbxBuildFileSection(file); // PBXBuildFile - this.addToPbxSourcesBuildPhase(file); // PBXSourcesBuildPhase + for (key in section) { + // only look for comments + if (!COMMENT_KEY.test(key)) continue; - return file; + if (section[key] == name) { + itemKey = key.split(COMMENT_KEY)[0]; + return section[itemKey]; + } + } + + return null; } -/** - * - * @param path {String} - * @param opt {Object} see pbxFile for avail options - * @param group {String} group key - * @returns {Object} file; see pbxFile - */ -pbxProject.prototype.removeSourceFile = function (path, opt, group) { - var file; - if (group) { - file = this.removeFile(path, group, opt); - } - else { - file = this.removePluginFile(path, opt); - } - file.target = opt ? opt.target : undefined; - this.removeFromPbxBuildFileSection(file); // PBXBuildFile - this.removeFromPbxSourcesBuildPhase(file); // PBXSourcesBuildPhase - - return file; +pbxProject.prototype.pbxSourcesBuildPhaseObj = function(target) { + return this.buildPhaseObject('PBXSourcesBuildPhase', 'Sources', target); } -/** - * - * @param path {String} - * @param opt {Object} see pbxFile for avail options - * @param group {String} group key - * @returns {Object} file; see pbxFile - */ -pbxProject.prototype.addHeaderFile = function (path, opt, group) { - if (group) { - return this.addFile(path, group, opt); - } - else { - return this.addPluginFile(path, opt); - } +pbxProject.prototype.pbxResourcesBuildPhaseObj = function(target) { + return this.buildPhaseObject('PBXResourcesBuildPhase', 'Resources', target); } -/** - * - * @param path {String} - * @param opt {Object} see pbxFile for avail options - * @param group {String} group key - * @returns {Object} file; see pbxFile - */ -pbxProject.prototype.removeHeaderFile = function (path, opt, group) { - if (group) { - return this.removeFile(path, group, opt); - } - else { - return this.removePluginFile(path, opt); - } +pbxProject.prototype.pbxFrameworksBuildPhaseObj = function(target) { + return this.buildPhaseObject('PBXFrameworksBuildPhase', 'Frameworks', target); } -/** - * - * @param path {String} - * @param opt {Object} see pbxFile for avail options - * @param group {String} group key - * @returns {Object} file; see pbxFile - */ -pbxProject.prototype.addResourceFile = function(path, opt, group) { - opt = opt || {}; +pbxProject.prototype.pbxEmbedFrameworksBuildPhaseObj = function (target) { + return this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed Frameworks', target); +}; - var file; +// Find Build Phase from group/target +pbxProject.prototype.buildPhase = function(group, target) { - if (opt.plugin) { - file = this.addPluginFile(path, opt); - if (!file) return false; - } else { - file = new pbxFile(path, opt); - if (this.hasFile(file.path)) return false; - } + if (!target) + return undefined; - file.uuid = this.generateUuid(); - file.target = opt ? opt.target : undefined; + var nativeTargets = this.pbxNativeTargetSection(); + if (typeof nativeTargets[target] == "undefined") + throw new Error("Invalid target: " + target); - if (!opt.plugin) { - correctForResourcesPath(file, this); - file.fileRef = this.generateUuid(); + var nativeTarget = nativeTargets[target]; + var buildPhases = nativeTarget.buildPhases; + for(var i in buildPhases) + { + var buildPhase = buildPhases[i]; + if (buildPhase.comment==group) + return buildPhase.value + "_comment"; + } } - if (!opt.variantGroup) { - this.addToPbxBuildFileSection(file); // PBXBuildFile - this.addToPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase - } +pbxProject.prototype.buildPhaseObject = function(name, group, target) { + var section = this.hash.project.objects[name], + obj, sectionKey, key; + var buildPhase = this.buildPhase(group, target); - if (!opt.plugin) { - this.addToPbxFileReferenceSection(file); // PBXFileReference - if (group) { - if (this.getPBXGroupByKey(group)) { - this.addToPbxGroup(file, group); //Group other than Resources (i.e. 'splash') - } - else if (this.getPBXVariantGroupByKey(group)) { - this.addToPbxVariantGroup(file, group); // PBXVariantGroup - } - } - else { - this.addToResourcesPbxGroup(file); // PBXGroup + for (key in section) { + + // only look for comments + if (!COMMENT_KEY.test(key)) continue; + + // select the proper buildPhase + if (buildPhase && buildPhase!=key) + continue; + if (section[key] == group) { + sectionKey = key.split(COMMENT_KEY)[0]; + return section[sectionKey]; } + } + return null; +} + +pbxProject.prototype.addBuildProperty = function(prop, value, build_name) { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + key, configuration; + for (key in configurations){ + configuration = configurations[key]; + if (!build_name || configuration.name === build_name){ + configuration.buildSettings[prop] = value; + } } +} - return file; +pbxProject.prototype.removeBuildProperty = function(prop, build_name) { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + key, configuration; + + for (key in configurations){ + configuration = configurations[key]; + if (configuration.buildSettings[prop] && + !build_name || configuration.name === build_name){ + delete configuration.buildSettings[prop]; + } + } } /** * - * @param path {String} - * @param opt {Object} see pbxFile for avail options - * @param group {String} group key - * @returns {Object} file; see pbxFile + * @param prop {String} + * @param value {String|Array|Object|Number|Boolean} + * @param build {String} Release or Debug */ -pbxProject.prototype.removeResourceFile = function(path, opt, group) { - var file = new pbxFile(path, opt); - file.target = opt ? opt.target : undefined; - - correctForResourcesPath(file, this); - - this.removeFromPbxBuildFileSection(file); // PBXBuildFile - this.removeFromPbxFileReferenceSection(file); // PBXFileReference - if (group) { - if (this.getPBXGroupByKey(group)) { - this.removeFromPbxGroup(file, group); //Group other than Resources (i.e. 'splash') - } - else if (this.getPBXVariantGroupByKey(group)) { - this.removeFromPbxVariantGroup(file, group); // PBXVariantGroup +pbxProject.prototype.updateBuildProperty = function(prop, value, build) { + var configs = this.pbxXCBuildConfigurationSection(); + for (var configName in configs) { + if (!COMMENT_KEY.test(configName)) { + var config = configs[configName]; + if ( (build && config.name === build) || (!build) ) { + config.buildSettings[prop] = value; + } } } - else { - this.removeFromResourcesPbxGroup(file); // PBXGroup - } - this.removeFromPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase - - return file; } -pbxProject.prototype.addFramework = function(fpath, opt) { - var customFramework = opt && opt.customFramework == true; - var link = !opt || (opt.link == undefined || opt.link); //defaults to true if not specified - var embed = opt && opt.embed; //defaults to false if not specified - - if (opt) { - delete opt.embed; - } +pbxProject.prototype.updateProductName = function(name) { + this.updateBuildProperty('PRODUCT_NAME', '"' + name + '"'); +} - var file = new pbxFile(fpath, opt); +pbxProject.prototype.removeFromFrameworkSearchPaths = function(file) { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + INHERITED = '"$(inherited)"', + SEARCH_PATHS = 'FRAMEWORK_SEARCH_PATHS', + config, buildSettings, searchPaths; + var new_path = searchPathForFile(file, this); - file.uuid = this.generateUuid(); - file.fileRef = this.generateUuid(); - file.target = opt ? opt.target : undefined; + for (config in configurations) { + buildSettings = configurations[config].buildSettings; - if (this.hasFile(file.path)) return false; + if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) + continue; - this.addToPbxBuildFileSection(file); // PBXBuildFile - this.addToPbxFileReferenceSection(file); // PBXFileReference - this.addToFrameworksPbxGroup(file); // PBXGroup + searchPaths = buildSettings[SEARCH_PATHS]; - if (link) { - this.addToPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase + if (searchPaths) { + var matches = searchPaths.filter(function(p) { + return p.indexOf(new_path) > -1; + }); + matches.forEach(function(m) { + var idx = searchPaths.indexOf(m); + searchPaths.splice(idx, 1); + }); + } } +} - if (customFramework) { - this.addToFrameworkSearchPaths(file); - - if (embed) { - opt.embed = embed; - var embeddedFile = new pbxFile(fpath, opt); - - embeddedFile.uuid = this.generateUuid(); - embeddedFile.fileRef = file.fileRef; +pbxProject.prototype.addToFrameworkSearchPaths = function(file) { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + INHERITED = '"$(inherited)"', + config, buildSettings, searchPaths; - //keeping a separate PBXBuildFile entry for Embed Frameworks - this.addToPbxBuildFileSection(embeddedFile); // PBXBuildFile + for (config in configurations) { + buildSettings = configurations[config].buildSettings; - this.addToPbxEmbedFrameworksBuildPhase(embeddedFile); // PBXCopyFilesBuildPhase + if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) + continue; - return embeddedFile; + if (!buildSettings['FRAMEWORK_SEARCH_PATHS'] + || buildSettings['FRAMEWORK_SEARCH_PATHS'] === INHERITED) { + buildSettings['FRAMEWORK_SEARCH_PATHS'] = [INHERITED]; } - } - return file; + buildSettings['FRAMEWORK_SEARCH_PATHS'].push(searchPathForFile(file, this)); + } } -pbxProject.prototype.removeFramework = function(fpath, opt) { - var embed = opt && opt.embed; +pbxProject.prototype.removeFromLibrarySearchPaths = function(file) { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + INHERITED = '"$(inherited)"', + SEARCH_PATHS = 'LIBRARY_SEARCH_PATHS', + config, buildSettings, searchPaths; + var new_path = searchPathForFile(file, this); - if (opt) { - delete opt.embed; - } - - var file = new pbxFile(fpath, opt); - file.target = opt ? opt.target : undefined; + for (config in configurations) { + buildSettings = configurations[config].buildSettings; - this.removeFromPbxBuildFileSection(file); // PBXBuildFile - this.removeFromPbxFileReferenceSection(file); // PBXFileReference - this.removeFromFrameworksPbxGroup(file); // PBXGroup - this.removeFromPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase + if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) + continue; - if (opt && opt.customFramework) { - this.removeFromFrameworkSearchPaths(file); - } + searchPaths = buildSettings[SEARCH_PATHS]; - opt = opt || {}; - opt.embed = true; - var embeddedFile = new pbxFile(fpath, opt); + if (searchPaths) { + var matches = searchPaths.filter(function(p) { + return p.indexOf(new_path) > -1; + }); + matches.forEach(function(m) { + var idx = searchPaths.indexOf(m); + searchPaths.splice(idx, 1); + }); + } - embeddedFile.fileRef = file.fileRef; + } +} - this.removeFromPbxBuildFileSection(embeddedFile); // PBXBuildFile - this.removeFromPbxEmbedFrameworksBuildPhase(embeddedFile); // PBXCopyFilesBuildPhase +pbxProject.prototype.addToLibrarySearchPaths = function(file) { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + INHERITED = '"$(inherited)"', + config, buildSettings, searchPaths; - return file; -} + for (config in configurations) { + buildSettings = configurations[config].buildSettings; + if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) + continue; -pbxProject.prototype.addCopyfile = function(fpath, opt) { - var file = new pbxFile(fpath, opt); + if (!buildSettings['LIBRARY_SEARCH_PATHS'] + || buildSettings['LIBRARY_SEARCH_PATHS'] === INHERITED) { + buildSettings['LIBRARY_SEARCH_PATHS'] = [INHERITED]; + } - // catch duplicates - if (this.hasFile(file.path)) { - file = this.hasFile(file.path); + if (typeof file === 'string') { + buildSettings['LIBRARY_SEARCH_PATHS'].push(file); + } else { + buildSettings['LIBRARY_SEARCH_PATHS'].push(searchPathForFile(file, this)); + } } +} - file.fileRef = file.uuid = this.generateUuid(); - file.target = opt ? opt.target : undefined; +pbxProject.prototype.removeFromHeaderSearchPaths = function(file) { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + INHERITED = '"$(inherited)"', + SEARCH_PATHS = 'HEADER_SEARCH_PATHS', + config, buildSettings, searchPaths; + var new_path = searchPathForFile(file, this); - this.addToPbxBuildFileSection(file); // PBXBuildFile - this.addToPbxFileReferenceSection(file); // PBXFileReference - this.addToPbxCopyfilesBuildPhase(file); // PBXCopyFilesBuildPhase + for (config in configurations) { + buildSettings = configurations[config].buildSettings; - return file; -} + if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) + continue; -pbxProject.prototype.pbxCopyfilesBuildPhaseObj = function(target) { - return this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Copy Files', target); -} + if (buildSettings[SEARCH_PATHS]) { + var matches = buildSettings[SEARCH_PATHS].filter(function(p) { + return p.indexOf(new_path) > -1; + }); + matches.forEach(function(m) { + var idx = buildSettings[SEARCH_PATHS].indexOf(m); + buildSettings[SEARCH_PATHS].splice(idx, 1); + }); + } -pbxProject.prototype.addToPbxCopyfilesBuildPhase = function(file) { - var sources = this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Copy Files', file.target); - sources.files.push(pbxBuildPhaseObj(file)); + } } +pbxProject.prototype.addToHeaderSearchPaths = function(file) { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + INHERITED = '"$(inherited)"', + config, buildSettings, searchPaths; -pbxProject.prototype.removeCopyfile = function(fpath, opt) { - var file = new pbxFile(fpath, opt); - file.target = opt ? opt.target : undefined; + for (config in configurations) { + buildSettings = configurations[config].buildSettings; - this.removeFromPbxBuildFileSection(file); // PBXBuildFile - this.removeFromPbxFileReferenceSection(file); // PBXFileReference - this.removeFromPbxCopyfilesBuildPhase(file); // PBXFrameworksBuildPhase + if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) + continue; - return file; -} + if (!buildSettings['HEADER_SEARCH_PATHS']) { + buildSettings['HEADER_SEARCH_PATHS'] = [INHERITED]; + } -pbxProject.prototype.removeFromPbxCopyfilesBuildPhase = function(file) { - var sources = this.pbxCopyfilesBuildPhaseObj(file.target); - for (i in sources.files) { - if (sources.files[i].comment == longComment(file)) { - sources.files.splice(i, 1); - break; + if (typeof file === 'string') { + buildSettings['HEADER_SEARCH_PATHS'].push(file); + } else { + buildSettings['HEADER_SEARCH_PATHS'].push(searchPathForFile(file, this)); } } } -pbxProject.prototype.addStaticLibrary = function(path, opt) { - opt = opt || {}; +pbxProject.prototype.addToOtherLinkerFlags = function (flag) { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + INHERITED = '"$(inherited)"', + OTHER_LDFLAGS = 'OTHER_LDFLAGS', + config, buildSettings; - var file; + for (config in configurations) { + buildSettings = configurations[config].buildSettings; - if (opt.plugin) { - file = this.addPluginFile(path, opt); - if (!file) return false; - } else { - file = new pbxFile(path, opt); - if (this.hasFile(file.path)) return false; - } + if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) + continue; - file.uuid = this.generateUuid(); - file.target = opt ? opt.target : undefined; + if (!buildSettings[OTHER_LDFLAGS] + || buildSettings[OTHER_LDFLAGS] === INHERITED) { + buildSettings[OTHER_LDFLAGS] = [INHERITED]; + } - if (!opt.plugin) { - file.fileRef = this.generateUuid(); - this.addToPbxFileReferenceSection(file); // PBXFileReference + buildSettings[OTHER_LDFLAGS].push(flag); } - - this.addToPbxBuildFileSection(file); // PBXBuildFile - this.addToPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase - this.addToLibrarySearchPaths(file); // make sure it gets built! - - return file; } -// helper addition functions -pbxProject.prototype.addToPbxBuildFileSection = function(file) { - var commentKey = f("%s_comment", file.uuid); +pbxProject.prototype.removeFromOtherLinkerFlags = function (flag) { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + OTHER_LDFLAGS = 'OTHER_LDFLAGS', + config, buildSettings; - this.pbxBuildFileSection()[file.uuid] = pbxBuildFileObj(file); - this.pbxBuildFileSection()[commentKey] = pbxBuildFileComment(file); -} + for (config in configurations) { + buildSettings = configurations[config].buildSettings; -pbxProject.prototype.removeFromPbxBuildFileSection = function(file) { - var uuid; + if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) { + continue; + } - for (uuid in this.pbxBuildFileSection()) { - if (this.pbxBuildFileSection()[uuid].fileRef_comment == file.basename) { - file.uuid = uuid; - delete this.pbxBuildFileSection()[uuid]; + if (buildSettings[OTHER_LDFLAGS]) { + var matches = buildSettings[OTHER_LDFLAGS].filter(function (p) { + return p.indexOf(flag) > -1; + }); + matches.forEach(function (m) { + var idx = buildSettings[OTHER_LDFLAGS].indexOf(m); + buildSettings[OTHER_LDFLAGS].splice(idx, 1); + }); } } - var commentKey = f("%s_comment", file.uuid); - delete this.pbxBuildFileSection()[commentKey]; } -pbxProject.prototype.addPbxGroup = function(filePathsArray, name, path, sourceTree) { - var groups = this.hash.project.objects['PBXGroup'], - pbxGroupUuid = this.generateUuid(), - commentKey = f("%s_comment", pbxGroupUuid), - pbxGroup = { - isa: 'PBXGroup', - children: [], - name: name, - path: path, - sourceTree: sourceTree ? sourceTree : '""' - }, - fileReferenceSection = this.pbxFileReferenceSection(), - filePathToReference = {}; - - for (var key in fileReferenceSection) { - // only look for comments - if (!COMMENT_KEY.test(key)) continue; - - var fileReferenceKey = key.split(COMMENT_KEY)[0], - fileReference = fileReferenceSection[fileReferenceKey]; - - filePathToReference[fileReference.path] = { fileRef: fileReferenceKey, basename: fileReferenceSection[key] }; - } - - for (var index = 0; index < filePathsArray.length; index++) { - var filePath = filePathsArray[index], - filePathQuoted = "\"" + filePath + "\""; - if (filePathToReference[filePath]) { - pbxGroup.children.push(pbxGroupChild(filePathToReference[filePath])); - continue; - } else if (filePathToReference[filePathQuoted]) { - pbxGroup.children.push(pbxGroupChild(filePathToReference[filePathQuoted])); - continue; - } +pbxProject.prototype.addToBuildSettings = function (buildSetting, value) { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + config, buildSettings; - var file = new pbxFile(filePath); - file.uuid = this.generateUuid(); - file.fileRef = this.generateUuid(); - this.addToPbxFileReferenceSection(file); // PBXFileReference - this.addToPbxBuildFileSection(file); // PBXBuildFile - pbxGroup.children.push(pbxGroupChild(file)); - } + for (config in configurations) { + buildSettings = configurations[config].buildSettings; - if (groups) { - groups[pbxGroupUuid] = pbxGroup; - groups[commentKey] = name; + buildSettings[buildSetting] = value; } - - return { uuid: pbxGroupUuid, pbxGroup: pbxGroup }; } -pbxProject.prototype.removePbxGroup = function (groupName) { - var section = this.hash.project.objects['PBXGroup'], - key, itemKey; +pbxProject.prototype.removeFromBuildSettings = function (buildSetting) { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + config, buildSettings; - for (key in section) { - // only look for comments - if (!COMMENT_KEY.test(key)) continue; + for (config in configurations) { + buildSettings = configurations[config].buildSettings; - if (section[key] == groupName) { - itemKey = key.split(COMMENT_KEY)[0]; - delete section[itemKey]; + if (buildSettings[buildSetting]) { + delete buildSettings[buildSetting]; } } } -pbxProject.prototype.addToPbxProjectSection = function(target) { +// a JS getter. hmmm +pbxProject.prototype.__defineGetter__("productName", function() { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + config, productName; - var newTarget = { - value: target.uuid, - comment: pbxNativeTargetComment(target.pbxNativeTarget) - }; + for (config in configurations) { + productName = configurations[config].buildSettings['PRODUCT_NAME']; - this.pbxProjectSection()[this.getFirstProject()['uuid']]['targets'].push(newTarget); -} + if (productName) { + return unquote(productName); + } + } +}); -pbxProject.prototype.addToPbxNativeTargetSection = function(target) { - var commentKey = f("%s_comment", target.uuid); +// check if file is present +pbxProject.prototype.hasFile = function(filePath) { + var files = nonComments(this.pbxFileReferenceSection()), + file, id; + for (id in files) { + file = files[id]; + if (file.path == filePath || file.path == ('"' + filePath + '"')) { + return file; + } + } - this.pbxNativeTargetSection()[target.uuid] = target.pbxNativeTarget; - this.pbxNativeTargetSection()[commentKey] = target.pbxNativeTarget.name; + return false; } -pbxProject.prototype.addToPbxFileReferenceSection = function(file) { - var commentKey = f("%s_comment", file.fileRef); +pbxProject.prototype.addTarget = function(name, type, subfolder) { - this.pbxFileReferenceSection()[file.fileRef] = pbxFileReferenceObj(file); - this.pbxFileReferenceSection()[commentKey] = pbxFileReferenceComment(file); -} + // Setup uuid and name of new target + var targetUuid = this.generateUuid(), + targetType = type, + targetSubfolder = subfolder || name, + targetName = name.trim(); -pbxProject.prototype.removeFromPbxFileReferenceSection = function(file) { + // Check type against list of allowed target types + if (!targetName) { + throw new Error("Target name missing."); + } - var i; - var refObj = pbxFileReferenceObj(file); - for (i in this.pbxFileReferenceSection()) { - if (this.pbxFileReferenceSection()[i].name == refObj.name || - ('"' + this.pbxFileReferenceSection()[i].name + '"') == refObj.name || - this.pbxFileReferenceSection()[i].path == refObj.path || - ('"' + this.pbxFileReferenceSection()[i].path + '"') == refObj.path) { - file.fileRef = file.uuid = i; - delete this.pbxFileReferenceSection()[i]; - break; - } + // Check type against list of allowed target types + if (!targetType) { + throw new Error("Target type missing."); } - var commentKey = f("%s_comment", file.fileRef); - if (this.pbxFileReferenceSection()[commentKey] != undefined) { - delete this.pbxFileReferenceSection()[commentKey]; + + // Check type against list of allowed target types + if (!producttypeForTargettype(targetType)) { + throw new Error("Target type invalid: " + targetType); } - return file; -} + // Build Configuration: Create + var buildConfigurationsList = [ + { + name: 'Debug', + isa: 'XCBuildConfiguration', + buildSettings: { + GCC_PREPROCESSOR_DEFINITIONS: ['"DEBUG=1"', '"$(inherited)"'], + INFOPLIST_FILE: '"' + path.join(targetSubfolder, targetSubfolder + '-Info.plist' + '"'), + LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"', + PRODUCT_NAME: '"' + targetName + '"', + SKIP_INSTALL: 'YES' + } + }, + { + name: 'Release', + isa: 'XCBuildConfiguration', + buildSettings: { + INFOPLIST_FILE: '"' + path.join(targetSubfolder, targetSubfolder + '-Info.plist' + '"'), + LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"', + PRODUCT_NAME: '"' + targetName + '"', + SKIP_INSTALL: 'YES' + } + } + ]; -pbxProject.prototype.addToXcVersionGroupSection = function(file) { - if (!file.models || !file.currentModel) { - throw new Error("Cannot create a XCVersionGroup section from not a data model document file"); - } + // Build Configuration: Add + var buildConfigurations = this.addXCConfigurationList(buildConfigurationsList, 'Release', 'Build configuration list for PBXNativeTarget "' + targetName +'"'); - var commentKey = f("%s_comment", file.fileRef); + // Product: Create + var productName = targetName, + productType = producttypeForTargettype(targetType), + productFileType = filetypeForProducttype(productType), + productFile = this.addProductFile(productName, { group: 'Copy Files', 'target': targetUuid, 'explicitFileType': productFileType}), + productFileName = productFile.basename; - if (!this.xcVersionGroupSection()[file.fileRef]) { - this.xcVersionGroupSection()[file.fileRef] = { - isa: 'XCVersionGroup', - children: file.models.map(function (el) { return el.fileRef; }), - currentVersion: file.currentModel.fileRef, - name: path.basename(file.path), - path: file.path, - sourceTree: '""', - versionGroupType: 'wrapper.xcdatamodel' - }; - this.xcVersionGroupSection()[commentKey] = path.basename(file.path); - } -} -pbxProject.prototype.addToPluginsPbxGroup = function(file) { - var pluginsGroup = this.pbxGroupByName('Plugins'); - pluginsGroup.children.push(pbxGroupChild(file)); -} + // Product: Add to build file list + this.addToPbxBuildFileSection(productFile); -pbxProject.prototype.removeFromPluginsPbxGroup = function(file) { - var pluginsGroupChildren = this.pbxGroupByName('Plugins').children, i; - for (i in pluginsGroupChildren) { - if (pbxGroupChild(file).value == pluginsGroupChildren[i].value && - pbxGroupChild(file).comment == pluginsGroupChildren[i].comment) { - pluginsGroupChildren.splice(i, 1); - break; - } - } -} + // Target: Create + var target = { + uuid: targetUuid, + pbxNativeTarget: { + isa: 'PBXNativeTarget', + name: '"' + targetName + '"', + productName: '"' + targetName + '"', + productReference: productFile.fileRef, + productType: '"' + producttypeForTargettype(targetType) + '"', + buildConfigurationList: buildConfigurations.uuid, + buildPhases: [], + buildRules: [], + dependencies: [] + } + }; -pbxProject.prototype.addToResourcesPbxGroup = function(file) { - var pluginsGroup = this.pbxGroupByName('Resources'); - pluginsGroup.children.push(pbxGroupChild(file)); -} + // Target: Add to PBXNativeTarget section + this.addToPbxNativeTargetSection(target) -pbxProject.prototype.removeFromResourcesPbxGroup = function(file) { - var pluginsGroupChildren = this.pbxGroupByName('Resources').children, i; - for (i in pluginsGroupChildren) { - if (pbxGroupChild(file).value == pluginsGroupChildren[i].value && - pbxGroupChild(file).comment == pluginsGroupChildren[i].comment) { - pluginsGroupChildren.splice(i, 1); - break; - } - } -} + // Product: Embed (only for "extension"-type targets) + if (targetType === 'app_extension') { -pbxProject.prototype.addToFrameworksPbxGroup = function(file) { - var pluginsGroup = this.pbxGroupByName('Frameworks'); - pluginsGroup.children.push(pbxGroupChild(file)); -} + // Create CopyFiles phase in first target + this.addBuildPhase([], 'PBXCopyFilesBuildPhase', 'Copy Files', this.getFirstTarget().uuid, targetType) -pbxProject.prototype.removeFromFrameworksPbxGroup = function(file) { - var pluginsGroupChildren = this.pbxGroupByName('Frameworks').children; + // Add product to CopyFiles phase + this.addToPbxCopyfilesBuildPhase(productFile) - for (i in pluginsGroupChildren) { - if (pbxGroupChild(file).value == pluginsGroupChildren[i].value && - pbxGroupChild(file).comment == pluginsGroupChildren[i].comment) { - pluginsGroupChildren.splice(i, 1); - break; - } - } -} + // this.addBuildPhaseToTarget(newPhase.buildPhase, this.getFirstTarget().uuid) -pbxProject.prototype.addToPbxEmbedFrameworksBuildPhase = function (file) { - var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target); - if (sources) { - sources.files.push(pbxBuildPhaseObj(file)); - } -} + }; -pbxProject.prototype.removeFromPbxEmbedFrameworksBuildPhase = function (file) { - var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target); - if (sources) { - var files = []; - for (i in sources.files) { - if (sources.files[i].comment != longComment(file)) { - files.push(sources.files[i]); - } - } - sources.files = files; - } -} + // Target: Add uuid to root project + this.addToPbxProjectSection(target); -pbxProject.prototype.addToProductsPbxGroup = function(file) { - var productsGroup = this.pbxGroupByName('Products'); - productsGroup.children.push(pbxGroupChild(file)); -} + // Target: Add dependency for this target to first (main) target + this.addTargetDependency(this.getFirstTarget().uuid, [target.uuid]); -pbxProject.prototype.removeFromProductsPbxGroup = function(file) { - var productsGroupChildren = this.pbxGroupByName('Products').children, i; - for (i in productsGroupChildren) { - if (pbxGroupChild(file).value == productsGroupChildren[i].value && - pbxGroupChild(file).comment == productsGroupChildren[i].comment) { - productsGroupChildren.splice(i, 1); - break; - } - } -} -pbxProject.prototype.addToPbxSourcesBuildPhase = function(file) { - var sources = this.pbxSourcesBuildPhaseObj(file.target); - sources.files.push(pbxBuildPhaseObj(file)); -} + // Return target on success + return target; -pbxProject.prototype.removeFromPbxSourcesBuildPhase = function(file) { +}; - var sources = this.pbxSourcesBuildPhaseObj(file.target), i; - for (i in sources.files) { - if (sources.files[i].comment == longComment(file)) { - sources.files.splice(i, 1); - break; +// helper recursive prop search+replace +function propReplace(obj, prop, value) { + var o = {}; + for (var p in obj) { + if (o.hasOwnProperty.call(obj, p)) { + if (typeof obj[p] == 'object' && !Array.isArray(obj[p])) { + propReplace(obj[p], prop, value); + } else if (p == prop) { + obj[p] = value; + } } } } -pbxProject.prototype.addToPbxResourcesBuildPhase = function(file) { - var sources = this.pbxResourcesBuildPhaseObj(file.target); - sources.files.push(pbxBuildPhaseObj(file)); -} - -pbxProject.prototype.removeFromPbxResourcesBuildPhase = function(file) { - var sources = this.pbxResourcesBuildPhaseObj(file.target), i; +// helper object creation functions +function pbxBuildFileObj(file) { + var obj = Object.create(null); - for (i in sources.files) { - if (sources.files[i].comment == longComment(file)) { - sources.files.splice(i, 1); - break; - } - } + obj.isa = 'PBXBuildFile'; + obj.fileRef = file.fileRef; + obj.fileRef_comment = file.basename; + if (file.settings) obj.settings = file.settings; + + return obj; } -pbxProject.prototype.addToPbxFrameworksBuildPhase = function(file) { - var sources = this.pbxFrameworksBuildPhaseObj(file.target); - sources.files.push(pbxBuildPhaseObj(file)); +function pbxFileReferenceObj(file) { + var fileObject = { + isa: "PBXFileReference", + name: "\"" + file.basename + "\"", + path: "\"" + file.path.replace(/\\/g, '/') + "\"", + sourceTree: file.sourceTree, + fileEncoding: file.fileEncoding, + lastKnownFileType: file.lastKnownFileType, + explicitFileType: file.explicitFileType, + includeInIndex: file.includeInIndex + }; + + return fileObject; } -pbxProject.prototype.removeFromPbxFrameworksBuildPhase = function(file) { - var sources = this.pbxFrameworksBuildPhaseObj(file.target); - for (i in sources.files) { - if (sources.files[i].comment == longComment(file)) { - sources.files.splice(i, 1); - break; - } - } +function pbxGroupChild(file) { + var obj = Object.create(null); + + obj.value = file.fileRef; + obj.comment = file.basename; + + return obj; } -pbxProject.prototype.addXCConfigurationList = function(configurationObjectsArray, defaultConfigurationName, comment) { - var pbxBuildConfigurationSection = this.pbxXCBuildConfigurationSection(), - pbxXCConfigurationListSection = this.pbxXCConfigurationList(), - xcConfigurationListUuid = this.generateUuid(), - commentKey = f("%s_comment", xcConfigurationListUuid), - xcConfigurationList = { - isa: 'XCConfigurationList', - buildConfigurations: [], - defaultConfigurationIsVisible: 0, - defaultConfigurationName: defaultConfigurationName - }; +function pbxBuildPhaseObj(file) { + var obj = Object.create(null); - for (var index = 0; index < configurationObjectsArray.length; index++) { - var configuration = configurationObjectsArray[index], - configurationUuid = this.generateUuid(), - configurationCommentKey = f("%s_comment", configurationUuid); + obj.value = file.uuid; + obj.comment = longComment(file); - pbxBuildConfigurationSection[configurationUuid] = configuration; - pbxBuildConfigurationSection[configurationCommentKey] = configuration.name; - xcConfigurationList.buildConfigurations.push({ value: configurationUuid, comment: configuration.name }); - } + return obj; +} - if (pbxXCConfigurationListSection) { - pbxXCConfigurationListSection[xcConfigurationListUuid] = xcConfigurationList; - pbxXCConfigurationListSection[commentKey] = comment; +function pbxCopyFilesBuildPhaseObj(obj, folderType, subfolderPath, phaseName) { + + // Add additional properties for 'CopyFiles' build phase + var DESTINATION_BY_TARGETTYPE = { + application: 'wrapper', + app_extension: 'plugins', + bundle: 'wrapper', + command_line_tool: 'wrapper', + dynamic_library: 'products_directory', + framework: 'shared_frameworks', + frameworks: 'frameworks', + static_library: 'products_directory', + unit_test_bundle: 'wrapper', + watch_app: 'wrapper', + watch_extension: 'plugins' + } + var SUBFOLDERSPEC_BY_DESTINATION = { + absolute_path: 0, + executables: 6, + frameworks: 10, + java_resources: 15, + plugins: 13, + products_directory: 16, + resources: 7, + shared_frameworks: 11, + shared_support: 12, + wrapper: 1, + xpc_services: 0 } - return { uuid: xcConfigurationListUuid, xcConfigurationList: xcConfigurationList }; + obj.name = '"' + phaseName + '"'; + obj.dstPath = subfolderPath || '""'; + obj.dstSubfolderSpec = SUBFOLDERSPEC_BY_DESTINATION[DESTINATION_BY_TARGETTYPE[folderType]]; + + return obj; } -pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) { - if (!target) - return undefined; +function pbxShellScriptBuildPhaseObj(obj, options, phaseName) { + obj.name = '"' + phaseName + '"'; + obj.inputPaths = options.inputPaths || []; + obj.outputPaths = options.outputPaths || []; + obj.shellPath = options.shellPath; + obj.shellScript = '"' + options.shellScript.replace(/"/g, '\\"') + '"'; - var nativeTargets = this.pbxNativeTargetSection(); + return obj; +} - if (typeof nativeTargets[target] == "undefined") - throw new Error("Invalid target: " + target); +function pbxBuildFileComment(file) { + return longComment(file); +} - for (var index = 0; index < dependencyTargets.length; index++) { - var dependencyTarget = dependencyTargets[index]; - if (typeof nativeTargets[dependencyTarget] == "undefined") - throw new Error("Invalid target: " + dependencyTarget); - } +function pbxFileReferenceComment(file) { + return file.basename || path.basename(file.path); +} - var pbxTargetDependency = 'PBXTargetDependency', - pbxContainerItemProxy = 'PBXContainerItemProxy', - pbxTargetDependencySection = this.hash.project.objects[pbxTargetDependency], - pbxContainerItemProxySection = this.hash.project.objects[pbxContainerItemProxy]; +function pbxNativeTargetComment(target) { + return target.name; +} - for (var index = 0; index < dependencyTargets.length; index++) { - var dependencyTargetUuid = dependencyTargets[index], - dependencyTargetCommentKey = f("%s_comment", dependencyTargetUuid), - targetDependencyUuid = this.generateUuid(), - targetDependencyCommentKey = f("%s_comment", targetDependencyUuid), - itemProxyUuid = this.generateUuid(), - itemProxyCommentKey = f("%s_comment", itemProxyUuid), - itemProxy = { - isa: pbxContainerItemProxy, - containerPortal: this.hash.project['rootObject'], - containerPortal_comment: this.hash.project['rootObject_comment'], - proxyType: 1, - remoteGlobalIDString: dependencyTargetUuid, - remoteInfo: nativeTargets[dependencyTargetUuid].name - }, - targetDependency = { - isa: pbxTargetDependency, - target: dependencyTargetUuid, - target_comment: nativeTargets[dependencyTargetCommentKey], - targetProxy: itemProxyUuid, - targetProxy_comment: pbxContainerItemProxy - }; +function longComment(file) { + return f("%s in %s", file.basename, file.group); +} - if (pbxContainerItemProxySection && pbxTargetDependencySection) { - pbxContainerItemProxySection[itemProxyUuid] = itemProxy; - pbxContainerItemProxySection[itemProxyCommentKey] = pbxContainerItemProxy; - pbxTargetDependencySection[targetDependencyUuid] = targetDependency; - pbxTargetDependencySection[targetDependencyCommentKey] = pbxTargetDependency; - nativeTargets[target].dependencies.push({ value: targetDependencyUuid, comment: pbxTargetDependency }) - } - } +// respect path +function correctForPluginsPath(file, project) { + return correctForPath(file, project, 'Plugins'); +} - return { uuid: target, target: nativeTargets[target] }; +function correctForResourcesPath(file, project) { + return correctForPath(file, project, 'Resources'); } -pbxProject.prototype.addBuildPhase = function(filePathsArray, buildPhaseType, comment, target, optionsOrFolderType, subfolderPath) { - var buildPhaseSection, - fileReferenceSection = this.pbxFileReferenceSection(), - buildFileSection = this.pbxBuildFileSection(), - buildPhaseUuid = this.generateUuid(), - buildPhaseTargetUuid = target || this.getFirstTarget().uuid, - commentKey = f("%s_comment", buildPhaseUuid), - buildPhase = { - isa: buildPhaseType, - buildActionMask: 2147483647, - files: [], - runOnlyForDeploymentPostprocessing: 0 - }, - filePathToBuildFile = {}; +function correctForFrameworksPath(file, project) { + return correctForPath(file, project, 'Frameworks'); +} - if (buildPhaseType === 'PBXCopyFilesBuildPhase') { - buildPhase = pbxCopyFilesBuildPhaseObj(buildPhase, optionsOrFolderType, subfolderPath, comment); - } else if (buildPhaseType === 'PBXShellScriptBuildPhase') { - buildPhase = pbxShellScriptBuildPhaseObj(buildPhase, optionsOrFolderType, comment) - } +function correctForPath(file, project, group) { + var r_group_dir = new RegExp('^' + group + '[\\\\/]'); - if (!this.hash.project.objects[buildPhaseType]) { - this.hash.project.objects[buildPhaseType] = new Object(); + if (project.pbxGroupByName(group).path) + file.path = file.path.replace(r_group_dir, ''); + + return file; +} + +function searchPathForFile(file, proj) { + var plugins = proj.pbxGroupByName('Plugins'), + pluginsPath = plugins ? plugins.path : null, + fileDir = path.dirname(file.path); + + if (fileDir == '.') { + fileDir = ''; + } else { + fileDir = '/' + fileDir; } - if (!this.hash.project.objects[buildPhaseType][buildPhaseUuid]) { - this.hash.project.objects[buildPhaseType][buildPhaseUuid] = buildPhase; - this.hash.project.objects[buildPhaseType][commentKey] = comment; + if (file.plugin && pluginsPath) { + return '"\\"$(SRCROOT)/' + unquote(pluginsPath) + '\\""'; + } else if (file.customFramework && file.dirname) { + return '"\\"' + file.dirname + '\\""'; + } else { + return '"\\"$(SRCROOT)/' + proj.productName + fileDir + '\\""'; } +} - if (this.hash.project.objects['PBXNativeTarget'][buildPhaseTargetUuid]['buildPhases']) { - this.hash.project.objects['PBXNativeTarget'][buildPhaseTargetUuid]['buildPhases'].push({ - value: buildPhaseUuid, - comment: comment - }) +function nonComments(obj) { + var keys = Object.keys(obj), + newObj = {}, i = 0; + for (i; i < keys.length; i++) { + if (!COMMENT_KEY.test(keys[i])) { + newObj[keys[i]] = obj[keys[i]]; + } } + return newObj; +} - for (var key in buildFileSection) { - // only look for comments - if (!COMMENT_KEY.test(key)) continue; +function unquote(str) { + if (str) return str.replace(/^"(.*)"$/, "$1"); +} - var buildFileKey = key.split(COMMENT_KEY)[0], - buildFile = buildFileSection[buildFileKey]; - fileReference = fileReferenceSection[buildFile.fileRef]; - if (!fileReference) continue; - - var pbxFileObj = new pbxFile(fileReference.path); +function buildPhaseNameForIsa (isa) { - filePathToBuildFile[fileReference.path] = { uuid: buildFileKey, basename: pbxFileObj.basename, group: pbxFileObj.group }; + BUILDPHASENAME_BY_ISA = { + PBXCopyFilesBuildPhase: 'Copy Files', + PBXResourcesBuildPhase: 'Resources', + PBXSourcesBuildPhase: 'Sources', + PBXFrameworksBuildPhase: 'Frameworks' } - for (var index = 0; index < filePathsArray.length; index++) { - var filePath = filePathsArray[index], - filePathQuoted = "\"" + filePath + "\"", - file = new pbxFile(filePath); - - if (filePathToBuildFile[filePath]) { - buildPhase.files.push(pbxBuildPhaseObj(filePathToBuildFile[filePath])); - continue; - } else if (filePathToBuildFile[filePathQuoted]) { - buildPhase.files.push(pbxBuildPhaseObj(filePathToBuildFile[filePathQuoted])); - continue; - } + return BUILDPHASENAME_BY_ISA[isa] +} - file.uuid = this.generateUuid(); - file.fileRef = this.generateUuid(); - this.addToPbxFileReferenceSection(file); // PBXFileReference - this.addToPbxBuildFileSection(file); // PBXBuildFile - buildPhase.files.push(pbxBuildPhaseObj(file)); - } +function producttypeForTargettype (targetType) { - if (buildPhaseSection) { - buildPhaseSection[buildPhaseUuid] = buildPhase; - buildPhaseSection[commentKey] = comment; - } + PRODUCTTYPE_BY_TARGETTYPE = { + application: 'com.apple.product-type.application', + app_extension: 'com.apple.product-type.app-extension', + bundle: 'com.apple.product-type.bundle', + command_line_tool: 'com.apple.product-type.tool', + dynamic_library: 'com.apple.product-type.library.dynamic', + framework: 'com.apple.product-type.framework', + static_library: 'com.apple.product-type.library.static', + unit_test_bundle: 'com.apple.product-type.bundle.unit-test', + watch_app: 'com.apple.product-type.application.watchapp', + watch_extension: 'com.apple.product-type.watchkit-extension' + }; - return { uuid: buildPhaseUuid, buildPhase: buildPhase }; + return PRODUCTTYPE_BY_TARGETTYPE[targetType] } -// helper access functions -pbxProject.prototype.pbxProjectSection = function() { - return this.hash.project.objects['PBXProject']; -} -pbxProject.prototype.pbxBuildFileSection = function() { - return this.hash.project.objects['PBXBuildFile']; -} +function filetypeForProducttype (productType) { -pbxProject.prototype.pbxXCBuildConfigurationSection = function() { - return this.hash.project.objects['XCBuildConfiguration']; -} + FILETYPE_BY_PRODUCTTYPE = { + 'com.apple.product-type.application': '"wrapper.application"', + 'com.apple.product-type.app-extension': '"wrapper.app-extension"', + 'com.apple.product-type.bundle': '"wrapper.plug-in"', + 'com.apple.product-type.tool': '"compiled.mach-o.dylib"', + 'com.apple.product-type.library.dynamic': '"compiled.mach-o.dylib"', + 'com.apple.product-type.framework': '"wrapper.framework"', + 'com.apple.product-type.library.static': '"archive.ar"', + 'com.apple.product-type.bundle.unit-test': '"wrapper.cfbundle"', + 'com.apple.product-type.application.watchapp': '"wrapper.application"', + 'com.apple.product-type.watchkit-extension': '"wrapper.app-extension"' + }; -pbxProject.prototype.pbxFileReferenceSection = function() { - return this.hash.project.objects['PBXFileReference']; + return FILETYPE_BY_PRODUCTTYPE[productType] } -pbxProject.prototype.pbxNativeTargetSection = function() { - return this.hash.project.objects['PBXNativeTarget']; -} +pbxProject.prototype.getFirstProject = function() { -pbxProject.prototype.xcVersionGroupSection = function () { - if (typeof this.hash.project.objects['XCVersionGroup'] !== 'object') { - this.hash.project.objects['XCVersionGroup'] = {}; - } + // Get pbxProject container + var pbxProjectContainer = this.pbxProjectSection(); - return this.hash.project.objects['XCVersionGroup']; + // Get first pbxProject UUID + var firstProjectUuid = Object.keys(pbxProjectContainer)[0]; + + // Get first pbxProject + var firstProject = pbxProjectContainer[firstProjectUuid]; + + return { + uuid: firstProjectUuid, + firstProject: firstProject + } } -pbxProject.prototype.pbxXCConfigurationList = function() { - return this.hash.project.objects['XCConfigurationList']; +pbxProject.prototype.getFirstTarget = function() { + + // Get first targets UUID + var firstTargetUuid = this.getFirstProject()['firstProject']['targets'][0].value; + + // Get first pbxNativeTarget + var firstTarget = this.pbxNativeTargetSection()[firstTargetUuid]; + + return { + uuid: firstTargetUuid, + firstTarget: firstTarget + } } -pbxProject.prototype.pbxGroupByName = function(name) { - var groups = this.hash.project.objects['PBXGroup'], - key, groupKey; +/*** NEW ***/ - for (key in groups) { - // only look for comments - if (!COMMENT_KEY.test(key)) continue; +pbxProject.prototype.addToPbxGroupType = function (file, groupKey, groupType) { + var group = this.getPBXGroupByKeyAndType(groupKey, groupType); + if (group && group.children !== undefined) { + if (typeof file === 'string') { + //Group Key + var childGroup = { + value:file, + }; + if (this.getPBXGroupByKey(file)) { + childGroup.comment = this.getPBXGroupByKey(file).name; + } + else if (this.getPBXVariantGroupByKey(file)) { + childGroup.comment = this.getPBXVariantGroupByKey(file).name; + } - if (groups[key] == name) { - groupKey = key.split(COMMENT_KEY)[0]; - return groups[groupKey]; + group.children.push(childGroup); + } + else { + //File Object + group.children.push(pbxGroupChild(file)); } } +} - return null; +pbxProject.prototype.addToPbxVariantGroup = function (file, groupKey) { + this.addToPbxGroupType(file, groupKey, 'PBXVariantGroup'); } -pbxProject.prototype.pbxTargetByName = function(name) { - return this.pbxItemByComment(name, 'PBXNativeTarget'); +pbxProject.prototype.addToPbxGroup = function (file, groupKey) { + this.addToPbxGroupType(file, groupKey, 'PBXGroup'); } -pbxProject.prototype.findTargetKey = function(name) { - var targets = this.hash.project.objects['PBXNativeTarget']; - for (var key in targets) { - // only look for comments - if (COMMENT_KEY.test(key)) continue; - var target = targets[key]; - if (target.name === name) { - return key; - } +pbxProject.prototype.pbxCreateGroupWithType = function(name, pathName, groupType) { + //Create object + var model = { + isa: '"' + groupType + '"', + children: [], + name: name, + sourceTree: '""' + }; + if (pathName) model.path = pathName; + var key = this.generateUuid(); + + //Create comment + var commendId = key + '_comment'; + + //add obj and commentObj to groups; + var groups = this.hash.project.objects[groupType]; + if (!groups) { + groups = this.hash.project.objects[groupType] = new Object(); } + groups[commendId] = name; + groups[key] = model; - return null; + return key; } -pbxProject.prototype.pbxItemByComment = function(name, pbxSectionName) { - var section = this.hash.project.objects[pbxSectionName], - key, itemKey; +pbxProject.prototype.pbxCreateVariantGroup = function(name) { + return this.pbxCreateGroupWithType(name, undefined, 'PBXVariantGroup') +} - for (key in section) { - // only look for comments - if (!COMMENT_KEY.test(key)) continue; +pbxProject.prototype.pbxCreateGroup = function(name, pathName) { + return this.pbxCreateGroupWithType(name, pathName, 'PBXGroup'); +} - if (section[key] == name) { - itemKey = key.split(COMMENT_KEY)[0]; - return section[itemKey]; + + +pbxProject.prototype.removeFromPbxGroupAndType = function (file, groupKey, groupType) { + var group = this.getPBXGroupByKeyAndType(groupKey, groupType); + if (group) { + var groupChildren = group.children, i; + for(i in groupChildren) { + if(pbxGroupChild(file).value == groupChildren[i].value && + pbxGroupChild(file).comment == groupChildren[i].comment) { + groupChildren.splice(i, 1); + break; + } } } - - return null; } -pbxProject.prototype.pbxSourcesBuildPhaseObj = function(target) { - return this.buildPhaseObject('PBXSourcesBuildPhase', 'Sources', target); +pbxProject.prototype.removeFromPbxGroup = function (file, groupKey) { + this.removeFromPbxGroupAndType(file, groupKey, 'PBXGroup'); } -pbxProject.prototype.pbxResourcesBuildPhaseObj = function(target) { - return this.buildPhaseObject('PBXResourcesBuildPhase', 'Resources', target); +pbxProject.prototype.removeFromPbxVariantGroup = function (file, groupKey) { + this.removeFromPbxGroupAndType(file, groupKey, 'PBXVariantGroup'); } -pbxProject.prototype.pbxFrameworksBuildPhaseObj = function(target) { - return this.buildPhaseObject('PBXFrameworksBuildPhase', 'Frameworks', target); -} -pbxProject.prototype.pbxEmbedFrameworksBuildPhaseObj = function (target) { - return this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed Frameworks', target); -}; -// Find Build Phase from group/target -pbxProject.prototype.buildPhase = function(group, target) { +pbxProject.prototype.getPBXGroupByKeyAndType = function(key, groupType) { + return this.hash.project.objects[groupType][key]; +}; - if (!target) - return undefined; +pbxProject.prototype.getPBXGroupByKey = function(key) { + return this.hash.project.objects['PBXGroup'][key]; +}; - var nativeTargets = this.pbxNativeTargetSection(); - if (typeof nativeTargets[target] == "undefined") - throw new Error("Invalid target: " + target); +pbxProject.prototype.getPBXVariantGroupByKey = function(key) { + return this.hash.project.objects['PBXVariantGroup'][key]; +}; - var nativeTarget = nativeTargets[target]; - var buildPhases = nativeTarget.buildPhases; - for(var i in buildPhases) - { - var buildPhase = buildPhases[i]; - if (buildPhase.comment==group) - return buildPhase.value + "_comment"; - } - } -pbxProject.prototype.buildPhaseObject = function(name, group, target) { - var section = this.hash.project.objects[name], - obj, sectionKey, key; - var buildPhase = this.buildPhase(group, target); - for (key in section) { +pbxProject.prototype.findPBXGroupKeyAndType = function(criteria, groupType) { + var groups = this.hash.project.objects[groupType]; + var target; + for (var key in groups) { // only look for comments - if (!COMMENT_KEY.test(key)) continue; + if (COMMENT_KEY.test(key)) continue; - // select the proper buildPhase - if (buildPhase && buildPhase!=key) - continue; - if (section[key] == group) { - sectionKey = key.split(COMMENT_KEY)[0]; - return section[sectionKey]; + var group = groups[key]; + if (criteria && criteria.path && criteria.name) { + if (criteria.path === group.path && criteria.name === group.name) { + target = key; + break + } + } + else if (criteria && criteria.path) { + if (criteria.path === group.path) { + target = key; + break + } + } + else if (criteria && criteria.name) { + if (criteria.name === group.name) { + target = key; + break + } } } - return null; + + return target; } -pbxProject.prototype.addBuildProperty = function(prop, value, build_name) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - key, configuration; +pbxProject.prototype.findPBXGroupKey = function(criteria) { + return this.findPBXGroupKeyAndType(criteria, 'PBXGroup'); +} - for (key in configurations){ - configuration = configurations[key]; - if (!build_name || configuration.name === build_name){ - configuration.buildSettings[prop] = value; - } - } +pbxProject.prototype.findPBXVariantGroupKey = function(criteria) { + return this.findPBXGroupKeyAndType(criteria, 'PBXVariantGroup'); } -pbxProject.prototype.removeBuildProperty = function(prop, build_name) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - key, configuration; +pbxProject.prototype.addLocalizationVariantGroup = function(name) { + var groupKey = this.pbxCreateVariantGroup(name); - for (key in configurations){ - configuration = configurations[key]; - if (configuration.buildSettings[prop] && - !build_name || configuration.name === build_name){ - delete configuration.buildSettings[prop]; - } + var resourceGroupKey = this.findPBXGroupKey({name: 'Resources'}); + this.addToPbxGroup(groupKey, resourceGroupKey); + + var localizationVariantGroup = { + uuid: this.generateUuid(), + fileRef: groupKey, + basename: name } + this.addToPbxBuildFileSection(localizationVariantGroup); // PBXBuildFile + this.addToPbxResourcesBuildPhase(localizationVariantGroup); //PBXResourcesBuildPhase + + return localizationVariantGroup; +}; + +pbxProject.prototype.addKnownRegion = function (name) { + if (!this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions']) { + this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions'] = []; + } + if (!this.hasKnownRegion(name)) { + this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions'].push(name); + } } -/** - * - * @param prop {String} - * @param value {String|Array|Object|Number|Boolean} - * @param build {String} Release or Debug - */ -pbxProject.prototype.updateBuildProperty = function(prop, value, build) { - var configs = this.pbxXCBuildConfigurationSection(); - for (var configName in configs) { - if (!COMMENT_KEY.test(configName)) { - var config = configs[configName]; - if ( (build && config.name === build) || (!build) ) { - config.buildSettings[prop] = value; - } - } +pbxProject.prototype.removeKnownRegion = function (name) { + var regions = this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions']; + if (regions) { + for (var i = 0; i < regions.length; i++) { + if (regions[i] === name) { + regions.splice(i, 1); + break; + } } + this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions'] = regions; + } } -pbxProject.prototype.updateProductName = function(name) { - this.updateBuildProperty('PRODUCT_NAME', '"' + name + '"'); +pbxProject.prototype.hasKnownRegion = function (name) { + var regions = this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions']; + if (regions) { + for (var i in regions) { + if (regions[i] === name) { + return true; + } + } + } + return false; } -pbxProject.prototype.removeFromFrameworkSearchPaths = function(file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - INHERITED = '"$(inherited)"', - SEARCH_PATHS = 'FRAMEWORK_SEARCH_PATHS', - config, buildSettings, searchPaths; - var new_path = searchPathForFile(file, this); - - for (config in configurations) { - buildSettings = configurations[config].buildSettings; - - if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) - continue; - - searchPaths = buildSettings[SEARCH_PATHS]; - - if (searchPaths) { - var matches = searchPaths.filter(function(p) { - return p.indexOf(new_path) > -1; - }); - matches.forEach(function(m) { - var idx = searchPaths.indexOf(m); - searchPaths.splice(idx, 1); - }); - } - } +pbxProject.prototype.getPBXObject = function(name) { + return this.hash.project.objects[name]; } -pbxProject.prototype.addToFrameworkSearchPaths = function(file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - INHERITED = '"$(inherited)"', - config, buildSettings, searchPaths; - for (config in configurations) { - buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) - continue; +pbxProject.prototype.addFile = function (path, group, opt) { + var file = new pbxFile(path, opt); - if (!buildSettings['FRAMEWORK_SEARCH_PATHS'] - || buildSettings['FRAMEWORK_SEARCH_PATHS'] === INHERITED) { - buildSettings['FRAMEWORK_SEARCH_PATHS'] = [INHERITED]; - } + // null is better for early errors + if (this.hasFile(file.path)) return null; - buildSettings['FRAMEWORK_SEARCH_PATHS'].push(searchPathForFile(file, this)); - } -} + file.fileRef = this.generateUuid(); -pbxProject.prototype.removeFromLibrarySearchPaths = function(file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - INHERITED = '"$(inherited)"', - SEARCH_PATHS = 'LIBRARY_SEARCH_PATHS', - config, buildSettings, searchPaths; - var new_path = searchPathForFile(file, this); + this.addToPbxFileReferenceSection(file); // PBXFileReference - for (config in configurations) { - buildSettings = configurations[config].buildSettings; + if (this.getPBXGroupByKey(group)) { + this.addToPbxGroup(file, group); // PBXGroup + } + else if (this.getPBXVariantGroupByKey(group)) { + this.addToPbxVariantGroup(file, group); // PBXVariantGroup + } - if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) - continue; + return file; +} - searchPaths = buildSettings[SEARCH_PATHS]; +pbxProject.prototype.removeFile = function (path, group, opt) { + var file = new pbxFile(path, opt); - if (searchPaths) { - var matches = searchPaths.filter(function(p) { - return p.indexOf(new_path) > -1; - }); - matches.forEach(function(m) { - var idx = searchPaths.indexOf(m); - searchPaths.splice(idx, 1); - }); - } + this.removeFromPbxFileReferenceSection(file); // PBXFileReference + if (this.getPBXGroupByKey(group)) { + this.removeFromPbxGroup(file, group); // PBXGroup + } + else if (this.getPBXVariantGroupByKey(group)) { + this.removeFromPbxVariantGroup(file, group); // PBXVariantGroup } -} -pbxProject.prototype.addToLibrarySearchPaths = function(file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - INHERITED = '"$(inherited)"', - config, buildSettings, searchPaths; + return file; +} - for (config in configurations) { - buildSettings = configurations[config].buildSettings; - if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) - continue; - if (!buildSettings['LIBRARY_SEARCH_PATHS'] - || buildSettings['LIBRARY_SEARCH_PATHS'] === INHERITED) { - buildSettings['LIBRARY_SEARCH_PATHS'] = [INHERITED]; +pbxProject.prototype.getBuildProperty = function(prop, build) { + var target; + var configs = this.pbxXCBuildConfigurationSection(); + for (var configName in configs) { + if (!COMMENT_KEY.test(configName)) { + var config = configs[configName]; + if ( (build && config.name === build) || (build === undefined) ) { + if (config.buildSettings[prop] !== undefined) { + target = config.buildSettings[prop]; + } + } } + } + return target; +} - if (typeof file === 'string') { - buildSettings['LIBRARY_SEARCH_PATHS'].push(file); - } else { - buildSettings['LIBRARY_SEARCH_PATHS'].push(searchPathForFile(file, this)); +pbxProject.prototype.getBuildConfigByName = function(name) { + var target = {}; + var configs = this.pbxXCBuildConfigurationSection(); + for (var configName in configs) { + if (!COMMENT_KEY.test(configName)) { + var config = configs[configName]; + if (config.name === name) { + target[configName] = config; + } } } + return target; } -pbxProject.prototype.removeFromHeaderSearchPaths = function(file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - INHERITED = '"$(inherited)"', - SEARCH_PATHS = 'HEADER_SEARCH_PATHS', - config, buildSettings, searchPaths; - var new_path = searchPathForFile(file, this); +pbxProject.prototype.addDataModelDocument = function(filePath, group, opt) { + if (!group) { + group = 'Resources'; + } + if (!this.getPBXGroupByKey(group)) { + group = this.findPBXGroupKey({ name: group }); + } - for (config in configurations) { - buildSettings = configurations[config].buildSettings; + var file = new pbxFile(filePath, opt); - if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) - continue; + if (!file || this.hasFile(file.path)) return null; - if (buildSettings[SEARCH_PATHS]) { - var matches = buildSettings[SEARCH_PATHS].filter(function(p) { - return p.indexOf(new_path) > -1; - }); - matches.forEach(function(m) { - var idx = buildSettings[SEARCH_PATHS].indexOf(m); - buildSettings[SEARCH_PATHS].splice(idx, 1); - }); - } + file.fileRef = this.generateUuid(); + this.addToPbxGroup(file, group); - } -} -pbxProject.prototype.addToHeaderSearchPaths = function(file) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - INHERITED = '"$(inherited)"', - config, buildSettings, searchPaths; + if (!file) return false; - for (config in configurations) { - buildSettings = configurations[config].buildSettings; + file.target = opt ? opt.target : undefined; + file.uuid = this.generateUuid(); - if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) - continue; + this.addToPbxBuildFileSection(file); + this.addToPbxSourcesBuildPhase(file); - if (!buildSettings['HEADER_SEARCH_PATHS']) { - buildSettings['HEADER_SEARCH_PATHS'] = [INHERITED]; - } + file.models = []; + var currentVersionName; + var modelFiles = fs.readdirSync(file.path); + for (var index in modelFiles) { + var modelFileName = modelFiles[index]; + var modelFilePath = path.join(filePath, modelFileName); - if (typeof file === 'string') { - buildSettings['HEADER_SEARCH_PATHS'].push(file); - } else { - buildSettings['HEADER_SEARCH_PATHS'].push(searchPathForFile(file, this)); + if (modelFileName == '.xccurrentversion') { + currentVersionName = plist.readFileSync(modelFilePath)._XCCurrentVersionName; + continue; } - } -} -pbxProject.prototype.addToOtherLinkerFlags = function (flag) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - INHERITED = '"$(inherited)"', - OTHER_LDFLAGS = 'OTHER_LDFLAGS', - config, buildSettings; + var modelFile = new pbxFile(modelFilePath); + modelFile.fileRef = this.generateUuid(); - for (config in configurations) { - buildSettings = configurations[config].buildSettings; + this.addToPbxFileReferenceSection(modelFile); - if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) - continue; + file.models.push(modelFile); - if (!buildSettings[OTHER_LDFLAGS] - || buildSettings[OTHER_LDFLAGS] === INHERITED) { - buildSettings[OTHER_LDFLAGS] = [INHERITED]; + if (currentVersionName && currentVersionName === modelFileName) { + file.currentModel = modelFile; } - - buildSettings[OTHER_LDFLAGS].push(flag); } -} -pbxProject.prototype.removeFromOtherLinkerFlags = function (flag) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - OTHER_LDFLAGS = 'OTHER_LDFLAGS', - config, buildSettings; + if (!file.currentModel) { + file.currentModel = file.models[0]; + } - for (config in configurations) { - buildSettings = configurations[config].buildSettings; + this.addToXcVersionGroupSection(file); - if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) { - continue; - } + return file; +} - if (buildSettings[OTHER_LDFLAGS]) { - var matches = buildSettings[OTHER_LDFLAGS].filter(function (p) { - return p.indexOf(flag) > -1; - }); - matches.forEach(function (m) { - var idx = buildSettings[OTHER_LDFLAGS].indexOf(m); - buildSettings[OTHER_LDFLAGS].splice(idx, 1); - }); - } +pbxProject.prototype.addTargetAttribute = function(prop, value, target) { + var attributes = this.getFirstProject()['firstProject']['attributes']; + if (attributes['TargetAttributes'] === undefined) { + attributes['TargetAttributes'] = {}; + } + target = target || this.getFirstTarget(); + if (attributes['TargetAttributes'][target.uuid] === undefined) { + attributes['TargetAttributes'][target.uuid] = {}; } + attributes['TargetAttributes'][target.uuid][prop] = value; } -pbxProject.prototype.addToBuildSettings = function (buildSetting, value) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - config, buildSettings; - - for (config in configurations) { - buildSettings = configurations[config].buildSettings; - - buildSettings[buildSetting] = value; +pbxProject.prototype.removeTargetAttribute = function(prop, target) { + var attributes = this.getFirstProject()['firstProject']['attributes']; + target = target || this.getFirstTarget(); + if (attributes['TargetAttributes'] && + attributes['TargetAttributes'][target.uuid]) { + delete attributes['TargetAttributes'][target.uuid][prop]; } } -pbxProject.prototype.removeFromBuildSettings = function (buildSetting) { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - config, buildSettings; +module.exports = pbxProject; - for (config in configurations) { - buildSettings = configurations[config].buildSettings; +/* WEBPACK VAR INJECTION */}.call(exports, "/")) - if (buildSettings[buildSetting]) { - delete buildSettings[buildSetting]; - } - } -} +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { -// a JS getter. hmmm -pbxProject.prototype.__defineGetter__("productName", function() { - var configurations = nonComments(this.pbxXCBuildConfigurationSection()), - config, productName; +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLCData, XMLNode, create, + 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; - for (config in configurations) { - productName = configurations[config].buildSettings['PRODUCT_NAME']; + create = __webpack_require__(1); - if (productName) { - return unquote(productName); - } - } -}); + XMLNode = __webpack_require__(6); -// check if file is present -pbxProject.prototype.hasFile = function(filePath) { - var files = nonComments(this.pbxFileReferenceSection()), - file, id; - for (id in files) { - file = files[id]; - if (file.path == filePath || file.path == ('"' + filePath + '"')) { - return file; - } + module.exports = XMLCData = (function(superClass) { + extend(XMLCData, superClass); + + function XMLCData(parent, text) { + XMLCData.__super__.constructor.call(this, parent); + if (text == null) { + throw new Error("Missing CDATA text"); + } + this.text = this.stringify.cdata(text); } - return false; -} + XMLCData.prototype.clone = function() { + return create(XMLCData.prototype, this); + }; -pbxProject.prototype.addTarget = function(name, type, subfolder) { + XMLCData.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += ''; + if (pretty) { + r += newline; + } + return r; + }; - // Setup uuid and name of new target - var targetUuid = this.generateUuid(), - targetType = type, - targetSubfolder = subfolder || name, - targetName = name.trim(); + return XMLCData; - // Check type against list of allowed target types - if (!targetName) { - throw new Error("Target name missing."); - } + })(XMLNode); - // Check type against list of allowed target types - if (!targetType) { - throw new Error("Target type missing."); - } +}).call(this); - // Check type against list of allowed target types - if (!producttypeForTargettype(targetType)) { - throw new Error("Target type invalid: " + targetType); - } - // Build Configuration: Create - var buildConfigurationsList = [ - { - name: 'Debug', - isa: 'XCBuildConfiguration', - buildSettings: { - GCC_PREPROCESSOR_DEFINITIONS: ['"DEBUG=1"', '"$(inherited)"'], - INFOPLIST_FILE: '"' + path.join(targetSubfolder, targetSubfolder + '-Info.plist' + '"'), - LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"', - PRODUCT_NAME: '"' + targetName + '"', - SKIP_INSTALL: 'YES' - } - }, - { - name: 'Release', - isa: 'XCBuildConfiguration', - buildSettings: { - INFOPLIST_FILE: '"' + path.join(targetSubfolder, targetSubfolder + '-Info.plist' + '"'), - LD_RUNPATH_SEARCH_PATHS: '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"', - PRODUCT_NAME: '"' + targetName + '"', - SKIP_INSTALL: 'YES' - } - } - ]; +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { - // Build Configuration: Add - var buildConfigurations = this.addXCConfigurationList(buildConfigurationsList, 'Release', 'Build configuration list for PBXNativeTarget "' + targetName +'"'); +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLComment, XMLNode, create, + 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; - // Product: Create - var productName = targetName, - productType = producttypeForTargettype(targetType), - productFileType = filetypeForProducttype(productType), - productFile = this.addProductFile(productName, { group: 'Copy Files', 'target': targetUuid, 'explicitFileType': productFileType}), - productFileName = productFile.basename; + create = __webpack_require__(1); + XMLNode = __webpack_require__(6); - // Product: Add to build file list - this.addToPbxBuildFileSection(productFile); + module.exports = XMLComment = (function(superClass) { + extend(XMLComment, superClass); - // Target: Create - var target = { - uuid: targetUuid, - pbxNativeTarget: { - isa: 'PBXNativeTarget', - name: '"' + targetName + '"', - productName: '"' + targetName + '"', - productReference: productFile.fileRef, - productType: '"' + producttypeForTargettype(targetType) + '"', - buildConfigurationList: buildConfigurations.uuid, - buildPhases: [], - buildRules: [], - dependencies: [] - } + function XMLComment(parent, text) { + XMLComment.__super__.constructor.call(this, parent); + if (text == null) { + throw new Error("Missing comment text"); + } + this.text = this.stringify.comment(text); + } + + XMLComment.prototype.clone = function() { + return create(XMLComment.prototype, this); }; - // Target: Add to PBXNativeTarget section - this.addToPbxNativeTargetSection(target) + XMLComment.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += ''; + if (pretty) { + r += newline; + } + return r; + }; - // Product: Embed (only for "extension"-type targets) - if (targetType === 'app_extension') { + return XMLComment; - // Create CopyFiles phase in first target - this.addBuildPhase([], 'PBXCopyFilesBuildPhase', 'Copy Files', this.getFirstTarget().uuid, targetType) + })(XMLNode); - // Add product to CopyFiles phase - this.addToPbxCopyfilesBuildPhase(productFile) +}).call(this); - // this.addBuildPhaseToTarget(newPhase.buildPhase, this.getFirstTarget().uuid) - }; +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { - // Target: Add uuid to root project - this.addToPbxProjectSection(target); +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLDeclaration, XMLNode, create, isObject, + 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; - // Target: Add dependency for this target to first (main) target - this.addTargetDependency(this.getFirstTarget().uuid, [target.uuid]); + create = __webpack_require__(1); + isObject = __webpack_require__(0); - // Return target on success - return target; + XMLNode = __webpack_require__(6); -}; + module.exports = XMLDeclaration = (function(superClass) { + extend(XMLDeclaration, superClass); -// helper recursive prop search+replace -function propReplace(obj, prop, value) { - var o = {}; - for (var p in obj) { - if (o.hasOwnProperty.call(obj, p)) { - if (typeof obj[p] == 'object' && !Array.isArray(obj[p])) { - propReplace(obj[p], prop, value); - } else if (p == prop) { - obj[p] = value; - } - } + function XMLDeclaration(parent, version, encoding, standalone) { + var ref; + XMLDeclaration.__super__.constructor.call(this, parent); + if (isObject(version)) { + ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone; + } + if (!version) { + version = '1.0'; + } + this.version = this.stringify.xmlVersion(version); + if (encoding != null) { + this.encoding = this.stringify.xmlEncoding(encoding); + } + if (standalone != null) { + this.standalone = this.stringify.xmlStandalone(standalone); + } } -} - -// helper object creation functions -function pbxBuildFileObj(file) { - var obj = Object.create(null); - - obj.isa = 'PBXBuildFile'; - obj.fileRef = file.fileRef; - obj.fileRef_comment = file.basename; - if (file.settings) obj.settings = file.settings; - - return obj; -} -function pbxFileReferenceObj(file) { - var fileObject = { - isa: "PBXFileReference", - name: "\"" + file.basename + "\"", - path: "\"" + file.path.replace(/\\/g, '/') + "\"", - sourceTree: file.sourceTree, - fileEncoding: file.fileEncoding, - lastKnownFileType: file.lastKnownFileType, - explicitFileType: file.explicitFileType, - includeInIndex: file.includeInIndex + XMLDeclaration.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += ''; + if (pretty) { + r += newline; + } + return r; }; - return fileObject; -} + return XMLDeclaration; -function pbxGroupChild(file) { - var obj = Object.create(null); + })(XMLNode); - obj.value = file.fileRef; - obj.comment = file.basename; +}).call(this); - return obj; -} -function pbxBuildPhaseObj(file) { - var obj = Object.create(null); +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { - obj.value = file.uuid; - obj.comment = longComment(file); +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLProcessingInstruction, create, isObject; - return obj; -} + create = __webpack_require__(1); -function pbxCopyFilesBuildPhaseObj(obj, folderType, subfolderPath, phaseName) { + isObject = __webpack_require__(0); - // Add additional properties for 'CopyFiles' build phase - var DESTINATION_BY_TARGETTYPE = { - application: 'wrapper', - app_extension: 'plugins', - bundle: 'wrapper', - command_line_tool: 'wrapper', - dynamic_library: 'products_directory', - framework: 'shared_frameworks', - frameworks: 'frameworks', - static_library: 'products_directory', - unit_test_bundle: 'wrapper', - watch_app: 'wrapper', - watch_extension: 'plugins' - } - var SUBFOLDERSPEC_BY_DESTINATION = { - absolute_path: 0, - executables: 6, - frameworks: 10, - java_resources: 15, - plugins: 13, - products_directory: 16, - resources: 7, - shared_frameworks: 11, - shared_support: 12, - wrapper: 1, - xpc_services: 0 - } + XMLCData = __webpack_require__(20); - obj.name = '"' + phaseName + '"'; - obj.dstPath = subfolderPath || '""'; - obj.dstSubfolderSpec = SUBFOLDERSPEC_BY_DESTINATION[DESTINATION_BY_TARGETTYPE[folderType]]; + XMLComment = __webpack_require__(21); - return obj; -} + XMLDTDAttList = __webpack_require__(57); -function pbxShellScriptBuildPhaseObj(obj, options, phaseName) { - obj.name = '"' + phaseName + '"'; - obj.inputPaths = options.inputPaths || []; - obj.outputPaths = options.outputPaths || []; - obj.shellPath = options.shellPath; - obj.shellScript = '"' + options.shellScript.replace(/"/g, '\\"') + '"'; + XMLDTDEntity = __webpack_require__(59); - return obj; -} + XMLDTDElement = __webpack_require__(58); -function pbxBuildFileComment(file) { - return longComment(file); -} + XMLDTDNotation = __webpack_require__(60); -function pbxFileReferenceComment(file) { - return file.basename || path.basename(file.path); -} + XMLProcessingInstruction = __webpack_require__(25); -function pbxNativeTargetComment(target) { - return target.name; -} + module.exports = XMLDocType = (function() { + function XMLDocType(parent, pubID, sysID) { + var ref, ref1; + this.documentObject = parent; + this.stringify = this.documentObject.stringify; + this.children = []; + if (isObject(pubID)) { + ref = pubID, pubID = ref.pubID, sysID = ref.sysID; + } + if (sysID == null) { + ref1 = [pubID, sysID], sysID = ref1[0], pubID = ref1[1]; + } + if (pubID != null) { + this.pubID = this.stringify.dtdPubID(pubID); + } + if (sysID != null) { + this.sysID = this.stringify.dtdSysID(sysID); + } + } -function longComment(file) { - return f("%s in %s", file.basename, file.group); -} + XMLDocType.prototype.element = function(name, value) { + var child; + child = new XMLDTDElement(this, name, value); + this.children.push(child); + return this; + }; -// respect path -function correctForPluginsPath(file, project) { - return correctForPath(file, project, 'Plugins'); -} + XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { + var child; + child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue); + this.children.push(child); + return this; + }; -function correctForResourcesPath(file, project) { - return correctForPath(file, project, 'Resources'); -} + XMLDocType.prototype.entity = function(name, value) { + var child; + child = new XMLDTDEntity(this, false, name, value); + this.children.push(child); + return this; + }; -function correctForFrameworksPath(file, project) { - return correctForPath(file, project, 'Frameworks'); -} - -function correctForPath(file, project, group) { - var r_group_dir = new RegExp('^' + group + '[\\\\/]'); + XMLDocType.prototype.pEntity = function(name, value) { + var child; + child = new XMLDTDEntity(this, true, name, value); + this.children.push(child); + return this; + }; - if (project.pbxGroupByName(group).path) - file.path = file.path.replace(r_group_dir, ''); + XMLDocType.prototype.notation = function(name, value) { + var child; + child = new XMLDTDNotation(this, name, value); + this.children.push(child); + return this; + }; - return file; -} + XMLDocType.prototype.cdata = function(value) { + var child; + child = new XMLCData(this, value); + this.children.push(child); + return this; + }; -function searchPathForFile(file, proj) { - var plugins = proj.pbxGroupByName('Plugins'), - pluginsPath = plugins ? plugins.path : null, - fileDir = path.dirname(file.path); + XMLDocType.prototype.comment = function(value) { + var child; + child = new XMLComment(this, value); + this.children.push(child); + return this; + }; - if (fileDir == '.') { - fileDir = ''; - } else { - fileDir = '/' + fileDir; - } + XMLDocType.prototype.instruction = function(target, value) { + var child; + child = new XMLProcessingInstruction(this, target, value); + this.children.push(child); + return this; + }; - if (file.plugin && pluginsPath) { - return '"\\"$(SRCROOT)/' + unquote(pluginsPath) + '\\""'; - } else if (file.customFramework && file.dirname) { - return '"\\"' + file.dirname + '\\""'; - } else { - return '"\\"$(SRCROOT)/' + proj.productName + fileDir + '\\""'; - } -} + XMLDocType.prototype.root = function() { + return this.documentObject.root(); + }; -function nonComments(obj) { - var keys = Object.keys(obj), - newObj = {}, i = 0; + XMLDocType.prototype.document = function() { + return this.documentObject; + }; - for (i; i < keys.length; i++) { - if (!COMMENT_KEY.test(keys[i])) { - newObj[keys[i]] = obj[keys[i]]; + XMLDocType.prototype.toString = function(options, level) { + var child, i, indent, len, newline, offset, pretty, r, ref, ref1, ref2, ref3, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += ' 0) { + r += ' ['; + if (pretty) { + r += newline; } - } + ref3 = this.children; + for (i = 0, len = ref3.length; i < len; i++) { + child = ref3[i]; + r += child.toString(options, level + 1); + } + r += ']'; + } + r += '>'; + if (pretty) { + r += newline; + } + return r; + }; - return newObj; -} + XMLDocType.prototype.ele = function(name, value) { + return this.element(name, value); + }; -function unquote(str) { - if (str) return str.replace(/^"(.*)"$/, "$1"); -} + XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { + return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue); + }; + XMLDocType.prototype.ent = function(name, value) { + return this.entity(name, value); + }; -function buildPhaseNameForIsa (isa) { + XMLDocType.prototype.pent = function(name, value) { + return this.pEntity(name, value); + }; - BUILDPHASENAME_BY_ISA = { - PBXCopyFilesBuildPhase: 'Copy Files', - PBXResourcesBuildPhase: 'Resources', - PBXSourcesBuildPhase: 'Sources', - PBXFrameworksBuildPhase: 'Frameworks' - } + XMLDocType.prototype.not = function(name, value) { + return this.notation(name, value); + }; - return BUILDPHASENAME_BY_ISA[isa] -} + XMLDocType.prototype.dat = function(value) { + return this.cdata(value); + }; -function producttypeForTargettype (targetType) { + XMLDocType.prototype.com = function(value) { + return this.comment(value); + }; - PRODUCTTYPE_BY_TARGETTYPE = { - application: 'com.apple.product-type.application', - app_extension: 'com.apple.product-type.app-extension', - bundle: 'com.apple.product-type.bundle', - command_line_tool: 'com.apple.product-type.tool', - dynamic_library: 'com.apple.product-type.library.dynamic', - framework: 'com.apple.product-type.framework', - static_library: 'com.apple.product-type.library.static', - unit_test_bundle: 'com.apple.product-type.bundle.unit-test', - watch_app: 'com.apple.product-type.application.watchapp', - watch_extension: 'com.apple.product-type.watchkit-extension' - }; + XMLDocType.prototype.ins = function(target, value) { + return this.instruction(target, value); + }; - return PRODUCTTYPE_BY_TARGETTYPE[targetType] -} + XMLDocType.prototype.up = function() { + return this.root(); + }; -function filetypeForProducttype (productType) { + XMLDocType.prototype.doc = function() { + return this.document(); + }; - FILETYPE_BY_PRODUCTTYPE = { - 'com.apple.product-type.application': '"wrapper.application"', - 'com.apple.product-type.app-extension': '"wrapper.app-extension"', - 'com.apple.product-type.bundle': '"wrapper.plug-in"', - 'com.apple.product-type.tool': '"compiled.mach-o.dylib"', - 'com.apple.product-type.library.dynamic': '"compiled.mach-o.dylib"', - 'com.apple.product-type.framework': '"wrapper.framework"', - 'com.apple.product-type.library.static': '"archive.ar"', - 'com.apple.product-type.bundle.unit-test': '"wrapper.cfbundle"', - 'com.apple.product-type.application.watchapp': '"wrapper.application"', - 'com.apple.product-type.watchkit-extension': '"wrapper.app-extension"' - }; + return XMLDocType; - return FILETYPE_BY_PRODUCTTYPE[productType] -} + })(); -pbxProject.prototype.getFirstProject = function() { +}).call(this); - // Get pbxProject container - var pbxProjectContainer = this.pbxProjectSection(); - // Get first pbxProject UUID - var firstProjectUuid = Object.keys(pbxProjectContainer)[0]; +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { - // Get first pbxProject - var firstProject = pbxProjectContainer[firstProjectUuid]; +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLAttribute, XMLElement, XMLNode, XMLProcessingInstruction, create, every, isFunction, isObject, + 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; - return { - uuid: firstProjectUuid, - firstProject: firstProject - } -} + create = __webpack_require__(1); -pbxProject.prototype.getFirstTarget = function() { + isObject = __webpack_require__(0); - // Get first targets UUID - var firstTargetUuid = this.getFirstProject()['firstProject']['targets'][0].value; + isFunction = __webpack_require__(11); - // Get first pbxNativeTarget - var firstTarget = this.pbxNativeTargetSection()[firstTargetUuid]; + every = __webpack_require__(66); - return { - uuid: firstTargetUuid, - firstTarget: firstTarget - } -} + XMLNode = __webpack_require__(6); -/*** NEW ***/ + XMLAttribute = __webpack_require__(55); -pbxProject.prototype.addToPbxGroupType = function (file, groupKey, groupType) { - var group = this.getPBXGroupByKeyAndType(groupKey, groupType); - if (group && group.children !== undefined) { - if (typeof file === 'string') { - //Group Key - var childGroup = { - value:file, - }; - if (this.getPBXGroupByKey(file)) { - childGroup.comment = this.getPBXGroupByKey(file).name; - } - else if (this.getPBXVariantGroupByKey(file)) { - childGroup.comment = this.getPBXVariantGroupByKey(file).name; - } + XMLProcessingInstruction = __webpack_require__(25); - group.children.push(childGroup); - } - else { - //File Object - group.children.push(pbxGroupChild(file)); - } - } -} + module.exports = XMLElement = (function(superClass) { + extend(XMLElement, superClass); -pbxProject.prototype.addToPbxVariantGroup = function (file, groupKey) { - this.addToPbxGroupType(file, groupKey, 'PBXVariantGroup'); -} + function XMLElement(parent, name, attributes) { + XMLElement.__super__.constructor.call(this, parent); + if (name == null) { + throw new Error("Missing element name"); + } + this.name = this.stringify.eleName(name); + this.children = []; + this.instructions = []; + this.attributes = {}; + if (attributes != null) { + this.attribute(attributes); + } + } -pbxProject.prototype.addToPbxGroup = function (file, groupKey) { - this.addToPbxGroupType(file, groupKey, 'PBXGroup'); -} - - - -pbxProject.prototype.pbxCreateGroupWithType = function(name, pathName, groupType) { - //Create object - var model = { - isa: '"' + groupType + '"', - children: [], - name: name, - sourceTree: '""' + XMLElement.prototype.clone = function() { + var att, attName, clonedSelf, i, len, pi, ref, ref1; + clonedSelf = create(XMLElement.prototype, this); + if (clonedSelf.isRoot) { + clonedSelf.documentObject = null; + } + clonedSelf.attributes = {}; + ref = this.attributes; + for (attName in ref) { + if (!hasProp.call(ref, attName)) continue; + att = ref[attName]; + clonedSelf.attributes[attName] = att.clone(); + } + clonedSelf.instructions = []; + ref1 = this.instructions; + for (i = 0, len = ref1.length; i < len; i++) { + pi = ref1[i]; + clonedSelf.instructions.push(pi.clone()); + } + clonedSelf.children = []; + this.children.forEach(function(child) { + var clonedChild; + clonedChild = child.clone(); + clonedChild.parent = clonedSelf; + return clonedSelf.children.push(clonedChild); + }); + return clonedSelf; }; - if (pathName) model.path = pathName; - var key = this.generateUuid(); - - //Create comment - var commendId = key + '_comment'; - - //add obj and commentObj to groups; - var groups = this.hash.project.objects[groupType]; - if (!groups) { - groups = this.hash.project.objects[groupType] = new Object(); - } - groups[commendId] = name; - groups[key] = model; - return key; -} + XMLElement.prototype.attribute = function(name, value) { + var attName, attValue; + if (name != null) { + name = name.valueOf(); + } + if (isObject(name)) { + for (attName in name) { + if (!hasProp.call(name, attName)) continue; + attValue = name[attName]; + this.attribute(attName, attValue); + } + } else { + if (isFunction(value)) { + value = value.apply(); + } + if (!this.options.skipNullAttributes || (value != null)) { + this.attributes[name] = new XMLAttribute(this, name, value); + } + } + return this; + }; -pbxProject.prototype.pbxCreateVariantGroup = function(name) { - return this.pbxCreateGroupWithType(name, undefined, 'PBXVariantGroup') -} + XMLElement.prototype.removeAttribute = function(name) { + var attName, i, len; + if (name == null) { + throw new Error("Missing attribute name"); + } + name = name.valueOf(); + if (Array.isArray(name)) { + for (i = 0, len = name.length; i < len; i++) { + attName = name[i]; + delete this.attributes[attName]; + } + } else { + delete this.attributes[name]; + } + return this; + }; -pbxProject.prototype.pbxCreateGroup = function(name, pathName) { - return this.pbxCreateGroupWithType(name, pathName, 'PBXGroup'); -} + XMLElement.prototype.instruction = function(target, value) { + var i, insTarget, insValue, instruction, len; + if (target != null) { + target = target.valueOf(); + } + if (value != null) { + value = value.valueOf(); + } + if (Array.isArray(target)) { + for (i = 0, len = target.length; i < len; i++) { + insTarget = target[i]; + this.instruction(insTarget); + } + } else if (isObject(target)) { + for (insTarget in target) { + if (!hasProp.call(target, insTarget)) continue; + insValue = target[insTarget]; + this.instruction(insTarget, insValue); + } + } else { + if (isFunction(value)) { + value = value.apply(); + } + instruction = new XMLProcessingInstruction(this, target, value); + this.instructions.push(instruction); + } + return this; + }; + XMLElement.prototype.toString = function(options, level) { + var att, child, i, indent, instruction, j, len, len1, name, newline, offset, pretty, r, ref, ref1, ref2, ref3, ref4, ref5, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + ref3 = this.instructions; + for (i = 0, len = ref3.length; i < len; i++) { + instruction = ref3[i]; + r += instruction.toString(options, level); + } + if (pretty) { + r += space; + } + r += '<' + this.name; + ref4 = this.attributes; + for (name in ref4) { + if (!hasProp.call(ref4, name)) continue; + att = ref4[name]; + r += att.toString(options); + } + if (this.children.length === 0 || every(this.children, function(e) { + return e.value === ''; + })) { + r += '/>'; + if (pretty) { + r += newline; + } + } else if (pretty && this.children.length === 1 && (this.children[0].value != null)) { + r += '>'; + r += this.children[0].value; + r += ''; + r += newline; + } else { + r += '>'; + if (pretty) { + r += newline; + } + ref5 = this.children; + for (j = 0, len1 = ref5.length; j < len1; j++) { + child = ref5[j]; + r += child.toString(options, level + 1); + } + if (pretty) { + r += space; + } + r += ''; + if (pretty) { + r += newline; + } + } + return r; + }; + XMLElement.prototype.att = function(name, value) { + return this.attribute(name, value); + }; -pbxProject.prototype.removeFromPbxGroupAndType = function (file, groupKey, groupType) { - var group = this.getPBXGroupByKeyAndType(groupKey, groupType); - if (group) { - var groupChildren = group.children, i; - for(i in groupChildren) { - if(pbxGroupChild(file).value == groupChildren[i].value && - pbxGroupChild(file).comment == groupChildren[i].comment) { - groupChildren.splice(i, 1); - break; - } - } - } -} + XMLElement.prototype.ins = function(target, value) { + return this.instruction(target, value); + }; -pbxProject.prototype.removeFromPbxGroup = function (file, groupKey) { - this.removeFromPbxGroupAndType(file, groupKey, 'PBXGroup'); -} + XMLElement.prototype.a = function(name, value) { + return this.attribute(name, value); + }; -pbxProject.prototype.removeFromPbxVariantGroup = function (file, groupKey) { - this.removeFromPbxGroupAndType(file, groupKey, 'PBXVariantGroup'); -} + XMLElement.prototype.i = function(target, value) { + return this.instruction(target, value); + }; + return XMLElement; + })(XMLNode); -pbxProject.prototype.getPBXGroupByKeyAndType = function(key, groupType) { - return this.hash.project.objects[groupType][key]; -}; +}).call(this); -pbxProject.prototype.getPBXGroupByKey = function(key) { - return this.hash.project.objects['PBXGroup'][key]; -}; -pbxProject.prototype.getPBXVariantGroupByKey = function(key) { - return this.hash.project.objects['PBXVariantGroup'][key]; -}; +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLProcessingInstruction, create; + create = __webpack_require__(1); -pbxProject.prototype.findPBXGroupKeyAndType = function(criteria, groupType) { - var groups = this.hash.project.objects[groupType]; - var target; + module.exports = XMLProcessingInstruction = (function() { + function XMLProcessingInstruction(parent, target, value) { + this.stringify = parent.stringify; + if (target == null) { + throw new Error("Missing instruction target"); + } + this.target = this.stringify.insTarget(target); + if (value) { + this.value = this.stringify.insValue(value); + } + } - for (var key in groups) { - // only look for comments - if (COMMENT_KEY.test(key)) continue; + XMLProcessingInstruction.prototype.clone = function() { + return create(XMLProcessingInstruction.prototype, this); + }; - var group = groups[key]; - if (criteria && criteria.path && criteria.name) { - if (criteria.path === group.path && criteria.name === group.name) { - target = key; - break - } - } - else if (criteria && criteria.path) { - if (criteria.path === group.path) { - target = key; - break - } - } - else if (criteria && criteria.name) { - if (criteria.name === group.name) { - target = key; - break - } - } - } + XMLProcessingInstruction.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += ''; + if (pretty) { + r += newline; + } + return r; + }; - return target; -} + return XMLProcessingInstruction; -pbxProject.prototype.findPBXGroupKey = function(criteria) { - return this.findPBXGroupKeyAndType(criteria, 'PBXGroup'); -} + })(); -pbxProject.prototype.findPBXVariantGroupKey = function(criteria) { - return this.findPBXGroupKeyAndType(criteria, 'PBXVariantGroup'); +}).call(this); + + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + +var baseCopy = __webpack_require__(72), + keys = __webpack_require__(8); + +/** + * The base implementation of `_.assign` without support for argument juggling, + * multiple sources, and `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. + */ +function baseAssign(object, source) { + return source == null + ? object + : baseCopy(source, keys(source), object); } -pbxProject.prototype.addLocalizationVariantGroup = function(name) { - var groupKey = this.pbxCreateVariantGroup(name); +module.exports = baseAssign; - var resourceGroupKey = this.findPBXGroupKey({name: 'Resources'}); - this.addToPbxGroup(groupKey, resourceGroupKey); - var localizationVariantGroup = { - uuid: this.generateUuid(), - fileRef: groupKey, - basename: name - } - this.addToPbxBuildFileSection(localizationVariantGroup); // PBXBuildFile - this.addToPbxResourcesBuildPhase(localizationVariantGroup); //PBXResourcesBuildPhase +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { - return localizationVariantGroup; -}; +var toObject = __webpack_require__(2); -pbxProject.prototype.addKnownRegion = function (name) { - if (!this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions']) { - this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions'] = []; +/** + * The base implementation of `get` without support for string paths + * and default values. + * + * @private + * @param {Object} object The object to query. + * @param {Array} path The path of the property to get. + * @param {string} [pathKey] The key representation of path. + * @returns {*} Returns the resolved value. + */ +function baseGet(object, path, pathKey) { + if (object == null) { + return; } - if (!this.hasKnownRegion(name)) { - this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions'].push(name); + if (pathKey !== undefined && pathKey in toObject(object)) { + path = [pathKey]; } -} + var index = 0, + length = path.length; -pbxProject.prototype.removeKnownRegion = function (name) { - var regions = this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions']; - if (regions) { - for (var i = 0; i < regions.length; i++) { - if (regions[i] === name) { - regions.splice(i, 1); - break; - } - } - this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions'] = regions; + while (object != null && index < length) { + object = object[path[index++]]; } + return (index && index == length) ? object : undefined; } -pbxProject.prototype.hasKnownRegion = function (name) { - var regions = this.pbxProjectSection()[this.getFirstProject()['uuid']]['knownRegions']; - if (regions) { - for (var i in regions) { - if (regions[i] === name) { - return true; - } - } +module.exports = baseGet; + + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + +var baseIsEqualDeep = __webpack_require__(78), + isObject = __webpack_require__(0), + isObjectLike = __webpack_require__(4); + +/** + * The base implementation of `_.isEqual` without support for `this` binding + * `customizer` functions. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {Function} [customizer] The function to customize comparing values. + * @param {boolean} [isLoose] Specify performing partial comparisons. + * @param {Array} [stackA] Tracks traversed `value` objects. + * @param {Array} [stackB] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + */ +function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) { + if (value === other) { + return true; } - return false; + if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB); } -pbxProject.prototype.getPBXObject = function(name) { - return this.hash.project.objects[name]; -} +module.exports = baseIsEqual; +/***/ }), +/* 29 */ +/***/ (function(module, exports) { -pbxProject.prototype.addFile = function (path, group, opt) { - var file = new pbxFile(path, opt); +/** + * The base implementation of `_.property` without support for deep paths. + * + * @private + * @param {string} key The key of the property to get. + * @returns {Function} Returns the new function. + */ +function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; +} - // null is better for early errors - if (this.hasFile(file.path)) return null; +module.exports = baseProperty; - file.fileRef = this.generateUuid(); - this.addToPbxFileReferenceSection(file); // PBXFileReference +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { - if (this.getPBXGroupByKey(group)) { - this.addToPbxGroup(file, group); // PBXGroup - } - else if (this.getPBXVariantGroupByKey(group)) { - this.addToPbxVariantGroup(file, group); // PBXVariantGroup - } +var identity = __webpack_require__(36); - return file; +/** + * A specialized version of `baseCallback` which only supports `this` binding + * and specifying the number of arguments to provide to `func`. + * + * @private + * @param {Function} func The function to bind. + * @param {*} thisArg The `this` binding of `func`. + * @param {number} [argCount] The number of arguments to provide to `func`. + * @returns {Function} Returns the callback. + */ +function bindCallback(func, thisArg, argCount) { + if (typeof func != 'function') { + return identity; + } + if (thisArg === undefined) { + return func; + } + switch (argCount) { + case 1: return function(value) { + return func.call(thisArg, value); + }; + case 3: return function(value, index, collection) { + return func.call(thisArg, value, index, collection); + }; + case 4: return function(accumulator, value, index, collection) { + return func.call(thisArg, accumulator, value, index, collection); + }; + case 5: return function(value, other, key, object, source) { + return func.call(thisArg, value, other, key, object, source); + }; + } + return function() { + return func.apply(thisArg, arguments); + }; } -pbxProject.prototype.removeFile = function (path, group, opt) { - var file = new pbxFile(path, opt); +module.exports = bindCallback; - this.removeFromPbxFileReferenceSection(file); // PBXFileReference - if (this.getPBXGroupByKey(group)) { - this.removeFromPbxGroup(file, group); // PBXGroup - } - else if (this.getPBXVariantGroupByKey(group)) { - this.removeFromPbxVariantGroup(file, group); // PBXVariantGroup - } +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { - return file; -} +var baseProperty = __webpack_require__(29); +/** + * Gets the "length" property value of `object`. + * + * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) + * that affects Safari on at least iOS 8.1-8.3 ARM64. + * + * @private + * @param {Object} object The object to query. + * @returns {*} Returns the "length" value. + */ +var getLength = baseProperty('length'); +module.exports = getLength; -pbxProject.prototype.getBuildProperty = function(prop, build) { - var target; - var configs = this.pbxXCBuildConfigurationSection(); - for (var configName in configs) { - if (!COMMENT_KEY.test(configName)) { - var config = configs[configName]; - if ( (build && config.name === build) || (build === undefined) ) { - if (config.buildSettings[prop] !== undefined) { - target = config.buildSettings[prop]; - } - } - } - } - return target; -} -pbxProject.prototype.getBuildConfigByName = function(name) { - var target = {}; - var configs = this.pbxXCBuildConfigurationSection(); - for (var configName in configs) { - if (!COMMENT_KEY.test(configName)) { - var config = configs[configName]; - if (config.name === name) { - target[configName] = config; - } - } - } - return target; +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + +var isNative = __webpack_require__(94); + +/** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ +function getNative(object, key) { + var value = object == null ? undefined : object[key]; + return isNative(value) ? value : undefined; } -pbxProject.prototype.addDataModelDocument = function(filePath, group, opt) { - if (!group) { - group = 'Resources'; - } - if (!this.getPBXGroupByKey(group)) { - group = this.findPBXGroupKey({ name: group }); - } +module.exports = getNative; - var file = new pbxFile(filePath, opt); - if (!file || this.hasFile(file.path)) return null; +/***/ }), +/* 33 */ +/***/ (function(module, exports, __webpack_require__) { - file.fileRef = this.generateUuid(); - this.addToPbxGroup(file, group); +var isArray = __webpack_require__(3), + toObject = __webpack_require__(2); - if (!file) return false; +/** Used to match property names within property paths. */ +var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/; - file.target = opt ? opt.target : undefined; - file.uuid = this.generateUuid(); +/** + * Checks if `value` is a property name and not a property path. + * + * @private + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. + */ +function isKey(value, object) { + var type = typeof value; + if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') { + return true; + } + if (isArray(value)) { + return false; + } + var result = !reIsDeepProp.test(value); + return result || (object != null && value in toObject(object)); +} - this.addToPbxBuildFileSection(file); - this.addToPbxSourcesBuildPhase(file); +module.exports = isKey; - file.models = []; - var currentVersionName; - var modelFiles = fs.readdirSync(file.path); - for (var index in modelFiles) { - var modelFileName = modelFiles[index]; - var modelFilePath = path.join(filePath, modelFileName); - if (modelFileName == '.xccurrentversion') { - currentVersionName = plist.readFileSync(modelFilePath)._XCCurrentVersionName; - continue; - } +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { - var modelFile = new pbxFile(modelFilePath); - modelFile.fileRef = this.generateUuid(); +var isObject = __webpack_require__(0); - this.addToPbxFileReferenceSection(modelFile); +/** + * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` if suitable for strict + * equality comparisons, else `false`. + */ +function isStrictComparable(value) { + return value === value && !isObject(value); +} - file.models.push(modelFile); +module.exports = isStrictComparable; - if (currentVersionName && currentVersionName === modelFileName) { - file.currentModel = modelFile; - } - } - if (!file.currentModel) { - file.currentModel = file.models[0]; - } +/***/ }), +/* 35 */ +/***/ (function(module, exports, __webpack_require__) { - this.addToXcVersionGroupSection(file); +var baseToString = __webpack_require__(84), + isArray = __webpack_require__(3); - return file; -} +/** Used to match property names within property paths. */ +var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g; -pbxProject.prototype.addTargetAttribute = function(prop, value, target) { - var attributes = this.getFirstProject()['firstProject']['attributes']; - if (attributes['TargetAttributes'] === undefined) { - attributes['TargetAttributes'] = {}; - } - target = target || this.getFirstTarget(); - if (attributes['TargetAttributes'][target.uuid] === undefined) { - attributes['TargetAttributes'][target.uuid] = {}; - } - attributes['TargetAttributes'][target.uuid][prop] = value; +/** Used to match backslashes in property paths. */ +var reEscapeChar = /\\(\\)?/g; + +/** + * Converts `value` to property path array if it's not one. + * + * @private + * @param {*} value The value to process. + * @returns {Array} Returns the property path array. + */ +function toPath(value) { + if (isArray(value)) { + return value; + } + var result = []; + baseToString(value).replace(rePropName, function(match, number, quote, string) { + result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); + }); + return result; } -pbxProject.prototype.removeTargetAttribute = function(prop, target) { - var attributes = this.getFirstProject()['firstProject']['attributes']; - target = target || this.getFirstTarget(); - if (attributes['TargetAttributes'] && - attributes['TargetAttributes'][target.uuid]) { - delete attributes['TargetAttributes'][target.uuid][prop]; - } +module.exports = toPath; + + +/***/ }), +/* 36 */ +/***/ (function(module, exports) { + +/** + * This method returns the first argument provided to it. + * + * @static + * @memberOf _ + * @category Utility + * @param {*} value Any value. + * @returns {*} Returns `value`. + * @example + * + * var object = { 'user': 'fred' }; + * + * _.identity(object) === object; + * // => true + */ +function identity(value) { + return value; } -module.exports = pbxProject; +module.exports = identity; -/* WEBPACK VAR INJECTION */}.call(exports, "/")) -/***/ }, +/***/ }), /* 37 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { /* * DOM Level 2 @@ -5361,73 +5361,203 @@ try{ //} -/***/ }, +/***/ }), /* 38 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { module.exports = require("events"); -/***/ }, +/***/ }), /* 39 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { module.exports = require("stream"); -/***/ }, +/***/ }), /* 40 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { -exports.project = __webpack_require__(36) +exports.project = __webpack_require__(19) -/***/ }, +/***/ }), /* 41 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { -"use strict"; +var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; +;(function (exports) { + 'use strict'; -// adapted from http://code.google.com/p/plist/source/browse/trunk/src/main/java/com/dd/plist/BinaryPropertyListWriter.java + var Arr = (typeof Uint8Array !== 'undefined') + ? Uint8Array + : Array -var streamBuffers = __webpack_require__(95); + var PLUS = '+'.charCodeAt(0) + var SLASH = '/'.charCodeAt(0) + var NUMBER = '0'.charCodeAt(0) + var LOWER = 'a'.charCodeAt(0) + var UPPER = 'A'.charCodeAt(0) + var PLUS_URL_SAFE = '-'.charCodeAt(0) + var SLASH_URL_SAFE = '_'.charCodeAt(0) -var debug = false; + function decode (elt) { + var code = elt.charCodeAt(0) + if (code === PLUS || + code === PLUS_URL_SAFE) + return 62 // '+' + if (code === SLASH || + code === SLASH_URL_SAFE) + return 63 // '/' + if (code < NUMBER) + return -1 //no match + if (code < NUMBER + 10) + return code - NUMBER + 26 + 26 + if (code < UPPER + 26) + return code - UPPER + if (code < LOWER + 26) + return code - LOWER + 26 + } -function Real(value) { - this.value = value; -} + function b64ToByteArray (b64) { + var i, j, l, tmp, placeHolders, arr -module.exports = function(dicts) { - var buffer = new streamBuffers.WritableStreamBuffer(); - buffer.write(new Buffer("bplist00")); + if (b64.length % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } - if (debug) { - console.log('create', __webpack_require__(5).inspect(dicts, false, 10)); - } + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + var len = b64.length + placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 - if (dicts instanceof Array && dicts.length === 1) { - dicts = dicts[0]; - } + // base64 is 4/3 + up to two characters of the original data + arr = new Arr(b64.length * 3 / 4 - placeHolders) - var entries = toEntries(dicts); - if (debug) { - console.log('entries', entries); - } - var idSizeInBytes = computeIdSizeInBytes(entries.length); - var offsets = []; - var offsetSizeInBytes; - var offsetTableOffset; + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? b64.length - 4 : b64.length - updateEntryIds(); + var L = 0 - entries.forEach(function(entry, entryIdx) { - offsets[entryIdx] = buffer.size(); - if (!entry) { - buffer.write(0x00); - } else { - write(entry); - } - }); + function push (v) { + arr[L++] = v + } + + for (i = 0, j = 0; i < l; i += 4, j += 3) { + tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) + push((tmp & 0xFF0000) >> 16) + push((tmp & 0xFF00) >> 8) + push(tmp & 0xFF) + } + + if (placeHolders === 2) { + tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) + push(tmp & 0xFF) + } else if (placeHolders === 1) { + tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) + push((tmp >> 8) & 0xFF) + push(tmp & 0xFF) + } + + return arr + } + + function uint8ToBase64 (uint8) { + var i, + extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes + output = "", + temp, length + + function encode (num) { + return lookup.charAt(num) + } + + function tripletToBase64 (num) { + return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) + } + + // go through the array every three bytes, we'll deal with trailing stuff later + for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { + temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) + output += tripletToBase64(temp) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + switch (extraBytes) { + case 1: + temp = uint8[uint8.length - 1] + output += encode(temp >> 2) + output += encode((temp << 4) & 0x3F) + output += '==' + break + case 2: + temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) + output += encode(temp >> 10) + output += encode((temp >> 4) & 0x3F) + output += encode((temp << 2) & 0x3F) + output += '=' + break + } + + return output + } + + exports.toByteArray = b64ToByteArray + exports.fromByteArray = uint8ToBase64 +}( false ? (this.base64js = {}) : exports)) + + +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +// adapted from http://code.google.com/p/plist/source/browse/trunk/src/main/java/com/dd/plist/BinaryPropertyListWriter.java + +var streamBuffers = __webpack_require__(50); + +var debug = false; + +function Real(value) { + this.value = value; +} + +module.exports = function(dicts) { + var buffer = new streamBuffers.WritableStreamBuffer(); + buffer.write(new Buffer("bplist00")); + + if (debug) { + console.log('create', __webpack_require__(5).inspect(dicts, false, 10)); + } + + if (dicts instanceof Array && dicts.length === 1) { + dicts = dicts[0]; + } + + var entries = toEntries(dicts); + if (debug) { + console.log('entries', entries); + } + var idSizeInBytes = computeIdSizeInBytes(entries.length); + var offsets = []; + var offsetSizeInBytes; + var offsetTableOffset; + + updateEntryIds(); + + entries.forEach(function(entry, entryIdx) { + offsets[entryIdx] = buffer.size(); + if (!entry) { + buffer.write(0x00); + } else { + write(entry); + } + }); writeOffsetTable(); writeTrailer(); @@ -5791,9 +5921,9 @@ function computeIdSizeInBytes(numberOfIds) { module.exports.Real = Real; -/***/ }, -/* 42 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 43 */ +/***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -6130,86 +6260,365 @@ function swapBytes(buffer) { } -/***/ }, -/* 43 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 44 */ +/***/ (function(module, exports, __webpack_require__) { +var __WEBPACK_AMD_DEFINE_RESULT__;// uuid.js +// +// Copyright (c) 2010-2012 Robert Kieffer +// MIT License - http://opensource.org/licenses/mit-license.php -/** - * Module dependencies. - */ +/*global window, require, define */ +(function(_window) { + 'use strict'; -var base64 = __webpack_require__(46); -var xmlbuilder = __webpack_require__(92); + // Unique ID creation requires a high quality random # generator. We feature + // detect to determine the best RNG source, normalizing to a function that + // returns 128-bits of randomness, since that's what's usually required + var _rng, _mathRNG, _nodeRNG, _whatwgRNG, _previousRoot; -/** - * Module exports. - */ + function setupBrowser() { + // Allow for MSIE11 msCrypto + var _crypto = _window.crypto || _window.msCrypto; -exports.build = build; + if (!_rng && _crypto && _crypto.getRandomValues) { + // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto + // + // Moderately fast, high quality + try { + var _rnds8 = new Uint8Array(16); + _whatwgRNG = _rng = function whatwgRNG() { + _crypto.getRandomValues(_rnds8); + return _rnds8; + }; + _rng(); + } catch(e) {} + } -/** - * Accepts a `Date` instance and returns an ISO date string. - * - * @param {Date} d - Date instance to serialize - * @returns {String} ISO date string representation of `d` - * @api private - */ + if (!_rng) { + // Math.random()-based (RNG) + // + // If all else fails, use Math.random(). It's fast, but is of unspecified + // quality. + var _rnds = new Array(16); + _mathRNG = _rng = function() { + for (var i = 0, r; i < 16; i++) { + if ((i & 0x03) === 0) { r = Math.random() * 0x100000000; } + _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; + } -function ISODateString(d){ - function pad(n){ - return n < 10 ? '0' + n : n; + return _rnds; + }; + if ('undefined' !== typeof console && console.warn) { + console.warn("[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()"); + } + } } - return d.getUTCFullYear()+'-' - + pad(d.getUTCMonth()+1)+'-' - + pad(d.getUTCDate())+'T' - + pad(d.getUTCHours())+':' - + pad(d.getUTCMinutes())+':' - + pad(d.getUTCSeconds())+'Z'; -} -/** - * Returns the internal "type" of `obj` via the - * `Object.prototype.toString()` trick. - * - * @param {Mixed} obj - any value - * @returns {String} the internal "type" name - * @api private - */ + function setupNode() { + // Node.js crypto-based RNG - http://nodejs.org/docs/v0.6.2/api/crypto.html + // + // Moderately fast, high quality + if (true) { + try { + var _rb = __webpack_require__(104).randomBytes; + _nodeRNG = _rng = _rb && function() {return _rb(16);}; + _rng(); + } catch(e) {} + } + } -var toString = Object.prototype.toString; -function type (obj) { - var m = toString.call(obj).match(/\[object (.*)\]/); - return m ? m[1] : m; -} + if (_window) { + setupBrowser(); + } else { + setupNode(); + } -/** - * Generate an XML plist string from the input object `obj`. - * - * @param {Object} obj - the object to convert - * @param {Object} [opts] - optional options object - * @returns {String} converted plist XML string - * @api public - */ + // Buffer class to use + var BufferClass = ('function' === typeof Buffer) ? Buffer : Array; -function build (obj, opts) { - var XMLHDR = { - version: '1.0', - encoding: 'UTF-8' - }; + // Maps for number <-> hex string conversion + var _byteToHex = []; + var _hexToByte = {}; + for (var i = 0; i < 256; i++) { + _byteToHex[i] = (i + 0x100).toString(16).substr(1); + _hexToByte[_byteToHex[i]] = i; + } - var XMLDTD = { - pubid: '-//Apple//DTD PLIST 1.0//EN', - sysid: 'http://www.apple.com/DTDs/PropertyList-1.0.dtd' - }; + // **`parse()` - Parse a UUID into it's component bytes** + function parse(s, buf, offset) { + var i = (buf && offset) || 0, ii = 0; - var doc = xmlbuilder.create('plist'); + buf = buf || []; + s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) { + if (ii < 16) { // Don't overflow! + buf[i + ii++] = _hexToByte[oct]; + } + }); - doc.dec(XMLHDR.version, XMLHDR.encoding, XMLHDR.standalone); - doc.dtd(XMLDTD.pubid, XMLDTD.sysid); - doc.att('version', '1.0'); + // Zero out remaining bytes if string was short + while (ii < 16) { + buf[i + ii++] = 0; + } - walk_obj(obj, doc); + return buf; + } + + // **`unparse()` - Convert UUID byte array (ala parse()) into a string** + function unparse(buf, offset) { + var i = offset || 0, bth = _byteToHex; + return bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]]; + } + + // **`v1()` - Generate time-based UUID** + // + // Inspired by https://github.com/LiosK/UUID.js + // and http://docs.python.org/library/uuid.html + + // random #'s we need to init node and clockseq + var _seedBytes = _rng(); + + // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) + var _nodeId = [ + _seedBytes[0] | 0x01, + _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5] + ]; + + // Per 4.2.2, randomize (14 bit) clockseq + var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff; + + // Previous uuid creation time + var _lastMSecs = 0, _lastNSecs = 0; + + // See https://github.com/broofa/node-uuid for API details + function v1(options, buf, offset) { + var i = buf && offset || 0; + var b = buf || []; + + options = options || {}; + + var clockseq = (options.clockseq != null) ? options.clockseq : _clockseq; + + // UUID timestamps are 100 nano-second units since the Gregorian epoch, + // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so + // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' + // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. + var msecs = (options.msecs != null) ? options.msecs : new Date().getTime(); + + // Per 4.2.1.2, use count of uuid's generated during the current clock + // cycle to simulate higher resolution clock + var nsecs = (options.nsecs != null) ? options.nsecs : _lastNSecs + 1; + + // Time since last uuid creation (in msecs) + var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000; + + // Per 4.2.1.2, Bump clockseq on clock regression + if (dt < 0 && options.clockseq == null) { + clockseq = clockseq + 1 & 0x3fff; + } + + // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new + // time interval + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs == null) { + nsecs = 0; + } + + // Per 4.2.1.2 Throw error if too many uuids are requested + if (nsecs >= 10000) { + throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec'); + } + + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; + + // Per 4.1.4 - Convert from unix epoch to Gregorian epoch + msecs += 12219292800000; + + // `time_low` + var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; + b[i++] = tl >>> 24 & 0xff; + b[i++] = tl >>> 16 & 0xff; + b[i++] = tl >>> 8 & 0xff; + b[i++] = tl & 0xff; + + // `time_mid` + var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff; + b[i++] = tmh >>> 8 & 0xff; + b[i++] = tmh & 0xff; + + // `time_high_and_version` + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version + b[i++] = tmh >>> 16 & 0xff; + + // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) + b[i++] = clockseq >>> 8 | 0x80; + + // `clock_seq_low` + b[i++] = clockseq & 0xff; + + // `node` + var node = options.node || _nodeId; + for (var n = 0; n < 6; n++) { + b[i + n] = node[n]; + } + + return buf ? buf : unparse(b); + } + + // **`v4()` - Generate random UUID** + + // See https://github.com/broofa/node-uuid for API details + function v4(options, buf, offset) { + // Deprecated - 'format' argument, as supported in v1.2 + var i = buf && offset || 0; + + if (typeof(options) === 'string') { + buf = (options === 'binary') ? new BufferClass(16) : null; + options = null; + } + options = options || {}; + + var rnds = options.random || (options.rng || _rng)(); + + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + rnds[6] = (rnds[6] & 0x0f) | 0x40; + rnds[8] = (rnds[8] & 0x3f) | 0x80; + + // Copy bytes to buffer, if provided + if (buf) { + for (var ii = 0; ii < 16; ii++) { + buf[i + ii] = rnds[ii]; + } + } + + return buf || unparse(rnds); + } + + // Export public API + var uuid = v4; + uuid.v1 = v1; + uuid.v4 = v4; + uuid.parse = parse; + uuid.unparse = unparse; + uuid.BufferClass = BufferClass; + uuid._rng = _rng; + uuid._mathRNG = _mathRNG; + uuid._nodeRNG = _nodeRNG; + uuid._whatwgRNG = _whatwgRNG; + + if (('undefined' !== typeof module) && module.exports) { + // Publish as node.js module + module.exports = uuid; + } else if (true) { + // Publish as AMD module + !(__WEBPACK_AMD_DEFINE_RESULT__ = function() {return uuid;}.call(exports, __webpack_require__, exports, module), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + + + } else { + // Publish as global (in browsers) + _previousRoot = _window.uuid; + + // **`noConflict()` - (browser only) to reset global 'uuid' var** + uuid.noConflict = function() { + _window.uuid = _previousRoot; + return uuid; + }; + + _window.uuid = uuid; + } +})('undefined' !== typeof window ? window : null); + + +/***/ }), +/* 45 */ +/***/ (function(module, exports, __webpack_require__) { + + +/** + * Module dependencies. + */ + +var base64 = __webpack_require__(41); +var xmlbuilder = __webpack_require__(64); + +/** + * Module exports. + */ + +exports.build = build; + +/** + * Accepts a `Date` instance and returns an ISO date string. + * + * @param {Date} d - Date instance to serialize + * @returns {String} ISO date string representation of `d` + * @api private + */ + +function ISODateString(d){ + function pad(n){ + return n < 10 ? '0' + n : n; + } + return d.getUTCFullYear()+'-' + + pad(d.getUTCMonth()+1)+'-' + + pad(d.getUTCDate())+'T' + + pad(d.getUTCHours())+':' + + pad(d.getUTCMinutes())+':' + + pad(d.getUTCSeconds())+'Z'; +} + +/** + * Returns the internal "type" of `obj` via the + * `Object.prototype.toString()` trick. + * + * @param {Mixed} obj - any value + * @returns {String} the internal "type" name + * @api private + */ + +var toString = Object.prototype.toString; +function type (obj) { + var m = toString.call(obj).match(/\[object (.*)\]/); + return m ? m[1] : m; +} + +/** + * Generate an XML plist string from the input object `obj`. + * + * @param {Object} obj - the object to convert + * @param {Object} [opts] - optional options object + * @returns {String} converted plist XML string + * @api public + */ + +function build (obj, opts) { + var XMLHDR = { + version: '1.0', + encoding: 'UTF-8' + }; + + var XMLDTD = { + pubid: '-//Apple//DTD PLIST 1.0//EN', + sysid: 'http://www.apple.com/DTDs/PropertyList-1.0.dtd' + }; + + var doc = xmlbuilder.create('plist'); + + doc.dec(XMLHDR.version, XMLHDR.encoding, XMLHDR.standalone); + doc.dtd(XMLDTD.pubid, XMLDTD.sysid); + doc.att('version', '1.0'); + + walk_obj(obj, doc); if (!opts) opts = {}; // default `pretty` to `true` @@ -6274,9 +6683,9 @@ function walk_obj(next, next_child) { } -/***/ }, -/* 44 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 46 */ +/***/ (function(module, exports, __webpack_require__) { /** * Module dependencies. @@ -6284,7 +6693,7 @@ function walk_obj(next, next_child) { var fs = __webpack_require__(9); var parse = __webpack_require__(17); -var deprecate = __webpack_require__(35); +var deprecate = __webpack_require__(18); /** * Module exports. @@ -6329,9 +6738,9 @@ function parseFileSync (filename) { } -/***/ }, -/* 45 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 47 */ +/***/ (function(module, exports, __webpack_require__) { var i; @@ -6347,5458 +6756,5050 @@ for (i in parserFunctions) exports[i] = parserFunctions[i]; * Builder functions. */ -var builderFunctions = __webpack_require__(43); +var builderFunctions = __webpack_require__(45); for (i in builderFunctions) exports[i] = builderFunctions[i]; /** * Add Node.js-specific functions (they're deprecated…). */ -var nodeFunctions = __webpack_require__(44); +var nodeFunctions = __webpack_require__(46); for (i in nodeFunctions) exports[i] = nodeFunctions[i]; -/***/ }, -/* 46 */ -/***/ function(module, exports, __webpack_require__) { - -var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - -;(function (exports) { - 'use strict'; - - var Arr = (typeof Uint8Array !== 'undefined') - ? Uint8Array - : Array - - var PLUS = '+'.charCodeAt(0) - var SLASH = '/'.charCodeAt(0) - var NUMBER = '0'.charCodeAt(0) - var LOWER = 'a'.charCodeAt(0) - var UPPER = 'A'.charCodeAt(0) - var PLUS_URL_SAFE = '-'.charCodeAt(0) - var SLASH_URL_SAFE = '_'.charCodeAt(0) - - function decode (elt) { - var code = elt.charCodeAt(0) - if (code === PLUS || - code === PLUS_URL_SAFE) - return 62 // '+' - if (code === SLASH || - code === SLASH_URL_SAFE) - return 63 // '/' - if (code < NUMBER) - return -1 //no match - if (code < NUMBER + 10) - return code - NUMBER + 26 + 26 - if (code < UPPER + 26) - return code - UPPER - if (code < LOWER + 26) - return code - LOWER + 26 - } - - function b64ToByteArray (b64) { - var i, j, l, tmp, placeHolders, arr - - if (b64.length % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - var len = b64.length - placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 - - // base64 is 4/3 + up to two characters of the original data - arr = new Arr(b64.length * 3 / 4 - placeHolders) +/***/ }), +/* 48 */ +/***/ (function(module, exports, __webpack_require__) { - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? b64.length - 4 : b64.length +var bplistParser = __webpack_require__(43), + bplistCreator = __webpack_require__(42), + plist = __webpack_require__(47), + fs = __webpack_require__(9); - var L = 0 +// reveal the underlying modules +exports.plist = plist; +exports.bplistCreator = bplistCreator; +exports.bplistParser = bplistParser; - function push (v) { - arr[L++] = v - } - for (i = 0, j = 0; i < l; i += 4, j += 3) { - tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) - push((tmp & 0xFF0000) >> 16) - push((tmp & 0xFF00) >> 8) - push(tmp & 0xFF) - } +// Parses the given file and returns its contents as a native JavaScript +// object. +exports.readFileSync = function(aFile) { + var contents = fs.readFileSync(aFile); - if (placeHolders === 2) { - tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) - push(tmp & 0xFF) - } else if (placeHolders === 1) { - tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) - push((tmp >> 8) & 0xFF) - push(tmp & 0xFF) - } + if (contents.length === 0) { + console.error("Unable to read file '%s'", aFile); + return {}; + } + return exports.parse(contents, aFile); +}; - return arr - } +exports.readFile = function(aFile, callback) { + var results; - function uint8ToBase64 (uint8) { - var i, - extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes - output = "", - temp, length + fs.readFile(aFile, function(err, contents){ + if (err) { + callback(err); + } + else { + try { + results = exports.parse(contents, aFile); + callback(null,results); + } + catch(err) { + callback(err); + } + } + }); +} - function encode (num) { - return lookup.charAt(num) - } +exports.writeFileSync = function(aFile, anObject, options) { + var data = plist.build(anObject); + fs.writeFileSync(aFile, data, options); +}; - function tripletToBase64 (num) { - return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) - } +exports.writeFile = function(aFile, anObject, options, callback) { + if (arguments.length === 3 && typeof options === 'function') { + callback = options; + options = undefined; + } + var data = plist.build(anObject); + fs.writeFile(aFile, data, options, callback); +}; - // go through the array every three bytes, we'll deal with trailing stuff later - for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { - temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) - output += tripletToBase64(temp) - } +exports.writeBinaryFileSync = function(aFile, anObject, options) { + var data = bplistCreator(anObject); + fs.writeFileSync(aFile, data, options); +}; - // pad the end with zeros, but make sure to not forget the extra bytes - switch (extraBytes) { - case 1: - temp = uint8[uint8.length - 1] - output += encode(temp >> 2) - output += encode((temp << 4) & 0x3F) - output += '==' - break - case 2: - temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) - output += encode(temp >> 10) - output += encode((temp >> 4) & 0x3F) - output += encode((temp << 2) & 0x3F) - output += '=' - break - } +exports.writeBinaryFile = function(aFile, anObject, options, callback) { + if (arguments.length === 3 && typeof options === 'function') { + callback = options; + options = undefined; + } - return output - } + var data = bplistCreator(anObject); + fs.writeFile(aFile, data, options, callback); +}; - exports.toByteArray = b64ToByteArray - exports.fromByteArray = uint8ToBase64 -}( false ? (this.base64js = {}) : exports)) +exports.stringify = function(anObject) { + return plist.build(anObject); +}; -/***/ }, -/* 47 */ -/***/ function(module, exports) { -/** - * Gets the last element of `array`. - * - * @static - * @memberOf _ - * @category Array - * @param {Array} array The array to query. - * @returns {*} Returns the last element of `array`. - * @example - * - * _.last([1, 2, 3]); - * // => 3 - */ -function last(array) { - var length = array ? array.length : 0; - return length ? array[length - 1] : undefined; +exports.parse = function(aStringOrBuffer, aFile) { + var results, + firstByte = aStringOrBuffer[0]; + try { + if (firstByte === 60 || firstByte === '<') { + results = plist.parse(aStringOrBuffer.toString()); + } + else if (firstByte === 98) { + results = bplistParser.parseBuffer(aStringOrBuffer)[0]; + } + else { + if (aFile != undefined) { + console.error("Unable to determine format for '%s'", aFile); + } + else { + console.error("Unable to determine format for plist aStringOrBuffer: '%s'", aStringOrBuffer); + } + results = {}; + } + } + catch(e) { + throw Error("'%s' has errors", aFile); + } + return results; } -module.exports = last; - - -/***/ }, -/* 48 */ -/***/ function(module, exports, __webpack_require__) { -var arrayEvery = __webpack_require__(50), - baseCallback = __webpack_require__(53), - baseEvery = __webpack_require__(57), - isArray = __webpack_require__(3), - isIterateeCall = __webpack_require__(14); +/***/ }), +/* 49 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * Checks if `predicate` returns truthy for **all** elements of `collection`. - * The predicate is bound to `thisArg` and invoked with three arguments: - * (value, index|key, collection). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @alias all - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [predicate=_.identity] The function invoked - * per iteration. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {boolean} Returns `true` if all elements pass the predicate check, - * else `false`. - * @example - * - * _.every([true, 1, null, 'yes'], Boolean); - * // => false - * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false } - * ]; - * - * // using the `_.matches` callback shorthand - * _.every(users, { 'user': 'barney', 'active': false }); - * // => false - * - * // using the `_.matchesProperty` callback shorthand - * _.every(users, 'active', false); - * // => true - * - * // using the `_.property` callback shorthand - * _.every(users, 'active'); - * // => false - */ -function every(collection, predicate, thisArg) { - var func = isArray(collection) ? arrayEvery : baseEvery; - if (thisArg && isIterateeCall(collection, predicate, thisArg)) { - predicate = undefined; - } - if (typeof predicate != 'function' || thisArg !== undefined) { - predicate = baseCallback(predicate, thisArg, 3); - } - return func(collection, predicate); -} - -module.exports = every; - - -/***/ }, -/* 49 */ -/***/ function(module, exports) { - -/** Used as the `TypeError` message for "Functions" methods. */ -var FUNC_ERROR_TEXT = 'Expected a function'; - -/* Native method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max; - -/** - * Creates a function that invokes `func` with the `this` binding of the - * created function and arguments from `start` and beyond provided as an array. - * - * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/Web/JavaScript/Reference/Functions/rest_parameters). - * - * @static - * @memberOf _ - * @category Function - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @returns {Function} Returns the new function. - * @example - * - * var say = _.restParam(function(what, names) { - * return what + ' ' + _.initial(names).join(', ') + - * (_.size(names) > 1 ? ', & ' : '') + _.last(names); - * }); - * - * say('hello', 'fred', 'barney', 'pebbles'); - * // => 'hello fred, barney, & pebbles' - */ -function restParam(func, start) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0); - return function() { - var args = arguments, - index = -1, - length = nativeMax(args.length - start, 0), - rest = Array(length); - - while (++index < length) { - rest[index] = args[start + index]; - } - switch (start) { - case 0: return func.call(this, rest); - case 1: return func.call(this, args[0], rest); - case 2: return func.call(this, args[0], args[1], rest); - } - var otherArgs = Array(start + 1); - index = -1; - while (++index < start) { - otherArgs[index] = args[index]; - } - otherArgs[start] = rest; - return func.apply(this, otherArgs); - }; -} - -module.exports = restParam; +var stream = __webpack_require__(39), + constants = __webpack_require__(13), + util = __webpack_require__(5); + +var ReadableStreamBuffer = module.exports = function(opts) { + var that = this; + + stream.Stream.call(this); + + opts = opts || {}; + var frequency = opts.hasOwnProperty("frequency") ? opts.frequency : constants.DEFAULT_FREQUENCY; + var chunkSize = opts.chunkSize || constants.DEFAULT_CHUNK_SIZE; + var initialSize = opts.initialSize || constants.DEFAULT_INITIAL_SIZE; + var incrementAmount = opts.incrementAmount || constants.DEFAULT_INCREMENT_AMOUNT; + + var size = 0; + var buffer = new Buffer(initialSize); + var encoding = null; + + this.readable = true; + this.writable = false; + + var sendData = function() { + if(!size) { + that.emit("end"); + return; + } + + var amount = Math.min(chunkSize, size); + var chunk = null; + if(encoding) { + chunk = buffer.toString(encoding, 0, amount); + } + else { + chunk = new Buffer(amount); + buffer.copy(chunk, 0, 0, amount); + } + + that.emit("data", chunk); + + if(amount < buffer.length) + buffer.copy(buffer, 0, amount, size); + size -= amount; + }; + + this.size = function() { + return size; + }; + + this.maxSize = function() { + return buffer.length; + }; + + var increaseBufferIfNecessary = function(incomingDataSize) { + if((buffer.length - size) < incomingDataSize) { + var factor = Math.ceil((incomingDataSize - (buffer.length - size)) / incrementAmount); + + var newBuffer = new Buffer(buffer.length + (incrementAmount * factor)); + buffer.copy(newBuffer, 0, 0, size); + buffer = newBuffer; + } + }; + + this.put = function(data, encoding) { + if(!that.readable) return; + + if(Buffer.isBuffer(data)) { + increaseBufferIfNecessary(data.length); + data.copy(buffer, size, 0); + size += data.length; + } + else { + data = data + ""; + var dataSizeInBytes = Buffer.byteLength(data); + increaseBufferIfNecessary(dataSizeInBytes); + buffer.write(data, size, encoding || "utf8"); + size += dataSizeInBytes; + } + + if (!this.isPaused && !frequency) { + while (size > 0) { + sendData(); + } + } + }; + + this.pause = function() { + this.isPaused = true; + if(sendData && sendData.interval) { + clearInterval(sendData.interval); + delete sendData.interval; + } + }; + + this.resume = function() { + this.isPaused = false; + if(sendData && !sendData.interval && frequency > 0) { + sendData.interval = setInterval(sendData, frequency); + } + }; + + this.destroy = function() { + that.emit("end"); + if(sendData.interval) clearTimeout(sendData.interval); + sendData = null; + that.readable = false; + that.emit("close"); + }; + + this.setEncoding = function(_encoding) { + encoding = _encoding; + }; + + this.resume(); +}; +util.inherits(ReadableStreamBuffer, stream.Stream); -/***/ }, +/***/ }), /* 50 */ -/***/ function(module, exports) { - -/** - * A specialized version of `_.every` for arrays without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if all elements pass the predicate check, - * else `false`. - */ -function arrayEvery(array, predicate) { - var index = -1, - length = array.length; - - while (++index < length) { - if (!predicate(array[index], index, array)) { - return false; - } - } - return true; -} +/***/ (function(module, exports, __webpack_require__) { -module.exports = arrayEvery; +module.exports = __webpack_require__(13); +module.exports.ReadableStreamBuffer = __webpack_require__(49); +module.exports.WritableStreamBuffer = __webpack_require__(51); -/***/ }, +/***/ }), /* 51 */ -/***/ function(module, exports) { - -/** - * A specialized version of `_.some` for arrays without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. - */ -function arraySome(array, predicate) { - var index = -1, - length = array.length; - - while (++index < length) { - if (predicate(array[index], index, array)) { - return true; - } - } - return false; -} - -module.exports = arraySome; - +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 52 */ -/***/ function(module, exports, __webpack_require__) { - -var keys = __webpack_require__(7); - -/** - * A specialized version of `_.assign` for customizing assigned values without - * support for argument juggling, multiple sources, and `this` binding `customizer` - * functions. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {Function} customizer The function to customize assigned values. - * @returns {Object} Returns `object`. - */ -function assignWith(object, source, customizer) { - var index = -1, - props = keys(source), - length = props.length; - - while (++index < length) { - var key = props[index], - value = object[key], - result = customizer(value, source[key], key, object, source); - - if ((result === result ? (result !== value) : (value === value)) || - (value === undefined && !(key in object))) { - object[key] = result; - } - } - return object; -} - -module.exports = assignWith; - - -/***/ }, -/* 53 */ -/***/ function(module, exports, __webpack_require__) { - -var baseMatches = __webpack_require__(62), - baseMatchesProperty = __webpack_require__(63), - bindCallback = __webpack_require__(22), - identity = __webpack_require__(28), - property = __webpack_require__(82); - -/** - * The base implementation of `_.callback` which supports specifying the - * number of arguments to provide to `func`. - * - * @private - * @param {*} [func=_.identity] The value to convert to a callback. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {number} [argCount] The number of arguments to provide to `func`. - * @returns {Function} Returns the callback. - */ -function baseCallback(func, thisArg, argCount) { - var type = typeof func; - if (type == 'function') { - return thisArg === undefined - ? func - : bindCallback(func, thisArg, argCount); - } - if (func == null) { - return identity; - } - if (type == 'object') { - return baseMatches(func); - } - return thisArg === undefined - ? property(func) - : baseMatchesProperty(func, thisArg); -} - -module.exports = baseCallback; - - -/***/ }, -/* 54 */ -/***/ function(module, exports) { - -/** - * Copies properties of `source` to `object`. - * - * @private - * @param {Object} source The object to copy properties from. - * @param {Array} props The property names to copy. - * @param {Object} [object={}] The object to copy properties to. - * @returns {Object} Returns `object`. - */ -function baseCopy(source, props, object) { - object || (object = {}); - - var index = -1, - length = props.length; - - while (++index < length) { - var key = props[index]; - object[key] = source[key]; - } - return object; -} - -module.exports = baseCopy; - - -/***/ }, -/* 55 */ -/***/ function(module, exports, __webpack_require__) { - -var isObject = __webpack_require__(0); - -/** - * The base implementation of `_.create` without support for assigning - * properties to the created object. - * - * @private - * @param {Object} prototype The object to inherit from. - * @returns {Object} Returns the new object. - */ -var baseCreate = (function() { - function object() {} - return function(prototype) { - if (isObject(prototype)) { - object.prototype = prototype; - var result = new object; - object.prototype = undefined; - } - return result || {}; - }; -}()); - -module.exports = baseCreate; - - -/***/ }, -/* 56 */ -/***/ function(module, exports, __webpack_require__) { - -var baseForOwn = __webpack_require__(59), - createBaseEach = __webpack_require__(68); - -/** - * The base implementation of `_.forEach` without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array|Object|string} Returns `collection`. - */ -var baseEach = createBaseEach(baseForOwn); - -module.exports = baseEach; - - -/***/ }, -/* 57 */ -/***/ function(module, exports, __webpack_require__) { - -var baseEach = __webpack_require__(56); - -/** - * The base implementation of `_.every` without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if all elements pass the predicate check, - * else `false` - */ -function baseEvery(collection, predicate) { - var result = true; - baseEach(collection, function(value, index, collection) { - result = !!predicate(value, index, collection); - return result; - }); - return result; -} - -module.exports = baseEvery; - - -/***/ }, -/* 58 */ -/***/ function(module, exports, __webpack_require__) { - -var createBaseFor = __webpack_require__(69); - -/** - * The base implementation of `baseForIn` and `baseForOwn` which iterates - * over `object` properties returned by `keysFunc` invoking `iteratee` for - * each property. Iteratee functions may exit iteration early by explicitly - * returning `false`. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Object} Returns `object`. - */ -var baseFor = createBaseFor(); - -module.exports = baseFor; - - -/***/ }, -/* 59 */ -/***/ function(module, exports, __webpack_require__) { - -var baseFor = __webpack_require__(58), - keys = __webpack_require__(7); - -/** - * The base implementation of `_.forOwn` without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ -function baseForOwn(object, iteratee) { - return baseFor(object, iteratee, keys); -} - -module.exports = baseForOwn; - - -/***/ }, -/* 60 */ -/***/ function(module, exports, __webpack_require__) { - -var equalArrays = __webpack_require__(70), - equalByTag = __webpack_require__(71), - equalObjects = __webpack_require__(72), - isArray = __webpack_require__(3), - isTypedArray = __webpack_require__(78); - -/** `Object#toString` result references. */ -var argsTag = '[object Arguments]', - arrayTag = '[object Array]', - objectTag = '[object Object]'; - -/** Used for native method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) - * of values. - */ -var objToString = objectProto.toString; - -/** - * A specialized version of `baseIsEqual` for arrays and objects which performs - * deep comparisons and tracks traversed objects enabling objects with circular - * references to be compared. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} [customizer] The function to customize comparing objects. - * @param {boolean} [isLoose] Specify performing partial comparisons. - * @param {Array} [stackA=[]] Tracks traversed `value` objects. - * @param {Array} [stackB=[]] Tracks traversed `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) { - var objIsArr = isArray(object), - othIsArr = isArray(other), - objTag = arrayTag, - othTag = arrayTag; - - if (!objIsArr) { - objTag = objToString.call(object); - if (objTag == argsTag) { - objTag = objectTag; - } else if (objTag != objectTag) { - objIsArr = isTypedArray(object); - } - } - if (!othIsArr) { - othTag = objToString.call(other); - if (othTag == argsTag) { - othTag = objectTag; - } else if (othTag != objectTag) { - othIsArr = isTypedArray(other); - } - } - var objIsObj = objTag == objectTag, - othIsObj = othTag == objectTag, - isSameTag = objTag == othTag; - - if (isSameTag && !(objIsArr || objIsObj)) { - return equalByTag(object, other, objTag); - } - if (!isLoose) { - var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), - othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); - - if (objIsWrapped || othIsWrapped) { - return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB); - } - } - if (!isSameTag) { - return false; - } - // Assume cyclic values are equal. - // For more information on detecting circular references see https://es5.github.io/#JO. - stackA || (stackA = []); - stackB || (stackB = []); - - var length = stackA.length; - while (length--) { - if (stackA[length] == object) { - return stackB[length] == other; - } - } - // Add `object` and `other` to the stack of traversed objects. - stackA.push(object); - stackB.push(other); - - var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB); - - stackA.pop(); - stackB.pop(); - - return result; -} - -module.exports = baseIsEqualDeep; - - -/***/ }, -/* 61 */ -/***/ function(module, exports, __webpack_require__) { - -var baseIsEqual = __webpack_require__(20), - toObject = __webpack_require__(2); - -/** - * The base implementation of `_.isMatch` without support for callback - * shorthands and `this` binding. - * - * @private - * @param {Object} object The object to inspect. - * @param {Array} matchData The propery names, values, and compare flags to match. - * @param {Function} [customizer] The function to customize comparing objects. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - */ -function baseIsMatch(object, matchData, customizer) { - var index = matchData.length, - length = index, - noCustomizer = !customizer; - - if (object == null) { - return !length; - } - object = toObject(object); - while (index--) { - var data = matchData[index]; - if ((noCustomizer && data[2]) - ? data[1] !== object[data[0]] - : !(data[0] in object) - ) { - return false; - } - } - while (++index < length) { - data = matchData[index]; - var key = data[0], - objValue = object[key], - srcValue = data[1]; - - if (noCustomizer && data[2]) { - if (objValue === undefined && !(key in object)) { - return false; - } - } else { - var result = customizer ? customizer(objValue, srcValue, key) : undefined; - if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) { - return false; - } - } - } - return true; -} - -module.exports = baseIsMatch; - - -/***/ }, -/* 62 */ -/***/ function(module, exports, __webpack_require__) { - -var baseIsMatch = __webpack_require__(61), - getMatchData = __webpack_require__(73), - toObject = __webpack_require__(2); - -/** - * The base implementation of `_.matches` which does not clone `source`. - * - * @private - * @param {Object} source The object of property values to match. - * @returns {Function} Returns the new function. - */ -function baseMatches(source) { - var matchData = getMatchData(source); - if (matchData.length == 1 && matchData[0][2]) { - var key = matchData[0][0], - value = matchData[0][1]; - - return function(object) { - if (object == null) { - return false; - } - return object[key] === value && (value !== undefined || (key in toObject(object))); - }; - } - return function(object) { - return baseIsMatch(object, matchData); - }; -} - -module.exports = baseMatches; - - -/***/ }, -/* 63 */ -/***/ function(module, exports, __webpack_require__) { - -var baseGet = __webpack_require__(19), - baseIsEqual = __webpack_require__(20), - baseSlice = __webpack_require__(65), - isArray = __webpack_require__(3), - isKey = __webpack_require__(25), - isStrictComparable = __webpack_require__(26), - last = __webpack_require__(47), - toObject = __webpack_require__(2), - toPath = __webpack_require__(27); - -/** - * The base implementation of `_.matchesProperty` which does not clone `srcValue`. - * - * @private - * @param {string} path The path of the property to get. - * @param {*} srcValue The value to compare. - * @returns {Function} Returns the new function. - */ -function baseMatchesProperty(path, srcValue) { - var isArr = isArray(path), - isCommon = isKey(path) && isStrictComparable(srcValue), - pathKey = (path + ''); - - path = toPath(path); - return function(object) { - if (object == null) { - return false; - } - var key = pathKey; - object = toObject(object); - if ((isArr || !isCommon) && !(key in object)) { - object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); - if (object == null) { - return false; - } - key = last(path); - object = toObject(object); - } - return object[key] === srcValue - ? (srcValue !== undefined || (key in object)) - : baseIsEqual(srcValue, object[key], undefined, true); - }; -} - -module.exports = baseMatchesProperty; - - -/***/ }, -/* 64 */ -/***/ function(module, exports, __webpack_require__) { - -var baseGet = __webpack_require__(19), - toPath = __webpack_require__(27); - -/** - * A specialized version of `baseProperty` which supports deep paths. - * - * @private - * @param {Array|string} path The path of the property to get. - * @returns {Function} Returns the new function. - */ -function basePropertyDeep(path) { - var pathKey = (path + ''); - path = toPath(path); - return function(object) { - return baseGet(object, path, pathKey); - }; -} - -module.exports = basePropertyDeep; - - -/***/ }, -/* 65 */ -/***/ function(module, exports) { - -/** - * The base implementation of `_.slice` without an iteratee call guard. - * - * @private - * @param {Array} array The array to slice. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the slice of `array`. - */ -function baseSlice(array, start, end) { - var index = -1, - length = array.length; - - start = start == null ? 0 : (+start || 0); - if (start < 0) { - start = -start > length ? 0 : (length + start); - } - end = (end === undefined || end > length) ? length : (+end || 0); - if (end < 0) { - end += length; - } - length = start > end ? 0 : ((end - start) >>> 0); - start >>>= 0; - - var result = Array(length); - while (++index < length) { - result[index] = array[index + start]; - } - return result; -} - -module.exports = baseSlice; - - -/***/ }, -/* 66 */ -/***/ function(module, exports) { - -/** - * Converts `value` to a string if it's not one. An empty string is returned - * for `null` or `undefined` values. - * - * @private - * @param {*} value The value to process. - * @returns {string} Returns the string. - */ -function baseToString(value) { - return value == null ? '' : (value + ''); -} - -module.exports = baseToString; - - -/***/ }, -/* 67 */ -/***/ function(module, exports, __webpack_require__) { - -var bindCallback = __webpack_require__(22), - isIterateeCall = __webpack_require__(14), - restParam = __webpack_require__(49); - -/** - * Creates a `_.assign`, `_.defaults`, or `_.merge` function. - * - * @private - * @param {Function} assigner The function to assign values. - * @returns {Function} Returns the new assigner function. - */ -function createAssigner(assigner) { - return restParam(function(object, sources) { - var index = -1, - length = object == null ? 0 : sources.length, - customizer = length > 2 ? sources[length - 2] : undefined, - guard = length > 2 ? sources[2] : undefined, - thisArg = length > 1 ? sources[length - 1] : undefined; - - if (typeof customizer == 'function') { - customizer = bindCallback(customizer, thisArg, 5); - length -= 2; - } else { - customizer = typeof thisArg == 'function' ? thisArg : undefined; - length -= (customizer ? 1 : 0); - } - if (guard && isIterateeCall(sources[0], sources[1], guard)) { - customizer = length < 3 ? undefined : customizer; - length = 1; - } - while (++index < length) { - var source = sources[index]; - if (source) { - assigner(object, source, customizer); - } - } - return object; - }); -} - -module.exports = createAssigner; - - -/***/ }, -/* 68 */ -/***/ function(module, exports, __webpack_require__) { - -var getLength = __webpack_require__(23), - isLength = __webpack_require__(6), - toObject = __webpack_require__(2); - -/** - * Creates a `baseEach` or `baseEachRight` function. - * - * @private - * @param {Function} eachFunc The function to iterate over a collection. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new base function. - */ -function createBaseEach(eachFunc, fromRight) { - return function(collection, iteratee) { - var length = collection ? getLength(collection) : 0; - if (!isLength(length)) { - return eachFunc(collection, iteratee); - } - var index = fromRight ? length : -1, - iterable = toObject(collection); - - while ((fromRight ? index-- : ++index < length)) { - if (iteratee(iterable[index], index, iterable) === false) { - break; - } - } - return collection; - }; -} - -module.exports = createBaseEach; - - -/***/ }, -/* 69 */ -/***/ function(module, exports, __webpack_require__) { - -var toObject = __webpack_require__(2); - -/** - * Creates a base function for `_.forIn` or `_.forInRight`. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new base function. - */ -function createBaseFor(fromRight) { - return function(object, iteratee, keysFunc) { - var iterable = toObject(object), - props = keysFunc(object), - length = props.length, - index = fromRight ? length : -1; - - while ((fromRight ? index-- : ++index < length)) { - var key = props[index]; - if (iteratee(iterable[key], key, iterable) === false) { - break; - } - } - return object; - }; -} - -module.exports = createBaseFor; - - -/***/ }, -/* 70 */ -/***/ function(module, exports, __webpack_require__) { - -var arraySome = __webpack_require__(51); - -/** - * A specialized version of `baseIsEqualDeep` for arrays with support for - * partial deep comparisons. - * - * @private - * @param {Array} array The array to compare. - * @param {Array} other The other array to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} [customizer] The function to customize comparing arrays. - * @param {boolean} [isLoose] Specify performing partial comparisons. - * @param {Array} [stackA] Tracks traversed `value` objects. - * @param {Array} [stackB] Tracks traversed `other` objects. - * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. - */ -function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) { - var index = -1, - arrLength = array.length, - othLength = other.length; - - if (arrLength != othLength && !(isLoose && othLength > arrLength)) { - return false; - } - // Ignore non-index properties. - while (++index < arrLength) { - var arrValue = array[index], - othValue = other[index], - result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined; - - if (result !== undefined) { - if (result) { - continue; - } - return false; - } - // Recursively compare arrays (susceptible to call stack limits). - if (isLoose) { - if (!arraySome(other, function(othValue) { - return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); - })) { - return false; - } - } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) { - return false; - } - } - return true; -} - -module.exports = equalArrays; - - -/***/ }, -/* 71 */ -/***/ function(module, exports) { - -/** `Object#toString` result references. */ -var boolTag = '[object Boolean]', - dateTag = '[object Date]', - errorTag = '[object Error]', - numberTag = '[object Number]', - regexpTag = '[object RegExp]', - stringTag = '[object String]'; - -/** - * A specialized version of `baseIsEqualDeep` for comparing objects of - * the same `toStringTag`. - * - * **Note:** This function only supports comparing values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {string} tag The `toStringTag` of the objects to compare. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -function equalByTag(object, other, tag) { - switch (tag) { - case boolTag: - case dateTag: - // Coerce dates and booleans to numbers, dates to milliseconds and booleans - // to `1` or `0` treating invalid dates coerced to `NaN` as not equal. - return +object == +other; - - case errorTag: - return object.name == other.name && object.message == other.message; - - case numberTag: - // Treat `NaN` vs. `NaN` as equal. - return (object != +object) - ? other != +other - : object == +other; - - case regexpTag: - case stringTag: - // Coerce regexes to strings and treat strings primitives and string - // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details. - return object == (other + ''); - } - return false; -} - -module.exports = equalByTag; - - -/***/ }, -/* 72 */ -/***/ function(module, exports, __webpack_require__) { - -var keys = __webpack_require__(7); - -/** Used for native method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * A specialized version of `baseIsEqualDeep` for objects with support for - * partial deep comparisons. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} [customizer] The function to customize comparing values. - * @param {boolean} [isLoose] Specify performing partial comparisons. - * @param {Array} [stackA] Tracks traversed `value` objects. - * @param {Array} [stackB] Tracks traversed `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) { - var objProps = keys(object), - objLength = objProps.length, - othProps = keys(other), - othLength = othProps.length; - - if (objLength != othLength && !isLoose) { - return false; - } - var index = objLength; - while (index--) { - var key = objProps[index]; - if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) { - return false; - } - } - var skipCtor = isLoose; - while (++index < objLength) { - key = objProps[index]; - var objValue = object[key], - othValue = other[key], - result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined; - - // Recursively compare objects (susceptible to call stack limits). - if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) { - return false; - } - skipCtor || (skipCtor = key == 'constructor'); - } - if (!skipCtor) { - var objCtor = object.constructor, - othCtor = other.constructor; - - // Non `Object` object instances with different constructors are not equal. - if (objCtor != othCtor && - ('constructor' in object && 'constructor' in other) && - !(typeof objCtor == 'function' && objCtor instanceof objCtor && - typeof othCtor == 'function' && othCtor instanceof othCtor)) { - return false; - } - } - return true; -} - -module.exports = equalObjects; - - -/***/ }, -/* 73 */ -/***/ function(module, exports, __webpack_require__) { - -var isStrictComparable = __webpack_require__(26), - pairs = __webpack_require__(81); - -/** - * Gets the propery names, values, and compare flags of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the match data of `object`. - */ -function getMatchData(object) { - var result = pairs(object), - length = result.length; - - while (length--) { - result[length][2] = isStrictComparable(result[length][1]); - } - return result; -} - -module.exports = getMatchData; - - -/***/ }, -/* 74 */ -/***/ function(module, exports, __webpack_require__) { - -var isArguments = __webpack_require__(15), - isArray = __webpack_require__(3), - isIndex = __webpack_require__(13), - isLength = __webpack_require__(6), - keysIn = __webpack_require__(80); - -/** Used for native method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * A fallback implementation of `Object.keys` which creates an array of the - * own enumerable property names of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ -function shimKeys(object) { - var props = keysIn(object), - propsLength = props.length, - length = propsLength && object.length; - - var allowIndexes = !!length && isLength(length) && - (isArray(object) || isArguments(object)); - - var index = -1, - result = []; - - while (++index < propsLength) { - var key = props[index]; - if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) { - result.push(key); - } - } - return result; -} - -module.exports = shimKeys; - - -/***/ }, -/* 75 */ -/***/ function(module, exports, __webpack_require__) { - -var isArguments = __webpack_require__(15), - isArray = __webpack_require__(3), - isArrayLike = __webpack_require__(10), - isFunction = __webpack_require__(11), - isObjectLike = __webpack_require__(4), - isString = __webpack_require__(77), - keys = __webpack_require__(7); - -/** - * Checks if `value` is empty. A value is considered empty unless it's an - * `arguments` object, array, string, or jQuery-like collection with a length - * greater than `0` or an object with own enumerable properties. - * - * @static - * @memberOf _ - * @category Lang - * @param {Array|Object|string} value The value to inspect. - * @returns {boolean} Returns `true` if `value` is empty, else `false`. - * @example - * - * _.isEmpty(null); - * // => true - * - * _.isEmpty(true); - * // => true - * - * _.isEmpty(1); - * // => true - * - * _.isEmpty([1, 2, 3]); - * // => false - * - * _.isEmpty({ 'a': 1 }); - * // => false - */ -function isEmpty(value) { - if (value == null) { - return true; - } - if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) || - (isObjectLike(value) && isFunction(value.splice)))) { - return !value.length; - } - return !keys(value).length; -} - -module.exports = isEmpty; - - -/***/ }, -/* 76 */ -/***/ function(module, exports, __webpack_require__) { - -var isFunction = __webpack_require__(11), - isObjectLike = __webpack_require__(4); - -/** Used to detect host constructors (Safari > 5). */ -var reIsHostCtor = /^\[object .+?Constructor\]$/; - -/** Used for native method references. */ -var objectProto = Object.prototype; - -/** Used to resolve the decompiled source of functions. */ -var fnToString = Function.prototype.toString; +var util = __webpack_require__(5), + stream = __webpack_require__(39), + constants = __webpack_require__(13); + +// TODO: clear up specs on returning false from a write and emitting a drain event. +// Does this mean if I return false from a write, I should ignore any write requests between that false return and the drain event? +var WritableStreamBuffer = module.exports = function(opts) { + var that = this; + + stream.Stream.call(this); + + opts = opts || {}; + var initialSize = opts.initialSize || constants.DEFAULT_INITIAL_SIZE; + var incrementAmount = opts.incrementAmount || constants.DEFAULT_INCREMENT_AMOUNT; + + var buffer = new Buffer(initialSize); + var size = 0; + + this.writable = true; + this.readable = false; + + this.size = function() { + return size; + }; + + this.maxSize = function() { + return buffer.length; + }; + + this.getContents = function(length) { + if(!size) return false; + + var data = new Buffer(Math.min(length || size, size)); + buffer.copy(data, 0, 0, data.length); + + if(data.length < size) + buffer.copy(buffer, 0, data.length); + + size -= data.length; + + return data; + }; + + this.getContentsAsString = function(encoding, length) { + if(!size) return false; + + var data = buffer.toString(encoding || "utf8", 0, Math.min(length || size, size)); + var dataLength = Buffer.byteLength(data); + + if(dataLength < size) + buffer.copy(buffer, 0, dataLength); + + size -= dataLength; + return data; + }; + + var increaseBufferIfNecessary = function(incomingDataSize) { + if((buffer.length - size) < incomingDataSize) { + var factor = Math.ceil((incomingDataSize - (buffer.length - size)) / incrementAmount); + + var newBuffer = new Buffer(buffer.length + (incrementAmount * factor)); + buffer.copy(newBuffer, 0, 0, size); + buffer = newBuffer; + } + }; + + this.write = function(data, encoding) { + if(!that.writable) return; + + if(Buffer.isBuffer(data)) { + increaseBufferIfNecessary(data.length); + data.copy(buffer, size, 0); + size += data.length; + } + else { + data = data + ""; + increaseBufferIfNecessary(data.length); + buffer.write(data, size, encoding || "utf8"); + size += Buffer.byteLength(data); + } + }; + + this.end = function() { + var args = Array.prototype.slice.apply(arguments); + if(args.length) that.write.apply(that, args); + that.destroy(); + }; + + this.destroySoon = this.destroy = function() { + that.writable = false; + that.emit("close"); + }; +}; +util.inherits(WritableStreamBuffer, stream.Stream); -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; -/** Used to detect if a method is native. */ -var reIsNative = RegExp('^' + - fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&') - .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' -); +/***/ }), +/* 52 */ +/***/ (function(module, exports, __webpack_require__) { -/** - * Checks if `value` is a native function. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, else `false`. - * @example - * - * _.isNative(Array.prototype.push); - * // => true +"use strict"; +/* + * Generated by PEG.js 0.10.0. * - * _.isNative(_); - * // => false + * http://pegjs.org/ */ -function isNative(value) { - if (value == null) { - return false; - } - if (isFunction(value)) { - return reIsNative.test(fnToString.call(value)); - } - return isObjectLike(value) && reIsHostCtor.test(value); -} - -module.exports = isNative; - - -/***/ }, -/* 77 */ -/***/ function(module, exports, __webpack_require__) { - -var isObjectLike = __webpack_require__(4); - -/** `Object#toString` result references. */ -var stringTag = '[object String]'; -/** Used for native method references. */ -var objectProto = Object.prototype; -/** - * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) - * of values. - */ -var objToString = objectProto.toString; -/** - * Checks if `value` is classified as a `String` primitive or object. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - * @example - * - * _.isString('abc'); - * // => true - * - * _.isString(1); - * // => false - */ -function isString(value) { - return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag); +function peg$subclass(child, parent) { + function ctor() { this.constructor = child; } + ctor.prototype = parent.prototype; + child.prototype = new ctor(); } -module.exports = isString; - +function peg$SyntaxError(message, expected, found, location) { + this.message = message; + this.expected = expected; + this.found = found; + this.location = location; + this.name = "SyntaxError"; -/***/ }, -/* 78 */ -/***/ function(module, exports, __webpack_require__) { + if (typeof Error.captureStackTrace === "function") { + Error.captureStackTrace(this, peg$SyntaxError); + } +} -var isLength = __webpack_require__(6), - isObjectLike = __webpack_require__(4); +peg$subclass(peg$SyntaxError, Error); -/** `Object#toString` result references. */ -var argsTag = '[object Arguments]', - arrayTag = '[object Array]', - boolTag = '[object Boolean]', - dateTag = '[object Date]', - errorTag = '[object Error]', - funcTag = '[object Function]', - mapTag = '[object Map]', - numberTag = '[object Number]', - objectTag = '[object Object]', - regexpTag = '[object RegExp]', - setTag = '[object Set]', - stringTag = '[object String]', - weakMapTag = '[object WeakMap]'; +peg$SyntaxError.buildMessage = function(expected, found) { + var DESCRIBE_EXPECTATION_FNS = { + literal: function(expectation) { + return "\"" + literalEscape(expectation.text) + "\""; + }, -var arrayBufferTag = '[object ArrayBuffer]', - float32Tag = '[object Float32Array]', - float64Tag = '[object Float64Array]', - int8Tag = '[object Int8Array]', - int16Tag = '[object Int16Array]', - int32Tag = '[object Int32Array]', - uint8Tag = '[object Uint8Array]', - uint8ClampedTag = '[object Uint8ClampedArray]', - uint16Tag = '[object Uint16Array]', - uint32Tag = '[object Uint32Array]'; + "class": function(expectation) { + var escapedParts = "", + i; -/** Used to identify `toStringTag` values of typed arrays. */ -var typedArrayTags = {}; -typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = -typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = -typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = -typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = -typedArrayTags[uint32Tag] = true; -typedArrayTags[argsTag] = typedArrayTags[arrayTag] = -typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = -typedArrayTags[dateTag] = typedArrayTags[errorTag] = -typedArrayTags[funcTag] = typedArrayTags[mapTag] = -typedArrayTags[numberTag] = typedArrayTags[objectTag] = -typedArrayTags[regexpTag] = typedArrayTags[setTag] = -typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; + for (i = 0; i < expectation.parts.length; i++) { + escapedParts += expectation.parts[i] instanceof Array + ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) + : classEscape(expectation.parts[i]); + } -/** Used for native method references. */ -var objectProto = Object.prototype; + return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; + }, -/** - * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) - * of values. - */ -var objToString = objectProto.toString; + any: function(expectation) { + return "any character"; + }, -/** - * Checks if `value` is classified as a typed array. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. - * @example - * - * _.isTypedArray(new Uint8Array); - * // => true - * - * _.isTypedArray([]); - * // => false - */ -function isTypedArray(value) { - return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)]; -} + end: function(expectation) { + return "end of input"; + }, -module.exports = isTypedArray; + other: function(expectation) { + return expectation.description; + } + }; + function hex(ch) { + return ch.charCodeAt(0).toString(16).toUpperCase(); + } -/***/ }, -/* 79 */ -/***/ function(module, exports, __webpack_require__) { + function literalEscape(s) { + return s + .replace(/\\/g, '\\\\') + .replace(/"/g, '\\"') + .replace(/\0/g, '\\0') + .replace(/\t/g, '\\t') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) + .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); + } -var assignWith = __webpack_require__(52), - baseAssign = __webpack_require__(18), - createAssigner = __webpack_require__(67); + function classEscape(s) { + return s + .replace(/\\/g, '\\\\') + .replace(/\]/g, '\\]') + .replace(/\^/g, '\\^') + .replace(/-/g, '\\-') + .replace(/\0/g, '\\0') + .replace(/\t/g, '\\t') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) + .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); + } -/** - * Assigns own enumerable properties of source object(s) to the destination - * object. Subsequent sources overwrite property assignments of previous sources. - * If `customizer` is provided it's invoked to produce the assigned values. - * The `customizer` is bound to `thisArg` and invoked with five arguments: - * (objectValue, sourceValue, key, object, source). - * - * **Note:** This method mutates `object` and is based on - * [`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign). - * - * @static - * @memberOf _ - * @alias extend - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @param {Function} [customizer] The function to customize assigned values. - * @param {*} [thisArg] The `this` binding of `customizer`. - * @returns {Object} Returns `object`. - * @example - * - * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' }); - * // => { 'user': 'fred', 'age': 40 } - * - * // using a customizer callback - * var defaults = _.partialRight(_.assign, function(value, other) { - * return _.isUndefined(value) ? other : value; - * }); - * - * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); - * // => { 'user': 'barney', 'age': 36 } - */ -var assign = createAssigner(function(object, source, customizer) { - return customizer - ? assignWith(object, source, customizer) - : baseAssign(object, source); -}); + function describeExpectation(expectation) { + return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); + } -module.exports = assign; + function describeExpected(expected) { + var descriptions = new Array(expected.length), + i, j; + for (i = 0; i < expected.length; i++) { + descriptions[i] = describeExpectation(expected[i]); + } -/***/ }, -/* 80 */ -/***/ function(module, exports, __webpack_require__) { + descriptions.sort(); -var isArguments = __webpack_require__(15), - isArray = __webpack_require__(3), - isIndex = __webpack_require__(13), - isLength = __webpack_require__(6), - isObject = __webpack_require__(0); + if (descriptions.length > 0) { + for (i = 1, j = 1; i < descriptions.length; i++) { + if (descriptions[i - 1] !== descriptions[i]) { + descriptions[j] = descriptions[i]; + j++; + } + } + descriptions.length = j; + } -/** Used for native method references. */ -var objectProto = Object.prototype; + switch (descriptions.length) { + case 1: + return descriptions[0]; -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; + case 2: + return descriptions[0] + " or " + descriptions[1]; -/** - * Creates an array of the own and inherited enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keysIn(new Foo); - * // => ['a', 'b', 'c'] (iteration order is not guaranteed) - */ -function keysIn(object) { - if (object == null) { - return []; + default: + return descriptions.slice(0, -1).join(", ") + + ", or " + + descriptions[descriptions.length - 1]; + } } - if (!isObject(object)) { - object = Object(object); + + function describeFound(found) { + return found ? "\"" + literalEscape(found) + "\"" : "end of input"; } - var length = object.length; - length = (length && isLength(length) && - (isArray(object) || isArguments(object)) && length) || 0; - var Ctor = object.constructor, - index = -1, - isProto = typeof Ctor == 'function' && Ctor.prototype === object, - result = Array(length), - skipIndexes = length > 0; + return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; +}; - while (++index < length) { - result[index] = (index + ''); - } - for (var key in object) { - if (!(skipIndexes && isIndex(key, length)) && - !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { - result.push(key); - } - } - return result; -} +function peg$parse(input, options) { + options = options !== void 0 ? options : {}; -module.exports = keysIn; + var peg$FAILED = {}, + peg$startRuleFunctions = { Project: peg$parseProject }, + peg$startRuleFunction = peg$parseProject, -/***/ }, -/* 81 */ -/***/ function(module, exports, __webpack_require__) { + peg$c0 = function(headComment, obj) { + var proj = Object.create(null) + proj.project = obj -var keys = __webpack_require__(7), - toObject = __webpack_require__(2); + if (headComment) { + proj.headComment = headComment + } -/** - * Creates a two dimensional array of the key-value pairs for `object`, - * e.g. `[[key1, value1], [key2, value2]]`. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the new array of key-value pairs. - * @example - * - * _.pairs({ 'barney': 36, 'fred': 40 }); - * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed) - */ -function pairs(object) { - object = toObject(object); + return proj; + }, + peg$c1 = "{", + peg$c2 = peg$literalExpectation("{", false), + peg$c3 = "}", + peg$c4 = peg$literalExpectation("}", false), + peg$c5 = function(obj) { return obj }, + peg$c6 = function() { return Object.create(null) }, + peg$c7 = function(list) { + var returnObject = list[0][0]; + for(var i = 1; i < list.length; i++){ + var another = list[i][0]; + returnObject = merge_obj(returnObject, another); + } + return returnObject; + }, + peg$c8 = "=", + peg$c9 = peg$literalExpectation("=", false), + peg$c10 = ";", + peg$c11 = peg$literalExpectation(";", false), + peg$c12 = function(id, val) { + var result = Object.create(null); + result[id] = val + return result + }, + peg$c13 = function(commentedId, val) { + var result = Object.create(null), + commentKey = commentedId.id + '_comment'; + + result[commentedId.id] = val; + result[commentKey] = commentedId[commentKey]; + return result; + + }, + peg$c14 = function(id, commentedVal) { + var result = Object.create(null); + result[id] = commentedVal.value; + result[id + "_comment"] = commentedVal.comment; + return result; + }, + peg$c15 = function(id, comment) { + var result = Object.create(null); + result.id = id; + result[id + "_comment"] = comment.trim(); + return result + }, + peg$c16 = function(literal, comment) { + var result = Object.create(null) + result.comment = comment.trim(); + result.value = literal.trim(); + return result; + }, + peg$c17 = /^[^*]/, + peg$c18 = peg$classExpectation(["*"], true, false), + peg$c19 = function(body) { return body.join('') }, + peg$c20 = "/*", + peg$c21 = peg$literalExpectation("/*", false), + peg$c22 = "*/", + peg$c23 = peg$literalExpectation("*/", false), + peg$c24 = function(begin, fields) { + var section = Object.create(null); + section[begin.name] = fields + + return section + }, + peg$c25 = "/* Begin ", + peg$c26 = peg$literalExpectation("/* Begin ", false), + peg$c27 = " section */", + peg$c28 = peg$literalExpectation(" section */", false), + peg$c29 = function(sectionName) { return { name: sectionName } }, + peg$c30 = "/* End ", + peg$c31 = peg$literalExpectation("/* End ", false), + peg$c32 = "(", + peg$c33 = peg$literalExpectation("(", false), + peg$c34 = ")", + peg$c35 = peg$literalExpectation(")", false), + peg$c36 = function(arr) { return arr }, + peg$c37 = function() { return [] }, + peg$c38 = function(head, tail) { + if (tail) { + tail.unshift(head); + return tail; + } else { + return [head]; + } + }, + peg$c39 = function(val) { return val }, + peg$c40 = function(val, comment) { + var result = Object.create(null); + result.value = val.trim(); + result.comment = comment.trim(); + return result; + }, + peg$c41 = ",", + peg$c42 = peg$literalExpectation(",", false), + peg$c43 = /^[A-Za-z0-9_.]/, + peg$c44 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], "_", "."], false, false), + peg$c45 = function(id) { return id.join('') }, + peg$c46 = ".", + peg$c47 = peg$literalExpectation(".", false), + peg$c48 = function(decimal) { + // store decimals as strings + // as JS doesn't differentiate bw strings and numbers + return decimal.join('') + }, + peg$c49 = function(number) { return parseInt(number.join(''), 10) }, + peg$c50 = function(str) { return '"' + str + '"' }, + peg$c51 = function(str) { return str.join('') }, + peg$c52 = peg$anyExpectation(), + peg$c53 = function(char) { return char }, + peg$c54 = "\\", + peg$c55 = peg$literalExpectation("\\", false), + peg$c56 = function() { return '\\"' }, + peg$c57 = function(literal) { return literal.join('') }, + peg$c58 = /^[^;,\n]/, + peg$c59 = peg$classExpectation([";", ",", "\n"], true, false), + peg$c60 = "//", + peg$c61 = peg$literalExpectation("//", false), + peg$c62 = function(contents) { return contents }, + peg$c63 = function(contents) { return contents.join('') }, + peg$c64 = /^[0-9]/, + peg$c65 = peg$classExpectation([["0", "9"]], false, false), + peg$c66 = /^[A-Za-z]/, + peg$c67 = peg$classExpectation([["A", "Z"], ["a", "z"]], false, false), + peg$c68 = "\"", + peg$c69 = peg$literalExpectation("\"", false), + peg$c70 = peg$otherExpectation("whitespace"), + peg$c71 = /^[\t ]/, + peg$c72 = peg$classExpectation(["\t", " "], false, false), + peg$c73 = /^[\n\r]/, + peg$c74 = peg$classExpectation(["\n", "\r"], false, false), + + peg$currPos = 0, + peg$savedPos = 0, + peg$posDetailsCache = [{ line: 1, column: 1 }], + peg$maxFailPos = 0, + peg$maxFailExpected = [], + peg$silentFails = 0, + + peg$result; + + if ("startRule" in options) { + if (!(options.startRule in peg$startRuleFunctions)) { + throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); + } - var index = -1, - props = keys(object), - length = props.length, - result = Array(length); + peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; + } - while (++index < length) { - var key = props[index]; - result[index] = [key, object[key]]; + function text() { + return input.substring(peg$savedPos, peg$currPos); } - return result; -} -module.exports = pairs; + function location() { + return peg$computeLocation(peg$savedPos, peg$currPos); + } + function expected(description, location) { + location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) -/***/ }, -/* 82 */ -/***/ function(module, exports, __webpack_require__) { + throw peg$buildStructuredError( + [peg$otherExpectation(description)], + input.substring(peg$savedPos, peg$currPos), + location + ); + } -var baseProperty = __webpack_require__(21), - basePropertyDeep = __webpack_require__(64), - isKey = __webpack_require__(25); + function error(message, location) { + location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) -/** - * Creates a function that returns the property value at `path` on a - * given object. - * - * @static - * @memberOf _ - * @category Utility - * @param {Array|string} path The path of the property to get. - * @returns {Function} Returns the new function. - * @example - * - * var objects = [ - * { 'a': { 'b': { 'c': 2 } } }, - * { 'a': { 'b': { 'c': 1 } } } - * ]; - * - * _.map(objects, _.property('a.b.c')); - * // => [2, 1] - * - * _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c'); - * // => [1, 2] - */ -function property(path) { - return isKey(path) ? baseProperty(path) : basePropertyDeep(path); -} + throw peg$buildSimpleError(message, location); + } -module.exports = property; + function peg$literalExpectation(text, ignoreCase) { + return { type: "literal", text: text, ignoreCase: ignoreCase }; + } + function peg$classExpectation(parts, inverted, ignoreCase) { + return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; + } -/***/ }, -/* 83 */ -/***/ function(module, exports, __webpack_require__) { + function peg$anyExpectation() { + return { type: "any" }; + } -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLAttribute, create; + function peg$endExpectation() { + return { type: "end" }; + } - create = __webpack_require__(1); + function peg$otherExpectation(description) { + return { type: "other", description: description }; + } - module.exports = XMLAttribute = (function() { - function XMLAttribute(parent, name, value) { - this.stringify = parent.stringify; - if (name == null) { - throw new Error("Missing attribute name of element " + parent.name); + function peg$computePosDetails(pos) { + var details = peg$posDetailsCache[pos], p; + + if (details) { + return details; + } else { + p = pos - 1; + while (!peg$posDetailsCache[p]) { + p--; } - if (value == null) { - throw new Error("Missing attribute value for attribute " + name + " of element " + parent.name); + + details = peg$posDetailsCache[p]; + details = { + line: details.line, + column: details.column + }; + + while (p < pos) { + if (input.charCodeAt(p) === 10) { + details.line++; + details.column = 1; + } else { + details.column++; + } + + p++; } - this.name = this.stringify.attName(name); - this.value = this.stringify.attValue(value); + + peg$posDetailsCache[pos] = details; + return details; } + } - XMLAttribute.prototype.clone = function() { - return create(XMLAttribute.prototype, this); - }; + function peg$computeLocation(startPos, endPos) { + var startPosDetails = peg$computePosDetails(startPos), + endPosDetails = peg$computePosDetails(endPos); - XMLAttribute.prototype.toString = function(options, level) { - return ' ' + this.name + '="' + this.value + '"'; + return { + start: { + offset: startPos, + line: startPosDetails.line, + column: startPosDetails.column + }, + end: { + offset: endPos, + line: endPosDetails.line, + column: endPosDetails.column + } }; + } - return XMLAttribute; - - })(); + function peg$fail(expected) { + if (peg$currPos < peg$maxFailPos) { return; } -}).call(this); + if (peg$currPos > peg$maxFailPos) { + peg$maxFailPos = peg$currPos; + peg$maxFailExpected = []; + } + peg$maxFailExpected.push(expected); + } -/***/ }, -/* 84 */ -/***/ function(module, exports, __webpack_require__) { + function peg$buildSimpleError(message, location) { + return new peg$SyntaxError(message, null, null, location); + } -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLBuilder, XMLDeclaration, XMLDocType, XMLElement, XMLStringifier; + function peg$buildStructuredError(expected, found, location) { + return new peg$SyntaxError( + peg$SyntaxError.buildMessage(expected, found), + expected, + found, + location + ); + } - XMLStringifier = __webpack_require__(90); + function peg$parseProject() { + var s0, s1, s2, s3, s4, s5, s6; - XMLDeclaration = __webpack_require__(31); + s0 = peg$currPos; + s1 = peg$parseSingleLineComment(); + if (s1 === peg$FAILED) { + s1 = null; + } + if (s1 !== peg$FAILED) { + s2 = peg$parseInlineComment(); + if (s2 === peg$FAILED) { + s2 = null; + } + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + if (s3 !== peg$FAILED) { + s4 = peg$parseObject(); + if (s4 !== peg$FAILED) { + s5 = peg$parseNewLine(); + if (s5 !== peg$FAILED) { + s6 = peg$parse_(); + if (s6 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c0(s1, s4); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } - XMLDocType = __webpack_require__(32); + return s0; + } - XMLElement = __webpack_require__(33); + function peg$parseObject() { + var s0, s1, s2, s3; - module.exports = XMLBuilder = (function() { - function XMLBuilder(name, options) { - var root, temp; - if (name == null) { - throw new Error("Root element needs a name"); - } - if (options == null) { - options = {}; + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 123) { + s1 = peg$c1; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c2); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseAssignmentList(); + if (s2 === peg$FAILED) { + s2 = peg$parseEmptyBody(); } - this.options = options; - this.stringify = new XMLStringifier(options); - temp = new XMLElement(this, 'doc'); - root = temp.element(name); - root.isRoot = true; - root.documentObject = this; - this.rootObject = root; - if (!options.headless) { - root.declaration(options); - if ((options.pubID != null) || (options.sysID != null)) { - root.doctype(options); + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 125) { + s3 = peg$c3; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c4); } + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c5(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; } + } else { + peg$currPos = s0; + s0 = peg$FAILED; } + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - XMLBuilder.prototype.root = function() { - return this.rootObject; - }; - - XMLBuilder.prototype.end = function(options) { - return this.toString(options); - }; - - XMLBuilder.prototype.toString = function(options) { - var indent, newline, offset, pretty, r, ref, ref1, ref2; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - r = ''; - if (this.xmldec != null) { - r += this.xmldec.toString(options); - } - if (this.doctype != null) { - r += this.doctype.toString(options); - } - r += this.rootObject.toString(options); - if (pretty && r.slice(-newline.length) === newline) { - r = r.slice(0, -newline.length); - } - return r; - }; - - return XMLBuilder; - - })(); - -}).call(this); + return s0; + } + function peg$parseEmptyBody() { + var s0, s1; -/***/ }, -/* 85 */ -/***/ function(module, exports, __webpack_require__) { + s0 = peg$currPos; + s1 = peg$parse_(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c6(); + } + s0 = s1; -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLDTDAttList, create; + return s0; + } - create = __webpack_require__(1); + function peg$parseAssignmentList() { + var s0, s1, s2, s3, s4, s5; - module.exports = XMLDTDAttList = (function() { - function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) { - this.stringify = parent.stringify; - if (elementName == null) { - throw new Error("Missing DTD element name"); - } - if (attributeName == null) { - throw new Error("Missing DTD attribute name"); - } - if (!attributeType) { - throw new Error("Missing DTD attribute type"); - } - if (!defaultValueType) { - throw new Error("Missing DTD attribute default"); + s0 = peg$currPos; + s1 = peg$parse_(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$parseAssignment(); + if (s4 === peg$FAILED) { + s4 = peg$parseDelimitedSection(); } - if (defaultValueType.indexOf('#') !== 0) { - defaultValueType = '#' + defaultValueType; + if (s4 !== peg$FAILED) { + s5 = peg$parse_(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; } - if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) { - throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT"); + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$parseAssignment(); + if (s4 === peg$FAILED) { + s4 = peg$parseDelimitedSection(); + } + if (s4 !== peg$FAILED) { + s5 = peg$parse_(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } + } else { + s2 = peg$FAILED; } - if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) { - throw new Error("Default value only applies to #FIXED or #DEFAULT"); + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c7(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - this.elementName = this.stringify.eleName(elementName); - this.attributeName = this.stringify.attName(attributeName); - this.attributeType = this.stringify.dtdAttType(attributeType); - this.defaultValue = this.stringify.dtdAttDefault(defaultValue); - this.defaultValueType = defaultValueType; + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - XMLDTDAttList.prototype.toString = function(options, level) { - var indent, newline, offset, pretty, r, ref, ref1, ref2, space; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - level || (level = 0); - space = new Array(level + offset + 1).join(indent); - r = ''; - if (pretty) { - r += space; - } - r += ''; - if (pretty) { - r += newline; - } - return r; - }; - - return XMLDTDAttList; - - })(); - -}).call(this); - + return s0; + } -/***/ }, -/* 86 */ -/***/ function(module, exports, __webpack_require__) { + function peg$parseAssignment() { + var s0; -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLDTDElement, create; + s0 = peg$parseSimpleAssignment(); + if (s0 === peg$FAILED) { + s0 = peg$parseCommentedAssignment(); + } - create = __webpack_require__(1); + return s0; + } - module.exports = XMLDTDElement = (function() { - function XMLDTDElement(parent, name, value) { - this.stringify = parent.stringify; - if (name == null) { - throw new Error("Missing DTD element name"); - } - if (!value) { - value = '(#PCDATA)'; - } - if (Array.isArray(value)) { - value = '(' + value.join(',') + ')'; - } - this.name = this.stringify.eleName(name); - this.value = this.stringify.dtdElementValue(value); - } + function peg$parseSimpleAssignment() { + var s0, s1, s2, s3, s4, s5, s6; - XMLDTDElement.prototype.toString = function(options, level) { - var indent, newline, offset, pretty, r, ref, ref1, ref2, space; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - level || (level = 0); - space = new Array(level + offset + 1).join(indent); - r = ''; - if (pretty) { - r += space; - } - r += ''; - if (pretty) { - r += newline; + s0 = peg$currPos; + s1 = peg$parseIdentifier(); + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 61) { + s3 = peg$c8; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c9); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + if (s4 !== peg$FAILED) { + s5 = peg$parseValue(); + if (s5 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 59) { + s6 = peg$c10; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c11); } + } + if (s6 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c12(s1, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - return r; - }; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } - return XMLDTDElement; + return s0; + } - })(); + function peg$parseCommentedAssignment() { + var s0, s1, s2, s3, s4, s5, s6; -}).call(this); + s0 = peg$currPos; + s1 = peg$parseCommentedIdentifier(); + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 61) { + s3 = peg$c8; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c9); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + if (s4 !== peg$FAILED) { + s5 = peg$parseValue(); + if (s5 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 59) { + s6 = peg$c10; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c11); } + } + if (s6 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c13(s1, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseIdentifier(); + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 61) { + s3 = peg$c8; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c9); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + if (s4 !== peg$FAILED) { + s5 = peg$parseCommentedValue(); + if (s5 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 59) { + s6 = peg$c10; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c11); } + } + if (s6 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c14(s1, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + return s0; + } -/***/ }, -/* 87 */ -/***/ function(module, exports, __webpack_require__) { + function peg$parseCommentedIdentifier() { + var s0, s1, s2, s3; -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLDTDEntity, create, isObject; + s0 = peg$currPos; + s1 = peg$parseIdentifier(); + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (s2 !== peg$FAILED) { + s3 = peg$parseInlineComment(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c15(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } - create = __webpack_require__(1); + return s0; + } - isObject = __webpack_require__(0); + function peg$parseCommentedValue() { + var s0, s1, s2, s3; - module.exports = XMLDTDEntity = (function() { - function XMLDTDEntity(parent, pe, name, value) { - this.stringify = parent.stringify; - if (name == null) { - throw new Error("Missing entity name"); - } - if (value == null) { - throw new Error("Missing entity value"); - } - this.pe = !!pe; - this.name = this.stringify.eleName(name); - if (!isObject(value)) { - this.value = this.stringify.dtdEntityValue(value); - } else { - if (!value.pubID && !value.sysID) { - throw new Error("Public and/or system identifiers are required for an external entity"); - } - if (value.pubID && !value.sysID) { - throw new Error("System identifier is required for a public external entity"); - } - if (value.pubID != null) { - this.pubID = this.stringify.dtdPubID(value.pubID); - } - if (value.sysID != null) { - this.sysID = this.stringify.dtdSysID(value.sysID); - } - if (value.nData != null) { - this.nData = this.stringify.dtdNData(value.nData); - } - if (this.pe && this.nData) { - throw new Error("Notation declaration is not allowed in a parameter entity"); + s0 = peg$currPos; + s1 = peg$parseValue(); + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (s2 !== peg$FAILED) { + s3 = peg$parseInlineComment(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c16(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; } + } else { + peg$currPos = s0; + s0 = peg$FAILED; } + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - XMLDTDEntity.prototype.toString = function(options, level) { - var indent, newline, offset, pretty, r, ref, ref1, ref2, space; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - level || (level = 0); - space = new Array(level + offset + 1).join(indent); - r = ''; - if (pretty) { - r += space; - } - r += ''; - if (pretty) { - r += newline; + if (s2 !== peg$FAILED) { + s3 = peg$parseInlineCommentClose(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c19(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - return r; - }; - - return XMLDTDEntity; - - })(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } -}).call(this); + return s0; + } + function peg$parseInlineCommentOpen() { + var s0; -/***/ }, -/* 88 */ -/***/ function(module, exports, __webpack_require__) { + if (input.substr(peg$currPos, 2) === peg$c20) { + s0 = peg$c20; + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c21); } + } -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLDTDNotation, create; + return s0; + } - create = __webpack_require__(1); + function peg$parseInlineCommentClose() { + var s0; - module.exports = XMLDTDNotation = (function() { - function XMLDTDNotation(parent, name, value) { - this.stringify = parent.stringify; - if (name == null) { - throw new Error("Missing notation name"); - } - if (!value.pubID && !value.sysID) { - throw new Error("Public or system identifiers are required for an external entity"); - } - this.name = this.stringify.eleName(name); - if (value.pubID != null) { - this.pubID = this.stringify.dtdPubID(value.pubID); - } - if (value.sysID != null) { - this.sysID = this.stringify.dtdSysID(value.sysID); - } + if (input.substr(peg$currPos, 2) === peg$c22) { + s0 = peg$c22; + peg$currPos += 2; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c23); } } - XMLDTDNotation.prototype.toString = function(options, level) { - var indent, newline, offset, pretty, r, ref, ref1, ref2, space; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - level || (level = 0); - space = new Array(level + offset + 1).join(indent); - r = ''; - if (pretty) { - r += space; - } - r += ''; - if (pretty) { - r += newline; - } - return r; - }; - - return XMLDTDNotation; - - })(); + return s0; + } -}).call(this); + function peg$parseDelimitedSection() { + var s0, s1, s2, s3, s4, s5; + s0 = peg$currPos; + s1 = peg$parseDelimitedSectionBegin(); + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (s2 !== peg$FAILED) { + s3 = peg$parseAssignmentList(); + if (s3 === peg$FAILED) { + s3 = peg$parseEmptyBody(); + } + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + if (s4 !== peg$FAILED) { + s5 = peg$parseDelimitedSectionEnd(); + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c24(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } -/***/ }, -/* 89 */ -/***/ function(module, exports, __webpack_require__) { + return s0; + } -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLNode, XMLRaw, create, - 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; + function peg$parseDelimitedSectionBegin() { + var s0, s1, s2, s3, s4; - create = __webpack_require__(1); + s0 = peg$currPos; + if (input.substr(peg$currPos, 9) === peg$c25) { + s1 = peg$c25; + peg$currPos += 9; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c26); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseIdentifier(); + if (s2 !== peg$FAILED) { + if (input.substr(peg$currPos, 11) === peg$c27) { + s3 = peg$c27; + peg$currPos += 11; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c28); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parseNewLine(); + if (s4 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c29(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } - XMLNode = __webpack_require__(8); + return s0; + } - module.exports = XMLRaw = (function(superClass) { - extend(XMLRaw, superClass); + function peg$parseDelimitedSectionEnd() { + var s0, s1, s2, s3, s4; - function XMLRaw(parent, text) { - XMLRaw.__super__.constructor.call(this, parent); - if (text == null) { - throw new Error("Missing raw text"); + s0 = peg$currPos; + if (input.substr(peg$currPos, 7) === peg$c30) { + s1 = peg$c30; + peg$currPos += 7; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c31); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseIdentifier(); + if (s2 !== peg$FAILED) { + if (input.substr(peg$currPos, 11) === peg$c27) { + s3 = peg$c27; + peg$currPos += 11; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c28); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parseNewLine(); + if (s4 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c29(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - this.value = this.stringify.raw(text); + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - XMLRaw.prototype.clone = function() { - return create(XMLRaw.prototype, this); - }; + return s0; + } - XMLRaw.prototype.toString = function(options, level) { - var indent, newline, offset, pretty, r, ref, ref1, ref2, space; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - level || (level = 0); - space = new Array(level + offset + 1).join(indent); - r = ''; - if (pretty) { - r += space; + function peg$parseArray() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 40) { + s1 = peg$c32; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c33); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseArrayBody(); + if (s2 === peg$FAILED) { + s2 = peg$parseEmptyArray(); } - r += this.value; - if (pretty) { - r += newline; + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 41) { + s3 = peg$c34; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c35); } + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c36(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - return r; - }; - - return XMLRaw; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } - })(XMLNode); + return s0; + } -}).call(this); + function peg$parseEmptyArray() { + var s0, s1; + s0 = peg$currPos; + s1 = peg$parse_(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c37(); + } + s0 = s1; -/***/ }, -/* 90 */ -/***/ function(module, exports) { + return s0; + } -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLStringifier, - bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - hasProp = {}.hasOwnProperty; + function peg$parseArrayBody() { + var s0, s1, s2, s3, s4, s5; - module.exports = XMLStringifier = (function() { - function XMLStringifier(options) { - this.assertLegalChar = bind(this.assertLegalChar, this); - var key, ref, value; - this.allowSurrogateChars = options != null ? options.allowSurrogateChars : void 0; - ref = (options != null ? options.stringify : void 0) || {}; - for (key in ref) { - if (!hasProp.call(ref, key)) continue; - value = ref[key]; - this[key] = value; + s0 = peg$currPos; + s1 = peg$parse_(); + if (s1 !== peg$FAILED) { + s2 = peg$parseArrayEntry(); + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + if (s3 !== peg$FAILED) { + s4 = peg$parseArrayBody(); + if (s4 === peg$FAILED) { + s4 = null; + } + if (s4 !== peg$FAILED) { + s5 = peg$parse_(); + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c38(s2, s4); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; } + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - XMLStringifier.prototype.eleName = function(val) { - val = '' + val || ''; - return this.assertLegalChar(val); - }; + return s0; + } - XMLStringifier.prototype.eleText = function(val) { - val = '' + val || ''; - return this.assertLegalChar(this.elEscape(val)); - }; + function peg$parseArrayEntry() { + var s0; - XMLStringifier.prototype.cdata = function(val) { - val = '' + val || ''; - if (val.match(/]]>/)) { - throw new Error("Invalid CDATA text: " + val); - } - return this.assertLegalChar(val); - }; + s0 = peg$parseSimpleArrayEntry(); + if (s0 === peg$FAILED) { + s0 = peg$parseCommentedArrayEntry(); + } - XMLStringifier.prototype.comment = function(val) { - val = '' + val || ''; - if (val.match(/--/)) { - throw new Error("Comment text cannot contain double-hypen: " + val); - } - return this.assertLegalChar(val); - }; + return s0; + } - XMLStringifier.prototype.raw = function(val) { - return '' + val || ''; - }; + function peg$parseSimpleArrayEntry() { + var s0, s1, s2; - XMLStringifier.prototype.attName = function(val) { - return '' + val || ''; - }; + s0 = peg$currPos; + s1 = peg$parseValue(); + if (s1 !== peg$FAILED) { + s2 = peg$parseEndArrayEntry(); + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c39(s1); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } - XMLStringifier.prototype.attValue = function(val) { - val = '' + val || ''; - return this.attEscape(val); - }; + return s0; + } - XMLStringifier.prototype.insTarget = function(val) { - return '' + val || ''; - }; + function peg$parseCommentedArrayEntry() { + var s0, s1, s2, s3, s4; - XMLStringifier.prototype.insValue = function(val) { - val = '' + val || ''; - if (val.match(/\?>/)) { - throw new Error("Invalid processing instruction value: " + val); + s0 = peg$currPos; + s1 = peg$parseValue(); + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (s2 !== peg$FAILED) { + s3 = peg$parseInlineComment(); + if (s3 !== peg$FAILED) { + s4 = peg$parseEndArrayEntry(); + if (s4 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c40(s1, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - return val; - }; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } - XMLStringifier.prototype.xmlVersion = function(val) { - val = '' + val || ''; - if (!val.match(/1\.[0-9]+/)) { - throw new Error("Invalid version number: " + val); - } - return val; - }; + return s0; + } - XMLStringifier.prototype.xmlEncoding = function(val) { - val = '' + val || ''; - if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-]|-)*$/)) { - throw new Error("Invalid encoding: " + val); - } - return val; - }; + function peg$parseEndArrayEntry() { + var s0, s1, s2, s3; - XMLStringifier.prototype.xmlStandalone = function(val) { - if (val) { - return "yes"; + if (input.charCodeAt(peg$currPos) === 44) { + s0 = peg$c41; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c42); } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parse_(); + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + if (input.charCodeAt(peg$currPos) === 41) { + s3 = peg$c34; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c35); } + } + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = void 0; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } } else { - return "no"; + peg$currPos = s0; + s0 = peg$FAILED; } - }; - - XMLStringifier.prototype.dtdPubID = function(val) { - return '' + val || ''; - }; - - XMLStringifier.prototype.dtdSysID = function(val) { - return '' + val || ''; - }; + } - XMLStringifier.prototype.dtdElementValue = function(val) { - return '' + val || ''; - }; + return s0; + } - XMLStringifier.prototype.dtdAttType = function(val) { - return '' + val || ''; - }; + function peg$parseIdentifier() { + var s0, s1, s2; - XMLStringifier.prototype.dtdAttDefault = function(val) { - if (val != null) { - return '' + val || ''; - } else { - return val; + s0 = peg$currPos; + s1 = []; + if (peg$c43.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c44); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + if (peg$c43.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c44); } + } } - }; + } else { + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c45(s1); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$parseQuotedString(); + } - XMLStringifier.prototype.dtdEntityValue = function(val) { - return '' + val || ''; - }; + return s0; + } - XMLStringifier.prototype.dtdNData = function(val) { - return '' + val || ''; - }; + function peg$parseValue() { + var s0; - XMLStringifier.prototype.convertAttKey = '@'; + s0 = peg$parseObject(); + if (s0 === peg$FAILED) { + s0 = peg$parseArray(); + if (s0 === peg$FAILED) { + s0 = peg$parseNumberValue(); + if (s0 === peg$FAILED) { + s0 = peg$parseStringValue(); + } + } + } - XMLStringifier.prototype.convertPIKey = '?'; + return s0; + } - XMLStringifier.prototype.convertTextKey = '#text'; + function peg$parseNumberValue() { + var s0; - XMLStringifier.prototype.convertCDataKey = '#cdata'; + s0 = peg$parseDecimalValue(); + if (s0 === peg$FAILED) { + s0 = peg$parseIntegerValue(); + } - XMLStringifier.prototype.convertCommentKey = '#comment'; + return s0; + } - XMLStringifier.prototype.convertRawKey = '#raw'; + function peg$parseDecimalValue() { + var s0, s1, s2, s3, s4; - XMLStringifier.prototype.assertLegalChar = function(str) { - var chars, chr; - if (this.allowSurrogateChars) { - chars = /[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uFFFE-\uFFFF]/; + s0 = peg$currPos; + s1 = peg$currPos; + s2 = peg$parseIntegerValue(); + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s3 = peg$c46; + peg$currPos++; } else { - chars = /[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE-\uFFFF]/; + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c47); } } - chr = str.match(chars); - if (chr) { - throw new Error("Invalid character (" + chr + ") in string: " + str + " at index " + chr.index); + if (s3 !== peg$FAILED) { + s4 = peg$parseIntegerValue(); + if (s4 !== peg$FAILED) { + s2 = [s2, s3, s4]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; } - return str; - }; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c48(s1); + } + s0 = s1; - XMLStringifier.prototype.elEscape = function(str) { - return str.replace(/&/g, '&').replace(//g, '>').replace(/\r/g, ' '); - }; + return s0; + } - XMLStringifier.prototype.attEscape = function(str) { - return str.replace(/&/g, '&').replace(/ peg$currPos) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c52); } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c53(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; } - return r; - }; - - return XMLText; + } - })(XMLNode); + return s0; + } -}).call(this); + function peg$parseEscapedQuote() { + var s0, s1, s2; + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 92) { + s1 = peg$c54; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c55); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseDoubleQuote(); + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c56(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } -/***/ }, -/* 92 */ -/***/ function(module, exports, __webpack_require__) { + return s0; + } -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLBuilder, assign; + function peg$parseLiteralString() { + var s0, s1, s2; - assign = __webpack_require__(79); + s0 = peg$currPos; + s1 = []; + s2 = peg$parseLiteralChar(); + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$parseLiteralChar(); + } + } else { + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c57(s1); + } + s0 = s1; - XMLBuilder = __webpack_require__(84); + return s0; + } - module.exports.create = function(name, xmldec, doctype, options) { - options = assign({}, xmldec, doctype, options); - return new XMLBuilder(name, options).root(); - }; + function peg$parseLiteralChar() { + var s0, s1, s2, s3; -}).call(this); + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + s2 = peg$parseInlineCommentOpen(); + peg$silentFails--; + if (s2 === peg$FAILED) { + s1 = void 0; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parseLineTerminator(); + peg$silentFails--; + if (s3 === peg$FAILED) { + s2 = void 0; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + s3 = peg$parseNonTerminator(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c53(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + return s0; + } -/***/ }, -/* 93 */ -/***/ function(module, exports, __webpack_require__) { + function peg$parseNonTerminator() { + var s0; -var bplistParser = __webpack_require__(42), - bplistCreator = __webpack_require__(41), - plist = __webpack_require__(45), - fs = __webpack_require__(9); + if (peg$c58.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c59); } + } -// reveal the underlying modules -exports.plist = plist; -exports.bplistCreator = bplistCreator; -exports.bplistParser = bplistParser; + return s0; + } + function peg$parseSingleLineComment() { + var s0, s1, s2, s3, s4; -// Parses the given file and returns its contents as a native JavaScript -// object. -exports.readFileSync = function(aFile) { - var contents = fs.readFileSync(aFile); + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c60) { + s1 = peg$c60; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c61); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (s2 !== peg$FAILED) { + s3 = peg$parseOneLineString(); + if (s3 !== peg$FAILED) { + s4 = peg$parseNewLine(); + if (s4 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c62(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } - if (contents.length === 0) { - console.error("Unable to read file '%s'", aFile); - return {}; + return s0; } - return exports.parse(contents, aFile); -}; -exports.readFile = function(aFile, callback) { - var results; + function peg$parseOneLineString() { + var s0, s1, s2; - fs.readFile(aFile, function(err, contents){ - if (err) { - callback(err); + s0 = peg$currPos; + s1 = []; + s2 = peg$parseNonLine(); + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$parseNonLine(); } - else { - try { - results = exports.parse(contents, aFile); - callback(null,results); - } - catch(err) { - callback(err); - } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c63(s1); } - }); -} - -exports.writeFileSync = function(aFile, anObject, options) { - var data = plist.build(anObject); - fs.writeFileSync(aFile, data, options); -}; + s0 = s1; -exports.writeFile = function(aFile, anObject, options, callback) { - if (arguments.length === 3 && typeof options === 'function') { - callback = options; - options = undefined; + return s0; } - var data = plist.build(anObject); - fs.writeFile(aFile, data, options, callback); -}; -exports.writeBinaryFileSync = function(aFile, anObject, options) { - var data = bplistCreator(anObject); - fs.writeFileSync(aFile, data, options); -}; + function peg$parseDigit() { + var s0; -exports.writeBinaryFile = function(aFile, anObject, options, callback) { - if (arguments.length === 3 && typeof options === 'function') { - callback = options; - options = undefined; + if (peg$c64.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c65); } + } + + return s0; } - var data = bplistCreator(anObject); - fs.writeFile(aFile, data, options, callback); -}; + function peg$parseAlpha() { + var s0; -exports.stringify = function(anObject) { - return plist.build(anObject); -}; + if (peg$c66.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c67); } + } + return s0; + } + function peg$parseDoubleQuote() { + var s0; -exports.parse = function(aStringOrBuffer, aFile) { - var results, - firstByte = aStringOrBuffer[0]; - try { - if (firstByte === 60 || firstByte === '<') { - results = plist.parse(aStringOrBuffer.toString()); + if (input.charCodeAt(peg$currPos) === 34) { + s0 = peg$c68; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c69); } } - else if (firstByte === 98) { - results = bplistParser.parseBuffer(aStringOrBuffer)[0]; + + return s0; + } + + function peg$parse_() { + var s0, s1; + + peg$silentFails++; + s0 = []; + s1 = peg$parsewhitespace(); + while (s1 !== peg$FAILED) { + s0.push(s1); + s1 = peg$parsewhitespace(); } - else { - if (aFile != undefined) { - console.error("Unable to determine format for '%s'", aFile); - } - else { - console.error("Unable to determine format for plist aStringOrBuffer: '%s'", aStringOrBuffer); - } - results = {}; + peg$silentFails--; + if (s0 === peg$FAILED) { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c70); } } - } - catch(e) { - throw Error("'%s' has errors", aFile); - } - return results; -} + return s0; + } -/***/ }, -/* 94 */ -/***/ function(module, exports, __webpack_require__) { + function peg$parsewhitespace() { + var s0; -var stream = __webpack_require__(39), - constants = __webpack_require__(16), - util = __webpack_require__(5); - -var ReadableStreamBuffer = module.exports = function(opts) { - var that = this; - - stream.Stream.call(this); - - opts = opts || {}; - var frequency = opts.hasOwnProperty("frequency") ? opts.frequency : constants.DEFAULT_FREQUENCY; - var chunkSize = opts.chunkSize || constants.DEFAULT_CHUNK_SIZE; - var initialSize = opts.initialSize || constants.DEFAULT_INITIAL_SIZE; - var incrementAmount = opts.incrementAmount || constants.DEFAULT_INCREMENT_AMOUNT; - - var size = 0; - var buffer = new Buffer(initialSize); - var encoding = null; - - this.readable = true; - this.writable = false; - - var sendData = function() { - if(!size) { - that.emit("end"); - return; - } - - var amount = Math.min(chunkSize, size); - var chunk = null; - if(encoding) { - chunk = buffer.toString(encoding, 0, amount); - } - else { - chunk = new Buffer(amount); - buffer.copy(chunk, 0, 0, amount); - } - - that.emit("data", chunk); - - if(amount < buffer.length) - buffer.copy(buffer, 0, amount, size); - size -= amount; - }; - - this.size = function() { - return size; - }; - - this.maxSize = function() { - return buffer.length; - }; - - var increaseBufferIfNecessary = function(incomingDataSize) { - if((buffer.length - size) < incomingDataSize) { - var factor = Math.ceil((incomingDataSize - (buffer.length - size)) / incrementAmount); - - var newBuffer = new Buffer(buffer.length + (incrementAmount * factor)); - buffer.copy(newBuffer, 0, 0, size); - buffer = newBuffer; - } - }; - - this.put = function(data, encoding) { - if(!that.readable) return; - - if(Buffer.isBuffer(data)) { - increaseBufferIfNecessary(data.length); - data.copy(buffer, size, 0); - size += data.length; - } - else { - data = data + ""; - var dataSizeInBytes = Buffer.byteLength(data); - increaseBufferIfNecessary(dataSizeInBytes); - buffer.write(data, size, encoding || "utf8"); - size += dataSizeInBytes; - } - - if (!this.isPaused && !frequency) { - while (size > 0) { - sendData(); - } - } - }; - - this.pause = function() { - this.isPaused = true; - if(sendData && sendData.interval) { - clearInterval(sendData.interval); - delete sendData.interval; - } - }; - - this.resume = function() { - this.isPaused = false; - if(sendData && !sendData.interval && frequency > 0) { - sendData.interval = setInterval(sendData, frequency); - } - }; - - this.destroy = function() { - that.emit("end"); - if(sendData.interval) clearTimeout(sendData.interval); - sendData = null; - that.readable = false; - that.emit("close"); - }; - - this.setEncoding = function(_encoding) { - encoding = _encoding; - }; - - this.resume(); -}; -util.inherits(ReadableStreamBuffer, stream.Stream); + s0 = peg$parseNewLine(); + if (s0 === peg$FAILED) { + if (peg$c71.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c72); } + } + } + return s0; + } -/***/ }, -/* 95 */ -/***/ function(module, exports, __webpack_require__) { + function peg$parseNonLine() { + var s0, s1, s2; -module.exports = __webpack_require__(16); -module.exports.ReadableStreamBuffer = __webpack_require__(94); -module.exports.WritableStreamBuffer = __webpack_require__(96); + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + s2 = peg$parseNewLine(); + peg$silentFails--; + if (s2 === peg$FAILED) { + s1 = void 0; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + s2 = peg$parseChar(); + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c53(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + return s0; + } -/***/ }, -/* 96 */ -/***/ function(module, exports, __webpack_require__) { + function peg$parseLineTerminator() { + var s0; -var util = __webpack_require__(5), - stream = __webpack_require__(39), - constants = __webpack_require__(16); - -// TODO: clear up specs on returning false from a write and emitting a drain event. -// Does this mean if I return false from a write, I should ignore any write requests between that false return and the drain event? -var WritableStreamBuffer = module.exports = function(opts) { - var that = this; - - stream.Stream.call(this); - - opts = opts || {}; - var initialSize = opts.initialSize || constants.DEFAULT_INITIAL_SIZE; - var incrementAmount = opts.incrementAmount || constants.DEFAULT_INCREMENT_AMOUNT; - - var buffer = new Buffer(initialSize); - var size = 0; - - this.writable = true; - this.readable = false; - - this.size = function() { - return size; - }; - - this.maxSize = function() { - return buffer.length; - }; - - this.getContents = function(length) { - if(!size) return false; - - var data = new Buffer(Math.min(length || size, size)); - buffer.copy(data, 0, 0, data.length); - - if(data.length < size) - buffer.copy(buffer, 0, data.length); - - size -= data.length; - - return data; - }; - - this.getContentsAsString = function(encoding, length) { - if(!size) return false; - - var data = buffer.toString(encoding || "utf8", 0, Math.min(length || size, size)); - var dataLength = Buffer.byteLength(data); - - if(dataLength < size) - buffer.copy(buffer, 0, dataLength); - - size -= dataLength; - return data; - }; - - var increaseBufferIfNecessary = function(incomingDataSize) { - if((buffer.length - size) < incomingDataSize) { - var factor = Math.ceil((incomingDataSize - (buffer.length - size)) / incrementAmount); - - var newBuffer = new Buffer(buffer.length + (incrementAmount * factor)); - buffer.copy(newBuffer, 0, 0, size); - buffer = newBuffer; - } - }; - - this.write = function(data, encoding) { - if(!that.writable) return; - - if(Buffer.isBuffer(data)) { - increaseBufferIfNecessary(data.length); - data.copy(buffer, size, 0); - size += data.length; - } - else { - data = data + ""; - increaseBufferIfNecessary(data.length); - buffer.write(data, size, encoding || "utf8"); - size += Buffer.byteLength(data); - } - }; - - this.end = function() { - var args = Array.prototype.slice.apply(arguments); - if(args.length) that.write.apply(that, args); - that.destroy(); - }; - - this.destroySoon = this.destroy = function() { - that.writable = false; - that.emit("close"); - }; -}; -util.inherits(WritableStreamBuffer, stream.Stream); + s0 = peg$parseNewLine(); + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 59) { + s0 = peg$c10; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c11); } + } + } + return s0; + } -/***/ }, -/* 97 */ -/***/ function(module, exports, __webpack_require__) { + function peg$parseNewLine() { + var s0; -"use strict"; -/* - * Generated by PEG.js 0.10.0. - * - * http://pegjs.org/ - */ + if (peg$c73.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c74); } + } + + return s0; + } + function peg$parseChar() { + var s0; + if (input.length > peg$currPos) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c52); } + } -function peg$subclass(child, parent) { - function ctor() { this.constructor = child; } - ctor.prototype = parent.prototype; - child.prototype = new ctor(); + return s0; + } + + + function merge_obj(obj, secondObj) { + if (!obj) + return secondObj; + + for(var i in secondObj) + obj[i] = merge_obj(obj[i], secondObj[i]); + + return obj; + } + + + peg$result = peg$startRuleFunction(); + + if (peg$result !== peg$FAILED && peg$currPos === input.length) { + return peg$result; + } else { + if (peg$result !== peg$FAILED && peg$currPos < input.length) { + peg$fail(peg$endExpectation()); + } + + throw peg$buildStructuredError( + peg$maxFailExpected, + peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, + peg$maxFailPos < input.length + ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) + : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) + ); + } } -function peg$SyntaxError(message, expected, found, location) { - this.message = message; - this.expected = expected; - this.found = found; - this.location = location; - this.name = "SyntaxError"; +module.exports = { + SyntaxError: peg$SyntaxError, + parse: peg$parse +}; + + +/***/ }), +/* 53 */ +/***/ (function(module, exports, __webpack_require__) { + +var path = __webpack_require__(12), + util = __webpack_require__(5); + +var DEFAULT_SOURCETREE = '""', + DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR', + DEFAULT_FILEENCODING = 4, + DEFAULT_GROUP = 'Resources', + DEFAULT_FILETYPE = 'unknown'; + +var FILETYPE_BY_EXTENSION = { + a: 'archive.ar', + app: 'wrapper.application', + appex: 'wrapper.app-extension', + bundle: 'wrapper.plug-in', + dylib: 'compiled.mach-o.dylib', + framework: 'wrapper.framework', + h: 'sourcecode.c.h', + m: 'sourcecode.c.objc', + markdown: 'text', + mdimporter: 'wrapper.cfbundle', + octest: 'wrapper.cfbundle', + pch: 'sourcecode.c.h', + plist: 'text.plist.xml', + sh: 'text.script.sh', + swift: 'sourcecode.swift', + tbd: 'sourcecode.text-based-dylib-definition', + xcassets: 'folder.assetcatalog', + xcconfig: 'text.xcconfig', + xcdatamodel: 'wrapper.xcdatamodel', + xcodeproj: 'wrapper.pb-project', + xctest: 'wrapper.cfbundle', + xib: 'file.xib', + strings: 'text.plist.strings' + }, + GROUP_BY_FILETYPE = { + 'archive.ar': 'Frameworks', + 'compiled.mach-o.dylib': 'Frameworks', + 'sourcecode.text-based-dylib-definition': 'Frameworks', + 'wrapper.framework': 'Frameworks', + 'embedded.framework': 'Embed Frameworks', + 'sourcecode.c.h': 'Resources', + 'sourcecode.c.objc': 'Sources', + 'sourcecode.swift': 'Sources' + }, + PATH_BY_FILETYPE = { + 'compiled.mach-o.dylib': 'usr/lib/', + 'sourcecode.text-based-dylib-definition': 'usr/lib/', + 'wrapper.framework': 'System/Library/Frameworks/' + }, + SOURCETREE_BY_FILETYPE = { + 'compiled.mach-o.dylib': 'SDKROOT', + 'sourcecode.text-based-dylib-definition': 'SDKROOT', + 'wrapper.framework': 'SDKROOT' + }, + ENCODING_BY_FILETYPE = { + 'sourcecode.c.h': 4, + 'sourcecode.c.h': 4, + 'sourcecode.c.objc': 4, + 'sourcecode.swift': 4, + 'text': 4, + 'text.plist.xml': 4, + 'text.script.sh': 4, + 'text.xcconfig': 4, + 'text.plist.strings': 4 + }; + - if (typeof Error.captureStackTrace === "function") { - Error.captureStackTrace(this, peg$SyntaxError); - } +function unquoted(text){ + return text.replace (/(^")|("$)/g, '') } -peg$subclass(peg$SyntaxError, Error); - -peg$SyntaxError.buildMessage = function(expected, found) { - var DESCRIBE_EXPECTATION_FNS = { - literal: function(expectation) { - return "\"" + literalEscape(expectation.text) + "\""; - }, - - "class": function(expectation) { - var escapedParts = "", - i; - - for (i = 0; i < expectation.parts.length; i++) { - escapedParts += expectation.parts[i] instanceof Array - ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) - : classEscape(expectation.parts[i]); - } +function detectType(filePath) { + var extension = path.extname(filePath).substring(1), + filetype = FILETYPE_BY_EXTENSION[unquoted(extension)]; - return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; - }, + if (!filetype) { + return DEFAULT_FILETYPE; + } - any: function(expectation) { - return "any character"; - }, + return filetype; +} - end: function(expectation) { - return "end of input"; - }, +function defaultExtension(fileRef) { + var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; - other: function(expectation) { - return expectation.description; + for(var extension in FILETYPE_BY_EXTENSION) { + if(FILETYPE_BY_EXTENSION.hasOwnProperty(unquoted(extension)) ) { + if(FILETYPE_BY_EXTENSION[unquoted(extension)] === filetype ) + return extension; } - }; - - function hex(ch) { - return ch.charCodeAt(0).toString(16).toUpperCase(); - } - - function literalEscape(s) { - return s - .replace(/\\/g, '\\\\') - .replace(/"/g, '\\"') - .replace(/\0/g, '\\0') - .replace(/\t/g, '\\t') - .replace(/\n/g, '\\n') - .replace(/\r/g, '\\r') - .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) - .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); - } - - function classEscape(s) { - return s - .replace(/\\/g, '\\\\') - .replace(/\]/g, '\\]') - .replace(/\^/g, '\\^') - .replace(/-/g, '\\-') - .replace(/\0/g, '\\0') - .replace(/\t/g, '\\t') - .replace(/\n/g, '\\n') - .replace(/\r/g, '\\r') - .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) - .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); - } - - function describeExpectation(expectation) { - return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); - } + } +} - function describeExpected(expected) { - var descriptions = new Array(expected.length), - i, j; +function defaultEncoding(fileRef) { + var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, + encoding = ENCODING_BY_FILETYPE[unquoted(filetype)]; - for (i = 0; i < expected.length; i++) { - descriptions[i] = describeExpectation(expected[i]); + if (encoding) { + return encoding; } +} - descriptions.sort(); +function detectGroup(fileRef, opt) { + var extension = path.extname(fileRef.basename).substring(1), + filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, + groupName = GROUP_BY_FILETYPE[unquoted(filetype)]; - if (descriptions.length > 0) { - for (i = 1, j = 1; i < descriptions.length; i++) { - if (descriptions[i - 1] !== descriptions[i]) { - descriptions[j] = descriptions[i]; - j++; - } - } - descriptions.length = j; + if (extension === 'xcdatamodeld') { + return 'Sources'; } - switch (descriptions.length) { - case 1: - return descriptions[0]; - - case 2: - return descriptions[0] + " or " + descriptions[1]; + if (opt.customFramework && opt.embed) { + return GROUP_BY_FILETYPE['embedded.framework']; + } - default: - return descriptions.slice(0, -1).join(", ") - + ", or " - + descriptions[descriptions.length - 1]; + if (!groupName) { + return DEFAULT_GROUP; } - } - function describeFound(found) { - return found ? "\"" + literalEscape(found) + "\"" : "end of input"; - } + return groupName; +} - return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; -}; +function detectSourcetree(fileRef) { -function peg$parse(input, options) { - options = options !== void 0 ? options : {}; + var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, + sourcetree = SOURCETREE_BY_FILETYPE[unquoted(filetype)]; - var peg$FAILED = {}, + if (fileRef.explicitFileType) { + return DEFAULT_PRODUCT_SOURCETREE; + } - peg$startRuleFunctions = { Project: peg$parseProject }, - peg$startRuleFunction = peg$parseProject, + if (fileRef.customFramework) { + return DEFAULT_SOURCETREE; + } - peg$c0 = function(headComment, obj) { - var proj = Object.create(null) - proj.project = obj + if (!sourcetree) { + return DEFAULT_SOURCETREE; + } - if (headComment) { - proj.headComment = headComment - } + return sourcetree; +} - return proj; - }, - peg$c1 = "{", - peg$c2 = peg$literalExpectation("{", false), - peg$c3 = "}", - peg$c4 = peg$literalExpectation("}", false), - peg$c5 = function(obj) { return obj }, - peg$c6 = function() { return Object.create(null) }, - peg$c7 = function(list) { - var returnObject = list[0][0]; - for(var i = 1; i < list.length; i++){ - var another = list[i][0]; - returnObject = merge_obj(returnObject, another); - } - return returnObject; - }, - peg$c8 = "=", - peg$c9 = peg$literalExpectation("=", false), - peg$c10 = ";", - peg$c11 = peg$literalExpectation(";", false), - peg$c12 = function(id, val) { - var result = Object.create(null); - result[id] = val - return result - }, - peg$c13 = function(commentedId, val) { - var result = Object.create(null), - commentKey = commentedId.id + '_comment'; +function defaultPath(fileRef, filePath) { + var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, + defaultPath = PATH_BY_FILETYPE[unquoted(filetype)]; - result[commentedId.id] = val; - result[commentKey] = commentedId[commentKey]; - return result; + if (fileRef.customFramework) { + return filePath; + } - }, - peg$c14 = function(id, commentedVal) { - var result = Object.create(null); - result[id] = commentedVal.value; - result[id + "_comment"] = commentedVal.comment; - return result; - }, - peg$c15 = function(id, comment) { - var result = Object.create(null); - result.id = id; - result[id + "_comment"] = comment.trim(); - return result - }, - peg$c16 = function(literal, comment) { - var result = Object.create(null) - result.comment = comment.trim(); - result.value = literal.trim(); - return result; - }, - peg$c17 = /^[^*]/, - peg$c18 = peg$classExpectation(["*"], true, false), - peg$c19 = function(body) { return body.join('') }, - peg$c20 = "/*", - peg$c21 = peg$literalExpectation("/*", false), - peg$c22 = "*/", - peg$c23 = peg$literalExpectation("*/", false), - peg$c24 = function(begin, fields) { - var section = Object.create(null); - section[begin.name] = fields + if (defaultPath) { + return path.join(defaultPath, path.basename(filePath)); + } - return section - }, - peg$c25 = "/* Begin ", - peg$c26 = peg$literalExpectation("/* Begin ", false), - peg$c27 = " section */", - peg$c28 = peg$literalExpectation(" section */", false), - peg$c29 = function(sectionName) { return { name: sectionName } }, - peg$c30 = "/* End ", - peg$c31 = peg$literalExpectation("/* End ", false), - peg$c32 = "(", - peg$c33 = peg$literalExpectation("(", false), - peg$c34 = ")", - peg$c35 = peg$literalExpectation(")", false), - peg$c36 = function(arr) { return arr }, - peg$c37 = function() { return [] }, - peg$c38 = function(head, tail) { - if (tail) { - tail.unshift(head); - return tail; - } else { - return [head]; - } - }, - peg$c39 = function(val) { return val }, - peg$c40 = function(val, comment) { - var result = Object.create(null); - result.value = val.trim(); - result.comment = comment.trim(); - return result; - }, - peg$c41 = ",", - peg$c42 = peg$literalExpectation(",", false), - peg$c43 = /^[A-Za-z0-9_.]/, - peg$c44 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], "_", "."], false, false), - peg$c45 = function(id) { return id.join('') }, - peg$c46 = ".", - peg$c47 = peg$literalExpectation(".", false), - peg$c48 = function(decimal) { - // store decimals as strings - // as JS doesn't differentiate bw strings and numbers - return decimal.join('') - }, - peg$c49 = function(number) { return parseInt(number.join(''), 10) }, - peg$c50 = function(str) { return '"' + str + '"' }, - peg$c51 = function(str) { return str.join('') }, - peg$c52 = peg$anyExpectation(), - peg$c53 = function(char) { return char }, - peg$c54 = "\\", - peg$c55 = peg$literalExpectation("\\", false), - peg$c56 = function() { return '\\"' }, - peg$c57 = function(literal) { return literal.join('') }, - peg$c58 = /^[^;,\n]/, - peg$c59 = peg$classExpectation([";", ",", "\n"], true, false), - peg$c60 = "//", - peg$c61 = peg$literalExpectation("//", false), - peg$c62 = function(contents) { return contents }, - peg$c63 = function(contents) { return contents.join('') }, - peg$c64 = /^[0-9]/, - peg$c65 = peg$classExpectation([["0", "9"]], false, false), - peg$c66 = /^[A-Za-z]/, - peg$c67 = peg$classExpectation([["A", "Z"], ["a", "z"]], false, false), - peg$c68 = "\"", - peg$c69 = peg$literalExpectation("\"", false), - peg$c70 = peg$otherExpectation("whitespace"), - peg$c71 = /^[\t ]/, - peg$c72 = peg$classExpectation(["\t", " "], false, false), - peg$c73 = /^[\n\r]/, - peg$c74 = peg$classExpectation(["\n", "\r"], false, false), + return filePath; +} - peg$currPos = 0, - peg$savedPos = 0, - peg$posDetailsCache = [{ line: 1, column: 1 }], - peg$maxFailPos = 0, - peg$maxFailExpected = [], - peg$silentFails = 0, +function defaultGroup(fileRef) { + var groupName = GROUP_BY_FILETYPE[fileRef.lastKnownFileType]; - peg$result; + if (!groupName) { + return DEFAULT_GROUP; + } - if ("startRule" in options) { - if (!(options.startRule in peg$startRuleFunctions)) { - throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); + return defaultGroup; +} + +function pbxFile(filepath, opt) { + var opt = opt || {}; + + this.basename = path.basename(filepath); + this.lastKnownFileType = opt.lastKnownFileType || detectType(filepath); + this.group = detectGroup(this, opt); + + // for custom frameworks + if (opt.customFramework == true) { + this.customFramework = true; + this.dirname = path.dirname(filepath).replace(/\\/g, '/'); } - peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; - } + this.path = defaultPath(this, filepath).replace(/\\/g, '/'); + this.fileEncoding = this.defaultEncoding = opt.defaultEncoding || defaultEncoding(this); - function text() { - return input.substring(peg$savedPos, peg$currPos); - } + // When referencing products / build output files + if (opt.explicitFileType) { + this.explicitFileType = opt.explicitFileType; + this.basename = this.basename + '.' + defaultExtension(this); + delete this.path; + delete this.lastKnownFileType; + delete this.group; + delete this.defaultEncoding; + } - function location() { - return peg$computeLocation(peg$savedPos, peg$currPos); - } + this.sourceTree = opt.sourceTree || detectSourcetree(this); + this.includeInIndex = 0; - function expected(description, location) { - location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) + if (opt.weak && opt.weak === true) + this.settings = { ATTRIBUTES: ['Weak'] }; - throw peg$buildStructuredError( - [peg$otherExpectation(description)], - input.substring(peg$savedPos, peg$currPos), - location - ); - } + if (opt.compilerFlags) { + if (!this.settings) + this.settings = {}; + this.settings.COMPILER_FLAGS = util.format('"%s"', opt.compilerFlags); + } - function error(message, location) { - location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) + if (opt.embed && opt.sign) { + if (!this.settings) + this.settings = {}; + if (!this.settings.ATTRIBUTES) + this.settings.ATTRIBUTES = []; + this.settings.ATTRIBUTES.push('CodeSignOnCopy'); + } +} - throw peg$buildSimpleError(message, location); - } +module.exports = pbxFile; - function peg$literalExpectation(text, ignoreCase) { - return { type: "literal", text: text, ignoreCase: ignoreCase }; - } - function peg$classExpectation(parts, inverted, ignoreCase) { - return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; - } +/***/ }), +/* 54 */ +/***/ (function(module, exports, __webpack_require__) { - function peg$anyExpectation() { - return { type: "any" }; - } +var pbxProj = __webpack_require__(19), + util = __webpack_require__(5), + f = util.format, + INDENT = '\t', + COMMENT_KEY = /_comment$/, + QUOTED = /^"(.*)"$/, + EventEmitter = __webpack_require__(38).EventEmitter - function peg$endExpectation() { - return { type: "end" }; - } +// indentation +function i(x) { + if (x <=0) + return ''; + else + return INDENT + i(x-1); +} - function peg$otherExpectation(description) { - return { type: "other", description: description }; - } +function comment(key, parent) { + var text = parent[key + '_comment']; - function peg$computePosDetails(pos) { - var details = peg$posDetailsCache[pos], p; + if (text) + return text; + else + return null; +} - if (details) { - return details; - } else { - p = pos - 1; - while (!peg$posDetailsCache[p]) { - p--; - } +// copied from underscore +function isObject(obj) { + return obj === Object(obj) +} - details = peg$posDetailsCache[p]; - details = { - line: details.line, - column: details.column - }; +function isArray(obj) { + return Array.isArray(obj) +} - while (p < pos) { - if (input.charCodeAt(p) === 10) { - details.line++; - details.column = 1; - } else { - details.column++; - } +function pbxWriter(contents) { + this.contents = contents; + this.sync = false; + this.indentLevel = 0; +} - p++; - } +util.inherits(pbxWriter, EventEmitter); - peg$posDetailsCache[pos] = details; - return details; +pbxWriter.prototype.write = function (str) { + var fmt = f.apply(null, arguments); + + if (this.sync) { + this.buffer += f("%s%s", i(this.indentLevel), fmt); + } else { + // do stream write } - } +} - function peg$computeLocation(startPos, endPos) { - var startPosDetails = peg$computePosDetails(startPos), - endPosDetails = peg$computePosDetails(endPos); +pbxWriter.prototype.writeFlush = function (str) { + var oldIndent = this.indentLevel; - return { - start: { - offset: startPos, - line: startPosDetails.line, - column: startPosDetails.column - }, - end: { - offset: endPos, - line: endPosDetails.line, - column: endPosDetails.column - } - }; - } + this.indentLevel = 0; + + this.write.apply(this, arguments) + + this.indentLevel = oldIndent; +} - function peg$fail(expected) { - if (peg$currPos < peg$maxFailPos) { return; } +pbxWriter.prototype.writeSync = function () { + this.sync = true; + this.buffer = ""; - if (peg$currPos > peg$maxFailPos) { - peg$maxFailPos = peg$currPos; - peg$maxFailExpected = []; + this.writeHeadComment(); + this.writeProject(); + + return this.buffer; +} + +pbxWriter.prototype.writeHeadComment = function () { + if (this.contents.headComment) { + this.write("// %s\n", this.contents.headComment) } +} - peg$maxFailExpected.push(expected); - } +pbxWriter.prototype.writeProject = function () { + var proj = this.contents.project, + key, cmt, obj; - function peg$buildSimpleError(message, location) { - return new peg$SyntaxError(message, null, null, location); - } + this.write("{\n") - function peg$buildStructuredError(expected, found, location) { - return new peg$SyntaxError( - peg$SyntaxError.buildMessage(expected, found), - expected, - found, - location - ); - } + if (proj) { + this.indentLevel++; - function peg$parseProject() { - var s0, s1, s2, s3, s4, s5, s6; + for (key in proj) { + // skip comments + if (COMMENT_KEY.test(key)) continue; - s0 = peg$currPos; - s1 = peg$parseSingleLineComment(); - if (s1 === peg$FAILED) { - s1 = null; - } - if (s1 !== peg$FAILED) { - s2 = peg$parseInlineComment(); - if (s2 === peg$FAILED) { - s2 = null; - } - if (s2 !== peg$FAILED) { - s3 = peg$parse_(); - if (s3 !== peg$FAILED) { - s4 = peg$parseObject(); - if (s4 !== peg$FAILED) { - s5 = peg$parseNewLine(); - if (s5 !== peg$FAILED) { - s6 = peg$parse_(); - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c0(s1, s4); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + cmt = comment(key, proj); + obj = proj[key]; - return s0; - } + if (isArray(obj)) { + this.writeArray(obj, key) + } else if (isObject(obj)) { + this.write("%s = {\n", key); + this.indentLevel++; - function peg$parseObject() { - var s0, s1, s2, s3; + if (key === 'objects') { + this.writeObjectsSections(obj) + } else { + this.writeObject(obj) + } - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 123) { - s1 = peg$c1; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c2); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseAssignmentList(); - if (s2 === peg$FAILED) { - s2 = peg$parseEmptyBody(); - } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 125) { - s3 = peg$c3; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c4); } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c5(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; + this.indentLevel--; + this.write("};\n"); + } else if (cmt) { + this.write("%s = %s /* %s */;\n", key, obj, cmt) + } else { + this.write("%s = %s;\n", key, obj) + } } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + + this.indentLevel--; } - return s0; - } + this.write("}\n") +} - function peg$parseEmptyBody() { - var s0, s1; +pbxWriter.prototype.writeObject = function (object) { + var key, obj, cmt; - s0 = peg$currPos; - s1 = peg$parse_(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c6(); - } - s0 = s1; + for (key in object) { + if (COMMENT_KEY.test(key)) continue; - return s0; - } + cmt = comment(key, object); + obj = object[key]; - function peg$parseAssignmentList() { - var s0, s1, s2, s3, s4, s5; + if (isArray(obj)) { + this.writeArray(obj, key) + } else if (isObject(obj)) { + this.write("%s = {\n", key); + this.indentLevel++; - s0 = peg$currPos; - s1 = peg$parse_(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parseAssignment(); - if (s4 === peg$FAILED) { - s4 = peg$parseDelimitedSection(); - } - if (s4 !== peg$FAILED) { - s5 = peg$parse_(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; + this.writeObject(obj) + + this.indentLevel--; + this.write("};\n"); } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parseAssignment(); - if (s4 === peg$FAILED) { - s4 = peg$parseDelimitedSection(); - } - if (s4 !== peg$FAILED) { - s5 = peg$parse_(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; + if (cmt) { + this.write("%s = %s /* %s */;\n", key, obj, cmt) } else { - peg$currPos = s3; - s3 = peg$FAILED; + this.write("%s = %s;\n", key, obj) } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c7(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; } +} + +pbxWriter.prototype.writeObjectsSections = function (objects) { + var first = true, + key, obj; + + for (key in objects) { + if (!first) { + this.writeFlush("\n") + } else { + first = false; + } + + obj = objects[key]; + + if (isObject(obj)) { + this.writeSectionComment(key, true); + + this.writeSection(obj); + + this.writeSectionComment(key, false); + } + } +} - return s0; - } +pbxWriter.prototype.writeArray = function (arr, name) { + var i, entry; - function peg$parseAssignment() { - var s0; + this.write("%s = (\n", name); + this.indentLevel++; - s0 = peg$parseSimpleAssignment(); - if (s0 === peg$FAILED) { - s0 = peg$parseCommentedAssignment(); + for (i=0; i < arr.length; i++) { + entry = arr[i] + + if (entry.value && entry.comment) { + this.write('%s /* %s */,\n', entry.value, entry.comment); + } else if (isObject(entry)) { + this.write('{\n'); + this.indentLevel++; + + this.writeObject(entry); + + this.indentLevel--; + this.write('},\n'); + } else { + this.write('%s,\n', entry); + } } - return s0; - } + this.indentLevel--; + this.write(");\n"); +} - function peg$parseSimpleAssignment() { - var s0, s1, s2, s3, s4, s5, s6; +pbxWriter.prototype.writeSectionComment = function (name, begin) { + if (begin) { + this.writeFlush("/* Begin %s section */\n", name) + } else { // end + this.writeFlush("/* End %s section */\n", name) + } +} - s0 = peg$currPos; - s1 = peg$parseIdentifier(); - if (s1 !== peg$FAILED) { - s2 = peg$parse_(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 61) { - s3 = peg$c8; - peg$currPos++; +pbxWriter.prototype.writeSection = function (section) { + var key, obj, cmt; + + // section should only contain objects + for (key in section) { + if (COMMENT_KEY.test(key)) continue; + + cmt = comment(key, section); + obj = section[key] + + if (obj.isa == 'PBXBuildFile' || obj.isa == 'PBXFileReference') { + this.writeInlineObject(key, cmt, obj); } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c9); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse_(); - if (s4 !== peg$FAILED) { - s5 = peg$parseValue(); - if (s5 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 59) { - s6 = peg$c10; - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c11); } - } - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c12(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + if (cmt) { + this.write("%s /* %s */ = {\n", key, cmt); } else { - peg$currPos = s0; - s0 = peg$FAILED; + this.write("%s = {\n", key); } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + + this.indentLevel++ + + this.writeObject(obj) + + this.indentLevel-- + this.write("};\n"); } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; } +} - return s0; - } +pbxWriter.prototype.writeInlineObject = function (n, d, r) { + var output = []; - function peg$parseCommentedAssignment() { - var s0, s1, s2, s3, s4, s5, s6; + var inlineObjectHelper = function (name, desc, ref) { + var key, cmt, obj; - s0 = peg$currPos; - s1 = peg$parseCommentedIdentifier(); - if (s1 !== peg$FAILED) { - s2 = peg$parse_(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 61) { - s3 = peg$c8; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c9); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse_(); - if (s4 !== peg$FAILED) { - s5 = peg$parseValue(); - if (s5 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 59) { - s6 = peg$c10; - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c11); } - } - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c13(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + if (desc) { + output.push(f("%s /* %s */ = {", name, desc)); } else { - peg$currPos = s0; - s0 = peg$FAILED; + output.push(f("%s = {", name)); } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseIdentifier(); - if (s1 !== peg$FAILED) { - s2 = peg$parse_(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 61) { - s3 = peg$c8; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c9); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse_(); - if (s4 !== peg$FAILED) { - s5 = peg$parseCommentedValue(); - if (s5 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 59) { - s6 = peg$c10; - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c11); } - } - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c14(s1, s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; + + for (key in ref) { + if (COMMENT_KEY.test(key)) continue; + + cmt = comment(key, ref); + obj = ref[key]; + + if (isArray(obj)) { + output.push(f("%s = (", key)); + + for (var i=0; i < obj.length; i++) { + output.push(f("%s, ", obj[i])) } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + + output.push("); "); + } else if (isObject(obj)) { + inlineObjectHelper(key, cmt, obj) + } else if (cmt) { + output.push(f("%s = %s /* %s */; ", key, obj, cmt)) } else { - peg$currPos = s0; - s0 = peg$FAILED; + output.push(f("%s = %s; ", key, obj)) } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + + output.push("}; "); + } + + inlineObjectHelper(n, d, r); + + this.write("%s\n", output.join('').trim()); +} + +module.exports = pbxWriter; + + +/***/ }), +/* 55 */ +/***/ (function(module, exports, __webpack_require__) { + +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLAttribute, create; + + create = __webpack_require__(1); + + module.exports = XMLAttribute = (function() { + function XMLAttribute(parent, name, value) { + this.stringify = parent.stringify; + if (name == null) { + throw new Error("Missing attribute name of element " + parent.name); + } + if (value == null) { + throw new Error("Missing attribute value for attribute " + name + " of element " + parent.name); } + this.name = this.stringify.attName(name); + this.value = this.stringify.attValue(value); } - return s0; - } + XMLAttribute.prototype.clone = function() { + return create(XMLAttribute.prototype, this); + }; - function peg$parseCommentedIdentifier() { - var s0, s1, s2, s3; + XMLAttribute.prototype.toString = function(options, level) { + return ' ' + this.name + '="' + this.value + '"'; + }; - s0 = peg$currPos; - s1 = peg$parseIdentifier(); - if (s1 !== peg$FAILED) { - s2 = peg$parse_(); - if (s2 !== peg$FAILED) { - s3 = peg$parseInlineComment(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c15(s1, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; + return XMLAttribute; + + })(); + +}).call(this); + + +/***/ }), +/* 56 */ +/***/ (function(module, exports, __webpack_require__) { + +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLBuilder, XMLDeclaration, XMLDocType, XMLElement, XMLStringifier; + + XMLStringifier = __webpack_require__(62); + + XMLDeclaration = __webpack_require__(22); + + XMLDocType = __webpack_require__(23); + + XMLElement = __webpack_require__(24); + + module.exports = XMLBuilder = (function() { + function XMLBuilder(name, options) { + var root, temp; + if (name == null) { + throw new Error("Root element needs a name"); + } + if (options == null) { + options = {}; + } + this.options = options; + this.stringify = new XMLStringifier(options); + temp = new XMLElement(this, 'doc'); + root = temp.element(name); + root.isRoot = true; + root.documentObject = this; + this.rootObject = root; + if (!options.headless) { + root.declaration(options); + if ((options.pubID != null) || (options.sysID != null)) { + root.doctype(options); } - } else { - peg$currPos = s0; - s0 = peg$FAILED; } - } else { - peg$currPos = s0; - s0 = peg$FAILED; } - return s0; - } + XMLBuilder.prototype.root = function() { + return this.rootObject; + }; - function peg$parseCommentedValue() { - var s0, s1, s2, s3; + XMLBuilder.prototype.end = function(options) { + return this.toString(options); + }; - s0 = peg$currPos; - s1 = peg$parseValue(); - if (s1 !== peg$FAILED) { - s2 = peg$parse_(); - if (s2 !== peg$FAILED) { - s3 = peg$parseInlineComment(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c16(s1, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + XMLBuilder.prototype.toString = function(options) { + var indent, newline, offset, pretty, r, ref, ref1, ref2; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + r = ''; + if (this.xmldec != null) { + r += this.xmldec.toString(options); } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + if (this.doctype != null) { + r += this.doctype.toString(options); + } + r += this.rootObject.toString(options); + if (pretty && r.slice(-newline.length) === newline) { + r = r.slice(0, -newline.length); + } + return r; + }; - return s0; - } + return XMLBuilder; - function peg$parseInlineComment() { - var s0, s1, s2, s3; + })(); - s0 = peg$currPos; - s1 = peg$parseInlineCommentOpen(); - if (s1 !== peg$FAILED) { - s2 = []; - if (peg$c17.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c18); } +}).call(this); + + +/***/ }), +/* 57 */ +/***/ (function(module, exports, __webpack_require__) { + +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLDTDAttList, create; + + create = __webpack_require__(1); + + module.exports = XMLDTDAttList = (function() { + function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) { + this.stringify = parent.stringify; + if (elementName == null) { + throw new Error("Missing DTD element name"); } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - if (peg$c17.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c18); } - } - } - } else { - s2 = peg$FAILED; + if (attributeName == null) { + throw new Error("Missing DTD attribute name"); } - if (s2 !== peg$FAILED) { - s3 = peg$parseInlineCommentClose(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c19(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + if (!attributeType) { + throw new Error("Missing DTD attribute type"); + } + if (!defaultValueType) { + throw new Error("Missing DTD attribute default"); + } + if (defaultValueType.indexOf('#') !== 0) { + defaultValueType = '#' + defaultValueType; + } + if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) { + throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT"); + } + if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) { + throw new Error("Default value only applies to #FIXED or #DEFAULT"); + } + this.elementName = this.stringify.eleName(elementName); + this.attributeName = this.stringify.attName(attributeName); + this.attributeType = this.stringify.dtdAttType(attributeType); + this.defaultValue = this.stringify.dtdAttDefault(defaultValue); + this.defaultValueType = defaultValueType; + } + + XMLDTDAttList.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += ''; + if (pretty) { + r += newline; + } + return r; + }; + + return XMLDTDAttList; + + })(); + +}).call(this); + + +/***/ }), +/* 58 */ +/***/ (function(module, exports, __webpack_require__) { + +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLDTDElement, create; + + create = __webpack_require__(1); + + module.exports = XMLDTDElement = (function() { + function XMLDTDElement(parent, name, value) { + this.stringify = parent.stringify; + if (name == null) { + throw new Error("Missing DTD element name"); } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + if (!value) { + value = '(#PCDATA)'; + } + if (Array.isArray(value)) { + value = '(' + value.join(',') + ')'; + } + this.name = this.stringify.eleName(name); + this.value = this.stringify.dtdElementValue(value); } - return s0; - } + XMLDTDElement.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += ''; + if (pretty) { + r += newline; + } + return r; + }; - function peg$parseInlineCommentOpen() { - var s0; + return XMLDTDElement; - if (input.substr(peg$currPos, 2) === peg$c20) { - s0 = peg$c20; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c21); } - } + })(); - return s0; - } +}).call(this); - function peg$parseInlineCommentClose() { - var s0; - if (input.substr(peg$currPos, 2) === peg$c22) { - s0 = peg$c22; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c23); } - } +/***/ }), +/* 59 */ +/***/ (function(module, exports, __webpack_require__) { - return s0; - } +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLDTDEntity, create, isObject; - function peg$parseDelimitedSection() { - var s0, s1, s2, s3, s4, s5; + create = __webpack_require__(1); - s0 = peg$currPos; - s1 = peg$parseDelimitedSectionBegin(); - if (s1 !== peg$FAILED) { - s2 = peg$parse_(); - if (s2 !== peg$FAILED) { - s3 = peg$parseAssignmentList(); - if (s3 === peg$FAILED) { - s3 = peg$parseEmptyBody(); + isObject = __webpack_require__(0); + + module.exports = XMLDTDEntity = (function() { + function XMLDTDEntity(parent, pe, name, value) { + this.stringify = parent.stringify; + if (name == null) { + throw new Error("Missing entity name"); + } + if (value == null) { + throw new Error("Missing entity value"); + } + this.pe = !!pe; + this.name = this.stringify.eleName(name); + if (!isObject(value)) { + this.value = this.stringify.dtdEntityValue(value); + } else { + if (!value.pubID && !value.sysID) { + throw new Error("Public and/or system identifiers are required for an external entity"); } - if (s3 !== peg$FAILED) { - s4 = peg$parse_(); - if (s4 !== peg$FAILED) { - s5 = peg$parseDelimitedSectionEnd(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c24(s1, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + if (value.pubID && !value.sysID) { + throw new Error("System identifier is required for a public external entity"); } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseDelimitedSectionBegin() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9) === peg$c25) { - s1 = peg$c25; - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c26); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseIdentifier(); - if (s2 !== peg$FAILED) { - if (input.substr(peg$currPos, 11) === peg$c27) { - s3 = peg$c27; - peg$currPos += 11; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c28); } + if (value.pubID != null) { + this.pubID = this.stringify.dtdPubID(value.pubID); } - if (s3 !== peg$FAILED) { - s4 = peg$parseNewLine(); - if (s4 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c29(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + if (value.sysID != null) { + this.sysID = this.stringify.dtdSysID(value.sysID); } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseDelimitedSectionEnd() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7) === peg$c30) { - s1 = peg$c30; - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c31); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseIdentifier(); - if (s2 !== peg$FAILED) { - if (input.substr(peg$currPos, 11) === peg$c27) { - s3 = peg$c27; - peg$currPos += 11; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c28); } + if (value.nData != null) { + this.nData = this.stringify.dtdNData(value.nData); } - if (s3 !== peg$FAILED) { - s4 = peg$parseNewLine(); - if (s4 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c29(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + if (this.pe && this.nData) { + throw new Error("Notation declaration is not allowed in a parameter entity"); } - } else { - peg$currPos = s0; - s0 = peg$FAILED; } - } else { - peg$currPos = s0; - s0 = peg$FAILED; } - return s0; - } - - function peg$parseArray() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 40) { - s1 = peg$c32; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c33); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseArrayBody(); - if (s2 === peg$FAILED) { - s2 = peg$parseEmptyArray(); + XMLDTDEntity.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s3 = peg$c34; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c35); } + r += ''; + if (pretty) { + r += newline; + } + return r; + }; - return s0; - } + return XMLDTDEntity; - function peg$parseEmptyArray() { - var s0, s1; + })(); - s0 = peg$currPos; - s1 = peg$parse_(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c37(); - } - s0 = s1; +}).call(this); - return s0; - } - function peg$parseArrayBody() { - var s0, s1, s2, s3, s4, s5; +/***/ }), +/* 60 */ +/***/ (function(module, exports, __webpack_require__) { - s0 = peg$currPos; - s1 = peg$parse_(); - if (s1 !== peg$FAILED) { - s2 = peg$parseArrayEntry(); - if (s2 !== peg$FAILED) { - s3 = peg$parse_(); - if (s3 !== peg$FAILED) { - s4 = peg$parseArrayBody(); - if (s4 === peg$FAILED) { - s4 = null; - } - if (s4 !== peg$FAILED) { - s5 = peg$parse_(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c38(s2, s4); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLDTDNotation, create; + + create = __webpack_require__(1); + + module.exports = XMLDTDNotation = (function() { + function XMLDTDNotation(parent, name, value) { + this.stringify = parent.stringify; + if (name == null) { + throw new Error("Missing notation name"); + } + if (!value.pubID && !value.sysID) { + throw new Error("Public or system identifiers are required for an external entity"); + } + this.name = this.stringify.eleName(name); + if (value.pubID != null) { + this.pubID = this.stringify.dtdPubID(value.pubID); + } + if (value.sysID != null) { + this.sysID = this.stringify.dtdSysID(value.sysID); } - } else { - peg$currPos = s0; - s0 = peg$FAILED; } - return s0; - } + XMLDTDNotation.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += ''; + if (pretty) { + r += newline; + } + return r; + }; - function peg$parseArrayEntry() { - var s0; + return XMLDTDNotation; - s0 = peg$parseSimpleArrayEntry(); - if (s0 === peg$FAILED) { - s0 = peg$parseCommentedArrayEntry(); - } + })(); - return s0; - } +}).call(this); - function peg$parseSimpleArrayEntry() { - var s0, s1, s2; - s0 = peg$currPos; - s1 = peg$parseValue(); - if (s1 !== peg$FAILED) { - s2 = peg$parseEndArrayEntry(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c39(s1); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } +/***/ }), +/* 61 */ +/***/ (function(module, exports, __webpack_require__) { - return s0; - } +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLNode, XMLRaw, create, + 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; - function peg$parseCommentedArrayEntry() { - var s0, s1, s2, s3, s4; + create = __webpack_require__(1); - s0 = peg$currPos; - s1 = peg$parseValue(); - if (s1 !== peg$FAILED) { - s2 = peg$parse_(); - if (s2 !== peg$FAILED) { - s3 = peg$parseInlineComment(); - if (s3 !== peg$FAILED) { - s4 = peg$parseEndArrayEntry(); - if (s4 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c40(s1, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + XMLNode = __webpack_require__(6); + + module.exports = XMLRaw = (function(superClass) { + extend(XMLRaw, superClass); + + function XMLRaw(parent, text) { + XMLRaw.__super__.constructor.call(this, parent); + if (text == null) { + throw new Error("Missing raw text"); } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + this.value = this.stringify.raw(text); } - return s0; - } - - function peg$parseEndArrayEntry() { - var s0, s1, s2, s3; + XMLRaw.prototype.clone = function() { + return create(XMLRaw.prototype, this); + }; - if (input.charCodeAt(peg$currPos) === 44) { - s0 = peg$c41; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c42); } - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parse_(); - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 41) { - s3 = peg$c34; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c35); } - } - peg$silentFails--; - if (s3 !== peg$FAILED) { - peg$currPos = s2; - s2 = void 0; - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + XMLRaw.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; } - } + r += this.value; + if (pretty) { + r += newline; + } + return r; + }; - return s0; - } + return XMLRaw; - function peg$parseIdentifier() { - var s0, s1, s2; + })(XMLNode); - s0 = peg$currPos; - s1 = []; - if (peg$c43.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c44); } - } - if (s2 !== peg$FAILED) { - while (s2 !== peg$FAILED) { - s1.push(s2); - if (peg$c43.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c44); } - } +}).call(this); + + +/***/ }), +/* 62 */ +/***/ (function(module, exports) { + +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLStringifier, + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + hasProp = {}.hasOwnProperty; + + module.exports = XMLStringifier = (function() { + function XMLStringifier(options) { + this.assertLegalChar = bind(this.assertLegalChar, this); + var key, ref, value; + this.allowSurrogateChars = options != null ? options.allowSurrogateChars : void 0; + ref = (options != null ? options.stringify : void 0) || {}; + for (key in ref) { + if (!hasProp.call(ref, key)) continue; + value = ref[key]; + this[key] = value; } - } else { - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c45(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$parseQuotedString(); } - return s0; - } + XMLStringifier.prototype.eleName = function(val) { + val = '' + val || ''; + return this.assertLegalChar(val); + }; - function peg$parseValue() { - var s0; + XMLStringifier.prototype.eleText = function(val) { + val = '' + val || ''; + return this.assertLegalChar(this.elEscape(val)); + }; - s0 = peg$parseObject(); - if (s0 === peg$FAILED) { - s0 = peg$parseArray(); - if (s0 === peg$FAILED) { - s0 = peg$parseNumberValue(); - if (s0 === peg$FAILED) { - s0 = peg$parseStringValue(); - } + XMLStringifier.prototype.cdata = function(val) { + val = '' + val || ''; + if (val.match(/]]>/)) { + throw new Error("Invalid CDATA text: " + val); } - } + return this.assertLegalChar(val); + }; - return s0; - } + XMLStringifier.prototype.comment = function(val) { + val = '' + val || ''; + if (val.match(/--/)) { + throw new Error("Comment text cannot contain double-hypen: " + val); + } + return this.assertLegalChar(val); + }; - function peg$parseNumberValue() { - var s0; + XMLStringifier.prototype.raw = function(val) { + return '' + val || ''; + }; - s0 = peg$parseDecimalValue(); - if (s0 === peg$FAILED) { - s0 = peg$parseIntegerValue(); - } + XMLStringifier.prototype.attName = function(val) { + return '' + val || ''; + }; - return s0; - } + XMLStringifier.prototype.attValue = function(val) { + val = '' + val || ''; + return this.attEscape(val); + }; - function peg$parseDecimalValue() { - var s0, s1, s2, s3, s4; + XMLStringifier.prototype.insTarget = function(val) { + return '' + val || ''; + }; - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseIntegerValue(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 46) { - s3 = peg$c46; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c47); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parseIntegerValue(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; + XMLStringifier.prototype.insValue = function(val) { + val = '' + val || ''; + if (val.match(/\?>/)) { + throw new Error("Invalid processing instruction value: " + val); } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c48(s1); - } - s0 = s1; + return val; + }; - return s0; - } + XMLStringifier.prototype.xmlVersion = function(val) { + val = '' + val || ''; + if (!val.match(/1\.[0-9]+/)) { + throw new Error("Invalid version number: " + val); + } + return val; + }; - function peg$parseIntegerValue() { - var s0, s1, s2, s3, s4; + XMLStringifier.prototype.xmlEncoding = function(val) { + val = '' + val || ''; + if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-]|-)*$/)) { + throw new Error("Invalid encoding: " + val); + } + return val; + }; - s0 = peg$currPos; - s1 = peg$currPos; - peg$silentFails++; - s2 = peg$parseAlpha(); - peg$silentFails--; - if (s2 === peg$FAILED) { - s1 = void 0; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parseDigit(); - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parseDigit(); - } + XMLStringifier.prototype.xmlStandalone = function(val) { + if (val) { + return "yes"; } else { - s2 = peg$FAILED; + return "no"; } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - s4 = peg$parseNonTerminator(); - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = void 0; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c49(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + }; + + XMLStringifier.prototype.dtdPubID = function(val) { + return '' + val || ''; + }; + + XMLStringifier.prototype.dtdSysID = function(val) { + return '' + val || ''; + }; + + XMLStringifier.prototype.dtdElementValue = function(val) { + return '' + val || ''; + }; + + XMLStringifier.prototype.dtdAttType = function(val) { + return '' + val || ''; + }; + + XMLStringifier.prototype.dtdAttDefault = function(val) { + if (val != null) { + return '' + val || ''; + } else { + return val; } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + }; - return s0; - } + XMLStringifier.prototype.dtdEntityValue = function(val) { + return '' + val || ''; + }; - function peg$parseStringValue() { - var s0; + XMLStringifier.prototype.dtdNData = function(val) { + return '' + val || ''; + }; - s0 = peg$parseQuotedString(); - if (s0 === peg$FAILED) { - s0 = peg$parseLiteralString(); - } + XMLStringifier.prototype.convertAttKey = '@'; - return s0; - } + XMLStringifier.prototype.convertPIKey = '?'; - function peg$parseQuotedString() { - var s0, s1, s2, s3; + XMLStringifier.prototype.convertTextKey = '#text'; - s0 = peg$currPos; - s1 = peg$parseDoubleQuote(); - if (s1 !== peg$FAILED) { - s2 = peg$parseQuotedBody(); - if (s2 !== peg$FAILED) { - s3 = peg$parseDoubleQuote(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c50(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + XMLStringifier.prototype.convertCDataKey = '#cdata'; + + XMLStringifier.prototype.convertCommentKey = '#comment'; + + XMLStringifier.prototype.convertRawKey = '#raw'; + + XMLStringifier.prototype.assertLegalChar = function(str) { + var chars, chr; + if (this.allowSurrogateChars) { + chars = /[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uFFFE-\uFFFF]/; } else { - peg$currPos = s0; - s0 = peg$FAILED; + chars = /[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE-\uFFFF]/; } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + chr = str.match(chars); + if (chr) { + throw new Error("Invalid character (" + chr + ") in string: " + str + " at index " + chr.index); + } + return str; + }; - return s0; - } + XMLStringifier.prototype.elEscape = function(str) { + return str.replace(/&/g, '&').replace(//g, '>').replace(/\r/g, ' '); + }; - function peg$parseQuotedBody() { - var s0, s1, s2; + XMLStringifier.prototype.attEscape = function(str) { + return str.replace(/&/g, '&').replace(/ peg$currPos) { - s2 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c52); } - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c53(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + r += this.value; + if (pretty) { + r += newline; } - } + return r; + }; - return s0; + return XMLText; + + })(XMLNode); + +}).call(this); + + +/***/ }), +/* 64 */ +/***/ (function(module, exports, __webpack_require__) { + +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLBuilder, assign; + + assign = __webpack_require__(97); + + XMLBuilder = __webpack_require__(56); + + module.exports.create = function(name, xmldec, doctype, options) { + options = assign({}, xmldec, doctype, options); + return new XMLBuilder(name, options).root(); + }; + +}).call(this); + + +/***/ }), +/* 65 */ +/***/ (function(module, exports) { + +/** + * Gets the last element of `array`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @returns {*} Returns the last element of `array`. + * @example + * + * _.last([1, 2, 3]); + * // => 3 + */ +function last(array) { + var length = array ? array.length : 0; + return length ? array[length - 1] : undefined; +} + +module.exports = last; + + +/***/ }), +/* 66 */ +/***/ (function(module, exports, __webpack_require__) { + +var arrayEvery = __webpack_require__(68), + baseCallback = __webpack_require__(71), + baseEvery = __webpack_require__(75), + isArray = __webpack_require__(3), + isIterateeCall = __webpack_require__(15); + +/** + * Checks if `predicate` returns truthy for **all** elements of `collection`. + * The predicate is bound to `thisArg` and invoked with three arguments: + * (value, index|key, collection). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @alias all + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. + * @example + * + * _.every([true, 1, null, 'yes'], Boolean); + * // => false + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false } + * ]; + * + * // using the `_.matches` callback shorthand + * _.every(users, { 'user': 'barney', 'active': false }); + * // => false + * + * // using the `_.matchesProperty` callback shorthand + * _.every(users, 'active', false); + * // => true + * + * // using the `_.property` callback shorthand + * _.every(users, 'active'); + * // => false + */ +function every(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayEvery : baseEvery; + if (thisArg && isIterateeCall(collection, predicate, thisArg)) { + predicate = undefined; + } + if (typeof predicate != 'function' || thisArg !== undefined) { + predicate = baseCallback(predicate, thisArg, 3); } + return func(collection, predicate); +} - function peg$parseEscapedQuote() { - var s0, s1, s2; +module.exports = every; - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 92) { - s1 = peg$c54; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c55); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseDoubleQuote(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c56(); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - return s0; - } +/***/ }), +/* 67 */ +/***/ (function(module, exports) { - function peg$parseLiteralString() { - var s0, s1, s2; +/** Used as the `TypeError` message for "Functions" methods. */ +var FUNC_ERROR_TEXT = 'Expected a function'; - s0 = peg$currPos; - s1 = []; - s2 = peg$parseLiteralChar(); - if (s2 !== peg$FAILED) { - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$parseLiteralChar(); - } - } else { - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c57(s1); - } - s0 = s1; +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; - return s0; +/** + * Creates a function that invokes `func` with the `this` binding of the + * created function and arguments from `start` and beyond provided as an array. + * + * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/Web/JavaScript/Reference/Functions/rest_parameters). + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @returns {Function} Returns the new function. + * @example + * + * var say = _.restParam(function(what, names) { + * return what + ' ' + _.initial(names).join(', ') + + * (_.size(names) > 1 ? ', & ' : '') + _.last(names); + * }); + * + * say('hello', 'fred', 'barney', 'pebbles'); + * // => 'hello fred, barney, & pebbles' + */ +function restParam(func, start) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); } + start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0); + return function() { + var args = arguments, + index = -1, + length = nativeMax(args.length - start, 0), + rest = Array(length); - function peg$parseLiteralChar() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$currPos; - peg$silentFails++; - s2 = peg$parseInlineCommentOpen(); - peg$silentFails--; - if (s2 === peg$FAILED) { - s1 = void 0; - } else { - peg$currPos = s1; - s1 = peg$FAILED; + while (++index < length) { + rest[index] = args[start + index]; } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseLineTerminator(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = void 0; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s3 = peg$parseNonTerminator(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c53(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + switch (start) { + case 0: return func.call(this, rest); + case 1: return func.call(this, args[0], rest); + case 2: return func.call(this, args[0], args[1], rest); } + var otherArgs = Array(start + 1); + index = -1; + while (++index < start) { + otherArgs[index] = args[index]; + } + otherArgs[start] = rest; + return func.apply(this, otherArgs); + }; +} - return s0; - } +module.exports = restParam; - function peg$parseNonTerminator() { - var s0; - if (peg$c58.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c59); } - } +/***/ }), +/* 68 */ +/***/ (function(module, exports) { - return s0; +/** + * A specialized version of `_.every` for arrays without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. + */ +function arrayEvery(array, predicate) { + var index = -1, + length = array.length; + + while (++index < length) { + if (!predicate(array[index], index, array)) { + return false; + } } + return true; +} - function peg$parseSingleLineComment() { - var s0, s1, s2, s3, s4; +module.exports = arrayEvery; - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c60) { - s1 = peg$c60; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c61); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse_(); - if (s2 !== peg$FAILED) { - s3 = peg$parseOneLineString(); - if (s3 !== peg$FAILED) { - s4 = peg$parseNewLine(); - if (s4 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c62(s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + +/***/ }), +/* 69 */ +/***/ (function(module, exports) { + +/** + * A specialized version of `_.some` for arrays without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + */ +function arraySome(array, predicate) { + var index = -1, + length = array.length; + + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; } + } + return false; +} + +module.exports = arraySome; - return s0; - } - function peg$parseOneLineString() { - var s0, s1, s2; +/***/ }), +/* 70 */ +/***/ (function(module, exports, __webpack_require__) { - s0 = peg$currPos; - s1 = []; - s2 = peg$parseNonLine(); - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$parseNonLine(); - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c63(s1); - } - s0 = s1; +var keys = __webpack_require__(8); - return s0; - } +/** + * A specialized version of `_.assign` for customizing assigned values without + * support for argument juggling, multiple sources, and `this` binding `customizer` + * functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {Function} customizer The function to customize assigned values. + * @returns {Object} Returns `object`. + */ +function assignWith(object, source, customizer) { + var index = -1, + props = keys(source), + length = props.length; - function peg$parseDigit() { - var s0; + while (++index < length) { + var key = props[index], + value = object[key], + result = customizer(value, source[key], key, object, source); - if (peg$c64.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c65); } + if ((result === result ? (result !== value) : (value === value)) || + (value === undefined && !(key in object))) { + object[key] = result; } - - return s0; } + return object; +} - function peg$parseAlpha() { - var s0; +module.exports = assignWith; - if (peg$c66.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c67); } - } - return s0; +/***/ }), +/* 71 */ +/***/ (function(module, exports, __webpack_require__) { + +var baseMatches = __webpack_require__(80), + baseMatchesProperty = __webpack_require__(81), + bindCallback = __webpack_require__(30), + identity = __webpack_require__(36), + property = __webpack_require__(100); + +/** + * The base implementation of `_.callback` which supports specifying the + * number of arguments to provide to `func`. + * + * @private + * @param {*} [func=_.identity] The value to convert to a callback. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {number} [argCount] The number of arguments to provide to `func`. + * @returns {Function} Returns the callback. + */ +function baseCallback(func, thisArg, argCount) { + var type = typeof func; + if (type == 'function') { + return thisArg === undefined + ? func + : bindCallback(func, thisArg, argCount); + } + if (func == null) { + return identity; + } + if (type == 'object') { + return baseMatches(func); } + return thisArg === undefined + ? property(func) + : baseMatchesProperty(func, thisArg); +} - function peg$parseDoubleQuote() { - var s0; +module.exports = baseCallback; - if (input.charCodeAt(peg$currPos) === 34) { - s0 = peg$c68; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c69); } - } - return s0; - } +/***/ }), +/* 72 */ +/***/ (function(module, exports) { - function peg$parse_() { - var s0, s1; +/** + * Copies properties of `source` to `object`. + * + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property names to copy. + * @param {Object} [object={}] The object to copy properties to. + * @returns {Object} Returns `object`. + */ +function baseCopy(source, props, object) { + object || (object = {}); - peg$silentFails++; - s0 = []; - s1 = peg$parsewhitespace(); - while (s1 !== peg$FAILED) { - s0.push(s1); - s1 = peg$parsewhitespace(); - } - peg$silentFails--; - if (s0 === peg$FAILED) { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c70); } - } + var index = -1, + length = props.length; - return s0; + while (++index < length) { + var key = props[index]; + object[key] = source[key]; } + return object; +} - function peg$parsewhitespace() { - var s0; +module.exports = baseCopy; - s0 = peg$parseNewLine(); - if (s0 === peg$FAILED) { - if (peg$c71.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c72); } - } - } - return s0; - } +/***/ }), +/* 73 */ +/***/ (function(module, exports, __webpack_require__) { - function peg$parseNonLine() { - var s0, s1, s2; +var isObject = __webpack_require__(0); - s0 = peg$currPos; - s1 = peg$currPos; - peg$silentFails++; - s2 = peg$parseNewLine(); - peg$silentFails--; - if (s2 === peg$FAILED) { - s1 = void 0; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - s2 = peg$parseChar(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c53(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; +/** + * The base implementation of `_.create` without support for assigning + * properties to the created object. + * + * @private + * @param {Object} prototype The object to inherit from. + * @returns {Object} Returns the new object. + */ +var baseCreate = (function() { + function object() {} + return function(prototype) { + if (isObject(prototype)) { + object.prototype = prototype; + var result = new object; + object.prototype = undefined; } + return result || {}; + }; +}()); - return s0; - } +module.exports = baseCreate; - function peg$parseLineTerminator() { - var s0; - s0 = peg$parseNewLine(); - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 59) { - s0 = peg$c10; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c11); } - } - } +/***/ }), +/* 74 */ +/***/ (function(module, exports, __webpack_require__) { - return s0; - } +var baseForOwn = __webpack_require__(77), + createBaseEach = __webpack_require__(86); - function peg$parseNewLine() { - var s0; +/** + * The base implementation of `_.forEach` without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object|string} Returns `collection`. + */ +var baseEach = createBaseEach(baseForOwn); - if (peg$c73.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c74); } - } +module.exports = baseEach; - return s0; - } - function peg$parseChar() { - var s0; +/***/ }), +/* 75 */ +/***/ (function(module, exports, __webpack_require__) { + +var baseEach = __webpack_require__(74); + +/** + * The base implementation of `_.every` without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false` + */ +function baseEvery(collection, predicate) { + var result = true; + baseEach(collection, function(value, index, collection) { + result = !!predicate(value, index, collection); + return result; + }); + return result; +} - if (input.length > peg$currPos) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c52); } - } +module.exports = baseEvery; - return s0; - } +/***/ }), +/* 76 */ +/***/ (function(module, exports, __webpack_require__) { - function merge_obj(obj, secondObj) { - if (!obj) - return secondObj; +var createBaseFor = __webpack_require__(87); - for(var i in secondObj) - obj[i] = merge_obj(obj[i], secondObj[i]); +/** + * The base implementation of `baseForIn` and `baseForOwn` which iterates + * over `object` properties returned by `keysFunc` invoking `iteratee` for + * each property. Iteratee functions may exit iteration early by explicitly + * returning `false`. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ +var baseFor = createBaseFor(); - return obj; - } +module.exports = baseFor; - peg$result = peg$startRuleFunction(); +/***/ }), +/* 77 */ +/***/ (function(module, exports, __webpack_require__) { - if (peg$result !== peg$FAILED && peg$currPos === input.length) { - return peg$result; - } else { - if (peg$result !== peg$FAILED && peg$currPos < input.length) { - peg$fail(peg$endExpectation()); - } +var baseFor = __webpack_require__(76), + keys = __webpack_require__(8); - throw peg$buildStructuredError( - peg$maxFailExpected, - peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, - peg$maxFailPos < input.length - ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) - : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) - ); - } +/** + * The base implementation of `_.forOwn` without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ +function baseForOwn(object, iteratee) { + return baseFor(object, iteratee, keys); } -module.exports = { - SyntaxError: peg$SyntaxError, - parse: peg$parse -}; +module.exports = baseForOwn; -/***/ }, -/* 98 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 78 */ +/***/ (function(module, exports, __webpack_require__) { -var path = __webpack_require__(12), - util = __webpack_require__(5); +var equalArrays = __webpack_require__(88), + equalByTag = __webpack_require__(89), + equalObjects = __webpack_require__(90), + isArray = __webpack_require__(3), + isTypedArray = __webpack_require__(96); -var DEFAULT_SOURCETREE = '""', - DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR', - DEFAULT_FILEENCODING = 4, - DEFAULT_GROUP = 'Resources', - DEFAULT_FILETYPE = 'unknown'; +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + objectTag = '[object Object]'; -var FILETYPE_BY_EXTENSION = { - a: 'archive.ar', - app: 'wrapper.application', - appex: 'wrapper.app-extension', - bundle: 'wrapper.plug-in', - dylib: 'compiled.mach-o.dylib', - framework: 'wrapper.framework', - h: 'sourcecode.c.h', - m: 'sourcecode.c.objc', - markdown: 'text', - mdimporter: 'wrapper.cfbundle', - octest: 'wrapper.cfbundle', - pch: 'sourcecode.c.h', - plist: 'text.plist.xml', - sh: 'text.script.sh', - swift: 'sourcecode.swift', - tbd: 'sourcecode.text-based-dylib-definition', - xcassets: 'folder.assetcatalog', - xcconfig: 'text.xcconfig', - xcdatamodel: 'wrapper.xcdatamodel', - xcodeproj: 'wrapper.pb-project', - xctest: 'wrapper.cfbundle', - xib: 'file.xib', - strings: 'text.plist.strings' - }, - GROUP_BY_FILETYPE = { - 'archive.ar': 'Frameworks', - 'compiled.mach-o.dylib': 'Frameworks', - 'sourcecode.text-based-dylib-definition': 'Frameworks', - 'wrapper.framework': 'Frameworks', - 'embedded.framework': 'Embed Frameworks', - 'sourcecode.c.h': 'Resources', - 'sourcecode.c.objc': 'Sources', - 'sourcecode.swift': 'Sources' - }, - PATH_BY_FILETYPE = { - 'compiled.mach-o.dylib': 'usr/lib/', - 'sourcecode.text-based-dylib-definition': 'usr/lib/', - 'wrapper.framework': 'System/Library/Frameworks/' - }, - SOURCETREE_BY_FILETYPE = { - 'compiled.mach-o.dylib': 'SDKROOT', - 'sourcecode.text-based-dylib-definition': 'SDKROOT', - 'wrapper.framework': 'SDKROOT' - }, - ENCODING_BY_FILETYPE = { - 'sourcecode.c.h': 4, - 'sourcecode.c.h': 4, - 'sourcecode.c.objc': 4, - 'sourcecode.swift': 4, - 'text': 4, - 'text.plist.xml': 4, - 'text.script.sh': 4, - 'text.xcconfig': 4, - 'text.plist.strings': 4 - }; +/** Used for native method references. */ +var objectProto = Object.prototype; +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; -function unquoted(text){ - return text.replace (/(^")|("$)/g, '') -} +/** + * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * of values. + */ +var objToString = objectProto.toString; -function detectType(filePath) { - var extension = path.extname(filePath).substring(1), - filetype = FILETYPE_BY_EXTENSION[unquoted(extension)]; +/** + * A specialized version of `baseIsEqual` for arrays and objects which performs + * deep comparisons and tracks traversed objects enabling objects with circular + * references to be compared. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Function} [customizer] The function to customize comparing objects. + * @param {boolean} [isLoose] Specify performing partial comparisons. + * @param {Array} [stackA=[]] Tracks traversed `value` objects. + * @param {Array} [stackB=[]] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) { + var objIsArr = isArray(object), + othIsArr = isArray(other), + objTag = arrayTag, + othTag = arrayTag; - if (!filetype) { - return DEFAULT_FILETYPE; + if (!objIsArr) { + objTag = objToString.call(object); + if (objTag == argsTag) { + objTag = objectTag; + } else if (objTag != objectTag) { + objIsArr = isTypedArray(object); } - - return filetype; -} - -function defaultExtension(fileRef) { - var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType; - - for(var extension in FILETYPE_BY_EXTENSION) { - if(FILETYPE_BY_EXTENSION.hasOwnProperty(unquoted(extension)) ) { - if(FILETYPE_BY_EXTENSION[unquoted(extension)] === filetype ) - return extension; - } + } + if (!othIsArr) { + othTag = objToString.call(other); + if (othTag == argsTag) { + othTag = objectTag; + } else if (othTag != objectTag) { + othIsArr = isTypedArray(other); } -} + } + var objIsObj = objTag == objectTag, + othIsObj = othTag == objectTag, + isSameTag = objTag == othTag; -function defaultEncoding(fileRef) { - var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, - encoding = ENCODING_BY_FILETYPE[unquoted(filetype)]; + if (isSameTag && !(objIsArr || objIsObj)) { + return equalByTag(object, other, objTag); + } + if (!isLoose) { + var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), + othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); - if (encoding) { - return encoding; + if (objIsWrapped || othIsWrapped) { + return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB); } -} - -function detectGroup(fileRef, opt) { - var extension = path.extname(fileRef.basename).substring(1), - filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, - groupName = GROUP_BY_FILETYPE[unquoted(filetype)]; + } + if (!isSameTag) { + return false; + } + // Assume cyclic values are equal. + // For more information on detecting circular references see https://es5.github.io/#JO. + stackA || (stackA = []); + stackB || (stackB = []); - if (extension === 'xcdatamodeld') { - return 'Sources'; + var length = stackA.length; + while (length--) { + if (stackA[length] == object) { + return stackB[length] == other; } + } + // Add `object` and `other` to the stack of traversed objects. + stackA.push(object); + stackB.push(other); - if (opt.customFramework && opt.embed) { - return GROUP_BY_FILETYPE['embedded.framework']; - } + var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB); - if (!groupName) { - return DEFAULT_GROUP; - } + stackA.pop(); + stackB.pop(); - return groupName; + return result; } -function detectSourcetree(fileRef) { +module.exports = baseIsEqualDeep; - var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, - sourcetree = SOURCETREE_BY_FILETYPE[unquoted(filetype)]; - if (fileRef.explicitFileType) { - return DEFAULT_PRODUCT_SOURCETREE; - } +/***/ }), +/* 79 */ +/***/ (function(module, exports, __webpack_require__) { - if (fileRef.customFramework) { - return DEFAULT_SOURCETREE; - } +var baseIsEqual = __webpack_require__(28), + toObject = __webpack_require__(2); - if (!sourcetree) { - return DEFAULT_SOURCETREE; +/** + * The base implementation of `_.isMatch` without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Object} object The object to inspect. + * @param {Array} matchData The propery names, values, and compare flags to match. + * @param {Function} [customizer] The function to customize comparing objects. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + */ +function baseIsMatch(object, matchData, customizer) { + var index = matchData.length, + length = index, + noCustomizer = !customizer; + + if (object == null) { + return !length; + } + object = toObject(object); + while (index--) { + var data = matchData[index]; + if ((noCustomizer && data[2]) + ? data[1] !== object[data[0]] + : !(data[0] in object) + ) { + return false; } + } + while (++index < length) { + data = matchData[index]; + var key = data[0], + objValue = object[key], + srcValue = data[1]; - return sourcetree; + if (noCustomizer && data[2]) { + if (objValue === undefined && !(key in object)) { + return false; + } + } else { + var result = customizer ? customizer(objValue, srcValue, key) : undefined; + if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) { + return false; + } + } + } + return true; } -function defaultPath(fileRef, filePath) { - var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, - defaultPath = PATH_BY_FILETYPE[unquoted(filetype)]; - - if (fileRef.customFramework) { - return filePath; - } +module.exports = baseIsMatch; - if (defaultPath) { - return path.join(defaultPath, path.basename(filePath)); - } - return filePath; -} +/***/ }), +/* 80 */ +/***/ (function(module, exports, __webpack_require__) { -function defaultGroup(fileRef) { - var groupName = GROUP_BY_FILETYPE[fileRef.lastKnownFileType]; +var baseIsMatch = __webpack_require__(79), + getMatchData = __webpack_require__(91), + toObject = __webpack_require__(2); - if (!groupName) { - return DEFAULT_GROUP; - } +/** + * The base implementation of `_.matches` which does not clone `source`. + * + * @private + * @param {Object} source The object of property values to match. + * @returns {Function} Returns the new function. + */ +function baseMatches(source) { + var matchData = getMatchData(source); + if (matchData.length == 1 && matchData[0][2]) { + var key = matchData[0][0], + value = matchData[0][1]; - return defaultGroup; + return function(object) { + if (object == null) { + return false; + } + return object[key] === value && (value !== undefined || (key in toObject(object))); + }; + } + return function(object) { + return baseIsMatch(object, matchData); + }; } -function pbxFile(filepath, opt) { - var opt = opt || {}; +module.exports = baseMatches; - this.basename = path.basename(filepath); - this.lastKnownFileType = opt.lastKnownFileType || detectType(filepath); - this.group = detectGroup(this, opt); - // for custom frameworks - if (opt.customFramework == true) { - this.customFramework = true; - this.dirname = path.dirname(filepath).replace(/\\/g, '/'); - } +/***/ }), +/* 81 */ +/***/ (function(module, exports, __webpack_require__) { - this.path = defaultPath(this, filepath).replace(/\\/g, '/'); - this.fileEncoding = this.defaultEncoding = opt.defaultEncoding || defaultEncoding(this); +var baseGet = __webpack_require__(27), + baseIsEqual = __webpack_require__(28), + baseSlice = __webpack_require__(83), + isArray = __webpack_require__(3), + isKey = __webpack_require__(33), + isStrictComparable = __webpack_require__(34), + last = __webpack_require__(65), + toObject = __webpack_require__(2), + toPath = __webpack_require__(35); - // When referencing products / build output files - if (opt.explicitFileType) { - this.explicitFileType = opt.explicitFileType; - this.basename = this.basename + '.' + defaultExtension(this); - delete this.path; - delete this.lastKnownFileType; - delete this.group; - delete this.defaultEncoding; +/** + * The base implementation of `_.matchesProperty` which does not clone `srcValue`. + * + * @private + * @param {string} path The path of the property to get. + * @param {*} srcValue The value to compare. + * @returns {Function} Returns the new function. + */ +function baseMatchesProperty(path, srcValue) { + var isArr = isArray(path), + isCommon = isKey(path) && isStrictComparable(srcValue), + pathKey = (path + ''); + + path = toPath(path); + return function(object) { + if (object == null) { + return false; + } + var key = pathKey; + object = toObject(object); + if ((isArr || !isCommon) && !(key in object)) { + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + if (object == null) { + return false; + } + key = last(path); + object = toObject(object); } + return object[key] === srcValue + ? (srcValue !== undefined || (key in object)) + : baseIsEqual(srcValue, object[key], undefined, true); + }; +} - this.sourceTree = opt.sourceTree || detectSourcetree(this); - this.includeInIndex = 0; +module.exports = baseMatchesProperty; - if (opt.weak && opt.weak === true) - this.settings = { ATTRIBUTES: ['Weak'] }; - if (opt.compilerFlags) { - if (!this.settings) - this.settings = {}; - this.settings.COMPILER_FLAGS = util.format('"%s"', opt.compilerFlags); - } +/***/ }), +/* 82 */ +/***/ (function(module, exports, __webpack_require__) { - if (opt.embed && opt.sign) { - if (!this.settings) - this.settings = {}; - if (!this.settings.ATTRIBUTES) - this.settings.ATTRIBUTES = []; - this.settings.ATTRIBUTES.push('CodeSignOnCopy'); - } +var baseGet = __webpack_require__(27), + toPath = __webpack_require__(35); + +/** + * A specialized version of `baseProperty` which supports deep paths. + * + * @private + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new function. + */ +function basePropertyDeep(path) { + var pathKey = (path + ''); + path = toPath(path); + return function(object) { + return baseGet(object, path, pathKey); + }; } -module.exports = pbxFile; +module.exports = basePropertyDeep; -/***/ }, -/* 99 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 83 */ +/***/ (function(module, exports) { -var pbxProj = __webpack_require__(36), - util = __webpack_require__(5), - f = util.format, - INDENT = '\t', - COMMENT_KEY = /_comment$/, - QUOTED = /^"(.*)"$/, - EventEmitter = __webpack_require__(38).EventEmitter +/** + * The base implementation of `_.slice` without an iteratee call guard. + * + * @private + * @param {Array} array The array to slice. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the slice of `array`. + */ +function baseSlice(array, start, end) { + var index = -1, + length = array.length; -// indentation -function i(x) { - if (x <=0) - return ''; - else - return INDENT + i(x-1); + start = start == null ? 0 : (+start || 0); + if (start < 0) { + start = -start > length ? 0 : (length + start); + } + end = (end === undefined || end > length) ? length : (+end || 0); + if (end < 0) { + end += length; + } + length = start > end ? 0 : ((end - start) >>> 0); + start >>>= 0; + + var result = Array(length); + while (++index < length) { + result[index] = array[index + start]; + } + return result; } -function comment(key, parent) { - var text = parent[key + '_comment']; +module.exports = baseSlice; - if (text) - return text; - else - return null; -} -// copied from underscore -function isObject(obj) { - return obj === Object(obj) +/***/ }), +/* 84 */ +/***/ (function(module, exports) { + +/** + * Converts `value` to a string if it's not one. An empty string is returned + * for `null` or `undefined` values. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString(value) { + return value == null ? '' : (value + ''); } -function isArray(obj) { - return Array.isArray(obj) -} +module.exports = baseToString; -function pbxWriter(contents) { - this.contents = contents; - this.sync = false; - this.indentLevel = 0; -} -util.inherits(pbxWriter, EventEmitter); +/***/ }), +/* 85 */ +/***/ (function(module, exports, __webpack_require__) { -pbxWriter.prototype.write = function (str) { - var fmt = f.apply(null, arguments); +var bindCallback = __webpack_require__(30), + isIterateeCall = __webpack_require__(15), + restParam = __webpack_require__(67); - if (this.sync) { - this.buffer += f("%s%s", i(this.indentLevel), fmt); +/** + * Creates a `_.assign`, `_.defaults`, or `_.merge` function. + * + * @private + * @param {Function} assigner The function to assign values. + * @returns {Function} Returns the new assigner function. + */ +function createAssigner(assigner) { + return restParam(function(object, sources) { + var index = -1, + length = object == null ? 0 : sources.length, + customizer = length > 2 ? sources[length - 2] : undefined, + guard = length > 2 ? sources[2] : undefined, + thisArg = length > 1 ? sources[length - 1] : undefined; + + if (typeof customizer == 'function') { + customizer = bindCallback(customizer, thisArg, 5); + length -= 2; } else { - // do stream write + customizer = typeof thisArg == 'function' ? thisArg : undefined; + length -= (customizer ? 1 : 0); + } + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + customizer = length < 3 ? undefined : customizer; + length = 1; + } + while (++index < length) { + var source = sources[index]; + if (source) { + assigner(object, source, customizer); + } } + return object; + }); } -pbxWriter.prototype.writeFlush = function (str) { - var oldIndent = this.indentLevel; - - this.indentLevel = 0; - - this.write.apply(this, arguments) +module.exports = createAssigner; - this.indentLevel = oldIndent; -} -pbxWriter.prototype.writeSync = function () { - this.sync = true; - this.buffer = ""; +/***/ }), +/* 86 */ +/***/ (function(module, exports, __webpack_require__) { - this.writeHeadComment(); - this.writeProject(); +var getLength = __webpack_require__(31), + isLength = __webpack_require__(7), + toObject = __webpack_require__(2); - return this.buffer; -} +/** + * Creates a `baseEach` or `baseEachRight` function. + * + * @private + * @param {Function} eachFunc The function to iterate over a collection. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ +function createBaseEach(eachFunc, fromRight) { + return function(collection, iteratee) { + var length = collection ? getLength(collection) : 0; + if (!isLength(length)) { + return eachFunc(collection, iteratee); + } + var index = fromRight ? length : -1, + iterable = toObject(collection); -pbxWriter.prototype.writeHeadComment = function () { - if (this.contents.headComment) { - this.write("// %s\n", this.contents.headComment) + while ((fromRight ? index-- : ++index < length)) { + if (iteratee(iterable[index], index, iterable) === false) { + break; + } } + return collection; + }; } -pbxWriter.prototype.writeProject = function () { - var proj = this.contents.project, - key, cmt, obj; - - this.write("{\n") - - if (proj) { - this.indentLevel++; - - for (key in proj) { - // skip comments - if (COMMENT_KEY.test(key)) continue; +module.exports = createBaseEach; - cmt = comment(key, proj); - obj = proj[key]; - if (isArray(obj)) { - this.writeArray(obj, key) - } else if (isObject(obj)) { - this.write("%s = {\n", key); - this.indentLevel++; +/***/ }), +/* 87 */ +/***/ (function(module, exports, __webpack_require__) { - if (key === 'objects') { - this.writeObjectsSections(obj) - } else { - this.writeObject(obj) - } +var toObject = __webpack_require__(2); - this.indentLevel--; - this.write("};\n"); - } else if (cmt) { - this.write("%s = %s /* %s */;\n", key, obj, cmt) - } else { - this.write("%s = %s;\n", key, obj) - } - } +/** + * Creates a base function for `_.forIn` or `_.forInRight`. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ +function createBaseFor(fromRight) { + return function(object, iteratee, keysFunc) { + var iterable = toObject(object), + props = keysFunc(object), + length = props.length, + index = fromRight ? length : -1; - this.indentLevel--; + while ((fromRight ? index-- : ++index < length)) { + var key = props[index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; + } } - - this.write("}\n") + return object; + }; } -pbxWriter.prototype.writeObject = function (object) { - var key, obj, cmt; +module.exports = createBaseFor; - for (key in object) { - if (COMMENT_KEY.test(key)) continue; - cmt = comment(key, object); - obj = object[key]; +/***/ }), +/* 88 */ +/***/ (function(module, exports, __webpack_require__) { - if (isArray(obj)) { - this.writeArray(obj, key) - } else if (isObject(obj)) { - this.write("%s = {\n", key); - this.indentLevel++; +var arraySome = __webpack_require__(69); - this.writeObject(obj) +/** + * A specialized version of `baseIsEqualDeep` for arrays with support for + * partial deep comparisons. + * + * @private + * @param {Array} array The array to compare. + * @param {Array} other The other array to compare. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Function} [customizer] The function to customize comparing arrays. + * @param {boolean} [isLoose] Specify performing partial comparisons. + * @param {Array} [stackA] Tracks traversed `value` objects. + * @param {Array} [stackB] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. + */ +function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) { + var index = -1, + arrLength = array.length, + othLength = other.length; - this.indentLevel--; - this.write("};\n"); - } else { - if (cmt) { - this.write("%s = %s /* %s */;\n", key, obj, cmt) - } else { - this.write("%s = %s;\n", key, obj) - } - } + if (arrLength != othLength && !(isLoose && othLength > arrLength)) { + return false; + } + // Ignore non-index properties. + while (++index < arrLength) { + var arrValue = array[index], + othValue = other[index], + result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined; + + if (result !== undefined) { + if (result) { + continue; + } + return false; + } + // Recursively compare arrays (susceptible to call stack limits). + if (isLoose) { + if (!arraySome(other, function(othValue) { + return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); + })) { + return false; + } + } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) { + return false; } + } + return true; } -pbxWriter.prototype.writeObjectsSections = function (objects) { - var first = true, - key, obj; +module.exports = equalArrays; - for (key in objects) { - if (!first) { - this.writeFlush("\n") - } else { - first = false; - } - obj = objects[key]; +/***/ }), +/* 89 */ +/***/ (function(module, exports) { + +/** `Object#toString` result references. */ +var boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + numberTag = '[object Number]', + regexpTag = '[object RegExp]', + stringTag = '[object String]'; + +/** + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `toStringTag`. + * + * **Note:** This function only supports comparing values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {string} tag The `toStringTag` of the objects to compare. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalByTag(object, other, tag) { + switch (tag) { + case boolTag: + case dateTag: + // Coerce dates and booleans to numbers, dates to milliseconds and booleans + // to `1` or `0` treating invalid dates coerced to `NaN` as not equal. + return +object == +other; - if (isObject(obj)) { - this.writeSectionComment(key, true); + case errorTag: + return object.name == other.name && object.message == other.message; - this.writeSection(obj); + case numberTag: + // Treat `NaN` vs. `NaN` as equal. + return (object != +object) + ? other != +other + : object == +other; - this.writeSectionComment(key, false); - } - } + case regexpTag: + case stringTag: + // Coerce regexes to strings and treat strings primitives and string + // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details. + return object == (other + ''); + } + return false; } -pbxWriter.prototype.writeArray = function (arr, name) { - var i, entry; +module.exports = equalByTag; - this.write("%s = (\n", name); - this.indentLevel++; - for (i=0; i < arr.length; i++) { - entry = arr[i] +/***/ }), +/* 90 */ +/***/ (function(module, exports, __webpack_require__) { - if (entry.value && entry.comment) { - this.write('%s /* %s */,\n', entry.value, entry.comment); - } else if (isObject(entry)) { - this.write('{\n'); - this.indentLevel++; - - this.writeObject(entry); +var keys = __webpack_require__(8); - this.indentLevel--; - this.write('},\n'); - } else { - this.write('%s,\n', entry); - } +/** Used for native method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * A specialized version of `baseIsEqualDeep` for objects with support for + * partial deep comparisons. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Function} [customizer] The function to customize comparing values. + * @param {boolean} [isLoose] Specify performing partial comparisons. + * @param {Array} [stackA] Tracks traversed `value` objects. + * @param {Array} [stackB] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) { + var objProps = keys(object), + objLength = objProps.length, + othProps = keys(other), + othLength = othProps.length; + + if (objLength != othLength && !isLoose) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) { + return false; } + } + var skipCtor = isLoose; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], + othValue = other[key], + result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined; - this.indentLevel--; - this.write(");\n"); -} + // Recursively compare objects (susceptible to call stack limits). + if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) { + return false; + } + skipCtor || (skipCtor = key == 'constructor'); + } + if (!skipCtor) { + var objCtor = object.constructor, + othCtor = other.constructor; -pbxWriter.prototype.writeSectionComment = function (name, begin) { - if (begin) { - this.writeFlush("/* Begin %s section */\n", name) - } else { // end - this.writeFlush("/* End %s section */\n", name) + // Non `Object` object instances with different constructors are not equal. + if (objCtor != othCtor && + ('constructor' in object && 'constructor' in other) && + !(typeof objCtor == 'function' && objCtor instanceof objCtor && + typeof othCtor == 'function' && othCtor instanceof othCtor)) { + return false; } + } + return true; } -pbxWriter.prototype.writeSection = function (section) { - var key, obj, cmt; - - // section should only contain objects - for (key in section) { - if (COMMENT_KEY.test(key)) continue; +module.exports = equalObjects; - cmt = comment(key, section); - obj = section[key] - if (obj.isa == 'PBXBuildFile' || obj.isa == 'PBXFileReference') { - this.writeInlineObject(key, cmt, obj); - } else { - if (cmt) { - this.write("%s /* %s */ = {\n", key, cmt); - } else { - this.write("%s = {\n", key); - } +/***/ }), +/* 91 */ +/***/ (function(module, exports, __webpack_require__) { - this.indentLevel++ +var isStrictComparable = __webpack_require__(34), + pairs = __webpack_require__(99); - this.writeObject(obj) +/** + * Gets the propery names, values, and compare flags of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the match data of `object`. + */ +function getMatchData(object) { + var result = pairs(object), + length = result.length; - this.indentLevel-- - this.write("};\n"); - } - } + while (length--) { + result[length][2] = isStrictComparable(result[length][1]); + } + return result; } -pbxWriter.prototype.writeInlineObject = function (n, d, r) { - var output = []; +module.exports = getMatchData; - var inlineObjectHelper = function (name, desc, ref) { - var key, cmt, obj; - if (desc) { - output.push(f("%s /* %s */ = {", name, desc)); - } else { - output.push(f("%s = {", name)); - } +/***/ }), +/* 92 */ +/***/ (function(module, exports, __webpack_require__) { - for (key in ref) { - if (COMMENT_KEY.test(key)) continue; +var isArguments = __webpack_require__(16), + isArray = __webpack_require__(3), + isIndex = __webpack_require__(14), + isLength = __webpack_require__(7), + keysIn = __webpack_require__(98); - cmt = comment(key, ref); - obj = ref[key]; +/** Used for native method references. */ +var objectProto = Object.prototype; - if (isArray(obj)) { - output.push(f("%s = (", key)); - - for (var i=0; i < obj.length; i++) { - output.push(f("%s, ", obj[i])) - } +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; - output.push("); "); - } else if (isObject(obj)) { - inlineObjectHelper(key, cmt, obj) - } else if (cmt) { - output.push(f("%s = %s /* %s */; ", key, obj, cmt)) - } else { - output.push(f("%s = %s; ", key, obj)) - } - } +/** + * A fallback implementation of `Object.keys` which creates an array of the + * own enumerable property names of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function shimKeys(object) { + var props = keysIn(object), + propsLength = props.length, + length = propsLength && object.length; - output.push("}; "); + var allowIndexes = !!length && isLength(length) && + (isArray(object) || isArguments(object)); + + var index = -1, + result = []; + + while (++index < propsLength) { + var key = props[index]; + if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) { + result.push(key); } + } + return result; +} - inlineObjectHelper(n, d, r); +module.exports = shimKeys; - this.write("%s\n", output.join('').trim()); + +/***/ }), +/* 93 */ +/***/ (function(module, exports, __webpack_require__) { + +var isArguments = __webpack_require__(16), + isArray = __webpack_require__(3), + isArrayLike = __webpack_require__(10), + isFunction = __webpack_require__(11), + isObjectLike = __webpack_require__(4), + isString = __webpack_require__(95), + keys = __webpack_require__(8); + +/** + * Checks if `value` is empty. A value is considered empty unless it's an + * `arguments` object, array, string, or jQuery-like collection with a length + * greater than `0` or an object with own enumerable properties. + * + * @static + * @memberOf _ + * @category Lang + * @param {Array|Object|string} value The value to inspect. + * @returns {boolean} Returns `true` if `value` is empty, else `false`. + * @example + * + * _.isEmpty(null); + * // => true + * + * _.isEmpty(true); + * // => true + * + * _.isEmpty(1); + * // => true + * + * _.isEmpty([1, 2, 3]); + * // => false + * + * _.isEmpty({ 'a': 1 }); + * // => false + */ +function isEmpty(value) { + if (value == null) { + return true; + } + if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) || + (isObjectLike(value) && isFunction(value.splice)))) { + return !value.length; + } + return !keys(value).length; } -module.exports = pbxWriter; +module.exports = isEmpty; -/***/ }, -/* 100 */ -/***/ function(module, exports, __webpack_require__) { +/***/ }), +/* 94 */ +/***/ (function(module, exports, __webpack_require__) { -var __WEBPACK_AMD_DEFINE_RESULT__;// uuid.js -// -// Copyright (c) 2010-2012 Robert Kieffer -// MIT License - http://opensource.org/licenses/mit-license.php +var isFunction = __webpack_require__(11), + isObjectLike = __webpack_require__(4); -/*global window, require, define */ -(function(_window) { - 'use strict'; +/** Used to detect host constructors (Safari > 5). */ +var reIsHostCtor = /^\[object .+?Constructor\]$/; - // Unique ID creation requires a high quality random # generator. We feature - // detect to determine the best RNG source, normalizing to a function that - // returns 128-bits of randomness, since that's what's usually required - var _rng, _mathRNG, _nodeRNG, _whatwgRNG, _previousRoot; +/** Used for native method references. */ +var objectProto = Object.prototype; - function setupBrowser() { - // Allow for MSIE11 msCrypto - var _crypto = _window.crypto || _window.msCrypto; +/** Used to resolve the decompiled source of functions. */ +var fnToString = Function.prototype.toString; - if (!_rng && _crypto && _crypto.getRandomValues) { - // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto - // - // Moderately fast, high quality - try { - var _rnds8 = new Uint8Array(16); - _whatwgRNG = _rng = function whatwgRNG() { - _crypto.getRandomValues(_rnds8); - return _rnds8; - }; - _rng(); - } catch(e) {} - } +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; - if (!_rng) { - // Math.random()-based (RNG) - // - // If all else fails, use Math.random(). It's fast, but is of unspecified - // quality. - var _rnds = new Array(16); - _mathRNG = _rng = function() { - for (var i = 0, r; i < 16; i++) { - if ((i & 0x03) === 0) { r = Math.random() * 0x100000000; } - _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; - } +/** Used to detect if a method is native. */ +var reIsNative = RegExp('^' + + fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' +); - return _rnds; - }; - if ('undefined' !== typeof console && console.warn) { - console.warn("[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()"); - } - } +/** + * Checks if `value` is a native function. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, else `false`. + * @example + * + * _.isNative(Array.prototype.push); + * // => true + * + * _.isNative(_); + * // => false + */ +function isNative(value) { + if (value == null) { + return false; } - - function setupNode() { - // Node.js crypto-based RNG - http://nodejs.org/docs/v0.6.2/api/crypto.html - // - // Moderately fast, high quality - if (true) { - try { - var _rb = __webpack_require__(104).randomBytes; - _nodeRNG = _rng = _rb && function() {return _rb(16);}; - _rng(); - } catch(e) {} - } + if (isFunction(value)) { + return reIsNative.test(fnToString.call(value)); } + return isObjectLike(value) && reIsHostCtor.test(value); +} - if (_window) { - setupBrowser(); - } else { - setupNode(); - } +module.exports = isNative; - // Buffer class to use - var BufferClass = ('function' === typeof Buffer) ? Buffer : Array; - // Maps for number <-> hex string conversion - var _byteToHex = []; - var _hexToByte = {}; - for (var i = 0; i < 256; i++) { - _byteToHex[i] = (i + 0x100).toString(16).substr(1); - _hexToByte[_byteToHex[i]] = i; - } +/***/ }), +/* 95 */ +/***/ (function(module, exports, __webpack_require__) { - // **`parse()` - Parse a UUID into it's component bytes** - function parse(s, buf, offset) { - var i = (buf && offset) || 0, ii = 0; +var isObjectLike = __webpack_require__(4); - buf = buf || []; - s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) { - if (ii < 16) { // Don't overflow! - buf[i + ii++] = _hexToByte[oct]; - } - }); +/** `Object#toString` result references. */ +var stringTag = '[object String]'; - // Zero out remaining bytes if string was short - while (ii < 16) { - buf[i + ii++] = 0; - } +/** Used for native method references. */ +var objectProto = Object.prototype; - return buf; - } +/** + * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * of values. + */ +var objToString = objectProto.toString; - // **`unparse()` - Convert UUID byte array (ala parse()) into a string** - function unparse(buf, offset) { - var i = offset || 0, bth = _byteToHex; - return bth[buf[i++]] + bth[buf[i++]] + - bth[buf[i++]] + bth[buf[i++]] + '-' + - bth[buf[i++]] + bth[buf[i++]] + '-' + - bth[buf[i++]] + bth[buf[i++]] + '-' + - bth[buf[i++]] + bth[buf[i++]] + '-' + - bth[buf[i++]] + bth[buf[i++]] + - bth[buf[i++]] + bth[buf[i++]] + - bth[buf[i++]] + bth[buf[i++]]; - } +/** + * Checks if `value` is classified as a `String` primitive or object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isString('abc'); + * // => true + * + * _.isString(1); + * // => false + */ +function isString(value) { + return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag); +} - // **`v1()` - Generate time-based UUID** - // - // Inspired by https://github.com/LiosK/UUID.js - // and http://docs.python.org/library/uuid.html +module.exports = isString; - // random #'s we need to init node and clockseq - var _seedBytes = _rng(); - // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) - var _nodeId = [ - _seedBytes[0] | 0x01, - _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5] - ]; +/***/ }), +/* 96 */ +/***/ (function(module, exports, __webpack_require__) { - // Per 4.2.2, randomize (14 bit) clockseq - var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff; +var isLength = __webpack_require__(7), + isObjectLike = __webpack_require__(4); - // Previous uuid creation time - var _lastMSecs = 0, _lastNSecs = 0; +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + funcTag = '[object Function]', + mapTag = '[object Map]', + numberTag = '[object Number]', + objectTag = '[object Object]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + weakMapTag = '[object WeakMap]'; - // See https://github.com/broofa/node-uuid for API details - function v1(options, buf, offset) { - var i = buf && offset || 0; - var b = buf || []; +var arrayBufferTag = '[object ArrayBuffer]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; - options = options || {}; +/** Used to identify `toStringTag` values of typed arrays. */ +var typedArrayTags = {}; +typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = +typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = +typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = +typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = +typedArrayTags[uint32Tag] = true; +typedArrayTags[argsTag] = typedArrayTags[arrayTag] = +typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = +typedArrayTags[dateTag] = typedArrayTags[errorTag] = +typedArrayTags[funcTag] = typedArrayTags[mapTag] = +typedArrayTags[numberTag] = typedArrayTags[objectTag] = +typedArrayTags[regexpTag] = typedArrayTags[setTag] = +typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; - var clockseq = (options.clockseq != null) ? options.clockseq : _clockseq; +/** Used for native method references. */ +var objectProto = Object.prototype; + +/** + * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * of values. + */ +var objToString = objectProto.toString; + +/** + * Checks if `value` is classified as a typed array. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isTypedArray(new Uint8Array); + * // => true + * + * _.isTypedArray([]); + * // => false + */ +function isTypedArray(value) { + return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)]; +} - // UUID timestamps are 100 nano-second units since the Gregorian epoch, - // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so - // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' - // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. - var msecs = (options.msecs != null) ? options.msecs : new Date().getTime(); +module.exports = isTypedArray; - // Per 4.2.1.2, use count of uuid's generated during the current clock - // cycle to simulate higher resolution clock - var nsecs = (options.nsecs != null) ? options.nsecs : _lastNSecs + 1; - // Time since last uuid creation (in msecs) - var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000; +/***/ }), +/* 97 */ +/***/ (function(module, exports, __webpack_require__) { - // Per 4.2.1.2, Bump clockseq on clock regression - if (dt < 0 && options.clockseq == null) { - clockseq = clockseq + 1 & 0x3fff; - } +var assignWith = __webpack_require__(70), + baseAssign = __webpack_require__(26), + createAssigner = __webpack_require__(85); - // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new - // time interval - if ((dt < 0 || msecs > _lastMSecs) && options.nsecs == null) { - nsecs = 0; - } +/** + * Assigns own enumerable properties of source object(s) to the destination + * object. Subsequent sources overwrite property assignments of previous sources. + * If `customizer` is provided it's invoked to produce the assigned values. + * The `customizer` is bound to `thisArg` and invoked with five arguments: + * (objectValue, sourceValue, key, object, source). + * + * **Note:** This method mutates `object` and is based on + * [`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign). + * + * @static + * @memberOf _ + * @alias extend + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @param {Function} [customizer] The function to customize assigned values. + * @param {*} [thisArg] The `this` binding of `customizer`. + * @returns {Object} Returns `object`. + * @example + * + * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' }); + * // => { 'user': 'fred', 'age': 40 } + * + * // using a customizer callback + * var defaults = _.partialRight(_.assign, function(value, other) { + * return _.isUndefined(value) ? other : value; + * }); + * + * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); + * // => { 'user': 'barney', 'age': 36 } + */ +var assign = createAssigner(function(object, source, customizer) { + return customizer + ? assignWith(object, source, customizer) + : baseAssign(object, source); +}); - // Per 4.2.1.2 Throw error if too many uuids are requested - if (nsecs >= 10000) { - throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec'); - } +module.exports = assign; - _lastMSecs = msecs; - _lastNSecs = nsecs; - _clockseq = clockseq; - // Per 4.1.4 - Convert from unix epoch to Gregorian epoch - msecs += 12219292800000; +/***/ }), +/* 98 */ +/***/ (function(module, exports, __webpack_require__) { - // `time_low` - var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; - b[i++] = tl >>> 24 & 0xff; - b[i++] = tl >>> 16 & 0xff; - b[i++] = tl >>> 8 & 0xff; - b[i++] = tl & 0xff; +var isArguments = __webpack_require__(16), + isArray = __webpack_require__(3), + isIndex = __webpack_require__(14), + isLength = __webpack_require__(7), + isObject = __webpack_require__(0); - // `time_mid` - var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff; - b[i++] = tmh >>> 8 & 0xff; - b[i++] = tmh & 0xff; +/** Used for native method references. */ +var objectProto = Object.prototype; - // `time_high_and_version` - b[i++] = tmh >>> 24 & 0xf | 0x10; // include version - b[i++] = tmh >>> 16 & 0xff; +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; - // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) - b[i++] = clockseq >>> 8 | 0x80; +/** + * Creates an array of the own and inherited enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keysIn(new Foo); + * // => ['a', 'b', 'c'] (iteration order is not guaranteed) + */ +function keysIn(object) { + if (object == null) { + return []; + } + if (!isObject(object)) { + object = Object(object); + } + var length = object.length; + length = (length && isLength(length) && + (isArray(object) || isArguments(object)) && length) || 0; - // `clock_seq_low` - b[i++] = clockseq & 0xff; + var Ctor = object.constructor, + index = -1, + isProto = typeof Ctor == 'function' && Ctor.prototype === object, + result = Array(length), + skipIndexes = length > 0; - // `node` - var node = options.node || _nodeId; - for (var n = 0; n < 6; n++) { - b[i + n] = node[n]; + while (++index < length) { + result[index] = (index + ''); + } + for (var key in object) { + if (!(skipIndexes && isIndex(key, length)) && + !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { + result.push(key); } - - return buf ? buf : unparse(b); } + return result; +} - // **`v4()` - Generate random UUID** +module.exports = keysIn; - // See https://github.com/broofa/node-uuid for API details - function v4(options, buf, offset) { - // Deprecated - 'format' argument, as supported in v1.2 - var i = buf && offset || 0; - if (typeof(options) === 'string') { - buf = (options === 'binary') ? new BufferClass(16) : null; - options = null; - } - options = options || {}; +/***/ }), +/* 99 */ +/***/ (function(module, exports, __webpack_require__) { - var rnds = options.random || (options.rng || _rng)(); +var keys = __webpack_require__(8), + toObject = __webpack_require__(2); - // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` - rnds[6] = (rnds[6] & 0x0f) | 0x40; - rnds[8] = (rnds[8] & 0x3f) | 0x80; +/** + * Creates a two dimensional array of the key-value pairs for `object`, + * e.g. `[[key1, value1], [key2, value2]]`. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the new array of key-value pairs. + * @example + * + * _.pairs({ 'barney': 36, 'fred': 40 }); + * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed) + */ +function pairs(object) { + object = toObject(object); - // Copy bytes to buffer, if provided - if (buf) { - for (var ii = 0; ii < 16; ii++) { - buf[i + ii] = rnds[ii]; - } - } + var index = -1, + props = keys(object), + length = props.length, + result = Array(length); - return buf || unparse(rnds); + while (++index < length) { + var key = props[index]; + result[index] = [key, object[key]]; } + return result; +} - // Export public API - var uuid = v4; - uuid.v1 = v1; - uuid.v4 = v4; - uuid.parse = parse; - uuid.unparse = unparse; - uuid.BufferClass = BufferClass; - uuid._rng = _rng; - uuid._mathRNG = _mathRNG; - uuid._nodeRNG = _nodeRNG; - uuid._whatwgRNG = _whatwgRNG; +module.exports = pairs; - if (('undefined' !== typeof module) && module.exports) { - // Publish as node.js module - module.exports = uuid; - } else if (true) { - // Publish as AMD module - !(__WEBPACK_AMD_DEFINE_RESULT__ = function() {return uuid;}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); +/***/ }), +/* 100 */ +/***/ (function(module, exports, __webpack_require__) { - } else { - // Publish as global (in browsers) - _previousRoot = _window.uuid; +var baseProperty = __webpack_require__(29), + basePropertyDeep = __webpack_require__(82), + isKey = __webpack_require__(33); - // **`noConflict()` - (browser only) to reset global 'uuid' var** - uuid.noConflict = function() { - _window.uuid = _previousRoot; - return uuid; - }; +/** + * Creates a function that returns the property value at `path` on a + * given object. + * + * @static + * @memberOf _ + * @category Utility + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new function. + * @example + * + * var objects = [ + * { 'a': { 'b': { 'c': 2 } } }, + * { 'a': { 'b': { 'c': 1 } } } + * ]; + * + * _.map(objects, _.property('a.b.c')); + * // => [2, 1] + * + * _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c'); + * // => [1, 2] + */ +function property(path) { + return isKey(path) ? baseProperty(path) : basePropertyDeep(path); +} - _window.uuid = uuid; - } -})('undefined' !== typeof window ? window : null); +module.exports = property; -/***/ }, +/***/ }), /* 101 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { function DOMParser(options){ this.options = options ||{locator:{}}; @@ -12053,9 +12054,9 @@ function appendElement (hander,node) { //} -/***/ }, +/***/ }), /* 102 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { //[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] //[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040] @@ -12692,21 +12693,21 @@ exports.XMLReader = XMLReader; -/***/ }, +/***/ }), /* 103 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { module.exports = require("child_process"); -/***/ }, +/***/ }), /* 104 */ -/***/ function(module, exports) { +/***/ (function(module, exports) { module.exports = require("crypto"); -/***/ }, +/***/ }), /* 105 */ -/***/ function(module, exports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -12744,6 +12745,8 @@ exports.default = function (context) { var bridgingHeaderPath = void 0; var bridgingHeaderContent = void 0; + var swift2objHeaderPath = void 0; + var swift2objcHeaderContent = void 0; var projectName = void 0; var projectPath = void 0; var pluginsPath = void 0; @@ -12783,7 +12786,19 @@ exports.default = function (context) { // Cordova/CDV.h import. bridgingHeaderContent = ['//', '// Use this file to import your target\'s public headers that you would like to expose to Swift.', '//', '#import ']; _fs2.default.writeFileSync(bridgingHeaderPath, bridgingHeaderContent.join('\n'), { encoding: 'utf-8', flag: 'w' }); - xcodeProject.addHeaderFile('Bridging-Header.h'); + xcodeProject.addHeaderFile('Bridging-Header.h', null); + } + + swift2objHeaderPath = _path2.default.posix.join(projectPath, 'Plugins', 'Swift2Objc-Header.h'); + + try { + _fs2.default.statSync(swift2objHeaderPath); + } catch (err) { + // If the bridging header doesn't exist, we create it with the minimum + // ProductModuleName-Swift.h import. + swift2objcHeaderContent = ['//', '// Use this file to import your projects\'s generated swift-header to expose Swift to Objective-C.', '//', '#import "' + projectName.replace(' ', '_') + '-Swift.h"']; + _fs2.default.writeFileSync(swift2objHeaderPath, swift2objcHeaderContent.join('\n'), { encoding: 'utf-8', flag: 'w' }); + xcodeProject.addHeaderFile('Swift2Objc-Header.h'); } buildConfigs = xcodeProject.pbxXCBuildConfigurationSection(); @@ -12912,6 +12927,6 @@ var getBridgingHeaderPath = function getBridgingHeaderPath(context, projectPath, }; module.exports = exports['default']; -/***/ } +/***/ }) /******/ ]); }); \ No newline at end of file diff --git a/src/main.js b/src/main.js index a61b2e6..4003c31 100644 --- a/src/main.js +++ b/src/main.js @@ -36,6 +36,8 @@ export default (context) => { let bridgingHeaderPath; let bridgingHeaderContent; + let swift2objHeaderPath; + let swift2objcHeaderContent; let projectName; let projectPath; let pluginsPath; @@ -78,7 +80,22 @@ export default (context) => { '//', '#import ' ]; fs.writeFileSync(bridgingHeaderPath, bridgingHeaderContent.join('\n'), { encoding: 'utf-8', flag: 'w' }); - xcodeProject.addHeaderFile('Bridging-Header.h'); + xcodeProject.addHeaderFile('Bridging-Header.h', null, ); + } + + swift2objHeaderPath = path.posix.join(projectPath, 'Plugins', 'Swift2Objc-Header.h'); + + try { + fs.statSync(swift2objHeaderPath); + } catch (err) { + // If the bridging header doesn't exist, we create it with the minimum + // ProductModuleName-Swift.h import. + swift2objcHeaderContent = [ '//', + '// Use this file to import your projects\'s generated swift-header to expose Swift to Objective-C.', + '//', + '#import "' + projectName.replace(' ', '_') + '-Swift.h"' ]; + fs.writeFileSync(swift2objHeaderPath, swift2objcHeaderContent.join('\n'), { encoding: 'utf-8', flag: 'w' }); + xcodeProject.addHeaderFile('Swift2Objc-Header.h'); } buildConfigs = xcodeProject.pbxXCBuildConfigurationSection();