emacroh5lib 1.0.85 → 1.0.87

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.
@@ -36,10 +36,6 @@ Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
36
36
  version 0.6.9
37
37
  */
38
38
 
39
- /*! sheetjs (C) 2013-present SheetJS -- http://sheetjs.com */
40
-
41
- /*! xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
42
-
43
39
  /**
44
40
  * vue-class-component v7.2.3
45
41
  * (c) 2015-present Evan You
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emacroh5lib",
3
- "version": "1.0.85",
3
+ "version": "1.0.87",
4
4
  "description": "EMacro前端组件库",
5
5
  "main": "dist/emacroh5lib.min.js",
6
6
  "scripts": {
@@ -79,6 +79,7 @@
79
79
  "@types/js-cookie": "^3.0.1",
80
80
  "@vue/cli-plugin-typescript": "^5.0.4",
81
81
  "axios": "^0.26.1",
82
+ "blueimp-md5": "^2.19.0",
82
83
  "browser-md5-file": "^1.1.1",
83
84
  "core-js": "^3.22.2",
84
85
  "deep-eql": "^4.0.0",
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { EMacro } from "./utilities/EMacro";
3
-
3
+ import TaskScheduler from "./utilities/TaskScheduler";
4
4
 
5
5
  import FileViewer from './views/FileViewer/index.vue'
6
6
  import ImageViewer from './views/ImageViewer/index.vue'
@@ -34,4 +34,4 @@ if (typeof window !== 'undefined' && (window as any).Vue) {
34
34
 
35
35
 
36
36
  export default {}
37
- export { EMacro, FileViewer, ImageViewer, VideoViewer, ModelViewer, DragResizeView, HtmlViewer }
37
+ export { EMacro, FileViewer, ImageViewer, VideoViewer, ModelViewer, DragResizeView, HtmlViewer, TaskScheduler }
@@ -1,8 +1,7 @@
1
1
 
2
2
  import XLSX from "xlsx";
3
3
  // import XLSX from "./dist/xlsx.js";
4
-
5
-
4
+
6
5
 
7
6
  // const XLSX = require("./dist/xlsx.js")
8
7
  import BMF from 'browser-md5-file';
@@ -306,6 +305,8 @@ export namespace EMacro {
306
305
  }
307
306
  }
308
307
 
308
+
309
+
309
310
  }
310
311
 
311
312
 
@@ -0,0 +1,244 @@
1
+
2
+ import md5 from "blueimp-md5"
3
+
4
+ class STATE {
5
+ // 未就绪
6
+ static NotReady = 0
7
+ // 就绪
8
+ static Ready = 1
9
+ // 运行中
10
+ static Running = 2
11
+ // 已删除
12
+ static Deleted = 3
13
+ // 任务执行异常
14
+ static Error = 4
15
+ }
16
+
17
+ class FunctionUtil {
18
+
19
+ static createFunction(fun) {
20
+
21
+ if (typeof fun === 'function') {
22
+ return fun
23
+ } else if (typeof fun === 'string') {
24
+ return new Function('return ' + fun)();
25
+ } else {
26
+ return null
27
+ }
28
+ }
29
+
30
+ static getParamNames(fun) {
31
+
32
+ if (typeof fun !== 'function') {
33
+ throw Error("参数fun必须是function类型")
34
+ }
35
+
36
+ let funStr = fun.toString();
37
+ // let _param = fun.toString().match(/function\s*([^(].+[\)$])/)[1];
38
+ // _param = _param.substring(this.getName().length + 1, _param.length-1);
39
+
40
+ let paramNames = funStr.substring(funStr.indexOf('(') + 1, funStr.indexOf(')'));
41
+ if (paramNames.length <= 0) return [];
42
+ paramNames = paramNames.split(',').map(function (name) { // 清洗多余字符
43
+ return name.match(/\w+/)[0]
44
+ });
45
+
46
+ return paramNames;
47
+ }
48
+
49
+ static getFunctionName(fun) {
50
+
51
+ let _callee = fun.toString().replace(/[\s\?]*/g, ""),
52
+ comb = _callee.length >= 50 ? 50 : _callee.length;
53
+ _callee = _callee.substring(0, comb);
54
+ let name = _callee.match(/^function([^\(]+?)\(/);
55
+ if (name && name[1])
56
+ return name[1];
57
+
58
+ let caller = fun.caller,
59
+ _caller = caller.toString().replace(/[\s\?]*/g, "");
60
+ let last = _caller.indexOf(_callee),
61
+ str = _caller.substring(last - 30, last);
62
+ name = str.match(/var([^\=]+?)\=/);
63
+ if (name && name[1])
64
+ return name[1];
65
+
66
+ return "anonymous"
67
+ }
68
+
69
+ }
70
+
71
+ class Task {
72
+
73
+ constructor(fun, config) {
74
+
75
+ const funMd5 = md5(fun.toString())
76
+ if (typeof config === 'number') {
77
+ this.interval = parseInt(config)
78
+ this.immediate = true
79
+ this.name = funMd5
80
+ } else if (typeof config === 'object') {
81
+ const { interval, immediate, name, onStop, onError } = config
82
+ this.interval = parseInt(interval)
83
+ this.immediate = immediate
84
+ this.name = name || funMd5
85
+ this.onStop = onStop
86
+ this.onError = onError
87
+ }
88
+
89
+ this.callback = fun
90
+ this.executions = 0 // 函数执行次数
91
+ this.state = STATE.NotReady
92
+ this.timerIdList = []
93
+ }
94
+
95
+ execute() {
96
+
97
+ return new Promise((resolve, reject) => {
98
+
99
+ try {
100
+ if (this.state != STATE.Ready)
101
+ return reject(this)
102
+
103
+ this.state = STATE.Running
104
+
105
+ this.callback()
106
+
107
+ this.executions++
108
+ this.state = STATE.Ready
109
+ return resolve(this)
110
+ } catch (error) {
111
+ this.state = STATE.Ready
112
+ this.error = error
113
+ return reject(this)
114
+ }
115
+
116
+ })
117
+ }
118
+
119
+ ready() {
120
+ if (this.state == STATE.Ready) {
121
+ console.warn("task already running", this);
122
+ return
123
+ }
124
+ this.state = STATE.Ready
125
+ }
126
+
127
+ stop() {
128
+ if (this.state == STATE.NotReady) {
129
+ console.warn("task is stopped", this);
130
+ return
131
+ }
132
+ this.state = STATE.NotReady
133
+ }
134
+
135
+ clearTimer() {
136
+ while (this.timerIdList.length > 0)
137
+ clearTimeout(this.timerIdList.splice(-1, 1))
138
+ }
139
+
140
+ }
141
+
142
+ class TaskScheduler {
143
+
144
+ static taskMap = new Map()
145
+
146
+ static createTask(fun, config) {
147
+
148
+ if (typeof config !== 'number' && typeof config !== 'object') {
149
+ throw Error('argument config must be a number or an object')
150
+ }
151
+
152
+ if (typeof fun === 'string')
153
+ fun = FunctionUtil.createFunction(fun)
154
+
155
+ if (typeof fun !== 'function')
156
+ throw Error('invalid argument', fun)
157
+
158
+ const task = new Task(fun, config)
159
+ TaskScheduler.taskMap.set(task.name, task)
160
+ return task
161
+ }
162
+
163
+ static runAllTask() {
164
+
165
+ for (const iterator of TaskScheduler.taskMap) {
166
+ const name = iterator[0]
167
+ const task = iterator[1]
168
+
169
+ if (isNaN(task.interval) || task.interval <= 0) {
170
+ console.warn("the interval of the task is invalid", task);
171
+ continue
172
+ }
173
+
174
+ if (task.state !== STATE.Ready)
175
+ task.ready()
176
+ const interval = task.interval
177
+ if (task.immediate)
178
+ task.interval = 0
179
+ setTimeout(() => {
180
+ TaskScheduler.runTask(task)
181
+ task.interval = interval
182
+ }, task.interval);
183
+
184
+ }
185
+ }
186
+
187
+ static stopAllTask() {
188
+ for (const iterator of TaskScheduler.taskMap) {
189
+ const name = iterator[0]
190
+ const task = iterator[1]
191
+ task.stop()
192
+ }
193
+ }
194
+
195
+ static runTask(task) {
196
+
197
+ if (task.state != STATE.Ready) {
198
+
199
+ task.onStop && task.onStop()
200
+ if (task.state == STATE.NotReady) {
201
+ } else if (task.state == STATE.Deleted) {
202
+ }
203
+ task.clearTimer()
204
+ task = null
205
+ return
206
+ }
207
+
208
+ task.execute()
209
+ .then(() => {
210
+ while (task.timerIdList.length > 2)
211
+ clearTimeout(task.timerIdList.splice(-1, 1))
212
+ task.timerIdList.push(setTimeout(() => TaskScheduler.runTask(task), task.interval))
213
+ }).catch((task) => {
214
+ task.state = STATE.Error
215
+ task.onError && task.onError()
216
+ task.clearTimer()
217
+ console.error("task scheduling exception", task);
218
+ })
219
+ }
220
+
221
+ static stopTask(name) {
222
+ const task = TaskScheduler.taskMap.get(name)
223
+ if (task) {
224
+ task.stop()
225
+ } else {
226
+ console.warn('not found task: ' + name);
227
+ }
228
+ }
229
+
230
+ static deleteTask(name) {
231
+
232
+ const task = TaskScheduler.taskMap.get(name)
233
+ if (task) {
234
+ task.state = STATE.Deleted
235
+ } else {
236
+ console.warn('not found task: ' + name);
237
+ return false
238
+ }
239
+ return TaskScheduler.taskMap.delete(name)
240
+ }
241
+
242
+ }
243
+
244
+ export default TaskScheduler
@@ -132,6 +132,10 @@
132
132
  background: {
133
133
  type: Number,
134
134
  default: 0xb9d3ff,
135
+ },
136
+ transparency: {
137
+ type: Number,
138
+ default: 0.6,
135
139
  }
