UNPKG

@blinkk/editor

Version:

Structured content editor with live previews.

1 lines 1.87 kB
(()=>{"use strict";var t={3640:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SessionDataStorage=e.LocalDataStorage=e.DataStorage=void 0;class r{clear(){return this.storageObj.clear()}get length(){return this.storageObj.length}get storageObj(){return this.storage||(this.storage=new s),this.storage}getItem(t){return this.storageObj.getItem(t)}getItemArray(t){const e=this.getItem(t);return e?JSON.parse(e):[]}getItemBoolean(t,e=!1){const r=this.getItem(t);return null===r?e:"true"===r}getItemRecord(t){const e=this.getItem(t);return e?JSON.parse(e):{}}key(t){return this.storageObj.key(t)}removeItem(t){return this.storageObj.removeItem(t)}setItem(t,e){return this.storageObj.setItem(t,e)}setItemArray(t,e){return this.storageObj.setItem(t,JSON.stringify(e))}setItemBoolean(t,e){return this.storageObj.setItem(t,e?"true":"false")}setItemRecord(t,e){return this.storageObj.setItem(t,JSON.stringify(e))}}e.DataStorage=r,e.LocalDataStorage=class extends r{get storageObj(){return localStorage}},e.SessionDataStorage=class extends r{get storageObj(){return sessionStorage}};class s{constructor(){this.obj={}}clear(){this.obj={}}getItem(t){return void 0!==this.obj[t]?this.obj[t]:null}key(t){const e=Object.keys(this.obj).sort();return t<e.length?this.obj[e[t]]:null}get length(){return Object.keys(this.obj).length}removeItem(t){void 0!==this.obj[t]&&delete this.obj[t]}setItem(t,e){this.obj[t]=e}}}},e={};function r(s){var o=e[s];if(void 0!==o)return o.exports;var a=e[s]={exports:{}};return t[s](a,a.exports,r),a.exports}(()=>{const t=new(r(3640).SessionDataStorage),e=t.getItem("redirectUrl")||"/",s=t.getItem("github.state");s||(console.error("No state defined."),window.location.href=e);const o=new URL(window.location.href);if(s===o.searchParams.get("state")){const e=o.searchParams.get("code");t.setItem("github.code",e)}window.location.href=e})()})();