pubo-web 1.0.69 → 1.0.71
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 +1 -1
- package/es/dom/drag.js +5 -2
- package/lib/dom/drag.js +5 -2
- package/package.json +2 -2
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 o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},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:()=>
|
|
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 o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},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:()=>g,WebStorage:()=>u,WebsocketClient:()=>p,blob2base64:()=>r,blob2file:()=>s,blob2text:()=>i,downloadFile:()=>a,loadScript:()=>o,pickFiles:()=>m});var n=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],o=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&o>=t.length&&(t=void 0),{value:t&&t[o++],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(o){var i,r,s=function(){var e,o,i=document.getElementsByTagName("script");try{for(var r=n(i),s=r.next();!s.done;s=r.next()){var a=s.value;if(a.src===t)return a}}catch(t){e={error:t}}finally{try{s&&!s.done&&(o=r.return)&&o.call(r)}finally{if(e)throw e.error}}return null}(),a=s;if(s){if("complete"===s._state)return o(t)}else a=document.createElement("script");try{for(var c=n(Object.keys(e)),u=c.next();!u.done;u=c.next()){var l=u.value;a[l]=e[l]}}catch(t){i={error:t}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(i)throw i.error}}return a.src=t,a.addEventListener("load",(function e(){o(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)}))},r=function(t){return new Promise((function(e,n){var o=new FileReader;t?(o.onload=function(t){return e(t.target.result)},o.onabort=function(){return n()},o.readAsDataURL(t)):n("文件爲空!")}))},s=function(t,e,n){return new File(t,e,{type:n})},a=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)},c=function(){return c=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},c.apply(this,arguments)},u=function(){function t(t){var e=t.type,n=void 0===e?"sessionStorage":e,o=t.key;this._key=o,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=c(c({},e),t)},t.prototype.clear=function(){this.storage.removeItem(this._key)},t}(),l=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],o=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&o>=t.length&&(t=void 0),{value:t&&t[o++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},f=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,i,r=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(t){i={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s},h=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(f(arguments[e]));return t},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,o=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="",o=0;o<=t;o+=8)n+=e(t-o>8?8:t-o);return n}(40);return this.ids[o]={event:t,index:n},o},t.prototype.cancel=function(t){var e=this;if(t){var n=this.ids[t]||{},o=n.event,i=n.index;o&&Array.isArray(this.state[o])&&(this.state[o].splice(i,1),delete this.ids[t],Object.keys(this.ids).forEach((function(t){e.ids[t].event===o&&e.ids[t].index>i&&(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){for(var e,n,o=[],i=1;i<arguments.length;i++)o[i-1]=arguments[i];if(Array.isArray(this.state[t]))try{for(var r=l(this.state[t]),s=r.next();!s.done;s=r.next()){var a=s.value;"function"==typeof a&&a.apply(void 0,h(o))}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}},t}();const p=function(){function t(t){var e=t.url;this.client=null,this._status=0,this.emitter=new d,this.url=e,this.connect()}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)},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._status=1})},t.prototype.close=function(){this.client&&(this.client.close(),this.client=null,this._status=2)},t.prototype.send=function(t,e){var n;void 0===e&&(e=!1);var o=t;e&&(o=JSON.stringify(t)),null===(n=this.client)||void 0===n||n.send(o)},t}();var y=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,i,r=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(t){i={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s},v=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(y(arguments[e]));return t},g=function(){function t(t){var e,n,o,i,r=void 0===t?{}:t,s=r.key,a=void 0===s?"":s,c=r.onMove,u=r.onMoveEnd;this.key="",this.cache={pageX:0,pageY:0,dragging:!1},this.key=a,this.onMouseDown=this._onMouseDown.bind(this),this.onMouseMove=(e=this._onMouseMove.bind(this),n=10,i=!0,function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];o||(o=setTimeout((function(){i=!0,o=null}),n)),i&&(i=!1,e.apply(void 0,v(t)))}),this.onMouseUp=this._onMouseUp.bind(this),this.onMove=c,this.onMoveEnd=u}return t.prototype._onMouseMove=function(t){"function"==typeof this.onMove&&(this.onMove({offsetX:t.pageX-this.cache.pageX,offsetY:t.pageY-this.cache.pageY,key:this.key}),this.cache.pageX=t.pageX,this.cache.pageY=t.pageY)},t.prototype._onMouseUp=function(){window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp),this.cache.dragging=!1,"function"==typeof this.onMoveEnd&&this.onMoveEnd()},t.prototype._onMouseDown=function(t){"function"!=typeof this.onMove||this.cache.dragging||(this.cache.dragging=!0,this.cache.pageX=t.pageX,this.cache.pageY=t.pageY,window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp))},t}(),m=function(){return new Promise((function(t){var e=document.createElement("input");e.type="file",e.style.visibility="hidden",e.style.position="fixed",e.style.top="0px",e.style.zIndex="-1",window.addEventListener("focus",(function t(){document.body.removeChild(e),window.removeEventListener("focus",t)})),e.onchange=function(e){t(e.target.files)},document.body.appendChild(e),e.click()}))};return e})()));
|
package/es/dom/drag.js
CHANGED
|
@@ -9,7 +9,8 @@ var DragMethod = /** @class */function () {
|
|
|
9
9
|
this.key = '';
|
|
10
10
|
this.cache = {
|
|
11
11
|
pageX: 0,
|
|
12
|
-
pageY: 0
|
|
12
|
+
pageY: 0,
|
|
13
|
+
dragging: false
|
|
13
14
|
};
|
|
14
15
|
this.key = key;
|
|
15
16
|
this.onMouseDown = this._onMouseDown.bind(this);
|
|
@@ -33,14 +34,16 @@ var DragMethod = /** @class */function () {
|
|
|
33
34
|
DragMethod.prototype._onMouseUp = function () {
|
|
34
35
|
window.removeEventListener('mousemove', this.onMouseMove);
|
|
35
36
|
window.removeEventListener('mouseup', this.onMouseUp);
|
|
37
|
+
this.cache.dragging = false;
|
|
36
38
|
if (typeof this.onMoveEnd === 'function') {
|
|
37
39
|
this.onMoveEnd();
|
|
38
40
|
}
|
|
39
41
|
};
|
|
40
42
|
DragMethod.prototype._onMouseDown = function (e) {
|
|
41
|
-
if (typeof this.onMove !== 'function') {
|
|
43
|
+
if (typeof this.onMove !== 'function' || this.cache.dragging) {
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
46
|
+
this.cache.dragging = true;
|
|
44
47
|
this.cache.pageX = e.pageX;
|
|
45
48
|
this.cache.pageY = e.pageY;
|
|
46
49
|
window.addEventListener('mousemove', this.onMouseMove);
|
package/lib/dom/drag.js
CHANGED
|
@@ -15,7 +15,8 @@ var DragMethod = /** @class */function () {
|
|
|
15
15
|
this.key = '';
|
|
16
16
|
this.cache = {
|
|
17
17
|
pageX: 0,
|
|
18
|
-
pageY: 0
|
|
18
|
+
pageY: 0,
|
|
19
|
+
dragging: false
|
|
19
20
|
};
|
|
20
21
|
this.key = key;
|
|
21
22
|
this.onMouseDown = this._onMouseDown.bind(this);
|
|
@@ -39,14 +40,16 @@ var DragMethod = /** @class */function () {
|
|
|
39
40
|
DragMethod.prototype._onMouseUp = function () {
|
|
40
41
|
window.removeEventListener('mousemove', this.onMouseMove);
|
|
41
42
|
window.removeEventListener('mouseup', this.onMouseUp);
|
|
43
|
+
this.cache.dragging = false;
|
|
42
44
|
if (typeof this.onMoveEnd === 'function') {
|
|
43
45
|
this.onMoveEnd();
|
|
44
46
|
}
|
|
45
47
|
};
|
|
46
48
|
DragMethod.prototype._onMouseDown = function (e) {
|
|
47
|
-
if (typeof this.onMove !== 'function') {
|
|
49
|
+
if (typeof this.onMove !== 'function' || this.cache.dragging) {
|
|
48
50
|
return;
|
|
49
51
|
}
|
|
52
|
+
this.cache.dragging = true;
|
|
50
53
|
this.cache.pageX = e.pageX;
|
|
51
54
|
this.cache.pageY = e.pageY;
|
|
52
55
|
window.addEventListener('mousemove', this.onMouseMove);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pubo-web",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.71",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"pubo-utils": "^1.0.69"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "863dd647559583ea4262fc680496f24ef56a45e9"
|
|
25
25
|
}
|