c17dddb0ee
* Update db-to-cloud * Change: refactor sync logic, disallow implicit auth * Add: better relog message in options page * read prefs only when `ready` * show the internal error text in icon tooltip * show the internal error text in options fully Co-authored-by: tophf <tophf@gmx.com> * Update _locales/en/messages.json Co-authored-by: Enrico Lamperti <910672+elamperti@users.noreply.github.com>
3 lines
20 KiB
JavaScript
3 lines
20 KiB
JavaScript
var dbToCloud=function(t){"use strict";function e(t,e,n,o,r,i,c){try{var a=t[i](c),s=a.value}catch(t){return void n(t)}a.done?e(s):Promise.resolve(s).then(o,r)}function n(t){return function(){var n=this,o=arguments;return new Promise((function(r,i){var c=t.apply(n,o);function a(t){e(c,r,i,a,s,"next",t)}function s(t){e(c,r,i,a,s,"throw",t)}a(void 0)}))}}function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function r(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}function i(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?r(Object(n),!0).forEach((function(e){o(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function c(t,e){if(null==t)return{};var n,o,r=function(t,e){if(null==t)return{};var n,o,r={},i=Object.keys(t);for(o=0;o<i.length;o++)n=i[o],e.indexOf(n)>=0||(r[n]=t[n]);return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)n=i[o],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function a(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var n=[],o=!0,r=!1,i=void 0;try{for(var c,a=t[Symbol.iterator]();!(o=(c=a.next()).done)&&(n.push(c.value),!e||n.length!==e);o=!0);}catch(t){r=!0,i=t}finally{try{o||null==a.return||a.return()}finally{if(r)throw i}}return n}(t,e)||s(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(t,e){if(t){if("string"==typeof t)return l(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?l(t,e):void 0}}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);n<e;n++)o[n]=t[n];return o}function u(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=s(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var o=0,r=function(){};return{s:r,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,c=!0,a=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return c=t.done,t},e:function(t){a=!0,i=t},f:function(){try{c||null==n.return||n.return()}finally{if(a)throw i}}}}function p({maxActiveReader:t=1/0}={}){let e,n,o=0;const r={read:t=>i(t,!1),write:t=>i(t,!0),length:0};return r;function i(t,o){const i=function({fn:t,block:e=!1,prev:n,next:o,q:r=c(),q2:i=(t.length?c():null)}){return{fn:t,block:e,prev:n,next:o,q:r,q2:i}}({fn:t,block:o});return n?(n.next=i,i.prev=n,n=i,e||(e=n)):e=n=i,r.length++,a(),i.q.promise}function c(){const t={};return t.promise=new Promise(((e,n)=>{t.resolve=e,t.reject=n})),t}function a(){const i=e;if(!i||i.block&&i.prev||i.prev&&i.prev.block||o>=t)return;let c;i.block||o++,e=i.next;try{c=i.fn(i.q2&&i.q2.resolve)}catch(t){return i.q.reject(t),void s()}if(i.q2&&i.q2.promise.then(l),c&&c.then){const t=c.then(i.q.resolve,i.q.reject);i.q2||t.then(s)}else if(i.q.resolve(c),!i.q2)return void s();function s(){l()}function l(t){i.prev&&(i.prev.next=i.next),i.next&&(i.next.prev=i.prev),n===i&&(n=i.prev),i.block||o--,r.length--,t&&t(),a()}a()}}function f(t){let e,n=0;return()=>(n&&clearTimeout(n),n=setTimeout(o),e||(e=function(){const t={};return t.promise=new Promise(((e,n)=>{t.resolve=e,t.reject=n})),t}()),e.promise);function o(){Promise.resolve(t()).then(e.resolve,e.reject),n=0,e=null}}const d={};function h(t){return String.fromCharCode(parseInt(t.slice(1),16))}function y(t){return"%".concat("00".concat(t.charCodeAt(0).toString(16)).slice(-2))}Object.defineProperty(d,"__esModule",{value:!0}),d.encode=function(t){return btoa(encodeURIComponent(t).replace(/%[0-9A-F]{2}/g,h))},d.decode=function(t){return decodeURIComponent(Array.from(atob(t),y).join(""))};class g extends Error{constructor(t,e,n=e&&e.status){super(t),this.code=n,this.origin=e,Error.captureStackTrace&&Error.captureStackTrace(this,g)}}function v(t){return new Promise((e=>setTimeout(e,t)))}function m({fetch:t,cooldown:e=0,getAccessToken:o}){const r=p();return t=>r.write(function(){var o=n((function*(n){try{return yield function(t){return a.apply(this,arguments)}(t)}finally{e&&t.method&&"GET"!==t.method?setTimeout(n,e):n()}}));return function(t){return o.apply(this,arguments)}}());function a(){return(a=n((function*(e){let n=e.path,r=e.contentType,a=e.headers,s=e.format,l=c(e,["path","contentType","headers","format"]);const u={Authorization:"Bearer ".concat(yield o())};for(r&&(u["Content-Type"]=r),Object.assign(u,a);;){const e=yield t(n,i({headers:u},l));if(!e.ok){const t=e.headers.get("Retry-After");if(t){const e=Number(t);if(e){yield v(1e3*e);continue}}const n=yield e.text();throw new g("failed to fetch [".concat(e.status,"]: ").concat(n),e)}if(s)return yield e[s]();const o=e.headers.get("Content-Type");return/application\/json/.test(o)?yield e.json():yield e.text()}}))).apply(this,arguments)}}var b=Object.freeze({__proto__:null,fsDrive:()=>{},github:function({userAgent:t="db-to-cloud",owner:e,repo:o,getAccessToken:r,fetch:i=("undefined"!=typeof self?self:global).fetch}){const c=m({fetch:i,getAccessToken:r,cooldown:1e3}),a=new Map;return{name:"github",get:p,put:h,post:function(t,e){return h(t,e,!1)},delete:function(t){return g.apply(this,arguments)},list:function(t){return l.apply(this,arguments)},shaCache:a};function s(e){return e.headers||(e.headers={}),e.headers["User-Agent"]||(e.headers["User-Agent"]=t),e.headers.Accept||(e.headers.Accept="application/vnd.github.v3+json"),e.path="https://api.github.com".concat(e.path),c(e)}function l(){return(l=n((function*(t){const n=[];var r,i=u(yield s({path:"/repos/".concat(e,"/").concat(o,"/contents/").concat(t)}));try{for(i.s();!(r=i.n()).done;){const t=r.value;n.push(t.name),a.set(t.path,t.sha)}}catch(t){i.e(t)}finally{i.f()}return n}))).apply(this,arguments)}function p(t){return f.apply(this,arguments)}function f(){return(f=n((function*(t){const n=yield s({path:"/repos/".concat(e,"/").concat(o,"/contents/").concat(t)});return a.set(n.path,n.sha),d.decode(n.content)}))).apply(this,arguments)}function h(t,e){return y.apply(this,arguments)}function y(){return(y=n((function*(t,n,r=!0){const i={message:"",content:d.encode(n)};r&&a.has(t)&&(i.sha=a.get(t));const c={method:"PUT",path:"/repos/".concat(e,"/").concat(o,"/contents/").concat(t),contentType:"application/json",body:JSON.stringify(i)};let l,u=!1;for(;!l;){try{l=yield s(c)}catch(e){if(422!==e.code||!e.message.includes('\\"sha\\" wasn\'t supplied'))throw e;if(!r||u)throw e.code="EEXIST",e;yield p(t)}u=!0}a.set(t,l.content.sha)}))).apply(this,arguments)}function g(){return(g=n((function*(t){try{let n=a.get(t);n||(yield p(t),n=a.get(t)),yield s({method:"DELETE",path:"/repos/".concat(e,"/").concat(o,"/contents/").concat(t),body:JSON.stringify({message:"",sha:n})})}catch(t){if(404===t.code)return;throw t}}))).apply(this,arguments)}},dropbox:function({getAccessToken:t,fetch:e=("undefined"!=typeof self?self:global).fetch}){const o=m({fetch:e,getAccessToken:t});return{name:"dropbox",get:function(t){return l.apply(this,arguments)},put:p,post:function(t,e){return d.apply(this,arguments)},delete:function(t){return h.apply(this,arguments)},list:function(t){return a.apply(this,arguments)}};function r(t){let e=t.path,n=t.body,r=c(t,["path","body"]);return o(i({method:"POST",path:"https://api.dropboxapi.com/2/".concat(e),contentType:"application/json",body:JSON.stringify(n)},r))}function a(){return(a=n((function*(t){const e=[];let n=yield r({path:"files/list_folder",body:{path:"/".concat(t)}});var o,i=u(n.entries);try{for(i.s();!(o=i.n()).done;){const t=o.value;e.push(t.name)}}catch(t){i.e(t)}finally{i.f()}if(!n.has_more)return e;for(;n.has_more;){n=yield r({path:"files/list_folder/continue",body:{cursor:n.cursor}});var c,a=u(n.entries);try{for(a.s();!(c=a.n()).done;){const t=c.value;e.push(t.name)}}catch(t){a.e(t)}finally{a.f()}}return e}))).apply(this,arguments)}function s(t){const e=new URLSearchParams;return e.set("arg",JSON.stringify(t)),e.toString()}function l(){return(l=n((function*(t){const e={path:"/".concat(t)};try{return yield o({path:"https://content.dropboxapi.com/2/files/download?".concat(s(e)),format:"text"})}catch(t){throw 409===t.code&&t.message.includes("not_found")&&(t.code="ENOENT"),t}}))).apply(this,arguments)}function p(t,e){return f.apply(this,arguments)}function f(){return(f=n((function*(t,e,n="overwrite"){const r={path:"/".concat(t),mode:n,autorename:!1,mute:!0};yield o({path:"https://content.dropboxapi.com/2/files/upload?".concat(s(r)),method:"POST",contentType:"application/octet-stream",body:e})}))).apply(this,arguments)}function d(){return(d=n((function*(t,e){try{return yield p(t,e,"add")}catch(t){throw 409===t.code&&t.message.includes("conflict")&&(t.code="EEXIST"),t}}))).apply(this,arguments)}function h(){return(h=n((function*(t){try{yield r({path:"files/delete_v2",body:{path:"/".concat(t)}})}catch(t){if(409===t.code&&t.message.includes("not_found"))return;throw t}}))).apply(this,arguments)}},onedrive:function({getAccessToken:t,fetch:e=("undefined"!=typeof self?self:global).fetch}){const o=m({fetch:e,getAccessToken:t});return{name:"onedrive",get:function(t){return a.apply(this,arguments)},put:function(t,e){return s.apply(this,arguments)},post:function(t,e){return l.apply(this,arguments)},delete:function(t){return u.apply(this,arguments)},list:function(t){return c.apply(this,arguments)}};function r(t){return i.apply(this,arguments)}function i(){return(i=n((function*(t){return t.path="https://graph.microsoft.com/v1.0/me/drive/special/approot".concat(t.path),yield o(t)}))).apply(this,arguments)}function c(){return(c=n((function*(t){t&&(t=":/".concat(t,":"));let e=yield r({path:"".concat(t,"/children?select=name")}),n=e.value.map((t=>t.name));for(;e["@odata.nextLink"];)e=yield o({path:e["@odata.nextLink"]}),n=n.concat(e.value.map((t=>t.name)));return n}))).apply(this,arguments)}function a(){return(a=n((function*(t){return yield r({path:":/".concat(t,":/content"),format:"text"})}))).apply(this,arguments)}function s(){return(s=n((function*(t,e){yield r({method:"PUT",path:":/".concat(t,":/content"),headers:{"Content-Type":"text/plain"},body:e})}))).apply(this,arguments)}function l(){return(l=n((function*(t,e){try{yield r({method:"PUT",path:":/".concat(t,":/content?@microsoft.graph.conflictBehavior=fail"),headers:{"Content-Type":"text/plain"},body:e})}catch(t){throw 409===t.code&&t.message.includes("nameAlreadyExists")&&(t.code="EEXIST"),t}}))).apply(this,arguments)}function u(){return(u=n((function*(t){try{yield r({method:"DELETE",path:":/".concat(t,":")})}catch(t){if(404===t.code)return;throw t}}))).apply(this,arguments)}},google:function({getAccessToken:t,fetch:e=("undefined"!=typeof self?self:global).fetch,FormData:o=("undefined"!=typeof self?self:global).FormData,Blob:r=("undefined"!=typeof self?self:global).Blob}){const i=m({fetch:e,getAccessToken:t}),c=new Map;let a;return{name:"google",get:function(t){return O.apply(this,arguments)},put:function(t,e){return k.apply(this,arguments)},post:E,delete:function(t){return S.apply(this,arguments)},list:function(t){return j.apply(this,arguments)},init:function(){return T.apply(this,arguments)},acquireLock:function(t){return p.apply(this,arguments)},releaseLock:function(){return f.apply(this,arguments)},fileMetaCache:c};function s(t,e){return l.apply(this,arguments)}function l(){return(l=n((function*(t,e){yield i({method:"DELETE",path:"https://www.googleapis.com/drive/v3/files/".concat(t,"/revisions/").concat(e)})}))).apply(this,arguments)}function p(){return(p=n((function*(t){const e=c.get("lock.json"),n=(yield y(e.id,JSON.stringify({expire:Date.now()+60*t*1e3}))).headRevisionId,o=yield i({path:"https://www.googleapis.com/drive/v3/files/".concat(e.id,"/revisions?fields=revisions(id)")});for(let t=1;t<o.revisions.length;t++){const r=o.revisions[t].id;if(r===n)return void(a=n);if(JSON.parse(yield i({path:"https://www.googleapis.com/drive/v3/files/".concat(e.id,"/revisions/").concat(r,"?alt=media")})).expire>Date.now())throw yield s(e.id,n),new g("failed to acquire lock",null,"EEXIST");yield s(e.id,r)}throw new Error("cannot find lock revision")}))).apply(this,arguments)}function f(){return(f=n((function*(){const t=c.get("lock.json");yield s(t.id,a),a=null}))).apply(this,arguments)}function d(t,e){return h.apply(this,arguments)}function h(){return(h=n((function*(t,e){t="https://www.googleapis.com/drive/v3/files?spaces=appDataFolder&fields=nextPageToken,files(id,name,headRevisionId)"+(t?"&"+t:"");let n=yield i({path:t});for(e(n);n.nextPageToken;)n=yield i({path:"".concat(t,"&pageToken=").concat(n.nextPageToken)}),e(n)}))).apply(this,arguments)}function y(t,e){return v.apply(this,arguments)}function v(){return(v=n((function*(t,e){return yield i({method:"PATCH",path:"https://www.googleapis.com/upload/drive/v3/files/".concat(t,"?uploadType=media&fields=headRevisionId"),headers:{"Content-Type":"text/plain"},body:e})}))).apply(this,arguments)}function b(t){return w.apply(this,arguments)}function w(){return(w=n((function*(t){t&&(t="q=".concat(encodeURIComponent(t))),yield d(t,(t=>{var e,n=u(t.files);try{for(n.s();!(e=n.n()).done;){const t=e.value;c.set(t.name,t)}}catch(t){n.e(t)}finally{n.f()}}))}))).apply(this,arguments)}function T(){return(T=n((function*(){yield b(),c.has("lock.json")||(yield E("lock.json","{}")),c.has("meta.json")||(yield E("meta.json","{}"))}))).apply(this,arguments)}function j(){return(j=n((function*(t){return[...c.values()].filter((e=>e.name.startsWith(t+"/"))).map((t=>t.name.split("/")[1]))}))).apply(this,arguments)}function O(){return(O=n((function*(t){let e=c.get(t);if(!e&&(yield b("name = '".concat(t,"'")),e=c.get(t),!e))throw new g("metaCache doesn't contain ".concat(t),null,"ENOENT");try{return yield i({path:"https://www.googleapis.com/drive/v3/files/".concat(e.id,"?alt=media")})}catch(t){throw 404===t.code&&(t.code="ENOENT"),t}}))).apply(this,arguments)}function k(){return(k=n((function*(t,e){if(!c.has(t))return yield E(t,e);const n=c.get(t),o=yield y(n.id,e);n.headRevisionId=o.headRevisionId}))).apply(this,arguments)}function E(t,e){return C.apply(this,arguments)}function C(){return(C=n((function*(t,e){const n=new o,a={name:t,parents:["appDataFolder"]};n.append("metadata",new r([JSON.stringify(a)],{type:"application/json; charset=UTF-8"})),n.append("media",new r([e],{type:"text/plain"}));const s=yield i({method:"POST",path:"https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart&fields=id,name,headRevisionId",body:n});c.set(s.name,s)}))).apply(this,arguments)}function S(){return(S=n((function*(t){const e=c.get(t);if(e)try{yield i({method:"DELETE",path:"https://www.googleapis.com/drive/v3/files/".concat(e.id)})}catch(t){if(404===t.code)return;throw t}}))).apply(this,arguments)}}});return t.dbToCloud=function({onGet:t,onPut:e,onDelete:o,onFirstSync:r,onWarn:i=console.error,onProgress:c,compareRevision:s,getState:l,setState:d,lockExpire:h=60}){let y,g,v;const m=new Map,b=f((()=>d(y,g))),w=new Map,T=p();return{use:function(t){y=function(t){const e=Object.create(t);return e.get=function(){var e=n((function*(e){return JSON.parse(yield t.get(e))}));return function(t){return e.apply(this,arguments)}}(),e.put=function(){var e=n((function*(e,n){return yield t.put(e,JSON.stringify(n))}));return function(t,n){return e.apply(this,arguments)}}(),e.post=function(){var e=n((function*(e,n){return yield t.post(e,JSON.stringify(n))}));return function(t,n){return e.apply(this,arguments)}}(),e.isInit=!1,e.acquireLock||(e.acquireLock=function(t){return o.apply(this,arguments)},e.releaseLock=function(){return r.apply(this,arguments)}),e.getMeta||(e.getMeta=function(){return i.apply(this,arguments)},e.putMeta=function(t){return c.apply(this,arguments)}),e.peekChanges||(e.peekChanges=function(t){return a.apply(this,arguments)}),e;function o(){return(o=n((function*(t){try{yield this.post("lock.json",{expire:Date.now()+60*t*1e3})}catch(t){if("EEXIST"===t.code){const t=yield this.get("lock.json");Date.now()>t.expire&&(yield this.delete("lock.json"))}throw t}}))).apply(this,arguments)}function r(){return(r=n((function*(){yield this.delete("lock.json")}))).apply(this,arguments)}function i(){return(i=n((function*(){try{return yield this.get("meta.json")}catch(t){if("ENOENT"===t.code||404===t.code)return{};throw t}}))).apply(this,arguments)}function c(){return(c=n((function*(t){yield this.put("meta.json",t)}))).apply(this,arguments)}function a(){return(a=n((function*(t){return(yield this.getMeta()).lastChange!==t.lastChange}))).apply(this,arguments)}}(t)},init:function(){return T.write(n((function*(){if(!g||!g.enabled){if(!y)throw new Error("cloud drive is undefined");g=(yield l(y))||{},g.enabled=!0,g.queue||(g.queue=[])}})))},uninit:function(){return T.write(n((function*(){g&&g.enabled&&(g=v=null,m.clear(),w.clear(),y.uninit&&y.isInit&&(yield y.uninit(),y.isInit=!1),yield b())})))},put:function(t,e){if(!g||!g.enabled)return;g.queue.push({_id:t,_rev:e,action:"put"}),b()},delete:function(t,e){if(!g||!g.enabled)return;g.queue.push({_id:t,_rev:e,action:"delete"}),b()},syncNow:function(t){return T.write(n((function*(){if(!g||!g.enabled)throw new Error("Cannot sync now, the sync is not enabled");y.init&&!y.isInit&&(yield y.init(),y.isInit=!0),null==g.lastChange&&(yield r()),yield function(){return x.apply(this,arguments)}(t)})))},drive:()=>y,isInit:()=>Boolean(g&&g.enabled)};function j(){return O.apply(this,arguments)}function O(){return(O=n((function*(){if(v=yield y.getMeta(),!v.lastChange||v.lastChange===g.lastChange)return;let t=[];if(g.lastChange){const e=Math.floor((v.lastChange-1)/100);let n=Math.floor(g.lastChange/100);for(;n<=e;){const e=yield y.get("changes/".concat(n,".json"));m.set(n,e),t=t.concat(e),n++}t=t.slice(g.lastChange%100)}else t=(yield y.list("docs")).map((t=>({action:"put",_id:t.slice(0,-5)})));const n=new Map;var r,s=u(t);try{for(s.s();!(r=s.n()).done;){const t=r.value;n.set(t._id,t)}}catch(t){s.e(t)}finally{s.f()}let l=0;var p,f=u(n);try{for(f.s();!(p=f.n()).done;){const t=a(p.value,2),r=t[0],s=t[1];let u,f;if(c&&c({phase:"pull",total:n.size,loaded:l,change:s}),"delete"===s.action)yield o(r,s._rev);else if("put"===s.action){try{var d=yield y.get("docs/".concat(r,".json"));u=d.doc,f=d._rev}catch(t){if("ENOENT"===t.code||404===t.code){i("Cannot find ".concat(r,". Is it deleted without updating the history?")),l++;continue}throw t}yield e(u)}const h=s._rev||f;h&&w.set(r,h),l++}}catch(t){f.e(t)}finally{f.f()}g.lastChange=v.lastChange,yield b()}))).apply(this,arguments)}function k(){return E.apply(this,arguments)}function E(){return(E=n((function*(){if(!g.queue.length)return;const e=g.queue.slice(),n=new Map;var o,r=u(e);try{for(r.s();!(o=r.n()).done;){const t=o.value;n.set(t._id,t)}}catch(t){r.e(t)}finally{r.f()}const i=[];var a,l=u(n.values());try{for(l.s();!(a=l.n()).done;){const t=a.value,e=w.get(t._id);void 0!==e&&s(t._rev,e)<=0||i.push(t)}}catch(t){l.e(t)}finally{l.f()}let p,f,d=0;for(var h=0,T=i;h<T.length;h++){const e=T[h];if(c&&c({phase:"push",loaded:d,total:i.length,change:e}),"delete"===e.action)yield y.delete("docs/".concat(e._id,".json"));else if("put"===e.action){const n=yield t(e._id,e._rev);yield y.put("docs/".concat(e._id,".json"),{doc:n,_rev:e._rev})}w.set(e._id,e._rev),d++}if(v.lastChange){f=Math.floor(v.lastChange/100);const t=v.lastChange%100;p=t?m.get(f)||(yield y.get("changes/".concat(f,".json"))):[],p=p.slice(0,t).concat(i)}else f=0,p=i;for(let t=0;100*t<p.length;t++){const e=p.slice(100*t,100*(t+1));yield y.put("changes/".concat(f+t,".json"),e),m.set(f+t,e)}v.lastChange=(v.lastChange||0)+i.length,yield y.putMeta(v),g.queue=g.queue.slice(e.length),g.lastChange=v.lastChange,yield b()}))).apply(this,arguments)}function C(){return S.apply(this,arguments)}function S(){return(S=n((function*(){yield y.acquireLock(h);try{yield j(),yield k()}finally{yield y.releaseLock()}}))).apply(this,arguments)}function x(){return(x=n((function*(t=!0){c&&c({phase:"start"});try{if(!g.queue.length&&t&&v){if(!(yield y.peekChanges(v)))return}yield C()}finally{c&&c({phase:"end"})}}))).apply(this,arguments)}},t.drive=b,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
|
|
//# sourceMappingURL=db-to-cloud.min.js.map
|