@idraw/renderer 0.4.0-beta.35 → 0.4.0-beta.37
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/draw/index.d.ts +1 -0
- package/dist/esm/draw/index.js +1 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +4 -4
- package/dist/index.global.js +51 -83
- package/dist/index.global.min.js +1 -1
- package/package.json +3 -3
package/dist/esm/draw/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { drawImage } from './image';
|
|
|
4
4
|
export { drawSVG } from './svg';
|
|
5
5
|
export { drawHTML } from './html';
|
|
6
6
|
export { drawText } from './text';
|
|
7
|
+
export { drawGroup, drawElement } from './group';
|
|
7
8
|
export { drawElementList } from './elements';
|
|
8
9
|
export { drawLayout } from './layout';
|
|
9
10
|
export { drawGlobalBackground } from './global';
|
package/dist/esm/draw/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { drawImage } from './image';
|
|
|
4
4
|
export { drawSVG } from './svg';
|
|
5
5
|
export { drawHTML } from './html';
|
|
6
6
|
export { drawText } from './text';
|
|
7
|
+
export { drawGroup, drawElement } from './group';
|
|
7
8
|
export { drawElementList } from './elements';
|
|
8
9
|
export { drawLayout } from './layout';
|
|
9
10
|
export { drawGlobalBackground } from './global';
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -14,4 +14,4 @@ export declare class Renderer extends EventEmitter<RendererEventMap> implements
|
|
|
14
14
|
getLoadItemMap(): LoadItemMap;
|
|
15
15
|
getLoader(): Loader;
|
|
16
16
|
}
|
|
17
|
-
export { drawRect } from './draw';
|
|
17
|
+
export { drawCircle, drawRect, drawImage, drawSVG, drawHTML, drawText, drawGroup, drawElement, drawElementList, drawLayout, drawGlobalBackground } from './draw';
|
package/dist/esm/index.js
CHANGED
|
@@ -104,4 +104,4 @@ _Renderer_opts = new WeakMap(), _Renderer_loader = new WeakMap(), _Renderer_hasD
|
|
|
104
104
|
console.error(e);
|
|
105
105
|
});
|
|
106
106
|
};
|
|
107
|
-
export { drawRect } from './draw';
|
|
107
|
+
export { drawCircle, drawRect, drawImage, drawSVG, drawHTML, drawText, drawGroup, drawElement, drawElementList, drawLayout, drawGlobalBackground } from './draw';
|
package/dist/esm/loader.js
CHANGED
|
@@ -60,8 +60,8 @@ export class Loader extends EventEmitter {
|
|
|
60
60
|
};
|
|
61
61
|
}));
|
|
62
62
|
__classPrivateFieldGet(this, _Loader_instances, "m", _Loader_registerLoadFunc).call(this, 'html', (elem, assets) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
var
|
|
64
|
-
const html = ((
|
|
63
|
+
var _a;
|
|
64
|
+
const html = ((_a = assets[elem.detail.html]) === null || _a === void 0 ? void 0 : _a.value) || elem.detail.html;
|
|
65
65
|
const content = yield loadHTML(html, {
|
|
66
66
|
width: elem.detail.originW || elem.w,
|
|
67
67
|
height: elem.detail.originH || elem.h
|
|
@@ -73,8 +73,8 @@ export class Loader extends EventEmitter {
|
|
|
73
73
|
};
|
|
74
74
|
}));
|
|
75
75
|
__classPrivateFieldGet(this, _Loader_instances, "m", _Loader_registerLoadFunc).call(this, 'svg', (elem, assets) => __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
var
|
|
77
|
-
const svg = ((
|
|
76
|
+
var _a;
|
|
77
|
+
const svg = ((_a = assets[elem.detail.svg]) === null || _a === void 0 ? void 0 : _a.value) || elem.detail.svg;
|
|
78
78
|
const content = yield loadSVG(svg);
|
|
79
79
|
return {
|
|
80
80
|
uuid: elem.uuid,
|
package/dist/index.global.js
CHANGED
|
@@ -1,28 +1,14 @@
|
|
|
1
1
|
var iDrawRenderer = function(exports) {
|
|
2
|
-
"use strict";var
|
|
3
|
-
|
|
4
|
-
throw TypeError("Cannot " + msg);
|
|
5
|
-
};
|
|
6
|
-
var __privateGet = (obj, member, getter) => {
|
|
7
|
-
__accessCheck(obj, member, "read from private field");
|
|
8
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
9
|
-
};
|
|
10
|
-
var __privateAdd = (obj, member, value) => {
|
|
11
|
-
if (member.has(obj))
|
|
12
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
13
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
14
|
-
};
|
|
15
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
16
|
-
__accessCheck(obj, member, "write to private field");
|
|
17
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
18
|
-
return value;
|
|
19
|
-
};
|
|
20
|
-
var __privateMethod = (obj, member, method) => {
|
|
21
|
-
__accessCheck(obj, member, "access private method");
|
|
22
|
-
return method;
|
|
2
|
+
"use strict";var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
23
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);
|
|
24
10
|
|
|
25
|
-
var _loadFuncMap, _currentLoadItemMap, _storageLoadItemMap, _hasDestroyed,
|
|
11
|
+
var _loadFuncMap, _currentLoadItemMap, _storageLoadItemMap, _hasDestroyed, _Loader_instances, registerLoadFunc_fn, getLoadElementSource_fn, createLoadItem_fn, emitLoad_fn, emitError_fn, loadResource_fn, isExistingErrorStorage_fn, _opts, _loader, _hasDestroyed2, _Renderer_instances, init_fn;
|
|
26
12
|
function isColorStr(color2) {
|
|
27
13
|
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));
|
|
28
14
|
}
|
|
@@ -321,35 +307,25 @@ var __privateMethod = (obj, member, method) => {
|
|
|
321
307
|
strokeWidth
|
|
322
308
|
};
|
|
323
309
|
(function(receiver, state, value, kind, f) {
|
|
324
|
-
if (kind === "m")
|
|
325
|
-
|
|
326
|
-
if (
|
|
327
|
-
throw new TypeError("Private accessor was defined without a setter");
|
|
328
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
329
|
-
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
310
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
311
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
312
|
+
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");
|
|
330
313
|
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
331
314
|
});
|
|
332
315
|
(function(receiver, state, kind, f) {
|
|
333
|
-
if (kind === "a" && !f)
|
|
334
|
-
|
|
335
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
336
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
316
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
317
|
+
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");
|
|
337
318
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
338
319
|
});
|
|
339
320
|
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
340
|
-
if (kind === "m")
|
|
341
|
-
|
|
342
|
-
if (
|
|
343
|
-
throw new TypeError("Private accessor was defined without a setter");
|
|
344
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
345
|
-
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
321
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
322
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
323
|
+
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");
|
|
346
324
|
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
347
325
|
};
|
|
348
326
|
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
349
|
-
if (kind === "a" && !f)
|
|
350
|
-
|
|
351
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
352
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
327
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
328
|
+
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");
|
|
353
329
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
354
330
|
};
|
|
355
331
|
var _EventEmitter_listeners;
|
|
@@ -410,19 +386,14 @@ var __privateMethod = (obj, member, method) => {
|
|
|
410
386
|
}
|
|
411
387
|
_EventEmitter_listeners = /* @__PURE__ */ new WeakMap();
|
|
412
388
|
(function(receiver, state, value, kind, f) {
|
|
413
|
-
if (kind === "m")
|
|
414
|
-
|
|
415
|
-
if (
|
|
416
|
-
throw new TypeError("Private accessor was defined without a setter");
|
|
417
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
418
|
-
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
389
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
390
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
391
|
+
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");
|
|
419
392
|
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
420
393
|
});
|
|
421
394
|
(function(receiver, state, kind, f) {
|
|
422
|
-
if (kind === "a" && !f)
|
|
423
|
-
|
|
424
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
425
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
395
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
396
|
+
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");
|
|
426
397
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
427
398
|
});
|
|
428
399
|
function parseAngleToRadian(angle2) {
|
|
@@ -556,9 +527,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
556
527
|
}
|
|
557
528
|
(function(s, e) {
|
|
558
529
|
var t = {};
|
|
559
|
-
for (var p in s)
|
|
560
|
-
|
|
561
|
-
t[p] = s[p];
|
|
530
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
531
|
+
t[p] = s[p];
|
|
562
532
|
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
563
533
|
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
564
534
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
@@ -1616,18 +1586,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1616
1586
|
class Loader extends EventEmitter {
|
|
1617
1587
|
constructor() {
|
|
1618
1588
|
super();
|
|
1619
|
-
__privateAdd(this,
|
|
1620
|
-
__privateAdd(this, _getLoadElementSource);
|
|
1621
|
-
__privateAdd(this, _createLoadItem);
|
|
1622
|
-
__privateAdd(this, _emitLoad);
|
|
1623
|
-
__privateAdd(this, _emitError);
|
|
1624
|
-
__privateAdd(this, _loadResource);
|
|
1625
|
-
__privateAdd(this, _isExistingErrorStorage);
|
|
1589
|
+
__privateAdd(this, _Loader_instances);
|
|
1626
1590
|
__privateAdd(this, _loadFuncMap, {});
|
|
1627
1591
|
__privateAdd(this, _currentLoadItemMap, {});
|
|
1628
1592
|
__privateAdd(this, _storageLoadItemMap, {});
|
|
1629
1593
|
__privateAdd(this, _hasDestroyed, false);
|
|
1630
|
-
__privateMethod(this,
|
|
1594
|
+
__privateMethod(this, _Loader_instances, registerLoadFunc_fn).call(this, "image", async (elem, assets) => {
|
|
1631
1595
|
var _a;
|
|
1632
1596
|
const src = ((_a = assets[elem.detail.src]) == null ? void 0 : _a.value) || elem.detail.src;
|
|
1633
1597
|
const content = await loadImage(src);
|
|
@@ -1637,7 +1601,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1637
1601
|
content
|
|
1638
1602
|
};
|
|
1639
1603
|
});
|
|
1640
|
-
__privateMethod(this,
|
|
1604
|
+
__privateMethod(this, _Loader_instances, registerLoadFunc_fn).call(this, "html", async (elem, assets) => {
|
|
1641
1605
|
var _a;
|
|
1642
1606
|
const html2 = ((_a = assets[elem.detail.html]) == null ? void 0 : _a.value) || elem.detail.html;
|
|
1643
1607
|
const content = await loadHTML(html2, {
|
|
@@ -1650,7 +1614,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1650
1614
|
content
|
|
1651
1615
|
};
|
|
1652
1616
|
});
|
|
1653
|
-
__privateMethod(this,
|
|
1617
|
+
__privateMethod(this, _Loader_instances, registerLoadFunc_fn).call(this, "svg", async (elem, assets) => {
|
|
1654
1618
|
var _a;
|
|
1655
1619
|
const svg2 = ((_a = assets[elem.detail.svg]) == null ? void 0 : _a.value) || elem.detail.svg;
|
|
1656
1620
|
const content = await loadSVG(svg2);
|
|
@@ -1675,11 +1639,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1675
1639
|
if (__privateGet(this, _hasDestroyed) === true) {
|
|
1676
1640
|
return;
|
|
1677
1641
|
}
|
|
1678
|
-
if (__privateMethod(this,
|
|
1642
|
+
if (__privateMethod(this, _Loader_instances, isExistingErrorStorage_fn).call(this, element)) {
|
|
1679
1643
|
return;
|
|
1680
1644
|
}
|
|
1681
1645
|
if (supportElementTypes.includes(element.type)) {
|
|
1682
|
-
__privateMethod(this,
|
|
1646
|
+
__privateMethod(this, _Loader_instances, loadResource_fn).call(this, element, assets);
|
|
1683
1647
|
}
|
|
1684
1648
|
}
|
|
1685
1649
|
getContent(element) {
|
|
@@ -1698,11 +1662,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1698
1662
|
_currentLoadItemMap = new WeakMap();
|
|
1699
1663
|
_storageLoadItemMap = new WeakMap();
|
|
1700
1664
|
_hasDestroyed = new WeakMap();
|
|
1701
|
-
|
|
1665
|
+
_Loader_instances = new WeakSet();
|
|
1702
1666
|
registerLoadFunc_fn = function(type, func) {
|
|
1703
1667
|
__privateGet(this, _loadFuncMap)[type] = func;
|
|
1704
1668
|
};
|
|
1705
|
-
_getLoadElementSource = new WeakSet();
|
|
1706
1669
|
getLoadElementSource_fn = function(element) {
|
|
1707
1670
|
var _a, _b, _c;
|
|
1708
1671
|
let source = null;
|
|
@@ -1715,7 +1678,6 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1715
1678
|
}
|
|
1716
1679
|
return source;
|
|
1717
1680
|
};
|
|
1718
|
-
_createLoadItem = new WeakSet();
|
|
1719
1681
|
createLoadItem_fn = function(element) {
|
|
1720
1682
|
return {
|
|
1721
1683
|
element,
|
|
@@ -1724,10 +1686,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1724
1686
|
error: null,
|
|
1725
1687
|
startTime: -1,
|
|
1726
1688
|
endTime: -1,
|
|
1727
|
-
source: __privateMethod(this,
|
|
1689
|
+
source: __privateMethod(this, _Loader_instances, getLoadElementSource_fn).call(this, element)
|
|
1728
1690
|
};
|
|
1729
1691
|
};
|
|
1730
|
-
_emitLoad = new WeakSet();
|
|
1731
1692
|
emitLoad_fn = function(item) {
|
|
1732
1693
|
const assetId = getAssetIdFromElement(item.element);
|
|
1733
1694
|
const storageItem = __privateGet(this, _storageLoadItemMap)[assetId];
|
|
@@ -1743,7 +1704,6 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1743
1704
|
}
|
|
1744
1705
|
}
|
|
1745
1706
|
};
|
|
1746
|
-
_emitError = new WeakSet();
|
|
1747
1707
|
emitError_fn = function(item) {
|
|
1748
1708
|
var _a;
|
|
1749
1709
|
const assetId = getAssetIdFromElement(item.element);
|
|
@@ -1760,9 +1720,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1760
1720
|
}
|
|
1761
1721
|
}
|
|
1762
1722
|
};
|
|
1763
|
-
_loadResource = new WeakSet();
|
|
1764
1723
|
loadResource_fn = function(element, assets) {
|
|
1765
|
-
const item = __privateMethod(this,
|
|
1724
|
+
const item = __privateMethod(this, _Loader_instances, createLoadItem_fn).call(this, element);
|
|
1766
1725
|
const assetId = getAssetIdFromElement(element);
|
|
1767
1726
|
if (__privateGet(this, _currentLoadItemMap)[assetId]) {
|
|
1768
1727
|
return;
|
|
@@ -1776,23 +1735,22 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1776
1735
|
item.content = result.content;
|
|
1777
1736
|
item.endTime = Date.now();
|
|
1778
1737
|
item.status = "load";
|
|
1779
|
-
__privateMethod(this,
|
|
1738
|
+
__privateMethod(this, _Loader_instances, emitLoad_fn).call(this, item);
|
|
1780
1739
|
}
|
|
1781
1740
|
}).catch((err) => {
|
|
1782
1741
|
console.warn(`Load element source "${item.source}" fail`, err, element);
|
|
1783
1742
|
item.endTime = Date.now();
|
|
1784
1743
|
item.status = "error";
|
|
1785
1744
|
item.error = err;
|
|
1786
|
-
__privateMethod(this,
|
|
1745
|
+
__privateMethod(this, _Loader_instances, emitError_fn).call(this, item);
|
|
1787
1746
|
});
|
|
1788
1747
|
}
|
|
1789
1748
|
};
|
|
1790
|
-
_isExistingErrorStorage = new WeakSet();
|
|
1791
1749
|
isExistingErrorStorage_fn = function(element) {
|
|
1792
1750
|
var _a;
|
|
1793
1751
|
const assetId = getAssetIdFromElement(element);
|
|
1794
1752
|
const existItem = (_a = __privateGet(this, _currentLoadItemMap)) == null ? void 0 : _a[assetId];
|
|
1795
|
-
if (existItem && existItem.status === "error" && existItem.source && existItem.source === __privateMethod(this,
|
|
1753
|
+
if (existItem && existItem.status === "error" && existItem.source && existItem.source === __privateMethod(this, _Loader_instances, getLoadElementSource_fn).call(this, element)) {
|
|
1796
1754
|
return true;
|
|
1797
1755
|
}
|
|
1798
1756
|
return false;
|
|
@@ -1800,12 +1758,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1800
1758
|
class Renderer extends EventEmitter {
|
|
1801
1759
|
constructor(opts) {
|
|
1802
1760
|
super();
|
|
1803
|
-
__privateAdd(this,
|
|
1804
|
-
__privateAdd(this, _opts
|
|
1761
|
+
__privateAdd(this, _Renderer_instances);
|
|
1762
|
+
__privateAdd(this, _opts);
|
|
1805
1763
|
__privateAdd(this, _loader, new Loader());
|
|
1806
1764
|
__privateAdd(this, _hasDestroyed2, false);
|
|
1807
1765
|
__privateSet(this, _opts, opts);
|
|
1808
|
-
__privateMethod(this,
|
|
1766
|
+
__privateMethod(this, _Renderer_instances, init_fn).call(this);
|
|
1809
1767
|
}
|
|
1810
1768
|
isDestroyed() {
|
|
1811
1769
|
return __privateGet(this, _hasDestroyed2);
|
|
@@ -1887,7 +1845,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1887
1845
|
_opts = new WeakMap();
|
|
1888
1846
|
_loader = new WeakMap();
|
|
1889
1847
|
_hasDestroyed2 = new WeakMap();
|
|
1890
|
-
|
|
1848
|
+
_Renderer_instances = new WeakSet();
|
|
1891
1849
|
init_fn = function() {
|
|
1892
1850
|
const loader = __privateGet(this, _loader);
|
|
1893
1851
|
loader.on("load", (e) => {
|
|
@@ -1898,7 +1856,17 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1898
1856
|
});
|
|
1899
1857
|
};
|
|
1900
1858
|
exports.Renderer = Renderer;
|
|
1859
|
+
exports.drawCircle = drawCircle;
|
|
1860
|
+
exports.drawElement = drawElement;
|
|
1861
|
+
exports.drawElementList = drawElementList;
|
|
1862
|
+
exports.drawGlobalBackground = drawGlobalBackground;
|
|
1863
|
+
exports.drawGroup = drawGroup;
|
|
1864
|
+
exports.drawHTML = drawHTML;
|
|
1865
|
+
exports.drawImage = drawImage;
|
|
1866
|
+
exports.drawLayout = drawLayout;
|
|
1901
1867
|
exports.drawRect = drawRect;
|
|
1868
|
+
exports.drawSVG = drawSVG;
|
|
1869
|
+
exports.drawText = drawText;
|
|
1902
1870
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
1903
1871
|
return exports;
|
|
1904
1872
|
}({});
|
package/dist/index.global.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var iDrawRenderer=function(e){"use strict";var t,n,i,o,a,r,l,s,c,d,h,f,u,w,g,v,p,y,m,S,x,b,I,z=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},T=(e,t,n)=>(z(e,t,"read from private field"),n?n.call(e):t.get(e)),k=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},A=(e,t,n,i)=>(z(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),C=(e,t,n)=>(z(e,t,"access private method"),n);function P(e){return"string"==typeof e&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e))}function E(e,t){if(1===t)return e;let n=1;const i=/^\#[0-9a-f]{6,6}$/i;let o=e;if(i.test(e)?n=parseInt(e.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(e)&&(n=parseInt(e.substring(7,9).replace(/^\#/,"0x")),o=e.substring(0,7)),n*=t,i.test(o)&&n>0&&n<1){const e=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${e.toString(16).toUpperCase()}`}return o}function W(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function O(e){let t=0;for(let n=0;n<e.length;n++)t+=e.charCodeAt(n)*e.charCodeAt(n)*n*n;return t.toString(16).substring(0,4)}function $(e){const t=e.length,n=Math.floor(t/2),i=e.substring(0,4).padEnd(4,"0"),o=e.substring(0,4).padEnd(4,"0");return`@assets/${O(t.toString(16).padEnd(4,i))}${O(e.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${O(e.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${O(e.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${O(e.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${O(e.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${O(e.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${O(o.padEnd(4,i).padEnd(4,o))}`}function M(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const R={type(e,t){const n=M(e);return!0===t?n.toLocaleLowerCase():n},array:e=>"Array"===M(e),json:e=>"Object"===M(e),function:e=>"Function"===M(e),asyncFunction:e=>"AsyncFunction"===M(e),boolean:e=>"Boolean"===M(e),string:e=>"String"===M(e),number:e=>"Number"===M(e),undefined:e=>"Undefined"===M(e),null:e=>"Null"===M(e),promise:e=>"Promise"===M(e)};var D=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function r(e){try{s(i.next(e))}catch(e){a(e)}}function l(e){try{s(i.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,l)}s((i=i.apply(e,t||[])).next())}))};const{Image:L}=window;function B(e){return new Promise(((t,n)=>{const i=new L;i.crossOrigin="anonymous",i.onload=function(){t(i)},i.onabort=n,i.onerror=n,i.src=e}))}function X(e){return D(this,void 0,void 0,(function*(){const t=yield function(e){return new Promise(((t,n)=>{const i=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(e){var n;const i=null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result;t(i)},o.onerror=function(e){n(e)}}))}(e);return yield B(t)}))}function Y(e,t){return D(this,void 0,void 0,(function*(){e=e.replace(/\&/gi,"&");const n=yield function(e,t){const{width:n,height:i}=t;return new Promise(((t,o)=>{const a=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${n||""}" \n height = "${i||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${e}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),r=new FileReader;r.readAsDataURL(a),r.onload=function(e){var n;const i=null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result;t(i)},r.onerror=function(e){o(e)}}))}(e,t);return yield B(n)}))}function F(e){return"number"==typeof e&&(e>0||e<=0)}function H(e){return"number"==typeof e&&e>=0}function j(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function U(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const N={x:function(e){return F(e)},y:function(e){return F(e)},w:H,h:function(e){return"number"==typeof e&&e>=0},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:F,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return H(e)},borderRadius:function(e){return F(e)&&e>=0},color:function(e){return P(e)},imageSrc:function(e){return U(e)||j(e)},imageURL:j,imageBase64:U,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let n=document.createElement("div");n.innerHTML=e,n.children.length>0&&(t=!0),n=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return F(e)&&e>0},lineHeight:function(e){return F(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)},strokeWidth:function(e){return F(e)&&e>0}};var q,G=function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};class J{constructor(){q.set(this,void 0),function(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===i?o.call(e,n):o?o.value=n:t.set(e,n)}(this,q,new Map,"f")}on(e,t){if(G(this,q,"f").has(e)){const n=G(this,q,"f").get(e)||[];null==n||n.push(t),G(this,q,"f").set(e,n)}else G(this,q,"f").set(e,[t])}off(e,t){if(G(this,q,"f").has(e)){const n=G(this,q,"f").get(e);if(Array.isArray(n))for(let e=0;e<(null==n?void 0:n.length);e++)if(n[e]===t){n.splice(e,1);break}G(this,q,"f").set(e,n||[])}}trigger(e,t){const n=G(this,q,"f").get(e);return!!Array.isArray(n)&&(n.forEach((e=>{e(t)})),!0)}has(e){if(G(this,q,"f").has(e)){const t=G(this,q,"f").get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){G(this,q,"f").clear()}}function K(e,t,n,i){const o=function(e){return e/180*Math.PI}(t||0);n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(o),e.translate(-n.x,-n.y)),i(e),n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(-o),e.translate(-n.x,-n.y))}function Q(e,t,n){const i={x:(o=t).x+o.w/2,y:o.y+o.h/2};var o;K(e,t.angle||0,i,(()=>{n(e)}))}function V(e,t){const{viewScaleInfo:n}=t,{x:i,y:o,w:a,h:r,angle:l}=e,{scale:s,offsetTop:c,offsetLeft:d}=n;return{x:i*s+d,y:o*s+c,w:a*s,h:r*s,angle:l}}function Z(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}q=new WeakMap;const _={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function ee(e,t){const{viewScaleInfo:n}=t,{scale:i}=n;let{borderRadius:o,borderDash:a}=e.detail;const r=Array.isArray(a)&&a.length>0,{boxSizing:l=_.boxSizing,borderWidth:s}=e.detail;Array.isArray(s)&&(o=0);let{x:c,y:d,w:h,h:f}=e,u=[0,0,0,0];if("number"==typeof o){const e=o*i;u=[e,e,e,e]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(u=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let w=0;return"number"==typeof s&&(w=(s||0)*i),"border-box"!==l||r?"content-box"===l?(c=e.x-w/2,d=e.y-w/2,h=e.w+w,f=e.h+w):(c=e.x,d=e.y,h=e.w,f=e.h):(c=e.x+w/2,d=e.y+w/2,h=e.w-w,f=e.h-w),h=Math.max(h,1),f=Math.max(f,1),u=u.map((e=>Math.min(e,h/2,f/2))),{x:c,y:d,w:h,h:f,radiusList:u}}const te=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function ne(e,t,n){if("string"==typeof t)return t;const{viewElementSize:i,viewScaleInfo:o,opacity:a=1}=n,{x:r,y:l}=i,{scale:s}=o;if("linear-gradient"===(null==t?void 0:t.type)){const{start:n,end:i,stops:o}=t,c={x:r+n.x*s,y:l+n.y*s},d={x:r+i.x*s,y:l+i.y*s},h=e.createLinearGradient(c.x,c.y,d.x,d.y);return o.forEach((e=>{h.addColorStop(e.offset,E(e.color,a))})),h}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:n,outer:i,stops:o}=t,c={x:r+n.x*s,y:l+n.y*s,radius:n.radius*s},d={x:r+i.x*s,y:l+i.y*s,radius:i.radius*s},h=e.createRadialGradient(c.x,c.y,c.radius,d.x,d.y,d.radius);return o.forEach((e=>{h.addColorStop(e.offset,E(e.color,a))})),h}return"#000000"}const ie={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function oe(e){var t,n,i,o;let a=1;return void 0!==(null==(t=null==e?void 0:e.detail)?void 0:t.opacity)&&(null==(n=null==e?void 0:e.detail)?void 0:n.opacity)>=0&&(null==(i=null==e?void 0:e.detail)?void 0:i.opacity)<=1&&(a=null==(o=null==e?void 0:e.detail)?void 0:o.opacity),a}function ae(e,t,n){const{pattern:i,renderContent:o,originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s}=n||{},{parentOpacity:c}=n,d=oe(a)*c,{clipPath:h,clipPathStrokeColor:f,clipPathStrokeWidth:u}=a.detail,w=()=>{e.globalAlpha=d,re(e,t,{pattern:i,viewScaleInfo:l,viewSizeInfo:s}),null==o||o(),le(e,t,{viewScaleInfo:l,viewSizeInfo:s}),e.globalAlpha=c};h?(function(e,t,n){const{renderContent:i,originElem:o,calcElemSize:a,viewSizeInfo:r}=n,l=r.devicePixelRatio,{clipPath:s}=(null==o?void 0:o.detail)||{};if(s&&a&&s.commands){const{x:n,y:o,w:r,h:c}=a,{originW:d,originH:h,originX:f,originY:u}=s,w=r/d,g=c/h,v=n-f*w,p=o-u*g;e.save(),e.translate(v,p),e.scale(l*w,l*g);const y=Z(s.commands||[]),m=new Path2D(y);e.clip(m),e.translate(0-v,0-p),e.setTransform(1,0,0,1,0,0),Q(e,{...t},(()=>{null==i||i()})),e.restore()}else null==i||i()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,renderContent:()=>{w()}}),"number"==typeof u&&u>0&&f&&function(e,t,n){const{renderContent:i,originElem:o,calcElemSize:a,viewSizeInfo:r,parentOpacity:l}=n,s=r.devicePixelRatio,{clipPath:c,clipPathStrokeColor:d,clipPathStrokeWidth:h}=(null==o?void 0:o.detail)||{};if(c&&a&&c.commands&&"number"==typeof h&&h>0&&d){const{x:n,y:o,w:r,h:f}=a,{originW:u,originH:w,originX:g,originY:v}=c,p=r/u,y=f/w,m=n-g*p,S=o-v*y;e.save(),e.globalAlpha=l,e.translate(m,S),e.scale(s*p,s*y);const x=Z(c.commands||[]),b=new Path2D(x);e.strokeStyle=d,e.lineWidth=h,e.stroke(b),e.translate(0-m,0-S),e.setTransform(1,0,0,1,0,0),Q(e,{...t},(()=>{null==i||i()})),e.restore()}else null==i||i()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,parentOpacity:c})):w()}function re(e,t,n){var i,o;const{pattern:a,viewScaleInfo:r,viewSizeInfo:l}=n,s=[];if(t.detail.background||a){const{x:n,y:c,w:d,h:h,radiusList:f}=ee(t,{viewScaleInfo:r,viewSizeInfo:l});if(e.beginPath(),e.moveTo(n+f[0],c),e.arcTo(n+d,c,n+d,c+h,f[1]),e.arcTo(n+d,c+h,n,c+h,f[2]),e.arcTo(n,c+h,n,c,f[3]),e.arcTo(n,c,n+d,c,f[0]),e.closePath(),"string"==typeof a)e.fillStyle=a;else if(["CanvasPattern"].includes(R.type(a)))e.fillStyle=a;else if("string"==typeof t.detail.background)e.fillStyle=t.detail.background;else if("linear-gradient"===(null==(i=t.detail.background)?void 0:i.type)){const i=ne(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:r,opacity:e.globalAlpha});e.fillStyle=i}else if("radial-gradient"===(null==(o=t.detail.background)?void 0:o.type)){const i=ne(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:r,opacity:e.globalAlpha});if(e.fillStyle=i,s&&s.length>0)for(let t=0;t<(null==s?void 0:s.length);t++){const i=s[t];"translate"===i.method?e.translate(i.args[0]+n,i.args[1]+c):"rotate"===i.method?e.rotate(...i.args):"scale"===i.method&&e.scale(...i.args)}}e.fill(),s&&s.length>0&&e.setTransform(1,0,0,1,0,0)}}function le(e,t,n){if(0===t.detail.borderWidth)return;if(!P(t.detail.borderColor))return;const{viewScaleInfo:i}=n,{scale:o}=i;let a=ie.borderColor;!0===P(t.detail.borderColor)&&(a=t.detail.borderColor);const{borderWidth:r,borderRadius:l,borderDash:s,boxSizing:c=ie.boxSizing}=t.detail;let d=0;"number"==typeof r&&(d=r||1),d*=o;let h=[0,0,0,0];if("number"==typeof l){const e=l*o;h=[e,e,e,e]}else Array.isArray(l)&&4===(null==l?void 0:l.length)&&(h=[l[0]*o,l[1]*o,l[2]*o,l[3]*o]);e.strokeStyle=a;let f=[];Array.isArray(s)&&s.length>0&&(f=s.map((e=>Math.ceil(e*o))));let u=0,w=0,g=0,v=0;if(Array.isArray(r)&&(u=(r[0]||0)*o,w=(r[1]||0)*o,g=(r[2]||0)*o,v=(r[3]||0)*o),v||w||u||g){e.lineCap="butt";let{x:n,y:i,w:o,h:a}=t;"border-box"===c?(n+=v/2,i+=u/2,o=o-v/2-w/2,a=a-u/2-g/2):"content-box"===c?(n-=v/2,i-=u/2,o=o+v/2+w/2,a=a+u/2+g/2):(n=t.x,i=t.y,o=t.w,a=t.h),u&&(e.beginPath(),e.lineWidth=u,e.moveTo(n-v/2,i),e.lineTo(n+o+w/2,i),e.closePath(),e.stroke()),w&&(e.beginPath(),e.lineWidth=w,e.moveTo(n+o,i-u/2),e.lineTo(n+o,i+a+g/2),e.closePath(),e.stroke()),g&&(e.beginPath(),e.lineWidth=g,e.moveTo(n-v/2,i+a),e.lineTo(n+o+w/2,i+a),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(n,i-u/2),e.lineTo(n,i+a+g/2),e.closePath(),e.stroke())}else{let{x:n,y:i,w:o,h:a}=t;"border-box"===c?(n=t.x+d/2,i=t.y+d/2,o=t.w-d,a=t.h-d):"content-box"===c?(n=t.x-d/2,i=t.y-d/2,o=t.w+d,a=t.h+d):(n=t.x,i=t.y,o=t.w,a=t.h),f.length>0?e.lineCap="butt":e.lineCap="square",o=Math.max(o,1),a=Math.max(a,1),h=h.map((e=>Math.min(e,o/2,a/2))),e.setLineDash(f),e.lineWidth=d,e.beginPath(),e.moveTo(n+h[0],i),e.arcTo(n+o,i,n+o,i+a,h[1]),e.arcTo(n+o,i+a,n,i+a,h[2]),e.arcTo(n,i+a,n,i,h[3]),e.arcTo(n,i,n+o,i,h[0]),e.closePath(),e.stroke()}e.setLineDash([])}function se(e,t,n){const{detail:i}=t,{viewScaleInfo:o,renderContent:a}=n,{shadowColor:r,shadowOffsetX:l,shadowOffsetY:s,shadowBlur:c}=i;N.number(c)?(e.save(),e.shadowColor=r||ie.shadowColor,e.shadowOffsetX=(l||0)*o.scale,e.shadowOffsetY=(s||0)*o.scale,e.shadowBlur=(c||0)*o.scale,a(),e.restore()):(e.save(),e.shadowColor="transparent",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,a(),e.restore())}function ce(e,t,n){const{viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a}=n,{x:r,y:l,w:s,h:c,angle:d}=V(t,{viewScaleInfo:i})||t,h={...t,x:r,y:l,w:s,h:c,angle:d};Q(e,{x:r,y:l,w:s,h:c,angle:d},(()=>{se(e,h,{viewScaleInfo:i,viewSizeInfo:o,renderContent:()=>{ae(e,h,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:c,angle:d},viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a,renderContent:()=>{}})}})}))}const de={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};const he=.4;function fe(e,t,n){var i,o,a;if(!0===(null==(i=null==t?void 0:t.operations)?void 0:i.invisible))return;const{w:r,h:l}=t,{scale:s}=n.viewScaleInfo;if(s<1&&(r*s<he||l*s<he)||0===n.parentOpacity)return;const{overrideElementMap:c}=n;if(!(null==(a=null==(o=null==c?void 0:c[t.uuid])?void 0:o.operations)?void 0:a.invisible))try{switch(t.type){case"rect":ce(e,t,n);break;case"circle":!function(e,t,n){const{detail:i,angle:o}=t,{viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=n,{background:s="#000000",borderColor:c="#000000",boxSizing:d,borderWidth:h=0,borderDash:f}=i;let u=0;"number"==typeof h&&h>0?u=h:Array.isArray(h)&&"number"==typeof h[0]&&h[0]>0&&(u=h[0]),u*=a.scale;const{x:w,y:g,w:v,h:p}=V({x:t.x,y:t.y,w:t.w,h:t.h},{viewScaleInfo:a})||t,y={...t,x:w,y:g,w:v,h:p,angle:o};Q(e,{x:w,y:g,w:v,h:p,angle:o},(()=>{se(e,y,{viewScaleInfo:a,viewSizeInfo:r,renderContent:()=>{let t=v/2,n=p/2;const i=w+t,o=g+n,r=t,h=n;if(u>0&&("content-box"===d||("center-line"===d?(t-=u/2,n-=u/2):(t-=u,n-=u))),t>=0&&n>=0){const d=oe(y)*l;e.globalAlpha=d,e.beginPath();const m=ne(e,s,{viewElementSize:{x:w,y:g,w:v,h:p},viewScaleInfo:a,opacity:e.globalAlpha});if(e.fillStyle=m,e.circle(i,o,r,h,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=l,"number"==typeof u&&u>0){const r=u/2+t,l=u/2+n;if(e.beginPath(),f){const t=f.map((e=>e*a.scale));e.setLineDash(t)}e.strokeStyle=c,e.lineWidth=u,e.circle(i,o,r,l,0,0,2*Math.PI),e.closePath(),e.stroke(),e.setLineDash([])}}}})}))}(e,t,n);break;case"text":!function(e,t,n){const{viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a}=n,{x:r,y:l,w:s,h:c,angle:d}=V(t,{viewScaleInfo:i})||t,h={...t,x:r,y:l,w:s,h:c,angle:d};Q(e,{x:r,y:l,w:s,h:c,angle:d},(()=>{se(e,h,{viewScaleInfo:i,viewSizeInfo:o,renderContent:()=>{ae(e,h,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:c,angle:d},viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a})}});{const o={...de,...t.detail},a=o.fontSize||de.fontSize,d=a*i.scale;if(d<2)return;const h=(o.lineHeight||a)*i.scale;e.fillStyle=t.detail.color||de.color,e.textBaseline="top",e.$setFont({fontWeight:o.fontWeight,fontSize:d,fontFamily:(n=o.fontFamily,[n,...te].join(", "))});let f=o.text.replace(/\r\n/gi,"\n");"lowercase"===o.textTransform?f=f.toLowerCase():"uppercase"===o.textTransform&&(f=f.toUpperCase());const u=h,w=f.split("\n"),g=[];let v=0;w.forEach(((t,n)=>{if("maxContent"===o.minInlineSize)g.push({text:t,width:e.$undoPixelRatio(e.measureText(t).width)});else{let l="",d="",h=t.split(d);if("normal"===o.wordBreak){const e=" ",n=t.split(e);h=[],n.forEach(((t,i)=>{h.push(t),i<n.length-1&&h.push(e)}))}if(1===h.length&&"visible"===o.overflow)g.push({text:h[0],width:e.$undoPixelRatio(e.measureText(h[0]).width)});else if(h.length>0){for(let t=0;t<h.length&&(a=e.$doPixelRatio(s),r=e.measureText(l+h[t]).width,i.scale<.5&&a<r&&(a-r)/a>-.15||a>=r?l+=h[t]||"":(g.push({text:l,width:e.$undoPixelRatio(e.measureText(l).width)}),l=h[t]||"",v++),!((v+1)*u>c&&"hidden"===o.overflow));t++)if(h.length-1===t&&(v+1)*u<=c){g.push({text:l,width:e.$undoPixelRatio(e.measureText(l).width)}),n<w.length-1&&v++;break}}else g.push({text:"",width:0})}var a,r}));let p=0,y=0;u>d&&(y=(u-d)/2),g.length*u<c&&("top"===t.detail.verticalAlign?p=0:"bottom"===t.detail.verticalAlign?p+=c-g.length*u:p+=(c-g.length*u)/2);{const t=l+p;void 0!==o.textShadowColor&&P(o.textShadowColor)&&(e.shadowColor=o.textShadowColor),void 0!==o.textShadowOffsetX&&N.number(o.textShadowOffsetX)&&(e.shadowOffsetX=o.textShadowOffsetX),void 0!==o.textShadowOffsetY&&N.number(o.textShadowOffsetY)&&(e.shadowOffsetY=o.textShadowOffsetY),void 0!==o.textShadowBlur&&N.number(o.textShadowBlur)&&(e.shadowBlur=o.textShadowBlur),g.forEach(((n,i)=>{let a=r;"center"===o.textAlign?a=r+(s-n.width)/2:"right"===o.textAlign&&(a=r+(s-n.width)),e.fillText(n.text,a,t+u*i+y)}))}}var n}))}(e,t,n);break;case"image":!function(e,t,n){const i=n.loader.getContent(t),{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=V(t,{viewScaleInfo:o})||t,f={...t,x:l,y:s,w:c,h:d,angle:h};Q(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{se(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{ae(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:c,h:d,angle:h},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{if(i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"image"===t.type&&i){e.globalAlpha=oe(t)*r;const{x:n,y:l,w:s,h:c,radiusList:d}=ee(f,{viewScaleInfo:o,viewSizeInfo:a}),{detail:h}=t,{scaleMode:u,originW:w=0,originH:g=0}=h,v=e.$undoPixelRatio(w),p=e.$undoPixelRatio(g);if(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(n+d[0],l),e.arcTo(n+s,l,n+s,l+c,d[1]),e.arcTo(n+s,l+c,n,l+c,d[2]),e.arcTo(n,l+c,n,l,d[3]),e.arcTo(n,l,n+s,l,d[0]),e.closePath(),e.fill(),e.clip(),u&&g&&w){let o=0,a=0,r=v,d=p;const h=n,f=l,w=s,g=c;if(v>t.w||p>t.h)if("fill"===u){const e=Math.max(t.w/v,t.h/p),n=p*e;o=(v*e-t.w)/2/e,a=(n-t.h)/2/e,r=t.w/e,d=t.h/e}else if("tile"===u)o=0,a=0,r=t.w,d=t.h;else if("fit"===u){const e=Math.min(t.w/v,t.h/p);o=(v-t.w/e)/2,a=(p-t.h/e)/2,r=t.w/e,d=t.h/e}e.drawImage(i,o,a,r,d,h,f,w,g)}else e.drawImage(i,n,l,s,c);e.globalAlpha=r,e.restore()}}})}})}))}(e,t,n);break;case"svg":!function(e,t,n){const i=n.loader.getContent(t),{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=V(t,{viewScaleInfo:o,viewSizeInfo:a})||t;Q(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"svg"===t.type&&i&&(e.globalAlpha=oe(t)*r,e.drawImage(i,l,s,c,d),e.globalAlpha=r)}))}(e,t,n);break;case"html":!function(e,t,n){const i=n.loader.getContent(t),{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=V(t,{viewScaleInfo:o,viewSizeInfo:a})||t;Q(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"html"===t.type&&i&&(e.globalAlpha=oe(t)*r,e.drawImage(i,l,s,c,d),e.globalAlpha=r)}))}(e,t,n);break;case"path":!function(e,t,n){var i,o;const{detail:a}=t,{originX:r,originY:l,originW:s,originH:c,fillRule:d}=a,{viewScaleInfo:h,viewSizeInfo:f,parentOpacity:u}=n,{x:w,y:g,w:v,h:p,angle:y}=V(t,{viewScaleInfo:h})||t,m=v/s,S=p/c,x=w-r*m,b=g-l*S,{clipPath:I,clipPathStrokeColor:z,clipPathStrokeWidth:T,...k}=t.detail,A=h.scale*f.devicePixelRatio,C={...t,x:w,y:g,w:v,h:p,angle:y};let P={...C};P.detail=k;let E={...t};E.detail=k,a.fill&&"string"!==a.fill&&(null==(o=null==(i=a.fill)?void 0:i.type)?void 0:o.includes("gradient"))&&(P={...C,detail:{...C.detail,background:a.fill,clipPath:{commands:a.commands,originX:r,originY:l,originW:s,originH:c}}},E.detail={...P.detail}),Q(e,{x:w,y:g,w:v,h:p,angle:y},(()=>{ae(e,P,{originElem:E,calcElemSize:{x:w,y:g,w:v,h:p,angle:y},viewScaleInfo:h,viewSizeInfo:f,parentOpacity:u,renderContent:()=>{se(e,C,{viewScaleInfo:h,viewSizeInfo:f,renderContent:()=>{e.save(),e.translate(x,b),e.scale(A*m/h.scale,A*S/h.scale);const t=Z(a.commands||[]),n=new Path2D(t);a.fill&&("string"==typeof a.fill?e.fillStyle=a.fill:e.fillStyle="transparent"),a.fill&&e.fill(n,d),a.stroke&&0!==a.strokeWidth&&(e.strokeStyle=a.stroke,e.lineWidth=(a.strokeWidth||1)/f.devicePixelRatio,e.lineCap=a.strokeLineCap||"square",e.stroke(n)),e.translate(-x,-b),e.restore()}})}})}))}(e,t,n);break;case"group":{const i={...n.elementAssets||{},...t.detail.assets||{}};!function(e,t,n){const{viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a}=n,{x:r,y:l,w:s,h:c,angle:d}=V({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},{viewScaleInfo:i})||t,h={...t,x:r,y:l,w:s,h:c,angle:d};Q(e,{x:r,y:l,w:s,h:c,angle:d},(()=>{e.globalAlpha=oe(t)*a,se(e,h,{viewScaleInfo:i,viewSizeInfo:o,renderContent:()=>{ae(e,h,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:c,angle:d},viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a,renderContent:()=>{const{x:r,y:l,w:s,h:c,radiusList:d}=ee(h,{viewScaleInfo:i,viewSizeInfo:o});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(r+d[0],l),e.arcTo(r+s,l,r+s,l+c,d[1]),e.arcTo(r+s,l+c,r,l+c,d[2]),e.arcTo(r,l+c,r,l,d[3]),e.arcTo(r,l,r+s,l,d[0]),e.closePath(),e.fill(),e.clip()),Array.isArray(t.detail.children)){const{parentElementSize:i}=n,o={x:i.x+t.x,y:i.y+t.y,w:t.w||i.w,h:t.h||i.h,angle:t.angle},{calculator:r}=n;for(let i=0;i<t.detail.children.length;i++){let l=t.detail.children[i];if(l={...l,x:o.x+l.x,y:o.y+l.y},!0===n.forceDrawAll||(null==r?void 0:r.needRender(l)))try{fe(e,l,{...n,parentOpacity:a*oe(t)})}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&e.restore()}})}}),e.globalAlpha=a}))}(e,t,{...n,elementAssets:i});break}}}catch(e){console.error(e)}}const ue={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function we(e,t,n){var i;const{elements:o=[]}=t,{parentOpacity:a}=n;for(let t=0;t<o.length;t++){const r=o[t],l={...r,detail:{...ue,...null==r?void 0:r.detail}};if(!0===n.forceDrawAll||(null==(i=n.calculator)?void 0:i.needRender(l)))try{fe(e,l,{...n,parentOpacity:a})}catch(e){console.error(e)}}}const ge=["image","svg","html"],ve=e=>{var t,n,i;let o=null;return"image"===e.type?o=(null==(t=null==e?void 0:e.detail)?void 0:t.src)||null:"svg"===e.type?o=(null==(n=null==e?void 0:e.detail)?void 0:n.svg)||null:"html"===e.type&&(o=(null==(i=null==e?void 0:e.detail)?void 0:i.html)||null),"string"==typeof o&&o?/^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.test(`${o}`)?o:$(o):$(`${W()}-${e.uuid}-${W()}-${W()}`)};class pe extends J{constructor(){super(),k(this,a),k(this,l),k(this,c),k(this,h),k(this,u),k(this,g),k(this,p),k(this,t,{}),k(this,n,{}),k(this,i,{}),k(this,o,!1),C(this,a,r).call(this,"image",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.src])?void 0:n.value)||e.detail.src,o=await B(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}})),C(this,a,r).call(this,"html",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.html])?void 0:n.value)||e.detail.html,o=await Y(i,{width:e.detail.originW||e.w,height:e.detail.originH||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:o}})),C(this,a,r).call(this,"svg",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.svg])?void 0:n.value)||e.detail.svg,o=await X(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}}))}isDestroyed(){return T(this,o)}destroy(){A(this,o,!0),this.clear(),A(this,t,null),A(this,n,null),A(this,i,null)}load(e,t){!0!==T(this,o)&&(C(this,p,y).call(this,e)||ge.includes(e.type)&&C(this,g,v).call(this,e,t))}getContent(e){var t,n;const o=ve(e);return(null==(n=null==(t=T(this,i))?void 0:t[o])?void 0:n.content)||null}getLoadItemMap(){return T(this,i)}setLoadItemMap(e){A(this,i,e)}}t=new WeakMap,n=new WeakMap,i=new WeakMap,o=new WeakMap,a=new WeakSet,r=function(e,n){T(this,t)[e]=n},l=new WeakSet,s=function(e){var t,n,i;let o=null;return"image"===e.type?o=(null==(t=null==e?void 0:e.detail)?void 0:t.src)||null:"svg"===e.type?o=(null==(n=null==e?void 0:e.detail)?void 0:n.svg)||null:"html"===e.type&&(o=(null==(i=null==e?void 0:e.detail)?void 0:i.html)||null),o},c=new WeakSet,d=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:C(this,l,s).call(this,e)}},h=new WeakSet,f=function(e){const t=ve(e.element),n=T(this,i)[t];T(this,o)||(n?n.startTime<e.startTime&&(T(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})):(T(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})))},u=new WeakSet,w=function(e){var t;const n=ve(e.element),a=null==(t=T(this,i))?void 0:t[n];T(this,o)||(a?a.startTime<e.startTime&&(T(this,i)[n]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})):(T(this,i)[n]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})))},g=new WeakSet,v=function(e,i){const a=C(this,c,d).call(this,e),r=ve(e);if(T(this,n)[r])return;T(this,n)[r]=a;const l=T(this,t)[e.type];"function"!=typeof l||T(this,o)||(a.startTime=Date.now(),l(e,i).then((e=>{T(this,o)||(a.content=e.content,a.endTime=Date.now(),a.status="load",C(this,h,f).call(this,a))})).catch((t=>{console.warn(`Load element source "${a.source}" fail`,t,e),a.endTime=Date.now(),a.status="error",a.error=t,C(this,u,w).call(this,a)})))},p=new WeakSet,y=function(e){var t;const i=ve(e),o=null==(t=T(this,n))?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==C(this,l,s).call(this,e))};return m=new WeakMap,S=new WeakMap,x=new WeakMap,b=new WeakSet,I=function(){const e=T(this,S);e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(e=>{console.error(e)}))},e.Renderer=class extends J{constructor(e){super(),k(this,b),k(this,m,void 0),k(this,S,new pe),k(this,x,!1),A(this,m,e),C(this,b,I).call(this)}isDestroyed(){return T(this,x)}destroy(){this.clear(),A(this,m,null),T(this,S).destroy(),A(this,S,null),A(this,x,!0)}updateOptions(e){A(this,m,e)}drawData(e,t){const n=T(this,S),{calculator:i,sharer:o}=T(this,m),a=T(this,m).viewContext;a.clearRect(0,0,a.canvas.width,a.canvas.height);const r={loader:n,calculator:i,parentElementSize:{x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height},elementAssets:e.assets,parentOpacity:1,overrideElementMap:null==o?void 0:o.getActiveOverrideElemenentMap(),...t};!function(e,t,n){if("string"==typeof(null==t?void 0:t.background)){const{viewSizeInfo:i}=n,{width:o,height:a}=i;e.globalAlpha=1,e.fillStyle=t.background,e.fillRect(0,0,o,a)}}(a,e.global,r),e.layout?function(e,t,n,i){const{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,l={uuid:"layout",type:"group",...t},{x:s,y:c,w:d,h:h}=V(l,{viewScaleInfo:o})||l,f={...l,x:s,y:c,w:d,h:h,angle:0};if(e.globalAlpha=1,se(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{re(e,f,{viewScaleInfo:o,viewSizeInfo:a})}}),"hidden"===t.detail.overflow){const{viewScaleInfo:i,viewSizeInfo:o}=n,a={uuid:"layout",type:"group",...t},r=V(a,{viewScaleInfo:i})||a,l={...a,...r},{x:s,y:c,w:d,h:h,radiusList:f}=ee(l,{viewScaleInfo:i,viewSizeInfo:o});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(s+f[0],c),e.arcTo(s+d,c,s+d,c+h,f[1]),e.arcTo(s+d,c+h,s,c+h,f[2]),e.arcTo(s,c+h,s,c,f[3]),e.arcTo(s,c,s+d,c,f[0]),e.closePath(),e.fill(),e.clip()}i(e),"hidden"===t.detail.overflow&&e.restore(),le(e,f,{viewScaleInfo:o,viewSizeInfo:a}),e.globalAlpha=r}(a,e.layout,r,(()=>{we(a,e,r)})):we(a,e,r)}scale(e){const{sharer:t}=T(this,m);if(!t)return;const{data:n,offsetTop:i,offsetBottom:o,offsetLeft:a,offsetRight:r,width:l,height:s,contextHeight:c,contextWidth:d,devicePixelRatio:h}=t.getActiveStoreSnapshot();n&&this.drawData(n,{viewScaleInfo:{scale:e,offsetTop:i,offsetBottom:o,offsetLeft:a,offsetRight:r},viewSizeInfo:{width:l,height:s,contextHeight:c,contextWidth:d,devicePixelRatio:h}})}setLoadItemMap(e){T(this,S).setLoadItemMap(e)}getLoadItemMap(){return T(this,S).getLoadItemMap()}getLoader(){return T(this,S)}},e.drawRect=ce,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
|
|
1
|
+
var iDrawRenderer=function(e){"use strict";var t,n,i,o,a,r,l,s,c,d,h,f,u,w,g,v,p,y=e=>{throw TypeError(e)},m=(e,t,n)=>t.has(e)||y("Cannot "+n),S=(e,t,n)=>(m(e,t,"read from private field"),n?n.call(e):t.get(e)),x=(e,t,n)=>t.has(e)?y("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),b=(e,t,n,i)=>(m(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),I=(e,t,n)=>(m(e,t,"access private method"),n);function z(e){return"string"==typeof e&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e))}function T(e,t){if(1===t)return e;let n=1;const i=/^\#[0-9a-f]{6,6}$/i;let o=e;if(i.test(e)?n=parseInt(e.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(e)&&(n=parseInt(e.substring(7,9).replace(/^\#/,"0x")),o=e.substring(0,7)),n*=t,i.test(o)&&n>0&&n<1){const e=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${e.toString(16).toUpperCase()}`}return o}function A(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function k(e){let t=0;for(let n=0;n<e.length;n++)t+=e.charCodeAt(n)*e.charCodeAt(n)*n*n;return t.toString(16).substring(0,4)}function C(e){const t=e.length,n=Math.floor(t/2),i=e.substring(0,4).padEnd(4,"0"),o=e.substring(0,4).padEnd(4,"0");return`@assets/${k(t.toString(16).padEnd(4,i))}${k(e.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${k(e.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${k(e.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${k(e.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${k(e.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${k(e.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${k(o.padEnd(4,i).padEnd(4,o))}`}function E(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const P={type(e,t){const n=E(e);return!0===t?n.toLocaleLowerCase():n},array:e=>"Array"===E(e),json:e=>"Object"===E(e),function:e=>"Function"===E(e),asyncFunction:e=>"AsyncFunction"===E(e),boolean:e=>"Boolean"===E(e),string:e=>"String"===E(e),number:e=>"Number"===E(e),undefined:e=>"Undefined"===E(e),null:e=>"Null"===E(e),promise:e=>"Promise"===E(e)};var O=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function r(e){try{s(i.next(e))}catch(e){a(e)}}function l(e){try{s(i.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,l)}s((i=i.apply(e,t||[])).next())}))};const{Image:W}=window;function $(e){return new Promise(((t,n)=>{const i=new W;i.crossOrigin="anonymous",i.onload=function(){t(i)},i.onabort=n,i.onerror=n,i.src=e}))}function M(e){return O(this,void 0,void 0,(function*(){const t=yield function(e){return new Promise(((t,n)=>{const i=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(e){var n;const i=null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result;t(i)},o.onerror=function(e){n(e)}}))}(e);return yield $(t)}))}function R(e,t){return O(this,void 0,void 0,(function*(){e=e.replace(/\&/gi,"&");const n=yield function(e,t){const{width:n,height:i}=t;return new Promise(((t,o)=>{const a=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${n||""}" \n height = "${i||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${e}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),r=new FileReader;r.readAsDataURL(a),r.onload=function(e){var n;const i=null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result;t(i)},r.onerror=function(e){o(e)}}))}(e,t);return yield $(n)}))}function D(e){return"number"==typeof e&&(e>0||e<=0)}function L(e){return"number"==typeof e&&e>=0}function B(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function X(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const Y={x:function(e){return D(e)},y:function(e){return D(e)},w:L,h:function(e){return"number"==typeof e&&e>=0},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:D,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return L(e)},borderRadius:function(e){return D(e)&&e>=0},color:function(e){return z(e)},imageSrc:function(e){return X(e)||B(e)},imageURL:B,imageBase64:X,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let n=document.createElement("div");n.innerHTML=e,n.children.length>0&&(t=!0),n=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return D(e)&&e>0},lineHeight:function(e){return D(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)},strokeWidth:function(e){return D(e)&&e>0}};var F,H=function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};class j{constructor(){F.set(this,void 0),function(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===i?o.call(e,n):o?o.value=n:t.set(e,n)}(this,F,new Map,"f")}on(e,t){if(H(this,F,"f").has(e)){const n=H(this,F,"f").get(e)||[];null==n||n.push(t),H(this,F,"f").set(e,n)}else H(this,F,"f").set(e,[t])}off(e,t){if(H(this,F,"f").has(e)){const n=H(this,F,"f").get(e);if(Array.isArray(n))for(let e=0;e<(null==n?void 0:n.length);e++)if(n[e]===t){n.splice(e,1);break}H(this,F,"f").set(e,n||[])}}trigger(e,t){const n=H(this,F,"f").get(e);return!!Array.isArray(n)&&(n.forEach((e=>{e(t)})),!0)}has(e){if(H(this,F,"f").has(e)){const t=H(this,F,"f").get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){H(this,F,"f").clear()}}function U(e,t,n,i){const o=function(e){return e/180*Math.PI}(t||0);n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(o),e.translate(-n.x,-n.y)),i(e),n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(-o),e.translate(-n.x,-n.y))}function G(e,t,n){const i={x:(o=t).x+o.w/2,y:o.y+o.h/2};var o;U(e,t.angle||0,i,(()=>{n(e)}))}function N(e,t){const{viewScaleInfo:n}=t,{x:i,y:o,w:a,h:r,angle:l}=e,{scale:s,offsetTop:c,offsetLeft:d}=n;return{x:i*s+d,y:o*s+c,w:a*s,h:r*s,angle:l}}function q(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}F=new WeakMap;const V={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function J(e,t){const{viewScaleInfo:n}=t,{scale:i}=n;let{borderRadius:o,borderDash:a}=e.detail;const r=Array.isArray(a)&&a.length>0,{boxSizing:l=V.boxSizing,borderWidth:s}=e.detail;Array.isArray(s)&&(o=0);let{x:c,y:d,w:h,h:f}=e,u=[0,0,0,0];if("number"==typeof o){const e=o*i;u=[e,e,e,e]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(u=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let w=0;return"number"==typeof s&&(w=(s||0)*i),"border-box"!==l||r?"content-box"===l?(c=e.x-w/2,d=e.y-w/2,h=e.w+w,f=e.h+w):(c=e.x,d=e.y,h=e.w,f=e.h):(c=e.x+w/2,d=e.y+w/2,h=e.w-w,f=e.h-w),h=Math.max(h,1),f=Math.max(f,1),u=u.map((e=>Math.min(e,h/2,f/2))),{x:c,y:d,w:h,h:f,radiusList:u}}const K=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function Q(e,t,n){if("string"==typeof t)return t;const{viewElementSize:i,viewScaleInfo:o,opacity:a=1}=n,{x:r,y:l}=i,{scale:s}=o;if("linear-gradient"===(null==t?void 0:t.type)){const{start:n,end:i,stops:o}=t,c={x:r+n.x*s,y:l+n.y*s},d={x:r+i.x*s,y:l+i.y*s},h=e.createLinearGradient(c.x,c.y,d.x,d.y);return o.forEach((e=>{h.addColorStop(e.offset,T(e.color,a))})),h}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:n,outer:i,stops:o}=t,c={x:r+n.x*s,y:l+n.y*s,radius:n.radius*s},d={x:r+i.x*s,y:l+i.y*s,radius:i.radius*s},h=e.createRadialGradient(c.x,c.y,c.radius,d.x,d.y,d.radius);return o.forEach((e=>{h.addColorStop(e.offset,T(e.color,a))})),h}return"#000000"}const Z={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function _(e){var t,n,i,o;let a=1;return void 0!==(null==(t=null==e?void 0:e.detail)?void 0:t.opacity)&&(null==(n=null==e?void 0:e.detail)?void 0:n.opacity)>=0&&(null==(i=null==e?void 0:e.detail)?void 0:i.opacity)<=1&&(a=null==(o=null==e?void 0:e.detail)?void 0:o.opacity),a}function ee(e,t,n){const{pattern:i,renderContent:o,originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s}=n||{},{parentOpacity:c}=n,d=_(a)*c,{clipPath:h,clipPathStrokeColor:f,clipPathStrokeWidth:u}=a.detail,w=()=>{e.globalAlpha=d,te(e,t,{pattern:i,viewScaleInfo:l,viewSizeInfo:s}),null==o||o(),ne(e,t,{viewScaleInfo:l,viewSizeInfo:s}),e.globalAlpha=c};h?(function(e,t,n){const{renderContent:i,originElem:o,calcElemSize:a,viewSizeInfo:r}=n,l=r.devicePixelRatio,{clipPath:s}=(null==o?void 0:o.detail)||{};if(s&&a&&s.commands){const{x:n,y:o,w:r,h:c}=a,{originW:d,originH:h,originX:f,originY:u}=s,w=r/d,g=c/h,v=n-f*w,p=o-u*g;e.save(),e.translate(v,p),e.scale(l*w,l*g);const y=q(s.commands||[]),m=new Path2D(y);e.clip(m),e.translate(0-v,0-p),e.setTransform(1,0,0,1,0,0),G(e,{...t},(()=>{null==i||i()})),e.restore()}else null==i||i()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,renderContent:()=>{w()}}),"number"==typeof u&&u>0&&f&&function(e,t,n){const{renderContent:i,originElem:o,calcElemSize:a,viewSizeInfo:r,parentOpacity:l}=n,s=r.devicePixelRatio,{clipPath:c,clipPathStrokeColor:d,clipPathStrokeWidth:h}=(null==o?void 0:o.detail)||{};if(c&&a&&c.commands&&"number"==typeof h&&h>0&&d){const{x:n,y:o,w:r,h:f}=a,{originW:u,originH:w,originX:g,originY:v}=c,p=r/u,y=f/w,m=n-g*p,S=o-v*y;e.save(),e.globalAlpha=l,e.translate(m,S),e.scale(s*p,s*y);const x=q(c.commands||[]),b=new Path2D(x);e.strokeStyle=d,e.lineWidth=h,e.stroke(b),e.translate(0-m,0-S),e.setTransform(1,0,0,1,0,0),G(e,{...t},(()=>{null==i||i()})),e.restore()}else null==i||i()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,parentOpacity:c})):w()}function te(e,t,n){var i,o;const{pattern:a,viewScaleInfo:r,viewSizeInfo:l}=n,s=[];if(t.detail.background||a){const{x:n,y:c,w:d,h:h,radiusList:f}=J(t,{viewScaleInfo:r,viewSizeInfo:l});if(e.beginPath(),e.moveTo(n+f[0],c),e.arcTo(n+d,c,n+d,c+h,f[1]),e.arcTo(n+d,c+h,n,c+h,f[2]),e.arcTo(n,c+h,n,c,f[3]),e.arcTo(n,c,n+d,c,f[0]),e.closePath(),"string"==typeof a)e.fillStyle=a;else if(["CanvasPattern"].includes(P.type(a)))e.fillStyle=a;else if("string"==typeof t.detail.background)e.fillStyle=t.detail.background;else if("linear-gradient"===(null==(i=t.detail.background)?void 0:i.type)){const i=Q(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:r,opacity:e.globalAlpha});e.fillStyle=i}else if("radial-gradient"===(null==(o=t.detail.background)?void 0:o.type)){const i=Q(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:r,opacity:e.globalAlpha});if(e.fillStyle=i,s&&s.length>0)for(let t=0;t<(null==s?void 0:s.length);t++){const i=s[t];"translate"===i.method?e.translate(i.args[0]+n,i.args[1]+c):"rotate"===i.method?e.rotate(...i.args):"scale"===i.method&&e.scale(...i.args)}}e.fill(),s&&s.length>0&&e.setTransform(1,0,0,1,0,0)}}function ne(e,t,n){if(0===t.detail.borderWidth)return;if(!z(t.detail.borderColor))return;const{viewScaleInfo:i}=n,{scale:o}=i;let a=Z.borderColor;!0===z(t.detail.borderColor)&&(a=t.detail.borderColor);const{borderWidth:r,borderRadius:l,borderDash:s,boxSizing:c=Z.boxSizing}=t.detail;let d=0;"number"==typeof r&&(d=r||1),d*=o;let h=[0,0,0,0];if("number"==typeof l){const e=l*o;h=[e,e,e,e]}else Array.isArray(l)&&4===(null==l?void 0:l.length)&&(h=[l[0]*o,l[1]*o,l[2]*o,l[3]*o]);e.strokeStyle=a;let f=[];Array.isArray(s)&&s.length>0&&(f=s.map((e=>Math.ceil(e*o))));let u=0,w=0,g=0,v=0;if(Array.isArray(r)&&(u=(r[0]||0)*o,w=(r[1]||0)*o,g=(r[2]||0)*o,v=(r[3]||0)*o),v||w||u||g){e.lineCap="butt";let{x:n,y:i,w:o,h:a}=t;"border-box"===c?(n+=v/2,i+=u/2,o=o-v/2-w/2,a=a-u/2-g/2):"content-box"===c?(n-=v/2,i-=u/2,o=o+v/2+w/2,a=a+u/2+g/2):(n=t.x,i=t.y,o=t.w,a=t.h),u&&(e.beginPath(),e.lineWidth=u,e.moveTo(n-v/2,i),e.lineTo(n+o+w/2,i),e.closePath(),e.stroke()),w&&(e.beginPath(),e.lineWidth=w,e.moveTo(n+o,i-u/2),e.lineTo(n+o,i+a+g/2),e.closePath(),e.stroke()),g&&(e.beginPath(),e.lineWidth=g,e.moveTo(n-v/2,i+a),e.lineTo(n+o+w/2,i+a),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(n,i-u/2),e.lineTo(n,i+a+g/2),e.closePath(),e.stroke())}else{let{x:n,y:i,w:o,h:a}=t;"border-box"===c?(n=t.x+d/2,i=t.y+d/2,o=t.w-d,a=t.h-d):"content-box"===c?(n=t.x-d/2,i=t.y-d/2,o=t.w+d,a=t.h+d):(n=t.x,i=t.y,o=t.w,a=t.h),f.length>0?e.lineCap="butt":e.lineCap="square",o=Math.max(o,1),a=Math.max(a,1),h=h.map((e=>Math.min(e,o/2,a/2))),e.setLineDash(f),e.lineWidth=d,e.beginPath(),e.moveTo(n+h[0],i),e.arcTo(n+o,i,n+o,i+a,h[1]),e.arcTo(n+o,i+a,n,i+a,h[2]),e.arcTo(n,i+a,n,i,h[3]),e.arcTo(n,i,n+o,i,h[0]),e.closePath(),e.stroke()}e.setLineDash([])}function ie(e,t,n){const{detail:i}=t,{viewScaleInfo:o,renderContent:a}=n,{shadowColor:r,shadowOffsetX:l,shadowOffsetY:s,shadowBlur:c}=i;Y.number(c)?(e.save(),e.shadowColor=r||Z.shadowColor,e.shadowOffsetX=(l||0)*o.scale,e.shadowOffsetY=(s||0)*o.scale,e.shadowBlur=(c||0)*o.scale,a(),e.restore()):(e.save(),e.shadowColor="transparent",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,a(),e.restore())}function oe(e,t,n){const{detail:i,angle:o}=t,{viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=n,{background:s="#000000",borderColor:c="#000000",boxSizing:d,borderWidth:h=0,borderDash:f}=i;let u=0;"number"==typeof h&&h>0?u=h:Array.isArray(h)&&"number"==typeof h[0]&&h[0]>0&&(u=h[0]),u*=a.scale;const{x:w,y:g,w:v,h:p}=N({x:t.x,y:t.y,w:t.w,h:t.h},{viewScaleInfo:a})||t,y={...t,x:w,y:g,w:v,h:p,angle:o};G(e,{x:w,y:g,w:v,h:p,angle:o},(()=>{ie(e,y,{viewScaleInfo:a,viewSizeInfo:r,renderContent:()=>{let t=v/2,n=p/2;const i=w+t,o=g+n,r=t,h=n;if(u>0&&("content-box"===d||("center-line"===d?(t-=u/2,n-=u/2):(t-=u,n-=u))),t>=0&&n>=0){const d=_(y)*l;e.globalAlpha=d,e.beginPath();const m=Q(e,s,{viewElementSize:{x:w,y:g,w:v,h:p},viewScaleInfo:a,opacity:e.globalAlpha});if(e.fillStyle=m,e.circle(i,o,r,h,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=l,"number"==typeof u&&u>0){const r=u/2+t,l=u/2+n;if(e.beginPath(),f){const t=f.map((e=>e*a.scale));e.setLineDash(t)}e.strokeStyle=c,e.lineWidth=u,e.circle(i,o,r,l,0,0,2*Math.PI),e.closePath(),e.stroke(),e.setLineDash([])}}}})}))}function ae(e,t,n){const{viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a}=n,{x:r,y:l,w:s,h:c,angle:d}=N(t,{viewScaleInfo:i})||t,h={...t,x:r,y:l,w:s,h:c,angle:d};G(e,{x:r,y:l,w:s,h:c,angle:d},(()=>{ie(e,h,{viewScaleInfo:i,viewSizeInfo:o,renderContent:()=>{ee(e,h,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:c,angle:d},viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a,renderContent:()=>{}})}})}))}function re(e,t,n){const i=n.loader.getContent(t),{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=N(t,{viewScaleInfo:o})||t,f={...t,x:l,y:s,w:c,h:d,angle:h};G(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{ie(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{ee(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:c,h:d,angle:h},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{if(i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"image"===t.type&&i){e.globalAlpha=_(t)*r;const{x:n,y:l,w:s,h:c,radiusList:d}=J(f,{viewScaleInfo:o,viewSizeInfo:a}),{detail:h}=t,{scaleMode:u,originW:w=0,originH:g=0}=h,v=e.$undoPixelRatio(w),p=e.$undoPixelRatio(g);if(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(n+d[0],l),e.arcTo(n+s,l,n+s,l+c,d[1]),e.arcTo(n+s,l+c,n,l+c,d[2]),e.arcTo(n,l+c,n,l,d[3]),e.arcTo(n,l,n+s,l,d[0]),e.closePath(),e.fill(),e.clip(),u&&g&&w){let o=0,a=0,r=v,d=p;const h=n,f=l,w=s,g=c;if(v>t.w||p>t.h)if("fill"===u){const e=Math.max(t.w/v,t.h/p),n=p*e;o=(v*e-t.w)/2/e,a=(n-t.h)/2/e,r=t.w/e,d=t.h/e}else if("tile"===u)o=0,a=0,r=t.w,d=t.h;else if("fit"===u){const e=Math.min(t.w/v,t.h/p);o=(v-t.w/e)/2,a=(p-t.h/e)/2,r=t.w/e,d=t.h/e}e.drawImage(i,o,a,r,d,h,f,w,g)}else e.drawImage(i,n,l,s,c);e.globalAlpha=r,e.restore()}}})}})}))}function le(e,t,n){const i=n.loader.getContent(t),{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=N(t,{viewScaleInfo:o,viewSizeInfo:a})||t;G(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"svg"===t.type&&i&&(e.globalAlpha=_(t)*r,e.drawImage(i,l,s,c,d),e.globalAlpha=r)}))}function se(e,t,n){const i=n.loader.getContent(t),{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=N(t,{viewScaleInfo:o,viewSizeInfo:a})||t;G(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"html"===t.type&&i&&(e.globalAlpha=_(t)*r,e.drawImage(i,l,s,c,d),e.globalAlpha=r)}))}const ce={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function de(e,t,n){const{viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a}=n,{x:r,y:l,w:s,h:c,angle:d}=N(t,{viewScaleInfo:i})||t,h={...t,x:r,y:l,w:s,h:c,angle:d};G(e,{x:r,y:l,w:s,h:c,angle:d},(()=>{ie(e,h,{viewScaleInfo:i,viewSizeInfo:o,renderContent:()=>{ee(e,h,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:c,angle:d},viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a})}});{const o={...ce,...t.detail},a=o.fontSize||ce.fontSize,d=a*i.scale;if(d<2)return;const h=(o.lineHeight||a)*i.scale;e.fillStyle=t.detail.color||ce.color,e.textBaseline="top",e.$setFont({fontWeight:o.fontWeight,fontSize:d,fontFamily:(n=o.fontFamily,[n,...K].join(", "))});let f=o.text.replace(/\r\n/gi,"\n");"lowercase"===o.textTransform?f=f.toLowerCase():"uppercase"===o.textTransform&&(f=f.toUpperCase());const u=h,w=f.split("\n"),g=[];let v=0;w.forEach(((t,n)=>{if("maxContent"===o.minInlineSize)g.push({text:t,width:e.$undoPixelRatio(e.measureText(t).width)});else{let l="",d="",h=t.split(d);if("normal"===o.wordBreak){const e=" ",n=t.split(e);h=[],n.forEach(((t,i)=>{h.push(t),i<n.length-1&&h.push(e)}))}if(1===h.length&&"visible"===o.overflow)g.push({text:h[0],width:e.$undoPixelRatio(e.measureText(h[0]).width)});else if(h.length>0){for(let t=0;t<h.length&&(a=e.$doPixelRatio(s),r=e.measureText(l+h[t]).width,i.scale<.5&&a<r&&(a-r)/a>-.15||a>=r?l+=h[t]||"":(g.push({text:l,width:e.$undoPixelRatio(e.measureText(l).width)}),l=h[t]||"",v++),!((v+1)*u>c&&"hidden"===o.overflow));t++)if(h.length-1===t&&(v+1)*u<=c){g.push({text:l,width:e.$undoPixelRatio(e.measureText(l).width)}),n<w.length-1&&v++;break}}else g.push({text:"",width:0})}var a,r}));let p=0,y=0;u>d&&(y=(u-d)/2),g.length*u<c&&("top"===t.detail.verticalAlign?p=0:"bottom"===t.detail.verticalAlign?p+=c-g.length*u:p+=(c-g.length*u)/2);{const t=l+p;void 0!==o.textShadowColor&&z(o.textShadowColor)&&(e.shadowColor=o.textShadowColor),void 0!==o.textShadowOffsetX&&Y.number(o.textShadowOffsetX)&&(e.shadowOffsetX=o.textShadowOffsetX),void 0!==o.textShadowOffsetY&&Y.number(o.textShadowOffsetY)&&(e.shadowOffsetY=o.textShadowOffsetY),void 0!==o.textShadowBlur&&Y.number(o.textShadowBlur)&&(e.shadowBlur=o.textShadowBlur),g.forEach(((n,i)=>{let a=r;"center"===o.textAlign?a=r+(s-n.width)/2:"right"===o.textAlign&&(a=r+(s-n.width)),e.fillText(n.text,a,t+u*i+y)}))}}var n}))}const he=.4;function fe(e,t,n){var i,o,a;if(!0===(null==(i=null==t?void 0:t.operations)?void 0:i.invisible))return;const{w:r,h:l}=t,{scale:s}=n.viewScaleInfo;if(s<1&&(r*s<he||l*s<he)||0===n.parentOpacity)return;const{overrideElementMap:c}=n;if(!(null==(a=null==(o=null==c?void 0:c[t.uuid])?void 0:o.operations)?void 0:a.invisible))try{switch(t.type){case"rect":ae(e,t,n);break;case"circle":oe(e,t,n);break;case"text":de(e,t,n);break;case"image":re(e,t,n);break;case"svg":le(e,t,n);break;case"html":se(e,t,n);break;case"path":!function(e,t,n){var i,o;const{detail:a}=t,{originX:r,originY:l,originW:s,originH:c,fillRule:d}=a,{viewScaleInfo:h,viewSizeInfo:f,parentOpacity:u}=n,{x:w,y:g,w:v,h:p,angle:y}=N(t,{viewScaleInfo:h})||t,m=v/s,S=p/c,x=w-r*m,b=g-l*S,{clipPath:I,clipPathStrokeColor:z,clipPathStrokeWidth:T,...A}=t.detail,k=h.scale*f.devicePixelRatio,C={...t,x:w,y:g,w:v,h:p,angle:y};let E={...C};E.detail=A;let P={...t};P.detail=A,a.fill&&"string"!==a.fill&&(null==(o=null==(i=a.fill)?void 0:i.type)?void 0:o.includes("gradient"))&&(E={...C,detail:{...C.detail,background:a.fill,clipPath:{commands:a.commands,originX:r,originY:l,originW:s,originH:c}}},P.detail={...E.detail}),G(e,{x:w,y:g,w:v,h:p,angle:y},(()=>{ee(e,E,{originElem:P,calcElemSize:{x:w,y:g,w:v,h:p,angle:y},viewScaleInfo:h,viewSizeInfo:f,parentOpacity:u,renderContent:()=>{ie(e,C,{viewScaleInfo:h,viewSizeInfo:f,renderContent:()=>{e.save(),e.translate(x,b),e.scale(k*m/h.scale,k*S/h.scale);const t=q(a.commands||[]),n=new Path2D(t);a.fill&&("string"==typeof a.fill?e.fillStyle=a.fill:e.fillStyle="transparent"),a.fill&&e.fill(n,d),a.stroke&&0!==a.strokeWidth&&(e.strokeStyle=a.stroke,e.lineWidth=(a.strokeWidth||1)/f.devicePixelRatio,e.lineCap=a.strokeLineCap||"square",e.stroke(n)),e.translate(-x,-b),e.restore()}})}})}))}(e,t,n);break;case"group":{const i={...n.elementAssets||{},...t.detail.assets||{}};ue(e,t,{...n,elementAssets:i});break}}}catch(e){console.error(e)}}function ue(e,t,n){const{viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a}=n,{x:r,y:l,w:s,h:c,angle:d}=N({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},{viewScaleInfo:i})||t,h={...t,x:r,y:l,w:s,h:c,angle:d};G(e,{x:r,y:l,w:s,h:c,angle:d},(()=>{e.globalAlpha=_(t)*a,ie(e,h,{viewScaleInfo:i,viewSizeInfo:o,renderContent:()=>{ee(e,h,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:c,angle:d},viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a,renderContent:()=>{const{x:r,y:l,w:s,h:c,radiusList:d}=J(h,{viewScaleInfo:i,viewSizeInfo:o});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(r+d[0],l),e.arcTo(r+s,l,r+s,l+c,d[1]),e.arcTo(r+s,l+c,r,l+c,d[2]),e.arcTo(r,l+c,r,l,d[3]),e.arcTo(r,l,r+s,l,d[0]),e.closePath(),e.fill(),e.clip()),Array.isArray(t.detail.children)){const{parentElementSize:i}=n,o={x:i.x+t.x,y:i.y+t.y,w:t.w||i.w,h:t.h||i.h,angle:t.angle},{calculator:r}=n;for(let i=0;i<t.detail.children.length;i++){let l=t.detail.children[i];if(l={...l,x:o.x+l.x,y:o.y+l.y},!0===n.forceDrawAll||(null==r?void 0:r.needRender(l)))try{fe(e,l,{...n,parentOpacity:a*_(t)})}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&e.restore()}})}}),e.globalAlpha=a}))}const we={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function ge(e,t,n){var i;const{elements:o=[]}=t,{parentOpacity:a}=n;for(let t=0;t<o.length;t++){const r=o[t],l={...r,detail:{...we,...null==r?void 0:r.detail}};if(!0===n.forceDrawAll||(null==(i=n.calculator)?void 0:i.needRender(l)))try{fe(e,l,{...n,parentOpacity:a})}catch(e){console.error(e)}}}function ve(e,t,n,i){const{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,l={uuid:"layout",type:"group",...t},{x:s,y:c,w:d,h:h}=N(l,{viewScaleInfo:o})||l,f={...l,x:s,y:c,w:d,h:h,angle:0};if(e.globalAlpha=1,ie(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{te(e,f,{viewScaleInfo:o,viewSizeInfo:a})}}),"hidden"===t.detail.overflow){const{viewScaleInfo:i,viewSizeInfo:o}=n,a={uuid:"layout",type:"group",...t},r=N(a,{viewScaleInfo:i})||a,l={...a,...r},{x:s,y:c,w:d,h:h,radiusList:f}=J(l,{viewScaleInfo:i,viewSizeInfo:o});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(s+f[0],c),e.arcTo(s+d,c,s+d,c+h,f[1]),e.arcTo(s+d,c+h,s,c+h,f[2]),e.arcTo(s,c+h,s,c,f[3]),e.arcTo(s,c,s+d,c,f[0]),e.closePath(),e.fill(),e.clip()}i(e),"hidden"===t.detail.overflow&&e.restore(),ne(e,f,{viewScaleInfo:o,viewSizeInfo:a}),e.globalAlpha=r}function pe(e,t,n){if("string"==typeof(null==t?void 0:t.background)){const{viewSizeInfo:i}=n,{width:o,height:a}=i;e.globalAlpha=1,e.fillStyle=t.background,e.fillRect(0,0,o,a)}}const ye=["image","svg","html"],me=e=>{var t,n,i;let o=null;return"image"===e.type?o=(null==(t=null==e?void 0:e.detail)?void 0:t.src)||null:"svg"===e.type?o=(null==(n=null==e?void 0:e.detail)?void 0:n.svg)||null:"html"===e.type&&(o=(null==(i=null==e?void 0:e.detail)?void 0:i.html)||null),"string"==typeof o&&o?/^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.test(`${o}`)?o:C(o):C(`${A()}-${e.uuid}-${A()}-${A()}`)};class Se extends j{constructor(){super(),x(this,a),x(this,t,{}),x(this,n,{}),x(this,i,{}),x(this,o,!1),I(this,a,r).call(this,"image",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.src])?void 0:n.value)||e.detail.src,o=await $(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}})),I(this,a,r).call(this,"html",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.html])?void 0:n.value)||e.detail.html,o=await R(i,{width:e.detail.originW||e.w,height:e.detail.originH||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:o}})),I(this,a,r).call(this,"svg",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.svg])?void 0:n.value)||e.detail.svg,o=await M(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}}))}isDestroyed(){return S(this,o)}destroy(){b(this,o,!0),this.clear(),b(this,t,null),b(this,n,null),b(this,i,null)}load(e,t){!0!==S(this,o)&&(I(this,a,f).call(this,e)||ye.includes(e.type)&&I(this,a,h).call(this,e,t))}getContent(e){var t,n;const o=me(e);return(null==(n=null==(t=S(this,i))?void 0:t[o])?void 0:n.content)||null}getLoadItemMap(){return S(this,i)}setLoadItemMap(e){b(this,i,e)}}t=new WeakMap,n=new WeakMap,i=new WeakMap,o=new WeakMap,a=new WeakSet,r=function(e,n){S(this,t)[e]=n},l=function(e){var t,n,i;let o=null;return"image"===e.type?o=(null==(t=null==e?void 0:e.detail)?void 0:t.src)||null:"svg"===e.type?o=(null==(n=null==e?void 0:e.detail)?void 0:n.svg)||null:"html"===e.type&&(o=(null==(i=null==e?void 0:e.detail)?void 0:i.html)||null),o},s=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:I(this,a,l).call(this,e)}},c=function(e){const t=me(e.element),n=S(this,i)[t];S(this,o)||(n?n.startTime<e.startTime&&(S(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})):(S(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})))},d=function(e){var t;const n=me(e.element),a=null==(t=S(this,i))?void 0:t[n];S(this,o)||(a?a.startTime<e.startTime&&(S(this,i)[n]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})):(S(this,i)[n]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})))},h=function(e,i){const r=I(this,a,s).call(this,e),l=me(e);if(S(this,n)[l])return;S(this,n)[l]=r;const h=S(this,t)[e.type];"function"!=typeof h||S(this,o)||(r.startTime=Date.now(),h(e,i).then((e=>{S(this,o)||(r.content=e.content,r.endTime=Date.now(),r.status="load",I(this,a,c).call(this,r))})).catch((t=>{console.warn(`Load element source "${r.source}" fail`,t,e),r.endTime=Date.now(),r.status="error",r.error=t,I(this,a,d).call(this,r)})))},f=function(e){var t;const i=me(e),o=null==(t=S(this,n))?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==I(this,a,l).call(this,e))};return u=new WeakMap,w=new WeakMap,g=new WeakMap,v=new WeakSet,p=function(){const e=S(this,w);e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(e=>{console.error(e)}))},e.Renderer=class extends j{constructor(e){super(),x(this,v),x(this,u),x(this,w,new Se),x(this,g,!1),b(this,u,e),I(this,v,p).call(this)}isDestroyed(){return S(this,g)}destroy(){this.clear(),b(this,u,null),S(this,w).destroy(),b(this,w,null),b(this,g,!0)}updateOptions(e){b(this,u,e)}drawData(e,t){const n=S(this,w),{calculator:i,sharer:o}=S(this,u),a=S(this,u).viewContext;a.clearRect(0,0,a.canvas.width,a.canvas.height);const r={loader:n,calculator:i,parentElementSize:{x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height},elementAssets:e.assets,parentOpacity:1,overrideElementMap:null==o?void 0:o.getActiveOverrideElemenentMap(),...t};pe(a,e.global,r),e.layout?ve(a,e.layout,r,(()=>{ge(a,e,r)})):ge(a,e,r)}scale(e){const{sharer:t}=S(this,u);if(!t)return;const{data:n,offsetTop:i,offsetBottom:o,offsetLeft:a,offsetRight:r,width:l,height:s,contextHeight:c,contextWidth:d,devicePixelRatio:h}=t.getActiveStoreSnapshot();n&&this.drawData(n,{viewScaleInfo:{scale:e,offsetTop:i,offsetBottom:o,offsetLeft:a,offsetRight:r},viewSizeInfo:{width:l,height:s,contextHeight:c,contextWidth:d,devicePixelRatio:h}})}setLoadItemMap(e){S(this,w).setLoadItemMap(e)}getLoadItemMap(){return S(this,w).getLoadItemMap()}getLoader(){return S(this,w)}},e.drawCircle=oe,e.drawElement=fe,e.drawElementList=ge,e.drawGlobalBackground=pe,e.drawGroup=ue,e.drawHTML=se,e.drawImage=re,e.drawLayout=ve,e.drawRect=ae,e.drawSVG=le,e.drawText=de,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idraw/renderer",
|
|
3
|
-
"version": "0.4.0-beta.
|
|
3
|
+
"version": "0.4.0-beta.37",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"author": "chenshenhai",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@idraw/types": "^0.4.0-beta.
|
|
24
|
+
"@idraw/types": "^0.4.0-beta.37"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@idraw/util": "^0.4.0-beta.
|
|
28
|
+
"@idraw/util": "^0.4.0-beta.37"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public",
|