From eed07bc31b43ea98c0612ccb5d6dbc2fdd3a99ad Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Wed, 13 Jun 2018 12:23:32 -0400 Subject: [PATCH] cordova-common 2.2.3 update with node_modules needed by node 4: - node_modules/fs.realpath - node_modules/strip-bom --- .gitignore | 1 - node_modules/base64-js/.travis.yml | 5 - .../base64-js/{LICENSE.MIT => LICENSE} | 0 node_modules/base64-js/README.md | 13 +- node_modules/base64-js/base64js.min.js | 1 + node_modules/base64-js/bench/bench.js | 19 - node_modules/base64-js/index.js | 151 + node_modules/base64-js/lib/b64.js | 124 - node_modules/base64-js/package.json | 108 +- node_modules/base64-js/test/big-data.js | 25 + node_modules/base64-js/test/convert.js | 115 +- node_modules/base64-js/test/corrupt.js | 10 + node_modules/base64-js/test/url-safe.js | 24 +- node_modules/big-integer/BigInteger.d.ts | 16 + node_modules/big-integer/BigInteger.js | 230 +- node_modules/big-integer/BigInteger.min.js | 2 +- node_modules/big-integer/README.md | 50 + node_modules/big-integer/package.json | 75 +- node_modules/cordova-common/.eslintrc.yml | 4 +- .../.github/PULL_REQUEST_TEMPLATE.md | 22 + node_modules/cordova-common/.jscs.json | 24 - node_modules/cordova-common/.travis.yml | 1 + node_modules/cordova-common/README.md | 16 +- node_modules/cordova-common/RELEASENOTES.md | 14 + node_modules/cordova-common/appveyor.yml | 3 +- .../cordova-common/node_modules/.bin/shjs | 1 + .../node_modules/elementtree/.npmignore | 1 + .../node_modules/elementtree/.travis.yml | 14 + .../node_modules/elementtree/CHANGES.md | 39 + .../node_modules/elementtree/LICENSE.txt | 203 + .../node_modules/elementtree/Makefile | 21 + .../node_modules/elementtree/NOTICE | 5 + .../node_modules/elementtree/README.md | 141 + .../node_modules/elementtree/lib/constants.js | 20 + .../elementtree/lib/elementpath.js | 343 + .../elementtree/lib/elementtree.js | 611 + .../node_modules/elementtree/lib/errors.js | 31 + .../node_modules/elementtree/lib/parser.js | 33 + .../elementtree/lib/parsers/index.js | 1 + .../elementtree/lib/parsers/sax.js | 56 + .../node_modules/elementtree/lib/sprintf.js | 86 + .../elementtree/lib/treebuilder.js | 60 + .../node_modules/elementtree/lib/utils.js | 72 + .../node_modules/elementtree/package.json | 75 + .../elementtree/tests/data/bom-xml.xml | 17 + .../elementtree/tests/data/xml1.xml | 17 + .../elementtree/tests/data/xml2.xml | 14 + .../elementtree/tests/test-simple.js | 348 + .../node_modules/glob}/LICENSE | 0 .../node_modules/glob/README.md | 368 + .../node_modules/glob/changelog.md | 67 + .../node_modules/glob/common.js | 240 + .../cordova-common/node_modules/glob/glob.js | 790 + .../node_modules/glob/package.json | 77 + .../cordova-common/node_modules/glob/sync.js | 486 + .../cordova-common/node_modules/sax/LICENSE | 41 + .../node_modules/sax/LICENSE-W3C.html | 188 + .../cordova-common/node_modules/sax/README.md | 220 + .../node_modules/sax/lib/sax.js | 1563 ++ .../node_modules/sax/package.json | 60 + .../node_modules/shelljs/CHANGELOG.md | 894 ++ .../node_modules/shelljs/LICENSE | 26 + .../node_modules/shelljs/README.md | 835 ++ .../node_modules/shelljs/bin/shjs | 39 + .../node_modules/shelljs/commands.js | 29 + .../node_modules/shelljs/global.js | 12 + .../node_modules/shelljs/make.js | 57 + .../node_modules/shelljs/package.json | 114 + .../node_modules/shelljs/plugin.js | 16 + .../node_modules/shelljs/shell.js | 156 + .../node_modules/shelljs/src/cat.js | 76 + .../node_modules/shelljs/src/cd.js | 39 + .../node_modules/shelljs/src/chmod.js | 216 + .../node_modules/shelljs/src/common.js | 468 + .../node_modules/shelljs/src/cp.js | 300 + .../node_modules/shelljs/src/dirs.js | 212 + .../node_modules/shelljs/src/echo.js | 63 + .../node_modules/shelljs/src/error.js | 15 + .../node_modules/shelljs/src/exec-child.js | 39 + .../node_modules/shelljs/src/exec.js | 205 + .../node_modules/shelljs/src/find.js | 61 + .../node_modules/shelljs/src/grep.js | 68 + .../node_modules/shelljs/src/head.js | 107 + .../node_modules/shelljs/src/ln.js | 73 + .../node_modules/shelljs/src/ls.js | 141 + .../node_modules/shelljs/src/mkdir.js | 100 + .../node_modules/shelljs/src/mv.js | 118 + .../node_modules/shelljs/src/popd.js | 1 + .../node_modules/shelljs/src/pushd.js | 1 + .../node_modules/shelljs/src/pwd.js | 16 + .../node_modules/shelljs/src/rm.js | 201 + .../node_modules/shelljs/src/sed.js | 87 + .../node_modules/shelljs/src/set.js | 56 + .../node_modules/shelljs/src/sort.js | 97 + .../node_modules/shelljs/src/tail.js | 80 + .../node_modules/shelljs/src/tempdir.js | 59 + .../node_modules/shelljs/src/test.js | 85 + .../node_modules/shelljs/src/to.js | 37 + .../node_modules/shelljs/src/toEnd.js | 36 + .../node_modules/shelljs/src/touch.js | 111 + .../node_modules/shelljs/src/uniq.js | 92 + .../node_modules/shelljs/src/which.js | 99 + node_modules/cordova-common/package.json | 145 +- .../src/ConfigChanges/ConfigChanges.js | 2 + .../src/ConfigChanges/ConfigFile.js | 8 +- .../src/ConfigParser/ConfigParser.js | 45 +- .../cordova-common/src/ConfigParser/README.md | 86 - .../cordova-common/src/FileUpdater.js | 6 +- node_modules/cordova-common/src/superspawn.js | 2 +- .../cordova-common/src/util/xml-helpers.js | 9 +- node_modules/fs.realpath/LICENSE | 43 + node_modules/fs.realpath/README.md | 33 + node_modules/fs.realpath/index.js | 66 + node_modules/fs.realpath/old.js | 303 + node_modules/fs.realpath/package.json | 67 + node_modules/lodash/LICENSE | 22 - node_modules/lodash/README.md | 121 - node_modules/lodash/array.js | 44 - node_modules/lodash/array/chunk.js | 46 - node_modules/lodash/array/compact.js | 30 - node_modules/lodash/array/difference.js | 29 - node_modules/lodash/array/drop.js | 39 - node_modules/lodash/array/dropRight.js | 40 - node_modules/lodash/array/dropRightWhile.js | 59 - node_modules/lodash/array/dropWhile.js | 59 - node_modules/lodash/array/fill.js | 44 - node_modules/lodash/array/findIndex.js | 53 - node_modules/lodash/array/findLastIndex.js | 53 - node_modules/lodash/array/first.js | 22 - node_modules/lodash/array/flatten.js | 32 - node_modules/lodash/array/flattenDeep.js | 21 - node_modules/lodash/array/head.js | 1 - node_modules/lodash/array/indexOf.js | 53 - node_modules/lodash/array/initial.js | 20 - node_modules/lodash/array/intersection.js | 58 - node_modules/lodash/array/last.js | 19 - node_modules/lodash/array/lastIndexOf.js | 60 - node_modules/lodash/array/object.js | 1 - node_modules/lodash/array/pull.js | 52 - node_modules/lodash/array/pullAt.js | 40 - node_modules/lodash/array/remove.js | 64 - node_modules/lodash/array/rest.js | 21 - node_modules/lodash/array/slice.js | 30 - node_modules/lodash/array/sortedIndex.js | 53 - node_modules/lodash/array/sortedLastIndex.js | 25 - node_modules/lodash/array/tail.js | 1 - node_modules/lodash/array/take.js | 39 - node_modules/lodash/array/takeRight.js | 40 - node_modules/lodash/array/takeRightWhile.js | 59 - node_modules/lodash/array/takeWhile.js | 59 - node_modules/lodash/array/union.js | 24 - node_modules/lodash/array/uniq.js | 71 - node_modules/lodash/array/unique.js | 1 - node_modules/lodash/array/unzip.js | 47 - node_modules/lodash/array/unzipWith.js | 41 - node_modules/lodash/array/without.js | 27 - node_modules/lodash/array/xor.js | 35 - node_modules/lodash/array/zip.js | 21 - node_modules/lodash/array/zipObject.js | 43 - node_modules/lodash/array/zipWith.js | 36 - node_modules/lodash/chain.js | 16 - node_modules/lodash/chain/chain.js | 35 - node_modules/lodash/chain/commit.js | 1 - node_modules/lodash/chain/concat.js | 1 - node_modules/lodash/chain/lodash.js | 125 - node_modules/lodash/chain/plant.js | 1 - node_modules/lodash/chain/reverse.js | 1 - node_modules/lodash/chain/run.js | 1 - node_modules/lodash/chain/tap.js | 29 - node_modules/lodash/chain/thru.js | 26 - node_modules/lodash/chain/toJSON.js | 1 - node_modules/lodash/chain/toString.js | 1 - node_modules/lodash/chain/value.js | 1 - node_modules/lodash/chain/valueOf.js | 1 - node_modules/lodash/chain/wrapperChain.js | 32 - node_modules/lodash/chain/wrapperCommit.js | 32 - node_modules/lodash/chain/wrapperConcat.js | 34 - node_modules/lodash/chain/wrapperPlant.js | 45 - node_modules/lodash/chain/wrapperReverse.js | 43 - node_modules/lodash/chain/wrapperToString.js | 17 - node_modules/lodash/chain/wrapperValue.js | 20 - node_modules/lodash/collection.js | 44 - node_modules/lodash/collection/all.js | 1 - node_modules/lodash/collection/any.js | 1 - node_modules/lodash/collection/at.js | 29 - node_modules/lodash/collection/collect.js | 1 - node_modules/lodash/collection/contains.js | 1 - node_modules/lodash/collection/countBy.js | 54 - node_modules/lodash/collection/detect.js | 1 - node_modules/lodash/collection/each.js | 1 - node_modules/lodash/collection/eachRight.js | 1 - node_modules/lodash/collection/every.js | 66 - node_modules/lodash/collection/filter.js | 61 - node_modules/lodash/collection/find.js | 56 - node_modules/lodash/collection/findLast.js | 25 - node_modules/lodash/collection/findWhere.js | 37 - node_modules/lodash/collection/foldl.js | 1 - node_modules/lodash/collection/foldr.js | 1 - node_modules/lodash/collection/forEach.js | 37 - .../lodash/collection/forEachRight.js | 26 - node_modules/lodash/collection/groupBy.js | 59 - node_modules/lodash/collection/include.js | 1 - node_modules/lodash/collection/includes.js | 57 - node_modules/lodash/collection/indexBy.js | 53 - node_modules/lodash/collection/inject.js | 1 - node_modules/lodash/collection/invoke.js | 42 - node_modules/lodash/collection/map.js | 68 - node_modules/lodash/collection/max.js | 1 - node_modules/lodash/collection/min.js | 1 - node_modules/lodash/collection/partition.js | 66 - node_modules/lodash/collection/pluck.js | 31 - node_modules/lodash/collection/reduce.js | 44 - node_modules/lodash/collection/reduceRight.js | 29 - node_modules/lodash/collection/reject.js | 50 - node_modules/lodash/collection/sample.js | 50 - node_modules/lodash/collection/select.js | 1 - node_modules/lodash/collection/shuffle.js | 24 - node_modules/lodash/collection/size.js | 30 - node_modules/lodash/collection/some.js | 67 - node_modules/lodash/collection/sortBy.js | 71 - node_modules/lodash/collection/sortByAll.js | 52 - node_modules/lodash/collection/sortByOrder.js | 55 - node_modules/lodash/collection/sum.js | 1 - node_modules/lodash/collection/where.js | 37 - node_modules/lodash/date.js | 3 - node_modules/lodash/date/now.js | 24 - node_modules/lodash/function.js | 28 - node_modules/lodash/function/after.js | 48 - node_modules/lodash/function/ary.js | 34 - node_modules/lodash/function/backflow.js | 1 - node_modules/lodash/function/before.js | 42 - node_modules/lodash/function/bind.js | 56 - node_modules/lodash/function/bindAll.js | 50 - node_modules/lodash/function/bindKey.js | 66 - node_modules/lodash/function/compose.js | 1 - node_modules/lodash/function/curry.js | 51 - node_modules/lodash/function/curryRight.js | 48 - node_modules/lodash/function/debounce.js | 181 - node_modules/lodash/function/defer.js | 25 - node_modules/lodash/function/delay.js | 26 - node_modules/lodash/function/flow.js | 25 - node_modules/lodash/function/flowRight.js | 25 - node_modules/lodash/function/memoize.js | 80 - node_modules/lodash/function/modArgs.js | 58 - node_modules/lodash/function/negate.js | 32 - node_modules/lodash/function/once.js | 24 - node_modules/lodash/function/partial.js | 43 - node_modules/lodash/function/partialRight.js | 42 - node_modules/lodash/function/rearg.js | 40 - node_modules/lodash/function/restParam.js | 58 - node_modules/lodash/function/spread.js | 44 - node_modules/lodash/function/throttle.js | 62 - node_modules/lodash/function/wrap.js | 33 - node_modules/lodash/index.js | 12351 ---------------- node_modules/lodash/internal/LazyWrapper.js | 26 - node_modules/lodash/internal/LodashWrapper.js | 21 - node_modules/lodash/internal/MapCache.js | 24 - node_modules/lodash/internal/SetCache.js | 29 - node_modules/lodash/internal/arrayConcat.js | 25 - node_modules/lodash/internal/arrayCopy.js | 20 - node_modules/lodash/internal/arrayEach.js | 22 - .../lodash/internal/arrayEachRight.js | 21 - node_modules/lodash/internal/arrayEvery.js | 23 - node_modules/lodash/internal/arrayExtremum.js | 30 - node_modules/lodash/internal/arrayFilter.js | 25 - node_modules/lodash/internal/arrayMap.js | 21 - node_modules/lodash/internal/arrayPush.js | 20 - node_modules/lodash/internal/arrayReduce.js | 26 - .../lodash/internal/arrayReduceRight.js | 24 - node_modules/lodash/internal/arraySome.js | 23 - node_modules/lodash/internal/arraySum.js | 20 - .../lodash/internal/assignDefaults.js | 13 - .../lodash/internal/assignOwnDefaults.js | 26 - node_modules/lodash/internal/assignWith.js | 32 - node_modules/lodash/internal/baseAssign.js | 19 - node_modules/lodash/internal/baseAt.js | 32 - node_modules/lodash/internal/baseCallback.js | 35 - node_modules/lodash/internal/baseClone.js | 128 - .../lodash/internal/baseCompareAscending.js | 34 - node_modules/lodash/internal/baseCopy.js | 23 - node_modules/lodash/internal/baseCreate.js | 23 - node_modules/lodash/internal/baseDelay.js | 21 - .../lodash/internal/baseDifference.js | 55 - node_modules/lodash/internal/baseEach.js | 15 - node_modules/lodash/internal/baseEachRight.js | 15 - node_modules/lodash/internal/baseEvery.js | 22 - node_modules/lodash/internal/baseExtremum.js | 29 - node_modules/lodash/internal/baseFill.js | 31 - node_modules/lodash/internal/baseFilter.js | 22 - node_modules/lodash/internal/baseFind.js | 25 - node_modules/lodash/internal/baseFindIndex.js | 23 - node_modules/lodash/internal/baseFlatten.js | 41 - node_modules/lodash/internal/baseFor.js | 17 - node_modules/lodash/internal/baseForIn.js | 17 - node_modules/lodash/internal/baseForOwn.js | 17 - .../lodash/internal/baseForOwnRight.js | 17 - node_modules/lodash/internal/baseForRight.js | 15 - node_modules/lodash/internal/baseFunctions.js | 27 - node_modules/lodash/internal/baseGet.js | 29 - node_modules/lodash/internal/baseIndexOf.js | 27 - node_modules/lodash/internal/baseIsEqual.js | 28 - .../lodash/internal/baseIsEqualDeep.js | 102 - .../lodash/internal/baseIsFunction.js | 15 - node_modules/lodash/internal/baseIsMatch.js | 52 - node_modules/lodash/internal/baseLodash.js | 10 - node_modules/lodash/internal/baseMap.js | 23 - node_modules/lodash/internal/baseMatches.js | 30 - .../lodash/internal/baseMatchesProperty.js | 45 - node_modules/lodash/internal/baseMerge.js | 56 - node_modules/lodash/internal/baseMergeDeep.js | 67 - node_modules/lodash/internal/baseProperty.js | 14 - .../lodash/internal/basePropertyDeep.js | 19 - node_modules/lodash/internal/basePullAt.js | 30 - node_modules/lodash/internal/baseRandom.js | 18 - node_modules/lodash/internal/baseReduce.js | 24 - node_modules/lodash/internal/baseSetData.js | 17 - node_modules/lodash/internal/baseSlice.js | 32 - node_modules/lodash/internal/baseSome.js | 23 - node_modules/lodash/internal/baseSortBy.js | 21 - .../lodash/internal/baseSortByOrder.js | 31 - node_modules/lodash/internal/baseSum.js | 20 - node_modules/lodash/internal/baseToString.js | 13 - node_modules/lodash/internal/baseUniq.js | 60 - node_modules/lodash/internal/baseValues.js | 22 - node_modules/lodash/internal/baseWhile.js | 24 - .../lodash/internal/baseWrapperValue.js | 29 - node_modules/lodash/internal/binaryIndex.js | 39 - node_modules/lodash/internal/binaryIndexBy.js | 57 - node_modules/lodash/internal/bindCallback.js | 39 - node_modules/lodash/internal/bufferClone.js | 20 - node_modules/lodash/internal/cacheIndexOf.js | 19 - node_modules/lodash/internal/cachePush.js | 20 - .../lodash/internal/charsLeftIndex.js | 18 - .../lodash/internal/charsRightIndex.js | 17 - .../lodash/internal/compareAscending.js | 16 - .../lodash/internal/compareMultiple.js | 44 - node_modules/lodash/internal/composeArgs.js | 34 - .../lodash/internal/composeArgsRight.js | 36 - .../lodash/internal/createAggregator.js | 35 - .../lodash/internal/createAssigner.js | 41 - .../lodash/internal/createBaseEach.js | 31 - node_modules/lodash/internal/createBaseFor.js | 27 - .../lodash/internal/createBindWrapper.js | 22 - node_modules/lodash/internal/createCache.js | 21 - .../lodash/internal/createCompounder.js | 26 - .../lodash/internal/createCtorWrapper.js | 37 - node_modules/lodash/internal/createCurry.js | 23 - .../lodash/internal/createDefaults.js | 22 - .../lodash/internal/createExtremum.js | 33 - node_modules/lodash/internal/createFind.js | 25 - .../lodash/internal/createFindIndex.js | 21 - node_modules/lodash/internal/createFindKey.js | 18 - node_modules/lodash/internal/createFlow.js | 74 - node_modules/lodash/internal/createForEach.js | 20 - node_modules/lodash/internal/createForIn.js | 20 - node_modules/lodash/internal/createForOwn.js | 19 - .../lodash/internal/createHybridWrapper.js | 111 - .../lodash/internal/createObjectMapper.js | 26 - node_modules/lodash/internal/createPadDir.js | 18 - node_modules/lodash/internal/createPadding.js | 29 - node_modules/lodash/internal/createPartial.js | 20 - .../lodash/internal/createPartialWrapper.js | 43 - node_modules/lodash/internal/createReduce.js | 22 - node_modules/lodash/internal/createRound.js | 23 - .../lodash/internal/createSortedIndex.js | 20 - node_modules/lodash/internal/createWrapper.js | 86 - node_modules/lodash/internal/deburrLetter.js | 33 - node_modules/lodash/internal/equalArrays.js | 51 - node_modules/lodash/internal/equalByTag.js | 48 - node_modules/lodash/internal/equalObjects.js | 67 - .../lodash/internal/escapeHtmlChar.js | 22 - .../lodash/internal/escapeRegExpChar.js | 38 - .../lodash/internal/escapeStringChar.js | 22 - node_modules/lodash/internal/getData.js | 15 - node_modules/lodash/internal/getFuncName.js | 25 - node_modules/lodash/internal/getLength.js | 15 - node_modules/lodash/internal/getMatchData.js | 21 - node_modules/lodash/internal/getNative.js | 16 - node_modules/lodash/internal/getView.js | 33 - node_modules/lodash/internal/indexOfNaN.js | 23 - .../lodash/internal/initCloneArray.js | 26 - .../lodash/internal/initCloneByTag.js | 63 - .../lodash/internal/initCloneObject.js | 16 - node_modules/lodash/internal/invokePath.js | 26 - node_modules/lodash/internal/isArrayLike.js | 15 - node_modules/lodash/internal/isIndex.js | 24 - .../lodash/internal/isIterateeCall.js | 28 - node_modules/lodash/internal/isKey.js | 28 - node_modules/lodash/internal/isLaziable.js | 27 - node_modules/lodash/internal/isLength.js | 20 - node_modules/lodash/internal/isObjectLike.js | 12 - node_modules/lodash/internal/isSpace.js | 14 - .../lodash/internal/isStrictComparable.js | 15 - node_modules/lodash/internal/lazyClone.js | 23 - node_modules/lodash/internal/lazyReverse.js | 23 - node_modules/lodash/internal/lazyValue.js | 72 - node_modules/lodash/internal/mapDelete.js | 14 - node_modules/lodash/internal/mapGet.js | 14 - node_modules/lodash/internal/mapHas.js | 20 - node_modules/lodash/internal/mapSet.js | 18 - node_modules/lodash/internal/mergeData.js | 89 - node_modules/lodash/internal/mergeDefaults.js | 15 - node_modules/lodash/internal/metaMap.js | 9 - node_modules/lodash/internal/pickByArray.js | 28 - .../lodash/internal/pickByCallback.js | 22 - node_modules/lodash/internal/reEscape.js | 4 - node_modules/lodash/internal/reEvaluate.js | 4 - node_modules/lodash/internal/reInterpolate.js | 4 - node_modules/lodash/internal/realNames.js | 4 - node_modules/lodash/internal/reorder.js | 29 - .../lodash/internal/replaceHolders.js | 28 - node_modules/lodash/internal/setData.js | 41 - node_modules/lodash/internal/shimKeys.js | 41 - node_modules/lodash/internal/sortedUniq.js | 29 - node_modules/lodash/internal/toIterable.js | 22 - node_modules/lodash/internal/toObject.js | 14 - node_modules/lodash/internal/toPath.js | 28 - .../lodash/internal/trimmedLeftIndex.js | 19 - .../lodash/internal/trimmedRightIndex.js | 18 - .../lodash/internal/unescapeHtmlChar.js | 22 - node_modules/lodash/internal/wrapperClone.js | 18 - node_modules/lodash/lang.js | 32 - node_modules/lodash/lang/clone.js | 70 - node_modules/lodash/lang/cloneDeep.js | 55 - node_modules/lodash/lang/eq.js | 1 - node_modules/lodash/lang/gt.js | 25 - node_modules/lodash/lang/gte.js | 25 - node_modules/lodash/lang/isArguments.js | 34 - node_modules/lodash/lang/isArray.js | 40 - node_modules/lodash/lang/isBoolean.js | 35 - node_modules/lodash/lang/isDate.js | 35 - node_modules/lodash/lang/isElement.js | 24 - node_modules/lodash/lang/isEmpty.js | 47 - node_modules/lodash/lang/isEqual.js | 54 - node_modules/lodash/lang/isError.js | 36 - node_modules/lodash/lang/isFinite.js | 35 - node_modules/lodash/lang/isFunction.js | 38 - node_modules/lodash/lang/isMatch.js | 49 - node_modules/lodash/lang/isNaN.js | 34 - node_modules/lodash/lang/isNative.js | 48 - node_modules/lodash/lang/isNull.js | 21 - node_modules/lodash/lang/isNumber.js | 41 - node_modules/lodash/lang/isObject.js | 28 - node_modules/lodash/lang/isPlainObject.js | 71 - node_modules/lodash/lang/isRegExp.js | 35 - node_modules/lodash/lang/isString.js | 35 - node_modules/lodash/lang/isTypedArray.js | 74 - node_modules/lodash/lang/isUndefined.js | 21 - node_modules/lodash/lang/lt.js | 25 - node_modules/lodash/lang/lte.js | 25 - node_modules/lodash/lang/toArray.js | 32 - node_modules/lodash/lang/toPlainObject.js | 31 - node_modules/lodash/math.js | 9 - node_modules/lodash/math/add.js | 19 - node_modules/lodash/math/ceil.js | 25 - node_modules/lodash/math/floor.js | 25 - node_modules/lodash/math/max.js | 56 - node_modules/lodash/math/min.js | 56 - node_modules/lodash/math/round.js | 25 - node_modules/lodash/math/sum.js | 50 - node_modules/lodash/number.js | 4 - node_modules/lodash/number/inRange.js | 47 - node_modules/lodash/number/random.js | 70 - node_modules/lodash/object.js | 31 - node_modules/lodash/object/assign.js | 43 - node_modules/lodash/object/create.js | 47 - node_modules/lodash/object/defaults.js | 25 - node_modules/lodash/object/defaultsDeep.js | 25 - node_modules/lodash/object/extend.js | 1 - node_modules/lodash/object/findKey.js | 54 - node_modules/lodash/object/findLastKey.js | 54 - node_modules/lodash/object/forIn.js | 33 - node_modules/lodash/object/forInRight.js | 31 - node_modules/lodash/object/forOwn.js | 33 - node_modules/lodash/object/forOwnRight.js | 31 - node_modules/lodash/object/functions.js | 23 - node_modules/lodash/object/get.js | 33 - node_modules/lodash/object/has.js | 57 - node_modules/lodash/object/invert.js | 60 - node_modules/lodash/object/keys.js | 45 - node_modules/lodash/object/keysIn.js | 64 - node_modules/lodash/object/mapKeys.js | 25 - node_modules/lodash/object/mapValues.js | 46 - node_modules/lodash/object/merge.js | 54 - node_modules/lodash/object/methods.js | 1 - node_modules/lodash/object/omit.js | 47 - node_modules/lodash/object/pairs.js | 33 - node_modules/lodash/object/pick.js | 42 - node_modules/lodash/object/result.js | 49 - node_modules/lodash/object/set.js | 55 - node_modules/lodash/object/transform.js | 61 - node_modules/lodash/object/values.js | 33 - node_modules/lodash/object/valuesIn.js | 31 - node_modules/lodash/package.json | 129 - node_modules/lodash/string.js | 25 - node_modules/lodash/string/camelCase.js | 27 - node_modules/lodash/string/capitalize.js | 21 - node_modules/lodash/string/deburr.js | 29 - node_modules/lodash/string/endsWith.js | 40 - node_modules/lodash/string/escape.js | 48 - node_modules/lodash/string/escapeRegExp.js | 32 - node_modules/lodash/string/kebabCase.js | 26 - node_modules/lodash/string/pad.js | 47 - node_modules/lodash/string/padLeft.js | 27 - node_modules/lodash/string/padRight.js | 27 - node_modules/lodash/string/parseInt.js | 46 - node_modules/lodash/string/repeat.js | 47 - node_modules/lodash/string/snakeCase.js | 26 - node_modules/lodash/string/startCase.js | 26 - node_modules/lodash/string/startsWith.js | 36 - node_modules/lodash/string/template.js | 226 - .../lodash/string/templateSettings.js | 67 - node_modules/lodash/string/trim.js | 42 - node_modules/lodash/string/trimLeft.js | 36 - node_modules/lodash/string/trimRight.js | 36 - node_modules/lodash/string/trunc.js | 105 - node_modules/lodash/string/unescape.js | 33 - node_modules/lodash/string/words.js | 38 - node_modules/lodash/support.js | 10 - node_modules/lodash/utility.js | 18 - node_modules/lodash/utility/attempt.js | 32 - node_modules/lodash/utility/callback.js | 53 - node_modules/lodash/utility/constant.js | 23 - node_modules/lodash/utility/identity.js | 20 - node_modules/lodash/utility/iteratee.js | 1 - node_modules/lodash/utility/matches.js | 33 - .../lodash/utility/matchesProperty.js | 32 - node_modules/lodash/utility/method.js | 33 - node_modules/lodash/utility/methodOf.js | 32 - node_modules/lodash/utility/mixin.js | 82 - node_modules/lodash/utility/noop.js | 19 - node_modules/lodash/utility/property.js | 31 - node_modules/lodash/utility/propertyOf.js | 30 - node_modules/lodash/utility/range.js | 66 - node_modules/lodash/utility/times.js | 60 - node_modules/lodash/utility/uniqueId.js | 27 - node_modules/os-tmpdir/index.js | 25 - node_modules/os-tmpdir/package.json | 109 - node_modules/os-tmpdir/readme.md | 32 - node_modules/osenv/README.md | 63 - node_modules/osenv/osenv.js | 72 - node_modules/osenv/package.json | 122 - node_modules/plist/.travis.yml | 35 +- node_modules/plist/History.md | 66 +- node_modules/plist/LICENSE | 2 +- node_modules/plist/Makefile | 3 +- node_modules/plist/README.md | 84 +- node_modules/plist/dist/plist-build.js | 5200 +++---- node_modules/plist/dist/plist-parse.js | 2286 +-- node_modules/plist/dist/plist.js | 6811 ++++----- node_modules/plist/index.js | 13 + node_modules/plist/lib/build.js | 1 - node_modules/plist/lib/node.js | 49 - node_modules/plist/lib/parse.js | 177 +- node_modules/plist/lib/plist.js | 23 - node_modules/plist/package.json | 91 +- node_modules/strip-bom/index.js | 14 + node_modules/{os-tmpdir => strip-bom}/license | 0 node_modules/strip-bom/package.json | 78 + node_modules/strip-bom/readme.md | 36 + node_modules/underscore/LICENSE | 2 +- node_modules/underscore/README.md | 6 + node_modules/underscore/package.json | 89 +- node_modules/underscore/underscore-min.js | 7 +- node_modules/underscore/underscore-min.js.map | 1 + node_modules/underscore/underscore-min.map | 1 - node_modules/underscore/underscore.js | 702 +- node_modules/unorm/LICENSE.md | 42 - node_modules/unorm/README.md | 118 - node_modules/unorm/lib/unorm.js | 442 - node_modules/unorm/package.json | 103 - node_modules/xmlbuilder/CHANGELOG.md | 423 + node_modules/xmlbuilder/README.md | 7 +- node_modules/xmlbuilder/lib/Utility.js | 73 + node_modules/xmlbuilder/lib/XMLAttribute.js | 13 +- node_modules/xmlbuilder/lib/XMLBuilder.js | 69 - node_modules/xmlbuilder/lib/XMLCData.js | 27 +- node_modules/xmlbuilder/lib/XMLComment.js | 27 +- node_modules/xmlbuilder/lib/XMLDTDAttList.js | 42 +- node_modules/xmlbuilder/lib/XMLDTDElement.js | 35 +- node_modules/xmlbuilder/lib/XMLDTDEntity.js | 54 +- node_modules/xmlbuilder/lib/XMLDTDNotation.js | 43 +- node_modules/xmlbuilder/lib/XMLDeclaration.js | 35 +- node_modules/xmlbuilder/lib/XMLDocType.js | 107 +- node_modules/xmlbuilder/lib/XMLDocument.js | 48 + node_modules/xmlbuilder/lib/XMLDocumentCB.js | 402 + node_modules/xmlbuilder/lib/XMLElement.js | 133 +- node_modules/xmlbuilder/lib/XMLNode.js | 189 +- .../lib/XMLProcessingInstruction.js | 42 +- node_modules/xmlbuilder/lib/XMLRaw.js | 27 +- .../xmlbuilder/lib/XMLStreamWriter.js | 279 + .../xmlbuilder/lib/XMLStringWriter.js | 334 + node_modules/xmlbuilder/lib/XMLStringifier.js | 36 +- node_modules/xmlbuilder/lib/XMLText.js | 27 +- node_modules/xmlbuilder/lib/XMLWriterBase.js | 90 + node_modules/xmlbuilder/lib/index.js | 49 +- node_modules/xmlbuilder/package.json | 78 +- package.json | 2 +- 598 files changed, 22108 insertions(+), 37651 deletions(-) delete mode 100644 node_modules/base64-js/.travis.yml rename node_modules/base64-js/{LICENSE.MIT => LICENSE} (100%) create mode 100644 node_modules/base64-js/base64js.min.js delete mode 100644 node_modules/base64-js/bench/bench.js create mode 100644 node_modules/base64-js/index.js delete mode 100644 node_modules/base64-js/lib/b64.js create mode 100644 node_modules/base64-js/test/big-data.js create mode 100644 node_modules/base64-js/test/corrupt.js create mode 100644 node_modules/cordova-common/.github/PULL_REQUEST_TEMPLATE.md delete mode 100644 node_modules/cordova-common/.jscs.json create mode 120000 node_modules/cordova-common/node_modules/.bin/shjs create mode 100644 node_modules/cordova-common/node_modules/elementtree/.npmignore create mode 100644 node_modules/cordova-common/node_modules/elementtree/.travis.yml create mode 100644 node_modules/cordova-common/node_modules/elementtree/CHANGES.md create mode 100644 node_modules/cordova-common/node_modules/elementtree/LICENSE.txt create mode 100755 node_modules/cordova-common/node_modules/elementtree/Makefile create mode 100644 node_modules/cordova-common/node_modules/elementtree/NOTICE create mode 100644 node_modules/cordova-common/node_modules/elementtree/README.md create mode 100644 node_modules/cordova-common/node_modules/elementtree/lib/constants.js create mode 100644 node_modules/cordova-common/node_modules/elementtree/lib/elementpath.js create mode 100644 node_modules/cordova-common/node_modules/elementtree/lib/elementtree.js create mode 100644 node_modules/cordova-common/node_modules/elementtree/lib/errors.js create mode 100644 node_modules/cordova-common/node_modules/elementtree/lib/parser.js create mode 100644 node_modules/cordova-common/node_modules/elementtree/lib/parsers/index.js create mode 100644 node_modules/cordova-common/node_modules/elementtree/lib/parsers/sax.js create mode 100644 node_modules/cordova-common/node_modules/elementtree/lib/sprintf.js create mode 100644 node_modules/cordova-common/node_modules/elementtree/lib/treebuilder.js create mode 100644 node_modules/cordova-common/node_modules/elementtree/lib/utils.js create mode 100644 node_modules/cordova-common/node_modules/elementtree/package.json create mode 100644 node_modules/cordova-common/node_modules/elementtree/tests/data/bom-xml.xml create mode 100644 node_modules/cordova-common/node_modules/elementtree/tests/data/xml1.xml create mode 100644 node_modules/cordova-common/node_modules/elementtree/tests/data/xml2.xml create mode 100644 node_modules/cordova-common/node_modules/elementtree/tests/test-simple.js rename node_modules/{osenv => cordova-common/node_modules/glob}/LICENSE (100%) create mode 100644 node_modules/cordova-common/node_modules/glob/README.md create mode 100644 node_modules/cordova-common/node_modules/glob/changelog.md create mode 100644 node_modules/cordova-common/node_modules/glob/common.js create mode 100644 node_modules/cordova-common/node_modules/glob/glob.js create mode 100644 node_modules/cordova-common/node_modules/glob/package.json create mode 100644 node_modules/cordova-common/node_modules/glob/sync.js create mode 100644 node_modules/cordova-common/node_modules/sax/LICENSE create mode 100644 node_modules/cordova-common/node_modules/sax/LICENSE-W3C.html create mode 100644 node_modules/cordova-common/node_modules/sax/README.md create mode 100644 node_modules/cordova-common/node_modules/sax/lib/sax.js create mode 100644 node_modules/cordova-common/node_modules/sax/package.json create mode 100644 node_modules/cordova-common/node_modules/shelljs/CHANGELOG.md create mode 100644 node_modules/cordova-common/node_modules/shelljs/LICENSE create mode 100644 node_modules/cordova-common/node_modules/shelljs/README.md create mode 100755 node_modules/cordova-common/node_modules/shelljs/bin/shjs create mode 100644 node_modules/cordova-common/node_modules/shelljs/commands.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/global.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/make.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/package.json create mode 100644 node_modules/cordova-common/node_modules/shelljs/plugin.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/shell.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/cat.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/cd.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/chmod.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/common.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/cp.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/dirs.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/echo.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/error.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/exec-child.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/exec.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/find.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/grep.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/head.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/ln.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/ls.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/mkdir.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/mv.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/popd.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/pushd.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/pwd.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/rm.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/sed.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/set.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/sort.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/tail.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/tempdir.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/test.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/to.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/toEnd.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/touch.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/uniq.js create mode 100644 node_modules/cordova-common/node_modules/shelljs/src/which.js delete mode 100644 node_modules/cordova-common/src/ConfigParser/README.md create mode 100644 node_modules/fs.realpath/LICENSE create mode 100644 node_modules/fs.realpath/README.md create mode 100644 node_modules/fs.realpath/index.js create mode 100644 node_modules/fs.realpath/old.js create mode 100644 node_modules/fs.realpath/package.json delete mode 100644 node_modules/lodash/LICENSE delete mode 100644 node_modules/lodash/README.md delete mode 100644 node_modules/lodash/array.js delete mode 100644 node_modules/lodash/array/chunk.js delete mode 100644 node_modules/lodash/array/compact.js delete mode 100644 node_modules/lodash/array/difference.js delete mode 100644 node_modules/lodash/array/drop.js delete mode 100644 node_modules/lodash/array/dropRight.js delete mode 100644 node_modules/lodash/array/dropRightWhile.js delete mode 100644 node_modules/lodash/array/dropWhile.js delete mode 100644 node_modules/lodash/array/fill.js delete mode 100644 node_modules/lodash/array/findIndex.js delete mode 100644 node_modules/lodash/array/findLastIndex.js delete mode 100644 node_modules/lodash/array/first.js delete mode 100644 node_modules/lodash/array/flatten.js delete mode 100644 node_modules/lodash/array/flattenDeep.js delete mode 100644 node_modules/lodash/array/head.js delete mode 100644 node_modules/lodash/array/indexOf.js delete mode 100644 node_modules/lodash/array/initial.js delete mode 100644 node_modules/lodash/array/intersection.js delete mode 100644 node_modules/lodash/array/last.js delete mode 100644 node_modules/lodash/array/lastIndexOf.js delete mode 100644 node_modules/lodash/array/object.js delete mode 100644 node_modules/lodash/array/pull.js delete mode 100644 node_modules/lodash/array/pullAt.js delete mode 100644 node_modules/lodash/array/remove.js delete mode 100644 node_modules/lodash/array/rest.js delete mode 100644 node_modules/lodash/array/slice.js delete mode 100644 node_modules/lodash/array/sortedIndex.js delete mode 100644 node_modules/lodash/array/sortedLastIndex.js delete mode 100644 node_modules/lodash/array/tail.js delete mode 100644 node_modules/lodash/array/take.js delete mode 100644 node_modules/lodash/array/takeRight.js delete mode 100644 node_modules/lodash/array/takeRightWhile.js delete mode 100644 node_modules/lodash/array/takeWhile.js delete mode 100644 node_modules/lodash/array/union.js delete mode 100644 node_modules/lodash/array/uniq.js delete mode 100644 node_modules/lodash/array/unique.js delete mode 100644 node_modules/lodash/array/unzip.js delete mode 100644 node_modules/lodash/array/unzipWith.js delete mode 100644 node_modules/lodash/array/without.js delete mode 100644 node_modules/lodash/array/xor.js delete mode 100644 node_modules/lodash/array/zip.js delete mode 100644 node_modules/lodash/array/zipObject.js delete mode 100644 node_modules/lodash/array/zipWith.js delete mode 100644 node_modules/lodash/chain.js delete mode 100644 node_modules/lodash/chain/chain.js delete mode 100644 node_modules/lodash/chain/commit.js delete mode 100644 node_modules/lodash/chain/concat.js delete mode 100644 node_modules/lodash/chain/lodash.js delete mode 100644 node_modules/lodash/chain/plant.js delete mode 100644 node_modules/lodash/chain/reverse.js delete mode 100644 node_modules/lodash/chain/run.js delete mode 100644 node_modules/lodash/chain/tap.js delete mode 100644 node_modules/lodash/chain/thru.js delete mode 100644 node_modules/lodash/chain/toJSON.js delete mode 100644 node_modules/lodash/chain/toString.js delete mode 100644 node_modules/lodash/chain/value.js delete mode 100644 node_modules/lodash/chain/valueOf.js delete mode 100644 node_modules/lodash/chain/wrapperChain.js delete mode 100644 node_modules/lodash/chain/wrapperCommit.js delete mode 100644 node_modules/lodash/chain/wrapperConcat.js delete mode 100644 node_modules/lodash/chain/wrapperPlant.js delete mode 100644 node_modules/lodash/chain/wrapperReverse.js delete mode 100644 node_modules/lodash/chain/wrapperToString.js delete mode 100644 node_modules/lodash/chain/wrapperValue.js delete mode 100644 node_modules/lodash/collection.js delete mode 100644 node_modules/lodash/collection/all.js delete mode 100644 node_modules/lodash/collection/any.js delete mode 100644 node_modules/lodash/collection/at.js delete mode 100644 node_modules/lodash/collection/collect.js delete mode 100644 node_modules/lodash/collection/contains.js delete mode 100644 node_modules/lodash/collection/countBy.js delete mode 100644 node_modules/lodash/collection/detect.js delete mode 100644 node_modules/lodash/collection/each.js delete mode 100644 node_modules/lodash/collection/eachRight.js delete mode 100644 node_modules/lodash/collection/every.js delete mode 100644 node_modules/lodash/collection/filter.js delete mode 100644 node_modules/lodash/collection/find.js delete mode 100644 node_modules/lodash/collection/findLast.js delete mode 100644 node_modules/lodash/collection/findWhere.js delete mode 100644 node_modules/lodash/collection/foldl.js delete mode 100644 node_modules/lodash/collection/foldr.js delete mode 100644 node_modules/lodash/collection/forEach.js delete mode 100644 node_modules/lodash/collection/forEachRight.js delete mode 100644 node_modules/lodash/collection/groupBy.js delete mode 100644 node_modules/lodash/collection/include.js delete mode 100644 node_modules/lodash/collection/includes.js delete mode 100644 node_modules/lodash/collection/indexBy.js delete mode 100644 node_modules/lodash/collection/inject.js delete mode 100644 node_modules/lodash/collection/invoke.js delete mode 100644 node_modules/lodash/collection/map.js delete mode 100644 node_modules/lodash/collection/max.js delete mode 100644 node_modules/lodash/collection/min.js delete mode 100644 node_modules/lodash/collection/partition.js delete mode 100644 node_modules/lodash/collection/pluck.js delete mode 100644 node_modules/lodash/collection/reduce.js delete mode 100644 node_modules/lodash/collection/reduceRight.js delete mode 100644 node_modules/lodash/collection/reject.js delete mode 100644 node_modules/lodash/collection/sample.js delete mode 100644 node_modules/lodash/collection/select.js delete mode 100644 node_modules/lodash/collection/shuffle.js delete mode 100644 node_modules/lodash/collection/size.js delete mode 100644 node_modules/lodash/collection/some.js delete mode 100644 node_modules/lodash/collection/sortBy.js delete mode 100644 node_modules/lodash/collection/sortByAll.js delete mode 100644 node_modules/lodash/collection/sortByOrder.js delete mode 100644 node_modules/lodash/collection/sum.js delete mode 100644 node_modules/lodash/collection/where.js delete mode 100644 node_modules/lodash/date.js delete mode 100644 node_modules/lodash/date/now.js delete mode 100644 node_modules/lodash/function.js delete mode 100644 node_modules/lodash/function/after.js delete mode 100644 node_modules/lodash/function/ary.js delete mode 100644 node_modules/lodash/function/backflow.js delete mode 100644 node_modules/lodash/function/before.js delete mode 100644 node_modules/lodash/function/bind.js delete mode 100644 node_modules/lodash/function/bindAll.js delete mode 100644 node_modules/lodash/function/bindKey.js delete mode 100644 node_modules/lodash/function/compose.js delete mode 100644 node_modules/lodash/function/curry.js delete mode 100644 node_modules/lodash/function/curryRight.js delete mode 100644 node_modules/lodash/function/debounce.js delete mode 100644 node_modules/lodash/function/defer.js delete mode 100644 node_modules/lodash/function/delay.js delete mode 100644 node_modules/lodash/function/flow.js delete mode 100644 node_modules/lodash/function/flowRight.js delete mode 100644 node_modules/lodash/function/memoize.js delete mode 100644 node_modules/lodash/function/modArgs.js delete mode 100644 node_modules/lodash/function/negate.js delete mode 100644 node_modules/lodash/function/once.js delete mode 100644 node_modules/lodash/function/partial.js delete mode 100644 node_modules/lodash/function/partialRight.js delete mode 100644 node_modules/lodash/function/rearg.js delete mode 100644 node_modules/lodash/function/restParam.js delete mode 100644 node_modules/lodash/function/spread.js delete mode 100644 node_modules/lodash/function/throttle.js delete mode 100644 node_modules/lodash/function/wrap.js delete mode 100644 node_modules/lodash/index.js delete mode 100644 node_modules/lodash/internal/LazyWrapper.js delete mode 100644 node_modules/lodash/internal/LodashWrapper.js delete mode 100644 node_modules/lodash/internal/MapCache.js delete mode 100644 node_modules/lodash/internal/SetCache.js delete mode 100644 node_modules/lodash/internal/arrayConcat.js delete mode 100644 node_modules/lodash/internal/arrayCopy.js delete mode 100644 node_modules/lodash/internal/arrayEach.js delete mode 100644 node_modules/lodash/internal/arrayEachRight.js delete mode 100644 node_modules/lodash/internal/arrayEvery.js delete mode 100644 node_modules/lodash/internal/arrayExtremum.js delete mode 100644 node_modules/lodash/internal/arrayFilter.js delete mode 100644 node_modules/lodash/internal/arrayMap.js delete mode 100644 node_modules/lodash/internal/arrayPush.js delete mode 100644 node_modules/lodash/internal/arrayReduce.js delete mode 100644 node_modules/lodash/internal/arrayReduceRight.js delete mode 100644 node_modules/lodash/internal/arraySome.js delete mode 100644 node_modules/lodash/internal/arraySum.js delete mode 100644 node_modules/lodash/internal/assignDefaults.js delete mode 100644 node_modules/lodash/internal/assignOwnDefaults.js delete mode 100644 node_modules/lodash/internal/assignWith.js delete mode 100644 node_modules/lodash/internal/baseAssign.js delete mode 100644 node_modules/lodash/internal/baseAt.js delete mode 100644 node_modules/lodash/internal/baseCallback.js delete mode 100644 node_modules/lodash/internal/baseClone.js delete mode 100644 node_modules/lodash/internal/baseCompareAscending.js delete mode 100644 node_modules/lodash/internal/baseCopy.js delete mode 100644 node_modules/lodash/internal/baseCreate.js delete mode 100644 node_modules/lodash/internal/baseDelay.js delete mode 100644 node_modules/lodash/internal/baseDifference.js delete mode 100644 node_modules/lodash/internal/baseEach.js delete mode 100644 node_modules/lodash/internal/baseEachRight.js delete mode 100644 node_modules/lodash/internal/baseEvery.js delete mode 100644 node_modules/lodash/internal/baseExtremum.js delete mode 100644 node_modules/lodash/internal/baseFill.js delete mode 100644 node_modules/lodash/internal/baseFilter.js delete mode 100644 node_modules/lodash/internal/baseFind.js delete mode 100644 node_modules/lodash/internal/baseFindIndex.js delete mode 100644 node_modules/lodash/internal/baseFlatten.js delete mode 100644 node_modules/lodash/internal/baseFor.js delete mode 100644 node_modules/lodash/internal/baseForIn.js delete mode 100644 node_modules/lodash/internal/baseForOwn.js delete mode 100644 node_modules/lodash/internal/baseForOwnRight.js delete mode 100644 node_modules/lodash/internal/baseForRight.js delete mode 100644 node_modules/lodash/internal/baseFunctions.js delete mode 100644 node_modules/lodash/internal/baseGet.js delete mode 100644 node_modules/lodash/internal/baseIndexOf.js delete mode 100644 node_modules/lodash/internal/baseIsEqual.js delete mode 100644 node_modules/lodash/internal/baseIsEqualDeep.js delete mode 100644 node_modules/lodash/internal/baseIsFunction.js delete mode 100644 node_modules/lodash/internal/baseIsMatch.js delete mode 100644 node_modules/lodash/internal/baseLodash.js delete mode 100644 node_modules/lodash/internal/baseMap.js delete mode 100644 node_modules/lodash/internal/baseMatches.js delete mode 100644 node_modules/lodash/internal/baseMatchesProperty.js delete mode 100644 node_modules/lodash/internal/baseMerge.js delete mode 100644 node_modules/lodash/internal/baseMergeDeep.js delete mode 100644 node_modules/lodash/internal/baseProperty.js delete mode 100644 node_modules/lodash/internal/basePropertyDeep.js delete mode 100644 node_modules/lodash/internal/basePullAt.js delete mode 100644 node_modules/lodash/internal/baseRandom.js delete mode 100644 node_modules/lodash/internal/baseReduce.js delete mode 100644 node_modules/lodash/internal/baseSetData.js delete mode 100644 node_modules/lodash/internal/baseSlice.js delete mode 100644 node_modules/lodash/internal/baseSome.js delete mode 100644 node_modules/lodash/internal/baseSortBy.js delete mode 100644 node_modules/lodash/internal/baseSortByOrder.js delete mode 100644 node_modules/lodash/internal/baseSum.js delete mode 100644 node_modules/lodash/internal/baseToString.js delete mode 100644 node_modules/lodash/internal/baseUniq.js delete mode 100644 node_modules/lodash/internal/baseValues.js delete mode 100644 node_modules/lodash/internal/baseWhile.js delete mode 100644 node_modules/lodash/internal/baseWrapperValue.js delete mode 100644 node_modules/lodash/internal/binaryIndex.js delete mode 100644 node_modules/lodash/internal/binaryIndexBy.js delete mode 100644 node_modules/lodash/internal/bindCallback.js delete mode 100644 node_modules/lodash/internal/bufferClone.js delete mode 100644 node_modules/lodash/internal/cacheIndexOf.js delete mode 100644 node_modules/lodash/internal/cachePush.js delete mode 100644 node_modules/lodash/internal/charsLeftIndex.js delete mode 100644 node_modules/lodash/internal/charsRightIndex.js delete mode 100644 node_modules/lodash/internal/compareAscending.js delete mode 100644 node_modules/lodash/internal/compareMultiple.js delete mode 100644 node_modules/lodash/internal/composeArgs.js delete mode 100644 node_modules/lodash/internal/composeArgsRight.js delete mode 100644 node_modules/lodash/internal/createAggregator.js delete mode 100644 node_modules/lodash/internal/createAssigner.js delete mode 100644 node_modules/lodash/internal/createBaseEach.js delete mode 100644 node_modules/lodash/internal/createBaseFor.js delete mode 100644 node_modules/lodash/internal/createBindWrapper.js delete mode 100644 node_modules/lodash/internal/createCache.js delete mode 100644 node_modules/lodash/internal/createCompounder.js delete mode 100644 node_modules/lodash/internal/createCtorWrapper.js delete mode 100644 node_modules/lodash/internal/createCurry.js delete mode 100644 node_modules/lodash/internal/createDefaults.js delete mode 100644 node_modules/lodash/internal/createExtremum.js delete mode 100644 node_modules/lodash/internal/createFind.js delete mode 100644 node_modules/lodash/internal/createFindIndex.js delete mode 100644 node_modules/lodash/internal/createFindKey.js delete mode 100644 node_modules/lodash/internal/createFlow.js delete mode 100644 node_modules/lodash/internal/createForEach.js delete mode 100644 node_modules/lodash/internal/createForIn.js delete mode 100644 node_modules/lodash/internal/createForOwn.js delete mode 100644 node_modules/lodash/internal/createHybridWrapper.js delete mode 100644 node_modules/lodash/internal/createObjectMapper.js delete mode 100644 node_modules/lodash/internal/createPadDir.js delete mode 100644 node_modules/lodash/internal/createPadding.js delete mode 100644 node_modules/lodash/internal/createPartial.js delete mode 100644 node_modules/lodash/internal/createPartialWrapper.js delete mode 100644 node_modules/lodash/internal/createReduce.js delete mode 100644 node_modules/lodash/internal/createRound.js delete mode 100644 node_modules/lodash/internal/createSortedIndex.js delete mode 100644 node_modules/lodash/internal/createWrapper.js delete mode 100644 node_modules/lodash/internal/deburrLetter.js delete mode 100644 node_modules/lodash/internal/equalArrays.js delete mode 100644 node_modules/lodash/internal/equalByTag.js delete mode 100644 node_modules/lodash/internal/equalObjects.js delete mode 100644 node_modules/lodash/internal/escapeHtmlChar.js delete mode 100644 node_modules/lodash/internal/escapeRegExpChar.js delete mode 100644 node_modules/lodash/internal/escapeStringChar.js delete mode 100644 node_modules/lodash/internal/getData.js delete mode 100644 node_modules/lodash/internal/getFuncName.js delete mode 100644 node_modules/lodash/internal/getLength.js delete mode 100644 node_modules/lodash/internal/getMatchData.js delete mode 100644 node_modules/lodash/internal/getNative.js delete mode 100644 node_modules/lodash/internal/getView.js delete mode 100644 node_modules/lodash/internal/indexOfNaN.js delete mode 100644 node_modules/lodash/internal/initCloneArray.js delete mode 100644 node_modules/lodash/internal/initCloneByTag.js delete mode 100644 node_modules/lodash/internal/initCloneObject.js delete mode 100644 node_modules/lodash/internal/invokePath.js delete mode 100644 node_modules/lodash/internal/isArrayLike.js delete mode 100644 node_modules/lodash/internal/isIndex.js delete mode 100644 node_modules/lodash/internal/isIterateeCall.js delete mode 100644 node_modules/lodash/internal/isKey.js delete mode 100644 node_modules/lodash/internal/isLaziable.js delete mode 100644 node_modules/lodash/internal/isLength.js delete mode 100644 node_modules/lodash/internal/isObjectLike.js delete mode 100644 node_modules/lodash/internal/isSpace.js delete mode 100644 node_modules/lodash/internal/isStrictComparable.js delete mode 100644 node_modules/lodash/internal/lazyClone.js delete mode 100644 node_modules/lodash/internal/lazyReverse.js delete mode 100644 node_modules/lodash/internal/lazyValue.js delete mode 100644 node_modules/lodash/internal/mapDelete.js delete mode 100644 node_modules/lodash/internal/mapGet.js delete mode 100644 node_modules/lodash/internal/mapHas.js delete mode 100644 node_modules/lodash/internal/mapSet.js delete mode 100644 node_modules/lodash/internal/mergeData.js delete mode 100644 node_modules/lodash/internal/mergeDefaults.js delete mode 100644 node_modules/lodash/internal/metaMap.js delete mode 100644 node_modules/lodash/internal/pickByArray.js delete mode 100644 node_modules/lodash/internal/pickByCallback.js delete mode 100644 node_modules/lodash/internal/reEscape.js delete mode 100644 node_modules/lodash/internal/reEvaluate.js delete mode 100644 node_modules/lodash/internal/reInterpolate.js delete mode 100644 node_modules/lodash/internal/realNames.js delete mode 100644 node_modules/lodash/internal/reorder.js delete mode 100644 node_modules/lodash/internal/replaceHolders.js delete mode 100644 node_modules/lodash/internal/setData.js delete mode 100644 node_modules/lodash/internal/shimKeys.js delete mode 100644 node_modules/lodash/internal/sortedUniq.js delete mode 100644 node_modules/lodash/internal/toIterable.js delete mode 100644 node_modules/lodash/internal/toObject.js delete mode 100644 node_modules/lodash/internal/toPath.js delete mode 100644 node_modules/lodash/internal/trimmedLeftIndex.js delete mode 100644 node_modules/lodash/internal/trimmedRightIndex.js delete mode 100644 node_modules/lodash/internal/unescapeHtmlChar.js delete mode 100644 node_modules/lodash/internal/wrapperClone.js delete mode 100644 node_modules/lodash/lang.js delete mode 100644 node_modules/lodash/lang/clone.js delete mode 100644 node_modules/lodash/lang/cloneDeep.js delete mode 100644 node_modules/lodash/lang/eq.js delete mode 100644 node_modules/lodash/lang/gt.js delete mode 100644 node_modules/lodash/lang/gte.js delete mode 100644 node_modules/lodash/lang/isArguments.js delete mode 100644 node_modules/lodash/lang/isArray.js delete mode 100644 node_modules/lodash/lang/isBoolean.js delete mode 100644 node_modules/lodash/lang/isDate.js delete mode 100644 node_modules/lodash/lang/isElement.js delete mode 100644 node_modules/lodash/lang/isEmpty.js delete mode 100644 node_modules/lodash/lang/isEqual.js delete mode 100644 node_modules/lodash/lang/isError.js delete mode 100644 node_modules/lodash/lang/isFinite.js delete mode 100644 node_modules/lodash/lang/isFunction.js delete mode 100644 node_modules/lodash/lang/isMatch.js delete mode 100644 node_modules/lodash/lang/isNaN.js delete mode 100644 node_modules/lodash/lang/isNative.js delete mode 100644 node_modules/lodash/lang/isNull.js delete mode 100644 node_modules/lodash/lang/isNumber.js delete mode 100644 node_modules/lodash/lang/isObject.js delete mode 100644 node_modules/lodash/lang/isPlainObject.js delete mode 100644 node_modules/lodash/lang/isRegExp.js delete mode 100644 node_modules/lodash/lang/isString.js delete mode 100644 node_modules/lodash/lang/isTypedArray.js delete mode 100644 node_modules/lodash/lang/isUndefined.js delete mode 100644 node_modules/lodash/lang/lt.js delete mode 100644 node_modules/lodash/lang/lte.js delete mode 100644 node_modules/lodash/lang/toArray.js delete mode 100644 node_modules/lodash/lang/toPlainObject.js delete mode 100644 node_modules/lodash/math.js delete mode 100644 node_modules/lodash/math/add.js delete mode 100644 node_modules/lodash/math/ceil.js delete mode 100644 node_modules/lodash/math/floor.js delete mode 100644 node_modules/lodash/math/max.js delete mode 100644 node_modules/lodash/math/min.js delete mode 100644 node_modules/lodash/math/round.js delete mode 100644 node_modules/lodash/math/sum.js delete mode 100644 node_modules/lodash/number.js delete mode 100644 node_modules/lodash/number/inRange.js delete mode 100644 node_modules/lodash/number/random.js delete mode 100644 node_modules/lodash/object.js delete mode 100644 node_modules/lodash/object/assign.js delete mode 100644 node_modules/lodash/object/create.js delete mode 100644 node_modules/lodash/object/defaults.js delete mode 100644 node_modules/lodash/object/defaultsDeep.js delete mode 100644 node_modules/lodash/object/extend.js delete mode 100644 node_modules/lodash/object/findKey.js delete mode 100644 node_modules/lodash/object/findLastKey.js delete mode 100644 node_modules/lodash/object/forIn.js delete mode 100644 node_modules/lodash/object/forInRight.js delete mode 100644 node_modules/lodash/object/forOwn.js delete mode 100644 node_modules/lodash/object/forOwnRight.js delete mode 100644 node_modules/lodash/object/functions.js delete mode 100644 node_modules/lodash/object/get.js delete mode 100644 node_modules/lodash/object/has.js delete mode 100644 node_modules/lodash/object/invert.js delete mode 100644 node_modules/lodash/object/keys.js delete mode 100644 node_modules/lodash/object/keysIn.js delete mode 100644 node_modules/lodash/object/mapKeys.js delete mode 100644 node_modules/lodash/object/mapValues.js delete mode 100644 node_modules/lodash/object/merge.js delete mode 100644 node_modules/lodash/object/methods.js delete mode 100644 node_modules/lodash/object/omit.js delete mode 100644 node_modules/lodash/object/pairs.js delete mode 100644 node_modules/lodash/object/pick.js delete mode 100644 node_modules/lodash/object/result.js delete mode 100644 node_modules/lodash/object/set.js delete mode 100644 node_modules/lodash/object/transform.js delete mode 100644 node_modules/lodash/object/values.js delete mode 100644 node_modules/lodash/object/valuesIn.js delete mode 100644 node_modules/lodash/package.json delete mode 100644 node_modules/lodash/string.js delete mode 100644 node_modules/lodash/string/camelCase.js delete mode 100644 node_modules/lodash/string/capitalize.js delete mode 100644 node_modules/lodash/string/deburr.js delete mode 100644 node_modules/lodash/string/endsWith.js delete mode 100644 node_modules/lodash/string/escape.js delete mode 100644 node_modules/lodash/string/escapeRegExp.js delete mode 100644 node_modules/lodash/string/kebabCase.js delete mode 100644 node_modules/lodash/string/pad.js delete mode 100644 node_modules/lodash/string/padLeft.js delete mode 100644 node_modules/lodash/string/padRight.js delete mode 100644 node_modules/lodash/string/parseInt.js delete mode 100644 node_modules/lodash/string/repeat.js delete mode 100644 node_modules/lodash/string/snakeCase.js delete mode 100644 node_modules/lodash/string/startCase.js delete mode 100644 node_modules/lodash/string/startsWith.js delete mode 100644 node_modules/lodash/string/template.js delete mode 100644 node_modules/lodash/string/templateSettings.js delete mode 100644 node_modules/lodash/string/trim.js delete mode 100644 node_modules/lodash/string/trimLeft.js delete mode 100644 node_modules/lodash/string/trimRight.js delete mode 100644 node_modules/lodash/string/trunc.js delete mode 100644 node_modules/lodash/string/unescape.js delete mode 100644 node_modules/lodash/string/words.js delete mode 100644 node_modules/lodash/support.js delete mode 100644 node_modules/lodash/utility.js delete mode 100644 node_modules/lodash/utility/attempt.js delete mode 100644 node_modules/lodash/utility/callback.js delete mode 100644 node_modules/lodash/utility/constant.js delete mode 100644 node_modules/lodash/utility/identity.js delete mode 100644 node_modules/lodash/utility/iteratee.js delete mode 100644 node_modules/lodash/utility/matches.js delete mode 100644 node_modules/lodash/utility/matchesProperty.js delete mode 100644 node_modules/lodash/utility/method.js delete mode 100644 node_modules/lodash/utility/methodOf.js delete mode 100644 node_modules/lodash/utility/mixin.js delete mode 100644 node_modules/lodash/utility/noop.js delete mode 100644 node_modules/lodash/utility/property.js delete mode 100644 node_modules/lodash/utility/propertyOf.js delete mode 100644 node_modules/lodash/utility/range.js delete mode 100644 node_modules/lodash/utility/times.js delete mode 100644 node_modules/lodash/utility/uniqueId.js delete mode 100644 node_modules/os-tmpdir/index.js delete mode 100644 node_modules/os-tmpdir/package.json delete mode 100644 node_modules/os-tmpdir/readme.md delete mode 100644 node_modules/osenv/README.md delete mode 100644 node_modules/osenv/osenv.js delete mode 100644 node_modules/osenv/package.json create mode 100644 node_modules/plist/index.js delete mode 100644 node_modules/plist/lib/node.js delete mode 100644 node_modules/plist/lib/plist.js create mode 100644 node_modules/strip-bom/index.js rename node_modules/{os-tmpdir => strip-bom}/license (100%) create mode 100644 node_modules/strip-bom/package.json create mode 100644 node_modules/strip-bom/readme.md create mode 100644 node_modules/underscore/underscore-min.js.map delete mode 100644 node_modules/underscore/underscore-min.map delete mode 100644 node_modules/unorm/LICENSE.md delete mode 100644 node_modules/unorm/README.md delete mode 100644 node_modules/unorm/lib/unorm.js delete mode 100644 node_modules/unorm/package.json create mode 100644 node_modules/xmlbuilder/CHANGELOG.md create mode 100644 node_modules/xmlbuilder/lib/Utility.js delete mode 100644 node_modules/xmlbuilder/lib/XMLBuilder.js create mode 100644 node_modules/xmlbuilder/lib/XMLDocument.js create mode 100644 node_modules/xmlbuilder/lib/XMLDocumentCB.js create mode 100644 node_modules/xmlbuilder/lib/XMLStreamWriter.js create mode 100644 node_modules/xmlbuilder/lib/XMLStringWriter.js create mode 100644 node_modules/xmlbuilder/lib/XMLWriterBase.js diff --git a/.gitignore b/.gitignore index 7560a1223f..c3eaa31ee6 100644 --- a/.gitignore +++ b/.gitignore @@ -131,4 +131,3 @@ node_modules/window-size/ node_modules/wordwrap/ node_modules/yargs/ node_modules/jasmine-core/ -node_modules/fs.realpath/ diff --git a/node_modules/base64-js/.travis.yml b/node_modules/base64-js/.travis.yml deleted file mode 100644 index 939cb517c3..0000000000 --- a/node_modules/base64-js/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: node_js -node_js: - - "0.8" - - "0.10" - - "0.11" \ No newline at end of file diff --git a/node_modules/base64-js/LICENSE.MIT b/node_modules/base64-js/LICENSE similarity index 100% rename from node_modules/base64-js/LICENSE.MIT rename to node_modules/base64-js/LICENSE diff --git a/node_modules/base64-js/README.md b/node_modules/base64-js/README.md index ed31d1ab5f..753251178c 100644 --- a/node_modules/base64-js/README.md +++ b/node_modules/base64-js/README.md @@ -15,17 +15,20 @@ Sometimes encoding/decoding binary data in the browser is useful, and that is wh With [npm](https://npmjs.org) do: -`npm install base64-js` +`npm install base64-js` and `var base64js = require('base64-js')` -## methods +For use in web browsers do: + +`` -`var base64 = require('base64-js')` +## methods -`base64` has two exposed functions, `toByteArray` and `fromByteArray`, which both take a single argument. +`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 \ No newline at end of file +MIT diff --git a/node_modules/base64-js/base64js.min.js b/node_modules/base64-js/base64js.min.js new file mode 100644 index 0000000000..0c621d355c --- /dev/null +++ b/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;f0){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>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;au?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/node_modules/base64-js/bench/bench.js b/node_modules/base64-js/bench/bench.js deleted file mode 100644 index 0689e08a46..0000000000 --- a/node_modules/base64-js/bench/bench.js +++ /dev/null @@ -1,19 +0,0 @@ -var random = require('crypto').pseudoRandomBytes - -var b64 = require('../') -var fs = require('fs') -var path = require('path') -var data = random(1e6).toString('base64') -//fs.readFileSync(path.join(__dirname, 'example.b64'), 'ascii').split('\n').join('') -var start = Date.now() -var raw = b64.toByteArray(data) -var middle = Date.now() -var data = b64.fromByteArray(raw) -var end = Date.now() - -console.log('decode ms, decode ops/ms, encode ms, encode ops/ms') -console.log( - middle - start, data.length / (middle - start), - end - middle, data.length / (end - middle)) -//console.log(data) - diff --git a/node_modules/base64-js/index.js b/node_modules/base64-js/index.js new file mode 100644 index 0000000000..44c67664c1 --- /dev/null +++ b/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/node_modules/base64-js/lib/b64.js b/node_modules/base64-js/lib/b64.js deleted file mode 100644 index 46001d2f16..0000000000 --- a/node_modules/base64-js/lib/b64.js +++ /dev/null @@ -1,124 +0,0 @@ -var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - -;(function (exports) { - 'use strict'; - - var Arr = (typeof Uint8Array !== 'undefined') - ? Uint8Array - : Array - - var PLUS = '+'.charCodeAt(0) - var SLASH = '/'.charCodeAt(0) - var NUMBER = '0'.charCodeAt(0) - var LOWER = 'a'.charCodeAt(0) - var UPPER = 'A'.charCodeAt(0) - var PLUS_URL_SAFE = '-'.charCodeAt(0) - var SLASH_URL_SAFE = '_'.charCodeAt(0) - - function decode (elt) { - var code = elt.charCodeAt(0) - if (code === PLUS || - code === PLUS_URL_SAFE) - return 62 // '+' - if (code === SLASH || - code === SLASH_URL_SAFE) - return 63 // '/' - if (code < NUMBER) - return -1 //no match - if (code < NUMBER + 10) - return code - NUMBER + 26 + 26 - if (code < UPPER + 26) - return code - UPPER - if (code < LOWER + 26) - return code - LOWER + 26 - } - - function b64ToByteArray (b64) { - var i, j, l, tmp, placeHolders, arr - - if (b64.length % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - var len = b64.length - placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 - - // base64 is 4/3 + up to two characters of the original data - arr = new Arr(b64.length * 3 / 4 - placeHolders) - - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? b64.length - 4 : b64.length - - var L = 0 - - function push (v) { - arr[L++] = v - } - - for (i = 0, j = 0; i < l; i += 4, j += 3) { - tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) - push((tmp & 0xFF0000) >> 16) - push((tmp & 0xFF00) >> 8) - push(tmp & 0xFF) - } - - if (placeHolders === 2) { - tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) - push(tmp & 0xFF) - } else if (placeHolders === 1) { - tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) - push((tmp >> 8) & 0xFF) - push(tmp & 0xFF) - } - - return arr - } - - function uint8ToBase64 (uint8) { - var i, - extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes - output = "", - temp, length - - function encode (num) { - return lookup.charAt(num) - } - - function tripletToBase64 (num) { - return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) - } - - // go through the array every three bytes, we'll deal with trailing stuff later - for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { - temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) - output += tripletToBase64(temp) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - switch (extraBytes) { - case 1: - temp = uint8[uint8.length - 1] - output += encode(temp >> 2) - output += encode((temp << 4) & 0x3F) - output += '==' - break - case 2: - temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) - output += encode(temp >> 10) - output += encode((temp >> 4) & 0x3F) - output += encode((temp << 2) & 0x3F) - output += '=' - break - } - - return output - } - - exports.toByteArray = b64ToByteArray - exports.fromByteArray = uint8ToBase64 -}(typeof exports === 'undefined' ? (this.base64js = {}) : exports)) diff --git a/node_modules/base64-js/package.json b/node_modules/base64-js/package.json index 1d472547bc..697ffacf7b 100644 --- a/node_modules/base64-js/package.json +++ b/node_modules/base64-js/package.json @@ -1,46 +1,27 @@ { - "_args": [ - [ - { - "raw": "base64-js@0.0.8", - "scope": null, - "escapedName": "base64-js", - "name": "base64-js", - "rawSpec": "0.0.8", - "spec": "0.0.8", - "type": "version" - }, - "/Users/steveng/repo/cordova/cordova-android/node_modules/plist" - ] - ], - "_from": "base64-js@0.0.8", - "_id": "base64-js@0.0.8", - "_inCache": true, + "_from": "base64-js@^1.2.3", + "_id": "base64-js@1.3.0", + "_inBundle": false, + "_integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==", "_location": "/base64-js", - "_nodeVersion": "0.10.35", - "_npmUser": { - "name": "feross", - "email": "feross@feross.org" - }, - "_npmVersion": "2.1.16", "_phantomChildren": {}, "_requested": { - "raw": "base64-js@0.0.8", - "scope": null, - "escapedName": "base64-js", + "type": "range", + "registry": true, + "raw": "base64-js@^1.2.3", "name": "base64-js", - "rawSpec": "0.0.8", - "spec": "0.0.8", - "type": "version" + "escapedName": "base64-js", + "rawSpec": "^1.2.3", + "saveSpec": null, + "fetchSpec": "^1.2.3" }, "_requiredBy": [ "/plist" ], - "_resolved": "https://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz", - "_shasum": "1101e9544f4a76b1bc3b26d452ca96d7a35e7978", - "_shrinkwrap": null, - "_spec": "base64-js@0.0.8", - "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/plist", + "_resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", + "_shasum": "cab1e6118f051095e58b5281aea8c1cd22bfc0e3", + "_spec": "base64-js@^1.2.3", + "_where": "/Users/brodybits/Documents/cbwork/cordova-android/node_modules/plist", "author": { "name": "T. Jameson Little", "email": "t.jameson.little@gmail.com" @@ -48,54 +29,37 @@ "bugs": { "url": "https://github.com/beatgammit/base64-js/issues" }, - "dependencies": {}, + "bundleDependencies": false, + "deprecated": false, "description": "Base64 encoding/decoding in pure JS", "devDependencies": { - "tape": "~2.3.2" - }, - "directories": {}, - "dist": { - "shasum": "1101e9544f4a76b1bc3b26d452ca96d7a35e7978", - "tarball": "https://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz" + "benchmark": "^2.1.4", + "browserify": "^14.0.0", + "standard": "*", + "tape": "4.x", + "uglify-js": "^2.8.29" }, - "engines": { - "node": ">= 0.4" - }, - "gitHead": "b4a8a5fa9b0caeddb5ad94dd1108253d8f2a315f", + "files": [ + "test", + "index.js", + "base64js.min.js" + ], "homepage": "https://github.com/beatgammit/base64-js", - "license": "MIT", - "main": "lib/b64.js", - "maintainers": [ - { - "name": "beatgammit", - "email": "t.jameson.little@gmail.com" - }, - { - "name": "feross", - "email": "feross@feross.org" - } + "keywords": [ + "base64" ], + "license": "MIT", + "main": "index.js", "name": "base64-js", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", "repository": { "type": "git", "url": "git://github.com/beatgammit/base64-js.git" }, "scripts": { - "test": "tape test/*.js" - }, - "testling": { - "files": "test/*.js", - "browsers": [ - "ie/6..latest", - "chrome/4..latest", - "firefox/3..latest", - "safari/5.1..latest", - "opera/11.0..latest", - "iphone/6", - "ipad/6" - ] + "build": "browserify -s base64js -r ./ | uglifyjs -m > base64js.min.js", + "lint": "standard", + "test": "npm run lint && npm run unit", + "unit": "tape test/*.js" }, - "version": "0.0.8" + "version": "1.3.0" } diff --git a/node_modules/base64-js/test/big-data.js b/node_modules/base64-js/test/big-data.js new file mode 100644 index 0000000000..107e09ecf2 --- /dev/null +++ b/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/node_modules/base64-js/test/convert.js b/node_modules/base64-js/test/convert.js index 60b09c0110..017a13322b 100644 --- a/node_modules/base64-js/test/convert.js +++ b/node_modules/base64-js/test/convert.js @@ -1,51 +1,88 @@ -var test = require('tape'), - b64 = require('../lib/b64'), - checks = [ - 'a', - 'aa', - 'aaa', - 'hi', - 'hi!', - 'hi!!', - 'sup', - 'sup?', - 'sup?!' - ]; +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); + t.plan(checks.length * 2) for (var i = 0; i < checks.length; i++) { - var check = checks[i], - b64Str, - arr, - str; + var check = checks[i] + var b64Str, arr, str - b64Str = b64.fromByteArray(map(check, function (char) { return char.charCodeAt(0); })); + 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(''); + arr = b64.toByteArray(b64Str) + str = map(arr, function (byte) { return String.fromCharCode(byte) }).join('') - t.equal(check, str, 'Checked ' + check); + 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 = [], - 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; + 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/node_modules/base64-js/test/corrupt.js b/node_modules/base64-js/test/corrupt.js new file mode 100644 index 0000000000..44c6e719a0 --- /dev/null +++ b/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/node_modules/base64-js/test/url-safe.js b/node_modules/base64-js/test/url-safe.js index dc437e96c2..4382e06c67 100644 --- a/node_modules/base64-js/test/url-safe.js +++ b/node_modules/base64-js/test/url-safe.js @@ -1,18 +1,24 @@ -var test = require('tape'), - b64 = require('../lib/b64'); +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 expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff] - var actual = b64.toByteArray('//++/++/++//'); + var str = '//++/++/++//' + var actual = b64.toByteArray(str) for (var i = 0; i < actual.length; i++) { t.equal(actual[i], expected[i]) } - actual = b64.toByteArray('__--_--_--__'); - for (var i = 0; i < actual.length; 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.end(); -}); + + t.equal(b64.byteLength(str), actual.length) + + t.end() +}) diff --git a/node_modules/big-integer/BigInteger.d.ts b/node_modules/big-integer/BigInteger.d.ts index d70e401bf7..a367aa1d38 100644 --- a/node_modules/big-integer/BigInteger.d.ts +++ b/node_modules/big-integer/BigInteger.d.ts @@ -100,6 +100,11 @@ declare namespace bigInt { */ and(number: BigNumber): BigInteger; + /** + * Returns the number of digits required to represent a bigInt in binary. + */ + bitLength(): BigInteger; + /** * Performs a comparison between two numbers. If the numbers are equal, it returns 0. * If the first number is greater, it returns 1. If the first number is lesser, it returns -1. @@ -337,6 +342,12 @@ declare namespace bigInt { */ times(number: BigNumber): BigInteger; + /** + * + * Converts a bigInt to an object representing it as an array of integers module the given radix. + */ + toArray(radix: number): BaseArray; + /** * Converts a bigInt into a native Javascript number. Loses precision for numbers outside the range. */ @@ -2366,4 +2377,9 @@ declare namespace bigInt { '998': BigInteger; '999': BigInteger; } + + interface BaseArray { + value: number[], + isNegative: boolean + } } diff --git a/node_modules/big-integer/BigInteger.js b/node_modules/big-integer/BigInteger.js index 9a65a5f48b..697e9c8230 100644 --- a/node_modules/big-integer/BigInteger.js +++ b/node_modules/big-integer/BigInteger.js @@ -179,7 +179,7 @@ var bigInt = (function (undefined) { function subtractAny(a, b, sign) { var value; if (compareAbs(a, b) >= 0) { - value = subtract(a,b); + value = subtract(a, b); } else { value = subtract(b, a); sign = !sign; @@ -354,16 +354,16 @@ var bigInt = (function (undefined) { return new BigInteger(multiplyLong(b, smallToArray(a)), sign); } SmallInteger.prototype._multiplyBySmall = function (a) { - if (isPrecise(a.value * this.value)) { - return new SmallInteger(a.value * this.value); - } - return multiplySmallAndArray(Math.abs(a.value), smallToArray(Math.abs(this.value)), this.sign !== a.sign); + if (isPrecise(a.value * this.value)) { + return new SmallInteger(a.value * this.value); + } + return multiplySmallAndArray(Math.abs(a.value), smallToArray(Math.abs(this.value)), this.sign !== a.sign); }; BigInteger.prototype._multiplyBySmall = function (a) { - if (a.value === 0) return Integer[0]; - if (a.value === 1) return this; - if (a.value === -1) return this.negate(); - return multiplySmallAndArray(Math.abs(a.value), this.value, this.sign !== a.sign); + if (a.value === 0) return Integer[0]; + if (a.value === 1) return this; + if (a.value === -1) return this.negate(); + return multiplySmallAndArray(Math.abs(a.value), this.value, this.sign !== a.sign); }; SmallInteger.prototype.multiply = function (v) { return parseValue(v)._multiplyBySmall(this); @@ -416,7 +416,7 @@ var bigInt = (function (undefined) { for (shift = a_l - b_l; shift >= 0; shift--) { quotientDigit = base - 1; if (remainder[shift + b_l] !== divisorMostSignificantDigit) { - quotientDigit = Math.floor((remainder[shift + b_l] * base + remainder[shift + b_l - 1]) / divisorMostSignificantDigit); + quotientDigit = Math.floor((remainder[shift + b_l] * base + remainder[shift + b_l - 1]) / divisorMostSignificantDigit); } // quotientDigit <= base - 1 carry = 0; @@ -799,7 +799,7 @@ var bigInt = (function (undefined) { for (i = 0; i < a.length; i++) { x = bigInt(a[i]).modPow(b, n); if (x.equals(Integer[1]) || x.equals(nPrev)) continue; - for (t = true, d = b; t && d.lesser(nPrev) ; d = d.multiply(2)) { + for (t = true, d = b; t && d.lesser(nPrev); d = d.multiply(2)) { x = x.square().mod(n); if (x.equals(nPrev)) t = false; } @@ -975,6 +975,29 @@ var bigInt = (function (undefined) { return x & -x; } + function integerLogarithm(value, base) { + if (base.compareTo(value) <= 0) { + var tmp = integerLogarithm(value, base.square(base)); + var p = tmp.p; + var e = tmp.e; + var t = p.multiply(base); + return t.compareTo(value) <= 0 ? { p: t, e: e * 2 + 1 } : { p: p, e: e * 2 }; + } + return { p: bigInt(1), e: 0 }; + } + + BigInteger.prototype.bitLength = function () { + var n = this; + if (n.compareTo(bigInt(0)) < 0) { + n = n.negate().subtract(bigInt(1)); + } + if (n.compareTo(bigInt(0)) === 0) { + return bigInt(0); + } + return bigInt(integerLogarithm(n, bigInt(2)).e).add(bigInt(1)); + } + SmallInteger.prototype.bitLength = BigInteger.prototype.bitLength; + function max(a, b) { a = parseValue(a); b = parseValue(b); @@ -1036,26 +1059,26 @@ var bigInt = (function (undefined) { } var parseBase = function (text, base) { var length = text.length; - var i; - var absBase = Math.abs(base); - for(var i = 0; i < length; i++) { - var c = text[i].toLowerCase(); - if(c === "-") continue; - if(/[a-z0-9]/.test(c)) { - if(/[0-9]/.test(c) && +c >= absBase) { - if(c === "1" && absBase === 1) continue; + var i; + var absBase = Math.abs(base); + for (var i = 0; i < length; i++) { + var c = text[i].toLowerCase(); + if (c === "-") continue; + if (/[a-z0-9]/.test(c)) { + if (/[0-9]/.test(c) && +c >= absBase) { + if (c === "1" && absBase === 1) continue; + throw new Error(c + " is not a valid digit in base " + base + "."); + } else if (c.charCodeAt(0) - 87 >= absBase) { throw new Error(c + " is not a valid digit in base " + base + "."); - } else if(c.charCodeAt(0) - 87 >= absBase) { - throw new Error(c + " is not a valid digit in base " + base + "."); - } - } - } + } + } + } if (2 <= base && base <= 36) { if (length <= LOG_MAX_INT / Math.log(base)) { - var result = parseInt(text, base); - if(isNaN(result)) { - throw new Error(c + " is not a valid digit in base " + base + "."); - } + var result = parseInt(text, base); + if (isNaN(result)) { + throw new Error(c + " is not a valid digit in base " + base + "."); + } return new SmallInteger(parseInt(text, base)); } } @@ -1087,32 +1110,50 @@ var bigInt = (function (undefined) { } function stringify(digit) { - var v = digit.value; - if (typeof v === "number") v = [v]; - if (v.length === 1 && v[0] <= 35) { - return "0123456789abcdefghijklmnopqrstuvwxyz".charAt(v[0]); + if (digit <= 35) { + return "0123456789abcdefghijklmnopqrstuvwxyz".charAt(digit); } - return "<" + v + ">"; + return "<" + digit + ">"; } + function toBase(n, base) { base = bigInt(base); if (base.isZero()) { - if (n.isZero()) return "0"; + if (n.isZero()) return { value: [0], isNegative: false }; throw new Error("Cannot convert nonzero numbers to base 0."); } if (base.equals(-1)) { - if (n.isZero()) return "0"; - if (n.isNegative()) return new Array(1 - n).join("10"); - return "1" + new Array(+n).join("01"); - } - var minusSign = ""; + if (n.isZero()) return { value: [0], isNegative: false }; + if (n.isNegative()) + return { + value: [].concat.apply([], Array.apply(null, Array(-n)) + .map(Array.prototype.valueOf, [1, 0]) + ), + isNegative: false + }; + + var arr = Array.apply(null, Array(+n - 1)) + .map(Array.prototype.valueOf, [0, 1]); + arr.unshift([1]); + return { + value: [].concat.apply([], arr), + isNegative: false + }; + } + + var neg = false; if (n.isNegative() && base.isPositive()) { - minusSign = "-"; + neg = true; n = n.abs(); } if (base.equals(1)) { - if (n.isZero()) return "0"; - return minusSign + new Array(+n + 1).join(1); + if (n.isZero()) return { value: [0], isNegative: false }; + + return { + value: Array.apply(null, Array(+n)) + .map(Number.prototype.valueOf, 1), + isNegative: neg + }; } var out = []; var left = n, divmod; @@ -1124,15 +1165,28 @@ var bigInt = (function (undefined) { digit = base.minus(digit).abs(); left = left.next(); } - out.push(stringify(digit)); + out.push(digit.toJSNumber()); } - out.push(stringify(left)); - return minusSign + out.reverse().join(""); + out.push(left.toJSNumber()); + return { value: out.reverse(), isNegative: neg }; } + function toBaseString(n, base) { + var arr = toBase(n, base); + return (arr.isNegative ? "-" : "") + arr.value.map(stringify).join(''); + } + + BigInteger.prototype.toArray = function (radix) { + return toBase(this, radix); + }; + + SmallInteger.prototype.toArray = function (radix) { + return toBase(this, radix); + }; + BigInteger.prototype.toString = function (radix) { if (radix === undefined) radix = 10; - if (radix !== 10) return toBase(this, radix); + if (radix !== 10) return toBaseString(this, radix); var v = this.value, l = v.length, str = String(v[--l]), zeros = "0000000", digit; while (--l >= 0) { digit = String(v[l]); @@ -1144,13 +1198,13 @@ var bigInt = (function (undefined) { SmallInteger.prototype.toString = function (radix) { if (radix === undefined) radix = 10; - if (radix != 10) return toBase(this, radix); + if (radix != 10) return toBaseString(this, radix); return String(this.value); }; - BigInteger.prototype.toJSON = SmallInteger.prototype.toJSON = function() { return this.toString(); } + BigInteger.prototype.toJSON = SmallInteger.prototype.toJSON = function () { return this.toString(); } BigInteger.prototype.valueOf = function () { - return +this.toString(); + return parseInt(this.toString(), 10); }; BigInteger.prototype.toJSNumber = BigInteger.prototype.valueOf; @@ -1160,42 +1214,42 @@ var bigInt = (function (undefined) { SmallInteger.prototype.toJSNumber = SmallInteger.prototype.valueOf; function parseStringValue(v) { - if (isPrecise(+v)) { - var x = +v; - if (x === truncate(x)) - return new SmallInteger(x); - throw "Invalid integer: " + v; - } - var sign = v[0] === "-"; - if (sign) v = v.slice(1); - var split = v.split(/e/i); - if (split.length > 2) throw new Error("Invalid integer: " + split.join("e")); - if (split.length === 2) { - var exp = split[1]; - if (exp[0] === "+") exp = exp.slice(1); - exp = +exp; - if (exp !== truncate(exp) || !isPrecise(exp)) throw new Error("Invalid integer: " + exp + " is not a valid exponent."); - var text = split[0]; - var decimalPlace = text.indexOf("."); - if (decimalPlace >= 0) { - exp -= text.length - decimalPlace - 1; - text = text.slice(0, decimalPlace) + text.slice(decimalPlace + 1); - } - if (exp < 0) throw new Error("Cannot include negative exponent part for integers"); - text += (new Array(exp + 1)).join("0"); - v = text; + if (isPrecise(+v)) { + var x = +v; + if (x === truncate(x)) + return new SmallInteger(x); + throw new Error("Invalid integer: " + v); + } + var sign = v[0] === "-"; + if (sign) v = v.slice(1); + var split = v.split(/e/i); + if (split.length > 2) throw new Error("Invalid integer: " + split.join("e")); + if (split.length === 2) { + var exp = split[1]; + if (exp[0] === "+") exp = exp.slice(1); + exp = +exp; + if (exp !== truncate(exp) || !isPrecise(exp)) throw new Error("Invalid integer: " + exp + " is not a valid exponent."); + var text = split[0]; + var decimalPlace = text.indexOf("."); + if (decimalPlace >= 0) { + exp -= text.length - decimalPlace - 1; + text = text.slice(0, decimalPlace) + text.slice(decimalPlace + 1); } - var isValid = /^([0-9][0-9]*)$/.test(v); - if (!isValid) throw new Error("Invalid integer: " + v); - var r = [], max = v.length, l = LOG_BASE, min = max - l; - while (max > 0) { - r.push(+v.slice(min, max)); - min -= l; - if (min < 0) min = 0; - max -= l; - } - trim(r); - return new BigInteger(r, sign); + if (exp < 0) throw new Error("Cannot include negative exponent part for integers"); + text += (new Array(exp + 1)).join("0"); + v = text; + } + var isValid = /^([0-9][0-9]*)$/.test(v); + if (!isValid) throw new Error("Invalid integer: " + v); + var r = [], max = v.length, l = LOG_BASE, min = max - l; + while (max > 0) { + r.push(+v.slice(min, max)); + min -= l; + if (min < 0) min = 0; + max -= l; + } + trim(r); + return new BigInteger(r, sign); } function parseNumberValue(v) { @@ -1244,8 +1298,8 @@ if (typeof module !== "undefined" && module.hasOwnProperty("exports")) { } //amd check -if ( typeof define === "function" && define.amd ) { - define( "big-integer", [], function() { - return bigInt; - }); +if (typeof define === "function" && define.amd) { + define("big-integer", [], function () { + return bigInt; + }); } diff --git a/node_modules/big-integer/BigInteger.min.js b/node_modules/big-integer/BigInteger.min.js index a868e442a3..c775f97a30 100644 --- a/node_modules/big-integer/BigInteger.min.js +++ b/node_modules/big-integer/BigInteger.min.js @@ -1 +1 @@ -var bigInt=function(undefined){"use strict";var BASE=1e7,LOG_BASE=7,MAX_INT=9007199254740992,MAX_INT_ARR=smallToArray(MAX_INT),LOG_MAX_INT=Math.log(MAX_INT);function Integer(v,radix){if(typeof v==="undefined")return Integer[0];if(typeof radix!=="undefined")return+radix===10?parseValue(v):parseBase(v,radix);return parseValue(v)}function BigInteger(value,sign){this.value=value;this.sign=sign;this.isSmall=false}BigInteger.prototype=Object.create(Integer.prototype);function SmallInteger(value){this.value=value;this.sign=value<0;this.isSmall=true}SmallInteger.prototype=Object.create(Integer.prototype);function isPrecise(n){return-MAX_INT0)return Math.floor(n);return Math.ceil(n)}function add(a,b){var l_a=a.length,l_b=b.length,r=new Array(l_a),carry=0,base=BASE,sum,i;for(i=0;i=base?1:0;r[i]=sum-carry*base}while(i0)r.push(carry);return r}function addAny(a,b){if(a.length>=b.length)return add(a,b);return add(b,a)}function addSmall(a,carry){var l=a.length,r=new Array(l),base=BASE,sum,i;for(i=0;i0){r[i++]=carry%base;carry=Math.floor(carry/base)}return r}BigInteger.prototype.add=function(v){var n=parseValue(v);if(this.sign!==n.sign){return this.subtract(n.negate())}var a=this.value,b=n.value;if(n.isSmall){return new BigInteger(addSmall(a,Math.abs(b)),this.sign)}return new BigInteger(addAny(a,b),this.sign)};BigInteger.prototype.plus=BigInteger.prototype.add;SmallInteger.prototype.add=function(v){var n=parseValue(v);var a=this.value;if(a<0!==n.sign){return this.subtract(n.negate())}var b=n.value;if(n.isSmall){if(isPrecise(a+b))return new SmallInteger(a+b);b=smallToArray(Math.abs(b))}return new BigInteger(addSmall(b,Math.abs(a)),a<0)};SmallInteger.prototype.plus=SmallInteger.prototype.add;function subtract(a,b){var a_l=a.length,b_l=b.length,r=new Array(a_l),borrow=0,base=BASE,i,difference;for(i=0;i=0){value=subtract(a,b)}else{value=subtract(b,a);sign=!sign}value=arrayToSmall(value);if(typeof value==="number"){if(sign)value=-value;return new SmallInteger(value)}return new BigInteger(value,sign)}function subtractSmall(a,b,sign){var l=a.length,r=new Array(l),carry=-b,base=BASE,i,difference;for(i=0;i=0)};SmallInteger.prototype.minus=SmallInteger.prototype.subtract;BigInteger.prototype.negate=function(){return new BigInteger(this.value,!this.sign)};SmallInteger.prototype.negate=function(){var sign=this.sign;var small=new SmallInteger(-this.value);small.sign=!sign;return small};BigInteger.prototype.abs=function(){return new BigInteger(this.value,false)};SmallInteger.prototype.abs=function(){return new SmallInteger(Math.abs(this.value))};function multiplyLong(a,b){var a_l=a.length,b_l=b.length,l=a_l+b_l,r=createArray(l),base=BASE,product,carry,i,a_i,b_j;for(i=0;i0){r[i++]=carry%base;carry=Math.floor(carry/base)}return r}function shiftLeft(x,n){var r=[];while(n-- >0)r.push(0);return r.concat(x)}function multiplyKaratsuba(x,y){var n=Math.max(x.length,y.length);if(n<=30)return multiplyLong(x,y);n=Math.ceil(n/2);var b=x.slice(n),a=x.slice(0,n),d=y.slice(n),c=y.slice(0,n);var ac=multiplyKaratsuba(a,c),bd=multiplyKaratsuba(b,d),abcd=multiplyKaratsuba(addAny(a,b),addAny(c,d));var product=addAny(addAny(ac,shiftLeft(subtract(subtract(abcd,ac),bd),n)),shiftLeft(bd,2*n));trim(product);return product}function useKaratsuba(l1,l2){return-.012*l1-.012*l2+15e-6*l1*l2>0}BigInteger.prototype.multiply=function(v){var n=parseValue(v),a=this.value,b=n.value,sign=this.sign!==n.sign,abs;if(n.isSmall){if(b===0)return Integer[0];if(b===1)return this;if(b===-1)return this.negate();abs=Math.abs(b);if(abs=0;shift--){quotientDigit=base-1;if(remainder[shift+b_l]!==divisorMostSignificantDigit){quotientDigit=Math.floor((remainder[shift+b_l]*base+remainder[shift+b_l-1])/divisorMostSignificantDigit)}carry=0;borrow=0;l=divisor.length;for(i=0;ib_l){highx=(highx+1)*base}guess=Math.ceil(highx/highy);do{check=multiplySmall(b,guess);if(compareAbs(check,part)<=0)break;guess--}while(guess);result.push(guess);part=subtract(part,check)}result.reverse();return[arrayToSmall(result),arrayToSmall(part)]}function divModSmall(value,lambda){var length=value.length,quotient=createArray(length),base=BASE,i,q,remainder,divisor;remainder=0;for(i=length-1;i>=0;--i){divisor=remainder*base+value[i];q=truncate(divisor/lambda);remainder=divisor-q*lambda;quotient[i]=q|0}return[quotient,remainder|0]}function divModAny(self,v){var value,n=parseValue(v);var a=self.value,b=n.value;var quotient;if(b===0)throw new Error("Cannot divide by zero");if(self.isSmall){if(n.isSmall){return[new SmallInteger(truncate(a/b)),new SmallInteger(a%b)]}return[Integer[0],self]}if(n.isSmall){if(b===1)return[self,Integer[0]];if(b==-1)return[self.negate(),Integer[0]];var abs=Math.abs(b);if(absb.length?1:-1}for(var i=a.length-1;i>=0;i--){if(a[i]!==b[i])return a[i]>b[i]?1:-1}return 0}BigInteger.prototype.compareAbs=function(v){var n=parseValue(v),a=this.value,b=n.value;if(n.isSmall)return 1;return compareAbs(a,b)};SmallInteger.prototype.compareAbs=function(v){var n=parseValue(v),a=Math.abs(this.value),b=n.value;if(n.isSmall){b=Math.abs(b);return a===b?0:a>b?1:-1}return-1};BigInteger.prototype.compare=function(v){if(v===Infinity){return-1}if(v===-Infinity){return 1}var n=parseValue(v),a=this.value,b=n.value;if(this.sign!==n.sign){return n.sign?1:-1}if(n.isSmall){return this.sign?-1:1}return compareAbs(a,b)*(this.sign?-1:1)};BigInteger.prototype.compareTo=BigInteger.prototype.compare;SmallInteger.prototype.compare=function(v){if(v===Infinity){return-1}if(v===-Infinity){return 1}var n=parseValue(v),a=this.value,b=n.value;if(n.isSmall){return a==b?0:a>b?1:-1}if(a<0!==n.sign){return a<0?-1:1}return a<0?1:-1};SmallInteger.prototype.compareTo=SmallInteger.prototype.compare;BigInteger.prototype.equals=function(v){return this.compare(v)===0};SmallInteger.prototype.eq=SmallInteger.prototype.equals=BigInteger.prototype.eq=BigInteger.prototype.equals;BigInteger.prototype.notEquals=function(v){return this.compare(v)!==0};SmallInteger.prototype.neq=SmallInteger.prototype.notEquals=BigInteger.prototype.neq=BigInteger.prototype.notEquals;BigInteger.prototype.greater=function(v){return this.compare(v)>0};SmallInteger.prototype.gt=SmallInteger.prototype.greater=BigInteger.prototype.gt=BigInteger.prototype.greater;BigInteger.prototype.lesser=function(v){return this.compare(v)<0};SmallInteger.prototype.lt=SmallInteger.prototype.lesser=BigInteger.prototype.lt=BigInteger.prototype.lesser;BigInteger.prototype.greaterOrEquals=function(v){return this.compare(v)>=0};SmallInteger.prototype.geq=SmallInteger.prototype.greaterOrEquals=BigInteger.prototype.geq=BigInteger.prototype.greaterOrEquals;BigInteger.prototype.lesserOrEquals=function(v){return this.compare(v)<=0};SmallInteger.prototype.leq=SmallInteger.prototype.lesserOrEquals=BigInteger.prototype.leq=BigInteger.prototype.lesserOrEquals;BigInteger.prototype.isEven=function(){return(this.value[0]&1)===0};SmallInteger.prototype.isEven=function(){return(this.value&1)===0};BigInteger.prototype.isOdd=function(){return(this.value[0]&1)===1};SmallInteger.prototype.isOdd=function(){return(this.value&1)===1};BigInteger.prototype.isPositive=function(){return!this.sign};SmallInteger.prototype.isPositive=function(){return this.value>0};BigInteger.prototype.isNegative=function(){return this.sign};SmallInteger.prototype.isNegative=function(){return this.value<0};BigInteger.prototype.isUnit=function(){return false};SmallInteger.prototype.isUnit=function(){return Math.abs(this.value)===1};BigInteger.prototype.isZero=function(){return false};SmallInteger.prototype.isZero=function(){return this.value===0};BigInteger.prototype.isDivisibleBy=function(v){var n=parseValue(v);var value=n.value;if(value===0)return false;if(value===1)return true;if(value===2)return this.isEven();return this.mod(n).equals(Integer[0])};SmallInteger.prototype.isDivisibleBy=BigInteger.prototype.isDivisibleBy;function isBasicPrime(v){var n=v.abs();if(n.isUnit())return false;if(n.equals(2)||n.equals(3)||n.equals(5))return true;if(n.isEven()||n.isDivisibleBy(3)||n.isDivisibleBy(5))return false;if(n.lesser(25))return true}BigInteger.prototype.isPrime=function(){var isPrime=isBasicPrime(this);if(isPrime!==undefined)return isPrime;var n=this.abs(),nPrev=n.prev();var a=[2,3,5,7,11,13,17,19],b=nPrev,d,t,i,x;while(b.isEven())b=b.divide(2);for(i=0;i-MAX_INT)return new SmallInteger(value-1);return new BigInteger(MAX_INT_ARR,true)};var powersOfTwo=[1];while(2*powersOfTwo[powersOfTwo.length-1]<=BASE)powersOfTwo.push(2*powersOfTwo[powersOfTwo.length-1]);var powers2Length=powersOfTwo.length,highestPower2=powersOfTwo[powers2Length-1];function shift_isSmall(n){return(typeof n==="number"||typeof n==="string")&&+Math.abs(n)<=BASE||n instanceof BigInteger&&n.value.length<=1}BigInteger.prototype.shiftLeft=function(n){if(!shift_isSmall(n)){throw new Error(String(n)+" is too large for shifting.")}n=+n;if(n<0)return this.shiftRight(-n);var result=this;while(n>=powers2Length){result=result.multiply(highestPower2);n-=powers2Length-1}return result.multiply(powersOfTwo[n])};SmallInteger.prototype.shiftLeft=BigInteger.prototype.shiftLeft;BigInteger.prototype.shiftRight=function(n){var remQuo;if(!shift_isSmall(n)){throw new Error(String(n)+" is too large for shifting.")}n=+n;if(n<0)return this.shiftLeft(-n);var result=this;while(n>=powers2Length){if(result.isZero())return result;remQuo=divModAny(result,highestPower2);result=remQuo[1].isNegative()?remQuo[0].prev():remQuo[0];n-=powers2Length-1}remQuo=divModAny(result,powersOfTwo[n]);return remQuo[1].isNegative()?remQuo[0].prev():remQuo[0]};SmallInteger.prototype.shiftRight=BigInteger.prototype.shiftRight;function bitwise(x,y,fn){y=parseValue(y);var xSign=x.isNegative(),ySign=y.isNegative();var xRem=xSign?x.not():x,yRem=ySign?y.not():y;var xDigit=0,yDigit=0;var xDivMod=null,yDivMod=null;var result=[];while(!xRem.isZero()||!yRem.isZero()){xDivMod=divModAny(xRem,highestPower2);xDigit=xDivMod[1].toJSNumber();if(xSign){xDigit=highestPower2-1-xDigit}yDivMod=divModAny(yRem,highestPower2);yDigit=yDivMod[1].toJSNumber();if(ySign){yDigit=highestPower2-1-yDigit}xRem=xDivMod[0];yRem=yDivMod[0];result.push(fn(xDigit,yDigit))}var sum=fn(xSign?1:0,ySign?1:0)!==0?bigInt(-1):bigInt(0);for(var i=result.length-1;i>=0;i-=1){sum=sum.multiply(highestPower2).add(bigInt(result[i]))}return sum}BigInteger.prototype.not=function(){return this.negate().prev()};SmallInteger.prototype.not=BigInteger.prototype.not;BigInteger.prototype.and=function(n){return bitwise(this,n,function(a,b){return a&b})};SmallInteger.prototype.and=BigInteger.prototype.and;BigInteger.prototype.or=function(n){return bitwise(this,n,function(a,b){return a|b})};SmallInteger.prototype.or=BigInteger.prototype.or;BigInteger.prototype.xor=function(n){return bitwise(this,n,function(a,b){return a^b})};SmallInteger.prototype.xor=BigInteger.prototype.xor;var LOBMASK_I=1<<30,LOBMASK_BI=(BASE&-BASE)*(BASE&-BASE)|LOBMASK_I;function roughLOB(n){var v=n.value,x=typeof v==="number"?v|LOBMASK_I:v[0]+v[1]*BASE|LOBMASK_BI;return x&-x}function max(a,b){a=parseValue(a);b=parseValue(b);return a.greater(b)?a:b}function min(a,b){a=parseValue(a);b=parseValue(b);return a.lesser(b)?a:b}function gcd(a,b){a=parseValue(a).abs();b=parseValue(b).abs();if(a.equals(b))return a;if(a.isZero())return b;if(b.isZero())return a;var c=Integer[1],d,t;while(a.isEven()&&b.isEven()){d=Math.min(roughLOB(a),roughLOB(b));a=a.divide(d);b=b.divide(d);c=c.multiply(d)}while(a.isEven()){a=a.divide(roughLOB(a))}do{while(b.isEven()){b=b.divide(roughLOB(b))}if(a.greater(b)){t=b;b=a;a=t}b=b.subtract(a)}while(!b.isZero());return c.isUnit()?a:a.multiply(c)}function lcm(a,b){a=parseValue(a).abs();b=parseValue(b).abs();return a.divide(gcd(a,b)).multiply(b)}function randBetween(a,b){a=parseValue(a);b=parseValue(b);var low=min(a,b),high=max(a,b);var range=high.subtract(low).add(1);if(range.isSmall)return low.add(Math.floor(Math.random()*range));var length=range.value.length-1;var result=[],restricted=true;for(var i=length;i>=0;i--){var top=restricted?range.value[i]:BASE;var digit=truncate(Math.random()*top);result.unshift(digit);if(digit=absBase){if(c==="1"&&absBase===1)continue;throw new Error(c+" is not a valid digit in base "+base+".")}else if(c.charCodeAt(0)-87>=absBase){throw new Error(c+" is not a valid digit in base "+base+".")}}}if(2<=base&&base<=36){if(length<=LOG_MAX_INT/Math.log(base)){var result=parseInt(text,base);if(isNaN(result)){throw new Error(c+" is not a valid digit in base "+base+".")}return new SmallInteger(parseInt(text,base))}}base=parseValue(base);var digits=[];var isNegative=text[0]==="-";for(i=isNegative?1:0;i");digits.push(parseValue(text.slice(start+1,i)))}else throw new Error(c+" is not a valid character")}return parseBaseFromArray(digits,base,isNegative)};function parseBaseFromArray(digits,base,isNegative){var val=Integer[0],pow=Integer[1],i;for(i=digits.length-1;i>=0;i--){val=val.add(digits[i].times(pow));pow=pow.times(base)}return isNegative?val.negate():val}function stringify(digit){var v=digit.value;if(typeof v==="number")v=[v];if(v.length===1&&v[0]<=35){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(v[0])}return"<"+v+">"}function toBase(n,base){base=bigInt(base);if(base.isZero()){if(n.isZero())return"0";throw new Error("Cannot convert nonzero numbers to base 0.")}if(base.equals(-1)){if(n.isZero())return"0";if(n.isNegative())return new Array(1-n).join("10");return"1"+new Array(+n).join("01")}var minusSign="";if(n.isNegative()&&base.isPositive()){minusSign="-";n=n.abs()}if(base.equals(1)){if(n.isZero())return"0";return minusSign+new Array(+n+1).join(1)}var out=[];var left=n,divmod;while(left.isNegative()||left.compareAbs(base)>=0){divmod=left.divmod(base);left=divmod.quotient;var digit=divmod.remainder;if(digit.isNegative()){digit=base.minus(digit).abs();left=left.next()}out.push(stringify(digit))}out.push(stringify(left));return minusSign+out.reverse().join("")}BigInteger.prototype.toString=function(radix){if(radix===undefined)radix=10;if(radix!==10)return toBase(this,radix);var v=this.value,l=v.length,str=String(v[--l]),zeros="0000000",digit;while(--l>=0){digit=String(v[l]);str+=zeros.slice(digit.length)+digit}var sign=this.sign?"-":"";return sign+str};SmallInteger.prototype.toString=function(radix){if(radix===undefined)radix=10;if(radix!=10)return toBase(this,radix);return String(this.value)};BigInteger.prototype.toJSON=SmallInteger.prototype.toJSON=function(){return this.toString()};BigInteger.prototype.valueOf=function(){return+this.toString()};BigInteger.prototype.toJSNumber=BigInteger.prototype.valueOf;SmallInteger.prototype.valueOf=function(){return this.value};SmallInteger.prototype.toJSNumber=SmallInteger.prototype.valueOf;function parseStringValue(v){if(isPrecise(+v)){var x=+v;if(x===truncate(x))return new SmallInteger(x);throw"Invalid integer: "+v}var sign=v[0]==="-";if(sign)v=v.slice(1);var split=v.split(/e/i);if(split.length>2)throw new Error("Invalid integer: "+split.join("e"));if(split.length===2){var exp=split[1];if(exp[0]==="+")exp=exp.slice(1);exp=+exp;if(exp!==truncate(exp)||!isPrecise(exp))throw new Error("Invalid integer: "+exp+" is not a valid exponent.");var text=split[0];var decimalPlace=text.indexOf(".");if(decimalPlace>=0){exp-=text.length-decimalPlace-1;text=text.slice(0,decimalPlace)+text.slice(decimalPlace+1)}if(exp<0)throw new Error("Cannot include negative exponent part for integers");text+=new Array(exp+1).join("0");v=text}var isValid=/^([0-9][0-9]*)$/.test(v);if(!isValid)throw new Error("Invalid integer: "+v);var r=[],max=v.length,l=LOG_BASE,min=max-l;while(max>0){r.push(+v.slice(min,max));min-=l;if(min<0)min=0;max-=l}trim(r);return new BigInteger(r,sign)}function parseNumberValue(v){if(isPrecise(v)){if(v!==truncate(v))throw new Error(v+" is not an integer.");return new SmallInteger(v)}return parseStringValue(v.toString())}function parseValue(v){if(typeof v==="number"){return parseNumberValue(v)}if(typeof v==="string"){return parseStringValue(v)}return v}for(var i=0;i<1e3;i++){Integer[i]=new SmallInteger(i);if(i>0)Integer[-i]=new SmallInteger(-i)}Integer.one=Integer[1];Integer.zero=Integer[0];Integer.minusOne=Integer[-1];Integer.max=max;Integer.min=min;Integer.gcd=gcd;Integer.lcm=lcm;Integer.isInstance=function(x){return x instanceof BigInteger||x instanceof SmallInteger};Integer.randBetween=randBetween;Integer.fromArray=function(digits,base,isNegative){return parseBaseFromArray(digits.map(parseValue),parseValue(base||10),isNegative)};return Integer}();if(typeof module!=="undefined"&&module.hasOwnProperty("exports")){module.exports=bigInt}if(typeof define==="function"&&define.amd){define("big-integer",[],function(){return bigInt})} \ No newline at end of file +var bigInt=function(undefined){"use strict";var BASE=1e7,LOG_BASE=7,MAX_INT=9007199254740992,MAX_INT_ARR=smallToArray(MAX_INT),LOG_MAX_INT=Math.log(MAX_INT);function Integer(v,radix){if(typeof v==="undefined")return Integer[0];if(typeof radix!=="undefined")return+radix===10?parseValue(v):parseBase(v,radix);return parseValue(v)}function BigInteger(value,sign){this.value=value;this.sign=sign;this.isSmall=false}BigInteger.prototype=Object.create(Integer.prototype);function SmallInteger(value){this.value=value;this.sign=value<0;this.isSmall=true}SmallInteger.prototype=Object.create(Integer.prototype);function isPrecise(n){return-MAX_INT0)return Math.floor(n);return Math.ceil(n)}function add(a,b){var l_a=a.length,l_b=b.length,r=new Array(l_a),carry=0,base=BASE,sum,i;for(i=0;i=base?1:0;r[i]=sum-carry*base}while(i0)r.push(carry);return r}function addAny(a,b){if(a.length>=b.length)return add(a,b);return add(b,a)}function addSmall(a,carry){var l=a.length,r=new Array(l),base=BASE,sum,i;for(i=0;i0){r[i++]=carry%base;carry=Math.floor(carry/base)}return r}BigInteger.prototype.add=function(v){var n=parseValue(v);if(this.sign!==n.sign){return this.subtract(n.negate())}var a=this.value,b=n.value;if(n.isSmall){return new BigInteger(addSmall(a,Math.abs(b)),this.sign)}return new BigInteger(addAny(a,b),this.sign)};BigInteger.prototype.plus=BigInteger.prototype.add;SmallInteger.prototype.add=function(v){var n=parseValue(v);var a=this.value;if(a<0!==n.sign){return this.subtract(n.negate())}var b=n.value;if(n.isSmall){if(isPrecise(a+b))return new SmallInteger(a+b);b=smallToArray(Math.abs(b))}return new BigInteger(addSmall(b,Math.abs(a)),a<0)};SmallInteger.prototype.plus=SmallInteger.prototype.add;function subtract(a,b){var a_l=a.length,b_l=b.length,r=new Array(a_l),borrow=0,base=BASE,i,difference;for(i=0;i=0){value=subtract(a,b)}else{value=subtract(b,a);sign=!sign}value=arrayToSmall(value);if(typeof value==="number"){if(sign)value=-value;return new SmallInteger(value)}return new BigInteger(value,sign)}function subtractSmall(a,b,sign){var l=a.length,r=new Array(l),carry=-b,base=BASE,i,difference;for(i=0;i=0)};SmallInteger.prototype.minus=SmallInteger.prototype.subtract;BigInteger.prototype.negate=function(){return new BigInteger(this.value,!this.sign)};SmallInteger.prototype.negate=function(){var sign=this.sign;var small=new SmallInteger(-this.value);small.sign=!sign;return small};BigInteger.prototype.abs=function(){return new BigInteger(this.value,false)};SmallInteger.prototype.abs=function(){return new SmallInteger(Math.abs(this.value))};function multiplyLong(a,b){var a_l=a.length,b_l=b.length,l=a_l+b_l,r=createArray(l),base=BASE,product,carry,i,a_i,b_j;for(i=0;i0){r[i++]=carry%base;carry=Math.floor(carry/base)}return r}function shiftLeft(x,n){var r=[];while(n-- >0)r.push(0);return r.concat(x)}function multiplyKaratsuba(x,y){var n=Math.max(x.length,y.length);if(n<=30)return multiplyLong(x,y);n=Math.ceil(n/2);var b=x.slice(n),a=x.slice(0,n),d=y.slice(n),c=y.slice(0,n);var ac=multiplyKaratsuba(a,c),bd=multiplyKaratsuba(b,d),abcd=multiplyKaratsuba(addAny(a,b),addAny(c,d));var product=addAny(addAny(ac,shiftLeft(subtract(subtract(abcd,ac),bd),n)),shiftLeft(bd,2*n));trim(product);return product}function useKaratsuba(l1,l2){return-.012*l1-.012*l2+15e-6*l1*l2>0}BigInteger.prototype.multiply=function(v){var n=parseValue(v),a=this.value,b=n.value,sign=this.sign!==n.sign,abs;if(n.isSmall){if(b===0)return Integer[0];if(b===1)return this;if(b===-1)return this.negate();abs=Math.abs(b);if(abs=0;shift--){quotientDigit=base-1;if(remainder[shift+b_l]!==divisorMostSignificantDigit){quotientDigit=Math.floor((remainder[shift+b_l]*base+remainder[shift+b_l-1])/divisorMostSignificantDigit)}carry=0;borrow=0;l=divisor.length;for(i=0;ib_l){highx=(highx+1)*base}guess=Math.ceil(highx/highy);do{check=multiplySmall(b,guess);if(compareAbs(check,part)<=0)break;guess--}while(guess);result.push(guess);part=subtract(part,check)}result.reverse();return[arrayToSmall(result),arrayToSmall(part)]}function divModSmall(value,lambda){var length=value.length,quotient=createArray(length),base=BASE,i,q,remainder,divisor;remainder=0;for(i=length-1;i>=0;--i){divisor=remainder*base+value[i];q=truncate(divisor/lambda);remainder=divisor-q*lambda;quotient[i]=q|0}return[quotient,remainder|0]}function divModAny(self,v){var value,n=parseValue(v);var a=self.value,b=n.value;var quotient;if(b===0)throw new Error("Cannot divide by zero");if(self.isSmall){if(n.isSmall){return[new SmallInteger(truncate(a/b)),new SmallInteger(a%b)]}return[Integer[0],self]}if(n.isSmall){if(b===1)return[self,Integer[0]];if(b==-1)return[self.negate(),Integer[0]];var abs=Math.abs(b);if(absb.length?1:-1}for(var i=a.length-1;i>=0;i--){if(a[i]!==b[i])return a[i]>b[i]?1:-1}return 0}BigInteger.prototype.compareAbs=function(v){var n=parseValue(v),a=this.value,b=n.value;if(n.isSmall)return 1;return compareAbs(a,b)};SmallInteger.prototype.compareAbs=function(v){var n=parseValue(v),a=Math.abs(this.value),b=n.value;if(n.isSmall){b=Math.abs(b);return a===b?0:a>b?1:-1}return-1};BigInteger.prototype.compare=function(v){if(v===Infinity){return-1}if(v===-Infinity){return 1}var n=parseValue(v),a=this.value,b=n.value;if(this.sign!==n.sign){return n.sign?1:-1}if(n.isSmall){return this.sign?-1:1}return compareAbs(a,b)*(this.sign?-1:1)};BigInteger.prototype.compareTo=BigInteger.prototype.compare;SmallInteger.prototype.compare=function(v){if(v===Infinity){return-1}if(v===-Infinity){return 1}var n=parseValue(v),a=this.value,b=n.value;if(n.isSmall){return a==b?0:a>b?1:-1}if(a<0!==n.sign){return a<0?-1:1}return a<0?1:-1};SmallInteger.prototype.compareTo=SmallInteger.prototype.compare;BigInteger.prototype.equals=function(v){return this.compare(v)===0};SmallInteger.prototype.eq=SmallInteger.prototype.equals=BigInteger.prototype.eq=BigInteger.prototype.equals;BigInteger.prototype.notEquals=function(v){return this.compare(v)!==0};SmallInteger.prototype.neq=SmallInteger.prototype.notEquals=BigInteger.prototype.neq=BigInteger.prototype.notEquals;BigInteger.prototype.greater=function(v){return this.compare(v)>0};SmallInteger.prototype.gt=SmallInteger.prototype.greater=BigInteger.prototype.gt=BigInteger.prototype.greater;BigInteger.prototype.lesser=function(v){return this.compare(v)<0};SmallInteger.prototype.lt=SmallInteger.prototype.lesser=BigInteger.prototype.lt=BigInteger.prototype.lesser;BigInteger.prototype.greaterOrEquals=function(v){return this.compare(v)>=0};SmallInteger.prototype.geq=SmallInteger.prototype.greaterOrEquals=BigInteger.prototype.geq=BigInteger.prototype.greaterOrEquals;BigInteger.prototype.lesserOrEquals=function(v){return this.compare(v)<=0};SmallInteger.prototype.leq=SmallInteger.prototype.lesserOrEquals=BigInteger.prototype.leq=BigInteger.prototype.lesserOrEquals;BigInteger.prototype.isEven=function(){return(this.value[0]&1)===0};SmallInteger.prototype.isEven=function(){return(this.value&1)===0};BigInteger.prototype.isOdd=function(){return(this.value[0]&1)===1};SmallInteger.prototype.isOdd=function(){return(this.value&1)===1};BigInteger.prototype.isPositive=function(){return!this.sign};SmallInteger.prototype.isPositive=function(){return this.value>0};BigInteger.prototype.isNegative=function(){return this.sign};SmallInteger.prototype.isNegative=function(){return this.value<0};BigInteger.prototype.isUnit=function(){return false};SmallInteger.prototype.isUnit=function(){return Math.abs(this.value)===1};BigInteger.prototype.isZero=function(){return false};SmallInteger.prototype.isZero=function(){return this.value===0};BigInteger.prototype.isDivisibleBy=function(v){var n=parseValue(v);var value=n.value;if(value===0)return false;if(value===1)return true;if(value===2)return this.isEven();return this.mod(n).equals(Integer[0])};SmallInteger.prototype.isDivisibleBy=BigInteger.prototype.isDivisibleBy;function isBasicPrime(v){var n=v.abs();if(n.isUnit())return false;if(n.equals(2)||n.equals(3)||n.equals(5))return true;if(n.isEven()||n.isDivisibleBy(3)||n.isDivisibleBy(5))return false;if(n.lesser(25))return true}BigInteger.prototype.isPrime=function(){var isPrime=isBasicPrime(this);if(isPrime!==undefined)return isPrime;var n=this.abs(),nPrev=n.prev();var a=[2,3,5,7,11,13,17,19],b=nPrev,d,t,i,x;while(b.isEven())b=b.divide(2);for(i=0;i-MAX_INT)return new SmallInteger(value-1);return new BigInteger(MAX_INT_ARR,true)};var powersOfTwo=[1];while(2*powersOfTwo[powersOfTwo.length-1]<=BASE)powersOfTwo.push(2*powersOfTwo[powersOfTwo.length-1]);var powers2Length=powersOfTwo.length,highestPower2=powersOfTwo[powers2Length-1];function shift_isSmall(n){return(typeof n==="number"||typeof n==="string")&&+Math.abs(n)<=BASE||n instanceof BigInteger&&n.value.length<=1}BigInteger.prototype.shiftLeft=function(n){if(!shift_isSmall(n)){throw new Error(String(n)+" is too large for shifting.")}n=+n;if(n<0)return this.shiftRight(-n);var result=this;while(n>=powers2Length){result=result.multiply(highestPower2);n-=powers2Length-1}return result.multiply(powersOfTwo[n])};SmallInteger.prototype.shiftLeft=BigInteger.prototype.shiftLeft;BigInteger.prototype.shiftRight=function(n){var remQuo;if(!shift_isSmall(n)){throw new Error(String(n)+" is too large for shifting.")}n=+n;if(n<0)return this.shiftLeft(-n);var result=this;while(n>=powers2Length){if(result.isZero())return result;remQuo=divModAny(result,highestPower2);result=remQuo[1].isNegative()?remQuo[0].prev():remQuo[0];n-=powers2Length-1}remQuo=divModAny(result,powersOfTwo[n]);return remQuo[1].isNegative()?remQuo[0].prev():remQuo[0]};SmallInteger.prototype.shiftRight=BigInteger.prototype.shiftRight;function bitwise(x,y,fn){y=parseValue(y);var xSign=x.isNegative(),ySign=y.isNegative();var xRem=xSign?x.not():x,yRem=ySign?y.not():y;var xDigit=0,yDigit=0;var xDivMod=null,yDivMod=null;var result=[];while(!xRem.isZero()||!yRem.isZero()){xDivMod=divModAny(xRem,highestPower2);xDigit=xDivMod[1].toJSNumber();if(xSign){xDigit=highestPower2-1-xDigit}yDivMod=divModAny(yRem,highestPower2);yDigit=yDivMod[1].toJSNumber();if(ySign){yDigit=highestPower2-1-yDigit}xRem=xDivMod[0];yRem=yDivMod[0];result.push(fn(xDigit,yDigit))}var sum=fn(xSign?1:0,ySign?1:0)!==0?bigInt(-1):bigInt(0);for(var i=result.length-1;i>=0;i-=1){sum=sum.multiply(highestPower2).add(bigInt(result[i]))}return sum}BigInteger.prototype.not=function(){return this.negate().prev()};SmallInteger.prototype.not=BigInteger.prototype.not;BigInteger.prototype.and=function(n){return bitwise(this,n,function(a,b){return a&b})};SmallInteger.prototype.and=BigInteger.prototype.and;BigInteger.prototype.or=function(n){return bitwise(this,n,function(a,b){return a|b})};SmallInteger.prototype.or=BigInteger.prototype.or;BigInteger.prototype.xor=function(n){return bitwise(this,n,function(a,b){return a^b})};SmallInteger.prototype.xor=BigInteger.prototype.xor;var LOBMASK_I=1<<30,LOBMASK_BI=(BASE&-BASE)*(BASE&-BASE)|LOBMASK_I;function roughLOB(n){var v=n.value,x=typeof v==="number"?v|LOBMASK_I:v[0]+v[1]*BASE|LOBMASK_BI;return x&-x}function integerLogarithm(value,base){if(base.compareTo(value)<=0){var tmp=integerLogarithm(value,base.square(base));var p=tmp.p;var e=tmp.e;var t=p.multiply(base);return t.compareTo(value)<=0?{p:t,e:e*2+1}:{p:p,e:e*2}}return{p:bigInt(1),e:0}}BigInteger.prototype.bitLength=function(){var n=this;if(n.compareTo(bigInt(0))<0){n=n.negate().subtract(bigInt(1))}if(n.compareTo(bigInt(0))===0){return bigInt(0)}return bigInt(integerLogarithm(n,bigInt(2)).e).add(bigInt(1))};SmallInteger.prototype.bitLength=BigInteger.prototype.bitLength;function max(a,b){a=parseValue(a);b=parseValue(b);return a.greater(b)?a:b}function min(a,b){a=parseValue(a);b=parseValue(b);return a.lesser(b)?a:b}function gcd(a,b){a=parseValue(a).abs();b=parseValue(b).abs();if(a.equals(b))return a;if(a.isZero())return b;if(b.isZero())return a;var c=Integer[1],d,t;while(a.isEven()&&b.isEven()){d=Math.min(roughLOB(a),roughLOB(b));a=a.divide(d);b=b.divide(d);c=c.multiply(d)}while(a.isEven()){a=a.divide(roughLOB(a))}do{while(b.isEven()){b=b.divide(roughLOB(b))}if(a.greater(b)){t=b;b=a;a=t}b=b.subtract(a)}while(!b.isZero());return c.isUnit()?a:a.multiply(c)}function lcm(a,b){a=parseValue(a).abs();b=parseValue(b).abs();return a.divide(gcd(a,b)).multiply(b)}function randBetween(a,b){a=parseValue(a);b=parseValue(b);var low=min(a,b),high=max(a,b);var range=high.subtract(low).add(1);if(range.isSmall)return low.add(Math.floor(Math.random()*range));var length=range.value.length-1;var result=[],restricted=true;for(var i=length;i>=0;i--){var top=restricted?range.value[i]:BASE;var digit=truncate(Math.random()*top);result.unshift(digit);if(digit=absBase){if(c==="1"&&absBase===1)continue;throw new Error(c+" is not a valid digit in base "+base+".")}else if(c.charCodeAt(0)-87>=absBase){throw new Error(c+" is not a valid digit in base "+base+".")}}}if(2<=base&&base<=36){if(length<=LOG_MAX_INT/Math.log(base)){var result=parseInt(text,base);if(isNaN(result)){throw new Error(c+" is not a valid digit in base "+base+".")}return new SmallInteger(parseInt(text,base))}}base=parseValue(base);var digits=[];var isNegative=text[0]==="-";for(i=isNegative?1:0;i");digits.push(parseValue(text.slice(start+1,i)))}else throw new Error(c+" is not a valid character")}return parseBaseFromArray(digits,base,isNegative)};function parseBaseFromArray(digits,base,isNegative){var val=Integer[0],pow=Integer[1],i;for(i=digits.length-1;i>=0;i--){val=val.add(digits[i].times(pow));pow=pow.times(base)}return isNegative?val.negate():val}function stringify(digit){if(digit<=35){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(digit)}return"<"+digit+">"}function toBase(n,base){base=bigInt(base);if(base.isZero()){if(n.isZero())return{value:[0],isNegative:false};throw new Error("Cannot convert nonzero numbers to base 0.")}if(base.equals(-1)){if(n.isZero())return{value:[0],isNegative:false};if(n.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-n)).map(Array.prototype.valueOf,[1,0])),isNegative:false};var arr=Array.apply(null,Array(+n-1)).map(Array.prototype.valueOf,[0,1]);arr.unshift([1]);return{value:[].concat.apply([],arr),isNegative:false}}var neg=false;if(n.isNegative()&&base.isPositive()){neg=true;n=n.abs()}if(base.equals(1)){if(n.isZero())return{value:[0],isNegative:false};return{value:Array.apply(null,Array(+n)).map(Number.prototype.valueOf,1),isNegative:neg}}var out=[];var left=n,divmod;while(left.isNegative()||left.compareAbs(base)>=0){divmod=left.divmod(base);left=divmod.quotient;var digit=divmod.remainder;if(digit.isNegative()){digit=base.minus(digit).abs();left=left.next()}out.push(digit.toJSNumber())}out.push(left.toJSNumber());return{value:out.reverse(),isNegative:neg}}function toBaseString(n,base){var arr=toBase(n,base);return(arr.isNegative?"-":"")+arr.value.map(stringify).join("")}BigInteger.prototype.toArray=function(radix){return toBase(this,radix)};SmallInteger.prototype.toArray=function(radix){return toBase(this,radix)};BigInteger.prototype.toString=function(radix){if(radix===undefined)radix=10;if(radix!==10)return toBaseString(this,radix);var v=this.value,l=v.length,str=String(v[--l]),zeros="0000000",digit;while(--l>=0){digit=String(v[l]);str+=zeros.slice(digit.length)+digit}var sign=this.sign?"-":"";return sign+str};SmallInteger.prototype.toString=function(radix){if(radix===undefined)radix=10;if(radix!=10)return toBaseString(this,radix);return String(this.value)};BigInteger.prototype.toJSON=SmallInteger.prototype.toJSON=function(){return this.toString()};BigInteger.prototype.valueOf=function(){return parseInt(this.toString(),10)};BigInteger.prototype.toJSNumber=BigInteger.prototype.valueOf;SmallInteger.prototype.valueOf=function(){return this.value};SmallInteger.prototype.toJSNumber=SmallInteger.prototype.valueOf;function parseStringValue(v){if(isPrecise(+v)){var x=+v;if(x===truncate(x))return new SmallInteger(x);throw new Error("Invalid integer: "+v)}var sign=v[0]==="-";if(sign)v=v.slice(1);var split=v.split(/e/i);if(split.length>2)throw new Error("Invalid integer: "+split.join("e"));if(split.length===2){var exp=split[1];if(exp[0]==="+")exp=exp.slice(1);exp=+exp;if(exp!==truncate(exp)||!isPrecise(exp))throw new Error("Invalid integer: "+exp+" is not a valid exponent.");var text=split[0];var decimalPlace=text.indexOf(".");if(decimalPlace>=0){exp-=text.length-decimalPlace-1;text=text.slice(0,decimalPlace)+text.slice(decimalPlace+1)}if(exp<0)throw new Error("Cannot include negative exponent part for integers");text+=new Array(exp+1).join("0");v=text}var isValid=/^([0-9][0-9]*)$/.test(v);if(!isValid)throw new Error("Invalid integer: "+v);var r=[],max=v.length,l=LOG_BASE,min=max-l;while(max>0){r.push(+v.slice(min,max));min-=l;if(min<0)min=0;max-=l}trim(r);return new BigInteger(r,sign)}function parseNumberValue(v){if(isPrecise(v)){if(v!==truncate(v))throw new Error(v+" is not an integer.");return new SmallInteger(v)}return parseStringValue(v.toString())}function parseValue(v){if(typeof v==="number"){return parseNumberValue(v)}if(typeof v==="string"){return parseStringValue(v)}return v}for(var i=0;i<1e3;i++){Integer[i]=new SmallInteger(i);if(i>0)Integer[-i]=new SmallInteger(-i)}Integer.one=Integer[1];Integer.zero=Integer[0];Integer.minusOne=Integer[-1];Integer.max=max;Integer.min=min;Integer.gcd=gcd;Integer.lcm=lcm;Integer.isInstance=function(x){return x instanceof BigInteger||x instanceof SmallInteger};Integer.randBetween=randBetween;Integer.fromArray=function(digits,base,isNegative){return parseBaseFromArray(digits.map(parseValue),parseValue(base||10),isNegative)};return Integer}();if(typeof module!=="undefined"&&module.hasOwnProperty("exports")){module.exports=bigInt}if(typeof define==="function"&&define.amd){define("big-integer",[],function(){return bigInt})} \ No newline at end of file diff --git a/node_modules/big-integer/README.md b/node_modules/big-integer/README.md index 5824f7eff0..55ab8d3383 100644 --- a/node_modules/big-integer/README.md +++ b/node_modules/big-integer/README.md @@ -92,6 +92,12 @@ Performs the bitwise AND operation. The operands are treated as if they were rep - `bigInt(6).and(3)` => `2` - `bigInt(6).and(-3)` => `4` +#### `bitLength()` + +Returns the number of digits required to represent a bigInt in binary. + + - `bigInt(5)` => `3` (since 5 is `101` in binary, which is three digits long) + #### `compare(number)` Performs a comparison between two numbers. If the numbers are equal, it returns `0`. If the first number is greater, it returns `1`. If the first number is lesser, it returns `-1`. @@ -406,6 +412,50 @@ Alias for the `multiply` method. [View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Multiplication) +#### `toArray(radix)` + +Converts a bigInt into an object with the properties "value" and "isNegative." "Value" is an array of integers modulo the given radix. "isNegative" is a boolean that represents the sign of the result. + + - `bigInt("1e9").toArray(10)` => { + value: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], + isNegative: false + } + - `bigInt("1e9").toArray(16)` => { + value: [3, 11, 9, 10, 12, 10, 0, 0], + isNegative: false + } + - `bigInt(567890).toArray(100)` => { + value: [56, 78, 90], + isNegative: false + } + +Negative bases are supported. + + - `bigInt(12345).toArray(-10)` => { + value: [2, 8, 4, 6, 5], + isNegative: false + } + +Base 1 and base -1 are also supported. + + - `bigInt(-15).toArray(1)` => { + value: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + isNegative: true + } + - `bigInt(-15).toArray(-1)` => { + value: [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], + isNegative: false + } + +Base 0 is only allowed for the number zero. + + - `bigInt(0).toArray(0)` => { + value: [0], + isNegative: false + } + - `bigInt(1).toArray(0)` => `Error: Cannot convert nonzero numbers to base 0.` + #### `toJSNumber()` Converts a bigInt into a native Javascript number. Loses precision for numbers outside the range `[-9007199254740992, 9007199254740992]`. diff --git a/node_modules/big-integer/package.json b/node_modules/big-integer/package.json index 3d34fd1e9e..a1a4af175e 100644 --- a/node_modules/big-integer/package.json +++ b/node_modules/big-integer/package.json @@ -1,50 +1,27 @@ { - "_args": [ - [ - { - "raw": "big-integer@^1.6.7", - "scope": null, - "escapedName": "big-integer", - "name": "big-integer", - "rawSpec": "^1.6.7", - "spec": ">=1.6.7 <2.0.0", - "type": "range" - }, - "/Users/steveng/repo/cordova/cordova-android/node_modules/bplist-parser" - ] - ], - "_from": "big-integer@>=1.6.7 <2.0.0", - "_id": "big-integer@1.6.26", - "_inCache": true, + "_from": "big-integer@^1.6.7", + "_id": "big-integer@1.6.31", + "_inBundle": false, + "_integrity": "sha512-lDbZNHHwxDKnjP7LWg2leO+tjs4SyVs2Z83dsR1Idbe2urRnxZAUdeQ8YBhHaGaWK/4WM3mz+RlbZsgqck17CA==", "_location": "/big-integer", - "_nodeVersion": "6.10.3", - "_npmOperationalInternal": { - "host": "s3://npm-registry-packages", - "tmp": "tmp/big-integer-1.6.26.tgz_1510889021794_0.842821853235364" - }, - "_npmUser": { - "name": "peterolson", - "email": "peter.e.c.olson+npm@gmail.com" - }, - "_npmVersion": "3.10.10", "_phantomChildren": {}, "_requested": { + "type": "range", + "registry": true, "raw": "big-integer@^1.6.7", - "scope": null, - "escapedName": "big-integer", "name": "big-integer", + "escapedName": "big-integer", "rawSpec": "^1.6.7", - "spec": ">=1.6.7 <2.0.0", - "type": "range" + "saveSpec": null, + "fetchSpec": "^1.6.7" }, "_requiredBy": [ "/bplist-parser" ], - "_resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.26.tgz", - "_shasum": "3af1672fa62daf2d5ecafacf6e5aa0d25e02c1c8", - "_shrinkwrap": null, + "_resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.31.tgz", + "_shasum": "6d7852486e67c642502dcc03f7225a245c9fc7fa", "_spec": "big-integer@^1.6.7", - "_where": "/Users/steveng/repo/cordova/cordova-android/node_modules/bplist-parser", + "_where": "/Users/brodybits/Documents/cbwork/cordova-android/node_modules/bplist-parser", "author": { "name": "Peter Olson", "email": "peter.e.c.olson+npm@gmail.com" @@ -53,16 +30,18 @@ "bugs": { "url": "https://github.com/peterolson/BigInteger.js/issues" }, + "bundleDependencies": false, "contributors": [], - "dependencies": {}, + "deprecated": false, "description": "An arbitrary length integer library for Javascript", "devDependencies": { - "@types/lodash": "^4.14.64", - "@types/node": "^7.0.22", + "@types/lodash": "^4.14.109", + "@types/node": "^7.0.65", "coveralls": "^2.11.4", "jasmine": "2.1.x", "jasmine-core": "^2.3.4", - "karma": "^0.13.3", + "karma": "^0.13.22", + "karma-cli": "^1.0.1", "karma-coverage": "^0.4.2", "karma-jasmine": "^0.3.6", "karma-phantomjs-launcher": "^1.0.4", @@ -70,15 +49,9 @@ "typescript": "^2.3.3", "uglifyjs": "^2.4.10" }, - "directories": {}, - "dist": { - "shasum": "3af1672fa62daf2d5ecafacf6e5aa0d25e02c1c8", - "tarball": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.26.tgz" - }, "engines": { "node": ">=0.6" }, - "gitHead": "b1c6e0e95eca0a0d19ebbb9cc81ec492448a9e8a", "homepage": "https://github.com/peterolson/BigInteger.js#readme", "keywords": [ "math", @@ -93,23 +66,15 @@ ], "license": "Unlicense", "main": "./BigInteger", - "maintainers": [ - { - "name": "peterolson", - "email": "peter.e.c.olson+npm@gmail.com" - } - ], "name": "big-integer", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", "repository": { "type": "git", "url": "git+ssh://git@github.com/peterolson/BigInteger.js.git" }, "scripts": { "minify": "uglifyjs BigInteger.js -o BigInteger.min.js", - "test": "tsc && node_modules/.bin/karma start my.conf.js && node spec/tsDefinitions.js" + "test": "tsc && karma start my.conf.js && node spec/tsDefinitions.js" }, "typings": "./BigInteger.d.ts", - "version": "1.6.26" + "version": "1.6.31" } diff --git a/node_modules/cordova-common/.eslintrc.yml b/node_modules/cordova-common/.eslintrc.yml index 7701c82aac..21a8e7b4ef 100644 --- a/node_modules/cordova-common/.eslintrc.yml +++ b/node_modules/cordova-common/.eslintrc.yml @@ -8,4 +8,6 @@ rules: padded-blocks: off operator-linebreak: off no-throw-literal: off - \ No newline at end of file + no-unused-vars: + - error + - args: after-used diff --git a/node_modules/cordova-common/.github/PULL_REQUEST_TEMPLATE.md b/node_modules/cordova-common/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000..91582f4efb --- /dev/null +++ b/node_modules/cordova-common/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,22 @@ + + +### Platforms affected + + +### What does this PR do? + + +### What testing has been done on this change? + + +### Checklist +- [ ] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database +- [ ] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected. +- [ ] Added automated test coverage as appropriate for this change. diff --git a/node_modules/cordova-common/.jscs.json b/node_modules/cordova-common/.jscs.json deleted file mode 100644 index 5cc7e26c34..0000000000 --- a/node_modules/cordova-common/.jscs.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "disallowMixedSpacesAndTabs": true, - "disallowTrailingWhitespace": true, - "validateLineBreaks": "LF", - "validateIndentation": 4, - "requireLineFeedAtFileEnd": true, - - "disallowSpaceAfterPrefixUnaryOperators": true, - "disallowSpaceBeforePostfixUnaryOperators": true, - "requireSpaceAfterLineComment": true, - "requireCapitalizedConstructors": true, - - "disallowSpacesInNamedFunctionExpression": { - "beforeOpeningRoundBrace": true - }, - - "requireSpaceAfterKeywords": [ - "if", - "else", - "for", - "while", - "do" - ] -} diff --git a/node_modules/cordova-common/.travis.yml b/node_modules/cordova-common/.travis.yml index 4592c3ee75..b4e310dbda 100644 --- a/node_modules/cordova-common/.travis.yml +++ b/node_modules/cordova-common/.travis.yml @@ -6,6 +6,7 @@ node_js: - "4" - "6" - "8" + - "10" install: - npm install - npm install -g codecov diff --git a/node_modules/cordova-common/README.md b/node_modules/cordova-common/README.md index 5659c57fbc..422c98b5df 100644 --- a/node_modules/cordova-common/README.md +++ b/node_modules/cordova-common/README.md @@ -24,11 +24,11 @@ [![NPM](https://nodei.co/npm/cordova-common.png)](https://nodei.co/npm/cordova-common/) # cordova-common -Expoeses shared functionality used by [cordova-lib](https://github.com/apache/cordova-lib/) and Cordova platforms. +Exposes shared functionality used by [cordova-lib](https://github.com/apache/cordova-lib/) and Cordova platforms. ## Exposed APIs ### `events` - + Represents special instance of NodeJS EventEmitter which is intended to be used to post events to cordova-lib and cordova-cli Usage: @@ -122,7 +122,7 @@ superspawn.spawn('adb', ['devices']) ### `xmlHelpers` -A set of utility methods for dealing with xml files. +A set of utility methods for dealing with XML files. Usage: ```js @@ -148,10 +148,8 @@ mungeUtil ## Setup * Clone this repository onto your local machine - `git clone https://git-wip-us.apache.org/repos/asf/cordova-lib.git` -* In terminal, navigate to the inner cordova-common directory - `cd cordova-lib/cordova-common` -* Install dependencies and npm-link - `npm install && npm link` + `git clone https://github.com/apache/cordova-common.git` +* Navigate to cordova-common directory, install dependencies and npm-link + `cd cordova-common && npm install && npm link` * Navigate to cordova-lib directory and link cordova-common - `cd ../cordova-lib && npm link cordova-common && npm install` + `cd && npm link cordova-common && npm install` diff --git a/node_modules/cordova-common/RELEASENOTES.md b/node_modules/cordova-common/RELEASENOTES.md index 5dda362887..bc4fe14537 100644 --- a/node_modules/cordova-common/RELEASENOTES.md +++ b/node_modules/cordova-common/RELEASENOTES.md @@ -20,6 +20,20 @@ --> # Cordova-common Release Notes +### 2.2.3 (June 1, 2018) +* Revert a minor refactoring that was incompatible with NodeJS 4.x. No change to functionality. + +### 2.2.2 (May 30, 2018) +* [CB-13979](https://issues.apache.org/jira/browse/CB-13979) More consistency for `config.xml` lookups +* [CB-14064](https://issues.apache.org/jira/browse/CB-14064) Remove Node 4 from CI matrix +* [CB-14088](https://issues.apache.org/jira/browse/CB-14088) Update dependencies +* [CB-11691](https://issues.apache.org/jira/browse/CB-11691) Fix for modifying binary plists +* [CB-13770](https://issues.apache.org/jira/browse/CB-13770) Warn when or not found +* [CB-13471](https://issues.apache.org/jira/browse/CB-13471) Fix tests and path issues for **Windows** +* [CB-13471](https://issues.apache.org/jira/browse/CB-13471) added unit test for config file provider +* [CB-13744](https://issues.apache.org/jira/browse/CB-13744) Recognize storyboards as XML files +* [CB-13674](https://issues.apache.org/jira/browse/CB-13674) Incremented package version to -dev + ### 2.2.1 (Dec 14, 2017) * [CB-13674](https://issues.apache.org/jira/browse/CB-13674): updated dependencies diff --git a/node_modules/cordova-common/appveyor.yml b/node_modules/cordova-common/appveyor.yml index ffe5194144..5302ae0d08 100644 --- a/node_modules/cordova-common/appveyor.yml +++ b/node_modules/cordova-common/appveyor.yml @@ -6,7 +6,8 @@ environment: - nodejs_version: "4" - nodejs_version: "6" - nodejs_version: "8" - + - nodejs_version: "10" + install: - ps: Install-Product node $env:nodejs_version - npm install diff --git a/node_modules/cordova-common/node_modules/.bin/shjs b/node_modules/cordova-common/node_modules/.bin/shjs new file mode 120000 index 0000000000..a0449975bf --- /dev/null +++ b/node_modules/cordova-common/node_modules/.bin/shjs @@ -0,0 +1 @@ +../shelljs/bin/shjs \ No newline at end of file diff --git a/node_modules/cordova-common/node_modules/elementtree/.npmignore b/node_modules/cordova-common/node_modules/elementtree/.npmignore new file mode 100644 index 0000000000..3c3629e647 --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/node_modules/cordova-common/node_modules/elementtree/.travis.yml b/node_modules/cordova-common/node_modules/elementtree/.travis.yml new file mode 100644 index 0000000000..1ab2652009 --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/.travis.yml @@ -0,0 +1,14 @@ +language: node_js +sudo: false + +node_js: + - "0.10" + - "0.11" + - "0.12" + - "iojs" + +script: make test + +notifications: + email: + - tomaz+travisci@tomaz.me diff --git a/node_modules/cordova-common/node_modules/elementtree/CHANGES.md b/node_modules/cordova-common/node_modules/elementtree/CHANGES.md new file mode 100644 index 0000000000..08fdb1fff5 --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/CHANGES.md @@ -0,0 +1,39 @@ +elementtree v0.1.6 - 2014-02-06 + +* Add support for CData elements. (#14) + [hermannpencole] + +elementtree v0.1.5 - 2012-11-14 + +* Fix a bug in the find() and findtext() method which could manifest itself + under some conditions. + [metagriffin] + +elementtree v0.1.4 - 2012-10-15 + +* Allow user to use namespaced attributes when using find* functions. + [Andrew Lunny] + +elementtree v0.1.3 - 2012-09-21 + +* Improve the output of text content in the tags (strip unnecessary line break + characters). + +[Darryl Pogue] + +elementtree v0.1.2 - 2012-09-04 + + * Allow user to pass 'indent' option to ElementTree.write method. If this + option is specified (e.g. {'indent': 4}). XML will be pretty printed. + [Darryl Pogue, Tomaz Muraus] + + * Bump sax dependency version. + +elementtree v0.1.1 - 2011-09-23 + + * Improve special character escaping. + [Ryan Phillips] + +elementtree v0.1.0 - 2011-09-05 + + * Initial release. diff --git a/node_modules/cordova-common/node_modules/elementtree/LICENSE.txt b/node_modules/cordova-common/node_modules/elementtree/LICENSE.txt new file mode 100644 index 0000000000..6b0b1270ff --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/LICENSE.txt @@ -0,0 +1,203 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. + diff --git a/node_modules/cordova-common/node_modules/elementtree/Makefile b/node_modules/cordova-common/node_modules/elementtree/Makefile new file mode 100755 index 0000000000..ab7c4e0eef --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/Makefile @@ -0,0 +1,21 @@ +TESTS := \ + tests/test-simple.js + + + +PATH := ./node_modules/.bin:$(PATH) + +WHISKEY := $(shell bash -c 'PATH=$(PATH) type -p whiskey') + +default: test + +test: + NODE_PATH=`pwd`/lib/ ${WHISKEY} --scope-leaks --sequential --real-time --tests "${TESTS}" + +tap: + NODE_PATH=`pwd`/lib/ ${WHISKEY} --test-reporter tap --sequential --real-time --tests "${TESTS}" + +coverage: + NODE_PATH=`pwd`/lib/ ${WHISKEY} --sequential --coverage --coverage-reporter html --coverage-dir coverage_html --tests "${TESTS}" + +.PHONY: default test coverage tap scope diff --git a/node_modules/cordova-common/node_modules/elementtree/NOTICE b/node_modules/cordova-common/node_modules/elementtree/NOTICE new file mode 100644 index 0000000000..28ad70aa94 --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/NOTICE @@ -0,0 +1,5 @@ +node-elementtree +Copyright (c) 2011, Rackspace, Inc. + +The ElementTree toolkit is Copyright (c) 1999-2007 by Fredrik Lundh + diff --git a/node_modules/cordova-common/node_modules/elementtree/README.md b/node_modules/cordova-common/node_modules/elementtree/README.md new file mode 100644 index 0000000000..738420cc8f --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/README.md @@ -0,0 +1,141 @@ +node-elementtree +==================== + +node-elementtree is a [Node.js](http://nodejs.org) XML parser and serializer based upon the [Python ElementTree v1.3](http://effbot.org/zone/element-index.htm) module. + +Installation +==================== + + $ npm install elementtree + +Using the library +==================== + +For the usage refer to the Python ElementTree library documentation - [http://effbot.org/zone/element-index.htm#usage](http://effbot.org/zone/element-index.htm#usage). + +Supported XPath expressions in `find`, `findall` and `findtext` methods are listed on [http://effbot.org/zone/element-xpath.htm](http://effbot.org/zone/element-xpath.htm). + +Example 1 – Creating An XML Document +==================== + +This example shows how to build a valid XML document that can be published to +Atom Hopper. Atom Hopper is used internally as a bridge from products all the +way to collecting revenue, called “Usage.” MaaS and other products send similar +events to it every time user performs an action on a resource +(e.g. creates,updates or deletes). Below is an example of leveraging the API +to create a new XML document. + +```javascript +var et = require('elementtree'); +var XML = et.XML; +var ElementTree = et.ElementTree; +var element = et.Element; +var subElement = et.SubElement; + +var date, root, tenantId, serviceName, eventType, usageId, dataCenter, region, +checks, resourceId, category, startTime, resourceName, etree, xml; + +date = new Date(); + +root = element('entry'); +root.set('xmlns', 'http://www.w3.org/2005/Atom'); + +tenantId = subElement(root, 'TenantId'); +tenantId.text = '12345'; + +serviceName = subElement(root, 'ServiceName'); +serviceName.text = 'MaaS'; + +resourceId = subElement(root, 'ResourceID'); +resourceId.text = 'enAAAA'; + +usageId = subElement(root, 'UsageID'); +usageId.text = '550e8400-e29b-41d4-a716-446655440000'; + +eventType = subElement(root, 'EventType'); +eventType.text = 'create'; + +category = subElement(root, 'category'); +category.set('term', 'monitoring.entity.create'); + +dataCenter = subElement(root, 'DataCenter'); +dataCenter.text = 'global'; + +region = subElement(root, 'Region'); +region.text = 'global'; + +startTime = subElement(root, 'StartTime'); +startTime.text = date; + +resourceName = subElement(root, 'ResourceName'); +resourceName.text = 'entity'; + +etree = new ElementTree(root); +xml = etree.write({'xml_declaration': false}); +console.log(xml); +``` + +As you can see, both et.Element and et.SubElement are factory methods which +return a new instance of Element and SubElement class, respectively. +When you create a new element (tag) you can use set method to set an attribute. +To set the tag value, assign a value to the .text attribute. + +This example would output a document that looks like this: + +```xml + + 12345 + MaaS + enAAAA + 550e8400-e29b-41d4-a716-446655440000 + create + + global + global + Sun Apr 29 2012 16:37:32 GMT-0700 (PDT) + entity + +``` + +Example 2 – Parsing An XML Document +==================== + +This example shows how to parse an XML document and use simple XPath selectors. +For demonstration purposes, we will use the XML document located at +https://gist.github.com/2554343. + +Behind the scenes, node-elementtree uses Isaac’s sax library for parsing XML, +but the library has a concept of “parsers,” which means it’s pretty simple to +add support for a different parser. + +```javascript +var fs = require('fs'); + +var et = require('elementtree'); + +var XML = et.XML; +var ElementTree = et.ElementTree; +var element = et.Element; +var subElement = et.SubElement; + +var data, etree; + +data = fs.readFileSync('document.xml').toString(); +etree = et.parse(data); + +console.log(etree.findall('./entry/TenantId').length); // 2 +console.log(etree.findtext('./entry/ServiceName')); // MaaS +console.log(etree.findall('./entry/category')[0].get('term')); // monitoring.entity.create +console.log(etree.findall('*/category/[@term="monitoring.entity.update"]').length); // 1 +``` + +Build status +==================== + +[![Build Status](https://secure.travis-ci.org/racker/node-elementtree.png)](http://travis-ci.org/racker/node-elementtree) + + +License +==================== + +node-elementtree is distributed under the [Apache license](http://www.apache.org/licenses/LICENSE-2.0.html). diff --git a/node_modules/cordova-common/node_modules/elementtree/lib/constants.js b/node_modules/cordova-common/node_modules/elementtree/lib/constants.js new file mode 100644 index 0000000000..b057fafee0 --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/lib/constants.js @@ -0,0 +1,20 @@ +/* + * Copyright 2011 Rackspace + * + * Licensed 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 DEFAULT_PARSER = 'sax'; + +exports.DEFAULT_PARSER = DEFAULT_PARSER; diff --git a/node_modules/cordova-common/node_modules/elementtree/lib/elementpath.js b/node_modules/cordova-common/node_modules/elementtree/lib/elementpath.js new file mode 100644 index 0000000000..2e93f47e96 --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/lib/elementpath.js @@ -0,0 +1,343 @@ +/** + * Copyright 2011 Rackspace + * + * Licensed 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 sprintf = require('./sprintf').sprintf; + +var utils = require('./utils'); +var SyntaxError = require('./errors').SyntaxError; + +var _cache = {}; + +var RE = new RegExp( + "(" + + "'[^']*'|\"[^\"]*\"|" + + "::|" + + "//?|" + + "\\.\\.|" + + "\\(\\)|" + + "[/.*:\\[\\]\\(\\)@=])|" + + "((?:\\{[^}]+\\})?[^/\\[\\]\\(\\)@=\\s]+)|" + + "\\s+", 'g' +); + +var xpath_tokenizer = utils.findall.bind(null, RE); + +function prepare_tag(next, token) { + var tag = token[0]; + + function select(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + elem._children.forEach(function(e) { + if (e.tag === tag) { + rv.push(e); + } + }); + } + + return rv; + } + + return select; +} + +function prepare_star(next, token) { + function select(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + elem._children.forEach(function(e) { + rv.push(e); + }); + } + + return rv; + } + + return select; +} + +function prepare_dot(next, token) { + function select(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + rv.push(elem); + } + + return rv; + } + + return select; +} + +function prepare_iter(next, token) { + var tag; + token = next(); + + if (token[1] === '*') { + tag = '*'; + } + else if (!token[1]) { + tag = token[0] || ''; + } + else { + throw new SyntaxError(token); + } + + function select(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + elem.iter(tag, function(e) { + if (e !== elem) { + rv.push(e); + } + }); + } + + return rv; + } + + return select; +} + +function prepare_dot_dot(next, token) { + function select(context, result) { + var i, len, elem, rv = [], parent_map = context.parent_map; + + if (!parent_map) { + context.parent_map = parent_map = {}; + + context.root.iter(null, function(p) { + p._children.forEach(function(e) { + parent_map[e] = p; + }); + }); + } + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + + if (parent_map.hasOwnProperty(elem)) { + rv.push(parent_map[elem]); + } + } + + return rv; + } + + return select; +} + + +function prepare_predicate(next, token) { + var tag, key, value, select; + token = next(); + + if (token[1] === '@') { + // attribute + token = next(); + + if (token[1]) { + throw new SyntaxError(token, 'Invalid attribute predicate'); + } + + key = token[0]; + token = next(); + + if (token[1] === ']') { + select = function(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + + if (elem.get(key)) { + rv.push(elem); + } + } + + return rv; + }; + } + else if (token[1] === '=') { + value = next()[1]; + + if (value[0] === '"' || value[value.length - 1] === '\'') { + value = value.slice(1, value.length - 1); + } + else { + throw new SyntaxError(token, 'Ivalid comparison target'); + } + + token = next(); + select = function(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + + if (elem.get(key) === value) { + rv.push(elem); + } + } + + return rv; + }; + } + + if (token[1] !== ']') { + throw new SyntaxError(token, 'Invalid attribute predicate'); + } + } + else if (!token[1]) { + tag = token[0] || ''; + token = next(); + + if (token[1] !== ']') { + throw new SyntaxError(token, 'Invalid node predicate'); + } + + select = function(context, result) { + var i, len, elem, rv = []; + + for (i = 0, len = result.length; i < len; i++) { + elem = result[i]; + + if (elem.find(tag)) { + rv.push(elem); + } + } + + return rv; + }; + } + else { + throw new SyntaxError(null, 'Invalid predicate'); + } + + return select; +} + + + +var ops = { + "": prepare_tag, + "*": prepare_star, + ".": prepare_dot, + "..": prepare_dot_dot, + "//": prepare_iter, + "[": prepare_predicate, +}; + +function _SelectorContext(root) { + this.parent_map = null; + this.root = root; +} + +function findall(elem, path) { + var selector, result, i, len, token, value, select, context; + + if (_cache.hasOwnProperty(path)) { + selector = _cache[path]; + } + else { + // TODO: Use smarter cache purging approach + if (Object.keys(_cache).length > 100) { + _cache = {}; + } + + if (path.charAt(0) === '/') { + throw new SyntaxError(null, 'Cannot use absolute path on element'); + } + + result = xpath_tokenizer(path); + selector = []; + + function getToken() { + return result.shift(); + } + + token = getToken(); + while (true) { + var c = token[1] || ''; + value = ops[c](getToken, token); + + if (!value) { + throw new SyntaxError(null, sprintf('Invalid path: %s', path)); + } + + selector.push(value); + token = getToken(); + + if (!token) { + break; + } + else if (token[1] === '/') { + token = getToken(); + } + + if (!token) { + break; + } + } + + _cache[path] = selector; + } + + // Execute slector pattern + result = [elem]; + context = new _SelectorContext(elem); + + for (i = 0, len = selector.length; i < len; i++) { + select = selector[i]; + result = select(context, result); + } + + return result || []; +} + +function find(element, path) { + var resultElements = findall(element, path); + + if (resultElements && resultElements.length > 0) { + return resultElements[0]; + } + + return null; +} + +function findtext(element, path, defvalue) { + var resultElements = findall(element, path); + + if (resultElements && resultElements.length > 0) { + return resultElements[0].text; + } + + return defvalue; +} + + +exports.find = find; +exports.findall = findall; +exports.findtext = findtext; diff --git a/node_modules/cordova-common/node_modules/elementtree/lib/elementtree.js b/node_modules/cordova-common/node_modules/elementtree/lib/elementtree.js new file mode 100644 index 0000000000..61d927693f --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/lib/elementtree.js @@ -0,0 +1,611 @@ +/** + * Copyright 2011 Rackspace + * + * Licensed 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 sprintf = require('./sprintf').sprintf; + +var utils = require('./utils'); +var ElementPath = require('./elementpath'); +var TreeBuilder = require('./treebuilder').TreeBuilder; +var get_parser = require('./parser').get_parser; +var constants = require('./constants'); + +var element_ids = 0; + +function Element(tag, attrib) +{ + this._id = element_ids++; + this.tag = tag; + this.attrib = {}; + this.text = null; + this.tail = null; + this._children = []; + + if (attrib) { + this.attrib = utils.merge(this.attrib, attrib); + } +} + +Element.prototype.toString = function() +{ + return sprintf("", this.tag, this._id); +}; + +Element.prototype.makeelement = function(tag, attrib) +{ + return new Element(tag, attrib); +}; + +Element.prototype.len = function() +{ + return this._children.length; +}; + +Element.prototype.getItem = function(index) +{ + return this._children[index]; +}; + +Element.prototype.setItem = function(index, element) +{ + this._children[index] = element; +}; + +Element.prototype.delItem = function(index) +{ + this._children.splice(index, 1); +}; + +Element.prototype.getSlice = function(start, stop) +{ + return this._children.slice(start, stop); +}; + +Element.prototype.setSlice = function(start, stop, elements) +{ + var i; + var k = 0; + for (i = start; i < stop; i++, k++) { + this._children[i] = elements[k]; + } +}; + +Element.prototype.delSlice = function(start, stop) +{ + this._children.splice(start, stop - start); +}; + +Element.prototype.append = function(element) +{ + this._children.push(element); +}; + +Element.prototype.extend = function(elements) +{ + this._children.concat(elements); +}; + +Element.prototype.insert = function(index, element) +{ + this._children[index] = element; +}; + +Element.prototype.remove = function(element) +{ + this._children = this._children.filter(function(e) { + /* TODO: is this the right way to do this? */ + if (e._id === element._id) { + return false; + } + return true; + }); +}; + +Element.prototype.getchildren = function() { + return this._children; +}; + +Element.prototype.find = function(path) +{ + return ElementPath.find(this, path); +}; + +Element.prototype.findtext = function(path, defvalue) +{ + return ElementPath.findtext(this, path, defvalue); +}; + +Element.prototype.findall = function(path, defvalue) +{ + return ElementPath.findall(this, path, defvalue); +}; + +Element.prototype.clear = function() +{ + this.attrib = {}; + this._children = []; + this.text = null; + this.tail = null; +}; + +Element.prototype.get = function(key, defvalue) +{ + if (this.attrib[key] !== undefined) { + return this.attrib[key]; + } + else { + return defvalue; + } +}; + +Element.prototype.set = function(key, value) +{ + this.attrib[key] = value; +}; + +Element.prototype.keys = function() +{ + return Object.keys(this.attrib); +}; + +Element.prototype.items = function() +{ + return utils.items(this.attrib); +}; + +/* + * In python this uses a generator, but in v8 we don't have em, + * so we use a callback instead. + **/ +Element.prototype.iter = function(tag, callback) +{ + var self = this; + var i, child; + + if (tag === "*") { + tag = null; + } + + if (tag === null || this.tag === tag) { + callback(self); + } + + for (i = 0; i < this._children.length; i++) { + child = this._children[i]; + child.iter(tag, function(e) { + callback(e); + }); + } +}; + +Element.prototype.itertext = function(callback) +{ + this.iter(null, function(e) { + if (e.text) { + callback(e.text); + } + + if (e.tail) { + callback(e.tail); + } + }); +}; + + +function SubElement(parent, tag, attrib) { + var element = parent.makeelement(tag, attrib); + parent.append(element); + return element; +} + +function Comment(text) { + var element = new Element(Comment); + if (text) { + element.text = text; + } + return element; +} + +function CData(text) { + var element = new Element(CData); + if (text) { + element.text = text; + } + return element; +} + +function ProcessingInstruction(target, text) +{ + var element = new Element(ProcessingInstruction); + element.text = target; + if (text) { + element.text = element.text + " " + text; + } + return element; +} + +function QName(text_or_uri, tag) +{ + if (tag) { + text_or_uri = sprintf("{%s}%s", text_or_uri, tag); + } + this.text = text_or_uri; +} + +QName.prototype.toString = function() { + return this.text; +}; + +function ElementTree(element) +{ + this._root = element; +} + +ElementTree.prototype.getroot = function() { + return this._root; +}; + +ElementTree.prototype._setroot = function(element) { + this._root = element; +}; + +ElementTree.prototype.parse = function(source, parser) { + if (!parser) { + parser = get_parser(constants.DEFAULT_PARSER); + parser = new parser.XMLParser(new TreeBuilder()); + } + + parser.feed(source); + this._root = parser.close(); + return this._root; +}; + +ElementTree.prototype.iter = function(tag, callback) { + this._root.iter(tag, callback); +}; + +ElementTree.prototype.find = function(path) { + return this._root.find(path); +}; + +ElementTree.prototype.findtext = function(path, defvalue) { + return this._root.findtext(path, defvalue); +}; + +ElementTree.prototype.findall = function(path) { + return this._root.findall(path); +}; + +/** + * Unlike ElementTree, we don't write to a file, we return you a string. + */ +ElementTree.prototype.write = function(options) { + var sb = []; + options = utils.merge({ + encoding: 'utf-8', + xml_declaration: null, + default_namespace: null, + method: 'xml'}, options); + + if (options.xml_declaration !== false) { + sb.push("\n"); + } + + if (options.method === "text") { + _serialize_text(sb, self._root, encoding); + } + else { + var qnames, namespaces, indent, indent_string; + var x = _namespaces(this._root, options.encoding, options.default_namespace); + qnames = x[0]; + namespaces = x[1]; + + if (options.hasOwnProperty('indent')) { + indent = 0; + indent_string = new Array(options.indent + 1).join(' '); + } + else { + indent = false; + } + + if (options.method === "xml") { + _serialize_xml(function(data) { + sb.push(data); + }, this._root, options.encoding, qnames, namespaces, indent, indent_string); + } + else { + /* TODO: html */ + throw new Error("unknown serialization method "+ options.method); + } + } + + return sb.join(""); +}; + +var _namespace_map = { + /* "well-known" namespace prefixes */ + "http://www.w3.org/XML/1998/namespace": "xml", + "http://www.w3.org/1999/xhtml": "html", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#": "rdf", + "http://schemas.xmlsoap.org/wsdl/": "wsdl", + /* xml schema */ + "http://www.w3.org/2001/XMLSchema": "xs", + "http://www.w3.org/2001/XMLSchema-instance": "xsi", + /* dublic core */ + "http://purl.org/dc/elements/1.1/": "dc", +}; + +function register_namespace(prefix, uri) { + if (/ns\d+$/.test(prefix)) { + throw new Error('Prefix format reserved for internal use'); + } + + if (_namespace_map.hasOwnProperty(uri) && _namespace_map[uri] === prefix) { + delete _namespace_map[uri]; + } + + _namespace_map[uri] = prefix; +} + + +function _escape(text, encoding, isAttribute, isText) { + if (text) { + text = text.toString(); + text = text.replace(/&/g, '&'); + text = text.replace(//g, '>'); + if (!isText) { + text = text.replace(/\n/g, ' '); + text = text.replace(/\r/g, ' '); + } + if (isAttribute) { + text = text.replace(/"/g, '"'); + } + } + return text; +} + +/* TODO: benchmark single regex */ +function _escape_attrib(text, encoding) { + return _escape(text, encoding, true); +} + +function _escape_cdata(text, encoding) { + return _escape(text, encoding, false); +} + +function _escape_text(text, encoding) { + return _escape(text, encoding, false, true); +} + +function _namespaces(elem, encoding, default_namespace) { + var qnames = {}; + var namespaces = {}; + + if (default_namespace) { + namespaces[default_namespace] = ""; + } + + function encode(text) { + return text; + } + + function add_qname(qname) { + if (qname[0] === "{") { + var tmp = qname.substring(1).split("}", 2); + var uri = tmp[0]; + var tag = tmp[1]; + var prefix = namespaces[uri]; + + if (prefix === undefined) { + prefix = _namespace_map[uri]; + if (prefix === undefined) { + prefix = "ns" + Object.keys(namespaces).length; + } + if (prefix !== "xml") { + namespaces[uri] = prefix; + } + } + + if (prefix) { + qnames[qname] = sprintf("%s:%s", prefix, tag); + } + else { + qnames[qname] = tag; + } + } + else { + if (default_namespace) { + throw new Error('cannot use non-qualified names with default_namespace option'); + } + + qnames[qname] = qname; + } + } + + + elem.iter(null, function(e) { + var i; + var tag = e.tag; + var text = e.text; + var items = e.items(); + + if (tag instanceof QName && qnames[tag.text] === undefined) { + add_qname(tag.text); + } + else if (typeof(tag) === "string") { + add_qname(tag); + } + else if (tag !== null && tag !== Comment && tag !== CData && tag !== ProcessingInstruction) { + throw new Error('Invalid tag type for serialization: '+ tag); + } + + if (text instanceof QName && qnames[text.text] === undefined) { + add_qname(text.text); + } + + items.forEach(function(item) { + var key = item[0], + value = item[1]; + if (key instanceof QName) { + key = key.text; + } + + if (qnames[key] === undefined) { + add_qname(key); + } + + if (value instanceof QName && qnames[value.text] === undefined) { + add_qname(value.text); + } + }); + }); + return [qnames, namespaces]; +} + +function _serialize_xml(write, elem, encoding, qnames, namespaces, indent, indent_string) { + var tag = elem.tag; + var text = elem.text; + var items; + var i; + + var newlines = indent || (indent === 0); + write(Array(indent + 1).join(indent_string)); + + if (tag === Comment) { + write(sprintf("", _escape_cdata(text, encoding))); + } + else if (tag === ProcessingInstruction) { + write(sprintf("", _escape_cdata(text, encoding))); + } + else if (tag === CData) { + text = text || ''; + write(sprintf("", text)); + } + else { + tag = qnames[tag]; + if (tag === undefined) { + if (text) { + write(_escape_text(text, encoding)); + } + elem.iter(function(e) { + _serialize_xml(write, e, encoding, qnames, null, newlines ? indent + 1 : false, indent_string); + }); + } + else { + write("<" + tag); + items = elem.items(); + + if (items || namespaces) { + items.sort(); // lexical order + + items.forEach(function(item) { + var k = item[0], + v = item[1]; + + if (k instanceof QName) { + k = k.text; + } + + if (v instanceof QName) { + v = qnames[v.text]; + } + else { + v = _escape_attrib(v, encoding); + } + write(sprintf(" %s=\"%s\"", qnames[k], v)); + }); + + if (namespaces) { + items = utils.items(namespaces); + items.sort(function(a, b) { return a[1] < b[1]; }); + + items.forEach(function(item) { + var k = item[1], + v = item[0]; + + if (k) { + k = ':' + k; + } + + write(sprintf(" xmlns%s=\"%s\"", k, _escape_attrib(v, encoding))); + }); + } + } + + if (text || elem.len()) { + if (text && text.toString().match(/^\s*$/)) { + text = null; + } + + write(">"); + if (!text && newlines) { + write("\n"); + } + + if (text) { + write(_escape_text(text, encoding)); + } + elem._children.forEach(function(e) { + _serialize_xml(write, e, encoding, qnames, null, newlines ? indent + 1 : false, indent_string); + }); + + if (!text && indent) { + write(Array(indent + 1).join(indent_string)); + } + write(""); + } + else { + write(" />"); + } + } + } + + if (newlines) { + write("\n"); + } +} + +function parse(source, parser) { + var tree = new ElementTree(); + tree.parse(source, parser); + return tree; +} + +function tostring(element, options) { + return new ElementTree(element).write(options); +} + +exports.PI = ProcessingInstruction; +exports.Comment = Comment; +exports.CData = CData; +exports.ProcessingInstruction = ProcessingInstruction; +exports.SubElement = SubElement; +exports.QName = QName; +exports.ElementTree = ElementTree; +exports.ElementPath = ElementPath; +exports.Element = function(tag, attrib) { + return new Element(tag, attrib); +}; + +exports.XML = function(data) { + var et = new ElementTree(); + return et.parse(data); +}; + +exports.parse = parse; +exports.register_namespace = register_namespace; +exports.tostring = tostring; diff --git a/node_modules/cordova-common/node_modules/elementtree/lib/errors.js b/node_modules/cordova-common/node_modules/elementtree/lib/errors.js new file mode 100644 index 0000000000..e8742be151 --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/lib/errors.js @@ -0,0 +1,31 @@ +/** + * Copyright 2011 Rackspace + * + * Licensed 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 util = require('util'); + +var sprintf = require('./sprintf').sprintf; + +function SyntaxError(token, msg) { + msg = msg || sprintf('Syntax Error at token %s', token.toString()); + this.token = token; + this.message = msg; + Error.call(this, msg); +} + +util.inherits(SyntaxError, Error); + +exports.SyntaxError = SyntaxError; diff --git a/node_modules/cordova-common/node_modules/elementtree/lib/parser.js b/node_modules/cordova-common/node_modules/elementtree/lib/parser.js new file mode 100644 index 0000000000..7307ee4764 --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/lib/parser.js @@ -0,0 +1,33 @@ +/* + * Copyright 2011 Rackspace + * + * Licensed 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. + * + */ + +/* TODO: support node-expat C++ module optionally */ + +var util = require('util'); +var parsers = require('./parsers/index'); + +function get_parser(name) { + if (name === 'sax') { + return parsers.sax; + } + else { + throw new Error('Invalid parser: ' + name); + } +} + + +exports.get_parser = get_parser; diff --git a/node_modules/cordova-common/node_modules/elementtree/lib/parsers/index.js b/node_modules/cordova-common/node_modules/elementtree/lib/parsers/index.js new file mode 100644 index 0000000000..5eac5c88a2 --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/lib/parsers/index.js @@ -0,0 +1 @@ +exports.sax = require('./sax'); diff --git a/node_modules/cordova-common/node_modules/elementtree/lib/parsers/sax.js b/node_modules/cordova-common/node_modules/elementtree/lib/parsers/sax.js new file mode 100644 index 0000000000..69b0a59bee --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/lib/parsers/sax.js @@ -0,0 +1,56 @@ +var util = require('util'); + +var sax = require('sax'); + +var TreeBuilder = require('./../treebuilder').TreeBuilder; + +function XMLParser(target) { + this.parser = sax.parser(true); + + this.target = (target) ? target : new TreeBuilder(); + + this.parser.onopentag = this._handleOpenTag.bind(this); + this.parser.ontext = this._handleText.bind(this); + this.parser.oncdata = this._handleCdata.bind(this); + this.parser.ondoctype = this._handleDoctype.bind(this); + this.parser.oncomment = this._handleComment.bind(this); + this.parser.onclosetag = this._handleCloseTag.bind(this); + this.parser.onerror = this._handleError.bind(this); +} + +XMLParser.prototype._handleOpenTag = function(tag) { + this.target.start(tag.name, tag.attributes); +}; + +XMLParser.prototype._handleText = function(text) { + this.target.data(text); +}; + +XMLParser.prototype._handleCdata = function(text) { + this.target.data(text); +}; + +XMLParser.prototype._handleDoctype = function(text) { +}; + +XMLParser.prototype._handleComment = function(comment) { +}; + +XMLParser.prototype._handleCloseTag = function(tag) { + this.target.end(tag); +}; + +XMLParser.prototype._handleError = function(err) { + throw err; +}; + +XMLParser.prototype.feed = function(chunk) { + this.parser.write(chunk); +}; + +XMLParser.prototype.close = function() { + this.parser.close(); + return this.target.close(); +}; + +exports.XMLParser = XMLParser; diff --git a/node_modules/cordova-common/node_modules/elementtree/lib/sprintf.js b/node_modules/cordova-common/node_modules/elementtree/lib/sprintf.js new file mode 100644 index 0000000000..f802c1b410 --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/lib/sprintf.js @@ -0,0 +1,86 @@ +/* + * Copyright 2011 Rackspace + * + * Licensed 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 cache = {}; + + +// Do any others need escaping? +var TO_ESCAPE = { + '\'': '\\\'', + '\n': '\\n' +}; + + +function populate(formatter) { + var i, type, + key = formatter, + prev = 0, + arg = 1, + builder = 'return \''; + + for (i = 0; i < formatter.length; i++) { + if (formatter[i] === '%') { + type = formatter[i + 1]; + + switch (type) { + case 's': + builder += formatter.slice(prev, i) + '\' + arguments[' + arg + '] + \''; + prev = i + 2; + arg++; + break; + case 'j': + builder += formatter.slice(prev, i) + '\' + JSON.stringify(arguments[' + arg + ']) + \''; + prev = i + 2; + arg++; + break; + case '%': + builder += formatter.slice(prev, i + 1); + prev = i + 2; + i++; + break; + } + + + } else if (TO_ESCAPE[formatter[i]]) { + builder += formatter.slice(prev, i) + TO_ESCAPE[formatter[i]]; + prev = i + 1; + } + } + + builder += formatter.slice(prev) + '\';'; + cache[key] = new Function(builder); +} + + +/** + * A fast version of sprintf(), which currently only supports the %s and %j. + * This caches a formatting function for each format string that is used, so + * you should only use this sprintf() will be called many times with a single + * format string and a limited number of format strings will ever be used (in + * general this means that format strings should be string literals). + * + * @param {String} formatter A format string. + * @param {...String} var_args Values that will be formatted by %s and %j. + * @return {String} The formatted output. + */ +exports.sprintf = function(formatter, var_args) { + if (!cache[formatter]) { + populate(formatter); + } + + return cache[formatter].apply(null, arguments); +}; diff --git a/node_modules/cordova-common/node_modules/elementtree/lib/treebuilder.js b/node_modules/cordova-common/node_modules/elementtree/lib/treebuilder.js new file mode 100644 index 0000000000..393a98fac9 --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/lib/treebuilder.js @@ -0,0 +1,60 @@ +function TreeBuilder(element_factory) { + this._data = []; + this._elem = []; + this._last = null; + this._tail = null; + if (!element_factory) { + /* evil circular dep */ + element_factory = require('./elementtree').Element; + } + this._factory = element_factory; +} + +TreeBuilder.prototype.close = function() { + return this._last; +}; + +TreeBuilder.prototype._flush = function() { + if (this._data) { + if (this._last !== null) { + var text = this._data.join(""); + if (this._tail) { + this._last.tail = text; + } + else { + this._last.text = text; + } + } + this._data = []; + } +}; + +TreeBuilder.prototype.data = function(data) { + this._data.push(data); +}; + +TreeBuilder.prototype.start = function(tag, attrs) { + this._flush(); + var elem = this._factory(tag, attrs); + this._last = elem; + + if (this._elem.length) { + this._elem[this._elem.length - 1].append(elem); + } + + this._elem.push(elem); + + this._tail = null; +}; + +TreeBuilder.prototype.end = function(tag) { + this._flush(); + this._last = this._elem.pop(); + if (this._last.tag !== tag) { + throw new Error("end tag mismatch"); + } + this._tail = 1; + return this._last; +}; + +exports.TreeBuilder = TreeBuilder; diff --git a/node_modules/cordova-common/node_modules/elementtree/lib/utils.js b/node_modules/cordova-common/node_modules/elementtree/lib/utils.js new file mode 100644 index 0000000000..b08a6706df --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/lib/utils.js @@ -0,0 +1,72 @@ +/** + * Copyright 2011 Rackspace + * + * Licensed 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. + * + */ + +/** + * @param {Object} hash. + * @param {Array} ignored. + */ +function items(hash, ignored) { + ignored = ignored || null; + var k, rv = []; + + function is_ignored(key) { + if (!ignored || ignored.length === 0) { + return false; + } + + return ignored.indexOf(key); + } + + for (k in hash) { + if (hash.hasOwnProperty(k) && !(is_ignored(ignored))) { + rv.push([k, hash[k]]); + } + } + + return rv; +} + + +function findall(re, str) { + var match, matches = []; + + while ((match = re.exec(str))) { + matches.push(match); + } + + return matches; +} + +function merge(a, b) { + var c = {}, attrname; + + for (attrname in a) { + if (a.hasOwnProperty(attrname)) { + c[attrname] = a[attrname]; + } + } + for (attrname in b) { + if (b.hasOwnProperty(attrname)) { + c[attrname] = b[attrname]; + } + } + return c; +} + +exports.items = items; +exports.findall = findall; +exports.merge = merge; diff --git a/node_modules/cordova-common/node_modules/elementtree/package.json b/node_modules/cordova-common/node_modules/elementtree/package.json new file mode 100644 index 0000000000..76c3473ec9 --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/package.json @@ -0,0 +1,75 @@ +{ + "_from": "elementtree@0.1.7", + "_id": "elementtree@0.1.7", + "_inBundle": false, + "_integrity": "sha1-mskb5uUvtuYkTE5UpKw+2K6OKcA=", + "_location": "/cordova-common/elementtree", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "elementtree@0.1.7", + "name": "elementtree", + "escapedName": "elementtree", + "rawSpec": "0.1.7", + "saveSpec": null, + "fetchSpec": "0.1.7" + }, + "_requiredBy": [ + "/cordova-common" + ], + "_resolved": "https://registry.npmjs.org/elementtree/-/elementtree-0.1.7.tgz", + "_shasum": "9ac91be6e52fb6e6244c4e54a4ac3ed8ae8e29c0", + "_spec": "elementtree@0.1.7", + "_where": "/Users/brodybits/Documents/cbwork/cordova-android/node_modules/cordova-common", + "author": { + "name": "Rackspace US, Inc." + }, + "bugs": { + "url": "https://github.com/racker/node-elementtree/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Paul Querna", + "email": "paul.querna@rackspace.com" + }, + { + "name": "Tomaz Muraus", + "email": "tomaz.muraus@rackspace.com" + } + ], + "dependencies": { + "sax": "1.1.4" + }, + "deprecated": false, + "description": "XML Serialization and Parsing module based on Python's ElementTree.", + "devDependencies": { + "whiskey": "0.8.x" + }, + "directories": { + "lib": "lib" + }, + "engines": { + "node": ">= 0.4.0" + }, + "homepage": "https://github.com/racker/node-elementtree", + "keywords": [ + "xml", + "sax", + "parser", + "seralization", + "elementtree" + ], + "license": "Apache-2.0", + "main": "lib/elementtree.js", + "name": "elementtree", + "repository": { + "type": "git", + "url": "git://github.com/racker/node-elementtree.git" + }, + "scripts": { + "test": "make test" + }, + "version": "0.1.7" +} diff --git a/node_modules/cordova-common/node_modules/elementtree/tests/data/bom-xml.xml b/node_modules/cordova-common/node_modules/elementtree/tests/data/bom-xml.xml new file mode 100644 index 0000000000..122cce6265 --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/tests/data/bom-xml.xml @@ -0,0 +1,17 @@ + + + dd + test_object_1 + 4281c348eaf83e70ddce0e07221c3d28 + 14 + application/octetstream + 2009-02-03T05:26:32.612278 + + + test_object_2 + b039efe731ad111bc1b0ef221c3849d0 + 64 + application/octetstream + 2009-02-03T05:26:32.612278 + + diff --git a/node_modules/cordova-common/node_modules/elementtree/tests/data/xml1.xml b/node_modules/cordova-common/node_modules/elementtree/tests/data/xml1.xml new file mode 100644 index 0000000000..72c33aecee --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/tests/data/xml1.xml @@ -0,0 +1,17 @@ + + + dd + test_object_1 + 4281c348eaf83e70ddce0e07221c3d28 + 14 + application/octetstream + 2009-02-03T05:26:32.612278 + + + test_object_2 + b039efe731ad111bc1b0ef221c3849d0 + 64 + application/octetstream + 2009-02-03T05:26:32.612278 + + diff --git a/node_modules/cordova-common/node_modules/elementtree/tests/data/xml2.xml b/node_modules/cordova-common/node_modules/elementtree/tests/data/xml2.xml new file mode 100644 index 0000000000..5f94bbd9c4 --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/tests/data/xml2.xml @@ -0,0 +1,14 @@ + + + + Hello World + + + + + + + + diff --git a/node_modules/cordova-common/node_modules/elementtree/tests/test-simple.js b/node_modules/cordova-common/node_modules/elementtree/tests/test-simple.js new file mode 100644 index 0000000000..629a208626 --- /dev/null +++ b/node_modules/cordova-common/node_modules/elementtree/tests/test-simple.js @@ -0,0 +1,348 @@ +/** + * Copyright 2011 Rackspace + * + * Licensed 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 fs = require('fs'); +var path = require('path'); + +var sprintf = require('./../lib/sprintf').sprintf; +var et = require('elementtree'); +var XML = et.XML; +var ElementTree = et.ElementTree; +var Element = et.Element; +var SubElement = et.SubElement; +var SyntaxError = require('./../lib/errors').SyntaxError; + +function readFile(name) { + return fs.readFileSync(path.join(__dirname, '/data/', name), 'utf8'); +} + +exports['test_simplest'] = function(test, assert) { + /* Ported from */ + var Element = et.Element; + var root = Element('root'); + root.append(Element('one')); + root.append(Element('two')); + root.append(Element('three')); + assert.equal(3, root.len()); + assert.equal('one', root.getItem(0).tag); + assert.equal('two', root.getItem(1).tag); + assert.equal('three', root.getItem(2).tag); + test.finish(); +}; + + +exports['test_attribute_values'] = function(test, assert) { + var XML = et.XML; + var root = XML(''); + assert.equal('Alpha', root.attrib['alpha']); + assert.equal('Beta', root.attrib['beta']); + assert.equal('Gamma', root.attrib['gamma']); + test.finish(); +}; + + +exports['test_findall'] = function(test, assert) { + var XML = et.XML; + var root = XML(''); + + assert.equal(root.findall("c").length, 1); + assert.equal(root.findall(".//c").length, 2); + assert.equal(root.findall(".//b").length, 3); + assert.equal(root.findall(".//b")[0]._children.length, 1); + assert.equal(root.findall(".//b")[1]._children.length, 0); + assert.equal(root.findall(".//b")[2]._children.length, 0); + assert.deepEqual(root.findall('.//b')[0], root.getchildren()[0]); + + test.finish(); +}; + +exports['test_find'] = function(test, assert) { + var a = Element('a'); + var b = SubElement(a, 'b'); + var c = SubElement(a, 'c'); + + assert.deepEqual(a.find('./b/..'), a); + test.finish(); +}; + +exports['test_elementtree_find_qname'] = function(test, assert) { + var tree = new et.ElementTree(XML('')); + assert.deepEqual(tree.find(new et.QName('c')), tree.getroot()._children[2]); + test.finish(); +}; + +exports['test_attrib_ns_clear'] = function(test, assert) { + var attribNS = '{http://foo/bar}x'; + + var par = Element('par'); + par.set(attribNS, 'a'); + var child = SubElement(par, 'child'); + child.set(attribNS, 'b'); + + assert.equal('a', par.get(attribNS)); + assert.equal('b', child.get(attribNS)); + + par.clear(); + assert.equal(null, par.get(attribNS)); + assert.equal('b', child.get(attribNS)); + test.finish(); +}; + +exports['test_create_tree_and_parse_simple'] = function(test, assert) { + var i = 0; + var e = new Element('bar', {}); + var expected = "\n" + + 'ponies'; + + SubElement(e, "blah", {a: 11}); + SubElement(e, "blah", {a: 12}); + var se = et.SubElement(e, "gag", {a: '13', b: 'abc'}); + se.text = 'ponies'; + + se.itertext(function(text) { + assert.equal(text, 'ponies'); + i++; + }); + + assert.equal(i, 1); + var etree = new ElementTree(e); + var xml = etree.write(); + assert.equal(xml, expected); + test.finish(); +}; + +exports['test_write_with_options'] = function(test, assert) { + var i = 0; + var e = new Element('bar', {}); + var expected1 = "\n" + + '\n' + + ' \n' + + ' test\n' + + ' \n' + + ' \n' + + ' ponies\n' + + '\n'; + var expected2 = "\n" + + '\n' + + ' \n' + + ' test\n' + + ' \n' + + ' \n' + + ' ponies\n' + + '\n'; + + var expected3 = "\n" + + '\n' + + ' \n' + + ' Hello World\n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' Test & Test & Test\n' + + ' \n' + + '\n'; + + var se1 = SubElement(e, "blah", {a: 11}); + var se2 = SubElement(se1, "baz", {d: 11}); + se2.text = 'test'; + SubElement(e, "blah", {a: 12}); + var se = et.SubElement(e, "gag", {a: '13', b: 'abc'}); + se.text = 'ponies'; + + se.itertext(function(text) { + assert.equal(text, 'ponies'); + i++; + }); + + assert.equal(i, 1); + var etree = new ElementTree(e); + var xml1 = etree.write({'indent': 4}); + var xml2 = etree.write({'indent': 2}); + assert.equal(xml1, expected1); + assert.equal(xml2, expected2); + + var file = readFile('xml2.xml'); + var etree2 = et.parse(file); + var xml3 = etree2.write({'indent': 4}); + assert.equal(xml3, expected3); + test.finish(); +}; + +exports['test_parse_and_find_2'] = function(test, assert) { + var data = readFile('xml1.xml'); + var etree = et.parse(data); + + assert.equal(etree.findall('./object').length, 2); + assert.equal(etree.findall('[@name]').length, 1); + assert.equal(etree.findall('[@name="test_container_1"]').length, 1); + assert.equal(etree.findall('[@name=\'test_container_1\']').length, 1); + assert.equal(etree.findall('./object')[0].findtext('name'), 'test_object_1'); + assert.equal(etree.findtext('./object/name'), 'test_object_1'); + assert.equal(etree.findall('.//bytes').length, 2); + assert.equal(etree.findall('*/bytes').length, 2); + assert.equal(etree.findall('*/foobar').length, 0); + + test.finish(); +}; + +exports['test_namespaced_attribute'] = function(test, assert) { + var data = readFile('xml1.xml'); + var etree = et.parse(data); + + assert.equal(etree.findall('*/bytes[@android:type="cool"]').length, 1); + + test.finish(); +} + +exports['test_syntax_errors'] = function(test, assert) { + var expressions = [ './/@bar', '[@bar', '[@foo=bar]', '[@', '/bar' ]; + var errCount = 0; + var data = readFile('xml1.xml'); + var etree = et.parse(data); + + expressions.forEach(function(expression) { + try { + etree.findall(expression); + } + catch (err) { + errCount++; + } + }); + + assert.equal(errCount, expressions.length); + test.finish(); +}; + +exports['test_register_namespace'] = function(test, assert){ + var prefix = 'TESTPREFIX'; + var namespace = 'http://seriously.unknown/namespace/URI'; + var errCount = 0; + + var etree = Element(sprintf('{%s}test', namespace)); + assert.equal(et.tostring(etree, { 'xml_declaration': false}), + sprintf('', namespace)); + + et.register_namespace(prefix, namespace); + var etree = Element(sprintf('{%s}test', namespace)); + assert.equal(et.tostring(etree, { 'xml_declaration': false}), + sprintf('<%s:test xmlns:%s="%s" />', prefix, prefix, namespace)); + + try { + et.register_namespace('ns25', namespace); + } + catch (err) { + errCount++; + } + + assert.equal(errCount, 1, 'Reserved prefix used, but exception was not thrown'); + test.finish(); +}; + +exports['test_tostring'] = function(test, assert) { + var a = Element('a'); + var b = SubElement(a, 'b'); + var c = SubElement(a, 'c'); + c.text = 543; + + assert.equal(et.tostring(a, { 'xml_declaration': false }), '543'); + assert.equal(et.tostring(c, { 'xml_declaration': false }), '543'); + test.finish(); +}; + +exports['test_escape'] = function(test, assert) { + var a = Element('a'); + var b = SubElement(a, 'b'); + b.text = '&&&&<>"\n\r'; + + assert.equal(et.tostring(a, { 'xml_declaration': false }), '&&&&<>\"\n\r'); + test.finish(); +}; + +exports['test_find_null'] = function(test, assert) { + var root = Element('root'); + var node = SubElement(root, 'node'); + var leaf = SubElement(node, 'leaf'); + leaf.text = 'ipsum'; + + assert.equal(root.find('node/leaf'), leaf); + assert.equal(root.find('no-such-node/leaf'), null); + test.finish(); +}; + +exports['test_findtext_null'] = function(test, assert) { + var root = Element('root'); + var node = SubElement(root, 'node'); + var leaf = SubElement(node, 'leaf'); + leaf.text = 'ipsum'; + + assert.equal(root.findtext('node/leaf'), 'ipsum'); + assert.equal(root.findtext('no-such-node/leaf'), null); + test.finish(); +}; + +exports['test_remove'] = function(test, assert) { + var root = Element('root'); + var node1 = SubElement(root, 'node1'); + var node2 = SubElement(root, 'node2'); + var node3 = SubElement(root, 'node3'); + + assert.equal(root.len(), 3); + + root.remove(node2); + + assert.equal(root.len(), 2); + assert.equal(root.getItem(0).tag, 'node1') + assert.equal(root.getItem(1).tag, 'node3') + + test.finish(); +}; + +exports['test_cdata_write'] = function(test, assert) { + var root, etree, xml, values, value, i; + + values = [ + 'if(0>1) then true;', + 'ponies hello', + '' + ]; + + for (i = 0; i < values.length; i++) { + value = values[i]; + + root = Element('root'); + root.append(et.CData(value)); + etree = new ElementTree(root); + xml = etree.write({'xml_declaration': false}); + + assert.equal(xml, sprintf('', value)); + } + + test.finish(); +}; + +exports['test_read_bom'] = function(test, assert) { + var file = readFile('bom-xml.xml'); + var etree = et.parse(file); + + // If parse finished, test was successful + + test.finish(); +}; diff --git a/node_modules/osenv/LICENSE b/node_modules/cordova-common/node_modules/glob/LICENSE similarity index 100% rename from node_modules/osenv/LICENSE rename to node_modules/cordova-common/node_modules/glob/LICENSE diff --git a/node_modules/cordova-common/node_modules/glob/README.md b/node_modules/cordova-common/node_modules/glob/README.md new file mode 100644 index 0000000000..baa1d1ba86 --- /dev/null +++ b/node_modules/cordova-common/node_modules/glob/README.md @@ -0,0 +1,368 @@ +# Glob + +Match files using the patterns the shell uses, like stars and stuff. + +[![Build Status](https://travis-ci.org/isaacs/node-glob.svg?branch=master)](https://travis-ci.org/isaacs/node-glob/) [![Build Status](https://ci.appveyor.com/api/projects/status/kd7f3yftf7unxlsx?svg=true)](https://ci.appveyor.com/project/isaacs/node-glob) [![Coverage Status](https://coveralls.io/repos/isaacs/node-glob/badge.svg?branch=master&service=github)](https://coveralls.io/github/isaacs/node-glob?branch=master) + +This is a glob implementation in JavaScript. It uses the `minimatch` +library to do its matching. + +![](oh-my-glob.gif) + +## Usage + +Install with npm + +``` +npm i glob +``` + +```javascript +var glob = require("glob") + +// options is optional +glob("**/*.js", options, function (er, files) { + // files is an array of filenames. + // If the `nonull` option is set, and nothing + // was found, then files is ["**/*.js"] + // er is an error object or null. +}) +``` + +## Glob Primer + +"Globs" are the patterns you type when you do stuff like `ls *.js` on +the command line, or put `build/*` in a `.gitignore` file. + +Before parsing the path part patterns, braced sections are expanded +into a set. Braced sections start with `{` and end with `}`, with any +number of comma-delimited sections within. Braced sections may contain +slash characters, so `a{/b/c,bcd}` would expand into `a/b/c` and `abcd`. + +The following characters have special magic meaning when used in a +path portion: + +* `*` Matches 0 or more characters in a single path portion +* `?` Matches 1 character +* `[...]` Matches a range of characters, similar to a RegExp range. + If the first character of the range is `!` or `^` then it matches + any character not in the range. +* `!(pattern|pattern|pattern)` Matches anything that does not match + any of the patterns provided. +* `?(pattern|pattern|pattern)` Matches zero or one occurrence of the + patterns provided. +* `+(pattern|pattern|pattern)` Matches one or more occurrences of the + patterns provided. +* `*(a|b|c)` Matches zero or more occurrences of the patterns provided +* `@(pattern|pat*|pat?erN)` Matches exactly one of the patterns + provided +* `**` If a "globstar" is alone in a path portion, then it matches + zero or more directories and subdirectories searching for matches. + It does not crawl symlinked directories. + +### Dots + +If a file or directory path portion has a `.` as the first character, +then it will not match any glob pattern unless that pattern's +corresponding path part also has a `.` as its first character. + +For example, the pattern `a/.*/c` would match the file at `a/.b/c`. +However the pattern `a/*/c` would not, because `*` does not start with +a dot character. + +You can make glob treat dots as normal characters by setting +`dot:true` in the options. + +### Basename Matching + +If you set `matchBase:true` in the options, and the pattern has no +slashes in it, then it will seek for any file anywhere in the tree +with a matching basename. For example, `*.js` would match +`test/simple/basic.js`. + +### Empty Sets + +If no matching files are found, then an empty array is returned. This +differs from the shell, where the pattern itself is returned. For +example: + + $ echo a*s*d*f + a*s*d*f + +To get the bash-style behavior, set the `nonull:true` in the options. + +### See Also: + +* `man sh` +* `man bash` (Search for "Pattern Matching") +* `man 3 fnmatch` +* `man 5 gitignore` +* [minimatch documentation](https://github.com/isaacs/minimatch) + +## glob.hasMagic(pattern, [options]) + +Returns `true` if there are any special characters in the pattern, and +`false` otherwise. + +Note that the options affect the results. If `noext:true` is set in +the options object, then `+(a|b)` will not be considered a magic +pattern. If the pattern has a brace expansion, like `a/{b/c,x/y}` +then that is considered magical, unless `nobrace:true` is set in the +options. + +## glob(pattern, [options], cb) + +* `pattern` `{String}` Pattern to be matched +* `options` `{Object}` +* `cb` `{Function}` + * `err` `{Error | null}` + * `matches` `{Array}` filenames found matching the pattern + +Perform an asynchronous glob search. + +## glob.sync(pattern, [options]) + +* `pattern` `{String}` Pattern to be matched +* `options` `{Object}` +* return: `{Array}` filenames found matching the pattern + +Perform a synchronous glob search. + +## Class: glob.Glob + +Create a Glob object by instantiating the `glob.Glob` class. + +```javascript +var Glob = require("glob").Glob +var mg = new Glob(pattern, options, cb) +``` + +It's an EventEmitter, and starts walking the filesystem to find matches +immediately. + +### new glob.Glob(pattern, [options], [cb]) + +* `pattern` `{String}` pattern to search for +* `options` `{Object}` +* `cb` `{Function}` Called when an error occurs, or matches are found + * `err` `{Error | null}` + * `matches` `{Array}` filenames found matching the pattern + +Note that if the `sync` flag is set in the options, then matches will +be immediately available on the `g.found` member. + +### Properties + +* `minimatch` The minimatch object that the glob uses. +* `options` The options object passed in. +* `aborted` Boolean which is set to true when calling `abort()`. There + is no way at this time to continue a glob search after aborting, but + you can re-use the statCache to avoid having to duplicate syscalls. +* `cache` Convenience object. Each field has the following possible + values: + * `false` - Path does not exist + * `true` - Path exists + * `'FILE'` - Path exists, and is not a directory + * `'DIR'` - Path exists, and is a directory + * `[file, entries, ...]` - Path exists, is a directory, and the + array value is the results of `fs.readdir` +* `statCache` Cache of `fs.stat` results, to prevent statting the same + path multiple times. +* `symlinks` A record of which paths are symbolic links, which is + relevant in resolving `**` patterns. +* `realpathCache` An optional object which is passed to `fs.realpath` + to minimize unnecessary syscalls. It is stored on the instantiated + Glob object, and may be re-used. + +### Events + +* `end` When the matching is finished, this is emitted with all the + matches found. If the `nonull` option is set, and no match was found, + then the `matches` list contains the original pattern. The matches + are sorted, unless the `nosort` flag is set. +* `match` Every time a match is found, this is emitted with the specific + thing that matched. It is not deduplicated or resolved to a realpath. +* `error` Emitted when an unexpected error is encountered, or whenever + any fs error occurs if `options.strict` is set. +* `abort` When `abort()` is called, this event is raised. + +### Methods + +* `pause` Temporarily stop the search +* `resume` Resume the search +* `abort` Stop the search forever + +### Options + +All the options that can be passed to Minimatch can also be passed to +Glob to change pattern matching behavior. Also, some have been added, +or have glob-specific ramifications. + +All options are false by default, unless otherwise noted. + +All options are added to the Glob object, as well. + +If you are running many `glob` operations, you can pass a Glob object +as the `options` argument to a subsequent operation to shortcut some +`stat` and `readdir` calls. At the very least, you may pass in shared +`symlinks`, `statCache`, `realpathCache`, and `cache` options, so that +parallel glob operations will be sped up by sharing information about +the filesystem. + +* `cwd` The current working directory in which to search. Defaults + to `process.cwd()`. +* `root` The place where patterns starting with `/` will be mounted + onto. Defaults to `path.resolve(options.cwd, "/")` (`/` on Unix + systems, and `C:\` or some such on Windows.) +* `dot` Include `.dot` files in normal matches and `globstar` matches. + Note that an explicit dot in a portion of the pattern will always + match dot files. +* `nomount` By default, a pattern starting with a forward-slash will be + "mounted" onto the root setting, so that a valid filesystem path is + returned. Set this flag to disable that behavior. +* `mark` Add a `/` character to directory matches. Note that this + requires additional stat calls. +* `nosort` Don't sort the results. +* `stat` Set to true to stat *all* results. This reduces performance + somewhat, and is completely unnecessary, unless `readdir` is presumed + to be an untrustworthy indicator of file existence. +* `silent` When an unusual error is encountered when attempting to + read a directory, a warning will be printed to stderr. Set the + `silent` option to true to suppress these warnings. +* `strict` When an unusual error is encountered when attempting to + read a directory, the process will just continue on in search of + other matches. Set the `strict` option to raise an error in these + cases. +* `cache` See `cache` property above. Pass in a previously generated + cache object to save some fs calls. +* `statCache` A cache of results of filesystem information, to prevent + unnecessary stat calls. While it should not normally be necessary + to set this, you may pass the statCache from one glob() call to the + options object of another, if you know that the filesystem will not + change between calls. (See "Race Conditions" below.) +* `symlinks` A cache of known symbolic links. You may pass in a + previously generated `symlinks` object to save `lstat` calls when + resolving `**` matches. +* `sync` DEPRECATED: use `glob.sync(pattern, opts)` instead. +* `nounique` In some cases, brace-expanded patterns can result in the + same file showing up multiple times in the result set. By default, + this implementation prevents duplicates in the result set. Set this + flag to disable that behavior. +* `nonull` Set to never return an empty set, instead returning a set + containing the pattern itself. This is the default in glob(3). +* `debug` Set to enable debug logging in minimatch and glob. +* `nobrace` Do not expand `{a,b}` and `{1..3}` brace sets. +* `noglobstar` Do not match `**` against multiple filenames. (Ie, + treat it as a normal `*` instead.) +* `noext` Do not match `+(a|b)` "extglob" patterns. +* `nocase` Perform a case-insensitive match. Note: on + case-insensitive filesystems, non-magic patterns will match by + default, since `stat` and `readdir` will not raise errors. +* `matchBase` Perform a basename-only match if the pattern does not + contain any slash characters. That is, `*.js` would be treated as + equivalent to `**/*.js`, matching all js files in all directories. +* `nodir` Do not match directories, only files. (Note: to match + *only* directories, simply put a `/` at the end of the pattern.) +* `ignore` Add a pattern or an array of glob patterns to exclude matches. + Note: `ignore` patterns are *always* in `dot:true` mode, regardless + of any other settings. +* `follow` Follow symlinked directories when expanding `**` patterns. + Note that this can result in a lot of duplicate references in the + presence of cyclic links. +* `realpath` Set to true to call `fs.realpath` on all of the results. + In the case of a symlink that cannot be resolved, the full absolute + path to the matched entry is returned (though it will usually be a + broken symlink) +* `absolute` Set to true to always receive absolute paths for matched + files. Unlike `realpath`, this also affects the values returned in + the `match` event. + +## Comparisons to other fnmatch/glob implementations + +While strict compliance with the existing standards is a worthwhile +goal, some discrepancies exist between node-glob and other +implementations, and are intentional. + +The double-star character `**` is supported by default, unless the +`noglobstar` flag is set. This is supported in the manner of bsdglob +and bash 4.3, where `**` only has special significance if it is the only +thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but +`a/**b` will not. + +Note that symlinked directories are not crawled as part of a `**`, +though their contents may match against subsequent portions of the +pattern. This prevents infinite loops and duplicates and the like. + +If an escaped pattern has no matches, and the `nonull` flag is set, +then glob returns the pattern as-provided, rather than +interpreting the character escapes. For example, +`glob.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than +`"*a?"`. This is akin to setting the `nullglob` option in bash, except +that it does not resolve escaped pattern characters. + +If brace expansion is not disabled, then it is performed before any +other interpretation of the glob pattern. Thus, a pattern like +`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded +**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are +checked for validity. Since those two are valid, matching proceeds. + +### Comments and Negation + +Previously, this module let you mark a pattern as a "comment" if it +started with a `#` character, or a "negated" pattern if it started +with a `!` character. + +These options were deprecated in version 5, and removed in version 6. + +To specify things that should not match, use the `ignore` option. + +## Windows + +**Please only use forward-slashes in glob expressions.** + +Though windows uses either `/` or `\` as its path separator, only `/` +characters are used by this glob implementation. You must use +forward-slashes **only** in glob expressions. Back-slashes will always +be interpreted as escape characters, not path separators. + +Results from absolute patterns such as `/foo/*` are mounted onto the +root setting using `path.join`. On windows, this will by default result +in `/foo/*` matching `C:\foo\bar.txt`. + +## Race Conditions + +Glob searching, by its very nature, is susceptible to race conditions, +since it relies on directory walking and such. + +As a result, it is possible that a file that exists when glob looks for +it may have been deleted or modified by the time it returns the result. + +As part of its internal implementation, this program caches all stat +and readdir calls that it makes, in order to cut down on system +overhead. However, this also makes it even more susceptible to races, +especially if the cache or statCache objects are reused between glob +calls. + +Users are thus advised not to use a glob result as a guarantee of +filesystem state in the face of rapid changes. For the vast majority +of operations, this is never a problem. + +## Contributing + +Any change to behavior (including bugfixes) must come with a test. + +Patches that fail tests or reduce performance will be rejected. + +``` +# to run tests +npm test + +# to re-generate test fixtures +npm run test-regen + +# to benchmark against bash/zsh +npm run bench + +# to profile javascript +npm run prof +``` diff --git a/node_modules/cordova-common/node_modules/glob/changelog.md b/node_modules/cordova-common/node_modules/glob/changelog.md new file mode 100644 index 0000000000..41636771e3 --- /dev/null +++ b/node_modules/cordova-common/node_modules/glob/changelog.md @@ -0,0 +1,67 @@ +## 7.0 + +- Raise error if `options.cwd` is specified, and not a directory + +## 6.0 + +- Remove comment and negation pattern support +- Ignore patterns are always in `dot:true` mode + +## 5.0 + +- Deprecate comment and negation patterns +- Fix regression in `mark` and `nodir` options from making all cache + keys absolute path. +- Abort if `fs.readdir` returns an error that's unexpected +- Don't emit `match` events for ignored items +- Treat ENOTSUP like ENOTDIR in readdir + +## 4.5 + +- Add `options.follow` to always follow directory symlinks in globstar +- Add `options.realpath` to call `fs.realpath` on all results +- Always cache based on absolute path + +## 4.4 + +- Add `options.ignore` +- Fix handling of broken symlinks + +## 4.3 + +- Bump minimatch to 2.x +- Pass all tests on Windows + +## 4.2 + +- Add `glob.hasMagic` function +- Add `options.nodir` flag + +## 4.1 + +- Refactor sync and async implementations for performance +- Throw if callback provided to sync glob function +- Treat symbolic links in globstar results the same as Bash 4.3 + +## 4.0 + +- Use `^` for dependency versions (bumped major because this breaks + older npm versions) +- Ensure callbacks are only ever called once +- switch to ISC license + +## 3.x + +- Rewrite in JavaScript +- Add support for setting root, cwd, and windows support +- Cache many fs calls +- Add globstar support +- emit match events + +## 2.x + +- Use `glob.h` and `fnmatch.h` from NetBSD + +## 1.x + +- `glob.h` static binding. diff --git a/node_modules/cordova-common/node_modules/glob/common.js b/node_modules/cordova-common/node_modules/glob/common.js new file mode 100644 index 0000000000..66651bb3aa --- /dev/null +++ b/node_modules/cordova-common/node_modules/glob/common.js @@ -0,0 +1,240 @@ +exports.alphasort = alphasort +exports.alphasorti = alphasorti +exports.setopts = setopts +exports.ownProp = ownProp +exports.makeAbs = makeAbs +exports.finish = finish +exports.mark = mark +exports.isIgnored = isIgnored +exports.childrenIgnored = childrenIgnored + +function ownProp (obj, field) { + return Object.prototype.hasOwnProperty.call(obj, field) +} + +var path = require("path") +var minimatch = require("minimatch") +var isAbsolute = require("path-is-absolute") +var Minimatch = minimatch.Minimatch + +function alphasorti (a, b) { + return a.toLowerCase().localeCompare(b.toLowerCase()) +} + +function alphasort (a, b) { + return a.localeCompare(b) +} + +function setupIgnores (self, options) { + self.ignore = options.ignore || [] + + if (!Array.isArray(self.ignore)) + self.ignore = [self.ignore] + + if (self.ignore.length) { + self.ignore = self.ignore.map(ignoreMap) + } +} + +// ignore patterns are always in dot:true mode. +function ignoreMap (pattern) { + var gmatcher = null + if (pattern.slice(-3) === '/**') { + var gpattern = pattern.replace(/(\/\*\*)+$/, '') + gmatcher = new Minimatch(gpattern, { dot: true }) + } + + return { + matcher: new Minimatch(pattern, { dot: true }), + gmatcher: gmatcher + } +} + +function setopts (self, pattern, options) { + if (!options) + options = {} + + // base-matching: just use globstar for that. + if (options.matchBase && -1 === pattern.indexOf("/")) { + if (options.noglobstar) { + throw new Error("base matching requires globstar") + } + pattern = "**/" + pattern + } + + self.silent = !!options.silent + self.pattern = pattern + self.strict = options.strict !== false + self.realpath = !!options.realpath + self.realpathCache = options.realpathCache || Object.create(null) + self.follow = !!options.follow + self.dot = !!options.dot + self.mark = !!options.mark + self.nodir = !!options.nodir + if (self.nodir) + self.mark = true + self.sync = !!options.sync + self.nounique = !!options.nounique + self.nonull = !!options.nonull + self.nosort = !!options.nosort + self.nocase = !!options.nocase + self.stat = !!options.stat + self.noprocess = !!options.noprocess + self.absolute = !!options.absolute + + self.maxLength = options.maxLength || Infinity + self.cache = options.cache || Object.create(null) + self.statCache = options.statCache || Object.create(null) + self.symlinks = options.symlinks || Object.create(null) + + setupIgnores(self, options) + + self.changedCwd = false + var cwd = process.cwd() + if (!ownProp(options, "cwd")) + self.cwd = cwd + else { + self.cwd = path.resolve(options.cwd) + self.changedCwd = self.cwd !== cwd + } + + self.root = options.root || path.resolve(self.cwd, "/") + self.root = path.resolve(self.root) + if (process.platform === "win32") + self.root = self.root.replace(/\\/g, "/") + + // TODO: is an absolute `cwd` supposed to be resolved against `root`? + // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test') + self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd) + if (process.platform === "win32") + self.cwdAbs = self.cwdAbs.replace(/\\/g, "/") + self.nomount = !!options.nomount + + // disable comments and negation in Minimatch. + // Note that they are not supported in Glob itself anyway. + options.nonegate = true + options.nocomment = true + + self.minimatch = new Minimatch(pattern, options) + self.options = self.minimatch.options +} + +function finish (self) { + var nou = self.nounique + var all = nou ? [] : Object.create(null) + + for (var i = 0, l = self.matches.length; i < l; i ++) { + var matches = self.matches[i] + if (!matches || Object.keys(matches).length === 0) { + if (self.nonull) { + // do like the shell, and spit out the literal glob + var literal = self.minimatch.globSet[i] + if (nou) + all.push(literal) + else + all[literal] = true + } + } else { + // had matches + var m = Object.keys(matches) + if (nou) + all.push.apply(all, m) + else + m.forEach(function (m) { + all[m] = true + }) + } + } + + if (!nou) + all = Object.keys(all) + + if (!self.nosort) + all = all.sort(self.nocase ? alphasorti : alphasort) + + // at *some* point we statted all of these + if (self.mark) { + for (var i = 0; i < all.length; i++) { + all[i] = self._mark(all[i]) + } + if (self.nodir) { + all = all.filter(function (e) { + var notDir = !(/\/$/.test(e)) + var c = self.cache[e] || self.cache[makeAbs(self, e)] + if (notDir && c) + notDir = c !== 'DIR' && !Array.isArray(c) + return notDir + }) + } + } + + if (self.ignore.length) + all = all.filter(function(m) { + return !isIgnored(self, m) + }) + + self.found = all +} + +function mark (self, p) { + var abs = makeAbs(self, p) + var c = self.cache[abs] + var m = p + if (c) { + var isDir = c === 'DIR' || Array.isArray(c) + var slash = p.slice(-1) === '/' + + if (isDir && !slash) + m += '/' + else if (!isDir && slash) + m = m.slice(0, -1) + + if (m !== p) { + var mabs = makeAbs(self, m) + self.statCache[mabs] = self.statCache[abs] + self.cache[mabs] = self.cache[abs] + } + } + + return m +} + +// lotta situps... +function makeAbs (self, f) { + var abs = f + if (f.charAt(0) === '/') { + abs = path.join(self.root, f) + } else if (isAbsolute(f) || f === '') { + abs = f + } else if (self.changedCwd) { + abs = path.resolve(self.cwd, f) + } else { + abs = path.resolve(f) + } + + if (process.platform === 'win32') + abs = abs.replace(/\\/g, '/') + + return abs +} + + +// Return true, if pattern ends with globstar '**', for the accompanying parent directory. +// Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents +function isIgnored (self, path) { + if (!self.ignore.length) + return false + + return self.ignore.some(function(item) { + return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path)) + }) +} + +function childrenIgnored (self, path) { + if (!self.ignore.length) + return false + + return self.ignore.some(function(item) { + return !!(item.gmatcher && item.gmatcher.match(path)) + }) +} diff --git a/node_modules/cordova-common/node_modules/glob/glob.js b/node_modules/cordova-common/node_modules/glob/glob.js new file mode 100644 index 0000000000..58dec0f6c2 --- /dev/null +++ b/node_modules/cordova-common/node_modules/glob/glob.js @@ -0,0 +1,790 @@ +// Approach: +// +// 1. Get the minimatch set +// 2. For each pattern in the set, PROCESS(pattern, false) +// 3. Store matches per-set, then uniq them +// +// PROCESS(pattern, inGlobStar) +// Get the first [n] items from pattern that are all strings +// Join these together. This is PREFIX. +// If there is no more remaining, then stat(PREFIX) and +// add to matches if it succeeds. END. +// +// If inGlobStar and PREFIX is symlink and points to dir +// set ENTRIES = [] +// else readdir(PREFIX) as ENTRIES +// If fail, END +// +// with ENTRIES +// If pattern[n] is GLOBSTAR +// // handle the case where the globstar match is empty +// // by pruning it out, and testing the resulting pattern +// PROCESS(pattern[0..n] + pattern[n+1 .. $], false) +// // handle other cases. +// for ENTRY in ENTRIES (not dotfiles) +// // attach globstar + tail onto the entry +// // Mark that this entry is a globstar match +// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true) +// +// else // not globstar +// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot) +// Test ENTRY against pattern[n] +// If fails, continue +// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $]) +// +// Caveat: +// Cache all stats and readdirs results to minimize syscall. Since all +// we ever care about is existence and directory-ness, we can just keep +// `true` for files, and [children,...] for directories, or `false` for +// things that don't exist. + +module.exports = glob + +var fs = require('fs') +var rp = require('fs.realpath') +var minimatch = require('minimatch') +var Minimatch = minimatch.Minimatch +var inherits = require('inherits') +var EE = require('events').EventEmitter +var path = require('path') +var assert = require('assert') +var isAbsolute = require('path-is-absolute') +var globSync = require('./sync.js') +var common = require('./common.js') +var alphasort = common.alphasort +var alphasorti = common.alphasorti +var setopts = common.setopts +var ownProp = common.ownProp +var inflight = require('inflight') +var util = require('util') +var childrenIgnored = common.childrenIgnored +var isIgnored = common.isIgnored + +var once = require('once') + +function glob (pattern, options, cb) { + if (typeof options === 'function') cb = options, options = {} + if (!options) options = {} + + if (options.sync) { + if (cb) + throw new TypeError('callback provided to sync glob') + return globSync(pattern, options) + } + + return new Glob(pattern, options, cb) +} + +glob.sync = globSync +var GlobSync = glob.GlobSync = globSync.GlobSync + +// old api surface +glob.glob = glob + +function extend (origin, add) { + if (add === null || typeof add !== 'object') { + return origin + } + + var keys = Object.keys(add) + var i = keys.length + while (i--) { + origin[keys[i]] = add[keys[i]] + } + return origin +} + +glob.hasMagic = function (pattern, options_) { + var options = extend({}, options_) + options.noprocess = true + + var g = new Glob(pattern, options) + var set = g.minimatch.set + + if (!pattern) + return false + + if (set.length > 1) + return true + + for (var j = 0; j < set[0].length; j++) { + if (typeof set[0][j] !== 'string') + return true + } + + return false +} + +glob.Glob = Glob +inherits(Glob, EE) +function Glob (pattern, options, cb) { + if (typeof options === 'function') { + cb = options + options = null + } + + if (options && options.sync) { + if (cb) + throw new TypeError('callback provided to sync glob') + return new GlobSync(pattern, options) + } + + if (!(this instanceof Glob)) + return new Glob(pattern, options, cb) + + setopts(this, pattern, options) + this._didRealPath = false + + // process each pattern in the minimatch set + var n = this.minimatch.set.length + + // The matches are stored as {: true,...} so that + // duplicates are automagically pruned. + // Later, we do an Object.keys() on these. + // Keep them as a list so we can fill in when nonull is set. + this.matches = new Array(n) + + if (typeof cb === 'function') { + cb = once(cb) + this.on('error', cb) + this.on('end', function (matches) { + cb(null, matches) + }) + } + + var self = this + this._processing = 0 + + this._emitQueue = [] + this._processQueue = [] + this.paused = false + + if (this.noprocess) + return this + + if (n === 0) + return done() + + var sync = true + for (var i = 0; i < n; i ++) { + this._process(this.minimatch.set[i], i, false, done) + } + sync = false + + function done () { + --self._processing + if (self._processing <= 0) { + if (sync) { + process.nextTick(function () { + self._finish() + }) + } else { + self._finish() + } + } + } +} + +Glob.prototype._finish = function () { + assert(this instanceof Glob) + if (this.aborted) + return + + if (this.realpath && !this._didRealpath) + return this._realpath() + + common.finish(this) + this.emit('end', this.found) +} + +Glob.prototype._realpath = function () { + if (this._didRealpath) + return + + this._didRealpath = true + + var n = this.matches.length + if (n === 0) + return this._finish() + + var self = this + for (var i = 0; i < this.matches.length; i++) + this._realpathSet(i, next) + + function next () { + if (--n === 0) + self._finish() + } +} + +Glob.prototype._realpathSet = function (index, cb) { + var matchset = this.matches[index] + if (!matchset) + return cb() + + var found = Object.keys(matchset) + var self = this + var n = found.length + + if (n === 0) + return cb() + + var set = this.matches[index] = Object.create(null) + found.forEach(function (p, i) { + // If there's a problem with the stat, then it means that + // one or more of the links in the realpath couldn't be + // resolved. just return the abs value in that case. + p = self._makeAbs(p) + rp.realpath(p, self.realpathCache, function (er, real) { + if (!er) + set[real] = true + else if (er.syscall === 'stat') + set[p] = true + else + self.emit('error', er) // srsly wtf right here + + if (--n === 0) { + self.matches[index] = set + cb() + } + }) + }) +} + +Glob.prototype._mark = function (p) { + return common.mark(this, p) +} + +Glob.prototype._makeAbs = function (f) { + return common.makeAbs(this, f) +} + +Glob.prototype.abort = function () { + this.aborted = true + this.emit('abort') +} + +Glob.prototype.pause = function () { + if (!this.paused) { + this.paused = true + this.emit('pause') + } +} + +Glob.prototype.resume = function () { + if (this.paused) { + this.emit('resume') + this.paused = false + if (this._emitQueue.length) { + var eq = this._emitQueue.slice(0) + this._emitQueue.length = 0 + for (var i = 0; i < eq.length; i ++) { + var e = eq[i] + this._emitMatch(e[0], e[1]) + } + } + if (this._processQueue.length) { + var pq = this._processQueue.slice(0) + this._processQueue.length = 0 + for (var i = 0; i < pq.length; i ++) { + var p = pq[i] + this._processing-- + this._process(p[0], p[1], p[2], p[3]) + } + } + } +} + +Glob.prototype._process = function (pattern, index, inGlobStar, cb) { + assert(this instanceof Glob) + assert(typeof cb === 'function') + + if (this.aborted) + return + + this._processing++ + if (this.paused) { + this._processQueue.push([pattern, index, inGlobStar, cb]) + return + } + + //console.error('PROCESS %d', this._processing, pattern) + + // Get the first [n] parts of pattern that are all strings. + var n = 0 + while (typeof pattern[n] === 'string') { + n ++ + } + // now n is the index of the first one that is *not* a string. + + // see if there's anything else + var prefix + switch (n) { + // if not, then this is rather simple + case pattern.length: + this._processSimple(pattern.join('/'), index, cb) + return + + case 0: + // pattern *starts* with some non-trivial item. + // going to readdir(cwd), but not include the prefix in matches. + prefix = null + break + + default: + // pattern has some string bits in the front. + // whatever it starts with, whether that's 'absolute' like /foo/bar, + // or 'relative' like '../baz' + prefix = pattern.slice(0, n).join('/') + break + } + + var remain = pattern.slice(n) + + // get the list of entries. + var read + if (prefix === null) + read = '.' + else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { + if (!prefix || !isAbsolute(prefix)) + prefix = '/' + prefix + read = prefix + } else + read = prefix + + var abs = this._makeAbs(read) + + //if ignored, skip _processing + if (childrenIgnored(this, read)) + return cb() + + var isGlobStar = remain[0] === minimatch.GLOBSTAR + if (isGlobStar) + this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb) + else + this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb) +} + +Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) { + var self = this + this._readdir(abs, inGlobStar, function (er, entries) { + return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb) + }) +} + +Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { + + // if the abs isn't a dir, then nothing can match! + if (!entries) + return cb() + + // It will only match dot entries if it starts with a dot, or if + // dot is set. Stuff like @(.foo|.bar) isn't allowed. + var pn = remain[0] + var negate = !!this.minimatch.negate + var rawGlob = pn._glob + var dotOk = this.dot || rawGlob.charAt(0) === '.' + + var matchedEntries = [] + for (var i = 0; i < entries.length; i++) { + var e = entries[i] + if (e.charAt(0) !== '.' || dotOk) { + var m + if (negate && !prefix) { + m = !e.match(pn) + } else { + m = e.match(pn) + } + if (m) + matchedEntries.push(e) + } + } + + //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries) + + var len = matchedEntries.length + // If there are no matched entries, then nothing matches. + if (len === 0) + return cb() + + // if this is the last remaining pattern bit, then no need for + // an additional stat *unless* the user has specified mark or + // stat explicitly. We know they exist, since readdir returned + // them. + + if (remain.length === 1 && !this.mark && !this.stat) { + if (!this.matches[index]) + this.matches[index] = Object.create(null) + + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + if (prefix) { + if (prefix !== '/') + e = prefix + '/' + e + else + e = prefix + e + } + + if (e.charAt(0) === '/' && !this.nomount) { + e = path.join(this.root, e) + } + this._emitMatch(index, e) + } + // This was the last one, and no stats were needed + return cb() + } + + // now test all matched entries as stand-ins for that part + // of the pattern. + remain.shift() + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + var newPattern + if (prefix) { + if (prefix !== '/') + e = prefix + '/' + e + else + e = prefix + e + } + this._process([e].concat(remain), index, inGlobStar, cb) + } + cb() +} + +Glob.prototype._emitMatch = function (index, e) { + if (this.aborted) + return + + if (isIgnored(this, e)) + return + + if (this.paused) { + this._emitQueue.push([index, e]) + return + } + + var abs = isAbsolute(e) ? e : this._makeAbs(e) + + if (this.mark) + e = this._mark(e) + + if (this.absolute) + e = abs + + if (this.matches[index][e]) + return + + if (this.nodir) { + var c = this.cache[abs] + if (c === 'DIR' || Array.isArray(c)) + return + } + + this.matches[index][e] = true + + var st = this.statCache[abs] + if (st) + this.emit('stat', e, st) + + this.emit('match', e) +} + +Glob.prototype._readdirInGlobStar = function (abs, cb) { + if (this.aborted) + return + + // follow all symlinked directories forever + // just proceed as if this is a non-globstar situation + if (this.follow) + return this._readdir(abs, false, cb) + + var lstatkey = 'lstat\0' + abs + var self = this + var lstatcb = inflight(lstatkey, lstatcb_) + + if (lstatcb) + fs.lstat(abs, lstatcb) + + function lstatcb_ (er, lstat) { + if (er && er.code === 'ENOENT') + return cb() + + var isSym = lstat && lstat.isSymbolicLink() + self.symlinks[abs] = isSym + + // If it's not a symlink or a dir, then it's definitely a regular file. + // don't bother doing a readdir in that case. + if (!isSym && lstat && !lstat.isDirectory()) { + self.cache[abs] = 'FILE' + cb() + } else + self._readdir(abs, false, cb) + } +} + +Glob.prototype._readdir = function (abs, inGlobStar, cb) { + if (this.aborted) + return + + cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb) + if (!cb) + return + + //console.error('RD %j %j', +inGlobStar, abs) + if (inGlobStar && !ownProp(this.symlinks, abs)) + return this._readdirInGlobStar(abs, cb) + + if (ownProp(this.cache, abs)) { + var c = this.cache[abs] + if (!c || c === 'FILE') + return cb() + + if (Array.isArray(c)) + return cb(null, c) + } + + var self = this + fs.readdir(abs, readdirCb(this, abs, cb)) +} + +function readdirCb (self, abs, cb) { + return function (er, entries) { + if (er) + self._readdirError(abs, er, cb) + else + self._readdirEntries(abs, entries, cb) + } +} + +Glob.prototype._readdirEntries = function (abs, entries, cb) { + if (this.aborted) + return + + // if we haven't asked to stat everything, then just + // assume that everything in there exists, so we can avoid + // having to stat it a second time. + if (!this.mark && !this.stat) { + for (var i = 0; i < entries.length; i ++) { + var e = entries[i] + if (abs === '/') + e = abs + e + else + e = abs + '/' + e + this.cache[e] = true + } + } + + this.cache[abs] = entries + return cb(null, entries) +} + +Glob.prototype._readdirError = function (f, er, cb) { + if (this.aborted) + return + + // handle errors, and cache the information + switch (er.code) { + case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 + case 'ENOTDIR': // totally normal. means it *does* exist. + var abs = this._makeAbs(f) + this.cache[abs] = 'FILE' + if (abs === this.cwdAbs) { + var error = new Error(er.code + ' invalid cwd ' + this.cwd) + error.path = this.cwd + error.code = er.code + this.emit('error', error) + this.abort() + } + break + + case 'ENOENT': // not terribly unusual + case 'ELOOP': + case 'ENAMETOOLONG': + case 'UNKNOWN': + this.cache[this._makeAbs(f)] = false + break + + default: // some unusual error. Treat as failure. + this.cache[this._makeAbs(f)] = false + if (this.strict) { + this.emit('error', er) + // If the error is handled, then we abort + // if not, we threw out of here + this.abort() + } + if (!this.silent) + console.error('glob error', er) + break + } + + return cb() +} + +Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) { + var self = this + this._readdir(abs, inGlobStar, function (er, entries) { + self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb) + }) +} + + +Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { + //console.error('pgs2', prefix, remain[0], entries) + + // no entries means not a dir, so it can never have matches + // foo.txt/** doesn't match foo.txt + if (!entries) + return cb() + + // test without the globstar, and with every child both below + // and replacing the globstar. + var remainWithoutGlobStar = remain.slice(1) + var gspref = prefix ? [ prefix ] : [] + var noGlobStar = gspref.concat(remainWithoutGlobStar) + + // the noGlobStar pattern exits the inGlobStar state + this._process(noGlobStar, index, false, cb) + + var isSym = this.symlinks[abs] + var len = entries.length + + // If it's a symlink, and we're in a globstar, then stop + if (isSym && inGlobStar) + return cb() + + for (var i = 0; i < len; i++) { + var e = entries[i] + if (e.charAt(0) === '.' && !this.dot) + continue + + // these two cases enter the inGlobStar state + var instead = gspref.concat(entries[i], remainWithoutGlobStar) + this._process(instead, index, true, cb) + + var below = gspref.concat(entries[i], remain) + this._process(below, index, true, cb) + } + + cb() +} + +Glob.prototype._processSimple = function (prefix, index, cb) { + // XXX review this. Shouldn't it be doing the mounting etc + // before doing stat? kinda weird? + var self = this + this._stat(prefix, function (er, exists) { + self._processSimple2(prefix, index, er, exists, cb) + }) +} +Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) { + + //console.error('ps2', prefix, exists) + + if (!this.matches[index]) + this.matches[index] = Object.create(null) + + // If it doesn't exist, then just mark the lack of results + if (!exists) + return cb() + + if (prefix && isAbsolute(prefix) && !this.nomount) { + var trail = /[\/\\]$/.test(prefix) + if (prefix.charAt(0) === '/') { + prefix = path.join(this.root, prefix) + } else { + prefix = path.resolve(this.root, prefix) + if (trail) + prefix += '/' + } + } + + if (process.platform === 'win32') + prefix = prefix.replace(/\\/g, '/') + + // Mark this as a match + this._emitMatch(index, prefix) + cb() +} + +// Returns either 'DIR', 'FILE', or false +Glob.prototype._stat = function (f, cb) { + var abs = this._makeAbs(f) + var needDir = f.slice(-1) === '/' + + if (f.length > this.maxLength) + return cb() + + if (!this.stat && ownProp(this.cache, abs)) { + var c = this.cache[abs] + + if (Array.isArray(c)) + c = 'DIR' + + // It exists, but maybe not how we need it + if (!needDir || c === 'DIR') + return cb(null, c) + + if (needDir && c === 'FILE') + return cb() + + // otherwise we have to stat, because maybe c=true + // if we know it exists, but not what it is. + } + + var exists + var stat = this.statCache[abs] + if (stat !== undefined) { + if (stat === false) + return cb(null, stat) + else { + var type = stat.isDirectory() ? 'DIR' : 'FILE' + if (needDir && type === 'FILE') + return cb() + else + return cb(null, type, stat) + } + } + + var self = this + var statcb = inflight('stat\0' + abs, lstatcb_) + if (statcb) + fs.lstat(abs, statcb) + + function lstatcb_ (er, lstat) { + if (lstat && lstat.isSymbolicLink()) { + // If it's a symlink, then treat it as the target, unless + // the target does not exist, then treat it as a file. + return fs.stat(abs, function (er, stat) { + if (er) + self._stat2(f, abs, null, lstat, cb) + else + self._stat2(f, abs, er, stat, cb) + }) + } else { + self._stat2(f, abs, er, lstat, cb) + } + } +} + +Glob.prototype._stat2 = function (f, abs, er, stat, cb) { + if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { + this.statCache[abs] = false + return cb() + } + + var needDir = f.slice(-1) === '/' + this.statCache[abs] = stat + + if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) + return cb(null, false, stat) + + var c = true + if (stat) + c = stat.isDirectory() ? 'DIR' : 'FILE' + this.cache[abs] = this.cache[abs] || c + + if (needDir && c === 'FILE') + return cb() + + return cb(null, c, stat) +} diff --git a/node_modules/cordova-common/node_modules/glob/package.json b/node_modules/cordova-common/node_modules/glob/package.json new file mode 100644 index 0000000000..ae1b093c77 --- /dev/null +++ b/node_modules/cordova-common/node_modules/glob/package.json @@ -0,0 +1,77 @@ +{ + "_from": "glob@^7.1.2", + "_id": "glob@7.1.2", + "_inBundle": false, + "_integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "_location": "/cordova-common/glob", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "glob@^7.1.2", + "name": "glob", + "escapedName": "glob", + "rawSpec": "^7.1.2", + "saveSpec": null, + "fetchSpec": "^7.1.2" + }, + "_requiredBy": [ + "/cordova-common", + "/cordova-common/shelljs" + ], + "_resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "_shasum": "c19c9df9a028702d678612384a6552404c636d15", + "_spec": "glob@^7.1.2", + "_where": "/Users/brodybits/Documents/cbwork/cordova-android/node_modules/cordova-common", + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "bugs": { + "url": "https://github.com/isaacs/node-glob/issues" + }, + "bundleDependencies": false, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "deprecated": false, + "description": "a little globber", + "devDependencies": { + "mkdirp": "0", + "rimraf": "^2.2.8", + "tap": "^7.1.2", + "tick": "0.0.6" + }, + "engines": { + "node": "*" + }, + "files": [ + "glob.js", + "sync.js", + "common.js" + ], + "homepage": "https://github.com/isaacs/node-glob#readme", + "license": "ISC", + "main": "glob.js", + "name": "glob", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/node-glob.git" + }, + "scripts": { + "bench": "bash benchmark.sh", + "benchclean": "node benchclean.js", + "prepublish": "npm run benchclean", + "prof": "bash prof.sh && cat profile.txt", + "profclean": "rm -f v8.log profile.txt", + "test": "tap test/*.js --cov", + "test-regen": "npm run profclean && TEST_REGEN=1 node test/00-setup.js" + }, + "version": "7.1.2" +} diff --git a/node_modules/cordova-common/node_modules/glob/sync.js b/node_modules/cordova-common/node_modules/glob/sync.js new file mode 100644 index 0000000000..c952134baa --- /dev/null +++ b/node_modules/cordova-common/node_modules/glob/sync.js @@ -0,0 +1,486 @@ +module.exports = globSync +globSync.GlobSync = GlobSync + +var fs = require('fs') +var rp = require('fs.realpath') +var minimatch = require('minimatch') +var Minimatch = minimatch.Minimatch +var Glob = require('./glob.js').Glob +var util = require('util') +var path = require('path') +var assert = require('assert') +var isAbsolute = require('path-is-absolute') +var common = require('./common.js') +var alphasort = common.alphasort +var alphasorti = common.alphasorti +var setopts = common.setopts +var ownProp = common.ownProp +var childrenIgnored = common.childrenIgnored +var isIgnored = common.isIgnored + +function globSync (pattern, options) { + if (typeof options === 'function' || arguments.length === 3) + throw new TypeError('callback provided to sync glob\n'+ + 'See: https://github.com/isaacs/node-glob/issues/167') + + return new GlobSync(pattern, options).found +} + +function GlobSync (pattern, options) { + if (!pattern) + throw new Error('must provide pattern') + + if (typeof options === 'function' || arguments.length === 3) + throw new TypeError('callback provided to sync glob\n'+ + 'See: https://github.com/isaacs/node-glob/issues/167') + + if (!(this instanceof GlobSync)) + return new GlobSync(pattern, options) + + setopts(this, pattern, options) + + if (this.noprocess) + return this + + var n = this.minimatch.set.length + this.matches = new Array(n) + for (var i = 0; i < n; i ++) { + this._process(this.minimatch.set[i], i, false) + } + this._finish() +} + +GlobSync.prototype._finish = function () { + assert(this instanceof GlobSync) + if (this.realpath) { + var self = this + this.matches.forEach(function (matchset, index) { + var set = self.matches[index] = Object.create(null) + for (var p in matchset) { + try { + p = self._makeAbs(p) + var real = rp.realpathSync(p, self.realpathCache) + set[real] = true + } catch (er) { + if (er.syscall === 'stat') + set[self._makeAbs(p)] = true + else + throw er + } + } + }) + } + common.finish(this) +} + + +GlobSync.prototype._process = function (pattern, index, inGlobStar) { + assert(this instanceof GlobSync) + + // Get the first [n] parts of pattern that are all strings. + var n = 0 + while (typeof pattern[n] === 'string') { + n ++ + } + // now n is the index of the first one that is *not* a string. + + // See if there's anything else + var prefix + switch (n) { + // if not, then this is rather simple + case pattern.length: + this._processSimple(pattern.join('/'), index) + return + + case 0: + // pattern *starts* with some non-trivial item. + // going to readdir(cwd), but not include the prefix in matches. + prefix = null + break + + default: + // pattern has some string bits in the front. + // whatever it starts with, whether that's 'absolute' like /foo/bar, + // or 'relative' like '../baz' + prefix = pattern.slice(0, n).join('/') + break + } + + var remain = pattern.slice(n) + + // get the list of entries. + var read + if (prefix === null) + read = '.' + else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { + if (!prefix || !isAbsolute(prefix)) + prefix = '/' + prefix + read = prefix + } else + read = prefix + + var abs = this._makeAbs(read) + + //if ignored, skip processing + if (childrenIgnored(this, read)) + return + + var isGlobStar = remain[0] === minimatch.GLOBSTAR + if (isGlobStar) + this._processGlobStar(prefix, read, abs, remain, index, inGlobStar) + else + this._processReaddir(prefix, read, abs, remain, index, inGlobStar) +} + + +GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) { + var entries = this._readdir(abs, inGlobStar) + + // if the abs isn't a dir, then nothing can match! + if (!entries) + return + + // It will only match dot entries if it starts with a dot, or if + // dot is set. Stuff like @(.foo|.bar) isn't allowed. + var pn = remain[0] + var negate = !!this.minimatch.negate + var rawGlob = pn._glob + var dotOk = this.dot || rawGlob.charAt(0) === '.' + + var matchedEntries = [] + for (var i = 0; i < entries.length; i++) { + var e = entries[i] + if (e.charAt(0) !== '.' || dotOk) { + var m + if (negate && !prefix) { + m = !e.match(pn) + } else { + m = e.match(pn) + } + if (m) + matchedEntries.push(e) + } + } + + var len = matchedEntries.length + // If there are no matched entries, then nothing matches. + if (len === 0) + return + + // if this is the last remaining pattern bit, then no need for + // an additional stat *unless* the user has specified mark or + // stat explicitly. We know they exist, since readdir returned + // them. + + if (remain.length === 1 && !this.mark && !this.stat) { + if (!this.matches[index]) + this.matches[index] = Object.create(null) + + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + if (prefix) { + if (prefix.slice(-1) !== '/') + e = prefix + '/' + e + else + e = prefix + e + } + + if (e.charAt(0) === '/' && !this.nomount) { + e = path.join(this.root, e) + } + this._emitMatch(index, e) + } + // This was the last one, and no stats were needed + return + } + + // now test all matched entries as stand-ins for that part + // of the pattern. + remain.shift() + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + var newPattern + if (prefix) + newPattern = [prefix, e] + else + newPattern = [e] + this._process(newPattern.concat(remain), index, inGlobStar) + } +} + + +GlobSync.prototype._emitMatch = function (index, e) { + if (isIgnored(this, e)) + return + + var abs = this._makeAbs(e) + + if (this.mark) + e = this._mark(e) + + if (this.absolute) { + e = abs + } + + if (this.matches[index][e]) + return + + if (this.nodir) { + var c = this.cache[abs] + if (c === 'DIR' || Array.isArray(c)) + return + } + + this.matches[index][e] = true + + if (this.stat) + this._stat(e) +} + + +GlobSync.prototype._readdirInGlobStar = function (abs) { + // follow all symlinked directories forever + // just proceed as if this is a non-globstar situation + if (this.follow) + return this._readdir(abs, false) + + var entries + var lstat + var stat + try { + lstat = fs.lstatSync(abs) + } catch (er) { + if (er.code === 'ENOENT') { + // lstat failed, doesn't exist + return null + } + } + + var isSym = lstat && lstat.isSymbolicLink() + this.symlinks[abs] = isSym + + // If it's not a symlink or a dir, then it's definitely a regular file. + // don't bother doing a readdir in that case. + if (!isSym && lstat && !lstat.isDirectory()) + this.cache[abs] = 'FILE' + else + entries = this._readdir(abs, false) + + return entries +} + +GlobSync.prototype._readdir = function (abs, inGlobStar) { + var entries + + if (inGlobStar && !ownProp(this.symlinks, abs)) + return this._readdirInGlobStar(abs) + + if (ownProp(this.cache, abs)) { + var c = this.cache[abs] + if (!c || c === 'FILE') + return null + + if (Array.isArray(c)) + return c + } + + try { + return this._readdirEntries(abs, fs.readdirSync(abs)) + } catch (er) { + this._readdirError(abs, er) + return null + } +} + +GlobSync.prototype._readdirEntries = function (abs, entries) { + // if we haven't asked to stat everything, then just + // assume that everything in there exists, so we can avoid + // having to stat it a second time. + if (!this.mark && !this.stat) { + for (var i = 0; i < entries.length; i ++) { + var e = entries[i] + if (abs === '/') + e = abs + e + else + e = abs + '/' + e + this.cache[e] = true + } + } + + this.cache[abs] = entries + + // mark and cache dir-ness + return entries +} + +GlobSync.prototype._readdirError = function (f, er) { + // handle errors, and cache the information + switch (er.code) { + case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 + case 'ENOTDIR': // totally normal. means it *does* exist. + var abs = this._makeAbs(f) + this.cache[abs] = 'FILE' + if (abs === this.cwdAbs) { + var error = new Error(er.code + ' invalid cwd ' + this.cwd) + error.path = this.cwd + error.code = er.code + throw error + } + break + + case 'ENOENT': // not terribly unusual + case 'ELOOP': + case 'ENAMETOOLONG': + case 'UNKNOWN': + this.cache[this._makeAbs(f)] = false + break + + default: // some unusual error. Treat as failure. + this.cache[this._makeAbs(f)] = false + if (this.strict) + throw er + if (!this.silent) + console.error('glob error', er) + break + } +} + +GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) { + + var entries = this._readdir(abs, inGlobStar) + + // no entries means not a dir, so it can never have matches + // foo.txt/** doesn't match foo.txt + if (!entries) + return + + // test without the globstar, and with every child both below + // and replacing the globstar. + var remainWithoutGlobStar = remain.slice(1) + var gspref = prefix ? [ prefix ] : [] + var noGlobStar = gspref.concat(remainWithoutGlobStar) + + // the noGlobStar pattern exits the inGlobStar state + this._process(noGlobStar, index, false) + + var len = entries.length + var isSym = this.symlinks[abs] + + // If it's a symlink, and we're in a globstar, then stop + if (isSym && inGlobStar) + return + + for (var i = 0; i < len; i++) { + var e = entries[i] + if (e.charAt(0) === '.' && !this.dot) + continue + + // these two cases enter the inGlobStar state + var instead = gspref.concat(entries[i], remainWithoutGlobStar) + this._process(instead, index, true) + + var below = gspref.concat(entries[i], remain) + this._process(below, index, true) + } +} + +GlobSync.prototype._processSimple = function (prefix, index) { + // XXX review this. Shouldn't it be doing the mounting etc + // before doing stat? kinda weird? + var exists = this._stat(prefix) + + if (!this.matches[index]) + this.matches[index] = Object.create(null) + + // If it doesn't exist, then just mark the lack of results + if (!exists) + return + + if (prefix && isAbsolute(prefix) && !this.nomount) { + var trail = /[\/\\]$/.test(prefix) + if (prefix.charAt(0) === '/') { + prefix = path.join(this.root, prefix) + } else { + prefix = path.resolve(this.root, prefix) + if (trail) + prefix += '/' + } + } + + if (process.platform === 'win32') + prefix = prefix.replace(/\\/g, '/') + + // Mark this as a match + this._emitMatch(index, prefix) +} + +// Returns either 'DIR', 'FILE', or false +GlobSync.prototype._stat = function (f) { + var abs = this._makeAbs(f) + var needDir = f.slice(-1) === '/' + + if (f.length > this.maxLength) + return false + + if (!this.stat && ownProp(this.cache, abs)) { + var c = this.cache[abs] + + if (Array.isArray(c)) + c = 'DIR' + + // It exists, but maybe not how we need it + if (!needDir || c === 'DIR') + return c + + if (needDir && c === 'FILE') + return false + + // otherwise we have to stat, because maybe c=true + // if we know it exists, but not what it is. + } + + var exists + var stat = this.statCache[abs] + if (!stat) { + var lstat + try { + lstat = fs.lstatSync(abs) + } catch (er) { + if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { + this.statCache[abs] = false + return false + } + } + + if (lstat && lstat.isSymbolicLink()) { + try { + stat = fs.statSync(abs) + } catch (er) { + stat = lstat + } + } else { + stat = lstat + } + } + + this.statCache[abs] = stat + + var c = true + if (stat) + c = stat.isDirectory() ? 'DIR' : 'FILE' + + this.cache[abs] = this.cache[abs] || c + + if (needDir && c === 'FILE') + return false + + return c +} + +GlobSync.prototype._mark = function (p) { + return common.mark(this, p) +} + +GlobSync.prototype._makeAbs = function (f) { + return common.makeAbs(this, f) +} diff --git a/node_modules/cordova-common/node_modules/sax/LICENSE b/node_modules/cordova-common/node_modules/sax/LICENSE new file mode 100644 index 0000000000..ccffa082c9 --- /dev/null +++ b/node_modules/cordova-common/node_modules/sax/LICENSE @@ -0,0 +1,41 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +==== + +`String.fromCodePoint` by Mathias Bynens used according to terms of MIT +License, as follows: + + Copyright Mathias Bynens + + 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/node_modules/cordova-common/node_modules/sax/LICENSE-W3C.html b/node_modules/cordova-common/node_modules/sax/LICENSE-W3C.html new file mode 100644 index 0000000000..a611e3f907 --- /dev/null +++ b/node_modules/cordova-common/node_modules/sax/LICENSE-W3C.html @@ -0,0 +1,188 @@ + +W3C Software Notice and License
+ + + +
+

+ W3C + +

+ +
+ + + +
+
+ +
+ + +
+
+ +
+ + +
+
+
+ +
+
+

W3C Software Notice and License

+
+
+

This work (and included software, documentation such as READMEs, or other +related items) is being provided by the copyright holders under the following +license.

+

License

+ +

+By obtaining, using and/or copying this work, you (the licensee) +agree that you have read, understood, and will comply with the following +terms and conditions.

+ +

Permission to copy, modify, and distribute this software and its +documentation, with or without modification, for any purpose and without +fee or royalty is hereby granted, provided that you include the following on +ALL copies of the software and documentation or portions thereof, including +modifications:

+ +
  • The full text of this NOTICE in a location viewable to users of the + redistributed or derivative work.
  • Any pre-existing intellectual property disclaimers, notices, or terms + and conditions. If none exist, the W3C Software Short + Notice should be included (hypertext is preferred, text is permitted) + within the body of any redistributed or derivative code.
  • Notice of any changes or modifications to the files, including the date + changes were made. (We recommend you provide URIs to the location from + which the code is derived.)
+ +

Disclaimers

+ +

THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS +MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR +PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE +ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.

+ +

COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR +DOCUMENTATION.

+ +

The name and trademarks of copyright holders may NOT be used in +advertising or publicity pertaining to the software without specific, written +prior permission. Title to copyright in this software and any associated +documentation will at all times remain with copyright holders.

+ +

Notes

+ +

This version: http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231

+ +

This formulation of W3C's notice and license became active on December 31 +2002. This version removes the copyright ownership notice such that this +license can be used with materials other than those owned by the W3C, +reflects that ERCIM is now a host of the W3C, includes references to this +specific dated version of the license, and removes the ambiguous grant of +"use". Otherwise, this version is the same as the previous +version and is written so as to preserve the Free +Software Foundation's assessment of GPL compatibility and OSI's certification +under the Open Source +Definition.

+
+
+
+
+ + + +
+ +
diff --git a/node_modules/cordova-common/node_modules/sax/README.md b/node_modules/cordova-common/node_modules/sax/README.md new file mode 100644 index 0000000000..91a03143de --- /dev/null +++ b/node_modules/cordova-common/node_modules/sax/README.md @@ -0,0 +1,220 @@ +# sax js + +A sax-style parser for XML and HTML. + +Designed with [node](http://nodejs.org/) in mind, but should work fine in +the browser or other CommonJS implementations. + +## What This Is + +* A very simple tool to parse through an XML string. +* A stepping stone to a streaming HTML parser. +* A handy way to deal with RSS and other mostly-ok-but-kinda-broken XML + docs. + +## What This Is (probably) Not + +* An HTML Parser - That's a fine goal, but this isn't it. It's just + XML. +* A DOM Builder - You can use it to build an object model out of XML, + but it doesn't do that out of the box. +* XSLT - No DOM = no querying. +* 100% Compliant with (some other SAX implementation) - Most SAX + implementations are in Java and do a lot more than this does. +* An XML Validator - It does a little validation when in strict mode, but + not much. +* A Schema-Aware XSD Thing - Schemas are an exercise in fetishistic + masochism. +* A DTD-aware Thing - Fetching DTDs is a much bigger job. + +## Regarding `Hello, world!').close(); + +// stream usage +// takes the same options as the parser +var saxStream = require("sax").createStream(strict, options) +saxStream.on("error", function (e) { + // unhandled errors will throw, since this is a proper node + // event emitter. + console.error("error!", e) + // clear the error + this._parser.error = null + this._parser.resume() +}) +saxStream.on("opentag", function (node) { + // same object as above +}) +// pipe is supported, and it's readable/writable +// same chunks coming in also go out. +fs.createReadStream("file.xml") + .pipe(saxStream) + .pipe(fs.createWriteStream("file-copy.xml")) +``` + + +## Arguments + +Pass the following arguments to the parser function. All are optional. + +`strict` - Boolean. Whether or not to be a jerk. Default: `false`. + +`opt` - Object bag of settings regarding string formatting. All default to `false`. + +Settings supported: + +* `trim` - Boolean. Whether or not to trim text and comment nodes. +* `normalize` - Boolean. If true, then turn any whitespace into a single + space. +* `lowercase` - Boolean. If true, then lowercase tag names and attribute names + in loose mode, rather than uppercasing them. +* `xmlns` - Boolean. If true, then namespaces are supported. +* `position` - Boolean. If false, then don't track line/col/position. +* `strictEntities` - Boolean. If true, only parse [predefined XML + entities](http://www.w3.org/TR/REC-xml/#sec-predefined-ent) + (`&`, `'`, `>`, `<`, and `"`) + +## Methods + +`write` - Write bytes onto the stream. You don't have to do this all at +once. You can keep writing as much as you want. + +`close` - Close the stream. Once closed, no more data may be written until +it is done processing the buffer, which is signaled by the `end` event. + +`resume` - To gracefully handle errors, assign a listener to the `error` +event. Then, when the error is taken care of, you can call `resume` to +continue parsing. Otherwise, the parser will not continue while in an error +state. + +## Members + +At all times, the parser object will have the following members: + +`line`, `column`, `position` - Indications of the position in the XML +document where the parser currently is looking. + +`startTagPosition` - Indicates the position where the current tag starts. + +`closed` - Boolean indicating whether or not the parser can be written to. +If it's `true`, then wait for the `ready` event to write again. + +`strict` - Boolean indicating whether or not the parser is a jerk. + +`opt` - Any options passed into the constructor. + +`tag` - The current tag being dealt with. + +And a bunch of other stuff that you probably shouldn't touch. + +## Events + +All events emit with a single argument. To listen to an event, assign a +function to `on`. Functions get executed in the this-context of +the parser object. The list of supported events are also in the exported +`EVENTS` array. + +When using the stream interface, assign handlers using the EventEmitter +`on` function in the normal fashion. + +`error` - Indication that something bad happened. The error will be hanging +out on `parser.error`, and must be deleted before parsing can continue. By +listening to this event, you can keep an eye on that kind of stuff. Note: +this happens *much* more in strict mode. Argument: instance of `Error`. + +`text` - Text node. Argument: string of text. + +`doctype` - The ``. Argument: +object with `name` and `body` members. Attributes are not parsed, as +processing instructions have implementation dependent semantics. + +`sgmldeclaration` - Random SGML declarations. Stuff like `` +would trigger this kind of event. This is a weird thing to support, so it +might go away at some point. SAX isn't intended to be used to parse SGML, +after all. + +`opentag` - An opening tag. Argument: object with `name` and `attributes`. +In non-strict mode, tag names are uppercased, unless the `lowercase` +option is set. If the `xmlns` option is set, then it will contain +namespace binding information on the `ns` member, and will have a +`local`, `prefix`, and `uri` member. + +`closetag` - A closing tag. In loose mode, tags are auto-closed if their +parent closes. In strict mode, well-formedness is enforced. Note that +self-closing tags will have `closeTag` emitted immediately after `openTag`. +Argument: tag name. + +`attribute` - An attribute node. Argument: object with `name` and `value`. +In non-strict mode, attribute names are uppercased, unless the `lowercase` +option is set. If the `xmlns` option is set, it will also contains namespace +information. + +`comment` - A comment node. Argument: the string of the comment. + +`opencdata` - The opening tag of a ``) of a `` tags trigger a `"script"` +event, and their contents are not checked for special xml characters. +If you pass `noscript: true`, then this behavior is suppressed. + +## Reporting Problems + +It's best to write a failing test if you find an issue. I will always +accept pull requests with failing tests if they demonstrate intended +behavior, but it is very hard to figure out what issue you're describing +without a test. Writing a test is also the best way for you yourself +to figure out if you really understand the issue you think you have with +sax-js. diff --git a/node_modules/cordova-common/node_modules/sax/lib/sax.js b/node_modules/cordova-common/node_modules/sax/lib/sax.js new file mode 100644 index 0000000000..5c08d5f6cc --- /dev/null +++ b/node_modules/cordova-common/node_modules/sax/lib/sax.js @@ -0,0 +1,1563 @@ +;(function (sax) { // wrapper for non-node envs + sax.parser = function (strict, opt) { return new SAXParser(strict, opt) } + sax.SAXParser = SAXParser + sax.SAXStream = SAXStream + sax.createStream = createStream + + // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns. + // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)), + // since that's the earliest that a buffer overrun could occur. This way, checks are + // as rare as required, but as often as necessary to ensure never crossing this bound. + // Furthermore, buffers are only tested at most once per write(), so passing a very + // large string into write() might have undesirable effects, but this is manageable by + // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme + // edge case, result in creating at most one complete copy of the string passed in. + // Set to Infinity to have unlimited buffers. + sax.MAX_BUFFER_LENGTH = 64 * 1024 + + var buffers = [ + 'comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype', + 'procInstName', 'procInstBody', 'entity', 'attribName', + 'attribValue', 'cdata', 'script' + ] + + sax.EVENTS = [ + 'text', + 'processinginstruction', + 'sgmldeclaration', + 'doctype', + 'comment', + 'attribute', + 'opentag', + 'closetag', + 'opencdata', + 'cdata', + 'closecdata', + 'error', + 'end', + 'ready', + 'script', + 'opennamespace', + 'closenamespace' + ] + + function SAXParser (strict, opt) { + if (!(this instanceof SAXParser)) { + return new SAXParser(strict, opt) + } + + var parser = this + clearBuffers(parser) + parser.q = parser.c = '' + parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH + parser.opt = opt || {} + parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags + parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase' + parser.tags = [] + parser.closed = parser.closedRoot = parser.sawRoot = false + parser.tag = parser.error = null + parser.strict = !!strict + parser.noscript = !!(strict || parser.opt.noscript) + parser.state = S.BEGIN + parser.strictEntities = parser.opt.strictEntities + parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES) + parser.attribList = [] + + // namespaces form a prototype chain. + // it always points at the current tag, + // which protos to its parent tag. + if (parser.opt.xmlns) { + parser.ns = Object.create(rootNS) + } + + // mostly just for error reporting + parser.trackPosition = parser.opt.position !== false + if (parser.trackPosition) { + parser.position = parser.line = parser.column = 0 + } + emit(parser, 'onready') + } + + if (!Object.create) { + Object.create = function (o) { + function F () {} + F.prototype = o + var newf = new F() + return newf + } + } + + if (!Object.keys) { + Object.keys = function (o) { + var a = [] + for (var i in o) if (o.hasOwnProperty(i)) a.push(i) + return a + } + } + + function checkBufferLength (parser) { + var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10) + var maxActual = 0 + for (var i = 0, l = buffers.length; i < l; i++) { + var len = parser[buffers[i]].length + if (len > maxAllowed) { + // Text/cdata nodes can get big, and since they're buffered, + // we can get here under normal conditions. + // Avoid issues by emitting the text node now, + // so at least it won't get any bigger. + switch (buffers[i]) { + case 'textNode': + closeText(parser) + break + + case 'cdata': + emitNode(parser, 'oncdata', parser.cdata) + parser.cdata = '' + break + + case 'script': + emitNode(parser, 'onscript', parser.script) + parser.script = '' + break + + default: + error(parser, 'Max buffer length exceeded: ' + buffers[i]) + } + } + maxActual = Math.max(maxActual, len) + } + // schedule the next check for the earliest possible buffer overrun. + var m = sax.MAX_BUFFER_LENGTH - maxActual + parser.bufferCheckPosition = m + parser.position + } + + function clearBuffers (parser) { + for (var i = 0, l = buffers.length; i < l; i++) { + parser[buffers[i]] = '' + } + } + + function flushBuffers (parser) { + closeText(parser) + if (parser.cdata !== '') { + emitNode(parser, 'oncdata', parser.cdata) + parser.cdata = '' + } + if (parser.script !== '') { + emitNode(parser, 'onscript', parser.script) + parser.script = '' + } + } + + SAXParser.prototype = { + end: function () { end(this) }, + write: write, + resume: function () { this.error = null; return this }, + close: function () { return this.write(null) }, + flush: function () { flushBuffers(this) } + } + + var Stream + try { + Stream = require('stream').Stream + } catch (ex) { + Stream = function () {} + } + + var streamWraps = sax.EVENTS.filter(function (ev) { + return ev !== 'error' && ev !== 'end' + }) + + function createStream (strict, opt) { + return new SAXStream(strict, opt) + } + + function SAXStream (strict, opt) { + if (!(this instanceof SAXStream)) { + return new SAXStream(strict, opt) + } + + Stream.apply(this) + + this._parser = new SAXParser(strict, opt) + this.writable = true + this.readable = true + + var me = this + + this._parser.onend = function () { + me.emit('end') + } + + this._parser.onerror = function (er) { + me.emit('error', er) + + // if didn't throw, then means error was handled. + // go ahead and clear error, so we can write again. + me._parser.error = null + } + + this._decoder = null + + streamWraps.forEach(function (ev) { + Object.defineProperty(me, 'on' + ev, { + get: function () { + return me._parser['on' + ev] + }, + set: function (h) { + if (!h) { + me.removeAllListeners(ev) + me._parser['on' + ev] = h + return h + } + me.on(ev, h) + }, + enumerable: true, + configurable: false + }) + }) + } + + SAXStream.prototype = Object.create(Stream.prototype, { + constructor: { + value: SAXStream + } + }) + + SAXStream.prototype.write = function (data) { + if (typeof Buffer === 'function' && + typeof Buffer.isBuffer === 'function' && + Buffer.isBuffer(data)) { + if (!this._decoder) { + var SD = require('string_decoder').StringDecoder + this._decoder = new SD('utf8') + } + data = this._decoder.write(data) + } + + this._parser.write(data.toString()) + this.emit('data', data) + return true + } + + SAXStream.prototype.end = function (chunk) { + if (chunk && chunk.length) { + this.write(chunk) + } + this._parser.end() + return true + } + + SAXStream.prototype.on = function (ev, handler) { + var me = this + if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) { + me._parser['on' + ev] = function () { + var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments) + args.splice(0, 0, ev) + me.emit.apply(me, args) + } + } + + return Stream.prototype.on.call(me, ev, handler) + } + + // character classes and tokens + var whitespace = '\r\n\t ' + + // this really needs to be replaced with character classes. + // XML allows all manner of ridiculous numbers and digits. + var number = '0124356789' + var letter = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + + // (Letter | "_" | ":") + var quote = '\'"' + var attribEnd = whitespace + '>' + var CDATA = '[CDATA[' + var DOCTYPE = 'DOCTYPE' + var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace' + var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/' + var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE } + + // turn all the string character sets into character class objects. + whitespace = charClass(whitespace) + number = charClass(number) + letter = charClass(letter) + + // http://www.w3.org/TR/REC-xml/#NT-NameStartChar + // This implementation works on strings, a single character at a time + // as such, it cannot ever support astral-plane characters (10000-EFFFF) + // without a significant breaking change to either this parser, or the + // JavaScript language. Implementation of an emoji-capable xml parser + // is left as an exercise for the reader. + var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/ + + var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040\.\d-]/ + + var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/ + var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040\.\d-]/ + + quote = charClass(quote) + attribEnd = charClass(attribEnd) + + function charClass (str) { + return str.split('').reduce(function (s, c) { + s[c] = true + return s + }, {}) + } + + function isRegExp (c) { + return Object.prototype.toString.call(c) === '[object RegExp]' + } + + function is (charclass, c) { + return isRegExp(charclass) ? !!c.match(charclass) : charclass[c] + } + + function not (charclass, c) { + return !is(charclass, c) + } + + var S = 0 + sax.STATE = { + BEGIN: S++, // leading byte order mark or whitespace + BEGIN_WHITESPACE: S++, // leading whitespace + TEXT: S++, // general stuff + TEXT_ENTITY: S++, // & and such. + OPEN_WAKA: S++, // < + SGML_DECL: S++, // + SCRIPT: S++, //