pubo-web 1.0.141 → 1.0.143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pubo-web.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["pubo-web"]=e():t["pubo-web"]=e()}(this,(()=>(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{DragMethod:()=>v,IndexedStorage:()=>j,WebStorage:()=>l,WebsocketClient:()=>y,blob2base64:()=>s,blob2file:()=>a,blob2text:()=>i,downloadFile:()=>c,getCookie:()=>T,getCookieValue:()=>P,loadScript:()=>o,pickFiles:()=>b,setCookieItem:()=>L});var n,r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},o=function(t,e){return void 0===e&&(e={}),new Promise((function(n){var o,i,s=function(){var e,n,o=document.getElementsByTagName("script");try{for(var i=r(o),s=i.next();!s.done;s=i.next()){var a=s.value;if(a.src===t)return a}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return null}(),a=s;if(s){if("complete"===s._state)return n(t)}else a=document.createElement("script");try{for(var c=r(Object.keys(e)),u=c.next();!u.done;u=c.next()){var l=u.value;a[l]=e[l]}}catch(t){o={error:t}}finally{try{u&&!u.done&&(i=c.return)&&i.call(c)}finally{if(o)throw o.error}}return a.src=t,a.addEventListener("load",(function e(){n(t),a.removeEventListener("load",e),a._state="complete"})),document.body.appendChild(a),"success"}))},i=function(t){return new Promise((function(e){var n=new FileReader;n.onload=function(t){return e(t.target.result)},n.readAsText(t)}))},s=function(t){return new Promise((function(e,n){var r=new FileReader;t?(r.onload=function(t){return e(t.target.result)},r.onabort=function(){return n()},r.readAsDataURL(t)):n("文件爲空!")}))},a=function(t,e,n){return new File(t,e,{type:n})},c=function(t,e){var n=document.createElement("a");n.href=t,e&&(n.download=e),n.style.position="fixed",n.style.visibility="hidden",document.body.appendChild(n),n.click(),document.body.removeChild(n)},u=function(){return u=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},u.apply(this,arguments)},l=function(){function t(t){var e=t.type,n=void 0===e?"sessionStorage":e,r=t.key;this._key=r,this.storage=window[n],this.zip=t.zip}return Object.defineProperty(t.prototype,"state",{get:function(){var t=this.storage.getItem(this._key);return this.zip&&t&&(t=this.zip.inflate(t)),t?JSON.parse(t):null},set:function(t){var e=JSON.stringify(t);this.zip&&(e=this.zip.deflate(e)),this.storage.setItem(this._key,e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"key",{get:function(){return this._key},enumerable:!1,configurable:!0}),t.prototype.merge=function(t){var e=this.state;this.state=u(u({},e),t)},t.prototype.clear=function(){this.storage.removeItem(this._key)},t}(),f=(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),h=function(){return h=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},h.apply(this,arguments)},p=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},d=function(){function t(){this.state={},this.ids={}}return t.prototype.on=function(t,e){if(this.state[t]||(this.state[t]=[]),"function"!=typeof e)throw new Error("第二个参数必须为function!");var n=this.state[t].push(e)-1,r=function(t){void 0===t&&(t=8);var e=function(t){return Math.random().toString(32).slice(2,2+t)};if(t<=8)return e(t);for(var n="",r=0;r<=t;r+=8)n+=e(t-r>8?8:t-r);return n}(40);return this.ids[r]={event:t,index:n},r},t.prototype.cancel=function(t){var e=this;if(t){var n=this.ids[t]||{},r=n.event,o=n.index;r&&Array.isArray(this.state[r])&&(this.state[r].splice(o,1),delete this.ids[t],Object.keys(this.ids).forEach((function(t){e.ids[t].event===r&&e.ids[t].index>o&&(e.ids[t].index=e.ids[t].index-1)})))}else this.clear()},t.prototype.clear=function(){this.state.length=0},t.prototype.emit=function(t,e){var n,r;if(Array.isArray(this.state[t]))try{for(var o=p(this.state[t]),i=o.next();!i.done;i=o.next()){var s=i.value;"function"==typeof s&&s(e)}}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},t.prototype.emitSync=function(t,e){return n=this,r=void 0,i=function(){var n,r,o,i,s,a;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(c){switch(c.label){case 0:if(!Array.isArray(this.state[t]))return[3,8];c.label=1;case 1:c.trys.push([1,6,7,8]),n=p(this.state[t]),r=n.next(),c.label=2;case 2:return r.done?[3,5]:"function"!=typeof(o=r.value)?[3,4]:[4,o(e)];case 3:c.sent(),c.label=4;case 4:return r=n.next(),[3,2];case 5:return[3,8];case 6:return i=c.sent(),s={error:i},[3,8];case 7:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 8:return[2]}}))},new((o=void 0)||(o=Promise))((function(t,e){function s(t){try{c(i.next(t))}catch(t){e(t)}}function a(t){try{c(i.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(s,a)}c((i=i.apply(n,r||[])).next())}));var n,r,o,i},t.prototype.clone=function(){return{state:h({},this.state),ids:h({},this.ids)}},t.prototype.restore=function(t){this.state=t.state,this.ids=t.ids},t}(),y=(function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._cache={},e}f(e,t),e.prototype.emit=function(e,n){this._cache[e]=n,t.prototype.emit.call(this,e,n)},e.prototype.getState=function(t){return this._cache[t]}}(d),function(){function t(t){var e=t.url;this.client=null,this._status=0,this.emitter=new d,this.url=e}return t.prototype.reconnect=function(){var t=this;this.client&&this.client.close(),this.client=null,3===this._status&&setTimeout((function(){return t.connect()}),1e3)},t.prototype.onClose=function(){2!==this._status&&(this._status=3),this.reconnect()},t.prototype.onMessage=function(t){this.emitter.emit("message",t.data)},Object.defineProperty(t.prototype,"status",{get:function(){return this._status},enumerable:!1,configurable:!0}),t.prototype.connect=function(){var t=this;this.client||(this.client=new WebSocket(this.url),this.client.onclose=this.onClose.bind(this),this.client.onmessage=this.onMessage.bind(this),this.client.onopen=function(){t.emitter.emit("connect"),t._status=1})},t.prototype.close=function(){this._status=2,this.client&&this.client.close(),this.client=null},t.prototype.send=function(t,e){var n;void 0===e&&(e=!1);var r=t;e&&(r=JSON.stringify(t)),null===(n=this.client)||void 0===n||n.send(r)},t}()),v=function(){function t(t){var e=void 0===t?{}:t,n=e.key,r=void 0===n?"":n,o=e.onMove,i=e.onMoveEnd;this.key="",this.cache={pageX:0,pageY:0,dragging:!1},this.key=r,this.onMouseDown=this._onMouseDown.bind(this),this.onTouchStart=this._onMouseDown.bind(this),this.onMouseMove=this._onMouseMove.bind(this),this.onMouseUp=this._onMouseUp.bind(this),this.onMove=o,this.onMoveEnd=i}return t.prototype._onMouseMove=function(t){var e,n,r,o;if("function"==typeof this.onMove){t.preventDefault?t.preventDefault():t.returnValue=!1;var i=null!==(e=t.pageX)&&void 0!==e?e:null===(n=t.touches[0])||void 0===n?void 0:n.pageX,s=null!==(r=t.pageY)&&void 0!==r?r:null===(o=t.touches[0])||void 0===o?void 0:o.pageY;this.onMove({offsetX:i-this.cache.pageX,offsetY:s-this.cache.pageY,pageX:i,pageY:s,startX:this.cache.pageX,startY:this.cache.pageY,key:this.key}),this.cache.pageX=i,this.cache.pageY=s}},t.prototype.clearListener=function(){window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("touchmove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("touchend",this.onMouseUp)},t.prototype._onMouseUp=function(){this.clearListener(),this.cache.dragging=!1,"function"==typeof this.onMoveEnd&&this.onMoveEnd()},t.prototype._onMouseDown=function(t){var e,n,r,o;if(t.preventDefault&&t.pageX?t.preventDefault():t.returnValue=!1,"function"==typeof this.onMove&&!this.cache.dragging){this.clearListener();var i=null!==(e=t.pageX)&&void 0!==e?e:null===(n=t.touches[0])||void 0===n?void 0:n.pageX,s=null!==(r=t.pageY)&&void 0!==r?r:null===(o=t.touches[0])||void 0===o?void 0:o.pageY;this.cache.dragging=!0,this.cache.pageX=i,this.cache.pageY=s,window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("touchmove",this.onMouseMove,{passive:!1}),window.addEventListener("mouseup",this.onMouseUp),window.addEventListener("touchend",this.onMouseUp,{passive:!1})}},t}(),b=function(){return new Promise((function(t,e){var n=document.createElement("input"),r=!1;n.type="file",n.style.visibility="hidden",n.style.position="fixed",n.style.top="0px",n.style.zIndex="-1",window.addEventListener("focus",(function t(){document.body.removeChild(n),window.removeEventListener("focus",t),setTimeout((function(){r||e("no files picked")}),1e3)})),n.onchange=function(e){r=e.target.files.length>0,t(e.target.files)},document.body.appendChild(n),n.click()}))},g=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},m=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},w=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},x=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},S=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},k=function(){function t(t,e,n){this.indexedDB=self.indexedDB,this.get=this.createTransaction((function(t,e){return t.get(e)})),this.getAll=this.createTransaction((function(t){return t.getAll()})),this.delete=this.createTransaction((function(t,e){return t.delete(e)})),this.put=this.createTransaction((function(t,e){return t.put(e)})),this.name=t,this.version=e,this.tables=n}return t.prototype.open=function(){var t=this;return new Promise((function(e,n){var r,o=null===(r=t.indexedDB)||void 0===r?void 0:r.open(t.name,t.version);o.onupgradeneeded=function(e){return g(t,void 0,void 0,(function(){var t,n,r,o,i,s,a=this;return m(this,(function(c){t=e.target.result,this.transaction=e.target.transaction,this.transaction.oncomplete=function(){return g(a,void 0,void 0,(function(){var t,e,n,r,o,i;return m(this,(function(s){switch(s.label){case 0:this.transaction=null,s.label=1;case 1:s.trys.push([1,6,7,8]),t=w(this.tables),e=t.next(),s.label=2;case 2:return e.done?[3,5]:(n=e.value).default?[4,this.put(n.name,n.default)]:[3,4];case 3:s.sent(),s.label=4;case 4:return e=t.next(),[3,2];case 5:return[3,8];case 6:return r=s.sent(),o={error:r},[3,8];case 7:try{e&&!e.done&&(i=t.return)&&i.call(t)}finally{if(o)throw o.error}return[7];case 8:return[2]}}))}))};try{for(n=w(this.tables),r=n.next();!r.done;r=n.next())o=r.value,t.objectStoreNames.contains(o.name)||t.createObjectStore(o.name,o.options||{keyPath:"_id",autoIncrement:!0})}catch(t){i={error:t}}finally{try{r&&!r.done&&(s=n.return)&&s.call(n)}finally{if(i)throw i.error}}return this.db=t,[2]}))}))},o.onsuccess=function(){t.db||(t.db=o.result),e("success")},o.onerror=function(t){console.error("indexed db connect error: ",t),n(t)}}))},t.prototype.createTransaction=function(t){var e=this;return function(n){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];return new Promise((function(o,i){if(e.db){var s=e.db.transaction([n],"readwrite").objectStore(n),a=t.apply(void 0,S([s],x(r),!1));a.onerror=function(t){i(t)},a.onsuccess=function(){o(a.result)}}else i("not connect")}))}},t}(),_=function(){return _=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},_.apply(this,arguments)},M=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},E=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},O=function(){function t(t,e){this.utils=t,this.store=e}return t.prototype.getState=function(){return M(this,void 0,void 0,(function(){return E(this,(function(t){return[2,this.utils.get(this.store,1)]}))}))},t.prototype.setState=function(t){this.utils.put(this.store,_(_({},t),{_id:1}))},t.prototype.merge=function(t){return M(this,void 0,void 0,(function(){var e;return E(this,(function(n){switch(n.label){case 0:return[4,this.getState()];case 1:return e=n.sent(),this.setState=_(_(_({},e),t),{_id:1}),[2]}}))}))},t}(),j=function(){function t(t){var e=t.name,n=t.version,r=t.tables;this._cache={},this.tables=[],this.connected=!1,this.connecting=!1,this.name=e,this.version=n,this.tables=null!=r?r:[]}return t.prototype.register=function(t){var e;(e=this.tables).push.apply(e,function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}([],function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}(t),!1))},t.prototype.connect=function(){return M(this,void 0,void 0,(function(){return E(this,(function(t){switch(t.label){case 0:if(this.connected)return[2];if(!this.connecting)return[3,4];t.label=1;case 1:return this.connecting?[3,3]:[4,(100,e=void 0,n=void 0,r=void 0,o=function(){return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t){return setTimeout((function(){return t()}),100)}))];case 1:return t.sent(),[2]}}))},new(r||(r=Promise))((function(t,i){function s(t){try{c(o.next(t))}catch(t){i(t)}}function a(t){try{c(o.throw(t))}catch(t){i(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(s,a)}c((o=o.apply(e,n||[])).next())})))];case 2:return t.sent(),[3,1];case 3:return[2];case 4:return this.connecting=!0,this.utils=new k(this.name,this.version,this.tables),[4,this.utils.open()];case 5:return t.sent(),this.connected=!0,this.connecting=!1,[2]}var e,n,r,o}))}))},t.prototype.get=function(t){return!this._cache[t]&&this.utils&&(this._cache[t]=new O(this.utils,t)),this._cache[t]},t}(),P=function(t){var e=new RegExp("(^| )".concat(t,"=([^;]*)(;|$)")).exec(document.cookie);return e?e[2]:""},T=function(){var t={};return document.cookie?(document.cookie.split(";").forEach((function(e){var n=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}(e.split("="),2),r=n[0],o=n[1];t[r]=o})),t):t},L=function(t,e){document.cookie="".concat(t,"=").concat(e)};return e})()));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["pubo-web"]=e():t["pubo-web"]=e()}(this,(()=>(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}t.r(e),t.d(e,{DragMethod:()=>M,IndexedStorage:()=>B,WebStorage:()=>f,WebsocketClient:()=>S,blob2base64:()=>o,blob2file:()=>s,blob2text:()=>i,downloadFile:()=>u,getCookie:()=>$,getCookieValue:()=>R,loadScript:()=>r,pickFiles:()=>j,setCookieItem:()=>J});var r=function(t,e){return void 0===e&&(e={}),new Promise((function(r){var i=function(){for(var e,r=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(document.getElementsByTagName("script"));!(e=r()).done;){var i=e.value;if(i.src===t)return i}return null}(),o=i;if(i){if("complete"===i._state)return r(t)}else o=document.createElement("script");for(var s=0,u=Object.keys(e);s<u.length;s++){var a=u[s];o[a]=e[a]}return o.src=t,o.addEventListener("load",(function e(){r(t),o.removeEventListener("load",e),o._state="complete"})),document.body.appendChild(o),"success"}))},i=function(t){return new Promise((function(e){var n=new FileReader;n.onload=function(t){return e(t.target.result)},n.readAsText(t)}))},o=function(t){return new Promise((function(e,n){var r=new FileReader;t?(r.onload=function(t){return e(t.target.result)},r.onabort=function(){return n()},r.readAsDataURL(t)):n("文件爲空!")}))},s=function(t,e,n){return new File(t,e,{type:n})},u=function(t,e){var n=document.createElement("a");n.href=t,e&&(n.download=e),n.style.position="fixed",n.style.visibility="hidden",document.body.appendChild(n),n.click(),document.body.removeChild(n)};function a(){return a=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},a.apply(this,arguments)}function c(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(i=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(r.key))?i:String(i)),r)}var i}var f=function(){function t(t){this._key=void 0,this.storage=void 0,this.zip=void 0;var e=t.type,n=void 0===e?"sessionStorage":e,r=t.key;this._key=r,this.storage=window[n],this.zip=t.zip}var e,n,r=t.prototype;return r.merge=function(t){var e=this.state;this.state=a({},e,t)},r.clear=function(){this.storage.removeItem(this._key)},e=t,(n=[{key:"state",get:function(){var t=this.storage.getItem(this._key);return this.zip&&t&&(t=this.zip.inflate(t)),t?JSON.parse(t):null},set:function(t){var e=JSON.stringify(t);this.zip&&(e=this.zip.deflate(e)),this.storage.setItem(this._key,e)}},{key:"key",get:function(){return this._key}}])&&c(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function h(){}function l(t){var e=t();if(e&&e.then)return e.then(h)}var v="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function d(t,e,n){if(!t.s){if(n instanceof p){if(!n.s)return void(n.o=d.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(d.bind(null,t,e),d.bind(null,t,2));t.s=e,t.v=n;var r=t.o;r&&r(t)}}var p=function(){function t(){}return t.prototype.then=function(e,n){var r=new t,i=this.s;if(i){var o=1&i?e:n;if(o){try{d(r,1,o(this.v))}catch(t){d(r,2,t)}return r}return this}return this.o=function(t){try{var i=t.v;1&t.s?d(r,1,e?e(i):i):n?d(r,1,n(i)):d(r,2,i)}catch(t){d(r,2,t)}},r},t}();function y(t){return t instanceof p&&1&t.s}function b(){return b=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},b.apply(this,arguments)}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var g=function(){function t(){this.state={},this.ids={}}var e=t.prototype;return e.on=function(t,e){if(this.state[t]||(this.state[t]=[]),"function"!=typeof e)throw new Error("第二个参数必须为function!");var n=this.state[t].push(e)-1,r=function(t){void 0===t&&(t=8);var e=function(t){return Math.random().toString(32).slice(2,2+t)};if(t<=8)return e(t);for(var n="",r=0;r<=t;r+=8)n+=e(t-r>8?8:t-r);return n}(40);return this.ids[r]={event:t,index:n},r},e.cancel=function(t){var e=this;if(t){var n=this.ids[t]||{},r=n.event,i=n.index;r&&Array.isArray(this.state[r])&&(this.state[r].splice(i,1),delete this.ids[t],Object.keys(this.ids).forEach((function(t){e.ids[t].event===r&&e.ids[t].index>i&&(e.ids[t].index=e.ids[t].index-1)})))}else this.clear()},e.clear=function(){this.state.length=0},e.emit=function(t,e){if(Array.isArray(this.state[t]))for(var n,r=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return m(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)?m(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[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.")}(this.state[t]);!(n=r()).done;){var i=n.value;"function"==typeof i&&i(e)}},e.emitSync=function(t,e){try{var n=this;return(r=l((function(){if(Array.isArray(n.state[t]))return function(t){if(t&&t.then)return t.then(h)}(function(t,e,n){if("function"==typeof t[v]){var r,i,o,s=t[v]();if(function t(u){try{for(;!((r=s.next()).done||n&&n());)if((u=e(r.value))&&u.then){if(!y(u))return void u.then(t,o||(o=d.bind(null,i=new p,2)));u=u.v}i?d(i,1,u):i=u}catch(t){d(i||(i=new p),2,t)}}(),s.return){var u=function(t){try{r.done||s.return()}catch(t){}return t};if(i&&i.then)return i.then(u,(function(t){throw u(t)}));u()}return i}if(!("length"in t))throw new TypeError("Object is not iterable");for(var a=[],c=0;c<t.length;c++)a.push(t[c]);return function(t,e,n){var r,i,o=-1;return function s(u){try{for(;++o<t.length&&(!n||!n());)if((u=e(o))&&u.then){if(!y(u))return void u.then(s,i||(i=d.bind(null,r=new p,2)));u=u.v}r?d(r,1,u):r=u}catch(t){d(r||(r=new p),2,t)}}(),r}(a,(function(t){return e(a[t])}),n)}(n.state[t],(function(t){return l((function(){if("function"==typeof t)return function(t,e){return t&&t.then?t.then(h):Promise.resolve()}(t(e))}))})))})))&&r.then||(r=Promise.resolve(r)),r}catch(t){return Promise.reject(t)}var r},e.clone=function(){return{state:b({},this.state),ids:b({},this.ids)}},e.restore=function(t){this.state=t.state,this.ids=t.ids},t}();function w(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(i=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(r.key))?i:String(i)),r)}var i}var S=function(){function t(t){var e=t.url;this.client=null,this._status=0,this.url=void 0,this.emitter=new g,this.url=e}var e,n,r=t.prototype;return r.reconnect=function(){var t=this;this.client&&this.client.close(),this.client=null,3===this._status&&setTimeout((function(){return t.connect()}),1e3)},r.onClose=function(){2!==this._status&&(this._status=3),this.reconnect()},r.onMessage=function(t){this.emitter.emit("message",t.data)},r.connect=function(){var t=this;this.client||(this.client=new WebSocket(this.url),this.client.onclose=this.onClose.bind(this),this.client.onmessage=this.onMessage.bind(this),this.client.onopen=function(){t.emitter.emit("connect"),t._status=1})},r.close=function(){this._status=2,this.client&&this.client.close(),this.client=null},r.send=function(t,e){var n;void 0===e&&(e=!1);var r=t;e&&(r=JSON.stringify(t)),null==(n=this.client)||n.send(r)},e=t,(n=[{key:"status",get:function(){return this._status}}])&&w(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}(),M=function(){function t(t){var e=void 0===t?{}:t,n=e.key,r=void 0===n?"":n,i=e.onMove,o=e.onMoveEnd;this.key="",this.cache={pageX:0,pageY:0,dragging:!1},this.onMouseMove=void 0,this.onMouseUp=void 0,this.onMouseDown=void 0,this.onTouchStart=void 0,this.onMove=void 0,this.onMoveEnd=void 0,this.key=r,this.onMouseDown=this._onMouseDown.bind(this),this.onTouchStart=this._onMouseDown.bind(this),this.onMouseMove=this._onMouseMove.bind(this),this.onMouseUp=this._onMouseUp.bind(this),this.onMove=i,this.onMoveEnd=o}var e=t.prototype;return e._onMouseMove=function(t){var e,n,r,i;if("function"==typeof this.onMove){t.preventDefault?t.preventDefault():t.returnValue=!1;var o=null!=(e=t.pageX)?e:null==(n=t.touches[0])?void 0:n.pageX,s=null!=(r=t.pageY)?r:null==(i=t.touches[0])?void 0:i.pageY;this.onMove({offsetX:o-this.cache.pageX,offsetY:s-this.cache.pageY,pageX:o,pageY:s,startX:this.cache.pageX,startY:this.cache.pageY,key:this.key}),this.cache.pageX=o,this.cache.pageY=s}},e.clearListener=function(){window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("touchmove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("touchend",this.onMouseUp)},e._onMouseUp=function(){this.clearListener(),this.cache.dragging=!1,"function"==typeof this.onMoveEnd&&this.onMoveEnd()},e._onMouseDown=function(t){var e,n,r,i;if(t.preventDefault&&t.pageX?t.preventDefault():t.returnValue=!1,"function"==typeof this.onMove&&!this.cache.dragging){this.clearListener();var o=null!=(e=t.pageX)?e:null==(n=t.touches[0])?void 0:n.pageX,s=null!=(r=t.pageY)?r:null==(i=t.touches[0])?void 0:i.pageY;this.cache.dragging=!0,this.cache.pageX=o,this.cache.pageY=s,window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("touchmove",this.onMouseMove,{passive:!1}),window.addEventListener("mouseup",this.onMouseUp),window.addEventListener("touchend",this.onMouseUp,{passive:!1})}},t}(),j=function(){return new Promise((function(t,e){var n=document.createElement("input"),r=!1;n.type="file",n.style.visibility="hidden",n.style.position="fixed",n.style.top="0px",n.style.zIndex="-1",window.addEventListener("focus",(function t(){document.body.removeChild(n),window.removeEventListener("focus",t),setTimeout((function(){r||e("no files picked")}),1e3)})),n.onchange=function(e){r=e.target.files.length>0,t(e.target.files)},document.body.appendChild(n),n.click()}))};function P(){}var k,O=(k=function(t){return(e=new Promise((function(e){return setTimeout(e,t)})))&&e.then?e.then(P):Promise.resolve();var e},function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return Promise.resolve(k.apply(this,t))}catch(t){return Promise.reject(t)}});function E(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(t.apply(this,e))}catch(t){return Promise.reject(t)}}}function _(){}var A="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function x(t,e,n){if(!t.s){if(n instanceof T){if(!n.s)return void(n.o=x.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(x.bind(null,t,e),x.bind(null,t,2));t.s=e,t.v=n;var r=t.o;r&&r(t)}}var T=function(){function t(){}return t.prototype.then=function(e,n){var r=new t,i=this.s;if(i){var o=1&i?e:n;if(o){try{x(r,1,o(this.v))}catch(t){x(r,2,t)}return r}return this}return this.o=function(t){try{var i=t.v;1&t.s?x(r,1,e?e(i):i):n?x(r,1,n(i)):x(r,2,i)}catch(t){x(r,2,t)}},r},t}();function I(t){return t instanceof T&&1&t.s}function L(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var C=function(){function t(t,e,n){this.name=void 0,this.version=void 0,this.indexedDB=self.indexedDB,this.tables=void 0,this.db=void 0,this.transaction=void 0,this.get=this.createTransaction((function(t,e){return t.get(e)})),this.getAll=this.createTransaction((function(t){return t.getAll()})),this.delete=this.createTransaction((function(t,e){return t.delete(e)})),this.put=this.createTransaction((function(t,e){return t.put(e)})),this.name=t,this.version=e,this.tables=n}var e=t.prototype;return e.open=function(){var t=this;return new Promise((function(e,n){var r,i=null==(r=t.indexedDB)?void 0:r.open(t.name,t.version);i.onupgradeneeded=E((function(e){var n,r=e.target.result;t.transaction=e.target.transaction,t.transaction.oncomplete=E((function(){return t.transaction=null,function(t){if(t&&t.then)return t.then(_)}(function(t,e,n){if("function"==typeof t[A]){var r,i,o,s=t[A]();if(function t(u){try{for(;!((r=s.next()).done||n&&n());)if((u=e(r.value))&&u.then){if(!I(u))return void u.then(t,o||(o=x.bind(null,i=new T,2)));u=u.v}i?x(i,1,u):i=u}catch(t){x(i||(i=new T),2,t)}}(),s.return){var u=function(t){try{r.done||s.return()}catch(t){}return t};if(i&&i.then)return i.then(u,(function(t){throw u(t)}));u()}return i}if(!("length"in t))throw new TypeError("Object is not iterable");for(var a=[],c=0;c<t.length;c++)a.push(t[c]);return function(t,e,n){var r,i,o=-1;return function s(u){try{for(;++o<t.length&&(!n||!n());)if((u=e(o))&&u.then){if(!I(u))return void u.then(s,i||(i=x.bind(null,r=new T,2)));u=u.v}r?x(r,1,u):r=u}catch(t){x(r||(r=new T),2,t)}}(),r}(a,(function(t){return e(a[t])}),n)}(t.tables,(function(e){return function(n){var r=function(){if(e.default)return function(t,e){if(!void 0)return t&&t.then?t.then(_):Promise.resolve()}(t.put(e.name,e.default))}();if(r&&r.then)return r.then(_)}()})))}));for(var i,o=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(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}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[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.")}(t.tables);!(i=o()).done;){var s=i.value;r.objectStoreNames.contains(s.name)||r.createObjectStore(s.name,s.options||{keyPath:"_id",autoIncrement:!0})}return t.db=r,n&&n.then||(n=Promise.resolve(n)),n})),i.onsuccess=function(){t.db||(t.db=i.result),e("success")},i.onerror=function(t){console.error("indexed db connect error: ",t),n(t)}}))},e.createTransaction=function(t){var e=this;return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];return new Promise((function(r,o){if(e.db){var s=e.db.transaction([n],"readwrite").objectStore(n),u=t.apply(void 0,[s].concat(i));u.onerror=function(t){o(t)},u.onsuccess=function(){r(u.result)}}else o("not connect")}))}},t}();function D(t,e,n){return n?e?e(t):t:(t&&t.then||(t=Promise.resolve(t)),e?t.then(e):t)}function X(){}function U(t,e,n){if(!t.s){if(n instanceof Y){if(!n.s)return void(n.o=U.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(U.bind(null,t,e),U.bind(null,t,2));t.s=e,t.v=n;var r=t.o;r&&r(t)}}var Y=function(){function t(){}return t.prototype.then=function(e,n){var r=new t,i=this.s;if(i){var o=1&i?e:n;if(o){try{U(r,1,o(this.v))}catch(t){U(r,2,t)}return r}return this}return this.o=function(t){try{var i=t.v;1&t.s?U(r,1,e?e(i):i):n?U(r,1,n(i)):U(r,2,i)}catch(t){U(r,2,t)}},r},t}();function z(t){return t instanceof Y&&1&t.s}function F(){return F=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},F.apply(this,arguments)}var N=function(){function t(t,e){this.utils=void 0,this.store=void 0,this.utils=t,this.store=e}var e=t.prototype;return e.getState=function(){try{return D(this.utils.get(this.store,1))}catch(t){return Promise.reject(t)}},e.setState=function(t){this.utils.put(this.store,F({},t,{_id:1}))},e.merge=function(t){try{var e=this;return D(e.getState(),(function(n){e.setState=F({},n,t,{_id:1})}))}catch(t){return Promise.reject(t)}},t}(),B=function(){function t(t){var e=t.name,n=t.version,r=t.tables;this.name=void 0,this.version=void 0,this.utils=void 0,this._cache={},this.tables=[],this.connected=!1,this.connecting=!1,this.name=e,this.version=n,this.tables=null!=r?r:[]}var e=t.prototype;return e.register=function(t){var e;(e=this.tables).push.apply(e,t)},e.connect=function(){try{var t=!1,e=this;return e.connected?D():D((n=function(){if(e.connecting)return n=function(t,e,n){for(var r;;){var i=t();if(z(i)&&(i=i.v),!i)return o;if(i.then){r=0;break}var o=n();if(o&&o.then){if(!z(o)){r=1;break}o=o.s}if(e){var s=e();if(s&&s.then&&!z(s)){r=2;break}}}var u=new Y,a=U.bind(null,u,2);return(0===r?i.then(f):1===r?o.then(c):s.then(h)).then(void 0,a),u;function c(r){o=r;do{if(e&&(s=e())&&s.then&&!z(s))return void s.then(h).then(void 0,a);if(!(i=t())||z(i)&&!i.v)return void U(u,1,o);if(i.then)return void i.then(f).then(void 0,a);z(o=n())&&(o=o.v)}while(!o||!o.then);o.then(c).then(void 0,a)}function f(t){t?(o=n())&&o.then?o.then(c).then(void 0,a):c(o):U(u,1,o)}function h(){(i=t())?i.then?i.then(f).then(void 0,a):f(i):U(u,1,o)}}((function(){return!e.connecting}),void 0,(function(){return function(t,e){return t&&t.then?t.then(X):Promise.resolve()}(O(100))})),r=function(){t=!0},n&&n.then?n.then(r):r();var n,r},r=function(n){return t?n:(e.connecting=!0,e.utils=new C(e.name,e.version,e.tables),D(e.utils.open(),(function(){e.connected=!0,e.connecting=!1})))},(i=n())&&i.then?i.then(r):r(i)))}catch(t){return Promise.reject(t)}var n,r,i},e.get=function(t){return!this._cache[t]&&this.utils&&(this._cache[t]=new N(this.utils,t)),this._cache[t]},t}(),R=function(t){var e=new RegExp("(^| )"+t+"=([^;]*)(;|$)").exec(document.cookie);return e?e[2]:""},$=function(){var t={};return document.cookie?(document.cookie.split(";").forEach((function(e){var n=e.split("="),r=n[0],i=n[1];t[r]=i})),t):t},J=function(t,e){document.cookie=t+"="+e};return e})()));
package/es/dom/drag.js CHANGED
@@ -1,19 +1,25 @@
1
1
  /**
2
2
  * Class for handling drag events in a UI.
3
3
  */
