gis-common 2.0.1 → 2.0.2

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.
Files changed (2) hide show
  1. package/dist/resource.min.js +11 -175
  2. package/package.json +1 -1
@@ -1,13 +1,13 @@
1
1
  (function webpackUniversalModuleDefinition(root, factory) {
2
2
  if(typeof exports === 'object' && typeof module === 'object')
3
- module.exports = factory(require("mqtt"));
3
+ module.exports = factory();
4
4
  else if(typeof define === 'function' && define.amd)
5
- define("Gis", ["mqtt"], factory);
5
+ define("Gis", [], factory);
6
6
  else if(typeof exports === 'object')
7
- exports["Gis"] = factory(require("mqtt"));
7
+ exports["Gis"] = factory();
8
8
  else
9
- root["Gis"] = factory(root["mqtt"]);
10
- })(window, function(__WEBPACK_EXTERNAL_MODULE__0__) {
9
+ root["Gis"] = factory();
10
+ })(window, function() {
11
11
  return /******/ (function(modules) { // webpackBootstrap
12
12
  /******/ // The module cache
13
13
  /******/ var installedModules = {};
@@ -91,17 +91,11 @@ return /******/ (function(modules) { // webpackBootstrap
91
91
  /******/
92
92
  /******/
93
93
  /******/ // Load entry module and return exports
94
- /******/ return __webpack_require__(__webpack_require__.s = 1);
94
+ /******/ return __webpack_require__(__webpack_require__.s = 0);
95
95
  /******/ })
96
96
  /************************************************************************/
97
97
  /******/ ([
98
98
  /* 0 */
99
- /***/ (function(module, exports) {
100
-
101
- module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
102
-
103
- /***/ }),
104
- /* 1 */
105
99
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
106
100
 
107
101
  "use strict";
@@ -130,7 +124,6 @@ __webpack_require__.d(__webpack_exports__, "CanvasDrawer", function() { return /
130
124
  __webpack_require__.d(__webpack_exports__, "ElQuery", function() { return /* reexport */ core_ElQuery; });
131
125
  __webpack_require__.d(__webpack_exports__, "EventDispatcher", function() { return /* reexport */ core_EventDispatcher; });
132
126
  __webpack_require__.d(__webpack_exports__, "HashMap", function() { return /* reexport */ core_HashMap; });
133
- __webpack_require__.d(__webpack_exports__, "MqttClient", function() { return /* reexport */ core_MqttClient; });
134
127
  __webpack_require__.d(__webpack_exports__, "WebSocketClient", function() { return /* reexport */ core_WebSocketClient; });
135
128
  __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /* reexport */ core_WebStorage; });
136
129
 
@@ -2046,184 +2039,27 @@ var HashMap = function () {
2046
2039
  }();
2047
2040
 
2048
2041
  /* harmony default export */ var core_HashMap = (HashMap);
2049
- // EXTERNAL MODULE: external "mqtt"
2050
- var external_mqtt_ = __webpack_require__(0);
2051
-
2052
- // CONCATENATED MODULE: ./src/core/MqttClient.js
2053
- var MqttClient_createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
2054
-
2055
- function MqttClient_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2056
-
2057
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
2058
-
2059
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
2060
-
2061
-
2062
-
2063
-
2064
-
2065
-
2066
-
2067
- var MqttClient_MqttClient = function (_EventDispatcher) {
2068
- _inherits(MqttClient, _EventDispatcher);
2069
-
2070
- /**
2071
- * Creates an instance of MqttClient.
2072
- * @param {*} config mqtt实例参数
2073
- */
2074
- function MqttClient() {
2075
- var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2076
-
2077
- MqttClient_classCallCheck(this, MqttClient);
2078
-
2079
- var _this = _possibleConstructorReturn(this, (MqttClient.__proto__ || Object.getPrototypeOf(MqttClient)).call(this));
2080
-
2081
- _this.context = CommUtils.extend(MqttClient.defaultContext, config);
2082
- _this.options = {
2083
- connectTimeout: _this.context.MQTT_TIMEOUTM,
2084
- clientId: CommUtils.generateGuid(),
2085
- username: _this.context.MQTT_USERNAME,
2086
- password: _this.context.MQTT_PASSWORD,
2087
- clean: true
2088
- };
2089
- _this.client = Object(external_mqtt_["connect"])(_this.context.MQTT_SERVICE, _this.options);
2090
- _this._onConnect();
2091
- _this._onMessage();
2092
- MqttClient.instance = _this;
2093
- return _this;
2094
- }
2095
-
2096
- MqttClient_createClass(MqttClient, [{
2097
- key: "_onConnect",
2098
- value: function _onConnect() {
2099
- var _this2 = this;
2100
-
2101
- this.client.on("connect", function () {
2102
- console.log("链接mqtt成功==>" + _this2.context.MQTT_SERVICE);
2103
- _this2.dispatchEvent({ type: EventTypeConstant.MQTT_CONNECT, message: _this2 });
2104
- });
2105
- this.client.on("error", function (err) {
2106
- console.log("链接mqtt报错", err);
2107
- _this2.dispatchEvent({ type: EventTypeConstant.MQTT_ERROR, message: _this2 });
2108
- _this2.client.end();
2109
- _this2.client.reconnect();
2110
- });
2111
- }
2112
- }, {
2113
- key: "_onMessage",
2114
- value: function _onMessage() {
2115
- var _this3 = this;
2116
-
2117
- this.client.on("message", function (topic, message) {
2118
- var dataString = message;
2119
- var data = "";
2120
- if (message instanceof Uint8Array) {
2121
- dataString = message.toString();
2122
- }
2123
- try {
2124
- data = JSON.parse(dataString);
2125
- } catch (error) {
2126
- throw new Error(ErrorTypeConstant.JSON_PARSE_ERROR);
2127
- }
2128
- _this3.dispatchEvent({
2129
- type: EventTypeConstant.MQTT_MESSAGE,
2130
- message: { topic: topic, data: data }
2131
- });
2132
- });
2133
- }
2134
- }, {
2135
- key: "sendMsg",
2136
- value: function sendMsg(topic, msg) {
2137
- if (!this.client.connected) {
2138
- console.error("客户端未连接");
2139
- return;
2140
- }
2141
- this.client.publish(topic, msg, { qos: 1, retain: true });
2142
- }
2143
- }, {
2144
- key: "subscribe",
2145
- value: function subscribe(topic) {
2146
- this.client.subscribe(topic, { qos: 1 }, function (error, res) {
2147
- if (error instanceof Error || res.length === 0) {
2148
- console.error("\u8BA2\u9605\u5931\u8D25==>" + topic, error);
2149
- } else {
2150
- console.log("\u8BA2\u9605\u6210\u529F==>" + topic);
2151
- }
2152
- });
2153
- return this;
2154
- }
2155
- }, {
2156
- key: "unsubscribe",
2157
- value: function unsubscribe(topic) {
2158
- this.client.unsubscribe(topic, { qos: 1 }, function (error, res) {
2159
- if (error instanceof Error || res.length === 0) {
2160
- console.error("\u53D6\u6D88\u8BA2\u9605\u5931\u8D25==>" + topic, error);
2161
- } else {
2162
- console.log("\u53D6\u6D88\u8BA2\u9605\u6210\u529F==>" + topic);
2163
- }
2164
- });
2165
- return this;
2166
- }
2167
- }, {
2168
- key: "unconnect",
2169
- value: function unconnect() {
2170
- this.client.end();
2171
- this.client = null;
2172
- this.dispatchEvent({ type: EventTypeConstant.MQTT_CLOSE, message: null });
2173
- console.log("断开mqtt成功==>" + this.context.MQTT_SERVICE);
2174
- }
2175
- /**
2176
- * @description 获取并冻结mqtt实例
2177
- * @static
2178
- * @param {*} [config={}]
2179
- * @returns {MqttClient}
2180
- */
2181
-
2182
- }], [{
2183
- key: "getInstance",
2184
- value: function getInstance() {
2185
- var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2186
-
2187
- if (MqttClient.instance) {
2188
- return Object.freeze(MqttClient.instance);
2189
- } else {
2190
- return Object.freeze(new MqttClient(config));
2191
- }
2192
- }
2193
- }]);
2194
-
2195
- return MqttClient;
2196
- }(core_EventDispatcher);
2197
-
2198
- /* harmony default export */ var core_MqttClient = (MqttClient_MqttClient);
2199
-
2200
- MqttClient_MqttClient.defaultContext = {
2201
- MQTT_TIMEOUTM: 20000,
2202
- MQTT_USERNAME: "iRVMS-WEB",
2203
- MQTT_PASSWORD: "novasky888",
2204
- MQTT_SERVICE: "ws://" + window.document.domain + ":20007/mqtt"
2205
- };
2206
2042
  // CONCATENATED MODULE: ./src/core/WebSocketClient.js
2207
2043
  var WebSocketClient_createClass = function () { 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
2208
2044
 
2209
2045
  function WebSocketClient_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2210
2046
 
2211
- function WebSocketClient_possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
2047
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
2212
2048
 
2213
- function WebSocketClient_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
2049
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
2214
2050
 
2215
2051
 
2216
2052
 
2217
2053
 
2218
2054
  var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
2219
- WebSocketClient_inherits(WebSocketClient, _EventDispatcher);
2055
+ _inherits(WebSocketClient, _EventDispatcher);
2220
2056
 
2221
2057
  function WebSocketClient() {
2222
2058
  var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "ws://127.0.0.1:10088";
2223
2059
 
2224
2060
  WebSocketClient_classCallCheck(this, WebSocketClient);
2225
2061
 
2226
- var _this = WebSocketClient_possibleConstructorReturn(this, (WebSocketClient.__proto__ || Object.getPrototypeOf(WebSocketClient)).call(this));
2062
+ var _this = _possibleConstructorReturn(this, (WebSocketClient.__proto__ || Object.getPrototypeOf(WebSocketClient)).call(this));
2227
2063
 
2228
2064
  _this.maxCheckTimes = 10;
2229
2065
  _this.url = url;
@@ -2462,7 +2298,7 @@ var WebStorage_WebStorage = function () {
2462
2298
 
2463
2299
 
2464
2300
 
2465
-
2301
+ // export { default as MqttClient } from './core/MqttClient' vite不支持?
2466
2302
 
2467
2303
 
2468
2304
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "gis-common",
3
3
  "description": "gis-common",
4
4
  "main": "dist/resource.min.js",
5
- "version": "2.0.1",
5
+ "version": "2.0.2",
6
6
  "author": "Guo.Yan <luv02@vip.qq.com>",
7
7
  "license": "MIT",
8
8
  "private": false,