gis-common 1.1.2 → 1.1.5

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 +36 -190
  2. package/package.json +35 -35
@@ -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";
@@ -132,7 +126,6 @@ __webpack_require__.d(__webpack_exports__, "CanvasDrawer", function() { return /
132
126
  __webpack_require__.d(__webpack_exports__, "ElQuery", function() { return /* reexport */ core_ElQuery; });
133
127
  __webpack_require__.d(__webpack_exports__, "EventDispatcher", function() { return /* reexport */ core_EventDispatcher; });
134
128
  __webpack_require__.d(__webpack_exports__, "HashMap", function() { return /* reexport */ core_HashMap; });
135
- __webpack_require__.d(__webpack_exports__, "MqttClient", function() { return /* reexport */ core_MqttClient; });
136
129
  __webpack_require__.d(__webpack_exports__, "WebSocketClient", function() { return /* reexport */ core_WebSocketClient; });
137
130
  __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /* reexport */ core_WebStorage; });
138
131
 
@@ -1276,8 +1269,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1276
1269
  * @returns {*}
1277
1270
  */
1278
1271
  convertBase64ToBlob: function convertBase64ToBlob(data) {
1279
- var mimeString = data.split(",")[0].split(":")[1].split(";")[0];
1280
- var byteString = window.atob(data.split(",")[1]);
1272
+ var mimeString = data.split(',')[0].split(':')[1].split(';')[0];
1273
+ var byteString = window.atob(data.split(',')[1]);
1281
1274
  var ab = new ArrayBuffer(byteString.length);
1282
1275
  var ia = new Uint8Array(ab);
1283
1276
 
@@ -1309,19 +1302,19 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1309
1302
  convertUrlToBase64: function convertUrlToBase64(url, width, height) {
1310
1303
  return new Promise(function (resolve, reject) {
1311
1304
  var img = new Image();
1312
- img.crossOrigin = "Anonymous";
1305
+ img.crossOrigin = 'Anonymous';
1313
1306
  img.src = url;
1314
1307
  img.onload = function () {
1315
- var canvas = document.createElement("canvas");
1308
+ var canvas = document.createElement('canvas');
1316
1309
  canvas.width = width || img.width;
1317
1310
  canvas.height = height || img.height;
1318
- var ctx = canvas.getContext("2d");
1311
+ var ctx = canvas.getContext('2d');
1319
1312
  ctx.drawImage(img, 0, 0, img.width, img.height);
1320
- var ext = img.src.substring(img.src.lastIndexOf(".") + 1).toLowerCase();
1321
- var dataURL = canvas.toDataURL("image/" + ext);
1313
+ var ext = img.src.substring(img.src.lastIndexOf('.') + 1).toLowerCase();
1314
+ var dataURL = canvas.toDataURL('image/' + ext);
1322
1315
  var base64 = {
1323
1316
  dataURL: dataURL,
1324
- type: "image/" + ext,
1317
+ type: 'image/' + ext,
1325
1318
  ext: ext
1326
1319
  };
1327
1320
  resolve(base64);
@@ -1337,7 +1330,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1337
1330
  * @returns {*}
1338
1331
  */
1339
1332
  convertBase64ToFile: function convertBase64ToFile(dataurl, filename) {
1340
- var arr = dataurl.split(","),
1333
+ var arr = dataurl.split(','),
1341
1334
  mime = arr[0].match(/:(.*?);/)[1],
1342
1335
  bstr = atob(arr[1]),
1343
1336
  n = bstr.length,
@@ -1352,16 +1345,26 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1352
1345
  /**
1353
1346
  * 直接下载文件,支持blob类型和url类型
1354
1347
  *
1355
- * @param {*} url
1348
+ * @param {*} data
1356
1349
  * @param {*} saveName
1357
1350
  */
1358
- downloadFromFile: function downloadFromFile(url, saveName) {
1359
- if ((typeof url === "undefined" ? "undefined" : _typeof(url)) == "object" && url instanceof Blob) {
1360
- url = URL.createObjectURL(url); // 创建blob地址
1351
+ downloadFromFile: function downloadFromFile(data, saveName) {
1352
+ var url = void 0;
1353
+ if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) == 'object') {
1354
+ if (data instanceof Blob) {
1355
+ url = URL.createObjectURL(data); // 创建blob地址
1356
+ } else {
1357
+ var str = JSON.stringify(data);
1358
+ var blob = new Blob([str], { type: 'text/json' }); // json对象
1359
+ url = window.URL.createObjectURL(blob);
1360
+ }
1361
+ } else if (typeof data == 'string') {
1362
+ var _blob = new Blob([data], { type: 'text/json' }); //json文本
1363
+ url = window.URL.createObjectURL(_blob);
1361
1364
  }
1362
- var link = document.createElement("a");
1365
+ var link = document.createElement('a');
1363
1366
  link.href = url;
1364
- link.download = saveName || ""; // HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
1367
+ link.download = saveName || ''; // HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
1365
1368
  link.click();
1366
1369
  window.URL.revokeObjectURL(link.href);
1367
1370
  }
@@ -2112,184 +2115,27 @@ var HashMap = function () {
2112
2115
  }();
2113
2116
 
2114
2117
  /* harmony default export */ var core_HashMap = (HashMap);
2115
- // EXTERNAL MODULE: external "mqtt"
2116
- var external_mqtt_ = __webpack_require__(0);
2117
-
2118
- // CONCATENATED MODULE: ./src/core/MqttClient.js
2119
- 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; }; }();
2120
-
2121
- function MqttClient_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2122
-
2123
- 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; }
2124
-
2125
- 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; }
2126
-
2127
-
2128
-
2129
-
2130
-
2131
-
2132
-
2133
- var MqttClient_MqttClient = function (_EventDispatcher) {
2134
- _inherits(MqttClient, _EventDispatcher);
2135
-
2136
- /**
2137
- * Creates an instance of MqttClient.
2138
- * @param {*} config mqtt实例参数
2139
- */
2140
- function MqttClient() {
2141
- var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2142
-
2143
- MqttClient_classCallCheck(this, MqttClient);
2144
-
2145
- var _this = _possibleConstructorReturn(this, (MqttClient.__proto__ || Object.getPrototypeOf(MqttClient)).call(this));
2146
-
2147
- _this.context = CommUtils.extend(MqttClient.defaultContext, config);
2148
- _this.options = {
2149
- connectTimeout: _this.context.MQTT_TIMEOUTM,
2150
- clientId: CommUtils.generateGuid(),
2151
- username: _this.context.MQTT_USERNAME,
2152
- password: _this.context.MQTT_PASSWORD,
2153
- clean: true
2154
- };
2155
- _this.client = Object(external_mqtt_["connect"])(_this.context.MQTT_SERVICE, _this.options);
2156
- _this._onConnect();
2157
- _this._onMessage();
2158
- MqttClient.instance = _this;
2159
- return _this;
2160
- }
2161
-
2162
- MqttClient_createClass(MqttClient, [{
2163
- key: "_onConnect",
2164
- value: function _onConnect() {
2165
- var _this2 = this;
2166
-
2167
- this.client.on("connect", function () {
2168
- console.log("链接mqtt成功==>" + _this2.context.MQTT_SERVICE);
2169
- _this2.dispatchEvent({ type: EventTypeConstant.MQTT_CONNECT, message: _this2 });
2170
- });
2171
- this.client.on("error", function (err) {
2172
- console.log("链接mqtt报错", err);
2173
- _this2.dispatchEvent({ type: EventTypeConstant.MQTT_ERROR, message: _this2 });
2174
- _this2.client.end();
2175
- _this2.client.reconnect();
2176
- });
2177
- }
2178
- }, {
2179
- key: "_onMessage",
2180
- value: function _onMessage() {
2181
- var _this3 = this;
2182
-
2183
- this.client.on("message", function (topic, message) {
2184
- var dataString = message;
2185
- var data = "";
2186
- if (message instanceof Uint8Array) {
2187
- dataString = message.toString();
2188
- }
2189
- try {
2190
- data = JSON.parse(dataString);
2191
- } catch (error) {
2192
- throw new Error(ErrorTypeConstant.JSON_PARSE_ERROR);
2193
- }
2194
- _this3.dispatchEvent({
2195
- type: EventTypeConstant.MQTT_MESSAGE,
2196
- message: { topic: topic, data: data }
2197
- });
2198
- });
2199
- }
2200
- }, {
2201
- key: "sendMsg",
2202
- value: function sendMsg(topic, msg) {
2203
- if (!this.client.connected) {
2204
- console.error("客户端未连接");
2205
- return;
2206
- }
2207
- this.client.publish(topic, msg, { qos: 1, retain: true });
2208
- }
2209
- }, {
2210
- key: "subscribe",
2211
- value: function subscribe(topic) {
2212
- this.client.subscribe(topic, { qos: 1 }, function (error, res) {
2213
- if (error instanceof Error || res.length === 0) {
2214
- console.error("\u8BA2\u9605\u5931\u8D25==>" + topic, error);
2215
- } else {
2216
- console.log("\u8BA2\u9605\u6210\u529F==>" + topic);
2217
- }
2218
- });
2219
- return this;
2220
- }
2221
- }, {
2222
- key: "unsubscribe",
2223
- value: function unsubscribe(topic) {
2224
- this.client.unsubscribe(topic, { qos: 1 }, function (error, res) {
2225
- if (error instanceof Error || res.length === 0) {
2226
- console.error("\u53D6\u6D88\u8BA2\u9605\u5931\u8D25==>" + topic, error);
2227
- } else {
2228
- console.log("\u53D6\u6D88\u8BA2\u9605\u6210\u529F==>" + topic);
2229
- }
2230
- });
2231
- return this;
2232
- }
2233
- }, {
2234
- key: "unconnect",
2235
- value: function unconnect() {
2236
- this.client.end();
2237
- this.client = null;
2238
- this.dispatchEvent({ type: EventTypeConstant.MQTT_CLOSE, message: null });
2239
- console.log("断开mqtt成功==>" + this.context.MQTT_SERVICE);
2240
- }
2241
- /**
2242
- * @description 获取并冻结mqtt实例
2243
- * @static
2244
- * @param {*} [config={}]
2245
- * @returns {MqttClient}
2246
- */
2247
-
2248
- }], [{
2249
- key: "getInstance",
2250
- value: function getInstance() {
2251
- var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2252
-
2253
- if (MqttClient.instance) {
2254
- return Object.freeze(MqttClient.instance);
2255
- } else {
2256
- return Object.freeze(new MqttClient(config));
2257
- }
2258
- }
2259
- }]);
2260
-
2261
- return MqttClient;
2262
- }(core_EventDispatcher);
2263
-
2264
- /* harmony default export */ var core_MqttClient = (MqttClient_MqttClient);
2265
-
2266
- MqttClient_MqttClient.defaultContext = {
2267
- MQTT_TIMEOUTM: 20000,
2268
- MQTT_USERNAME: "iRVMS-WEB",
2269
- MQTT_PASSWORD: "novasky888",
2270
- MQTT_SERVICE: "ws://" + window.document.domain + ":20007/mqtt"
2271
- };
2272
2118
  // CONCATENATED MODULE: ./src/core/WebSocketClient.js
2273
2119
  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; }; }();
