gis-common 2.2.2 → 2.2.3

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "gis-common",
3
3
  "description": "gis-common",
4
4
  "main": "src/index.js",
5
- "version": "2.2.2",
5
+ "version": "2.2.3",
6
6
  "author": "Guo.Yan <luv02@vip.qq.com>",
7
7
  "license": "MIT",
8
8
  "private": false,
@@ -10,6 +10,9 @@
10
10
  "dev": "cross-env NODE_ENV=development webpack-dev-server --hot --port 7000",
11
11
  "build": "cross-env NODE_ENV=production webpack --progress"
12
12
  },
13
+ "files": [
14
+ "src"
15
+ ],
13
16
  "browserslist": [
14
17
  "> 1%",
15
18
  "last 2 versions",
@@ -1,93 +1,93 @@
1
1
  function EventDispatcher() {}
2
2
 
3
3
  Object.assign(EventDispatcher.prototype, {
4
- /**
5
- * 添加监听器
6
- * @param type{string}
7
- * @param listener{function}
8
- * @param mutexStatus{boolean}
9
- */
10
- addEventListener(type, listener, context, mutexStatus = false) {
11
- if (this._listeners === undefined) this._listeners = {}
12
- this._mutex = this._mutex || {}
13
- this._context = context
14
- const mutex = this._mutex
15
- const listeners = this._listeners
16
-
17
- if (listeners[type] === undefined) {
18
- listeners[type] = []
19
- }
20
-
21
- if (listeners[type].indexOf(listener) === -1) {
22
- // 如果启用功能独占
23
- if (mutexStatus) {
24
- mutex[type] = listener
25
- }
26
- listeners[type].push(listener)
27
- }
28
- return this
29
- },
30
-
31
- hasEventListener(type, listener) {
32
- if (this._listeners === undefined) return false
33
-
34
- const listeners = this._listeners
35
-
36
- return listeners[type] !== undefined && listeners[type].indexOf(listener) !== -1
37
- },
38
-
39
- removeEventListener(type, listener) {
40
- if (this._listeners === undefined) return
41
-
42
- const listeners = this._listeners
43
- const listenerArray = listeners[type]
44
-
45
- // 移除指定的功能独占
46
- if (this._mutex[type] === listener) {
47
- this._mutex[type] = null
48
- }
49
-
50
- if (listenerArray !== undefined) {
51
- const index = listenerArray.indexOf(listener)
52
-
53
- if (index !== -1) {
54
- listenerArray.splice(index, 1)
55
- }
56
- }
57
- },
58
-
59
- /**
60
- * 派发事件
61
- * @param event{{type: string, message: {}}}
62
- */
63
- dispatchEvent(event) {
64
- if (this._listeners === undefined) return
65
-
66
- const listeners = this._listeners
67
- const listenerArray = listeners[event.type]
68
-
69
- if (listenerArray !== undefined) {
70
- event.target = this
71
-
72
- // Make a copy, in case listeners are removed while iterating.
73
- const array = listenerArray.slice(0)
74
- if (this._mutex[event.type]) {
75
- const find = array.find(item => item === this._mutex[event.type])
76
- find.call(this._context || this, event)
77
- return
78
- }
79
- for (let i = 0, l = array.length; i < l; i++) {
80
- array[i].call(this._context || this, event)
81
- }
82
- }
83
- },
84
-
85
- removeAllListener() {
86
- this._mutex = {}
87
- for (const key in this._listeners) {
88
- this._listeners[key] = []
89
- }
90
- }
4
+ /**
5
+ * 添加监听器
6
+ * @param type{string}
7
+ * @param listener{function}
8
+ * @param mutexStatus{boolean}
9
+ */
10
+ addEventListener(type, listener, context, mutexStatus = false) {
11
+ if (this._listeners === undefined) this._listeners = {}
12
+ this._mutex = this._mutex || {}
13
+ this._context = context
14
+ const mutex = this._mutex
15
+ const listeners = this._listeners
16
+
17
+ if (listeners[type] === undefined) {
18
+ listeners[type] = []
19
+ }
20
+
21
+ if (listeners[type].indexOf(listener) === -1) {
22
+ // 如果启用功能独占
23
+ if (mutexStatus) {
24
+ mutex[type] = listener
25
+ }
26
+ listeners[type].push(listener)
27
+ }
28
+ return this
29
+ },
30
+
31
+ hasEventListener(type, listener) {
32
+ if (this._listeners === undefined) return false
33
+
34
+ const listeners = this._listeners
35
+
36
+ return listeners[type] !== undefined && listeners[type].indexOf(listener) !== -1
37
+ },
38
+
39
+ removeEventListener(type, listener) {
40
+ if (this._listeners === undefined) return
41
+
42
+ const listeners = this._listeners
43
+ const listenerArray = listeners[type]
44
+
45
+ // 移除指定的功能独占
46
+ if (this._mutex[type] === listener) {
47
+ this._mutex[type] = null
48
+ }
49
+
50
+ if (listenerArray !== undefined) {
51
+ const index = listenerArray.map((d) => d.toString()).indexOf(listener.toString())
52
+
53
+ if (index !== -1) {
54
+ listenerArray.splice(index, 1)
55
+ }
56
+ }
57
+ },
58
+
59
+ /**
60
+ * 派发事件
61
+ * @param event{{type: string, message: {}}}
62
+ */
63
+ dispatchEvent(event) {
64
+ if (this._listeners === undefined) return
65
+
66
+ const listeners = this._listeners
67
+ const listenerArray = listeners[event.type]
68
+
69
+ if (listenerArray !== undefined) {
70
+ event.target = this
71
+
72
+ // Make a copy, in case listeners are removed while iterating.
73
+ const array = listenerArray.slice(0)
74
+ if (this._mutex[event.type]) {
75
+ const find = array.find((item) => item === this._mutex[event.type])
76
+ find.call(this._context || this, event)
77
+ return
78
+ }
79
+ for (let i = 0, l = array.length; i < l; i++) {
80
+ array[i].call(this._context || this, event)
81
+ }
82
+ }
83
+ },
84
+
85
+ removeAllListener() {
86
+ this._mutex = {}
87
+ for (const key in this._listeners) {
88
+ this._listeners[key] = []
89
+ }
90
+ },
91
91
  })
92
92
 
93
93
  export default EventDispatcher
package/.babelrc DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "presets": [
3
- [
4
- "env",
5
- {
6
- "modules": false
7
- }
8
- ],
9
- "stage-3"
10
- ]
11
- }
package/.editorconfig DELETED
@@ -1,9 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- charset = utf-8
5
- indent_style = space
6
- indent_size = 4
7
- end_of_line = lf
8
- insert_final_newline = true
9
- trim_trailing_whitespace = true
package/.prettierrc DELETED
@@ -1 +0,0 @@
1
- { "printWidth": 160, "tabWidth": 4, "singleQuote": true, "semi": false }
package/index.html DELETED
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
-
4
- <head>
5
- <meta charset="UTF-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <meta http-equiv="X-UA-Compatible" content="ie=edge" />
8
- <script src="./dist/resource.min.js"></script>
9
- <style>
10
- body, html {
11
- width: 100%;
12
- height: 100%;
13
- margin: 0;
14
- }
15
- #app {
16
- height: 100%;
17
- }
18
-
19
- </style>
20
- </head>
21
-
22
- <body>
23
- <div id="app"></div>
24
- </body>
25
-
26
- </html>
package/jsconfig.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2017",
4
- "allowSyntheticDefaultImports": false,
5
- "baseUrl": "./",
6
- "paths": {
7
- "@/*": [
8
- "src/*"
9
- ]
10
- }
11
- },
12
- "include": [
13
- "./src/**/*",
14
- ],
15
- "exclude": [
16
- "node_modules",
17
- "dist"
18
- ]
19
- }
package/webpack.config.js DELETED
@@ -1,70 +0,0 @@
1
- var path = require('path')
2
- var webpack = require('webpack')
3
- const { CleanWebpackPlugin } = require('clean-webpack-plugin')
4
-
5
- module.exports = {
6
- entry: './src/index.js',
7
- output: {
8
- path: path.resolve(__dirname, './dist'),
9
- publicPath: '/dist/',
10
- filename: 'resource.min.js',
11
- library: 'Gis',
12
- libraryTarget: 'umd',
13
- umdNamedDefine: true,
14
- },
15
- module: {
16
- rules: [
17
- {
18
- test: /\.css$/,
19
- use: ['vue-style-loader', 'css-loader'],
20
- },
21
- {
22
- test: /\.vue$/,
23
- loader: 'vue-loader',
24
- options: {
25
- loaders: {},
26
- // other vue-loader options go here
27
- },
28
- },
29
- {
30
- test: /\.js$/,
31
- loader: 'babel-loader',
32
- exclude: /node_modules/,
33
- },
34
- {
35
- test: /\.(png|jpg|gif|svg)$/,
36
- loader: 'url-loader',
37
- options: {
38
- limit: 100000,
39
- },
40
- },
41
- ],
42
- },
43
- externals: {
44
- mqtt: 'mqtt',
45
- },
46
- plugins: [
47
- new CleanWebpackPlugin(),
48
- new webpack.LoaderOptionsPlugin({
49
- minimize: true,
50
- }),
51
- ],
52
- resolve: {
53
- alias: {
54
- vue$: 'vue/dist/vue.esm.js',
55
- },
56
- extensions: ['*', '.js', '.vue', '.json'],
57
- },
58
- devServer: {
59
- historyApiFallback: true,
60
- noInfo: true,
61
- overlay: true,
62
- },
63
- performance: {
64
- hints: false,
65
- },
66
- devtool: 'none',
67
- optimization: {
68
- minimize: false,
69
- },
70
- }