(window["webpackjsonp"] = window["webpackjsonp"] || []).push([[65],{
/***/ 1:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export countbits */
/* unused harmony export countbytes */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return padstart; });
/* unused harmony export istypedarray */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return touint8; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return tohexstring; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return tobinarystring; });
/* unused harmony export endianness */
/* unused harmony export is_big_endian */
/* unused harmony export is_little_endian */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return bytestonumber; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return numbertobytes; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return bytestostring; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return stringtobytes; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return concattypedarrays; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return bytesmatch; });
/* unused harmony export slicebytes */
/* unused harmony export reversebytes */
/* harmony import */ var global_window__webpack_imported_module_0__ = __webpack_require__(0);
/* harmony import */ var global_window__webpack_imported_module_0___default = /*#__pure__*/__webpack_require__.n(global_window__webpack_imported_module_0__);
// const log2 = math.log2 ? math.log2 : (x) => (math.log(x) / math.log(2));
var repeat = function repeat(str, len) {
var acc = '';
while (len--) {
acc += str;
}
return acc;
}; // count the number of bits it would take to represent a number
// we used to do this with log2 but bigint does not support builtin math
// math.ceil(log2(x));
var countbits = function countbits(x) {
return x.tostring(2).length;
}; // count the number of whole bytes it would take to represent a number
var countbytes = function countbytes(x) {
return math.ceil(countbits(x) / 8);
};
var padstart = function padstart(b, len, str) {
if (str === void 0) {
str = ' ';
}
return (repeat(str, len) + b.tostring()).slice(-len);
};
var istypedarray = function istypedarray(obj) {
return arraybuffer.isview(obj);
};
var touint8 = function touint8(bytes) {
if (bytes instanceof uint8array) {
return bytes;
}
if (!array.isarray(bytes) && !istypedarray(bytes) && !(bytes instanceof arraybuffer)) {
// any non-number or nan leads to empty uint8array
// eslint-disable-next-line
if (typeof bytes !== 'number' || typeof bytes === 'number' && bytes !== bytes) {
bytes = 0;
} else {
bytes = [bytes];
}
}
return new uint8array(bytes && bytes.buffer || bytes, bytes && bytes.byteoffset || 0, bytes && bytes.bytelength || 0);
};
var tohexstring = function tohexstring(bytes) {
bytes = touint8(bytes);
var str = '';
for (var i = 0; i < bytes.length; i++) {
str += padstart(bytes[i].tostring(16), 2, '0');
}
return str;
};
var tobinarystring = function tobinarystring(bytes) {
bytes = touint8(bytes);
var str = '';
for (var i = 0; i < bytes.length; i++) {
str += padstart(bytes[i].tostring(2), 8, '0');
}
return str;
};
var bigint = global_window__webpack_imported_module_0___default.a.bigint || number;
var byte_table = [bigint('0x1'), bigint('0x100'), bigint('0x10000'), bigint('0x1000000'), bigint('0x100000000'), bigint('0x10000000000'), bigint('0x1000000000000'), bigint('0x100000000000000'), bigint('0x10000000000000000')];
var endianness = function () {
var a = new uint16array([0xffcc]);
var b = new uint8array(a.buffer, a.byteoffset, a.bytelength);
if (b[0] === 0xff) {
return 'big';
}
if (b[0] === 0xcc) {
return 'little';
}
return 'unknown';
}();
var is_big_endian = endianness === 'big';
var is_little_endian = endianness === 'little';
var bytestonumber = function bytestonumber(bytes, _temp) {
var _ref = _temp === void 0 ? {} : _temp,
_ref$signed = _ref.signed,
signed = _ref$signed === void 0 ? false : _ref$signed,
_ref$le = _ref.le,
le = _ref$le === void 0 ? false : _ref$le;
bytes = touint8(bytes);
var fn = le ? 'reduce' : 'reduceright';
var obj = bytes[fn] ? bytes[fn] : array.prototype[fn];
var number = obj.call(bytes, function (total, byte, i) {
var exponent = le ? i : math.abs(i + 1 - bytes.length);
return total + bigint(byte) * byte_table[exponent];
}, bigint(0));
if (signed) {
var max = byte_table[bytes.length] / bigint(2) - bigint(1);
number = bigint(number);
if (number > max) {
number -= max;
number -= max;
number -= bigint(2);
}
}
return number(number);
};
var numbertobytes = function numbertobytes(number, _temp2) {
var _ref2 = _temp2 === void 0 ? {} : _temp2,
_ref2$le = _ref2.le,
le = _ref2$le === void 0 ? false : _ref2$le;
// eslint-disable-next-line
if (typeof number !== 'bigint' && typeof number !== 'number' || typeof number === 'number' && number !== number) {
number = 0;
}
number = bigint(number);
var bytecount = countbytes(number);
var bytes = new uint8array(new arraybuffer(bytecount));
for (var i = 0; i < bytecount; i++) {
var byteindex = le ? i : math.abs(i + 1 - bytes.length);
bytes[byteindex] = number(number / byte_table[i] & bigint(0xff));
if (number < 0) {
bytes[byteindex] = math.abs(~bytes[byteindex]);
bytes[byteindex] -= i === 0 ? 1 : 2;
}
}
return bytes;
};
var bytestostring = function bytestostring(bytes) {
if (!bytes) {
return '';
} // todo: should touint8 handle cases where we only have 8 bytes
// but report more since this is a uint16+ array?
bytes = array.prototype.slice.call(bytes);
var string = string.fromcharcode.apply(null, touint8(bytes));
try {
return decodeuricomponent(escape(string));
} catch (e) {// if decodeuricomponent/escape fails, we are dealing with partial
// or full non string data. just return the potentially garbled string.
}
return string;
};
var stringtobytes = function stringtobytes(string, stringisbytes) {
if (typeof string !== 'string' && string && typeof string.tostring === 'function') {
string = string.tostring();
}
if (typeof string !== 'string') {
return new uint8array();
} // if the string already is bytes, we don't have to do this
// otherwise we do this so that we split multi length characters
// into individual bytes
if (!stringisbytes) {
string = unescape(encodeuricomponent(string));
}
var view = new uint8array(string.length);
for (var i = 0; i < string.length; i++) {
view[i] = string.charcodeat(i);
}
return view;
};
var concattypedarrays = function concattypedarrays() {
for (var _len = arguments.length, buffers = new array(_len), _key = 0; _key < _len; _key++) {
buffers[_key] = arguments[_key];
}
buffers = buffers.filter(function (b) {
return b && (b.bytelength || b.length) && typeof b !== 'string';
});
if (buffers.length <= 1) {
// for 0 length we will return empty uint8
// for 1 length we return the first uint8
return touint8(buffers[0]);
}
var totallen = buffers.reduce(function (total, buf, i) {
return total + (buf.bytelength || buf.length);
}, 0);
var tempbuffer = new uint8array(totallen);
var offset = 0;
buffers.foreach(function (buf) {
buf = touint8(buf);
tempbuffer.set(buf, offset);
offset += buf.bytelength;
});
return tempbuffer;
};
/**
* check if the bytes "b" are contained within bytes "a".
*
* @param {uint8array|array} a
* bytes to check in
*
* @param {uint8array|array} b
* bytes to check for
*
* @param {object} options
* options
*
* @param {array|uint8array} [offset=0]
* offset to use when looking at bytes in a
*
* @param {array|uint8array} [mask=[]]
* mask to use on bytes before comparison.
*
* @return {boolean}
* if all bytes in b are inside of a, taking into account
* bit masks.
*/
var bytesmatch = function bytesmatch(a, b, _temp3) {
var _ref3 = _temp3 === void 0 ? {} : _temp3,
_ref3$offset = _ref3.offset,
offset = _ref3$offset === void 0 ? 0 : _ref3$offset,
_ref3$mask = _ref3.mask,
mask = _ref3$mask === void 0 ? [] : _ref3$mask;
a = touint8(a);
b = touint8(b); // ie 11 does not support uint8 every
var fn = b.every ? b.every : array.prototype.every;
return b.length && a.length - offset >= b.length && // ie 11 doesn't support every on uin8
fn.call(b, function (bbyte, i) {
var abyte = mask[i] ? mask[i] & a[offset + i] : a[offset + i];
return bbyte === abyte;
});
};
var slicebytes = function slicebytes(src, start, end) {
if (uint8array.prototype.slice) {
return uint8array.prototype.slice.call(src, start, end);
}
return new uint8array(array.prototype.slice.call(src, start, end));
};
var reversebytes = function reversebytes(src) {
if (src.reverse) {
return src.reverse();
}
return array.prototype.reverse.call(src);
};
/***/ }),
/***/ 107:
/***/ (function(module, exports) {
function _setprototypeof(o, p) {
module.exports = _setprototypeof = object.setprototypeof || function _setprototypeof(o, p) {
o.__proto__ = p;
return o;
}, module.exports.__esmodule = true, module.exports["default"] = module.exports;
return _setprototypeof(o, p);
}
module.exports = _setprototypeof, module.exports.__esmodule = true, module.exports["default"] = module.exports;
/***/ }),
/***/ 111:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayliketoarray; });
function _arrayliketoarray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new array(len); i < len; i++) {
arr2[i] = arr[i];
}
return arr2;
}
/***/ }),
/***/ 113:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _toarray; });
/* harmony import */ var _arraywithholes_js__webpack_imported_module_0__ = __webpack_require__(86);
/* harmony import */ var _iterabletoarray_js__webpack_imported_module_1__ = __webpack_require__(156);
/* harmony import */ var _unsupportediterabletoarray_js__webpack_imported_module_2__ = __webpack_require__(85);
/* harmony import */ var _noniterablerest_js__webpack_imported_module_3__ = __webpack_require__(87);
function _toarray(arr) {
return object(_arraywithholes_js__webpack_imported_module_0__[/* default */ "a"])(arr) || object(_iterabletoarray_js__webpack_imported_module_1__[/* default */ "a"])(arr) || object(_unsupportediterabletoarray_js__webpack_imported_module_2__[/* default */ "a"])(arr) || object(_noniterablerest_js__webpack_imported_module_3__[/* default */ "a"])();
}
/***/ }),
/***/ 119:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var window = __webpack_require__(0);
var _extends = __webpack_require__(21);
var isfunction = __webpack_require__(309);
createxhr.httphandler = __webpack_require__(310);
/**
* @license
* slighly modified parse-headers 2.0.2
* copyright (c) 2014 david björklund
* available under the mit license
*
*/
var parseheaders = function parseheaders(headers) {
var result = {};
if (!headers) {
return result;
}
headers.trim().split('\n').foreach(function (row) {
var index = row.indexof(':');
var key = row.slice(0, index).trim().tolowercase();
var value = row.slice(index + 1).trim();
if (typeof result[key] === 'undefined') {
result[key] = value;
} else if (array.isarray(result[key])) {
result[key].push(value);
} else {
result[key] = [result[key], value];
}
});
return result;
};
module.exports = createxhr; // allow use of default import syntax in typescript
module.exports.default = createxhr;
createxhr.xmlhttprequest = window.xmlhttprequest || noop;
createxhr.xdomainrequest = "withcredentials" in new createxhr.xmlhttprequest() ? createxhr.xmlhttprequest : window.xdomainrequest;
foreacharray(["get", "put", "post", "patch", "head", "delete"], function (method) {
createxhr[method === "delete" ? "del" : method] = function (uri, options, callback) {
options = initparams(uri, options, callback);
options.method = method.touppercase();
return _createxhr(options);
};
});
function foreacharray(array, iterator) {
for (var i = 0; i < array.length; i++) {
iterator(array[i]);
}
}
function isempty(obj) {
for (var i in obj) {
if (obj.hasownproperty(i)) return false;
}
return true;
}
function initparams(uri, options, callback) {
var params = uri;
if (isfunction(options)) {
callback = options;
if (typeof uri === "string") {
params = {
uri: uri
};
}
} else {
params = _extends({}, options, {
uri: uri
});
}
params.callback = callback;
return params;
}
function createxhr(uri, options, callback) {
options = initparams(uri, options, callback);
return _createxhr(options);
}
function _createxhr(options) {
if (typeof options.callback === "undefined") {
throw new error("callback argument missing");
}
var called = false;
var callback = function cbonce(err, response, body) {
if (!called) {
called = true;
options.callback(err, response, body);
}
};
function readystatechange() {
if (xhr.readystate === 4) {
settimeout(loadfunc, 0);
}
}
function getbody() {
// chrome with requesttype=blob throws errors arround when even testing access to responsetext
var body = undefined;
if (xhr.response) {
body = xhr.response;
} else {
body = xhr.responsetext || getxml(xhr);
}
if (isjson) {
try {
body = json.parse(body);
} catch (e) {}
}
return body;
}
function errorfunc(evt) {
cleartimeout(timeouttimer);
if (!(evt instanceof error)) {
evt = new error("" + (evt || "unknown xmlhttprequest error"));
}
evt.statuscode = 0;
return callback(evt, failureresponse);
} // will load the data & process the response in a special response object
function loadfunc() {
if (aborted) return;
var status;
cleartimeout(timeouttimer);
if (options.usexdr && xhr.status === undefined) {
//ie8 cors get successful response doesn't have a status field, but body is fine
status = 200;
} else {
status = xhr.status === 1223 ? 204 : xhr.status;
}
var response = failureresponse;
var err = null;
if (status !== 0) {
response = {
body: getbody(),
statuscode: status,
method: method,
headers: {},
url: uri,
rawrequest: xhr
};
if (xhr.getallresponseheaders) {
//remember xhr can in fact be xdr for cors in ie
response.headers = parseheaders(xhr.getallresponseheaders());
}
} else {
err = new error("internal xmlhttprequest error");
}
return callback(err, response, response.body);
}
var xhr = options.xhr || null;
if (!xhr) {
if (options.cors || options.usexdr) {
xhr = new createxhr.xdomainrequest();
} else {
xhr = new createxhr.xmlhttprequest();
}
}
var key;
var aborted;
var uri = xhr.url = options.uri || options.url;
var method = xhr.method = options.method || "get";
var body = options.body || options.data;
var headers = xhr.headers = options.headers || {};
var sync = !!options.sync;
var isjson = false;
var timeouttimer;
var failureresponse = {
body: undefined,
headers: {},
statuscode: 0,
method: method,
url: uri,
rawrequest: xhr
};
if ("json" in options && options.json !== false) {
isjson = true;
headers["accept"] || headers["accept"] || (headers["accept"] = "application/json"); //don't override existing accept header declared by user
if (method !== "get" && method !== "head") {
headers["content-type"] || headers["content-type"] || (headers["content-type"] = "application/json"); //don't override existing accept header declared by user
body = json.stringify(options.json === true ? body : options.json);
}
}
xhr.onreadystatechange = readystatechange;
xhr.onload = loadfunc;
xhr.onerror = errorfunc; // ie9 must have onprogress be set to a unique function.
xhr.onprogress = function () {// ie must die
};
xhr.onabort = function () {
aborted = true;
};
xhr.ontimeout = errorfunc;
xhr.open(method, uri, !sync, options.username, options.password); //has to be after open
if (!sync) {
xhr.withcredentials = !!options.withcredentials;
} // cannot set timeout with sync request
// not setting timeout on the xhr object, because of old webkits etc. not handling that correctly
// both npm's request and jquery 1.x use this kind of timeout, so this is being consistent
if (!sync && options.timeout > 0) {
timeouttimer = settimeout(function () {
if (aborted) return;
aborted = true; //ie9 may still call readystatechange
xhr.abort("timeout");
var e = new error("xmlhttprequest timeout");
e.code = "etimedout";
errorfunc(e);
}, options.timeout);
}
if (xhr.setrequestheader) {
for (key in headers) {
if (headers.hasownproperty(key)) {
xhr.setrequestheader(key, headers[key]);
}
}
} else if (options.headers && !isempty(options.headers)) {
throw new error("headers cannot be set on an xdomainrequest object");
}
if ("responsetype" in options) {
xhr.responsetype = options.responsetype;
}
if ("beforesend" in options && typeof options.beforesend === "function") {
options.beforesend(xhr);
} // microsoft edge browser sends "undefined" when send is called with undefined value.
// xmlhttprequest spec says to pass null as body to indicate no body
// see https://github.com/naugtur/xhr/issues/100.
xhr.send(body || null);
return xhr;
}
function getxml(xhr) {
// xhr.responsexml will throw exception "invalidstateerror" or "domexception"
// see https://developer.mozilla.org/en-us/docs/web/api/xmlhttprequest/responsexml.
try {
if (xhr.responsetype === "document") {
return xhr.responsexml;
}
var firefoxbugtakeneffect = xhr.responsexml && xhr.responsexml.documentelement.nodename === "parsererror";
if (xhr.responsetype === "" && !firefoxbugtakeneffect) {
return xhr.responsexml;
}
} catch (e) {}
return null;
}
function noop() {}
/***/ }),
/***/ 122:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return simpletypefromsourcetype; });
var mpegurl_regex = /^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i;
var dash_regex = /^application\/dash\+xml/i;
/**
* returns a string that describes the type of source based on a video source object's
* media type.
*
* @see {@link https://dev.w3.org/html5/pf-summary/video.html#dom-source-type|source type}
*
* @param {string} type
* video source object media type
* @return {('hls'|'dash'|'vhs-json'|null)}
* vhs source type string
*/
var simpletypefromsourcetype = function simpletypefromsourcetype(type) {
if (mpegurl_regex.test(type)) {
return 'hls';
}
if (dash_regex.test(type)) {
return 'dash';
} // denotes the special case of a manifest object passed to http-streaming instead of a
// source url.
//
// see https://en.wikipedia.org/wiki/media_type for details on specifying media types.
//
// in this case, vnd stands for vendor, video.js for the organization, vhs for this
// project, and the +json suffix identifies the structure of the media type.
if (type === 'application/vnd.videojs.vhs+json') {
return 'vhs-json';
}
return null;
};
/***/ }),
/***/ 156:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterabletoarray; });
function _iterabletoarray(iter) {
if (typeof symbol !== "undefined" && iter[symbol.iterator] != null || iter["@@iterator"] != null) return array.from(iter);
}
/***/ }),
/***/ 177:
/***/ (function(module, exports, __webpack_require__) {
var conventions = __webpack_require__(84);
var namespace = conventions.namespace;
/**
* a prerequisite for `[].filter`, to drop elements that are empty
* @param {string} input
* @returns {boolean}
*/
function notemptystring (input) {
return input !== ''
}
/**
* @see https://infra.spec.whatwg.org/#split-on-ascii-whitespace
* @see https://infra.spec.whatwg.org/#ascii-whitespace
*
* @param {string} input
* @returns {string[]} (can be empty)
*/
function splitonasciiwhitespace(input) {
// u+0009 tab, u+000a lf, u+000c ff, u+000d cr, u+0020 space
return input ? input.split(/[\t\n\f\r ]+/).filter(notemptystring) : []
}
/**
* adds element as a key to current if it is not already present.
*
* @param {record} current
* @param {string} element
* @returns {record}
*/
function orderedsetreducer (current, element) {
if (!current.hasownproperty(element)) {
current[element] = true;
}
return current;
}
/**
* @see https://infra.spec.whatwg.org/#ordered-set
* @param {string} input
* @returns {string[]}
*/
function toorderedset(input) {
if (!input) return [];
var list = splitonasciiwhitespace(input);
return object.keys(list.reduce(orderedsetreducer, {}))
}
/**
* uses `list.indexof` to implement something like `array.prototype.includes`,
* which we can not rely on being available.
*
* @param {any[]} list
* @returns {function(any): boolean}
*/
function arrayincludes (list) {
return function(element) {
return list && list.indexof(element) !== -1;
}
}
function copy(src,dest){
for(var p in src){
dest[p] = src[p];
}
}
/**
^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\s]*?^})|\s.*?(?=[;\r\n]));?
^\w+\.prototype\.([_\w]+)\s*=\s*(\s.*?(?=[;\r\n]));?
*/
function _extends(class,super){
var pt = class.prototype;
if(!(pt instanceof super)){
function t(){};
t.prototype = super.prototype;
t = new t();
copy(pt,t);
class.prototype = pt = t;
}
if(pt.constructor != class){
if(typeof class != 'function'){
console.error("unknown class:"+class)
}
pt.constructor = class
}
}
// node types
var nodetype = {}
var element_node = nodetype.element_node = 1;
var attribute_node = nodetype.attribute_node = 2;
var text_node = nodetype.text_node = 3;
var cdata_section_node = nodetype.cdata_section_node = 4;
var entity_reference_node = nodetype.entity_reference_node = 5;
var entity_node = nodetype.entity_node = 6;
var processing_instruction_node = nodetype.processing_instruction_node = 7;
var comment_node = nodetype.comment_node = 8;
var document_node = nodetype.document_node = 9;
var document_type_node = nodetype.document_type_node = 10;
var document_fragment_node = nodetype.document_fragment_node = 11;
var notation_node = nodetype.notation_node = 12;
// exceptioncode
var exceptioncode = {}
var exceptionmessage = {};
var index_size_err = exceptioncode.index_size_err = ((exceptionmessage[1]="index size error"),1);
var domstring_size_err = exceptioncode.domstring_size_err = ((exceptionmessage[2]="domstring size error"),2);
var hierarchy_request_err = exceptioncode.hierarchy_request_err = ((exceptionmessage[3]="hierarchy request error"),3);
var wrong_document_err = exceptioncode.wrong_document_err = ((exceptionmessage[4]="wrong document"),4);
var invalid_character_err = exceptioncode.invalid_character_err = ((exceptionmessage[5]="invalid character"),5);
var no_data_allowed_err = exceptioncode.no_data_allowed_err = ((exceptionmessage[6]="no data allowed"),6);
var no_modification_allowed_err = exceptioncode.no_modification_allowed_err = ((exceptionmessage[7]="no modification allowed"),7);
var not_found_err = exceptioncode.not_found_err = ((exceptionmessage[8]="not found"),8);
var not_supported_err = exceptioncode.not_supported_err = ((exceptionmessage[9]="not supported"),9);
var inuse_attribute_err = exceptioncode.inuse_attribute_err = ((exceptionmessage[10]="attribute in use"),10);
//level2
var invalid_state_err = exceptioncode.invalid_state_err = ((exceptionmessage[11]="invalid state"),11);
var syntax_err = exceptioncode.syntax_err = ((exceptionmessage[12]="syntax error"),12);
var invalid_modification_err = exceptioncode.invalid_modification_err = ((exceptionmessage[13]="invalid modification"),13);
var namespace_err = exceptioncode.namespace_err = ((exceptionmessage[14]="invalid namespace"),14);
var invalid_access_err = exceptioncode.invalid_access_err = ((exceptionmessage[15]="invalid access"),15);
/**
* dom level 2
* object domexception
* @see http://www.w3.org/tr/2000/rec-dom-level-2-core-20001113/ecma-script-binding.html
* @see http://www.w3.org/tr/rec-dom-level-1/ecma-script-language-binding.html
*/
function domexception(code, message) {
if(message instanceof error){
var error = message;
}else{
error = this;
error.call(this, exceptionmessage[code]);
this.message = exceptionmessage[code];
if(error.capturestacktrace) error.capturestacktrace(this, domexception);
}
error.code = code;
if(message) this.message = this.message + ": " + message;
return error;
};
domexception.prototype = error.prototype;
copy(exceptioncode,domexception)
/**
* @see http://www.w3.org/tr/2000/rec-dom-level-2-core-20001113/core.html#id-536297177
* the nodelist interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. nodelist objects in the dom are live.
* the items in the nodelist are accessible via an integral index, starting from 0.
*/
function nodelist() {
};
nodelist.prototype = {
/**
* the number of nodes in the list. the range of valid child node indices is 0 to length-1 inclusive.
* @standard level1
*/
length:0,
/**
* returns the indexth item in the collection. if index is greater than or equal to the number of nodes in the list, this returns null.
* @standard level1
* @param index unsigned long
* index into the collection.
* @return node
* the node at the indexth position in the nodelist, or null if that is not a valid index.
*/
item: function(index) {
return this[index] || null;
},
tostring:function(ishtml,nodefilter){
for(var buf = [], i = 0;i=0){
var lastindex = list.length-1
while(i0 || key == 'xmlns'){
// return null;
// }
//console.log()
var i = this.length;
while(i--){
var attr = this[i];
//console.log(attr.nodename,key)
if(attr.nodename == key){
return attr;
}
}
},
setnameditem: function(attr) {
var el = attr.ownerelement;
if(el && el!=this._ownerelement){
throw new domexception(inuse_attribute_err);
}
var oldattr = this.getnameditem(attr.nodename);
_addnamednode(this._ownerelement,this,attr,oldattr);
return oldattr;
},
/* returns node */
setnameditemns: function(attr) {// raises: wrong_document_err,no_modification_allowed_err,inuse_attribute_err
var el = attr.ownerelement, oldattr;
if(el && el!=this._ownerelement){
throw new domexception(inuse_attribute_err);
}
oldattr = this.getnameditemns(attr.namespaceuri,attr.localname);
_addnamednode(this._ownerelement,this,attr,oldattr);
return oldattr;
},
/* returns node */
removenameditem: function(key) {
var attr = this.getnameditem(key);
_removenamednode(this._ownerelement,this,attr);
return attr;
},// raises: not_found_err,no_modification_allowed_err
//for level2
removenameditemns:function(namespaceuri,localname){
var attr = this.getnameditemns(namespaceuri,localname);
_removenamednode(this._ownerelement,this,attr);
return attr;
},
getnameditemns: function(namespaceuri, localname) {
var i = this.length;
while(i--){
var node = this[i];
if(node.localname == localname && node.namespaceuri == namespaceuri){
return node;
}
}
return null;
}
};
/**
* the domimplementation interface represents an object providing methods
* which are not dependent on any particular document.
* such an object is returned by the `document.implementation` property.
*
* __the individual methods describe the differences compared to the specs.__
*
* @constructor
*
* @see https://developer.mozilla.org/en-us/docs/web/api/domimplementation mdn
* @see https://www.w3.org/tr/rec-dom-level-1/level-one-core.html#id-102161490 dom level 1 core (initial)
* @see https://www.w3.org/tr/dom-level-2-core/core.html#id-102161490 dom level 2 core
* @see https://www.w3.org/tr/dom-level-3-core/core.html#id-102161490 dom level 3 core
* @see https://dom.spec.whatwg.org/#domimplementation dom living standard
*/
function domimplementation() {
}
domimplementation.prototype = {
/**
* the domimplementation.hasfeature() method returns a boolean flag indicating if a given feature is supported.
* the different implementations fairly diverged in what kind of features were reported.
* the latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use.
*
* @deprecated it is deprecated and modern browsers return true in all cases.
*
* @param {string} feature
* @param {string} [version]
* @returns {boolean} always true
*
* @see https://developer.mozilla.org/en-us/docs/web/api/domimplementation/hasfeature mdn
* @see https://www.w3.org/tr/rec-dom-level-1/level-one-core.html#id-5ced94d7 dom level 1 core
* @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature dom living standard
*/
hasfeature: function(feature, version) {
return true;
},
/**
* creates an xml document object of the specified type with its document element.
*
* __it behaves slightly different from the description in the living standard__:
* - there is no interface/class `xmldocument`, it returns a `document` instance.
* - `contenttype`, `encoding`, `mode`, `origin`, `url` fields are currently not declared.
* - this implementation is not validating names or qualified names
* (when parsing xml strings, the sax parser takes care of that)
*
* @param {string|null} namespaceuri
* @param {string} qualifiedname
* @param {documenttype=null} doctype
* @returns {document}
*
* @see https://developer.mozilla.org/en-us/docs/web/api/domimplementation/createdocument mdn
* @see https://www.w3.org/tr/dom-level-2-core/core.html#level-2-core-dom-createdocument dom level 2 core (initial)
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument dom level 2 core
*
* @see https://dom.spec.whatwg.org/#validate-and-extract dom: validate and extract
* @see https://www.w3.org/tr/xml/#nt-namestartchar xml spec: names
* @see https://www.w3.org/tr/xml-names/#ns-qualnames xml namespaces: qualified names
*/
createdocument: function(namespaceuri, qualifiedname, doctype){
var doc = new document();
doc.implementation = this;
doc.childnodes = new nodelist();
doc.doctype = doctype || null;
if (doctype){
doc.appendchild(doctype);
}
if (qualifiedname){
var root = doc.createelementns(namespaceuri, qualifiedname);
doc.appendchild(root);
}
return doc;
},
/**
* returns a doctype, with the given `qualifiedname`, `publicid`, and `systemid`.
*
* __this behavior is slightly different from the in the specs__:
* - this implementation is not validating names or qualified names
* (when parsing xml strings, the sax parser takes care of that)
*
* @param {string} qualifiedname
* @param {string} [publicid]
* @param {string} [systemid]
* @returns {documenttype} which can either be used with `domimplementation.createdocument` upon document creation
* or can be put into the document via methods like `node.insertbefore()` or `node.replacechild()`
*
* @see https://developer.mozilla.org/en-us/docs/web/api/domimplementation/createdocumenttype mdn
* @see https://www.w3.org/tr/dom-level-2-core/core.html#level-2-core-dom-createdoctype dom level 2 core
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype dom living standard
*
* @see https://dom.spec.whatwg.org/#validate-and-extract dom: validate and extract
* @see https://www.w3.org/tr/xml/#nt-namestartchar xml spec: names
* @see https://www.w3.org/tr/xml-names/#ns-qualnames xml namespaces: qualified names
*/
createdocumenttype: function(qualifiedname, publicid, systemid){
var node = new documenttype();
node.name = qualifiedname;
node.nodename = qualifiedname;
node.publicid = publicid || '';
node.systemid = systemid || '';
return node;
}
};
/**
* @see http://www.w3.org/tr/2000/rec-dom-level-2-core-20001113/core.html#id-1950641247
*/
function node() {
};
node.prototype = {
firstchild : null,
lastchild : null,
previoussibling : null,
nextsibling : null,
attributes : null,
parentnode : null,
childnodes : null,
ownerdocument : null,
nodevalue : null,
namespaceuri : null,
prefix : null,
localname : null,
// modified in dom level 2:
insertbefore:function(newchild, refchild){//raises
return _insertbefore(this,newchild,refchild);
},
replacechild:function(newchild, oldchild){//raises
this.insertbefore(newchild,oldchild);
if(oldchild){
this.removechild(oldchild);
}
},
removechild:function(oldchild){
return _removechild(this,oldchild);
},
appendchild:function(newchild){
return this.insertbefore(newchild,null);
},
haschildnodes:function(){
return this.firstchild != null;
},
clonenode:function(deep){
return clonenode(this.ownerdocument||this,this,deep);
},
// modified in dom level 2:
normalize:function(){
var child = this.firstchild;
while(child){
var next = child.nextsibling;
if(next && next.nodetype == text_node && child.nodetype == text_node){
this.removechild(next);
child.appenddata(next.data);
}else{
child.normalize();
child = next;
}
}
},
// introduced in dom level 2:
issupported:function(feature, version){
return this.ownerdocument.implementation.hasfeature(feature,version);
},
// introduced in dom level 2:
hasattributes:function(){
return this.attributes.length>0;
},
/**
* look up the prefix associated to the given namespace uri, starting from this node.
* **the default namespace declarations are ignored by this method.**
* see namespace prefix lookup for details on the algorithm used by this method.
*
* _note: the implementation seems to be incomplete when compared to the algorithm described in the specs._
*
* @param {string | null} namespaceuri
* @returns {string | null}
* @see https://www.w3.org/tr/dom-level-3-core/core.html#node3-lookupnamespaceprefix
* @see https://www.w3.org/tr/dom-level-3-core/namespaces-algorithms.html#lookupnamespaceprefixalgo
* @see https://dom.spec.whatwg.org/#dom-node-lookupprefix
* @see https://github.com/xmldom/xmldom/issues/322
*/
lookupprefix:function(namespaceuri){
var el = this;
while(el){
var map = el._nsmap;
//console.dir(map)
if(map){
for(var n in map){
if(map[n] == namespaceuri){
return n;
}
}
}
el = el.nodetype == attribute_node?el.ownerdocument : el.parentnode;
}
return null;
},
// introduced in dom level 3:
lookupnamespaceuri:function(prefix){
var el = this;
while(el){
var map = el._nsmap;
//console.dir(map)
if(map){
if(prefix in map){
return map[prefix] ;
}
}
el = el.nodetype == attribute_node?el.ownerdocument : el.parentnode;
}
return null;
},
// introduced in dom level 3:
isdefaultnamespace:function(namespaceuri){
var prefix = this.lookupprefix(namespaceuri);
return prefix == null;
}
};
function _xmlencoder(c){
return c == '<' && '<' ||
c == '>' && '>' ||
c == '&' && '&' ||
c == '"' && '"' ||
''+c.charcodeat()+';'
}
copy(nodetype,node);
copy(nodetype,node.prototype);
/**
* @param callback return true for continue,false for break
* @return boolean true: break visit;
*/
function _visitnode(node,callback){
if(callback(node)){
return true;
}
if(node = node.firstchild){
do{
if(_visitnode(node,callback)){return true}
}while(node=node.nextsibling)
}
}
function document(){
}
function _onaddattribute(doc,el,newattr){
doc && doc._inc++;
var ns = newattr.namespaceuri ;
if(ns === namespace.xmlns){
//update namespace
el._nsmap[newattr.prefix?newattr.localname:''] = newattr.value
}
}
function _onremoveattribute(doc,el,newattr,remove){
doc && doc._inc++;
var ns = newattr.namespaceuri ;
if(ns === namespace.xmlns){
//update namespace
delete el._nsmap[newattr.prefix?newattr.localname:'']
}
}
function _onupdatechild(doc,el,newchild){
if(doc && doc._inc){
doc._inc++;
//update childnodes
var cs = el.childnodes;
if(newchild){
cs[cs.length++] = newchild;
}else{
//console.log(1)
var child = el.firstchild;
var i = 0;
while(child){
cs[i++] = child;
child =child.nextsibling;
}
cs.length = i;
}
}
}
/**
* attributes;
* children;
*
* writeable properties:
* nodevalue,attr:value,characterdata:data
* prefix
*/
function _removechild(parentnode,child){
var previous = child.previoussibling;
var next = child.nextsibling;
if(previous){
previous.nextsibling = next;
}else{
parentnode.firstchild = next
}
if(next){
next.previoussibling = previous;
}else{
parentnode.lastchild = previous;
}
_onupdatechild(parentnode.ownerdocument,parentnode);
return child;
}
/**
* preformance key(refchild == null)
*/
function _insertbefore(parentnode,newchild,nextchild){
var cp = newchild.parentnode;
if(cp){
cp.removechild(newchild);//remove and update
}
if(newchild.nodetype === document_fragment_node){
var newfirst = newchild.firstchild;
if (newfirst == null) {
return newchild;
}
var newlast = newchild.lastchild;
}else{
newfirst = newlast = newchild;
}
var pre = nextchild ? nextchild.previoussibling : parentnode.lastchild;
newfirst.previoussibling = pre;
newlast.nextsibling = nextchild;
if(pre){
pre.nextsibling = newfirst;
}else{
parentnode.firstchild = newfirst;
}
if(nextchild == null){
parentnode.lastchild = newlast;
}else{
nextchild.previoussibling = newlast;
}
do{
newfirst.parentnode = parentnode;
}while(newfirst !== newlast && (newfirst= newfirst.nextsibling))
_onupdatechild(parentnode.ownerdocument||parentnode,parentnode);
//console.log(parentnode.lastchild.nextsibling == null)
if (newchild.nodetype == document_fragment_node) {
newchild.firstchild = newchild.lastchild = null;
}
return newchild;
}
function _appendsinglechild(parentnode,newchild){
var cp = newchild.parentnode;
if(cp){
var pre = parentnode.lastchild;
cp.removechild(newchild);//remove and update
var pre = parentnode.lastchild;
}
var pre = parentnode.lastchild;
newchild.parentnode = parentnode;
newchild.previoussibling = pre;
newchild.nextsibling = null;
if(pre){
pre.nextsibling = newchild;
}else{
parentnode.firstchild = newchild;
}
parentnode.lastchild = newchild;
_onupdatechild(parentnode.ownerdocument,parentnode,newchild);
return newchild;
//console.log("__aa",parentnode.lastchild.nextsibling == null)
}
document.prototype = {
//implementation : null,
nodename : '#document',
nodetype : document_node,
/**
* the documenttype node of the document.
*
* @readonly
* @type documenttype
*/
doctype : null,
documentelement : null,
_inc : 1,
insertbefore : function(newchild, refchild){//raises
if(newchild.nodetype == document_fragment_node){
var child = newchild.firstchild;
while(child){
var next = child.nextsibling;
this.insertbefore(child,refchild);
child = next;
}
return newchild;
}
if(this.documentelement == null && newchild.nodetype == element_node){
this.documentelement = newchild;
}
return _insertbefore(this,newchild,refchild),(newchild.ownerdocument = this),newchild;
},
removechild : function(oldchild){
if(this.documentelement == oldchild){
this.documentelement = null;
}
return _removechild(this,oldchild);
},
// introduced in dom level 2:
importnode : function(importednode,deep){
return importnode(this,importednode,deep);
},
// introduced in dom level 2:
getelementbyid : function(id){
var rtv = null;
_visitnode(this.documentelement,function(node){
if(node.nodetype == element_node){
if(node.getattribute('id') == id){
rtv = node;
return true;
}
}
})
return rtv;
},
/**
* the `getelementsbyclassname` method of `document` interface returns an array-like object
* of all child elements which have **all** of the given class name(s).
*
* returns an empty list if `classenames` is an empty string or only contains html white space characters.
*
*
* warning: this is a live livenodelist.
* changes in the dom will reflect in the array as the changes occur.
* if an element selected by this array no longer qualifies for the selector,
* it will automatically be removed. be aware of this for iteration purposes.
*
* @param {string} classnames is a string representing the class name(s) to match; multiple class names are separated by (ascii-)whitespace
*
* @see https://developer.mozilla.org/en-us/docs/web/api/document/getelementsbyclassname
* @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
*/
getelementsbyclassname: function(classnames) {
var classnamesset = toorderedset(classnames)
return new livenodelist(this, function(base) {
var ls = [];
if (classnamesset.length > 0) {
_visitnode(base.documentelement, function(node) {
if(node !== base && node.nodetype === element_node) {
var nodeclassnames = node.getattribute('class')
// can be null if the attribute does not exist
if (nodeclassnames) {
// before splitting and iterating just compare them for the most common case
var matches = classnames === nodeclassnames;
if (!matches) {
var nodeclassnamesset = toorderedset(nodeclassnames)
matches = classnamesset.every(arrayincludes(nodeclassnamesset))
}
if(matches) {
ls.push(node);
}
}
}
});
}
return ls;
});
},
//document factory method:
createelement : function(tagname){
var node = new element();
node.ownerdocument = this;
node.nodename = tagname;
node.tagname = tagname;
node.localname = tagname;
node.childnodes = new nodelist();
var attrs = node.attributes = new namednodemap();
attrs._ownerelement = node;
return node;
},
createdocumentfragment : function(){
var node = new documentfragment();
node.ownerdocument = this;
node.childnodes = new nodelist();
return node;
},
createtextnode : function(data){
var node = new text();
node.ownerdocument = this;
node.appenddata(data)
return node;
},
createcomment : function(data){
var node = new comment();
node.ownerdocument = this;
node.appenddata(data)
return node;
},
createcdatasection : function(data){
var node = new cdatasection();
node.ownerdocument = this;
node.appenddata(data)
return node;
},
createprocessinginstruction : function(target,data){
var node = new processinginstruction();
node.ownerdocument = this;
node.tagname = node.target = target;
node.nodevalue= node.data = data;
return node;
},
createattribute : function(name){
var node = new attr();
node.ownerdocument = this;
node.name = name;
node.nodename = name;
node.localname = name;
node.specified = true;
return node;
},
createentityreference : function(name){
var node = new entityreference();
node.ownerdocument = this;
node.nodename = name;
return node;
},
// introduced in dom level 2:
createelementns : function(namespaceuri,qualifiedname){
var node = new element();
var pl = qualifiedname.split(':');
var attrs = node.attributes = new namednodemap();
node.childnodes = new nodelist();
node.ownerdocument = this;
node.nodename = qualifiedname;
node.tagname = qualifiedname;
node.namespaceuri = namespaceuri;
if(pl.length == 2){
node.prefix = pl[0];
node.localname = pl[1];
}else{
//el.prefix = null;
node.localname = qualifiedname;
}
attrs._ownerelement = node;
return node;
},
// introduced in dom level 2:
createattributens : function(namespaceuri,qualifiedname){
var node = new attr();
var pl = qualifiedname.split(':');
node.ownerdocument = this;
node.nodename = qualifiedname;
node.name = qualifiedname;
node.namespaceuri = namespaceuri;
node.specified = true;
if(pl.length == 2){
node.prefix = pl[0];
node.localname = pl[1];
}else{
//el.prefix = null;
node.localname = qualifiedname;
}
return node;
}
};
_extends(document,node);
function element() {
this._nsmap = {};
};
element.prototype = {
nodetype : element_node,
hasattribute : function(name){
return this.getattributenode(name)!=null;
},
getattribute : function(name){
var attr = this.getattributenode(name);
return attr && attr.value || '';
},
getattributenode : function(name){
return this.attributes.getnameditem(name);
},
setattribute : function(name, value){
var attr = this.ownerdocument.createattribute(name);
attr.value = attr.nodevalue = "" + value;
this.setattributenode(attr)
},
removeattribute : function(name){
var attr = this.getattributenode(name)
attr && this.removeattributenode(attr);
},
//four real opeartion method
appendchild:function(newchild){
if(newchild.nodetype === document_fragment_node){
return this.insertbefore(newchild,null);
}else{
return _appendsinglechild(this,newchild);
}
},
setattributenode : function(newattr){
return this.attributes.setnameditem(newattr);
},
setattributenodens : function(newattr){
return this.attributes.setnameditemns(newattr);
},
removeattributenode : function(oldattr){
//console.log(this == oldattr.ownerelement)
return this.attributes.removenameditem(oldattr.nodename);
},
//get real attribute name,and remove it by removeattributenode
removeattributens : function(namespaceuri, localname){
var old = this.getattributenodens(namespaceuri, localname);
old && this.removeattributenode(old);
},
hasattributens : function(namespaceuri, localname){
return this.getattributenodens(namespaceuri, localname)!=null;
},
getattributens : function(namespaceuri, localname){
var attr = this.getattributenodens(namespaceuri, localname);
return attr && attr.value || '';
},
setattributens : function(namespaceuri, qualifiedname, value){
var attr = this.ownerdocument.createattributens(namespaceuri, qualifiedname);
attr.value = attr.nodevalue = "" + value;
this.setattributenode(attr)
},
getattributenodens : function(namespaceuri, localname){
return this.attributes.getnameditemns(namespaceuri, localname);
},
getelementsbytagname : function(tagname){
return new livenodelist(this,function(base){
var ls = [];
_visitnode(base,function(node){
if(node !== base && node.nodetype == element_node && (tagname === '*' || node.tagname == tagname)){
ls.push(node);
}
});
return ls;
});
},
getelementsbytagnamens : function(namespaceuri, localname){
return new livenodelist(this,function(base){
var ls = [];
_visitnode(base,function(node){
if(node !== base && node.nodetype === element_node && (namespaceuri === '*' || node.namespaceuri === namespaceuri) && (localname === '*' || node.localname == localname)){
ls.push(node);
}
});
return ls;
});
}
};
document.prototype.getelementsbytagname = element.prototype.getelementsbytagname;
document.prototype.getelementsbytagnamens = element.prototype.getelementsbytagnamens;
_extends(element,node);
function attr() {
};
attr.prototype.nodetype = attribute_node;
_extends(attr,node);
function characterdata() {
};
characterdata.prototype = {
data : '',
substringdata : function(offset, count) {
return this.data.substring(offset, offset+count);
},
appenddata: function(text) {
text = this.data+text;
this.nodevalue = this.data = text;
this.length = text.length;
},
insertdata: function(offset,text) {
this.replacedata(offset,0,text);
},
appendchild:function(newchild){
throw new error(exceptionmessage[hierarchy_request_err])
},
deletedata: function(offset, count) {
this.replacedata(offset,count,"");
},
replacedata: function(offset, count, text) {
var start = this.data.substring(0,offset);
var end = this.data.substring(offset+count);
text = start + text + end;
this.nodevalue = this.data = text;
this.length = text.length;
}
}
_extends(characterdata,node);
function text() {
};
text.prototype = {
nodename : "#text",
nodetype : text_node,
splittext : function(offset) {
var text = this.data;
var newtext = text.substring(offset);
text = text.substring(0, offset);
this.data = this.nodevalue = text;
this.length = text.length;
var newnode = this.ownerdocument.createtextnode(newtext);
if(this.parentnode){
this.parentnode.insertbefore(newnode, this.nextsibling);
}
return newnode;
}
}
_extends(text,characterdata);
function comment() {
};
comment.prototype = {
nodename : "#comment",
nodetype : comment_node
}
_extends(comment,characterdata);
function cdatasection() {
};
cdatasection.prototype = {
nodename : "#cdata-section",
nodetype : cdata_section_node
}
_extends(cdatasection,characterdata);
function documenttype() {
};
documenttype.prototype.nodetype = document_type_node;
_extends(documenttype,node);
function notation() {
};
notation.prototype.nodetype = notation_node;
_extends(notation,node);
function entity() {
};
entity.prototype.nodetype = entity_node;
_extends(entity,node);
function entityreference() {
};
entityreference.prototype.nodetype = entity_reference_node;
_extends(entityreference,node);
function documentfragment() {
};
documentfragment.prototype.nodename = "#document-fragment";
documentfragment.prototype.nodetype = document_fragment_node;
_extends(documentfragment,node);
function processinginstruction() {
}
processinginstruction.prototype.nodetype = processing_instruction_node;
_extends(processinginstruction,node);
function xmlserializer(){}
xmlserializer.prototype.serializetostring = function(node,ishtml,nodefilter){
return nodeserializetostring.call(node,ishtml,nodefilter);
}
node.prototype.tostring = nodeserializetostring;
function nodeserializetostring(ishtml,nodefilter){
var buf = [];
var refnode = this.nodetype == 9 && this.documentelement || this;
var prefix = refnode.prefix;
var uri = refnode.namespaceuri;
if(uri && prefix == null){
//console.log(prefix)
var prefix = refnode.lookupprefix(uri);
if(prefix == null){
//ishtml = true;
var visiblenamespaces=[
{namespace:uri,prefix:null}
//{namespace:uri,prefix:''}
]
}
}
serializetostring(this,buf,ishtml,nodefilter,visiblenamespaces);
//console.log('###',this.nodetype,uri,prefix,buf.join(''))
return buf.join('');
}
function neednamespacedefine(node, ishtml, visiblenamespaces) {
var prefix = node.prefix || '';
var uri = node.namespaceuri;
// according to [namespaces in xml 1.0](https://www.w3.org/tr/rec-xml-names/#ns-using) ,
// and more specifically https://www.w3.org/tr/rec-xml-names/#nsc-noprefixundecl :
// > in a namespace declaration for a prefix [...], the attribute value must not be empty.
// in a similar manner [namespaces in xml 1.1](https://www.w3.org/tr/xml-names11/#ns-using)
// and more specifically https://www.w3.org/tr/xml-names11/#nsc-nsdeclared :
// > [...] furthermore, the attribute value [...] must not be an empty string.
// so serializing empty namespace value like xmlns:ds="" would produce an invalid xml document.
if (!uri) {
return false;
}
if (prefix === "xml" && uri === namespace.xml || uri === namespace.xmlns) {
return false;
}
var i = visiblenamespaces.length
while (i--) {
var ns = visiblenamespaces[i];
// get namespace prefix
if (ns.prefix === prefix) {
return ns.namespace !== uri;
}
}
return true;
}
/**
* well-formed constraint: no < in attribute values
* the replacement text of any entity referred to directly or indirectly in an attribute value must not contain a <.
* @see https://www.w3.org/tr/xml/#cleanattrvals
* @see https://www.w3.org/tr/xml/#nt-attvalue
*/
function addserializedattribute(buf, qualifiedname, value) {
buf.push(' ', qualifiedname, '="', value.replace(/[<&"]/g,_xmlencoder), '"')
}
function serializetostring(node,buf,ishtml,nodefilter,visiblenamespaces){
if (!visiblenamespaces) {
visiblenamespaces = [];
}
if(nodefilter){
node = nodefilter(node);
if(node){
if(typeof node == 'string'){
buf.push(node);
return;
}
}else{
return;
}
//buf.sort.apply(attrs, attributesorter);
}
switch(node.nodetype){
case element_node:
var attrs = node.attributes;
var len = attrs.length;
var child = node.firstchild;
var nodename = node.tagname;
ishtml = namespace.ishtml(node.namespaceuri) || ishtml
var prefixednodename = nodename
if (!ishtml && !node.prefix && node.namespaceuri) {
var defaultns
// lookup current default ns from `xmlns` attribute
for (var ai = 0; ai < attrs.length; ai++) {
if (attrs.item(ai).name === 'xmlns') {
defaultns = attrs.item(ai).value
break
}
}
if (!defaultns) {
// lookup current default ns in visiblenamespaces
for (var nsi = visiblenamespaces.length - 1; nsi >= 0; nsi--) {
var namespace = visiblenamespaces[nsi]
if (namespace.prefix === '' && namespace.namespace === node.namespaceuri) {
defaultns = namespace.namespace
break
}
}
}
if (defaultns !== node.namespaceuri) {
for (var nsi = visiblenamespaces.length - 1; nsi >= 0; nsi--) {
var namespace = visiblenamespaces[nsi]
if (namespace.namespace === node.namespaceuri) {
if (namespace.prefix) {
prefixednodename = namespace.prefix + ':' + nodename
}
break
}
}
}
}
buf.push('<', prefixednodename);
for(var i=0;i');
//if is cdata child node
if(ishtml && /^script$/i.test(nodename)){
while(child){
if(child.data){
buf.push(child.data);
}else{
serializetostring(child, buf, ishtml, nodefilter, visiblenamespaces.slice());
}
child = child.nextsibling;
}
}else
{
while(child){
serializetostring(child, buf, ishtml, nodefilter, visiblenamespaces.slice());
child = child.nextsibling;
}
}
buf.push('',prefixednodename,'>');
}else{
buf.push('/>');
}
// remove added visible namespaces
//visiblenamespaces.length = startvisiblenamespaces;
return;
case document_node:
case document_fragment_node:
var child = node.firstchild;
while(child){
serializetostring(child, buf, ishtml, nodefilter, visiblenamespaces.slice());
child = child.nextsibling;
}
return;
case attribute_node:
return addserializedattribute(buf, node.name, node.value);
case text_node:
/**
* the ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
* except when used as markup delimiters, or within a comment, a processing instruction, or a cdata section.
* if they are needed elsewhere, they must be escaped using either numeric character references or the strings
* `&` and `<` respectively.
* the right angle bracket (>) may be represented using the string " > ", and must, for compatibility,
* be escaped using either `>` or a character reference when it appears in the string `]]>` in content,
* when that string is not marking the end of a cdata section.
*
* in the content of elements, character data is any string of characters
* which does not contain the start-delimiter of any markup
* and does not include the cdata-section-close delimiter, `]]>`.
*
* @see https://www.w3.org/tr/xml/#nt-chardata
*/
return buf.push(node.data
.replace(/[<&]/g,_xmlencoder)
.replace(/]]>/g, ']]>')
);
case cdata_section_node:
return buf.push( '');
case comment_node:
return buf.push( "");
case document_type_node:
var pubid = node.publicid;
var sysid = node.systemid;
buf.push('');
}else if(sysid && sysid!='.'){
buf.push(' system ', sysid, '>');
}else{
var sub = node.internalsubset;
if(sub){
buf.push(" [",sub,"]");
}
buf.push(">");
}
return;
case processing_instruction_node:
return buf.push( "",node.target," ",node.data,"?>");
case entity_reference_node:
return buf.push( '&',node.nodename,';');
//case entity_node:
//case notation_node:
default:
buf.push('??',node.nodename);
}
}
function importnode(doc,node,deep){
var node2;
switch (node.nodetype) {
case element_node:
node2 = node.clonenode(false);
node2.ownerdocument = doc;
//var attrs = node2.attributes;
//var len = attrs.length;
//for(var i=0;i= 500 && error.response.status <= 599);
}
/**
* @param {error} error
* @return {boolean}
*/
function issaferequesterror(error) {
if (!error.config) {
// cannot determine if the request can be retried
return false;
}
return isretryableerror(error) && safe_http_methods.indexof(error.config.method) !== -1;
}
/**
* @param {error} error
* @return {boolean}
*/
function isidempotentrequesterror(error) {
if (!error.config) {
// cannot determine if the request can be retried
return false;
}
return isretryableerror(error) && idempotent_http_methods.indexof(error.config.method) !== -1;
}
/**
* @param {error} error
* @return {boolean | promise}
*/
function isnetworkoridempotentrequesterror(error) {
return isnetworkerror(error) || isidempotentrequesterror(error);
}
/**
* @return {number} - delay in milliseconds, always 0
*/
function nodelay() {
return 0;
}
/**
* @param {number} [retrynumber=0]
* @return {number} - delay in milliseconds
*/
function exponentialdelay() {
var retrynumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var delay = math.pow(2, retrynumber) * 100;
var randomsum = delay * 0.2 * math.random(); // 0-20% of the delay
return delay + randomsum;
}
/**
* initializes and returns the retry state for the given request/config
* @param {axiosrequestconfig} config
* @return {object}
*/
function getcurrentstate(config) {
var currentstate = config[namespace] || {};
currentstate.retrycount = currentstate.retrycount || 0;
config[namespace] = currentstate;
return currentstate;
}
/**
* returns the axios-retry options for the current request
* @param {axiosrequestconfig} config
* @param {axiosretryconfig} defaultoptions
* @return {axiosretryconfig}
*/
function getrequestoptions(config, defaultoptions) {
return _objectspread(_objectspread({}, defaultoptions), config[namespace]);
}
/**
* @param {axios} axios
* @param {axiosrequestconfig} config
*/
function fixconfig(axios, config) {
if (axios.defaults.agent === config.agent) {
delete config.agent;
}
if (axios.defaults.httpagent === config.httpagent) {
delete config.httpagent;
}
if (axios.defaults.httpsagent === config.httpsagent) {
delete config.httpsagent;
}
}
/**
* checks retrycondition if request can be retried. handles it's retruning value or promise.
* @param {number} retries
* @param {function} retrycondition
* @param {object} currentstate
* @param {error} error
* @return {boolean}
*/
function shouldretry(_x, _x2, _x3, _x4) {
return _shouldretry.apply(this, arguments);
}
/**
* adds response interceptors to an axios instance to retry requests failed due to network issues
*
* @example
*
* import axios from 'axios';
*
* axiosretry(axios, { retries: 3 });
*
* axios.get('http://example.com/test') // the first request fails and the second returns 'ok'
* .then(result => {
* result.data; // 'ok'
* });
*
* // exponential back-off retry delay between requests
* axiosretry(axios, { retrydelay : axiosretry.exponentialdelay});
*
* // custom retry delay
* axiosretry(axios, { retrydelay : (retrycount) => {
* return retrycount * 1000;
* }});
*
* // also works with custom axios instances
* const client = axios.create({ baseurl: 'http://example.com' });
* axiosretry(client, { retries: 3 });
*
* client.get('/test') // the first request fails and the second returns 'ok'
* .then(result => {
* result.data; // 'ok'
* });
*
* // allows request-specific configuration
* client
* .get('/test', {
* 'axios-retry': {
* retries: 0
* }
* })
* .catch(error => { // the first request fails
* error !== undefined
* });
*
* @param {axios} axios an axios instance (the axios object or one created from axios.create)
* @param {object} [defaultoptions]
* @param {number} [defaultoptions.retries=3] number of retries
* @param {boolean} [defaultoptions.shouldresettimeout=false]
* defines if the timeout should be reset between retries
* @param {function} [defaultoptions.retrycondition=isnetworkoridempotentrequesterror]
* a function to determine if the error can be retried
* @param {function} [defaultoptions.retrydelay=nodelay]
* a function to determine the delay between retry requests
*/
function _shouldretry() {
_shouldretry = _asynctogenerator(function* (retries, retrycondition, currentstate, error) {
var shouldretryorpromise = currentstate.retrycount < retries && retrycondition(error); // this could be a promise
if (typeof shouldretryorpromise === 'object') {
try {
yield shouldretryorpromise;
return true;
} catch (_err) {
return false;
}
}
return shouldretryorpromise;
});
return _shouldretry.apply(this, arguments);
}
function axiosretry(axios, defaultoptions) {
axios.interceptors.request.use(config => {
var currentstate = getcurrentstate(config);
currentstate.lastrequesttime = date.now();
return config;
});
axios.interceptors.response.use(null, /*#__pure__*/function () {
var _ref = _asynctogenerator(function* (error) {
var {
config
} = error; // if we have no information to retry the request
if (!config) {
return promise.reject(error);
}
var {
retries = 3,
retrycondition = isnetworkoridempotentrequesterror,
retrydelay = nodelay,
shouldresettimeout = false
} = getrequestoptions(config, defaultoptions);
var currentstate = getcurrentstate(config);
if (yield shouldretry(retries, retrycondition, currentstate, error)) {
currentstate.retrycount += 1;
var delay = retrydelay(currentstate.retrycount, error); // axios fails merging this configuration to the default configuration because it has an issue
// with circular structures: https://github.com/mzabriskie/axios/issues/370
fixconfig(axios, config);
if (!shouldresettimeout && config.timeout && currentstate.lastrequesttime) {
var lastrequestduration = date.now() - currentstate.lastrequesttime; // minimum 1ms timeout (passing 0 or less to xhr means no timeout)
config.timeout = math.max(config.timeout - lastrequestduration - delay, 1);
}
config.transformrequest = [data => data];
return new promise(resolve => settimeout(() => resolve(axios(config)), delay));
}
return promise.reject(error);
});
return function (_x5) {
return _ref.apply(this, arguments);
};
}());
} // compatibility with commonjs
axiosretry.isnetworkerror = isnetworkerror;
axiosretry.issaferequesterror = issaferequesterror;
axiosretry.isidempotentrequesterror = isidempotentrequesterror;
axiosretry.isnetworkoridempotentrequesterror = isnetworkoridempotentrequesterror;
axiosretry.exponentialdelay = exponentialdelay;
axiosretry.isretryableerror = isretryableerror;
//# sourcemappingurl=index.js.map
/***/ }),
/***/ 190:
/***/ (function(module, exports, __webpack_require__) {
var setprototypeof = __webpack_require__(107);
var isnativereflectconstruct = __webpack_require__(314);
function _construct(parent, args, class) {
if (isnativereflectconstruct()) {
module.exports = _construct = reflect.construct, module.exports.__esmodule = true, module.exports["default"] = module.exports;
} else {
module.exports = _construct = function _construct(parent, args, class) {
var a = [null];
a.push.apply(a, args);
var constructor = function.bind.apply(parent, a);
var instance = new constructor();
if (class) setprototypeof(instance, class.prototype);
return instance;
}, module.exports.__esmodule = true, module.exports["default"] = module.exports;
}
return _construct.apply(null, arguments);
}
module.exports = _construct, module.exports.__esmodule = true, module.exports["default"] = module.exports;
/***/ }),
/***/ 191:
/***/ (function(module, exports, __webpack_require__) {
var setprototypeof = __webpack_require__(107);
function _inherits(subclass, superclass) {
if (typeof superclass !== "function" && superclass !== null) {
throw new typeerror("super expression must either be null or a function");
}
subclass.prototype = object.create(superclass && superclass.prototype, {
constructor: {
value: subclass,
writable: true,
configurable: true
}
});
object.defineproperty(subclass, "prototype", {
writable: false
});
if (superclass) setprototypeof(subclass, superclass);
}
module.exports = _inherits, module.exports.__esmodule = true, module.exports["default"] = module.exports;
/***/ }),
/***/ 193:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return foreachmediagroup; });
/**
* loops through all supported media groups in master and calls the provided
* callback for each group
*
* @param {object} master
* the parsed master manifest object
* @param {string[]} groups
* the media groups to call the callback for
* @param {function} callback
* callback to call for each media group
*/
var foreachmediagroup = function foreachmediagroup(master, groups, callback) {
groups.foreach(function (mediatype) {
for (var groupkey in master.mediagroups[mediatype]) {
for (var labelkey in master.mediagroups[mediatype][groupkey]) {
var mediaproperties = master.mediagroups[mediatype][groupkey][labelkey];
callback(mediaproperties, mediatype, groupkey, labelkey);
}
}
});
};
/***/ }),
/***/ 194:
/***/ (function(module, exports, __webpack_require__) {
var dom = __webpack_require__(177)
exports.domimplementation = dom.domimplementation
exports.xmlserializer = dom.xmlserializer
exports.domparser = __webpack_require__(319).domparser
/***/ }),
/***/ 20:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineproperty; });
function _defineproperty(obj, key, value) {
if (key in obj) {
object.defineproperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
/***/ }),
/***/ 21:
/***/ (function(module, exports) {
function _extends() {
module.exports = _extends = object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (object.prototype.hasownproperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
}, module.exports.__esmodule = true, module.exports["default"] = module.exports;
return _extends.apply(this, arguments);
}
module.exports = _extends, module.exports.__esmodule = true, module.exports["default"] = module.exports;
/***/ }),
/***/ 22:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// exports
__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _slicedtoarray; });
// external module: ./node_modules/@babel/runtime/helpers/esm/arraywithholes.js
var arraywithholes = __webpack_require__(86);
// concatenated module: ./node_modules/@babel/runtime/helpers/esm/iterabletoarraylimit.js
function _iterabletoarraylimit(arr, i) {
var _i = arr == null ? null : typeof symbol !== "undefined" && arr[symbol.iterator] || arr["@@iterator"];
if (_i == null) return;
var _arr = [];
var _n = true;
var _d = false;
var _s, _e;
try {
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
// external module: ./node_modules/@babel/runtime/helpers/esm/unsupportediterabletoarray.js
var unsupportediterabletoarray = __webpack_require__(85);
// external module: ./node_modules/@babel/runtime/helpers/esm/noniterablerest.js
var noniterablerest = __webpack_require__(87);
// concatenated module: ./node_modules/@babel/runtime/helpers/esm/slicedtoarray.js
function _slicedtoarray(arr, i) {
return object(arraywithholes["a" /* default */])(arr) || _iterabletoarraylimit(arr, i) || object(unsupportediterabletoarray["a" /* default */])(arr, i) || object(noniterablerest["a" /* default */])();
}
/***/ }),
/***/ 28:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; });
function _typeof(obj) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof symbol && "symbol" == typeof symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && "function" == typeof symbol && obj.constructor === symbol && obj !== symbol.prototype ? "symbol" : typeof obj;
}, _typeof(obj);
}
/***/ }),
/***/ 310:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var window = __webpack_require__(0);
var httpresponsehandler = function httpresponsehandler(callback, decoderesponsebody) {
if (decoderesponsebody === void 0) {
decoderesponsebody = false;
}
return function (err, response, responsebody) {
// if the xhr failed, return that error
if (err) {
callback(err);
return;
} // if the http status code is 4xx or 5xx, the request also failed
if (response.statuscode >= 400 && response.statuscode <= 599) {
var cause = responsebody;
if (decoderesponsebody) {
if (window.textdecoder) {
var charset = getcharset(response.headers && response.headers['content-type']);
try {
cause = new textdecoder(charset).decode(responsebody);
} catch (e) {}
} else {
cause = string.fromcharcode.apply(null, new uint8array(responsebody));
}
}
callback({
cause: cause
});
return;
} // otherwise, request succeeded
callback(null, responsebody);
};
};
function getcharset(contenttypeheader) {
if (contenttypeheader === void 0) {
contenttypeheader = '';
}
return contenttypeheader.tolowercase().split(';').reduce(function (charset, contenttype) {
var _contenttype$split = contenttype.split('='),
type = _contenttype$split[0],
value = _contenttype$split[1];
if (type.trim() === 'charset') {
return value.trim();
}
return charset;
}, 'utf-8');
}
module.exports = httpresponsehandler;
/***/ }),
/***/ 314:
/***/ (function(module, exports) {
function _isnativereflectconstruct() {
if (typeof reflect === "undefined" || !reflect.construct) return false;
if (reflect.construct.sham) return false;
if (typeof proxy === "function") return true;
try {
boolean.prototype.valueof.call(reflect.construct(boolean, [], function () {}));
return true;
} catch (e) {
return false;
}
}
module.exports = _isnativereflectconstruct, module.exports.__esmodule = true, module.exports["default"] = module.exports;
/***/ }),
/***/ 315:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* webpack var injection */(function(global) {/*!
* the buffer module from node.js, for the browser.
*
* @author feross aboukhadijeh
* @license mit
*/
/* eslint-disable no-proto */
var base64 = __webpack_require__(316)
var ieee754 = __webpack_require__(317)
var isarray = __webpack_require__(318)
exports.buffer = buffer
exports.slowbuffer = slowbuffer
exports.inspect_max_bytes = 50
/**
* if `buffer.typed_array_support`:
* === true use uint8array implementation (fastest)
* === false use object implementation (most compatible, even ie6)
*
* browsers that support typed arrays are ie 10+, firefox 4+, chrome 7+, safari 5.1+,
* opera 11.6+, ios 4.2+.
*
* due to various browser bugs, sometimes the object implementation will be used even
* when the browser supports typed arrays.
*
* note:
*
* - firefox 4-29 lacks support for adding new properties to `uint8array` instances,
* see: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
*
* - chrome 9-10 is missing the `typedarray.prototype.subarray` function.
*
* - ie10 has a broken `typedarray.prototype.subarray` function which returns arrays of
* incorrect length in some situations.
* we detect these buggy browsers and set `buffer.typed_array_support` to `false` so they
* get the object implementation, which is slower but behaves correctly.
*/
buffer.typed_array_support = global.typed_array_support !== undefined
? global.typed_array_support
: typedarraysupport()
/*
* export kmaxlength after typed array support is determined.
*/
exports.kmaxlength = kmaxlength()
function typedarraysupport () {
try {
var arr = new uint8array(1)
arr.__proto__ = {__proto__: uint8array.prototype, foo: function () { return 42 }}
return arr.foo() === 42 && // typed array instances can be augmented
typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
arr.subarray(1, 1).bytelength === 0 // ie10 has broken `subarray`
} catch (e) {
return false
}
}
function kmaxlength () {
return buffer.typed_array_support
? 0x7fffffff
: 0x3fffffff
}
function createbuffer (that, length) {
if (kmaxlength() < length) {
throw new rangeerror('invalid typed array length')
}
if (buffer.typed_array_support) {
// return an augmented `uint8array` instance, for best performance
that = new uint8array(length)
that.__proto__ = buffer.prototype
} else {
// fallback: return an object instance of the buffer class
if (that === null) {
that = new buffer(length)
}
that.length = length
}
return that
}
/**
* the buffer constructor returns instances of `uint8array` that have their
* prototype changed to `buffer.prototype`. furthermore, `buffer` is a subclass of
* `uint8array`, so the returned instances will have all the node `buffer` methods
* and the `uint8array` methods. square bracket notation works as expected -- it
* returns a single octet.
*
* the `uint8array` prototype remains unmodified.
*/
function buffer (arg, encodingoroffset, length) {
if (!buffer.typed_array_support && !(this instanceof buffer)) {
return new buffer(arg, encodingoroffset, length)
}
// common case.
if (typeof arg === 'number') {
if (typeof encodingoroffset === 'string') {
throw new error(
'if encoding is specified then the first argument must be a string'
)
}
return allocunsafe(this, arg)
}
return from(this, arg, encodingoroffset, length)
}
buffer.poolsize = 8192 // not used by this implementation
// todo: legacy, not needed anymore. remove in next major version.
buffer._augment = function (arr) {
arr.__proto__ = buffer.prototype
return arr
}
function from (that, value, encodingoroffset, length) {
if (typeof value === 'number') {
throw new typeerror('"value" argument must not be a number')
}
if (typeof arraybuffer !== 'undefined' && value instanceof arraybuffer) {
return fromarraybuffer(that, value, encodingoroffset, length)
}
if (typeof value === 'string') {
return fromstring(that, value, encodingoroffset)
}
return fromobject(that, value)
}
/**
* functionally equivalent to buffer(arg, encoding) but throws a typeerror
* if value is a number.
* buffer.from(str[, encoding])
* buffer.from(array)
* buffer.from(buffer)
* buffer.from(arraybuffer[, byteoffset[, length]])
**/
buffer.from = function (value, encodingoroffset, length) {
return from(null, value, encodingoroffset, length)
}
if (buffer.typed_array_support) {
buffer.prototype.__proto__ = uint8array.prototype
buffer.__proto__ = uint8array
if (typeof symbol !== 'undefined' && symbol.species &&
buffer[symbol.species] === buffer) {
// fix subarray() in es2016. see: https://github.com/feross/buffer/pull/97
object.defineproperty(buffer, symbol.species, {
value: null,
configurable: true
})
}
}
function assertsize (size) {
if (typeof size !== 'number') {
throw new typeerror('"size" argument must be a number')
} else if (size < 0) {
throw new rangeerror('"size" argument must not be negative')
}
}
function alloc (that, size, fill, encoding) {
assertsize(size)
if (size <= 0) {
return createbuffer(that, size)
}
if (fill !== undefined) {
// only pay attention to encoding if it's a string. this
// prevents accidentally sending in a number that would
// be interpretted as a start offset.
return typeof encoding === 'string'
? createbuffer(that, size).fill(fill, encoding)
: createbuffer(that, size).fill(fill)
}
return createbuffer(that, size)
}
/**
* creates a new filled buffer instance.
* alloc(size[, fill[, encoding]])
**/
buffer.alloc = function (size, fill, encoding) {
return alloc(null, size, fill, encoding)
}
function allocunsafe (that, size) {
assertsize(size)
that = createbuffer(that, size < 0 ? 0 : checked(size) | 0)
if (!buffer.typed_array_support) {
for (var i = 0; i < size; ++i) {
that[i] = 0
}
}
return that
}
/**
* equivalent to buffer(num), by default creates a non-zero-filled buffer instance.
* */
buffer.allocunsafe = function (size) {
return allocunsafe(null, size)
}
/**
* equivalent to slowbuffer(num), by default creates a non-zero-filled buffer instance.
*/
buffer.allocunsafeslow = function (size) {
return allocunsafe(null, size)
}
function fromstring (that, string, encoding) {
if (typeof encoding !== 'string' || encoding === '') {
encoding = 'utf8'
}
if (!buffer.isencoding(encoding)) {
throw new typeerror('"encoding" must be a valid string encoding')
}
var length = bytelength(string, encoding) | 0
that = createbuffer(that, length)
var actual = that.write(string, encoding)
if (actual !== length) {
// writing a hex string, for example, that contains invalid characters will
// cause everything after the first invalid character to be ignored. (e.g.
// 'abxxcd' will be treated as 'ab')
that = that.slice(0, actual)
}
return that
}
function fromarraylike (that, array) {
var length = array.length < 0 ? 0 : checked(array.length) | 0
that = createbuffer(that, length)
for (var i = 0; i < length; i += 1) {
that[i] = array[i] & 255
}
return that
}
function fromarraybuffer (that, array, byteoffset, length) {
array.bytelength // this throws if `array` is not a valid arraybuffer
if (byteoffset < 0 || array.bytelength < byteoffset) {
throw new rangeerror('\'offset\' is out of bounds')
}
if (array.bytelength < byteoffset + (length || 0)) {
throw new rangeerror('\'length\' is out of bounds')
}
if (byteoffset === undefined && length === undefined) {
array = new uint8array(array)
} else if (length === undefined) {
array = new uint8array(array, byteoffset)
} else {
array = new uint8array(array, byteoffset, length)
}
if (buffer.typed_array_support) {
// return an augmented `uint8array` instance, for best performance
that = array
that.__proto__ = buffer.prototype
} else {
// fallback: return an object instance of the buffer class
that = fromarraylike(that, array)
}
return that
}
function fromobject (that, obj) {
if (buffer.isbuffer(obj)) {
var len = checked(obj.length) | 0
that = createbuffer(that, len)
if (that.length === 0) {
return that
}
obj.copy(that, 0, 0, len)
return that
}
if (obj) {
if ((typeof arraybuffer !== 'undefined' &&
obj.buffer instanceof arraybuffer) || 'length' in obj) {
if (typeof obj.length !== 'number' || isnan(obj.length)) {
return createbuffer(that, 0)
}
return fromarraylike(that, obj)
}
if (obj.type === 'buffer' && isarray(obj.data)) {
return fromarraylike(that, obj.data)
}
}
throw new typeerror('first argument must be a string, buffer, arraybuffer, array, or array-like object.')
}
function checked (length) {
// note: cannot use `length < kmaxlength()` here because that fails when
// length is nan (which is otherwise coerced to zero.)
if (length >= kmaxlength()) {
throw new rangeerror('attempt to allocate buffer larger than maximum ' +
'size: 0x' + kmaxlength().tostring(16) + ' bytes')
}
return length | 0
}
function slowbuffer (length) {
if (+length != length) { // eslint-disable-line eqeqeq
length = 0
}
return buffer.alloc(+length)
}
buffer.isbuffer = function isbuffer (b) {
return !!(b != null && b._isbuffer)
}
buffer.compare = function compare (a, b) {
if (!buffer.isbuffer(a) || !buffer.isbuffer(b)) {
throw new typeerror('arguments must be buffers')
}
if (a === b) return 0
var x = a.length
var y = b.length
for (var i = 0, len = math.min(x, y); i < len; ++i) {
if (a[i] !== b[i]) {
x = a[i]
y = b[i]
break
}
}
if (x < y) return -1
if (y < x) return 1
return 0
}
buffer.isencoding = function isencoding (encoding) {
switch (string(encoding).tolowercase()) {
case 'hex':
case 'utf8':
case 'utf-8':
case 'ascii':
case 'latin1':
case 'binary':
case 'base64':
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return true
default:
return false
}
}
buffer.concat = function concat (list, length) {
if (!isarray(list)) {
throw new typeerror('"list" argument must be an array of buffers')
}
if (list.length === 0) {
return buffer.alloc(0)
}
var i
if (length === undefined) {
length = 0
for (i = 0; i < list.length; ++i) {
length += list[i].length
}
}
var buffer = buffer.allocunsafe(length)
var pos = 0
for (i = 0; i < list.length; ++i) {
var buf = list[i]
if (!buffer.isbuffer(buf)) {
throw new typeerror('"list" argument must be an array of buffers')
}
buf.copy(buffer, pos)
pos += buf.length
}
return buffer
}
function bytelength (string, encoding) {
if (buffer.isbuffer(string)) {
return string.length
}
if (typeof arraybuffer !== 'undefined' && typeof arraybuffer.isview === 'function' &&
(arraybuffer.isview(string) || string instanceof arraybuffer)) {
return string.bytelength
}
if (typeof string !== 'string') {
string = '' + string
}
var len = string.length
if (len === 0) return 0
// use a for loop to avoid recursion
var loweredcase = false
for (;;) {
switch (encoding) {
case 'ascii':
case 'latin1':
case 'binary':
return len
case 'utf8':
case 'utf-8':
case undefined:
return utf8tobytes(string).length
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return len * 2
case 'hex':
return len >>> 1
case 'base64':
return base64tobytes(string).length
default:
if (loweredcase) return utf8tobytes(string).length // assume utf8
encoding = ('' + encoding).tolowercase()
loweredcase = true
}
}
}
buffer.bytelength = bytelength
function slowtostring (encoding, start, end) {
var loweredcase = false
// no need to verify that "this.length <= max_uint32" since it's a read-only
// property of a typed array.
// this behaves neither like string nor uint8array in that we set start/end
// to their upper/lower bounds if the value passed is out of range.
// undefined is handled specially as per ecma-262 6th edition,
// section 13.3.3.7 runtime semantics: keyedbindinginitialization.
if (start === undefined || start < 0) {
start = 0
}
// return early if start > this.length. done here to prevent potential uint32
// coercion fail below.
if (start > this.length) {
return ''
}
if (end === undefined || end > this.length) {
end = this.length
}
if (end <= 0) {
return ''
}
// force coersion to uint32. this will also coerce falsey/nan values to 0.
end >>>= 0
start >>>= 0
if (end <= start) {
return ''
}
if (!encoding) encoding = 'utf8'
while (true) {
switch (encoding) {
case 'hex':
return hexslice(this, start, end)
case 'utf8':
case 'utf-8':
return utf8slice(this, start, end)
case 'ascii':
return asciislice(this, start, end)
case 'latin1':
case 'binary':
return latin1slice(this, start, end)
case 'base64':
return base64slice(this, start, end)
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return utf16leslice(this, start, end)
default:
if (loweredcase) throw new typeerror('unknown encoding: ' + encoding)
encoding = (encoding + '').tolowercase()
loweredcase = true
}
}
}
// the property is used by `buffer.isbuffer` and `is-buffer` (in safari 5-7) to detect
// buffer instances.
buffer.prototype._isbuffer = true
function swap (b, n, m) {
var i = b[n]
b[n] = b[m]
b[m] = i
}
buffer.prototype.swap16 = function swap16 () {
var len = this.length
if (len % 2 !== 0) {
throw new rangeerror('buffer size must be a multiple of 16-bits')
}
for (var i = 0; i < len; i += 2) {
swap(this, i, i + 1)
}
return this
}
buffer.prototype.swap32 = function swap32 () {
var len = this.length
if (len % 4 !== 0) {
throw new rangeerror('buffer size must be a multiple of 32-bits')
}
for (var i = 0; i < len; i += 4) {
swap(this, i, i + 3)
swap(this, i + 1, i + 2)
}
return this
}
buffer.prototype.swap64 = function swap64 () {
var len = this.length
if (len % 8 !== 0) {
throw new rangeerror('buffer size must be a multiple of 64-bits')
}
for (var i = 0; i < len; i += 8) {
swap(this, i, i + 7)
swap(this, i + 1, i + 6)
swap(this, i + 2, i + 5)
swap(this, i + 3, i + 4)
}
return this
}
buffer.prototype.tostring = function tostring () {
var length = this.length | 0
if (length === 0) return ''
if (arguments.length === 0) return utf8slice(this, 0, length)
return slowtostring.apply(this, arguments)
}
buffer.prototype.equals = function equals (b) {
if (!buffer.isbuffer(b)) throw new typeerror('argument must be a buffer')
if (this === b) return true
return buffer.compare(this, b) === 0
}
buffer.prototype.inspect = function inspect () {
var str = ''
var max = exports.inspect_max_bytes
if (this.length > 0) {
str = this.tostring('hex', 0, max).match(/.{2}/g).join(' ')
if (this.length > max) str += ' ... '
}
return ''
}
buffer.prototype.compare = function compare (target, start, end, thisstart, thisend) {
if (!buffer.isbuffer(target)) {
throw new typeerror('argument must be a buffer')
}
if (start === undefined) {
start = 0
}
if (end === undefined) {
end = target ? target.length : 0
}
if (thisstart === undefined) {
thisstart = 0
}
if (thisend === undefined) {
thisend = this.length
}
if (start < 0 || end > target.length || thisstart < 0 || thisend > this.length) {
throw new rangeerror('out of range index')
}
if (thisstart >= thisend && start >= end) {
return 0
}
if (thisstart >= thisend) {
return -1
}
if (start >= end) {
return 1
}
start >>>= 0
end >>>= 0
thisstart >>>= 0
thisend >>>= 0
if (this === target) return 0
var x = thisend - thisstart
var y = end - start
var len = math.min(x, y)
var thiscopy = this.slice(thisstart, thisend)
var targetcopy = target.slice(start, end)
for (var i = 0; i < len; ++i) {
if (thiscopy[i] !== targetcopy[i]) {
x = thiscopy[i]
y = targetcopy[i]
break
}
}
if (x < y) return -1
if (y < x) return 1
return 0
}
// finds either the first index of `val` in `buffer` at offset >= `byteoffset`,
// or the last index of `val` in `buffer` at offset <= `byteoffset`.
//
// arguments:
// - buffer - a buffer to search
// - val - a string, buffer, or number
// - byteoffset - an index into `buffer`; will be clamped to an int32
// - encoding - an optional encoding, relevant is val is a string
// - dir - true for indexof, false for lastindexof
function bidirectionalindexof (buffer, val, byteoffset, encoding, dir) {
// empty buffer means no match
if (buffer.length === 0) return -1
// normalize byteoffset
if (typeof byteoffset === 'string') {
encoding = byteoffset
byteoffset = 0
} else if (byteoffset > 0x7fffffff) {
byteoffset = 0x7fffffff
} else if (byteoffset < -0x80000000) {
byteoffset = -0x80000000
}
byteoffset = +byteoffset // coerce to number.
if (isnan(byteoffset)) {
// byteoffset: it it's undefined, null, nan, "foo", etc, search whole buffer
byteoffset = dir ? 0 : (buffer.length - 1)
}
// normalize byteoffset: negative offsets start from the end of the buffer
if (byteoffset < 0) byteoffset = buffer.length + byteoffset
if (byteoffset >= buffer.length) {
if (dir) return -1
else byteoffset = buffer.length - 1
} else if (byteoffset < 0) {
if (dir) byteoffset = 0
else return -1
}
// normalize val
if (typeof val === 'string') {
val = buffer.from(val, encoding)
}
// finally, search either indexof (if dir is true) or lastindexof
if (buffer.isbuffer(val)) {
// special case: looking for empty string/buffer always fails
if (val.length === 0) {
return -1
}
return arrayindexof(buffer, val, byteoffset, encoding, dir)
} else if (typeof val === 'number') {
val = val & 0xff // search for a byte value [0-255]
if (buffer.typed_array_support &&
typeof uint8array.prototype.indexof === 'function') {
if (dir) {
return uint8array.prototype.indexof.call(buffer, val, byteoffset)
} else {
return uint8array.prototype.lastindexof.call(buffer, val, byteoffset)
}
}
return arrayindexof(buffer, [ val ], byteoffset, encoding, dir)
}
throw new typeerror('val must be string, number or buffer')
}
function arrayindexof (arr, val, byteoffset, encoding, dir) {
var indexsize = 1
var arrlength = arr.length
var vallength = val.length
if (encoding !== undefined) {
encoding = string(encoding).tolowercase()
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
encoding === 'utf16le' || encoding === 'utf-16le') {
if (arr.length < 2 || val.length < 2) {
return -1
}
indexsize = 2
arrlength /= 2
vallength /= 2
byteoffset /= 2
}
}
function read (buf, i) {
if (indexsize === 1) {
return buf[i]
} else {
return buf.readuint16be(i * indexsize)
}
}
var i
if (dir) {
var foundindex = -1
for (i = byteoffset; i < arrlength; i++) {
if (read(arr, i) === read(val, foundindex === -1 ? 0 : i - foundindex)) {
if (foundindex === -1) foundindex = i
if (i - foundindex + 1 === vallength) return foundindex * indexsize
} else {
if (foundindex !== -1) i -= i - foundindex
foundindex = -1
}
}
} else {
if (byteoffset + vallength > arrlength) byteoffset = arrlength - vallength
for (i = byteoffset; i >= 0; i--) {
var found = true
for (var j = 0; j < vallength; j++) {
if (read(arr, i + j) !== read(val, j)) {
found = false
break
}
}
if (found) return i
}
}
return -1
}
buffer.prototype.includes = function includes (val, byteoffset, encoding) {
return this.indexof(val, byteoffset, encoding) !== -1
}
buffer.prototype.indexof = function indexof (val, byteoffset, encoding) {
return bidirectionalindexof(this, val, byteoffset, encoding, true)
}
buffer.prototype.lastindexof = function lastindexof (val, byteoffset, encoding) {
return bidirectionalindexof(this, val, byteoffset, encoding, false)
}
function hexwrite (buf, string, offset, length) {
offset = number(offset) || 0
var remaining = buf.length - offset
if (!length) {
length = remaining
} else {
length = number(length)
if (length > remaining) {
length = remaining
}
}
// must be an even number of digits
var strlen = string.length
if (strlen % 2 !== 0) throw new typeerror('invalid hex string')
if (length > strlen / 2) {
length = strlen / 2
}
for (var i = 0; i < length; ++i) {
var parsed = parseint(string.substr(i * 2, 2), 16)
if (isnan(parsed)) return i
buf[offset + i] = parsed
}
return i
}
function utf8write (buf, string, offset, length) {
return blitbuffer(utf8tobytes(string, buf.length - offset), buf, offset, length)
}
function asciiwrite (buf, string, offset, length) {
return blitbuffer(asciitobytes(string), buf, offset, length)
}
function latin1write (buf, string, offset, length) {
return asciiwrite(buf, string, offset, length)
}
function base64write (buf, string, offset, length) {
return blitbuffer(base64tobytes(string), buf, offset, length)
}
function ucs2write (buf, string, offset, length) {
return blitbuffer(utf16letobytes(string, buf.length - offset), buf, offset, length)
}
buffer.prototype.write = function write (string, offset, length, encoding) {
// buffer#write(string)
if (offset === undefined) {
encoding = 'utf8'
length = this.length
offset = 0
// buffer#write(string, encoding)
} else if (length === undefined && typeof offset === 'string') {
encoding = offset
length = this.length
offset = 0
// buffer#write(string, offset[, length][, encoding])
} else if (isfinite(offset)) {
offset = offset | 0
if (isfinite(length)) {
length = length | 0
if (encoding === undefined) encoding = 'utf8'
} else {
encoding = length
length = undefined
}
// legacy write(string, encoding, offset, length) - remove in v0.13
} else {
throw new error(
'buffer.write(string, encoding, offset[, length]) is no longer supported'
)
}
var remaining = this.length - offset
if (length === undefined || length > remaining) length = remaining
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
throw new rangeerror('attempt to write outside buffer bounds')
}
if (!encoding) encoding = 'utf8'
var loweredcase = false
for (;;) {
switch (encoding) {
case 'hex':
return hexwrite(this, string, offset, length)
case 'utf8':
case 'utf-8':
return utf8write(this, string, offset, length)
case 'ascii':
return asciiwrite(this, string, offset, length)
case 'latin1':
case 'binary':
return latin1write(this, string, offset, length)
case 'base64':
// warning: maxlength not taken into account in base64write
return base64write(this, string, offset, length)
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return ucs2write(this, string, offset, length)
default:
if (loweredcase) throw new typeerror('unknown encoding: ' + encoding)
encoding = ('' + encoding).tolowercase()
loweredcase = true
}
}
}
buffer.prototype.tojson = function tojson () {
return {
type: 'buffer',
data: array.prototype.slice.call(this._arr || this, 0)
}
}
function base64slice (buf, start, end) {
if (start === 0 && end === buf.length) {
return base64.frombytearray(buf)
} else {
return base64.frombytearray(buf.slice(start, end))
}
}
function utf8slice (buf, start, end) {
end = math.min(buf.length, end)
var res = []
var i = start
while (i < end) {
var firstbyte = buf[i]
var codepoint = null
var bytespersequence = (firstbyte > 0xef) ? 4
: (firstbyte > 0xdf) ? 3
: (firstbyte > 0xbf) ? 2
: 1
if (i + bytespersequence <= end) {
var secondbyte, thirdbyte, fourthbyte, tempcodepoint
switch (bytespersequence) {
case 1:
if (firstbyte < 0x80) {
codepoint = firstbyte
}
break
case 2:
secondbyte = buf[i + 1]
if ((secondbyte & 0xc0) === 0x80) {
tempcodepoint = (firstbyte & 0x1f) << 0x6 | (secondbyte & 0x3f)
if (tempcodepoint > 0x7f) {
codepoint = tempcodepoint
}
}
break
case 3:
secondbyte = buf[i + 1]
thirdbyte = buf[i + 2]
if ((secondbyte & 0xc0) === 0x80 && (thirdbyte & 0xc0) === 0x80) {
tempcodepoint = (firstbyte & 0xf) << 0xc | (secondbyte & 0x3f) << 0x6 | (thirdbyte & 0x3f)
if (tempcodepoint > 0x7ff && (tempcodepoint < 0xd800 || tempcodepoint > 0xdfff)) {
codepoint = tempcodepoint
}
}
break
case 4:
secondbyte = buf[i + 1]
thirdbyte = buf[i + 2]
fourthbyte = buf[i + 3]
if ((secondbyte & 0xc0) === 0x80 && (thirdbyte & 0xc0) === 0x80 && (fourthbyte & 0xc0) === 0x80) {
tempcodepoint = (firstbyte & 0xf) << 0x12 | (secondbyte & 0x3f) << 0xc | (thirdbyte & 0x3f) << 0x6 | (fourthbyte & 0x3f)
if (tempcodepoint > 0xffff && tempcodepoint < 0x110000) {
codepoint = tempcodepoint
}
}
}
}
if (codepoint === null) {
// we did not generate a valid codepoint so insert a
// replacement char (u+fffd) and advance only 1 byte
codepoint = 0xfffd
bytespersequence = 1
} else if (codepoint > 0xffff) {
// encode to utf16 (surrogate pair dance)
codepoint -= 0x10000
res.push(codepoint >>> 10 & 0x3ff | 0xd800)
codepoint = 0xdc00 | codepoint & 0x3ff
}
res.push(codepoint)
i += bytespersequence
}
return decodecodepointsarray(res)
}
// based on http://stackoverflow.com/a/22747272/680742, the browser with
// the lowest limit is chrome, with 0x10000 args.
// we go 1 magnitude less, for safety
var max_arguments_length = 0x1000
function decodecodepointsarray (codepoints) {
var len = codepoints.length
if (len <= max_arguments_length) {
return string.fromcharcode.apply(string, codepoints) // avoid extra slice()
}
// decode in chunks to avoid "call stack size exceeded".
var res = ''
var i = 0
while (i < len) {
res += string.fromcharcode.apply(
string,
codepoints.slice(i, i += max_arguments_length)
)
}
return res
}
function asciislice (buf, start, end) {
var ret = ''
end = math.min(buf.length, end)
for (var i = start; i < end; ++i) {
ret += string.fromcharcode(buf[i] & 0x7f)
}
return ret
}
function latin1slice (buf, start, end) {
var ret = ''
end = math.min(buf.length, end)
for (var i = start; i < end; ++i) {
ret += string.fromcharcode(buf[i])
}
return ret
}
function hexslice (buf, start, end) {
var len = buf.length
if (!start || start < 0) start = 0
if (!end || end < 0 || end > len) end = len
var out = ''
for (var i = start; i < end; ++i) {
out += tohex(buf[i])
}
return out
}
function utf16leslice (buf, start, end) {
var bytes = buf.slice(start, end)
var res = ''
for (var i = 0; i < bytes.length; i += 2) {
res += string.fromcharcode(bytes[i] + bytes[i + 1] * 256)
}
return res
}
buffer.prototype.slice = function slice (start, end) {
var len = this.length
start = ~~start
end = end === undefined ? len : ~~end
if (start < 0) {
start += len
if (start < 0) start = 0
} else if (start > len) {
start = len
}
if (end < 0) {
end += len
if (end < 0) end = 0
} else if (end > len) {
end = len
}
if (end < start) end = start
var newbuf
if (buffer.typed_array_support) {
newbuf = this.subarray(start, end)
newbuf.__proto__ = buffer.prototype
} else {
var slicelen = end - start
newbuf = new buffer(slicelen, undefined)
for (var i = 0; i < slicelen; ++i) {
newbuf[i] = this[i + start]
}
}
return newbuf
}
/*
* need to make sure that buffer isn't trying to write out of bounds.
*/
function checkoffset (offset, ext, length) {
if ((offset % 1) !== 0 || offset < 0) throw new rangeerror('offset is not uint')
if (offset + ext > length) throw new rangeerror('trying to access beyond buffer length')
}
buffer.prototype.readuintle = function readuintle (offset, bytelength, noassert) {
offset = offset | 0
bytelength = bytelength | 0
if (!noassert) checkoffset(offset, bytelength, this.length)
var val = this[offset]
var mul = 1
var i = 0
while (++i < bytelength && (mul *= 0x100)) {
val += this[offset + i] * mul
}
return val
}
buffer.prototype.readuintbe = function readuintbe (offset, bytelength, noassert) {
offset = offset | 0
bytelength = bytelength | 0
if (!noassert) {
checkoffset(offset, bytelength, this.length)
}
var val = this[offset + --bytelength]
var mul = 1
while (bytelength > 0 && (mul *= 0x100)) {
val += this[offset + --bytelength] * mul
}
return val
}
buffer.prototype.readuint8 = function readuint8 (offset, noassert) {
if (!noassert) checkoffset(offset, 1, this.length)
return this[offset]
}
buffer.prototype.readuint16le = function readuint16le (offset, noassert) {
if (!noassert) checkoffset(offset, 2, this.length)
return this[offset] | (this[offset + 1] << 8)
}
buffer.prototype.readuint16be = function readuint16be (offset, noassert) {
if (!noassert) checkoffset(offset, 2, this.length)
return (this[offset] << 8) | this[offset + 1]
}
buffer.prototype.readuint32le = function readuint32le (offset, noassert) {
if (!noassert) checkoffset(offset, 4, this.length)
return ((this[offset]) |
(this[offset + 1] << 8) |
(this[offset + 2] << 16)) +
(this[offset + 3] * 0x1000000)
}
buffer.prototype.readuint32be = function readuint32be (offset, noassert) {
if (!noassert) checkoffset(offset, 4, this.length)
return (this[offset] * 0x1000000) +
((this[offset + 1] << 16) |
(this[offset + 2] << 8) |
this[offset + 3])
}
buffer.prototype.readintle = function readintle (offset, bytelength, noassert) {
offset = offset | 0
bytelength = bytelength | 0
if (!noassert) checkoffset(offset, bytelength, this.length)
var val = this[offset]
var mul = 1
var i = 0
while (++i < bytelength && (mul *= 0x100)) {
val += this[offset + i] * mul
}
mul *= 0x80
if (val >= mul) val -= math.pow(2, 8 * bytelength)
return val
}
buffer.prototype.readintbe = function readintbe (offset, bytelength, noassert) {
offset = offset | 0
bytelength = bytelength | 0
if (!noassert) checkoffset(offset, bytelength, this.length)
var i = bytelength
var mul = 1
var val = this[offset + --i]
while (i > 0 && (mul *= 0x100)) {
val += this[offset + --i] * mul
}
mul *= 0x80
if (val >= mul) val -= math.pow(2, 8 * bytelength)
return val
}
buffer.prototype.readint8 = function readint8 (offset, noassert) {
if (!noassert) checkoffset(offset, 1, this.length)
if (!(this[offset] & 0x80)) return (this[offset])
return ((0xff - this[offset] + 1) * -1)
}
buffer.prototype.readint16le = function readint16le (offset, noassert) {
if (!noassert) checkoffset(offset, 2, this.length)
var val = this[offset] | (this[offset + 1] << 8)
return (val & 0x8000) ? val | 0xffff0000 : val
}
buffer.prototype.readint16be = function readint16be (offset, noassert) {
if (!noassert) checkoffset(offset, 2, this.length)
var val = this[offset + 1] | (this[offset] << 8)
return (val & 0x8000) ? val | 0xffff0000 : val
}
buffer.prototype.readint32le = function readint32le (offset, noassert) {
if (!noassert) checkoffset(offset, 4, this.length)
return (this[offset]) |
(this[offset + 1] << 8) |
(this[offset + 2] << 16) |
(this[offset + 3] << 24)
}
buffer.prototype.readint32be = function readint32be (offset, noassert) {
if (!noassert) checkoffset(offset, 4, this.length)
return (this[offset] << 24) |
(this[offset + 1] << 16) |
(this[offset + 2] << 8) |
(this[offset + 3])
}
buffer.prototype.readfloatle = function readfloatle (offset, noassert) {
if (!noassert) checkoffset(offset, 4, this.length)
return ieee754.read(this, offset, true, 23, 4)
}
buffer.prototype.readfloatbe = function readfloatbe (offset, noassert) {
if (!noassert) checkoffset(offset, 4, this.length)
return ieee754.read(this, offset, false, 23, 4)
}
buffer.prototype.readdoublele = function readdoublele (offset, noassert) {
if (!noassert) checkoffset(offset, 8, this.length)
return ieee754.read(this, offset, true, 52, 8)
}
buffer.prototype.readdoublebe = function readdoublebe (offset, noassert) {
if (!noassert) checkoffset(offset, 8, this.length)
return ieee754.read(this, offset, false, 52, 8)
}
function checkint (buf, value, offset, ext, max, min) {
if (!buffer.isbuffer(buf)) throw new typeerror('"buffer" argument must be a buffer instance')
if (value > max || value < min) throw new rangeerror('"value" argument is out of bounds')
if (offset + ext > buf.length) throw new rangeerror('index out of range')
}
buffer.prototype.writeuintle = function writeuintle (value, offset, bytelength, noassert) {
value = +value
offset = offset | 0
bytelength = bytelength | 0
if (!noassert) {
var maxbytes = math.pow(2, 8 * bytelength) - 1
checkint(this, value, offset, bytelength, maxbytes, 0)
}
var mul = 1
var i = 0
this[offset] = value & 0xff
while (++i < bytelength && (mul *= 0x100)) {
this[offset + i] = (value / mul) & 0xff
}
return offset + bytelength
}
buffer.prototype.writeuintbe = function writeuintbe (value, offset, bytelength, noassert) {
value = +value
offset = offset | 0
bytelength = bytelength | 0
if (!noassert) {
var maxbytes = math.pow(2, 8 * bytelength) - 1
checkint(this, value, offset, bytelength, maxbytes, 0)
}
var i = bytelength - 1
var mul = 1
this[offset + i] = value & 0xff
while (--i >= 0 && (mul *= 0x100)) {
this[offset + i] = (value / mul) & 0xff
}
return offset + bytelength
}
buffer.prototype.writeuint8 = function writeuint8 (value, offset, noassert) {
value = +value
offset = offset | 0
if (!noassert) checkint(this, value, offset, 1, 0xff, 0)
if (!buffer.typed_array_support) value = math.floor(value)
this[offset] = (value & 0xff)
return offset + 1
}
function objectwriteuint16 (buf, value, offset, littleendian) {
if (value < 0) value = 0xffff + value + 1
for (var i = 0, j = math.min(buf.length - offset, 2); i < j; ++i) {
buf[offset + i] = (value & (0xff << (8 * (littleendian ? i : 1 - i)))) >>>
(littleendian ? i : 1 - i) * 8
}
}
buffer.prototype.writeuint16le = function writeuint16le (value, offset, noassert) {
value = +value
offset = offset | 0
if (!noassert) checkint(this, value, offset, 2, 0xffff, 0)
if (buffer.typed_array_support) {
this[offset] = (value & 0xff)
this[offset + 1] = (value >>> 8)
} else {
objectwriteuint16(this, value, offset, true)
}
return offset + 2
}
buffer.prototype.writeuint16be = function writeuint16be (value, offset, noassert) {
value = +value
offset = offset | 0
if (!noassert) checkint(this, value, offset, 2, 0xffff, 0)
if (buffer.typed_array_support) {
this[offset] = (value >>> 8)
this[offset + 1] = (value & 0xff)
} else {
objectwriteuint16(this, value, offset, false)
}
return offset + 2
}
function objectwriteuint32 (buf, value, offset, littleendian) {
if (value < 0) value = 0xffffffff + value + 1
for (var i = 0, j = math.min(buf.length - offset, 4); i < j; ++i) {
buf[offset + i] = (value >>> (littleendian ? i : 3 - i) * 8) & 0xff
}
}
buffer.prototype.writeuint32le = function writeuint32le (value, offset, noassert) {
value = +value
offset = offset | 0
if (!noassert) checkint(this, value, offset, 4, 0xffffffff, 0)
if (buffer.typed_array_support) {
this[offset + 3] = (value >>> 24)
this[offset + 2] = (value >>> 16)
this[offset + 1] = (value >>> 8)
this[offset] = (value & 0xff)
} else {
objectwriteuint32(this, value, offset, true)
}
return offset + 4
}
buffer.prototype.writeuint32be = function writeuint32be (value, offset, noassert) {
value = +value
offset = offset | 0
if (!noassert) checkint(this, value, offset, 4, 0xffffffff, 0)
if (buffer.typed_array_support) {
this[offset] = (value >>> 24)
this[offset + 1] = (value >>> 16)
this[offset + 2] = (value >>> 8)
this[offset + 3] = (value & 0xff)
} else {
objectwriteuint32(this, value, offset, false)
}
return offset + 4
}
buffer.prototype.writeintle = function writeintle (value, offset, bytelength, noassert) {
value = +value
offset = offset | 0
if (!noassert) {
var limit = math.pow(2, 8 * bytelength - 1)
checkint(this, value, offset, bytelength, limit - 1, -limit)
}
var i = 0
var mul = 1
var sub = 0
this[offset] = value & 0xff
while (++i < bytelength && (mul *= 0x100)) {
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
sub = 1
}
this[offset + i] = ((value / mul) >> 0) - sub & 0xff
}
return offset + bytelength
}
buffer.prototype.writeintbe = function writeintbe (value, offset, bytelength, noassert) {
value = +value
offset = offset | 0
if (!noassert) {
var limit = math.pow(2, 8 * bytelength - 1)
checkint(this, value, offset, bytelength, limit - 1, -limit)
}
var i = bytelength - 1
var mul = 1
var sub = 0
this[offset + i] = value & 0xff
while (--i >= 0 && (mul *= 0x100)) {
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
sub = 1
}
this[offset + i] = ((value / mul) >> 0) - sub & 0xff
}
return offset + bytelength
}
buffer.prototype.writeint8 = function writeint8 (value, offset, noassert) {
value = +value
offset = offset | 0
if (!noassert) checkint(this, value, offset, 1, 0x7f, -0x80)
if (!buffer.typed_array_support) value = math.floor(value)
if (value < 0) value = 0xff + value + 1
this[offset] = (value & 0xff)
return offset + 1
}
buffer.prototype.writeint16le = function writeint16le (value, offset, noassert) {
value = +value
offset = offset | 0
if (!noassert) checkint(this, value, offset, 2, 0x7fff, -0x8000)
if (buffer.typed_array_support) {
this[offset] = (value & 0xff)
this[offset + 1] = (value >>> 8)
} else {
objectwriteuint16(this, value, offset, true)
}
return offset + 2
}
buffer.prototype.writeint16be = function writeint16be (value, offset, noassert) {
value = +value
offset = offset | 0
if (!noassert) checkint(this, value, offset, 2, 0x7fff, -0x8000)
if (buffer.typed_array_support) {
this[offset] = (value >>> 8)
this[offset + 1] = (value & 0xff)
} else {
objectwriteuint16(this, value, offset, false)
}
return offset + 2
}
buffer.prototype.writeint32le = function writeint32le (value, offset, noassert) {
value = +value
offset = offset | 0
if (!noassert) checkint(this, value, offset, 4, 0x7fffffff, -0x80000000)
if (buffer.typed_array_support) {
this[offset] = (value & 0xff)
this[offset + 1] = (value >>> 8)
this[offset + 2] = (value >>> 16)
this[offset + 3] = (value >>> 24)
} else {
objectwriteuint32(this, value, offset, true)
}
return offset + 4
}
buffer.prototype.writeint32be = function writeint32be (value, offset, noassert) {
value = +value
offset = offset | 0
if (!noassert) checkint(this, value, offset, 4, 0x7fffffff, -0x80000000)
if (value < 0) value = 0xffffffff + value + 1
if (buffer.typed_array_support) {
this[offset] = (value >>> 24)
this[offset + 1] = (value >>> 16)
this[offset + 2] = (value >>> 8)
this[offset + 3] = (value & 0xff)
} else {
objectwriteuint32(this, value, offset, false)
}
return offset + 4
}
function checkieee754 (buf, value, offset, ext, max, min) {
if (offset + ext > buf.length) throw new rangeerror('index out of range')
if (offset < 0) throw new rangeerror('index out of range')
}
function writefloat (buf, value, offset, littleendian, noassert) {
if (!noassert) {
checkieee754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
}
ieee754.write(buf, value, offset, littleendian, 23, 4)
return offset + 4
}
buffer.prototype.writefloatle = function writefloatle (value, offset, noassert) {
return writefloat(this, value, offset, true, noassert)
}
buffer.prototype.writefloatbe = function writefloatbe (value, offset, noassert) {
return writefloat(this, value, offset, false, noassert)
}
function writedouble (buf, value, offset, littleendian, noassert) {
if (!noassert) {
checkieee754(buf, value, offset, 8, 1.7976931348623157e+308, -1.7976931348623157e+308)
}
ieee754.write(buf, value, offset, littleendian, 52, 8)
return offset + 8
}
buffer.prototype.writedoublele = function writedoublele (value, offset, noassert) {
return writedouble(this, value, offset, true, noassert)
}
buffer.prototype.writedoublebe = function writedoublebe (value, offset, noassert) {
return writedouble(this, value, offset, false, noassert)
}
// copy(targetbuffer, targetstart=0, sourcestart=0, sourceend=buffer.length)
buffer.prototype.copy = function copy (target, targetstart, start, end) {
if (!start) start = 0
if (!end && end !== 0) end = this.length
if (targetstart >= target.length) targetstart = target.length
if (!targetstart) targetstart = 0
if (end > 0 && end < start) end = start
// copy 0 bytes; we're done
if (end === start) return 0
if (target.length === 0 || this.length === 0) return 0
// fatal error conditions
if (targetstart < 0) {
throw new rangeerror('targetstart out of bounds')
}
if (start < 0 || start >= this.length) throw new rangeerror('sourcestart out of bounds')
if (end < 0) throw new rangeerror('sourceend out of bounds')
// are we oob?
if (end > this.length) end = this.length
if (target.length - targetstart < end - start) {
end = target.length - targetstart + start
}
var len = end - start
var i
if (this === target && start < targetstart && targetstart < end) {
// descending copy from end
for (i = len - 1; i >= 0; --i) {
target[i + targetstart] = this[i + start]
}
} else if (len < 1000 || !buffer.typed_array_support) {
// ascending copy from start
for (i = 0; i < len; ++i) {
target[i + targetstart] = this[i + start]
}
} else {
uint8array.prototype.set.call(
target,
this.subarray(start, start + len),
targetstart
)
}
return len
}
// usage:
// buffer.fill(number[, offset[, end]])
// buffer.fill(buffer[, offset[, end]])
// buffer.fill(string[, offset[, end]][, encoding])
buffer.prototype.fill = function fill (val, start, end, encoding) {
// handle string cases:
if (typeof val === 'string') {
if (typeof start === 'string') {
encoding = start
start = 0
end = this.length
} else if (typeof end === 'string') {
encoding = end
end = this.length
}
if (val.length === 1) {
var code = val.charcodeat(0)
if (code < 256) {
val = code
}
}
if (encoding !== undefined && typeof encoding !== 'string') {
throw new typeerror('encoding must be a string')
}
if (typeof encoding === 'string' && !buffer.isencoding(encoding)) {
throw new typeerror('unknown encoding: ' + encoding)
}
} else if (typeof val === 'number') {
val = val & 255
}
// invalid ranges are not set to a default, so can range check early.
if (start < 0 || this.length < start || this.length < end) {
throw new rangeerror('out of range index')
}
if (end <= start) {
return this
}
start = start >>> 0
end = end === undefined ? this.length : end >>> 0
if (!val) val = 0
var i
if (typeof val === 'number') {
for (i = start; i < end; ++i) {
this[i] = val
}
} else {
var bytes = buffer.isbuffer(val)
? val
: utf8tobytes(new buffer(val, encoding).tostring())
var len = bytes.length
for (i = 0; i < end - start; ++i) {
this[i + start] = bytes[i % len]
}
}
return this
}
// helper functions
// ================
var invalid_base64_re = /[^+\/0-9a-za-z-_]/g
function base64clean (str) {
// node strips out invalid characters like \n and \t from the string, base64-js does not
str = stringtrim(str).replace(invalid_base64_re, '')
// node converts strings with length < 2 to ''
if (str.length < 2) return ''
// node allows for non-padded base64 strings (missing trailing ===), base64-js does not
while (str.length % 4 !== 0) {
str = str + '='
}
return str
}
function stringtrim (str) {
if (str.trim) return str.trim()
return str.replace(/^\s+|\s+$/g, '')
}
function tohex (n) {
if (n < 16) return '0' + n.tostring(16)
return n.tostring(16)
}
function utf8tobytes (string, units) {
units = units || infinity
var codepoint
var length = string.length
var leadsurrogate = null
var bytes = []
for (var i = 0; i < length; ++i) {
codepoint = string.charcodeat(i)
// is surrogate component
if (codepoint > 0xd7ff && codepoint < 0xe000) {
// last char was a lead
if (!leadsurrogate) {
// no lead yet
if (codepoint > 0xdbff) {
// unexpected trail
if ((units -= 3) > -1) bytes.push(0xef, 0xbf, 0xbd)
continue
} else if (i + 1 === length) {
// unpaired lead
if ((units -= 3) > -1) bytes.push(0xef, 0xbf, 0xbd)
continue
}
// valid lead
leadsurrogate = codepoint
continue
}
// 2 leads in a row
if (codepoint < 0xdc00) {
if ((units -= 3) > -1) bytes.push(0xef, 0xbf, 0xbd)
leadsurrogate = codepoint
continue
}
// valid surrogate pair
codepoint = (leadsurrogate - 0xd800 << 10 | codepoint - 0xdc00) + 0x10000
} else if (leadsurrogate) {
// valid bmp char, but last char was a lead
if ((units -= 3) > -1) bytes.push(0xef, 0xbf, 0xbd)
}
leadsurrogate = null
// encode utf8
if (codepoint < 0x80) {
if ((units -= 1) < 0) break
bytes.push(codepoint)
} else if (codepoint < 0x800) {
if ((units -= 2) < 0) break
bytes.push(
codepoint >> 0x6 | 0xc0,
codepoint & 0x3f | 0x80
)
} else if (codepoint < 0x10000) {
if ((units -= 3) < 0) break
bytes.push(
codepoint >> 0xc | 0xe0,
codepoint >> 0x6 & 0x3f | 0x80,
codepoint & 0x3f | 0x80
)
} else if (codepoint < 0x110000) {
if ((units -= 4) < 0) break
bytes.push(
codepoint >> 0x12 | 0xf0,
codepoint >> 0xc & 0x3f | 0x80,
codepoint >> 0x6 & 0x3f | 0x80,
codepoint & 0x3f | 0x80
)
} else {
throw new error('invalid code point')
}
}
return bytes
}
function asciitobytes (str) {
var bytearray = []
for (var i = 0; i < str.length; ++i) {
// node's code seems to be doing this and not & 0x7f..
bytearray.push(str.charcodeat(i) & 0xff)
}
return bytearray
}
function utf16letobytes (str, units) {
var c, hi, lo
var bytearray = []
for (var i = 0; i < str.length; ++i) {
if ((units -= 2) < 0) break
c = str.charcodeat(i)
hi = c >> 8
lo = c % 256
bytearray.push(lo)
bytearray.push(hi)
}
return bytearray
}
function base64tobytes (str) {
return base64.tobytearray(base64clean(str))
}
function blitbuffer (src, dst, offset, length) {
for (var i = 0; i < length; ++i) {
if ((i + offset >= dst.length) || (i >= src.length)) break
dst[i + offset] = src[i]
}
return i
}
function isnan (val) {
return val !== val // eslint-disable-line no-self-compare
}
/* webpack var injection */}.call(this, __webpack_require__(15)))
/***/ }),
/***/ 316:
/***/ (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
}
// support decoding url-safe base64 strings, as node.js does.
// see: https://en.wikipedia.org/wiki/base64#url_applications
revlookup['-'.charcodeat(0)] = 62
revlookup['_'.charcodeat(0)] = 63
function getlens (b64) {
var len = b64.length
if (len % 4 > 0) {
throw new error('invalid string. length must be a multiple of 4')
}
// trim off extra bytes after placeholder bytes are found
// see: https://github.com/beatgammit/base64-js/issues/42
var validlen = b64.indexof('=')
if (validlen === -1) validlen = len
var placeholderslen = validlen === len
? 0
: 4 - (validlen % 4)
return [validlen, placeholderslen]
}
// base64 is 4/3 + up to two characters of the original data
function bytelength (b64) {
var lens = getlens(b64)
var validlen = lens[0]
var placeholderslen = lens[1]
return ((validlen + placeholderslen) * 3 / 4) - placeholderslen
}
function _bytelength (b64, validlen, placeholderslen) {
return ((validlen + placeholderslen) * 3 / 4) - placeholderslen
}
function tobytearray (b64) {
var tmp
var lens = getlens(b64)
var validlen = lens[0]
var placeholderslen = lens[1]
var arr = new arr(_bytelength(b64, validlen, placeholderslen))
var curbyte = 0
// if there are placeholders, only get up to the last complete 4 chars
var len = placeholderslen > 0
? validlen - 4
: validlen
var i
for (i = 0; i < len; i += 4) {
tmp =
(revlookup[b64.charcodeat(i)] << 18) |
(revlookup[b64.charcodeat(i + 1)] << 12) |
(revlookup[b64.charcodeat(i + 2)] << 6) |
revlookup[b64.charcodeat(i + 3)]
arr[curbyte++] = (tmp >> 16) & 0xff
arr[curbyte++] = (tmp >> 8) & 0xff
arr[curbyte++] = tmp & 0xff
}
if (placeholderslen === 2) {
tmp =
(revlookup[b64.charcodeat(i)] << 2) |
(revlookup[b64.charcodeat(i + 1)] >> 4)
arr[curbyte++] = tmp & 0xff
}
if (placeholderslen === 1) {
tmp =
(revlookup[b64.charcodeat(i)] << 10) |
(revlookup[b64.charcodeat(i + 1)] << 4) |
(revlookup[b64.charcodeat(i + 2)] >> 2)
arr[curbyte++] = (tmp >> 8) & 0xff
arr[curbyte++] = tmp & 0xff
}
return arr
}
function triplettobase64 (num) {
return lookup[num >> 18 & 0x3f] +
lookup[num >> 12 & 0x3f] +
lookup[num >> 6 & 0x3f] +
lookup[num & 0x3f]
}
function encodechunk (uint8, start, end) {
var tmp
var output = []
for (var i = start; i < end; i += 3) {
tmp =
((uint8[i] << 16) & 0xff0000) +
((uint8[i + 1] << 8) & 0xff00) +
(uint8[i + 2] & 0xff)
output.push(triplettobase64(tmp))
}
return output.join('')
}
function frombytearray (uint8) {
var tmp
var len = uint8.length
var extrabytes = len % 3 // if we have 1 byte left, pad 2 bytes
var parts = []
var maxchunklength = 16383 // must be multiple of 3
// go through the array every three bytes, we'll deal with trailing stuff later
for (var i = 0, len2 = len - extrabytes; i < len2; i += maxchunklength) {
parts.push(encodechunk(uint8, i, (i + maxchunklength) > len2 ? len2 : (i + maxchunklength)))
}
// pad the end with zeros, but make sure to not forget the extra bytes
if (extrabytes === 1) {
tmp = uint8[len - 1]
parts.push(
lookup[tmp >> 2] +
lookup[(tmp << 4) & 0x3f] +
'=='
)
} else if (extrabytes === 2) {
tmp = (uint8[len - 2] << 8) + uint8[len - 1]
parts.push(
lookup[tmp >> 10] +
lookup[(tmp >> 4) & 0x3f] +
lookup[(tmp << 2) & 0x3f] +
'='
)
}
return parts.join('')
}
/***/ }),
/***/ 319:
/***/ (function(module, exports, __webpack_require__) {
var conventions = __webpack_require__(84);
var dom = __webpack_require__(177)
var entities = __webpack_require__(320);
var sax = __webpack_require__(321);
var domimplementation = dom.domimplementation;
var namespace = conventions.namespace;
var parseerror = sax.parseerror;
var xmlreader = sax.xmlreader;
function domparser(options){
this.options = options ||{locator:{}};
}
domparser.prototype.parsefromstring = function(source,mimetype){
var options = this.options;
var sax = new xmlreader();
var dombuilder = options.dombuilder || new domhandler();//contenthandler and lexicalhandler
var errorhandler = options.errorhandler;
var locator = options.locator;
var defaultnsmap = options.xmlns||{};
var ishtml = /\/x?html?$/.test(mimetype);//mimetype.tolowercase().indexof('html') > -1;
var entitymap = ishtml ? entities.html_entities : entities.xml_entities;
if(locator){
dombuilder.setdocumentlocator(locator)
}
sax.errorhandler = builderrorhandler(errorhandler,dombuilder,locator);
sax.dombuilder = options.dombuilder || dombuilder;
if(ishtml){
defaultnsmap[''] = namespace.html;
}
defaultnsmap.xml = defaultnsmap.xml || namespace.xml;
if(source && typeof source === 'string'){
sax.parse(source,defaultnsmap,entitymap);
}else{
sax.errorhandler.error("invalid doc source");
}
return dombuilder.doc;
}
function builderrorhandler(errorimpl,dombuilder,locator){
if(!errorimpl){
if(dombuilder instanceof domhandler){
return dombuilder;
}
errorimpl = dombuilder ;
}
var errorhandler = {}
var iscallback = errorimpl instanceof function;
locator = locator||{}
function build(key){
var fn = errorimpl[key];
if(!fn && iscallback){
fn = errorimpl.length == 2?function(msg){errorimpl(key,msg)}:errorimpl;
}
errorhandler[key] = fn && function(msg){
fn('[xmldom '+key+']\t'+msg+_locator(locator));
}||function(){};
}
build('warning');
build('error');
build('fatalerror');
return errorhandler;
}
//console.log('#\n\n\n\n\n\n\n####')
/**
* +contenthandler+errorhandler
* +lexicalhandler+entityresolver2
* -declhandler-dtdhandler
*
* defaulthandler:entityresolver, dtdhandler, contenthandler, errorhandler
* defaulthandler2:defaulthandler,lexicalhandler, declhandler, entityresolver2
* @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/defaulthandler.html
*/
function domhandler() {
this.cdata = false;
}
function position(locator,node){
node.linenumber = locator.linenumber;
node.columnnumber = locator.columnnumber;
}
/**
* @see org.xml.sax.contenthandler#startdocument
* @link http://www.saxproject.org/apidoc/org/xml/sax/contenthandler.html
*/
domhandler.prototype = {
startdocument : function() {
this.doc = new domimplementation().createdocument(null, null, null);
if (this.locator) {
this.doc.documenturi = this.locator.systemid;
}
},
startelement:function(namespaceuri, localname, qname, attrs) {
var doc = this.doc;
var el = doc.createelementns(namespaceuri, qname||localname);
var len = attrs.length;
appendelement(this, el);
this.currentelement = el;
this.locator && position(this.locator,el)
for (var i = 0 ; i < len; i++) {
var namespaceuri = attrs.geturi(i);
var value = attrs.getvalue(i);
var qname = attrs.getqname(i);
var attr = doc.createattributens(namespaceuri, qname);
this.locator &&position(attrs.getlocator(i),attr);
attr.value = attr.nodevalue = value;
el.setattributenode(attr)
}
},
endelement:function(namespaceuri, localname, qname) {
var current = this.currentelement
var tagname = current.tagname;
this.currentelement = current.parentnode;
},
startprefixmapping:function(prefix, uri) {
},
endprefixmapping:function(prefix) {
},
processinginstruction:function(target, data) {
var ins = this.doc.createprocessinginstruction(target, data);
this.locator && position(this.locator,ins)
appendelement(this, ins);
},
ignorablewhitespace:function(ch, start, length) {
},
characters:function(chars, start, length) {
chars = _tostring.apply(this,arguments)
//console.log(chars)
if(chars){
if (this.cdata) {
var charnode = this.doc.createcdatasection(chars);
} else {
var charnode = this.doc.createtextnode(chars);
}
if(this.currentelement){
this.currentelement.appendchild(charnode);
}else if(/^\s*$/.test(chars)){
this.doc.appendchild(charnode);
//process xml
}
this.locator && position(this.locator,charnode)
}
},
skippedentity:function(name) {
},
enddocument:function() {
this.doc.normalize();
},
setdocumentlocator:function (locator) {
if(this.locator = locator){// && !('linenumber' in locator)){
locator.linenumber = 0;
}
},
//lexicalhandler
comment:function(chars, start, length) {
chars = _tostring.apply(this,arguments)
var comm = this.doc.createcomment(chars);
this.locator && position(this.locator,comm)
appendelement(this, comm);
},
startcdata:function() {
//used in characters() methods
this.cdata = true;
},
endcdata:function() {
this.cdata = false;
},
startdtd:function(name, publicid, systemid) {
var impl = this.doc.implementation;
if (impl && impl.createdocumenttype) {
var dt = impl.createdocumenttype(name, publicid, systemid);
this.locator && position(this.locator,dt)
appendelement(this, dt);
this.doc.doctype = dt;
}
},
/**
* @see org.xml.sax.errorhandler
* @link http://www.saxproject.org/apidoc/org/xml/sax/errorhandler.html
*/
warning:function(error) {
console.warn('[xmldom warning]\t'+error,_locator(this.locator));
},
error:function(error) {
console.error('[xmldom error]\t'+error,_locator(this.locator));
},
fatalerror:function(error) {
throw new parseerror(error, this.locator);
}
}
function _locator(l){
if(l){
return '\n@'+(l.systemid ||'')+'#[line:'+l.linenumber+',col:'+l.columnnumber+']'
}
}
function _tostring(chars,start,length){
if(typeof chars == 'string'){
return chars.substr(start,length)
}else{//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof string)")
if(chars.length >= start+length || start){
return new java.lang.string(chars,start,length)+'';
}
return chars;
}
}
/*
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/lexicalhandler.html
* used method of org.xml.sax.ext.lexicalhandler:
* #comment(chars, start, length)
* #startcdata()
* #endcdata()
* #startdtd(name, publicid, systemid)
*
*
* ignored method of org.xml.sax.ext.lexicalhandler:
* #enddtd()
* #startentity(name)
* #endentity(name)
*
*
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/declhandler.html
* ignored method of org.xml.sax.ext.declhandler
* #attributedecl(ename, aname, type, mode, value)
* #elementdecl(name, model)
* #externalentitydecl(name, publicid, systemid)
* #internalentitydecl(name, value)
* @link http://www.saxproject.org/apidoc/org/xml/sax/ext/entityresolver2.html
* ignored method of org.xml.sax.entityresolver2
* #resolveentity(string name,string publicid,string baseuri,string systemid)
* #resolveentity(publicid, systemid)
* #getexternalsubset(name, baseuri)
* @link http://www.saxproject.org/apidoc/org/xml/sax/dtdhandler.html
* ignored method of org.xml.sax.dtdhandler
* #notationdecl(name, publicid, systemid) {};
* #unparsedentitydecl(name, publicid, systemid, notationname) {};
*/
"enddtd,startentity,endentity,attributedecl,elementdecl,externalentitydecl,internalentitydecl,resolveentity,getexternalsubset,notationdecl,unparsedentitydecl".replace(/\w+/g,function(key){
domhandler.prototype[key] = function(){return null}
})
/* private static helpers treated below as private instance methods, so don't need to add these to the public api; we might use a relator to also get rid of non-standard public properties */
function appendelement (hander,node) {
if (!hander.currentelement) {
hander.doc.appendchild(node);
} else {
hander.currentelement.appendchild(node);
}
}//appendchild and setattributens are preformance key
exports.__domhandler = domhandler;
exports.domparser = domparser;
/**
* @deprecated import/require from main entry point instead
*/
exports.domimplementation = dom.domimplementation;
/**
* @deprecated import/require from main entry point instead
*/
exports.xmlserializer = dom.xmlserializer;
/***/ }),
/***/ 320:
/***/ (function(module, exports, __webpack_require__) {
var freeze = __webpack_require__(84).freeze;
/**
* the entities that are predefined in every xml document.
*
* @see https://www.w3.org/tr/2006/rec-xml11-20060816/#sec-predefined-ent w3c xml 1.1
* @see https://www.w3.org/tr/2008/rec-xml-20081126/#sec-predefined-ent w3c xml 1.0
* @see https://en.wikipedia.org/wiki/list_of_xml_and_html_character_entity_references#predefined_entities_in_xml wikipedia
*/
exports.xml_entities = freeze({amp:'&', apos:"'", gt:'>', lt:'<', quot:'"'})
/**
* a map of currently 241 entities that are detected in an html document.
* they contain all entries from `xml_entities`.
*
* @see xml_entities
* @see domparser.parsefromstring
* @see domimplementation.prototype.createhtmldocument
* @see https://html.spec.whatwg.org/#named-character-references whatwg html(5) spec
* @see https://www.w3.org/tr/xml-entity-names/ w3c xml entity names
* @see https://www.w3.org/tr/html4/sgml/entities.html w3c html4/sgml
* @see https://en.wikipedia.org/wiki/list_of_xml_and_html_character_entity_references#character_entity_references_in_html wikipedia (html)
* @see https://en.wikipedia.org/wiki/list_of_xml_and_html_character_entity_references#entities_representing_special_characters_in_xhtml wikpedia (xhtml)
*/
exports.html_entities = freeze({
lt: '<',
gt: '>',
amp: '&',
quot: '"',
apos: "'",
agrave: "à",
aacute: "á",
acirc: "â",
atilde: "ã",
auml: "ä",
aring: "å",
aelig: "æ",
ccedil: "ç",
egrave: "è",
eacute: "é",
ecirc: "ê",
euml: "ë",
igrave: "ì",
iacute: "í",
icirc: "î",
iuml: "ï",
eth: "ð",
ntilde: "ñ",
ograve: "ò",
oacute: "ó",
ocirc: "ô",
otilde: "õ",
ouml: "ö",
oslash: "ø",
ugrave: "ù",
uacute: "ú",
ucirc: "û",
uuml: "ü",
yacute: "ý",
thorn: "þ",
szlig: "ß",
agrave: "à",
aacute: "á",
acirc: "â",
atilde: "ã",
auml: "ä",
aring: "å",
aelig: "æ",
ccedil: "ç",
egrave: "è",
eacute: "é",
ecirc: "ê",
euml: "ë",
igrave: "ì",
iacute: "í",
icirc: "î",
iuml: "ï",
eth: "ð",
ntilde: "ñ",
ograve: "ò",
oacute: "ó",
ocirc: "ô",
otilde: "õ",
ouml: "ö",
oslash: "ø",
ugrave: "ù",
uacute: "ú",
ucirc: "û",
uuml: "ü",
yacute: "ý",
thorn: "þ",
yuml: "ÿ",
nbsp: "\u00a0",
iexcl: "¡",
cent: "¢",
pound: "£",
curren: "¤",
yen: "¥",
brvbar: "¦",
sect: "§",
uml: "¨",
copy: "©",
ordf: "ª",
laquo: "«",
not: "¬",
shy: "",
reg: "®",
macr: "¯",
deg: "°",
plusmn: "±",
sup2: "²",
sup3: "³",
acute: "´",
micro: "µ",
para: "¶",
middot: "·",
cedil: "¸",
sup1: "¹",
ordm: "º",
raquo: "»",
frac14: "¼",
frac12: "½",
frac34: "¾",
iquest: "¿",
times: "×",
divide: "÷",
forall: "∀",
part: "∂",
exist: "∃",
empty: "∅",
nabla: "∇",
isin: "∈",
notin: "∉",
ni: "∋",
prod: "∏",
sum: "∑",
minus: "−",
lowast: "∗",
radic: "√",
prop: "∝",
infin: "∞",
ang: "∠",
and: "∧",
or: "∨",
cap: "∩",
cup: "∪",
'int': "∫",
there4: "∴",
sim: "∼",
cong: "≅",
asymp: "≈",
ne: "≠",
equiv: "≡",
le: "≤",
ge: "≥",
sub: "⊂",
sup: "⊃",
nsub: "⊄",
sube: "⊆",
supe: "⊇",
oplus: "⊕",
otimes: "⊗",
perp: "⊥",
sdot: "⋅",
alpha: "α",
beta: "β",
gamma: "γ",
delta: "δ",
epsilon: "ε",
zeta: "ζ",
eta: "η",
theta: "θ",
iota: "ι",
kappa: "κ",
lambda: "λ",
mu: "μ",
nu: "ν",
xi: "ξ",
omicron: "ο",
pi: "π",
rho: "ρ",
sigma: "σ",
tau: "τ",
upsilon: "υ",
phi: "φ",
chi: "χ",
psi: "ψ",
omega: "ω",
alpha: "α",
beta: "β",
gamma: "γ",
delta: "δ",
epsilon: "ε",
zeta: "ζ",
eta: "η",
theta: "θ",
iota: "ι",
kappa: "κ",
lambda: "λ",
mu: "μ",
nu: "ν",
xi: "ξ",
omicron: "ο",
pi: "π",
rho: "ρ",
sigmaf: "ς",
sigma: "σ",
tau: "τ",
upsilon: "υ",
phi: "φ",
chi: "χ",
psi: "ψ",
omega: "ω",
thetasym: "ϑ",
upsih: "υ",
piv: "ϖ",
oelig: "œ",
oelig: "œ",
scaron: "š",
scaron: "š",
yuml: "ÿ",
fnof: "ƒ",
circ: "ˆ",
tilde: "˜",
ensp: " ",
emsp: " ",
thinsp: " ",
zwnj: "",
zwj: "",
lrm: "",
rlm: "",
ndash: "–",
mdash: "—",
lsquo: "‘",
rsquo: "’",
sbquo: "‚",
ldquo: "“",
rdquo: "”",
bdquo: "„",
dagger: "†",
dagger: "‡",
bull: "•",
hellip: "…",
permil: "‰",
prime: "′",
prime: "″",
lsaquo: "‹",
rsaquo: "›",
oline: "‾",
euro: "€",
trade: "™",
larr: "←",
uarr: "↑",
rarr: "→",
darr: "↓",
harr: "↔",
crarr: "↵",
lceil: "⌈",
rceil: "⌉",
lfloor: "⌊",
rfloor: "⌋",
loz: "◊",
spades: "♠",
clubs: "♣",
hearts: "♥",
diams: "♦"
});
/**
* @deprecated use `html_entities` instead
* @see html_entities
*/
exports.entitymap = exports.html_entities
/***/ }),
/***/ 321:
/***/ (function(module, exports, __webpack_require__) {
var namespace = __webpack_require__(84).namespace;
//[4] namestartchar ::= ":" | [a-z] | "_" | [a-z] | [#xc0-#xd6] | [#xd8-#xf6] | [#xf8-#x2ff] | [#x370-#x37d] | [#x37f-#x1fff] | [#x200c-#x200d] | [#x2070-#x218f] | [#x2c00-#x2fef] | [#x3001-#xd7ff] | [#xf900-#xfdcf] | [#xfdf0-#xfffd] | [#x10000-#xeffff]
//[4a] namechar ::= namestartchar | "-" | "." | [0-9] | #xb7 | [#x0300-#x036f] | [#x203f-#x2040]
//[5] name ::= namestartchar (namechar)*
var namestartchar = /[a-z_a-z\xc0-\xd6\xd8-\xf6\u00f8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c-\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]///\u10000-\ueffff
var namechar = new regexp("[\\-\\.0-9"+namestartchar.source.slice(1,-1)+"\\u00b7\\u0300-\\u036f\\u203f-\\u2040]");
var tagnamepattern = new regexp('^'+namestartchar.source+namechar.source+'*(?:\:'+namestartchar.source+namechar.source+'*)?$');
//var tagnamepattern = /^[a-za-z_][\w\-\.]*(?:\:[a-za-z_][\w\-\.]*)?$/
//var handlers = 'resolveentity,getexternalsubset,characters,enddocument,endelement,endprefixmapping,ignorablewhitespace,processinginstruction,setdocumentlocator,skippedentity,startdocument,startelement,startprefixmapping,notationdecl,unparsedentitydecl,error,fatalerror,warning,attributedecl,elementdecl,externalentitydecl,internalentitydecl,comment,endcdata,enddtd,endentity,startcdata,startdtd,startentity'.split(',')
//s_tag, s_attr, s_eq, s_attr_noquot_value
//s_attr_space, s_attr_end, s_tag_space, s_tag_close
var s_tag = 0;//tag name offerring
var s_attr = 1;//attr name offerring
var s_attr_space=2;//attr name end and space offer
var s_eq = 3;//=space?
var s_attr_noquot_value = 4;//attr value(no quot value only)
var s_attr_end = 5;//attr value end and no space(quot end)
var s_tag_space = 6;//(attr value end || tag end ) && (space offer)
var s_tag_close = 7;//closed el
/**
* creates an error that will not be caught by xmlreader aka the sax parser.
*
* @param {string} message
* @param {any?} locator optional, can provide details about the location in the source
* @constructor
*/
function parseerror(message, locator) {
this.message = message
this.locator = locator
if(error.capturestacktrace) error.capturestacktrace(this, parseerror);
}
parseerror.prototype = new error();
parseerror.prototype.name = parseerror.name
function xmlreader(){
}
xmlreader.prototype = {
parse:function(source,defaultnsmap,entitymap){
var dombuilder = this.dombuilder;
dombuilder.startdocument();
_copy(defaultnsmap ,defaultnsmap = {})
parse(source,defaultnsmap,entitymap,
dombuilder,this.errorhandler);
dombuilder.enddocument();
}
}
function parse(source,defaultnsmapcopy,entitymap,dombuilder,errorhandler){
function fixedfromcharcode(code) {
// string.prototype.fromcharcode does not supports
// > 2 bytes unicode chars directly
if (code > 0xffff) {
code -= 0x10000;
var surrogate1 = 0xd800 + (code >> 10)
, surrogate2 = 0xdc00 + (code & 0x3ff);
return string.fromcharcode(surrogate1, surrogate2);
} else {
return string.fromcharcode(code);
}
}
function entityreplacer(a){
var k = a.slice(1,-1);
if(k in entitymap){
return entitymap[k];
}else if(k.charat(0) === '#'){
return fixedfromcharcode(parseint(k.substr(1).replace('x','0x')))
}else{
errorhandler.error('entity not found:'+a);
return a;
}
}
function appendtext(end){//has some bugs
if(end>start){
var xt = source.substring(start,end).replace(/?\w+;/g,entityreplacer);
locator&&position(start);
dombuilder.characters(xt,0,end-start);
start = end
}
}
function position(p,m){
while(p>=lineend && (m = linepattern.exec(source))){
linestart = m.index;
lineend = linestart + m[0].length;
locator.linenumber++;
//console.log('line++:',locator,startpos,endpos)
}
locator.columnnumber = p-linestart+1;
}
var linestart = 0;
var lineend = 0;
var linepattern = /.*(?:\r\n?|\n)|.*$/g
var locator = dombuilder.locator;
var parsestack = [{currentnsmap:defaultnsmapcopy}]
var closemap = {};
var start = 0;
while(true){
try{
var tagstart = source.indexof('<',start);
if(tagstart<0){
if(!source.substr(start).match(/^\s*$/)){
var doc = dombuilder.doc;
var text = doc.createtextnode(source.substr(start));
doc.appendchild(text);
dombuilder.currentelement = text;
}
return;
}
if(tagstart>start){
appendtext(tagstart);
}
switch(source.charat(tagstart+1)){
case '/':
var end = source.indexof('>',tagstart+3);
var tagname = source.substring(tagstart + 2, end).replace(/[ \t\n\r]+$/g, '');
var config = parsestack.pop();
if(end<0){
tagname = source.substring(tagstart+2).replace(/[\s<].*/,'');
errorhandler.error("end tag name: "+tagname+' is not complete:'+config.tagname);
end = tagstart+1+tagname.length;
}else if(tagname.match(/\s)){
tagname = tagname.replace(/[\s<].*/,'');
errorhandler.error("end tag name: "+tagname+' maybe not complete');
end = tagstart+1+tagname.length;
}
var localnsmap = config.localnsmap;
var endmatch = config.tagname == tagname;
var endignorecasemach = endmatch || config.tagname&&config.tagname.tolowercase() == tagname.tolowercase()
if(endignorecasemach){
dombuilder.endelement(config.uri,config.localname,tagname);
if(localnsmap){
for(var prefix in localnsmap){
dombuilder.endprefixmapping(prefix) ;
}
}
if(!endmatch){
errorhandler.fatalerror("end tag name: "+tagname+' is not match the current start tagname:'+config.tagname ); // no known test case
}
}else{
parsestack.push(config)
}
end++;
break;
// end elment
case '?':// ...?>
locator&&position(tagstart);
end = parseinstruction(source,tagstart,dombuilder);
break;
case '!':// start){
start = end;
}else{
//todo: 这里有可能sax回退,有位置错误风险
appendtext(math.max(tagstart,start)+1);
}
}
}
function copylocator(f,t){
t.linenumber = f.linenumber;
t.columnnumber = f.columnnumber;
return t;
}
/**
* @see #appendelement(source,elstartend,el,selfclosed,entityreplacer,dombuilder,parsestack);
* @return end of the elementstartpart(end of elementendpart for selfclosed el)
*/
function parseelementstartpart(source,start,el,currentnsmap,entityreplacer,errorhandler){
/**
* @param {string} qname
* @param {string} value
* @param {number} startindex
*/
function addattribute(qname, value, startindex) {
if (el.attributenames.hasownproperty(qname)) {
errorhandler.fatalerror('attribute ' + qname + ' redefined')
}
el.addvalue(qname, value, startindex)
}
var attrname;
var value;
var p = ++start;
var s = s_tag;//status
while(true){
var c = source.charat(p);
switch(c){
case '=':
if(s === s_attr){//attrname
attrname = source.slice(start,p);
s = s_eq;
}else if(s === s_attr_space){
s = s_eq;
}else{
//fatalerror: equal must after attrname or space after attrname
throw new error('attribute equal must after attrname'); // no known test case
}
break;
case '\'':
case '"':
if(s === s_eq || s === s_attr //|| s == s_attr_space
){//equal
if(s === s_attr){
errorhandler.warning('attribute value must after "="')
attrname = source.slice(start,p)
}
start = p+1;
p = source.indexof(c,start)
if(p>0){
value = source.slice(start,p).replace(/?\w+;/g,entityreplacer);
addattribute(attrname, value, start-1);
s = s_attr_end;
}else{
//fatalerror: no end quot match
throw new error('attribute value no end \''+c+'\' match');
}
}else if(s == s_attr_noquot_value){
value = source.slice(start,p).replace(/?\w+;/g,entityreplacer);
//console.log(attrname,value,start,p)
addattribute(attrname, value, start);
//console.dir(el)
errorhandler.warning('attribute "'+attrname+'" missed start quot('+c+')!!');
start = p+1;
s = s_attr_end
}else{
//fatalerror: no equal before
throw new error('attribute value must after "="'); // no known test case
}
break;
case '/':
switch(s){
case s_tag:
el.settagname(source.slice(start,p));
case s_attr_end:
case s_tag_space:
case s_tag_close:
s =s_tag_close;
el.closed = true;
case s_attr_noquot_value:
case s_attr:
case s_attr_space:
break;
//case s_eq:
default:
throw new error("attribute invalid close char('/')") // no known test case
}
break;
case ''://end document
errorhandler.error('unexpected end of input');
if(s == s_tag){
el.settagname(source.slice(start,p));
}
return p;
case '>':
switch(s){
case s_tag:
el.settagname(source.slice(start,p));
case s_attr_end:
case s_tag_space:
case s_tag_close:
break;//normal
case s_attr_noquot_value://compatible state
case s_attr:
value = source.slice(start,p);
if(value.slice(-1) === '/'){
el.closed = true;
value = value.slice(0,-1)
}
case s_attr_space:
if(s === s_attr_space){
value = attrname;
}
if(s == s_attr_noquot_value){
errorhandler.warning('attribute "'+value+'" missed quot(")!');
addattribute(attrname, value.replace(/?\w+;/g,entityreplacer), start)
}else{
if(!namespace.ishtml(currentnsmap['']) || !value.match(/^(?:disabled|checked|selected)$/i)){
errorhandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!')
}
addattribute(value, value, start)
}
break;
case s_eq:
throw new error('attribute value missed!!');
}
// console.log(tagname,tagnamepattern,tagnamepattern.test(tagname))
return p;
/*xml space '\x20' | #x9 | #xd | #xa; */
case '\u0080':
c = ' ';
default:
if(c<= ' '){//space
switch(s){
case s_tag:
el.settagname(source.slice(start,p));//tagname
s = s_tag_space;
break;
case s_attr:
attrname = source.slice(start,p)
s = s_attr_space;
break;
case s_attr_noquot_value:
var value = source.slice(start,p).replace(/?\w+;/g,entityreplacer);
errorhandler.warning('attribute "'+value+'" missed quot(")!!');
addattribute(attrname, value, start)
case s_attr_end:
s = s_tag_space;
break;
//case s_tag_space:
//case s_eq:
//case s_attr_space:
// void();break;
//case s_tag_close:
//ignore warning
}
}else{//not space
//s_tag, s_attr, s_eq, s_attr_noquot_value
//s_attr_space, s_attr_end, s_tag_space, s_tag_close
switch(s){
//case s_tag:void();break;
//case s_attr:void();break;
//case s_attr_noquot_value:void();break;
case s_attr_space:
var tagname = el.tagname;
if (!namespace.ishtml(currentnsmap['']) || !attrname.match(/^(?:disabled|checked|selected)$/i)) {
errorhandler.warning('attribute "'+attrname+'" missed value!! "'+attrname+'" instead2!!')
}
addattribute(attrname, attrname, start);
start = p;
s = s_attr;
break;
case s_attr_end:
errorhandler.warning('attribute space is required"'+attrname+'"!!')
case s_tag_space:
s = s_attr;
start = p;
break;
case s_eq:
s = s_attr_noquot_value;
start = p;
break;
case s_tag_close:
throw new error("elements closed character '/' and '>' must be connected to");
}
}
}//end outer switch
//console.log('p++',p)
p++;
}
}
/**
* @return true if has new namespace define
*/
function appendelement(el,dombuilder,currentnsmap){
var tagname = el.tagname;
var localnsmap = null;
//var currentnsmap = parsestack[parsestack.length-1].currentnsmap;
var i = el.length;
while(i--){
var a = el[i];
var qname = a.qname;
var value = a.value;
var nsp = qname.indexof(':');
if(nsp>0){
var prefix = a.prefix = qname.slice(0,nsp);
var localname = qname.slice(nsp+1);
var nsprefix = prefix === 'xmlns' && localname
}else{
localname = qname;
prefix = null
nsprefix = qname === 'xmlns' && ''
}
//can not set prefix,because prefix !== ''
a.localname = localname ;
//prefix == null for no ns prefix attribute
if(nsprefix !== false){//hack!!
if(localnsmap == null){
localnsmap = {}
//console.log(currentnsmap,0)
_copy(currentnsmap,currentnsmap={})
//console.log(currentnsmap,1)
}
currentnsmap[nsprefix] = localnsmap[nsprefix] = value;
a.uri = namespace.xmlns
dombuilder.startprefixmapping(nsprefix, value)
}
}
var i = el.length;
while(i--){
a = el[i];
var prefix = a.prefix;
if(prefix){//no prefix attribute has no namespace
if(prefix === 'xml'){
a.uri = namespace.xml;
}if(prefix !== 'xmlns'){
a.uri = currentnsmap[prefix || '']
//{console.log('###'+a.qname,dombuilder.locator.systemid+'',currentnsmap,a.uri)}
}
}
}
var nsp = tagname.indexof(':');
if(nsp>0){
prefix = el.prefix = tagname.slice(0,nsp);
localname = el.localname = tagname.slice(nsp+1);
}else{
prefix = null;//important!!
localname = el.localname = tagname;
}
//no prefix element has default namespace
var ns = el.uri = currentnsmap[prefix || ''];
dombuilder.startelement(ns,localname,tagname,el);
//endprefixmapping and startprefixmapping have not any help for dom builder
//localnsmap = null
if(el.closed){
dombuilder.endelement(ns,localname,tagname);
if(localnsmap){
for(prefix in localnsmap){
dombuilder.endprefixmapping(prefix)
}
}
}else{
el.currentnsmap = currentnsmap;
el.localnsmap = localnsmap;
//parsestack.push(el);
return true;
}
}
function parsehtmlspecialcontent(source,elstartend,tagname,entityreplacer,dombuilder){
if(/^(?:script|textarea)$/i.test(tagname)){
var elendstart = source.indexof(''+tagname+'>',elstartend);
var text = source.substring(elstartend+1,elendstart);
if(/[&<]/.test(text)){
if(/^script$/i.test(tagname)){
//if(!/\]\]>/.test(text)){
//lexhandler.startcdata();
dombuilder.characters(text,0,text.length);
//lexhandler.endcdata();
return elendstart;
//}
}//}else{//text area
text = text.replace(/?\w+;/g,entityreplacer);
dombuilder.characters(text,0,text.length);
return elendstart;
//}
}
}
return elstartend+1;
}
function fixselfclosed(source,elstartend,tagname,closemap){
//if(tagname in closemap){
var pos = closemap[tagname];
if(pos == null){
//console.log(tagname)
pos = source.lastindexof(''+tagname+'>')
if(pos',start+4);
//append comment source.substring(4,end)//