@idraw/core 0.3.0-beta.6 → 0.3.0-beta.7
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 +5 -5
- package/dist/esm/lib/engine.d.ts +47 -0
- package/dist/esm/lib/helper.d.ts +30 -0
- package/dist/esm/lib/mapper.d.ts +26 -0
- package/dist/index.global.js +1128 -2215
- package/dist/index.global.min.js +1 -1
- package/package.json +6 -6
package/dist/index.global.js
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
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
|
-
};
|
|
15
3
|
function compose(middleware) {
|
|
16
4
|
return function(context, next) {
|
|
17
5
|
return dispatch(0);
|
|
18
6
|
function dispatch(i) {
|
|
19
|
-
|
|
7
|
+
let fn = middleware[i];
|
|
20
8
|
if (i === middleware.length && next) {
|
|
21
9
|
fn = next;
|
|
22
10
|
}
|
|
@@ -31,35 +19,31 @@ var iDrawCore = function() {
|
|
|
31
19
|
};
|
|
32
20
|
}
|
|
33
21
|
function delay(time) {
|
|
34
|
-
return new Promise(
|
|
35
|
-
setTimeout(
|
|
22
|
+
return new Promise((resolve) => {
|
|
23
|
+
setTimeout(() => {
|
|
36
24
|
resolve();
|
|
37
25
|
}, time);
|
|
38
26
|
});
|
|
39
27
|
}
|
|
40
28
|
function throttle$1(fn, timeout) {
|
|
41
|
-
|
|
42
|
-
return function() {
|
|
43
|
-
var args = [];
|
|
44
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
45
|
-
args[_i] = arguments[_i];
|
|
46
|
-
}
|
|
29
|
+
let timer = -1;
|
|
30
|
+
return function(...args) {
|
|
47
31
|
if (timer > 0) {
|
|
48
32
|
return;
|
|
49
33
|
}
|
|
50
|
-
timer = setTimeout(
|
|
51
|
-
fn
|
|
34
|
+
timer = setTimeout(() => {
|
|
35
|
+
fn(...args);
|
|
52
36
|
timer = -1;
|
|
53
37
|
}, timeout);
|
|
54
38
|
};
|
|
55
39
|
}
|
|
56
40
|
function downloadImageFromCanvas(canvas, opts) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
41
|
+
const { filename, type = "image/jpeg" } = opts;
|
|
42
|
+
const stream = canvas.toDataURL(type);
|
|
43
|
+
const downloadLink = document.createElement("a");
|
|
60
44
|
downloadLink.href = stream;
|
|
61
45
|
downloadLink.download = filename;
|
|
62
|
-
|
|
46
|
+
const downloadClickEvent = document.createEvent("MouseEvents");
|
|
63
47
|
downloadClickEvent.initEvent("click", true, false);
|
|
64
48
|
downloadLink.dispatchEvent(downloadClickEvent);
|
|
65
49
|
}
|
|
@@ -69,91 +53,120 @@ var iDrawCore = function() {
|
|
|
69
53
|
function toColorHexStr(color2) {
|
|
70
54
|
return "#" + color2.toString(16);
|
|
71
55
|
}
|
|
72
|
-
function isColorStr
|
|
56
|
+
function isColorStr(color2) {
|
|
73
57
|
return typeof color2 === "string" && /^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color2);
|
|
74
58
|
}
|
|
75
|
-
function createUUID
|
|
59
|
+
function createUUID() {
|
|
76
60
|
function str4() {
|
|
77
61
|
return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
|
|
78
62
|
}
|
|
79
|
-
return
|
|
63
|
+
return `${str4()}${str4()}-${str4()}-${str4()}-${str4()}-${str4()}${str4()}${str4()}`;
|
|
80
64
|
}
|
|
81
|
-
function deepClone
|
|
65
|
+
function deepClone(target) {
|
|
82
66
|
function _clone(t) {
|
|
83
|
-
|
|
67
|
+
const type = is$2(t);
|
|
84
68
|
if (["Null", "Number", "String", "Boolean", "Undefined"].indexOf(type) >= 0) {
|
|
85
69
|
return t;
|
|
86
70
|
} else if (type === "Array") {
|
|
87
|
-
|
|
88
|
-
t.forEach(
|
|
89
|
-
|
|
71
|
+
const arr = [];
|
|
72
|
+
t.forEach((item) => {
|
|
73
|
+
arr.push(_clone(item));
|
|
90
74
|
});
|
|
91
|
-
return
|
|
75
|
+
return arr;
|
|
92
76
|
} else if (type === "Object") {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
keys.forEach(
|
|
96
|
-
|
|
77
|
+
const obj = {};
|
|
78
|
+
const keys = Object.keys(t);
|
|
79
|
+
keys.forEach((key) => {
|
|
80
|
+
obj[key] = _clone(t[key]);
|
|
97
81
|
});
|
|
98
|
-
return
|
|
82
|
+
return obj;
|
|
99
83
|
}
|
|
100
84
|
}
|
|
101
85
|
return _clone(target);
|
|
102
86
|
}
|
|
103
|
-
function is$
|
|
87
|
+
function is$2(data) {
|
|
104
88
|
return Object.prototype.toString.call(data).replace(/[\]|\[]{1,1}/ig, "").split(" ")[1];
|
|
105
89
|
}
|
|
106
|
-
function parsePrototype
|
|
107
|
-
|
|
108
|
-
|
|
90
|
+
function parsePrototype(data) {
|
|
91
|
+
const typeStr = Object.prototype.toString.call(data) || "";
|
|
92
|
+
const result = typeStr.replace(/(\[object|\])/ig, "").trim();
|
|
109
93
|
return result;
|
|
110
94
|
}
|
|
111
|
-
|
|
112
|
-
type
|
|
113
|
-
|
|
95
|
+
const istype = {
|
|
96
|
+
type(data, lowerCase) {
|
|
97
|
+
const result = parsePrototype(data);
|
|
114
98
|
return lowerCase === true ? result.toLocaleLowerCase() : result;
|
|
115
99
|
},
|
|
116
|
-
array
|
|
117
|
-
return parsePrototype
|
|
100
|
+
array(data) {
|
|
101
|
+
return parsePrototype(data) === "Array";
|
|
118
102
|
},
|
|
119
|
-
json
|
|
120
|
-
return parsePrototype
|
|
103
|
+
json(data) {
|
|
104
|
+
return parsePrototype(data) === "Object";
|
|
121
105
|
},
|
|
122
|
-
function
|
|
123
|
-
return parsePrototype
|
|
106
|
+
function(data) {
|
|
107
|
+
return parsePrototype(data) === "Function";
|
|
124
108
|
},
|
|
125
|
-
asyncFunction
|
|
126
|
-
return parsePrototype
|
|
109
|
+
asyncFunction(data) {
|
|
110
|
+
return parsePrototype(data) === "AsyncFunction";
|
|
127
111
|
},
|
|
128
|
-
string
|
|
129
|
-
return parsePrototype
|
|
112
|
+
string(data) {
|
|
113
|
+
return parsePrototype(data) === "String";
|
|
130
114
|
},
|
|
131
|
-
number
|
|
132
|
-
return parsePrototype
|
|
115
|
+
number(data) {
|
|
116
|
+
return parsePrototype(data) === "Number";
|
|
133
117
|
},
|
|
134
|
-
undefined
|
|
135
|
-
return parsePrototype
|
|
118
|
+
undefined(data) {
|
|
119
|
+
return parsePrototype(data) === "Undefined";
|
|
136
120
|
},
|
|
137
|
-
null
|
|
138
|
-
return parsePrototype
|
|
121
|
+
null(data) {
|
|
122
|
+
return parsePrototype(data) === "Null";
|
|
139
123
|
},
|
|
140
|
-
promise
|
|
141
|
-
return parsePrototype
|
|
124
|
+
promise(data) {
|
|
125
|
+
return parsePrototype(data) === "Promise";
|
|
142
126
|
}
|
|
143
127
|
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
128
|
+
function parseHTMLToDataURL(html2, opts) {
|
|
129
|
+
const { width, height } = opts;
|
|
130
|
+
return new Promise((resolve, reject) => {
|
|
131
|
+
const _svg = `
|
|
132
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="${width || ""}" height = "${height || ""}">
|
|
133
|
+
<foreignObject width="100%" height="100%">
|
|
134
|
+
<div xmlns = "http://www.w3.org/1999/xhtml">
|
|
135
|
+
${html2}
|
|
136
|
+
</div>
|
|
137
|
+
</foreignObject>
|
|
138
|
+
</svg>
|
|
139
|
+
`;
|
|
140
|
+
const blob = new Blob([_svg], { type: "image/svg+xml;charset=utf-8" });
|
|
141
|
+
const reader = new FileReader();
|
|
142
|
+
reader.readAsDataURL(blob);
|
|
143
|
+
reader.onload = function(event) {
|
|
144
|
+
var _a;
|
|
145
|
+
const base64 = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.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 _a;
|
|
161
|
+
const base64 = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.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) {
|
|
157
170
|
function adopt(value) {
|
|
158
171
|
return value instanceof P ? value : new P(function(resolve) {
|
|
159
172
|
resolve(value);
|
|
@@ -179,120 +192,12 @@ var iDrawCore = function() {
|
|
|
179
192
|
}
|
|
180
193
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
181
194
|
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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();
|
|
195
|
+
};
|
|
196
|
+
const { Image } = window;
|
|
197
|
+
function loadImage(src) {
|
|
198
|
+
return new Promise((resolve, reject) => {
|
|
199
|
+
const img = new Image();
|
|
200
|
+
img.crossOrigin = "anonymous";
|
|
296
201
|
img.onload = function() {
|
|
297
202
|
resolve(img);
|
|
298
203
|
};
|
|
@@ -301,42 +206,26 @@ var iDrawCore = function() {
|
|
|
301
206
|
img.src = src;
|
|
302
207
|
});
|
|
303
208
|
}
|
|
304
|
-
function loadSVG
|
|
305
|
-
return __awaiter$
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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
|
-
});
|
|
209
|
+
function loadSVG(svg2) {
|
|
210
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
211
|
+
const dataURL = yield parseSVGToDataURL(svg2);
|
|
212
|
+
const image = yield loadImage(dataURL);
|
|
213
|
+
return image;
|
|
319
214
|
});
|
|
320
215
|
}
|
|
321
|
-
function
|
|
322
|
-
return
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
return [4, loadImage$1(dataURL)];
|
|
331
|
-
case 2:
|
|
332
|
-
image = _a2.sent();
|
|
333
|
-
return [2, image];
|
|
334
|
-
}
|
|
335
|
-
});
|
|
216
|
+
function filterAmpersand(str) {
|
|
217
|
+
return str.replace(/\&/ig, "&");
|
|
218
|
+
}
|
|
219
|
+
function loadHTML(html2, opts) {
|
|
220
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
221
|
+
html2 = filterAmpersand(html2);
|
|
222
|
+
const dataURL = yield parseHTMLToDataURL(html2, opts);
|
|
223
|
+
const image = yield loadImage(dataURL);
|
|
224
|
+
return image;
|
|
336
225
|
});
|
|
337
226
|
}
|
|
338
|
-
|
|
339
|
-
|
|
227
|
+
let Context$1 = class Context {
|
|
228
|
+
constructor(ctx, opts) {
|
|
340
229
|
this._opts = opts;
|
|
341
230
|
this._ctx = ctx;
|
|
342
231
|
this._transform = {
|
|
@@ -345,19 +234,19 @@ var iDrawCore = function() {
|
|
|
345
234
|
scrollY: 0
|
|
346
235
|
};
|
|
347
236
|
}
|
|
348
|
-
|
|
237
|
+
getContext() {
|
|
349
238
|
return this._ctx;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
this._opts =
|
|
353
|
-
}
|
|
354
|
-
|
|
239
|
+
}
|
|
240
|
+
resetSize(opts) {
|
|
241
|
+
this._opts = Object.assign(Object.assign({}, this._opts), opts);
|
|
242
|
+
}
|
|
243
|
+
calcDeviceNum(num) {
|
|
355
244
|
return num * this._opts.devicePixelRatio;
|
|
356
|
-
}
|
|
357
|
-
|
|
245
|
+
}
|
|
246
|
+
calcScreenNum(num) {
|
|
358
247
|
return num / this._opts.devicePixelRatio;
|
|
359
|
-
}
|
|
360
|
-
|
|
248
|
+
}
|
|
249
|
+
getSize() {
|
|
361
250
|
return {
|
|
362
251
|
width: this._opts.width,
|
|
363
252
|
height: this._opts.height,
|
|
@@ -365,217 +254,209 @@ var iDrawCore = function() {
|
|
|
365
254
|
contextHeight: this._opts.contextHeight,
|
|
366
255
|
devicePixelRatio: this._opts.devicePixelRatio
|
|
367
256
|
};
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
this._transform =
|
|
371
|
-
}
|
|
372
|
-
|
|
257
|
+
}
|
|
258
|
+
setTransform(config) {
|
|
259
|
+
this._transform = Object.assign(Object.assign({}, this._transform), config);
|
|
260
|
+
}
|
|
261
|
+
getTransform() {
|
|
373
262
|
return {
|
|
374
263
|
scale: this._transform.scale,
|
|
375
264
|
scrollX: this._transform.scrollX,
|
|
376
265
|
scrollY: this._transform.scrollY
|
|
377
266
|
};
|
|
378
|
-
}
|
|
379
|
-
|
|
267
|
+
}
|
|
268
|
+
setFillStyle(color2) {
|
|
380
269
|
this._ctx.fillStyle = color2;
|
|
381
|
-
}
|
|
382
|
-
|
|
270
|
+
}
|
|
271
|
+
fill(fillRule) {
|
|
383
272
|
return this._ctx.fill(fillRule || "nonzero");
|
|
384
|
-
}
|
|
385
|
-
|
|
273
|
+
}
|
|
274
|
+
arc(x2, y2, radius, startAngle, endAngle, anticlockwise) {
|
|
386
275
|
return this._ctx.arc(this._doSize(x2), this._doSize(y2), this._doSize(radius), startAngle, endAngle, anticlockwise);
|
|
387
|
-
}
|
|
388
|
-
|
|
276
|
+
}
|
|
277
|
+
rect(x2, y2, w2, h2) {
|
|
389
278
|
return this._ctx.rect(this._doSize(x2), this._doSize(y2), this._doSize(w2), this._doSize(h2));
|
|
390
|
-
}
|
|
391
|
-
|
|
279
|
+
}
|
|
280
|
+
fillRect(x2, y2, w2, h2) {
|
|
392
281
|
return this._ctx.fillRect(this._doSize(x2), this._doSize(y2), this._doSize(w2), this._doSize(h2));
|
|
393
|
-
}
|
|
394
|
-
|
|
282
|
+
}
|
|
283
|
+
clearRect(x2, y2, w2, h2) {
|
|
395
284
|
return this._ctx.clearRect(this._doSize(x2), this._doSize(y2), this._doSize(w2), this._doSize(h2));
|
|
396
|
-
}
|
|
397
|
-
|
|
285
|
+
}
|
|
286
|
+
beginPath() {
|
|
398
287
|
return this._ctx.beginPath();
|
|
399
|
-
}
|
|
400
|
-
|
|
288
|
+
}
|
|
289
|
+
closePath() {
|
|
401
290
|
return this._ctx.closePath();
|
|
402
|
-
}
|
|
403
|
-
|
|
291
|
+
}
|
|
292
|
+
lineTo(x2, y2) {
|
|
404
293
|
return this._ctx.lineTo(this._doSize(x2), this._doSize(y2));
|
|
405
|
-
}
|
|
406
|
-
|
|
294
|
+
}
|
|
295
|
+
moveTo(x2, y2) {
|
|
407
296
|
return this._ctx.moveTo(this._doSize(x2), this._doSize(y2));
|
|
408
|
-
}
|
|
409
|
-
|
|
297
|
+
}
|
|
298
|
+
arcTo(x1, y1, x2, y2, radius) {
|
|
410
299
|
return this._ctx.arcTo(this._doSize(x1), this._doSize(y1), this._doSize(x2), this._doSize(y2), this._doSize(radius));
|
|
411
|
-
}
|
|
412
|
-
|
|
300
|
+
}
|
|
301
|
+
setLineWidth(w2) {
|
|
413
302
|
return this._ctx.lineWidth = this._doSize(w2);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
}));
|
|
420
|
-
};
|
|
421
|
-
Context2.prototype.isPointInPath = function(x2, y2) {
|
|
303
|
+
}
|
|
304
|
+
setLineDash(nums) {
|
|
305
|
+
return this._ctx.setLineDash(nums.map((n) => this._doSize(n)));
|
|
306
|
+
}
|
|
307
|
+
isPointInPath(x2, y2) {
|
|
422
308
|
return this._ctx.isPointInPath(this._doX(x2), this._doY(y2));
|
|
423
|
-
}
|
|
424
|
-
|
|
309
|
+
}
|
|
310
|
+
isPointInPathWithoutScroll(x2, y2) {
|
|
425
311
|
return this._ctx.isPointInPath(this._doSize(x2), this._doSize(y2));
|
|
426
|
-
}
|
|
427
|
-
|
|
312
|
+
}
|
|
313
|
+
setStrokeStyle(color2) {
|
|
428
314
|
this._ctx.strokeStyle = color2;
|
|
429
|
-
}
|
|
430
|
-
|
|
315
|
+
}
|
|
316
|
+
stroke() {
|
|
431
317
|
return this._ctx.stroke();
|
|
432
|
-
}
|
|
433
|
-
|
|
318
|
+
}
|
|
319
|
+
translate(x2, y2) {
|
|
434
320
|
return this._ctx.translate(this._doSize(x2), this._doSize(y2));
|
|
435
|
-
}
|
|
436
|
-
|
|
321
|
+
}
|
|
322
|
+
rotate(angle2) {
|
|
437
323
|
return this._ctx.rotate(angle2);
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
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];
|
|
324
|
+
}
|
|
325
|
+
drawImage(...args) {
|
|
326
|
+
const image = args[0];
|
|
327
|
+
const sx = args[1];
|
|
328
|
+
const sy = args[2];
|
|
329
|
+
const sw = args[3];
|
|
330
|
+
const sh = args[4];
|
|
331
|
+
const dx = args[args.length - 4];
|
|
332
|
+
const dy = args[args.length - 3];
|
|
333
|
+
const dw = args[args.length - 2];
|
|
334
|
+
const dh = args[args.length - 1];
|
|
453
335
|
if (args.length === 9) {
|
|
454
336
|
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));
|
|
455
337
|
} else {
|
|
456
338
|
return this._ctx.drawImage(image, this._doSize(dx), this._doSize(dy), this._doSize(dw), this._doSize(dh));
|
|
457
339
|
}
|
|
458
|
-
}
|
|
459
|
-
|
|
340
|
+
}
|
|
341
|
+
createPattern(image, repetition) {
|
|
460
342
|
return this._ctx.createPattern(image, repetition);
|
|
461
|
-
}
|
|
462
|
-
|
|
343
|
+
}
|
|
344
|
+
measureText(text2) {
|
|
463
345
|
return this._ctx.measureText(text2);
|
|
464
|
-
}
|
|
465
|
-
|
|
346
|
+
}
|
|
347
|
+
setTextAlign(align) {
|
|
466
348
|
this._ctx.textAlign = align;
|
|
467
|
-
}
|
|
468
|
-
|
|
349
|
+
}
|
|
350
|
+
fillText(text2, x2, y2, maxWidth) {
|
|
469
351
|
if (maxWidth !== void 0) {
|
|
470
352
|
return this._ctx.fillText(text2, this._doSize(x2), this._doSize(y2), this._doSize(maxWidth));
|
|
471
353
|
} else {
|
|
472
354
|
return this._ctx.fillText(text2, this._doSize(x2), this._doSize(y2));
|
|
473
355
|
}
|
|
474
|
-
}
|
|
475
|
-
|
|
356
|
+
}
|
|
357
|
+
strokeText(text2, x2, y2, maxWidth) {
|
|
476
358
|
if (maxWidth !== void 0) {
|
|
477
359
|
return this._ctx.strokeText(text2, this._doSize(x2), this._doSize(y2), this._doSize(maxWidth));
|
|
478
360
|
} else {
|
|
479
361
|
return this._ctx.strokeText(text2, this._doSize(x2), this._doSize(y2));
|
|
480
362
|
}
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
|
|
363
|
+
}
|
|
364
|
+
setFont(opts) {
|
|
365
|
+
const strList = [];
|
|
484
366
|
if (opts.fontWeight === "bold") {
|
|
485
|
-
strList.push(
|
|
367
|
+
strList.push(`${opts.fontWeight}`);
|
|
486
368
|
}
|
|
487
|
-
strList.push(
|
|
488
|
-
strList.push(
|
|
489
|
-
this._ctx.font =
|
|
490
|
-
}
|
|
491
|
-
|
|
369
|
+
strList.push(`${this._doSize(opts.fontSize || 12)}px`);
|
|
370
|
+
strList.push(`${opts.fontFamily || "sans-serif"}`);
|
|
371
|
+
this._ctx.font = `${strList.join(" ")}`;
|
|
372
|
+
}
|
|
373
|
+
setTextBaseline(baseline) {
|
|
492
374
|
this._ctx.textBaseline = baseline;
|
|
493
|
-
}
|
|
494
|
-
|
|
375
|
+
}
|
|
376
|
+
setGlobalAlpha(alpha) {
|
|
495
377
|
this._ctx.globalAlpha = alpha;
|
|
496
|
-
}
|
|
497
|
-
|
|
378
|
+
}
|
|
379
|
+
save() {
|
|
498
380
|
this._ctx.save();
|
|
499
|
-
}
|
|
500
|
-
|
|
381
|
+
}
|
|
382
|
+
restore() {
|
|
501
383
|
this._ctx.restore();
|
|
502
|
-
}
|
|
503
|
-
|
|
384
|
+
}
|
|
385
|
+
scale(ratioX, ratioY) {
|
|
504
386
|
this._ctx.scale(ratioX, ratioY);
|
|
505
|
-
}
|
|
506
|
-
|
|
387
|
+
}
|
|
388
|
+
setShadowColor(color2) {
|
|
507
389
|
this._ctx.shadowColor = color2;
|
|
508
|
-
}
|
|
509
|
-
|
|
390
|
+
}
|
|
391
|
+
setShadowOffsetX(offsetX) {
|
|
510
392
|
this._ctx.shadowOffsetX = this._doSize(offsetX);
|
|
511
|
-
}
|
|
512
|
-
|
|
393
|
+
}
|
|
394
|
+
setShadowOffsetY(offsetY) {
|
|
513
395
|
this._ctx.shadowOffsetY = this._doSize(offsetY);
|
|
514
|
-
}
|
|
515
|
-
|
|
396
|
+
}
|
|
397
|
+
setShadowBlur(blur) {
|
|
516
398
|
this._ctx.shadowBlur = this._doSize(blur);
|
|
517
|
-
}
|
|
518
|
-
|
|
399
|
+
}
|
|
400
|
+
ellipse(x2, y2, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
|
|
519
401
|
this._ctx.ellipse(this._doSize(x2), this._doSize(y2), this._doSize(radiusX), this._doSize(radiusY), rotation, startAngle, endAngle, counterclockwise);
|
|
520
|
-
}
|
|
521
|
-
|
|
402
|
+
}
|
|
403
|
+
_doSize(num) {
|
|
522
404
|
return this._opts.devicePixelRatio * num;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
405
|
+
}
|
|
406
|
+
_doX(x2) {
|
|
407
|
+
const { scale, scrollX } = this._transform;
|
|
408
|
+
const _x = (x2 - scrollX) / scale;
|
|
527
409
|
return this._doSize(_x);
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
410
|
+
}
|
|
411
|
+
_doY(y2) {
|
|
412
|
+
const { scale, scrollY } = this._transform;
|
|
413
|
+
const _y = (y2 - scrollY) / scale;
|
|
532
414
|
return this._doSize(_y);
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
function number$2(value) {
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
function number$1(value) {
|
|
537
418
|
return typeof value === "number" && (value > 0 || value <= 0);
|
|
538
419
|
}
|
|
539
|
-
function x$
|
|
540
|
-
return number$
|
|
420
|
+
function x$1(value) {
|
|
421
|
+
return number$1(value);
|
|
541
422
|
}
|
|
542
|
-
function y$
|
|
543
|
-
return number$
|
|
423
|
+
function y$1(value) {
|
|
424
|
+
return number$1(value);
|
|
544
425
|
}
|
|
545
|
-
function w$
|
|
426
|
+
function w$1(value) {
|
|
546
427
|
return typeof value === "number" && value >= 0;
|
|
547
428
|
}
|
|
548
|
-
function h$
|
|
429
|
+
function h$1(value) {
|
|
549
430
|
return typeof value === "number" && value >= 0;
|
|
550
431
|
}
|
|
551
|
-
function angle$
|
|
432
|
+
function angle$1(value) {
|
|
552
433
|
return typeof value === "number" && value >= -360 && value <= 360;
|
|
553
434
|
}
|
|
554
|
-
function borderWidth$
|
|
555
|
-
return w$
|
|
435
|
+
function borderWidth$1(value) {
|
|
436
|
+
return w$1(value);
|
|
556
437
|
}
|
|
557
|
-
function borderRadius$
|
|
558
|
-
return number$
|
|
438
|
+
function borderRadius$1(value) {
|
|
439
|
+
return number$1(value) && value >= 0;
|
|
559
440
|
}
|
|
560
|
-
function color$
|
|
561
|
-
return isColorStr
|
|
441
|
+
function color$1(value) {
|
|
442
|
+
return isColorStr(value);
|
|
562
443
|
}
|
|
563
|
-
function imageURL$
|
|
564
|
-
return typeof value === "string" && /^(http:\/\/|https:\/\/|\.\/|\/)/.test(
|
|
444
|
+
function imageURL$1(value) {
|
|
445
|
+
return typeof value === "string" && /^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${value}`);
|
|
565
446
|
}
|
|
566
|
-
function imageBase64$
|
|
567
|
-
return typeof value === "string" && /^(data:image\/)/.test(
|
|
447
|
+
function imageBase64$1(value) {
|
|
448
|
+
return typeof value === "string" && /^(data:image\/)/.test(`${value}`);
|
|
568
449
|
}
|
|
569
|
-
function imageSrc$
|
|
570
|
-
return imageBase64$
|
|
450
|
+
function imageSrc$1(value) {
|
|
451
|
+
return imageBase64$1(value) || imageURL$1(value);
|
|
571
452
|
}
|
|
572
|
-
function svg$
|
|
573
|
-
return typeof value === "string" && /^(<svg[\s]{1,}|<svg>)/i.test(
|
|
453
|
+
function svg$1(value) {
|
|
454
|
+
return typeof value === "string" && /^(<svg[\s]{1,}|<svg>)/i.test(`${value}`.trim()) && /<\/[\s]{0,}svg>$/i.test(`${value}`.trim());
|
|
574
455
|
}
|
|
575
|
-
function html$
|
|
576
|
-
|
|
456
|
+
function html$1(value) {
|
|
457
|
+
let result = false;
|
|
577
458
|
if (typeof value === "string") {
|
|
578
|
-
|
|
459
|
+
let div = document.createElement("div");
|
|
579
460
|
div.innerHTML = value;
|
|
580
461
|
if (div.children.length > 0) {
|
|
581
462
|
result = true;
|
|
@@ -584,53 +465,53 @@ var iDrawCore = function() {
|
|
|
584
465
|
}
|
|
585
466
|
return result;
|
|
586
467
|
}
|
|
587
|
-
function text$
|
|
468
|
+
function text$1(value) {
|
|
588
469
|
return typeof value === "string";
|
|
589
470
|
}
|
|
590
|
-
function fontSize$
|
|
591
|
-
return number$
|
|
471
|
+
function fontSize$1(value) {
|
|
472
|
+
return number$1(value) && value > 0;
|
|
592
473
|
}
|
|
593
|
-
function lineHeight$
|
|
594
|
-
return number$
|
|
474
|
+
function lineHeight$1(value) {
|
|
475
|
+
return number$1(value) && value > 0;
|
|
595
476
|
}
|
|
596
|
-
function strokeWidth$
|
|
597
|
-
return number$
|
|
477
|
+
function strokeWidth$1(value) {
|
|
478
|
+
return number$1(value) && value > 0;
|
|
598
479
|
}
|
|
599
|
-
function textAlign$
|
|
480
|
+
function textAlign$1(value) {
|
|
600
481
|
return ["center", "left", "right"].includes(value);
|
|
601
482
|
}
|
|
602
|
-
function fontFamily$
|
|
483
|
+
function fontFamily$1(value) {
|
|
603
484
|
return typeof value === "string" && value.length > 0;
|
|
604
485
|
}
|
|
605
|
-
function fontWeight$
|
|
486
|
+
function fontWeight$1(value) {
|
|
606
487
|
return ["bold"].includes(value);
|
|
607
488
|
}
|
|
608
|
-
|
|
609
|
-
x: x$
|
|
610
|
-
y: y$
|
|
611
|
-
w: w$
|
|
612
|
-
h: h$
|
|
613
|
-
angle: angle$
|
|
614
|
-
number: number$
|
|
615
|
-
borderWidth: borderWidth$
|
|
616
|
-
borderRadius: borderRadius$
|
|
617
|
-
color: color$
|
|
618
|
-
imageSrc: imageSrc$
|
|
619
|
-
imageURL: imageURL$
|
|
620
|
-
imageBase64: imageBase64$
|
|
621
|
-
svg: svg$
|
|
622
|
-
html: html$
|
|
623
|
-
text: text$
|
|
624
|
-
fontSize: fontSize$
|
|
625
|
-
lineHeight: lineHeight$
|
|
626
|
-
textAlign: textAlign$
|
|
627
|
-
fontFamily: fontFamily$
|
|
628
|
-
fontWeight: fontWeight$
|
|
629
|
-
strokeWidth: strokeWidth$
|
|
489
|
+
const is$1 = {
|
|
490
|
+
x: x$1,
|
|
491
|
+
y: y$1,
|
|
492
|
+
w: w$1,
|
|
493
|
+
h: h$1,
|
|
494
|
+
angle: angle$1,
|
|
495
|
+
number: number$1,
|
|
496
|
+
borderWidth: borderWidth$1,
|
|
497
|
+
borderRadius: borderRadius$1,
|
|
498
|
+
color: color$1,
|
|
499
|
+
imageSrc: imageSrc$1,
|
|
500
|
+
imageURL: imageURL$1,
|
|
501
|
+
imageBase64: imageBase64$1,
|
|
502
|
+
svg: svg$1,
|
|
503
|
+
html: html$1,
|
|
504
|
+
text: text$1,
|
|
505
|
+
fontSize: fontSize$1,
|
|
506
|
+
lineHeight: lineHeight$1,
|
|
507
|
+
textAlign: textAlign$1,
|
|
508
|
+
fontFamily: fontFamily$1,
|
|
509
|
+
fontWeight: fontWeight$1,
|
|
510
|
+
strokeWidth: strokeWidth$1
|
|
630
511
|
};
|
|
631
512
|
function attrs$1(attrs2) {
|
|
632
|
-
|
|
633
|
-
if (!(is$
|
|
513
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = attrs2;
|
|
514
|
+
if (!(is$1.x(x2) && is$1.y(y2) && is$1.w(w2) && is$1.h(h2) && is$1.angle(angle2))) {
|
|
634
515
|
return false;
|
|
635
516
|
}
|
|
636
517
|
if (!(angle2 >= -360 && angle2 <= 360)) {
|
|
@@ -638,25 +519,22 @@ var iDrawCore = function() {
|
|
|
638
519
|
}
|
|
639
520
|
return true;
|
|
640
521
|
}
|
|
641
|
-
function box$1(desc) {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
}
|
|
645
|
-
var borderColor = desc.borderColor, borderRadius2 = desc.borderRadius, borderWidth2 = desc.borderWidth;
|
|
646
|
-
if (desc.hasOwnProperty("borderColor") && !is$3.color(borderColor)) {
|
|
522
|
+
function box$1(desc = {}) {
|
|
523
|
+
const { borderColor, borderRadius: borderRadius2, borderWidth: borderWidth2 } = desc;
|
|
524
|
+
if (desc.hasOwnProperty("borderColor") && !is$1.color(borderColor)) {
|
|
647
525
|
return false;
|
|
648
526
|
}
|
|
649
|
-
if (desc.hasOwnProperty("borderRadius") && !is$
|
|
527
|
+
if (desc.hasOwnProperty("borderRadius") && !is$1.number(borderRadius2)) {
|
|
650
528
|
return false;
|
|
651
529
|
}
|
|
652
|
-
if (desc.hasOwnProperty("borderWidth") && !is$
|
|
530
|
+
if (desc.hasOwnProperty("borderWidth") && !is$1.number(borderWidth2)) {
|
|
653
531
|
return false;
|
|
654
532
|
}
|
|
655
533
|
return true;
|
|
656
534
|
}
|
|
657
535
|
function rectDesc$1(desc) {
|
|
658
|
-
|
|
659
|
-
if (desc.hasOwnProperty("bgColor") && !is$
|
|
536
|
+
const { bgColor } = desc;
|
|
537
|
+
if (desc.hasOwnProperty("bgColor") && !is$1.color(bgColor)) {
|
|
660
538
|
return false;
|
|
661
539
|
}
|
|
662
540
|
if (!box$1(desc)) {
|
|
@@ -665,69 +543,69 @@ var iDrawCore = function() {
|
|
|
665
543
|
return true;
|
|
666
544
|
}
|
|
667
545
|
function circleDesc$1(desc) {
|
|
668
|
-
|
|
669
|
-
if (desc.hasOwnProperty("bgColor") && !is$
|
|
546
|
+
const { bgColor, borderColor, borderWidth: borderWidth2 } = desc;
|
|
547
|
+
if (desc.hasOwnProperty("bgColor") && !is$1.color(bgColor)) {
|
|
670
548
|
return false;
|
|
671
549
|
}
|
|
672
|
-
if (desc.hasOwnProperty("borderColor") && !is$
|
|
550
|
+
if (desc.hasOwnProperty("borderColor") && !is$1.color(borderColor)) {
|
|
673
551
|
return false;
|
|
674
552
|
}
|
|
675
|
-
if (desc.hasOwnProperty("borderWidth") && !is$
|
|
553
|
+
if (desc.hasOwnProperty("borderWidth") && !is$1.number(borderWidth2)) {
|
|
676
554
|
return false;
|
|
677
555
|
}
|
|
678
556
|
return true;
|
|
679
557
|
}
|
|
680
558
|
function imageDesc$1(desc) {
|
|
681
|
-
|
|
682
|
-
if (!is$
|
|
559
|
+
const { src } = desc;
|
|
560
|
+
if (!is$1.imageSrc(src)) {
|
|
683
561
|
return false;
|
|
684
562
|
}
|
|
685
563
|
return true;
|
|
686
564
|
}
|
|
687
565
|
function svgDesc$1(desc) {
|
|
688
|
-
|
|
689
|
-
if (!is$
|
|
566
|
+
const { svg: svg2 } = desc;
|
|
567
|
+
if (!is$1.svg(svg2)) {
|
|
690
568
|
return false;
|
|
691
569
|
}
|
|
692
570
|
return true;
|
|
693
571
|
}
|
|
694
572
|
function htmlDesc$1(desc) {
|
|
695
|
-
|
|
696
|
-
if (!is$
|
|
573
|
+
const { html: html2 } = desc;
|
|
574
|
+
if (!is$1.html(html2)) {
|
|
697
575
|
return false;
|
|
698
576
|
}
|
|
699
577
|
return true;
|
|
700
578
|
}
|
|
701
579
|
function textDesc$1(desc) {
|
|
702
|
-
|
|
703
|
-
if (!is$
|
|
580
|
+
const { text: text2, color: color2, fontSize: fontSize2, lineHeight: lineHeight2, fontFamily: fontFamily2, textAlign: textAlign2, fontWeight: fontWeight2, bgColor, strokeWidth: strokeWidth2, strokeColor } = desc;
|
|
581
|
+
if (!is$1.text(text2)) {
|
|
704
582
|
return false;
|
|
705
583
|
}
|
|
706
|
-
if (!is$
|
|
584
|
+
if (!is$1.color(color2)) {
|
|
707
585
|
return false;
|
|
708
586
|
}
|
|
709
|
-
if (!is$
|
|
587
|
+
if (!is$1.fontSize(fontSize2)) {
|
|
710
588
|
return false;
|
|
711
589
|
}
|
|
712
|
-
if (desc.hasOwnProperty("bgColor") && !is$
|
|
590
|
+
if (desc.hasOwnProperty("bgColor") && !is$1.color(bgColor)) {
|
|
713
591
|
return false;
|
|
714
592
|
}
|
|
715
|
-
if (desc.hasOwnProperty("fontWeight") && !is$
|
|
593
|
+
if (desc.hasOwnProperty("fontWeight") && !is$1.fontWeight(fontWeight2)) {
|
|
716
594
|
return false;
|
|
717
595
|
}
|
|
718
|
-
if (desc.hasOwnProperty("lineHeight") && !is$
|
|
596
|
+
if (desc.hasOwnProperty("lineHeight") && !is$1.lineHeight(lineHeight2)) {
|
|
719
597
|
return false;
|
|
720
598
|
}
|
|
721
|
-
if (desc.hasOwnProperty("fontFamily") && !is$
|
|
599
|
+
if (desc.hasOwnProperty("fontFamily") && !is$1.fontFamily(fontFamily2)) {
|
|
722
600
|
return false;
|
|
723
601
|
}
|
|
724
|
-
if (desc.hasOwnProperty("textAlign") && !is$
|
|
602
|
+
if (desc.hasOwnProperty("textAlign") && !is$1.textAlign(textAlign2)) {
|
|
725
603
|
return false;
|
|
726
604
|
}
|
|
727
|
-
if (desc.hasOwnProperty("strokeWidth") && !is$
|
|
605
|
+
if (desc.hasOwnProperty("strokeWidth") && !is$1.strokeWidth(strokeWidth2)) {
|
|
728
606
|
return false;
|
|
729
607
|
}
|
|
730
|
-
if (desc.hasOwnProperty("strokeColor") && !is$
|
|
608
|
+
if (desc.hasOwnProperty("strokeColor") && !is$1.color(strokeColor)) {
|
|
731
609
|
return false;
|
|
732
610
|
}
|
|
733
611
|
if (!box$1(desc)) {
|
|
@@ -735,7 +613,7 @@ var iDrawCore = function() {
|
|
|
735
613
|
}
|
|
736
614
|
return true;
|
|
737
615
|
}
|
|
738
|
-
|
|
616
|
+
const check$1 = {
|
|
739
617
|
attrs: attrs$1,
|
|
740
618
|
textDesc: textDesc$1,
|
|
741
619
|
rectDesc: rectDesc$1,
|
|
@@ -744,43 +622,42 @@ var iDrawCore = function() {
|
|
|
744
622
|
svgDesc: svgDesc$1,
|
|
745
623
|
htmlDesc: htmlDesc$1
|
|
746
624
|
};
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
is: is$3,
|
|
625
|
+
const util = {
|
|
626
|
+
is: is$1,
|
|
750
627
|
check: check$1,
|
|
751
628
|
delay,
|
|
752
629
|
compose,
|
|
753
630
|
throttle: throttle$1,
|
|
754
|
-
loadImage
|
|
755
|
-
loadSVG
|
|
756
|
-
loadHTML
|
|
631
|
+
loadImage,
|
|
632
|
+
loadSVG,
|
|
633
|
+
loadHTML,
|
|
757
634
|
downloadImageFromCanvas,
|
|
758
635
|
toColorHexStr,
|
|
759
636
|
toColorHexNum,
|
|
760
|
-
isColorStr
|
|
761
|
-
createUUID
|
|
762
|
-
istype
|
|
763
|
-
deepClone
|
|
637
|
+
isColorStr,
|
|
638
|
+
createUUID,
|
|
639
|
+
istype,
|
|
640
|
+
deepClone,
|
|
764
641
|
Context: Context$1
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
|
|
642
|
+
};
|
|
643
|
+
class BoardEvent {
|
|
644
|
+
constructor() {
|
|
768
645
|
this._listeners = /* @__PURE__ */ new Map();
|
|
769
646
|
}
|
|
770
|
-
|
|
647
|
+
on(eventKey, callback) {
|
|
771
648
|
if (this._listeners.has(eventKey)) {
|
|
772
|
-
|
|
649
|
+
const callbacks = this._listeners.get(eventKey);
|
|
773
650
|
callbacks === null || callbacks === void 0 ? void 0 : callbacks.push(callback);
|
|
774
651
|
this._listeners.set(eventKey, callbacks || []);
|
|
775
652
|
} else {
|
|
776
653
|
this._listeners.set(eventKey, [callback]);
|
|
777
654
|
}
|
|
778
|
-
}
|
|
779
|
-
|
|
655
|
+
}
|
|
656
|
+
off(eventKey, callback) {
|
|
780
657
|
if (this._listeners.has(eventKey)) {
|
|
781
|
-
|
|
658
|
+
const callbacks = this._listeners.get(eventKey);
|
|
782
659
|
if (Array.isArray(callbacks)) {
|
|
783
|
-
for (
|
|
660
|
+
for (let i = 0; i < (callbacks === null || callbacks === void 0 ? void 0 : callbacks.length); i++) {
|
|
784
661
|
if (callbacks[i] === callback) {
|
|
785
662
|
callbacks.splice(i, 1);
|
|
786
663
|
break;
|
|
@@ -789,29 +666,28 @@ var iDrawCore = function() {
|
|
|
789
666
|
}
|
|
790
667
|
this._listeners.set(eventKey, callbacks || []);
|
|
791
668
|
}
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
|
|
669
|
+
}
|
|
670
|
+
trigger(eventKey, arg) {
|
|
671
|
+
const callbacks = this._listeners.get(eventKey);
|
|
795
672
|
if (Array.isArray(callbacks)) {
|
|
796
|
-
callbacks.forEach(
|
|
673
|
+
callbacks.forEach((cb) => {
|
|
797
674
|
cb(arg);
|
|
798
675
|
});
|
|
799
676
|
return true;
|
|
800
677
|
} else {
|
|
801
678
|
return false;
|
|
802
679
|
}
|
|
803
|
-
}
|
|
804
|
-
|
|
680
|
+
}
|
|
681
|
+
has(name) {
|
|
805
682
|
if (this._listeners.has(name)) {
|
|
806
|
-
|
|
683
|
+
const list = this._listeners.get(name);
|
|
807
684
|
if (Array.isArray(list) && list.length > 0) {
|
|
808
685
|
return true;
|
|
809
686
|
}
|
|
810
687
|
}
|
|
811
688
|
return false;
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
}();
|
|
689
|
+
}
|
|
690
|
+
}
|
|
815
691
|
function createTempData() {
|
|
816
692
|
return {
|
|
817
693
|
prevClickPoint: null,
|
|
@@ -825,23 +701,22 @@ var iDrawCore = function() {
|
|
|
825
701
|
}
|
|
826
702
|
};
|
|
827
703
|
}
|
|
828
|
-
|
|
829
|
-
|
|
704
|
+
let TempData$2 = class TempData {
|
|
705
|
+
constructor() {
|
|
830
706
|
this._temp = createTempData();
|
|
831
707
|
}
|
|
832
|
-
|
|
708
|
+
set(name, value) {
|
|
833
709
|
this._temp[name] = value;
|
|
834
|
-
}
|
|
835
|
-
|
|
710
|
+
}
|
|
711
|
+
get(name) {
|
|
836
712
|
return this._temp[name];
|
|
837
|
-
}
|
|
838
|
-
|
|
713
|
+
}
|
|
714
|
+
clear() {
|
|
839
715
|
this._temp = createTempData();
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
function ScreenWatcher2(canvas, ctx) {
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
class ScreenWatcher {
|
|
719
|
+
constructor(canvas, ctx) {
|
|
845
720
|
this._isMoving = false;
|
|
846
721
|
this._temp = new TempData$2();
|
|
847
722
|
this._container = window;
|
|
@@ -850,18 +725,18 @@ var iDrawCore = function() {
|
|
|
850
725
|
this._initEvent();
|
|
851
726
|
this._event = new BoardEvent();
|
|
852
727
|
}
|
|
853
|
-
|
|
728
|
+
setStatusMap(statusMap) {
|
|
854
729
|
this._temp.set("statusMap", statusMap);
|
|
855
|
-
}
|
|
856
|
-
|
|
730
|
+
}
|
|
731
|
+
on(name, callback) {
|
|
857
732
|
this._event.on(name, callback);
|
|
858
|
-
}
|
|
859
|
-
|
|
733
|
+
}
|
|
734
|
+
off(name, callback) {
|
|
860
735
|
this._event.off(name, callback);
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
736
|
+
}
|
|
737
|
+
_initEvent() {
|
|
738
|
+
const canvas = this._canvas;
|
|
739
|
+
const container = this._container;
|
|
865
740
|
container.addEventListener("mousemove", this._listenWindowMove.bind(this), false);
|
|
866
741
|
container.addEventListener("mouseup", this._listenWindowMoveEnd.bind(this), false);
|
|
867
742
|
canvas.addEventListener("mousemove", this._listenHover.bind(this), false);
|
|
@@ -875,11 +750,11 @@ var iDrawCore = function() {
|
|
|
875
750
|
canvas.addEventListener("mouseover", this._listenCanvasMoveOver.bind(this), true);
|
|
876
751
|
canvas.addEventListener("mouseleave", this._listenCanvasMoveLeave.bind(this), true);
|
|
877
752
|
this._initParentEvent();
|
|
878
|
-
}
|
|
879
|
-
|
|
753
|
+
}
|
|
754
|
+
_initParentEvent() {
|
|
880
755
|
try {
|
|
881
|
-
|
|
882
|
-
|
|
756
|
+
let target = window;
|
|
757
|
+
const targetOrigin = target.origin;
|
|
883
758
|
while (target.self !== target.top) {
|
|
884
759
|
if (target.self !== target.parent) {
|
|
885
760
|
if (target.origin === targetOrigin) {
|
|
@@ -894,20 +769,20 @@ var iDrawCore = function() {
|
|
|
894
769
|
} catch (err) {
|
|
895
770
|
console.warn(err);
|
|
896
771
|
}
|
|
897
|
-
}
|
|
898
|
-
|
|
772
|
+
}
|
|
773
|
+
_listenHover(e) {
|
|
899
774
|
e.preventDefault();
|
|
900
|
-
|
|
775
|
+
const p = this._getPosition(e);
|
|
901
776
|
if (this._isVaildPoint(p)) {
|
|
902
777
|
if (this._event.has("hover")) {
|
|
903
778
|
this._event.trigger("hover", p);
|
|
904
779
|
}
|
|
905
780
|
}
|
|
906
781
|
this._isMoving = true;
|
|
907
|
-
}
|
|
908
|
-
|
|
782
|
+
}
|
|
783
|
+
_listenMoveStart(e) {
|
|
909
784
|
e.preventDefault();
|
|
910
|
-
|
|
785
|
+
const p = this._getPosition(e);
|
|
911
786
|
if (this._isVaildPoint(p)) {
|
|
912
787
|
if (this._event.has("point")) {
|
|
913
788
|
this._event.trigger("point", p);
|
|
@@ -917,28 +792,28 @@ var iDrawCore = function() {
|
|
|
917
792
|
}
|
|
918
793
|
}
|
|
919
794
|
this._isMoving = true;
|
|
920
|
-
}
|
|
921
|
-
|
|
795
|
+
}
|
|
796
|
+
_listenMove(e) {
|
|
922
797
|
e.preventDefault();
|
|
923
798
|
e.stopPropagation();
|
|
924
799
|
if (this._event.has("move") && this._isMoving === true) {
|
|
925
|
-
|
|
800
|
+
const p = this._getPosition(e);
|
|
926
801
|
if (this._isVaildPoint(p)) {
|
|
927
802
|
this._event.trigger("move", p);
|
|
928
803
|
}
|
|
929
804
|
}
|
|
930
|
-
}
|
|
931
|
-
|
|
805
|
+
}
|
|
806
|
+
_listenMoveEnd(e) {
|
|
932
807
|
e.preventDefault();
|
|
933
808
|
if (this._event.has("moveEnd")) {
|
|
934
|
-
|
|
809
|
+
const p = this._getPosition(e);
|
|
935
810
|
if (this._isVaildPoint(p)) {
|
|
936
811
|
this._event.trigger("moveEnd", p);
|
|
937
812
|
}
|
|
938
813
|
}
|
|
939
814
|
this._isMoving = false;
|
|
940
|
-
}
|
|
941
|
-
|
|
815
|
+
}
|
|
816
|
+
_listSameOriginParentWindow() {
|
|
942
817
|
if (this._temp.get("isHoverCanvas")) {
|
|
943
818
|
if (this._event.has("leave")) {
|
|
944
819
|
this._event.trigger("leave", void 0);
|
|
@@ -952,59 +827,59 @@ var iDrawCore = function() {
|
|
|
952
827
|
this._isMoving = false;
|
|
953
828
|
this._temp.set("isDragCanvas", false);
|
|
954
829
|
this._temp.set("isHoverCanvas", false);
|
|
955
|
-
}
|
|
956
|
-
|
|
830
|
+
}
|
|
831
|
+
_listenCanvasMoveStart() {
|
|
957
832
|
if (this._temp.get("isHoverCanvas")) {
|
|
958
833
|
this._temp.set("isDragCanvas", true);
|
|
959
834
|
}
|
|
960
|
-
}
|
|
961
|
-
|
|
835
|
+
}
|
|
836
|
+
_listenCanvasMoveEnd() {
|
|
962
837
|
this._temp.set("isDragCanvas", false);
|
|
963
|
-
}
|
|
964
|
-
|
|
838
|
+
}
|
|
839
|
+
_listenCanvasMoveOver() {
|
|
965
840
|
this._temp.set("isHoverCanvas", true);
|
|
966
|
-
}
|
|
967
|
-
|
|
841
|
+
}
|
|
842
|
+
_listenCanvasMoveLeave() {
|
|
968
843
|
this._temp.set("isHoverCanvas", false);
|
|
969
844
|
if (this._event.has("leave")) {
|
|
970
845
|
this._event.trigger("leave", void 0);
|
|
971
846
|
}
|
|
972
|
-
}
|
|
973
|
-
|
|
847
|
+
}
|
|
848
|
+
_listenWindowMove(e) {
|
|
974
849
|
if (this._temp.get("isDragCanvas") !== true) {
|
|
975
850
|
return;
|
|
976
851
|
}
|
|
977
852
|
e.preventDefault();
|
|
978
853
|
e.stopPropagation();
|
|
979
854
|
if (this._event.has("move") && this._isMoving === true) {
|
|
980
|
-
|
|
855
|
+
const p = this._getPosition(e);
|
|
981
856
|
if (this._isVaildPoint(p)) {
|
|
982
857
|
this._event.trigger("move", p);
|
|
983
858
|
}
|
|
984
859
|
}
|
|
985
|
-
}
|
|
986
|
-
|
|
860
|
+
}
|
|
861
|
+
_listenWindowMoveEnd(e) {
|
|
987
862
|
if (!this._temp.get("isDragCanvas") === true) {
|
|
988
863
|
return;
|
|
989
864
|
}
|
|
990
865
|
e.preventDefault();
|
|
991
866
|
if (this._event.has("moveEnd")) {
|
|
992
|
-
|
|
867
|
+
const p = this._getPosition(e);
|
|
993
868
|
if (this._isVaildPoint(p)) {
|
|
994
869
|
this._event.trigger("moveEnd", p);
|
|
995
870
|
}
|
|
996
871
|
}
|
|
997
872
|
this._temp.set("isDragCanvas", false);
|
|
998
873
|
this._isMoving = false;
|
|
999
|
-
}
|
|
1000
|
-
|
|
874
|
+
}
|
|
875
|
+
_listenCanvasWheel(e) {
|
|
1001
876
|
if (this._event.has("wheelX") && (e.deltaX > 0 || e.deltaX < 0)) {
|
|
1002
877
|
this._event.trigger("wheelX", e.deltaX);
|
|
1003
878
|
}
|
|
1004
879
|
if (this._event.has("wheelY") && (e.deltaY > 0 || e.deltaY < 0)) {
|
|
1005
880
|
this._event.trigger("wheelY", e.deltaY);
|
|
1006
881
|
}
|
|
1007
|
-
|
|
882
|
+
const { canScrollYNext, canScrollYPrev } = this._temp.get("statusMap");
|
|
1008
883
|
if (e.deltaX > 0 && e.deltaX < 0) {
|
|
1009
884
|
e.preventDefault();
|
|
1010
885
|
} else if (e.deltaY > 0 && canScrollYNext === true) {
|
|
@@ -1012,14 +887,14 @@ var iDrawCore = function() {
|
|
|
1012
887
|
} else if (e.deltaY < 0 && canScrollYPrev === true) {
|
|
1013
888
|
e.preventDefault();
|
|
1014
889
|
}
|
|
1015
|
-
}
|
|
1016
|
-
|
|
890
|
+
}
|
|
891
|
+
_listenCanvasClick(e) {
|
|
1017
892
|
e.preventDefault();
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
893
|
+
const maxLimitTime = 500;
|
|
894
|
+
const p = this._getPosition(e);
|
|
895
|
+
const t = Date.now();
|
|
1021
896
|
if (this._isVaildPoint(p)) {
|
|
1022
|
-
|
|
897
|
+
const preClickPoint = this._temp.get("prevClickPoint");
|
|
1023
898
|
if (preClickPoint && t - preClickPoint.t <= maxLimitTime && Math.abs(preClickPoint.x - p.x) <= 5 && Math.abs(preClickPoint.y - p.y) <= 5) {
|
|
1024
899
|
if (this._event.has("doubleClick")) {
|
|
1025
900
|
this._event.trigger("doubleClick", { x: p.x, y: p.y });
|
|
@@ -1028,13 +903,13 @@ var iDrawCore = function() {
|
|
|
1028
903
|
this._temp.set("prevClickPoint", { x: p.x, y: p.y, t });
|
|
1029
904
|
}
|
|
1030
905
|
}
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
906
|
+
}
|
|
907
|
+
_getPosition(e) {
|
|
908
|
+
const canvas = this._canvas;
|
|
909
|
+
let x2 = 0;
|
|
910
|
+
let y2 = 0;
|
|
1036
911
|
if (e && e.touches && e.touches.length > 0) {
|
|
1037
|
-
|
|
912
|
+
const touch = e.touches[0];
|
|
1038
913
|
if (touch) {
|
|
1039
914
|
x2 = touch.clientX;
|
|
1040
915
|
y2 = touch.clientY;
|
|
@@ -1043,62 +918,67 @@ var iDrawCore = function() {
|
|
|
1043
918
|
x2 = e.clientX;
|
|
1044
919
|
y2 = e.clientY;
|
|
1045
920
|
}
|
|
1046
|
-
|
|
921
|
+
const p = {
|
|
1047
922
|
x: x2 - canvas.getBoundingClientRect().left,
|
|
1048
923
|
y: y2 - canvas.getBoundingClientRect().top,
|
|
1049
924
|
t: Date.now()
|
|
1050
925
|
};
|
|
1051
926
|
return p;
|
|
1052
|
-
}
|
|
1053
|
-
|
|
927
|
+
}
|
|
928
|
+
_isVaildPoint(p) {
|
|
1054
929
|
return isAvailableNum(p.x) && isAvailableNum(p.y);
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
}();
|
|
930
|
+
}
|
|
931
|
+
}
|
|
1058
932
|
function isAvailableNum(num) {
|
|
1059
933
|
return num > 0 || num < 0 || num === 0;
|
|
1060
934
|
}
|
|
1061
935
|
function setStyle(dom, style) {
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
keys.forEach(
|
|
1067
|
-
styleStr +=
|
|
936
|
+
const originStyle = getStyle(dom);
|
|
937
|
+
const _style = Object.assign(Object.assign({}, originStyle), style);
|
|
938
|
+
const keys = Object.keys(_style);
|
|
939
|
+
let styleStr = "";
|
|
940
|
+
keys.forEach((key) => {
|
|
941
|
+
styleStr += `${key}:${_style[key] || ""};`;
|
|
1068
942
|
});
|
|
1069
943
|
dom.setAttribute("style", styleStr);
|
|
1070
944
|
}
|
|
1071
945
|
function getStyle(dom) {
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
styleList.forEach(
|
|
1076
|
-
|
|
946
|
+
const styleObj = {};
|
|
947
|
+
const style = dom.getAttribute("style") || "";
|
|
948
|
+
const styleList = style.split(";");
|
|
949
|
+
styleList.forEach((item) => {
|
|
950
|
+
const dataList = item.split(":");
|
|
1077
951
|
if (dataList[0] && typeof dataList[0] === "string") {
|
|
1078
952
|
styleObj[dataList[0]] = dataList[1] || "";
|
|
1079
953
|
}
|
|
1080
954
|
});
|
|
1081
955
|
return styleObj;
|
|
1082
956
|
}
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
957
|
+
const minScrollerWidth = 12;
|
|
958
|
+
const scrollerAlpha = 0.12;
|
|
959
|
+
const scrollerThumbAlpha = 0.36;
|
|
960
|
+
const defaultScrollConfig = {
|
|
961
|
+
width: minScrollerWidth,
|
|
962
|
+
color: "#000000",
|
|
963
|
+
showBackground: true
|
|
1086
964
|
};
|
|
1087
|
-
|
|
1088
|
-
|
|
965
|
+
class Scroller {
|
|
966
|
+
constructor(ctx, opts) {
|
|
1089
967
|
this._displayCtx = ctx;
|
|
1090
968
|
this._opts = this._getOpts(opts);
|
|
1091
969
|
}
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
970
|
+
draw(position) {
|
|
971
|
+
const { width, height, scrollConfig } = this._opts;
|
|
972
|
+
const wrapper = this.calc(position);
|
|
973
|
+
const ctx = this._displayCtx;
|
|
1096
974
|
if (wrapper.xSize > 0) {
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
975
|
+
if (scrollConfig.showBackground === true) {
|
|
976
|
+
ctx.globalAlpha = scrollerAlpha;
|
|
977
|
+
ctx.fillStyle = wrapper.color;
|
|
978
|
+
ctx.fillRect(0, this._doSize(height - wrapper.lineSize), this._doSize(width), this._doSize(wrapper.lineSize));
|
|
979
|
+
}
|
|
980
|
+
drawBoxScrollerThumb(ctx, {
|
|
981
|
+
axis: "X",
|
|
1102
982
|
x: this._doSize(wrapper.translateX),
|
|
1103
983
|
y: this._doSize(height - wrapper.lineSize),
|
|
1104
984
|
w: this._doSize(wrapper.xSize),
|
|
@@ -1108,11 +988,13 @@ var iDrawCore = function() {
|
|
|
1108
988
|
});
|
|
1109
989
|
}
|
|
1110
990
|
if (wrapper.ySize > 0) {
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
991
|
+
if (scrollConfig.showBackground === true) {
|
|
992
|
+
ctx.globalAlpha = scrollerAlpha;
|
|
993
|
+
ctx.fillStyle = wrapper.color;
|
|
994
|
+
ctx.fillRect(this._doSize(width - wrapper.lineSize), 0, this._doSize(wrapper.lineSize), this._doSize(height));
|
|
995
|
+
}
|
|
996
|
+
drawBoxScrollerThumb(ctx, {
|
|
997
|
+
axis: "Y",
|
|
1116
998
|
x: this._doSize(width - wrapper.lineSize),
|
|
1117
999
|
y: this._doSize(wrapper.translateY),
|
|
1118
1000
|
w: this._doSize(wrapper.lineSize),
|
|
@@ -1122,42 +1004,42 @@ var iDrawCore = function() {
|
|
|
1122
1004
|
});
|
|
1123
1005
|
}
|
|
1124
1006
|
ctx.globalAlpha = 1;
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
this._opts =
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1007
|
+
}
|
|
1008
|
+
resetSize(opts) {
|
|
1009
|
+
this._opts = Object.assign(Object.assign({}, this._opts), opts);
|
|
1010
|
+
}
|
|
1011
|
+
isPointAtScrollY(p) {
|
|
1012
|
+
const { width, height, scrollConfig } = this._opts;
|
|
1013
|
+
const ctx = this._displayCtx;
|
|
1132
1014
|
ctx.beginPath();
|
|
1133
|
-
ctx.rect(this._doSize(width - scrollConfig.
|
|
1015
|
+
ctx.rect(this._doSize(width - scrollConfig.width), 0, this._doSize(scrollConfig.width), this._doSize(height));
|
|
1134
1016
|
ctx.closePath();
|
|
1135
1017
|
if (ctx.isPointInPath(this._doSize(p.x), this._doSize(p.y))) {
|
|
1136
1018
|
return true;
|
|
1137
1019
|
}
|
|
1138
1020
|
return false;
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1021
|
+
}
|
|
1022
|
+
isPointAtScrollX(p) {
|
|
1023
|
+
const { width, height, scrollConfig } = this._opts;
|
|
1024
|
+
const ctx = this._displayCtx;
|
|
1143
1025
|
ctx.beginPath();
|
|
1144
|
-
ctx.rect(0, this._doSize(height - scrollConfig.
|
|
1026
|
+
ctx.rect(0, this._doSize(height - scrollConfig.width), this._doSize(width - scrollConfig.width), this._doSize(scrollConfig.width));
|
|
1145
1027
|
ctx.closePath();
|
|
1146
1028
|
if (ctx.isPointInPath(this._doSize(p.x), this._doSize(p.y))) {
|
|
1147
1029
|
return true;
|
|
1148
1030
|
}
|
|
1149
1031
|
return false;
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1032
|
+
}
|
|
1033
|
+
getLineWidth() {
|
|
1034
|
+
const lineWidth = this._opts.scrollConfig.width;
|
|
1153
1035
|
return lineWidth;
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1036
|
+
}
|
|
1037
|
+
calc(position) {
|
|
1038
|
+
const { width, height, scrollConfig } = this._opts;
|
|
1039
|
+
const sliderMinSize = scrollConfig.width * 2.5;
|
|
1040
|
+
const lineSize = scrollConfig.width;
|
|
1041
|
+
let xSize = 0;
|
|
1042
|
+
let ySize = 0;
|
|
1161
1043
|
if (position.left <= 0 && position.right <= 0) {
|
|
1162
1044
|
xSize = Math.max(sliderMinSize, width - (Math.abs(position.left) + Math.abs(position.right)));
|
|
1163
1045
|
if (xSize >= width)
|
|
@@ -1168,17 +1050,17 @@ var iDrawCore = function() {
|
|
|
1168
1050
|
if (ySize >= height)
|
|
1169
1051
|
ySize = 0;
|
|
1170
1052
|
}
|
|
1171
|
-
|
|
1053
|
+
let translateX = 0;
|
|
1172
1054
|
if (xSize > 0) {
|
|
1173
1055
|
translateX = xSize / 2 + (width - xSize) * Math.abs(position.left) / (Math.abs(position.left) + Math.abs(position.right));
|
|
1174
1056
|
translateX = Math.min(Math.max(0, translateX - xSize / 2), width - xSize);
|
|
1175
1057
|
}
|
|
1176
|
-
|
|
1058
|
+
let translateY = 0;
|
|
1177
1059
|
if (ySize > 0) {
|
|
1178
1060
|
translateY = ySize / 2 + (height - ySize) * Math.abs(position.top) / (Math.abs(position.top) + Math.abs(position.bottom));
|
|
1179
1061
|
translateY = Math.min(Math.max(0, translateY - ySize / 2), height - ySize);
|
|
1180
1062
|
}
|
|
1181
|
-
|
|
1063
|
+
const scrollWrapper = {
|
|
1182
1064
|
lineSize,
|
|
1183
1065
|
xSize,
|
|
1184
1066
|
ySize,
|
|
@@ -1187,33 +1069,44 @@ var iDrawCore = function() {
|
|
|
1187
1069
|
color: this._opts.scrollConfig.color
|
|
1188
1070
|
};
|
|
1189
1071
|
return scrollWrapper;
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1072
|
+
}
|
|
1073
|
+
_doSize(num) {
|
|
1192
1074
|
return num * this._opts.devicePixelRatio;
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
var
|
|
1075
|
+
}
|
|
1076
|
+
_getOpts(opts) {
|
|
1077
|
+
var _a;
|
|
1078
|
+
const options = Object.assign(Object.assign({}, opts), {
|
|
1079
|
+
scrollConfig: Object.assign(Object.assign({}, defaultScrollConfig), opts.scrollConfig || {})
|
|
1080
|
+
});
|
|
1196
1081
|
if (!options.scrollConfig) {
|
|
1197
1082
|
options.scrollConfig = defaultScrollConfig;
|
|
1198
1083
|
}
|
|
1199
|
-
if (!(options.scrollConfig.
|
|
1200
|
-
options.scrollConfig.
|
|
1084
|
+
if (!(((_a = options === null || options === void 0 ? void 0 : options.scrollConfig) === null || _a === void 0 ? void 0 : _a.width) > 0)) {
|
|
1085
|
+
options.scrollConfig.width = defaultScrollConfig.width;
|
|
1201
1086
|
}
|
|
1202
|
-
options.scrollConfig.
|
|
1203
|
-
if (isColorStr
|
|
1087
|
+
options.scrollConfig.width = Math.max(options.scrollConfig.width, defaultScrollConfig.width);
|
|
1088
|
+
if (isColorStr(options.scrollConfig.color) !== true) {
|
|
1204
1089
|
options.scrollConfig.color = options.scrollConfig.color;
|
|
1205
1090
|
}
|
|
1206
1091
|
return options;
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
function drawBoxScrollerThumb(ctx, opts) {
|
|
1095
|
+
let { x: x2, y: y2, h: h2, w: w2 } = opts;
|
|
1096
|
+
const { color: color2, axis } = opts;
|
|
1097
|
+
if (axis === "X") {
|
|
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;
|
|
1213
1105
|
r = Math.min(r, w2 / 2, h2 / 2);
|
|
1214
1106
|
if (w2 < r * 2 || h2 < r * 2) {
|
|
1215
1107
|
r = 0;
|
|
1216
1108
|
}
|
|
1109
|
+
ctx.globalAlpha = scrollerThumbAlpha;
|
|
1217
1110
|
ctx.beginPath();
|
|
1218
1111
|
ctx.moveTo(x2 + r, y2);
|
|
1219
1112
|
ctx.arcTo(x2 + w2, y2, x2 + w2, y2 + h2, r);
|
|
@@ -1223,77 +1116,88 @@ var iDrawCore = function() {
|
|
|
1223
1116
|
ctx.closePath();
|
|
1224
1117
|
ctx.fillStyle = color2;
|
|
1225
1118
|
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();
|
|
1226
1130
|
}
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
this[_opts$1
|
|
1232
|
-
this[_ctx
|
|
1131
|
+
const _opts$1 = Symbol("_opts");
|
|
1132
|
+
const _ctx = Symbol("_ctx");
|
|
1133
|
+
class Screen {
|
|
1134
|
+
constructor(ctx, opts) {
|
|
1135
|
+
this[_opts$1] = opts;
|
|
1136
|
+
this[_ctx] = ctx;
|
|
1233
1137
|
}
|
|
1234
|
-
|
|
1235
|
-
this[_opts$1
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1138
|
+
resetSize(opts) {
|
|
1139
|
+
this[_opts$1] = Object.assign(Object.assign({}, this[_opts$1]), opts);
|
|
1140
|
+
}
|
|
1141
|
+
calcScreen() {
|
|
1142
|
+
const scaleRatio = this[_ctx].getTransform().scale;
|
|
1143
|
+
const { width, height, contextWidth, contextHeight, devicePixelRatio: pxRatio } = this[_opts$1];
|
|
1144
|
+
let canScrollXPrev = true;
|
|
1145
|
+
let canScrollXNext = true;
|
|
1146
|
+
let canScrollYPrev = true;
|
|
1147
|
+
let canScrollYNext = true;
|
|
1244
1148
|
if (contextWidth * scaleRatio <= width) {
|
|
1245
|
-
this[_ctx
|
|
1149
|
+
this[_ctx].setTransform({
|
|
1246
1150
|
scrollX: (width - contextWidth * scaleRatio) / 2
|
|
1247
1151
|
});
|
|
1248
1152
|
canScrollXPrev = false;
|
|
1249
1153
|
canScrollXNext = false;
|
|
1250
1154
|
}
|
|
1251
1155
|
if (contextHeight * scaleRatio <= height) {
|
|
1252
|
-
this[_ctx
|
|
1156
|
+
this[_ctx].setTransform({
|
|
1253
1157
|
scrollY: (height - contextHeight * scaleRatio) / 2
|
|
1254
1158
|
});
|
|
1255
1159
|
canScrollYPrev = false;
|
|
1256
1160
|
canScrollYNext = false;
|
|
1257
1161
|
}
|
|
1258
|
-
if (contextWidth * scaleRatio >= width && this[_ctx
|
|
1259
|
-
this[_ctx
|
|
1162
|
+
if (contextWidth * scaleRatio >= width && this[_ctx].getTransform().scrollX > 0) {
|
|
1163
|
+
this[_ctx].setTransform({
|
|
1260
1164
|
scrollX: 0
|
|
1261
1165
|
});
|
|
1262
1166
|
canScrollXPrev = false;
|
|
1263
1167
|
}
|
|
1264
|
-
if (contextHeight * scaleRatio >= height && this[_ctx
|
|
1265
|
-
this[_ctx
|
|
1168
|
+
if (contextHeight * scaleRatio >= height && this[_ctx].getTransform().scrollY > 0) {
|
|
1169
|
+
this[_ctx].setTransform({
|
|
1266
1170
|
scrollY: 0
|
|
1267
1171
|
});
|
|
1268
1172
|
canScrollYPrev = false;
|
|
1269
1173
|
}
|
|
1270
|
-
|
|
1174
|
+
const { scrollX: _scrollX, scrollY: _scrollY } = this[_ctx].getTransform();
|
|
1271
1175
|
if (_scrollX < 0 && Math.abs(_scrollX) > Math.abs(contextWidth * scaleRatio - width)) {
|
|
1272
|
-
this[_ctx
|
|
1176
|
+
this[_ctx].setTransform({
|
|
1273
1177
|
scrollX: 0 - Math.abs(contextWidth * scaleRatio - width)
|
|
1274
1178
|
});
|
|
1275
1179
|
canScrollXNext = false;
|
|
1276
1180
|
}
|
|
1277
1181
|
if (_scrollY < 0 && Math.abs(_scrollY) > Math.abs(contextHeight * scaleRatio - height)) {
|
|
1278
|
-
this[_ctx
|
|
1182
|
+
this[_ctx].setTransform({
|
|
1279
1183
|
scrollY: 0 - Math.abs(contextHeight * scaleRatio - height)
|
|
1280
1184
|
});
|
|
1281
1185
|
canScrollYNext = false;
|
|
1282
1186
|
}
|
|
1283
|
-
|
|
1284
|
-
|
|
1187
|
+
const { scrollX, scrollY } = this[_ctx].getTransform();
|
|
1188
|
+
const size = {
|
|
1285
1189
|
x: scrollX * scaleRatio,
|
|
1286
1190
|
y: scrollY * scaleRatio,
|
|
1287
1191
|
w: contextWidth * scaleRatio,
|
|
1288
1192
|
h: contextHeight * scaleRatio
|
|
1289
1193
|
};
|
|
1290
|
-
|
|
1194
|
+
const deviceSize = {
|
|
1291
1195
|
x: scrollX * pxRatio,
|
|
1292
1196
|
y: scrollY * pxRatio,
|
|
1293
1197
|
w: contextWidth * pxRatio * scaleRatio,
|
|
1294
1198
|
h: contextHeight * pxRatio * scaleRatio
|
|
1295
1199
|
};
|
|
1296
|
-
|
|
1200
|
+
const position = {
|
|
1297
1201
|
top: scrollY,
|
|
1298
1202
|
bottom: height - (contextHeight * scaleRatio + scrollY),
|
|
1299
1203
|
left: scrollX,
|
|
@@ -1303,1274 +1207,295 @@ var iDrawCore = function() {
|
|
|
1303
1207
|
size,
|
|
1304
1208
|
position,
|
|
1305
1209
|
deviceSize,
|
|
1306
|
-
width: this[_opts$1
|
|
1307
|
-
height: this[_opts$1
|
|
1308
|
-
devicePixelRatio: this[_opts$1
|
|
1210
|
+
width: this[_opts$1].width,
|
|
1211
|
+
height: this[_opts$1].height,
|
|
1212
|
+
devicePixelRatio: this[_opts$1].devicePixelRatio,
|
|
1309
1213
|
canScrollYPrev,
|
|
1310
1214
|
canScrollYNext,
|
|
1311
1215
|
canScrollXPrev,
|
|
1312
1216
|
canScrollXNext
|
|
1313
1217
|
};
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1218
|
+
}
|
|
1219
|
+
calcScreenScroll(start, end, sliderSize, limitLen, moveDistance) {
|
|
1220
|
+
let scrollDistance = start;
|
|
1221
|
+
let scrollLen = limitLen - sliderSize;
|
|
1318
1222
|
if (start <= 0 && end <= 0) {
|
|
1319
1223
|
scrollLen = Math.abs(start) + Math.abs(end);
|
|
1320
1224
|
}
|
|
1321
|
-
|
|
1225
|
+
let unit = 1;
|
|
1322
1226
|
if (scrollLen > 0) {
|
|
1323
1227
|
unit = scrollLen / (limitLen - sliderSize);
|
|
1324
1228
|
}
|
|
1325
1229
|
scrollDistance = 0 - unit * moveDistance;
|
|
1326
1230
|
return scrollDistance;
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
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;
|
|
1353
|
-
this[_mount] = mount;
|
|
1354
|
-
this[_canvas] = document.createElement("canvas");
|
|
1355
|
-
this[_helperCanvas] = document.createElement("canvas");
|
|
1356
|
-
this[_displayCanvas] = document.createElement("canvas");
|
|
1357
|
-
this[_mount].appendChild(this[_displayCanvas]);
|
|
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]);
|
|
1366
|
-
this[_scroller] = new Scroller(displayCtx2d, {
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
const { throttle, Context } = util;
|
|
1234
|
+
class Board {
|
|
1235
|
+
constructor(mount, opts) {
|
|
1236
|
+
this._hasRendered = false;
|
|
1237
|
+
this._mount = mount;
|
|
1238
|
+
this._canvas = document.createElement("canvas");
|
|
1239
|
+
this._helperCanvas = document.createElement("canvas");
|
|
1240
|
+
this._displayCanvas = document.createElement("canvas");
|
|
1241
|
+
this._mount.appendChild(this._displayCanvas);
|
|
1242
|
+
this._opts = this._parsePrivateOptions(opts);
|
|
1243
|
+
const originCtx2d = this._canvas.getContext("2d");
|
|
1244
|
+
const displayCtx2d = this._displayCanvas.getContext("2d");
|
|
1245
|
+
const helperCtx2d = this._helperCanvas.getContext("2d");
|
|
1246
|
+
this._ctx = new Context(originCtx2d, this._opts);
|
|
1247
|
+
this._helperCtx = new Context(helperCtx2d, this._opts);
|
|
1248
|
+
this._screen = new Screen(this._ctx, this._opts);
|
|
1249
|
+
this._watcher = new ScreenWatcher(this._displayCanvas, this._ctx);
|
|
1250
|
+
this._scroller = new Scroller(displayCtx2d, {
|
|
1367
1251
|
width: opts.width,
|
|
1368
1252
|
height: opts.height,
|
|
1369
1253
|
devicePixelRatio: opts.devicePixelRatio || 1,
|
|
1370
1254
|
scrollConfig: opts.scrollConfig
|
|
1371
1255
|
});
|
|
1372
|
-
this
|
|
1256
|
+
this._render();
|
|
1373
1257
|
}
|
|
1374
|
-
|
|
1375
|
-
return this
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
return this
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
return this
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
return this
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
return this
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1258
|
+
getDisplayContext2D() {
|
|
1259
|
+
return this._displayCanvas.getContext("2d");
|
|
1260
|
+
}
|
|
1261
|
+
getOriginContext2D() {
|
|
1262
|
+
return this._ctx.getContext();
|
|
1263
|
+
}
|
|
1264
|
+
getHelperContext2D() {
|
|
1265
|
+
return this._helperCtx.getContext();
|
|
1266
|
+
}
|
|
1267
|
+
getContext() {
|
|
1268
|
+
return this._ctx;
|
|
1269
|
+
}
|
|
1270
|
+
getHelperContext() {
|
|
1271
|
+
return this._helperCtx;
|
|
1272
|
+
}
|
|
1273
|
+
scale(scaleRatio) {
|
|
1390
1274
|
if (scaleRatio > 0) {
|
|
1391
|
-
this
|
|
1392
|
-
this
|
|
1275
|
+
this._ctx.setTransform({ scale: scaleRatio });
|
|
1276
|
+
this._helperCtx.setTransform({ scale: scaleRatio });
|
|
1393
1277
|
}
|
|
1394
|
-
|
|
1278
|
+
const { position, size } = this._screen.calcScreen();
|
|
1395
1279
|
return { position, size };
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
this
|
|
1280
|
+
}
|
|
1281
|
+
scrollX(x2) {
|
|
1282
|
+
this._watcher.setStatusMap({
|
|
1399
1283
|
canScrollYPrev: true,
|
|
1400
1284
|
canScrollYNext: true,
|
|
1401
1285
|
canScrollXPrev: true,
|
|
1402
1286
|
canScrollXNext: true
|
|
1403
1287
|
});
|
|
1404
1288
|
if (x2 >= 0 || x2 < 0) {
|
|
1405
|
-
this
|
|
1406
|
-
this
|
|
1289
|
+
this._ctx.setTransform({ scrollX: x2 });
|
|
1290
|
+
this._helperCtx.setTransform({ scrollX: x2 });
|
|
1407
1291
|
}
|
|
1408
|
-
|
|
1409
|
-
this
|
|
1292
|
+
const { position, size, canScrollXNext, canScrollYNext, canScrollXPrev, canScrollYPrev } = this._screen.calcScreen();
|
|
1293
|
+
this._watcher.setStatusMap({
|
|
1410
1294
|
canScrollYPrev,
|
|
1411
1295
|
canScrollYNext,
|
|
1412
1296
|
canScrollXPrev,
|
|
1413
1297
|
canScrollXNext
|
|
1414
1298
|
});
|
|
1415
1299
|
return { position, size };
|
|
1416
|
-
}
|
|
1417
|
-
|
|
1418
|
-
this
|
|
1300
|
+
}
|
|
1301
|
+
scrollY(y2) {
|
|
1302
|
+
this._watcher.setStatusMap({
|
|
1419
1303
|
canScrollYPrev: true,
|
|
1420
1304
|
canScrollYNext: true,
|
|
1421
1305
|
canScrollXPrev: true,
|
|
1422
1306
|
canScrollXNext: true
|
|
1423
1307
|
});
|
|
1424
1308
|
if (y2 >= 0 || y2 < 0) {
|
|
1425
|
-
this
|
|
1426
|
-
this
|
|
1309
|
+
this._ctx.setTransform({ scrollY: y2 });
|
|
1310
|
+
this._helperCtx.setTransform({ scrollY: y2 });
|
|
1427
1311
|
}
|
|
1428
|
-
|
|
1429
|
-
this
|
|
1312
|
+
const { position, size, canScrollXNext, canScrollYNext, canScrollXPrev, canScrollYPrev } = this._screen.calcScreen();
|
|
1313
|
+
this._watcher.setStatusMap({
|
|
1430
1314
|
canScrollYPrev,
|
|
1431
1315
|
canScrollYNext,
|
|
1432
1316
|
canScrollXPrev,
|
|
1433
1317
|
canScrollXNext
|
|
1434
1318
|
});
|
|
1435
1319
|
return { position, size };
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1438
|
-
return this
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1320
|
+
}
|
|
1321
|
+
getTransform() {
|
|
1322
|
+
return this._ctx.getTransform();
|
|
1323
|
+
}
|
|
1324
|
+
draw() {
|
|
1441
1325
|
this.clear();
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
displayCtx === null || displayCtx === void 0 ? void 0 : displayCtx.drawImage(this
|
|
1445
|
-
displayCtx === null || displayCtx === void 0 ? void 0 : displayCtx.drawImage(this
|
|
1446
|
-
if (this
|
|
1447
|
-
this
|
|
1326
|
+
const { position, deviceSize, size } = this._screen.calcScreen();
|
|
1327
|
+
const displayCtx = this._displayCanvas.getContext("2d");
|
|
1328
|
+
displayCtx === null || displayCtx === void 0 ? void 0 : displayCtx.drawImage(this._canvas, deviceSize.x, deviceSize.y, deviceSize.w, deviceSize.h);
|
|
1329
|
+
displayCtx === null || displayCtx === void 0 ? void 0 : displayCtx.drawImage(this._helperCanvas, deviceSize.x, deviceSize.y, deviceSize.w, deviceSize.h);
|
|
1330
|
+
if (this._opts.canScroll === true) {
|
|
1331
|
+
this._scroller.draw(position);
|
|
1448
1332
|
}
|
|
1449
1333
|
return { position, size };
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
displayCtx === null || displayCtx === void 0 ? void 0 : displayCtx.clearRect(0, 0, this
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
this
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
this
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
return this
|
|
1463
|
-
}
|
|
1464
|
-
|
|
1465
|
-
this
|
|
1466
|
-
}
|
|
1467
|
-
|
|
1468
|
-
this
|
|
1469
|
-
}
|
|
1470
|
-
|
|
1471
|
-
this
|
|
1472
|
-
this
|
|
1473
|
-
this
|
|
1474
|
-
this
|
|
1475
|
-
this
|
|
1476
|
-
this
|
|
1477
|
-
width: this
|
|
1478
|
-
height: this
|
|
1479
|
-
devicePixelRatio: this
|
|
1334
|
+
}
|
|
1335
|
+
clear() {
|
|
1336
|
+
const displayCtx = this._displayCanvas.getContext("2d");
|
|
1337
|
+
displayCtx === null || displayCtx === void 0 ? void 0 : displayCtx.clearRect(0, 0, this._displayCanvas.width, this._displayCanvas.height);
|
|
1338
|
+
}
|
|
1339
|
+
on(name, callback) {
|
|
1340
|
+
this._watcher.on(name, callback);
|
|
1341
|
+
}
|
|
1342
|
+
off(name, callback) {
|
|
1343
|
+
this._watcher.off(name, callback);
|
|
1344
|
+
}
|
|
1345
|
+
getScreenInfo() {
|
|
1346
|
+
return this._screen.calcScreen();
|
|
1347
|
+
}
|
|
1348
|
+
setCursor(cursor) {
|
|
1349
|
+
this._displayCanvas.style.cursor = cursor;
|
|
1350
|
+
}
|
|
1351
|
+
resetCursor() {
|
|
1352
|
+
this._displayCanvas.style.cursor = "auto";
|
|
1353
|
+
}
|
|
1354
|
+
resetSize(opts) {
|
|
1355
|
+
this._opts = Object.assign(Object.assign({}, this._opts), opts);
|
|
1356
|
+
this._resetContext();
|
|
1357
|
+
this._ctx.resetSize(opts);
|
|
1358
|
+
this._helperCtx.resetSize(opts);
|
|
1359
|
+
this._screen.resetSize(opts);
|
|
1360
|
+
this._scroller.resetSize({
|
|
1361
|
+
width: this._opts.width,
|
|
1362
|
+
height: this._opts.height,
|
|
1363
|
+
devicePixelRatio: this._opts.devicePixelRatio
|
|
1480
1364
|
});
|
|
1481
1365
|
this.draw();
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
if (this
|
|
1486
|
-
lineWidth = this
|
|
1366
|
+
}
|
|
1367
|
+
getScrollLineWidth() {
|
|
1368
|
+
let lineWidth = 0;
|
|
1369
|
+
if (this._opts.canScroll === true) {
|
|
1370
|
+
lineWidth = this._scroller.getLineWidth();
|
|
1487
1371
|
}
|
|
1488
1372
|
return lineWidth;
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1373
|
+
}
|
|
1374
|
+
pointScreenToContext(screenPoint) {
|
|
1375
|
+
const { scrollX, scrollY, scale } = this.getTransform();
|
|
1376
|
+
const ctxPoint = {
|
|
1493
1377
|
x: (screenPoint.x - scrollX) / scale,
|
|
1494
1378
|
y: (screenPoint.y - scrollY) / scale
|
|
1495
1379
|
};
|
|
1496
1380
|
return ctxPoint;
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1381
|
+
}
|
|
1382
|
+
pointContextToScreen(ctxPoint) {
|
|
1383
|
+
const { scrollX, scrollY, scale } = this.getTransform();
|
|
1384
|
+
const screenPoint = {
|
|
1501
1385
|
x: ctxPoint.x * scale + scrollX,
|
|
1502
1386
|
y: ctxPoint.y * scale + scrollY
|
|
1503
1387
|
};
|
|
1504
1388
|
return screenPoint;
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
|
-
if (this
|
|
1389
|
+
}
|
|
1390
|
+
_render() {
|
|
1391
|
+
if (this._hasRendered === true) {
|
|
1508
1392
|
return;
|
|
1509
1393
|
}
|
|
1510
|
-
this
|
|
1511
|
-
this
|
|
1512
|
-
this
|
|
1513
|
-
}
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
this
|
|
1517
|
-
this
|
|
1518
|
-
this
|
|
1519
|
-
this
|
|
1520
|
-
this
|
|
1521
|
-
this
|
|
1522
|
-
setStyle(this
|
|
1523
|
-
width:
|
|
1524
|
-
height:
|
|
1394
|
+
this._resetContext();
|
|
1395
|
+
this._initEvent();
|
|
1396
|
+
this._hasRendered = true;
|
|
1397
|
+
}
|
|
1398
|
+
_resetContext() {
|
|
1399
|
+
const { width, height, contextWidth, contextHeight, devicePixelRatio } = this._opts;
|
|
1400
|
+
this._canvas.width = contextWidth * devicePixelRatio;
|
|
1401
|
+
this._canvas.height = contextHeight * devicePixelRatio;
|
|
1402
|
+
this._helperCanvas.width = contextWidth * devicePixelRatio;
|
|
1403
|
+
this._helperCanvas.height = contextHeight * devicePixelRatio;
|
|
1404
|
+
this._displayCanvas.width = width * devicePixelRatio;
|
|
1405
|
+
this._displayCanvas.height = height * devicePixelRatio;
|
|
1406
|
+
setStyle(this._displayCanvas, {
|
|
1407
|
+
width: `${width}px`,
|
|
1408
|
+
height: `${height}px`
|
|
1525
1409
|
});
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1410
|
+
}
|
|
1411
|
+
_parsePrivateOptions(opts) {
|
|
1412
|
+
const defaultOpts = {
|
|
1529
1413
|
devicePixelRatio: 1
|
|
1530
1414
|
};
|
|
1531
|
-
return
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
if (this[_hasRendered] === true) {
|
|
1415
|
+
return Object.assign(Object.assign({}, defaultOpts), opts);
|
|
1416
|
+
}
|
|
1417
|
+
_initEvent() {
|
|
1418
|
+
if (this._hasRendered === true) {
|
|
1536
1419
|
return;
|
|
1537
1420
|
}
|
|
1538
|
-
if (this
|
|
1539
|
-
this.on("wheelX", throttle
|
|
1540
|
-
|
|
1541
|
-
}, 16));
|
|
1542
|
-
this.on("wheelY", throttle$2(function(deltaY) {
|
|
1543
|
-
_this[_doScrollY](deltaY);
|
|
1544
|
-
}, 16));
|
|
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";
|
|
1551
|
-
}
|
|
1552
|
-
}, 16));
|
|
1553
|
-
this.on("move", throttle$2(function(p) {
|
|
1554
|
-
if (scrollType_1) {
|
|
1555
|
-
_this[_doMoveScroll](scrollType_1, p);
|
|
1556
|
-
}
|
|
1421
|
+
if (this._opts.canScroll === true) {
|
|
1422
|
+
this.on("wheelX", throttle((deltaX) => {
|
|
1423
|
+
this._doScrollX(deltaX);
|
|
1557
1424
|
}, 16));
|
|
1558
|
-
this.on("
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1425
|
+
this.on("wheelY", throttle((deltaY) => {
|
|
1426
|
+
this._doScrollY(deltaY);
|
|
1427
|
+
}, 16));
|
|
1428
|
+
let scrollType = null;
|
|
1429
|
+
this.on("moveStart", throttle((p) => {
|
|
1430
|
+
if (this._scroller.isPointAtScrollX(p)) {
|
|
1431
|
+
scrollType = "x";
|
|
1432
|
+
} else if (this._scroller.isPointAtScrollY(p)) {
|
|
1433
|
+
scrollType = "y";
|
|
1434
|
+
}
|
|
1435
|
+
}, 16));
|
|
1436
|
+
this.on("move", throttle((p) => {
|
|
1437
|
+
if (scrollType) {
|
|
1438
|
+
this._doMoveScroll(scrollType, p);
|
|
1439
|
+
}
|
|
1440
|
+
}, 16));
|
|
1441
|
+
this.on("moveEnd", throttle((p) => {
|
|
1442
|
+
if (scrollType) {
|
|
1443
|
+
this._doMoveScroll(scrollType, p);
|
|
1444
|
+
}
|
|
1445
|
+
scrollType = null;
|
|
1563
1446
|
}, 16));
|
|
1564
1447
|
}
|
|
1565
|
-
}
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
if (!(typeof scrollX === "number" && (scrollX > 0 || scrollX <= 0))) {
|
|
1570
|
-
scrollX = this
|
|
1571
|
-
}
|
|
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);
|
|
1575
|
-
this.scrollX(scrollX + moveX);
|
|
1576
|
-
this.draw();
|
|
1577
|
-
};
|
|
1578
|
-
Board2.prototype[_doScrollY] = function(dy, prevScrollY) {
|
|
1579
|
-
var height = this[_opts$2].height;
|
|
1580
|
-
var scrollY = prevScrollY;
|
|
1581
|
-
if (!(typeof scrollY === "number" && (scrollY > 0 || scrollY <= 0))) {
|
|
1582
|
-
scrollY = this[_ctx$2].getTransform().scrollY;
|
|
1583
|
-
}
|
|
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);
|
|
1587
|
-
this.scrollY(scrollY + moveY);
|
|
1588
|
-
this.draw();
|
|
1589
|
-
};
|
|
1590
|
-
Board2.prototype[_doMoveScroll] = function(scrollType, point) {
|
|
1591
|
-
if (!scrollType) {
|
|
1592
|
-
return;
|
|
1593
|
-
}
|
|
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));
|
|
1448
|
+
}
|
|
1449
|
+
_doScrollX(dx, prevScrollX) {
|
|
1450
|
+
const { width } = this._opts;
|
|
1451
|
+
let scrollX = prevScrollX;
|
|
1452
|
+
if (!(typeof scrollX === "number" && (scrollX > 0 || scrollX <= 0))) {
|
|
1453
|
+
scrollX = this._ctx.getTransform().scrollX;
|
|
2410
1454
|
}
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
1455
|
+
const { position } = this._screen.calcScreen();
|
|
1456
|
+
const { xSize } = this._scroller.calc(position);
|
|
1457
|
+
const moveX = this._screen.calcScreenScroll(position.left, position.right, xSize, width, dx);
|
|
1458
|
+
this.scrollX(scrollX + moveX);
|
|
1459
|
+
this.draw();
|
|
1460
|
+
}
|
|
1461
|
+
_doScrollY(dy, prevScrollY) {
|
|
1462
|
+
const { height } = this._opts;
|
|
1463
|
+
let scrollY = prevScrollY;
|
|
1464
|
+
if (!(typeof scrollY === "number" && (scrollY > 0 || scrollY <= 0))) {
|
|
1465
|
+
scrollY = this._ctx.getTransform().scrollY;
|
|
2416
1466
|
}
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
this.
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
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;
|
|
1467
|
+
const { position } = this._screen.calcScreen();
|
|
1468
|
+
const { ySize } = this._scroller.calc(position);
|
|
1469
|
+
const moveY = this._screen.calcScreenScroll(position.top, position.bottom, ySize, height, dy);
|
|
1470
|
+
this.scrollY(scrollY + moveY);
|
|
1471
|
+
this.draw();
|
|
1472
|
+
}
|
|
1473
|
+
_doMoveScroll(scrollType, point) {
|
|
1474
|
+
if (!scrollType) {
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
const { position } = this._screen.calcScreen();
|
|
1478
|
+
const { xSize, ySize } = this._scroller.calc(position);
|
|
1479
|
+
if (scrollType === "x") {
|
|
1480
|
+
this._doScrollX(point.x - xSize / 2, 0);
|
|
1481
|
+
} else if (scrollType === "y") {
|
|
1482
|
+
this._doScrollY(point.y - ySize / 2, 0);
|
|
2512
1483
|
}
|
|
2513
|
-
div = null;
|
|
2514
1484
|
}
|
|
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
1485
|
}
|
|
2532
|
-
function fontFamily$1(value) {
|
|
2533
|
-
return typeof value === "string" && value.length > 0;
|
|
2534
|
-
}
|
|
2535
|
-
function fontWeight$1(value) {
|
|
2536
|
-
return ["bold"].includes(value);
|
|
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
|
-
};
|
|
2561
1486
|
function parseAngleToRadian$1(angle2) {
|
|
2562
1487
|
return angle2 / 180 * Math.PI;
|
|
2563
1488
|
}
|
|
2564
1489
|
function calcElementCenter$1(elem) {
|
|
2565
|
-
|
|
1490
|
+
const p = {
|
|
2566
1491
|
x: elem.x + elem.w / 2,
|
|
2567
1492
|
y: elem.y + elem.h / 2
|
|
2568
1493
|
};
|
|
2569
1494
|
return p;
|
|
2570
1495
|
}
|
|
2571
1496
|
function rotateElement$1(ctx, elem, callback) {
|
|
2572
|
-
|
|
2573
|
-
|
|
1497
|
+
const center = calcElementCenter$1(elem);
|
|
1498
|
+
const radian = parseAngleToRadian$1(elem.angle || 0);
|
|
2574
1499
|
return rotateContext$1(ctx, center, radian || 0, callback);
|
|
2575
1500
|
}
|
|
2576
1501
|
function rotateContext$1(ctx, center, radian, callback) {
|
|
@@ -2597,7 +1522,7 @@ var iDrawCore = function() {
|
|
|
2597
1522
|
ctx.setShadowBlur(0);
|
|
2598
1523
|
}
|
|
2599
1524
|
function drawBgColor(ctx, color2) {
|
|
2600
|
-
|
|
1525
|
+
const size = ctx.getSize();
|
|
2601
1526
|
ctx.setFillStyle(color2);
|
|
2602
1527
|
ctx.fillRect(0, 0, size.contextWidth, size.contextHeight);
|
|
2603
1528
|
}
|
|
@@ -2605,9 +1530,9 @@ var iDrawCore = function() {
|
|
|
2605
1530
|
clearContext$1(ctx);
|
|
2606
1531
|
drawBoxBorder(ctx, elem);
|
|
2607
1532
|
clearContext$1(ctx);
|
|
2608
|
-
rotateElement$1(ctx, elem,
|
|
2609
|
-
|
|
2610
|
-
|
|
1533
|
+
rotateElement$1(ctx, elem, () => {
|
|
1534
|
+
const { x: x2, y: y2, w: w2, h: h2 } = elem;
|
|
1535
|
+
let r = elem.desc.borderRadius || 0;
|
|
2611
1536
|
r = Math.min(r, w2 / 2, h2 / 2);
|
|
2612
1537
|
if (w2 < r * 2 || h2 < r * 2) {
|
|
2613
1538
|
r = 0;
|
|
@@ -2629,35 +1554,35 @@ var iDrawCore = function() {
|
|
|
2629
1554
|
}
|
|
2630
1555
|
function drawBoxBorder(ctx, elem) {
|
|
2631
1556
|
clearContext$1(ctx);
|
|
2632
|
-
rotateElement$1(ctx, elem,
|
|
1557
|
+
rotateElement$1(ctx, elem, () => {
|
|
2633
1558
|
if (!(elem.desc.borderWidth && elem.desc.borderWidth > 0)) {
|
|
2634
1559
|
return;
|
|
2635
1560
|
}
|
|
2636
|
-
|
|
2637
|
-
|
|
1561
|
+
const bw = elem.desc.borderWidth;
|
|
1562
|
+
let borderColor = "#000000";
|
|
2638
1563
|
if (isColorStr(elem.desc.borderColor) === true) {
|
|
2639
1564
|
borderColor = elem.desc.borderColor;
|
|
2640
1565
|
}
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
1566
|
+
const x2 = elem.x - bw / 2;
|
|
1567
|
+
const y2 = elem.y - bw / 2;
|
|
1568
|
+
const w2 = elem.w + bw;
|
|
1569
|
+
const h2 = elem.h + bw;
|
|
1570
|
+
let r = elem.desc.borderRadius || 0;
|
|
2646
1571
|
r = Math.min(r, w2 / 2, h2 / 2);
|
|
2647
1572
|
if (r < w2 / 2 && r < h2 / 2) {
|
|
2648
1573
|
r = r + bw / 2;
|
|
2649
1574
|
}
|
|
2650
|
-
|
|
1575
|
+
const { desc } = elem;
|
|
2651
1576
|
if (desc.shadowColor !== void 0 && isColorStr(desc.shadowColor)) {
|
|
2652
1577
|
ctx.setShadowColor(desc.shadowColor);
|
|
2653
1578
|
}
|
|
2654
|
-
if (desc.shadowOffsetX !== void 0 && is$
|
|
1579
|
+
if (desc.shadowOffsetX !== void 0 && is$1.number(desc.shadowOffsetX)) {
|
|
2655
1580
|
ctx.setShadowOffsetX(desc.shadowOffsetX);
|
|
2656
1581
|
}
|
|
2657
|
-
if (desc.shadowOffsetY !== void 0 && is$
|
|
1582
|
+
if (desc.shadowOffsetY !== void 0 && is$1.number(desc.shadowOffsetY)) {
|
|
2658
1583
|
ctx.setShadowOffsetY(desc.shadowOffsetY);
|
|
2659
1584
|
}
|
|
2660
|
-
if (desc.shadowBlur !== void 0 && is$
|
|
1585
|
+
if (desc.shadowBlur !== void 0 && is$1.number(desc.shadowBlur)) {
|
|
2661
1586
|
ctx.setShadowBlur(desc.shadowBlur);
|
|
2662
1587
|
}
|
|
2663
1588
|
ctx.beginPath();
|
|
@@ -2676,24 +1601,24 @@ var iDrawCore = function() {
|
|
|
2676
1601
|
drawBox(ctx, elem, elem.desc.bgColor);
|
|
2677
1602
|
}
|
|
2678
1603
|
function drawImage(ctx, elem, loader) {
|
|
2679
|
-
|
|
2680
|
-
rotateElement$1(ctx, elem,
|
|
1604
|
+
const content = loader.getContent(elem.uuid);
|
|
1605
|
+
rotateElement$1(ctx, elem, () => {
|
|
2681
1606
|
if (content) {
|
|
2682
1607
|
ctx.drawImage(content, elem.x, elem.y, elem.w, elem.h);
|
|
2683
1608
|
}
|
|
2684
1609
|
});
|
|
2685
1610
|
}
|
|
2686
1611
|
function drawSVG(ctx, elem, loader) {
|
|
2687
|
-
|
|
2688
|
-
rotateElement$1(ctx, elem,
|
|
1612
|
+
const content = loader.getContent(elem.uuid);
|
|
1613
|
+
rotateElement$1(ctx, elem, () => {
|
|
2689
1614
|
if (content) {
|
|
2690
1615
|
ctx.drawImage(content, elem.x, elem.y, elem.w, elem.h);
|
|
2691
1616
|
}
|
|
2692
1617
|
});
|
|
2693
1618
|
}
|
|
2694
1619
|
function drawHTML(ctx, elem, loader) {
|
|
2695
|
-
|
|
2696
|
-
rotateElement$1(ctx, elem,
|
|
1620
|
+
const content = loader.getContent(elem.uuid);
|
|
1621
|
+
rotateElement$1(ctx, elem, () => {
|
|
2697
1622
|
if (content) {
|
|
2698
1623
|
ctx.drawImage(content, elem.x, elem.y, elem.w, elem.h);
|
|
2699
1624
|
}
|
|
@@ -2702,8 +1627,8 @@ var iDrawCore = function() {
|
|
|
2702
1627
|
function drawText(ctx, elem, loader) {
|
|
2703
1628
|
clearContext$1(ctx);
|
|
2704
1629
|
drawBox(ctx, elem, elem.desc.bgColor || "transparent");
|
|
2705
|
-
rotateElement$1(ctx, elem,
|
|
2706
|
-
|
|
1630
|
+
rotateElement$1(ctx, elem, () => {
|
|
1631
|
+
const desc = Object.assign({
|
|
2707
1632
|
fontSize: 12,
|
|
2708
1633
|
fontFamily: "sans-serif",
|
|
2709
1634
|
textAlign: "center"
|
|
@@ -2715,15 +1640,15 @@ var iDrawCore = function() {
|
|
|
2715
1640
|
fontSize: desc.fontSize,
|
|
2716
1641
|
fontFamily: desc.fontFamily
|
|
2717
1642
|
});
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
descTextList.forEach(
|
|
2724
|
-
|
|
1643
|
+
const descText = desc.text.replace(/\r\n/gi, "\n");
|
|
1644
|
+
const fontHeight = desc.lineHeight || desc.fontSize;
|
|
1645
|
+
const descTextList = descText.split("\n");
|
|
1646
|
+
const lines = [];
|
|
1647
|
+
let lineNum = 0;
|
|
1648
|
+
descTextList.forEach((tempText, idx) => {
|
|
1649
|
+
let lineText = "";
|
|
2725
1650
|
if (tempText.length > 0) {
|
|
2726
|
-
for (
|
|
1651
|
+
for (let i = 0; i < tempText.length; i++) {
|
|
2727
1652
|
if (ctx.measureText(lineText + (tempText[i] || "")).width < ctx.calcDeviceNum(elem.w)) {
|
|
2728
1653
|
lineText += tempText[i] || "";
|
|
2729
1654
|
} else {
|
|
@@ -2757,41 +1682,45 @@ var iDrawCore = function() {
|
|
|
2757
1682
|
});
|
|
2758
1683
|
}
|
|
2759
1684
|
});
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
if (
|
|
2763
|
-
|
|
1685
|
+
let startY = 0;
|
|
1686
|
+
if (lines.length * fontHeight < elem.h) {
|
|
1687
|
+
if (elem.desc.verticalAlign === "top") {
|
|
1688
|
+
startY = 0;
|
|
1689
|
+
} else if (elem.desc.verticalAlign === "bottom") {
|
|
1690
|
+
startY += elem.h - lines.length * fontHeight;
|
|
1691
|
+
} else {
|
|
1692
|
+
startY += (elem.h - lines.length * fontHeight) / 2;
|
|
2764
1693
|
}
|
|
1694
|
+
}
|
|
1695
|
+
{
|
|
1696
|
+
const _y = elem.y + startY;
|
|
2765
1697
|
if (desc.textShadowColor !== void 0 && isColorStr(desc.textShadowColor)) {
|
|
2766
1698
|
ctx.setShadowColor(desc.textShadowColor);
|
|
2767
1699
|
}
|
|
2768
|
-
if (desc.textShadowOffsetX !== void 0 && is$
|
|
1700
|
+
if (desc.textShadowOffsetX !== void 0 && is$1.number(desc.textShadowOffsetX)) {
|
|
2769
1701
|
ctx.setShadowOffsetX(desc.textShadowOffsetX);
|
|
2770
1702
|
}
|
|
2771
|
-
if (desc.textShadowOffsetY !== void 0 && is$
|
|
1703
|
+
if (desc.textShadowOffsetY !== void 0 && is$1.number(desc.textShadowOffsetY)) {
|
|
2772
1704
|
ctx.setShadowOffsetY(desc.textShadowOffsetY);
|
|
2773
1705
|
}
|
|
2774
|
-
if (desc.textShadowBlur !== void 0 && is$
|
|
1706
|
+
if (desc.textShadowBlur !== void 0 && is$1.number(desc.textShadowBlur)) {
|
|
2775
1707
|
ctx.setShadowBlur(desc.textShadowBlur);
|
|
2776
1708
|
}
|
|
2777
|
-
lines.forEach(
|
|
2778
|
-
|
|
1709
|
+
lines.forEach((line, i) => {
|
|
1710
|
+
let _x = elem.x;
|
|
2779
1711
|
if (desc.textAlign === "center") {
|
|
2780
1712
|
_x = elem.x + (elem.w - line.width) / 2;
|
|
2781
1713
|
} else if (desc.textAlign === "right") {
|
|
2782
1714
|
_x = elem.x + (elem.w - line.width);
|
|
2783
1715
|
}
|
|
2784
|
-
ctx.fillText(line.text, _x,
|
|
1716
|
+
ctx.fillText(line.text, _x, _y + fontHeight * i);
|
|
2785
1717
|
});
|
|
2786
1718
|
clearContext$1(ctx);
|
|
2787
1719
|
}
|
|
2788
1720
|
if (isColorStr(desc.strokeColor) && desc.strokeWidth !== void 0 && desc.strokeWidth > 0) {
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
}
|
|
2793
|
-
lines.forEach(function(line, i) {
|
|
2794
|
-
var _x = elem.x;
|
|
1721
|
+
const _y = elem.y + startY;
|
|
1722
|
+
lines.forEach((line, i) => {
|
|
1723
|
+
let _x = elem.x;
|
|
2795
1724
|
if (desc.textAlign === "center") {
|
|
2796
1725
|
_x = elem.x + (elem.w - line.width) / 2;
|
|
2797
1726
|
} else if (desc.textAlign === "right") {
|
|
@@ -2803,23 +1732,23 @@ var iDrawCore = function() {
|
|
|
2803
1732
|
if (desc.strokeWidth !== void 0 && desc.strokeWidth > 0) {
|
|
2804
1733
|
ctx.setLineWidth(desc.strokeWidth);
|
|
2805
1734
|
}
|
|
2806
|
-
ctx.strokeText(line.text, _x,
|
|
1735
|
+
ctx.strokeText(line.text, _x, _y + fontHeight * i);
|
|
2807
1736
|
});
|
|
2808
1737
|
}
|
|
2809
1738
|
});
|
|
2810
1739
|
}
|
|
2811
1740
|
function drawCircle(ctx, elem) {
|
|
2812
1741
|
clearContext$1(ctx);
|
|
2813
|
-
rotateElement$1(ctx, elem,
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
1742
|
+
rotateElement$1(ctx, elem, (ctx2) => {
|
|
1743
|
+
const { x: x2, y: y2, w: w2, h: h2, desc } = elem;
|
|
1744
|
+
const { bgColor = "#000000", borderColor = "#000000", borderWidth: borderWidth2 = 0 } = desc;
|
|
1745
|
+
const a = w2 / 2;
|
|
1746
|
+
const b = h2 / 2;
|
|
1747
|
+
const centerX = x2 + a;
|
|
1748
|
+
const centerY = y2 + b;
|
|
2820
1749
|
if (borderWidth2 && borderWidth2 > 0) {
|
|
2821
|
-
|
|
2822
|
-
|
|
1750
|
+
const ba = borderWidth2 / 2 + a;
|
|
1751
|
+
const bb = borderWidth2 / 2 + b;
|
|
2823
1752
|
ctx2.beginPath();
|
|
2824
1753
|
ctx2.setStrokeStyle(borderColor);
|
|
2825
1754
|
ctx2.setLineWidth(borderWidth2);
|
|
@@ -2835,9 +1764,9 @@ var iDrawCore = function() {
|
|
|
2835
1764
|
});
|
|
2836
1765
|
}
|
|
2837
1766
|
function drawContext(ctx, data, loader) {
|
|
2838
|
-
var
|
|
1767
|
+
var _a;
|
|
2839
1768
|
clearContext$1(ctx);
|
|
2840
|
-
|
|
1769
|
+
const size = ctx.getSize();
|
|
2841
1770
|
ctx.clearRect(0, 0, size.contextWidth, size.contextHeight);
|
|
2842
1771
|
if (typeof data.bgColor === "string" && isColorStr(data.bgColor)) {
|
|
2843
1772
|
drawBgColor(ctx, data.bgColor);
|
|
@@ -2845,9 +1774,9 @@ var iDrawCore = function() {
|
|
|
2845
1774
|
if (!(data.elements.length > 0)) {
|
|
2846
1775
|
return;
|
|
2847
1776
|
}
|
|
2848
|
-
for (
|
|
2849
|
-
|
|
2850
|
-
if (((
|
|
1777
|
+
for (let i = 0; i < data.elements.length; i++) {
|
|
1778
|
+
const elem = data.elements[i];
|
|
1779
|
+
if (((_a = elem === null || elem === void 0 ? void 0 : elem.operation) === null || _a === void 0 ? void 0 : _a.invisible) === true) {
|
|
2851
1780
|
continue;
|
|
2852
1781
|
}
|
|
2853
1782
|
switch (elem.type) {
|
|
@@ -2878,24 +1807,24 @@ var iDrawCore = function() {
|
|
|
2878
1807
|
}
|
|
2879
1808
|
}
|
|
2880
1809
|
}
|
|
2881
|
-
|
|
2882
|
-
|
|
1810
|
+
class LoaderEvent {
|
|
1811
|
+
constructor() {
|
|
2883
1812
|
this._listeners = /* @__PURE__ */ new Map();
|
|
2884
1813
|
}
|
|
2885
|
-
|
|
1814
|
+
on(eventKey, callback) {
|
|
2886
1815
|
if (this._listeners.has(eventKey)) {
|
|
2887
|
-
|
|
1816
|
+
const callbacks = this._listeners.get(eventKey);
|
|
2888
1817
|
callbacks === null || callbacks === void 0 ? void 0 : callbacks.push(callback);
|
|
2889
1818
|
this._listeners.set(eventKey, callbacks || []);
|
|
2890
1819
|
} else {
|
|
2891
1820
|
this._listeners.set(eventKey, [callback]);
|
|
2892
1821
|
}
|
|
2893
|
-
}
|
|
2894
|
-
|
|
1822
|
+
}
|
|
1823
|
+
off(eventKey, callback) {
|
|
2895
1824
|
if (this._listeners.has(eventKey)) {
|
|
2896
|
-
|
|
1825
|
+
const callbacks = this._listeners.get(eventKey);
|
|
2897
1826
|
if (Array.isArray(callbacks)) {
|
|
2898
|
-
for (
|
|
1827
|
+
for (let i = 0; i < (callbacks === null || callbacks === void 0 ? void 0 : callbacks.length); i++) {
|
|
2899
1828
|
if (callbacks[i] === callback) {
|
|
2900
1829
|
callbacks.splice(i, 1);
|
|
2901
1830
|
break;
|
|
@@ -2904,40 +1833,66 @@ var iDrawCore = function() {
|
|
|
2904
1833
|
}
|
|
2905
1834
|
this._listeners.set(eventKey, callbacks || []);
|
|
2906
1835
|
}
|
|
2907
|
-
}
|
|
2908
|
-
|
|
2909
|
-
|
|
1836
|
+
}
|
|
1837
|
+
trigger(eventKey, arg) {
|
|
1838
|
+
const callbacks = this._listeners.get(eventKey);
|
|
2910
1839
|
if (Array.isArray(callbacks)) {
|
|
2911
|
-
callbacks.forEach(
|
|
1840
|
+
callbacks.forEach((cb) => {
|
|
2912
1841
|
cb(arg);
|
|
2913
1842
|
});
|
|
2914
1843
|
return true;
|
|
2915
1844
|
} else {
|
|
2916
1845
|
return false;
|
|
2917
1846
|
}
|
|
2918
|
-
}
|
|
2919
|
-
|
|
1847
|
+
}
|
|
1848
|
+
has(name) {
|
|
2920
1849
|
if (this._listeners.has(name)) {
|
|
2921
|
-
|
|
1850
|
+
const list = this._listeners.get(name);
|
|
2922
1851
|
if (Array.isArray(list) && list.length > 0) {
|
|
2923
1852
|
return true;
|
|
2924
1853
|
}
|
|
2925
1854
|
}
|
|
2926
1855
|
return false;
|
|
2927
|
-
}
|
|
2928
|
-
|
|
2929
|
-
}();
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
2930
1858
|
function filterScript(html2) {
|
|
2931
1859
|
return html2.replace(/<script[\s\S]*?<\/script>/ig, "");
|
|
2932
1860
|
}
|
|
1861
|
+
var __awaiter = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
1862
|
+
function adopt(value) {
|
|
1863
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
1864
|
+
resolve(value);
|
|
1865
|
+
});
|
|
1866
|
+
}
|
|
1867
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
1868
|
+
function fulfilled(value) {
|
|
1869
|
+
try {
|
|
1870
|
+
step(generator.next(value));
|
|
1871
|
+
} catch (e) {
|
|
1872
|
+
reject(e);
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
function rejected(value) {
|
|
1876
|
+
try {
|
|
1877
|
+
step(generator["throw"](value));
|
|
1878
|
+
} catch (e) {
|
|
1879
|
+
reject(e);
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
function step(result) {
|
|
1883
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1884
|
+
}
|
|
1885
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1886
|
+
});
|
|
1887
|
+
};
|
|
2933
1888
|
var LoaderStatus;
|
|
2934
1889
|
(function(LoaderStatus2) {
|
|
2935
1890
|
LoaderStatus2["FREE"] = "free";
|
|
2936
1891
|
LoaderStatus2["LOADING"] = "loading";
|
|
2937
1892
|
LoaderStatus2["COMPLETE"] = "complete";
|
|
2938
1893
|
})(LoaderStatus || (LoaderStatus = {}));
|
|
2939
|
-
|
|
2940
|
-
|
|
1894
|
+
class Loader {
|
|
1895
|
+
constructor(opts) {
|
|
2941
1896
|
this._currentLoadData = {};
|
|
2942
1897
|
this._currentUUIDQueue = [];
|
|
2943
1898
|
this._storageLoadData = {};
|
|
@@ -2947,8 +1902,8 @@ var iDrawCore = function() {
|
|
|
2947
1902
|
this._event = new LoaderEvent();
|
|
2948
1903
|
this._waitingLoadQueue = [];
|
|
2949
1904
|
}
|
|
2950
|
-
|
|
2951
|
-
|
|
1905
|
+
load(data, changeResourceUUIDs) {
|
|
1906
|
+
const [uuidQueue, loadData] = this._resetLoadData(data, changeResourceUUIDs);
|
|
2952
1907
|
if (this._status === LoaderStatus.FREE || this._status === LoaderStatus.COMPLETE) {
|
|
2953
1908
|
this._currentUUIDQueue = uuidQueue;
|
|
2954
1909
|
this._currentLoadData = loadData;
|
|
@@ -2959,29 +1914,29 @@ var iDrawCore = function() {
|
|
|
2959
1914
|
loadData
|
|
2960
1915
|
});
|
|
2961
1916
|
}
|
|
2962
|
-
}
|
|
2963
|
-
|
|
1917
|
+
}
|
|
1918
|
+
on(name, callback) {
|
|
2964
1919
|
this._event.on(name, callback);
|
|
2965
|
-
}
|
|
2966
|
-
|
|
1920
|
+
}
|
|
1921
|
+
off(name, callback) {
|
|
2967
1922
|
this._event.off(name, callback);
|
|
2968
|
-
}
|
|
2969
|
-
|
|
1923
|
+
}
|
|
1924
|
+
isComplete() {
|
|
2970
1925
|
return this._status === LoaderStatus.COMPLETE;
|
|
2971
|
-
}
|
|
2972
|
-
|
|
2973
|
-
var
|
|
2974
|
-
if (((
|
|
1926
|
+
}
|
|
1927
|
+
getContent(uuid) {
|
|
1928
|
+
var _a;
|
|
1929
|
+
if (((_a = this._storageLoadData[uuid]) === null || _a === void 0 ? void 0 : _a.status) === "loaded") {
|
|
2975
1930
|
return this._storageLoadData[uuid].content;
|
|
2976
1931
|
}
|
|
2977
1932
|
return null;
|
|
2978
|
-
}
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
for (
|
|
2984
|
-
|
|
1933
|
+
}
|
|
1934
|
+
_resetLoadData(data, changeResourceUUIDs) {
|
|
1935
|
+
const loadData = {};
|
|
1936
|
+
const uuidQueue = [];
|
|
1937
|
+
const storageLoadData = this._storageLoadData;
|
|
1938
|
+
for (let i = data.elements.length - 1; i >= 0; i--) {
|
|
1939
|
+
const elem = data.elements[i];
|
|
2985
1940
|
if (["image", "svg", "html"].includes(elem.type)) {
|
|
2986
1941
|
if (!storageLoadData[elem.uuid]) {
|
|
2987
1942
|
loadData[elem.uuid] = this._createEmptyLoadItem(elem);
|
|
@@ -2995,20 +1950,20 @@ var iDrawCore = function() {
|
|
|
2995
1950
|
}
|
|
2996
1951
|
}
|
|
2997
1952
|
return [uuidQueue, loadData];
|
|
2998
|
-
}
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
1953
|
+
}
|
|
1954
|
+
_createEmptyLoadItem(elem) {
|
|
1955
|
+
let source = "";
|
|
1956
|
+
const type = elem.type;
|
|
1957
|
+
let elemW = elem.w;
|
|
1958
|
+
let elemH = elem.h;
|
|
3004
1959
|
if (elem.type === "image") {
|
|
3005
|
-
|
|
1960
|
+
const _elem = elem;
|
|
3006
1961
|
source = _elem.desc.src || "";
|
|
3007
1962
|
} else if (elem.type === "svg") {
|
|
3008
|
-
|
|
1963
|
+
const _elem = elem;
|
|
3009
1964
|
source = _elem.desc.svg || "";
|
|
3010
1965
|
} else if (elem.type === "html") {
|
|
3011
|
-
|
|
1966
|
+
const _elem = elem;
|
|
3012
1967
|
source = filterScript(_elem.desc.html || "");
|
|
3013
1968
|
elemW = _elem.desc.width || elem.w;
|
|
3014
1969
|
elemH = _elem.desc.height || elem.h;
|
|
@@ -3023,9 +1978,8 @@ var iDrawCore = function() {
|
|
|
3023
1978
|
elemH,
|
|
3024
1979
|
element: deepClone(elem)
|
|
3025
1980
|
};
|
|
3026
|
-
}
|
|
3027
|
-
|
|
3028
|
-
var _this = this;
|
|
1981
|
+
}
|
|
1982
|
+
_loadTask() {
|
|
3029
1983
|
if (this._status === LoaderStatus.LOADING) {
|
|
3030
1984
|
return;
|
|
3031
1985
|
}
|
|
@@ -3036,160 +1990,137 @@ var iDrawCore = function() {
|
|
|
3036
1990
|
this._event.trigger("complete", void 0);
|
|
3037
1991
|
return;
|
|
3038
1992
|
} else {
|
|
3039
|
-
|
|
1993
|
+
const waitingItem = this._waitingLoadQueue.shift();
|
|
3040
1994
|
if (waitingItem) {
|
|
3041
|
-
|
|
1995
|
+
const { uuidQueue, loadData } = waitingItem;
|
|
3042
1996
|
this._currentLoadData = loadData;
|
|
3043
1997
|
this._currentUUIDQueue = uuidQueue;
|
|
3044
1998
|
}
|
|
3045
1999
|
}
|
|
3046
2000
|
}
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
uuids.forEach(
|
|
2001
|
+
const { maxParallelNum } = this._opts;
|
|
2002
|
+
const uuids = this._currentUUIDQueue.splice(0, maxParallelNum);
|
|
2003
|
+
uuids.forEach((url, i) => {
|
|
3050
2004
|
});
|
|
3051
|
-
|
|
3052
|
-
|
|
2005
|
+
const loadUUIDList = [];
|
|
2006
|
+
const _loadAction = () => {
|
|
3053
2007
|
if (loadUUIDList.length >= maxParallelNum) {
|
|
3054
2008
|
return false;
|
|
3055
2009
|
}
|
|
3056
2010
|
if (uuids.length === 0) {
|
|
3057
2011
|
return true;
|
|
3058
2012
|
}
|
|
3059
|
-
|
|
3060
|
-
|
|
2013
|
+
for (let i = loadUUIDList.length; i < maxParallelNum; i++) {
|
|
2014
|
+
const uuid = uuids.shift();
|
|
3061
2015
|
if (uuid === void 0) {
|
|
3062
|
-
|
|
2016
|
+
break;
|
|
3063
2017
|
}
|
|
3064
2018
|
loadUUIDList.push(uuid);
|
|
3065
|
-
|
|
3066
|
-
var
|
|
2019
|
+
this._loadElementSource(this._currentLoadData[uuid]).then((image) => {
|
|
2020
|
+
var _a, _b;
|
|
3067
2021
|
loadUUIDList.splice(loadUUIDList.indexOf(uuid), 1);
|
|
3068
|
-
|
|
3069
|
-
|
|
2022
|
+
const status = _loadAction();
|
|
2023
|
+
this._storageLoadData[uuid] = {
|
|
3070
2024
|
uuid,
|
|
3071
|
-
type:
|
|
2025
|
+
type: this._currentLoadData[uuid].type,
|
|
3072
2026
|
status: "loaded",
|
|
3073
2027
|
content: image,
|
|
3074
|
-
source:
|
|
3075
|
-
elemW:
|
|
3076
|
-
elemH:
|
|
3077
|
-
element:
|
|
2028
|
+
source: this._currentLoadData[uuid].source,
|
|
2029
|
+
elemW: this._currentLoadData[uuid].elemW,
|
|
2030
|
+
elemH: this._currentLoadData[uuid].elemH,
|
|
2031
|
+
element: this._currentLoadData[uuid].element
|
|
3078
2032
|
};
|
|
3079
2033
|
if (loadUUIDList.length === 0 && uuids.length === 0 && status === true) {
|
|
3080
|
-
|
|
3081
|
-
|
|
2034
|
+
this._status = LoaderStatus.FREE;
|
|
2035
|
+
this._loadTask();
|
|
3082
2036
|
}
|
|
3083
|
-
|
|
3084
|
-
uuid: (
|
|
3085
|
-
type:
|
|
3086
|
-
status:
|
|
3087
|
-
content:
|
|
3088
|
-
source:
|
|
3089
|
-
elemW:
|
|
3090
|
-
elemH:
|
|
3091
|
-
element: (
|
|
2037
|
+
this._event.trigger("load", {
|
|
2038
|
+
uuid: (_a = this._storageLoadData[uuid]) === null || _a === void 0 ? void 0 : _a.uuid,
|
|
2039
|
+
type: this._storageLoadData[uuid].type,
|
|
2040
|
+
status: this._storageLoadData[uuid].status,
|
|
2041
|
+
content: this._storageLoadData[uuid].content,
|
|
2042
|
+
source: this._storageLoadData[uuid].source,
|
|
2043
|
+
elemW: this._storageLoadData[uuid].elemW,
|
|
2044
|
+
elemH: this._storageLoadData[uuid].elemH,
|
|
2045
|
+
element: (_b = this._storageLoadData[uuid]) === null || _b === void 0 ? void 0 : _b.element
|
|
3092
2046
|
});
|
|
3093
|
-
}).catch(
|
|
3094
|
-
var
|
|
2047
|
+
}).catch((err) => {
|
|
2048
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
3095
2049
|
console.warn(err);
|
|
3096
2050
|
loadUUIDList.splice(loadUUIDList.indexOf(uuid), 1);
|
|
3097
|
-
|
|
3098
|
-
if (
|
|
3099
|
-
|
|
2051
|
+
const status = _loadAction();
|
|
2052
|
+
if (this._currentLoadData[uuid]) {
|
|
2053
|
+
this._storageLoadData[uuid] = {
|
|
3100
2054
|
uuid,
|
|
3101
|
-
type: (
|
|
2055
|
+
type: (_a = this._currentLoadData[uuid]) === null || _a === void 0 ? void 0 : _a.type,
|
|
3102
2056
|
status: "fail",
|
|
3103
2057
|
content: null,
|
|
3104
2058
|
error: err,
|
|
3105
|
-
source: (
|
|
3106
|
-
elemW: (
|
|
3107
|
-
elemH: (_d =
|
|
3108
|
-
element: (_e =
|
|
2059
|
+
source: (_b = this._currentLoadData[uuid]) === null || _b === void 0 ? void 0 : _b.source,
|
|
2060
|
+
elemW: (_c = this._currentLoadData[uuid]) === null || _c === void 0 ? void 0 : _c.elemW,
|
|
2061
|
+
elemH: (_d = this._currentLoadData[uuid]) === null || _d === void 0 ? void 0 : _d.elemH,
|
|
2062
|
+
element: (_e = this._currentLoadData[uuid]) === null || _e === void 0 ? void 0 : _e.element
|
|
3109
2063
|
};
|
|
3110
2064
|
}
|
|
3111
2065
|
if (loadUUIDList.length === 0 && uuids.length === 0 && status === true) {
|
|
3112
|
-
|
|
3113
|
-
|
|
2066
|
+
this._status = LoaderStatus.FREE;
|
|
2067
|
+
this._loadTask();
|
|
3114
2068
|
}
|
|
3115
|
-
if (
|
|
3116
|
-
|
|
2069
|
+
if (this._currentLoadData[uuid]) {
|
|
2070
|
+
this._event.trigger("error", {
|
|
3117
2071
|
uuid,
|
|
3118
|
-
type: (_f =
|
|
3119
|
-
status: (_g =
|
|
3120
|
-
content: (_h =
|
|
3121
|
-
source: (_j =
|
|
3122
|
-
elemW: (_k =
|
|
3123
|
-
elemH: (_l =
|
|
3124
|
-
element: (_m =
|
|
2072
|
+
type: (_f = this._storageLoadData[uuid]) === null || _f === void 0 ? void 0 : _f.type,
|
|
2073
|
+
status: (_g = this._storageLoadData[uuid]) === null || _g === void 0 ? void 0 : _g.status,
|
|
2074
|
+
content: (_h = this._storageLoadData[uuid]) === null || _h === void 0 ? void 0 : _h.content,
|
|
2075
|
+
source: (_j = this._storageLoadData[uuid]) === null || _j === void 0 ? void 0 : _j.source,
|
|
2076
|
+
elemW: (_k = this._storageLoadData[uuid]) === null || _k === void 0 ? void 0 : _k.elemW,
|
|
2077
|
+
elemH: (_l = this._storageLoadData[uuid]) === null || _l === void 0 ? void 0 : _l.elemH,
|
|
2078
|
+
element: (_m = this._storageLoadData[uuid]) === null || _m === void 0 ? void 0 : _m.element
|
|
3125
2079
|
});
|
|
3126
2080
|
}
|
|
3127
2081
|
});
|
|
3128
|
-
};
|
|
3129
|
-
for (var i = loadUUIDList.length; i < maxParallelNum; i++) {
|
|
3130
|
-
var state_1 = _loop_1();
|
|
3131
|
-
if (state_1 === "break")
|
|
3132
|
-
break;
|
|
3133
2082
|
}
|
|
3134
2083
|
return false;
|
|
3135
2084
|
};
|
|
3136
2085
|
_loadAction();
|
|
3137
|
-
}
|
|
3138
|
-
|
|
3139
|
-
return __awaiter
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
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
|
-
});
|
|
2086
|
+
}
|
|
2087
|
+
_loadElementSource(params) {
|
|
2088
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2089
|
+
if (params && params.type === "image") {
|
|
2090
|
+
const image = yield loadImage(params.source);
|
|
2091
|
+
return image;
|
|
2092
|
+
} else if (params && params.type === "svg") {
|
|
2093
|
+
const image = yield loadSVG(params.source);
|
|
2094
|
+
return image;
|
|
2095
|
+
} else if (params && params.type === "html") {
|
|
2096
|
+
const image = yield loadHTML(params.source, {
|
|
2097
|
+
width: params.elemW,
|
|
2098
|
+
height: params.elemH
|
|
2099
|
+
});
|
|
2100
|
+
return image;
|
|
2101
|
+
}
|
|
2102
|
+
throw Error("Element's source is not support!");
|
|
3171
2103
|
});
|
|
3172
|
-
}
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
function RendererEvent2() {
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
class RendererEvent {
|
|
2107
|
+
constructor() {
|
|
3177
2108
|
this._listeners = /* @__PURE__ */ new Map();
|
|
3178
2109
|
}
|
|
3179
|
-
|
|
2110
|
+
on(eventKey, callback) {
|
|
3180
2111
|
if (this._listeners.has(eventKey)) {
|
|
3181
|
-
|
|
2112
|
+
const callbacks = this._listeners.get(eventKey);
|
|
3182
2113
|
callbacks === null || callbacks === void 0 ? void 0 : callbacks.push(callback);
|
|
3183
2114
|
this._listeners.set(eventKey, callbacks || []);
|
|
3184
2115
|
} else {
|
|
3185
2116
|
this._listeners.set(eventKey, [callback]);
|
|
3186
2117
|
}
|
|
3187
|
-
}
|
|
3188
|
-
|
|
2118
|
+
}
|
|
2119
|
+
off(eventKey, callback) {
|
|
3189
2120
|
if (this._listeners.has(eventKey)) {
|
|
3190
|
-
|
|
2121
|
+
const callbacks = this._listeners.get(eventKey);
|
|
3191
2122
|
if (Array.isArray(callbacks)) {
|
|
3192
|
-
for (
|
|
2123
|
+
for (let i = 0; i < (callbacks === null || callbacks === void 0 ? void 0 : callbacks.length); i++) {
|
|
3193
2124
|
if (callbacks[i] === callback) {
|
|
3194
2125
|
callbacks.splice(i, 1);
|
|
3195
2126
|
break;
|
|
@@ -3198,39 +2129,29 @@ var iDrawCore = function() {
|
|
|
3198
2129
|
}
|
|
3199
2130
|
this._listeners.set(eventKey, callbacks || []);
|
|
3200
2131
|
}
|
|
3201
|
-
}
|
|
3202
|
-
|
|
3203
|
-
|
|
2132
|
+
}
|
|
2133
|
+
trigger(eventKey, arg) {
|
|
2134
|
+
const callbacks = this._listeners.get(eventKey);
|
|
3204
2135
|
if (Array.isArray(callbacks)) {
|
|
3205
|
-
callbacks.forEach(
|
|
2136
|
+
callbacks.forEach((cb) => {
|
|
3206
2137
|
cb(arg);
|
|
3207
2138
|
});
|
|
3208
2139
|
return true;
|
|
3209
2140
|
} else {
|
|
3210
2141
|
return false;
|
|
3211
2142
|
}
|
|
3212
|
-
}
|
|
3213
|
-
|
|
2143
|
+
}
|
|
2144
|
+
has(name) {
|
|
3214
2145
|
if (this._listeners.has(name)) {
|
|
3215
|
-
|
|
2146
|
+
const list = this._listeners.get(name);
|
|
3216
2147
|
if (Array.isArray(list) && list.length > 0) {
|
|
3217
2148
|
return true;
|
|
3218
2149
|
}
|
|
3219
2150
|
}
|
|
3220
2151
|
return false;
|
|
3221
|
-
}
|
|
3222
|
-
|
|
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;
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
const { requestAnimationFrame } = window;
|
|
3234
2155
|
var DrawStatus;
|
|
3235
2156
|
(function(DrawStatus2) {
|
|
3236
2157
|
DrawStatus2["NULL"] = "null";
|
|
@@ -3238,131 +2159,123 @@ var iDrawCore = function() {
|
|
|
3238
2159
|
DrawStatus2["DRAWING"] = "drawing";
|
|
3239
2160
|
DrawStatus2["FREEZE"] = "freeze";
|
|
3240
2161
|
})(DrawStatus || (DrawStatus = {}));
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
_this[_loader] = new Loader({
|
|
2162
|
+
class Renderer extends RendererEvent {
|
|
2163
|
+
constructor(opts) {
|
|
2164
|
+
super();
|
|
2165
|
+
this._queue = [];
|
|
2166
|
+
this._ctx = null;
|
|
2167
|
+
this._status = DrawStatus.NULL;
|
|
2168
|
+
this._opts = opts;
|
|
2169
|
+
this._loader = new Loader({
|
|
3250
2170
|
maxParallelNum: 6
|
|
3251
2171
|
});
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
2172
|
+
this._loader.on("load", (res) => {
|
|
2173
|
+
this._drawFrame();
|
|
2174
|
+
this.trigger("load", { element: res.element });
|
|
3255
2175
|
});
|
|
3256
|
-
|
|
3257
|
-
|
|
2176
|
+
this._loader.on("error", (res) => {
|
|
2177
|
+
this.trigger("error", { element: res.element, error: res.error });
|
|
3258
2178
|
});
|
|
3259
|
-
|
|
3260
|
-
|
|
2179
|
+
this._loader.on("complete", () => {
|
|
2180
|
+
this.trigger("loadComplete", { t: Date.now() });
|
|
3261
2181
|
});
|
|
3262
|
-
return _this;
|
|
3263
2182
|
}
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
this
|
|
3267
|
-
|
|
2183
|
+
render(target, originData, opts) {
|
|
2184
|
+
const { changeResourceUUIDs = [] } = opts || {};
|
|
2185
|
+
this._status = DrawStatus.FREE;
|
|
2186
|
+
const data = deepClone(originData);
|
|
3268
2187
|
if (Array.isArray(data.elements)) {
|
|
3269
|
-
data.elements.forEach(
|
|
2188
|
+
data.elements.forEach((elem) => {
|
|
3270
2189
|
if (!(typeof elem.uuid === "string" && elem.uuid)) {
|
|
3271
2190
|
elem.uuid = createUUID();
|
|
3272
2191
|
}
|
|
3273
2192
|
});
|
|
3274
2193
|
}
|
|
3275
|
-
if (!this
|
|
3276
|
-
if (this
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
canvas.width = width *
|
|
3280
|
-
canvas.height = height *
|
|
3281
|
-
|
|
3282
|
-
this
|
|
2194
|
+
if (!this._ctx) {
|
|
2195
|
+
if (this._opts && Object.prototype.toString.call(target) === "[object HTMLCanvasElement]") {
|
|
2196
|
+
const { width, height, contextWidth, contextHeight, devicePixelRatio } = this._opts;
|
|
2197
|
+
const canvas = target;
|
|
2198
|
+
canvas.width = width * devicePixelRatio;
|
|
2199
|
+
canvas.height = height * devicePixelRatio;
|
|
2200
|
+
const ctx2d = canvas.getContext("2d");
|
|
2201
|
+
this._ctx = new Context$1(ctx2d, {
|
|
3283
2202
|
width,
|
|
3284
2203
|
height,
|
|
3285
2204
|
contextWidth: contextWidth || width,
|
|
3286
2205
|
contextHeight: contextHeight || height,
|
|
3287
|
-
devicePixelRatio
|
|
2206
|
+
devicePixelRatio
|
|
3288
2207
|
});
|
|
3289
2208
|
} else if (target) {
|
|
3290
|
-
this
|
|
2209
|
+
this._ctx = target;
|
|
3291
2210
|
}
|
|
3292
2211
|
}
|
|
3293
|
-
if ([DrawStatus.FREEZE].includes(this
|
|
2212
|
+
if ([DrawStatus.FREEZE].includes(this._status)) {
|
|
3294
2213
|
return;
|
|
3295
2214
|
}
|
|
3296
|
-
|
|
3297
|
-
this
|
|
3298
|
-
this
|
|
3299
|
-
this
|
|
3300
|
-
}
|
|
3301
|
-
|
|
3302
|
-
return this
|
|
3303
|
-
}
|
|
3304
|
-
|
|
3305
|
-
this
|
|
3306
|
-
}
|
|
3307
|
-
|
|
3308
|
-
this
|
|
3309
|
-
}
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
if (this[_status] === DrawStatus.FREEZE) {
|
|
2215
|
+
const _data = deepClone({ data });
|
|
2216
|
+
this._queue.push(_data);
|
|
2217
|
+
this._drawFrame();
|
|
2218
|
+
this._loader.load(data, changeResourceUUIDs || []);
|
|
2219
|
+
}
|
|
2220
|
+
getContext() {
|
|
2221
|
+
return this._ctx;
|
|
2222
|
+
}
|
|
2223
|
+
thaw() {
|
|
2224
|
+
this._status = DrawStatus.FREE;
|
|
2225
|
+
}
|
|
2226
|
+
_freeze() {
|
|
2227
|
+
this._status = DrawStatus.FREEZE;
|
|
2228
|
+
}
|
|
2229
|
+
_drawFrame() {
|
|
2230
|
+
if (this._status === DrawStatus.FREEZE) {
|
|
3313
2231
|
return;
|
|
3314
2232
|
}
|
|
3315
|
-
requestAnimationFrame(
|
|
3316
|
-
if (
|
|
2233
|
+
requestAnimationFrame(() => {
|
|
2234
|
+
if (this._status === DrawStatus.FREEZE) {
|
|
3317
2235
|
return;
|
|
3318
2236
|
}
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
if (
|
|
3323
|
-
item =
|
|
2237
|
+
const ctx = this._ctx;
|
|
2238
|
+
let item = this._queue[0];
|
|
2239
|
+
let isLastFrame = false;
|
|
2240
|
+
if (this._queue.length > 1) {
|
|
2241
|
+
item = this._queue.shift();
|
|
3324
2242
|
} else {
|
|
3325
2243
|
isLastFrame = true;
|
|
3326
2244
|
}
|
|
3327
|
-
if (
|
|
3328
|
-
|
|
2245
|
+
if (this._loader.isComplete() !== true) {
|
|
2246
|
+
this._drawFrame();
|
|
3329
2247
|
if (item && ctx) {
|
|
3330
|
-
drawContext(ctx, item.data,
|
|
2248
|
+
drawContext(ctx, item.data, this._loader);
|
|
3331
2249
|
}
|
|
3332
2250
|
} else if (item && ctx) {
|
|
3333
|
-
drawContext(ctx, item.data,
|
|
3334
|
-
|
|
2251
|
+
drawContext(ctx, item.data, this._loader);
|
|
2252
|
+
this._retainQueueOneItem();
|
|
3335
2253
|
if (!isLastFrame) {
|
|
3336
|
-
|
|
2254
|
+
this._drawFrame();
|
|
3337
2255
|
} else {
|
|
3338
|
-
|
|
2256
|
+
this._status = DrawStatus.FREE;
|
|
3339
2257
|
}
|
|
3340
2258
|
} else {
|
|
3341
|
-
|
|
2259
|
+
this._status = DrawStatus.FREE;
|
|
3342
2260
|
}
|
|
3343
|
-
|
|
3344
|
-
if (
|
|
3345
|
-
if (ctx &&
|
|
3346
|
-
drawContext(ctx,
|
|
2261
|
+
this.trigger("drawFrame", { t: Date.now() });
|
|
2262
|
+
if (this._loader.isComplete() === true && this._queue.length === 1 && this._status === DrawStatus.FREE) {
|
|
2263
|
+
if (ctx && this._queue[0] && this._queue[0].data) {
|
|
2264
|
+
drawContext(ctx, this._queue[0].data, this._loader);
|
|
3347
2265
|
}
|
|
3348
|
-
|
|
3349
|
-
|
|
2266
|
+
this.trigger("drawFrameComplete", { t: Date.now() });
|
|
2267
|
+
this._freeze();
|
|
3350
2268
|
}
|
|
3351
2269
|
});
|
|
3352
|
-
}
|
|
3353
|
-
|
|
3354
|
-
if (this
|
|
2270
|
+
}
|
|
2271
|
+
_retainQueueOneItem() {
|
|
2272
|
+
if (this._queue.length <= 1) {
|
|
3355
2273
|
return;
|
|
3356
2274
|
}
|
|
3357
|
-
|
|
3358
|
-
this
|
|
3359
|
-
}
|
|
3360
|
-
|
|
3361
|
-
}(RendererEvent);
|
|
3362
|
-
var default_1 = /* @__PURE__ */ Object.freeze({
|
|
3363
|
-
__proto__: null,
|
|
3364
|
-
Renderer
|
|
3365
|
-
});
|
|
2275
|
+
const lastOne = deepClone(this._queue[this._queue.length - 1]);
|
|
2276
|
+
this._queue = [lastOne];
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
3366
2279
|
function number(value) {
|
|
3367
2280
|
return typeof value === "number" && (value > 0 || value <= 0);
|
|
3368
2281
|
}
|
|
@@ -3388,7 +2301,7 @@ var iDrawCore = function() {
|
|
|
3388
2301
|
return number(value) && value >= 0;
|
|
3389
2302
|
}
|
|
3390
2303
|
function color(value) {
|
|
3391
|
-
return isColorStr
|
|
2304
|
+
return isColorStr(value);
|
|
3392
2305
|
}
|
|
3393
2306
|
function imageURL(value) {
|
|
3394
2307
|
return typeof value === "string" && /^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${value}`);
|
|
@@ -3647,7 +2560,7 @@ var iDrawCore = function() {
|
|
|
3647
2560
|
}
|
|
3648
2561
|
};
|
|
3649
2562
|
function mergeConfig(config) {
|
|
3650
|
-
const result = deepClone
|
|
2563
|
+
const result = deepClone(defaultConfig);
|
|
3651
2564
|
if (config) {
|
|
3652
2565
|
if (config.elementWrapper) {
|
|
3653
2566
|
result.elementWrapper = {
|
|
@@ -3707,16 +2620,16 @@ var iDrawCore = function() {
|
|
|
3707
2620
|
}
|
|
3708
2621
|
}
|
|
3709
2622
|
function isChangeImageElementResource(before, after) {
|
|
3710
|
-
var
|
|
3711
|
-
return ((
|
|
2623
|
+
var _a, _b;
|
|
2624
|
+
return ((_a = before == null ? void 0 : before.desc) == null ? void 0 : _a.src) !== ((_b = after == null ? void 0 : after.desc) == null ? void 0 : _b.src);
|
|
3712
2625
|
}
|
|
3713
2626
|
function isChangeSVGElementResource(before, after) {
|
|
3714
|
-
var
|
|
3715
|
-
return ((
|
|
2627
|
+
var _a, _b;
|
|
2628
|
+
return ((_a = before == null ? void 0 : before.desc) == null ? void 0 : _a.svg) !== ((_b = after == null ? void 0 : after.desc) == null ? void 0 : _b.svg);
|
|
3716
2629
|
}
|
|
3717
2630
|
function isChangeHTMLElementResource(before, after) {
|
|
3718
|
-
var
|
|
3719
|
-
return ((
|
|
2631
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2632
|
+
return ((_a = before == null ? void 0 : before.desc) == null ? void 0 : _a.html) !== ((_b = after == null ? void 0 : after.desc) == null ? void 0 : _b.html) || ((_c = before == null ? void 0 : before.desc) == null ? void 0 : _c.width) !== ((_d = after == null ? void 0 : after.desc) == null ? void 0 : _d.width) || ((_e = before == null ? void 0 : before.desc) == null ? void 0 : _e.height) !== ((_f = after == null ? void 0 : after.desc) == null ? void 0 : _f.height);
|
|
3720
2633
|
}
|
|
3721
2634
|
function diffElementResourceChange(before, after) {
|
|
3722
2635
|
let result = null;
|
|
@@ -3750,12 +2663,12 @@ var iDrawCore = function() {
|
|
|
3750
2663
|
return result;
|
|
3751
2664
|
}
|
|
3752
2665
|
function diffElementResourceChangeList(before, after) {
|
|
3753
|
-
var
|
|
2666
|
+
var _a;
|
|
3754
2667
|
const uuids = [];
|
|
3755
2668
|
const beforeMap = parseDataElementMap(before);
|
|
3756
2669
|
const afterMap = parseDataElementMap(after);
|
|
3757
2670
|
for (const uuid in afterMap) {
|
|
3758
|
-
if (["image", "svg", "html"].includes((
|
|
2671
|
+
if (["image", "svg", "html"].includes((_a = afterMap[uuid]) == null ? void 0 : _a.type) !== true) {
|
|
3759
2672
|
continue;
|
|
3760
2673
|
}
|
|
3761
2674
|
if (beforeMap[uuid]) {
|
|
@@ -3848,22 +2761,22 @@ var iDrawCore = function() {
|
|
|
3848
2761
|
initData(data) {
|
|
3849
2762
|
data.elements.forEach((elem) => {
|
|
3850
2763
|
if (!(elem.uuid && typeof elem.uuid === "string")) {
|
|
3851
|
-
elem.uuid = createUUID
|
|
2764
|
+
elem.uuid = createUUID();
|
|
3852
2765
|
}
|
|
3853
2766
|
});
|
|
3854
2767
|
return data;
|
|
3855
2768
|
}
|
|
3856
2769
|
isPointInElement(p, data) {
|
|
3857
|
-
var
|
|
2770
|
+
var _a, _b;
|
|
3858
2771
|
const ctx = this._ctx;
|
|
3859
2772
|
let idx = -1;
|
|
3860
2773
|
let uuid = null;
|
|
3861
2774
|
for (let i = data.elements.length - 1; i >= 0; i--) {
|
|
3862
2775
|
const ele = data.elements[i];
|
|
3863
|
-
if (((
|
|
2776
|
+
if (((_a = ele.operation) == null ? void 0 : _a.invisible) === true)
|
|
3864
2777
|
continue;
|
|
3865
2778
|
let bw = 0;
|
|
3866
|
-
if (((
|
|
2779
|
+
if (((_b = ele.desc) == null ? void 0 : _b.borderWidth) > 0) {
|
|
3867
2780
|
bw = ele.desc.borderWidth;
|
|
3868
2781
|
}
|
|
3869
2782
|
rotateElement(ctx, ele, () => {
|
|
@@ -3897,12 +2810,12 @@ var iDrawCore = function() {
|
|
|
3897
2810
|
this.limitElementAttrs(data.elements[index]);
|
|
3898
2811
|
}
|
|
3899
2812
|
transformElement(data, uuid, point, prevPoint, scale, direction) {
|
|
3900
|
-
var
|
|
2813
|
+
var _a, _b;
|
|
3901
2814
|
const index = this.getElementIndex(data, uuid);
|
|
3902
2815
|
if (!data.elements[index]) {
|
|
3903
2816
|
return null;
|
|
3904
2817
|
}
|
|
3905
|
-
if (((
|
|
2818
|
+
if (((_b = (_a = data.elements[index]) == null ? void 0 : _a.operation) == null ? void 0 : _b.lock) === true) {
|
|
3906
2819
|
return null;
|
|
3907
2820
|
}
|
|
3908
2821
|
const moveX = (point.x - prevPoint.x) / scale;
|
|
@@ -3954,10 +2867,10 @@ var iDrawCore = function() {
|
|
|
3954
2867
|
}
|
|
3955
2868
|
}
|
|
3956
2869
|
function calcuScaleElemPosition(elem, moveX, moveY, direction) {
|
|
3957
|
-
var
|
|
2870
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
3958
2871
|
const p = { x: elem.x, y: elem.y, w: elem.w, h: elem.h };
|
|
3959
2872
|
elem.angle || 0;
|
|
3960
|
-
if (((
|
|
2873
|
+
if (((_a = elem.operation) == null ? void 0 : _a.limitRatio) === true) {
|
|
3961
2874
|
if (["top-left", "top-right", "bottom-right", "bottom-left"].includes(
|
|
3962
2875
|
direction
|
|
3963
2876
|
)) {
|
|
@@ -3981,7 +2894,7 @@ var iDrawCore = function() {
|
|
|
3981
2894
|
if (p.h - moveY > 0) {
|
|
3982
2895
|
p.y += moveY;
|
|
3983
2896
|
p.h -= moveY;
|
|
3984
|
-
if (((
|
|
2897
|
+
if (((_b = elem.operation) == null ? void 0 : _b.limitRatio) === true) {
|
|
3985
2898
|
p.x += moveY / elem.h * elem.w / 2;
|
|
3986
2899
|
p.w -= moveY / elem.h * elem.w;
|
|
3987
2900
|
}
|
|
@@ -4017,7 +2930,7 @@ var iDrawCore = function() {
|
|
|
4017
2930
|
centerY = centerY - centerMoveDist * Math.sin(radian);
|
|
4018
2931
|
}
|
|
4019
2932
|
if (p.h + moveDist > 0) {
|
|
4020
|
-
if (((
|
|
2933
|
+
if (((_c = elem.operation) == null ? void 0 : _c.limitRatio) === true) {
|
|
4021
2934
|
p.w = p.w + moveDist / elem.h * elem.w;
|
|
4022
2935
|
}
|
|
4023
2936
|
p.h = p.h + moveDist;
|
|
@@ -4266,7 +3179,7 @@ var iDrawCore = function() {
|
|
|
4266
3179
|
this._updateSelectedElementListWrapper(data, opts);
|
|
4267
3180
|
}
|
|
4268
3181
|
getConfig() {
|
|
4269
|
-
return deepClone
|
|
3182
|
+
return deepClone(this._helperConfig);
|
|
4270
3183
|
}
|
|
4271
3184
|
getElementIndexByUUID(uuid) {
|
|
4272
3185
|
const index = this._helperConfig.elementIndexMap[uuid];
|
|
@@ -4276,9 +3189,9 @@ var iDrawCore = function() {
|
|
|
4276
3189
|
return null;
|
|
4277
3190
|
}
|
|
4278
3191
|
isPointInElementWrapperController(p, data) {
|
|
4279
|
-
var
|
|
3192
|
+
var _a, _b;
|
|
4280
3193
|
const ctx = this._ctx;
|
|
4281
|
-
const uuid = ((
|
|
3194
|
+
const uuid = ((_b = (_a = this._helperConfig) == null ? void 0 : _a.selectedElementWrapper) == null ? void 0 : _b.uuid) || null;
|
|
4282
3195
|
let directIndex = null;
|
|
4283
3196
|
let selectedControllerDirection = null;
|
|
4284
3197
|
let hoverControllerDirection = null;
|
|
@@ -4311,7 +3224,7 @@ var iDrawCore = function() {
|
|
|
4311
3224
|
"bottom",
|
|
4312
3225
|
"bottom-right"
|
|
4313
3226
|
];
|
|
4314
|
-
let hoverDirectionNames = deepClone
|
|
3227
|
+
let hoverDirectionNames = deepClone(directionNames);
|
|
4315
3228
|
let angleMoveNum = 0;
|
|
4316
3229
|
if (data && uuid) {
|
|
4317
3230
|
const elemIdx = this.getElementIndexByUUID(uuid);
|
|
@@ -4394,21 +3307,21 @@ var iDrawCore = function() {
|
|
|
4394
3307
|
};
|
|
4395
3308
|
}
|
|
4396
3309
|
isPointInElementList(p, data) {
|
|
4397
|
-
var
|
|
3310
|
+
var _a, _b, _c;
|
|
4398
3311
|
const ctx = this._ctx;
|
|
4399
3312
|
let idx = -1;
|
|
4400
3313
|
let uuid = null;
|
|
4401
|
-
const wrapperList = ((
|
|
3314
|
+
const wrapperList = ((_a = this._helperConfig) == null ? void 0 : _a.selectedElementListWrappers) || [];
|
|
4402
3315
|
for (let i = 0; i < wrapperList.length; i++) {
|
|
4403
3316
|
const wrapper = wrapperList[i];
|
|
4404
3317
|
const elemIdx = this._helperConfig.elementIndexMap[wrapper.uuid];
|
|
4405
3318
|
const ele = data.elements[elemIdx];
|
|
4406
3319
|
if (!ele)
|
|
4407
3320
|
continue;
|
|
4408
|
-
if (((
|
|
3321
|
+
if (((_b = ele.operation) == null ? void 0 : _b.invisible) === true)
|
|
4409
3322
|
continue;
|
|
4410
3323
|
let bw = 0;
|
|
4411
|
-
if (((
|
|
3324
|
+
if (((_c = ele.desc) == null ? void 0 : _c.borderWidth) > 0) {
|
|
4412
3325
|
bw = ele.desc.borderWidth;
|
|
4413
3326
|
}
|
|
4414
3327
|
rotateElement(ctx, ele, () => {
|
|
@@ -4466,8 +3379,8 @@ var iDrawCore = function() {
|
|
|
4466
3379
|
ctx.lineTo(x2, y2);
|
|
4467
3380
|
ctx.closePath();
|
|
4468
3381
|
data.elements.forEach((elem) => {
|
|
4469
|
-
var
|
|
4470
|
-
if (((
|
|
3382
|
+
var _a;
|
|
3383
|
+
if (((_a = elem == null ? void 0 : elem.operation) == null ? void 0 : _a.invisible) !== true) {
|
|
4471
3384
|
const centerX = elem.x + elem.w / 2;
|
|
4472
3385
|
const centerY = elem.y + elem.h / 2;
|
|
4473
3386
|
if (ctx.isPointInPathWithoutScroll(centerX, centerY)) {
|
|
@@ -4504,7 +3417,7 @@ var iDrawCore = function() {
|
|
|
4504
3417
|
});
|
|
4505
3418
|
}
|
|
4506
3419
|
_updateSelectedElementWrapper(data, opts) {
|
|
4507
|
-
var
|
|
3420
|
+
var _a;
|
|
4508
3421
|
const { selectedUUID: uuid } = opts;
|
|
4509
3422
|
if (!(typeof uuid === "string" && this._helperConfig.elementIndexMap[uuid] >= 0)) {
|
|
4510
3423
|
delete this._helperConfig.selectedElementWrapper;
|
|
@@ -4512,7 +3425,7 @@ var iDrawCore = function() {
|
|
|
4512
3425
|
}
|
|
4513
3426
|
const index = this._helperConfig.elementIndexMap[uuid];
|
|
4514
3427
|
const elem = data.elements[index];
|
|
4515
|
-
if (((
|
|
3428
|
+
if (((_a = elem == null ? void 0 : elem.operation) == null ? void 0 : _a.invisible) === true) {
|
|
4516
3429
|
return;
|
|
4517
3430
|
}
|
|
4518
3431
|
const wrapper = this._createSelectedElementWrapper(elem, opts);
|
|
@@ -4530,14 +3443,14 @@ var iDrawCore = function() {
|
|
|
4530
3443
|
this._helperConfig.selectedElementListWrappers = wrapperList;
|
|
4531
3444
|
}
|
|
4532
3445
|
_createSelectedElementWrapper(elem, opts) {
|
|
4533
|
-
var
|
|
3446
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
4534
3447
|
const { scale } = opts;
|
|
4535
3448
|
const elemWrapper = this._coreConfig.elementWrapper;
|
|
4536
3449
|
const controllerSize = elemWrapper.controllerSize / scale;
|
|
4537
3450
|
const lineWidth = elemWrapper.lineWidth / scale;
|
|
4538
3451
|
const lineDash = elemWrapper.lineDash.map((n) => n / scale);
|
|
4539
3452
|
const rotateLimit = 12;
|
|
4540
|
-
const bw = ((
|
|
3453
|
+
const bw = ((_a = elem.desc) == null ? void 0 : _a.borderWidth) || 0;
|
|
4541
3454
|
let hideObliqueDirection = false;
|
|
4542
3455
|
if (typeof elem.angle === "number" && Math.abs(elem.angle) > limitQbliqueAngle) {
|
|
4543
3456
|
hideObliqueDirection = true;
|
|
@@ -4547,12 +3460,12 @@ var iDrawCore = function() {
|
|
|
4547
3460
|
uuid: elem.uuid,
|
|
4548
3461
|
controllerSize,
|
|
4549
3462
|
controllerOffset,
|
|
4550
|
-
lock: ((
|
|
3463
|
+
lock: ((_b = elem == null ? void 0 : elem.operation) == null ? void 0 : _b.lock) === true,
|
|
4551
3464
|
controllers: {
|
|
4552
3465
|
topLeft: {
|
|
4553
3466
|
x: elem.x - controllerOffset - bw,
|
|
4554
3467
|
y: elem.y - controllerOffset - bw,
|
|
4555
|
-
invisible: hideObliqueDirection || ((
|
|
3468
|
+
invisible: hideObliqueDirection || ((_c = elem == null ? void 0 : elem.operation) == null ? void 0 : _c.disableScale) === true
|
|
4556
3469
|
},
|
|
4557
3470
|
top: {
|
|
4558
3471
|
x: elem.x + elem.w / 2,
|
|
@@ -4767,30 +3680,30 @@ var iDrawCore = function() {
|
|
|
4767
3680
|
elems.push(elem);
|
|
4768
3681
|
}
|
|
4769
3682
|
});
|
|
4770
|
-
return deepClone
|
|
3683
|
+
return deepClone(elems);
|
|
4771
3684
|
}
|
|
4772
3685
|
function getElement(core, uuid) {
|
|
4773
3686
|
let elem = null;
|
|
4774
3687
|
const index = core.getEngine().helper.getElementIndexByUUID(uuid);
|
|
4775
3688
|
if (index !== null && core.$data.elements[index]) {
|
|
4776
|
-
elem = deepClone
|
|
3689
|
+
elem = deepClone(core.$data.elements[index]);
|
|
4777
3690
|
}
|
|
4778
3691
|
return elem;
|
|
4779
3692
|
}
|
|
4780
3693
|
function getElementByIndex(core, index) {
|
|
4781
3694
|
let elem = null;
|
|
4782
3695
|
if (index >= 0 && core.$data.elements[index]) {
|
|
4783
|
-
elem = deepClone
|
|
3696
|
+
elem = deepClone(core.$data.elements[index]);
|
|
4784
3697
|
}
|
|
4785
3698
|
return elem;
|
|
4786
3699
|
}
|
|
4787
3700
|
function updateElement(core, elem) {
|
|
4788
|
-
var
|
|
4789
|
-
const _elem = deepClone
|
|
3701
|
+
var _a;
|
|
3702
|
+
const _elem = deepClone(elem);
|
|
4790
3703
|
const data = core.getData();
|
|
4791
3704
|
const resourceChangeUUIDs = [];
|
|
4792
3705
|
for (let i = 0; i < data.elements.length; i++) {
|
|
4793
|
-
if (_elem.uuid === ((
|
|
3706
|
+
if (_elem.uuid === ((_a = data.elements[i]) == null ? void 0 : _a.uuid)) {
|
|
4794
3707
|
const result = diffElementResourceChange(data.elements[i], _elem);
|
|
4795
3708
|
if (typeof result === "string") {
|
|
4796
3709
|
resourceChangeUUIDs.push(result);
|
|
@@ -4858,8 +3771,8 @@ var iDrawCore = function() {
|
|
|
4858
3771
|
core.$draw();
|
|
4859
3772
|
}
|
|
4860
3773
|
function addElement(core, elem) {
|
|
4861
|
-
const _elem = deepClone
|
|
4862
|
-
_elem.uuid = createUUID
|
|
3774
|
+
const _elem = deepClone(elem);
|
|
3775
|
+
_elem.uuid = createUUID();
|
|
4863
3776
|
core.$data.elements.push(_elem);
|
|
4864
3777
|
core.$emitChangeData();
|
|
4865
3778
|
core.$draw();
|
|
@@ -4881,8 +3794,8 @@ var iDrawCore = function() {
|
|
|
4881
3794
|
return null;
|
|
4882
3795
|
}
|
|
4883
3796
|
function insertElementBeforeIndex(core, elem, index) {
|
|
4884
|
-
const _elem = deepClone
|
|
4885
|
-
_elem.uuid = createUUID
|
|
3797
|
+
const _elem = deepClone(elem);
|
|
3798
|
+
_elem.uuid = createUUID();
|
|
4886
3799
|
if (index >= 0) {
|
|
4887
3800
|
core.$data.elements.splice(index, 0, _elem);
|
|
4888
3801
|
core.$emitChangeData();
|
|
@@ -4899,8 +3812,8 @@ var iDrawCore = function() {
|
|
|
4899
3812
|
return null;
|
|
4900
3813
|
}
|
|
4901
3814
|
function insertElementAfterIndex(core, elem, index) {
|
|
4902
|
-
const _elem = deepClone
|
|
4903
|
-
_elem.uuid = createUUID
|
|
3815
|
+
const _elem = deepClone(elem);
|
|
3816
|
+
_elem.uuid = createUUID();
|
|
4904
3817
|
if (index >= 0) {
|
|
4905
3818
|
core.$data.elements.splice(index + 1, 0, _elem);
|
|
4906
3819
|
core.$emitChangeData();
|
|
@@ -4954,7 +3867,7 @@ var iDrawCore = function() {
|
|
|
4954
3867
|
return this.helper.getConfig();
|
|
4955
3868
|
}
|
|
4956
3869
|
updateHelperConfig(opts) {
|
|
4957
|
-
var
|
|
3870
|
+
var _a;
|
|
4958
3871
|
const { board, getDataFeekback, config } = this._opts;
|
|
4959
3872
|
const data = getDataFeekback();
|
|
4960
3873
|
const transform = board.getTransform();
|
|
@@ -4962,7 +3875,7 @@ var iDrawCore = function() {
|
|
|
4962
3875
|
width: opts.width,
|
|
4963
3876
|
height: opts.height,
|
|
4964
3877
|
devicePixelRatio: opts.devicePixelRatio,
|
|
4965
|
-
canScroll: ((
|
|
3878
|
+
canScroll: ((_a = config == null ? void 0 : config.scrollWrapper) == null ? void 0 : _a.use) === true,
|
|
4966
3879
|
selectedUUID: this.temp.get("selectedUUID"),
|
|
4967
3880
|
selectedUUIDList: this.temp.get("selectedUUIDList"),
|
|
4968
3881
|
scale: transform.scale,
|
|
@@ -4978,34 +3891,34 @@ var iDrawCore = function() {
|
|
|
4978
3891
|
return;
|
|
4979
3892
|
}
|
|
4980
3893
|
const { board } = this._opts;
|
|
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));
|
|
3894
|
+
board.on("hover", throttle$1(this._handleHover.bind(this), 32));
|
|
3895
|
+
board.on("leave", throttle$1(this._handleLeave.bind(this), 32));
|
|
3896
|
+
board.on("point", throttle$1(this._handleClick.bind(this), 16));
|
|
4984
3897
|
board.on("doubleClick", this._handleDoubleClick.bind(this));
|
|
4985
3898
|
board.on("point", this._handlePoint.bind(this));
|
|
4986
3899
|
board.on("moveStart", this._handleMoveStart.bind(this));
|
|
4987
|
-
board.on("move", throttle(this._handleMove.bind(this), 16));
|
|
3900
|
+
board.on("move", throttle$1(this._handleMove.bind(this), 16));
|
|
4988
3901
|
board.on("moveEnd", this._handleMoveEnd.bind(this));
|
|
4989
3902
|
}
|
|
4990
3903
|
_handleDoubleClick(point) {
|
|
4991
|
-
var
|
|
3904
|
+
var _a, _b, _c;
|
|
4992
3905
|
const { element, getDataFeekback, drawFeekback, coreEvent } = this._opts;
|
|
4993
3906
|
const data = getDataFeekback();
|
|
4994
3907
|
const [index, uuid] = element.isPointInElement(point, data);
|
|
4995
3908
|
if (index >= 0 && uuid) {
|
|
4996
|
-
const elem = deepClone
|
|
4997
|
-
if (((
|
|
3909
|
+
const elem = deepClone((_a = data.elements) == null ? void 0 : _a[index]);
|
|
3910
|
+
if (((_b = elem == null ? void 0 : elem.operation) == null ? void 0 : _b.invisible) !== true) {
|
|
4998
3911
|
coreEvent.trigger("screenDoubleClickElement", {
|
|
4999
3912
|
index,
|
|
5000
3913
|
uuid,
|
|
5001
|
-
element: deepClone
|
|
3914
|
+
element: deepClone((_c = data.elements) == null ? void 0 : _c[index])
|
|
5002
3915
|
});
|
|
5003
3916
|
}
|
|
5004
3917
|
}
|
|
5005
3918
|
drawFeekback();
|
|
5006
3919
|
}
|
|
5007
3920
|
_handlePoint(point) {
|
|
5008
|
-
var
|
|
3921
|
+
var _a, _b, _c;
|
|
5009
3922
|
if (!this._mapper.isEffectivePoint(point)) {
|
|
5010
3923
|
return;
|
|
5011
3924
|
}
|
|
@@ -5032,13 +3945,13 @@ var iDrawCore = function() {
|
|
|
5032
3945
|
this.temp.set("selectedUUID", uuid);
|
|
5033
3946
|
} else {
|
|
5034
3947
|
const [index, uuid2] = element.isPointInElement(point, data);
|
|
5035
|
-
if (index >= 0 && ((
|
|
3948
|
+
if (index >= 0 && ((_b = (_a = data.elements[index]) == null ? void 0 : _a.operation) == null ? void 0 : _b.invisible) !== true) {
|
|
5036
3949
|
selectElementByIndex2(index, { useMode: true });
|
|
5037
3950
|
if (typeof uuid2 === "string" && coreEvent.has("screenSelectElement")) {
|
|
5038
3951
|
coreEvent.trigger("screenSelectElement", {
|
|
5039
3952
|
index,
|
|
5040
3953
|
uuid: uuid2,
|
|
5041
|
-
element: deepClone
|
|
3954
|
+
element: deepClone((_c = data.elements) == null ? void 0 : _c[index])
|
|
5042
3955
|
});
|
|
5043
3956
|
emitChangeScreen();
|
|
5044
3957
|
}
|
|
@@ -5053,7 +3966,7 @@ var iDrawCore = function() {
|
|
|
5053
3966
|
drawFeekback();
|
|
5054
3967
|
}
|
|
5055
3968
|
_handleClick(point) {
|
|
5056
|
-
var
|
|
3969
|
+
var _a;
|
|
5057
3970
|
const { element, getDataFeekback, coreEvent, drawFeekback } = this._opts;
|
|
5058
3971
|
const data = getDataFeekback();
|
|
5059
3972
|
const [index, uuid] = element.isPointInElement(point, data);
|
|
@@ -5061,7 +3974,7 @@ var iDrawCore = function() {
|
|
|
5061
3974
|
coreEvent.trigger("screenClickElement", {
|
|
5062
3975
|
index,
|
|
5063
3976
|
uuid,
|
|
5064
|
-
element: deepClone
|
|
3977
|
+
element: deepClone((_a = data.elements) == null ? void 0 : _a[index])
|
|
5065
3978
|
});
|
|
5066
3979
|
}
|
|
5067
3980
|
drawFeekback();
|
|
@@ -5134,12 +4047,12 @@ var iDrawCore = function() {
|
|
|
5134
4047
|
const data = getDataFeekback();
|
|
5135
4048
|
const helper = this.helper;
|
|
5136
4049
|
uuids.forEach((uuid) => {
|
|
5137
|
-
var
|
|
4050
|
+
var _a, _b;
|
|
5138
4051
|
const idx = helper.getElementIndexByUUID(uuid);
|
|
5139
4052
|
if (idx === null)
|
|
5140
4053
|
return;
|
|
5141
4054
|
const elem = data.elements[idx];
|
|
5142
|
-
if (((
|
|
4055
|
+
if (((_a = elem == null ? void 0 : elem.operation) == null ? void 0 : _a.lock) !== true && ((_b = elem == null ? void 0 : elem.operation) == null ? void 0 : _b.invisible) !== true) {
|
|
5143
4056
|
element.dragElement(
|
|
5144
4057
|
data,
|
|
5145
4058
|
uuid,
|
|
@@ -5223,7 +4136,7 @@ var iDrawCore = function() {
|
|
|
5223
4136
|
}
|
|
5224
4137
|
}
|
|
5225
4138
|
_handleHover(point) {
|
|
5226
|
-
var
|
|
4139
|
+
var _a, _b;
|
|
5227
4140
|
let isMouseOverElement = false;
|
|
5228
4141
|
const { board, getDataFeekback, coreEvent } = this._opts;
|
|
5229
4142
|
const data = getDataFeekback();
|
|
@@ -5238,7 +4151,7 @@ var iDrawCore = function() {
|
|
|
5238
4151
|
const index = helper.getElementIndexByUUID(elementUUID);
|
|
5239
4152
|
if (index !== null && index >= 0) {
|
|
5240
4153
|
const elem = data.elements[index];
|
|
5241
|
-
if (((
|
|
4154
|
+
if (((_a = elem == null ? void 0 : elem.operation) == null ? void 0 : _a.lock) === true || ((_b = elem == null ? void 0 : elem.operation) == null ? void 0 : _b.invisible) === true) {
|
|
5242
4155
|
board.resetCursor();
|
|
5243
4156
|
return;
|
|
5244
4157
|
}
|
|
@@ -5541,22 +4454,22 @@ var iDrawCore = function() {
|
|
|
5541
4454
|
}
|
|
5542
4455
|
class Core {
|
|
5543
4456
|
constructor(mount, opts, config) {
|
|
5544
|
-
var
|
|
4457
|
+
var _a, _b, _c;
|
|
5545
4458
|
this._coreEvent = new CoreEvent();
|
|
5546
4459
|
this._tempData = new TempData$1();
|
|
5547
4460
|
this.$data = { elements: [] };
|
|
5548
4461
|
this._opts = opts;
|
|
5549
4462
|
this._config = mergeConfig(config || {});
|
|
5550
|
-
this._board = new
|
|
4463
|
+
this._board = new Board(mount, {
|
|
5551
4464
|
...this._opts,
|
|
5552
|
-
canScroll: (
|
|
4465
|
+
canScroll: (_a = config == null ? void 0 : config.scrollWrapper) == null ? void 0 : _a.use,
|
|
5553
4466
|
scrollConfig: {
|
|
5554
|
-
color: ((
|
|
5555
|
-
width: ((
|
|
4467
|
+
color: ((_b = config == null ? void 0 : config.scrollWrapper) == null ? void 0 : _b.color) || "#000000",
|
|
4468
|
+
width: ((_c = config == null ? void 0 : config.scrollWrapper) == null ? void 0 : _c.width) || 12,
|
|
5556
4469
|
...(config == null ? void 0 : config.scrollWrapper) || {}
|
|
5557
4470
|
}
|
|
5558
4471
|
});
|
|
5559
|
-
this._renderer = new
|
|
4472
|
+
this._renderer = new Renderer();
|
|
5560
4473
|
const drawFrame = () => {
|
|
5561
4474
|
const helperCtx = this._board.getHelperContext();
|
|
5562
4475
|
const helperConfig = this._engine.getHelperConfig();
|
|
@@ -5698,11 +4611,11 @@ var iDrawCore = function() {
|
|
|
5698
4611
|
};
|
|
5699
4612
|
}
|
|
5700
4613
|
getData() {
|
|
5701
|
-
return deepClone
|
|
4614
|
+
return deepClone(this.$data);
|
|
5702
4615
|
}
|
|
5703
4616
|
setData(data, opts) {
|
|
5704
4617
|
const resourceChangeUUIDs = diffElementResourceChangeList(this.$data, data);
|
|
5705
|
-
this.$data = this._elementHandler.initData(deepClone
|
|
4618
|
+
this.$data = this._elementHandler.initData(deepClone(parseData(data)));
|
|
5706
4619
|
if (opts && opts.triggerChangeEvent === true) {
|
|
5707
4620
|
this.$emitChangeData();
|
|
5708
4621
|
}
|
|
@@ -5738,7 +4651,7 @@ var iDrawCore = function() {
|
|
|
5738
4651
|
}
|
|
5739
4652
|
$emitChangeData() {
|
|
5740
4653
|
if (this._coreEvent.has("changeData")) {
|
|
5741
|
-
this._coreEvent.trigger("changeData", deepClone
|
|
4654
|
+
this._coreEvent.trigger("changeData", deepClone(this.$data));
|
|
5742
4655
|
}
|
|
5743
4656
|
}
|
|
5744
4657
|
$getElementHandler() {
|