From 735d8e5aa8b590b37a16c0e1b52a688c43dd5c10 Mon Sep 17 00:00:00 2001 From: Determinant Date: Thu, 7 Feb 2019 01:32:45 -0500 Subject: add popup --- dist/background_bundle.js | 1 - 1 file changed, 1 deletion(-) delete mode 100644 dist/background_bundle.js (limited to 'dist/background_bundle.js') diff --git a/dist/background_bundle.js b/dist/background_bundle.js deleted file mode 100644 index ff18ca7..0000000 --- a/dist/background_bundle.js +++ /dev/null @@ -1 +0,0 @@ -!function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=848)}({109:function(t,e,n){"use strict";const r=n(172),i=Symbol("max"),a=Symbol("length"),o=Symbol("lengthCalculator"),s=Symbol("allowStale"),u=Symbol("maxAge"),l=Symbol("dispose"),h=Symbol("noDisposeOnSet"),c=Symbol("lruList"),f=Symbol("cache"),d=Symbol("updateAgeOnGet"),v=()=>1;const p=(t,e,n)=>{const r=t[f].get(e);if(r){const e=r.value;if(g(t,e)){if(m(t,r),!t[s])return}else n&&(t[d]&&(r.value.now=Date.now()),t[c].unshiftNode(r));return e.value}},g=(t,e)=>{if(!e||!e.maxAge&&!t[u])return!1;const n=Date.now()-e.now;return e.maxAge?n>e.maxAge:t[u]&&n>t[u]},y=t=>{if(t[a]>t[i])for(let e=t[c].tail;t[a]>t[i]&&null!==e;){const n=e.prev;m(t,e),e=n}},m=(t,e)=>{if(e){const n=e.value;t[l]&&t[l](n.key,n.value),t[a]-=n.length,t[f].delete(n.key),t[c].removeNode(e)}};class w{constructor(t,e,n,r,i){this.key=t,this.value=e,this.length=n,this.now=r,this.maxAge=i||0}}const b=(t,e,n,r)=>{let i=n.value;g(t,i)&&(m(t,n),t[s]||(i=void 0)),i&&e.call(r,i.value,i.key,t)};t.exports=class{constructor(t){if("number"==typeof t&&(t={max:t}),t||(t={}),t.max&&("number"!=typeof t.max||t.max<0))throw new TypeError("max must be a non-negative number");this[i]=t.max||1/0;const e=t.length||v;if(this[o]="function"!=typeof e?v:e,this[s]=t.stale||!1,t.maxAge&&"number"!=typeof t.maxAge)throw new TypeError("maxAge must be a number");this[u]=t.maxAge||0,this[l]=t.dispose,this[h]=t.noDisposeOnSet||!1,this[d]=t.updateAgeOnGet||!1,this.reset()}set max(t){if("number"!=typeof t||t<0)throw new TypeError("max must be a non-negative number");this[i]=t||1/0,y(this)}get max(){return this[i]}set allowStale(t){this[s]=!!t}get allowStale(){return this[s]}set maxAge(t){if("number"!=typeof t)throw new TypeError("maxAge must be a non-negative number");this[u]=t,y(this)}get maxAge(){return this[u]}set lengthCalculator(t){"function"!=typeof t&&(t=v),t!==this[o]&&(this[o]=t,this[a]=0,this[c].forEach(t=>{t.length=this[o](t.value,t.key),this[a]+=t.length})),y(this)}get lengthCalculator(){return this[o]}get length(){return this[a]}get itemCount(){return this[c].length}rforEach(t,e){e=e||this;for(let n=this[c].tail;null!==n;){const r=n.prev;b(this,t,n,e),n=r}}forEach(t,e){e=e||this;for(let n=this[c].head;null!==n;){const r=n.next;b(this,t,n,e),n=r}}keys(){return this[c].toArray().map(t=>t.key)}values(){return this[c].toArray().map(t=>t.value)}reset(){this[l]&&this[c]&&this[c].length&&this[c].forEach(t=>this[l](t.key,t.value)),this[f]=new Map,this[c]=new r,this[a]=0}dump(){return this[c].map(t=>!g(this,t)&&{k:t.key,v:t.value,e:t.now+(t.maxAge||0)}).toArray().filter(t=>t)}dumpLru(){return this[c]}set(t,e,n){if((n=n||this[u])&&"number"!=typeof n)throw new TypeError("maxAge must be a number");const r=n?Date.now():0,s=this[o](e,t);if(this[f].has(t)){if(s>this[i])return m(this,this[f].get(t)),!1;const o=this[f].get(t).value;return this[l]&&(this[h]||this[l](t,o.value)),o.now=r,o.maxAge=n,o.value=e,this[a]+=s-o.length,o.length=s,this.get(t),y(this),!0}const d=new w(t,e,s,r,n);return d.length>this[i]?(this[l]&&this[l](t,e),!1):(this[a]+=d.length,this[c].unshift(d),this[f].set(t,this[c].head),y(this),!0)}has(t){if(!this[f].has(t))return!1;const e=this[f].get(t).value;return!g(this,e)}get(t){return p(this,t,!0)}peek(t){return p(this,t,!1)}pop(){const t=this[c].tail;return t?(m(this,t),t.value):null}del(t){m(this,this[f].get(t))}load(t){this.reset();const e=Date.now();for(let n=t.length-1;n>=0;n--){const r=t[n],i=r.e||0;if(0===i)this.set(r.k,r.v);else{const t=i-e;t>0&&this.set(r.k,r.v,t)}}}prune(){this[f].forEach((t,e)=>p(this,e,!1))}}},172:function(t,e,n){"use strict";function r(t){var e=this;if(e instanceof r||(e=new r),e.tail=null,e.head=null,e.length=0,t&&"function"==typeof t.forEach)t.forEach(function(t){e.push(t)});else if(arguments.length>0)for(var n=0,i=arguments.length;n1)n=e;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");r=this.head.next,n=this.head.value}for(var i=0;null!==r;i++)n=t(n,r.value,i),r=r.next;return n},r.prototype.reduceReverse=function(t,e){var n,r=this.tail;if(arguments.length>1)n=e;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");r=this.tail.prev,n=this.tail.value}for(var i=this.length-1;null!==r;i--)n=t(n,r.value,i),r=r.prev;return n},r.prototype.toArray=function(){for(var t=new Array(this.length),e=0,n=this.head;null!==n;e++)t[e]=n.value,n=n.next;return t},r.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,n=this.tail;null!==n;e++)t[e]=n.value,n=n.prev;return t},r.prototype.slice=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var n=new r;if(ethis.length&&(e=this.length);for(var i=0,a=this.head;null!==a&&ithis.length&&(e=this.length);for(var i=this.length,a=this.tail;null!==a&&i>e;i--)a=a.prev;for(;null!==a&&i>t;i--,a=a.prev)n.push(a.value);return n},r.prototype.reverse=function(){for(var t=this.head,e=this.tail,n=t;null!==n;n=n.prev){var r=n.prev;n.prev=n.next,n.next=r}return this.head=e,this.tail=t,this};try{n(173)(r)}catch(t){}},173:function(t,e,n){"use strict";t.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let t=this.head;t;t=t.next)yield t.value}}},27:function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n0?o.ids.pop():o.maxId++,o.inFlight[r]=e,n.port.postMessage(new d(r,i,a).deflate()),s});var i=chrome.runtime.connect({name:e});i.onMessage.addListener(function(t){console.log(t);var e=(t.type,n.requestCallback),r=e.inFlight[t.id];console.assert(void 0!==r),e.ids.push(t.id),r(t)}),this.port=i,this.requestCallback={inFlight:{},ids:[],maxId:0}}},43:function(t,e,n){"use strict";n.d(e,"e",function(){return d}),n.d(e,"b",function(){return v}),n.d(e,"f",function(){return p}),n.d(e,"g",function(){return g}),n.d(e,"c",function(){return y}),n.d(e,"d",function(){return m}),n.d(e,"a",function(){return b});var r=n(109),i=n.n(r);function a(t,e){for(var n=0;n0&&void 0!==arguments[0]&&arguments[0];return new Promise(function(e){return chrome.identity.getAuthToken({interactive:t},function(t){return e([t,!chrome.runtime.lastError])})}).then(function(t){var e=s(t,2),n=e[0];if(e[1])return n;throw l.notLoggedIn})}function d(){return null===c?f(!1).then(function(){return c=!0}).catch(function(){return c=!1}).then(function(){return c}):Promise.resolve(c)}function v(){return d().then(function(t){if(t)return f(!1);throw l.notLoggedIn})}function p(){return d().then(function(t){if(t)throw l.notLoggedOut;return f(!0).then(function(){return c=!0})})}function g(){return v().then(function(t){return fetch("https://accounts.google.com/o/oauth2/revoke?".concat(h({token:t})),{method:"GET",async:!0}).then(function(e){if(200===e.status)return function(t){return new Promise(function(e){return chrome.identity.removeCachedAuthToken({token:t},function(){return e()})})}(t);throw l.otherError})}).then(function(){return c=!1})}function y(t){return fetch("".concat(u,"/users/me/calendarList?").concat(h({access_token:t})),{method:"GET",async:!0}).then(function(t){return t.json()}).then(function(t){return t.items})}function m(t){return fetch("".concat(u,"/colors?").concat(h({access_token:t})),{method:"GET",async:!0}).then(function(t){return t.json()})}function w(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:100,s=[];return function n(c,f){return fetch("".concat(u,"/calendars/").concat(t,"/events?").concat(h({access_token:e,pageToken:c,syncToken:f,timeMin:r,timeMax:i,maxResults:a})),{method:"GET",async:!0}).then(function(t){if(200===t.status)return t.json();throw 410===t.status?l.invalidSyncToken:l.otherError}).then(function(t){return s.push.apply(s,o(t.items)),t.nextPageToken?n(t.nextPageToken,""):{nextSyncToken:t.nextSyncToken,results:s}})}("",n)}var b=function(){function t(e,n){var r=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{maxCachedItems:100,nDaysPerSlot:10,largeQuery:10};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.calId=e,this.name=n,this.syncToken="",this.cache=new i.a({max:a.maxCachedItems,dispose:function(t,e){return r.onRemoveSlot(t,e)}}),this.eventMeta={},this.options=a,this.divider=864e5*this.options.nDaysPerSlot}var e,n,r;return e=t,(n=[{key:"dateToCacheKey",value:function(t){return Math.floor(t/this.divider)}},{key:"dateRangeToCacheKeys",value:function(t){return{start:this.dateToCacheKey(t.start),end:this.dateToCacheKey(new Date(t.end.getTime()-1))}}},{key:"getSlot",value:function(t){if(this.cache.has(t))return this.cache.get(t);var e={};return this.cache.set(t,e),e}},{key:"onRemoveSlot",value:function(t,e){for(var n in e){console.assert(this.eventMeta[n]);var r=this.eventMeta[n].keys;r.delete(t),0===r.size&&delete this.eventMeta[n]}}},{key:"slotStartDate",value:function(t){return new Date(t*this.divider)}},{key:"slotEndDate",value:function(t){return new Date((t+1)*this.divider)}},{key:"addEvent",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.eventMeta.hasOwnProperty(t.id)&&this.removeEvent(t);for(var n=this.dateRangeToCacheKeys(t),r=n.start,i=n.end,a=this.cache.length,o=new Set,s=r;s<=i;s++)o.add(s),this.cache.has(s)||a++;if(this.eventMeta[t.id]={keys:o,summary:t.summary},e||!(a>this.options.maxCachedItems))if(r===i)this.getSlot(r)[t.id]={start:t.start,end:t.end,id:t.id};else{this.getSlot(r)[t.id]={start:t.start,end:this.slotEndDate(r),id:t.id},this.getSlot(i)[t.id]={start:this.slotStartDate(i),end:t.end,id:t.id};for(var u=r+1;u=n||r[a].end<=e||i.push({id:a,start:r[a].startn?n:r[a].end,summary:this.eventMeta[a].summary});return i}},{key:"getCachedEvents",value:function(t){for(var e=this.dateRangeToCacheKeys(t),n=e.start,r=e.end,i=this.getSlotEvents(n,t.start,t.end),a=n+1;an&&i.push.apply(i,o(this.getSlotEvents(r,t.start,t.end))),i}},{key:"sync",value:function(){var t=this;return this.token.then(function(e){return w(t.calId,e,t.syncToken).then(function(n){var r=n.results.map(function(n){return n.start?Promise.resolve(n):function(t,e,n){return fetch("".concat(u,"/calendars/").concat(t,"/events/").concat(e,"?").concat(h({access_token:n})),{method:"GET",async:!0}).then(function(t){return t.json()})}(t.calId,n.id,e)});return Promise.all(r).then(function(e){e.forEach(function(e){e.start=new Date(e.start.dateTime),e.end=new Date(e.end.dateTime),"confirmed"===e.status?t.addEvent(e):"cancelled"===e.status&&t.removeEvent(e)}),t.syncToken=n.nextSyncToken})})}).catch(function(e){if(e!==l.invalidSyncToken)throw e;t.syncToken="",t.sync()})}},{key:"getEvents",value:function(t,e){for(var n=this,r=this.dateRangeToCacheKeys({start:t,end:e}),i={},a=r.start;a<=r.end;a++)this.cache.has(a)||(i.hasOwnProperty("start")||(i.start=a),i.end=a);return console.log("start: ".concat(t," end: ").concat(e)),i.hasOwnProperty("start")?(console.assert(i.start<=i.end),i.end-i.start+1>this.options.largeQuery?(console.log("encounter large query, use direct fetch"),this.token.then(function(r){return w(n.calId,r,null,t.toISOString(),e.toISOString()).then(function(n){var r=[];return n.results.forEach(function(t){console.assert(t.start),t.start=new Date(t.start.dateTime),t.end=new Date(t.end.dateTime),r.push(t)}),r.filter(function(n){return!(n.start>=e||n.end<=t)}).map(function(n){return{id:n.id,start:n.starte?e:n.end,summary:n.summary}})})})):(console.log("fetching short event list"),this.token.then(function(t){return w(n.calId,t,null,n.slotStartDate(i.start).toISOString(),n.slotEndDate(i.end).toISOString()).then(function(t){t.results.forEach(function(t){"confirmed"===t.status&&(console.assert(t.start),t.start=new Date(t.start.dateTime),t.end=new Date(t.end.dateTime),n.addEvent(t,!0))}),""===n.syncToken&&(n.syncToken=t.nextSyncToken)})}).then(function(){return n.sync()}).then(function(){return n.getCachedEvents({start:t,end:e})}))):(console.log("cache hit"),this.sync().then(function(){return n.getCachedEvents({start:t,end:e})}))}},{key:"token",get:function(){return v()}}])&&a(e.prototype,n),r&&a(e,r),t}()},848:function(t,e,n){"use strict";n.r(e);var r=n(43),i=n(27),a=[],o=[],s={},u={};chrome.runtime.onConnect.addListener(function(t){console.assert("main"==t.name),t.onMessage.addListener(function(e){var n=i.a.inflate(e);if(console.log(n),n.type==i.c.updatePatterns)"analyze"==n.data.id?o=n.data.patterns:a=n.data.patterns,t.postMessage(n.genResp(null));else if(n.type==i.c.getPatterns){var l;l="analyze"==n.data.id?o:a,t.postMessage(n.genResp(l))}else if(n.type==i.c.updateCalendars){for(var h in s=n.data)u.hasOwnProperty(h)||(u[h]=new r.a(h,s[h].summary));t.postMessage(n.genResp(null))}else if(n.type==i.c.getCalendars){var c=s;n.data.enabledOnly&&(c=Object.keys(s).filter(function(t){return s[t].enabled}).reduce(function(t,e){return t[e]=s[e],t},{})),t.postMessage(n.genResp(c))}else n.type==i.c.getCalEvents?u[n.data.id].getEvents(new Date(n.data.start),new Date(n.data.end)).catch(function(t){return console.log("cannot load calendar ".concat(n.data.id),t),[]}).then(function(e){console.log(e);var r=n.genResp(e.map(function(t){return{id:t.id,start:t.start.getTime(),end:t.end.getTime()}}));console.log(r),t.postMessage(r)}):console.error("unknown msg type")})}),chrome.browserAction.onClicked.addListener(function(){chrome.tabs.create({url:"index.html"})})}}); \ No newline at end of file -- cgit v1.2.3-70-g09d2