From 9bb221dcff20a3ca44cd53e8f6015fa653a96b20 Mon Sep 17 00:00:00 2001 From: carsonxu <459452372@qq.com> Date: Tue, 4 Jul 2017 22:16:39 +0800 Subject: [PATCH] update --- demo/demo.js | 390 ++++++++---- demo/index.html | 2 +- dist/cos-js-sdk-v5.js | 9 +- dist/cos-js-sdk-v5.js.map | 1 - lib/request.js | 34 +- package.json | 2 +- src/advance.js | 121 ++-- src/base.js | 1192 ++++++++++++++++--------------------- src/util.js | 50 +- webpack.config.js | 1 - 10 files changed, 895 insertions(+), 907 deletions(-) delete mode 100644 dist/cos-js-sdk-v5.js.map diff --git a/demo/demo.js b/demo/demo.js index 8d82584..dcb1c90 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -26,27 +26,37 @@ var cos = new COS({ }); var pre = document.querySelector('.result'); -var log = { - info: function (text, color) { - console.log(text); - if (typeof text === 'object') { - try { - text = JSON.stringify(text); - } catch (e) { - } +var logger = function (text, color) { + if (typeof text === 'object') { + try { + text = JSON.stringify(text); + } catch (e) { } - var div = document.createElement('div'); - div.innerText = text; - color && (div.style.color = color); - pre.append(div); - pre.style.display = 'block'; - pre.scrollTop = pre.scrollHeight; - }, - error: function (text) { - log.info(text, 'red'); - }, + } + var div = document.createElement('div'); + div.innerText = text; + color && (div.style.color = color); + pre.append(div); + pre.style.display = 'block'; + pre.scrollTop = pre.scrollHeight; +}; +console._log = console.log; +console._error = console.error; +console.log = function (text) { + console._log.apply(console._log, arguments); + logger(text); +}; +console.error = function (text) { + console._error.apply(console._error, arguments); + logger(text, 'red'); }; +function getService() { + cos.getService(function (err, data) { + return console.log(err || data); + }); +} + function getAuth() { var AppId = config.AppId; var Bucket = config.Bucket; @@ -60,7 +70,17 @@ function getAuth() { method: 'get', pathname: '/' + key }, function (auth) { - log.info('http://' + Bucket + '-' + AppId + '.' + config.Region + '.myqcloud.com' + '/' + key + '?sign=' + encodeURIComponent(auth)); + console.log('http://' + Bucket + '-' + AppId + '.' + config.Region + '.myqcloud.com' + '/' + key + '?sign=' + encodeURIComponent(auth)); + }); +} + +function putBucket() { + cos.putBucket({ + Bucket: 'testnew', + Region: config.Region + }, function (err, data) { + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } @@ -69,10 +89,8 @@ function getBucket() { Bucket: config.Bucket, Region: config.Region }, function (err, data) { - if (err) { - return log.error(err); - } - log.info(JSON.stringify(data, null, ' ')); + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } @@ -81,10 +99,8 @@ function headBucket() { Bucket: config.Bucket, Region: config.Region }, function (err, data) { - if (err) { - return log.error(err); - } - log.info(JSON.stringify(data, null, ' ')); + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } @@ -97,12 +113,21 @@ function putBucketACL() { // GrantRead: 'uin="1001", uin="1002"', // ACL: 'public-read-write', // ACL: 'public-read', - ACL: 'private' - }, function (err, data) { - if (err) { - return log.error(err); + // ACL: 'private', + AccessControlPolicy: { + "Owner": { + "ID": 'qcs::cam::uin/459452372:uin/459452372' // 459452372 是 QQ 号 + }, + "Grants": [{ + "Grantee": { + "ID": "qcs::cam::uin/10002:uin/10002", // 10002 是 QQ 号 + }, + "Permission": "READ" + }] } - log.info(JSON.stringify(data, null, ' ')); + }, function (err, data) { + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } @@ -111,30 +136,27 @@ function getBucketACL() { Bucket: config.Bucket, Region: config.Region }, function (err, data) { - if (err) { - return log.error(err); - } - log.info(data.AccessControlList.Grant); + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } function putBucketCORS() { - // 该接口存在问题,Content-MD5 错误 cos.putBucketCORS({ Bucket: config.Bucket, Region: config.Region, - CORSRules: [{ - "AllowedOrigin": ["*"], - "AllowedMethod": ["GET", "POST", "PUT", "DELETE", "HEAD"], - "AllowedHeader": ["origin", "accept", "content-type", "authorzation"], - "ExposeHeader": ["ETag"], - "MaxAgeSeconds": "600" - }] - }, function (err, data) { - if (err) { - return log.error(err); + CORSConfiguration: { + CORSRule: [{ + "AllowedOrigin": ["*"], + "AllowedMethod": ["GET", "POST", "PUT", "DELETE", "HEAD"], + "AllowedHeader": ["origin", "accept", "content-type", "authorzation"], + "ExposeHeader": ["ETag"], + "MaxAgeSeconds": "600" + }] } - log.info(JSON.stringify(data, null, ' ')); + }, function (err, data) { + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } @@ -143,10 +165,54 @@ function getBucketCORS() { Bucket: config.Bucket, Region: config.Region }, function (err, data) { - if (err) { - return log.error(err); + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); + }); +} + +function deleteBucketCORS() { + cos.deleteBucketCORS({ + Bucket: config.Bucket, + Region: config.Region + }, function (err, data) { + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); + }); +} + +function putBucketTagging() { + cos.putBucketTagging({ + Bucket: config.Bucket, + Region: config.Region, + Tagging: { + TagSet: [ + {Key: "k1", Value: "v1"}, + {Key: "k2", Value: "v2"} + ] } - log.info(JSON.stringify(data, null, ' ')); + }, function (err, data) { + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); + }); +} + +function getBucketTagging() { + cos.getBucketTagging({ + Bucket: config.Bucket, + Region: config.Region + }, function (err, data) { + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); + }); +} + +function deleteBucketTagging() { + cos.deleteBucketTagging({ + Bucket: config.Bucket, + Region: config.Region + }, function (err, data) { + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } @@ -161,7 +227,7 @@ function putBucketPolicy() { cos.putBucketPolicy({ Policy: { "version": "2.0", - "principal": {"qcs": ["qcs::cam::uin/909600000:uin/909600000"]}, // 这里的 909600000 是 QQ 号 + "principal": {"qcs": ["qcs::cam::uin/10001:uin/10001"]}, // 这里的 10001 是 QQ 号 "statement": [ { "effect": "allow", @@ -185,11 +251,18 @@ function putBucketPolicy() { Bucket: config.Bucket, Region: config.Region }, function (err, data) { - if (err) { - log.error(err); - } else { - getBucketPolicy(); - } + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); + }); +} + +function getBucketPolicy() { + cos.getBucketPolicy({ + Bucket: config.Bucket, + Region: config.Region + }, function (err, data) { + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } @@ -198,54 +271,78 @@ function getBucketLocation() { Bucket: config.Bucket, Region: config.Region }, function (err, data) { - if (err) { - return log.error(err); + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); + }); +} + +function putBucketLifecycle() { + cos.putBucketLifecycle({ + Bucket: config.Bucket, + Region: config.Region, + LifecycleConfiguration: { + Rules: [{ + 'ID': 1, + 'Prefix': 'test', + 'Status': 'Enabled', + 'Transition': { + 'Date': '2016-10-31T00:00:00+08:00', + 'StorageClass': 'Standard_IA' + } + }] } - log.info(JSON.stringify(data, null, ' ')); + }, function (err, data) { + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } -function deleteBucket() { - cos.deleteBucket({ - Bucket: 'testnew', +function getBucketLifecycle() { + cos.getBucketLifecycle({ + Bucket: config.Bucket, Region: config.Region }, function (err, data) { - if (err) { - return log.error(err); - } - log.info(JSON.stringify(data, null, ' ')); + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } -function getBucketPolicy() { - cos.getBucketPolicy({ +function deleteBucketLifecycle() { + cos.deleteBucketLifecycle({ Bucket: config.Bucket, Region: config.Region }, function (err, data) { - if (err) { - log.error(err); - } else { - log.info(JSON.stringify(data, null, ' ')); - } + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); + }); +} + +function deleteBucket() { + cos.deleteBucket({ + Bucket: 'testnew', + Region: config.Region + }, function (err, data) { + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } function putObject() { + // 创建测试文件 + var filename = '1mb.zip'; var blob = util.createFile({type: 'image/png', size: 1024 * 1024}); + // 调用方法 cos.putObject({ - Bucket: config.Bucket, + Bucket: config.Bucket, /* 必须 */ Region: config.Region, - Key: '1mb.zip', - Body: blob, + Key: filename, /* 必须 */ onProgress: function (progressData) { - log.info(JSON.stringify(progressData)); + console.log(JSON.stringify(progressData)); }, + Body: blob }, function (err, data) { - if (err) { - log.error(err); - } else { - log.info(JSON.stringify(data, null, ' ')); - } + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } @@ -263,11 +360,8 @@ function putObjectCopy() { Key: '1mb.copy.zip', CopySource: Bucket + '-' + AppId + '.' + config.Region + '.myqcloud.com/1mb.zip', }, function (err, data) { - if (err) { - log.error(err); - } else { - log.info(JSON.stringify(data, null, ' ')); - } + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } @@ -277,10 +371,8 @@ function getObject() { Region: config.Region, Key: '1mb.zip' }, function (err, data) { - if (err) { - return log.error(err); - } - log.info(JSON.stringify(data, null, ' ')); + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } @@ -290,10 +382,8 @@ function headObject() { Region: config.Region, Key: '1mb.zip' }, function (err, data) { - if (err) { - return log.error(err); - } - log.info(JSON.stringify(data, null, ' ')); + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } @@ -307,12 +397,21 @@ function putObjectACL() { // GrantRead: 'uin="1001", uin="1002"', // ACL: 'public-read-write', // ACL: 'public-read', - ACL: 'private' - }, function (err, data) { - if (err) { - return log.error(err); + // ACL: 'private', + AccessControlPolicy: { + "Owner": { + "ID": 'qcs::cam::uin/10001:uin/10001' // 10001 是 QQ 号 + }, + "Grants": [{ + "Grantee": { + "ID": "qcs::cam::uin/10002:uin/10002", // 10002 是 QQ 号 + }, + "Permission": "READ" + }] } - log.info(JSON.stringify(data, null, ' ')); + }, function (err, data) { + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } @@ -322,10 +421,8 @@ function getObjectACL() { Region: config.Region, Key: '1mb.zip' }, function (err, data) { - if (err) { - return log.error(err); - } - log.info(JSON.stringify(data, null, ' ')); + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } @@ -335,11 +432,8 @@ function deleteObject() { Region: config.Region, Key: '1mb.zip' }, function (err, data) { - if (err) { - return log.error(err); - } - - log.info(JSON.stringify(data, null, ' ')); + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } @@ -352,10 +446,8 @@ function deleteMultipleObject() { {Key: '3mb.zip'}, ] }, function (err, data) { - if (err) { - return log.error(err); - } - log.info(JSON.stringify(data, null, ' ')); + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } @@ -363,14 +455,18 @@ function abortUploadTask() { cos.abortUploadTask({ Bucket: config.Bucket, /* 必须 */ Region: config.Region, /* 必须 */ + // 格式1,删除单个上传任务 + // Level: 'task', + // Key: '10mb.zip', + // UploadId: '14985543913e4e2642e31db217b9a1a3d9b3cd6cf62abfda23372c8d36ffa38585492681e3', + // 格式2,删除单个文件所有未完成上传任务 + Level: 'file', Key: '10mb.zip', - Level: 'bucket', + // 格式3,删除 Bucket 下所有未完成上传任务 + // Level: 'bucket', }, function (err, data) { - if (err) { - log.error(err); - } else { - log.info(JSON.stringify(data, null, ' ')); - } + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } @@ -384,39 +480,77 @@ function sliceUploadFile() { AsyncLimit: 3, /* 非必须 */ Body: blob, onHashProgress: function (progressData) { - log.info(JSON.stringify(progressData)); + console.log(JSON.stringify(progressData)); }, onProgress: function (progressData) { - log.info(JSON.stringify(progressData)); + console.log(JSON.stringify(progressData)); }, }, function (err, data) { - if (err) { - log.error(err); - } else { - log.info(JSON.stringify(data, null, ' ')); - } + if (err) return console.log(err); + console.log(JSON.stringify(data, null, ' ')); }); } +// getService(); +// getAuth(); +// putBucket(); +// getBucket(); +// headBucket(); +// putBucketACL(); +// getBucketACL(); +// putBucketCORS(); +// getBucketCORS(); +// deleteBucketCORS(); +// putBucketTagging(); +// getBucketTagging(); +// deleteBucketTagging(); +// putBucketPolicy(); +// getBucketPolicy(); +// getBucketLocation(); +// getBucketLifecycle(); +// putBucketLifecycle(); +// deleteBucketLifecycle(); +// deleteBucket(); +// putObject(); +// putObjectCopy(); +// getObject(); +// headObject(); +// putObjectACL(); +// getObjectACL(); +// deleteObject(); +// deleteMultipleObject(); +// abortUploadTask(); +// sliceUploadFile(); + + (function () { var list = [ + // 'getService', 'getAuth', + // 'putBucket', 'getBucket', 'headBucket', // 'putBucketACL', // 'getBucketACL', // 'putBucketCORS', // 'getBucketCORS', + // 'deleteBucketCORS', + // 'putBucketTagging', + // 'getBucketTagging', + // 'deleteBucketTagging', // 'putBucketPolicy', // 'getBucketPolicy', // 'getBucketLocation', + // 'getBucketLifecycle', + // 'putBucketLifecycle', + // 'deleteBucketLifecycle', 'deleteBucket', 'putObject', 'putObjectCopy', 'getObject', 'headObject', // 'putObjectACL', - 'getObjectACL', + // 'getObjectACL', 'deleteObject', // 'deleteMultipleObject', // 'abortUploadTask', diff --git a/demo/index.html b/demo/index.html index 7e3c12c..a6a0dcc 100644 --- a/demo/index.html +++ b/demo/index.html @@ -12,7 +12,7 @@ h1 { font-weight: normal; color:#333;} a { color: #006eff; background-color: transparent; padding: 8px 16px; line-height: 1.3; display: inline-block; text-align: center; margin: 0 8px 8px 0; border: 1px solid #006eff; font-size: 14px; text-decoration: none; } a:hover { color: #fff; background-color: #006eff; } - .result {display:none;line-height:1.3;font-size: 13px;font-family:monospace;border:1px solid #006eff;margin:0;min-height:100px;max-height:300px;overflow:auto;box-sizing:border-box;padding:5px;} + .result {display:none;line-height:1.3;font-size: 13px;font-family:monospace;border:1px solid #006eff;margin:0;height:200px;overflow:auto;box-sizing:border-box;padding:5px;}
diff --git a/dist/cos-js-sdk-v5.js b/dist/cos-js-sdk-v5.js index e381e99..19108f4 100644 --- a/dist/cos-js-sdk-v5.js +++ b/dist/cos-js-sdk-v5.js @@ -1,12 +1,11 @@ -!function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/dist/",e(e.s=71)}([function(t,e,n){function r(t,e){var n=o(t);return null==e?n:i(n,e)}var i=n(116),o=n(117);t.exports=r},function(t,e){function n(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}t.exports=n},function(t,e){var n=Array.isArray;t.exports=n},function(t,e,n){var r=n(52),i="object"==typeof self&&self&&self.Object===Object&&self,o=r||i||Function("return this")();t.exports=o},function(t,e,n){"use strict";function r(t){if(!(this instanceof r))return new r(t);c.call(this,t),l.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",i)}function i(){this.allowHalfOpen||this._writableState.ended||a(o,this)}function o(t){t.end()}var a=n(17),s=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};t.exports=r;var u=n(11);u.inherits=n(6);var c=n(45),l=n(30);u.inherits(r,c);for(var f=s(l.prototype),p=0;p",o&&(a+=r),a},t}()}).call(this)},function(t,e,n){(function(){var e,r,i=function(t,e){function n(){this.constructor=t}for(var r in e)o.call(e,r)&&(t[r]=e[r]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},o={}.hasOwnProperty;r=n(0),e=n(8),t.exports=function(t){function e(t,n){if(e.__super__.constructor.call(this,t),null==n)throw new Error("Missing CDATA text");this.text=this.stringify.cdata(n)}return i(e,t),e.prototype.clone=function(){return r(e.prototype,this)},e.prototype.toString=function(t,e){var n,r,i,o,a,s,u,c,l;return o=(null!=t?t.pretty:void 0)||!1,n=null!=(s=null!=t?t.indent:void 0)?s:" ",i=null!=(u=null!=t?t.offset:void 0)?u:0,r=null!=(c=null!=t?t.newline:void 0)?c:"\n",e||(e=0),l=new Array(e+i+1).join(n),a="",o&&(a+=l),a+="",o&&(a+=r),a},e}(e)}).call(this)},function(t,e,n){(function(){var e,r,i=function(t,e){function n(){this.constructor=t}for(var r in e)o.call(e,r)&&(t[r]=e[r]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},o={}.hasOwnProperty;r=n(0),e=n(8),t.exports=function(t){function e(t,n){if(e.__super__.constructor.call(this,t),null==n)throw new Error("Missing comment text");this.text=this.stringify.comment(n)}return i(e,t),e.prototype.clone=function(){return r(e.prototype,this)},e.prototype.toString=function(t,e){var n,r,i,o,a,s,u,c,l;return o=(null!=t?t.pretty:void 0)||!1,n=null!=(s=null!=t?t.indent:void 0)?s:" ",i=null!=(u=null!=t?t.offset:void 0)?u:0,r=null!=(c=null!=t?t.newline:void 0)?c:"\n",e||(e=0),l=new Array(e+i+1).join(n),a="",o&&(a+=l),a+="\x3c!-- "+this.text+" --\x3e",o&&(a+=r),a},e}(e)}).call(this)},function(t,e,n){(function(){var e,r,i,o,a,s,u,c;n(0),c=n(1),e=n(68),r=n(69),i=n(189),a=n(190),o=n(191),s=n(192),u=n(67),t.exports=function(){function t(t,e,n){var r,i;this.documentObject=t,this.stringify=this.documentObject.stringify,this.children=[],c(e)&&(r=e,e=r.pubID,n=r.sysID),null==n&&(i=[e,n],n=i[0],e=i[1]),null!=e&&(this.pubID=this.stringify.dtdPubID(e)),null!=n&&(this.sysID=this.stringify.dtdSysID(n))}return t.prototype.element=function(t,e){var n;return n=new o(this,t,e),this.children.push(n),this},t.prototype.attList=function(t,e,n,r,o){var a;return a=new i(this,t,e,n,r,o),this.children.push(a),this},t.prototype.entity=function(t,e){var n;return n=new a(this,!1,t,e),this.children.push(n),this},t.prototype.pEntity=function(t,e){var n;return n=new a(this,!0,t,e),this.children.push(n),this},t.prototype.notation=function(t,e){var n;return n=new s(this,t,e),this.children.push(n),this},t.prototype.cdata=function(t){var n;return n=new e(this,t),this.children.push(n),this},t.prototype.comment=function(t){var e;return e=new r(this,t),this.children.push(e),this},t.prototype.instruction=function(t,e){var n;return n=new u(this,t,e),this.children.push(n),this},t.prototype.root=function(){return this.documentObject.root()},t.prototype.document=function(){return this.documentObject},t.prototype.toString=function(t,e){var n,r,i,o,a,s,u,c,l,f,p,h,d;if(u=(null!=t?t.pretty:void 0)||!1,i=null!=(l=null!=t?t.indent:void 0)?l:" ",s=null!=(f=null!=t?t.offset:void 0)?f:0,a=null!=(p=null!=t?t.newline:void 0)?p:"\n",e||(e=0),d=new Array(e+s+1).join(i),c="",u&&(c+=d),c+="0){for(c+=" [",u&&(c+=a),h=this.children,r=0,o=h.length;r ",o&&(a+=r),a},t}()}).call(this)},function(t,e,n){(function(){var e,r,i=function(t,e){function n(){this.constructor=t}for(var r in e)o.call(e,r)&&(t[r]=e[r]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},o={}.hasOwnProperty;r=n(0),e=n(9),t.exports=function(t){function e(t,n){if(e.__super__.constructor.call(this,t),null==n)throw new Error("Missing CDATA text");this.text=this.stringify.cdata(n)}return i(e,t),e.prototype.clone=function(){return r(e.prototype,this)},e.prototype.toString=function(t,e){var n,r,i,o,a,s,u,c,l;return o=(null!=t?t.pretty:void 0)||!1,n=null!=(s=null!=t?t.indent:void 0)?s:" ",i=null!=(u=null!=t?t.offset:void 0)?u:0,r=null!=(c=null!=t?t.newline:void 0)?c:"\n",e||(e=0),l=new Array(e+i+1).join(n),a="",o&&(a+=l),a+="",o&&(a+=r),a},e}(e)}).call(this)},function(t,e,n){(function(){var e,r,i=function(t,e){function n(){this.constructor=t}for(var r in e)o.call(e,r)&&(t[r]=e[r]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},o={}.hasOwnProperty;r=n(0),e=n(9),t.exports=function(t){function e(t,n){if(e.__super__.constructor.call(this,t),null==n)throw new Error("Missing comment text");this.text=this.stringify.comment(n)}return i(e,t),e.prototype.clone=function(){return r(e.prototype,this)},e.prototype.toString=function(t,e){var n,r,i,o,a,s,u,c,l;return o=(null!=t?t.pretty:void 0)||!1,n=null!=(s=null!=t?t.indent:void 0)?s:" ",i=null!=(u=null!=t?t.offset:void 0)?u:0,r=null!=(c=null!=t?t.newline:void 0)?c:"\n",e||(e=0),l=new Array(e+i+1).join(n),a="",o&&(a+=l),a+="\x3c!-- "+this.text+" --\x3e",o&&(a+=r),a},e}(e)}).call(this)},function(t,e,n){(function(){var e,r,i,o,a,s,u,c;n(0),c=n(1),e=n(68),r=n(69),i=n(189),a=n(190),o=n(191),s=n(192),u=n(67),t.exports=function(){function t(t,e,n){var r,i;this.documentObject=t,this.stringify=this.documentObject.stringify,this.children=[],c(e)&&(r=e,e=r.pubID,n=r.sysID),null==n&&(i=[e,n],n=i[0],e=i[1]),null!=e&&(this.pubID=this.stringify.dtdPubID(e)),null!=n&&(this.sysID=this.stringify.dtdSysID(n))}return t.prototype.element=function(t,e){var n;return n=new o(this,t,e),this.children.push(n),this},t.prototype.attList=function(t,e,n,r,o){var a;return a=new i(this,t,e,n,r,o),this.children.push(a),this},t.prototype.entity=function(t,e){var n;return n=new a(this,!1,t,e),this.children.push(n),this},t.prototype.pEntity=function(t,e){var n;return n=new a(this,!0,t,e),this.children.push(n),this},t.prototype.notation=function(t,e){var n;return n=new s(this,t,e),this.children.push(n),this},t.prototype.cdata=function(t){var n;return n=new e(this,t),this.children.push(n),this},t.prototype.comment=function(t){var e;return e=new r(this,t),this.children.push(e),this},t.prototype.instruction=function(t,e){var n;return n=new u(this,t,e),this.children.push(n),this},t.prototype.root=function(){return this.documentObject.root()},t.prototype.document=function(){return this.documentObject},t.prototype.toString=function(t,e){var n,r,i,o,a,s,u,c,l,f,p,h,d;if(u=(null!=t?t.pretty:void 0)||!1,i=null!=(l=null!=t?t.indent:void 0)?l:" ",s=null!=(f=null!=t?t.offset:void 0)?f:0,a=null!=(p=null!=t?t.newline:void 0)?p:"\n",e||(e=0),d=new Array(e+s+1).join(i),c="",u&&(c+=d),c+="0){for(c+=" [",u&&(c+=a),h=this.children,r=0,o=h.length;r0&&c>u&&(c=u);for(var l=0;l=0:I.find(n,this,null,[u]).length),i[n]&&i.push(r);i.length&&a.push({elem:u,handlers:i})}return s=0:I.find(n,this,null,[u]).length),i[n]&&i.push(r);i.length&&a.push({elem:u,handlers:i})}return s