filer/dist/filer.min.js

4 lines
88 KiB
JavaScript
Raw Normal View History

/*! filer 2014-01-16 */
(function(t,e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Filer||(t.Filer=e())})(this,function(){var t,e,n;(function(r){function i(t,e){return w.call(t,e)}function o(t,e){var n,r,i,o,s,a,c,u,f,l,h=e&&e.split("/"),d=m.map,p=d&&d["*"]||{};if(t&&"."===t.charAt(0))if(e){for(h=h.slice(0,h.length-1),t=h.concat(t.split("/")),u=0;t.length>u;u+=1)if(l=t[u],"."===l)t.splice(u,1),u-=1;else if(".."===l){if(1===u&&(".."===t[2]||".."===t[0]))break;u>0&&(t.splice(u-1,2),u-=2)}t=t.join("/")}else 0===t.indexOf("./")&&(t=t.substring(2));if((h||p)&&d){for(n=t.split("/"),u=n.length;u>0;u-=1){if(r=n.slice(0,u).join("/"),h)for(f=h.length;f>0;f-=1)if(i=d[h.slice(0,f).join("/")],i&&(i=i[r])){o=i,s=u;break}if(o)break;!a&&p&&p[r]&&(a=p[r],c=u)}!o&&a&&(o=a,s=c),o&&(n.splice(0,s,o),t=n.join("/"))}return t}function s(t,e){return function(){return d.apply(r,E.call(arguments,0).concat([t,e]))}}function a(t){return function(e){return o(e,t)}}function c(t){return function(e){v[t]=e}}function u(t){if(i(y,t)){var e=y[t];delete y[t],b[t]=!0,h.apply(r,e)}if(!i(v,t)&&!i(b,t))throw Error("No "+t);return v[t]}function f(t){var e,n=t?t.indexOf("!"):-1;return n>-1&&(e=t.substring(0,n),t=t.substring(n+1,t.length)),[e,t]}function l(t){return function(){return m&&m.config&&m.config[t]||{}}}var h,d,p,g,v={},y={},m={},b={},w=Object.prototype.hasOwnProperty,E=[].slice;p=function(t,e){var n,r=f(t),i=r[0];return t=r[1],i&&(i=o(i,e),n=u(i)),i?t=n&&n.normalize?n.normalize(t,a(e)):o(t,e):(t=o(t,e),r=f(t),i=r[0],t=r[1],i&&(n=u(i))),{f:i?i+"!"+t:t,n:t,pr:i,p:n}},g={require:function(t){return s(t)},exports:function(t){var e=v[t];return e!==void 0?e:v[t]={}},module:function(t){return{id:t,uri:"",exports:v[t],config:l(t)}}},h=function(t,e,n,o){var a,f,l,h,d,m,w=[];if(o=o||t,"function"==typeof n){for(e=!e.length&&n.length?["require","exports","module"]:e,d=0;e.length>d;d+=1)if(h=p(e[d],o),f=h.f,"require"===f)w[d]=g.require(t);else if("exports"===f)w[d]=g.exports(t),m=!0;else if("module"===f)a=w[d]=g.module(t);else if(i(v,f)||i(y,f)||i(b,f))w[d]=u(f);else{if(!h.p)throw Error(t+" missing "+f);h.p.load(h.n,s(o,!0),c(f),{}),w[d]=v[f]}l=n.apply(v[t],w),t&&(a&&a.exports!==r&&a.exports!==v[t]?v[t]=a.exports:l===r&&m||(v[t]=l))}else t&&(v[t]=n)},t=e=d=function(t,e,n,i,o){return"string"==typeof t?g[t]?g[t](e):u(p(t,e).f):(t.splice||(m=t,e.splice?(t=e,e=n,n=null):t=r),e=e||function(){},"function"==typeof n&&(n=i,i=o),i?h(r,t,e,n):setTimeout(function(){h(r,t,e,n)},4),d)},d.config=function(t){return m=t,m.deps&&d(m.deps,m.callback),d},n=function(t,e,n){e.splice||(n=e,e=[]),i(v,t)||i(y,t)||(y[t]=[t,e,n])},n.amd={jQuery:!0}})(),n("build/almond",function(){}),n("nodash",["require"],function(){function t(t,e){return d.call(t,e)}function e(t){return null==t?0:t.length===+t.length?t.length:v(t).length}function n(t){return t}function r(t,e,n){var r,i;if(null!=t)if(u&&t.forEach===u)t.forEach(e,n);else if(t.length===+t.length){for(r=0,i=t.length;i>r;r++)if(e.call(n,t[r],r,t)===g)return}else{var o=o(t);for(r=0,i=o.length;i>r;r++)if(e.call(n,t[o[r]],o[r],t)===g)return}}function i(t,e,i){e||(e=n);var o=!1;return null==t?o:l&&t.some===l?t.some(e,i):(r(t,function(t,n,r){return o||(o=e.call(i,t,n,r))?g:void 0}),!!o)}function o(t,e){return null==t?!1:f&&t.indexOf===f?-1!=t.indexOf(e):i(t,function(t){return t===e})}function s(t){this.value=t}function a(t){return t&&"object"==typeof t&&!Array.isArray(t)&&d.call(t,"__wrapped__")?t:new s(t)}var c=Array.prototype,u=c.forEach,f=c.indexOf,l=c.some,h=Object.prototype,d=h.hasOwnProperty,p=Object.keys,g={},v=p||function(e){if(e!==Object(e))throw new TypeError("Invalid object");var n=[];for(var r in e)t(e,r)&&n.push(r);return n};return s.prototype.has=function(e){return t(this.value,e)},s.prototype.contains=function(t){return o(this.value,t)},s.prototype.size=function(){return e(this.value)},a}),function(t){t["encoding-indexes"]=t["encoding-indexes"]||[]}(this),n("encoding-indexes-shim",function(){}),function(t){function e(t,e,n){return t>=e&&n>=t}function n(t,e){return Math.floor(t/e)}function r(t){var e=0;this.get
return e.prototype.clear=function(t){try{var e=this.objectStore.clear();e.onsuccess=function(){t()},e.onerror=function(e){t(e)}}catch(n){t(n)}},e.prototype.get=function(t,e){try{var n=this.objectStore.get(t);n.onsuccess=function(t){var n=t.target.result;e(null,n)},n.onerror=function(t){e(t)}}catch(r){e(r)}},e.prototype.put=function(t,e,n){try{var r=this.objectStore.put(e,t);r.onsuccess=function(t){var e=t.target.result;n(null,e)},r.onerror=function(t){n(t)}}catch(i){n(i)}},e.prototype.delete=function(t,e){try{var n=this.objectStore.delete(t);n.onsuccess=function(t){var n=t.target.result;e(null,n)},n.onerror=function(t){e(t)}}catch(r){e(r)}},n.isSupported=function(){return!!o},n.prototype.open=function(t){var e=this;if(e.db)return t(null,!1),void 0;var n=!1,r=o.open(e.name);r.onupgradeneeded=function(t){var e=t.target.result;e.objectStoreNames.contains(i)&&e.deleteObjectStore(i),e.createObjectStore(i),n=!0},r.onsuccess=function(r){e.db=r.target.result,t(null,n)},r.onerror=function(e){t(e)}},n.prototype.getReadOnlyContext=function(){return new e(this.db,a)},n.prototype.getReadWriteContext=function(){return new e(this.db,s)},n}),n("src/providers/websql",["require","src/constants","src/constants","src/constants","src/constants","src/constants"],function(t){function e(t,e){var n=this;this.getTransaction=function(r){return n.transaction?(r(n.transaction),void 0):(t[e?"readTransaction":"transaction"](function(t){n.transaction=t,r(t)}),void 0)}}function n(t){this.name=t||r,this.db=null}var r=t("src/constants").FILE_SYSTEM_NAME,i=t("src/constants").FILE_STORE_NAME,o=t("src/constants").WSQL_VERSION,s=t("src/constants").WSQL_SIZE,a=t("src/constants").WSQL_DESC;return e.prototype.clear=function(t){function e(e,n){t(n)}function n(){t(null)}this.getTransaction(function(t){t.executeSql("DELETE FROM "+i,[],n,e)})},e.prototype.get=function(t,e){function n(t,n){var r=0===n.rows.length?null:n.rows.item(0).data;e(null,r)}function r(t,n){e(n)}this.getTransaction(function(e){e.executeSql("SELECT data FROM "+i+" WHERE id = ?",[t],n,r)})},e.prototype.put=function(t,e,n){function r(){n(null)}function o(t,e){n(e)}this.getTransaction(function(n){n.executeSql("INSERT OR REPLACE INTO "+i+" (id, data) VALUES (?, ?)",[t,e],r,o)})},e.prototype.delete=function(t,e){function n(){e(null)}function r(t,n){e(n)}this.getTransaction(function(e){e.executeSql("DELETE FROM "+i+" WHERE id = ?",[t],n,r)})},n.isSupported=function(){return!!window.openDatabase},n.prototype.open=function(t){function e(e,n){t(n)}function n(e){function n(e,n){var r=0===n.rows.item(0).count;t(null,r)}function o(e,n){t(n)}r.db=c,e.executeSql("SELECT COUNT(id) AS count FROM "+i+";",[],n,o)}var r=this;if(r.db)return t(null,!1),void 0;var c=window.openDatabase(r.name,o,a,s);return c?(c.transaction(function(t){t.executeSql("CREATE TABLE IF NOT EXISTS "+i+" (id unique, data)",[],n,e)}),void 0):(t("[WebSQL] Unable to open database."),void 0)},n.prototype.getReadOnlyContext=function(){return new e(this.db,!0)},n.prototype.getReadWriteContext=function(){return new e(this.db,!1)},n}),n("src/providers/memory",["require","src/constants"],function(t){function e(t,e){this.readOnly=e,this.objectStore=t}function n(t){this.name=t||r,this.db={}}var r=t("src/constants").FILE_SYSTEM_NAME;return e.prototype.clear=function(t){if(this.readOnly)return t("[MemoryContext] Error: write operation on read only context");var e=this.objectStore;Object.keys(e).forEach(function(t){delete e[t]}),t(null)},e.prototype.get=function(t,e){e(null,this.objectStore[t])},e.prototype.put=function(t,e,n){return this.readOnly?n("[MemoryContext] Error: write operation on read only context"):(this.objectStore[t]=e,n(null),void 0)},e.prototype.delete=function(t,e){return this.readOnly?e("[MemoryContext] Error: write operation on read only context"):(delete this.objectStore[t],e(null),void 0)},n.isSupported=function(){return!0},n.prototype.open=function(t){t(null,!0)},n.prototype.getReadOnlyContext=function(){return new e(this.db,!0)},n.prototype.getReadWriteContext=function(){return new e(this.db,!1)},n}),n("src/providers/providers",[
},decrypt:function(t,e,n,r){return r=this.cfg.extend(r),e=this._parse(e,r.format),t.createDecryptor(n,r).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t):t}}),e=(e.kdf={}).OpenSSL={compute:function(t,e,n,r){return r||(r=o.random(8)),t=c.create({keySize:e+n}).compute(t,r),n=o.create(t.words.slice(e),4*n),t.sigBytes=4*e,d.create({key:t,iv:n,salt:r})}},g=n.PasswordBasedCipher=p.extend({cfg:p.cfg.extend({kdf:e}),encrypt:function(t,e,n,r){return r=this.cfg.extend(r),n=r.kdf.compute(n,t.keySize,t.ivSize),r.iv=n.iv,t=p.encrypt.call(this,t,e,n.key,r),t.mixIn(n),t},decrypt:function(t,e,n,r){return r=this.cfg.extend(r),e=this._parse(e,r.format),n=r.kdf.compute(n,t.keySize,t.ivSize,e.salt),r.iv=n.iv,p.decrypt.call(this,t,e,n.key,r)}})}(),function(){var t=r,e=t.lib.BlockCipher,n=t.algo,i=[],o=[],s=[],a=[],c=[],u=[],f=[],l=[],h=[],d=[];(function(){for(var t=[],e=0;256>e;e++)t[e]=128>e?e<<1:283^e<<1;for(var n=0,r=0,e=0;256>e;e++){var p=r^r<<1^r<<2^r<<3^r<<4,p=99^(p>>>8^255&p);i[n]=p,o[p]=n;var g=t[n],v=t[g],y=t[v],m=257*t[p]^16843008*p;s[n]=m<<24|m>>>8,a[n]=m<<16|m>>>16,c[n]=m<<8|m>>>24,u[n]=m,m=16843009*y^65537*v^257*g^16843008*n,f[p]=m<<24|m>>>8,l[p]=m<<16|m>>>16,h[p]=m<<8|m>>>24,d[p]=m,n?(n=g^t[t[t[y^g]]],r^=t[t[r]]):n=r=1}})();var p=[0,1,2,4,8,16,32,64,128,27,54],n=n.AES=e.extend({_doReset:function(){for(var t=this._key,e=t.words,n=t.sigBytes/4,t=4*((this._nRounds=n+6)+1),r=this._keySchedule=[],o=0;t>o;o++)if(n>o)r[o]=e[o];else{var s=r[o-1];o%n?n>6&&4==o%n&&(s=i[s>>>24]<<24|i[255&s>>>16]<<16|i[255&s>>>8]<<8|i[255&s]):(s=s<<8|s>>>24,s=i[s>>>24]<<24|i[255&s>>>16]<<16|i[255&s>>>8]<<8|i[255&s],s^=p[0|o/n]<<24),r[o]=r[o-n]^s}for(e=this._invKeySchedule=[],n=0;t>n;n++)o=t-n,s=n%4?r[o]:r[o-4],e[n]=4>n||4>=o?s:f[i[s>>>24]]^l[i[255&s>>>16]]^h[i[255&s>>>8]]^d[i[255&s]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,a,c,u,i)},decryptBlock:function(t,e){var n=t[e+1];t[e+1]=t[e+3],t[e+3]=n,this._doCryptBlock(t,e,this._invKeySchedule,f,l,h,d,o),n=t[e+1],t[e+1]=t[e+3],t[e+3]=n},_doCryptBlock:function(t,e,n,r,i,o,s,a){for(var c=this._nRounds,u=t[e]^n[0],f=t[e+1]^n[1],l=t[e+2]^n[2],h=t[e+3]^n[3],d=4,p=1;c>p;p++)var g=r[u>>>24]^i[255&f>>>16]^o[255&l>>>8]^s[255&h]^n[d++],v=r[f>>>24]^i[255&l>>>16]^o[255&h>>>8]^s[255&u]^n[d++],y=r[l>>>24]^i[255&h>>>16]^o[255&u>>>8]^s[255&f]^n[d++],h=r[h>>>24]^i[255&u>>>16]^o[255&f>>>8]^s[255&l]^n[d++],u=g,f=v,l=y;g=(a[u>>>24]<<24|a[255&f>>>16]<<16|a[255&l>>>8]<<8|a[255&h])^n[d++],v=(a[f>>>24]<<24|a[255&l>>>16]<<16|a[255&h>>>8]<<8|a[255&u])^n[d++],y=(a[l>>>24]<<24|a[255&h>>>16]<<16|a[255&u>>>8]<<8|a[255&f])^n[d++],h=(a[h>>>24]<<24|a[255&u>>>16]<<16|a[255&f>>>8]<<8|a[255&l])^n[d++],t[e]=g,t[e+1]=v,t[e+2]=y,t[e+3]=h},keySize:8});t.AES=e._createHelper(n)}(),n("crypto-js/rollups/aes",function(){}),n("src/adapters/crypto",["require","crypto-js/rollups/aes","encoding"],function(t){function e(t){for(var e=t.length,n=[],r=0;e>r;r++)n[r>>>2]|=(255&t[r])<<24-8*(r%4);return a.create(n,e)}function n(t){return new TextEncoder("utf-8").encode(t)}function i(t){return new TextDecoder("utf-8").decode(t)}function o(t,e,n){this.context=t,this.encrypt=e,this.decrypt=n}function s(t,o){this.provider=o;var s=r.AES;this.encrypt=function(r){var i=e(r),o=s.encrypt(i,t),a=n(o);return a},this.decrypt=function(e){var o=i(e),a=s.decrypt(o,t),c=a.toString(r.enc.Utf8),u=n(c);return u}}t("crypto-js/rollups/aes");var a=r.lib.WordArray;return t("encoding"),o.prototype.clear=function(t){this.context.clear(t)},o.prototype.get=function(t,e){var n=this.decrypt;this.context.get(t,function(t,r){return t?(e(t),void 0):(r&&(r=n(r)),e(null,r),void 0)})},o.prototype.put=function(t,e,n){var r=this.encrypt(e);this.context.put(t,r,n)},o.prototype.delete=function(t,e){this.context.delete(t,e)},s.isSupported=function(){return!0},s.prototype.open=function(t){this.provider.open(t)},s.prototype.getReadOnlyContext=function(){return new o(this.provider.getReadOnlyContext(),this.encrypt,this.decrypt)},s.prototype.getReadWriteContext=function(){return new o(this.provider.getReadWriteContext(),this.encrypt,this.decrypt)}