136
140
  },
137
141
  computed: {
@@ -774,7 +778,7 @@
774
778
  */
775
779
  this.gl.renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
776
780
  this.gl.renderer.setSize(width, height); //设置渲染区域尺寸
777
- this.gl.renderer.setClearColor(this.background, this.background == null ? 0 : 1); //设置背景颜色
781
+ this.gl.renderer.setClearColor(this.background, this.transparency); //设置背景颜色
778
782
 
779
783
  this.gl.WebGLoutput.innerHTML = ""
780
784
  this.gl.renderer.domElement.style.width = "100%"
@@ -1,103 +0,0 @@
1
- # WaveFront *.mtl file (generated by Cinema 4D)
2
-
3
- newmtl default
4
- Kd 1 1 1
5
-
6
- newmtl 材质.1
7
- Ka 1 1 1
8
- Kd 0.12300000339746 0.12884999811649 0.15000000596046
9
- Ks 1 1 1
10
- Ns 50
11
- illum 7
12
-
13
- newmtl 材质.10
14
- Ka 1 1 1
15
- Kd 0.95999997854233 0.79295998811722 0.12479999661446
16
- Ks 1 1 1
17
- Ns 50
18
- illum 7
19
-
20
- newmtl 材质.7
21
- Ka 1 1 1
22
- Kd 1 1 1
23
- Ks 1 1 1
24
- Ns 90
25
- illum 7
26
-
27
- newmtl 材质.4
28
- Ka 1 1 1
29
- Kd 0.9200000166893 0.9200000166893 0.9200000166893
30
- Ks 1 1 1
31
- Ns 4
32
- illum 7
33
-
34
- newmtl 材质.2
35
- Ka 1 1 1
36
- Kd 0.87000000476837 0.21750000119209 0.21750000119209
37
- Ks 1 1 1
38
- Ns 50
39
- illum 7
40
-
41
- newmtl 材质.9
42
- Ka 1 1 1
43
- Kd 1 1 1
44
- Ks 0.68000000715256 0.59273332357407 0.30599999427795
45
- Ns 90
46
- illum 7
47
-
48
- newmtl 材质.5
49
- Ka 1 1 1
50
- Kd 0.23275999724865 0.200100004673 0.68999999761581
51
- Ks 1 1 1
52
- Ns 50
53
- illum 7
54
-
55
- newmtl 材质.6
56
- Ka 1 1 1
57
- Kd 1 1 1
58
- Ks 1 1 1
59
- Ns 50
60
- illum 7
61
-
62
- newmtl 材质.8
63
- Ka 1 1 1
64
- Kd 0.75999999046326 0.37873333692551 0.22800000011921
65
- Ks 1 1 1
66
- Ns 50
67
- illum 7
68
-
69
- newmtl 材质
70
- Ka 1 1 1
71
- Kd 0.62999999523163 0.62999999523163 0.62999999523163
72
- Ks 1 1 1
73
- Ns 50
74
- illum 7
75
-
76
- newmtl 材质.1
77
- Ka 1 1 1
78
- Kd 0.15639999508858 0.15934666991234 0.17000000178814
79
- Ks 1 1 1
80
- Ns 50
81
- illum 7
82
-
83
- newmtl 材质
84
- Ka 1 1 1
85
- Kd 0.78200000524521 0.79673331975937 0.85000002384186
86
- Ks 1 1 1
87
- Ns 50
88
- illum 7
89
-
90
- newmtl 材质.10
91
- Ka 1 1 1
92
- Kd 0.95999997854233 0.79295998811722 0.12479999661446
93
- Ks 1 1 1
94
- Ns 50
95
- illum 7
96
-
97
- newmtl 材质.3
98
- Ka 1 1 1
99
- Kd 0.88999998569489 0.82770001888275 0.14239999651909
100
- Ks 1 1 1
101
- Ns 50
102
- illum 7
103
-