@idraw/core 0.3.0-beta.3 → 0.3.0-beta.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/esm/index.d.ts +44 -44
- package/dist/esm/index.js +85 -80
- package/dist/esm/lib/calculate.d.ts +3 -3
- package/dist/esm/lib/calculate.js +5 -5
- package/dist/esm/lib/check.d.ts +4 -4
- package/dist/esm/lib/check.js +1 -1
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/core-event.d.ts +21 -21
- package/dist/esm/lib/diff.d.ts +6 -6
- package/dist/esm/lib/diff.js +9 -7
- package/dist/esm/lib/draw/base.d.ts +5 -5
- package/dist/esm/lib/draw/wrapper.d.ts +4 -4
- package/dist/esm/lib/element.d.ts +8 -8
- package/dist/esm/lib/element.js +15 -11
- package/dist/esm/lib/engine-temp.d.ts +4 -4
- package/dist/esm/lib/is.d.ts +3 -3
- package/dist/esm/lib/parse.d.ts +2 -2
- package/dist/esm/lib/parse.js +6 -3
- package/dist/esm/lib/transform.d.ts +4 -4
- package/dist/esm/lib/transform.js +1 -1
- package/dist/esm/mixins/element.d.ts +12 -14
- package/dist/esm/mixins/element.js +60 -62
- package/dist/esm/plugins/helper.d.ts +7 -7
- package/dist/esm/plugins/helper.js +5 -10
- package/dist/index.global.js +2247 -1199
- package/dist/index.global.min.js +1 -1
- package/package.json +6 -6
- package/dist/esm/lib/element/element-base.d.ts +0 -3
- package/dist/esm/lib/element/element-base.js +0 -5
- package/dist/esm/lib/element/element-controller.d.ts +0 -3
- package/dist/esm/lib/element/element-controller.js +0 -3
- package/dist/esm/lib/element/element-hub.d.ts +0 -9
- package/dist/esm/lib/element/element-hub.js +0 -16
- package/dist/esm/lib/engine.d.ts +0 -47
- package/dist/esm/lib/helper.d.ts +0 -30
- package/dist/esm/lib/mapper.d.ts +0 -26
- package/dist/esm/names.d.ts +0 -15
- package/dist/esm/names.js +0 -15
package/dist/index.global.js
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
var iDrawCore = function() {
|
|
2
2
|
"use strict";
|
|
3
|
+
var __assign$1$1 = function() {
|
|
4
|
+
__assign$1$1 = Object.assign || function __assign2(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s)
|
|
8
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
9
|
+
t[p] = s[p];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
return __assign$1$1.apply(this, arguments);
|
|
14
|
+
};
|
|
3
15
|
function compose(middleware) {
|
|
4
16
|
return function(context, next) {
|
|
5
17
|
return dispatch(0);
|
|
6
18
|
function dispatch(i) {
|
|
7
|
-
|
|
19
|
+
var fn = middleware[i];
|
|
8
20
|
if (i === middleware.length && next) {
|
|
9
21
|
fn = next;
|
|
10
22
|
}
|
|
@@ -19,31 +31,35 @@ var iDrawCore = function() {
|
|
|
19
31
|
};
|
|
20
32
|
}
|
|
21
33
|
function delay(time) {
|
|
22
|
-
return new Promise((resolve)
|
|
23
|
-
setTimeout(()
|
|
34
|
+
return new Promise(function(resolve) {
|
|
35
|
+
setTimeout(function() {
|
|
24
36
|
resolve();
|
|
25
37
|
}, time);
|
|
26
38
|
});
|
|
27
39
|
}
|
|
28
40
|
function throttle$1(fn, timeout) {
|
|
29
|
-
|
|
30
|
-
return function(
|
|
41
|
+
var timer = -1;
|
|
42
|
+
return function() {
|
|
43
|
+
var args = [];
|
|
44
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
45
|
+
args[_i] = arguments[_i];
|
|
46
|
+
}
|
|
31
47
|
if (timer > 0) {
|
|
32
48
|
return;
|
|
33
49
|
}
|
|
34
|
-
timer = setTimeout(()
|
|
35
|
-
fn(
|
|
50
|
+
timer = setTimeout(function() {
|
|
51
|
+
fn.apply(void 0, args);
|
|
36
52
|
timer = -1;
|
|
37
53
|
}, timeout);
|
|
38
54
|
};
|
|
39
55
|
}
|
|
40
56
|
function downloadImageFromCanvas(canvas, opts) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
57
|
+
var filename = opts.filename, _a2 = opts.type, type = _a2 === void 0 ? "image/jpeg" : _a2;
|
|
58
|
+
var stream = canvas.toDataURL(type);
|
|
59
|
+
var downloadLink = document.createElement("a");
|
|
44
60
|
downloadLink.href = stream;
|
|
45
61
|
downloadLink.download = filename;
|
|
46
|
-
|
|
62
|
+
var downloadClickEvent = document.createEvent("MouseEvents");
|
|
47
63
|
downloadClickEvent.initEvent("click", true, false);
|
|
48
64
|
downloadLink.dispatchEvent(downloadClickEvent);
|
|
49
65
|
}
|
|
@@ -53,120 +69,91 @@ var iDrawCore = function() {
|
|
|
53
69
|
function toColorHexStr(color2) {
|
|
54
70
|
return "#" + color2.toString(16);
|
|
55
71
|
}
|
|
56
|
-
function isColorStr(color2) {
|
|
72
|
+
function isColorStr$2(color2) {
|
|
57
73
|
return typeof color2 === "string" && /^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color2);
|
|
58
74
|
}
|
|
59
|
-
function createUUID() {
|
|
75
|
+
function createUUID$2() {
|
|
60
76
|
function str4() {
|
|
61
77
|
return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
|
|
62
78
|
}
|
|
63
|
-
return
|
|
79
|
+
return "".concat(str4()).concat(str4(), "-").concat(str4(), "-").concat(str4(), "-").concat(str4(), "-").concat(str4()).concat(str4()).concat(str4());
|
|
64
80
|
}
|
|
65
|
-
function deepClone(target) {
|
|
81
|
+
function deepClone$2(target) {
|
|
66
82
|
function _clone(t) {
|
|
67
|
-
|
|
83
|
+
var type = is$1$2(t);
|
|
68
84
|
if (["Null", "Number", "String", "Boolean", "Undefined"].indexOf(type) >= 0) {
|
|
69
85
|
return t;
|
|
70
86
|
} else if (type === "Array") {
|
|
71
|
-
|
|
72
|
-
t.forEach((item)
|
|
73
|
-
|
|
87
|
+
var arr_1 = [];
|
|
88
|
+
t.forEach(function(item) {
|
|
89
|
+
arr_1.push(_clone(item));
|
|
74
90
|
});
|
|
75
|
-
return
|
|
91
|
+
return arr_1;
|
|
76
92
|
} else if (type === "Object") {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
keys.forEach((key)
|
|
80
|
-
|
|
93
|
+
var obj_1 = {};
|
|
94
|
+
var keys = Object.keys(t);
|
|
95
|
+
keys.forEach(function(key) {
|
|
96
|
+
obj_1[key] = _clone(t[key]);
|
|
81
97
|
});
|
|
82
|
-
return
|
|
98
|
+
return obj_1;
|
|
83
99
|
}
|
|
84
100
|
}
|
|
85
101
|
return _clone(target);
|
|
86
102
|
}
|
|
87
|
-
function is$2(data) {
|
|
103
|
+
function is$1$2(data) {
|
|
88
104
|
return Object.prototype.toString.call(data).replace(/[\]|\[]{1,1}/ig, "").split(" ")[1];
|
|
89
105
|
}
|
|
90
|
-
function parsePrototype(data) {
|
|
91
|
-
|
|
92
|
-
|
|
106
|
+
function parsePrototype$1(data) {
|
|
107
|
+
var typeStr = Object.prototype.toString.call(data) || "";
|
|
108
|
+
var result = typeStr.replace(/(\[object|\])/ig, "").trim();
|
|
93
109
|
return result;
|
|
94
110
|
}
|
|
95
|
-
|
|
96
|
-
type(data, lowerCase) {
|
|
97
|
-
|
|
111
|
+
var istype$1 = {
|
|
112
|
+
type: function(data, lowerCase) {
|
|
113
|
+
var result = parsePrototype$1(data);
|
|
98
114
|
return lowerCase === true ? result.toLocaleLowerCase() : result;
|
|
99
115
|
},
|
|
100
|
-
array(data) {
|
|
101
|
-
return parsePrototype(data) === "Array";
|
|
116
|
+
array: function(data) {
|
|
117
|
+
return parsePrototype$1(data) === "Array";
|
|
102
118
|
},
|
|
103
|
-
json(data) {
|
|
104
|
-
return parsePrototype(data) === "Object";
|
|
119
|
+
json: function(data) {
|
|
120
|
+
return parsePrototype$1(data) === "Object";
|
|
105
121
|
},
|
|
106
|
-
function(data) {
|
|
107
|
-
return parsePrototype(data) === "Function";
|
|
122
|
+
function: function(data) {
|
|
123
|
+
return parsePrototype$1(data) === "Function";
|
|
108
124
|
},
|
|
109
|
-
asyncFunction(data) {
|
|
110
|
-
return parsePrototype(data) === "AsyncFunction";
|
|
125
|
+
asyncFunction: function(data) {
|
|
126
|
+
return parsePrototype$1(data) === "AsyncFunction";
|
|
111
127
|
},
|
|
112
|
-
string(data) {
|
|
113
|
-
return parsePrototype(data) === "String";
|
|
128
|
+
string: function(data) {
|
|
129
|
+
return parsePrototype$1(data) === "String";
|
|
114
130
|
},
|
|
115
|
-
number(data) {
|
|
116
|
-
return parsePrototype(data) === "Number";
|
|
131
|
+
number: function(data) {
|
|
132
|
+
return parsePrototype$1(data) === "Number";
|
|
117
133
|
},
|
|
118
|
-
undefined(data) {
|
|
119
|
-
return parsePrototype(data) === "Undefined";
|
|
134
|
+
undefined: function(data) {
|
|
135
|
+
return parsePrototype$1(data) === "Undefined";
|
|
120
136
|
},
|
|
121
|
-
null(data) {
|
|
122
|
-
return parsePrototype(data) === "Null";
|
|
137
|
+
null: function(data) {
|
|
138
|
+
return parsePrototype$1(data) === "Null";
|
|
123
139
|
},
|
|
124
|
-
promise(data) {
|
|
125
|
-
return parsePrototype(data) === "Promise";
|
|
140
|
+
promise: function(data) {
|
|
141
|
+
return parsePrototype$1(data) === "Promise";
|
|
126
142
|
}
|
|
127
143
|
};
|
|
128
|
-
function
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const reader = new FileReader();
|
|
142
|
-
reader.readAsDataURL(blob);
|
|
143
|
-
reader.onload = function(event) {
|
|
144
|
-
var _a2;
|
|
145
|
-
const base64 = (_a2 = event === null || event === void 0 ? void 0 : event.target) === null || _a2 === void 0 ? void 0 : _a2.result;
|
|
146
|
-
resolve(base64);
|
|
147
|
-
};
|
|
148
|
-
reader.onerror = function(err) {
|
|
149
|
-
reject(err);
|
|
150
|
-
};
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
function parseSVGToDataURL(svg2) {
|
|
154
|
-
return new Promise((resolve, reject) => {
|
|
155
|
-
const _svg = svg2;
|
|
156
|
-
const blob = new Blob([_svg], { type: "image/svg+xml;charset=utf-8" });
|
|
157
|
-
const reader = new FileReader();
|
|
158
|
-
reader.readAsDataURL(blob);
|
|
159
|
-
reader.onload = function(event) {
|
|
160
|
-
var _a2;
|
|
161
|
-
const base64 = (_a2 = event === null || event === void 0 ? void 0 : event.target) === null || _a2 === void 0 ? void 0 : _a2.result;
|
|
162
|
-
resolve(base64);
|
|
163
|
-
};
|
|
164
|
-
reader.onerror = function(err) {
|
|
165
|
-
reject(err);
|
|
166
|
-
};
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
var __awaiter$1 = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
144
|
+
var __assign$3 = function() {
|
|
145
|
+
__assign$3 = Object.assign || function __assign2(t) {
|
|
146
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
147
|
+
s = arguments[i];
|
|
148
|
+
for (var p in s)
|
|
149
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
150
|
+
t[p] = s[p];
|
|
151
|
+
}
|
|
152
|
+
return t;
|
|
153
|
+
};
|
|
154
|
+
return __assign$3.apply(this, arguments);
|
|
155
|
+
};
|
|
156
|
+
function __awaiter$2(thisArg, _arguments, P, generator) {
|
|
170
157
|
function adopt(value) {
|
|
171
158
|
return value instanceof P ? value : new P(function(resolve) {
|
|
172
159
|
resolve(value);
|
|
@@ -192,12 +179,120 @@ var iDrawCore = function() {
|
|
|
192
179
|
}
|
|
193
180
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
194
181
|
});
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
182
|
+
}
|
|
183
|
+
function __generator$2(thisArg, body) {
|
|
184
|
+
var _ = { label: 0, sent: function() {
|
|
185
|
+
if (t[0] & 1)
|
|
186
|
+
throw t[1];
|
|
187
|
+
return t[1];
|
|
188
|
+
}, trys: [], ops: [] }, f, y2, t, g;
|
|
189
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
190
|
+
return this;
|
|
191
|
+
}), g;
|
|
192
|
+
function verb(n) {
|
|
193
|
+
return function(v) {
|
|
194
|
+
return step([n, v]);
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function step(op) {
|
|
198
|
+
if (f)
|
|
199
|
+
throw new TypeError("Generator is already executing.");
|
|
200
|
+
while (_)
|
|
201
|
+
try {
|
|
202
|
+
if (f = 1, y2 && (t = op[0] & 2 ? y2["return"] : op[0] ? y2["throw"] || ((t = y2["return"]) && t.call(y2), 0) : y2.next) && !(t = t.call(y2, op[1])).done)
|
|
203
|
+
return t;
|
|
204
|
+
if (y2 = 0, t)
|
|
205
|
+
op = [op[0] & 2, t.value];
|
|
206
|
+
switch (op[0]) {
|
|
207
|
+
case 0:
|
|
208
|
+
case 1:
|
|
209
|
+
t = op;
|
|
210
|
+
break;
|
|
211
|
+
case 4:
|
|
212
|
+
_.label++;
|
|
213
|
+
return { value: op[1], done: false };
|
|
214
|
+
case 5:
|
|
215
|
+
_.label++;
|
|
216
|
+
y2 = op[1];
|
|
217
|
+
op = [0];
|
|
218
|
+
continue;
|
|
219
|
+
case 7:
|
|
220
|
+
op = _.ops.pop();
|
|
221
|
+
_.trys.pop();
|
|
222
|
+
continue;
|
|
223
|
+
default:
|
|
224
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
225
|
+
_ = 0;
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
229
|
+
_.label = op[1];
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
233
|
+
_.label = t[1];
|
|
234
|
+
t = op;
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
if (t && _.label < t[2]) {
|
|
238
|
+
_.label = t[2];
|
|
239
|
+
_.ops.push(op);
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
if (t[2])
|
|
243
|
+
_.ops.pop();
|
|
244
|
+
_.trys.pop();
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
op = body.call(thisArg, _);
|
|
248
|
+
} catch (e) {
|
|
249
|
+
op = [6, e];
|
|
250
|
+
y2 = 0;
|
|
251
|
+
} finally {
|
|
252
|
+
f = t = 0;
|
|
253
|
+
}
|
|
254
|
+
if (op[0] & 5)
|
|
255
|
+
throw op[1];
|
|
256
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function parseHTMLToDataURL$1(html2, opts) {
|
|
260
|
+
var width = opts.width, height = opts.height;
|
|
261
|
+
return new Promise(function(resolve, reject) {
|
|
262
|
+
var _svg = '\n <svg xmlns="http://www.w3.org/2000/svg" width="'.concat(width || "", '" height = "').concat(height || "", '">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ').concat(html2, "\n </div>\n </foreignObject>\n </svg>\n ");
|
|
263
|
+
var blob = new Blob([_svg], { type: "image/svg+xml;charset=utf-8" });
|
|
264
|
+
var reader = new FileReader();
|
|
265
|
+
reader.readAsDataURL(blob);
|
|
266
|
+
reader.onload = function(event) {
|
|
267
|
+
var _a2;
|
|
268
|
+
var base64 = (_a2 = event === null || event === void 0 ? void 0 : event.target) === null || _a2 === void 0 ? void 0 : _a2.result;
|
|
269
|
+
resolve(base64);
|
|
270
|
+
};
|
|
271
|
+
reader.onerror = function(err) {
|
|
272
|
+
reject(err);
|
|
273
|
+
};
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
function parseSVGToDataURL$1(svg2) {
|
|
277
|
+
return new Promise(function(resolve, reject) {
|
|
278
|
+
var _svg = svg2;
|
|
279
|
+
var blob = new Blob([_svg], { type: "image/svg+xml;charset=utf-8" });
|
|
280
|
+
var reader = new FileReader();
|
|
281
|
+
reader.readAsDataURL(blob);
|
|
282
|
+
reader.onload = function(event) {
|
|
283
|
+
var _a2;
|
|
284
|
+
var base64 = (_a2 = event === null || event === void 0 ? void 0 : event.target) === null || _a2 === void 0 ? void 0 : _a2.result;
|
|
285
|
+
resolve(base64);
|
|
286
|
+
};
|
|
287
|
+
reader.onerror = function(err) {
|
|
288
|
+
reject(err);
|
|
289
|
+
};
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
var Image$1 = window.Image;
|
|
293
|
+
function loadImage$1(src) {
|
|
294
|
+
return new Promise(function(resolve, reject) {
|
|
295
|
+
var img = new Image$1();
|
|
201
296
|
img.onload = function() {
|
|
202
297
|
resolve(img);
|
|
203
298
|
};
|
|
@@ -206,26 +301,42 @@ var iDrawCore = function() {
|
|
|
206
301
|
img.src = src;
|
|
207
302
|
});
|
|
208
303
|
}
|
|
209
|
-
function loadSVG(svg2) {
|
|
210
|
-
return __awaiter$
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
304
|
+
function loadSVG$1(svg2) {
|
|
305
|
+
return __awaiter$2(this, void 0, void 0, function() {
|
|
306
|
+
var dataURL, image;
|
|
307
|
+
return __generator$2(this, function(_a2) {
|
|
308
|
+
switch (_a2.label) {
|
|
309
|
+
case 0:
|
|
310
|
+
return [4, parseSVGToDataURL$1(svg2)];
|
|
311
|
+
case 1:
|
|
312
|
+
dataURL = _a2.sent();
|
|
313
|
+
return [4, loadImage$1(dataURL)];
|
|
314
|
+
case 2:
|
|
315
|
+
image = _a2.sent();
|
|
316
|
+
return [2, image];
|
|
317
|
+
}
|
|
318
|
+
});
|
|
214
319
|
});
|
|
215
320
|
}
|
|
216
|
-
function
|
|
217
|
-
return
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
321
|
+
function loadHTML$1(html2, opts) {
|
|
322
|
+
return __awaiter$2(this, void 0, void 0, function() {
|
|
323
|
+
var dataURL, image;
|
|
324
|
+
return __generator$2(this, function(_a2) {
|
|
325
|
+
switch (_a2.label) {
|
|
326
|
+
case 0:
|
|
327
|
+
return [4, parseHTMLToDataURL$1(html2, opts)];
|
|
328
|
+
case 1:
|
|
329
|
+
dataURL = _a2.sent();
|
|
330
|
+
return [4, loadImage$1(dataURL)];
|
|
331
|
+
case 2:
|
|
332
|
+
image = _a2.sent();
|
|
333
|
+
return [2, image];
|
|
334
|
+
}
|
|
335
|
+
});
|
|
225
336
|
});
|
|
226
337
|
}
|
|
227
|
-
|
|
228
|
-
|
|
338
|
+
var Context$1 = function() {
|
|
339
|
+
function Context2(ctx, opts) {
|
|
229
340
|
this._opts = opts;
|
|
230
341
|
this._ctx = ctx;
|
|
231
342
|
this._transform = {
|
|
@@ -234,19 +345,19 @@ var iDrawCore = function() {
|
|
|
234
345
|
scrollY: 0
|
|
235
346
|
};
|
|
236
347
|
}
|
|
237
|
-
getContext() {
|
|
348
|
+
Context2.prototype.getContext = function() {
|
|
238
349
|
return this._ctx;
|
|
239
|
-
}
|
|
240
|
-
resetSize(opts) {
|
|
241
|
-
this._opts =
|
|
242
|
-
}
|
|
243
|
-
calcDeviceNum(num) {
|
|
350
|
+
};
|
|
351
|
+
Context2.prototype.resetSize = function(opts) {
|
|
352
|
+
this._opts = __assign$3(__assign$3({}, this._opts), opts);
|
|
353
|
+
};
|
|
354
|
+
Context2.prototype.calcDeviceNum = function(num) {
|
|
244
355
|
return num * this._opts.devicePixelRatio;
|
|
245
|
-
}
|
|
246
|
-
calcScreenNum(num) {
|
|
356
|
+
};
|
|
357
|
+
Context2.prototype.calcScreenNum = function(num) {
|
|
247
358
|
return num / this._opts.devicePixelRatio;
|
|
248
|
-
}
|
|
249
|
-
getSize() {
|
|
359
|
+
};
|
|
360
|
+
Context2.prototype.getSize = function() {
|
|
250
361
|
return {
|
|
251
362
|
width: this._opts.width,
|
|
252
363
|
height: this._opts.height,
|
|
@@ -254,209 +365,217 @@ var iDrawCore = function() {
|
|
|
254
365
|
contextHeight: this._opts.contextHeight,
|
|
255
366
|
devicePixelRatio: this._opts.devicePixelRatio
|
|
256
367
|
};
|
|
257
|
-
}
|
|
258
|
-
setTransform(config) {
|
|
259
|
-
this._transform =
|
|
260
|
-
}
|
|
261
|
-
getTransform() {
|
|
368
|
+
};
|
|
369
|
+
Context2.prototype.setTransform = function(config) {
|
|
370
|
+
this._transform = __assign$3(__assign$3({}, this._transform), config);
|
|
371
|
+
};
|
|
372
|
+
Context2.prototype.getTransform = function() {
|
|
262
373
|
return {
|
|
263
374
|
scale: this._transform.scale,
|
|
264
375
|
scrollX: this._transform.scrollX,
|
|
265
376
|
scrollY: this._transform.scrollY
|
|
266
377
|
};
|
|
267
|
-
}
|
|
268
|
-
setFillStyle(color2) {
|
|
378
|
+
};
|
|
379
|
+
Context2.prototype.setFillStyle = function(color2) {
|
|
269
380
|
this._ctx.fillStyle = color2;
|
|
270
|
-
}
|
|
271
|
-
fill(fillRule) {
|
|
381
|
+
};
|
|
382
|
+
Context2.prototype.fill = function(fillRule) {
|
|
272
383
|
return this._ctx.fill(fillRule || "nonzero");
|
|
273
|
-
}
|
|
274
|
-
arc(x2, y2, radius, startAngle, endAngle, anticlockwise) {
|
|
384
|
+
};
|
|
385
|
+
Context2.prototype.arc = function(x2, y2, radius, startAngle, endAngle, anticlockwise) {
|
|
275
386
|
return this._ctx.arc(this._doSize(x2), this._doSize(y2), this._doSize(radius), startAngle, endAngle, anticlockwise);
|
|
276
|
-
}
|
|
277
|
-
rect(x2, y2, w2, h2) {
|
|
387
|
+
};
|
|
388
|
+
Context2.prototype.rect = function(x2, y2, w2, h2) {
|
|
278
389
|
return this._ctx.rect(this._doSize(x2), this._doSize(y2), this._doSize(w2), this._doSize(h2));
|
|
279
|
-
}
|
|
280
|
-
fillRect(x2, y2, w2, h2) {
|
|
390
|
+
};
|
|
391
|
+
Context2.prototype.fillRect = function(x2, y2, w2, h2) {
|
|
281
392
|
return this._ctx.fillRect(this._doSize(x2), this._doSize(y2), this._doSize(w2), this._doSize(h2));
|
|
282
|
-
}
|
|
283
|
-
clearRect(x2, y2, w2, h2) {
|
|
393
|
+
};
|
|
394
|
+
Context2.prototype.clearRect = function(x2, y2, w2, h2) {
|
|
284
395
|
return this._ctx.clearRect(this._doSize(x2), this._doSize(y2), this._doSize(w2), this._doSize(h2));
|
|
285
|
-
}
|
|
286
|
-
beginPath() {
|
|
396
|
+
};
|
|
397
|
+
Context2.prototype.beginPath = function() {
|
|
287
398
|
return this._ctx.beginPath();
|
|
288
|
-
}
|
|
289
|
-
closePath() {
|
|
399
|
+
};
|
|
400
|
+
Context2.prototype.closePath = function() {
|
|
290
401
|
return this._ctx.closePath();
|
|
291
|
-
}
|
|
292
|
-
lineTo(x2, y2) {
|
|
402
|
+
};
|
|
403
|
+
Context2.prototype.lineTo = function(x2, y2) {
|
|
293
404
|
return this._ctx.lineTo(this._doSize(x2), this._doSize(y2));
|
|
294
|
-
}
|
|
295
|
-
moveTo(x2, y2) {
|
|
405
|
+
};
|
|
406
|
+
Context2.prototype.moveTo = function(x2, y2) {
|
|
296
407
|
return this._ctx.moveTo(this._doSize(x2), this._doSize(y2));
|
|
297
|
-
}
|
|
298
|
-
arcTo(x1, y1, x2, y2, radius) {
|
|
408
|
+
};
|
|
409
|
+
Context2.prototype.arcTo = function(x1, y1, x2, y2, radius) {
|
|
299
410
|
return this._ctx.arcTo(this._doSize(x1), this._doSize(y1), this._doSize(x2), this._doSize(y2), this._doSize(radius));
|
|
300
|
-
}
|
|
301
|
-
setLineWidth(w2) {
|
|
411
|
+
};
|
|
412
|
+
Context2.prototype.setLineWidth = function(w2) {
|
|
302
413
|
return this._ctx.lineWidth = this._doSize(w2);
|
|
303
|
-
}
|
|
304
|
-
setLineDash(nums) {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
414
|
+
};
|
|
415
|
+
Context2.prototype.setLineDash = function(nums) {
|
|
416
|
+
var _this = this;
|
|
417
|
+
return this._ctx.setLineDash(nums.map(function(n) {
|
|
418
|
+
return _this._doSize(n);
|
|
419
|
+
}));
|
|
420
|
+
};
|
|
421
|
+
Context2.prototype.isPointInPath = function(x2, y2) {
|
|
308
422
|
return this._ctx.isPointInPath(this._doX(x2), this._doY(y2));
|
|
309
|
-
}
|
|
310
|
-
isPointInPathWithoutScroll(x2, y2) {
|
|
423
|
+
};
|
|
424
|
+
Context2.prototype.isPointInPathWithoutScroll = function(x2, y2) {
|
|
311
425
|
return this._ctx.isPointInPath(this._doSize(x2), this._doSize(y2));
|
|
312
|
-
}
|
|
313
|
-
setStrokeStyle(color2) {
|
|
426
|
+
};
|
|
427
|
+
Context2.prototype.setStrokeStyle = function(color2) {
|
|
314
428
|
this._ctx.strokeStyle = color2;
|
|
315
|
-
}
|
|
316
|
-
stroke() {
|
|
429
|
+
};
|
|
430
|
+
Context2.prototype.stroke = function() {
|
|
317
431
|
return this._ctx.stroke();
|
|
318
|
-
}
|
|
319
|
-
translate(x2, y2) {
|
|
432
|
+
};
|
|
433
|
+
Context2.prototype.translate = function(x2, y2) {
|
|
320
434
|
return this._ctx.translate(this._doSize(x2), this._doSize(y2));
|
|
321
|
-
}
|
|
322
|
-
rotate(angle2) {
|
|
435
|
+
};
|
|
436
|
+
Context2.prototype.rotate = function(angle2) {
|
|
323
437
|
return this._ctx.rotate(angle2);
|
|
324
|
-
}
|
|
325
|
-
drawImage(
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
438
|
+
};
|
|
439
|
+
Context2.prototype.drawImage = function() {
|
|
440
|
+
var args = [];
|
|
441
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
442
|
+
args[_i] = arguments[_i];
|
|
443
|
+
}
|
|
444
|
+
var image = args[0];
|
|
445
|
+
var sx = args[1];
|
|
446
|
+
var sy = args[2];
|
|
447
|
+
var sw = args[3];
|
|
448
|
+
var sh = args[4];
|
|
449
|
+
var dx = args[args.length - 4];
|
|
450
|
+
var dy = args[args.length - 3];
|
|
451
|
+
var dw = args[args.length - 2];
|
|
452
|
+
var dh = args[args.length - 1];
|
|
335
453
|
if (args.length === 9) {
|
|
336
454
|
return this._ctx.drawImage(image, this._doSize(sx), this._doSize(sy), this._doSize(sw), this._doSize(sh), this._doSize(dx), this._doSize(dy), this._doSize(dw), this._doSize(dh));
|
|
337
455
|
} else {
|
|
338
456
|
return this._ctx.drawImage(image, this._doSize(dx), this._doSize(dy), this._doSize(dw), this._doSize(dh));
|
|
339
457
|
}
|
|
340
|
-
}
|
|
341
|
-
createPattern(image, repetition) {
|
|
458
|
+
};
|
|
459
|
+
Context2.prototype.createPattern = function(image, repetition) {
|
|
342
460
|
return this._ctx.createPattern(image, repetition);
|
|
343
|
-
}
|
|
344
|
-
measureText(text2) {
|
|
461
|
+
};
|
|
462
|
+
Context2.prototype.measureText = function(text2) {
|
|
345
463
|
return this._ctx.measureText(text2);
|
|
346
|
-
}
|
|
347
|
-
setTextAlign(align) {
|
|
464
|
+
};
|
|
465
|
+
Context2.prototype.setTextAlign = function(align) {
|
|
348
466
|
this._ctx.textAlign = align;
|
|
349
|
-
}
|
|
350
|
-
fillText(text2, x2, y2, maxWidth) {
|
|
467
|
+
};
|
|
468
|
+
Context2.prototype.fillText = function(text2, x2, y2, maxWidth) {
|
|
351
469
|
if (maxWidth !== void 0) {
|
|
352
470
|
return this._ctx.fillText(text2, this._doSize(x2), this._doSize(y2), this._doSize(maxWidth));
|
|
353
471
|
} else {
|
|
354
472
|
return this._ctx.fillText(text2, this._doSize(x2), this._doSize(y2));
|
|
355
473
|
}
|
|
356
|
-
}
|
|
357
|
-
strokeText(text2, x2, y2, maxWidth) {
|
|
474
|
+
};
|
|
475
|
+
Context2.prototype.strokeText = function(text2, x2, y2, maxWidth) {
|
|
358
476
|
if (maxWidth !== void 0) {
|
|
359
477
|
return this._ctx.strokeText(text2, this._doSize(x2), this._doSize(y2), this._doSize(maxWidth));
|
|
360
478
|
} else {
|
|
361
479
|
return this._ctx.strokeText(text2, this._doSize(x2), this._doSize(y2));
|
|
362
480
|
}
|
|
363
|
-
}
|
|
364
|
-
setFont(opts) {
|
|
365
|
-
|
|
481
|
+
};
|
|
482
|
+
Context2.prototype.setFont = function(opts) {
|
|
483
|
+
var strList = [];
|
|
366
484
|
if (opts.fontWeight === "bold") {
|
|
367
|
-
strList.push(
|
|
485
|
+
strList.push("".concat(opts.fontWeight));
|
|
368
486
|
}
|
|
369
|
-
strList.push(
|
|
370
|
-
strList.push(
|
|
371
|
-
this._ctx.font =
|
|
372
|
-
}
|
|
373
|
-
setTextBaseline(baseline) {
|
|
487
|
+
strList.push("".concat(this._doSize(opts.fontSize || 12), "px"));
|
|
488
|
+
strList.push("".concat(opts.fontFamily || "sans-serif"));
|
|
489
|
+
this._ctx.font = "".concat(strList.join(" "));
|
|
490
|
+
};
|
|
491
|
+
Context2.prototype.setTextBaseline = function(baseline) {
|
|
374
492
|
this._ctx.textBaseline = baseline;
|
|
375
|
-
}
|
|
376
|
-
setGlobalAlpha(alpha) {
|
|
493
|
+
};
|
|
494
|
+
Context2.prototype.setGlobalAlpha = function(alpha) {
|
|
377
495
|
this._ctx.globalAlpha = alpha;
|
|
378
|
-
}
|
|
379
|
-
save() {
|
|
496
|
+
};
|
|
497
|
+
Context2.prototype.save = function() {
|
|
380
498
|
this._ctx.save();
|
|
381
|
-
}
|
|
382
|
-
restore() {
|
|
499
|
+
};
|
|
500
|
+
Context2.prototype.restore = function() {
|
|
383
501
|
this._ctx.restore();
|
|
384
|
-
}
|
|
385
|
-
scale(ratioX, ratioY) {
|
|
502
|
+
};
|
|
503
|
+
Context2.prototype.scale = function(ratioX, ratioY) {
|
|
386
504
|
this._ctx.scale(ratioX, ratioY);
|
|
387
|
-
}
|
|
388
|
-
setShadowColor(color2) {
|
|
505
|
+
};
|
|
506
|
+
Context2.prototype.setShadowColor = function(color2) {
|
|
389
507
|
this._ctx.shadowColor = color2;
|
|
390
|
-
}
|
|
391
|
-
setShadowOffsetX(offsetX) {
|
|
508
|
+
};
|
|
509
|
+
Context2.prototype.setShadowOffsetX = function(offsetX) {
|
|
392
510
|
this._ctx.shadowOffsetX = this._doSize(offsetX);
|
|
393
|
-
}
|
|
394
|
-
setShadowOffsetY(offsetY) {
|
|
511
|
+
};
|
|
512
|
+
Context2.prototype.setShadowOffsetY = function(offsetY) {
|
|
395
513
|
this._ctx.shadowOffsetY = this._doSize(offsetY);
|
|
396
|
-
}
|
|
397
|
-
setShadowBlur(blur) {
|
|
514
|
+
};
|
|
515
|
+
Context2.prototype.setShadowBlur = function(blur) {
|
|
398
516
|
this._ctx.shadowBlur = this._doSize(blur);
|
|
399
|
-
}
|
|
400
|
-
ellipse(x2, y2, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
|
|
517
|
+
};
|
|
518
|
+
Context2.prototype.ellipse = function(x2, y2, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
|
|
401
519
|
this._ctx.ellipse(this._doSize(x2), this._doSize(y2), this._doSize(radiusX), this._doSize(radiusY), rotation, startAngle, endAngle, counterclockwise);
|
|
402
|
-
}
|
|
403
|
-
_doSize(num) {
|
|
520
|
+
};
|
|
521
|
+
Context2.prototype._doSize = function(num) {
|
|
404
522
|
return this._opts.devicePixelRatio * num;
|
|
405
|
-
}
|
|
406
|
-
_doX(x2) {
|
|
407
|
-
|
|
408
|
-
|
|
523
|
+
};
|
|
524
|
+
Context2.prototype._doX = function(x2) {
|
|
525
|
+
var _a2 = this._transform, scale = _a2.scale, scrollX = _a2.scrollX;
|
|
526
|
+
var _x = (x2 - scrollX) / scale;
|
|
409
527
|
return this._doSize(_x);
|
|
410
|
-
}
|
|
411
|
-
_doY(y2) {
|
|
412
|
-
|
|
413
|
-
|
|
528
|
+
};
|
|
529
|
+
Context2.prototype._doY = function(y2) {
|
|
530
|
+
var _a2 = this._transform, scale = _a2.scale, scrollY = _a2.scrollY;
|
|
531
|
+
var _y = (y2 - scrollY) / scale;
|
|
414
532
|
return this._doSize(_y);
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
|
|
533
|
+
};
|
|
534
|
+
return Context2;
|
|
535
|
+
}();
|
|
536
|
+
function number$2(value) {
|
|
418
537
|
return typeof value === "number" && (value > 0 || value <= 0);
|
|
419
538
|
}
|
|
420
|
-
function x$
|
|
421
|
-
return number$
|
|
539
|
+
function x$2(value) {
|
|
540
|
+
return number$2(value);
|
|
422
541
|
}
|
|
423
|
-
function y$
|
|
424
|
-
return number$
|
|
542
|
+
function y$2(value) {
|
|
543
|
+
return number$2(value);
|
|
425
544
|
}
|
|
426
|
-
function w$
|
|
545
|
+
function w$2(value) {
|
|
427
546
|
return typeof value === "number" && value >= 0;
|
|
428
547
|
}
|
|
429
|
-
function h$
|
|
548
|
+
function h$2(value) {
|
|
430
549
|
return typeof value === "number" && value >= 0;
|
|
431
550
|
}
|
|
432
|
-
function angle$
|
|
551
|
+
function angle$2(value) {
|
|
433
552
|
return typeof value === "number" && value >= -360 && value <= 360;
|
|
434
553
|
}
|
|
435
|
-
function borderWidth$
|
|
436
|
-
return w$
|
|
554
|
+
function borderWidth$2(value) {
|
|
555
|
+
return w$2(value);
|
|
437
556
|
}
|
|
438
|
-
function borderRadius$
|
|
439
|
-
return number$
|
|
557
|
+
function borderRadius$2(value) {
|
|
558
|
+
return number$2(value) && value >= 0;
|
|
440
559
|
}
|
|
441
|
-
function color$
|
|
442
|
-
return isColorStr(value);
|
|
560
|
+
function color$2(value) {
|
|
561
|
+
return isColorStr$2(value);
|
|
443
562
|
}
|
|
444
|
-
function imageURL$
|
|
445
|
-
return typeof value === "string" && /^(http:\/\/|https:\/\/|\.\/|\/)/.test(
|
|
563
|
+
function imageURL$2(value) {
|
|
564
|
+
return typeof value === "string" && /^(http:\/\/|https:\/\/|\.\/|\/)/.test("".concat(value));
|
|
446
565
|
}
|
|
447
|
-
function imageBase64$
|
|
448
|
-
return typeof value === "string" && /^(data:image\/)/.test(
|
|
566
|
+
function imageBase64$2(value) {
|
|
567
|
+
return typeof value === "string" && /^(data:image\/)/.test("".concat(value));
|
|
449
568
|
}
|
|
450
|
-
function imageSrc$
|
|
451
|
-
return imageBase64$
|
|
569
|
+
function imageSrc$2(value) {
|
|
570
|
+
return imageBase64$2(value) || imageURL$2(value);
|
|
452
571
|
}
|
|
453
|
-
function svg$
|
|
454
|
-
return typeof value === "string" && /^(<svg[\s]{1,}|<svg>)/i.test(
|
|
572
|
+
function svg$2(value) {
|
|
573
|
+
return typeof value === "string" && /^(<svg[\s]{1,}|<svg>)/i.test("".concat(value).trim()) && /<\/[\s]{0,}svg>$/i.test("".concat(value).trim());
|
|
455
574
|
}
|
|
456
|
-
function html$
|
|
457
|
-
|
|
575
|
+
function html$2(value) {
|
|
576
|
+
var result = false;
|
|
458
577
|
if (typeof value === "string") {
|
|
459
|
-
|
|
578
|
+
var div = document.createElement("div");
|
|
460
579
|
div.innerHTML = value;
|
|
461
580
|
if (div.children.length > 0) {
|
|
462
581
|
result = true;
|
|
@@ -465,53 +584,53 @@ var iDrawCore = function() {
|
|
|
465
584
|
}
|
|
466
585
|
return result;
|
|
467
586
|
}
|
|
468
|
-
function text$
|
|
587
|
+
function text$2(value) {
|
|
469
588
|
return typeof value === "string";
|
|
470
589
|
}
|
|
471
|
-
function fontSize$
|
|
472
|
-
return number$
|
|
590
|
+
function fontSize$2(value) {
|
|
591
|
+
return number$2(value) && value > 0;
|
|
473
592
|
}
|
|
474
|
-
function lineHeight$
|
|
475
|
-
return number$
|
|
593
|
+
function lineHeight$2(value) {
|
|
594
|
+
return number$2(value) && value > 0;
|
|
476
595
|
}
|
|
477
|
-
function strokeWidth$
|
|
478
|
-
return number$
|
|
596
|
+
function strokeWidth$2(value) {
|
|
597
|
+
return number$2(value) && value > 0;
|
|
479
598
|
}
|
|
480
|
-
function textAlign$
|
|
599
|
+
function textAlign$2(value) {
|
|
481
600
|
return ["center", "left", "right"].includes(value);
|
|
482
601
|
}
|
|
483
|
-
function fontFamily$
|
|
602
|
+
function fontFamily$2(value) {
|
|
484
603
|
return typeof value === "string" && value.length > 0;
|
|
485
604
|
}
|
|
486
|
-
function fontWeight$
|
|
605
|
+
function fontWeight$2(value) {
|
|
487
606
|
return ["bold"].includes(value);
|
|
488
607
|
}
|
|
489
|
-
|
|
490
|
-
x: x$
|
|
491
|
-
y: y$
|
|
492
|
-
w: w$
|
|
493
|
-
h: h$
|
|
494
|
-
angle: angle$
|
|
495
|
-
number: number$
|
|
496
|
-
borderWidth: borderWidth$
|
|
497
|
-
borderRadius: borderRadius$
|
|
498
|
-
color: color$
|
|
499
|
-
imageSrc: imageSrc$
|
|
500
|
-
imageURL: imageURL$
|
|
501
|
-
imageBase64: imageBase64$
|
|
502
|
-
svg: svg$
|
|
503
|
-
html: html$
|
|
504
|
-
text: text$
|
|
505
|
-
fontSize: fontSize$
|
|
506
|
-
lineHeight: lineHeight$
|
|
507
|
-
textAlign: textAlign$
|
|
508
|
-
fontFamily: fontFamily$
|
|
509
|
-
fontWeight: fontWeight$
|
|
510
|
-
strokeWidth: strokeWidth$
|
|
608
|
+
var is$3 = {
|
|
609
|
+
x: x$2,
|
|
610
|
+
y: y$2,
|
|
611
|
+
w: w$2,
|
|
612
|
+
h: h$2,
|
|
613
|
+
angle: angle$2,
|
|
614
|
+
number: number$2,
|
|
615
|
+
borderWidth: borderWidth$2,
|
|
616
|
+
borderRadius: borderRadius$2,
|
|
617
|
+
color: color$2,
|
|
618
|
+
imageSrc: imageSrc$2,
|
|
619
|
+
imageURL: imageURL$2,
|
|
620
|
+
imageBase64: imageBase64$2,
|
|
621
|
+
svg: svg$2,
|
|
622
|
+
html: html$2,
|
|
623
|
+
text: text$2,
|
|
624
|
+
fontSize: fontSize$2,
|
|
625
|
+
lineHeight: lineHeight$2,
|
|
626
|
+
textAlign: textAlign$2,
|
|
627
|
+
fontFamily: fontFamily$2,
|
|
628
|
+
fontWeight: fontWeight$2,
|
|
629
|
+
strokeWidth: strokeWidth$2
|
|
511
630
|
};
|
|
512
631
|
function attrs$1(attrs2) {
|
|
513
|
-
|
|
514
|
-
if (!(is$
|
|
632
|
+
var x2 = attrs2.x, y2 = attrs2.y, w2 = attrs2.w, h2 = attrs2.h, angle2 = attrs2.angle;
|
|
633
|
+
if (!(is$3.x(x2) && is$3.y(y2) && is$3.w(w2) && is$3.h(h2) && is$3.angle(angle2))) {
|
|
515
634
|
return false;
|
|
516
635
|
}
|
|
517
636
|
if (!(angle2 >= -360 && angle2 <= 360)) {
|
|
@@ -519,22 +638,25 @@ var iDrawCore = function() {
|
|
|
519
638
|
}
|
|
520
639
|
return true;
|
|
521
640
|
}
|
|
522
|
-
function box$1(desc
|
|
523
|
-
|
|
524
|
-
|
|
641
|
+
function box$1(desc) {
|
|
642
|
+
if (desc === void 0) {
|
|
643
|
+
desc = {};
|
|
644
|
+
}
|
|
645
|
+
var borderColor = desc.borderColor, borderRadius2 = desc.borderRadius, borderWidth2 = desc.borderWidth;
|
|
646
|
+
if (desc.hasOwnProperty("borderColor") && !is$3.color(borderColor)) {
|
|
525
647
|
return false;
|
|
526
648
|
}
|
|
527
|
-
if (desc.hasOwnProperty("borderRadius") && !is$
|
|
649
|
+
if (desc.hasOwnProperty("borderRadius") && !is$3.number(borderRadius2)) {
|
|
528
650
|
return false;
|
|
529
651
|
}
|
|
530
|
-
if (desc.hasOwnProperty("borderWidth") && !is$
|
|
652
|
+
if (desc.hasOwnProperty("borderWidth") && !is$3.number(borderWidth2)) {
|
|
531
653
|
return false;
|
|
532
654
|
}
|
|
533
655
|
return true;
|
|
534
656
|
}
|
|
535
657
|
function rectDesc$1(desc) {
|
|
536
|
-
|
|
537
|
-
if (desc.hasOwnProperty("bgColor") && !is$
|
|
658
|
+
var bgColor = desc.bgColor;
|
|
659
|
+
if (desc.hasOwnProperty("bgColor") && !is$3.color(bgColor)) {
|
|
538
660
|
return false;
|
|
539
661
|
}
|
|
540
662
|
if (!box$1(desc)) {
|
|
@@ -543,69 +665,69 @@ var iDrawCore = function() {
|
|
|
543
665
|
return true;
|
|
544
666
|
}
|
|
545
667
|
function circleDesc$1(desc) {
|
|
546
|
-
|
|
547
|
-
if (desc.hasOwnProperty("bgColor") && !is$
|
|
668
|
+
var bgColor = desc.bgColor, borderColor = desc.borderColor, borderWidth2 = desc.borderWidth;
|
|
669
|
+
if (desc.hasOwnProperty("bgColor") && !is$3.color(bgColor)) {
|
|
548
670
|
return false;
|
|
549
671
|
}
|
|
550
|
-
if (desc.hasOwnProperty("borderColor") && !is$
|
|
672
|
+
if (desc.hasOwnProperty("borderColor") && !is$3.color(borderColor)) {
|
|
551
673
|
return false;
|
|
552
674
|
}
|
|
553
|
-
if (desc.hasOwnProperty("borderWidth") && !is$
|
|
675
|
+
if (desc.hasOwnProperty("borderWidth") && !is$3.number(borderWidth2)) {
|
|
554
676
|
return false;
|
|
555
677
|
}
|
|
556
678
|
return true;
|
|
557
679
|
}
|
|
558
680
|
function imageDesc$1(desc) {
|
|
559
|
-
|
|
560
|
-
if (!is$
|
|
681
|
+
var src = desc.src;
|
|
682
|
+
if (!is$3.imageSrc(src)) {
|
|
561
683
|
return false;
|
|
562
684
|
}
|
|
563
685
|
return true;
|
|
564
686
|
}
|
|
565
687
|
function svgDesc$1(desc) {
|
|
566
|
-
|
|
567
|
-
if (!is$
|
|
688
|
+
var svg2 = desc.svg;
|
|
689
|
+
if (!is$3.svg(svg2)) {
|
|
568
690
|
return false;
|
|
569
691
|
}
|
|
570
692
|
return true;
|
|
571
693
|
}
|
|
572
694
|
function htmlDesc$1(desc) {
|
|
573
|
-
|
|
574
|
-
if (!is$
|
|
695
|
+
var html2 = desc.html;
|
|
696
|
+
if (!is$3.html(html2)) {
|
|
575
697
|
return false;
|
|
576
698
|
}
|
|
577
699
|
return true;
|
|
578
700
|
}
|
|
579
701
|
function textDesc$1(desc) {
|
|
580
|
-
|
|
581
|
-
if (!is$
|
|
702
|
+
var text2 = desc.text, color2 = desc.color, fontSize2 = desc.fontSize, lineHeight2 = desc.lineHeight, fontFamily2 = desc.fontFamily, textAlign2 = desc.textAlign, fontWeight2 = desc.fontWeight, bgColor = desc.bgColor, strokeWidth2 = desc.strokeWidth, strokeColor = desc.strokeColor;
|
|
703
|
+
if (!is$3.text(text2)) {
|
|
582
704
|
return false;
|
|
583
705
|
}
|
|
584
|
-
if (!is$
|
|
706
|
+
if (!is$3.color(color2)) {
|
|
585
707
|
return false;
|
|
586
708
|
}
|
|
587
|
-
if (!is$
|
|
709
|
+
if (!is$3.fontSize(fontSize2)) {
|
|
588
710
|
return false;
|
|
589
711
|
}
|
|
590
|
-
if (desc.hasOwnProperty("bgColor") && !is$
|
|
712
|
+
if (desc.hasOwnProperty("bgColor") && !is$3.color(bgColor)) {
|
|
591
713
|
return false;
|
|
592
714
|
}
|
|
593
|
-
if (desc.hasOwnProperty("fontWeight") && !is$
|
|
715
|
+
if (desc.hasOwnProperty("fontWeight") && !is$3.fontWeight(fontWeight2)) {
|
|
594
716
|
return false;
|
|
595
717
|
}
|
|
596
|
-
if (desc.hasOwnProperty("lineHeight") && !is$
|
|
718
|
+
if (desc.hasOwnProperty("lineHeight") && !is$3.lineHeight(lineHeight2)) {
|
|
597
719
|
return false;
|
|
598
720
|
}
|
|
599
|
-
if (desc.hasOwnProperty("fontFamily") && !is$
|
|
721
|
+
if (desc.hasOwnProperty("fontFamily") && !is$3.fontFamily(fontFamily2)) {
|
|
600
722
|
return false;
|
|
601
723
|
}
|
|
602
|
-
if (desc.hasOwnProperty("textAlign") && !is$
|
|
724
|
+
if (desc.hasOwnProperty("textAlign") && !is$3.textAlign(textAlign2)) {
|
|
603
725
|
return false;
|
|
604
726
|
}
|
|
605
|
-
if (desc.hasOwnProperty("strokeWidth") && !is$
|
|
727
|
+
if (desc.hasOwnProperty("strokeWidth") && !is$3.strokeWidth(strokeWidth2)) {
|
|
606
728
|
return false;
|
|
607
729
|
}
|
|
608
|
-
if (desc.hasOwnProperty("strokeColor") && !is$
|
|
730
|
+
if (desc.hasOwnProperty("strokeColor") && !is$3.color(strokeColor)) {
|
|
609
731
|
return false;
|
|
610
732
|
}
|
|
611
733
|
if (!box$1(desc)) {
|
|
@@ -613,7 +735,7 @@ var iDrawCore = function() {
|
|
|
613
735
|
}
|
|
614
736
|
return true;
|
|
615
737
|
}
|
|
616
|
-
|
|
738
|
+
var check$1 = {
|
|
617
739
|
attrs: attrs$1,
|
|
618
740
|
textDesc: textDesc$1,
|
|
619
741
|
rectDesc: rectDesc$1,
|
|
@@ -622,42 +744,43 @@ var iDrawCore = function() {
|
|
|
622
744
|
svgDesc: svgDesc$1,
|
|
623
745
|
htmlDesc: htmlDesc$1
|
|
624
746
|
};
|
|
625
|
-
|
|
626
|
-
|
|
747
|
+
var default_1$1 = Object.freeze({
|
|
748
|
+
__proto__: null,
|
|
749
|
+
is: is$3,
|
|
627
750
|
check: check$1,
|
|
628
751
|
delay,
|
|
629
752
|
compose,
|
|
630
753
|
throttle: throttle$1,
|
|
631
|
-
loadImage,
|
|
632
|
-
loadSVG,
|
|
633
|
-
loadHTML,
|
|
754
|
+
loadImage: loadImage$1,
|
|
755
|
+
loadSVG: loadSVG$1,
|
|
756
|
+
loadHTML: loadHTML$1,
|
|
634
757
|
downloadImageFromCanvas,
|
|
635
758
|
toColorHexStr,
|
|
636
759
|
toColorHexNum,
|
|
637
|
-
isColorStr,
|
|
638
|
-
createUUID,
|
|
639
|
-
istype,
|
|
640
|
-
deepClone,
|
|
760
|
+
isColorStr: isColorStr$2,
|
|
761
|
+
createUUID: createUUID$2,
|
|
762
|
+
istype: istype$1,
|
|
763
|
+
deepClone: deepClone$2,
|
|
641
764
|
Context: Context$1
|
|
642
|
-
};
|
|
643
|
-
|
|
644
|
-
|
|
765
|
+
});
|
|
766
|
+
var BoardEvent = function() {
|
|
767
|
+
function BoardEvent2() {
|
|
645
768
|
this._listeners = /* @__PURE__ */ new Map();
|
|
646
769
|
}
|
|
647
|
-
on(eventKey, callback) {
|
|
770
|
+
BoardEvent2.prototype.on = function(eventKey, callback) {
|
|
648
771
|
if (this._listeners.has(eventKey)) {
|
|
649
|
-
|
|
772
|
+
var callbacks = this._listeners.get(eventKey);
|
|
650
773
|
callbacks === null || callbacks === void 0 ? void 0 : callbacks.push(callback);
|
|
651
774
|
this._listeners.set(eventKey, callbacks || []);
|
|
652
775
|
} else {
|
|
653
776
|
this._listeners.set(eventKey, [callback]);
|
|
654
777
|
}
|
|
655
|
-
}
|
|
656
|
-
off(eventKey, callback) {
|
|
778
|
+
};
|
|
779
|
+
BoardEvent2.prototype.off = function(eventKey, callback) {
|
|
657
780
|
if (this._listeners.has(eventKey)) {
|
|
658
|
-
|
|
781
|
+
var callbacks = this._listeners.get(eventKey);
|
|
659
782
|
if (Array.isArray(callbacks)) {
|
|
660
|
-
for (
|
|
783
|
+
for (var i = 0; i < (callbacks === null || callbacks === void 0 ? void 0 : callbacks.length); i++) {
|
|
661
784
|
if (callbacks[i] === callback) {
|
|
662
785
|
callbacks.splice(i, 1);
|
|
663
786
|
break;
|
|
@@ -666,28 +789,29 @@ var iDrawCore = function() {
|
|
|
666
789
|
}
|
|
667
790
|
this._listeners.set(eventKey, callbacks || []);
|
|
668
791
|
}
|
|
669
|
-
}
|
|
670
|
-
trigger(eventKey, arg) {
|
|
671
|
-
|
|
792
|
+
};
|
|
793
|
+
BoardEvent2.prototype.trigger = function(eventKey, arg) {
|
|
794
|
+
var callbacks = this._listeners.get(eventKey);
|
|
672
795
|
if (Array.isArray(callbacks)) {
|
|
673
|
-
callbacks.forEach((cb)
|
|
796
|
+
callbacks.forEach(function(cb) {
|
|
674
797
|
cb(arg);
|
|
675
798
|
});
|
|
676
799
|
return true;
|
|
677
800
|
} else {
|
|
678
801
|
return false;
|
|
679
802
|
}
|
|
680
|
-
}
|
|
681
|
-
has(name) {
|
|
803
|
+
};
|
|
804
|
+
BoardEvent2.prototype.has = function(name) {
|
|
682
805
|
if (this._listeners.has(name)) {
|
|
683
|
-
|
|
806
|
+
var list = this._listeners.get(name);
|
|
684
807
|
if (Array.isArray(list) && list.length > 0) {
|
|
685
808
|
return true;
|
|
686
809
|
}
|
|
687
810
|
}
|
|
688
811
|
return false;
|
|
689
|
-
}
|
|
690
|
-
|
|
812
|
+
};
|
|
813
|
+
return BoardEvent2;
|
|
814
|
+
}();
|
|
691
815
|
function createTempData() {
|
|
692
816
|
return {
|
|
693
817
|
prevClickPoint: null,
|
|
@@ -701,22 +825,23 @@ var iDrawCore = function() {
|
|
|
701
825
|
}
|
|
702
826
|
};
|
|
703
827
|
}
|
|
704
|
-
|
|
705
|
-
|
|
828
|
+
var TempData$2 = function() {
|
|
829
|
+
function TempData2() {
|
|
706
830
|
this._temp = createTempData();
|
|
707
831
|
}
|
|
708
|
-
set(name, value) {
|
|
832
|
+
TempData2.prototype.set = function(name, value) {
|
|
709
833
|
this._temp[name] = value;
|
|
710
|
-
}
|
|
711
|
-
get(name) {
|
|
834
|
+
};
|
|
835
|
+
TempData2.prototype.get = function(name) {
|
|
712
836
|
return this._temp[name];
|
|
713
|
-
}
|
|
714
|
-
clear() {
|
|
837
|
+
};
|
|
838
|
+
TempData2.prototype.clear = function() {
|
|
715
839
|
this._temp = createTempData();
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
840
|
+
};
|
|
841
|
+
return TempData2;
|
|
842
|
+
}();
|
|
843
|
+
var ScreenWatcher = function() {
|
|
844
|
+
function ScreenWatcher2(canvas, ctx) {
|
|
720
845
|
this._isMoving = false;
|
|
721
846
|
this._temp = new TempData$2();
|
|
722
847
|
this._container = window;
|
|
@@ -725,18 +850,18 @@ var iDrawCore = function() {
|
|
|
725
850
|
this._initEvent();
|
|
726
851
|
this._event = new BoardEvent();
|
|
727
852
|
}
|
|
728
|
-
setStatusMap(statusMap) {
|
|
853
|
+
ScreenWatcher2.prototype.setStatusMap = function(statusMap) {
|
|
729
854
|
this._temp.set("statusMap", statusMap);
|
|
730
|
-
}
|
|
731
|
-
on(name, callback) {
|
|
855
|
+
};
|
|
856
|
+
ScreenWatcher2.prototype.on = function(name, callback) {
|
|
732
857
|
this._event.on(name, callback);
|
|
733
|
-
}
|
|
734
|
-
off(name, callback) {
|
|
858
|
+
};
|
|
859
|
+
ScreenWatcher2.prototype.off = function(name, callback) {
|
|
735
860
|
this._event.off(name, callback);
|
|
736
|
-
}
|
|
737
|
-
_initEvent() {
|
|
738
|
-
|
|
739
|
-
|
|
861
|
+
};
|
|
862
|
+
ScreenWatcher2.prototype._initEvent = function() {
|
|
863
|
+
var canvas = this._canvas;
|
|
864
|
+
var container = this._container;
|
|
740
865
|
container.addEventListener("mousemove", this._listenWindowMove.bind(this), false);
|
|
741
866
|
container.addEventListener("mouseup", this._listenWindowMoveEnd.bind(this), false);
|
|
742
867
|
canvas.addEventListener("mousemove", this._listenHover.bind(this), false);
|
|
@@ -750,11 +875,11 @@ var iDrawCore = function() {
|
|
|
750
875
|
canvas.addEventListener("mouseover", this._listenCanvasMoveOver.bind(this), true);
|
|
751
876
|
canvas.addEventListener("mouseleave", this._listenCanvasMoveLeave.bind(this), true);
|
|
752
877
|
this._initParentEvent();
|
|
753
|
-
}
|
|
754
|
-
_initParentEvent() {
|
|
878
|
+
};
|
|
879
|
+
ScreenWatcher2.prototype._initParentEvent = function() {
|
|
755
880
|
try {
|
|
756
|
-
|
|
757
|
-
|
|
881
|
+
var target = window;
|
|
882
|
+
var targetOrigin = target.origin;
|
|
758
883
|
while (target.self !== target.top) {
|
|
759
884
|
if (target.self !== target.parent) {
|
|
760
885
|
if (target.origin === targetOrigin) {
|
|
@@ -769,20 +894,20 @@ var iDrawCore = function() {
|
|
|
769
894
|
} catch (err) {
|
|
770
895
|
console.warn(err);
|
|
771
896
|
}
|
|
772
|
-
}
|
|
773
|
-
_listenHover(e) {
|
|
897
|
+
};
|
|
898
|
+
ScreenWatcher2.prototype._listenHover = function(e) {
|
|
774
899
|
e.preventDefault();
|
|
775
|
-
|
|
900
|
+
var p = this._getPosition(e);
|
|
776
901
|
if (this._isVaildPoint(p)) {
|
|
777
902
|
if (this._event.has("hover")) {
|
|
778
903
|
this._event.trigger("hover", p);
|
|
779
904
|
}
|
|
780
905
|
}
|
|
781
906
|
this._isMoving = true;
|
|
782
|
-
}
|
|
783
|
-
_listenMoveStart(e) {
|
|
907
|
+
};
|
|
908
|
+
ScreenWatcher2.prototype._listenMoveStart = function(e) {
|
|
784
909
|
e.preventDefault();
|
|
785
|
-
|
|
910
|
+
var p = this._getPosition(e);
|
|
786
911
|
if (this._isVaildPoint(p)) {
|
|
787
912
|
if (this._event.has("point")) {
|
|
788
913
|
this._event.trigger("point", p);
|
|
@@ -792,28 +917,28 @@ var iDrawCore = function() {
|
|
|
792
917
|
}
|
|
793
918
|
}
|
|
794
919
|
this._isMoving = true;
|
|
795
|
-
}
|
|
796
|
-
_listenMove(e) {
|
|
920
|
+
};
|
|
921
|
+
ScreenWatcher2.prototype._listenMove = function(e) {
|
|
797
922
|
e.preventDefault();
|
|
798
923
|
e.stopPropagation();
|
|
799
924
|
if (this._event.has("move") && this._isMoving === true) {
|
|
800
|
-
|
|
925
|
+
var p = this._getPosition(e);
|
|
801
926
|
if (this._isVaildPoint(p)) {
|
|
802
927
|
this._event.trigger("move", p);
|
|
803
928
|
}
|
|
804
929
|
}
|
|
805
|
-
}
|
|
806
|
-
_listenMoveEnd(e) {
|
|
930
|
+
};
|
|
931
|
+
ScreenWatcher2.prototype._listenMoveEnd = function(e) {
|
|
807
932
|
e.preventDefault();
|
|
808
933
|
if (this._event.has("moveEnd")) {
|
|
809
|
-
|
|
934
|
+
var p = this._getPosition(e);
|
|
810
935
|
if (this._isVaildPoint(p)) {
|
|
811
936
|
this._event.trigger("moveEnd", p);
|
|
812
937
|
}
|
|
813
938
|
}
|
|
814
939
|
this._isMoving = false;
|
|
815
|
-
}
|
|
816
|
-
_listSameOriginParentWindow() {
|
|
940
|
+
};
|
|
941
|
+
ScreenWatcher2.prototype._listSameOriginParentWindow = function() {
|
|
817
942
|
if (this._temp.get("isHoverCanvas")) {
|
|
818
943
|
if (this._event.has("leave")) {
|
|
819
944
|
this._event.trigger("leave", void 0);
|
|
@@ -827,59 +952,59 @@ var iDrawCore = function() {
|
|
|
827
952
|
this._isMoving = false;
|
|
828
953
|
this._temp.set("isDragCanvas", false);
|
|
829
954
|
this._temp.set("isHoverCanvas", false);
|
|
830
|
-
}
|
|
831
|
-
_listenCanvasMoveStart() {
|
|
955
|
+
};
|
|
956
|
+
ScreenWatcher2.prototype._listenCanvasMoveStart = function() {
|
|
832
957
|
if (this._temp.get("isHoverCanvas")) {
|
|
833
958
|
this._temp.set("isDragCanvas", true);
|
|
834
959
|
}
|
|
835
|
-
}
|
|
836
|
-
_listenCanvasMoveEnd() {
|
|
960
|
+
};
|
|
961
|
+
ScreenWatcher2.prototype._listenCanvasMoveEnd = function() {
|
|
837
962
|
this._temp.set("isDragCanvas", false);
|
|
838
|
-
}
|
|
839
|
-
_listenCanvasMoveOver() {
|
|
963
|
+
};
|
|
964
|
+
ScreenWatcher2.prototype._listenCanvasMoveOver = function() {
|
|
840
965
|
this._temp.set("isHoverCanvas", true);
|
|
841
|
-
}
|
|
842
|
-
_listenCanvasMoveLeave() {
|
|
966
|
+
};
|
|
967
|
+
ScreenWatcher2.prototype._listenCanvasMoveLeave = function() {
|
|
843
968
|
this._temp.set("isHoverCanvas", false);
|
|
844
969
|
if (this._event.has("leave")) {
|
|
845
970
|
this._event.trigger("leave", void 0);
|
|
846
971
|
}
|
|
847
|
-
}
|
|
848
|
-
_listenWindowMove(e) {
|
|
972
|
+
};
|
|
973
|
+
ScreenWatcher2.prototype._listenWindowMove = function(e) {
|
|
849
974
|
if (this._temp.get("isDragCanvas") !== true) {
|
|
850
975
|
return;
|
|
851
976
|
}
|
|
852
977
|
e.preventDefault();
|
|
853
978
|
e.stopPropagation();
|
|
854
979
|
if (this._event.has("move") && this._isMoving === true) {
|
|
855
|
-
|
|
980
|
+
var p = this._getPosition(e);
|
|
856
981
|
if (this._isVaildPoint(p)) {
|
|
857
982
|
this._event.trigger("move", p);
|
|
858
983
|
}
|
|
859
984
|
}
|
|
860
|
-
}
|
|
861
|
-
_listenWindowMoveEnd(e) {
|
|
985
|
+
};
|
|
986
|
+
ScreenWatcher2.prototype._listenWindowMoveEnd = function(e) {
|
|
862
987
|
if (!this._temp.get("isDragCanvas") === true) {
|
|
863
988
|
return;
|
|
864
989
|
}
|
|
865
990
|
e.preventDefault();
|
|
866
991
|
if (this._event.has("moveEnd")) {
|
|
867
|
-
|
|
992
|
+
var p = this._getPosition(e);
|
|
868
993
|
if (this._isVaildPoint(p)) {
|
|
869
994
|
this._event.trigger("moveEnd", p);
|
|
870
995
|
}
|
|
871
996
|
}
|
|
872
997
|
this._temp.set("isDragCanvas", false);
|
|
873
998
|
this._isMoving = false;
|
|
874
|
-
}
|
|
875
|
-
_listenCanvasWheel(e) {
|
|
999
|
+
};
|
|
1000
|
+
ScreenWatcher2.prototype._listenCanvasWheel = function(e) {
|
|
876
1001
|
if (this._event.has("wheelX") && (e.deltaX > 0 || e.deltaX < 0)) {
|
|
877
1002
|
this._event.trigger("wheelX", e.deltaX);
|
|
878
1003
|
}
|
|
879
1004
|
if (this._event.has("wheelY") && (e.deltaY > 0 || e.deltaY < 0)) {
|
|
880
1005
|
this._event.trigger("wheelY", e.deltaY);
|
|
881
1006
|
}
|
|
882
|
-
|
|
1007
|
+
var _a2 = this._temp.get("statusMap"), canScrollYNext = _a2.canScrollYNext, canScrollYPrev = _a2.canScrollYPrev;
|
|
883
1008
|
if (e.deltaX > 0 && e.deltaX < 0) {
|
|
884
1009
|
e.preventDefault();
|
|
885
1010
|
} else if (e.deltaY > 0 && canScrollYNext === true) {
|
|
@@ -887,14 +1012,14 @@ var iDrawCore = function() {
|
|
|
887
1012
|
} else if (e.deltaY < 0 && canScrollYPrev === true) {
|
|
888
1013
|
e.preventDefault();
|
|
889
1014
|
}
|
|
890
|
-
}
|
|
891
|
-
_listenCanvasClick(e) {
|
|
1015
|
+
};
|
|
1016
|
+
ScreenWatcher2.prototype._listenCanvasClick = function(e) {
|
|
892
1017
|
e.preventDefault();
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
1018
|
+
var maxLimitTime = 500;
|
|
1019
|
+
var p = this._getPosition(e);
|
|
1020
|
+
var t = Date.now();
|
|
896
1021
|
if (this._isVaildPoint(p)) {
|
|
897
|
-
|
|
1022
|
+
var preClickPoint = this._temp.get("prevClickPoint");
|
|
898
1023
|
if (preClickPoint && t - preClickPoint.t <= maxLimitTime && Math.abs(preClickPoint.x - p.x) <= 5 && Math.abs(preClickPoint.y - p.y) <= 5) {
|
|
899
1024
|
if (this._event.has("doubleClick")) {
|
|
900
1025
|
this._event.trigger("doubleClick", { x: p.x, y: p.y });
|
|
@@ -903,13 +1028,13 @@ var iDrawCore = function() {
|
|
|
903
1028
|
this._temp.set("prevClickPoint", { x: p.x, y: p.y, t });
|
|
904
1029
|
}
|
|
905
1030
|
}
|
|
906
|
-
}
|
|
907
|
-
_getPosition(e) {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
1031
|
+
};
|
|
1032
|
+
ScreenWatcher2.prototype._getPosition = function(e) {
|
|
1033
|
+
var canvas = this._canvas;
|
|
1034
|
+
var x2 = 0;
|
|
1035
|
+
var y2 = 0;
|
|
911
1036
|
if (e && e.touches && e.touches.length > 0) {
|
|
912
|
-
|
|
1037
|
+
var touch = e.touches[0];
|
|
913
1038
|
if (touch) {
|
|
914
1039
|
x2 = touch.clientX;
|
|
915
1040
|
y2 = touch.clientY;
|
|
@@ -918,67 +1043,62 @@ var iDrawCore = function() {
|
|
|
918
1043
|
x2 = e.clientX;
|
|
919
1044
|
y2 = e.clientY;
|
|
920
1045
|
}
|
|
921
|
-
|
|
1046
|
+
var p = {
|
|
922
1047
|
x: x2 - canvas.getBoundingClientRect().left,
|
|
923
1048
|
y: y2 - canvas.getBoundingClientRect().top,
|
|
924
1049
|
t: Date.now()
|
|
925
1050
|
};
|
|
926
1051
|
return p;
|
|
927
|
-
}
|
|
928
|
-
_isVaildPoint(p) {
|
|
1052
|
+
};
|
|
1053
|
+
ScreenWatcher2.prototype._isVaildPoint = function(p) {
|
|
929
1054
|
return isAvailableNum(p.x) && isAvailableNum(p.y);
|
|
930
|
-
}
|
|
931
|
-
|
|
1055
|
+
};
|
|
1056
|
+
return ScreenWatcher2;
|
|
1057
|
+
}();
|
|
932
1058
|
function isAvailableNum(num) {
|
|
933
1059
|
return num > 0 || num < 0 || num === 0;
|
|
934
1060
|
}
|
|
935
1061
|
function setStyle(dom, style) {
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
keys.forEach((key)
|
|
941
|
-
styleStr +=
|
|
1062
|
+
var originStyle = getStyle(dom);
|
|
1063
|
+
var _style = __assign$1$1(__assign$1$1({}, originStyle), style);
|
|
1064
|
+
var keys = Object.keys(_style);
|
|
1065
|
+
var styleStr = "";
|
|
1066
|
+
keys.forEach(function(key) {
|
|
1067
|
+
styleStr += "".concat(key, ":").concat(_style[key] || "", ";");
|
|
942
1068
|
});
|
|
943
1069
|
dom.setAttribute("style", styleStr);
|
|
944
1070
|
}
|
|
945
1071
|
function getStyle(dom) {
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
styleList.forEach((item)
|
|
950
|
-
|
|
1072
|
+
var styleObj = {};
|
|
1073
|
+
var style = dom.getAttribute("style") || "";
|
|
1074
|
+
var styleList = style.split(";");
|
|
1075
|
+
styleList.forEach(function(item) {
|
|
1076
|
+
var dataList = item.split(":");
|
|
951
1077
|
if (dataList[0] && typeof dataList[0] === "string") {
|
|
952
1078
|
styleObj[dataList[0]] = dataList[1] || "";
|
|
953
1079
|
}
|
|
954
1080
|
});
|
|
955
1081
|
return styleObj;
|
|
956
1082
|
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
const defaultScrollConfig = {
|
|
961
|
-
width: minScrollerWidth,
|
|
962
|
-
color: "#000000",
|
|
963
|
-
showBackground: true
|
|
1083
|
+
var defaultScrollConfig = {
|
|
1084
|
+
lineWidth: 12,
|
|
1085
|
+
color: "#a0a0a0"
|
|
964
1086
|
};
|
|
965
|
-
|
|
966
|
-
|
|
1087
|
+
var Scroller = function() {
|
|
1088
|
+
function Scroller2(ctx, opts) {
|
|
967
1089
|
this._displayCtx = ctx;
|
|
968
1090
|
this._opts = this._getOpts(opts);
|
|
969
1091
|
}
|
|
970
|
-
draw(position) {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
1092
|
+
Scroller2.prototype.draw = function(position) {
|
|
1093
|
+
var _a2 = this._opts, width = _a2.width, height = _a2.height;
|
|
1094
|
+
var wrapper = this.calc(position);
|
|
1095
|
+
var ctx = this._displayCtx;
|
|
974
1096
|
if (wrapper.xSize > 0) {
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
drawBoxScrollerThumb(ctx, {
|
|
981
|
-
axis: "X",
|
|
1097
|
+
ctx.globalAlpha = 0.2;
|
|
1098
|
+
ctx.fillStyle = wrapper.color;
|
|
1099
|
+
ctx.fillRect(0, this._doSize(height - wrapper.lineSize), this._doSize(width), this._doSize(wrapper.lineSize));
|
|
1100
|
+
ctx.globalAlpha = 1;
|
|
1101
|
+
drawBox$1(ctx, {
|
|
982
1102
|
x: this._doSize(wrapper.translateX),
|
|
983
1103
|
y: this._doSize(height - wrapper.lineSize),
|
|
984
1104
|
w: this._doSize(wrapper.xSize),
|
|
@@ -988,13 +1108,11 @@ var iDrawCore = function() {
|
|
|
988
1108
|
});
|
|
989
1109
|
}
|
|
990
1110
|
if (wrapper.ySize > 0) {
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
drawBoxScrollerThumb(ctx, {
|
|
997
|
-
axis: "Y",
|
|
1111
|
+
ctx.globalAlpha = 0.2;
|
|
1112
|
+
ctx.fillStyle = wrapper.color;
|
|
1113
|
+
ctx.fillRect(this._doSize(width - wrapper.lineSize), 0, this._doSize(wrapper.lineSize), this._doSize(height));
|
|
1114
|
+
ctx.globalAlpha = 1;
|
|
1115
|
+
drawBox$1(ctx, {
|
|
998
1116
|
x: this._doSize(width - wrapper.lineSize),
|
|
999
1117
|
y: this._doSize(wrapper.translateY),
|
|
1000
1118
|
w: this._doSize(wrapper.lineSize),
|
|
@@ -1004,42 +1122,42 @@ var iDrawCore = function() {
|
|
|
1004
1122
|
});
|
|
1005
1123
|
}
|
|
1006
1124
|
ctx.globalAlpha = 1;
|
|
1007
|
-
}
|
|
1008
|
-
resetSize(opts) {
|
|
1009
|
-
this._opts =
|
|
1010
|
-
}
|
|
1011
|
-
isPointAtScrollY(p) {
|
|
1012
|
-
|
|
1013
|
-
|
|
1125
|
+
};
|
|
1126
|
+
Scroller2.prototype.resetSize = function(opts) {
|
|
1127
|
+
this._opts = __assign$1$1(__assign$1$1({}, this._opts), opts);
|
|
1128
|
+
};
|
|
1129
|
+
Scroller2.prototype.isPointAtScrollY = function(p) {
|
|
1130
|
+
var _a2 = this._opts, width = _a2.width, height = _a2.height, scrollConfig = _a2.scrollConfig;
|
|
1131
|
+
var ctx = this._displayCtx;
|
|
1014
1132
|
ctx.beginPath();
|
|
1015
|
-
ctx.rect(this._doSize(width - scrollConfig.
|
|
1133
|
+
ctx.rect(this._doSize(width - scrollConfig.lineWidth), 0, this._doSize(scrollConfig.lineWidth), this._doSize(height));
|
|
1016
1134
|
ctx.closePath();
|
|
1017
1135
|
if (ctx.isPointInPath(this._doSize(p.x), this._doSize(p.y))) {
|
|
1018
1136
|
return true;
|
|
1019
1137
|
}
|
|
1020
1138
|
return false;
|
|
1021
|
-
}
|
|
1022
|
-
isPointAtScrollX(p) {
|
|
1023
|
-
|
|
1024
|
-
|
|
1139
|
+
};
|
|
1140
|
+
Scroller2.prototype.isPointAtScrollX = function(p) {
|
|
1141
|
+
var _a2 = this._opts, width = _a2.width, height = _a2.height, scrollConfig = _a2.scrollConfig;
|
|
1142
|
+
var ctx = this._displayCtx;
|
|
1025
1143
|
ctx.beginPath();
|
|
1026
|
-
ctx.rect(0, this._doSize(height - scrollConfig.
|
|
1144
|
+
ctx.rect(0, this._doSize(height - scrollConfig.lineWidth), this._doSize(width - scrollConfig.lineWidth), this._doSize(scrollConfig.lineWidth));
|
|
1027
1145
|
ctx.closePath();
|
|
1028
1146
|
if (ctx.isPointInPath(this._doSize(p.x), this._doSize(p.y))) {
|
|
1029
1147
|
return true;
|
|
1030
1148
|
}
|
|
1031
1149
|
return false;
|
|
1032
|
-
}
|
|
1033
|
-
getLineWidth() {
|
|
1034
|
-
|
|
1150
|
+
};
|
|
1151
|
+
Scroller2.prototype.getLineWidth = function() {
|
|
1152
|
+
var lineWidth = this._opts.scrollConfig.lineWidth;
|
|
1035
1153
|
return lineWidth;
|
|
1036
|
-
}
|
|
1037
|
-
calc(position) {
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1154
|
+
};
|
|
1155
|
+
Scroller2.prototype.calc = function(position) {
|
|
1156
|
+
var _a2 = this._opts, width = _a2.width, height = _a2.height, scrollConfig = _a2.scrollConfig;
|
|
1157
|
+
var sliderMinSize = scrollConfig.lineWidth * 2.5;
|
|
1158
|
+
var lineSize = scrollConfig.lineWidth;
|
|
1159
|
+
var xSize = 0;
|
|
1160
|
+
var ySize = 0;
|
|
1043
1161
|
if (position.left <= 0 && position.right <= 0) {
|
|
1044
1162
|
xSize = Math.max(sliderMinSize, width - (Math.abs(position.left) + Math.abs(position.right)));
|
|
1045
1163
|
if (xSize >= width)
|
|
@@ -1050,17 +1168,17 @@ var iDrawCore = function() {
|
|
|
1050
1168
|
if (ySize >= height)
|
|
1051
1169
|
ySize = 0;
|
|
1052
1170
|
}
|
|
1053
|
-
|
|
1171
|
+
var translateX = 0;
|
|
1054
1172
|
if (xSize > 0) {
|
|
1055
1173
|
translateX = xSize / 2 + (width - xSize) * Math.abs(position.left) / (Math.abs(position.left) + Math.abs(position.right));
|
|
1056
1174
|
translateX = Math.min(Math.max(0, translateX - xSize / 2), width - xSize);
|
|
1057
1175
|
}
|
|
1058
|
-
|
|
1176
|
+
var translateY = 0;
|
|
1059
1177
|
if (ySize > 0) {
|
|
1060
1178
|
translateY = ySize / 2 + (height - ySize) * Math.abs(position.top) / (Math.abs(position.top) + Math.abs(position.bottom));
|
|
1061
1179
|
translateY = Math.min(Math.max(0, translateY - ySize / 2), height - ySize);
|
|
1062
1180
|
}
|
|
1063
|
-
|
|
1181
|
+
var scrollWrapper = {
|
|
1064
1182
|
lineSize,
|
|
1065
1183
|
xSize,
|
|
1066
1184
|
ySize,
|
|
@@ -1069,44 +1187,33 @@ var iDrawCore = function() {
|
|
|
1069
1187
|
color: this._opts.scrollConfig.color
|
|
1070
1188
|
};
|
|
1071
1189
|
return scrollWrapper;
|
|
1072
|
-
}
|
|
1073
|
-
_doSize(num) {
|
|
1190
|
+
};
|
|
1191
|
+
Scroller2.prototype._doSize = function(num) {
|
|
1074
1192
|
return num * this._opts.devicePixelRatio;
|
|
1075
|
-
}
|
|
1076
|
-
_getOpts(opts) {
|
|
1077
|
-
var
|
|
1078
|
-
const options = Object.assign(Object.assign({}, opts), {
|
|
1079
|
-
scrollConfig: Object.assign(Object.assign({}, defaultScrollConfig), opts.scrollConfig || {})
|
|
1080
|
-
});
|
|
1193
|
+
};
|
|
1194
|
+
Scroller2.prototype._getOpts = function(opts) {
|
|
1195
|
+
var options = __assign$1$1({ scrollConfig: defaultScrollConfig }, opts);
|
|
1081
1196
|
if (!options.scrollConfig) {
|
|
1082
1197
|
options.scrollConfig = defaultScrollConfig;
|
|
1083
1198
|
}
|
|
1084
|
-
if (!(
|
|
1085
|
-
options.scrollConfig.
|
|
1199
|
+
if (!(options.scrollConfig.lineWidth > 0)) {
|
|
1200
|
+
options.scrollConfig.lineWidth = defaultScrollConfig.lineWidth;
|
|
1086
1201
|
}
|
|
1087
|
-
options.scrollConfig.
|
|
1088
|
-
if (isColorStr(options.scrollConfig.color) !== true) {
|
|
1202
|
+
options.scrollConfig.lineWidth = Math.max(options.scrollConfig.lineWidth, defaultScrollConfig.lineWidth);
|
|
1203
|
+
if (isColorStr$2(options.scrollConfig.color) !== true) {
|
|
1089
1204
|
options.scrollConfig.color = options.scrollConfig.color;
|
|
1090
1205
|
}
|
|
1091
1206
|
return options;
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
y2 = y2 + h2 / 4 + 1;
|
|
1099
|
-
h2 = h2 / 2;
|
|
1100
|
-
} else if (axis === "Y") {
|
|
1101
|
-
x2 = x2 + w2 / 4 + 1;
|
|
1102
|
-
w2 = w2 / 2;
|
|
1103
|
-
}
|
|
1104
|
-
let r = opts.r;
|
|
1207
|
+
};
|
|
1208
|
+
return Scroller2;
|
|
1209
|
+
}();
|
|
1210
|
+
function drawBox$1(ctx, opts) {
|
|
1211
|
+
var x2 = opts.x, y2 = opts.y, w2 = opts.w, h2 = opts.h, color2 = opts.color;
|
|
1212
|
+
var r = opts.r;
|
|
1105
1213
|
r = Math.min(r, w2 / 2, h2 / 2);
|
|
1106
1214
|
if (w2 < r * 2 || h2 < r * 2) {
|
|
1107
1215
|
r = 0;
|
|
1108
1216
|
}
|
|
1109
|
-
ctx.globalAlpha = scrollerThumbAlpha;
|
|
1110
1217
|
ctx.beginPath();
|
|
1111
1218
|
ctx.moveTo(x2 + r, y2);
|
|
1112
1219
|
ctx.arcTo(x2 + w2, y2, x2 + w2, y2 + h2, r);
|
|
@@ -1116,88 +1223,77 @@ var iDrawCore = function() {
|
|
|
1116
1223
|
ctx.closePath();
|
|
1117
1224
|
ctx.fillStyle = color2;
|
|
1118
1225
|
ctx.fill();
|
|
1119
|
-
ctx.globalAlpha = 1;
|
|
1120
|
-
ctx.beginPath();
|
|
1121
|
-
ctx.lineWidth = 1;
|
|
1122
|
-
ctx.strokeStyle = color2;
|
|
1123
|
-
ctx.moveTo(x2 + r, y2);
|
|
1124
|
-
ctx.arcTo(x2 + w2, y2, x2 + w2, y2 + h2, r);
|
|
1125
|
-
ctx.arcTo(x2 + w2, y2 + h2, x2, y2 + h2, r);
|
|
1126
|
-
ctx.arcTo(x2, y2 + h2, x2, y2, r);
|
|
1127
|
-
ctx.arcTo(x2, y2, x2 + w2, y2, r);
|
|
1128
|
-
ctx.closePath();
|
|
1129
|
-
ctx.stroke();
|
|
1130
1226
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
this[_opts$
|
|
1136
|
-
this[_ctx$
|
|
1227
|
+
var _opts$1$1 = Symbol("_opts");
|
|
1228
|
+
var _ctx$1 = Symbol("_ctx");
|
|
1229
|
+
var Screen = function() {
|
|
1230
|
+
function Screen2(ctx, opts) {
|
|
1231
|
+
this[_opts$1$1] = opts;
|
|
1232
|
+
this[_ctx$1] = ctx;
|
|
1137
1233
|
}
|
|
1138
|
-
resetSize(opts) {
|
|
1139
|
-
this[_opts$
|
|
1140
|
-
}
|
|
1141
|
-
calcScreen() {
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1234
|
+
Screen2.prototype.resetSize = function(opts) {
|
|
1235
|
+
this[_opts$1$1] = __assign$1$1(__assign$1$1({}, this[_opts$1$1]), opts);
|
|
1236
|
+
};
|
|
1237
|
+
Screen2.prototype.calcScreen = function() {
|
|
1238
|
+
var scaleRatio = this[_ctx$1].getTransform().scale;
|
|
1239
|
+
var _a2 = this[_opts$1$1], width = _a2.width, height = _a2.height, contextWidth = _a2.contextWidth, contextHeight = _a2.contextHeight, pxRatio = _a2.devicePixelRatio;
|
|
1240
|
+
var canScrollXPrev = true;
|
|
1241
|
+
var canScrollXNext = true;
|
|
1242
|
+
var canScrollYPrev = true;
|
|
1243
|
+
var canScrollYNext = true;
|
|
1148
1244
|
if (contextWidth * scaleRatio <= width) {
|
|
1149
|
-
this[_ctx$
|
|
1245
|
+
this[_ctx$1].setTransform({
|
|
1150
1246
|
scrollX: (width - contextWidth * scaleRatio) / 2
|
|
1151
1247
|
});
|
|
1152
1248
|
canScrollXPrev = false;
|
|
1153
1249
|
canScrollXNext = false;
|
|
1154
1250
|
}
|
|
1155
1251
|
if (contextHeight * scaleRatio <= height) {
|
|
1156
|
-
this[_ctx$
|
|
1252
|
+
this[_ctx$1].setTransform({
|
|
1157
1253
|
scrollY: (height - contextHeight * scaleRatio) / 2
|
|
1158
1254
|
});
|
|
1159
1255
|
canScrollYPrev = false;
|
|
1160
1256
|
canScrollYNext = false;
|
|
1161
1257
|
}
|
|
1162
|
-
if (contextWidth * scaleRatio >= width && this[_ctx$
|
|
1163
|
-
this[_ctx$
|
|
1258
|
+
if (contextWidth * scaleRatio >= width && this[_ctx$1].getTransform().scrollX > 0) {
|
|
1259
|
+
this[_ctx$1].setTransform({
|
|
1164
1260
|
scrollX: 0
|
|
1165
1261
|
});
|
|
1166
1262
|
canScrollXPrev = false;
|
|
1167
1263
|
}
|
|
1168
|
-
if (contextHeight * scaleRatio >= height && this[_ctx$
|
|
1169
|
-
this[_ctx$
|
|
1264
|
+
if (contextHeight * scaleRatio >= height && this[_ctx$1].getTransform().scrollY > 0) {
|
|
1265
|
+
this[_ctx$1].setTransform({
|
|
1170
1266
|
scrollY: 0
|
|
1171
1267
|
});
|
|
1172
1268
|
canScrollYPrev = false;
|
|
1173
1269
|
}
|
|
1174
|
-
|
|
1270
|
+
var _b2 = this[_ctx$1].getTransform(), _scrollX = _b2.scrollX, _scrollY = _b2.scrollY;
|
|
1175
1271
|
if (_scrollX < 0 && Math.abs(_scrollX) > Math.abs(contextWidth * scaleRatio - width)) {
|
|
1176
|
-
this[_ctx$
|
|
1272
|
+
this[_ctx$1].setTransform({
|
|
1177
1273
|
scrollX: 0 - Math.abs(contextWidth * scaleRatio - width)
|
|
1178
1274
|
});
|
|
1179
1275
|
canScrollXNext = false;
|
|
1180
1276
|
}
|
|
1181
1277
|
if (_scrollY < 0 && Math.abs(_scrollY) > Math.abs(contextHeight * scaleRatio - height)) {
|
|
1182
|
-
this[_ctx$
|
|
1278
|
+
this[_ctx$1].setTransform({
|
|
1183
1279
|
scrollY: 0 - Math.abs(contextHeight * scaleRatio - height)
|
|
1184
1280
|
});
|
|
1185
1281
|
canScrollYNext = false;
|
|
1186
1282
|
}
|
|
1187
|
-
|
|
1188
|
-
|
|
1283
|
+
var _c2 = this[_ctx$1].getTransform(), scrollX = _c2.scrollX, scrollY = _c2.scrollY;
|
|
1284
|
+
var size = {
|
|
1189
1285
|
x: scrollX * scaleRatio,
|
|
1190
1286
|
y: scrollY * scaleRatio,
|
|
1191
1287
|
w: contextWidth * scaleRatio,
|
|
1192
1288
|
h: contextHeight * scaleRatio
|
|
1193
1289
|
};
|
|
1194
|
-
|
|
1290
|
+
var deviceSize = {
|
|
1195
1291
|
x: scrollX * pxRatio,
|
|
1196
1292
|
y: scrollY * pxRatio,
|
|
1197
1293
|
w: contextWidth * pxRatio * scaleRatio,
|
|
1198
1294
|
h: contextHeight * pxRatio * scaleRatio
|
|
1199
1295
|
};
|
|
1200
|
-
|
|
1296
|
+
var position = {
|
|
1201
1297
|
top: scrollY,
|
|
1202
1298
|
bottom: height - (contextHeight * scaleRatio + scrollY),
|
|
1203
1299
|
left: scrollX,
|
|
@@ -1207,65 +1303,66 @@ var iDrawCore = function() {
|
|
|
1207
1303
|
size,
|
|
1208
1304
|
position,
|
|
1209
1305
|
deviceSize,
|
|
1210
|
-
width: this[_opts$
|
|
1211
|
-
height: this[_opts$
|
|
1212
|
-
devicePixelRatio: this[_opts$
|
|
1306
|
+
width: this[_opts$1$1].width,
|
|
1307
|
+
height: this[_opts$1$1].height,
|
|
1308
|
+
devicePixelRatio: this[_opts$1$1].devicePixelRatio,
|
|
1213
1309
|
canScrollYPrev,
|
|
1214
1310
|
canScrollYNext,
|
|
1215
1311
|
canScrollXPrev,
|
|
1216
1312
|
canScrollXNext
|
|
1217
1313
|
};
|
|
1218
|
-
}
|
|
1219
|
-
calcScreenScroll(start, end, sliderSize, limitLen, moveDistance) {
|
|
1220
|
-
|
|
1221
|
-
|
|
1314
|
+
};
|
|
1315
|
+
Screen2.prototype.calcScreenScroll = function(start, end, sliderSize, limitLen, moveDistance) {
|
|
1316
|
+
var scrollDistance = start;
|
|
1317
|
+
var scrollLen = limitLen - sliderSize;
|
|
1222
1318
|
if (start <= 0 && end <= 0) {
|
|
1223
1319
|
scrollLen = Math.abs(start) + Math.abs(end);
|
|
1224
1320
|
}
|
|
1225
|
-
|
|
1321
|
+
var unit = 1;
|
|
1226
1322
|
if (scrollLen > 0) {
|
|
1227
1323
|
unit = scrollLen / (limitLen - sliderSize);
|
|
1228
1324
|
}
|
|
1229
1325
|
scrollDistance = 0 - unit * moveDistance;
|
|
1230
1326
|
return scrollDistance;
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
var
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1327
|
+
};
|
|
1328
|
+
return Screen2;
|
|
1329
|
+
}();
|
|
1330
|
+
var _canvas = Symbol("_canvas");
|
|
1331
|
+
var _displayCanvas = Symbol("_displayCanvas");
|
|
1332
|
+
var _helperCanvas = Symbol("_helperCanvas");
|
|
1333
|
+
var _mount = Symbol("_mount");
|
|
1334
|
+
var _opts$2 = Symbol("_opts");
|
|
1335
|
+
var _hasRendered = Symbol("_hasRendered");
|
|
1336
|
+
var _ctx$2 = Symbol("_ctx");
|
|
1337
|
+
var _helperCtx = Symbol("_helperCtx");
|
|
1338
|
+
var _watcher = Symbol("_watcher");
|
|
1339
|
+
var _render = Symbol("_render");
|
|
1340
|
+
var _parsePrivateOptions = Symbol("_parsePrivateOptions");
|
|
1341
|
+
var _scroller = Symbol("_scroller");
|
|
1342
|
+
var _initEvent = Symbol("_initEvent");
|
|
1343
|
+
var _doScrollX = Symbol("_doScrollX");
|
|
1344
|
+
var _doScrollY = Symbol("_doScrollY");
|
|
1345
|
+
var _doMoveScroll = Symbol("_doMoveScroll");
|
|
1346
|
+
var _resetContext = Symbol("_resetContext");
|
|
1347
|
+
var _screen = Symbol("_screen");
|
|
1348
|
+
var _a$1;
|
|
1349
|
+
var throttle$2 = default_1$1.throttle, Context$2 = default_1$1.Context;
|
|
1350
|
+
var Board = function() {
|
|
1351
|
+
function Board2(mount, opts) {
|
|
1352
|
+
this[_a$1] = false;
|
|
1256
1353
|
this[_mount] = mount;
|
|
1257
1354
|
this[_canvas] = document.createElement("canvas");
|
|
1258
1355
|
this[_helperCanvas] = document.createElement("canvas");
|
|
1259
1356
|
this[_displayCanvas] = document.createElement("canvas");
|
|
1260
1357
|
this[_mount].appendChild(this[_displayCanvas]);
|
|
1261
|
-
this[_opts$
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
this[_ctx$
|
|
1266
|
-
this[_helperCtx] = new Context(helperCtx2d, this[_opts$
|
|
1267
|
-
this[_screen] = new Screen(this[_ctx$
|
|
1268
|
-
this[_watcher] = new ScreenWatcher(this[_displayCanvas], this[_ctx$
|
|
1358
|
+
this[_opts$2] = this[_parsePrivateOptions](opts);
|
|
1359
|
+
var originCtx2d = this[_canvas].getContext("2d");
|
|
1360
|
+
var displayCtx2d = this[_displayCanvas].getContext("2d");
|
|
1361
|
+
var helperCtx2d = this[_helperCanvas].getContext("2d");
|
|
1362
|
+
this[_ctx$2] = new Context$2(originCtx2d, this[_opts$2]);
|
|
1363
|
+
this[_helperCtx] = new Context$2(helperCtx2d, this[_opts$2]);
|
|
1364
|
+
this[_screen] = new Screen(this[_ctx$2], this[_opts$2]);
|
|
1365
|
+
this[_watcher] = new ScreenWatcher(this[_displayCanvas], this[_ctx$2]);
|
|
1269
1366
|
this[_scroller] = new Scroller(displayCtx2d, {
|
|
1270
1367
|
width: opts.width,
|
|
1271
1368
|
height: opts.height,
|
|
@@ -1274,30 +1371,30 @@ var iDrawCore = function() {
|
|
|
1274
1371
|
});
|
|
1275
1372
|
this[_render]();
|
|
1276
1373
|
}
|
|
1277
|
-
getDisplayContext2D() {
|
|
1374
|
+
Board2.prototype.getDisplayContext2D = function() {
|
|
1278
1375
|
return this[_displayCanvas].getContext("2d");
|
|
1279
|
-
}
|
|
1280
|
-
getOriginContext2D() {
|
|
1281
|
-
return this[_ctx$
|
|
1282
|
-
}
|
|
1283
|
-
getHelperContext2D() {
|
|
1376
|
+
};
|
|
1377
|
+
Board2.prototype.getOriginContext2D = function() {
|
|
1378
|
+
return this[_ctx$2].getContext();
|
|
1379
|
+
};
|
|
1380
|
+
Board2.prototype.getHelperContext2D = function() {
|
|
1284
1381
|
return this[_helperCtx].getContext();
|
|
1285
|
-
}
|
|
1286
|
-
getContext() {
|
|
1287
|
-
return this[_ctx$
|
|
1288
|
-
}
|
|
1289
|
-
getHelperContext() {
|
|
1382
|
+
};
|
|
1383
|
+
Board2.prototype.getContext = function() {
|
|
1384
|
+
return this[_ctx$2];
|
|
1385
|
+
};
|
|
1386
|
+
Board2.prototype.getHelperContext = function() {
|
|
1290
1387
|
return this[_helperCtx];
|
|
1291
|
-
}
|
|
1292
|
-
scale(scaleRatio) {
|
|
1388
|
+
};
|
|
1389
|
+
Board2.prototype.scale = function(scaleRatio) {
|
|
1293
1390
|
if (scaleRatio > 0) {
|
|
1294
|
-
this[_ctx$
|
|
1391
|
+
this[_ctx$2].setTransform({ scale: scaleRatio });
|
|
1295
1392
|
this[_helperCtx].setTransform({ scale: scaleRatio });
|
|
1296
1393
|
}
|
|
1297
|
-
|
|
1394
|
+
var _b2 = this[_screen].calcScreen(), position = _b2.position, size = _b2.size;
|
|
1298
1395
|
return { position, size };
|
|
1299
|
-
}
|
|
1300
|
-
scrollX(x2) {
|
|
1396
|
+
};
|
|
1397
|
+
Board2.prototype.scrollX = function(x2) {
|
|
1301
1398
|
this[_watcher].setStatusMap({
|
|
1302
1399
|
canScrollYPrev: true,
|
|
1303
1400
|
canScrollYNext: true,
|
|
@@ -1305,10 +1402,10 @@ var iDrawCore = function() {
|
|
|
1305
1402
|
canScrollXNext: true
|
|
1306
1403
|
});
|
|
1307
1404
|
if (x2 >= 0 || x2 < 0) {
|
|
1308
|
-
this[_ctx$
|
|
1405
|
+
this[_ctx$2].setTransform({ scrollX: x2 });
|
|
1309
1406
|
this[_helperCtx].setTransform({ scrollX: x2 });
|
|
1310
1407
|
}
|
|
1311
|
-
|
|
1408
|
+
var _b2 = this[_screen].calcScreen(), position = _b2.position, size = _b2.size, canScrollXNext = _b2.canScrollXNext, canScrollYNext = _b2.canScrollYNext, canScrollXPrev = _b2.canScrollXPrev, canScrollYPrev = _b2.canScrollYPrev;
|
|
1312
1409
|
this[_watcher].setStatusMap({
|
|
1313
1410
|
canScrollYPrev,
|
|
1314
1411
|
canScrollYNext,
|
|
@@ -1316,8 +1413,8 @@ var iDrawCore = function() {
|
|
|
1316
1413
|
canScrollXNext
|
|
1317
1414
|
});
|
|
1318
1415
|
return { position, size };
|
|
1319
|
-
}
|
|
1320
|
-
scrollY(y2) {
|
|
1416
|
+
};
|
|
1417
|
+
Board2.prototype.scrollY = function(y2) {
|
|
1321
1418
|
this[_watcher].setStatusMap({
|
|
1322
1419
|
canScrollYPrev: true,
|
|
1323
1420
|
canScrollYNext: true,
|
|
@@ -1325,10 +1422,10 @@ var iDrawCore = function() {
|
|
|
1325
1422
|
canScrollXNext: true
|
|
1326
1423
|
});
|
|
1327
1424
|
if (y2 >= 0 || y2 < 0) {
|
|
1328
|
-
this[_ctx$
|
|
1425
|
+
this[_ctx$2].setTransform({ scrollY: y2 });
|
|
1329
1426
|
this[_helperCtx].setTransform({ scrollY: y2 });
|
|
1330
1427
|
}
|
|
1331
|
-
|
|
1428
|
+
var _b2 = this[_screen].calcScreen(), position = _b2.position, size = _b2.size, canScrollXNext = _b2.canScrollXNext, canScrollYNext = _b2.canScrollYNext, canScrollXPrev = _b2.canScrollXPrev, canScrollYPrev = _b2.canScrollYPrev;
|
|
1332
1429
|
this[_watcher].setStatusMap({
|
|
1333
1430
|
canScrollYPrev,
|
|
1334
1431
|
canScrollYNext,
|
|
@@ -1336,86 +1433,86 @@ var iDrawCore = function() {
|
|
|
1336
1433
|
canScrollXNext
|
|
1337
1434
|
});
|
|
1338
1435
|
return { position, size };
|
|
1339
|
-
}
|
|
1340
|
-
getTransform() {
|
|
1341
|
-
return this[_ctx$
|
|
1342
|
-
}
|
|
1343
|
-
draw() {
|
|
1436
|
+
};
|
|
1437
|
+
Board2.prototype.getTransform = function() {
|
|
1438
|
+
return this[_ctx$2].getTransform();
|
|
1439
|
+
};
|
|
1440
|
+
Board2.prototype.draw = function() {
|
|
1344
1441
|
this.clear();
|
|
1345
|
-
|
|
1346
|
-
|
|
1442
|
+
var _b2 = this[_screen].calcScreen(), position = _b2.position, deviceSize = _b2.deviceSize, size = _b2.size;
|
|
1443
|
+
var displayCtx = this[_displayCanvas].getContext("2d");
|
|
1347
1444
|
displayCtx === null || displayCtx === void 0 ? void 0 : displayCtx.drawImage(this[_canvas], deviceSize.x, deviceSize.y, deviceSize.w, deviceSize.h);
|
|
1348
1445
|
displayCtx === null || displayCtx === void 0 ? void 0 : displayCtx.drawImage(this[_helperCanvas], deviceSize.x, deviceSize.y, deviceSize.w, deviceSize.h);
|
|
1349
|
-
if (this[_opts$
|
|
1446
|
+
if (this[_opts$2].canScroll === true) {
|
|
1350
1447
|
this[_scroller].draw(position);
|
|
1351
1448
|
}
|
|
1352
1449
|
return { position, size };
|
|
1353
|
-
}
|
|
1354
|
-
clear() {
|
|
1355
|
-
|
|
1450
|
+
};
|
|
1451
|
+
Board2.prototype.clear = function() {
|
|
1452
|
+
var displayCtx = this[_displayCanvas].getContext("2d");
|
|
1356
1453
|
displayCtx === null || displayCtx === void 0 ? void 0 : displayCtx.clearRect(0, 0, this[_displayCanvas].width, this[_displayCanvas].height);
|
|
1357
|
-
}
|
|
1358
|
-
on(name, callback) {
|
|
1454
|
+
};
|
|
1455
|
+
Board2.prototype.on = function(name, callback) {
|
|
1359
1456
|
this[_watcher].on(name, callback);
|
|
1360
|
-
}
|
|
1361
|
-
off(name, callback) {
|
|
1457
|
+
};
|
|
1458
|
+
Board2.prototype.off = function(name, callback) {
|
|
1362
1459
|
this[_watcher].off(name, callback);
|
|
1363
|
-
}
|
|
1364
|
-
getScreenInfo() {
|
|
1460
|
+
};
|
|
1461
|
+
Board2.prototype.getScreenInfo = function() {
|
|
1365
1462
|
return this[_screen].calcScreen();
|
|
1366
|
-
}
|
|
1367
|
-
setCursor(cursor) {
|
|
1463
|
+
};
|
|
1464
|
+
Board2.prototype.setCursor = function(cursor) {
|
|
1368
1465
|
this[_displayCanvas].style.cursor = cursor;
|
|
1369
|
-
}
|
|
1370
|
-
resetCursor() {
|
|
1466
|
+
};
|
|
1467
|
+
Board2.prototype.resetCursor = function() {
|
|
1371
1468
|
this[_displayCanvas].style.cursor = "auto";
|
|
1372
|
-
}
|
|
1373
|
-
resetSize(opts) {
|
|
1374
|
-
this[_opts$
|
|
1469
|
+
};
|
|
1470
|
+
Board2.prototype.resetSize = function(opts) {
|
|
1471
|
+
this[_opts$2] = __assign$1$1(__assign$1$1({}, this[_opts$2]), opts);
|
|
1375
1472
|
this[_resetContext]();
|
|
1376
|
-
this[_ctx$
|
|
1473
|
+
this[_ctx$2].resetSize(opts);
|
|
1377
1474
|
this[_helperCtx].resetSize(opts);
|
|
1378
1475
|
this[_screen].resetSize(opts);
|
|
1379
1476
|
this[_scroller].resetSize({
|
|
1380
|
-
width: this[_opts$
|
|
1381
|
-
height: this[_opts$
|
|
1382
|
-
devicePixelRatio: this[_opts$
|
|
1477
|
+
width: this[_opts$2].width,
|
|
1478
|
+
height: this[_opts$2].height,
|
|
1479
|
+
devicePixelRatio: this[_opts$2].devicePixelRatio
|
|
1383
1480
|
});
|
|
1384
1481
|
this.draw();
|
|
1385
|
-
}
|
|
1386
|
-
getScrollLineWidth() {
|
|
1387
|
-
|
|
1388
|
-
if (this[_opts$
|
|
1482
|
+
};
|
|
1483
|
+
Board2.prototype.getScrollLineWidth = function() {
|
|
1484
|
+
var lineWidth = 0;
|
|
1485
|
+
if (this[_opts$2].canScroll === true) {
|
|
1389
1486
|
lineWidth = this[_scroller].getLineWidth();
|
|
1390
1487
|
}
|
|
1391
1488
|
return lineWidth;
|
|
1392
|
-
}
|
|
1393
|
-
pointScreenToContext(screenPoint) {
|
|
1394
|
-
|
|
1395
|
-
|
|
1489
|
+
};
|
|
1490
|
+
Board2.prototype.pointScreenToContext = function(screenPoint) {
|
|
1491
|
+
var _b2 = this.getTransform(), scrollX = _b2.scrollX, scrollY = _b2.scrollY, scale = _b2.scale;
|
|
1492
|
+
var ctxPoint = {
|
|
1396
1493
|
x: (screenPoint.x - scrollX) / scale,
|
|
1397
1494
|
y: (screenPoint.y - scrollY) / scale
|
|
1398
1495
|
};
|
|
1399
1496
|
return ctxPoint;
|
|
1400
|
-
}
|
|
1401
|
-
pointContextToScreen(ctxPoint) {
|
|
1402
|
-
|
|
1403
|
-
|
|
1497
|
+
};
|
|
1498
|
+
Board2.prototype.pointContextToScreen = function(ctxPoint) {
|
|
1499
|
+
var _b2 = this.getTransform(), scrollX = _b2.scrollX, scrollY = _b2.scrollY, scale = _b2.scale;
|
|
1500
|
+
var screenPoint = {
|
|
1404
1501
|
x: ctxPoint.x * scale + scrollX,
|
|
1405
1502
|
y: ctxPoint.y * scale + scrollY
|
|
1406
1503
|
};
|
|
1407
1504
|
return screenPoint;
|
|
1408
|
-
}
|
|
1409
|
-
[
|
|
1505
|
+
};
|
|
1506
|
+
Board2.prototype[_a$1 = _hasRendered, _render] = function() {
|
|
1410
1507
|
if (this[_hasRendered] === true) {
|
|
1411
1508
|
return;
|
|
1412
1509
|
}
|
|
1413
1510
|
this[_resetContext]();
|
|
1414
1511
|
this[_initEvent]();
|
|
1415
1512
|
this[_hasRendered] = true;
|
|
1416
|
-
}
|
|
1417
|
-
[_resetContext]() {
|
|
1418
|
-
|
|
1513
|
+
};
|
|
1514
|
+
Board2.prototype[_resetContext] = function() {
|
|
1515
|
+
var _b2 = this[_opts$2], width = _b2.width, height = _b2.height, contextWidth = _b2.contextWidth, contextHeight = _b2.contextHeight, devicePixelRatio = _b2.devicePixelRatio;
|
|
1419
1516
|
this[_canvas].width = contextWidth * devicePixelRatio;
|
|
1420
1517
|
this[_canvas].height = contextHeight * devicePixelRatio;
|
|
1421
1518
|
this[_helperCanvas].width = contextWidth * devicePixelRatio;
|
|
@@ -1423,98 +1520,1057 @@ var iDrawCore = function() {
|
|
|
1423
1520
|
this[_displayCanvas].width = width * devicePixelRatio;
|
|
1424
1521
|
this[_displayCanvas].height = height * devicePixelRatio;
|
|
1425
1522
|
setStyle(this[_displayCanvas], {
|
|
1426
|
-
width:
|
|
1427
|
-
height:
|
|
1523
|
+
width: "".concat(width, "px"),
|
|
1524
|
+
height: "".concat(height, "px")
|
|
1428
1525
|
});
|
|
1429
|
-
}
|
|
1430
|
-
[_parsePrivateOptions](opts) {
|
|
1431
|
-
|
|
1526
|
+
};
|
|
1527
|
+
Board2.prototype[_parsePrivateOptions] = function(opts) {
|
|
1528
|
+
var defaultOpts = {
|
|
1432
1529
|
devicePixelRatio: 1
|
|
1433
1530
|
};
|
|
1434
|
-
return
|
|
1435
|
-
}
|
|
1436
|
-
[_initEvent]() {
|
|
1531
|
+
return __assign$1$1(__assign$1$1({}, defaultOpts), opts);
|
|
1532
|
+
};
|
|
1533
|
+
Board2.prototype[_initEvent] = function() {
|
|
1534
|
+
var _this = this;
|
|
1437
1535
|
if (this[_hasRendered] === true) {
|
|
1438
1536
|
return;
|
|
1439
1537
|
}
|
|
1440
|
-
if (this[_opts$
|
|
1441
|
-
this.on("wheelX", throttle((deltaX)
|
|
1442
|
-
|
|
1538
|
+
if (this[_opts$2].canScroll === true) {
|
|
1539
|
+
this.on("wheelX", throttle$2(function(deltaX) {
|
|
1540
|
+
_this[_doScrollX](deltaX);
|
|
1443
1541
|
}, 16));
|
|
1444
|
-
this.on("wheelY", throttle((deltaY)
|
|
1445
|
-
|
|
1542
|
+
this.on("wheelY", throttle$2(function(deltaY) {
|
|
1543
|
+
_this[_doScrollY](deltaY);
|
|
1446
1544
|
}, 16));
|
|
1447
|
-
|
|
1448
|
-
this.on("moveStart", throttle((p)
|
|
1449
|
-
if (
|
|
1450
|
-
|
|
1451
|
-
} else if (
|
|
1452
|
-
|
|
1545
|
+
var scrollType_1 = null;
|
|
1546
|
+
this.on("moveStart", throttle$2(function(p) {
|
|
1547
|
+
if (_this[_scroller].isPointAtScrollX(p)) {
|
|
1548
|
+
scrollType_1 = "x";
|
|
1549
|
+
} else if (_this[_scroller].isPointAtScrollY(p)) {
|
|
1550
|
+
scrollType_1 = "y";
|
|
1453
1551
|
}
|
|
1454
1552
|
}, 16));
|
|
1455
|
-
this.on("move", throttle((p)
|
|
1456
|
-
if (
|
|
1457
|
-
|
|
1553
|
+
this.on("move", throttle$2(function(p) {
|
|
1554
|
+
if (scrollType_1) {
|
|
1555
|
+
_this[_doMoveScroll](scrollType_1, p);
|
|
1458
1556
|
}
|
|
1459
1557
|
}, 16));
|
|
1460
|
-
this.on("moveEnd", throttle((p)
|
|
1461
|
-
if (
|
|
1462
|
-
|
|
1558
|
+
this.on("moveEnd", throttle$2(function(p) {
|
|
1559
|
+
if (scrollType_1) {
|
|
1560
|
+
_this[_doMoveScroll](scrollType_1, p);
|
|
1463
1561
|
}
|
|
1464
|
-
|
|
1562
|
+
scrollType_1 = null;
|
|
1465
1563
|
}, 16));
|
|
1466
1564
|
}
|
|
1467
|
-
}
|
|
1468
|
-
[_doScrollX](dx, prevScrollX) {
|
|
1469
|
-
|
|
1470
|
-
|
|
1565
|
+
};
|
|
1566
|
+
Board2.prototype[_doScrollX] = function(dx, prevScrollX) {
|
|
1567
|
+
var width = this[_opts$2].width;
|
|
1568
|
+
var scrollX = prevScrollX;
|
|
1471
1569
|
if (!(typeof scrollX === "number" && (scrollX > 0 || scrollX <= 0))) {
|
|
1472
|
-
scrollX = this[_ctx$
|
|
1570
|
+
scrollX = this[_ctx$2].getTransform().scrollX;
|
|
1473
1571
|
}
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1572
|
+
var position = this[_screen].calcScreen().position;
|
|
1573
|
+
var xSize = this[_scroller].calc(position).xSize;
|
|
1574
|
+
var moveX = this[_screen].calcScreenScroll(position.left, position.right, xSize, width, dx);
|
|
1477
1575
|
this.scrollX(scrollX + moveX);
|
|
1478
1576
|
this.draw();
|
|
1479
|
-
}
|
|
1480
|
-
[_doScrollY](dy, prevScrollY) {
|
|
1481
|
-
|
|
1482
|
-
|
|
1577
|
+
};
|
|
1578
|
+
Board2.prototype[_doScrollY] = function(dy, prevScrollY) {
|
|
1579
|
+
var height = this[_opts$2].height;
|
|
1580
|
+
var scrollY = prevScrollY;
|
|
1483
1581
|
if (!(typeof scrollY === "number" && (scrollY > 0 || scrollY <= 0))) {
|
|
1484
|
-
scrollY = this[_ctx$
|
|
1582
|
+
scrollY = this[_ctx$2].getTransform().scrollY;
|
|
1485
1583
|
}
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1584
|
+
var position = this[_screen].calcScreen().position;
|
|
1585
|
+
var ySize = this[_scroller].calc(position).ySize;
|
|
1586
|
+
var moveY = this[_screen].calcScreenScroll(position.top, position.bottom, ySize, height, dy);
|
|
1489
1587
|
this.scrollY(scrollY + moveY);
|
|
1490
1588
|
this.draw();
|
|
1491
|
-
}
|
|
1492
|
-
[_doMoveScroll](scrollType, point) {
|
|
1589
|
+
};
|
|
1590
|
+
Board2.prototype[_doMoveScroll] = function(scrollType, point) {
|
|
1493
1591
|
if (!scrollType) {
|
|
1494
1592
|
return;
|
|
1495
1593
|
}
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
if (scrollType === "x") {
|
|
1499
|
-
this[_doScrollX](point.x - xSize / 2, 0);
|
|
1500
|
-
} else if (scrollType === "y") {
|
|
1501
|
-
this[_doScrollY](point.y - ySize / 2, 0);
|
|
1594
|
+
var position = this[_screen].calcScreen().position;
|
|
1595
|
+
var _b2 = this[_scroller].calc(position), xSize = _b2.xSize, ySize = _b2.ySize;
|
|
1596
|
+
if (scrollType === "x") {
|
|
1597
|
+
this[_doScrollX](point.x - xSize / 2, 0);
|
|
1598
|
+
} else if (scrollType === "y") {
|
|
1599
|
+
this[_doScrollY](point.y - ySize / 2, 0);
|
|
1600
|
+
}
|
|
1601
|
+
};
|
|
1602
|
+
return Board2;
|
|
1603
|
+
}();
|
|
1604
|
+
var default_1$2 = /* @__PURE__ */ Object.freeze({
|
|
1605
|
+
__proto__: null,
|
|
1606
|
+
Board
|
|
1607
|
+
});
|
|
1608
|
+
function throttle(fn, timeout) {
|
|
1609
|
+
var timer = -1;
|
|
1610
|
+
return function() {
|
|
1611
|
+
var args = [];
|
|
1612
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1613
|
+
args[_i] = arguments[_i];
|
|
1614
|
+
}
|
|
1615
|
+
if (timer > 0) {
|
|
1616
|
+
return;
|
|
1617
|
+
}
|
|
1618
|
+
timer = setTimeout(function() {
|
|
1619
|
+
fn.apply(void 0, args);
|
|
1620
|
+
timer = -1;
|
|
1621
|
+
}, timeout);
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
function isColorStr$1(color2) {
|
|
1625
|
+
return typeof color2 === "string" && /^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color2);
|
|
1626
|
+
}
|
|
1627
|
+
function createUUID$1() {
|
|
1628
|
+
function str4() {
|
|
1629
|
+
return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
|
|
1630
|
+
}
|
|
1631
|
+
return "".concat(str4()).concat(str4(), "-").concat(str4(), "-").concat(str4(), "-").concat(str4(), "-").concat(str4()).concat(str4()).concat(str4());
|
|
1632
|
+
}
|
|
1633
|
+
function deepClone$1(target) {
|
|
1634
|
+
function _clone(t) {
|
|
1635
|
+
var type = is$1$1(t);
|
|
1636
|
+
if (["Null", "Number", "String", "Boolean", "Undefined"].indexOf(type) >= 0) {
|
|
1637
|
+
return t;
|
|
1638
|
+
} else if (type === "Array") {
|
|
1639
|
+
var arr_1 = [];
|
|
1640
|
+
t.forEach(function(item) {
|
|
1641
|
+
arr_1.push(_clone(item));
|
|
1642
|
+
});
|
|
1643
|
+
return arr_1;
|
|
1644
|
+
} else if (type === "Object") {
|
|
1645
|
+
var obj_1 = {};
|
|
1646
|
+
var keys = Object.keys(t);
|
|
1647
|
+
keys.forEach(function(key) {
|
|
1648
|
+
obj_1[key] = _clone(t[key]);
|
|
1649
|
+
});
|
|
1650
|
+
return obj_1;
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
return _clone(target);
|
|
1654
|
+
}
|
|
1655
|
+
function is$1$1(data) {
|
|
1656
|
+
return Object.prototype.toString.call(data).replace(/[\]|\[]{1,1}/ig, "").split(" ")[1];
|
|
1657
|
+
}
|
|
1658
|
+
var __assign$2 = function() {
|
|
1659
|
+
__assign$2 = Object.assign || function __assign2(t) {
|
|
1660
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1661
|
+
s = arguments[i];
|
|
1662
|
+
for (var p in s)
|
|
1663
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
1664
|
+
t[p] = s[p];
|
|
1665
|
+
}
|
|
1666
|
+
return t;
|
|
1667
|
+
};
|
|
1668
|
+
return __assign$2.apply(this, arguments);
|
|
1669
|
+
};
|
|
1670
|
+
(function() {
|
|
1671
|
+
function Context2(ctx, opts) {
|
|
1672
|
+
this._opts = opts;
|
|
1673
|
+
this._ctx = ctx;
|
|
1674
|
+
this._transform = {
|
|
1675
|
+
scale: 1,
|
|
1676
|
+
scrollX: 0,
|
|
1677
|
+
scrollY: 0
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
Context2.prototype.getContext = function() {
|
|
1681
|
+
return this._ctx;
|
|
1682
|
+
};
|
|
1683
|
+
Context2.prototype.resetSize = function(opts) {
|
|
1684
|
+
this._opts = __assign$2(__assign$2({}, this._opts), opts);
|
|
1685
|
+
};
|
|
1686
|
+
Context2.prototype.calcDeviceNum = function(num) {
|
|
1687
|
+
return num * this._opts.devicePixelRatio;
|
|
1688
|
+
};
|
|
1689
|
+
Context2.prototype.calcScreenNum = function(num) {
|
|
1690
|
+
return num / this._opts.devicePixelRatio;
|
|
1691
|
+
};
|
|
1692
|
+
Context2.prototype.getSize = function() {
|
|
1693
|
+
return {
|
|
1694
|
+
width: this._opts.width,
|
|
1695
|
+
height: this._opts.height,
|
|
1696
|
+
contextWidth: this._opts.contextWidth,
|
|
1697
|
+
contextHeight: this._opts.contextHeight,
|
|
1698
|
+
devicePixelRatio: this._opts.devicePixelRatio
|
|
1699
|
+
};
|
|
1700
|
+
};
|
|
1701
|
+
Context2.prototype.setTransform = function(config) {
|
|
1702
|
+
this._transform = __assign$2(__assign$2({}, this._transform), config);
|
|
1703
|
+
};
|
|
1704
|
+
Context2.prototype.getTransform = function() {
|
|
1705
|
+
return {
|
|
1706
|
+
scale: this._transform.scale,
|
|
1707
|
+
scrollX: this._transform.scrollX,
|
|
1708
|
+
scrollY: this._transform.scrollY
|
|
1709
|
+
};
|
|
1710
|
+
};
|
|
1711
|
+
Context2.prototype.setFillStyle = function(color2) {
|
|
1712
|
+
this._ctx.fillStyle = color2;
|
|
1713
|
+
};
|
|
1714
|
+
Context2.prototype.fill = function(fillRule) {
|
|
1715
|
+
return this._ctx.fill(fillRule || "nonzero");
|
|
1716
|
+
};
|
|
1717
|
+
Context2.prototype.arc = function(x2, y2, radius, startAngle, endAngle, anticlockwise) {
|
|
1718
|
+
return this._ctx.arc(this._doSize(x2), this._doSize(y2), this._doSize(radius), startAngle, endAngle, anticlockwise);
|
|
1719
|
+
};
|
|
1720
|
+
Context2.prototype.rect = function(x2, y2, w2, h2) {
|
|
1721
|
+
return this._ctx.rect(this._doSize(x2), this._doSize(y2), this._doSize(w2), this._doSize(h2));
|
|
1722
|
+
};
|
|
1723
|
+
Context2.prototype.fillRect = function(x2, y2, w2, h2) {
|
|
1724
|
+
return this._ctx.fillRect(this._doSize(x2), this._doSize(y2), this._doSize(w2), this._doSize(h2));
|
|
1725
|
+
};
|
|
1726
|
+
Context2.prototype.clearRect = function(x2, y2, w2, h2) {
|
|
1727
|
+
return this._ctx.clearRect(this._doSize(x2), this._doSize(y2), this._doSize(w2), this._doSize(h2));
|
|
1728
|
+
};
|
|
1729
|
+
Context2.prototype.beginPath = function() {
|
|
1730
|
+
return this._ctx.beginPath();
|
|
1731
|
+
};
|
|
1732
|
+
Context2.prototype.closePath = function() {
|
|
1733
|
+
return this._ctx.closePath();
|
|
1734
|
+
};
|
|
1735
|
+
Context2.prototype.lineTo = function(x2, y2) {
|
|
1736
|
+
return this._ctx.lineTo(this._doSize(x2), this._doSize(y2));
|
|
1737
|
+
};
|
|
1738
|
+
Context2.prototype.moveTo = function(x2, y2) {
|
|
1739
|
+
return this._ctx.moveTo(this._doSize(x2), this._doSize(y2));
|
|
1740
|
+
};
|
|
1741
|
+
Context2.prototype.arcTo = function(x1, y1, x2, y2, radius) {
|
|
1742
|
+
return this._ctx.arcTo(this._doSize(x1), this._doSize(y1), this._doSize(x2), this._doSize(y2), this._doSize(radius));
|
|
1743
|
+
};
|
|
1744
|
+
Context2.prototype.setLineWidth = function(w2) {
|
|
1745
|
+
return this._ctx.lineWidth = this._doSize(w2);
|
|
1746
|
+
};
|
|
1747
|
+
Context2.prototype.setLineDash = function(nums) {
|
|
1748
|
+
var _this = this;
|
|
1749
|
+
return this._ctx.setLineDash(nums.map(function(n) {
|
|
1750
|
+
return _this._doSize(n);
|
|
1751
|
+
}));
|
|
1752
|
+
};
|
|
1753
|
+
Context2.prototype.isPointInPath = function(x2, y2) {
|
|
1754
|
+
return this._ctx.isPointInPath(this._doX(x2), this._doY(y2));
|
|
1755
|
+
};
|
|
1756
|
+
Context2.prototype.isPointInPathWithoutScroll = function(x2, y2) {
|
|
1757
|
+
return this._ctx.isPointInPath(this._doSize(x2), this._doSize(y2));
|
|
1758
|
+
};
|
|
1759
|
+
Context2.prototype.setStrokeStyle = function(color2) {
|
|
1760
|
+
this._ctx.strokeStyle = color2;
|
|
1761
|
+
};
|
|
1762
|
+
Context2.prototype.stroke = function() {
|
|
1763
|
+
return this._ctx.stroke();
|
|
1764
|
+
};
|
|
1765
|
+
Context2.prototype.translate = function(x2, y2) {
|
|
1766
|
+
return this._ctx.translate(this._doSize(x2), this._doSize(y2));
|
|
1767
|
+
};
|
|
1768
|
+
Context2.prototype.rotate = function(angle2) {
|
|
1769
|
+
return this._ctx.rotate(angle2);
|
|
1770
|
+
};
|
|
1771
|
+
Context2.prototype.drawImage = function() {
|
|
1772
|
+
var args = [];
|
|
1773
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1774
|
+
args[_i] = arguments[_i];
|
|
1775
|
+
}
|
|
1776
|
+
var image = args[0];
|
|
1777
|
+
var sx = args[1];
|
|
1778
|
+
var sy = args[2];
|
|
1779
|
+
var sw = args[3];
|
|
1780
|
+
var sh = args[4];
|
|
1781
|
+
var dx = args[args.length - 4];
|
|
1782
|
+
var dy = args[args.length - 3];
|
|
1783
|
+
var dw = args[args.length - 2];
|
|
1784
|
+
var dh = args[args.length - 1];
|
|
1785
|
+
if (args.length === 9) {
|
|
1786
|
+
return this._ctx.drawImage(image, this._doSize(sx), this._doSize(sy), this._doSize(sw), this._doSize(sh), this._doSize(dx), this._doSize(dy), this._doSize(dw), this._doSize(dh));
|
|
1787
|
+
} else {
|
|
1788
|
+
return this._ctx.drawImage(image, this._doSize(dx), this._doSize(dy), this._doSize(dw), this._doSize(dh));
|
|
1789
|
+
}
|
|
1790
|
+
};
|
|
1791
|
+
Context2.prototype.createPattern = function(image, repetition) {
|
|
1792
|
+
return this._ctx.createPattern(image, repetition);
|
|
1793
|
+
};
|
|
1794
|
+
Context2.prototype.measureText = function(text2) {
|
|
1795
|
+
return this._ctx.measureText(text2);
|
|
1796
|
+
};
|
|
1797
|
+
Context2.prototype.setTextAlign = function(align) {
|
|
1798
|
+
this._ctx.textAlign = align;
|
|
1799
|
+
};
|
|
1800
|
+
Context2.prototype.fillText = function(text2, x2, y2, maxWidth) {
|
|
1801
|
+
if (maxWidth !== void 0) {
|
|
1802
|
+
return this._ctx.fillText(text2, this._doSize(x2), this._doSize(y2), this._doSize(maxWidth));
|
|
1803
|
+
} else {
|
|
1804
|
+
return this._ctx.fillText(text2, this._doSize(x2), this._doSize(y2));
|
|
1805
|
+
}
|
|
1806
|
+
};
|
|
1807
|
+
Context2.prototype.strokeText = function(text2, x2, y2, maxWidth) {
|
|
1808
|
+
if (maxWidth !== void 0) {
|
|
1809
|
+
return this._ctx.strokeText(text2, this._doSize(x2), this._doSize(y2), this._doSize(maxWidth));
|
|
1810
|
+
} else {
|
|
1811
|
+
return this._ctx.strokeText(text2, this._doSize(x2), this._doSize(y2));
|
|
1812
|
+
}
|
|
1813
|
+
};
|
|
1814
|
+
Context2.prototype.setFont = function(opts) {
|
|
1815
|
+
var strList = [];
|
|
1816
|
+
if (opts.fontWeight === "bold") {
|
|
1817
|
+
strList.push("".concat(opts.fontWeight));
|
|
1818
|
+
}
|
|
1819
|
+
strList.push("".concat(this._doSize(opts.fontSize || 12), "px"));
|
|
1820
|
+
strList.push("".concat(opts.fontFamily || "sans-serif"));
|
|
1821
|
+
this._ctx.font = "".concat(strList.join(" "));
|
|
1822
|
+
};
|
|
1823
|
+
Context2.prototype.setTextBaseline = function(baseline) {
|
|
1824
|
+
this._ctx.textBaseline = baseline;
|
|
1825
|
+
};
|
|
1826
|
+
Context2.prototype.setGlobalAlpha = function(alpha) {
|
|
1827
|
+
this._ctx.globalAlpha = alpha;
|
|
1828
|
+
};
|
|
1829
|
+
Context2.prototype.save = function() {
|
|
1830
|
+
this._ctx.save();
|
|
1831
|
+
};
|
|
1832
|
+
Context2.prototype.restore = function() {
|
|
1833
|
+
this._ctx.restore();
|
|
1834
|
+
};
|
|
1835
|
+
Context2.prototype.scale = function(ratioX, ratioY) {
|
|
1836
|
+
this._ctx.scale(ratioX, ratioY);
|
|
1837
|
+
};
|
|
1838
|
+
Context2.prototype.setShadowColor = function(color2) {
|
|
1839
|
+
this._ctx.shadowColor = color2;
|
|
1840
|
+
};
|
|
1841
|
+
Context2.prototype.setShadowOffsetX = function(offsetX) {
|
|
1842
|
+
this._ctx.shadowOffsetX = this._doSize(offsetX);
|
|
1843
|
+
};
|
|
1844
|
+
Context2.prototype.setShadowOffsetY = function(offsetY) {
|
|
1845
|
+
this._ctx.shadowOffsetY = this._doSize(offsetY);
|
|
1846
|
+
};
|
|
1847
|
+
Context2.prototype.setShadowBlur = function(blur) {
|
|
1848
|
+
this._ctx.shadowBlur = this._doSize(blur);
|
|
1849
|
+
};
|
|
1850
|
+
Context2.prototype.ellipse = function(x2, y2, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
|
|
1851
|
+
this._ctx.ellipse(this._doSize(x2), this._doSize(y2), this._doSize(radiusX), this._doSize(radiusY), rotation, startAngle, endAngle, counterclockwise);
|
|
1852
|
+
};
|
|
1853
|
+
Context2.prototype._doSize = function(num) {
|
|
1854
|
+
return this._opts.devicePixelRatio * num;
|
|
1855
|
+
};
|
|
1856
|
+
Context2.prototype._doX = function(x2) {
|
|
1857
|
+
var _a2 = this._transform, scale = _a2.scale, scrollX = _a2.scrollX;
|
|
1858
|
+
var _x = (x2 - scrollX) / scale;
|
|
1859
|
+
return this._doSize(_x);
|
|
1860
|
+
};
|
|
1861
|
+
Context2.prototype._doY = function(y2) {
|
|
1862
|
+
var _a2 = this._transform, scale = _a2.scale, scrollY = _a2.scrollY;
|
|
1863
|
+
var _y = (y2 - scrollY) / scale;
|
|
1864
|
+
return this._doSize(_y);
|
|
1865
|
+
};
|
|
1866
|
+
return Context2;
|
|
1867
|
+
})();
|
|
1868
|
+
var extendStatics = function(d, b) {
|
|
1869
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
1870
|
+
d2.__proto__ = b2;
|
|
1871
|
+
} || function(d2, b2) {
|
|
1872
|
+
for (var p in b2)
|
|
1873
|
+
if (Object.prototype.hasOwnProperty.call(b2, p))
|
|
1874
|
+
d2[p] = b2[p];
|
|
1875
|
+
};
|
|
1876
|
+
return extendStatics(d, b);
|
|
1877
|
+
};
|
|
1878
|
+
function __extends(d, b) {
|
|
1879
|
+
if (typeof b !== "function" && b !== null)
|
|
1880
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1881
|
+
extendStatics(d, b);
|
|
1882
|
+
function __() {
|
|
1883
|
+
this.constructor = d;
|
|
1884
|
+
}
|
|
1885
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1886
|
+
}
|
|
1887
|
+
var __assign$1 = function() {
|
|
1888
|
+
__assign$1 = Object.assign || function __assign2(t) {
|
|
1889
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1890
|
+
s = arguments[i];
|
|
1891
|
+
for (var p in s)
|
|
1892
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
1893
|
+
t[p] = s[p];
|
|
1894
|
+
}
|
|
1895
|
+
return t;
|
|
1896
|
+
};
|
|
1897
|
+
return __assign$1.apply(this, arguments);
|
|
1898
|
+
};
|
|
1899
|
+
function __awaiter$1(thisArg, _arguments, P, generator) {
|
|
1900
|
+
function adopt(value) {
|
|
1901
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
1902
|
+
resolve(value);
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
1906
|
+
function fulfilled(value) {
|
|
1907
|
+
try {
|
|
1908
|
+
step(generator.next(value));
|
|
1909
|
+
} catch (e) {
|
|
1910
|
+
reject(e);
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
function rejected(value) {
|
|
1914
|
+
try {
|
|
1915
|
+
step(generator["throw"](value));
|
|
1916
|
+
} catch (e) {
|
|
1917
|
+
reject(e);
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
function step(result) {
|
|
1921
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1922
|
+
}
|
|
1923
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1924
|
+
});
|
|
1925
|
+
}
|
|
1926
|
+
function __generator$1(thisArg, body) {
|
|
1927
|
+
var _ = { label: 0, sent: function() {
|
|
1928
|
+
if (t[0] & 1)
|
|
1929
|
+
throw t[1];
|
|
1930
|
+
return t[1];
|
|
1931
|
+
}, trys: [], ops: [] }, f, y2, t, g;
|
|
1932
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
1933
|
+
return this;
|
|
1934
|
+
}), g;
|
|
1935
|
+
function verb(n) {
|
|
1936
|
+
return function(v) {
|
|
1937
|
+
return step([n, v]);
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1940
|
+
function step(op) {
|
|
1941
|
+
if (f)
|
|
1942
|
+
throw new TypeError("Generator is already executing.");
|
|
1943
|
+
while (_)
|
|
1944
|
+
try {
|
|
1945
|
+
if (f = 1, y2 && (t = op[0] & 2 ? y2["return"] : op[0] ? y2["throw"] || ((t = y2["return"]) && t.call(y2), 0) : y2.next) && !(t = t.call(y2, op[1])).done)
|
|
1946
|
+
return t;
|
|
1947
|
+
if (y2 = 0, t)
|
|
1948
|
+
op = [op[0] & 2, t.value];
|
|
1949
|
+
switch (op[0]) {
|
|
1950
|
+
case 0:
|
|
1951
|
+
case 1:
|
|
1952
|
+
t = op;
|
|
1953
|
+
break;
|
|
1954
|
+
case 4:
|
|
1955
|
+
_.label++;
|
|
1956
|
+
return { value: op[1], done: false };
|
|
1957
|
+
case 5:
|
|
1958
|
+
_.label++;
|
|
1959
|
+
y2 = op[1];
|
|
1960
|
+
op = [0];
|
|
1961
|
+
continue;
|
|
1962
|
+
case 7:
|
|
1963
|
+
op = _.ops.pop();
|
|
1964
|
+
_.trys.pop();
|
|
1965
|
+
continue;
|
|
1966
|
+
default:
|
|
1967
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1968
|
+
_ = 0;
|
|
1969
|
+
continue;
|
|
1970
|
+
}
|
|
1971
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1972
|
+
_.label = op[1];
|
|
1973
|
+
break;
|
|
1974
|
+
}
|
|
1975
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
1976
|
+
_.label = t[1];
|
|
1977
|
+
t = op;
|
|
1978
|
+
break;
|
|
1979
|
+
}
|
|
1980
|
+
if (t && _.label < t[2]) {
|
|
1981
|
+
_.label = t[2];
|
|
1982
|
+
_.ops.push(op);
|
|
1983
|
+
break;
|
|
1984
|
+
}
|
|
1985
|
+
if (t[2])
|
|
1986
|
+
_.ops.pop();
|
|
1987
|
+
_.trys.pop();
|
|
1988
|
+
continue;
|
|
1989
|
+
}
|
|
1990
|
+
op = body.call(thisArg, _);
|
|
1991
|
+
} catch (e) {
|
|
1992
|
+
op = [6, e];
|
|
1993
|
+
y2 = 0;
|
|
1994
|
+
} finally {
|
|
1995
|
+
f = t = 0;
|
|
1996
|
+
}
|
|
1997
|
+
if (op[0] & 5)
|
|
1998
|
+
throw op[1];
|
|
1999
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
function isColorStr(color2) {
|
|
2003
|
+
return typeof color2 === "string" && /^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color2);
|
|
2004
|
+
}
|
|
2005
|
+
function createUUID() {
|
|
2006
|
+
function str4() {
|
|
2007
|
+
return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
|
|
2008
|
+
}
|
|
2009
|
+
return "".concat(str4()).concat(str4(), "-").concat(str4(), "-").concat(str4(), "-").concat(str4(), "-").concat(str4()).concat(str4()).concat(str4());
|
|
2010
|
+
}
|
|
2011
|
+
function deepClone(target) {
|
|
2012
|
+
function _clone(t) {
|
|
2013
|
+
var type = is$1(t);
|
|
2014
|
+
if (["Null", "Number", "String", "Boolean", "Undefined"].indexOf(type) >= 0) {
|
|
2015
|
+
return t;
|
|
2016
|
+
} else if (type === "Array") {
|
|
2017
|
+
var arr_1 = [];
|
|
2018
|
+
t.forEach(function(item) {
|
|
2019
|
+
arr_1.push(_clone(item));
|
|
2020
|
+
});
|
|
2021
|
+
return arr_1;
|
|
2022
|
+
} else if (type === "Object") {
|
|
2023
|
+
var obj_1 = {};
|
|
2024
|
+
var keys = Object.keys(t);
|
|
2025
|
+
keys.forEach(function(key) {
|
|
2026
|
+
obj_1[key] = _clone(t[key]);
|
|
2027
|
+
});
|
|
2028
|
+
return obj_1;
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
return _clone(target);
|
|
2032
|
+
}
|
|
2033
|
+
function is$1(data) {
|
|
2034
|
+
return Object.prototype.toString.call(data).replace(/[\]|\[]{1,1}/ig, "").split(" ")[1];
|
|
2035
|
+
}
|
|
2036
|
+
function parsePrototype(data) {
|
|
2037
|
+
var typeStr = Object.prototype.toString.call(data) || "";
|
|
2038
|
+
var result = typeStr.replace(/(\[object|\])/ig, "").trim();
|
|
2039
|
+
return result;
|
|
2040
|
+
}
|
|
2041
|
+
var istype = {
|
|
2042
|
+
type: function(data, lowerCase) {
|
|
2043
|
+
var result = parsePrototype(data);
|
|
2044
|
+
return lowerCase === true ? result.toLocaleLowerCase() : result;
|
|
2045
|
+
},
|
|
2046
|
+
array: function(data) {
|
|
2047
|
+
return parsePrototype(data) === "Array";
|
|
2048
|
+
},
|
|
2049
|
+
json: function(data) {
|
|
2050
|
+
return parsePrototype(data) === "Object";
|
|
2051
|
+
},
|
|
2052
|
+
function: function(data) {
|
|
2053
|
+
return parsePrototype(data) === "Function";
|
|
2054
|
+
},
|
|
2055
|
+
asyncFunction: function(data) {
|
|
2056
|
+
return parsePrototype(data) === "AsyncFunction";
|
|
2057
|
+
},
|
|
2058
|
+
string: function(data) {
|
|
2059
|
+
return parsePrototype(data) === "String";
|
|
2060
|
+
},
|
|
2061
|
+
number: function(data) {
|
|
2062
|
+
return parsePrototype(data) === "Number";
|
|
2063
|
+
},
|
|
2064
|
+
undefined: function(data) {
|
|
2065
|
+
return parsePrototype(data) === "Undefined";
|
|
2066
|
+
},
|
|
2067
|
+
null: function(data) {
|
|
2068
|
+
return parsePrototype(data) === "Null";
|
|
2069
|
+
},
|
|
2070
|
+
promise: function(data) {
|
|
2071
|
+
return parsePrototype(data) === "Promise";
|
|
2072
|
+
}
|
|
2073
|
+
};
|
|
2074
|
+
var __assign = function() {
|
|
2075
|
+
__assign = Object.assign || function __assign2(t) {
|
|
2076
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2077
|
+
s = arguments[i];
|
|
2078
|
+
for (var p in s)
|
|
2079
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
2080
|
+
t[p] = s[p];
|
|
2081
|
+
}
|
|
2082
|
+
return t;
|
|
2083
|
+
};
|
|
2084
|
+
return __assign.apply(this, arguments);
|
|
2085
|
+
};
|
|
2086
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
2087
|
+
function adopt(value) {
|
|
2088
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
2089
|
+
resolve(value);
|
|
2090
|
+
});
|
|
2091
|
+
}
|
|
2092
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
2093
|
+
function fulfilled(value) {
|
|
2094
|
+
try {
|
|
2095
|
+
step(generator.next(value));
|
|
2096
|
+
} catch (e) {
|
|
2097
|
+
reject(e);
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
function rejected(value) {
|
|
2101
|
+
try {
|
|
2102
|
+
step(generator["throw"](value));
|
|
2103
|
+
} catch (e) {
|
|
2104
|
+
reject(e);
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
function step(result) {
|
|
2108
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
2109
|
+
}
|
|
2110
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2111
|
+
});
|
|
2112
|
+
}
|
|
2113
|
+
function __generator(thisArg, body) {
|
|
2114
|
+
var _ = { label: 0, sent: function() {
|
|
2115
|
+
if (t[0] & 1)
|
|
2116
|
+
throw t[1];
|
|
2117
|
+
return t[1];
|
|
2118
|
+
}, trys: [], ops: [] }, f, y2, t, g;
|
|
2119
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
2120
|
+
return this;
|
|
2121
|
+
}), g;
|
|
2122
|
+
function verb(n) {
|
|
2123
|
+
return function(v) {
|
|
2124
|
+
return step([n, v]);
|
|
2125
|
+
};
|
|
2126
|
+
}
|
|
2127
|
+
function step(op) {
|
|
2128
|
+
if (f)
|
|
2129
|
+
throw new TypeError("Generator is already executing.");
|
|
2130
|
+
while (_)
|
|
2131
|
+
try {
|
|
2132
|
+
if (f = 1, y2 && (t = op[0] & 2 ? y2["return"] : op[0] ? y2["throw"] || ((t = y2["return"]) && t.call(y2), 0) : y2.next) && !(t = t.call(y2, op[1])).done)
|
|
2133
|
+
return t;
|
|
2134
|
+
if (y2 = 0, t)
|
|
2135
|
+
op = [op[0] & 2, t.value];
|
|
2136
|
+
switch (op[0]) {
|
|
2137
|
+
case 0:
|
|
2138
|
+
case 1:
|
|
2139
|
+
t = op;
|
|
2140
|
+
break;
|
|
2141
|
+
case 4:
|
|
2142
|
+
_.label++;
|
|
2143
|
+
return { value: op[1], done: false };
|
|
2144
|
+
case 5:
|
|
2145
|
+
_.label++;
|
|
2146
|
+
y2 = op[1];
|
|
2147
|
+
op = [0];
|
|
2148
|
+
continue;
|
|
2149
|
+
case 7:
|
|
2150
|
+
op = _.ops.pop();
|
|
2151
|
+
_.trys.pop();
|
|
2152
|
+
continue;
|
|
2153
|
+
default:
|
|
2154
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
2155
|
+
_ = 0;
|
|
2156
|
+
continue;
|
|
2157
|
+
}
|
|
2158
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
2159
|
+
_.label = op[1];
|
|
2160
|
+
break;
|
|
2161
|
+
}
|
|
2162
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
2163
|
+
_.label = t[1];
|
|
2164
|
+
t = op;
|
|
2165
|
+
break;
|
|
2166
|
+
}
|
|
2167
|
+
if (t && _.label < t[2]) {
|
|
2168
|
+
_.label = t[2];
|
|
2169
|
+
_.ops.push(op);
|
|
2170
|
+
break;
|
|
2171
|
+
}
|
|
2172
|
+
if (t[2])
|
|
2173
|
+
_.ops.pop();
|
|
2174
|
+
_.trys.pop();
|
|
2175
|
+
continue;
|
|
2176
|
+
}
|
|
2177
|
+
op = body.call(thisArg, _);
|
|
2178
|
+
} catch (e) {
|
|
2179
|
+
op = [6, e];
|
|
2180
|
+
y2 = 0;
|
|
2181
|
+
} finally {
|
|
2182
|
+
f = t = 0;
|
|
2183
|
+
}
|
|
2184
|
+
if (op[0] & 5)
|
|
2185
|
+
throw op[1];
|
|
2186
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
function parseHTMLToDataURL(html2, opts) {
|
|
2190
|
+
var width = opts.width, height = opts.height;
|
|
2191
|
+
return new Promise(function(resolve, reject) {
|
|
2192
|
+
var _svg = '\n <svg xmlns="http://www.w3.org/2000/svg" width="'.concat(width || "", '" height = "').concat(height || "", '">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ').concat(html2, "\n </div>\n </foreignObject>\n </svg>\n ");
|
|
2193
|
+
var blob = new Blob([_svg], { type: "image/svg+xml;charset=utf-8" });
|
|
2194
|
+
var reader = new FileReader();
|
|
2195
|
+
reader.readAsDataURL(blob);
|
|
2196
|
+
reader.onload = function(event) {
|
|
2197
|
+
var _a2;
|
|
2198
|
+
var base64 = (_a2 = event === null || event === void 0 ? void 0 : event.target) === null || _a2 === void 0 ? void 0 : _a2.result;
|
|
2199
|
+
resolve(base64);
|
|
2200
|
+
};
|
|
2201
|
+
reader.onerror = function(err) {
|
|
2202
|
+
reject(err);
|
|
2203
|
+
};
|
|
2204
|
+
});
|
|
2205
|
+
}
|
|
2206
|
+
function parseSVGToDataURL(svg2) {
|
|
2207
|
+
return new Promise(function(resolve, reject) {
|
|
2208
|
+
var _svg = svg2;
|
|
2209
|
+
var blob = new Blob([_svg], { type: "image/svg+xml;charset=utf-8" });
|
|
2210
|
+
var reader = new FileReader();
|
|
2211
|
+
reader.readAsDataURL(blob);
|
|
2212
|
+
reader.onload = function(event) {
|
|
2213
|
+
var _a2;
|
|
2214
|
+
var base64 = (_a2 = event === null || event === void 0 ? void 0 : event.target) === null || _a2 === void 0 ? void 0 : _a2.result;
|
|
2215
|
+
resolve(base64);
|
|
2216
|
+
};
|
|
2217
|
+
reader.onerror = function(err) {
|
|
2218
|
+
reject(err);
|
|
2219
|
+
};
|
|
2220
|
+
});
|
|
2221
|
+
}
|
|
2222
|
+
var Image = window.Image;
|
|
2223
|
+
function loadImage(src) {
|
|
2224
|
+
return new Promise(function(resolve, reject) {
|
|
2225
|
+
var img = new Image();
|
|
2226
|
+
img.onload = function() {
|
|
2227
|
+
resolve(img);
|
|
2228
|
+
};
|
|
2229
|
+
img.onabort = reject;
|
|
2230
|
+
img.onerror = reject;
|
|
2231
|
+
img.src = src;
|
|
2232
|
+
});
|
|
2233
|
+
}
|
|
2234
|
+
function loadSVG(svg2) {
|
|
2235
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
2236
|
+
var dataURL, image;
|
|
2237
|
+
return __generator(this, function(_a2) {
|
|
2238
|
+
switch (_a2.label) {
|
|
2239
|
+
case 0:
|
|
2240
|
+
return [4, parseSVGToDataURL(svg2)];
|
|
2241
|
+
case 1:
|
|
2242
|
+
dataURL = _a2.sent();
|
|
2243
|
+
return [4, loadImage(dataURL)];
|
|
2244
|
+
case 2:
|
|
2245
|
+
image = _a2.sent();
|
|
2246
|
+
return [2, image];
|
|
2247
|
+
}
|
|
2248
|
+
});
|
|
2249
|
+
});
|
|
2250
|
+
}
|
|
2251
|
+
function loadHTML(html2, opts) {
|
|
2252
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
2253
|
+
var dataURL, image;
|
|
2254
|
+
return __generator(this, function(_a2) {
|
|
2255
|
+
switch (_a2.label) {
|
|
2256
|
+
case 0:
|
|
2257
|
+
return [4, parseHTMLToDataURL(html2, opts)];
|
|
2258
|
+
case 1:
|
|
2259
|
+
dataURL = _a2.sent();
|
|
2260
|
+
return [4, loadImage(dataURL)];
|
|
2261
|
+
case 2:
|
|
2262
|
+
image = _a2.sent();
|
|
2263
|
+
return [2, image];
|
|
2264
|
+
}
|
|
2265
|
+
});
|
|
2266
|
+
});
|
|
2267
|
+
}
|
|
2268
|
+
var Context = function() {
|
|
2269
|
+
function Context2(ctx, opts) {
|
|
2270
|
+
this._opts = opts;
|
|
2271
|
+
this._ctx = ctx;
|
|
2272
|
+
this._transform = {
|
|
2273
|
+
scale: 1,
|
|
2274
|
+
scrollX: 0,
|
|
2275
|
+
scrollY: 0
|
|
2276
|
+
};
|
|
2277
|
+
}
|
|
2278
|
+
Context2.prototype.getContext = function() {
|
|
2279
|
+
return this._ctx;
|
|
2280
|
+
};
|
|
2281
|
+
Context2.prototype.resetSize = function(opts) {
|
|
2282
|
+
this._opts = __assign(__assign({}, this._opts), opts);
|
|
2283
|
+
};
|
|
2284
|
+
Context2.prototype.calcDeviceNum = function(num) {
|
|
2285
|
+
return num * this._opts.devicePixelRatio;
|
|
2286
|
+
};
|
|
2287
|
+
Context2.prototype.calcScreenNum = function(num) {
|
|
2288
|
+
return num / this._opts.devicePixelRatio;
|
|
2289
|
+
};
|
|
2290
|
+
Context2.prototype.getSize = function() {
|
|
2291
|
+
return {
|
|
2292
|
+
width: this._opts.width,
|
|
2293
|
+
height: this._opts.height,
|
|
2294
|
+
contextWidth: this._opts.contextWidth,
|
|
2295
|
+
contextHeight: this._opts.contextHeight,
|
|
2296
|
+
devicePixelRatio: this._opts.devicePixelRatio
|
|
2297
|
+
};
|
|
2298
|
+
};
|
|
2299
|
+
Context2.prototype.setTransform = function(config) {
|
|
2300
|
+
this._transform = __assign(__assign({}, this._transform), config);
|
|
2301
|
+
};
|
|
2302
|
+
Context2.prototype.getTransform = function() {
|
|
2303
|
+
return {
|
|
2304
|
+
scale: this._transform.scale,
|
|
2305
|
+
scrollX: this._transform.scrollX,
|
|
2306
|
+
scrollY: this._transform.scrollY
|
|
2307
|
+
};
|
|
2308
|
+
};
|
|
2309
|
+
Context2.prototype.setFillStyle = function(color2) {
|
|
2310
|
+
this._ctx.fillStyle = color2;
|
|
2311
|
+
};
|
|
2312
|
+
Context2.prototype.fill = function(fillRule) {
|
|
2313
|
+
return this._ctx.fill(fillRule || "nonzero");
|
|
2314
|
+
};
|
|
2315
|
+
Context2.prototype.arc = function(x2, y2, radius, startAngle, endAngle, anticlockwise) {
|
|
2316
|
+
return this._ctx.arc(this._doSize(x2), this._doSize(y2), this._doSize(radius), startAngle, endAngle, anticlockwise);
|
|
2317
|
+
};
|
|
2318
|
+
Context2.prototype.rect = function(x2, y2, w2, h2) {
|
|
2319
|
+
return this._ctx.rect(this._doSize(x2), this._doSize(y2), this._doSize(w2), this._doSize(h2));
|
|
2320
|
+
};
|
|
2321
|
+
Context2.prototype.fillRect = function(x2, y2, w2, h2) {
|
|
2322
|
+
return this._ctx.fillRect(this._doSize(x2), this._doSize(y2), this._doSize(w2), this._doSize(h2));
|
|
2323
|
+
};
|
|
2324
|
+
Context2.prototype.clearRect = function(x2, y2, w2, h2) {
|
|
2325
|
+
return this._ctx.clearRect(this._doSize(x2), this._doSize(y2), this._doSize(w2), this._doSize(h2));
|
|
2326
|
+
};
|
|
2327
|
+
Context2.prototype.beginPath = function() {
|
|
2328
|
+
return this._ctx.beginPath();
|
|
2329
|
+
};
|
|
2330
|
+
Context2.prototype.closePath = function() {
|
|
2331
|
+
return this._ctx.closePath();
|
|
2332
|
+
};
|
|
2333
|
+
Context2.prototype.lineTo = function(x2, y2) {
|
|
2334
|
+
return this._ctx.lineTo(this._doSize(x2), this._doSize(y2));
|
|
2335
|
+
};
|
|
2336
|
+
Context2.prototype.moveTo = function(x2, y2) {
|
|
2337
|
+
return this._ctx.moveTo(this._doSize(x2), this._doSize(y2));
|
|
2338
|
+
};
|
|
2339
|
+
Context2.prototype.arcTo = function(x1, y1, x2, y2, radius) {
|
|
2340
|
+
return this._ctx.arcTo(this._doSize(x1), this._doSize(y1), this._doSize(x2), this._doSize(y2), this._doSize(radius));
|
|
2341
|
+
};
|
|
2342
|
+
Context2.prototype.setLineWidth = function(w2) {
|
|
2343
|
+
return this._ctx.lineWidth = this._doSize(w2);
|
|
2344
|
+
};
|
|
2345
|
+
Context2.prototype.setLineDash = function(nums) {
|
|
2346
|
+
var _this = this;
|
|
2347
|
+
return this._ctx.setLineDash(nums.map(function(n) {
|
|
2348
|
+
return _this._doSize(n);
|
|
2349
|
+
}));
|
|
2350
|
+
};
|
|
2351
|
+
Context2.prototype.isPointInPath = function(x2, y2) {
|
|
2352
|
+
return this._ctx.isPointInPath(this._doX(x2), this._doY(y2));
|
|
2353
|
+
};
|
|
2354
|
+
Context2.prototype.isPointInPathWithoutScroll = function(x2, y2) {
|
|
2355
|
+
return this._ctx.isPointInPath(this._doSize(x2), this._doSize(y2));
|
|
2356
|
+
};
|
|
2357
|
+
Context2.prototype.setStrokeStyle = function(color2) {
|
|
2358
|
+
this._ctx.strokeStyle = color2;
|
|
2359
|
+
};
|
|
2360
|
+
Context2.prototype.stroke = function() {
|
|
2361
|
+
return this._ctx.stroke();
|
|
2362
|
+
};
|
|
2363
|
+
Context2.prototype.translate = function(x2, y2) {
|
|
2364
|
+
return this._ctx.translate(this._doSize(x2), this._doSize(y2));
|
|
2365
|
+
};
|
|
2366
|
+
Context2.prototype.rotate = function(angle2) {
|
|
2367
|
+
return this._ctx.rotate(angle2);
|
|
2368
|
+
};
|
|
2369
|
+
Context2.prototype.drawImage = function() {
|
|
2370
|
+
var args = [];
|
|
2371
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2372
|
+
args[_i] = arguments[_i];
|
|
2373
|
+
}
|
|
2374
|
+
var image = args[0];
|
|
2375
|
+
var sx = args[1];
|
|
2376
|
+
var sy = args[2];
|
|
2377
|
+
var sw = args[3];
|
|
2378
|
+
var sh = args[4];
|
|
2379
|
+
var dx = args[args.length - 4];
|
|
2380
|
+
var dy = args[args.length - 3];
|
|
2381
|
+
var dw = args[args.length - 2];
|
|
2382
|
+
var dh = args[args.length - 1];
|
|
2383
|
+
if (args.length === 9) {
|
|
2384
|
+
return this._ctx.drawImage(image, this._doSize(sx), this._doSize(sy), this._doSize(sw), this._doSize(sh), this._doSize(dx), this._doSize(dy), this._doSize(dw), this._doSize(dh));
|
|
2385
|
+
} else {
|
|
2386
|
+
return this._ctx.drawImage(image, this._doSize(dx), this._doSize(dy), this._doSize(dw), this._doSize(dh));
|
|
2387
|
+
}
|
|
2388
|
+
};
|
|
2389
|
+
Context2.prototype.createPattern = function(image, repetition) {
|
|
2390
|
+
return this._ctx.createPattern(image, repetition);
|
|
2391
|
+
};
|
|
2392
|
+
Context2.prototype.measureText = function(text2) {
|
|
2393
|
+
return this._ctx.measureText(text2);
|
|
2394
|
+
};
|
|
2395
|
+
Context2.prototype.setTextAlign = function(align) {
|
|
2396
|
+
this._ctx.textAlign = align;
|
|
2397
|
+
};
|
|
2398
|
+
Context2.prototype.fillText = function(text2, x2, y2, maxWidth) {
|
|
2399
|
+
if (maxWidth !== void 0) {
|
|
2400
|
+
return this._ctx.fillText(text2, this._doSize(x2), this._doSize(y2), this._doSize(maxWidth));
|
|
2401
|
+
} else {
|
|
2402
|
+
return this._ctx.fillText(text2, this._doSize(x2), this._doSize(y2));
|
|
2403
|
+
}
|
|
2404
|
+
};
|
|
2405
|
+
Context2.prototype.strokeText = function(text2, x2, y2, maxWidth) {
|
|
2406
|
+
if (maxWidth !== void 0) {
|
|
2407
|
+
return this._ctx.strokeText(text2, this._doSize(x2), this._doSize(y2), this._doSize(maxWidth));
|
|
2408
|
+
} else {
|
|
2409
|
+
return this._ctx.strokeText(text2, this._doSize(x2), this._doSize(y2));
|
|
2410
|
+
}
|
|
2411
|
+
};
|
|
2412
|
+
Context2.prototype.setFont = function(opts) {
|
|
2413
|
+
var strList = [];
|
|
2414
|
+
if (opts.fontWeight === "bold") {
|
|
2415
|
+
strList.push("".concat(opts.fontWeight));
|
|
2416
|
+
}
|
|
2417
|
+
strList.push("".concat(this._doSize(opts.fontSize || 12), "px"));
|
|
2418
|
+
strList.push("".concat(opts.fontFamily || "sans-serif"));
|
|
2419
|
+
this._ctx.font = "".concat(strList.join(" "));
|
|
2420
|
+
};
|
|
2421
|
+
Context2.prototype.setTextBaseline = function(baseline) {
|
|
2422
|
+
this._ctx.textBaseline = baseline;
|
|
2423
|
+
};
|
|
2424
|
+
Context2.prototype.setGlobalAlpha = function(alpha) {
|
|
2425
|
+
this._ctx.globalAlpha = alpha;
|
|
2426
|
+
};
|
|
2427
|
+
Context2.prototype.save = function() {
|
|
2428
|
+
this._ctx.save();
|
|
2429
|
+
};
|
|
2430
|
+
Context2.prototype.restore = function() {
|
|
2431
|
+
this._ctx.restore();
|
|
2432
|
+
};
|
|
2433
|
+
Context2.prototype.scale = function(ratioX, ratioY) {
|
|
2434
|
+
this._ctx.scale(ratioX, ratioY);
|
|
2435
|
+
};
|
|
2436
|
+
Context2.prototype.setShadowColor = function(color2) {
|
|
2437
|
+
this._ctx.shadowColor = color2;
|
|
2438
|
+
};
|
|
2439
|
+
Context2.prototype.setShadowOffsetX = function(offsetX) {
|
|
2440
|
+
this._ctx.shadowOffsetX = this._doSize(offsetX);
|
|
2441
|
+
};
|
|
2442
|
+
Context2.prototype.setShadowOffsetY = function(offsetY) {
|
|
2443
|
+
this._ctx.shadowOffsetY = this._doSize(offsetY);
|
|
2444
|
+
};
|
|
2445
|
+
Context2.prototype.setShadowBlur = function(blur) {
|
|
2446
|
+
this._ctx.shadowBlur = this._doSize(blur);
|
|
2447
|
+
};
|
|
2448
|
+
Context2.prototype.ellipse = function(x2, y2, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
|
|
2449
|
+
this._ctx.ellipse(this._doSize(x2), this._doSize(y2), this._doSize(radiusX), this._doSize(radiusY), rotation, startAngle, endAngle, counterclockwise);
|
|
2450
|
+
};
|
|
2451
|
+
Context2.prototype._doSize = function(num) {
|
|
2452
|
+
return this._opts.devicePixelRatio * num;
|
|
2453
|
+
};
|
|
2454
|
+
Context2.prototype._doX = function(x2) {
|
|
2455
|
+
var _a2 = this._transform, scale = _a2.scale, scrollX = _a2.scrollX;
|
|
2456
|
+
var _x = (x2 - scrollX) / scale;
|
|
2457
|
+
return this._doSize(_x);
|
|
2458
|
+
};
|
|
2459
|
+
Context2.prototype._doY = function(y2) {
|
|
2460
|
+
var _a2 = this._transform, scale = _a2.scale, scrollY = _a2.scrollY;
|
|
2461
|
+
var _y = (y2 - scrollY) / scale;
|
|
2462
|
+
return this._doSize(_y);
|
|
2463
|
+
};
|
|
2464
|
+
return Context2;
|
|
2465
|
+
}();
|
|
2466
|
+
function number$1(value) {
|
|
2467
|
+
return typeof value === "number" && (value > 0 || value <= 0);
|
|
2468
|
+
}
|
|
2469
|
+
function x$1(value) {
|
|
2470
|
+
return number$1(value);
|
|
2471
|
+
}
|
|
2472
|
+
function y$1(value) {
|
|
2473
|
+
return number$1(value);
|
|
2474
|
+
}
|
|
2475
|
+
function w$1(value) {
|
|
2476
|
+
return typeof value === "number" && value >= 0;
|
|
2477
|
+
}
|
|
2478
|
+
function h$1(value) {
|
|
2479
|
+
return typeof value === "number" && value >= 0;
|
|
2480
|
+
}
|
|
2481
|
+
function angle$1(value) {
|
|
2482
|
+
return typeof value === "number" && value >= -360 && value <= 360;
|
|
2483
|
+
}
|
|
2484
|
+
function borderWidth$1(value) {
|
|
2485
|
+
return w$1(value);
|
|
2486
|
+
}
|
|
2487
|
+
function borderRadius$1(value) {
|
|
2488
|
+
return number$1(value) && value >= 0;
|
|
2489
|
+
}
|
|
2490
|
+
function color$1(value) {
|
|
2491
|
+
return isColorStr(value);
|
|
2492
|
+
}
|
|
2493
|
+
function imageURL$1(value) {
|
|
2494
|
+
return typeof value === "string" && /^(http:\/\/|https:\/\/|\.\/|\/)/.test("".concat(value));
|
|
2495
|
+
}
|
|
2496
|
+
function imageBase64$1(value) {
|
|
2497
|
+
return typeof value === "string" && /^(data:image\/)/.test("".concat(value));
|
|
2498
|
+
}
|
|
2499
|
+
function imageSrc$1(value) {
|
|
2500
|
+
return imageBase64$1(value) || imageURL$1(value);
|
|
2501
|
+
}
|
|
2502
|
+
function svg$1(value) {
|
|
2503
|
+
return typeof value === "string" && /^(<svg[\s]{1,}|<svg>)/i.test("".concat(value).trim()) && /<\/[\s]{0,}svg>$/i.test("".concat(value).trim());
|
|
2504
|
+
}
|
|
2505
|
+
function html$1(value) {
|
|
2506
|
+
var result = false;
|
|
2507
|
+
if (typeof value === "string") {
|
|
2508
|
+
var div = document.createElement("div");
|
|
2509
|
+
div.innerHTML = value;
|
|
2510
|
+
if (div.children.length > 0) {
|
|
2511
|
+
result = true;
|
|
1502
2512
|
}
|
|
2513
|
+
div = null;
|
|
1503
2514
|
}
|
|
2515
|
+
return result;
|
|
2516
|
+
}
|
|
2517
|
+
function text$1(value) {
|
|
2518
|
+
return typeof value === "string";
|
|
2519
|
+
}
|
|
2520
|
+
function fontSize$1(value) {
|
|
2521
|
+
return number$1(value) && value > 0;
|
|
2522
|
+
}
|
|
2523
|
+
function lineHeight$1(value) {
|
|
2524
|
+
return number$1(value) && value > 0;
|
|
2525
|
+
}
|
|
2526
|
+
function strokeWidth$1(value) {
|
|
2527
|
+
return number$1(value) && value > 0;
|
|
2528
|
+
}
|
|
2529
|
+
function textAlign$1(value) {
|
|
2530
|
+
return ["center", "left", "right"].includes(value);
|
|
2531
|
+
}
|
|
2532
|
+
function fontFamily$1(value) {
|
|
2533
|
+
return typeof value === "string" && value.length > 0;
|
|
2534
|
+
}
|
|
2535
|
+
function fontWeight$1(value) {
|
|
2536
|
+
return ["bold"].includes(value);
|
|
1504
2537
|
}
|
|
2538
|
+
var is$2 = {
|
|
2539
|
+
x: x$1,
|
|
2540
|
+
y: y$1,
|
|
2541
|
+
w: w$1,
|
|
2542
|
+
h: h$1,
|
|
2543
|
+
angle: angle$1,
|
|
2544
|
+
number: number$1,
|
|
2545
|
+
borderWidth: borderWidth$1,
|
|
2546
|
+
borderRadius: borderRadius$1,
|
|
2547
|
+
color: color$1,
|
|
2548
|
+
imageSrc: imageSrc$1,
|
|
2549
|
+
imageURL: imageURL$1,
|
|
2550
|
+
imageBase64: imageBase64$1,
|
|
2551
|
+
svg: svg$1,
|
|
2552
|
+
html: html$1,
|
|
2553
|
+
text: text$1,
|
|
2554
|
+
fontSize: fontSize$1,
|
|
2555
|
+
lineHeight: lineHeight$1,
|
|
2556
|
+
textAlign: textAlign$1,
|
|
2557
|
+
fontFamily: fontFamily$1,
|
|
2558
|
+
fontWeight: fontWeight$1,
|
|
2559
|
+
strokeWidth: strokeWidth$1
|
|
2560
|
+
};
|
|
1505
2561
|
function parseAngleToRadian$1(angle2) {
|
|
1506
2562
|
return angle2 / 180 * Math.PI;
|
|
1507
2563
|
}
|
|
1508
2564
|
function calcElementCenter$1(elem) {
|
|
1509
|
-
|
|
2565
|
+
var p = {
|
|
1510
2566
|
x: elem.x + elem.w / 2,
|
|
1511
2567
|
y: elem.y + elem.h / 2
|
|
1512
2568
|
};
|
|
1513
2569
|
return p;
|
|
1514
2570
|
}
|
|
1515
2571
|
function rotateElement$1(ctx, elem, callback) {
|
|
1516
|
-
|
|
1517
|
-
|
|
2572
|
+
var center = calcElementCenter$1(elem);
|
|
2573
|
+
var radian = parseAngleToRadian$1(elem.angle || 0);
|
|
1518
2574
|
return rotateContext$1(ctx, center, radian || 0, callback);
|
|
1519
2575
|
}
|
|
1520
2576
|
function rotateContext$1(ctx, center, radian, callback) {
|
|
@@ -1541,7 +2597,7 @@ var iDrawCore = function() {
|
|
|
1541
2597
|
ctx.setShadowBlur(0);
|
|
1542
2598
|
}
|
|
1543
2599
|
function drawBgColor(ctx, color2) {
|
|
1544
|
-
|
|
2600
|
+
var size = ctx.getSize();
|
|
1545
2601
|
ctx.setFillStyle(color2);
|
|
1546
2602
|
ctx.fillRect(0, 0, size.contextWidth, size.contextHeight);
|
|
1547
2603
|
}
|
|
@@ -1549,9 +2605,9 @@ var iDrawCore = function() {
|
|
|
1549
2605
|
clearContext$1(ctx);
|
|
1550
2606
|
drawBoxBorder(ctx, elem);
|
|
1551
2607
|
clearContext$1(ctx);
|
|
1552
|
-
rotateElement$1(ctx, elem, ()
|
|
1553
|
-
|
|
1554
|
-
|
|
2608
|
+
rotateElement$1(ctx, elem, function() {
|
|
2609
|
+
var x2 = elem.x, y2 = elem.y, w2 = elem.w, h2 = elem.h;
|
|
2610
|
+
var r = elem.desc.borderRadius || 0;
|
|
1555
2611
|
r = Math.min(r, w2 / 2, h2 / 2);
|
|
1556
2612
|
if (w2 < r * 2 || h2 < r * 2) {
|
|
1557
2613
|
r = 0;
|
|
@@ -1573,35 +2629,35 @@ var iDrawCore = function() {
|
|
|
1573
2629
|
}
|
|
1574
2630
|
function drawBoxBorder(ctx, elem) {
|
|
1575
2631
|
clearContext$1(ctx);
|
|
1576
|
-
rotateElement$1(ctx, elem, ()
|
|
2632
|
+
rotateElement$1(ctx, elem, function() {
|
|
1577
2633
|
if (!(elem.desc.borderWidth && elem.desc.borderWidth > 0)) {
|
|
1578
2634
|
return;
|
|
1579
2635
|
}
|
|
1580
|
-
|
|
1581
|
-
|
|
2636
|
+
var bw = elem.desc.borderWidth;
|
|
2637
|
+
var borderColor = "#000000";
|
|
1582
2638
|
if (isColorStr(elem.desc.borderColor) === true) {
|
|
1583
2639
|
borderColor = elem.desc.borderColor;
|
|
1584
2640
|
}
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
2641
|
+
var x2 = elem.x - bw / 2;
|
|
2642
|
+
var y2 = elem.y - bw / 2;
|
|
2643
|
+
var w2 = elem.w + bw;
|
|
2644
|
+
var h2 = elem.h + bw;
|
|
2645
|
+
var r = elem.desc.borderRadius || 0;
|
|
1590
2646
|
r = Math.min(r, w2 / 2, h2 / 2);
|
|
1591
2647
|
if (r < w2 / 2 && r < h2 / 2) {
|
|
1592
2648
|
r = r + bw / 2;
|
|
1593
2649
|
}
|
|
1594
|
-
|
|
2650
|
+
var desc = elem.desc;
|
|
1595
2651
|
if (desc.shadowColor !== void 0 && isColorStr(desc.shadowColor)) {
|
|
1596
2652
|
ctx.setShadowColor(desc.shadowColor);
|
|
1597
2653
|
}
|
|
1598
|
-
if (desc.shadowOffsetX !== void 0 && is$
|
|
2654
|
+
if (desc.shadowOffsetX !== void 0 && is$2.number(desc.shadowOffsetX)) {
|
|
1599
2655
|
ctx.setShadowOffsetX(desc.shadowOffsetX);
|
|
1600
2656
|
}
|
|
1601
|
-
if (desc.shadowOffsetY !== void 0 && is$
|
|
2657
|
+
if (desc.shadowOffsetY !== void 0 && is$2.number(desc.shadowOffsetY)) {
|
|
1602
2658
|
ctx.setShadowOffsetY(desc.shadowOffsetY);
|
|
1603
2659
|
}
|
|
1604
|
-
if (desc.shadowBlur !== void 0 && is$
|
|
2660
|
+
if (desc.shadowBlur !== void 0 && is$2.number(desc.shadowBlur)) {
|
|
1605
2661
|
ctx.setShadowBlur(desc.shadowBlur);
|
|
1606
2662
|
}
|
|
1607
2663
|
ctx.beginPath();
|
|
@@ -1620,24 +2676,24 @@ var iDrawCore = function() {
|
|
|
1620
2676
|
drawBox(ctx, elem, elem.desc.bgColor);
|
|
1621
2677
|
}
|
|
1622
2678
|
function drawImage(ctx, elem, loader) {
|
|
1623
|
-
|
|
1624
|
-
rotateElement$1(ctx, elem, ()
|
|
2679
|
+
var content = loader.getContent(elem.uuid);
|
|
2680
|
+
rotateElement$1(ctx, elem, function() {
|
|
1625
2681
|
if (content) {
|
|
1626
2682
|
ctx.drawImage(content, elem.x, elem.y, elem.w, elem.h);
|
|
1627
2683
|
}
|
|
1628
2684
|
});
|
|
1629
2685
|
}
|
|
1630
2686
|
function drawSVG(ctx, elem, loader) {
|
|
1631
|
-
|
|
1632
|
-
rotateElement$1(ctx, elem, ()
|
|
2687
|
+
var content = loader.getContent(elem.uuid);
|
|
2688
|
+
rotateElement$1(ctx, elem, function() {
|
|
1633
2689
|
if (content) {
|
|
1634
2690
|
ctx.drawImage(content, elem.x, elem.y, elem.w, elem.h);
|
|
1635
2691
|
}
|
|
1636
2692
|
});
|
|
1637
2693
|
}
|
|
1638
2694
|
function drawHTML(ctx, elem, loader) {
|
|
1639
|
-
|
|
1640
|
-
rotateElement$1(ctx, elem, ()
|
|
2695
|
+
var content = loader.getContent(elem.uuid);
|
|
2696
|
+
rotateElement$1(ctx, elem, function() {
|
|
1641
2697
|
if (content) {
|
|
1642
2698
|
ctx.drawImage(content, elem.x, elem.y, elem.w, elem.h);
|
|
1643
2699
|
}
|
|
@@ -1646,8 +2702,8 @@ var iDrawCore = function() {
|
|
|
1646
2702
|
function drawText(ctx, elem, loader) {
|
|
1647
2703
|
clearContext$1(ctx);
|
|
1648
2704
|
drawBox(ctx, elem, elem.desc.bgColor || "transparent");
|
|
1649
|
-
rotateElement$1(ctx, elem, ()
|
|
1650
|
-
|
|
2705
|
+
rotateElement$1(ctx, elem, function() {
|
|
2706
|
+
var desc = __assign$1({
|
|
1651
2707
|
fontSize: 12,
|
|
1652
2708
|
fontFamily: "sans-serif",
|
|
1653
2709
|
textAlign: "center"
|
|
@@ -1659,15 +2715,15 @@ var iDrawCore = function() {
|
|
|
1659
2715
|
fontSize: desc.fontSize,
|
|
1660
2716
|
fontFamily: desc.fontFamily
|
|
1661
2717
|
});
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
descTextList.forEach((tempText, idx)
|
|
1668
|
-
|
|
2718
|
+
var descText = desc.text.replace(/\r\n/ig, "\n");
|
|
2719
|
+
var fontHeight = desc.lineHeight || desc.fontSize;
|
|
2720
|
+
var descTextList = descText.split("\n");
|
|
2721
|
+
var lines = [];
|
|
2722
|
+
var lineNum = 0;
|
|
2723
|
+
descTextList.forEach(function(tempText, idx) {
|
|
2724
|
+
var lineText = "";
|
|
1669
2725
|
if (tempText.length > 0) {
|
|
1670
|
-
for (
|
|
2726
|
+
for (var i = 0; i < tempText.length; i++) {
|
|
1671
2727
|
if (ctx.measureText(lineText + (tempText[i] || "")).width < ctx.calcDeviceNum(elem.w)) {
|
|
1672
2728
|
lineText += tempText[i] || "";
|
|
1673
2729
|
} else {
|
|
@@ -1701,45 +2757,41 @@ var iDrawCore = function() {
|
|
|
1701
2757
|
});
|
|
1702
2758
|
}
|
|
1703
2759
|
});
|
|
1704
|
-
let startY = 0;
|
|
1705
|
-
if (lines.length * fontHeight < elem.h) {
|
|
1706
|
-
if (elem.desc.verticalAlign === "top") {
|
|
1707
|
-
startY = 0;
|
|
1708
|
-
} else if (elem.desc.verticalAlign === "bottom") {
|
|
1709
|
-
startY += elem.h - lines.length * fontHeight;
|
|
1710
|
-
} else {
|
|
1711
|
-
startY += (elem.h - lines.length * fontHeight) / 2;
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
2760
|
{
|
|
1715
|
-
|
|
2761
|
+
var _y_1 = elem.y;
|
|
2762
|
+
if (lines.length * fontHeight < elem.h) {
|
|
2763
|
+
_y_1 += (elem.h - lines.length * fontHeight) / 2;
|
|
2764
|
+
}
|
|
1716
2765
|
if (desc.textShadowColor !== void 0 && isColorStr(desc.textShadowColor)) {
|
|
1717
2766
|
ctx.setShadowColor(desc.textShadowColor);
|
|
1718
2767
|
}
|
|
1719
|
-
if (desc.textShadowOffsetX !== void 0 && is$
|
|
2768
|
+
if (desc.textShadowOffsetX !== void 0 && is$2.number(desc.textShadowOffsetX)) {
|
|
1720
2769
|
ctx.setShadowOffsetX(desc.textShadowOffsetX);
|
|
1721
2770
|
}
|
|
1722
|
-
if (desc.textShadowOffsetY !== void 0 && is$
|
|
2771
|
+
if (desc.textShadowOffsetY !== void 0 && is$2.number(desc.textShadowOffsetY)) {
|
|
1723
2772
|
ctx.setShadowOffsetY(desc.textShadowOffsetY);
|
|
1724
2773
|
}
|
|
1725
|
-
if (desc.textShadowBlur !== void 0 && is$
|
|
2774
|
+
if (desc.textShadowBlur !== void 0 && is$2.number(desc.textShadowBlur)) {
|
|
1726
2775
|
ctx.setShadowBlur(desc.textShadowBlur);
|
|
1727
2776
|
}
|
|
1728
|
-
lines.forEach((line, i)
|
|
1729
|
-
|
|
2777
|
+
lines.forEach(function(line, i) {
|
|
2778
|
+
var _x = elem.x;
|
|
1730
2779
|
if (desc.textAlign === "center") {
|
|
1731
2780
|
_x = elem.x + (elem.w - line.width) / 2;
|
|
1732
2781
|
} else if (desc.textAlign === "right") {
|
|
1733
2782
|
_x = elem.x + (elem.w - line.width);
|
|
1734
2783
|
}
|
|
1735
|
-
ctx.fillText(line.text, _x,
|
|
2784
|
+
ctx.fillText(line.text, _x, _y_1 + fontHeight * i);
|
|
1736
2785
|
});
|
|
1737
2786
|
clearContext$1(ctx);
|
|
1738
2787
|
}
|
|
1739
2788
|
if (isColorStr(desc.strokeColor) && desc.strokeWidth !== void 0 && desc.strokeWidth > 0) {
|
|
1740
|
-
|
|
1741
|
-
lines.
|
|
1742
|
-
|
|
2789
|
+
var _y_2 = elem.y;
|
|
2790
|
+
if (lines.length * fontHeight < elem.h) {
|
|
2791
|
+
_y_2 += (elem.h - lines.length * fontHeight) / 2;
|
|
2792
|
+
}
|
|
2793
|
+
lines.forEach(function(line, i) {
|
|
2794
|
+
var _x = elem.x;
|
|
1743
2795
|
if (desc.textAlign === "center") {
|
|
1744
2796
|
_x = elem.x + (elem.w - line.width) / 2;
|
|
1745
2797
|
} else if (desc.textAlign === "right") {
|
|
@@ -1751,23 +2803,23 @@ var iDrawCore = function() {
|
|
|
1751
2803
|
if (desc.strokeWidth !== void 0 && desc.strokeWidth > 0) {
|
|
1752
2804
|
ctx.setLineWidth(desc.strokeWidth);
|
|
1753
2805
|
}
|
|
1754
|
-
ctx.strokeText(line.text, _x,
|
|
2806
|
+
ctx.strokeText(line.text, _x, _y_2 + fontHeight * i);
|
|
1755
2807
|
});
|
|
1756
2808
|
}
|
|
1757
2809
|
});
|
|
1758
2810
|
}
|
|
1759
2811
|
function drawCircle(ctx, elem) {
|
|
1760
2812
|
clearContext$1(ctx);
|
|
1761
|
-
rotateElement$1(ctx, elem, (ctx2)
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
2813
|
+
rotateElement$1(ctx, elem, function(ctx2) {
|
|
2814
|
+
var x2 = elem.x, y2 = elem.y, w2 = elem.w, h2 = elem.h, desc = elem.desc;
|
|
2815
|
+
var _a2 = desc.bgColor, bgColor = _a2 === void 0 ? "#000000" : _a2, _b2 = desc.borderColor, borderColor = _b2 === void 0 ? "#000000" : _b2, _c2 = desc.borderWidth, borderWidth2 = _c2 === void 0 ? 0 : _c2;
|
|
2816
|
+
var a = w2 / 2;
|
|
2817
|
+
var b = h2 / 2;
|
|
2818
|
+
var centerX = x2 + a;
|
|
2819
|
+
var centerY = y2 + b;
|
|
1768
2820
|
if (borderWidth2 && borderWidth2 > 0) {
|
|
1769
|
-
|
|
1770
|
-
|
|
2821
|
+
var ba = borderWidth2 / 2 + a;
|
|
2822
|
+
var bb = borderWidth2 / 2 + b;
|
|
1771
2823
|
ctx2.beginPath();
|
|
1772
2824
|
ctx2.setStrokeStyle(borderColor);
|
|
1773
2825
|
ctx2.setLineWidth(borderWidth2);
|
|
@@ -1785,7 +2837,7 @@ var iDrawCore = function() {
|
|
|
1785
2837
|
function drawContext(ctx, data, loader) {
|
|
1786
2838
|
var _a2;
|
|
1787
2839
|
clearContext$1(ctx);
|
|
1788
|
-
|
|
2840
|
+
var size = ctx.getSize();
|
|
1789
2841
|
ctx.clearRect(0, 0, size.contextWidth, size.contextHeight);
|
|
1790
2842
|
if (typeof data.bgColor === "string" && isColorStr(data.bgColor)) {
|
|
1791
2843
|
drawBgColor(ctx, data.bgColor);
|
|
@@ -1793,8 +2845,8 @@ var iDrawCore = function() {
|
|
|
1793
2845
|
if (!(data.elements.length > 0)) {
|
|
1794
2846
|
return;
|
|
1795
2847
|
}
|
|
1796
|
-
for (
|
|
1797
|
-
|
|
2848
|
+
for (var i = 0; i < data.elements.length; i++) {
|
|
2849
|
+
var elem = data.elements[i];
|
|
1798
2850
|
if (((_a2 = elem === null || elem === void 0 ? void 0 : elem.operation) === null || _a2 === void 0 ? void 0 : _a2.invisible) === true) {
|
|
1799
2851
|
continue;
|
|
1800
2852
|
}
|
|
@@ -1826,24 +2878,24 @@ var iDrawCore = function() {
|
|
|
1826
2878
|
}
|
|
1827
2879
|
}
|
|
1828
2880
|
}
|
|
1829
|
-
|
|
1830
|
-
|
|
2881
|
+
var LoaderEvent = function() {
|
|
2882
|
+
function LoaderEvent2() {
|
|
1831
2883
|
this._listeners = /* @__PURE__ */ new Map();
|
|
1832
2884
|
}
|
|
1833
|
-
on(eventKey, callback) {
|
|
2885
|
+
LoaderEvent2.prototype.on = function(eventKey, callback) {
|
|
1834
2886
|
if (this._listeners.has(eventKey)) {
|
|
1835
|
-
|
|
2887
|
+
var callbacks = this._listeners.get(eventKey);
|
|
1836
2888
|
callbacks === null || callbacks === void 0 ? void 0 : callbacks.push(callback);
|
|
1837
2889
|
this._listeners.set(eventKey, callbacks || []);
|
|
1838
2890
|
} else {
|
|
1839
2891
|
this._listeners.set(eventKey, [callback]);
|
|
1840
2892
|
}
|
|
1841
|
-
}
|
|
1842
|
-
off(eventKey, callback) {
|
|
2893
|
+
};
|
|
2894
|
+
LoaderEvent2.prototype.off = function(eventKey, callback) {
|
|
1843
2895
|
if (this._listeners.has(eventKey)) {
|
|
1844
|
-
|
|
2896
|
+
var callbacks = this._listeners.get(eventKey);
|
|
1845
2897
|
if (Array.isArray(callbacks)) {
|
|
1846
|
-
for (
|
|
2898
|
+
for (var i = 0; i < (callbacks === null || callbacks === void 0 ? void 0 : callbacks.length); i++) {
|
|
1847
2899
|
if (callbacks[i] === callback) {
|
|
1848
2900
|
callbacks.splice(i, 1);
|
|
1849
2901
|
break;
|
|
@@ -1852,66 +2904,40 @@ var iDrawCore = function() {
|
|
|
1852
2904
|
}
|
|
1853
2905
|
this._listeners.set(eventKey, callbacks || []);
|
|
1854
2906
|
}
|
|
1855
|
-
}
|
|
1856
|
-
trigger(eventKey, arg) {
|
|
1857
|
-
|
|
2907
|
+
};
|
|
2908
|
+
LoaderEvent2.prototype.trigger = function(eventKey, arg) {
|
|
2909
|
+
var callbacks = this._listeners.get(eventKey);
|
|
1858
2910
|
if (Array.isArray(callbacks)) {
|
|
1859
|
-
callbacks.forEach((cb)
|
|
2911
|
+
callbacks.forEach(function(cb) {
|
|
1860
2912
|
cb(arg);
|
|
1861
2913
|
});
|
|
1862
2914
|
return true;
|
|
1863
2915
|
} else {
|
|
1864
2916
|
return false;
|
|
1865
2917
|
}
|
|
1866
|
-
}
|
|
1867
|
-
has(name) {
|
|
2918
|
+
};
|
|
2919
|
+
LoaderEvent2.prototype.has = function(name) {
|
|
1868
2920
|
if (this._listeners.has(name)) {
|
|
1869
|
-
|
|
2921
|
+
var list = this._listeners.get(name);
|
|
1870
2922
|
if (Array.isArray(list) && list.length > 0) {
|
|
1871
2923
|
return true;
|
|
1872
2924
|
}
|
|
1873
2925
|
}
|
|
1874
2926
|
return false;
|
|
1875
|
-
}
|
|
1876
|
-
|
|
2927
|
+
};
|
|
2928
|
+
return LoaderEvent2;
|
|
2929
|
+
}();
|
|
1877
2930
|
function filterScript(html2) {
|
|
1878
2931
|
return html2.replace(/<script[\s\S]*?<\/script>/ig, "");
|
|
1879
2932
|
}
|
|
1880
|
-
var __awaiter = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
1881
|
-
function adopt(value) {
|
|
1882
|
-
return value instanceof P ? value : new P(function(resolve) {
|
|
1883
|
-
resolve(value);
|
|
1884
|
-
});
|
|
1885
|
-
}
|
|
1886
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
|
1887
|
-
function fulfilled(value) {
|
|
1888
|
-
try {
|
|
1889
|
-
step(generator.next(value));
|
|
1890
|
-
} catch (e) {
|
|
1891
|
-
reject(e);
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
function rejected(value) {
|
|
1895
|
-
try {
|
|
1896
|
-
step(generator["throw"](value));
|
|
1897
|
-
} catch (e) {
|
|
1898
|
-
reject(e);
|
|
1899
|
-
}
|
|
1900
|
-
}
|
|
1901
|
-
function step(result) {
|
|
1902
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1903
|
-
}
|
|
1904
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1905
|
-
});
|
|
1906
|
-
};
|
|
1907
2933
|
var LoaderStatus;
|
|
1908
2934
|
(function(LoaderStatus2) {
|
|
1909
2935
|
LoaderStatus2["FREE"] = "free";
|
|
1910
2936
|
LoaderStatus2["LOADING"] = "loading";
|
|
1911
2937
|
LoaderStatus2["COMPLETE"] = "complete";
|
|
1912
2938
|
})(LoaderStatus || (LoaderStatus = {}));
|
|
1913
|
-
|
|
1914
|
-
|
|
2939
|
+
var Loader = function() {
|
|
2940
|
+
function Loader2(opts) {
|
|
1915
2941
|
this._currentLoadData = {};
|
|
1916
2942
|
this._currentUUIDQueue = [];
|
|
1917
2943
|
this._storageLoadData = {};
|
|
@@ -1921,8 +2947,8 @@ var iDrawCore = function() {
|
|
|
1921
2947
|
this._event = new LoaderEvent();
|
|
1922
2948
|
this._waitingLoadQueue = [];
|
|
1923
2949
|
}
|
|
1924
|
-
load(data, changeResourceUUIDs) {
|
|
1925
|
-
|
|
2950
|
+
Loader2.prototype.load = function(data, changeResourceUUIDs) {
|
|
2951
|
+
var _a2 = this._resetLoadData(data, changeResourceUUIDs), uuidQueue = _a2[0], loadData = _a2[1];
|
|
1926
2952
|
if (this._status === LoaderStatus.FREE || this._status === LoaderStatus.COMPLETE) {
|
|
1927
2953
|
this._currentUUIDQueue = uuidQueue;
|
|
1928
2954
|
this._currentLoadData = loadData;
|
|
@@ -1933,29 +2959,29 @@ var iDrawCore = function() {
|
|
|
1933
2959
|
loadData
|
|
1934
2960
|
});
|
|
1935
2961
|
}
|
|
1936
|
-
}
|
|
1937
|
-
on(name, callback) {
|
|
2962
|
+
};
|
|
2963
|
+
Loader2.prototype.on = function(name, callback) {
|
|
1938
2964
|
this._event.on(name, callback);
|
|
1939
|
-
}
|
|
1940
|
-
off(name, callback) {
|
|
2965
|
+
};
|
|
2966
|
+
Loader2.prototype.off = function(name, callback) {
|
|
1941
2967
|
this._event.off(name, callback);
|
|
1942
|
-
}
|
|
1943
|
-
isComplete() {
|
|
2968
|
+
};
|
|
2969
|
+
Loader2.prototype.isComplete = function() {
|
|
1944
2970
|
return this._status === LoaderStatus.COMPLETE;
|
|
1945
|
-
}
|
|
1946
|
-
getContent(uuid) {
|
|
2971
|
+
};
|
|
2972
|
+
Loader2.prototype.getContent = function(uuid) {
|
|
1947
2973
|
var _a2;
|
|
1948
2974
|
if (((_a2 = this._storageLoadData[uuid]) === null || _a2 === void 0 ? void 0 : _a2.status) === "loaded") {
|
|
1949
2975
|
return this._storageLoadData[uuid].content;
|
|
1950
2976
|
}
|
|
1951
2977
|
return null;
|
|
1952
|
-
}
|
|
1953
|
-
_resetLoadData(data, changeResourceUUIDs) {
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
for (
|
|
1958
|
-
|
|
2978
|
+
};
|
|
2979
|
+
Loader2.prototype._resetLoadData = function(data, changeResourceUUIDs) {
|
|
2980
|
+
var loadData = {};
|
|
2981
|
+
var uuidQueue = [];
|
|
2982
|
+
var storageLoadData = this._storageLoadData;
|
|
2983
|
+
for (var i = data.elements.length - 1; i >= 0; i--) {
|
|
2984
|
+
var elem = data.elements[i];
|
|
1959
2985
|
if (["image", "svg", "html"].includes(elem.type)) {
|
|
1960
2986
|
if (!storageLoadData[elem.uuid]) {
|
|
1961
2987
|
loadData[elem.uuid] = this._createEmptyLoadItem(elem);
|
|
@@ -1969,20 +2995,20 @@ var iDrawCore = function() {
|
|
|
1969
2995
|
}
|
|
1970
2996
|
}
|
|
1971
2997
|
return [uuidQueue, loadData];
|
|
1972
|
-
}
|
|
1973
|
-
_createEmptyLoadItem(elem) {
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
2998
|
+
};
|
|
2999
|
+
Loader2.prototype._createEmptyLoadItem = function(elem) {
|
|
3000
|
+
var source = "";
|
|
3001
|
+
var type = elem.type;
|
|
3002
|
+
var elemW = elem.w;
|
|
3003
|
+
var elemH = elem.h;
|
|
1978
3004
|
if (elem.type === "image") {
|
|
1979
|
-
|
|
3005
|
+
var _elem = elem;
|
|
1980
3006
|
source = _elem.desc.src || "";
|
|
1981
3007
|
} else if (elem.type === "svg") {
|
|
1982
|
-
|
|
3008
|
+
var _elem = elem;
|
|
1983
3009
|
source = _elem.desc.svg || "";
|
|
1984
3010
|
} else if (elem.type === "html") {
|
|
1985
|
-
|
|
3011
|
+
var _elem = elem;
|
|
1986
3012
|
source = filterScript(_elem.desc.html || "");
|
|
1987
3013
|
elemW = _elem.desc.width || elem.w;
|
|
1988
3014
|
elemH = _elem.desc.height || elem.h;
|
|
@@ -1997,8 +3023,9 @@ var iDrawCore = function() {
|
|
|
1997
3023
|
elemH,
|
|
1998
3024
|
element: deepClone(elem)
|
|
1999
3025
|
};
|
|
2000
|
-
}
|
|
2001
|
-
_loadTask() {
|
|
3026
|
+
};
|
|
3027
|
+
Loader2.prototype._loadTask = function() {
|
|
3028
|
+
var _this = this;
|
|
2002
3029
|
if (this._status === LoaderStatus.LOADING) {
|
|
2003
3030
|
return;
|
|
2004
3031
|
}
|
|
@@ -2009,137 +3036,160 @@ var iDrawCore = function() {
|
|
|
2009
3036
|
this._event.trigger("complete", void 0);
|
|
2010
3037
|
return;
|
|
2011
3038
|
} else {
|
|
2012
|
-
|
|
3039
|
+
var waitingItem = this._waitingLoadQueue.shift();
|
|
2013
3040
|
if (waitingItem) {
|
|
2014
|
-
|
|
3041
|
+
var uuidQueue = waitingItem.uuidQueue, loadData = waitingItem.loadData;
|
|
2015
3042
|
this._currentLoadData = loadData;
|
|
2016
3043
|
this._currentUUIDQueue = uuidQueue;
|
|
2017
3044
|
}
|
|
2018
3045
|
}
|
|
2019
3046
|
}
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
uuids.forEach((url, i)
|
|
3047
|
+
var maxParallelNum = this._opts.maxParallelNum;
|
|
3048
|
+
var uuids = this._currentUUIDQueue.splice(0, maxParallelNum);
|
|
3049
|
+
uuids.forEach(function(url, i) {
|
|
2023
3050
|
});
|
|
2024
|
-
|
|
2025
|
-
|
|
3051
|
+
var loadUUIDList = [];
|
|
3052
|
+
var _loadAction = function() {
|
|
2026
3053
|
if (loadUUIDList.length >= maxParallelNum) {
|
|
2027
3054
|
return false;
|
|
2028
3055
|
}
|
|
2029
3056
|
if (uuids.length === 0) {
|
|
2030
3057
|
return true;
|
|
2031
3058
|
}
|
|
2032
|
-
|
|
2033
|
-
|
|
3059
|
+
var _loop_1 = function(i2) {
|
|
3060
|
+
var uuid = uuids.shift();
|
|
2034
3061
|
if (uuid === void 0) {
|
|
2035
|
-
break;
|
|
3062
|
+
return "break";
|
|
2036
3063
|
}
|
|
2037
3064
|
loadUUIDList.push(uuid);
|
|
2038
|
-
|
|
3065
|
+
_this._loadElementSource(_this._currentLoadData[uuid]).then(function(image) {
|
|
2039
3066
|
var _a2, _b2;
|
|
2040
3067
|
loadUUIDList.splice(loadUUIDList.indexOf(uuid), 1);
|
|
2041
|
-
|
|
2042
|
-
|
|
3068
|
+
var status = _loadAction();
|
|
3069
|
+
_this._storageLoadData[uuid] = {
|
|
2043
3070
|
uuid,
|
|
2044
|
-
type:
|
|
3071
|
+
type: _this._currentLoadData[uuid].type,
|
|
2045
3072
|
status: "loaded",
|
|
2046
3073
|
content: image,
|
|
2047
|
-
source:
|
|
2048
|
-
elemW:
|
|
2049
|
-
elemH:
|
|
2050
|
-
element:
|
|
3074
|
+
source: _this._currentLoadData[uuid].source,
|
|
3075
|
+
elemW: _this._currentLoadData[uuid].elemW,
|
|
3076
|
+
elemH: _this._currentLoadData[uuid].elemH,
|
|
3077
|
+
element: _this._currentLoadData[uuid].element
|
|
2051
3078
|
};
|
|
2052
3079
|
if (loadUUIDList.length === 0 && uuids.length === 0 && status === true) {
|
|
2053
|
-
|
|
2054
|
-
|
|
3080
|
+
_this._status = LoaderStatus.FREE;
|
|
3081
|
+
_this._loadTask();
|
|
2055
3082
|
}
|
|
2056
|
-
|
|
2057
|
-
uuid: (_a2 =
|
|
2058
|
-
type:
|
|
2059
|
-
status:
|
|
2060
|
-
content:
|
|
2061
|
-
source:
|
|
2062
|
-
elemW:
|
|
2063
|
-
elemH:
|
|
2064
|
-
element: (_b2 =
|
|
3083
|
+
_this._event.trigger("load", {
|
|
3084
|
+
uuid: (_a2 = _this._storageLoadData[uuid]) === null || _a2 === void 0 ? void 0 : _a2.uuid,
|
|
3085
|
+
type: _this._storageLoadData[uuid].type,
|
|
3086
|
+
status: _this._storageLoadData[uuid].status,
|
|
3087
|
+
content: _this._storageLoadData[uuid].content,
|
|
3088
|
+
source: _this._storageLoadData[uuid].source,
|
|
3089
|
+
elemW: _this._storageLoadData[uuid].elemW,
|
|
3090
|
+
elemH: _this._storageLoadData[uuid].elemH,
|
|
3091
|
+
element: (_b2 = _this._storageLoadData[uuid]) === null || _b2 === void 0 ? void 0 : _b2.element
|
|
2065
3092
|
});
|
|
2066
|
-
}).catch((err)
|
|
3093
|
+
}).catch(function(err) {
|
|
2067
3094
|
var _a2, _b2, _c2, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
2068
3095
|
console.warn(err);
|
|
2069
3096
|
loadUUIDList.splice(loadUUIDList.indexOf(uuid), 1);
|
|
2070
|
-
|
|
2071
|
-
if (
|
|
2072
|
-
|
|
3097
|
+
var status = _loadAction();
|
|
3098
|
+
if (_this._currentLoadData[uuid]) {
|
|
3099
|
+
_this._storageLoadData[uuid] = {
|
|
2073
3100
|
uuid,
|
|
2074
|
-
type: (_a2 =
|
|
3101
|
+
type: (_a2 = _this._currentLoadData[uuid]) === null || _a2 === void 0 ? void 0 : _a2.type,
|
|
2075
3102
|
status: "fail",
|
|
2076
3103
|
content: null,
|
|
2077
3104
|
error: err,
|
|
2078
|
-
source: (_b2 =
|
|
2079
|
-
elemW: (_c2 =
|
|
2080
|
-
elemH: (_d =
|
|
2081
|
-
element: (_e =
|
|
3105
|
+
source: (_b2 = _this._currentLoadData[uuid]) === null || _b2 === void 0 ? void 0 : _b2.source,
|
|
3106
|
+
elemW: (_c2 = _this._currentLoadData[uuid]) === null || _c2 === void 0 ? void 0 : _c2.elemW,
|
|
3107
|
+
elemH: (_d = _this._currentLoadData[uuid]) === null || _d === void 0 ? void 0 : _d.elemH,
|
|
3108
|
+
element: (_e = _this._currentLoadData[uuid]) === null || _e === void 0 ? void 0 : _e.element
|
|
2082
3109
|
};
|
|
2083
3110
|
}
|
|
2084
3111
|
if (loadUUIDList.length === 0 && uuids.length === 0 && status === true) {
|
|
2085
|
-
|
|
2086
|
-
|
|
3112
|
+
_this._status = LoaderStatus.FREE;
|
|
3113
|
+
_this._loadTask();
|
|
2087
3114
|
}
|
|
2088
|
-
if (
|
|
2089
|
-
|
|
3115
|
+
if (_this._currentLoadData[uuid]) {
|
|
3116
|
+
_this._event.trigger("error", {
|
|
2090
3117
|
uuid,
|
|
2091
|
-
type: (_f =
|
|
2092
|
-
status: (_g =
|
|
2093
|
-
content: (_h =
|
|
2094
|
-
source: (_j =
|
|
2095
|
-
elemW: (_k =
|
|
2096
|
-
elemH: (_l =
|
|
2097
|
-
element: (_m =
|
|
3118
|
+
type: (_f = _this._storageLoadData[uuid]) === null || _f === void 0 ? void 0 : _f.type,
|
|
3119
|
+
status: (_g = _this._storageLoadData[uuid]) === null || _g === void 0 ? void 0 : _g.status,
|
|
3120
|
+
content: (_h = _this._storageLoadData[uuid]) === null || _h === void 0 ? void 0 : _h.content,
|
|
3121
|
+
source: (_j = _this._storageLoadData[uuid]) === null || _j === void 0 ? void 0 : _j.source,
|
|
3122
|
+
elemW: (_k = _this._storageLoadData[uuid]) === null || _k === void 0 ? void 0 : _k.elemW,
|
|
3123
|
+
elemH: (_l = _this._storageLoadData[uuid]) === null || _l === void 0 ? void 0 : _l.elemH,
|
|
3124
|
+
element: (_m = _this._storageLoadData[uuid]) === null || _m === void 0 ? void 0 : _m.element
|
|
2098
3125
|
});
|
|
2099
3126
|
}
|
|
2100
3127
|
});
|
|
3128
|
+
};
|
|
3129
|
+
for (var i = loadUUIDList.length; i < maxParallelNum; i++) {
|
|
3130
|
+
var state_1 = _loop_1();
|
|
3131
|
+
if (state_1 === "break")
|
|
3132
|
+
break;
|
|
2101
3133
|
}
|
|
2102
3134
|
return false;
|
|
2103
3135
|
};
|
|
2104
3136
|
_loadAction();
|
|
2105
|
-
}
|
|
2106
|
-
_loadElementSource(params) {
|
|
2107
|
-
return __awaiter(this, void 0, void 0, function
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
3137
|
+
};
|
|
3138
|
+
Loader2.prototype._loadElementSource = function(params) {
|
|
3139
|
+
return __awaiter$1(this, void 0, void 0, function() {
|
|
3140
|
+
var image, image, image;
|
|
3141
|
+
return __generator$1(this, function(_a2) {
|
|
3142
|
+
switch (_a2.label) {
|
|
3143
|
+
case 0:
|
|
3144
|
+
if (!(params && params.type === "image"))
|
|
3145
|
+
return [3, 2];
|
|
3146
|
+
return [4, loadImage(params.source)];
|
|
3147
|
+
case 1:
|
|
3148
|
+
image = _a2.sent();
|
|
3149
|
+
return [2, image];
|
|
3150
|
+
case 2:
|
|
3151
|
+
if (!(params && params.type === "svg"))
|
|
3152
|
+
return [3, 4];
|
|
3153
|
+
return [4, loadSVG(params.source)];
|
|
3154
|
+
case 3:
|
|
3155
|
+
image = _a2.sent();
|
|
3156
|
+
return [2, image];
|
|
3157
|
+
case 4:
|
|
3158
|
+
if (!(params && params.type === "html"))
|
|
3159
|
+
return [3, 6];
|
|
3160
|
+
return [4, loadHTML(params.source, {
|
|
3161
|
+
width: params.elemW,
|
|
3162
|
+
height: params.elemH
|
|
3163
|
+
})];
|
|
3164
|
+
case 5:
|
|
3165
|
+
image = _a2.sent();
|
|
3166
|
+
return [2, image];
|
|
3167
|
+
case 6:
|
|
3168
|
+
throw Error("Element's source is not support!");
|
|
3169
|
+
}
|
|
3170
|
+
});
|
|
2122
3171
|
});
|
|
2123
|
-
}
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
3172
|
+
};
|
|
3173
|
+
return Loader2;
|
|
3174
|
+
}();
|
|
3175
|
+
var RendererEvent = function() {
|
|
3176
|
+
function RendererEvent2() {
|
|
2127
3177
|
this._listeners = /* @__PURE__ */ new Map();
|
|
2128
3178
|
}
|
|
2129
|
-
on(eventKey, callback) {
|
|
3179
|
+
RendererEvent2.prototype.on = function(eventKey, callback) {
|
|
2130
3180
|
if (this._listeners.has(eventKey)) {
|
|
2131
|
-
|
|
3181
|
+
var callbacks = this._listeners.get(eventKey);
|
|
2132
3182
|
callbacks === null || callbacks === void 0 ? void 0 : callbacks.push(callback);
|
|
2133
3183
|
this._listeners.set(eventKey, callbacks || []);
|
|
2134
3184
|
} else {
|
|
2135
3185
|
this._listeners.set(eventKey, [callback]);
|
|
2136
3186
|
}
|
|
2137
|
-
}
|
|
2138
|
-
off(eventKey, callback) {
|
|
3187
|
+
};
|
|
3188
|
+
RendererEvent2.prototype.off = function(eventKey, callback) {
|
|
2139
3189
|
if (this._listeners.has(eventKey)) {
|
|
2140
|
-
|
|
3190
|
+
var callbacks = this._listeners.get(eventKey);
|
|
2141
3191
|
if (Array.isArray(callbacks)) {
|
|
2142
|
-
for (
|
|
3192
|
+
for (var i = 0; i < (callbacks === null || callbacks === void 0 ? void 0 : callbacks.length); i++) {
|
|
2143
3193
|
if (callbacks[i] === callback) {
|
|
2144
3194
|
callbacks.splice(i, 1);
|
|
2145
3195
|
break;
|
|
@@ -2148,38 +3198,39 @@ var iDrawCore = function() {
|
|
|
2148
3198
|
}
|
|
2149
3199
|
this._listeners.set(eventKey, callbacks || []);
|
|
2150
3200
|
}
|
|
2151
|
-
}
|
|
2152
|
-
trigger(eventKey, arg) {
|
|
2153
|
-
|
|
3201
|
+
};
|
|
3202
|
+
RendererEvent2.prototype.trigger = function(eventKey, arg) {
|
|
3203
|
+
var callbacks = this._listeners.get(eventKey);
|
|
2154
3204
|
if (Array.isArray(callbacks)) {
|
|
2155
|
-
callbacks.forEach((cb)
|
|
3205
|
+
callbacks.forEach(function(cb) {
|
|
2156
3206
|
cb(arg);
|
|
2157
3207
|
});
|
|
2158
3208
|
return true;
|
|
2159
3209
|
} else {
|
|
2160
3210
|
return false;
|
|
2161
3211
|
}
|
|
2162
|
-
}
|
|
2163
|
-
has(name) {
|
|
3212
|
+
};
|
|
3213
|
+
RendererEvent2.prototype.has = function(name) {
|
|
2164
3214
|
if (this._listeners.has(name)) {
|
|
2165
|
-
|
|
3215
|
+
var list = this._listeners.get(name);
|
|
2166
3216
|
if (Array.isArray(list) && list.length > 0) {
|
|
2167
3217
|
return true;
|
|
2168
3218
|
}
|
|
2169
3219
|
}
|
|
2170
3220
|
return false;
|
|
2171
|
-
}
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
var
|
|
2182
|
-
|
|
3221
|
+
};
|
|
3222
|
+
return RendererEvent2;
|
|
3223
|
+
}();
|
|
3224
|
+
var _queue = Symbol("_queue");
|
|
3225
|
+
var _ctx = Symbol("_ctx");
|
|
3226
|
+
var _status = Symbol("_status");
|
|
3227
|
+
var _loader = Symbol("_loader");
|
|
3228
|
+
var _opts$1 = Symbol("_opts");
|
|
3229
|
+
var _freeze = Symbol("_freeze");
|
|
3230
|
+
var _drawFrame = Symbol("_drawFrame");
|
|
3231
|
+
var _retainQueueOneItem = Symbol("_retainQueueOneItem");
|
|
3232
|
+
var _a, _b, _c;
|
|
3233
|
+
var requestAnimationFrame = window.requestAnimationFrame;
|
|
2183
3234
|
var DrawStatus;
|
|
2184
3235
|
(function(DrawStatus2) {
|
|
2185
3236
|
DrawStatus2["NULL"] = "null";
|
|
@@ -2187,51 +3238,53 @@ var iDrawCore = function() {
|
|
|
2187
3238
|
DrawStatus2["DRAWING"] = "drawing";
|
|
2188
3239
|
DrawStatus2["FREEZE"] = "freeze";
|
|
2189
3240
|
})(DrawStatus || (DrawStatus = {}));
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
3241
|
+
var Renderer = function(_super) {
|
|
3242
|
+
__extends(Renderer2, _super);
|
|
3243
|
+
function Renderer2(opts) {
|
|
3244
|
+
var _this = _super.call(this) || this;
|
|
3245
|
+
_this[_a] = [];
|
|
3246
|
+
_this[_b] = null;
|
|
3247
|
+
_this[_c] = DrawStatus.NULL;
|
|
3248
|
+
_this[_opts$1] = opts;
|
|
3249
|
+
_this[_loader] = new Loader({
|
|
2198
3250
|
maxParallelNum: 6
|
|
2199
3251
|
});
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
3252
|
+
_this[_loader].on("load", function(res) {
|
|
3253
|
+
_this[_drawFrame]();
|
|
3254
|
+
_this.trigger("load", { element: res.element });
|
|
2203
3255
|
});
|
|
2204
|
-
|
|
2205
|
-
|
|
3256
|
+
_this[_loader].on("error", function(res) {
|
|
3257
|
+
_this.trigger("error", { element: res.element, error: res.error });
|
|
2206
3258
|
});
|
|
2207
|
-
|
|
2208
|
-
|
|
3259
|
+
_this[_loader].on("complete", function() {
|
|
3260
|
+
_this.trigger("loadComplete", { t: Date.now() });
|
|
2209
3261
|
});
|
|
3262
|
+
return _this;
|
|
2210
3263
|
}
|
|
2211
|
-
render(target, originData, opts) {
|
|
2212
|
-
|
|
3264
|
+
Renderer2.prototype.render = function(target, originData, opts) {
|
|
3265
|
+
var _d = (opts || {}).changeResourceUUIDs, changeResourceUUIDs = _d === void 0 ? [] : _d;
|
|
2213
3266
|
this[_status] = DrawStatus.FREE;
|
|
2214
|
-
|
|
3267
|
+
var data = deepClone(originData);
|
|
2215
3268
|
if (Array.isArray(data.elements)) {
|
|
2216
|
-
data.elements.forEach((elem)
|
|
3269
|
+
data.elements.forEach(function(elem) {
|
|
2217
3270
|
if (!(typeof elem.uuid === "string" && elem.uuid)) {
|
|
2218
3271
|
elem.uuid = createUUID();
|
|
2219
3272
|
}
|
|
2220
3273
|
});
|
|
2221
3274
|
}
|
|
2222
3275
|
if (!this[_ctx]) {
|
|
2223
|
-
if (this[_opts$
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
canvas.width = width *
|
|
2227
|
-
canvas.height = height *
|
|
2228
|
-
|
|
2229
|
-
this[_ctx] = new Context
|
|
3276
|
+
if (this[_opts$1] && Object.prototype.toString.call(target) === "[object HTMLCanvasElement]") {
|
|
3277
|
+
var _e = this[_opts$1], width = _e.width, height = _e.height, contextWidth = _e.contextWidth, contextHeight = _e.contextHeight, devicePixelRatio_1 = _e.devicePixelRatio;
|
|
3278
|
+
var canvas = target;
|
|
3279
|
+
canvas.width = width * devicePixelRatio_1;
|
|
3280
|
+
canvas.height = height * devicePixelRatio_1;
|
|
3281
|
+
var ctx2d = canvas.getContext("2d");
|
|
3282
|
+
this[_ctx] = new Context(ctx2d, {
|
|
2230
3283
|
width,
|
|
2231
3284
|
height,
|
|
2232
3285
|
contextWidth: contextWidth || width,
|
|
2233
3286
|
contextHeight: contextHeight || height,
|
|
2234
|
-
devicePixelRatio
|
|
3287
|
+
devicePixelRatio: devicePixelRatio_1
|
|
2235
3288
|
});
|
|
2236
3289
|
} else if (target) {
|
|
2237
3290
|
this[_ctx] = target;
|
|
@@ -2240,70 +3293,76 @@ var iDrawCore = function() {
|
|
|
2240
3293
|
if ([DrawStatus.FREEZE].includes(this[_status])) {
|
|
2241
3294
|
return;
|
|
2242
3295
|
}
|
|
2243
|
-
|
|
2244
|
-
this[_queue].push(
|
|
3296
|
+
var _data = deepClone({ data });
|
|
3297
|
+
this[_queue].push(_data);
|
|
2245
3298
|
this[_drawFrame]();
|
|
2246
3299
|
this[_loader].load(data, changeResourceUUIDs || []);
|
|
2247
|
-
}
|
|
2248
|
-
getContext() {
|
|
3300
|
+
};
|
|
3301
|
+
Renderer2.prototype.getContext = function() {
|
|
2249
3302
|
return this[_ctx];
|
|
2250
|
-
}
|
|
2251
|
-
thaw() {
|
|
3303
|
+
};
|
|
3304
|
+
Renderer2.prototype.thaw = function() {
|
|
2252
3305
|
this[_status] = DrawStatus.FREE;
|
|
2253
|
-
}
|
|
2254
|
-
[
|
|
3306
|
+
};
|
|
3307
|
+
Renderer2.prototype[_a = _queue, _b = _ctx, _c = _status, _freeze] = function() {
|
|
2255
3308
|
this[_status] = DrawStatus.FREEZE;
|
|
2256
|
-
}
|
|
2257
|
-
[_drawFrame]() {
|
|
3309
|
+
};
|
|
3310
|
+
Renderer2.prototype[_drawFrame] = function() {
|
|
3311
|
+
var _this = this;
|
|
2258
3312
|
if (this[_status] === DrawStatus.FREEZE) {
|
|
2259
3313
|
return;
|
|
2260
3314
|
}
|
|
2261
|
-
requestAnimationFrame(()
|
|
2262
|
-
if (
|
|
3315
|
+
requestAnimationFrame(function() {
|
|
3316
|
+
if (_this[_status] === DrawStatus.FREEZE) {
|
|
2263
3317
|
return;
|
|
2264
3318
|
}
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
if (
|
|
2269
|
-
item =
|
|
3319
|
+
var ctx = _this[_ctx];
|
|
3320
|
+
var item = _this[_queue][0];
|
|
3321
|
+
var isLastFrame = false;
|
|
3322
|
+
if (_this[_queue].length > 1) {
|
|
3323
|
+
item = _this[_queue].shift();
|
|
2270
3324
|
} else {
|
|
2271
3325
|
isLastFrame = true;
|
|
2272
3326
|
}
|
|
2273
|
-
if (
|
|
2274
|
-
|
|
3327
|
+
if (_this[_loader].isComplete() !== true) {
|
|
3328
|
+
_this[_drawFrame]();
|
|
2275
3329
|
if (item && ctx) {
|
|
2276
|
-
drawContext(ctx, item.data,
|
|
3330
|
+
drawContext(ctx, item.data, _this[_loader]);
|
|
2277
3331
|
}
|
|
2278
3332
|
} else if (item && ctx) {
|
|
2279
|
-
drawContext(ctx, item.data,
|
|
2280
|
-
|
|
3333
|
+
drawContext(ctx, item.data, _this[_loader]);
|
|
3334
|
+
_this[_retainQueueOneItem]();
|
|
2281
3335
|
if (!isLastFrame) {
|
|
2282
|
-
|
|
3336
|
+
_this[_drawFrame]();
|
|
2283
3337
|
} else {
|
|
2284
|
-
|
|
3338
|
+
_this[_status] = DrawStatus.FREE;
|
|
2285
3339
|
}
|
|
2286
3340
|
} else {
|
|
2287
|
-
|
|
3341
|
+
_this[_status] = DrawStatus.FREE;
|
|
2288
3342
|
}
|
|
2289
|
-
|
|
2290
|
-
if (
|
|
2291
|
-
if (ctx &&
|
|
2292
|
-
drawContext(ctx,
|
|
3343
|
+
_this.trigger("drawFrame", { t: Date.now() });
|
|
3344
|
+
if (_this[_loader].isComplete() === true && _this[_queue].length === 1 && _this[_status] === DrawStatus.FREE) {
|
|
3345
|
+
if (ctx && _this[_queue][0] && _this[_queue][0].data) {
|
|
3346
|
+
drawContext(ctx, _this[_queue][0].data, _this[_loader]);
|
|
2293
3347
|
}
|
|
2294
|
-
|
|
2295
|
-
|
|
3348
|
+
_this.trigger("drawFrameComplete", { t: Date.now() });
|
|
3349
|
+
_this[_freeze]();
|
|
2296
3350
|
}
|
|
2297
3351
|
});
|
|
2298
|
-
}
|
|
2299
|
-
[_retainQueueOneItem]() {
|
|
3352
|
+
};
|
|
3353
|
+
Renderer2.prototype[_retainQueueOneItem] = function() {
|
|
2300
3354
|
if (this[_queue].length <= 1) {
|
|
2301
3355
|
return;
|
|
2302
3356
|
}
|
|
2303
|
-
|
|
3357
|
+
var lastOne = deepClone(this[_queue][this[_queue].length - 1]);
|
|
2304
3358
|
this[_queue] = [lastOne];
|
|
2305
|
-
}
|
|
2306
|
-
|
|
3359
|
+
};
|
|
3360
|
+
return Renderer2;
|
|
3361
|
+
}(RendererEvent);
|
|
3362
|
+
var default_1 = /* @__PURE__ */ Object.freeze({
|
|
3363
|
+
__proto__: null,
|
|
3364
|
+
Renderer
|
|
3365
|
+
});
|
|
2307
3366
|
function number(value) {
|
|
2308
3367
|
return typeof value === "number" && (value > 0 || value <= 0);
|
|
2309
3368
|
}
|
|
@@ -2329,7 +3388,7 @@ var iDrawCore = function() {
|
|
|
2329
3388
|
return number(value) && value >= 0;
|
|
2330
3389
|
}
|
|
2331
3390
|
function color(value) {
|
|
2332
|
-
return isColorStr(value);
|
|
3391
|
+
return isColorStr$1(value);
|
|
2333
3392
|
}
|
|
2334
3393
|
function imageURL(value) {
|
|
2335
3394
|
return typeof value === "string" && /^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${value}`);
|
|
@@ -2588,7 +3647,7 @@ var iDrawCore = function() {
|
|
|
2588
3647
|
}
|
|
2589
3648
|
};
|
|
2590
3649
|
function mergeConfig(config) {
|
|
2591
|
-
const result = deepClone(defaultConfig);
|
|
3650
|
+
const result = deepClone$1(defaultConfig);
|
|
2592
3651
|
if (config) {
|
|
2593
3652
|
if (config.elementWrapper) {
|
|
2594
3653
|
result.elementWrapper = {
|
|
@@ -2789,7 +3848,7 @@ var iDrawCore = function() {
|
|
|
2789
3848
|
initData(data) {
|
|
2790
3849
|
data.elements.forEach((elem) => {
|
|
2791
3850
|
if (!(elem.uuid && typeof elem.uuid === "string")) {
|
|
2792
|
-
elem.uuid = createUUID();
|
|
3851
|
+
elem.uuid = createUUID$1();
|
|
2793
3852
|
}
|
|
2794
3853
|
});
|
|
2795
3854
|
return data;
|
|
@@ -2894,10 +3953,10 @@ var iDrawCore = function() {
|
|
|
2894
3953
|
elem.angle = limitAngle(elem.angle || 0);
|
|
2895
3954
|
}
|
|
2896
3955
|
}
|
|
2897
|
-
function calcuScaleElemPosition(elem, moveX, moveY, direction
|
|
3956
|
+
function calcuScaleElemPosition(elem, moveX, moveY, direction) {
|
|
2898
3957
|
var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
2899
3958
|
const p = { x: elem.x, y: elem.y, w: elem.w, h: elem.h };
|
|
2900
|
-
elem.angle;
|
|
3959
|
+
elem.angle || 0;
|
|
2901
3960
|
if (((_a2 = elem.operation) == null ? void 0 : _a2.limitRatio) === true) {
|
|
2902
3961
|
if (["top-left", "top-right", "bottom-right", "bottom-left"].includes(
|
|
2903
3962
|
direction
|
|
@@ -2918,7 +3977,7 @@ var iDrawCore = function() {
|
|
|
2918
3977
|
break;
|
|
2919
3978
|
}
|
|
2920
3979
|
case "top": {
|
|
2921
|
-
if (elem.angle === 0 || Math.abs(elem.angle) < limitQbliqueAngle$1) {
|
|
3980
|
+
if (elem.angle === 0 || Math.abs(elem.angle || 0) < limitQbliqueAngle$1) {
|
|
2922
3981
|
if (p.h - moveY > 0) {
|
|
2923
3982
|
p.y += moveY;
|
|
2924
3983
|
p.h -= moveY;
|
|
@@ -2927,7 +3986,7 @@ var iDrawCore = function() {
|
|
|
2927
3986
|
p.w -= moveY / elem.h * elem.w;
|
|
2928
3987
|
}
|
|
2929
3988
|
}
|
|
2930
|
-
} else if (elem.angle > 0 || elem.angle < 0) {
|
|
3989
|
+
} else if (elem.angle !== void 0 && (elem.angle > 0 || elem.angle < 0)) {
|
|
2931
3990
|
const angle2 = elem.angle > 0 ? elem.angle : Math.max(0, elem.angle + 360);
|
|
2932
3991
|
let moveDist = calcMoveDist(moveX, moveY);
|
|
2933
3992
|
let centerX = p.x + elem.w / 2;
|
|
@@ -2986,7 +4045,7 @@ var iDrawCore = function() {
|
|
|
2986
4045
|
break;
|
|
2987
4046
|
}
|
|
2988
4047
|
case "right": {
|
|
2989
|
-
if (elem.angle === 0 || Math.abs(elem.angle) < limitQbliqueAngle$1) {
|
|
4048
|
+
if (elem.angle === 0 || Math.abs(elem.angle || 0) < limitQbliqueAngle$1) {
|
|
2990
4049
|
if (elem.w + moveX > 0) {
|
|
2991
4050
|
p.w += moveX;
|
|
2992
4051
|
if (((_e = elem.operation) == null ? void 0 : _e.limitRatio) === true) {
|
|
@@ -2994,7 +4053,7 @@ var iDrawCore = function() {
|
|
|
2994
4053
|
p.h += moveX * elem.h / elem.w;
|
|
2995
4054
|
}
|
|
2996
4055
|
}
|
|
2997
|
-
} else if (elem.angle > 0 || elem.angle < 0) {
|
|
4056
|
+
} else if (elem.angle !== void 0 && (elem.angle > 0 || elem.angle < 0)) {
|
|
2998
4057
|
const angle2 = elem.angle > 0 ? elem.angle : Math.max(0, elem.angle + 360);
|
|
2999
4058
|
let moveDist = calcMoveDist(moveX, moveY);
|
|
3000
4059
|
let centerX = p.x + elem.w / 2;
|
|
@@ -3052,7 +4111,7 @@ var iDrawCore = function() {
|
|
|
3052
4111
|
break;
|
|
3053
4112
|
}
|
|
3054
4113
|
case "bottom": {
|
|
3055
|
-
if (elem.angle === 0 || Math.abs(elem.angle) < limitQbliqueAngle$1) {
|
|
4114
|
+
if (elem.angle === 0 || Math.abs(elem.angle || 0) < limitQbliqueAngle$1) {
|
|
3056
4115
|
if (elem.h + moveY > 0) {
|
|
3057
4116
|
p.h += moveY;
|
|
3058
4117
|
if (((_h = elem.operation) == null ? void 0 : _h.limitRatio) === true) {
|
|
@@ -3060,7 +4119,7 @@ var iDrawCore = function() {
|
|
|
3060
4119
|
p.w += moveY / elem.h * elem.w;
|
|
3061
4120
|
}
|
|
3062
4121
|
}
|
|
3063
|
-
} else if (elem.angle > 0 || elem.angle < 0) {
|
|
4122
|
+
} else if (elem.angle !== void 0 && (elem.angle > 0 || elem.angle < 0)) {
|
|
3064
4123
|
const angle2 = elem.angle > 0 ? elem.angle : Math.max(0, elem.angle + 360);
|
|
3065
4124
|
let moveDist = calcMoveDist(moveX, moveY);
|
|
3066
4125
|
let centerX = p.x + elem.w / 2;
|
|
@@ -3118,7 +4177,7 @@ var iDrawCore = function() {
|
|
|
3118
4177
|
break;
|
|
3119
4178
|
}
|
|
3120
4179
|
case "left": {
|
|
3121
|
-
if (elem.angle === 0 || Math.abs(elem.angle) < limitQbliqueAngle$1) {
|
|
4180
|
+
if (elem.angle === 0 || Math.abs(elem.angle || 0) < limitQbliqueAngle$1) {
|
|
3122
4181
|
if (elem.w - moveX > 0) {
|
|
3123
4182
|
p.x += moveX;
|
|
3124
4183
|
p.w -= moveX;
|
|
@@ -3127,7 +4186,7 @@ var iDrawCore = function() {
|
|
|
3127
4186
|
p.y += moveX / elem.w * elem.h / 2;
|
|
3128
4187
|
}
|
|
3129
4188
|
}
|
|
3130
|
-
} else if (elem.angle > 0 || elem.angle < 0) {
|
|
4189
|
+
} else if (elem.angle !== void 0 && (elem.angle > 0 || elem.angle < 0)) {
|
|
3131
4190
|
const angle2 = elem.angle > 0 ? elem.angle : Math.max(0, elem.angle + 360);
|
|
3132
4191
|
let moveDist = calcMoveDist(moveX, moveY);
|
|
3133
4192
|
let centerX = p.x + elem.w / 2;
|
|
@@ -3207,7 +4266,7 @@ var iDrawCore = function() {
|
|
|
3207
4266
|
this._updateSelectedElementListWrapper(data, opts);
|
|
3208
4267
|
}
|
|
3209
4268
|
getConfig() {
|
|
3210
|
-
return deepClone(this._helperConfig);
|
|
4269
|
+
return deepClone$1(this._helperConfig);
|
|
3211
4270
|
}
|
|
3212
4271
|
getElementIndexByUUID(uuid) {
|
|
3213
4272
|
const index = this._helperConfig.elementIndexMap[uuid];
|
|
@@ -3252,7 +4311,7 @@ var iDrawCore = function() {
|
|
|
3252
4311
|
"bottom",
|
|
3253
4312
|
"bottom-right"
|
|
3254
4313
|
];
|
|
3255
|
-
let hoverDirectionNames = deepClone(directionNames);
|
|
4314
|
+
let hoverDirectionNames = deepClone$1(directionNames);
|
|
3256
4315
|
let angleMoveNum = 0;
|
|
3257
4316
|
if (data && uuid) {
|
|
3258
4317
|
const elemIdx = this.getElementIndexByUUID(uuid);
|
|
@@ -3547,20 +4606,20 @@ var iDrawCore = function() {
|
|
|
3547
4606
|
return wrapper;
|
|
3548
4607
|
}
|
|
3549
4608
|
}
|
|
3550
|
-
const _board
|
|
4609
|
+
const _board = Symbol("_displayCtx");
|
|
3551
4610
|
const _helper = Symbol("_helper");
|
|
3552
|
-
const _element
|
|
3553
|
-
const _opts
|
|
4611
|
+
const _element = Symbol("_element");
|
|
4612
|
+
const _opts = Symbol("_opts");
|
|
3554
4613
|
class Mapper {
|
|
3555
4614
|
constructor(opts) {
|
|
3556
|
-
this[_opts
|
|
3557
|
-
this[_board
|
|
3558
|
-
this[_element
|
|
3559
|
-
this[_helper] = this[_opts
|
|
4615
|
+
this[_opts] = opts;
|
|
4616
|
+
this[_board] = this[_opts].board;
|
|
4617
|
+
this[_element] = this[_opts].element;
|
|
4618
|
+
this[_helper] = this[_opts].helper;
|
|
3560
4619
|
}
|
|
3561
4620
|
isEffectivePoint(p) {
|
|
3562
|
-
const scrollLineWidth = this[_board
|
|
3563
|
-
const screenInfo = this[_board
|
|
4621
|
+
const scrollLineWidth = this[_board].getScrollLineWidth();
|
|
4622
|
+
const screenInfo = this[_board].getScreenInfo();
|
|
3564
4623
|
if (p.x <= screenInfo.width - scrollLineWidth && p.y <= screenInfo.height - scrollLineWidth) {
|
|
3565
4624
|
return true;
|
|
3566
4625
|
}
|
|
@@ -3617,7 +4676,7 @@ var iDrawCore = function() {
|
|
|
3617
4676
|
elementUUID = uuid;
|
|
3618
4677
|
}
|
|
3619
4678
|
} else {
|
|
3620
|
-
const [index, uuid2] = this[_element
|
|
4679
|
+
const [index, uuid2] = this[_element].isPointInElement(p, data);
|
|
3621
4680
|
if (index >= 0) {
|
|
3622
4681
|
cursor = "move";
|
|
3623
4682
|
}
|
|
@@ -3678,18 +4737,6 @@ var iDrawCore = function() {
|
|
|
3678
4737
|
this._temp = createData$1();
|
|
3679
4738
|
}
|
|
3680
4739
|
};
|
|
3681
|
-
const _board = Symbol("_board");
|
|
3682
|
-
const _data = Symbol("_data");
|
|
3683
|
-
const _opts = Symbol("_opts");
|
|
3684
|
-
const _config = Symbol("_config");
|
|
3685
|
-
const _renderer = Symbol("_renderer");
|
|
3686
|
-
const _element = Symbol("_element");
|
|
3687
|
-
const _tempData = Symbol("_tempData");
|
|
3688
|
-
const _draw = Symbol("_draw");
|
|
3689
|
-
const _coreEvent = Symbol("_coreEvent");
|
|
3690
|
-
const _emitChangeScreen = Symbol("_emitChangeScreen");
|
|
3691
|
-
const _emitChangeData = Symbol("_emitChangeData");
|
|
3692
|
-
const _engine = Symbol("_engine");
|
|
3693
4740
|
var Mode = /* @__PURE__ */ ((Mode2) => {
|
|
3694
4741
|
Mode2["NULL"] = "null";
|
|
3695
4742
|
Mode2["SELECT_ELEMENT"] = "select-element";
|
|
@@ -3706,42 +4753,41 @@ var iDrawCore = function() {
|
|
|
3706
4753
|
function getSelectedElements(core) {
|
|
3707
4754
|
const elems = [];
|
|
3708
4755
|
let list = [];
|
|
3709
|
-
const uuid = core
|
|
4756
|
+
const uuid = core.getEngine().temp.get("selectedUUID");
|
|
3710
4757
|
if (typeof uuid === "string" && uuid) {
|
|
3711
4758
|
list.push(uuid);
|
|
3712
4759
|
} else {
|
|
3713
|
-
list = core
|
|
4760
|
+
list = core.getEngine().temp.get("selectedUUIDList");
|
|
3714
4761
|
}
|
|
3715
4762
|
list.forEach((uuid2) => {
|
|
3716
|
-
|
|
3717
|
-
const index = core[_engine].helper.getElementIndexByUUID(uuid2);
|
|
4763
|
+
const index = core.getEngine().helper.getElementIndexByUUID(uuid2);
|
|
3718
4764
|
if (index !== null && index >= 0) {
|
|
3719
|
-
const elem =
|
|
4765
|
+
const elem = core.$data.elements[index];
|
|
3720
4766
|
if (elem)
|
|
3721
4767
|
elems.push(elem);
|
|
3722
4768
|
}
|
|
3723
4769
|
});
|
|
3724
|
-
return deepClone(elems);
|
|
4770
|
+
return deepClone$1(elems);
|
|
3725
4771
|
}
|
|
3726
4772
|
function getElement(core, uuid) {
|
|
3727
4773
|
let elem = null;
|
|
3728
|
-
const index = core
|
|
3729
|
-
if (index !== null && core
|
|
3730
|
-
elem = deepClone(core
|
|
4774
|
+
const index = core.getEngine().helper.getElementIndexByUUID(uuid);
|
|
4775
|
+
if (index !== null && core.$data.elements[index]) {
|
|
4776
|
+
elem = deepClone$1(core.$data.elements[index]);
|
|
3731
4777
|
}
|
|
3732
4778
|
return elem;
|
|
3733
4779
|
}
|
|
3734
4780
|
function getElementByIndex(core, index) {
|
|
3735
4781
|
let elem = null;
|
|
3736
|
-
if (index >= 0 && core
|
|
3737
|
-
elem = deepClone(core
|
|
4782
|
+
if (index >= 0 && core.$data.elements[index]) {
|
|
4783
|
+
elem = deepClone$1(core.$data.elements[index]);
|
|
3738
4784
|
}
|
|
3739
4785
|
return elem;
|
|
3740
4786
|
}
|
|
3741
4787
|
function updateElement(core, elem) {
|
|
3742
4788
|
var _a2;
|
|
3743
|
-
const _elem = deepClone(elem);
|
|
3744
|
-
const data = core
|
|
4789
|
+
const _elem = deepClone$1(elem);
|
|
4790
|
+
const data = core.getData();
|
|
3745
4791
|
const resourceChangeUUIDs = [];
|
|
3746
4792
|
for (let i = 0; i < data.elements.length; i++) {
|
|
3747
4793
|
if (_elem.uuid === ((_a2 = data.elements[i]) == null ? void 0 : _a2.uuid)) {
|
|
@@ -3753,112 +4799,112 @@ var iDrawCore = function() {
|
|
|
3753
4799
|
break;
|
|
3754
4800
|
}
|
|
3755
4801
|
}
|
|
3756
|
-
core
|
|
3757
|
-
core
|
|
4802
|
+
core.$emitChangeData();
|
|
4803
|
+
core.$draw({ resourceChangeUUIDs });
|
|
3758
4804
|
}
|
|
3759
4805
|
function selectElementByIndex(core, index) {
|
|
3760
|
-
if (core
|
|
3761
|
-
const uuid = core
|
|
3762
|
-
core
|
|
4806
|
+
if (core.$data.elements[index]) {
|
|
4807
|
+
const uuid = core.$data.elements[index].uuid;
|
|
4808
|
+
core.getEngine().temp.set("mode", Mode.NULL);
|
|
3763
4809
|
if (typeof uuid === "string") {
|
|
3764
|
-
core
|
|
3765
|
-
core
|
|
4810
|
+
core.getEngine().temp.set("selectedUUID", uuid);
|
|
4811
|
+
core.getEngine().temp.set("selectedUUIDList", []);
|
|
3766
4812
|
}
|
|
3767
|
-
core
|
|
4813
|
+
core.$draw();
|
|
3768
4814
|
}
|
|
3769
4815
|
}
|
|
3770
4816
|
function selectElement(core, uuid) {
|
|
3771
|
-
const index = core
|
|
4817
|
+
const index = core.getEngine().helper.getElementIndexByUUID(uuid);
|
|
3772
4818
|
if (typeof index === "number" && index >= 0) {
|
|
3773
4819
|
core.selectElementByIndex(index);
|
|
3774
4820
|
}
|
|
3775
4821
|
}
|
|
3776
4822
|
function cancelElementByIndex(core, index) {
|
|
3777
|
-
if (core
|
|
3778
|
-
const uuid = core
|
|
3779
|
-
const selectedUUID = core
|
|
4823
|
+
if (core.$data.elements[index]) {
|
|
4824
|
+
const uuid = core.$data.elements[index].uuid;
|
|
4825
|
+
const selectedUUID = core.getEngine().temp.get("selectedUUID");
|
|
3780
4826
|
if (typeof uuid === "string" && uuid === selectedUUID) {
|
|
3781
|
-
core
|
|
3782
|
-
core
|
|
3783
|
-
core
|
|
4827
|
+
core.getEngine().temp.set("mode", Mode.NULL);
|
|
4828
|
+
core.getEngine().temp.set("selectedUUID", null);
|
|
4829
|
+
core.getEngine().temp.set("selectedUUIDList", []);
|
|
3784
4830
|
}
|
|
3785
|
-
core
|
|
4831
|
+
core.$draw();
|
|
3786
4832
|
}
|
|
3787
4833
|
}
|
|
3788
|
-
function cancelElement(core, uuid
|
|
3789
|
-
const index = core
|
|
4834
|
+
function cancelElement(core, uuid) {
|
|
4835
|
+
const index = core.getEngine().helper.getElementIndexByUUID(uuid);
|
|
3790
4836
|
if (typeof index === "number" && index >= 0) {
|
|
3791
|
-
core.cancelElementByIndex(index
|
|
4837
|
+
core.cancelElementByIndex(index);
|
|
3792
4838
|
}
|
|
3793
4839
|
}
|
|
3794
4840
|
function moveUpElement(core, uuid) {
|
|
3795
|
-
const index = core
|
|
3796
|
-
if (typeof index === "number" && index >= 0 && index < core
|
|
3797
|
-
const temp = core
|
|
3798
|
-
core
|
|
3799
|
-
core
|
|
4841
|
+
const index = core.getEngine().helper.getElementIndexByUUID(uuid);
|
|
4842
|
+
if (typeof index === "number" && index >= 0 && index < core.$data.elements.length - 1) {
|
|
4843
|
+
const temp = core.$data.elements[index];
|
|
4844
|
+
core.$data.elements[index] = core.$data.elements[index + 1];
|
|
4845
|
+
core.$data.elements[index + 1] = temp;
|
|
3800
4846
|
}
|
|
3801
|
-
core
|
|
3802
|
-
core
|
|
4847
|
+
core.$emitChangeData();
|
|
4848
|
+
core.$draw();
|
|
3803
4849
|
}
|
|
3804
4850
|
function moveDownElement(core, uuid) {
|
|
3805
|
-
const index = core
|
|
3806
|
-
if (typeof index === "number" && index > 0 && index < core
|
|
3807
|
-
const temp = core
|
|
3808
|
-
core
|
|
3809
|
-
core
|
|
4851
|
+
const index = core.getEngine().helper.getElementIndexByUUID(uuid);
|
|
4852
|
+
if (typeof index === "number" && index > 0 && index < core.$data.elements.length) {
|
|
4853
|
+
const temp = core.$data.elements[index];
|
|
4854
|
+
core.$data.elements[index] = core.$data.elements[index - 1];
|
|
4855
|
+
core.$data.elements[index - 1] = temp;
|
|
3810
4856
|
}
|
|
3811
|
-
core
|
|
3812
|
-
core
|
|
4857
|
+
core.$emitChangeData();
|
|
4858
|
+
core.$draw();
|
|
3813
4859
|
}
|
|
3814
4860
|
function addElement(core, elem) {
|
|
3815
|
-
const _elem = deepClone(elem);
|
|
3816
|
-
_elem.uuid = createUUID();
|
|
3817
|
-
core
|
|
3818
|
-
core
|
|
3819
|
-
core
|
|
4861
|
+
const _elem = deepClone$1(elem);
|
|
4862
|
+
_elem.uuid = createUUID$1();
|
|
4863
|
+
core.$data.elements.push(_elem);
|
|
4864
|
+
core.$emitChangeData();
|
|
4865
|
+
core.$draw();
|
|
3820
4866
|
return _elem.uuid;
|
|
3821
4867
|
}
|
|
3822
4868
|
function deleteElement(core, uuid) {
|
|
3823
|
-
const index = core
|
|
4869
|
+
const index = core.$getElementHandler().getElementIndex(core.getData(), uuid);
|
|
3824
4870
|
if (index >= 0) {
|
|
3825
|
-
core
|
|
3826
|
-
core
|
|
3827
|
-
core
|
|
4871
|
+
core.$data.elements.splice(index, 1);
|
|
4872
|
+
core.$emitChangeData();
|
|
4873
|
+
core.$draw();
|
|
3828
4874
|
}
|
|
3829
4875
|
}
|
|
3830
4876
|
function insertElementBefore(core, elem, beforeUUID) {
|
|
3831
|
-
const index = core
|
|
4877
|
+
const index = core.getEngine().helper.getElementIndexByUUID(beforeUUID);
|
|
3832
4878
|
if (index !== null) {
|
|
3833
4879
|
return core.insertElementBeforeIndex(elem, index);
|
|
3834
4880
|
}
|
|
3835
4881
|
return null;
|
|
3836
4882
|
}
|
|
3837
4883
|
function insertElementBeforeIndex(core, elem, index) {
|
|
3838
|
-
const _elem = deepClone(elem);
|
|
3839
|
-
_elem.uuid = createUUID();
|
|
4884
|
+
const _elem = deepClone$1(elem);
|
|
4885
|
+
_elem.uuid = createUUID$1();
|
|
3840
4886
|
if (index >= 0) {
|
|
3841
|
-
core
|
|
3842
|
-
core
|
|
3843
|
-
core
|
|
4887
|
+
core.$data.elements.splice(index, 0, _elem);
|
|
4888
|
+
core.$emitChangeData();
|
|
4889
|
+
core.$draw();
|
|
3844
4890
|
return _elem.uuid;
|
|
3845
4891
|
}
|
|
3846
4892
|
return null;
|
|
3847
4893
|
}
|
|
3848
4894
|
function insertElementAfter(core, elem, beforeUUID) {
|
|
3849
|
-
const index = core
|
|
4895
|
+
const index = core.getEngine().helper.getElementIndexByUUID(beforeUUID);
|
|
3850
4896
|
if (index !== null) {
|
|
3851
4897
|
return core.insertElementAfterIndex(elem, index);
|
|
3852
4898
|
}
|
|
3853
4899
|
return null;
|
|
3854
4900
|
}
|
|
3855
4901
|
function insertElementAfterIndex(core, elem, index) {
|
|
3856
|
-
const _elem = deepClone(elem);
|
|
3857
|
-
_elem.uuid = createUUID();
|
|
4902
|
+
const _elem = deepClone$1(elem);
|
|
4903
|
+
_elem.uuid = createUUID$1();
|
|
3858
4904
|
if (index >= 0) {
|
|
3859
|
-
core
|
|
3860
|
-
core
|
|
3861
|
-
core
|
|
4905
|
+
core.$data.elements.splice(index + 1, 0, _elem);
|
|
4906
|
+
core.$emitChangeData();
|
|
4907
|
+
core.$draw();
|
|
3862
4908
|
return _elem.uuid;
|
|
3863
4909
|
}
|
|
3864
4910
|
return null;
|
|
@@ -3932,13 +4978,13 @@ var iDrawCore = function() {
|
|
|
3932
4978
|
return;
|
|
3933
4979
|
}
|
|
3934
4980
|
const { board } = this._opts;
|
|
3935
|
-
board.on("hover", throttle
|
|
3936
|
-
board.on("leave", throttle
|
|
3937
|
-
board.on("point", throttle
|
|
4981
|
+
board.on("hover", throttle(this._handleHover.bind(this), 32));
|
|
4982
|
+
board.on("leave", throttle(this._handleLeave.bind(this), 32));
|
|
4983
|
+
board.on("point", throttle(this._handleClick.bind(this), 16));
|
|
3938
4984
|
board.on("doubleClick", this._handleDoubleClick.bind(this));
|
|
3939
4985
|
board.on("point", this._handlePoint.bind(this));
|
|
3940
4986
|
board.on("moveStart", this._handleMoveStart.bind(this));
|
|
3941
|
-
board.on("move", throttle
|
|
4987
|
+
board.on("move", throttle(this._handleMove.bind(this), 16));
|
|
3942
4988
|
board.on("moveEnd", this._handleMoveEnd.bind(this));
|
|
3943
4989
|
}
|
|
3944
4990
|
_handleDoubleClick(point) {
|
|
@@ -3947,12 +4993,12 @@ var iDrawCore = function() {
|
|
|
3947
4993
|
const data = getDataFeekback();
|
|
3948
4994
|
const [index, uuid] = element.isPointInElement(point, data);
|
|
3949
4995
|
if (index >= 0 && uuid) {
|
|
3950
|
-
const elem = deepClone((_a2 = data.elements) == null ? void 0 : _a2[index]);
|
|
4996
|
+
const elem = deepClone$1((_a2 = data.elements) == null ? void 0 : _a2[index]);
|
|
3951
4997
|
if (((_b2 = elem == null ? void 0 : elem.operation) == null ? void 0 : _b2.invisible) !== true) {
|
|
3952
4998
|
coreEvent.trigger("screenDoubleClickElement", {
|
|
3953
4999
|
index,
|
|
3954
5000
|
uuid,
|
|
3955
|
-
element: deepClone((_c2 = data.elements) == null ? void 0 : _c2[index])
|
|
5001
|
+
element: deepClone$1((_c2 = data.elements) == null ? void 0 : _c2[index])
|
|
3956
5002
|
});
|
|
3957
5003
|
}
|
|
3958
5004
|
}
|
|
@@ -3992,7 +5038,7 @@ var iDrawCore = function() {
|
|
|
3992
5038
|
coreEvent.trigger("screenSelectElement", {
|
|
3993
5039
|
index,
|
|
3994
5040
|
uuid: uuid2,
|
|
3995
|
-
element: deepClone((_c2 = data.elements) == null ? void 0 : _c2[index])
|
|
5041
|
+
element: deepClone$1((_c2 = data.elements) == null ? void 0 : _c2[index])
|
|
3996
5042
|
});
|
|
3997
5043
|
emitChangeScreen();
|
|
3998
5044
|
}
|
|
@@ -4015,7 +5061,7 @@ var iDrawCore = function() {
|
|
|
4015
5061
|
coreEvent.trigger("screenClickElement", {
|
|
4016
5062
|
index,
|
|
4017
5063
|
uuid,
|
|
4018
|
-
element: deepClone((_a2 = data.elements) == null ? void 0 : _a2[index])
|
|
5064
|
+
element: deepClone$1((_a2 = data.elements) == null ? void 0 : _a2[index])
|
|
4019
5065
|
});
|
|
4020
5066
|
}
|
|
4021
5067
|
drawFeekback();
|
|
@@ -4493,17 +5539,16 @@ var iDrawCore = function() {
|
|
|
4493
5539
|
});
|
|
4494
5540
|
});
|
|
4495
5541
|
}
|
|
4496
|
-
var _a, _b;
|
|
4497
5542
|
class Core {
|
|
4498
5543
|
constructor(mount, opts, config) {
|
|
4499
5544
|
var _a2, _b2, _c2;
|
|
4500
|
-
this
|
|
4501
|
-
this
|
|
4502
|
-
this
|
|
4503
|
-
this
|
|
4504
|
-
this
|
|
4505
|
-
this
|
|
4506
|
-
...this
|
|
5545
|
+
this._coreEvent = new CoreEvent();
|
|
5546
|
+
this._tempData = new TempData$1();
|
|
5547
|
+
this.$data = { elements: [] };
|
|
5548
|
+
this._opts = opts;
|
|
5549
|
+
this._config = mergeConfig(config || {});
|
|
5550
|
+
this._board = new default_1$2(mount, {
|
|
5551
|
+
...this._opts,
|
|
4507
5552
|
canScroll: (_a2 = config == null ? void 0 : config.scrollWrapper) == null ? void 0 : _a2.use,
|
|
4508
5553
|
scrollConfig: {
|
|
4509
5554
|
color: ((_b2 = config == null ? void 0 : config.scrollWrapper) == null ? void 0 : _b2.color) || "#000000",
|
|
@@ -4511,12 +5556,12 @@ var iDrawCore = function() {
|
|
|
4511
5556
|
...(config == null ? void 0 : config.scrollWrapper) || {}
|
|
4512
5557
|
}
|
|
4513
5558
|
});
|
|
4514
|
-
this
|
|
5559
|
+
this._renderer = new default_1();
|
|
4515
5560
|
const drawFrame = () => {
|
|
4516
|
-
const helperCtx = this
|
|
4517
|
-
const helperConfig = this
|
|
4518
|
-
this
|
|
4519
|
-
const { contextWidth, contextHeight, devicePixelRatio } = this
|
|
5561
|
+
const helperCtx = this._board.getHelperContext();
|
|
5562
|
+
const helperConfig = this._engine.getHelperConfig();
|
|
5563
|
+
this._board.clear();
|
|
5564
|
+
const { contextWidth, contextHeight, devicePixelRatio } = this._opts;
|
|
4520
5565
|
helperCtx.clearRect(
|
|
4521
5566
|
0,
|
|
4522
5567
|
0,
|
|
@@ -4526,43 +5571,50 @@ var iDrawCore = function() {
|
|
|
4526
5571
|
drawElementWrapper(helperCtx, helperConfig);
|
|
4527
5572
|
drawAreaWrapper(helperCtx, helperConfig);
|
|
4528
5573
|
drawElementListWrappers(helperCtx, helperConfig);
|
|
4529
|
-
this
|
|
5574
|
+
this._board.draw();
|
|
4530
5575
|
};
|
|
4531
|
-
this
|
|
5576
|
+
this._renderer.on("drawFrame", () => {
|
|
4532
5577
|
drawFrame();
|
|
4533
5578
|
});
|
|
4534
|
-
this
|
|
5579
|
+
this._renderer.on("drawFrameComplete", () => {
|
|
4535
5580
|
drawFrame();
|
|
4536
5581
|
});
|
|
4537
|
-
this
|
|
4538
|
-
this
|
|
4539
|
-
coreEvent: this
|
|
4540
|
-
board: this
|
|
4541
|
-
element: this
|
|
4542
|
-
config: this
|
|
4543
|
-
drawFeekback: this
|
|
4544
|
-
getDataFeekback: () => this
|
|
5582
|
+
this._elementHandler = new Element(this._board.getContext());
|
|
5583
|
+
this._engine = new Engine({
|
|
5584
|
+
coreEvent: this._coreEvent,
|
|
5585
|
+
board: this._board,
|
|
5586
|
+
element: this._elementHandler,
|
|
5587
|
+
config: this._config,
|
|
5588
|
+
drawFeekback: this.$draw.bind(this),
|
|
5589
|
+
getDataFeekback: () => this.$data,
|
|
4545
5590
|
selectElementByIndex: this.selectElementByIndex.bind(this),
|
|
4546
|
-
emitChangeScreen: this
|
|
4547
|
-
emitChangeData: this
|
|
5591
|
+
emitChangeScreen: this._emitChangeScreen.bind(this),
|
|
5592
|
+
emitChangeData: this.$emitChangeData.bind(this)
|
|
4548
5593
|
});
|
|
4549
|
-
this
|
|
4550
|
-
this
|
|
4551
|
-
this
|
|
5594
|
+
this._engine.init();
|
|
5595
|
+
this._renderer.on("drawFrame", () => {
|
|
5596
|
+
this._coreEvent.trigger("drawFrame", void 0);
|
|
4552
5597
|
});
|
|
4553
|
-
this
|
|
4554
|
-
this
|
|
5598
|
+
this._renderer.on("drawFrameComplete", () => {
|
|
5599
|
+
this._coreEvent.trigger("drawFrameComplete", void 0);
|
|
4555
5600
|
});
|
|
4556
|
-
this
|
|
5601
|
+
this._tempData.set("hasInited", true);
|
|
5602
|
+
}
|
|
5603
|
+
_emitChangeScreen() {
|
|
5604
|
+
if (this._coreEvent.has("changeScreen")) {
|
|
5605
|
+
this._coreEvent.trigger("changeScreen", {
|
|
5606
|
+
...this.getScreenTransform()
|
|
5607
|
+
});
|
|
5608
|
+
}
|
|
4557
5609
|
}
|
|
4558
|
-
|
|
4559
|
-
this
|
|
4560
|
-
width: this
|
|
4561
|
-
height: this
|
|
4562
|
-
devicePixelRatio: this
|
|
5610
|
+
$draw(opts) {
|
|
5611
|
+
this._engine.updateHelperConfig({
|
|
5612
|
+
width: this._opts.width,
|
|
5613
|
+
height: this._opts.height,
|
|
5614
|
+
devicePixelRatio: this._opts.devicePixelRatio
|
|
4563
5615
|
});
|
|
4564
|
-
this
|
|
4565
|
-
this
|
|
5616
|
+
this._renderer.thaw();
|
|
5617
|
+
this._renderer.render(this._board.getContext(), this.$data, {
|
|
4566
5618
|
changeResourceUUIDs: (opts == null ? void 0 : opts.resourceChangeUUIDs) || []
|
|
4567
5619
|
});
|
|
4568
5620
|
}
|
|
@@ -4581,8 +5633,8 @@ var iDrawCore = function() {
|
|
|
4581
5633
|
cancelElementByIndex(index) {
|
|
4582
5634
|
return cancelElementByIndex(this, index);
|
|
4583
5635
|
}
|
|
4584
|
-
cancelElement(uuid
|
|
4585
|
-
return cancelElement(this, uuid
|
|
5636
|
+
cancelElement(uuid) {
|
|
5637
|
+
return cancelElement(this, uuid);
|
|
4586
5638
|
}
|
|
4587
5639
|
moveUpElement(uuid) {
|
|
4588
5640
|
return moveUpElement(this, uuid);
|
|
@@ -4615,30 +5667,30 @@ var iDrawCore = function() {
|
|
|
4615
5667
|
return insertElementAfterIndex(this, elem, index);
|
|
4616
5668
|
}
|
|
4617
5669
|
resetSize(opts) {
|
|
4618
|
-
this
|
|
4619
|
-
this
|
|
4620
|
-
this
|
|
5670
|
+
this._opts = { ...this._opts, ...opts };
|
|
5671
|
+
this._board.resetSize(opts);
|
|
5672
|
+
this.$draw();
|
|
4621
5673
|
}
|
|
4622
5674
|
scale(ratio) {
|
|
4623
|
-
const screen = this
|
|
4624
|
-
this
|
|
4625
|
-
this
|
|
5675
|
+
const screen = this._board.scale(ratio);
|
|
5676
|
+
this.$draw();
|
|
5677
|
+
this._emitChangeScreen();
|
|
4626
5678
|
return screen;
|
|
4627
5679
|
}
|
|
4628
5680
|
scrollLeft(left) {
|
|
4629
|
-
const screen = this
|
|
4630
|
-
this
|
|
4631
|
-
this
|
|
5681
|
+
const screen = this._board.scrollX(0 - left);
|
|
5682
|
+
this.$draw();
|
|
5683
|
+
this._emitChangeScreen();
|
|
4632
5684
|
return screen;
|
|
4633
5685
|
}
|
|
4634
5686
|
scrollTop(top) {
|
|
4635
|
-
const screen = this
|
|
4636
|
-
this
|
|
4637
|
-
this
|
|
5687
|
+
const screen = this._board.scrollY(0 - top);
|
|
5688
|
+
this.$draw();
|
|
5689
|
+
this._emitChangeScreen();
|
|
4638
5690
|
return screen;
|
|
4639
5691
|
}
|
|
4640
5692
|
getScreenTransform() {
|
|
4641
|
-
const transform = this
|
|
5693
|
+
const transform = this._board.getTransform();
|
|
4642
5694
|
return {
|
|
4643
5695
|
scale: transform.scale,
|
|
4644
5696
|
scrollTop: Math.max(0, 0 - transform.scrollY),
|
|
@@ -4646,55 +5698,51 @@ var iDrawCore = function() {
|
|
|
4646
5698
|
};
|
|
4647
5699
|
}
|
|
4648
5700
|
getData() {
|
|
4649
|
-
return deepClone(this
|
|
5701
|
+
return deepClone$1(this.$data);
|
|
4650
5702
|
}
|
|
4651
5703
|
setData(data, opts) {
|
|
4652
|
-
const resourceChangeUUIDs = diffElementResourceChangeList(
|
|
4653
|
-
|
|
4654
|
-
data
|
|
4655
|
-
);
|
|
4656
|
-
this[_data] = this[_element].initData(deepClone(parseData(data)));
|
|
5704
|
+
const resourceChangeUUIDs = diffElementResourceChangeList(this.$data, data);
|
|
5705
|
+
this.$data = this._elementHandler.initData(deepClone$1(parseData(data)));
|
|
4657
5706
|
if (opts && opts.triggerChangeEvent === true) {
|
|
4658
|
-
this
|
|
5707
|
+
this.$emitChangeData();
|
|
4659
5708
|
}
|
|
4660
|
-
this
|
|
5709
|
+
this.$draw({ resourceChangeUUIDs });
|
|
4661
5710
|
}
|
|
4662
5711
|
clearOperation() {
|
|
4663
|
-
this
|
|
4664
|
-
this
|
|
5712
|
+
this._tempData.clear();
|
|
5713
|
+
this.$draw();
|
|
4665
5714
|
}
|
|
4666
5715
|
on(key, callback) {
|
|
4667
|
-
this
|
|
5716
|
+
this._coreEvent.on(key, callback);
|
|
4668
5717
|
}
|
|
4669
5718
|
off(key, callback) {
|
|
4670
|
-
this
|
|
5719
|
+
this._coreEvent.off(key, callback);
|
|
5720
|
+
}
|
|
5721
|
+
getEngine() {
|
|
5722
|
+
return this._engine;
|
|
4671
5723
|
}
|
|
4672
5724
|
pointScreenToContext(p) {
|
|
4673
|
-
return this
|
|
5725
|
+
return this._board.pointScreenToContext(p);
|
|
4674
5726
|
}
|
|
4675
5727
|
pointContextToScreen(p) {
|
|
4676
|
-
return this
|
|
5728
|
+
return this._board.pointContextToScreen(p);
|
|
4677
5729
|
}
|
|
4678
|
-
|
|
4679
|
-
return this
|
|
5730
|
+
$getBoardContext() {
|
|
5731
|
+
return this._board.getContext();
|
|
4680
5732
|
}
|
|
4681
|
-
|
|
4682
|
-
return this
|
|
5733
|
+
$getDisplayContext2D() {
|
|
5734
|
+
return this._board.getDisplayContext2D();
|
|
4683
5735
|
}
|
|
4684
|
-
|
|
4685
|
-
return this
|
|
5736
|
+
$getOriginContext2D() {
|
|
5737
|
+
return this._board.getOriginContext2D();
|
|
4686
5738
|
}
|
|
4687
|
-
|
|
4688
|
-
if (this
|
|
4689
|
-
this
|
|
4690
|
-
...this.getScreenTransform()
|
|
4691
|
-
});
|
|
5739
|
+
$emitChangeData() {
|
|
5740
|
+
if (this._coreEvent.has("changeData")) {
|
|
5741
|
+
this._coreEvent.trigger("changeData", deepClone$1(this.$data));
|
|
4692
5742
|
}
|
|
4693
5743
|
}
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
this[_coreEvent].trigger("changeData", deepClone(this[_data]));
|
|
4697
|
-
}
|
|
5744
|
+
$getElementHandler() {
|
|
5745
|
+
return this._elementHandler;
|
|
4698
5746
|
}
|
|
4699
5747
|
}
|
|
4700
5748
|
Core.is = is;
|