2274
2120
 
2275
2121
  function WebSocketClient_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2276
2122
 
2277
- 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; }
2123
+ 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; }
2278
2124
 
2279
- 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; }
2125
+ 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; }
2280
2126
 
2281
2127
 
2282
2128
 
2283
2129
 
2284
2130
  var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
2285
- WebSocketClient_inherits(WebSocketClient, _EventDispatcher);
2131
+ _inherits(WebSocketClient, _EventDispatcher);
2286
2132
 
2287
2133
  function WebSocketClient() {
2288
2134
  var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'ws://127.0.0.1:10088';
2289
2135
 
2290
2136
  WebSocketClient_classCallCheck(this, WebSocketClient);
2291
2137
 
2292
- var _this = WebSocketClient_possibleConstructorReturn(this, (WebSocketClient.__proto__ || Object.getPrototypeOf(WebSocketClient)).call(this));
2138
+ var _this = _possibleConstructorReturn(this, (WebSocketClient.__proto__ || Object.getPrototypeOf(WebSocketClient)).call(this));
2293
2139
 
2294
2140
  _this.maxCheckTimes = 10;
2295
2141
  _this.url = url;
@@ -2526,7 +2372,7 @@ var WebStorage_WebStorage = function () {
2526
2372
 
2527
2373
 
2528
2374
 
2529
-
2375
+ // export { default as MqttClient } from './core/MqttClient' vite不支持?
2530
2376
 
2531
2377
 
2532
2378
 
package/package.json CHANGED
@@ -1,35 +1,35 @@
1
- {
2
- "name": "gis-common",
3
- "description": "gis-common",
4
- "main": "dist/resource.min.js",
5
- "version": "1.1.2",
6
- "author": "Guo.Yan <luv02@vip.qq.com>",
7
- "license": "MIT",
8
- "private": false,
9
- "scripts": {
10
- "dev": "cross-env NODE_ENV=development webpack-dev-server --hot --port 7000",
11
- "build": "cross-env NODE_ENV=production webpack --progress"
12
- },
13
- "dependencies": {
14
- "mqtt": "^4.2.8"
15
- },
16
- "browserslist": [
17
- "> 1%",
18
- "last 2 versions",
19
- "not ie <= 8"
20
- ],
21
- "files": [],
22
- "devDependencies": {
23
- "babel-core": "^6.26.0",
24
- "babel-loader": "^7.1.2",
25
- "babel-preset-env": "^1.6.0",
26
- "babel-preset-stage-3": "^6.24.1",
27
- "cross-env": "^5.0.5",
28
- "css-loader": "^0.28.7",
29
- "uglifyjs-webpack-plugin": "^2.2.0",
30
- "webpack": "^4.23.1",
31
- "webpack-cli": "^4.9.1",
32
- "webpack-dev-server": "^2.9.1",
33
- "clean-webpack-plugin": "^4.0.0-alpha.0"
34
- }
35
- }
1
+ {
2
+ "name": "gis-common",
3
+ "description": "gis-common",
4
+ "main": "dist/resource.min.js",
5
+ "version": "1.1.5",
6
+ "author": "Guo.Yan <luv02@vip.qq.com>",
7
+ "license": "MIT",
8
+ "private": false,
9
+ "scripts": {
10
+ "dev": "cross-env NODE_ENV=development webpack-dev-server --hot --port 7000",
11
+ "build": "cross-env NODE_ENV=production webpack --progress"
12
+ },
13
+ "browserslist": [
14
+ "> 1%",
15
+ "last 2 versions",
16
+ "not ie <= 8"
17
+ ],
18
+ "files": [],
19
+ "devDependencies": {
20
+ "babel-core": "^6.26.0",
21
+ "babel-loader": "^7.1.2",
22
+ "babel-preset-env": "^1.6.0",
23
+ "babel-preset-stage-3": "^6.24.1",
24
+ "clean-webpack-plugin": "^4.0.0-alpha.0",
25
+ "cross-env": "^5.0.5",
26
+ "css-loader": "^0.28.7",
27
+ "uglifyjs-webpack-plugin": "^2.2.0",
28
+ "webpack": "^4.23.1",
29
+ "webpack-cli": "^4.9.1",
30
+ "webpack-dev-server": "^2.9.1"
31
+ },
32
+ "dependencies": {
33
+ "mqtt": "^4.3.7"
34
+ }
35
+ }