filer/dist/filer.min.js

4 lines
64 KiB
JavaScript
Raw Normal View History

2014-09-30 20:16:56 +00:00
/*! filer 0.0.32 2014-09-30 */
2014-09-30 20:16:15 +00:00
!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,u){if(!n[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 f=n[a]={exports:{}};t[a][0].call(f.exports,function(e){var n=t[a][1][e];return i(n?n:e)},f,f.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:9}],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=u(),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"),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}(n);o.prototype._transaction=function(t){function e(){if(!a){var c=Date.now(),d=0|s.getItem(l);if(d&&r>c-d)return u||(o._on("storage",e),u=!0),f=setTimeout(e,i),void 0;a=!0,s.setItem(l,c),t(),n()}}function n(){u&&o._off("storage",e),f&&clearTimeout(f),s.removeItem(l)}var r=1e3,i=20,o=this,a=!1,u=!1,f=null;e()},o.prototype._cleanup_emit=r(100,function(){var t=this;t._transaction(function(){var t,e=Date.now(),n=e-d,r=0;try{t=JSON.parse(s.getItem(f)||"[]")}catch(i){t=[]}for(var o=t.length-1;o>=0;o--)n>t[o].timestamp&&(t.splice(o,1),r++);r>0&&s.setItem(f,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(s.getItem(c)||"{}")}catch(i){n={}}for(e in n)t._once_expired(e,n)&&(delete n[e],r++);r>0&&s.setItem(c,JSON.stringify(n))})}),o.prototype._once_expired=function(t,e){if(!e)return!0;if(!e.hasOwnProperty(t))retur
}e=he(e);var l,d,p,h,g=ve(e),v=ge(e);o(t,e,i)}function f(t,e,n){function i(e,r){e?n(e):(g=r,t.getObject(g.data,a))}function a(r,i){r?n(r):je==m?n(new ke.EBUSY(null,e)):de(i).has(m)?(v=i,p=v[m].id,t.getObject(p,u)):n(new ke.ENOENT(null,e))}function u(r,i){r?n(r):i.mode!=be?n(new ke.ENOTDIR(null,e)):(p=i,t.getObject(p.data,s))}function s(t,r){t?n(t):(h=r,de(h).size()>0?n(new ke.ENOTEMPTY(null,e)):c())}function f(e){if(e)n(e);else{var i=Date.now();r(t,E,g,{mtime:i,ctime:i},l)}}function c(){delete v[m],t.putObject(g.data,v,f)}function l(e){e?n(e):t.delete(p.id,d)}function d(e){e?n(e):t.delete(p.data,n)}e=he(e);var p,h,g,v,m=ve(e),E=ge(e);o(t,E,i)}function c(t,e,n,i){function a(n,r){n?i(n):r.mode!==be?i(new ke.ENOENT(null,e)):(v=r,t.getObject(v.data,u))}function u(r,o){r?i(r):(m=o,de(m).has(b)?de(n).contains(De)?i(new ke.ENOENT("O_CREATE and O_EXCLUSIVE are set, and the named file exists",e)):(E=m[b],E.type==be&&de(n).contains(xe)?i(new ke.EISDIR("the named file is a directory and O_WRITE is set",e)):t.getObject(E.id,s)):de(n).contains(Ne)?l():i(new ke.ENOENT("O_CREATE is not set and the named file does not exist",e)))}function s(t,n){if(t)i(t);else{var r=n;r.mode==Ie?(O++,O>Ae?i(new ke.ELOOP(null,e)):f(r.data)):c(void 0,r)}}function f(r){r=he(r),I=ge(r),b=ve(r),je==b&&(de(n).contains(xe)?i(new ke.EISDIR("the named file is a directory and O_WRITE is set",e)):o(t,e,c)),o(t,I,a)}function c(t,e){t?i(t):(y=e,i(null,y))}function l(){Ye.create({guid:t.guid,mode:we},function(e,n){return e?(i(e),void 0):(y=n,y.nlinks+=1,t.putObject(y.id,y,d),void 0)})}function d(e){e?i(e):(w=new We(0),w.fill(0),t.putBuffer(y.data,w,h))}function p(e){if(e)i(e);else{var n=Date.now();r(t,I,v,{mtime:n,ctime:n},g)}}function h(e){e?i(e):(m[b]=new Pe(y.id,we),t.putObject(v.data,m,p))}function g(t){t?i(t):i(null,y)}e=he(e);var v,m,E,y,w,b=ve(e),I=ge(e),O=0;je==b?de(n).contains(xe)?i(new ke.EISDIR("the named file is a directory and O_WRITE is set",e)):o(t,e,c):o(t,I,a)}function l(t,e,n,i,o,a){function u(t){t?a(t):a(null,o)}function s(n){if(n)a(n);else{var i=Date.now();r(t,e.path,l,{mtime:i,ctime:i},u)}}function f(e){e?a(e):t.putObject(l.id,l,s)}function c(r,u){if(r)a(r);else{l=u;var s=new We(o);s.fill(0),n.copy(s,0,i,i+o),e.position=o,l.size=o,l.version+=1,t.putBuffer(l.data,s,f)}}var l;t.getObject(e.id,c)}function d(t,e,n,i,o,a,u){function s(t){t?u(t):u(null,o)}function f(n){if(n)u(n);else{var i=Date.now();r(t,e.path,p,{mtime:i,ctime:i},s)}}function c(e){e?u(e):t.putObject(p.id,p,f)}function l(r,s){if(r)u(r);else{if(h=s,!h)return u(new ke.EIO("Expected Buffer"));var f=void 0!==a&&null!==a?a:e.position,l=Math.max(h.length,f+o),d=new We(l);d.fill(0),h&&h.copy(d),n.copy(d,f,i,i+o),void 0===a&&(e.position+=o),p.size=l,p.version+=1,t.putBuffer(p.data,d,c)}}function d(e,n){e?u(e):(p=n,t.getBuffer(p.data,l))}var p,h;t.getObject(e.id,d)}function p(t,e,n,r,i,o,a){function u(t,u){if(t)a(t);else{if(c=u,!c)return a(new ke.EIO("Expected Buffer"));var s=void 0!==o&&null!==o?o:e.position;i=s+i>n.length?i-s:i,c.copy(n,r,s,s+i),void 0===o&&(e.position+=i),a(null,i)}}function s(e,n){e?a(e):(f=n,t.getBuffer(f.data,u))}var f,c;t.getObject(e.id,s)}function h(t,e,r){e=he(e),ve(e),o(t,e,n(r))}function g(t,e,r){t.getObject(e.id,n(r))}function v(t,e,r){function i(e,n){e?r(e):(u=n,t.getObject(u.data,a))}function a(i,o){i?r(i):(s=o,de(s).has(f)?t.getObject(s[f].id,n(r)):r(new ke.ENOENT("a component of the path does not name an existing file",e)))}e=he(e);var u,s,f=ve(e),c=ge(e);je==f?o(t,e,n(r)):o(t,c,i)}function m(t,e,n,i){function a(e){e?i(e):r(t,n,y,{ctime:Date.now()},i)}function u(e,n){e?i(e):(y=n,y.nlinks+=1,t.putObject(y.id,y,a))}function s(e){e?i(e):t.getObject(E[w].id,u)}function f(e,n){e?i(e):(E=n,de(E).has(w)?i(new ke.EEXIST("newpath resolves to an existing file",w)):(E[w]=v[p],t.putObject(m.data,E,s)))}function c(e,n){e?i(e):(m=n,t.getObject(m.data,f))}function l(e,n){e?i(e):(v=n,de(v).has(p)?o(t,b,c):i(new ke.ENOENT("a component of either path prefix does not exist",p)))}function d(e,n){e?i(e):(g=n,t.getObject(g.data,l))}e=he(e);var p=ve(e),h=ge(e);n=he(n);var g,v,m,E,y,w
}),void 0)})}})}var o=this,a=o.fs;return e=e||function(){},t?"/"===t?(e(),void 0):(n(t,e),void 0):(e(new i.EINVAL("Missing path argument")),void 0)},e.exports=n},{"../../lib/async.js":1,"../encoding.js":13,"../errors.js":14,"../path.js":21,"./environment.js":27}],29:[function(t,e){function n(t,e){this.node=t.id,this.dev=e,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");n.prototype.isFile=function(){return this.type===r.MODE_FILE},n.prototype.isDirectory=function(){return this.type===r.MODE_DIRECTORY},n.prototype.isSymbolicLink=function(){return this.type===r.MODE_SYMBOLIC_LINK},n.prototype.isSocket=n.prototype.isFIFO=n.prototype.isCharacterDevice=n.prototype.isBlockDevice=function(){return!1},e.exports=n},{"./constants.js":11}],30:[function(t,e){function n(t){var e=Date.now();this.id=r.SUPER_NODE_ID,this.mode=r.MODE_META,this.atime=t.atime||e,this.ctime=t.ctime||e,this.mtime=t.mtime||e,this.rnode=t.rnode}var r=t("./constants.js");n.create=function(t,e){t.guid(function(r,i){return r?(e(r),void 0):(t.rnode=t.rnode||i,e(null,new n(t)),void 0)})},e.exports=n},{"./constants.js":11}]},{},[18])(18)});