gis-common 1.1.1 → 1.1.4

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 +56 -192
  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";
@@ -125,12 +119,13 @@ __webpack_require__.d(__webpack_exports__, "Utils", function() { return /* reexp
125
119
  __webpack_require__.d(__webpack_exports__, "EventType", function() { return /* reexport */ EventTypeConstant; });
126
120
  __webpack_require__.d(__webpack_exports__, "ErrorType", function() { return /* reexport */ ErrorTypeConstant; });
127
121
  __webpack_require__.d(__webpack_exports__, "LayerType", function() { return /* reexport */ LayerType; });
122
+ __webpack_require__.d(__webpack_exports__, "GraphicType", function() { return /* reexport */ GraphicType; });
123
+ __webpack_require__.d(__webpack_exports__, "MeasureMode", function() { return /* reexport */ MeasureMode; });
128
124
  __webpack_require__.d(__webpack_exports__, "AudioPlayer", function() { return /* reexport */ core_AudioPlayer; });
129
125
  __webpack_require__.d(__webpack_exports__, "CanvasDrawer", function() { return /* reexport */ core_CanvasDrawer; });
130
126
  __webpack_require__.d(__webpack_exports__, "ElQuery", function() { return /* reexport */ core_ElQuery; });
131
127
  __webpack_require__.d(__webpack_exports__, "EventDispatcher", function() { return /* reexport */ core_EventDispatcher; });
132
128
  __webpack_require__.d(__webpack_exports__, "HashMap", function() { return /* reexport */ core_HashMap; });
133
- __webpack_require__.d(__webpack_exports__, "MqttClient", function() { return /* reexport */ core_MqttClient; });
134
129
  __webpack_require__.d(__webpack_exports__, "WebSocketClient", function() { return /* reexport */ core_WebSocketClient; });
135
130
  __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /* reexport */ core_WebStorage; });
136
131
 
@@ -262,10 +257,28 @@ __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /*
262
257
  S3M_GROUP: "S3MGroup", // addS3MGroupLayer(url, options, index) 添加S3M分组图层。
263
258
  TERRAIN_LAYER: "TerrainFileLayer" // 地形图层, 需要单独处理
264
259
  });
260
+ // CONCATENATED MODULE: ./src/constant/GraphicConstant.js
261
+ var GraphicType = {
262
+ POINT: 'point',
263
+ POLYLINE: 'polyline',
264
+ POLYGON: 'polygon',
265
+ BILLBOARD: 'billboard',
266
+ CYLINDER: 'cylinder',
267
+ ELLIPSOID: 'ellipsoid',
268
+ LABEL: 'label',
269
+ MODEL: 'model',
270
+ WALL: 'wall'
271
+ };
272
+ var MeasureMode = {
273
+ DISTANCE: 'distance',
274
+ AREA: 'area',
275
+ HEIGHT: 'height'
276
+ };
265
277
  // CONCATENATED MODULE: ./src/constant/index.js
266
278
 
267
279
 
268
280
 
281
+
269
282
  // CONCATENATED MODULE: ./src/utils/CommUtils.js
270
283
 
271
284
 
@@ -1256,8 +1269,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1256
1269
  * @returns {*}
1257
1270
  */
1258
1271
  convertBase64ToBlob: function convertBase64ToBlob(data) {
1259
- var mimeString = data.split(",")[0].split(":")[1].split(";")[0];
1260
- 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]);
1261
1274
  var ab = new ArrayBuffer(byteString.length);
1262
1275
  var ia = new Uint8Array(ab);
1263
1276
 
