From 7f16e5112d05160b86026efc3d19c5692ed44e76 Mon Sep 17 00:00:00 2001 From: carsonxu <459452372@qq.com> Date: Wed, 1 Nov 2017 00:18:55 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E5=A6=82=E6=8E=89=20async=20=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/async.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 lib/async.js diff --git a/lib/async.js b/lib/async.js new file mode 100644 index 0000000..d572531 --- /dev/null +++ b/lib/async.js @@ -0,0 +1,56 @@ +var eachLimit = function (arr, limit, iterator, callback) { + callback = callback || function () {}; + if (!arr.length || limit <= 0) { + return callback(); + } + + var completed = 0; + var started = 0; + var running = 0; + + (function replenish () { + if (completed >= arr.length) { + return callback(); + } + + while (running < limit && started < arr.length) { + started += 1; + running += 1; + iterator(arr[started - 1], function (err) { + + if (err) { + callback(err); + callback = function () {}; + } else { + completed += 1; + running -= 1; + if (completed >= arr.length) { + callback(); + } else { + replenish(); + } + } + }); + } + })(); +}; + +var retry = function (times, iterator, callback) { + var next = function (index) { + iterator(function (err, data) { + if (err && index < times) { + next(index + 1); + } else { + callback(err, data); + } + }); + }; + next(1); +}; + +var async = { + eachLimit: eachLimit, + retry: retry +}; + +module.exports = async; \ No newline at end of file From 17f380a5b8a2e514d70ffa617d64edaa75bcc0cc Mon Sep 17 00:00:00 2001 From: carsonxu <459452372@qq.com> Date: Wed, 1 Nov 2017 00:19:25 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E6=94=AF=E6=8C=81=20EventProxy=20?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/event.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/event.js b/src/event.js index e00ea08..75c1827 100644 --- a/src/event.js +++ b/src/event.js @@ -5,6 +5,9 @@ var initEvent = function (cos) { return listeners[action]; }; cos.on = function (action, callback) { + if (action === 'task-list-update') { + console.warn('Event "' + action + '" has been deprecated. Please use "list-update" instead.'); + } getList(action).push(callback); }; cos.off = function (action, callback) { @@ -23,4 +26,9 @@ var initEvent = function (cos) { }; }; -module.exports.init = initEvent; \ No newline at end of file +var EventProxy = function () { + initEvent(this); +}; + +module.exports.init = initEvent; +module.exports.EventProxy = EventProxy; \ No newline at end of file From 605a8956f238c70e8c42f27c3ac3fb214db5af7f Mon Sep 17 00:00:00 2001 From: carsonxu <459452372@qq.com> Date: Wed, 1 Nov 2017 00:19:59 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20onProgress?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/advance.js | 324 ++++++++++++++++++++++++++----------------------- src/base.js | 143 +++++++--------------- 2 files changed, 211 insertions(+), 256 deletions(-) diff --git a/src/advance.js b/src/advance.js index 905df83..9242ee6 100644 --- a/src/advance.js +++ b/src/advance.js @@ -1,22 +1,16 @@ -var Async = require('async'); -var EventProxy = require('eventproxy'); +var Async = require('../lib/async'); +var EventProxy = require('./event').EventProxy; var util = require('./util'); -// 分块上传入口 -function sliceUploadFile(params, callback) { - var taskId = util.uuid(); - params.TaskReady && params.TaskReady(taskId); - this._addTask(taskId, '_sliceUploadFile', params, callback); -} - // 文件分块上传全过程,暴露的分块上传接口 -function _sliceUploadFile (params, callback) { - var proxy = new EventProxy(); +function sliceUploadFile(params, callback) { + var ep = new EventProxy(); var TaskId = params.TaskId; var Bucket = params.Bucket; var Region = params.Region; var Key = params.Key; var Body = params.Body; + var AppId = params.AppId; var SliceSize = params.SliceSize || this.options.ChunkSize; var AsyncLimit = params.AsyncLimit; var StorageClass = params.StorageClass || 'Standard'; @@ -29,40 +23,42 @@ function _sliceUploadFile (params, callback) { StorageClass = null; // 上传过程中出现错误,返回错误 - proxy.all('error', function (err) { + ep.on('error', function (err) { if (!self._isRunningTask(TaskId)) return; return callback(err); }); // 上传分块完成,开始 uploadSliceComplete 操作 - proxy.all('upload_complete', function (UploadCompleteData) { + ep.on('upload_complete', function (UploadCompleteData) { callback(null, UploadCompleteData); }); // 上传分块完成,开始 uploadSliceComplete 操作 - proxy.all('upload_slice_complete', function (data) { + ep.on('upload_slice_complete', function (data) { uploadSliceComplete.call(self, { Bucket: Bucket, Region: Region, Key: Key, + AppId: AppId, UploadId: data.UploadId, SliceList: data.SliceList }, function (err, data) { if (!self._isRunningTask(TaskId)) return; if (err) { - return proxy.emit('error', err); + return ep.emit('error', err); } - proxy.emit('upload_complete', data); + ep.emit('upload_complete', data); }); }); // 获取 UploadId 完成,开始上传每个分片 - proxy.all('get_upload_data_finish', function (UploadData) { + ep.on('get_upload_data_finish', function (UploadData) { uploadSliceList.call(self, { TaskId: TaskId, Bucket: Bucket, Region: Region, Key: Key, + AppId: AppId, Body: Body, FileSize: FileSize, SliceSize: SliceSize, @@ -71,41 +67,35 @@ function _sliceUploadFile (params, callback) { onProgress: onProgress }, function (err, data) { if (!self._isRunningTask(TaskId)) return; - if (err) return proxy.emit('error', err); - proxy.emit('upload_slice_complete', data); + if (err) return ep.emit('error', err); + ep.emit('upload_slice_complete', data); }); }); // 开始获取文件 UploadId,里面会视情况计算 ETag,并比对,保证文件一致性,也优化上传 - proxy.all('get_file_size_finish', function () { + ep.on('get_file_size_finish', function () { if (params.UploadData.UploadId) { - proxy.emit('get_upload_data_finish', params.UploadData); + ep.emit('get_upload_data_finish', params.UploadData); } else { - getUploadIdAndPartList.call(self, { + var _params = util.extend({}, params); + _params = util.extend(_params, { TaskId: TaskId, Bucket: Bucket, Region: Region, Key: Key, + AppId: AppId, StorageClass: StorageClass, Body: Body, FileSize: FileSize, SliceSize: SliceSize, onHashProgress: onHashProgress, - // init params - CacheControl: params.CacheControl, - ContentDisposition: params.ContentDisposition, - ContentEncoding: params.ContentEncoding, - ContentType: params.ContentType, - ACL: params.ACL, - GrantRead: params.GrantRead, - GrantWrite: params.GrantWrite, - GrantFullControl: params.GrantFullControl - }, function (err, UploadData) { + }); + getUploadIdAndPartList.call(self, _params, function (err, UploadData) { if (!self._isRunningTask(TaskId)) return; - if (err) return proxy.emit('error', err); + if (err) return ep.emit('error', err); params.UploadData.UploadId = UploadData.UploadId; params.UploadData.PartList = UploadData.PartList; - proxy.emit('get_upload_data_finish', params.UploadData); + ep.emit('get_upload_data_finish', params.UploadData); }); } }); @@ -113,7 +103,7 @@ function _sliceUploadFile (params, callback) { // 获取上传文件大小 FileSize = Body.size || params.ContentLength; SliceCount = Math.ceil(FileSize / SliceSize); - proxy.emit('get_file_size_finish'); + ep.emit('get_file_size_finish'); } @@ -123,6 +113,7 @@ function getUploadIdAndPartList(params, callback) { var Bucket = params.Bucket; var Region = params.Region; var Key = params.Key; + var AppId = params.AppId; var Body = params.Body; var StorageClass = params.StorageClass; var self = this; @@ -137,38 +128,7 @@ function getUploadIdAndPartList(params, callback) { var progressTimer = 0; var time0 = 0; var size0 = 0; - var onHashProgress = function (immediately) { - var update = function () { - if (!self._isRunningTask(TaskId)) return; - progressTimer = 0; - var time1 = Date.now(); - var speed = parseInt((FinishSize - size0) / ((time1 - time0) / 1000) * 100) / 100 || 0; - var percent = parseInt(FinishSliceCount / SliceCount * 100) / 100 || 0; - time0 = time1; - size0 = FinishSize; - if (params.onHashProgress && typeof params.onHashProgress === 'function') { - try { - params.onHashProgress({ - loaded: FinishSize, - total: FileSize, - speed: speed, - percent: percent - }); - } catch (e) { - } - } - }; - if (immediately) { - if (progressTimer) { - clearTimeout(progressTimer); - progressTimer = 0; - update(); - } - } else { - if (progressTimer) return; - progressTimer = setTimeout(update, self.options.ProgressInterval || 1000); - } - }; + var onHashProgress = util.throttleOnProgress.call(self, FileSize, params.onHashProgress); var getChunkETag = function (PartNumber, callback) { var start = SliceSize * (PartNumber - 1); var end = Math.min(start + SliceSize, FileSize); @@ -193,7 +153,7 @@ function getUploadIdAndPartList(params, callback) { ETag: ETag, Size: ChunkSize }); - onHashProgress(); + onHashProgress({loaded: FinishSize, total: FileSize}); }); } }; @@ -234,14 +194,14 @@ function getUploadIdAndPartList(params, callback) { next(0); }; - var proxy = new EventProxy(); - proxy.all('error', function (errData) { + var ep = new EventProxy(); + ep.on('error', function (errData) { if (!self._isRunningTask(TaskId)) return; return callback(errData); }); // 不存在 UploadId - proxy.all('upload_id_ready', function (UploadData) { + ep.on('upload_id_ready', function (UploadData) { // 转换成 map var map = {}; var list = []; @@ -267,34 +227,29 @@ function getUploadIdAndPartList(params, callback) { }); // 不存在 UploadId, 初始化生成 UploadId - proxy.all('no_available_upload_id', function () { + ep.on('no_available_upload_id', function () { if (!self._isRunningTask(TaskId)) return; - self.multipartInit({ + var _params = util.extend({}, params); + _params = util.extend(_params, { Bucket: Bucket, Region: Region, Key: Key, + AppId: AppId, StorageClass: StorageClass, - CacheControl: params.CacheControl, - ContentDisposition: params.ContentDisposition, - ContentEncoding: params.ContentEncoding, - ContentType: params.ContentType, - ACL: params.ACL, - GrantRead: params.GrantRead, - GrantWrite: params.GrantWrite, - GrantFullControl: params.GrantFullControl, - }, function (err, data) { + }); + self.multipartInit(_params, function (err, data) { if (!self._isRunningTask(TaskId)) return; - if (err) return proxy.emit('error', err); + if (err) return ep.emit('error', err); var UploadId = data.UploadId; if (!UploadId) { return callback({Message: 'no upload id'}); } - proxy.emit('upload_id_ready', {UploadId: UploadId, PartList: []}); + ep.emit('upload_id_ready', {UploadId: UploadId, PartList: []}); }); }); // 如果已存在 UploadId,找一个可以用的 UploadId - proxy.all('has_upload_id', function (UploadIdList) { + ep.on('has_upload_id', function (UploadIdList) { // 串行地,找一个内容一致的 UploadId UploadIdList = UploadIdList.reverse(); Async.eachLimit(UploadIdList, 1, function (UploadId, asyncCallback) { @@ -303,10 +258,11 @@ function getUploadIdAndPartList(params, callback) { Bucket: Bucket, Region: Region, Key: Key, + AppId: AppId, UploadId: UploadId, }, function (err, PartListData) { if (!self._isRunningTask(TaskId)) return; - if (err) return proxy.emit('error', err); + if (err) return ep.emit('error', err); var PartList = PartListData.PartList; PartList.forEach(function (item) { item.PartNumber *= 1; @@ -315,7 +271,7 @@ function getUploadIdAndPartList(params, callback) { }); isAvailableUploadList(PartList, function (err, isAvailable) { if (!self._isRunningTask(TaskId)) return; - if (err) return proxy.emit('error', err); + if (err) return ep.emit('error', err); if (isAvailable) { asyncCallback({ UploadId: UploadId, @@ -328,11 +284,11 @@ function getUploadIdAndPartList(params, callback) { }); }, function(AvailableUploadData){ if (!self._isRunningTask(TaskId)) return; - onHashProgress(true); + onHashProgress(null, true); if (AvailableUploadData && AvailableUploadData.UploadId) { - proxy.emit('upload_id_ready', AvailableUploadData); + ep.emit('upload_id_ready', AvailableUploadData); } else { - proxy.emit('no_available_upload_id'); + ep.emit('no_available_upload_id'); } }); }); @@ -341,11 +297,12 @@ function getUploadIdAndPartList(params, callback) { wholeMultipartList.call(self, { Bucket: Bucket, Region: Region, - Key: Key + Key: Key, + AppId: AppId }, function (err, data) { if (!self._isRunningTask(TaskId)) return; if (err) { - return proxy.emit('error', err); + return ep.emit('error', err); } var UploadIdList = data.UploadList.filter(function (item) { return item.Key === Key && (!StorageClass || item.StorageClass.toUpperCase() === StorageClass.toUpperCase()); @@ -353,9 +310,9 @@ function getUploadIdAndPartList(params, callback) { return item.UploadId || item.UploadID; }); if (UploadIdList.length) { - proxy.emit('has_upload_id', UploadIdList); + ep.emit('has_upload_id', UploadIdList); } else { - proxy.emit('no_available_upload_id'); + ep.emit('no_available_upload_id'); } }); } @@ -367,6 +324,7 @@ function wholeMultipartList(params, callback) { var sendParams = { Bucket: params.Bucket, Region: params.Region, + AppId: params.AppId, Prefix: params.Key }; var next = function () { @@ -393,6 +351,7 @@ function wholeMultipartListPart(params, callback) { Bucket: params.Bucket, Region: params.Region, Key: params.Key, + AppId: params.AppId, UploadId: params.UploadId }; var next = function () { @@ -426,12 +385,12 @@ function uploadSliceList(params, cb) { var Bucket = params.Bucket; var Region = params.Region; var Key = params.Key; + var AppId = params.AppId; var UploadData = params.UploadData; var FileSize = params.FileSize; var SliceSize = params.SliceSize; var ChunkParallel = params.AsyncLimit || self.options.ChunkParallelLimit || 1; var Body = params.Body; - var onProgress = params.onProgress; var SliceCount = Math.ceil(FileSize / SliceSize); var FinishSize = 0; var needUploadSlices = util.filter(UploadData.PartList, function (SliceItem) { @@ -441,44 +400,11 @@ function uploadSliceList(params, cb) { return !SliceItem['Uploaded']; }); - var onFileProgress = (function () { - var time0 = Date.now(); - var size0 = FinishSize; - var progressTimer; - var update = function () { - if (!self._isRunningTask(TaskId)) return; - progressTimer = 0; - if (onProgress && (typeof onProgress === 'function')) { - var time1 = Date.now(); - var speed = parseInt((FinishSize - size0) / ((time1 - time0) / 1000) * 100) / 100 || 0; - var percent = parseInt(FinishSize / FileSize * 100) / 100 || 0; - time0 = time1; - size0 = FinishSize; - try { - onProgress({ - loaded: FinishSize, - total: FileSize, - speed: speed, - percent: percent - }); - } catch (e) { - } - } - }; - return function (immediately) { - if (immediately) { - clearTimeout(progressTimer); - update(); - } else { - if (progressTimer) return; - progressTimer = setTimeout(update, self.options.ProgressInterval || 1000); - } - }; - })(); - Async.mapLimit(needUploadSlices, ChunkParallel, function (SliceItem, asyncCallback) { + var onProgress = util.throttleOnProgress.call(self, FileSize, params.onProgress); + + Async.eachLimit(needUploadSlices, ChunkParallel, function (SliceItem, asyncCallback) { if (!self._isRunningTask(TaskId)) return; var PartNumber = SliceItem['PartNumber']; - var ETag = SliceItem['ETag']; var currentSize = Math.min(FileSize, SliceItem['PartNumber'] * SliceSize) - (SliceItem['PartNumber'] - 1) * SliceSize; var preAddSize = 0; uploadSliceItem.call(self, { @@ -486,6 +412,7 @@ function uploadSliceList(params, cb) { Bucket: Bucket, Region: Region, Key: Key, + AppId: AppId, SliceSize: SliceSize, FileSize: FileSize, PartNumber: PartNumber, @@ -494,10 +421,13 @@ function uploadSliceList(params, cb) { onProgress: function (data) { FinishSize += data.loaded - preAddSize; preAddSize = data.loaded; - onFileProgress(); + onProgress({loaded: FinishSize, total: FileSize}); }, }, function (err, data) { if (!self._isRunningTask(TaskId)) return; + if (!err && !data.ETag) { + err = 'get ETag error, please add "ETag" to CORS ExposeHeader setting.'; + } if (err) { FinishSize -= preAddSize; } else { @@ -507,14 +437,13 @@ function uploadSliceList(params, cb) { asyncCallback(err || null, data); }); - }, function (err, datas) { + }, function (err) { if (!self._isRunningTask(TaskId)) return; - onFileProgress(true); + onProgress(null, true); if (err) { return cb(err); } cb(null, { - datas: datas, UploadId: UploadData.UploadId, SliceList: UploadData.PartList }); @@ -527,6 +456,7 @@ function uploadSliceItem(params, callback) { var Bucket = params.Bucket; var Region = params.Region; var Key = params.Key; + var AppId = params.AppId; var FileSize = params.FileSize; var FileBody = params.Body; var PartNumber = params.PartNumber * 1; @@ -556,6 +486,7 @@ function uploadSliceItem(params, callback) { Bucket: Bucket, Region: Region, Key: Key, + AppId: AppId, ContentLength: ContentLength, ContentSha1: ContentSha1, PartNumber: PartNumber, @@ -584,6 +515,7 @@ function uploadSliceComplete(params, callback) { var Bucket = params.Bucket; var Region = params.Region; var Key = params.Key; + var AppId = params.AppId; var UploadId = params.UploadId; var SliceList = params.SliceList; var self = this; @@ -598,6 +530,7 @@ function uploadSliceComplete(params, callback) { Bucket: Bucket, Region: Region, Key: Key, + AppId: AppId, UploadId: UploadId, Parts: Parts }, function (err, data) { @@ -619,6 +552,7 @@ function abortUploadTask(params, callback) { var Bucket = params.Bucket; var Region = params.Region; var Key = params.Key; + var AppId = params.AppId; var UploadId = params.UploadId; var Level = params.Level || 'task'; var AsyncLimit = params.AsyncLimit; @@ -626,16 +560,17 @@ function abortUploadTask(params, callback) { var ep = new EventProxy(); - ep.all('error', function (errData) { + ep.on('error', function (errData) { return callback(errData); }); // 已经获取到需要抛弃的任务列表 - ep.all('get_abort_array', function (AbortArray) { + ep.on('get_abort_array', function (AbortArray) { abortUploadTaskArray.call(self, { Bucket: Bucket, Region: Region, Key: Key, + AppId: AppId, AsyncLimit: AsyncLimit, AbortArray: AbortArray }, function (err, data) { @@ -693,7 +628,10 @@ function abortUploadTaskArray(params, callback) { var AsyncLimit = params.AsyncLimit || 1; var self = this; - Async.mapLimit(AbortArray, AsyncLimit, function (AbortItem, callback) { + var index = 0; + var resultList = new Array(AbortArray.length); + Async.eachLimit(AbortArray, AsyncLimit, function (AbortItem, callback) { + var eachIndex = index; if (Key && Key != AbortItem.Key) { return callback(null, { KeyNotMatch: true @@ -713,20 +651,12 @@ function abortUploadTaskArray(params, callback) { Key: AbortItem.Key, UploadId: UploadId }; - if (err) { - return callback(null, { - error: err, - task: task - }); - } - - return callback(null, { - error: false, - task: task - }); + resultList[eachIndex] = {error: err, task: task}; + callback(null); }); + index ++; - }, function (err, datas) { + }, function (err) { if (err) { return callback(err); } @@ -734,8 +664,8 @@ function abortUploadTaskArray(params, callback) { var successList = []; var errorList = []; - for (var i = 0, len = datas.length; i < len; i++) { - var item = datas[i]; + for (var i = 0, len = resultList.length; i < len; i++) { + var item = resultList[i]; if (item['task']) { if (item['error']) { errorList.push(item['task']); @@ -753,12 +683,98 @@ function abortUploadTaskArray(params, callback) { } +// 批量上传文件 +function uploadFiles(params, callback) { + var self = this; + + // 判断多大的文件使用分片上传 + var SliceSize = params.SliceSize === undefined ? self.options.SliceSize : params.SliceSize; + + // 汇总返回进度 + var TotalSize = 0; + var TotalFinish = 0; + var onTotalProgress = util.throttleOnProgress.call(self, TotalFinish, params.onProgress); + + // 汇总返回回调 + var unFinishCount = params.files.length; + var _onTotalFileFinish = params.onFileFinish; + var resultList = Array(unFinishCount); + var onTotalFileFinish = function (err, data, options) { + onTotalProgress(null, true); + _onTotalFileFinish && _onTotalFileFinish(err, data, options); + resultList[options.Index] = { + options: options, + error: err, + data: data + }; + if (--unFinishCount <= 0 && callback) { + callback(null, { + files: resultList, + }); + } + }; + + // 开始处理每个文件 + var taskList = []; + util.each(params.files, function (fileParams, index) { + + var Body = fileParams.Body; + var FileSize = Body.size || Body.length || 0; + var fileInfo = {Index: index, TaskId: ''}; + + // 更新文件总大小 + TotalSize += FileSize; + + // 整理 option,用于返回给回调 + util.each(fileParams, function (v, k) { + if (typeof v !== 'object' && typeof v !== 'function') { + fileInfo[k] = v; + } + }); + + // 处理单个文件 TaskReady + var _TaskReady = fileParams.TaskReady; + var TaskReady = function (tid) { + fileInfo.TaskId = tid; + _TaskReady && _TaskReady(tid); + }; + fileParams.TaskReady = TaskReady; + + // 处理单个文件进度 + var PreAddSize = 0; + var _onProgress = fileParams.onProgress; + var onProgress = function (info) { + TotalFinish = TotalFinish - PreAddSize + info.loaded; + PreAddSize = info.loaded; + _onProgress && _onProgress(info); + onTotalProgress({loaded: TotalFinish, total: TotalSize}); + }; + fileParams.onProgress = onProgress; + + // 处理单个文件完成 + var _onFileFinish = fileParams.onFileFinish; + var onFileFinish = function (err, data) { + _onFileFinish && _onFileFinish(err, data); + onTotalFileFinish && onTotalFileFinish(err, data, fileInfo); + }; + + // 添加上传任务 + taskList.push({ + api: FileSize >= SliceSize ? 'sliceUploadFile' : 'putObject', + params: fileParams, + callback: onFileFinish, + }); + }); + self._addTasks(taskList); +} + + var API_MAP = { sliceUploadFile: sliceUploadFile, - _sliceUploadFile: _sliceUploadFile, abortUploadTask: abortUploadTask, + uploadFiles: uploadFiles, }; util.each(API_MAP, function (fn, apiName) { exports[apiName] = util.apiWrapper(apiName, fn); -}); \ No newline at end of file +}); diff --git a/src/base.js b/src/base.js index 752e81f..f96de38 100644 --- a/src/base.js +++ b/src/base.js @@ -773,13 +773,7 @@ function getObject(params, callback) { * @return {String} data.ETag 为对应上传文件的 ETag 值 */ function putObject(params, callback) { - var taskId = util.uuid(); - params.TaskReady && params.TaskReady(taskId); - this._addTask(taskId, '_putObject', params, callback); -} -function _putObject(params, callback) { var self = this; - var TaskId = params.TaskId; var headers = {}; headers['Cache-Control'] = params['CacheControl']; @@ -823,48 +817,10 @@ function _putObject(params, callback) { return; } - var onProgress = params.onProgress; - var onFileProgress = (function () { - var time0 = Date.now(); - var size0 = 0; - var FinishSize = 0; - var FileSize = headers['Content-Length']; - var progressTimer; - var update = function () { - progressTimer = 0; - if (onProgress && (typeof onProgress === 'function')) { - var time1 = Date.now(); - var speed = parseInt((FinishSize - size0) / ((time1 - time0) / 1000) * 100) / 100 || 0; - var percent = parseInt(FinishSize / FileSize * 100) / 100 || 0; - time0 = time1; - size0 = FinishSize; - try { - onProgress({ - loaded: FinishSize, - total: FileSize, - speed: speed, - percent: percent - }); - } catch (e) { - } - } - }; - return function (info, immediately) { - if (info && info.loaded) { - FinishSize = info.loaded; - FileSize = info.total; - } - if (immediately) { - clearTimeout(progressTimer); - update(); - } else { - if (progressTimer) return; - progressTimer = setTimeout(update, self.options.ProgressInterval || 1000); - } - }; - })(); + var onProgress = util.throttleOnProgress.call(self, headers['Content-Length'], params.onProgress); - var sender = submitRequest.call(this, { + submitRequest.call(this, { + TaskId: params.TaskId, method: 'PUT', Bucket: params.Bucket, Region: params.Region, @@ -872,10 +828,9 @@ function _putObject(params, callback) { Key: params.Key, headers: headers, body: Body, - onProgress: onFileProgress + onProgress: onProgress }, function (err, data) { - TaskId && self.off('inner-kill-task', killTask); - onFileProgress(null, true); + onProgress(null, true); if (err) { return callback(err); } @@ -888,14 +843,6 @@ function _putObject(params, callback) { } callback(null, data); }); - - var killTask = function (data) { - if (data.TaskId === TaskId) { - sender && sender.abort && sender.abort(); - self.off('inner-kill-task', killTask); - } - }; - TaskId && this.on('inner-kill-task', killTask); } /** @@ -1281,8 +1228,6 @@ function multipartInit(params, callback) { * @return {Object} data.ETag 返回的文件分块 sha1 值 */ function multipartUpload(params, callback) { - var self = this; - var TaskId = params.TaskId; var headers = {}; headers['Content-Length'] = params['ContentLength']; @@ -1294,6 +1239,7 @@ function multipartUpload(params, callback) { var action = '?partNumber=' + PartNumber + '&uploadId=' + UploadId; var sender = submitRequest.call(this, { + TaskId: params.TaskId, method: 'PUT', Bucket: params.Bucket, Region: params.Region, @@ -1304,7 +1250,6 @@ function multipartUpload(params, callback) { body: params.Body || null, onProgress: params.onProgress }, function (err, data) { - if (TaskId) self.off('inner-kill-task', killTask); if (err) { return callback(err); } @@ -1316,14 +1261,6 @@ function multipartUpload(params, callback) { }); }); - var killTask = function (data) { - if (data.TaskId === TaskId) { - sender && sender.abort && sender.abort(); - self.off('inner-kill-task', killTask); - } - }; - TaskId && this.on('inner-kill-task', killTask); - } /** @@ -1629,6 +1566,8 @@ function getUrl(params) { // 发起请求 function submitRequest(params, callback) { + var self = this; + var TaskId = params.TaskId; var bucket = params.Bucket; var region = params.Region; var object = params.Key; @@ -1643,12 +1582,12 @@ function submitRequest(params, callback) { var opt = { url: url || getUrl({ - domain: this.options.Domain, + domain: self.options.Domain, bucket: bucket, region: region, object: object, action: action, - appId: params.AppId || this.options.AppId, + appId: params.AppId || self.options.AppId, }), method: method, headers: headers || {}, @@ -1657,17 +1596,22 @@ function submitRequest(params, callback) { json: json, }; - var innerSender; - var outerSender = { - abort: function () { - innerSender && innerSender.abort && innerSender.abort(); - } - }; - // 发送请求 var getAuthorizationCallback = function (auth) { + if (TaskId && !self._isRunningTask(TaskId)) return; + + var token, clientIP, clientUA; + if (typeof auth === 'object') { + token = auth.Token; + clientIP = auth.ClientIP; + clientUA = auth.ClientUA; + auth = auth.Authorization; + } opt.headers.Authorization = auth; + token && (opt.headers['token'] = token); + clientIP && (opt.headers['clientIP'] = clientIP); + clientUA && (opt.headers['clientUA'] = clientUA); // 预先处理 undefined 的属性 if (opt.headers) { @@ -1682,30 +1626,19 @@ function submitRequest(params, callback) { // progress if (params.onProgress && typeof params.onProgress === 'function') { var contentLength = body && body.size || 0; - var time0 = Date.now(); - var size0 = 0; opt.onProgress = function (e) { - var loaded = 0; - try { loaded = e.loaded; } catch (e) {} - var total = contentLength; - var time1 = Date.now(); - var speed = parseInt((loaded - size0) / ((time1 - time0) / 1000) * 100) / 100; - var percent = total ? (parseInt(loaded / total * 100) / 100) : 0; - time0 = time1; - size0 = loaded; - params.onProgress({ - loaded: loaded, - total: total, - speed: speed, - percent: percent, - }); + if (TaskId && !self._isRunningTask(TaskId)) return; + var loaded = e ? e.loaded : 0; + params.onProgress({loaded: loaded, total: contentLength}); }; } - innerSender = REQUEST(opt, function (err, response, body) { + var sender = REQUEST(opt, function (err, response, body) { // 返回内容添加 状态码 和 headers var cb = function (err, data) { + TaskId && self.off('inner-kill-task', killTask); + if (TaskId && !self._isRunningTask(TaskId)) return; if (err) { err = err || {}; response && response.statusCode && (err.statusCode = response.statusCode); @@ -1750,11 +1683,20 @@ function submitRequest(params, callback) { } cb(null, jsonRes); }); + + // kill task + var killTask = function (data) { + if (data.TaskId === TaskId) { + sender && sender.abort && sender.abort(); + self.off('inner-kill-task', killTask); + } + }; + TaskId && self.on('inner-kill-task', killTask); }; // 获取签名 - if (this.options.getAuthorization) { - this.options.getAuthorization({ + if (self.options.getAuthorization) { + self.options.getAuthorization({ Method: opt.method, Key: object || '', method: opt.method, @@ -1764,14 +1706,12 @@ function submitRequest(params, callback) { var auth = util.getAuth({ Method: opt.method, Key: object || '', - SecretId: params.SecretId || this.options.SecretId, - SecretKey: params.SecretKey || this.options.SecretKey, + SecretId: params.SecretId || self.options.SecretId, + SecretKey: params.SecretKey || self.options.SecretKey, }); getAuthorizationCallback(auth); } - return outerSender; - } @@ -1799,7 +1739,6 @@ var API_MAP = { getObject: getObject, headObject: headObject, putObject: putObject, - _putObject: _putObject, deleteObject: deleteObject, getObjectAcl: getObjectAcl, putObjectAcl: putObjectAcl, From ed85d74f870081bccecfd20decd011dff4fc9dc1 Mon Sep 17 00:00:00 2001 From: carsonxu <459452372@qq.com> Date: Wed, 1 Nov 2017 00:20:29 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E5=8E=BB=E9=99=A4=20package.json=20?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cos.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cos.js b/src/cos.js index 10beddc..4c37b75 100644 --- a/src/cos.js +++ b/src/cos.js @@ -5,7 +5,6 @@ var event = require('./event'); var task = require('./task'); var base = require('./base'); var advance = require('./advance'); -var pkg = require('../package.json'); var defaultOptions = { AppId: '', @@ -14,6 +13,7 @@ var defaultOptions = { FileParallelLimit: 3, ChunkParallelLimit: 3, ChunkSize: 1024 * 1024, + SliceSize: 1024 * 1024 * 20, ProgressInterval: 1000, Domain: '', ServiceDomain: '', @@ -30,6 +30,6 @@ util.extend(COS.prototype, base); util.extend(COS.prototype, advance); COS.getAuthorization = util.getAuth; -COS.version = pkg.version; +COS.version = '0.1.5'; module.exports = window.COS = COS; From d8f856eb698bde8b3c1e20be62b16c62392800fc Mon Sep 17 00:00:00 2001 From: carsonxu <459452372@qq.com> Date: Wed, 1 Nov 2017 00:21:05 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=98=9F=E5=88=97?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/task.js | 60 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/src/task.js b/src/task.js index 12d3b26..b2bbf17 100644 --- a/src/task.js +++ b/src/task.js @@ -7,6 +7,19 @@ var initTask = function (cos) { var uploadingFileCount = 0; var nextUploadIndex = 0; + var originApiMap = {}; + + // 把上传方法替换成添加任务的方法 + util.each([ + 'putObject', + 'sliceUploadFile', + ], function (api) { + originApiMap[api] = cos[api]; + cos[api] = function (params, callback) { + cos._addTask(api, params, callback); + }; + }); + // 接口返回简略的任务信息 var formatTask = function (task) { var t = { @@ -26,6 +39,11 @@ var initTask = function (cos) { return t; }; + var emitListUpdate = function () { + cos.emit('task-list-update', {list: util.map(queue, formatTask)}); + cos.emit('list-update', {list: util.map(queue, formatTask)}); + }; + var startNextTask = function () { if (nextUploadIndex < queue.length && uploadingFileCount < cos.options.FileParallelLimit) { @@ -34,10 +52,12 @@ var initTask = function (cos) { uploadingFileCount++; task.state = 'checking'; !task.params.UploadData && (task.params.UploadData = {}); - cos[task.api](task.params, function (err, data) { + originApiMap[task.api].call(cos, task.params, function (err, data) { + if (!cos._isRunningTask(task.id)) return; if (task.state === 'checking' || task.state === 'uploading') { task.state = err ? 'error' : 'success'; uploadingFileCount--; + emitListUpdate(); startNextTask(cos); task.callback && task.callback(err, data); if (task.state === 'success') { @@ -46,6 +66,7 @@ var initTask = function (cos) { } } }); + emitListUpdate(); } nextUploadIndex++; startNextTask(cos); @@ -56,14 +77,16 @@ var initTask = function (cos) { var task = tasks[id]; var waiting = task && task.state === 'waiting'; var running = task && (task.state === 'checking' || task.state === 'uploading'); - if (waiting || running || (switchToState === 'canceled' && task.state === 'paused')) { + if (switchToState === 'canceled' && task.state !== 'canceled' || + switchToState === 'paused' && waiting || + switchToState === 'paused' && running) { if (switchToState === 'paused' && task.params.Body && typeof task.params.Body.pipe === 'function') { console.error('stream not support pause'); return; } task.state = switchToState; cos.emit('inner-kill-task', {TaskId: id}); - cos.emit('task-update', {task: formatTask(task)}); + emitListUpdate(); if (running) { uploadingFileCount--; startNextTask(cos); @@ -75,17 +98,32 @@ var initTask = function (cos) { } }; - cos._addTask = function (id, api, params, callback) { - var size; - if (params.Body && params.Body.size) { + cos._addTasks = function (taskList) { + util.each(taskList, function (task) { + task.params.IgnoreAddEvent = true; + cos._addTask(task.api, task.params, task.callback); + }); + emitListUpdate(); + }; + + cos._addTask = function (api, params, callback) { + + // 生成 id + var id = util.uuid(); + params.TaskReady && params.TaskReady(id); + + var size = 0; + if (params.Body && params.Body.size !== undefined) { size = params.Body.size; - } else if (params.Body && params.Body.length) { + } else if (params.Body && params.Body.length !== undefined) { size = params.Body.length; } else if (params.ContentLength !== undefined) { size = params.ContentLength; } + if (params.ContentLength === undefined) params.ContentLength = size; params.TaskId = id; + var task = { // env params: params, @@ -110,7 +148,7 @@ var initTask = function (cos) { if (!cos._isRunningTask(task.id)) return; task.hashPercent = info.percent; onHashProgress && onHashProgress(info); - cos.emit('task-update', {task: formatTask(task)}); + emitListUpdate(); }; var onProgress = params.onProgress; params.onProgress = function (info) { @@ -120,11 +158,11 @@ var initTask = function (cos) { task.speed = info.speed; task.percent = info.percent; onProgress && onProgress(info); - cos.emit('task-update', {task: formatTask(task)}); + emitListUpdate(); }; queue.push(task); tasks[id] = task; - cos.emit('task-list-update', {list: util.map(queue, formatTask)}); + !params.IgnoreAddEvent && emitListUpdate(); startNextTask(cos); return id; }; @@ -145,7 +183,7 @@ var initTask = function (cos) { var task = tasks[id]; if (task && (task.state === 'paused' || task.state === 'error')) { task.state = 'waiting'; - cos.emit('task-update', {task: formatTask(task)}); + emitListUpdate(); nextUploadIndex = Math.min(nextUploadIndex, task.index); startNextTask(); } From 60a871b4622938aadd622c3df65d4cbd3fea8b36 Mon Sep 17 00:00:00 2001 From: carsonxu <459452372@qq.com> Date: Wed, 1 Nov 2017 00:21:47 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AD=BE=E5=90=8D?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/auth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/auth.js b/server/auth.js index 5e4706c..6493fb0 100644 --- a/server/auth.js +++ b/server/auth.js @@ -26,7 +26,7 @@ function getAuthorization (method, pathname) { var headers = {}; method = (method ? method : 'get').toLowerCase(); pathname = pathname ? pathname : '/'; - pathname.indexOf('/') === -1 && (pathname = '/' + pathname); + pathname.indexOf('/') !== 0 && (pathname = '/' + pathname); // 工具方法 var getObjectKeys = function (obj) { From 48a755efacfa7c09a9d22fe997a77f12993f5b2d Mon Sep 17 00:00:00 2001 From: carsonxu <459452372@qq.com> Date: Wed, 1 Nov 2017 00:22:11 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=20xml=20=E5=92=8C=20js?= =?UTF-8?q?on=20=E8=BD=AC=E6=8D=A2=E7=9A=84=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/json2xml.js | 166 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/xml2json.js | 164 +++++++++++++++++++++++++++++++++++++++++++++++ src/util.js | 69 ++++++++++++-------- 3 files changed, 374 insertions(+), 25 deletions(-) create mode 100644 lib/json2xml.js create mode 100644 lib/xml2json.js diff --git a/lib/json2xml.js b/lib/json2xml.js new file mode 100644 index 0000000..2b6494f --- /dev/null +++ b/lib/json2xml.js @@ -0,0 +1,166 @@ +//copyright Ryan Day 2010 , Joscha Feth 2013 [MIT Licensed] + +var element_start_char = + "a-zA-Z_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FFF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD"; +var element_non_start_char = "\-.0-9\u00B7\u0300-\u036F\u203F\u2040"; +var element_replace = new RegExp("^([^" + element_start_char + "])|^((x|X)(m|M)(l|L))|([^" + element_start_char + element_non_start_char + "])", "g"); +var not_safe_in_xml = /[^\x09\x0A\x0D\x20-\xFF\x85\xA0-\uD7FF\uE000-\uFDCF\uFDE0-\uFFFD]/gm; + +var objKeys = function (obj) { + var l = []; + if (obj instanceof Object) { + for (var k in obj) { + if (obj.hasOwnProperty(k)) { + l.push(k); + } + } + } + return l; +}; +var process_to_xml = function (node_data, options) { + + var makeNode = function (name, content, attributes, level, hasSubNodes) { + var indent_value = options.indent !== undefined ? options.indent : "\t"; + var indent = options.prettyPrint ? '\n' + new Array(level).join(indent_value) : ''; + if (options.removeIllegalNameCharacters) { + name = name.replace(element_replace, '_'); + } + + var node = [indent, '<', name, (attributes || '')]; + if (content && content.length > 0) { + node.push('>') + node.push(content); + hasSubNodes && node.push(indent); + node.push(''); + } else { + node.push('/>'); + } + return node.join(''); + }; + + return (function fn(node_data, node_descriptor, level) { + var type = typeof node_data; + if ((Array.isArray) ? Array.isArray(node_data) : node_data instanceof Array) { + type = 'array'; + } else if (node_data instanceof Date) { + type = 'date'; + } + + switch (type) { + //if value is an array create child nodes from values + case 'array': + var ret = []; + node_data.map(function (v) { + ret.push(fn(v, 1, level + 1)); + //entries that are values of an array are the only ones that can be special node descriptors + }); + options.prettyPrint && ret.push('\n'); + return ret.join(''); + break; + + case 'date': + // cast dates to ISO 8601 date (soap likes it) + return node_data.toJSON ? node_data.toJSON() : node_data + ''; + break; + + case 'object': + var nodes = []; + for (var name in node_data) { + if (node_data[name] instanceof Array) { + for (var j in node_data[name]) { + nodes.push(makeNode(name, fn(node_data[name][j], 0, level + 1), null, level + 1, objKeys(node_data[name][j]).length)); + } + } else { + nodes.push(makeNode(name, fn(node_data[name], 0, level + 1), null, level + 1)); + } + } + options.prettyPrint && nodes.length > 0 && nodes.push('\n'); + return nodes.join(''); + break; + + case 'function': + return node_data(); + break; + + default: + return options.escape ? esc(node_data) : '' + node_data; + } + + }(node_data, 0, 0)) +}; + + +var xml_header = function (standalone) { + var ret = [''); + + return ret.join(''); +}; + +function esc(str) { + return ('' + str).replace(/&/g, '&') + .replace(//g, '>') + .replace(/'/g, ''') + .replace(/"/g, '"') + .replace(not_safe_in_xml, ''); +} + +module.exports = function (obj, options) { + + if (!options) { + options = { + xmlHeader: { + standalone: true + }, + prettyPrint: true, + indent: " " + }; + } + + var Buffer = this.Buffer || function Buffer() { + }; + + if (typeof obj == 'string' || obj instanceof Buffer) { + try { + obj = JSON.parse(obj.toString()); + } catch (e) { + return false; + } + } + + var xmlheader = ''; + var docType = ''; + if (options) { + if (typeof options == 'object') { + // our config is an object + + if (options.xmlHeader) { + // the user wants an xml header + xmlheader = xml_header(!!options.xmlHeader.standalone); + } + + if (typeof options.docType != 'undefined') { + docType = '' + } + } else { + // our config is a boolean value, so just add xml header + xmlheader = xml_header(); + } + } + options = options || {} + + var ret = [ + xmlheader, + (options.prettyPrint && docType ? '\n' : ''), + docType, + process_to_xml(obj, options) + ]; + return ret.join('').replace(/\n{2,}/g, '\n').replace(/\s+$/g, ''); +}; \ No newline at end of file diff --git a/lib/xml2json.js b/lib/xml2json.js new file mode 100644 index 0000000..bc21c34 --- /dev/null +++ b/lib/xml2json.js @@ -0,0 +1,164 @@ +/* Copyright 2015 William Summers, MetaTribal LLC + * adapted from https://developer.mozilla.org/en-US/docs/JXON + * + * Licensed under the MIT 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 + * + * https://opensource.org/licenses/MIT + * + * 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. + */ +/** + * @author William Summers + * https://github.com/metatribal/xmlToJSON + */ + +var xmlToJSON = (function () { + + this.version = "1.3.5"; + + var options = { // set up the default options + mergeCDATA: true, // extract cdata and merge with text + normalize: true, // collapse multiple spaces to single space + stripElemPrefix: true, // for elements of same name in diff namespaces, you can enable namespaces and access the nskey property + }; + + var prefixMatch = new RegExp(/(?!xmlns)^.*:/); + var trimMatch = new RegExp(/^\s+|\s+$/g); + + this.grokType = function (sValue) { + if (/^\s*$/.test(sValue)) { + return null; + } + if (/^(?:true|false)$/i.test(sValue)) { + return sValue.toLowerCase() === "true"; + } + if (isFinite(sValue)) { + return parseFloat(sValue); + } + return sValue; + }; + + this.parseString = function (xmlString, opt) { + if (xmlString) { + var xml = this.stringToXML(xmlString); + if (xml.getElementsByTagName('parsererror').length) { + return null; + } else { + return this.parseXML(xml, opt); + } + } else { + return null; + } + }; + + this.parseXML = function (oXMLParent, opt) { + + // initialize options + for (var key in opt) { + options[key] = opt[key]; + } + + var vResult = {}, + nLength = 0, + sCollectedTxt = ""; + + // iterate over the children + var childNum = oXMLParent.childNodes.length; + if (childNum) { + for (var oNode, sProp, vContent, nItem = 0; nItem < oXMLParent.childNodes.length; nItem++) { + oNode = oXMLParent.childNodes.item(nItem); + + if (oNode.nodeType === 4) { + if (options.mergeCDATA) { + sCollectedTxt += oNode.nodeValue; + } + } /* nodeType is "CDATASection" (4) */ + else if (oNode.nodeType === 3) { + sCollectedTxt += oNode.nodeValue; + } /* nodeType is "Text" (3) */ + else if (oNode.nodeType === 1) { /* nodeType is "Element" (1) */ + + if (nLength === 0) { + vResult = {}; + } + + // using nodeName to support browser (IE) implementation with no 'localName' property + if (options.stripElemPrefix) { + sProp = oNode.nodeName.replace(prefixMatch, ''); + } else { + sProp = oNode.nodeName; + } + + vContent = xmlToJSON.parseXML(oNode); + + if (vResult.hasOwnProperty(sProp)) { + if (vResult[sProp].constructor !== Array) { + vResult[sProp] = [vResult[sProp]]; + } + vResult[sProp].push(vContent); + + } else { + vResult[sProp] = vContent; + nLength++; + } + } + } + } + + if (!Object.keys(vResult).length) { + vResult = sCollectedTxt.replace(trimMatch, '') || ''; + } + + return vResult; + }; + + // Convert xmlDocument to a string + // Returns null on failure + this.xmlToString = function (xmlDoc) { + try { + var xmlString = xmlDoc.xml ? xmlDoc.xml : (new XMLSerializer()).serializeToString(xmlDoc); + return xmlString; + } catch (err) { + return null; + } + }; + + // Convert a string to XML Node Structure + // Returns null on failure + this.stringToXML = function (xmlString) { + try { + var xmlDoc = null; + + if (window.DOMParser) { + + var parser = new DOMParser(); + xmlDoc = parser.parseFromString(xmlString, "text/xml"); + + return xmlDoc; + } else { + xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); + xmlDoc.async = false; + xmlDoc.loadXML(xmlString); + + return xmlDoc; + } + } catch (e) { + return null; + } + }; + + return this; + +}).call({}); + +var xml2json = function (xmlString) { + return xmlToJSON.parseString(xmlString); +}; + +module.exports = xml2json; diff --git a/src/util.js b/src/util.js index 3112118..a8c3136 100644 --- a/src/util.js +++ b/src/util.js @@ -2,9 +2,8 @@ var md5 = require('../lib/md5'); var CryptoJS = require('../lib/crypto'); -var xml2js = require('xml2js'); -var xmlParser = new xml2js.Parser({explicitArray: false, ignoreAttrs: true}); -var xmlBuilder = new xml2js.Builder(); +var xml2json = require('../lib/xml2json'); +var json2xml = require('../lib/json2xml'); function camSafeUrlEncode(str) { return encodeURIComponent(str) @@ -26,7 +25,7 @@ var getAuth = function (opt) { var pathname = opt.pathname || opt.Key || '/'; var queryParams = opt.params || ''; var headers = opt.headers || ''; - pathname.indexOf('/') === -1 && (pathname = '/' + pathname); + pathname.indexOf('/') !== 0 && (pathname = '/' + pathname); if (!SecretId) return console.error('lack of param SecretId'); if (!SecretKey) return console.error('lack of param SecretKey'); @@ -100,22 +99,6 @@ var getAuth = function (opt) { }; -// XML 对象转 JSON 对象 -var xml2json = function (bodyStr) { - var d = {}; - xmlParser.parseString(bodyStr, function (err, result) { - d = result; - }); - - return d; -}; - -// JSON 对象转 XML 对象 -var json2xml = function (json) { - var xml = xmlBuilder.buildObject(json); - return xml; -}; - // 清除对象里值为的 undefined 或 null 的属性 var clearKey = function (obj) { var retObj = {}; @@ -272,11 +255,10 @@ var apiWrapper = function (apiName, apiFn) { return; } // 兼容带有 AppId 的 Bucket - var appId, bucket = params.Bucket; - if (bucket && bucket.indexOf('-') > -1) { - var arr = bucket.split('-'); - appId = arr[1]; - bucket = arr[0]; + var appId, m, bucket = params.Bucket; + if (bucket && (m = bucket.match(/^(.+)-(\d+)$/))) { + appId = m[2]; + bucket = m[1]; params.AppId = appId; params.Bucket = bucket; } @@ -292,6 +274,42 @@ var apiWrapper = function (apiName, apiFn) { } }; +var throttleOnProgress = function (total, onProgress) { + var self = this; + var size0 = 0; + var size1 = 0; + var time0 = Date.now(); + var time1; + var timer; + var update = function () { + timer = 0; + if (onProgress && (typeof onProgress === 'function')) { + time1 = Date.now(); + var speed = Math.max(0, parseInt((size1 - size0) / ((time1 - time0) / 1000) * 100) / 100); + var percent = size1 === 0 && total === 0 ? 1 : parseInt(size1 / total * 100) / 100 || 0; + time0 = time1; + size0 = size1; + try { + onProgress({loaded: size1, total: total, speed: speed, percent: percent}); + } catch (e) { + } + } + }; + return function (info, immediately) { + if (info) { + size1 = info.loaded; + total = info.total; + } + if (immediately) { + clearTimeout(timer); + update(); + } else { + if (timer) return; + timer = setTimeout(update, self.options.ProgressInterval); + } + }; +}; + var fileSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice; var util = { @@ -311,6 +329,7 @@ var util = { filter: filter, clone: clone, uuid: uuid, + throttleOnProgress: throttleOnProgress, isBrowser: !!global.window }; From 19224408b8813c1533c6aa5e716f639a2bf4e47d Mon Sep 17 00:00:00 2001 From: carsonxu <459452372@qq.com> Date: Wed, 1 Nov 2017 00:22:55 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20dist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/cos-js-sdk-v5.js | 33233 ++++++++---------------------------- dist/cos-js-sdk-v5.min.js | 8 +- 2 files changed, 7334 insertions(+), 25907 deletions(-) diff --git a/dist/cos-js-sdk-v5.js b/dist/cos-js-sdk-v5.js index dddf939..d8d9ee2 100644 --- a/dist/cos-js-sdk-v5.js +++ b/dist/cos-js-sdk-v5.js @@ -1,4 +1,14 @@ -/******/ (function(modules) { // webpackBootstrap +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["COS"] = factory(); + else + root["COS"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ @@ -60,324 +70,371 @@ /******/ __webpack_require__.p = "/dist/"; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 72); +/******/ return __webpack_require__(__webpack_require__.s = 5); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { -var baseAssign = __webpack_require__(117), - baseCreate = __webpack_require__(118); - -/** - * Creates an object that inherits from the `prototype` object. If a - * `properties` object is given, its own enumerable string keyed properties - * are assigned to the created object. - * - * @static - * @memberOf _ - * @since 2.3.0 - * @category Object - * @param {Object} prototype The object to inherit from. - * @param {Object} [properties] The properties to assign to the object. - * @returns {Object} Returns the new object. - * @example - * - * function Shape() { - * this.x = 0; - * this.y = 0; - * } - * - * function Circle() { - * Shape.call(this); - * } - * - * Circle.prototype = _.create(Shape.prototype, { - * 'constructor': Circle - * }); - * - * var circle = new Circle; - * circle instanceof Circle; - * // => true - * - * circle instanceof Shape; - * // => true - */ -function create(prototype, properties) { - var result = baseCreate(prototype); - return properties == null ? result : baseAssign(result, properties); -} - -module.exports = create; - - -/***/ }), -/* 1 */ -/***/ (function(module, exports) { - -/** - * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) - * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(_.noop); - * // => true - * - * _.isObject(null); - * // => false - */ -function isObject(value) { - var type = typeof value; - return value != null && (type == 'object' || type == 'function'); -} - -module.exports = isObject; - - -/***/ }), -/* 2 */ -/***/ (function(module, exports) { - -/** - * Checks if `value` is classified as an `Array` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array, else `false`. - * @example - * - * _.isArray([1, 2, 3]); - * // => true - * - * _.isArray(document.body.children); - * // => false - * - * _.isArray('abc'); - * // => false - * - * _.isArray(_.noop); - * // => false - */ -var isArray = Array.isArray; - -module.exports = isArray; - - -/***/ }), -/* 3 */ -/***/ (function(module, exports) { - -var g; +"use strict"; +/* WEBPACK VAR INJECTION */(function(Buffer, global) { -// This works in non-strict mode -g = (function() { - return this; -})(); +var md5 = __webpack_require__(10); +var CryptoJS = __webpack_require__(11); +var xml2json = __webpack_require__(12); +var json2xml = __webpack_require__(13); -try { - // This works if eval is allowed (see CSP) - g = g || Function("return this")() || (1,eval)("this"); -} catch(e) { - // This works if the window reference is available - if(typeof window === "object") - g = window; +function camSafeUrlEncode(str) { + return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A'); } -// g can still be undefined, but nothing to do about it... -// We return undefined, instead of nothing here, so it's -// easier to handle this case. if(!global) { ...} - -module.exports = g; - +//测试用的key后面可以去掉 +var getAuth = function (opt) { -/***/ }), -/* 4 */ -/***/ (function(module, exports, __webpack_require__) { + opt = opt || {}; -var freeGlobal = __webpack_require__(52); + var SecretId = opt.SecretId; + var SecretKey = opt.SecretKey; + var method = (opt.method || opt.Method || 'get').toLowerCase(); + var pathname = opt.pathname || opt.Key || '/'; + var queryParams = opt.params || ''; + var headers = opt.headers || ''; + pathname.indexOf('/') !== 0 && (pathname = '/' + pathname); -/** Detect free variable `self`. */ -var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + if (!SecretId) return console.error('lack of param SecretId'); + if (!SecretKey) return console.error('lack of param SecretKey'); -/** Used as a reference to the global object. */ -var root = freeGlobal || freeSelf || Function('return this')(); + var getObjectKeys = function (obj) { + var list = []; + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + list.push(key); + } + } + return list.sort(); + }; -module.exports = root; + var obj2str = function (obj) { + var i, key, val; + var list = []; + var keyList = getObjectKeys(obj); + for (i = 0; i < keyList.length; i++) { + key = keyList[i]; + val = obj[key] || ''; + key = key.toLowerCase(); + list.push(camSafeUrlEncode(key) + '=' + camSafeUrlEncode(val)); + } + return list.join('&'); + }; + // 签名有效起止时间 + var now = parseInt(new Date().getTime() / 1000) - 1; + var expired = now; -/***/ }), -/* 5 */ -/***/ (function(module, exports, __webpack_require__) { + if (opt.expires === undefined) { + expired += 3600; // 签名过期时间为当前 + 3600s + } else { + expired += opt.expires * 1 || 0; + } -"use strict"; -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. + // 要用到的 Authorization 参数列表 + var qSignAlgorithm = 'sha1'; + var qAk = SecretId; + var qSignTime = now + ';' + expired; + var qKeyTime = now + ';' + expired; + var qHeaderList = getObjectKeys(headers).join(';').toLowerCase(); + var qUrlParamList = getObjectKeys(queryParams).join(';').toLowerCase(); -// a duplex stream is just a stream that is both readable and writable. -// Since JS doesn't have multiple prototypal inheritance, this class -// prototypally inherits from Readable, and then parasitically from -// Writable. + // 签名算法说明文档:https://www.qcloud.com/document/product/436/7778 + // 步骤一:计算 SignKey + var signKey = CryptoJS.HmacSHA1(qKeyTime, SecretKey).toString(); + // 步骤二:构成 FormatString + var formatString = [method, pathname, obj2str(queryParams), obj2str(headers), ''].join('\n'); + // 步骤三:计算 StringToSign + var stringToSign = ['sha1', qSignTime, CryptoJS.SHA1(formatString).toString(), ''].join('\n'); -/**/ + // 步骤四:计算 Signature + var qSignature = CryptoJS.HmacSHA1(stringToSign, signKey).toString(); -var processNextTick = __webpack_require__(18); -/**/ + // 步骤五:构造 Authorization + var authorization = ['q-sign-algorithm=' + qSignAlgorithm, 'q-ak=' + qAk, 'q-sign-time=' + qSignTime, 'q-key-time=' + qKeyTime, 'q-header-list=' + qHeaderList, 'q-url-param-list=' + qUrlParamList, 'q-signature=' + qSignature].join('&'); -/**/ -var objectKeys = Object.keys || function (obj) { - var keys = []; - for (var key in obj) { - keys.push(key); - }return keys; + return authorization; }; -/**/ - -module.exports = Duplex; - -/**/ -var util = __webpack_require__(11); -util.inherits = __webpack_require__(8); -/**/ - -var Readable = __webpack_require__(45); -var Writable = __webpack_require__(30); - -util.inherits(Duplex, Readable); -var keys = objectKeys(Writable.prototype); -for (var v = 0; v < keys.length; v++) { - var method = keys[v]; - if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; -} - -function Duplex(options) { - if (!(this instanceof Duplex)) return new Duplex(options); - - Readable.call(this, options); - Writable.call(this, options); - - if (options && options.readable === false) this.readable = false; +// 清除对象里值为的 undefined 或 null 的属性 +var clearKey = function (obj) { + var retObj = {}; + for (var key in obj) { + if (obj[key] !== undefined && obj[key] !== null) { + retObj[key] = obj[key]; + } + } + return retObj; +}; - if (options && options.writable === false) this.writable = false; +var readAsBinaryString = function (blob, callback) { + var readFun; + var fr = new FileReader(); + if (FileReader.prototype.readAsBinaryString) { + readFun = FileReader.prototype.readAsBinaryString; + fr.onload = function () { + callback(this.result); + }; + } else if (FileReader.prototype.readAsArrayBuffer) { + // 在 ie11 添加 readAsBinaryString 兼容 + readFun = function (fileData) { + var binary = ""; + var pt = this; + var reader = new FileReader(); + reader.onload = function (e) { + var bytes = new Uint8Array(reader.result); + var length = bytes.byteLength; + for (var i = 0; i < length; i++) { + binary += String.fromCharCode(bytes[i]); + } + callback(binary); + }; + reader.readAsArrayBuffer(fileData); + }; + } else { + console.error('FileReader not support readAsBinaryString'); + } + readFun.call(fr, blob); +}; - this.allowHalfOpen = true; - if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; +// 获取文件 sha1 值 +var getFileSHA = function (blob, callback) { + readAsBinaryString(blob, function (content) { + var hash = CryptoJS.SHA1(content).toString(); + callback(null, hash); + }); +}; - this.once('end', onend); +// 获取文件 md5 值 +var getFileMd5 = function (blob, callback) { + readAsBinaryString(blob, function (content) { + var hash = md5(content); + callback(null, hash); + }); +}; +function clone(obj) { + return map(obj, function (v) { + return typeof v === 'object' ? clone(v) : v; + }); } - -// the no-half-open enforcer -function onend() { - // if we allow half-open state, or if the writable side ended, - // then we're ok. - if (this.allowHalfOpen || this._writableState.ended) return; - - // no more data can be written. - // But allow more writes to happen in this tick. - processNextTick(onEndNT, this); +function extend(target, source) { + each(source, function (val, key) { + target[key] = source[key]; + }); + return target; } - -function onEndNT(self) { - self.end(); +function isArray(arr) { + return arr instanceof Array; } - -Object.defineProperty(Duplex.prototype, 'destroyed', { - get: function () { - if (this._readableState === undefined || this._writableState === undefined) { - return false; +function each(obj, fn) { + for (var i in obj) { + if (obj.hasOwnProperty(i)) { + fn(obj[i], i); + } } - return this._readableState.destroyed && this._writableState.destroyed; - }, - set: function (value) { - // we ignore the value if the stream - // has not been initialized yet - if (this._readableState === undefined || this._writableState === undefined) { - return; +} +function map(obj, fn) { + var o = isArray(obj) ? [] : {}; + for (var i in obj) { + if (obj.hasOwnProperty(i)) { + o[i] = fn(obj[i], i); + } } - - // backward compatibility, the user is explicitly - // managing destroyed - this._readableState.destroyed = value; - this._writableState.destroyed = value; - } -}); - -Duplex.prototype._destroy = function (err, cb) { - this.push(null); - this.end(); - - processNextTick(cb, err); -}; - -function forEach(xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xs[i], i); - } + return o; } +function filter(obj, fn) { + var iaArr = isArray(obj); + var o = iaArr ? [] : {}; + for (var i in obj) { + if (obj.hasOwnProperty(i)) { + if (fn(obj[i], i)) { + if (iaArr) { + o.push(obj[i]); + } else { + o[i] = obj[i]; + } + } + } + } + return o; +} +var binaryBase64 = function (str) { + var i, + len, + char, + arr = []; + for (i = 0, len = str.length / 2; i < len; i++) { + char = parseInt(str[i * 2] + str[i * 2 + 1], 16); + arr.push(char); + } + return new Buffer(arr).toString('base64'); +}; +var uuid = function () { + var S4 = function () { + return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1); + }; + return S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4(); +}; -/***/ }), -/* 6 */ -/***/ (function(module, exports, __webpack_require__) { - -var baseIsNative = __webpack_require__(92), - getValue = __webpack_require__(97); +var checkParams = function (apiName, params) { + var bucket = params.Bucket; + var region = params.Region; + var object = params.Key; + if (apiName.indexOf('Bucket') > -1 || apiName === 'deleteMultipleObject' || apiName === 'multipartList') { + return bucket && region; + } + if (apiName.indexOf('Object') > -1 || apiName.indexOf('multipart') > -1 || apiName === 'sliceUploadFile' || apiName === 'abortUploadTask') { + return bucket && region && object; + } + return true; +}; -/** - * Gets the native function at `key` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {string} key The key of the method to get. - * @returns {*} Returns the function if it's native, else `undefined`. - */ -function getNative(object, key) { - var value = getValue(object, key); - return baseIsNative(value) ? value : undefined; +var apiWrapper = function (apiName, apiFn) { + var regionMap = { + 'gz': 'ap-guangzhou', + 'tj': 'ap-beijing-2', + 'sh': 'ap-shanghai', + 'cd': 'ap-chengdu' + }; + return function (params, callback) { + callback = callback || function () {}; + if (apiName !== 'getService' && apiName !== 'abortUploadTask') { + // 判断参数是否完整 + if (!checkParams(apiName, params)) { + callback({ error: 'lack of required params' }); + return; + } + // 判断 region 格式 + if (params.Region && regionMap[params.Region]) { + callback({ error: 'Region should be ' + regionMap[params.Region] }); + return; + } + // 判断 region 格式 + if (params.Region && params.Region.indexOf('cos.') > -1) { + callback({ error: 'Region should not be start with "cos."' }); + return; + } + // 兼容带有 AppId 的 Bucket + var appId, + m, + bucket = params.Bucket; + if (bucket && (m = bucket.match(/^(.+)-(\d+)$/))) { + appId = m[2]; + bucket = m[1]; + params.AppId = appId; + params.Bucket = bucket; + } + // 兼容带有斜杠开头的 Key + if (params.Key && params.Key.substr(0, 1) === '/') { + params.Key = params.Key.substr(1); + } + } + var res = apiFn.call(this, params, callback); + if (apiName === 'getAuth') { + return res; + } + }; +}; + +var throttleOnProgress = function (total, onProgress) { + var self = this; + var size0 = 0; + var size1 = 0; + var time0 = Date.now(); + var time1; + var timer; + var update = function () { + timer = 0; + if (onProgress && typeof onProgress === 'function') { + time1 = Date.now(); + var speed = Math.max(0, parseInt((size1 - size0) / ((time1 - time0) / 1000) * 100) / 100); + var percent = size1 === 0 && total === 0 ? 1 : parseInt(size1 / total * 100) / 100 || 0; + time0 = time1; + size0 = size1; + try { + onProgress({ loaded: size1, total: total, speed: speed, percent: percent }); + } catch (e) {} + } + }; + return function (info, immediately) { + if (info) { + size1 = info.loaded; + total = info.total; + } + if (immediately) { + clearTimeout(timer); + update(); + } else { + if (timer) return; + timer = setTimeout(update, self.options.ProgressInterval); + } + }; +}; + +var fileSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice; + +var util = { + fileSlice: fileSlice, + apiWrapper: apiWrapper, + getAuth: getAuth, + xml2json: xml2json, + json2xml: json2xml, + md5: md5, + clearKey: clearKey, + getFileMd5: getFileMd5, + binaryBase64: binaryBase64, + extend: extend, + isArray: isArray, + each: each, + map: map, + filter: filter, + clone: clone, + uuid: uuid, + throttleOnProgress: throttleOnProgress, + isBrowser: !!global.window +}; + +module.exports = util; +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2).Buffer, __webpack_require__(1))) + +/***/ }), +/* 1 */ +/***/ (function(module, exports) { + +var g; + +// This works in non-strict mode +g = (function() { + return this; +})(); + +try { + // This works if eval is allowed (see CSP) + g = g || Function("return this")() || (1,eval)("this"); +} catch(e) { + // This works if the window reference is available + if(typeof window === "object") + g = window; } -module.exports = getNative; +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} + +module.exports = g; /***/ }), -/* 7 */ +/* 2 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -391,9 +448,9 @@ module.exports = getNative; -var base64 = __webpack_require__(74) -var ieee754 = __webpack_require__(75) -var isArray = __webpack_require__(44) +var base64 = __webpack_require__(7) +var ieee754 = __webpack_require__(8) +var isArray = __webpack_require__(9) exports.Buffer = Buffer exports.SlowBuffer = SlowBuffer @@ -2171,26885 +2228,8259 @@ function isnan (val) { return val !== val // eslint-disable-line no-self-compare } -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) - -/***/ }), -/* 8 */ -/***/ (function(module, exports) { - -if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - }; -} else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } -} - +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }), -/* 9 */ +/* 3 */ /***/ (function(module, exports) { -// shim for using process in browser -var process = module.exports = {}; - -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. - -var cachedSetTimeout; -var cachedClearTimeout; - -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); -} -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); +var initEvent = function (cos) { + var listeners = {}; + var getList = function (action) { + !listeners[action] && (listeners[action] = []); + return listeners[action]; + }; + cos.on = function (action, callback) { + if (action === 'task-list-update') { + console.warn('Event "' + action + '" has been deprecated. Please use "list-update" instead.'); } - } - - - -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; - -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } -} - -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } + getList(action).push(callback); + }; + cos.off = function (action, callback) { + var list = getList(action); + for (var i = list.length - 1; i >= 0; i--) { + callback === list[i] && list.splice(i, 1); } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} - -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; + }; + cos.emit = function (action, data) { + var list = getList(action).map(function (cb) { + return cb; + }); + for (var i = 0; i < list.length; i++) { + list[i](data); } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); + }; }; -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); +var EventProxy = function () { + initEvent(this); }; -process.umask = function() { return 0; }; +module.exports.init = initEvent; +module.exports.EventProxy = EventProxy; /***/ }), -/* 10 */ +/* 4 */ /***/ (function(module, exports, __webpack_require__) { -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLElement, XMLNode, XMLRaw, XMLText, isEmpty, isFunction, isObject, - hasProp = {}.hasOwnProperty; - - isObject = __webpack_require__(1); +"use strict"; - isFunction = __webpack_require__(20); - isEmpty = __webpack_require__(119); +exports.decode = exports.parse = __webpack_require__(16); +exports.encode = exports.stringify = __webpack_require__(17); - XMLElement = null; - XMLCData = null; +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { - XMLComment = null; +var COS = __webpack_require__(6); +module.exports = COS; - XMLDeclaration = null; +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { - XMLDocType = null; +"use strict"; - XMLRaw = null; - XMLText = null; +var util = __webpack_require__(0); +var event = __webpack_require__(3); +var task = __webpack_require__(14); +var base = __webpack_require__(15); +var advance = __webpack_require__(19); - module.exports = XMLNode = (function() { - function XMLNode(parent) { - this.parent = parent; - this.options = this.parent.options; - this.stringify = this.parent.stringify; - if (XMLElement === null) { - XMLElement = __webpack_require__(59); - XMLCData = __webpack_require__(68); - XMLComment = __webpack_require__(69); - XMLDeclaration = __webpack_require__(57); - XMLDocType = __webpack_require__(70); - XMLRaw = __webpack_require__(194); - XMLText = __webpack_require__(195); - } - } - - XMLNode.prototype.element = function(name, attributes, text) { - var childNode, item, j, k, key, lastChild, len, len1, ref, val; - lastChild = null; - if (attributes == null) { - attributes = {}; - } - attributes = attributes.valueOf(); - if (!isObject(attributes)) { - ref = [attributes, text], text = ref[0], attributes = ref[1]; - } - if (name != null) { - name = name.valueOf(); - } - if (Array.isArray(name)) { - for (j = 0, len = name.length; j < len; j++) { - item = name[j]; - lastChild = this.element(item); - } - } else if (isFunction(name)) { - lastChild = this.element(name.apply()); - } else if (isObject(name)) { - for (key in name) { - if (!hasProp.call(name, key)) continue; - val = name[key]; - if (isFunction(val)) { - val = val.apply(); - } - if ((isObject(val)) && (isEmpty(val))) { - val = null; - } - if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) { - lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val); - } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && key.indexOf(this.stringify.convertPIKey) === 0) { - lastChild = this.instruction(key.substr(this.stringify.convertPIKey.length), val); - } else if (!this.options.separateArrayItems && Array.isArray(val)) { - for (k = 0, len1 = val.length; k < len1; k++) { - item = val[k]; - childNode = {}; - childNode[key] = item; - lastChild = this.element(childNode); - } - } else if (isObject(val)) { - lastChild = this.element(key); - lastChild.element(val); - } else { - lastChild = this.element(key, val); - } - } - } else { - if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) { - lastChild = this.text(text); - } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) { - lastChild = this.cdata(text); - } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) { - lastChild = this.comment(text); - } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) { - lastChild = this.raw(text); - } else { - lastChild = this.node(name, attributes, text); - } - } - if (lastChild == null) { - throw new Error("Could not create any elements with: " + name); - } - return lastChild; - }; - - XMLNode.prototype.insertBefore = function(name, attributes, text) { - var child, i, removed; - if (this.isRoot) { - throw new Error("Cannot insert elements at root level"); - } - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i); - child = this.parent.element(name, attributes, text); - Array.prototype.push.apply(this.parent.children, removed); - return child; - }; - - XMLNode.prototype.insertAfter = function(name, attributes, text) { - var child, i, removed; - if (this.isRoot) { - throw new Error("Cannot insert elements at root level"); - } - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i + 1); - child = this.parent.element(name, attributes, text); - Array.prototype.push.apply(this.parent.children, removed); - return child; - }; - - XMLNode.prototype.remove = function() { - var i, ref; - if (this.isRoot) { - throw new Error("Cannot remove the root element"); - } - i = this.parent.children.indexOf(this); - [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref = [])), ref; - return this.parent; - }; - - XMLNode.prototype.node = function(name, attributes, text) { - var child, ref; - if (name != null) { - name = name.valueOf(); - } - if (attributes == null) { - attributes = {}; - } - attributes = attributes.valueOf(); - if (!isObject(attributes)) { - ref = [attributes, text], text = ref[0], attributes = ref[1]; - } - child = new XMLElement(this, name, attributes); - if (text != null) { - child.text(text); - } - this.children.push(child); - return child; - }; - - XMLNode.prototype.text = function(value) { - var child; - child = new XMLText(this, value); - this.children.push(child); - return this; - }; - - XMLNode.prototype.cdata = function(value) { - var child; - child = new XMLCData(this, value); - this.children.push(child); - return this; - }; - - XMLNode.prototype.comment = function(value) { - var child; - child = new XMLComment(this, value); - this.children.push(child); - return this; - }; - - XMLNode.prototype.raw = function(value) { - var child; - child = new XMLRaw(this, value); - this.children.push(child); - return this; - }; - - XMLNode.prototype.declaration = function(version, encoding, standalone) { - var doc, xmldec; - doc = this.document(); - xmldec = new XMLDeclaration(doc, version, encoding, standalone); - doc.xmldec = xmldec; - return doc.root(); - }; - - XMLNode.prototype.doctype = function(pubID, sysID) { - var doc, doctype; - doc = this.document(); - doctype = new XMLDocType(doc, pubID, sysID); - doc.doctype = doctype; - return doctype; - }; - - XMLNode.prototype.up = function() { - if (this.isRoot) { - throw new Error("The root node has no parent. Use doc() if you need to get the document object."); - } - return this.parent; - }; - - XMLNode.prototype.root = function() { - var child; - if (this.isRoot) { - return this; - } - child = this.parent; - while (!child.isRoot) { - child = child.parent; - } - return child; - }; - - XMLNode.prototype.document = function() { - return this.root().documentObject; - }; - - XMLNode.prototype.end = function(options) { - return this.document().toString(options); - }; - - XMLNode.prototype.prev = function() { - var i; - if (this.isRoot) { - throw new Error("Root node has no siblings"); - } - i = this.parent.children.indexOf(this); - if (i < 1) { - throw new Error("Already at the first node"); - } - return this.parent.children[i - 1]; - }; - - XMLNode.prototype.next = function() { - var i; - if (this.isRoot) { - throw new Error("Root node has no siblings"); - } - i = this.parent.children.indexOf(this); - if (i === -1 || i === this.parent.children.length - 1) { - throw new Error("Already at the last node"); - } - return this.parent.children[i + 1]; - }; - - XMLNode.prototype.importXMLBuilder = function(xmlbuilder) { - var clonedRoot; - clonedRoot = xmlbuilder.root().clone(); - clonedRoot.parent = this; - clonedRoot.isRoot = false; - this.children.push(clonedRoot); - return this; - }; - - XMLNode.prototype.ele = function(name, attributes, text) { - return this.element(name, attributes, text); - }; - - XMLNode.prototype.nod = function(name, attributes, text) { - return this.node(name, attributes, text); - }; - - XMLNode.prototype.txt = function(value) { - return this.text(value); - }; - - XMLNode.prototype.dat = function(value) { - return this.cdata(value); - }; - - XMLNode.prototype.com = function(value) { - return this.comment(value); - }; - - XMLNode.prototype.doc = function() { - return this.document(); - }; - - XMLNode.prototype.dec = function(version, encoding, standalone) { - return this.declaration(version, encoding, standalone); - }; - - XMLNode.prototype.dtd = function(pubID, sysID) { - return this.doctype(pubID, sysID); - }; - - XMLNode.prototype.e = function(name, attributes, text) { - return this.element(name, attributes, text); - }; - - XMLNode.prototype.n = function(name, attributes, text) { - return this.node(name, attributes, text); - }; - - XMLNode.prototype.t = function(value) { - return this.text(value); - }; +var defaultOptions = { + AppId: '', + SecretId: '', + SecretKey: '', + FileParallelLimit: 3, + ChunkParallelLimit: 3, + ChunkSize: 1024 * 1024, + SliceSize: 1024 * 1024 * 20, + ProgressInterval: 1000, + Domain: '', + ServiceDomain: '' +}; - XMLNode.prototype.d = function(value) { - return this.cdata(value); - }; +// 对外暴露的类 +var COS = function (options) { + this.options = util.extend(util.clone(defaultOptions), options || {}); + event.init(this); + task.init(this); +}; - XMLNode.prototype.c = function(value) { - return this.comment(value); - }; +util.extend(COS.prototype, base); +util.extend(COS.prototype, advance); - XMLNode.prototype.r = function(value) { - return this.raw(value); - }; +COS.getAuthorization = util.getAuth; +COS.version = '0.1.5'; - XMLNode.prototype.u = function() { - return this.up(); - }; +module.exports = window.COS = COS; - return XMLNode; +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { - })(); +"use strict"; -}).call(this); +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray -/***/ }), -/* 11 */ -/***/ (function(module, exports, __webpack_require__) { +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array -/* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i +} -// NOTE: These type checking functions intentionally don't use `instanceof` -// because it is fragile and can be easily faked with `Object.create()`. +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 -function isArray(arg) { - if (Array.isArray) { - return Array.isArray(arg); +function placeHoldersCount (b64) { + var len = b64.length + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') } - return objectToString(arg) === '[object Array]'; -} -exports.isArray = isArray; -function isBoolean(arg) { - return typeof arg === 'boolean'; + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 } -exports.isBoolean = isBoolean; -function isNull(arg) { - return arg === null; +function byteLength (b64) { + // base64 is 4/3 + up to two characters of the original data + return (b64.length * 3 / 4) - placeHoldersCount(b64) } -exports.isNull = isNull; -function isNullOrUndefined(arg) { - return arg == null; -} -exports.isNullOrUndefined = isNullOrUndefined; +function toByteArray (b64) { + var i, l, tmp, placeHolders, arr + var len = b64.length + placeHolders = placeHoldersCount(b64) -function isNumber(arg) { - return typeof arg === 'number'; -} -exports.isNumber = isNumber; + arr = new Arr((len * 3 / 4) - placeHolders) -function isString(arg) { - return typeof arg === 'string'; -} -exports.isString = isString; + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? len - 4 : len -function isSymbol(arg) { - return typeof arg === 'symbol'; -} -exports.isSymbol = isSymbol; + var L = 0 -function isUndefined(arg) { - return arg === void 0; -} -exports.isUndefined = isUndefined; + for (i = 0; i < l; i += 4) { + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] + arr[L++] = (tmp >> 16) & 0xFF + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } -function isRegExp(re) { - return objectToString(re) === '[object RegExp]'; -} -exports.isRegExp = isRegExp; + if (placeHolders === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[L++] = tmp & 0xFF + } else if (placeHolders === 1) { + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } -function isObject(arg) { - return typeof arg === 'object' && arg !== null; + return arr } -exports.isObject = isObject; -function isDate(d) { - return objectToString(d) === '[object Date]'; +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] } -exports.isDate = isDate; -function isError(e) { - return (objectToString(e) === '[object Error]' || e instanceof Error); +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) + output.push(tripletToBase64(tmp)) + } + return output.join('') } -exports.isError = isError; -function isFunction(arg) { - return typeof arg === 'function'; -} -exports.isFunction = isFunction; - -function isPrimitive(arg) { - return arg === null || - typeof arg === 'boolean' || - typeof arg === 'number' || - typeof arg === 'string' || - typeof arg === 'symbol' || // ES6 symbol - typeof arg === 'undefined'; -} -exports.isPrimitive = isPrimitive; +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var output = '' + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + output += lookup[tmp >> 2] + output += lookup[(tmp << 4) & 0x3F] + output += '==' + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) + output += lookup[tmp >> 10] + output += lookup[(tmp >> 4) & 0x3F] + output += lookup[(tmp << 2) & 0x3F] + output += '=' + } -exports.isBuffer = Buffer.isBuffer; + parts.push(output) -function objectToString(o) { - return Object.prototype.toString.call(o); + return parts.join('') } -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7).Buffer)) /***/ }), -/* 12 */ -/***/ (function(module, exports, __webpack_require__) { +/* 8 */ +/***/ (function(module, exports) { -var Symbol = __webpack_require__(21), - getRawTag = __webpack_require__(93), - objectToString = __webpack_require__(94); +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] -/** `Object#toString` result references. */ -var nullTag = '[object Null]', - undefinedTag = '[object Undefined]'; + i += d -/** Built-in value references. */ -var symToStringTag = Symbol ? Symbol.toStringTag : undefined; + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} -/** - * The base implementation of `getTag` without fallbacks for buggy environments. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ -function baseGetTag(value) { - if (value == null) { - return value === undefined ? undefinedTag : nullTag; + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias } - return (symToStringTag && symToStringTag in Object(value)) - ? getRawTag(value) - : objectToString(value); + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) } -module.exports = baseGetTag; +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + value = Math.abs(value) -/***/ }), -/* 13 */ -/***/ (function(module, exports, __webpack_require__) { + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } -var isFunction = __webpack_require__(20), - isLength = __webpack_require__(33); + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } -/** - * Checks if `value` is array-like. A value is considered array-like if it's - * not a function and has a `value.length` that's an integer greater than or - * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - * @example - * - * _.isArrayLike([1, 2, 3]); - * // => true - * - * _.isArrayLike(document.body.children); - * // => true - * - * _.isArrayLike('abc'); - * // => true - * - * _.isArrayLike(_.noop); - * // => false - */ -function isArrayLike(value) { - return value != null && isLength(value.length) && !isFunction(value); -} + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} -module.exports = isArrayLike; + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + buffer[offset + i - d] |= s * 128 +} -/***/ }), -/* 14 */ -/***/ (function(module, exports, __webpack_require__) { -var arrayLikeKeys = __webpack_require__(106), - baseKeys = __webpack_require__(56), - isArrayLike = __webpack_require__(13); +/***/ }), +/* 9 */ +/***/ (function(module, exports) { -/** - * Creates an array of the own enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) - * for more details. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keys(new Foo); - * // => ['a', 'b'] (iteration order is not guaranteed) - * - * _.keys('hi'); - * // => ['0', '1'] - */ -function keys(object) { - return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); -} +var toString = {}.toString; -module.exports = keys; +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; /***/ }), -/* 15 */ +/* 10 */ /***/ (function(module, exports) { /** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false + * MD5 (Message-Digest Algorithm) + * http://www.webtoolkit.info/ * - * _.isObjectLike(null); - * // => false - */ -function isObjectLike(value) { - return value != null && typeof value == 'object'; -} - -module.exports = isObjectLike; - + **/ -/***/ }), -/* 16 */ -/***/ (function(module, exports, __webpack_require__) { +var md5 = function (string) { -"use strict"; -/* WEBPACK VAR INJECTION */(function(Buffer, global) { + function RotateLeft(lValue, iShiftBits) { + return lValue << iShiftBits | lValue >>> 32 - iShiftBits; + } -var md5 = __webpack_require__(76); -var CryptoJS = __webpack_require__(77); -var xml2js = __webpack_require__(78); -var xmlParser = new xml2js.Parser({ explicitArray: false, ignoreAttrs: true }); -var xmlBuilder = new xml2js.Builder(); + function AddUnsigned(lX, lY) { + var lX4, lY4, lX8, lY8, lResult; + lX8 = lX & 0x80000000; + lY8 = lY & 0x80000000; + lX4 = lX & 0x40000000; + lY4 = lY & 0x40000000; + lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF); + if (lX4 & lY4) { + return lResult ^ 0x80000000 ^ lX8 ^ lY8; + } + if (lX4 | lY4) { + if (lResult & 0x40000000) { + return lResult ^ 0xC0000000 ^ lX8 ^ lY8; + } else { + return lResult ^ 0x40000000 ^ lX8 ^ lY8; + } + } else { + return lResult ^ lX8 ^ lY8; + } + } -function camSafeUrlEncode(str) { - return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A'); -} + function F(x, y, z) { + return x & y | ~x & z; + } + function G(x, y, z) { + return x & z | y & ~z; + } + function H(x, y, z) { + return x ^ y ^ z; + } + function I(x, y, z) { + return y ^ (x | ~z); + } -//测试用的key后面可以去掉 -var getAuth = function (opt) { + function FF(a, b, c, d, x, s, ac) { + a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac)); + return AddUnsigned(RotateLeft(a, s), b); + }; - opt = opt || {}; + function GG(a, b, c, d, x, s, ac) { + a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac)); + return AddUnsigned(RotateLeft(a, s), b); + }; - var SecretId = opt.SecretId; - var SecretKey = opt.SecretKey; - var method = (opt.method || opt.Method || 'get').toLowerCase(); - var pathname = opt.pathname || opt.Key || '/'; - var queryParams = opt.params || ''; - var headers = opt.headers || ''; - pathname.indexOf('/') === -1 && (pathname = '/' + pathname); + function HH(a, b, c, d, x, s, ac) { + a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac)); + return AddUnsigned(RotateLeft(a, s), b); + }; - if (!SecretId) return console.error('lack of param SecretId'); - if (!SecretKey) return console.error('lack of param SecretKey'); + function II(a, b, c, d, x, s, ac) { + a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac)); + return AddUnsigned(RotateLeft(a, s), b); + }; - var getObjectKeys = function (obj) { - var list = []; - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - list.push(key); - } + function ConvertToWordArray(string) { + var lWordCount; + var lMessageLength = string.length; + var lNumberOfWords_temp1 = lMessageLength + 8; + var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - lNumberOfWords_temp1 % 64) / 64; + var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16; + var lWordArray = Array(lNumberOfWords - 1); + var lBytePosition = 0; + var lByteCount = 0; + while (lByteCount < lMessageLength) { + lWordCount = (lByteCount - lByteCount % 4) / 4; + lBytePosition = lByteCount % 4 * 8; + lWordArray[lWordCount] = lWordArray[lWordCount] | string.charCodeAt(lByteCount) << lBytePosition; + lByteCount++; } - return list.sort(); + lWordCount = (lByteCount - lByteCount % 4) / 4; + lBytePosition = lByteCount % 4 * 8; + lWordArray[lWordCount] = lWordArray[lWordCount] | 0x80 << lBytePosition; + lWordArray[lNumberOfWords - 2] = lMessageLength << 3; + lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29; + return lWordArray; }; - var obj2str = function (obj) { - var i, key, val; - var list = []; - var keyList = getObjectKeys(obj); - for (i = 0; i < keyList.length; i++) { - key = keyList[i]; - val = obj[key] || ''; - key = key.toLowerCase(); - list.push(camSafeUrlEncode(key) + '=' + camSafeUrlEncode(val)); + function WordToHex(lValue) { + var WordToHexValue = "", + WordToHexValue_temp = "", + lByte, + lCount; + for (lCount = 0; lCount <= 3; lCount++) { + lByte = lValue >>> lCount * 8 & 255; + WordToHexValue_temp = "0" + lByte.toString(16); + WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length - 2, 2); } - return list.join('&'); + return WordToHexValue; }; - // 签名有效起止时间 - var now = parseInt(new Date().getTime() / 1000) - 1; - var expired = now; + function Utf8Encode(string) { + string = string.replace(/\r\n/g, "\n"); + var utftext = ""; - if (opt.expires === undefined) { - expired += 3600; // 签名过期时间为当前 + 3600s - } else { - expired += opt.expires * 1 || 0; - } + for (var n = 0; n < string.length; n++) { - // 要用到的 Authorization 参数列表 - var qSignAlgorithm = 'sha1'; - var qAk = SecretId; - var qSignTime = now + ';' + expired; - var qKeyTime = now + ';' + expired; - var qHeaderList = getObjectKeys(headers).join(';').toLowerCase(); - var qUrlParamList = getObjectKeys(queryParams).join(';').toLowerCase(); + var c = string.charCodeAt(n); - // 签名算法说明文档:https://www.qcloud.com/document/product/436/7778 - // 步骤一:计算 SignKey - var signKey = CryptoJS.HmacSHA1(qKeyTime, SecretKey).toString(); + if (c < 128) { + utftext += String.fromCharCode(c); + } else if (c > 127 && c < 2048) { + utftext += String.fromCharCode(c >> 6 | 192); + utftext += String.fromCharCode(c & 63 | 128); + } else { + utftext += String.fromCharCode(c >> 12 | 224); + utftext += String.fromCharCode(c >> 6 & 63 | 128); + utftext += String.fromCharCode(c & 63 | 128); + } + } - // 步骤二:构成 FormatString - var formatString = [method, pathname, obj2str(queryParams), obj2str(headers), ''].join('\n'); + return utftext; + }; - // 步骤三:计算 StringToSign - var stringToSign = ['sha1', qSignTime, CryptoJS.SHA1(formatString).toString(), ''].join('\n'); - - // 步骤四:计算 Signature - var qSignature = CryptoJS.HmacSHA1(stringToSign, signKey).toString(); - - // 步骤五:构造 Authorization - var authorization = ['q-sign-algorithm=' + qSignAlgorithm, 'q-ak=' + qAk, 'q-sign-time=' + qSignTime, 'q-key-time=' + qKeyTime, 'q-header-list=' + qHeaderList, 'q-url-param-list=' + qUrlParamList, 'q-signature=' + qSignature].join('&'); - - return authorization; -}; - -// XML 对象转 JSON 对象 -var xml2json = function (bodyStr) { - var d = {}; - xmlParser.parseString(bodyStr, function (err, result) { - d = result; - }); - - return d; -}; - -// JSON 对象转 XML 对象 -var json2xml = function (json) { - var xml = xmlBuilder.buildObject(json); - return xml; -}; - -// 清除对象里值为的 undefined 或 null 的属性 -var clearKey = function (obj) { - var retObj = {}; - for (var key in obj) { - if (obj[key] !== undefined && obj[key] !== null) { - retObj[key] = obj[key]; - } - } - return retObj; -}; - -var readAsBinaryString = function (blob, callback) { - var readFun; - var fr = new FileReader(); - if (FileReader.prototype.readAsBinaryString) { - readFun = FileReader.prototype.readAsBinaryString; - fr.onload = function () { - callback(this.result); - }; - } else if (FileReader.prototype.readAsArrayBuffer) { - // 在 ie11 添加 readAsBinaryString 兼容 - readFun = function (fileData) { - var binary = ""; - var pt = this; - var reader = new FileReader(); - reader.onload = function (e) { - var bytes = new Uint8Array(reader.result); - var length = bytes.byteLength; - for (var i = 0; i < length; i++) { - binary += String.fromCharCode(bytes[i]); - } - callback(binary); - }; - reader.readAsArrayBuffer(fileData); - }; - } else { - console.error('FileReader not support readAsBinaryString'); - } - readFun.call(fr, blob); -}; - -// 获取文件 sha1 值 -var getFileSHA = function (blob, callback) { - readAsBinaryString(blob, function (content) { - var hash = CryptoJS.SHA1(content).toString(); - callback(null, hash); - }); -}; - -// 获取文件 md5 值 -var getFileMd5 = function (blob, callback) { - readAsBinaryString(blob, function (content) { - var hash = md5(content); - callback(null, hash); - }); -}; -function clone(obj) { - return map(obj, function (v) { - return typeof v === 'object' ? clone(v) : v; - }); -} -function extend(target, source) { - each(source, function (val, key) { - target[key] = source[key]; - }); - return target; -} -function isArray(arr) { - return arr instanceof Array; -} -function each(obj, fn) { - for (var i in obj) { - if (obj.hasOwnProperty(i)) { - fn(obj[i], i); - } - } -} -function map(obj, fn) { - var o = isArray(obj) ? [] : {}; - for (var i in obj) { - if (obj.hasOwnProperty(i)) { - o[i] = fn(obj[i], i); - } - } - return o; -} -function filter(obj, fn) { - var iaArr = isArray(obj); - var o = iaArr ? [] : {}; - for (var i in obj) { - if (obj.hasOwnProperty(i)) { - if (fn(obj[i], i)) { - if (iaArr) { - o.push(obj[i]); - } else { - o[i] = obj[i]; - } - } - } - } - return o; -} -var binaryBase64 = function (str) { - var i, - len, - char, - arr = []; - for (i = 0, len = str.length / 2; i < len; i++) { - char = parseInt(str[i * 2] + str[i * 2 + 1], 16); - arr.push(char); - } - return new Buffer(arr).toString('base64'); -}; -var uuid = function () { - var S4 = function () { - return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1); - }; - return S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4(); -}; - -var checkParams = function (apiName, params) { - var bucket = params.Bucket; - var region = params.Region; - var object = params.Key; - if (apiName.indexOf('Bucket') > -1 || apiName === 'deleteMultipleObject' || apiName === 'multipartList') { - return bucket && region; - } - if (apiName.indexOf('Object') > -1 || apiName.indexOf('multipart') > -1 || apiName === 'sliceUploadFile' || apiName === 'abortUploadTask') { - return bucket && region && object; - } - return true; -}; - -var apiWrapper = function (apiName, apiFn) { - var regionMap = { - 'gz': 'ap-guangzhou', - 'tj': 'ap-beijing-2', - 'sh': 'ap-shanghai', - 'cd': 'ap-chengdu' - }; - return function (params, callback) { - callback = callback || function () {}; - if (apiName !== 'getService' && apiName !== 'abortUploadTask') { - // 判断参数是否完整 - if (!checkParams(apiName, params)) { - callback({ error: 'lack of required params' }); - return; - } - // 判断 region 格式 - if (params.Region && regionMap[params.Region]) { - callback({ error: 'Region should be ' + regionMap[params.Region] }); - return; - } - // 判断 region 格式 - if (params.Region && params.Region.indexOf('cos.') > -1) { - callback({ error: 'Region should not be start with "cos."' }); - return; - } - // 兼容带有 AppId 的 Bucket - var appId, - bucket = params.Bucket; - if (bucket && bucket.indexOf('-') > -1) { - var arr = bucket.split('-'); - appId = arr[1]; - bucket = arr[0]; - params.AppId = appId; - params.Bucket = bucket; - } - // 兼容带有斜杠开头的 Key - if (params.Key && params.Key.substr(0, 1) === '/') { - params.Key = params.Key.substr(1); - } - } - var res = apiFn.call(this, params, callback); - if (apiName === 'getAuth') { - return res; - } - }; -}; - -var fileSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice; - -var util = { - fileSlice: fileSlice, - apiWrapper: apiWrapper, - getAuth: getAuth, - xml2json: xml2json, - json2xml: json2xml, - md5: md5, - clearKey: clearKey, - getFileMd5: getFileMd5, - binaryBase64: binaryBase64, - extend: extend, - isArray: isArray, - each: each, - map: map, - filter: filter, - clone: clone, - uuid: uuid, - isBrowser: !!global.window -}; - -module.exports = util; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7).Buffer, __webpack_require__(3))) - -/***/ }), -/* 17 */ -/***/ (function(module, exports) { - -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -function EventEmitter() { - this._events = this._events || {}; - this._maxListeners = this._maxListeners || undefined; -} -module.exports = EventEmitter; - -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; - -EventEmitter.prototype._events = undefined; -EventEmitter.prototype._maxListeners = undefined; - -// By default EventEmitters will print a warning if more than 10 listeners are -// added to it. This is a useful default which helps finding memory leaks. -EventEmitter.defaultMaxListeners = 10; - -// Obviously not all Emitters should be limited to 10. This function allows -// that to be increased. Set to zero for unlimited. -EventEmitter.prototype.setMaxListeners = function(n) { - if (!isNumber(n) || n < 0 || isNaN(n)) - throw TypeError('n must be a positive number'); - this._maxListeners = n; - return this; -}; - -EventEmitter.prototype.emit = function(type) { - var er, handler, len, args, i, listeners; - - if (!this._events) - this._events = {}; - - // If there is no 'error' event listener then throw. - if (type === 'error') { - if (!this._events.error || - (isObject(this._events.error) && !this._events.error.length)) { - er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } else { - // At least give some kind of context to the user - var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); - err.context = er; - throw err; - } - } - } - - handler = this._events[type]; - - if (isUndefined(handler)) - return false; - - if (isFunction(handler)) { - switch (arguments.length) { - // fast cases - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - // slower - default: - args = Array.prototype.slice.call(arguments, 1); - handler.apply(this, args); - } - } else if (isObject(handler)) { - args = Array.prototype.slice.call(arguments, 1); - listeners = handler.slice(); - len = listeners.length; - for (i = 0; i < len; i++) - listeners[i].apply(this, args); - } - - return true; -}; - -EventEmitter.prototype.addListener = function(type, listener) { - var m; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events) - this._events = {}; - - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (this._events.newListener) - this.emit('newListener', type, - isFunction(listener.listener) ? - listener.listener : listener); - - if (!this._events[type]) - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - else if (isObject(this._events[type])) - // If we've already got an array, just append. - this._events[type].push(listener); - else - // Adding the second element, need to change to array. - this._events[type] = [this._events[type], listener]; - - // Check for listener leak - if (isObject(this._events[type]) && !this._events[type].warned) { - if (!isUndefined(this._maxListeners)) { - m = this._maxListeners; - } else { - m = EventEmitter.defaultMaxListeners; - } - - if (m && m > 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - if (typeof console.trace === 'function') { - // not supported in IE 10 - console.trace(); - } - } - } - - return this; -}; - -EventEmitter.prototype.on = EventEmitter.prototype.addListener; - -EventEmitter.prototype.once = function(type, listener) { - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - var fired = false; - - function g() { - this.removeListener(type, g); - - if (!fired) { - fired = true; - listener.apply(this, arguments); - } - } - - g.listener = listener; - this.on(type, g); - - return this; -}; - -// emits a 'removeListener' event iff the listener was removed -EventEmitter.prototype.removeListener = function(type, listener) { - var list, position, length, i; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events || !this._events[type]) - return this; - - list = this._events[type]; - length = list.length; - position = -1; - - if (list === listener || - (isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (this._events.removeListener) - this.emit('removeListener', type, listener); - - } else if (isObject(list)) { - for (i = length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { - position = i; - break; - } - } - - if (position < 0) - return this; - - if (list.length === 1) { - list.length = 0; - delete this._events[type]; - } else { - list.splice(position, 1); - } - - if (this._events.removeListener) - this.emit('removeListener', type, listener); - } - - return this; -}; - -EventEmitter.prototype.removeAllListeners = function(type) { - var key, listeners; - - if (!this._events) - return this; - - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; - } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - for (key in this._events) { - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = {}; - return this; - } - - listeners = this._events[type]; - - if (isFunction(listeners)) { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - while (listeners.length) - this.removeListener(type, listeners[listeners.length - 1]); - } - delete this._events[type]; - - return this; -}; - -EventEmitter.prototype.listeners = function(type) { - var ret; - if (!this._events || !this._events[type]) - ret = []; - else if (isFunction(this._events[type])) - ret = [this._events[type]]; - else - ret = this._events[type].slice(); - return ret; -}; - -EventEmitter.prototype.listenerCount = function(type) { - if (this._events) { - var evlistener = this._events[type]; - - if (isFunction(evlistener)) - return 1; - else if (evlistener) - return evlistener.length; - } - return 0; -}; - -EventEmitter.listenerCount = function(emitter, type) { - return emitter.listenerCount(type); -}; - -function isFunction(arg) { - return typeof arg === 'function'; -} - -function isNumber(arg) { - return typeof arg === 'number'; -} - -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} - -function isUndefined(arg) { - return arg === void 0; -} - - -/***/ }), -/* 18 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function(process) { - -if (!process.version || - process.version.indexOf('v0.') === 0 || - process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { - module.exports = nextTick; -} else { - module.exports = process.nextTick; -} - -function nextTick(fn, arg1, arg2, arg3) { - if (typeof fn !== 'function') { - throw new TypeError('"callback" argument must be a function'); - } - var len = arguments.length; - var args, i; - switch (len) { - case 0: - case 1: - return process.nextTick(fn); - case 2: - return process.nextTick(function afterTickOne() { - fn.call(null, arg1); - }); - case 3: - return process.nextTick(function afterTickTwo() { - fn.call(null, arg1, arg2); - }); - case 4: - return process.nextTick(function afterTickThree() { - fn.call(null, arg1, arg2, arg3); - }); - default: - args = new Array(len - 1); - i = 0; - while (i < args.length) { - args[i++] = arguments[i]; - } - return process.nextTick(function afterTick() { - fn.apply(null, args); - }); - } -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9))) - -/***/ }), -/* 19 */ -/***/ (function(module, exports, __webpack_require__) { - -var apply = Function.prototype.apply; - -// DOM APIs, for completeness - -exports.setTimeout = function() { - return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); -}; -exports.setInterval = function() { - return new Timeout(apply.call(setInterval, window, arguments), clearInterval); -}; -exports.clearTimeout = -exports.clearInterval = function(timeout) { - if (timeout) { - timeout.close(); - } -}; - -function Timeout(id, clearFn) { - this._id = id; - this._clearFn = clearFn; -} -Timeout.prototype.unref = Timeout.prototype.ref = function() {}; -Timeout.prototype.close = function() { - this._clearFn.call(window, this._id); -}; - -// Does not start the time, just sets up the members needed. -exports.enroll = function(item, msecs) { - clearTimeout(item._idleTimeoutId); - item._idleTimeout = msecs; -}; - -exports.unenroll = function(item) { - clearTimeout(item._idleTimeoutId); - item._idleTimeout = -1; -}; - -exports._unrefActive = exports.active = function(item) { - clearTimeout(item._idleTimeoutId); - - var msecs = item._idleTimeout; - if (msecs >= 0) { - item._idleTimeoutId = setTimeout(function onTimeout() { - if (item._onTimeout) - item._onTimeout(); - }, msecs); - } -}; - -// setimmediate attaches itself to the global object -__webpack_require__(83); -exports.setImmediate = setImmediate; -exports.clearImmediate = clearImmediate; - - -/***/ }), -/* 20 */ -/***/ (function(module, exports, __webpack_require__) { - -var baseGetTag = __webpack_require__(12), - isObject = __webpack_require__(1); - -/** `Object#toString` result references. */ -var asyncTag = '[object AsyncFunction]', - funcTag = '[object Function]', - genTag = '[object GeneratorFunction]', - proxyTag = '[object Proxy]'; - -/** - * Checks if `value` is classified as a `Function` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a function, else `false`. - * @example - * - * _.isFunction(_); - * // => true - * - * _.isFunction(/abc/); - * // => false - */ -function isFunction(value) { - if (!isObject(value)) { - return false; - } - // The use of `Object#toString` avoids issues with the `typeof` operator - // in Safari 9 which returns 'object' for typed arrays and other constructors. - var tag = baseGetTag(value); - return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; -} - -module.exports = isFunction; - - -/***/ }), -/* 21 */ -/***/ (function(module, exports, __webpack_require__) { - -var root = __webpack_require__(4); - -/** Built-in value references. */ -var Symbol = root.Symbol; - -module.exports = Symbol; - - -/***/ }), -/* 22 */ -/***/ (function(module, exports) { - -/** - * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * comparison between two values to determine if they are equivalent. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'a': 1 }; - * var other = { 'a': 1 }; - * - * _.eq(object, object); - * // => true - * - * _.eq(object, other); - * // => false - * - * _.eq('a', 'a'); - * // => true - * - * _.eq('a', Object('a')); - * // => false - * - * _.eq(NaN, NaN); - * // => true - */ -function eq(value, other) { - return value === other || (value !== value && other !== other); -} - -module.exports = eq; - - -/***/ }), -/* 23 */ -/***/ (function(module, exports, __webpack_require__) { - -var listCacheClear = __webpack_require__(135), - listCacheDelete = __webpack_require__(136), - listCacheGet = __webpack_require__(137), - listCacheHas = __webpack_require__(138), - listCacheSet = __webpack_require__(139); - -/** - * Creates an list cache object. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function ListCache(entries) { - var index = -1, - length = entries == null ? 0 : entries.length; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } -} - -// Add methods to `ListCache`. -ListCache.prototype.clear = listCacheClear; -ListCache.prototype['delete'] = listCacheDelete; -ListCache.prototype.get = listCacheGet; -ListCache.prototype.has = listCacheHas; -ListCache.prototype.set = listCacheSet; - -module.exports = ListCache; - - -/***/ }), -/* 24 */ -/***/ (function(module, exports, __webpack_require__) { - -var eq = __webpack_require__(22); - -/** - * Gets the index at which the `key` is found in `array` of key-value pairs. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} key The key to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function assocIndexOf(array, key) { - var length = array.length; - while (length--) { - if (eq(array[length][0], key)) { - return length; - } - } - return -1; -} - -module.exports = assocIndexOf; - - -/***/ }), -/* 25 */ -/***/ (function(module, exports, __webpack_require__) { - -var getNative = __webpack_require__(6); - -/* Built-in method references that are verified to be native. */ -var nativeCreate = getNative(Object, 'create'); - -module.exports = nativeCreate; - - -/***/ }), -/* 26 */ -/***/ (function(module, exports, __webpack_require__) { - -var isKeyable = __webpack_require__(153); - -/** - * Gets the data for `map`. - * - * @private - * @param {Object} map The map to query. - * @param {string} key The reference key. - * @returns {*} Returns the map data. - */ -function getMapData(map, key) { - var data = map.__data__; - return isKeyable(key) - ? data[typeof key == 'string' ? 'string' : 'hash'] - : data.map; -} - -module.exports = getMapData; - - -/***/ }), -/* 27 */ -/***/ (function(module, exports, __webpack_require__) { - -var isSymbol = __webpack_require__(43); - -/** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0; - -/** - * Converts `value` to a string key if it's not a string or symbol. - * - * @private - * @param {*} value The value to inspect. - * @returns {string|symbol} Returns the key. - */ -function toKey(value) { - if (typeof value == 'string' || isSymbol(value)) { - return value; - } - var result = (value + ''); - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; -} - -module.exports = toKey; - - -/***/ }), -/* 28 */ -/***/ (function(module, exports, __webpack_require__) { - -exports = module.exports = __webpack_require__(45); -exports.Stream = exports; -exports.Readable = exports; -exports.Writable = __webpack_require__(30); -exports.Duplex = __webpack_require__(5); -exports.Transform = __webpack_require__(48); -exports.PassThrough = __webpack_require__(85); - - -/***/ }), -/* 29 */ -/***/ (function(module, exports, __webpack_require__) { - -/* eslint-disable node/no-deprecated-api */ -var buffer = __webpack_require__(7) -var Buffer = buffer.Buffer - -// alternative to using Object.keys for old browsers -function copyProps (src, dst) { - for (var key in src) { - dst[key] = src[key] - } -} -if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { - module.exports = buffer -} else { - // Copy properties from require('buffer') - copyProps(buffer, exports) - exports.Buffer = SafeBuffer -} - -function SafeBuffer (arg, encodingOrOffset, length) { - return Buffer(arg, encodingOrOffset, length) -} - -// Copy static methods from Buffer -copyProps(Buffer, SafeBuffer) - -SafeBuffer.from = function (arg, encodingOrOffset, length) { - if (typeof arg === 'number') { - throw new TypeError('Argument must not be a number') - } - return Buffer(arg, encodingOrOffset, length) -} - -SafeBuffer.alloc = function (size, fill, encoding) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - var buf = Buffer(size) - if (fill !== undefined) { - if (typeof encoding === 'string') { - buf.fill(fill, encoding) - } else { - buf.fill(fill) - } - } else { - buf.fill(0) - } - return buf -} - -SafeBuffer.allocUnsafe = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return Buffer(size) -} - -SafeBuffer.allocUnsafeSlow = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return buffer.SlowBuffer(size) -} - - -/***/ }), -/* 30 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function(process, setImmediate, global) {// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -// A bit simpler than readable streams. -// Implement an async ._write(chunk, encoding, cb), and it'll handle all -// the drain event emission and buffering. - - - -/**/ - -var processNextTick = __webpack_require__(18); -/**/ - -module.exports = Writable; - -/* */ -function WriteReq(chunk, encoding, cb) { - this.chunk = chunk; - this.encoding = encoding; - this.callback = cb; - this.next = null; -} - -// It seems a linked list but it is not -// there will be only 2 of these for each stream -function CorkedRequest(state) { - var _this = this; - - this.next = null; - this.entry = null; - this.finish = function () { - onCorkedFinish(_this, state); - }; -} -/* */ - -/**/ -var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick; -/**/ - -/**/ -var Duplex; -/**/ - -Writable.WritableState = WritableState; - -/**/ -var util = __webpack_require__(11); -util.inherits = __webpack_require__(8); -/**/ - -/**/ -var internalUtil = { - deprecate: __webpack_require__(84) -}; -/**/ - -/**/ -var Stream = __webpack_require__(46); -/**/ - -/**/ -var Buffer = __webpack_require__(29).Buffer; -var OurUint8Array = global.Uint8Array || function () {}; -function _uint8ArrayToBuffer(chunk) { - return Buffer.from(chunk); -} -function _isUint8Array(obj) { - return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; -} -/**/ - -var destroyImpl = __webpack_require__(47); - -util.inherits(Writable, Stream); - -function nop() {} - -function WritableState(options, stream) { - Duplex = Duplex || __webpack_require__(5); - - options = options || {}; - - // object stream flag to indicate whether or not this stream - // contains buffers or objects. - this.objectMode = !!options.objectMode; - - if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode; - - // the point at which write() starts returning false - // Note: 0 is a valid value, means that we always return false if - // the entire buffer is not flushed immediately on write() - var hwm = options.highWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; - this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; - - // cast to ints. - this.highWaterMark = Math.floor(this.highWaterMark); - - // if _final has been called - this.finalCalled = false; - - // drain event flag. - this.needDrain = false; - // at the start of calling end() - this.ending = false; - // when end() has been called, and returned - this.ended = false; - // when 'finish' is emitted - this.finished = false; - - // has it been destroyed - this.destroyed = false; - - // should we decode strings into buffers before passing to _write? - // this is here so that some node-core streams can optimize string - // handling at a lower level. - var noDecode = options.decodeStrings === false; - this.decodeStrings = !noDecode; - - // Crypto is kind of old and crusty. Historically, its default string - // encoding is 'binary' so we have to make this configurable. - // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = options.defaultEncoding || 'utf8'; - - // not an actual buffer we keep track of, but a measurement - // of how much we're waiting to get pushed to some underlying - // socket or file. - this.length = 0; - - // a flag to see when we're in the middle of a write. - this.writing = false; - - // when true all writes will be buffered until .uncork() call - this.corked = 0; - - // a flag to be able to tell if the onwrite cb is called immediately, - // or on a later tick. We set this to true at first, because any - // actions that shouldn't happen until "later" should generally also - // not happen before the first write call. - this.sync = true; - - // a flag to know if we're processing previously buffered items, which - // may call the _write() callback in the same tick, so that we don't - // end up in an overlapped onwrite situation. - this.bufferProcessing = false; - - // the callback that's passed to _write(chunk,cb) - this.onwrite = function (er) { - onwrite(stream, er); - }; - - // the callback that the user supplies to write(chunk,encoding,cb) - this.writecb = null; - - // the amount that is being written when _write is called. - this.writelen = 0; - - this.bufferedRequest = null; - this.lastBufferedRequest = null; - - // number of pending user-supplied write callbacks - // this must be 0 before 'finish' can be emitted - this.pendingcb = 0; - - // emit prefinish if the only thing we're waiting for is _write cbs - // This is relevant for synchronous Transform streams - this.prefinished = false; - - // True if the error was already emitted and should not be thrown again - this.errorEmitted = false; - - // count buffered requests - this.bufferedRequestCount = 0; - - // allocate the first CorkedRequest, there is always - // one allocated and free to use, and we maintain at most two - this.corkedRequestsFree = new CorkedRequest(this); -} - -WritableState.prototype.getBuffer = function getBuffer() { - var current = this.bufferedRequest; - var out = []; - while (current) { - out.push(current); - current = current.next; - } - return out; -}; - -(function () { - try { - Object.defineProperty(WritableState.prototype, 'buffer', { - get: internalUtil.deprecate(function () { - return this.getBuffer(); - }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') - }); - } catch (_) {} -})(); - -// Test _writableState for inheritance to account for Duplex streams, -// whose prototype chain only points to Readable. -var realHasInstance; -if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { - realHasInstance = Function.prototype[Symbol.hasInstance]; - Object.defineProperty(Writable, Symbol.hasInstance, { - value: function (object) { - if (realHasInstance.call(this, object)) return true; - - return object && object._writableState instanceof WritableState; - } - }); -} else { - realHasInstance = function (object) { - return object instanceof this; - }; -} - -function Writable(options) { - Duplex = Duplex || __webpack_require__(5); - - // Writable ctor is applied to Duplexes, too. - // `realHasInstance` is necessary because using plain `instanceof` - // would return false, as no `_writableState` property is attached. - - // Trying to use the custom `instanceof` for Writable here will also break the - // Node.js LazyTransform implementation, which has a non-trivial getter for - // `_writableState` that would lead to infinite recursion. - if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { - return new Writable(options); - } - - this._writableState = new WritableState(options, this); - - // legacy. - this.writable = true; - - if (options) { - if (typeof options.write === 'function') this._write = options.write; - - if (typeof options.writev === 'function') this._writev = options.writev; - - if (typeof options.destroy === 'function') this._destroy = options.destroy; - - if (typeof options.final === 'function') this._final = options.final; - } - - Stream.call(this); -} - -// Otherwise people can pipe Writable streams, which is just wrong. -Writable.prototype.pipe = function () { - this.emit('error', new Error('Cannot pipe, not readable')); -}; - -function writeAfterEnd(stream, cb) { - var er = new Error('write after end'); - // TODO: defer error events consistently everywhere, not just the cb - stream.emit('error', er); - processNextTick(cb, er); -} - -// Checks that a user-supplied chunk is valid, especially for the particular -// mode the stream is in. Currently this means that `null` is never accepted -// and undefined/non-string values are only allowed in object mode. -function validChunk(stream, state, chunk, cb) { - var valid = true; - var er = false; - - if (chunk === null) { - er = new TypeError('May not write null values to stream'); - } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); - } - if (er) { - stream.emit('error', er); - processNextTick(cb, er); - valid = false; - } - return valid; -} - -Writable.prototype.write = function (chunk, encoding, cb) { - var state = this._writableState; - var ret = false; - var isBuf = _isUint8Array(chunk) && !state.objectMode; - - if (isBuf && !Buffer.isBuffer(chunk)) { - chunk = _uint8ArrayToBuffer(chunk); - } - - if (typeof encoding === 'function') { - cb = encoding; - encoding = null; - } - - if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; - - if (typeof cb !== 'function') cb = nop; - - if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { - state.pendingcb++; - ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); - } - - return ret; -}; - -Writable.prototype.cork = function () { - var state = this._writableState; - - state.corked++; -}; - -Writable.prototype.uncork = function () { - var state = this._writableState; - - if (state.corked) { - state.corked--; - - if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); - } -}; - -Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { - // node::ParseEncoding() requires lower case. - if (typeof encoding === 'string') encoding = encoding.toLowerCase(); - if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); - this._writableState.defaultEncoding = encoding; - return this; -}; - -function decodeChunk(state, chunk, encoding) { - if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { - chunk = Buffer.from(chunk, encoding); - } - return chunk; -} - -// if we're already writing something, then just put this -// in the queue, and wait our turn. Otherwise, call _write -// If we return false, then we need a drain event, so set that flag. -function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { - if (!isBuf) { - var newChunk = decodeChunk(state, chunk, encoding); - if (chunk !== newChunk) { - isBuf = true; - encoding = 'buffer'; - chunk = newChunk; - } - } - var len = state.objectMode ? 1 : chunk.length; - - state.length += len; - - var ret = state.length < state.highWaterMark; - // we must ensure that previous needDrain will not be reset to false. - if (!ret) state.needDrain = true; - - if (state.writing || state.corked) { - var last = state.lastBufferedRequest; - state.lastBufferedRequest = { - chunk: chunk, - encoding: encoding, - isBuf: isBuf, - callback: cb, - next: null - }; - if (last) { - last.next = state.lastBufferedRequest; - } else { - state.bufferedRequest = state.lastBufferedRequest; - } - state.bufferedRequestCount += 1; - } else { - doWrite(stream, state, false, len, chunk, encoding, cb); - } - - return ret; -} - -function doWrite(stream, state, writev, len, chunk, encoding, cb) { - state.writelen = len; - state.writecb = cb; - state.writing = true; - state.sync = true; - if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); - state.sync = false; -} - -function onwriteError(stream, state, sync, er, cb) { - --state.pendingcb; - - if (sync) { - // defer the callback if we are being called synchronously - // to avoid piling up things on the stack - processNextTick(cb, er); - // this can emit finish, and it will always happen - // after error - processNextTick(finishMaybe, stream, state); - stream._writableState.errorEmitted = true; - stream.emit('error', er); - } else { - // the caller expect this to happen before if - // it is async - cb(er); - stream._writableState.errorEmitted = true; - stream.emit('error', er); - // this can emit finish, but finish must - // always follow error - finishMaybe(stream, state); - } -} - -function onwriteStateUpdate(state) { - state.writing = false; - state.writecb = null; - state.length -= state.writelen; - state.writelen = 0; -} - -function onwrite(stream, er) { - var state = stream._writableState; - var sync = state.sync; - var cb = state.writecb; - - onwriteStateUpdate(state); - - if (er) onwriteError(stream, state, sync, er, cb);else { - // Check if we're actually ready to finish, but don't emit yet - var finished = needFinish(state); - - if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { - clearBuffer(stream, state); - } - - if (sync) { - /**/ - asyncWrite(afterWrite, stream, state, finished, cb); - /**/ - } else { - afterWrite(stream, state, finished, cb); - } - } -} - -function afterWrite(stream, state, finished, cb) { - if (!finished) onwriteDrain(stream, state); - state.pendingcb--; - cb(); - finishMaybe(stream, state); -} - -// Must force callback to be called on nextTick, so that we don't -// emit 'drain' before the write() consumer gets the 'false' return -// value, and has a chance to attach a 'drain' listener. -function onwriteDrain(stream, state) { - if (state.length === 0 && state.needDrain) { - state.needDrain = false; - stream.emit('drain'); - } -} - -// if there's something in the buffer waiting, then process it -function clearBuffer(stream, state) { - state.bufferProcessing = true; - var entry = state.bufferedRequest; - - if (stream._writev && entry && entry.next) { - // Fast case, write everything using _writev() - var l = state.bufferedRequestCount; - var buffer = new Array(l); - var holder = state.corkedRequestsFree; - holder.entry = entry; - - var count = 0; - var allBuffers = true; - while (entry) { - buffer[count] = entry; - if (!entry.isBuf) allBuffers = false; - entry = entry.next; - count += 1; - } - buffer.allBuffers = allBuffers; - - doWrite(stream, state, true, state.length, buffer, '', holder.finish); - - // doWrite is almost always async, defer these to save a bit of time - // as the hot path ends with doWrite - state.pendingcb++; - state.lastBufferedRequest = null; - if (holder.next) { - state.corkedRequestsFree = holder.next; - holder.next = null; - } else { - state.corkedRequestsFree = new CorkedRequest(state); - } - } else { - // Slow case, write chunks one-by-one - while (entry) { - var chunk = entry.chunk; - var encoding = entry.encoding; - var cb = entry.callback; - var len = state.objectMode ? 1 : chunk.length; - - doWrite(stream, state, false, len, chunk, encoding, cb); - entry = entry.next; - // if we didn't call the onwrite immediately, then - // it means that we need to wait until it does. - // also, that means that the chunk and cb are currently - // being processed, so move the buffer counter past them. - if (state.writing) { - break; - } - } - - if (entry === null) state.lastBufferedRequest = null; - } - - state.bufferedRequestCount = 0; - state.bufferedRequest = entry; - state.bufferProcessing = false; -} - -Writable.prototype._write = function (chunk, encoding, cb) { - cb(new Error('_write() is not implemented')); -}; - -Writable.prototype._writev = null; - -Writable.prototype.end = function (chunk, encoding, cb) { - var state = this._writableState; - - if (typeof chunk === 'function') { - cb = chunk; - chunk = null; - encoding = null; - } else if (typeof encoding === 'function') { - cb = encoding; - encoding = null; - } - - if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); - - // .end() fully uncorks - if (state.corked) { - state.corked = 1; - this.uncork(); - } - - // ignore unnecessary end() calls. - if (!state.ending && !state.finished) endWritable(this, state, cb); -}; - -function needFinish(state) { - return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; -} -function callFinal(stream, state) { - stream._final(function (err) { - state.pendingcb--; - if (err) { - stream.emit('error', err); - } - state.prefinished = true; - stream.emit('prefinish'); - finishMaybe(stream, state); - }); -} -function prefinish(stream, state) { - if (!state.prefinished && !state.finalCalled) { - if (typeof stream._final === 'function') { - state.pendingcb++; - state.finalCalled = true; - processNextTick(callFinal, stream, state); - } else { - state.prefinished = true; - stream.emit('prefinish'); - } - } -} - -function finishMaybe(stream, state) { - var need = needFinish(state); - if (need) { - prefinish(stream, state); - if (state.pendingcb === 0) { - state.finished = true; - stream.emit('finish'); - } - } - return need; -} - -function endWritable(stream, state, cb) { - state.ending = true; - finishMaybe(stream, state); - if (cb) { - if (state.finished) processNextTick(cb);else stream.once('finish', cb); - } - state.ended = true; - stream.writable = false; -} - -function onCorkedFinish(corkReq, state, err) { - var entry = corkReq.entry; - corkReq.entry = null; - while (entry) { - var cb = entry.callback; - state.pendingcb--; - cb(err); - entry = entry.next; - } - if (state.corkedRequestsFree) { - state.corkedRequestsFree.next = corkReq; - } else { - state.corkedRequestsFree = corkReq; - } -} - -Object.defineProperty(Writable.prototype, 'destroyed', { - get: function () { - if (this._writableState === undefined) { - return false; - } - return this._writableState.destroyed; - }, - set: function (value) { - // we ignore the value if the stream - // has not been initialized yet - if (!this._writableState) { - return; - } - - // backward compatibility, the user is explicitly - // managing destroyed - this._writableState.destroyed = value; - } -}); - -Writable.prototype.destroy = destroyImpl.destroy; -Writable.prototype._undestroy = destroyImpl.undestroy; -Writable.prototype._destroy = function (err, cb) { - this.end(); - cb(err); -}; -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9), __webpack_require__(19).setImmediate, __webpack_require__(3))) - -/***/ }), -/* 31 */ -/***/ (function(module, exports, __webpack_require__) { - -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -var Buffer = __webpack_require__(7).Buffer; - -var isBufferEncoding = Buffer.isEncoding - || function(encoding) { - switch (encoding && encoding.toLowerCase()) { - case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true; - default: return false; - } - } - - -function assertEncoding(encoding) { - if (encoding && !isBufferEncoding(encoding)) { - throw new Error('Unknown encoding: ' + encoding); - } -} - -// StringDecoder provides an interface for efficiently splitting a series of -// buffers into a series of JS strings without breaking apart multi-byte -// characters. CESU-8 is handled as part of the UTF-8 encoding. -// -// @TODO Handling all encodings inside a single object makes it very difficult -// to reason about this code, so it should be split up in the future. -// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code -// points as used by CESU-8. -var StringDecoder = exports.StringDecoder = function(encoding) { - this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); - assertEncoding(encoding); - switch (this.encoding) { - case 'utf8': - // CESU-8 represents each of Surrogate Pair by 3-bytes - this.surrogateSize = 3; - break; - case 'ucs2': - case 'utf16le': - // UTF-16 represents each of Surrogate Pair by 2-bytes - this.surrogateSize = 2; - this.detectIncompleteChar = utf16DetectIncompleteChar; - break; - case 'base64': - // Base-64 stores 3 bytes in 4 chars, and pads the remainder. - this.surrogateSize = 3; - this.detectIncompleteChar = base64DetectIncompleteChar; - break; - default: - this.write = passThroughWrite; - return; - } - - // Enough space to store all bytes of a single character. UTF-8 needs 4 - // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). - this.charBuffer = new Buffer(6); - // Number of bytes received for the current incomplete multi-byte character. - this.charReceived = 0; - // Number of bytes expected for the current incomplete multi-byte character. - this.charLength = 0; -}; - - -// write decodes the given buffer and returns it as JS string that is -// guaranteed to not contain any partial multi-byte characters. Any partial -// character found at the end of the buffer is buffered up, and will be -// returned when calling write again with the remaining bytes. -// -// Note: Converting a Buffer containing an orphan surrogate to a String -// currently works, but converting a String to a Buffer (via `new Buffer`, or -// Buffer#write) will replace incomplete surrogates with the unicode -// replacement character. See https://codereview.chromium.org/121173009/ . -StringDecoder.prototype.write = function(buffer) { - var charStr = ''; - // if our last write ended with an incomplete multibyte character - while (this.charLength) { - // determine how many remaining bytes this buffer has to offer for this char - var available = (buffer.length >= this.charLength - this.charReceived) ? - this.charLength - this.charReceived : - buffer.length; - - // add the new bytes to the char buffer - buffer.copy(this.charBuffer, this.charReceived, 0, available); - this.charReceived += available; - - if (this.charReceived < this.charLength) { - // still not enough chars in this buffer? wait for more ... - return ''; - } - - // remove bytes belonging to the current character from the buffer - buffer = buffer.slice(available, buffer.length); - - // get the character that was split - charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); - - // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character - var charCode = charStr.charCodeAt(charStr.length - 1); - if (charCode >= 0xD800 && charCode <= 0xDBFF) { - this.charLength += this.surrogateSize; - charStr = ''; - continue; - } - this.charReceived = this.charLength = 0; - - // if there are no more bytes in this buffer, just emit our char - if (buffer.length === 0) { - return charStr; - } - break; - } - - // determine and set charLength / charReceived - this.detectIncompleteChar(buffer); - - var end = buffer.length; - if (this.charLength) { - // buffer the incomplete character bytes we got - buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end); - end -= this.charReceived; - } - - charStr += buffer.toString(this.encoding, 0, end); - - var end = charStr.length - 1; - var charCode = charStr.charCodeAt(end); - // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character - if (charCode >= 0xD800 && charCode <= 0xDBFF) { - var size = this.surrogateSize; - this.charLength += size; - this.charReceived += size; - this.charBuffer.copy(this.charBuffer, size, 0, size); - buffer.copy(this.charBuffer, 0, 0, size); - return charStr.substring(0, end); - } - - // or just emit the charStr - return charStr; -}; - -// detectIncompleteChar determines if there is an incomplete UTF-8 character at -// the end of the given buffer. If so, it sets this.charLength to the byte -// length that character, and sets this.charReceived to the number of bytes -// that are available for this character. -StringDecoder.prototype.detectIncompleteChar = function(buffer) { - // determine how many bytes we have to check at the end of this buffer - var i = (buffer.length >= 3) ? 3 : buffer.length; - - // Figure out if one of the last i bytes of our buffer announces an - // incomplete char. - for (; i > 0; i--) { - var c = buffer[buffer.length - i]; - - // See http://en.wikipedia.org/wiki/UTF-8#Description - - // 110XXXXX - if (i == 1 && c >> 5 == 0x06) { - this.charLength = 2; - break; - } - - // 1110XXXX - if (i <= 2 && c >> 4 == 0x0E) { - this.charLength = 3; - break; - } - - // 11110XXX - if (i <= 3 && c >> 3 == 0x1E) { - this.charLength = 4; - break; - } - } - this.charReceived = i; -}; - -StringDecoder.prototype.end = function(buffer) { - var res = ''; - if (buffer && buffer.length) - res = this.write(buffer); - - if (this.charReceived) { - var cr = this.charReceived; - var buf = this.charBuffer; - var enc = this.encoding; - res += buf.slice(0, cr).toString(enc); - } - - return res; -}; - -function passThroughWrite(buffer) { - return buffer.toString(this.encoding); -} - -function utf16DetectIncompleteChar(buffer) { - this.charReceived = buffer.length % 2; - this.charLength = this.charReceived ? 2 : 0; -} - -function base64DetectIncompleteChar(buffer) { - this.charReceived = buffer.length % 3; - this.charLength = this.charReceived ? 3 : 0; -} - - -/***/ }), -/* 32 */ -/***/ (function(module, exports) { - -/** - * This method returns the first argument it receives. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Util - * @param {*} value Any value. - * @returns {*} Returns `value`. - * @example - * - * var object = { 'a': 1 }; - * - * console.log(_.identity(object) === object); - * // => true - */ -function identity(value) { - return value; -} - -module.exports = identity; - - -/***/ }), -/* 33 */ -/***/ (function(module, exports) { - -/** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER = 9007199254740991; - -/** - * Checks if `value` is a valid array-like length. - * - * **Note:** This method is loosely based on - * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - * @example - * - * _.isLength(3); - * // => true - * - * _.isLength(Number.MIN_VALUE); - * // => false - * - * _.isLength(Infinity); - * // => false - * - * _.isLength('3'); - * // => false - */ -function isLength(value) { - return typeof value == 'number' && - value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; -} - -module.exports = isLength; - - -/***/ }), -/* 34 */ -/***/ (function(module, exports) { - -/** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER = 9007199254740991; - -/** Used to detect unsigned integer values. */ -var reIsUint = /^(?:0|[1-9]\d*)$/; - -/** - * Checks if `value` is a valid array-like index. - * - * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ -function isIndex(value, length) { - length = length == null ? MAX_SAFE_INTEGER : length; - return !!length && - (typeof value == 'number' || reIsUint.test(value)) && - (value > -1 && value % 1 == 0 && value < length); -} - -module.exports = isIndex; - - -/***/ }), -/* 35 */ -/***/ (function(module, exports) { - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** - * Checks if `value` is likely a prototype object. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. - */ -function isPrototype(value) { - var Ctor = value && value.constructor, - proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; - - return value === proto; -} - -module.exports = isPrototype; - - -/***/ }), -/* 36 */ -/***/ (function(module, exports, __webpack_require__) { - -var baseIsArguments = __webpack_require__(108), - isObjectLike = __webpack_require__(15); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** Built-in value references. */ -var propertyIsEnumerable = objectProto.propertyIsEnumerable; - -/** - * Checks if `value` is likely an `arguments` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an `arguments` object, - * else `false`. - * @example - * - * _.isArguments(function() { return arguments; }()); - * // => true - * - * _.isArguments([1, 2, 3]); - * // => false - */ -var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { - return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && - !propertyIsEnumerable.call(value, 'callee'); -}; - -module.exports = isArguments; - - -/***/ }), -/* 37 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(module) {var root = __webpack_require__(4), - stubFalse = __webpack_require__(109); - -/** Detect free variable `exports`. */ -var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; - -/** Detect free variable `module`. */ -var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; - -/** Detect the popular CommonJS extension `module.exports`. */ -var moduleExports = freeModule && freeModule.exports === freeExports; - -/** Built-in value references. */ -var Buffer = moduleExports ? root.Buffer : undefined; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; - -/** - * Checks if `value` is a buffer. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. - * @example - * - * _.isBuffer(new Buffer(2)); - * // => true - * - * _.isBuffer(new Uint8Array(2)); - * // => false - */ -var isBuffer = nativeIsBuffer || stubFalse; - -module.exports = isBuffer; - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(38)(module))) - -/***/ }), -/* 38 */ -/***/ (function(module, exports) { - -module.exports = function(module) { - if(!module.webpackPolyfill) { - module.deprecate = function() {}; - module.paths = []; - // module.parent = undefined by default - if(!module.children) module.children = []; - Object.defineProperty(module, "loaded", { - enumerable: true, - get: function() { - return module.l; - } - }); - Object.defineProperty(module, "id", { - enumerable: true, - get: function() { - return module.i; - } - }); - module.webpackPolyfill = 1; - } - return module; -}; - - -/***/ }), -/* 39 */ -/***/ (function(module, exports, __webpack_require__) { - -var baseIsTypedArray = __webpack_require__(110), - baseUnary = __webpack_require__(111), - nodeUtil = __webpack_require__(112); - -/* Node.js helper references. */ -var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; - -/** - * Checks if `value` is classified as a typed array. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. - * @example - * - * _.isTypedArray(new Uint8Array); - * // => true - * - * _.isTypedArray([]); - * // => false - */ -var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; - -module.exports = isTypedArray; - - -/***/ }), -/* 40 */ -/***/ (function(module, exports, __webpack_require__) { - -var getNative = __webpack_require__(6), - root = __webpack_require__(4); - -/* Built-in method references that are verified to be native. */ -var Map = getNative(root, 'Map'); - -module.exports = Map; - - -/***/ }), -/* 41 */ -/***/ (function(module, exports, __webpack_require__) { - -var mapCacheClear = __webpack_require__(145), - mapCacheDelete = __webpack_require__(152), - mapCacheGet = __webpack_require__(154), - mapCacheHas = __webpack_require__(155), - mapCacheSet = __webpack_require__(156); - -/** - * Creates a map cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function MapCache(entries) { - var index = -1, - length = entries == null ? 0 : entries.length; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } -} - -// Add methods to `MapCache`. -MapCache.prototype.clear = mapCacheClear; -MapCache.prototype['delete'] = mapCacheDelete; -MapCache.prototype.get = mapCacheGet; -MapCache.prototype.has = mapCacheHas; -MapCache.prototype.set = mapCacheSet; - -module.exports = MapCache; - - -/***/ }), -/* 42 */ -/***/ (function(module, exports, __webpack_require__) { - -var isArray = __webpack_require__(2), - isSymbol = __webpack_require__(43); - -/** Used to match property names within property paths. */ -var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, - reIsPlainProp = /^\w*$/; - -/** - * Checks if `value` is a property name and not a property path. - * - * @private - * @param {*} value The value to check. - * @param {Object} [object] The object to query keys on. - * @returns {boolean} Returns `true` if `value` is a property name, else `false`. - */ -function isKey(value, object) { - if (isArray(value)) { - return false; - } - var type = typeof value; - if (type == 'number' || type == 'symbol' || type == 'boolean' || - value == null || isSymbol(value)) { - return true; - } - return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || - (object != null && value in Object(object)); -} - -module.exports = isKey; - - -/***/ }), -/* 43 */ -/***/ (function(module, exports, __webpack_require__) { - -var baseGetTag = __webpack_require__(12), - isObjectLike = __webpack_require__(15); - -/** `Object#toString` result references. */ -var symbolTag = '[object Symbol]'; - -/** - * Checks if `value` is classified as a `Symbol` primitive or object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. - * @example - * - * _.isSymbol(Symbol.iterator); - * // => true - * - * _.isSymbol('abc'); - * // => false - */ -function isSymbol(value) { - return typeof value == 'symbol' || - (isObjectLike(value) && baseGetTag(value) == symbolTag); -} - -module.exports = isSymbol; - - -/***/ }), -/* 44 */ -/***/ (function(module, exports) { - -var toString = {}.toString; - -module.exports = Array.isArray || function (arr) { - return toString.call(arr) == '[object Array]'; -}; - - -/***/ }), -/* 45 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - - - -/**/ - -var processNextTick = __webpack_require__(18); -/**/ - -module.exports = Readable; - -/**/ -var isArray = __webpack_require__(44); -/**/ - -/**/ -var Duplex; -/**/ - -Readable.ReadableState = ReadableState; - -/**/ -var EE = __webpack_require__(17).EventEmitter; - -var EElistenerCount = function (emitter, type) { - return emitter.listeners(type).length; -}; -/**/ - -/**/ -var Stream = __webpack_require__(46); -/**/ - -// TODO(bmeurer): Change this back to const once hole checks are -// properly optimized away early in Ignition+TurboFan. -/**/ -var Buffer = __webpack_require__(29).Buffer; -var OurUint8Array = global.Uint8Array || function () {}; -function _uint8ArrayToBuffer(chunk) { - return Buffer.from(chunk); -} -function _isUint8Array(obj) { - return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; -} -/**/ - -/**/ -var util = __webpack_require__(11); -util.inherits = __webpack_require__(8); -/**/ - -/**/ -var debugUtil = __webpack_require__(81); -var debug = void 0; -if (debugUtil && debugUtil.debuglog) { - debug = debugUtil.debuglog('stream'); -} else { - debug = function () {}; -} -/**/ - -var BufferList = __webpack_require__(82); -var destroyImpl = __webpack_require__(47); -var StringDecoder; - -util.inherits(Readable, Stream); - -var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; - -function prependListener(emitter, event, fn) { - // Sadly this is not cacheable as some libraries bundle their own - // event emitter implementation with them. - if (typeof emitter.prependListener === 'function') { - return emitter.prependListener(event, fn); - } else { - // This is a hack to make sure that our error handler is attached before any - // userland ones. NEVER DO THIS. This is here only because this code needs - // to continue to work with older versions of Node.js that do not include - // the prependListener() method. The goal is to eventually remove this hack. - if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; - } -} - -function ReadableState(options, stream) { - Duplex = Duplex || __webpack_require__(5); - - options = options || {}; - - // object stream flag. Used to make read(n) ignore n and to - // make all the buffer merging and length checks go away - this.objectMode = !!options.objectMode; - - if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode; - - // the point at which it stops calling _read() to fill the buffer - // Note: 0 is a valid value, means "don't call _read preemptively ever" - var hwm = options.highWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; - this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; - - // cast to ints. - this.highWaterMark = Math.floor(this.highWaterMark); - - // A linked list is used to store data chunks instead of an array because the - // linked list can remove elements from the beginning faster than - // array.shift() - this.buffer = new BufferList(); - this.length = 0; - this.pipes = null; - this.pipesCount = 0; - this.flowing = null; - this.ended = false; - this.endEmitted = false; - this.reading = false; - - // a flag to be able to tell if the event 'readable'/'data' is emitted - // immediately, or on a later tick. We set this to true at first, because - // any actions that shouldn't happen until "later" should generally also - // not happen before the first read call. - this.sync = true; - - // whenever we return null, then we set a flag to say - // that we're awaiting a 'readable' event emission. - this.needReadable = false; - this.emittedReadable = false; - this.readableListening = false; - this.resumeScheduled = false; - - // has it been destroyed - this.destroyed = false; - - // Crypto is kind of old and crusty. Historically, its default string - // encoding is 'binary' so we have to make this configurable. - // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = options.defaultEncoding || 'utf8'; - - // the number of writers that are awaiting a drain event in .pipe()s - this.awaitDrain = 0; - - // if true, a maybeReadMore has been scheduled - this.readingMore = false; - - this.decoder = null; - this.encoding = null; - if (options.encoding) { - if (!StringDecoder) StringDecoder = __webpack_require__(31).StringDecoder; - this.decoder = new StringDecoder(options.encoding); - this.encoding = options.encoding; - } -} - -function Readable(options) { - Duplex = Duplex || __webpack_require__(5); - - if (!(this instanceof Readable)) return new Readable(options); - - this._readableState = new ReadableState(options, this); - - // legacy - this.readable = true; - - if (options) { - if (typeof options.read === 'function') this._read = options.read; - - if (typeof options.destroy === 'function') this._destroy = options.destroy; - } - - Stream.call(this); -} - -Object.defineProperty(Readable.prototype, 'destroyed', { - get: function () { - if (this._readableState === undefined) { - return false; - } - return this._readableState.destroyed; - }, - set: function (value) { - // we ignore the value if the stream - // has not been initialized yet - if (!this._readableState) { - return; - } - - // backward compatibility, the user is explicitly - // managing destroyed - this._readableState.destroyed = value; - } -}); - -Readable.prototype.destroy = destroyImpl.destroy; -Readable.prototype._undestroy = destroyImpl.undestroy; -Readable.prototype._destroy = function (err, cb) { - this.push(null); - cb(err); -}; - -// Manually shove something into the read() buffer. -// This returns true if the highWaterMark has not been hit yet, -// similar to how Writable.write() returns true if you should -// write() some more. -Readable.prototype.push = function (chunk, encoding) { - var state = this._readableState; - var skipChunkCheck; - - if (!state.objectMode) { - if (typeof chunk === 'string') { - encoding = encoding || state.defaultEncoding; - if (encoding !== state.encoding) { - chunk = Buffer.from(chunk, encoding); - encoding = ''; - } - skipChunkCheck = true; - } - } else { - skipChunkCheck = true; - } - - return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); -}; - -// Unshift should *always* be something directly out of read() -Readable.prototype.unshift = function (chunk) { - return readableAddChunk(this, chunk, null, true, false); -}; - -function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { - var state = stream._readableState; - if (chunk === null) { - state.reading = false; - onEofChunk(stream, state); - } else { - var er; - if (!skipChunkCheck) er = chunkInvalid(state, chunk); - if (er) { - stream.emit('error', er); - } else if (state.objectMode || chunk && chunk.length > 0) { - if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { - chunk = _uint8ArrayToBuffer(chunk); - } - - if (addToFront) { - if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); - } else if (state.ended) { - stream.emit('error', new Error('stream.push() after EOF')); - } else { - state.reading = false; - if (state.decoder && !encoding) { - chunk = state.decoder.write(chunk); - if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); - } else { - addChunk(stream, state, chunk, false); - } - } - } else if (!addToFront) { - state.reading = false; - } - } - - return needMoreData(state); -} - -function addChunk(stream, state, chunk, addToFront) { - if (state.flowing && state.length === 0 && !state.sync) { - stream.emit('data', chunk); - stream.read(0); - } else { - // update the buffer info. - state.length += state.objectMode ? 1 : chunk.length; - if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); - - if (state.needReadable) emitReadable(stream); - } - maybeReadMore(stream, state); -} - -function chunkInvalid(state, chunk) { - var er; - if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); - } - return er; -} - -// if it's past the high water mark, we can push in some more. -// Also, if we have no data yet, we can stand some -// more bytes. This is to work around cases where hwm=0, -// such as the repl. Also, if the push() triggered a -// readable event, and the user called read(largeNumber) such that -// needReadable was set, then we ought to push more, so that another -// 'readable' event will be triggered. -function needMoreData(state) { - return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); -} - -Readable.prototype.isPaused = function () { - return this._readableState.flowing === false; -}; - -// backwards compatibility. -Readable.prototype.setEncoding = function (enc) { - if (!StringDecoder) StringDecoder = __webpack_require__(31).StringDecoder; - this._readableState.decoder = new StringDecoder(enc); - this._readableState.encoding = enc; - return this; -}; - -// Don't raise the hwm > 8MB -var MAX_HWM = 0x800000; -function computeNewHighWaterMark(n) { - if (n >= MAX_HWM) { - n = MAX_HWM; - } else { - // Get the next highest power of 2 to prevent increasing hwm excessively in - // tiny amounts - n--; - n |= n >>> 1; - n |= n >>> 2; - n |= n >>> 4; - n |= n >>> 8; - n |= n >>> 16; - n++; - } - return n; -} - -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function howMuchToRead(n, state) { - if (n <= 0 || state.length === 0 && state.ended) return 0; - if (state.objectMode) return 1; - if (n !== n) { - // Only flow one buffer at a time - if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; - } - // If we're asking for more than the current hwm, then raise the hwm. - if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); - if (n <= state.length) return n; - // Don't have enough - if (!state.ended) { - state.needReadable = true; - return 0; - } - return state.length; -} - -// you can override either this method, or the async _read(n) below. -Readable.prototype.read = function (n) { - debug('read', n); - n = parseInt(n, 10); - var state = this._readableState; - var nOrig = n; - - if (n !== 0) state.emittedReadable = false; - - // if we're doing read(0) to trigger a readable event, but we - // already have a bunch of data in the buffer, then just trigger - // the 'readable' event and move on. - if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { - debug('read: emitReadable', state.length, state.ended); - if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); - return null; - } - - n = howMuchToRead(n, state); - - // if we've ended, and we're now clear, then finish it up. - if (n === 0 && state.ended) { - if (state.length === 0) endReadable(this); - return null; - } - - // All the actual chunk generation logic needs to be - // *below* the call to _read. The reason is that in certain - // synthetic stream cases, such as passthrough streams, _read - // may be a completely synchronous operation which may change - // the state of the read buffer, providing enough data when - // before there was *not* enough. - // - // So, the steps are: - // 1. Figure out what the state of things will be after we do - // a read from the buffer. - // - // 2. If that resulting state will trigger a _read, then call _read. - // Note that this may be asynchronous, or synchronous. Yes, it is - // deeply ugly to write APIs this way, but that still doesn't mean - // that the Readable class should behave improperly, as streams are - // designed to be sync/async agnostic. - // Take note if the _read call is sync or async (ie, if the read call - // has returned yet), so that we know whether or not it's safe to emit - // 'readable' etc. - // - // 3. Actually pull the requested chunks out of the buffer and return. - - // if we need a readable event, then we need to do some reading. - var doRead = state.needReadable; - debug('need readable', doRead); - - // if we currently have less than the highWaterMark, then also read some - if (state.length === 0 || state.length - n < state.highWaterMark) { - doRead = true; - debug('length less than watermark', doRead); - } - - // however, if we've ended, then there's no point, and if we're already - // reading, then it's unnecessary. - if (state.ended || state.reading) { - doRead = false; - debug('reading or ended', doRead); - } else if (doRead) { - debug('do read'); - state.reading = true; - state.sync = true; - // if the length is currently zero, then we *need* a readable event. - if (state.length === 0) state.needReadable = true; - // call internal read method - this._read(state.highWaterMark); - state.sync = false; - // If _read pushed data synchronously, then `reading` will be false, - // and we need to re-evaluate how much data we can return to the user. - if (!state.reading) n = howMuchToRead(nOrig, state); - } - - var ret; - if (n > 0) ret = fromList(n, state);else ret = null; - - if (ret === null) { - state.needReadable = true; - n = 0; - } else { - state.length -= n; - } - - if (state.length === 0) { - // If we have nothing in the buffer, then we want to know - // as soon as we *do* get something into the buffer. - if (!state.ended) state.needReadable = true; - - // If we tried to read() past the EOF, then emit end on the next tick. - if (nOrig !== n && state.ended) endReadable(this); - } - - if (ret !== null) this.emit('data', ret); - - return ret; -}; - -function onEofChunk(stream, state) { - if (state.ended) return; - if (state.decoder) { - var chunk = state.decoder.end(); - if (chunk && chunk.length) { - state.buffer.push(chunk); - state.length += state.objectMode ? 1 : chunk.length; - } - } - state.ended = true; - - // emit 'readable' now to make sure it gets picked up. - emitReadable(stream); -} - -// Don't emit readable right away in sync mode, because this can trigger -// another read() call => stack overflow. This way, it might trigger -// a nextTick recursion warning, but that's not so bad. -function emitReadable(stream) { - var state = stream._readableState; - state.needReadable = false; - if (!state.emittedReadable) { - debug('emitReadable', state.flowing); - state.emittedReadable = true; - if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream); - } -} - -function emitReadable_(stream) { - debug('emit readable'); - stream.emit('readable'); - flow(stream); -} - -// at this point, the user has presumably seen the 'readable' event, -// and called read() to consume some data. that may have triggered -// in turn another _read(n) call, in which case reading = true if -// it's in progress. -// However, if we're not ended, or reading, and the length < hwm, -// then go ahead and try to read some more preemptively. -function maybeReadMore(stream, state) { - if (!state.readingMore) { - state.readingMore = true; - processNextTick(maybeReadMore_, stream, state); - } -} - -function maybeReadMore_(stream, state) { - var len = state.length; - while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { - debug('maybeReadMore read 0'); - stream.read(0); - if (len === state.length) - // didn't get any data, stop spinning. - break;else len = state.length; - } - state.readingMore = false; -} - -// abstract method. to be overridden in specific implementation classes. -// call cb(er, data) where data is <= n in length. -// for virtual (non-string, non-buffer) streams, "length" is somewhat -// arbitrary, and perhaps not very meaningful. -Readable.prototype._read = function (n) { - this.emit('error', new Error('_read() is not implemented')); -}; - -Readable.prototype.pipe = function (dest, pipeOpts) { - var src = this; - var state = this._readableState; - - switch (state.pipesCount) { - case 0: - state.pipes = dest; - break; - case 1: - state.pipes = [state.pipes, dest]; - break; - default: - state.pipes.push(dest); - break; - } - state.pipesCount += 1; - debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); - - var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; - - var endFn = doEnd ? onend : unpipe; - if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn); - - dest.on('unpipe', onunpipe); - function onunpipe(readable, unpipeInfo) { - debug('onunpipe'); - if (readable === src) { - if (unpipeInfo && unpipeInfo.hasUnpiped === false) { - unpipeInfo.hasUnpiped = true; - cleanup(); - } - } - } - - function onend() { - debug('onend'); - dest.end(); - } - - // when the dest drains, it reduces the awaitDrain counter - // on the source. This would be more elegant with a .once() - // handler in flow(), but adding and removing repeatedly is - // too slow. - var ondrain = pipeOnDrain(src); - dest.on('drain', ondrain); - - var cleanedUp = false; - function cleanup() { - debug('cleanup'); - // cleanup event handlers once the pipe is broken - dest.removeListener('close', onclose); - dest.removeListener('finish', onfinish); - dest.removeListener('drain', ondrain); - dest.removeListener('error', onerror); - dest.removeListener('unpipe', onunpipe); - src.removeListener('end', onend); - src.removeListener('end', unpipe); - src.removeListener('data', ondata); - - cleanedUp = true; - - // if the reader is waiting for a drain event from this - // specific writer, then it would cause it to never start - // flowing again. - // So, if this is awaiting a drain, then we just call it now. - // If we don't know, then assume that we are waiting for one. - if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); - } - - // If the user pushes more data while we're writing to dest then we'll end up - // in ondata again. However, we only want to increase awaitDrain once because - // dest will only emit one 'drain' event for the multiple writes. - // => Introduce a guard on increasing awaitDrain. - var increasedAwaitDrain = false; - src.on('data', ondata); - function ondata(chunk) { - debug('ondata'); - increasedAwaitDrain = false; - var ret = dest.write(chunk); - if (false === ret && !increasedAwaitDrain) { - // If the user unpiped during `dest.write()`, it is possible - // to get stuck in a permanently paused state if that write - // also returned false. - // => Check whether `dest` is still a piping destination. - if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { - debug('false write response, pause', src._readableState.awaitDrain); - src._readableState.awaitDrain++; - increasedAwaitDrain = true; - } - src.pause(); - } - } - - // if the dest has an error, then stop piping into it. - // however, don't suppress the throwing behavior for this. - function onerror(er) { - debug('onerror', er); - unpipe(); - dest.removeListener('error', onerror); - if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); - } - - // Make sure our error handler is attached before userland ones. - prependListener(dest, 'error', onerror); - - // Both close and finish should trigger unpipe, but only once. - function onclose() { - dest.removeListener('finish', onfinish); - unpipe(); - } - dest.once('close', onclose); - function onfinish() { - debug('onfinish'); - dest.removeListener('close', onclose); - unpipe(); - } - dest.once('finish', onfinish); - - function unpipe() { - debug('unpipe'); - src.unpipe(dest); - } - - // tell the dest that it's being piped to - dest.emit('pipe', src); - - // start the flow if it hasn't been started already. - if (!state.flowing) { - debug('pipe resume'); - src.resume(); - } - - return dest; -}; - -function pipeOnDrain(src) { - return function () { - var state = src._readableState; - debug('pipeOnDrain', state.awaitDrain); - if (state.awaitDrain) state.awaitDrain--; - if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { - state.flowing = true; - flow(src); - } - }; -} - -Readable.prototype.unpipe = function (dest) { - var state = this._readableState; - var unpipeInfo = { hasUnpiped: false }; - - // if we're not piping anywhere, then do nothing. - if (state.pipesCount === 0) return this; - - // just one destination. most common case. - if (state.pipesCount === 1) { - // passed in one, but it's not the right one. - if (dest && dest !== state.pipes) return this; - - if (!dest) dest = state.pipes; - - // got a match. - state.pipes = null; - state.pipesCount = 0; - state.flowing = false; - if (dest) dest.emit('unpipe', this, unpipeInfo); - return this; - } - - // slow case. multiple pipe destinations. - - if (!dest) { - // remove all. - var dests = state.pipes; - var len = state.pipesCount; - state.pipes = null; - state.pipesCount = 0; - state.flowing = false; - - for (var i = 0; i < len; i++) { - dests[i].emit('unpipe', this, unpipeInfo); - }return this; - } - - // try to find the right one. - var index = indexOf(state.pipes, dest); - if (index === -1) return this; - - state.pipes.splice(index, 1); - state.pipesCount -= 1; - if (state.pipesCount === 1) state.pipes = state.pipes[0]; - - dest.emit('unpipe', this, unpipeInfo); - - return this; -}; - -// set up data events if they are asked for -// Ensure readable listeners eventually get something -Readable.prototype.on = function (ev, fn) { - var res = Stream.prototype.on.call(this, ev, fn); - - if (ev === 'data') { - // Start flowing on next tick if stream isn't explicitly paused - if (this._readableState.flowing !== false) this.resume(); - } else if (ev === 'readable') { - var state = this._readableState; - if (!state.endEmitted && !state.readableListening) { - state.readableListening = state.needReadable = true; - state.emittedReadable = false; - if (!state.reading) { - processNextTick(nReadingNextTick, this); - } else if (state.length) { - emitReadable(this); - } - } - } - - return res; -}; -Readable.prototype.addListener = Readable.prototype.on; - -function nReadingNextTick(self) { - debug('readable nexttick read 0'); - self.read(0); -} - -// pause() and resume() are remnants of the legacy readable stream API -// If the user uses them, then switch into old mode. -Readable.prototype.resume = function () { - var state = this._readableState; - if (!state.flowing) { - debug('resume'); - state.flowing = true; - resume(this, state); - } - return this; -}; - -function resume(stream, state) { - if (!state.resumeScheduled) { - state.resumeScheduled = true; - processNextTick(resume_, stream, state); - } -} - -function resume_(stream, state) { - if (!state.reading) { - debug('resume read 0'); - stream.read(0); - } - - state.resumeScheduled = false; - state.awaitDrain = 0; - stream.emit('resume'); - flow(stream); - if (state.flowing && !state.reading) stream.read(0); -} - -Readable.prototype.pause = function () { - debug('call pause flowing=%j', this._readableState.flowing); - if (false !== this._readableState.flowing) { - debug('pause'); - this._readableState.flowing = false; - this.emit('pause'); - } - return this; -}; - -function flow(stream) { - var state = stream._readableState; - debug('flow', state.flowing); - while (state.flowing && stream.read() !== null) {} -} - -// wrap an old-style stream as the async data source. -// This is *not* part of the readable stream interface. -// It is an ugly unfortunate mess of history. -Readable.prototype.wrap = function (stream) { - var state = this._readableState; - var paused = false; - - var self = this; - stream.on('end', function () { - debug('wrapped end'); - if (state.decoder && !state.ended) { - var chunk = state.decoder.end(); - if (chunk && chunk.length) self.push(chunk); - } - - self.push(null); - }); - - stream.on('data', function (chunk) { - debug('wrapped data'); - if (state.decoder) chunk = state.decoder.write(chunk); - - // don't skip over falsy values in objectMode - if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; - - var ret = self.push(chunk); - if (!ret) { - paused = true; - stream.pause(); - } - }); - - // proxy all the other methods. - // important when wrapping filters and duplexes. - for (var i in stream) { - if (this[i] === undefined && typeof stream[i] === 'function') { - this[i] = function (method) { - return function () { - return stream[method].apply(stream, arguments); - }; - }(i); - } - } - - // proxy certain important events. - for (var n = 0; n < kProxyEvents.length; n++) { - stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n])); - } - - // when we try to consume some more bytes, simply unpause the - // underlying stream. - self._read = function (n) { - debug('wrapped _read', n); - if (paused) { - paused = false; - stream.resume(); - } - }; - - return self; -}; - -// exposed for testing purposes only. -Readable._fromList = fromList; - -// Pluck off n bytes from an array of buffers. -// Length is the combined lengths of all the buffers in the list. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function fromList(n, state) { - // nothing buffered - if (state.length === 0) return null; - - var ret; - if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { - // read it all, truncate the list - if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); - state.buffer.clear(); - } else { - // read part of list - ret = fromListPartial(n, state.buffer, state.decoder); - } - - return ret; -} - -// Extracts only enough buffered data to satisfy the amount requested. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function fromListPartial(n, list, hasStrings) { - var ret; - if (n < list.head.data.length) { - // slice is the same for buffers and strings - ret = list.head.data.slice(0, n); - list.head.data = list.head.data.slice(n); - } else if (n === list.head.data.length) { - // first chunk is a perfect match - ret = list.shift(); - } else { - // result spans more than one buffer - ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); - } - return ret; -} - -// Copies a specified amount of characters from the list of buffered data -// chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBufferString(n, list) { - var p = list.head; - var c = 1; - var ret = p.data; - n -= ret.length; - while (p = p.next) { - var str = p.data; - var nb = n > str.length ? str.length : n; - if (nb === str.length) ret += str;else ret += str.slice(0, n); - n -= nb; - if (n === 0) { - if (nb === str.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = str.slice(nb); - } - break; - } - ++c; - } - list.length -= c; - return ret; -} - -// Copies a specified amount of bytes from the list of buffered data chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBuffer(n, list) { - var ret = Buffer.allocUnsafe(n); - var p = list.head; - var c = 1; - p.data.copy(ret); - n -= p.data.length; - while (p = p.next) { - var buf = p.data; - var nb = n > buf.length ? buf.length : n; - buf.copy(ret, ret.length - n, 0, nb); - n -= nb; - if (n === 0) { - if (nb === buf.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = buf.slice(nb); - } - break; - } - ++c; - } - list.length -= c; - return ret; -} - -function endReadable(stream) { - var state = stream._readableState; - - // If we get here before consuming all the bytes, then that is a - // bug in node. Should never happen. - if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); - - if (!state.endEmitted) { - state.ended = true; - processNextTick(endReadableNT, state, stream); - } -} - -function endReadableNT(state, stream) { - // Check that we didn't get one last unshift. - if (!state.endEmitted && state.length === 0) { - state.endEmitted = true; - stream.readable = false; - stream.emit('end'); - } -} - -function forEach(xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xs[i], i); - } -} - -function indexOf(xs, x) { - for (var i = 0, l = xs.length; i < l; i++) { - if (xs[i] === x) return i; - } - return -1; -} -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3), __webpack_require__(9))) - -/***/ }), -/* 46 */ -/***/ (function(module, exports, __webpack_require__) { - -module.exports = __webpack_require__(17).EventEmitter; - - -/***/ }), -/* 47 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -/**/ - -var processNextTick = __webpack_require__(18); -/**/ - -// undocumented cb() API, needed for core, not for public API -function destroy(err, cb) { - var _this = this; - - var readableDestroyed = this._readableState && this._readableState.destroyed; - var writableDestroyed = this._writableState && this._writableState.destroyed; - - if (readableDestroyed || writableDestroyed) { - if (cb) { - cb(err); - } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { - processNextTick(emitErrorNT, this, err); - } - return; - } - - // we set destroyed to true before firing error callbacks in order - // to make it re-entrance safe in case destroy() is called within callbacks - - if (this._readableState) { - this._readableState.destroyed = true; - } - - // if this is a duplex stream mark the writable part as destroyed as well - if (this._writableState) { - this._writableState.destroyed = true; - } - - this._destroy(err || null, function (err) { - if (!cb && err) { - processNextTick(emitErrorNT, _this, err); - if (_this._writableState) { - _this._writableState.errorEmitted = true; - } - } else if (cb) { - cb(err); - } - }); -} - -function undestroy() { - if (this._readableState) { - this._readableState.destroyed = false; - this._readableState.reading = false; - this._readableState.ended = false; - this._readableState.endEmitted = false; - } - - if (this._writableState) { - this._writableState.destroyed = false; - this._writableState.ended = false; - this._writableState.ending = false; - this._writableState.finished = false; - this._writableState.errorEmitted = false; - } -} - -function emitErrorNT(self, err) { - self.emit('error', err); -} - -module.exports = { - destroy: destroy, - undestroy: undestroy -}; - -/***/ }), -/* 48 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -// Copyright Joyent, Inc. and other Node contributors. -// -// 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. - -// a transform stream is a readable/writable stream where you do -// something with the data. Sometimes it's called a "filter", -// but that's not a great name for it, since that implies a thing where -// some bits pass through, and others are simply ignored. (That would -// be a valid example of a transform, of course.) -// -// While the output is causally related to the input, it's not a -// necessarily symmetric or synchronous transformation. For example, -// a zlib stream might take multiple plain-text writes(), and then -// emit a single compressed chunk some time in the future. -// -// Here's how this works: -// -// The Transform stream has all the aspects of the readable and writable -// stream classes. When you write(chunk), that calls _write(chunk,cb) -// internally, and returns false if there's a lot of pending writes -// buffered up. When you call read(), that calls _read(n) until -// there's enough pending readable data buffered up. -// -// In a transform stream, the written data is placed in a buffer. When -// _read(n) is called, it transforms the queued up data, calling the -// buffered _write cb's as it consumes chunks. If consuming a single -// written chunk would result in multiple output chunks, then the first -// outputted bit calls the readcb, and subsequent chunks just go into -// the read buffer, and will cause it to emit 'readable' if necessary. -// -// This way, back-pressure is actually determined by the reading side, -// since _read has to be called to start processing a new chunk. However, -// a pathological inflate type of transform can cause excessive buffering -// here. For example, imagine a stream where every byte of input is -// interpreted as an integer from 0-255, and then results in that many -// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in -// 1kb of data being output. In this case, you could write a very small -// amount of input, and end up with a very large amount of output. In -// such a pathological inflating mechanism, there'd be no way to tell -// the system to stop doing the transform. A single 4MB write could -// cause the system to run out of memory. -// -// However, even in such a pathological case, only a single written chunk -// would be consumed, and then the rest would wait (un-transformed) until -// the results of the previous transformed chunk were consumed. - - - -module.exports = Transform; - -var Duplex = __webpack_require__(5); - -/**/ -var util = __webpack_require__(11); -util.inherits = __webpack_require__(8); -/**/ - -util.inherits(Transform, Duplex); - -function TransformState(stream) { - this.afterTransform = function (er, data) { - return afterTransform(stream, er, data); - }; - - this.needTransform = false; - this.transforming = false; - this.writecb = null; - this.writechunk = null; - this.writeencoding = null; -} - -function afterTransform(stream, er, data) { - var ts = stream._transformState; - ts.transforming = false; - - var cb = ts.writecb; - - if (!cb) { - return stream.emit('error', new Error('write callback called multiple times')); - } - - ts.writechunk = null; - ts.writecb = null; - - if (data !== null && data !== undefined) stream.push(data); - - cb(er); - - var rs = stream._readableState; - rs.reading = false; - if (rs.needReadable || rs.length < rs.highWaterMark) { - stream._read(rs.highWaterMark); - } -} - -function Transform(options) { - if (!(this instanceof Transform)) return new Transform(options); - - Duplex.call(this, options); - - this._transformState = new TransformState(this); - - var stream = this; - - // start out asking for a readable event once data is transformed. - this._readableState.needReadable = true; - - // we have implemented the _read method, and done the other things - // that Readable wants before the first _read call, so unset the - // sync guard flag. - this._readableState.sync = false; - - if (options) { - if (typeof options.transform === 'function') this._transform = options.transform; - - if (typeof options.flush === 'function') this._flush = options.flush; - } - - // When the writable side finishes, then flush out anything remaining. - this.once('prefinish', function () { - if (typeof this._flush === 'function') this._flush(function (er, data) { - done(stream, er, data); - });else done(stream); - }); -} - -Transform.prototype.push = function (chunk, encoding) { - this._transformState.needTransform = false; - return Duplex.prototype.push.call(this, chunk, encoding); -}; - -// This is the part where you do stuff! -// override this function in implementation classes. -// 'chunk' is an input chunk. -// -// Call `push(newChunk)` to pass along transformed output -// to the readable side. You may call 'push' zero or more times. -// -// Call `cb(err)` when you are done with this chunk. If you pass -// an error, then that'll put the hurt on the whole operation. If you -// never call cb(), then you'll never get another chunk. -Transform.prototype._transform = function (chunk, encoding, cb) { - throw new Error('_transform() is not implemented'); -}; - -Transform.prototype._write = function (chunk, encoding, cb) { - var ts = this._transformState; - ts.writecb = cb; - ts.writechunk = chunk; - ts.writeencoding = encoding; - if (!ts.transforming) { - var rs = this._readableState; - if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); - } -}; - -// Doesn't matter what the args are here. -// _transform does all the work. -// That we got here means that the readable side wants more data. -Transform.prototype._read = function (n) { - var ts = this._transformState; - - if (ts.writechunk !== null && ts.writecb && !ts.transforming) { - ts.transforming = true; - this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); - } else { - // mark that we need a transform, so that any data that comes in - // will get processed, now that we've asked for it. - ts.needTransform = true; - } -}; - -Transform.prototype._destroy = function (err, cb) { - var _this = this; - - Duplex.prototype._destroy.call(this, err, function (err2) { - cb(err2); - _this.emit('close'); - }); -}; - -function done(stream, er, data) { - if (er) return stream.emit('error', er); - - if (data !== null && data !== undefined) stream.push(data); - - // if there's nothing in the write buffer, then that means - // that nothing more will ever be provided - var ws = stream._writableState; - var ts = stream._transformState; - - if (ws.length) throw new Error('Calling transform done when ws.length != 0'); - - if (ts.transforming) throw new Error('Calling transform done when still transforming'); - - return stream.push(null); -} - -/***/ }), -/* 49 */ -/***/ (function(module, exports, __webpack_require__) { - -var baseAssignValue = __webpack_require__(50), - eq = __webpack_require__(22); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Assigns `value` to `key` of `object` if the existing value is not equivalent - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ -function assignValue(object, key, value) { - var objValue = object[key]; - if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || - (value === undefined && !(key in object))) { - baseAssignValue(object, key, value); - } -} - -module.exports = assignValue; - - -/***/ }), -/* 50 */ -/***/ (function(module, exports, __webpack_require__) { - -var defineProperty = __webpack_require__(51); - -/** - * The base implementation of `assignValue` and `assignMergeValue` without - * value checks. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ -function baseAssignValue(object, key, value) { - if (key == '__proto__' && defineProperty) { - defineProperty(object, key, { - 'configurable': true, - 'enumerable': true, - 'value': value, - 'writable': true - }); - } else { - object[key] = value; - } -} - -module.exports = baseAssignValue; - - -/***/ }), -/* 51 */ -/***/ (function(module, exports, __webpack_require__) { - -var getNative = __webpack_require__(6); - -var defineProperty = (function() { - try { - var func = getNative(Object, 'defineProperty'); - func({}, '', {}); - return func; - } catch (e) {} -}()); - -module.exports = defineProperty; - - -/***/ }), -/* 52 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(global) {/** Detect free variable `global` from Node.js. */ -var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; - -module.exports = freeGlobal; - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) - -/***/ }), -/* 53 */ -/***/ (function(module, exports) { - -/** Used for built-in method references. */ -var funcProto = Function.prototype; - -/** Used to resolve the decompiled source of functions. */ -var funcToString = funcProto.toString; - -/** - * Converts `func` to its source code. - * - * @private - * @param {Function} func The function to convert. - * @returns {string} Returns the source code. - */ -function toSource(func) { - if (func != null) { - try { - return funcToString.call(func); - } catch (e) {} - try { - return (func + ''); - } catch (e) {} - } - return ''; -} - -module.exports = toSource; - - -/***/ }), -/* 54 */ -/***/ (function(module, exports, __webpack_require__) { - -var assignValue = __webpack_require__(49), - baseAssignValue = __webpack_require__(50); - -/** - * Copies properties of `source` to `object`. - * - * @private - * @param {Object} source The object to copy properties from. - * @param {Array} props The property identifiers to copy. - * @param {Object} [object={}] The object to copy properties to. - * @param {Function} [customizer] The function to customize copied values. - * @returns {Object} Returns `object`. - */ -function copyObject(source, props, object, customizer) { - var isNew = !object; - object || (object = {}); - - var index = -1, - length = props.length; - - while (++index < length) { - var key = props[index]; - - var newValue = customizer - ? customizer(object[key], source[key], key, object, source) - : undefined; - - if (newValue === undefined) { - newValue = source[key]; - } - if (isNew) { - baseAssignValue(object, key, newValue); - } else { - assignValue(object, key, newValue); - } - } - return object; -} - -module.exports = copyObject; - - -/***/ }), -/* 55 */ -/***/ (function(module, exports, __webpack_require__) { - -var eq = __webpack_require__(22), - isArrayLike = __webpack_require__(13), - isIndex = __webpack_require__(34), - isObject = __webpack_require__(1); - -/** - * Checks if the given arguments are from an iteratee call. - * - * @private - * @param {*} value The potential iteratee value argument. - * @param {*} index The potential iteratee index or key argument. - * @param {*} object The potential iteratee object argument. - * @returns {boolean} Returns `true` if the arguments are from an iteratee call, - * else `false`. - */ -function isIterateeCall(value, index, object) { - if (!isObject(object)) { - return false; - } - var type = typeof index; - if (type == 'number' - ? (isArrayLike(object) && isIndex(index, object.length)) - : (type == 'string' && index in object) - ) { - return eq(object[index], value); - } - return false; -} - -module.exports = isIterateeCall; - - -/***/ }), -/* 56 */ -/***/ (function(module, exports, __webpack_require__) { - -var isPrototype = __webpack_require__(35), - nativeKeys = __webpack_require__(113); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ -function baseKeys(object) { - if (!isPrototype(object)) { - return nativeKeys(object); - } - var result = []; - for (var key in Object(object)) { - if (hasOwnProperty.call(object, key) && key != 'constructor') { - result.push(key); - } - } - return result; -} - -module.exports = baseKeys; - - -/***/ }), -/* 57 */ -/***/ (function(module, exports, __webpack_require__) { - -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLDeclaration, XMLNode, create, isObject, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - create = __webpack_require__(0); - - isObject = __webpack_require__(1); - - XMLNode = __webpack_require__(10); - - module.exports = XMLDeclaration = (function(superClass) { - extend(XMLDeclaration, superClass); - - function XMLDeclaration(parent, version, encoding, standalone) { - var ref; - XMLDeclaration.__super__.constructor.call(this, parent); - if (isObject(version)) { - ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone; - } - if (!version) { - version = '1.0'; - } - this.version = this.stringify.xmlVersion(version); - if (encoding != null) { - this.encoding = this.stringify.xmlEncoding(encoding); - } - if (standalone != null) { - this.standalone = this.stringify.xmlStandalone(standalone); - } - } - - XMLDeclaration.prototype.toString = function(options, level) { - var indent, newline, offset, pretty, r, ref, ref1, ref2, space; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - level || (level = 0); - space = new Array(level + offset + 1).join(indent); - r = ''; - if (pretty) { - r += space; - } - r += ''; - if (pretty) { - r += newline; - } - return r; - }; - - return XMLDeclaration; - - })(XMLNode); - -}).call(this); - - -/***/ }), -/* 58 */ -/***/ (function(module, exports, __webpack_require__) { - -var DataView = __webpack_require__(120), - Map = __webpack_require__(40), - Promise = __webpack_require__(121), - Set = __webpack_require__(122), - WeakMap = __webpack_require__(123), - baseGetTag = __webpack_require__(12), - toSource = __webpack_require__(53); - -/** `Object#toString` result references. */ -var mapTag = '[object Map]', - objectTag = '[object Object]', - promiseTag = '[object Promise]', - setTag = '[object Set]', - weakMapTag = '[object WeakMap]'; - -var dataViewTag = '[object DataView]'; - -/** Used to detect maps, sets, and weakmaps. */ -var dataViewCtorString = toSource(DataView), - mapCtorString = toSource(Map), - promiseCtorString = toSource(Promise), - setCtorString = toSource(Set), - weakMapCtorString = toSource(WeakMap); - -/** - * Gets the `toStringTag` of `value`. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ -var getTag = baseGetTag; - -// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. -if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || - (Map && getTag(new Map) != mapTag) || - (Promise && getTag(Promise.resolve()) != promiseTag) || - (Set && getTag(new Set) != setTag) || - (WeakMap && getTag(new WeakMap) != weakMapTag)) { - getTag = function(value) { - var result = baseGetTag(value), - Ctor = result == objectTag ? value.constructor : undefined, - ctorString = Ctor ? toSource(Ctor) : ''; - - if (ctorString) { - switch (ctorString) { - case dataViewCtorString: return dataViewTag; - case mapCtorString: return mapTag; - case promiseCtorString: return promiseTag; - case setCtorString: return setTag; - case weakMapCtorString: return weakMapTag; - } - } - return result; - }; -} - -module.exports = getTag; - - -/***/ }), -/* 59 */ -/***/ (function(module, exports, __webpack_require__) { - -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLAttribute, XMLElement, XMLNode, XMLProcessingInstruction, create, every, isFunction, isObject, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - create = __webpack_require__(0); - - isObject = __webpack_require__(1); - - isFunction = __webpack_require__(20); - - every = __webpack_require__(124); - - XMLNode = __webpack_require__(10); - - XMLAttribute = __webpack_require__(189); - - XMLProcessingInstruction = __webpack_require__(67); - - module.exports = XMLElement = (function(superClass) { - extend(XMLElement, superClass); - - function XMLElement(parent, name, attributes) { - XMLElement.__super__.constructor.call(this, parent); - if (name == null) { - throw new Error("Missing element name"); - } - this.name = this.stringify.eleName(name); - this.children = []; - this.instructions = []; - this.attributes = {}; - if (attributes != null) { - this.attribute(attributes); - } - } - - XMLElement.prototype.clone = function() { - var att, attName, clonedSelf, i, len, pi, ref, ref1; - clonedSelf = create(XMLElement.prototype, this); - if (clonedSelf.isRoot) { - clonedSelf.documentObject = null; - } - clonedSelf.attributes = {}; - ref = this.attributes; - for (attName in ref) { - if (!hasProp.call(ref, attName)) continue; - att = ref[attName]; - clonedSelf.attributes[attName] = att.clone(); - } - clonedSelf.instructions = []; - ref1 = this.instructions; - for (i = 0, len = ref1.length; i < len; i++) { - pi = ref1[i]; - clonedSelf.instructions.push(pi.clone()); - } - clonedSelf.children = []; - this.children.forEach(function(child) { - var clonedChild; - clonedChild = child.clone(); - clonedChild.parent = clonedSelf; - return clonedSelf.children.push(clonedChild); - }); - return clonedSelf; - }; - - XMLElement.prototype.attribute = function(name, value) { - var attName, attValue; - if (name != null) { - name = name.valueOf(); - } - if (isObject(name)) { - for (attName in name) { - if (!hasProp.call(name, attName)) continue; - attValue = name[attName]; - this.attribute(attName, attValue); - } - } else { - if (isFunction(value)) { - value = value.apply(); - } - if (!this.options.skipNullAttributes || (value != null)) { - this.attributes[name] = new XMLAttribute(this, name, value); - } - } - return this; - }; - - XMLElement.prototype.removeAttribute = function(name) { - var attName, i, len; - if (name == null) { - throw new Error("Missing attribute name"); - } - name = name.valueOf(); - if (Array.isArray(name)) { - for (i = 0, len = name.length; i < len; i++) { - attName = name[i]; - delete this.attributes[attName]; - } - } else { - delete this.attributes[name]; - } - return this; - }; - - XMLElement.prototype.instruction = function(target, value) { - var i, insTarget, insValue, instruction, len; - if (target != null) { - target = target.valueOf(); - } - if (value != null) { - value = value.valueOf(); - } - if (Array.isArray(target)) { - for (i = 0, len = target.length; i < len; i++) { - insTarget = target[i]; - this.instruction(insTarget); - } - } else if (isObject(target)) { - for (insTarget in target) { - if (!hasProp.call(target, insTarget)) continue; - insValue = target[insTarget]; - this.instruction(insTarget, insValue); - } - } else { - if (isFunction(value)) { - value = value.apply(); - } - instruction = new XMLProcessingInstruction(this, target, value); - this.instructions.push(instruction); - } - return this; - }; - - XMLElement.prototype.toString = function(options, level) { - var att, child, i, indent, instruction, j, len, len1, name, newline, offset, pretty, r, ref, ref1, ref2, ref3, ref4, ref5, space; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - level || (level = 0); - space = new Array(level + offset + 1).join(indent); - r = ''; - ref3 = this.instructions; - for (i = 0, len = ref3.length; i < len; i++) { - instruction = ref3[i]; - r += instruction.toString(options, level); - } - if (pretty) { - r += space; - } - r += '<' + this.name; - ref4 = this.attributes; - for (name in ref4) { - if (!hasProp.call(ref4, name)) continue; - att = ref4[name]; - r += att.toString(options); - } - if (this.children.length === 0 || every(this.children, function(e) { - return e.value === ''; - })) { - r += '/>'; - if (pretty) { - r += newline; - } - } else if (pretty && this.children.length === 1 && (this.children[0].value != null)) { - r += '>'; - r += this.children[0].value; - r += ''; - r += newline; - } else { - r += '>'; - if (pretty) { - r += newline; - } - ref5 = this.children; - for (j = 0, len1 = ref5.length; j < len1; j++) { - child = ref5[j]; - r += child.toString(options, level + 1); - } - if (pretty) { - r += space; - } - r += ''; - if (pretty) { - r += newline; - } - } - return r; - }; - - XMLElement.prototype.att = function(name, value) { - return this.attribute(name, value); - }; - - XMLElement.prototype.ins = function(target, value) { - return this.instruction(target, value); - }; - - XMLElement.prototype.a = function(name, value) { - return this.attribute(name, value); - }; - - XMLElement.prototype.i = function(target, value) { - return this.instruction(target, value); - }; - - return XMLElement; - - })(XMLNode); - -}).call(this); - - -/***/ }), -/* 60 */ -/***/ (function(module, exports, __webpack_require__) { - -var ListCache = __webpack_require__(23), - stackClear = __webpack_require__(140), - stackDelete = __webpack_require__(141), - stackGet = __webpack_require__(142), - stackHas = __webpack_require__(143), - stackSet = __webpack_require__(144); - -/** - * Creates a stack cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function Stack(entries) { - var data = this.__data__ = new ListCache(entries); - this.size = data.size; -} - -// Add methods to `Stack`. -Stack.prototype.clear = stackClear; -Stack.prototype['delete'] = stackDelete; -Stack.prototype.get = stackGet; -Stack.prototype.has = stackHas; -Stack.prototype.set = stackSet; - -module.exports = Stack; - - -/***/ }), -/* 61 */ -/***/ (function(module, exports, __webpack_require__) { - -var baseIsEqualDeep = __webpack_require__(157), - isObjectLike = __webpack_require__(15); - -/** - * The base implementation of `_.isEqual` which supports partial comparisons - * and tracks traversed objects. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {boolean} bitmask The bitmask flags. - * 1 - Unordered comparison - * 2 - Partial comparison - * @param {Function} [customizer] The function to customize comparisons. - * @param {Object} [stack] Tracks traversed `value` and `other` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - */ -function baseIsEqual(value, other, bitmask, customizer, stack) { - if (value === other) { - return true; - } - if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { - return value !== value && other !== other; - } - return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); -} - -module.exports = baseIsEqual; - - -/***/ }), -/* 62 */ -/***/ (function(module, exports, __webpack_require__) { - -var SetCache = __webpack_require__(158), - arraySome = __webpack_require__(161), - cacheHas = __webpack_require__(162); - -/** Used to compose bitmasks for value comparisons. */ -var COMPARE_PARTIAL_FLAG = 1, - COMPARE_UNORDERED_FLAG = 2; - -/** - * A specialized version of `baseIsEqualDeep` for arrays with support for - * partial deep comparisons. - * - * @private - * @param {Array} array The array to compare. - * @param {Array} other The other array to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `array` and `other` objects. - * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. - */ -function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { - var isPartial = bitmask & COMPARE_PARTIAL_FLAG, - arrLength = array.length, - othLength = other.length; - - if (arrLength != othLength && !(isPartial && othLength > arrLength)) { - return false; - } - // Assume cyclic values are equal. - var stacked = stack.get(array); - if (stacked && stack.get(other)) { - return stacked == other; - } - var index = -1, - result = true, - seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; - - stack.set(array, other); - stack.set(other, array); - - // Ignore non-index properties. - while (++index < arrLength) { - var arrValue = array[index], - othValue = other[index]; - - if (customizer) { - var compared = isPartial - ? customizer(othValue, arrValue, index, other, array, stack) - : customizer(arrValue, othValue, index, array, other, stack); - } - if (compared !== undefined) { - if (compared) { - continue; - } - result = false; - break; - } - // Recursively compare arrays (susceptible to call stack limits). - if (seen) { - if (!arraySome(other, function(othValue, othIndex) { - if (!cacheHas(seen, othIndex) && - (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { - return seen.push(othIndex); - } - })) { - result = false; - break; - } - } else if (!( - arrValue === othValue || - equalFunc(arrValue, othValue, bitmask, customizer, stack) - )) { - result = false; - break; - } - } - stack['delete'](array); - stack['delete'](other); - return result; -} - -module.exports = equalArrays; - - -/***/ }), -/* 63 */ -/***/ (function(module, exports, __webpack_require__) { - -var isObject = __webpack_require__(1); - -/** - * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` if suitable for strict - * equality comparisons, else `false`. - */ -function isStrictComparable(value) { - return value === value && !isObject(value); -} - -module.exports = isStrictComparable; - - -/***/ }), -/* 64 */ -/***/ (function(module, exports) { - -/** - * A specialized version of `matchesProperty` for source values suitable - * for strict equality comparisons, i.e. `===`. - * - * @private - * @param {string} key The key of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new spec function. - */ -function matchesStrictComparable(key, srcValue) { - return function(object) { - if (object == null) { - return false; - } - return object[key] === srcValue && - (srcValue !== undefined || (key in Object(object))); - }; -} - -module.exports = matchesStrictComparable; - - -/***/ }), -/* 65 */ -/***/ (function(module, exports, __webpack_require__) { - -var castPath = __webpack_require__(66), - toKey = __webpack_require__(27); - -/** - * The base implementation of `_.get` without support for default values. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @returns {*} Returns the resolved value. - */ -function baseGet(object, path) { - path = castPath(path, object); - - var index = 0, - length = path.length; - - while (object != null && index < length) { - object = object[toKey(path[index++])]; - } - return (index && index == length) ? object : undefined; -} - -module.exports = baseGet; - - -/***/ }), -/* 66 */ -/***/ (function(module, exports, __webpack_require__) { - -var isArray = __webpack_require__(2), - isKey = __webpack_require__(42), - stringToPath = __webpack_require__(177), - toString = __webpack_require__(180); - -/** - * Casts `value` to a path array if it's not one. - * - * @private - * @param {*} value The value to inspect. - * @param {Object} [object] The object to query keys on. - * @returns {Array} Returns the cast property path array. - */ -function castPath(value, object) { - if (isArray(value)) { - return value; - } - return isKey(value, object) ? [value] : stringToPath(toString(value)); -} - -module.exports = castPath; - - -/***/ }), -/* 67 */ -/***/ (function(module, exports, __webpack_require__) { - -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLProcessingInstruction, create; - - create = __webpack_require__(0); - - module.exports = XMLProcessingInstruction = (function() { - function XMLProcessingInstruction(parent, target, value) { - this.stringify = parent.stringify; - if (target == null) { - throw new Error("Missing instruction target"); - } - this.target = this.stringify.insTarget(target); - if (value) { - this.value = this.stringify.insValue(value); - } - } - - XMLProcessingInstruction.prototype.clone = function() { - return create(XMLProcessingInstruction.prototype, this); - }; - - XMLProcessingInstruction.prototype.toString = function(options, level) { - var indent, newline, offset, pretty, r, ref, ref1, ref2, space; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - level || (level = 0); - space = new Array(level + offset + 1).join(indent); - r = ''; - if (pretty) { - r += space; - } - r += ''; - if (pretty) { - r += newline; - } - return r; - }; - - return XMLProcessingInstruction; - - })(); - -}).call(this); - - -/***/ }), -/* 68 */ -/***/ (function(module, exports, __webpack_require__) { - -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLCData, XMLNode, create, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - create = __webpack_require__(0); - - XMLNode = __webpack_require__(10); - - module.exports = XMLCData = (function(superClass) { - extend(XMLCData, superClass); - - function XMLCData(parent, text) { - XMLCData.__super__.constructor.call(this, parent); - if (text == null) { - throw new Error("Missing CDATA text"); - } - this.text = this.stringify.cdata(text); - } - - XMLCData.prototype.clone = function() { - return create(XMLCData.prototype, this); - }; - - XMLCData.prototype.toString = function(options, level) { - var indent, newline, offset, pretty, r, ref, ref1, ref2, space; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - level || (level = 0); - space = new Array(level + offset + 1).join(indent); - r = ''; - if (pretty) { - r += space; - } - r += ''; - if (pretty) { - r += newline; - } - return r; - }; - - return XMLCData; - - })(XMLNode); - -}).call(this); - - -/***/ }), -/* 69 */ -/***/ (function(module, exports, __webpack_require__) { - -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLComment, XMLNode, create, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - create = __webpack_require__(0); - - XMLNode = __webpack_require__(10); - - module.exports = XMLComment = (function(superClass) { - extend(XMLComment, superClass); - - function XMLComment(parent, text) { - XMLComment.__super__.constructor.call(this, parent); - if (text == null) { - throw new Error("Missing comment text"); - } - this.text = this.stringify.comment(text); - } - - XMLComment.prototype.clone = function() { - return create(XMLComment.prototype, this); - }; - - XMLComment.prototype.toString = function(options, level) { - var indent, newline, offset, pretty, r, ref, ref1, ref2, space; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - level || (level = 0); - space = new Array(level + offset + 1).join(indent); - r = ''; - if (pretty) { - r += space; - } - r += ''; - if (pretty) { - r += newline; - } - return r; - }; - - return XMLComment; - - })(XMLNode); - -}).call(this); - - -/***/ }), -/* 70 */ -/***/ (function(module, exports, __webpack_require__) { - -// Generated by CoffeeScript 1.9.1 -(function() { - var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLProcessingInstruction, create, isObject; - - create = __webpack_require__(0); - - isObject = __webpack_require__(1); - - XMLCData = __webpack_require__(68); - - XMLComment = __webpack_require__(69); - - XMLDTDAttList = __webpack_require__(190); - - XMLDTDEntity = __webpack_require__(191); - - XMLDTDElement = __webpack_require__(192); - - XMLDTDNotation = __webpack_require__(193); - - XMLProcessingInstruction = __webpack_require__(67); - - module.exports = XMLDocType = (function() { - function XMLDocType(parent, pubID, sysID) { - var ref, ref1; - this.documentObject = parent; - this.stringify = this.documentObject.stringify; - this.children = []; - if (isObject(pubID)) { - ref = pubID, pubID = ref.pubID, sysID = ref.sysID; - } - if (sysID == null) { - ref1 = [pubID, sysID], sysID = ref1[0], pubID = ref1[1]; - } - if (pubID != null) { - this.pubID = this.stringify.dtdPubID(pubID); - } - if (sysID != null) { - this.sysID = this.stringify.dtdSysID(sysID); - } - } - - XMLDocType.prototype.element = function(name, value) { - var child; - child = new XMLDTDElement(this, name, value); - this.children.push(child); - return this; - }; - - XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { - var child; - child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue); - this.children.push(child); - return this; - }; - - XMLDocType.prototype.entity = function(name, value) { - var child; - child = new XMLDTDEntity(this, false, name, value); - this.children.push(child); - return this; - }; - - XMLDocType.prototype.pEntity = function(name, value) { - var child; - child = new XMLDTDEntity(this, true, name, value); - this.children.push(child); - return this; - }; - - XMLDocType.prototype.notation = function(name, value) { - var child; - child = new XMLDTDNotation(this, name, value); - this.children.push(child); - return this; - }; - - XMLDocType.prototype.cdata = function(value) { - var child; - child = new XMLCData(this, value); - this.children.push(child); - return this; - }; - - XMLDocType.prototype.comment = function(value) { - var child; - child = new XMLComment(this, value); - this.children.push(child); - return this; - }; - - XMLDocType.prototype.instruction = function(target, value) { - var child; - child = new XMLProcessingInstruction(this, target, value); - this.children.push(child); - return this; - }; - - XMLDocType.prototype.root = function() { - return this.documentObject.root(); - }; - - XMLDocType.prototype.document = function() { - return this.documentObject; - }; - - XMLDocType.prototype.toString = function(options, level) { - var child, i, indent, len, newline, offset, pretty, r, ref, ref1, ref2, ref3, space; - pretty = (options != null ? options.pretty : void 0) || false; - indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; - offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; - newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; - level || (level = 0); - space = new Array(level + offset + 1).join(indent); - r = ''; - if (pretty) { - r += space; - } - r += ' 0) { - r += ' ['; - if (pretty) { - r += newline; - } - ref3 = this.children; - for (i = 0, len = ref3.length; i < len; i++) { - child = ref3[i]; - r += child.toString(options, level + 1); - } - r += ']'; - } - r += '>'; - if (pretty) { - r += newline; - } - return r; - }; - - XMLDocType.prototype.ele = function(name, value) { - return this.element(name, value); - }; - - XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { - return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue); - }; - - XMLDocType.prototype.ent = function(name, value) { - return this.entity(name, value); - }; - - XMLDocType.prototype.pent = function(name, value) { - return this.pEntity(name, value); - }; - - XMLDocType.prototype.not = function(name, value) { - return this.notation(name, value); - }; - - XMLDocType.prototype.dat = function(value) { - return this.cdata(value); - }; - - XMLDocType.prototype.com = function(value) { - return this.comment(value); - }; - - XMLDocType.prototype.ins = function(target, value) { - return this.instruction(target, value); - }; - - XMLDocType.prototype.up = function() { - return this.root(); - }; - - XMLDocType.prototype.doc = function() { - return this.document(); - }; - - return XMLDocType; - - })(); - -}).call(this); - - -/***/ }), -/* 71 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -exports.decode = exports.parse = __webpack_require__(201); -exports.encode = exports.stringify = __webpack_require__(202); - - -/***/ }), -/* 72 */ -/***/ (function(module, exports, __webpack_require__) { - -var COS = __webpack_require__(73); -module.exports = COS; - -/***/ }), -/* 73 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var util = __webpack_require__(16); -var event = __webpack_require__(198); -var task = __webpack_require__(199); -var base = __webpack_require__(200); -var advance = __webpack_require__(204); -var pkg = __webpack_require__(211); - -var defaultOptions = { - AppId: '', - SecretId: '', - SecretKey: '', - FileParallelLimit: 3, - ChunkParallelLimit: 3, - ChunkSize: 1024 * 1024, - ProgressInterval: 1000, - Domain: '', - ServiceDomain: '' -}; - -// 对外暴露的类 -var COS = function (options) { - this.options = util.extend(util.clone(defaultOptions), options || {}); - event.init(this); - task.init(this); -}; - -util.extend(COS.prototype, base); -util.extend(COS.prototype, advance); - -COS.getAuthorization = util.getAuth; -COS.version = pkg.version; - -module.exports = window.COS = COS; - -/***/ }), -/* 74 */ -/***/ (function(module, exports, __webpack_require__) { - -"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 -} - -revLookup['-'.charCodeAt(0)] = 62 -revLookup['_'.charCodeAt(0)] = 63 - -function placeHoldersCount (b64) { - var len = b64.length - if (len % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 -} - -function byteLength (b64) { - // base64 is 4/3 + up to two characters of the original data - return (b64.length * 3 / 4) - placeHoldersCount(b64) -} - -function toByteArray (b64) { - var i, l, tmp, placeHolders, arr - var len = b64.length - placeHolders = placeHoldersCount(b64) - - arr = new Arr((len * 3 / 4) - placeHolders) - - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? len - 4 : len - - var L = 0 - - for (i = 0; i < l; i += 4) { - tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] - arr[L++] = (tmp >> 16) & 0xFF - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF - } - - if (placeHolders === 2) { - tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[L++] = tmp & 0xFF - } else if (placeHolders === 1) { - tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[L++] = (tmp >> 8) & 0xFF - arr[L++] = tmp & 0xFF - } - - return arr -} - -function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] -} - -function encodeChunk (uint8, start, end) { - var tmp - var output = [] - for (var i = start; i < end; i += 3) { - tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) - output.push(tripletToBase64(tmp)) - } - return output.join('') -} - -function fromByteArray (uint8) { - var tmp - var len = uint8.length - var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes - var output = '' - var parts = [] - var maxChunkLength = 16383 // must be multiple of 3 - - // go through the array every three bytes, we'll deal with trailing stuff later - for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - if (extraBytes === 1) { - tmp = uint8[len - 1] - output += lookup[tmp >> 2] - output += lookup[(tmp << 4) & 0x3F] - output += '==' - } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) - output += lookup[tmp >> 10] - output += lookup[(tmp >> 4) & 0x3F] - output += lookup[(tmp << 2) & 0x3F] - output += '=' - } - - parts.push(output) - - return parts.join('') -} - - -/***/ }), -/* 75 */ -/***/ (function(module, exports) { - -exports.read = function (buffer, offset, isLE, mLen, nBytes) { - var e, m - var eLen = nBytes * 8 - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var nBits = -7 - var i = isLE ? (nBytes - 1) : 0 - var d = isLE ? -1 : 1 - var s = buffer[offset + i] - - i += d - - e = s & ((1 << (-nBits)) - 1) - s >>= (-nBits) - nBits += eLen - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} - - m = e & ((1 << (-nBits)) - 1) - e >>= (-nBits) - nBits += mLen - for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} - - if (e === 0) { - e = 1 - eBias - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity) - } else { - m = m + Math.pow(2, mLen) - e = e - eBias - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen) -} - -exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c - var eLen = nBytes * 8 - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) - var i = isLE ? 0 : (nBytes - 1) - var d = isLE ? 1 : -1 - var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 - - value = Math.abs(value) - - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0 - e = eMax - } else { - e = Math.floor(Math.log(value) / Math.LN2) - if (value * (c = Math.pow(2, -e)) < 1) { - e-- - c *= 2 - } - if (e + eBias >= 1) { - value += rt / c - } else { - value += rt * Math.pow(2, 1 - eBias) - } - if (value * c >= 2) { - e++ - c /= 2 - } - - if (e + eBias >= eMax) { - m = 0 - e = eMax - } else if (e + eBias >= 1) { - m = (value * c - 1) * Math.pow(2, mLen) - e = e + eBias - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) - e = 0 - } - } - - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - - e = (e << mLen) | m - eLen += mLen - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - - buffer[offset + i - d] |= s * 128 -} - - -/***/ }), -/* 76 */ -/***/ (function(module, exports) { - -/** - * - * MD5 (Message-Digest Algorithm) - * http://www.webtoolkit.info/ - * - **/ - -var md5 = function (string) { - - function RotateLeft(lValue, iShiftBits) { - return lValue << iShiftBits | lValue >>> 32 - iShiftBits; - } - - function AddUnsigned(lX, lY) { - var lX4, lY4, lX8, lY8, lResult; - lX8 = lX & 0x80000000; - lY8 = lY & 0x80000000; - lX4 = lX & 0x40000000; - lY4 = lY & 0x40000000; - lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF); - if (lX4 & lY4) { - return lResult ^ 0x80000000 ^ lX8 ^ lY8; - } - if (lX4 | lY4) { - if (lResult & 0x40000000) { - return lResult ^ 0xC0000000 ^ lX8 ^ lY8; - } else { - return lResult ^ 0x40000000 ^ lX8 ^ lY8; - } - } else { - return lResult ^ lX8 ^ lY8; - } - } - - function F(x, y, z) { - return x & y | ~x & z; - } - function G(x, y, z) { - return x & z | y & ~z; - } - function H(x, y, z) { - return x ^ y ^ z; - } - function I(x, y, z) { - return y ^ (x | ~z); - } - - function FF(a, b, c, d, x, s, ac) { - a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac)); - return AddUnsigned(RotateLeft(a, s), b); - }; - - function GG(a, b, c, d, x, s, ac) { - a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac)); - return AddUnsigned(RotateLeft(a, s), b); - }; - - function HH(a, b, c, d, x, s, ac) { - a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac)); - return AddUnsigned(RotateLeft(a, s), b); - }; - - function II(a, b, c, d, x, s, ac) { - a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac)); - return AddUnsigned(RotateLeft(a, s), b); - }; - - function ConvertToWordArray(string) { - var lWordCount; - var lMessageLength = string.length; - var lNumberOfWords_temp1 = lMessageLength + 8; - var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - lNumberOfWords_temp1 % 64) / 64; - var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16; - var lWordArray = Array(lNumberOfWords - 1); - var lBytePosition = 0; - var lByteCount = 0; - while (lByteCount < lMessageLength) { - lWordCount = (lByteCount - lByteCount % 4) / 4; - lBytePosition = lByteCount % 4 * 8; - lWordArray[lWordCount] = lWordArray[lWordCount] | string.charCodeAt(lByteCount) << lBytePosition; - lByteCount++; - } - lWordCount = (lByteCount - lByteCount % 4) / 4; - lBytePosition = lByteCount % 4 * 8; - lWordArray[lWordCount] = lWordArray[lWordCount] | 0x80 << lBytePosition; - lWordArray[lNumberOfWords - 2] = lMessageLength << 3; - lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29; - return lWordArray; - }; - - function WordToHex(lValue) { - var WordToHexValue = "", - WordToHexValue_temp = "", - lByte, - lCount; - for (lCount = 0; lCount <= 3; lCount++) { - lByte = lValue >>> lCount * 8 & 255; - WordToHexValue_temp = "0" + lByte.toString(16); - WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length - 2, 2); - } - return WordToHexValue; - }; - - function Utf8Encode(string) { - string = string.replace(/\r\n/g, "\n"); - var utftext = ""; - - for (var n = 0; n < string.length; n++) { - - var c = string.charCodeAt(n); - - if (c < 128) { - utftext += String.fromCharCode(c); - } else if (c > 127 && c < 2048) { - utftext += String.fromCharCode(c >> 6 | 192); - utftext += String.fromCharCode(c & 63 | 128); - } else { - utftext += String.fromCharCode(c >> 12 | 224); - utftext += String.fromCharCode(c >> 6 & 63 | 128); - utftext += String.fromCharCode(c & 63 | 128); - } - } - - return utftext; - }; - - var x = Array(); - var k, AA, BB, CC, DD, a, b, c, d; - var S11 = 7, - S12 = 12, - S13 = 17, - S14 = 22; - var S21 = 5, - S22 = 9, - S23 = 14, - S24 = 20; - var S31 = 4, - S32 = 11, - S33 = 16, - S34 = 23; - var S41 = 6, - S42 = 10, - S43 = 15, - S44 = 21; - - string = Utf8Encode(string); - - x = ConvertToWordArray(string); - - a = 0x67452301;b = 0xEFCDAB89;c = 0x98BADCFE;d = 0x10325476; - - for (k = 0; k < x.length; k += 16) { - AA = a;BB = b;CC = c;DD = d; - a = FF(a, b, c, d, x[k + 0], S11, 0xD76AA478); - d = FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756); - c = FF(c, d, a, b, x[k + 2], S13, 0x242070DB); - b = FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE); - a = FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF); - d = FF(d, a, b, c, x[k + 5], S12, 0x4787C62A); - c = FF(c, d, a, b, x[k + 6], S13, 0xA8304613); - b = FF(b, c, d, a, x[k + 7], S14, 0xFD469501); - a = FF(a, b, c, d, x[k + 8], S11, 0x698098D8); - d = FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF); - c = FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1); - b = FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE); - a = FF(a, b, c, d, x[k + 12], S11, 0x6B901122); - d = FF(d, a, b, c, x[k + 13], S12, 0xFD987193); - c = FF(c, d, a, b, x[k + 14], S13, 0xA679438E); - b = FF(b, c, d, a, x[k + 15], S14, 0x49B40821); - a = GG(a, b, c, d, x[k + 1], S21, 0xF61E2562); - d = GG(d, a, b, c, x[k + 6], S22, 0xC040B340); - c = GG(c, d, a, b, x[k + 11], S23, 0x265E5A51); - b = GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA); - a = GG(a, b, c, d, x[k + 5], S21, 0xD62F105D); - d = GG(d, a, b, c, x[k + 10], S22, 0x2441453); - c = GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681); - b = GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8); - a = GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6); - d = GG(d, a, b, c, x[k + 14], S22, 0xC33707D6); - c = GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87); - b = GG(b, c, d, a, x[k + 8], S24, 0x455A14ED); - a = GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905); - d = GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8); - c = GG(c, d, a, b, x[k + 7], S23, 0x676F02D9); - b = GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A); - a = HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942); - d = HH(d, a, b, c, x[k + 8], S32, 0x8771F681); - c = HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122); - b = HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C); - a = HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44); - d = HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9); - c = HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60); - b = HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70); - a = HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6); - d = HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA); - c = HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085); - b = HH(b, c, d, a, x[k + 6], S34, 0x4881D05); - a = HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039); - d = HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5); - c = HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8); - b = HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665); - a = II(a, b, c, d, x[k + 0], S41, 0xF4292244); - d = II(d, a, b, c, x[k + 7], S42, 0x432AFF97); - c = II(c, d, a, b, x[k + 14], S43, 0xAB9423A7); - b = II(b, c, d, a, x[k + 5], S44, 0xFC93A039); - a = II(a, b, c, d, x[k + 12], S41, 0x655B59C3); - d = II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92); - c = II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D); - b = II(b, c, d, a, x[k + 1], S44, 0x85845DD1); - a = II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F); - d = II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0); - c = II(c, d, a, b, x[k + 6], S43, 0xA3014314); - b = II(b, c, d, a, x[k + 13], S44, 0x4E0811A1); - a = II(a, b, c, d, x[k + 4], S41, 0xF7537E82); - d = II(d, a, b, c, x[k + 11], S42, 0xBD3AF235); - c = II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB); - b = II(b, c, d, a, x[k + 9], S44, 0xEB86D391); - a = AddUnsigned(a, AA); - b = AddUnsigned(b, BB); - c = AddUnsigned(c, CC); - d = AddUnsigned(d, DD); - } - - var temp = WordToHex(a) + WordToHex(b) + WordToHex(c) + WordToHex(d); - - return temp.toLowerCase(); -}; - -module.exports = md5; - -/***/ }), -/* 77 */ -/***/ (function(module, exports, __webpack_require__) { - -/* - CryptoJS v3.1.2 - code.google.com/p/crypto-js - (c) 2009-2013 by Jeff Mott. All rights reserved. - code.google.com/p/crypto-js/wiki/License - */ -var CryptoJS = CryptoJS || function (g, l) { - var e = {}, - d = e.lib = {}, - m = function () {}, - k = d.Base = { extend: function (a) { - m.prototype = this;var c = new m();a && c.mixIn(a);c.hasOwnProperty("init") || (c.init = function () { - c.$super.init.apply(this, arguments); - });c.init.prototype = c;c.$super = this;return c; - }, create: function () { - var a = this.extend();a.init.apply(a, arguments);return a; - }, init: function () {}, mixIn: function (a) { - for (var c in a) a.hasOwnProperty(c) && (this[c] = a[c]);a.hasOwnProperty("toString") && (this.toString = a.toString); - }, clone: function () { - return this.init.prototype.extend(this); - } }, - p = d.WordArray = k.extend({ init: function (a, c) { - a = this.words = a || [];this.sigBytes = c != l ? c : 4 * a.length; - }, toString: function (a) { - return (a || n).stringify(this); - }, concat: function (a) { - var c = this.words, - q = a.words, - f = this.sigBytes;a = a.sigBytes;this.clamp();if (f % 4) for (var b = 0; b < a; b++) c[f + b >>> 2] |= (q[b >>> 2] >>> 24 - 8 * (b % 4) & 255) << 24 - 8 * ((f + b) % 4);else if (65535 < q.length) for (b = 0; b < a; b += 4) c[f + b >>> 2] = q[b >>> 2];else c.push.apply(c, q);this.sigBytes += a;return this; - }, clamp: function () { - var a = this.words, - c = this.sigBytes;a[c >>> 2] &= 4294967295 << 32 - 8 * (c % 4);a.length = g.ceil(c / 4); - }, clone: function () { - var a = k.clone.call(this);a.words = this.words.slice(0);return a; - }, random: function (a) { - for (var c = [], b = 0; b < a; b += 4) c.push(4294967296 * g.random() | 0);return new p.init(c, a); - } }), - b = e.enc = {}, - n = b.Hex = { stringify: function (a) { - var c = a.words;a = a.sigBytes;for (var b = [], f = 0; f < a; f++) { - var d = c[f >>> 2] >>> 24 - 8 * (f % 4) & 255;b.push((d >>> 4).toString(16));b.push((d & 15).toString(16)); - }return b.join(""); - }, parse: function (a) { - for (var c = a.length, b = [], f = 0; f < c; f += 2) b[f >>> 3] |= parseInt(a.substr(f, 2), 16) << 24 - 4 * (f % 8);return new p.init(b, c / 2); - } }, - j = b.Latin1 = { stringify: function (a) { - var c = a.words;a = a.sigBytes;for (var b = [], f = 0; f < a; f++) b.push(String.fromCharCode(c[f >>> 2] >>> 24 - 8 * (f % 4) & 255));return b.join(""); - }, parse: function (a) { - for (var c = a.length, b = [], f = 0; f < c; f++) b[f >>> 2] |= (a.charCodeAt(f) & 255) << 24 - 8 * (f % 4);return new p.init(b, c); - } }, - h = b.Utf8 = { stringify: function (a) { - try { - return decodeURIComponent(escape(j.stringify(a))); - } catch (c) { - throw Error("Malformed UTF-8 data"); - } - }, parse: function (a) { - return j.parse(unescape(encodeURIComponent(a))); - } }, - r = d.BufferedBlockAlgorithm = k.extend({ reset: function () { - this._data = new p.init();this._nDataBytes = 0; - }, _append: function (a) { - "string" == typeof a && (a = h.parse(a));this._data.concat(a);this._nDataBytes += a.sigBytes; - }, _process: function (a) { - var c = this._data, - b = c.words, - f = c.sigBytes, - d = this.blockSize, - e = f / (4 * d), - e = a ? g.ceil(e) : g.max((e | 0) - this._minBufferSize, 0);a = e * d;f = g.min(4 * a, f);if (a) { - for (var k = 0; k < a; k += d) this._doProcessBlock(b, k);k = b.splice(0, a);c.sigBytes -= f; - }return new p.init(k, f); - }, clone: function () { - var a = k.clone.call(this); - a._data = this._data.clone();return a; - }, _minBufferSize: 0 });d.Hasher = r.extend({ cfg: k.extend(), init: function (a) { - this.cfg = this.cfg.extend(a);this.reset(); - }, reset: function () { - r.reset.call(this);this._doReset(); - }, update: function (a) { - this._append(a);this._process();return this; - }, finalize: function (a) { - a && this._append(a);return this._doFinalize(); - }, blockSize: 16, _createHelper: function (a) { - return function (b, d) { - return new a.init(d).finalize(b); - }; - }, _createHmacHelper: function (a) { - return function (b, d) { - return new s.HMAC.init(a, d).finalize(b); - }; - } });var s = e.algo = {};return e; -}(Math); -(function () { - var g = CryptoJS, - l = g.lib, - e = l.WordArray, - d = l.Hasher, - m = [], - l = g.algo.SHA1 = d.extend({ _doReset: function () { - this._hash = new e.init([1732584193, 4023233417, 2562383102, 271733878, 3285377520]); - }, _doProcessBlock: function (d, e) { - for (var b = this._hash.words, n = b[0], j = b[1], h = b[2], g = b[3], l = b[4], a = 0; 80 > a; a++) { - if (16 > a) m[a] = d[e + a] | 0;else { - var c = m[a - 3] ^ m[a - 8] ^ m[a - 14] ^ m[a - 16];m[a] = c << 1 | c >>> 31; - }c = (n << 5 | n >>> 27) + l + m[a];c = 20 > a ? c + ((j & h | ~j & g) + 1518500249) : 40 > a ? c + ((j ^ h ^ g) + 1859775393) : 60 > a ? c + ((j & h | j & g | h & g) - 1894007588) : c + ((j ^ h ^ g) - 899497514);l = g;g = h;h = j << 30 | j >>> 2;j = n;n = c; - }b[0] = b[0] + n | 0;b[1] = b[1] + j | 0;b[2] = b[2] + h | 0;b[3] = b[3] + g | 0;b[4] = b[4] + l | 0; - }, _doFinalize: function () { - var d = this._data, - e = d.words, - b = 8 * this._nDataBytes, - g = 8 * d.sigBytes;e[g >>> 5] |= 128 << 24 - g % 32;e[(g + 64 >>> 9 << 4) + 14] = Math.floor(b / 4294967296);e[(g + 64 >>> 9 << 4) + 15] = b;d.sigBytes = 4 * e.length;this._process();return this._hash; - }, clone: function () { - var e = d.clone.call(this);e._hash = this._hash.clone();return e; - } });g.SHA1 = d._createHelper(l);g.HmacSHA1 = d._createHmacHelper(l); -})(); -(function () { - var g = CryptoJS, - l = g.enc.Utf8;g.algo.HMAC = g.lib.Base.extend({ init: function (e, d) { - e = this._hasher = new e.init();"string" == typeof d && (d = l.parse(d));var g = e.blockSize, - k = 4 * g;d.sigBytes > k && (d = e.finalize(d));d.clamp();for (var p = this._oKey = d.clone(), b = this._iKey = d.clone(), n = p.words, j = b.words, h = 0; h < g; h++) n[h] ^= 1549556828, j[h] ^= 909522486;p.sigBytes = b.sigBytes = k;this.reset(); - }, reset: function () { - var e = this._hasher;e.reset();e.update(this._iKey); - }, update: function (e) { - this._hasher.update(e);return this; - }, finalize: function (e) { - var d = this._hasher;e = d.finalize(e);d.reset();return d.finalize(this._oKey.clone().concat(e)); - } }); -})(); - -(function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var C_enc = C.enc; - - /** - * Base64 encoding strategy. - */ - var Base64 = C_enc.Base64 = { - /** - * Converts a word array to a Base64 string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The Base64 string. - * - * @static - * - * @example - * - * var base64String = CryptoJS.enc.Base64.stringify(wordArray); - */ - stringify: function (wordArray) { - // Shortcuts - var words = wordArray.words; - var sigBytes = wordArray.sigBytes; - var map = this._map; - - // Clamp excess bits - wordArray.clamp(); - - // Convert - var base64Chars = []; - for (var i = 0; i < sigBytes; i += 3) { - var byte1 = words[i >>> 2] >>> 24 - i % 4 * 8 & 0xff; - var byte2 = words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 0xff; - var byte3 = words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 0xff; - - var triplet = byte1 << 16 | byte2 << 8 | byte3; - - for (var j = 0; j < 4 && i + j * 0.75 < sigBytes; j++) { - base64Chars.push(map.charAt(triplet >>> 6 * (3 - j) & 0x3f)); - } - } - - // Add padding - var paddingChar = map.charAt(64); - if (paddingChar) { - while (base64Chars.length % 4) { - base64Chars.push(paddingChar); - } - } - - return base64Chars.join(''); - }, - - /** - * Converts a Base64 string to a word array. - * - * @param {string} base64Str The Base64 string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * var wordArray = CryptoJS.enc.Base64.parse(base64String); - */ - parse: function (base64Str) { - // Shortcuts - var base64StrLength = base64Str.length; - var map = this._map; - - // Ignore padding - var paddingChar = map.charAt(64); - if (paddingChar) { - var paddingIndex = base64Str.indexOf(paddingChar); - if (paddingIndex != -1) { - base64StrLength = paddingIndex; - } - } - - // Convert - var words = []; - var nBytes = 0; - for (var i = 0; i < base64StrLength; i++) { - if (i % 4) { - var bits1 = map.indexOf(base64Str.charAt(i - 1)) << i % 4 * 2; - var bits2 = map.indexOf(base64Str.charAt(i)) >>> 6 - i % 4 * 2; - words[nBytes >>> 2] |= (bits1 | bits2) << 24 - nBytes % 4 * 8; - nBytes++; - } - } - - return WordArray.create(words, nBytes); - }, - - _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' - }; -})(); - -if (true) { - module.exports = CryptoJS; -} else { - window.CryptoJS = CryptoJS; -} - -/***/ }), -/* 78 */ -/***/ (function(module, exports, __webpack_require__) { - -// Generated by CoffeeScript 1.10.0 -(function() { - "use strict"; - var bom, builder, escapeCDATA, events, isEmpty, processName, processors, requiresCDATA, sax, setImmediate, wrapCDATA, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty, - bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - sax = __webpack_require__(79); - - events = __webpack_require__(17); - - builder = __webpack_require__(90); - - bom = __webpack_require__(196); - - processors = __webpack_require__(197); - - setImmediate = __webpack_require__(19).setImmediate; - - isEmpty = function(thing) { - return typeof thing === "object" && (thing != null) && Object.keys(thing).length === 0; - }; - - processName = function(processors, processedName) { - var i, len, process; - for (i = 0, len = processors.length; i < len; i++) { - process = processors[i]; - processedName = process(processedName); - } - return processedName; - }; - - requiresCDATA = function(entry) { - return entry.indexOf('&') >= 0 || entry.indexOf('>') >= 0 || entry.indexOf('<') >= 0; - }; - - wrapCDATA = function(entry) { - return ""; - }; - - escapeCDATA = function(entry) { - return entry.replace(']]>', ']]]]>'); - }; - - exports.processors = processors; - - exports.defaults = { - "0.1": { - explicitCharkey: false, - trim: true, - normalize: true, - normalizeTags: false, - attrkey: "@", - charkey: "#", - explicitArray: false, - ignoreAttrs: false, - mergeAttrs: false, - explicitRoot: false, - validator: null, - xmlns: false, - explicitChildren: false, - childkey: '@@', - charsAsChildren: false, - includeWhiteChars: false, - async: false, - strict: true, - attrNameProcessors: null, - attrValueProcessors: null, - tagNameProcessors: null, - valueProcessors: null, - emptyTag: '' - }, - "0.2": { - explicitCharkey: false, - trim: false, - normalize: false, - normalizeTags: false, - attrkey: "$", - charkey: "_", - explicitArray: true, - ignoreAttrs: false, - mergeAttrs: false, - explicitRoot: true, - validator: null, - xmlns: false, - explicitChildren: false, - preserveChildrenOrder: false, - childkey: '$$', - charsAsChildren: false, - includeWhiteChars: false, - async: false, - strict: true, - attrNameProcessors: null, - attrValueProcessors: null, - tagNameProcessors: null, - valueProcessors: null, - rootName: 'root', - xmldec: { - 'version': '1.0', - 'encoding': 'UTF-8', - 'standalone': true - }, - doctype: null, - renderOpts: { - 'pretty': true, - 'indent': ' ', - 'newline': '\n' - }, - headless: false, - chunkSize: 10000, - emptyTag: '', - cdata: false - } - }; - - exports.ValidationError = (function(superClass) { - extend(ValidationError, superClass); - - function ValidationError(message) { - this.message = message; - } - - return ValidationError; - - })(Error); - - exports.Builder = (function() { - function Builder(opts) { - var key, ref, value; - this.options = {}; - ref = exports.defaults["0.2"]; - for (key in ref) { - if (!hasProp.call(ref, key)) continue; - value = ref[key]; - this.options[key] = value; - } - for (key in opts) { - if (!hasProp.call(opts, key)) continue; - value = opts[key]; - this.options[key] = value; - } - } - - Builder.prototype.buildObject = function(rootObj) { - var attrkey, charkey, render, rootElement, rootName; - attrkey = this.options.attrkey; - charkey = this.options.charkey; - if ((Object.keys(rootObj).length === 1) && (this.options.rootName === exports.defaults['0.2'].rootName)) { - rootName = Object.keys(rootObj)[0]; - rootObj = rootObj[rootName]; - } else { - rootName = this.options.rootName; - } - render = (function(_this) { - return function(element, obj) { - var attr, child, entry, index, key, value; - if (typeof obj !== 'object') { - if (_this.options.cdata && requiresCDATA(obj)) { - element.raw(wrapCDATA(obj)); - } else { - element.txt(obj); - } - } else { - for (key in obj) { - if (!hasProp.call(obj, key)) continue; - child = obj[key]; - if (key === attrkey) { - if (typeof child === "object") { - for (attr in child) { - value = child[attr]; - element = element.att(attr, value); - } - } - } else if (key === charkey) { - if (_this.options.cdata && requiresCDATA(child)) { - element = element.raw(wrapCDATA(child)); - } else { - element = element.txt(child); - } - } else if (Array.isArray(child)) { - for (index in child) { - if (!hasProp.call(child, index)) continue; - entry = child[index]; - if (typeof entry === 'string') { - if (_this.options.cdata && requiresCDATA(entry)) { - element = element.ele(key).raw(wrapCDATA(entry)).up(); - } else { - element = element.ele(key, entry).up(); - } - } else { - element = render(element.ele(key), entry).up(); - } - } - } else if (typeof child === "object") { - element = render(element.ele(key), child).up(); - } else { - if (typeof child === 'string' && _this.options.cdata && requiresCDATA(child)) { - element = element.ele(key).raw(wrapCDATA(child)).up(); - } else { - if (child == null) { - child = ''; - } - element = element.ele(key, child.toString()).up(); - } - } - } - } - return element; - }; - })(this); - rootElement = builder.create(rootName, this.options.xmldec, this.options.doctype, { - headless: this.options.headless, - allowSurrogateChars: this.options.allowSurrogateChars - }); - return render(rootElement, rootObj).end(this.options.renderOpts); - }; - - return Builder; - - })(); - - exports.Parser = (function(superClass) { - extend(Parser, superClass); - - function Parser(opts) { - this.parseString = bind(this.parseString, this); - this.reset = bind(this.reset, this); - this.assignOrPush = bind(this.assignOrPush, this); - this.processAsync = bind(this.processAsync, this); - var key, ref, value; - if (!(this instanceof exports.Parser)) { - return new exports.Parser(opts); - } - this.options = {}; - ref = exports.defaults["0.2"]; - for (key in ref) { - if (!hasProp.call(ref, key)) continue; - value = ref[key]; - this.options[key] = value; - } - for (key in opts) { - if (!hasProp.call(opts, key)) continue; - value = opts[key]; - this.options[key] = value; - } - if (this.options.xmlns) { - this.options.xmlnskey = this.options.attrkey + "ns"; - } - if (this.options.normalizeTags) { - if (!this.options.tagNameProcessors) { - this.options.tagNameProcessors = []; - } - this.options.tagNameProcessors.unshift(processors.normalize); - } - this.reset(); - } - - Parser.prototype.processAsync = function() { - var chunk, err, error1; - try { - if (this.remaining.length <= this.options.chunkSize) { - chunk = this.remaining; - this.remaining = ''; - this.saxParser = this.saxParser.write(chunk); - return this.saxParser.close(); - } else { - chunk = this.remaining.substr(0, this.options.chunkSize); - this.remaining = this.remaining.substr(this.options.chunkSize, this.remaining.length); - this.saxParser = this.saxParser.write(chunk); - return setImmediate(this.processAsync); - } - } catch (error1) { - err = error1; - if (!this.saxParser.errThrown) { - this.saxParser.errThrown = true; - return this.emit(err); - } - } - }; - - Parser.prototype.assignOrPush = function(obj, key, newValue) { - if (!(key in obj)) { - if (!this.options.explicitArray) { - return obj[key] = newValue; - } else { - return obj[key] = [newValue]; - } - } else { - if (!(obj[key] instanceof Array)) { - obj[key] = [obj[key]]; - } - return obj[key].push(newValue); - } - }; - - Parser.prototype.reset = function() { - var attrkey, charkey, ontext, stack; - this.removeAllListeners(); - this.saxParser = sax.parser(this.options.strict, { - trim: false, - normalize: false, - xmlns: this.options.xmlns - }); - this.saxParser.errThrown = false; - this.saxParser.onerror = (function(_this) { - return function(error) { - _this.saxParser.resume(); - if (!_this.saxParser.errThrown) { - _this.saxParser.errThrown = true; - return _this.emit("error", error); - } - }; - })(this); - this.saxParser.onend = (function(_this) { - return function() { - if (!_this.saxParser.ended) { - _this.saxParser.ended = true; - return _this.emit("end", _this.resultObject); - } - }; - })(this); - this.saxParser.ended = false; - this.EXPLICIT_CHARKEY = this.options.explicitCharkey; - this.resultObject = null; - stack = []; - attrkey = this.options.attrkey; - charkey = this.options.charkey; - this.saxParser.onopentag = (function(_this) { - return function(node) { - var key, newValue, obj, processedKey, ref; - obj = {}; - obj[charkey] = ""; - if (!_this.options.ignoreAttrs) { - ref = node.attributes; - for (key in ref) { - if (!hasProp.call(ref, key)) continue; - if (!(attrkey in obj) && !_this.options.mergeAttrs) { - obj[attrkey] = {}; - } - newValue = _this.options.attrValueProcessors ? processName(_this.options.attrValueProcessors, node.attributes[key]) : node.attributes[key]; - processedKey = _this.options.attrNameProcessors ? processName(_this.options.attrNameProcessors, key) : key; - if (_this.options.mergeAttrs) { - _this.assignOrPush(obj, processedKey, newValue); - } else { - obj[attrkey][processedKey] = newValue; - } - } - } - obj["#name"] = _this.options.tagNameProcessors ? processName(_this.options.tagNameProcessors, node.name) : node.name; - if (_this.options.xmlns) { - obj[_this.options.xmlnskey] = { - uri: node.uri, - local: node.local - }; - } - return stack.push(obj); - }; - })(this); - this.saxParser.onclosetag = (function(_this) { - return function() { - var cdata, emptyStr, err, error1, key, node, nodeName, obj, objClone, old, s, xpath; - obj = stack.pop(); - nodeName = obj["#name"]; - if (!_this.options.explicitChildren || !_this.options.preserveChildrenOrder) { - delete obj["#name"]; - } - if (obj.cdata === true) { - cdata = obj.cdata; - delete obj.cdata; - } - s = stack[stack.length - 1]; - if (obj[charkey].match(/^\s*$/) && !cdata) { - emptyStr = obj[charkey]; - delete obj[charkey]; - } else { - if (_this.options.trim) { - obj[charkey] = obj[charkey].trim(); - } - if (_this.options.normalize) { - obj[charkey] = obj[charkey].replace(/\s{2,}/g, " ").trim(); - } - obj[charkey] = _this.options.valueProcessors ? processName(_this.options.valueProcessors, obj[charkey]) : obj[charkey]; - if (Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) { - obj = obj[charkey]; - } - } - if (isEmpty(obj)) { - obj = _this.options.emptyTag !== '' ? _this.options.emptyTag : emptyStr; - } - if (_this.options.validator != null) { - xpath = "/" + ((function() { - var i, len, results; - results = []; - for (i = 0, len = stack.length; i < len; i++) { - node = stack[i]; - results.push(node["#name"]); - } - return results; - })()).concat(nodeName).join("/"); - try { - obj = _this.options.validator(xpath, s && s[nodeName], obj); - } catch (error1) { - err = error1; - _this.emit("error", err); - } - } - if (_this.options.explicitChildren && !_this.options.mergeAttrs && typeof obj === 'object') { - if (!_this.options.preserveChildrenOrder) { - node = {}; - if (_this.options.attrkey in obj) { - node[_this.options.attrkey] = obj[_this.options.attrkey]; - delete obj[_this.options.attrkey]; - } - if (!_this.options.charsAsChildren && _this.options.charkey in obj) { - node[_this.options.charkey] = obj[_this.options.charkey]; - delete obj[_this.options.charkey]; - } - if (Object.getOwnPropertyNames(obj).length > 0) { - node[_this.options.childkey] = obj; - } - obj = node; - } else if (s) { - s[_this.options.childkey] = s[_this.options.childkey] || []; - objClone = {}; - for (key in obj) { - if (!hasProp.call(obj, key)) continue; - objClone[key] = obj[key]; - } - s[_this.options.childkey].push(objClone); - delete obj["#name"]; - if (Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) { - obj = obj[charkey]; - } - } - } - if (stack.length > 0) { - return _this.assignOrPush(s, nodeName, obj); - } else { - if (_this.options.explicitRoot) { - old = obj; - obj = {}; - obj[nodeName] = old; - } - _this.resultObject = obj; - _this.saxParser.ended = true; - return _this.emit("end", _this.resultObject); - } - }; - })(this); - ontext = (function(_this) { - return function(text) { - var charChild, s; - s = stack[stack.length - 1]; - if (s) { - s[charkey] += text; - if (_this.options.explicitChildren && _this.options.preserveChildrenOrder && _this.options.charsAsChildren && (_this.options.includeWhiteChars || text.replace(/\\n/g, '').trim() !== '')) { - s[_this.options.childkey] = s[_this.options.childkey] || []; - charChild = { - '#name': '__text__' - }; - charChild[charkey] = text; - if (_this.options.normalize) { - charChild[charkey] = charChild[charkey].replace(/\s{2,}/g, " ").trim(); - } - s[_this.options.childkey].push(charChild); - } - return s; - } - }; - })(this); - this.saxParser.ontext = ontext; - return this.saxParser.oncdata = (function(_this) { - return function(text) { - var s; - s = ontext(text); - if (s) { - return s.cdata = true; - } - }; - })(this); - }; - - Parser.prototype.parseString = function(str, cb) { - var err, error1; - if ((cb != null) && typeof cb === "function") { - this.on("end", function(result) { - this.reset(); - return cb(null, result); - }); - this.on("error", function(err) { - this.reset(); - return cb(err); - }); - } - try { - str = str.toString(); - if (str.trim() === '') { - this.emit("end", null); - return true; - } - str = bom.stripBOM(str); - if (this.options.async) { - this.remaining = str; - setImmediate(this.processAsync); - return this.saxParser; - } - return this.saxParser.write(str).close(); - } catch (error1) { - err = error1; - if (!(this.saxParser.errThrown || this.saxParser.ended)) { - this.emit('error', err); - return this.saxParser.errThrown = true; - } else if (this.saxParser.ended) { - throw err; - } - } - }; - - return Parser; - - })(events.EventEmitter); - - exports.parseString = function(str, a, b) { - var cb, options, parser; - if (b != null) { - if (typeof b === 'function') { - cb = b; - } - if (typeof a === 'object') { - options = a; - } - } else { - if (typeof a === 'function') { - cb = a; - } - options = {}; - } - parser = new exports.Parser(options); - return parser.parseString(str, cb); - }; - -}).call(this); - - -/***/ }), -/* 79 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {;(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', - 'opentagstart', - '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 = __webpack_require__(80).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 = __webpack_require__(31).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) - } - - // this really needs to be replaced with character classes. - // XML allows all manner of ridiculous numbers and digits. - 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 } - - // 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-]/ - - function isWhitespace (c) { - return c === ' ' || c === '\n' || c === '\r' || c === '\t' - } - - function isQuote (c) { - return c === '"' || c === '\'' - } - - function isAttribEnd (c) { - return c === '>' || isWhitespace(c) - } - - function isMatch (regex, c) { - return regex.test(c) - } - - function notMatch (regex, c) { - return !isMatch(regex, 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++, //