4 lines
79 KiB
JavaScript
4 lines
79 KiB
JavaScript
/*! filer 0.0.27 2014-09-02 */
|
|
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.Filer=t()}}(function(){var t;return function n(t,e,r){function i(a,u){if(!e[a]){if(!t[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var c=e[a]={exports:{}};t[a][0].call(c.exports,function(n){var e=t[a][1][n];return i(e?e:n)},c,c.exports,n,t,e,r)}return e[a].exports}for(var o="function"==typeof require&&require,a=0;r.length>a;a++)i(r[a]);return i}({1:[function(n,e){(function(n){(function(){function r(t){var n=!1;return function(){if(n)throw Error("Callback was already called.");n=!0,t.apply(i,arguments)}}var i,o,a={};i=this,null!=i&&(o=i.async),a.noConflict=function(){return i.async=o,a};var u=function(t,n){if(t.forEach)return t.forEach(n);for(var e=0;t.length>e;e+=1)n(t[e],e,t)},s=function(t,n){if(t.map)return t.map(n);var e=[];return u(t,function(t,r,i){e.push(n(t,r,i))}),e},c=function(t,n,e){return t.reduce?t.reduce(n,e):(u(t,function(t,r,i){e=n(e,t,r,i)}),e)},f=function(t){if(Object.keys)return Object.keys(t);var n=[];for(var e in t)t.hasOwnProperty(e)&&n.push(e);return n};void 0!==n&&n.nextTick?(a.nextTick=n.nextTick,a.setImmediate="undefined"!=typeof setImmediate?function(t){setImmediate(t)}:a.nextTick):"function"==typeof setImmediate?(a.nextTick=function(t){setImmediate(t)},a.setImmediate=a.nextTick):(a.nextTick=function(t){setTimeout(t,0)},a.setImmediate=a.nextTick),a.each=function(t,n,e){if(e=e||function(){},!t.length)return e();var i=0;u(t,function(o){n(o,r(function(n){n?(e(n),e=function(){}):(i+=1,i>=t.length&&e(null))}))})},a.forEach=a.each,a.eachSeries=function(t,n,e){if(e=e||function(){},!t.length)return e();var r=0,i=function(){n(t[r],function(n){n?(e(n),e=function(){}):(r+=1,r>=t.length?e(null):i())})};i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(t,n,e,r){var i=l(n);i.apply(null,[t,e,r])},a.forEachLimit=a.eachLimit;var l=function(t){return function(n,e,r){if(r=r||function(){},!n.length||0>=t)return r();var i=0,o=0,a=0;(function u(){if(i>=n.length)return r();for(;t>a&&n.length>o;)o+=1,a+=1,e(n[o-1],function(t){t?(r(t),r=function(){}):(i+=1,a-=1,i>=n.length?r():u())})})()}},d=function(t){return function(){var n=Array.prototype.slice.call(arguments);return t.apply(null,[a.each].concat(n))}},p=function(t,n){return function(){var e=Array.prototype.slice.call(arguments);return n.apply(null,[l(t)].concat(e))}},h=function(t){return function(){var n=Array.prototype.slice.call(arguments);return t.apply(null,[a.eachSeries].concat(n))}},g=function(t,n,e,r){var i=[];n=s(n,function(t,n){return{index:n,value:t}}),t(n,function(t,n){e(t.value,function(e,r){i[t.index]=r,n(e)})},function(t){r(t,i)})};a.map=d(g),a.mapSeries=h(g),a.mapLimit=function(t,n,e,r){return v(n)(t,e,r)};var v=function(t){return p(t,g)};a.reduce=function(t,n,e,r){a.eachSeries(t,function(t,r){e(n,t,function(t,e){n=e,r(t)})},function(t){r(t,n)})},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(t,n,e,r){var i=s(t,function(t){return t}).reverse();a.reduce(i,n,e,r)},a.foldr=a.reduceRight;var m=function(t,n,e,r){var i=[];n=s(n,function(t,n){return{index:n,value:t}}),t(n,function(t,n){e(t.value,function(e){e&&i.push(t),n()})},function(){r(s(i.sort(function(t,n){return t.index-n.index}),function(t){return t.value}))})};a.filter=d(m),a.filterSeries=h(m),a.select=a.filter,a.selectSeries=a.filterSeries;var y=function(t,n,e,r){var i=[];n=s(n,function(t,n){return{index:n,value:t}}),t(n,function(t,n){e(t.value,function(e){e||i.push(t),n()})},function(){r(s(i.sort(function(t,n){return t.index-n.index}),function(t){return t.value}))})};a.reject=d(y),a.rejectSeries=h(y);var E=function(t,n,e,r){t(n,function(t,n){e(t,function(e){e?(r(t),r=function(){}):n()})},function(){r()})};a.detect=d(E),a.detectSeries=h(E),a.some=function(t,n,e){a.each(t,function(t,r){n(t,function(t){t&&(e(!0),e=function(){}),r()})},function(){e(!1)})},a.any=a.some,a.every=function(t,n,e){a.each(t,function(t,r){n(t,function(t){t||(e(!1),e=function(){}),r()})},function(){e(!0)})},a.all=a.every,a.sortBy=function(t,n,e){a.map(t,function(t,e){n(t,function(n,r){n?e(n):e(null,{value:t,criteria:r})})},function(t,n){if(t)return e(t);var r=function(t,n){var e=t.criteria,r=n.criteria;return r>e?-1:e>r?1:0};e(null,s(n.sort(r),function(t){return t.value}))})},a.auto=function(t,n){n=n||function(){};var e=f(t);if(!e.length)return n(null);var r={},i=[],o=function(t){i.unshift(t)},s=function(t){for(var n=0;i.length>n;n+=1)if(i[n]===t)return i.splice(n,1),void 0},l=function(){u(i.slice(0),function(t){t()})};o(function(){f(r).length===e.length&&(n(null,r),n=function(){})}),u(e,function(e){var i=t[e]instanceof Function?[t[e]]:t[e],d=function(t){var i=Array.prototype.slice.call(arguments,1);if(1>=i.length&&(i=i[0]),t){var o={};u(f(r),function(t){o[t]=r[t]}),o[e]=i,n(t,o),n=function(){}}else r[e]=i,a.setImmediate(l)},p=i.slice(0,Math.abs(i.length-1))||[],h=function(){return c(p,function(t,n){return t&&r.hasOwnProperty(n)},!0)&&!r.hasOwnProperty(e)};if(h())i[i.length-1](d,r);else{var g=function(){h()&&(s(g),i[i.length-1](d,r))};o(g)}})},a.waterfall=function(t,n){if(n=n||function(){},t.constructor!==Array){var e=Error("First argument to waterfall must be an array of functions");return n(e)}if(!t.length)return n();var r=function(t){return function(e){if(e)n.apply(null,arguments),n=function(){};else{var i=Array.prototype.slice.call(arguments,1),o=t.next();o?i.push(r(o)):i.push(n),a.setImmediate(function(){t.apply(null,i)})}}};r(a.iterator(t))()};var b=function(t,n,e){if(e=e||function(){},n.constructor===Array)t.map(n,function(t,n){t&&t(function(t){var e=Array.prototype.slice.call(arguments,1);1>=e.length&&(e=e[0]),n.call(null,t,e)})},e);else{var r={};t.each(f(n),function(t,e){n[t](function(n){var i=Array.prototype.slice.call(arguments,1);1>=i.length&&(i=i[0]),r[t]=i,e(n)})},function(t){e(t,r)})}};a.parallel=function(t,n){b({map:a.map,each:a.each},t,n)},a.parallelLimit=function(t,n,e){b({map:v(n),each:l(n)},t,e)},a.series=function(t,n){if(n=n||function(){},t.constructor===Array)a.mapSeries(t,function(t,n){t&&t(function(t){var e=Array.prototype.slice.call(arguments,1);1>=e.length&&(e=e[0]),n.call(null,t,e)})},n);else{var e={};a.eachSeries(f(t),function(n,r){t[n](function(t){var i=Array.prototype.slice.call(arguments,1);1>=i.length&&(i=i[0]),e[n]=i,r(t)})},function(t){n(t,e)})}},a.iterator=function(t){var n=function(e){var r=function(){return t.length&&t[e].apply(null,arguments),r.next()};return r.next=function(){return t.length-1>e?n(e+1):null},r};return n(0)},a.apply=function(t){var n=Array.prototype.slice.call(arguments,1);return function(){return t.apply(null,n.concat(Array.prototype.slice.call(arguments)))}};var w=function(t,n,e,r){var i=[];t(n,function(t,n){e(t,function(t,e){i=i.concat(e||[]),n(t)})},function(t){r(t,i)})};a.concat=d(w),a.concatSeries=h(w),a.whilst=function(t,n,e){t()?n(function(r){return r?e(r):(a.whilst(t,n,e),void 0)}):e()},a.doWhilst=function(t,n,e){t(function(r){return r?e(r):(n()?a.doWhilst(t,n,e):e(),void 0)})},a.until=function(t,n,e){t()?e():n(function(r){return r?e(r):(a.until(t,n,e),void 0)})},a.doUntil=function(t,n,e){t(function(r){return r?e(r):(n()?e():a.doUntil(t,n,e),void 0)})},a.queue=function(t,n){function e(t,e,r,i){e.constructor!==Array&&(e=[e]),u(e,function(e){var o={data:e,callback:"function"==typeof i?i:null};r?t.tasks.unshift(o):t.tasks.push(o),t.saturated&&t.tasks.length===n&&t.saturated(),a.setImmediate(t.process)})}void 0===n&&(n=1);var i=0,o={tasks:[],concurrency:n,saturated:null,empty:null,drain:null,push:function(t,n){e(o,t,!1,n)},unshift:function(t,n){e(o,t,!0,n)},process:function(){if(o.concurrency>i&&o.tasks.length){var n=o.tasks.shift();o.empty&&0===o.tasks.length&&o.empty(),i+=1;var e=function(){i-=1,n.callback&&n.callback.apply(n,arguments),o.drain&&0===o.tasks.length+i&&o.drain(),o.process()},a=r(e);t(n.data,a)}},length:function(){return o.tasks.length},running:function(){return i}};return o},a.cargo=function(t,n){var e=!1,r=[],i={tasks:r,payload:n,saturated:null,empty:null,drain:null,push:function(t,e){t.constructor!==Array&&(t=[t]),u(t,function(t){r.push({data:t,callback:"function"==typeof e?e:null}),i.saturated&&r.length===n&&i.saturated()}),a.setImmediate(i.process)},process:function o(){if(!e){if(0===r.length)return i.drain&&i.drain(),void 0;var a="number"==typeof n?r.splice(0,n):r.splice(0),c=s(a,function(t){return t.data});i.empty&&i.empty(),e=!0,t(c,function(){e=!1;var t=arguments;u(a,function(n){n.callback&&n.callback.apply(null,t)}),o()})}},length:function(){return r.length},running:function(){return e}};return i};var I=function(t){return function(n){var e=Array.prototype.slice.call(arguments,1);n.apply(null,e.concat([function(n){var e=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(n?console.error&&console.error(n):console[t]&&u(e,function(n){console[t](n)}))}]))}};a.log=I("log"),a.dir=I("dir"),a.memoize=function(t,n){var e={},r={};n=n||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),o=i.pop(),a=n.apply(null,i);a in e?o.apply(null,e[a]):a in r?r[a].push(o):(r[a]=[o],t.apply(null,i.concat([function(){e[a]=arguments;var t=r[a];delete r[a];for(var n=0,i=t.length;i>n;n++)t[n].apply(null,arguments)}])))};return i.memo=e,i.unmemoized=t,i},a.unmemoize=function(t){return function(){return(t.unmemoized||t).apply(null,arguments)}},a.times=function(t,n,e){for(var r=[],i=0;t>i;i++)r.push(i);return a.map(r,n,e)},a.timesSeries=function(t,n,e){for(var r=[],i=0;t>i;i++)r.push(i);return a.mapSeries(r,n,e)},a.compose=function(){var t=Array.prototype.reverse.call(arguments);return function(){var n=this,e=Array.prototype.slice.call(arguments),r=e.pop();a.reduce(t,e,function(t,e,r){e.apply(n,t.concat([function(){var t=arguments[0],n=Array.prototype.slice.call(arguments,1);r(t,n)}]))},function(t,e){r.apply(n,[t].concat(e))})}};var O=function(t,n){var e=function(){var e=this,r=Array.prototype.slice.call(arguments),i=r.pop();return t(n,function(t,n){t.apply(e,r.concat([n]))},i)};if(arguments.length>2){var r=Array.prototype.slice.call(arguments,2);return e.apply(this,r)}return e};a.applyEach=d(O),a.applyEachSeries=h(O),a.forever=function(t,n){function e(r){if(r){if(n)return n(r);throw r}t(e)}e()},t!==void 0&&t.amd?t([],function(){return a}):e!==void 0&&e.exports?e.exports=a:i.async=a})()}).call(this,n("JkpR2F"))},{JkpR2F:10}],2:[function(t,n){function e(t,n){for(var e=n.length-1;e>=0;e--)n[e]===t&&n.splice(e,1);return n}var r=function(){};r.createInterface=function(t){var n={};return n.on=function(n,e){this[t]===void 0&&(this[t]={}),this[t].hasOwnProperty(n)||(this[t][n]=[]),this[t][n].push(e)},n.off=function(n,r){void 0!==this[t]&&this[t].hasOwnProperty(n)&&e(r,this[t][n])},n.trigger=function(n){if(this[t]!==void 0&&this[t].hasOwnProperty(n))for(var e=Array.prototype.slice.call(arguments,1),r=0;this[t][n].length>r;r++)this[t][n][r].apply(this[t][n][r],e)},n.removeAllListeners=function(n){if(void 0!==this[t]){var e=this;e[t][n].forEach(function(t){e.off(n,t)})}},n};var i=r.createInterface("_handlers");r.prototype._on=i.on,r.prototype._off=i.off,r.prototype._trigger=i.trigger;var o=r.createInterface("handlers");r.prototype.on=function(){o.on.apply(this,arguments),Array.prototype.unshift.call(arguments,"on"),this._trigger.apply(this,arguments)},r.prototype.off=o.off,r.prototype.trigger=o.trigger,r.prototype.removeAllListeners=o.removeAllListeners,n.exports=r},{}],3:[function(t,n){(function(e){function r(t,n){var e=0;return function(){var r=Date.now();r-e>t&&(e=r,n.apply(this,arguments))}}function i(t,n){if(void 0!==t&&t||(t={}),"object"==typeof n)for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e]);return t}function o(){var t=this,n=Date.now();this.origin=u(),this.lastMessage=n,this.receivedIDs={},this.previousValues={};var r=function(){t._onStorageEvent.apply(t,arguments)};"undefined"!=typeof document&&(document.attachEvent?document.attachEvent("onstorage",r):e.addEventListener("storage",r,!1))}var a=t("./eventemitter.js"),u=t("../src/shared.js").guid,s=function(t){return t===void 0||t.localStorage===void 0?{getItem:function(){},setItem:function(){},removeItem:function(){}}:t.localStorage}(e);o.prototype._transaction=function(t){function n(){if(!a){var f=Date.now(),d=0|s.getItem(l);if(d&&r>f-d)return u||(o._on("storage",n),u=!0),c=setTimeout(n,i),void 0;a=!0,s.setItem(l,f),t(),e()}}function e(){u&&o._off("storage",n),c&&clearTimeout(c),s.removeItem(l)}var r=1e3,i=20,o=this,a=!1,u=!1,c=null;n()},o.prototype._cleanup_emit=r(100,function(){var t=this;t._transaction(function(){var t,n=Date.now(),e=n-d,r=0;try{t=JSON.parse(s.getItem(c)||"[]")}catch(i){t=[]}for(var o=t.length-1;o>=0;o--)e>t[o].timestamp&&(t.splice(o,1),r++);r>0&&s.setItem(c,JSON.stringify(t))})}),o.prototype._cleanup_once=r(100,function(){var t=this;t._transaction(function(){var n,e;Date.now();var r=0;try{e=JSON.parse(s.getItem(f)||"{}")}catch(i){e={}}for(n in e)t._once_expired(n,e)&&(delete e[n],r++);r>0&&s.setItem(f,JSON.stringify(e))})}),o.prototype._once_expired=function(t,n){if(!n)return!0;if(!n.hasOwnProperty(t))return!0;if("object"!=typeof n[t])return!0;var e=n[t].ttl||p,r=Date.now(),i=n[t].timestamp;return r-e>i},o.prototype._localStorageChanged=function(t,n){if(t&&t.key)return t.key===n;var e=s.getItem(n);return e===this.previousValues[n]?!1:(this.previousValues[n]=e,!0)},o.prototype._onStorageEvent=function(t){t=t||e.event;var n=this;this._localStorageChanged(t,c)&&this._transaction(function(){var t,e=Date.now(),r=s.getItem(c);try{t=JSON.parse(r||"[]")}catch(i){t=[]}for(var o=0;t.length>o;o++)if(t[o].origin!==n.origin&&!(t[o].timestamp<n.lastMessage)){if(t[o].id){if(n.receivedIDs.hasOwnProperty(t[o].id))continue;n.receivedIDs[t[o].id]=!0}n.trigger(t[o].name,t[o].payload)}n.lastMessage=e}),this._trigger("storage",t)},o.prototype._emit=function(t,n,e){if(e="string"==typeof e||"number"==typeof e?e+"":null,e&&e.length){if(this.receivedIDs.hasOwnProperty(e))return;this.receivedIDs[e]=!0}var r={id:e,name:t,origin:this.origin,timestamp:Date.now(),payload:n},i=this;this._transaction(function(){var e=s.getItem(c)||"[]",o="[]"===e?"":",";e=[e.substring(0,e.length-1),o,JSON.stringify(r),"]"].join(""),s.setItem(c,e),i.trigger(t,n),setTimeout(function(){i._cleanup_emit()},50)})},o.prototype.emit=function(t,n){this._emit.apply(this,arguments),this._trigger("emit",t,n)},o.prototype.once=function(t,n,e){if(o.supported){var r=this;this._transaction(function(){var i;try{i=JSON.parse(s.getItem(f)||"{}")}catch(o){i={}}r._once_expired(t,i)&&(i[t]={},i[t].timestamp=Date.now(),"number"==typeof e&&(i[t].ttl=1e3*e),s.setItem(f,JSON.stringify(i)),n(),setTimeout(function(){r._cleanup_once()},50))})}},i(o.prototype,a.prototype),o.supported=s!==void 0;var c="intercom",f="intercom_once",l="intercom_lock",d=5e4,p=36e5;o.destroy=function(){s.removeItem(l),s.removeItem(c),s.removeItem(f)},o.getInstance=function(){var t;return function(){return t||(t=new o),t}}(),n.exports=o}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../src/shared.js":27,"./eventemitter.js":2}],4:[function(t,n){function e(t,n){return g.call(t,n)}function r(t){return null==t?0:t.length===+t.length?t.length:y(t).length}function i(t){return t}function o(t,n,e){var r,i;if(null!=t)if(l&&t.forEach===l)t.forEach(n,e);else if(t.length===+t.length){for(r=0,i=t.length;i>r;r++)if(n.call(e,t[r],r,t)===m)return}else{var o=o(t);for(r=0,i=o.length;i>r;r++)if(n.call(e,t[o[r]],o[r],t)===m)return}}function a(t,n,e){n||(n=i);var r=!1;return null==t?r:p&&t.some===p?t.some(n,e):(o(t,function(t,i,o){return r||(r=n.call(e,t,i,o))?m:void 0}),!!r)}function u(t,n){return null==t?!1:d&&t.indexOf===d?-1!=t.indexOf(n):a(t,function(t){return t===n})}function s(t){this.value=t}function c(t){return t&&"object"==typeof t&&!Array.isArray(t)&&g.call(t,"__wrapped__")?t:new s(t)}var f=Array.prototype,l=f.forEach,d=f.indexOf,p=f.some,h=Object.prototype,g=h.hasOwnProperty,v=Object.keys,m={},y=v||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var n=[];for(var r in t)e(t,r)&&n.push(r);return n};s.prototype.has=function(t){return e(this.value,t)},s.prototype.contains=function(t){return u(this.value,t)},s.prototype.size=function(){return r(this.value)},n.exports=c},{}],5:[function(t,n,e){(function(t){"use strict";e.encode=function(n){var e,r=new Uint8Array(n),i=r.length,o="";for(e=0;i>e;e+=3)o+=t[r[e]>>2],o+=t[(3&r[e])<<4|r[e+1]>>4],o+=t[(15&r[e+1])<<2|r[e+2]>>6],o+=t[63&r[e+2]];return 2===i%3?o=o.substring(0,o.length-1)+"=":1===i%3&&(o=o.substring(0,o.length-2)+"=="),o},e.decode=function(n){var e,r,i,o,a,u=.75*n.length,s=n.length,c=0;"="===n[n.length-1]&&(u--,"="===n[n.length-2]&&u--);var f=new ArrayBuffer(u),l=new Uint8Array(f);for(e=0;s>e;e+=4)r=t.indexOf(n[e]),i=t.indexOf(n[e+1]),o=t.indexOf(n[e+2]),a=t.indexOf(n[e+3]),l[c++]=r<<2|i>>4,l[c++]=(15&i)<<4|o>>2,l[c++]=(3&o)<<6|63&a;return f}})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],6:[function(t,n){(function(t){function e(t,n){if("function"!=typeof n)throw Error("Bad callback given: "+n);if(!t)throw Error("No options given");var a=t.onResponse;if(t="string"==typeof t?{uri:t}:JSON.parse(JSON.stringify(t)),t.onResponse=a,t.verbose&&(e.log=o()),t.url&&(t.uri=t.url,delete t.url),!t.uri&&""!==t.uri)throw Error("options.uri is a required argument");if("string"!=typeof t.uri)throw Error("options.uri must be a string");for(var u=["proxy","_redirectsFollowed","maxRedirects","followRedirect"],c=0;u.length>c;c++)if(t[u[c]])throw Error("options."+u[c]+" is not supported");if(t.callback=n,t.method=t.method||"GET",t.headers=t.headers||{},t.body=t.body||null,t.timeout=t.timeout||e.DEFAULT_TIMEOUT,t.headers.host)throw Error("Options.headers.host is not supported");t.json&&(t.headers.accept=t.headers.accept||"application/json","GET"!==t.method&&(t.headers["content-type"]="application/json"),"boolean"!=typeof t.json?t.body=JSON.stringify(t.json):"string"!=typeof t.body&&(t.body=JSON.stringify(t.body)));var f=function(t){var n=[];for(var e in t)t.hasOwnProperty(e)&&n.push(encodeURIComponent(e)+"="+encodeURIComponent(t[e]));return n.join("&")};if(t.qs){var l="string"==typeof t.qs?t.qs:f(t.qs);t.uri=-1!==t.uri.indexOf("?")?t.uri+"&"+l:t.uri+"?"+l}var d=function(t){var n={};n.boundry="-------------------------------"+Math.floor(1e9*Math.random());var e=[];for(var r in t)t.hasOwnProperty(r)&&e.push("--"+n.boundry+"\n"+'Content-Disposition: form-data; name="'+r+'"'+"\n"+"\n"+t[r]+"\n");return e.push("--"+n.boundry+"--"),n.body=e.join(""),n.length=n.body.length,n.type="multipart/form-data; boundary="+n.boundry,n};if(t.form){if("string"==typeof t.form)throw"form name unsupported";if("POST"===t.method){var p=(t.encoding||"application/x-www-form-urlencoded").toLowerCase();switch(t.headers["content-type"]=p,p){case"application/x-www-form-urlencoded":t.body=f(t.form).replace(/%20/g,"+");break;case"multipart/form-data":var h=d(t.form);t.body=h.body,t.headers["content-type"]=h.type;break;default:throw Error("unsupported encoding:"+p)}}}return t.onResponse=t.onResponse||i,t.onResponse===!0&&(t.onResponse=n,t.callback=i),!t.headers.authorization&&t.auth&&(t.headers.authorization="Basic "+s(t.auth.username+":"+t.auth.password)),r(t)}function r(n){function r(){d=!0;var t=Error("ETIMEDOUT");return t.code="ETIMEDOUT",t.duration=n.timeout,e.log.error("Timeout",{id:f._id,milliseconds:n.timeout}),n.callback(t,f)}function i(){if(d)return e.log.debug("Ignoring timed out state change",{state:f.readyState,id:f.id});if(e.log.debug("State change",{state:f.readyState,id:f.id,timed_out:d}),f.readyState===c.OPENED){e.log.debug("Request started",{id:f.id});for(var t in n.headers)f.setRequestHeader(t,n.headers[t])}else f.readyState===c.HEADERS_RECEIVED?o():f.readyState===c.LOADING?(o(),a()):f.readyState===c.DONE&&(o(),a(),s())}function o(){if(!v.response){if(v.response=!0,e.log.debug("Got response",{id:f.id,status:f.status}),clearTimeout(f.timeoutTimer),f.statusCode=f.status,p&&0==f.statusCode){var t=Error("CORS request rejected: "+n.uri);return t.cors="rejected",v.loading=!0,v.end=!0,n.callback(t,f)}n.onResponse(null,f)}}function a(){v.loading||(v.loading=!0,e.log.debug("Response body loading",{id:f.id}))}function s(){if(!v.end){if(v.end=!0,e.log.debug("Request done",{id:f.id}),null===n.encoding)f.body=new t(new Uint8Array(f.response));else if(f.body=f.responseText,n.json)try{f.body=JSON.parse(f.responseText)}catch(r){return n.callback(r,f)}n.callback(null,f,f.body)}}var f=new c,d=!1,p=u(n.uri),h="withCredentials"in f;if(l+=1,f.seq_id=l,f.id=l+": "+n.method+" "+n.uri,f._id=f.id,p&&!h){var g=Error("Browser does not support cross-origin request: "+n.uri);return g.cors="unsupported",n.callback(g,f)}f.timeoutTimer=setTimeout(r,n.timeout);var v={response:!1,loading:!1,end:!1};return f.onreadystatechange=i,f.open(n.method,n.uri,!0),null===n.encoding&&(f.responseType="arraybuffer"),p&&(f.withCredentials=!!n.withCredentials),f.send(n.body),f}function i(){}function o(){var t,n,e={},r=["trace","debug","info","warn","error"];for(n=0;r.length>n;n++)t=r[n],e[t]=i,"undefined"!=typeof console&&console&&console[t]&&(e[t]=a(console,t));return e}function a(t,n){function e(e,r){return"object"==typeof r&&(e+=" "+JSON.stringify(r)),t[n].call(t,e)}return e}function u(t){var n,e=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/;try{n=location.href}catch(r){n=document.createElement("a"),n.href="",n=n.href}var i=e.exec(n.toLowerCase())||[],o=e.exec(t.toLowerCase()),a=!(!o||o[1]==i[1]&&o[2]==i[2]&&(o[3]||("http:"===o[1]?80:443))==(i[3]||("http:"===i[1]?80:443)));return a}function s(t){var n,e,r,i,o,a,u,s,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f=0,l=0,d="",p=[];if(!t)return t;do n=t.charCodeAt(f++),e=t.charCodeAt(f++),r=t.charCodeAt(f++),s=n<<16|e<<8|r,i=63&s>>18,o=63&s>>12,a=63&s>>6,u=63&s,p[l++]=c.charAt(i)+c.charAt(o)+c.charAt(a)+c.charAt(u);while(t.length>f);switch(d=p.join(""),t.length%3){case 1:d=d.slice(0,-2)+"==";break;case 2:d=d.slice(0,-1)+"="}return d}var c=XMLHttpRequest;if(!c)throw Error("missing XMLHttpRequest");e.log={trace:i,debug:i,info:i,warn:i,error:i};var f=18e4,l=0;e.withCredentials=!1,e.DEFAULT_TIMEOUT=f,e.defaults=function(t){var n=function(n){var e=function(e,r){e="string"==typeof e?{uri:e}:JSON.parse(JSON.stringify(e));for(var i in t)void 0===e[i]&&(e[i]=t[i]);return n(e,r)};return e},r=n(e);return r.get=n(e.get),r.post=n(e.post),r.put=n(e.put),r.head=n(e.head),r};var d=["get","put","post","head"];d.forEach(function(t){var n=t.toUpperCase(),r=t.toLowerCase();e[r]=function(t){"string"==typeof t?t={method:n,uri:t}:(t=JSON.parse(JSON.stringify(t)),t.method=n);var r=[t].concat(Array.prototype.slice.apply(arguments,[1]));return e.apply(this,r)}}),e.couch=function(t,n){function r(t,e,r){if(t)return n(t,e,r);if((200>e.statusCode||e.statusCode>299)&&r.error){t=Error("CouchDB error: "+(r.error.reason||r.error.error));for(var i in r)t[i]=r[i];return n(t,e,r)}return n(t,e,r)}"string"==typeof t&&(t={uri:t}),t.json=!0,t.body&&(t.json=t.body),delete t.body,n=n||i;var o=e(t,r);return o},n.exports=e}).call(this,t("buffer").Buffer)},{buffer:7}],7:[function(t,n,e){function r(t,n,e){if(!(this instanceof r))return new r(t,n,e);var i=typeof t;"base64"===n&&"string"===i&&(t=x(t));var o;if("number"===i)o=R(t);else if("string"===i)o=r.byteLength(t,n);else{if("object"!==i)throw Error("First argument needs to be a number, array or string.");o=R(t.length)}var a;r._useTypedArrays?a=r._augment(new Uint8Array(o)):(a=this,a.length=o,a._isBuffer=!0);var u;if(r._useTypedArrays&&"number"==typeof t.byteLength)a._set(t);else if(L(t))if(r.isBuffer(t))for(u=0;o>u;u++)a[u]=t.readUInt8(u);else for(u=0;o>u;u++)a[u]=(t[u]%256+256)%256;else if("string"===i)a.write(t,0,n);else if("number"===i&&!r._useTypedArrays&&!e)for(u=0;o>u;u++)a[u]=0;return a}function i(t,n,e,r){e=Number(e)||0;var i=t.length-e;r?(r=Number(r),r>i&&(r=i)):r=i;var o=n.length;z(0===o%2,"Invalid hex string"),r>o/2&&(r=o/2);for(var a=0;r>a;a++){var u=parseInt(n.substr(2*a,2),16);z(!isNaN(u),"Invalid hex string"),t[e+a]=u}return a}function o(t,n,e,r){var i=U(M(n),t,e,r);return i}function a(t,n,e,r){var i=U(k(n),t,e,r);return i}function u(t,n,e,r){return a(t,n,e,r)}function s(t,n,e,r){var i=U(F(n),t,e,r);return i}function c(t,n,e,r){var i=U(C(n),t,e,r);return i}function f(t,n,e){return 0===n&&e===t.length?X.fromByteArray(t):X.fromByteArray(t.slice(n,e))}function l(t,n,e){var r="",i="";e=Math.min(t.length,e);for(var o=n;e>o;o++)127>=t[o]?(r+=P(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return r+P(i)}function d(t,n,e){var r="";e=Math.min(t.length,e);for(var i=n;e>i;i++)r+=String.fromCharCode(t[i]);return r}function p(t,n,e){return d(t,n,e)}function h(t,n,e){var r=t.length;(!n||0>n)&&(n=0),(!e||0>e||e>r)&&(e=r);for(var i="",o=n;e>o;o++)i+=B(t[o]);return i}function g(t,n,e){for(var r=t.slice(n,e),i="",o=0;r.length>o;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function v(t,n,e,r){r||(z("boolean"==typeof e,"missing or invalid endian"),z(void 0!==n&&null!==n,"missing offset"),z(t.length>n+1,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o;return e?(o=t[n],i>n+1&&(o|=t[n+1]<<8)):(o=t[n]<<8,i>n+1&&(o|=t[n+1])),o}}function m(t,n,e,r){r||(z("boolean"==typeof e,"missing or invalid endian"),z(void 0!==n&&null!==n,"missing offset"),z(t.length>n+3,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o;return e?(i>n+2&&(o=t[n+2]<<16),i>n+1&&(o|=t[n+1]<<8),o|=t[n],i>n+3&&(o+=t[n+3]<<24>>>0)):(i>n+1&&(o=t[n+1]<<16),i>n+2&&(o|=t[n+2]<<8),i>n+3&&(o|=t[n+3]),o+=t[n]<<24>>>0),o}}function y(t,n,e,r){r||(z("boolean"==typeof e,"missing or invalid endian"),z(void 0!==n&&null!==n,"missing offset"),z(t.length>n+1,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o=v(t,n,e,!0),a=32768&o;return a?-1*(65535-o+1):o}}function E(t,n,e,r){r||(z("boolean"==typeof e,"missing or invalid endian"),z(void 0!==n&&null!==n,"missing offset"),z(t.length>n+3,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o=m(t,n,e,!0),a=2147483648&o;return a?-1*(4294967295-o+1):o}}function b(t,n,e,r){return r||(z("boolean"==typeof e,"missing or invalid endian"),z(t.length>n+3,"Trying to read beyond buffer length")),W.read(t,n,e,23,4)}function w(t,n,e,r){return r||(z("boolean"==typeof e,"missing or invalid endian"),z(t.length>n+7,"Trying to read beyond buffer length")),W.read(t,n,e,52,8)}function I(t,n,e,r,i){i||(z(void 0!==n&&null!==n,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(t.length>e+1,"trying to write beyond buffer length"),V(n,65535));var o=t.length;if(!(e>=o)){for(var a=0,u=Math.min(o-e,2);u>a;a++)t[e+a]=(n&255<<8*(r?a:1-a))>>>8*(r?a:1-a);return e+2}}function O(t,n,e,r,i){i||(z(void 0!==n&&null!==n,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(t.length>e+3,"trying to write beyond buffer length"),V(n,4294967295));var o=t.length;if(!(e>=o)){for(var a=0,u=Math.min(o-e,4);u>a;a++)t[e+a]=255&n>>>8*(r?a:3-a);return e+4}}function A(t,n,e,r,i){i||(z(void 0!==n&&null!==n,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(t.length>e+1,"Trying to write beyond buffer length"),Y(n,32767,-32768));var o=t.length;if(!(e>=o))return n>=0?I(t,n,e,r,i):I(t,65535+n+1,e,r,i),e+2}function j(t,n,e,r,i){i||(z(void 0!==n&&null!==n,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(t.length>e+3,"Trying to write beyond buffer length"),Y(n,2147483647,-2147483648));var o=t.length;if(!(e>=o))return n>=0?O(t,n,e,r,i):O(t,4294967295+n+1,e,r,i),e+4}function T(t,n,e,r,i){i||(z(void 0!==n&&null!==n,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(t.length>e+3,"Trying to write beyond buffer length"),q(n,3.4028234663852886e38,-3.4028234663852886e38));var o=t.length;if(!(e>=o))return W.write(t,n,e,r,23,4),e+4}function S(t,n,e,r,i){i||(z(void 0!==n&&null!==n,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(t.length>e+7,"Trying to write beyond buffer length"),q(n,1.7976931348623157e308,-1.7976931348623157e308));var o=t.length;if(!(e>=o))return W.write(t,n,e,r,52,8),e+8}function x(t){for(t=N(t).replace(H,"");0!==t.length%4;)t+="=";return t}function N(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function D(t,n,e){return"number"!=typeof t?e:(t=~~t,t>=n?n:t>=0?t:(t+=n,t>=0?t:0))}function R(t){return t=~~Math.ceil(+t),0>t?0:t}function _(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function L(t){return _(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function B(t){return 16>t?"0"+t.toString(16):t.toString(16)}function M(t){for(var n=[],e=0;t.length>e;e++){var r=t.charCodeAt(e);if(127>=r)n.push(r);else{var i=e;r>=55296&&57343>=r&&e++;for(var o=encodeURIComponent(t.slice(i,e+1)).substr(1).split("%"),a=0;o.length>a;a++)n.push(parseInt(o[a],16))}}return n}function k(t){for(var n=[],e=0;t.length>e;e++)n.push(255&t.charCodeAt(e));return n}function C(t){for(var n,e,r,i=[],o=0;t.length>o;o++)n=t.charCodeAt(o),e=n>>8,r=n%256,i.push(r),i.push(e);return i}function F(t){return X.toByteArray(t)}function U(t,n,e,r){for(var i=0;r>i&&!(i+e>=n.length||i>=t.length);i++)n[i+e]=t[i];return i}function P(t){try{return decodeURIComponent(t)}catch(n){return String.fromCharCode(65533)}}function V(t,n){z("number"==typeof t,"cannot write a non-number as a number"),z(t>=0,"specified a negative value for writing an unsigned value"),z(n>=t,"value is larger than maximum value for type"),z(Math.floor(t)===t,"value has a fractional component")}function Y(t,n,e){z("number"==typeof t,"cannot write a non-number as a number"),z(n>=t,"value larger than maximum allowed value"),z(t>=e,"value smaller than minimum allowed value"),z(Math.floor(t)===t,"value has a fractional component")}function q(t,n,e){z("number"==typeof t,"cannot write a non-number as a number"),z(n>=t,"value larger than maximum allowed value"),z(t>=e,"value smaller than minimum allowed value")}function z(t,n){if(!t)throw Error(n||"Failed assertion")}var X=t("base64-js"),W=t("ieee754");e.Buffer=r,e.SlowBuffer=r,e.INSPECT_MAX_BYTES=50,r.poolSize=8192,r._useTypedArrays=function(){try{var t=new ArrayBuffer(0),n=new Uint8Array(t);return n.foo=function(){return 42},42===n.foo()&&"function"==typeof n.subarray}catch(e){return!1}}(),r.isEncoding=function(t){switch((t+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},r.isBuffer=function(t){return!(null===t||void 0===t||!t._isBuffer)},r.byteLength=function(t,n){var e;switch(t=""+t,n||"utf8"){case"hex":e=t.length/2;break;case"utf8":case"utf-8":e=M(t).length;break;case"ascii":case"binary":case"raw":e=t.length;break;case"base64":e=F(t).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":e=2*t.length;break;default:throw Error("Unknown encoding")}return e},r.concat=function(t,n){if(z(_(t),"Usage: Buffer.concat(list[, length])"),0===t.length)return new r(0);if(1===t.length)return t[0];var e;if(void 0===n)for(n=0,e=0;t.length>e;e++)n+=t[e].length;var i=new r(n),o=0;for(e=0;t.length>e;e++){var a=t[e];a.copy(i,o),o+=a.length}return i},r.compare=function(t,n){z(r.isBuffer(t)&&r.isBuffer(n),"Arguments must be Buffers");for(var e=t.length,i=n.length,o=0,a=Math.min(e,i);a>o&&t[o]===n[o];o++);return o!==a&&(e=t[o],i=n[o]),i>e?-1:e>i?1:0},r.prototype.write=function(t,n,e,r){if(isFinite(n))isFinite(e)||(r=e,e=void 0);else{var f=r;r=n,n=e,e=f}n=Number(n)||0;var l=this.length-n;
|
|
e?(e=Number(e),e>l&&(e=l)):e=l,r=((r||"utf8")+"").toLowerCase();var d;switch(r){case"hex":d=i(this,t,n,e);break;case"utf8":case"utf-8":d=o(this,t,n,e);break;case"ascii":d=a(this,t,n,e);break;case"binary":d=u(this,t,n,e);break;case"base64":d=s(this,t,n,e);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":d=c(this,t,n,e);break;default:throw Error("Unknown encoding")}return d},r.prototype.toString=function(t,n,e){var r=this;if(t=((t||"utf8")+"").toLowerCase(),n=Number(n)||0,e=void 0===e?r.length:Number(e),e===n)return"";var i;switch(t){case"hex":i=h(r,n,e);break;case"utf8":case"utf-8":i=l(r,n,e);break;case"ascii":i=d(r,n,e);break;case"binary":i=p(r,n,e);break;case"base64":i=f(r,n,e);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=g(r,n,e);break;default:throw Error("Unknown encoding")}return i},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.equals=function(t){return z(r.isBuffer(t),"Argument must be a Buffer"),0===r.compare(this,t)},r.prototype.compare=function(t){return z(r.isBuffer(t),"Argument must be a Buffer"),r.compare(this,t)},r.prototype.copy=function(t,n,e,i){var o=this;if(e||(e=0),i||0===i||(i=this.length),n||(n=0),i!==e&&0!==t.length&&0!==o.length){z(i>=e,"sourceEnd < sourceStart"),z(n>=0&&t.length>n,"targetStart out of bounds"),z(e>=0&&o.length>e,"sourceStart out of bounds"),z(i>=0&&o.length>=i,"sourceEnd out of bounds"),i>this.length&&(i=this.length),i-e>t.length-n&&(i=t.length-n+e);var a=i-e;if(100>a||!r._useTypedArrays)for(var u=0;a>u;u++)t[u+n]=this[u+e];else t._set(this.subarray(e,e+a),n)}},r.prototype.slice=function(t,n){var e=this.length;if(t=D(t,e,0),n=D(n,e,e),r._useTypedArrays)return r._augment(this.subarray(t,n));for(var i=n-t,o=new r(i,void 0,!0),a=0;i>a;a++)o[a]=this[a+t];return o},r.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},r.prototype.set=function(t,n){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,n)},r.prototype.readUInt8=function(t,n){return n||(z(void 0!==t&&null!==t,"missing offset"),z(this.length>t,"Trying to read beyond buffer length")),t>=this.length?void 0:this[t]},r.prototype.readUInt16LE=function(t,n){return v(this,t,!0,n)},r.prototype.readUInt16BE=function(t,n){return v(this,t,!1,n)},r.prototype.readUInt32LE=function(t,n){return m(this,t,!0,n)},r.prototype.readUInt32BE=function(t,n){return m(this,t,!1,n)},r.prototype.readInt8=function(t,n){if(n||(z(void 0!==t&&null!==t,"missing offset"),z(this.length>t,"Trying to read beyond buffer length")),!(t>=this.length)){var e=128&this[t];return e?-1*(255-this[t]+1):this[t]}},r.prototype.readInt16LE=function(t,n){return y(this,t,!0,n)},r.prototype.readInt16BE=function(t,n){return y(this,t,!1,n)},r.prototype.readInt32LE=function(t,n){return E(this,t,!0,n)},r.prototype.readInt32BE=function(t,n){return E(this,t,!1,n)},r.prototype.readFloatLE=function(t,n){return b(this,t,!0,n)},r.prototype.readFloatBE=function(t,n){return b(this,t,!1,n)},r.prototype.readDoubleLE=function(t,n){return w(this,t,!0,n)},r.prototype.readDoubleBE=function(t,n){return w(this,t,!1,n)},r.prototype.writeUInt8=function(t,n,e){return e||(z(void 0!==t&&null!==t,"missing value"),z(void 0!==n&&null!==n,"missing offset"),z(this.length>n,"trying to write beyond buffer length"),V(t,255)),n>=this.length?void 0:(this[n]=t,n+1)},r.prototype.writeUInt16LE=function(t,n,e){return I(this,t,n,!0,e)},r.prototype.writeUInt16BE=function(t,n,e){return I(this,t,n,!1,e)},r.prototype.writeUInt32LE=function(t,n,e){return O(this,t,n,!0,e)},r.prototype.writeUInt32BE=function(t,n,e){return O(this,t,n,!1,e)},r.prototype.writeInt8=function(t,n,e){return e||(z(void 0!==t&&null!==t,"missing value"),z(void 0!==n&&null!==n,"missing offset"),z(this.length>n,"Trying to write beyond buffer length"),Y(t,127,-128)),n>=this.length?void 0:(t>=0?this.writeUInt8(t,n,e):this.writeUInt8(255+t+1,n,e),n+1)},r.prototype.writeInt16LE=function(t,n,e){return A(this,t,n,!0,e)},r.prototype.writeInt16BE=function(t,n,e){return A(this,t,n,!1,e)},r.prototype.writeInt32LE=function(t,n,e){return j(this,t,n,!0,e)},r.prototype.writeInt32BE=function(t,n,e){return j(this,t,n,!1,e)},r.prototype.writeFloatLE=function(t,n,e){return T(this,t,n,!0,e)},r.prototype.writeFloatBE=function(t,n,e){return T(this,t,n,!1,e)},r.prototype.writeDoubleLE=function(t,n,e){return S(this,t,n,!0,e)},r.prototype.writeDoubleBE=function(t,n,e){return S(this,t,n,!1,e)},r.prototype.fill=function(t,n,e){if(t||(t=0),n||(n=0),e||(e=this.length),z(e>=n,"end < start"),e!==n&&0!==this.length){z(n>=0&&this.length>n,"start out of bounds"),z(e>=0&&this.length>=e,"end out of bounds");var r;if("number"==typeof t)for(r=n;e>r;r++)this[r]=t;else{var i=M(""+t),o=i.length;for(r=n;e>r;r++)this[r]=i[r%o]}return this}},r.prototype.inspect=function(){for(var t=[],n=this.length,r=0;n>r;r++)if(t[r]=B(this[r]),r===e.INSPECT_MAX_BYTES){t[r+1]="...";break}return"<Buffer "+t.join(" ")+">"},r.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(r._useTypedArrays)return new r(this).buffer;for(var t=new Uint8Array(this.length),n=0,e=t.length;e>n;n+=1)t[n]=this[n];return t.buffer}throw Error("Buffer.toArrayBuffer not supported in this browser")};var J=r.prototype;r._augment=function(t){return t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=J.get,t.set=J.set,t.write=J.write,t.toString=J.toString,t.toLocaleString=J.toString,t.toJSON=J.toJSON,t.equals=J.equals,t.compare=J.compare,t.copy=J.copy,t.slice=J.slice,t.readUInt8=J.readUInt8,t.readUInt16LE=J.readUInt16LE,t.readUInt16BE=J.readUInt16BE,t.readUInt32LE=J.readUInt32LE,t.readUInt32BE=J.readUInt32BE,t.readInt8=J.readInt8,t.readInt16LE=J.readInt16LE,t.readInt16BE=J.readInt16BE,t.readInt32LE=J.readInt32LE,t.readInt32BE=J.readInt32BE,t.readFloatLE=J.readFloatLE,t.readFloatBE=J.readFloatBE,t.readDoubleLE=J.readDoubleLE,t.readDoubleBE=J.readDoubleBE,t.writeUInt8=J.writeUInt8,t.writeUInt16LE=J.writeUInt16LE,t.writeUInt16BE=J.writeUInt16BE,t.writeUInt32LE=J.writeUInt32LE,t.writeUInt32BE=J.writeUInt32BE,t.writeInt8=J.writeInt8,t.writeInt16LE=J.writeInt16LE,t.writeInt16BE=J.writeInt16BE,t.writeInt32LE=J.writeInt32LE,t.writeInt32BE=J.writeInt32BE,t.writeFloatLE=J.writeFloatLE,t.writeFloatBE=J.writeFloatBE,t.writeDoubleLE=J.writeDoubleLE,t.writeDoubleBE=J.writeDoubleBE,t.fill=J.fill,t.inspect=J.inspect,t.toArrayBuffer=J.toArrayBuffer,t};var H=/[^+\/0-9A-z]/g},{"base64-js":8,ieee754:9}],8:[function(t,n,e){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(t){"use strict";function n(t){var n=t.charCodeAt(0);return n===a?62:n===u?63:s>n?-1:s+10>n?n-s+26+26:f+26>n?n-f:c+26>n?n-c+26:void 0}function e(t){function e(t){c[l++]=t}var r,i,a,u,s,c;if(t.length%4>0)throw Error("Invalid string. Length must be a multiple of 4");var f=t.length;s="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,c=new o(3*t.length/4-s),a=s>0?t.length-4:t.length;var l=0;for(r=0,i=0;a>r;r+=4,i+=3)u=n(t.charAt(r))<<18|n(t.charAt(r+1))<<12|n(t.charAt(r+2))<<6|n(t.charAt(r+3)),e((16711680&u)>>16),e((65280&u)>>8),e(255&u);return 2===s?(u=n(t.charAt(r))<<2|n(t.charAt(r+1))>>4,e(255&u)):1===s&&(u=n(t.charAt(r))<<10|n(t.charAt(r+1))<<4|n(t.charAt(r+2))>>2,e(255&u>>8),e(255&u)),c}function i(t){function n(t){return r.charAt(t)}function e(t){return n(63&t>>18)+n(63&t>>12)+n(63&t>>6)+n(63&t)}var i,o,a,u=t.length%3,s="";for(i=0,a=t.length-u;a>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],s+=e(o);switch(u){case 1:o=t[t.length-1],s+=n(o>>2),s+=n(63&o<<4),s+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],s+=n(o>>10),s+=n(63&o>>4),s+=n(63&o<<2),s+="="}return s}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="+".charCodeAt(0),u="/".charCodeAt(0),s="0".charCodeAt(0),c="a".charCodeAt(0),f="A".charCodeAt(0);t.toByteArray=e,t.fromByteArray=i})(e===void 0?this.base64js={}:e)},{}],9:[function(t,n,e){e.read=function(t,n,e,r,i){var o,a,u=8*i-r-1,s=(1<<u)-1,c=s>>1,f=-7,l=e?i-1:0,d=e?-1:1,p=t[n+l];for(l+=d,o=p&(1<<-f)-1,p>>=-f,f+=u;f>0;o=256*o+t[n+l],l+=d,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=r;f>0;a=256*a+t[n+l],l+=d,f-=8);if(0===o)o=1-c;else{if(o===s)return a?0/0:1/0*(p?-1:1);a+=Math.pow(2,r),o-=c}return(p?-1:1)*a*Math.pow(2,o-r)},e.write=function(t,n,e,r,i,o){var a,u,s,c=8*o-i-1,f=(1<<c)-1,l=f>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,h=r?1:-1,g=0>n||0===n&&0>1/n?1:0;for(n=Math.abs(n),isNaN(n)||1/0===n?(u=isNaN(n)?1:0,a=f):(a=Math.floor(Math.log(n)/Math.LN2),1>n*(s=Math.pow(2,-a))&&(a--,s*=2),n+=a+l>=1?d/s:d*Math.pow(2,1-l),n*s>=2&&(a++,s/=2),a+l>=f?(u=0,a=f):a+l>=1?(u=(n*s-1)*Math.pow(2,i),a+=l):(u=n*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[e+p]=255&u,p+=h,u/=256,i-=8);for(a=a<<i|u,c+=i;c>0;t[e+p]=255&a,p+=h,a/=256,c-=8);t[e+p-h]|=128*g}},{}],10:[function(t,n){function e(){}var r=n.exports={};r.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,n="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(n){var e=[];return window.addEventListener("message",function(t){var n=t.source;if((n===window||null===n)&&"process-tick"===t.data&&(t.stopPropagation(),e.length>0)){var r=e.shift();r()}},!0),function(t){e.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=e,r.addListener=e,r.once=e,r.off=e,r.removeListener=e,r.removeAllListeners=e,r.emit=e,r.binding=function(){throw Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw Error("process.chdir is not supported")}},{}],11:[function(t,n){(function(t){function e(n,e,r){return n instanceof ArrayBuffer&&(n=new Uint8Array(n)),new t(n,e,r)}e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Object.keys(t).forEach(function(n){t.hasOwnProperty(n)&&(e[n]=t[n])}),n.exports=e}).call(this,t("buffer").Buffer)},{buffer:7}],12:[function(t,n){var e="READ",r="WRITE",i="CREATE",o="EXCLUSIVE",a="TRUNCATE",u="APPEND",s="CREATE",c="REPLACE";n.exports={FILE_SYSTEM_NAME:"local",FILE_STORE_NAME:"files",IDB_RO:"readonly",IDB_RW:"readwrite",WSQL_VERSION:"1",WSQL_SIZE:5242880,WSQL_DESC:"FileSystem Storage",MODE_FILE:"FILE",MODE_DIRECTORY:"DIRECTORY",MODE_SYMBOLIC_LINK:"SYMLINK",MODE_META:"META",SYMLOOP_MAX:10,BINARY_MIME_TYPE:"application/octet-stream",JSON_MIME_TYPE:"application/json",ROOT_DIRECTORY_NAME:"/",FS_FORMAT:"FORMAT",FS_NOCTIME:"NOCTIME",FS_NOMTIME:"NOMTIME",FS_NODUPEIDCHECK:"FS_NODUPEIDCHECK",O_READ:e,O_WRITE:r,O_CREATE:i,O_EXCLUSIVE:o,O_TRUNCATE:a,O_APPEND:u,O_FLAGS:{r:[e],"r+":[e,r],w:[r,i,a],"w+":[r,e,i,a],wx:[r,i,o,a],"wx+":[r,e,i,o,a],a:[r,i,u],"a+":[r,e,i,u],ax:[r,i,o,u],"ax+":[r,e,i,o,u]},XATTR_CREATE:s,XATTR_REPLACE:c,FS_READY:"READY",FS_PENDING:"PENDING",FS_ERROR:"ERROR",SUPER_NODE_ID:"00000000-0000-0000-0000-000000000000",STDIN:0,STDOUT:1,STDERR:2,FIRST_DESCRIPTOR:3,ENVIRONMENT:{TMP:"/tmp",PATH:""}}},{}],13:[function(t,n){var e=t("./constants.js").MODE_FILE;n.exports=function(t,n){this.id=t,this.type=n||e}},{"./constants.js":12}],14:[function(t,n){(function(t){function e(t){return t.toString("utf8")}function r(n){return new t(n,"utf8")}n.exports={encode:r,decode:e}}).call(this,t("buffer").Buffer)},{buffer:7}],15:[function(t,n){var e={};["9:EBADF:bad file descriptor","10:EBUSY:resource busy or locked","18:EINVAL:invalid argument","27:ENOTDIR:not a directory","28:EISDIR:illegal operation on a directory","34:ENOENT:no such file or directory","47:EEXIST:file already exists","51:ELOOP:too many symbolic links encountered","53:ENOTEMPTY:directory not empty","55:EIO:i/o error","1000:ENOTMOUNTED:not mounted","1001:EFILESYSTEMERROR:missing super node, use 'FORMAT' flag to format filesystem.","1002:ENOATTR:attribute does not exist"].forEach(function(t){function n(t,n){Error.call(this),this.name=i,this.code=i,this.errno=r,this.message=t||o,n&&(this.path=n),this.stack=Error(this.message).stack}t=t.split(":");var r=+t[0],i=t[1],o=t[2];n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n.prototype.toString=function(){var t=this.path?", '"+this.path+"'":"";return this.name+": "+this.message+t},e[i]=e[r]=n}),n.exports=e},{}],16:[function(t,n){function e(t){return function(n,e){n?t(n):t(null,e)}}function r(t,n,e,r,i){function o(e){t.changes.push({event:"change",path:n}),i(e)}var a=t.flags;pn(a).contains(Cn)&&delete r.ctime,pn(a).contains(kn)&&delete r.mtime;var u=!1;r.ctime&&(e.ctime=r.ctime,e.atime=r.ctime,u=!0),r.atime&&(e.atime=r.atime,u=!0),r.mtime&&(e.mtime=r.mtime,u=!0),u?t.putObject(e.id,e,o):o()}function i(t,n,e,i){function a(e,r){e?i(e):r.mode!==In?i(new Un.ENOTDIR("a component of the path prefix is not a directory",n)):(l=r,o(t,n,u))}function u(e,r){!e&&r?i(new Un.EEXIST("path name already exists",n)):!e||e instanceof Un.ENOENT?t.getObject(l.data,s):i(e)}function s(n,r){n?i(n):(d=r,qn.create({guid:t.guid,mode:e},function(n,e){return n?(i(n),void 0):(p=e,p.nlinks+=1,t.putObject(p.id,p,f),void 0)}))}function c(n){if(n)i(n);else{var e=Date.now();r(t,g,p,{mtime:e,ctime:e},i)}}function f(n){n?i(n):(d[h]=new Pn(p.id,e),t.putObject(l.data,d,c))}if(e!==In&&e!==wn)return i(new Un.EINVAL("mode must be a directory or file",n));n=gn(n);var l,d,p,h=mn(n),g=vn(n);o(t,g,a)}function o(t,n,e){function r(n,r){n?e(n):r&&r.mode===An&&r.rnode?t.getObject(r.rnode,i):e(new Un.EFILESYSTEMERROR)}function i(t,n){t?e(t):n?e(null,n):e(new Un.ENOENT)}function a(r,i){r?e(r):i.mode===In&&i.data?t.getObject(i.data,u):e(new Un.ENOTDIR("a component of the path prefix is not a directory",n))}function u(r,i){if(r)e(r);else if(pn(i).has(f)){var o=i[f].id;t.getObject(o,s)}else e(new Un.ENOENT(null,n))}function s(t,r){t?e(t):r.mode==On?(d++,d>Sn?e(new Un.ELOOP(null,n)):c(r.data)):e(null,r)}function c(n){n=gn(n),l=vn(n),f=mn(n),jn==f?t.getObject(Tn,r):o(t,l,a)}if(n=gn(n),!n)return e(new Un.ENOENT("path is an empty string"));var f=mn(n),l=vn(n),d=0;jn==f?t.getObject(Tn,r):o(t,l,a)}function a(t,n,e,i,a,u){function s(o,s){function f(n){n?u(n):r(t,c,s,{ctime:Date.now()},u)}s?s.xattrs[e]:null,o?u(o):a===Bn&&s.xattrs.hasOwnProperty(e)?u(new Un.EEXIST("attribute already exists",n)):a!==Mn||s.xattrs.hasOwnProperty(e)?(s.xattrs[e]=i,t.putObject(s.id,s,f)):u(new Un.ENOATTR(null,n))}var c;"string"==typeof n?(c=n,o(t,n,s)):"object"==typeof n&&"string"==typeof n.id?(c=n.path,t.getObject(n.id,s)):u(new Un.EINVAL("path or file descriptor of wrong type",n))}function u(t,n){function e(e,i){!e&&i?n():!e||e instanceof Un.ENOENT?Yn.create({guid:t.guid},function(e,i){return e?(n(e),void 0):(o=i,t.putObject(o.id,o,r),void 0)}):n(e)}function r(e){e?n(e):qn.create({guid:t.guid,id:o.rnode,mode:In},function(e,r){return e?(n(e),void 0):(a=r,a.nlinks+=1,t.putObject(a.id,a,i),void 0)})}function i(e){e?n(e):(u={},t.putObject(a.data,u,n))}var o,a,u;t.getObject(Tn,e)}function s(t,n,e){function i(r,i){!r&&i?e(new Un.EEXIST(null,n)):!r||r instanceof Un.ENOENT?o(t,v,a):e(r)}function a(n,r){n?e(n):(p=r,t.getObject(p.data,u))}function u(n,r){n?e(n):(h=r,qn.create({guid:t.guid,mode:In},function(n,r){return n?(e(n),void 0):(l=r,l.nlinks+=1,t.putObject(l.id,l,s),void 0)}))}function s(n){n?e(n):(d={},t.putObject(l.data,d,f))}function c(n){if(n)e(n);else{var i=Date.now();r(t,v,p,{mtime:i,ctime:i},e)}}function f(n){n?e(n):(h[g]=new Pn(l.id,In),t.putObject(p.data,h,c))}n=gn(n);var l,d,p,h,g=mn(n),v=vn(n);o(t,n,i)}function c(t,n,e){function i(n,r){n?e(n):(g=r,t.getObject(g.data,a))}function a(r,i){r?e(r):jn==m?e(new Un.EBUSY(null,n)):pn(i).has(m)?(v=i,p=v[m].id,t.getObject(p,u)):e(new Un.ENOENT(null,n))}function u(r,i){r?e(r):i.mode!=In?e(new Un.ENOTDIR(null,n)):(p=i,t.getObject(p.data,s))}function s(t,r){t?e(t):(h=r,pn(h).size()>0?e(new Un.ENOTEMPTY(null,n)):f())}function c(n){if(n)e(n);else{var i=Date.now();r(t,y,g,{mtime:i,ctime:i},l)}}function f(){delete v[m],t.putObject(g.data,v,c)}function l(n){n?e(n):t.delete(p.id,d)}function d(n){n?e(n):t.delete(p.data,e)}n=gn(n);var p,h,g,v,m=mn(n),y=vn(n);o(t,y,i)}function f(t,n,e,i){function a(e,r){e?i(e):r.mode!==In?i(new Un.ENOENT(null,n)):(v=r,t.getObject(v.data,u))}function u(r,o){r?i(r):(m=o,pn(m).has(w)?pn(e).contains(Rn)?i(new Un.ENOENT("O_CREATE and O_EXCLUSIVE are set, and the named file exists",n)):(y=m[w],y.type==In&&pn(e).contains(Nn)?i(new Un.EISDIR("the named file is a directory and O_WRITE is set",n)):t.getObject(y.id,s)):pn(e).contains(Dn)?l():i(new Un.ENOENT("O_CREATE is not set and the named file does not exist",n)))}function s(t,e){if(t)i(t);else{var r=e;r.mode==On?(O++,O>Sn?i(new Un.ELOOP(null,n)):c(r.data)):f(void 0,r)}}function c(r){r=gn(r),I=vn(r),w=mn(r),jn==w&&(pn(e).contains(Nn)?i(new Un.EISDIR("the named file is a directory and O_WRITE is set",n)):o(t,n,f)),o(t,I,a)}function f(t,n){t?i(t):(E=n,i(null,E))}function l(){qn.create({guid:t.guid,mode:wn},function(n,e){return n?(i(n),void 0):(E=e,E.nlinks+=1,t.putObject(E.id,E,d),void 0)})}function d(n){n?i(n):(b=new Xn(0),b.fill(0),t.putBuffer(E.data,b,h))}function p(n){if(n)i(n);else{var e=Date.now();r(t,I,v,{mtime:e,ctime:e},g)}}function h(n){n?i(n):(m[w]=new Pn(E.id,wn),t.putObject(v.data,m,p))}function g(t){t?i(t):i(null,E)}n=gn(n);var v,m,y,E,b,w=mn(n),I=vn(n),O=0;jn==w?pn(e).contains(Nn)?i(new Un.EISDIR("the named file is a directory and O_WRITE is set",n)):o(t,n,f):o(t,I,a)}function l(t,n,e,i,o,a){function u(t){t?a(t):a(null,o)}function s(e){if(e)a(e);else{var i=Date.now();r(t,n.path,l,{mtime:i,ctime:i},u)}}function c(n){n?a(n):t.putObject(l.id,l,s)}function f(r,u){if(r)a(r);else{l=u;var s=new Xn(o);s.fill(0),e.copy(s,0,i,i+o),n.position=o,l.size=o,l.version+=1,t.putBuffer(l.data,s,c)}}var l;t.getObject(n.id,f)}function d(t,n,e,i,o,a,u){function s(t){t?u(t):u(null,o)}function c(e){if(e)u(e);else{var i=Date.now();r(t,n.path,p,{mtime:i,ctime:i},s)}}function f(n){n?u(n):t.putObject(p.id,p,c)}function l(r,s){if(r)u(r);else{if(h=s,!h)return u(new Un.EIO("Expected Buffer"));var c=void 0!==a&&null!==a?a:n.position,l=Math.max(h.length,c+o),d=new Xn(l);d.fill(0),h&&h.copy(d),e.copy(d,c,i,i+o),void 0===a&&(n.position+=o),p.size=l,p.version+=1,t.putBuffer(p.data,d,f)}}function d(n,e){n?u(n):(p=e,t.getBuffer(p.data,l))}var p,h;t.getObject(n.id,d)}function p(t,n,e,r,i,o,a){function u(t,u){if(t)a(t);else{if(f=u,!f)return a(new Un.EIO("Expected Buffer"));var s=void 0!==o&&null!==o?o:n.position;i=s+i>e.length?i-s:i,f.copy(e,r,s,s+i),void 0===o&&(n.position+=i),a(null,i)}}function s(n,e){n?a(n):(c=e,t.getBuffer(c.data,u))}var c,f;t.getObject(n.id,s)}function h(t,n,r){n=gn(n),mn(n),o(t,n,e(r))}function g(t,n,r){t.getObject(n.id,e(r))}function v(t,n,r){function i(n,e){n?r(n):(u=e,t.getObject(u.data,a))}function a(i,o){i?r(i):(s=o,pn(s).has(c)?t.getObject(s[c].id,e(r)):r(new Un.ENOENT("a component of the path does not name an existing file",n)))}n=gn(n);var u,s,c=mn(n),f=vn(n);jn==c?o(t,n,e(r)):o(t,f,i)}function m(t,n,e,i){function a(n){n?i(n):r(t,e,E,{ctime:Date.now()},i)}function u(n,e){n?i(n):(E=e,E.nlinks+=1,t.putObject(E.id,E,a))}function s(n){n?i(n):t.getObject(y[b].id,u)}function c(n,e){n?i(n):(y=e,pn(y).has(b)?i(new Un.EEXIST("newpath resolves to an existing file",b)):(y[b]=v[p],t.putObject(m.data,y,s)))}function f(n,e){n?i(n):(m=e,t.getObject(m.data,c))}function l(n,e){n?i(n):(v=e,pn(v).has(p)?o(t,w,f):i(new Un.ENOENT("a component of either path prefix does not exist",p)))}function d(n,e){n?i(n):(g=e,t.getObject(g.data,l))}n=gn(n);var p=mn(n),h=vn(n);e=gn(e);var g,v,m,y,E,b=mn(e),w=vn(e);o(t,h,d)}function y(t,n,e){function i(n){n?e(n):(delete l[p],t.putObject(f.data,l,function(){var n=Date.now();r(t,h,f,{mtime:n,ctime:n},e)}))}function a(n){n?e(n):t.delete(d.data,i)}function u(o,u){o?e(o):(d=u,d.nlinks-=1,1>d.nlinks?t.delete(d.id,a):t.putObject(d.id,d,function(){r(t,n,d,{ctime:Date.now()},i)}))}function s(n,r){n?e(n):(l=r,pn(l).has(p)?t.getObject(l[p].id,u):e(new Un.ENOENT("a component of the path does not name an existing file",p)))}function c(n,r){n?e(n):(f=r,t.getObject(f.data,s))}n=gn(n);var f,l,d,p=mn(n),h=vn(n);o(t,h,c)}function E(t,n,e){function r(t,n){if(t)e(t);else{u=n;var r=Object.keys(u);e(null,r)}}function i(i,o){i?e(i):o.mode!==In?e(new Un.ENOTDIR(null,n)):(a=o,t.getObject(a.data,r))}n=gn(n),mn(n);var a,u;o(t,n,i)}function b(t,n,e,i){function a(n,e){n?i(n):(l=e,t.getObject(l.data,u))}function u(t,n){t?i(t):(d=n,pn(d).has(h)?i(new Un.EEXIST(null,h)):s())}function s(){qn.create({guid:t.guid,mode:On},function(e,r){return e?(i(e),void 0):(p=r,p.nlinks+=1,p.size=n.length,p.data=n,t.putObject(p.id,p,f),void 0)})}function c(n){if(n)i(n);else{var e=Date.now();r(t,g,l,{mtime:e,ctime:e},i)}}function f(n){n?i(n):(d[h]=new Pn(p.id,On),t.putObject(l.data,d,c))}e=gn(e);var l,d,p,h=mn(e),g=vn(e);jn==h?i(new Un.EEXIST(null,h)):o(t,g,a)}function w(t,n,e){function r(n,r){n?e(n):(u=r,t.getObject(u.data,i))}function i(n,r){n?e(n):(s=r,pn(s).has(c)?t.getObject(s[c].id,a):e(new Un.ENOENT("a component of the path does not name an existing file",c)))}function a(t,r){t?e(t):r.mode!=On?e(new Un.EINVAL("path not a symbolic link",n)):e(null,r.data)}n=gn(n);var u,s,c=mn(n),f=vn(n);o(t,f,r)}function I(t,n,e,i){function a(e,r){e?i(e):r.mode==In?i(new Un.EISDIR(null,n)):(f=r,t.getBuffer(f.data,u))}function u(n,r){if(n)i(n);else{if(!r)return i(new Un.EIO("Expected Buffer"));var o=new Xn(e);o.fill(0),r&&r.copy(o),t.putBuffer(f.data,o,c)}}function s(e){if(e)i(e);else{var o=Date.now();r(t,n,f,{mtime:o,ctime:o},i)}}function c(n){n?i(n):(f.size=e,f.version+=1,t.putObject(f.id,f,s))}n=gn(n);var f;0>e?i(new Un.EINVAL("length cannot be negative")):o(t,n,a)}function O(t,n,e,i){function o(n,e){n?i(n):e.mode==In?i(new Un.EISDIR):(c=e,t.getBuffer(c.data,a))}function a(n,r){if(n)i(n);else{var o;if(!r)return i(new Un.EIO("Expected Buffer"));r?o=r.slice(0,e):(o=new Xn(e),o.fill(0)),t.putBuffer(c.data,o,s)}}function u(e){if(e)i(e);else{var o=Date.now();r(t,n.path,c,{mtime:o,ctime:o},i)}}function s(n){n?i(n):(c.size=e,c.version+=1,t.putObject(c.id,c,u))}var c;0>e?i(new Un.EINVAL("length cannot be negative")):t.getObject(n.id,o)}function A(t,n,e,i,a){function u(o,u){o?a(o):r(t,n,u,{atime:e,ctime:i,mtime:i},a)}n=gn(n),"number"!=typeof e||"number"!=typeof i?a(new Un.EINVAL("atime and mtime must be number",n)):0>e||0>i?a(new Un.EINVAL("atime and mtime must be positive integers",n)):o(t,n,u)}function j(t,n,e,i,o){function a(a,u){a?o(a):r(t,n.path,u,{atime:e,ctime:i,mtime:i},o)}"number"!=typeof e||"number"!=typeof i?o(new Un.EINVAL("atime and mtime must be a number")):0>e||0>i?o(new Un.EINVAL("atime and mtime must be positive integers")):t.getObject(n.id,a)}function T(t,n,e,r,i,o){n=gn(n),"string"!=typeof e?o(new Un.EINVAL("attribute name must be a string",n)):e?null!==i&&i!==Bn&&i!==Mn?o(new Un.EINVAL("invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE",n)):a(t,n,e,r,i,o):o(new Un.EINVAL("attribute name cannot be an empty string",n))}function S(t,n,e,r,i,o){"string"!=typeof e?o(new Un.EINVAL("attribute name must be a string")):e?null!==i&&i!==Bn&&i!==Mn?o(new Un.EINVAL("invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE")):a(t,n,e,r,i,o):o(new Un.EINVAL("attribute name cannot be an empty string"))}function x(t,n,e,r){function i(t,i){i?i.xattrs[e]:null,t?r(t):i.xattrs.hasOwnProperty(e)?r(null,i.xattrs[e]):r(new Un.ENOATTR(null,n))}n=gn(n),"string"!=typeof e?r(new Un.EINVAL("attribute name must be a string",n)):e?o(t,n,i):r(new Un.EINVAL("attribute name cannot be an empty string",n))}function N(t,n,e,r){function i(t,n){n?n.xattrs[e]:null,t?r(t):n.xattrs.hasOwnProperty(e)?r(null,n.xattrs[e]):r(new Un.ENOATTR)}"string"!=typeof e?r(new Un.EINVAL):e?t.getObject(n.id,i):r(new Un.EINVAL("attribute name cannot be an empty string"))}function D(t,n,e,i){function a(o,a){function u(e){e?i(e):r(t,n,a,{ctime:Date.now()},i)}var s=a?a.xattrs:null;o?i(o):s.hasOwnProperty(e)?(delete a.xattrs[e],t.putObject(a.id,a,u)):i(new Un.ENOATTR(null,n))}n=gn(n),"string"!=typeof e?i(new Un.EINVAL("attribute name must be a string",n)):e?o(t,n,a):i(new Un.EINVAL("attribute name cannot be an empty string",n))}function R(t,n,e,i){function o(o,a){function u(e){e?i(e):r(t,n.path,a,{ctime:Date.now()},i)}o?i(o):a.xattrs.hasOwnProperty(e)?(delete a.xattrs[e],t.putObject(a.id,a,u)):i(new Un.ENOATTR)}"string"!=typeof e?i(new Un.EINVAL("attribute name must be a string")):e?t.getObject(n.id,o):i(new Un.EINVAL("attribute name cannot be an empty string"))}function _(t){return pn(Ln).has(t)?Ln[t]:null}function L(t,n,e){return t?"function"==typeof t?t={encoding:n,flag:e}:"string"==typeof t&&(t={encoding:t,flag:e}):t={encoding:n,flag:e},t}function B(t,n){var e;return t?En(t)?e=new Un.EINVAL("Path must be a string without null bytes.",t):yn(t)||(e=new Un.EINVAL("Path must be absolute.",t)):e=new Un.EINVAL("Path must be a string",t),e?(n(e),!1):!0}function M(t,n,e,r,i,o){function a(n,i){if(n)o(n);else{var a;a=pn(r).contains(_n)?i.size:0;var u=new Vn(e,i.id,r,a),s=t.allocDescriptor(u);o(null,s)}}o=arguments[arguments.length-1],B(e,o)&&(r=_(r),r||o(new Un.EINVAL("flags is not valid"),e),f(n,e,r,a))}function k(t,n,e,r){pn(t.openFiles).has(e)?(t.releaseDescriptor(e),r(null)):r(new Un.EBADF)}function C(t,n,e,r,o){B(e,o)&&i(n,e,r,o)}function F(t,n,r,i,o){o=arguments[arguments.length-1],B(r,o)&&s(n,r,e(o))}function U(t,n,r,i){B(r,i)&&c(n,r,e(i))}function P(t,n,e,r){function i(n,e){if(n)r(n);else{var i=new zn(e,t.name);r(null,i)}}B(e,r)&&h(n,e,i)}function V(t,n,e,r){function i(n,e){if(n)r(n);else{var i=new zn(e,t.name);r(null,i)}}var o=t.openFiles[e];o?g(n,o,i):r(new Un.EBADF)}function Y(t,n,r,i,o){B(r,o)&&B(i,o)&&m(n,r,i,e(o))}function q(t,n,r,i){B(r,i)&&y(n,r,e(i))}function z(t,n,r,i,o,a,u,s){function c(t,n){s(t,n||0,i)}o=void 0===o?0:o,a=void 0===a?i.length-o:a,s=arguments[arguments.length-1];var f=t.openFiles[r];f?pn(f.flags).contains(xn)?p(n,f,i,o,a,u,e(c)):s(new Un.EBADF("descriptor does not permit reading")):s(new Un.EBADF)}function X(t,n,e,r,i){if(i=arguments[arguments.length-1],r=L(r,null,"r"),B(e,i)){var o=_(r.flag||"r");return o?(f(n,e,o,function(a,u){function s(){t.releaseDescriptor(f)}if(a)return i(a);var c=new Vn(e,u.id,o,0),f=t.allocDescriptor(c);g(n,c,function(o,a){if(o)return s(),i(o);var u=new zn(a,t.name);if(u.isDirectory())return s(),i(new Un.EISDIR("illegal operation on directory",e));var f=u.size,l=new Xn(f);l.fill(0),p(n,c,l,0,f,0,function(t){if(s(),t)return i(t);var n;n="utf8"===r.encoding?Fn.decode(l):l,i(null,n)})})}),void 0):i(new Un.EINVAL("flags is not valid",e))}}function W(t,n,r,i,o,a,u,s){s=arguments[arguments.length-1],o=void 0===o?0:o,a=void 0===a?i.length-o:a;var c=t.openFiles[r];c?pn(c.flags).contains(Nn)?a>i.length-o?s(new Un.EIO("intput buffer is too small")):d(n,c,i,o,a,u,e(s)):s(new Un.EBADF("descriptor does not permit writing")):s(new Un.EBADF)}function J(t,n,e,r,i,o){if(o=arguments[arguments.length-1],i=L(i,"utf8","w"),B(e,o)){var a=_(i.flag||"w");if(!a)return o(new Un.EINVAL("flags is not valid",e));r=r||"","number"==typeof r&&(r=""+r),"string"==typeof r&&"utf8"===i.encoding&&(r=Fn.encode(r)),f(n,e,a,function(i,u){if(i)return o(i);var s=new Vn(e,u.id,a,0),c=t.allocDescriptor(s);l(n,s,r,0,r.length,function(n){return t.releaseDescriptor(c),n?o(n):(o(null),void 0)})})}}function H(t,n,e,r,i,o){if(o=arguments[arguments.length-1],i=L(i,"utf8","a"),B(e,o)){var a=_(i.flag||"a");if(!a)return o(new Un.EINVAL("flags is not valid",e));r=r||"","number"==typeof r&&(r=""+r),"string"==typeof r&&"utf8"===i.encoding&&(r=Fn.encode(r)),f(n,e,a,function(i,u){if(i)return o(i);var s=new Vn(e,u.id,a,u.size),c=t.allocDescriptor(s);d(n,s,r,0,r.length,s.position,function(n){return t.releaseDescriptor(c),n?o(n):(o(null),void 0)})})}}function G(t,n,e,r){function i(t){r(t?!1:!0)}P(t,n,e,i)}function Q(t,n,r,i,o){B(r,o)&&x(n,r,i,e(o))}function K(t,n,r,i,o){var a=t.openFiles[r];a?N(n,a,i,e(o)):o(new Un.EBADF)}function Z(t,n,r,i,o,a,u){"function"==typeof a&&(u=a,a=null),B(r,u)&&T(n,r,i,o,a,e(u))}function $(t,n,r,i,o,a,u){"function"==typeof a&&(u=a,a=null);var s=t.openFiles[r];s?pn(s.flags).contains(Nn)?S(n,s,i,o,a,e(u)):u(new Un.EBADF("descriptor does not permit writing")):u(new Un.EBADF)}function tn(t,n,r,i,o){B(r,o)&&D(n,r,i,e(o))}function nn(t,n,r,i,o){var a=t.openFiles[r];a?pn(a.flags).contains(Nn)?R(n,a,i,e(o)):o(new Un.EBADF("descriptor does not permit writing")):o(new Un.EBADF)}function en(t,n,e,r,i,o){function a(t,n){t?o(t):0>n.size+r?o(new Un.EINVAL("resulting file offset would be negative")):(u.position=n.size+r,o(null,u.position))}var u=t.openFiles[e];u||o(new Un.EBADF),"SET"===i?0>r?o(new Un.EINVAL("resulting file offset would be negative")):(u.position=r,o(null,u.position)):"CUR"===i?0>u.position+r?o(new Un.EINVAL("resulting file offset would be negative")):(u.position+=r,o(null,u.position)):"END"===i?g(n,u,a):o(new Un.EINVAL("whence argument is not a proper value"))}function rn(t,n,r,i){B(r,i)&&E(n,r,e(i))}function on(t,n,r,i,o,a){if(B(r,a)){var u=Date.now();i=i?i:u,o=o?o:u,A(n,r,i,o,e(a))}}function an(t,n,r,i,o,a){var u=Date.now();i=i?i:u,o=o?o:u;var s=t.openFiles[r];s?pn(s.flags).contains(Nn)?j(n,s,i,o,e(a)):a(new Un.EBADF("descriptor does not permit writing")):a(new Un.EBADF)}function un(t,n,r,i,o){function a(t){t?o(t):y(n,r,e(o))}B(r,o)&&B(i,o)&&m(n,r,i,a)}function sn(t,n,r,i,o,a){a=arguments[arguments.length-1],B(r,a)&&B(i,a)&&b(n,r,i,e(a))}function cn(t,n,r,i){B(r,i)&&w(n,r,e(i))}function fn(t,n,e,r){function i(n,e){if(n)r(n);else{var i=new zn(e,t.name);r(null,i)}}B(e,r)&&v(n,e,i)}function ln(t,n,r,i,o){o=arguments[arguments.length-1],i=i||0,B(r,o)&&I(n,r,i,e(o))}function dn(t,n,r,i,o){o=arguments[arguments.length-1],i=i||0;var a=t.openFiles[r];a?pn(a.flags).contains(Nn)?O(n,a,i,e(o)):o(new Un.EBADF("descriptor does not permit writing")):o(new Un.EBADF)}var pn=t("../../lib/nodash.js"),hn=t("../path.js"),gn=hn.normalize,vn=hn.dirname,mn=hn.basename,yn=hn.isAbsolute,En=hn.isNull,bn=t("../constants.js"),wn=bn.MODE_FILE,In=bn.MODE_DIRECTORY,On=bn.MODE_SYMBOLIC_LINK,An=bn.MODE_META,jn=bn.ROOT_DIRECTORY_NAME,Tn=bn.SUPER_NODE_ID,Sn=bn.SYMLOOP_MAX,xn=bn.O_READ,Nn=bn.O_WRITE,Dn=bn.O_CREATE,Rn=bn.O_EXCLUSIVE;bn.O_TRUNCATE;var _n=bn.O_APPEND,Ln=bn.O_FLAGS,Bn=bn.XATTR_CREATE,Mn=bn.XATTR_REPLACE,kn=bn.FS_NOMTIME,Cn=bn.FS_NOCTIME,Fn=t("../encoding.js"),Un=t("../errors.js"),Pn=t("../directory-entry.js"),Vn=t("../open-file-description.js"),Yn=t("../super-node.js"),qn=t("../node.js"),zn=t("../stats.js"),Xn=t("../buffer.js");n.exports={ensureRootDirectory:u,open:M,close:k,mknod:C,mkdir:F,rmdir:U,unlink:q,stat:P,fstat:V,link:Y,read:z,readFile:X,write:W,writeFile:J,appendFile:H,exists:G,getxattr:Q,fgetxattr:K,setxattr:Z,fsetxattr:$,removexattr:tn,fremovexattr:nn,lseek:en,readdir:rn,utimes:on,futimes:an,rename:un,symlink:sn,readlink:cn,lstat:fn,truncate:ln,ftruncate:dn}},{"../../lib/nodash.js":4,"../buffer.js":11,"../constants.js":12,"../directory-entry.js":13,"../encoding.js":14,"../errors.js":15,"../node.js":20,"../open-file-description.js":21,"../path.js":22,"../stats.js":31,"../super-node.js":32}],17:[function(t,n){function e(t){return"function"==typeof t?t:function(t){if(t)throw t}}function r(t,n){function e(){_.forEach(function(t){t.call(this)}.bind(N)),_=null}function r(t){return function(n){function e(n){var r=j();t.getObject(r,function(t,i){return t?(n(t),void 0):(i?e(n):n(null,r),void 0)})}return i(g).contains(p)?(n(null,j()),void 0):(e(n),void 0)}}function u(t){if(t.length){var n=v.getInstance();t.forEach(function(t){n.emit(t.event,t.path)})}}t=t||{},n=n||a;var g=t.flags,j=t.guid?t.guid:E,T=t.provider||new h.Default(t.name||s),S=t.name||T.name,x=i(g).contains(c),N=this;N.readyState=l,N.name=S,N.error=null,N.stdin=b,N.stdout=w,N.stderr=I;var D={},R=O;Object.defineProperty(this,"openFiles",{get:function(){return D}}),this.allocDescriptor=function(t){var n=R++;return D[n]=t,n},this.releaseDescriptor=function(t){delete D[t]};var _=[];this.queueOrRun=function(t){var n;return f==N.readyState?t.call(N):d==N.readyState?n=new y.EFILESYSTEMERROR("unknown error"):_.push(t),n},this.watch=function(t,n,e){if(o(t))throw Error("Path must be a string without null bytes.");
|
|
"function"==typeof n&&(e=n,n={}),n=n||{},e=e||a;var r=new m;return r.start(t,!1,n.recursive),r.on("change",e),r},T.open(function(t){function i(t){function i(t){var n=T[t]();return n.flags=g,n.changes=[],n.guid=r(n),n.close=function(){var t=n.changes;u(t),t.length=0},n}N.provider={openReadWriteContext:function(){return i("getReadWriteContext")},openReadOnlyContext:function(){return i("getReadOnlyContext")}},N.readyState=t?d:f,e(),n(t,N)}if(t)return i(t);var o=T.getReadWriteContext();o.guid=r(o),x?o.clear(function(t){return t?i(t):(A.ensureRootDirectory(o,i),void 0)}):A.ensureRootDirectory(o,i)})}var i=t("../../lib/nodash.js"),o=t("../path.js").isNull,a=t("../shared.js").nop,u=t("../constants.js"),s=u.FILE_SYSTEM_NAME,c=u.FS_FORMAT,f=u.FS_READY,l=u.FS_PENDING,d=u.FS_ERROR,p=u.FS_NODUPEIDCHECK,h=t("../providers/index.js"),g=t("../shell/shell.js"),v=t("../../lib/intercom.js"),m=t("../fs-watcher.js"),y=t("../errors.js"),E=t("../shared.js").guid,b=u.STDIN,w=u.STDOUT,I=u.STDERR,O=u.FIRST_DESCRIPTOR,A=t("./implementation.js");r.providers=h,["open","close","mknod","mkdir","rmdir","stat","fstat","link","unlink","read","readFile","write","writeFile","appendFile","exists","lseek","readdir","rename","readlink","symlink","lstat","truncate","ftruncate","utimes","futimes","setxattr","getxattr","fsetxattr","fgetxattr","removexattr","fremovexattr"].forEach(function(t){r.prototype[t]=function(){var n=this,r=Array.prototype.slice.call(arguments,0),i=r.length-1,o="function"!=typeof r[i],a=e(r[i]),u=n.queueOrRun(function(){function e(){u.close(),a.apply(n,arguments)}var u=n.provider.openReadWriteContext();if(d===n.readyState){var s=new y.EFILESYSTEMERROR("filesystem unavailable, operation canceled");return a.call(n,s)}o?r.push(e):r[i]=e;var c=[n,u].concat(r);A[t].apply(null,c)});u&&a(u)}}),r.prototype.Shell=function(t){return new g(this,t)},n.exports=r},{"../../lib/intercom.js":3,"../../lib/nodash.js":4,"../constants.js":12,"../errors.js":15,"../fs-watcher.js":18,"../path.js":22,"../providers/index.js":23,"../shared.js":27,"../shell/shell.js":30,"./implementation.js":16}],18:[function(t,n){function e(){function t(t){(e===t||u&&0===t.indexOf(n))&&a.trigger("change","change",t)}r.call(this);var n,e,a=this,u=!1;a.start=function(r,a,s){if(!e){if(i.isNull(r))throw Error("Path must be a string without null bytes.");e=i.normalize(r),u=s===!0,u&&(n="/"===e?"/":e+"/");var c=o.getInstance();c.on("change",t)}},a.close=function(){var n=o.getInstance();n.off("change",t),a.removeAllListeners("change")}}var r=t("../lib/eventemitter.js"),i=t("./path.js"),o=t("../lib/intercom.js");e.prototype=new r,e.prototype.constructor=e,n.exports=e},{"../lib/eventemitter.js":2,"../lib/intercom.js":3,"./path.js":22}],19:[function(t,n){n.exports={FileSystem:t("./filesystem/interface.js"),Buffer:t("./buffer.js"),Path:t("./path.js"),Errors:t("./errors.js")}},{"./buffer.js":11,"./errors.js":15,"./filesystem/interface.js":17,"./path.js":22}],20:[function(t,n){function e(t){var n=Date.now();this.id=t.id,this.mode=t.mode||i,this.size=t.size||0,this.atime=t.atime||n,this.ctime=t.ctime||n,this.mtime=t.mtime||n,this.flags=t.flags||[],this.xattrs=t.xattrs||{},this.nlinks=t.nlinks||0,this.version=t.version||0,this.blksize=void 0,this.nblocks=1,this.data=t.data}function r(t,n,e){t[n]?e(null):t.guid(function(r,i){t[n]=i,e(r)})}var i=t("./constants.js").MODE_FILE;e.create=function(t,n){r(t,"id",function(i){return i?(n(i),void 0):(r(t,"data",function(r){return r?(n(r),void 0):(n(null,new e(t)),void 0)}),void 0)})},n.exports=e},{"./constants.js":12}],21:[function(t,n){n.exports=function(t,n,e,r){this.path=t,this.id=n,this.flags=e,this.position=r}},{}],22:[function(t,n,e){function r(t,n){for(var e=0,r=t.length-1;r>=0;r--){var i=t[r];"."===i?t.splice(r,1):".."===i?(t.splice(r,1),e++):e&&(t.splice(r,1),e--)}if(n)for(;e--;e)t.unshift("..");return t}function i(){for(var t="",n=!1,e=arguments.length-1;e>=-1&&!n;e--){var i=e>=0?arguments[e]:"/";"string"==typeof i&&i&&(t=i+"/"+t,n="/"===i.charAt(0))}return t=r(t.split("/").filter(function(t){return!!t}),!n).join("/"),(n?"/":"")+t||"."}function o(t){var n="/"===t.charAt(0);return"/"===t.substr(-1),t=r(t.split("/").filter(function(t){return!!t}),!n).join("/"),t||n||(t="."),(n?"/":"")+t}function a(){var t=Array.prototype.slice.call(arguments,0);return o(t.filter(function(t){return t&&"string"==typeof t}).join("/"))}function u(t,n){function r(t){for(var n=0;t.length>n&&""===t[n];n++);for(var e=t.length-1;e>=0&&""===t[e];e--);return n>e?[]:t.slice(n,e-n+1)}t=e.resolve(t).substr(1),n=e.resolve(n).substr(1);for(var i=r(t.split("/")),o=r(n.split("/")),a=Math.min(i.length,o.length),u=a,s=0;a>s;s++)if(i[s]!==o[s]){u=s;break}for(var c=[],s=u;i.length>s;s++)c.push("..");return c=c.concat(o.slice(u)),c.join("/")}function s(t){var n=h(t),e=n[0],r=n[1];return e||r?(r&&(r=r.substr(0,r.length-1)),e+r):"."}function c(t,n){var e=h(t)[2];return n&&e.substr(-1*n.length)===n&&(e=e.substr(0,e.length-n.length)),""===e?"/":e}function f(t){return h(t)[3]}function l(t){return"/"===t.charAt(0)?!0:!1}function d(t){return-1!==(""+t).indexOf("\0")?!0:!1}var p=/^(\/?)([\s\S]+\/(?!$)|\/)?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/]*)?)$/,h=function(t){var n=p.exec(t);return[n[1]||"",n[2]||"",n[3]||"",n[4]||""]};n.exports={normalize:o,resolve:i,join:a,relative:u,sep:"/",delimiter:":",dirname:s,basename:c,extname:f,isAbsolute:l,isNull:d}},{}],23:[function(t,n){var e=t("./indexeddb.js"),r=t("./websql.js"),i=t("./memory.js");n.exports={IndexedDB:e,WebSQL:r,Memory:i,Default:e,Fallback:function(){function t(){throw"[Filer Error] Your browser doesn't support IndexedDB or WebSQL."}return e.isSupported()?e:r.isSupported()?r:(t.isSupported=function(){return!1},t)}()}},{"./indexeddb.js":24,"./memory.js":25,"./websql.js":26}],24:[function(t,n){(function(e){function r(t,n){var e=t.transaction(s,n);this.objectStore=e.objectStore(s)}function i(t,n,e){try{var r=t.get(n);r.onsuccess=function(t){var n=t.target.result;e(null,n)},r.onerror=function(t){e(t)}}catch(i){e(i)}}function o(t,n,e,r){try{var i=t.put(e,n);i.onsuccess=function(t){var n=t.target.result;r(null,n)},i.onerror=function(t){r(t)}}catch(o){r(o)}}function a(t){this.name=t||u,this.db=null}var u=t("../constants.js").FILE_SYSTEM_NAME,s=t("../constants.js").FILE_STORE_NAME,c=t("../constants.js").IDB_RW;t("../constants.js").IDB_RO;var f=t("../errors.js"),l=t("../buffer.js"),d=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB;r.prototype.clear=function(t){try{var n=this.objectStore.clear();n.onsuccess=function(){t()},n.onerror=function(n){t(n)}}catch(e){t(e)}},r.prototype.getObject=function(t,n){i(this.objectStore,t,n)},r.prototype.getBuffer=function(t,n){i(this.objectStore,t,function(t,e){return t?n(t):(n(null,new l(e)),void 0)})},r.prototype.putObject=function(t,n,e){o(this.objectStore,t,n,e)},r.prototype.putBuffer=function(t,n,e){o(this.objectStore,t,n.buffer,e)},r.prototype.delete=function(t,n){try{var e=this.objectStore.delete(t);e.onsuccess=function(t){var e=t.target.result;n(null,e)},e.onerror=function(t){n(t)}}catch(r){n(r)}},a.isSupported=function(){return!!d},a.prototype.open=function(t){var n=this;if(n.db)return t();var e=d.open(n.name);e.onupgradeneeded=function(t){var n=t.target.result;n.objectStoreNames.contains(s)&&n.deleteObjectStore(s),n.createObjectStore(s)},e.onsuccess=function(e){n.db=e.target.result,t()},e.onerror=function(){t(new f.EINVAL("IndexedDB cannot be accessed. If private browsing is enabled, disable it."))}},a.prototype.getReadOnlyContext=function(){return new r(this.db,c)},a.prototype.getReadWriteContext=function(){return new r(this.db,c)},n.exports=a}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../buffer.js":11,"../constants.js":12,"../errors.js":15}],25:[function(t,n){function e(t,n){this.readOnly=n,this.objectStore=t}function r(t){this.name=t||i}var i=t("../constants.js").FILE_SYSTEM_NAME,o=t("../../lib/async.js").setImmediate,a=function(){var t={};return function(n){return t.hasOwnProperty(n)||(t[n]={}),t[n]}}();e.prototype.clear=function(t){if(this.readOnly)return o(function(){t("[MemoryContext] Error: write operation on read only context")}),void 0;var n=this.objectStore;Object.keys(n).forEach(function(t){delete n[t]}),o(t)},e.prototype.getObject=e.prototype.getBuffer=function(t,n){var e=this;o(function(){n(null,e.objectStore[t])})},e.prototype.putObject=e.prototype.putBuffer=function(t,n,e){return this.readOnly?(o(function(){e("[MemoryContext] Error: write operation on read only context")}),void 0):(this.objectStore[t]=n,o(e),void 0)},e.prototype.delete=function(t,n){return this.readOnly?(o(function(){n("[MemoryContext] Error: write operation on read only context")}),void 0):(delete this.objectStore[t],o(n),void 0)},r.isSupported=function(){return!0},r.prototype.open=function(t){this.db=a(this.name),o(t)},r.prototype.getReadOnlyContext=function(){return new e(this.db,!0)},r.prototype.getReadWriteContext=function(){return new e(this.db,!1)},n.exports=r},{"../../lib/async.js":1,"../constants.js":12}],26:[function(t,n){(function(e){function r(t,n){var e=this;this.getTransaction=function(r){return e.transaction?(r(e.transaction),void 0):(t[n?"readTransaction":"transaction"](function(t){e.transaction=t,r(t)}),void 0)}}function i(t,n,e){function r(t,n){var r=0===n.rows.length?null:n.rows.item(0).data;e(null,r)}function i(t,n){e(n)}t(function(t){t.executeSql("SELECT data FROM "+s+" WHERE id = ? LIMIT 1;",[n],r,i)})}function o(t,n,e,r){function i(){r(null)}function o(t,n){r(n)}t(function(t){t.executeSql("INSERT OR REPLACE INTO "+s+" (id, data) VALUES (?, ?);",[n,e],i,o)})}function a(t){this.name=t||u,this.db=null}var u=t("../constants.js").FILE_SYSTEM_NAME,s=t("../constants.js").FILE_STORE_NAME,c=t("../constants.js").WSQL_VERSION,f=t("../constants.js").WSQL_SIZE,l=t("../constants.js").WSQL_DESC,d=t("../errors.js"),p=t("../buffer.js"),h=t("base64-arraybuffer");r.prototype.clear=function(t){function n(n,e){t(e)}function e(){t(null)}this.getTransaction(function(t){t.executeSql("DELETE FROM "+s+";",[],e,n)})},r.prototype.getObject=function(t,n){i(this.getTransaction,t,function(t,e){if(t)return n(t);try{e&&(e=JSON.parse(e))}catch(r){return n(r)}n(null,e)})},r.prototype.getBuffer=function(t,n){i(this.getTransaction,t,function(t,e){if(t)return n(t);if(e||""===e){var r=h.decode(e);e=new p(r)}n(null,e)})},r.prototype.putObject=function(t,n,e){var r=JSON.stringify(n);o(this.getTransaction,t,r,e)},r.prototype.putBuffer=function(t,n,e){var r=h.encode(n.buffer);o(this.getTransaction,t,r,e)},r.prototype.delete=function(t,n){function e(){n(null)}function r(t,e){n(e)}this.getTransaction(function(n){n.executeSql("DELETE FROM "+s+" WHERE id = ?;",[t],e,r)})},a.isSupported=function(){return!!e.openDatabase},a.prototype.open=function(t){function n(n,e){5===e.code&&t(new d.EINVAL("WebSQL cannot be accessed. If private browsing is enabled, disable it.")),t(e)}function r(){i.db=o,t()}var i=this;if(i.db)return t();var o=e.openDatabase(i.name,c,l,f);return o?(o.transaction(function(t){function e(t){t.executeSql("CREATE INDEX IF NOT EXISTS idx_"+s+"_id"+" on "+s+" (id);",[],r,n)}t.executeSql("CREATE TABLE IF NOT EXISTS "+s+" (id unique, data TEXT);",[],e,n)}),void 0):(t("[WebSQL] Unable to open database."),void 0)},a.prototype.getReadOnlyContext=function(){return new r(this.db,!0)},a.prototype.getReadWriteContext=function(){return new r(this.db,!1)},n.exports=a}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../buffer.js":11,"../constants.js":12,"../errors.js":15,"base64-arraybuffer":5}],27:[function(t,n){function e(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=0|16*Math.random(),e="x"==t?n:8|3&n;return e.toString(16)}).toUpperCase()}function r(){}function i(t){for(var n=[],e=t.length,r=0;e>r;r++)n[r]=t[r];return n}n.exports={guid:e,u8toArray:i,nop:r}},{}],28:[function(t,n){var e=t("../constants.js").ENVIRONMENT;n.exports=function(t){t=t||{},t.TMP=t.TMP||e.TMP,t.PATH=t.PATH||e.PATH,this.get=function(n){return t[n]},this.set=function(n,e){t[n]=e}}},{"../constants.js":12}],29:[function(t,n){var e=t("request");n.exports.download=function(t,n){e({url:t,method:"GET",encoding:null},function(t,e,r){var i,o;return e=e||null,i=e&&e.statusCode,(o=200!==i?{message:t||"Not found!",code:i}:null)?(n(o,null),void 0):(n(null,r),void 0)})}},{request:6}],30:[function(t,n){function e(t,n){n=n||{};var e=new o(n.env),a="/";Object.defineProperty(this,"fs",{get:function(){return t},enumerable:!0}),Object.defineProperty(this,"env",{get:function(){return e},enumerable:!0}),this.cd=function(n,e){n=r.resolve(a,n),t.stat(n,function(t,r){return t?(e(new i.ENOTDIR(null,n)),void 0):("DIRECTORY"===r.type?(a=n,e()):e(new i.ENOTDIR(null,n)),void 0)})},this.pwd=function(){return a}}var r=t("../path.js"),i=t("../errors.js"),o=t("./environment.js"),a=t("../../lib/async.js"),u=t("./network.js");t("../encoding.js"),e.prototype.exec=function(t,n,e){var i=this,o=i.fs;"function"==typeof n&&(e=n,n=[]),n=n||[],e=e||function(){},t=r.resolve(i.pwd(),t),o.readFile(t,"utf8",function(t,r){if(t)return e(t),void 0;try{var i=Function("fs","args","callback",r);i(o,n,e)}catch(a){e(a)}})},e.prototype.touch=function(t,n,e){function i(t){u.writeFile(t,"",e)}function o(t){var r=Date.now(),i=n.date||r,o=n.date||r;u.utimes(t,i,o,e)}var a=this,u=a.fs;"function"==typeof n&&(e=n,n={}),n=n||{},e=e||function(){},t=r.resolve(a.pwd(),t),u.stat(t,function(r){r?n.updateOnly===!0?e():i(t):o(t)})},e.prototype.cat=function(t,n){function e(t,n){var e=r.resolve(o.pwd(),t);u.readFile(e,"utf8",function(t,e){return t?(n(t),void 0):(s+=e+"\n",n(),void 0)})}var o=this,u=o.fs,s="";return n=n||function(){},t?(t="string"==typeof t?[t]:t,a.eachSeries(t,e,function(t){t?n(t):n(null,s.replace(/\n$/,""))}),void 0):(n(new i.EINVAL("Missing files argument")),void 0)},e.prototype.ls=function(t,n,e){function o(t,e){var i=r.resolve(u.pwd(),t),c=[];s.readdir(i,function(t,u){function f(t,e){t=r.join(i,t),s.stat(t,function(a,u){if(a)return e(a),void 0;var s={path:r.basename(t),links:u.nlinks,size:u.size,modified:u.mtime,type:u.type};n.recursive&&"DIRECTORY"===u.type?o(r.join(i,s.path),function(t,n){return t?(e(t),void 0):(s.contents=n,c.push(s),e(),void 0)}):(c.push(s),e())})}return t?(e(t),void 0):(a.eachSeries(u,f,function(t){e(t,c)}),void 0)})}var u=this,s=u.fs;return"function"==typeof n&&(e=n,n={}),n=n||{},e=e||function(){},t?(o(t,e),void 0):(e(new i.EINVAL("Missing dir argument")),void 0)},e.prototype.rm=function(t,n,e){function o(t,e){t=r.resolve(u.pwd(),t),s.stat(t,function(u,c){return u?(e(u),void 0):"FILE"===c.type?(s.unlink(t,e),void 0):(s.readdir(t,function(u,c){return u?(e(u),void 0):0===c.length?(s.rmdir(t,e),void 0):n.recursive?(c=c.map(function(n){return r.join(t,n)}),a.eachSeries(c,o,function(n){return n?(e(n),void 0):(s.rmdir(t,e),void 0)}),void 0):(e(new i.ENOTEMPTY(null,t)),void 0)}),void 0)})}var u=this,s=u.fs;return"function"==typeof n&&(e=n,n={}),n=n||{},e=e||function(){},t?(o(t,e),void 0):(e(new i.EINVAL("Missing path argument")),void 0)},e.prototype.tempDir=function(t){var n=this,e=n.fs,r=n.env.get("TMP");t=t||function(){},e.mkdir(r,function(){t(null,r)})},e.prototype.mkdirp=function(t,n){function e(t,n){a.stat(t,function(o,u){if(u){if(u.isDirectory())return n(),void 0;if(u.isFile())return n(new i.ENOTDIR(null,t)),void 0}else{if(o&&"ENOENT"!==o.code)return n(o),void 0;var s=r.dirname(t);"/"===s?a.mkdir(t,function(t){return t&&"EEXIST"!=t.code?(n(t),void 0):(n(),void 0)}):e(s,function(e){return e?n(e):(a.mkdir(t,function(t){return t&&"EEXIST"!=t.code?(n(t),void 0):(n(),void 0)}),void 0)})}})}var o=this,a=o.fs;return n=n||function(){},t?"/"===t?(n(),void 0):(e(t,n),void 0):(n(new i.EINVAL("Missing path argument")),void 0)},e.prototype.wget=function(t,n,e){function o(){e(Error("unable to get resource"))}var a=this,s=a.fs;if("function"==typeof n&&(e=n,n={}),n=n||{},e=e||function(){},!t)return e(new i.EINVAL("Missing url argument")),void 0;var c=n.filename||t.split("/").pop();c=r.resolve(a.pwd(),c),u.download(t,function(t,n){return t||!n?o():(s.writeFile(c,n,function(t){t?e(t):e(null,c)}),void 0)})},n.exports=e},{"../../lib/async.js":1,"../encoding.js":14,"../errors.js":15,"../path.js":22,"./environment.js":28,"./network.js":29}],31:[function(t,n){function e(t,n){this.node=t.id,this.dev=n,this.size=t.size,this.nlinks=t.nlinks,this.atime=t.atime,this.mtime=t.mtime,this.ctime=t.ctime,this.type=t.mode}var r=t("./constants.js");e.prototype.isFile=function(){return this.type===r.MODE_FILE},e.prototype.isDirectory=function(){return this.type===r.MODE_DIRECTORY},e.prototype.isSymbolicLink=function(){return this.type===r.MODE_SYMBOLIC_LINK},e.prototype.isSocket=e.prototype.isFIFO=e.prototype.isCharacterDevice=e.prototype.isBlockDevice=function(){return!1},n.exports=e},{"./constants.js":12}],32:[function(t,n){function e(t){var n=Date.now();this.id=r.SUPER_NODE_ID,this.mode=r.MODE_META,this.atime=t.atime||n,this.ctime=t.ctime||n,this.mtime=t.mtime||n,this.rnode=t.rnode}var r=t("./constants.js");e.create=function(t,n){t.guid(function(r,i){return r?(n(r),void 0):(t.rnode=t.rnode||i,n(null,new e(t)),void 0)})},n.exports=e},{"./constants.js":12}]},{},[19])(19)}); |