@@ -1289,19 +1302,19 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1289
1302
  convertUrlToBase64: function convertUrlToBase64(url, width, height) {
1290
1303
  return new Promise(function (resolve, reject) {
1291
1304
  var img = new Image();
1292
- img.crossOrigin = "Anonymous";
1305
+ img.crossOrigin = 'Anonymous';
1293
1306
  img.src = url;
1294
1307
  img.onload = function () {
1295
- var canvas = document.createElement("canvas");
1308
+ var canvas = document.createElement('canvas');
1296
1309
  canvas.width = width || img.width;
1297
1310
  canvas.height = height || img.height;
1298
- var ctx = canvas.getContext("2d");
1311
+ var ctx = canvas.getContext('2d');
1299
1312
  ctx.drawImage(img, 0, 0, img.width, img.height);
1300
- var ext = img.src.substring(img.src.lastIndexOf(".") + 1).toLowerCase();
1301
- var dataURL = canvas.toDataURL("image/" + ext);
1313
+ var ext = img.src.substring(img.src.lastIndexOf('.') + 1).toLowerCase();
1314
+ var dataURL = canvas.toDataURL('image/' + ext);
1302
1315
  var base64 = {
1303
1316
  dataURL: dataURL,
1304
- type: "image/" + ext,
1317
+ type: 'image/' + ext,
1305
1318
  ext: ext
1306
1319
  };
1307
1320
  resolve(base64);
@@ -1317,7 +1330,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1317
1330
  * @returns {*}
1318
1331
  */
1319
1332
  convertBase64ToFile: function convertBase64ToFile(dataurl, filename) {
1320
- var arr = dataurl.split(","),
1333
+ var arr = dataurl.split(','),
1321
1334
  mime = arr[0].match(/:(.*?);/)[1],
1322
1335
  bstr = atob(arr[1]),
1323
1336
  n = bstr.length,
@@ -1332,16 +1345,24 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1332
1345
  /**
1333
1346
  * 直接下载文件,支持blob类型和url类型
1334
1347
  *
1335
- * @param {*} url
1348
+ * @param {*} data
1336
1349
  * @param {*} saveName
1337
1350
  */
1338
- downloadFromFile: function downloadFromFile(url, saveName) {
1339
- if ((typeof url === "undefined" ? "undefined" : _typeof(url)) == "object" && url instanceof Blob) {
1340
- 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
+ url = new Blob([str], { type: 'text/json' }); // json对象
1359
+ }
1360
+ } else if (typeof data == 'string') {
1361
+ url = new Blob([data], { type: 'text/json' }); //json文本
1341
1362
  }
1342
- var link = document.createElement("a");
1363
+ var link = document.createElement('a');
1343
1364
  link.href = url;
1344
- link.download = saveName || ""; // HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
1365
+ link.download = saveName || ''; // HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
1345
1366
  link.click();
1346
1367
  window.URL.revokeObjectURL(link.href);
1347
1368
  }
@@ -1448,9 +1469,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1448
1469
  */
1449
1470
  throttle: function throttle(func, wait, type) {
1450
1471
  if (type === 1) {
1451
- var _previous = 0;
1472
+ var previous = 0;
1452
1473
  } else if (type === 2) {
1453
- var _timeout = void 0;
1474
+ var timeout;
1454
1475
  }
1455
1476
  return function () {
1456
1477
  var context = this;
@@ -2092,184 +2113,27 @@ var HashMap = function () {
2092
2113
  }();
2093
2114
 
2094
2115
  /* harmony default export */ var core_HashMap = (HashMap);
2095
- // EXTERNAL MODULE: external "mqtt"
2096
- var external_mqtt_ = __webpack_require__(0);
2097
-
2098
- // CONCATENATED MODULE: ./src/core/MqttClient.js
2099
- 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; }; }();
2100
-
2101
- function MqttClient_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2102
-
2103
- 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; }
2104
-
2105
- 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; }
2106
-
2107
-
2108
-
2109
-
2110
-
2111
-
2112
-
2113
- var MqttClient_MqttClient = function (_EventDispatcher) {
2114
- _inherits(MqttClient, _EventDispatcher);
2115
-
2116
- /**
2117
- * Creates an instance of MqttClient.
2118
- * @param {*} config mqtt实例参数
2119
- */
2120
- function MqttClient() {
2121
- var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2122
-
2123
- MqttClient_classCallCheck(this, MqttClient);
2124
-
2125
- var _this = _possibleConstructorReturn(this, (MqttClient.__proto__ || Object.getPrototypeOf(MqttClient)).call(this));
2126
-
2127
- _this.context = CommUtils.extend(MqttClient.defaultContext, config);
2128
- _this.options = {
2129
- connectTimeout: _this.context.MQTT_TIMEOUTM,
2130
- clientId: CommUtils.generateGuid(),
2131
- username: _this.context.MQTT_USERNAME,
2132
- password: _this.context.MQTT_PASSWORD,
2133
- clean: true
2134
- };
2135
- _this.client = Object(external_mqtt_["connect"])(_this.context.MQTT_SERVICE, _this.options);
2136
- _this._onConnect();
2137
- _this._onMessage();
2138
- MqttClient.instance = _this;
2139
- return _this;
2140
- }
2141
-
2142
- MqttClient_createClass(MqttClient, [{
2143
- key: "_onConnect",
2144
- value: function _onConnect() {
2145
- var _this2 = this;
2146
-
2147
- this.client.on("connect", function () {
2148
- console.log("链接mqtt成功==>" + _this2.context.MQTT_SERVICE);
2149
- _this2.dispatchEvent({ type: EventTypeConstant.MQTT_CONNECT, message: _this2 });
2150
- });
2151
- this.client.on("error", function (err) {
2152
- console.log("链接mqtt报错", err);
2153
- _this2.dispatchEvent({ type: EventTypeConstant.MQTT_ERROR, message: _this2 });
2154
- _this2.client.end();
2155
- _this2.client.reconnect();
2156
- });
2157
- }
2158
- }, {
2159
- key: "_onMessage",
2160
- value: function _onMessage() {
2161
- var _this3 = this;
2162
-
2163
- this.client.on("message", function (topic, message) {
2164
- var dataString = message;
2165
- var data = "";
2166
- if (message instanceof Uint8Array) {
2167
- dataString = message.toString();
2168
- }
2169
- try {
2170
- data = JSON.parse(dataString);
2171
- } catch (error) {
2172
- throw new Error(ErrorTypeConstant.JSON_PARSE_ERROR);
2173
- }
2174
- _this3.dispatchEvent({
2175
- type: EventTypeConstant.MQTT_MESSAGE,
2176
- message: { topic: topic, data: data }
2177
- });
2178
- });
2179
- }
2180
- }, {
2181
- key: "sendMsg",
2182
- value: function sendMsg(topic, msg) {
2183
- if (!this.client.connected) {
2184
- console.error("客户端未连接");
2185
- return;
2186
- }
2187
- this.client.publish(topic, msg, { qos: 1, retain: true });
2188
- }
2189
- }, {
2190
- key: "subscribe",
2191
- value: function subscribe(topic) {
2192
- this.client.subscribe(topic, { qos: 1 }, function (error, res) {
2193
- if (error instanceof Error || res.length === 0) {
2194
- console.error("\u8BA2\u9605\u5931\u8D25==>" + topic, error);
2195
- } else {
2196
- console.log("\u8BA2\u9605\u6210\u529F==>" + topic);
2197
- }
2198
- });
2199
- return this;
2200
- }
2201
- }, {
2202
- key: "unsubscribe",
2203
- value: function unsubscribe(topic) {
2204
- this.client.unsubscribe(topic, { qos: 1 }, function (error, res) {
2205
- if (error instanceof Error || res.length === 0) {
2206
- console.error("\u53D6\u6D88\u8BA2\u9605\u5931\u8D25==>" + topic, error);
2207
- } else {
2208
- console.log("\u53D6\u6D88\u8BA2\u9605\u6210\u529F==>" + topic);
2209
- }
2210
- });
2211
- return this;
2212
- }
2213
- }, {
2214
- key: "unconnect",
2215
- value: function unconnect() {
2216
- this.client.end();
2217
- this.client = null;
2218
- this.dispatchEvent({ type: EventTypeConstant.MQTT_CLOSE, message: null });
2219
- console.log("断开mqtt成功==>" + this.context.MQTT_SERVICE);
2220
- }
2221
- /**
2222
- * @description 获取并冻结mqtt实例
2223
- * @static
2224
- * @param {*} [config={}]
2225
- * @returns {MqttClient}
2226
- */
2227
-
2228
- }], [{
2229
- key: "getInstance",
2230
- value: function getInstance() {
2231
- var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2232
-
2233
- if (MqttClient.instance) {
2234
- return Object.freeze(MqttClient.instance);
2235
- } else {
2236
- return Object.freeze(new MqttClient(config));
2237
- }
2238
- }
2239
- }]);
2240
-
2241
- return MqttClient;
2242
- }(core_EventDispatcher);
2243
-
2244
- /* harmony default export */ var core_MqttClient = (MqttClient_MqttClient);
2245
-
2246
- MqttClient_MqttClient.defaultContext = {
2247
- MQTT_TIMEOUTM: 20000,
2248
- MQTT_USERNAME: "iRVMS-WEB",
2249
- MQTT_PASSWORD: "novasky888",
2250
- MQTT_SERVICE: "ws://" + window.document.domain + ":20007/mqtt"
2251
- };
2252
2116
  // CONCATENATED MODULE: ./src/core/WebSocketClient.js
2253
2117
  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; }; }();
