pubo-web 1.0.38 → 1.0.40
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,(function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},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 o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},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=1)}([,function(t,e,n){"use strict";n.r(e),n.d(e,"loadScript",(function(){return r})),n.d(e,"blob2text",(function(){return i})),n.d(e,"blob2base64",(function(){return
|
|
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,(function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},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 o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},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=1)}([,function(t,e,n){"use strict";n.r(e),n.d(e,"loadScript",(function(){return r})),n.d(e,"blob2text",(function(){return i})),n.d(e,"blob2base64",(function(){return s})),n.d(e,"blob2file",(function(){return u})),n.d(e,"downloadFile",(function(){return a})),n.d(e,"WebStorage",(function(){return f})),n.d(e,"WebsocketClient",(function(){return y})),n.d(e,"DragMethod",(function(){return m}));var o=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.")},r=function(t,e){void 0===e&&(e={});return new Promise((function(n){var r,i;if(function(){var e,n,r=document.getElementsByTagName("script");try{for(var i=o(r),s=i.next();!s.done;s=i.next()){var u=s.value;if(u.src===t)return u}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return null}())return n(t);var s=document.createElement("script");try{for(var u=o(Object.keys(e)),a=u.next();!a.done;a=u.next()){var c=a.value;s[c]=e[c]}}catch(t){r={error:t}}finally{try{a&&!a.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}return s.src=t,s.onload=function(){return n(t)},document.body.appendChild(s),"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 o=new FileReader;t?(o.onload=function(t){return e(t.target.result)},o.onabort=function(){return n()},o.readAsDataURL(t)):n("文件爲空!")}))},u=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 r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},f=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.")},h=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,r,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(o=i.next()).done;)s.push(o.value)}catch(t){r={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return s},d=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(h(arguments[e]));return t},p=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,r=n.index;o&&Array.isArray(this.state[o])&&(this.state[o].splice(r,1),delete this.ids[t],Object.keys(this.ids).forEach((function(t){e.ids[t].event===o&&e.ids[t].index>r&&(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=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];if(Array.isArray(this.state[t]))try{for(var i=l(this.state[t]),s=i.next();!s.done;s=i.next()){var u=s.value;"function"==typeof u&&u.apply(void 0,d(o))}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},t}(),y=function(){function t(t){var e=t.url;this.client=null,this._status=0,this.emitter=new p,this.url=e,this.connect()}return t.prototype.reconnect=function(){var t=this;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}(),v=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,r,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(o=i.next()).done;)s.push(o.value)}catch(t){r={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return s},b=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(v(arguments[e]));return t};var m=function(){function t(t){var e,n,o,r,i=void 0===t?{}:t,s=i.key,u=void 0===s?"":s,a=i.onMove,c=i.onMoveEnd;this.key="",this.cache={pageX:0,pageY:0},this.key=u,this.onMouseDown=this._onMouseDown.bind(this),this.onMouseMove=(e=this._onMouseMove.bind(this),n=10,r=!0,function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];o||(o=setTimeout((function(){r=!0,o=null}),n)),r&&(r=!1,e.apply(void 0,b(t)))}),this.onMouseUp=this._onMouseUp.bind(this),this.onMove=a,this.onMoveEnd=c}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),"function"==typeof this.onMoveEnd&&this.onMoveEnd()},t.prototype._onMouseDown=function(t){"function"==typeof this.onMove&&(this.cache.pageX=t.pageX,this.cache.pageY=t.pageY,window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp))},t}()}])}));
|
package/es/websocket/client.d.ts
CHANGED
package/es/websocket/client.js
CHANGED
|
@@ -5,8 +5,8 @@ var WebsocketClient =
|
|
|
5
5
|
function () {
|
|
6
6
|
function WebsocketClient(_a) {
|
|
7
7
|
var url = _a.url;
|
|
8
|
+
this.client = null;
|
|
8
9
|
this._status = 0;
|
|
9
|
-
this.url = '';
|
|
10
10
|
this.emitter = new Emitter();
|
|
11
11
|
this.url = url;
|
|
12
12
|
this.connect();
|
|
@@ -37,6 +37,10 @@ function () {
|
|
|
37
37
|
WebsocketClient.prototype.connect = function () {
|
|
38
38
|
var _this = this;
|
|
39
39
|
|
|
40
|
+
if (this.client) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
40
44
|
this.client = new WebSocket(this.url);
|
|
41
45
|
this.client.onclose = this.onClose.bind(this);
|
|
42
46
|
this.client.onmessage = this.onMessage.bind(this);
|
package/lib/websocket/client.js
CHANGED
|
@@ -11,8 +11,8 @@ var WebsocketClient =
|
|
|
11
11
|
function () {
|
|
12
12
|
function WebsocketClient(_a) {
|
|
13
13
|
var url = _a.url;
|
|
14
|
+
this.client = null;
|
|
14
15
|
this._status = 0;
|
|
15
|
-
this.url = '';
|
|
16
16
|
this.emitter = new pubo_utils_1.Emitter();
|
|
17
17
|
this.url = url;
|
|
18
18
|
this.connect();
|
|
@@ -43,6 +43,10 @@ function () {
|
|
|
43
43
|
WebsocketClient.prototype.connect = function () {
|
|
44
44
|
var _this = this;
|
|
45
45
|
|
|
46
|
+
if (this.client) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
46
50
|
this.client = new WebSocket(this.url);
|
|
47
51
|
this.client.onclose = this.onClose.bind(this);
|
|
48
52
|
this.client.onmessage = this.onMessage.bind(this);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pubo-web",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.40",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"node": ">=8.0.0"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"pubo-utils": "^1.0.
|
|
22
|
+
"pubo-utils": "^1.0.39",
|
|
23
23
|
"roslib": "^1.2.0"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "00e134ecd307b76ba3e69be1d5603221dea82ce6"
|
|
26
26
|
}
|