filer/dist/idbfs.min.js

4 lines
94 KiB
JavaScript
Raw Normal View History

/*! idbfs 2013-12-02 */
(function(t,e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):t.IDBFS||(t.IDBFS=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,c,a,u,f,l,d=e&&e.split("/"),h=_.map,p=h&&h["*"]||{};if(t&&"."===t.charAt(0))if(e){for(d=d.slice(0,d.length-1),t=d.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((d||p)&&h){for(n=t.split("/"),u=n.length;u>0;u-=1){if(r=n.slice(0,u).join("/"),d)for(f=d.length;f>0;f-=1)if(i=h[d.slice(0,f).join("/")],i&&(i=i[r])){o=i,s=u;break}if(o)break;!c&&p&&p[r]&&(c=p[r],a=u)}!o&&c&&(o=c,s=a),o&&(n.splice(0,s,o),t=n.join("/"))}return t}function s(t,e){return function(){return h.apply(r,x.call(arguments,0).concat([t,e]))}}function c(t){return function(e){return o(e,t)}}function a(t){return function(e){v[t]=e}}function u(t){if(i(y,t)){var e=y[t];delete y[t],m[t]=!0,d.apply(r,e)}if(!i(v,t)&&!i(m,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 _&&_.config&&_.config[t]||{}}}var d,h,p,g,v={},y={},_={},m={},w=Object.prototype.hasOwnProperty,x=[].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,c(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)}}},d=function(t,e,n,o){var c,f,l,d,h,_,w=[];if(o=o||t,"function"==typeof n){for(e=!e.length&&n.length?["require","exports","module"]:e,h=0;e.length>h;h+=1)if(d=p(e[h],o),f=d.f,"require"===f)w[h]=g.require(t);else if("exports"===f)w[h]=g.exports(t),_=!0;else if("module"===f)c=w[h]=g.module(t);else if(i(v,f)||i(y,f)||i(m,f))w[h]=u(f);else{if(!d.p)throw Error(t+" missing "+f);d.p.load(d.n,s(o,!0),a(f),{}),w[h]=v[f]}l=n.apply(v[t],w),t&&(c&&c.exports!==r&&c.exports!==v[t]?v[t]=c.exports:l===r&&_||(v[t]=l))}else t&&(v[t]=n)},t=e=h=function(t,e,n,i,o){return"string"==typeof t?g[t]?g[t](e):u(p(t,e).f):(t.splice||(_=t,e.splice?(t=e,e=n,n=null):t=r),e=e||function(){},"function"==typeof n&&(n=i,i=o),i?d(r,t,e,n):setTimeout(function(){d(r,t,e,n)},4),h)},h.config=function(t){return _=t,_.deps&&h(_.deps,_.callback),h},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 h.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 c(t){return t&&"object"==typeof t&&!Array.isArray(t)&&h.call(t,"__wrapped__")?t:new s(t)}var a=Array.prototype,u=a.forEach,f=a.indexOf,l=a.some,d=Object.prototype,h=d.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)},c}),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
},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,c)},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,c=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=a,e.executeSql("SELECT COUNT(id) AS count FROM "+i+";",[],n,o)}var r=this;if(r.db)return t(null,!1),void 0;var a=window.openDatabase(r.name,o,c,s);return a?(a.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",["require","src/providers/indexeddb","src/providers/websql","src/providers/memory"],function(t){var
e[n]=1&t[r>>>5]>>>31-r%32}for(t=this._subKeys=[],r=0;16>r;r++){for(var i=t[r]=[],o=u[r],n=0;24>n;n++)i[0|n/6]|=e[(a[n]-1+o)%28]<<31-n%6,i[4+(0|n/6)]|=e[28+(a[n+24]-1+o)%28]<<31-n%6;for(i[0]=i[0]<<1|i[0]>>>31,n=1;7>n;n++)i[n]>>>=4*(n-1)+3;i[7]=i[7]<<5|i[7]>>>27}for(e=this._invSubKeys=[],n=0;16>n;n++)e[n]=t[15-n]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(n,r,i){this._lBlock=n[r],this._rBlock=n[r+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var o=0;16>o;o++){for(var s=i[o],c=this._lBlock,a=this._rBlock,u=0,d=0;8>d;d++)u|=f[d][((a^s[d])&l[d])>>>0];this._lBlock=a,this._rBlock=c^u}i=this._lBlock,this._lBlock=this._rBlock,this._rBlock=i,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),n[r]=this._lBlock,n[r+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});n.DES=i._createHelper(d),s=s.TripleDES=i.extend({_doReset:function(){var t=this._key.words;this._des1=d.createEncryptor(o.create(t.slice(0,2))),this._des2=d.createEncryptor(o.create(t.slice(2,4))),this._des3=d.createEncryptor(o.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),n.TripleDES=i._createHelper(s)}(),n("crypto-js/rollups/tripledes",function(){});var r=r||function(t,e){var n={},r=n.lib={},i=r.Base=function(){function t(){}return{extend:function(e){t.prototype=this;var n=new t;return e&&n.mixIn(e),n.$super=this,n},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.$super.extend(this)}}}(),o=r.WordArray=i.extend({init:function(t,n){t=this.words=t||[],this.sigBytes=n!=e?n:4*t.length},toString:function(t){return(t||c).stringify(this)},concat:function(t){var e=this.words,n=t.words,r=this.sigBytes,t=t.sigBytes;if(this.clamp(),r%4)for(var i=0;t>i;i++)e[r+i>>>2]|=(255&n[i>>>2]>>>24-8*(i%4))<<24-8*((r+i)%4);else if(n.length>65535)for(i=0;t>i;i+=4)e[r+i>>>2]=n[i>>>2];else e.push.apply(e,n);return this.sigBytes+=t,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-8*(n%4),e.length=t.ceil(n/4)},clone:function(){var t=i.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var n=[],r=0;e>r;r+=4)n.push(0|4294967296*t.random());return o.create(n,e)}}),s=n.enc={},c=s.Hex={stringify:function(t){for(var e=t.words,t=t.sigBytes,n=[],r=0;t>r;r++){var i=255&e[r>>>2]>>>24-8*(r%4);n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,n=[],r=0;e>r;r+=2)n[r>>>3]|=parseInt(t.substr(r,2),16)<<24-4*(r%8);return o.create(n,e/2)}},a=s.Latin1={stringify:function(t){for(var e=t.words,t=t.sigBytes,n=[],r=0;t>r;r++)n.push(String.fromCharCode(255&e[r>>>2]>>>24-8*(r%4)));return n.join("")},parse:function(t){for(var e=t.length,n=[],r=0;e>r;r++)n[r>>>2]|=(255&t.charCodeAt(r))<<24-8*(r%4);return o.create(n,e)}},u=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(a.stringify(t)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(t){return a.parse(unescape(encodeURIComponent(t)))}},f=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=o.create(),this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=u.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n=this._data,r=n.words,i=n.sigBytes,s=this.blockSize,c=i/(4*s),c=e?t.ceil(c):t.max((0|c)-this._minBufferSize,0),e=c*s,i=t.min(4*e,i);if(e){for(var a=0;e>a;a+=s)this._doProcessBlock(r,a);a=r.splice(0,e),n.sigBytes-=i}return o.create(a,i)},clone:function(){var t=i.clone.call(th