2254
2118
 
2255
2119
  function WebSocketClient_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2256
2120
 
2257
- 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; }
2121
+ 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; }
2258
2122
 
2259
- 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; }
2123
+ 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; }
2260
2124
 
2261
2125
 
2262
2126
 
2263
2127
 
2264
2128
  var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
2265
- WebSocketClient_inherits(WebSocketClient, _EventDispatcher);
2129
+ _inherits(WebSocketClient, _EventDispatcher);
2266
2130
 
2267
2131
  function WebSocketClient() {
2268
2132
  var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'ws://127.0.0.1:10088';
2269
2133
 
2270
2134
  WebSocketClient_classCallCheck(this, WebSocketClient);
2271
2135
 
2272
- var _this = WebSocketClient_possibleConstructorReturn(this, (WebSocketClient.__proto__ || Object.getPrototypeOf(WebSocketClient)).call(this));
2136
+ var _this = _possibleConstructorReturn(this, (WebSocketClient.__proto__ || Object.getPrototypeOf(WebSocketClient)).call(this));
2273
2137
 
2274
2138
  _this.maxCheckTimes = 10;
2275
2139
  _this.url = url;
@@ -2506,7 +2370,7 @@ var WebStorage_WebStorage = function () {
2506
2370
 
2507
2371
 
2508
2372
 
2509
-
2373
+ // export { default as MqttClient } from './core/MqttClient' vite不支持?
2510
2374
 
2511
2375
 
2512
2376
 
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.1",
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.4",
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
+ }