stylus/vendor/db-to-cloud/db-to-cloud.min.js

3 lines
20 KiB
JavaScript
Raw Normal View History

Add: sync database to a cloud drive (#787) * Add key * Add: a second index uuid, push changes to sync controller * Add: sync.js * Add: tokenManager * Change: log entire body for http error * Add: token flow * Fix: minor * Fix: move cleanup to stop function * Add: syncNow * Update dependencies * Fix: handle 401 error * Add: handle 401 error * Fix: then -> catch * Add: sync options to options page * Update db-to-cloud * Change: make prefs.set return a promise * Add: disble selector if connected * Add: update selector state * Fix: return promise in prefs.set * Fix: manage complex state * Fix: handle prefs change * Change: manage sync status in background * Add: show current status in the UI * Add: schedule a faster sync when db changed * Update dependencies * Add: include progress in sync status * Add: more detail status * Show status text only * Bump dependencies * Change: show loaded and total * Fix: syncTarget is undefined * Add: google and onedrive * Fix: token is not reused * Bump dependencies * Don't use minified version since it is hard to debug * Fix: expire time is incorrect * Change: switch google to code flow * Bump dependencies * Change: only modify pref if the initialization success? * Don't stop the sync if the first sync is not triggered by the user * Add: implement refresh token * Change: switch microsoft to code flow * Add: subtract expire with a latency * Add: microsoft client secret * Add: display error message * Fix: fromPref is not used * Change: try to revoke the token when log out * Add: revoke dropbox token * Fix: Google only generates one refresh token for one user by default * Bump dependencies, fix onedrive list issue * Fix: arguments sent to sync.put is wrong * Fix: don't schedule a sync on db changed if not connected * Bump dependencies. Fix issue of switching drives * Bump db-to-cloud, fix switching drive issue * Fix: only auth user on 401 error, don't display login window without user interaction * Fix: don't call revoke() if token is undefined * Add: login button to generate the access token interactively * Fix: make addMissingProperties a local * Fix: store missing props in an object * Fix: sync.getStatus should be sync * LATENCY -> NETWORK_LATENCY * Fix: cache the token forever if there is no expire time e.g. dropbox * Add some comments * Fix: i18n * Fix: i18n sync status * fixup! Fix: i18n sync status * Fix: 'sync to cloud' is displayed twice
2019-11-05 19:30:45 +00:00
var dbToCloud=function(t){"use strict";function e(t,e,n,o,r,i,c){try{var a=t[i](c),l=a.value}catch(t){return void n(t)}a.done?e(l):Promise.resolve(l).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,l,"next",t)}function l(t){e(c,r,i,a,l,"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(n,!0).forEach((function(e){o(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r(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(!(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(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)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function l({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(i,a){const l=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:i,block:a});return n?(n.next=l,l.prev=n,n=l,e||(e=n)):e=n=l,r.length++,function i(){const c=e;if(!c||c.block&&c.prev||c.prev&&c.prev.block||o>=t)return;c.block||o++;e=c.next;let a;try{a=c.fn(c.q2&&c.q2.resolve)}catch(t){return c.q.reject(t),void l()}c.q2&&c.q2.promise.then(s);if(a&&a.then){const t=a.then(c.q.resolve,c.q.reject);c.q2||t.then(l)}else if(c.q.resolve(a),!c.q2)return void l();i();function l(){s()}function s(t){c.prev&&(c.prev.next=c.next),c.next&&(c.next.prev=c.prev),n===c&&(n=c.prev),c.block||o--,r.length--,t&&t(),i()}}(),l.q.promise}function c(){const t={};return t.promise=new Promise((e,n)=>{t.resolve=e,t.reject=n}),t}}function s(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 u={};function p(t){return String.fromCharCode(parseInt(t.slice(1),16))}function f(t){return"%".concat("00".concat(t.charCodeAt(0).toString(16)).slice(-2))}Object.defineProperty(u,"__esModule",{value:!0}),u.encode=function(t){return btoa(encodeURIComponent(t).replace(/%[0-9A-F]{2}/g,p))},u.decode=function(t){return decodeURIComponent(Array.from(atob(t),f).join(""))};class d extends Error{constructor(t,e,n=e&&e.status){super(t),this.code=n,this.origin=e,Error.captureStackTrace&&Error.captureStackTrace(this,d)}}function h(t){return new Promise(e=>setTimeout(e,t))}function y({fetch:t,cooldown:e=0,getAccessToken:o}){const r=l();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,l=e.format,s=c(e,["path","contentType","headers","format"]);const u={Authorization:"Beare
//# sourceMappingURL=db-to-cloud.min.js.map