aboutsummaryrefslogtreecommitdiff
path: root/cordova/node_modules/ios-sim
diff options
context:
space:
mode:
Diffstat (limited to 'cordova/node_modules/ios-sim')
-rw-r--r--cordova/node_modules/ios-sim/.eslintrc3
-rw-r--r--cordova/node_modules/ios-sim/.eslintrc.yml16
-rw-r--r--cordova/node_modules/ios-sim/.github/CONTRIBUTING.md29
-rw-r--r--cordova/node_modules/ios-sim/.github/ISSUE_TEMPLATE.md24
-rw-r--r--cordova/node_modules/ios-sim/.jscsrc40
-rw-r--r--cordova/node_modules/ios-sim/.travis.yml24
-rw-r--r--cordova/node_modules/ios-sim/LICENSE21
-rw-r--r--cordova/node_modules/ios-sim/README.md100
-rw-r--r--cordova/node_modules/ios-sim/appveyor.yml19
-rwxr-xr-xcordova/node_modules/ios-sim/bin/ios-sim42
-rwxr-xr-xcordova/node_modules/ios-sim/bin/ios-sim.cmd1
-rw-r--r--cordova/node_modules/ios-sim/doc/help.txt33
-rw-r--r--cordova/node_modules/ios-sim/ios-sim.js4
l---------cordova/node_modules/ios-sim/node_modules/.bin/nopt1
-rw-r--r--cordova/node_modules/ios-sim/node_modules/base64-js/LICENSE21
-rw-r--r--cordova/node_modules/ios-sim/node_modules/base64-js/README.md34
-rw-r--r--cordova/node_modules/ios-sim/node_modules/base64-js/base64js.min.js1
-rw-r--r--cordova/node_modules/ios-sim/node_modules/base64-js/index.js151
-rw-r--r--cordova/node_modules/ios-sim/node_modules/base64-js/package.json65
-rw-r--r--cordova/node_modules/ios-sim/node_modules/base64-js/test/big-data.js25
-rw-r--r--cordova/node_modules/ios-sim/node_modules/base64-js/test/convert.js88
-rw-r--r--cordova/node_modules/ios-sim/node_modules/base64-js/test/corrupt.js10
-rw-r--r--cordova/node_modules/ios-sim/node_modules/base64-js/test/url-safe.js24
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/bplist-parser/.npmignore8
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/bplist-parser/README.md47
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/bplist-parser/bplistParser.js332
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/bplist-parser/package.json55
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/bplist-parser/test/airplay.bplistbin0 -> 341 bytes
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/bplist-parser/test/iTunes-small.bplistbin0 -> 24433 bytes
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/bplist-parser/test/parseTest.js120
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/bplist-parser/test/sample1.bplistbin0 -> 605 bytes
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/bplist-parser/test/sample2.bplistbin0 -> 384 bytes
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/bplist-parser/test/uid.bplistbin0 -> 365 bytes
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/bplist-parser/test/utf16.bplistbin0 -> 1273 bytes
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/nopt/.npmignore0
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/nopt/LICENSE23
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/nopt/README.md206
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/nopt/bin/nopt.js44
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/nopt/examples/my-program.js30
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/nopt/lib/nopt.js530
-rwxr-xr-xcordova/node_modules/ios-sim/node_modules/nopt/package.json60
-rw-r--r--cordova/node_modules/ios-sim/node_modules/plist/.jshintrc4
-rw-r--r--cordova/node_modules/ios-sim/node_modules/plist/.travis.yml33
-rw-r--r--cordova/node_modules/ios-sim/node_modules/plist/History.md162
-rw-r--r--cordova/node_modules/ios-sim/node_modules/plist/LICENSE24
-rw-r--r--cordova/node_modules/ios-sim/node_modules/plist/Makefile75
-rw-r--r--cordova/node_modules/ios-sim/node_modules/plist/README.md141
-rw-r--r--cordova/node_modules/ios-sim/node_modules/plist/dist/plist-build.js2832
-rw-r--r--cordova/node_modules/ios-sim/node_modules/plist/dist/plist-parse.js4297
-rw-r--r--cordova/node_modules/ios-sim/node_modules/plist/dist/plist.js7024
-rw-r--r--cordova/node_modules/ios-sim/node_modules/plist/examples/browser/index.html14
-rw-r--r--cordova/node_modules/ios-sim/node_modules/plist/index.js13
-rw-r--r--cordova/node_modules/ios-sim/node_modules/plist/lib/build.js137
-rw-r--r--cordova/node_modules/ios-sim/node_modules/plist/lib/parse.js215
-rw-r--r--cordova/node_modules/ios-sim/node_modules/plist/package.json88
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/.npmignore5
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/CHANGELOG.md423
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/LICENSE21
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/README.md85
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/Utility.js73
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLAttribute.js31
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLCData.js32
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLComment.js32
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDTDAttList.js50
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDTDElement.js35
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDTDEntity.js56
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDTDNotation.js37
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDeclaration.js40
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDocType.js107
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDocument.js48
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDocumentCB.js402
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLElement.js111
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLNode.js432
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js35
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLRaw.js32
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLStreamWriter.js279
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLStringWriter.js334
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLStringifier.js163
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLText.js32
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLWriterBase.js90
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/index.js53
-rw-r--r--cordova/node_modules/ios-sim/node_modules/xmlbuilder/package.json65
-rw-r--r--cordova/node_modules/ios-sim/package.json80
-rw-r--r--cordova/node_modules/ios-sim/spec/.eslintrc.yml19
-rw-r--r--cordova/node_modules/ios-sim/spec/cli.spec.js30
-rw-r--r--cordova/node_modules/ios-sim/spec/commands.spec.js61
-rw-r--r--cordova/node_modules/ios-sim/spec/fixture/list.json522
-rw-r--r--cordova/node_modules/ios-sim/spec/jasmine.json8
-rw-r--r--cordova/node_modules/ios-sim/spec/lib.spec.js58
-rw-r--r--cordova/node_modules/ios-sim/src/.eslintrc.yml21
-rw-r--r--cordova/node_modules/ios-sim/src/cli.js105
-rw-r--r--cordova/node_modules/ios-sim/src/commands.js94
-rw-r--r--cordova/node_modules/ios-sim/src/help.js41
-rw-r--r--cordova/node_modules/ios-sim/src/lib.js491
94 files changed, 21923 insertions, 0 deletions
diff --git a/cordova/node_modules/ios-sim/.eslintrc b/cordova/node_modules/ios-sim/.eslintrc
new file mode 100644
index 0000000..e3578aa
--- /dev/null
+++ b/cordova/node_modules/ios-sim/.eslintrc
@@ -0,0 +1,3 @@
+{
+ "extends": "standard"
+}
diff --git a/cordova/node_modules/ios-sim/.eslintrc.yml b/cordova/node_modules/ios-sim/.eslintrc.yml
new file mode 100644
index 0000000..0e770eb
--- /dev/null
+++ b/cordova/node_modules/ios-sim/.eslintrc.yml
@@ -0,0 +1,16 @@
+root: true
+
+extends: semistandard
+
+rules:
+ indent:
+ - error
+ - 4
+
+ no-unused-vars:
+ - error
+ - args: after-used
+
+ # excpetions specified in:
+ # - src/.eslintrc.yml
+ # - spec/.eslintrc.yml
diff --git a/cordova/node_modules/ios-sim/.github/CONTRIBUTING.md b/cordova/node_modules/ios-sim/.github/CONTRIBUTING.md
new file mode 100644
index 0000000..b132d71
--- /dev/null
+++ b/cordova/node_modules/ios-sim/.github/CONTRIBUTING.md
@@ -0,0 +1,29 @@
+## Contributing to ios-sim
+
+Github url:
+
+ https://github.com/phonegap/ios-sim
+
+Git clone url:
+
+ https://github.com/phonegap/ios-sim.git
+
+## Filing an issue
+
+Please run the commands below in your Terminal.app and include it in the issue:
+
+```
+1. sw_vers -productVersion
+2. ios-sim --version
+3. xcodebuild -version
+4. xcode-select --print-path
+5. gcc --version
+```
+Also include **command line arguments** you used for ios-sim.
+
+
+## Sending a Pull Request
+
+Please **create a topic branch** for your issue before submitting your pull request. You will be asked to re-submit if your pull request contains unrelated commits.
+
+Please elaborate regarding the problem the pull request is supposed to solve, and perhaps also link to any relevant issues the pull request is trying to fix. \ No newline at end of file
diff --git a/cordova/node_modules/ios-sim/.github/ISSUE_TEMPLATE.md b/cordova/node_modules/ios-sim/.github/ISSUE_TEMPLATE.md
new file mode 100644
index 0000000..bd3591d
--- /dev/null
+++ b/cordova/node_modules/ios-sim/.github/ISSUE_TEMPLATE.md
@@ -0,0 +1,24 @@
+## MUST READ BEFORE YOU FILE (DELETE THIS SECTION BEFORE FILING)
+
+Include the **command line arguments** you used for ios-sim.
+
+Don't forget to check out the [README](https://github.com/phonegap/ios-sim/blob/master/README.md) before filing this issue, to see if there are any known issues.
+
+# Expected behavior
+
+
+# Actual behavior.
+
+
+# Steps to reproduce the problem
+
+
+# System Specs
+
+Please run the commands below in your Terminal.app and include it in the issue. Check when done and include results below.
+
+- [ ] 1. system_profiler SPSoftwareDataType
+- [ ] 2. ios-sim --version
+- [ ] 3. xcodebuild -version
+- [ ] 4. xcode-select --print-path
+- [ ] 5. node --version
diff --git a/cordova/node_modules/ios-sim/.jscsrc b/cordova/node_modules/ios-sim/.jscsrc
new file mode 100644
index 0000000..a0a41ff
--- /dev/null
+++ b/cordova/node_modules/ios-sim/.jscsrc
@@ -0,0 +1,40 @@
+{
+ "disallowTabs": true,
+ "preset": "google",
+ "fileExtensions": [".js", "jscs"],
+
+ "requireSemicolons": true,
+ "requireParenthesesAroundIIFE": true,
+ "maximumLineLength": 120,
+ "validateLineBreaks": "LF",
+ "validateIndentation": 4,
+ "disallowTrailingComma": true,
+ "disallowUnusedParams": true,
+
+ "disallowSpacesInsideObjectBrackets": null,
+ "disallowImplicitTypeConversion": ["string"],
+
+ "safeContextKeyword": "_this",
+
+ "disallowMultipleVarDecl": {
+ allExcept: ['require']
+ },
+
+ "requireCamelCaseOrUpperCaseIdentifiers" : false,
+
+ "jsDoc": {
+ "checkAnnotations": "closurecompiler",
+ "checkParamNames": true,
+ "requireParamTypes": true,
+ "checkRedundantParams": true,
+ "checkReturnTypes": true,
+ "checkRedundantReturns": true,
+ "requireReturnTypes": true,
+ "checkTypes": "capitalizedNativeCase",
+ "checkRedundantAccess": true,
+ "requireNewlineAfterDescription": true
+ },
+
+ "excludeFiles": [
+ ]
+} \ No newline at end of file
diff --git a/cordova/node_modules/ios-sim/.travis.yml b/cordova/node_modules/ios-sim/.travis.yml
new file mode 100644
index 0000000..c82aecf
--- /dev/null
+++ b/cordova/node_modules/ios-sim/.travis.yml
@@ -0,0 +1,24 @@
+os: osx
+osx_image: xcode8.3
+sudo: false
+env:
+ matrix:
+ - TRAVIS_NODE_VERSION: '4'
+ - TRAVIS_NODE_VERSION: '6'
+git:
+ depth: 10
+before_install:
+- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm
+ && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm
+ install $TRAVIS_NODE_VERSION
+- node --version
+- npm --version
+- npm cache clean
+- npm install -g npm@3
+install:
+- npm install
+script:
+- npm test
+notifications:
+ slack:
+ secure: gn0YH0MCFOYR3Dd8Vsx3K/J9G0aazhnRjQVfqbeRKN3f6vToKif1CxhiDLXI6cxEB5DBiAtpK58jkoDYrXoNLGuSbiTHBJ+ankU8aG3s0OTIHa/8I0TjRKjBRc0PrMV7n7EiLC6LQxNe0x0mMSE1gdOUeS1UrZ5ZiVrS1u0eHHs=
diff --git a/cordova/node_modules/ios-sim/LICENSE b/cordova/node_modules/ios-sim/LICENSE
new file mode 100644
index 0000000..f5768b4
--- /dev/null
+++ b/cordova/node_modules/ios-sim/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Shazron Abdullah
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE. \ No newline at end of file
diff --git a/cordova/node_modules/ios-sim/README.md b/cordova/node_modules/ios-sim/README.md
new file mode 100644
index 0000000..b53d3a3
--- /dev/null
+++ b/cordova/node_modules/ios-sim/README.md
@@ -0,0 +1,100 @@
+[![Build status](https://ci.appveyor.com/api/projects/status/0kw833771uu622fs?svg=true)](https://ci.appveyor.com/project/shazron/ios-sim)
+[![Build Status](https://travis-ci.org/phonegap/ios-sim.svg?branch=master)](https://travis-ci.org/phonegap/ios-sim)
+
+ios-sim
+=======
+
+Supports Xcode 8 and greater only since version 5.x.
+
+The ios-sim tool is a command-line utility that launches an iOS application on the iOS Simulator. This allows for niceties such as automated testing without having to open Xcode.
+
+Features
+--------
+
+* Choose the device family to simulate, i.e. iPhone or iPad. Run using "showdevicetypes" option to see available device types, and pass it in as the "devicetypeid" parameter.
+
+See the `--help` option for more info.
+
+The unimplemented options below are in the [backlog](https://github.com/phonegap/ios-sim/milestones/ios-sim%204.2.0)
+
+Usage
+-----
+
+```
+
+ Usage: ios-sim <command> <options> [--args ...]
+
+ Commands:
+ showsdks List the available iOS SDK versions
+ showdevicetypes List the available device types
+ launch <application path> Launch the application at the specified path on the iOS Simulator
+ start Launch iOS Simulator without an app
+ install <application path> Install the application at the specified path on the iOS Simulator without launching the app
+
+ Options:
+ --version Print the version of ios-sim
+ --help Show this help text
+ --exit Exit after startup
+ --log <log file path> The path where log of the app running in the Simulator will be redirected to
+ --devicetypeid <device type> The id of the device type that should be simulated (Xcode6+). Use 'showdevicetypes' to list devices.
+ e.g "com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone6, 8.0"
+
+ Removed in version 4.x:
+ --stdout <stdout file path> The path where stdout of the simulator will be redirected to (defaults to stdout of ios-sim)
+ --stderr <stderr file path> The path where stderr of the simulator will be redirected to (defaults to stderr of ios-sim)
+ --sdk <sdkversion> The iOS SDK version to run the application on (defaults to the latest)
+ --family <device family> The device type that should be simulated (defaults to `iphone')
+ --retina Start a retina device
+ --tall In combination with --retina flag, start the tall version of the retina device (e.g. iPhone 5 (4-inch))
+ --64bit In combination with --retina flag and the --tall flag, start the 64bit version of the tall retina device (e.g. iPhone 5S (4-inch 64bit))
+
+ Unimplemented in this version:
+ --verbose Set the output level to verbose
+ --timeout <seconds> The timeout time to wait for a response from the Simulator. Default value: 30 seconds
+ --args <...> All following arguments will be passed on to the application
+ --env <environment file path> A plist file containing environment key-value pairs that should be set
+ --setenv NAME=VALUE Set an environment variable
+
+```
+
+Installation
+------------
+
+Choose one of the following installation methods.
+
+### Node JS
+
+Install using node.js (at least 0.10.20):
+
+ $ npm install ios-sim -g
+
+### Zip
+
+Download a zip file:
+
+ $ curl -L https://github.com/phonegap/ios-sim/archive/master.zip -o ios-sim.zip
+ $ unzip ios-sim.zip
+
+### Git
+
+Download using git clone:
+
+ $ git clone git://github.com/phonegap/ios-sim.git
+
+Troubleshooting
+---------------
+
+Make sure you enable Developer Mode on your machine:
+
+ $ DevToolsSecurity -enable
+
+Make sure multiple instances of launchd_sim are not running:
+
+ $ killall launchd_sim
+
+License
+-------
+
+This project is available under the MIT license. See [LICENSE][license].
+
+[license]: https://github.com/phonegap/ios-sim/blob/master/LICENSE
diff --git a/cordova/node_modules/ios-sim/appveyor.yml b/cordova/node_modules/ios-sim/appveyor.yml
new file mode 100644
index 0000000..d4c6a08
--- /dev/null
+++ b/cordova/node_modules/ios-sim/appveyor.yml
@@ -0,0 +1,19 @@
+# appveyor file
+# http://www.appveyor.com/docs/appveyor-yml
+environment:
+ matrix:
+ - nodejs_version: "4"
+ - nodejs_version: "6"
+
+install:
+ - ps: Install-Product node $env:nodejs_version
+ - npm cache clean
+ - npm install -g npm@3
+ - npm install
+
+build: off
+
+test_script:
+ - node --version
+ - npm --version
+ - npm test
diff --git a/cordova/node_modules/ios-sim/bin/ios-sim b/cordova/node_modules/ios-sim/bin/ios-sim
new file mode 100755
index 0000000..bab9b88
--- /dev/null
+++ b/cordova/node_modules/ios-sim/bin/ios-sim
@@ -0,0 +1,42 @@
+#!/usr/bin/env node
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+// Set this to 1 to enable timestamp collection via addTs().
+if (0) {
+ var ts = [];
+ addTs = function(name) {
+ ts.push([name, new Date]);
+ }
+ process.on('exit', function() {
+ for (var i = 0; i < ts.length - 1; ++i) {
+ var e1 = ts[i];
+ var e2 = ts[i+1];
+ console.log(e1[0] + ' -> ' + e2[0] + ' = ' + (e2[1] - e1[1]));
+ }
+ console.log('total: ' + (ts[ts.length-1][1] - ts[0][1]));
+ });
+} else {
+ addTs = function() {};
+}
+
+addTs('start');
+var cli = require('../src/cli');
+cli(process.argv);
+addTs('end');
diff --git a/cordova/node_modules/ios-sim/bin/ios-sim.cmd b/cordova/node_modules/ios-sim/bin/ios-sim.cmd
new file mode 100755
index 0000000..18927ed
--- /dev/null
+++ b/cordova/node_modules/ios-sim/bin/ios-sim.cmd
@@ -0,0 +1 @@
+@node "%~dpn0" %*
diff --git a/cordova/node_modules/ios-sim/doc/help.txt b/cordova/node_modules/ios-sim/doc/help.txt
new file mode 100644
index 0000000..8174cfe
--- /dev/null
+++ b/cordova/node_modules/ios-sim/doc/help.txt
@@ -0,0 +1,33 @@
+Usage: ios-sim <command> <options> [--args ...]
+
+Commands:
+ showsdks List the available iOS SDK versions
+ showdevicetypes List the available device types
+ launch <application path> Launch the application at the specified path on the iOS Simulator
+ start Launch iOS Simulator without an app
+ install <application path> Install the application at the specified path on the iOS Simulator without launching the app
+
+Options:
+ --version Print the version of ios-sim
+ --help Show this help text
+ --exit Exit after startup
+ --log <log file path> The path where log of the app running in the Simulator will be redirected to
+ --devicetypeid <device type> The id of the device type that should be simulated (Xcode6+). Use 'showdevicetypes' to list devices.
+ e.g "com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone6, 8.0"
+
+Removed in version 4.x:
+ --stdout <stdout file path> The path where stdout of the simulator will be redirected to (defaults to stdout of ios-sim)
+ --stderr <stderr file path> The path where stderr of the simulator will be redirected to (defaults to stderr of ios-sim)
+ --sdk <sdkversion> The iOS SDK version to run the application on (defaults to the latest)
+ --family <device family> The device type that should be simulated (defaults to `iphone')
+ --retina Start a retina device
+ --tall In combination with --retina flag, start the tall version of the retina device (e.g. iPhone 5 (4-inch))
+ --64bit In combination with --retina flag and the --tall flag, start the 64bit version of the tall retina device (e.g. iPhone 5S (4-inch 64bit))
+
+Unimplemented since version 4.x:
+ --verbose Set the output level to verbose
+ --timeout <seconds> The timeout time to wait for a response from the Simulator. Default value: 30 seconds
+ --args <...> All following arguments will be passed on to the application
+ --env <environment file path> A plist file containing environment key-value pairs that should be set
+ --setenv NAME=VALUE Set an environment variable
+ \ No newline at end of file
diff --git a/cordova/node_modules/ios-sim/ios-sim.js b/cordova/node_modules/ios-sim/ios-sim.js
new file mode 100644
index 0000000..4547126
--- /dev/null
+++ b/cordova/node_modules/ios-sim/ios-sim.js
@@ -0,0 +1,4 @@
+var iossim = require('./src/lib.js');
+iossim.init();
+
+exports = module.exports = iossim;
diff --git a/cordova/node_modules/ios-sim/node_modules/.bin/nopt b/cordova/node_modules/ios-sim/node_modules/.bin/nopt
new file mode 120000
index 0000000..6b6566e
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/.bin/nopt
@@ -0,0 +1 @@
+../nopt/bin/nopt.js \ No newline at end of file
diff --git a/cordova/node_modules/ios-sim/node_modules/base64-js/LICENSE b/cordova/node_modules/ios-sim/node_modules/base64-js/LICENSE
new file mode 100644
index 0000000..96d3f68
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/base64-js/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/cordova/node_modules/ios-sim/node_modules/base64-js/README.md b/cordova/node_modules/ios-sim/node_modules/base64-js/README.md
new file mode 100644
index 0000000..7532511
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/base64-js/README.md
@@ -0,0 +1,34 @@
+base64-js
+=========
+
+`base64-js` does basic base64 encoding/decoding in pure JS.
+
+[![build status](https://secure.travis-ci.org/beatgammit/base64-js.png)](http://travis-ci.org/beatgammit/base64-js)
+
+[![testling badge](https://ci.testling.com/beatgammit/base64-js.png)](https://ci.testling.com/beatgammit/base64-js)
+
+Many browsers already have base64 encoding/decoding functionality, but it is for text data, not all-purpose binary data.
+
+Sometimes encoding/decoding binary data in the browser is useful, and that is what this module does.
+
+## install
+
+With [npm](https://npmjs.org) do:
+
+`npm install base64-js` and `var base64js = require('base64-js')`
+
+For use in web browsers do:
+
+`<script src="base64js.min.js"></script>`
+
+## methods
+
+`base64js` has three exposed functions, `byteLength`, `toByteArray` and `fromByteArray`, which both take a single argument.
+
+* `byteLength` - Takes a base64 string and returns length of byte array
+* `toByteArray` - Takes a base64 string and returns a byte array
+* `fromByteArray` - Takes a byte array and returns a base64 string
+
+## license
+
+MIT
diff --git a/cordova/node_modules/ios-sim/node_modules/base64-js/base64js.min.js b/cordova/node_modules/ios-sim/node_modules/base64-js/base64js.min.js
new file mode 100644
index 0000000..0c621d3
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/base64-js/base64js.min.js
@@ -0,0 +1 @@
+(function(r){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=r()}else if(typeof define==="function"&&define.amd){define([],r)}else{var e;if(typeof window!=="undefined"){e=window}else if(typeof global!=="undefined"){e=global}else if(typeof self!=="undefined"){e=self}else{e=this}e.base64js=r()}})(function(){var r,e,n;return function(){function r(e,n,t){function o(f,i){if(!n[f]){if(!e[f]){var u="function"==typeof require&&require;if(!i&&u)return u(f,!0);if(a)return a(f,!0);var v=new Error("Cannot find module '"+f+"'");throw v.code="MODULE_NOT_FOUND",v}var d=n[f]={exports:{}};e[f][0].call(d.exports,function(r){var n=e[f][1][r];return o(n||r)},d,d.exports,r,e,n,t)}return n[f].exports}for(var a="function"==typeof require&&require,f=0;f<t.length;f++)o(t[f]);return o}return r}()({"/":[function(r,e,n){"use strict";n.byteLength=d;n.toByteArray=h;n.fromByteArray=p;var t=[];var o=[];var a=typeof Uint8Array!=="undefined"?Uint8Array:Array;var f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i=0,u=f.length;i<u;++i){t[i]=f[i];o[f.charCodeAt(i)]=i}o["-".charCodeAt(0)]=62;o["_".charCodeAt(0)]=63;function v(r){var e=r.length;if(e%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var n=r.indexOf("=");if(n===-1)n=e;var t=n===e?0:4-n%4;return[n,t]}function d(r){var e=v(r);var n=e[0];var t=e[1];return(n+t)*3/4-t}function c(r,e,n){return(e+n)*3/4-n}function h(r){var e;var n=v(r);var t=n[0];var f=n[1];var i=new a(c(r,t,f));var u=0;var d=f>0?t-4:t;for(var h=0;h<d;h+=4){e=o[r.charCodeAt(h)]<<18|o[r.charCodeAt(h+1)]<<12|o[r.charCodeAt(h+2)]<<6|o[r.charCodeAt(h+3)];i[u++]=e>>16&255;i[u++]=e>>8&255;i[u++]=e&255}if(f===2){e=o[r.charCodeAt(h)]<<2|o[r.charCodeAt(h+1)]>>4;i[u++]=e&255}if(f===1){e=o[r.charCodeAt(h)]<<10|o[r.charCodeAt(h+1)]<<4|o[r.charCodeAt(h+2)]>>2;i[u++]=e>>8&255;i[u++]=e&255}return i}function s(r){return t[r>>18&63]+t[r>>12&63]+t[r>>6&63]+t[r&63]}function l(r,e,n){var t;var o=[];for(var a=e;a<n;a+=3){t=(r[a]<<16&16711680)+(r[a+1]<<8&65280)+(r[a+2]&255);o.push(s(t))}return o.join("")}function p(r){var e;var n=r.length;var o=n%3;var a=[];var f=16383;for(var i=0,u=n-o;i<u;i+=f){a.push(l(r,i,i+f>u?u:i+f))}if(o===1){e=r[n-1];a.push(t[e>>2]+t[e<<4&63]+"==")}else if(o===2){e=(r[n-2]<<8)+r[n-1];a.push(t[e>>10]+t[e>>4&63]+t[e<<2&63]+"=")}return a.join("")}},{}]},{},[])("/")});
diff --git a/cordova/node_modules/ios-sim/node_modules/base64-js/index.js b/cordova/node_modules/ios-sim/node_modules/base64-js/index.js
new file mode 100644
index 0000000..44c6766
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/base64-js/index.js
@@ -0,0 +1,151 @@
+'use strict'
+
+exports.byteLength = byteLength
+exports.toByteArray = toByteArray
+exports.fromByteArray = fromByteArray
+
+var lookup = []
+var revLookup = []
+var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
+
+var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
+for (var i = 0, len = code.length; i < len; ++i) {
+ lookup[i] = code[i]
+ revLookup[code.charCodeAt(i)] = i
+}
+
+// Support decoding URL-safe base64 strings, as Node.js does.
+// See: https://en.wikipedia.org/wiki/Base64#URL_applications
+revLookup['-'.charCodeAt(0)] = 62
+revLookup['_'.charCodeAt(0)] = 63
+
+function getLens (b64) {
+ var len = b64.length
+
+ if (len % 4 > 0) {
+ throw new Error('Invalid string. Length must be a multiple of 4')
+ }
+
+ // Trim off extra bytes after placeholder bytes are found
+ // See: https://github.com/beatgammit/base64-js/issues/42
+ var validLen = b64.indexOf('=')
+ if (validLen === -1) validLen = len
+
+ var placeHoldersLen = validLen === len
+ ? 0
+ : 4 - (validLen % 4)
+
+ return [validLen, placeHoldersLen]
+}
+
+// base64 is 4/3 + up to two characters of the original data
+function byteLength (b64) {
+ var lens = getLens(b64)
+ var validLen = lens[0]
+ var placeHoldersLen = lens[1]
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
+}
+
+function _byteLength (b64, validLen, placeHoldersLen) {
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
+}
+
+function toByteArray (b64) {
+ var tmp
+ var lens = getLens(b64)
+ var validLen = lens[0]
+ var placeHoldersLen = lens[1]
+
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
+
+ var curByte = 0
+
+ // if there are placeholders, only get up to the last complete 4 chars
+ var len = placeHoldersLen > 0
+ ? validLen - 4
+ : validLen
+
+ for (var i = 0; i < len; i += 4) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 18) |
+ (revLookup[b64.charCodeAt(i + 1)] << 12) |
+ (revLookup[b64.charCodeAt(i + 2)] << 6) |
+ revLookup[b64.charCodeAt(i + 3)]
+ arr[curByte++] = (tmp >> 16) & 0xFF
+ arr[curByte++] = (tmp >> 8) & 0xFF
+ arr[curByte++] = tmp & 0xFF
+ }
+
+ if (placeHoldersLen === 2) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 2) |
+ (revLookup[b64.charCodeAt(i + 1)] >> 4)
+ arr[curByte++] = tmp & 0xFF
+ }
+
+ if (placeHoldersLen === 1) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 10) |
+ (revLookup[b64.charCodeAt(i + 1)] << 4) |
+ (revLookup[b64.charCodeAt(i + 2)] >> 2)
+ arr[curByte++] = (tmp >> 8) & 0xFF
+ arr[curByte++] = tmp & 0xFF
+ }
+
+ return arr
+}
+
+function tripletToBase64 (num) {
+ return lookup[num >> 18 & 0x3F] +
+ lookup[num >> 12 & 0x3F] +
+ lookup[num >> 6 & 0x3F] +
+ lookup[num & 0x3F]
+}
+
+function encodeChunk (uint8, start, end) {
+ var tmp
+ var output = []
+ for (var i = start; i < end; i += 3) {
+ tmp =
+ ((uint8[i] << 16) & 0xFF0000) +
+ ((uint8[i + 1] << 8) & 0xFF00) +
+ (uint8[i + 2] & 0xFF)
+ output.push(tripletToBase64(tmp))
+ }
+ return output.join('')
+}
+
+function fromByteArray (uint8) {
+ var tmp
+ var len = uint8.length
+ var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
+ var parts = []
+ var maxChunkLength = 16383 // must be multiple of 3
+
+ // go through the array every three bytes, we'll deal with trailing stuff later
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
+ parts.push(encodeChunk(
+ uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
+ ))
+ }
+
+ // pad the end with zeros, but make sure to not forget the extra bytes
+ if (extraBytes === 1) {
+ tmp = uint8[len - 1]
+ parts.push(
+ lookup[tmp >> 2] +
+ lookup[(tmp << 4) & 0x3F] +
+ '=='
+ )
+ } else if (extraBytes === 2) {
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1]
+ parts.push(
+ lookup[tmp >> 10] +
+ lookup[(tmp >> 4) & 0x3F] +
+ lookup[(tmp << 2) & 0x3F] +
+ '='
+ )
+ }
+
+ return parts.join('')
+}
diff --git a/cordova/node_modules/ios-sim/node_modules/base64-js/package.json b/cordova/node_modules/ios-sim/node_modules/base64-js/package.json
new file mode 100644
index 0000000..235c10d
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/base64-js/package.json
@@ -0,0 +1,65 @@
+{
+ "_from": "base64-js@^1.2.3",
+ "_id": "[email protected]",
+ "_inBundle": false,
+ "_integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==",
+ "_location": "/ios-sim/base64-js",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "base64-js@^1.2.3",
+ "name": "base64-js",
+ "escapedName": "base64-js",
+ "rawSpec": "^1.2.3",
+ "saveSpec": null,
+ "fetchSpec": "^1.2.3"
+ },
+ "_requiredBy": [
+ "/ios-sim/plist"
+ ],
+ "_resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz",
+ "_shasum": "cab1e6118f051095e58b5281aea8c1cd22bfc0e3",
+ "_spec": "base64-js@^1.2.3",
+ "_where": "/Users/lucifer/Desktop/weatherApp/platforms/ios/cordova/node_modules/ios-sim/node_modules/plist",
+ "author": {
+ "name": "T. Jameson Little",
+ "email": "[email protected]"
+ },
+ "bugs": {
+ "url": "https://github.com/beatgammit/base64-js/issues"
+ },
+ "bundleDependencies": false,
+ "deprecated": false,
+ "description": "Base64 encoding/decoding in pure JS",
+ "devDependencies": {
+ "benchmark": "^2.1.4",
+ "browserify": "^14.0.0",
+ "standard": "*",
+ "tape": "4.x",
+ "uglify-js": "^2.8.29"
+ },
+ "files": [
+ "test",
+ "index.js",
+ "base64js.min.js"
+ ],
+ "homepage": "https://github.com/beatgammit/base64-js",
+ "keywords": [
+ "base64"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "name": "base64-js",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/beatgammit/base64-js.git"
+ },
+ "scripts": {
+ "build": "browserify -s base64js -r ./ | uglifyjs -m > base64js.min.js",
+ "lint": "standard",
+ "test": "npm run lint && npm run unit",
+ "unit": "tape test/*.js"
+ },
+ "version": "1.3.0"
+}
diff --git a/cordova/node_modules/ios-sim/node_modules/base64-js/test/big-data.js b/cordova/node_modules/ios-sim/node_modules/base64-js/test/big-data.js
new file mode 100644
index 0000000..107e09e
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/base64-js/test/big-data.js
@@ -0,0 +1,25 @@
+var test = require('tape')
+var b64 = require('../')
+
+test('convert big data to base64', function (t) {
+ var b64str, arr, i, length
+ var big = new Uint8Array(64 * 1024 * 1024)
+ for (i = 0, length = big.length; i < length; ++i) {
+ big[i] = i % 256
+ }
+ b64str = b64.fromByteArray(big)
+ arr = b64.toByteArray(b64str)
+ t.ok(equal(arr, big))
+ t.equal(b64.byteLength(b64str), arr.length)
+ t.end()
+})
+
+function equal (a, b) {
+ var i
+ var length = a.length
+ if (length !== b.length) return false
+ for (i = 0; i < length; ++i) {
+ if (a[i] !== b[i]) return false
+ }
+ return true
+}
diff --git a/cordova/node_modules/ios-sim/node_modules/base64-js/test/convert.js b/cordova/node_modules/ios-sim/node_modules/base64-js/test/convert.js
new file mode 100644
index 0000000..017a133
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/base64-js/test/convert.js
@@ -0,0 +1,88 @@
+var test = require('tape')
+var b64 = require('../')
+var checks = [
+ 'a',
+ 'aa',
+ 'aaa',
+ 'hi',
+ 'hi!',
+ 'hi!!',
+ 'sup',
+ 'sup?',
+ 'sup?!'
+]
+
+test('convert to base64 and back', function (t) {
+ t.plan(checks.length * 2)
+
+ for (var i = 0; i < checks.length; i++) {
+ var check = checks[i]
+ var b64Str, arr, str
+
+ b64Str = b64.fromByteArray(map(check, function (char) { return char.charCodeAt(0) }))
+
+ arr = b64.toByteArray(b64Str)
+ str = map(arr, function (byte) { return String.fromCharCode(byte) }).join('')
+
+ t.equal(check, str, 'Checked ' + check)
+ t.equal(b64.byteLength(b64Str), arr.length, 'Checked length for ' + check)
+ }
+})
+
+var data = [
+ [[0, 0, 0], 'AAAA'],
+ [[0, 0, 1], 'AAAB'],
+ [[0, 1, -1], 'AAH/'],
+ [[1, 1, 1], 'AQEB'],
+ [[0, -73, 23], 'ALcX']
+]
+
+test('convert known data to string', function (t) {
+ for (var i = 0; i < data.length; i++) {
+ var bytes = data[i][0]
+ var expected = data[i][1]
+ var actual = b64.fromByteArray(bytes)
+ t.equal(actual, expected, 'Ensure that ' + bytes + ' serialise to ' + expected)
+ }
+ t.end()
+})
+
+test('convert known data from string', function (t) {
+ for (var i = 0; i < data.length; i++) {
+ var expected = data[i][0]
+ var string = data[i][1]
+ var actual = b64.toByteArray(string)
+ t.ok(equal(actual, expected), 'Ensure that ' + string + ' deserialise to ' + expected)
+ var length = b64.byteLength(string)
+ t.equal(length, expected.length, 'Ensure that ' + string + ' has byte lentgh of ' + expected.length)
+ }
+ t.end()
+})
+
+function equal (a, b) {
+ var i
+ var length = a.length
+ if (length !== b.length) return false
+ for (i = 0; i < length; ++i) {
+ if ((a[i] & 0xFF) !== (b[i] & 0xFF)) return false
+ }
+ return true
+}
+
+function map (arr, callback) {
+ var res = []
+ var kValue, mappedValue
+
+ for (var k = 0, len = arr.length; k < len; k++) {
+ if ((typeof arr === 'string' && !!arr.charAt(k))) {
+ kValue = arr.charAt(k)
+ mappedValue = callback(kValue, k, arr)
+ res[k] = mappedValue
+ } else if (typeof arr !== 'string' && k in arr) {
+ kValue = arr[k]
+ mappedValue = callback(kValue, k, arr)
+ res[k] = mappedValue
+ }
+ }
+ return res
+}
diff --git a/cordova/node_modules/ios-sim/node_modules/base64-js/test/corrupt.js b/cordova/node_modules/ios-sim/node_modules/base64-js/test/corrupt.js
new file mode 100644
index 0000000..44c6e71
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/base64-js/test/corrupt.js
@@ -0,0 +1,10 @@
+var test = require('tape')
+var b64 = require('../')
+
+test('padding bytes found inside base64 string', function (t) {
+ // See https://github.com/beatgammit/base64-js/issues/42
+ var str = 'SQ==QU0='
+ t.deepEqual(b64.toByteArray(str), new Uint8Array([73]))
+ t.equal(b64.byteLength(str), 1)
+ t.end()
+})
diff --git a/cordova/node_modules/ios-sim/node_modules/base64-js/test/url-safe.js b/cordova/node_modules/ios-sim/node_modules/base64-js/test/url-safe.js
new file mode 100644
index 0000000..4382e06
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/base64-js/test/url-safe.js
@@ -0,0 +1,24 @@
+var test = require('tape')
+var b64 = require('../')
+
+test('decode url-safe style base64 strings', function (t) {
+ var expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff]
+
+ var str = '//++/++/++//'
+ var actual = b64.toByteArray(str)
+ for (var i = 0; i < actual.length; i++) {
+ t.equal(actual[i], expected[i])
+ }
+
+ t.equal(b64.byteLength(str), actual.length)
+
+ str = '__--_--_--__'
+ actual = b64.toByteArray(str)
+ for (i = 0; i < actual.length; i++) {
+ t.equal(actual[i], expected[i])
+ }
+
+ t.equal(b64.byteLength(str), actual.length)
+
+ t.end()
+})
diff --git a/cordova/node_modules/ios-sim/node_modules/bplist-parser/.npmignore b/cordova/node_modules/ios-sim/node_modules/bplist-parser/.npmignore
new file mode 100755
index 0000000..a9b46ea
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/bplist-parser/.npmignore
@@ -0,0 +1,8 @@
+/build/*
+node_modules
+*.node
+*.sh
+*.swp
+.lock*
+npm-debug.log
+.idea
diff --git a/cordova/node_modules/ios-sim/node_modules/bplist-parser/README.md b/cordova/node_modules/ios-sim/node_modules/bplist-parser/README.md
new file mode 100755
index 0000000..37e5e1c
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/bplist-parser/README.md
@@ -0,0 +1,47 @@
+bplist-parser
+=============
+
+Binary Mac OS X Plist (property list) parser.
+
+## Installation
+
+```bash
+$ npm install bplist-parser
+```
+
+## Quick Examples
+
+```javascript
+var bplist = require('bplist-parser');
+
+bplist.parseFile('myPlist.bplist', function(err, obj) {
+ if (err) throw err;
+
+ console.log(JSON.stringify(obj));
+});
+```
+
+## License
+
+(The MIT License)
+
+Copyright (c) 2012 Near Infinity Corporation
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/cordova/node_modules/ios-sim/node_modules/bplist-parser/bplistParser.js b/cordova/node_modules/ios-sim/node_modules/bplist-parser/bplistParser.js
new file mode 100755
index 0000000..e818454
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/bplist-parser/bplistParser.js
@@ -0,0 +1,332 @@
+'use strict';
+
+// adapted from http://code.google.com/p/plist/source/browse/trunk/src/com/dd/plist/BinaryPropertyListParser.java
+
+var fs = require('fs');
+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
+ // <a href="http://www.opensource.apple.com/source/CF/CF-635/CFBinaryPList.c">
+ // Apple's binary property list parser implementation</a>.
+ 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;
+}
diff --git a/cordova/node_modules/ios-sim/node_modules/bplist-parser/package.json b/cordova/node_modules/ios-sim/node_modules/bplist-parser/package.json
new file mode 100755
index 0000000..58cb2af
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/bplist-parser/package.json
@@ -0,0 +1,55 @@
+{
+ "_from": "bplist-parser@^0.0.6",
+ "_id": "[email protected]",
+ "_inBundle": true,
+ "_integrity": "sha1-ONo0cYF9+dRKs4kuJ3B7u9daEbk=",
+ "_location": "/cordova-ios/ios-sim/bplist-parser",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "bplist-parser@^0.0.6",
+ "name": "bplist-parser",
+ "escapedName": "bplist-parser",
+ "rawSpec": "^0.0.6",
+ "saveSpec": null,
+ "fetchSpec": "^0.0.6"
+ },
+ "_requiredBy": [
+ "/cordova-ios/ios-sim"
+ ],
+ "_resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.0.6.tgz",
+ "_shasum": "38da3471817df9d44ab3892e27707bbbd75a11b9",
+ "_spec": "bplist-parser@^0.0.6",
+ "_where": "/Users/brodybits/Documents/cordova/cordova-ios/node_modules/ios-sim",
+ "author": {
+ "name": "Joe Ferner",
+ "email": "[email protected]"
+ },
+ "bugs": {
+ "url": "https://github.com/nearinfinity/node-bplist-parser/issues"
+ },
+ "bundleDependencies": false,
+ "deprecated": false,
+ "description": "Binary plist parser.",
+ "devDependencies": {
+ "nodeunit": "~0.7.4"
+ },
+ "homepage": "https://github.com/nearinfinity/node-bplist-parser#readme",
+ "keywords": [
+ "bplist",
+ "plist",
+ "parser"
+ ],
+ "license": "MIT",
+ "main": "bplistParser.js",
+ "name": "bplist-parser",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/nearinfinity/node-bplist-parser.git"
+ },
+ "scripts": {
+ "test": "./node_modules/nodeunit/bin/nodeunit test"
+ },
+ "version": "0.0.6"
+}
diff --git a/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/airplay.bplist b/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/airplay.bplist
new file mode 100755
index 0000000..931adea
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/airplay.bplist
Binary files differ
diff --git a/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/iTunes-small.bplist b/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/iTunes-small.bplist
new file mode 100755
index 0000000..b7edb14
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/iTunes-small.bplist
Binary files differ
diff --git a/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/parseTest.js b/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/parseTest.js
new file mode 100755
index 0000000..dcb6dd0
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/parseTest.js
@@ -0,0 +1,120 @@
+'use strict';
+
+// tests are adapted from https://github.com/TooTallNate/node-plist
+
+var path = require('path');
+var nodeunit = require('nodeunit');
+var bplist = require('../');
+
+module.exports = {
+ 'iTunes Small': function (test) {
+ var file = path.join(__dirname, "iTunes-small.bplist");
+ var startTime1 = new Date();
+
+ bplist.parseFile(file, function (err, dicts) {
+ if (err) {
+ throw err;
+ }
+
+ var endTime = new Date();
+ console.log('Parsed "' + file + '" in ' + (endTime - startTime1) + 'ms');
+ var dict = dicts[0];
+ test.equal(dict['Application Version'], "9.0.3");
+ test.equal(dict['Library Persistent ID'], "6F81D37F95101437");
+ test.done();
+ });
+ },
+
+ 'sample1': function (test) {
+ var file = path.join(__dirname, "sample1.bplist");
+ var startTime = new Date();
+
+ bplist.parseFile(file, function (err, dicts) {
+ if (err) {
+ throw err;
+ }
+
+ var endTime = new Date();
+ console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms');
+ var dict = dicts[0];
+ test.equal(dict['CFBundleIdentifier'], 'com.apple.dictionary.MySample');
+ test.done();
+ });
+ },
+
+ 'sample2': function (test) {
+ var file = path.join(__dirname, "sample2.bplist");
+ var startTime = new Date();
+
+ bplist.parseFile(file, function (err, dicts) {
+ if (err) {
+ throw err;
+ }
+
+ var endTime = new Date();
+ console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms');
+ var dict = dicts[0];
+ test.equal(dict['PopupMenu'][2]['Key'], "\n #import <Cocoa/Cocoa.h>\n\n#import <MacRuby/MacRuby.h>\n\nint main(int argc, char *argv[])\n{\n return macruby_main(\"rb_main.rb\", argc, argv);\n}\n");
+ test.done();
+ });
+ },
+
+ 'airplay': function (test) {
+ var file = path.join(__dirname, "airplay.bplist");
+ var startTime = new Date();
+
+ bplist.parseFile(file, function (err, dicts) {
+ if (err) {
+ throw err;
+ }
+
+ var endTime = new Date();
+ console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms');
+
+ var dict = dicts[0];
+ test.equal(dict['duration'], 5555.0495000000001);
+ test.equal(dict['position'], 4.6269989039999997);
+ test.done();
+ });
+ },
+
+ 'utf16': function (test) {
+ var file = path.join(__dirname, "utf16.bplist");
+ var startTime = new Date();
+
+ bplist.parseFile(file, function (err, dicts) {
+ if (err) {
+ throw err;
+ }
+
+ var endTime = new Date();
+ console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms');
+
+ var dict = dicts[0];
+ test.equal(dict['CFBundleName'], 'sellStuff');
+ test.equal(dict['CFBundleShortVersionString'], '2.6.1');
+ test.equal(dict['NSHumanReadableCopyright'], '©2008-2012, sellStuff, Inc.');
+ test.done();
+ });
+ },
+
+ 'uid': function (test) {
+ var file = path.join(__dirname, "uid.bplist");
+ var startTime = new Date();
+
+ bplist.parseFile(file, function (err, dicts) {
+ if (err) {
+ throw err;
+ }
+
+ var endTime = new Date();
+ console.log('Parsed "' + file + '" in ' + (endTime - startTime) + 'ms');
+
+ var dict = dicts[0];
+ test.deepEqual(dict['$objects'][1]['NS.keys'], [2, 3, 4]);
+ test.deepEqual(dict['$objects'][1]['NS.objects'], [5, 6, 7]);
+ test.equal(dict['$top']['root'], 1);
+ test.done();
+ });
+ }
+};
diff --git a/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/sample1.bplist b/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/sample1.bplist
new file mode 100755
index 0000000..5b808ff
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/sample1.bplist
Binary files differ
diff --git a/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/sample2.bplist b/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/sample2.bplist
new file mode 100755
index 0000000..fc42979
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/sample2.bplist
Binary files differ
diff --git a/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/uid.bplist b/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/uid.bplist
new file mode 100755
index 0000000..59f341e
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/uid.bplist
Binary files differ
diff --git a/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/utf16.bplist b/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/utf16.bplist
new file mode 100755
index 0000000..ba4bcfa
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/bplist-parser/test/utf16.bplist
Binary files differ
diff --git a/cordova/node_modules/ios-sim/node_modules/nopt/.npmignore b/cordova/node_modules/ios-sim/node_modules/nopt/.npmignore
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/nopt/.npmignore
diff --git a/cordova/node_modules/ios-sim/node_modules/nopt/LICENSE b/cordova/node_modules/ios-sim/node_modules/nopt/LICENSE
new file mode 100755
index 0000000..05a4010
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/nopt/LICENSE
@@ -0,0 +1,23 @@
+Copyright 2009, 2010, 2011 Isaac Z. Schlueter.
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
diff --git a/cordova/node_modules/ios-sim/node_modules/nopt/README.md b/cordova/node_modules/ios-sim/node_modules/nopt/README.md
new file mode 100755
index 0000000..e364799
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/nopt/README.md
@@ -0,0 +1,206 @@
+If you want to write an option parser, and have it be good, there are
+two ways to do it. The Right Way, and the Wrong Way.
+
+The Wrong Way is to sit down and write an option parser. We've all done
+that.
+
+The Right Way is to write some complex configurable program with so many
+options that you go half-insane just trying to manage them all, and put
+it off with duct-tape solutions until you see exactly to the core of the
+problem, and finally snap and write an awesome option parser.
+
+If you want to write an option parser, don't write an option parser.
+Write a package manager, or a source control system, or a service
+restarter, or an operating system. You probably won't end up with a
+good one of those, but if you don't give up, and you are relentless and
+diligent enough in your procrastination, you may just end up with a very
+nice option parser.
+
+## USAGE
+
+ // my-program.js
+ var nopt = require("nopt")
+ , Stream = require("stream").Stream
+ , path = require("path")
+ , knownOpts = { "foo" : [String, null]
+ , "bar" : [Stream, Number]
+ , "baz" : path
+ , "bloo" : [ "big", "medium", "small" ]
+ , "flag" : Boolean
+ , "pick" : Boolean
+ , "many" : [String, Array]
+ }
+ , shortHands = { "foofoo" : ["--foo", "Mr. Foo"]
+ , "b7" : ["--bar", "7"]
+ , "m" : ["--bloo", "medium"]
+ , "p" : ["--pick"]
+ , "f" : ["--flag"]
+ }
+ // everything is optional.
+ // knownOpts and shorthands default to {}
+ // arg list defaults to process.argv
+ // slice defaults to 2
+ , parsed = nopt(knownOpts, shortHands, process.argv, 2)
+ console.log(parsed)
+
+This would give you support for any of the following:
+
+```bash
+$ node my-program.js --foo "blerp" --no-flag
+{ "foo" : "blerp", "flag" : false }
+
+$ node my-program.js ---bar 7 --foo "Mr. Hand" --flag
+{ bar: 7, foo: "Mr. Hand", flag: true }
+
+$ node my-program.js --foo "blerp" -f -----p
+{ foo: "blerp", flag: true, pick: true }
+
+$ node my-program.js -fp --foofoo
+{ foo: "Mr. Foo", flag: true, pick: true }
+
+$ node my-program.js --foofoo -- -fp # -- stops the flag parsing.
+{ foo: "Mr. Foo", argv: { remain: ["-fp"] } }
+
+$ node my-program.js --blatzk 1000 -fp # unknown opts are ok.
+{ blatzk: 1000, flag: true, pick: true }
+
+$ node my-program.js --blatzk true -fp # but they need a value
+{ blatzk: true, flag: true, pick: true }
+
+$ node my-program.js --no-blatzk -fp # unless they start with "no-"
+{ blatzk: false, flag: true, pick: true }
+
+$ node my-program.js --baz b/a/z # known paths are resolved.
+{ baz: "/Users/isaacs/b/a/z" }
+
+# if Array is one of the types, then it can take many
+# values, and will always be an array. The other types provided
+# specify what types are allowed in the list.
+
+$ node my-program.js --many 1 --many null --many foo
+{ many: ["1", "null", "foo"] }
+
+$ node my-program.js --many foo
+{ many: ["foo"] }
+```
+
+Read the tests at the bottom of `lib/nopt.js` for more examples of
+what this puppy can do.
+
+## Types
+
+The following types are supported, and defined on `nopt.typeDefs`
+
+* String: A normal string. No parsing is done.
+* path: A file system path. Gets resolved against cwd if not absolute.
+* Number: Must be numeric.
+* url: A url. If it doesn't parse, it isn't accepted.
+* Boolean: Must be either `true` or `false`. If an option is a boolean,
+ then it does not need a value, and its presence will imply `true` as
+ the value. To negate boolean flags, do `--no-whatever` or `--whatever
+ false`
+* NaN: Means that the option is strictly not allowed. Any value will
+ fail.
+* Stream: An object matching the "Stream" class in node. Valuable
+ for use when validating programmatically. (npm uses this to let you
+ supply any WriteStream on the `outfd` and `logfd` config options.)
+* Array: If `Array` is specified as one of the types, then the value
+ will be parsed as a list of options. This means that multiple values
+ can be specified, and that the value will always be an array.
+
+If a type is an array of values not on this list, then those are
+considered valid values. For instance, in the example above, the
+`--bloo` option can only be one of `"big"`, `"medium"`, or `"small"`,
+and any other value will be rejected.
+
+When parsing unknown fields, `"true"`, `"false"`, and `"null"` will be
+interpreted as their JavaScript equivalents, and numeric values will be
+interpreted as a number.
+
+You can also mix types and values, or multiple types, in a list. For
+instance `{ blah: [Number, null] }` would allow a value to be set to
+either a Number or null.
+
+To define a new type, add it to `nopt.typeDefs`. Each item in that
+hash is an object with a `type` member and a `validate` method. The
+`type` member is an object that matches what goes in the type list. The
+`validate` method is a function that gets called with `validate(data,
+key, val)`. Validate methods should assign `data[key]` to the valid
+value of `val` if it can be handled properly, or return boolean
+`false` if it cannot.
+
+You can also call `nopt.clean(data, types, typeDefs)` to clean up a
+config object and remove its invalid properties.
+
+## Error Handling
+
+By default, nopt outputs a warning to standard error when invalid
+options are found. You can change this behavior by assigning a method
+to `nopt.invalidHandler`. This method will be called with
+the offending `nopt.invalidHandler(key, val, types)`.
+
+If no `nopt.invalidHandler` is assigned, then it will console.error
+its whining. If it is assigned to boolean `false` then the warning is
+suppressed.
+
+## Abbreviations
+
+Yes, they are supported. If you define options like this:
+
+```javascript
+{ "foolhardyelephants" : Boolean
+, "pileofmonkeys" : Boolean }
+```
+
+Then this will work:
+
+```bash
+node program.js --foolhar --pil
+node program.js --no-f --pileofmon
+# etc.
+```
+
+## Shorthands
+
+Shorthands are a hash of shorter option names to a snippet of args that
+they expand to.
+
+If multiple one-character shorthands are all combined, and the
+combination does not unambiguously match any other option or shorthand,
+then they will be broken up into their constituent parts. For example:
+
+```json
+{ "s" : ["--loglevel", "silent"]
+, "g" : "--global"
+, "f" : "--force"
+, "p" : "--parseable"
+, "l" : "--long"
+}
+```
+
+```bash
+npm ls -sgflp
+# just like doing this:
+npm ls --loglevel silent --global --force --long --parseable
+```
+
+## The Rest of the args
+
+The config object returned by nopt is given a special member called
+`argv`, which is an object with the following fields:
+
+* `remain`: The remaining args after all the parsing has occurred.
+* `original`: The args as they originally appeared.
+* `cooked`: The args after flags and shorthands are expanded.
+
+## Slicing
+
+Node programs are called with more or less the exact argv as it appears
+in C land, after the v8 and node-specific options have been plucked off.
+As such, `argv[0]` is always `node` and `argv[1]` is always the
+JavaScript program being run.
+
+That's usually not very useful to you. So they're sliced off by
+default. If you want them, then you can pass in `0` as the last
+argument, or any other number that you'd like to slice off the start of
+the list.
diff --git a/cordova/node_modules/ios-sim/node_modules/nopt/bin/nopt.js b/cordova/node_modules/ios-sim/node_modules/nopt/bin/nopt.js
new file mode 100755
index 0000000..df90c72
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/nopt/bin/nopt.js
@@ -0,0 +1,44 @@
+#!/usr/bin/env node
+var nopt = require("../lib/nopt")
+ , types = { num: Number
+ , bool: Boolean
+ , help: Boolean
+ , list: Array
+ , "num-list": [Number, Array]
+ , "str-list": [String, Array]
+ , "bool-list": [Boolean, Array]
+ , str: String }
+ , shorthands = { s: [ "--str", "astring" ]
+ , b: [ "--bool" ]
+ , nb: [ "--no-bool" ]
+ , tft: [ "--bool-list", "--no-bool-list", "--bool-list", "true" ]
+ , "?": ["--help"]
+ , h: ["--help"]
+ , H: ["--help"]
+ , n: [ "--num", "125" ] }
+ , parsed = nopt( types
+ , shorthands
+ , process.argv
+ , 2 )
+
+console.log("parsed", parsed)
+
+if (parsed.help) {
+ console.log("")
+ console.log("nopt cli tester")
+ console.log("")
+ console.log("types")
+ console.log(Object.keys(types).map(function M (t) {
+ var type = types[t]
+ if (Array.isArray(type)) {
+ return [t, type.map(function (type) { return type.name })]
+ }
+ return [t, type && type.name]
+ }).reduce(function (s, i) {
+ s[i[0]] = i[1]
+ return s
+ }, {}))
+ console.log("")
+ console.log("shorthands")
+ console.log(shorthands)
+}
diff --git a/cordova/node_modules/ios-sim/node_modules/nopt/examples/my-program.js b/cordova/node_modules/ios-sim/node_modules/nopt/examples/my-program.js
new file mode 100755
index 0000000..142447e
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/nopt/examples/my-program.js
@@ -0,0 +1,30 @@
+#!/usr/bin/env node
+
+//process.env.DEBUG_NOPT = 1
+
+// my-program.js
+var nopt = require("../lib/nopt")
+ , Stream = require("stream").Stream
+ , path = require("path")
+ , knownOpts = { "foo" : [String, null]
+ , "bar" : [Stream, Number]
+ , "baz" : path
+ , "bloo" : [ "big", "medium", "small" ]
+ , "flag" : Boolean
+ , "pick" : Boolean
+ }
+ , shortHands = { "foofoo" : ["--foo", "Mr. Foo"]
+ , "b7" : ["--bar", "7"]
+ , "m" : ["--bloo", "medium"]
+ , "p" : ["--pick"]
+ , "f" : ["--flag", "true"]
+ , "g" : ["--flag"]
+ , "s" : "--flag"
+ }
+ // everything is optional.
+ // knownOpts and shorthands default to {}
+ // arg list defaults to process.argv
+ // slice defaults to 2
+ , parsed = nopt(knownOpts, shortHands, process.argv, 2)
+
+console.log("parsed =\n"+ require("util").inspect(parsed))
diff --git a/cordova/node_modules/ios-sim/node_modules/nopt/lib/nopt.js b/cordova/node_modules/ios-sim/node_modules/nopt/lib/nopt.js
new file mode 100755
index 0000000..ff41bbc
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/nopt/lib/nopt.js
@@ -0,0 +1,530 @@
+// info about each config option.
+
+var debug = process.env.DEBUG_NOPT || process.env.NOPT_DEBUG
+ ? function () { console.error.apply(console, arguments) }
+ : function () {}
+
+var url = require("url")
+ , path = require("path")
+ , Stream = require("stream").Stream
+ , abbrev = require("abbrev")
+
+module.exports = exports = nopt
+exports.clean = clean
+
+exports.typeDefs =
+ { String : { type: String, validate: validateString }
+ , Boolean : { type: Boolean, validate: validateBoolean }
+ , url : { type: url, validate: validateUrl }
+ , Number : { type: Number, validate: validateNumber }
+ , path : { type: path, validate: validatePath }
+ , Stream : { type: Stream, validate: validateStream }
+ }
+
+function nopt (types, shorthands, args, slice) {
+ args = args || process.argv
+ types = types || {}
+ shorthands = shorthands || {}
+ if (typeof slice !== "number") slice = 2
+
+ debug(types, shorthands, args, slice)
+
+ args = args.slice(slice)
+ var data = {}
+ , key
+ , remain = []
+ , cooked = args
+ , original = args.slice(0)
+
+ parse(args, data, remain, types, shorthands)
+ // now data is full
+ clean(data, types, exports.typeDefs)
+ data.argv = {remain:remain,cooked:cooked,original:original}
+ data.argv.toString = function () {
+ return this.original.map(JSON.stringify).join(" ")
+ }
+ return data
+}
+
+function clean (data, types, typeDefs) {
+ typeDefs = typeDefs || exports.typeDefs
+ var remove = {}
+ , typeDefault = [false, true, null, String, Number]
+
+ Object.keys(data).forEach(function (k) {
+ if (k === "argv") return
+ var val = data[k]
+ , isArray = Array.isArray(val)
+ , type = types[k]
+ if (!isArray) val = [val]
+ if (!type) type = typeDefault
+ if (type === Array) type = typeDefault.concat(Array)
+ if (!Array.isArray(type)) type = [type]
+
+ debug("val=%j", val)
+ debug("types=", type)
+ val = val.map(function (val) {
+ // if it's an unknown value, then parse false/true/null/numbers
+ if (typeof val === "string") {
+ debug("string %j", val)
+ val = val.trim()
+ if ((val === "null" && ~type.indexOf(null))
+ || (val === "true" &&
+ (~type.indexOf(true) || ~type.indexOf(Boolean)))
+ || (val === "false" &&
+ (~type.indexOf(false) || ~type.indexOf(Boolean)))) {
+ val = JSON.parse(val)
+ debug("jsonable %j", val)
+ } else if (~type.indexOf(Number) && !isNaN(val)) {
+ debug("convert to number", val)
+ val = +val
+ }
+ }
+
+ if (!types.hasOwnProperty(k)) {
+ return val
+ }
+
+ // allow `--no-blah` to set 'blah' to null if null is allowed
+ if (val === false && ~type.indexOf(null) &&
+ !(~type.indexOf(false) || ~type.indexOf(Boolean))) {
+ val = null
+ }
+
+ var d = {}
+ d[k] = val
+ debug("prevalidated val", d, val, types[k])
+ if (!validate(d, k, val, types[k], typeDefs)) {
+ if (exports.invalidHandler) {
+ exports.invalidHandler(k, val, types[k], data)
+ } else if (exports.invalidHandler !== false) {
+ debug("invalid: "+k+"="+val, types[k])
+ }
+ return remove
+ }
+ debug("validated val", d, val, types[k])
+ return d[k]
+ }).filter(function (val) { return val !== remove })
+
+ if (!val.length) delete data[k]
+ else if (isArray) {
+ debug(isArray, data[k], val)
+ data[k] = val
+ } else data[k] = val[0]
+
+ debug("k=%s val=%j", k, val, data[k])
+ })
+}
+
+function validateString (data, k, val) {
+ data[k] = String(val)
+}
+
+function validatePath (data, k, val) {
+ data[k] = path.resolve(String(val))
+ return true
+}
+
+function validateNumber (data, k, val) {
+ debug("validate Number %j %j %j", k, val, isNaN(val))
+ if (isNaN(val)) return false
+ data[k] = +val
+}
+
+function validateBoolean (data, k, val) {
+ if (val instanceof Boolean) val = val.valueOf()
+ else if (typeof val === "string") {
+ if (!isNaN(val)) val = !!(+val)
+ else if (val === "null" || val === "false") val = false
+ else val = true
+ } else val = !!val
+ data[k] = val
+}
+
+function validateUrl (data, k, val) {
+ val = url.parse(String(val))
+ if (!val.host) return false
+ data[k] = val.href
+}
+
+function validateStream (data, k, val) {
+ if (!(val instanceof Stream)) return false
+ data[k] = val
+}
+
+function validate (data, k, val, type, typeDefs) {
+ // arrays are lists of types.
+ if (Array.isArray(type)) {
+ for (var i = 0, l = type.length; i < l; i ++) {
+ if (type[i] === Array) continue
+ if (validate(data, k, val, type[i], typeDefs)) return true
+ }
+ delete data[k]
+ return false
+ }
+
+ // an array of anything?
+ if (type === Array) return true
+
+ // NaN is poisonous. Means that something is not allowed.
+ if (type !== type) {
+ debug("Poison NaN", k, val, type)
+ delete data[k]
+ return false
+ }
+
+ // explicit list of values
+ if (val === type) {
+ debug("Explicitly allowed %j", val)
+ // if (isArray) (data[k] = data[k] || []).push(val)
+ // else data[k] = val
+ data[k] = val
+ return true
+ }
+
+ // now go through the list of typeDefs, validate against each one.
+ var ok = false
+ , types = Object.keys(typeDefs)
+ for (var i = 0, l = types.length; i < l; i ++) {
+ debug("test type %j %j %j", k, val, types[i])
+ var t = typeDefs[types[i]]
+ if (t && type === t.type) {
+ var d = {}
+ ok = false !== t.validate(d, k, val)
+ val = d[k]
+ if (ok) {
+ // if (isArray) (data[k] = data[k] || []).push(val)
+ // else data[k] = val
+ data[k] = val
+ break
+ }
+ }
+ }
+ debug("OK? %j (%j %j %j)", ok, k, val, types[i])
+
+ if (!ok) delete data[k]
+ return ok
+}
+
+function parse (args, data, remain, types, shorthands) {
+ debug("parse", args, data, remain)
+
+ var key = null
+ , abbrevs = abbrev(Object.keys(types))
+ , shortAbbr = abbrev(Object.keys(shorthands))
+
+ for (var i = 0; i < args.length; i ++) {
+ var arg = args[i]
+ debug("arg", arg)
+
+ if (arg.match(/^-{2,}$/)) {
+ // done with keys.
+ // the rest are args.
+ remain.push.apply(remain, args.slice(i + 1))
+ args[i] = "--"
+ break
+ }
+ if (arg.charAt(0) === "-") {
+ if (arg.indexOf("=") !== -1) {
+ var v = arg.split("=")
+ arg = v.shift()
+ v = v.join("=")
+ args.splice.apply(args, [i, 1].concat([arg, v]))
+ }
+ // see if it's a shorthand
+ // if so, splice and back up to re-parse it.
+ var shRes = resolveShort(arg, shorthands, shortAbbr, abbrevs)
+ debug("arg=%j shRes=%j", arg, shRes)
+ if (shRes) {
+ debug(arg, shRes)
+ args.splice.apply(args, [i, 1].concat(shRes))
+ if (arg !== shRes[0]) {
+ i --
+ continue
+ }
+ }
+ arg = arg.replace(/^-+/, "")
+ var no = false
+ while (arg.toLowerCase().indexOf("no-") === 0) {
+ no = !no
+ arg = arg.substr(3)
+ }
+
+ if (abbrevs[arg]) arg = abbrevs[arg]
+
+ var isArray = types[arg] === Array ||
+ Array.isArray(types[arg]) && types[arg].indexOf(Array) !== -1
+
+ var val
+ , la = args[i + 1]
+
+ var isBool = no ||
+ types[arg] === Boolean ||
+ Array.isArray(types[arg]) && types[arg].indexOf(Boolean) !== -1 ||
+ (la === "false" &&
+ (types[arg] === null ||
+ Array.isArray(types[arg]) && ~types[arg].indexOf(null)))
+
+ if (isBool) {
+ // just set and move along
+ val = !no
+ // however, also support --bool true or --bool false
+ if (la === "true" || la === "false") {
+ val = JSON.parse(la)
+ la = null
+ if (no) val = !val
+ i ++
+ }
+
+ // also support "foo":[Boolean, "bar"] and "--foo bar"
+ if (Array.isArray(types[arg]) && la) {
+ if (~types[arg].indexOf(la)) {
+ // an explicit type
+ val = la
+ i ++
+ } else if ( la === "null" && ~types[arg].indexOf(null) ) {
+ // null allowed
+ val = null
+ i ++
+ } else if ( !la.match(/^-{2,}[^-]/) &&
+ !isNaN(la) &&
+ ~types[arg].indexOf(Number) ) {
+ // number
+ val = +la
+ i ++
+ } else if ( !la.match(/^-[^-]/) && ~types[arg].indexOf(String) ) {
+ // string
+ val = la
+ i ++
+ }
+ }
+
+ if (isArray) (data[arg] = data[arg] || []).push(val)
+ else data[arg] = val
+
+ continue
+ }
+
+ if (la && la.match(/^-{2,}$/)) {
+ la = undefined
+ i --
+ }
+
+ val = la === undefined ? true : la
+ if (isArray) (data[arg] = data[arg] || []).push(val)
+ else data[arg] = val
+
+ i ++
+ continue
+ }
+ remain.push(arg)
+ }
+}
+
+function resolveShort (arg, shorthands, shortAbbr, abbrevs) {
+ // handle single-char shorthands glommed together, like
+ // npm ls -glp, but only if there is one dash, and only if
+ // all of the chars are single-char shorthands, and it's
+ // not a match to some other abbrev.
+ arg = arg.replace(/^-+/, '')
+ if (abbrevs[arg] && !shorthands[arg]) {
+ return null
+ }
+ if (shortAbbr[arg]) {
+ arg = shortAbbr[arg]
+ } else {
+ var singles = shorthands.___singles
+ if (!singles) {
+ singles = Object.keys(shorthands).filter(function (s) {
+ return s.length === 1
+ }).reduce(function (l,r) { l[r] = true ; return l }, {})
+ shorthands.___singles = singles
+ }
+ var chrs = arg.split("").filter(function (c) {
+ return singles[c]
+ })
+ if (chrs.join("") === arg) return chrs.map(function (c) {
+ return shorthands[c]
+ }).reduce(function (l, r) {
+ return l.concat(r)
+ }, [])
+ }
+
+ if (shorthands[arg] && !Array.isArray(shorthands[arg])) {
+ shorthands[arg] = shorthands[arg].split(/\s+/)
+ }
+ return shorthands[arg]
+}
+
+if (module === require.main) {
+var assert = require("assert")
+ , util = require("util")
+
+ , shorthands =
+ { s : ["--loglevel", "silent"]
+ , d : ["--loglevel", "info"]
+ , dd : ["--loglevel", "verbose"]
+ , ddd : ["--loglevel", "silly"]
+ , noreg : ["--no-registry"]
+ , reg : ["--registry"]
+ , "no-reg" : ["--no-registry"]
+ , silent : ["--loglevel", "silent"]
+ , verbose : ["--loglevel", "verbose"]
+ , h : ["--usage"]
+ , H : ["--usage"]
+ , "?" : ["--usage"]
+ , help : ["--usage"]
+ , v : ["--version"]
+ , f : ["--force"]
+ , desc : ["--description"]
+ , "no-desc" : ["--no-description"]
+ , "local" : ["--no-global"]
+ , l : ["--long"]
+ , p : ["--parseable"]
+ , porcelain : ["--parseable"]
+ , g : ["--global"]
+ }
+
+ , types =
+ { aoa: Array
+ , nullstream: [null, Stream]
+ , str: String
+ , browser : String
+ , cache : path
+ , color : ["always", Boolean]
+ , depth : Number
+ , description : Boolean
+ , dev : Boolean
+ , editor : path
+ , force : Boolean
+ , global : Boolean
+ , globalconfig : path
+ , group : [String, Number]
+ , gzipbin : String
+ , logfd : [Number, Stream]
+ , loglevel : ["silent","win","error","warn","info","verbose","silly"]
+ , long : Boolean
+ , "node-version" : [false, String]
+ , npaturl : url
+ , npat : Boolean
+ , "onload-script" : [false, String]
+ , outfd : [Number, Stream]
+ , parseable : Boolean
+ , pre: Boolean
+ , prefix: path
+ , proxy : url
+ , "rebuild-bundle" : Boolean
+ , registry : url
+ , searchopts : String
+ , searchexclude: [null, String]
+ , shell : path
+ , t: [Array, String]
+ , tag : String
+ , tar : String
+ , tmp : path
+ , "unsafe-perm" : Boolean
+ , usage : Boolean
+ , user : String
+ , username : String
+ , userconfig : path
+ , version : Boolean
+ , viewer: path
+ , _exit : Boolean
+ }
+
+; [["-v", {version:true}, []]
+ ,["---v", {version:true}, []]
+ ,["ls -s --no-reg connect -d",
+ {loglevel:"info",registry:null},["ls","connect"]]
+ ,["ls ---s foo",{loglevel:"silent"},["ls","foo"]]
+ ,["ls --registry blargle", {}, ["ls"]]
+ ,["--no-registry", {registry:null}, []]
+ ,["--no-color true", {color:false}, []]
+ ,["--no-color false", {color:true}, []]
+ ,["--no-color", {color:false}, []]
+ ,["--color false", {color:false}, []]
+ ,["--color --logfd 7", {logfd:7,color:true}, []]
+ ,["--color=true", {color:true}, []]
+ ,["--logfd=10", {logfd:10}, []]
+ ,["--tmp=/tmp -tar=gtar",{tmp:"/tmp",tar:"gtar"},[]]
+ ,["--tmp=tmp -tar=gtar",
+ {tmp:path.resolve(process.cwd(), "tmp"),tar:"gtar"},[]]
+ ,["--logfd x", {}, []]
+ ,["a -true -- -no-false", {true:true},["a","-no-false"]]
+ ,["a -no-false", {false:false},["a"]]
+ ,["a -no-no-true", {true:true}, ["a"]]
+ ,["a -no-no-no-false", {false:false}, ["a"]]
+ ,["---NO-no-No-no-no-no-nO-no-no"+
+ "-No-no-no-no-no-no-no-no-no"+
+ "-no-no-no-no-NO-NO-no-no-no-no-no-no"+
+ "-no-body-can-do-the-boogaloo-like-I-do"
+ ,{"body-can-do-the-boogaloo-like-I-do":false}, []]
+ ,["we are -no-strangers-to-love "+
+ "--you-know the-rules --and so-do-i "+
+ "---im-thinking-of=a-full-commitment "+
+ "--no-you-would-get-this-from-any-other-guy "+
+ "--no-gonna-give-you-up "+
+ "-no-gonna-let-you-down=true "+
+ "--no-no-gonna-run-around false "+
+ "--desert-you=false "+
+ "--make-you-cry false "+
+ "--no-tell-a-lie "+
+ "--no-no-and-hurt-you false"
+ ,{"strangers-to-love":false
+ ,"you-know":"the-rules"
+ ,"and":"so-do-i"
+ ,"you-would-get-this-from-any-other-guy":false
+ ,"gonna-give-you-up":false
+ ,"gonna-let-you-down":false
+ ,"gonna-run-around":false
+ ,"desert-you":false
+ ,"make-you-cry":false
+ ,"tell-a-lie":false
+ ,"and-hurt-you":false
+ },["we", "are"]]
+ ,["-t one -t two -t three"
+ ,{t: ["one", "two", "three"]}
+ ,[]]
+ ,["-t one -t null -t three four five null"
+ ,{t: ["one", "null", "three"]}
+ ,["four", "five", "null"]]
+ ,["-t foo"
+ ,{t:["foo"]}
+ ,[]]
+ ,["--no-t"
+ ,{t:["false"]}
+ ,[]]
+ ,["-no-no-t"
+ ,{t:["true"]}
+ ,[]]
+ ,["-aoa one -aoa null -aoa 100"
+ ,{aoa:["one", null, 100]}
+ ,[]]
+ ,["-str 100"
+ ,{str:"100"}
+ ,[]]
+ ,["--color always"
+ ,{color:"always"}
+ ,[]]
+ ,["--no-nullstream"
+ ,{nullstream:null}
+ ,[]]
+ ,["--nullstream false"
+ ,{nullstream:null}
+ ,[]]
+ ].forEach(function (test) {
+ var argv = test[0].split(/\s+/)
+ , opts = test[1]
+ , rem = test[2]
+ , actual = nopt(types, shorthands, argv, 0)
+ , parsed = actual.argv
+ delete actual.argv
+ console.log(util.inspect(actual, false, 2, true), parsed.remain)
+ for (var i in opts) {
+ var e = JSON.stringify(opts[i])
+ , a = JSON.stringify(actual[i] === undefined ? null : actual[i])
+ assert.equal(e, a)
+ }
+ assert.deepEqual(rem, parsed.remain)
+ })
+}
diff --git a/cordova/node_modules/ios-sim/node_modules/nopt/package.json b/cordova/node_modules/ios-sim/node_modules/nopt/package.json
new file mode 100755
index 0000000..972d0e2
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/nopt/package.json
@@ -0,0 +1,60 @@
+{
+ "_from": "[email protected]",
+ "_id": "[email protected]",
+ "_inBundle": true,
+ "_integrity": "sha1-O8DXy6e/sNWmdtvtfA6+SKT9RU4=",
+ "_location": "/cordova-ios/ios-sim/nopt",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "version",
+ "registry": true,
+ "raw": "[email protected]",
+ "name": "nopt",
+ "escapedName": "nopt",
+ "rawSpec": "1.0.9",
+ "saveSpec": null,
+ "fetchSpec": "1.0.9"
+ },
+ "_requiredBy": [
+ "/cordova-ios/ios-sim"
+ ],
+ "_resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.9.tgz",
+ "_shasum": "3bc0d7cba7bfb0d5a676dbed7c0ebe48a4fd454e",
+ "_spec": "[email protected]",
+ "_where": "/Users/brodybits/Documents/cordova/cordova-ios/node_modules/ios-sim",
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "[email protected]",
+ "url": "http://blog.izs.me/"
+ },
+ "bin": {
+ "nopt": "./bin/nopt.js"
+ },
+ "bugs": {
+ "url": "https://github.com/isaacs/nopt/issues"
+ },
+ "bundleDependencies": false,
+ "dependencies": {
+ "abbrev": "1"
+ },
+ "deprecated": false,
+ "description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.",
+ "engines": {
+ "node": "*"
+ },
+ "homepage": "https://github.com/isaacs/nopt#readme",
+ "license": {
+ "type": "MIT",
+ "url": "https://github.com/isaacs/nopt/raw/master/LICENSE"
+ },
+ "main": "lib/nopt.js",
+ "name": "nopt",
+ "repository": {
+ "type": "git",
+ "url": "git+ssh://[email protected]/isaacs/nopt.git"
+ },
+ "scripts": {
+ "test": "node lib/nopt.js"
+ },
+ "version": "1.0.9"
+}
diff --git a/cordova/node_modules/ios-sim/node_modules/plist/.jshintrc b/cordova/node_modules/ios-sim/node_modules/plist/.jshintrc
new file mode 100644
index 0000000..3f42622
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/plist/.jshintrc
@@ -0,0 +1,4 @@
+{
+ "laxbreak": true,
+ "laxcomma": true
+}
diff --git a/cordova/node_modules/ios-sim/node_modules/plist/.travis.yml b/cordova/node_modules/ios-sim/node_modules/plist/.travis.yml
new file mode 100644
index 0000000..12c3399
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/plist/.travis.yml
@@ -0,0 +1,33 @@
+sudo: false
+
+language: node_js
+
+node_js:
+- '6'
+- '7'
+- '8'
+- '9'
+
+env:
+ global:
+ - secure: xlLmWO7akYQjmDgrv6/b/ZMGILF8FReD+k6A/u8pYRD2JW29hhwvRwIQGcKp9+zmJdn4i5M4D1/qJkCeI3pdhAYBDHvzHOHSEwLJz1ESB2Crv6fa69CtpIufQkWvIxmZoU49tCaLpMBaIroGihJ4DAXdIVOIz6Ur9vXLDhGsE4c=
+ - secure: aQ46RdxL10xR5ZJJTMUKdH5k4tdrzgZ87nlwHC+pTr6bfRw3UKYC+6Rm7yQpg9wq0Io9O9dYCP007gQGSWstbjr1+jXNu/ubtNG+q5cpWBQZZZ013VHh9QJTf1MnetsZxbv8Yhrjg590s6vruT0oqesOnB2CizO/BsKxnY37Nos=
+
+matrix:
+ include:
+ - node_js: '6'
+ env: BROWSER_NAME=chrome BROWSER_VERSION=latest
+ - node_js: '6'
+ env: BROWSER_NAME=chrome BROWSER_VERSION=29
+ - node_js: '6'
+ env: BROWSER_NAME=firefox BROWSER_VERSION=latest
+ - node_js: '6'
+ env: BROWSER_NAME=safari BROWSER_VERSION=latest
+ - node_js: '6'
+ env: BROWSER_NAME=safari BROWSER_VERSION=7
+ - node_js: '6'
+ env: BROWSER_NAME=ie BROWSER_VERSION=11
+ - node_js: '6'
+ env: BROWSER_NAME=ie BROWSER_VERSION=10
+ - node_js: '6'
+ env: BROWSER_NAME=ie BROWSER_VERSION=9
diff --git a/cordova/node_modules/ios-sim/node_modules/plist/History.md b/cordova/node_modules/ios-sim/node_modules/plist/History.md
new file mode 100644
index 0000000..8ead85a
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/plist/History.md
@@ -0,0 +1,162 @@
+3.0.0 / 2018-03-18
+==================
+* [[`cb0d8f1bc6`]](https://github.com/TooTallNate/plist.js/commit/cb0d8f1bc60dee423f8fc2cfcac427452dfaddb0) update Makefile, rebuild dist/ (Mike Reinstein)
+* [[`9dfeffe73f`]](https://github.com/TooTallNate/plist.js/commit/9dfeffe73fdb447ac5a87ee364a1472975f12adf) remove unsupported browser versions from travis (Mike Reinstein)
+* [[`c962bfe1ea`]](https://github.com/TooTallNate/plist.js/commit/c962bfe1ea04dd87966250253d33738bceecab61) update module deps, remove support for node < 6 (Mike Reinstein)
+
+
+2.1.0 / 2017-05-04
+==================
+
+* [[`e4f06669bb`]](https://github.com/TooTallNate/plist.js/commit/e4f06669bb51d2e65654df7c39aab52bc3bf4e8a) - update license (extend copyright term) (Mike Reinstein)
+* [[`edc6e41035`]](https://github.com/TooTallNate/plist.js/commit/edc6e4103546b1d7518a577e7c202c305a8abec0) - update module deps (Mike Reinstein)
+* [[`85d11c48ef`](https://github.com/TooTallNate/plist.js/commit/85d11c48eff02312cbdd67f46fd8e74b0d372ca1)] - Harden test-cases and implementation to align with other implementations (Björn Brauer)
+* [[`7619537eaa`]](https://github.com/TooTallNate/plist.js/commit/7619537eaa9e3e5a80829e759c004d2e017a07d2) review feedback: early returns and constants for nodeTypes (Björn Brauer)
+
+
+2.0.1 / 2016-08-16
+==================
+
+* [[`de136c8388`](https://github.com/TooTallNate/plist/commit/de136c8388)] - bad npm release… (Nathan Rajlich)
+
+
+2.0.0 / 2016-08-16
+==================
+
+* [[`90deef5d43`](https://github.com/TooTallNate/plist/commit/90deef5d43)] - remove deprecated functions (Nathan Rajlich)
+* [[`d475cd8ce9`](https://github.com/TooTallNate/plist/commit/d475cd8ce9)] - Added travis ci support for node 6 (Amila Welihinda)
+* [[`04c8ee7646`](https://github.com/TooTallNate/plist/commit/04c8ee7646)] - update dependencies (Mitchell Hentges)
+* [[`97c02b3f05`](https://github.com/TooTallNate/plist/commit/97c02b3f05)] - **travis**: add `sudo: false` and test more node versions (Nathan Rajlich)
+* [[`54c821ec29`](https://github.com/TooTallNate/plist/commit/54c821ec29)] - #71 - fixed and added test (Andrew Goldis)
+* [[`4afb7c5079`](https://github.com/TooTallNate/plist/commit/4afb7c5079)] - fix `Cannot read property 'nodeValue' of undefined exception` that is thrown when a `<key></key>` construct appears in plist (Chris Kinsman)
+* [[`f360d7d685`](https://github.com/TooTallNate/plist/commit/f360d7d685)] - #66 - fixed empty keys and added tests (Andrew Goldis)
+* [[`421c7f26e9`](https://github.com/TooTallNate/plist/commit/421c7f26e9)] - #66 - fixed empty key (Andrew Goldis)
+* [[`a88aa4dca7`](https://github.com/TooTallNate/plist/commit/a88aa4dca7)] - add verbose examples (mrzmyr)
+
+
+1.2.0 / 2015-11-10
+==================
+
+ * package: update "browserify" to v12.0.1
+ * package: update "zuul" to v3.7.2
+ * package: update "xmlbuilder" to v4.0.0
+ * package: update "util-deprecate" to v1.0.2
+ * package: update "mocha" to v2.3.3
+ * package: update "base64-js" to v0.0.8
+ * build: omit undefined values
+ * travis: add node 4.0 and 4.1 to test matrix
+
+
+1.1.0 / 2014-08-27
+==================
+
+ * package: update "browserify" to v5.10.1
+ * package: update "zuul" to v1.10.2
+ * README: add "Sauce Test Status" build badge
+ * travis: use new "plistjs" sauce credentials
+ * travis: set up zuul saucelabs automated testing
+
+
+1.0.1 / 2014-06-25
+==================
+
+ * add .zuul.yml file for browser testing
+ * remove Testling stuff
+ * build: fix global variable `val` leak
+ * package: use --check-leaks when running mocha tests
+ * README: update examples to use preferred API
+ * package: add "browser" keyword
+
+
+1.0.0 / 2014-05-20
+==================
+
+ * package: remove "android-browser"
+ * test: add <dict> build() test
+ * test: re-add the empty string build() test
+ * test: remove "fixtures" and legacy "tests" dir
+ * test: add some more build() tests
+ * test: add a parse() CDATA test
+ * test: starting on build() tests
+ * test: more parse() tests
+ * package: attempt to fix "android-browser" testling
+ * parse: better <data> with newline handling
+ * README: add Testling badge
+ * test: add <data> node tests
+ * test: add a <date> parse() test
+ * travis: don't test node v0.6 or v0.8
+ * test: some more parse() tests
+ * test: add simple <string> parsing test
+ * build: add support for an optional "opts" object
+ * package: test mobile devices
+ * test: use multiline to inline the XML
+ * package: beautify
+ * package: fix "mocha" harness
+ * package: more testling browsers
+ * build: add the "version=1.0" attribute
+ * beginnings of "mocha" tests
+ * build: more JSDocs
+ * tests: add test that ensures that empty string conversion works
+ * build: update "xmlbuilder" to v2.2.1
+ * parse: ignore comment and cdata nodes
+ * tests: make the "Newlines" test actually contain a newline
+ * parse: lint
+ * test travis
+ * README: add Travis CI badge
+ * add .travis.yml file
+ * build: updated DTD to reflect name change
+ * parse: return falsey values in an Array plist
+ * build: fix encoding a typed array in the browser
+ * build: add support for Typed Arrays and ArrayBuffers
+ * build: more lint
+ * build: slight cleanup and optimizations
+ * build: use .txt() for the "date" value
+ * parse: always return a Buffer for <data> nodes
+ * build: don't interpret Strings as base64
+ * dist: commit prebuilt plist*.js files
+ * parse: fix typo in deprecate message
+ * parse: fix parse() return value
+ * parse: add jsdoc comments for the deprecated APIs
+ * parse: add `parse()` function
+ * node, parse: use `util-deprecate` module
+ * re-implemented parseFile to be asynchronous
+ * node: fix jsdoc comment
+ * Makefile: fix "node" require stubbing
+ * examples: add "browser" example
+ * package: tweak "main"
+ * package: remove "engines" field
+ * Makefile: fix --exclude command for browserify
+ * package: update "description"
+ * lib: more styling
+ * Makefile: add -build.js and -parse.js dist files
+ * lib: separate out the parse and build logic into their own files
+ * Makefile: add makefile with browserify build rules
+ * package: add "browserify" as a dev dependency
+ * plist: tabs to spaces (again)
+ * add a .jshintrc file
+ * LICENSE: update
+ * node-webkit support
+ * Ignore tests/ in .npmignore file
+ * Remove duplicate devDependencies key
+ * Remove trailing whitespace
+ * adding recent contributors. Bumping npm package number (patch release)
+ * Fixed node.js string handling
+ * bumping version number
+ * Fixed global variable plist leak
+ * patch release 0.4.1
+ * removed temporary debug output file
+ * flipping the cases for writing data and string elements in build(). removed the 125 length check. Added validation of base64 encoding for data fields when parsing. added unit tests.
+ * fixed syntax errors in README examples (issue #20)
+ * added Sync versions of calls. added deprecation warnings for old method calls. updated documentation. If the resulting object from parseStringSync is an array with 1 element, return just the element. If a plist string or file doesnt have a <plist> tag as the document root element, fail noisily (issue #15)
+ * incrementing package version
+ * added cross platform base64 encode/decode for data elements (issue #17.) Comments and hygiene.
+ * refactored the code to use a DOM parser instead of SAX. closes issues #5 and #16
+ * rolling up package version
+ * updated base64 detection regexp. updated README. hygiene.
+ * refactored the build function. Fixes issue #14
+ * refactored tests. Modified tests from issue #9. thanks @sylvinus
+ * upgrade xmlbuilder package version. this is why .end() was needed in last commit; breaking change to xmlbuilder lib. :/
+ * bug fix in build function, forgot to call .end() Refactored tests to use nodeunit
+ * Implemented support for real, identity tests
+ * Refactored base64 detection - still sloppy, fixed date building. Passing tests OK.
+ * Implemented basic plist builder that turns an existing JS object into plist XML. date, real and data types still need to be implemented.
diff --git a/cordova/node_modules/ios-sim/node_modules/plist/LICENSE b/cordova/node_modules/ios-sim/node_modules/plist/LICENSE
new file mode 100644
index 0000000..92e3423
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/plist/LICENSE
@@ -0,0 +1,24 @@
+(The MIT License)
+
+Copyright (c) 2010-2017 Nathan Rajlich <[email protected]>
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
diff --git a/cordova/node_modules/ios-sim/node_modules/plist/Makefile b/cordova/node_modules/ios-sim/node_modules/plist/Makefile
new file mode 100644
index 0000000..7a918b5
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/plist/Makefile
@@ -0,0 +1,75 @@
+
+# get Makefile directory name: http://stackoverflow.com/a/5982798/376773
+THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
+THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd)
+
+# BIN directory
+BIN := $(THIS_DIR)/node_modules/.bin
+
+# applications
+NODE ?= node
+NPM ?= $(NODE) $(shell which npm)
+BROWSERIFY ?= $(NODE) $(BIN)/browserify
+MOCHA ?= $(NODE) $(BIN)/mocha
+ZUUL ?= $(NODE) $(BIN)/zuul
+
+REPORTER ?= spec
+
+all: dist/plist.js dist/plist-build.js dist/plist-parse.js
+
+install: node_modules
+
+clean:
+ @rm -rf node_modules dist
+
+dist:
+ @mkdir -p $@
+
+dist/plist-build.js: node_modules lib/build.js dist
+ @$(BROWSERIFY) \
+ --standalone plist \
+ lib/build.js > $@
+
+dist/plist-parse.js: node_modules lib/parse.js dist
+ @$(BROWSERIFY) \
+ --standalone plist \
+ lib/parse.js > $@
+
+dist/plist.js: node_modules lib/*.js dist
+ @$(BROWSERIFY) \
+ --standalone plist \
+ index.js > $@
+
+node_modules: package.json
+ @NODE_ENV= $(NPM) install
+ @touch node_modules
+
+test:
+ @if [ "x$(BROWSER_NAME)" = "x" ]; then \
+ $(MAKE) test-node; \
+ else \
+ $(MAKE) test-zuul; \
+ fi
+
+test-node:
+ @$(MOCHA) \
+ --reporter $(REPORTER) \
+ test/*.js
+
+test-zuul:
+ @if [ "x$(BROWSER_PLATFORM)" = "x" ]; then \
+ $(ZUUL) \
+ --ui mocha-bdd \
+ --browser-name $(BROWSER_NAME) \
+ --browser-version $(BROWSER_VERSION) \
+ test/*.js; \
+ else \
+ $(ZUUL) \
+ --ui mocha-bdd \
+ --browser-name $(BROWSER_NAME) \
+ --browser-version $(BROWSER_VERSION) \
+ --browser-platform "$(BROWSER_PLATFORM)" \
+ test/*.js; \
+ fi
+
+.PHONY: all install clean test test-node test-zuul
diff --git a/cordova/node_modules/ios-sim/node_modules/plist/README.md b/cordova/node_modules/ios-sim/node_modules/plist/README.md
new file mode 100644
index 0000000..81545ae
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/plist/README.md
@@ -0,0 +1,141 @@
+plist.js
+========
+### Mac OS X Plist parser/builder for Node.js and browsers
+
+[![Sauce Test Status](https://saucelabs.com/browser-matrix/plistjs.svg)](https://saucelabs.com/u/plistjs)
+
+[![Build Status](https://travis-ci.org/TooTallNate/plist.js.svg?branch=master)](https://travis-ci.org/TooTallNate/plist.js)
+
+Provides facilities for reading and writing Mac OS X Plist (property list)
+files. These are often used in programming OS X and iOS applications, as
+well as the iTunes configuration XML file.
+
+Plist files represent stored programming "object"s. They are very similar
+to JSON. A valid Plist file is representable as a native JavaScript Object
+and vice-versa.
+
+
+## Usage
+
+### Node.js
+
+Install using `npm`:
+
+``` bash
+$ npm install --save plist
+```
+
+Then `require()` the _plist_ module in your file:
+
+``` js
+var plist = require('plist');
+
+// now use the `parse()` and `build()` functions
+var val = plist.parse('<plist><string>Hello World!</string></plist>');
+console.log(val); // "Hello World!"
+```
+
+
+### Browser
+
+Include the `dist/plist.js` in a `<script>` tag in your HTML file:
+
+``` html
+<script src="plist.js"></script>
+<script>
+ // now use the `parse()` and `build()` functions
+ var val = plist.parse('<plist><string>Hello World!</string></plist>');
+ console.log(val); // "Hello World!"
+</script>
+```
+
+
+## API
+
+### Parsing
+
+Parsing a plist from filename:
+
+``` javascript
+var fs = require('fs');
+var plist = require('plist');
+
+var obj = plist.parse(fs.readFileSync('myPlist.plist', 'utf8'));
+console.log(JSON.stringify(obj));
+```
+
+Parsing a plist from string payload:
+
+``` javascript
+var plist = require('plist');
+
+var xml =
+ '<?xml version="1.0" encoding="UTF-8"?>' +
+ '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' +
+ '<plist version="1.0">' +
+ '<key>metadata</key>' +
+ '<dict>' +
+ '<key>bundle-identifier</key>' +
+ '<string>com.company.app</string>' +
+ '<key>bundle-version</key>' +
+ '<string>0.1.1</string>' +
+ '<key>kind</key>' +
+ '<string>software</string>' +
+ '<key>title</key>' +
+ '<string>AppName</string>' +
+ '</dict>' +
+ '</plist>';
+
+console.log(plist.parse(xml));
+
+// [
+// "metadata",
+// {
+// "bundle-identifier": "com.company.app",
+// "bundle-version": "0.1.1",
+// "kind": "software",
+// "title": "AppName"
+// }
+// ]
+```
+
+### Building
+
+Given an existing JavaScript Object, you can turn it into an XML document
+that complies with the plist DTD:
+
+``` javascript
+var plist = require('plist');
+
+var json = [
+ "metadata",
+ {
+ "bundle-identifier": "com.company.app",
+ "bundle-version": "0.1.1",
+ "kind": "software",
+ "title": "AppName"
+ }
+];
+
+console.log(plist.build(json));
+
+// <?xml version="1.0" encoding="UTF-8"?>
+// <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+// <plist version="1.0">
+// <key>metadata</key>
+// <dict>
+// <key>bundle-identifier</key>
+// <string>com.company.app</string>
+// <key>bundle-version</key>
+// <string>0.1.1</string>
+// <key>kind</key>
+// <string>software</string>
+// <key>title</key>
+// <string>AppName</string>
+// </dict>
+// </plist>
+```
+
+## License
+
+[(The MIT License)](LICENSE)
diff --git a/cordova/node_modules/ios-sim/node_modules/plist/dist/plist-build.js b/cordova/node_modules/ios-sim/node_modules/plist/dist/plist-build.js
new file mode 100644
index 0000000..0606dfc
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/plist/dist/plist-build.js
@@ -0,0 +1,2832 @@
+(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.plist = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
+(function (Buffer){
+/**
+ * Module dependencies.
+ */
+
+var base64 = require('base64-js');
+var xmlbuilder = require('xmlbuilder');
+
+/**
+ * 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));
+
+ }
+}
+
+}).call(this,{"isBuffer":require("../node_modules/is-buffer/index.js")})
+},{"../node_modules/is-buffer/index.js":3,"base64-js":2,"xmlbuilder":25}],2:[function(require,module,exports){
+'use strict'
+
+exports.byteLength = byteLength
+exports.toByteArray = toByteArray
+exports.fromByteArray = fromByteArray
+
+var lookup = []
+var revLookup = []
+var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
+
+var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
+for (var i = 0, len = code.length; i < len; ++i) {
+ lookup[i] = code[i]
+ revLookup[code.charCodeAt(i)] = i
+}
+
+// Support decoding URL-safe base64 strings, as Node.js does.
+// See: https://en.wikipedia.org/wiki/Base64#URL_applications
+revLookup['-'.charCodeAt(0)] = 62
+revLookup['_'.charCodeAt(0)] = 63
+
+function placeHoldersCount (b64) {
+ var len = b64.length
+ if (len % 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
+ return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
+}
+
+function byteLength (b64) {
+ // base64 is 4/3 + up to two characters of the original data
+ return (b64.length * 3 / 4) - placeHoldersCount(b64)
+}
+
+function toByteArray (b64) {
+ var i, l, tmp, placeHolders, arr
+ var len = b64.length
+ placeHolders = placeHoldersCount(b64)
+
+ arr = new Arr((len * 3 / 4) - placeHolders)
+
+ // if there are placeholders, only get up to the last complete 4 chars
+ l = placeHolders > 0 ? len - 4 : len
+
+ var L = 0
+
+ for (i = 0; i < l; i += 4) {
+ tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
+ arr[L++] = (tmp >> 16) & 0xFF
+ arr[L++] = (tmp >> 8) & 0xFF
+ arr[L++] = tmp & 0xFF
+ }
+
+ if (placeHolders === 2) {
+ tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
+ arr[L++] = tmp & 0xFF
+ } else if (placeHolders === 1) {
+ tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
+ arr[L++] = (tmp >> 8) & 0xFF
+ arr[L++] = tmp & 0xFF
+ }
+
+ return arr
+}
+
+function tripletToBase64 (num) {
+ return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
+}
+
+function encodeChunk (uint8, start, end) {
+ var tmp
+ var output = []
+ for (var i = start; i < end; i += 3) {
+ tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF)
+ output.push(tripletToBase64(tmp))
+ }
+ return output.join('')
+}
+
+function fromByteArray (uint8) {
+ var tmp
+ var len = uint8.length
+ var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
+ var output = ''
+ var parts = []
+ var maxChunkLength = 16383 // must be multiple of 3
+
+ // go through the array every three bytes, we'll deal with trailing stuff later
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
+ parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
+ }
+
+ // pad the end with zeros, but make sure to not forget the extra bytes
+ if (extraBytes === 1) {
+ tmp = uint8[len - 1]
+ output += lookup[tmp >> 2]
+ output += lookup[(tmp << 4) & 0x3F]
+ output += '=='
+ } else if (extraBytes === 2) {
+ tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
+ output += lookup[tmp >> 10]
+ output += lookup[(tmp >> 4) & 0x3F]
+ output += lookup[(tmp << 2) & 0x3F]
+ output += '='
+ }
+
+ parts.push(output)
+
+ return parts.join('')
+}
+
+},{}],3:[function(require,module,exports){
+/*!
+ * Determine if an object is a Buffer
+ *
+ * @author Feross Aboukhadijeh <https://feross.org>
+ * @license MIT
+ */
+
+// The _isBuffer check is for Safari 5-7 support, because it's missing
+// Object.prototype.constructor. Remove this eventually
+module.exports = function (obj) {
+ return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
+}
+
+function isBuffer (obj) {
+ return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
+}
+
+// For Node v0.10 support. Remove this eventually.
+function isSlowBuffer (obj) {
+ return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
+}
+
+},{}],4:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var assign, isArray, isEmpty, isFunction, isObject, isPlainObject,
+ slice = [].slice,
+ hasProp = {}.hasOwnProperty;
+
+ assign = function() {
+ var i, key, len, source, sources, target;
+ target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
+ if (isFunction(Object.assign)) {
+ Object.assign.apply(null, arguments);
+ } else {
+ for (i = 0, len = sources.length; i < len; i++) {
+ source = sources[i];
+ if (source != null) {
+ for (key in source) {
+ if (!hasProp.call(source, key)) continue;
+ target[key] = source[key];
+ }
+ }
+ }
+ }
+ return target;
+ };
+
+ isFunction = function(val) {
+ return !!val && Object.prototype.toString.call(val) === '[object Function]';
+ };
+
+ isObject = function(val) {
+ var ref;
+ return !!val && ((ref = typeof val) === 'function' || ref === 'object');
+ };
+
+ isArray = function(val) {
+ if (isFunction(Array.isArray)) {
+ return Array.isArray(val);
+ } else {
+ return Object.prototype.toString.call(val) === '[object Array]';
+ }
+ };
+
+ isEmpty = function(val) {
+ var key;
+ if (isArray(val)) {
+ return !val.length;
+ } else {
+ for (key in val) {
+ if (!hasProp.call(val, key)) continue;
+ return false;
+ }
+ return true;
+ }
+ };
+
+ isPlainObject = function(val) {
+ var ctor, proto;
+ return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object));
+ };
+
+ module.exports.assign = assign;
+
+ module.exports.isFunction = isFunction;
+
+ module.exports.isObject = isObject;
+
+ module.exports.isArray = isArray;
+
+ module.exports.isEmpty = isEmpty;
+
+ module.exports.isPlainObject = isPlainObject;
+
+}).call(this);
+
+},{}],5:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLAttribute;
+
+ module.exports = XMLAttribute = (function() {
+ function XMLAttribute(parent, name, value) {
+ this.options = parent.options;
+ 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 Object.create(this);
+ };
+
+ XMLAttribute.prototype.toString = function(options) {
+ return this.options.writer.set(options).attribute(this);
+ };
+
+ return XMLAttribute;
+
+ })();
+
+}).call(this);
+
+},{}],6:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLCData, XMLNode,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ 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 Object.create(this);
+ };
+
+ XMLCData.prototype.toString = function(options) {
+ return this.options.writer.set(options).cdata(this);
+ };
+
+ return XMLCData;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./XMLNode":17}],7:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLComment, XMLNode,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ 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 Object.create(this);
+ };
+
+ XMLComment.prototype.toString = function(options) {
+ return this.options.writer.set(options).comment(this);
+ };
+
+ return XMLComment;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./XMLNode":17}],8:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDTDAttList, XMLNode,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLDTDAttList = (function(superClass) {
+ extend(XMLDTDAttList, superClass);
+
+ function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
+ XMLDTDAttList.__super__.constructor.call(this, parent);
+ 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) {
+ return this.options.writer.set(options).dtdAttList(this);
+ };
+
+ return XMLDTDAttList;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./XMLNode":17}],9:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDTDElement, XMLNode,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLDTDElement = (function(superClass) {
+ extend(XMLDTDElement, superClass);
+
+ function XMLDTDElement(parent, name, value) {
+ XMLDTDElement.__super__.constructor.call(this, parent);
+ 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) {
+ return this.options.writer.set(options).dtdElement(this);
+ };
+
+ return XMLDTDElement;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./XMLNode":17}],10:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDTDEntity, XMLNode, 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;
+
+ isObject = require('./Utility').isObject;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLDTDEntity = (function(superClass) {
+ extend(XMLDTDEntity, superClass);
+
+ function XMLDTDEntity(parent, pe, name, value) {
+ XMLDTDEntity.__super__.constructor.call(this, parent);
+ 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) {
+ return this.options.writer.set(options).dtdEntity(this);
+ };
+
+ return XMLDTDEntity;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./Utility":4,"./XMLNode":17}],11:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDTDNotation, XMLNode,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLDTDNotation = (function(superClass) {
+ extend(XMLDTDNotation, superClass);
+
+ function XMLDTDNotation(parent, name, value) {
+ XMLDTDNotation.__super__.constructor.call(this, parent);
+ 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) {
+ return this.options.writer.set(options).dtdNotation(this);
+ };
+
+ return XMLDTDNotation;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./XMLNode":17}],12:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDeclaration, XMLNode, 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;
+
+ isObject = require('./Utility').isObject;
+
+ XMLNode = require('./XMLNode');
+
+ 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) {
+ return this.options.writer.set(options).declaration(this);
+ };
+
+ return XMLDeclaration;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./Utility":4,"./XMLNode":17}],13:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNode, 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;
+
+ isObject = require('./Utility').isObject;
+
+ XMLNode = require('./XMLNode');
+
+ XMLDTDAttList = require('./XMLDTDAttList');
+
+ XMLDTDEntity = require('./XMLDTDEntity');
+
+ XMLDTDElement = require('./XMLDTDElement');
+
+ XMLDTDNotation = require('./XMLDTDNotation');
+
+ module.exports = XMLDocType = (function(superClass) {
+ extend(XMLDocType, superClass);
+
+ function XMLDocType(parent, pubID, sysID) {
+ var ref, ref1;
+ XMLDocType.__super__.constructor.call(this, parent);
+ this.documentObject = parent;
+ 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.toString = function(options) {
+ return this.options.writer.set(options).docType(this);
+ };
+
+ 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.up = function() {
+ return this.root() || this.documentObject;
+ };
+
+ return XMLDocType;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./Utility":4,"./XMLDTDAttList":8,"./XMLDTDElement":9,"./XMLDTDEntity":10,"./XMLDTDNotation":11,"./XMLNode":17}],14:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject,
+ 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;
+
+ isPlainObject = require('./Utility').isPlainObject;
+
+ XMLNode = require('./XMLNode');
+
+ XMLStringifier = require('./XMLStringifier');
+
+ XMLStringWriter = require('./XMLStringWriter');
+
+ module.exports = XMLDocument = (function(superClass) {
+ extend(XMLDocument, superClass);
+
+ function XMLDocument(options) {
+ XMLDocument.__super__.constructor.call(this, null);
+ options || (options = {});
+ if (!options.writer) {
+ options.writer = new XMLStringWriter();
+ }
+ this.options = options;
+ this.stringify = new XMLStringifier(options);
+ this.isDocument = true;
+ }
+
+ XMLDocument.prototype.end = function(writer) {
+ var writerOptions;
+ if (!writer) {
+ writer = this.options.writer;
+ } else if (isPlainObject(writer)) {
+ writerOptions = writer;
+ writer = this.options.writer.set(writerOptions);
+ }
+ return writer.document(this);
+ };
+
+ XMLDocument.prototype.toString = function(options) {
+ return this.options.writer.set(options).document(this);
+ };
+
+ return XMLDocument;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./Utility":4,"./XMLNode":17,"./XMLStringWriter":21,"./XMLStringifier":22}],15:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, isFunction, isObject, isPlainObject, ref,
+ hasProp = {}.hasOwnProperty;
+
+ ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject;
+
+ XMLElement = require('./XMLElement');
+
+ XMLCData = require('./XMLCData');
+
+ XMLComment = require('./XMLComment');
+
+ XMLRaw = require('./XMLRaw');
+
+ XMLText = require('./XMLText');
+
+ XMLProcessingInstruction = require('./XMLProcessingInstruction');
+
+ XMLDeclaration = require('./XMLDeclaration');
+
+ XMLDocType = require('./XMLDocType');
+
+ XMLDTDAttList = require('./XMLDTDAttList');
+
+ XMLDTDEntity = require('./XMLDTDEntity');
+
+ XMLDTDElement = require('./XMLDTDElement');
+
+ XMLDTDNotation = require('./XMLDTDNotation');
+
+ XMLAttribute = require('./XMLAttribute');
+
+ XMLStringifier = require('./XMLStringifier');
+
+ XMLStringWriter = require('./XMLStringWriter');
+
+ module.exports = XMLDocumentCB = (function() {
+ function XMLDocumentCB(options, onData, onEnd) {
+ var writerOptions;
+ options || (options = {});
+ if (!options.writer) {
+ options.writer = new XMLStringWriter(options);
+ } else if (isPlainObject(options.writer)) {
+ writerOptions = options.writer;
+ options.writer = new XMLStringWriter(writerOptions);
+ }
+ this.options = options;
+ this.writer = options.writer;
+ this.stringify = new XMLStringifier(options);
+ this.onDataCallback = onData || function() {};
+ this.onEndCallback = onEnd || function() {};
+ this.currentNode = null;
+ this.currentLevel = -1;
+ this.openTags = {};
+ this.documentStarted = false;
+ this.documentCompleted = false;
+ this.root = null;
+ }
+
+ XMLDocumentCB.prototype.node = function(name, attributes, text) {
+ var ref1;
+ if (name == null) {
+ throw new Error("Missing node name");
+ }
+ if (this.root && this.currentLevel === -1) {
+ throw new Error("Document can only have one root node");
+ }
+ this.openCurrent();
+ name = name.valueOf();
+ if (attributes == null) {
+ attributes = {};
+ }
+ attributes = attributes.valueOf();
+ if (!isObject(attributes)) {
+ ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
+ }
+ this.currentNode = new XMLElement(this, name, attributes);
+ this.currentNode.children = false;
+ this.currentLevel++;
+ this.openTags[this.currentLevel] = this.currentNode;
+ if (text != null) {
+ this.text(text);
+ }
+ return this;
+ };
+
+ XMLDocumentCB.prototype.element = function(name, attributes, text) {
+ if (this.currentNode && this.currentNode instanceof XMLDocType) {
+ return this.dtdElement.apply(this, arguments);
+ } else {
+ return this.node(name, attributes, text);
+ }
+ };
+
+ XMLDocumentCB.prototype.attribute = function(name, value) {
+ var attName, attValue;
+ if (!this.currentNode || this.currentNode.children) {
+ throw new Error("att() can only be used immediately after an ele() call in callback mode");
+ }
+ 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.currentNode.attributes[name] = new XMLAttribute(this, name, value);
+ }
+ }
+ return this;
+ };
+
+ XMLDocumentCB.prototype.text = function(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLText(this, value);
+ this.onData(this.writer.text(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.cdata = function(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLCData(this, value);
+ this.onData(this.writer.cdata(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.comment = function(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLComment(this, value);
+ this.onData(this.writer.comment(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.raw = function(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLRaw(this, value);
+ this.onData(this.writer.raw(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.instruction = function(target, value) {
+ var i, insTarget, insValue, len, node;
+ this.openCurrent();
+ 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();
+ }
+ node = new XMLProcessingInstruction(this, target, value);
+ this.onData(this.writer.processingInstruction(node, this.currentLevel + 1));
+ }
+ return this;
+ };
+
+ XMLDocumentCB.prototype.declaration = function(version, encoding, standalone) {
+ var node;
+ this.openCurrent();
+ if (this.documentStarted) {
+ throw new Error("declaration() must be the first node");
+ }
+ node = new XMLDeclaration(this, version, encoding, standalone);
+ this.onData(this.writer.declaration(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.doctype = function(root, pubID, sysID) {
+ this.openCurrent();
+ if (root == null) {
+ throw new Error("Missing root node name");
+ }
+ if (this.root) {
+ throw new Error("dtd() must come before the root node");
+ }
+ this.currentNode = new XMLDocType(this, pubID, sysID);
+ this.currentNode.rootNodeName = root;
+ this.currentNode.children = false;
+ this.currentLevel++;
+ this.openTags[this.currentLevel] = this.currentNode;
+ return this;
+ };
+
+ XMLDocumentCB.prototype.dtdElement = function(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDElement(this, name, value);
+ this.onData(this.writer.dtdElement(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
+ this.onData(this.writer.dtdAttList(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.entity = function(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDEntity(this, false, name, value);
+ this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.pEntity = function(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDEntity(this, true, name, value);
+ this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.notation = function(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDNotation(this, name, value);
+ this.onData(this.writer.dtdNotation(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.up = function() {
+ if (this.currentLevel < 0) {
+ throw new Error("The document node has no parent");
+ }
+ if (this.currentNode) {
+ if (this.currentNode.children) {
+ this.closeNode(this.currentNode);
+ } else {
+ this.openNode(this.currentNode);
+ }
+ this.currentNode = null;
+ } else {
+ this.closeNode(this.openTags[this.currentLevel]);
+ }
+ delete this.openTags[this.currentLevel];
+ this.currentLevel--;
+ return this;
+ };
+
+ XMLDocumentCB.prototype.end = function() {
+ while (this.currentLevel >= 0) {
+ this.up();
+ }
+ return this.onEnd();
+ };
+
+ XMLDocumentCB.prototype.openCurrent = function() {
+ if (this.currentNode) {
+ this.currentNode.children = true;
+ return this.openNode(this.currentNode);
+ }
+ };
+
+ XMLDocumentCB.prototype.openNode = function(node) {
+ if (!node.isOpen) {
+ if (!this.root && this.currentLevel === 0 && node instanceof XMLElement) {
+ this.root = node;
+ }
+ this.onData(this.writer.openNode(node, this.currentLevel));
+ return node.isOpen = true;
+ }
+ };
+
+ XMLDocumentCB.prototype.closeNode = function(node) {
+ if (!node.isClosed) {
+ this.onData(this.writer.closeNode(node, this.currentLevel));
+ return node.isClosed = true;
+ }
+ };
+
+ XMLDocumentCB.prototype.onData = function(chunk) {
+ this.documentStarted = true;
+ return this.onDataCallback(chunk);
+ };
+
+ XMLDocumentCB.prototype.onEnd = function() {
+ this.documentCompleted = true;
+ return this.onEndCallback();
+ };
+
+ XMLDocumentCB.prototype.ele = function() {
+ return this.element.apply(this, arguments);
+ };
+
+ XMLDocumentCB.prototype.nod = function(name, attributes, text) {
+ return this.node(name, attributes, text);
+ };
+
+ XMLDocumentCB.prototype.txt = function(value) {
+ return this.text(value);
+ };
+
+ XMLDocumentCB.prototype.dat = function(value) {
+ return this.cdata(value);
+ };
+
+ XMLDocumentCB.prototype.com = function(value) {
+ return this.comment(value);
+ };
+
+ XMLDocumentCB.prototype.ins = function(target, value) {
+ return this.instruction(target, value);
+ };
+
+ XMLDocumentCB.prototype.dec = function(version, encoding, standalone) {
+ return this.declaration(version, encoding, standalone);
+ };
+
+ XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) {
+ return this.doctype(root, pubID, sysID);
+ };
+
+ XMLDocumentCB.prototype.e = function(name, attributes, text) {
+ return this.element(name, attributes, text);
+ };
+
+ XMLDocumentCB.prototype.n = function(name, attributes, text) {
+ return this.node(name, attributes, text);
+ };
+
+ XMLDocumentCB.prototype.t = function(value) {
+ return this.text(value);
+ };
+
+ XMLDocumentCB.prototype.d = function(value) {
+ return this.cdata(value);
+ };
+
+ XMLDocumentCB.prototype.c = function(value) {
+ return this.comment(value);
+ };
+
+ XMLDocumentCB.prototype.r = function(value) {
+ return this.raw(value);
+ };
+
+ XMLDocumentCB.prototype.i = function(target, value) {
+ return this.instruction(target, value);
+ };
+
+ XMLDocumentCB.prototype.att = function() {
+ if (this.currentNode && this.currentNode instanceof XMLDocType) {
+ return this.attList.apply(this, arguments);
+ } else {
+ return this.attribute.apply(this, arguments);
+ }
+ };
+
+ XMLDocumentCB.prototype.a = function() {
+ if (this.currentNode && this.currentNode instanceof XMLDocType) {
+ return this.attList.apply(this, arguments);
+ } else {
+ return this.attribute.apply(this, arguments);
+ }
+ };
+
+ XMLDocumentCB.prototype.ent = function(name, value) {
+ return this.entity(name, value);
+ };
+
+ XMLDocumentCB.prototype.pent = function(name, value) {
+ return this.pEntity(name, value);
+ };
+
+ XMLDocumentCB.prototype.not = function(name, value) {
+ return this.notation(name, value);
+ };
+
+ return XMLDocumentCB;
+
+ })();
+
+}).call(this);
+
+},{"./Utility":4,"./XMLAttribute":5,"./XMLCData":6,"./XMLComment":7,"./XMLDTDAttList":8,"./XMLDTDElement":9,"./XMLDTDEntity":10,"./XMLDTDNotation":11,"./XMLDeclaration":12,"./XMLDocType":13,"./XMLElement":16,"./XMLProcessingInstruction":18,"./XMLRaw":19,"./XMLStringWriter":21,"./XMLStringifier":22,"./XMLText":23}],16:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLAttribute, XMLElement, XMLNode, isFunction, isObject, ref,
+ 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;
+
+ ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction;
+
+ XMLNode = require('./XMLNode');
+
+ XMLAttribute = require('./XMLAttribute');
+
+ 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.attributes = {};
+ if (attributes != null) {
+ this.attribute(attributes);
+ }
+ if (parent.isDocument) {
+ this.isRoot = true;
+ this.documentObject = parent;
+ parent.rootObject = this;
+ }
+ }
+
+ XMLElement.prototype.clone = function() {
+ var att, attName, clonedSelf, ref1;
+ clonedSelf = Object.create(this);
+ if (clonedSelf.isRoot) {
+ clonedSelf.documentObject = null;
+ }
+ clonedSelf.attributes = {};
+ ref1 = this.attributes;
+ for (attName in ref1) {
+ if (!hasProp.call(ref1, attName)) continue;
+ att = ref1[attName];
+ clonedSelf.attributes[attName] = att.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.toString = function(options) {
+ return this.options.writer.set(options).element(this);
+ };
+
+ XMLElement.prototype.att = function(name, value) {
+ return this.attribute(name, value);
+ };
+
+ XMLElement.prototype.a = function(name, value) {
+ return this.attribute(name, value);
+ };
+
+ return XMLElement;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./Utility":4,"./XMLAttribute":5,"./XMLNode":17}],17:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLElement, XMLNode, XMLProcessingInstruction, XMLRaw, XMLText, isEmpty, isFunction, isObject, ref,
+ hasProp = {}.hasOwnProperty;
+
+ ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isEmpty = ref.isEmpty;
+
+ XMLElement = null;
+
+ XMLCData = null;
+
+ XMLComment = null;
+
+ XMLDeclaration = null;
+
+ XMLDocType = null;
+
+ XMLRaw = null;
+
+ XMLText = null;
+
+ XMLProcessingInstruction = null;
+
+ module.exports = XMLNode = (function() {
+ function XMLNode(parent) {
+ this.parent = parent;
+ if (this.parent) {
+ this.options = this.parent.options;
+ this.stringify = this.parent.stringify;
+ }
+ this.children = [];
+ if (!XMLElement) {
+ XMLElement = require('./XMLElement');
+ XMLCData = require('./XMLCData');
+ XMLComment = require('./XMLComment');
+ XMLDeclaration = require('./XMLDeclaration');
+ XMLDocType = require('./XMLDocType');
+ XMLRaw = require('./XMLRaw');
+ XMLText = require('./XMLText');
+ XMLProcessingInstruction = require('./XMLProcessingInstruction');
+ }
+ }
+
+ XMLNode.prototype.element = function(name, attributes, text) {
+ var childNode, item, j, k, key, lastChild, len, len1, ref1, val;
+ lastChild = null;
+ if (attributes == null) {
+ attributes = {};
+ }
+ attributes = attributes.valueOf();
+ if (!isObject(attributes)) {
+ ref1 = [attributes, text], text = ref1[0], attributes = ref1[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.separateArrayItems && 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 if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
+ lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), 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, ref1;
+ 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(ref1 = [])), ref1;
+ return this.parent;
+ };
+
+ XMLNode.prototype.node = function(name, attributes, text) {
+ var child, ref1;
+ if (name != null) {
+ name = name.valueOf();
+ }
+ attributes || (attributes = {});
+ attributes = attributes.valueOf();
+ if (!isObject(attributes)) {
+ ref1 = [attributes, text], text = ref1[0], attributes = ref1[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.commentBefore = function(value) {
+ var child, i, removed;
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i);
+ child = this.parent.comment(value);
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ };
+
+ XMLNode.prototype.commentAfter = function(value) {
+ var child, i, removed;
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i + 1);
+ child = this.parent.comment(value);
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ };
+
+ XMLNode.prototype.raw = function(value) {
+ var child;
+ child = new XMLRaw(this, value);
+ this.children.push(child);
+ return this;
+ };
+
+ XMLNode.prototype.instruction = function(target, value) {
+ var insTarget, insValue, instruction, j, len;
+ if (target != null) {
+ target = target.valueOf();
+ }
+ if (value != null) {
+ value = value.valueOf();
+ }
+ if (Array.isArray(target)) {
+ for (j = 0, len = target.length; j < len; j++) {
+ insTarget = target[j];
+ 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.children.push(instruction);
+ }
+ return this;
+ };
+
+ XMLNode.prototype.instructionBefore = function(target, value) {
+ var child, i, removed;
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i);
+ child = this.parent.instruction(target, value);
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ };
+
+ XMLNode.prototype.instructionAfter = function(target, value) {
+ var child, i, removed;
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i + 1);
+ child = this.parent.instruction(target, value);
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ };
+
+ XMLNode.prototype.declaration = function(version, encoding, standalone) {
+ var doc, xmldec;
+ doc = this.document();
+ xmldec = new XMLDeclaration(doc, version, encoding, standalone);
+ if (doc.children[0] instanceof XMLDeclaration) {
+ doc.children[0] = xmldec;
+ } else {
+ doc.children.unshift(xmldec);
+ }
+ return doc.root() || doc;
+ };
+
+ XMLNode.prototype.doctype = function(pubID, sysID) {
+ var child, doc, doctype, i, j, k, len, len1, ref1, ref2;
+ doc = this.document();
+ doctype = new XMLDocType(doc, pubID, sysID);
+ ref1 = doc.children;
+ for (i = j = 0, len = ref1.length; j < len; i = ++j) {
+ child = ref1[i];
+ if (child instanceof XMLDocType) {
+ doc.children[i] = doctype;
+ return doctype;
+ }
+ }
+ ref2 = doc.children;
+ for (i = k = 0, len1 = ref2.length; k < len1; i = ++k) {
+ child = ref2[i];
+ if (child.isRoot) {
+ doc.children.splice(i, 0, doctype);
+ return doctype;
+ }
+ }
+ doc.children.push(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 node;
+ node = this;
+ while (node) {
+ if (node.isDocument) {
+ return node.rootObject;
+ } else if (node.isRoot) {
+ return node;
+ } else {
+ node = node.parent;
+ }
+ }
+ };
+
+ XMLNode.prototype.document = function() {
+ var node;
+ node = this;
+ while (node) {
+ if (node.isDocument) {
+ return node;
+ } else {
+ node = node.parent;
+ }
+ }
+ };
+
+ XMLNode.prototype.end = function(options) {
+ return this.document().end(options);
+ };
+
+ XMLNode.prototype.prev = function() {
+ var i;
+ 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;
+ 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.importDocument = function(doc) {
+ var clonedRoot;
+ clonedRoot = doc.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.ins = function(target, value) {
+ return this.instruction(target, 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.i = function(target, value) {
+ return this.instruction(target, value);
+ };
+
+ XMLNode.prototype.u = function() {
+ return this.up();
+ };
+
+ XMLNode.prototype.importXMLBuilder = function(doc) {
+ return this.importDocument(doc);
+ };
+
+ return XMLNode;
+
+ })();
+
+}).call(this);
+
+},{"./Utility":4,"./XMLCData":6,"./XMLComment":7,"./XMLDeclaration":12,"./XMLDocType":13,"./XMLElement":16,"./XMLProcessingInstruction":18,"./XMLRaw":19,"./XMLText":23}],18:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLNode, XMLProcessingInstruction,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLProcessingInstruction = (function(superClass) {
+ extend(XMLProcessingInstruction, superClass);
+
+ function XMLProcessingInstruction(parent, target, value) {
+ XMLProcessingInstruction.__super__.constructor.call(this, parent);
+ 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 Object.create(this);
+ };
+
+ XMLProcessingInstruction.prototype.toString = function(options) {
+ return this.options.writer.set(options).processingInstruction(this);
+ };
+
+ return XMLProcessingInstruction;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./XMLNode":17}],19:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLNode, XMLRaw,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ 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 Object.create(this);
+ };
+
+ XMLRaw.prototype.toString = function(options) {
+ return this.options.writer.set(options).raw(this);
+ };
+
+ return XMLRaw;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./XMLNode":17}],20:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStreamWriter, XMLText, XMLWriterBase,
+ 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;
+
+ XMLDeclaration = require('./XMLDeclaration');
+
+ XMLDocType = require('./XMLDocType');
+
+ XMLCData = require('./XMLCData');
+
+ XMLComment = require('./XMLComment');
+
+ XMLElement = require('./XMLElement');
+
+ XMLRaw = require('./XMLRaw');
+
+ XMLText = require('./XMLText');
+
+ XMLProcessingInstruction = require('./XMLProcessingInstruction');
+
+ XMLDTDAttList = require('./XMLDTDAttList');
+
+ XMLDTDElement = require('./XMLDTDElement');
+
+ XMLDTDEntity = require('./XMLDTDEntity');
+
+ XMLDTDNotation = require('./XMLDTDNotation');
+
+ XMLWriterBase = require('./XMLWriterBase');
+
+ module.exports = XMLStreamWriter = (function(superClass) {
+ extend(XMLStreamWriter, superClass);
+
+ function XMLStreamWriter(stream, options) {
+ XMLStreamWriter.__super__.constructor.call(this, options);
+ this.stream = stream;
+ }
+
+ XMLStreamWriter.prototype.document = function(doc) {
+ var child, i, j, len, len1, ref, ref1, results;
+ ref = doc.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ child.isLastRootNode = false;
+ }
+ doc.children[doc.children.length - 1].isLastRootNode = true;
+ ref1 = doc.children;
+ results = [];
+ for (j = 0, len1 = ref1.length; j < len1; j++) {
+ child = ref1[j];
+ switch (false) {
+ case !(child instanceof XMLDeclaration):
+ results.push(this.declaration(child));
+ break;
+ case !(child instanceof XMLDocType):
+ results.push(this.docType(child));
+ break;
+ case !(child instanceof XMLComment):
+ results.push(this.comment(child));
+ break;
+ case !(child instanceof XMLProcessingInstruction):
+ results.push(this.processingInstruction(child));
+ break;
+ default:
+ results.push(this.element(child));
+ }
+ }
+ return results;
+ };
+
+ XMLStreamWriter.prototype.attribute = function(att) {
+ return this.stream.write(' ' + att.name + '="' + att.value + '"');
+ };
+
+ XMLStreamWriter.prototype.cdata = function(node, level) {
+ return this.stream.write(this.space(level) + '<![CDATA[' + node.text + ']]>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.comment = function(node, level) {
+ return this.stream.write(this.space(level) + '<!-- ' + node.text + ' -->' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.declaration = function(node, level) {
+ this.stream.write(this.space(level));
+ this.stream.write('<?xml version="' + node.version + '"');
+ if (node.encoding != null) {
+ this.stream.write(' encoding="' + node.encoding + '"');
+ }
+ if (node.standalone != null) {
+ this.stream.write(' standalone="' + node.standalone + '"');
+ }
+ this.stream.write(this.spacebeforeslash + '?>');
+ return this.stream.write(this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.docType = function(node, level) {
+ var child, i, len, ref;
+ level || (level = 0);
+ this.stream.write(this.space(level));
+ this.stream.write('<!DOCTYPE ' + node.root().name);
+ if (node.pubID && node.sysID) {
+ this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
+ } else if (node.sysID) {
+ this.stream.write(' SYSTEM "' + node.sysID + '"');
+ }
+ if (node.children.length > 0) {
+ this.stream.write(' [');
+ this.stream.write(this.endline(node));
+ ref = node.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ switch (false) {
+ case !(child instanceof XMLDTDAttList):
+ this.dtdAttList(child, level + 1);
+ break;
+ case !(child instanceof XMLDTDElement):
+ this.dtdElement(child, level + 1);
+ break;
+ case !(child instanceof XMLDTDEntity):
+ this.dtdEntity(child, level + 1);
+ break;
+ case !(child instanceof XMLDTDNotation):
+ this.dtdNotation(child, level + 1);
+ break;
+ case !(child instanceof XMLCData):
+ this.cdata(child, level + 1);
+ break;
+ case !(child instanceof XMLComment):
+ this.comment(child, level + 1);
+ break;
+ case !(child instanceof XMLProcessingInstruction):
+ this.processingInstruction(child, level + 1);
+ break;
+ default:
+ throw new Error("Unknown DTD node type: " + child.constructor.name);
+ }
+ }
+ this.stream.write(']');
+ }
+ this.stream.write(this.spacebeforeslash + '>');
+ return this.stream.write(this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.element = function(node, level) {
+ var att, child, i, len, name, ref, ref1, space;
+ level || (level = 0);
+ space = this.space(level);
+ this.stream.write(space + '<' + node.name);
+ ref = node.attributes;
+ for (name in ref) {
+ if (!hasProp.call(ref, name)) continue;
+ att = ref[name];
+ this.attribute(att);
+ }
+ if (node.children.length === 0 || node.children.every(function(e) {
+ return e.value === '';
+ })) {
+ if (this.allowEmpty) {
+ this.stream.write('></' + node.name + '>');
+ } else {
+ this.stream.write(this.spacebeforeslash + '/>');
+ }
+ } else if (this.pretty && node.children.length === 1 && (node.children[0].value != null)) {
+ this.stream.write('>');
+ this.stream.write(node.children[0].value);
+ this.stream.write('</' + node.name + '>');
+ } else {
+ this.stream.write('>' + this.newline);
+ ref1 = node.children;
+ for (i = 0, len = ref1.length; i < len; i++) {
+ child = ref1[i];
+ switch (false) {
+ case !(child instanceof XMLCData):
+ this.cdata(child, level + 1);
+ break;
+ case !(child instanceof XMLComment):
+ this.comment(child, level + 1);
+ break;
+ case !(child instanceof XMLElement):
+ this.element(child, level + 1);
+ break;
+ case !(child instanceof XMLRaw):
+ this.raw(child, level + 1);
+ break;
+ case !(child instanceof XMLText):
+ this.text(child, level + 1);
+ break;
+ case !(child instanceof XMLProcessingInstruction):
+ this.processingInstruction(child, level + 1);
+ break;
+ default:
+ throw new Error("Unknown XML node type: " + child.constructor.name);
+ }
+ }
+ this.stream.write(space + '</' + node.name + '>');
+ }
+ return this.stream.write(this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.processingInstruction = function(node, level) {
+ this.stream.write(this.space(level) + '<?' + node.target);
+ if (node.value) {
+ this.stream.write(' ' + node.value);
+ }
+ return this.stream.write(this.spacebeforeslash + '?>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.raw = function(node, level) {
+ return this.stream.write(this.space(level) + node.value + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.text = function(node, level) {
+ return this.stream.write(this.space(level) + node.value + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.dtdAttList = function(node, level) {
+ this.stream.write(this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType);
+ if (node.defaultValueType !== '#DEFAULT') {
+ this.stream.write(' ' + node.defaultValueType);
+ }
+ if (node.defaultValue) {
+ this.stream.write(' "' + node.defaultValue + '"');
+ }
+ return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.dtdElement = function(node, level) {
+ this.stream.write(this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value);
+ return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.dtdEntity = function(node, level) {
+ this.stream.write(this.space(level) + '<!ENTITY');
+ if (node.pe) {
+ this.stream.write(' %');
+ }
+ this.stream.write(' ' + node.name);
+ if (node.value) {
+ this.stream.write(' "' + node.value + '"');
+ } else {
+ if (node.pubID && node.sysID) {
+ this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
+ } else if (node.sysID) {
+ this.stream.write(' SYSTEM "' + node.sysID + '"');
+ }
+ if (node.nData) {
+ this.stream.write(' NDATA ' + node.nData);
+ }
+ }
+ return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.dtdNotation = function(node, level) {
+ this.stream.write(this.space(level) + '<!NOTATION ' + node.name);
+ if (node.pubID && node.sysID) {
+ this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
+ } else if (node.pubID) {
+ this.stream.write(' PUBLIC "' + node.pubID + '"');
+ } else if (node.sysID) {
+ this.stream.write(' SYSTEM "' + node.sysID + '"');
+ }
+ return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.endline = function(node) {
+ if (!node.isLastRootNode) {
+ return this.newline;
+ } else {
+ return '';
+ }
+ };
+
+ return XMLStreamWriter;
+
+ })(XMLWriterBase);
+
+}).call(this);
+
+},{"./XMLCData":6,"./XMLComment":7,"./XMLDTDAttList":8,"./XMLDTDElement":9,"./XMLDTDEntity":10,"./XMLDTDNotation":11,"./XMLDeclaration":12,"./XMLDocType":13,"./XMLElement":16,"./XMLProcessingInstruction":18,"./XMLRaw":19,"./XMLText":23,"./XMLWriterBase":24}],21:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLText, XMLWriterBase,
+ 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;
+
+ XMLDeclaration = require('./XMLDeclaration');
+
+ XMLDocType = require('./XMLDocType');
+
+ XMLCData = require('./XMLCData');
+
+ XMLComment = require('./XMLComment');
+
+ XMLElement = require('./XMLElement');
+
+ XMLRaw = require('./XMLRaw');
+
+ XMLText = require('./XMLText');
+
+ XMLProcessingInstruction = require('./XMLProcessingInstruction');
+
+ XMLDTDAttList = require('./XMLDTDAttList');
+
+ XMLDTDElement = require('./XMLDTDElement');
+
+ XMLDTDEntity = require('./XMLDTDEntity');
+
+ XMLDTDNotation = require('./XMLDTDNotation');
+
+ XMLWriterBase = require('./XMLWriterBase');
+
+ module.exports = XMLStringWriter = (function(superClass) {
+ extend(XMLStringWriter, superClass);
+
+ function XMLStringWriter(options) {
+ XMLStringWriter.__super__.constructor.call(this, options);
+ }
+
+ XMLStringWriter.prototype.document = function(doc) {
+ var child, i, len, r, ref;
+ this.textispresent = false;
+ r = '';
+ ref = doc.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ r += (function() {
+ switch (false) {
+ case !(child instanceof XMLDeclaration):
+ return this.declaration(child);
+ case !(child instanceof XMLDocType):
+ return this.docType(child);
+ case !(child instanceof XMLComment):
+ return this.comment(child);
+ case !(child instanceof XMLProcessingInstruction):
+ return this.processingInstruction(child);
+ default:
+ return this.element(child, 0);
+ }
+ }).call(this);
+ }
+ if (this.pretty && r.slice(-this.newline.length) === this.newline) {
+ r = r.slice(0, -this.newline.length);
+ }
+ return r;
+ };
+
+ XMLStringWriter.prototype.attribute = function(att) {
+ return ' ' + att.name + '="' + att.value + '"';
+ };
+
+ XMLStringWriter.prototype.cdata = function(node, level) {
+ return this.space(level) + '<![CDATA[' + node.text + ']]>' + this.newline;
+ };
+
+ XMLStringWriter.prototype.comment = function(node, level) {
+ return this.space(level) + '<!-- ' + node.text + ' -->' + this.newline;
+ };
+
+ XMLStringWriter.prototype.declaration = function(node, level) {
+ var r;
+ r = this.space(level);
+ r += '<?xml version="' + node.version + '"';
+ if (node.encoding != null) {
+ r += ' encoding="' + node.encoding + '"';
+ }
+ if (node.standalone != null) {
+ r += ' standalone="' + node.standalone + '"';
+ }
+ r += this.spacebeforeslash + '?>';
+ r += this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.docType = function(node, level) {
+ var child, i, len, r, ref;
+ level || (level = 0);
+ r = this.space(level);
+ r += '<!DOCTYPE ' + node.root().name;
+ if (node.pubID && node.sysID) {
+ r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
+ } else if (node.sysID) {
+ r += ' SYSTEM "' + node.sysID + '"';
+ }
+ if (node.children.length > 0) {
+ r += ' [';
+ r += this.newline;
+ ref = node.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ r += (function() {
+ switch (false) {
+ case !(child instanceof XMLDTDAttList):
+ return this.dtdAttList(child, level + 1);
+ case !(child instanceof XMLDTDElement):
+ return this.dtdElement(child, level + 1);
+ case !(child instanceof XMLDTDEntity):
+ return this.dtdEntity(child, level + 1);
+ case !(child instanceof XMLDTDNotation):
+ return this.dtdNotation(child, level + 1);
+ case !(child instanceof XMLCData):
+ return this.cdata(child, level + 1);
+ case !(child instanceof XMLComment):
+ return this.comment(child, level + 1);
+ case !(child instanceof XMLProcessingInstruction):
+ return this.processingInstruction(child, level + 1);
+ default:
+ throw new Error("Unknown DTD node type: " + child.constructor.name);
+ }
+ }).call(this);
+ }
+ r += ']';
+ }
+ r += this.spacebeforeslash + '>';
+ r += this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.element = function(node, level) {
+ var att, child, i, j, len, len1, name, r, ref, ref1, ref2, space, textispresentwasset;
+ level || (level = 0);
+ textispresentwasset = false;
+ if (this.textispresent) {
+ this.newline = '';
+ this.pretty = false;
+ } else {
+ this.newline = this.newlinedefault;
+ this.pretty = this.prettydefault;
+ }
+ space = this.space(level);
+ r = '';
+ r += space + '<' + node.name;
+ ref = node.attributes;
+ for (name in ref) {
+ if (!hasProp.call(ref, name)) continue;
+ att = ref[name];
+ r += this.attribute(att);
+ }
+ if (node.children.length === 0 || node.children.every(function(e) {
+ return e.value === '';
+ })) {
+ if (this.allowEmpty) {
+ r += '></' + node.name + '>' + this.newline;
+ } else {
+ r += this.spacebeforeslash + '/>' + this.newline;
+ }
+ } else if (this.pretty && node.children.length === 1 && (node.children[0].value != null)) {
+ r += '>';
+ r += node.children[0].value;
+ r += '</' + node.name + '>' + this.newline;
+ } else {
+ if (this.dontprettytextnodes) {
+ ref1 = node.children;
+ for (i = 0, len = ref1.length; i < len; i++) {
+ child = ref1[i];
+ if (child.value != null) {
+ this.textispresent++;
+ textispresentwasset = true;
+ break;
+ }
+ }
+ }
+ if (this.textispresent) {
+ this.newline = '';
+ this.pretty = false;
+ space = this.space(level);
+ }
+ r += '>' + this.newline;
+ ref2 = node.children;
+ for (j = 0, len1 = ref2.length; j < len1; j++) {
+ child = ref2[j];
+ r += (function() {
+ switch (false) {
+ case !(child instanceof XMLCData):
+ return this.cdata(child, level + 1);
+ case !(child instanceof XMLComment):
+ return this.comment(child, level + 1);
+ case !(child instanceof XMLElement):
+ return this.element(child, level + 1);
+ case !(child instanceof XMLRaw):
+ return this.raw(child, level + 1);
+ case !(child instanceof XMLText):
+ return this.text(child, level + 1);
+ case !(child instanceof XMLProcessingInstruction):
+ return this.processingInstruction(child, level + 1);
+ default:
+ throw new Error("Unknown XML node type: " + child.constructor.name);
+ }
+ }).call(this);
+ }
+ if (textispresentwasset) {
+ this.textispresent--;
+ }
+ if (!this.textispresent) {
+ this.newline = this.newlinedefault;
+ this.pretty = this.prettydefault;
+ }
+ r += space + '</' + node.name + '>' + this.newline;
+ }
+ return r;
+ };
+
+ XMLStringWriter.prototype.processingInstruction = function(node, level) {
+ var r;
+ r = this.space(level) + '<?' + node.target;
+ if (node.value) {
+ r += ' ' + node.value;
+ }
+ r += this.spacebeforeslash + '?>' + this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.raw = function(node, level) {
+ return this.space(level) + node.value + this.newline;
+ };
+
+ XMLStringWriter.prototype.text = function(node, level) {
+ return this.space(level) + node.value + this.newline;
+ };
+
+ XMLStringWriter.prototype.dtdAttList = function(node, level) {
+ var r;
+ r = this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType;
+ if (node.defaultValueType !== '#DEFAULT') {
+ r += ' ' + node.defaultValueType;
+ }
+ if (node.defaultValue) {
+ r += ' "' + node.defaultValue + '"';
+ }
+ r += this.spacebeforeslash + '>' + this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.dtdElement = function(node, level) {
+ return this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value + this.spacebeforeslash + '>' + this.newline;
+ };
+
+ XMLStringWriter.prototype.dtdEntity = function(node, level) {
+ var r;
+ r = this.space(level) + '<!ENTITY';
+ if (node.pe) {
+ r += ' %';
+ }
+ r += ' ' + node.name;
+ if (node.value) {
+ r += ' "' + node.value + '"';
+ } else {
+ if (node.pubID && node.sysID) {
+ r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
+ } else if (node.sysID) {
+ r += ' SYSTEM "' + node.sysID + '"';
+ }
+ if (node.nData) {
+ r += ' NDATA ' + node.nData;
+ }
+ }
+ r += this.spacebeforeslash + '>' + this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.dtdNotation = function(node, level) {
+ var r;
+ r = this.space(level) + '<!NOTATION ' + node.name;
+ if (node.pubID && node.sysID) {
+ r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
+ } else if (node.pubID) {
+ r += ' PUBLIC "' + node.pubID + '"';
+ } else if (node.sysID) {
+ r += ' SYSTEM "' + node.sysID + '"';
+ }
+ r += this.spacebeforeslash + '>' + this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.openNode = function(node, level) {
+ var att, name, r, ref;
+ level || (level = 0);
+ if (node instanceof XMLElement) {
+ r = this.space(level) + '<' + node.name;
+ ref = node.attributes;
+ for (name in ref) {
+ if (!hasProp.call(ref, name)) continue;
+ att = ref[name];
+ r += this.attribute(att);
+ }
+ r += (node.children ? '>' : '/>') + this.newline;
+ return r;
+ } else {
+ r = this.space(level) + '<!DOCTYPE ' + node.rootNodeName;
+ if (node.pubID && node.sysID) {
+ r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
+ } else if (node.sysID) {
+ r += ' SYSTEM "' + node.sysID + '"';
+ }
+ r += (node.children ? ' [' : '>') + this.newline;
+ return r;
+ }
+ };
+
+ XMLStringWriter.prototype.closeNode = function(node, level) {
+ level || (level = 0);
+ switch (false) {
+ case !(node instanceof XMLElement):
+ return this.space(level) + '</' + node.name + '>' + this.newline;
+ case !(node instanceof XMLDocType):
+ return this.space(level) + ']>' + this.newline;
+ }
+ };
+
+ return XMLStringWriter;
+
+ })(XMLWriterBase);
+
+}).call(this);
+
+},{"./XMLCData":6,"./XMLComment":7,"./XMLDTDAttList":8,"./XMLDTDElement":9,"./XMLDTDEntity":10,"./XMLDTDNotation":11,"./XMLDeclaration":12,"./XMLDocType":13,"./XMLElement":16,"./XMLProcessingInstruction":18,"./XMLRaw":19,"./XMLText":23,"./XMLWriterBase":24}],22:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(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;
+ options || (options = {});
+ this.noDoubleEncoding = options.noDoubleEncoding;
+ ref = options.stringify || {};
+ 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 || '';
+ val = val.replace(']]>', ']]]]><![CDATA[>');
+ 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 = '' + 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 res;
+ res = str.match(/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/);
+ if (res) {
+ throw new Error("Invalid character in string: " + str + " at index " + res.index);
+ }
+ return str;
+ };
+
+ XMLStringifier.prototype.elEscape = function(str) {
+ var ampregex;
+ ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
+ return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\r/g, '&#xD;');
+ };
+
+ XMLStringifier.prototype.attEscape = function(str) {
+ var ampregex;
+ ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
+ return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/\t/g, '&#x9;').replace(/\n/g, '&#xA;').replace(/\r/g, '&#xD;');
+ };
+
+ return XMLStringifier;
+
+ })();
+
+}).call(this);
+
+},{}],23:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLNode, XMLText,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLText = (function(superClass) {
+ extend(XMLText, superClass);
+
+ function XMLText(parent, text) {
+ XMLText.__super__.constructor.call(this, parent);
+ if (text == null) {
+ throw new Error("Missing element text");
+ }
+ this.value = this.stringify.eleText(text);
+ }
+
+ XMLText.prototype.clone = function() {
+ return Object.create(this);
+ };
+
+ XMLText.prototype.toString = function(options) {
+ return this.options.writer.set(options).text(this);
+ };
+
+ return XMLText;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./XMLNode":17}],24:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLWriterBase,
+ hasProp = {}.hasOwnProperty;
+
+ module.exports = XMLWriterBase = (function() {
+ function XMLWriterBase(options) {
+ var key, ref, ref1, ref2, ref3, ref4, ref5, ref6, value;
+ options || (options = {});
+ this.pretty = options.pretty || false;
+ this.allowEmpty = (ref = options.allowEmpty) != null ? ref : false;
+ if (this.pretty) {
+ this.indent = (ref1 = options.indent) != null ? ref1 : ' ';
+ this.newline = (ref2 = options.newline) != null ? ref2 : '\n';
+ this.offset = (ref3 = options.offset) != null ? ref3 : 0;
+ this.dontprettytextnodes = (ref4 = options.dontprettytextnodes) != null ? ref4 : 0;
+ } else {
+ this.indent = '';
+ this.newline = '';
+ this.offset = 0;
+ this.dontprettytextnodes = 0;
+ }
+ this.spacebeforeslash = (ref5 = options.spacebeforeslash) != null ? ref5 : '';
+ if (this.spacebeforeslash === true) {
+ this.spacebeforeslash = ' ';
+ }
+ this.newlinedefault = this.newline;
+ this.prettydefault = this.pretty;
+ ref6 = options.writer || {};
+ for (key in ref6) {
+ if (!hasProp.call(ref6, key)) continue;
+ value = ref6[key];
+ this[key] = value;
+ }
+ }
+
+ XMLWriterBase.prototype.set = function(options) {
+ var key, ref, value;
+ options || (options = {});
+ if ("pretty" in options) {
+ this.pretty = options.pretty;
+ }
+ if ("allowEmpty" in options) {
+ this.allowEmpty = options.allowEmpty;
+ }
+ if (this.pretty) {
+ this.indent = "indent" in options ? options.indent : ' ';
+ this.newline = "newline" in options ? options.newline : '\n';
+ this.offset = "offset" in options ? options.offset : 0;
+ this.dontprettytextnodes = "dontprettytextnodes" in options ? options.dontprettytextnodes : 0;
+ } else {
+ this.indent = '';
+ this.newline = '';
+ this.offset = 0;
+ this.dontprettytextnodes = 0;
+ }
+ this.spacebeforeslash = "spacebeforeslash" in options ? options.spacebeforeslash : '';
+ if (this.spacebeforeslash === true) {
+ this.spacebeforeslash = ' ';
+ }
+ this.newlinedefault = this.newline;
+ this.prettydefault = this.pretty;
+ ref = options.writer || {};
+ for (key in ref) {
+ if (!hasProp.call(ref, key)) continue;
+ value = ref[key];
+ this[key] = value;
+ }
+ return this;
+ };
+
+ XMLWriterBase.prototype.space = function(level) {
+ var indent;
+ if (this.pretty) {
+ indent = (level || 0) + this.offset + 1;
+ if (indent > 0) {
+ return new Array(indent).join(this.indent);
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ };
+
+ return XMLWriterBase;
+
+ })();
+
+}).call(this);
+
+},{}],25:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
+
+ ref = require('./Utility'), assign = ref.assign, isFunction = ref.isFunction;
+
+ XMLDocument = require('./XMLDocument');
+
+ XMLDocumentCB = require('./XMLDocumentCB');
+
+ XMLStringWriter = require('./XMLStringWriter');
+
+ XMLStreamWriter = require('./XMLStreamWriter');
+
+ module.exports.create = function(name, xmldec, doctype, options) {
+ var doc, root;
+ if (name == null) {
+ throw new Error("Root element needs a name");
+ }
+ options = assign({}, xmldec, doctype, options);
+ doc = new XMLDocument(options);
+ root = doc.element(name);
+ if (!options.headless) {
+ doc.declaration(options);
+ if ((options.pubID != null) || (options.sysID != null)) {
+ doc.doctype(options);
+ }
+ }
+ return root;
+ };
+
+ module.exports.begin = function(options, onData, onEnd) {
+ var ref1;
+ if (isFunction(options)) {
+ ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
+ options = {};
+ }
+ if (onData) {
+ return new XMLDocumentCB(options, onData, onEnd);
+ } else {
+ return new XMLDocument(options);
+ }
+ };
+
+ module.exports.stringWriter = function(options) {
+ return new XMLStringWriter(options);
+ };
+
+ module.exports.streamWriter = function(stream, options) {
+ return new XMLStreamWriter(stream, options);
+ };
+
+}).call(this);
+
+},{"./Utility":4,"./XMLDocument":14,"./XMLDocumentCB":15,"./XMLStreamWriter":20,"./XMLStringWriter":21}]},{},[1])(1)
+});
diff --git a/cordova/node_modules/ios-sim/node_modules/plist/dist/plist-parse.js b/cordova/node_modules/ios-sim/node_modules/plist/dist/plist-parse.js
new file mode 100644
index 0000000..f3710fd
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/plist/dist/plist-parse.js
@@ -0,0 +1,4297 @@
+(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.plist = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
+(function (Buffer){
+/**
+ * Module dependencies.
+ */
+
+var DOMParser = require('xmldom').DOMParser;
+
+/**
+ * Module exports.
+ */
+
+exports.parse = parse;
+
+var TEXT_NODE = 3;
+var CDATA_NODE = 4;
+var COMMENT_NODE = 8;
+
+
+/**
+ * We ignore raw text (usually whitespace), <!-- xml comments -->,
+ * and raw CDATA nodes.
+ *
+ * @param {Element} node
+ * @returns {Boolean}
+ * @api private
+ */
+
+function shouldIgnoreNode (node) {
+ return node.nodeType === TEXT_NODE
+ || node.nodeType === COMMENT_NODE
+ || node.nodeType === CDATA_NODE;
+}
+
+/**
+ * Check if the node is empty. Some plist file has such node:
+ * <key />
+ * this node shoud be ignored.
+ *
+ * @see https://github.com/TooTallNate/plist.js/issues/66
+ * @param {Element} node
+ * @returns {Boolean}
+ * @api private
+ */
+function isEmptyNode(node){
+ if(!node.childNodes || node.childNodes.length === 0) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+function invariant(test, message) {
+ if (!test) {
+ throw new Error(message);
+ }
+}
+
+/**
+ * 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);
+ invariant(
+ doc.documentElement.nodeName === 'plist',
+ 'malformed document. First element should be <plist>'
+ );
+ var plist = parsePlistXML(doc.documentElement);
+
+ // the root <plist> node gets interpreted as an Array,
+ // so pull out the inner data first
+ 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, counter, type;
+
+ if (!node)
+ return null;
+
+ if (node.nodeName === 'plist') {
+ new_arr = [];
+ if (isEmptyNode(node)) {
+ return new_arr;
+ }
+ for (i=0; i < node.childNodes.length; i++) {
+ if (!shouldIgnoreNode(node.childNodes[i])) {
+ new_arr.push( parsePlistXML(node.childNodes[i]));
+ }
+ }
+ return new_arr;
+ } else if (node.nodeName === 'dict') {
+ new_obj = {};
+ key = null;
+ counter = 0;
+ if (isEmptyNode(node)) {
+ return new_obj;
+ }
+ for (i=0; i < node.childNodes.length; i++) {
+ if (shouldIgnoreNode(node.childNodes[i])) continue;
+ if (counter % 2 === 0) {
+ invariant(
+ node.childNodes[i].nodeName === 'key',
+ 'Missing key while parsing <dict/>.'
+ );
+ key = parsePlistXML(node.childNodes[i]);
+ } else {
+ invariant(
+ node.childNodes[i].nodeName !== 'key',
+ 'Unexpected key "'
+ + parsePlistXML(node.childNodes[i])
+ + '" while parsing <dict/>.'
+ );
+ new_obj[key] = parsePlistXML(node.childNodes[i]);
+ }
+ counter += 1;
+ }
+ if (counter % 2 === 1) {
+ throw new Error('Missing value for "' + key + '" while parsing <dict/>');
+ }
+ return new_obj;
+
+ } else if (node.nodeName === 'array') {
+ new_arr = [];
+ if (isEmptyNode(node)) {
+ return new_arr;
+ }
+ for (i=0; i < node.childNodes.length; i++) {
+ 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') {
+ if (isEmptyNode(node)) {
+ return '';
+ }
+ return node.childNodes[0].nodeValue;
+ } else if (node.nodeName === 'string') {
+ res = '';
+ if (isEmptyNode(node)) {
+ return res;
+ }
+ for (i=0; i < node.childNodes.length; i++) {
+ var type = node.childNodes[i].nodeType;
+ if (type === TEXT_NODE || type === CDATA_NODE) {
+ res += node.childNodes[i].nodeValue;
+ }
+ }
+ return res;
+
+ } else if (node.nodeName === 'integer') {
+ invariant(
+ !isEmptyNode(node),
+ 'Cannot parse "" as integer.'
+ );
+ return parseInt(node.childNodes[0].nodeValue, 10);
+
+ } else if (node.nodeName === 'real') {
+ invariant(
+ !isEmptyNode(node),
+ 'Cannot parse "" as real.'
+ );
+ res = '';
+ for (i=0; i < node.childNodes.length; i++) {
+ if (node.childNodes[i].nodeType === TEXT_NODE) {
+ res += node.childNodes[i].nodeValue;
+ }
+ }
+ return parseFloat(res);
+
+ } else if (node.nodeName === 'data') {
+ res = '';
+ if (isEmptyNode(node)) {
+ return Buffer.from(res, 'base64');
+ }
+ for (i=0; i < node.childNodes.length; i++) {
+ if (node.childNodes[i].nodeType === TEXT_NODE) {
+ res += node.childNodes[i].nodeValue.replace(/\s+/g, '');
+ }
+ }
+ return Buffer.from(res, 'base64');
+
+ } else if (node.nodeName === 'date') {
+ invariant(
+ !isEmptyNode(node),
+ 'Cannot parse "" as Date.'
+ )
+ return new Date(node.childNodes[0].nodeValue);
+
+ } else if (node.nodeName === 'true') {
+ return true;
+
+ } else if (node.nodeName === 'false') {
+ return false;
+ }
+}
+
+}).call(this,require("buffer").Buffer)
+},{"buffer":3,"xmldom":5}],2:[function(require,module,exports){
+'use strict'
+
+exports.byteLength = byteLength
+exports.toByteArray = toByteArray
+exports.fromByteArray = fromByteArray
+
+var lookup = []
+var revLookup = []
+var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
+
+var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
+for (var i = 0, len = code.length; i < len; ++i) {
+ lookup[i] = code[i]
+ revLookup[code.charCodeAt(i)] = i
+}
+
+// Support decoding URL-safe base64 strings, as Node.js does.
+// See: https://en.wikipedia.org/wiki/Base64#URL_applications
+revLookup['-'.charCodeAt(0)] = 62
+revLookup['_'.charCodeAt(0)] = 63
+
+function placeHoldersCount (b64) {
+ var len = b64.length
+ if (len % 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
+ return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
+}
+
+function byteLength (b64) {
+ // base64 is 4/3 + up to two characters of the original data
+ return (b64.length * 3 / 4) - placeHoldersCount(b64)
+}
+
+function toByteArray (b64) {
+ var i, l, tmp, placeHolders, arr
+ var len = b64.length
+ placeHolders = placeHoldersCount(b64)
+
+ arr = new Arr((len * 3 / 4) - placeHolders)
+
+ // if there are placeholders, only get up to the last complete 4 chars
+ l = placeHolders > 0 ? len - 4 : len
+
+ var L = 0
+
+ for (i = 0; i < l; i += 4) {
+ tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
+ arr[L++] = (tmp >> 16) & 0xFF
+ arr[L++] = (tmp >> 8) & 0xFF
+ arr[L++] = tmp & 0xFF
+ }
+
+ if (placeHolders === 2) {
+ tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
+ arr[L++] = tmp & 0xFF
+ } else if (placeHolders === 1) {
+ tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
+ arr[L++] = (tmp >> 8) & 0xFF
+ arr[L++] = tmp & 0xFF
+ }
+
+ return arr
+}
+
+function tripletToBase64 (num) {
+ return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
+}
+
+function encodeChunk (uint8, start, end) {
+ var tmp
+ var output = []
+ for (var i = start; i < end; i += 3) {
+ tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF)
+ output.push(tripletToBase64(tmp))
+ }
+ return output.join('')
+}
+
+function fromByteArray (uint8) {
+ var tmp
+ var len = uint8.length
+ var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
+ var output = ''
+ var parts = []
+ var maxChunkLength = 16383 // must be multiple of 3
+
+ // go through the array every three bytes, we'll deal with trailing stuff later
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
+ parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
+ }
+
+ // pad the end with zeros, but make sure to not forget the extra bytes
+ if (extraBytes === 1) {
+ tmp = uint8[len - 1]
+ output += lookup[tmp >> 2]
+ output += lookup[(tmp << 4) & 0x3F]
+ output += '=='
+ } else if (extraBytes === 2) {
+ tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
+ output += lookup[tmp >> 10]
+ output += lookup[(tmp >> 4) & 0x3F]
+ output += lookup[(tmp << 2) & 0x3F]
+ output += '='
+ }
+
+ parts.push(output)
+
+ return parts.join('')
+}
+
+},{}],3:[function(require,module,exports){
+/*!
+ * The buffer module from node.js, for the browser.
+ *
+ * @author Feross Aboukhadijeh <https://feross.org>
+ * @license MIT
+ */
+/* eslint-disable no-proto */
+
+'use strict'
+
+var base64 = require('base64-js')
+var ieee754 = require('ieee754')
+
+exports.Buffer = Buffer
+exports.SlowBuffer = SlowBuffer
+exports.INSPECT_MAX_BYTES = 50
+
+var K_MAX_LENGTH = 0x7fffffff
+exports.kMaxLength = K_MAX_LENGTH
+
+/**
+ * If `Buffer.TYPED_ARRAY_SUPPORT`:
+ * === true Use Uint8Array implementation (fastest)
+ * === false Print warning and recommend using `buffer` v4.x which has an Object
+ * implementation (most compatible, even IE6)
+ *
+ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
+ * Opera 11.6+, iOS 4.2+.
+ *
+ * We report that the browser does not support typed arrays if the are not subclassable
+ * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
+ * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
+ * for __proto__ and has a buggy typed array implementation.
+ */
+Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
+
+if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
+ typeof console.error === 'function') {
+ console.error(
+ 'This browser lacks typed array (Uint8Array) support which is required by ' +
+ '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
+ )
+}
+
+function typedArraySupport () {
+ // Can typed array instances can be augmented?
+ try {
+ var arr = new Uint8Array(1)
+ arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
+ return arr.foo() === 42
+ } catch (e) {
+ return false
+ }
+}
+
+Object.defineProperty(Buffer.prototype, 'parent', {
+ get: function () {
+ if (!(this instanceof Buffer)) {
+ return undefined
+ }
+ return this.buffer
+ }
+})
+
+Object.defineProperty(Buffer.prototype, 'offset', {
+ get: function () {
+ if (!(this instanceof Buffer)) {
+ return undefined
+ }
+ return this.byteOffset
+ }
+})
+
+function createBuffer (length) {
+ if (length > K_MAX_LENGTH) {
+ throw new RangeError('Invalid typed array length')
+ }
+ // Return an augmented `Uint8Array` instance
+ var buf = new Uint8Array(length)
+ buf.__proto__ = Buffer.prototype
+ return buf
+}
+
+/**
+ * The Buffer constructor returns instances of `Uint8Array` that have their
+ * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
+ * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
+ * and the `Uint8Array` methods. Square bracket notation works as expected -- it
+ * returns a single octet.
+ *
+ * The `Uint8Array` prototype remains unmodified.
+ */
+
+function Buffer (arg, encodingOrOffset, length) {
+ // Common case.
+ if (typeof arg === 'number') {
+ if (typeof encodingOrOffset === 'string') {
+ throw new Error(
+ 'If encoding is specified then the first argument must be a string'
+ )
+ }
+ return allocUnsafe(arg)
+ }
+ return from(arg, encodingOrOffset, length)
+}
+
+// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
+if (typeof Symbol !== 'undefined' && Symbol.species &&
+ Buffer[Symbol.species] === Buffer) {
+ Object.defineProperty(Buffer, Symbol.species, {
+ value: null,
+ configurable: true,
+ enumerable: false,
+ writable: false
+ })
+}
+
+Buffer.poolSize = 8192 // not used by this implementation
+
+function from (value, encodingOrOffset, length) {
+ if (typeof value === 'number') {
+ throw new TypeError('"value" argument must not be a number')
+ }
+
+ if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) {
+ return fromArrayBuffer(value, encodingOrOffset, length)
+ }
+
+ if (typeof value === 'string') {
+ return fromString(value, encodingOrOffset)
+ }
+
+ return fromObject(value)
+}
+
+/**
+ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
+ * if value is a number.
+ * Buffer.from(str[, encoding])
+ * Buffer.from(array)
+ * Buffer.from(buffer)
+ * Buffer.from(arrayBuffer[, byteOffset[, length]])
+ **/
+Buffer.from = function (value, encodingOrOffset, length) {
+ return from(value, encodingOrOffset, length)
+}
+
+// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
+// https://github.com/feross/buffer/pull/148
+Buffer.prototype.__proto__ = Uint8Array.prototype
+Buffer.__proto__ = Uint8Array
+
+function assertSize (size) {
+ if (typeof size !== 'number') {
+ throw new TypeError('"size" argument must be of type number')
+ } else if (size < 0) {
+ throw new RangeError('"size" argument must not be negative')
+ }
+}
+
+function alloc (size, fill, encoding) {
+ assertSize(size)
+ if (size <= 0) {
+ return createBuffer(size)
+ }
+ if (fill !== undefined) {
+ // Only pay attention to encoding if it's a string. This
+ // prevents accidentally sending in a number that would
+ // be interpretted as a start offset.
+ return typeof encoding === 'string'
+ ? createBuffer(size).fill(fill, encoding)
+ : createBuffer(size).fill(fill)
+ }
+ return createBuffer(size)
+}
+
+/**
+ * Creates a new filled Buffer instance.
+ * alloc(size[, fill[, encoding]])
+ **/
+Buffer.alloc = function (size, fill, encoding) {
+ return alloc(size, fill, encoding)
+}
+
+function allocUnsafe (size) {
+ assertSize(size)
+ return createBuffer(size < 0 ? 0 : checked(size) | 0)
+}
+
+/**
+ * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
+ * */
+Buffer.allocUnsafe = function (size) {
+ return allocUnsafe(size)
+}
+/**
+ * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
+ */
+Buffer.allocUnsafeSlow = function (size) {
+ return allocUnsafe(size)
+}
+
+function fromString (string, encoding) {
+ if (typeof encoding !== 'string' || encoding === '') {
+ encoding = 'utf8'
+ }
+
+ if (!Buffer.isEncoding(encoding)) {
+ throw new TypeError('Unknown encoding: ' + encoding)
+ }
+
+ var length = byteLength(string, encoding) | 0
+ var buf = createBuffer(length)
+
+ var actual = buf.write(string, encoding)
+
+ if (actual !== length) {
+ // Writing a hex string, for example, that contains invalid characters will
+ // cause everything after the first invalid character to be ignored. (e.g.
+ // 'abxxcd' will be treated as 'ab')
+ buf = buf.slice(0, actual)
+ }
+
+ return buf
+}
+
+function fromArrayLike (array) {
+ var length = array.length < 0 ? 0 : checked(array.length) | 0
+ var buf = createBuffer(length)
+ for (var i = 0; i < length; i += 1) {
+ buf[i] = array[i] & 255
+ }
+ return buf
+}
+
+function fromArrayBuffer (array, byteOffset, length) {
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
+ throw new RangeError('"offset" is outside of buffer bounds')
+ }
+
+ if (array.byteLength < byteOffset + (length || 0)) {
+ throw new RangeError('"length" is outside of buffer bounds')
+ }
+
+ var buf
+ if (byteOffset === undefined && length === undefined) {
+ buf = new Uint8Array(array)
+ } else if (length === undefined) {
+ buf = new Uint8Array(array, byteOffset)
+ } else {
+ buf = new Uint8Array(array, byteOffset, length)
+ }
+
+ // Return an augmented `Uint8Array` instance
+ buf.__proto__ = Buffer.prototype
+ return buf
+}
+
+function fromObject (obj) {
+ if (Buffer.isBuffer(obj)) {
+ var len = checked(obj.length) | 0
+ var buf = createBuffer(len)
+
+ if (buf.length === 0) {
+ return buf
+ }
+
+ obj.copy(buf, 0, 0, len)
+ return buf
+ }
+
+ if (obj) {
+ if (ArrayBuffer.isView(obj) || 'length' in obj) {
+ if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
+ return createBuffer(0)
+ }
+ return fromArrayLike(obj)
+ }
+
+ if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
+ return fromArrayLike(obj.data)
+ }
+ }
+
+ throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.')
+}
+
+function checked (length) {
+ // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
+ // length is NaN (which is otherwise coerced to zero.)
+ if (length >= K_MAX_LENGTH) {
+ throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
+ 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
+ }
+ return length | 0
+}
+
+function SlowBuffer (length) {
+ if (+length != length) { // eslint-disable-line eqeqeq
+ length = 0
+ }
+ return Buffer.alloc(+length)
+}
+
+Buffer.isBuffer = function isBuffer (b) {
+ return b != null && b._isBuffer === true
+}
+
+Buffer.compare = function compare (a, b) {
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
+ throw new TypeError('Arguments must be Buffers')
+ }
+
+ if (a === b) return 0
+
+ var x = a.length
+ var y = b.length
+
+ for (var i = 0, len = Math.min(x, y); i < len; ++i) {
+ if (a[i] !== b[i]) {
+ x = a[i]
+ y = b[i]
+ break
+ }
+ }
+
+ if (x < y) return -1
+ if (y < x) return 1
+ return 0
+}
+
+Buffer.isEncoding = function isEncoding (encoding) {
+ switch (String(encoding).toLowerCase()) {
+ case 'hex':
+ case 'utf8':
+ case 'utf-8':
+ case 'ascii':
+ case 'latin1':
+ case 'binary':
+ case 'base64':
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return true
+ default:
+ return false
+ }
+}
+
+Buffer.concat = function concat (list, length) {
+ if (!Array.isArray(list)) {
+ throw new TypeError('"list" argument must be an Array of Buffers')
+ }
+
+ if (list.length === 0) {
+ return Buffer.alloc(0)
+ }
+
+ var i
+ if (length === undefined) {
+ length = 0
+ for (i = 0; i < list.length; ++i) {
+ length += list[i].length
+ }
+ }
+
+ var buffer = Buffer.allocUnsafe(length)
+ var pos = 0
+ for (i = 0; i < list.length; ++i) {
+ var buf = list[i]
+ if (ArrayBuffer.isView(buf)) {
+ buf = Buffer.from(buf)
+ }
+ if (!Buffer.isBuffer(buf)) {
+ throw new TypeError('"list" argument must be an Array of Buffers')
+ }
+ buf.copy(buffer, pos)
+ pos += buf.length
+ }
+ return buffer
+}
+
+function byteLength (string, encoding) {
+ if (Buffer.isBuffer(string)) {
+ return string.length
+ }
+ if (ArrayBuffer.isView(string) || isArrayBuffer(string)) {
+ return string.byteLength
+ }
+ if (typeof string !== 'string') {
+ string = '' + string
+ }
+
+ var len = string.length
+ if (len === 0) return 0
+
+ // Use a for loop to avoid recursion
+ var loweredCase = false
+ for (;;) {
+ switch (encoding) {
+ case 'ascii':
+ case 'latin1':
+ case 'binary':
+ return len
+ case 'utf8':
+ case 'utf-8':
+ case undefined:
+ return utf8ToBytes(string).length
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return len * 2
+ case 'hex':
+ return len >>> 1
+ case 'base64':
+ return base64ToBytes(string).length
+ default:
+ if (loweredCase) return utf8ToBytes(string).length // assume utf8
+ encoding = ('' + encoding).toLowerCase()
+ loweredCase = true
+ }
+ }
+}
+Buffer.byteLength = byteLength
+
+function slowToString (encoding, start, end) {
+ var loweredCase = false
+
+ // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
+ // property of a typed array.
+
+ // This behaves neither like String nor Uint8Array in that we set start/end
+ // to their upper/lower bounds if the value passed is out of range.
+ // undefined is handled specially as per ECMA-262 6th Edition,
+ // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
+ if (start === undefined || start < 0) {
+ start = 0
+ }
+ // Return early if start > this.length. Done here to prevent potential uint32
+ // coercion fail below.
+ if (start > this.length) {
+ return ''
+ }
+
+ if (end === undefined || end > this.length) {
+ end = this.length
+ }
+
+ if (end <= 0) {
+ return ''
+ }
+
+ // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
+ end >>>= 0
+ start >>>= 0
+
+ if (end <= start) {
+ return ''
+ }
+
+ if (!encoding) encoding = 'utf8'
+
+ while (true) {
+ switch (encoding) {
+ case 'hex':
+ return hexSlice(this, start, end)
+
+ case 'utf8':
+ case 'utf-8':
+ return utf8Slice(this, start, end)
+
+ case 'ascii':
+ return asciiSlice(this, start, end)
+
+ case 'latin1':
+ case 'binary':
+ return latin1Slice(this, start, end)
+
+ case 'base64':
+ return base64Slice(this, start, end)
+
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return utf16leSlice(this, start, end)
+
+ default:
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
+ encoding = (encoding + '').toLowerCase()
+ loweredCase = true
+ }
+ }
+}
+
+// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
+// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
+// reliably in a browserify context because there could be multiple different
+// copies of the 'buffer' package in use. This method works even for Buffer
+// instances that were created from another copy of the `buffer` package.
+// See: https://github.com/feross/buffer/issues/154
+Buffer.prototype._isBuffer = true
+
+function swap (b, n, m) {
+ var i = b[n]
+ b[n] = b[m]
+ b[m] = i
+}
+
+Buffer.prototype.swap16 = function swap16 () {
+ var len = this.length
+ if (len % 2 !== 0) {
+ throw new RangeError('Buffer size must be a multiple of 16-bits')
+ }
+ for (var i = 0; i < len; i += 2) {
+ swap(this, i, i + 1)
+ }
+ return this
+}
+
+Buffer.prototype.swap32 = function swap32 () {
+ var len = this.length
+ if (len % 4 !== 0) {
+ throw new RangeError('Buffer size must be a multiple of 32-bits')
+ }
+ for (var i = 0; i < len; i += 4) {
+ swap(this, i, i + 3)
+ swap(this, i + 1, i + 2)
+ }
+ return this
+}
+
+Buffer.prototype.swap64 = function swap64 () {
+ var len = this.length
+ if (len % 8 !== 0) {
+ throw new RangeError('Buffer size must be a multiple of 64-bits')
+ }
+ for (var i = 0; i < len; i += 8) {
+ swap(this, i, i + 7)
+ swap(this, i + 1, i + 6)
+ swap(this, i + 2, i + 5)
+ swap(this, i + 3, i + 4)
+ }
+ return this
+}
+
+Buffer.prototype.toString = function toString () {
+ var length = this.length
+ if (length === 0) return ''
+ if (arguments.length === 0) return utf8Slice(this, 0, length)
+ return slowToString.apply(this, arguments)
+}
+
+Buffer.prototype.toLocaleString = Buffer.prototype.toString
+
+Buffer.prototype.equals = function equals (b) {
+ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
+ if (this === b) return true
+ return Buffer.compare(this, b) === 0
+}
+
+Buffer.prototype.inspect = function inspect () {
+ var str = ''
+ var max = exports.INSPECT_MAX_BYTES
+ if (this.length > 0) {
+ str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
+ if (this.length > max) str += ' ... '
+ }
+ return '<Buffer ' + str + '>'
+}
+
+Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
+ if (!Buffer.isBuffer(target)) {
+ throw new TypeError('Argument must be a Buffer')
+ }
+
+ if (start === undefined) {
+ start = 0
+ }
+ if (end === undefined) {
+ end = target ? target.length : 0
+ }
+ if (thisStart === undefined) {
+ thisStart = 0
+ }
+ if (thisEnd === undefined) {
+ thisEnd = this.length
+ }
+
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
+ throw new RangeError('out of range index')
+ }
+
+ if (thisStart >= thisEnd && start >= end) {
+ return 0
+ }
+ if (thisStart >= thisEnd) {
+ return -1
+ }
+ if (start >= end) {
+ return 1
+ }
+
+ start >>>= 0
+ end >>>= 0
+ thisStart >>>= 0
+ thisEnd >>>= 0
+
+ if (this === target) return 0
+
+ var x = thisEnd - thisStart
+ var y = end - start
+ var len = Math.min(x, y)
+
+ var thisCopy = this.slice(thisStart, thisEnd)
+ var targetCopy = target.slice(start, end)
+
+ for (var i = 0; i < len; ++i) {
+ if (thisCopy[i] !== targetCopy[i]) {
+ x = thisCopy[i]
+ y = targetCopy[i]
+ break
+ }
+ }
+
+ if (x < y) return -1
+ if (y < x) return 1
+ return 0
+}
+
+// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
+// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
+//
+// Arguments:
+// - buffer - a Buffer to search
+// - val - a string, Buffer, or number
+// - byteOffset - an index into `buffer`; will be clamped to an int32
+// - encoding - an optional encoding, relevant is val is a string
+// - dir - true for indexOf, false for lastIndexOf
+function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
+ // Empty buffer means no match
+ if (buffer.length === 0) return -1
+
+ // Normalize byteOffset
+ if (typeof byteOffset === 'string') {
+ encoding = byteOffset
+ byteOffset = 0
+ } else if (byteOffset > 0x7fffffff) {
+ byteOffset = 0x7fffffff
+ } else if (byteOffset < -0x80000000) {
+ byteOffset = -0x80000000
+ }
+ byteOffset = +byteOffset // Coerce to Number.
+ if (numberIsNaN(byteOffset)) {
+ // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
+ byteOffset = dir ? 0 : (buffer.length - 1)
+ }
+
+ // Normalize byteOffset: negative offsets start from the end of the buffer
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset
+ if (byteOffset >= buffer.length) {
+ if (dir) return -1
+ else byteOffset = buffer.length - 1
+ } else if (byteOffset < 0) {
+ if (dir) byteOffset = 0
+ else return -1
+ }
+
+ // Normalize val
+ if (typeof val === 'string') {
+ val = Buffer.from(val, encoding)
+ }
+
+ // Finally, search either indexOf (if dir is true) or lastIndexOf
+ if (Buffer.isBuffer(val)) {
+ // Special case: looking for empty string/buffer always fails
+ if (val.length === 0) {
+ return -1
+ }
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
+ } else if (typeof val === 'number') {
+ val = val & 0xFF // Search for a byte value [0-255]
+ if (typeof Uint8Array.prototype.indexOf === 'function') {
+ if (dir) {
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
+ } else {
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
+ }
+ }
+ return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
+ }
+
+ throw new TypeError('val must be string, number or Buffer')
+}
+
+function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
+ var indexSize = 1
+ var arrLength = arr.length
+ var valLength = val.length
+
+ if (encoding !== undefined) {
+ encoding = String(encoding).toLowerCase()
+ if (encoding === 'ucs2' || encoding === 'ucs-2' ||
+ encoding === 'utf16le' || encoding === 'utf-16le') {
+ if (arr.length < 2 || val.length < 2) {
+ return -1
+ }
+ indexSize = 2
+ arrLength /= 2
+ valLength /= 2
+ byteOffset /= 2
+ }
+ }
+
+ function read (buf, i) {
+ if (indexSize === 1) {
+ return buf[i]
+ } else {
+ return buf.readUInt16BE(i * indexSize)
+ }
+ }
+
+ var i
+ if (dir) {
+ var foundIndex = -1
+ for (i = byteOffset; i < arrLength; i++) {
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
+ if (foundIndex === -1) foundIndex = i
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
+ } else {
+ if (foundIndex !== -1) i -= i - foundIndex
+ foundIndex = -1
+ }
+ }
+ } else {
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
+ for (i = byteOffset; i >= 0; i--) {
+ var found = true
+ for (var j = 0; j < valLength; j++) {
+ if (read(arr, i + j) !== read(val, j)) {
+ found = false
+ break
+ }
+ }
+ if (found) return i
+ }
+ }
+
+ return -1
+}
+
+Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
+ return this.indexOf(val, byteOffset, encoding) !== -1
+}
+
+Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
+}
+
+Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
+}
+
+function hexWrite (buf, string, offset, length) {
+ offset = Number(offset) || 0
+ var remaining = buf.length - offset
+ if (!length) {
+ length = remaining
+ } else {
+ length = Number(length)
+ if (length > remaining) {
+ length = remaining
+ }
+ }
+
+ var strLen = string.length
+
+ if (length > strLen / 2) {
+ length = strLen / 2
+ }
+ for (var i = 0; i < length; ++i) {
+ var parsed = parseInt(string.substr(i * 2, 2), 16)
+ if (numberIsNaN(parsed)) return i
+ buf[offset + i] = parsed
+ }
+ return i
+}
+
+function utf8Write (buf, string, offset, length) {
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
+}
+
+function asciiWrite (buf, string, offset, length) {
+ return blitBuffer(asciiToBytes(string), buf, offset, length)
+}
+
+function latin1Write (buf, string, offset, length) {
+ return asciiWrite(buf, string, offset, length)
+}
+
+function base64Write (buf, string, offset, length) {
+ return blitBuffer(base64ToBytes(string), buf, offset, length)
+}
+
+function ucs2Write (buf, string, offset, length) {
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
+}
+
+Buffer.prototype.write = function write (string, offset, length, encoding) {
+ // Buffer#write(string)
+ if (offset === undefined) {
+ encoding = 'utf8'
+ length = this.length
+ offset = 0
+ // Buffer#write(string, encoding)
+ } else if (length === undefined && typeof offset === 'string') {
+ encoding = offset
+ length = this.length
+ offset = 0
+ // Buffer#write(string, offset[, length][, encoding])
+ } else if (isFinite(offset)) {
+ offset = offset >>> 0
+ if (isFinite(length)) {
+ length = length >>> 0
+ if (encoding === undefined) encoding = 'utf8'
+ } else {
+ encoding = length
+ length = undefined
+ }
+ } else {
+ throw new Error(
+ 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
+ )
+ }
+
+ var remaining = this.length - offset
+ if (length === undefined || length > remaining) length = remaining
+
+ if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
+ throw new RangeError('Attempt to write outside buffer bounds')
+ }
+
+ if (!encoding) encoding = 'utf8'
+
+ var loweredCase = false
+ for (;;) {
+ switch (encoding) {
+ case 'hex':
+ return hexWrite(this, string, offset, length)
+
+ case 'utf8':
+ case 'utf-8':
+ return utf8Write(this, string, offset, length)
+
+ case 'ascii':
+ return asciiWrite(this, string, offset, length)
+
+ case 'latin1':
+ case 'binary':
+ return latin1Write(this, string, offset, length)
+
+ case 'base64':
+ // Warning: maxLength not taken into account in base64Write
+ return base64Write(this, string, offset, length)
+
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return ucs2Write(this, string, offset, length)
+
+ default:
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
+ encoding = ('' + encoding).toLowerCase()
+ loweredCase = true
+ }
+ }
+}
+
+Buffer.prototype.toJSON = function toJSON () {
+ return {
+ type: 'Buffer',
+ data: Array.prototype.slice.call(this._arr || this, 0)
+ }
+}
+
+function base64Slice (buf, start, end) {
+ if (start === 0 && end === buf.length) {
+ return base64.fromByteArray(buf)
+ } else {
+ return base64.fromByteArray(buf.slice(start, end))
+ }
+}
+
+function utf8Slice (buf, start, end) {
+ end = Math.min(buf.length, end)
+ var res = []
+
+ var i = start
+ while (i < end) {
+ var firstByte = buf[i]
+ var codePoint = null
+ var bytesPerSequence = (firstByte > 0xEF) ? 4
+ : (firstByte > 0xDF) ? 3
+ : (firstByte > 0xBF) ? 2
+ : 1
+
+ if (i + bytesPerSequence <= end) {
+ var secondByte, thirdByte, fourthByte, tempCodePoint
+
+ switch (bytesPerSequence) {
+ case 1:
+ if (firstByte < 0x80) {
+ codePoint = firstByte
+ }
+ break
+ case 2:
+ secondByte = buf[i + 1]
+ if ((secondByte & 0xC0) === 0x80) {
+ tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
+ if (tempCodePoint > 0x7F) {
+ codePoint = tempCodePoint
+ }
+ }
+ break
+ case 3:
+ secondByte = buf[i + 1]
+ thirdByte = buf[i + 2]
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
+ tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
+ if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
+ codePoint = tempCodePoint
+ }
+ }
+ break
+ case 4:
+ secondByte = buf[i + 1]
+ thirdByte = buf[i + 2]
+ fourthByte = buf[i + 3]
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
+ tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
+ if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
+ codePoint = tempCodePoint
+ }
+ }
+ }
+ }
+
+ if (codePoint === null) {
+ // we did not generate a valid codePoint so insert a
+ // replacement char (U+FFFD) and advance only 1 byte
+ codePoint = 0xFFFD
+ bytesPerSequence = 1
+ } else if (codePoint > 0xFFFF) {
+ // encode to utf16 (surrogate pair dance)
+ codePoint -= 0x10000
+ res.push(codePoint >>> 10 & 0x3FF | 0xD800)
+ codePoint = 0xDC00 | codePoint & 0x3FF
+ }
+
+ res.push(codePoint)
+ i += bytesPerSequence
+ }
+
+ return decodeCodePointsArray(res)
+}
+
+// Based on http://stackoverflow.com/a/22747272/680742, the browser with
+// the lowest limit is Chrome, with 0x10000 args.
+// We go 1 magnitude less, for safety
+var MAX_ARGUMENTS_LENGTH = 0x1000
+
+function decodeCodePointsArray (codePoints) {
+ var len = codePoints.length
+ if (len <= MAX_ARGUMENTS_LENGTH) {
+ return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
+ }
+
+ // Decode in chunks to avoid "call stack size exceeded".
+ var res = ''
+ var i = 0
+ while (i < len) {
+ res += String.fromCharCode.apply(
+ String,
+ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
+ )
+ }
+ return res
+}
+
+function asciiSlice (buf, start, end) {
+ var ret = ''
+ end = Math.min(buf.length, end)
+
+ for (var i = start; i < end; ++i) {
+ ret += String.fromCharCode(buf[i] & 0x7F)
+ }
+ return ret
+}
+
+function latin1Slice (buf, start, end) {
+ var ret = ''
+ end = Math.min(buf.length, end)
+
+ for (var i = start; i < end; ++i) {
+ ret += String.fromCharCode(buf[i])
+ }
+ return ret
+}
+
+function hexSlice (buf, start, end) {
+ var len = buf.length
+
+ if (!start || start < 0) start = 0
+ if (!end || end < 0 || end > len) end = len
+
+ var out = ''
+ for (var i = start; i < end; ++i) {
+ out += toHex(buf[i])
+ }
+ return out
+}
+
+function utf16leSlice (buf, start, end) {
+ var bytes = buf.slice(start, end)
+ var res = ''
+ for (var i = 0; i < bytes.length; i += 2) {
+ res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
+ }
+ return res
+}
+
+Buffer.prototype.slice = function slice (start, end) {
+ var len = this.length
+ start = ~~start
+ end = end === undefined ? len : ~~end
+
+ if (start < 0) {
+ start += len
+ if (start < 0) start = 0
+ } else if (start > len) {
+ start = len
+ }
+
+ if (end < 0) {
+ end += len
+ if (end < 0) end = 0
+ } else if (end > len) {
+ end = len
+ }
+
+ if (end < start) end = start
+
+ var newBuf = this.subarray(start, end)
+ // Return an augmented `Uint8Array` instance
+ newBuf.__proto__ = Buffer.prototype
+ return newBuf
+}
+
+/*
+ * Need to make sure that buffer isn't trying to write out of bounds.
+ */
+function checkOffset (offset, ext, length) {
+ if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
+ if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
+}
+
+Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
+ offset = offset >>> 0
+ byteLength = byteLength >>> 0
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
+
+ var val = this[offset]
+ var mul = 1
+ var i = 0
+ while (++i < byteLength && (mul *= 0x100)) {
+ val += this[offset + i] * mul
+ }
+
+ return val
+}
+
+Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
+ offset = offset >>> 0
+ byteLength = byteLength >>> 0
+ if (!noAssert) {
+ checkOffset(offset, byteLength, this.length)
+ }
+
+ var val = this[offset + --byteLength]
+ var mul = 1
+ while (byteLength > 0 && (mul *= 0x100)) {
+ val += this[offset + --byteLength] * mul
+ }
+
+ return val
+}
+
+Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 1, this.length)
+ return this[offset]
+}
+
+Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 2, this.length)
+ return this[offset] | (this[offset + 1] << 8)
+}
+
+Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 2, this.length)
+ return (this[offset] << 8) | this[offset + 1]
+}
+
+Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 4, this.length)
+
+ return ((this[offset]) |
+ (this[offset + 1] << 8) |
+ (this[offset + 2] << 16)) +
+ (this[offset + 3] * 0x1000000)
+}
+
+Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 4, this.length)
+
+ return (this[offset] * 0x1000000) +
+ ((this[offset + 1] << 16) |
+ (this[offset + 2] << 8) |
+ this[offset + 3])
+}
+
+Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
+ offset = offset >>> 0
+ byteLength = byteLength >>> 0
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
+
+ var val = this[offset]
+ var mul = 1
+ var i = 0
+ while (++i < byteLength && (mul *= 0x100)) {
+ val += this[offset + i] * mul
+ }
+ mul *= 0x80
+
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength)
+
+ return val
+}
+
+Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
+ offset = offset >>> 0
+ byteLength = byteLength >>> 0
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
+
+ var i = byteLength
+ var mul = 1
+ var val = this[offset + --i]
+ while (i > 0 && (mul *= 0x100)) {
+ val += this[offset + --i] * mul
+ }
+ mul *= 0x80
+
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength)
+
+ return val
+}
+
+Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 1, this.length)
+ if (!(this[offset] & 0x80)) return (this[offset])
+ return ((0xff - this[offset] + 1) * -1)
+}
+
+Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 2, this.length)
+ var val = this[offset] | (this[offset + 1] << 8)
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
+}
+
+Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 2, this.length)
+ var val = this[offset + 1] | (this[offset] << 8)
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
+}
+
+Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 4, this.length)
+
+ return (this[offset]) |
+ (this[offset + 1] << 8) |
+ (this[offset + 2] << 16) |
+ (this[offset + 3] << 24)
+}
+
+Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 4, this.length)
+
+ return (this[offset] << 24) |
+ (this[offset + 1] << 16) |
+ (this[offset + 2] << 8) |
+ (this[offset + 3])
+}
+
+Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 4, this.length)
+ return ieee754.read(this, offset, true, 23, 4)
+}
+
+Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 4, this.length)
+ return ieee754.read(this, offset, false, 23, 4)
+}
+
+Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 8, this.length)
+ return ieee754.read(this, offset, true, 52, 8)
+}
+
+Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 8, this.length)
+ return ieee754.read(this, offset, false, 52, 8)
+}
+
+function checkInt (buf, value, offset, ext, max, min) {
+ if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
+ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
+}
+
+Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ byteLength = byteLength >>> 0
+ if (!noAssert) {
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1
+ checkInt(this, value, offset, byteLength, maxBytes, 0)
+ }
+
+ var mul = 1
+ var i = 0
+ this[offset] = value & 0xFF
+ while (++i < byteLength && (mul *= 0x100)) {
+ this[offset + i] = (value / mul) & 0xFF
+ }
+
+ return offset + byteLength
+}
+
+Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ byteLength = byteLength >>> 0
+ if (!noAssert) {
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1
+ checkInt(this, value, offset, byteLength, maxBytes, 0)
+ }
+
+ var i = byteLength - 1
+ var mul = 1
+ this[offset + i] = value & 0xFF
+ while (--i >= 0 && (mul *= 0x100)) {
+ this[offset + i] = (value / mul) & 0xFF
+ }
+
+ return offset + byteLength
+}
+
+Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
+ this[offset] = (value & 0xff)
+ return offset + 1
+}
+
+Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
+ this[offset] = (value & 0xff)
+ this[offset + 1] = (value >>> 8)
+ return offset + 2
+}
+
+Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
+ this[offset] = (value >>> 8)
+ this[offset + 1] = (value & 0xff)
+ return offset + 2
+}
+
+Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
+ this[offset + 3] = (value >>> 24)
+ this[offset + 2] = (value >>> 16)
+ this[offset + 1] = (value >>> 8)
+ this[offset] = (value & 0xff)
+ return offset + 4
+}
+
+Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
+ this[offset] = (value >>> 24)
+ this[offset + 1] = (value >>> 16)
+ this[offset + 2] = (value >>> 8)
+ this[offset + 3] = (value & 0xff)
+ return offset + 4
+}
+
+Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) {
+ var limit = Math.pow(2, (8 * byteLength) - 1)
+
+ checkInt(this, value, offset, byteLength, limit - 1, -limit)
+ }
+
+ var i = 0
+ var mul = 1
+ var sub = 0
+ this[offset] = value & 0xFF
+ while (++i < byteLength && (mul *= 0x100)) {
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
+ sub = 1
+ }
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
+ }
+
+ return offset + byteLength
+}
+
+Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) {
+ var limit = Math.pow(2, (8 * byteLength) - 1)
+
+ checkInt(this, value, offset, byteLength, limit - 1, -limit)
+ }
+
+ var i = byteLength - 1
+ var mul = 1
+ var sub = 0
+ this[offset + i] = value & 0xFF
+ while (--i >= 0 && (mul *= 0x100)) {
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
+ sub = 1
+ }
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
+ }
+
+ return offset + byteLength
+}
+
+Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
+ if (value < 0) value = 0xff + value + 1
+ this[offset] = (value & 0xff)
+ return offset + 1
+}
+
+Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
+ this[offset] = (value & 0xff)
+ this[offset + 1] = (value >>> 8)
+ return offset + 2
+}
+
+Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
+ this[offset] = (value >>> 8)
+ this[offset + 1] = (value & 0xff)
+ return offset + 2
+}
+
+Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
+ this[offset] = (value & 0xff)
+ this[offset + 1] = (value >>> 8)
+ this[offset + 2] = (value >>> 16)
+ this[offset + 3] = (value >>> 24)
+ return offset + 4
+}
+
+Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
+ if (value < 0) value = 0xffffffff + value + 1
+ this[offset] = (value >>> 24)
+ this[offset + 1] = (value >>> 16)
+ this[offset + 2] = (value >>> 8)
+ this[offset + 3] = (value & 0xff)
+ return offset + 4
+}
+
+function checkIEEE754 (buf, value, offset, ext, max, min) {
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
+ if (offset < 0) throw new RangeError('Index out of range')
+}
+
+function writeFloat (buf, value, offset, littleEndian, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) {
+ checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
+ }
+ ieee754.write(buf, value, offset, littleEndian, 23, 4)
+ return offset + 4
+}
+
+Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
+ return writeFloat(this, value, offset, true, noAssert)
+}
+
+Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
+ return writeFloat(this, value, offset, false, noAssert)
+}
+
+function writeDouble (buf, value, offset, littleEndian, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) {
+ checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
+ }
+ ieee754.write(buf, value, offset, littleEndian, 52, 8)
+ return offset + 8
+}
+
+Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
+ return writeDouble(this, value, offset, true, noAssert)
+}
+
+Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
+ return writeDouble(this, value, offset, false, noAssert)
+}
+
+// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
+Buffer.prototype.copy = function copy (target, targetStart, start, end) {
+ if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
+ if (!start) start = 0
+ if (!end && end !== 0) end = this.length
+ if (targetStart >= target.length) targetStart = target.length
+ if (!targetStart) targetStart = 0
+ if (end > 0 && end < start) end = start
+
+ // Copy 0 bytes; we're done
+ if (end === start) return 0
+ if (target.length === 0 || this.length === 0) return 0
+
+ // Fatal error conditions
+ if (targetStart < 0) {
+ throw new RangeError('targetStart out of bounds')
+ }
+ if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
+ if (end < 0) throw new RangeError('sourceEnd out of bounds')
+
+ // Are we oob?
+ if (end > this.length) end = this.length
+ if (target.length - targetStart < end - start) {
+ end = target.length - targetStart + start
+ }
+
+ var len = end - start
+
+ if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
+ // Use built-in when available, missing from IE11
+ this.copyWithin(targetStart, start, end)
+ } else if (this === target && start < targetStart && targetStart < end) {
+ // descending copy from end
+ for (var i = len - 1; i >= 0; --i) {
+ target[i + targetStart] = this[i + start]
+ }
+ } else {
+ Uint8Array.prototype.set.call(
+ target,
+ this.subarray(start, end),
+ targetStart
+ )
+ }
+
+ return len
+}
+
+// Usage:
+// buffer.fill(number[, offset[, end]])
+// buffer.fill(buffer[, offset[, end]])
+// buffer.fill(string[, offset[, end]][, encoding])
+Buffer.prototype.fill = function fill (val, start, end, encoding) {
+ // Handle string cases:
+ if (typeof val === 'string') {
+ if (typeof start === 'string') {
+ encoding = start
+ start = 0
+ end = this.length
+ } else if (typeof end === 'string') {
+ encoding = end
+ end = this.length
+ }
+ if (encoding !== undefined && typeof encoding !== 'string') {
+ throw new TypeError('encoding must be a string')
+ }
+ if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
+ throw new TypeError('Unknown encoding: ' + encoding)
+ }
+ if (val.length === 1) {
+ var code = val.charCodeAt(0)
+ if ((encoding === 'utf8' && code < 128) ||
+ encoding === 'latin1') {
+ // Fast path: If `val` fits into a single byte, use that numeric value.
+ val = code
+ }
+ }
+ } else if (typeof val === 'number') {
+ val = val & 255
+ }
+
+ // Invalid ranges are not set to a default, so can range check early.
+ if (start < 0 || this.length < start || this.length < end) {
+ throw new RangeError('Out of range index')
+ }
+
+ if (end <= start) {
+ return this
+ }
+
+ start = start >>> 0
+ end = end === undefined ? this.length : end >>> 0
+
+ if (!val) val = 0
+
+ var i
+ if (typeof val === 'number') {
+ for (i = start; i < end; ++i) {
+ this[i] = val
+ }
+ } else {
+ var bytes = Buffer.isBuffer(val)
+ ? val
+ : new Buffer(val, encoding)
+ var len = bytes.length
+ if (len === 0) {
+ throw new TypeError('The value "' + val +
+ '" is invalid for argument "value"')
+ }
+ for (i = 0; i < end - start; ++i) {
+ this[i + start] = bytes[i % len]
+ }
+ }
+
+ return this
+}
+
+// HELPER FUNCTIONS
+// ================
+
+var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
+
+function base64clean (str) {
+ // Node takes equal signs as end of the Base64 encoding
+ str = str.split('=')[0]
+ // Node strips out invalid characters like \n and \t from the string, base64-js does not
+ str = str.trim().replace(INVALID_BASE64_RE, '')
+ // Node converts strings with length < 2 to ''
+ if (str.length < 2) return ''
+ // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
+ while (str.length % 4 !== 0) {
+ str = str + '='
+ }
+ return str
+}
+
+function toHex (n) {
+ if (n < 16) return '0' + n.toString(16)
+ return n.toString(16)
+}
+
+function utf8ToBytes (string, units) {
+ units = units || Infinity
+ var codePoint
+ var length = string.length
+ var leadSurrogate = null
+ var bytes = []
+
+ for (var i = 0; i < length; ++i) {
+ codePoint = string.charCodeAt(i)
+
+ // is surrogate component
+ if (codePoint > 0xD7FF && codePoint < 0xE000) {
+ // last char was a lead
+ if (!leadSurrogate) {
+ // no lead yet
+ if (codePoint > 0xDBFF) {
+ // unexpected trail
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
+ continue
+ } else if (i + 1 === length) {
+ // unpaired lead
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
+ continue
+ }
+
+ // valid lead
+ leadSurrogate = codePoint
+
+ continue
+ }
+
+ // 2 leads in a row
+ if (codePoint < 0xDC00) {
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
+ leadSurrogate = codePoint
+ continue
+ }
+
+ // valid surrogate pair
+ codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
+ } else if (leadSurrogate) {
+ // valid bmp char, but last char was a lead
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
+ }
+
+ leadSurrogate = null
+
+ // encode utf8
+ if (codePoint < 0x80) {
+ if ((units -= 1) < 0) break
+ bytes.push(codePoint)
+ } else if (codePoint < 0x800) {
+ if ((units -= 2) < 0) break
+ bytes.push(
+ codePoint >> 0x6 | 0xC0,
+ codePoint & 0x3F | 0x80
+ )
+ } else if (codePoint < 0x10000) {
+ if ((units -= 3) < 0) break
+ bytes.push(
+ codePoint >> 0xC | 0xE0,
+ codePoint >> 0x6 & 0x3F | 0x80,
+ codePoint & 0x3F | 0x80
+ )
+ } else if (codePoint < 0x110000) {
+ if ((units -= 4) < 0) break
+ bytes.push(
+ codePoint >> 0x12 | 0xF0,
+ codePoint >> 0xC & 0x3F | 0x80,
+ codePoint >> 0x6 & 0x3F | 0x80,
+ codePoint & 0x3F | 0x80
+ )
+ } else {
+ throw new Error('Invalid code point')
+ }
+ }
+
+ return bytes
+}
+
+function asciiToBytes (str) {
+ var byteArray = []
+ for (var i = 0; i < str.length; ++i) {
+ // Node's code seems to be doing this and not & 0x7F..
+ byteArray.push(str.charCodeAt(i) & 0xFF)
+ }
+ return byteArray
+}
+
+function utf16leToBytes (str, units) {
+ var c, hi, lo
+ var byteArray = []
+ for (var i = 0; i < str.length; ++i) {
+ if ((units -= 2) < 0) break
+
+ c = str.charCodeAt(i)
+ hi = c >> 8
+ lo = c % 256
+ byteArray.push(lo)
+ byteArray.push(hi)
+ }
+
+ return byteArray
+}
+
+function base64ToBytes (str) {
+ return base64.toByteArray(base64clean(str))
+}
+
+function blitBuffer (src, dst, offset, length) {
+ for (var i = 0; i < length; ++i) {
+ if ((i + offset >= dst.length) || (i >= src.length)) break
+ dst[i + offset] = src[i]
+ }
+ return i
+}
+
+// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check
+// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166
+function isArrayBuffer (obj) {
+ return obj instanceof ArrayBuffer ||
+ (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' &&
+ typeof obj.byteLength === 'number')
+}
+
+function numberIsNaN (obj) {
+ return obj !== obj // eslint-disable-line no-self-compare
+}
+
+},{"base64-js":2,"ieee754":4}],4:[function(require,module,exports){
+exports.read = function (buffer, offset, isLE, mLen, nBytes) {
+ var e, m
+ var eLen = (nBytes * 8) - mLen - 1
+ var eMax = (1 << eLen) - 1
+ var eBias = eMax >> 1
+ var nBits = -7
+ var i = isLE ? (nBytes - 1) : 0
+ var d = isLE ? -1 : 1
+ var s = buffer[offset + i]
+
+ i += d
+
+ e = s & ((1 << (-nBits)) - 1)
+ s >>= (-nBits)
+ nBits += eLen
+ for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
+
+ m = e & ((1 << (-nBits)) - 1)
+ e >>= (-nBits)
+ nBits += mLen
+ for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
+
+ if (e === 0) {
+ e = 1 - eBias
+ } else if (e === eMax) {
+ return m ? NaN : ((s ? -1 : 1) * Infinity)
+ } else {
+ m = m + Math.pow(2, mLen)
+ e = e - eBias
+ }
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
+}
+
+exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
+ var e, m, c
+ var eLen = (nBytes * 8) - mLen - 1
+ var eMax = (1 << eLen) - 1
+ var eBias = eMax >> 1
+ var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
+ var i = isLE ? 0 : (nBytes - 1)
+ var d = isLE ? 1 : -1
+ var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
+
+ value = Math.abs(value)
+
+ if (isNaN(value) || value === Infinity) {
+ m = isNaN(value) ? 1 : 0
+ e = eMax
+ } else {
+ e = Math.floor(Math.log(value) / Math.LN2)
+ if (value * (c = Math.pow(2, -e)) < 1) {
+ e--
+ c *= 2
+ }
+ if (e + eBias >= 1) {
+ value += rt / c
+ } else {
+ value += rt * Math.pow(2, 1 - eBias)
+ }
+ if (value * c >= 2) {
+ e++
+ c /= 2
+ }
+
+ if (e + eBias >= eMax) {
+ m = 0
+ e = eMax
+ } else if (e + eBias >= 1) {
+ m = ((value * c) - 1) * Math.pow(2, mLen)
+ e = e + eBias
+ } else {
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
+ e = 0
+ }
+ }
+
+ for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
+
+ e = (e << mLen) | m
+ eLen += mLen
+ for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
+
+ buffer[offset + i - d] |= s * 128
+}
+
+},{}],5:[function(require,module,exports){
+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 = require('./sax').XMLReader;
+ var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation;
+ exports.XMLSerializer = require('./dom').XMLSerializer ;
+ exports.DOMParser = DOMParser;
+//}
+
+},{"./dom":6,"./sax":7}],6:[function(require,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<this.length;i++){
+ serializeToString(this[i],buf,isHTML,nodeFilter);
+ }
+ return buf.join('');
+ }
+};
+function LiveNodeList(node,refresh){
+ this._node = node;
+ this._refresh = refresh
+ _updateLiveList(this);
+}
+function _updateLiveList(list){
+ var inc = list._node._inc || list._node.ownerDocument._inc;
+ if(list._inc != inc){
+ var ls = list._refresh(list._node);
+ //console.log(ls.length)
+ __set__(list,'length',ls.length);
+ copy(ls,list);
+ list._inc = inc;
+ }
+}
+LiveNodeList.prototype.item = function(i){
+ _updateLiveList(this);
+ return this[i];
+}
+
+_extends(LiveNodeList,NodeList);
+/**
+ *
+ * Objects implementing the NamedNodeMap interface are used to represent collections of nodes that can be accessed by name. Note that NamedNodeMap does not inherit from NodeList; NamedNodeMaps are not maintained in any particular order. Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index, but this is simply to allow convenient enumeration of the contents of a NamedNodeMap, and does not imply that the DOM specifies an order to these Nodes.
+ * NamedNodeMap objects in the DOM are live.
+ * used for attributes or DocumentType entities
+ */
+function NamedNodeMap() {
+};
+
+function _findNodeIndex(list,node){
+ var i = list.length;
+ while(i--){
+ if(list[i] === node){return i}
+ }
+}
+
+function _addNamedNode(el,list,newAttr,oldAttr){
+ if(oldAttr){
+ list[_findNodeIndex(list,oldAttr)] = newAttr;
+ }else{
+ list[list.length++] = newAttr;
+ }
+ if(el){
+ newAttr.ownerElement = el;
+ var doc = el.ownerDocument;
+ if(doc){
+ oldAttr && _onRemoveAttribute(doc,el,oldAttr);
+ _onAddAttribute(doc,el,newAttr);
+ }
+ }
+}
+function _removeNamedNode(el,list,attr){
+ //console.log('remove attr:'+attr)
+ var i = _findNodeIndex(list,attr);
+ if(i>=0){
+ var lastIndex = list.length-1
+ while(i<lastIndex){
+ list[i] = list[++i]
+ }
+ list.length = lastIndex;
+ if(el){
+ var doc = el.ownerDocument;
+ if(doc){
+ _onRemoveAttribute(doc,el,attr);
+ attr.ownerElement = null;
+ }
+ }
+ }else{
+ throw DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr))
+ }
+}
+NamedNodeMap.prototype = {
+ length:0,
+ item:NodeList.prototype.item,
+ getNamedItem: function(key) {
+// if(key.indexOf(':')>0 || 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 == '<' && '&lt;' ||
+ c == '>' && '&gt;' ||
+ c == '&' && '&amp;' ||
+ c == '"' && '&quot;' ||
+ '&#'+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<len;i++){
+ // add namespaces for attributes
+ var attr = attrs.item(i);
+ if (attr.prefix == 'xmlns') {
+ visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
+ }else if(attr.nodeName == 'xmlns'){
+ visibleNamespaces.push({ prefix: '', namespace: attr.value });
+ }
+ }
+ for(var i=0;i<len;i++){
+ var attr = attrs.item(i);
+ if (needNamespaceDefine(attr,isHTML, visibleNamespaces)) {
+ var prefix = attr.prefix||'';
+ var uri = attr.namespaceURI;
+ var ns = prefix ? ' xmlns:' + prefix : " xmlns";
+ buf.push(ns, '="' , uri , '"');
+ visibleNamespaces.push({ prefix: prefix, namespace:uri });
+ }
+ serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
+ }
+ // add namespace for current node
+ if (needNamespaceDefine(node,isHTML, visibleNamespaces)) {
+ var prefix = node.prefix||'';
+ var uri = node.namespaceURI;
+ var ns = prefix ? ' xmlns:' + prefix : " xmlns";
+ buf.push(ns, '="' , uri , '"');
+ visibleNamespaces.push({ prefix: prefix, namespace:uri });
+ }
+
+ if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
+ buf.push('>');
+ //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('</',nodeName,'>');
+ }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( '<![CDATA[',node.data,']]>');
+ case COMMENT_NODE:
+ return buf.push( "<!--",node.data,"-->");
+ case DOCUMENT_TYPE_NODE:
+ var pubid = node.publicId;
+ var sysid = node.systemId;
+ buf.push('<!DOCTYPE ',node.name);
+ if(pubid){
+ buf.push(' PUBLIC "',pubid);
+ if (sysid && sysid!='.') {
+ buf.push( '" "',sysid);
+ }
+ 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( "<?",node.target," ",node.data,"?>");
+ 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<len;i++){
+ //node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep));
+ //}
+ case DOCUMENT_FRAGMENT_NODE:
+ break;
+ case ATTRIBUTE_NODE:
+ deep = true;
+ break;
+ //case ENTITY_REFERENCE_NODE:
+ //case PROCESSING_INSTRUCTION_NODE:
+ ////case TEXT_NODE:
+ //case CDATA_SECTION_NODE:
+ //case COMMENT_NODE:
+ // deep = false;
+ // break;
+ //case DOCUMENT_NODE:
+ //case DOCUMENT_TYPE_NODE:
+ //cannot be imported.
+ //case ENTITY_NODE:
+ //case NOTATION_NODE:
+ //can not hit in level3
+ //default:throw e;
+ }
+ if(!node2){
+ node2 = node.cloneNode(false);//false
+ }
+ node2.ownerDocument = doc;
+ node2.parentNode = null;
+ if(deep){
+ var child = node.firstChild;
+ while(child){
+ node2.appendChild(importNode(doc,child,deep));
+ child = child.nextSibling;
+ }
+ }
+ return node2;
+}
+//
+//var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
+// attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
+function cloneNode(doc,node,deep){
+ var node2 = new node.constructor();
+ for(var n in node){
+ var v = node[n];
+ if(typeof v != 'object' ){
+ if(v != node2[n]){
+ node2[n] = v;
+ }
+ }
+ }
+ if(node.childNodes){
+ node2.childNodes = new NodeList();
+ }
+ node2.ownerDocument = doc;
+ switch (node2.nodeType) {
+ case ELEMENT_NODE:
+ var attrs = node.attributes;
+ var attrs2 = node2.attributes = new NamedNodeMap();
+ var len = attrs.length
+ attrs2._ownerElement = node2;
+ for(var i=0;i<len;i++){
+ node2.setAttributeNode(cloneNode(doc,attrs.item(i),true));
+ }
+ break;;
+ case ATTRIBUTE_NODE:
+ deep = true;
+ }
+ if(deep){
+ var child = node.firstChild;
+ while(child){
+ node2.appendChild(cloneNode(doc,child,deep));
+ child = child.nextSibling;
+ }
+ }
+ return node2;
+}
+
+function __set__(object,key,value){
+ object[key] = value
+}
+//do dynamic
+try{
+ if(Object.defineProperty){
+ Object.defineProperty(LiveNodeList.prototype,'length',{
+ get:function(){
+ _updateLiveList(this);
+ return this.$$length;
+ }
+ });
+ Object.defineProperty(Node.prototype,'textContent',{
+ get:function(){
+ return getTextContent(this);
+ },
+ set:function(data){
+ switch(this.nodeType){
+ case ELEMENT_NODE:
+ case DOCUMENT_FRAGMENT_NODE:
+ while(this.firstChild){
+ this.removeChild(this.firstChild);
+ }
+ if(data || String(data)){
+ this.appendChild(this.ownerDocument.createTextNode(data));
+ }
+ break;
+ default:
+ //TODO:
+ this.data = data;
+ this.value = data;
+ this.nodeValue = data;
+ }
+ }
+ })
+
+ function getTextContent(node){
+ switch(node.nodeType){
+ case ELEMENT_NODE:
+ case DOCUMENT_FRAGMENT_NODE:
+ var buf = [];
+ node = node.firstChild;
+ while(node){
+ if(node.nodeType!==7 && node.nodeType !==8){
+ buf.push(getTextContent(node));
+ }
+ node = node.nextSibling;
+ }
+ return buf.join('');
+ default:
+ return node.nodeValue;
+ }
+ }
+ __set__ = function(object,key,value){
+ //console.log(value)
+ object['$$'+key] = value
+ }
+ }
+}catch(e){//ie8
+}
+
+//if(typeof require == 'function'){
+ exports.DOMImplementation = DOMImplementation;
+ exports.XMLSerializer = XMLSerializer;
+//}
+
+},{}],7:[function(require,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<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</)){
+ tagName = tagName.replace(/[\s<].*/,'');
+ errorHandler.error("end tag name: "+tagName+' maybe not complete');
+ end = tagStart+1+tagName.length;
+ }
+ //console.error(parseStack.length,parseStack)
+ //console.error(config);
+ var localNSMap = config.localNSMap;
+ var endMatch = config.tagName == tagName;
+ var endIgnoreCaseMach = endMatch || config.tagName&&config.tagName.toLowerCase() == tagName.toLowerCase()
+ if(endIgnoreCaseMach){
+ domBuilder.endElement(config.uri,config.localName,tagName);
+ if(localNSMap){
+ for(var prefix in localNSMap){
+ domBuilder.endPrefixMapping(prefix) ;
+ }
+ }
+ if(!endMatch){
+ errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName );
+ }
+ }else{
+ parseStack.push(config)
+ }
+
+ end++;
+ break;
+ // end elment
+ case '?':// <?...?>
+ locator&&position(tagStart);
+ end = parseInstruction(source,tagStart,domBuilder);
+ break;
+ case '!':// <!doctype,<![CDATA,<!--
+ locator&&position(tagStart);
+ end = parseDCC(source,tagStart,domBuilder,errorHandler);
+ break;
+ default:
+ locator&&position(tagStart);
+ var el = new ElementAttributes();
+ var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
+ //elStartEnd
+ var end = parseElementStartPart(source,tagStart,el,currentNSMap,entityReplacer,errorHandler);
+ var len = el.length;
+
+
+ if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){
+ el.closed = true;
+ if(!entityMap.nbsp){
+ errorHandler.warning('unclosed xml attribute');
+ }
+ }
+ if(locator && len){
+ var locator2 = copyLocator(locator,{});
+ //try{//attribute position fixed
+ for(var i = 0;i<len;i++){
+ var a = el[i];
+ position(a.offset);
+ a.locator = copyLocator(locator,{});
+ }
+ //}catch(e){console.error('@@@@@'+e)}
+ domBuilder.locator = locator2
+ if(appendElement(el,domBuilder,currentNSMap)){
+ parseStack.push(el)
+ }
+ domBuilder.locator = locator;
+ }else{
+ if(appendElement(el,domBuilder,currentNSMap)){
+ parseStack.push(el)
+ }
+ }
+
+
+
+ if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){
+ end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder)
+ }else{
+ end++;
+ }
+ }
+ }catch(e){
+ errorHandler.error('element parse error: '+e)
+ //errorHandler.error('element parse error: '+e);
+ end = -1;
+ //throw e;
+ }
+ if(end>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('</'+tagName+'>',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('</'+tagName+'>')
+ if(pos<elStartEnd){//忘记闭合
+ pos = source.lastIndexOf('</'+tagName)
+ }
+ closeMap[tagName] =pos
+ }
+ return pos<elStartEnd;
+ //}
+}
+function _copy(source,target){
+ for(var n in source){target[n] = source[n]}
+}
+function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
+ var next= source.charAt(start+2)
+ switch(next){
+ case '-':
+ if(source.charAt(start + 3) === '-'){
+ var end = source.indexOf('-->',start+4);
+ //append comment source.substring(4,end)//<!--
+ if(end>start){
+ domBuilder.comment(source,start+4,end-start-4);
+ return end+3;
+ }else{
+ errorHandler.error("Unclosed comment");
+ return -1;
+ }
+ }else{
+ //error
+ return -1;
+ }
+ default:
+ if(source.substr(start+3,6) == 'CDATA['){
+ var end = source.indexOf(']]>',start+9);
+ domBuilder.startCDATA();
+ domBuilder.characters(source,start+9,end-start-9);
+ domBuilder.endCDATA()
+ return end+3;
+ }
+ //<!DOCTYPE
+ //startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
+ var matchs = split(source,start);
+ var len = matchs.length;
+ if(len>1 && /!doctype/i.test(matchs[0][0])){
+ var name = matchs[1][0];
+ var pubid = len>3 && /^public$/i.test(matchs[2][0]) && matchs[3][0]
+ var sysid = len>4 && matchs[4][0];
+ var lastMatch = matchs[len-1]
+ domBuilder.startDTD(name,pubid && pubid.replace(/^(['"])(.*?)\1$/,'$2'),
+ sysid && sysid.replace(/^(['"])(.*?)\1$/,'$2'));
+ domBuilder.endDTD();
+
+ return lastMatch.index+lastMatch[0].length
+ }
+ }
+ return -1;
+}
+
+
+
+function parseInstruction(source,start,domBuilder){
+ var end = source.indexOf('?>',start);
+ if(end){
+ var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
+ if(match){
+ var len = match[0].length;
+ domBuilder.processingInstruction(match[1], match[2]) ;
+ return end+2;
+ }else{//error
+ return -1;
+ }
+ }
+ return -1;
+}
+
+/**
+ * @param source
+ */
+function ElementAttributes(source){
+
+}
+ElementAttributes.prototype = {
+ setTagName:function(tagName){
+ if(!tagNamePattern.test(tagName)){
+ throw new Error('invalid tagName:'+tagName)
+ }
+ this.tagName = tagName
+ },
+ add:function(qName,value,offset){
+ if(!tagNamePattern.test(qName)){
+ throw new Error('invalid attribute:'+qName)
+ }
+ this[this.length++] = {qName:qName,value:value,offset:offset}
+ },
+ length:0,
+ getLocalName:function(i){return this[i].localName},
+ getLocator:function(i){return this[i].locator},
+ getQName:function(i){return this[i].qName},
+ getURI:function(i){return this[i].uri},
+ getValue:function(i){return this[i].value}
+// ,getIndex:function(uri, localName)){
+// if(localName){
+//
+// }else{
+// var qName = uri
+// }
+// },
+// getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
+// getType:function(uri,localName){}
+// getType:function(i){},
+}
+
+
+
+
+function _set_proto_(thiz,parent){
+ thiz.__proto__ = parent;
+ return thiz;
+}
+if(!(_set_proto_({},_set_proto_.prototype) instanceof _set_proto_)){
+ _set_proto_ = function(thiz,parent){
+ function p(){};
+ p.prototype = parent;
+ p = new p();
+ for(parent in thiz){
+ p[parent] = thiz[parent];
+ }
+ return p;
+ }
+}
+
+function split(source,start){
+ var match;
+ var buf = [];
+ var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
+ reg.lastIndex = start;
+ reg.exec(source);//skip <
+ while(match = reg.exec(source)){
+ buf.push(match);
+ if(match[1])return buf;
+ }
+}
+
+exports.XMLReader = XMLReader;
+
+
+},{}]},{},[1])(1)
+});
diff --git a/cordova/node_modules/ios-sim/node_modules/plist/dist/plist.js b/cordova/node_modules/ios-sim/node_modules/plist/dist/plist.js
new file mode 100644
index 0000000..40f6e41
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/plist/dist/plist.js
@@ -0,0 +1,7024 @@
+(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.plist = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
+/**
+ * Parser functions.
+ */
+
+var parserFunctions = require('./lib/parse');
+Object.keys(parserFunctions).forEach(function (k) { exports[k] = parserFunctions[k]; });
+
+/**
+ * Builder functions.
+ */
+
+var builderFunctions = require('./lib/build');
+Object.keys(builderFunctions).forEach(function (k) { exports[k] = builderFunctions[k]; });
+
+},{"./lib/build":2,"./lib/parse":3}],2:[function(require,module,exports){
+(function (Buffer){
+/**
+ * Module dependencies.
+ */
+
+var base64 = require('base64-js');
+var xmlbuilder = require('xmlbuilder');
+
+/**
+ * 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));
+
+ }
+}
+
+}).call(this,{"isBuffer":require("../node_modules/is-buffer/index.js")})
+},{"../node_modules/is-buffer/index.js":7,"base64-js":4,"xmlbuilder":29}],3:[function(require,module,exports){
+(function (Buffer){
+/**
+ * Module dependencies.
+ */
+
+var DOMParser = require('xmldom').DOMParser;
+
+/**
+ * Module exports.
+ */
+
+exports.parse = parse;
+
+var TEXT_NODE = 3;
+var CDATA_NODE = 4;
+var COMMENT_NODE = 8;
+
+
+/**
+ * We ignore raw text (usually whitespace), <!-- xml comments -->,
+ * and raw CDATA nodes.
+ *
+ * @param {Element} node
+ * @returns {Boolean}
+ * @api private
+ */
+
+function shouldIgnoreNode (node) {
+ return node.nodeType === TEXT_NODE
+ || node.nodeType === COMMENT_NODE
+ || node.nodeType === CDATA_NODE;
+}
+
+/**
+ * Check if the node is empty. Some plist file has such node:
+ * <key />
+ * this node shoud be ignored.
+ *
+ * @see https://github.com/TooTallNate/plist.js/issues/66
+ * @param {Element} node
+ * @returns {Boolean}
+ * @api private
+ */
+function isEmptyNode(node){
+ if(!node.childNodes || node.childNodes.length === 0) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+function invariant(test, message) {
+ if (!test) {
+ throw new Error(message);
+ }
+}
+
+/**
+ * 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);
+ invariant(
+ doc.documentElement.nodeName === 'plist',
+ 'malformed document. First element should be <plist>'
+ );
+ var plist = parsePlistXML(doc.documentElement);
+
+ // the root <plist> node gets interpreted as an Array,
+ // so pull out the inner data first
+ 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, counter, type;
+
+ if (!node)
+ return null;
+
+ if (node.nodeName === 'plist') {
+ new_arr = [];
+ if (isEmptyNode(node)) {
+ return new_arr;
+ }
+ for (i=0; i < node.childNodes.length; i++) {
+ if (!shouldIgnoreNode(node.childNodes[i])) {
+ new_arr.push( parsePlistXML(node.childNodes[i]));
+ }
+ }
+ return new_arr;
+ } else if (node.nodeName === 'dict') {
+ new_obj = {};
+ key = null;
+ counter = 0;
+ if (isEmptyNode(node)) {
+ return new_obj;
+ }
+ for (i=0; i < node.childNodes.length; i++) {
+ if (shouldIgnoreNode(node.childNodes[i])) continue;
+ if (counter % 2 === 0) {
+ invariant(
+ node.childNodes[i].nodeName === 'key',
+ 'Missing key while parsing <dict/>.'
+ );
+ key = parsePlistXML(node.childNodes[i]);
+ } else {
+ invariant(
+ node.childNodes[i].nodeName !== 'key',
+ 'Unexpected key "'
+ + parsePlistXML(node.childNodes[i])
+ + '" while parsing <dict/>.'
+ );
+ new_obj[key] = parsePlistXML(node.childNodes[i]);
+ }
+ counter += 1;
+ }
+ if (counter % 2 === 1) {
+ throw new Error('Missing value for "' + key + '" while parsing <dict/>');
+ }
+ return new_obj;
+
+ } else if (node.nodeName === 'array') {
+ new_arr = [];
+ if (isEmptyNode(node)) {
+ return new_arr;
+ }
+ for (i=0; i < node.childNodes.length; i++) {
+ 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') {
+ if (isEmptyNode(node)) {
+ return '';
+ }
+ return node.childNodes[0].nodeValue;
+ } else if (node.nodeName === 'string') {
+ res = '';
+ if (isEmptyNode(node)) {
+ return res;
+ }
+ for (i=0; i < node.childNodes.length; i++) {
+ var type = node.childNodes[i].nodeType;
+ if (type === TEXT_NODE || type === CDATA_NODE) {
+ res += node.childNodes[i].nodeValue;
+ }
+ }
+ return res;
+
+ } else if (node.nodeName === 'integer') {
+ invariant(
+ !isEmptyNode(node),
+ 'Cannot parse "" as integer.'
+ );
+ return parseInt(node.childNodes[0].nodeValue, 10);
+
+ } else if (node.nodeName === 'real') {
+ invariant(
+ !isEmptyNode(node),
+ 'Cannot parse "" as real.'
+ );
+ res = '';
+ for (i=0; i < node.childNodes.length; i++) {
+ if (node.childNodes[i].nodeType === TEXT_NODE) {
+ res += node.childNodes[i].nodeValue;
+ }
+ }
+ return parseFloat(res);
+
+ } else if (node.nodeName === 'data') {
+ res = '';
+ if (isEmptyNode(node)) {
+ return Buffer.from(res, 'base64');
+ }
+ for (i=0; i < node.childNodes.length; i++) {
+ if (node.childNodes[i].nodeType === TEXT_NODE) {
+ res += node.childNodes[i].nodeValue.replace(/\s+/g, '');
+ }
+ }
+ return Buffer.from(res, 'base64');
+
+ } else if (node.nodeName === 'date') {
+ invariant(
+ !isEmptyNode(node),
+ 'Cannot parse "" as Date.'
+ )
+ return new Date(node.childNodes[0].nodeValue);
+
+ } else if (node.nodeName === 'true') {
+ return true;
+
+ } else if (node.nodeName === 'false') {
+ return false;
+ }
+}
+
+}).call(this,require("buffer").Buffer)
+},{"buffer":5,"xmldom":30}],4:[function(require,module,exports){
+'use strict'
+
+exports.byteLength = byteLength
+exports.toByteArray = toByteArray
+exports.fromByteArray = fromByteArray
+
+var lookup = []
+var revLookup = []
+var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
+
+var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
+for (var i = 0, len = code.length; i < len; ++i) {
+ lookup[i] = code[i]
+ revLookup[code.charCodeAt(i)] = i
+}
+
+// Support decoding URL-safe base64 strings, as Node.js does.
+// See: https://en.wikipedia.org/wiki/Base64#URL_applications
+revLookup['-'.charCodeAt(0)] = 62
+revLookup['_'.charCodeAt(0)] = 63
+
+function placeHoldersCount (b64) {
+ var len = b64.length
+ if (len % 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
+ return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
+}
+
+function byteLength (b64) {
+ // base64 is 4/3 + up to two characters of the original data
+ return (b64.length * 3 / 4) - placeHoldersCount(b64)
+}
+
+function toByteArray (b64) {
+ var i, l, tmp, placeHolders, arr
+ var len = b64.length
+ placeHolders = placeHoldersCount(b64)
+
+ arr = new Arr((len * 3 / 4) - placeHolders)
+
+ // if there are placeholders, only get up to the last complete 4 chars
+ l = placeHolders > 0 ? len - 4 : len
+
+ var L = 0
+
+ for (i = 0; i < l; i += 4) {
+ tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
+ arr[L++] = (tmp >> 16) & 0xFF
+ arr[L++] = (tmp >> 8) & 0xFF
+ arr[L++] = tmp & 0xFF
+ }
+
+ if (placeHolders === 2) {
+ tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
+ arr[L++] = tmp & 0xFF
+ } else if (placeHolders === 1) {
+ tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
+ arr[L++] = (tmp >> 8) & 0xFF
+ arr[L++] = tmp & 0xFF
+ }
+
+ return arr
+}
+
+function tripletToBase64 (num) {
+ return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
+}
+
+function encodeChunk (uint8, start, end) {
+ var tmp
+ var output = []
+ for (var i = start; i < end; i += 3) {
+ tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF)
+ output.push(tripletToBase64(tmp))
+ }
+ return output.join('')
+}
+
+function fromByteArray (uint8) {
+ var tmp
+ var len = uint8.length
+ var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
+ var output = ''
+ var parts = []
+ var maxChunkLength = 16383 // must be multiple of 3
+
+ // go through the array every three bytes, we'll deal with trailing stuff later
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
+ parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
+ }
+
+ // pad the end with zeros, but make sure to not forget the extra bytes
+ if (extraBytes === 1) {
+ tmp = uint8[len - 1]
+ output += lookup[tmp >> 2]
+ output += lookup[(tmp << 4) & 0x3F]
+ output += '=='
+ } else if (extraBytes === 2) {
+ tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
+ output += lookup[tmp >> 10]
+ output += lookup[(tmp >> 4) & 0x3F]
+ output += lookup[(tmp << 2) & 0x3F]
+ output += '='
+ }
+
+ parts.push(output)
+
+ return parts.join('')
+}
+
+},{}],5:[function(require,module,exports){
+/*!
+ * The buffer module from node.js, for the browser.
+ *
+ * @author Feross Aboukhadijeh <https://feross.org>
+ * @license MIT
+ */
+/* eslint-disable no-proto */
+
+'use strict'
+
+var base64 = require('base64-js')
+var ieee754 = require('ieee754')
+
+exports.Buffer = Buffer
+exports.SlowBuffer = SlowBuffer
+exports.INSPECT_MAX_BYTES = 50
+
+var K_MAX_LENGTH = 0x7fffffff
+exports.kMaxLength = K_MAX_LENGTH
+
+/**
+ * If `Buffer.TYPED_ARRAY_SUPPORT`:
+ * === true Use Uint8Array implementation (fastest)
+ * === false Print warning and recommend using `buffer` v4.x which has an Object
+ * implementation (most compatible, even IE6)
+ *
+ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
+ * Opera 11.6+, iOS 4.2+.
+ *
+ * We report that the browser does not support typed arrays if the are not subclassable
+ * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
+ * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
+ * for __proto__ and has a buggy typed array implementation.
+ */
+Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
+
+if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
+ typeof console.error === 'function') {
+ console.error(
+ 'This browser lacks typed array (Uint8Array) support which is required by ' +
+ '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
+ )
+}
+
+function typedArraySupport () {
+ // Can typed array instances can be augmented?
+ try {
+ var arr = new Uint8Array(1)
+ arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
+ return arr.foo() === 42
+ } catch (e) {
+ return false
+ }
+}
+
+Object.defineProperty(Buffer.prototype, 'parent', {
+ get: function () {
+ if (!(this instanceof Buffer)) {
+ return undefined
+ }
+ return this.buffer
+ }
+})
+
+Object.defineProperty(Buffer.prototype, 'offset', {
+ get: function () {
+ if (!(this instanceof Buffer)) {
+ return undefined
+ }
+ return this.byteOffset
+ }
+})
+
+function createBuffer (length) {
+ if (length > K_MAX_LENGTH) {
+ throw new RangeError('Invalid typed array length')
+ }
+ // Return an augmented `Uint8Array` instance
+ var buf = new Uint8Array(length)
+ buf.__proto__ = Buffer.prototype
+ return buf
+}
+
+/**
+ * The Buffer constructor returns instances of `Uint8Array` that have their
+ * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
+ * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
+ * and the `Uint8Array` methods. Square bracket notation works as expected -- it
+ * returns a single octet.
+ *
+ * The `Uint8Array` prototype remains unmodified.
+ */
+
+function Buffer (arg, encodingOrOffset, length) {
+ // Common case.
+ if (typeof arg === 'number') {
+ if (typeof encodingOrOffset === 'string') {
+ throw new Error(
+ 'If encoding is specified then the first argument must be a string'
+ )
+ }
+ return allocUnsafe(arg)
+ }
+ return from(arg, encodingOrOffset, length)
+}
+
+// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
+if (typeof Symbol !== 'undefined' && Symbol.species &&
+ Buffer[Symbol.species] === Buffer) {
+ Object.defineProperty(Buffer, Symbol.species, {
+ value: null,
+ configurable: true,
+ enumerable: false,
+ writable: false
+ })
+}
+
+Buffer.poolSize = 8192 // not used by this implementation
+
+function from (value, encodingOrOffset, length) {
+ if (typeof value === 'number') {
+ throw new TypeError('"value" argument must not be a number')
+ }
+
+ if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) {
+ return fromArrayBuffer(value, encodingOrOffset, length)
+ }
+
+ if (typeof value === 'string') {
+ return fromString(value, encodingOrOffset)
+ }
+
+ return fromObject(value)
+}
+
+/**
+ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
+ * if value is a number.
+ * Buffer.from(str[, encoding])
+ * Buffer.from(array)
+ * Buffer.from(buffer)
+ * Buffer.from(arrayBuffer[, byteOffset[, length]])
+ **/
+Buffer.from = function (value, encodingOrOffset, length) {
+ return from(value, encodingOrOffset, length)
+}
+
+// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
+// https://github.com/feross/buffer/pull/148
+Buffer.prototype.__proto__ = Uint8Array.prototype
+Buffer.__proto__ = Uint8Array
+
+function assertSize (size) {
+ if (typeof size !== 'number') {
+ throw new TypeError('"size" argument must be of type number')
+ } else if (size < 0) {
+ throw new RangeError('"size" argument must not be negative')
+ }
+}
+
+function alloc (size, fill, encoding) {
+ assertSize(size)
+ if (size <= 0) {
+ return createBuffer(size)
+ }
+ if (fill !== undefined) {
+ // Only pay attention to encoding if it's a string. This
+ // prevents accidentally sending in a number that would
+ // be interpretted as a start offset.
+ return typeof encoding === 'string'
+ ? createBuffer(size).fill(fill, encoding)
+ : createBuffer(size).fill(fill)
+ }
+ return createBuffer(size)
+}
+
+/**
+ * Creates a new filled Buffer instance.
+ * alloc(size[, fill[, encoding]])
+ **/
+Buffer.alloc = function (size, fill, encoding) {
+ return alloc(size, fill, encoding)
+}
+
+function allocUnsafe (size) {
+ assertSize(size)
+ return createBuffer(size < 0 ? 0 : checked(size) | 0)
+}
+
+/**
+ * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
+ * */
+Buffer.allocUnsafe = function (size) {
+ return allocUnsafe(size)
+}
+/**
+ * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
+ */
+Buffer.allocUnsafeSlow = function (size) {
+ return allocUnsafe(size)
+}
+
+function fromString (string, encoding) {
+ if (typeof encoding !== 'string' || encoding === '') {
+ encoding = 'utf8'
+ }
+
+ if (!Buffer.isEncoding(encoding)) {
+ throw new TypeError('Unknown encoding: ' + encoding)
+ }
+
+ var length = byteLength(string, encoding) | 0
+ var buf = createBuffer(length)
+
+ var actual = buf.write(string, encoding)
+
+ if (actual !== length) {
+ // Writing a hex string, for example, that contains invalid characters will
+ // cause everything after the first invalid character to be ignored. (e.g.
+ // 'abxxcd' will be treated as 'ab')
+ buf = buf.slice(0, actual)
+ }
+
+ return buf
+}
+
+function fromArrayLike (array) {
+ var length = array.length < 0 ? 0 : checked(array.length) | 0
+ var buf = createBuffer(length)
+ for (var i = 0; i < length; i += 1) {
+ buf[i] = array[i] & 255
+ }
+ return buf
+}
+
+function fromArrayBuffer (array, byteOffset, length) {
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
+ throw new RangeError('"offset" is outside of buffer bounds')
+ }
+
+ if (array.byteLength < byteOffset + (length || 0)) {
+ throw new RangeError('"length" is outside of buffer bounds')
+ }
+
+ var buf
+ if (byteOffset === undefined && length === undefined) {
+ buf = new Uint8Array(array)
+ } else if (length === undefined) {
+ buf = new Uint8Array(array, byteOffset)
+ } else {
+ buf = new Uint8Array(array, byteOffset, length)
+ }
+
+ // Return an augmented `Uint8Array` instance
+ buf.__proto__ = Buffer.prototype
+ return buf
+}
+
+function fromObject (obj) {
+ if (Buffer.isBuffer(obj)) {
+ var len = checked(obj.length) | 0
+ var buf = createBuffer(len)
+
+ if (buf.length === 0) {
+ return buf
+ }
+
+ obj.copy(buf, 0, 0, len)
+ return buf
+ }
+
+ if (obj) {
+ if (ArrayBuffer.isView(obj) || 'length' in obj) {
+ if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
+ return createBuffer(0)
+ }
+ return fromArrayLike(obj)
+ }
+
+ if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
+ return fromArrayLike(obj.data)
+ }
+ }
+
+ throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.')
+}
+
+function checked (length) {
+ // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
+ // length is NaN (which is otherwise coerced to zero.)
+ if (length >= K_MAX_LENGTH) {
+ throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
+ 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
+ }
+ return length | 0
+}
+
+function SlowBuffer (length) {
+ if (+length != length) { // eslint-disable-line eqeqeq
+ length = 0
+ }
+ return Buffer.alloc(+length)
+}
+
+Buffer.isBuffer = function isBuffer (b) {
+ return b != null && b._isBuffer === true
+}
+
+Buffer.compare = function compare (a, b) {
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
+ throw new TypeError('Arguments must be Buffers')
+ }
+
+ if (a === b) return 0
+
+ var x = a.length
+ var y = b.length
+
+ for (var i = 0, len = Math.min(x, y); i < len; ++i) {
+ if (a[i] !== b[i]) {
+ x = a[i]
+ y = b[i]
+ break
+ }
+ }
+
+ if (x < y) return -1
+ if (y < x) return 1
+ return 0
+}
+
+Buffer.isEncoding = function isEncoding (encoding) {
+ switch (String(encoding).toLowerCase()) {
+ case 'hex':
+ case 'utf8':
+ case 'utf-8':
+ case 'ascii':
+ case 'latin1':
+ case 'binary':
+ case 'base64':
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return true
+ default:
+ return false
+ }
+}
+
+Buffer.concat = function concat (list, length) {
+ if (!Array.isArray(list)) {
+ throw new TypeError('"list" argument must be an Array of Buffers')
+ }
+
+ if (list.length === 0) {
+ return Buffer.alloc(0)
+ }
+
+ var i
+ if (length === undefined) {
+ length = 0
+ for (i = 0; i < list.length; ++i) {
+ length += list[i].length
+ }
+ }
+
+ var buffer = Buffer.allocUnsafe(length)
+ var pos = 0
+ for (i = 0; i < list.length; ++i) {
+ var buf = list[i]
+ if (ArrayBuffer.isView(buf)) {
+ buf = Buffer.from(buf)
+ }
+ if (!Buffer.isBuffer(buf)) {
+ throw new TypeError('"list" argument must be an Array of Buffers')
+ }
+ buf.copy(buffer, pos)
+ pos += buf.length
+ }
+ return buffer
+}
+
+function byteLength (string, encoding) {
+ if (Buffer.isBuffer(string)) {
+ return string.length
+ }
+ if (ArrayBuffer.isView(string) || isArrayBuffer(string)) {
+ return string.byteLength
+ }
+ if (typeof string !== 'string') {
+ string = '' + string
+ }
+
+ var len = string.length
+ if (len === 0) return 0
+
+ // Use a for loop to avoid recursion
+ var loweredCase = false
+ for (;;) {
+ switch (encoding) {
+ case 'ascii':
+ case 'latin1':
+ case 'binary':
+ return len
+ case 'utf8':
+ case 'utf-8':
+ case undefined:
+ return utf8ToBytes(string).length
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return len * 2
+ case 'hex':
+ return len >>> 1
+ case 'base64':
+ return base64ToBytes(string).length
+ default:
+ if (loweredCase) return utf8ToBytes(string).length // assume utf8
+ encoding = ('' + encoding).toLowerCase()
+ loweredCase = true
+ }
+ }
+}
+Buffer.byteLength = byteLength
+
+function slowToString (encoding, start, end) {
+ var loweredCase = false
+
+ // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
+ // property of a typed array.
+
+ // This behaves neither like String nor Uint8Array in that we set start/end
+ // to their upper/lower bounds if the value passed is out of range.
+ // undefined is handled specially as per ECMA-262 6th Edition,
+ // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
+ if (start === undefined || start < 0) {
+ start = 0
+ }
+ // Return early if start > this.length. Done here to prevent potential uint32
+ // coercion fail below.
+ if (start > this.length) {
+ return ''
+ }
+
+ if (end === undefined || end > this.length) {
+ end = this.length
+ }
+
+ if (end <= 0) {
+ return ''
+ }
+
+ // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
+ end >>>= 0
+ start >>>= 0
+
+ if (end <= start) {
+ return ''
+ }
+
+ if (!encoding) encoding = 'utf8'
+
+ while (true) {
+ switch (encoding) {
+ case 'hex':
+ return hexSlice(this, start, end)
+
+ case 'utf8':
+ case 'utf-8':
+ return utf8Slice(this, start, end)
+
+ case 'ascii':
+ return asciiSlice(this, start, end)
+
+ case 'latin1':
+ case 'binary':
+ return latin1Slice(this, start, end)
+
+ case 'base64':
+ return base64Slice(this, start, end)
+
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return utf16leSlice(this, start, end)
+
+ default:
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
+ encoding = (encoding + '').toLowerCase()
+ loweredCase = true
+ }
+ }
+}
+
+// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
+// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
+// reliably in a browserify context because there could be multiple different
+// copies of the 'buffer' package in use. This method works even for Buffer
+// instances that were created from another copy of the `buffer` package.
+// See: https://github.com/feross/buffer/issues/154
+Buffer.prototype._isBuffer = true
+
+function swap (b, n, m) {
+ var i = b[n]
+ b[n] = b[m]
+ b[m] = i
+}
+
+Buffer.prototype.swap16 = function swap16 () {
+ var len = this.length
+ if (len % 2 !== 0) {
+ throw new RangeError('Buffer size must be a multiple of 16-bits')
+ }
+ for (var i = 0; i < len; i += 2) {
+ swap(this, i, i + 1)
+ }
+ return this
+}
+
+Buffer.prototype.swap32 = function swap32 () {
+ var len = this.length
+ if (len % 4 !== 0) {
+ throw new RangeError('Buffer size must be a multiple of 32-bits')
+ }
+ for (var i = 0; i < len; i += 4) {
+ swap(this, i, i + 3)
+ swap(this, i + 1, i + 2)
+ }
+ return this
+}
+
+Buffer.prototype.swap64 = function swap64 () {
+ var len = this.length
+ if (len % 8 !== 0) {
+ throw new RangeError('Buffer size must be a multiple of 64-bits')
+ }
+ for (var i = 0; i < len; i += 8) {
+ swap(this, i, i + 7)
+ swap(this, i + 1, i + 6)
+ swap(this, i + 2, i + 5)
+ swap(this, i + 3, i + 4)
+ }
+ return this
+}
+
+Buffer.prototype.toString = function toString () {
+ var length = this.length
+ if (length === 0) return ''
+ if (arguments.length === 0) return utf8Slice(this, 0, length)
+ return slowToString.apply(this, arguments)
+}
+
+Buffer.prototype.toLocaleString = Buffer.prototype.toString
+
+Buffer.prototype.equals = function equals (b) {
+ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
+ if (this === b) return true
+ return Buffer.compare(this, b) === 0
+}
+
+Buffer.prototype.inspect = function inspect () {
+ var str = ''
+ var max = exports.INSPECT_MAX_BYTES
+ if (this.length > 0) {
+ str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
+ if (this.length > max) str += ' ... '
+ }
+ return '<Buffer ' + str + '>'
+}
+
+Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
+ if (!Buffer.isBuffer(target)) {
+ throw new TypeError('Argument must be a Buffer')
+ }
+
+ if (start === undefined) {
+ start = 0
+ }
+ if (end === undefined) {
+ end = target ? target.length : 0
+ }
+ if (thisStart === undefined) {
+ thisStart = 0
+ }
+ if (thisEnd === undefined) {
+ thisEnd = this.length
+ }
+
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
+ throw new RangeError('out of range index')
+ }
+
+ if (thisStart >= thisEnd && start >= end) {
+ return 0
+ }
+ if (thisStart >= thisEnd) {
+ return -1
+ }
+ if (start >= end) {
+ return 1
+ }
+
+ start >>>= 0
+ end >>>= 0
+ thisStart >>>= 0
+ thisEnd >>>= 0
+
+ if (this === target) return 0
+
+ var x = thisEnd - thisStart
+ var y = end - start
+ var len = Math.min(x, y)
+
+ var thisCopy = this.slice(thisStart, thisEnd)
+ var targetCopy = target.slice(start, end)
+
+ for (var i = 0; i < len; ++i) {
+ if (thisCopy[i] !== targetCopy[i]) {
+ x = thisCopy[i]
+ y = targetCopy[i]
+ break
+ }
+ }
+
+ if (x < y) return -1
+ if (y < x) return 1
+ return 0
+}
+
+// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
+// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
+//
+// Arguments:
+// - buffer - a Buffer to search
+// - val - a string, Buffer, or number
+// - byteOffset - an index into `buffer`; will be clamped to an int32
+// - encoding - an optional encoding, relevant is val is a string
+// - dir - true for indexOf, false for lastIndexOf
+function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
+ // Empty buffer means no match
+ if (buffer.length === 0) return -1
+
+ // Normalize byteOffset
+ if (typeof byteOffset === 'string') {
+ encoding = byteOffset
+ byteOffset = 0
+ } else if (byteOffset > 0x7fffffff) {
+ byteOffset = 0x7fffffff
+ } else if (byteOffset < -0x80000000) {
+ byteOffset = -0x80000000
+ }
+ byteOffset = +byteOffset // Coerce to Number.
+ if (numberIsNaN(byteOffset)) {
+ // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
+ byteOffset = dir ? 0 : (buffer.length - 1)
+ }
+
+ // Normalize byteOffset: negative offsets start from the end of the buffer
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset
+ if (byteOffset >= buffer.length) {
+ if (dir) return -1
+ else byteOffset = buffer.length - 1
+ } else if (byteOffset < 0) {
+ if (dir) byteOffset = 0
+ else return -1
+ }
+
+ // Normalize val
+ if (typeof val === 'string') {
+ val = Buffer.from(val, encoding)
+ }
+
+ // Finally, search either indexOf (if dir is true) or lastIndexOf
+ if (Buffer.isBuffer(val)) {
+ // Special case: looking for empty string/buffer always fails
+ if (val.length === 0) {
+ return -1
+ }
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
+ } else if (typeof val === 'number') {
+ val = val & 0xFF // Search for a byte value [0-255]
+ if (typeof Uint8Array.prototype.indexOf === 'function') {
+ if (dir) {
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
+ } else {
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
+ }
+ }
+ return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
+ }
+
+ throw new TypeError('val must be string, number or Buffer')
+}
+
+function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
+ var indexSize = 1
+ var arrLength = arr.length
+ var valLength = val.length
+
+ if (encoding !== undefined) {
+ encoding = String(encoding).toLowerCase()
+ if (encoding === 'ucs2' || encoding === 'ucs-2' ||
+ encoding === 'utf16le' || encoding === 'utf-16le') {
+ if (arr.length < 2 || val.length < 2) {
+ return -1
+ }
+ indexSize = 2
+ arrLength /= 2
+ valLength /= 2
+ byteOffset /= 2
+ }
+ }
+
+ function read (buf, i) {
+ if (indexSize === 1) {
+ return buf[i]
+ } else {
+ return buf.readUInt16BE(i * indexSize)
+ }
+ }
+
+ var i
+ if (dir) {
+ var foundIndex = -1
+ for (i = byteOffset; i < arrLength; i++) {
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
+ if (foundIndex === -1) foundIndex = i
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
+ } else {
+ if (foundIndex !== -1) i -= i - foundIndex
+ foundIndex = -1
+ }
+ }
+ } else {
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
+ for (i = byteOffset; i >= 0; i--) {
+ var found = true
+ for (var j = 0; j < valLength; j++) {
+ if (read(arr, i + j) !== read(val, j)) {
+ found = false
+ break
+ }
+ }
+ if (found) return i
+ }
+ }
+
+ return -1
+}
+
+Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
+ return this.indexOf(val, byteOffset, encoding) !== -1
+}
+
+Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
+}
+
+Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
+}
+
+function hexWrite (buf, string, offset, length) {
+ offset = Number(offset) || 0
+ var remaining = buf.length - offset
+ if (!length) {
+ length = remaining
+ } else {
+ length = Number(length)
+ if (length > remaining) {
+ length = remaining
+ }
+ }
+
+ var strLen = string.length
+
+ if (length > strLen / 2) {
+ length = strLen / 2
+ }
+ for (var i = 0; i < length; ++i) {
+ var parsed = parseInt(string.substr(i * 2, 2), 16)
+ if (numberIsNaN(parsed)) return i
+ buf[offset + i] = parsed
+ }
+ return i
+}
+
+function utf8Write (buf, string, offset, length) {
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
+}
+
+function asciiWrite (buf, string, offset, length) {
+ return blitBuffer(asciiToBytes(string), buf, offset, length)
+}
+
+function latin1Write (buf, string, offset, length) {
+ return asciiWrite(buf, string, offset, length)
+}
+
+function base64Write (buf, string, offset, length) {
+ return blitBuffer(base64ToBytes(string), buf, offset, length)
+}
+
+function ucs2Write (buf, string, offset, length) {
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
+}
+
+Buffer.prototype.write = function write (string, offset, length, encoding) {
+ // Buffer#write(string)
+ if (offset === undefined) {
+ encoding = 'utf8'
+ length = this.length
+ offset = 0
+ // Buffer#write(string, encoding)
+ } else if (length === undefined && typeof offset === 'string') {
+ encoding = offset
+ length = this.length
+ offset = 0
+ // Buffer#write(string, offset[, length][, encoding])
+ } else if (isFinite(offset)) {
+ offset = offset >>> 0
+ if (isFinite(length)) {
+ length = length >>> 0
+ if (encoding === undefined) encoding = 'utf8'
+ } else {
+ encoding = length
+ length = undefined
+ }
+ } else {
+ throw new Error(
+ 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
+ )
+ }
+
+ var remaining = this.length - offset
+ if (length === undefined || length > remaining) length = remaining
+
+ if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
+ throw new RangeError('Attempt to write outside buffer bounds')
+ }
+
+ if (!encoding) encoding = 'utf8'
+
+ var loweredCase = false
+ for (;;) {
+ switch (encoding) {
+ case 'hex':
+ return hexWrite(this, string, offset, length)
+
+ case 'utf8':
+ case 'utf-8':
+ return utf8Write(this, string, offset, length)
+
+ case 'ascii':
+ return asciiWrite(this, string, offset, length)
+
+ case 'latin1':
+ case 'binary':
+ return latin1Write(this, string, offset, length)
+
+ case 'base64':
+ // Warning: maxLength not taken into account in base64Write
+ return base64Write(this, string, offset, length)
+
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return ucs2Write(this, string, offset, length)
+
+ default:
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
+ encoding = ('' + encoding).toLowerCase()
+ loweredCase = true
+ }
+ }
+}
+
+Buffer.prototype.toJSON = function toJSON () {
+ return {
+ type: 'Buffer',
+ data: Array.prototype.slice.call(this._arr || this, 0)
+ }
+}
+
+function base64Slice (buf, start, end) {
+ if (start === 0 && end === buf.length) {
+ return base64.fromByteArray(buf)
+ } else {
+ return base64.fromByteArray(buf.slice(start, end))
+ }
+}
+
+function utf8Slice (buf, start, end) {
+ end = Math.min(buf.length, end)
+ var res = []
+
+ var i = start
+ while (i < end) {
+ var firstByte = buf[i]
+ var codePoint = null
+ var bytesPerSequence = (firstByte > 0xEF) ? 4
+ : (firstByte > 0xDF) ? 3
+ : (firstByte > 0xBF) ? 2
+ : 1
+
+ if (i + bytesPerSequence <= end) {
+ var secondByte, thirdByte, fourthByte, tempCodePoint
+
+ switch (bytesPerSequence) {
+ case 1:
+ if (firstByte < 0x80) {
+ codePoint = firstByte
+ }
+ break
+ case 2:
+ secondByte = buf[i + 1]
+ if ((secondByte & 0xC0) === 0x80) {
+ tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
+ if (tempCodePoint > 0x7F) {
+ codePoint = tempCodePoint
+ }
+ }
+ break
+ case 3:
+ secondByte = buf[i + 1]
+ thirdByte = buf[i + 2]
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
+ tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
+ if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
+ codePoint = tempCodePoint
+ }
+ }
+ break
+ case 4:
+ secondByte = buf[i + 1]
+ thirdByte = buf[i + 2]
+ fourthByte = buf[i + 3]
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
+ tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
+ if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
+ codePoint = tempCodePoint
+ }
+ }
+ }
+ }
+
+ if (codePoint === null) {
+ // we did not generate a valid codePoint so insert a
+ // replacement char (U+FFFD) and advance only 1 byte
+ codePoint = 0xFFFD
+ bytesPerSequence = 1
+ } else if (codePoint > 0xFFFF) {
+ // encode to utf16 (surrogate pair dance)
+ codePoint -= 0x10000
+ res.push(codePoint >>> 10 & 0x3FF | 0xD800)
+ codePoint = 0xDC00 | codePoint & 0x3FF
+ }
+
+ res.push(codePoint)
+ i += bytesPerSequence
+ }
+
+ return decodeCodePointsArray(res)
+}
+
+// Based on http://stackoverflow.com/a/22747272/680742, the browser with
+// the lowest limit is Chrome, with 0x10000 args.
+// We go 1 magnitude less, for safety
+var MAX_ARGUMENTS_LENGTH = 0x1000
+
+function decodeCodePointsArray (codePoints) {
+ var len = codePoints.length
+ if (len <= MAX_ARGUMENTS_LENGTH) {
+ return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
+ }
+
+ // Decode in chunks to avoid "call stack size exceeded".
+ var res = ''
+ var i = 0
+ while (i < len) {
+ res += String.fromCharCode.apply(
+ String,
+ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
+ )
+ }
+ return res
+}
+
+function asciiSlice (buf, start, end) {
+ var ret = ''
+ end = Math.min(buf.length, end)
+
+ for (var i = start; i < end; ++i) {
+ ret += String.fromCharCode(buf[i] & 0x7F)
+ }
+ return ret
+}
+
+function latin1Slice (buf, start, end) {
+ var ret = ''
+ end = Math.min(buf.length, end)
+
+ for (var i = start; i < end; ++i) {
+ ret += String.fromCharCode(buf[i])
+ }
+ return ret
+}
+
+function hexSlice (buf, start, end) {
+ var len = buf.length
+
+ if (!start || start < 0) start = 0
+ if (!end || end < 0 || end > len) end = len
+
+ var out = ''
+ for (var i = start; i < end; ++i) {
+ out += toHex(buf[i])
+ }
+ return out
+}
+
+function utf16leSlice (buf, start, end) {
+ var bytes = buf.slice(start, end)
+ var res = ''
+ for (var i = 0; i < bytes.length; i += 2) {
+ res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
+ }
+ return res
+}
+
+Buffer.prototype.slice = function slice (start, end) {
+ var len = this.length
+ start = ~~start
+ end = end === undefined ? len : ~~end
+
+ if (start < 0) {
+ start += len
+ if (start < 0) start = 0
+ } else if (start > len) {
+ start = len
+ }
+
+ if (end < 0) {
+ end += len
+ if (end < 0) end = 0
+ } else if (end > len) {
+ end = len
+ }
+
+ if (end < start) end = start
+
+ var newBuf = this.subarray(start, end)
+ // Return an augmented `Uint8Array` instance
+ newBuf.__proto__ = Buffer.prototype
+ return newBuf
+}
+
+/*
+ * Need to make sure that buffer isn't trying to write out of bounds.
+ */
+function checkOffset (offset, ext, length) {
+ if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
+ if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
+}
+
+Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
+ offset = offset >>> 0
+ byteLength = byteLength >>> 0
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
+
+ var val = this[offset]
+ var mul = 1
+ var i = 0
+ while (++i < byteLength && (mul *= 0x100)) {
+ val += this[offset + i] * mul
+ }
+
+ return val
+}
+
+Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
+ offset = offset >>> 0
+ byteLength = byteLength >>> 0
+ if (!noAssert) {
+ checkOffset(offset, byteLength, this.length)
+ }
+
+ var val = this[offset + --byteLength]
+ var mul = 1
+ while (byteLength > 0 && (mul *= 0x100)) {
+ val += this[offset + --byteLength] * mul
+ }
+
+ return val
+}
+
+Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 1, this.length)
+ return this[offset]
+}
+
+Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 2, this.length)
+ return this[offset] | (this[offset + 1] << 8)
+}
+
+Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 2, this.length)
+ return (this[offset] << 8) | this[offset + 1]
+}
+
+Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 4, this.length)
+
+ return ((this[offset]) |
+ (this[offset + 1] << 8) |
+ (this[offset + 2] << 16)) +
+ (this[offset + 3] * 0x1000000)
+}
+
+Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 4, this.length)
+
+ return (this[offset] * 0x1000000) +
+ ((this[offset + 1] << 16) |
+ (this[offset + 2] << 8) |
+ this[offset + 3])
+}
+
+Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
+ offset = offset >>> 0
+ byteLength = byteLength >>> 0
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
+
+ var val = this[offset]
+ var mul = 1
+ var i = 0
+ while (++i < byteLength && (mul *= 0x100)) {
+ val += this[offset + i] * mul
+ }
+ mul *= 0x80
+
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength)
+
+ return val
+}
+
+Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
+ offset = offset >>> 0
+ byteLength = byteLength >>> 0
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
+
+ var i = byteLength
+ var mul = 1
+ var val = this[offset + --i]
+ while (i > 0 && (mul *= 0x100)) {
+ val += this[offset + --i] * mul
+ }
+ mul *= 0x80
+
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength)
+
+ return val
+}
+
+Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 1, this.length)
+ if (!(this[offset] & 0x80)) return (this[offset])
+ return ((0xff - this[offset] + 1) * -1)
+}
+
+Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 2, this.length)
+ var val = this[offset] | (this[offset + 1] << 8)
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
+}
+
+Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 2, this.length)
+ var val = this[offset + 1] | (this[offset] << 8)
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
+}
+
+Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 4, this.length)
+
+ return (this[offset]) |
+ (this[offset + 1] << 8) |
+ (this[offset + 2] << 16) |
+ (this[offset + 3] << 24)
+}
+
+Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 4, this.length)
+
+ return (this[offset] << 24) |
+ (this[offset + 1] << 16) |
+ (this[offset + 2] << 8) |
+ (this[offset + 3])
+}
+
+Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 4, this.length)
+ return ieee754.read(this, offset, true, 23, 4)
+}
+
+Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 4, this.length)
+ return ieee754.read(this, offset, false, 23, 4)
+}
+
+Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 8, this.length)
+ return ieee754.read(this, offset, true, 52, 8)
+}
+
+Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
+ offset = offset >>> 0
+ if (!noAssert) checkOffset(offset, 8, this.length)
+ return ieee754.read(this, offset, false, 52, 8)
+}
+
+function checkInt (buf, value, offset, ext, max, min) {
+ if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
+ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
+}
+
+Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ byteLength = byteLength >>> 0
+ if (!noAssert) {
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1
+ checkInt(this, value, offset, byteLength, maxBytes, 0)
+ }
+
+ var mul = 1
+ var i = 0
+ this[offset] = value & 0xFF
+ while (++i < byteLength && (mul *= 0x100)) {
+ this[offset + i] = (value / mul) & 0xFF
+ }
+
+ return offset + byteLength
+}
+
+Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ byteLength = byteLength >>> 0
+ if (!noAssert) {
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1
+ checkInt(this, value, offset, byteLength, maxBytes, 0)
+ }
+
+ var i = byteLength - 1
+ var mul = 1
+ this[offset + i] = value & 0xFF
+ while (--i >= 0 && (mul *= 0x100)) {
+ this[offset + i] = (value / mul) & 0xFF
+ }
+
+ return offset + byteLength
+}
+
+Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
+ this[offset] = (value & 0xff)
+ return offset + 1
+}
+
+Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
+ this[offset] = (value & 0xff)
+ this[offset + 1] = (value >>> 8)
+ return offset + 2
+}
+
+Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
+ this[offset] = (value >>> 8)
+ this[offset + 1] = (value & 0xff)
+ return offset + 2
+}
+
+Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
+ this[offset + 3] = (value >>> 24)
+ this[offset + 2] = (value >>> 16)
+ this[offset + 1] = (value >>> 8)
+ this[offset] = (value & 0xff)
+ return offset + 4
+}
+
+Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
+ this[offset] = (value >>> 24)
+ this[offset + 1] = (value >>> 16)
+ this[offset + 2] = (value >>> 8)
+ this[offset + 3] = (value & 0xff)
+ return offset + 4
+}
+
+Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) {
+ var limit = Math.pow(2, (8 * byteLength) - 1)
+
+ checkInt(this, value, offset, byteLength, limit - 1, -limit)
+ }
+
+ var i = 0
+ var mul = 1
+ var sub = 0
+ this[offset] = value & 0xFF
+ while (++i < byteLength && (mul *= 0x100)) {
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
+ sub = 1
+ }
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
+ }
+
+ return offset + byteLength
+}
+
+Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) {
+ var limit = Math.pow(2, (8 * byteLength) - 1)
+
+ checkInt(this, value, offset, byteLength, limit - 1, -limit)
+ }
+
+ var i = byteLength - 1
+ var mul = 1
+ var sub = 0
+ this[offset + i] = value & 0xFF
+ while (--i >= 0 && (mul *= 0x100)) {
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
+ sub = 1
+ }
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
+ }
+
+ return offset + byteLength
+}
+
+Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
+ if (value < 0) value = 0xff + value + 1
+ this[offset] = (value & 0xff)
+ return offset + 1
+}
+
+Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
+ this[offset] = (value & 0xff)
+ this[offset + 1] = (value >>> 8)
+ return offset + 2
+}
+
+Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
+ this[offset] = (value >>> 8)
+ this[offset + 1] = (value & 0xff)
+ return offset + 2
+}
+
+Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
+ this[offset] = (value & 0xff)
+ this[offset + 1] = (value >>> 8)
+ this[offset + 2] = (value >>> 16)
+ this[offset + 3] = (value >>> 24)
+ return offset + 4
+}
+
+Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
+ if (value < 0) value = 0xffffffff + value + 1
+ this[offset] = (value >>> 24)
+ this[offset + 1] = (value >>> 16)
+ this[offset + 2] = (value >>> 8)
+ this[offset + 3] = (value & 0xff)
+ return offset + 4
+}
+
+function checkIEEE754 (buf, value, offset, ext, max, min) {
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
+ if (offset < 0) throw new RangeError('Index out of range')
+}
+
+function writeFloat (buf, value, offset, littleEndian, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) {
+ checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
+ }
+ ieee754.write(buf, value, offset, littleEndian, 23, 4)
+ return offset + 4
+}
+
+Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
+ return writeFloat(this, value, offset, true, noAssert)
+}
+
+Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
+ return writeFloat(this, value, offset, false, noAssert)
+}
+
+function writeDouble (buf, value, offset, littleEndian, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert) {
+ checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
+ }
+ ieee754.write(buf, value, offset, littleEndian, 52, 8)
+ return offset + 8
+}
+
+Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
+ return writeDouble(this, value, offset, true, noAssert)
+}
+
+Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
+ return writeDouble(this, value, offset, false, noAssert)
+}
+
+// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
+Buffer.prototype.copy = function copy (target, targetStart, start, end) {
+ if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
+ if (!start) start = 0
+ if (!end && end !== 0) end = this.length
+ if (targetStart >= target.length) targetStart = target.length
+ if (!targetStart) targetStart = 0
+ if (end > 0 && end < start) end = start
+
+ // Copy 0 bytes; we're done
+ if (end === start) return 0
+ if (target.length === 0 || this.length === 0) return 0
+
+ // Fatal error conditions
+ if (targetStart < 0) {
+ throw new RangeError('targetStart out of bounds')
+ }
+ if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
+ if (end < 0) throw new RangeError('sourceEnd out of bounds')
+
+ // Are we oob?
+ if (end > this.length) end = this.length
+ if (target.length - targetStart < end - start) {
+ end = target.length - targetStart + start
+ }
+
+ var len = end - start
+
+ if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
+ // Use built-in when available, missing from IE11
+ this.copyWithin(targetStart, start, end)
+ } else if (this === target && start < targetStart && targetStart < end) {
+ // descending copy from end
+ for (var i = len - 1; i >= 0; --i) {
+ target[i + targetStart] = this[i + start]
+ }
+ } else {
+ Uint8Array.prototype.set.call(
+ target,
+ this.subarray(start, end),
+ targetStart
+ )
+ }
+
+ return len
+}
+
+// Usage:
+// buffer.fill(number[, offset[, end]])
+// buffer.fill(buffer[, offset[, end]])
+// buffer.fill(string[, offset[, end]][, encoding])
+Buffer.prototype.fill = function fill (val, start, end, encoding) {
+ // Handle string cases:
+ if (typeof val === 'string') {
+ if (typeof start === 'string') {
+ encoding = start
+ start = 0
+ end = this.length
+ } else if (typeof end === 'string') {
+ encoding = end
+ end = this.length
+ }
+ if (encoding !== undefined && typeof encoding !== 'string') {
+ throw new TypeError('encoding must be a string')
+ }
+ if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
+ throw new TypeError('Unknown encoding: ' + encoding)
+ }
+ if (val.length === 1) {
+ var code = val.charCodeAt(0)
+ if ((encoding === 'utf8' && code < 128) ||
+ encoding === 'latin1') {
+ // Fast path: If `val` fits into a single byte, use that numeric value.
+ val = code
+ }
+ }
+ } else if (typeof val === 'number') {
+ val = val & 255
+ }
+
+ // Invalid ranges are not set to a default, so can range check early.
+ if (start < 0 || this.length < start || this.length < end) {
+ throw new RangeError('Out of range index')
+ }
+
+ if (end <= start) {
+ return this
+ }
+
+ start = start >>> 0
+ end = end === undefined ? this.length : end >>> 0
+
+ if (!val) val = 0
+
+ var i
+ if (typeof val === 'number') {
+ for (i = start; i < end; ++i) {
+ this[i] = val
+ }
+ } else {
+ var bytes = Buffer.isBuffer(val)
+ ? val
+ : new Buffer(val, encoding)
+ var len = bytes.length
+ if (len === 0) {
+ throw new TypeError('The value "' + val +
+ '" is invalid for argument "value"')
+ }
+ for (i = 0; i < end - start; ++i) {
+ this[i + start] = bytes[i % len]
+ }
+ }
+
+ return this
+}
+
+// HELPER FUNCTIONS
+// ================
+
+var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
+
+function base64clean (str) {
+ // Node takes equal signs as end of the Base64 encoding
+ str = str.split('=')[0]
+ // Node strips out invalid characters like \n and \t from the string, base64-js does not
+ str = str.trim().replace(INVALID_BASE64_RE, '')
+ // Node converts strings with length < 2 to ''
+ if (str.length < 2) return ''
+ // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
+ while (str.length % 4 !== 0) {
+ str = str + '='
+ }
+ return str
+}
+
+function toHex (n) {
+ if (n < 16) return '0' + n.toString(16)
+ return n.toString(16)
+}
+
+function utf8ToBytes (string, units) {
+ units = units || Infinity
+ var codePoint
+ var length = string.length
+ var leadSurrogate = null
+ var bytes = []
+
+ for (var i = 0; i < length; ++i) {
+ codePoint = string.charCodeAt(i)
+
+ // is surrogate component
+ if (codePoint > 0xD7FF && codePoint < 0xE000) {
+ // last char was a lead
+ if (!leadSurrogate) {
+ // no lead yet
+ if (codePoint > 0xDBFF) {
+ // unexpected trail
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
+ continue
+ } else if (i + 1 === length) {
+ // unpaired lead
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
+ continue
+ }
+
+ // valid lead
+ leadSurrogate = codePoint
+
+ continue
+ }
+
+ // 2 leads in a row
+ if (codePoint < 0xDC00) {
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
+ leadSurrogate = codePoint
+ continue
+ }
+
+ // valid surrogate pair
+ codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
+ } else if (leadSurrogate) {
+ // valid bmp char, but last char was a lead
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
+ }
+
+ leadSurrogate = null
+
+ // encode utf8
+ if (codePoint < 0x80) {
+ if ((units -= 1) < 0) break
+ bytes.push(codePoint)
+ } else if (codePoint < 0x800) {
+ if ((units -= 2) < 0) break
+ bytes.push(
+ codePoint >> 0x6 | 0xC0,
+ codePoint & 0x3F | 0x80
+ )
+ } else if (codePoint < 0x10000) {
+ if ((units -= 3) < 0) break
+ bytes.push(
+ codePoint >> 0xC | 0xE0,
+ codePoint >> 0x6 & 0x3F | 0x80,
+ codePoint & 0x3F | 0x80
+ )
+ } else if (codePoint < 0x110000) {
+ if ((units -= 4) < 0) break
+ bytes.push(
+ codePoint >> 0x12 | 0xF0,
+ codePoint >> 0xC & 0x3F | 0x80,
+ codePoint >> 0x6 & 0x3F | 0x80,
+ codePoint & 0x3F | 0x80
+ )
+ } else {
+ throw new Error('Invalid code point')
+ }
+ }
+
+ return bytes
+}
+
+function asciiToBytes (str) {
+ var byteArray = []
+ for (var i = 0; i < str.length; ++i) {
+ // Node's code seems to be doing this and not & 0x7F..
+ byteArray.push(str.charCodeAt(i) & 0xFF)
+ }
+ return byteArray
+}
+
+function utf16leToBytes (str, units) {
+ var c, hi, lo
+ var byteArray = []
+ for (var i = 0; i < str.length; ++i) {
+ if ((units -= 2) < 0) break
+
+ c = str.charCodeAt(i)
+ hi = c >> 8
+ lo = c % 256
+ byteArray.push(lo)
+ byteArray.push(hi)
+ }
+
+ return byteArray
+}
+
+function base64ToBytes (str) {
+ return base64.toByteArray(base64clean(str))
+}
+
+function blitBuffer (src, dst, offset, length) {
+ for (var i = 0; i < length; ++i) {
+ if ((i + offset >= dst.length) || (i >= src.length)) break
+ dst[i + offset] = src[i]
+ }
+ return i
+}
+
+// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check
+// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166
+function isArrayBuffer (obj) {
+ return obj instanceof ArrayBuffer ||
+ (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' &&
+ typeof obj.byteLength === 'number')
+}
+
+function numberIsNaN (obj) {
+ return obj !== obj // eslint-disable-line no-self-compare
+}
+
+},{"base64-js":4,"ieee754":6}],6:[function(require,module,exports){
+exports.read = function (buffer, offset, isLE, mLen, nBytes) {
+ var e, m
+ var eLen = (nBytes * 8) - mLen - 1
+ var eMax = (1 << eLen) - 1
+ var eBias = eMax >> 1
+ var nBits = -7
+ var i = isLE ? (nBytes - 1) : 0
+ var d = isLE ? -1 : 1
+ var s = buffer[offset + i]
+
+ i += d
+
+ e = s & ((1 << (-nBits)) - 1)
+ s >>= (-nBits)
+ nBits += eLen
+ for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
+
+ m = e & ((1 << (-nBits)) - 1)
+ e >>= (-nBits)
+ nBits += mLen
+ for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
+
+ if (e === 0) {
+ e = 1 - eBias
+ } else if (e === eMax) {
+ return m ? NaN : ((s ? -1 : 1) * Infinity)
+ } else {
+ m = m + Math.pow(2, mLen)
+ e = e - eBias
+ }
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
+}
+
+exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
+ var e, m, c
+ var eLen = (nBytes * 8) - mLen - 1
+ var eMax = (1 << eLen) - 1
+ var eBias = eMax >> 1
+ var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
+ var i = isLE ? 0 : (nBytes - 1)
+ var d = isLE ? 1 : -1
+ var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
+
+ value = Math.abs(value)
+
+ if (isNaN(value) || value === Infinity) {
+ m = isNaN(value) ? 1 : 0
+ e = eMax
+ } else {
+ e = Math.floor(Math.log(value) / Math.LN2)
+ if (value * (c = Math.pow(2, -e)) < 1) {
+ e--
+ c *= 2
+ }
+ if (e + eBias >= 1) {
+ value += rt / c
+ } else {
+ value += rt * Math.pow(2, 1 - eBias)
+ }
+ if (value * c >= 2) {
+ e++
+ c /= 2
+ }
+
+ if (e + eBias >= eMax) {
+ m = 0
+ e = eMax
+ } else if (e + eBias >= 1) {
+ m = ((value * c) - 1) * Math.pow(2, mLen)
+ e = e + eBias
+ } else {
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
+ e = 0
+ }
+ }
+
+ for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
+
+ e = (e << mLen) | m
+ eLen += mLen
+ for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
+
+ buffer[offset + i - d] |= s * 128
+}
+
+},{}],7:[function(require,module,exports){
+/*!
+ * Determine if an object is a Buffer
+ *
+ * @author Feross Aboukhadijeh <https://feross.org>
+ * @license MIT
+ */
+
+// The _isBuffer check is for Safari 5-7 support, because it's missing
+// Object.prototype.constructor. Remove this eventually
+module.exports = function (obj) {
+ return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
+}
+
+function isBuffer (obj) {
+ return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
+}
+
+// For Node v0.10 support. Remove this eventually.
+function isSlowBuffer (obj) {
+ return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
+}
+
+},{}],8:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var assign, isArray, isEmpty, isFunction, isObject, isPlainObject,
+ slice = [].slice,
+ hasProp = {}.hasOwnProperty;
+
+ assign = function() {
+ var i, key, len, source, sources, target;
+ target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
+ if (isFunction(Object.assign)) {
+ Object.assign.apply(null, arguments);
+ } else {
+ for (i = 0, len = sources.length; i < len; i++) {
+ source = sources[i];
+ if (source != null) {
+ for (key in source) {
+ if (!hasProp.call(source, key)) continue;
+ target[key] = source[key];
+ }
+ }
+ }
+ }
+ return target;
+ };
+
+ isFunction = function(val) {
+ return !!val && Object.prototype.toString.call(val) === '[object Function]';
+ };
+
+ isObject = function(val) {
+ var ref;
+ return !!val && ((ref = typeof val) === 'function' || ref === 'object');
+ };
+
+ isArray = function(val) {
+ if (isFunction(Array.isArray)) {
+ return Array.isArray(val);
+ } else {
+ return Object.prototype.toString.call(val) === '[object Array]';
+ }
+ };
+
+ isEmpty = function(val) {
+ var key;
+ if (isArray(val)) {
+ return !val.length;
+ } else {
+ for (key in val) {
+ if (!hasProp.call(val, key)) continue;
+ return false;
+ }
+ return true;
+ }
+ };
+
+ isPlainObject = function(val) {
+ var ctor, proto;
+ return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object));
+ };
+
+ module.exports.assign = assign;
+
+ module.exports.isFunction = isFunction;
+
+ module.exports.isObject = isObject;
+
+ module.exports.isArray = isArray;
+
+ module.exports.isEmpty = isEmpty;
+
+ module.exports.isPlainObject = isPlainObject;
+
+}).call(this);
+
+},{}],9:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLAttribute;
+
+ module.exports = XMLAttribute = (function() {
+ function XMLAttribute(parent, name, value) {
+ this.options = parent.options;
+ 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 Object.create(this);
+ };
+
+ XMLAttribute.prototype.toString = function(options) {
+ return this.options.writer.set(options).attribute(this);
+ };
+
+ return XMLAttribute;
+
+ })();
+
+}).call(this);
+
+},{}],10:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLCData, XMLNode,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ 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 Object.create(this);
+ };
+
+ XMLCData.prototype.toString = function(options) {
+ return this.options.writer.set(options).cdata(this);
+ };
+
+ return XMLCData;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./XMLNode":21}],11:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLComment, XMLNode,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ 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 Object.create(this);
+ };
+
+ XMLComment.prototype.toString = function(options) {
+ return this.options.writer.set(options).comment(this);
+ };
+
+ return XMLComment;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./XMLNode":21}],12:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDTDAttList, XMLNode,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLDTDAttList = (function(superClass) {
+ extend(XMLDTDAttList, superClass);
+
+ function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
+ XMLDTDAttList.__super__.constructor.call(this, parent);
+ 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) {
+ return this.options.writer.set(options).dtdAttList(this);
+ };
+
+ return XMLDTDAttList;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./XMLNode":21}],13:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDTDElement, XMLNode,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLDTDElement = (function(superClass) {
+ extend(XMLDTDElement, superClass);
+
+ function XMLDTDElement(parent, name, value) {
+ XMLDTDElement.__super__.constructor.call(this, parent);
+ 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) {
+ return this.options.writer.set(options).dtdElement(this);
+ };
+
+ return XMLDTDElement;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./XMLNode":21}],14:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDTDEntity, XMLNode, 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;
+
+ isObject = require('./Utility').isObject;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLDTDEntity = (function(superClass) {
+ extend(XMLDTDEntity, superClass);
+
+ function XMLDTDEntity(parent, pe, name, value) {
+ XMLDTDEntity.__super__.constructor.call(this, parent);
+ 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) {
+ return this.options.writer.set(options).dtdEntity(this);
+ };
+
+ return XMLDTDEntity;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./Utility":8,"./XMLNode":21}],15:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDTDNotation, XMLNode,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLDTDNotation = (function(superClass) {
+ extend(XMLDTDNotation, superClass);
+
+ function XMLDTDNotation(parent, name, value) {
+ XMLDTDNotation.__super__.constructor.call(this, parent);
+ 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) {
+ return this.options.writer.set(options).dtdNotation(this);
+ };
+
+ return XMLDTDNotation;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./XMLNode":21}],16:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDeclaration, XMLNode, 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;
+
+ isObject = require('./Utility').isObject;
+
+ XMLNode = require('./XMLNode');
+
+ 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) {
+ return this.options.writer.set(options).declaration(this);
+ };
+
+ return XMLDeclaration;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./Utility":8,"./XMLNode":21}],17:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNode, 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;
+
+ isObject = require('./Utility').isObject;
+
+ XMLNode = require('./XMLNode');
+
+ XMLDTDAttList = require('./XMLDTDAttList');
+
+ XMLDTDEntity = require('./XMLDTDEntity');
+
+ XMLDTDElement = require('./XMLDTDElement');
+
+ XMLDTDNotation = require('./XMLDTDNotation');
+
+ module.exports = XMLDocType = (function(superClass) {
+ extend(XMLDocType, superClass);
+
+ function XMLDocType(parent, pubID, sysID) {
+ var ref, ref1;
+ XMLDocType.__super__.constructor.call(this, parent);
+ this.documentObject = parent;
+ 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.toString = function(options) {
+ return this.options.writer.set(options).docType(this);
+ };
+
+ 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.up = function() {
+ return this.root() || this.documentObject;
+ };
+
+ return XMLDocType;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./Utility":8,"./XMLDTDAttList":12,"./XMLDTDElement":13,"./XMLDTDEntity":14,"./XMLDTDNotation":15,"./XMLNode":21}],18:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject,
+ 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;
+
+ isPlainObject = require('./Utility').isPlainObject;
+
+ XMLNode = require('./XMLNode');
+
+ XMLStringifier = require('./XMLStringifier');
+
+ XMLStringWriter = require('./XMLStringWriter');
+
+ module.exports = XMLDocument = (function(superClass) {
+ extend(XMLDocument, superClass);
+
+ function XMLDocument(options) {
+ XMLDocument.__super__.constructor.call(this, null);
+ options || (options = {});
+ if (!options.writer) {
+ options.writer = new XMLStringWriter();
+ }
+ this.options = options;
+ this.stringify = new XMLStringifier(options);
+ this.isDocument = true;
+ }
+
+ XMLDocument.prototype.end = function(writer) {
+ var writerOptions;
+ if (!writer) {
+ writer = this.options.writer;
+ } else if (isPlainObject(writer)) {
+ writerOptions = writer;
+ writer = this.options.writer.set(writerOptions);
+ }
+ return writer.document(this);
+ };
+
+ XMLDocument.prototype.toString = function(options) {
+ return this.options.writer.set(options).document(this);
+ };
+
+ return XMLDocument;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./Utility":8,"./XMLNode":21,"./XMLStringWriter":25,"./XMLStringifier":26}],19:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, isFunction, isObject, isPlainObject, ref,
+ hasProp = {}.hasOwnProperty;
+
+ ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject;
+
+ XMLElement = require('./XMLElement');
+
+ XMLCData = require('./XMLCData');
+
+ XMLComment = require('./XMLComment');
+
+ XMLRaw = require('./XMLRaw');
+
+ XMLText = require('./XMLText');
+
+ XMLProcessingInstruction = require('./XMLProcessingInstruction');
+
+ XMLDeclaration = require('./XMLDeclaration');
+
+ XMLDocType = require('./XMLDocType');
+
+ XMLDTDAttList = require('./XMLDTDAttList');
+
+ XMLDTDEntity = require('./XMLDTDEntity');
+
+ XMLDTDElement = require('./XMLDTDElement');
+
+ XMLDTDNotation = require('./XMLDTDNotation');
+
+ XMLAttribute = require('./XMLAttribute');
+
+ XMLStringifier = require('./XMLStringifier');
+
+ XMLStringWriter = require('./XMLStringWriter');
+
+ module.exports = XMLDocumentCB = (function() {
+ function XMLDocumentCB(options, onData, onEnd) {
+ var writerOptions;
+ options || (options = {});
+ if (!options.writer) {
+ options.writer = new XMLStringWriter(options);
+ } else if (isPlainObject(options.writer)) {
+ writerOptions = options.writer;
+ options.writer = new XMLStringWriter(writerOptions);
+ }
+ this.options = options;
+ this.writer = options.writer;
+ this.stringify = new XMLStringifier(options);
+ this.onDataCallback = onData || function() {};
+ this.onEndCallback = onEnd || function() {};
+ this.currentNode = null;
+ this.currentLevel = -1;
+ this.openTags = {};
+ this.documentStarted = false;
+ this.documentCompleted = false;
+ this.root = null;
+ }
+
+ XMLDocumentCB.prototype.node = function(name, attributes, text) {
+ var ref1;
+ if (name == null) {
+ throw new Error("Missing node name");
+ }
+ if (this.root && this.currentLevel === -1) {
+ throw new Error("Document can only have one root node");
+ }
+ this.openCurrent();
+ name = name.valueOf();
+ if (attributes == null) {
+ attributes = {};
+ }
+ attributes = attributes.valueOf();
+ if (!isObject(attributes)) {
+ ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
+ }
+ this.currentNode = new XMLElement(this, name, attributes);
+ this.currentNode.children = false;
+ this.currentLevel++;
+ this.openTags[this.currentLevel] = this.currentNode;
+ if (text != null) {
+ this.text(text);
+ }
+ return this;
+ };
+
+ XMLDocumentCB.prototype.element = function(name, attributes, text) {
+ if (this.currentNode && this.currentNode instanceof XMLDocType) {
+ return this.dtdElement.apply(this, arguments);
+ } else {
+ return this.node(name, attributes, text);
+ }
+ };
+
+ XMLDocumentCB.prototype.attribute = function(name, value) {
+ var attName, attValue;
+ if (!this.currentNode || this.currentNode.children) {
+ throw new Error("att() can only be used immediately after an ele() call in callback mode");
+ }
+ 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.currentNode.attributes[name] = new XMLAttribute(this, name, value);
+ }
+ }
+ return this;
+ };
+
+ XMLDocumentCB.prototype.text = function(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLText(this, value);
+ this.onData(this.writer.text(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.cdata = function(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLCData(this, value);
+ this.onData(this.writer.cdata(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.comment = function(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLComment(this, value);
+ this.onData(this.writer.comment(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.raw = function(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLRaw(this, value);
+ this.onData(this.writer.raw(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.instruction = function(target, value) {
+ var i, insTarget, insValue, len, node;
+ this.openCurrent();
+ 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();
+ }
+ node = new XMLProcessingInstruction(this, target, value);
+ this.onData(this.writer.processingInstruction(node, this.currentLevel + 1));
+ }
+ return this;
+ };
+
+ XMLDocumentCB.prototype.declaration = function(version, encoding, standalone) {
+ var node;
+ this.openCurrent();
+ if (this.documentStarted) {
+ throw new Error("declaration() must be the first node");
+ }
+ node = new XMLDeclaration(this, version, encoding, standalone);
+ this.onData(this.writer.declaration(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.doctype = function(root, pubID, sysID) {
+ this.openCurrent();
+ if (root == null) {
+ throw new Error("Missing root node name");
+ }
+ if (this.root) {
+ throw new Error("dtd() must come before the root node");
+ }
+ this.currentNode = new XMLDocType(this, pubID, sysID);
+ this.currentNode.rootNodeName = root;
+ this.currentNode.children = false;
+ this.currentLevel++;
+ this.openTags[this.currentLevel] = this.currentNode;
+ return this;
+ };
+
+ XMLDocumentCB.prototype.dtdElement = function(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDElement(this, name, value);
+ this.onData(this.writer.dtdElement(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
+ this.onData(this.writer.dtdAttList(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.entity = function(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDEntity(this, false, name, value);
+ this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.pEntity = function(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDEntity(this, true, name, value);
+ this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.notation = function(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDNotation(this, name, value);
+ this.onData(this.writer.dtdNotation(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.up = function() {
+ if (this.currentLevel < 0) {
+ throw new Error("The document node has no parent");
+ }
+ if (this.currentNode) {
+ if (this.currentNode.children) {
+ this.closeNode(this.currentNode);
+ } else {
+ this.openNode(this.currentNode);
+ }
+ this.currentNode = null;
+ } else {
+ this.closeNode(this.openTags[this.currentLevel]);
+ }
+ delete this.openTags[this.currentLevel];
+ this.currentLevel--;
+ return this;
+ };
+
+ XMLDocumentCB.prototype.end = function() {
+ while (this.currentLevel >= 0) {
+ this.up();
+ }
+ return this.onEnd();
+ };
+
+ XMLDocumentCB.prototype.openCurrent = function() {
+ if (this.currentNode) {
+ this.currentNode.children = true;
+ return this.openNode(this.currentNode);
+ }
+ };
+
+ XMLDocumentCB.prototype.openNode = function(node) {
+ if (!node.isOpen) {
+ if (!this.root && this.currentLevel === 0 && node instanceof XMLElement) {
+ this.root = node;
+ }
+ this.onData(this.writer.openNode(node, this.currentLevel));
+ return node.isOpen = true;
+ }
+ };
+
+ XMLDocumentCB.prototype.closeNode = function(node) {
+ if (!node.isClosed) {
+ this.onData(this.writer.closeNode(node, this.currentLevel));
+ return node.isClosed = true;
+ }
+ };
+
+ XMLDocumentCB.prototype.onData = function(chunk) {
+ this.documentStarted = true;
+ return this.onDataCallback(chunk);
+ };
+
+ XMLDocumentCB.prototype.onEnd = function() {
+ this.documentCompleted = true;
+ return this.onEndCallback();
+ };
+
+ XMLDocumentCB.prototype.ele = function() {
+ return this.element.apply(this, arguments);
+ };
+
+ XMLDocumentCB.prototype.nod = function(name, attributes, text) {
+ return this.node(name, attributes, text);
+ };
+
+ XMLDocumentCB.prototype.txt = function(value) {
+ return this.text(value);
+ };
+
+ XMLDocumentCB.prototype.dat = function(value) {
+ return this.cdata(value);
+ };
+
+ XMLDocumentCB.prototype.com = function(value) {
+ return this.comment(value);
+ };
+
+ XMLDocumentCB.prototype.ins = function(target, value) {
+ return this.instruction(target, value);
+ };
+
+ XMLDocumentCB.prototype.dec = function(version, encoding, standalone) {
+ return this.declaration(version, encoding, standalone);
+ };
+
+ XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) {
+ return this.doctype(root, pubID, sysID);
+ };
+
+ XMLDocumentCB.prototype.e = function(name, attributes, text) {
+ return this.element(name, attributes, text);
+ };
+
+ XMLDocumentCB.prototype.n = function(name, attributes, text) {
+ return this.node(name, attributes, text);
+ };
+
+ XMLDocumentCB.prototype.t = function(value) {
+ return this.text(value);
+ };
+
+ XMLDocumentCB.prototype.d = function(value) {
+ return this.cdata(value);
+ };
+
+ XMLDocumentCB.prototype.c = function(value) {
+ return this.comment(value);
+ };
+
+ XMLDocumentCB.prototype.r = function(value) {
+ return this.raw(value);
+ };
+
+ XMLDocumentCB.prototype.i = function(target, value) {
+ return this.instruction(target, value);
+ };
+
+ XMLDocumentCB.prototype.att = function() {
+ if (this.currentNode && this.currentNode instanceof XMLDocType) {
+ return this.attList.apply(this, arguments);
+ } else {
+ return this.attribute.apply(this, arguments);
+ }
+ };
+
+ XMLDocumentCB.prototype.a = function() {
+ if (this.currentNode && this.currentNode instanceof XMLDocType) {
+ return this.attList.apply(this, arguments);
+ } else {
+ return this.attribute.apply(this, arguments);
+ }
+ };
+
+ XMLDocumentCB.prototype.ent = function(name, value) {
+ return this.entity(name, value);
+ };
+
+ XMLDocumentCB.prototype.pent = function(name, value) {
+ return this.pEntity(name, value);
+ };
+
+ XMLDocumentCB.prototype.not = function(name, value) {
+ return this.notation(name, value);
+ };
+
+ return XMLDocumentCB;
+
+ })();
+
+}).call(this);
+
+},{"./Utility":8,"./XMLAttribute":9,"./XMLCData":10,"./XMLComment":11,"./XMLDTDAttList":12,"./XMLDTDElement":13,"./XMLDTDEntity":14,"./XMLDTDNotation":15,"./XMLDeclaration":16,"./XMLDocType":17,"./XMLElement":20,"./XMLProcessingInstruction":22,"./XMLRaw":23,"./XMLStringWriter":25,"./XMLStringifier":26,"./XMLText":27}],20:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLAttribute, XMLElement, XMLNode, isFunction, isObject, ref,
+ 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;
+
+ ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction;
+
+ XMLNode = require('./XMLNode');
+
+ XMLAttribute = require('./XMLAttribute');
+
+ 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.attributes = {};
+ if (attributes != null) {
+ this.attribute(attributes);
+ }
+ if (parent.isDocument) {
+ this.isRoot = true;
+ this.documentObject = parent;
+ parent.rootObject = this;
+ }
+ }
+
+ XMLElement.prototype.clone = function() {
+ var att, attName, clonedSelf, ref1;
+ clonedSelf = Object.create(this);
+ if (clonedSelf.isRoot) {
+ clonedSelf.documentObject = null;
+ }
+ clonedSelf.attributes = {};
+ ref1 = this.attributes;
+ for (attName in ref1) {
+ if (!hasProp.call(ref1, attName)) continue;
+ att = ref1[attName];
+ clonedSelf.attributes[attName] = att.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.toString = function(options) {
+ return this.options.writer.set(options).element(this);
+ };
+
+ XMLElement.prototype.att = function(name, value) {
+ return this.attribute(name, value);
+ };
+
+ XMLElement.prototype.a = function(name, value) {
+ return this.attribute(name, value);
+ };
+
+ return XMLElement;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./Utility":8,"./XMLAttribute":9,"./XMLNode":21}],21:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLElement, XMLNode, XMLProcessingInstruction, XMLRaw, XMLText, isEmpty, isFunction, isObject, ref,
+ hasProp = {}.hasOwnProperty;
+
+ ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isEmpty = ref.isEmpty;
+
+ XMLElement = null;
+
+ XMLCData = null;
+
+ XMLComment = null;
+
+ XMLDeclaration = null;
+
+ XMLDocType = null;
+
+ XMLRaw = null;
+
+ XMLText = null;
+
+ XMLProcessingInstruction = null;
+
+ module.exports = XMLNode = (function() {
+ function XMLNode(parent) {
+ this.parent = parent;
+ if (this.parent) {
+ this.options = this.parent.options;
+ this.stringify = this.parent.stringify;
+ }
+ this.children = [];
+ if (!XMLElement) {
+ XMLElement = require('./XMLElement');
+ XMLCData = require('./XMLCData');
+ XMLComment = require('./XMLComment');
+ XMLDeclaration = require('./XMLDeclaration');
+ XMLDocType = require('./XMLDocType');
+ XMLRaw = require('./XMLRaw');
+ XMLText = require('./XMLText');
+ XMLProcessingInstruction = require('./XMLProcessingInstruction');
+ }
+ }
+
+ XMLNode.prototype.element = function(name, attributes, text) {
+ var childNode, item, j, k, key, lastChild, len, len1, ref1, val;
+ lastChild = null;
+ if (attributes == null) {
+ attributes = {};
+ }
+ attributes = attributes.valueOf();
+ if (!isObject(attributes)) {
+ ref1 = [attributes, text], text = ref1[0], attributes = ref1[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.separateArrayItems && 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 if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
+ lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), 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, ref1;
+ 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(ref1 = [])), ref1;
+ return this.parent;
+ };
+
+ XMLNode.prototype.node = function(name, attributes, text) {
+ var child, ref1;
+ if (name != null) {
+ name = name.valueOf();
+ }
+ attributes || (attributes = {});
+ attributes = attributes.valueOf();
+ if (!isObject(attributes)) {
+ ref1 = [attributes, text], text = ref1[0], attributes = ref1[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.commentBefore = function(value) {
+ var child, i, removed;
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i);
+ child = this.parent.comment(value);
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ };
+
+ XMLNode.prototype.commentAfter = function(value) {
+ var child, i, removed;
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i + 1);
+ child = this.parent.comment(value);
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ };
+
+ XMLNode.prototype.raw = function(value) {
+ var child;
+ child = new XMLRaw(this, value);
+ this.children.push(child);
+ return this;
+ };
+
+ XMLNode.prototype.instruction = function(target, value) {
+ var insTarget, insValue, instruction, j, len;
+ if (target != null) {
+ target = target.valueOf();
+ }
+ if (value != null) {
+ value = value.valueOf();
+ }
+ if (Array.isArray(target)) {
+ for (j = 0, len = target.length; j < len; j++) {
+ insTarget = target[j];
+ 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.children.push(instruction);
+ }
+ return this;
+ };
+
+ XMLNode.prototype.instructionBefore = function(target, value) {
+ var child, i, removed;
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i);
+ child = this.parent.instruction(target, value);
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ };
+
+ XMLNode.prototype.instructionAfter = function(target, value) {
+ var child, i, removed;
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i + 1);
+ child = this.parent.instruction(target, value);
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ };
+
+ XMLNode.prototype.declaration = function(version, encoding, standalone) {
+ var doc, xmldec;
+ doc = this.document();
+ xmldec = new XMLDeclaration(doc, version, encoding, standalone);
+ if (doc.children[0] instanceof XMLDeclaration) {
+ doc.children[0] = xmldec;
+ } else {
+ doc.children.unshift(xmldec);
+ }
+ return doc.root() || doc;
+ };
+
+ XMLNode.prototype.doctype = function(pubID, sysID) {
+ var child, doc, doctype, i, j, k, len, len1, ref1, ref2;
+ doc = this.document();
+ doctype = new XMLDocType(doc, pubID, sysID);
+ ref1 = doc.children;
+ for (i = j = 0, len = ref1.length; j < len; i = ++j) {
+ child = ref1[i];
+ if (child instanceof XMLDocType) {
+ doc.children[i] = doctype;
+ return doctype;
+ }
+ }
+ ref2 = doc.children;
+ for (i = k = 0, len1 = ref2.length; k < len1; i = ++k) {
+ child = ref2[i];
+ if (child.isRoot) {
+ doc.children.splice(i, 0, doctype);
+ return doctype;
+ }
+ }
+ doc.children.push(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 node;
+ node = this;
+ while (node) {
+ if (node.isDocument) {
+ return node.rootObject;
+ } else if (node.isRoot) {
+ return node;
+ } else {
+ node = node.parent;
+ }
+ }
+ };
+
+ XMLNode.prototype.document = function() {
+ var node;
+ node = this;
+ while (node) {
+ if (node.isDocument) {
+ return node;
+ } else {
+ node = node.parent;
+ }
+ }
+ };
+
+ XMLNode.prototype.end = function(options) {
+ return this.document().end(options);
+ };
+
+ XMLNode.prototype.prev = function() {
+ var i;
+ 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;
+ 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.importDocument = function(doc) {
+ var clonedRoot;
+ clonedRoot = doc.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.ins = function(target, value) {
+ return this.instruction(target, 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.i = function(target, value) {
+ return this.instruction(target, value);
+ };
+
+ XMLNode.prototype.u = function() {
+ return this.up();
+ };
+
+ XMLNode.prototype.importXMLBuilder = function(doc) {
+ return this.importDocument(doc);
+ };
+
+ return XMLNode;
+
+ })();
+
+}).call(this);
+
+},{"./Utility":8,"./XMLCData":10,"./XMLComment":11,"./XMLDeclaration":16,"./XMLDocType":17,"./XMLElement":20,"./XMLProcessingInstruction":22,"./XMLRaw":23,"./XMLText":27}],22:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLNode, XMLProcessingInstruction,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLProcessingInstruction = (function(superClass) {
+ extend(XMLProcessingInstruction, superClass);
+
+ function XMLProcessingInstruction(parent, target, value) {
+ XMLProcessingInstruction.__super__.constructor.call(this, parent);
+ 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 Object.create(this);
+ };
+
+ XMLProcessingInstruction.prototype.toString = function(options) {
+ return this.options.writer.set(options).processingInstruction(this);
+ };
+
+ return XMLProcessingInstruction;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./XMLNode":21}],23:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLNode, XMLRaw,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ 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 Object.create(this);
+ };
+
+ XMLRaw.prototype.toString = function(options) {
+ return this.options.writer.set(options).raw(this);
+ };
+
+ return XMLRaw;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./XMLNode":21}],24:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStreamWriter, XMLText, XMLWriterBase,
+ 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;
+
+ XMLDeclaration = require('./XMLDeclaration');
+
+ XMLDocType = require('./XMLDocType');
+
+ XMLCData = require('./XMLCData');
+
+ XMLComment = require('./XMLComment');
+
+ XMLElement = require('./XMLElement');
+
+ XMLRaw = require('./XMLRaw');
+
+ XMLText = require('./XMLText');
+
+ XMLProcessingInstruction = require('./XMLProcessingInstruction');
+
+ XMLDTDAttList = require('./XMLDTDAttList');
+
+ XMLDTDElement = require('./XMLDTDElement');
+
+ XMLDTDEntity = require('./XMLDTDEntity');
+
+ XMLDTDNotation = require('./XMLDTDNotation');
+
+ XMLWriterBase = require('./XMLWriterBase');
+
+ module.exports = XMLStreamWriter = (function(superClass) {
+ extend(XMLStreamWriter, superClass);
+
+ function XMLStreamWriter(stream, options) {
+ XMLStreamWriter.__super__.constructor.call(this, options);
+ this.stream = stream;
+ }
+
+ XMLStreamWriter.prototype.document = function(doc) {
+ var child, i, j, len, len1, ref, ref1, results;
+ ref = doc.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ child.isLastRootNode = false;
+ }
+ doc.children[doc.children.length - 1].isLastRootNode = true;
+ ref1 = doc.children;
+ results = [];
+ for (j = 0, len1 = ref1.length; j < len1; j++) {
+ child = ref1[j];
+ switch (false) {
+ case !(child instanceof XMLDeclaration):
+ results.push(this.declaration(child));
+ break;
+ case !(child instanceof XMLDocType):
+ results.push(this.docType(child));
+ break;
+ case !(child instanceof XMLComment):
+ results.push(this.comment(child));
+ break;
+ case !(child instanceof XMLProcessingInstruction):
+ results.push(this.processingInstruction(child));
+ break;
+ default:
+ results.push(this.element(child));
+ }
+ }
+ return results;
+ };
+
+ XMLStreamWriter.prototype.attribute = function(att) {
+ return this.stream.write(' ' + att.name + '="' + att.value + '"');
+ };
+
+ XMLStreamWriter.prototype.cdata = function(node, level) {
+ return this.stream.write(this.space(level) + '<![CDATA[' + node.text + ']]>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.comment = function(node, level) {
+ return this.stream.write(this.space(level) + '<!-- ' + node.text + ' -->' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.declaration = function(node, level) {
+ this.stream.write(this.space(level));
+ this.stream.write('<?xml version="' + node.version + '"');
+ if (node.encoding != null) {
+ this.stream.write(' encoding="' + node.encoding + '"');
+ }
+ if (node.standalone != null) {
+ this.stream.write(' standalone="' + node.standalone + '"');
+ }
+ this.stream.write(this.spacebeforeslash + '?>');
+ return this.stream.write(this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.docType = function(node, level) {
+ var child, i, len, ref;
+ level || (level = 0);
+ this.stream.write(this.space(level));
+ this.stream.write('<!DOCTYPE ' + node.root().name);
+ if (node.pubID && node.sysID) {
+ this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
+ } else if (node.sysID) {
+ this.stream.write(' SYSTEM "' + node.sysID + '"');
+ }
+ if (node.children.length > 0) {
+ this.stream.write(' [');
+ this.stream.write(this.endline(node));
+ ref = node.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ switch (false) {
+ case !(child instanceof XMLDTDAttList):
+ this.dtdAttList(child, level + 1);
+ break;
+ case !(child instanceof XMLDTDElement):
+ this.dtdElement(child, level + 1);
+ break;
+ case !(child instanceof XMLDTDEntity):
+ this.dtdEntity(child, level + 1);
+ break;
+ case !(child instanceof XMLDTDNotation):
+ this.dtdNotation(child, level + 1);
+ break;
+ case !(child instanceof XMLCData):
+ this.cdata(child, level + 1);
+ break;
+ case !(child instanceof XMLComment):
+ this.comment(child, level + 1);
+ break;
+ case !(child instanceof XMLProcessingInstruction):
+ this.processingInstruction(child, level + 1);
+ break;
+ default:
+ throw new Error("Unknown DTD node type: " + child.constructor.name);
+ }
+ }
+ this.stream.write(']');
+ }
+ this.stream.write(this.spacebeforeslash + '>');
+ return this.stream.write(this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.element = function(node, level) {
+ var att, child, i, len, name, ref, ref1, space;
+ level || (level = 0);
+ space = this.space(level);
+ this.stream.write(space + '<' + node.name);
+ ref = node.attributes;
+ for (name in ref) {
+ if (!hasProp.call(ref, name)) continue;
+ att = ref[name];
+ this.attribute(att);
+ }
+ if (node.children.length === 0 || node.children.every(function(e) {
+ return e.value === '';
+ })) {
+ if (this.allowEmpty) {
+ this.stream.write('></' + node.name + '>');
+ } else {
+ this.stream.write(this.spacebeforeslash + '/>');
+ }
+ } else if (this.pretty && node.children.length === 1 && (node.children[0].value != null)) {
+ this.stream.write('>');
+ this.stream.write(node.children[0].value);
+ this.stream.write('</' + node.name + '>');
+ } else {
+ this.stream.write('>' + this.newline);
+ ref1 = node.children;
+ for (i = 0, len = ref1.length; i < len; i++) {
+ child = ref1[i];
+ switch (false) {
+ case !(child instanceof XMLCData):
+ this.cdata(child, level + 1);
+ break;
+ case !(child instanceof XMLComment):
+ this.comment(child, level + 1);
+ break;
+ case !(child instanceof XMLElement):
+ this.element(child, level + 1);
+ break;
+ case !(child instanceof XMLRaw):
+ this.raw(child, level + 1);
+ break;
+ case !(child instanceof XMLText):
+ this.text(child, level + 1);
+ break;
+ case !(child instanceof XMLProcessingInstruction):
+ this.processingInstruction(child, level + 1);
+ break;
+ default:
+ throw new Error("Unknown XML node type: " + child.constructor.name);
+ }
+ }
+ this.stream.write(space + '</' + node.name + '>');
+ }
+ return this.stream.write(this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.processingInstruction = function(node, level) {
+ this.stream.write(this.space(level) + '<?' + node.target);
+ if (node.value) {
+ this.stream.write(' ' + node.value);
+ }
+ return this.stream.write(this.spacebeforeslash + '?>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.raw = function(node, level) {
+ return this.stream.write(this.space(level) + node.value + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.text = function(node, level) {
+ return this.stream.write(this.space(level) + node.value + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.dtdAttList = function(node, level) {
+ this.stream.write(this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType);
+ if (node.defaultValueType !== '#DEFAULT') {
+ this.stream.write(' ' + node.defaultValueType);
+ }
+ if (node.defaultValue) {
+ this.stream.write(' "' + node.defaultValue + '"');
+ }
+ return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.dtdElement = function(node, level) {
+ this.stream.write(this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value);
+ return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.dtdEntity = function(node, level) {
+ this.stream.write(this.space(level) + '<!ENTITY');
+ if (node.pe) {
+ this.stream.write(' %');
+ }
+ this.stream.write(' ' + node.name);
+ if (node.value) {
+ this.stream.write(' "' + node.value + '"');
+ } else {
+ if (node.pubID && node.sysID) {
+ this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
+ } else if (node.sysID) {
+ this.stream.write(' SYSTEM "' + node.sysID + '"');
+ }
+ if (node.nData) {
+ this.stream.write(' NDATA ' + node.nData);
+ }
+ }
+ return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.dtdNotation = function(node, level) {
+ this.stream.write(this.space(level) + '<!NOTATION ' + node.name);
+ if (node.pubID && node.sysID) {
+ this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
+ } else if (node.pubID) {
+ this.stream.write(' PUBLIC "' + node.pubID + '"');
+ } else if (node.sysID) {
+ this.stream.write(' SYSTEM "' + node.sysID + '"');
+ }
+ return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.endline = function(node) {
+ if (!node.isLastRootNode) {
+ return this.newline;
+ } else {
+ return '';
+ }
+ };
+
+ return XMLStreamWriter;
+
+ })(XMLWriterBase);
+
+}).call(this);
+
+},{"./XMLCData":10,"./XMLComment":11,"./XMLDTDAttList":12,"./XMLDTDElement":13,"./XMLDTDEntity":14,"./XMLDTDNotation":15,"./XMLDeclaration":16,"./XMLDocType":17,"./XMLElement":20,"./XMLProcessingInstruction":22,"./XMLRaw":23,"./XMLText":27,"./XMLWriterBase":28}],25:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLText, XMLWriterBase,
+ 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;
+
+ XMLDeclaration = require('./XMLDeclaration');
+
+ XMLDocType = require('./XMLDocType');
+
+ XMLCData = require('./XMLCData');
+
+ XMLComment = require('./XMLComment');
+
+ XMLElement = require('./XMLElement');
+
+ XMLRaw = require('./XMLRaw');
+
+ XMLText = require('./XMLText');
+
+ XMLProcessingInstruction = require('./XMLProcessingInstruction');
+
+ XMLDTDAttList = require('./XMLDTDAttList');
+
+ XMLDTDElement = require('./XMLDTDElement');
+
+ XMLDTDEntity = require('./XMLDTDEntity');
+
+ XMLDTDNotation = require('./XMLDTDNotation');
+
+ XMLWriterBase = require('./XMLWriterBase');
+
+ module.exports = XMLStringWriter = (function(superClass) {
+ extend(XMLStringWriter, superClass);
+
+ function XMLStringWriter(options) {
+ XMLStringWriter.__super__.constructor.call(this, options);
+ }
+
+ XMLStringWriter.prototype.document = function(doc) {
+ var child, i, len, r, ref;
+ this.textispresent = false;
+ r = '';
+ ref = doc.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ r += (function() {
+ switch (false) {
+ case !(child instanceof XMLDeclaration):
+ return this.declaration(child);
+ case !(child instanceof XMLDocType):
+ return this.docType(child);
+ case !(child instanceof XMLComment):
+ return this.comment(child);
+ case !(child instanceof XMLProcessingInstruction):
+ return this.processingInstruction(child);
+ default:
+ return this.element(child, 0);
+ }
+ }).call(this);
+ }
+ if (this.pretty && r.slice(-this.newline.length) === this.newline) {
+ r = r.slice(0, -this.newline.length);
+ }
+ return r;
+ };
+
+ XMLStringWriter.prototype.attribute = function(att) {
+ return ' ' + att.name + '="' + att.value + '"';
+ };
+
+ XMLStringWriter.prototype.cdata = function(node, level) {
+ return this.space(level) + '<![CDATA[' + node.text + ']]>' + this.newline;
+ };
+
+ XMLStringWriter.prototype.comment = function(node, level) {
+ return this.space(level) + '<!-- ' + node.text + ' -->' + this.newline;
+ };
+
+ XMLStringWriter.prototype.declaration = function(node, level) {
+ var r;
+ r = this.space(level);
+ r += '<?xml version="' + node.version + '"';
+ if (node.encoding != null) {
+ r += ' encoding="' + node.encoding + '"';
+ }
+ if (node.standalone != null) {
+ r += ' standalone="' + node.standalone + '"';
+ }
+ r += this.spacebeforeslash + '?>';
+ r += this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.docType = function(node, level) {
+ var child, i, len, r, ref;
+ level || (level = 0);
+ r = this.space(level);
+ r += '<!DOCTYPE ' + node.root().name;
+ if (node.pubID && node.sysID) {
+ r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
+ } else if (node.sysID) {
+ r += ' SYSTEM "' + node.sysID + '"';
+ }
+ if (node.children.length > 0) {
+ r += ' [';
+ r += this.newline;
+ ref = node.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ r += (function() {
+ switch (false) {
+ case !(child instanceof XMLDTDAttList):
+ return this.dtdAttList(child, level + 1);
+ case !(child instanceof XMLDTDElement):
+ return this.dtdElement(child, level + 1);
+ case !(child instanceof XMLDTDEntity):
+ return this.dtdEntity(child, level + 1);
+ case !(child instanceof XMLDTDNotation):
+ return this.dtdNotation(child, level + 1);
+ case !(child instanceof XMLCData):
+ return this.cdata(child, level + 1);
+ case !(child instanceof XMLComment):
+ return this.comment(child, level + 1);
+ case !(child instanceof XMLProcessingInstruction):
+ return this.processingInstruction(child, level + 1);
+ default:
+ throw new Error("Unknown DTD node type: " + child.constructor.name);
+ }
+ }).call(this);
+ }
+ r += ']';
+ }
+ r += this.spacebeforeslash + '>';
+ r += this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.element = function(node, level) {
+ var att, child, i, j, len, len1, name, r, ref, ref1, ref2, space, textispresentwasset;
+ level || (level = 0);
+ textispresentwasset = false;
+ if (this.textispresent) {
+ this.newline = '';
+ this.pretty = false;
+ } else {
+ this.newline = this.newlinedefault;
+ this.pretty = this.prettydefault;
+ }
+ space = this.space(level);
+ r = '';
+ r += space + '<' + node.name;
+ ref = node.attributes;
+ for (name in ref) {
+ if (!hasProp.call(ref, name)) continue;
+ att = ref[name];
+ r += this.attribute(att);
+ }
+ if (node.children.length === 0 || node.children.every(function(e) {
+ return e.value === '';
+ })) {
+ if (this.allowEmpty) {
+ r += '></' + node.name + '>' + this.newline;
+ } else {
+ r += this.spacebeforeslash + '/>' + this.newline;
+ }
+ } else if (this.pretty && node.children.length === 1 && (node.children[0].value != null)) {
+ r += '>';
+ r += node.children[0].value;
+ r += '</' + node.name + '>' + this.newline;
+ } else {
+ if (this.dontprettytextnodes) {
+ ref1 = node.children;
+ for (i = 0, len = ref1.length; i < len; i++) {
+ child = ref1[i];
+ if (child.value != null) {
+ this.textispresent++;
+ textispresentwasset = true;
+ break;
+ }
+ }
+ }
+ if (this.textispresent) {
+ this.newline = '';
+ this.pretty = false;
+ space = this.space(level);
+ }
+ r += '>' + this.newline;
+ ref2 = node.children;
+ for (j = 0, len1 = ref2.length; j < len1; j++) {
+ child = ref2[j];
+ r += (function() {
+ switch (false) {
+ case !(child instanceof XMLCData):
+ return this.cdata(child, level + 1);
+ case !(child instanceof XMLComment):
+ return this.comment(child, level + 1);
+ case !(child instanceof XMLElement):
+ return this.element(child, level + 1);
+ case !(child instanceof XMLRaw):
+ return this.raw(child, level + 1);
+ case !(child instanceof XMLText):
+ return this.text(child, level + 1);
+ case !(child instanceof XMLProcessingInstruction):
+ return this.processingInstruction(child, level + 1);
+ default:
+ throw new Error("Unknown XML node type: " + child.constructor.name);
+ }
+ }).call(this);
+ }
+ if (textispresentwasset) {
+ this.textispresent--;
+ }
+ if (!this.textispresent) {
+ this.newline = this.newlinedefault;
+ this.pretty = this.prettydefault;
+ }
+ r += space + '</' + node.name + '>' + this.newline;
+ }
+ return r;
+ };
+
+ XMLStringWriter.prototype.processingInstruction = function(node, level) {
+ var r;
+ r = this.space(level) + '<?' + node.target;
+ if (node.value) {
+ r += ' ' + node.value;
+ }
+ r += this.spacebeforeslash + '?>' + this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.raw = function(node, level) {
+ return this.space(level) + node.value + this.newline;
+ };
+
+ XMLStringWriter.prototype.text = function(node, level) {
+ return this.space(level) + node.value + this.newline;
+ };
+
+ XMLStringWriter.prototype.dtdAttList = function(node, level) {
+ var r;
+ r = this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType;
+ if (node.defaultValueType !== '#DEFAULT') {
+ r += ' ' + node.defaultValueType;
+ }
+ if (node.defaultValue) {
+ r += ' "' + node.defaultValue + '"';
+ }
+ r += this.spacebeforeslash + '>' + this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.dtdElement = function(node, level) {
+ return this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value + this.spacebeforeslash + '>' + this.newline;
+ };
+
+ XMLStringWriter.prototype.dtdEntity = function(node, level) {
+ var r;
+ r = this.space(level) + '<!ENTITY';
+ if (node.pe) {
+ r += ' %';
+ }
+ r += ' ' + node.name;
+ if (node.value) {
+ r += ' "' + node.value + '"';
+ } else {
+ if (node.pubID && node.sysID) {
+ r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
+ } else if (node.sysID) {
+ r += ' SYSTEM "' + node.sysID + '"';
+ }
+ if (node.nData) {
+ r += ' NDATA ' + node.nData;
+ }
+ }
+ r += this.spacebeforeslash + '>' + this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.dtdNotation = function(node, level) {
+ var r;
+ r = this.space(level) + '<!NOTATION ' + node.name;
+ if (node.pubID && node.sysID) {
+ r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
+ } else if (node.pubID) {
+ r += ' PUBLIC "' + node.pubID + '"';
+ } else if (node.sysID) {
+ r += ' SYSTEM "' + node.sysID + '"';
+ }
+ r += this.spacebeforeslash + '>' + this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.openNode = function(node, level) {
+ var att, name, r, ref;
+ level || (level = 0);
+ if (node instanceof XMLElement) {
+ r = this.space(level) + '<' + node.name;
+ ref = node.attributes;
+ for (name in ref) {
+ if (!hasProp.call(ref, name)) continue;
+ att = ref[name];
+ r += this.attribute(att);
+ }
+ r += (node.children ? '>' : '/>') + this.newline;
+ return r;
+ } else {
+ r = this.space(level) + '<!DOCTYPE ' + node.rootNodeName;
+ if (node.pubID && node.sysID) {
+ r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
+ } else if (node.sysID) {
+ r += ' SYSTEM "' + node.sysID + '"';
+ }
+ r += (node.children ? ' [' : '>') + this.newline;
+ return r;
+ }
+ };
+
+ XMLStringWriter.prototype.closeNode = function(node, level) {
+ level || (level = 0);
+ switch (false) {
+ case !(node instanceof XMLElement):
+ return this.space(level) + '</' + node.name + '>' + this.newline;
+ case !(node instanceof XMLDocType):
+ return this.space(level) + ']>' + this.newline;
+ }
+ };
+
+ return XMLStringWriter;
+
+ })(XMLWriterBase);
+
+}).call(this);
+
+},{"./XMLCData":10,"./XMLComment":11,"./XMLDTDAttList":12,"./XMLDTDElement":13,"./XMLDTDEntity":14,"./XMLDTDNotation":15,"./XMLDeclaration":16,"./XMLDocType":17,"./XMLElement":20,"./XMLProcessingInstruction":22,"./XMLRaw":23,"./XMLText":27,"./XMLWriterBase":28}],26:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(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;
+ options || (options = {});
+ this.noDoubleEncoding = options.noDoubleEncoding;
+ ref = options.stringify || {};
+ 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 || '';
+ val = val.replace(']]>', ']]]]><![CDATA[>');
+ 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 = '' + 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 res;
+ res = str.match(/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/);
+ if (res) {
+ throw new Error("Invalid character in string: " + str + " at index " + res.index);
+ }
+ return str;
+ };
+
+ XMLStringifier.prototype.elEscape = function(str) {
+ var ampregex;
+ ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
+ return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\r/g, '&#xD;');
+ };
+
+ XMLStringifier.prototype.attEscape = function(str) {
+ var ampregex;
+ ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
+ return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/\t/g, '&#x9;').replace(/\n/g, '&#xA;').replace(/\r/g, '&#xD;');
+ };
+
+ return XMLStringifier;
+
+ })();
+
+}).call(this);
+
+},{}],27:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLNode, XMLText,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLText = (function(superClass) {
+ extend(XMLText, superClass);
+
+ function XMLText(parent, text) {
+ XMLText.__super__.constructor.call(this, parent);
+ if (text == null) {
+ throw new Error("Missing element text");
+ }
+ this.value = this.stringify.eleText(text);
+ }
+
+ XMLText.prototype.clone = function() {
+ return Object.create(this);
+ };
+
+ XMLText.prototype.toString = function(options) {
+ return this.options.writer.set(options).text(this);
+ };
+
+ return XMLText;
+
+ })(XMLNode);
+
+}).call(this);
+
+},{"./XMLNode":21}],28:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLWriterBase,
+ hasProp = {}.hasOwnProperty;
+
+ module.exports = XMLWriterBase = (function() {
+ function XMLWriterBase(options) {
+ var key, ref, ref1, ref2, ref3, ref4, ref5, ref6, value;
+ options || (options = {});
+ this.pretty = options.pretty || false;
+ this.allowEmpty = (ref = options.allowEmpty) != null ? ref : false;
+ if (this.pretty) {
+ this.indent = (ref1 = options.indent) != null ? ref1 : ' ';
+ this.newline = (ref2 = options.newline) != null ? ref2 : '\n';
+ this.offset = (ref3 = options.offset) != null ? ref3 : 0;
+ this.dontprettytextnodes = (ref4 = options.dontprettytextnodes) != null ? ref4 : 0;
+ } else {
+ this.indent = '';
+ this.newline = '';
+ this.offset = 0;
+ this.dontprettytextnodes = 0;
+ }
+ this.spacebeforeslash = (ref5 = options.spacebeforeslash) != null ? ref5 : '';
+ if (this.spacebeforeslash === true) {
+ this.spacebeforeslash = ' ';
+ }
+ this.newlinedefault = this.newline;
+ this.prettydefault = this.pretty;
+ ref6 = options.writer || {};
+ for (key in ref6) {
+ if (!hasProp.call(ref6, key)) continue;
+ value = ref6[key];
+ this[key] = value;
+ }
+ }
+
+ XMLWriterBase.prototype.set = function(options) {
+ var key, ref, value;
+ options || (options = {});
+ if ("pretty" in options) {
+ this.pretty = options.pretty;
+ }
+ if ("allowEmpty" in options) {
+ this.allowEmpty = options.allowEmpty;
+ }
+ if (this.pretty) {
+ this.indent = "indent" in options ? options.indent : ' ';
+ this.newline = "newline" in options ? options.newline : '\n';
+ this.offset = "offset" in options ? options.offset : 0;
+ this.dontprettytextnodes = "dontprettytextnodes" in options ? options.dontprettytextnodes : 0;
+ } else {
+ this.indent = '';
+ this.newline = '';
+ this.offset = 0;
+ this.dontprettytextnodes = 0;
+ }
+ this.spacebeforeslash = "spacebeforeslash" in options ? options.spacebeforeslash : '';
+ if (this.spacebeforeslash === true) {
+ this.spacebeforeslash = ' ';
+ }
+ this.newlinedefault = this.newline;
+ this.prettydefault = this.pretty;
+ ref = options.writer || {};
+ for (key in ref) {
+ if (!hasProp.call(ref, key)) continue;
+ value = ref[key];
+ this[key] = value;
+ }
+ return this;
+ };
+
+ XMLWriterBase.prototype.space = function(level) {
+ var indent;
+ if (this.pretty) {
+ indent = (level || 0) + this.offset + 1;
+ if (indent > 0) {
+ return new Array(indent).join(this.indent);
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ };
+
+ return XMLWriterBase;
+
+ })();
+
+}).call(this);
+
+},{}],29:[function(require,module,exports){
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
+
+ ref = require('./Utility'), assign = ref.assign, isFunction = ref.isFunction;
+
+ XMLDocument = require('./XMLDocument');
+
+ XMLDocumentCB = require('./XMLDocumentCB');
+
+ XMLStringWriter = require('./XMLStringWriter');
+
+ XMLStreamWriter = require('./XMLStreamWriter');
+
+ module.exports.create = function(name, xmldec, doctype, options) {
+ var doc, root;
+ if (name == null) {
+ throw new Error("Root element needs a name");
+ }
+ options = assign({}, xmldec, doctype, options);
+ doc = new XMLDocument(options);
+ root = doc.element(name);
+ if (!options.headless) {
+ doc.declaration(options);
+ if ((options.pubID != null) || (options.sysID != null)) {
+ doc.doctype(options);
+ }
+ }
+ return root;
+ };
+
+ module.exports.begin = function(options, onData, onEnd) {
+ var ref1;
+ if (isFunction(options)) {
+ ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
+ options = {};
+ }
+ if (onData) {
+ return new XMLDocumentCB(options, onData, onEnd);
+ } else {
+ return new XMLDocument(options);
+ }
+ };
+
+ module.exports.stringWriter = function(options) {
+ return new XMLStringWriter(options);
+ };
+
+ module.exports.streamWriter = function(stream, options) {
+ return new XMLStreamWriter(stream, options);
+ };
+
+}).call(this);
+
+},{"./Utility":8,"./XMLDocument":18,"./XMLDocumentCB":19,"./XMLStreamWriter":24,"./XMLStringWriter":25}],30:[function(require,module,exports){
+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 = require('./sax').XMLReader;
+ var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation;
+ exports.XMLSerializer = require('./dom').XMLSerializer ;
+ exports.DOMParser = DOMParser;
+//}
+
+},{"./dom":31,"./sax":32}],31:[function(require,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<this.length;i++){
+ serializeToString(this[i],buf,isHTML,nodeFilter);
+ }
+ return buf.join('');
+ }
+};
+function LiveNodeList(node,refresh){
+ this._node = node;
+ this._refresh = refresh
+ _updateLiveList(this);
+}
+function _updateLiveList(list){
+ var inc = list._node._inc || list._node.ownerDocument._inc;
+ if(list._inc != inc){
+ var ls = list._refresh(list._node);
+ //console.log(ls.length)
+ __set__(list,'length',ls.length);
+ copy(ls,list);
+ list._inc = inc;
+ }
+}
+LiveNodeList.prototype.item = function(i){
+ _updateLiveList(this);
+ return this[i];
+}
+
+_extends(LiveNodeList,NodeList);
+/**
+ *
+ * Objects implementing the NamedNodeMap interface are used to represent collections of nodes that can be accessed by name. Note that NamedNodeMap does not inherit from NodeList; NamedNodeMaps are not maintained in any particular order. Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index, but this is simply to allow convenient enumeration of the contents of a NamedNodeMap, and does not imply that the DOM specifies an order to these Nodes.
+ * NamedNodeMap objects in the DOM are live.
+ * used for attributes or DocumentType entities
+ */
+function NamedNodeMap() {
+};
+
+function _findNodeIndex(list,node){
+ var i = list.length;
+ while(i--){
+ if(list[i] === node){return i}
+ }
+}
+
+function _addNamedNode(el,list,newAttr,oldAttr){
+ if(oldAttr){
+ list[_findNodeIndex(list,oldAttr)] = newAttr;
+ }else{
+ list[list.length++] = newAttr;
+ }
+ if(el){
+ newAttr.ownerElement = el;
+ var doc = el.ownerDocument;
+ if(doc){
+ oldAttr && _onRemoveAttribute(doc,el,oldAttr);
+ _onAddAttribute(doc,el,newAttr);
+ }
+ }
+}
+function _removeNamedNode(el,list,attr){
+ //console.log('remove attr:'+attr)
+ var i = _findNodeIndex(list,attr);
+ if(i>=0){
+ var lastIndex = list.length-1
+ while(i<lastIndex){
+ list[i] = list[++i]
+ }
+ list.length = lastIndex;
+ if(el){
+ var doc = el.ownerDocument;
+ if(doc){
+ _onRemoveAttribute(doc,el,attr);
+ attr.ownerElement = null;
+ }
+ }
+ }else{
+ throw DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr))
+ }
+}
+NamedNodeMap.prototype = {
+ length:0,
+ item:NodeList.prototype.item,
+ getNamedItem: function(key) {
+// if(key.indexOf(':')>0 || 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 == '<' && '&lt;' ||
+ c == '>' && '&gt;' ||
+ c == '&' && '&amp;' ||
+ c == '"' && '&quot;' ||
+ '&#'+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<len;i++){
+ // add namespaces for attributes
+ var attr = attrs.item(i);
+ if (attr.prefix == 'xmlns') {
+ visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
+ }else if(attr.nodeName == 'xmlns'){
+ visibleNamespaces.push({ prefix: '', namespace: attr.value });
+ }
+ }
+ for(var i=0;i<len;i++){
+ var attr = attrs.item(i);
+ if (needNamespaceDefine(attr,isHTML, visibleNamespaces)) {
+ var prefix = attr.prefix||'';
+ var uri = attr.namespaceURI;
+ var ns = prefix ? ' xmlns:' + prefix : " xmlns";
+ buf.push(ns, '="' , uri , '"');
+ visibleNamespaces.push({ prefix: prefix, namespace:uri });
+ }
+ serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
+ }
+ // add namespace for current node
+ if (needNamespaceDefine(node,isHTML, visibleNamespaces)) {
+ var prefix = node.prefix||'';
+ var uri = node.namespaceURI;
+ var ns = prefix ? ' xmlns:' + prefix : " xmlns";
+ buf.push(ns, '="' , uri , '"');
+ visibleNamespaces.push({ prefix: prefix, namespace:uri });
+ }
+
+ if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
+ buf.push('>');
+ //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('</',nodeName,'>');
+ }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( '<![CDATA[',node.data,']]>');
+ case COMMENT_NODE:
+ return buf.push( "<!--",node.data,"-->");
+ case DOCUMENT_TYPE_NODE:
+ var pubid = node.publicId;
+ var sysid = node.systemId;
+ buf.push('<!DOCTYPE ',node.name);
+ if(pubid){
+ buf.push(' PUBLIC "',pubid);
+ if (sysid && sysid!='.') {
+ buf.push( '" "',sysid);
+ }
+ 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( "<?",node.target," ",node.data,"?>");
+ 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<len;i++){
+ //node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep));
+ //}
+ case DOCUMENT_FRAGMENT_NODE:
+ break;
+ case ATTRIBUTE_NODE:
+ deep = true;
+ break;
+ //case ENTITY_REFERENCE_NODE:
+ //case PROCESSING_INSTRUCTION_NODE:
+ ////case TEXT_NODE:
+ //case CDATA_SECTION_NODE:
+ //case COMMENT_NODE:
+ // deep = false;
+ // break;
+ //case DOCUMENT_NODE:
+ //case DOCUMENT_TYPE_NODE:
+ //cannot be imported.
+ //case ENTITY_NODE:
+ //case NOTATION_NODE:
+ //can not hit in level3
+ //default:throw e;
+ }
+ if(!node2){
+ node2 = node.cloneNode(false);//false
+ }
+ node2.ownerDocument = doc;
+ node2.parentNode = null;
+ if(deep){
+ var child = node.firstChild;
+ while(child){
+ node2.appendChild(importNode(doc,child,deep));
+ child = child.nextSibling;
+ }
+ }
+ return node2;
+}
+//
+//var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
+// attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
+function cloneNode(doc,node,deep){
+ var node2 = new node.constructor();
+ for(var n in node){
+ var v = node[n];
+ if(typeof v != 'object' ){
+ if(v != node2[n]){
+ node2[n] = v;
+ }
+ }
+ }
+ if(node.childNodes){
+ node2.childNodes = new NodeList();
+ }
+ node2.ownerDocument = doc;
+ switch (node2.nodeType) {
+ case ELEMENT_NODE:
+ var attrs = node.attributes;
+ var attrs2 = node2.attributes = new NamedNodeMap();
+ var len = attrs.length
+ attrs2._ownerElement = node2;
+ for(var i=0;i<len;i++){
+ node2.setAttributeNode(cloneNode(doc,attrs.item(i),true));
+ }
+ break;;
+ case ATTRIBUTE_NODE:
+ deep = true;
+ }
+ if(deep){
+ var child = node.firstChild;
+ while(child){
+ node2.appendChild(cloneNode(doc,child,deep));
+ child = child.nextSibling;
+ }
+ }
+ return node2;
+}
+
+function __set__(object,key,value){
+ object[key] = value
+}
+//do dynamic
+try{
+ if(Object.defineProperty){
+ Object.defineProperty(LiveNodeList.prototype,'length',{
+ get:function(){
+ _updateLiveList(this);
+ return this.$$length;
+ }
+ });
+ Object.defineProperty(Node.prototype,'textContent',{
+ get:function(){
+ return getTextContent(this);
+ },
+ set:function(data){
+ switch(this.nodeType){
+ case ELEMENT_NODE:
+ case DOCUMENT_FRAGMENT_NODE:
+ while(this.firstChild){
+ this.removeChild(this.firstChild);
+ }
+ if(data || String(data)){
+ this.appendChild(this.ownerDocument.createTextNode(data));
+ }
+ break;
+ default:
+ //TODO:
+ this.data = data;
+ this.value = data;
+ this.nodeValue = data;
+ }
+ }
+ })
+
+ function getTextContent(node){
+ switch(node.nodeType){
+ case ELEMENT_NODE:
+ case DOCUMENT_FRAGMENT_NODE:
+ var buf = [];
+ node = node.firstChild;
+ while(node){
+ if(node.nodeType!==7 && node.nodeType !==8){
+ buf.push(getTextContent(node));
+ }
+ node = node.nextSibling;
+ }
+ return buf.join('');
+ default:
+ return node.nodeValue;
+ }
+ }
+ __set__ = function(object,key,value){
+ //console.log(value)
+ object['$$'+key] = value
+ }
+ }
+}catch(e){//ie8
+}
+
+//if(typeof require == 'function'){
+ exports.DOMImplementation = DOMImplementation;
+ exports.XMLSerializer = XMLSerializer;
+//}
+
+},{}],32:[function(require,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<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</)){
+ tagName = tagName.replace(/[\s<].*/,'');
+ errorHandler.error("end tag name: "+tagName+' maybe not complete');
+ end = tagStart+1+tagName.length;
+ }
+ //console.error(parseStack.length,parseStack)
+ //console.error(config);
+ var localNSMap = config.localNSMap;
+ var endMatch = config.tagName == tagName;
+ var endIgnoreCaseMach = endMatch || config.tagName&&config.tagName.toLowerCase() == tagName.toLowerCase()
+ if(endIgnoreCaseMach){
+ domBuilder.endElement(config.uri,config.localName,tagName);
+ if(localNSMap){
+ for(var prefix in localNSMap){
+ domBuilder.endPrefixMapping(prefix) ;
+ }
+ }
+ if(!endMatch){
+ errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName );
+ }
+ }else{
+ parseStack.push(config)
+ }
+
+ end++;
+ break;
+ // end elment
+ case '?':// <?...?>
+ locator&&position(tagStart);
+ end = parseInstruction(source,tagStart,domBuilder);
+ break;
+ case '!':// <!doctype,<![CDATA,<!--
+ locator&&position(tagStart);
+ end = parseDCC(source,tagStart,domBuilder,errorHandler);
+ break;
+ default:
+ locator&&position(tagStart);
+ var el = new ElementAttributes();
+ var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
+ //elStartEnd
+ var end = parseElementStartPart(source,tagStart,el,currentNSMap,entityReplacer,errorHandler);
+ var len = el.length;
+
+
+ if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){
+ el.closed = true;
+ if(!entityMap.nbsp){
+ errorHandler.warning('unclosed xml attribute');
+ }
+ }
+ if(locator && len){
+ var locator2 = copyLocator(locator,{});
+ //try{//attribute position fixed
+ for(var i = 0;i<len;i++){
+ var a = el[i];
+ position(a.offset);
+ a.locator = copyLocator(locator,{});
+ }
+ //}catch(e){console.error('@@@@@'+e)}
+ domBuilder.locator = locator2
+ if(appendElement(el,domBuilder,currentNSMap)){
+ parseStack.push(el)
+ }
+ domBuilder.locator = locator;
+ }else{
+ if(appendElement(el,domBuilder,currentNSMap)){
+ parseStack.push(el)
+ }
+ }
+
+
+
+ if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){
+ end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder)
+ }else{
+ end++;
+ }
+ }
+ }catch(e){
+ errorHandler.error('element parse error: '+e)
+ //errorHandler.error('element parse error: '+e);
+ end = -1;
+ //throw e;
+ }
+ if(end>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('</'+tagName+'>',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('</'+tagName+'>')
+ if(pos<elStartEnd){//忘记闭合
+ pos = source.lastIndexOf('</'+tagName)
+ }
+ closeMap[tagName] =pos
+ }
+ return pos<elStartEnd;
+ //}
+}
+function _copy(source,target){
+ for(var n in source){target[n] = source[n]}
+}
+function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
+ var next= source.charAt(start+2)
+ switch(next){
+ case '-':
+ if(source.charAt(start + 3) === '-'){
+ var end = source.indexOf('-->',start+4);
+ //append comment source.substring(4,end)//<!--
+ if(end>start){
+ domBuilder.comment(source,start+4,end-start-4);
+ return end+3;
+ }else{
+ errorHandler.error("Unclosed comment");
+ return -1;
+ }
+ }else{
+ //error
+ return -1;
+ }
+ default:
+ if(source.substr(start+3,6) == 'CDATA['){
+ var end = source.indexOf(']]>',start+9);
+ domBuilder.startCDATA();
+ domBuilder.characters(source,start+9,end-start-9);
+ domBuilder.endCDATA()
+ return end+3;
+ }
+ //<!DOCTYPE
+ //startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
+ var matchs = split(source,start);
+ var len = matchs.length;
+ if(len>1 && /!doctype/i.test(matchs[0][0])){
+ var name = matchs[1][0];
+ var pubid = len>3 && /^public$/i.test(matchs[2][0]) && matchs[3][0]
+ var sysid = len>4 && matchs[4][0];
+ var lastMatch = matchs[len-1]
+ domBuilder.startDTD(name,pubid && pubid.replace(/^(['"])(.*?)\1$/,'$2'),
+ sysid && sysid.replace(/^(['"])(.*?)\1$/,'$2'));
+ domBuilder.endDTD();
+
+ return lastMatch.index+lastMatch[0].length
+ }
+ }
+ return -1;
+}
+
+
+
+function parseInstruction(source,start,domBuilder){
+ var end = source.indexOf('?>',start);
+ if(end){
+ var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
+ if(match){
+ var len = match[0].length;
+ domBuilder.processingInstruction(match[1], match[2]) ;
+ return end+2;
+ }else{//error
+ return -1;
+ }
+ }
+ return -1;
+}
+
+/**
+ * @param source
+ */
+function ElementAttributes(source){
+
+}
+ElementAttributes.prototype = {
+ setTagName:function(tagName){
+ if(!tagNamePattern.test(tagName)){
+ throw new Error('invalid tagName:'+tagName)
+ }
+ this.tagName = tagName
+ },
+ add:function(qName,value,offset){
+ if(!tagNamePattern.test(qName)){
+ throw new Error('invalid attribute:'+qName)
+ }
+ this[this.length++] = {qName:qName,value:value,offset:offset}
+ },
+ length:0,
+ getLocalName:function(i){return this[i].localName},
+ getLocator:function(i){return this[i].locator},
+ getQName:function(i){return this[i].qName},
+ getURI:function(i){return this[i].uri},
+ getValue:function(i){return this[i].value}
+// ,getIndex:function(uri, localName)){
+// if(localName){
+//
+// }else{
+// var qName = uri
+// }
+// },
+// getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
+// getType:function(uri,localName){}
+// getType:function(i){},
+}
+
+
+
+
+function _set_proto_(thiz,parent){
+ thiz.__proto__ = parent;
+ return thiz;
+}
+if(!(_set_proto_({},_set_proto_.prototype) instanceof _set_proto_)){
+ _set_proto_ = function(thiz,parent){
+ function p(){};
+ p.prototype = parent;
+ p = new p();
+ for(parent in thiz){
+ p[parent] = thiz[parent];
+ }
+ return p;
+ }
+}
+
+function split(source,start){
+ var match;
+ var buf = [];
+ var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
+ reg.lastIndex = start;
+ reg.exec(source);//skip <
+ while(match = reg.exec(source)){
+ buf.push(match);
+ if(match[1])return buf;
+ }
+}
+
+exports.XMLReader = XMLReader;
+
+
+},{}]},{},[1])(1)
+});
diff --git a/cordova/node_modules/ios-sim/node_modules/plist/examples/browser/index.html b/cordova/node_modules/ios-sim/node_modules/plist/examples/browser/index.html
new file mode 100644
index 0000000..8ce7d92
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/plist/examples/browser/index.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>plist.js browser example</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ </head>
+ <body>
+ <script src="../../dist/plist.js"></script>
+ <script>
+ // TODO: add <input type=file> drag and drop example
+ console.log(plist);
+ </script>
+ </body>
+</html>
diff --git a/cordova/node_modules/ios-sim/node_modules/plist/index.js b/cordova/node_modules/ios-sim/node_modules/plist/index.js
new file mode 100644
index 0000000..d7385ae
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/plist/index.js
@@ -0,0 +1,13 @@
+/**
+ * Parser functions.
+ */
+
+var parserFunctions = require('./lib/parse');
+Object.keys(parserFunctions).forEach(function (k) { exports[k] = parserFunctions[k]; });
+
+/**
+ * Builder functions.
+ */
+
+var builderFunctions = require('./lib/build');
+Object.keys(builderFunctions).forEach(function (k) { exports[k] = builderFunctions[k]; });
diff --git a/cordova/node_modules/ios-sim/node_modules/plist/lib/build.js b/cordova/node_modules/ios-sim/node_modules/plist/lib/build.js
new file mode 100644
index 0000000..83ea557
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/plist/lib/build.js
@@ -0,0 +1,137 @@
+/**
+ * Module dependencies.
+ */
+
+var base64 = require('base64-js');
+var xmlbuilder = require('xmlbuilder');
+
+/**
+ * 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));
+
+ }
+}
diff --git a/cordova/node_modules/ios-sim/node_modules/plist/lib/parse.js b/cordova/node_modules/ios-sim/node_modules/plist/lib/parse.js
new file mode 100644
index 0000000..76f7cf6
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/plist/lib/parse.js
@@ -0,0 +1,215 @@
+/**
+ * Module dependencies.
+ */
+
+var DOMParser = require('xmldom').DOMParser;
+
+/**
+ * Module exports.
+ */
+
+exports.parse = parse;
+
+var TEXT_NODE = 3;
+var CDATA_NODE = 4;
+var COMMENT_NODE = 8;
+
+
+/**
+ * We ignore raw text (usually whitespace), <!-- xml comments -->,
+ * and raw CDATA nodes.
+ *
+ * @param {Element} node
+ * @returns {Boolean}
+ * @api private
+ */
+
+function shouldIgnoreNode (node) {
+ return node.nodeType === TEXT_NODE
+ || node.nodeType === COMMENT_NODE
+ || node.nodeType === CDATA_NODE;
+}
+
+/**
+ * Check if the node is empty. Some plist file has such node:
+ * <key />
+ * this node shoud be ignored.
+ *
+ * @see https://github.com/TooTallNate/plist.js/issues/66
+ * @param {Element} node
+ * @returns {Boolean}
+ * @api private
+ */
+function isEmptyNode(node){
+ if(!node.childNodes || node.childNodes.length === 0) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+function invariant(test, message) {
+ if (!test) {
+ throw new Error(message);
+ }
+}
+
+/**
+ * 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);
+ invariant(
+ doc.documentElement.nodeName === 'plist',
+ 'malformed document. First element should be <plist>'
+ );
+ var plist = parsePlistXML(doc.documentElement);
+
+ // the root <plist> node gets interpreted as an Array,
+ // so pull out the inner data first
+ 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, counter, type;
+
+ if (!node)
+ return null;
+
+ if (node.nodeName === 'plist') {
+ new_arr = [];
+ if (isEmptyNode(node)) {
+ return new_arr;
+ }
+ for (i=0; i < node.childNodes.length; i++) {
+ if (!shouldIgnoreNode(node.childNodes[i])) {
+ new_arr.push( parsePlistXML(node.childNodes[i]));
+ }
+ }
+ return new_arr;
+ } else if (node.nodeName === 'dict') {
+ new_obj = {};
+ key = null;
+ counter = 0;
+ if (isEmptyNode(node)) {
+ return new_obj;
+ }
+ for (i=0; i < node.childNodes.length; i++) {
+ if (shouldIgnoreNode(node.childNodes[i])) continue;
+ if (counter % 2 === 0) {
+ invariant(
+ node.childNodes[i].nodeName === 'key',
+ 'Missing key while parsing <dict/>.'
+ );
+ key = parsePlistXML(node.childNodes[i]);
+ } else {
+ invariant(
+ node.childNodes[i].nodeName !== 'key',
+ 'Unexpected key "'
+ + parsePlistXML(node.childNodes[i])
+ + '" while parsing <dict/>.'
+ );
+ new_obj[key] = parsePlistXML(node.childNodes[i]);
+ }
+ counter += 1;
+ }
+ if (counter % 2 === 1) {
+ throw new Error('Missing value for "' + key + '" while parsing <dict/>');
+ }
+ return new_obj;
+
+ } else if (node.nodeName === 'array') {
+ new_arr = [];
+ if (isEmptyNode(node)) {
+ return new_arr;
+ }
+ for (i=0; i < node.childNodes.length; i++) {
+ 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') {
+ if (isEmptyNode(node)) {
+ return '';
+ }
+ return node.childNodes[0].nodeValue;
+ } else if (node.nodeName === 'string') {
+ res = '';
+ if (isEmptyNode(node)) {
+ return res;
+ }
+ for (i=0; i < node.childNodes.length; i++) {
+ var type = node.childNodes[i].nodeType;
+ if (type === TEXT_NODE || type === CDATA_NODE) {
+ res += node.childNodes[i].nodeValue;
+ }
+ }
+ return res;
+
+ } else if (node.nodeName === 'integer') {
+ invariant(
+ !isEmptyNode(node),
+ 'Cannot parse "" as integer.'
+ );
+ return parseInt(node.childNodes[0].nodeValue, 10);
+
+ } else if (node.nodeName === 'real') {
+ invariant(
+ !isEmptyNode(node),
+ 'Cannot parse "" as real.'
+ );
+ res = '';
+ for (i=0; i < node.childNodes.length; i++) {
+ if (node.childNodes[i].nodeType === TEXT_NODE) {
+ res += node.childNodes[i].nodeValue;
+ }
+ }
+ return parseFloat(res);
+
+ } else if (node.nodeName === 'data') {
+ res = '';
+ if (isEmptyNode(node)) {
+ return Buffer.from(res, 'base64');
+ }
+ for (i=0; i < node.childNodes.length; i++) {
+ if (node.childNodes[i].nodeType === TEXT_NODE) {
+ res += node.childNodes[i].nodeValue.replace(/\s+/g, '');
+ }
+ }
+ return Buffer.from(res, 'base64');
+
+ } else if (node.nodeName === 'date') {
+ invariant(
+ !isEmptyNode(node),
+ 'Cannot parse "" as Date.'
+ )
+ return new Date(node.childNodes[0].nodeValue);
+
+ } else if (node.nodeName === 'true') {
+ return true;
+
+ } else if (node.nodeName === 'false') {
+ return false;
+ }
+}
diff --git a/cordova/node_modules/ios-sim/node_modules/plist/package.json b/cordova/node_modules/ios-sim/node_modules/plist/package.json
new file mode 100644
index 0000000..1f2395e
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/plist/package.json
@@ -0,0 +1,88 @@
+{
+ "_from": "plist@^3.0.1",
+ "_id": "[email protected]",
+ "_inBundle": false,
+ "_integrity": "sha512-GpgvHHocGRyQm74b6FWEZZVRroHKE1I0/BTjAmySaohK+cUn+hZpbqXkc3KWgW3gQYkqcQej35FohcT0FRlkRQ==",
+ "_location": "/ios-sim/plist",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "plist@^3.0.1",
+ "name": "plist",
+ "escapedName": "plist",
+ "rawSpec": "^3.0.1",
+ "saveSpec": null,
+ "fetchSpec": "^3.0.1"
+ },
+ "_requiredBy": [
+ "/ios-sim"
+ ],
+ "_resolved": "https://registry.npmjs.org/plist/-/plist-3.0.1.tgz",
+ "_shasum": "a9b931d17c304e8912ef0ba3bdd6182baf2e1f8c",
+ "_spec": "plist@^3.0.1",
+ "_where": "/Users/lucifer/Desktop/weatherApp/platforms/ios/cordova/node_modules/ios-sim",
+ "author": {
+ "name": "Nathan Rajlich",
+ "email": "[email protected]"
+ },
+ "bugs": {
+ "url": "https://github.com/TooTallNate/node-plist/issues"
+ },
+ "bundleDependencies": false,
+ "contributors": [
+ {
+ "name": "Hans Huebner",
+ "email": "[email protected]"
+ },
+ {
+ "name": "Pierre Metrailler"
+ },
+ {
+ "name": "Mike Reinstein",
+ "email": "[email protected]"
+ },
+ {
+ "name": "Vladimir Tsvang"
+ },
+ {
+ "name": "Mathieu D'Amours"
+ }
+ ],
+ "dependencies": {
+ "base64-js": "^1.2.3",
+ "xmlbuilder": "^9.0.7",
+ "xmldom": "0.1.x"
+ },
+ "deprecated": false,
+ "description": "Mac OS X Plist parser/builder for Node.js and browsers",
+ "devDependencies": {
+ "browserify": "^16.1.1",
+ "mocha": "^5.0.4",
+ "multiline": "^1.0.2",
+ "zuul": "^3.10.1"
+ },
+ "engines": {
+ "node": ">=6"
+ },
+ "homepage": "https://github.com/TooTallNate/node-plist#readme",
+ "keywords": [
+ "apple",
+ "browser",
+ "mac",
+ "plist",
+ "parser",
+ "xml"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "name": "plist",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/TooTallNate/node-plist.git"
+ },
+ "scripts": {
+ "test": "make test"
+ },
+ "version": "3.0.1"
+}
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/.npmignore b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/.npmignore
new file mode 100644
index 0000000..b6ad1f6
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/.npmignore
@@ -0,0 +1,5 @@
+.travis.yml
+src
+test
+perf
+coverage
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/CHANGELOG.md b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/CHANGELOG.md
new file mode 100644
index 0000000..6264283
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/CHANGELOG.md
@@ -0,0 +1,423 @@
+# Change Log
+
+All notable changes to this project are documented in this file. This project adheres to [Semantic Versioning](http://semver.org/#semantic-versioning-200).
+
+## [9.0.4] - 2017-08-16
+- `spacebeforeslash` writer option accepts `true` as well as space char(s).
+
+## [9.0.3] - 2017-08-15
+- `spacebeforeslash` writer option can now be used with XML fragments.
+
+## [9.0.2] - 2017-08-15
+- Added the `spacebeforeslash` writer option to add a space character before closing tags of empty elements. See
+[#157](https://github.com/oozcitak/xmlbuilder-js/issues/157).
+
+## [9.0.1] - 2017-06-19
+- Fixed character validity checks to work with node.js 4.0 and 5.0. See
+[#161](https://github.com/oozcitak/xmlbuilder-js/issues/161).
+
+## [9.0.0] - 2017-05-05
+- Removed case conversion options.
+- Removed support for node.js 4.0 and 5.0. Minimum required version is now 6.0.
+- Fixed valid char filter to use XML 1.1 instead of 1.0. See
+[#147](https://github.com/oozcitak/xmlbuilder-js/issues/147).
+- Added options for negative indentation and suppressing pretty printing of text
+nodes. See
+[#145](https://github.com/oozcitak/xmlbuilder-js/issues/145).
+
+## [8.2.2] - 2016-04-08
+- Falsy values can now be used as a text node in callback mode.
+
+## [8.2.1] - 2016-04-07
+- Falsy values can now be used as a text node. See
+[#117](https://github.com/oozcitak/xmlbuilder-js/issues/117).
+
+## [8.2.0] - 2016-04-01
+- Removed lodash dependency to keep the library small and simple. See
+[#114](https://github.com/oozcitak/xmlbuilder-js/issues/114),
+[#53](https://github.com/oozcitak/xmlbuilder-js/issues/53),
+and [#43](https://github.com/oozcitak/xmlbuilder-js/issues/43).
+- Added title case to name conversion options.
+
+## [8.1.0] - 2016-03-29
+- Added the callback option to the `begin` export function. When used with a
+callback function, the XML document will be generated in chunks and each chunk
+will be passed to the supplied function. In this mode, `begin` uses a different
+code path and the builder should use much less memory since the entire XML tree
+is not kept. There are a few drawbacks though. For example, traversing the document
+tree or adding attributes to a node after it is written is not possible. It is
+also not possible to remove nodes or attributes.
+
+``` js
+var result = '';
+
+builder.begin(function(chunk) { result += chunk; })
+ .dec()
+ .ele('root')
+ .ele('xmlbuilder').up()
+ .end();
+```
+
+- Replaced native `Object.assign` with `lodash.assign` to support old JS engines. See [#111](https://github.com/oozcitak/xmlbuilder-js/issues/111).
+
+## [8.0.0] - 2016-03-25
+- Added the `begin` export function. See the wiki for details.
+- Added the ability to add comments and processing instructions before and after the root element. Added `commentBefore`, `commentAfter`, `instructionBefore` and `instructionAfter` functions for this purpose.
+- Dropped support for old node.js releases. Minimum required node.js version is now 4.0.
+
+## [7.0.0] - 2016-03-21
+- Processing instructions are now created as regular nodes. This is a major breaking change if you are using processing instructions. Previously processing instructions were inserted before their parent node. After this change processing instructions are appended to the children of the parent node. Note that it is not currently possible to insert processing instructions before or after the root element.
+```js
+root.ele('node').ins('pi');
+// pre-v7
+<?pi?><node/>
+// v7
+<node><?pi?></node>
+```
+
+## [6.0.0] - 2016-03-20
+- Added custom XML writers. The default string conversion functions are now collected under the `XMLStringWriter` class which can be accessed by the `stringWriter(options)` function exported by the module. An `XMLStreamWriter` is also added which outputs the XML document to a writable stream. A stream writer can be created by calling the `streamWriter(stream, options)` function exported by the module. Both classes are heavily customizable and the details are added to the wiki. It is also possible to write an XML writer from scratch and use it when calling `end()` on the XML document.
+
+## [5.0.1] - 2016-03-08
+- Moved require statements for text case conversion to the top of files to reduce lazy requires.
+
+## [5.0.0] - 2016-03-05
+- Added text case option for element names and attribute names. Valid cases are `lower`, `upper`, `camel`, `kebab` and `snake`.
+- Attribute and element values are escaped according to the [Canonical XML 1.0 specification](http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping). See [#54](https://github.com/oozcitak/xmlbuilder-js/issues/54) and [#86](https://github.com/oozcitak/xmlbuilder-js/issues/86).
+- Added the `allowEmpty` option to `end()`. When this option is set, empty elements are not self-closed.
+- Added support for [nested CDATA](https://en.wikipedia.org/wiki/CDATA#Nesting). The triad `]]>` in CDATA is now automatically replaced with `]]]]><![CDATA[>`.
+
+## [4.2.1] - 2016-01-15
+- Updated lodash dependency to 4.0.0.
+
+## [4.2.0] - 2015-12-16
+- Added the `noDoubleEncoding` option to `create()` to control whether existing html entities are encoded.
+
+## [4.1.0] - 2015-11-11
+- Added the `separateArrayItems` option to `create()` to control how arrays are handled when converting from objects. e.g.
+
+```js
+root.ele({ number: [ "one", "two" ]});
+// with separateArrayItems: true
+<number>
+ <one/>
+ <two/>
+</number>
+// with separateArrayItems: false
+<number>one</number>
+<number>two</number>
+```
+
+## [4.0.0] - 2015-11-01
+- Removed the `#list` decorator. Array items are now created as child nodes by default.
+- Fixed a bug where the XML encoding string was checked partially.
+
+## [3.1.0] - 2015-09-19
+- `#list` decorator ignores empty arrays.
+
+## [3.0.0] - 2015-09-10
+- Allow `\r`, `\n` and `\t` in attribute values without escaping. See [#86](https://github.com/oozcitak/xmlbuilder-js/issues/86).
+
+## [2.6.5] - 2015-09-09
+- Use native `isArray` instead of lodash.
+- Indentation of processing instructions are set to the parent element's.
+
+## [2.6.4] - 2015-05-27
+- Updated lodash dependency to 3.5.0.
+
+## [2.6.3] - 2015-05-27
+- Bumped version because previous release was not published on npm.
+
+## [2.6.2] - 2015-03-10
+- Updated lodash dependency to 3.5.0.
+
+## [2.6.1] - 2015-02-20
+- Updated lodash dependency to 3.3.0.
+
+## [2.6.0] - 2015-02-20
+- Fixed a bug where the `XMLNode` constructor overwrote the super class parent.
+- Removed document property from cloned nodes.
+- Switched to mocha.js for testing.
+
+## [2.5.2] - 2015-02-16
+- Updated lodash dependency to 3.2.0.
+
+## [2.5.1] - 2015-02-09
+- Updated lodash dependency to 3.1.0.
+- Support all node >= 0.8.
+
+## [2.5.0] - 2015-00-03
+- Updated lodash dependency to 3.0.0.
+
+## [2.4.6] - 2015-01-26
+- Show more information from attribute creation with null values.
+- Added iojs as an engine.
+- Self close elements with empty text.
+
+## [2.4.5] - 2014-11-15
+- Fixed prepublish script to run on windows.
+- Fixed bug in XMLStringifier where an undefined value was used while reporting an invalid encoding value.
+- Moved require statements to the top of files to reduce lazy requires. See [#62](https://github.com/oozcitak/xmlbuilder-js/issues/62).
+
+## [2.4.4] - 2014-09-08
+- Added the `offset` option to `toString()` for use in XML fragments.
+
+## [2.4.3] - 2014-08-13
+- Corrected license in package description.
+
+## [2.4.2] - 2014-08-13
+- Dropped performance test and memwatch dependency.
+
+## [2.4.1] - 2014-08-12
+- Fixed a bug where empty indent string was omitted when pretty printing. See [#59](https://github.com/oozcitak/xmlbuilder-js/issues/59).
+
+## [2.4.0] - 2014-08-04
+- Correct cases of pubID and sysID.
+- Use single lodash instead of separate npm modules. See [#53](https://github.com/oozcitak/xmlbuilder-js/issues/53).
+- Escape according to Canonical XML 1.0. See [#54](https://github.com/oozcitak/xmlbuilder-js/issues/54).
+
+## [2.3.0] - 2014-07-17
+- Convert objects to JS primitives while sanitizing user input.
+- Object builder preserves items with null values. See [#44](https://github.com/oozcitak/xmlbuilder-js/issues/44).
+- Use modularized lodash functions to cut down dependencies.
+- Process empty objects when converting from objects so that we don't throw on empty child objects.
+
+## [2.2.1] - 2014-04-04
+- Bumped version because previous release was not published on npm.
+
+## [2.2.0] - 2014-04-04
+- Switch to lodash from underscore.
+- Removed legacy `ext` option from `create()`.
+- Drop old node versions: 0.4, 0.5, 0.6. 0.8 is the minimum requirement from now on.
+
+## [2.1.0] - 2013-12-30
+- Removed duplicate null checks from constructors.
+- Fixed node count in performance test.
+- Added option for skipping null attribute values. See [#26](https://github.com/oozcitak/xmlbuilder-js/issues/26).
+- Allow multiple values in `att()` and `ins()`.
+- Added ability to run individual performance tests.
+- Added flag for ignoring decorator strings.
+
+## [2.0.1] - 2013-12-24
+- Removed performance tests from npm package.
+
+## [2.0.0] - 2013-12-24
+- Combined loops for speed up.
+- Added support for the DTD and XML declaration.
+- `clone` includes attributes.
+- Added performance tests.
+- Evaluate attribute value if function.
+- Evaluate instruction value if function.
+
+## [1.1.2] - 2013-12-11
+- Changed processing instruction decorator to `?`.
+
+## [1.1.1] - 2013-12-11
+- Added processing instructions to JS object conversion.
+
+## [1.1.0] - 2013-12-10
+- Added license to package.
+- `create()` and `element()` accept JS object to fully build the document.
+- Added `nod()` and `n()` aliases for `node()`.
+- Renamed `convertAttChar` decorator to `convertAttKey`.
+- Ignore empty decorator strings when converting JS objects.
+
+## [1.0.2] - 2013-11-27
+- Removed temp file which was accidentally included in the package.
+
+## [1.0.1] - 2013-11-27
+- Custom stringify functions affect current instance only.
+
+## [1.0.0] - 2013-11-27
+- Added processing instructions.
+- Added stringify functions to sanitize and convert input values.
+- Added option for headless XML documents.
+- Added vows tests.
+- Removed Makefile. Using npm publish scripts instead.
+- Removed the `begin()` function. `create()` begins the document by creating the root node.
+
+## [0.4.3] - 2013-11-08
+- Added option to include surrogate pairs in XML content. See [#29](https://github.com/oozcitak/xmlbuilder-js/issues/29).
+- Fixed empty value string representation in pretty mode.
+- Added pre and postpublish scripts to package.json.
+- Filtered out prototype properties when appending attributes. See [#31](https://github.com/oozcitak/xmlbuilder-js/issues/31).
+
+## [0.4.2] - 2012-09-14
+- Removed README.md from `.npmignore`.
+
+## [0.4.1] - 2012-08-31
+- Removed `begin()` calls in favor of `XMLBuilder` constructor.
+- Added the `end()` function. `end()` is a convenience over `doc().toString()`.
+
+## [0.4.0] - 2012-08-31
+- Added arguments to `XMLBuilder` constructor to allow the name of the root element and XML prolog to be defined in one line.
+- Soft deprecated `begin()`.
+
+## [0.3.11] - 2012-08-13
+- Package keywords are fixed to be an array of values.
+
+## [0.3.10] - 2012-08-13
+- Brought back npm package contents which were lost due to incorrect configuration of `package.json` in previous releases.
+
+## [0.3.3] - 2012-07-27
+- Implemented `importXMLBuilder()`.
+
+## [0.3.2] - 2012-07-20
+- Fixed a duplicated escaping problem on `element()`.
+- Fixed a problem with text node creation from empty string.
+- Calling `root()` on the document element returns the root element.
+- `XMLBuilder` no longer extends `XMLFragment`.
+
+## [0.3.1] - 2011-11-28
+- Added guards for document element so that nodes cannot be inserted at document level.
+
+## [0.3.0] - 2011-11-28
+- Added `doc()` to return the document element.
+
+## [0.2.2] - 2011-11-28
+- Prevent code relying on `up()`'s older behavior to break.
+
+## [0.2.1] - 2011-11-28
+- Added the `root()` function.
+
+## [0.2.0] - 2011-11-21
+- Added Travis-CI integration.
+- Added coffee-script dependency.
+- Added insert, traversal and delete functions.
+
+## [0.1.7] - 2011-10-25
+- No changes. Accidental release.
+
+## [0.1.6] - 2011-10-25
+- Corrected `package.json` bugs link to `url` from `web`.
+
+## [0.1.5] - 2011-08-08
+- Added missing npm package contents.
+
+## [0.1.4] - 2011-07-29
+- Text-only nodes are no longer indented.
+- Added documentation for multiple instances.
+
+## [0.1.3] - 2011-07-27
+- Exported the `create()` function to return a new instance. This allows multiple builder instances to be constructed.
+- Fixed `u()` function so that it now correctly calls `up()`.
+- Fixed typo in `element()` so that `attributes` and `text` can be passed interchangeably.
+
+## [0.1.2] - 2011-06-03
+- `ele()` accepts element text.
+- `attributes()` now overrides existing attributes if passed the same attribute name.
+
+## [0.1.1] - 2011-05-19
+- Added the raw output option.
+- Removed most validity checks.
+
+## [0.1.0] - 2011-04-27
+- `text()` and `cdata()` now return parent element.
+- Attribute values are escaped.
+
+## [0.0.7] - 2011-04-23
+- Coerced text values to string.
+
+## [0.0.6] - 2011-02-23
+- Added support for XML comments.
+- Text nodes are checked against CharData.
+
+## [0.0.5] - 2010-12-31
+- Corrected the name of the main npm module in `package.json`.
+
+## [0.0.4] - 2010-12-28
+- Added `.npmignore`.
+
+## [0.0.3] - 2010-12-27
+- root element is now constructed in `begin()`.
+- moved prolog to `begin()`.
+- Added the ability to have CDATA in element text.
+- Removed unused prolog aliases.
+- Removed `builder()` function from main module.
+- Added the name of the main npm module in `package.json`.
+
+## [0.0.2] - 2010-11-03
+- `element()` expands nested arrays.
+- Added pretty printing.
+- Added the `up()`, `build()` and `prolog()` functions.
+- Added readme.
+
+## 0.0.1 - 2010-11-02
+- Initial release
+
+[9.0.4]: https://github.com/oozcitak/xmlbuilder-js/compare/v9.0.3...v9.0.4
+[9.0.3]: https://github.com/oozcitak/xmlbuilder-js/compare/v9.0.2...v9.0.3
+[9.0.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v9.0.1...v9.0.2
+[9.0.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v9.0.0...v9.0.1
+[9.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v8.2.2...v9.0.0
+[8.2.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v8.2.1...v8.2.2
+[8.2.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v8.2.0...v8.2.1
+[8.2.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v8.1.0...v8.2.0
+[8.1.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v8.0.0...v8.1.0
+[8.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v7.0.0...v8.0.0
+[7.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v6.0.0...v7.0.0
+[6.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v5.0.1...v6.0.0
+[5.0.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v5.0.0...v5.0.1
+[5.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v4.2.1...v5.0.0
+[4.2.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v4.2.0...v4.2.1
+[4.2.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v4.1.0...v4.2.0
+[4.1.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v4.0.0...v4.1.0
+[4.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v3.1.0...v4.0.0
+[3.1.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v3.0.0...v3.1.0
+[3.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.6.5...v3.0.0
+[2.6.5]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.6.4...v2.6.5
+[2.6.4]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.6.3...v2.6.4
+[2.6.3]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.6.2...v2.6.3
+[2.6.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.6.1...v2.6.2
+[2.6.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.6.0...v2.6.1
+[2.6.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.5.2...v2.6.0
+[2.5.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.5.1...v2.5.2
+[2.5.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.5.0...v2.5.1
+[2.5.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.4.6...v2.5.0
+[2.4.6]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.4.5...v2.4.6
+[2.4.5]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.4.4...v2.4.5
+[2.4.4]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.4.3...v2.4.4
+[2.4.3]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.4.2...v2.4.3
+[2.4.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.4.1...v2.4.2
+[2.4.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.4.0...v2.4.1
+[2.4.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.3.0...v2.4.0
+[2.3.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.2.1...v2.3.0
+[2.2.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.2.0...v2.2.1
+[2.2.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.1.0...v2.2.0
+[2.1.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.0.1...v2.1.0
+[2.0.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v2.0.0...v2.0.1
+[2.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v1.1.2...v2.0.0
+[1.1.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v1.1.1...v1.1.2
+[1.1.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v1.1.0...v1.1.1
+[1.1.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v1.0.2...v1.1.0
+[1.0.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v1.0.1...v1.0.2
+[1.0.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v1.0.0...v1.0.1
+[1.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.4.3...v1.0.0
+[0.4.3]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.4.2...v0.4.3
+[0.4.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.4.1...v0.4.2
+[0.4.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.4.0...v0.4.1
+[0.4.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.3.11...v0.4.0
+[0.3.11]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.3.10...v0.3.11
+[0.3.10]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.3.3...v0.3.10
+[0.3.3]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.3.2...v0.3.3
+[0.3.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.3.1...v0.3.2
+[0.3.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.3.0...v0.3.1
+[0.3.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.2.2...v0.3.0
+[0.2.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.2.1...v0.2.2
+[0.2.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.2.0...v0.2.1
+[0.2.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.1.7...v0.2.0
+[0.1.7]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.1.6...v0.1.7
+[0.1.6]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.1.5...v0.1.6
+[0.1.5]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.1.4...v0.1.5
+[0.1.4]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.1.3...v0.1.4
+[0.1.3]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.1.2...v0.1.3
+[0.1.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.1.1...v0.1.2
+[0.1.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.1.0...v0.1.1
+[0.1.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.0.7...v0.1.0
+[0.0.7]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.0.6...v0.0.7
+[0.0.6]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.0.5...v0.0.6
+[0.0.5]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.0.4...v0.0.5
+[0.0.4]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.0.3...v0.0.4
+[0.0.3]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.0.2...v0.0.3
+[0.0.2]: https://github.com/oozcitak/xmlbuilder-js/compare/v0.0.1...v0.0.2
+
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/LICENSE b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/LICENSE
new file mode 100644
index 0000000..e7cbac9
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2013 Ozgur Ozcitak
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/README.md b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/README.md
new file mode 100644
index 0000000..785c4dd
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/README.md
@@ -0,0 +1,85 @@
+# xmlbuilder-js
+
+An XML builder for [node.js](https://nodejs.org/) similar to
+[java-xmlbuilder](https://github.com/jmurty/java-xmlbuilder).
+
+[![License](http://img.shields.io/npm/l/xmlbuilder.svg?style=flat-square)](http://opensource.org/licenses/MIT)
+[![NPM Version](http://img.shields.io/npm/v/xmlbuilder.svg?style=flat-square)](https://npmjs.com/package/xmlbuilder)
+[![NPM Downloads](https://img.shields.io/npm/dm/xmlbuilder.svg?style=flat-square)](https://npmjs.com/package/xmlbuilder)
+
+[![Build Status](http://img.shields.io/travis/oozcitak/xmlbuilder-js.svg?style=flat-square)](http://travis-ci.org/oozcitak/xmlbuilder-js)
+[![Dev Dependency Status](http://img.shields.io/david/dev/oozcitak/xmlbuilder-js.svg?style=flat-square)](https://david-dm.org/oozcitak/xmlbuilder-js)
+[![Code Coverage](https://img.shields.io/coveralls/oozcitak/xmlbuilder-js.svg?style=flat-square)](https://coveralls.io/github/oozcitak/xmlbuilder-js)
+
+### Installation:
+
+``` sh
+npm install xmlbuilder
+```
+
+### Usage:
+
+``` js
+var builder = require('xmlbuilder');
+var xml = builder.create('root')
+ .ele('xmlbuilder')
+ .ele('repo', {'type': 'git'}, 'git://github.com/oozcitak/xmlbuilder-js.git')
+ .end({ pretty: true});
+
+console.log(xml);
+```
+
+will result in:
+
+``` xml
+<?xml version="1.0"?>
+<root>
+ <xmlbuilder>
+ <repo type="git">git://github.com/oozcitak/xmlbuilder-js.git</repo>
+ </xmlbuilder>
+</root>
+```
+
+It is also possible to convert objects into nodes:
+
+``` js
+builder.create({
+ root: {
+ xmlbuilder: {
+ repo: {
+ '@type': 'git', // attributes start with @
+ '#text': 'git://github.com/oozcitak/xmlbuilder-js.git' // text node
+ }
+ }
+ }
+});
+```
+
+If you need to do some processing:
+
+``` js
+var root = builder.create('squares');
+root.com('f(x) = x^2');
+for(var i = 1; i <= 5; i++)
+{
+ var item = root.ele('data');
+ item.att('x', i);
+ item.att('y', i * i);
+}
+```
+
+This will result in:
+
+``` xml
+<?xml version="1.0"?>
+<squares>
+ <!-- f(x) = x^2 -->
+ <data x="1" y="1"/>
+ <data x="2" y="4"/>
+ <data x="3" y="9"/>
+ <data x="4" y="16"/>
+ <data x="5" y="25"/>
+</squares>
+```
+
+See the [wiki](https://github.com/oozcitak/xmlbuilder-js/wiki) for details and [examples](https://github.com/oozcitak/xmlbuilder-js/wiki/Examples) for more complex examples.
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/Utility.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/Utility.js
new file mode 100644
index 0000000..908f8a8
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/Utility.js
@@ -0,0 +1,73 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var assign, isArray, isEmpty, isFunction, isObject, isPlainObject,
+ slice = [].slice,
+ hasProp = {}.hasOwnProperty;
+
+ assign = function() {
+ var i, key, len, source, sources, target;
+ target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
+ if (isFunction(Object.assign)) {
+ Object.assign.apply(null, arguments);
+ } else {
+ for (i = 0, len = sources.length; i < len; i++) {
+ source = sources[i];
+ if (source != null) {
+ for (key in source) {
+ if (!hasProp.call(source, key)) continue;
+ target[key] = source[key];
+ }
+ }
+ }
+ }
+ return target;
+ };
+
+ isFunction = function(val) {
+ return !!val && Object.prototype.toString.call(val) === '[object Function]';
+ };
+
+ isObject = function(val) {
+ var ref;
+ return !!val && ((ref = typeof val) === 'function' || ref === 'object');
+ };
+
+ isArray = function(val) {
+ if (isFunction(Array.isArray)) {
+ return Array.isArray(val);
+ } else {
+ return Object.prototype.toString.call(val) === '[object Array]';
+ }
+ };
+
+ isEmpty = function(val) {
+ var key;
+ if (isArray(val)) {
+ return !val.length;
+ } else {
+ for (key in val) {
+ if (!hasProp.call(val, key)) continue;
+ return false;
+ }
+ return true;
+ }
+ };
+
+ isPlainObject = function(val) {
+ var ctor, proto;
+ return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object));
+ };
+
+ module.exports.assign = assign;
+
+ module.exports.isFunction = isFunction;
+
+ module.exports.isObject = isObject;
+
+ module.exports.isArray = isArray;
+
+ module.exports.isEmpty = isEmpty;
+
+ module.exports.isPlainObject = isPlainObject;
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLAttribute.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLAttribute.js
new file mode 100644
index 0000000..67cc0bc
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLAttribute.js
@@ -0,0 +1,31 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLAttribute;
+
+ module.exports = XMLAttribute = (function() {
+ function XMLAttribute(parent, name, value) {
+ this.options = parent.options;
+ 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 Object.create(this);
+ };
+
+ XMLAttribute.prototype.toString = function(options) {
+ return this.options.writer.set(options).attribute(this);
+ };
+
+ return XMLAttribute;
+
+ })();
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLCData.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLCData.js
new file mode 100644
index 0000000..670e860
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLCData.js
@@ -0,0 +1,32 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLCData, XMLNode,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ 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 Object.create(this);
+ };
+
+ XMLCData.prototype.toString = function(options) {
+ return this.options.writer.set(options).cdata(this);
+ };
+
+ return XMLCData;
+
+ })(XMLNode);
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLComment.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLComment.js
new file mode 100644
index 0000000..c189714
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLComment.js
@@ -0,0 +1,32 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLComment, XMLNode,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ 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 Object.create(this);
+ };
+
+ XMLComment.prototype.toString = function(options) {
+ return this.options.writer.set(options).comment(this);
+ };
+
+ return XMLComment;
+
+ })(XMLNode);
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDTDAttList.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDTDAttList.js
new file mode 100644
index 0000000..8f911c2
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDTDAttList.js
@@ -0,0 +1,50 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDTDAttList, XMLNode,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLDTDAttList = (function(superClass) {
+ extend(XMLDTDAttList, superClass);
+
+ function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
+ XMLDTDAttList.__super__.constructor.call(this, parent);
+ 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) {
+ return this.options.writer.set(options).dtdAttList(this);
+ };
+
+ return XMLDTDAttList;
+
+ })(XMLNode);
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDTDElement.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDTDElement.js
new file mode 100644
index 0000000..43f5d05
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDTDElement.js
@@ -0,0 +1,35 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDTDElement, XMLNode,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLDTDElement = (function(superClass) {
+ extend(XMLDTDElement, superClass);
+
+ function XMLDTDElement(parent, name, value) {
+ XMLDTDElement.__super__.constructor.call(this, parent);
+ 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) {
+ return this.options.writer.set(options).dtdElement(this);
+ };
+
+ return XMLDTDElement;
+
+ })(XMLNode);
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDTDEntity.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDTDEntity.js
new file mode 100644
index 0000000..943f312
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDTDEntity.js
@@ -0,0 +1,56 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDTDEntity, XMLNode, 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;
+
+ isObject = require('./Utility').isObject;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLDTDEntity = (function(superClass) {
+ extend(XMLDTDEntity, superClass);
+
+ function XMLDTDEntity(parent, pe, name, value) {
+ XMLDTDEntity.__super__.constructor.call(this, parent);
+ 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) {
+ return this.options.writer.set(options).dtdEntity(this);
+ };
+
+ return XMLDTDEntity;
+
+ })(XMLNode);
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDTDNotation.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDTDNotation.js
new file mode 100644
index 0000000..2c0c698
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDTDNotation.js
@@ -0,0 +1,37 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDTDNotation, XMLNode,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLDTDNotation = (function(superClass) {
+ extend(XMLDTDNotation, superClass);
+
+ function XMLDTDNotation(parent, name, value) {
+ XMLDTDNotation.__super__.constructor.call(this, parent);
+ 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) {
+ return this.options.writer.set(options).dtdNotation(this);
+ };
+
+ return XMLDTDNotation;
+
+ })(XMLNode);
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDeclaration.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDeclaration.js
new file mode 100644
index 0000000..3251f28
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDeclaration.js
@@ -0,0 +1,40 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDeclaration, XMLNode, 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;
+
+ isObject = require('./Utility').isObject;
+
+ XMLNode = require('./XMLNode');
+
+ 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) {
+ return this.options.writer.set(options).declaration(this);
+ };
+
+ return XMLDeclaration;
+
+ })(XMLNode);
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDocType.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDocType.js
new file mode 100644
index 0000000..1bb0429
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDocType.js
@@ -0,0 +1,107 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNode, 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;
+
+ isObject = require('./Utility').isObject;
+
+ XMLNode = require('./XMLNode');
+
+ XMLDTDAttList = require('./XMLDTDAttList');
+
+ XMLDTDEntity = require('./XMLDTDEntity');
+
+ XMLDTDElement = require('./XMLDTDElement');
+
+ XMLDTDNotation = require('./XMLDTDNotation');
+
+ module.exports = XMLDocType = (function(superClass) {
+ extend(XMLDocType, superClass);
+
+ function XMLDocType(parent, pubID, sysID) {
+ var ref, ref1;
+ XMLDocType.__super__.constructor.call(this, parent);
+ this.documentObject = parent;
+ 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.toString = function(options) {
+ return this.options.writer.set(options).docType(this);
+ };
+
+ 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.up = function() {
+ return this.root() || this.documentObject;
+ };
+
+ return XMLDocType;
+
+ })(XMLNode);
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDocument.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDocument.js
new file mode 100644
index 0000000..38743ee
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDocument.js
@@ -0,0 +1,48 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject,
+ 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;
+
+ isPlainObject = require('./Utility').isPlainObject;
+
+ XMLNode = require('./XMLNode');
+
+ XMLStringifier = require('./XMLStringifier');
+
+ XMLStringWriter = require('./XMLStringWriter');
+
+ module.exports = XMLDocument = (function(superClass) {
+ extend(XMLDocument, superClass);
+
+ function XMLDocument(options) {
+ XMLDocument.__super__.constructor.call(this, null);
+ options || (options = {});
+ if (!options.writer) {
+ options.writer = new XMLStringWriter();
+ }
+ this.options = options;
+ this.stringify = new XMLStringifier(options);
+ this.isDocument = true;
+ }
+
+ XMLDocument.prototype.end = function(writer) {
+ var writerOptions;
+ if (!writer) {
+ writer = this.options.writer;
+ } else if (isPlainObject(writer)) {
+ writerOptions = writer;
+ writer = this.options.writer.set(writerOptions);
+ }
+ return writer.document(this);
+ };
+
+ XMLDocument.prototype.toString = function(options) {
+ return this.options.writer.set(options).document(this);
+ };
+
+ return XMLDocument;
+
+ })(XMLNode);
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDocumentCB.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDocumentCB.js
new file mode 100644
index 0000000..00da8dc
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLDocumentCB.js
@@ -0,0 +1,402 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, isFunction, isObject, isPlainObject, ref,
+ hasProp = {}.hasOwnProperty;
+
+ ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject;
+
+ XMLElement = require('./XMLElement');
+
+ XMLCData = require('./XMLCData');
+
+ XMLComment = require('./XMLComment');
+
+ XMLRaw = require('./XMLRaw');
+
+ XMLText = require('./XMLText');
+
+ XMLProcessingInstruction = require('./XMLProcessingInstruction');
+
+ XMLDeclaration = require('./XMLDeclaration');
+
+ XMLDocType = require('./XMLDocType');
+
+ XMLDTDAttList = require('./XMLDTDAttList');
+
+ XMLDTDEntity = require('./XMLDTDEntity');
+
+ XMLDTDElement = require('./XMLDTDElement');
+
+ XMLDTDNotation = require('./XMLDTDNotation');
+
+ XMLAttribute = require('./XMLAttribute');
+
+ XMLStringifier = require('./XMLStringifier');
+
+ XMLStringWriter = require('./XMLStringWriter');
+
+ module.exports = XMLDocumentCB = (function() {
+ function XMLDocumentCB(options, onData, onEnd) {
+ var writerOptions;
+ options || (options = {});
+ if (!options.writer) {
+ options.writer = new XMLStringWriter(options);
+ } else if (isPlainObject(options.writer)) {
+ writerOptions = options.writer;
+ options.writer = new XMLStringWriter(writerOptions);
+ }
+ this.options = options;
+ this.writer = options.writer;
+ this.stringify = new XMLStringifier(options);
+ this.onDataCallback = onData || function() {};
+ this.onEndCallback = onEnd || function() {};
+ this.currentNode = null;
+ this.currentLevel = -1;
+ this.openTags = {};
+ this.documentStarted = false;
+ this.documentCompleted = false;
+ this.root = null;
+ }
+
+ XMLDocumentCB.prototype.node = function(name, attributes, text) {
+ var ref1;
+ if (name == null) {
+ throw new Error("Missing node name");
+ }
+ if (this.root && this.currentLevel === -1) {
+ throw new Error("Document can only have one root node");
+ }
+ this.openCurrent();
+ name = name.valueOf();
+ if (attributes == null) {
+ attributes = {};
+ }
+ attributes = attributes.valueOf();
+ if (!isObject(attributes)) {
+ ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
+ }
+ this.currentNode = new XMLElement(this, name, attributes);
+ this.currentNode.children = false;
+ this.currentLevel++;
+ this.openTags[this.currentLevel] = this.currentNode;
+ if (text != null) {
+ this.text(text);
+ }
+ return this;
+ };
+
+ XMLDocumentCB.prototype.element = function(name, attributes, text) {
+ if (this.currentNode && this.currentNode instanceof XMLDocType) {
+ return this.dtdElement.apply(this, arguments);
+ } else {
+ return this.node(name, attributes, text);
+ }
+ };
+
+ XMLDocumentCB.prototype.attribute = function(name, value) {
+ var attName, attValue;
+ if (!this.currentNode || this.currentNode.children) {
+ throw new Error("att() can only be used immediately after an ele() call in callback mode");
+ }
+ 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.currentNode.attributes[name] = new XMLAttribute(this, name, value);
+ }
+ }
+ return this;
+ };
+
+ XMLDocumentCB.prototype.text = function(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLText(this, value);
+ this.onData(this.writer.text(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.cdata = function(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLCData(this, value);
+ this.onData(this.writer.cdata(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.comment = function(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLComment(this, value);
+ this.onData(this.writer.comment(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.raw = function(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLRaw(this, value);
+ this.onData(this.writer.raw(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.instruction = function(target, value) {
+ var i, insTarget, insValue, len, node;
+ this.openCurrent();
+ 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();
+ }
+ node = new XMLProcessingInstruction(this, target, value);
+ this.onData(this.writer.processingInstruction(node, this.currentLevel + 1));
+ }
+ return this;
+ };
+
+ XMLDocumentCB.prototype.declaration = function(version, encoding, standalone) {
+ var node;
+ this.openCurrent();
+ if (this.documentStarted) {
+ throw new Error("declaration() must be the first node");
+ }
+ node = new XMLDeclaration(this, version, encoding, standalone);
+ this.onData(this.writer.declaration(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.doctype = function(root, pubID, sysID) {
+ this.openCurrent();
+ if (root == null) {
+ throw new Error("Missing root node name");
+ }
+ if (this.root) {
+ throw new Error("dtd() must come before the root node");
+ }
+ this.currentNode = new XMLDocType(this, pubID, sysID);
+ this.currentNode.rootNodeName = root;
+ this.currentNode.children = false;
+ this.currentLevel++;
+ this.openTags[this.currentLevel] = this.currentNode;
+ return this;
+ };
+
+ XMLDocumentCB.prototype.dtdElement = function(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDElement(this, name, value);
+ this.onData(this.writer.dtdElement(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
+ this.onData(this.writer.dtdAttList(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.entity = function(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDEntity(this, false, name, value);
+ this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.pEntity = function(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDEntity(this, true, name, value);
+ this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.notation = function(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDNotation(this, name, value);
+ this.onData(this.writer.dtdNotation(node, this.currentLevel + 1));
+ return this;
+ };
+
+ XMLDocumentCB.prototype.up = function() {
+ if (this.currentLevel < 0) {
+ throw new Error("The document node has no parent");
+ }
+ if (this.currentNode) {
+ if (this.currentNode.children) {
+ this.closeNode(this.currentNode);
+ } else {
+ this.openNode(this.currentNode);
+ }
+ this.currentNode = null;
+ } else {
+ this.closeNode(this.openTags[this.currentLevel]);
+ }
+ delete this.openTags[this.currentLevel];
+ this.currentLevel--;
+ return this;
+ };
+
+ XMLDocumentCB.prototype.end = function() {
+ while (this.currentLevel >= 0) {
+ this.up();
+ }
+ return this.onEnd();
+ };
+
+ XMLDocumentCB.prototype.openCurrent = function() {
+ if (this.currentNode) {
+ this.currentNode.children = true;
+ return this.openNode(this.currentNode);
+ }
+ };
+
+ XMLDocumentCB.prototype.openNode = function(node) {
+ if (!node.isOpen) {
+ if (!this.root && this.currentLevel === 0 && node instanceof XMLElement) {
+ this.root = node;
+ }
+ this.onData(this.writer.openNode(node, this.currentLevel));
+ return node.isOpen = true;
+ }
+ };
+
+ XMLDocumentCB.prototype.closeNode = function(node) {
+ if (!node.isClosed) {
+ this.onData(this.writer.closeNode(node, this.currentLevel));
+ return node.isClosed = true;
+ }
+ };
+
+ XMLDocumentCB.prototype.onData = function(chunk) {
+ this.documentStarted = true;
+ return this.onDataCallback(chunk);
+ };
+
+ XMLDocumentCB.prototype.onEnd = function() {
+ this.documentCompleted = true;
+ return this.onEndCallback();
+ };
+
+ XMLDocumentCB.prototype.ele = function() {
+ return this.element.apply(this, arguments);
+ };
+
+ XMLDocumentCB.prototype.nod = function(name, attributes, text) {
+ return this.node(name, attributes, text);
+ };
+
+ XMLDocumentCB.prototype.txt = function(value) {
+ return this.text(value);
+ };
+
+ XMLDocumentCB.prototype.dat = function(value) {
+ return this.cdata(value);
+ };
+
+ XMLDocumentCB.prototype.com = function(value) {
+ return this.comment(value);
+ };
+
+ XMLDocumentCB.prototype.ins = function(target, value) {
+ return this.instruction(target, value);
+ };
+
+ XMLDocumentCB.prototype.dec = function(version, encoding, standalone) {
+ return this.declaration(version, encoding, standalone);
+ };
+
+ XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) {
+ return this.doctype(root, pubID, sysID);
+ };
+
+ XMLDocumentCB.prototype.e = function(name, attributes, text) {
+ return this.element(name, attributes, text);
+ };
+
+ XMLDocumentCB.prototype.n = function(name, attributes, text) {
+ return this.node(name, attributes, text);
+ };
+
+ XMLDocumentCB.prototype.t = function(value) {
+ return this.text(value);
+ };
+
+ XMLDocumentCB.prototype.d = function(value) {
+ return this.cdata(value);
+ };
+
+ XMLDocumentCB.prototype.c = function(value) {
+ return this.comment(value);
+ };
+
+ XMLDocumentCB.prototype.r = function(value) {
+ return this.raw(value);
+ };
+
+ XMLDocumentCB.prototype.i = function(target, value) {
+ return this.instruction(target, value);
+ };
+
+ XMLDocumentCB.prototype.att = function() {
+ if (this.currentNode && this.currentNode instanceof XMLDocType) {
+ return this.attList.apply(this, arguments);
+ } else {
+ return this.attribute.apply(this, arguments);
+ }
+ };
+
+ XMLDocumentCB.prototype.a = function() {
+ if (this.currentNode && this.currentNode instanceof XMLDocType) {
+ return this.attList.apply(this, arguments);
+ } else {
+ return this.attribute.apply(this, arguments);
+ }
+ };
+
+ XMLDocumentCB.prototype.ent = function(name, value) {
+ return this.entity(name, value);
+ };
+
+ XMLDocumentCB.prototype.pent = function(name, value) {
+ return this.pEntity(name, value);
+ };
+
+ XMLDocumentCB.prototype.not = function(name, value) {
+ return this.notation(name, value);
+ };
+
+ return XMLDocumentCB;
+
+ })();
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLElement.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLElement.js
new file mode 100644
index 0000000..bd1f46c
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLElement.js
@@ -0,0 +1,111 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLAttribute, XMLElement, XMLNode, isFunction, isObject, ref,
+ 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;
+
+ ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction;
+
+ XMLNode = require('./XMLNode');
+
+ XMLAttribute = require('./XMLAttribute');
+
+ 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.attributes = {};
+ if (attributes != null) {
+ this.attribute(attributes);
+ }
+ if (parent.isDocument) {
+ this.isRoot = true;
+ this.documentObject = parent;
+ parent.rootObject = this;
+ }
+ }
+
+ XMLElement.prototype.clone = function() {
+ var att, attName, clonedSelf, ref1;
+ clonedSelf = Object.create(this);
+ if (clonedSelf.isRoot) {
+ clonedSelf.documentObject = null;
+ }
+ clonedSelf.attributes = {};
+ ref1 = this.attributes;
+ for (attName in ref1) {
+ if (!hasProp.call(ref1, attName)) continue;
+ att = ref1[attName];
+ clonedSelf.attributes[attName] = att.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.toString = function(options) {
+ return this.options.writer.set(options).element(this);
+ };
+
+ XMLElement.prototype.att = function(name, value) {
+ return this.attribute(name, value);
+ };
+
+ XMLElement.prototype.a = function(name, value) {
+ return this.attribute(name, value);
+ };
+
+ return XMLElement;
+
+ })(XMLNode);
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLNode.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLNode.js
new file mode 100644
index 0000000..00ab37d
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLNode.js
@@ -0,0 +1,432 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLElement, XMLNode, XMLProcessingInstruction, XMLRaw, XMLText, isEmpty, isFunction, isObject, ref,
+ hasProp = {}.hasOwnProperty;
+
+ ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isEmpty = ref.isEmpty;
+
+ XMLElement = null;
+
+ XMLCData = null;
+
+ XMLComment = null;
+
+ XMLDeclaration = null;
+
+ XMLDocType = null;
+
+ XMLRaw = null;
+
+ XMLText = null;
+
+ XMLProcessingInstruction = null;
+
+ module.exports = XMLNode = (function() {
+ function XMLNode(parent) {
+ this.parent = parent;
+ if (this.parent) {
+ this.options = this.parent.options;
+ this.stringify = this.parent.stringify;
+ }
+ this.children = [];
+ if (!XMLElement) {
+ XMLElement = require('./XMLElement');
+ XMLCData = require('./XMLCData');
+ XMLComment = require('./XMLComment');
+ XMLDeclaration = require('./XMLDeclaration');
+ XMLDocType = require('./XMLDocType');
+ XMLRaw = require('./XMLRaw');
+ XMLText = require('./XMLText');
+ XMLProcessingInstruction = require('./XMLProcessingInstruction');
+ }
+ }
+
+ XMLNode.prototype.element = function(name, attributes, text) {
+ var childNode, item, j, k, key, lastChild, len, len1, ref1, val;
+ lastChild = null;
+ if (attributes == null) {
+ attributes = {};
+ }
+ attributes = attributes.valueOf();
+ if (!isObject(attributes)) {
+ ref1 = [attributes, text], text = ref1[0], attributes = ref1[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.separateArrayItems && 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 if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
+ lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), 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, ref1;
+ 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(ref1 = [])), ref1;
+ return this.parent;
+ };
+
+ XMLNode.prototype.node = function(name, attributes, text) {
+ var child, ref1;
+ if (name != null) {
+ name = name.valueOf();
+ }
+ attributes || (attributes = {});
+ attributes = attributes.valueOf();
+ if (!isObject(attributes)) {
+ ref1 = [attributes, text], text = ref1[0], attributes = ref1[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.commentBefore = function(value) {
+ var child, i, removed;
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i);
+ child = this.parent.comment(value);
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ };
+
+ XMLNode.prototype.commentAfter = function(value) {
+ var child, i, removed;
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i + 1);
+ child = this.parent.comment(value);
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ };
+
+ XMLNode.prototype.raw = function(value) {
+ var child;
+ child = new XMLRaw(this, value);
+ this.children.push(child);
+ return this;
+ };
+
+ XMLNode.prototype.instruction = function(target, value) {
+ var insTarget, insValue, instruction, j, len;
+ if (target != null) {
+ target = target.valueOf();
+ }
+ if (value != null) {
+ value = value.valueOf();
+ }
+ if (Array.isArray(target)) {
+ for (j = 0, len = target.length; j < len; j++) {
+ insTarget = target[j];
+ 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.children.push(instruction);
+ }
+ return this;
+ };
+
+ XMLNode.prototype.instructionBefore = function(target, value) {
+ var child, i, removed;
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i);
+ child = this.parent.instruction(target, value);
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ };
+
+ XMLNode.prototype.instructionAfter = function(target, value) {
+ var child, i, removed;
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i + 1);
+ child = this.parent.instruction(target, value);
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ };
+
+ XMLNode.prototype.declaration = function(version, encoding, standalone) {
+ var doc, xmldec;
+ doc = this.document();
+ xmldec = new XMLDeclaration(doc, version, encoding, standalone);
+ if (doc.children[0] instanceof XMLDeclaration) {
+ doc.children[0] = xmldec;
+ } else {
+ doc.children.unshift(xmldec);
+ }
+ return doc.root() || doc;
+ };
+
+ XMLNode.prototype.doctype = function(pubID, sysID) {
+ var child, doc, doctype, i, j, k, len, len1, ref1, ref2;
+ doc = this.document();
+ doctype = new XMLDocType(doc, pubID, sysID);
+ ref1 = doc.children;
+ for (i = j = 0, len = ref1.length; j < len; i = ++j) {
+ child = ref1[i];
+ if (child instanceof XMLDocType) {
+ doc.children[i] = doctype;
+ return doctype;
+ }
+ }
+ ref2 = doc.children;
+ for (i = k = 0, len1 = ref2.length; k < len1; i = ++k) {
+ child = ref2[i];
+ if (child.isRoot) {
+ doc.children.splice(i, 0, doctype);
+ return doctype;
+ }
+ }
+ doc.children.push(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 node;
+ node = this;
+ while (node) {
+ if (node.isDocument) {
+ return node.rootObject;
+ } else if (node.isRoot) {
+ return node;
+ } else {
+ node = node.parent;
+ }
+ }
+ };
+
+ XMLNode.prototype.document = function() {
+ var node;
+ node = this;
+ while (node) {
+ if (node.isDocument) {
+ return node;
+ } else {
+ node = node.parent;
+ }
+ }
+ };
+
+ XMLNode.prototype.end = function(options) {
+ return this.document().end(options);
+ };
+
+ XMLNode.prototype.prev = function() {
+ var i;
+ 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;
+ 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.importDocument = function(doc) {
+ var clonedRoot;
+ clonedRoot = doc.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.ins = function(target, value) {
+ return this.instruction(target, 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.i = function(target, value) {
+ return this.instruction(target, value);
+ };
+
+ XMLNode.prototype.u = function() {
+ return this.up();
+ };
+
+ XMLNode.prototype.importXMLBuilder = function(doc) {
+ return this.importDocument(doc);
+ };
+
+ return XMLNode;
+
+ })();
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js
new file mode 100644
index 0000000..e6f71d1
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js
@@ -0,0 +1,35 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLNode, XMLProcessingInstruction,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLProcessingInstruction = (function(superClass) {
+ extend(XMLProcessingInstruction, superClass);
+
+ function XMLProcessingInstruction(parent, target, value) {
+ XMLProcessingInstruction.__super__.constructor.call(this, parent);
+ 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 Object.create(this);
+ };
+
+ XMLProcessingInstruction.prototype.toString = function(options) {
+ return this.options.writer.set(options).processingInstruction(this);
+ };
+
+ return XMLProcessingInstruction;
+
+ })(XMLNode);
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLRaw.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLRaw.js
new file mode 100644
index 0000000..dbe7fdc
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLRaw.js
@@ -0,0 +1,32 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLNode, XMLRaw,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ 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 Object.create(this);
+ };
+
+ XMLRaw.prototype.toString = function(options) {
+ return this.options.writer.set(options).raw(this);
+ };
+
+ return XMLRaw;
+
+ })(XMLNode);
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLStreamWriter.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLStreamWriter.js
new file mode 100644
index 0000000..20d98ee
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLStreamWriter.js
@@ -0,0 +1,279 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStreamWriter, XMLText, XMLWriterBase,
+ 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;
+
+ XMLDeclaration = require('./XMLDeclaration');
+
+ XMLDocType = require('./XMLDocType');
+
+ XMLCData = require('./XMLCData');
+
+ XMLComment = require('./XMLComment');
+
+ XMLElement = require('./XMLElement');
+
+ XMLRaw = require('./XMLRaw');
+
+ XMLText = require('./XMLText');
+
+ XMLProcessingInstruction = require('./XMLProcessingInstruction');
+
+ XMLDTDAttList = require('./XMLDTDAttList');
+
+ XMLDTDElement = require('./XMLDTDElement');
+
+ XMLDTDEntity = require('./XMLDTDEntity');
+
+ XMLDTDNotation = require('./XMLDTDNotation');
+
+ XMLWriterBase = require('./XMLWriterBase');
+
+ module.exports = XMLStreamWriter = (function(superClass) {
+ extend(XMLStreamWriter, superClass);
+
+ function XMLStreamWriter(stream, options) {
+ XMLStreamWriter.__super__.constructor.call(this, options);
+ this.stream = stream;
+ }
+
+ XMLStreamWriter.prototype.document = function(doc) {
+ var child, i, j, len, len1, ref, ref1, results;
+ ref = doc.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ child.isLastRootNode = false;
+ }
+ doc.children[doc.children.length - 1].isLastRootNode = true;
+ ref1 = doc.children;
+ results = [];
+ for (j = 0, len1 = ref1.length; j < len1; j++) {
+ child = ref1[j];
+ switch (false) {
+ case !(child instanceof XMLDeclaration):
+ results.push(this.declaration(child));
+ break;
+ case !(child instanceof XMLDocType):
+ results.push(this.docType(child));
+ break;
+ case !(child instanceof XMLComment):
+ results.push(this.comment(child));
+ break;
+ case !(child instanceof XMLProcessingInstruction):
+ results.push(this.processingInstruction(child));
+ break;
+ default:
+ results.push(this.element(child));
+ }
+ }
+ return results;
+ };
+
+ XMLStreamWriter.prototype.attribute = function(att) {
+ return this.stream.write(' ' + att.name + '="' + att.value + '"');
+ };
+
+ XMLStreamWriter.prototype.cdata = function(node, level) {
+ return this.stream.write(this.space(level) + '<![CDATA[' + node.text + ']]>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.comment = function(node, level) {
+ return this.stream.write(this.space(level) + '<!-- ' + node.text + ' -->' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.declaration = function(node, level) {
+ this.stream.write(this.space(level));
+ this.stream.write('<?xml version="' + node.version + '"');
+ if (node.encoding != null) {
+ this.stream.write(' encoding="' + node.encoding + '"');
+ }
+ if (node.standalone != null) {
+ this.stream.write(' standalone="' + node.standalone + '"');
+ }
+ this.stream.write(this.spacebeforeslash + '?>');
+ return this.stream.write(this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.docType = function(node, level) {
+ var child, i, len, ref;
+ level || (level = 0);
+ this.stream.write(this.space(level));
+ this.stream.write('<!DOCTYPE ' + node.root().name);
+ if (node.pubID && node.sysID) {
+ this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
+ } else if (node.sysID) {
+ this.stream.write(' SYSTEM "' + node.sysID + '"');
+ }
+ if (node.children.length > 0) {
+ this.stream.write(' [');
+ this.stream.write(this.endline(node));
+ ref = node.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ switch (false) {
+ case !(child instanceof XMLDTDAttList):
+ this.dtdAttList(child, level + 1);
+ break;
+ case !(child instanceof XMLDTDElement):
+ this.dtdElement(child, level + 1);
+ break;
+ case !(child instanceof XMLDTDEntity):
+ this.dtdEntity(child, level + 1);
+ break;
+ case !(child instanceof XMLDTDNotation):
+ this.dtdNotation(child, level + 1);
+ break;
+ case !(child instanceof XMLCData):
+ this.cdata(child, level + 1);
+ break;
+ case !(child instanceof XMLComment):
+ this.comment(child, level + 1);
+ break;
+ case !(child instanceof XMLProcessingInstruction):
+ this.processingInstruction(child, level + 1);
+ break;
+ default:
+ throw new Error("Unknown DTD node type: " + child.constructor.name);
+ }
+ }
+ this.stream.write(']');
+ }
+ this.stream.write(this.spacebeforeslash + '>');
+ return this.stream.write(this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.element = function(node, level) {
+ var att, child, i, len, name, ref, ref1, space;
+ level || (level = 0);
+ space = this.space(level);
+ this.stream.write(space + '<' + node.name);
+ ref = node.attributes;
+ for (name in ref) {
+ if (!hasProp.call(ref, name)) continue;
+ att = ref[name];
+ this.attribute(att);
+ }
+ if (node.children.length === 0 || node.children.every(function(e) {
+ return e.value === '';
+ })) {
+ if (this.allowEmpty) {
+ this.stream.write('></' + node.name + '>');
+ } else {
+ this.stream.write(this.spacebeforeslash + '/>');
+ }
+ } else if (this.pretty && node.children.length === 1 && (node.children[0].value != null)) {
+ this.stream.write('>');
+ this.stream.write(node.children[0].value);
+ this.stream.write('</' + node.name + '>');
+ } else {
+ this.stream.write('>' + this.newline);
+ ref1 = node.children;
+ for (i = 0, len = ref1.length; i < len; i++) {
+ child = ref1[i];
+ switch (false) {
+ case !(child instanceof XMLCData):
+ this.cdata(child, level + 1);
+ break;
+ case !(child instanceof XMLComment):
+ this.comment(child, level + 1);
+ break;
+ case !(child instanceof XMLElement):
+ this.element(child, level + 1);
+ break;
+ case !(child instanceof XMLRaw):
+ this.raw(child, level + 1);
+ break;
+ case !(child instanceof XMLText):
+ this.text(child, level + 1);
+ break;
+ case !(child instanceof XMLProcessingInstruction):
+ this.processingInstruction(child, level + 1);
+ break;
+ default:
+ throw new Error("Unknown XML node type: " + child.constructor.name);
+ }
+ }
+ this.stream.write(space + '</' + node.name + '>');
+ }
+ return this.stream.write(this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.processingInstruction = function(node, level) {
+ this.stream.write(this.space(level) + '<?' + node.target);
+ if (node.value) {
+ this.stream.write(' ' + node.value);
+ }
+ return this.stream.write(this.spacebeforeslash + '?>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.raw = function(node, level) {
+ return this.stream.write(this.space(level) + node.value + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.text = function(node, level) {
+ return this.stream.write(this.space(level) + node.value + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.dtdAttList = function(node, level) {
+ this.stream.write(this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType);
+ if (node.defaultValueType !== '#DEFAULT') {
+ this.stream.write(' ' + node.defaultValueType);
+ }
+ if (node.defaultValue) {
+ this.stream.write(' "' + node.defaultValue + '"');
+ }
+ return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.dtdElement = function(node, level) {
+ this.stream.write(this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value);
+ return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.dtdEntity = function(node, level) {
+ this.stream.write(this.space(level) + '<!ENTITY');
+ if (node.pe) {
+ this.stream.write(' %');
+ }
+ this.stream.write(' ' + node.name);
+ if (node.value) {
+ this.stream.write(' "' + node.value + '"');
+ } else {
+ if (node.pubID && node.sysID) {
+ this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
+ } else if (node.sysID) {
+ this.stream.write(' SYSTEM "' + node.sysID + '"');
+ }
+ if (node.nData) {
+ this.stream.write(' NDATA ' + node.nData);
+ }
+ }
+ return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.dtdNotation = function(node, level) {
+ this.stream.write(this.space(level) + '<!NOTATION ' + node.name);
+ if (node.pubID && node.sysID) {
+ this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
+ } else if (node.pubID) {
+ this.stream.write(' PUBLIC "' + node.pubID + '"');
+ } else if (node.sysID) {
+ this.stream.write(' SYSTEM "' + node.sysID + '"');
+ }
+ return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
+ };
+
+ XMLStreamWriter.prototype.endline = function(node) {
+ if (!node.isLastRootNode) {
+ return this.newline;
+ } else {
+ return '';
+ }
+ };
+
+ return XMLStreamWriter;
+
+ })(XMLWriterBase);
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLStringWriter.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLStringWriter.js
new file mode 100644
index 0000000..49da759
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLStringWriter.js
@@ -0,0 +1,334 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLText, XMLWriterBase,
+ 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;
+
+ XMLDeclaration = require('./XMLDeclaration');
+
+ XMLDocType = require('./XMLDocType');
+
+ XMLCData = require('./XMLCData');
+
+ XMLComment = require('./XMLComment');
+
+ XMLElement = require('./XMLElement');
+
+ XMLRaw = require('./XMLRaw');
+
+ XMLText = require('./XMLText');
+
+ XMLProcessingInstruction = require('./XMLProcessingInstruction');
+
+ XMLDTDAttList = require('./XMLDTDAttList');
+
+ XMLDTDElement = require('./XMLDTDElement');
+
+ XMLDTDEntity = require('./XMLDTDEntity');
+
+ XMLDTDNotation = require('./XMLDTDNotation');
+
+ XMLWriterBase = require('./XMLWriterBase');
+
+ module.exports = XMLStringWriter = (function(superClass) {
+ extend(XMLStringWriter, superClass);
+
+ function XMLStringWriter(options) {
+ XMLStringWriter.__super__.constructor.call(this, options);
+ }
+
+ XMLStringWriter.prototype.document = function(doc) {
+ var child, i, len, r, ref;
+ this.textispresent = false;
+ r = '';
+ ref = doc.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ r += (function() {
+ switch (false) {
+ case !(child instanceof XMLDeclaration):
+ return this.declaration(child);
+ case !(child instanceof XMLDocType):
+ return this.docType(child);
+ case !(child instanceof XMLComment):
+ return this.comment(child);
+ case !(child instanceof XMLProcessingInstruction):
+ return this.processingInstruction(child);
+ default:
+ return this.element(child, 0);
+ }
+ }).call(this);
+ }
+ if (this.pretty && r.slice(-this.newline.length) === this.newline) {
+ r = r.slice(0, -this.newline.length);
+ }
+ return r;
+ };
+
+ XMLStringWriter.prototype.attribute = function(att) {
+ return ' ' + att.name + '="' + att.value + '"';
+ };
+
+ XMLStringWriter.prototype.cdata = function(node, level) {
+ return this.space(level) + '<![CDATA[' + node.text + ']]>' + this.newline;
+ };
+
+ XMLStringWriter.prototype.comment = function(node, level) {
+ return this.space(level) + '<!-- ' + node.text + ' -->' + this.newline;
+ };
+
+ XMLStringWriter.prototype.declaration = function(node, level) {
+ var r;
+ r = this.space(level);
+ r += '<?xml version="' + node.version + '"';
+ if (node.encoding != null) {
+ r += ' encoding="' + node.encoding + '"';
+ }
+ if (node.standalone != null) {
+ r += ' standalone="' + node.standalone + '"';
+ }
+ r += this.spacebeforeslash + '?>';
+ r += this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.docType = function(node, level) {
+ var child, i, len, r, ref;
+ level || (level = 0);
+ r = this.space(level);
+ r += '<!DOCTYPE ' + node.root().name;
+ if (node.pubID && node.sysID) {
+ r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
+ } else if (node.sysID) {
+ r += ' SYSTEM "' + node.sysID + '"';
+ }
+ if (node.children.length > 0) {
+ r += ' [';
+ r += this.newline;
+ ref = node.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ r += (function() {
+ switch (false) {
+ case !(child instanceof XMLDTDAttList):
+ return this.dtdAttList(child, level + 1);
+ case !(child instanceof XMLDTDElement):
+ return this.dtdElement(child, level + 1);
+ case !(child instanceof XMLDTDEntity):
+ return this.dtdEntity(child, level + 1);
+ case !(child instanceof XMLDTDNotation):
+ return this.dtdNotation(child, level + 1);
+ case !(child instanceof XMLCData):
+ return this.cdata(child, level + 1);
+ case !(child instanceof XMLComment):
+ return this.comment(child, level + 1);
+ case !(child instanceof XMLProcessingInstruction):
+ return this.processingInstruction(child, level + 1);
+ default:
+ throw new Error("Unknown DTD node type: " + child.constructor.name);
+ }
+ }).call(this);
+ }
+ r += ']';
+ }
+ r += this.spacebeforeslash + '>';
+ r += this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.element = function(node, level) {
+ var att, child, i, j, len, len1, name, r, ref, ref1, ref2, space, textispresentwasset;
+ level || (level = 0);
+ textispresentwasset = false;
+ if (this.textispresent) {
+ this.newline = '';
+ this.pretty = false;
+ } else {
+ this.newline = this.newlinedefault;
+ this.pretty = this.prettydefault;
+ }
+ space = this.space(level);
+ r = '';
+ r += space + '<' + node.name;
+ ref = node.attributes;
+ for (name in ref) {
+ if (!hasProp.call(ref, name)) continue;
+ att = ref[name];
+ r += this.attribute(att);
+ }
+ if (node.children.length === 0 || node.children.every(function(e) {
+ return e.value === '';
+ })) {
+ if (this.allowEmpty) {
+ r += '></' + node.name + '>' + this.newline;
+ } else {
+ r += this.spacebeforeslash + '/>' + this.newline;
+ }
+ } else if (this.pretty && node.children.length === 1 && (node.children[0].value != null)) {
+ r += '>';
+ r += node.children[0].value;
+ r += '</' + node.name + '>' + this.newline;
+ } else {
+ if (this.dontprettytextnodes) {
+ ref1 = node.children;
+ for (i = 0, len = ref1.length; i < len; i++) {
+ child = ref1[i];
+ if (child.value != null) {
+ this.textispresent++;
+ textispresentwasset = true;
+ break;
+ }
+ }
+ }
+ if (this.textispresent) {
+ this.newline = '';
+ this.pretty = false;
+ space = this.space(level);
+ }
+ r += '>' + this.newline;
+ ref2 = node.children;
+ for (j = 0, len1 = ref2.length; j < len1; j++) {
+ child = ref2[j];
+ r += (function() {
+ switch (false) {
+ case !(child instanceof XMLCData):
+ return this.cdata(child, level + 1);
+ case !(child instanceof XMLComment):
+ return this.comment(child, level + 1);
+ case !(child instanceof XMLElement):
+ return this.element(child, level + 1);
+ case !(child instanceof XMLRaw):
+ return this.raw(child, level + 1);
+ case !(child instanceof XMLText):
+ return this.text(child, level + 1);
+ case !(child instanceof XMLProcessingInstruction):
+ return this.processingInstruction(child, level + 1);
+ default:
+ throw new Error("Unknown XML node type: " + child.constructor.name);
+ }
+ }).call(this);
+ }
+ if (textispresentwasset) {
+ this.textispresent--;
+ }
+ if (!this.textispresent) {
+ this.newline = this.newlinedefault;
+ this.pretty = this.prettydefault;
+ }
+ r += space + '</' + node.name + '>' + this.newline;
+ }
+ return r;
+ };
+
+ XMLStringWriter.prototype.processingInstruction = function(node, level) {
+ var r;
+ r = this.space(level) + '<?' + node.target;
+ if (node.value) {
+ r += ' ' + node.value;
+ }
+ r += this.spacebeforeslash + '?>' + this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.raw = function(node, level) {
+ return this.space(level) + node.value + this.newline;
+ };
+
+ XMLStringWriter.prototype.text = function(node, level) {
+ return this.space(level) + node.value + this.newline;
+ };
+
+ XMLStringWriter.prototype.dtdAttList = function(node, level) {
+ var r;
+ r = this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType;
+ if (node.defaultValueType !== '#DEFAULT') {
+ r += ' ' + node.defaultValueType;
+ }
+ if (node.defaultValue) {
+ r += ' "' + node.defaultValue + '"';
+ }
+ r += this.spacebeforeslash + '>' + this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.dtdElement = function(node, level) {
+ return this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value + this.spacebeforeslash + '>' + this.newline;
+ };
+
+ XMLStringWriter.prototype.dtdEntity = function(node, level) {
+ var r;
+ r = this.space(level) + '<!ENTITY';
+ if (node.pe) {
+ r += ' %';
+ }
+ r += ' ' + node.name;
+ if (node.value) {
+ r += ' "' + node.value + '"';
+ } else {
+ if (node.pubID && node.sysID) {
+ r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
+ } else if (node.sysID) {
+ r += ' SYSTEM "' + node.sysID + '"';
+ }
+ if (node.nData) {
+ r += ' NDATA ' + node.nData;
+ }
+ }
+ r += this.spacebeforeslash + '>' + this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.dtdNotation = function(node, level) {
+ var r;
+ r = this.space(level) + '<!NOTATION ' + node.name;
+ if (node.pubID && node.sysID) {
+ r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
+ } else if (node.pubID) {
+ r += ' PUBLIC "' + node.pubID + '"';
+ } else if (node.sysID) {
+ r += ' SYSTEM "' + node.sysID + '"';
+ }
+ r += this.spacebeforeslash + '>' + this.newline;
+ return r;
+ };
+
+ XMLStringWriter.prototype.openNode = function(node, level) {
+ var att, name, r, ref;
+ level || (level = 0);
+ if (node instanceof XMLElement) {
+ r = this.space(level) + '<' + node.name;
+ ref = node.attributes;
+ for (name in ref) {
+ if (!hasProp.call(ref, name)) continue;
+ att = ref[name];
+ r += this.attribute(att);
+ }
+ r += (node.children ? '>' : '/>') + this.newline;
+ return r;
+ } else {
+ r = this.space(level) + '<!DOCTYPE ' + node.rootNodeName;
+ if (node.pubID && node.sysID) {
+ r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
+ } else if (node.sysID) {
+ r += ' SYSTEM "' + node.sysID + '"';
+ }
+ r += (node.children ? ' [' : '>') + this.newline;
+ return r;
+ }
+ };
+
+ XMLStringWriter.prototype.closeNode = function(node, level) {
+ level || (level = 0);
+ switch (false) {
+ case !(node instanceof XMLElement):
+ return this.space(level) + '</' + node.name + '>' + this.newline;
+ case !(node instanceof XMLDocType):
+ return this.space(level) + ']>' + this.newline;
+ }
+ };
+
+ return XMLStringWriter;
+
+ })(XMLWriterBase);
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLStringifier.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLStringifier.js
new file mode 100644
index 0000000..c1844fb
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLStringifier.js
@@ -0,0 +1,163 @@
+// Generated by CoffeeScript 1.12.7
+(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;
+ options || (options = {});
+ this.noDoubleEncoding = options.noDoubleEncoding;
+ ref = options.stringify || {};
+ 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 || '';
+ val = val.replace(']]>', ']]]]><![CDATA[>');
+ 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 = '' + 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 res;
+ res = str.match(/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/);
+ if (res) {
+ throw new Error("Invalid character in string: " + str + " at index " + res.index);
+ }
+ return str;
+ };
+
+ XMLStringifier.prototype.elEscape = function(str) {
+ var ampregex;
+ ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
+ return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\r/g, '&#xD;');
+ };
+
+ XMLStringifier.prototype.attEscape = function(str) {
+ var ampregex;
+ ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
+ return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/\t/g, '&#x9;').replace(/\n/g, '&#xA;').replace(/\r/g, '&#xD;');
+ };
+
+ return XMLStringifier;
+
+ })();
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLText.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLText.js
new file mode 100644
index 0000000..0ecceb3
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLText.js
@@ -0,0 +1,32 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLNode, XMLText,
+ 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;
+
+ XMLNode = require('./XMLNode');
+
+ module.exports = XMLText = (function(superClass) {
+ extend(XMLText, superClass);
+
+ function XMLText(parent, text) {
+ XMLText.__super__.constructor.call(this, parent);
+ if (text == null) {
+ throw new Error("Missing element text");
+ }
+ this.value = this.stringify.eleText(text);
+ }
+
+ XMLText.prototype.clone = function() {
+ return Object.create(this);
+ };
+
+ XMLText.prototype.toString = function(options) {
+ return this.options.writer.set(options).text(this);
+ };
+
+ return XMLText;
+
+ })(XMLNode);
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLWriterBase.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLWriterBase.js
new file mode 100644
index 0000000..dfa51d8
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/XMLWriterBase.js
@@ -0,0 +1,90 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLWriterBase,
+ hasProp = {}.hasOwnProperty;
+
+ module.exports = XMLWriterBase = (function() {
+ function XMLWriterBase(options) {
+ var key, ref, ref1, ref2, ref3, ref4, ref5, ref6, value;
+ options || (options = {});
+ this.pretty = options.pretty || false;
+ this.allowEmpty = (ref = options.allowEmpty) != null ? ref : false;
+ if (this.pretty) {
+ this.indent = (ref1 = options.indent) != null ? ref1 : ' ';
+ this.newline = (ref2 = options.newline) != null ? ref2 : '\n';
+ this.offset = (ref3 = options.offset) != null ? ref3 : 0;
+ this.dontprettytextnodes = (ref4 = options.dontprettytextnodes) != null ? ref4 : 0;
+ } else {
+ this.indent = '';
+ this.newline = '';
+ this.offset = 0;
+ this.dontprettytextnodes = 0;
+ }
+ this.spacebeforeslash = (ref5 = options.spacebeforeslash) != null ? ref5 : '';
+ if (this.spacebeforeslash === true) {
+ this.spacebeforeslash = ' ';
+ }
+ this.newlinedefault = this.newline;
+ this.prettydefault = this.pretty;
+ ref6 = options.writer || {};
+ for (key in ref6) {
+ if (!hasProp.call(ref6, key)) continue;
+ value = ref6[key];
+ this[key] = value;
+ }
+ }
+
+ XMLWriterBase.prototype.set = function(options) {
+ var key, ref, value;
+ options || (options = {});
+ if ("pretty" in options) {
+ this.pretty = options.pretty;
+ }
+ if ("allowEmpty" in options) {
+ this.allowEmpty = options.allowEmpty;
+ }
+ if (this.pretty) {
+ this.indent = "indent" in options ? options.indent : ' ';
+ this.newline = "newline" in options ? options.newline : '\n';
+ this.offset = "offset" in options ? options.offset : 0;
+ this.dontprettytextnodes = "dontprettytextnodes" in options ? options.dontprettytextnodes : 0;
+ } else {
+ this.indent = '';
+ this.newline = '';
+ this.offset = 0;
+ this.dontprettytextnodes = 0;
+ }
+ this.spacebeforeslash = "spacebeforeslash" in options ? options.spacebeforeslash : '';
+ if (this.spacebeforeslash === true) {
+ this.spacebeforeslash = ' ';
+ }
+ this.newlinedefault = this.newline;
+ this.prettydefault = this.pretty;
+ ref = options.writer || {};
+ for (key in ref) {
+ if (!hasProp.call(ref, key)) continue;
+ value = ref[key];
+ this[key] = value;
+ }
+ return this;
+ };
+
+ XMLWriterBase.prototype.space = function(level) {
+ var indent;
+ if (this.pretty) {
+ indent = (level || 0) + this.offset + 1;
+ if (indent > 0) {
+ return new Array(indent).join(this.indent);
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ };
+
+ return XMLWriterBase;
+
+ })();
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/index.js b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/index.js
new file mode 100644
index 0000000..d2a1dc1
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/lib/index.js
@@ -0,0 +1,53 @@
+// Generated by CoffeeScript 1.12.7
+(function() {
+ var XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
+
+ ref = require('./Utility'), assign = ref.assign, isFunction = ref.isFunction;
+
+ XMLDocument = require('./XMLDocument');
+
+ XMLDocumentCB = require('./XMLDocumentCB');
+
+ XMLStringWriter = require('./XMLStringWriter');
+
+ XMLStreamWriter = require('./XMLStreamWriter');
+
+ module.exports.create = function(name, xmldec, doctype, options) {
+ var doc, root;
+ if (name == null) {
+ throw new Error("Root element needs a name");
+ }
+ options = assign({}, xmldec, doctype, options);
+ doc = new XMLDocument(options);
+ root = doc.element(name);
+ if (!options.headless) {
+ doc.declaration(options);
+ if ((options.pubID != null) || (options.sysID != null)) {
+ doc.doctype(options);
+ }
+ }
+ return root;
+ };
+
+ module.exports.begin = function(options, onData, onEnd) {
+ var ref1;
+ if (isFunction(options)) {
+ ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
+ options = {};
+ }
+ if (onData) {
+ return new XMLDocumentCB(options, onData, onEnd);
+ } else {
+ return new XMLDocument(options);
+ }
+ };
+
+ module.exports.stringWriter = function(options) {
+ return new XMLStringWriter(options);
+ };
+
+ module.exports.streamWriter = function(stream, options) {
+ return new XMLStreamWriter(stream, options);
+ };
+
+}).call(this);
diff --git a/cordova/node_modules/ios-sim/node_modules/xmlbuilder/package.json b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/package.json
new file mode 100644
index 0000000..f51c56d
--- /dev/null
+++ b/cordova/node_modules/ios-sim/node_modules/xmlbuilder/package.json
@@ -0,0 +1,65 @@
+{
+ "_from": "xmlbuilder@^9.0.7",
+ "_id": "[email protected]",
+ "_inBundle": false,
+ "_integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=",
+ "_location": "/ios-sim/xmlbuilder",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "xmlbuilder@^9.0.7",
+ "name": "xmlbuilder",
+ "escapedName": "xmlbuilder",
+ "rawSpec": "^9.0.7",
+ "saveSpec": null,
+ "fetchSpec": "^9.0.7"
+ },
+ "_requiredBy": [
+ "/ios-sim/plist"
+ ],
+ "_resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
+ "_shasum": "132ee63d2ec5565c557e20f4c22df9aca686b10d",
+ "_spec": "xmlbuilder@^9.0.7",
+ "_where": "/Users/lucifer/Desktop/weatherApp/platforms/ios/cordova/node_modules/ios-sim/node_modules/plist",
+ "author": {
+ "name": "Ozgur Ozcitak",
+ "email": "[email protected]"
+ },
+ "bugs": {
+ "url": "http://github.com/oozcitak/xmlbuilder-js/issues"
+ },
+ "bundleDependencies": false,
+ "contributors": [],
+ "dependencies": {},
+ "deprecated": false,
+ "description": "An XML builder for node.js",
+ "devDependencies": {
+ "coffee-coverage": "2.*",
+ "coffeescript": "1.*",
+ "coveralls": "*",
+ "istanbul": "*",
+ "mocha": "*"
+ },
+ "engines": {
+ "node": ">=4.0"
+ },
+ "homepage": "http://github.com/oozcitak/xmlbuilder-js",
+ "keywords": [
+ "xml",
+ "xmlbuilder"
+ ],
+ "license": "MIT",
+ "main": "./lib/index",
+ "name": "xmlbuilder",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/oozcitak/xmlbuilder-js.git"
+ },
+ "scripts": {
+ "postpublish": "rm -rf lib",
+ "prepublish": "coffee -co lib src",
+ "test": "mocha \"test/**/*.coffee\" && istanbul report text lcov"
+ },
+ "version": "9.0.7"
+}
diff --git a/cordova/node_modules/ios-sim/package.json b/cordova/node_modules/ios-sim/package.json
new file mode 100644
index 0000000..2d64c70
--- /dev/null
+++ b/cordova/node_modules/ios-sim/package.json
@@ -0,0 +1,80 @@
+{
+ "_from": "ios-sim@latest",
+ "_id": "[email protected]",
+ "_inBundle": false,
+ "_integrity": "sha512-VloxT+AARztnhkGQcfxPjMU8puewPULVA+qzAOrK5JspiWTvi7JhBV8t19x42It+tsX35ZabF1WyUZhorLDbvQ==",
+ "_location": "/ios-sim",
+ "_phantomChildren": {
+ "abbrev": "1.1.1",
+ "xmldom": "0.1.27"
+ },
+ "_requested": {
+ "type": "tag",
+ "registry": true,
+ "raw": "ios-sim@latest",
+ "name": "ios-sim",
+ "escapedName": "ios-sim",
+ "rawSpec": "latest",
+ "saveSpec": null,
+ "fetchSpec": "latest"
+ },
+ "_requiredBy": [
+ "#USER",
+ "/"
+ ],
+ "_resolved": "https://registry.npmjs.org/ios-sim/-/ios-sim-7.0.0.tgz",
+ "_shasum": "c286a8ac8e13e978b5bb219f790133b2d36a4b06",
+ "_spec": "ios-sim@latest",
+ "_where": "/Users/lucifer/Desktop/weatherApp/platforms/ios/cordova",
+ "author": {
+ "name": "Shazron Abdullah"
+ },
+ "bin": {
+ "ios-sim": "./bin/ios-sim"
+ },
+ "bugs": {
+ "url": "https://github.com/phonegap/ios-sim/issues"
+ },
+ "bundleDependencies": false,
+ "dependencies": {
+ "bplist-parser": "^0.0.6",
+ "nopt": "1.0.9",
+ "plist": "^3.0.1",
+ "simctl": "^1.1.1"
+ },
+ "deprecated": false,
+ "description": "launch iOS apps into the iOS Simulator from the command line (Xcode 8.0+)",
+ "devDependencies": {
+ "eslint": "^4.19.1",
+ "eslint-config-semistandard": "^12.0.1",
+ "eslint-config-standard": "^11.0.0",
+ "eslint-plugin-import": "^2.12.0",
+ "eslint-plugin-node": "^6.0.1",
+ "eslint-plugin-promise": "^3.8.0",
+ "eslint-plugin-standard": "^3.1.0",
+ "jasmine": "~2.6.0"
+ },
+ "engines": {
+ "node": ">=4"
+ },
+ "homepage": "https://github.com/ios-control/ios-sim#readme",
+ "keywords": [
+ "ios-sim",
+ "iOS Simulator"
+ ],
+ "license": "MIT",
+ "main": "ios-sim.js",
+ "name": "ios-sim",
+ "preferGlobal": "true",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/ios-control/ios-sim.git"
+ },
+ "scripts": {
+ "eslint": "eslint *.js src spec",
+ "jasmine": "jasmine --config=spec/jasmine.json",
+ "posttest": "npm run eslint",
+ "test": "npm run jasmine"
+ },
+ "version": "7.0.0"
+}
diff --git a/cordova/node_modules/ios-sim/spec/.eslintrc.yml b/cordova/node_modules/ios-sim/spec/.eslintrc.yml
new file mode 100644
index 0000000..6c02e1c
--- /dev/null
+++ b/cordova/node_modules/ios-sim/spec/.eslintrc.yml
@@ -0,0 +1,19 @@
+env:
+ jasmine: true
+
+rules:
+ # TBD easy fix:
+ padded-blocks: off
+ spaced-comment: off
+
+ # TODO resolve:
+ eol-last: off
+ semi: off
+
+ # TBD easy resolve:
+ key-spacing: off
+
+ # FUTURE TBD:
+ indent: off
+ quotes: off
+ space-before-function-paren: off
diff --git a/cordova/node_modules/ios-sim/spec/cli.spec.js b/cordova/node_modules/ios-sim/spec/cli.spec.js
new file mode 100644
index 0000000..fe233b7
--- /dev/null
+++ b/cordova/node_modules/ios-sim/spec/cli.spec.js
@@ -0,0 +1,30 @@
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+describe('cli end-to-end', function() {
+
+ beforeEach(function() {
+ });
+
+ afterEach(function() {
+ });
+
+ // it('', function(done) {
+ // });
+}); \ No newline at end of file
diff --git a/cordova/node_modules/ios-sim/spec/commands.spec.js b/cordova/node_modules/ios-sim/spec/commands.spec.js
new file mode 100644
index 0000000..b963ae8
--- /dev/null
+++ b/cordova/node_modules/ios-sim/spec/commands.spec.js
@@ -0,0 +1,61 @@
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+var commands = require('../src/commands');
+var os = require('os');
+
+describe('commands end-to-end', function() {
+
+ beforeEach(function() {
+ if (os.platform() === 'darwin') {
+ commands.init();
+ }
+ });
+
+ afterEach(function() {
+ });
+
+ it('command - showsdks', function() {
+ if (os.platform() === 'darwin') {
+ commands.showsdks({ 'no-output': true });
+ }
+ });
+
+ it('command - showdevicetypes', function() {
+ if (os.platform() === 'darwin') {
+ commands.showdevicetypes({ 'no-output': true });
+ }
+ });
+
+ it('command - launch', function() {
+ //TODO: - fail();
+ //TODO: add a fixture Simulator .app to launch
+ });
+
+ it('command - install', function() {
+ //TODO: - fail();
+ //TODO: add a fixture Simulator .app to install
+ });
+
+ it('command - start', function() {
+ var devicetypeid = 'iPhone-6';
+ if (os.platform() === 'darwin') {
+ commands.start({ 'devicetypeid': devicetypeid });
+ }
+ });
+});
diff --git a/cordova/node_modules/ios-sim/spec/fixture/list.json b/cordova/node_modules/ios-sim/spec/fixture/list.json
new file mode 100644
index 0000000..148fdbe
--- /dev/null
+++ b/cordova/node_modules/ios-sim/spec/fixture/list.json
@@ -0,0 +1,522 @@
+{
+ "devicetypes": [{
+ "name": "iPhone 4s",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPhone-4s"
+ }, {
+ "name": "iPhone 5",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPhone-5"
+ }, {
+ "name": "iPhone 5s",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPhone-5s"
+ }, {
+ "name": "iPhone 6",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPhone-6"
+ }, {
+ "name": "iPhone 6 Plus",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus"
+ }, {
+ "name": "iPhone 6s",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPhone-6s"
+ }, {
+ "name": "iPhone 6s Plus",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus"
+ }, {
+ "name": "iPhone 7",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPhone-7"
+ }, {
+ "name": "iPhone 7 Plus",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPhone-7-Plus"
+ }, {
+ "name": "iPhone SE",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPhone-SE"
+ }, {
+ "name": "iPad 2",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPad-2"
+ }, {
+ "name": "iPad Retina",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPad-Retina"
+ }, {
+ "name": "iPad Air",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPad-Air"
+ }, {
+ "name": "iPad Air 2",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPad-Air-2"
+ }, {
+ "name": "iPad (5th generation)",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPad--5th-generation-"
+ }, {
+ "name": "iPad Pro (9.7-inch)",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--9-7-inch-"
+ }, {
+ "name": "iPad Pro (12.9-inch)",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPad-Pro"
+ }, {
+ "name": "iPad Pro (12.9-inch) (2nd generation)",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---2nd-generation-"
+ }, {
+ "name": "iPad Pro (10.5-inch)",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.iPad-Pro--10-5-inch-"
+ }, {
+ "name": "Apple TV 1080p",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p"
+ }, {
+ "name": "Apple Watch - 38mm",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm"
+ }, {
+ "name": "Apple Watch - 42mm",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-42mm"
+ }, {
+ "name": "Apple Watch Series 2 - 38mm",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-38mm"
+ }, {
+ "name": "Apple Watch Series 2 - 42mm",
+ "identifier": "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-42mm"
+ }],
+ "runtimes": [{
+ "buildversion": "15A5278f",
+ "availability": "(available)",
+ "name": "iOS 11.0",
+ "identifier": "com.apple.CoreSimulator.SimRuntime.iOS-11-0",
+ "version": "11.0"
+ }, {
+ "buildversion": "15J5284e",
+ "availability": "(available)",
+ "name": "tvOS 11.0",
+ "identifier": "com.apple.CoreSimulator.SimRuntime.tvOS-11-0",
+ "version": "11.0"
+ }, {
+ "buildversion": "15R5281f",
+ "availability": "(available)",
+ "name": "watchOS 4.0",
+ "identifier": "com.apple.CoreSimulator.SimRuntime.watchOS-4-0",
+ "version": "4.0"
+ }],
+ "devices": {
+ "iOS 11.0": [{
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "iPhone 5s",
+ "udid": "90EDD7FB-282F-4902-83C0-954F683FB58C"
+ }, {
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "iPhone 6",
+ "udid": "CEFCEEB3-F16E-418F-A8D9-8BDDE22E376B"
+ }, {
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "iPhone 6 Plus",
+ "udid": "62F9F7BA-9529-468A-A9C1-31304514A305"
+ }, {
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "iPhone 6s",
+ "udid": "E47312EF-4A77-46D9-ADC1-C60563BBD462"
+ }, {
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "iPhone 6s Plus",
+ "udid": "3BCF226B-216F-41FB-8BD1-42E1B3D35E96"
+ }, {
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "iPhone 7",
+ "udid": "6278DDAB-E66E-4DC1-BBC2-55340A86077B"
+ }, {
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "iPhone 7 Plus",
+ "udid": "2514D029-A2DF-423A-803D-63F602AF3F6B"
+ }, {
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "iPhone SE",
+ "udid": "E1AF56B8-FF00-4349-BA96-38B7132A7F02"
+ }, {
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "iPad Air",
+ "udid": "1D906B96-4834-47FC-A7F9-AC8AEAC312A6"
+ }, {
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "iPad Air 2",
+ "udid": "008AE630-3481-4AAB-8D4F-A13A64417C7A"
+ }, {
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "iPad (5th generation)",
+ "udid": "E0691C07-BD74-43D1-AC51-050B43912BCD"
+ }, {
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "iPad Pro (9.7 inch)",
+ "udid": "F70A11BD-C120-452E-8C39-D80FB3581A5D"
+ }, {
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "iPad Pro (12.9 inch)",
+ "udid": "649AA16D-CACF-41D0-9B7E-0C28865F4104"
+ }, {
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "iPad Pro (12.9-inch) (2nd generation)",
+ "udid": "CECC5304-4CF2-4D3E-9AA8-EF4F4B09795E"
+ }, {
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "iPad Pro (10.5-inch)",
+ "udid": "8B7A6405-B969-4FFB-800F-1DA09F88DFF1"
+ }],
+ "com.apple.CoreSimulator.SimRuntime.watchOS-3-1": [{
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "Apple Watch - 38mm",
+ "udid": "CB4EEEA0-522A-46A3-B651-7BB1DDB78BAA"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "Apple Watch - 42mm",
+ "udid": "E1BF737C-76B5-410D-B1D6-86653A5D185B"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "Apple Watch Series 2 - 38mm",
+ "udid": "A089A64E-A83A-4E03-97AC-4065C2767F4F"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "Apple Watch Series 2 - 42mm",
+ "udid": "9A7C0B24-071F-4FEF-8D78-F109D51E5EA0"
+ }],
+ "com.apple.CoreSimulator.SimRuntime.iOS-10-2": [{
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone 5",
+ "udid": "93CE90F5-8834-4153-81E0-FC26F6F704AA"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone 5s",
+ "udid": "D1B033B9-ABC6-4842-886C-7DB8FAC6089C"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone 6",
+ "udid": "8A28FD8A-3A1E-41E0-B714-42D4A0D85F40"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone 6 Plus",
+ "udid": "D420BF01-19F6-4241-B434-D0ADE9AF5C0B"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone 6s",
+ "udid": "0AF827DF-F8A5-4745-BDB7-91B0868FAFD9"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone 6s Plus",
+ "udid": "B9FC4934-0534-49D8-B05A-7E0B827CFE2E"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone 7",
+ "udid": "E7FF4BC9-016D-444C-A11C-00F17447B5C0"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone 7 Plus",
+ "udid": "930EE33E-3688-4FD2-997A-41D5B2E8D2AD"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone SE",
+ "udid": "ACF622CF-3958-4B21-A7F5-04C4DF7171A4"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPad Retina",
+ "udid": "B4D33871-C253-4DD9-A7EB-4B0C49FD0AF9"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPad Air",
+ "udid": "C0CAC3C1-E319-43B7-9269-25CAF0EC74A1"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPad Air 2",
+ "udid": "3C7A3B8E-9368-44D4-808E-00E6113E50CE"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPad Pro (9.7 inch)",
+ "udid": "B597EE0E-26E2-404B-9F3A-9551170D547E"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPad Pro (12.9 inch)",
+ "udid": "220DD398-99B3-4840-A4F3-80480801FC79"
+ }],
+ "tvOS 11.0": [{
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "Apple TV 1080p",
+ "udid": "81186783-7F0F-460F-96AF-4BDA342D5E6A"
+ }],
+ "com.apple.CoreSimulator.SimRuntime.tvOS-10-1": [{
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "Apple TV 1080p",
+ "udid": "94187B12-9791-4163-86E4-C632392AE715"
+ }],
+ "com.apple.CoreSimulator.SimRuntime.tvOS-10-2": [{
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "Apple TV 1080p",
+ "udid": "D2BE66BC-F5F7-49E8-A152-EACC8FE3EBA4"
+ }],
+ "com.apple.CoreSimulator.SimRuntime.watchOS-3-2": [{
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "Apple Watch - 38mm",
+ "udid": "934C236B-1651-4FE5-A0CB-D8408ED73F26"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "Apple Watch - 42mm",
+ "udid": "4C69478B-F0BA-47EE-BE03-7EBDC046A821"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "Apple Watch Series 2 - 38mm",
+ "udid": "D505C680-CDAE-41F8-8570-EDB731D5BC7E"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "Apple Watch Series 2 - 42mm",
+ "udid": "BF47F600-1651-44F1-BF85-F30015257135"
+ }],
+ "com.apple.CoreSimulator.SimRuntime.iOS-10-3": [{
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone 5",
+ "udid": "310D3B96-24D4-4610-ADA8-25667AB53B18"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone 5s",
+ "udid": "8A172233-647B-4259-85E8-D0A796D5BF5E"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone 6",
+ "udid": "CE0124DB-7DF9-4311-B686-6DAACC5CF4E5"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone 6 Plus",
+ "udid": "B2C52237-9652-4AA5-8CF3-CAC2AFA5E8AA"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone 6s",
+ "udid": "D649BEC5-2F44-43ED-90D3-0CEA1505B3AA"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone 6s Plus",
+ "udid": "B817B81F-D7AF-486F-85A6-F7151788F163"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone 7",
+ "udid": "739FFF90-F2EF-488A-A88A-B3AADA8831DE"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone 7 Plus",
+ "udid": "4F79A21C-D3A4-432F-A655-BE7966B5C605"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPhone SE",
+ "udid": "C310CF39-B994-4323-8063-DF7F995F822C"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPad Air",
+ "udid": "5EFAC0B6-0583-48EA-BDC6-E80FBFF76116"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPad Air 2",
+ "udid": "C5227DFA-FE4F-4517-95D1-066C8AE65307"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPad Pro (9.7 inch)",
+ "udid": "45AB7B33-CC85-4C25-B6E9-EB861126ABAF"
+ }, {
+ "state": "Shutdown",
+ "availability": " (unavailable, runtime profile not found)",
+ "name": "iPad Pro (12.9 inch)",
+ "udid": "DB13CD84-BAB6-48AA-B402-D0A6B8CEF347"
+ }],
+ "watchOS 4.0": [{
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "Apple Watch - 38mm",
+ "udid": "3F9314D4-1BEB-49F9-B752-F4945498019B"
+ }, {
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "Apple Watch - 42mm",
+ "udid": "0FD51B8F-B2A9-4893-A3AB-8F99140D18BC"
+ }, {
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "Apple Watch Series 2 - 38mm",
+ "udid": "6621CC54-C40D-4B3A-B3D6-3B1451CE5C6C"
+ }, {
+ "state": "Shutdown",
+ "availability": "(available)",
+ "name": "Apple Watch Series 2 - 42mm",
+ "udid": "FAAC4B0F-A273-4E71-A193-D6098AE3D0B1"
+ }]
+ },
+ "pairs": {
+ "54AEA67D-DA3C-4CCE-88F2-EB53AF9D9652": {
+ "watch": {
+ "name": "Apple Watch Series 2 - 42mm",
+ "udid": "BF47F600-1651-44F1-BF85-F30015257135",
+ "state": "Shutdown"
+ },
+ "phone": {
+ "name": "iPhone 7 Plus",
+ "udid": "4F79A21C-D3A4-432F-A655-BE7966B5C605",
+ "state": "Shutdown"
+ },
+ "state": "(unavailable)"
+ },
+ "2AEB0DD4-F854-4861-8BEA-43D6CDF72B3C": {
+ "watch": {
+ "name": "Apple Watch - 42mm",
+ "udid": "0FD51B8F-B2A9-4893-A3AB-8F99140D18BC",
+ "state": "Shutdown"
+ },
+ "phone": {
+ "name": "iPhone 6s Plus",
+ "udid": "3BCF226B-216F-41FB-8BD1-42E1B3D35E96",
+ "state": "Shutdown"
+ },
+ "state": "(active, disconnected)"
+ },
+ "ACC60596-CAF9-414E-8D6A-0EECAB8F1392": {
+ "watch": {
+ "name": "Apple Watch Series 2 - 38mm",
+ "udid": "6621CC54-C40D-4B3A-B3D6-3B1451CE5C6C",
+ "state": "Shutdown"
+ },
+ "phone": {
+ "name": "iPhone 7",
+ "udid": "6278DDAB-E66E-4DC1-BBC2-55340A86077B",
+ "state": "Shutdown"
+ },
+ "state": "(active, disconnected)"
+ },
+ "C482FCBE-3EA5-4726-A18E-C2289AC97181": {
+ "watch": {
+ "name": "Apple Watch Series 2 - 38mm",
+ "udid": "A089A64E-A83A-4E03-97AC-4065C2767F4F",
+ "state": "Shutdown"
+ },
+ "phone": {
+ "name": "iPhone 7",
+ "udid": "E7FF4BC9-016D-444C-A11C-00F17447B5C0",
+ "state": "Shutdown"
+ },
+ "state": "(unavailable)"
+ },
+ "11518B00-90AA-40D9-A361-486AE3BBBD23": {
+ "watch": {
+ "name": "Apple Watch - 38mm",
+ "udid": "934C236B-1651-4FE5-A0CB-D8408ED73F26",
+ "state": "Shutdown"
+ },
+ "phone": {
+ "name": "iPhone 6s",
+ "udid": "D649BEC5-2F44-43ED-90D3-0CEA1505B3AA",
+ "state": "Shutdown"
+ },
+ "state": "(unavailable)"
+ },
+ "4E765022-977B-46B5-878F-3F8BD1C109B8": {
+ "watch": {
+ "name": "Apple Watch Series 2 - 42mm",
+ "udid": "FAAC4B0F-A273-4E71-A193-D6098AE3D0B1",
+ "state": "Shutdown"
+ },
+ "phone": {
+ "name": "iPhone 7 Plus",
+ "udid": "2514D029-A2DF-423A-803D-63F602AF3F6B",
+ "state": "Shutdown"
+ },
+ "state": "(active, disconnected)"
+ },
+ "D383D4FB-98AD-489D-8972-548077111E46": {
+ "watch": {
+ "name": "Apple Watch - 42mm",
+ "udid": "4C69478B-F0BA-47EE-BE03-7EBDC046A821",
+ "state": "Shutdown"
+ },
+ "phone": {
+ "name": "iPhone 6s Plus",
+ "udid": "B817B81F-D7AF-486F-85A6-F7151788F163",
+ "state": "Shutdown"
+ },
+ "state": "(unavailable)"
+ },
+ "E7B45654-1DA4-4E7E-96F3-942B0F49ECE3": {
+ "watch": {
+ "name": "Apple Watch Series 2 - 38mm",
+ "udid": "D505C680-CDAE-41F8-8570-EDB731D5BC7E",
+ "state": "Shutdown"
+ },
+ "phone": {
+ "name": "iPhone 7",
+ "udid": "739FFF90-F2EF-488A-A88A-B3AADA8831DE",
+ "state": "Shutdown"
+ },
+ "state": "(unavailable)"
+ },
+ "5C436B84-09D4-4CDF-B0EF-7847247F0342": {
+ "watch": {
+ "name": "Apple Watch - 38mm",
+ "udid": "3F9314D4-1BEB-49F9-B752-F4945498019B",
+ "state": "Shutdown"
+ },
+ "phone": {
+ "name": "iPhone 6s",
+ "udid": "E47312EF-4A77-46D9-ADC1-C60563BBD462",
+ "state": "Shutdown"
+ },
+ "state": "(active, disconnected)"
+ },
+ "3CF04E41-DCB0-4DFA-B230-94767AF83754": {
+ "watch": {
+ "name": "Apple Watch Series 2 - 42mm",
+ "udid": "9A7C0B24-071F-4FEF-8D78-F109D51E5EA0",
+ "state": "Shutdown"
+ },
+ "phone": {
+ "name": "iPhone 7 Plus",
+ "udid": "930EE33E-3688-4FD2-997A-41D5B2E8D2AD",
+ "state": "Shutdown"
+ },
+ "state": "(unavailable)"
+ }
+ }
+}
diff --git a/cordova/node_modules/ios-sim/spec/jasmine.json b/cordova/node_modules/ios-sim/spec/jasmine.json
new file mode 100644
index 0000000..0bf271b
--- /dev/null
+++ b/cordova/node_modules/ios-sim/spec/jasmine.json
@@ -0,0 +1,8 @@
+{
+ "spec_dir": "spec",
+ "spec_files": [
+ "**/*[sS]pec.js"
+ ],
+ "stopSpecOnExpectationFailure": false,
+ "random": false
+}
diff --git a/cordova/node_modules/ios-sim/spec/lib.spec.js b/cordova/node_modules/ios-sim/spec/lib.spec.js
new file mode 100644
index 0000000..7fa0e88
--- /dev/null
+++ b/cordova/node_modules/ios-sim/spec/lib.spec.js
@@ -0,0 +1,58 @@
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+var lib = require('../src/lib');
+
+describe('lib end-to-end', function() {
+
+ beforeEach(function() {
+ });
+
+ afterEach(function() {
+ });
+
+ describe('when parsing env variables', function() {
+ it("should return empty map on null value", function() {
+ expect(lib._parseEnvironmentVariables(null)).toEqual({});
+ });
+ it("should return empty map on undefined value", function() {
+ expect(lib._parseEnvironmentVariables(undefined)).toEqual({});
+ });
+ describe('without simctl fix', function() {
+ it("should return valid map for valid env variable", function() {
+ expect(lib._parseEnvironmentVariables(["KEY=VALUE"], false)).toEqual({"KEY":"VALUE"});
+ });
+ });
+ describe('with simctl fix', function() {
+ it("should add SIMCTL_CHILD_ prefix to all keys", function() {
+ expect(lib._parseEnvironmentVariables(["KEY=VALUE", "KEY2=VALUE2"], true))
+ .toEqual(
+ {
+ "SIMCTL_CHILD_KEY":"VALUE",
+ "SIMCTL_CHILD_KEY2":"VALUE2"
+ }
+ );
+ });
+ });
+ })
+
+ it('init should not process.exit when called as a lib', function() {
+ var code = lib.init();
+ expect(!isNaN(code)).toBe(true);
+ });
+}); \ No newline at end of file
diff --git a/cordova/node_modules/ios-sim/src/.eslintrc.yml b/cordova/node_modules/ios-sim/src/.eslintrc.yml
new file mode 100644
index 0000000..1ed9eab
--- /dev/null
+++ b/cordova/node_modules/ios-sim/src/.eslintrc.yml
@@ -0,0 +1,21 @@
+rules:
+ # common src exception:
+ camelcase: off
+
+ # TBD easy fix:
+ padded-blocks: off
+
+ # TODO resolve:
+ eqeqeq: off
+ no-unused-vars: off
+ node/no-deprecated-api: off
+
+ # TBD easy resolve:
+ comma-spacing: off
+ no-useless-escape: off
+
+ # FUTURE TBD:
+ no-multiple-empty-lines: off
+ one-var: off
+ spaced-comment: off
+ space-before-function-paren: off
diff --git a/cordova/node_modules/ios-sim/src/cli.js b/cordova/node_modules/ios-sim/src/cli.js
new file mode 100644
index 0000000..206ce2f
--- /dev/null
+++ b/cordova/node_modules/ios-sim/src/cli.js
@@ -0,0 +1,105 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2014 Shazron Abdullah
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+var path = require('path'),
+ command_lib = require('./commands'),
+ help = require('./help');
+var nopt;
+
+/*
+ * init
+ *
+ * initializes nopt and simctl
+ * nopt, and simctl are require()d in try-catch below to print a nice error
+ * message if one of them is not installed.
+ */
+function init() {
+ try {
+ nopt = require('nopt');
+ var code = command_lib.init();
+ if (code !== 0) {
+ process.exit(code);
+ }
+ } catch (e) {
+ console.error(
+ 'Please run npm install from this directory:\n\t' +
+ path.dirname(__dirname)
+ );
+ process.exit(2);
+ }
+}
+
+function cli(inputArgs) {
+ var knownOpts =
+ {
+ 'version': Boolean,
+ 'help': Boolean,
+ 'verbose': Boolean,
+ 'exit': Boolean,
+ 'use-gdb': Boolean,
+ 'uuid': String,
+ 'env': String,
+ 'setenv': Array,
+ 'stdout': path,
+ 'stderr': path,
+ 'timeout': Number,
+ 'args': Array,
+ 'devicetypeid': String
+ };
+
+ var shortHands = null;
+
+ // If no inputArgs given, use process.argv.
+ inputArgs = inputArgs || process.argv;
+
+ init();
+
+ var args = nopt(knownOpts, shortHands, inputArgs);
+
+ process.on('uncaughtException', function(err) {
+ if (!args.verbose) {
+ console.error(err.message);
+ } else {
+ console.error(err.stack);
+ }
+ process.exit(1);
+ });
+
+ var cmd = args.argv.remain[0];
+
+ // some options do *not* need commands and can be run
+ if (args.help) {
+ help();
+ } else if (args.version) {
+ console.log(require('../package').version);
+ } else if (cmd && command_lib[cmd]) { // command found
+ command_lib[cmd](args);
+ } else {
+ help();
+ process.exit(1);
+ }
+}
+
+module.exports = cli;
+
diff --git a/cordova/node_modules/ios-sim/src/commands.js b/cordova/node_modules/ios-sim/src/commands.js
new file mode 100644
index 0000000..89c402d
--- /dev/null
+++ b/cordova/node_modules/ios-sim/src/commands.js
@@ -0,0 +1,94 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2014 Shazron Abdullah
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+var path = require('path'),
+ fs = require('fs'),
+ help = require('./help'),
+ lib = require('./lib'),
+ util = require('util');
+
+var command_lib = {
+
+ init: function() {
+ return lib.init();
+ },
+
+ //jscs:disable disallowUnusedParams
+ showsdks: function(args) {
+ args = args || {};
+
+ var output = lib.showsdks();
+ if (!args['no-output']) {
+ console.log(output);
+ }
+ },
+ //jscs:enable disallowUnusedParams
+
+ //jscs:disable disallowUnusedParams
+ showdevicetypes: function(args) {
+ args = args || {};
+
+ var output = lib.showdevicetypes();
+ if (!args['no-output']) {
+ console.log(output);
+ }
+ },
+ //jscs:enable disallowUnusedParams
+
+ launch: function(args) {
+ var wait_for_debugger = false;
+ var app_path;
+
+ if (args.argv.remain.length < 2) {
+ help();
+ process.exit(1);
+ }
+
+ app_path = args.argv.remain[1];
+
+ lib.launch(app_path, args.devicetypeid, args.log, args.exit, args.setenv, args.args);
+ },
+
+ install: function(args) {
+ var app_identifier;
+ var argv;
+ var app_path;
+ var info_plist_path;
+
+ if (args.argv.remain.length < 2) {
+ help();
+ process.exit(1);
+ }
+
+ app_path = args.argv.remain[1];
+
+ lib.install(app_path, args.devicetypeid, args.log, args.exit);
+ },
+
+ start: function(args) {
+ lib.start(args.devicetypeid);
+ }
+};
+
+module.exports = command_lib;
diff --git a/cordova/node_modules/ios-sim/src/help.js b/cordova/node_modules/ios-sim/src/help.js
new file mode 100644
index 0000000..c2e3306
--- /dev/null
+++ b/cordova/node_modules/ios-sim/src/help.js
@@ -0,0 +1,41 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2014 Shazron Abdullah
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+var fs = require('fs'),
+ path = require('path');
+
+function help() {
+ var docdir = path.join(__dirname, '..', 'doc');
+ var helpfile = path.join(docdir, 'help.txt');
+
+ if (fs.existsSync(helpfile)) {
+ var s = fs.readFileSync(helpfile).toString('utf8');
+ console.log(s);
+ } else {
+ console.log('Help file missing.');
+ }
+}
+
+module.exports = help;
+
diff --git a/cordova/node_modules/ios-sim/src/lib.js b/cordova/node_modules/ios-sim/src/lib.js
new file mode 100644
index 0000000..81e7d3b
--- /dev/null
+++ b/cordova/node_modules/ios-sim/src/lib.js
@@ -0,0 +1,491 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2014 Shazron Abdullah
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+//jscs:disable maximumLineLength
+
+var path = require('path'),
+ fs = require('fs'),
+ help = require('./help'),
+ util = require('util');
+var simctl;
+var bplist;
+var plist;
+
+function findFirstAvailableDevice(list) {
+ /*
+ // Example result:
+ {
+ name : 'iPhone 6',
+ id : 'A1193D97-F5EE-468D-9DBA-786F403766E6',
+ runtime : 'iOS 8.3'
+ }
+ */
+
+ // the object to return
+ var ret_obj = {
+ name: null,
+ id: null,
+ runtime: null
+ };
+
+ var available_runtimes = {};
+
+ list.runtimes.forEach(function(runtime) {
+ available_runtimes[ runtime.name ] = (runtime.availability === '(available)');
+ });
+
+ Object.keys(list.devices).some(function(deviceGroup) {
+ return list.devices[deviceGroup].some(function(device) {
+ if (available_runtimes[deviceGroup]) {
+ ret_obj = {
+ name: device.name,
+ id: device.udid,
+ runtime: deviceGroup
+ };
+ return true;
+ }
+ return false;
+ });
+ });
+
+ return ret_obj;
+}
+
+function findRuntimesGroupByDeviceProperty(list, deviceProperty, availableOnly) {
+ /*
+ // Example result:
+ {
+ "iPhone 6" : [ "iOS 8.2", "iOS 8.3"],
+ "iPhone 6 Plus" : [ "iOS 8.2", "iOS 8.3"]
+ }
+ */
+
+ var runtimes = {};
+ var available_runtimes = {};
+
+ list.runtimes.forEach(function(runtime) {
+ available_runtimes[ runtime.name ] = (runtime.availability === '(available)');
+ });
+
+ Object.keys(list.devices).forEach(function(deviceGroup) {
+ list.devices[deviceGroup].forEach(function(device) {
+ var devicePropertyValue = device[deviceProperty];
+
+ if (!runtimes[devicePropertyValue]) {
+ runtimes[devicePropertyValue] = [];
+ }
+ if (availableOnly) {
+ if (available_runtimes[deviceGroup]) {
+ runtimes[devicePropertyValue].push(deviceGroup);
+ }
+ } else {
+ runtimes[devicePropertyValue].push(deviceGroup);
+ }
+ });
+ });
+
+ return runtimes;
+}
+
+function findAvailableRuntime(list, device_name) {
+
+ var all_druntimes = findRuntimesGroupByDeviceProperty(list, 'name', true);
+ var druntime = all_druntimes[ filterDeviceName(device_name) ] || all_druntimes[ device_name ];
+ var runtime_found = druntime && druntime.length > 0;
+
+ if (!runtime_found) {
+ console.error(util.format('No available runtimes could be found for "%s".', device_name));
+ process.exit(1);
+ }
+
+ // return most modern runtime
+ return druntime.sort().pop();
+}
+
+function getDeviceFromDeviceTypeId(devicetypeid) {
+ /*
+ // Example result:
+ {
+ name : 'iPhone 6',
+ id : 'A1193D97-F5EE-468D-9DBA-786F403766E6',
+ runtime : 'iOS 8.3'
+ }
+ */
+
+ // the object to return
+ var ret_obj = {
+ name: null,
+ id: null,
+ runtime: null
+ };
+
+ var options = { 'silent': true };
+ var list = simctl.list(options).json;
+ list = fixSimCtlList(list);
+
+ var arr = [];
+ if (devicetypeid) {
+ arr = devicetypeid.split(',');
+ }
+
+ // get the devicetype from --devicetypeid
+ // --devicetypeid is a string in the form "devicetype, runtime_version" (optional: runtime_version)
+ var devicetype = null;
+ if (arr.length < 1) {
+ var dv = findFirstAvailableDevice(list);
+ console.error(util.format('--devicetypeid was not specified, using first available device: %s.', dv.name));
+ return dv;
+ } else {
+ devicetype = arr[0].trim();
+ if (arr.length > 1) {
+ ret_obj.runtime = arr[1].trim();
+ }
+ }
+
+ // check whether devicetype has the "com.apple.CoreSimulator.SimDeviceType." prefix, if not, add it
+ var prefix = 'com.apple.CoreSimulator.SimDeviceType.';
+ if (devicetype.indexOf(prefix) !== 0) {
+ devicetype = prefix + devicetype;
+ }
+
+ // now find the devicename from the devicetype
+ var devicename_found = list.devicetypes.some(function(deviceGroup) {
+ if (deviceGroup.identifier === devicetype) {
+ ret_obj.name = deviceGroup.name;
+ return true;
+ }
+
+ return false;
+ });
+
+ // device name not found, exit
+ if (!devicename_found) {
+ console.error(util.format('Device type "%s" could not be found.', devicetype));
+ process.exit(1);
+ }
+
+ // if runtime_version was not specified, we use a default. Use first available that has the device
+ if (!ret_obj.runtime) {
+ ret_obj.runtime = findAvailableRuntime(list, ret_obj.name);
+ }
+
+ // prepend iOS to runtime version, if necessary
+ if (ret_obj.runtime.indexOf('OS') === -1) {
+ ret_obj.runtime = util.format('iOS %s', ret_obj.runtime);
+ }
+
+ // now find the deviceid (by runtime and devicename)
+ var deviceid_found = Object.keys(list.devices).some(function(deviceGroup) {
+ // found the runtime, now find the actual device matching devicename
+ if (deviceGroup === ret_obj.runtime) {
+ return list.devices[deviceGroup].some(function(device) {
+ if (filterDeviceName(device.name) === filterDeviceName(ret_obj.name)) {
+ ret_obj.id = device.udid;
+ return true;
+ }
+ return false;
+ });
+ }
+ return false;
+ });
+
+ if (!deviceid_found) {
+ console.error(
+ util.format('Device id for device name "%s" and runtime "%s" could not be found, or is not available.', ret_obj.name, ret_obj.runtime)
+ );
+ process.exit(1);
+ }
+
+ return ret_obj;
+}
+
+// Parses array of KEY=Value strings into map of strings
+// If fixsymctl == true, updates variables for correct usage with simctl
+function parseEnvironmentVariables(envVariables, fixsymctl) {
+ envVariables = envVariables || [];
+ fixsymctl = typeof fixsymctl != 'undefined' ? fixsymctl : true;
+
+ var envMap = {};
+ envVariables.forEach(function(variable) {
+ var envPair = variable.split('=', 2);
+ if (envPair.length == 2) {
+ var key = envPair[0];
+ var value = envPair[1];
+ if (fixsymctl) {
+ key = 'SIMCTL_CHILD_' + key;
+ }
+ envMap[ key ] = value;
+ }
+ });
+ return envMap;
+}
+
+// Injects specified environt variables to the process and then runs action
+// returns environment variables back to original state after action completes
+function withInjectedEnvironmentVariablesToProcess(process, envVariables, action) {
+ var oldVariables = util._extend({}, process.env);
+
+ // Inject additional environment variables to process
+ for (var key in envVariables) {
+ var value = envVariables[key];
+ process.env[key] = value;
+ }
+
+ action();
+
+ // restore old envs
+ process.env = oldVariables;
+}
+
+// replace hyphens in iPad Pro name which differ in 'Device Types' and 'Devices'
+function filterDeviceName(deviceName) {
+ // replace hyphens in iPad Pro name which differ in 'Device Types' and 'Devices'
+ if (deviceName.indexOf('iPad Pro') === 0) {
+ return deviceName.replace(/\-/g, ' ').trim();
+ }
+ return deviceName;
+}
+
+function fixNameKey(array, mapping) {
+ if (!array || !mapping) {
+ return array;
+ }
+
+ return array.map(function(elem) {
+ var name = mapping[elem.name];
+ if (name) {
+ elem.name = name;
+ }
+ return elem;
+ });
+}
+
+function fixSimCtlList(list) {
+ // Xcode 9 `xcrun simctl list devicetypes` have obfuscated names for 2017 iPhones and Apple Watches.
+ var deviceTypeNameMap = {
+ 'iPhone2017-A': 'iPhone 8',
+ 'iPhone2017-B': 'iPhone 8 Plus',
+ 'iPhone2017-C': 'iPhone X',
+ 'Watch2017 - 38mm': 'Apple Watch Series 3 - 38mm',
+ 'Watch2017 - 42mm': 'Apple Watch Series 3 - 42mm'
+ };
+ list.devicetypes = fixNameKey(list.devicetypes, deviceTypeNameMap);
+
+ // `iPad Pro` in iOS 9.3 has mapped to `iPad Pro (9.7 inch)`
+ // `Apple TV 1080p` has mapped to `Apple TV`
+ var deviceNameMap = {
+ 'Apple TV 1080p': 'Apple TV',
+ 'iPad Pro': 'iPad Pro (9.7-inch)'
+ };
+ Object.keys(list.devices).forEach(function(key) {
+ list.devices[key] = fixNameKey(list.devices[key], deviceNameMap);
+ });
+
+ return list;
+}
+
+var lib = {
+
+ init: function() {
+ if (!simctl) {
+ simctl = require('simctl');
+ }
+ var output = simctl.check_prerequisites();
+ if (output.code !== 0) {
+ console.error(output.output);
+ }
+
+ if (!bplist) {
+ bplist = require('bplist-parser');
+ }
+
+ return output.code;
+ },
+
+ //jscs:disable disallowUnusedParams
+ showsdks: function(args) {
+ var options = { silent: true, runtimes: true };
+ var list = simctl.list(options).json;
+
+ var output = 'Simulator SDK Roots:\n';
+ list.runtimes.forEach(function(runtime) {
+ if (runtime.availability === '(available)') {
+ output += util.format('"%s" (%s)\n', runtime.name, runtime.buildversion);
+ output += util.format('\t(unknown)\n');
+ }
+ });
+
+ return output;
+ },
+ //jscs:enable disallowUnusedParams
+
+ //jscs:disable disallowUnusedParams
+ getdevicetypes: function(args) {
+ var options = { silent: true };
+ var list = simctl.list(options).json;
+ list = fixSimCtlList(list);
+
+ var druntimes = findRuntimesGroupByDeviceProperty(list, 'name', true);
+ var name_id_map = {};
+
+ list.devicetypes.forEach(function(device) {
+ name_id_map[ filterDeviceName(device.name) ] = device.identifier;
+ });
+
+ list = [];
+ var remove = function(devicename, runtime) {
+ // remove "iOS" prefix in runtime, remove prefix "com.apple.CoreSimulator.SimDeviceType." in id
+ list.push(util.format('%s, %s', name_id_map[ devicename ].replace(/^com.apple.CoreSimulator.SimDeviceType./, ''), runtime.replace(/^iOS /, '')));
+ };
+
+ var cur = function(devicename) {
+ return function(runtime) {
+ remove(devicename, runtime);
+ };
+ };
+
+ for (var deviceName in druntimes) {
+ var runtimes = druntimes[ deviceName ];
+ var dname = filterDeviceName(deviceName);
+
+ if (!(dname in name_id_map)) {
+ continue;
+ }
+
+ runtimes.forEach(cur(dname));
+ }
+ return list;
+ },
+ //jscs:enable disallowUnusedParams
+
+ //jscs:disable disallowUnusedParams
+ showdevicetypes: function(args) {
+ var output = '';
+ this.getdevicetypes().forEach(function(device) {
+ output += util.format('%s\n', device);
+ });
+
+ return output;
+ },
+ //jscs:enable disallowUnusedParams
+
+ launch: function(app_path, devicetypeid, log, exit, setenv, argv) {
+ var wait_for_debugger = false;
+ var info_plist_path;
+ var app_identifier;
+
+ info_plist_path = path.join(app_path,'Info.plist');
+ if (!fs.existsSync(info_plist_path)) {
+ console.error(info_plist_path + ' file not found.');
+ process.exit(1);
+ }
+
+ bplist.parseFile(info_plist_path, function(err, obj) {
+
+ if (err) {
+ // try to see if a regular plist parser will work
+ if (!plist) {
+ plist = require('plist');
+ }
+ obj = plist.parse(fs.readFileSync(info_plist_path, 'utf8'));
+ if (obj) {
+ app_identifier = obj.CFBundleIdentifier;
+ } else {
+ throw err;
+ }
+ } else {
+ app_identifier = obj[0].CFBundleIdentifier;
+ }
+
+ argv = argv || [];
+ setenv = setenv || [];
+
+ var environmentVariables = parseEnvironmentVariables(setenv);
+
+ withInjectedEnvironmentVariablesToProcess(process, environmentVariables, function() {
+ // get the deviceid from --devicetypeid
+ // --devicetypeid is a string in the form "devicetype, runtime_version" (optional: runtime_version)
+ var device = getDeviceFromDeviceTypeId(devicetypeid);
+
+ // so now we have the deviceid, we can proceed
+ simctl.extensions.start(device.id);
+ simctl.install(device.id, app_path);
+ simctl.launch(wait_for_debugger, device.id, app_identifier, argv);
+ simctl.extensions.log(device.id, log);
+ if (log) {
+ console.log(util.format('logPath: %s', path.resolve(log)));
+ }
+ if (exit) {
+ process.exit(0);
+ }
+ });
+ });
+ },
+
+ install: function(app_path, devicetypeid, log, exit) {
+ var wait_for_debugger = false;
+ var info_plist_path;
+ var app_identifier;
+
+ info_plist_path = path.join(app_path,'Info.plist');
+ if (!fs.existsSync(info_plist_path)) {
+ console.error(info_plist_path + ' file not found.');
+ process.exit(1);
+ }
+
+ bplist.parseFile(info_plist_path, function(err, obj) {
+
+ if (err) {
+ throw err;
+ }
+
+ app_identifier = obj[0].CFBundleIdentifier;
+
+ // get the deviceid from --devicetypeid
+ // --devicetypeid is a string in the form "devicetype, runtime_version" (optional: runtime_version)
+ var device = getDeviceFromDeviceTypeId(devicetypeid);
+
+ // so now we have the deviceid, we can proceed
+ simctl.extensions.start(device.id);
+ simctl.install(device.id, app_path);
+
+ simctl.extensions.log(device.id, log);
+ if (log) {
+ console.log(util.format('logPath: %s', path.resolve(log)));
+ }
+ if (exit) {
+ process.exit(0);
+ }
+ });
+ },
+
+ start: function(devicetypeid) {
+ var device = getDeviceFromDeviceTypeId(devicetypeid);
+ simctl.extensions.start(device.id);
+ },
+
+ _parseEnvironmentVariables: parseEnvironmentVariables
+
+};
+
+module.exports = lib;