@idraw/renderer 0.4.2 → 1.0.0-alpha.1
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/calculator.d.ts +17 -12
- package/dist/esm/calculator.js +103 -88
- package/dist/esm/draw/base.d.ts +19 -0
- package/dist/esm/draw/base.js +141 -0
- package/dist/esm/draw/box.d.ts +2 -28
- package/dist/esm/draw/box.js +3 -335
- package/dist/esm/draw/circle.d.ts +2 -2
- package/dist/esm/draw/circle.js +4 -72
- package/dist/esm/draw/color.d.ts +3 -3
- package/dist/esm/draw/color.js +10 -8
- package/dist/esm/draw/ellipse.d.ts +2 -0
- package/dist/esm/draw/ellipse.js +6 -0
- package/dist/esm/draw/foreign-object.d.ts +2 -0
- package/dist/esm/draw/foreign-object.js +15 -0
- package/dist/esm/draw/global.d.ts +2 -2
- package/dist/esm/draw/global.js +2 -2
- package/dist/esm/draw/group.d.ts +3 -3
- package/dist/esm/draw/group.js +60 -94
- package/dist/esm/draw/image.d.ts +2 -2
- package/dist/esm/draw/image.js +70 -86
- package/dist/esm/draw/index.d.ts +6 -5
- package/dist/esm/draw/index.js +6 -5
- package/dist/esm/draw/layout.d.ts +2 -2
- package/dist/esm/draw/layout.js +21 -35
- package/dist/esm/draw/materials.d.ts +2 -0
- package/dist/esm/draw/materials.js +27 -0
- package/dist/esm/draw/path.d.ts +2 -2
- package/dist/esm/draw/path.js +4 -89
- package/dist/esm/draw/rect.d.ts +2 -2
- package/dist/esm/draw/rect.js +4 -22
- package/dist/esm/draw/svg-code.d.ts +2 -0
- package/dist/esm/draw/svg-code.js +15 -0
- package/dist/esm/draw/text.d.ts +2 -2
- package/dist/esm/draw/text.js +60 -50
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +15 -15
- package/dist/esm/loader.d.ts +4 -4
- package/dist/esm/loader.js +68 -70
- package/dist/esm/virtual/base.d.ts +2 -0
- package/dist/esm/virtual/base.js +52 -0
- package/dist/esm/virtual/circle.d.ts +2 -0
- package/dist/esm/virtual/circle.js +38 -0
- package/dist/esm/virtual/ellipse.d.ts +2 -0
- package/dist/esm/virtual/ellipse.js +40 -0
- package/dist/esm/virtual/index.d.ts +6 -0
- package/dist/esm/virtual/index.js +77 -0
- package/dist/esm/virtual/path.d.ts +2 -0
- package/dist/esm/virtual/path.js +10 -0
- package/dist/esm/virtual/rect.d.ts +2 -0
- package/dist/esm/virtual/rect.js +146 -0
- package/dist/esm/virtual/text.d.ts +2 -0
- package/dist/esm/virtual/text.js +165 -0
- package/dist/esm/visible/index.d.ts +22 -0
- package/dist/esm/{view-visible → visible}/index.js +29 -23
- package/dist/index.global.js +1794 -1578
- package/dist/index.global.min.js +1 -1
- package/package.json +3 -3
- package/dist/esm/draw/elements.d.ts +0 -2
- package/dist/esm/draw/elements.js +0 -27
- package/dist/esm/draw/html.d.ts +0 -2
- package/dist/esm/draw/html.js +0 -17
- package/dist/esm/draw/svg.d.ts +0 -2
- package/dist/esm/draw/svg.js +0 -17
- package/dist/esm/view-visible/index.d.ts +0 -22
- package/dist/esm/virtual-flat/index.d.ts +0 -7
- package/dist/esm/virtual-flat/index.js +0 -45
- package/dist/esm/virtual-flat/text.d.ts +0 -2
- package/dist/esm/virtual-flat/text.js +0 -151
package/dist/index.global.js
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
var iDrawRenderer = function(exports) {
|
|
2
|
-
"use strict";
|
|
3
|
-
throw TypeError(msg);
|
|
4
|
-
};
|
|
5
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
6
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
7
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
8
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
9
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
10
|
-
|
|
11
|
-
var _loadFuncMap, _currentLoadItemMap, _storageLoadItemMap, _hasDestroyed, _Loader_instances, registerLoadFunc_fn, getLoadElementSource_fn, createLoadItem_fn, emitLoad_fn, emitError_fn, loadResource_fn, isExistingErrorStorage_fn, _opts, _store, _opts2, _loader, _calculator, _hasDestroyed2, _Renderer_instances, init_fn;
|
|
1
|
+
var iDrawRenderer = (function(exports) {
|
|
2
|
+
"use strict";
|
|
12
3
|
function isColorStr(color2) {
|
|
13
4
|
return typeof color2 === "string" && (/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(color2) || /^[a-z]{1,}$/i.test(color2));
|
|
14
5
|
}
|
|
@@ -33,11 +24,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
33
24
|
}
|
|
34
25
|
return result;
|
|
35
26
|
}
|
|
27
|
+
function createStr(num) {
|
|
28
|
+
return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
|
|
29
|
+
}
|
|
36
30
|
function createUUID() {
|
|
37
|
-
|
|
38
|
-
return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
|
|
39
|
-
}
|
|
40
|
-
return `${_createStr()}${_createStr()}-${_createStr()}-${_createStr()}-${_createStr()}-${_createStr()}${_createStr()}${_createStr()}`;
|
|
31
|
+
return `${createStr()}${createStr()}-${createStr()}-${createStr()}-${createStr()}-${createStr()}${createStr()}${createStr()}`;
|
|
41
32
|
}
|
|
42
33
|
function limitHexStr(str, seed) {
|
|
43
34
|
let count = 0;
|
|
@@ -53,9 +44,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
53
44
|
}
|
|
54
45
|
return sum;
|
|
55
46
|
}
|
|
56
|
-
function createAssetId(assetStr,
|
|
47
|
+
function createAssetId(assetStr, mtrlUUID) {
|
|
57
48
|
const len = assetStr.length;
|
|
58
|
-
const seed = sumCharCodes(
|
|
49
|
+
const seed = sumCharCodes(mtrlUUID);
|
|
59
50
|
const mid = Math.floor(len / 2);
|
|
60
51
|
const start4 = assetStr.substring(0, 4).padStart(4, "0");
|
|
61
52
|
const end4 = assetStr.substring(0, 4).padStart(4, "0");
|
|
@@ -69,20 +60,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
69
60
|
const str8 = limitHexStr(end4.padStart(4, start4).padStart(4, end4), seed);
|
|
70
61
|
return `@assets/${str1}${str2}-${str3}-${str4}-${str5}-${str6}${str7}${str8}`;
|
|
71
62
|
}
|
|
72
|
-
function isAssetId(
|
|
73
|
-
return /^@assets\/[0-9a-z-]{0,}$/.test(`${
|
|
63
|
+
function isAssetId(id2) {
|
|
64
|
+
return /^@assets\/[0-9a-z-]{0,}$/.test(`${id2}`);
|
|
74
65
|
}
|
|
75
|
-
(function(s, e) {
|
|
76
|
-
var t = {};
|
|
77
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
78
|
-
t[p] = s[p];
|
|
79
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
80
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
81
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
82
|
-
t[p[i]] = s[p[i]];
|
|
83
|
-
}
|
|
84
|
-
return t;
|
|
85
|
-
});
|
|
86
66
|
function deepClone(target) {
|
|
87
67
|
function _clone(t) {
|
|
88
68
|
const type2 = is$1(t);
|
|
@@ -112,58 +92,17 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
112
92
|
function is$1(target) {
|
|
113
93
|
return Object.prototype.toString.call(target).replace(/[\]|\[]{1,1}/gi, "").split(" ")[1];
|
|
114
94
|
}
|
|
115
|
-
function
|
|
116
|
-
const
|
|
117
|
-
const result = typeStr.replace(/(\[object|\])/gi, "").trim();
|
|
118
|
-
return result;
|
|
119
|
-
}
|
|
120
|
-
const istype = {
|
|
121
|
-
type(data2, lowerCase) {
|
|
122
|
-
const result = parsePrototype(data2);
|
|
123
|
-
return lowerCase === true ? result.toLocaleLowerCase() : result;
|
|
124
|
-
},
|
|
125
|
-
array(data2) {
|
|
126
|
-
return parsePrototype(data2) === "Array";
|
|
127
|
-
},
|
|
128
|
-
json(data2) {
|
|
129
|
-
return parsePrototype(data2) === "Object";
|
|
130
|
-
},
|
|
131
|
-
function(data2) {
|
|
132
|
-
return parsePrototype(data2) === "Function";
|
|
133
|
-
},
|
|
134
|
-
asyncFunction(data2) {
|
|
135
|
-
return parsePrototype(data2) === "AsyncFunction";
|
|
136
|
-
},
|
|
137
|
-
boolean(data2) {
|
|
138
|
-
return parsePrototype(data2) === "Boolean";
|
|
139
|
-
},
|
|
140
|
-
string(data2) {
|
|
141
|
-
return parsePrototype(data2) === "String";
|
|
142
|
-
},
|
|
143
|
-
number(data2) {
|
|
144
|
-
return parsePrototype(data2) === "Number";
|
|
145
|
-
},
|
|
146
|
-
undefined(data2) {
|
|
147
|
-
return parsePrototype(data2) === "Undefined";
|
|
148
|
-
},
|
|
149
|
-
null(data2) {
|
|
150
|
-
return parsePrototype(data2) === "Null";
|
|
151
|
-
},
|
|
152
|
-
promise(data2) {
|
|
153
|
-
return parsePrototype(data2) === "Promise";
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
function parseHTMLToDataURL(html2, opts) {
|
|
157
|
-
const { width, height } = opts;
|
|
95
|
+
function parseXMLToDataURL(xml, opts) {
|
|
96
|
+
const { width: width2, height: height2 } = opts;
|
|
158
97
|
return new Promise((resolve, reject) => {
|
|
159
98
|
const _svg = `
|
|
160
99
|
<svg
|
|
161
100
|
xmlns="http://www.w3.org/2000/svg"
|
|
162
|
-
width="${
|
|
163
|
-
height = "${
|
|
101
|
+
width="${width2 || ""}"
|
|
102
|
+
height = "${height2 || ""}">
|
|
164
103
|
<foreignObject width="100%" height="100%">
|
|
165
104
|
<div xmlns = "http://www.w3.org/1999/xhtml">
|
|
166
|
-
${
|
|
105
|
+
${xml}
|
|
167
106
|
</div>
|
|
168
107
|
</foreignObject>
|
|
169
108
|
</svg>
|
|
@@ -172,8 +111,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
172
111
|
const reader = new FileReader();
|
|
173
112
|
reader.readAsDataURL(blob);
|
|
174
113
|
reader.onload = function(event) {
|
|
175
|
-
|
|
176
|
-
const base64 = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.result;
|
|
114
|
+
const base64 = event?.target?.result;
|
|
177
115
|
resolve(base64);
|
|
178
116
|
};
|
|
179
117
|
reader.onerror = function(err) {
|
|
@@ -181,15 +119,14 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
181
119
|
};
|
|
182
120
|
});
|
|
183
121
|
}
|
|
184
|
-
function
|
|
122
|
+
function parseSVGCodeToDataURL(svg2) {
|
|
185
123
|
return new Promise((resolve, reject) => {
|
|
186
124
|
const _svg = svg2;
|
|
187
125
|
const blob = new Blob([_svg], { type: "image/svg+xml;charset=utf-8" });
|
|
188
126
|
const reader = new FileReader();
|
|
189
127
|
reader.readAsDataURL(blob);
|
|
190
128
|
reader.onload = function(event) {
|
|
191
|
-
|
|
192
|
-
const base64 = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.result;
|
|
129
|
+
const base64 = event?.target?.result;
|
|
193
130
|
resolve(base64);
|
|
194
131
|
};
|
|
195
132
|
reader.onerror = function(err) {
|
|
@@ -197,33 +134,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
197
134
|
};
|
|
198
135
|
});
|
|
199
136
|
}
|
|
200
|
-
var __awaiter = function(thisArg, _arguments, P, generator) {
|
|
201
|
-
function adopt(value) {
|
|
202
|
-
return value instanceof P ? value : new P(function(resolve) {
|
|
203
|
-
resolve(value);
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
|
207
|
-
function fulfilled(value) {
|
|
208
|
-
try {
|
|
209
|
-
step(generator.next(value));
|
|
210
|
-
} catch (e) {
|
|
211
|
-
reject(e);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
function rejected(value) {
|
|
215
|
-
try {
|
|
216
|
-
step(generator["throw"](value));
|
|
217
|
-
} catch (e) {
|
|
218
|
-
reject(e);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
function step(result) {
|
|
222
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
223
|
-
}
|
|
224
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
225
|
-
});
|
|
226
|
-
};
|
|
227
137
|
const { Image } = window;
|
|
228
138
|
function loadImage(src) {
|
|
229
139
|
return new Promise((resolve, reject) => {
|
|
@@ -237,23 +147,19 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
237
147
|
img.src = src;
|
|
238
148
|
});
|
|
239
149
|
}
|
|
240
|
-
function
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
return image;
|
|
245
|
-
});
|
|
150
|
+
async function loadSVGCode(code) {
|
|
151
|
+
const dataURL = await parseSVGCodeToDataURL(code);
|
|
152
|
+
const image = await loadImage(dataURL);
|
|
153
|
+
return image;
|
|
246
154
|
}
|
|
247
155
|
function filterAmpersand(str) {
|
|
248
|
-
return str.replace(
|
|
249
|
-
}
|
|
250
|
-
function
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
return image;
|
|
256
|
-
});
|
|
156
|
+
return str.replace(/&/gi, "&");
|
|
157
|
+
}
|
|
158
|
+
async function loadForeignObject(content, opts) {
|
|
159
|
+
content = filterAmpersand(content);
|
|
160
|
+
const dataURL = await parseXMLToDataURL(content, opts);
|
|
161
|
+
const image = await loadImage(dataURL);
|
|
162
|
+
return image;
|
|
257
163
|
}
|
|
258
164
|
function positiveNum(value) {
|
|
259
165
|
return typeof value === "number" && value >= 0;
|
|
@@ -267,19 +173,19 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
267
173
|
function y(value) {
|
|
268
174
|
return number(value);
|
|
269
175
|
}
|
|
270
|
-
function
|
|
176
|
+
function width(value) {
|
|
271
177
|
return positiveNum(value);
|
|
272
178
|
}
|
|
273
|
-
function
|
|
179
|
+
function height(value) {
|
|
274
180
|
return positiveNum(value);
|
|
275
181
|
}
|
|
276
182
|
function angle(value) {
|
|
277
183
|
return typeof value === "number" && value >= -360 && value <= 360;
|
|
278
184
|
}
|
|
279
|
-
function
|
|
185
|
+
function strokeWidth(value) {
|
|
280
186
|
return positiveNum(value) || Array.isArray(value) && positiveNum(value[0]) && positiveNum(value[1]) && positiveNum(value[2]) && positiveNum(value[3]);
|
|
281
187
|
}
|
|
282
|
-
function
|
|
188
|
+
function cornerRadius(value) {
|
|
283
189
|
return positiveNum(value) || Array.isArray(value) && positiveNum(value[0]) && positiveNum(value[1]) && positiveNum(value[2]) && positiveNum(value[3]);
|
|
284
190
|
}
|
|
285
191
|
function color(value) {
|
|
@@ -318,9 +224,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
318
224
|
function lineHeight(value) {
|
|
319
225
|
return number(value) && value > 0;
|
|
320
226
|
}
|
|
321
|
-
function strokeWidth(value) {
|
|
322
|
-
return number(value) && value > 0;
|
|
323
|
-
}
|
|
324
227
|
function textAlign(value) {
|
|
325
228
|
return ["center", "left", "right"].includes(value);
|
|
326
229
|
}
|
|
@@ -334,22 +237,22 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
334
237
|
return /^(-?\d+(?:\.\d+)?)$/.test(`${value}`);
|
|
335
238
|
}
|
|
336
239
|
function type(value) {
|
|
337
|
-
return ["rect", "circle", "text", "image", "
|
|
240
|
+
return ["rect", "circle", "text", "image", "svgCode", "foreignObject", "group"].includes(value);
|
|
338
241
|
}
|
|
339
|
-
function
|
|
340
|
-
if (!
|
|
242
|
+
function material(mtrl) {
|
|
243
|
+
if (!mtrl) {
|
|
341
244
|
return false;
|
|
342
245
|
}
|
|
343
|
-
return type(
|
|
246
|
+
return type(mtrl?.type) && x(mtrl?.x) && y(mtrl?.y) && width(mtrl?.w) && height(mtrl?.h);
|
|
344
247
|
}
|
|
345
248
|
function layout(value) {
|
|
346
249
|
if (!value) {
|
|
347
250
|
return false;
|
|
348
251
|
}
|
|
349
|
-
return x(value
|
|
252
|
+
return x(value?.x) && y(value?.y) && width(value?.w) && height(value?.h);
|
|
350
253
|
}
|
|
351
254
|
function data(d) {
|
|
352
|
-
if (Array(d
|
|
255
|
+
if (Array(d?.materials) && d?.materials.length >= 0) {
|
|
353
256
|
return true;
|
|
354
257
|
}
|
|
355
258
|
return false;
|
|
@@ -357,18 +260,18 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
357
260
|
const is = {
|
|
358
261
|
positiveNum,
|
|
359
262
|
data,
|
|
360
|
-
|
|
263
|
+
material,
|
|
361
264
|
layout,
|
|
362
265
|
type,
|
|
363
266
|
x,
|
|
364
267
|
y,
|
|
365
|
-
|
|
366
|
-
|
|
268
|
+
width,
|
|
269
|
+
height,
|
|
367
270
|
angle,
|
|
368
271
|
number,
|
|
369
272
|
numberStr,
|
|
370
|
-
|
|
371
|
-
|
|
273
|
+
strokeWidth,
|
|
274
|
+
cornerRadius,
|
|
372
275
|
color,
|
|
373
276
|
imageSrc,
|
|
374
277
|
imageURL,
|
|
@@ -380,62 +283,38 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
380
283
|
lineHeight,
|
|
381
284
|
textAlign,
|
|
382
285
|
fontFamily,
|
|
383
|
-
fontWeight
|
|
384
|
-
strokeWidth
|
|
385
|
-
};
|
|
386
|
-
(function(receiver, state, value, kind, f) {
|
|
387
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
388
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
389
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
390
|
-
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
391
|
-
});
|
|
392
|
-
(function(receiver, state, kind, f) {
|
|
393
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
394
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
395
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
396
|
-
});
|
|
397
|
-
var __classPrivateFieldSet$1 = function(receiver, state, value, kind, f) {
|
|
398
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
399
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
400
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
401
|
-
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
402
|
-
};
|
|
403
|
-
var __classPrivateFieldGet$1 = function(receiver, state, kind, f) {
|
|
404
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
405
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
406
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
286
|
+
fontWeight
|
|
407
287
|
};
|
|
408
|
-
var _EventEmitter_listeners;
|
|
409
288
|
class EventEmitter {
|
|
289
|
+
#listeners;
|
|
410
290
|
constructor() {
|
|
411
|
-
|
|
412
|
-
__classPrivateFieldSet$1(this, _EventEmitter_listeners, /* @__PURE__ */ new Map(), "f");
|
|
291
|
+
this.#listeners = /* @__PURE__ */ new Map();
|
|
413
292
|
}
|
|
414
293
|
on(eventKey, callback) {
|
|
415
|
-
if (
|
|
416
|
-
const callbacks =
|
|
417
|
-
callbacks
|
|
418
|
-
|
|
294
|
+
if (this.#listeners.has(eventKey)) {
|
|
295
|
+
const callbacks = this.#listeners.get(eventKey) || [];
|
|
296
|
+
callbacks?.push(callback);
|
|
297
|
+
this.#listeners.set(eventKey, callbacks);
|
|
419
298
|
} else {
|
|
420
|
-
|
|
299
|
+
this.#listeners.set(eventKey, [callback]);
|
|
421
300
|
}
|
|
422
301
|
}
|
|
423
302
|
off(eventKey, callback) {
|
|
424
|
-
if (
|
|
425
|
-
const callbacks =
|
|
303
|
+
if (this.#listeners.has(eventKey)) {
|
|
304
|
+
const callbacks = this.#listeners.get(eventKey);
|
|
426
305
|
if (Array.isArray(callbacks)) {
|
|
427
|
-
for (let i = 0; i <
|
|
306
|
+
for (let i = 0; i < callbacks?.length; i++) {
|
|
428
307
|
if (callbacks[i] === callback) {
|
|
429
308
|
callbacks.splice(i, 1);
|
|
430
309
|
break;
|
|
431
310
|
}
|
|
432
311
|
}
|
|
433
312
|
}
|
|
434
|
-
|
|
313
|
+
this.#listeners.set(eventKey, callbacks || []);
|
|
435
314
|
}
|
|
436
315
|
}
|
|
437
316
|
trigger(eventKey, e) {
|
|
438
|
-
const callbacks =
|
|
317
|
+
const callbacks = this.#listeners.get(eventKey);
|
|
439
318
|
if (Array.isArray(callbacks)) {
|
|
440
319
|
callbacks.forEach((cb) => {
|
|
441
320
|
cb(e);
|
|
@@ -446,8 +325,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
446
325
|
}
|
|
447
326
|
}
|
|
448
327
|
has(name) {
|
|
449
|
-
if (
|
|
450
|
-
const list =
|
|
328
|
+
if (this.#listeners.has(name)) {
|
|
329
|
+
const list = this.#listeners.get(name);
|
|
451
330
|
if (Array.isArray(list) && list.length > 0) {
|
|
452
331
|
return true;
|
|
453
332
|
}
|
|
@@ -458,10 +337,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
458
337
|
this.clear();
|
|
459
338
|
}
|
|
460
339
|
clear() {
|
|
461
|
-
|
|
340
|
+
this.#listeners.clear();
|
|
462
341
|
}
|
|
463
342
|
}
|
|
464
|
-
_EventEmitter_listeners = /* @__PURE__ */ new WeakMap();
|
|
465
343
|
function calcDistance(start, end) {
|
|
466
344
|
const distance = (start.x - end.x) * (start.x - end.x) + (start.y - end.y) * (start.y - end.y);
|
|
467
345
|
return distance === 0 ? distance : Math.sqrt(distance);
|
|
@@ -472,57 +350,44 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
472
350
|
y: p1.y + (p2.y - p1.y) / 2
|
|
473
351
|
};
|
|
474
352
|
}
|
|
475
|
-
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
476
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
477
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
478
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
479
|
-
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
480
|
-
};
|
|
481
|
-
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
482
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
483
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
484
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
485
|
-
};
|
|
486
|
-
var _Store_instances, _Store_temp, _Store_backUpDefaultStorage, _Store_static, _Store_createTempStorage;
|
|
487
353
|
class Store {
|
|
354
|
+
#temp;
|
|
355
|
+
#backUpDefaultStorage;
|
|
356
|
+
#static;
|
|
488
357
|
constructor(opts) {
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
_Store_static.set(this, void 0);
|
|
493
|
-
__classPrivateFieldSet(this, _Store_backUpDefaultStorage, deepClone(opts.defaultStorage), "f");
|
|
494
|
-
__classPrivateFieldSet(this, _Store_temp, __classPrivateFieldGet(this, _Store_instances, "m", _Store_createTempStorage).call(this), "f");
|
|
495
|
-
__classPrivateFieldSet(this, _Store_static, opts.defaultStatic || {}, "f");
|
|
358
|
+
this.#backUpDefaultStorage = deepClone(opts.defaultStorage);
|
|
359
|
+
this.#temp = this.#createTempStorage();
|
|
360
|
+
this.#static = opts.defaultStatic || {};
|
|
496
361
|
}
|
|
497
362
|
set(name, value) {
|
|
498
|
-
|
|
363
|
+
this.#temp[name] = value;
|
|
499
364
|
}
|
|
500
365
|
get(name) {
|
|
501
|
-
return
|
|
366
|
+
return this.#temp[name];
|
|
502
367
|
}
|
|
503
368
|
setStatic(name, value) {
|
|
504
|
-
|
|
369
|
+
this.#static[name] = value;
|
|
505
370
|
}
|
|
506
371
|
getStatic(name) {
|
|
507
|
-
return
|
|
372
|
+
return this.#static[name];
|
|
508
373
|
}
|
|
509
374
|
getSnapshot(opts) {
|
|
510
|
-
if (
|
|
511
|
-
return deepClone(
|
|
375
|
+
if (opts?.deepClone === true) {
|
|
376
|
+
return deepClone(this.#temp);
|
|
512
377
|
}
|
|
513
|
-
return
|
|
378
|
+
return { ...this.#temp };
|
|
514
379
|
}
|
|
515
380
|
clear() {
|
|
516
|
-
|
|
381
|
+
this.#temp = this.#createTempStorage();
|
|
517
382
|
}
|
|
518
383
|
destroy() {
|
|
519
|
-
|
|
520
|
-
|
|
384
|
+
this.#temp = null;
|
|
385
|
+
this.#static = null;
|
|
386
|
+
}
|
|
387
|
+
#createTempStorage() {
|
|
388
|
+
return deepClone(this.#backUpDefaultStorage);
|
|
521
389
|
}
|
|
522
390
|
}
|
|
523
|
-
_Store_temp = /* @__PURE__ */ new WeakMap(), _Store_backUpDefaultStorage = /* @__PURE__ */ new WeakMap(), _Store_static = /* @__PURE__ */ new WeakMap(), _Store_instances = /* @__PURE__ */ new WeakSet(), _Store_createTempStorage = function _Store_createTempStorage2() {
|
|
524
|
-
return deepClone(__classPrivateFieldGet(this, _Store_backUpDefaultStorage, "f"));
|
|
525
|
-
};
|
|
526
391
|
function parseAngleToRadian(angle2) {
|
|
527
392
|
return angle2 / 180 * Math.PI;
|
|
528
393
|
}
|
|
@@ -540,31 +405,25 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
540
405
|
ctx.translate(-center.x, -center.y);
|
|
541
406
|
}
|
|
542
407
|
}
|
|
543
|
-
function
|
|
544
|
-
const center = calcElementCenter(elemSize);
|
|
545
|
-
rotateByCenter(ctx, elemSize.angle || 0, center, () => {
|
|
546
|
-
callback(ctx);
|
|
547
|
-
});
|
|
548
|
-
}
|
|
549
|
-
function calcElementCenter(elem) {
|
|
408
|
+
function calcMaterialCenter(mtrl) {
|
|
550
409
|
const p = {
|
|
551
|
-
x:
|
|
552
|
-
y:
|
|
410
|
+
x: mtrl.x + mtrl.width / 2,
|
|
411
|
+
y: mtrl.y + mtrl.height / 2
|
|
553
412
|
};
|
|
554
413
|
return p;
|
|
555
414
|
}
|
|
556
|
-
function
|
|
415
|
+
function calcMaterialCenterFromVertexes(ves) {
|
|
557
416
|
const startX = Math.min(ves[0].x, ves[1].x, ves[2].x, ves[3].x);
|
|
558
417
|
const startY = Math.min(ves[0].y, ves[1].y, ves[2].y, ves[3].y);
|
|
559
418
|
const endX = Math.max(ves[0].x, ves[1].x, ves[2].x, ves[3].x);
|
|
560
419
|
const endY = Math.max(ves[0].y, ves[1].y, ves[2].y, ves[3].y);
|
|
561
|
-
const
|
|
420
|
+
const mtrlSize = {
|
|
562
421
|
x: startX,
|
|
563
422
|
y: startY,
|
|
564
|
-
|
|
565
|
-
|
|
423
|
+
width: endX - startX,
|
|
424
|
+
height: endY - startY
|
|
566
425
|
};
|
|
567
|
-
return
|
|
426
|
+
return calcMaterialCenter(mtrlSize);
|
|
568
427
|
}
|
|
569
428
|
function calcLineRadian(center, p) {
|
|
570
429
|
const x2 = p.x - center.x;
|
|
@@ -640,12 +499,12 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
640
499
|
y2 += center.y;
|
|
641
500
|
return { x: x2, y: y2 };
|
|
642
501
|
}
|
|
643
|
-
function
|
|
644
|
-
const { x: x2, y: y2,
|
|
502
|
+
function getMaterialRotateVertexes(mtrlSize, center, angle2) {
|
|
503
|
+
const { x: x2, y: y2, width: width2, height: height2 } = mtrlSize;
|
|
645
504
|
let p1 = { x: x2, y: y2 };
|
|
646
|
-
let p2 = { x: x2 +
|
|
647
|
-
let p3 = { x: x2 +
|
|
648
|
-
let p4 = { x: x2, y: y2 +
|
|
505
|
+
let p2 = { x: x2 + width2, y: y2 };
|
|
506
|
+
let p3 = { x: x2 + width2, y: y2 + height2 };
|
|
507
|
+
let p4 = { x: x2, y: y2 + height2 };
|
|
649
508
|
if (angle2 && (angle2 > 0 || angle2 < 0)) {
|
|
650
509
|
const radian = parseAngleToRadian(limitAngle(angle2));
|
|
651
510
|
p1 = rotatePoint(center, p1, radian);
|
|
@@ -655,10 +514,10 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
655
514
|
}
|
|
656
515
|
return [p1, p2, p3, p4];
|
|
657
516
|
}
|
|
658
|
-
function
|
|
659
|
-
const { angle: angle2 = 0 } =
|
|
660
|
-
const center =
|
|
661
|
-
return
|
|
517
|
+
function rotateMaterialVertexes(mtrlSize) {
|
|
518
|
+
const { angle: angle2 = 0 } = mtrlSize;
|
|
519
|
+
const center = calcMaterialCenter(mtrlSize);
|
|
520
|
+
return getMaterialRotateVertexes(mtrlSize, center, angle2);
|
|
662
521
|
}
|
|
663
522
|
function rotateVertexes(center, ves, radian) {
|
|
664
523
|
return [
|
|
@@ -680,17 +539,16 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
680
539
|
}
|
|
681
540
|
return num;
|
|
682
541
|
}
|
|
683
|
-
function
|
|
684
|
-
var _a;
|
|
542
|
+
function getGroupQueueByMaterialPosition(materials, position) {
|
|
685
543
|
const groupQueue = [];
|
|
686
|
-
let
|
|
544
|
+
let currentMaterials = materials;
|
|
687
545
|
if (position.length > 1) {
|
|
688
546
|
for (let i = 0; i < position.length - 1; i++) {
|
|
689
547
|
const index = position[i];
|
|
690
|
-
const group =
|
|
691
|
-
if (
|
|
548
|
+
const group = currentMaterials[index];
|
|
549
|
+
if (group?.type === "group" && Array.isArray(group?.children)) {
|
|
692
550
|
groupQueue.push(group);
|
|
693
|
-
|
|
551
|
+
currentMaterials = group.children;
|
|
694
552
|
} else {
|
|
695
553
|
return null;
|
|
696
554
|
}
|
|
@@ -698,14 +556,14 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
698
556
|
}
|
|
699
557
|
return groupQueue;
|
|
700
558
|
}
|
|
701
|
-
function
|
|
559
|
+
function findMaterialFromListByPosition(position, list) {
|
|
702
560
|
let result = null;
|
|
703
561
|
let tempList = list;
|
|
704
562
|
for (let i = 0; i < position.length; i++) {
|
|
705
563
|
const pos = position[i];
|
|
706
564
|
const item = tempList[pos];
|
|
707
|
-
if (i < position.length - 1 &&
|
|
708
|
-
tempList = item.
|
|
565
|
+
if (i < position.length - 1 && item?.type === "group") {
|
|
566
|
+
tempList = item.children;
|
|
709
567
|
} else if (i === position.length - 1) {
|
|
710
568
|
result = item;
|
|
711
569
|
} else {
|
|
@@ -714,49 +572,49 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
714
572
|
}
|
|
715
573
|
return result;
|
|
716
574
|
}
|
|
717
|
-
function
|
|
718
|
-
const { x: x2, y: y2,
|
|
575
|
+
function getMaterialVertexes(mtrlSize) {
|
|
576
|
+
const { x: x2, y: y2, height: height2, width: width2 } = mtrlSize;
|
|
719
577
|
return [
|
|
720
578
|
{ x: x2, y: y2 },
|
|
721
|
-
{ x: x2 +
|
|
722
|
-
{ x: x2 +
|
|
723
|
-
{ x: x2, y: y2 +
|
|
579
|
+
{ x: x2 + width2, y: y2 },
|
|
580
|
+
{ x: x2 + width2, y: y2 + height2 },
|
|
581
|
+
{ x: x2, y: y2 + height2 }
|
|
724
582
|
];
|
|
725
583
|
}
|
|
726
|
-
function
|
|
727
|
-
const { x: x2, y: y2,
|
|
584
|
+
function calcMaterialVertexes(mtrlSize) {
|
|
585
|
+
const { x: x2, y: y2, width: width2, height: height2, angle: angle2 = 0 } = mtrlSize;
|
|
728
586
|
if (angle2 === 0) {
|
|
729
|
-
return
|
|
587
|
+
return getMaterialVertexes(mtrlSize);
|
|
730
588
|
}
|
|
731
|
-
return
|
|
589
|
+
return getMaterialRotateVertexes(mtrlSize, calcMaterialCenter({ x: x2, y: y2, width: width2, height: height2 }), angle2);
|
|
732
590
|
}
|
|
733
|
-
function
|
|
591
|
+
function calcMaterialQueueVertexesQueueInGroup(groupQueue) {
|
|
734
592
|
const vesList = [];
|
|
735
593
|
let totalX = 0;
|
|
736
594
|
let totalY = 0;
|
|
737
595
|
const rotateActionList = [];
|
|
738
|
-
const
|
|
739
|
-
for (let i = 0; i <
|
|
740
|
-
const { x: x2, y: y2,
|
|
596
|
+
const mtrlQueue = [...groupQueue];
|
|
597
|
+
for (let i = 0; i < mtrlQueue.length; i++) {
|
|
598
|
+
const { x: x2, y: y2, width: width2, height: height2, angle: angle2 = 0 } = mtrlQueue[i];
|
|
741
599
|
totalX += x2;
|
|
742
600
|
totalY += y2;
|
|
743
601
|
let ves;
|
|
744
602
|
if (i === 0) {
|
|
745
|
-
const
|
|
746
|
-
ves =
|
|
603
|
+
const mtrlSize = { x: totalX, y: totalY, width: width2, height: height2 };
|
|
604
|
+
ves = calcMaterialVertexes({ x: x2, y: y2, width: width2, height: height2, angle: angle2 });
|
|
747
605
|
rotateActionList.push({
|
|
748
|
-
center:
|
|
606
|
+
center: calcMaterialCenter(mtrlSize),
|
|
749
607
|
angle: angle2,
|
|
750
608
|
radian: parseAngleToRadian(angle2)
|
|
751
609
|
});
|
|
752
610
|
} else {
|
|
753
|
-
const
|
|
754
|
-
ves =
|
|
611
|
+
const mtrlSize = { x: totalX, y: totalY, width: width2, height: height2 };
|
|
612
|
+
ves = getMaterialVertexes(mtrlSize);
|
|
755
613
|
for (let aIdx = 0; aIdx < rotateActionList.length; aIdx++) {
|
|
756
614
|
const { center, radian } = rotateActionList[aIdx];
|
|
757
615
|
ves = rotateVertexes(center, ves, radian);
|
|
758
616
|
}
|
|
759
|
-
const vesCenter =
|
|
617
|
+
const vesCenter = calcMaterialCenterFromVertexes(ves);
|
|
760
618
|
if (angle2 > 0 || angle2 < 0) {
|
|
761
619
|
const radian = parseAngleToRadian(angle2);
|
|
762
620
|
ves = rotateVertexes(vesCenter, ves, radian);
|
|
@@ -771,34 +629,35 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
771
629
|
}
|
|
772
630
|
return vesList;
|
|
773
631
|
}
|
|
774
|
-
function
|
|
632
|
+
function calcMaterialVertexesQueueInGroup(targetMtrl, opts) {
|
|
775
633
|
const { groupQueue } = opts;
|
|
776
634
|
if (!(groupQueue.length > 0)) {
|
|
777
|
-
return [
|
|
635
|
+
return [calcMaterialVertexes(targetMtrl)];
|
|
778
636
|
}
|
|
779
|
-
const
|
|
780
|
-
const vesList =
|
|
637
|
+
const mtrlQueue = [...groupQueue, ...[targetMtrl]];
|
|
638
|
+
const vesList = calcMaterialQueueVertexesQueueInGroup(mtrlQueue);
|
|
781
639
|
return vesList;
|
|
782
640
|
}
|
|
783
|
-
function
|
|
784
|
-
const vesList =
|
|
641
|
+
function calcMaterialVertexesInGroup(targetMtrl, opts) {
|
|
642
|
+
const vesList = calcMaterialVertexesQueueInGroup(targetMtrl, opts);
|
|
785
643
|
const ves = vesList.pop();
|
|
786
644
|
return ves || null;
|
|
787
645
|
}
|
|
788
|
-
function
|
|
646
|
+
function calcViewMaterialSize(size, opts) {
|
|
789
647
|
const { viewScaleInfo } = opts;
|
|
790
|
-
const { x: x2, y: y2,
|
|
791
|
-
const { scale, offsetTop, offsetLeft } = viewScaleInfo;
|
|
648
|
+
const { id: id2, x: x2, y: y2, width: width2, height: height2, angle: angle2 } = size;
|
|
649
|
+
const { scale = 1, offsetTop = 0, offsetLeft = 0 } = viewScaleInfo;
|
|
792
650
|
const newSize = {
|
|
651
|
+
id: id2,
|
|
793
652
|
x: x2 * scale + offsetLeft,
|
|
794
653
|
y: y2 * scale + offsetTop,
|
|
795
|
-
|
|
796
|
-
|
|
654
|
+
width: width2 * scale,
|
|
655
|
+
height: height2 * scale,
|
|
797
656
|
angle: angle2
|
|
798
657
|
};
|
|
799
658
|
return newSize;
|
|
800
659
|
}
|
|
801
|
-
function
|
|
660
|
+
function calcViewPoint(size, opts) {
|
|
802
661
|
const { viewScaleInfo } = opts;
|
|
803
662
|
const { x: x2, y: y2 } = size;
|
|
804
663
|
const { scale, offsetTop, offsetLeft } = viewScaleInfo;
|
|
@@ -808,11 +667,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
808
667
|
};
|
|
809
668
|
return newSize;
|
|
810
669
|
}
|
|
811
|
-
function
|
|
812
|
-
const { context2d: ctx,
|
|
813
|
-
const { angle: angle2 = 0 } =
|
|
814
|
-
const { x: x2, y: y2,
|
|
815
|
-
const vertexes =
|
|
670
|
+
function isViewPointInMaterial(p, opts) {
|
|
671
|
+
const { context2d: ctx, material: mtrl, viewScaleInfo } = opts;
|
|
672
|
+
const { angle: angle2 = 0 } = mtrl;
|
|
673
|
+
const { x: x2, y: y2, width: width2, height: height2 } = calcViewMaterialSize(mtrl, { viewScaleInfo });
|
|
674
|
+
const vertexes = rotateMaterialVertexes({ x: x2, y: y2, width: width2, height: height2, angle: angle2 });
|
|
816
675
|
if (vertexes.length >= 2) {
|
|
817
676
|
ctx.beginPath();
|
|
818
677
|
ctx.moveTo(vertexes[0].x, vertexes[0].y);
|
|
@@ -826,15 +685,14 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
826
685
|
}
|
|
827
686
|
return false;
|
|
828
687
|
}
|
|
829
|
-
function
|
|
830
|
-
var _a, _b, _c;
|
|
688
|
+
function getViewPointAtMaterial(p, opts) {
|
|
831
689
|
const { context2d: ctx, data: data2, viewScaleInfo, groupQueue } = opts;
|
|
832
690
|
const result = {
|
|
833
691
|
index: -1,
|
|
834
|
-
|
|
692
|
+
material: null,
|
|
835
693
|
groupQueueIndex: -1
|
|
836
694
|
};
|
|
837
|
-
if (groupQueue && Array.isArray(groupQueue) &&
|
|
695
|
+
if (groupQueue && Array.isArray(groupQueue) && groupQueue?.length > 0) {
|
|
838
696
|
for (let gIdx = groupQueue.length - 1; gIdx >= 0; gIdx--) {
|
|
839
697
|
let totalX = 0;
|
|
840
698
|
let totalY = 0;
|
|
@@ -845,22 +703,22 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
845
703
|
totalAngle += groupQueue[i].angle || 0;
|
|
846
704
|
}
|
|
847
705
|
const lastGroup = groupQueue[gIdx];
|
|
848
|
-
if (lastGroup && lastGroup.type === "group" && Array.isArray(
|
|
849
|
-
for (let i = 0; i < lastGroup.
|
|
850
|
-
const child = lastGroup.
|
|
851
|
-
if (
|
|
706
|
+
if (lastGroup && lastGroup.type === "group" && Array.isArray(lastGroup?.children)) {
|
|
707
|
+
for (let i = 0; i < lastGroup.children.length; i++) {
|
|
708
|
+
const child = lastGroup.children[i];
|
|
709
|
+
if (child?.operations?.invisible === true) {
|
|
852
710
|
continue;
|
|
853
711
|
}
|
|
854
712
|
if (child) {
|
|
855
|
-
const
|
|
713
|
+
const mtrlSize = {
|
|
856
714
|
x: totalX + child.x,
|
|
857
715
|
y: totalY + child.y,
|
|
858
|
-
|
|
859
|
-
|
|
716
|
+
width: child.width,
|
|
717
|
+
height: child.height,
|
|
860
718
|
angle: totalAngle + (child.angle || 0)
|
|
861
719
|
};
|
|
862
|
-
if (
|
|
863
|
-
result.
|
|
720
|
+
if (isViewPointInMaterial(p, { context2d: ctx, material: mtrlSize, viewScaleInfo })) {
|
|
721
|
+
result.material = child;
|
|
864
722
|
if (gIdx < groupQueue.length - 1 || child.type !== "group") {
|
|
865
723
|
result.groupQueueIndex = gIdx;
|
|
866
724
|
}
|
|
@@ -871,30 +729,30 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
871
729
|
}
|
|
872
730
|
}
|
|
873
731
|
}
|
|
874
|
-
if (result.
|
|
732
|
+
if (result.material) {
|
|
875
733
|
break;
|
|
876
734
|
}
|
|
877
735
|
}
|
|
878
736
|
}
|
|
879
|
-
if (result.
|
|
737
|
+
if (result.material) {
|
|
880
738
|
return result;
|
|
881
739
|
}
|
|
882
|
-
for (let i = data2.
|
|
883
|
-
const
|
|
884
|
-
if (
|
|
740
|
+
for (let i = data2.materials.length - 1; i >= 0; i--) {
|
|
741
|
+
const mtrl = data2.materials[i];
|
|
742
|
+
if (mtrl?.operations?.invisible === true) {
|
|
885
743
|
continue;
|
|
886
744
|
}
|
|
887
|
-
if (
|
|
745
|
+
if (isViewPointInMaterial(p, { context2d: ctx, material: mtrl, viewScaleInfo })) {
|
|
888
746
|
result.index = i;
|
|
889
|
-
result.
|
|
747
|
+
result.material = mtrl;
|
|
890
748
|
break;
|
|
891
749
|
}
|
|
892
750
|
}
|
|
893
751
|
return result;
|
|
894
752
|
}
|
|
895
|
-
function
|
|
753
|
+
function calcMaterialBoundingInfo(mtrlSize, opts) {
|
|
896
754
|
const { groupQueue } = opts;
|
|
897
|
-
const vertexes =
|
|
755
|
+
const vertexes = calcMaterialVertexesInGroup(mtrlSize, { groupQueue });
|
|
898
756
|
const top = getCenterFromTwoPoints(vertexes[0], vertexes[1]);
|
|
899
757
|
const right = getCenterFromTwoPoints(vertexes[1], vertexes[2]);
|
|
900
758
|
const bottom = getCenterFromTwoPoints(vertexes[2], vertexes[3]);
|
|
@@ -911,7 +769,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
911
769
|
x: (maxX + minX) / 2,
|
|
912
770
|
y: (maxY + minY) / 2
|
|
913
771
|
};
|
|
914
|
-
const
|
|
772
|
+
const boundingBox = {
|
|
915
773
|
center,
|
|
916
774
|
topLeft,
|
|
917
775
|
topRight,
|
|
@@ -922,14 +780,34 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
922
780
|
left,
|
|
923
781
|
bottom
|
|
924
782
|
};
|
|
925
|
-
return
|
|
926
|
-
}
|
|
927
|
-
function
|
|
928
|
-
const rangeMaxX = Math.max(
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
783
|
+
return boundingBox;
|
|
784
|
+
}
|
|
785
|
+
function boundingInfoToRangeBoundingInfo(boundingInfo) {
|
|
786
|
+
const rangeMaxX = Math.max(
|
|
787
|
+
boundingInfo.topLeft.x,
|
|
788
|
+
boundingInfo.topRight.x,
|
|
789
|
+
boundingInfo.bottomRight.x,
|
|
790
|
+
boundingInfo.bottomLeft.x
|
|
791
|
+
);
|
|
792
|
+
const rangeMaxY = Math.max(
|
|
793
|
+
boundingInfo.topLeft.y,
|
|
794
|
+
boundingInfo.topRight.y,
|
|
795
|
+
boundingInfo.bottomRight.y,
|
|
796
|
+
boundingInfo.bottomLeft.y
|
|
797
|
+
);
|
|
798
|
+
const rangeMinX = Math.min(
|
|
799
|
+
boundingInfo.topLeft.x,
|
|
800
|
+
boundingInfo.topRight.x,
|
|
801
|
+
boundingInfo.bottomRight.x,
|
|
802
|
+
boundingInfo.bottomLeft.x
|
|
803
|
+
);
|
|
804
|
+
const rangeMinY = Math.min(
|
|
805
|
+
boundingInfo.topLeft.y,
|
|
806
|
+
boundingInfo.topRight.y,
|
|
807
|
+
boundingInfo.bottomRight.y,
|
|
808
|
+
boundingInfo.bottomLeft.y
|
|
809
|
+
);
|
|
810
|
+
const rangeCenter = { x: boundingInfo.center.x, y: boundingInfo.center.y };
|
|
933
811
|
const rangeTopLeft = { x: rangeMinX, y: rangeMinY };
|
|
934
812
|
const rangeTopRight = { x: rangeMaxX, y: rangeMinY };
|
|
935
813
|
const rangeBottomRight = { x: rangeMaxX, y: rangeMaxY };
|
|
@@ -938,7 +816,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
938
816
|
const rangeBottom = getCenterFromTwoPoints(rangeBottomLeft, rangeBottomRight);
|
|
939
817
|
const rangeLeft = getCenterFromTwoPoints(rangeTopLeft, rangeBottomLeft);
|
|
940
818
|
const rangeRight = getCenterFromTwoPoints(rangeTopRight, rangeBottomRight);
|
|
941
|
-
const
|
|
819
|
+
const rangeBoundingInfo = {
|
|
942
820
|
center: rangeCenter,
|
|
943
821
|
topLeft: rangeTopLeft,
|
|
944
822
|
topRight: rangeTopRight,
|
|
@@ -949,114 +827,445 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
949
827
|
left: rangeLeft,
|
|
950
828
|
bottom: rangeBottom
|
|
951
829
|
};
|
|
952
|
-
return
|
|
830
|
+
return rangeBoundingInfo;
|
|
953
831
|
}
|
|
954
|
-
function
|
|
832
|
+
function convertPathCommandsToStr(commands) {
|
|
955
833
|
let path = "";
|
|
956
834
|
commands.forEach((item) => {
|
|
957
|
-
path += item.type + item.params
|
|
835
|
+
path += item.type + item.params?.join?.(" ");
|
|
958
836
|
});
|
|
959
837
|
return path;
|
|
960
838
|
}
|
|
961
|
-
|
|
839
|
+
const defaultText = "Text";
|
|
840
|
+
const defaultFill = "#787878";
|
|
841
|
+
const defaultStroke = "#525252";
|
|
842
|
+
const defaultImageSlotSVG = `<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200" fill="${defaultFill}"><path d="M928 160H96c-17.7 0-32 14.3-32 32v640c0 17.7 14.3 32 32 32h832c17.7 0 32-14.3 32-32V192c0-17.7-14.3-32-32-32zM338 304c35.3 0 64 28.7 64 64s-28.7 64-64 64-64-28.7-64-64 28.7-64 64-64z m513.9 437.1c-1.4 1.2-3.3 1.9-5.2 1.9H177.2c-4.4 0-8-3.6-8-8 0-1.9 0.7-3.7 1.9-5.2l170.3-202c2.8-3.4 7.9-3.8 11.3-1 0.3 0.3 0.7 0.6 1 1l99.4 118 158.1-187.5c2.8-3.4 7.9-3.8 11.3-1 0.3 0.3 0.7 0.6 1 1l229.6 271.6c2.6 3.3 2.2 8.4-1.2 11.2z" ></path></svg>`;
|
|
843
|
+
const defaultImageHref = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(defaultImageSlotSVG)}`;
|
|
844
|
+
function getDefaultMaterialAttributes() {
|
|
962
845
|
const config = {
|
|
963
|
-
|
|
964
|
-
borderWidth: 0,
|
|
965
|
-
borderColor: "#000000",
|
|
966
|
-
shadowColor: "#000000",
|
|
967
|
-
borderRadius: 0,
|
|
968
|
-
borderDash: [],
|
|
969
|
-
shadowOffsetX: 0,
|
|
970
|
-
shadowOffsetY: 0,
|
|
971
|
-
shadowBlur: 0,
|
|
846
|
+
// Transform and display attributes
|
|
972
847
|
opacity: 1,
|
|
973
|
-
|
|
848
|
+
display: "inline",
|
|
849
|
+
visibility: "visible",
|
|
850
|
+
overflow: "visible",
|
|
851
|
+
// Fill attributes
|
|
852
|
+
fill: defaultFill,
|
|
853
|
+
fillOpacity: 1,
|
|
854
|
+
fillRule: "nonzero",
|
|
855
|
+
// Stroke attributes
|
|
856
|
+
stroke: defaultStroke,
|
|
857
|
+
strokeWidth: 0,
|
|
858
|
+
strokeOpacity: 1,
|
|
859
|
+
strokeLinecap: "butt",
|
|
860
|
+
strokeLinejoin: "miter",
|
|
861
|
+
strokeDasharray: [],
|
|
862
|
+
strokeDashoffset: 0,
|
|
863
|
+
strokeMiterlimit: 0,
|
|
864
|
+
// Text attributes
|
|
865
|
+
text: defaultText,
|
|
866
|
+
fontSize: 12,
|
|
867
|
+
// TODO
|
|
868
|
+
fontFamily: "system-ui",
|
|
869
|
+
fontWeight: "normal",
|
|
870
|
+
fontStyle: "normal",
|
|
871
|
+
textAnchor: "start",
|
|
872
|
+
textDecoration: "none",
|
|
873
|
+
letterSpacing: "normal",
|
|
874
|
+
wordSpacing: "normal",
|
|
875
|
+
writingMode: "horizontal-tb",
|
|
974
876
|
textAlign: "left",
|
|
975
877
|
verticalAlign: "top",
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
fontWeight: 400,
|
|
979
|
-
minInlineSize: "auto",
|
|
980
|
-
wordBreak: "break-all",
|
|
981
|
-
overflow: "hidden"
|
|
878
|
+
// Image attributes
|
|
879
|
+
href: defaultImageHref
|
|
982
880
|
};
|
|
983
881
|
return config;
|
|
984
882
|
}
|
|
985
|
-
const defaultElemConfig$1 = getDefaultElementDetailConfig();
|
|
986
|
-
function calcViewBoxSize(viewElem, opts) {
|
|
987
|
-
const { viewScaleInfo } = opts;
|
|
988
|
-
const { scale } = viewScaleInfo;
|
|
989
|
-
let { borderRadius: borderRadius2 } = viewElem.detail;
|
|
990
|
-
const { borderDash } = viewElem.detail;
|
|
991
|
-
const hasBorderDash = Array.isArray(borderDash) && borderDash.length > 0;
|
|
992
|
-
const { boxSizing = defaultElemConfig$1.boxSizing, borderWidth: borderWidth2 } = viewElem.detail;
|
|
993
|
-
if (Array.isArray(borderWidth2)) {
|
|
994
|
-
borderRadius2 = 0;
|
|
995
|
-
}
|
|
996
|
-
let { x: x2, y: y2, w: w2, h: h2 } = viewElem;
|
|
997
|
-
let radiusList = [0, 0, 0, 0];
|
|
998
|
-
if (typeof borderRadius2 === "number") {
|
|
999
|
-
const br = borderRadius2 * scale;
|
|
1000
|
-
radiusList = [br, br, br, br];
|
|
1001
|
-
} else if (Array.isArray(borderRadius2) && (borderRadius2 === null || borderRadius2 === void 0 ? void 0 : borderRadius2.length) === 4) {
|
|
1002
|
-
radiusList = [borderRadius2[0] * scale, borderRadius2[1] * scale, borderRadius2[2] * scale, borderRadius2[3] * scale];
|
|
1003
|
-
}
|
|
1004
|
-
let bw = 0;
|
|
1005
|
-
if (typeof borderWidth2 === "number") {
|
|
1006
|
-
bw = (borderWidth2 || 0) * scale;
|
|
1007
|
-
}
|
|
1008
|
-
if (boxSizing === "border-box" && !hasBorderDash) {
|
|
1009
|
-
x2 = viewElem.x + bw / 2;
|
|
1010
|
-
y2 = viewElem.y + bw / 2;
|
|
1011
|
-
w2 = viewElem.w - bw;
|
|
1012
|
-
h2 = viewElem.h - bw;
|
|
1013
|
-
} else if (boxSizing === "content-box") {
|
|
1014
|
-
x2 = viewElem.x - bw / 2;
|
|
1015
|
-
y2 = viewElem.y - bw / 2;
|
|
1016
|
-
w2 = viewElem.w + bw;
|
|
1017
|
-
h2 = viewElem.h + bw;
|
|
1018
|
-
} else {
|
|
1019
|
-
x2 = viewElem.x;
|
|
1020
|
-
y2 = viewElem.y;
|
|
1021
|
-
w2 = viewElem.w;
|
|
1022
|
-
h2 = viewElem.h;
|
|
1023
|
-
}
|
|
1024
|
-
w2 = Math.max(w2, 1);
|
|
1025
|
-
h2 = Math.max(h2, 1);
|
|
1026
|
-
radiusList = radiusList.map((r) => {
|
|
1027
|
-
return Math.min(r, w2 / 2, h2 / 2);
|
|
1028
|
-
});
|
|
1029
|
-
return {
|
|
1030
|
-
x: x2,
|
|
1031
|
-
y: y2,
|
|
1032
|
-
w: w2,
|
|
1033
|
-
h: h2,
|
|
1034
|
-
radiusList
|
|
1035
|
-
};
|
|
1036
|
-
}
|
|
1037
883
|
const baseFontFamilyList = ["-apple-system", '"system-ui"', ' "Segoe UI"', " Roboto", '"Helvetica Neue"', "Arial", '"Noto Sans"', " sans-serif"];
|
|
1038
884
|
function enhanceFontFamliy(fontFamily2) {
|
|
1039
885
|
return [fontFamily2, ...baseFontFamilyList].join(", ");
|
|
1040
886
|
}
|
|
1041
|
-
(
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
887
|
+
const id = () => Math.random().toString(36).substring(2);
|
|
888
|
+
function createId() {
|
|
889
|
+
return `${id()}${id()}`.substring(0, 16);
|
|
890
|
+
}
|
|
891
|
+
function shiftPathCommand(command, x2, y2) {
|
|
892
|
+
const { type: type2 } = command;
|
|
893
|
+
const params = [...command.params];
|
|
894
|
+
const id2 = command.id;
|
|
895
|
+
let anchorInfo = { id: id2 };
|
|
896
|
+
if (command.start && command.end) {
|
|
897
|
+
const start = { ...command.start };
|
|
898
|
+
const end = { ...command.end };
|
|
899
|
+
start.x += x2;
|
|
900
|
+
start.y += y2;
|
|
901
|
+
end.x += x2;
|
|
902
|
+
end.y += y2;
|
|
903
|
+
anchorInfo = { id: id2, start, end };
|
|
904
|
+
}
|
|
905
|
+
switch (type2) {
|
|
906
|
+
// MoveTo: Apply offset to both coordinates
|
|
907
|
+
case "M": {
|
|
908
|
+
params[0] += x2;
|
|
909
|
+
params[1] += y2;
|
|
910
|
+
return { type: type2, params, ...anchorInfo };
|
|
911
|
+
}
|
|
912
|
+
// LineTo: Apply offset to both coordinates
|
|
913
|
+
case "L": {
|
|
914
|
+
params[0] += x2;
|
|
915
|
+
params[1] += y2;
|
|
916
|
+
return { type: type2, params, ...anchorInfo };
|
|
917
|
+
}
|
|
918
|
+
// Horizontal Line: Only apply x offset
|
|
919
|
+
case "H": {
|
|
920
|
+
params[0] += x2;
|
|
921
|
+
return { type: type2, params, ...anchorInfo };
|
|
922
|
+
}
|
|
923
|
+
// Vertical Line: Only apply y offset
|
|
924
|
+
case "V": {
|
|
925
|
+
params[0] += y2;
|
|
926
|
+
return { type: type2, params, ...anchorInfo };
|
|
927
|
+
}
|
|
928
|
+
// Cubic Bezier: Offset all control points and endpoint
|
|
929
|
+
case "C": {
|
|
930
|
+
params[0] += x2;
|
|
931
|
+
params[1] += y2;
|
|
932
|
+
params[2] += x2;
|
|
933
|
+
params[3] += y2;
|
|
934
|
+
params[4] += x2;
|
|
935
|
+
params[5] += y2;
|
|
936
|
+
return { type: type2, params, ...anchorInfo };
|
|
937
|
+
}
|
|
938
|
+
case "S": {
|
|
939
|
+
params[0] += x2;
|
|
940
|
+
params[1] += y2;
|
|
941
|
+
params[2] += x2;
|
|
942
|
+
params[3] += y2;
|
|
943
|
+
return { type: type2, params, ...anchorInfo };
|
|
944
|
+
}
|
|
945
|
+
// Quadratic Bezier: Offset both control point and endpoint
|
|
946
|
+
case "Q": {
|
|
947
|
+
params[0] += x2;
|
|
948
|
+
params[1] += y2;
|
|
949
|
+
params[2] += x2;
|
|
950
|
+
params[3] += y2;
|
|
951
|
+
return { type: type2, params, ...anchorInfo };
|
|
952
|
+
}
|
|
953
|
+
case "T": {
|
|
954
|
+
params[0] += x2;
|
|
955
|
+
params[1] += y2;
|
|
956
|
+
return { type: type2, params, ...anchorInfo };
|
|
957
|
+
}
|
|
958
|
+
// Arc: Only offset endpoint (radius/rotation remain unchanged)
|
|
959
|
+
case "A": {
|
|
960
|
+
params[5] += x2;
|
|
961
|
+
params[6] += y2;
|
|
962
|
+
return { type: type2, params, ...anchorInfo };
|
|
963
|
+
}
|
|
964
|
+
// ClosePath: No coordinates to modify
|
|
965
|
+
case "Z": {
|
|
966
|
+
return { type: type2, params, ...anchorInfo };
|
|
967
|
+
}
|
|
968
|
+
// Default: Return original command if unsupported
|
|
969
|
+
default: {
|
|
970
|
+
return { type: type2, params, ...anchorInfo };
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
function shiftPathCommands(commands, x2, y2) {
|
|
975
|
+
const cmds = [];
|
|
976
|
+
commands.forEach((command) => {
|
|
977
|
+
const cmd = shiftPathCommand(command, x2, y2);
|
|
978
|
+
cmds.push(cmd);
|
|
979
|
+
});
|
|
980
|
+
return cmds;
|
|
981
|
+
}
|
|
982
|
+
function scalePathCommands(path, scaleX, scaleY) {
|
|
983
|
+
return path.map((cmd) => {
|
|
984
|
+
const { id: id2, type: type2, params } = cmd;
|
|
985
|
+
const newParams = [];
|
|
986
|
+
let anchorInfo = { id: id2 };
|
|
987
|
+
if (cmd.start && cmd.end) {
|
|
988
|
+
const start = { ...cmd.start };
|
|
989
|
+
const end = { ...cmd.end };
|
|
990
|
+
start.x *= scaleX;
|
|
991
|
+
start.y *= scaleY;
|
|
992
|
+
end.x *= scaleX;
|
|
993
|
+
end.y *= scaleY;
|
|
994
|
+
anchorInfo = { id: id2, start, end };
|
|
995
|
+
}
|
|
996
|
+
switch (type2.toUpperCase()) {
|
|
997
|
+
// MoveTo, LineTo, and Smooth Quadratic Bezier Curve
|
|
998
|
+
case "M":
|
|
999
|
+
case "L":
|
|
1000
|
+
case "T":
|
|
1001
|
+
for (let i = 0; i < params.length; i += 2) {
|
|
1002
|
+
newParams.push(params[i] * scaleX, params[i + 1] * scaleY);
|
|
1003
|
+
}
|
|
1004
|
+
break;
|
|
1005
|
+
// Cubic Bezier Curve
|
|
1006
|
+
case "C":
|
|
1007
|
+
for (let i = 0; i < params.length; i += 6) {
|
|
1008
|
+
newParams.push(
|
|
1009
|
+
params[i] * scaleX,
|
|
1010
|
+
params[i + 1] * scaleY,
|
|
1011
|
+
params[i + 2] * scaleX,
|
|
1012
|
+
params[i + 3] * scaleY,
|
|
1013
|
+
params[i + 4] * scaleX,
|
|
1014
|
+
params[i + 5] * scaleY
|
|
1015
|
+
);
|
|
1016
|
+
}
|
|
1017
|
+
break;
|
|
1018
|
+
// Smooth Cubic Bezier Curve
|
|
1019
|
+
case "S":
|
|
1020
|
+
for (let i = 0; i < params.length; i += 4) {
|
|
1021
|
+
newParams.push(params[i] * scaleX, params[i + 1] * scaleY, params[i + 2] * scaleX, params[i + 3] * scaleY);
|
|
1022
|
+
}
|
|
1023
|
+
break;
|
|
1024
|
+
// Quadratic Bezier Curve
|
|
1025
|
+
case "Q":
|
|
1026
|
+
for (let i = 0; i < params.length; i += 4) {
|
|
1027
|
+
newParams.push(params[i] * scaleX, params[i + 1] * scaleY, params[i + 2] * scaleX, params[i + 3] * scaleY);
|
|
1028
|
+
}
|
|
1029
|
+
break;
|
|
1030
|
+
// Horizontal Line
|
|
1031
|
+
case "H":
|
|
1032
|
+
params.forEach((val) => newParams.push(val * scaleX));
|
|
1033
|
+
break;
|
|
1034
|
+
// Vertical Line
|
|
1035
|
+
case "V":
|
|
1036
|
+
params.forEach((val) => newParams.push(val * scaleY));
|
|
1037
|
+
break;
|
|
1038
|
+
// Elliptical Arc
|
|
1039
|
+
case "A":
|
|
1040
|
+
for (let i = 0; i < params.length; i += 7) {
|
|
1041
|
+
newParams.push(
|
|
1042
|
+
params[i] * scaleX,
|
|
1043
|
+
// rx
|
|
1044
|
+
params[i + 1] * scaleY,
|
|
1045
|
+
// ry
|
|
1046
|
+
params[i + 2],
|
|
1047
|
+
// x-axis-rotation
|
|
1048
|
+
params[i + 3],
|
|
1049
|
+
// large-arc-flag
|
|
1050
|
+
params[i + 4],
|
|
1051
|
+
// sweep-flag
|
|
1052
|
+
params[i + 5] * scaleX,
|
|
1053
|
+
// x
|
|
1054
|
+
params[i + 6] * scaleY
|
|
1055
|
+
// y
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1058
|
+
break;
|
|
1059
|
+
// Relative coordinate commands
|
|
1060
|
+
case "M":
|
|
1061
|
+
case "L":
|
|
1062
|
+
case "C":
|
|
1063
|
+
case "S":
|
|
1064
|
+
case "Q":
|
|
1065
|
+
case "T":
|
|
1066
|
+
case "A":
|
|
1067
|
+
case "H":
|
|
1068
|
+
case "V":
|
|
1069
|
+
for (let i = 0; i < params.length; i++) {
|
|
1070
|
+
const isXParam = type2 === "a" && (i % 7 === 0 || i % 7 === 5) || // rx and x in arcs
|
|
1071
|
+
type2 === "h" || // horizontal moves
|
|
1072
|
+
type2 !== "v" && i % 2 === 0;
|
|
1073
|
+
newParams.push(params[i] * (isXParam ? scaleX : scaleY));
|
|
1074
|
+
}
|
|
1075
|
+
break;
|
|
1076
|
+
// ClosePath command and unknown commands
|
|
1077
|
+
default:
|
|
1078
|
+
return { type: type2, params: [...params], ...anchorInfo };
|
|
1079
|
+
}
|
|
1080
|
+
return { type: type2, params: newParams, ...anchorInfo };
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
function convertPathCommandsToACLMZ(commands) {
|
|
1084
|
+
const output = [];
|
|
1085
|
+
let currentPoint = { x: 0, y: 0 };
|
|
1086
|
+
let startPoint = { x: 0, y: 0 };
|
|
1087
|
+
let prevControlPoint = null;
|
|
1088
|
+
for (const command of commands) {
|
|
1089
|
+
const type2 = command.type;
|
|
1090
|
+
const params = command.params;
|
|
1091
|
+
const isRelative = type2 === type2.toLowerCase();
|
|
1092
|
+
const absCommand = type2.toUpperCase();
|
|
1093
|
+
const id2 = command.id;
|
|
1094
|
+
switch (absCommand) {
|
|
1095
|
+
case "M": {
|
|
1096
|
+
const [x2, y2] = params;
|
|
1097
|
+
const point = isRelative ? { x: currentPoint.x + x2, y: currentPoint.y + y2 } : { x: x2, y: y2 };
|
|
1098
|
+
output.push({ id: id2, type: "M", params: [point.x, point.y], start: { x: x2, y: y2 }, end: { x: x2, y: y2 } });
|
|
1099
|
+
currentPoint = point;
|
|
1100
|
+
startPoint = point;
|
|
1101
|
+
prevControlPoint = null;
|
|
1102
|
+
break;
|
|
1103
|
+
}
|
|
1104
|
+
case "L": {
|
|
1105
|
+
const [x2, y2] = params;
|
|
1106
|
+
const point = isRelative ? { x: currentPoint.x + x2, y: currentPoint.y + y2 } : { x: x2, y: y2 };
|
|
1107
|
+
output.push({
|
|
1108
|
+
id: id2,
|
|
1109
|
+
type: "L",
|
|
1110
|
+
params: [point.x, point.y],
|
|
1111
|
+
start: { ...currentPoint },
|
|
1112
|
+
end: { ...point }
|
|
1113
|
+
});
|
|
1114
|
+
currentPoint = point;
|
|
1115
|
+
prevControlPoint = null;
|
|
1116
|
+
break;
|
|
1117
|
+
}
|
|
1118
|
+
case "H": {
|
|
1119
|
+
const [x2] = params;
|
|
1120
|
+
const point = isRelative ? { x: currentPoint.x + x2, y: currentPoint.y } : { x: x2, y: currentPoint.y };
|
|
1121
|
+
output.push({
|
|
1122
|
+
id: id2,
|
|
1123
|
+
type: "L",
|
|
1124
|
+
params: [point.x, point.y],
|
|
1125
|
+
start: { ...currentPoint },
|
|
1126
|
+
end: { ...point }
|
|
1127
|
+
});
|
|
1128
|
+
currentPoint = point;
|
|
1129
|
+
prevControlPoint = null;
|
|
1130
|
+
break;
|
|
1131
|
+
}
|
|
1132
|
+
case "V": {
|
|
1133
|
+
const [y2] = params;
|
|
1134
|
+
const point = isRelative ? { x: currentPoint.x, y: currentPoint.y + y2 } : { x: currentPoint.x, y: y2 };
|
|
1135
|
+
output.push({
|
|
1136
|
+
id: id2,
|
|
1137
|
+
type: "L",
|
|
1138
|
+
params: [point.x, point.y],
|
|
1139
|
+
start: { ...currentPoint },
|
|
1140
|
+
end: { ...point }
|
|
1141
|
+
});
|
|
1142
|
+
currentPoint = point;
|
|
1143
|
+
prevControlPoint = null;
|
|
1144
|
+
break;
|
|
1145
|
+
}
|
|
1146
|
+
case "C": {
|
|
1147
|
+
const [x1, y1, x2, y2, x3, y3] = params;
|
|
1148
|
+
const c1 = isRelative ? { x: currentPoint.x + x1, y: currentPoint.y + y1 } : { x: x1, y: y1 };
|
|
1149
|
+
const c2 = isRelative ? { x: currentPoint.x + x2, y: currentPoint.y + y2 } : { x: x2, y: y2 };
|
|
1150
|
+
const point = isRelative ? { x: currentPoint.x + x3, y: currentPoint.y + y3 } : { x: x3, y: y3 };
|
|
1151
|
+
output.push({
|
|
1152
|
+
id: id2,
|
|
1153
|
+
type: "C",
|
|
1154
|
+
params: [c1.x, c1.y, c2.x, c2.y, point.x, point.y],
|
|
1155
|
+
start: { ...currentPoint },
|
|
1156
|
+
end: { ...point }
|
|
1157
|
+
});
|
|
1158
|
+
currentPoint = point;
|
|
1159
|
+
prevControlPoint = c2;
|
|
1160
|
+
break;
|
|
1161
|
+
}
|
|
1162
|
+
case "S": {
|
|
1163
|
+
const [x2, y2, x3, y3] = params;
|
|
1164
|
+
const c1 = prevControlPoint ? {
|
|
1165
|
+
x: 2 * currentPoint.x - prevControlPoint.x,
|
|
1166
|
+
y: 2 * currentPoint.y - prevControlPoint.y
|
|
1167
|
+
} : currentPoint;
|
|
1168
|
+
const c2 = isRelative ? { x: currentPoint.x + x2, y: currentPoint.y + y2 } : { x: x2, y: y2 };
|
|
1169
|
+
const point = isRelative ? { x: currentPoint.x + x3, y: currentPoint.y + y3 } : { x: x3, y: y3 };
|
|
1170
|
+
output.push({
|
|
1171
|
+
id: id2,
|
|
1172
|
+
type: "C",
|
|
1173
|
+
params: [c1.x, c1.y, c2.x, c2.y, point.x, point.y],
|
|
1174
|
+
start: { ...currentPoint },
|
|
1175
|
+
end: { ...point }
|
|
1176
|
+
});
|
|
1177
|
+
currentPoint = point;
|
|
1178
|
+
prevControlPoint = c2;
|
|
1179
|
+
break;
|
|
1180
|
+
}
|
|
1181
|
+
case "Q": {
|
|
1182
|
+
const [x1, y1, x2, y2] = params;
|
|
1183
|
+
const cp1 = isRelative ? { x: currentPoint.x + x1, y: currentPoint.y + y1 } : { x: x1, y: y1 };
|
|
1184
|
+
const endPoint = isRelative ? { x: currentPoint.x + x2, y: currentPoint.y + y2 } : { x: x2, y: y2 };
|
|
1185
|
+
output.push({
|
|
1186
|
+
id: id2,
|
|
1187
|
+
type: "C",
|
|
1188
|
+
params: [
|
|
1189
|
+
currentPoint.x + 2 / 3 * (cp1.x - currentPoint.x),
|
|
1190
|
+
currentPoint.y + 2 / 3 * (cp1.y - currentPoint.y),
|
|
1191
|
+
endPoint.x + 2 / 3 * (cp1.x - endPoint.x),
|
|
1192
|
+
endPoint.y + 2 / 3 * (cp1.y - endPoint.y),
|
|
1193
|
+
endPoint.x,
|
|
1194
|
+
endPoint.y
|
|
1195
|
+
],
|
|
1196
|
+
start: { ...currentPoint },
|
|
1197
|
+
end: { ...endPoint }
|
|
1198
|
+
});
|
|
1199
|
+
currentPoint = endPoint;
|
|
1200
|
+
prevControlPoint = cp1;
|
|
1201
|
+
break;
|
|
1202
|
+
}
|
|
1203
|
+
case "T": {
|
|
1204
|
+
const [x2, y2] = params;
|
|
1205
|
+
const endPoint = isRelative ? { x: currentPoint.x + x2, y: currentPoint.y + y2 } : { x: x2, y: y2 };
|
|
1206
|
+
const cp1 = prevControlPoint ? {
|
|
1207
|
+
x: 2 * currentPoint.x - prevControlPoint.x,
|
|
1208
|
+
y: 2 * currentPoint.y - prevControlPoint.y
|
|
1209
|
+
} : currentPoint;
|
|
1210
|
+
output.push({
|
|
1211
|
+
id: id2,
|
|
1212
|
+
type: "C",
|
|
1213
|
+
params: [
|
|
1214
|
+
currentPoint.x + 2 / 3 * (cp1.x - currentPoint.x),
|
|
1215
|
+
currentPoint.y + 2 / 3 * (cp1.y - currentPoint.y),
|
|
1216
|
+
endPoint.x + 2 / 3 * (cp1.x - endPoint.x),
|
|
1217
|
+
endPoint.y + 2 / 3 * (cp1.y - endPoint.y),
|
|
1218
|
+
endPoint.x,
|
|
1219
|
+
endPoint.y
|
|
1220
|
+
],
|
|
1221
|
+
start: { ...currentPoint },
|
|
1222
|
+
end: { ...endPoint }
|
|
1223
|
+
});
|
|
1224
|
+
currentPoint = endPoint;
|
|
1225
|
+
prevControlPoint = cp1;
|
|
1226
|
+
break;
|
|
1227
|
+
}
|
|
1228
|
+
case "A": {
|
|
1229
|
+
const [rx, ry, rotation, largeArc, sweep, x2, y2] = params;
|
|
1230
|
+
const point = isRelative ? { x: currentPoint.x + x2, y: currentPoint.y + y2 } : { x: x2, y: y2 };
|
|
1231
|
+
output.push({
|
|
1232
|
+
id: id2,
|
|
1233
|
+
type: "A",
|
|
1234
|
+
params: [rx, ry, rotation, largeArc, sweep, point.x, point.y],
|
|
1235
|
+
start: { ...currentPoint },
|
|
1236
|
+
end: { ...point }
|
|
1237
|
+
});
|
|
1238
|
+
currentPoint = point;
|
|
1239
|
+
prevControlPoint = null;
|
|
1240
|
+
break;
|
|
1241
|
+
}
|
|
1242
|
+
case "Z": {
|
|
1243
|
+
output.push({ id: id2, type: "Z", params: [], start: { ...currentPoint }, end: { ...startPoint } });
|
|
1244
|
+
currentPoint = startPoint;
|
|
1245
|
+
prevControlPoint = null;
|
|
1246
|
+
break;
|
|
1247
|
+
}
|
|
1248
|
+
default:
|
|
1249
|
+
throw new Error(`Unsupported command: ${type2}`);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
return output;
|
|
1253
|
+
}
|
|
1254
|
+
function omit(obj, keys) {
|
|
1255
|
+
const result = { ...obj };
|
|
1256
|
+
for (const key of keys) {
|
|
1257
|
+
delete result[key];
|
|
1258
|
+
}
|
|
1259
|
+
return result;
|
|
1260
|
+
}
|
|
1261
|
+
function createColor(ctx, color2, opts) {
|
|
1053
1262
|
if (typeof color2 === "string") {
|
|
1054
1263
|
return color2;
|
|
1055
1264
|
}
|
|
1056
|
-
const {
|
|
1057
|
-
const { x: x2, y: y2 } =
|
|
1265
|
+
const { viewMaterialSize, viewScaleInfo, opacity = 1 } = opts;
|
|
1266
|
+
const { x: x2, y: y2 } = viewMaterialSize;
|
|
1058
1267
|
const { scale } = viewScaleInfo;
|
|
1059
|
-
if (
|
|
1268
|
+
if (color2?.type === "linear-gradient") {
|
|
1060
1269
|
const { start, end, stops } = color2;
|
|
1061
1270
|
const viewStart = {
|
|
1062
1271
|
x: x2 + start.x * scale,
|
|
@@ -1068,11 +1277,13 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1068
1277
|
};
|
|
1069
1278
|
const linearGradient = ctx.createLinearGradient(viewStart.x, viewStart.y, viewEnd.x, viewEnd.y);
|
|
1070
1279
|
stops.forEach((stop) => {
|
|
1071
|
-
|
|
1280
|
+
if (stop.offset >= 0 && stop.color) {
|
|
1281
|
+
linearGradient.addColorStop(stop.offset, mergeHexColorAlpha(stop.color, opacity));
|
|
1282
|
+
}
|
|
1072
1283
|
});
|
|
1073
1284
|
return linearGradient;
|
|
1074
1285
|
}
|
|
1075
|
-
if (
|
|
1286
|
+
if (color2?.type === "radial-gradient") {
|
|
1076
1287
|
const { inner, outer, stops } = color2;
|
|
1077
1288
|
const viewInner = {
|
|
1078
1289
|
x: x2 + inner.x * scale,
|
|
@@ -1084,7 +1295,14 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1084
1295
|
y: y2 + outer.y * scale,
|
|
1085
1296
|
radius: outer.radius * scale
|
|
1086
1297
|
};
|
|
1087
|
-
const radialGradient = ctx.createRadialGradient(
|
|
1298
|
+
const radialGradient = ctx.createRadialGradient(
|
|
1299
|
+
viewInner.x,
|
|
1300
|
+
viewInner.y,
|
|
1301
|
+
viewInner.radius,
|
|
1302
|
+
viewOuter.x,
|
|
1303
|
+
viewOuter.y,
|
|
1304
|
+
viewOuter.radius
|
|
1305
|
+
);
|
|
1088
1306
|
stops.forEach((stop) => {
|
|
1089
1307
|
radialGradient.addColorStop(stop.offset, mergeHexColorAlpha(stop.color, opacity));
|
|
1090
1308
|
});
|
|
@@ -1092,715 +1310,413 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1092
1310
|
}
|
|
1093
1311
|
return "#000000";
|
|
1094
1312
|
}
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
opacity
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1313
|
+
let defaultAttrs$1 = getDefaultMaterialAttributes();
|
|
1314
|
+
defaultAttrs$1 = omit(defaultAttrs$1, ["fill"]);
|
|
1315
|
+
function drawBase(ctx, mtrl, opts) {
|
|
1316
|
+
const { viewScaleInfo, viewSizeInfo, calculator } = opts;
|
|
1317
|
+
const {
|
|
1318
|
+
opacity,
|
|
1319
|
+
fill,
|
|
1320
|
+
fillOpacity,
|
|
1321
|
+
fillRule,
|
|
1322
|
+
stroke,
|
|
1323
|
+
strokeWidth: strokeWidth2,
|
|
1324
|
+
strokeOpacity,
|
|
1325
|
+
strokeLinecap,
|
|
1326
|
+
strokeLinejoin,
|
|
1327
|
+
strokeDasharray,
|
|
1328
|
+
strokeDashoffset,
|
|
1329
|
+
strokeMiterlimit
|
|
1330
|
+
} = { ...defaultAttrs$1, ...mtrl };
|
|
1331
|
+
const { scale, offsetLeft, offsetTop } = viewScaleInfo;
|
|
1332
|
+
const { devicePixelRatio } = viewSizeInfo;
|
|
1333
|
+
const virtualAttributes = calculator.getVirtualItem(mtrl.id);
|
|
1334
|
+
const { commands, worldCenter } = virtualAttributes;
|
|
1335
|
+
const { width: width2, height: height2 } = mtrl;
|
|
1336
|
+
let cmds = commands;
|
|
1337
|
+
cmds = scalePathCommands(cmds, scale, scale);
|
|
1338
|
+
cmds = shiftPathCommands(
|
|
1339
|
+
cmds,
|
|
1340
|
+
(offsetLeft + (worldCenter.x - width2 / 2) * scale) * devicePixelRatio,
|
|
1341
|
+
(offsetTop + (worldCenter.y - height2 / 2) * scale) * devicePixelRatio
|
|
1342
|
+
);
|
|
1343
|
+
const originGlobalAlpha = ctx.globalAlpha;
|
|
1344
|
+
const pathStr = convertPathCommandsToStr(cmds);
|
|
1345
|
+
const path2d = new Path2D(pathStr);
|
|
1346
|
+
drawShadow(ctx, mtrl, { ...opts, path2d });
|
|
1347
|
+
drawClipPath(ctx, mtrl, {
|
|
1348
|
+
path2d,
|
|
1349
|
+
viewScaleInfo,
|
|
1350
|
+
viewSizeInfo,
|
|
1351
|
+
calculator,
|
|
1352
|
+
renderContent: () => {
|
|
1353
|
+
if (fill) {
|
|
1354
|
+
const viewMaterialSize = calcViewMaterialSize(mtrl, { viewScaleInfo });
|
|
1355
|
+
if (typeof fillOpacity === "number" && fillOpacity > 0) {
|
|
1356
|
+
ctx.globalAlpha = originGlobalAlpha * fillOpacity * opacity;
|
|
1357
|
+
}
|
|
1358
|
+
ctx.fillStyle = createColor(ctx, fill, { viewMaterialSize, viewScaleInfo, opacity: mtrl.opacity || 1 });
|
|
1359
|
+
ctx.fill(path2d, fillRule);
|
|
1360
|
+
ctx.globalAlpha = originGlobalAlpha;
|
|
1123
1361
|
}
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
function drawClipPath(ctx, viewElem, opts) {
|
|
1138
|
-
const { renderContent, originElem, calcElemSize, viewSizeInfo } = opts;
|
|
1139
|
-
const totalScale = viewSizeInfo.devicePixelRatio;
|
|
1140
|
-
const { clipPath } = (originElem == null ? void 0 : originElem.detail) || {};
|
|
1141
|
-
if (clipPath && calcElemSize && clipPath.commands) {
|
|
1142
|
-
const { x: x2, y: y2, w: w2, h: h2 } = calcElemSize;
|
|
1143
|
-
const { originW, originH, originX, originY } = clipPath;
|
|
1144
|
-
const scaleW = w2 / originW;
|
|
1145
|
-
const scaleH = h2 / originH;
|
|
1146
|
-
const viewOriginX = originX * scaleW;
|
|
1147
|
-
const viewOriginY = originY * scaleH;
|
|
1148
|
-
const internalX = x2 - viewOriginX;
|
|
1149
|
-
const internalY = y2 - viewOriginY;
|
|
1150
|
-
ctx.save();
|
|
1151
|
-
ctx.translate(internalX, internalY);
|
|
1152
|
-
ctx.scale(totalScale * scaleW, totalScale * scaleH);
|
|
1153
|
-
const pathStr = generateSVGPath(clipPath.commands || []);
|
|
1154
|
-
const path2d = new Path2D(pathStr);
|
|
1155
|
-
ctx.clip(path2d, "nonzero");
|
|
1156
|
-
ctx.translate(0 - internalX, 0 - internalY);
|
|
1157
|
-
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
1158
|
-
rotateElement(ctx, { ...viewElem }, () => {
|
|
1159
|
-
renderContent == null ? void 0 : renderContent();
|
|
1160
|
-
});
|
|
1161
|
-
ctx.restore();
|
|
1162
|
-
} else {
|
|
1163
|
-
renderContent == null ? void 0 : renderContent();
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
function drawClipPathStroke(ctx, viewElem, opts) {
|
|
1167
|
-
const { renderContent, originElem, calcElemSize, viewSizeInfo, parentOpacity } = opts;
|
|
1168
|
-
const totalScale = viewSizeInfo.devicePixelRatio;
|
|
1169
|
-
const { clipPath, clipPathStrokeColor, clipPathStrokeWidth } = (originElem == null ? void 0 : originElem.detail) || {};
|
|
1170
|
-
if (clipPath && calcElemSize && clipPath.commands && typeof clipPathStrokeWidth === "number" && clipPathStrokeWidth > 0 && clipPathStrokeColor) {
|
|
1171
|
-
const { x: x2, y: y2, w: w2, h: h2 } = calcElemSize;
|
|
1172
|
-
const { originW, originH, originX, originY } = clipPath;
|
|
1173
|
-
const scaleW = w2 / originW;
|
|
1174
|
-
const scaleH = h2 / originH;
|
|
1175
|
-
const viewOriginX = originX * scaleW;
|
|
1176
|
-
const viewOriginY = originY * scaleH;
|
|
1177
|
-
const internalX = x2 - viewOriginX;
|
|
1178
|
-
const internalY = y2 - viewOriginY;
|
|
1179
|
-
ctx.save();
|
|
1180
|
-
ctx.globalAlpha = parentOpacity;
|
|
1181
|
-
ctx.translate(internalX, internalY);
|
|
1182
|
-
ctx.scale(totalScale * scaleW, totalScale * scaleH);
|
|
1183
|
-
const pathStr = generateSVGPath(clipPath.commands || []);
|
|
1184
|
-
const path2d = new Path2D(pathStr);
|
|
1185
|
-
ctx.strokeStyle = clipPathStrokeColor;
|
|
1186
|
-
ctx.lineWidth = clipPathStrokeWidth;
|
|
1187
|
-
ctx.stroke(path2d);
|
|
1188
|
-
ctx.translate(0 - internalX, 0 - internalY);
|
|
1189
|
-
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
1190
|
-
rotateElement(ctx, { ...viewElem }, () => {
|
|
1191
|
-
renderContent == null ? void 0 : renderContent();
|
|
1192
|
-
});
|
|
1193
|
-
ctx.restore();
|
|
1194
|
-
} else {
|
|
1195
|
-
renderContent == null ? void 0 : renderContent();
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
function drawBoxBackground(ctx, viewElem, opts) {
|
|
1199
|
-
var _a, _b;
|
|
1200
|
-
const { pattern, viewScaleInfo, viewSizeInfo } = opts;
|
|
1201
|
-
const transform = [];
|
|
1202
|
-
if (viewElem.detail.background || pattern) {
|
|
1203
|
-
const { x: x2, y: y2, w: w2, h: h2, radiusList } = calcViewBoxSize(viewElem, {
|
|
1204
|
-
viewScaleInfo
|
|
1205
|
-
});
|
|
1206
|
-
ctx.beginPath();
|
|
1207
|
-
ctx.moveTo(x2 + radiusList[0], y2);
|
|
1208
|
-
ctx.arcTo(x2 + w2, y2, x2 + w2, y2 + h2, radiusList[1]);
|
|
1209
|
-
ctx.arcTo(x2 + w2, y2 + h2, x2, y2 + h2, radiusList[2]);
|
|
1210
|
-
ctx.arcTo(x2, y2 + h2, x2, y2, radiusList[3]);
|
|
1211
|
-
ctx.arcTo(x2, y2, x2 + w2, y2, radiusList[0]);
|
|
1212
|
-
ctx.closePath();
|
|
1213
|
-
if (typeof pattern === "string") {
|
|
1214
|
-
ctx.fillStyle = pattern;
|
|
1215
|
-
} else if (["CanvasPattern"].includes(istype.type(pattern))) {
|
|
1216
|
-
ctx.fillStyle = pattern;
|
|
1217
|
-
} else if (typeof viewElem.detail.background === "string") {
|
|
1218
|
-
ctx.fillStyle = viewElem.detail.background;
|
|
1219
|
-
} else if (((_a = viewElem.detail.background) == null ? void 0 : _a.type) === "linear-gradient") {
|
|
1220
|
-
const colorStyle = createColorStyle(ctx, viewElem.detail.background, {
|
|
1221
|
-
viewElementSize: { x: x2, y: y2, w: w2, h: h2 },
|
|
1222
|
-
viewScaleInfo,
|
|
1223
|
-
opacity: ctx.globalAlpha
|
|
1224
|
-
});
|
|
1225
|
-
ctx.fillStyle = colorStyle;
|
|
1226
|
-
} else if (((_b = viewElem.detail.background) == null ? void 0 : _b.type) === "radial-gradient") {
|
|
1227
|
-
const colorStyle = createColorStyle(ctx, viewElem.detail.background, {
|
|
1228
|
-
viewElementSize: { x: x2, y: y2, w: w2, h: h2 },
|
|
1229
|
-
viewScaleInfo,
|
|
1230
|
-
opacity: ctx.globalAlpha
|
|
1231
|
-
});
|
|
1232
|
-
ctx.fillStyle = colorStyle;
|
|
1233
|
-
if (transform && transform.length > 0) {
|
|
1234
|
-
for (let i = 0; i < (transform == null ? void 0 : transform.length); i++) {
|
|
1235
|
-
const action = transform[i];
|
|
1236
|
-
if (action.method === "translate") {
|
|
1237
|
-
ctx.translate(action.args[0] + x2, action.args[1] + y2);
|
|
1238
|
-
} else if (action.method === "rotate") {
|
|
1239
|
-
ctx.rotate(...action.args);
|
|
1240
|
-
} else if (action.method === "scale") {
|
|
1241
|
-
ctx.scale(...action.args);
|
|
1242
|
-
}
|
|
1362
|
+
if (typeof strokeWidth2 === "number" && strokeWidth2 > 0) {
|
|
1363
|
+
if (typeof strokeOpacity === "number" && strokeOpacity > 0) {
|
|
1364
|
+
ctx.globalAlpha = originGlobalAlpha * strokeOpacity * opacity;
|
|
1365
|
+
}
|
|
1366
|
+
ctx.lineCap = strokeLinecap;
|
|
1367
|
+
ctx.lineJoin = strokeLinejoin;
|
|
1368
|
+
ctx.lineDashOffset = strokeDashoffset;
|
|
1369
|
+
ctx.miterLimit = strokeMiterlimit;
|
|
1370
|
+
if (Array.isArray(strokeDasharray)) {
|
|
1371
|
+
const lineDash = strokeDasharray.map((dash) => scale * dash);
|
|
1372
|
+
ctx.setLineDash(lineDash);
|
|
1243
1373
|
}
|
|
1374
|
+
ctx.lineWidth = strokeWidth2 * scale;
|
|
1375
|
+
ctx.strokeStyle = stroke;
|
|
1376
|
+
ctx.stroke(path2d);
|
|
1377
|
+
ctx.setLineDash([]);
|
|
1378
|
+
ctx.lineCap = defaultAttrs$1.strokeLinecap;
|
|
1379
|
+
ctx.lineJoin = defaultAttrs$1.strokeLinejoin;
|
|
1380
|
+
ctx.lineDashOffset = defaultAttrs$1.strokeDashoffset;
|
|
1381
|
+
ctx.miterLimit = defaultAttrs$1.strokeMiterlimit;
|
|
1382
|
+
ctx.globalAlpha = originGlobalAlpha;
|
|
1244
1383
|
}
|
|
1245
1384
|
}
|
|
1246
|
-
|
|
1247
|
-
if (transform && transform.length > 0) {
|
|
1248
|
-
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
function drawBoxBorder(ctx, viewElem, opts) {
|
|
1253
|
-
if (viewElem.detail.borderWidth === 0) {
|
|
1254
|
-
return;
|
|
1255
|
-
}
|
|
1256
|
-
if (!isColorStr(viewElem.detail.borderColor)) {
|
|
1257
|
-
return;
|
|
1258
|
-
}
|
|
1259
|
-
const { viewScaleInfo } = opts;
|
|
1260
|
-
const { scale } = viewScaleInfo;
|
|
1261
|
-
let borderColor = defaultElemConfig.borderColor;
|
|
1262
|
-
if (isColorStr(viewElem.detail.borderColor) === true) {
|
|
1263
|
-
borderColor = viewElem.detail.borderColor;
|
|
1264
|
-
}
|
|
1265
|
-
const { borderDash, borderWidth: borderWidth2, borderRadius: borderRadius2, boxSizing = defaultElemConfig.boxSizing } = viewElem.detail;
|
|
1266
|
-
let viewBorderDash = [];
|
|
1267
|
-
if (Array.isArray(borderDash) && borderDash.length > 0) {
|
|
1268
|
-
viewBorderDash = borderDash.map((num) => Math.ceil(num * scale));
|
|
1269
|
-
}
|
|
1270
|
-
if (viewBorderDash.length > 0) {
|
|
1271
|
-
ctx.lineCap = "butt";
|
|
1272
|
-
} else {
|
|
1273
|
-
ctx.lineCap = "square";
|
|
1274
|
-
}
|
|
1275
|
-
let radiusList = [0, 0, 0, 0];
|
|
1276
|
-
if (typeof borderRadius2 === "number") {
|
|
1277
|
-
const br = borderRadius2 * scale;
|
|
1278
|
-
radiusList = [br, br, br, br];
|
|
1279
|
-
} else if (Array.isArray(borderRadius2) && (borderRadius2 == null ? void 0 : borderRadius2.length) === 4) {
|
|
1280
|
-
radiusList = [borderRadius2[0] * scale, borderRadius2[1] * scale, borderRadius2[2] * scale, borderRadius2[3] * scale];
|
|
1281
|
-
}
|
|
1282
|
-
let bw = 0;
|
|
1283
|
-
if (typeof borderWidth2 === "number") {
|
|
1284
|
-
bw = borderWidth2 || 1;
|
|
1285
|
-
}
|
|
1286
|
-
bw = bw * scale;
|
|
1287
|
-
ctx.strokeStyle = borderColor;
|
|
1288
|
-
let borderTop = 0;
|
|
1289
|
-
let borderRight = 0;
|
|
1290
|
-
let borderBottom = 0;
|
|
1291
|
-
let borderLeft = 0;
|
|
1292
|
-
if (Array.isArray(borderWidth2)) {
|
|
1293
|
-
borderTop = (borderWidth2[0] || 0) * scale;
|
|
1294
|
-
borderRight = (borderWidth2[1] || 0) * scale;
|
|
1295
|
-
borderBottom = (borderWidth2[2] || 0) * scale;
|
|
1296
|
-
borderLeft = (borderWidth2[3] || 0) * scale;
|
|
1297
|
-
}
|
|
1298
|
-
if (borderLeft || borderRight || borderTop || borderBottom) {
|
|
1299
|
-
ctx.lineCap = "butt";
|
|
1300
|
-
let { x: x2, y: y2, w: w2, h: h2 } = viewElem;
|
|
1301
|
-
if (boxSizing === "border-box") {
|
|
1302
|
-
x2 = x2 + borderLeft / 2;
|
|
1303
|
-
y2 = y2 + borderTop / 2;
|
|
1304
|
-
w2 = w2 - borderLeft / 2 - borderRight / 2;
|
|
1305
|
-
h2 = h2 - borderTop / 2 - borderBottom / 2;
|
|
1306
|
-
} else if (boxSizing === "content-box") {
|
|
1307
|
-
x2 = x2 - borderLeft / 2;
|
|
1308
|
-
y2 = y2 - borderTop / 2;
|
|
1309
|
-
w2 = w2 + borderLeft / 2 + borderRight / 2;
|
|
1310
|
-
h2 = h2 + borderTop / 2 + borderBottom / 2;
|
|
1311
|
-
} else {
|
|
1312
|
-
x2 = viewElem.x;
|
|
1313
|
-
y2 = viewElem.y;
|
|
1314
|
-
w2 = viewElem.w;
|
|
1315
|
-
h2 = viewElem.h;
|
|
1316
|
-
}
|
|
1317
|
-
if (borderTop) {
|
|
1318
|
-
ctx.beginPath();
|
|
1319
|
-
ctx.lineWidth = borderTop;
|
|
1320
|
-
ctx.moveTo(x2 - borderLeft / 2, y2);
|
|
1321
|
-
ctx.lineTo(x2 + w2 + borderRight / 2, y2);
|
|
1322
|
-
ctx.closePath();
|
|
1323
|
-
ctx.stroke();
|
|
1324
|
-
}
|
|
1325
|
-
if (borderRight) {
|
|
1326
|
-
ctx.beginPath();
|
|
1327
|
-
ctx.lineWidth = borderRight;
|
|
1328
|
-
ctx.moveTo(x2 + w2, y2 - borderTop / 2);
|
|
1329
|
-
ctx.lineTo(x2 + w2, y2 + h2 + borderBottom / 2);
|
|
1330
|
-
ctx.closePath();
|
|
1331
|
-
ctx.stroke();
|
|
1332
|
-
}
|
|
1333
|
-
if (borderBottom) {
|
|
1334
|
-
ctx.beginPath();
|
|
1335
|
-
ctx.lineWidth = borderBottom;
|
|
1336
|
-
ctx.moveTo(x2 - borderLeft / 2, y2 + h2);
|
|
1337
|
-
ctx.lineTo(x2 + w2 + borderRight / 2, y2 + h2);
|
|
1338
|
-
ctx.closePath();
|
|
1339
|
-
ctx.stroke();
|
|
1340
|
-
}
|
|
1341
|
-
if (borderLeft) {
|
|
1342
|
-
ctx.beginPath();
|
|
1343
|
-
ctx.lineWidth = borderLeft;
|
|
1344
|
-
ctx.moveTo(x2, y2 - borderTop / 2);
|
|
1345
|
-
ctx.lineTo(x2, y2 + h2 + borderBottom / 2);
|
|
1346
|
-
ctx.closePath();
|
|
1347
|
-
ctx.stroke();
|
|
1348
|
-
}
|
|
1349
|
-
} else {
|
|
1350
|
-
let { x: x2, y: y2, w: w2, h: h2 } = viewElem;
|
|
1351
|
-
if (boxSizing === "border-box") {
|
|
1352
|
-
x2 = viewElem.x + bw / 2;
|
|
1353
|
-
y2 = viewElem.y + bw / 2;
|
|
1354
|
-
w2 = viewElem.w - bw;
|
|
1355
|
-
h2 = viewElem.h - bw;
|
|
1356
|
-
} else if (boxSizing === "content-box") {
|
|
1357
|
-
x2 = viewElem.x - bw / 2;
|
|
1358
|
-
y2 = viewElem.y - bw / 2;
|
|
1359
|
-
w2 = viewElem.w + bw;
|
|
1360
|
-
h2 = viewElem.h + bw;
|
|
1361
|
-
} else {
|
|
1362
|
-
x2 = viewElem.x;
|
|
1363
|
-
y2 = viewElem.y;
|
|
1364
|
-
w2 = viewElem.w;
|
|
1365
|
-
h2 = viewElem.h;
|
|
1366
|
-
}
|
|
1367
|
-
w2 = Math.max(w2, 1);
|
|
1368
|
-
h2 = Math.max(h2, 1);
|
|
1369
|
-
radiusList = radiusList.map((r) => {
|
|
1370
|
-
return Math.min(r, w2 / 2, h2 / 2);
|
|
1371
|
-
});
|
|
1372
|
-
ctx.setLineDash(viewBorderDash);
|
|
1373
|
-
ctx.lineWidth = bw;
|
|
1374
|
-
ctx.beginPath();
|
|
1375
|
-
ctx.moveTo(x2 + radiusList[0], y2);
|
|
1376
|
-
ctx.arcTo(x2 + w2, y2, x2 + w2, y2 + h2, radiusList[1]);
|
|
1377
|
-
ctx.arcTo(x2 + w2, y2 + h2, x2, y2 + h2, radiusList[2]);
|
|
1378
|
-
ctx.arcTo(x2, y2 + h2, x2, y2, radiusList[3]);
|
|
1379
|
-
ctx.arcTo(x2, y2, x2 + w2, y2, radiusList[0]);
|
|
1380
|
-
ctx.closePath();
|
|
1381
|
-
ctx.stroke();
|
|
1382
|
-
}
|
|
1383
|
-
ctx.setLineDash([]);
|
|
1385
|
+
});
|
|
1384
1386
|
}
|
|
1385
|
-
function
|
|
1386
|
-
const { detail } =
|
|
1387
|
-
const { viewScaleInfo,
|
|
1387
|
+
function drawShadow(ctx, viewMtrl, opts) {
|
|
1388
|
+
const { ...detail } = viewMtrl;
|
|
1389
|
+
const { viewScaleInfo, viewSizeInfo, tempContext, path2d } = opts;
|
|
1390
|
+
const { width: width2, height: height2 } = viewSizeInfo;
|
|
1388
1391
|
const { shadowColor, shadowOffsetX, shadowOffsetY, shadowBlur } = detail;
|
|
1389
|
-
if (is.number(shadowBlur)) {
|
|
1392
|
+
if (is.number(shadowBlur) && shadowColor) {
|
|
1393
|
+
tempContext.clearRect(0, 0, tempContext.canvas.width, tempContext.canvas.height);
|
|
1394
|
+
tempContext.save();
|
|
1395
|
+
tempContext.shadowColor = shadowColor;
|
|
1396
|
+
tempContext.shadowOffsetX = (shadowOffsetX || 0) * viewScaleInfo.scale;
|
|
1397
|
+
tempContext.shadowOffsetY = (shadowOffsetY || 0) * viewScaleInfo.scale;
|
|
1398
|
+
tempContext.shadowBlur = (shadowBlur || 0) * viewScaleInfo.scale;
|
|
1399
|
+
tempContext.fillStyle = "#ffffff";
|
|
1400
|
+
tempContext.fill(path2d);
|
|
1401
|
+
tempContext.restore();
|
|
1402
|
+
tempContext.save();
|
|
1403
|
+
tempContext.globalCompositeOperation = "destination-out";
|
|
1404
|
+
tempContext.fillStyle = "#ffffff";
|
|
1405
|
+
tempContext.fill(path2d);
|
|
1406
|
+
tempContext.restore();
|
|
1407
|
+
ctx.drawImage(tempContext.canvas, 0, 0, width2, height2);
|
|
1408
|
+
tempContext.clearRect(0, 0, tempContext.canvas.width, tempContext.canvas.height);
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
function drawClipPath(ctx, mtrl, opts) {
|
|
1412
|
+
const { renderContent, calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
1413
|
+
if (mtrl.overflow === "hidden") {
|
|
1414
|
+
let path2d = opts.path2d;
|
|
1415
|
+
if (!path2d) {
|
|
1416
|
+
const { scale, offsetLeft, offsetTop } = viewScaleInfo;
|
|
1417
|
+
const { devicePixelRatio } = viewSizeInfo;
|
|
1418
|
+
const virtualAttributes = calculator.getVirtualItem(mtrl.id);
|
|
1419
|
+
const { commands, worldCenter } = virtualAttributes;
|
|
1420
|
+
const { width: width2, height: height2 } = mtrl;
|
|
1421
|
+
let cmds = commands;
|
|
1422
|
+
cmds = scalePathCommands(cmds, scale, scale);
|
|
1423
|
+
cmds = shiftPathCommands(
|
|
1424
|
+
cmds,
|
|
1425
|
+
(offsetLeft + (worldCenter.x - width2 / 2) * scale) * devicePixelRatio,
|
|
1426
|
+
(offsetTop + (worldCenter.y - height2 / 2) * scale) * devicePixelRatio
|
|
1427
|
+
);
|
|
1428
|
+
const pathStr = convertPathCommandsToStr(cmds);
|
|
1429
|
+
path2d = new Path2D(pathStr);
|
|
1430
|
+
}
|
|
1390
1431
|
ctx.save();
|
|
1391
|
-
ctx.
|
|
1392
|
-
|
|
1393
|
-
ctx.shadowOffsetY = (shadowOffsetY || 0) * viewScaleInfo.scale;
|
|
1394
|
-
ctx.shadowBlur = (shadowBlur || 0) * viewScaleInfo.scale;
|
|
1395
|
-
renderContent();
|
|
1432
|
+
ctx.clip(path2d, "nonzero");
|
|
1433
|
+
renderContent?.();
|
|
1396
1434
|
ctx.restore();
|
|
1397
1435
|
} else {
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1436
|
+
renderContent?.();
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
function rotateViewMaterial(ctx, mtrl, opts, callback) {
|
|
1440
|
+
const { viewScaleInfo, calculator } = opts;
|
|
1441
|
+
const virtualAttributes = calculator?.getVirtualItem(mtrl.id);
|
|
1442
|
+
if (virtualAttributes) {
|
|
1443
|
+
const { worldAngle, worldCenter } = virtualAttributes;
|
|
1444
|
+
const viewWorldCenter = calcViewPoint(worldCenter, { viewScaleInfo });
|
|
1445
|
+
const { scale } = viewScaleInfo;
|
|
1446
|
+
rotateByCenter(ctx, worldAngle, viewWorldCenter, () => {
|
|
1447
|
+
const width2 = mtrl.width * scale;
|
|
1448
|
+
const height2 = mtrl.height * scale;
|
|
1449
|
+
const viewWorldSize = {
|
|
1450
|
+
x: viewWorldCenter.x - width2 / 2,
|
|
1451
|
+
y: viewWorldCenter.y - height2 / 2,
|
|
1452
|
+
width: width2,
|
|
1453
|
+
height: height2
|
|
1454
|
+
};
|
|
1455
|
+
callback({ viewWorldCenter, viewWorldSize });
|
|
1456
|
+
});
|
|
1405
1457
|
}
|
|
1406
1458
|
}
|
|
1407
|
-
function
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
const { background = "#000000", borderColor = "#000000", boxSizing, borderWidth: borderWidth2 = 0, borderDash } = detail;
|
|
1411
|
-
let bw = 0;
|
|
1412
|
-
if (typeof borderWidth2 === "number" && borderWidth2 > 0) {
|
|
1413
|
-
bw = borderWidth2;
|
|
1414
|
-
} else if (Array.isArray(borderWidth2) && typeof borderWidth2[0] === "number" && borderWidth2[0] > 0) {
|
|
1415
|
-
bw = borderWidth2[0];
|
|
1416
|
-
}
|
|
1417
|
-
bw = bw * viewScaleInfo.scale;
|
|
1418
|
-
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h }, { viewScaleInfo }) || elem;
|
|
1419
|
-
const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
|
|
1420
|
-
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
1421
|
-
drawBoxShadow(ctx, viewElem, {
|
|
1422
|
-
viewScaleInfo,
|
|
1423
|
-
renderContent: () => {
|
|
1424
|
-
let a = w2 / 2;
|
|
1425
|
-
let b = h2 / 2;
|
|
1426
|
-
const centerX = x2 + a;
|
|
1427
|
-
const centerY = y2 + b;
|
|
1428
|
-
const radiusA = a;
|
|
1429
|
-
const radiusB = b;
|
|
1430
|
-
if (bw > 0) {
|
|
1431
|
-
if (boxSizing === "content-box") ;
|
|
1432
|
-
else if (boxSizing === "center-line") {
|
|
1433
|
-
a = a - bw / 2;
|
|
1434
|
-
b = b - bw / 2;
|
|
1435
|
-
} else {
|
|
1436
|
-
a = a - bw;
|
|
1437
|
-
b = b - bw;
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
if (a >= 0 && b >= 0) {
|
|
1441
|
-
const opacity = getOpacity(viewElem) * parentOpacity;
|
|
1442
|
-
ctx.globalAlpha = opacity;
|
|
1443
|
-
ctx.beginPath();
|
|
1444
|
-
const fillStyle = createColorStyle(ctx, background, {
|
|
1445
|
-
viewElementSize: { x: x2, y: y2, w: w2, h: h2 },
|
|
1446
|
-
viewScaleInfo,
|
|
1447
|
-
opacity: ctx.globalAlpha
|
|
1448
|
-
});
|
|
1449
|
-
ctx.fillStyle = fillStyle;
|
|
1450
|
-
ctx.circle(centerX, centerY, radiusA, radiusB, 0, 0, 2 * Math.PI);
|
|
1451
|
-
ctx.closePath();
|
|
1452
|
-
ctx.fill("nonzero");
|
|
1453
|
-
ctx.globalAlpha = parentOpacity;
|
|
1454
|
-
if (typeof bw === "number" && bw > 0) {
|
|
1455
|
-
const ba = bw / 2 + a;
|
|
1456
|
-
const bb = bw / 2 + b;
|
|
1457
|
-
ctx.beginPath();
|
|
1458
|
-
if (borderDash) {
|
|
1459
|
-
const lineDash = borderDash.map((n) => n * viewScaleInfo.scale);
|
|
1460
|
-
ctx.setLineDash(lineDash);
|
|
1461
|
-
}
|
|
1462
|
-
ctx.strokeStyle = borderColor;
|
|
1463
|
-
ctx.lineWidth = bw;
|
|
1464
|
-
ctx.circle(centerX, centerY, ba, bb, 0, 0, 2 * Math.PI);
|
|
1465
|
-
ctx.closePath();
|
|
1466
|
-
ctx.stroke();
|
|
1467
|
-
ctx.setLineDash([]);
|
|
1468
|
-
}
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
});
|
|
1459
|
+
function drawRect(ctx, mtrl, opts) {
|
|
1460
|
+
rotateViewMaterial(ctx, mtrl, opts, () => {
|
|
1461
|
+
drawBase(ctx, mtrl, opts);
|
|
1472
1462
|
});
|
|
1473
1463
|
}
|
|
1474
|
-
function
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
|
|
1478
|
-
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
1479
|
-
drawBoxShadow(ctx, viewElem, {
|
|
1480
|
-
viewScaleInfo,
|
|
1481
|
-
renderContent: () => {
|
|
1482
|
-
drawBox(ctx, viewElem, {
|
|
1483
|
-
originElem: elem,
|
|
1484
|
-
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
1485
|
-
viewScaleInfo,
|
|
1486
|
-
viewSizeInfo,
|
|
1487
|
-
parentOpacity,
|
|
1488
|
-
renderContent: () => {
|
|
1489
|
-
}
|
|
1490
|
-
});
|
|
1491
|
-
}
|
|
1492
|
-
});
|
|
1464
|
+
function drawCircle(ctx, mtrl, opts) {
|
|
1465
|
+
rotateViewMaterial(ctx, mtrl, opts, () => {
|
|
1466
|
+
drawBase(ctx, mtrl, opts);
|
|
1493
1467
|
});
|
|
1494
1468
|
}
|
|
1495
|
-
function
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
|
|
1499
|
-
const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
|
|
1500
|
-
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
1501
|
-
drawBoxShadow(ctx, viewElem, {
|
|
1502
|
-
viewScaleInfo,
|
|
1503
|
-
renderContent: () => {
|
|
1504
|
-
drawBox(ctx, viewElem, {
|
|
1505
|
-
originElem: elem,
|
|
1506
|
-
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
1507
|
-
viewScaleInfo,
|
|
1508
|
-
viewSizeInfo,
|
|
1509
|
-
parentOpacity,
|
|
1510
|
-
renderContent: () => {
|
|
1511
|
-
if (!content && !opts.loader.isDestroyed()) {
|
|
1512
|
-
opts.loader.load(elem, opts.elementAssets || {});
|
|
1513
|
-
}
|
|
1514
|
-
if (elem.type === "image" && content) {
|
|
1515
|
-
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
1516
|
-
const { x: x22, y: y22, w: w22, h: h22, radiusList } = calcViewBoxSize(viewElem, {
|
|
1517
|
-
viewScaleInfo
|
|
1518
|
-
});
|
|
1519
|
-
const { detail } = elem;
|
|
1520
|
-
const { scaleMode, originW = 0, originH = 0 } = detail;
|
|
1521
|
-
const imageW = ctx.$undoPixelRatio(originW);
|
|
1522
|
-
const imageH = ctx.$undoPixelRatio(originH);
|
|
1523
|
-
ctx.save();
|
|
1524
|
-
ctx.fillStyle = "transparent";
|
|
1525
|
-
ctx.beginPath();
|
|
1526
|
-
ctx.moveTo(x22 + radiusList[0], y22);
|
|
1527
|
-
ctx.arcTo(x22 + w22, y22, x22 + w22, y22 + h22, radiusList[1]);
|
|
1528
|
-
ctx.arcTo(x22 + w22, y22 + h22, x22, y22 + h22, radiusList[2]);
|
|
1529
|
-
ctx.arcTo(x22, y22 + h22, x22, y22, radiusList[3]);
|
|
1530
|
-
ctx.arcTo(x22, y22, x22 + w22, y22, radiusList[0]);
|
|
1531
|
-
ctx.closePath();
|
|
1532
|
-
ctx.fill("nonzero");
|
|
1533
|
-
ctx.clip("nonzero");
|
|
1534
|
-
if (scaleMode && originH && originW) {
|
|
1535
|
-
let sx = 0;
|
|
1536
|
-
let sy = 0;
|
|
1537
|
-
let sWidth = imageW;
|
|
1538
|
-
let sHeight = imageH;
|
|
1539
|
-
const dx = x22;
|
|
1540
|
-
const dy = y22;
|
|
1541
|
-
const dWidth = w22;
|
|
1542
|
-
const dHeight = h22;
|
|
1543
|
-
if (imageW > elem.w || imageH > elem.h) {
|
|
1544
|
-
if (scaleMode === "fill") {
|
|
1545
|
-
const sourceScale = Math.max(elem.w / imageW, elem.h / imageH);
|
|
1546
|
-
const newImageWidth = imageW * sourceScale;
|
|
1547
|
-
const newImageHeight = imageH * sourceScale;
|
|
1548
|
-
sx = (newImageWidth - elem.w) / 2 / sourceScale;
|
|
1549
|
-
sy = (newImageHeight - elem.h) / 2 / sourceScale;
|
|
1550
|
-
sWidth = elem.w / sourceScale;
|
|
1551
|
-
sHeight = elem.h / sourceScale;
|
|
1552
|
-
} else if (scaleMode === "tile") {
|
|
1553
|
-
sx = 0;
|
|
1554
|
-
sy = 0;
|
|
1555
|
-
sWidth = elem.w;
|
|
1556
|
-
sHeight = elem.h;
|
|
1557
|
-
} else if (scaleMode === "fit") {
|
|
1558
|
-
const sourceScale = Math.min(elem.w / imageW, elem.h / imageH);
|
|
1559
|
-
sx = (imageW - elem.w / sourceScale) / 2;
|
|
1560
|
-
sy = (imageH - elem.h / sourceScale) / 2;
|
|
1561
|
-
sWidth = elem.w / sourceScale;
|
|
1562
|
-
sHeight = elem.h / sourceScale;
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
ctx.drawImage(content, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
|
|
1566
|
-
} else {
|
|
1567
|
-
ctx.drawImage(content, x22, y22, w22, h22);
|
|
1568
|
-
}
|
|
1569
|
-
ctx.globalAlpha = parentOpacity;
|
|
1570
|
-
ctx.restore();
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1573
|
-
});
|
|
1574
|
-
}
|
|
1575
|
-
});
|
|
1469
|
+
function drawEllipse(ctx, mtrl, opts) {
|
|
1470
|
+
rotateViewMaterial(ctx, mtrl, opts, () => {
|
|
1471
|
+
drawBase(ctx, mtrl, opts);
|
|
1576
1472
|
});
|
|
1577
1473
|
}
|
|
1578
|
-
function
|
|
1579
|
-
|
|
1474
|
+
function getOpacity(mtrl) {
|
|
1475
|
+
let opacity = 1;
|
|
1476
|
+
if (mtrl?.opacity !== void 0 && mtrl?.opacity >= 0 && mtrl?.opacity <= 1) {
|
|
1477
|
+
opacity = mtrl?.opacity;
|
|
1478
|
+
}
|
|
1479
|
+
return opacity;
|
|
1480
|
+
}
|
|
1481
|
+
function drawImage(ctx, mtrl, opts) {
|
|
1482
|
+
const content = opts.loader.getContent(mtrl);
|
|
1580
1483
|
const { viewScaleInfo, parentOpacity } = opts;
|
|
1581
|
-
const { x: x2, y: y2,
|
|
1582
|
-
|
|
1484
|
+
const { x: x2, y: y2, width: width2, height: height2, angle: angle2 } = calcViewMaterialSize(mtrl, { viewScaleInfo }) || mtrl;
|
|
1485
|
+
const viewMtrl = { ...mtrl, ...{ x: x2, y: y2, width: width2, height: height2, angle: angle2 } };
|
|
1486
|
+
rotateViewMaterial(ctx, mtrl, opts, () => {
|
|
1583
1487
|
if (!content && !opts.loader.isDestroyed()) {
|
|
1584
|
-
opts.loader.load(
|
|
1488
|
+
opts.loader.load(mtrl, opts.materialAssets || {});
|
|
1585
1489
|
}
|
|
1586
|
-
if (
|
|
1587
|
-
ctx.globalAlpha = getOpacity(
|
|
1588
|
-
|
|
1490
|
+
if (mtrl.type === "image" && content) {
|
|
1491
|
+
ctx.globalAlpha = getOpacity(mtrl) * parentOpacity;
|
|
1492
|
+
const { x: x22, y: y22, width: width22, height: height22 } = viewMtrl;
|
|
1493
|
+
const radiusList = [0, 0, 0, 0];
|
|
1494
|
+
const attributes = mtrl;
|
|
1495
|
+
const { scaleMode, originW = 0, originH = 0 } = attributes;
|
|
1496
|
+
const imageW = ctx.$undoPixelRatio(originW);
|
|
1497
|
+
const imageH = ctx.$undoPixelRatio(originH);
|
|
1498
|
+
ctx.save();
|
|
1499
|
+
ctx.fillStyle = "transparent";
|
|
1500
|
+
ctx.beginPath();
|
|
1501
|
+
ctx.moveTo(x22 + radiusList[0], y22);
|
|
1502
|
+
ctx.arcTo(x22 + width22, y22, x22 + width22, y22 + height22, radiusList[1]);
|
|
1503
|
+
ctx.arcTo(x22 + width22, y22 + height22, x22, y22 + height22, radiusList[2]);
|
|
1504
|
+
ctx.arcTo(x22, y22 + height22, x22, y22, radiusList[3]);
|
|
1505
|
+
ctx.arcTo(x22, y22, x22 + width22, y22, radiusList[0]);
|
|
1506
|
+
ctx.closePath();
|
|
1507
|
+
ctx.fill("nonzero");
|
|
1508
|
+
ctx.clip("nonzero");
|
|
1509
|
+
if (scaleMode && originH && originW) {
|
|
1510
|
+
let sx = 0;
|
|
1511
|
+
let sy = 0;
|
|
1512
|
+
let sWidth = imageW;
|
|
1513
|
+
let sHeight = imageH;
|
|
1514
|
+
const dx = x22;
|
|
1515
|
+
const dy = y22;
|
|
1516
|
+
const dWidth = width22;
|
|
1517
|
+
const dHeight = height22;
|
|
1518
|
+
if (imageW > mtrl.width || imageH > mtrl.height) {
|
|
1519
|
+
if (scaleMode === "fill") {
|
|
1520
|
+
const sourceScale = Math.max(mtrl.width / imageW, mtrl.height / imageH);
|
|
1521
|
+
const newImageWidth = imageW * sourceScale;
|
|
1522
|
+
const newImageHeight = imageH * sourceScale;
|
|
1523
|
+
sx = (newImageWidth - mtrl.width) / 2 / sourceScale;
|
|
1524
|
+
sy = (newImageHeight - mtrl.height) / 2 / sourceScale;
|
|
1525
|
+
sWidth = mtrl.width / sourceScale;
|
|
1526
|
+
sHeight = mtrl.height / sourceScale;
|
|
1527
|
+
} else if (scaleMode === "tile") {
|
|
1528
|
+
sx = 0;
|
|
1529
|
+
sy = 0;
|
|
1530
|
+
sWidth = mtrl.width;
|
|
1531
|
+
sHeight = mtrl.height;
|
|
1532
|
+
} else if (scaleMode === "fit") {
|
|
1533
|
+
const sourceScale = Math.min(mtrl.width / imageW, mtrl.height / imageH);
|
|
1534
|
+
sx = (imageW - mtrl.width / sourceScale) / 2;
|
|
1535
|
+
sy = (imageH - mtrl.height / sourceScale) / 2;
|
|
1536
|
+
sWidth = mtrl.width / sourceScale;
|
|
1537
|
+
sHeight = mtrl.height / sourceScale;
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
ctx.drawImage(content, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
|
|
1541
|
+
} else {
|
|
1542
|
+
ctx.drawImage(content, x22, y22, width22, height22);
|
|
1543
|
+
}
|
|
1589
1544
|
ctx.globalAlpha = parentOpacity;
|
|
1545
|
+
ctx.restore();
|
|
1590
1546
|
}
|
|
1591
1547
|
});
|
|
1592
1548
|
}
|
|
1593
|
-
function
|
|
1594
|
-
const content = opts.loader.getContent(
|
|
1595
|
-
const { viewScaleInfo
|
|
1596
|
-
const { x: x2, y: y2,
|
|
1597
|
-
|
|
1549
|
+
function drawSVGCode(ctx, mtrl, opts) {
|
|
1550
|
+
const content = opts.loader.getContent(mtrl);
|
|
1551
|
+
const { viewScaleInfo } = opts;
|
|
1552
|
+
const { x: x2, y: y2, width: width2, height: height2 } = calcViewMaterialSize(mtrl, { viewScaleInfo }) || mtrl;
|
|
1553
|
+
rotateViewMaterial(ctx, mtrl, opts, () => {
|
|
1598
1554
|
if (!content && !opts.loader.isDestroyed()) {
|
|
1599
|
-
opts.loader.load(
|
|
1555
|
+
opts.loader.load(mtrl, opts.materialAssets || {});
|
|
1600
1556
|
}
|
|
1601
|
-
if (
|
|
1602
|
-
ctx.
|
|
1603
|
-
ctx.drawImage(content, x2, y2, w2, h2);
|
|
1604
|
-
ctx.globalAlpha = parentOpacity;
|
|
1557
|
+
if (mtrl.type === "svgCode" && content) {
|
|
1558
|
+
ctx.drawImage(content, x2, y2, width2, height2);
|
|
1605
1559
|
}
|
|
1606
1560
|
});
|
|
1607
1561
|
}
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
const { viewScaleInfo
|
|
1611
|
-
const { x: x2, y: y2,
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1562
|
+
function drawForeignObject(ctx, mtrl, opts) {
|
|
1563
|
+
const content = opts.loader.getContent(mtrl);
|
|
1564
|
+
const { viewScaleInfo } = opts;
|
|
1565
|
+
const { x: x2, y: y2, width: width2, height: height2 } = calcViewMaterialSize(mtrl, { viewScaleInfo }) || mtrl;
|
|
1566
|
+
rotateViewMaterial(ctx, mtrl, opts, () => {
|
|
1567
|
+
if (!content && !opts.loader.isDestroyed()) {
|
|
1568
|
+
opts.loader.load(mtrl, opts.materialAssets || {});
|
|
1569
|
+
}
|
|
1570
|
+
if (mtrl.type === "foreignObject" && content) {
|
|
1571
|
+
ctx.drawImage(content, x2, y2, width2, height2);
|
|
1572
|
+
}
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
const defaultAttrs = getDefaultMaterialAttributes();
|
|
1576
|
+
function drawText(ctx, mtrl, opts) {
|
|
1577
|
+
const { viewScaleInfo, viewSizeInfo, calculator } = opts;
|
|
1578
|
+
const viewMaterialSize = calcViewMaterialSize(mtrl, { viewScaleInfo }) || mtrl;
|
|
1579
|
+
const { scale } = viewScaleInfo;
|
|
1580
|
+
rotateViewMaterial(ctx, mtrl, opts, ({ viewWorldSize }) => {
|
|
1627
1581
|
{
|
|
1628
|
-
const
|
|
1629
|
-
...
|
|
1630
|
-
...
|
|
1582
|
+
const attributes = {
|
|
1583
|
+
...defaultAttrs,
|
|
1584
|
+
...mtrl
|
|
1631
1585
|
};
|
|
1632
|
-
const
|
|
1586
|
+
const { x: x2, y: y2 } = viewWorldSize;
|
|
1587
|
+
const originFontSize = attributes.fontSize || defaultAttrs.fontSize;
|
|
1633
1588
|
const fontSize2 = originFontSize * viewScaleInfo.scale;
|
|
1589
|
+
const {
|
|
1590
|
+
opacity,
|
|
1591
|
+
fill,
|
|
1592
|
+
fillOpacity,
|
|
1593
|
+
stroke,
|
|
1594
|
+
strokeWidth: strokeWidth2,
|
|
1595
|
+
strokeOpacity,
|
|
1596
|
+
strokeLinecap,
|
|
1597
|
+
strokeLinejoin,
|
|
1598
|
+
strokeDasharray,
|
|
1599
|
+
strokeDashoffset,
|
|
1600
|
+
strokeMiterlimit
|
|
1601
|
+
} = attributes;
|
|
1634
1602
|
if (fontSize2 < 2) {
|
|
1635
1603
|
return;
|
|
1636
1604
|
}
|
|
1637
|
-
const
|
|
1638
|
-
const
|
|
1639
|
-
ctx.globalAlpha = opacity;
|
|
1640
|
-
ctx.fillStyle = elem.detail.color || detailConfig$1.color;
|
|
1605
|
+
const originGlobalAlpha = ctx.globalAlpha;
|
|
1606
|
+
const virtualTextAttributes = calculator.getVirtualItem(mtrl.id);
|
|
1641
1607
|
ctx.textBaseline = "top";
|
|
1642
1608
|
ctx.$setFont({
|
|
1643
|
-
fontWeight:
|
|
1609
|
+
fontWeight: attributes.fontWeight,
|
|
1644
1610
|
fontSize: fontSize2,
|
|
1645
|
-
fontFamily: enhanceFontFamliy(
|
|
1611
|
+
fontFamily: enhanceFontFamliy(attributes.fontFamily)
|
|
1646
1612
|
});
|
|
1647
|
-
{
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1613
|
+
drawClipPath(ctx, mtrl, {
|
|
1614
|
+
viewScaleInfo,
|
|
1615
|
+
viewSizeInfo,
|
|
1616
|
+
calculator,
|
|
1617
|
+
renderContent: () => {
|
|
1618
|
+
if (fill) {
|
|
1619
|
+
if (typeof fillOpacity === "number" && fillOpacity > 0) {
|
|
1620
|
+
ctx.globalAlpha = originGlobalAlpha * fillOpacity * opacity;
|
|
1621
|
+
}
|
|
1622
|
+
ctx.fillStyle = createColor(ctx, fill, { viewMaterialSize, viewScaleInfo, opacity: mtrl.opacity || 1 });
|
|
1623
|
+
if (Array.isArray(virtualTextAttributes?.textLines) && virtualTextAttributes?.textLines?.length > 0) {
|
|
1624
|
+
virtualTextAttributes?.textLines?.forEach((line) => {
|
|
1625
|
+
ctx.fillText(line.text, x2 + line.x * viewScaleInfo.scale, y2 + line.y * viewScaleInfo.scale);
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
ctx.globalAlpha = originGlobalAlpha;
|
|
1658
1629
|
}
|
|
1659
|
-
if (
|
|
1660
|
-
|
|
1630
|
+
if (typeof strokeWidth2 === "number" && strokeWidth2 > 0) {
|
|
1631
|
+
if (typeof strokeOpacity === "number" && strokeOpacity > 0) {
|
|
1632
|
+
ctx.globalAlpha = originGlobalAlpha * strokeOpacity * opacity;
|
|
1633
|
+
}
|
|
1634
|
+
ctx.lineCap = strokeLinecap;
|
|
1635
|
+
ctx.lineJoin = strokeLinejoin;
|
|
1636
|
+
ctx.lineDashOffset = strokeDashoffset;
|
|
1637
|
+
ctx.miterLimit = strokeMiterlimit;
|
|
1638
|
+
if (Array.isArray(strokeDasharray)) {
|
|
1639
|
+
const lineDash = strokeDasharray.map((dash) => scale * dash);
|
|
1640
|
+
ctx.setLineDash(lineDash);
|
|
1641
|
+
}
|
|
1642
|
+
ctx.lineWidth = strokeWidth2 * scale;
|
|
1643
|
+
ctx.strokeStyle = stroke;
|
|
1644
|
+
virtualTextAttributes?.textLines?.forEach((line) => {
|
|
1645
|
+
ctx.strokeText(line.text, x2 + line.x * viewScaleInfo.scale, y2 + line.y * viewScaleInfo.scale);
|
|
1646
|
+
});
|
|
1647
|
+
ctx.setLineDash([]);
|
|
1648
|
+
ctx.lineCap = defaultAttrs.strokeLinecap;
|
|
1649
|
+
ctx.lineJoin = defaultAttrs.strokeLinejoin;
|
|
1650
|
+
ctx.lineDashOffset = defaultAttrs.strokeDashoffset;
|
|
1651
|
+
ctx.miterLimit = defaultAttrs.strokeMiterlimit;
|
|
1652
|
+
ctx.globalAlpha = originGlobalAlpha;
|
|
1661
1653
|
}
|
|
1662
|
-
(_b = virtualTextDetail == null ? void 0 : virtualTextDetail.textLines) == null ? void 0 : _b.forEach((line) => {
|
|
1663
|
-
ctx.fillText(line.text, x2 + line.x * viewScaleInfo.scale, y2 + line.y * viewScaleInfo.scale);
|
|
1664
|
-
});
|
|
1665
1654
|
}
|
|
1666
|
-
}
|
|
1667
|
-
ctx.globalAlpha = parentOpacity2;
|
|
1655
|
+
});
|
|
1668
1656
|
}
|
|
1669
1657
|
});
|
|
1670
1658
|
}
|
|
1671
|
-
function drawPath(ctx,
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
const { originX, originY, originW, originH, fillRule } = detail;
|
|
1675
|
-
const { viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
1676
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
|
|
1677
|
-
const scaleW = w2 / originW;
|
|
1678
|
-
const scaleH = h2 / originH;
|
|
1679
|
-
const viewOriginX = originX * scaleW;
|
|
1680
|
-
const viewOriginY = originY * scaleH;
|
|
1681
|
-
const internalX = x2 - viewOriginX;
|
|
1682
|
-
const internalY = y2 - viewOriginY;
|
|
1683
|
-
const { clipPath, clipPathStrokeColor, clipPathStrokeWidth, ...restDetail } = elem.detail;
|
|
1684
|
-
const scaleNum = viewScaleInfo.scale * viewSizeInfo.devicePixelRatio;
|
|
1685
|
-
const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
|
|
1686
|
-
let boxViewElem = { ...viewElem };
|
|
1687
|
-
boxViewElem.detail = restDetail;
|
|
1688
|
-
let boxOriginElem = { ...elem };
|
|
1689
|
-
boxOriginElem.detail = restDetail;
|
|
1690
|
-
if (detail.fill && detail.fill !== "string" && ((_b = (_a = detail.fill) == null ? void 0 : _a.type) == null ? void 0 : _b.includes("gradient"))) {
|
|
1691
|
-
boxViewElem = {
|
|
1692
|
-
...viewElem,
|
|
1693
|
-
...{
|
|
1694
|
-
detail: {
|
|
1695
|
-
...viewElem.detail,
|
|
1696
|
-
...{
|
|
1697
|
-
background: detail.fill,
|
|
1698
|
-
clipPath: {
|
|
1699
|
-
commands: detail.commands,
|
|
1700
|
-
originX,
|
|
1701
|
-
originY,
|
|
1702
|
-
originW,
|
|
1703
|
-
originH
|
|
1704
|
-
}
|
|
1705
|
-
}
|
|
1706
|
-
}
|
|
1707
|
-
}
|
|
1708
|
-
};
|
|
1709
|
-
boxOriginElem.detail = { ...boxViewElem.detail };
|
|
1710
|
-
}
|
|
1711
|
-
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
1712
|
-
drawBox(ctx, boxViewElem, {
|
|
1713
|
-
originElem: boxOriginElem,
|
|
1714
|
-
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
1715
|
-
viewScaleInfo,
|
|
1716
|
-
viewSizeInfo,
|
|
1717
|
-
parentOpacity,
|
|
1718
|
-
renderContent: () => {
|
|
1719
|
-
drawBoxShadow(ctx, viewElem, {
|
|
1720
|
-
viewScaleInfo,
|
|
1721
|
-
renderContent: () => {
|
|
1722
|
-
ctx.save();
|
|
1723
|
-
ctx.translate(internalX, internalY);
|
|
1724
|
-
ctx.scale(scaleNum * scaleW / viewScaleInfo.scale, scaleNum * scaleH / viewScaleInfo.scale);
|
|
1725
|
-
const pathStr = generateSVGPath(detail.commands || []);
|
|
1726
|
-
const path2d = new Path2D(pathStr);
|
|
1727
|
-
if (detail.fill) {
|
|
1728
|
-
if (typeof detail.fill === "string") {
|
|
1729
|
-
ctx.fillStyle = detail.fill;
|
|
1730
|
-
} else {
|
|
1731
|
-
ctx.fillStyle = "transparent";
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
if (detail.fill) {
|
|
1735
|
-
ctx.fill(path2d, fillRule || "nonzero");
|
|
1736
|
-
}
|
|
1737
|
-
if (detail.stroke && detail.strokeWidth !== 0) {
|
|
1738
|
-
ctx.strokeStyle = detail.stroke;
|
|
1739
|
-
ctx.lineWidth = (detail.strokeWidth || 1) / viewSizeInfo.devicePixelRatio;
|
|
1740
|
-
ctx.lineCap = detail.strokeLineCap || "square";
|
|
1741
|
-
ctx.stroke(path2d);
|
|
1742
|
-
}
|
|
1743
|
-
ctx.translate(-internalX, -internalY);
|
|
1744
|
-
ctx.restore();
|
|
1745
|
-
}
|
|
1746
|
-
});
|
|
1747
|
-
}
|
|
1748
|
-
});
|
|
1659
|
+
function drawPath(ctx, mtrl, opts) {
|
|
1660
|
+
rotateViewMaterial(ctx, mtrl, opts, () => {
|
|
1661
|
+
drawBase(ctx, mtrl, opts);
|
|
1749
1662
|
});
|
|
1750
1663
|
}
|
|
1751
1664
|
const visiableMinSize = 0.4;
|
|
1752
|
-
function
|
|
1753
|
-
|
|
1754
|
-
if (((_a = elem == null ? void 0 : elem.operations) == null ? void 0 : _a.invisible) === true) {
|
|
1665
|
+
function drawMaterial(ctx, mtrl, opts) {
|
|
1666
|
+
if (mtrl?.operations?.invisible === true) {
|
|
1755
1667
|
return;
|
|
1756
1668
|
}
|
|
1757
|
-
const {
|
|
1669
|
+
const { width: width2, height: height2 } = mtrl;
|
|
1758
1670
|
const { scale } = opts.viewScaleInfo;
|
|
1759
|
-
if (scale < 1 && (
|
|
1671
|
+
if (scale < 1 && (width2 * scale < visiableMinSize || height2 * scale < visiableMinSize) || opts.parentOpacity === 0) {
|
|
1760
1672
|
return;
|
|
1761
1673
|
}
|
|
1762
|
-
const {
|
|
1763
|
-
if (
|
|
1674
|
+
const { overrideMaterialMap } = opts;
|
|
1675
|
+
if (overrideMaterialMap?.[mtrl.id]?.operations?.invisible) {
|
|
1764
1676
|
return;
|
|
1765
1677
|
}
|
|
1766
1678
|
try {
|
|
1767
|
-
switch (
|
|
1679
|
+
switch (mtrl.type) {
|
|
1768
1680
|
case "rect": {
|
|
1769
|
-
drawRect(ctx,
|
|
1681
|
+
drawRect(ctx, mtrl, opts);
|
|
1770
1682
|
break;
|
|
1771
1683
|
}
|
|
1772
1684
|
case "circle": {
|
|
1773
|
-
drawCircle(ctx,
|
|
1685
|
+
drawCircle(ctx, mtrl, opts);
|
|
1686
|
+
break;
|
|
1687
|
+
}
|
|
1688
|
+
case "ellipse": {
|
|
1689
|
+
drawEllipse(ctx, mtrl, opts);
|
|
1774
1690
|
break;
|
|
1775
1691
|
}
|
|
1776
1692
|
case "text": {
|
|
1777
|
-
drawText(ctx,
|
|
1693
|
+
drawText(ctx, mtrl, opts);
|
|
1778
1694
|
break;
|
|
1779
1695
|
}
|
|
1780
1696
|
case "image": {
|
|
1781
|
-
drawImage(ctx,
|
|
1697
|
+
drawImage(ctx, mtrl, opts);
|
|
1782
1698
|
break;
|
|
1783
1699
|
}
|
|
1784
|
-
case "
|
|
1785
|
-
|
|
1700
|
+
case "svgCode": {
|
|
1701
|
+
drawSVGCode(ctx, mtrl, opts);
|
|
1786
1702
|
break;
|
|
1787
1703
|
}
|
|
1788
|
-
case "
|
|
1789
|
-
|
|
1704
|
+
case "foreignObject": {
|
|
1705
|
+
drawForeignObject(ctx, mtrl, opts);
|
|
1790
1706
|
break;
|
|
1791
1707
|
}
|
|
1792
1708
|
case "path": {
|
|
1793
|
-
drawPath(ctx,
|
|
1709
|
+
drawPath(ctx, mtrl, opts);
|
|
1794
1710
|
break;
|
|
1795
1711
|
}
|
|
1796
1712
|
case "group": {
|
|
1797
1713
|
const assets = {
|
|
1798
|
-
...opts.
|
|
1799
|
-
...
|
|
1714
|
+
...opts.materialAssets || {},
|
|
1715
|
+
...mtrl.assets || {}
|
|
1800
1716
|
};
|
|
1801
|
-
drawGroup(ctx,
|
|
1717
|
+
drawGroup(ctx, mtrl, {
|
|
1802
1718
|
...opts,
|
|
1803
|
-
|
|
1719
|
+
materialAssets: assets
|
|
1804
1720
|
});
|
|
1805
1721
|
break;
|
|
1806
1722
|
}
|
|
@@ -1812,102 +1728,64 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1812
1728
|
console.error(err);
|
|
1813
1729
|
}
|
|
1814
1730
|
}
|
|
1815
|
-
function drawGroup(ctx,
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
|
|
1819
|
-
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
1820
|
-
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
1821
|
-
drawBoxShadow(ctx, viewElem, {
|
|
1822
|
-
viewScaleInfo,
|
|
1823
|
-
renderContent: () => {
|
|
1824
|
-
drawBox(ctx, viewElem, {
|
|
1825
|
-
originElem: elem,
|
|
1826
|
-
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
1827
|
-
viewScaleInfo,
|
|
1828
|
-
viewSizeInfo,
|
|
1829
|
-
parentOpacity,
|
|
1830
|
-
renderContent: () => {
|
|
1831
|
-
const { x: x22, y: y22, w: w22, h: h22, radiusList } = calcViewBoxSize(viewElem, {
|
|
1832
|
-
viewScaleInfo
|
|
1833
|
-
});
|
|
1834
|
-
if (elem.detail.overflow === "hidden") {
|
|
1835
|
-
ctx.save();
|
|
1836
|
-
ctx.fillStyle = "transparent";
|
|
1837
|
-
ctx.beginPath();
|
|
1838
|
-
ctx.moveTo(x22 + radiusList[0], y22);
|
|
1839
|
-
ctx.arcTo(x22 + w22, y22, x22 + w22, y22 + h22, radiusList[1]);
|
|
1840
|
-
ctx.arcTo(x22 + w22, y22 + h22, x22, y22 + h22, radiusList[2]);
|
|
1841
|
-
ctx.arcTo(x22, y22 + h22, x22, y22, radiusList[3]);
|
|
1842
|
-
ctx.arcTo(x22, y22, x22 + w22, y22, radiusList[0]);
|
|
1843
|
-
ctx.closePath();
|
|
1844
|
-
ctx.fill("nonzero");
|
|
1845
|
-
ctx.clip("nonzero");
|
|
1846
|
-
}
|
|
1847
|
-
if (Array.isArray(elem.detail.children)) {
|
|
1848
|
-
const { parentElementSize: parentSize } = opts;
|
|
1849
|
-
const newParentSize = {
|
|
1850
|
-
x: parentSize.x + elem.x,
|
|
1851
|
-
y: parentSize.y + elem.y,
|
|
1852
|
-
w: elem.w || parentSize.w,
|
|
1853
|
-
h: elem.h || parentSize.h,
|
|
1854
|
-
angle: elem.angle
|
|
1855
|
-
};
|
|
1856
|
-
const { calculator } = opts;
|
|
1857
|
-
for (let i = 0; i < elem.detail.children.length; i++) {
|
|
1858
|
-
let child = elem.detail.children[i];
|
|
1859
|
-
child = {
|
|
1860
|
-
...child,
|
|
1861
|
-
...{
|
|
1862
|
-
x: newParentSize.x + child.x,
|
|
1863
|
-
y: newParentSize.y + child.y
|
|
1864
|
-
}
|
|
1865
|
-
};
|
|
1866
|
-
if (opts.forceDrawAll !== true) {
|
|
1867
|
-
if (!(calculator == null ? void 0 : calculator.needRender(child))) {
|
|
1868
|
-
continue;
|
|
1869
|
-
}
|
|
1870
|
-
}
|
|
1871
|
-
try {
|
|
1872
|
-
drawElement(ctx, child, { ...opts, ...{ parentOpacity: parentOpacity * getOpacity(elem) } });
|
|
1873
|
-
} catch (err) {
|
|
1874
|
-
console.error(err);
|
|
1875
|
-
}
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
if (elem.detail.overflow === "hidden") {
|
|
1879
|
-
ctx.restore();
|
|
1880
|
-
}
|
|
1881
|
-
}
|
|
1882
|
-
});
|
|
1883
|
-
}
|
|
1884
|
-
});
|
|
1885
|
-
ctx.globalAlpha = parentOpacity;
|
|
1731
|
+
function drawGroup(ctx, mtrl, opts) {
|
|
1732
|
+
rotateViewMaterial(ctx, mtrl, opts, () => {
|
|
1733
|
+
drawBase(ctx, mtrl, opts);
|
|
1886
1734
|
});
|
|
1735
|
+
if (Array.isArray(mtrl.children)) {
|
|
1736
|
+
const { parentMaterialSize: parentSize } = opts;
|
|
1737
|
+
const newParentSize = {
|
|
1738
|
+
x: parentSize.x + mtrl.x,
|
|
1739
|
+
y: parentSize.y + mtrl.y,
|
|
1740
|
+
width: mtrl.width || parentSize.width,
|
|
1741
|
+
height: mtrl.height || parentSize.height,
|
|
1742
|
+
angle: mtrl.angle
|
|
1743
|
+
};
|
|
1744
|
+
const { calculator } = opts;
|
|
1745
|
+
for (let i = 0; i < mtrl.children.length; i++) {
|
|
1746
|
+
let child = mtrl.children[i];
|
|
1747
|
+
child = {
|
|
1748
|
+
...child,
|
|
1749
|
+
...{
|
|
1750
|
+
x: newParentSize.x + child.x,
|
|
1751
|
+
y: newParentSize.y + child.y
|
|
1752
|
+
}
|
|
1753
|
+
};
|
|
1754
|
+
if (opts.forceDrawAll !== true) {
|
|
1755
|
+
if (!calculator?.needRender(child)) {
|
|
1756
|
+
continue;
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
try {
|
|
1760
|
+
drawMaterial(ctx, child, opts);
|
|
1761
|
+
} catch (err) {
|
|
1762
|
+
console.error(err);
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1887
1766
|
}
|
|
1888
|
-
const
|
|
1889
|
-
function
|
|
1890
|
-
|
|
1891
|
-
const { elements = [] } = data2;
|
|
1767
|
+
const defaultAttributes = getDefaultMaterialAttributes();
|
|
1768
|
+
function drawMaterialList(ctx, data2, opts) {
|
|
1769
|
+
const { materials = [] } = data2;
|
|
1892
1770
|
const { parentOpacity } = opts;
|
|
1893
|
-
for (let i = 0; i <
|
|
1894
|
-
const
|
|
1895
|
-
const
|
|
1896
|
-
...
|
|
1771
|
+
for (let i = 0; i < materials.length; i++) {
|
|
1772
|
+
const material2 = materials[i];
|
|
1773
|
+
const mtrl = {
|
|
1774
|
+
...material2,
|
|
1897
1775
|
...{
|
|
1898
|
-
|
|
1899
|
-
...
|
|
1900
|
-
...
|
|
1776
|
+
attributes: {
|
|
1777
|
+
...defaultAttributes,
|
|
1778
|
+
...material2
|
|
1901
1779
|
}
|
|
1902
1780
|
}
|
|
1903
1781
|
};
|
|
1904
1782
|
if (opts.forceDrawAll !== true) {
|
|
1905
|
-
if (!
|
|
1783
|
+
if (!opts.calculator?.needRender(mtrl)) {
|
|
1906
1784
|
continue;
|
|
1907
1785
|
}
|
|
1908
1786
|
}
|
|
1909
1787
|
try {
|
|
1910
|
-
|
|
1788
|
+
drawMaterial(ctx, mtrl, {
|
|
1911
1789
|
...opts,
|
|
1912
1790
|
...{
|
|
1913
1791
|
parentOpacity
|
|
@@ -1919,385 +1797,666 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1919
1797
|
}
|
|
1920
1798
|
}
|
|
1921
1799
|
function drawLayout(ctx, layout2, opts, renderContent) {
|
|
1922
|
-
const {
|
|
1923
|
-
const elem = { uuid: "layout", type: "group", ...layout2 };
|
|
1924
|
-
const { x: x2, y: y2, w: w2, h: h2 } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
|
|
1925
|
-
const angle2 = 0;
|
|
1926
|
-
const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
|
|
1800
|
+
const { parentOpacity } = opts;
|
|
1927
1801
|
ctx.globalAlpha = 1;
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
}
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
ctx.arcTo(x22, y22, x22 + w22, y22, radiusList[0]);
|
|
1950
|
-
ctx.closePath();
|
|
1951
|
-
ctx.fill("nonzero");
|
|
1802
|
+
const { viewScaleInfo } = opts;
|
|
1803
|
+
const mtrl = {
|
|
1804
|
+
id: "layout",
|
|
1805
|
+
type: "group",
|
|
1806
|
+
...layout2
|
|
1807
|
+
};
|
|
1808
|
+
const viewMtrlSize = calcViewMaterialSize(mtrl, { viewScaleInfo }) || mtrl;
|
|
1809
|
+
const viewMtrl = { ...mtrl, ...viewMtrlSize };
|
|
1810
|
+
const { x: x2, y: y2, width: width2, height: height2, fill } = viewMtrl;
|
|
1811
|
+
const radiusList = [0, 0, 0, 0];
|
|
1812
|
+
ctx.save();
|
|
1813
|
+
ctx.fillStyle = createColor(ctx, fill, { viewMaterialSize: viewMtrlSize, viewScaleInfo, opacity: mtrl.opacity || 1 });
|
|
1814
|
+
ctx.beginPath();
|
|
1815
|
+
ctx.moveTo(x2 + radiusList[0], y2);
|
|
1816
|
+
ctx.arcTo(x2 + width2, y2, x2 + width2, y2 + height2, radiusList[1]);
|
|
1817
|
+
ctx.arcTo(x2 + width2, y2 + height2, x2, y2 + height2, radiusList[2]);
|
|
1818
|
+
ctx.arcTo(x2, y2 + height2, x2, y2, radiusList[3]);
|
|
1819
|
+
ctx.arcTo(x2, y2, x2 + width2, y2, radiusList[0]);
|
|
1820
|
+
ctx.closePath();
|
|
1821
|
+
ctx.fill("nonzero");
|
|
1822
|
+
if (layout2.overflow === "hidden") {
|
|
1952
1823
|
ctx.clip("nonzero");
|
|
1953
1824
|
}
|
|
1954
1825
|
renderContent(ctx);
|
|
1955
|
-
if (layout2.
|
|
1826
|
+
if (layout2.overflow === "hidden") {
|
|
1956
1827
|
ctx.restore();
|
|
1957
1828
|
}
|
|
1958
|
-
drawBoxBorder(ctx, viewElem, { viewScaleInfo });
|
|
1959
1829
|
ctx.globalAlpha = parentOpacity;
|
|
1960
1830
|
}
|
|
1961
1831
|
function drawGlobalBackground(ctx, global, opts) {
|
|
1962
|
-
if (typeof
|
|
1832
|
+
if (typeof global?.fill === "string") {
|
|
1963
1833
|
const { viewSizeInfo } = opts;
|
|
1964
|
-
const { width, height } = viewSizeInfo;
|
|
1834
|
+
const { width: width2, height: height2 } = viewSizeInfo;
|
|
1965
1835
|
ctx.globalAlpha = 1;
|
|
1966
|
-
ctx.fillStyle = global.
|
|
1967
|
-
ctx.fillRect(0, 0,
|
|
1836
|
+
ctx.fillStyle = global.fill;
|
|
1837
|
+
ctx.fillRect(0, 0, width2, height2);
|
|
1968
1838
|
}
|
|
1969
1839
|
}
|
|
1970
|
-
const
|
|
1971
|
-
const
|
|
1972
|
-
var _a, _b, _c;
|
|
1840
|
+
const supportMaterialTypes = ["image", "svgCode", "foreignObject"];
|
|
1841
|
+
const getAssetIdFromMaterial = (material2) => {
|
|
1973
1842
|
let source = null;
|
|
1974
|
-
if (
|
|
1975
|
-
source =
|
|
1976
|
-
} else if (
|
|
1977
|
-
source =
|
|
1978
|
-
} else if (
|
|
1979
|
-
source =
|
|
1843
|
+
if (material2.type === "image") {
|
|
1844
|
+
source = material2?.href || null;
|
|
1845
|
+
} else if (material2.type === "svgCode") {
|
|
1846
|
+
source = material2?.code || null;
|
|
1847
|
+
} else if (material2.type === "foreignObject") {
|
|
1848
|
+
source = material2?.content || null;
|
|
1980
1849
|
}
|
|
1981
1850
|
if (typeof source === "string" && source) {
|
|
1982
1851
|
if (isAssetId(source)) {
|
|
1983
1852
|
return source;
|
|
1984
1853
|
}
|
|
1985
|
-
return createAssetId(source,
|
|
1854
|
+
return createAssetId(source, material2.id);
|
|
1986
1855
|
}
|
|
1987
|
-
return createAssetId(`${createUUID()}-${
|
|
1856
|
+
return createAssetId(`${createUUID()}-${material2.id}-${createUUID()}-${createUUID()}`, material2.id);
|
|
1988
1857
|
};
|
|
1989
1858
|
class Loader extends EventEmitter {
|
|
1859
|
+
#loadFuncMap = {};
|
|
1860
|
+
#currentLoadItemMap = {};
|
|
1861
|
+
#storageLoadItemMap = {};
|
|
1862
|
+
#hasDestroyed = false;
|
|
1990
1863
|
constructor() {
|
|
1991
1864
|
super();
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
__privateAdd(this, _storageLoadItemMap, {});
|
|
1996
|
-
__privateAdd(this, _hasDestroyed, false);
|
|
1997
|
-
__privateMethod(this, _Loader_instances, registerLoadFunc_fn).call(this, "image", async (elem, assets) => {
|
|
1998
|
-
var _a;
|
|
1999
|
-
const src = ((_a = assets[elem.detail.src]) == null ? void 0 : _a.value) || elem.detail.src;
|
|
2000
|
-
const content = await loadImage(src);
|
|
1865
|
+
this.#registerLoadFunc("image", async (mtrl, assets) => {
|
|
1866
|
+
const href = assets[mtrl.href]?.value || mtrl.href;
|
|
1867
|
+
const content = await loadImage(href);
|
|
2001
1868
|
return {
|
|
2002
|
-
|
|
1869
|
+
id: mtrl.id,
|
|
2003
1870
|
lastModified: Date.now(),
|
|
2004
1871
|
content
|
|
2005
1872
|
};
|
|
2006
1873
|
});
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
const
|
|
1874
|
+
this.#registerLoadFunc(
|
|
1875
|
+
"foreignObject",
|
|
1876
|
+
async (mtrl, assets) => {
|
|
1877
|
+
const html2 = assets[mtrl.content]?.value || mtrl.content;
|
|
1878
|
+
const content = await loadForeignObject(html2, {
|
|
1879
|
+
width: mtrl.originW || mtrl.width,
|
|
1880
|
+
height: mtrl.originH || mtrl.height
|
|
1881
|
+
});
|
|
1882
|
+
return {
|
|
1883
|
+
id: mtrl.id,
|
|
1884
|
+
lastModified: Date.now(),
|
|
1885
|
+
content
|
|
1886
|
+
};
|
|
1887
|
+
}
|
|
1888
|
+
);
|
|
1889
|
+
this.#registerLoadFunc("svgCode", async (mtrl, assets) => {
|
|
1890
|
+
const svg2 = assets[mtrl.code]?.value || mtrl.code;
|
|
1891
|
+
const content = await loadSVGCode(svg2);
|
|
2024
1892
|
return {
|
|
2025
|
-
|
|
1893
|
+
id: mtrl.id,
|
|
2026
1894
|
lastModified: Date.now(),
|
|
2027
1895
|
content
|
|
2028
1896
|
};
|
|
2029
1897
|
});
|
|
2030
1898
|
}
|
|
2031
1899
|
isDestroyed() {
|
|
2032
|
-
return
|
|
1900
|
+
return this.#hasDestroyed;
|
|
2033
1901
|
}
|
|
2034
1902
|
reset() {
|
|
2035
|
-
if (
|
|
1903
|
+
if (this.#hasDestroyed === true) {
|
|
2036
1904
|
return;
|
|
2037
1905
|
}
|
|
2038
|
-
|
|
2039
|
-
|
|
1906
|
+
this.#currentLoadItemMap = {};
|
|
1907
|
+
this.#storageLoadItemMap = {};
|
|
2040
1908
|
}
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
if (supportElementTypes.includes(element2.type)) {
|
|
1909
|
+
resetMaterialAsset(material2) {
|
|
1910
|
+
if (supportMaterialTypes.includes(material2.type)) {
|
|
2044
1911
|
let assetId = null;
|
|
2045
1912
|
let resource = null;
|
|
2046
|
-
if (
|
|
2047
|
-
resource =
|
|
2048
|
-
} else if (
|
|
2049
|
-
resource =
|
|
2050
|
-
} else if (
|
|
2051
|
-
resource =
|
|
1913
|
+
if (material2.type === "image" && typeof material2?.href === "string") {
|
|
1914
|
+
resource = material2.href;
|
|
1915
|
+
} else if (material2.type === "svgCode" && typeof material2?.code === "string") {
|
|
1916
|
+
resource = material2.code;
|
|
1917
|
+
} else if (material2.type === "foreignObject" && typeof material2?.content === "string") {
|
|
1918
|
+
resource = material2.content;
|
|
2052
1919
|
}
|
|
2053
1920
|
if (typeof resource === "string") {
|
|
2054
|
-
this.load(
|
|
1921
|
+
this.load(material2, {});
|
|
2055
1922
|
if (isAssetId(resource)) {
|
|
2056
1923
|
assetId = resource;
|
|
2057
|
-
} else if (
|
|
2058
|
-
assetId = createAssetId(resource,
|
|
1924
|
+
} else if (material2.id) {
|
|
1925
|
+
assetId = createAssetId(resource, material2.id);
|
|
2059
1926
|
}
|
|
2060
1927
|
}
|
|
2061
1928
|
if (assetId && isAssetId(assetId)) {
|
|
2062
|
-
delete
|
|
2063
|
-
delete
|
|
1929
|
+
delete this.#storageLoadItemMap[assetId];
|
|
1930
|
+
delete this.#currentLoadItemMap[assetId];
|
|
2064
1931
|
}
|
|
2065
1932
|
}
|
|
2066
1933
|
}
|
|
2067
1934
|
destroy() {
|
|
2068
|
-
|
|
1935
|
+
this.#hasDestroyed = true;
|
|
2069
1936
|
this.clear();
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
1937
|
+
this.#loadFuncMap = null;
|
|
1938
|
+
this.#currentLoadItemMap = null;
|
|
1939
|
+
this.#storageLoadItemMap = null;
|
|
1940
|
+
}
|
|
1941
|
+
#registerLoadFunc(type2, func) {
|
|
1942
|
+
this.#loadFuncMap[type2] = func;
|
|
1943
|
+
}
|
|
1944
|
+
#getLoadMaterialSource(material2) {
|
|
1945
|
+
let source = null;
|
|
1946
|
+
if (material2.type === "image") {
|
|
1947
|
+
source = material2?.href || null;
|
|
1948
|
+
} else if (material2.type === "svgCode") {
|
|
1949
|
+
source = material2?.code || null;
|
|
1950
|
+
} else if (material2.type === "foreignObject") {
|
|
1951
|
+
source = material2?.content || null;
|
|
1952
|
+
}
|
|
1953
|
+
return source;
|
|
1954
|
+
}
|
|
1955
|
+
#createLoadItem(material2) {
|
|
1956
|
+
return {
|
|
1957
|
+
material: material2,
|
|
1958
|
+
status: "null",
|
|
1959
|
+
content: null,
|
|
1960
|
+
error: null,
|
|
1961
|
+
startTime: -1,
|
|
1962
|
+
endTime: -1,
|
|
1963
|
+
source: this.#getLoadMaterialSource(material2)
|
|
1964
|
+
};
|
|
1965
|
+
}
|
|
1966
|
+
#emitLoad(item) {
|
|
1967
|
+
const assetId = getAssetIdFromMaterial(item.material);
|
|
1968
|
+
const storageItem = this.#storageLoadItemMap[assetId];
|
|
1969
|
+
if (!this.#hasDestroyed) {
|
|
1970
|
+
if (storageItem) {
|
|
1971
|
+
if (storageItem.startTime < item.startTime) {
|
|
1972
|
+
this.#storageLoadItemMap[assetId] = item;
|
|
1973
|
+
this.trigger("load", { ...item, countTime: item.endTime - item.startTime });
|
|
1974
|
+
}
|
|
1975
|
+
} else {
|
|
1976
|
+
this.#storageLoadItemMap[assetId] = item;
|
|
1977
|
+
this.trigger("load", { ...item, countTime: item.endTime - item.startTime });
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
#emitError(item) {
|
|
1982
|
+
const assetId = getAssetIdFromMaterial(item.material);
|
|
1983
|
+
const storageItem = this.#storageLoadItemMap?.[assetId];
|
|
1984
|
+
if (!this.#hasDestroyed) {
|
|
1985
|
+
if (storageItem) {
|
|
1986
|
+
if (storageItem.startTime < item.startTime) {
|
|
1987
|
+
this.#storageLoadItemMap[assetId] = item;
|
|
1988
|
+
this.trigger("error", { ...item, countTime: item.endTime - item.startTime });
|
|
1989
|
+
}
|
|
1990
|
+
} else {
|
|
1991
|
+
this.#storageLoadItemMap[assetId] = item;
|
|
1992
|
+
this.trigger("error", { ...item, countTime: item.endTime - item.startTime });
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
#loadResource(material2, assets) {
|
|
1997
|
+
const item = this.#createLoadItem(material2);
|
|
1998
|
+
const assetId = getAssetIdFromMaterial(material2);
|
|
1999
|
+
if (this.#currentLoadItemMap[assetId]) {
|
|
2000
|
+
return;
|
|
2001
|
+
}
|
|
2002
|
+
this.#currentLoadItemMap[assetId] = item;
|
|
2003
|
+
const loadFunc = this.#loadFuncMap[material2.type];
|
|
2004
|
+
if (typeof loadFunc === "function" && !this.#hasDestroyed) {
|
|
2005
|
+
item.startTime = Date.now();
|
|
2006
|
+
loadFunc(material2, assets).then((result) => {
|
|
2007
|
+
if (!this.#hasDestroyed) {
|
|
2008
|
+
item.content = result.content;
|
|
2009
|
+
item.endTime = Date.now();
|
|
2010
|
+
item.status = "load";
|
|
2011
|
+
this.#emitLoad(item);
|
|
2012
|
+
}
|
|
2013
|
+
}).catch((err) => {
|
|
2014
|
+
console.warn(`Load material source "${item.source}" fail`, err, material2);
|
|
2015
|
+
item.endTime = Date.now();
|
|
2016
|
+
item.status = "error";
|
|
2017
|
+
item.error = err;
|
|
2018
|
+
this.#emitError(item);
|
|
2019
|
+
});
|
|
2020
|
+
}
|
|
2073
2021
|
}
|
|
2074
|
-
|
|
2075
|
-
|
|
2022
|
+
#isExistingErrorStorage(material2) {
|
|
2023
|
+
const assetId = getAssetIdFromMaterial(material2);
|
|
2024
|
+
const existItem = this.#currentLoadItemMap?.[assetId];
|
|
2025
|
+
if (existItem && existItem.status === "error" && existItem.source && existItem.source === this.#getLoadMaterialSource(material2)) {
|
|
2026
|
+
return true;
|
|
2027
|
+
}
|
|
2028
|
+
return false;
|
|
2029
|
+
}
|
|
2030
|
+
load(material2, assets) {
|
|
2031
|
+
if (this.#hasDestroyed === true) {
|
|
2076
2032
|
return;
|
|
2077
2033
|
}
|
|
2078
|
-
if (
|
|
2034
|
+
if (this.#isExistingErrorStorage(material2)) {
|
|
2079
2035
|
return;
|
|
2080
2036
|
}
|
|
2081
|
-
if (
|
|
2082
|
-
|
|
2037
|
+
if (supportMaterialTypes.includes(material2.type)) {
|
|
2038
|
+
this.#loadResource(material2, assets);
|
|
2083
2039
|
}
|
|
2084
2040
|
}
|
|
2085
|
-
getContent(
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
return ((_b = (_a = __privateGet(this, _storageLoadItemMap)) == null ? void 0 : _a[assetId]) == null ? void 0 : _b.content) || null;
|
|
2041
|
+
getContent(material2) {
|
|
2042
|
+
const assetId = getAssetIdFromMaterial(material2);
|
|
2043
|
+
return this.#storageLoadItemMap?.[assetId]?.content || null;
|
|
2089
2044
|
}
|
|
2090
2045
|
getLoadItemMap() {
|
|
2091
|
-
return
|
|
2046
|
+
return this.#storageLoadItemMap;
|
|
2092
2047
|
}
|
|
2093
2048
|
setLoadItemMap(itemMap) {
|
|
2094
|
-
|
|
2049
|
+
this.#storageLoadItemMap = itemMap;
|
|
2095
2050
|
}
|
|
2096
2051
|
}
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
};
|
|
2105
|
-
getLoadElementSource_fn = function(element2) {
|
|
2106
|
-
var _a, _b, _c;
|
|
2107
|
-
let source = null;
|
|
2108
|
-
if (element2.type === "image") {
|
|
2109
|
-
source = ((_a = element2 == null ? void 0 : element2.detail) == null ? void 0 : _a.src) || null;
|
|
2110
|
-
} else if (element2.type === "svg") {
|
|
2111
|
-
source = ((_b = element2 == null ? void 0 : element2.detail) == null ? void 0 : _b.svg) || null;
|
|
2112
|
-
} else if (element2.type === "html") {
|
|
2113
|
-
source = ((_c = element2 == null ? void 0 : element2.detail) == null ? void 0 : _c.html) || null;
|
|
2114
|
-
}
|
|
2115
|
-
return source;
|
|
2116
|
-
};
|
|
2117
|
-
createLoadItem_fn = function(element2) {
|
|
2118
|
-
return {
|
|
2119
|
-
element: element2,
|
|
2120
|
-
status: "null",
|
|
2121
|
-
content: null,
|
|
2122
|
-
error: null,
|
|
2123
|
-
startTime: -1,
|
|
2124
|
-
endTime: -1,
|
|
2125
|
-
source: __privateMethod(this, _Loader_instances, getLoadElementSource_fn).call(this, element2)
|
|
2126
|
-
};
|
|
2127
|
-
};
|
|
2128
|
-
emitLoad_fn = function(item) {
|
|
2129
|
-
const assetId = getAssetIdFromElement(item.element);
|
|
2130
|
-
const storageItem = __privateGet(this, _storageLoadItemMap)[assetId];
|
|
2131
|
-
if (!__privateGet(this, _hasDestroyed)) {
|
|
2132
|
-
if (storageItem) {
|
|
2133
|
-
if (storageItem.startTime < item.startTime) {
|
|
2134
|
-
__privateGet(this, _storageLoadItemMap)[assetId] = item;
|
|
2135
|
-
this.trigger("load", { ...item, countTime: item.endTime - item.startTime });
|
|
2136
|
-
}
|
|
2137
|
-
} else {
|
|
2138
|
-
__privateGet(this, _storageLoadItemMap)[assetId] = item;
|
|
2139
|
-
this.trigger("load", { ...item, countTime: item.endTime - item.startTime });
|
|
2140
|
-
}
|
|
2052
|
+
function calculateWorldPosition(targetRect, parents) {
|
|
2053
|
+
parents = [...parents].reverse();
|
|
2054
|
+
if (!parents || parents.length === 0) {
|
|
2055
|
+
return {
|
|
2056
|
+
x: targetRect.x + targetRect.width / 2,
|
|
2057
|
+
y: targetRect.y + targetRect.height / 2
|
|
2058
|
+
};
|
|
2141
2059
|
}
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2060
|
+
let centerX = targetRect.x + targetRect.width / 2;
|
|
2061
|
+
let centerY = targetRect.y + targetRect.height / 2;
|
|
2062
|
+
for (let i = 0; i < parents.length; i++) {
|
|
2063
|
+
const parent = parents[i];
|
|
2064
|
+
const transformed = applyRectTransformation({ x: centerX, y: centerY }, parent);
|
|
2065
|
+
centerX = transformed.x;
|
|
2066
|
+
centerY = transformed.y;
|
|
2067
|
+
}
|
|
2068
|
+
return { x: centerX, y: centerY };
|
|
2069
|
+
}
|
|
2070
|
+
function applyRectTransformation(point, rect) {
|
|
2071
|
+
const rectCenterX = rect.width / 2;
|
|
2072
|
+
const rectCenterY = rect.height / 2;
|
|
2073
|
+
const centeredX = point.x - rectCenterX;
|
|
2074
|
+
const centeredY = point.y - rectCenterY;
|
|
2075
|
+
let rotatedX = centeredX;
|
|
2076
|
+
let rotatedY = centeredY;
|
|
2077
|
+
if (typeof rect.angle === "number" && rect.angle !== 0) {
|
|
2078
|
+
const angleRad = rect.angle * Math.PI / 180;
|
|
2079
|
+
const cos = Math.cos(angleRad);
|
|
2080
|
+
const sin = Math.sin(angleRad);
|
|
2081
|
+
rotatedX = centeredX * cos - centeredY * sin;
|
|
2082
|
+
rotatedY = centeredX * sin + centeredY * cos;
|
|
2083
|
+
}
|
|
2084
|
+
const localX = rotatedX + rectCenterX;
|
|
2085
|
+
const localY = rotatedY + rectCenterY;
|
|
2086
|
+
const worldX = localX + rect.x;
|
|
2087
|
+
const worldY = localY + rect.y;
|
|
2088
|
+
return { x: worldX, y: worldY };
|
|
2089
|
+
}
|
|
2090
|
+
function calcVirtualBaseAttributes(mtrl, opts) {
|
|
2091
|
+
const { groupQueue = [] } = opts;
|
|
2092
|
+
let worldAngle = mtrl.angle || 0;
|
|
2093
|
+
groupQueue.forEach((group) => {
|
|
2094
|
+
worldAngle += group.angle || 0;
|
|
2095
|
+
});
|
|
2096
|
+
const worldCenter = calculateWorldPosition(mtrl, groupQueue);
|
|
2097
|
+
const attributes = {
|
|
2098
|
+
worldCenter,
|
|
2099
|
+
worldAngle: limitAngle(worldAngle)
|
|
2100
|
+
};
|
|
2101
|
+
return attributes;
|
|
2102
|
+
}
|
|
2103
|
+
function calcVirtualRectAttributes(mtrl, opts) {
|
|
2104
|
+
const { dpr } = opts;
|
|
2105
|
+
let {
|
|
2106
|
+
// x,
|
|
2107
|
+
// y,
|
|
2108
|
+
width: width2,
|
|
2109
|
+
height: height2,
|
|
2110
|
+
rx = 0,
|
|
2111
|
+
ry = 0
|
|
2112
|
+
} = mtrl;
|
|
2113
|
+
const { cornerRadius: cornerRadius2 } = mtrl;
|
|
2114
|
+
const x2 = 0;
|
|
2115
|
+
const y2 = 0;
|
|
2116
|
+
height2 = height2 * dpr;
|
|
2117
|
+
width2 = width2 * dpr;
|
|
2118
|
+
const commands = [];
|
|
2119
|
+
let tlRX = 0;
|
|
2120
|
+
let trRX = 0;
|
|
2121
|
+
let brRX = 0;
|
|
2122
|
+
let blRX = 0;
|
|
2123
|
+
let tlRY = 0;
|
|
2124
|
+
let trRY = 0;
|
|
2125
|
+
let brRY = 0;
|
|
2126
|
+
let blRY = 0;
|
|
2127
|
+
if (typeof rx === "number" && typeof ry === "number") {
|
|
2128
|
+
rx = rx * dpr;
|
|
2129
|
+
ry = ry * dpr;
|
|
2130
|
+
tlRX = rx;
|
|
2131
|
+
trRX = rx;
|
|
2132
|
+
brRX = rx;
|
|
2133
|
+
blRX = rx;
|
|
2134
|
+
tlRY = ry;
|
|
2135
|
+
trRY = ry;
|
|
2136
|
+
brRY = ry;
|
|
2137
|
+
blRY = ry;
|
|
2138
|
+
} else if (Array.isArray(cornerRadius2) && cornerRadius2.length === 4) {
|
|
2139
|
+
const crs = cornerRadius2.map((r) => r * dpr);
|
|
2140
|
+
tlRX = crs[0] || 0;
|
|
2141
|
+
trRX = crs[1] || 0;
|
|
2142
|
+
brRX = crs[2] || 0;
|
|
2143
|
+
blRX = crs[3] || 0;
|
|
2144
|
+
tlRY = crs[0] || 0;
|
|
2145
|
+
trRY = crs[1] || 0;
|
|
2146
|
+
brRY = crs[2] || 0;
|
|
2147
|
+
blRY = crs[3] || 0;
|
|
2148
|
+
} else if (typeof cornerRadius2 === "number") {
|
|
2149
|
+
const cr = cornerRadius2 * dpr;
|
|
2150
|
+
tlRX = cr;
|
|
2151
|
+
trRX = cr;
|
|
2152
|
+
brRX = cr;
|
|
2153
|
+
blRX = cr;
|
|
2154
|
+
tlRY = cr;
|
|
2155
|
+
trRY = cr;
|
|
2156
|
+
brRY = cr;
|
|
2157
|
+
blRY = cr;
|
|
2158
|
+
}
|
|
2159
|
+
const x0 = x2;
|
|
2160
|
+
const y0 = y2;
|
|
2161
|
+
const x1 = x2 + width2;
|
|
2162
|
+
const y1 = y2 + height2;
|
|
2163
|
+
commands.push({
|
|
2164
|
+
id: createId(),
|
|
2165
|
+
type: "M",
|
|
2166
|
+
params: [x2 + tlRX, y2]
|
|
2167
|
+
});
|
|
2168
|
+
if (trRX > 0 || trRY > 0) {
|
|
2169
|
+
commands.push({
|
|
2170
|
+
id: createId(),
|
|
2171
|
+
type: "L",
|
|
2172
|
+
params: [x1 - trRX, y0]
|
|
2173
|
+
});
|
|
2174
|
+
commands.push({
|
|
2175
|
+
id: createId(),
|
|
2176
|
+
type: "A",
|
|
2177
|
+
params: [trRX, trRY, 0, 0, 1, x1, y0 + trRY]
|
|
2178
|
+
});
|
|
2179
|
+
} else {
|
|
2180
|
+
commands.push({
|
|
2181
|
+
id: createId(),
|
|
2182
|
+
type: "L",
|
|
2183
|
+
params: [x1, y0]
|
|
2184
|
+
});
|
|
2157
2185
|
}
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2186
|
+
if (brRX > 0 || brRY > 0) {
|
|
2187
|
+
commands.push({
|
|
2188
|
+
id: createId(),
|
|
2189
|
+
type: "L",
|
|
2190
|
+
params: [x1, y1 - brRY]
|
|
2191
|
+
});
|
|
2192
|
+
commands.push({
|
|
2193
|
+
id: createId(),
|
|
2194
|
+
type: "A",
|
|
2195
|
+
params: [brRX, brRY, 0, 0, 1, x1 - brRX, y1]
|
|
2196
|
+
});
|
|
2197
|
+
} else {
|
|
2198
|
+
commands.push({
|
|
2199
|
+
id: createId(),
|
|
2200
|
+
type: "L",
|
|
2201
|
+
params: [x1, y1]
|
|
2202
|
+
});
|
|
2164
2203
|
}
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
__privateMethod(this, _Loader_instances, emitError_fn).call(this, item);
|
|
2204
|
+
if (blRX > 0 || blRY > 0) {
|
|
2205
|
+
commands.push({
|
|
2206
|
+
id: createId(),
|
|
2207
|
+
type: "L",
|
|
2208
|
+
params: [x0 + blRX, y1]
|
|
2209
|
+
});
|
|
2210
|
+
commands.push({
|
|
2211
|
+
id: createId(),
|
|
2212
|
+
type: "A",
|
|
2213
|
+
params: [blRX, blRY, 0, 0, 1, x0, y1 - blRY]
|
|
2214
|
+
});
|
|
2215
|
+
} else {
|
|
2216
|
+
commands.push({
|
|
2217
|
+
id: createId(),
|
|
2218
|
+
type: "L",
|
|
2219
|
+
params: [x0, y1]
|
|
2182
2220
|
});
|
|
2183
2221
|
}
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2222
|
+
if (tlRX > 0 || tlRY > 0) {
|
|
2223
|
+
commands.push({
|
|
2224
|
+
id: createId(),
|
|
2225
|
+
type: "L",
|
|
2226
|
+
params: [x0, y0 + tlRY]
|
|
2227
|
+
});
|
|
2228
|
+
commands.push({
|
|
2229
|
+
id: createId(),
|
|
2230
|
+
type: "A",
|
|
2231
|
+
params: [tlRX, tlRY, 0, 0, 1, x0 + tlRX, y0]
|
|
2232
|
+
});
|
|
2233
|
+
} else {
|
|
2234
|
+
commands.push({
|
|
2235
|
+
id: createId(),
|
|
2236
|
+
type: "L",
|
|
2237
|
+
params: [x0, y0]
|
|
2238
|
+
});
|
|
2191
2239
|
}
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2240
|
+
commands.push({
|
|
2241
|
+
id: createId(),
|
|
2242
|
+
type: "Z",
|
|
2243
|
+
params: []
|
|
2244
|
+
});
|
|
2245
|
+
const attributes = {
|
|
2246
|
+
...calcVirtualBaseAttributes(mtrl, opts),
|
|
2247
|
+
commands
|
|
2248
|
+
};
|
|
2249
|
+
return attributes;
|
|
2250
|
+
}
|
|
2251
|
+
function calcVirtualCircleAttributes(mtrl, opts) {
|
|
2252
|
+
const { dpr } = opts;
|
|
2253
|
+
const { width: width2, height: height2 } = mtrl;
|
|
2254
|
+
let { r } = mtrl;
|
|
2255
|
+
const cx = width2 / 2 * dpr;
|
|
2256
|
+
const cy = height2 / 2 * dpr;
|
|
2257
|
+
r = r * dpr;
|
|
2258
|
+
const c = r * 0.55228475;
|
|
2259
|
+
const commands = [
|
|
2260
|
+
// M - Move to starting point (right side of circle)
|
|
2261
|
+
{
|
|
2262
|
+
type: "M",
|
|
2263
|
+
params: [cx + r, cy]
|
|
2264
|
+
},
|
|
2265
|
+
// C - Cubic Bezier curve to top point
|
|
2266
|
+
{
|
|
2267
|
+
type: "C",
|
|
2268
|
+
params: [cx + r, cy - c, cx + c, cy - r, cx, cy - r]
|
|
2269
|
+
},
|
|
2270
|
+
// C - Cubic Bezier curve to left point
|
|
2271
|
+
{
|
|
2272
|
+
type: "C",
|
|
2273
|
+
params: [cx - c, cy - r, cx - r, cy - c, cx - r, cy]
|
|
2274
|
+
},
|
|
2275
|
+
// C - Cubic Bezier curve to bottom point
|
|
2276
|
+
{
|
|
2277
|
+
type: "C",
|
|
2278
|
+
params: [cx - r, cy + c, cx - c, cy + r, cx, cy + r]
|
|
2279
|
+
},
|
|
2280
|
+
// C - Cubic Bezier curve back to starting point
|
|
2281
|
+
{
|
|
2282
|
+
type: "C",
|
|
2283
|
+
params: [cx + c, cy + r, cx + r, cy + c, cx + r, cy]
|
|
2284
|
+
},
|
|
2285
|
+
{
|
|
2286
|
+
type: "Z",
|
|
2287
|
+
params: []
|
|
2288
|
+
}
|
|
2289
|
+
];
|
|
2290
|
+
const attributes = {
|
|
2291
|
+
...calcVirtualBaseAttributes(mtrl, opts),
|
|
2292
|
+
commands
|
|
2293
|
+
};
|
|
2294
|
+
return attributes;
|
|
2295
|
+
}
|
|
2296
|
+
function calcVirtualEllipseAttributes(mtrl, opts) {
|
|
2297
|
+
const { dpr } = opts;
|
|
2298
|
+
const { width: width2, height: height2 } = mtrl;
|
|
2299
|
+
let { rx, ry } = mtrl;
|
|
2300
|
+
const cx = width2 / 2 * dpr;
|
|
2301
|
+
const cy = height2 / 2 * dpr;
|
|
2302
|
+
rx = rx * dpr;
|
|
2303
|
+
ry = ry * dpr;
|
|
2304
|
+
const kx = 0.55228475 * rx;
|
|
2305
|
+
const ky = 0.55228475 * ry;
|
|
2306
|
+
const commands = [
|
|
2307
|
+
// M - Move to right point
|
|
2308
|
+
{
|
|
2309
|
+
type: "M",
|
|
2310
|
+
params: [cx + rx, cy]
|
|
2311
|
+
},
|
|
2312
|
+
// C - Cubic Bezier curve to top point
|
|
2313
|
+
{
|
|
2314
|
+
type: "C",
|
|
2315
|
+
params: [cx + rx, cy - ky, cx + kx, cy - ry, cx, cy - ry]
|
|
2316
|
+
},
|
|
2317
|
+
// C - Cubic Bezier curve to left point
|
|
2318
|
+
{
|
|
2319
|
+
type: "C",
|
|
2320
|
+
params: [cx - kx, cy - ry, cx - rx, cy - ky, cx - rx, cy]
|
|
2321
|
+
},
|
|
2322
|
+
// C - Cubic Bezier curve to bottom point
|
|
2323
|
+
{
|
|
2324
|
+
type: "C",
|
|
2325
|
+
params: [cx - rx, cy + ky, cx - kx, cy + ry, cx, cy + ry]
|
|
2326
|
+
},
|
|
2327
|
+
// C - Cubic Bezier curve back to starting point
|
|
2328
|
+
{
|
|
2329
|
+
type: "C",
|
|
2330
|
+
params: [cx + kx, cy + ry, cx + rx, cy + ky, cx + rx, cy]
|
|
2331
|
+
},
|
|
2332
|
+
{
|
|
2333
|
+
type: "Z",
|
|
2334
|
+
params: []
|
|
2335
|
+
}
|
|
2336
|
+
];
|
|
2337
|
+
const attributes = {
|
|
2338
|
+
...calcVirtualBaseAttributes(mtrl, opts),
|
|
2339
|
+
commands
|
|
2340
|
+
};
|
|
2341
|
+
return attributes;
|
|
2342
|
+
}
|
|
2343
|
+
const attributesConfig = getDefaultMaterialAttributes();
|
|
2195
2344
|
function isTextWidthWithinErrorRange(w0, w1, scale) {
|
|
2196
2345
|
return w0 >= w1;
|
|
2197
2346
|
}
|
|
2198
|
-
function
|
|
2199
|
-
const {
|
|
2347
|
+
function calcVirtualTextAttributes(mtrl, opts) {
|
|
2348
|
+
const { width: width2, height: height2 } = mtrl;
|
|
2200
2349
|
const x2 = 0;
|
|
2201
2350
|
const y2 = 0;
|
|
2202
2351
|
const ctx = opts.tempContext;
|
|
2203
2352
|
const lines = [];
|
|
2204
|
-
const
|
|
2205
|
-
...
|
|
2206
|
-
...
|
|
2353
|
+
const attributes = {
|
|
2354
|
+
...attributesConfig,
|
|
2355
|
+
...mtrl
|
|
2207
2356
|
};
|
|
2208
|
-
const originFontSize =
|
|
2357
|
+
const originFontSize = attributes.fontSize || attributesConfig.fontSize;
|
|
2209
2358
|
const fontSize2 = originFontSize;
|
|
2359
|
+
const baseAttrs = calcVirtualRectAttributes(mtrl, opts);
|
|
2210
2360
|
if (fontSize2 < 2) {
|
|
2211
|
-
return {};
|
|
2361
|
+
return { ...baseAttrs, textLines: [] };
|
|
2212
2362
|
}
|
|
2213
|
-
const originLineHeight =
|
|
2363
|
+
const originLineHeight = attributes.lineHeight || originFontSize;
|
|
2214
2364
|
const lineHeight2 = originLineHeight;
|
|
2215
2365
|
ctx.textBaseline = "top";
|
|
2216
2366
|
ctx.$setFont({
|
|
2217
|
-
fontWeight:
|
|
2367
|
+
fontWeight: attributes.fontWeight,
|
|
2218
2368
|
fontSize: fontSize2,
|
|
2219
|
-
fontFamily: enhanceFontFamliy(
|
|
2369
|
+
fontFamily: enhanceFontFamliy(attributes.fontFamily)
|
|
2220
2370
|
});
|
|
2221
|
-
let
|
|
2222
|
-
if (
|
|
2223
|
-
|
|
2224
|
-
} else if (
|
|
2225
|
-
|
|
2371
|
+
let attributesText = attributes.text.replace(/\r\n/gi, "\n");
|
|
2372
|
+
if (attributes.textTransform === "lowercase") {
|
|
2373
|
+
attributesText = attributesText.toLowerCase();
|
|
2374
|
+
} else if (attributes.textTransform === "uppercase") {
|
|
2375
|
+
attributesText = attributesText.toUpperCase();
|
|
2226
2376
|
}
|
|
2227
2377
|
const fontHeight = lineHeight2;
|
|
2228
|
-
const
|
|
2378
|
+
const attributesTextList = attributesText.split("\n");
|
|
2229
2379
|
let lineNum = 0;
|
|
2230
|
-
|
|
2231
|
-
if (
|
|
2380
|
+
attributesTextList.forEach((itemText, idx) => {
|
|
2381
|
+
if (attributes.minInlineSize === "maxContent") {
|
|
2382
|
+
const measureResult = ctx.measureText(itemText);
|
|
2232
2383
|
lines.push({
|
|
2233
2384
|
x: x2,
|
|
2234
2385
|
y: 0,
|
|
2235
|
-
// TODO
|
|
2236
2386
|
text: itemText,
|
|
2237
|
-
width: ctx.$undoPixelRatio(
|
|
2387
|
+
width: ctx.$undoPixelRatio(measureResult.width)
|
|
2238
2388
|
});
|
|
2239
2389
|
} else {
|
|
2240
2390
|
let lineText = "";
|
|
2241
2391
|
let splitStr = "";
|
|
2242
|
-
let
|
|
2243
|
-
if (
|
|
2392
|
+
let tempCharList = itemText.split(splitStr);
|
|
2393
|
+
if (attributes.wordBreak === "normal") {
|
|
2244
2394
|
splitStr = " ";
|
|
2245
2395
|
const wordList = itemText.split(splitStr);
|
|
2246
|
-
|
|
2396
|
+
tempCharList = [];
|
|
2247
2397
|
wordList.forEach((word, idx2) => {
|
|
2248
|
-
|
|
2398
|
+
tempCharList.push(word);
|
|
2249
2399
|
if (idx2 < wordList.length - 1) {
|
|
2250
|
-
|
|
2400
|
+
tempCharList.push(splitStr);
|
|
2251
2401
|
}
|
|
2252
2402
|
});
|
|
2253
2403
|
}
|
|
2254
|
-
if (
|
|
2404
|
+
if (tempCharList.length === 1 && attributes.overflow !== "hidden") {
|
|
2255
2405
|
lines.push({
|
|
2256
2406
|
x: x2,
|
|
2257
2407
|
y: 0,
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
width: ctx.$undoPixelRatio(ctx.measureText(tempStrList[0]).width)
|
|
2408
|
+
text: tempCharList[0],
|
|
2409
|
+
width: ctx.$undoPixelRatio(ctx.measureText(tempCharList[0]).width)
|
|
2261
2410
|
});
|
|
2262
|
-
} else if (
|
|
2263
|
-
for (let i = 0; i <
|
|
2264
|
-
if (isTextWidthWithinErrorRange(ctx.$doPixelRatio(
|
|
2265
|
-
lineText +=
|
|
2411
|
+
} else if (tempCharList.length > 0) {
|
|
2412
|
+
for (let i = 0; i < tempCharList.length; i++) {
|
|
2413
|
+
if (isTextWidthWithinErrorRange(ctx.$doPixelRatio(width2), ctx.measureText(lineText + tempCharList[i]).width)) {
|
|
2414
|
+
lineText += tempCharList[i] || "";
|
|
2266
2415
|
} else {
|
|
2267
2416
|
lines.push({
|
|
2268
2417
|
x: x2,
|
|
2269
2418
|
y: 0,
|
|
2270
|
-
// TODO
|
|
2271
2419
|
text: lineText,
|
|
2272
2420
|
width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
|
|
2273
2421
|
});
|
|
2274
|
-
lineText =
|
|
2422
|
+
lineText = tempCharList[i] || "";
|
|
2275
2423
|
lineNum++;
|
|
2276
2424
|
}
|
|
2277
|
-
if (
|
|
2278
|
-
|
|
2425
|
+
if (lineNum * fontHeight >= height2) {
|
|
2426
|
+
if (attributes.overflow === "hidden") {
|
|
2427
|
+
lineText = "";
|
|
2428
|
+
break;
|
|
2429
|
+
}
|
|
2279
2430
|
}
|
|
2280
|
-
if (
|
|
2281
|
-
if ((lineNum + 1) * fontHeight <=
|
|
2431
|
+
if (tempCharList.length - 1 === i) {
|
|
2432
|
+
if ((lineNum + 1) * fontHeight <= height2) {
|
|
2282
2433
|
lines.push({
|
|
2283
2434
|
x: x2,
|
|
2284
2435
|
y: 0,
|
|
2285
|
-
// TODO
|
|
2286
2436
|
text: lineText,
|
|
2287
2437
|
width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
|
|
2288
2438
|
});
|
|
2289
|
-
|
|
2439
|
+
lineText = "";
|
|
2440
|
+
if (idx < attributesTextList.length - 1) {
|
|
2290
2441
|
lineNum++;
|
|
2291
2442
|
}
|
|
2292
2443
|
break;
|
|
2293
2444
|
}
|
|
2294
2445
|
}
|
|
2295
2446
|
}
|
|
2447
|
+
if (lineText) {
|
|
2448
|
+
lines.push({
|
|
2449
|
+
x: x2,
|
|
2450
|
+
y: 0,
|
|
2451
|
+
text: lineText,
|
|
2452
|
+
width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
|
|
2453
|
+
});
|
|
2454
|
+
lineText = "";
|
|
2455
|
+
}
|
|
2296
2456
|
} else {
|
|
2297
2457
|
lines.push({
|
|
2298
2458
|
x: x2,
|
|
2299
2459
|
y: 0,
|
|
2300
|
-
// TODO
|
|
2301
2460
|
text: "",
|
|
2302
2461
|
width: 0
|
|
2303
2462
|
});
|
|
@@ -2309,126 +2468,172 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2309
2468
|
if (fontHeight > fontSize2) {
|
|
2310
2469
|
eachLineStartY = (fontHeight - fontSize2) / 2;
|
|
2311
2470
|
}
|
|
2312
|
-
if (lines.length * fontHeight <
|
|
2313
|
-
if (
|
|
2471
|
+
if (lines.length * fontHeight < height2) {
|
|
2472
|
+
if (attributes.verticalAlign === "top") {
|
|
2314
2473
|
startY = 0;
|
|
2315
|
-
} else if (
|
|
2316
|
-
startY +=
|
|
2474
|
+
} else if (attributes.verticalAlign === "bottom") {
|
|
2475
|
+
startY += height2 - lines.length * fontHeight;
|
|
2317
2476
|
} else {
|
|
2318
|
-
startY += (
|
|
2477
|
+
startY += (height2 - lines.length * fontHeight) / 2;
|
|
2319
2478
|
}
|
|
2320
2479
|
}
|
|
2321
2480
|
{
|
|
2322
2481
|
const _y = y2 + startY;
|
|
2323
2482
|
lines.forEach((line, i) => {
|
|
2324
2483
|
let _x = x2;
|
|
2325
|
-
if (
|
|
2326
|
-
_x = x2 + (
|
|
2327
|
-
} else if (
|
|
2328
|
-
_x = x2 + (
|
|
2484
|
+
if (attributes.textAlign === "center") {
|
|
2485
|
+
_x = x2 + (width2 - line.width) / 2;
|
|
2486
|
+
} else if (attributes.textAlign === "right") {
|
|
2487
|
+
_x = x2 + (width2 - line.width);
|
|
2329
2488
|
}
|
|
2330
2489
|
lines[i].x = _x;
|
|
2331
2490
|
lines[i].y = _y + fontHeight * i + eachLineStartY;
|
|
2332
2491
|
});
|
|
2333
2492
|
}
|
|
2334
|
-
const
|
|
2493
|
+
const virtualTextAttributes = {
|
|
2494
|
+
...baseAttrs,
|
|
2335
2495
|
textLines: lines
|
|
2336
2496
|
};
|
|
2337
|
-
return
|
|
2338
|
-
}
|
|
2339
|
-
function
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2497
|
+
return virtualTextAttributes;
|
|
2498
|
+
}
|
|
2499
|
+
function calcVirtualPathAttributes(mtrl, opts) {
|
|
2500
|
+
const { dpr } = opts;
|
|
2501
|
+
const attributes = { ...calcVirtualBaseAttributes(mtrl, opts), anchorCommands: [] };
|
|
2502
|
+
const anchorCommands = convertPathCommandsToACLMZ(mtrl.commands || []);
|
|
2503
|
+
attributes.anchorCommands = anchorCommands;
|
|
2504
|
+
attributes.commands = scalePathCommands(mtrl.commands, dpr, dpr);
|
|
2505
|
+
return attributes;
|
|
2506
|
+
}
|
|
2507
|
+
function calcVirtualAttributes(mtrl, opts) {
|
|
2508
|
+
let attributes = null;
|
|
2509
|
+
switch (mtrl.type) {
|
|
2510
|
+
case "rect": {
|
|
2511
|
+
attributes = calcVirtualRectAttributes(mtrl, opts);
|
|
2512
|
+
break;
|
|
2513
|
+
}
|
|
2514
|
+
case "circle": {
|
|
2515
|
+
attributes = calcVirtualCircleAttributes(mtrl, opts);
|
|
2516
|
+
break;
|
|
2517
|
+
}
|
|
2518
|
+
case "ellipse": {
|
|
2519
|
+
attributes = calcVirtualEllipseAttributes(mtrl, opts);
|
|
2520
|
+
break;
|
|
2521
|
+
}
|
|
2522
|
+
case "text": {
|
|
2523
|
+
attributes = calcVirtualTextAttributes(mtrl, opts);
|
|
2524
|
+
break;
|
|
2525
|
+
}
|
|
2526
|
+
case "group": {
|
|
2527
|
+
attributes = calcVirtualRectAttributes(mtrl, opts);
|
|
2528
|
+
break;
|
|
2529
|
+
}
|
|
2530
|
+
case "path": {
|
|
2531
|
+
attributes = calcVirtualPathAttributes(mtrl, opts);
|
|
2532
|
+
break;
|
|
2533
|
+
}
|
|
2534
|
+
default: {
|
|
2535
|
+
attributes = calcVirtualBaseAttributes(mtrl, opts);
|
|
2536
|
+
break;
|
|
2537
|
+
}
|
|
2343
2538
|
}
|
|
2344
|
-
return
|
|
2539
|
+
return attributes;
|
|
2345
2540
|
}
|
|
2346
|
-
function
|
|
2541
|
+
function materialsToVirtualFlatMap(materials, opts) {
|
|
2347
2542
|
const virtualFlatMap = {};
|
|
2348
2543
|
const currentPosition = [];
|
|
2349
|
-
const _walk = (
|
|
2544
|
+
const _walk = (mtrl) => {
|
|
2350
2545
|
const baseInfo = {
|
|
2351
|
-
type:
|
|
2546
|
+
type: mtrl.type,
|
|
2352
2547
|
isVisibleInView: true,
|
|
2353
2548
|
position: [...currentPosition]
|
|
2354
2549
|
};
|
|
2355
|
-
let
|
|
2356
|
-
const groupQueue =
|
|
2357
|
-
|
|
2550
|
+
let boundingInfo = null;
|
|
2551
|
+
const groupQueue = getGroupQueueByMaterialPosition(materials, currentPosition);
|
|
2552
|
+
boundingInfo = calcMaterialBoundingInfo(mtrl, {
|
|
2358
2553
|
groupQueue: groupQueue || []
|
|
2359
2554
|
});
|
|
2360
2555
|
const virtualItem = {
|
|
2361
2556
|
...baseInfo,
|
|
2362
2557
|
...{
|
|
2363
|
-
|
|
2364
|
-
|
|
2558
|
+
boundingInfo,
|
|
2559
|
+
rangeBoundingInfo: is.angle(mtrl.angle) ? boundingInfoToRangeBoundingInfo(boundingInfo) : boundingInfo
|
|
2365
2560
|
},
|
|
2366
|
-
...
|
|
2561
|
+
...calcVirtualAttributes(mtrl, {
|
|
2562
|
+
...opts,
|
|
2563
|
+
groupQueue: groupQueue || []
|
|
2564
|
+
})
|
|
2367
2565
|
};
|
|
2368
|
-
virtualFlatMap[
|
|
2369
|
-
if (
|
|
2370
|
-
|
|
2566
|
+
virtualFlatMap[mtrl.id] = virtualItem;
|
|
2567
|
+
if (mtrl.type === "group") {
|
|
2568
|
+
mtrl.children.forEach((ele, i) => {
|
|
2371
2569
|
currentPosition.push(i);
|
|
2372
2570
|
_walk(ele);
|
|
2373
2571
|
currentPosition.pop();
|
|
2374
2572
|
});
|
|
2375
2573
|
}
|
|
2376
2574
|
};
|
|
2377
|
-
|
|
2575
|
+
materials.forEach((mtrl, index) => {
|
|
2378
2576
|
currentPosition.push(index);
|
|
2379
|
-
_walk(
|
|
2577
|
+
_walk(mtrl);
|
|
2380
2578
|
currentPosition.pop();
|
|
2381
2579
|
});
|
|
2382
2580
|
return virtualFlatMap;
|
|
2383
2581
|
}
|
|
2384
|
-
function
|
|
2582
|
+
function sortMaterialsViewVisiableInfoMap(materials, opts) {
|
|
2385
2583
|
const { viewScaleInfo, viewSizeInfo, tempContext } = opts;
|
|
2386
|
-
const visibleInfoMap =
|
|
2387
|
-
|
|
2584
|
+
const visibleInfoMap = materialsToVirtualFlatMap(materials, {
|
|
2585
|
+
tempContext,
|
|
2586
|
+
dpr: viewSizeInfo.devicePixelRatio
|
|
2587
|
+
});
|
|
2588
|
+
return updateVirtualItemMapStatus(visibleInfoMap, { viewScaleInfo, viewSizeInfo });
|
|
2388
2589
|
}
|
|
2389
|
-
function
|
|
2590
|
+
function isRangeBoundingBoxCollide(info1, info2) {
|
|
2591
|
+
const centerX = info1.center.x;
|
|
2592
|
+
const centerY = info1.center.y;
|
|
2390
2593
|
const rect1MinX = Math.min(info1.topLeft.x, info1.topRight.x, info1.bottomLeft.x, info1.bottomRight.x);
|
|
2391
2594
|
const rect1MaxX = Math.max(info1.topLeft.x, info1.topRight.x, info1.bottomLeft.x, info1.bottomRight.x);
|
|
2392
2595
|
const rect1MinY = Math.min(info1.topLeft.y, info1.topRight.y, info1.bottomLeft.y, info1.bottomRight.y);
|
|
2393
2596
|
const rect1MaxY = Math.max(info1.topLeft.y, info1.topRight.y, info1.bottomLeft.y, info1.bottomRight.y);
|
|
2394
|
-
const
|
|
2395
|
-
const
|
|
2396
|
-
const
|
|
2397
|
-
const
|
|
2398
|
-
|
|
2597
|
+
const w = Math.abs(rect1MaxX - rect1MinX);
|
|
2598
|
+
const h = Math.abs(rect1MaxY - rect1MinY);
|
|
2599
|
+
const rect2MinX = Math.min(info2.topLeft.x, info2.topRight.x, info2.bottomLeft.x, info2.bottomRight.x) - w;
|
|
2600
|
+
const rect2MaxX = Math.max(info2.topLeft.x, info2.topRight.x, info2.bottomLeft.x, info2.bottomRight.x) + w;
|
|
2601
|
+
const rect2MinY = Math.min(info2.topLeft.y, info2.topRight.y, info2.bottomLeft.y, info2.bottomRight.y) - h;
|
|
2602
|
+
const rect2MaxY = Math.max(info2.topLeft.y, info2.topRight.y, info2.bottomLeft.y, info2.bottomRight.y) + h;
|
|
2603
|
+
if (centerX >= rect2MinX && centerX <= rect2MaxX && centerY >= rect2MinY && centerY <= rect2MaxY) {
|
|
2399
2604
|
return true;
|
|
2400
2605
|
}
|
|
2401
2606
|
return false;
|
|
2402
2607
|
}
|
|
2403
|
-
function
|
|
2404
|
-
const
|
|
2608
|
+
function updateVirtualItemMapStatus(virtualItemMap, opts) {
|
|
2609
|
+
const canvasBoundingBox = calcVisibleOriginCanvasBoundingBox(opts);
|
|
2405
2610
|
let visibleCount = 0;
|
|
2406
2611
|
let invisibleCount = 0;
|
|
2407
|
-
Object.keys(
|
|
2408
|
-
const info =
|
|
2409
|
-
info.isVisibleInView =
|
|
2612
|
+
Object.keys(virtualItemMap).forEach((id2) => {
|
|
2613
|
+
const info = virtualItemMap[id2];
|
|
2614
|
+
info.isVisibleInView = isRangeBoundingBoxCollide(info.rangeBoundingInfo, canvasBoundingBox);
|
|
2410
2615
|
info.isVisibleInView ? visibleCount++ : invisibleCount++;
|
|
2411
2616
|
});
|
|
2412
|
-
return {
|
|
2617
|
+
return { virtualItemMap, visibleCount, invisibleCount };
|
|
2413
2618
|
}
|
|
2414
|
-
function
|
|
2619
|
+
function calcVisibleOriginCanvasBoundingBox(opts) {
|
|
2415
2620
|
const { viewScaleInfo, viewSizeInfo } = opts;
|
|
2416
2621
|
const { scale, offsetTop, offsetLeft } = viewScaleInfo;
|
|
2417
|
-
const { width, height } = viewSizeInfo;
|
|
2622
|
+
const { width: width2, height: height2 } = viewSizeInfo;
|
|
2418
2623
|
const x2 = 0 - offsetLeft / scale;
|
|
2419
2624
|
const y2 = 0 - offsetTop / scale;
|
|
2420
|
-
const
|
|
2421
|
-
const
|
|
2422
|
-
const center =
|
|
2625
|
+
const w = width2 / scale;
|
|
2626
|
+
const h = height2 / scale;
|
|
2627
|
+
const center = calcMaterialCenter({ x: x2, y: y2, width: width2, height: height2 });
|
|
2423
2628
|
const topLeft = { x: x2, y: y2 };
|
|
2424
|
-
const topRight = { x: x2 +
|
|
2425
|
-
const bottomLeft = { x: x2, y: y2 +
|
|
2426
|
-
const bottomRight = { x: x2 +
|
|
2629
|
+
const topRight = { x: x2 + w, y: y2 };
|
|
2630
|
+
const bottomLeft = { x: x2, y: y2 + h };
|
|
2631
|
+
const bottomRight = { x: x2 + w, y: y2 + h };
|
|
2427
2632
|
const left = { x: x2, y: center.y };
|
|
2428
2633
|
const top = { x: center.x, y: y2 };
|
|
2429
|
-
const right = { x: x2 +
|
|
2430
|
-
const bottom = { x: center.x, y: y2 +
|
|
2431
|
-
const
|
|
2634
|
+
const right = { x: x2 + w, y: center.y };
|
|
2635
|
+
const bottom = { x: center.x, y: y2 + h };
|
|
2636
|
+
const boundingBox = {
|
|
2432
2637
|
center,
|
|
2433
2638
|
topLeft,
|
|
2434
2639
|
topRight,
|
|
@@ -2439,227 +2644,251 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2439
2644
|
right,
|
|
2440
2645
|
bottom
|
|
2441
2646
|
};
|
|
2442
|
-
return
|
|
2647
|
+
return boundingBox;
|
|
2443
2648
|
}
|
|
2444
2649
|
class Calculator {
|
|
2650
|
+
#opts;
|
|
2651
|
+
#store;
|
|
2445
2652
|
constructor(opts) {
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
__privateSet(this, _opts, opts);
|
|
2449
|
-
__privateSet(this, _store, new Store({
|
|
2653
|
+
this.#opts = opts;
|
|
2654
|
+
this.#store = new Store({
|
|
2450
2655
|
defaultStorage: {
|
|
2451
|
-
|
|
2656
|
+
virtualItemMap: {},
|
|
2452
2657
|
visibleCount: 0,
|
|
2453
2658
|
invisibleCount: 0
|
|
2454
2659
|
}
|
|
2455
|
-
})
|
|
2660
|
+
});
|
|
2456
2661
|
}
|
|
2457
2662
|
toGridNum(num, opts) {
|
|
2458
|
-
if (
|
|
2663
|
+
if (opts?.ignore === true) {
|
|
2459
2664
|
return num;
|
|
2460
2665
|
}
|
|
2461
2666
|
return Math.round(num);
|
|
2462
2667
|
}
|
|
2463
2668
|
destroy() {
|
|
2464
|
-
|
|
2669
|
+
this.#opts = null;
|
|
2465
2670
|
}
|
|
2466
|
-
needRender(
|
|
2467
|
-
const
|
|
2468
|
-
const info =
|
|
2671
|
+
needRender(mtrl) {
|
|
2672
|
+
const virtualItemMap = this.#store.get("virtualItemMap");
|
|
2673
|
+
const info = virtualItemMap[mtrl.id];
|
|
2469
2674
|
if (!info) {
|
|
2470
2675
|
return true;
|
|
2471
2676
|
}
|
|
2472
2677
|
return info.isVisibleInView;
|
|
2473
2678
|
}
|
|
2474
|
-
|
|
2475
|
-
const
|
|
2476
|
-
|
|
2679
|
+
forceVisiable(id2) {
|
|
2680
|
+
const virtualItemMap = this.#store.get("virtualItemMap");
|
|
2681
|
+
const info = virtualItemMap[id2];
|
|
2682
|
+
if (info) {
|
|
2683
|
+
info.isVisibleInView = true;
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
getPointMaterial(p, opts) {
|
|
2687
|
+
const context2d = this.#opts.tempContext;
|
|
2688
|
+
return getViewPointAtMaterial(p, { ...opts, ...{ context2d } });
|
|
2477
2689
|
}
|
|
2478
|
-
|
|
2690
|
+
resetVirtualItemMap(data2, opts) {
|
|
2479
2691
|
if (data2) {
|
|
2480
|
-
const {
|
|
2692
|
+
const { virtualItemMap, invisibleCount, visibleCount } = sortMaterialsViewVisiableInfoMap(data2.materials, {
|
|
2481
2693
|
...opts,
|
|
2482
2694
|
...{
|
|
2483
|
-
tempContext:
|
|
2695
|
+
tempContext: this.#opts.tempContext
|
|
2484
2696
|
}
|
|
2485
2697
|
});
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2698
|
+
this.#store.set("virtualItemMap", virtualItemMap);
|
|
2699
|
+
this.#store.set("invisibleCount", invisibleCount);
|
|
2700
|
+
this.#store.set("visibleCount", visibleCount);
|
|
2489
2701
|
}
|
|
2490
2702
|
}
|
|
2491
2703
|
updateVisiableStatus(opts) {
|
|
2492
|
-
const {
|
|
2493
|
-
|
|
2704
|
+
const { virtualItemMap, invisibleCount, visibleCount } = updateVirtualItemMapStatus(
|
|
2705
|
+
this.#store.get("virtualItemMap"),
|
|
2494
2706
|
opts
|
|
2495
2707
|
);
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2708
|
+
this.#store.set("virtualItemMap", virtualItemMap);
|
|
2709
|
+
this.#store.set("invisibleCount", invisibleCount);
|
|
2710
|
+
this.#store.set("visibleCount", visibleCount);
|
|
2499
2711
|
}
|
|
2500
|
-
|
|
2501
|
-
const infoData =
|
|
2502
|
-
if (!
|
|
2712
|
+
calcViewBoundingInfoFromOrigin(id2, opts) {
|
|
2713
|
+
const infoData = this.#store.get("virtualItemMap")[id2];
|
|
2714
|
+
if (!infoData?.boundingInfo) {
|
|
2503
2715
|
return null;
|
|
2504
2716
|
}
|
|
2505
2717
|
const { checkVisible, viewScaleInfo, viewSizeInfo } = opts;
|
|
2506
|
-
const { center, left, right, bottom, top, topLeft, topRight, bottomLeft, bottomRight } = infoData.
|
|
2718
|
+
const { center, left, right, bottom, top, topLeft, topRight, bottomLeft, bottomRight } = infoData.boundingInfo;
|
|
2507
2719
|
if (checkVisible === true && infoData.isVisibleInView === false) {
|
|
2508
2720
|
return null;
|
|
2509
2721
|
}
|
|
2510
2722
|
const calcOpts = { viewScaleInfo };
|
|
2511
|
-
const
|
|
2512
|
-
center:
|
|
2513
|
-
left:
|
|
2514
|
-
right:
|
|
2515
|
-
bottom:
|
|
2516
|
-
top:
|
|
2517
|
-
topLeft:
|
|
2518
|
-
topRight:
|
|
2519
|
-
bottomLeft:
|
|
2520
|
-
bottomRight:
|
|
2723
|
+
const viewBoundingBox = {
|
|
2724
|
+
center: calcViewPoint(center, calcOpts),
|
|
2725
|
+
left: calcViewPoint(left, calcOpts),
|
|
2726
|
+
right: calcViewPoint(right, calcOpts),
|
|
2727
|
+
bottom: calcViewPoint(bottom, calcOpts),
|
|
2728
|
+
top: calcViewPoint(top, calcOpts),
|
|
2729
|
+
topLeft: calcViewPoint(topLeft, calcOpts),
|
|
2730
|
+
topRight: calcViewPoint(topRight, calcOpts),
|
|
2731
|
+
bottomLeft: calcViewPoint(bottomLeft, calcOpts),
|
|
2732
|
+
bottomRight: calcViewPoint(bottomRight, calcOpts)
|
|
2521
2733
|
};
|
|
2522
|
-
return
|
|
2734
|
+
return viewBoundingBox;
|
|
2523
2735
|
}
|
|
2524
|
-
|
|
2525
|
-
const infoData =
|
|
2526
|
-
if (!
|
|
2736
|
+
calcViewBoundingInfoFromRange(id2, opts) {
|
|
2737
|
+
const infoData = this.#store.get("virtualItemMap")[id2];
|
|
2738
|
+
if (!infoData?.boundingInfo) {
|
|
2527
2739
|
return null;
|
|
2528
2740
|
}
|
|
2529
2741
|
const { checkVisible, viewScaleInfo, viewSizeInfo } = opts;
|
|
2530
|
-
const { center, left, right, bottom, top, topLeft, topRight, bottomLeft, bottomRight } = infoData.
|
|
2742
|
+
const { center, left, right, bottom, top, topLeft, topRight, bottomLeft, bottomRight } = infoData.rangeBoundingInfo;
|
|
2531
2743
|
if (checkVisible === true && infoData.isVisibleInView === false) {
|
|
2532
2744
|
return null;
|
|
2533
2745
|
}
|
|
2534
2746
|
const calcOpts = { viewScaleInfo };
|
|
2535
|
-
const
|
|
2536
|
-
center:
|
|
2537
|
-
left:
|
|
2538
|
-
right:
|
|
2539
|
-
bottom:
|
|
2540
|
-
top:
|
|
2541
|
-
topLeft:
|
|
2542
|
-
topRight:
|
|
2543
|
-
bottomLeft:
|
|
2544
|
-
bottomRight:
|
|
2747
|
+
const info = {
|
|
2748
|
+
center: calcViewPoint(center, calcOpts),
|
|
2749
|
+
left: calcViewPoint(left, calcOpts),
|
|
2750
|
+
right: calcViewPoint(right, calcOpts),
|
|
2751
|
+
bottom: calcViewPoint(bottom, calcOpts),
|
|
2752
|
+
top: calcViewPoint(top, calcOpts),
|
|
2753
|
+
topLeft: calcViewPoint(topLeft, calcOpts),
|
|
2754
|
+
topRight: calcViewPoint(topRight, calcOpts),
|
|
2755
|
+
bottomLeft: calcViewPoint(bottomLeft, calcOpts),
|
|
2756
|
+
bottomRight: calcViewPoint(bottomRight, calcOpts)
|
|
2545
2757
|
};
|
|
2546
|
-
return
|
|
2547
|
-
}
|
|
2548
|
-
|
|
2549
|
-
const
|
|
2550
|
-
const
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2758
|
+
return info;
|
|
2759
|
+
}
|
|
2760
|
+
modifyVirtualAttributes(material2, opts) {
|
|
2761
|
+
const { viewSizeInfo, groupQueue } = opts;
|
|
2762
|
+
const virtualItemMap = this.#store.get("virtualItemMap");
|
|
2763
|
+
const vItem = virtualItemMap[material2.id];
|
|
2764
|
+
const vAttributes = calcVirtualAttributes(material2, {
|
|
2765
|
+
tempContext: this.#opts.tempContext,
|
|
2766
|
+
dpr: viewSizeInfo.devicePixelRatio,
|
|
2767
|
+
groupQueue
|
|
2768
|
+
});
|
|
2769
|
+
if (vAttributes) {
|
|
2770
|
+
const boundingInfo = calcMaterialBoundingInfo(material2, {
|
|
2771
|
+
groupQueue
|
|
2772
|
+
});
|
|
2773
|
+
const newVirtualItem = {
|
|
2774
|
+
...vItem,
|
|
2775
|
+
...vAttributes,
|
|
2776
|
+
boundingInfo,
|
|
2777
|
+
rangeBoundingInfo: is.angle(material2.angle) ? boundingInfoToRangeBoundingInfo(boundingInfo) : boundingInfo
|
|
2557
2778
|
};
|
|
2558
|
-
|
|
2559
|
-
|
|
2779
|
+
virtualItemMap[material2.id] = newVirtualItem;
|
|
2780
|
+
this.#store.set("virtualItemMap", virtualItemMap);
|
|
2560
2781
|
}
|
|
2561
2782
|
}
|
|
2562
|
-
|
|
2783
|
+
modifyVirtualItemMap(data2, opts) {
|
|
2563
2784
|
const { modifyInfo, viewScaleInfo, viewSizeInfo } = opts;
|
|
2564
2785
|
const { type: type2, content } = modifyInfo;
|
|
2565
|
-
const list = data2.
|
|
2566
|
-
const
|
|
2567
|
-
if (type2 === "
|
|
2568
|
-
const {
|
|
2569
|
-
const
|
|
2786
|
+
const list = data2.materials;
|
|
2787
|
+
const virtualItemMap = this.#store.get("virtualItemMap");
|
|
2788
|
+
if (type2 === "deleteMaterial") {
|
|
2789
|
+
const { material: material2 } = content;
|
|
2790
|
+
const ids = [];
|
|
2570
2791
|
const _walk = (e) => {
|
|
2571
|
-
|
|
2572
|
-
if (e.type === "group" && Array.isArray(e.
|
|
2573
|
-
e.
|
|
2792
|
+
ids.push(e.id);
|
|
2793
|
+
if (e.type === "group" && Array.isArray(e.children)) {
|
|
2794
|
+
e.children.forEach((child) => {
|
|
2574
2795
|
_walk(child);
|
|
2575
2796
|
});
|
|
2576
2797
|
}
|
|
2577
2798
|
};
|
|
2578
|
-
_walk(
|
|
2579
|
-
|
|
2580
|
-
delete
|
|
2799
|
+
_walk(material2);
|
|
2800
|
+
ids.forEach((id2) => {
|
|
2801
|
+
delete virtualItemMap[id2];
|
|
2581
2802
|
});
|
|
2582
|
-
|
|
2583
|
-
} else if (type2 === "
|
|
2803
|
+
this.#store.set("virtualItemMap", virtualItemMap);
|
|
2804
|
+
} else if (type2 === "addMaterial" || type2 === "updateMaterial") {
|
|
2584
2805
|
const { position } = content;
|
|
2585
|
-
const
|
|
2586
|
-
const groupQueue =
|
|
2587
|
-
if (
|
|
2588
|
-
if (type2 === "
|
|
2589
|
-
this.
|
|
2806
|
+
const material2 = findMaterialFromListByPosition(position, data2.materials);
|
|
2807
|
+
const groupQueue = getGroupQueueByMaterialPosition(list, position);
|
|
2808
|
+
if (material2) {
|
|
2809
|
+
if (type2 === "updateMaterial" && material2.type === "group") {
|
|
2810
|
+
this.resetVirtualItemMap(data2, { viewScaleInfo, viewSizeInfo });
|
|
2590
2811
|
} else {
|
|
2591
|
-
const
|
|
2812
|
+
const boundingInfo = calcMaterialBoundingInfo(material2, {
|
|
2592
2813
|
groupQueue: groupQueue || []
|
|
2593
2814
|
});
|
|
2594
|
-
const
|
|
2595
|
-
type:
|
|
2596
|
-
|
|
2597
|
-
|
|
2815
|
+
const newVirtualItem = {
|
|
2816
|
+
type: material2.type,
|
|
2817
|
+
boundingInfo,
|
|
2818
|
+
rangeBoundingInfo: is.angle(material2.angle) ? boundingInfoToRangeBoundingInfo(boundingInfo) : boundingInfo,
|
|
2598
2819
|
isVisibleInView: true,
|
|
2599
2820
|
position: [...position],
|
|
2600
|
-
...
|
|
2601
|
-
tempContext:
|
|
2821
|
+
...calcVirtualAttributes(material2, {
|
|
2822
|
+
tempContext: this.#opts.tempContext,
|
|
2823
|
+
dpr: viewSizeInfo.devicePixelRatio,
|
|
2824
|
+
groupQueue: groupQueue || []
|
|
2602
2825
|
})
|
|
2603
2826
|
};
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
if (type2 === "
|
|
2827
|
+
virtualItemMap[material2.id] = newVirtualItem;
|
|
2828
|
+
this.#store.set("virtualItemMap", virtualItemMap);
|
|
2829
|
+
if (type2 === "updateMaterial") {
|
|
2607
2830
|
this.updateVisiableStatus({ viewScaleInfo, viewSizeInfo });
|
|
2608
2831
|
}
|
|
2609
2832
|
}
|
|
2610
2833
|
}
|
|
2611
|
-
} else if (type2 === "
|
|
2612
|
-
this.
|
|
2834
|
+
} else if (type2 === "moveMaterial") {
|
|
2835
|
+
this.resetVirtualItemMap(data2, { viewScaleInfo, viewSizeInfo });
|
|
2613
2836
|
}
|
|
2614
2837
|
}
|
|
2615
|
-
|
|
2616
|
-
const itemMap =
|
|
2617
|
-
return itemMap[
|
|
2838
|
+
getVirtualItem(id2) {
|
|
2839
|
+
const itemMap = this.#store.get("virtualItemMap");
|
|
2840
|
+
return itemMap[id2] || null;
|
|
2618
2841
|
}
|
|
2619
2842
|
}
|
|
2620
|
-
_opts = new WeakMap();
|
|
2621
|
-
_store = new WeakMap();
|
|
2622
2843
|
class Renderer extends EventEmitter {
|
|
2844
|
+
#opts;
|
|
2845
|
+
#loader = new Loader();
|
|
2846
|
+
#calculator;
|
|
2847
|
+
#hasDestroyed = false;
|
|
2623
2848
|
constructor(opts) {
|
|
2624
2849
|
super();
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
__privateAdd(this, _loader, new Loader());
|
|
2628
|
-
__privateAdd(this, _calculator);
|
|
2629
|
-
__privateAdd(this, _hasDestroyed2, false);
|
|
2630
|
-
__privateSet(this, _opts2, opts);
|
|
2631
|
-
__privateSet(this, _calculator, new Calculator({
|
|
2850
|
+
this.#opts = opts;
|
|
2851
|
+
this.#calculator = new Calculator({
|
|
2632
2852
|
tempContext: opts.tempContext
|
|
2633
|
-
})
|
|
2634
|
-
|
|
2853
|
+
});
|
|
2854
|
+
this.#init();
|
|
2635
2855
|
}
|
|
2636
2856
|
isDestroyed() {
|
|
2637
|
-
return
|
|
2857
|
+
return this.#hasDestroyed;
|
|
2638
2858
|
}
|
|
2639
2859
|
destroy() {
|
|
2640
2860
|
this.clear();
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2861
|
+
this.#opts = null;
|
|
2862
|
+
this.#loader.destroy();
|
|
2863
|
+
this.#loader = null;
|
|
2864
|
+
this.#hasDestroyed = true;
|
|
2865
|
+
}
|
|
2866
|
+
#init() {
|
|
2867
|
+
const loader = this.#loader;
|
|
2868
|
+
loader.on("load", (e) => {
|
|
2869
|
+
this.trigger("load", e);
|
|
2870
|
+
});
|
|
2871
|
+
loader.on("error", (e) => {
|
|
2872
|
+
console.error(e);
|
|
2873
|
+
});
|
|
2645
2874
|
}
|
|
2646
2875
|
updateOptions(opts) {
|
|
2647
|
-
|
|
2876
|
+
this.#opts = opts;
|
|
2648
2877
|
}
|
|
2649
2878
|
drawData(data2, opts) {
|
|
2650
|
-
const loader =
|
|
2651
|
-
const calculator =
|
|
2652
|
-
const { sharer } =
|
|
2653
|
-
const viewContext =
|
|
2879
|
+
const loader = this.#loader;
|
|
2880
|
+
const calculator = this.#calculator;
|
|
2881
|
+
const { sharer } = this.#opts;
|
|
2882
|
+
const viewContext = this.#opts.viewContext;
|
|
2654
2883
|
viewContext.clearRect(0, 0, viewContext.canvas.width, viewContext.canvas.height);
|
|
2655
|
-
const
|
|
2884
|
+
const parentMaterialSize = {
|
|
2656
2885
|
x: 0,
|
|
2657
2886
|
y: 0,
|
|
2658
|
-
|
|
2659
|
-
|
|
2887
|
+
width: opts.viewSizeInfo.width,
|
|
2888
|
+
height: opts.viewSizeInfo.height
|
|
2660
2889
|
};
|
|
2661
2890
|
if (opts.forceDrawAll === true) {
|
|
2662
|
-
|
|
2891
|
+
this.#calculator.resetVirtualItemMap(data2, {
|
|
2663
2892
|
viewScaleInfo: opts.viewScaleInfo,
|
|
2664
2893
|
viewSizeInfo: opts.viewSizeInfo
|
|
2665
2894
|
});
|
|
@@ -2667,23 +2896,24 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2667
2896
|
const drawOpts = {
|
|
2668
2897
|
loader,
|
|
2669
2898
|
calculator,
|
|
2670
|
-
|
|
2671
|
-
|
|
2899
|
+
parentMaterialSize,
|
|
2900
|
+
materialAssets: data2.assets,
|
|
2672
2901
|
parentOpacity: 1,
|
|
2673
|
-
|
|
2902
|
+
overrideMaterialMap: sharer?.getActiveOverrideMaterialMap(),
|
|
2903
|
+
tempContext: this.#opts.tempContext,
|
|
2674
2904
|
...opts
|
|
2675
2905
|
};
|
|
2676
2906
|
drawGlobalBackground(viewContext, data2.global, drawOpts);
|
|
2677
2907
|
if (data2.layout) {
|
|
2678
2908
|
drawLayout(viewContext, data2.layout, drawOpts, () => {
|
|
2679
|
-
|
|
2909
|
+
drawMaterialList(viewContext, data2, drawOpts);
|
|
2680
2910
|
});
|
|
2681
2911
|
} else {
|
|
2682
|
-
|
|
2912
|
+
drawMaterialList(viewContext, data2, drawOpts);
|
|
2683
2913
|
}
|
|
2684
2914
|
}
|
|
2685
2915
|
scale(num) {
|
|
2686
|
-
const { sharer } =
|
|
2916
|
+
const { sharer } = this.#opts;
|
|
2687
2917
|
if (!sharer) {
|
|
2688
2918
|
return;
|
|
2689
2919
|
}
|
|
@@ -2693,8 +2923,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2693
2923
|
offsetBottom,
|
|
2694
2924
|
offsetLeft,
|
|
2695
2925
|
offsetRight,
|
|
2696
|
-
width,
|
|
2697
|
-
height,
|
|
2926
|
+
width: width2,
|
|
2927
|
+
height: height2,
|
|
2698
2928
|
contextHeight,
|
|
2699
2929
|
contextWidth,
|
|
2700
2930
|
devicePixelRatio
|
|
@@ -2709,8 +2939,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2709
2939
|
offsetRight
|
|
2710
2940
|
},
|
|
2711
2941
|
viewSizeInfo: {
|
|
2712
|
-
width,
|
|
2713
|
-
height,
|
|
2942
|
+
width: width2,
|
|
2943
|
+
height: height2,
|
|
2714
2944
|
contextHeight,
|
|
2715
2945
|
contextWidth,
|
|
2716
2946
|
devicePixelRatio
|
|
@@ -2719,45 +2949,31 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2719
2949
|
}
|
|
2720
2950
|
}
|
|
2721
2951
|
setLoadItemMap(itemMap) {
|
|
2722
|
-
|
|
2952
|
+
this.#loader.setLoadItemMap(itemMap);
|
|
2723
2953
|
}
|
|
2724
2954
|
getLoadItemMap() {
|
|
2725
|
-
return
|
|
2955
|
+
return this.#loader.getLoadItemMap();
|
|
2726
2956
|
}
|
|
2727
2957
|
getLoader() {
|
|
2728
|
-
return
|
|
2958
|
+
return this.#loader;
|
|
2729
2959
|
}
|
|
2730
2960
|
getCalculator() {
|
|
2731
|
-
return
|
|
2732
|
-
}
|
|
2733
|
-
}
|
|
2734
|
-
_opts2 = new WeakMap();
|
|
2735
|
-
_loader = new WeakMap();
|
|
2736
|
-
_calculator = new WeakMap();
|
|
2737
|
-
_hasDestroyed2 = new WeakMap();
|
|
2738
|
-
_Renderer_instances = new WeakSet();
|
|
2739
|
-
init_fn = function() {
|
|
2740
|
-
const loader = __privateGet(this, _loader);
|
|
2741
|
-
loader.on("load", (e) => {
|
|
2742
|
-
this.trigger("load", e);
|
|
2743
|
-
});
|
|
2744
|
-
loader.on("error", (e) => {
|
|
2745
|
-
console.error(e);
|
|
2746
|
-
});
|
|
2747
|
-
};
|
|
2961
|
+
return this.#calculator;
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2748
2964
|
exports.Calculator = Calculator;
|
|
2749
2965
|
exports.Renderer = Renderer;
|
|
2750
2966
|
exports.drawCircle = drawCircle;
|
|
2751
|
-
exports.
|
|
2752
|
-
exports.drawElementList = drawElementList;
|
|
2967
|
+
exports.drawForeignObject = drawForeignObject;
|
|
2753
2968
|
exports.drawGlobalBackground = drawGlobalBackground;
|
|
2754
2969
|
exports.drawGroup = drawGroup;
|
|
2755
|
-
exports.drawHTML = drawHTML;
|
|
2756
2970
|
exports.drawImage = drawImage;
|
|
2757
2971
|
exports.drawLayout = drawLayout;
|
|
2972
|
+
exports.drawMaterial = drawMaterial;
|
|
2973
|
+
exports.drawMaterialList = drawMaterialList;
|
|
2758
2974
|
exports.drawRect = drawRect;
|
|
2759
|
-
exports.
|
|
2975
|
+
exports.drawSVGCode = drawSVGCode;
|
|
2760
2976
|
exports.drawText = drawText;
|
|
2761
2977
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2762
2978
|
return exports;
|
|
2763
|
-
}({});
|
|
2979
|
+
})({});
|