filer/dist/filer.min.js

4 lines
64 KiB
JavaScript
Raw Normal View History

2014-10-24 11:57:19 +00:00
/*! filer 0.0.34 2014-10-24 */
2014-10-24 11:56:16 +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
2014-10-24 11:57:19 +00:00
}function u(n,i){n?r(n):i.mode!=we?r(new Ce.ENOTDIR(null,e)):(p=i,t.getObject(p.data,s))}function s(t,n){t?r(t):(h=n,le(h).size()>0?r(new Ce.ENOTEMPTY(null,e)):c())}function f(e){if(e)r(e);else{var i=Date.now();n(t,E,g,{mtime:i,ctime:i},l)}}function c(){delete v[m],t.putObject(g.data,v,f)}function l(e){e?r(e):t.delete(p.id,d)}function d(e){e?r(e):t.delete(p.data,r)}e=pe(e);var p,h,g,v,m=ge(e),E=he(e);i(t,E,o)}function f(t,e,r,o){function a(n,r){n?o(n):r.mode!==we?o(new Ce.ENOENT(null,e)):(v=r,t.getObject(v.data,u))}function u(n,i){n?o(n):(m=i,le(m).has(b)?le(r).contains(xe)?o(new Ce.ENOENT("O_CREATE and O_EXCLUSIVE are set, and the named file exists",e)):(E=m[b],E.type==we&&le(r).contains(Se)?o(new Ce.EISDIR("the named file is a directory and O_WRITE is set",e)):t.getObject(E.id,s)):le(r).contains(Ne)?l():o(new Ce.ENOENT("O_CREATE is not set and the named file does not exist",e)))}function s(t,n){if(t)o(t);else{var r=n;r.mode==be?(O++,O>Te?o(new Ce.ELOOP(null,e)):f(r.data)):c(void 0,r)}}function f(n){n=pe(n),I=he(n),b=ge(n),Oe==b&&(le(r).contains(Se)?o(new Ce.EISDIR("the named file is a directory and O_WRITE is set",e)):i(t,e,c)),i(t,I,a)}function c(t,e){t?o(t):(y=e,o(null,y))}function l(){Ve.create({guid:t.guid,mode:ye},function(e,n){return e?(o(e),void 0):(y=n,y.nlinks+=1,t.putObject(y.id,y,d),void 0)})}function d(e){e?o(e):(w=new Xe(0),w.fill(0),t.putBuffer(y.data,w,h))}function p(e){if(e)o(e);else{var r=Date.now();n(t,I,v,{mtime:r,ctime:r},g)}}function h(e){e?o(e):(m[b]=new ke(y.id,ye),t.putObject(v.data,m,p))}function g(t){t?o(t):o(null,y)}e=pe(e);var v,m,E,y,w,b=ge(e),I=he(e),O=0;Oe==b?le(r).contains(Se)?o(new Ce.EISDIR("the named file is a directory and O_WRITE is set",e)):i(t,e,c):i(t,I,a)}function c(t,e,r,i,o,a){function u(t){t?a(t):a(null,o)}function s(r){if(r)a(r);else{var i=Date.now();n(t,e.path,l,{mtime:i,ctime:i},u)}}function f(e){e?a(e):t.putObject(l.id,l,s)}function c(n,u){if(n)a(n);else{l=u;var s=new Xe(o);s.fill(0),r.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 l(t,e,r,i,o,a,u){function s(t){t?u(t):u(null,o)}function f(r){if(r)u(r);else{var i=Date.now();n(t,e.path,p,{mtime:i,ctime:i},s)}}function c(e){e?u(e):t.putObject(p.id,p,f)}function l(n,s){if(n)u(n);else{if(h=s,!h)return u(new Ce.EIO("Expected Buffer"));var f=void 0!==a&&null!==a?a:e.position,l=Math.max(h.length,f+o),d=new Xe(l);d.fill(0),h&&h.copy(d),r.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 d(t,e,n,r,i,o,a){function u(t,u){if(t)a(t);else{if(c=u,!c)return a(new Ce.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 p(t,e,n){e=pe(e),ge(e),i(t,e,n)}function h(t,e,n){e.getNode(t,n)}function g(t,e,n){function r(e,r){e?n(e):(a=r,t.getObject(a.data,o))}function o(r,i){r?n(r):(u=i,le(u).has(s)?t.getObject(u[s].id,n):n(new Ce.ENOENT("a component of the path does not name an existing file",e)))}e=pe(e);var a,u,s=ge(e),f=he(e);Oe==s?i(t,e,n):i(t,f,r)}function v(t,e,r,o){function a(e){e?o(e):n(t,r,y,{ctime:Date.now()},o)}function u(e,n){e?o(e):(y=n,y.nlinks+=1,t.putObject(y.id,y,a))}function s(e){e?o(e):t.getObject(E[w].id,u)}function f(e,n){e?o(e):(E=n,le(E).has(w)?o(new Ce.EEXIST("newpath resolves to an existing file",w)):(E[w]=v[p],t.putObject(m.data,E,s)))}function c(e,n){e?o(e):(m=n,t.getObject(m.data,f))}function l(e,n){e?o(e):(v=n,le(v).has(p)?i(t,b,c):o(new Ce.ENOENT("a component of either path prefix does not exist",p)))}function d(e,n){e?o(e):(g=n,t.getObject(g.data,l))}e=pe(e);var p=ge(e),h=he(e);r=pe(r);var g,v,m,E,y,w=ge(r),b=he(r);i(t,h,d)}function m(t,e,r){function o(e){e?r(e):(delete d[h],t.putObject(l.data,d,function(){var e=Date.now();n(t,g,l,{mtime:e,ctime:e},r)}))}function a(e){e?r(e):t.delete(p.data,o)}function u(i,u){i?r(i):(p=u,p.nlinks-=1,1>p.nlinks?t.delet
}):n(s,function(n){return n?e(n):(a.mkdir(t,function(t){return t&&"EEXIST"!=t.code?(e(t),void 0):(e(),void 0)}),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)});