From 7ccb08d9b4c8eee714db7bbe9114fa92739ffdc9 Mon Sep 17 00:00:00 2001 From: Anders Rune Jensen Date: Tue, 21 Apr 2020 22:08:45 +0200 Subject: [PATCH] Bump random-access-chrome-file to make saving work in Chrome 81 --- dist/bundle-core.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/bundle-core.js b/dist/bundle-core.js index 78bed75..94f5a1b 100644 --- a/dist/bundle-core.js +++ b/dist/bundle-core.js @@ -2298,7 +2298,7 @@ module.exports=function(s){for(var e=s;s.source;)s=s.source;return this.sink=s,s },{"./decode":487,"./encode":488}],490:[function(require,module,exports){ (function (Buffer){ -const ras=require("random-access-storage"),TYPE={type:"octet/stream"},requestFileSystem=window.requestFileSystem||window.webkitRequestFileSystem,persistentStorage=navigator.persistentStorage||navigator.webkitPersistentStorage,FileReader=window.FileReader,Blob=window.Blob;function requestQuota(t,e,i){if("function"==typeof e)return requestQuota(t,!0,e);persistentStorage.queryUsageAndQuota(function(r,n){if(n&&!e)return i(null,n);persistentStorage.requestQuota(t,function(t){i(null,t)},i)},i)}function createFile(t,e){e||(e={});const i=e.maxSize||createFile.DEFAULT_MAX_SIZE,r=new Mutex;var n=null,o=null,s=null,u=null,l=[],c=[];return ras({read:function(t){(l.pop()||new ReadRequest(l,o,s,r)).run(t)},write:function(t){(c.pop()||new WriteRequest(c,o,s,r)).run(t)},open:function(e){function r(t){n=o=s=null,e.callback(t)}requestQuota(i,!1,function(i,l){if(i)return r(i);requestFileSystem(window.PERSISTENT,l,function(i){n=i,function t(e,i){if(!e)return i();n.root.getDirectory(e,{create:!0},i,function(){t(parentFolder(e),function(){n.root.getDirectory(e,{create:!0},i,i)})})}(parentFolder(t),function(){n.root.getFile(t,{create:!0},function(t){(s=u=t).file(function(t){o=t,e.callback(null)},r)},r)})},r)})},stat:function(t){t.callback(null,o)},close:function(t){l=c=s=o=n=null,t.callback(null)},destroy:function(t){u.remove(function(){u=null,t.callback(null,null)},function(e){u=null,t.callback(e,null)})}})}function parentFolder(t){const e=t.lastIndexOf("/"),i=t.lastIndexOf("\\"),r=t.slice(0,Math.max(0,e,i));return/^\w:$/.test(r)?"":r}function WriteRequest(t,e,i,r){this.writer=null,this.entry=i,this.file=e,this.req=null,this.pool=t,this.mutex=r,this.locked=!1,this.truncating=!1}function Mutex(){this.queued=null}function ReadRequest(t,e,i,r){this.reader=new FileReader,this.file=e,this.req=null,this.pool=t,this.retry=!0,this.mutex=r,this.locked=!1;const n=this;this.reader.onerror=function(){n.onread(this.error,null)},this.reader.onload=function(){const t=Buffer.from(this.result);n.onread(null,t)}}createFile.DEFAULT_MAX_SIZE=Number.MAX_SAFE_INTEGER,createFile.requestQuota=requestQuota,module.exports=createFile,WriteRequest.prototype.makeWriter=function(){const t=this;this.entry.createWriter(function(e){t.writer=e,e.onwriteend=function(){t.onwrite(null)},e.onerror=function(e){t.onwrite(e)},t.run(t.req)})},WriteRequest.prototype.onwrite=function(t){const e=this.req;if(this.req=null,this.locked&&(this.locked=!1,this.mutex.release()),this.truncating&&(this.truncating=!1,!t))return this.run(e);this.pool.push(this),e.callback(t,null)},WriteRequest.prototype.truncate=function(){this.truncating=!0,this.writer.truncate(this.req.offset)},WriteRequest.prototype.lock=function(){return!!this.locked||(this.locked=this.mutex.lock(this),this.locked)},WriteRequest.prototype.run=function(t){if(this.req=t,!this.writer||this.writer.length!==this.file.size)return this.makeWriter();if(!(t.offset+t.size>this.file.size)||this.lock()){if(t.offset>this.writer.length)return t.offset>this.file.size?this.truncate():this.makeWriter();this.writer.seek(t.offset),this.writer.write(new Blob([t.data],TYPE))}},Mutex.prototype.release=function(){const t=this.queued;this.queued=null;for(var e=0;ethis.file.size)return this.onread(new Error("Could not satisfy length"),null);this.reader.readAsArrayBuffer(this.file.slice(t.offset,e))}; +const ras=require("random-access-storage"),TYPE={type:"octet/stream"},requestFileSystem=window.requestFileSystem||window.webkitRequestFileSystem,persistentStorage=navigator.persistentStorage||navigator.webkitPersistentStorage,FileReader=window.FileReader,Blob=window.Blob;function requestQuota(t,e,r){if("function"==typeof e)return requestQuota(t,!0,e);persistentStorage.queryUsageAndQuota(function(i,n){if(n&&!e)return r(null,n);persistentStorage.requestQuota(t,function(t){r(null,t)},r)},r)}function createFile(t,e){e||(e={});const r=e.maxSize||createFile.DEFAULT_MAX_SIZE,i=new Mutex;var n=null,o=null,s=null,u=[],l=[];return ras({read:function(t){(u.pop()||new ReadRequest(u,o,i)).run(t)},write:function(t){(l.pop()||new WriteRequest(l,o,i)).run(t)},open:function(e){function i(t){n=o=null,e.callback(t)}requestQuota(r,!1,function(r,u){if(r)return i(r);requestFileSystem(window.PERSISTENT,u,function(r){n=r,function t(e,r){if(!e)return r();n.root.getDirectory(e,{create:!0},r,function(){t(parentFolder(e),function(){n.root.getDirectory(e,{create:!0},r,r)})})}(parentFolder(t),function(){n.root.getFile(t,{create:!0},function(t){o=s=t,e.callback(null)},i)})},i)})},stat:function(t){o.file(e=>{t.callback(null,e)},e=>t.callback(e))},close:function(t){u=l=o=n=null,t.callback(null)},destroy:function(t){s.remove(function(){s=null,t.callback(null,null)},function(e){s=null,t.callback(e,null)})}})}function parentFolder(t){const e=t.lastIndexOf("/"),r=t.lastIndexOf("\\"),i=t.slice(0,Math.max(0,e,r));return/^\w:$/.test(i)?"":i}function WriteRequest(t,e,r){this.pool=t,this.entry=e,this.mutex=r,this.writer=null,this.req=null,this.locked=!1,this.truncating=!1}function Mutex(){this.queued=null}function ReadRequest(t,e,r){this.pool=t,this.entry=e,this.mutex=r,this.reader=new FileReader,this.req=null,this.retry=!0,this.locked=!1;const i=this;this.reader.onerror=function(){i.onread(this.error,null)},this.reader.onload=function(){const t=Buffer.from(this.result);i.onread(null,t)}}createFile.DEFAULT_MAX_SIZE=Number.MAX_SAFE_INTEGER,createFile.requestQuota=requestQuota,module.exports=createFile,WriteRequest.prototype.makeWriter=function(){const t=this;this.entry.createWriter(function(e){t.writer=e,e.onwriteend=function(){t.onwrite(null)},e.onerror=function(e){t.onwrite(e)},t.run(t.req)})},WriteRequest.prototype.onwrite=function(t){const e=this.req;if(this.req=null,this.locked&&(this.locked=!1,this.mutex.release()),this.truncating&&(this.truncating=!1,!t))return this.run(e);this.pool.push(this),e.callback(t,null)},WriteRequest.prototype.truncate=function(){this.truncating=!0,this.writer.truncate(this.req.offset)},WriteRequest.prototype.lock=function(){return!!this.locked||(this.locked=this.mutex.lock(this),this.locked)},WriteRequest.prototype.run=function(t){this.entry.file(e=>{if(this.req=t,!this.writer||this.writer.length!==e.size)return this.makeWriter();if(!(t.offset+t.size>e.size)||this.lock()){if(t.offset>this.writer.length)return t.offset>e.size?this.truncate():this.makeWriter();this.writer.seek(t.offset),this.writer.write(new Blob([t.data],TYPE))}},e=>t.callback(e))},Mutex.prototype.release=function(){const t=this.queued;this.queued=null;for(var e=0;e{const r=t.offset+t.size;if(this.req=t,r>e.size)return this.onread(new Error("Could not satisfy length"),null);this.reader.readAsArrayBuffer(e.slice(t.offset,r))},e=>t.callback(e))}; }).call(this,require("buffer").Buffer) },{"buffer":69,"random-access-storage":497}],491:[function(require,module,exports){ diff --git a/package.json b/package.json index bf634d8..2a30ce7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ssb-browser-core", "description": "", - "version": "3.1.0", + "version": "3.1.1", "homepage": "https://github.com/arj03/ssb-browser-core", "repository": { "type": "git",