diff --git a/inst/htmlwidgets/lib/xml-viewer/XMLDisplay.css b/inst/htmlwidgets/lib/xml-viewer/XMLDisplay.css
new file mode 100644
index 0000000..b1f2009
--- /dev/null
+++ b/inst/htmlwidgets/lib/xml-viewer/XMLDisplay.css
@@ -0,0 +1,44 @@
+@charset "utf-8";
+/* CSS Document */
+.Utility {
+ font-family: monospace;
+ color: black;
+}
+.NodeName {
+ font-family: monospace;
+ font-weight:bold;
+ color: #800080;
+}
+.AttributeName
+{
+ font-family: monospace;
+ font-weight:bold;
+ color: black;
+}
+.AttributeValue
+{
+ font-family: monospace;
+ color:blue;
+}
+.NodeValue
+{
+ font-family: monospace;
+ color: black;
+}
+.Element {
+ font-family: monospace;
+ border-left-color:lightslategray;
+ border-left-width:thin;
+ border-left-style:solid;
+ padding-top:0;
+ margin-top:6px;
+}
+.Clickable {
+ font-family: monospace;
+ font-weight:900;
+ font-size:large;
+ color: #800080;
+ cursor:pointer;
+
+ vertical-align:middle;
+}
diff --git a/inst/htmlwidgets/lib/xml-viewer/XMLDisplay.js b/inst/htmlwidgets/lib/xml-viewer/XMLDisplay.js
new file mode 100644
index 0000000..28ec1ab
--- /dev/null
+++ b/inst/htmlwidgets/lib/xml-viewer/XMLDisplay.js
@@ -0,0 +1,261 @@
+/* Copyright (c) 2007 Lev Muchnik . All rights reserved.
+ * You may copy and modify this script as long as the above copyright notice,
+ * this condition and the following disclaimer is left intact.
+ * This software is provided by the author "AS IS" and no warranties are
+ * implied, including fitness for a particular purpose. In no event shall
+ * the author be liable for any damages arising in any way out of the use
+ * of this software, even if advised of the possibility of such damage.
+ * $Date: 2007-10-03 19:08:15 -0700 (Wed, 03 Oct 2007) $
+ */
+
+function LoadXML(ParentElementID,URL)
+{
+ var xmlHolderElement = GetParentElement(ParentElementID);
+ if (xmlHolderElement==null) { return false; }
+ ToggleElementVisibility(xmlHolderElement);
+ return RequestURL(URL,URLReceiveCallback,ParentElementID);
+}
+function LoadXMLDom(ParentElementID,xmlDoc)
+{
+ if (xmlDoc) {
+ var xmlHolderElement = GetParentElement(ParentElementID);
+ if (xmlHolderElement==null) { return false; }
+ while (xmlHolderElement.childNodes.length) { xmlHolderElement.removeChild(xmlHolderElement.childNodes.item(xmlHolderElement.childNodes.length-1)); }
+ var Result = ShowXML(xmlHolderElement,xmlDoc.documentElement,0);
+
+ var ReferenceElement = document.createElement('div');
+ var Link = document.createElement('a');
+ Link.setAttribute('href','http://www.levmuchnik.net/Content/ProgrammingTips/WEB/XMLDisplay/DisplayXMLFileWithJavascript.html');
+
+ xmlHolderElement.appendChild(Link);
+ return Result;
+ }
+ else { return false; }
+}
+function LoadXMLString(ParentElementID,XMLString)
+{
+ xmlDoc = CreateXMLDOM(XMLString);
+ return LoadXMLDom(ParentElementID,xmlDoc) ;
+}
+////////////////////////////////////////////////////////////
+// HELPER FUNCTIONS - SHOULD NOT BE DIRECTLY CALLED BY USERS
+////////////////////////////////////////////////////////////
+function GetParentElement(ParentElementID)
+{
+ if (typeof(ParentElementID)=='string') { return document.getElementById(ParentElementID); }
+ else if (typeof(ParentElementID)=='object') { return ParentElementID;}
+ else { return null; }
+}
+function URLReceiveCallback(httpRequest,xmlHolderElement)
+{
+ try {
+ if (httpRequest.readyState == 4) {
+ if (httpRequest.status == 200) {
+ var xmlDoc = httpRequest.responseXML;
+ if (xmlHolderElement && xmlHolderElement!=null) {
+ xmlHolderElement.innerHTML = '';
+ return LoadXMLDom(xmlHolderElement,xmlDoc);
+ }
+ } else {
+ return false;
+ }
+ }
+ }
+ catch( e ) {
+ return false;
+ }
+}
+function RequestURL(url,callback,ExtraData) { // based on: http://developer.mozilla.org/en/docs/AJAX:Getting_Started
+ var httpRequest;
+ if (window.XMLHttpRequest) { // Mozilla, Safari, ...
+ httpRequest = new XMLHttpRequest();
+ if (httpRequest.overrideMimeType) { httpRequest.overrideMimeType('text/xml'); }
+ }
+ else if (window.ActiveXObject) { // IE
+ try { httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
+ catch (e) {
+ try { httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); }
+ catch (e) {}
+ }
+ }
+ if (!httpRequest) { return false; }
+ httpRequest.onreadystatechange = function() { callback(httpRequest,ExtraData); };
+ httpRequest.open('GET', url, true);
+ httpRequest.send('');
+ return true;
+ }
+function CreateXMLDOM(XMLStr)
+{
+ if (window.ActiveXObject)
+ {
+ xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
+ xmlDoc.loadXML(XMLStr);
+ return xmlDoc;
+ }
+ else if (document.implementation && document.implementation.createDocument) {
+ var parser=new DOMParser();
+ return parser.parseFromString(XMLStr,"text/xml");
+ }
+ else {
+ return null;
+ }
+}
+
+var IDCounter = 1;
+var NestingIndent = 15;
+function ShowXML(xmlHolderElement,RootNode,indent)
+{
+ if (RootNode==null || xmlHolderElement==null) { return false; }
+ var Result = true;
+ var TagEmptyElement = document.createElement('div');
+ TagEmptyElement.className = 'Element';
+ TagEmptyElement.style.position = 'relative';
+ TagEmptyElement.style.left = NestingIndent+'px';
+ if (RootNode.childNodes.length==0) {
+ var ClickableElement = AddTextNode(TagEmptyElement,'','Clickable') ;
+ ClickableElement.id = 'div_empty_' + IDCounter;
+ AddTextNode(TagEmptyElement,'<','Utility') ;
+ AddTextNode(TagEmptyElement,RootNode.nodeName ,'NodeName')
+ for (var i = 0; RootNode.attributes && i < RootNode.attributes.length; ++i) {
+ CurrentAttribute = RootNode.attributes.item(i);
+ AddTextNode(TagEmptyElement,' ' + CurrentAttribute.nodeName ,'AttributeName') ;
+ AddTextNode(TagEmptyElement,'=','Utility') ;
+ AddTextNode(TagEmptyElement,'"' + CurrentAttribute.nodeValue + '"','AttributeValue') ;
+ }
+ AddTextNode(TagEmptyElement,' />') ;
+ xmlHolderElement.appendChild(TagEmptyElement);
+ //SetVisibility(TagEmptyElement,true);
+ }
+ else { // mo child nodes
+
+ var ClickableElement = AddTextNode(TagEmptyElement,'+','Clickable') ;
+ ClickableElement.onclick = function() {ToggleElementVisibility(this); }
+ ClickableElement.id = 'div_empty_' + IDCounter;
+
+ AddTextNode(TagEmptyElement,'<','Utility') ;
+ AddTextNode(TagEmptyElement,RootNode.nodeName ,'NodeName')
+ for (var i = 0; RootNode.attributes && i < RootNode.attributes.length; ++i) {
+ CurrentAttribute = RootNode.attributes.item(i);
+ AddTextNode(TagEmptyElement,' ' + CurrentAttribute.nodeName ,'AttributeName') ;
+ AddTextNode(TagEmptyElement,'=','Utility') ;
+ AddTextNode(TagEmptyElement,'"' + CurrentAttribute.nodeValue + '"','AttributeValue') ;
+ }
+
+ AddTextNode(TagEmptyElement,'> ','Utility') ;
+ AddTextNode(TagEmptyElement,RootNode.nodeName,'NodeName') ;
+ AddTextNode(TagEmptyElement,'>','Utility') ;
+ xmlHolderElement.appendChild(TagEmptyElement);
+ SetVisibility(TagEmptyElement,false);
+ //----------------------------------------------
+
+ var TagElement = document.createElement('div');
+ TagElement.className = 'Element';
+ TagElement.style.position = 'relative';
+ TagElement.style.left = NestingIndent+'px';
+ ClickableElement = AddTextNode(TagElement,'-','Clickable') ;
+ ClickableElement.onclick = function() {ToggleElementVisibility(this); }
+ ClickableElement.id = 'div_content_' + IDCounter;
+ ++IDCounter;
+ AddTextNode(TagElement,'<','Utility') ;
+ AddTextNode(TagElement,RootNode.nodeName ,'NodeName') ;
+
+ for (var i = 0; RootNode.attributes && i < RootNode.attributes.length; ++i) {
+ CurrentAttribute = RootNode.attributes.item(i);
+ AddTextNode(TagElement,' ' + CurrentAttribute.nodeName ,'AttributeName') ;
+ AddTextNode(TagElement,'=','Utility') ;
+ AddTextNode(TagElement,'"' + CurrentAttribute.nodeValue + '"','AttributeValue') ;
+ }
+ AddTextNode(TagElement,'>','Utility') ;
+ TagElement.appendChild(document.createElement('br'));
+ var NodeContent = null;
+ for (var i = 0; RootNode.childNodes && i < RootNode.childNodes.length; ++i) {
+ if (RootNode.childNodes.item(i).nodeName != '#text') {
+ Result &= ShowXML(TagElement,RootNode.childNodes.item(i),indent+1);
+ }
+ else {
+ NodeContent =RootNode.childNodes.item(i).nodeValue;
+ }
+ }
+ if (RootNode.nodeValue) {
+ NodeContent = RootNode.nodeValue;
+ }
+ if (NodeContent) {
+ var ContentElement = document.createElement('div');
+ ContentElement.style.position = 'relative';
+ ContentElement.style.left = NestingIndent+'px';
+ AddTextNode(ContentElement,NodeContent ,'NodeValue') ;
+ TagElement.appendChild(ContentElement);
+ }
+ AddTextNode(TagElement,' ','Utility') ;
+ AddTextNode(TagElement,RootNode.nodeName,'NodeName') ;
+ AddTextNode(TagElement,'>','Utility') ;
+ xmlHolderElement.appendChild(TagElement);
+ }
+
+ // if (indent==0) { ToggleElementVisibility(TagElement.childNodes(0)); } - uncomment to collapse the external element
+ return Result;
+}
+function AddTextNode(ParentNode,Text,Class)
+{
+ NewNode = document.createElement('span');
+ if (Class) { NewNode.className = Class;}
+ if (Text) { NewNode.appendChild(document.createTextNode(Text)); }
+ if (ParentNode) { ParentNode.appendChild(NewNode); }
+ return NewNode;
+}
+function CompatibleGetElementByID(id)
+{
+ if (!id) { return null; }
+ if (document.getElementById) { // DOM3 = IE5, NS6
+ return document.getElementById(id);
+ }
+ else {
+ if (document.layers) { // Netscape 4
+ return document.id;
+ }
+ else { // IE 4
+ return document.all.id;
+ }
+ }
+}
+function SetVisibility(HTMLElement,Visible)
+{
+ if (!HTMLElement) { return; }
+ var VisibilityStr = (Visible) ? 'block' : 'none';
+ if (document.getElementById) { // DOM3 = IE5, NS6
+ HTMLElement.style.display =VisibilityStr;
+ }
+ else {
+ if (document.layers) { // Netscape 4
+ HTMLElement.display = VisibilityStr;
+ }
+ else { // IE 4
+ HTMLElement.id.style.display = VisibilityStr;
+ }
+ }
+}
+function ToggleElementVisibility(Element)
+{
+ if (!Element|| !Element.id) { return; }
+ try {
+ ElementType = Element.id.slice(0,Element.id.lastIndexOf('_')+1);
+ ElementID = parseInt(Element.id.slice(Element.id.lastIndexOf('_')+1));
+ }
+ catch(e) { return ; }
+ var ElementToHide = null;
+ var ElementToShow= null;
+ if (ElementType=='div_content_') {
+ ElementToHide = 'div_content_' + ElementID;
+ ElementToShow = 'div_empty_' + ElementID;
+ }
+ else if (ElementType=='div_empty_') {
+ ElementToShow= 'div_content_' + ElementID;
+ ElementToHide = 'div_empty_' + ElementID;
+ }
+ ElementToHide = CompatibleGetElementByID(ElementToHide);
+ ElementToShow = CompatibleGetElementByID(ElementToShow);
+ if (ElementToHide) { ElementToHide = ElementToHide.parentNode;}
+ if (ElementToShow) { ElementToShow = ElementToShow.parentNode;}
+ SetVisibility(ElementToHide,false);
+ SetVisibility(ElementToShow,true);
+}
diff --git a/inst/htmlwidgets/lib/xml-viewer/xml-viewer.js b/inst/htmlwidgets/lib/xml-viewer/xml-viewer.js
index d66e8f8..7d71022 100644
--- a/inst/htmlwidgets/lib/xml-viewer/xml-viewer.js
+++ b/inst/htmlwidgets/lib/xml-viewer/xml-viewer.js
@@ -1,2254 +1,2346 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Viewer = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0 && this._events[type].length > m) {
- this._events[type].warned = true;
- console.error('(node) warning: possible EventEmitter memory ' +
- 'leak detected. %d listeners added. ' +
- 'Use emitter.setMaxListeners() to increase limit.',
- this._events[type].length);
- if (typeof console.trace === 'function') {
- // not supported in IE 10
- console.trace();
- }
+ ev.target.innerHTML = '+';
+ node.children.forEach(function(child){
+ child.el.style.display = 'none';
+ });
}
+ folded = !folded;
}
- return this;
-};
+ node.text = function(){
+ return render.node(node);
+ };
-EventEmitter.prototype.on = EventEmitter.prototype.addListener;
+ var el = h('span',
+ { onclick: this._handleClick(node) },
+ h('br'),
+ tabs(indent),
+ h('span', { onclick: ontoggle }, '-'),
+ spaces(1),
+ render.tagOpen(node),
+ node.children.map(function(child){
+ return self._renderNode(child, indent + 1);
+ }),
+ h('br'),
+ tabs(indent),
+ spaces(2),
+ render.tagClose(node)
+ );
+ node.el = el;
-EventEmitter.prototype.once = function(type, listener) {
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
+ return el;
+}
- var fired = false;
+Viewer.prototype._renderLeaf = function(node, indent){
+ var self = this;
- function g() {
- this.removeListener(type, g);
+ node.text = function(){
+ return render.node(node);
+ };
- if (!fired) {
- fired = true;
- listener.apply(this, arguments);
- }
- }
+ var el = h('span',
+ { onclick: this._handleClick(node) },
+ h('br'),
+ tabs(indent),
+ spaces(2),
+ node.text()
+ );
+ node.el = el;
- g.listener = listener;
- this.on(type, g);
+ return el;
+}
- return this;
+Viewer.prototype._handleClick = function(node){
+ var self = this;
+ return function(ev){
+ ev.stopPropagation();
+ self._setSelection(node);
+ };
};
-// emits a 'removeListener' event iff the listener was removed
-EventEmitter.prototype.removeListener = function(type, listener) {
- var list, position, length, i;
-
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
-
- if (!this._events || !this._events[type])
- return this;
+function tabs(n){
+ var out = [];
+ for (var i = 0; i < n; i++) out.push(spaces(4));
+ return out;
+}
- list = this._events[type];
- length = list.length;
- position = -1;
+function spaces(n){
+ var el = document.createElement('span');
+ for (var i = 0; i < n; i++) {
+ el.innerHTML += ' ';
+ }
+ return el;
+}
- if (list === listener ||
- (isFunction(list.listener) && list.listener === listener)) {
- delete this._events[type];
- if (this._events.removeListener)
- this.emit('removeListener', type, listener);
+},{"events":12,"hyperscript":6,"util":16,"xml-parser":9,"xml-render":10}],2:[function(require,module,exports){
+/*!
+ * Cross-Browser Split 1.1.1
+ * Copyright 2007-2012 Steven Levithan
+ * Available under the MIT License
+ * ECMAScript compliant, uniform cross-browser split method
+ */
- } else if (isObject(list)) {
- for (i = length; i-- > 0;) {
- if (list[i] === listener ||
- (list[i].listener && list[i].listener === listener)) {
- position = i;
- break;
- }
- }
+/**
+ * Splits a string into an array of strings using a regex or string separator. Matches of the
+ * separator are not included in the result array. However, if `separator` is a regex that contains
+ * capturing groups, backreferences are spliced into the result each time `separator` is matched.
+ * Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably
+ * cross-browser.
+ * @param {String} str String to split.
+ * @param {RegExp|String} separator Regex or string to use for separating the string.
+ * @param {Number} [limit] Maximum number of items to include in the result array.
+ * @returns {Array} Array of substrings.
+ * @example
+ *
+ * // Basic use
+ * split('a b c d', ' ');
+ * // -> ['a', 'b', 'c', 'd']
+ *
+ * // With limit
+ * split('a b c d', ' ', 2);
+ * // -> ['a', 'b']
+ *
+ * // Backreferences in result array
+ * split('..word1 word2..', /([a-z]+)(\d+)/i);
+ * // -> ['..', 'word', '1', ' ', 'word', '2', '..']
+ */
+module.exports = (function split(undef) {
- if (position < 0)
- return this;
+ var nativeSplit = String.prototype.split,
+ compliantExecNpcg = /()??/.exec("")[1] === undef,
+ // NPCG: nonparticipating capturing group
+ self;
- if (list.length === 1) {
- list.length = 0;
- delete this._events[type];
+ self = function(str, separator, limit) {
+ // If `separator` is not a regex, use `nativeSplit`
+ if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
+ return nativeSplit.call(str, separator, limit);
+ }
+ var output = [],
+ flags = (separator.ignoreCase ? "i" : "") + (separator.multiline ? "m" : "") + (separator.extended ? "x" : "") + // Proposed for ES6
+ (separator.sticky ? "y" : ""),
+ // Firefox 3+
+ lastLastIndex = 0,
+ // Make `global` and avoid `lastIndex` issues by working with a copy
+ separator = new RegExp(separator.source, flags + "g"),
+ separator2, match, lastIndex, lastLength;
+ str += ""; // Type-convert
+ if (!compliantExecNpcg) {
+ // Doesn't need flags gy, but they don't hurt
+ separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
+ }
+ /* Values for `limit`, per the spec:
+ * If undefined: 4294967295 // Math.pow(2, 32) - 1
+ * If 0, Infinity, or NaN: 0
+ * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
+ * If negative number: 4294967296 - Math.floor(Math.abs(limit))
+ * If other: Type-convert, then use the above rules
+ */
+ limit = limit === undef ? -1 >>> 0 : // Math.pow(2, 32) - 1
+ limit >>> 0; // ToUint32(limit)
+ while (match = separator.exec(str)) {
+ // `separator.lastIndex` is not reliable cross-browser
+ lastIndex = match.index + match[0].length;
+ if (lastIndex > lastLastIndex) {
+ output.push(str.slice(lastLastIndex, match.index));
+ // Fix browsers whose `exec` methods don't consistently return `undefined` for
+ // nonparticipating capturing groups
+ if (!compliantExecNpcg && match.length > 1) {
+ match[0].replace(separator2, function() {
+ for (var i = 1; i < arguments.length - 2; i++) {
+ if (arguments[i] === undef) {
+ match[i] = undef;
+ }
+ }
+ });
+ }
+ if (match.length > 1 && match.index < str.length) {
+ Array.prototype.push.apply(output, match.slice(1));
+ }
+ lastLength = match[0].length;
+ lastLastIndex = lastIndex;
+ if (output.length >= limit) {
+ break;
+ }
+ }
+ if (separator.lastIndex === match.index) {
+ separator.lastIndex++; // Avoid an infinite loop
+ }
+ }
+ if (lastLastIndex === str.length) {
+ if (lastLength || !separator.test("")) {
+ output.push("");
+ }
} else {
- list.splice(position, 1);
+ output.push(str.slice(lastLastIndex));
}
+ return output.length > limit ? output.slice(0, limit) : output;
+ };
- if (this._events.removeListener)
- this.emit('removeListener', type, listener);
- }
+ return self;
+})();
- return this;
-};
+},{}],3:[function(require,module,exports){
+// contains, add, remove, toggle
+var indexof = require('indexof')
-EventEmitter.prototype.removeAllListeners = function(type) {
- var key, listeners;
+module.exports = ClassList
- if (!this._events)
- return this;
+function ClassList(elem) {
+ var cl = elem.classList
- // not listening for removeListener, no need to emit
- if (!this._events.removeListener) {
- if (arguments.length === 0)
- this._events = {};
- else if (this._events[type])
- delete this._events[type];
- return this;
- }
+ if (cl) {
+ return cl
+ }
- // emit removeListener for all listeners on all events
- if (arguments.length === 0) {
- for (key in this._events) {
- if (key === 'removeListener') continue;
- this.removeAllListeners(key);
+ var classList = {
+ add: add
+ , remove: remove
+ , contains: contains
+ , toggle: toggle
+ , toString: $toString
+ , length: 0
+ , item: item
}
- this.removeAllListeners('removeListener');
- this._events = {};
- return this;
- }
- listeners = this._events[type];
+ return classList
- if (isFunction(listeners)) {
- this.removeListener(type, listeners);
- } else {
- // LIFO order
- while (listeners.length)
- this.removeListener(type, listeners[listeners.length - 1]);
- }
- delete this._events[type];
+ function add(token) {
+ var list = getTokens()
+ if (indexof(list, token) > -1) {
+ return
+ }
+ list.push(token)
+ setTokens(list)
+ }
- return this;
-};
+ function remove(token) {
+ var list = getTokens()
+ , index = indexof(list, token)
-EventEmitter.prototype.listeners = function(type) {
- var ret;
- if (!this._events || !this._events[type])
- ret = [];
- else if (isFunction(this._events[type]))
- ret = [this._events[type]];
- else
- ret = this._events[type].slice();
- return ret;
-};
+ if (index === -1) {
+ return
+ }
-EventEmitter.listenerCount = function(emitter, type) {
- var ret;
- if (!emitter._events || !emitter._events[type])
- ret = 0;
- else if (isFunction(emitter._events[type]))
- ret = 1;
- else
- ret = emitter._events[type].length;
- return ret;
-};
+ list.splice(index, 1)
+ setTokens(list)
+ }
-function isFunction(arg) {
- return typeof arg === 'function';
-}
+ function contains(token) {
+ return indexof(getTokens(), token) > -1
+ }
-function isNumber(arg) {
- return typeof arg === 'number';
-}
+ function toggle(token) {
+ if (contains(token)) {
+ remove(token)
+ return false
+ } else {
+ add(token)
+ return true
+ }
+ }
-function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
-}
+ function $toString() {
+ return elem.className
+ }
-function isUndefined(arg) {
- return arg === void 0;
-}
+ function item(index) {
+ var tokens = getTokens()
+ return tokens[index] || null
+ }
-},{}],3:[function(require,module,exports){
-if (typeof Object.create === 'function') {
- // implementation from standard node.js 'util' module
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- };
-} else {
- // old school shim for old browsers
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- var TempCtor = function () {}
- TempCtor.prototype = superCtor.prototype
- ctor.prototype = new TempCtor()
- ctor.prototype.constructor = ctor
- }
-}
-
-},{}],4:[function(require,module,exports){
-// shim for using process in browser
-
-var process = module.exports = {};
-var queue = [];
-var draining = false;
-var currentQueue;
-var queueIndex = -1;
+ function getTokens() {
+ var className = elem.className
-function cleanUpNextTick() {
- draining = false;
- if (currentQueue.length) {
- queue = currentQueue.concat(queue);
- } else {
- queueIndex = -1;
- }
- if (queue.length) {
- drainQueue();
+ return filter(className.split(" "), isTruthy)
}
-}
-function drainQueue() {
- if (draining) {
- return;
- }
- var timeout = setTimeout(cleanUpNextTick);
- draining = true;
+ function setTokens(list) {
+ var length = list.length
- var len = queue.length;
- while(len) {
- currentQueue = queue;
- queue = [];
- while (++queueIndex < len) {
- currentQueue[queueIndex].run();
+ elem.className = list.join(" ")
+ classList.length = length
+
+ for (var i = 0; i < list.length; i++) {
+ classList[i] = list[i]
}
- queueIndex = -1;
- len = queue.length;
+
+ delete list[length]
}
- currentQueue = null;
- draining = false;
- clearTimeout(timeout);
}
-process.nextTick = function (fun) {
- var args = new Array(arguments.length - 1);
- if (arguments.length > 1) {
- for (var i = 1; i < arguments.length; i++) {
- args[i - 1] = arguments[i];
- }
- }
- queue.push(new Item(fun, args));
- if (queue.length === 1 && !draining) {
- setTimeout(drainQueue, 0);
+function filter (arr, fn) {
+ var ret = []
+ for (var i = 0; i < arr.length; i++) {
+ if (fn(arr[i])) ret.push(arr[i])
}
-};
+ return ret
+}
-// v8 likes predictible objects
-function Item(fun, array) {
- this.fun = fun;
- this.array = array;
+function isTruthy(value) {
+ return !!value
}
-Item.prototype.run = function () {
- this.fun.apply(null, this.array);
-};
-process.title = 'browser';
-process.browser = true;
-process.env = {};
-process.argv = [];
-process.version = ''; // empty string to avoid regexp issues
-process.versions = {};
-function noop() {}
+},{"indexof":7}],4:[function(require,module,exports){
+(function (process){
+/**
+ * This is the web browser implementation of `debug()`.
+ *
+ * Expose `debug()` as the module.
+ */
-process.on = noop;
-process.addListener = noop;
-process.once = noop;
-process.off = noop;
-process.removeListener = noop;
-process.removeAllListeners = noop;
-process.emit = noop;
+exports = module.exports = require('./debug');
+exports.log = log;
+exports.formatArgs = formatArgs;
+exports.save = save;
+exports.load = load;
+exports.useColors = useColors;
+exports.storage = 'undefined' != typeof chrome
+ && 'undefined' != typeof chrome.storage
+ ? chrome.storage.local
+ : localstorage();
-process.binding = function (name) {
- throw new Error('process.binding is not supported');
-};
+/**
+ * Colors.
+ */
-// TODO(shtylman)
-process.cwd = function () { return '/' };
-process.chdir = function (dir) {
- throw new Error('process.chdir is not supported');
-};
-process.umask = function() { return 0; };
+exports.colors = [
+ 'lightseagreen',
+ 'forestgreen',
+ 'goldenrod',
+ 'dodgerblue',
+ 'darkorchid',
+ 'crimson'
+];
-},{}],5:[function(require,module,exports){
-module.exports = function isBuffer(arg) {
- return arg && typeof arg === 'object'
- && typeof arg.copy === 'function'
- && typeof arg.fill === 'function'
- && typeof arg.readUInt8 === 'function';
-}
-},{}],6:[function(require,module,exports){
-(function (process,global){
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
+/**
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
+ * and the Firebug extension (any Firefox version) are known
+ * to support "%c" CSS customizations.
+ *
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
+ */
-var formatRegExp = /%[sdj%]/g;
-exports.format = function(f) {
- if (!isString(f)) {
- var objects = [];
- for (var i = 0; i < arguments.length; i++) {
- objects.push(inspect(arguments[i]));
- }
- return objects.join(' ');
+function useColors() {
+ // NB: In an Electron preload script, document will be defined but not fully
+ // initialized. Since we know we're in Chrome, we'll just detect this case
+ // explicitly
+ if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
+ return true;
}
- var i = 1;
- var args = arguments;
- var len = args.length;
- var str = String(f).replace(formatRegExp, function(x) {
- if (x === '%%') return '%';
- if (i >= len) return x;
- switch (x) {
- case '%s': return String(args[i++]);
- case '%d': return Number(args[i++]);
- case '%j':
- try {
- return JSON.stringify(args[i++]);
- } catch (_) {
- return '[Circular]';
- }
- default:
- return x;
- }
- });
- for (var x = args[i]; i < len; x = args[++i]) {
- if (isNull(x) || !isObject(x)) {
- str += ' ' + x;
- } else {
- str += ' ' + inspect(x);
- }
+ // is webkit? http://stackoverflow.com/a/16459606/376773
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
+ return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
+ // is firebug? http://stackoverflow.com/a/398120/376773
+ (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
+ // is firefox >= v31?
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
+ // double check webkit in userAgent just in case we are in a worker
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
+}
+
+/**
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
+ */
+
+exports.formatters.j = function(v) {
+ try {
+ return JSON.stringify(v);
+ } catch (err) {
+ return '[UnexpectedJSONParseError]: ' + err.message;
}
- return str;
};
-// Mark that a method should not be used.
-// Returns a modified function which warns once by default.
-// If --no-deprecation is set, then it is a no-op.
-exports.deprecate = function(fn, msg) {
- // Allow for deprecating things in the process of starting up.
- if (isUndefined(global.process)) {
- return function() {
- return exports.deprecate(fn, msg).apply(this, arguments);
- };
- }
+/**
+ * Colorize log arguments if enabled.
+ *
+ * @api public
+ */
- if (process.noDeprecation === true) {
- return fn;
- }
+function formatArgs(args) {
+ var useColors = this.useColors;
- var warned = false;
- function deprecated() {
- if (!warned) {
- if (process.throwDeprecation) {
- throw new Error(msg);
- } else if (process.traceDeprecation) {
- console.trace(msg);
- } else {
- console.error(msg);
- }
- warned = true;
- }
- return fn.apply(this, arguments);
- }
+ args[0] = (useColors ? '%c' : '')
+ + this.namespace
+ + (useColors ? ' %c' : ' ')
+ + args[0]
+ + (useColors ? '%c ' : ' ')
+ + '+' + exports.humanize(this.diff);
- return deprecated;
-};
+ if (!useColors) return;
+ var c = 'color: ' + this.color;
+ args.splice(1, 0, c, 'color: inherit')
-var debugs = {};
-var debugEnviron;
-exports.debuglog = function(set) {
- if (isUndefined(debugEnviron))
- debugEnviron = process.env.NODE_DEBUG || '';
- set = set.toUpperCase();
- if (!debugs[set]) {
- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
- var pid = process.pid;
- debugs[set] = function() {
- var msg = exports.format.apply(exports, arguments);
- console.error('%s %d: %s', set, pid, msg);
- };
- } else {
- debugs[set] = function() {};
+ // the final "%c" is somewhat tricky, because there could be other
+ // arguments passed either before or after the %c, so we need to
+ // figure out the correct index to insert the CSS into
+ var index = 0;
+ var lastC = 0;
+ args[0].replace(/%[a-zA-Z%]/g, function(match) {
+ if ('%%' === match) return;
+ index++;
+ if ('%c' === match) {
+ // we only are interested in the *last* %c
+ // (the user may have provided their own)
+ lastC = index;
}
- }
- return debugs[set];
-};
+ });
+ args.splice(lastC, 0, c);
+}
/**
- * Echos the value of a value. Trys to print the value out
- * in the best way possible given the different types.
+ * Invokes `console.log()` when available.
+ * No-op when `console.log` is not a "function".
*
- * @param {Object} obj The object to print out.
- * @param {Object} opts Optional options object that alters the output.
+ * @api public
*/
-/* legacy: obj, showHidden, depth, colors*/
-function inspect(obj, opts) {
- // default options
- var ctx = {
- seen: [],
- stylize: stylizeNoColor
- };
- // legacy...
- if (arguments.length >= 3) ctx.depth = arguments[2];
- if (arguments.length >= 4) ctx.colors = arguments[3];
- if (isBoolean(opts)) {
- // legacy...
- ctx.showHidden = opts;
- } else if (opts) {
- // got an "options" object
- exports._extend(ctx, opts);
- }
- // set default options
- if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
- if (isUndefined(ctx.depth)) ctx.depth = 2;
- if (isUndefined(ctx.colors)) ctx.colors = false;
- if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
- if (ctx.colors) ctx.stylize = stylizeWithColor;
- return formatValue(ctx, obj, ctx.depth);
-}
-exports.inspect = inspect;
+function log() {
+ // this hackery is required for IE8/9, where
+ // the `console.log` function doesn't have 'apply'
+ return 'object' === typeof console
+ && console.log
+ && Function.prototype.apply.call(console.log, console, arguments);
+}
-// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
-inspect.colors = {
- 'bold' : [1, 22],
- 'italic' : [3, 23],
- 'underline' : [4, 24],
- 'inverse' : [7, 27],
- 'white' : [37, 39],
- 'grey' : [90, 39],
- 'black' : [30, 39],
- 'blue' : [34, 39],
- 'cyan' : [36, 39],
- 'green' : [32, 39],
- 'magenta' : [35, 39],
- 'red' : [31, 39],
- 'yellow' : [33, 39]
-};
+/**
+ * Save `namespaces`.
+ *
+ * @param {String} namespaces
+ * @api private
+ */
-// Don't use 'blue' not visible on cmd.exe
-inspect.styles = {
- 'special': 'cyan',
- 'number': 'yellow',
- 'boolean': 'yellow',
- 'undefined': 'grey',
- 'null': 'bold',
- 'string': 'green',
- 'date': 'magenta',
- // "name": intentionally not styling
- 'regexp': 'red'
-};
+function save(namespaces) {
+ try {
+ if (null == namespaces) {
+ exports.storage.removeItem('debug');
+ } else {
+ exports.storage.debug = namespaces;
+ }
+ } catch(e) {}
+}
+/**
+ * Load `namespaces`.
+ *
+ * @return {String} returns the previously persisted debug modes
+ * @api private
+ */
-function stylizeWithColor(str, styleType) {
- var style = inspect.styles[styleType];
+function load() {
+ var r;
+ try {
+ r = exports.storage.debug;
+ } catch(e) {}
- if (style) {
- return '\u001b[' + inspect.colors[style][0] + 'm' + str +
- '\u001b[' + inspect.colors[style][1] + 'm';
- } else {
- return str;
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
+ r = process.env.DEBUG;
}
-}
-
-function stylizeNoColor(str, styleType) {
- return str;
+ return r;
}
+/**
+ * Enable namespaces listed in `localStorage.debug` initially.
+ */
-function arrayToHash(array) {
- var hash = {};
+exports.enable(load());
- array.forEach(function(val, idx) {
- hash[val] = true;
- });
+/**
+ * Localstorage attempts to return the localstorage.
+ *
+ * This is necessary because safari throws
+ * when a user disables cookies/localstorage
+ * and you attempt to access it.
+ *
+ * @return {LocalStorage}
+ * @api private
+ */
- return hash;
+function localstorage() {
+ try {
+ return window.localStorage;
+ } catch (e) {}
}
+}).call(this,require('_process'))
+},{"./debug":5,"_process":14}],5:[function(require,module,exports){
-function formatValue(ctx, value, recurseTimes) {
- // Provide a hook for user-specified inspect functions.
- // Check that value is an object with an inspect function on it
- if (ctx.customInspect &&
- value &&
- isFunction(value.inspect) &&
- // Filter out the util module, it's inspect function is special
- value.inspect !== exports.inspect &&
- // Also filter out any prototype objects using the circular check.
- !(value.constructor && value.constructor.prototype === value)) {
- var ret = value.inspect(recurseTimes, ctx);
- if (!isString(ret)) {
- ret = formatValue(ctx, ret, recurseTimes);
- }
- return ret;
- }
+/**
+ * This is the common logic for both the Node.js and web browser
+ * implementations of `debug()`.
+ *
+ * Expose `debug()` as the module.
+ */
- // Primitive types cannot have properties
- var primitive = formatPrimitive(ctx, value);
- if (primitive) {
- return primitive;
- }
+exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
+exports.coerce = coerce;
+exports.disable = disable;
+exports.enable = enable;
+exports.enabled = enabled;
+exports.humanize = require('ms');
- // Look up the keys of the object.
- var keys = Object.keys(value);
- var visibleKeys = arrayToHash(keys);
+/**
+ * The currently active debug mode names, and names to skip.
+ */
- if (ctx.showHidden) {
- keys = Object.getOwnPropertyNames(value);
- }
+exports.names = [];
+exports.skips = [];
- // IE doesn't make error fields non-enumerable
- // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
- if (isError(value)
- && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
- return formatError(value);
- }
+/**
+ * Map of special "%n" handling functions, for the debug "format" argument.
+ *
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
+ */
- // Some type of object without properties can be shortcutted.
- if (keys.length === 0) {
- if (isFunction(value)) {
- var name = value.name ? ': ' + value.name : '';
- return ctx.stylize('[Function' + name + ']', 'special');
- }
- if (isRegExp(value)) {
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
- }
- if (isDate(value)) {
- return ctx.stylize(Date.prototype.toString.call(value), 'date');
- }
- if (isError(value)) {
- return formatError(value);
- }
- }
+exports.formatters = {};
- var base = '', array = false, braces = ['{', '}'];
+/**
+ * Previous log timestamp.
+ */
- // Make Array say that they are Array
- if (isArray(value)) {
- array = true;
- braces = ['[', ']'];
- }
+var prevTime;
- // Make functions say that they are functions
- if (isFunction(value)) {
- var n = value.name ? ': ' + value.name : '';
- base = ' [Function' + n + ']';
- }
+/**
+ * Select a color.
+ * @param {String} namespace
+ * @return {Number}
+ * @api private
+ */
- // Make RegExps say that they are RegExps
- if (isRegExp(value)) {
- base = ' ' + RegExp.prototype.toString.call(value);
+function selectColor(namespace) {
+ var hash = 0, i;
+
+ for (i in namespace) {
+ hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
+ hash |= 0; // Convert to 32bit integer
}
- // Make dates with properties first say the date
- if (isDate(value)) {
- base = ' ' + Date.prototype.toUTCString.call(value);
- }
+ return exports.colors[Math.abs(hash) % exports.colors.length];
+}
- // Make error with message first say the error
- if (isError(value)) {
- base = ' ' + formatError(value);
- }
+/**
+ * Create a debugger with the given `namespace`.
+ *
+ * @param {String} namespace
+ * @return {Function}
+ * @api public
+ */
- if (keys.length === 0 && (!array || value.length == 0)) {
- return braces[0] + base + braces[1];
- }
+function createDebug(namespace) {
- if (recurseTimes < 0) {
- if (isRegExp(value)) {
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
- } else {
- return ctx.stylize('[Object]', 'special');
+ function debug() {
+ // disabled?
+ if (!debug.enabled) return;
+
+ var self = debug;
+
+ // set `diff` timestamp
+ var curr = +new Date();
+ var ms = curr - (prevTime || curr);
+ self.diff = ms;
+ self.prev = prevTime;
+ self.curr = curr;
+ prevTime = curr;
+
+ // turn the `arguments` into a proper Array
+ var args = new Array(arguments.length);
+ for (var i = 0; i < args.length; i++) {
+ args[i] = arguments[i];
}
- }
- ctx.seen.push(value);
+ args[0] = exports.coerce(args[0]);
- var output;
- if (array) {
- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
- } else {
- output = keys.map(function(key) {
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
+ if ('string' !== typeof args[0]) {
+ // anything else let's inspect with %O
+ args.unshift('%O');
+ }
+
+ // apply any `formatters` transformations
+ var index = 0;
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
+ // if we encounter an escaped % then don't increase the array index
+ if (match === '%%') return match;
+ index++;
+ var formatter = exports.formatters[format];
+ if ('function' === typeof formatter) {
+ var val = args[index];
+ match = formatter.call(self, val);
+
+ // now we need to remove `args[index]` since it's inlined in the `format`
+ args.splice(index, 1);
+ index--;
+ }
+ return match;
});
- }
- ctx.seen.pop();
+ // apply env-specific formatting (colors, etc.)
+ exports.formatArgs.call(self, args);
- return reduceToSingleString(output, base, braces);
-}
+ var logFn = debug.log || exports.log || console.log.bind(console);
+ logFn.apply(self, args);
+ }
+ debug.namespace = namespace;
+ debug.enabled = exports.enabled(namespace);
+ debug.useColors = exports.useColors();
+ debug.color = selectColor(namespace);
-function formatPrimitive(ctx, value) {
- if (isUndefined(value))
- return ctx.stylize('undefined', 'undefined');
- if (isString(value)) {
- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
- .replace(/'/g, "\\'")
- .replace(/\\"/g, '"') + '\'';
- return ctx.stylize(simple, 'string');
+ // env-specific initialization logic for debug instances
+ if ('function' === typeof exports.init) {
+ exports.init(debug);
}
- if (isNumber(value))
- return ctx.stylize('' + value, 'number');
- if (isBoolean(value))
- return ctx.stylize('' + value, 'boolean');
- // For some reason typeof null is "object", so special case here.
- if (isNull(value))
- return ctx.stylize('null', 'null');
+
+ return debug;
}
+/**
+ * Enables a debug mode by namespaces. This can include modes
+ * separated by a colon and wildcards.
+ *
+ * @param {String} namespaces
+ * @api public
+ */
-function formatError(value) {
- return '[' + Error.prototype.toString.call(value) + ']';
-}
+function enable(namespaces) {
+ exports.save(namespaces);
+ exports.names = [];
+ exports.skips = [];
-function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
- var output = [];
- for (var i = 0, l = value.length; i < l; ++i) {
- if (hasOwnProperty(value, String(i))) {
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
- String(i), true));
+ var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
+ var len = split.length;
+
+ for (var i = 0; i < len; i++) {
+ if (!split[i]) continue; // ignore empty strings
+ namespaces = split[i].replace(/\*/g, '.*?');
+ if (namespaces[0] === '-') {
+ exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
} else {
- output.push('');
+ exports.names.push(new RegExp('^' + namespaces + '$'));
}
}
- keys.forEach(function(key) {
- if (!key.match(/^\d+$/)) {
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
- key, true));
- }
- });
- return output;
}
+/**
+ * Disable debug output.
+ *
+ * @api public
+ */
-function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
- var name, str, desc;
- desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
- if (desc.get) {
- if (desc.set) {
- str = ctx.stylize('[Getter/Setter]', 'special');
- } else {
- str = ctx.stylize('[Getter]', 'special');
- }
- } else {
- if (desc.set) {
- str = ctx.stylize('[Setter]', 'special');
- }
- }
- if (!hasOwnProperty(visibleKeys, key)) {
- name = '[' + key + ']';
- }
- if (!str) {
- if (ctx.seen.indexOf(desc.value) < 0) {
- if (isNull(recurseTimes)) {
- str = formatValue(ctx, desc.value, null);
- } else {
- str = formatValue(ctx, desc.value, recurseTimes - 1);
- }
- if (str.indexOf('\n') > -1) {
- if (array) {
- str = str.split('\n').map(function(line) {
- return ' ' + line;
- }).join('\n').substr(2);
- } else {
- str = '\n' + str.split('\n').map(function(line) {
- return ' ' + line;
- }).join('\n');
- }
- }
- } else {
- str = ctx.stylize('[Circular]', 'special');
+function disable() {
+ exports.enable('');
+}
+
+/**
+ * Returns true if the given mode name is enabled, false otherwise.
+ *
+ * @param {String} name
+ * @return {Boolean}
+ * @api public
+ */
+
+function enabled(name) {
+ var i, len;
+ for (i = 0, len = exports.skips.length; i < len; i++) {
+ if (exports.skips[i].test(name)) {
+ return false;
}
}
- if (isUndefined(name)) {
- if (array && key.match(/^\d+$/)) {
- return str;
- }
- name = JSON.stringify('' + key);
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
- name = name.substr(1, name.length - 2);
- name = ctx.stylize(name, 'name');
- } else {
- name = name.replace(/'/g, "\\'")
- .replace(/\\"/g, '"')
- .replace(/(^"|"$)/g, "'");
- name = ctx.stylize(name, 'string');
+ for (i = 0, len = exports.names.length; i < len; i++) {
+ if (exports.names[i].test(name)) {
+ return true;
}
}
-
- return name + ': ' + str;
+ return false;
}
+/**
+ * Coerce `val`.
+ *
+ * @param {Mixed} val
+ * @return {Mixed}
+ * @api private
+ */
-function reduceToSingleString(output, base, braces) {
- var numLinesEst = 0;
- var length = output.reduce(function(prev, cur) {
- numLinesEst++;
- if (cur.indexOf('\n') >= 0) numLinesEst++;
- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
- }, 0);
-
- if (length > 60) {
- return braces[0] +
- (base === '' ? '' : base + '\n ') +
- ' ' +
- output.join(',\n ') +
- ' ' +
- braces[1];
- }
-
- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
+function coerce(val) {
+ if (val instanceof Error) return val.stack || val.message;
+ return val;
}
+},{"ms":8}],6:[function(require,module,exports){
+var split = require('browser-split')
+var ClassList = require('class-list')
-// NOTE: These type checking functions intentionally don't use `instanceof`
-// because it is fragile and can be easily faked with `Object.create()`.
-function isArray(ar) {
- return Array.isArray(ar);
-}
-exports.isArray = isArray;
-
-function isBoolean(arg) {
- return typeof arg === 'boolean';
-}
-exports.isBoolean = isBoolean;
+var w = typeof window === 'undefined' ? require('html-element') : window
+var document = w.document
+var Text = w.Text
-function isNull(arg) {
- return arg === null;
-}
-exports.isNull = isNull;
+function context () {
-function isNullOrUndefined(arg) {
- return arg == null;
-}
-exports.isNullOrUndefined = isNullOrUndefined;
+ var cleanupFuncs = []
-function isNumber(arg) {
- return typeof arg === 'number';
-}
-exports.isNumber = isNumber;
+ function h() {
+ var args = [].slice.call(arguments), e = null
+ function item (l) {
+ var r
+ function parseClass (string) {
+ // Our minimal parser doesn’t understand escaping CSS special
+ // characters like `#`. Don’t use them. More reading:
+ // https://mathiasbynens.be/notes/css-escapes .
-function isString(arg) {
- return typeof arg === 'string';
-}
-exports.isString = isString;
+ var m = split(string, /([\.#]?[^\s#.]+)/)
+ if(/^\.|#/.test(m[1]))
+ e = document.createElement('div')
+ forEach(m, function (v) {
+ var s = v.substring(1,v.length)
+ if(!v) return
+ if(!e)
+ e = document.createElement(v)
+ else if (v[0] === '.')
+ ClassList(e).add(s)
+ else if (v[0] === '#')
+ e.setAttribute('id', s)
+ })
+ }
-function isSymbol(arg) {
- return typeof arg === 'symbol';
-}
-exports.isSymbol = isSymbol;
+ if(l == null)
+ ;
+ else if('string' === typeof l) {
+ if(!e)
+ parseClass(l)
+ else
+ e.appendChild(r = document.createTextNode(l))
+ }
+ else if('number' === typeof l
+ || 'boolean' === typeof l
+ || l instanceof Date
+ || l instanceof RegExp ) {
+ e.appendChild(r = document.createTextNode(l.toString()))
+ }
+ //there might be a better way to handle this...
+ else if (isArray(l))
+ forEach(l, item)
+ else if(isNode(l))
+ e.appendChild(r = l)
+ else if(l instanceof Text)
+ e.appendChild(r = l)
+ else if ('object' === typeof l) {
+ for (var k in l) {
+ if('function' === typeof l[k]) {
+ if(/^on\w+/.test(k)) {
+ (function (k, l) { // capture k, l in the closure
+ if (e.addEventListener){
+ e.addEventListener(k.substring(2), l[k], false)
+ cleanupFuncs.push(function(){
+ e.removeEventListener(k.substring(2), l[k], false)
+ })
+ }else{
+ e.attachEvent(k, l[k])
+ cleanupFuncs.push(function(){
+ e.detachEvent(k, l[k])
+ })
+ }
+ })(k, l)
+ } else {
+ // observable
+ e[k] = l[k]()
+ cleanupFuncs.push(l[k](function (v) {
+ e[k] = v
+ }))
+ }
+ }
+ else if(k === 'style') {
+ if('string' === typeof l[k]) {
+ e.style.cssText = l[k]
+ }else{
+ for (var s in l[k]) (function(s, v) {
+ if('function' === typeof v) {
+ // observable
+ e.style.setProperty(s, v())
+ cleanupFuncs.push(v(function (val) {
+ e.style.setProperty(s, val)
+ }))
+ } else
+ var match = l[k][s].match(/(.*)\W+!important\W*$/);
+ if (match) {
+ e.style.setProperty(s, match[1], 'important')
+ } else {
+ e.style.setProperty(s, l[k][s])
+ }
+ })(s, l[k][s])
+ }
+ } else if(k === 'attrs') {
+ for (var v in l[k]) {
+ e.setAttribute(v, l[k][v])
+ }
+ }
+ else if (k.substr(0, 5) === "data-") {
+ e.setAttribute(k, l[k])
+ } else {
+ e[k] = l[k]
+ }
+ }
+ } else if ('function' === typeof l) {
+ //assume it's an observable!
+ var v = l()
+ e.appendChild(r = isNode(v) ? v : document.createTextNode(v))
-function isUndefined(arg) {
- return arg === void 0;
-}
-exports.isUndefined = isUndefined;
+ cleanupFuncs.push(l(function (v) {
+ if(isNode(v) && r.parentElement)
+ r.parentElement.replaceChild(v, r), r = v
+ else
+ r.textContent = v
+ }))
+ }
-function isRegExp(re) {
- return isObject(re) && objectToString(re) === '[object RegExp]';
-}
-exports.isRegExp = isRegExp;
+ return r
+ }
+ while(args.length)
+ item(args.shift())
-function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
-}
-exports.isObject = isObject;
+ return e
+ }
-function isDate(d) {
- return isObject(d) && objectToString(d) === '[object Date]';
-}
-exports.isDate = isDate;
+ h.cleanup = function () {
+ for (var i = 0; i < cleanupFuncs.length; i++){
+ cleanupFuncs[i]()
+ }
+ cleanupFuncs.length = 0
+ }
-function isError(e) {
- return isObject(e) &&
- (objectToString(e) === '[object Error]' || e instanceof Error);
+ return h
}
-exports.isError = isError;
-function isFunction(arg) {
- return typeof arg === 'function';
-}
-exports.isFunction = isFunction;
+var h = module.exports = context()
+h.context = context
-function isPrimitive(arg) {
- return arg === null ||
- typeof arg === 'boolean' ||
- typeof arg === 'number' ||
- typeof arg === 'string' ||
- typeof arg === 'symbol' || // ES6 symbol
- typeof arg === 'undefined';
+function isNode (el) {
+ return el && el.nodeName && el.nodeType
}
-exports.isPrimitive = isPrimitive;
-
-exports.isBuffer = require('./support/isBuffer');
-function objectToString(o) {
- return Object.prototype.toString.call(o);
+function forEach (arr, fn) {
+ if (arr.forEach) return arr.forEach(fn)
+ for (var i = 0; i < arr.length; i++) fn(arr[i], i)
}
-
-function pad(n) {
- return n < 10 ? '0' + n.toString(10) : n.toString(10);
+function isArray (arr) {
+ return Object.prototype.toString.call(arr) == '[object Array]'
}
-var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
- 'Oct', 'Nov', 'Dec'];
-// 26 Feb 16:19:34
-function timestamp() {
- var d = new Date();
- var time = [pad(d.getHours()),
- pad(d.getMinutes()),
- pad(d.getSeconds())].join(':');
- return [d.getDate(), months[d.getMonth()], time].join(' ');
-}
+},{"browser-split":2,"class-list":3,"html-element":11}],7:[function(require,module,exports){
+var indexOf = [].indexOf;
-// log is just a thin wrapper to console.log that prepends a timestamp
-exports.log = function() {
- console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
+module.exports = function(arr, obj){
+ if (indexOf) return arr.indexOf(obj);
+ for (var i = 0; i < arr.length; ++i) {
+ if (arr[i] === obj) return i;
+ }
+ return -1;
};
+},{}],8:[function(require,module,exports){
+/**
+ * Helpers.
+ */
+var s = 1000;
+var m = s * 60;
+var h = m * 60;
+var d = h * 24;
+var y = d * 365.25;
/**
- * Inherit the prototype methods from one constructor into another.
+ * Parse or format the given `val`.
*
- * The Function.prototype.inherits from lang.js rewritten as a standalone
- * function (not on Function.prototype). NOTE: If this file is to be loaded
- * during bootstrapping this function needs to be rewritten using some native
- * functions as prototype setup using normal JavaScript does not work as
- * expected during bootstrapping (see mirror.js in r114903).
+ * Options:
*
- * @param {function} ctor Constructor function which needs to inherit the
- * prototype.
- * @param {function} superCtor Constructor function to inherit prototype from.
+ * - `long` verbose formatting [false]
+ *
+ * @param {String|Number} val
+ * @param {Object} [options]
+ * @throws {Error} throw an error if val is not a non-empty string or a number
+ * @return {String|Number}
+ * @api public
*/
-exports.inherits = require('inherits');
-
-exports._extend = function(origin, add) {
- // Don't do anything if add isn't an object
- if (!add || !isObject(add)) return origin;
- var keys = Object.keys(add);
- var i = keys.length;
- while (i--) {
- origin[keys[i]] = add[keys[i]];
+module.exports = function(val, options) {
+ options = options || {};
+ var type = typeof val;
+ if (type === 'string' && val.length > 0) {
+ return parse(val);
+ } else if (type === 'number' && isNaN(val) === false) {
+ return options.long ? fmtLong(val) : fmtShort(val);
}
- return origin;
+ throw new Error(
+ 'val is not a non-empty string or a valid number. val=' +
+ JSON.stringify(val)
+ );
};
-function hasOwnProperty(obj, prop) {
- return Object.prototype.hasOwnProperty.call(obj, prop);
-}
-
-}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"./support/isBuffer":5,"_process":4,"inherits":3}],7:[function(require,module,exports){
-var parse = require('xml-parser');
-var render = require('xml-render');
-var fmt = require('util').format;
-var h = require('hyperscript');
-var inherits = require('util').inherits;
-var EventEmitter = require('events').EventEmitter;
-
-module.exports = Viewer;
-inherits(Viewer, EventEmitter);
-
-function Viewer(xml){
- EventEmitter.call(this);
- if (typeof xml != 'string') xml = xml.toString();
- var obj = parse(xml);
- this._el = this._renderRoot(obj);
- this._selection = null;
-}
-
-Viewer.prototype.appendTo = function(el){
- var self = this;
- el.appendChild(this._el);
- el.addEventListener('click', function(ev){
- if (ev.target == el) self._setSelection(null);
- });
-};
+/**
+ * Parse the given `str` and return milliseconds.
+ *
+ * @param {String} str
+ * @return {Number}
+ * @api private
+ */
-Viewer.prototype._setSelection = function(node){
- if (this._selection === node) return;
+function parse(str) {
+ str = String(str);
+ if (str.length > 100) {
+ return;
+ }
+ var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
+ str
+ );
+ if (!match) {
+ return;
+ }
+ var n = parseFloat(match[1]);
+ var type = (match[2] || 'ms').toLowerCase();
+ switch (type) {
+ case 'years':
+ case 'year':
+ case 'yrs':
+ case 'yr':
+ case 'y':
+ return n * y;
+ case 'days':
+ case 'day':
+ case 'd':
+ return n * d;
+ case 'hours':
+ case 'hour':
+ case 'hrs':
+ case 'hr':
+ case 'h':
+ return n * h;
+ case 'minutes':
+ case 'minute':
+ case 'mins':
+ case 'min':
+ case 'm':
+ return n * m;
+ case 'seconds':
+ case 'second':
+ case 'secs':
+ case 'sec':
+ case 's':
+ return n * s;
+ case 'milliseconds':
+ case 'millisecond':
+ case 'msecs':
+ case 'msec':
+ case 'ms':
+ return n;
+ default:
+ return undefined;
+ }
+}
- if (this._selection) this._selection.el.classList.remove('selected');
- if (node) node.el.classList.add('selected');
+/**
+ * Short format for `ms`.
+ *
+ * @param {Number} ms
+ * @return {String}
+ * @api private
+ */
- this._selection = node;
- this.emit('select', this._selection);
-};
+function fmtShort(ms) {
+ if (ms >= d) {
+ return Math.round(ms / d) + 'd';
+ }
+ if (ms >= h) {
+ return Math.round(ms / h) + 'h';
+ }
+ if (ms >= m) {
+ return Math.round(ms / m) + 'm';
+ }
+ if (ms >= s) {
+ return Math.round(ms / s) + 's';
+ }
+ return ms + 'ms';
+}
-Viewer.prototype.getSelection = function(){
- return this._selection;
-};
+/**
+ * Long format for `ms`.
+ *
+ * @param {Number} ms
+ * @return {String}
+ * @api private
+ */
-Viewer.prototype._renderRoot = function(node){
- var self = this;
+function fmtLong(ms) {
+ return plural(ms, d, 'day') ||
+ plural(ms, h, 'hour') ||
+ plural(ms, m, 'minute') ||
+ plural(ms, s, 'second') ||
+ ms + ' ms';
+}
- node.text = function(){
- return render.node(node);
- };
+/**
+ * Pluralization helper.
+ */
- var el = h('span',
- { onclick: this._handleClick(node) },
- spaces(2),
- render.declaration(node.declaration),
- this._renderNode(node.root)
- );
- node.el = el;
+function plural(ms, n, name) {
+ if (ms < n) {
+ return;
+ }
+ if (ms < n * 1.5) {
+ return Math.floor(ms / n) + ' ' + name;
+ }
+ return Math.ceil(ms / n) + ' ' + name + 's';
+}
- return el;
-};
+},{}],9:[function(require,module,exports){
-Viewer.prototype._renderNode = function(node, indent){
- var self = this;
- var folded = false;
- indent = indent || 0;
+/**
+ * Module dependencies.
+ */
- if (!node.children || !node.children.length) return this._renderLeaf(node, indent);
+var debug = require('debug')('xml-parser');
- function ontoggle(ev){
- ev.stopPropagation();
- if (folded) {
- ev.target.innerHTML = '-';
- node.children.forEach(function(child){
- child.el.style.display = 'inline';
- });
- } else {
- ev.target.innerHTML = '+';
- node.children.forEach(function(child){
- child.el.style.display = 'none';
- });
- }
- folded = !folded;
- }
+/**
+ * Expose `parse`.
+ */
- node.text = function(){
- return render.node(node);
- };
+module.exports = parse;
- var el = h('span',
- { onclick: this._handleClick(node) },
- h('br'),
- tabs(indent),
- h('span', { onclick: ontoggle }, '-'),
- spaces(1),
- render.tagOpen(node),
- node.children.map(function(child){
- return self._renderNode(child, indent + 1);
- }),
- h('br'),
- tabs(indent),
- spaces(2),
- render.tagClose(node)
- );
- node.el = el;
+/**
+ * Parse the given string of `xml`.
+ *
+ * @param {String} xml
+ * @return {Object}
+ * @api public
+ */
- return el;
-}
+function parse(xml) {
+ xml = xml.trim();
-Viewer.prototype._renderLeaf = function(node, indent){
- var self = this;
+ // strip comments
+ xml = xml.replace(//g, '');
- node.text = function(){
- return render.node(node);
- };
+ return document();
- var el = h('span',
- { onclick: this._handleClick(node) },
- h('br'),
- tabs(indent),
- spaces(2),
- node.text()
- );
- node.el = el;
+ /**
+ * XML document.
+ */
- return el;
-}
+ function document() {
+ return {
+ declaration: declaration(),
+ root: tag()
+ }
+ }
-Viewer.prototype._handleClick = function(node){
- var self = this;
- return function(ev){
- ev.stopPropagation();
- self._setSelection(node);
- };
-};
+ /**
+ * Declaration.
+ */
-function tabs(n){
- var out = [];
- for (var i = 0; i < n; i++) out.push(spaces(4));
- return out;
-}
+ function declaration() {
+ var m = match(/^<\?xml\s*/);
+ if (!m) return;
-function spaces(n){
- var el = document.createElement('span');
- for (var i = 0; i < n; i++) {
- el.innerHTML += ' ';
- }
- return el;
-}
+ // tag
+ var node = {
+ attributes: {}
+ };
-},{"events":2,"hyperscript":8,"util":6,"xml-parser":12,"xml-render":16}],8:[function(require,module,exports){
-var split = require('browser-split')
-var ClassList = require('class-list')
-require('html-element')
+ // attributes
+ while (!(eos() || is('?>'))) {
+ var attr = attribute();
+ if (!attr) return node;
+ node.attributes[attr.name] = attr.value;
+ }
-function context () {
+ match(/\?>\s*/);
- var cleanupFuncs = []
+ return node;
+ }
- function h() {
- var args = [].slice.call(arguments), e = null
- function item (l) {
- var r
- function parseClass (string) {
- // Our minimal parser doesn’t understand escaping CSS special
- // characters like `#`. Don’t use them. More reading:
- // https://mathiasbynens.be/notes/css-escapes .
+ /**
+ * Tag.
+ */
- var m = split(string, /([\.#]?[^\s#.]+)/)
- if(/^\.|#/.test(m[1]))
- e = document.createElement('div')
- forEach(m, function (v) {
- var s = v.substring(1,v.length)
- if(!v) return
- if(!e)
- e = document.createElement(v)
- else if (v[0] === '.')
- ClassList(e).add(s)
- else if (v[0] === '#')
- e.setAttribute('id', s)
- })
- }
+ function tag() {
+ debug('tag %j', xml);
+ var m = match(/^<([\w-:.]+)\s*/);
+ if (!m) return;
- if(l == null)
- ;
- else if('string' === typeof l) {
- if(!e)
- parseClass(l)
- else
- e.appendChild(r = document.createTextNode(l))
- }
- else if('number' === typeof l
- || 'boolean' === typeof l
- || l instanceof Date
- || l instanceof RegExp ) {
- e.appendChild(r = document.createTextNode(l.toString()))
- }
- //there might be a better way to handle this...
- else if (isArray(l))
- forEach(l, item)
- else if(isNode(l))
- e.appendChild(r = l)
- else if(l instanceof Text)
- e.appendChild(r = l)
- else if ('object' === typeof l) {
- for (var k in l) {
- if('function' === typeof l[k]) {
- if(/^on\w+/.test(k)) {
- (function (k, l) { // capture k, l in the closure
- if (e.addEventListener){
- e.addEventListener(k.substring(2), l[k], false)
- cleanupFuncs.push(function(){
- e.removeEventListener(k.substring(2), l[k], false)
- })
- }else{
- e.attachEvent(k, l[k])
- cleanupFuncs.push(function(){
- e.detachEvent(k, l[k])
- })
- }
- })(k, l)
- } else {
- // observable
- e[k] = l[k]()
- cleanupFuncs.push(l[k](function (v) {
- e[k] = v
- }))
- }
- }
- else if(k === 'style') {
- if('string' === typeof l[k]) {
- e.style.cssText = l[k]
- }else{
- for (var s in l[k]) (function(s, v) {
- if('function' === typeof v) {
- // observable
- e.style.setProperty(s, v())
- cleanupFuncs.push(v(function (val) {
- e.style.setProperty(s, val)
- }))
- } else
- e.style.setProperty(s, l[k][s])
- })(s, l[k][s])
- }
- } else if (k.substr(0, 5) === "data-") {
- e.setAttribute(k, l[k])
- } else {
- e[k] = l[k]
- }
- }
- } else if ('function' === typeof l) {
- //assume it's an observable!
- var v = l()
- e.appendChild(r = isNode(v) ? v : document.createTextNode(v))
+ // name
+ var node = {
+ name: m[1],
+ attributes: {},
+ children: []
+ };
- cleanupFuncs.push(l(function (v) {
- if(isNode(v) && r.parentElement)
- r.parentElement.replaceChild(v, r), r = v
- else
- r.textContent = v
- }))
- }
+ // attributes
+ while (!(eos() || is('>') || is('?>') || is('/>'))) {
+ var attr = attribute();
+ if (!attr) return node;
+ node.attributes[attr.name] = attr.value;
+ }
- return r
+ // self closing tag
+ if (match(/^\s*\/>\s*/)) {
+ return node;
}
- while(args.length)
- item(args.shift())
- return e
- }
+ match(/\??>\s*/);
- h.cleanup = function () {
- for (var i = 0; i < cleanupFuncs.length; i++){
- cleanupFuncs[i]()
+ // content
+ node.content = content();
+
+ // children
+ var child;
+ while (child = tag()) {
+ node.children.push(child);
}
- cleanupFuncs.length = 0
+
+ // closing
+ match(/^<\/[\w-:.]+>\s*/);
+
+ return node;
}
- return h
-}
+ /**
+ * Text content.
+ */
-var h = module.exports = context()
-h.context = context
+ function content() {
+ debug('content %j', xml);
+ var m = match(/^([^<]*)/);
+ if (m) return m[1];
+ return '';
+ }
-function isNode (el) {
- return el && el.nodeName && el.nodeType
-}
+ /**
+ * Attribute.
+ */
-function isText (el) {
- return el && el.nodeName === '#text' && el.nodeType == 3
-}
+ function attribute() {
+ debug('attribute %j', xml);
+ var m = match(/([\w:-]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/);
+ if (!m) return;
+ return { name: m[1], value: strip(m[2]) }
+ }
-function forEach (arr, fn) {
- if (arr.forEach) return arr.forEach(fn)
- for (var i = 0; i < arr.length; i++) fn(arr[i], i)
-}
+ /**
+ * Strip quotes from `val`.
+ */
-function isArray (arr) {
- return Object.prototype.toString.call(arr) == '[object Array]'
+ function strip(val) {
+ return val.replace(/^['"]|['"]$/g, '');
+ }
+
+ /**
+ * Match `re` and advance the string.
+ */
+
+ function match(re) {
+ var m = xml.match(re);
+ if (!m) return;
+ xml = xml.slice(m[0].length);
+ return m;
+ }
+
+ /**
+ * End-of-source.
+ */
+
+ function eos() {
+ return 0 == xml.length;
+ }
+
+ /**
+ * Check for `prefix`.
+ */
+
+ function is(prefix) {
+ return 0 == xml.indexOf(prefix);
+ }
}
-},{"browser-split":9,"class-list":10,"html-element":1}],9:[function(require,module,exports){
-/*!
- * Cross-Browser Split 1.1.1
- * Copyright 2007-2012 Steven Levithan
- * Available under the MIT License
- * ECMAScript compliant, uniform cross-browser split method
- */
+},{"debug":4}],10:[function(require,module,exports){
+var fmt = require('util').format;
-/**
- * Splits a string into an array of strings using a regex or string separator. Matches of the
- * separator are not included in the result array. However, if `separator` is a regex that contains
- * capturing groups, backreferences are spliced into the result each time `separator` is matched.
- * Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably
- * cross-browser.
- * @param {String} str String to split.
- * @param {RegExp|String} separator Regex or string to use for separating the string.
- * @param {Number} [limit] Maximum number of items to include in the result array.
- * @returns {Array} Array of substrings.
- * @example
- *
- * // Basic use
- * split('a b c d', ' ');
- * // -> ['a', 'b', 'c', 'd']
- *
- * // With limit
- * split('a b c d', ' ', 2);
- * // -> ['a', 'b']
- *
- * // Backreferences in result array
- * split('..word1 word2..', /([a-z]+)(\d+)/i);
- * // -> ['..', 'word', '1', ' ', 'word', '2', '..']
- */
-module.exports = (function split(undef) {
+exports.tagOpen = function(node){
+ return fmt('<%s%s>', node.name, renderAttributes(node));
+};
- var nativeSplit = String.prototype.split,
- compliantExecNpcg = /()??/.exec("")[1] === undef,
- // NPCG: nonparticipating capturing group
- self;
+exports.declaration = function(node){
+ return fmt('', renderAttributes(node));
+};
- self = function(str, separator, limit) {
- // If `separator` is not a regex, use `nativeSplit`
- if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
- return nativeSplit.call(str, separator, limit);
- }
- var output = [],
- flags = (separator.ignoreCase ? "i" : "") + (separator.multiline ? "m" : "") + (separator.extended ? "x" : "") + // Proposed for ES6
- (separator.sticky ? "y" : ""),
- // Firefox 3+
- lastLastIndex = 0,
- // Make `global` and avoid `lastIndex` issues by working with a copy
- separator = new RegExp(separator.source, flags + "g"),
- separator2, match, lastIndex, lastLength;
- str += ""; // Type-convert
- if (!compliantExecNpcg) {
- // Doesn't need flags gy, but they don't hurt
- separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
- }
- /* Values for `limit`, per the spec:
- * If undefined: 4294967295 // Math.pow(2, 32) - 1
- * If 0, Infinity, or NaN: 0
- * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
- * If negative number: 4294967296 - Math.floor(Math.abs(limit))
- * If other: Type-convert, then use the above rules
- */
- limit = limit === undef ? -1 >>> 0 : // Math.pow(2, 32) - 1
- limit >>> 0; // ToUint32(limit)
- while (match = separator.exec(str)) {
- // `separator.lastIndex` is not reliable cross-browser
- lastIndex = match.index + match[0].length;
- if (lastIndex > lastLastIndex) {
- output.push(str.slice(lastLastIndex, match.index));
- // Fix browsers whose `exec` methods don't consistently return `undefined` for
- // nonparticipating capturing groups
- if (!compliantExecNpcg && match.length > 1) {
- match[0].replace(separator2, function() {
- for (var i = 1; i < arguments.length - 2; i++) {
- if (arguments[i] === undef) {
- match[i] = undef;
- }
- }
- });
- }
- if (match.length > 1 && match.index < str.length) {
- Array.prototype.push.apply(output, match.slice(1));
- }
- lastLength = match[0].length;
- lastLastIndex = lastIndex;
- if (output.length >= limit) {
- break;
- }
- }
- if (separator.lastIndex === match.index) {
- separator.lastIndex++; // Avoid an infinite loop
- }
- }
- if (lastLastIndex === str.length) {
- if (lastLength || !separator.test("")) {
- output.push("");
- }
- } else {
- output.push(str.slice(lastLastIndex));
- }
- return output.length > limit ? output.slice(0, limit) : output;
- };
+function renderAttributes(node){
+ var attr = exports.attributes(node);
+ return attr.length ? ' ' + attr : '';
+};
- return self;
-})();
+exports.attributes = function(node){
+ if (!node.attributes) return '';
+ var keys = Object.keys(node.attributes);
+ if (!keys.length) return '';
+ return keys.map(function(key){
+ return fmt('%s="%s"', key, node.attributes[key]);
+ }).join(' ');
+};
-},{}],10:[function(require,module,exports){
-// contains, add, remove, toggle
-var indexof = require('indexof')
+exports.tagClose = function(node){
+ return fmt('%s>', node.name);
+};
-module.exports = ClassList
+exports.leaf = function(node){
+ return exports.tagOpen(node) + node.content + exports.tagClose(node);
+};
-function ClassList(elem) {
- var cl = elem.classList
+exports.node = function(node){
+ if (node.root) return exports.document(node);
+ if (!node.children || !node.children.length) return exports.leaf(node);
- if (cl) {
- return cl
- }
+ return exports.tagOpen(node) + '\n'
+ + node.children.map(function(child){
+ return exports.node(child).replace(/^/gm, '\t');
+ }).join('\n') + '\n'
+ + exports.tagClose(node);
+};
- var classList = {
- add: add
- , remove: remove
- , contains: contains
- , toggle: toggle
- , toString: $toString
- , length: 0
- , item: item
- }
+exports.document = function(node){
+ return exports.declaration(node.declaration) + '\n'
+ + exports.node(node.root);
+};
- return classList
- function add(token) {
- var list = getTokens()
- if (indexof(list, token) > -1) {
- return
- }
- list.push(token)
- setTokens(list)
- }
+},{"util":16}],11:[function(require,module,exports){
- function remove(token) {
- var list = getTokens()
- , index = indexof(list, token)
+},{}],12:[function(require,module,exports){
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
- if (index === -1) {
- return
- }
+function EventEmitter() {
+ this._events = this._events || {};
+ this._maxListeners = this._maxListeners || undefined;
+}
+module.exports = EventEmitter;
- list.splice(index, 1)
- setTokens(list)
- }
+// Backwards-compat with node 0.10.x
+EventEmitter.EventEmitter = EventEmitter;
- function contains(token) {
- return indexof(getTokens(), token) > -1
- }
+EventEmitter.prototype._events = undefined;
+EventEmitter.prototype._maxListeners = undefined;
- function toggle(token) {
- if (contains(token)) {
- remove(token)
- return false
- } else {
- add(token)
- return true
- }
- }
+// By default EventEmitters will print a warning if more than 10 listeners are
+// added to it. This is a useful default which helps finding memory leaks.
+EventEmitter.defaultMaxListeners = 10;
- function $toString() {
- return elem.className
+// Obviously not all Emitters should be limited to 10. This function allows
+// that to be increased. Set to zero for unlimited.
+EventEmitter.prototype.setMaxListeners = function(n) {
+ if (!isNumber(n) || n < 0 || isNaN(n))
+ throw TypeError('n must be a positive number');
+ this._maxListeners = n;
+ return this;
+};
+
+EventEmitter.prototype.emit = function(type) {
+ var er, handler, len, args, i, listeners;
+
+ if (!this._events)
+ this._events = {};
+
+ // If there is no 'error' event listener then throw.
+ if (type === 'error') {
+ if (!this._events.error ||
+ (isObject(this._events.error) && !this._events.error.length)) {
+ er = arguments[1];
+ if (er instanceof Error) {
+ throw er; // Unhandled 'error' event
+ } else {
+ // At least give some kind of context to the user
+ var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
+ err.context = er;
+ throw err;
+ }
}
+ }
- function item(index) {
- var tokens = getTokens()
- return tokens[index] || null
+ handler = this._events[type];
+
+ if (isUndefined(handler))
+ return false;
+
+ if (isFunction(handler)) {
+ switch (arguments.length) {
+ // fast cases
+ case 1:
+ handler.call(this);
+ break;
+ case 2:
+ handler.call(this, arguments[1]);
+ break;
+ case 3:
+ handler.call(this, arguments[1], arguments[2]);
+ break;
+ // slower
+ default:
+ args = Array.prototype.slice.call(arguments, 1);
+ handler.apply(this, args);
}
+ } else if (isObject(handler)) {
+ args = Array.prototype.slice.call(arguments, 1);
+ listeners = handler.slice();
+ len = listeners.length;
+ for (i = 0; i < len; i++)
+ listeners[i].apply(this, args);
+ }
- function getTokens() {
- var className = elem.className
+ return true;
+};
- return filter(className.split(" "), isTruthy)
- }
+EventEmitter.prototype.addListener = function(type, listener) {
+ var m;
- function setTokens(list) {
- var length = list.length
+ if (!isFunction(listener))
+ throw TypeError('listener must be a function');
- elem.className = list.join(" ")
- classList.length = length
+ if (!this._events)
+ this._events = {};
- for (var i = 0; i < list.length; i++) {
- classList[i] = list[i]
- }
+ // To avoid recursion in the case that type === "newListener"! Before
+ // adding it to the listeners, first emit "newListener".
+ if (this._events.newListener)
+ this.emit('newListener', type,
+ isFunction(listener.listener) ?
+ listener.listener : listener);
- delete list[length]
+ if (!this._events[type])
+ // Optimize the case of one listener. Don't need the extra array object.
+ this._events[type] = listener;
+ else if (isObject(this._events[type]))
+ // If we've already got an array, just append.
+ this._events[type].push(listener);
+ else
+ // Adding the second element, need to change to array.
+ this._events[type] = [this._events[type], listener];
+
+ // Check for listener leak
+ if (isObject(this._events[type]) && !this._events[type].warned) {
+ if (!isUndefined(this._maxListeners)) {
+ m = this._maxListeners;
+ } else {
+ m = EventEmitter.defaultMaxListeners;
}
-}
-function filter (arr, fn) {
- var ret = []
- for (var i = 0; i < arr.length; i++) {
- if (fn(arr[i])) ret.push(arr[i])
+ if (m && m > 0 && this._events[type].length > m) {
+ this._events[type].warned = true;
+ console.error('(node) warning: possible EventEmitter memory ' +
+ 'leak detected. %d listeners added. ' +
+ 'Use emitter.setMaxListeners() to increase limit.',
+ this._events[type].length);
+ if (typeof console.trace === 'function') {
+ // not supported in IE 10
+ console.trace();
+ }
}
- return ret
-}
+ }
-function isTruthy(value) {
- return !!value
-}
+ return this;
+};
-},{"indexof":11}],11:[function(require,module,exports){
+EventEmitter.prototype.on = EventEmitter.prototype.addListener;
-var indexOf = [].indexOf;
+EventEmitter.prototype.once = function(type, listener) {
+ if (!isFunction(listener))
+ throw TypeError('listener must be a function');
-module.exports = function(arr, obj){
- if (indexOf) return arr.indexOf(obj);
- for (var i = 0; i < arr.length; ++i) {
- if (arr[i] === obj) return i;
- }
- return -1;
-};
-},{}],12:[function(require,module,exports){
+ var fired = false;
-/**
- * Module dependencies.
- */
+ function g() {
+ this.removeListener(type, g);
-var debug = require('debug')('xml-parser');
+ if (!fired) {
+ fired = true;
+ listener.apply(this, arguments);
+ }
+ }
-/**
- * Expose `parse`.
- */
+ g.listener = listener;
+ this.on(type, g);
-module.exports = parse;
+ return this;
+};
-/**
- * Parse the given string of `xml`.
- *
- * @param {String} xml
- * @return {Object}
- * @api public
- */
+// emits a 'removeListener' event iff the listener was removed
+EventEmitter.prototype.removeListener = function(type, listener) {
+ var list, position, length, i;
-function parse(xml) {
- xml = xml.trim();
+ if (!isFunction(listener))
+ throw TypeError('listener must be a function');
- // strip comments
- xml = xml.replace(//g, '');
+ if (!this._events || !this._events[type])
+ return this;
- return document();
+ list = this._events[type];
+ length = list.length;
+ position = -1;
- /**
- * XML document.
- */
+ if (list === listener ||
+ (isFunction(list.listener) && list.listener === listener)) {
+ delete this._events[type];
+ if (this._events.removeListener)
+ this.emit('removeListener', type, listener);
- function document() {
- return {
- declaration: declaration(),
- root: tag()
+ } else if (isObject(list)) {
+ for (i = length; i-- > 0;) {
+ if (list[i] === listener ||
+ (list[i].listener && list[i].listener === listener)) {
+ position = i;
+ break;
+ }
}
- }
-
- /**
- * Declaration.
- */
-
- function declaration() {
- var m = match(/^<\?xml\s*/);
- if (!m) return;
- // tag
- var node = {
- attributes: {}
- };
+ if (position < 0)
+ return this;
- // attributes
- while (!(eos() || is('?>'))) {
- var attr = attribute();
- if (!attr) return node;
- node.attributes[attr.name] = attr.value;
+ if (list.length === 1) {
+ list.length = 0;
+ delete this._events[type];
+ } else {
+ list.splice(position, 1);
}
- match(/\?>\s*/);
-
- return node;
+ if (this._events.removeListener)
+ this.emit('removeListener', type, listener);
}
- /**
- * Tag.
- */
-
- function tag() {
- debug('tag %j', xml);
- var m = match(/^<([\w-:.]+)\s*/);
- if (!m) return;
-
- // name
- var node = {
- name: m[1],
- attributes: {},
- children: []
- };
-
- // attributes
- while (!(eos() || is('>') || is('?>') || is('/>'))) {
- var attr = attribute();
- if (!attr) return node;
- node.attributes[attr.name] = attr.value;
- }
+ return this;
+};
- // self closing tag
- if (match(/^\s*\/>\s*/)) {
- return node;
- }
+EventEmitter.prototype.removeAllListeners = function(type) {
+ var key, listeners;
- match(/\??>\s*/);
+ if (!this._events)
+ return this;
- // content
- node.content = content();
+ // not listening for removeListener, no need to emit
+ if (!this._events.removeListener) {
+ if (arguments.length === 0)
+ this._events = {};
+ else if (this._events[type])
+ delete this._events[type];
+ return this;
+ }
- // children
- var child;
- while (child = tag()) {
- node.children.push(child);
+ // emit removeListener for all listeners on all events
+ if (arguments.length === 0) {
+ for (key in this._events) {
+ if (key === 'removeListener') continue;
+ this.removeAllListeners(key);
}
+ this.removeAllListeners('removeListener');
+ this._events = {};
+ return this;
+ }
- // closing
- match(/^<\/[\w-:.]+>\s*/);
+ listeners = this._events[type];
- return node;
+ if (isFunction(listeners)) {
+ this.removeListener(type, listeners);
+ } else if (listeners) {
+ // LIFO order
+ while (listeners.length)
+ this.removeListener(type, listeners[listeners.length - 1]);
}
+ delete this._events[type];
- /**
- * Text content.
- */
+ return this;
+};
- function content() {
- debug('content %j', xml);
- var m = match(/^([^<]*)/);
- if (m) return m[1];
- return '';
- }
+EventEmitter.prototype.listeners = function(type) {
+ var ret;
+ if (!this._events || !this._events[type])
+ ret = [];
+ else if (isFunction(this._events[type]))
+ ret = [this._events[type]];
+ else
+ ret = this._events[type].slice();
+ return ret;
+};
- /**
- * Attribute.
- */
+EventEmitter.prototype.listenerCount = function(type) {
+ if (this._events) {
+ var evlistener = this._events[type];
- function attribute() {
- debug('attribute %j', xml);
- var m = match(/([\w:-]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/);
- if (!m) return;
- return { name: m[1], value: strip(m[2]) }
+ if (isFunction(evlistener))
+ return 1;
+ else if (evlistener)
+ return evlistener.length;
}
+ return 0;
+};
- /**
- * Strip quotes from `val`.
- */
+EventEmitter.listenerCount = function(emitter, type) {
+ return emitter.listenerCount(type);
+};
- function strip(val) {
- return val.replace(/^['"]|['"]$/g, '');
- }
+function isFunction(arg) {
+ return typeof arg === 'function';
+}
- /**
- * Match `re` and advance the string.
- */
+function isNumber(arg) {
+ return typeof arg === 'number';
+}
- function match(re) {
- var m = xml.match(re);
- if (!m) return;
- xml = xml.slice(m[0].length);
- return m;
- }
+function isObject(arg) {
+ return typeof arg === 'object' && arg !== null;
+}
- /**
- * End-of-source.
- */
+function isUndefined(arg) {
+ return arg === void 0;
+}
- function eos() {
- return 0 == xml.length;
+},{}],13:[function(require,module,exports){
+if (typeof Object.create === 'function') {
+ // implementation from standard node.js 'util' module
+ module.exports = function inherits(ctor, superCtor) {
+ ctor.super_ = superCtor
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+ };
+} else {
+ // old school shim for old browsers
+ module.exports = function inherits(ctor, superCtor) {
+ ctor.super_ = superCtor
+ var TempCtor = function () {}
+ TempCtor.prototype = superCtor.prototype
+ ctor.prototype = new TempCtor()
+ ctor.prototype.constructor = ctor
}
+}
- /**
- * Check for `prefix`.
- */
+},{}],14:[function(require,module,exports){
+// shim for using process in browser
- function is(prefix) {
- return 0 == xml.indexOf(prefix);
+var process = module.exports = {};
+
+// cached from whatever global is present so that test runners that stub it
+// don't break things. But we need to wrap it in a try catch in case it is
+// wrapped in strict mode code which doesn't define any globals. It's inside a
+// function because try/catches deoptimize in certain engines.
+
+var cachedSetTimeout;
+var cachedClearTimeout;
+
+(function () {
+ try {
+ cachedSetTimeout = setTimeout;
+ } catch (e) {
+ cachedSetTimeout = function () {
+ throw new Error('setTimeout is not defined');
+ }
+ }
+ try {
+ cachedClearTimeout = clearTimeout;
+ } catch (e) {
+ cachedClearTimeout = function () {
+ throw new Error('clearTimeout is not defined');
+ }
}
+} ())
+var queue = [];
+var draining = false;
+var currentQueue;
+var queueIndex = -1;
+
+function cleanUpNextTick() {
+ if (!draining || !currentQueue) {
+ return;
+ }
+ draining = false;
+ if (currentQueue.length) {
+ queue = currentQueue.concat(queue);
+ } else {
+ queueIndex = -1;
+ }
+ if (queue.length) {
+ drainQueue();
+ }
}
-},{"debug":13}],13:[function(require,module,exports){
+function drainQueue() {
+ if (draining) {
+ return;
+ }
+ var timeout = cachedSetTimeout.call(null, cleanUpNextTick);
+ draining = true;
-/**
- * This is the web browser implementation of `debug()`.
- *
- * Expose `debug()` as the module.
- */
+ var len = queue.length;
+ while(len) {
+ currentQueue = queue;
+ queue = [];
+ while (++queueIndex < len) {
+ if (currentQueue) {
+ currentQueue[queueIndex].run();
+ }
+ }
+ queueIndex = -1;
+ len = queue.length;
+ }
+ currentQueue = null;
+ draining = false;
+ cachedClearTimeout.call(null, timeout);
+}
-exports = module.exports = require('./debug');
-exports.log = log;
-exports.formatArgs = formatArgs;
-exports.save = save;
-exports.load = load;
-exports.useColors = useColors;
-exports.storage = 'undefined' != typeof chrome
- && 'undefined' != typeof chrome.storage
- ? chrome.storage.local
- : localstorage();
+process.nextTick = function (fun) {
+ var args = new Array(arguments.length - 1);
+ if (arguments.length > 1) {
+ for (var i = 1; i < arguments.length; i++) {
+ args[i - 1] = arguments[i];
+ }
+ }
+ queue.push(new Item(fun, args));
+ if (queue.length === 1 && !draining) {
+ cachedSetTimeout.call(null, drainQueue, 0);
+ }
+};
-/**
- * Colors.
- */
+// v8 likes predictible objects
+function Item(fun, array) {
+ this.fun = fun;
+ this.array = array;
+}
+Item.prototype.run = function () {
+ this.fun.apply(null, this.array);
+};
+process.title = 'browser';
+process.browser = true;
+process.env = {};
+process.argv = [];
+process.version = ''; // empty string to avoid regexp issues
+process.versions = {};
-exports.colors = [
- 'lightseagreen',
- 'forestgreen',
- 'goldenrod',
- 'dodgerblue',
- 'darkorchid',
- 'crimson'
-];
+function noop() {}
-/**
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
- * and the Firebug extension (any Firefox version) are known
- * to support "%c" CSS customizations.
- *
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
- */
+process.on = noop;
+process.addListener = noop;
+process.once = noop;
+process.off = noop;
+process.removeListener = noop;
+process.removeAllListeners = noop;
+process.emit = noop;
-function useColors() {
- // is webkit? http://stackoverflow.com/a/16459606/376773
- return ('WebkitAppearance' in document.documentElement.style) ||
- // is firebug? http://stackoverflow.com/a/398120/376773
- (window.console && (console.firebug || (console.exception && console.table))) ||
- // is firefox >= v31?
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
- (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
+process.binding = function (name) {
+ throw new Error('process.binding is not supported');
+};
+
+process.cwd = function () { return '/' };
+process.chdir = function (dir) {
+ throw new Error('process.chdir is not supported');
+};
+process.umask = function() { return 0; };
+
+},{}],15:[function(require,module,exports){
+module.exports = function isBuffer(arg) {
+ return arg && typeof arg === 'object'
+ && typeof arg.copy === 'function'
+ && typeof arg.fill === 'function'
+ && typeof arg.readUInt8 === 'function';
}
+},{}],16:[function(require,module,exports){
+(function (process,global){
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
-/**
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
- */
+var formatRegExp = /%[sdj%]/g;
+exports.format = function(f) {
+ if (!isString(f)) {
+ var objects = [];
+ for (var i = 0; i < arguments.length; i++) {
+ objects.push(inspect(arguments[i]));
+ }
+ return objects.join(' ');
+ }
-exports.formatters.j = function(v) {
- return JSON.stringify(v);
+ var i = 1;
+ var args = arguments;
+ var len = args.length;
+ var str = String(f).replace(formatRegExp, function(x) {
+ if (x === '%%') return '%';
+ if (i >= len) return x;
+ switch (x) {
+ case '%s': return String(args[i++]);
+ case '%d': return Number(args[i++]);
+ case '%j':
+ try {
+ return JSON.stringify(args[i++]);
+ } catch (_) {
+ return '[Circular]';
+ }
+ default:
+ return x;
+ }
+ });
+ for (var x = args[i]; i < len; x = args[++i]) {
+ if (isNull(x) || !isObject(x)) {
+ str += ' ' + x;
+ } else {
+ str += ' ' + inspect(x);
+ }
+ }
+ return str;
};
-/**
- * Colorize log arguments if enabled.
- *
- * @api public
- */
+// Mark that a method should not be used.
+// Returns a modified function which warns once by default.
+// If --no-deprecation is set, then it is a no-op.
+exports.deprecate = function(fn, msg) {
+ // Allow for deprecating things in the process of starting up.
+ if (isUndefined(global.process)) {
+ return function() {
+ return exports.deprecate(fn, msg).apply(this, arguments);
+ };
+ }
-function formatArgs() {
- var args = arguments;
- var useColors = this.useColors;
+ if (process.noDeprecation === true) {
+ return fn;
+ }
- args[0] = (useColors ? '%c' : '')
- + this.namespace
- + (useColors ? ' %c' : ' ')
- + args[0]
- + (useColors ? '%c ' : ' ')
- + '+' + exports.humanize(this.diff);
+ var warned = false;
+ function deprecated() {
+ if (!warned) {
+ if (process.throwDeprecation) {
+ throw new Error(msg);
+ } else if (process.traceDeprecation) {
+ console.trace(msg);
+ } else {
+ console.error(msg);
+ }
+ warned = true;
+ }
+ return fn.apply(this, arguments);
+ }
- if (!useColors) return args;
+ return deprecated;
+};
- var c = 'color: ' + this.color;
- args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));
- // the final "%c" is somewhat tricky, because there could be other
- // arguments passed either before or after the %c, so we need to
- // figure out the correct index to insert the CSS into
- var index = 0;
- var lastC = 0;
- args[0].replace(/%[a-z%]/g, function(match) {
- if ('%%' === match) return;
- index++;
- if ('%c' === match) {
- // we only are interested in the *last* %c
- // (the user may have provided their own)
- lastC = index;
+var debugs = {};
+var debugEnviron;
+exports.debuglog = function(set) {
+ if (isUndefined(debugEnviron))
+ debugEnviron = process.env.NODE_DEBUG || '';
+ set = set.toUpperCase();
+ if (!debugs[set]) {
+ if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
+ var pid = process.pid;
+ debugs[set] = function() {
+ var msg = exports.format.apply(exports, arguments);
+ console.error('%s %d: %s', set, pid, msg);
+ };
+ } else {
+ debugs[set] = function() {};
}
- });
+ }
+ return debugs[set];
+};
- args.splice(lastC, 0, c);
- return args;
-}
/**
- * Invokes `console.log()` when available.
- * No-op when `console.log` is not a "function".
+ * Echos the value of a value. Trys to print the value out
+ * in the best way possible given the different types.
*
- * @api public
+ * @param {Object} obj The object to print out.
+ * @param {Object} opts Optional options object that alters the output.
*/
-
-function log() {
- // this hackery is required for IE8/9, where
- // the `console.log` function doesn't have 'apply'
- return 'object' === typeof console
- && console.log
- && Function.prototype.apply.call(console.log, console, arguments);
+/* legacy: obj, showHidden, depth, colors*/
+function inspect(obj, opts) {
+ // default options
+ var ctx = {
+ seen: [],
+ stylize: stylizeNoColor
+ };
+ // legacy...
+ if (arguments.length >= 3) ctx.depth = arguments[2];
+ if (arguments.length >= 4) ctx.colors = arguments[3];
+ if (isBoolean(opts)) {
+ // legacy...
+ ctx.showHidden = opts;
+ } else if (opts) {
+ // got an "options" object
+ exports._extend(ctx, opts);
+ }
+ // set default options
+ if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
+ if (isUndefined(ctx.depth)) ctx.depth = 2;
+ if (isUndefined(ctx.colors)) ctx.colors = false;
+ if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
+ if (ctx.colors) ctx.stylize = stylizeWithColor;
+ return formatValue(ctx, obj, ctx.depth);
}
+exports.inspect = inspect;
-/**
- * Save `namespaces`.
- *
- * @param {String} namespaces
- * @api private
- */
-function save(namespaces) {
- try {
- if (null == namespaces) {
- exports.storage.removeItem('debug');
- } else {
- exports.storage.debug = namespaces;
- }
- } catch(e) {}
+// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
+inspect.colors = {
+ 'bold' : [1, 22],
+ 'italic' : [3, 23],
+ 'underline' : [4, 24],
+ 'inverse' : [7, 27],
+ 'white' : [37, 39],
+ 'grey' : [90, 39],
+ 'black' : [30, 39],
+ 'blue' : [34, 39],
+ 'cyan' : [36, 39],
+ 'green' : [32, 39],
+ 'magenta' : [35, 39],
+ 'red' : [31, 39],
+ 'yellow' : [33, 39]
+};
+
+// Don't use 'blue' not visible on cmd.exe
+inspect.styles = {
+ 'special': 'cyan',
+ 'number': 'yellow',
+ 'boolean': 'yellow',
+ 'undefined': 'grey',
+ 'null': 'bold',
+ 'string': 'green',
+ 'date': 'magenta',
+ // "name": intentionally not styling
+ 'regexp': 'red'
+};
+
+
+function stylizeWithColor(str, styleType) {
+ var style = inspect.styles[styleType];
+
+ if (style) {
+ return '\u001b[' + inspect.colors[style][0] + 'm' + str +
+ '\u001b[' + inspect.colors[style][1] + 'm';
+ } else {
+ return str;
+ }
}
-/**
- * Load `namespaces`.
- *
- * @return {String} returns the previously persisted debug modes
- * @api private
- */
-function load() {
- var r;
- try {
- r = exports.storage.debug;
- } catch(e) {}
- return r;
+function stylizeNoColor(str, styleType) {
+ return str;
}
-/**
- * Enable namespaces listed in `localStorage.debug` initially.
- */
-exports.enable(load());
+function arrayToHash(array) {
+ var hash = {};
-/**
- * Localstorage attempts to return the localstorage.
- *
- * This is necessary because safari throws
- * when a user disables cookies/localstorage
- * and you attempt to access it.
- *
- * @return {LocalStorage}
- * @api private
- */
+ array.forEach(function(val, idx) {
+ hash[val] = true;
+ });
-function localstorage(){
- try {
- return window.localStorage;
- } catch (e) {}
+ return hash;
}
-},{"./debug":14}],14:[function(require,module,exports){
-/**
- * This is the common logic for both the Node.js and web browser
- * implementations of `debug()`.
- *
- * Expose `debug()` as the module.
- */
+function formatValue(ctx, value, recurseTimes) {
+ // Provide a hook for user-specified inspect functions.
+ // Check that value is an object with an inspect function on it
+ if (ctx.customInspect &&
+ value &&
+ isFunction(value.inspect) &&
+ // Filter out the util module, it's inspect function is special
+ value.inspect !== exports.inspect &&
+ // Also filter out any prototype objects using the circular check.
+ !(value.constructor && value.constructor.prototype === value)) {
+ var ret = value.inspect(recurseTimes, ctx);
+ if (!isString(ret)) {
+ ret = formatValue(ctx, ret, recurseTimes);
+ }
+ return ret;
+ }
-exports = module.exports = debug;
-exports.coerce = coerce;
-exports.disable = disable;
-exports.enable = enable;
-exports.enabled = enabled;
-exports.humanize = require('ms');
+ // Primitive types cannot have properties
+ var primitive = formatPrimitive(ctx, value);
+ if (primitive) {
+ return primitive;
+ }
-/**
- * The currently active debug mode names, and names to skip.
- */
+ // Look up the keys of the object.
+ var keys = Object.keys(value);
+ var visibleKeys = arrayToHash(keys);
+
+ if (ctx.showHidden) {
+ keys = Object.getOwnPropertyNames(value);
+ }
-exports.names = [];
-exports.skips = [];
+ // IE doesn't make error fields non-enumerable
+ // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
+ if (isError(value)
+ && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
+ return formatError(value);
+ }
-/**
- * Map of special "%n" handling functions, for the debug "format" argument.
- *
- * Valid key names are a single, lowercased letter, i.e. "n".
- */
+ // Some type of object without properties can be shortcutted.
+ if (keys.length === 0) {
+ if (isFunction(value)) {
+ var name = value.name ? ': ' + value.name : '';
+ return ctx.stylize('[Function' + name + ']', 'special');
+ }
+ if (isRegExp(value)) {
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
+ }
+ if (isDate(value)) {
+ return ctx.stylize(Date.prototype.toString.call(value), 'date');
+ }
+ if (isError(value)) {
+ return formatError(value);
+ }
+ }
-exports.formatters = {};
+ var base = '', array = false, braces = ['{', '}'];
-/**
- * Previously assigned color.
- */
+ // Make Array say that they are Array
+ if (isArray(value)) {
+ array = true;
+ braces = ['[', ']'];
+ }
-var prevColor = 0;
+ // Make functions say that they are functions
+ if (isFunction(value)) {
+ var n = value.name ? ': ' + value.name : '';
+ base = ' [Function' + n + ']';
+ }
-/**
- * Previous log timestamp.
- */
+ // Make RegExps say that they are RegExps
+ if (isRegExp(value)) {
+ base = ' ' + RegExp.prototype.toString.call(value);
+ }
-var prevTime;
+ // Make dates with properties first say the date
+ if (isDate(value)) {
+ base = ' ' + Date.prototype.toUTCString.call(value);
+ }
-/**
- * Select a color.
- *
- * @return {Number}
- * @api private
- */
+ // Make error with message first say the error
+ if (isError(value)) {
+ base = ' ' + formatError(value);
+ }
-function selectColor() {
- return exports.colors[prevColor++ % exports.colors.length];
-}
+ if (keys.length === 0 && (!array || value.length == 0)) {
+ return braces[0] + base + braces[1];
+ }
-/**
- * Create a debugger with the given `namespace`.
- *
- * @param {String} namespace
- * @return {Function}
- * @api public
- */
+ if (recurseTimes < 0) {
+ if (isRegExp(value)) {
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
+ } else {
+ return ctx.stylize('[Object]', 'special');
+ }
+ }
-function debug(namespace) {
+ ctx.seen.push(value);
- // define the `disabled` version
- function disabled() {
+ var output;
+ if (array) {
+ output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
+ } else {
+ output = keys.map(function(key) {
+ return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
+ });
}
- disabled.enabled = false;
- // define the `enabled` version
- function enabled() {
+ ctx.seen.pop();
- var self = enabled;
+ return reduceToSingleString(output, base, braces);
+}
- // set `diff` timestamp
- var curr = +new Date();
- var ms = curr - (prevTime || curr);
- self.diff = ms;
- self.prev = prevTime;
- self.curr = curr;
- prevTime = curr;
- // add the `color` if not set
- if (null == self.useColors) self.useColors = exports.useColors();
- if (null == self.color && self.useColors) self.color = selectColor();
+function formatPrimitive(ctx, value) {
+ if (isUndefined(value))
+ return ctx.stylize('undefined', 'undefined');
+ if (isString(value)) {
+ var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
+ .replace(/'/g, "\\'")
+ .replace(/\\"/g, '"') + '\'';
+ return ctx.stylize(simple, 'string');
+ }
+ if (isNumber(value))
+ return ctx.stylize('' + value, 'number');
+ if (isBoolean(value))
+ return ctx.stylize('' + value, 'boolean');
+ // For some reason typeof null is "object", so special case here.
+ if (isNull(value))
+ return ctx.stylize('null', 'null');
+}
+
- var args = Array.prototype.slice.call(arguments);
+function formatError(value) {
+ return '[' + Error.prototype.toString.call(value) + ']';
+}
- args[0] = exports.coerce(args[0]);
- if ('string' !== typeof args[0]) {
- // anything else let's inspect with %o
- args = ['%o'].concat(args);
+function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
+ var output = [];
+ for (var i = 0, l = value.length; i < l; ++i) {
+ if (hasOwnProperty(value, String(i))) {
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
+ String(i), true));
+ } else {
+ output.push('');
+ }
+ }
+ keys.forEach(function(key) {
+ if (!key.match(/^\d+$/)) {
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
+ key, true));
}
+ });
+ return output;
+}
- // apply any `formatters` transformations
- var index = 0;
- args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
- // if we encounter an escaped % then don't increase the array index
- if (match === '%%') return match;
- index++;
- var formatter = exports.formatters[format];
- if ('function' === typeof formatter) {
- var val = args[index];
- match = formatter.call(self, val);
- // now we need to remove `args[index]` since it's inlined in the `format`
- args.splice(index, 1);
- index--;
+function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
+ var name, str, desc;
+ desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
+ if (desc.get) {
+ if (desc.set) {
+ str = ctx.stylize('[Getter/Setter]', 'special');
+ } else {
+ str = ctx.stylize('[Getter]', 'special');
+ }
+ } else {
+ if (desc.set) {
+ str = ctx.stylize('[Setter]', 'special');
+ }
+ }
+ if (!hasOwnProperty(visibleKeys, key)) {
+ name = '[' + key + ']';
+ }
+ if (!str) {
+ if (ctx.seen.indexOf(desc.value) < 0) {
+ if (isNull(recurseTimes)) {
+ str = formatValue(ctx, desc.value, null);
+ } else {
+ str = formatValue(ctx, desc.value, recurseTimes - 1);
}
- return match;
- });
-
- if ('function' === typeof exports.formatArgs) {
- args = exports.formatArgs.apply(self, args);
+ if (str.indexOf('\n') > -1) {
+ if (array) {
+ str = str.split('\n').map(function(line) {
+ return ' ' + line;
+ }).join('\n').substr(2);
+ } else {
+ str = '\n' + str.split('\n').map(function(line) {
+ return ' ' + line;
+ }).join('\n');
+ }
+ }
+ } else {
+ str = ctx.stylize('[Circular]', 'special');
+ }
+ }
+ if (isUndefined(name)) {
+ if (array && key.match(/^\d+$/)) {
+ return str;
+ }
+ name = JSON.stringify('' + key);
+ if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
+ name = name.substr(1, name.length - 2);
+ name = ctx.stylize(name, 'name');
+ } else {
+ name = name.replace(/'/g, "\\'")
+ .replace(/\\"/g, '"')
+ .replace(/(^"|"$)/g, "'");
+ name = ctx.stylize(name, 'string');
}
- var logFn = enabled.log || exports.log || console.log.bind(console);
- logFn.apply(self, args);
}
- enabled.enabled = true;
-
- var fn = exports.enabled(namespace) ? enabled : disabled;
-
- fn.namespace = namespace;
- return fn;
+ return name + ': ' + str;
}
-/**
- * Enables a debug mode by namespaces. This can include modes
- * separated by a colon and wildcards.
- *
- * @param {String} namespaces
- * @api public
- */
-
-function enable(namespaces) {
- exports.save(namespaces);
- var split = (namespaces || '').split(/[\s,]+/);
- var len = split.length;
+function reduceToSingleString(output, base, braces) {
+ var numLinesEst = 0;
+ var length = output.reduce(function(prev, cur) {
+ numLinesEst++;
+ if (cur.indexOf('\n') >= 0) numLinesEst++;
+ return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
+ }, 0);
- for (var i = 0; i < len; i++) {
- if (!split[i]) continue; // ignore empty strings
- namespaces = split[i].replace(/\*/g, '.*?');
- if (namespaces[0] === '-') {
- exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
- } else {
- exports.names.push(new RegExp('^' + namespaces + '$'));
- }
+ if (length > 60) {
+ return braces[0] +
+ (base === '' ? '' : base + '\n ') +
+ ' ' +
+ output.join(',\n ') +
+ ' ' +
+ braces[1];
}
+
+ return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
}
-/**
- * Disable debug output.
- *
- * @api public
- */
-function disable() {
- exports.enable('');
+// NOTE: These type checking functions intentionally don't use `instanceof`
+// because it is fragile and can be easily faked with `Object.create()`.
+function isArray(ar) {
+ return Array.isArray(ar);
+}
+exports.isArray = isArray;
+
+function isBoolean(arg) {
+ return typeof arg === 'boolean';
}
+exports.isBoolean = isBoolean;
-/**
- * Returns true if the given mode name is enabled, false otherwise.
- *
- * @param {String} name
- * @return {Boolean}
- * @api public
- */
+function isNull(arg) {
+ return arg === null;
+}
+exports.isNull = isNull;
-function enabled(name) {
- var i, len;
- for (i = 0, len = exports.skips.length; i < len; i++) {
- if (exports.skips[i].test(name)) {
- return false;
- }
- }
- for (i = 0, len = exports.names.length; i < len; i++) {
- if (exports.names[i].test(name)) {
- return true;
- }
- }
- return false;
+function isNullOrUndefined(arg) {
+ return arg == null;
}
+exports.isNullOrUndefined = isNullOrUndefined;
-/**
- * Coerce `val`.
- *
- * @param {Mixed} val
- * @return {Mixed}
- * @api private
- */
+function isNumber(arg) {
+ return typeof arg === 'number';
+}
+exports.isNumber = isNumber;
-function coerce(val) {
- if (val instanceof Error) return val.stack || val.message;
- return val;
+function isString(arg) {
+ return typeof arg === 'string';
}
+exports.isString = isString;
-},{"ms":15}],15:[function(require,module,exports){
-/**
- * Helpers.
- */
+function isSymbol(arg) {
+ return typeof arg === 'symbol';
+}
+exports.isSymbol = isSymbol;
-var s = 1000;
-var m = s * 60;
-var h = m * 60;
-var d = h * 24;
-var y = d * 365.25;
+function isUndefined(arg) {
+ return arg === void 0;
+}
+exports.isUndefined = isUndefined;
-/**
- * Parse or format the given `val`.
- *
- * Options:
- *
- * - `long` verbose formatting [false]
- *
- * @param {String|Number} val
- * @param {Object} options
- * @return {String|Number}
- * @api public
- */
+function isRegExp(re) {
+ return isObject(re) && objectToString(re) === '[object RegExp]';
+}
+exports.isRegExp = isRegExp;
-module.exports = function(val, options){
- options = options || {};
- if ('string' == typeof val) return parse(val);
- return options.long
- ? long(val)
- : short(val);
-};
+function isObject(arg) {
+ return typeof arg === 'object' && arg !== null;
+}
+exports.isObject = isObject;
-/**
- * Parse the given `str` and return milliseconds.
- *
- * @param {String} str
- * @return {Number}
- * @api private
- */
+function isDate(d) {
+ return isObject(d) && objectToString(d) === '[object Date]';
+}
+exports.isDate = isDate;
-function parse(str) {
- str = '' + str;
- if (str.length > 10000) return;
- var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);
- if (!match) return;
- var n = parseFloat(match[1]);
- var type = (match[2] || 'ms').toLowerCase();
- switch (type) {
- case 'years':
- case 'year':
- case 'yrs':
- case 'yr':
- case 'y':
- return n * y;
- case 'days':
- case 'day':
- case 'd':
- return n * d;
- case 'hours':
- case 'hour':
- case 'hrs':
- case 'hr':
- case 'h':
- return n * h;
- case 'minutes':
- case 'minute':
- case 'mins':
- case 'min':
- case 'm':
- return n * m;
- case 'seconds':
- case 'second':
- case 'secs':
- case 'sec':
- case 's':
- return n * s;
- case 'milliseconds':
- case 'millisecond':
- case 'msecs':
- case 'msec':
- case 'ms':
- return n;
- }
+function isError(e) {
+ return isObject(e) &&
+ (objectToString(e) === '[object Error]' || e instanceof Error);
}
+exports.isError = isError;
-/**
- * Short format for `ms`.
- *
- * @param {Number} ms
- * @return {String}
- * @api private
- */
+function isFunction(arg) {
+ return typeof arg === 'function';
+}
+exports.isFunction = isFunction;
-function short(ms) {
- if (ms >= d) return Math.round(ms / d) + 'd';
- if (ms >= h) return Math.round(ms / h) + 'h';
- if (ms >= m) return Math.round(ms / m) + 'm';
- if (ms >= s) return Math.round(ms / s) + 's';
- return ms + 'ms';
+function isPrimitive(arg) {
+ return arg === null ||
+ typeof arg === 'boolean' ||
+ typeof arg === 'number' ||
+ typeof arg === 'string' ||
+ typeof arg === 'symbol' || // ES6 symbol
+ typeof arg === 'undefined';
}
+exports.isPrimitive = isPrimitive;
-/**
- * Long format for `ms`.
- *
- * @param {Number} ms
- * @return {String}
- * @api private
- */
+exports.isBuffer = require('./support/isBuffer');
-function long(ms) {
- return plural(ms, d, 'day')
- || plural(ms, h, 'hour')
- || plural(ms, m, 'minute')
- || plural(ms, s, 'second')
- || ms + ' ms';
+function objectToString(o) {
+ return Object.prototype.toString.call(o);
}
-/**
- * Pluralization helper.
- */
-function plural(ms, n, name) {
- if (ms < n) return;
- if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;
- return Math.ceil(ms / n) + ' ' + name + 's';
+function pad(n) {
+ return n < 10 ? '0' + n.toString(10) : n.toString(10);
}
-},{}],16:[function(require,module,exports){
-var fmt = require('util').format;
-
-exports.tagOpen = function(node){
- return fmt('<%s%s>', node.name, renderAttributes(node));
-};
-exports.declaration = function(node){
- return fmt('', renderAttributes(node));
-};
+var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
+ 'Oct', 'Nov', 'Dec'];
-function renderAttributes(node){
- var attr = exports.attributes(node);
- return attr.length ? ' ' + attr : '';
-};
+// 26 Feb 16:19:34
+function timestamp() {
+ var d = new Date();
+ var time = [pad(d.getHours()),
+ pad(d.getMinutes()),
+ pad(d.getSeconds())].join(':');
+ return [d.getDate(), months[d.getMonth()], time].join(' ');
+}
-exports.attributes = function(node){
- if (!node.attributes) return '';
- var keys = Object.keys(node.attributes);
- if (!keys.length) return '';
- return keys.map(function(key){
- return fmt('%s="%s"', key, node.attributes[key]);
- }).join(' ');
-};
-exports.tagClose = function(node){
- return fmt('%s>', node.name);
+// log is just a thin wrapper to console.log that prepends a timestamp
+exports.log = function() {
+ console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
};
-exports.leaf = function(node){
- return exports.tagOpen(node) + node.content + exports.tagClose(node);
-};
-exports.node = function(node){
- if (node.root) return exports.document(node);
- if (!node.children || !node.children.length) return exports.leaf(node);
+/**
+ * Inherit the prototype methods from one constructor into another.
+ *
+ * The Function.prototype.inherits from lang.js rewritten as a standalone
+ * function (not on Function.prototype). NOTE: If this file is to be loaded
+ * during bootstrapping this function needs to be rewritten using some native
+ * functions as prototype setup using normal JavaScript does not work as
+ * expected during bootstrapping (see mirror.js in r114903).
+ *
+ * @param {function} ctor Constructor function which needs to inherit the
+ * prototype.
+ * @param {function} superCtor Constructor function to inherit prototype from.
+ */
+exports.inherits = require('inherits');
- return exports.tagOpen(node) + '\n'
- + node.children.map(function(child){
- return exports.node(child).replace(/^/gm, '\t');
- }).join('\n') + '\n'
- + exports.tagClose(node);
-};
+exports._extend = function(origin, add) {
+ // Don't do anything if add isn't an object
+ if (!add || !isObject(add)) return origin;
-exports.document = function(node){
- return exports.declaration(node.declaration) + '\n'
- + exports.node(node.root);
+ var keys = Object.keys(add);
+ var i = keys.length;
+ while (i--) {
+ origin[keys[i]] = add[keys[i]];
+ }
+ return origin;
};
+function hasOwnProperty(obj, prop) {
+ return Object.prototype.hasOwnProperty.call(obj, prop);
+}
-},{"util":6}]},{},[7])(7)
+}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+},{"./support/isBuffer":15,"_process":14,"inherits":13}]},{},[1])(1)
});
\ No newline at end of file
diff --git a/inst/htmlwidgets/xmltreeview.js b/inst/htmlwidgets/xmltreeview.js
index 5e01ebc..9de8626 100644
--- a/inst/htmlwidgets/xmltreeview.js
+++ b/inst/htmlwidgets/xmltreeview.js
@@ -19,10 +19,12 @@ HTMLWidgets.widget({
//add CSS overflow scroll to el
if (param.scroll) { el.style.overflow = "scroll" }
- var view = new Viewer(param.xmlDoc);
- view.appendTo(el);
+ LoadXMLString(el, param.xmlDoc);
- this.view = view;
+// var view = new Viewer(param.xmlDoc);
+// view.appendTo(el);
+//
+// this.view = view;
},
@@ -32,4 +34,4 @@ HTMLWidgets.widget({
}
-});
\ No newline at end of file
+});
diff --git a/inst/htmlwidgets/xmltreeview.yaml b/inst/htmlwidgets/xmltreeview.yaml
index 59b739b..c038ab3 100644
--- a/inst/htmlwidgets/xmltreeview.yaml
+++ b/inst/htmlwidgets/xmltreeview.yaml
@@ -2,5 +2,5 @@
- name: xml-viewer
version: 1.3.7
src: htmlwidgets/lib/xml-viewer
- script: xml-viewer.js
- stylesheet: treewdgt.css
+ script: XMLDisplay.js
+ stylesheet: XMLDisplay.css