From 2b4f540f52357517f048f2c11a8ca88b88b64f31 Mon Sep 17 00:00:00 2001 From: Leonardo Rossetti Date: Wed, 26 Apr 2017 10:07:46 -0300 Subject: [PATCH] npm build --- add-swift-support.js | 12914 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 12914 insertions(+) create mode 100644 add-swift-support.js diff --git a/add-swift-support.js b/add-swift-support.js new file mode 100644 index 0000000..589a686 --- /dev/null +++ b/add-swift-support.js @@ -0,0 +1,12914 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("util"), require("fs"), require("path"), require("events"), require("stream"), require("child_process"), (function webpackLoadOptionalExternalModule() { try { return require("crypto"); } catch(e) {} }())); + else if(typeof define === 'function' && define.amd) + define(["util", "fs", "path", "events", "stream", "child_process", "crypto"], factory); + else { + var a = typeof exports === 'object' ? factory(require("util"), require("fs"), require("path"), require("events"), require("stream"), require("child_process"), (function webpackLoadOptionalExternalModule() { try { return require("crypto"); } catch(e) {} }())) : factory(root["util"], root["fs"], root["path"], root["events"], root["stream"], root["child_process"], root["crypto"]); + for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; + } +})(this, function(__WEBPACK_EXTERNAL_MODULE_5__, __WEBPACK_EXTERNAL_MODULE_9__, __WEBPACK_EXTERNAL_MODULE_12__, __WEBPACK_EXTERNAL_MODULE_38__, __WEBPACK_EXTERNAL_MODULE_39__, __WEBPACK_EXTERNAL_MODULE_104__, __WEBPACK_EXTERNAL_MODULE_105__) { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // identity function for calling harmony imports with the correct context +/******/ __webpack_require__.i = function(value) { return value; }; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 41); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + +/** + * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. + * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(1); + * // => false + */ +function isObject(value) { + // Avoid a V8 JIT bug in Chrome 19-20. + // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. + var type = typeof value; + return !!value && (type == 'object' || type == 'function'); +} + +module.exports = isObject; + + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +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 + * `properties` object is provided its own enumerable properties are assigned + * to the created object. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} prototype The object to inherit from. + * @param {Object} [properties] The properties to assign to the object. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Object} Returns the new object. + * @example + * + * function Shape() { + * this.x = 0; + * this.y = 0; + * } + * + * function Circle() { + * Shape.call(this); + * } + * + * Circle.prototype = _.create(Shape.prototype, { + * 'constructor': Circle + * }); + * + * var circle = new Circle; + * circle instanceof Circle; + * // => true + * + * circle instanceof Shape; + * // => true + */ +function create(prototype, properties, guard) { + var result = baseCreate(prototype); + if (guard && isIterateeCall(prototype, properties, guard)) { + properties = undefined; + } + return properties ? baseAssign(result, properties) : result; +} + +module.exports = create; + + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + +var isObject = __webpack_require__(0); + +/** + * Converts `value` to an object if it's not one. + * + * @private + * @param {*} value The value to process. + * @returns {Object} Returns the object. + */ +function toObject(value) { + return isObject(value) ? value : Object(value); +} + +module.exports = toObject; + + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +var getNative = __webpack_require__(32), + isLength = __webpack_require__(7), + isObjectLike = __webpack_require__(4); + +/** `Object#toString` result references. */ +var arrayTag = '[object Array]'; + +/** 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; + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeIsArray = getNative(Array, 'isArray'); + +/** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(function() { return arguments; }()); + * // => false + */ +var isArray = nativeIsArray || function(value) { + return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag; +}; + +module.exports = isArray; + + +/***/ }), +/* 4 */ +/***/ (function(module, exports) { + +/** + * Checks if `value` is object-like. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + */ +function isObjectLike(value) { + return !!value && typeof value == 'object'; +} + +module.exports = isObjectLike; + + +/***/ }), +/* 5 */ +/***/ (function(module, exports) { + +module.exports = require("util"); + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLElement, XMLNode, XMLRaw, XMLText, isEmpty, isFunction, isObject, + hasProp = {}.hasOwnProperty; + + isObject = __webpack_require__(0); + + isFunction = __webpack_require__(11); + + isEmpty = __webpack_require__(93); + + XMLElement = null; + + XMLCData = null; + + XMLComment = null; + + XMLDeclaration = null; + + XMLDocType = null; + + XMLRaw = null; + + XMLText = null; + + module.exports = XMLNode = (function() { + function XMLNode(parent) { + this.parent = parent; + this.options = this.parent.options; + this.stringify = this.parent.stringify; + if (XMLElement === null) { + 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); + } + } + + XMLNode.prototype.element = function(name, attributes, text) { + var childNode, item, j, k, key, lastChild, len, len1, ref, val; + lastChild = null; + if (attributes == null) { + attributes = {}; + } + attributes = attributes.valueOf(); + if (!isObject(attributes)) { + ref = [attributes, text], text = ref[0], attributes = ref[1]; + } + if (name != null) { + name = name.valueOf(); + } + if (Array.isArray(name)) { + for (j = 0, len = name.length; j < len; j++) { + item = name[j]; + lastChild = this.element(item); + } + } else if (isFunction(name)) { + lastChild = this.element(name.apply()); + } else if (isObject(name)) { + for (key in name) { + if (!hasProp.call(name, key)) continue; + val = name[key]; + if (isFunction(val)) { + val = val.apply(); + } + if ((isObject(val)) && (isEmpty(val))) { + val = null; + } + if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) { + lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val); + } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && key.indexOf(this.stringify.convertPIKey) === 0) { + lastChild = this.instruction(key.substr(this.stringify.convertPIKey.length), val); + } else if (Array.isArray(val)) { + for (k = 0, len1 = val.length; k < len1; k++) { + item = val[k]; + childNode = {}; + childNode[key] = item; + lastChild = this.element(childNode); + } + } else if (isObject(val)) { + lastChild = this.element(key); + lastChild.element(val); + } else { + lastChild = this.element(key, val); + } + } + } else { + if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) { + lastChild = this.text(text); + } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) { + lastChild = this.cdata(text); + } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) { + lastChild = this.comment(text); + } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) { + lastChild = this.raw(text); + } else { + lastChild = this.node(name, attributes, text); + } + } + if (lastChild == null) { + throw new Error("Could not create any elements with: " + name); + } + return lastChild; + }; + + XMLNode.prototype.insertBefore = function(name, attributes, text) { + var child, i, removed; + if (this.isRoot) { + throw new Error("Cannot insert elements at root level"); + } + i = this.parent.children.indexOf(this); + removed = this.parent.children.splice(i); + child = this.parent.element(name, attributes, text); + Array.prototype.push.apply(this.parent.children, removed); + return child; + }; + + XMLNode.prototype.insertAfter = function(name, attributes, text) { + var child, i, removed; + if (this.isRoot) { + throw new Error("Cannot insert elements at root level"); + } + i = this.parent.children.indexOf(this); + removed = this.parent.children.splice(i + 1); + child = this.parent.element(name, attributes, text); + Array.prototype.push.apply(this.parent.children, removed); + return child; + }; + + XMLNode.prototype.remove = function() { + var i, ref; + if (this.isRoot) { + throw new Error("Cannot remove the root element"); + } + i = this.parent.children.indexOf(this); + [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref = [])), ref; + return this.parent; + }; + + XMLNode.prototype.node = function(name, attributes, text) { + var child, ref; + if (name != null) { + name = name.valueOf(); + } + if (attributes == null) { + attributes = {}; + } + attributes = attributes.valueOf(); + if (!isObject(attributes)) { + ref = [attributes, text], text = ref[0], attributes = ref[1]; + } + child = new XMLElement(this, name, attributes); + if (text != null) { + child.text(text); + } + this.children.push(child); + return child; + }; + + XMLNode.prototype.text = function(value) { + var child; + child = new XMLText(this, value); + this.children.push(child); + return this; + }; + + XMLNode.prototype.cdata = function(value) { + var child; + child = new XMLCData(this, value); + this.children.push(child); + return this; + }; + + XMLNode.prototype.comment = function(value) { + var child; + child = new XMLComment(this, value); + this.children.push(child); + return this; + }; + + XMLNode.prototype.raw = function(value) { + var child; + child = new XMLRaw(this, value); + this.children.push(child); + return this; + }; + + XMLNode.prototype.declaration = function(version, encoding, standalone) { + var doc, xmldec; + doc = this.document(); + xmldec = new XMLDeclaration(doc, version, encoding, standalone); + doc.xmldec = xmldec; + return doc.root(); + }; + + XMLNode.prototype.doctype = function(pubID, sysID) { + var doc, doctype; + doc = this.document(); + doctype = new XMLDocType(doc, pubID, sysID); + doc.doctype = doctype; + return doctype; + }; + + XMLNode.prototype.up = function() { + if (this.isRoot) { + throw new Error("The root node has no parent. Use doc() if you need to get the document object."); + } + return this.parent; + }; + + XMLNode.prototype.root = function() { + var child; + if (this.isRoot) { + return this; + } + child = this.parent; + while (!child.isRoot) { + child = child.parent; + } + return child; + }; + + XMLNode.prototype.document = function() { + return this.root().documentObject; + }; + + XMLNode.prototype.end = function(options) { + return this.document().toString(options); + }; + + XMLNode.prototype.prev = function() { + var i; + if (this.isRoot) { + throw new Error("Root node has no siblings"); + } + i = this.parent.children.indexOf(this); + if (i < 1) { + throw new Error("Already at the first node"); + } + return this.parent.children[i - 1]; + }; + + XMLNode.prototype.next = function() { + var i; + if (this.isRoot) { + throw new Error("Root node has no siblings"); + } + i = this.parent.children.indexOf(this); + if (i === -1 || i === this.parent.children.length - 1) { + throw new Error("Already at the last node"); + } + return this.parent.children[i + 1]; + }; + + XMLNode.prototype.importXMLBuilder = function(xmlbuilder) { + var clonedRoot; + clonedRoot = xmlbuilder.root().clone(); + clonedRoot.parent = this; + clonedRoot.isRoot = false; + this.children.push(clonedRoot); + return this; + }; + + XMLNode.prototype.ele = function(name, attributes, text) { + return this.element(name, attributes, text); + }; + + XMLNode.prototype.nod = function(name, attributes, text) { + return this.node(name, attributes, text); + }; + + XMLNode.prototype.txt = function(value) { + return this.text(value); + }; + + XMLNode.prototype.dat = function(value) { + return this.cdata(value); + }; + + XMLNode.prototype.com = function(value) { + return this.comment(value); + }; + + XMLNode.prototype.doc = function() { + return this.document(); + }; + + XMLNode.prototype.dec = function(version, encoding, standalone) { + return this.declaration(version, encoding, standalone); + }; + + XMLNode.prototype.dtd = function(pubID, sysID) { + return this.doctype(pubID, sysID); + }; + + XMLNode.prototype.e = function(name, attributes, text) { + return this.element(name, attributes, text); + }; + + XMLNode.prototype.n = function(name, attributes, text) { + return this.node(name, attributes, text); + }; + + XMLNode.prototype.t = function(value) { + return this.text(value); + }; + + XMLNode.prototype.d = function(value) { + return this.cdata(value); + }; + + XMLNode.prototype.c = function(value) { + return this.comment(value); + }; + + XMLNode.prototype.r = function(value) { + return this.raw(value); + }; + + XMLNode.prototype.u = function() { + return this.up(); + }; + + return XMLNode; + + })(); + +}).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) { + +module.exports = require("fs"); + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + +var getLength = __webpack_require__(31), + isLength = __webpack_require__(7); + +/** + * Checks if `value` is array-like. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + */ +function isArrayLike(value) { + return value != null && isLength(getLength(value)); +} + +module.exports = isArrayLike; + + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + +var isObject = __webpack_require__(0); + +/** `Object#toString` result references. */ +var funcTag = '[object Function]'; + +/** 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 `Function` object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ +function isFunction(value) { + // The use of `Object#toString` avoids issues with the `typeof` operator + // in older versions of Chrome and Safari which return 'function' for regexes + // and Safari 8 which returns 'object' for typed array constructors. + return isObject(value) && objToString.call(value) == funcTag; +} + +module.exports = isFunction; + + +/***/ }), +/* 12 */ +/***/ (function(module, exports) { + +module.exports = require("path"); + +/***/ }), +/* 13 */ +/***/ (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+$/; + +/** + * 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 index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ +function isIndex(value, length) { + value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1; + length = length == null ? MAX_SAFE_INTEGER : length; + return value > -1 && value % 1 == 0 && value < length; +} + +module.exports = isIndex; + + +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + +var isArrayLike = __webpack_require__(10), + isIndex = __webpack_require__(14), + isObject = __webpack_require__(0); + +/** + * Checks if the provided arguments are from an iteratee call. + * + * @private + * @param {*} value The potential iteratee value argument. + * @param {*} index The potential iteratee index or key argument. + * @param {*} object The potential iteratee object argument. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`. + */ +function isIterateeCall(value, index, object) { + if (!isObject(object)) { + return false; + } + var type = typeof index; + if (type == 'number' + ? (isArrayLike(object) && isIndex(index, object.length)) + : (type == 'string' && index in object)) { + var other = object[index]; + return value === value ? (value === other) : (other !== other); + } + return false; +} + +module.exports = isIterateeCall; + + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + +var isArrayLike = __webpack_require__(10), + isObjectLike = __webpack_require__(4); + +/** Used for native method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** Native method references. */ +var propertyIsEnumerable = objectProto.propertyIsEnumerable; + +/** + * Checks if `value` is classified as an `arguments` object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isArguments(function() { return arguments; }()); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false + */ +function isArguments(value) { + return isObjectLike(value) && isArrayLike(value) && + hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee'); +} + +module.exports = isArguments; + + +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { + +/* 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__(45), + fork = __webpack_require__(104).fork, + pbxWriter = __webpack_require__(44), + pbxFile = __webpack_require__(43), + fs = __webpack_require__(9), + parser = __webpack_require__(42), + plist = __webpack_require__(103), + COMMENT_KEY = /_comment$/ + +function pbxProject(filename) { + if (!(this instanceof pbxProject)) + return new pbxProject(filename); + + this.filepath = path.resolve(filename) +} + +util.inherits(pbxProject, EventEmitter) + +pbxProject.prototype.parse = function(cb) { + var worker = fork(__dirname + '/parseJob.js', [this.filepath]) + + 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 (cb) { + this.on('error', cb); + this.on('end', cb); + } + + return this; +} + +pbxProject.prototype.parseSync = function() { + var file_contents = fs.readFileSync(this.filepath, 'utf-8'); + + this.hash = parser.parse(file_contents); + return this; +} + +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; + + for (key in sections) { + section = sections[key] + uuids = uuids.concat(Object.keys(section)) + } + + uuids = uuids.filter(function(str) { + return !COMMENT_KEY.test(str) && str.length == 24; + }); + + return uuids; +} + +pbxProject.prototype.generateUuid = function() { + var id = uuid.v4() + .replace(/-/g, '') + .substr(0, 24) + .toUpperCase() + + if (this.allUuids().indexOf(id) >= 0) { + return this.generateUuid(); + } else { + return id; + } +} + +pbxProject.prototype.addPluginFile = function(path, opt) { + var file = new pbxFile(path, opt); + + file.plugin = true; // durr + correctForPluginsPath(file, this); + + // null is better for early errors + if (this.hasFile(file.path)) return null; + + file.fileRef = this.generateUuid(); + + this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToPluginsPbxGroup(file); // PBXGroup + + return file; +} + +pbxProject.prototype.removePluginFile = function(path, opt) { + var file = new pbxFile(path, opt); + correctForPluginsPath(file, this); + + this.removeFromPbxFileReferenceSection(file); // PBXFileReference + this.removeFromPluginsPbxGroup(file); // PBXGroup + + return file; +} + +pbxProject.prototype.addProductFile = function(targetPath, opt) { + var file = new pbxFile(targetPath, opt); + + 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; + + this.addToPbxFileReferenceSection(file); + this.addToProductsPbxGroup(file); // PBXGroup + + return file; +} + +pbxProject.prototype.removeProductFile = function(path, opt) { + var file = new pbxFile(path, opt); + + this.removeFromProductsPbxGroup(file); // PBXGroup + + return file; +} + +/** + * + * @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); + } + + if (!file) return false; + + file.target = opt ? opt.target : undefined; + file.uuid = this.generateUuid(); + + this.addToPbxBuildFileSection(file); // PBXBuildFile + this.addToPbxSourcesBuildPhase(file); // PBXSourcesBuildPhase + + return file; +} + +/** + * + * @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; +} + +/** + * + * @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); + } +} + +/** + * + * @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 || {}; + + var file; + + 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; + } + + file.uuid = this.generateUuid(); + file.target = opt ? opt.target : undefined; + + if (!opt.plugin) { + correctForResourcesPath(file, this); + file.fileRef = this.generateUuid(); + } + + 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 + } + + } + + return file; +} + +/** + * + * @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; + + 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 + } + } + 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; + } + + var file = new pbxFile(fpath, opt); + + file.uuid = this.generateUuid(); + file.fileRef = this.generateUuid(); + file.target = opt ? opt.target : undefined; + + if (this.hasFile(file.path)) return false; + + this.addToPbxBuildFileSection(file); // PBXBuildFile + this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToFrameworksPbxGroup(file); // PBXGroup + + if (link) { + this.addToPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase + } + + if (customFramework) { + this.addToFrameworkSearchPaths(file); + + if (embed) { + opt.embed = embed; + var embeddedFile = new pbxFile(fpath, opt); + + embeddedFile.uuid = this.generateUuid(); + embeddedFile.fileRef = file.fileRef; + + //keeping a separate PBXBuildFile entry for Embed Frameworks + this.addToPbxBuildFileSection(embeddedFile); // PBXBuildFile + + this.addToPbxEmbedFrameworksBuildPhase(embeddedFile); // PBXCopyFilesBuildPhase + + return embeddedFile; + } + } + + return file; +} + +pbxProject.prototype.removeFramework = function(fpath, opt) { + var embed = opt && opt.embed; + + if (opt) { + delete opt.embed; + } + + var file = new pbxFile(fpath, opt); + file.target = opt ? opt.target : undefined; + + this.removeFromPbxBuildFileSection(file); // PBXBuildFile + this.removeFromPbxFileReferenceSection(file); // PBXFileReference + this.removeFromFrameworksPbxGroup(file); // PBXGroup + this.removeFromPbxFrameworksBuildPhase(file); // PBXFrameworksBuildPhase + + if (opt && opt.customFramework) { + this.removeFromFrameworkSearchPaths(file); + } + + opt = opt || {}; + opt.embed = true; + var embeddedFile = new pbxFile(fpath, opt); + + embeddedFile.fileRef = file.fileRef; + + this.removeFromPbxBuildFileSection(embeddedFile); // PBXBuildFile + this.removeFromPbxEmbedFrameworksBuildPhase(embeddedFile); // PBXCopyFilesBuildPhase + + return file; +} + + +pbxProject.prototype.addCopyfile = function(fpath, opt) { + var file = new pbxFile(fpath, opt); + + // catch duplicates + if (this.hasFile(file.path)) { + file = this.hasFile(file.path); + } + + file.fileRef = file.uuid = this.generateUuid(); + file.target = opt ? opt.target : undefined; + + this.addToPbxBuildFileSection(file); // PBXBuildFile + this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToPbxCopyfilesBuildPhase(file); // PBXCopyFilesBuildPhase + + return file; +} + +pbxProject.prototype.pbxCopyfilesBuildPhaseObj = function(target) { + return this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Copy Files', target); +} + +pbxProject.prototype.addToPbxCopyfilesBuildPhase = function(file) { + var sources = this.buildPhaseObject('PBXCopyFilesBuildPhase', 'Copy Files', file.target); + sources.files.push(pbxBuildPhaseObj(file)); +} + +pbxProject.prototype.removeCopyfile = function(fpath, opt) { + var file = new pbxFile(fpath, opt); + file.target = opt ? opt.target : undefined; + + this.removeFromPbxBuildFileSection(file); // PBXBuildFile + this.removeFromPbxFileReferenceSection(file); // PBXFileReference + this.removeFromPbxCopyfilesBuildPhase(file); // PBXFrameworksBuildPhase + + return file; +} + +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; + } + } +} + +pbxProject.prototype.addStaticLibrary = function(path, opt) { + opt = opt || {}; + + var file; + + 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; + } + + file.uuid = this.generateUuid(); + file.target = opt ? opt.target : undefined; + + if (!opt.plugin) { + file.fileRef = this.generateUuid(); + this.addToPbxFileReferenceSection(file); // PBXFileReference + } + + 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); + + this.pbxBuildFileSection()[file.uuid] = pbxBuildFileObj(file); + this.pbxBuildFileSection()[commentKey] = pbxBuildFileComment(file); +} + +pbxProject.prototype.removeFromPbxBuildFileSection = function(file) { + var uuid; + + for (uuid in this.pbxBuildFileSection()) { + if (this.pbxBuildFileSection()[uuid].fileRef_comment == file.basename) { + file.uuid = uuid; + delete this.pbxBuildFileSection()[uuid]; + } + } + 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; + } + + 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)); + } + + if (groups) { + groups[pbxGroupUuid] = pbxGroup; + groups[commentKey] = name; + } + + return { uuid: pbxGroupUuid, pbxGroup: pbxGroup }; +} + +pbxProject.prototype.removePbxGroup = function (groupName) { + var section = this.hash.project.objects['PBXGroup'], + key, itemKey; + + 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]; + } + } +} + +pbxProject.prototype.addToPbxProjectSection = function(target) { + + var newTarget = { + value: target.uuid, + comment: pbxNativeTargetComment(target.pbxNativeTarget) + }; + + this.pbxProjectSection()[this.getFirstProject()['uuid']]['targets'].push(newTarget); +} + +pbxProject.prototype.addToPbxNativeTargetSection = function(target) { + var commentKey = f("%s_comment", target.uuid); + + this.pbxNativeTargetSection()[target.uuid] = target.pbxNativeTarget; + this.pbxNativeTargetSection()[commentKey] = target.pbxNativeTarget.name; +} + +pbxProject.prototype.addToPbxFileReferenceSection = function(file) { + var commentKey = f("%s_comment", file.fileRef); + + this.pbxFileReferenceSection()[file.fileRef] = pbxFileReferenceObj(file); + this.pbxFileReferenceSection()[commentKey] = pbxFileReferenceComment(file); +} + +pbxProject.prototype.removeFromPbxFileReferenceSection = function(file) { + + 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]; + } + + return file; +} + +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"); + } + + var commentKey = f("%s_comment", file.fileRef); + + 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)); +} + +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; + } + } +} + +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; + } + } +} + +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; + } + } +} + +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; + } +} + +pbxProject.prototype.addToProductsPbxGroup = function(file) { + var productsGroup = this.pbxGroupByName('Products'); + productsGroup.children.push(pbxGroupChild(file)); +} + +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)); +} + +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; + } + } +} + +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; + + 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)); +} + +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; + } + } +} + +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 + }; + + for (var index = 0; index < configurationObjectsArray.length; index++) { + var configuration = configurationObjectsArray[index], + configurationUuid = this.generateUuid(), + configurationCommentKey = f("%s_comment", configurationUuid); + + pbxBuildConfigurationSection[configurationUuid] = configuration; + pbxBuildConfigurationSection[configurationCommentKey] = configuration.name; + xcConfigurationList.buildConfigurations.push({ value: configurationUuid, comment: configuration.name }); + } + + if (pbxXCConfigurationListSection) { + pbxXCConfigurationListSection[xcConfigurationListUuid] = xcConfigurationList; + pbxXCConfigurationListSection[commentKey] = comment; + } + + return { uuid: xcConfigurationListUuid, xcConfigurationList: xcConfigurationList }; +} + +pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) { + if (!target) + return undefined; + + var nativeTargets = this.pbxNativeTargetSection(); + + if (typeof nativeTargets[target] == "undefined") + throw new Error("Invalid target: " + target); + + 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 (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 + }; + + if (pbxContainerItemProxySection && pbxTargetDependencySection) { + pbxContainerItemProxySection[itemProxyUuid] = itemProxy; + pbxContainerItemProxySection[itemProxyCommentKey] = pbxContainerItemProxy; + pbxTargetDependencySection[targetDependencyUuid] = targetDependency; + pbxTargetDependencySection[targetDependencyCommentKey] = pbxTargetDependency; + nativeTargets[target].dependencies.push({ value: targetDependencyUuid, comment: pbxTargetDependency }) + } + } + + return { uuid: target, target: nativeTargets[target] }; +} + +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 = {}; + + if (buildPhaseType === 'PBXCopyFilesBuildPhase') { + buildPhase = pbxCopyFilesBuildPhaseObj(buildPhase, optionsOrFolderType, subfolderPath, comment); + } else if (buildPhaseType === 'PBXShellScriptBuildPhase') { + buildPhase = pbxShellScriptBuildPhaseObj(buildPhase, optionsOrFolderType, comment) + } + + if (!this.hash.project.objects[buildPhaseType]) { + this.hash.project.objects[buildPhaseType] = new Object(); + } + + if (!this.hash.project.objects[buildPhaseType][buildPhaseUuid]) { + this.hash.project.objects[buildPhaseType][buildPhaseUuid] = buildPhase; + this.hash.project.objects[buildPhaseType][commentKey] = comment; + } + + if (this.hash.project.objects['PBXNativeTarget'][buildPhaseTargetUuid]['buildPhases']) { + this.hash.project.objects['PBXNativeTarget'][buildPhaseTargetUuid]['buildPhases'].push({ + value: buildPhaseUuid, + comment: comment + }) + + } + + + for (var key in buildFileSection) { + // only look for comments + if (!COMMENT_KEY.test(key)) continue; + + var buildFileKey = key.split(COMMENT_KEY)[0], + buildFile = buildFileSection[buildFileKey]; + fileReference = fileReferenceSection[buildFile.fileRef]; + + if (!fileReference) continue; + + var pbxFileObj = new pbxFile(fileReference.path); + + filePathToBuildFile[fileReference.path] = { uuid: buildFileKey, basename: pbxFileObj.basename, group: pbxFileObj.group }; + } + + 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; + } + + file.uuid = this.generateUuid(); + file.fileRef = this.generateUuid(); + this.addToPbxFileReferenceSection(file); // PBXFileReference + this.addToPbxBuildFileSection(file); // PBXBuildFile + buildPhase.files.push(pbxBuildPhaseObj(file)); + } + + if (buildPhaseSection) { + buildPhaseSection[buildPhaseUuid] = buildPhase; + buildPhaseSection[commentKey] = comment; + } + + return { uuid: buildPhaseUuid, buildPhase: buildPhase }; +} + +// helper access functions +pbxProject.prototype.pbxProjectSection = function() { + return this.hash.project.objects['PBXProject']; +} +pbxProject.prototype.pbxBuildFileSection = function() { + return this.hash.project.objects['PBXBuildFile']; +} + +pbxProject.prototype.pbxXCBuildConfigurationSection = function() { + return this.hash.project.objects['XCBuildConfiguration']; +} + +pbxProject.prototype.pbxFileReferenceSection = function() { + return this.hash.project.objects['PBXFileReference']; +} + +pbxProject.prototype.pbxNativeTargetSection = function() { + return this.hash.project.objects['PBXNativeTarget']; +} + +pbxProject.prototype.xcVersionGroupSection = function () { + if (typeof this.hash.project.objects['XCVersionGroup'] !== 'object') { + this.hash.project.objects['XCVersionGroup'] = {}; + } + + return this.hash.project.objects['XCVersionGroup']; +} + +pbxProject.prototype.pbxXCConfigurationList = function() { + return this.hash.project.objects['XCConfigurationList']; +} + +pbxProject.prototype.pbxGroupByName = function(name) { + var groups = this.hash.project.objects['PBXGroup'], + key, groupKey; + + for (key in groups) { + // only look for comments + if (!COMMENT_KEY.test(key)) continue; + + if (groups[key] == name) { + groupKey = key.split(COMMENT_KEY)[0]; + return groups[groupKey]; + } + } + + return null; +} + +pbxProject.prototype.pbxTargetByName = function(name) { + return this.pbxItemByComment(name, 'PBXNativeTarget'); +} + +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; + } + } + + return null; +} + +pbxProject.prototype.pbxItemByComment = function(name, pbxSectionName) { + var section = this.hash.project.objects[pbxSectionName], + key, itemKey; + + for (key in section) { + // only look for comments + if (!COMMENT_KEY.test(key)) continue; + + if (section[key] == name) { + itemKey = key.split(COMMENT_KEY)[0]; + return section[itemKey]; + } + } + + return null; +} + +pbxProject.prototype.pbxSourcesBuildPhaseObj = function(target) { + return this.buildPhaseObject('PBXSourcesBuildPhase', 'Sources', target); +} + +pbxProject.prototype.pbxResourcesBuildPhaseObj = function(target) { + return this.buildPhaseObject('PBXResourcesBuildPhase', 'Resources', target); +} + +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) { + + if (!target) + return undefined; + + var nativeTargets = this.pbxNativeTargetSection(); + if (typeof nativeTargets[target] == "undefined") + throw new Error("Invalid target: " + target); + + 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) { + + // 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; + } + } +} + +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 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.updateProductName = function(name) { + this.updateBuildProperty('PRODUCT_NAME', '"' + name + '"'); +} + +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.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; + + if (!buildSettings['FRAMEWORK_SEARCH_PATHS'] + || buildSettings['FRAMEWORK_SEARCH_PATHS'] === INHERITED) { + buildSettings['FRAMEWORK_SEARCH_PATHS'] = [INHERITED]; + } + + buildSettings['FRAMEWORK_SEARCH_PATHS'].push(searchPathForFile(file, this)); + } +} + +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); + + 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.addToLibrarySearchPaths = 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; + + if (!buildSettings['LIBRARY_SEARCH_PATHS'] + || buildSettings['LIBRARY_SEARCH_PATHS'] === INHERITED) { + buildSettings['LIBRARY_SEARCH_PATHS'] = [INHERITED]; + } + + if (typeof file === 'string') { + buildSettings['LIBRARY_SEARCH_PATHS'].push(file); + } else { + buildSettings['LIBRARY_SEARCH_PATHS'].push(searchPathForFile(file, this)); + } + } +} + +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); + + for (config in configurations) { + buildSettings = configurations[config].buildSettings; + + if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) + continue; + + 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.addToHeaderSearchPaths = 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; + + if (!buildSettings['HEADER_SEARCH_PATHS']) { + buildSettings['HEADER_SEARCH_PATHS'] = [INHERITED]; + } + + if (typeof file === 'string') { + buildSettings['HEADER_SEARCH_PATHS'].push(file); + } else { + buildSettings['HEADER_SEARCH_PATHS'].push(searchPathForFile(file, this)); + } + } +} + +pbxProject.prototype.addToOtherLinkerFlags = function (flag) { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + INHERITED = '"$(inherited)"', + OTHER_LDFLAGS = 'OTHER_LDFLAGS', + config, buildSettings; + + for (config in configurations) { + buildSettings = configurations[config].buildSettings; + + if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) + continue; + + if (!buildSettings[OTHER_LDFLAGS] + || buildSettings[OTHER_LDFLAGS] === INHERITED) { + buildSettings[OTHER_LDFLAGS] = [INHERITED]; + } + + buildSettings[OTHER_LDFLAGS].push(flag); + } +} + +pbxProject.prototype.removeFromOtherLinkerFlags = function (flag) { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + OTHER_LDFLAGS = 'OTHER_LDFLAGS', + config, buildSettings; + + for (config in configurations) { + buildSettings = configurations[config].buildSettings; + + if (unquote(buildSettings['PRODUCT_NAME']) != this.productName) { + continue; + } + + 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.addToBuildSettings = function (buildSetting, value) { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + config, buildSettings; + + for (config in configurations) { + buildSettings = configurations[config].buildSettings; + + buildSettings[buildSetting] = value; + } +} + +pbxProject.prototype.removeFromBuildSettings = function (buildSetting) { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + config, buildSettings; + + for (config in configurations) { + buildSettings = configurations[config].buildSettings; + + if (buildSettings[buildSetting]) { + delete buildSettings[buildSetting]; + } + } +} + +// a JS getter. hmmm +pbxProject.prototype.__defineGetter__("productName", function() { + var configurations = nonComments(this.pbxXCBuildConfigurationSection()), + config, productName; + + for (config in configurations) { + productName = configurations[config].buildSettings['PRODUCT_NAME']; + + if (productName) { + return unquote(productName); + } + } +}); + +// 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; + } + } + + return false; +} + +pbxProject.prototype.addTarget = function(name, type, subfolder) { + + // Setup uuid and name of new target + var targetUuid = this.generateUuid(), + targetType = type, + targetSubfolder = subfolder || name, + targetName = name.trim(); + + // Check type against list of allowed target types + if (!targetName) { + throw new Error("Target name missing."); + } + + // Check type against list of allowed target types + if (!targetType) { + throw new Error("Target type missing."); + } + + // 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' + } + } + ]; + + // Build Configuration: Add + var buildConfigurations = this.addXCConfigurationList(buildConfigurationsList, 'Release', 'Build configuration list for PBXNativeTarget "' + targetName +'"'); + + // 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; + + + // Product: Add to build file list + this.addToPbxBuildFileSection(productFile); + + // 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: [] + } + }; + + // Target: Add to PBXNativeTarget section + this.addToPbxNativeTargetSection(target) + + // Product: Embed (only for "extension"-type targets) + if (targetType === 'app_extension') { + + // Create CopyFiles phase in first target + this.addBuildPhase([], 'PBXCopyFilesBuildPhase', 'Copy Files', this.getFirstTarget().uuid, targetType) + + // Add product to CopyFiles phase + this.addToPbxCopyfilesBuildPhase(productFile) + + // this.addBuildPhaseToTarget(newPhase.buildPhase, this.getFirstTarget().uuid) + + }; + + // Target: Add uuid to root project + this.addToPbxProjectSection(target); + + // Target: Add dependency for this target to first (main) target + this.addTargetDependency(this.getFirstTarget().uuid, [target.uuid]); + + + // Return target on success + return target; + +}; + +// 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; + } + } + } +} + +// 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 + }; + + return fileObject; +} + +function pbxGroupChild(file) { + var obj = Object.create(null); + + obj.value = file.fileRef; + obj.comment = file.basename; + + return obj; +} + +function pbxBuildPhaseObj(file) { + var obj = Object.create(null); + + obj.value = file.uuid; + obj.comment = longComment(file); + + return obj; +} + +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 + } + + obj.name = '"' + phaseName + '"'; + obj.dstPath = subfolderPath || '""'; + obj.dstSubfolderSpec = SUBFOLDERSPEC_BY_DESTINATION[DESTINATION_BY_TARGETTYPE[folderType]]; + + return obj; +} + +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, '\\"') + '"'; + + return obj; +} + +function pbxBuildFileComment(file) { + return longComment(file); +} + +function pbxFileReferenceComment(file) { + return file.basename || path.basename(file.path); +} + +function pbxNativeTargetComment(target) { + return target.name; +} + +function longComment(file) { + return f("%s in %s", file.basename, file.group); +} + +// respect path +function correctForPluginsPath(file, project) { + return correctForPath(file, project, 'Plugins'); +} + +function correctForResourcesPath(file, project) { + return correctForPath(file, project, 'Resources'); +} + +function correctForFrameworksPath(file, project) { + return correctForPath(file, project, 'Frameworks'); +} + +function correctForPath(file, project, group) { + var r_group_dir = new RegExp('^' + group + '[\\\\/]'); + + 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 (file.plugin && pluginsPath) { + return '"\\"$(SRCROOT)/' + unquote(pluginsPath) + '\\""'; + } else if (file.customFramework && file.dirname) { + return '"\\"' + file.dirname + '\\""'; + } else { + return '"\\"$(SRCROOT)/' + proj.productName + fileDir + '\\""'; + } +} + +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; +} + +function unquote(str) { + if (str) return str.replace(/^"(.*)"$/, "$1"); +} + + +function buildPhaseNameForIsa (isa) { + + BUILDPHASENAME_BY_ISA = { + PBXCopyFilesBuildPhase: 'Copy Files', + PBXResourcesBuildPhase: 'Resources', + PBXSourcesBuildPhase: 'Sources', + PBXFrameworksBuildPhase: 'Frameworks' + } + + return BUILDPHASENAME_BY_ISA[isa] +} + +function producttypeForTargettype (targetType) { + + 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 PRODUCTTYPE_BY_TARGETTYPE[targetType] +} + +function filetypeForProducttype (productType) { + + 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 FILETYPE_BY_PRODUCTTYPE[productType] +} + +pbxProject.prototype.getFirstProject = function() { + + // Get pbxProject container + var pbxProjectContainer = this.pbxProjectSection(); + + // Get first pbxProject UUID + var firstProjectUuid = Object.keys(pbxProjectContainer)[0]; + + // Get first pbxProject + var firstProject = pbxProjectContainer[firstProjectUuid]; + + return { + uuid: firstProjectUuid, + firstProject: firstProject + } +} + +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 + } +} + +/*** NEW ***/ + +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; + } + + group.children.push(childGroup); + } + else { + //File Object + group.children.push(pbxGroupChild(file)); + } + } +} + +pbxProject.prototype.addToPbxVariantGroup = function (file, groupKey) { + this.addToPbxGroupType(file, groupKey, 'PBXVariantGroup'); +} + +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: '""' + }; + 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; +} + +pbxProject.prototype.pbxCreateVariantGroup = function(name) { + return this.pbxCreateGroupWithType(name, undefined, 'PBXVariantGroup') +} + +pbxProject.prototype.pbxCreateGroup = function(name, pathName) { + return this.pbxCreateGroupWithType(name, pathName, 'PBXGroup'); +} + + + +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; + } + } + } +} + +pbxProject.prototype.removeFromPbxGroup = function (file, groupKey) { + this.removeFromPbxGroupAndType(file, groupKey, 'PBXGroup'); +} + +pbxProject.prototype.removeFromPbxVariantGroup = function (file, groupKey) { + this.removeFromPbxGroupAndType(file, groupKey, 'PBXVariantGroup'); +} + + + +pbxProject.prototype.getPBXGroupByKeyAndType = function(key, groupType) { + return this.hash.project.objects[groupType][key]; +}; + +pbxProject.prototype.getPBXGroupByKey = function(key) { + return this.hash.project.objects['PBXGroup'][key]; +}; + +pbxProject.prototype.getPBXVariantGroupByKey = function(key) { + return this.hash.project.objects['PBXVariantGroup'][key]; +}; + + + +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; + + 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 target; +} + +pbxProject.prototype.findPBXGroupKey = function(criteria) { + return this.findPBXGroupKeyAndType(criteria, 'PBXGroup'); +} + +pbxProject.prototype.findPBXVariantGroupKey = function(criteria) { + return this.findPBXGroupKeyAndType(criteria, 'PBXVariantGroup'); +} + +pbxProject.prototype.addLocalizationVariantGroup = function(name) { + var groupKey = this.pbxCreateVariantGroup(name); + + 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); + } +} + +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.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.getPBXObject = function(name) { + return this.hash.project.objects[name]; +} + + + +pbxProject.prototype.addFile = function (path, group, opt) { + var file = new pbxFile(path, opt); + + // null is better for early errors + if (this.hasFile(file.path)) return null; + + file.fileRef = this.generateUuid(); + + this.addToPbxFileReferenceSection(file); // PBXFileReference + + if (this.getPBXGroupByKey(group)) { + this.addToPbxGroup(file, group); // PBXGroup + } + else if (this.getPBXVariantGroupByKey(group)) { + this.addToPbxVariantGroup(file, group); // PBXVariantGroup + } + + return file; +} + +pbxProject.prototype.removeFile = function (path, group, opt) { + var file = new pbxFile(path, opt); + + this.removeFromPbxFileReferenceSection(file); // PBXFileReference + + if (this.getPBXGroupByKey(group)) { + this.removeFromPbxGroup(file, group); // PBXGroup + } + else if (this.getPBXVariantGroupByKey(group)) { + this.removeFromPbxVariantGroup(file, group); // PBXVariantGroup + } + + return file; +} + + + +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; +} + +pbxProject.prototype.addDataModelDocument = function(filePath, group, opt) { + if (!group) { + group = 'Resources'; + } + if (!this.getPBXGroupByKey(group)) { + group = this.findPBXGroupKey({ name: group }); + } + + var file = new pbxFile(filePath, opt); + + if (!file || this.hasFile(file.path)) return null; + + file.fileRef = this.generateUuid(); + this.addToPbxGroup(file, group); + + if (!file) return false; + + file.target = opt ? opt.target : undefined; + file.uuid = this.generateUuid(); + + this.addToPbxBuildFileSection(file); + this.addToPbxSourcesBuildPhase(file); + + 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; + } + + var modelFile = new pbxFile(modelFilePath); + modelFile.fileRef = this.generateUuid(); + + this.addToPbxFileReferenceSection(modelFile); + + file.models.push(modelFile); + + if (currentVersionName && currentVersionName === modelFileName) { + file.currentModel = modelFile; + } + } + + if (!file.currentModel) { + file.currentModel = file.models[0]; + } + + this.addToXcVersionGroupSection(file); + + return file; +} + +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.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 = pbxProject; + +/* WEBPACK VAR INJECTION */}.call(exports, "/")) + +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { + + +/** + * Module dependencies. + */ + +var deprecate = __webpack_require__(19); +var DOMParser = __webpack_require__(101).DOMParser; + +/** + * Module exports. + */ + +exports.parse = parse; +exports.parseString = deprecate(parseString, '`parseString()` is deprecated. ' + + 'It\'s not actually async. Use `parse()` instead.'); +exports.parseStringSync = deprecate(parseStringSync, '`parseStringSync()` is ' + + 'deprecated. Use `parse()` instead.'); + +/** + * We ignore raw text (usually whitespace), , + * and raw CDATA nodes. + * + * @param {Element} node + * @returns {Boolean} + * @api private + */ + +function shouldIgnoreNode (node) { + return node.nodeType === 3 // text + || node.nodeType === 8 // comment + || node.nodeType === 4; // cdata +} + + +/** + * Parses a Plist XML string. Returns an Object. + * + * @param {String} xml - the XML String to decode + * @returns {Mixed} the decoded value from the Plist XML + * @api public + */ + +function parse (xml) { + var doc = new DOMParser().parseFromString(xml); + if (doc.documentElement.nodeName !== 'plist') { + throw new Error('malformed document. First element should be '); + } + var plist = parsePlistXML(doc.documentElement); + + // the root node gets interpreted as an Array, + // so pull out the inner data first + if (plist.length == 1) plist = plist[0]; + + return plist; +} + +/** + * Parses a Plist XML string. Returns an Object. Takes a `callback` function. + * + * @param {String} xml - the XML String to decode + * @param {Function} callback - callback function + * @returns {Mixed} the decoded value from the Plist XML + * @api public + * @deprecated not actually async. use parse() instead + */ + +function parseString (xml, callback) { + var doc, error, plist; + try { + doc = new DOMParser().parseFromString(xml); + plist = parsePlistXML(doc.documentElement); + } catch(e) { + error = e; + } + callback(error, plist); +} + +/** + * Parses a Plist XML string. Returns an Object. + * + * @param {String} xml - the XML String to decode + * @param {Function} callback - callback function + * @returns {Mixed} the decoded value from the Plist XML + * @api public + * @deprecated use parse() instead + */ + +function parseStringSync (xml) { + var doc = new DOMParser().parseFromString(xml); + var plist; + if (doc.documentElement.nodeName !== 'plist') { + throw new Error('malformed document. First element should be '); + } + plist = parsePlistXML(doc.documentElement); + + // if the plist is an array with 1 element, pull it out of the array + if (plist.length == 1) { + plist = plist[0]; + } + return plist; +} + +/** + * Convert an XML based plist document into a JSON representation. + * + * @param {Object} xml_node - current XML node in the plist + * @returns {Mixed} built up JSON object + * @api private + */ + +function parsePlistXML (node) { + var i, new_obj, key, val, new_arr, res, d; + + if (!node) + return null; + + if (node.nodeName === 'plist') { + new_arr = []; + for (i=0; i < node.childNodes.length; i++) { + // ignore comment nodes (text) + if (!shouldIgnoreNode(node.childNodes[i])) { + new_arr.push( parsePlistXML(node.childNodes[i])); + } + } + return new_arr; + + } else if (node.nodeName === 'dict') { + new_obj = {}; + key = null; + for (i=0; i < node.childNodes.length; i++) { + // ignore comment nodes (text) + if (!shouldIgnoreNode(node.childNodes[i])) { + if (key === null) { + key = parsePlistXML(node.childNodes[i]); + } else { + new_obj[key] = parsePlistXML(node.childNodes[i]); + key = null; + } + } + } + return new_obj; + + } else if (node.nodeName === 'array') { + new_arr = []; + for (i=0; i < node.childNodes.length; i++) { + // ignore comment nodes (text) + if (!shouldIgnoreNode(node.childNodes[i])) { + res = parsePlistXML(node.childNodes[i]); + if (null != res) new_arr.push(res); + } + } + return new_arr; + + } else if (node.nodeName === '#text') { + // TODO: what should we do with text types? (CDATA sections) + + } else if (node.nodeName === 'key') { + return node.childNodes[0].nodeValue; + + } else if (node.nodeName === 'string') { + res = ''; + for (d=0; d < node.childNodes.length; d++) { + res += node.childNodes[d].nodeValue; + } + return res; + + } else if (node.nodeName === 'integer') { + // parse as base 10 integer + return parseInt(node.childNodes[0].nodeValue, 10); + + } else if (node.nodeName === 'real') { + res = ''; + for (d=0; d < node.childNodes.length; d++) { + if (node.childNodes[d].nodeType === 3) { + res += node.childNodes[d].nodeValue; + } + } + return parseFloat(res); + + } else if (node.nodeName === 'data') { + res = ''; + for (d=0; d < node.childNodes.length; d++) { + if (node.childNodes[d].nodeType === 3) { + res += node.childNodes[d].nodeValue.replace(/\s+/g, ''); + } + } + + // decode base64 data to a Buffer instance + return new Buffer(res, 'base64'); + + } else if (node.nodeName === 'date') { + return new Date(node.childNodes[0].nodeValue); + + } else if (node.nodeName === 'true') { + return true; + + } else if (node.nodeName === 'false') { + return false; + } +} + + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + + +/** + * For Node.js, simply re-export the core `util.deprecate` function. + */ + +module.exports = __webpack_require__(5).deprecate; + + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + +// 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; + + create = __webpack_require__(1); + + XMLNode = __webpack_require__(6); + + 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); + } + + XMLCData.prototype.clone = function() { + return create(XMLCData.prototype, this); + }; + + 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; + }; + + return XMLCData; + + })(XMLNode); + +}).call(this); + + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + +// 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; + + create = __webpack_require__(1); + + XMLNode = __webpack_require__(6); + + module.exports = XMLComment = (function(superClass) { + extend(XMLComment, superClass); + + 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); + }; + + 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; + }; + + return XMLComment; + + })(XMLNode); + +}).call(this); + + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + +// 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; + + create = __webpack_require__(1); + + isObject = __webpack_require__(0); + + XMLNode = __webpack_require__(6); + + module.exports = XMLDeclaration = (function(superClass) { + extend(XMLDeclaration, superClass); + + 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); + } + } + + 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; + + })(XMLNode); + +}).call(this); + + +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { + +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLProcessingInstruction, create, isObject; + + create = __webpack_require__(1); + + isObject = __webpack_require__(0); + + XMLCData = __webpack_require__(20); + + XMLComment = __webpack_require__(21); + + XMLDTDAttList = __webpack_require__(57); + + XMLDTDEntity = __webpack_require__(59); + + XMLDTDElement = __webpack_require__(58); + + XMLDTDNotation = __webpack_require__(60); + + XMLProcessingInstruction = __webpack_require__(25); + + 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); + } + } + + XMLDocType.prototype.element = function(name, value) { + var child; + child = new XMLDTDElement(this, name, value); + this.children.push(child); + return this; + }; + + 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; + }; + + XMLDocType.prototype.entity = function(name, value) { + var child; + child = new XMLDTDEntity(this, false, name, value); + this.children.push(child); + return this; + }; + + XMLDocType.prototype.pEntity = function(name, value) { + var child; + child = new XMLDTDEntity(this, true, name, value); + this.children.push(child); + return this; + }; + + XMLDocType.prototype.notation = function(name, value) { + var child; + child = new XMLDTDNotation(this, name, value); + this.children.push(child); + return this; + }; + + XMLDocType.prototype.cdata = function(value) { + var child; + child = new XMLCData(this, value); + this.children.push(child); + return this; + }; + + XMLDocType.prototype.comment = function(value) { + var child; + child = new XMLComment(this, value); + this.children.push(child); + return this; + }; + + XMLDocType.prototype.instruction = function(target, value) { + var child; + child = new XMLProcessingInstruction(this, target, value); + this.children.push(child); + return this; + }; + + XMLDocType.prototype.root = function() { + return this.documentObject.root(); + }; + + XMLDocType.prototype.document = function() { + return this.documentObject; + }; + + 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; + }; + + XMLDocType.prototype.ele = function(name, value) { + return this.element(name, value); + }; + + 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); + }; + + XMLDocType.prototype.pent = function(name, value) { + return this.pEntity(name, value); + }; + + XMLDocType.prototype.not = function(name, value) { + return this.notation(name, value); + }; + + XMLDocType.prototype.dat = function(value) { + return this.cdata(value); + }; + + XMLDocType.prototype.com = function(value) { + return this.comment(value); + }; + + XMLDocType.prototype.ins = function(target, value) { + return this.instruction(target, value); + }; + + XMLDocType.prototype.up = function() { + return this.root(); + }; + + XMLDocType.prototype.doc = function() { + return this.document(); + }; + + return XMLDocType; + + })(); + +}).call(this); + + +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + +// 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; + + create = __webpack_require__(1); + + isObject = __webpack_require__(0); + + isFunction = __webpack_require__(11); + + every = __webpack_require__(66); + + XMLNode = __webpack_require__(6); + + XMLAttribute = __webpack_require__(55); + + XMLProcessingInstruction = __webpack_require__(25); + + module.exports = XMLElement = (function(superClass) { + extend(XMLElement, superClass); + + 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); + } + } + + 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; + }; + + 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; + }; + + 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; + }; + + 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); + }; + + XMLElement.prototype.ins = function(target, value) { + return this.instruction(target, value); + }; + + XMLElement.prototype.a = function(name, value) { + return this.attribute(name, value); + }; + + XMLElement.prototype.i = function(target, value) { + return this.instruction(target, value); + }; + + return XMLElement; + + })(XMLNode); + +}).call(this); + + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLProcessingInstruction, create; + + create = __webpack_require__(1); + + 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); + } + } + + 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; + }; + + return XMLProcessingInstruction; + + })(); + +}).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); +} + +module.exports = baseAssign; + + +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { + +var toObject = __webpack_require__(2); + +/** + * 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; + + while (object != null && index < length) { + object = object[path[index++]]; + } + return (index && index == length) ? object : undefined; +} + +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; + } + if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB); +} + +module.exports = baseIsEqual; + + +/***/ }), +/* 29 */ +/***/ (function(module, exports) { + +/** + * 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]; + }; +} + +module.exports = baseProperty; + + +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { + +var identity = __webpack_require__(36); + +/** + * 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); + }; +} + +module.exports = bindCallback; + + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + +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; + + +/***/ }), +/* 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; +} + +module.exports = getNative; + + +/***/ }), +/* 33 */ +/***/ (function(module, exports, __webpack_require__) { + +var isArray = __webpack_require__(3), + toObject = __webpack_require__(2); + +/** Used to match property names within property paths. */ +var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/; + +/** + * 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)); +} + +module.exports = isKey; + + +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + +var isObject = __webpack_require__(0); + +/** + * 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); +} + +module.exports = isStrictComparable; + + +/***/ }), +/* 35 */ +/***/ (function(module, exports, __webpack_require__) { + +var baseToString = __webpack_require__(84), + isArray = __webpack_require__(3); + +/** Used to match property names within property paths. */ +var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g; + +/** 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; +} + +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 = identity; + + +/***/ }), +/* 37 */ +/***/ (function(module, exports) { + +/* + * DOM Level 2 + * Object DOMException + * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html + * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html + */ + +function copy(src,dest){ + for(var p in src){ + dest[p] = src[p]; + } +} +/** +^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));? +^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));? + */ +function _extends(Class,Super){ + var pt = Class.prototype; + if(Object.create){ + var ppt = Object.create(Super.prototype) + pt.__proto__ = ppt; + } + if(!(pt instanceof Super)){ + function t(){}; + t.prototype = Super.prototype; + t = new t(); + copy(pt,t); + Class.prototype = pt = t; + } + if(pt.constructor != Class){ + if(typeof Class != 'function'){ + console.error("unknow Class:"+Class) + } + pt.constructor = Class + } +} +var htmlns = 'http://www.w3.org/1999/xhtml' ; +// Node Types +var NodeType = {} +var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1; +var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2; +var TEXT_NODE = NodeType.TEXT_NODE = 3; +var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4; +var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5; +var ENTITY_NODE = NodeType.ENTITY_NODE = 6; +var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7; +var COMMENT_NODE = NodeType.COMMENT_NODE = 8; +var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9; +var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10; +var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11; +var NOTATION_NODE = NodeType.NOTATION_NODE = 12; + +// ExceptionCode +var ExceptionCode = {} +var ExceptionMessage = {}; +var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]="Index size error"),1); +var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2); +var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3); +var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4); +var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5); +var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6); +var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7); +var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8); +var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9); +var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10); +//level2 +var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11); +var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12); +var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13); +var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14); +var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15]="Invalid access"),15); + + +function DOMException(code, message) { + if(message instanceof Error){ + var error = message; + }else{ + error = this; + Error.call(this, ExceptionMessage[code]); + this.message = ExceptionMessage[code]; + if(Error.captureStackTrace) Error.captureStackTrace(this, DOMException); + } + error.code = code; + if(message) this.message = this.message + ": " + message; + return error; +}; +DOMException.prototype = Error.prototype; +copy(ExceptionCode,DOMException) +/** + * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177 + * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live. + * The items in the NodeList are accessible via an integral index, starting from 0. + */ +function NodeList() { +}; +NodeList.prototype = { + /** + * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive. + * @standard level1 + */ + length:0, + /** + * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null. + * @standard level1 + * @param index unsigned long + * Index into the collection. + * @return Node + * The node at the indexth position in the NodeList, or null if that is not a valid index. + */ + item: function(index) { + return this[index] || null; + }, + toString:function(isHTML,nodeFilter){ + for(var buf = [], i = 0;i=0){ + var lastIndex = list.length-1 + while(i0 || key == 'xmlns'){ +// return null; +// } + //console.log() + var i = this.length; + while(i--){ + var attr = this[i]; + //console.log(attr.nodeName,key) + if(attr.nodeName == key){ + return attr; + } + } + }, + setNamedItem: function(attr) { + var el = attr.ownerElement; + if(el && el!=this._ownerElement){ + throw new DOMException(INUSE_ATTRIBUTE_ERR); + } + var oldAttr = this.getNamedItem(attr.nodeName); + _addNamedNode(this._ownerElement,this,attr,oldAttr); + return oldAttr; + }, + /* returns Node */ + setNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR + var el = attr.ownerElement, oldAttr; + if(el && el!=this._ownerElement){ + throw new DOMException(INUSE_ATTRIBUTE_ERR); + } + oldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName); + _addNamedNode(this._ownerElement,this,attr,oldAttr); + return oldAttr; + }, + + /* returns Node */ + removeNamedItem: function(key) { + var attr = this.getNamedItem(key); + _removeNamedNode(this._ownerElement,this,attr); + return attr; + + + },// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR + + //for level2 + removeNamedItemNS:function(namespaceURI,localName){ + var attr = this.getNamedItemNS(namespaceURI,localName); + _removeNamedNode(this._ownerElement,this,attr); + return attr; + }, + getNamedItemNS: function(namespaceURI, localName) { + var i = this.length; + while(i--){ + var node = this[i]; + if(node.localName == localName && node.namespaceURI == namespaceURI){ + return node; + } + } + return null; + } +}; +/** + * @see http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 + */ +function DOMImplementation(/* Object */ features) { + this._features = {}; + if (features) { + for (var feature in features) { + this._features = features[feature]; + } + } +}; + +DOMImplementation.prototype = { + hasFeature: function(/* string */ feature, /* string */ version) { + var versions = this._features[feature.toLowerCase()]; + if (versions && (!version || version in versions)) { + return true; + } else { + return false; + } + }, + // Introduced in DOM Level 2: + createDocument:function(namespaceURI, qualifiedName, doctype){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR,WRONG_DOCUMENT_ERR + var doc = new Document(); + doc.implementation = this; + doc.childNodes = new NodeList(); + doc.doctype = doctype; + if(doctype){ + doc.appendChild(doctype); + } + if(qualifiedName){ + var root = doc.createElementNS(namespaceURI,qualifiedName); + doc.appendChild(root); + } + return doc; + }, + // Introduced in DOM Level 2: + createDocumentType:function(qualifiedName, publicId, systemId){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR + var node = new DocumentType(); + node.name = qualifiedName; + node.nodeName = qualifiedName; + node.publicId = publicId; + node.systemId = systemId; + // Introduced in DOM Level 2: + //readonly attribute DOMString internalSubset; + + //TODO:.. + // readonly attribute NamedNodeMap entities; + // readonly attribute NamedNodeMap notations; + return node; + } +}; + + +/** + * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247 + */ + +function Node() { +}; + +Node.prototype = { + firstChild : null, + lastChild : null, + previousSibling : null, + nextSibling : null, + attributes : null, + parentNode : null, + childNodes : null, + ownerDocument : null, + nodeValue : null, + namespaceURI : null, + prefix : null, + localName : null, + // Modified in DOM Level 2: + insertBefore:function(newChild, refChild){//raises + return _insertBefore(this,newChild,refChild); + }, + replaceChild:function(newChild, oldChild){//raises + this.insertBefore(newChild,oldChild); + if(oldChild){ + this.removeChild(oldChild); + } + }, + removeChild:function(oldChild){ + return _removeChild(this,oldChild); + }, + appendChild:function(newChild){ + return this.insertBefore(newChild,null); + }, + hasChildNodes:function(){ + return this.firstChild != null; + }, + cloneNode:function(deep){ + return cloneNode(this.ownerDocument||this,this,deep); + }, + // Modified in DOM Level 2: + normalize:function(){ + var child = this.firstChild; + while(child){ + var next = child.nextSibling; + if(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){ + this.removeChild(next); + child.appendData(next.data); + }else{ + child.normalize(); + child = next; + } + } + }, + // Introduced in DOM Level 2: + isSupported:function(feature, version){ + return this.ownerDocument.implementation.hasFeature(feature,version); + }, + // Introduced in DOM Level 2: + hasAttributes:function(){ + return this.attributes.length>0; + }, + lookupPrefix:function(namespaceURI){ + var el = this; + while(el){ + var map = el._nsMap; + //console.dir(map) + if(map){ + for(var n in map){ + if(map[n] == namespaceURI){ + return n; + } + } + } + el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode; + } + return null; + }, + // Introduced in DOM Level 3: + lookupNamespaceURI:function(prefix){ + var el = this; + while(el){ + var map = el._nsMap; + //console.dir(map) + if(map){ + if(prefix in map){ + return map[prefix] ; + } + } + el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode; + } + return null; + }, + // Introduced in DOM Level 3: + isDefaultNamespace:function(namespaceURI){ + var prefix = this.lookupPrefix(namespaceURI); + return prefix == null; + } +}; + + +function _xmlEncoder(c){ + return c == '<' && '<' || + c == '>' && '>' || + c == '&' && '&' || + c == '"' && '"' || + '&#'+c.charCodeAt()+';' +} + + +copy(NodeType,Node); +copy(NodeType,Node.prototype); + +/** + * @param callback return true for continue,false for break + * @return boolean true: break visit; + */ +function _visitNode(node,callback){ + if(callback(node)){ + return true; + } + if(node = node.firstChild){ + do{ + if(_visitNode(node,callback)){return true} + }while(node=node.nextSibling) + } +} + + + +function Document(){ +} +function _onAddAttribute(doc,el,newAttr){ + doc && doc._inc++; + var ns = newAttr.namespaceURI ; + if(ns == 'http://www.w3.org/2000/xmlns/'){ + //update namespace + el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value + } +} +function _onRemoveAttribute(doc,el,newAttr,remove){ + doc && doc._inc++; + var ns = newAttr.namespaceURI ; + if(ns == 'http://www.w3.org/2000/xmlns/'){ + //update namespace + delete el._nsMap[newAttr.prefix?newAttr.localName:''] + } +} +function _onUpdateChild(doc,el,newChild){ + if(doc && doc._inc){ + doc._inc++; + //update childNodes + var cs = el.childNodes; + if(newChild){ + cs[cs.length++] = newChild; + }else{ + //console.log(1) + var child = el.firstChild; + var i = 0; + while(child){ + cs[i++] = child; + child =child.nextSibling; + } + cs.length = i; + } + } +} + +/** + * attributes; + * children; + * + * writeable properties: + * nodeValue,Attr:value,CharacterData:data + * prefix + */ +function _removeChild(parentNode,child){ + var previous = child.previousSibling; + var next = child.nextSibling; + if(previous){ + previous.nextSibling = next; + }else{ + parentNode.firstChild = next + } + if(next){ + next.previousSibling = previous; + }else{ + parentNode.lastChild = previous; + } + _onUpdateChild(parentNode.ownerDocument,parentNode); + return child; +} +/** + * preformance key(refChild == null) + */ +function _insertBefore(parentNode,newChild,nextChild){ + var cp = newChild.parentNode; + if(cp){ + cp.removeChild(newChild);//remove and update + } + if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){ + var newFirst = newChild.firstChild; + if (newFirst == null) { + return newChild; + } + var newLast = newChild.lastChild; + }else{ + newFirst = newLast = newChild; + } + var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild; + + newFirst.previousSibling = pre; + newLast.nextSibling = nextChild; + + + if(pre){ + pre.nextSibling = newFirst; + }else{ + parentNode.firstChild = newFirst; + } + if(nextChild == null){ + parentNode.lastChild = newLast; + }else{ + nextChild.previousSibling = newLast; + } + do{ + newFirst.parentNode = parentNode; + }while(newFirst !== newLast && (newFirst= newFirst.nextSibling)) + _onUpdateChild(parentNode.ownerDocument||parentNode,parentNode); + //console.log(parentNode.lastChild.nextSibling == null) + if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) { + newChild.firstChild = newChild.lastChild = null; + } + return newChild; +} +function _appendSingleChild(parentNode,newChild){ + var cp = newChild.parentNode; + if(cp){ + var pre = parentNode.lastChild; + cp.removeChild(newChild);//remove and update + var pre = parentNode.lastChild; + } + var pre = parentNode.lastChild; + newChild.parentNode = parentNode; + newChild.previousSibling = pre; + newChild.nextSibling = null; + if(pre){ + pre.nextSibling = newChild; + }else{ + parentNode.firstChild = newChild; + } + parentNode.lastChild = newChild; + _onUpdateChild(parentNode.ownerDocument,parentNode,newChild); + return newChild; + //console.log("__aa",parentNode.lastChild.nextSibling == null) +} +Document.prototype = { + //implementation : null, + nodeName : '#document', + nodeType : DOCUMENT_NODE, + doctype : null, + documentElement : null, + _inc : 1, + + insertBefore : function(newChild, refChild){//raises + if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){ + var child = newChild.firstChild; + while(child){ + var next = child.nextSibling; + this.insertBefore(child,refChild); + child = next; + } + return newChild; + } + if(this.documentElement == null && newChild.nodeType == ELEMENT_NODE){ + this.documentElement = newChild; + } + + return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild; + }, + removeChild : function(oldChild){ + if(this.documentElement == oldChild){ + this.documentElement = null; + } + return _removeChild(this,oldChild); + }, + // Introduced in DOM Level 2: + importNode : function(importedNode,deep){ + return importNode(this,importedNode,deep); + }, + // Introduced in DOM Level 2: + getElementById : function(id){ + var rtv = null; + _visitNode(this.documentElement,function(node){ + if(node.nodeType == ELEMENT_NODE){ + if(node.getAttribute('id') == id){ + rtv = node; + return true; + } + } + }) + return rtv; + }, + + //document factory method: + createElement : function(tagName){ + var node = new Element(); + node.ownerDocument = this; + node.nodeName = tagName; + node.tagName = tagName; + node.childNodes = new NodeList(); + var attrs = node.attributes = new NamedNodeMap(); + attrs._ownerElement = node; + return node; + }, + createDocumentFragment : function(){ + var node = new DocumentFragment(); + node.ownerDocument = this; + node.childNodes = new NodeList(); + return node; + }, + createTextNode : function(data){ + var node = new Text(); + node.ownerDocument = this; + node.appendData(data) + return node; + }, + createComment : function(data){ + var node = new Comment(); + node.ownerDocument = this; + node.appendData(data) + return node; + }, + createCDATASection : function(data){ + var node = new CDATASection(); + node.ownerDocument = this; + node.appendData(data) + return node; + }, + createProcessingInstruction : function(target,data){ + var node = new ProcessingInstruction(); + node.ownerDocument = this; + node.tagName = node.target = target; + node.nodeValue= node.data = data; + return node; + }, + createAttribute : function(name){ + var node = new Attr(); + node.ownerDocument = this; + node.name = name; + node.nodeName = name; + node.localName = name; + node.specified = true; + return node; + }, + createEntityReference : function(name){ + var node = new EntityReference(); + node.ownerDocument = this; + node.nodeName = name; + return node; + }, + // Introduced in DOM Level 2: + createElementNS : function(namespaceURI,qualifiedName){ + var node = new Element(); + var pl = qualifiedName.split(':'); + var attrs = node.attributes = new NamedNodeMap(); + node.childNodes = new NodeList(); + node.ownerDocument = this; + node.nodeName = qualifiedName; + node.tagName = qualifiedName; + node.namespaceURI = namespaceURI; + if(pl.length == 2){ + node.prefix = pl[0]; + node.localName = pl[1]; + }else{ + //el.prefix = null; + node.localName = qualifiedName; + } + attrs._ownerElement = node; + return node; + }, + // Introduced in DOM Level 2: + createAttributeNS : function(namespaceURI,qualifiedName){ + var node = new Attr(); + var pl = qualifiedName.split(':'); + node.ownerDocument = this; + node.nodeName = qualifiedName; + node.name = qualifiedName; + node.namespaceURI = namespaceURI; + node.specified = true; + if(pl.length == 2){ + node.prefix = pl[0]; + node.localName = pl[1]; + }else{ + //el.prefix = null; + node.localName = qualifiedName; + } + return node; + } +}; +_extends(Document,Node); + + +function Element() { + this._nsMap = {}; +}; +Element.prototype = { + nodeType : ELEMENT_NODE, + hasAttribute : function(name){ + return this.getAttributeNode(name)!=null; + }, + getAttribute : function(name){ + var attr = this.getAttributeNode(name); + return attr && attr.value || ''; + }, + getAttributeNode : function(name){ + return this.attributes.getNamedItem(name); + }, + setAttribute : function(name, value){ + var attr = this.ownerDocument.createAttribute(name); + attr.value = attr.nodeValue = "" + value; + this.setAttributeNode(attr) + }, + removeAttribute : function(name){ + var attr = this.getAttributeNode(name) + attr && this.removeAttributeNode(attr); + }, + + //four real opeartion method + appendChild:function(newChild){ + if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){ + return this.insertBefore(newChild,null); + }else{ + return _appendSingleChild(this,newChild); + } + }, + setAttributeNode : function(newAttr){ + return this.attributes.setNamedItem(newAttr); + }, + setAttributeNodeNS : function(newAttr){ + return this.attributes.setNamedItemNS(newAttr); + }, + removeAttributeNode : function(oldAttr){ + //console.log(this == oldAttr.ownerElement) + return this.attributes.removeNamedItem(oldAttr.nodeName); + }, + //get real attribute name,and remove it by removeAttributeNode + removeAttributeNS : function(namespaceURI, localName){ + var old = this.getAttributeNodeNS(namespaceURI, localName); + old && this.removeAttributeNode(old); + }, + + hasAttributeNS : function(namespaceURI, localName){ + return this.getAttributeNodeNS(namespaceURI, localName)!=null; + }, + getAttributeNS : function(namespaceURI, localName){ + var attr = this.getAttributeNodeNS(namespaceURI, localName); + return attr && attr.value || ''; + }, + setAttributeNS : function(namespaceURI, qualifiedName, value){ + var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName); + attr.value = attr.nodeValue = "" + value; + this.setAttributeNode(attr) + }, + getAttributeNodeNS : function(namespaceURI, localName){ + return this.attributes.getNamedItemNS(namespaceURI, localName); + }, + + getElementsByTagName : function(tagName){ + return new LiveNodeList(this,function(base){ + var ls = []; + _visitNode(base,function(node){ + if(node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)){ + ls.push(node); + } + }); + return ls; + }); + }, + getElementsByTagNameNS : function(namespaceURI, localName){ + return new LiveNodeList(this,function(base){ + var ls = []; + _visitNode(base,function(node){ + if(node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){ + ls.push(node); + } + }); + return ls; + + }); + } +}; +Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName; +Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS; + + +_extends(Element,Node); +function Attr() { +}; +Attr.prototype.nodeType = ATTRIBUTE_NODE; +_extends(Attr,Node); + + +function CharacterData() { +}; +CharacterData.prototype = { + data : '', + substringData : function(offset, count) { + return this.data.substring(offset, offset+count); + }, + appendData: function(text) { + text = this.data+text; + this.nodeValue = this.data = text; + this.length = text.length; + }, + insertData: function(offset,text) { + this.replaceData(offset,0,text); + + }, + appendChild:function(newChild){ + throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR]) + }, + deleteData: function(offset, count) { + this.replaceData(offset,count,""); + }, + replaceData: function(offset, count, text) { + var start = this.data.substring(0,offset); + var end = this.data.substring(offset+count); + text = start + text + end; + this.nodeValue = this.data = text; + this.length = text.length; + } +} +_extends(CharacterData,Node); +function Text() { +}; +Text.prototype = { + nodeName : "#text", + nodeType : TEXT_NODE, + splitText : function(offset) { + var text = this.data; + var newText = text.substring(offset); + text = text.substring(0, offset); + this.data = this.nodeValue = text; + this.length = text.length; + var newNode = this.ownerDocument.createTextNode(newText); + if(this.parentNode){ + this.parentNode.insertBefore(newNode, this.nextSibling); + } + return newNode; + } +} +_extends(Text,CharacterData); +function Comment() { +}; +Comment.prototype = { + nodeName : "#comment", + nodeType : COMMENT_NODE +} +_extends(Comment,CharacterData); + +function CDATASection() { +}; +CDATASection.prototype = { + nodeName : "#cdata-section", + nodeType : CDATA_SECTION_NODE +} +_extends(CDATASection,CharacterData); + + +function DocumentType() { +}; +DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE; +_extends(DocumentType,Node); + +function Notation() { +}; +Notation.prototype.nodeType = NOTATION_NODE; +_extends(Notation,Node); + +function Entity() { +}; +Entity.prototype.nodeType = ENTITY_NODE; +_extends(Entity,Node); + +function EntityReference() { +}; +EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE; +_extends(EntityReference,Node); + +function DocumentFragment() { +}; +DocumentFragment.prototype.nodeName = "#document-fragment"; +DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE; +_extends(DocumentFragment,Node); + + +function ProcessingInstruction() { +} +ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE; +_extends(ProcessingInstruction,Node); +function XMLSerializer(){} +XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){ + return nodeSerializeToString.call(node,isHtml,nodeFilter); +} +Node.prototype.toString = nodeSerializeToString; +function nodeSerializeToString(isHtml,nodeFilter){ + var buf = []; + var refNode = this.nodeType == 9?this.documentElement:this; + var prefix = refNode.prefix; + var uri = refNode.namespaceURI; + + if(uri && prefix == null){ + //console.log(prefix) + var prefix = refNode.lookupPrefix(uri); + if(prefix == null){ + //isHTML = true; + var visibleNamespaces=[ + {namespace:uri,prefix:null} + //{namespace:uri,prefix:''} + ] + } + } + serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces); + //console.log('###',this.nodeType,uri,prefix,buf.join('')) + return buf.join(''); +} +function needNamespaceDefine(node,isHTML, visibleNamespaces) { + var prefix = node.prefix||''; + var uri = node.namespaceURI; + if (!prefix && !uri){ + return false; + } + if (prefix === "xml" && uri === "http://www.w3.org/XML/1998/namespace" + || uri == 'http://www.w3.org/2000/xmlns/'){ + return false; + } + + var i = visibleNamespaces.length + //console.log('@@@@',node.tagName,prefix,uri,visibleNamespaces) + while (i--) { + var ns = visibleNamespaces[i]; + // get namespace prefix + //console.log(node.nodeType,node.tagName,ns.prefix,prefix) + if (ns.prefix == prefix){ + return ns.namespace != uri; + } + } + //console.log(isHTML,uri,prefix=='') + //if(isHTML && prefix ==null && uri == 'http://www.w3.org/1999/xhtml'){ + // return false; + //} + //node.flag = '11111' + //console.error(3,true,node.flag,node.prefix,node.namespaceURI) + return true; +} +function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){ + if(nodeFilter){ + node = nodeFilter(node); + if(node){ + if(typeof node == 'string'){ + buf.push(node); + return; + } + }else{ + return; + } + //buf.sort.apply(attrs, attributeSorter); + } + switch(node.nodeType){ + case ELEMENT_NODE: + if (!visibleNamespaces) visibleNamespaces = []; + var startVisibleNamespaces = visibleNamespaces.length; + var attrs = node.attributes; + var len = attrs.length; + var child = node.firstChild; + var nodeName = node.tagName; + + isHTML = (htmlns === node.namespaceURI) ||isHTML + buf.push('<',nodeName); + + + + for(var i=0;i'); + //if is cdata child node + if(isHTML && /^script$/i.test(nodeName)){ + while(child){ + if(child.data){ + buf.push(child.data); + }else{ + serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces); + } + child = child.nextSibling; + } + }else + { + while(child){ + serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces); + child = child.nextSibling; + } + } + buf.push(''); + }else{ + buf.push('/>'); + } + // remove added visible namespaces + //visibleNamespaces.length = startVisibleNamespaces; + return; + case DOCUMENT_NODE: + case DOCUMENT_FRAGMENT_NODE: + var child = node.firstChild; + while(child){ + serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces); + child = child.nextSibling; + } + return; + case ATTRIBUTE_NODE: + return buf.push(' ',node.name,'="',node.value.replace(/[<&"]/g,_xmlEncoder),'"'); + case TEXT_NODE: + return buf.push(node.data.replace(/[<&]/g,_xmlEncoder)); + case CDATA_SECTION_NODE: + return buf.push( ''); + case COMMENT_NODE: + return buf.push( ""); + case DOCUMENT_TYPE_NODE: + var pubid = node.publicId; + var sysid = node.systemId; + buf.push(''); + }else if(sysid && sysid!='.'){ + buf.push(' SYSTEM "',sysid,'">'); + }else{ + var sub = node.internalSubset; + if(sub){ + buf.push(" [",sub,"]"); + } + buf.push(">"); + } + return; + case PROCESSING_INSTRUCTION_NODE: + return buf.push( ""); + case ENTITY_REFERENCE_NODE: + return buf.push( '&',node.nodeName,';'); + //case ENTITY_NODE: + //case NOTATION_NODE: + default: + buf.push('??',node.nodeName); + } +} +function importNode(doc,node,deep){ + var node2; + switch (node.nodeType) { + case ELEMENT_NODE: + node2 = node.cloneNode(false); + node2.ownerDocument = doc; + //var attrs = node2.attributes; + //var len = attrs.length; + //for(var i=0;i']; + _fs2.default.writeFileSync(bridgingHeaderPath, bridgingHeaderContent.join('\n'), { encoding: 'utf-8', flag: 'w' }); + xcodeProject.addHeaderFile('Bridging-Header.h'); + } + + buildConfigs = xcodeProject.pbxXCBuildConfigurationSection(); + + var bridgingHeaderProperty = '"$(PROJECT_DIR)/$(PROJECT_NAME)' + bridgingHeaderPath.split(projectPath)[1] + '"'; + + for (configName in buildConfigs) { + if (!COMMENT_KEY.test(configName)) { + buildConfig = buildConfigs[configName]; + if (xcodeProject.getBuildProperty('SWIFT_OBJC_BRIDGING_HEADER', buildConfig.name) !== bridgingHeaderProperty) { + xcodeProject.updateBuildProperty('SWIFT_OBJC_BRIDGING_HEADER', bridgingHeaderProperty, buildConfig.name); + console.log('Update IOS build setting SWIFT_OBJC_BRIDGING_HEADER to:', bridgingHeaderProperty, 'for build configuration', buildConfig.name); + } + } + } + + // Look for any bridging header defined in the plugin + glob('**/*Bridging-Header*.h', { cwd: pluginsPath }, function (error, files) { + var bridgingHeader = _path2.default.basename(bridgingHeaderPath); + var headers = files.map(function (filePath) { + return _path2.default.basename(filePath); + }); + + // if other bridging headers are found, they are imported in the + // one already configured in the project. + var content = _fs2.default.readFileSync(bridgingHeaderPath, 'utf-8'); + + if (error) throw new Error(error); + + headers.forEach(function (header) { + if (header !== bridgingHeader && !~content.indexOf(header)) { + if (content.charAt(content.length - 1) !== '\n') { + content += '\n'; + } + content += '#import "' + header + '"\n'; + console.log('Importing', header, 'into', bridgingHeaderPath); + } + }); + _fs2.default.writeFileSync(bridgingHeaderPath, content, 'utf-8'); + + for (configName in buildConfigs) { + if (!COMMENT_KEY.test(configName)) { + buildConfig = buildConfigs[configName]; + if (parseFloat(xcodeProject.getBuildProperty('IPHONEOS_DEPLOYMENT_TARGET', buildConfig.name)) < parseFloat(IOS_MIN_DEPLOYMENT_TARGET)) { + xcodeProject.updateBuildProperty('IPHONEOS_DEPLOYMENT_TARGET', IOS_MIN_DEPLOYMENT_TARGET, buildConfig.name); + console.log('Update IOS project deployment target to:', IOS_MIN_DEPLOYMENT_TARGET, 'for build configuration', buildConfig.name); + } + + if (xcodeProject.getBuildProperty('ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES', buildConfig.name) !== 'YES') { + xcodeProject.updateBuildProperty('ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES', 'YES', buildConfig.name); + console.log('Update IOS build setting ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to: YES', 'for build configuration', buildConfig.name); + } + + if (xcodeProject.getBuildProperty('LD_RUNPATH_SEARCH_PATHS', buildConfig.name) !== '"@executable_path/Frameworks"') { + xcodeProject.updateBuildProperty('LD_RUNPATH_SEARCH_PATHS', '"@executable_path/Frameworks"', buildConfig.name); + console.log('Update IOS build setting LD_RUNPATH_SEARCH_PATHS to: @executable_path/Frameworks', 'for build configuration', buildConfig.name); + } + + if (typeof xcodeProject.getBuildProperty('SWIFT_VERSION', buildConfig.name) === 'undefined') { + if (config.getPreference('UseLegacySwiftLanguageVersion', 'ios')) { + xcodeProject.updateBuildProperty('SWIFT_VERSION', '2.3', buildConfig.name); + console.log('Use legacy Swift language version', buildConfig.name); + } else { + xcodeProject.updateBuildProperty('SWIFT_VERSION', '3.0', buildConfig.name); + console.log('Update SWIFT version to 3.0', buildConfig.name); + } + } + + if (buildConfig.name === 'Debug') { + if (xcodeProject.getBuildProperty('SWIFT_OPTIMIZATION_LEVEL', buildConfig.name) !== '"-Onone"') { + xcodeProject.updateBuildProperty('SWIFT_OPTIMIZATION_LEVEL', '"-Onone"', buildConfig.name); + console.log('Update IOS build setting SWIFT_OPTIMIZATION_LEVEL to: -Onone', 'for build configuration', buildConfig.name); + } + } + } + } + + _fs2.default.writeFileSync(pbxprojPath, xcodeProject.writeSync()); + }); + }); + } +}; /* + * This hook adds all the needed config to implement a Cordova plugin with Swift. + * + * - It adds a Bridging header importing Cordova/CDV.h if it's not already + * the case. Else it concats all the bridging headers in one single file. + * + * /!\ Please be sure not naming your bridging header file 'Bridging-Header.h' + * else it won't be supported. + * + * - It puts the ios deployment target to 7.0 in case your project would have a + * lesser one. + * + * - It updates the ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES build setting to YES. + * + * - It updates the SWIFT_VERSION to 3.0. + */ + +var getConfigParser = function getConfigParser(context, configPath) { + var semver = context.requireCordovaModule('semver'); + var ConfigParser = void 0; + + if (semver.lt(context.opts.cordova.version, '5.4.0')) { + ConfigParser = context.requireCordovaModule('cordova-lib/src/ConfigParser/ConfigParser'); + } else { + ConfigParser = context.requireCordovaModule('cordova-common/src/ConfigParser/ConfigParser'); + } + + return new ConfigParser(configPath); +}; + +var getBridgingHeaderPath = function getBridgingHeaderPath(context, projectPath, iosPlatformVersion) { + var semver = context.requireCordovaModule('semver'); + var bridgingHeaderPath = void 0; + if (semver.lt(iosPlatformVersion, '4.0.0')) { + bridgingHeaderPath = _path2.default.posix.join(projectPath, 'Plugins', 'Bridging-Header.h'); + } else { + bridgingHeaderPath = _path2.default.posix.join(projectPath, 'Bridging-Header.h'); + } + + return bridgingHeaderPath; +}; +module.exports = exports['default']; + +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* + * Generated by PEG.js 0.10.0. + * + * http://pegjs.org/ + */ + + + +function peg$subclass(child, parent) { + function ctor() { this.constructor = child; } + ctor.prototype = parent.prototype; + child.prototype = new ctor(); +} + +function peg$SyntaxError(message, expected, found, location) { + this.message = message; + this.expected = expected; + this.found = found; + this.location = location; + this.name = "SyntaxError"; + + if (typeof Error.captureStackTrace === "function") { + Error.captureStackTrace(this, peg$SyntaxError); + } +} + +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]); + } + + return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; + }, + + any: function(expectation) { + return "any character"; + }, + + end: function(expectation) { + return "end of input"; + }, + + other: function(expectation) { + return expectation.description; + } + }; + + 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; + + for (i = 0; i < expected.length; i++) { + descriptions[i] = describeExpectation(expected[i]); + } + + descriptions.sort(); + + 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; + } + + switch (descriptions.length) { + case 1: + return descriptions[0]; + + case 2: + return descriptions[0] + " or " + descriptions[1]; + + default: + return descriptions.slice(0, -1).join(", ") + + ", or " + + descriptions[descriptions.length - 1]; + } + } + + function describeFound(found) { + return found ? "\"" + literalEscape(found) + "\"" : "end of input"; + } + + return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; +}; + +function peg$parse(input, options) { + options = options !== void 0 ? options : {}; + + var peg$FAILED = {}, + + peg$startRuleFunctions = { Project: peg$parseProject }, + peg$startRuleFunction = peg$parseProject, + + peg$c0 = function(headComment, obj) { + var proj = Object.create(null) + proj.project = obj + + if (headComment) { + proj.headComment = headComment + } + + 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 + "\"."); + } + + peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; + } + + function text() { + return input.substring(peg$savedPos, peg$currPos); + } + + function location() { + return peg$computeLocation(peg$savedPos, peg$currPos); + } + + function expected(description, location) { + location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) + + throw peg$buildStructuredError( + [peg$otherExpectation(description)], + input.substring(peg$savedPos, peg$currPos), + location + ); + } + + function error(message, location) { + location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) + + throw peg$buildSimpleError(message, location); + } + + 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 }; + } + + function peg$anyExpectation() { + return { type: "any" }; + } + + function peg$endExpectation() { + return { type: "end" }; + } + + function peg$otherExpectation(description) { + return { type: "other", description: description }; + } + + function peg$computePosDetails(pos) { + var details = peg$posDetailsCache[pos], p; + + if (details) { + return details; + } else { + p = pos - 1; + while (!peg$posDetailsCache[p]) { + p--; + } + + 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++; + } + + peg$posDetailsCache[pos] = details; + return details; + } + } + + function peg$computeLocation(startPos, endPos) { + var startPosDetails = peg$computePosDetails(startPos), + endPosDetails = peg$computePosDetails(endPos); + + return { + start: { + offset: startPos, + line: startPosDetails.line, + column: startPosDetails.column + }, + end: { + offset: endPos, + line: endPosDetails.line, + column: endPosDetails.column + } + }; + } + + function peg$fail(expected) { + if (peg$currPos < peg$maxFailPos) { return; } + + if (peg$currPos > peg$maxFailPos) { + peg$maxFailPos = peg$currPos; + peg$maxFailExpected = []; + } + + peg$maxFailExpected.push(expected); + } + + function peg$buildSimpleError(message, location) { + return new peg$SyntaxError(message, null, null, location); + } + + function peg$buildStructuredError(expected, found, location) { + return new peg$SyntaxError( + peg$SyntaxError.buildMessage(expected, found), + expected, + found, + location + ); + } + + function peg$parseProject() { + var s0, s1, s2, s3, s4, s5, s6; + + 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; + } + + return s0; + } + + function peg$parseObject() { + var s0, s1, s2, s3; + + 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; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseEmptyBody() { + var s0, s1; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c6(); + } + s0 = s1; + + return s0; + } + + function peg$parseAssignmentList() { + var s0, s1, s2, s3, s4, s5; + + 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; + } 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; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + } 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; + } + + return s0; + } + + function peg$parseAssignment() { + var s0; + + s0 = peg$parseSimpleAssignment(); + if (s0 === peg$FAILED) { + s0 = peg$parseCommentedAssignment(); + } + + return s0; + } + + function peg$parseSimpleAssignment() { + var s0, s1, s2, s3, s4, s5, s6; + + 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; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseCommentedAssignment() { + var s0, s1, s2, s3, s4, s5, s6; + + 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; + } + + function peg$parseCommentedIdentifier() { + var s0, s1, s2, s3; + + 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; + } + + return s0; + } + + function peg$parseCommentedValue() { + var s0, s1, s2, s3; + + 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; + } + + return s0; + } + + 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); } + } + 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 (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; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseInlineCommentOpen() { + var s0; + + 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; + } + + 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); } + } + + return s0; + } + + 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; + } + + 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 (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; + } + + 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 (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; + } + + 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(); + } + 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; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseEmptyArray() { + var s0, s1; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c37(); + } + s0 = s1; + + return s0; + } + + function peg$parseArrayBody() { + var s0, s1, s2, s3, s4, s5; + + 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; + } + + return s0; + } + + function peg$parseArrayEntry() { + var s0; + + s0 = peg$parseSimpleArrayEntry(); + if (s0 === peg$FAILED) { + s0 = peg$parseCommentedArrayEntry(); + } + + return s0; + } + + 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; + } + + return s0; + } + + function peg$parseCommentedArrayEntry() { + var s0, s1, s2, s3, s4; + + 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; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseEndArrayEntry() { + var s0, s1, s2, s3; + + 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; + } + } + + return s0; + } + + function peg$parseIdentifier() { + var s0, s1, s2; + + 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(); + } + + return s0; + } + + function peg$parseValue() { + var s0; + + s0 = peg$parseObject(); + if (s0 === peg$FAILED) { + s0 = peg$parseArray(); + if (s0 === peg$FAILED) { + s0 = peg$parseNumberValue(); + if (s0 === peg$FAILED) { + s0 = peg$parseStringValue(); + } + } + } + + return s0; + } + + function peg$parseNumberValue() { + var s0; + + s0 = peg$parseDecimalValue(); + if (s0 === peg$FAILED) { + s0 = peg$parseIntegerValue(); + } + + return s0; + } + + function peg$parseDecimalValue() { + var s0, s1, s2, s3, s4; + + 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; + } + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c48(s1); + } + s0 = s1; + + return s0; + } + + function peg$parseIntegerValue() { + var s0, s1, s2, s3, s4; + + 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(); + } + } else { + s2 = peg$FAILED; + } + 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; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseStringValue() { + var s0; + + s0 = peg$parseQuotedString(); + if (s0 === peg$FAILED) { + s0 = peg$parseLiteralString(); + } + + return s0; + } + + function peg$parseQuotedString() { + var s0, s1, s2, s3; + + 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; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + + function peg$parseQuotedBody() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = []; + s2 = peg$parseNonQuote(); + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$parseNonQuote(); + } + } else { + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$c51(s1); + } + s0 = s1; + + return s0; + } + + function peg$parseNonQuote() { + var s0, s1, s2; + + s0 = peg$parseEscapedQuote(); + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$currPos; + peg$silentFails++; + s2 = peg$parseDoubleQuote(); + peg$silentFails--; + if (s2 === peg$FAILED) { + s1 = void 0; + } else { + peg$currPos = s1; + s1 = peg$FAILED; + } + if (s1 !== peg$FAILED) { + if (input.length > 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 s0; + } + + 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; + } + + return s0; + } + + function peg$parseLiteralString() { + var s0, s1, s2; + + 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; + + return s0; + } + + 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; + } + 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; + } + + 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); } + } + + return s0; + } + + function peg$parseSingleLineComment() { + var s0, s1, s2, s3, s4; + + 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; + } + + return s0; + } + + function peg$parseOneLineString() { + var s0, s1, s2; + + 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; + + return s0; + } + + function peg$parseDigit() { + var s0; + + 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; + } + + function peg$parseAlpha() { + var s0; + + 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; + + 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; + } + + function peg$parse_() { + var s0, s1; + + 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); } + } + + return s0; + } + + function peg$parsewhitespace() { + var s0; + + 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; + } + + function peg$parseNonLine() { + var s0, s1, s2; + + 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; + } + + 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); } + } + } + + return s0; + } + + function peg$parseNewLine() { + var s0; + + 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); } + } + + 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) + ); + } +} + +module.exports = { + SyntaxError: peg$SyntaxError, + parse: peg$parse +}; + + +/***/ }), +/* 43 */ +/***/ (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 + }; + + +function unquoted(text){ + return text.replace (/(^")|("$)/g, '') +} + +function detectType(filePath) { + var extension = path.extname(filePath).substring(1), + filetype = FILETYPE_BY_EXTENSION[unquoted(extension)]; + + if (!filetype) { + return DEFAULT_FILETYPE; + } + + 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; + } + } +} + +function defaultEncoding(fileRef) { + var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, + encoding = ENCODING_BY_FILETYPE[unquoted(filetype)]; + + if (encoding) { + return encoding; + } +} + +function detectGroup(fileRef, opt) { + var extension = path.extname(fileRef.basename).substring(1), + filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, + groupName = GROUP_BY_FILETYPE[unquoted(filetype)]; + + if (extension === 'xcdatamodeld') { + return 'Sources'; + } + + if (opt.customFramework && opt.embed) { + return GROUP_BY_FILETYPE['embedded.framework']; + } + + if (!groupName) { + return DEFAULT_GROUP; + } + + return groupName; +} + +function detectSourcetree(fileRef) { + + var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, + sourcetree = SOURCETREE_BY_FILETYPE[unquoted(filetype)]; + + if (fileRef.explicitFileType) { + return DEFAULT_PRODUCT_SOURCETREE; + } + + if (fileRef.customFramework) { + return DEFAULT_SOURCETREE; + } + + if (!sourcetree) { + return DEFAULT_SOURCETREE; + } + + return sourcetree; +} + +function defaultPath(fileRef, filePath) { + var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType, + defaultPath = PATH_BY_FILETYPE[unquoted(filetype)]; + + if (fileRef.customFramework) { + return filePath; + } + + if (defaultPath) { + return path.join(defaultPath, path.basename(filePath)); + } + + return filePath; +} + +function defaultGroup(fileRef) { + var groupName = GROUP_BY_FILETYPE[fileRef.lastKnownFileType]; + + if (!groupName) { + return DEFAULT_GROUP; + } + + 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, '/'); + } + + this.path = defaultPath(this, filepath).replace(/\\/g, '/'); + this.fileEncoding = this.defaultEncoding = opt.defaultEncoding || defaultEncoding(this); + + // 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; + } + + this.sourceTree = opt.sourceTree || detectSourcetree(this); + this.includeInIndex = 0; + + 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); + } + + if (opt.embed && opt.sign) { + if (!this.settings) + this.settings = {}; + if (!this.settings.ATTRIBUTES) + this.settings.ATTRIBUTES = []; + this.settings.ATTRIBUTES.push('CodeSignOnCopy'); + } +} + +module.exports = pbxFile; + + +/***/ }), +/* 44 */ +/***/ (function(module, exports, __webpack_require__) { + +var pbxProj = __webpack_require__(17), + util = __webpack_require__(5), + f = util.format, + INDENT = '\t', + COMMENT_KEY = /_comment$/, + QUOTED = /^"(.*)"$/, + EventEmitter = __webpack_require__(38).EventEmitter + +// indentation +function i(x) { + if (x <=0) + return ''; + else + return INDENT + i(x-1); +} + +function comment(key, parent) { + var text = parent[key + '_comment']; + + if (text) + return text; + else + return null; +} + +// copied from underscore +function isObject(obj) { + return obj === Object(obj) +} + +function isArray(obj) { + return Array.isArray(obj) +} + +function pbxWriter(contents) { + this.contents = contents; + this.sync = false; + this.indentLevel = 0; +} + +util.inherits(pbxWriter, EventEmitter); + +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 + } +} + +pbxWriter.prototype.writeFlush = function (str) { + var oldIndent = this.indentLevel; + + this.indentLevel = 0; + + this.write.apply(this, arguments) + + this.indentLevel = oldIndent; +} + +pbxWriter.prototype.writeSync = function () { + this.sync = true; + this.buffer = ""; + + this.writeHeadComment(); + this.writeProject(); + + return this.buffer; +} + +pbxWriter.prototype.writeHeadComment = function () { + if (this.contents.headComment) { + this.write("// %s\n", this.contents.headComment) + } +} + +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; + + 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++; + + if (key === 'objects') { + this.writeObjectsSections(obj) + } else { + this.writeObject(obj) + } + + 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) + } + } + + this.indentLevel--; + } + + this.write("}\n") +} + +pbxWriter.prototype.writeObject = function (object) { + var key, obj, cmt; + + for (key in object) { + if (COMMENT_KEY.test(key)) continue; + + cmt = comment(key, object); + obj = object[key]; + + if (isArray(obj)) { + this.writeArray(obj, key) + } else if (isObject(obj)) { + this.write("%s = {\n", key); + this.indentLevel++; + + this.writeObject(obj) + + 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) + } + } + } +} + +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); + } + } +} + +pbxWriter.prototype.writeArray = function (arr, name) { + var i, entry; + + this.write("%s = (\n", name); + this.indentLevel++; + + 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); + } + } + + this.indentLevel--; + this.write(");\n"); +} + +pbxWriter.prototype.writeSectionComment = function (name, begin) { + if (begin) { + this.writeFlush("/* Begin %s section */\n", name) + } else { // end + this.writeFlush("/* End %s section */\n", name) + } +} + +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 { + if (cmt) { + this.write("%s /* %s */ = {\n", key, cmt); + } else { + this.write("%s = {\n", key); + } + + this.indentLevel++ + + this.writeObject(obj) + + this.indentLevel-- + this.write("};\n"); + } + } +} + +pbxWriter.prototype.writeInlineObject = function (n, d, r) { + var output = []; + + 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)); + } + + 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])) + } + + 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)) + } + } + + output.push("}; "); + } + + inlineObjectHelper(n, d, r); + + this.write("%s\n", output.join('').trim()); +} + +module.exports = pbxWriter; + + +/***/ }), +/* 45 */ +/***/ (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 + +/*global window, require, define */ +(function(_window) { + 'use strict'; + + // 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; + + function setupBrowser() { + // Allow for MSIE11 msCrypto + var _crypto = _window.crypto || _window.msCrypto; + + 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) {} + } + + 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; + } + + return _rnds; + }; + if ('undefined' !== typeof console && console.warn) { + console.warn("[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()"); + } + } + } + + 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__(105).randomBytes; + _nodeRNG = _rng = _rb && function() {return _rb(16);}; + _rng(); + } catch(e) {} + } + } + + if (_window) { + setupBrowser(); + } else { + setupNode(); + } + + // 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; + } + + // **`parse()` - Parse a UUID into it's component bytes** + function parse(s, buf, offset) { + var i = (buf && offset) || 0, ii = 0; + + buf = buf || []; + s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) { + if (ii < 16) { // Don't overflow! + buf[i + ii++] = _hexToByte[oct]; + } + }); + + // Zero out remaining bytes if string was short + while (ii < 16) { + buf[i + ii++] = 0; + } + + 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); + + +/***/ }), +/* 46 */ +/***/ (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__(48); + +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(); + return buffer.getContents(); + + function updateEntryIds() { + var strings = {}; + var entryId = 0; + entries.forEach(function(entry) { + if (entry.id) { + return; + } + if (entry.type === 'string') { + if (!entry.bplistOverride && strings.hasOwnProperty(entry.value)) { + entry.type = 'stringref'; + entry.id = strings[entry.value]; + } else { + strings[entry.value] = entry.id = entryId++; + } + } else { + entry.id = entryId++; + } + }); + + entries = entries.filter(function(entry) { + return (entry.type !== 'stringref'); + }); + } + + function writeTrailer() { + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeTrailer'); + } + // 6 null bytes + buffer.write(new Buffer([0, 0, 0, 0, 0, 0])); + + // size of an offset + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeTrailer(offsetSizeInBytes):', offsetSizeInBytes); + } + writeByte(offsetSizeInBytes); + + // size of a ref + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeTrailer(offsetSizeInBytes):', idSizeInBytes); + } + writeByte(idSizeInBytes); + + // number of objects + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeTrailer(number of objects):', entries.length); + } + writeLong(entries.length); + + // top object + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeTrailer(top object)'); + } + writeLong(0); + + // offset table offset + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeTrailer(offset table offset):', offsetTableOffset); + } + writeLong(offsetTableOffset); + } + + function writeOffsetTable() { + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeOffsetTable'); + } + offsetTableOffset = buffer.size(); + offsetSizeInBytes = computeOffsetSizeInBytes(offsetTableOffset); + offsets.forEach(function(offset) { + writeBytes(offset, offsetSizeInBytes); + }); + } + + function write(entry) { + switch (entry.type) { + case 'dict': + writeDict(entry); + break; + case 'number': + case 'double': + writeNumber(entry); + break; + case 'array': + writeArray(entry); + break; + case 'boolean': + writeBoolean(entry); + break; + case 'string': + case 'string-utf16': + writeString(entry); + break; + case 'data': + writeData(entry); + break; + default: + throw new Error("unhandled entry type: " + entry.type); + } + } + + function writeDict(entry) { + if (debug) { + var keysStr = entry.entryKeys.map(function(k) {return k.id;}); + var valsStr = entry.entryValues.map(function(k) {return k.id;}); + console.log('0x' + buffer.size().toString(16), 'writeDict', '(id: ' + entry.id + ')', '(keys: ' + keysStr + ')', '(values: ' + valsStr + ')'); + } + writeIntHeader(0xD, entry.entryKeys.length); + entry.entryKeys.forEach(function(entry) { + writeID(entry.id); + }); + entry.entryValues.forEach(function(entry) { + writeID(entry.id); + }); + } + + function writeNumber(entry) { + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeNumber', entry.value, ' (type: ' + entry.type + ')', '(id: ' + entry.id + ')'); + } + + if (entry.type !== 'double' && parseFloat(entry.value.toFixed()) == entry.value) { + if (entry.value < 0) { + writeByte(0x13); + writeBytes(entry.value, 8); + } else if (entry.value <= 0xff) { + writeByte(0x10); + writeBytes(entry.value, 1); + } else if (entry.value <= 0xffff) { + writeByte(0x11); + writeBytes(entry.value, 2); + } else if (entry.value <= 0xffffffff) { + writeByte(0x12); + writeBytes(entry.value, 4); + } else { + writeByte(0x13); + writeBytes(entry.value, 8); + } + } else { + writeByte(0x23); + writeDouble(entry.value); + } + } + + function writeArray(entry) { + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeArray (length: ' + entry.entries.length + ')', '(id: ' + entry.id + ')'); + } + writeIntHeader(0xA, entry.entries.length); + entry.entries.forEach(function(e) { + writeID(e.id); + }); + } + + function writeBoolean(entry) { + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeBoolean', entry.value, '(id: ' + entry.id + ')'); + } + writeByte(entry.value ? 0x09 : 0x08); + } + + function writeString(entry) { + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeString', entry.value, '(id: ' + entry.id + ')'); + } + if (entry.type === 'string-utf16') { + var utf16 = new Buffer(entry.value, 'ucs2'); + writeIntHeader(0x6, utf16.length / 2); + // needs to be big endian so swap the bytes + for (var i = 0; i < utf16.length; i += 2) { + var t = utf16[i + 0]; + utf16[i + 0] = utf16[i + 1]; + utf16[i + 1] = t; + } + buffer.write(utf16); + } else { + var utf8 = new Buffer(entry.value, 'utf8'); + writeIntHeader(0x5, utf8.length); + buffer.write(utf8); + } + } + + function writeData(entry) { + if (debug) { + console.log('0x' + buffer.size().toString(16), 'writeData', entry.value, '(id: ' + entry.id + ')'); + } + writeIntHeader(0x4, entry.value.length); + buffer.write(entry.value); + } + + function writeLong(l) { + writeBytes(l, 8); + } + + function writeByte(b) { + buffer.write(new Buffer([b])); + } + + function writeDouble(v) { + var buf = new Buffer(8); + buf.writeDoubleBE(v, 0); + buffer.write(buf); + } + + function writeIntHeader(kind, value) { + if (value < 15) { + writeByte((kind << 4) + value); + } else if (value < 256) { + writeByte((kind << 4) + 15); + writeByte(0x10); + writeBytes(value, 1); + } else if (value < 65536) { + writeByte((kind << 4) + 15); + writeByte(0x11); + writeBytes(value, 2); + } else { + writeByte((kind << 4) + 15); + writeByte(0x12); + writeBytes(value, 4); + } + } + + function writeID(id) { + writeBytes(id, idSizeInBytes); + } + + function writeBytes(value, bytes) { + // write low-order bytes big-endian style + var buf = new Buffer(bytes); + var z = 0; + // javascript doesn't handle large numbers + while (bytes > 4) { + buf[z++] = 0; + bytes--; + } + for (var i = bytes - 1; i >= 0; i--) { + buf[z++] = value >> (8 * i); + } + buffer.write(buf); + } +}; + +function toEntries(dicts) { + if (dicts.bplistOverride) { + return [dicts]; + } + + if (dicts instanceof Array) { + return toEntriesArray(dicts); + } else if (dicts instanceof Buffer) { + return [ + { + type: 'data', + value: dicts + } + ]; + } else if (dicts instanceof Real) { + return [ + { + type: 'double', + value: dicts.value + } + ]; + } else if (typeof(dicts) === 'object') { + return toEntriesObject(dicts); + } else if (typeof(dicts) === 'string') { + return [ + { + type: 'string', + value: dicts + } + ]; + } else if (typeof(dicts) === 'number') { + return [ + { + type: 'number', + value: dicts + } + ]; + } else if (typeof(dicts) === 'boolean') { + return [ + { + type: 'boolean', + value: dicts + } + ]; + } else { + throw new Error('unhandled entry: ' + dicts); + } +} + +function toEntriesArray(arr) { + if (debug) { + console.log('toEntriesArray'); + } + var results = [ + { + type: 'array', + entries: [] + } + ]; + arr.forEach(function(v) { + var entry = toEntries(v); + results[0].entries.push(entry[0]); + results = results.concat(entry); + }); + return results; +} + +function toEntriesObject(dict) { + if (debug) { + console.log('toEntriesObject'); + } + var results = [ + { + type: 'dict', + entryKeys: [], + entryValues: [] + } + ]; + Object.keys(dict).forEach(function(key) { + var entryKey = toEntries(key); + results[0].entryKeys.push(entryKey[0]); + results = results.concat(entryKey[0]); + }); + Object.keys(dict).forEach(function(key) { + var entryValue = toEntries(dict[key]); + results[0].entryValues.push(entryValue[0]); + results = results.concat(entryValue); + }); + return results; +} + +function computeOffsetSizeInBytes(maxOffset) { + if (maxOffset < 256) { + return 1; + } + if (maxOffset < 65536) { + return 2; + } + if (maxOffset < 4294967296) { + return 4; + } + return 8; +} + +function computeIdSizeInBytes(numberOfIds) { + if (numberOfIds < 256) { + return 1; + } + if (numberOfIds < 65536) { + return 2; + } + return 4; +} + +module.exports.Real = Real; + + +/***/ }), +/* 47 */ +/***/ (function(module, exports, __webpack_require__) { + +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); + + +/***/ }), +/* 48 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = __webpack_require__(13); +module.exports.ReadableStreamBuffer = __webpack_require__(47); +module.exports.WritableStreamBuffer = __webpack_require__(49); + + +/***/ }), +/* 49 */ +/***/ (function(module, exports, __webpack_require__) { + +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); + + +/***/ }), +/* 50 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +// adapted from http://code.google.com/p/plist/source/browse/trunk/src/com/dd/plist/BinaryPropertyListParser.java + +var fs = __webpack_require__(9); +var debug = false; + +exports.maxObjectSize = 100 * 1000 * 1000; // 100Meg +exports.maxObjectCount = 32768; + +// EPOCH = new SimpleDateFormat("yyyy MM dd zzz").parse("2001 01 01 GMT").getTime(); +// ...but that's annoying in a static initializer because it can throw exceptions, ick. +// So we just hardcode the correct value. +var EPOCH = 978307200000; + +var parseFile = exports.parseFile = function (fileNameOrBuffer, callback) { + function tryParseBuffer(buffer) { + var err = null; + var result; + try { + result = parseBuffer(buffer); + } catch (ex) { + err = ex; + } + callback(err, result); + } + + if (Buffer.isBuffer(fileNameOrBuffer)) { + return tryParseBuffer(fileNameOrBuffer); + } else { + fs.readFile(fileNameOrBuffer, function (err, data) { + if (err) { return callback(err); } + tryParseBuffer(data); + }); + } +}; + +var parseBuffer = exports.parseBuffer = function (buffer) { + var result = {}; + + // check header + var header = buffer.slice(0, 'bplist'.length).toString('utf8'); + if (header !== 'bplist') { + throw new Error("Invalid binary plist. Expected 'bplist' at offset 0."); + } + + // Handle trailer, last 32 bytes of the file + var trailer = buffer.slice(buffer.length - 32, buffer.length); + // 6 null bytes (index 0 to 5) + var offsetSize = trailer.readUInt8(6); + if (debug) { + console.log("offsetSize: " + offsetSize); + } + var objectRefSize = trailer.readUInt8(7); + if (debug) { + console.log("objectRefSize: " + objectRefSize); + } + var numObjects = readUInt64BE(trailer, 8); + if (debug) { + console.log("numObjects: " + numObjects); + } + var topObject = readUInt64BE(trailer, 16); + if (debug) { + console.log("topObject: " + topObject); + } + var offsetTableOffset = readUInt64BE(trailer, 24); + if (debug) { + console.log("offsetTableOffset: " + offsetTableOffset); + } + + if (numObjects > exports.maxObjectCount) { + throw new Error("maxObjectCount exceeded"); + } + + // Handle offset table + var offsetTable = []; + + for (var i = 0; i < numObjects; i++) { + var offsetBytes = buffer.slice(offsetTableOffset + i * offsetSize, offsetTableOffset + (i + 1) * offsetSize); + offsetTable[i] = readUInt(offsetBytes, 0); + if (debug) { + console.log("Offset for Object #" + i + " is " + offsetTable[i] + " [" + offsetTable[i].toString(16) + "]"); + } + } + + // Parses an object inside the currently parsed binary property list. + // For the format specification check + // + // Apple's binary property list parser implementation. + function parseObject(tableOffset) { + var offset = offsetTable[tableOffset]; + var type = buffer[offset]; + var objType = (type & 0xF0) >> 4; //First 4 bits + var objInfo = (type & 0x0F); //Second 4 bits + switch (objType) { + case 0x0: + return parseSimple(); + case 0x1: + return parseInteger(); + case 0x8: + return parseUID(); + case 0x2: + return parseReal(); + case 0x3: + return parseDate(); + case 0x4: + return parseData(); + case 0x5: // ASCII + return parsePlistString(); + case 0x6: // UTF-16 + return parsePlistString(true); + case 0xA: + return parseArray(); + case 0xD: + return parseDictionary(); + default: + throw new Error("Unhandled type 0x" + objType.toString(16)); + } + + function parseSimple() { + //Simple + switch (objInfo) { + case 0x0: // null + return null; + case 0x8: // false + return false; + case 0x9: // true + return true; + case 0xF: // filler byte + return null; + default: + throw new Error("Unhandled simple type 0x" + objType.toString(16)); + } + } + + function parseInteger() { + var length = Math.pow(2, objInfo); + if (length < exports.maxObjectSize) { + return readUInt(buffer.slice(offset + 1, offset + 1 + length)); + } else { + throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); + } + } + + function parseUID() { + var length = objInfo + 1; + if (length < exports.maxObjectSize) { + return readUInt(buffer.slice(offset + 1, offset + 1 + length)); + } else { + throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); + } + } + + function parseReal() { + var length = Math.pow(2, objInfo); + if (length < exports.maxObjectSize) { + var realBuffer = buffer.slice(offset + 1, offset + 1 + length); + if (length === 4) { + return realBuffer.readFloatBE(0); + } + else if (length === 8) { + return realBuffer.readDoubleBE(0); + } + } else { + throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); + } + } + + function parseDate() { + if (objInfo != 0x3) { + console.error("Unknown date type :" + objInfo + ". Parsing anyway..."); + } + var dateBuffer = buffer.slice(offset + 1, offset + 9); + return new Date(EPOCH + (1000 * dateBuffer.readDoubleBE(0))); + } + + function parseData() { + var dataoffset = 1; + var length = objInfo; + if (objInfo == 0xF) { + var int_type = buffer[offset + 1]; + var intType = (int_type & 0xF0) / 0x10; + if (intType != 0x1) { + console.error("0x4: UNEXPECTED LENGTH-INT TYPE! " + intType); + } + var intInfo = int_type & 0x0F; + var intLength = Math.pow(2, intInfo); + dataoffset = 2 + intLength; + if (intLength < 3) { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } else { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } + } + if (length < exports.maxObjectSize) { + return buffer.slice(offset + dataoffset, offset + dataoffset + length); + } else { + throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); + } + } + + function parsePlistString (isUtf16) { + isUtf16 = isUtf16 || 0; + var enc = "utf8"; + var length = objInfo; + var stroffset = 1; + if (objInfo == 0xF) { + var int_type = buffer[offset + 1]; + var intType = (int_type & 0xF0) / 0x10; + if (intType != 0x1) { + console.err("UNEXPECTED LENGTH-INT TYPE! " + intType); + } + var intInfo = int_type & 0x0F; + var intLength = Math.pow(2, intInfo); + var stroffset = 2 + intLength; + if (intLength < 3) { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } else { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } + } + // length is String length -> to get byte length multiply by 2, as 1 character takes 2 bytes in UTF-16 + length *= (isUtf16 + 1); + if (length < exports.maxObjectSize) { + var plistString = buffer.slice(offset + stroffset, offset + stroffset + length); + if (isUtf16) { + plistString = swapBytes(plistString); + enc = "ucs2"; + } + return plistString.toString(enc); + } else { + throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); + } + } + + function parseArray() { + var length = objInfo; + var arrayoffset = 1; + if (objInfo == 0xF) { + var int_type = buffer[offset + 1]; + var intType = (int_type & 0xF0) / 0x10; + if (intType != 0x1) { + console.error("0xa: UNEXPECTED LENGTH-INT TYPE! " + intType); + } + var intInfo = int_type & 0x0F; + var intLength = Math.pow(2, intInfo); + arrayoffset = 2 + intLength; + if (intLength < 3) { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } else { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } + } + if (length * objectRefSize > exports.maxObjectSize) { + throw new Error("To little heap space available!"); + } + var array = []; + for (var i = 0; i < length; i++) { + var objRef = readUInt(buffer.slice(offset + arrayoffset + i * objectRefSize, offset + arrayoffset + (i + 1) * objectRefSize)); + array[i] = parseObject(objRef); + } + return array; + } + + function parseDictionary() { + var length = objInfo; + var dictoffset = 1; + if (objInfo == 0xF) { + var int_type = buffer[offset + 1]; + var intType = (int_type & 0xF0) / 0x10; + if (intType != 0x1) { + console.error("0xD: UNEXPECTED LENGTH-INT TYPE! " + intType); + } + var intInfo = int_type & 0x0F; + var intLength = Math.pow(2, intInfo); + dictoffset = 2 + intLength; + if (intLength < 3) { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } else { + length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength)); + } + } + if (length * 2 * objectRefSize > exports.maxObjectSize) { + throw new Error("To little heap space available!"); + } + if (debug) { + console.log("Parsing dictionary #" + tableOffset); + } + var dict = {}; + for (var i = 0; i < length; i++) { + var keyRef = readUInt(buffer.slice(offset + dictoffset + i * objectRefSize, offset + dictoffset + (i + 1) * objectRefSize)); + var valRef = readUInt(buffer.slice(offset + dictoffset + (length * objectRefSize) + i * objectRefSize, offset + dictoffset + (length * objectRefSize) + (i + 1) * objectRefSize)); + var key = parseObject(keyRef); + var val = parseObject(valRef); + if (debug) { + console.log(" DICT #" + tableOffset + ": Mapped " + key + " to " + val); + } + dict[key] = val; + } + return dict; + } + } + + return [ parseObject(topObject) ]; +}; + +function readUInt(buffer, start) { + start = start || 0; + + var l = 0; + for (var i = start; i < buffer.length; i++) { + l <<= 8; + l |= buffer[i] & 0xFF; + } + return l; +} + +// we're just going to toss the high order bits because javascript doesn't have 64-bit ints +function readUInt64BE(buffer, start) { + var data = buffer.slice(start, start + 8); + return data.readUInt32BE(4, 8); +} + +function swapBytes(buffer) { + var len = buffer.length; + for (var i = 0; i < len; i += 2) { + var a = buffer[i]; + buffer[i] = buffer[i+1]; + buffer[i+1] = a; + } + return buffer; +} + + +/***/ }), +/* 51 */ +/***/ (function(module, exports, __webpack_require__) { + + +/** + * Module dependencies. + */ + +var base64 = __webpack_require__(54); +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` + opts.pretty = opts.pretty !== false; + return doc.end(opts); +} + +/** + * depth first, recursive traversal of a javascript object. when complete, + * next_child contains a reference to the build XML object. + * + * @api private + */ + +function walk_obj(next, next_child) { + var tag_type, i, prop; + var name = type(next); + + if ('Undefined' == name) { + return; + } else if (Array.isArray(next)) { + next_child = next_child.ele('array'); + for (i = 0; i < next.length; i++) { + walk_obj(next[i], next_child); + } + + } else if (Buffer.isBuffer(next)) { + next_child.ele('data').raw(next.toString('base64')); + + } else if ('Object' == name) { + next_child = next_child.ele('dict'); + for (prop in next) { + if (next.hasOwnProperty(prop)) { + next_child.ele('key').txt(prop); + walk_obj(next[prop], next_child); + } + } + + } else if ('Number' == name) { + // detect if this is an integer or real + // TODO: add an ability to force one way or another via a "cast" + tag_type = (next % 1 === 0) ? 'integer' : 'real'; + next_child.ele(tag_type).txt(next.toString()); + + } else if ('Date' == name) { + next_child.ele('date').txt(ISODateString(new Date(next))); + + } else if ('Boolean' == name) { + next_child.ele(next ? 'true' : 'false'); + + } else if ('String' == name) { + next_child.ele('string').txt(next); + + } else if ('ArrayBuffer' == name) { + next_child.ele('data').raw(base64.fromByteArray(next)); + + } else if (next && next.buffer && 'ArrayBuffer' == type(next.buffer)) { + // a typed array + next_child.ele('data').raw(base64.fromByteArray(new Uint8Array(next.buffer), next_child)); + + } +} + + +/***/ }), +/* 52 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * Module dependencies. + */ + +var fs = __webpack_require__(9); +var parse = __webpack_require__(18); +var deprecate = __webpack_require__(19); + +/** + * Module exports. + */ + +exports.parseFile = deprecate(parseFile, '`parseFile()` is deprecated. ' + + 'Use `parseString()` instead.'); +exports.parseFileSync = deprecate(parseFileSync, '`parseFileSync()` is deprecated. ' + + 'Use `parseStringSync()` instead.'); + +/** + * Parses file `filename` as a .plist file. + * Invokes `fn` callback function when done. + * + * @param {String} filename - name of the file to read + * @param {Function} fn - callback function + * @api public + * @deprecated use parseString() instead + */ + +function parseFile (filename, fn) { + fs.readFile(filename, { encoding: 'utf8' }, onread); + function onread (err, inxml) { + if (err) return fn(err); + parse.parseString(inxml, fn); + } +} + +/** + * Parses file `filename` as a .plist file. + * Returns a when done. + * + * @param {String} filename - name of the file to read + * @param {Function} fn - callback function + * @api public + * @deprecated use parseStringSync() instead + */ + +function parseFileSync (filename) { + var inxml = fs.readFileSync(filename, 'utf8'); + return parse.parseStringSync(inxml); +} + + +/***/ }), +/* 53 */ +/***/ (function(module, exports, __webpack_require__) { + + +var i; + +/** + * Parser functions. + */ + +var parserFunctions = __webpack_require__(18); +for (i in parserFunctions) exports[i] = parserFunctions[i]; + +/** + * Builder functions. + */ + +var builderFunctions = __webpack_require__(51); +for (i in builderFunctions) exports[i] = builderFunctions[i]; + +/** + * Add Node.js-specific functions (they're deprecated…). + */ + +var nodeFunctions = __webpack_require__(52); +for (i in nodeFunctions) exports[i] = nodeFunctions[i]; + + +/***/ }), +/* 54 */ +/***/ (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) + + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? b64.length - 4 : b64.length + + var L = 0 + + 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)) + + +/***/ }), +/* 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); + } + + XMLAttribute.prototype.clone = function() { + return create(XMLAttribute.prototype, this); + }; + + XMLAttribute.prototype.toString = function(options, level) { + return ' ' + this.name + '="' + this.value + '"'; + }; + + 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); + } + } + } + + 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); + + +/***/ }), +/* 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 (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"); + } + 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"); + } + if (!value) { + value = '(#PCDATA)'; + } + if (Array.isArray(value)) { + value = '(' + value.join(',') + ')'; + } + this.name = this.stringify.eleName(name); + this.value = this.stringify.dtdElementValue(value); + } + + 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; + }; + + return XMLDTDElement; + + })(); + +}).call(this); + + +/***/ }), +/* 59 */ +/***/ (function(module, exports, __webpack_require__) { + +// Generated by CoffeeScript 1.9.1 +(function() { + var XMLDTDEntity, create, isObject; + + create = __webpack_require__(1); + + 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 (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"); + } + } + } + + 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; + } + return r; + }; + + return XMLDTDEntity; + + })(); + +}).call(this); + + +/***/ }), +/* 60 */ +/***/ (function(module, exports, __webpack_require__) { + +// 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); + } + } + + 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; + + })(); + +}).call(this); + + +/***/ }), +/* 61 */ +/***/ (function(module, exports, __webpack_require__) { + +// 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; + + create = __webpack_require__(1); + + 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"); + } + this.value = this.stringify.raw(text); + } + + XMLRaw.prototype.clone = function() { + return create(XMLRaw.prototype, this); + }; + + 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 XMLRaw; + + })(XMLNode); + +}).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; + } + } + + XMLStringifier.prototype.eleName = function(val) { + val = '' + val || ''; + return this.assertLegalChar(val); + }; + + XMLStringifier.prototype.eleText = function(val) { + val = '' + val || ''; + return this.assertLegalChar(this.elEscape(val)); + }; + + XMLStringifier.prototype.cdata = function(val) { + val = '' + val || ''; + if (val.match(/]]>/)) { + throw new Error("Invalid CDATA text: " + val); + } + return this.assertLegalChar(val); + }; + + XMLStringifier.prototype.comment = function(val) { + val = '' + val || ''; + if (val.match(/--/)) { + throw new Error("Comment text cannot contain double-hypen: " + val); + } + return this.assertLegalChar(val); + }; + + XMLStringifier.prototype.raw = function(val) { + return '' + val || ''; + }; + + XMLStringifier.prototype.attName = function(val) { + return '' + val || ''; + }; + + XMLStringifier.prototype.attValue = function(val) { + val = '' + val || ''; + return this.attEscape(val); + }; + + XMLStringifier.prototype.insTarget = function(val) { + return '' + val || ''; + }; + + XMLStringifier.prototype.insValue = function(val) { + val = '' + val || ''; + if (val.match(/\?>/)) { + throw new Error("Invalid processing instruction value: " + val); + } + return val; + }; + + XMLStringifier.prototype.xmlVersion = function(val) { + val = '' + val || ''; + if (!val.match(/1\.[0-9]+/)) { + throw new Error("Invalid version number: " + val); + } + return val; + }; + + 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; + }; + + XMLStringifier.prototype.xmlStandalone = function(val) { + if (val) { + return "yes"; + } else { + return "no"; + } + }; + + 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; + } + }; + + XMLStringifier.prototype.dtdEntityValue = function(val) { + return '' + val || ''; + }; + + XMLStringifier.prototype.dtdNData = function(val) { + return '' + val || ''; + }; + + XMLStringifier.prototype.convertAttKey = '@'; + + XMLStringifier.prototype.convertPIKey = '?'; + + XMLStringifier.prototype.convertTextKey = '#text'; + + 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 { + chars = /[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE-\uFFFF]/; + } + chr = str.match(chars); + if (chr) { + throw new Error("Invalid character (" + chr + ") in string: " + str + " at index " + chr.index); + } + return str; + }; + + XMLStringifier.prototype.elEscape = function(str) { + return str.replace(/&/g, '&').replace(//g, '>').replace(/\r/g, ' '); + }; + + XMLStringifier.prototype.attEscape = function(str) { + return str.replace(/&/g, '&').replace(/ 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); +} + +module.exports = every; + + +/***/ }), +/* 67 */ +/***/ (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; + + +/***/ }), +/* 68 */ +/***/ (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; +} + +module.exports = arrayEvery; + + +/***/ }), +/* 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; + + +/***/ }), +/* 70 */ +/***/ (function(module, exports, __webpack_require__) { + +var keys = __webpack_require__(8); + +/** + * 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; + + +/***/ }), +/* 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); +} + +module.exports = baseCallback; + + +/***/ }), +/* 72 */ +/***/ (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; + + +/***/ }), +/* 73 */ +/***/ (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; + + +/***/ }), +/* 74 */ +/***/ (function(module, exports, __webpack_require__) { + +var baseForOwn = __webpack_require__(77), + createBaseEach = __webpack_require__(86); + +/** + * 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; + + +/***/ }), +/* 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; +} + +module.exports = baseEvery; + + +/***/ }), +/* 76 */ +/***/ (function(module, exports, __webpack_require__) { + +var createBaseFor = __webpack_require__(87); + +/** + * 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; + + +/***/ }), +/* 77 */ +/***/ (function(module, exports, __webpack_require__) { + +var baseFor = __webpack_require__(76), + keys = __webpack_require__(8); + +/** + * 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; + + +/***/ }), +/* 78 */ +/***/ (function(module, exports, __webpack_require__) { + +var equalArrays = __webpack_require__(88), + equalByTag = __webpack_require__(89), + equalObjects = __webpack_require__(90), + isArray = __webpack_require__(3), + isTypedArray = __webpack_require__(96); + +/** `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; + + +/***/ }), +/* 79 */ +/***/ (function(module, exports, __webpack_require__) { + +var baseIsEqual = __webpack_require__(28), + 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; + + +/***/ }), +/* 80 */ +/***/ (function(module, exports, __webpack_require__) { + +var baseIsMatch = __webpack_require__(79), + getMatchData = __webpack_require__(91), + 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; + + +/***/ }), +/* 81 */ +/***/ (function(module, exports, __webpack_require__) { + +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); + +/** + * 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; + + +/***/ }), +/* 82 */ +/***/ (function(module, exports, __webpack_require__) { + +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 = basePropertyDeep; + + +/***/ }), +/* 83 */ +/***/ (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; + + +/***/ }), +/* 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 + ''); +} + +module.exports = baseToString; + + +/***/ }), +/* 85 */ +/***/ (function(module, exports, __webpack_require__) { + +var bindCallback = __webpack_require__(30), + isIterateeCall = __webpack_require__(15), + restParam = __webpack_require__(67); + +/** + * 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; + + +/***/ }), +/* 86 */ +/***/ (function(module, exports, __webpack_require__) { + +var getLength = __webpack_require__(31), + isLength = __webpack_require__(7), + 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; + + +/***/ }), +/* 87 */ +/***/ (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; + + +/***/ }), +/* 88 */ +/***/ (function(module, exports, __webpack_require__) { + +var arraySome = __webpack_require__(69); + +/** + * 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; + + +/***/ }), +/* 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; + + 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; + + +/***/ }), +/* 90 */ +/***/ (function(module, exports, __webpack_require__) { + +var keys = __webpack_require__(8); + +/** 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; + + +/***/ }), +/* 91 */ +/***/ (function(module, exports, __webpack_require__) { + +var isStrictComparable = __webpack_require__(34), + pairs = __webpack_require__(99); + +/** + * 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; + + +/***/ }), +/* 92 */ +/***/ (function(module, exports, __webpack_require__) { + +var isArguments = __webpack_require__(16), + isArray = __webpack_require__(3), + isIndex = __webpack_require__(14), + isLength = __webpack_require__(7), + keysIn = __webpack_require__(98); + +/** 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; + + +/***/ }), +/* 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 = isEmpty; + + +/***/ }), +/* 94 */ +/***/ (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; + +/** 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.*?') + '$' +); + +/** + * 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; + } + if (isFunction(value)) { + return reIsNative.test(fnToString.call(value)); + } + return isObjectLike(value) && reIsHostCtor.test(value); +} + +module.exports = isNative; + + +/***/ }), +/* 95 */ +/***/ (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); +} + +module.exports = isString; + + +/***/ }), +/* 96 */ +/***/ (function(module, exports, __webpack_require__) { + +var isLength = __webpack_require__(7), + isObjectLike = __webpack_require__(4); + +/** `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]'; + +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]'; + +/** 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; + +/** 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)]; +} + +module.exports = isTypedArray; + + +/***/ }), +/* 97 */ +/***/ (function(module, exports, __webpack_require__) { + +var assignWith = __webpack_require__(70), + baseAssign = __webpack_require__(26), + createAssigner = __webpack_require__(85); + +/** + * 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); +}); + +module.exports = assign; + + +/***/ }), +/* 98 */ +/***/ (function(module, exports, __webpack_require__) { + +var isArguments = __webpack_require__(16), + isArray = __webpack_require__(3), + isIndex = __webpack_require__(14), + isLength = __webpack_require__(7), + isObject = __webpack_require__(0); + +/** Used for native method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * 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; + + var Ctor = object.constructor, + index = -1, + isProto = typeof Ctor == 'function' && Ctor.prototype === object, + result = Array(length), + skipIndexes = length > 0; + + 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; +} + +module.exports = keysIn; + + +/***/ }), +/* 99 */ +/***/ (function(module, exports, __webpack_require__) { + +var keys = __webpack_require__(8), + toObject = __webpack_require__(2); + +/** + * 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); + + var index = -1, + props = keys(object), + length = props.length, + result = Array(length); + + while (++index < length) { + var key = props[index]; + result[index] = [key, object[key]]; + } + return result; +} + +module.exports = pairs; + + +/***/ }), +/* 100 */ +/***/ (function(module, exports, __webpack_require__) { + +var baseProperty = __webpack_require__(29), + basePropertyDeep = __webpack_require__(82), + isKey = __webpack_require__(33); + +/** + * 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); +} + +module.exports = property; + + +/***/ }), +/* 101 */ +/***/ (function(module, exports, __webpack_require__) { + +function DOMParser(options){ + this.options = options ||{locator:{}}; + +} +DOMParser.prototype.parseFromString = function(source,mimeType){ + var options = this.options; + var sax = new XMLReader(); + var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler + var errorHandler = options.errorHandler; + var locator = options.locator; + var defaultNSMap = options.xmlns||{}; + var entityMap = {'lt':'<','gt':'>','amp':'&','quot':'"','apos':"'"} + if(locator){ + domBuilder.setDocumentLocator(locator) + } + + sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator); + sax.domBuilder = options.domBuilder || domBuilder; + if(/\/x?html?$/.test(mimeType)){ + entityMap.nbsp = '\xa0'; + entityMap.copy = '\xa9'; + defaultNSMap['']= 'http://www.w3.org/1999/xhtml'; + } + defaultNSMap.xml = defaultNSMap.xml || 'http://www.w3.org/XML/1998/namespace'; + if(source){ + sax.parse(source,defaultNSMap,entityMap); + }else{ + sax.errorHandler.error("invalid doc source"); + } + return domBuilder.doc; +} +function buildErrorHandler(errorImpl,domBuilder,locator){ + if(!errorImpl){ + if(domBuilder instanceof DOMHandler){ + return domBuilder; + } + errorImpl = domBuilder ; + } + var errorHandler = {} + var isCallback = errorImpl instanceof Function; + locator = locator||{} + function build(key){ + var fn = errorImpl[key]; + if(!fn && isCallback){ + fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl; + } + errorHandler[key] = fn && function(msg){ + fn('[xmldom '+key+']\t'+msg+_locator(locator)); + }||function(){}; + } + build('warning'); + build('error'); + build('fatalError'); + return errorHandler; +} + +//console.log('#\n\n\n\n\n\n\n####') +/** + * +ContentHandler+ErrorHandler + * +LexicalHandler+EntityResolver2 + * -DeclHandler-DTDHandler + * + * DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler + * DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2 + * @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html + */ +function DOMHandler() { + this.cdata = false; +} +function position(locator,node){ + node.lineNumber = locator.lineNumber; + node.columnNumber = locator.columnNumber; +} +/** + * @see org.xml.sax.ContentHandler#startDocument + * @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html + */ +DOMHandler.prototype = { + startDocument : function() { + this.doc = new DOMImplementation().createDocument(null, null, null); + if (this.locator) { + this.doc.documentURI = this.locator.systemId; + } + }, + startElement:function(namespaceURI, localName, qName, attrs) { + var doc = this.doc; + var el = doc.createElementNS(namespaceURI, qName||localName); + var len = attrs.length; + appendElement(this, el); + this.currentElement = el; + + this.locator && position(this.locator,el) + for (var i = 0 ; i < len; i++) { + var namespaceURI = attrs.getURI(i); + var value = attrs.getValue(i); + var qName = attrs.getQName(i); + var attr = doc.createAttributeNS(namespaceURI, qName); + this.locator &&position(attrs.getLocator(i),attr); + attr.value = attr.nodeValue = value; + el.setAttributeNode(attr) + } + }, + endElement:function(namespaceURI, localName, qName) { + var current = this.currentElement + var tagName = current.tagName; + this.currentElement = current.parentNode; + }, + startPrefixMapping:function(prefix, uri) { + }, + endPrefixMapping:function(prefix) { + }, + processingInstruction:function(target, data) { + var ins = this.doc.createProcessingInstruction(target, data); + this.locator && position(this.locator,ins) + appendElement(this, ins); + }, + ignorableWhitespace:function(ch, start, length) { + }, + characters:function(chars, start, length) { + chars = _toString.apply(this,arguments) + //console.log(chars) + if(chars){ + if (this.cdata) { + var charNode = this.doc.createCDATASection(chars); + } else { + var charNode = this.doc.createTextNode(chars); + } + if(this.currentElement){ + this.currentElement.appendChild(charNode); + }else if(/^\s*$/.test(chars)){ + this.doc.appendChild(charNode); + //process xml + } + this.locator && position(this.locator,charNode) + } + }, + skippedEntity:function(name) { + }, + endDocument:function() { + this.doc.normalize(); + }, + setDocumentLocator:function (locator) { + if(this.locator = locator){// && !('lineNumber' in locator)){ + locator.lineNumber = 0; + } + }, + //LexicalHandler + comment:function(chars, start, length) { + chars = _toString.apply(this,arguments) + var comm = this.doc.createComment(chars); + this.locator && position(this.locator,comm) + appendElement(this, comm); + }, + + startCDATA:function() { + //used in characters() methods + this.cdata = true; + }, + endCDATA:function() { + this.cdata = false; + }, + + startDTD:function(name, publicId, systemId) { + var impl = this.doc.implementation; + if (impl && impl.createDocumentType) { + var dt = impl.createDocumentType(name, publicId, systemId); + this.locator && position(this.locator,dt) + appendElement(this, dt); + } + }, + /** + * @see org.xml.sax.ErrorHandler + * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html + */ + warning:function(error) { + console.warn('[xmldom warning]\t'+error,_locator(this.locator)); + }, + error:function(error) { + console.error('[xmldom error]\t'+error,_locator(this.locator)); + }, + fatalError:function(error) { + console.error('[xmldom fatalError]\t'+error,_locator(this.locator)); + throw error; + } +} +function _locator(l){ + if(l){ + return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']' + } +} +function _toString(chars,start,length){ + if(typeof chars == 'string'){ + return chars.substr(start,length) + }else{//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)") + if(chars.length >= start+length || start){ + return new java.lang.String(chars,start,length)+''; + } + return chars; + } +} + +/* + * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html + * used method of org.xml.sax.ext.LexicalHandler: + * #comment(chars, start, length) + * #startCDATA() + * #endCDATA() + * #startDTD(name, publicId, systemId) + * + * + * IGNORED method of org.xml.sax.ext.LexicalHandler: + * #endDTD() + * #startEntity(name) + * #endEntity(name) + * + * + * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html + * IGNORED method of org.xml.sax.ext.DeclHandler + * #attributeDecl(eName, aName, type, mode, value) + * #elementDecl(name, model) + * #externalEntityDecl(name, publicId, systemId) + * #internalEntityDecl(name, value) + * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html + * IGNORED method of org.xml.sax.EntityResolver2 + * #resolveEntity(String name,String publicId,String baseURI,String systemId) + * #resolveEntity(publicId, systemId) + * #getExternalSubset(name, baseURI) + * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html + * IGNORED method of org.xml.sax.DTDHandler + * #notationDecl(name, publicId, systemId) {}; + * #unparsedEntityDecl(name, publicId, systemId, notationName) {}; + */ +"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){ + DOMHandler.prototype[key] = function(){return null} +}) + +/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */ +function appendElement (hander,node) { + if (!hander.currentElement) { + hander.doc.appendChild(node); + } else { + hander.currentElement.appendChild(node); + } +}//appendChild and setAttributeNS are preformance key + +//if(typeof require == 'function'){ + var XMLReader = __webpack_require__(102).XMLReader; + var DOMImplementation = exports.DOMImplementation = __webpack_require__(37).DOMImplementation; + exports.XMLSerializer = __webpack_require__(37).XMLSerializer ; + exports.DOMParser = DOMParser; +//} + + +/***/ }), +/* 102 */ +/***/ (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] +//[5] Name ::= NameStartChar (NameChar)* +var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]///\u10000-\uEFFFF +var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"); +var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$'); +//var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/ +//var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',') + +//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE +//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE +var S_TAG = 0;//tag name offerring +var S_ATTR = 1;//attr name offerring +var S_ATTR_SPACE=2;//attr name end and space offer +var S_EQ = 3;//=space? +var S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only) +var S_ATTR_END = 5;//attr value end and no space(quot end) +var S_TAG_SPACE = 6;//(attr value end || tag end ) && (space offer) +var S_TAG_CLOSE = 7;//closed el + +function XMLReader(){ + +} + +XMLReader.prototype = { + parse:function(source,defaultNSMap,entityMap){ + var domBuilder = this.domBuilder; + domBuilder.startDocument(); + _copy(defaultNSMap ,defaultNSMap = {}) + parse(source,defaultNSMap,entityMap, + domBuilder,this.errorHandler); + domBuilder.endDocument(); + } +} +function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){ + function fixedFromCharCode(code) { + // String.prototype.fromCharCode does not supports + // > 2 bytes unicode chars directly + if (code > 0xffff) { + code -= 0x10000; + var surrogate1 = 0xd800 + (code >> 10) + , surrogate2 = 0xdc00 + (code & 0x3ff); + + return String.fromCharCode(surrogate1, surrogate2); + } else { + return String.fromCharCode(code); + } + } + function entityReplacer(a){ + var k = a.slice(1,-1); + if(k in entityMap){ + return entityMap[k]; + }else if(k.charAt(0) === '#'){ + return fixedFromCharCode(parseInt(k.substr(1).replace('x','0x'))) + }else{ + errorHandler.error('entity not found:'+a); + return a; + } + } + function appendText(end){//has some bugs + if(end>start){ + var xt = source.substring(start,end).replace(/&#?\w+;/g,entityReplacer); + locator&&position(start); + domBuilder.characters(xt,0,end-start); + start = end + } + } + function position(p,m){ + while(p>=lineEnd && (m = linePattern.exec(source))){ + lineStart = m.index; + lineEnd = lineStart + m[0].length; + locator.lineNumber++; + //console.log('line++:',locator,startPos,endPos) + } + locator.columnNumber = p-lineStart+1; + } + var lineStart = 0; + var lineEnd = 0; + var linePattern = /.*(?:\r\n?|\n)|.*$/g + var locator = domBuilder.locator; + + var parseStack = [{currentNSMap:defaultNSMapCopy}] + var closeMap = {}; + var start = 0; + while(true){ + try{ + var tagStart = source.indexOf('<',start); + if(tagStart<0){ + if(!source.substr(start).match(/^\s*$/)){ + var doc = domBuilder.doc; + var text = doc.createTextNode(source.substr(start)); + doc.appendChild(text); + domBuilder.currentElement = text; + } + return; + } + if(tagStart>start){ + appendText(tagStart); + } + switch(source.charAt(tagStart+1)){ + case '/': + var end = source.indexOf('>',tagStart+3); + var tagName = source.substring(tagStart+2,end); + var config = parseStack.pop(); + if(end<0){ + + tagName = source.substring(tagStart+2).replace(/[\s<].*/,''); + //console.error('#@@@@@@'+tagName) + errorHandler.error("end tag name: "+tagName+' is not complete:'+config.tagName); + end = tagStart+1+tagName.length; + }else if(tagName.match(/\s + locator&&position(tagStart); + end = parseInstruction(source,tagStart,domBuilder); + break; + case '!':// start){ + start = end; + }else{ + //TODO: 这里有可能sax回退,有位置错误风险 + appendText(Math.max(tagStart,start)+1); + } + } +} +function copyLocator(f,t){ + t.lineNumber = f.lineNumber; + t.columnNumber = f.columnNumber; + return t; +} + +/** + * @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack); + * @return end of the elementStartPart(end of elementEndPart for selfClosed el) + */ +function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){ + var attrName; + var value; + var p = ++start; + var s = S_TAG;//status + while(true){ + var c = source.charAt(p); + switch(c){ + case '=': + if(s === S_ATTR){//attrName + attrName = source.slice(start,p); + s = S_EQ; + }else if(s === S_ATTR_SPACE){ + s = S_EQ; + }else{ + //fatalError: equal must after attrName or space after attrName + throw new Error('attribute equal must after attrName'); + } + break; + case '\'': + case '"': + if(s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE + ){//equal + if(s === S_ATTR){ + errorHandler.warning('attribute value must after "="') + attrName = source.slice(start,p) + } + start = p+1; + p = source.indexOf(c,start) + if(p>0){ + value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer); + el.add(attrName,value,start-1); + s = S_ATTR_END; + }else{ + //fatalError: no end quot match + throw new Error('attribute value no end \''+c+'\' match'); + } + }else if(s == S_ATTR_NOQUOT_VALUE){ + value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer); + //console.log(attrName,value,start,p) + el.add(attrName,value,start); + //console.dir(el) + errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!'); + start = p+1; + s = S_ATTR_END + }else{ + //fatalError: no equal before + throw new Error('attribute value must after "="'); + } + break; + case '/': + switch(s){ + case S_TAG: + el.setTagName(source.slice(start,p)); + case S_ATTR_END: + case S_TAG_SPACE: + case S_TAG_CLOSE: + s =S_TAG_CLOSE; + el.closed = true; + case S_ATTR_NOQUOT_VALUE: + case S_ATTR: + case S_ATTR_SPACE: + break; + //case S_EQ: + default: + throw new Error("attribute invalid close char('/')") + } + break; + case ''://end document + //throw new Error('unexpected end of input') + errorHandler.error('unexpected end of input'); + if(s == S_TAG){ + el.setTagName(source.slice(start,p)); + } + return p; + case '>': + switch(s){ + case S_TAG: + el.setTagName(source.slice(start,p)); + case S_ATTR_END: + case S_TAG_SPACE: + case S_TAG_CLOSE: + break;//normal + case S_ATTR_NOQUOT_VALUE://Compatible state + case S_ATTR: + value = source.slice(start,p); + if(value.slice(-1) === '/'){ + el.closed = true; + value = value.slice(0,-1) + } + case S_ATTR_SPACE: + if(s === S_ATTR_SPACE){ + value = attrName; + } + if(s == S_ATTR_NOQUOT_VALUE){ + errorHandler.warning('attribute "'+value+'" missed quot(")!!'); + el.add(attrName,value.replace(/&#?\w+;/g,entityReplacer),start) + }else{ + if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !value.match(/^(?:disabled|checked|selected)$/i)){ + errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!') + } + el.add(value,value,start) + } + break; + case S_EQ: + throw new Error('attribute value missed!!'); + } +// console.log(tagName,tagNamePattern,tagNamePattern.test(tagName)) + return p; + /*xml space '\x20' | #x9 | #xD | #xA; */ + case '\u0080': + c = ' '; + default: + if(c<= ' '){//space + switch(s){ + case S_TAG: + el.setTagName(source.slice(start,p));//tagName + s = S_TAG_SPACE; + break; + case S_ATTR: + attrName = source.slice(start,p) + s = S_ATTR_SPACE; + break; + case S_ATTR_NOQUOT_VALUE: + var value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer); + errorHandler.warning('attribute "'+value+'" missed quot(")!!'); + el.add(attrName,value,start) + case S_ATTR_END: + s = S_TAG_SPACE; + break; + //case S_TAG_SPACE: + //case S_EQ: + //case S_ATTR_SPACE: + // void();break; + //case S_TAG_CLOSE: + //ignore warning + } + }else{//not space +//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE +//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE + switch(s){ + //case S_TAG:void();break; + //case S_ATTR:void();break; + //case S_ATTR_NOQUOT_VALUE:void();break; + case S_ATTR_SPACE: + var tagName = el.tagName; + if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !attrName.match(/^(?:disabled|checked|selected)$/i)){ + errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!') + } + el.add(attrName,attrName,start); + start = p; + s = S_ATTR; + break; + case S_ATTR_END: + errorHandler.warning('attribute space is required"'+attrName+'"!!') + case S_TAG_SPACE: + s = S_ATTR; + start = p; + break; + case S_EQ: + s = S_ATTR_NOQUOT_VALUE; + start = p; + break; + case S_TAG_CLOSE: + throw new Error("elements closed character '/' and '>' must be connected to"); + } + } + }//end outer switch + //console.log('p++',p) + p++; + } +} +/** + * @return true if has new namespace define + */ +function appendElement(el,domBuilder,currentNSMap){ + var tagName = el.tagName; + var localNSMap = null; + //var currentNSMap = parseStack[parseStack.length-1].currentNSMap; + var i = el.length; + while(i--){ + var a = el[i]; + var qName = a.qName; + var value = a.value; + var nsp = qName.indexOf(':'); + if(nsp>0){ + var prefix = a.prefix = qName.slice(0,nsp); + var localName = qName.slice(nsp+1); + var nsPrefix = prefix === 'xmlns' && localName + }else{ + localName = qName; + prefix = null + nsPrefix = qName === 'xmlns' && '' + } + //can not set prefix,because prefix !== '' + a.localName = localName ; + //prefix == null for no ns prefix attribute + if(nsPrefix !== false){//hack!! + if(localNSMap == null){ + localNSMap = {} + //console.log(currentNSMap,0) + _copy(currentNSMap,currentNSMap={}) + //console.log(currentNSMap,1) + } + currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value; + a.uri = 'http://www.w3.org/2000/xmlns/' + domBuilder.startPrefixMapping(nsPrefix, value) + } + } + var i = el.length; + while(i--){ + a = el[i]; + var prefix = a.prefix; + if(prefix){//no prefix attribute has no namespace + if(prefix === 'xml'){ + a.uri = 'http://www.w3.org/XML/1998/namespace'; + }if(prefix !== 'xmlns'){ + a.uri = currentNSMap[prefix || ''] + + //{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)} + } + } + } + var nsp = tagName.indexOf(':'); + if(nsp>0){ + prefix = el.prefix = tagName.slice(0,nsp); + localName = el.localName = tagName.slice(nsp+1); + }else{ + prefix = null;//important!! + localName = el.localName = tagName; + } + //no prefix element has default namespace + var ns = el.uri = currentNSMap[prefix || '']; + domBuilder.startElement(ns,localName,tagName,el); + //endPrefixMapping and startPrefixMapping have not any help for dom builder + //localNSMap = null + if(el.closed){ + domBuilder.endElement(ns,localName,tagName); + if(localNSMap){ + for(prefix in localNSMap){ + domBuilder.endPrefixMapping(prefix) + } + } + }else{ + el.currentNSMap = currentNSMap; + el.localNSMap = localNSMap; + //parseStack.push(el); + return true; + } +} +function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){ + if(/^(?:script|textarea)$/i.test(tagName)){ + var elEndStart = source.indexOf('',elStartEnd); + var text = source.substring(elStartEnd+1,elEndStart); + if(/[&<]/.test(text)){ + if(/^script$/i.test(tagName)){ + //if(!/\]\]>/.test(text)){ + //lexHandler.startCDATA(); + domBuilder.characters(text,0,text.length); + //lexHandler.endCDATA(); + return elEndStart; + //} + }//}else{//text area + text = text.replace(/&#?\w+;/g,entityReplacer); + domBuilder.characters(text,0,text.length); + return elEndStart; + //} + + } + } + return elStartEnd+1; +} +function fixSelfClosed(source,elStartEnd,tagName,closeMap){ + //if(tagName in closeMap){ + var pos = closeMap[tagName]; + if(pos == null){ + //console.log(tagName) + pos = source.lastIndexOf('') + if(pos',start+4); + //append comment source.substring(4,end)//