@pdftron/pdfnet-node 10.4.0-beta → 10.5.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules/underscore/LICENSE +23 -0
- package/node_modules/underscore/README.md +28 -0
- package/node_modules/underscore/amd/_apply.js +7 -0
- package/node_modules/underscore/amd/_applyProperty.js +14 -0
- package/node_modules/underscore/amd/_arrayAccessors.js +11 -0
- package/node_modules/underscore/amd/_arrayMutators.js +15 -0
- package/node_modules/underscore/amd/_baseCreate.js +21 -0
- package/node_modules/underscore/amd/_baseIteratee.js +15 -0
- package/node_modules/underscore/amd/_binarySearch.js +17 -0
- package/node_modules/underscore/amd/_bindCb.js +14 -0
- package/node_modules/underscore/amd/_bindCb4.js +17 -0
- package/node_modules/underscore/amd/_byValue.js +11 -0
- package/node_modules/underscore/amd/_cb.js +12 -0
- package/node_modules/underscore/amd/_chainResult.js +10 -0
- package/node_modules/underscore/amd/_collectNonEnumProps.js +42 -0
- package/node_modules/underscore/amd/_createAssigner.js +24 -0
- package/node_modules/underscore/amd/_createEscaper.js +21 -0
- package/node_modules/underscore/amd/_createIndexFinder.js +30 -0
- package/node_modules/underscore/amd/_createPredicateIndexFinder.js +18 -0
- package/node_modules/underscore/amd/_createReduce.js +30 -0
- package/node_modules/underscore/amd/_createSizePropertyCheck.js +13 -0
- package/node_modules/underscore/amd/_deepGet.js +15 -0
- package/node_modules/underscore/amd/_escapeMap.js +15 -0
- package/node_modules/underscore/amd/_executeBound.js +16 -0
- package/node_modules/underscore/amd/_extremum.js +35 -0
- package/node_modules/underscore/amd/_flatten.js +32 -0
- package/node_modules/underscore/amd/_forceNumericMinMax.js +16 -0
- package/node_modules/underscore/amd/_getByteLength.js +8 -0
- package/node_modules/underscore/amd/_getLength.js +8 -0
- package/node_modules/underscore/amd/_greater.js +10 -0
- package/node_modules/underscore/amd/_group.js +18 -0
- package/node_modules/underscore/amd/_has.js +10 -0
- package/node_modules/underscore/amd/_hasObjectTag.js +7 -0
- package/node_modules/underscore/amd/_isArrayLike.js +11 -0
- package/node_modules/underscore/amd/_isBufferLike.js +9 -0
- package/node_modules/underscore/amd/_keyInObj.js +11 -0
- package/node_modules/underscore/amd/_less.js +10 -0
- package/node_modules/underscore/amd/_lessEqual.js +10 -0
- package/node_modules/underscore/amd/_linearSearch.js +31 -0
- package/node_modules/underscore/amd/_mapReduce.js +5 -0
- package/node_modules/underscore/amd/_methodFingerprint.js +44 -0
- package/node_modules/underscore/amd/_optimizeCb.js +27 -0
- package/node_modules/underscore/amd/_push.js +7 -0
- package/node_modules/underscore/amd/_pusher.js +13 -0
- package/node_modules/underscore/amd/_sequence.js +18 -0
- package/node_modules/underscore/amd/_setup.js +70 -0
- package/node_modules/underscore/amd/_shallowProperty.js +12 -0
- package/node_modules/underscore/amd/_slice.js +7 -0
- package/node_modules/underscore/amd/_strictEqual.js +9 -0
- package/node_modules/underscore/amd/_stringTagBug.js +16 -0
- package/node_modules/underscore/amd/_tagTester.js +13 -0
- package/node_modules/underscore/amd/_toBufferView.js +15 -0
- package/node_modules/underscore/amd/_toPath.js +11 -0
- package/node_modules/underscore/amd/_unescapeMap.js +8 -0
- package/node_modules/underscore/amd/_unmethodize.js +9 -0
- package/node_modules/underscore/amd/_wrapArrayAccessor.js +15 -0
- package/node_modules/underscore/amd/_wrapArrayMutator.js +28 -0
- package/node_modules/underscore/amd/after.js +14 -0
- package/node_modules/underscore/amd/allKeys.js +15 -0
- package/node_modules/underscore/amd/before.js +18 -0
- package/node_modules/underscore/amd/bind.js +15 -0
- package/node_modules/underscore/amd/bindAll.js +19 -0
- package/node_modules/underscore/amd/chain.js +12 -0
- package/node_modules/underscore/amd/chunk.js +17 -0
- package/node_modules/underscore/amd/clone.js +11 -0
- package/node_modules/underscore/amd/compact.js +10 -0
- package/node_modules/underscore/amd/compose.js +18 -0
- package/node_modules/underscore/amd/concat.js +7 -0
- package/node_modules/underscore/amd/constant.js +12 -0
- package/node_modules/underscore/amd/contains.js +12 -0
- package/node_modules/underscore/amd/countBy.js +12 -0
- package/node_modules/underscore/amd/create.js +14 -0
- package/node_modules/underscore/amd/debounce.js +43 -0
- package/node_modules/underscore/amd/defaults.js +8 -0
- package/node_modules/underscore/amd/defer.js +9 -0
- package/node_modules/underscore/amd/delay.js +13 -0
- package/node_modules/underscore/amd/difference.js +14 -0
- package/node_modules/underscore/amd/each.js +25 -0
- package/node_modules/underscore/amd/escape.js +8 -0
- package/node_modules/underscore/amd/every.js +17 -0
- package/node_modules/underscore/amd/extend.js +8 -0
- package/node_modules/underscore/amd/extendOwn.js +10 -0
- package/node_modules/underscore/amd/filter.js +15 -0
- package/node_modules/underscore/amd/find.js +12 -0
- package/node_modules/underscore/amd/findIndex.js +8 -0
- package/node_modules/underscore/amd/findKey.js +15 -0
- package/node_modules/underscore/amd/findLastIndex.js +8 -0
- package/node_modules/underscore/amd/findWhere.js +11 -0
- package/node_modules/underscore/amd/first.js +13 -0
- package/node_modules/underscore/amd/flatten.js +11 -0
- package/node_modules/underscore/amd/functions.js +14 -0
- package/node_modules/underscore/amd/get.js +14 -0
- package/node_modules/underscore/amd/groupBy.js +11 -0
- package/node_modules/underscore/amd/has.js +19 -0
- package/node_modules/underscore/amd/identity.js +10 -0
- package/node_modules/underscore/amd/index-default.js +12 -0
- package/node_modules/underscore/amd/index.js +154 -0
- package/node_modules/underscore/amd/indexBy.js +11 -0
- package/node_modules/underscore/amd/indexOf.js +11 -0
- package/node_modules/underscore/amd/initial.js +12 -0
- package/node_modules/underscore/amd/intersection.js +22 -0
- package/node_modules/underscore/amd/invert.js +15 -0
- package/node_modules/underscore/amd/invoke.js +28 -0
- package/node_modules/underscore/amd/isArguments.js +19 -0
- package/node_modules/underscore/amd/isArray.js +9 -0
- package/node_modules/underscore/amd/isArrayBuffer.js +7 -0
- package/node_modules/underscore/amd/isBoolean.js +10 -0
- package/node_modules/underscore/amd/isDataView.js +15 -0
- package/node_modules/underscore/amd/isDate.js +7 -0
- package/node_modules/underscore/amd/isElement.js +10 -0
- package/node_modules/underscore/amd/isEmpty.js +18 -0
- package/node_modules/underscore/amd/isEqual.js +133 -0
- package/node_modules/underscore/amd/isError.js +7 -0
- package/node_modules/underscore/amd/isFinite.js +10 -0
- package/node_modules/underscore/amd/isFunction.js +18 -0
- package/node_modules/underscore/amd/isMap.js +7 -0
- package/node_modules/underscore/amd/isMatch.js +17 -0
- package/node_modules/underscore/amd/isNaN.js +10 -0
- package/node_modules/underscore/amd/isNull.js +10 -0
- package/node_modules/underscore/amd/isNumber.js +7 -0
- package/node_modules/underscore/amd/isObject.js +11 -0
- package/node_modules/underscore/amd/isRegExp.js +7 -0
- package/node_modules/underscore/amd/isSet.js +7 -0
- package/node_modules/underscore/amd/isString.js +7 -0
- package/node_modules/underscore/amd/isSymbol.js +7 -0
- package/node_modules/underscore/amd/isTypedArray.js +16 -0
- package/node_modules/underscore/amd/isUndefined.js +10 -0
- package/node_modules/underscore/amd/isWeakMap.js +7 -0
- package/node_modules/underscore/amd/isWeakSet.js +7 -0
- package/node_modules/underscore/amd/iteratee.js +13 -0
- package/node_modules/underscore/amd/join.js +7 -0
- package/node_modules/underscore/amd/keys.js +17 -0
- package/node_modules/underscore/amd/last.js +13 -0
- package/node_modules/underscore/amd/lastIndexOf.js +9 -0
- package/node_modules/underscore/amd/map.js +18 -0
- package/node_modules/underscore/amd/mapObject.js +19 -0
- package/node_modules/underscore/amd/matcher.js +14 -0
- package/node_modules/underscore/amd/max.js +30 -0
- package/node_modules/underscore/amd/memoize.js +17 -0
- package/node_modules/underscore/amd/min.js +30 -0
- package/node_modules/underscore/amd/mixin.js +18 -0
- package/node_modules/underscore/amd/negate.js +12 -0
- package/node_modules/underscore/amd/noop.js +8 -0
- package/node_modules/underscore/amd/now.js +10 -0
- package/node_modules/underscore/amd/object.js +20 -0
- package/node_modules/underscore/amd/omit.js +20 -0
- package/node_modules/underscore/amd/once.js +9 -0
- package/node_modules/underscore/amd/pairs.js +17 -0
- package/node_modules/underscore/amd/partial.js +25 -0
- package/node_modules/underscore/amd/partition.js +11 -0
- package/node_modules/underscore/amd/pick.js +25 -0
- package/node_modules/underscore/amd/pluck.js +10 -0
- package/node_modules/underscore/amd/pop.js +7 -0
- package/node_modules/underscore/amd/property.js +14 -0
- package/node_modules/underscore/amd/propertyOf.js +13 -0
- package/node_modules/underscore/amd/push.js +7 -0
- package/node_modules/underscore/amd/random.js +14 -0
- package/node_modules/underscore/amd/range.js +27 -0
- package/node_modules/underscore/amd/reduce.js +9 -0
- package/node_modules/underscore/amd/reduceRight.js +8 -0
- package/node_modules/underscore/amd/reject.js +10 -0
- package/node_modules/underscore/amd/rest.js +12 -0
- package/node_modules/underscore/amd/restArguments.js +33 -0
- package/node_modules/underscore/amd/result.js +25 -0
- package/node_modules/underscore/amd/reverse.js +7 -0
- package/node_modules/underscore/amd/sample.js +27 -0
- package/node_modules/underscore/amd/shift.js +7 -0
- package/node_modules/underscore/amd/shuffle.js +10 -0
- package/node_modules/underscore/amd/size.js +11 -0
- package/node_modules/underscore/amd/slice.js +7 -0
- package/node_modules/underscore/amd/some.js +17 -0
- package/node_modules/underscore/amd/sort.js +7 -0
- package/node_modules/underscore/amd/sortBy.js +26 -0
- package/node_modules/underscore/amd/sortedIndex.js +18 -0
- package/node_modules/underscore/amd/sortedLastIndex.js +11 -0
- package/node_modules/underscore/amd/splice.js +7 -0
- package/node_modules/underscore/amd/tap.js +13 -0
- package/node_modules/underscore/amd/template.js +95 -0
- package/node_modules/underscore/amd/templateSettings.js +13 -0
- package/node_modules/underscore/amd/throttle.js +51 -0
- package/node_modules/underscore/amd/times.js +13 -0
- package/node_modules/underscore/amd/toArray.js +18 -0
- package/node_modules/underscore/amd/toPath.js +12 -0
- package/node_modules/underscore/amd/toString.js +11 -0
- package/node_modules/underscore/amd/underscore-array-methods.js +30 -0
- package/node_modules/underscore/amd/underscore.js +29 -0
- package/node_modules/underscore/amd/unescape.js +8 -0
- package/node_modules/underscore/amd/union.js +11 -0
- package/node_modules/underscore/amd/uniq.js +37 -0
- package/node_modules/underscore/amd/uniqueId.js +13 -0
- package/node_modules/underscore/amd/unshift.js +7 -0
- package/node_modules/underscore/amd/unzip.js +17 -0
- package/node_modules/underscore/amd/value.js +13 -0
- package/node_modules/underscore/amd/values.js +16 -0
- package/node_modules/underscore/amd/where.js +11 -0
- package/node_modules/underscore/amd/without.js +10 -0
- package/node_modules/underscore/amd/wrap.js +12 -0
- package/node_modules/underscore/amd/zip.js +9 -0
- package/node_modules/underscore/cjs/_apply.js +6 -0
- package/node_modules/underscore/cjs/_applyProperty.js +10 -0
- package/node_modules/underscore/cjs/_arrayAccessors.js +11 -0
- package/node_modules/underscore/cjs/_arrayMutators.js +19 -0
- package/node_modules/underscore/cjs/_baseCreate.js +20 -0
- package/node_modules/underscore/cjs/_baseIteratee.js +19 -0
- package/node_modules/underscore/cjs/_binarySearch.js +15 -0
- package/node_modules/underscore/cjs/_bindCb.js +10 -0
- package/node_modules/underscore/cjs/_bindCb4.js +13 -0
- package/node_modules/underscore/cjs/_byValue.js +7 -0
- package/node_modules/underscore/cjs/_cb.js +12 -0
- package/node_modules/underscore/cjs/_chainResult.js +8 -0
- package/node_modules/underscore/cjs/_collectNonEnumProps.js +42 -0
- package/node_modules/underscore/cjs/_createAssigner.js +20 -0
- package/node_modules/underscore/cjs/_createEscaper.js +19 -0
- package/node_modules/underscore/cjs/_createIndexFinder.js +30 -0
- package/node_modules/underscore/cjs/_createPredicateIndexFinder.js +17 -0
- package/node_modules/underscore/cjs/_createReduce.js +30 -0
- package/node_modules/underscore/cjs/_createSizePropertyCheck.js +11 -0
- package/node_modules/underscore/cjs/_deepGet.js +11 -0
- package/node_modules/underscore/cjs/_escapeMap.js +11 -0
- package/node_modules/underscore/cjs/_executeBound.js +15 -0
- package/node_modules/underscore/cjs/_extremum.js +35 -0
- package/node_modules/underscore/cjs/_flatten.js +33 -0
- package/node_modules/underscore/cjs/_forceNumericMinMax.js +14 -0
- package/node_modules/underscore/cjs/_getByteLength.js +6 -0
- package/node_modules/underscore/cjs/_getLength.js +6 -0
- package/node_modules/underscore/cjs/_greater.js +6 -0
- package/node_modules/underscore/cjs/_group.js +17 -0
- package/node_modules/underscore/cjs/_has.js +8 -0
- package/node_modules/underscore/cjs/_hasObjectTag.js +5 -0
- package/node_modules/underscore/cjs/_isArrayLike.js +10 -0
- package/node_modules/underscore/cjs/_isBufferLike.js +8 -0
- package/node_modules/underscore/cjs/_keyInObj.js +7 -0
- package/node_modules/underscore/cjs/_less.js +6 -0
- package/node_modules/underscore/cjs/_lessEqual.js +6 -0
- package/node_modules/underscore/cjs/_linearSearch.js +30 -0
- package/node_modules/underscore/cjs/_mapReduce.js +1 -0
- package/node_modules/underscore/cjs/_methodFingerprint.js +44 -0
- package/node_modules/underscore/cjs/_optimizeCb.js +23 -0
- package/node_modules/underscore/cjs/_push.js +6 -0
- package/node_modules/underscore/cjs/_pusher.js +9 -0
- package/node_modules/underscore/cjs/_sequence.js +14 -0
- package/node_modules/underscore/cjs/_setup.js +66 -0
- package/node_modules/underscore/cjs/_shallowProperty.js +8 -0
- package/node_modules/underscore/cjs/_slice.js +6 -0
- package/node_modules/underscore/cjs/_strictEqual.js +5 -0
- package/node_modules/underscore/cjs/_stringTagBug.js +15 -0
- package/node_modules/underscore/cjs/_tagTester.js +11 -0
- package/node_modules/underscore/cjs/_toBufferView.js +13 -0
- package/node_modules/underscore/cjs/_toPath.js +10 -0
- package/node_modules/underscore/cjs/_unescapeMap.js +7 -0
- package/node_modules/underscore/cjs/_unmethodize.js +8 -0
- package/node_modules/underscore/cjs/_wrapArrayAccessor.js +14 -0
- package/node_modules/underscore/cjs/_wrapArrayMutator.js +29 -0
- package/node_modules/underscore/cjs/after.js +10 -0
- package/node_modules/underscore/cjs/allKeys.js +15 -0
- package/node_modules/underscore/cjs/before.js +14 -0
- package/node_modules/underscore/cjs/bind.js +15 -0
- package/node_modules/underscore/cjs/bindAll.js +19 -0
- package/node_modules/underscore/cjs/chain.js +10 -0
- package/node_modules/underscore/cjs/chunk.js +15 -0
- package/node_modules/underscore/cjs/clone.js +11 -0
- package/node_modules/underscore/cjs/compact.js +8 -0
- package/node_modules/underscore/cjs/compose.js +14 -0
- package/node_modules/underscore/cjs/concat.js +6 -0
- package/node_modules/underscore/cjs/constant.js +8 -0
- package/node_modules/underscore/cjs/contains.js +12 -0
- package/node_modules/underscore/cjs/countBy.js +11 -0
- package/node_modules/underscore/cjs/create.js +13 -0
- package/node_modules/underscore/cjs/debounce.js +42 -0
- package/node_modules/underscore/cjs/defaults.js +7 -0
- package/node_modules/underscore/cjs/defer.js +9 -0
- package/node_modules/underscore/cjs/delay.js +11 -0
- package/node_modules/underscore/cjs/difference.js +15 -0
- package/node_modules/underscore/cjs/each.js +25 -0
- package/node_modules/underscore/cjs/escape.js +7 -0
- package/node_modules/underscore/cjs/every.js +17 -0
- package/node_modules/underscore/cjs/extend.js +7 -0
- package/node_modules/underscore/cjs/extendOwn.js +9 -0
- package/node_modules/underscore/cjs/filter.js +14 -0
- package/node_modules/underscore/cjs/find.js +12 -0
- package/node_modules/underscore/cjs/findIndex.js +6 -0
- package/node_modules/underscore/cjs/findKey.js +14 -0
- package/node_modules/underscore/cjs/findLastIndex.js +6 -0
- package/node_modules/underscore/cjs/findWhere.js +10 -0
- package/node_modules/underscore/cjs/first.js +11 -0
- package/node_modules/underscore/cjs/flatten.js +9 -0
- package/node_modules/underscore/cjs/functions.js +12 -0
- package/node_modules/underscore/cjs/get.js +14 -0
- package/node_modules/underscore/cjs/groupBy.js +10 -0
- package/node_modules/underscore/cjs/has.js +18 -0
- package/node_modules/underscore/cjs/identity.js +6 -0
- package/node_modules/underscore/cjs/index-default.js +11 -0
- package/node_modules/underscore/cjs/index.js +277 -0
- package/node_modules/underscore/cjs/indexBy.js +9 -0
- package/node_modules/underscore/cjs/indexOf.js +11 -0
- package/node_modules/underscore/cjs/initial.js +10 -0
- package/node_modules/underscore/cjs/intersection.js +21 -0
- package/node_modules/underscore/cjs/invert.js +13 -0
- package/node_modules/underscore/cjs/invoke.js +30 -0
- package/node_modules/underscore/cjs/isArguments.js +18 -0
- package/node_modules/underscore/cjs/isArray.js +8 -0
- package/node_modules/underscore/cjs/isArrayBuffer.js +5 -0
- package/node_modules/underscore/cjs/isBoolean.js +8 -0
- package/node_modules/underscore/cjs/isDataView.js +16 -0
- package/node_modules/underscore/cjs/isDate.js +5 -0
- package/node_modules/underscore/cjs/isElement.js +6 -0
- package/node_modules/underscore/cjs/isEmpty.js +20 -0
- package/node_modules/underscore/cjs/isEqual.js +140 -0
- package/node_modules/underscore/cjs/isError.js +5 -0
- package/node_modules/underscore/cjs/isFinite.js +9 -0
- package/node_modules/underscore/cjs/isFunction.js +17 -0
- package/node_modules/underscore/cjs/isMap.js +7 -0
- package/node_modules/underscore/cjs/isMatch.js +15 -0
- package/node_modules/underscore/cjs/isNaN.js +9 -0
- package/node_modules/underscore/cjs/isNull.js +6 -0
- package/node_modules/underscore/cjs/isNumber.js +5 -0
- package/node_modules/underscore/cjs/isObject.js +7 -0
- package/node_modules/underscore/cjs/isRegExp.js +5 -0
- package/node_modules/underscore/cjs/isSet.js +7 -0
- package/node_modules/underscore/cjs/isString.js +5 -0
- package/node_modules/underscore/cjs/isSymbol.js +5 -0
- package/node_modules/underscore/cjs/isTypedArray.js +17 -0
- package/node_modules/underscore/cjs/isUndefined.js +6 -0
- package/node_modules/underscore/cjs/isWeakMap.js +7 -0
- package/node_modules/underscore/cjs/isWeakSet.js +5 -0
- package/node_modules/underscore/cjs/iteratee.js +12 -0
- package/node_modules/underscore/cjs/join.js +6 -0
- package/node_modules/underscore/cjs/keys.js +18 -0
- package/node_modules/underscore/cjs/last.js +11 -0
- package/node_modules/underscore/cjs/lastIndexOf.js +8 -0
- package/node_modules/underscore/cjs/map.js +18 -0
- package/node_modules/underscore/cjs/mapObject.js +18 -0
- package/node_modules/underscore/cjs/matcher.js +13 -0
- package/node_modules/underscore/cjs/max.js +31 -0
- package/node_modules/underscore/cjs/memoize.js +15 -0
- package/node_modules/underscore/cjs/min.js +31 -0
- package/node_modules/underscore/cjs/mixin.js +20 -0
- package/node_modules/underscore/cjs/negate.js +8 -0
- package/node_modules/underscore/cjs/noop.js +4 -0
- package/node_modules/underscore/cjs/now.js +6 -0
- package/node_modules/underscore/cjs/object.js +18 -0
- package/node_modules/underscore/cjs/omit.js +24 -0
- package/node_modules/underscore/cjs/once.js +8 -0
- package/node_modules/underscore/cjs/pairs.js +15 -0
- package/node_modules/underscore/cjs/partial.js +25 -0
- package/node_modules/underscore/cjs/partition.js +9 -0
- package/node_modules/underscore/cjs/pick.js +28 -0
- package/node_modules/underscore/cjs/pluck.js +9 -0
- package/node_modules/underscore/cjs/pop.js +6 -0
- package/node_modules/underscore/cjs/property.js +13 -0
- package/node_modules/underscore/cjs/propertyOf.js +12 -0
- package/node_modules/underscore/cjs/push.js +6 -0
- package/node_modules/underscore/cjs/random.js +10 -0
- package/node_modules/underscore/cjs/range.js +23 -0
- package/node_modules/underscore/cjs/reduce.js +7 -0
- package/node_modules/underscore/cjs/reduceRight.js +6 -0
- package/node_modules/underscore/cjs/reject.js +10 -0
- package/node_modules/underscore/cjs/rest.js +10 -0
- package/node_modules/underscore/cjs/restArguments.js +29 -0
- package/node_modules/underscore/cjs/result.js +24 -0
- package/node_modules/underscore/cjs/reverse.js +6 -0
- package/node_modules/underscore/cjs/sample.js +29 -0
- package/node_modules/underscore/cjs/shift.js +6 -0
- package/node_modules/underscore/cjs/shuffle.js +8 -0
- package/node_modules/underscore/cjs/size.js +10 -0
- package/node_modules/underscore/cjs/slice.js +6 -0
- package/node_modules/underscore/cjs/some.js +17 -0
- package/node_modules/underscore/cjs/sort.js +6 -0
- package/node_modules/underscore/cjs/sortBy.js +26 -0
- package/node_modules/underscore/cjs/sortedIndex.js +17 -0
- package/node_modules/underscore/cjs/sortedLastIndex.js +11 -0
- package/node_modules/underscore/cjs/splice.js +6 -0
- package/node_modules/underscore/cjs/tap.js +9 -0
- package/node_modules/underscore/cjs/template.js +95 -0
- package/node_modules/underscore/cjs/templateSettings.js +11 -0
- package/node_modules/underscore/cjs/throttle.js +49 -0
- package/node_modules/underscore/cjs/times.js +11 -0
- package/node_modules/underscore/cjs/toArray.js +22 -0
- package/node_modules/underscore/cjs/toPath.js +11 -0
- package/node_modules/underscore/cjs/toString.js +9 -0
- package/node_modules/underscore/cjs/underscore-array-methods.js +31 -0
- package/node_modules/underscore/cjs/underscore.js +27 -0
- package/node_modules/underscore/cjs/unescape.js +7 -0
- package/node_modules/underscore/cjs/union.js +11 -0
- package/node_modules/underscore/cjs/uniq.js +38 -0
- package/node_modules/underscore/cjs/uniqueId.js +9 -0
- package/node_modules/underscore/cjs/unshift.js +6 -0
- package/node_modules/underscore/cjs/unzip.js +17 -0
- package/node_modules/underscore/cjs/value.js +9 -0
- package/node_modules/underscore/cjs/values.js +14 -0
- package/node_modules/underscore/cjs/where.js +10 -0
- package/node_modules/underscore/cjs/without.js +9 -0
- package/node_modules/underscore/cjs/wrap.js +10 -0
- package/node_modules/underscore/cjs/zip.js +8 -0
- package/node_modules/underscore/modules/.eslintrc +12 -0
- package/node_modules/underscore/modules/_baseCreate.js +18 -0
- package/node_modules/underscore/modules/_baseIteratee.js +17 -0
- package/node_modules/underscore/modules/_cb.js +10 -0
- package/node_modules/underscore/modules/_chainResult.js +6 -0
- package/node_modules/underscore/modules/_collectNonEnumProps.js +40 -0
- package/node_modules/underscore/modules/_createAssigner.js +18 -0
- package/node_modules/underscore/modules/_createEscaper.js +17 -0
- package/node_modules/underscore/modules/_createIndexFinder.js +28 -0
- package/node_modules/underscore/modules/_createPredicateIndexFinder.js +15 -0
- package/node_modules/underscore/modules/_createReduce.js +28 -0
- package/node_modules/underscore/modules/_createSizePropertyCheck.js +9 -0
- package/node_modules/underscore/modules/_deepGet.js +9 -0
- package/node_modules/underscore/modules/_escapeMap.js +9 -0
- package/node_modules/underscore/modules/_executeBound.js +13 -0
- package/node_modules/underscore/modules/_flatten.js +31 -0
- package/node_modules/underscore/modules/_getByteLength.js +4 -0
- package/node_modules/underscore/modules/_getLength.js +4 -0
- package/node_modules/underscore/modules/_group.js +15 -0
- package/node_modules/underscore/modules/_has.js +6 -0
- package/node_modules/underscore/modules/_hasObjectTag.js +3 -0
- package/node_modules/underscore/modules/_isArrayLike.js +8 -0
- package/node_modules/underscore/modules/_isBufferLike.js +6 -0
- package/node_modules/underscore/modules/_keyInObj.js +5 -0
- package/node_modules/underscore/modules/_methodFingerprint.js +37 -0
- package/node_modules/underscore/modules/_optimizeCb.js +21 -0
- package/node_modules/underscore/modules/_setup.js +43 -0
- package/node_modules/underscore/modules/_shallowProperty.js +6 -0
- package/node_modules/underscore/modules/_stringTagBug.js +10 -0
- package/node_modules/underscore/modules/_tagTester.js +9 -0
- package/node_modules/underscore/modules/_toBufferView.js +11 -0
- package/node_modules/underscore/modules/_toPath.js +8 -0
- package/node_modules/underscore/modules/_unescapeMap.js +5 -0
- package/node_modules/underscore/modules/after.js +8 -0
- package/node_modules/underscore/modules/allKeys.js +13 -0
- package/node_modules/underscore/modules/before.js +12 -0
- package/node_modules/underscore/modules/bind.js +13 -0
- package/node_modules/underscore/modules/bindAll.js +17 -0
- package/node_modules/underscore/modules/chain.js +8 -0
- package/node_modules/underscore/modules/chunk.js +13 -0
- package/node_modules/underscore/modules/clone.js +9 -0
- package/node_modules/underscore/modules/compact.js +6 -0
- package/node_modules/underscore/modules/compose.js +12 -0
- package/node_modules/underscore/modules/constant.js +6 -0
- package/node_modules/underscore/modules/contains.js +10 -0
- package/node_modules/underscore/modules/countBy.js +9 -0
- package/node_modules/underscore/modules/create.js +11 -0
- package/node_modules/underscore/modules/debounce.js +40 -0
- package/node_modules/underscore/modules/defaults.js +5 -0
- package/node_modules/underscore/modules/defer.js +7 -0
- package/node_modules/underscore/modules/delay.js +9 -0
- package/node_modules/underscore/modules/difference.js +13 -0
- package/node_modules/underscore/modules/each.js +23 -0
- package/node_modules/underscore/modules/escape.js +5 -0
- package/node_modules/underscore/modules/every.js +15 -0
- package/node_modules/underscore/modules/extend.js +5 -0
- package/node_modules/underscore/modules/extendOwn.js +7 -0
- package/node_modules/underscore/modules/filter.js +12 -0
- package/node_modules/underscore/modules/find.js +10 -0
- package/node_modules/underscore/modules/findIndex.js +4 -0
- package/node_modules/underscore/modules/findKey.js +12 -0
- package/node_modules/underscore/modules/findLastIndex.js +4 -0
- package/node_modules/underscore/modules/findWhere.js +8 -0
- package/node_modules/underscore/modules/first.js +9 -0
- package/node_modules/underscore/modules/flatten.js +7 -0
- package/node_modules/underscore/modules/functions.js +10 -0
- package/node_modules/underscore/modules/get.js +12 -0
- package/node_modules/underscore/modules/groupBy.js +8 -0
- package/node_modules/underscore/modules/has.js +16 -0
- package/node_modules/underscore/modules/identity.js +4 -0
- package/node_modules/underscore/modules/index-all.js +18 -0
- package/node_modules/underscore/modules/index-default.js +27 -0
- package/node_modules/underscore/modules/index.js +200 -0
- package/node_modules/underscore/modules/indexBy.js +7 -0
- package/node_modules/underscore/modules/indexOf.js +9 -0
- package/node_modules/underscore/modules/initial.js +8 -0
- package/node_modules/underscore/modules/intersection.js +19 -0
- package/node_modules/underscore/modules/invert.js +11 -0
- package/node_modules/underscore/modules/invoke.js +28 -0
- package/node_modules/underscore/modules/isArguments.js +16 -0
- package/node_modules/underscore/modules/isArray.js +6 -0
- package/node_modules/underscore/modules/isArrayBuffer.js +3 -0
- package/node_modules/underscore/modules/isBoolean.js +6 -0
- package/node_modules/underscore/modules/isDataView.js +14 -0
- package/node_modules/underscore/modules/isDate.js +3 -0
- package/node_modules/underscore/modules/isElement.js +4 -0
- package/node_modules/underscore/modules/isEmpty.js +18 -0
- package/node_modules/underscore/modules/isEqual.js +138 -0
- package/node_modules/underscore/modules/isError.js +3 -0
- package/node_modules/underscore/modules/isFinite.js +7 -0
- package/node_modules/underscore/modules/isFunction.js +15 -0
- package/node_modules/underscore/modules/isMap.js +5 -0
- package/node_modules/underscore/modules/isMatch.js +13 -0
- package/node_modules/underscore/modules/isNaN.js +7 -0
- package/node_modules/underscore/modules/isNull.js +4 -0
- package/node_modules/underscore/modules/isNumber.js +3 -0
- package/node_modules/underscore/modules/isObject.js +5 -0
- package/node_modules/underscore/modules/isRegExp.js +3 -0
- package/node_modules/underscore/modules/isSet.js +5 -0
- package/node_modules/underscore/modules/isString.js +3 -0
- package/node_modules/underscore/modules/isSymbol.js +3 -0
- package/node_modules/underscore/modules/isTypedArray.js +15 -0
- package/node_modules/underscore/modules/isUndefined.js +4 -0
- package/node_modules/underscore/modules/isWeakMap.js +5 -0
- package/node_modules/underscore/modules/isWeakSet.js +3 -0
- package/node_modules/underscore/modules/iteratee.js +10 -0
- package/node_modules/underscore/modules/keys.js +16 -0
- package/node_modules/underscore/modules/last.js +9 -0
- package/node_modules/underscore/modules/lastIndexOf.js +6 -0
- package/node_modules/underscore/modules/map.js +16 -0
- package/node_modules/underscore/modules/mapObject.js +16 -0
- package/node_modules/underscore/modules/matcher.js +11 -0
- package/node_modules/underscore/modules/max.js +29 -0
- package/node_modules/underscore/modules/memoize.js +13 -0
- package/node_modules/underscore/modules/min.js +29 -0
- package/node_modules/underscore/modules/mixin.js +18 -0
- package/node_modules/underscore/modules/negate.js +6 -0
- package/node_modules/underscore/modules/noop.js +2 -0
- package/node_modules/underscore/modules/now.js +4 -0
- package/node_modules/underscore/modules/object.js +16 -0
- package/node_modules/underscore/modules/omit.js +22 -0
- package/node_modules/underscore/modules/once.js +6 -0
- package/node_modules/underscore/modules/pairs.js +13 -0
- package/node_modules/underscore/modules/partial.js +24 -0
- package/node_modules/underscore/modules/partition.js +7 -0
- package/node_modules/underscore/modules/pick.js +26 -0
- package/node_modules/underscore/modules/pluck.js +7 -0
- package/node_modules/underscore/modules/property.js +11 -0
- package/node_modules/underscore/modules/propertyOf.js +10 -0
- package/node_modules/underscore/modules/random.js +8 -0
- package/node_modules/underscore/modules/range.js +21 -0
- package/node_modules/underscore/modules/reduce.js +5 -0
- package/node_modules/underscore/modules/reduceRight.js +4 -0
- package/node_modules/underscore/modules/reject.js +8 -0
- package/node_modules/underscore/modules/rest.js +8 -0
- package/node_modules/underscore/modules/restArguments.js +27 -0
- package/node_modules/underscore/modules/result.js +22 -0
- package/node_modules/underscore/modules/sample.js +27 -0
- package/node_modules/underscore/modules/shuffle.js +6 -0
- package/node_modules/underscore/modules/size.js +8 -0
- package/node_modules/underscore/modules/some.js +15 -0
- package/node_modules/underscore/modules/sortBy.js +24 -0
- package/node_modules/underscore/modules/sortedIndex.js +15 -0
- package/node_modules/underscore/modules/tap.js +7 -0
- package/node_modules/underscore/modules/template.js +93 -0
- package/node_modules/underscore/modules/templateSettings.js +9 -0
- package/node_modules/underscore/modules/throttle.js +47 -0
- package/node_modules/underscore/modules/times.js +9 -0
- package/node_modules/underscore/modules/toArray.js +20 -0
- package/node_modules/underscore/modules/toPath.js +9 -0
- package/node_modules/underscore/modules/underscore-array-methods.js +31 -0
- package/node_modules/underscore/modules/underscore.js +25 -0
- package/node_modules/underscore/modules/unescape.js +5 -0
- package/node_modules/underscore/modules/union.js +9 -0
- package/node_modules/underscore/modules/uniq.js +36 -0
- package/node_modules/underscore/modules/uniqueId.js +7 -0
- package/node_modules/underscore/modules/unzip.js +15 -0
- package/node_modules/underscore/modules/values.js +12 -0
- package/node_modules/underscore/modules/where.js +8 -0
- package/node_modules/underscore/modules/without.js +7 -0
- package/node_modules/underscore/modules/wrap.js +8 -0
- package/node_modules/underscore/modules/zip.js +6 -0
- package/node_modules/underscore/package.json +108 -0
- package/node_modules/underscore/underscore-esm-min.js +5 -0
- package/node_modules/underscore/underscore-esm-min.js.map +1 -0
- package/node_modules/underscore/underscore-esm.js +2026 -0
- package/node_modules/underscore/underscore-esm.js.map +1 -0
- package/node_modules/underscore/underscore-min.js +6 -0
- package/node_modules/underscore/underscore.js +2034 -0
- package/node_modules/underscore/underscore.js.map +1 -0
- package/node_modules/xhr2/CONTRIBUTING.md +33 -0
- package/node_modules/xhr2/Cakefile +131 -0
- package/node_modules/xhr2/LICENSE.txt +19 -0
- package/node_modules/xhr2/lib/browser.js +1 -0
- package/node_modules/xhr2/lib/xhr2.js +1244 -0
- package/node_modules/xhr2/package.json +93 -0
- package/node_modules/xhr2/src/001-xml_http_request.coffee +782 -0
- package/node_modules/xhr2/src/errors.coffee +31 -0
- package/node_modules/xhr2/src/progress_event.coffee +39 -0
- package/node_modules/xhr2/test/fixtures/hello.json +1 -0
- package/node_modules/xhr2/test/fixtures/hello.txt +1 -0
- package/node_modules/xhr2/test/fixtures/xhr2.png +0 -0
- package/node_modules/xhr2/test/html/browser_test.html +30 -0
- package/node_modules/xhr2/test/src/event_target_test.coffee +85 -0
- package/node_modules/xhr2/test/src/events_test.coffee +204 -0
- package/node_modules/xhr2/test/src/headers_test.coffee +165 -0
- package/node_modules/xhr2/test/src/helpers/browser_mocha_setup.coffee +1 -0
- package/node_modules/xhr2/test/src/helpers/setup.coffee +38 -0
- package/node_modules/xhr2/test/src/helpers/xhr_server.coffee +156 -0
- package/node_modules/xhr2/test/src/nodejs_set_test.coffee +162 -0
- package/node_modules/xhr2/test/src/redirect_test.coffee +57 -0
- package/node_modules/xhr2/test/src/response_type_test.coffee +88 -0
- package/node_modules/xhr2/test/src/send_test.coffee +89 -0
- package/node_modules/xhr2/test/src/status_test.coffee +47 -0
- package/node_modules/xhr2/test/src/xhr_test.coffee +102 -0
- package/package.json +29 -29
- package/readme.md +37 -37
|
@@ -0,0 +1,1244 @@
|
|
|
1
|
+
// Generated by CoffeeScript 2.4.1
|
|
2
|
+
(function() {
|
|
3
|
+
// This file's name is set up in such a way that it will always show up first in
|
|
4
|
+
// the list of files given to coffee --join, so that the other files can assume
|
|
5
|
+
// that XMLHttpRequestEventTarget was already defined.
|
|
6
|
+
|
|
7
|
+
// The DOM EventTarget subclass used by XMLHttpRequest.
|
|
8
|
+
|
|
9
|
+
// @see http://xhr.spec.whatwg.org/#interface-xmlhttprequest
|
|
10
|
+
var InvalidStateError, NetworkError, ProgressEvent, SecurityError, SyntaxError, XMLHttpRequest, XMLHttpRequestEventTarget, XMLHttpRequestUpload, http, https, os, url;
|
|
11
|
+
|
|
12
|
+
XMLHttpRequestEventTarget = (function() {
|
|
13
|
+
class XMLHttpRequestEventTarget {
|
|
14
|
+
// @private
|
|
15
|
+
// This is an abstract class and should not be instantiated directly.
|
|
16
|
+
constructor() {
|
|
17
|
+
this.onloadstart = null;
|
|
18
|
+
this.onprogress = null;
|
|
19
|
+
this.onabort = null;
|
|
20
|
+
this.onerror = null;
|
|
21
|
+
this.onload = null;
|
|
22
|
+
this.ontimeout = null;
|
|
23
|
+
this.onloadend = null;
|
|
24
|
+
this._listeners = {};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Adds a new-style listener for one of the XHR events.
|
|
28
|
+
|
|
29
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#events
|
|
30
|
+
|
|
31
|
+
// @param {String} eventType an XHR event type, such as 'readystatechange'
|
|
32
|
+
// @param {function(ProgressEvent)} listener function that will be called when
|
|
33
|
+
// the event fires
|
|
34
|
+
// @return {undefined} undefined
|
|
35
|
+
addEventListener(eventType, listener) {
|
|
36
|
+
var base;
|
|
37
|
+
eventType = eventType.toLowerCase();
|
|
38
|
+
(base = this._listeners)[eventType] || (base[eventType] = []);
|
|
39
|
+
this._listeners[eventType].push(listener);
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Removes an event listener added by calling addEventListener.
|
|
44
|
+
|
|
45
|
+
// @param {String} eventType an XHR event type, such as 'readystatechange'
|
|
46
|
+
// @param {function(ProgressEvent)} listener the value passed in a previous
|
|
47
|
+
// call to addEventListener.
|
|
48
|
+
// @return {undefined} undefined
|
|
49
|
+
removeEventListener(eventType, listener) {
|
|
50
|
+
var index;
|
|
51
|
+
eventType = eventType.toLowerCase();
|
|
52
|
+
if (this._listeners[eventType]) {
|
|
53
|
+
index = this._listeners[eventType].indexOf(listener);
|
|
54
|
+
if (index !== -1) {
|
|
55
|
+
this._listeners[eventType].splice(index, 1);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Calls all the listeners for an event.
|
|
62
|
+
|
|
63
|
+
// @param {ProgressEvent} event the event to be dispatched
|
|
64
|
+
// @return {undefined} undefined
|
|
65
|
+
dispatchEvent(event) {
|
|
66
|
+
var eventType, j, len, listener, listeners;
|
|
67
|
+
event.currentTarget = event.target = this;
|
|
68
|
+
eventType = event.type;
|
|
69
|
+
if (listeners = this._listeners[eventType]) {
|
|
70
|
+
for (j = 0, len = listeners.length; j < len; j++) {
|
|
71
|
+
listener = listeners[j];
|
|
72
|
+
listener.call(this, event);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (listener = this[`on${eventType}`]) {
|
|
76
|
+
listener.call(this, event);
|
|
77
|
+
}
|
|
78
|
+
return void 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// @property {function(ProgressEvent)} DOM level 0-style handler
|
|
84
|
+
// for the 'loadstart' event
|
|
85
|
+
XMLHttpRequestEventTarget.prototype.onloadstart = null;
|
|
86
|
+
|
|
87
|
+
// @property {function(ProgressEvent)} DOM level 0-style handler
|
|
88
|
+
// for the 'progress' event
|
|
89
|
+
XMLHttpRequestEventTarget.prototype.onprogress = null;
|
|
90
|
+
|
|
91
|
+
// @property {function(ProgressEvent)} DOM level 0-style handler
|
|
92
|
+
// for the 'abort' event
|
|
93
|
+
XMLHttpRequestEventTarget.prototype.onabort = null;
|
|
94
|
+
|
|
95
|
+
// @property {function(ProgressEvent)} DOM level 0-style handler
|
|
96
|
+
// for the 'error' event
|
|
97
|
+
XMLHttpRequestEventTarget.prototype.onerror = null;
|
|
98
|
+
|
|
99
|
+
// @property {function(ProgressEvent)} DOM level 0-style handler
|
|
100
|
+
// for the 'load' event
|
|
101
|
+
XMLHttpRequestEventTarget.prototype.onload = null;
|
|
102
|
+
|
|
103
|
+
// @property {function(ProgressEvent)} DOM level 0-style handler
|
|
104
|
+
// for the 'timeout' event
|
|
105
|
+
XMLHttpRequestEventTarget.prototype.ontimeout = null;
|
|
106
|
+
|
|
107
|
+
// @property {function(ProgressEvent)} DOM level 0-style handler
|
|
108
|
+
// for the 'loadend' event
|
|
109
|
+
XMLHttpRequestEventTarget.prototype.onloadend = null;
|
|
110
|
+
|
|
111
|
+
return XMLHttpRequestEventTarget;
|
|
112
|
+
|
|
113
|
+
}).call(this);
|
|
114
|
+
|
|
115
|
+
// This file's name is set up in such a way that it will always show up second
|
|
116
|
+
// in the list of files given to coffee --join, so it can use the
|
|
117
|
+
// XMLHttpRequestEventTarget definition and so that the other files can assume
|
|
118
|
+
// that XMLHttpRequest was already defined.
|
|
119
|
+
http = require('http');
|
|
120
|
+
|
|
121
|
+
https = require('https');
|
|
122
|
+
|
|
123
|
+
os = require('os');
|
|
124
|
+
|
|
125
|
+
url = require('url');
|
|
126
|
+
|
|
127
|
+
XMLHttpRequest = (function() {
|
|
128
|
+
// The ECMAScript HTTP API.
|
|
129
|
+
|
|
130
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#introduction
|
|
131
|
+
class XMLHttpRequest extends XMLHttpRequestEventTarget {
|
|
132
|
+
// Creates a new request.
|
|
133
|
+
|
|
134
|
+
// @param {Object} options one or more of the options below
|
|
135
|
+
// @option options {Boolean} anon if true, the request's anonymous flag
|
|
136
|
+
// will be set
|
|
137
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#constructors
|
|
138
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#anonymous-flag
|
|
139
|
+
constructor(options) {
|
|
140
|
+
super();
|
|
141
|
+
this.onreadystatechange = null;
|
|
142
|
+
this._anonymous = options && options.anon;
|
|
143
|
+
this.readyState = XMLHttpRequest.UNSENT;
|
|
144
|
+
this.response = null;
|
|
145
|
+
this.responseText = '';
|
|
146
|
+
this.responseType = '';
|
|
147
|
+
this.responseURL = '';
|
|
148
|
+
this.status = 0;
|
|
149
|
+
this.statusText = '';
|
|
150
|
+
this.timeout = 0;
|
|
151
|
+
this.upload = new XMLHttpRequestUpload(this);
|
|
152
|
+
this._method = null; // String
|
|
153
|
+
this._url = null; // Return value of url.parse()
|
|
154
|
+
this._sync = false;
|
|
155
|
+
this._headers = null; // Object<String, String>
|
|
156
|
+
this._loweredHeaders = null; // Object<lowercase String, String>
|
|
157
|
+
this._mimeOverride = null;
|
|
158
|
+
this._request = null; // http.ClientRequest
|
|
159
|
+
this._response = null; // http.ClientResponse
|
|
160
|
+
this._responseParts = null; // Array<Buffer, String>
|
|
161
|
+
this._responseHeaders = null; // Object<lowercase String, String>
|
|
162
|
+
this._aborting = null;
|
|
163
|
+
this._error = null;
|
|
164
|
+
this._loadedBytes = 0;
|
|
165
|
+
this._totalBytes = 0;
|
|
166
|
+
this._lengthComputable = false;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Sets the XHR's method, URL, synchronous flag, and authentication params.
|
|
170
|
+
|
|
171
|
+
// @param {String} method the HTTP method to be used
|
|
172
|
+
// @param {String} url the URL that the request will be made to
|
|
173
|
+
// @param {?Boolean} async if false, the XHR should be processed
|
|
174
|
+
// synchronously; true by default
|
|
175
|
+
// @param {?String} user the user credential to be used in HTTP basic
|
|
176
|
+
// authentication
|
|
177
|
+
// @param {?String} password the password credential to be used in HTTP basic
|
|
178
|
+
// authentication
|
|
179
|
+
// @return {undefined} undefined
|
|
180
|
+
// @throw {SecurityError} method is not one of the allowed methods
|
|
181
|
+
// @throw {SyntaxError} urlString is not a valid URL
|
|
182
|
+
// @throw {Error} the URL contains an unsupported protocol; the supported
|
|
183
|
+
// protocols are file, http and https
|
|
184
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#the-open()-method
|
|
185
|
+
open(method, url, async, user, password) {
|
|
186
|
+
var xhrUrl;
|
|
187
|
+
method = method.toUpperCase();
|
|
188
|
+
if (method in this._restrictedMethods) {
|
|
189
|
+
throw new SecurityError(`HTTP method ${method} is not allowed in XHR`);
|
|
190
|
+
}
|
|
191
|
+
xhrUrl = this._parseUrl(url);
|
|
192
|
+
if (async === void 0) {
|
|
193
|
+
async = true;
|
|
194
|
+
}
|
|
195
|
+
switch (this.readyState) {
|
|
196
|
+
case XMLHttpRequest.UNSENT:
|
|
197
|
+
case XMLHttpRequest.OPENED:
|
|
198
|
+
case XMLHttpRequest.DONE:
|
|
199
|
+
// Nothing to do here.
|
|
200
|
+
null;
|
|
201
|
+
break;
|
|
202
|
+
case XMLHttpRequest.HEADERS_RECEIVED:
|
|
203
|
+
case XMLHttpRequest.LOADING:
|
|
204
|
+
// TODO(pwnall): terminate abort(), terminate send()
|
|
205
|
+
null;
|
|
206
|
+
}
|
|
207
|
+
this._method = method;
|
|
208
|
+
this._url = xhrUrl;
|
|
209
|
+
this._sync = !async;
|
|
210
|
+
this._headers = {};
|
|
211
|
+
this._loweredHeaders = {};
|
|
212
|
+
this._mimeOverride = null;
|
|
213
|
+
this._setReadyState(XMLHttpRequest.OPENED);
|
|
214
|
+
this._request = null;
|
|
215
|
+
this._response = null;
|
|
216
|
+
this.status = 0;
|
|
217
|
+
this.statusText = '';
|
|
218
|
+
this._responseParts = [];
|
|
219
|
+
this._responseHeaders = null;
|
|
220
|
+
this._loadedBytes = 0;
|
|
221
|
+
this._totalBytes = 0;
|
|
222
|
+
this._lengthComputable = false;
|
|
223
|
+
return void 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Appends a header to the list of author request headers.
|
|
227
|
+
|
|
228
|
+
// @param {String} name the HTTP header name
|
|
229
|
+
// @param {String} value the HTTP header value
|
|
230
|
+
// @return {undefined} undefined
|
|
231
|
+
// @throw {InvalidStateError} readyState is not OPENED
|
|
232
|
+
// @throw {SyntaxError} name is not a valid HTTP header name or value is not
|
|
233
|
+
// a valid HTTP header value
|
|
234
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader()-method
|
|
235
|
+
setRequestHeader(name, value) {
|
|
236
|
+
var loweredName;
|
|
237
|
+
if (this.readyState !== XMLHttpRequest.OPENED) {
|
|
238
|
+
throw new InvalidStateError("XHR readyState must be OPENED");
|
|
239
|
+
}
|
|
240
|
+
loweredName = name.toLowerCase();
|
|
241
|
+
if (this._restrictedHeaders[loweredName] || /^sec\-/.test(loweredName) || /^proxy-/.test(loweredName)) {
|
|
242
|
+
console.warn(`Refused to set unsafe header "${name}"`);
|
|
243
|
+
return void 0;
|
|
244
|
+
}
|
|
245
|
+
value = value.toString();
|
|
246
|
+
if (loweredName in this._loweredHeaders) {
|
|
247
|
+
// Combine value with the existing header value.
|
|
248
|
+
name = this._loweredHeaders[loweredName];
|
|
249
|
+
this._headers[name] = this._headers[name] + ', ' + value;
|
|
250
|
+
} else {
|
|
251
|
+
// New header.
|
|
252
|
+
this._loweredHeaders[loweredName] = name;
|
|
253
|
+
this._headers[name] = value;
|
|
254
|
+
}
|
|
255
|
+
return void 0;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Initiates the request.
|
|
259
|
+
|
|
260
|
+
// @param {?String, ?ArrayBufferView} data the data to be sent; ignored for
|
|
261
|
+
// GET and HEAD requests
|
|
262
|
+
// @return {undefined} undefined
|
|
263
|
+
// @throw {InvalidStateError} readyState is not OPENED
|
|
264
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#the-send()-method
|
|
265
|
+
send(data) {
|
|
266
|
+
if (this.readyState !== XMLHttpRequest.OPENED) {
|
|
267
|
+
throw new InvalidStateError("XHR readyState must be OPENED");
|
|
268
|
+
}
|
|
269
|
+
if (this._request) {
|
|
270
|
+
throw new InvalidStateError("send() already called");
|
|
271
|
+
}
|
|
272
|
+
switch (this._url.protocol) {
|
|
273
|
+
case 'file:':
|
|
274
|
+
this._sendFile(data);
|
|
275
|
+
break;
|
|
276
|
+
case 'http:':
|
|
277
|
+
case 'https:':
|
|
278
|
+
this._sendHttp(data);
|
|
279
|
+
break;
|
|
280
|
+
default:
|
|
281
|
+
throw new NetworkError(`Unsupported protocol ${this._url.protocol}`);
|
|
282
|
+
}
|
|
283
|
+
return void 0;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// Cancels the network activity performed by this request.
|
|
287
|
+
|
|
288
|
+
// @return {undefined} undefined
|
|
289
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#the-abort()-method
|
|
290
|
+
abort() {
|
|
291
|
+
if (!this._request) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
this._request.abort();
|
|
295
|
+
this._setError();
|
|
296
|
+
this._dispatchProgress('abort');
|
|
297
|
+
this._dispatchProgress('loadend');
|
|
298
|
+
return void 0;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Returns a header value in the HTTP response for this XHR.
|
|
302
|
+
|
|
303
|
+
// @param {String} name case-insensitive HTTP header name
|
|
304
|
+
// @return {?String} value the value of the header whose name matches the
|
|
305
|
+
// given name, or null if there is no such header
|
|
306
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#the-getresponseheader()-method
|
|
307
|
+
getResponseHeader(name) {
|
|
308
|
+
var loweredName;
|
|
309
|
+
if (!this._responseHeaders) {
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
loweredName = name.toLowerCase();
|
|
313
|
+
if (loweredName in this._responseHeaders) {
|
|
314
|
+
return this._responseHeaders[loweredName];
|
|
315
|
+
} else {
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Returns all the HTTP headers in this XHR's response.
|
|
321
|
+
|
|
322
|
+
// @return {String} header lines separated by CR LF, where each header line
|
|
323
|
+
// has the name and value separated by a ": " (colon, space); the empty
|
|
324
|
+
// string is returned if the headers are not available
|
|
325
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#the-getallresponseheaders()-method
|
|
326
|
+
getAllResponseHeaders() {
|
|
327
|
+
var lines, name, value;
|
|
328
|
+
if (!this._responseHeaders) {
|
|
329
|
+
return '';
|
|
330
|
+
}
|
|
331
|
+
lines = (function() {
|
|
332
|
+
var ref, results;
|
|
333
|
+
ref = this._responseHeaders;
|
|
334
|
+
results = [];
|
|
335
|
+
for (name in ref) {
|
|
336
|
+
value = ref[name];
|
|
337
|
+
results.push(`${name}: ${value}`);
|
|
338
|
+
}
|
|
339
|
+
return results;
|
|
340
|
+
}).call(this);
|
|
341
|
+
return lines.join("\r\n");
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Overrides the Content-Type
|
|
345
|
+
|
|
346
|
+
// @return {undefined} undefined
|
|
347
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#the-overridemimetype()-method
|
|
348
|
+
overrideMimeType(newMimeType) {
|
|
349
|
+
if (this.readyState === XMLHttpRequest.LOADING || this.readyState === XMLHttpRequest.DONE) {
|
|
350
|
+
throw new InvalidStateError("overrideMimeType() not allowed in LOADING or DONE");
|
|
351
|
+
}
|
|
352
|
+
this._mimeOverride = newMimeType.toLowerCase();
|
|
353
|
+
return void 0;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// Network configuration not exposed in the XHR API.
|
|
357
|
+
|
|
358
|
+
// Although the XMLHttpRequest specification calls itself "ECMAScript HTTP",
|
|
359
|
+
// it assumes that requests are always performed in the context of a browser
|
|
360
|
+
// application, where some network parameters are set by the browser user and
|
|
361
|
+
// should not be modified by Web applications. This API provides access to
|
|
362
|
+
// these network parameters.
|
|
363
|
+
|
|
364
|
+
// NOTE: this is not in the XMLHttpRequest API, and will not work in
|
|
365
|
+
// browsers. It is a stable node-xhr2 API.
|
|
366
|
+
|
|
367
|
+
// @param {Object} options one or more of the options below
|
|
368
|
+
// @option options {?http.Agent} httpAgent the value for the nodejsHttpAgent
|
|
369
|
+
// property (the agent used for HTTP requests)
|
|
370
|
+
// @option options {?https.Agent} httpsAgent the value for the
|
|
371
|
+
// nodejsHttpsAgent property (the agent used for HTTPS requests)
|
|
372
|
+
// @return {undefined} undefined
|
|
373
|
+
nodejsSet(options) {
|
|
374
|
+
var baseUrl, parsedUrl;
|
|
375
|
+
if ('httpAgent' in options) {
|
|
376
|
+
this.nodejsHttpAgent = options.httpAgent;
|
|
377
|
+
}
|
|
378
|
+
if ('httpsAgent' in options) {
|
|
379
|
+
this.nodejsHttpsAgent = options.httpsAgent;
|
|
380
|
+
}
|
|
381
|
+
if ('baseUrl' in options) {
|
|
382
|
+
baseUrl = options.baseUrl;
|
|
383
|
+
if (baseUrl !== null) {
|
|
384
|
+
parsedUrl = url.parse(baseUrl, false, true);
|
|
385
|
+
if (!parsedUrl.protocol) {
|
|
386
|
+
throw new SyntaxError("baseUrl must be an absolute URL");
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
this.nodejsBaseUrl = baseUrl;
|
|
390
|
+
}
|
|
391
|
+
return void 0;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Default settings for the network configuration not exposed in the XHR API.
|
|
395
|
+
|
|
396
|
+
// NOTE: this is not in the XMLHttpRequest API, and will not work in
|
|
397
|
+
// browsers. It is a stable node-xhr2 API.
|
|
398
|
+
|
|
399
|
+
// @param {Object} options one or more of the options below
|
|
400
|
+
// @option options {?http.Agent} httpAgent the default value for the
|
|
401
|
+
// nodejsHttpAgent property (the agent used for HTTP requests)
|
|
402
|
+
// @option options {https.Agent} httpsAgent the default value for the
|
|
403
|
+
// nodejsHttpsAgent property (the agent used for HTTPS requests)
|
|
404
|
+
// @return {undefined} undefined
|
|
405
|
+
// @see XMLHttpRequest.nodejsSet
|
|
406
|
+
static nodejsSet(options) {
|
|
407
|
+
// "this" will be set to XMLHttpRequest.prototype, so the instance nodejsSet
|
|
408
|
+
// operates on default property values.
|
|
409
|
+
XMLHttpRequest.prototype.nodejsSet(options);
|
|
410
|
+
return void 0;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// Sets the readyState property and fires the readystatechange event.
|
|
414
|
+
|
|
415
|
+
// @private
|
|
416
|
+
// @param {Number} newReadyState the new value of readyState
|
|
417
|
+
// @return {undefined} undefined
|
|
418
|
+
_setReadyState(newReadyState) {
|
|
419
|
+
var event;
|
|
420
|
+
this.readyState = newReadyState;
|
|
421
|
+
event = new ProgressEvent('readystatechange');
|
|
422
|
+
this.dispatchEvent(event);
|
|
423
|
+
return void 0;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// XMLHttpRequest#send() implementation for the file: protocol.
|
|
427
|
+
|
|
428
|
+
// @private
|
|
429
|
+
_sendFile() {
|
|
430
|
+
if (this._url.method !== 'GET') {
|
|
431
|
+
throw new NetworkError('The file protocol only supports GET');
|
|
432
|
+
}
|
|
433
|
+
throw new Error("Protocol file: not implemented");
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// XMLHttpRequest#send() implementation for the http: and https: protocols.
|
|
437
|
+
|
|
438
|
+
// @private
|
|
439
|
+
// This method sets the instance variables and calls _sendHxxpRequest(), which
|
|
440
|
+
// is responsible for building a node.js request and firing it off. The code
|
|
441
|
+
// in _sendHxxpRequest() is separated off so it can be reused when handling
|
|
442
|
+
// redirects.
|
|
443
|
+
|
|
444
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#infrastructure-for-the-send()-method
|
|
445
|
+
_sendHttp(data) {
|
|
446
|
+
if (this._sync) {
|
|
447
|
+
throw new Error("Synchronous XHR processing not implemented");
|
|
448
|
+
}
|
|
449
|
+
if ((data != null) && (this._method === 'GET' || this._method === 'HEAD')) {
|
|
450
|
+
console.warn(`Discarding entity body for ${this._method} requests`);
|
|
451
|
+
data = null;
|
|
452
|
+
} else {
|
|
453
|
+
// Send Content-Length: 0
|
|
454
|
+
data || (data = '');
|
|
455
|
+
}
|
|
456
|
+
// NOTE: this is called before finalizeHeaders so that the uploader can
|
|
457
|
+
// figure out Content-Length and Content-Type.
|
|
458
|
+
this.upload._setData(data);
|
|
459
|
+
this._finalizeHeaders();
|
|
460
|
+
this._sendHxxpRequest();
|
|
461
|
+
return void 0;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// Sets up and fires off a HTTP/HTTPS request using the node.js API.
|
|
465
|
+
|
|
466
|
+
// @private
|
|
467
|
+
// This method contains the bulk of the XMLHttpRequest#send() implementation,
|
|
468
|
+
// and is also used to issue new HTTP requests when handling HTTP redirects.
|
|
469
|
+
|
|
470
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#infrastructure-for-the-send()-method
|
|
471
|
+
_sendHxxpRequest() {
|
|
472
|
+
var agent, hxxp, request;
|
|
473
|
+
if (this._url.protocol === 'http:') {
|
|
474
|
+
hxxp = http;
|
|
475
|
+
agent = this.nodejsHttpAgent;
|
|
476
|
+
} else {
|
|
477
|
+
hxxp = https;
|
|
478
|
+
agent = this.nodejsHttpsAgent;
|
|
479
|
+
}
|
|
480
|
+
request = hxxp.request({
|
|
481
|
+
hostname: this._url.hostname,
|
|
482
|
+
port: this._url.port,
|
|
483
|
+
path: this._url.path,
|
|
484
|
+
auth: this._url.auth,
|
|
485
|
+
method: this._method,
|
|
486
|
+
headers: this._headers,
|
|
487
|
+
agent: agent
|
|
488
|
+
});
|
|
489
|
+
this._request = request;
|
|
490
|
+
if (this.timeout) {
|
|
491
|
+
request.setTimeout(this.timeout, () => {
|
|
492
|
+
return this._onHttpTimeout(request);
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
request.on('response', (response) => {
|
|
496
|
+
return this._onHttpResponse(request, response);
|
|
497
|
+
});
|
|
498
|
+
request.on('error', (error) => {
|
|
499
|
+
return this._onHttpRequestError(request, error);
|
|
500
|
+
});
|
|
501
|
+
this.upload._startUpload(request);
|
|
502
|
+
if (this._request === request) { // An http error might have already fired.
|
|
503
|
+
this._dispatchProgress('loadstart');
|
|
504
|
+
}
|
|
505
|
+
return void 0;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// Fills in the restricted HTTP headers with default values.
|
|
509
|
+
|
|
510
|
+
// This is called right before the HTTP request is sent off.
|
|
511
|
+
|
|
512
|
+
// @private
|
|
513
|
+
// @return {undefined} undefined
|
|
514
|
+
_finalizeHeaders() {
|
|
515
|
+
this._headers['Connection'] = 'keep-alive';
|
|
516
|
+
this._headers['Host'] = this._url.host;
|
|
517
|
+
if (this._anonymous) {
|
|
518
|
+
this._headers['Referer'] = 'about:blank';
|
|
519
|
+
}
|
|
520
|
+
this._headers['User-Agent'] = this._userAgent;
|
|
521
|
+
this.upload._finalizeHeaders(this._headers, this._loweredHeaders);
|
|
522
|
+
return void 0;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// Called when the headers of an HTTP response have been received.
|
|
526
|
+
|
|
527
|
+
// @private
|
|
528
|
+
// @param {http.ClientRequest} request the node.js ClientRequest instance that
|
|
529
|
+
// produced this response
|
|
530
|
+
// @param {http.ClientResponse} response the node.js ClientResponse instance
|
|
531
|
+
// passed to
|
|
532
|
+
_onHttpResponse(request, response) {
|
|
533
|
+
var lengthString;
|
|
534
|
+
if (this._request !== request) {
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
// Transparent redirection handling.
|
|
538
|
+
switch (response.statusCode) {
|
|
539
|
+
case 301:
|
|
540
|
+
case 302:
|
|
541
|
+
case 303:
|
|
542
|
+
case 307:
|
|
543
|
+
case 308:
|
|
544
|
+
this._url = this._parseUrl(response.headers['location']);
|
|
545
|
+
this._method = 'GET';
|
|
546
|
+
if ('content-type' in this._loweredHeaders) {
|
|
547
|
+
delete this._headers[this._loweredHeaders['content-type']];
|
|
548
|
+
delete this._loweredHeaders['content-type'];
|
|
549
|
+
}
|
|
550
|
+
// XMLHttpRequestUpload#_finalizeHeaders() sets Content-Type directly.
|
|
551
|
+
if ('Content-Type' in this._headers) {
|
|
552
|
+
delete this._headers['Content-Type'];
|
|
553
|
+
}
|
|
554
|
+
// Restricted headers can't be set by the user, no need to check
|
|
555
|
+
// loweredHeaders.
|
|
556
|
+
delete this._headers['Content-Length'];
|
|
557
|
+
this.upload._reset();
|
|
558
|
+
this._finalizeHeaders();
|
|
559
|
+
this._sendHxxpRequest();
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
this._response = response;
|
|
563
|
+
this._response.on('data', (data) => {
|
|
564
|
+
return this._onHttpResponseData(response, data);
|
|
565
|
+
});
|
|
566
|
+
this._response.on('end', () => {
|
|
567
|
+
return this._onHttpResponseEnd(response);
|
|
568
|
+
});
|
|
569
|
+
this._response.on('close', () => {
|
|
570
|
+
return this._onHttpResponseClose(response);
|
|
571
|
+
});
|
|
572
|
+
this.responseURL = this._url.href.split('#')[0];
|
|
573
|
+
this.status = this._response.statusCode;
|
|
574
|
+
this.statusText = http.STATUS_CODES[this.status];
|
|
575
|
+
this._parseResponseHeaders(response);
|
|
576
|
+
if (lengthString = this._responseHeaders['content-length']) {
|
|
577
|
+
this._totalBytes = parseInt(lengthString);
|
|
578
|
+
this._lengthComputable = true;
|
|
579
|
+
} else {
|
|
580
|
+
this._lengthComputable = false;
|
|
581
|
+
}
|
|
582
|
+
return this._setReadyState(XMLHttpRequest.HEADERS_RECEIVED);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// Called when some data has been received on a HTTP connection.
|
|
586
|
+
|
|
587
|
+
// @private
|
|
588
|
+
// @param {http.ClientResponse} response the node.js ClientResponse instance
|
|
589
|
+
// that fired this event
|
|
590
|
+
// @param {String, Buffer} data the data that has been received
|
|
591
|
+
_onHttpResponseData(response, data) {
|
|
592
|
+
if (this._response !== response) {
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
this._responseParts.push(data);
|
|
596
|
+
this._loadedBytes += data.length;
|
|
597
|
+
if (this.readyState !== XMLHttpRequest.LOADING) {
|
|
598
|
+
this._setReadyState(XMLHttpRequest.LOADING);
|
|
599
|
+
}
|
|
600
|
+
return this._dispatchProgress('progress');
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// Called when the HTTP request finished processing.
|
|
604
|
+
|
|
605
|
+
// @private
|
|
606
|
+
// @param {http.ClientResponse} response the node.js ClientResponse instance
|
|
607
|
+
// that fired this event
|
|
608
|
+
_onHttpResponseEnd(response) {
|
|
609
|
+
if (this._response !== response) {
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
this._parseResponse();
|
|
613
|
+
this._request = null;
|
|
614
|
+
this._response = null;
|
|
615
|
+
this._setReadyState(XMLHttpRequest.DONE);
|
|
616
|
+
this._dispatchProgress('load');
|
|
617
|
+
return this._dispatchProgress('loadend');
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// Called when the underlying HTTP connection was closed prematurely.
|
|
621
|
+
|
|
622
|
+
// If this method is called, it will be called after or instead of
|
|
623
|
+
// onHttpResponseEnd.
|
|
624
|
+
|
|
625
|
+
// @private
|
|
626
|
+
// @param {http.ClientResponse} response the node.js ClientResponse instance
|
|
627
|
+
// that fired this event
|
|
628
|
+
_onHttpResponseClose(response) {
|
|
629
|
+
var request;
|
|
630
|
+
if (this._response !== response) {
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
request = this._request;
|
|
634
|
+
this._setError();
|
|
635
|
+
request.abort();
|
|
636
|
+
this._setReadyState(XMLHttpRequest.DONE);
|
|
637
|
+
this._dispatchProgress('error');
|
|
638
|
+
return this._dispatchProgress('loadend');
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
// Called when the timeout set on the HTTP socket expires.
|
|
642
|
+
|
|
643
|
+
// @private
|
|
644
|
+
// @param {http.ClientRequest} request the node.js ClientRequest instance that
|
|
645
|
+
// fired this event
|
|
646
|
+
_onHttpTimeout(request) {
|
|
647
|
+
if (this._request !== request) {
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
this._setError();
|
|
651
|
+
request.abort();
|
|
652
|
+
this._setReadyState(XMLHttpRequest.DONE);
|
|
653
|
+
this._dispatchProgress('timeout');
|
|
654
|
+
return this._dispatchProgress('loadend');
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// Called when something wrong happens on the HTTP socket
|
|
658
|
+
|
|
659
|
+
// @private
|
|
660
|
+
// @param {http.ClientRequest} request the node.js ClientRequest instance that
|
|
661
|
+
// fired this event
|
|
662
|
+
// @param {Error} error emitted exception
|
|
663
|
+
_onHttpRequestError(request, error) {
|
|
664
|
+
if (this._request !== request) {
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
this._setError();
|
|
668
|
+
request.abort();
|
|
669
|
+
this._setReadyState(XMLHttpRequest.DONE);
|
|
670
|
+
this._dispatchProgress('error');
|
|
671
|
+
return this._dispatchProgress('loadend');
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
// Fires an XHR progress event.
|
|
675
|
+
|
|
676
|
+
// @private
|
|
677
|
+
// @param {String} eventType one of the XHR progress event types, such as
|
|
678
|
+
// 'load' and 'progress'
|
|
679
|
+
_dispatchProgress(eventType) {
|
|
680
|
+
var event;
|
|
681
|
+
event = new ProgressEvent(eventType);
|
|
682
|
+
event.lengthComputable = this._lengthComputable;
|
|
683
|
+
event.loaded = this._loadedBytes;
|
|
684
|
+
event.total = this._totalBytes;
|
|
685
|
+
this.dispatchEvent(event);
|
|
686
|
+
return void 0;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// Sets up the XHR to reflect the fact that an error has occurred.
|
|
690
|
+
|
|
691
|
+
// The possible errors are a network error, a timeout, or an abort.
|
|
692
|
+
|
|
693
|
+
// @private
|
|
694
|
+
_setError() {
|
|
695
|
+
this._request = null;
|
|
696
|
+
this._response = null;
|
|
697
|
+
this._responseHeaders = null;
|
|
698
|
+
this._responseParts = null;
|
|
699
|
+
return void 0;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
// Parses a request URL string.
|
|
703
|
+
|
|
704
|
+
// @private
|
|
705
|
+
// This method is a thin wrapper around url.parse() that normalizes HTTP
|
|
706
|
+
// user/password credentials. It is used to parse the URL string passed to
|
|
707
|
+
// XMLHttpRequest#open() and the URLs in the Location headers of HTTP redirect
|
|
708
|
+
// responses.
|
|
709
|
+
|
|
710
|
+
// @param {String} urlString the URL to be parsed
|
|
711
|
+
// @return {Object} parsed URL
|
|
712
|
+
_parseUrl(urlString) {
|
|
713
|
+
var absoluteUrlString, index, password, user, xhrUrl;
|
|
714
|
+
if (this.nodejsBaseUrl === null) {
|
|
715
|
+
absoluteUrlString = urlString;
|
|
716
|
+
} else {
|
|
717
|
+
absoluteUrlString = url.resolve(this.nodejsBaseUrl, urlString);
|
|
718
|
+
}
|
|
719
|
+
xhrUrl = url.parse(absoluteUrlString, false, true);
|
|
720
|
+
xhrUrl.hash = null;
|
|
721
|
+
if (xhrUrl.auth && ((typeof user !== "undefined" && user !== null) || (typeof password !== "undefined" && password !== null))) {
|
|
722
|
+
index = xhrUrl.auth.indexOf(':');
|
|
723
|
+
if (index === -1) {
|
|
724
|
+
if (!user) {
|
|
725
|
+
user = xhrUrl.auth;
|
|
726
|
+
}
|
|
727
|
+
} else {
|
|
728
|
+
if (!user) {
|
|
729
|
+
user = xhrUrl.substring(0, index);
|
|
730
|
+
}
|
|
731
|
+
if (!password) {
|
|
732
|
+
password = xhrUrl.substring(index + 1);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
if (user || password) {
|
|
737
|
+
xhrUrl.auth = `${user}:${password}`;
|
|
738
|
+
}
|
|
739
|
+
return xhrUrl;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
// Reads the headers from a node.js ClientResponse instance.
|
|
743
|
+
|
|
744
|
+
// @private
|
|
745
|
+
// @param {http.ClientResponse} response the response whose headers will be
|
|
746
|
+
// imported into this XMLHttpRequest's state
|
|
747
|
+
// @return {undefined} undefined
|
|
748
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#the-getresponseheader()-method
|
|
749
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#the-getallresponseheaders()-method
|
|
750
|
+
_parseResponseHeaders(response) {
|
|
751
|
+
var loweredName, name, ref, value;
|
|
752
|
+
this._responseHeaders = {};
|
|
753
|
+
ref = response.headers;
|
|
754
|
+
for (name in ref) {
|
|
755
|
+
value = ref[name];
|
|
756
|
+
loweredName = name.toLowerCase();
|
|
757
|
+
if (this._privateHeaders[loweredName]) {
|
|
758
|
+
continue;
|
|
759
|
+
}
|
|
760
|
+
if (this._mimeOverride !== null && loweredName === 'content-type') {
|
|
761
|
+
value = this._mimeOverride;
|
|
762
|
+
}
|
|
763
|
+
this._responseHeaders[loweredName] = value;
|
|
764
|
+
}
|
|
765
|
+
if (this._mimeOverride !== null && !('content-type' in this._responseHeaders)) {
|
|
766
|
+
this._responseHeaders['content-type'] = this._mimeOverride;
|
|
767
|
+
}
|
|
768
|
+
return void 0;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
// Sets the response and responseText properties when an XHR completes.
|
|
772
|
+
|
|
773
|
+
// @private
|
|
774
|
+
// @return {undefined} undefined
|
|
775
|
+
_parseResponse() {
|
|
776
|
+
var arrayBuffer, buffer, i, j, jsonError, ref, view;
|
|
777
|
+
if (Buffer.concat) {
|
|
778
|
+
buffer = Buffer.concat(this._responseParts);
|
|
779
|
+
} else {
|
|
780
|
+
// node 0.6
|
|
781
|
+
buffer = this._concatBuffers(this._responseParts);
|
|
782
|
+
}
|
|
783
|
+
this._responseParts = null;
|
|
784
|
+
switch (this.responseType) {
|
|
785
|
+
case 'text':
|
|
786
|
+
this._parseTextResponse(buffer);
|
|
787
|
+
break;
|
|
788
|
+
case 'json':
|
|
789
|
+
this.responseText = null;
|
|
790
|
+
try {
|
|
791
|
+
this.response = JSON.parse(buffer.toString('utf-8'));
|
|
792
|
+
} catch (error1) {
|
|
793
|
+
jsonError = error1;
|
|
794
|
+
this.response = null;
|
|
795
|
+
}
|
|
796
|
+
break;
|
|
797
|
+
case 'buffer':
|
|
798
|
+
this.responseText = null;
|
|
799
|
+
this.response = buffer;
|
|
800
|
+
break;
|
|
801
|
+
case 'arraybuffer':
|
|
802
|
+
this.responseText = null;
|
|
803
|
+
arrayBuffer = new ArrayBuffer(buffer.length);
|
|
804
|
+
view = new Uint8Array(arrayBuffer);
|
|
805
|
+
for (i = j = 0, ref = buffer.length; (0 <= ref ? j < ref : j > ref); i = 0 <= ref ? ++j : --j) {
|
|
806
|
+
view[i] = buffer[i];
|
|
807
|
+
}
|
|
808
|
+
this.response = arrayBuffer;
|
|
809
|
+
break;
|
|
810
|
+
default:
|
|
811
|
+
// TODO(pwnall): content-base detection
|
|
812
|
+
this._parseTextResponse(buffer);
|
|
813
|
+
}
|
|
814
|
+
return void 0;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// Sets response and responseText for a 'text' response type.
|
|
818
|
+
|
|
819
|
+
// @private
|
|
820
|
+
// @param {Buffer} buffer the node.js Buffer containing the binary response
|
|
821
|
+
// @return {undefined} undefined
|
|
822
|
+
_parseTextResponse(buffer) {
|
|
823
|
+
var e;
|
|
824
|
+
try {
|
|
825
|
+
this.responseText = buffer.toString(this._parseResponseEncoding());
|
|
826
|
+
} catch (error1) {
|
|
827
|
+
e = error1;
|
|
828
|
+
// Unknown encoding.
|
|
829
|
+
this.responseText = buffer.toString('binary');
|
|
830
|
+
}
|
|
831
|
+
this.response = this.responseText;
|
|
832
|
+
return void 0;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
// Figures out the string encoding of the XHR's response.
|
|
836
|
+
|
|
837
|
+
// This is called to determine the encoding when responseText is set.
|
|
838
|
+
|
|
839
|
+
// @private
|
|
840
|
+
// @return {String} a string encoding, e.g. 'utf-8'
|
|
841
|
+
_parseResponseEncoding() {
|
|
842
|
+
var contentType, encoding, match;
|
|
843
|
+
encoding = null;
|
|
844
|
+
if (contentType = this._responseHeaders['content-type']) {
|
|
845
|
+
if (match = /\;\s*charset\=(.*)$/.exec(contentType)) {
|
|
846
|
+
return match[1];
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
return 'utf-8';
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
// Buffer.concat implementation for node 0.6.
|
|
853
|
+
|
|
854
|
+
// @private
|
|
855
|
+
// @param {Array<Buffer>} buffers the buffers whose contents will be merged
|
|
856
|
+
// @return {Buffer} same as Buffer.concat(buffers) in node 0.8 and above
|
|
857
|
+
_concatBuffers(buffers) {
|
|
858
|
+
var buffer, j, k, len, len1, length, target;
|
|
859
|
+
if (buffers.length === 0) {
|
|
860
|
+
return Buffer.alloc(0);
|
|
861
|
+
}
|
|
862
|
+
if (buffers.length === 1) {
|
|
863
|
+
return buffers[0];
|
|
864
|
+
}
|
|
865
|
+
length = 0;
|
|
866
|
+
for (j = 0, len = buffers.length; j < len; j++) {
|
|
867
|
+
buffer = buffers[j];
|
|
868
|
+
length += buffer.length;
|
|
869
|
+
}
|
|
870
|
+
target = Buffer.alloc(length);
|
|
871
|
+
length = 0;
|
|
872
|
+
for (k = 0, len1 = buffers.length; k < len1; k++) {
|
|
873
|
+
buffer = buffers[k];
|
|
874
|
+
buffer.copy(target, length);
|
|
875
|
+
length += buffer.length;
|
|
876
|
+
}
|
|
877
|
+
return target;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
};
|
|
881
|
+
|
|
882
|
+
// @property {function(ProgressEvent)} DOM level 0-style handler for the
|
|
883
|
+
// 'readystatechange' event
|
|
884
|
+
XMLHttpRequest.prototype.onreadystatechange = null;
|
|
885
|
+
|
|
886
|
+
// @property {Number} the current state of the XHR object
|
|
887
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#states
|
|
888
|
+
XMLHttpRequest.prototype.readyState = null;
|
|
889
|
+
|
|
890
|
+
// @property {String, ArrayBuffer, Buffer, Object} processed XHR response
|
|
891
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#the-response-attribute
|
|
892
|
+
XMLHttpRequest.prototype.response = null;
|
|
893
|
+
|
|
894
|
+
// @property {String} response string, if responseType is '' or 'text'
|
|
895
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#the-responsetext-attribute
|
|
896
|
+
XMLHttpRequest.prototype.responseText = null;
|
|
897
|
+
|
|
898
|
+
// @property {String} sets the parsing method for the XHR response
|
|
899
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#the-responsetype-attribute
|
|
900
|
+
XMLHttpRequest.prototype.responseType = null;
|
|
901
|
+
|
|
902
|
+
// @property {Number} the HTTP
|
|
903
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#the-status-attribute
|
|
904
|
+
XMLHttpRequest.prototype.status = null;
|
|
905
|
+
|
|
906
|
+
// @property {Number} milliseconds to wait for the request to complete
|
|
907
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#the-timeout-attribute
|
|
908
|
+
XMLHttpRequest.prototype.timeout = null;
|
|
909
|
+
|
|
910
|
+
// @property {XMLHttpRequestUpload} the associated upload information
|
|
911
|
+
// @see http://www.w3.org/TR/XMLHttpRequest/#the-upload-attribute
|
|
912
|
+
XMLHttpRequest.prototype.upload = null;
|
|
913
|
+
|
|
914
|
+
// readyState value before XMLHttpRequest#open() is called
|
|
915
|
+
XMLHttpRequest.prototype.UNSENT = 0;
|
|
916
|
+
|
|
917
|
+
// readyState value before XMLHttpRequest#open() is called
|
|
918
|
+
XMLHttpRequest.UNSENT = 0;
|
|
919
|
+
|
|
920
|
+
// readyState value after XMLHttpRequest#open() is called, and before
|
|
921
|
+
// XMLHttpRequest#send() is called; XMLHttpRequest#setRequestHeader() can be
|
|
922
|
+
// called in this state
|
|
923
|
+
XMLHttpRequest.prototype.OPENED = 1;
|
|
924
|
+
|
|
925
|
+
// readyState value after XMLHttpRequest#open() is called, and before
|
|
926
|
+
// XMLHttpRequest#send() is called; XMLHttpRequest#setRequestHeader() can be
|
|
927
|
+
// called in this state
|
|
928
|
+
XMLHttpRequest.OPENED = 1;
|
|
929
|
+
|
|
930
|
+
// readyState value after redirects have been followed and the HTTP headers of
|
|
931
|
+
// the final response have been received
|
|
932
|
+
XMLHttpRequest.prototype.HEADERS_RECEIVED = 2;
|
|
933
|
+
|
|
934
|
+
// readyState value after redirects have been followed and the HTTP headers of
|
|
935
|
+
// the final response have been received
|
|
936
|
+
XMLHttpRequest.HEADERS_RECEIVED = 2;
|
|
937
|
+
|
|
938
|
+
// readyState value when the response entity body is being received
|
|
939
|
+
XMLHttpRequest.prototype.LOADING = 3;
|
|
940
|
+
|
|
941
|
+
// readyState value when the response entity body is being received
|
|
942
|
+
XMLHttpRequest.LOADING = 3;
|
|
943
|
+
|
|
944
|
+
// readyState value after the request has been completely processed
|
|
945
|
+
XMLHttpRequest.prototype.DONE = 4;
|
|
946
|
+
|
|
947
|
+
// readyState value after the request has been completely processed
|
|
948
|
+
XMLHttpRequest.DONE = 4;
|
|
949
|
+
|
|
950
|
+
// @property {http.Agent} the agent option passed to HTTP requests
|
|
951
|
+
|
|
952
|
+
// NOTE: this is not in the XMLHttpRequest API, and will not work in browsers.
|
|
953
|
+
// It is a stable node-xhr2 API that is useful for testing & going through
|
|
954
|
+
// web-proxies.
|
|
955
|
+
XMLHttpRequest.prototype.nodejsHttpAgent = http.globalAgent;
|
|
956
|
+
|
|
957
|
+
// @property {https.Agent} the agent option passed to HTTPS requests
|
|
958
|
+
|
|
959
|
+
// NOTE: this is not in the XMLHttpRequest API, and will not work in browsers.
|
|
960
|
+
// It is a stable node-xhr2 API that is useful for testing & going through
|
|
961
|
+
// web-proxies.
|
|
962
|
+
XMLHttpRequest.prototype.nodejsHttpsAgent = https.globalAgent;
|
|
963
|
+
|
|
964
|
+
// @property {String} the base URL that relative URLs get resolved to
|
|
965
|
+
|
|
966
|
+
// NOTE: this is not in the XMLHttpRequest API, and will not work in browsers.
|
|
967
|
+
// Its browser equivalent is the base URL of the document associated with the
|
|
968
|
+
// Window object. It is a stable node-xhr2 API provided for libraries such as
|
|
969
|
+
// Angular Universal.
|
|
970
|
+
XMLHttpRequest.prototype.nodejsBaseUrl = null;
|
|
971
|
+
|
|
972
|
+
// HTTP methods that are disallowed in the XHR spec.
|
|
973
|
+
|
|
974
|
+
// @private
|
|
975
|
+
// @see Step 6 in http://www.w3.org/TR/XMLHttpRequest/#the-open()-method
|
|
976
|
+
XMLHttpRequest.prototype._restrictedMethods = {
|
|
977
|
+
CONNECT: true,
|
|
978
|
+
TRACE: true,
|
|
979
|
+
TRACK: true
|
|
980
|
+
};
|
|
981
|
+
|
|
982
|
+
// HTTP request headers that are disallowed in the XHR spec.
|
|
983
|
+
|
|
984
|
+
// @private
|
|
985
|
+
// @see Step 5 in
|
|
986
|
+
// http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader()-method
|
|
987
|
+
XMLHttpRequest.prototype._restrictedHeaders = {
|
|
988
|
+
'accept-charset': true,
|
|
989
|
+
'accept-encoding': true,
|
|
990
|
+
'access-control-request-headers': true,
|
|
991
|
+
'access-control-request-method': true,
|
|
992
|
+
connection: true,
|
|
993
|
+
'content-length': true,
|
|
994
|
+
cookie: true,
|
|
995
|
+
cookie2: true,
|
|
996
|
+
date: true,
|
|
997
|
+
dnt: true,
|
|
998
|
+
expect: true,
|
|
999
|
+
host: true,
|
|
1000
|
+
'keep-alive': true,
|
|
1001
|
+
origin: true,
|
|
1002
|
+
referer: true,
|
|
1003
|
+
te: true,
|
|
1004
|
+
trailer: true,
|
|
1005
|
+
'transfer-encoding': true,
|
|
1006
|
+
upgrade: true,
|
|
1007
|
+
'user-agent': true,
|
|
1008
|
+
via: true
|
|
1009
|
+
};
|
|
1010
|
+
|
|
1011
|
+
// HTTP response headers that should not be exposed according to the XHR spec.
|
|
1012
|
+
|
|
1013
|
+
// @private
|
|
1014
|
+
// @see Step 3 in
|
|
1015
|
+
// http://www.w3.org/TR/XMLHttpRequest/#the-getresponseheader()-method
|
|
1016
|
+
XMLHttpRequest.prototype._privateHeaders = {
|
|
1017
|
+
'set-cookie': true,
|
|
1018
|
+
'set-cookie2': true
|
|
1019
|
+
};
|
|
1020
|
+
|
|
1021
|
+
// The value of the User-Agent header.
|
|
1022
|
+
XMLHttpRequest.prototype._userAgent = `Mozilla/5.0 (${os.type()} ${os.arch()}) ` + `node.js/${process.versions.node} v8/${process.versions.v8}`;
|
|
1023
|
+
|
|
1024
|
+
return XMLHttpRequest;
|
|
1025
|
+
|
|
1026
|
+
}).call(this);
|
|
1027
|
+
|
|
1028
|
+
// XMLHttpRequest is the result of require('node-xhr2').
|
|
1029
|
+
module.exports = XMLHttpRequest;
|
|
1030
|
+
|
|
1031
|
+
// Make node-xhr2 work as a drop-in replacement for libraries that promote the
|
|
1032
|
+
// following usage pattern:
|
|
1033
|
+
// var XMLHttpRequest = require('xhr-library-name').XMLHttpRequest
|
|
1034
|
+
XMLHttpRequest.XMLHttpRequest = XMLHttpRequest;
|
|
1035
|
+
|
|
1036
|
+
// This file defines the custom errors used in the XMLHttpRequest specification.
|
|
1037
|
+
|
|
1038
|
+
// Thrown if the XHR security policy is violated.
|
|
1039
|
+
SecurityError = class SecurityError extends Error {
|
|
1040
|
+
// @private
|
|
1041
|
+
constructor() {
|
|
1042
|
+
super();
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
// Thrown if the XHR security policy is violated.
|
|
1048
|
+
XMLHttpRequest.SecurityError = SecurityError;
|
|
1049
|
+
|
|
1050
|
+
// Usually thrown if the XHR is in the wrong readyState for an operation.
|
|
1051
|
+
InvalidStateError = class InvalidStateError extends Error {
|
|
1052
|
+
// @private
|
|
1053
|
+
constructor() {
|
|
1054
|
+
super();
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
};
|
|
1058
|
+
|
|
1059
|
+
// Usually thrown if the XHR is in the wrong readyState for an operation.
|
|
1060
|
+
InvalidStateError = class InvalidStateError extends Error {};
|
|
1061
|
+
|
|
1062
|
+
XMLHttpRequest.InvalidStateError = InvalidStateError;
|
|
1063
|
+
|
|
1064
|
+
// Thrown if there is a problem with the URL passed to the XHR.
|
|
1065
|
+
NetworkError = class NetworkError extends Error {
|
|
1066
|
+
// @private
|
|
1067
|
+
constructor() {
|
|
1068
|
+
super();
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
};
|
|
1072
|
+
|
|
1073
|
+
// Thrown if parsing URLs errors out.
|
|
1074
|
+
XMLHttpRequest.SyntaxError = SyntaxError;
|
|
1075
|
+
|
|
1076
|
+
SyntaxError = class SyntaxError extends Error {
|
|
1077
|
+
// @private:
|
|
1078
|
+
constructor() {
|
|
1079
|
+
super();
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1084
|
+
ProgressEvent = (function() {
|
|
1085
|
+
// http://xhr.spec.whatwg.org/#interface-progressevent
|
|
1086
|
+
class ProgressEvent {
|
|
1087
|
+
// Creates a new event.
|
|
1088
|
+
|
|
1089
|
+
// @param {String} type the event type, e.g. 'readystatechange'; must be
|
|
1090
|
+
// lowercased
|
|
1091
|
+
constructor(type) {
|
|
1092
|
+
this.type = type;
|
|
1093
|
+
this.target = null;
|
|
1094
|
+
this.currentTarget = null;
|
|
1095
|
+
this.lengthComputable = false;
|
|
1096
|
+
this.loaded = 0;
|
|
1097
|
+
this.total = 0;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
};
|
|
1101
|
+
|
|
1102
|
+
// Getting the time from the OS is expensive, skip on that for now.
|
|
1103
|
+
// @timeStamp = Date.now()
|
|
1104
|
+
|
|
1105
|
+
// @property {Boolean} for compatibility with DOM events
|
|
1106
|
+
ProgressEvent.prototype.bubbles = false;
|
|
1107
|
+
|
|
1108
|
+
// @property {Boolean} for fompatibility with DOM events
|
|
1109
|
+
ProgressEvent.prototype.cancelable = false;
|
|
1110
|
+
|
|
1111
|
+
// @property {XMLHttpRequest} the request that caused this event
|
|
1112
|
+
ProgressEvent.prototype.target = null;
|
|
1113
|
+
|
|
1114
|
+
// @property {Number} number of bytes that have already been downloaded or
|
|
1115
|
+
// uploaded
|
|
1116
|
+
ProgressEvent.prototype.loaded = null;
|
|
1117
|
+
|
|
1118
|
+
// @property {Boolean} true if the Content-Length response header is available
|
|
1119
|
+
// and the value of the event's total property is meaningful
|
|
1120
|
+
ProgressEvent.prototype.lengthComputable = null;
|
|
1121
|
+
|
|
1122
|
+
// @property {Number} number of bytes that will be downloaded or uploaded by
|
|
1123
|
+
// the request that fired the event
|
|
1124
|
+
ProgressEvent.prototype.total = null;
|
|
1125
|
+
|
|
1126
|
+
return ProgressEvent;
|
|
1127
|
+
|
|
1128
|
+
}).call(this);
|
|
1129
|
+
|
|
1130
|
+
// The XHR spec exports the ProgressEvent constructor.
|
|
1131
|
+
XMLHttpRequest.ProgressEvent = ProgressEvent;
|
|
1132
|
+
|
|
1133
|
+
// @see http://xhr.spec.whatwg.org/#interface-xmlhttprequest
|
|
1134
|
+
XMLHttpRequestUpload = class XMLHttpRequestUpload extends XMLHttpRequestEventTarget {
|
|
1135
|
+
// @private
|
|
1136
|
+
// @param {XMLHttpRequest} the XMLHttpRequest that this upload object is
|
|
1137
|
+
// associated with
|
|
1138
|
+
constructor(request) {
|
|
1139
|
+
super();
|
|
1140
|
+
this._request = request;
|
|
1141
|
+
this._reset();
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
// Sets up this Upload to handle a new request.
|
|
1145
|
+
|
|
1146
|
+
// @private
|
|
1147
|
+
// @return {undefined} undefined
|
|
1148
|
+
_reset() {
|
|
1149
|
+
this._contentType = null;
|
|
1150
|
+
this._body = null;
|
|
1151
|
+
return void 0;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
// Implements the upload-related part of the send() XHR specification.
|
|
1155
|
+
|
|
1156
|
+
// @private
|
|
1157
|
+
// @param {?String, ?Buffer, ?ArrayBufferView} data the argument passed to
|
|
1158
|
+
// XMLHttpRequest#send()
|
|
1159
|
+
// @return {undefined} undefined
|
|
1160
|
+
// @see step 4 of http://www.w3.org/TR/XMLHttpRequest/#the-send()-method
|
|
1161
|
+
_setData(data) {
|
|
1162
|
+
var body, i, j, k, offset, ref, ref1, view;
|
|
1163
|
+
if (typeof data === 'undefined' || data === null) {
|
|
1164
|
+
return;
|
|
1165
|
+
}
|
|
1166
|
+
if (typeof data === 'string') {
|
|
1167
|
+
// DOMString
|
|
1168
|
+
if (data.length !== 0) {
|
|
1169
|
+
this._contentType = 'text/plain;charset=UTF-8';
|
|
1170
|
+
}
|
|
1171
|
+
this._body = Buffer.from(data, 'utf8');
|
|
1172
|
+
} else if (Buffer.isBuffer(data)) {
|
|
1173
|
+
// node.js Buffer
|
|
1174
|
+
this._body = data;
|
|
1175
|
+
} else if (data instanceof ArrayBuffer) {
|
|
1176
|
+
// ArrayBuffer arguments were supported in an old revision of the spec.
|
|
1177
|
+
body = Buffer.alloc(data.byteLength);
|
|
1178
|
+
view = new Uint8Array(data);
|
|
1179
|
+
for (i = j = 0, ref = data.byteLength; (0 <= ref ? j < ref : j > ref); i = 0 <= ref ? ++j : --j) {
|
|
1180
|
+
body[i] = view[i];
|
|
1181
|
+
}
|
|
1182
|
+
this._body = body;
|
|
1183
|
+
} else if (data.buffer && data.buffer instanceof ArrayBuffer) {
|
|
1184
|
+
// ArrayBufferView
|
|
1185
|
+
body = Buffer.alloc(data.byteLength);
|
|
1186
|
+
offset = data.byteOffset;
|
|
1187
|
+
view = new Uint8Array(data.buffer);
|
|
1188
|
+
for (i = k = 0, ref1 = data.byteLength; (0 <= ref1 ? k < ref1 : k > ref1); i = 0 <= ref1 ? ++k : --k) {
|
|
1189
|
+
body[i] = view[i + offset];
|
|
1190
|
+
}
|
|
1191
|
+
this._body = body;
|
|
1192
|
+
} else {
|
|
1193
|
+
// NOTE: diverging from the XHR specification of coercing everything else
|
|
1194
|
+
// to Strings via toString() because that behavior masks bugs and is
|
|
1195
|
+
// rarely useful
|
|
1196
|
+
throw new Error(`Unsupported send() data ${data}`);
|
|
1197
|
+
}
|
|
1198
|
+
return void 0;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
// Updates the HTTP headers right before the request is sent.
|
|
1202
|
+
|
|
1203
|
+
// This is used to set data-dependent headers such as Content-Length and
|
|
1204
|
+
// Content-Type.
|
|
1205
|
+
|
|
1206
|
+
// @private
|
|
1207
|
+
// @param {Object<String, String>} headers the HTTP headers to be sent
|
|
1208
|
+
// @param {Object<String, String>} loweredHeaders maps lowercased HTTP header
|
|
1209
|
+
// names (e.g., 'content-type') to the actual names used in the headers
|
|
1210
|
+
// parameter (e.g., 'Content-Type')
|
|
1211
|
+
// @return {undefined} undefined
|
|
1212
|
+
_finalizeHeaders(headers, loweredHeaders) {
|
|
1213
|
+
if (this._contentType) {
|
|
1214
|
+
if (!('content-type' in loweredHeaders)) {
|
|
1215
|
+
headers['Content-Type'] = this._contentType;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
if (this._body) {
|
|
1219
|
+
// Restricted headers can't be set by the user, no need to check
|
|
1220
|
+
// loweredHeaders.
|
|
1221
|
+
headers['Content-Length'] = this._body.length.toString();
|
|
1222
|
+
}
|
|
1223
|
+
return void 0;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
// Starts sending the HTTP request data.
|
|
1227
|
+
|
|
1228
|
+
// @private
|
|
1229
|
+
// @param {http.ClientRequest} request the HTTP request
|
|
1230
|
+
// @return {undefined} undefined
|
|
1231
|
+
_startUpload(request) {
|
|
1232
|
+
if (this._body) {
|
|
1233
|
+
request.write(this._body);
|
|
1234
|
+
}
|
|
1235
|
+
request.end();
|
|
1236
|
+
return void 0;
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
};
|
|
1240
|
+
|
|
1241
|
+
// Export the XMLHttpRequestUpload constructor.
|
|
1242
|
+
XMLHttpRequest.XMLHttpRequestUpload = XMLHttpRequestUpload;
|
|
1243
|
+
|
|
1244
|
+
}).call(this);
|