filer/dist/filer.min.js

4 lines
80 KiB
JavaScript
Raw Normal View History

2014-12-17 07:35:01 +00:00
/*! filer 0.0.36 2014-12-17 */
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Filer=t()}}(function(){var t;return function e(t,n,r){function i(a,s){if(!n[a]){if(!t[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var c=n[a]={exports:{}};t[a][0].call(c.exports,function(e){var n=t[a][1][e];return i(n?n:e)},c,c.exports,e,t,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;r.length>a;a++)i(r[a]);return i}({1:[function(e,n){(function(e){(function(){var r={};void 0!==e&&e.nextTick?(r.nextTick=e.nextTick,r.setImmediate="undefined"!=typeof setImmediate?function(t){setImmediate(t)}:r.nextTick):"function"==typeof setImmediate?(r.nextTick=function(t){setImmediate(t)},r.setImmediate=r.nextTick):(r.nextTick=function(t){setTimeout(t,0)},r.setImmediate=r.nextTick),r.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],function(e){e?(n(e),n=function(){}):(r+=1,r>=t.length?n():i())})};i()},r.forEachSeries=r.eachSeries,t!==void 0&&t.amd?t([],function(){return r}):n!==void 0&&n.exports?n.exports=r:root.async=r})()}).call(this,e("JkpR2F"))},{JkpR2F:10}],2:[function(t,e){function n(t,e){for(var n=e.length-1;n>=0;n--)e[n]===t&&e.splice(n,1);return e}var r=function(){};r.createInterface=function(t){var e={};return e.on=function(e,n){this[t]===void 0&&(this[t]={}),this[t].hasOwnProperty(e)||(this[t][e]=[]),this[t][e].push(n)},e.off=function(e,r){void 0!==this[t]&&this[t].hasOwnProperty(e)&&n(r,this[t][e])},e.trigger=function(e){if(this[t]!==void 0&&this[t].hasOwnProperty(e))for(var n=Array.prototype.slice.call(arguments,1),r=0;this[t][e].length>r;r++)this[t][e][r].apply(this[t][e][r],n)},e.removeAllListeners=function(e){if(void 0!==this[t]){var n=this;n[t][e].forEach(function(t){n.off(e,t)})}},e};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,e.exports=r},{}],3:[function(t,e){(function(n){function r(t,e){var n=0;return function(){var r=Date.now();r-n>t&&(n=r,e.apply(this,arguments))}}function i(t,e){if(void 0!==t&&t||(t={}),"object"==typeof e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function o(){var t=this,e=Date.now();this.origin=s(),this.lastMessage=e,this.receivedIDs={},this.previousValues={};var r=function(){t._onStorageEvent.apply(t,arguments)};"undefined"!=typeof document&&(document.attachEvent?document.attachEvent("onstorage",r):n.addEventListener("storage",r,!1))}var a=t("./eventemitter.js"),s=t("../src/shared.js").guid,u=function(t){return t===void 0||t.localStorage===void 0?{getItem:function(){},setItem:function(){},removeItem:function(){}}:t.localStorage}(n);o.prototype._transaction=function(t){function e(){if(!a){var f=Date.now(),h=0|u.getItem(l);if(h&&r>f-h)return s||(o._on("storage",e),s=!0),c=setTimeout(e,i),void 0;a=!0,u.setItem(l,f),t(),n()}}function n(){s&&o._off("storage",e),c&&clearTimeout(c),u.removeItem(l)}var r=1e3,i=20,o=this,a=!1,s=!1,c=null;e()},o.prototype._cleanup_emit=r(100,function(){var t=this;t._transaction(function(){var t,e=Date.now(),n=e-h,r=0;try{t=JSON.parse(u.getItem(c)||"[]")}catch(i){t=[]}for(var o=t.length-1;o>=0;o--)n>t[o].timestamp&&(t.splice(o,1),r++);r>0&&u.setItem(c,JSON.stringify(t))})}),o.prototype._cleanup_once=r(100,function(){var t=this;t._transaction(function(){var e,n;Date.now();var r=0;try{n=JSON.parse(u.getItem(f)||"{}")}catch(i){n={}}for(e in n)t._once_expired(e,n)&&(delete n[e],r++);r>0&&u.setItem(f,JSON.stringify(n))})}),o.prototype._once_expired=function(t,e){if(!e)return!0;if(!e.hasOwnProperty(t))retu
else switch(a){case"/":return!1;case"\\":n(),c=!0;continue;case"?":case"*":case"+":case"@":case"!":if(this.debug("%s %s %s %j <-- stateChar",t,v,s,a),l){this.debug(" in class"),"!"===a&&v===d+1&&(a="^"),s+=a;continue}g.debug("call clearStateChar %j",o),n(),o=a,r.noext&&n();continue;case"(":if(l){s+="(";continue}if(!o){s+="\\(";continue}i=o,f.push({type:i,start:v-1,reStart:s.length}),s+="!"===o?"(?:(?!":"(?:",this.debug("plType %j %j",o,s),o=!1;continue;case")":if(l||!f.length){s+="\\)";continue}switch(n(),u=!0,s+=")",i=f.pop().type){case"!":s+="[^/]*?)";break;case"?":case"+":case"*":s+=i;case"@":}continue;case"|":if(l||!f.length||c){s+="\\|",c=!1;continue}n(),s+="|";continue;case"[":if(n(),l){s+="\\"+a;continue}l=!0,d=v,h=s.length,s+=a;continue;case"]":if(v===d+1||!l){s+="\\"+a,c=!1;continue}u=!0,l=!1,s+=a;continue;default:n(),c?c=!1:!A[a]||"^"===a&&l||(s+="\\"),s+=a}if(l){var b=t.substr(d+1),w=this.parse(b,T);s=s.substr(0,h)+"\\["+w[0],u=u||w[1]}for(var _;_=f.pop();){var j=s.slice(_.reStart+3);j=j.replace(/((?:\\{2})*)(\\?)\|/g,function(t,e,n){return n||(n="\\"),e+e+n+"|"}),this.debug("tail=%j\n %s",j,j);var x="*"===_.type?I:"?"===_.type?O:"\\"+_.type;u=!0,s=s.slice(0,_.reStart)+x+"\\("+j}n(),c&&(s+="\\\\");var S=!1;switch(s.charAt(0)){case".":case"[":case"(":S=!0}if(""!==s&&u&&(s="(?=.)"+s),S&&(s=p+s),e===T)return[s,u];if(!u)return m(t);var N=r.nocase?"i":"",D=RegExp("^"+s+"$",N);return D._glob=t,D._src=s,D}function p(){if(this.regexp||this.regexp===!1)return this.regexp;var t=this.set;if(!t.length)return this.regexp=!1;var e=this.options,n=e.noglobstar?I:e.dot?_:j,r=e.nocase?"i":"",i=t.map(function(t){return t.map(function(t){return t===E?n:"string"==typeof t?v(t):t._src}).join("\\/")}).join("|");i="^(?:"+i+")$",this.negate&&(i="^(?!"+i+").*$");try{return this.regexp=RegExp(i,r)}catch(o){return this.regexp=!1}}function g(t,e){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return""===t;if("/"===t&&e)return!0;var n=this.options;"win32"===r&&(t=t.split("\\").join("/")),t=t.split(x),this.debug(this.pattern,"split",t);var i=this.set;this.debug(this.pattern,"set",i);for(var o,a=t.length-1;a>=0&&!(o=t[a]);a--);for(var a=0,s=i.length;s>a;a++){var u=i[a],c=t;n.matchBase&&1===u.length&&(c=[o]);var f=this.matchOne(c,u,e);if(f)return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}function m(t){return t.replace(/\\(.)/g,"$1")}function v(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}n?n.exports=s:e.minimatch=s,t||(t=function(t){switch(t){case"sigmund":return function(t){return JSON.stringify(t)};case"path":return{basename:function(t){t=t.split(/[\/\\]/);var e=t.pop();return e||(e=t.pop()),e}};case"lru-cache":return function(){var t={},e=0;this.set=function(n,r){e++,e>=100&&(t={}),t[n]=r},this.get=function(e){return t[e]}}}}),s.Minimatch=u;var y=t("lru-cache"),b=s.cache=new y({max:100}),E=s.GLOBSTAR=u.GLOBSTAR={},w=t("sigmund"),O=(t("path"),"[^/]"),I=O+"*?",_="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",j="(?:(?!(?:\\/|^)\\.).)*?",A=i("().*{}+?[]^$\\!"),x=/\/+/;s.filter=o,s.defaults=function(t){if(!t||!Object.keys(t).length)return r;var e=r,n=function r(n,r,i){return e.minimatch(n,r,a(t,i))};return n.Minimatch=function(n,r){return new e.Minimatch(n,a(t,r))},n},u.defaults=function(t){return t&&Object.keys(t).length?s.defaults(t).Minimatch:u},u.prototype.debug=function(){},u.prototype.make=c,u.prototype.parseNegate=f,s.braceExpand=function(t,e){return new u(t,e).braceExpand()},u.prototype.braceExpand=h,u.prototype.parse=d;var T={};s.makeRe=function(t,e){return new u(t,e||{}).makeRe()},u.prototype.makeRe=p,s.match=function(t,e,n){n=n||{};var r=new u(e,n);return t=t.filter(function(t){return r.match(t)}),r.options.nonull&&!t.length&&t.push(e),t},u.prototype.match=g,u.prototype.matchOne=function(t,e,n){var r=this.options;this.debug("matchOne",{"this":this,file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var i=0,o=0,a=t.length,s=e.length;a>i&&s>o;i++,o++){this.debug("matchOne loop");var u=e[o],c=t[i];if(this.debug(e,u,c),u===!1)return!1;if(u===E){this.debug("GLOBSTAR",[e
return l==D.readyState?t.call(D):d==D.readyState?e=new b.EFILESYSTEMERROR("unknown error"):B.push(t),e},this.watch=function(t,e,n){if(a(t))throw Error("Path must be a string without null bytes.");"function"==typeof e&&(n=e,e={}),e=e||{},n=n||s;var r=new y;return r.start(t,!1,e.recursive),r.on("change",n),r},T.open(function(t){function r(t){function r(t){var e=T[t]();return e.flags=A,e.changes=[],e.guid=i(e),e.close=function(){var t=e.changes;u(t),t.length=0},e}D.provider={openReadWriteContext:function(){return r("getReadWriteContext")},openReadOnlyContext:function(){return r("getReadOnlyContext")}},D.readyState=t?d:l,n(),e(t,D)}if(t)return r(t);var o=T.getReadWriteContext();o.guid=i(o),N?o.clear(function(t){return t?r(t):(j.ensureRootDirectory(o,r),void 0)}):j.ensureRootDirectory(o,r)})}var o=t("../../lib/nodash.js"),a=t("../path.js").isNull,s=t("../shared.js").nop,u=t("../constants.js"),c=u.FILE_SYSTEM_NAME,f=u.FS_FORMAT,l=u.FS_READY,h=u.FS_PENDING,d=u.FS_ERROR,p=u.FS_NODUPEIDCHECK,g=t("../providers/index.js"),m=t("../shell/shell.js"),v=t("../../lib/intercom.js"),y=t("../fs-watcher.js"),b=t("../errors.js"),E=t("../shared.js").guid,w=u.STDIN,O=u.STDOUT,I=u.STDERR,_=u.FIRST_DESCRIPTOR,j=t("./implementation.js");i.providers=g,["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){i.prototype[t]=function(){var e=this,r=Array.prototype.slice.call(arguments,0),i=r.length-1,o="function"!=typeof r[i],a=n(r[i]),s=e.queueOrRun(function(){function n(){s.close(),a.apply(e,arguments)}var s=e.provider.openReadWriteContext();if(d===e.readyState){var u=new b.EFILESYSTEMERROR("filesystem unavailable, operation canceled");return a.call(e,u)}o?r.push(n):r[i]=n;var c=[e,s].concat(r);j[t].apply(null,c)});s&&a(s)}}),e.exports=i},{"../../lib/intercom.js":3,"../../lib/nodash.js":4,"../constants.js":15,"../errors.js":18,"../fs-watcher.js":21,"../path.js":25,"../providers/index.js":26,"../shared.js":30,"../shell/shell.js":32,"./implementation.js":19}],21:[function(t,e){function n(){function t(t){(n===t||s&&0===t.indexOf(e))&&a.trigger("change","change",t)}r.call(this);var e,n,a=this,s=!1;a.start=function(r,a,u){if(!n){if(i.isNull(r))throw Error("Path must be a string without null bytes.");n=i.normalize(r),s=u===!0,s&&(e="/"===n?"/":n+"/");var c=o.getInstance();c.on("change",t)}},a.close=function(){var e=o.getInstance();e.off("change",t),a.removeAllListeners("change")}}var r=t("../lib/eventemitter.js"),i=t("./path.js"),o=t("../lib/intercom.js");n.prototype=new r,n.prototype.constructor=n,e.exports=n},{"../lib/eventemitter.js":2,"../lib/intercom.js":3,"./path.js":25}],22:[function(t,e){e.exports={FileSystem:t("./filesystem/interface.js"),Buffer:t("./buffer.js"),Path:t("./path.js"),Errors:t("./errors.js"),Shell:t("./shell/shell.js")}},{"./buffer.js":14,"./errors.js":18,"./filesystem/interface.js":20,"./path.js":25,"./shell/shell.js":32}],23:[function(t,e){function n(t){var e=Date.now();this.id=t.id,this.mode=t.mode||i,this.size=t.size||0,this.atime=t.atime||e,this.ctime=t.ctime||e,this.mtime=t.mtime||e,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,e,n){t[e]?n(null):t.guid(function(r,i){t[e]=i,n(r)})}var i=t("./constants.js").MODE_FILE;n.create=function(t,e){r(t,"id",function(i){return i?(e(i),void 0):(r(t,"data",function(r){return r?(e(r),void 0):(e(null,new n(t)),void 0)}),void 0)})},e.exports=n},{"./constants.js":15}],24:[function(t,e){function n(t,e,n,r){this.path=t,this.id=e,this.flags=n,this.position=r}var r=t("./errors.js");n.prototype.getNode=function(t,e){function n(t,n){return t?e(t):n?(e(null,n),void 0):e(new r.EBADF("file descriptor refers to unknown node",o))}var i=this.id,o=this.path;t.getObject(i,n)},e.exports=n},{"./errors.js":18}],25:[function(t,e,n){f