4
- var DragMethod = /** @class */function () {
5
- function DragMethod(_a) {
6
- var _b = _a === void 0 ? {} : _a,
7
- _c = _b.key,
8
- key = _c === void 0 ? '' : _c,
9
- onMove = _b.onMove,
10
- onMoveEnd = _b.onMoveEnd;
4
+ export var DragMethod = /*#__PURE__*/function () {
5
+ function DragMethod(_temp) {
6
+ var _ref = _temp === void 0 ? {} : _temp,
7
+ _ref$key = _ref.key,
8
+ key = _ref$key === void 0 ? '' : _ref$key,
9
+ onMove = _ref.onMove,
10
+ onMoveEnd = _ref.onMoveEnd;
11
11
  this.key = '';
12
12
  this.cache = {
13
13
  pageX: 0,
14
14
  pageY: 0,
15
15
  dragging: false
16
16
  };
17
+ this.onMouseMove = void 0;
18
+ this.onMouseUp = void 0;
19
+ this.onMouseDown = void 0;
20
+ this.onTouchStart = void 0;
21
+ this.onMove = void 0;
22
+ this.onMoveEnd = void 0;
17
23
  this.key = key;
18
24
  this.onMouseDown = this._onMouseDown.bind(this);
19
25
  this.onTouchStart = this._onMouseDown.bind(this);
@@ -22,8 +28,9 @@ var DragMethod = /** @class */function () {
22
28
  this.onMove = onMove;
23
29
  this.onMoveEnd = onMoveEnd;
24
30
  }
25
- DragMethod.prototype._onMouseMove = function (e) {
26
- var _a, _b, _c, _d;
31
+ var _proto = DragMethod.prototype;
32
+ _proto._onMouseMove = function _onMouseMove(e) {
33
+ var _e$pageX, _e$touches$, _e$pageY, _e$touches$2;
27
34
  if (typeof this.onMove !== 'function') {
28
35
  return;
29
36
  }
@@ -32,8 +39,8 @@ var DragMethod = /** @class */function () {
32
39
  } else {
33
40
  e.returnValue = false;
34
41
  }
35
- var pageX = (_a = e.pageX) !== null && _a !== void 0 ? _a : (_b = e.touches[0]) === null || _b === void 0 ? void 0 : _b.pageX;
36
- var pageY = (_c = e.pageY) !== null && _c !== void 0 ? _c : (_d = e.touches[0]) === null || _d === void 0 ? void 0 : _d.pageY;
42
+ var pageX = (_e$pageX = e.pageX) != null ? _e$pageX : (_e$touches$ = e.touches[0]) == null ? void 0 : _e$touches$.pageX;
43
+ var pageY = (_e$pageY = e.pageY) != null ? _e$pageY : (_e$touches$2 = e.touches[0]) == null ? void 0 : _e$touches$2.pageY;
37
44
  this.onMove({
38
45
  offsetX: pageX - this.cache.pageX,
39
46
  offsetY: pageY - this.cache.pageY,
@@ -46,21 +53,21 @@ var DragMethod = /** @class */function () {
46
53
  this.cache.pageX = pageX;
47
54
  this.cache.pageY = pageY;
48
55
  };
49
- DragMethod.prototype.clearListener = function () {
56
+ _proto.clearListener = function clearListener() {
50
57
  window.removeEventListener('mousemove', this.onMouseMove);
51
58
  window.removeEventListener('touchmove', this.onMouseMove);
52
59
  window.removeEventListener('mouseup', this.onMouseUp);
53
60
  window.removeEventListener('touchend', this.onMouseUp);
54
61
  };
55
- DragMethod.prototype._onMouseUp = function () {
62
+ _proto._onMouseUp = function _onMouseUp() {
56
63
  this.clearListener();
57
64
  this.cache.dragging = false;
58
65
  if (typeof this.onMoveEnd === 'function') {
59
66
  this.onMoveEnd();
60
67
  }
61
68
  };
62
- DragMethod.prototype._onMouseDown = function (e) {
63
- var _a, _b, _c, _d;
69
+ _proto._onMouseDown = function _onMouseDown(e) {
70
+ var _e$pageX2, _e$touches$3, _e$pageY2, _e$touches$4;
64
71
  if (e.preventDefault && e.pageX) {
65
72
  e.preventDefault();
66
73
  } else {
@@ -70,8 +77,8 @@ var DragMethod = /** @class */function () {
70
77
  return;
71
78
  }
72
79
  this.clearListener();
73
- var pageX = (_a = e.pageX) !== null && _a !== void 0 ? _a : (_b = e.touches[0]) === null || _b === void 0 ? void 0 : _b.pageX;
74
- var pageY = (_c = e.pageY) !== null && _c !== void 0 ? _c : (_d = e.touches[0]) === null || _d === void 0 ? void 0 : _d.pageY;
80
+ var pageX = (_e$pageX2 = e.pageX) != null ? _e$pageX2 : (_e$touches$3 = e.touches[0]) == null ? void 0 : _e$touches$3.pageX;
81
+ var pageY = (_e$pageY2 = e.pageY) != null ? _e$pageY2 : (_e$touches$4 = e.touches[0]) == null ? void 0 : _e$touches$4.pageY;
75
82
  this.cache.dragging = true;
76
83
  this.cache.pageX = pageX;
77
84
  this.cache.pageY = pageY;
@@ -85,5 +92,4 @@ var DragMethod = /** @class */function () {
85
92
  });
86
93
  };
87
94
  return DragMethod;
88
- }();
89
- export { DragMethod };
95
+ }();
@@ -1,19 +1,6 @@
1
- var __values = this && this.__values || function (o) {
2
- var s = typeof Symbol === "function" && Symbol.iterator,
3
- m = s && o[s],
4
- i = 0;
5
- if (m) return m.call(o);
6
- if (o && typeof o.length === "number") return {
7
- next: function next() {
8
- if (o && i >= o.length) o = void 0;
9
- return {
10
- value: o && o[i++],
11
- done: !o
12
- };
13
- }
14
- };
15
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
16
- };
1
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
17
4
  /**
18
5
  * Loads a script from the given URL with the provided options.
19
6
  *
@@ -26,30 +13,16 @@ export var loadScript = function loadScript(url, options) {
26
13
  options = {};
27
14
  }
28
15
  var findScript = function findScript() {
29
- var e_1, _a;
30
16
  var list = document.getElementsByTagName('script');
31
- try {
32
- for (var list_1 = __values(list), list_1_1 = list_1.next(); !list_1_1.done; list_1_1 = list_1.next()) {
33
- var item = list_1_1.value;
34
- if (item.src === url) {
35
- return item;
36
- }
37
- }
38
- } catch (e_1_1) {
39
- e_1 = {
40
- error: e_1_1
41
- };
42
- } finally {
43
- try {
44
- if (list_1_1 && !list_1_1.done && (_a = list_1["return"])) _a.call(list_1);
45
- } finally {
46
- if (e_1) throw e_1.error;
17
+ for (var _iterator = _createForOfIteratorHelperLoose(list), _step; !(_step = _iterator()).done;) {
18
+ var item = _step.value;
19
+ if (item.src === url) {
20
+ return item;
47
21
  }
48
22
  }
49
23
  return null;
50
24
  };
51
25
  return new Promise(function (resolve) {
52
- var e_2, _a;
53
26
  var old = findScript();
54
27
  var el = old;
55
28
  if (!old) {
@@ -57,21 +30,9 @@ export var loadScript = function loadScript(url, options) {
57
30
  } else if (old._state === 'complete') {
58
31
  return resolve(url);
59
32
  }
60
- try {
61
- for (var _b = __values(Object.keys(options)), _c = _b.next(); !_c.done; _c = _b.next()) {
62
- var key = _c.value;
63
- el[key] = options[key];
64
- }
65
- } catch (e_2_1) {
66
- e_2 = {
67
- error: e_2_1
68
- };
69
- } finally {
70
- try {
71
- if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
72
- } finally {
73
- if (e_2) throw e_2.error;
74
- }
33
+ for (var _i = 0, _Object$keys = Object.keys(options); _i < _Object$keys.length; _i++) {
34
+ var key = _Object$keys[_i];
35
+ el[key] = options[key];
75
36
  }
76
37
  var onLoad = function onLoad() {
77
38
  resolve(url);
@@ -1,27 +1,5 @@
1
- var __read = this && this.__read || function (o, n) {
2
- var m = typeof Symbol === "function" && o[Symbol.iterator];
3
- if (!m) return o;
4
- var i = m.call(o),
5
- r,
6
- ar = [],
7
- e;
8
- try {
9
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
10
- } catch (error) {
11
- e = {
12
- error: error
13
- };
14
- } finally {
15
- try {
16
- if (r && !r.done && (m = i["return"])) m.call(i);
17
- } finally {
18
- if (e) throw e.error;
19
- }
20
- }
21
- return ar;
22
- };
23
1
  export var getCookieValue = function getCookieValue(key) {
24
- var reg = new RegExp("(^| )".concat(key, "=([^;]*)(;|$)"));
2
+ var reg = new RegExp("(^| )" + key + "=([^;]*)(;|$)");
25
3
  var res = reg.exec(document.cookie);
26
4
  return res ? res[2] : '';
27
5
  };
@@ -32,13 +10,13 @@ export var getCookie = function getCookie() {
32
10
  }
33
11
  var tmp = document.cookie.split(';');
34
12
  tmp.forEach(function (item) {
35
- var _a = __read(item.split('='), 2),
36
- key = _a[0],
37
- value = _a[1];
13
+ var _item$split = item.split('='),
14
+ key = _item$split[0],
15
+ value = _item$split[1];
38
16
  res[key] = value;
39
17
  });
40
18
  return res;
41
19
  };
42
20
  export var setCookieItem = function setCookieItem(key, value) {
43
- document.cookie = "".concat(key, "=").concat(value);
21
+ document.cookie = key + "=" + value;
44
22
  };
@@ -1,23 +1,30 @@
1
- var __assign = this && this.__assign || function () {
2
- __assign = Object.assign || function (t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
6
- }
7
- return t;
8
- };
9
- return __assign.apply(this, arguments);
10
- };
11
- var WebStorage = /** @class */function () {
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
+ export var WebStorage = /*#__PURE__*/function () {
12
7
  function WebStorage(props) {
13
- var _a = props.type,
14
- type = _a === void 0 ? 'sessionStorage' : _a,
8
+ this._key = void 0;
9
+ this.storage = void 0;
10
+ this.zip = void 0;
11
+ var _props$type = props.type,
12
+ type = _props$type === void 0 ? 'sessionStorage' : _props$type,
15
13
  key = props.key;
16
14
  this._key = key;
17
15
  this.storage = window[type];
18
16
  this.zip = props.zip;
19
17
  }
20
- Object.defineProperty(WebStorage.prototype, "state", {
18
+ var _proto = WebStorage.prototype;
19
+ _proto.merge = function merge(data) {
20
+ var old = this.state;
21
+ this.state = _extends({}, old, data);
22
+ };
23
+ _proto.clear = function clear() {
24
+ this.storage.removeItem(this._key);
25
+ };
26
+ _createClass(WebStorage, [{
27
+ key: "state",
21
28
  get: function get() {
22
29
  var value = this.storage.getItem(this._key);
23
30
  if (this.zip && value) {
@@ -35,24 +42,12 @@ var WebStorage = /** @class */function () {
35
42
  temp = this.zip.deflate(temp);
36
43
  }
37
44
  this.storage.setItem(this._key, temp);
38
- },
39
- enumerable: false,
40
- configurable: true
41
- });
42
- Object.defineProperty(WebStorage.prototype, "key", {
45
+ }
46
+ }, {
47
+ key: "key",
43
48
  get: function get() {
44
49
  return this._key;
45
- },
46
- enumerable: false,
47
- configurable: true
48
- });
49
- WebStorage.prototype.merge = function (data) {
50
- var old = this.state;
51
- this.state = __assign(__assign({}, old), data);
52
- };
53
- WebStorage.prototype.clear = function () {
54
- this.storage.removeItem(this._key);
55
- };
50
+ }
51
+ }]);
56
52
  return WebStorage;
57
- }();
58
- export { WebStorage };
53
+ }();