gis-common 1.1.5 → 1.1.6
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/resource.min.js +178 -11
- package/package.json +1 -1
package/dist/resource.min.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
2
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
-
module.exports = factory();
|
|
3
|
+
module.exports = factory(require("mqtt"));
|
|
4
4
|
else if(typeof define === 'function' && define.amd)
|
|
5
|
-
define("Gis", [], factory);
|
|
5
|
+
define("Gis", ["mqtt"], factory);
|
|
6
6
|
else if(typeof exports === 'object')
|
|
7
|
-
exports["Gis"] = factory();
|
|
7
|
+
exports["Gis"] = factory(require("mqtt"));
|
|
8
8
|
else
|
|
9
|
-
root["Gis"] = factory();
|
|
10
|
-
})(window, function() {
|
|
9
|
+
root["Gis"] = factory(root["mqtt"]);
|
|
10
|
+
})(window, function(__WEBPACK_EXTERNAL_MODULE__0__) {
|
|
11
11
|
return /******/ (function(modules) { // webpackBootstrap
|
|
12
12
|
/******/ // The module cache
|
|
13
13
|
/******/ var installedModules = {};
|
|
@@ -91,11 +91,17 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
91
91
|
/******/
|
|
92
92
|
/******/
|
|
93
93
|
/******/ // Load entry module and return exports
|
|
94
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
|
94
|
+
/******/ return __webpack_require__(__webpack_require__.s = 1);
|
|
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 */
|
|
99
105
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
100
106
|
|
|
101
107
|
"use strict";
|
|
@@ -126,6 +132,7 @@ __webpack_require__.d(__webpack_exports__, "CanvasDrawer", function() { return /
|
|
|
126
132
|
__webpack_require__.d(__webpack_exports__, "ElQuery", function() { return /* reexport */ core_ElQuery; });
|
|
127
133
|
__webpack_require__.d(__webpack_exports__, "EventDispatcher", function() { return /* reexport */ core_EventDispatcher; });
|
|
128
134
|
__webpack_require__.d(__webpack_exports__, "HashMap", function() { return /* reexport */ core_HashMap; });
|
|
135
|
+
__webpack_require__.d(__webpack_exports__, "MqttClient", function() { return /* reexport */ core_MqttClient; });
|
|
129
136
|
__webpack_require__.d(__webpack_exports__, "WebSocketClient", function() { return /* reexport */ core_WebSocketClient; });
|
|
130
137
|
__webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /* reexport */ core_WebStorage; });
|
|
131
138
|
|
|
@@ -1922,6 +1929,9 @@ var ElQuery = function () {
|
|
|
1922
1929
|
var _this3 = this;
|
|
1923
1930
|
|
|
1924
1931
|
this.each(function (obj) {
|
|
1932
|
+
obj.removeEventListener(type, function (e) {
|
|
1933
|
+
callback.call(_this3, e);
|
|
1934
|
+
});
|
|
1925
1935
|
obj.addEventListener(type, function (e) {
|
|
1926
1936
|
callback.call(_this3, e);
|
|
1927
1937
|
});
|
|
@@ -2115,27 +2125,184 @@ var HashMap = function () {
|
|
|
2115
2125
|
}();
|
|
2116
2126
|
|
|
2117
2127
|
/* harmony default export */ var core_HashMap = (HashMap);
|
|
2128
|
+
// EXTERNAL MODULE: external "mqtt"
|
|
2129
|
+
var external_mqtt_ = __webpack_require__(0);
|
|
2130
|
+
|
|
2131
|
+
// CONCATENATED MODULE: ./src/core/MqttClient.js
|
|
2132
|
+
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; }; }();
|
|
2133
|
+
|
|
2134
|
+
function MqttClient_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2135
|
+
|
|
2136
|
+
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; }
|
|
2137
|
+
|
|
2138
|
+
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; }
|
|
2139
|
+
|
|
2140
|
+
|
|
2141
|
+
|
|
2142
|
+
|
|
2143
|
+
|
|
2144
|
+
|
|
2145
|
+
|
|
2146
|
+
var MqttClient_MqttClient = function (_EventDispatcher) {
|
|
2147
|
+
_inherits(MqttClient, _EventDispatcher);
|
|
2148
|
+
|
|
2149
|
+
/**
|
|
2150
|
+
* Creates an instance of MqttClient.
|
|
2151
|
+
* @param {*} config mqtt实例参数
|
|
2152
|
+
*/
|
|
2153
|
+
function MqttClient() {
|
|
2154
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2155
|
+
|
|
2156
|
+
MqttClient_classCallCheck(this, MqttClient);
|
|
2157
|
+
|
|
2158
|
+
var _this = _possibleConstructorReturn(this, (MqttClient.__proto__ || Object.getPrototypeOf(MqttClient)).call(this));
|
|
2159
|
+
|
|
2160
|
+
_this.context = CommUtils.extend(MqttClient.defaultContext, config);
|
|
2161
|
+
_this.options = {
|
|
2162
|
+
connectTimeout: _this.context.MQTT_TIMEOUTM,
|
|
2163
|
+
clientId: CommUtils.generateGuid(),
|
|
2164
|
+
username: _this.context.MQTT_USERNAME,
|
|
2165
|
+
password: _this.context.MQTT_PASSWORD,
|
|
2166
|
+
clean: true
|
|
2167
|
+
};
|
|
2168
|
+
_this.client = Object(external_mqtt_["connect"])(_this.context.MQTT_SERVICE, _this.options);
|
|
2169
|
+
_this._onConnect();
|
|
2170
|
+
_this._onMessage();
|
|
2171
|
+
MqttClient.instance = _this;
|
|
2172
|
+
return _this;
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
MqttClient_createClass(MqttClient, [{
|
|
2176
|
+
key: "_onConnect",
|
|
2177
|
+
value: function _onConnect() {
|
|
2178
|
+
var _this2 = this;
|
|
2179
|
+
|
|
2180
|
+
this.client.on("connect", function () {
|
|
2181
|
+
console.log("链接mqtt成功==>" + _this2.context.MQTT_SERVICE);
|
|
2182
|
+
_this2.dispatchEvent({ type: EventTypeConstant.MQTT_CONNECT, message: _this2 });
|
|
2183
|
+
});
|
|
2184
|
+
this.client.on("error", function (err) {
|
|
2185
|
+
console.log("链接mqtt报错", err);
|
|
2186
|
+
_this2.dispatchEvent({ type: EventTypeConstant.MQTT_ERROR, message: _this2 });
|
|
2187
|
+
_this2.client.end();
|
|
2188
|
+
_this2.client.reconnect();
|
|
2189
|
+
});
|
|
2190
|
+
}
|
|
2191
|
+
}, {
|
|
2192
|
+
key: "_onMessage",
|
|
2193
|
+
value: function _onMessage() {
|
|
2194
|
+
var _this3 = this;
|
|
2195
|
+
|
|
2196
|
+
this.client.on("message", function (topic, message) {
|
|
2197
|
+
var dataString = message;
|
|
2198
|
+
var data = "";
|
|
2199
|
+
if (message instanceof Uint8Array) {
|
|
2200
|
+
dataString = message.toString();
|
|
2201
|
+
}
|
|
2202
|
+
try {
|
|
2203
|
+
data = JSON.parse(dataString);
|
|
2204
|
+
} catch (error) {
|
|
2205
|
+
throw new Error(ErrorTypeConstant.JSON_PARSE_ERROR);
|
|
2206
|
+
}
|
|
2207
|
+
_this3.dispatchEvent({
|
|
2208
|
+
type: EventTypeConstant.MQTT_MESSAGE,
|
|
2209
|
+
message: { topic: topic, data: data }
|
|
2210
|
+
});
|
|
2211
|
+
});
|
|
2212
|
+
}
|
|
2213
|
+
}, {
|
|
2214
|
+
key: "sendMsg",
|
|
2215
|
+
value: function sendMsg(topic, msg) {
|
|
2216
|
+
if (!this.client.connected) {
|
|
2217
|
+
console.error("客户端未连接");
|
|
2218
|
+
return;
|
|
2219
|
+
}
|
|
2220
|
+
this.client.publish(topic, msg, { qos: 1, retain: true });
|
|
2221
|
+
}
|
|
2222
|
+
}, {
|
|
2223
|
+
key: "subscribe",
|
|
2224
|
+
value: function subscribe(topic) {
|
|
2225
|
+
this.client.subscribe(topic, { qos: 1 }, function (error, res) {
|
|
2226
|
+
if (error instanceof Error || res.length === 0) {
|
|
2227
|
+
console.error("\u8BA2\u9605\u5931\u8D25==>" + topic, error);
|
|
2228
|
+
} else {
|
|
2229
|
+
console.log("\u8BA2\u9605\u6210\u529F==>" + topic);
|
|
2230
|
+
}
|
|
2231
|
+
});
|
|
2232
|
+
return this;
|
|
2233
|
+
}
|
|
2234
|
+
}, {
|
|
2235
|
+
key: "unsubscribe",
|
|
2236
|
+
value: function unsubscribe(topic) {
|
|
2237
|
+
this.client.unsubscribe(topic, { qos: 1 }, function (error, res) {
|
|
2238
|
+
if (error instanceof Error || res.length === 0) {
|
|
2239
|
+
console.error("\u53D6\u6D88\u8BA2\u9605\u5931\u8D25==>" + topic, error);
|
|
2240
|
+
} else {
|
|
2241
|
+
console.log("\u53D6\u6D88\u8BA2\u9605\u6210\u529F==>" + topic);
|
|
2242
|
+
}
|
|
2243
|
+
});
|
|
2244
|
+
return this;
|
|
2245
|
+
}
|
|
2246
|
+
}, {
|
|
2247
|
+
key: "unconnect",
|
|
2248
|
+
value: function unconnect() {
|
|
2249
|
+
this.client.end();
|
|
2250
|
+
this.client = null;
|
|
2251
|
+
this.dispatchEvent({ type: EventTypeConstant.MQTT_CLOSE, message: null });
|
|
2252
|
+
console.log("断开mqtt成功==>" + this.context.MQTT_SERVICE);
|
|
2253
|
+
}
|
|
2254
|
+
/**
|
|
2255
|
+
* @description 获取并冻结mqtt实例
|
|
2256
|
+
* @static
|
|
2257
|
+
* @param {*} [config={}]
|
|
2258
|
+
* @returns {MqttClient}
|
|
2259
|
+
*/
|
|
2260
|
+
|
|
2261
|
+
}], [{
|
|
2262
|
+
key: "getInstance",
|
|
2263
|
+
value: function getInstance() {
|
|
2264
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2265
|
+
|
|
2266
|
+
if (MqttClient.instance) {
|
|
2267
|
+
return Object.freeze(MqttClient.instance);
|
|
2268
|
+
} else {
|
|
2269
|
+
return Object.freeze(new MqttClient(config));
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
}]);
|
|
2273
|
+
|
|
2274
|
+
return MqttClient;
|
|
2275
|
+
}(core_EventDispatcher);
|
|
2276
|
+
|
|
2277
|
+
/* harmony default export */ var core_MqttClient = (MqttClient_MqttClient);
|
|
2278
|
+
|
|
2279
|
+
MqttClient_MqttClient.defaultContext = {
|
|
2280
|
+
MQTT_TIMEOUTM: 20000,
|
|
2281
|
+
MQTT_USERNAME: "iRVMS-WEB",
|
|
2282
|
+
MQTT_PASSWORD: "novasky888",
|
|
2283
|
+
MQTT_SERVICE: "ws://" + window.document.domain + ":20007/mqtt"
|
|
2284
|
+
};
|
|
2118
2285
|
// CONCATENATED MODULE: ./src/core/WebSocketClient.js
|
|
2119
2286
|
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; }; }();
|
|
2120
2287
|
|
|
2121
2288
|
function WebSocketClient_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2122
2289
|
|
|
2123
|
-
function
|
|
2290
|
+
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; }
|
|
2124
2291
|
|
|
2125
|
-
function
|
|
2292
|
+
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; }
|
|
2126
2293
|
|
|
2127
2294
|
|
|
2128
2295
|
|
|
2129
2296
|
|
|
2130
2297
|
var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
2131
|
-
|
|
2298
|
+
WebSocketClient_inherits(WebSocketClient, _EventDispatcher);
|
|
2132
2299
|
|
|
2133
2300
|
function WebSocketClient() {
|
|
2134
2301
|
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'ws://127.0.0.1:10088';
|
|
2135
2302
|
|
|
2136
2303
|
WebSocketClient_classCallCheck(this, WebSocketClient);
|
|
2137
2304
|
|
|
2138
|
-
var _this =
|
|
2305
|
+
var _this = WebSocketClient_possibleConstructorReturn(this, (WebSocketClient.__proto__ || Object.getPrototypeOf(WebSocketClient)).call(this));
|
|
2139
2306
|
|
|
2140
2307
|
_this.maxCheckTimes = 10;
|
|
2141
2308
|
_this.url = url;
|
|
@@ -2372,7 +2539,7 @@ var WebStorage_WebStorage = function () {
|
|
|
2372
2539
|
|
|
2373
2540
|
|
|
2374
2541
|
|
|
2375
|
-
//
|
|
2542
|
+
// vite不支持?
|
|
2376
2543
|
|
|
2377
2544
|
|
|
2378
2545
|
|