@idraw/renderer 0.4.0-beta.4 → 0.4.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/draw/box.d.ts +2 -0
- package/dist/esm/draw/box.js +12 -21
- package/dist/esm/draw/circle.js +28 -12
- package/dist/esm/draw/elements.js +4 -1
- package/dist/esm/draw/group.js +6 -4
- package/dist/esm/draw/html.js +4 -4
- package/dist/esm/draw/image.js +5 -5
- package/dist/esm/draw/path.js +2 -1
- package/dist/esm/draw/rect.js +2 -1
- package/dist/esm/draw/svg.js +4 -4
- package/dist/esm/draw/text.js +2 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +2 -2
- package/dist/index.global.js +68 -48
- package/dist/index.global.min.js +1 -1
- package/package.json +3 -3
package/dist/esm/draw/box.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ViewContext2D, Element, ElementType, ElementSize, ViewScaleInfo, ViewSizeInfo } from '@idraw/types';
|
|
2
|
+
export declare function getOpacity(elem: Element): number;
|
|
2
3
|
export declare function drawBox(ctx: ViewContext2D, viewElem: Element<ElementType>, opts: {
|
|
3
4
|
originElem: Element<ElementType>;
|
|
4
5
|
calcElemSize: ElementSize;
|
|
@@ -6,6 +7,7 @@ export declare function drawBox(ctx: ViewContext2D, viewElem: Element<ElementTyp
|
|
|
6
7
|
renderContent: () => void;
|
|
7
8
|
viewScaleInfo: ViewScaleInfo;
|
|
8
9
|
viewSizeInfo: ViewSizeInfo;
|
|
10
|
+
parentOpacity: number;
|
|
9
11
|
}): void;
|
|
10
12
|
export declare function drawBoxShadow(ctx: ViewContext2D, viewElem: Element<ElementType>, opts: {
|
|
11
13
|
viewScaleInfo: ViewScaleInfo;
|
package/dist/esm/draw/box.js
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import { istype, isColorStr, generateSVGPath, rotateElement, is, getDefaultElementDetailConfig, calcViewBoxSize } from '@idraw/util';
|
|
2
2
|
import { createColorStyle } from './color';
|
|
3
3
|
const defaultElemConfig = getDefaultElementDetailConfig();
|
|
4
|
+
export function getOpacity(elem) {
|
|
5
|
+
var _a, _b, _c, _d;
|
|
6
|
+
let opacity = 1;
|
|
7
|
+
if (((_a = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _a === void 0 ? void 0 : _a.opacity) !== undefined && ((_b = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _b === void 0 ? void 0 : _b.opacity) >= 0 && ((_c = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _c === void 0 ? void 0 : _c.opacity) <= 1) {
|
|
8
|
+
opacity = (_d = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _d === void 0 ? void 0 : _d.opacity;
|
|
9
|
+
}
|
|
10
|
+
return opacity;
|
|
11
|
+
}
|
|
4
12
|
export function drawBox(ctx, viewElem, opts) {
|
|
5
13
|
const { pattern, renderContent, originElem, calcElemSize, viewScaleInfo, viewSizeInfo } = opts || {};
|
|
14
|
+
const { parentOpacity } = opts;
|
|
15
|
+
const opacity = getOpacity(originElem) * parentOpacity;
|
|
6
16
|
drawClipPath(ctx, viewElem, {
|
|
7
17
|
originElem,
|
|
8
18
|
calcElemSize,
|
|
9
19
|
viewScaleInfo,
|
|
10
20
|
viewSizeInfo,
|
|
11
21
|
renderContent: () => {
|
|
12
|
-
|
|
13
|
-
if (((_a = viewElem === null || viewElem === void 0 ? void 0 : viewElem.detail) === null || _a === void 0 ? void 0 : _a.opacity) !== undefined && ((_b = viewElem === null || viewElem === void 0 ? void 0 : viewElem.detail) === null || _b === void 0 ? void 0 : _b.opacity) >= 0) {
|
|
14
|
-
ctx.globalAlpha = viewElem.detail.opacity;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
ctx.globalAlpha = 1;
|
|
18
|
-
}
|
|
22
|
+
ctx.globalAlpha = opacity;
|
|
19
23
|
drawBoxBackground(ctx, viewElem, { pattern, viewScaleInfo, viewSizeInfo });
|
|
20
24
|
renderContent === null || renderContent === void 0 ? void 0 : renderContent();
|
|
21
25
|
drawBoxBorder(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
|
|
22
|
-
ctx.globalAlpha =
|
|
26
|
+
ctx.globalAlpha = parentOpacity;
|
|
23
27
|
}
|
|
24
28
|
});
|
|
25
29
|
}
|
|
@@ -57,11 +61,6 @@ function drawBoxBackground(ctx, viewElem, opts) {
|
|
|
57
61
|
var _a, _b;
|
|
58
62
|
const { pattern, viewScaleInfo, viewSizeInfo } = opts;
|
|
59
63
|
const transform = [];
|
|
60
|
-
let { borderRadius } = viewElem.detail;
|
|
61
|
-
const { borderWidth } = viewElem.detail;
|
|
62
|
-
if (typeof borderWidth !== 'number') {
|
|
63
|
-
borderRadius = 0;
|
|
64
|
-
}
|
|
65
64
|
if (viewElem.detail.background || pattern) {
|
|
66
65
|
const { x, y, w, h, radiusList } = calcViewBoxSize(viewElem, {
|
|
67
66
|
viewScaleInfo,
|
|
@@ -120,19 +119,12 @@ function drawBoxBackground(ctx, viewElem, opts) {
|
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
function drawBoxBorder(ctx, viewElem, opts) {
|
|
123
|
-
var _a, _b;
|
|
124
122
|
if (viewElem.detail.borderWidth === 0) {
|
|
125
123
|
return;
|
|
126
124
|
}
|
|
127
125
|
if (!isColorStr(viewElem.detail.borderColor)) {
|
|
128
126
|
return;
|
|
129
127
|
}
|
|
130
|
-
if (((_a = viewElem === null || viewElem === void 0 ? void 0 : viewElem.detail) === null || _a === void 0 ? void 0 : _a.opacity) !== undefined && ((_b = viewElem === null || viewElem === void 0 ? void 0 : viewElem.detail) === null || _b === void 0 ? void 0 : _b.opacity) >= 0) {
|
|
131
|
-
ctx.globalAlpha = viewElem.detail.opacity;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
ctx.globalAlpha = 1;
|
|
135
|
-
}
|
|
136
128
|
const { viewScaleInfo } = opts;
|
|
137
129
|
const { scale } = viewScaleInfo;
|
|
138
130
|
let borderColor = defaultElemConfig.borderColor;
|
|
@@ -263,7 +255,6 @@ function drawBoxBorder(ctx, viewElem, opts) {
|
|
|
263
255
|
ctx.arcTo(x, y, x + w, y, radiusList[0]);
|
|
264
256
|
ctx.closePath();
|
|
265
257
|
ctx.stroke();
|
|
266
|
-
ctx.globalAlpha = 1;
|
|
267
258
|
}
|
|
268
259
|
ctx.setLineDash([]);
|
|
269
260
|
}
|
package/dist/esm/draw/circle.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { rotateElement } from '@idraw/util';
|
|
2
2
|
import { createColorStyle } from './color';
|
|
3
|
-
import { drawBoxShadow } from './box';
|
|
3
|
+
import { drawBoxShadow, getOpacity } from './box';
|
|
4
4
|
export function drawCircle(ctx, elem, opts) {
|
|
5
5
|
const { detail, angle } = elem;
|
|
6
|
-
const { background = '#000000', borderColor = '#000000', borderWidth = 0 } = detail;
|
|
7
|
-
|
|
6
|
+
const { background = '#000000', borderColor = '#000000', boxSizing, borderWidth = 0 } = detail;
|
|
7
|
+
let bw = 0;
|
|
8
|
+
if (typeof borderWidth === 'number' && borderWidth > 0) {
|
|
9
|
+
bw = borderWidth;
|
|
10
|
+
}
|
|
11
|
+
else if (Array.isArray(borderWidth) && typeof borderWidth[0] === 'number' && borderWidth[0] > 0) {
|
|
12
|
+
bw = borderWidth[0];
|
|
13
|
+
}
|
|
14
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
8
15
|
const { x, y, w, h } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h }, viewScaleInfo, viewSizeInfo)) || elem;
|
|
9
16
|
const viewElem = Object.assign(Object.assign({}, elem), { x, y, w, h, angle });
|
|
10
17
|
rotateElement(ctx, { x, y, w, h, angle }, () => {
|
|
@@ -12,17 +19,26 @@ export function drawCircle(ctx, elem, opts) {
|
|
|
12
19
|
viewScaleInfo,
|
|
13
20
|
viewSizeInfo,
|
|
14
21
|
renderContent: () => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const b = h / 2;
|
|
22
|
+
let a = w / 2;
|
|
23
|
+
let b = h / 2;
|
|
18
24
|
const centerX = x + a;
|
|
19
25
|
const centerY = y + b;
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
if (bw > 0) {
|
|
27
|
+
if (boxSizing === 'border-box') {
|
|
28
|
+
a = a - bw;
|
|
29
|
+
b = b - bw;
|
|
30
|
+
}
|
|
31
|
+
else if (boxSizing === 'center-line') {
|
|
32
|
+
a = a - bw / 2;
|
|
33
|
+
b = b - bw / 2;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
a = a - bw;
|
|
37
|
+
b = b - bw;
|
|
38
|
+
}
|
|
25
39
|
}
|
|
40
|
+
const opacity = getOpacity(viewElem) * parentOpacity;
|
|
41
|
+
ctx.globalAlpha = opacity;
|
|
26
42
|
if (typeof borderWidth === 'number' && borderWidth > 0) {
|
|
27
43
|
const ba = borderWidth / 2 + a;
|
|
28
44
|
const bb = borderWidth / 2 + b;
|
|
@@ -43,7 +59,7 @@ export function drawCircle(ctx, elem, opts) {
|
|
|
43
59
|
ctx.circle(centerX, centerY, a, b, 0, 0, 2 * Math.PI);
|
|
44
60
|
ctx.closePath();
|
|
45
61
|
ctx.fill();
|
|
46
|
-
ctx.globalAlpha =
|
|
62
|
+
ctx.globalAlpha = parentOpacity;
|
|
47
63
|
}
|
|
48
64
|
});
|
|
49
65
|
});
|
|
@@ -4,6 +4,7 @@ const defaultDetail = getDefaultElementDetailConfig();
|
|
|
4
4
|
export function drawElementList(ctx, data, opts) {
|
|
5
5
|
var _a;
|
|
6
6
|
const { elements = [] } = data;
|
|
7
|
+
const { parentOpacity } = opts;
|
|
7
8
|
for (let i = 0; i < elements.length; i++) {
|
|
8
9
|
const element = elements[i];
|
|
9
10
|
const elem = Object.assign(Object.assign({}, element), {
|
|
@@ -15,7 +16,9 @@ export function drawElementList(ctx, data, opts) {
|
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
try {
|
|
18
|
-
drawElement(ctx, elem, opts)
|
|
19
|
+
drawElement(ctx, elem, Object.assign(Object.assign({}, opts), {
|
|
20
|
+
parentOpacity
|
|
21
|
+
}));
|
|
19
22
|
}
|
|
20
23
|
catch (err) {
|
|
21
24
|
console.error(err);
|
package/dist/esm/draw/group.js
CHANGED
|
@@ -5,7 +5,7 @@ import { drawImage } from './image';
|
|
|
5
5
|
import { drawText } from './text';
|
|
6
6
|
import { drawSVG } from './svg';
|
|
7
7
|
import { drawHTML } from './html';
|
|
8
|
-
import { drawBox, drawBoxShadow } from './box';
|
|
8
|
+
import { drawBox, drawBoxShadow, getOpacity } from './box';
|
|
9
9
|
import { drawPath } from './path';
|
|
10
10
|
export function drawElement(ctx, elem, opts) {
|
|
11
11
|
var _a;
|
|
@@ -57,10 +57,11 @@ export function drawElement(ctx, elem, opts) {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
export function drawGroup(ctx, elem, opts) {
|
|
60
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
60
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
61
61
|
const { x, y, w, h, angle } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h, angle: elem.angle }, viewScaleInfo, viewSizeInfo)) || elem;
|
|
62
62
|
const viewElem = Object.assign(Object.assign({}, elem), { x, y, w, h, angle });
|
|
63
63
|
rotateElement(ctx, { x, y, w, h, angle }, () => {
|
|
64
|
+
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
64
65
|
drawBoxShadow(ctx, viewElem, {
|
|
65
66
|
viewScaleInfo,
|
|
66
67
|
viewSizeInfo,
|
|
@@ -70,6 +71,7 @@ export function drawGroup(ctx, elem, opts) {
|
|
|
70
71
|
calcElemSize: { x, y, w, h, angle },
|
|
71
72
|
viewScaleInfo,
|
|
72
73
|
viewSizeInfo,
|
|
74
|
+
parentOpacity,
|
|
73
75
|
renderContent: () => {
|
|
74
76
|
const { x, y, w, h, radiusList } = calcViewBoxSize(viewElem, {
|
|
75
77
|
viewScaleInfo,
|
|
@@ -110,7 +112,7 @@ export function drawGroup(ctx, elem, opts) {
|
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
114
|
try {
|
|
113
|
-
drawElement(ctx, child, Object.assign({}, opts));
|
|
115
|
+
drawElement(ctx, child, Object.assign(Object.assign({}, opts), { parentOpacity: parentOpacity * getOpacity(elem) }));
|
|
114
116
|
}
|
|
115
117
|
catch (err) {
|
|
116
118
|
console.error(err);
|
|
@@ -118,12 +120,12 @@ export function drawGroup(ctx, elem, opts) {
|
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
122
|
if (elem.detail.overflow === 'hidden') {
|
|
121
|
-
ctx.globalAlpha = 1;
|
|
122
123
|
ctx.restore();
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
});
|
|
126
127
|
}
|
|
127
128
|
});
|
|
129
|
+
ctx.globalAlpha = parentOpacity;
|
|
128
130
|
});
|
|
129
131
|
}
|
package/dist/esm/draw/html.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { rotateElement } from '@idraw/util';
|
|
2
|
+
import { getOpacity } from './box';
|
|
2
3
|
export function drawHTML(ctx, elem, opts) {
|
|
3
4
|
const content = opts.loader.getContent(elem);
|
|
4
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
5
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
5
6
|
const { x, y, w, h, angle } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
6
7
|
rotateElement(ctx, { x, y, w, h, angle }, () => {
|
|
7
8
|
if (!content) {
|
|
8
9
|
opts.loader.load(elem, opts.elementAssets || {});
|
|
9
10
|
}
|
|
10
11
|
if (elem.type === 'html' && content) {
|
|
11
|
-
|
|
12
|
-
ctx.globalAlpha = opacity ? opacity : 1;
|
|
12
|
+
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
13
13
|
ctx.drawImage(content, x, y, w, h);
|
|
14
|
-
ctx.globalAlpha =
|
|
14
|
+
ctx.globalAlpha = parentOpacity;
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
}
|
package/dist/esm/draw/image.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { rotateElement, calcViewBoxSize } from '@idraw/util';
|
|
2
|
-
import { drawBox, drawBoxShadow } from './box';
|
|
2
|
+
import { drawBox, drawBoxShadow, getOpacity } from './box';
|
|
3
3
|
export function drawImage(ctx, elem, opts) {
|
|
4
4
|
const content = opts.loader.getContent(elem);
|
|
5
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
5
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
6
6
|
const { x, y, w, h, angle } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
7
7
|
const viewElem = Object.assign(Object.assign({}, elem), { x, y, w, h, angle });
|
|
8
8
|
rotateElement(ctx, { x, y, w, h, angle }, () => {
|
|
@@ -15,13 +15,13 @@ export function drawImage(ctx, elem, opts) {
|
|
|
15
15
|
calcElemSize: { x, y, w, h, angle },
|
|
16
16
|
viewScaleInfo,
|
|
17
17
|
viewSizeInfo,
|
|
18
|
+
parentOpacity,
|
|
18
19
|
renderContent: () => {
|
|
19
20
|
if (!content) {
|
|
20
21
|
opts.loader.load(elem, opts.elementAssets || {});
|
|
21
22
|
}
|
|
22
23
|
if (elem.type === 'image' && content) {
|
|
23
|
-
|
|
24
|
-
ctx.globalAlpha = opacity ? opacity : 1;
|
|
24
|
+
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
25
25
|
const { x, y, w, h, radiusList } = calcViewBoxSize(viewElem, {
|
|
26
26
|
viewScaleInfo,
|
|
27
27
|
viewSizeInfo
|
|
@@ -38,7 +38,7 @@ export function drawImage(ctx, elem, opts) {
|
|
|
38
38
|
ctx.fill();
|
|
39
39
|
ctx.clip();
|
|
40
40
|
ctx.drawImage(content, x, y, w, h);
|
|
41
|
-
ctx.globalAlpha =
|
|
41
|
+
ctx.globalAlpha = parentOpacity;
|
|
42
42
|
ctx.restore();
|
|
43
43
|
}
|
|
44
44
|
}
|
package/dist/esm/draw/path.js
CHANGED
|
@@ -3,7 +3,7 @@ import { drawBox, drawBoxShadow } from './box';
|
|
|
3
3
|
export function drawPath(ctx, elem, opts) {
|
|
4
4
|
const { detail } = elem;
|
|
5
5
|
const { originX, originY, originW, originH } = detail;
|
|
6
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
6
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
7
7
|
const { x, y, w, h, angle } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
8
8
|
const scaleW = w / originW;
|
|
9
9
|
const scaleH = h / originH;
|
|
@@ -19,6 +19,7 @@ export function drawPath(ctx, elem, opts) {
|
|
|
19
19
|
calcElemSize: { x, y, w, h, angle },
|
|
20
20
|
viewScaleInfo,
|
|
21
21
|
viewSizeInfo,
|
|
22
|
+
parentOpacity,
|
|
22
23
|
renderContent: () => {
|
|
23
24
|
drawBoxShadow(ctx, viewElem, {
|
|
24
25
|
viewScaleInfo,
|
package/dist/esm/draw/rect.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { rotateElement } from '@idraw/util';
|
|
2
2
|
import { drawBox, drawBoxShadow } from './box';
|
|
3
3
|
export function drawRect(ctx, elem, opts) {
|
|
4
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
4
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
5
5
|
const { x, y, w, h, angle } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
6
6
|
const viewElem = Object.assign(Object.assign({}, elem), { x, y, w, h, angle });
|
|
7
7
|
rotateElement(ctx, { x, y, w, h, angle }, () => {
|
|
@@ -14,6 +14,7 @@ export function drawRect(ctx, elem, opts) {
|
|
|
14
14
|
calcElemSize: { x, y, w, h, angle },
|
|
15
15
|
viewScaleInfo,
|
|
16
16
|
viewSizeInfo,
|
|
17
|
+
parentOpacity,
|
|
17
18
|
renderContent: () => {
|
|
18
19
|
}
|
|
19
20
|
});
|
package/dist/esm/draw/svg.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { rotateElement } from '@idraw/util';
|
|
2
|
+
import { getOpacity } from './box';
|
|
2
3
|
export function drawSVG(ctx, elem, opts) {
|
|
3
4
|
const content = opts.loader.getContent(elem);
|
|
4
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
5
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
5
6
|
const { x, y, w, h, angle } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
6
7
|
rotateElement(ctx, { x, y, w, h, angle }, () => {
|
|
7
8
|
if (!content) {
|
|
8
9
|
opts.loader.load(elem, opts.elementAssets || {});
|
|
9
10
|
}
|
|
10
11
|
if (elem.type === 'svg' && content) {
|
|
11
|
-
|
|
12
|
-
ctx.globalAlpha = opacity ? opacity : 1;
|
|
12
|
+
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
13
13
|
ctx.drawImage(content, x, y, w, h);
|
|
14
|
-
ctx.globalAlpha =
|
|
14
|
+
ctx.globalAlpha = parentOpacity;
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
}
|
package/dist/esm/draw/text.js
CHANGED
|
@@ -3,7 +3,7 @@ import { is, isColorStr, getDefaultElementDetailConfig } from '@idraw/util';
|
|
|
3
3
|
import { drawBox } from './box';
|
|
4
4
|
const detailConfig = getDefaultElementDetailConfig();
|
|
5
5
|
export function drawText(ctx, elem, opts) {
|
|
6
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
6
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
7
7
|
const { x, y, w, h, angle } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
8
8
|
const viewElem = Object.assign(Object.assign({}, elem), { x, y, w, h, angle });
|
|
9
9
|
rotateElement(ctx, { x, y, w, h, angle }, () => {
|
|
@@ -12,6 +12,7 @@ export function drawText(ctx, elem, opts) {
|
|
|
12
12
|
calcElemSize: { x, y, w, h, angle },
|
|
13
13
|
viewScaleInfo,
|
|
14
14
|
viewSizeInfo,
|
|
15
|
+
parentOpacity,
|
|
15
16
|
renderContent: () => {
|
|
16
17
|
const detail = Object.assign(Object.assign({}, detailConfig), elem.detail);
|
|
17
18
|
const fontSize = (detail.fontSize || detailConfig.fontSize) * viewScaleInfo.scale;
|
package/dist/esm/index.js
CHANGED
|
@@ -38,7 +38,7 @@ export class Renderer extends EventEmitter {
|
|
|
38
38
|
};
|
|
39
39
|
drawElementList(viewContext, data, Object.assign({ loader,
|
|
40
40
|
calculator,
|
|
41
|
-
parentElementSize, elementAssets: data.assets }, opts));
|
|
41
|
+
parentElementSize, elementAssets: data.assets, parentOpacity: 1 }, opts));
|
|
42
42
|
}
|
|
43
43
|
scale(num) {
|
|
44
44
|
const { sharer } = __classPrivateFieldGet(this, _Renderer_opts, "f");
|
package/dist/esm/loader.js
CHANGED
|
@@ -62,8 +62,8 @@ export class Loader extends EventEmitter {
|
|
|
62
62
|
var _b;
|
|
63
63
|
const html = ((_b = assets[elem.detail.html]) === null || _b === void 0 ? void 0 : _b.value) || elem.detail.html;
|
|
64
64
|
const content = yield loadHTML(html, {
|
|
65
|
-
width: elem.detail.
|
|
66
|
-
height: elem.detail.
|
|
65
|
+
width: elem.detail.originW || elem.w,
|
|
66
|
+
height: elem.detail.originH || elem.h
|
|
67
67
|
});
|
|
68
68
|
return {
|
|
69
69
|
uuid: elem.uuid,
|
package/dist/index.global.js
CHANGED
|
@@ -447,7 +447,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
447
447
|
const { scale } = viewScaleInfo;
|
|
448
448
|
let { borderRadius: borderRadius2 } = viewElem.detail;
|
|
449
449
|
const { boxSizing = defaultElemConfig$1.boxSizing, borderWidth: borderWidth2 } = viewElem.detail;
|
|
450
|
-
if (
|
|
450
|
+
if (Array.isArray(borderWidth2)) {
|
|
451
451
|
borderRadius2 = 0;
|
|
452
452
|
}
|
|
453
453
|
let { x: x2, y: y2, w: w2, h: h2 } = viewElem;
|
|
@@ -535,24 +535,29 @@ var __privateMethod = (obj, member, method) => {
|
|
|
535
535
|
return "#000000";
|
|
536
536
|
}
|
|
537
537
|
const defaultElemConfig = getDefaultElementDetailConfig();
|
|
538
|
+
function getOpacity(elem) {
|
|
539
|
+
var _a, _b, _c, _d;
|
|
540
|
+
let opacity = 1;
|
|
541
|
+
if (((_a = elem == null ? void 0 : elem.detail) == null ? void 0 : _a.opacity) !== void 0 && ((_b = elem == null ? void 0 : elem.detail) == null ? void 0 : _b.opacity) >= 0 && ((_c = elem == null ? void 0 : elem.detail) == null ? void 0 : _c.opacity) <= 1) {
|
|
542
|
+
opacity = (_d = elem == null ? void 0 : elem.detail) == null ? void 0 : _d.opacity;
|
|
543
|
+
}
|
|
544
|
+
return opacity;
|
|
545
|
+
}
|
|
538
546
|
function drawBox(ctx, viewElem, opts) {
|
|
539
547
|
const { pattern, renderContent, originElem, calcElemSize, viewScaleInfo, viewSizeInfo } = opts || {};
|
|
548
|
+
const { parentOpacity } = opts;
|
|
549
|
+
const opacity = getOpacity(originElem) * parentOpacity;
|
|
540
550
|
drawClipPath(ctx, viewElem, {
|
|
541
551
|
originElem,
|
|
542
552
|
calcElemSize,
|
|
543
553
|
viewScaleInfo,
|
|
544
554
|
viewSizeInfo,
|
|
545
555
|
renderContent: () => {
|
|
546
|
-
|
|
547
|
-
if (((_a = viewElem == null ? void 0 : viewElem.detail) == null ? void 0 : _a.opacity) !== void 0 && ((_b = viewElem == null ? void 0 : viewElem.detail) == null ? void 0 : _b.opacity) >= 0) {
|
|
548
|
-
ctx.globalAlpha = viewElem.detail.opacity;
|
|
549
|
-
} else {
|
|
550
|
-
ctx.globalAlpha = 1;
|
|
551
|
-
}
|
|
556
|
+
ctx.globalAlpha = opacity;
|
|
552
557
|
drawBoxBackground(ctx, viewElem, { pattern, viewScaleInfo, viewSizeInfo });
|
|
553
558
|
renderContent == null ? void 0 : renderContent();
|
|
554
559
|
drawBoxBorder(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
|
|
555
|
-
ctx.globalAlpha =
|
|
560
|
+
ctx.globalAlpha = parentOpacity;
|
|
556
561
|
}
|
|
557
562
|
});
|
|
558
563
|
}
|
|
@@ -589,8 +594,6 @@ var __privateMethod = (obj, member, method) => {
|
|
|
589
594
|
var _a, _b;
|
|
590
595
|
const { pattern, viewScaleInfo, viewSizeInfo } = opts;
|
|
591
596
|
const transform = [];
|
|
592
|
-
viewElem.detail;
|
|
593
|
-
viewElem.detail;
|
|
594
597
|
if (viewElem.detail.background || pattern) {
|
|
595
598
|
const { x: x2, y: y2, w: w2, h: h2, radiusList } = calcViewBoxSize(viewElem, {
|
|
596
599
|
viewScaleInfo,
|
|
@@ -643,18 +646,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
643
646
|
}
|
|
644
647
|
}
|
|
645
648
|
function drawBoxBorder(ctx, viewElem, opts) {
|
|
646
|
-
var _a, _b;
|
|
647
649
|
if (viewElem.detail.borderWidth === 0) {
|
|
648
650
|
return;
|
|
649
651
|
}
|
|
650
652
|
if (!isColorStr(viewElem.detail.borderColor)) {
|
|
651
653
|
return;
|
|
652
654
|
}
|
|
653
|
-
if (((_a = viewElem == null ? void 0 : viewElem.detail) == null ? void 0 : _a.opacity) !== void 0 && ((_b = viewElem == null ? void 0 : viewElem.detail) == null ? void 0 : _b.opacity) >= 0) {
|
|
654
|
-
ctx.globalAlpha = viewElem.detail.opacity;
|
|
655
|
-
} else {
|
|
656
|
-
ctx.globalAlpha = 1;
|
|
657
|
-
}
|
|
658
655
|
const { viewScaleInfo } = opts;
|
|
659
656
|
const { scale } = viewScaleInfo;
|
|
660
657
|
let borderColor = defaultElemConfig.borderColor;
|
|
@@ -778,7 +775,6 @@ var __privateMethod = (obj, member, method) => {
|
|
|
778
775
|
ctx.arcTo(x2, y2, x2 + w2, y2, radiusList[0]);
|
|
779
776
|
ctx.closePath();
|
|
780
777
|
ctx.stroke();
|
|
781
|
-
ctx.globalAlpha = 1;
|
|
782
778
|
}
|
|
783
779
|
ctx.setLineDash([]);
|
|
784
780
|
}
|
|
@@ -800,8 +796,14 @@ var __privateMethod = (obj, member, method) => {
|
|
|
800
796
|
}
|
|
801
797
|
function drawCircle(ctx, elem, opts) {
|
|
802
798
|
const { detail, angle: angle2 } = elem;
|
|
803
|
-
const { background = "#000000", borderColor = "#000000", borderWidth: borderWidth2 = 0 } = detail;
|
|
804
|
-
|
|
799
|
+
const { background = "#000000", borderColor = "#000000", boxSizing, borderWidth: borderWidth2 = 0 } = detail;
|
|
800
|
+
let bw = 0;
|
|
801
|
+
if (typeof borderWidth2 === "number" && borderWidth2 > 0) {
|
|
802
|
+
bw = borderWidth2;
|
|
803
|
+
} else if (Array.isArray(borderWidth2) && typeof borderWidth2[0] === "number" && borderWidth2[0] > 0) {
|
|
804
|
+
bw = borderWidth2[0];
|
|
805
|
+
}
|
|
806
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
805
807
|
const { x: x2, y: y2, w: w2, h: h2 } = (calculator == null ? void 0 : calculator.elementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h }, viewScaleInfo, viewSizeInfo)) || elem;
|
|
806
808
|
const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
|
|
807
809
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
@@ -809,16 +811,24 @@ var __privateMethod = (obj, member, method) => {
|
|
|
809
811
|
viewScaleInfo,
|
|
810
812
|
viewSizeInfo,
|
|
811
813
|
renderContent: () => {
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
const b = h2 / 2;
|
|
814
|
+
let a = w2 / 2;
|
|
815
|
+
let b = h2 / 2;
|
|
815
816
|
const centerX = x2 + a;
|
|
816
817
|
const centerY = y2 + b;
|
|
817
|
-
if (
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
818
|
+
if (bw > 0) {
|
|
819
|
+
if (boxSizing === "border-box") {
|
|
820
|
+
a = a - bw;
|
|
821
|
+
b = b - bw;
|
|
822
|
+
} else if (boxSizing === "center-line") {
|
|
823
|
+
a = a - bw / 2;
|
|
824
|
+
b = b - bw / 2;
|
|
825
|
+
} else {
|
|
826
|
+
a = a - bw;
|
|
827
|
+
b = b - bw;
|
|
828
|
+
}
|
|
821
829
|
}
|
|
830
|
+
const opacity = getOpacity(viewElem) * parentOpacity;
|
|
831
|
+
ctx.globalAlpha = opacity;
|
|
822
832
|
if (typeof borderWidth2 === "number" && borderWidth2 > 0) {
|
|
823
833
|
const ba = borderWidth2 / 2 + a;
|
|
824
834
|
const bb = borderWidth2 / 2 + b;
|
|
@@ -839,13 +849,13 @@ var __privateMethod = (obj, member, method) => {
|
|
|
839
849
|
ctx.circle(centerX, centerY, a, b, 0, 0, 2 * Math.PI);
|
|
840
850
|
ctx.closePath();
|
|
841
851
|
ctx.fill();
|
|
842
|
-
ctx.globalAlpha =
|
|
852
|
+
ctx.globalAlpha = parentOpacity;
|
|
843
853
|
}
|
|
844
854
|
});
|
|
845
855
|
});
|
|
846
856
|
}
|
|
847
857
|
function drawRect(ctx, elem, opts) {
|
|
848
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
858
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
849
859
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
850
860
|
const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
|
|
851
861
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
@@ -858,6 +868,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
858
868
|
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
859
869
|
viewScaleInfo,
|
|
860
870
|
viewSizeInfo,
|
|
871
|
+
parentOpacity,
|
|
861
872
|
renderContent: () => {
|
|
862
873
|
}
|
|
863
874
|
});
|
|
@@ -867,7 +878,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
867
878
|
}
|
|
868
879
|
function drawImage(ctx, elem, opts) {
|
|
869
880
|
const content = opts.loader.getContent(elem);
|
|
870
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
881
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
871
882
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
872
883
|
const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
|
|
873
884
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
@@ -880,13 +891,13 @@ var __privateMethod = (obj, member, method) => {
|
|
|
880
891
|
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
881
892
|
viewScaleInfo,
|
|
882
893
|
viewSizeInfo,
|
|
894
|
+
parentOpacity,
|
|
883
895
|
renderContent: () => {
|
|
884
896
|
if (!content) {
|
|
885
897
|
opts.loader.load(elem, opts.elementAssets || {});
|
|
886
898
|
}
|
|
887
899
|
if (elem.type === "image" && content) {
|
|
888
|
-
|
|
889
|
-
ctx.globalAlpha = opacity ? opacity : 1;
|
|
900
|
+
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
890
901
|
const { x: x22, y: y22, w: w22, h: h22, radiusList } = calcViewBoxSize(viewElem, {
|
|
891
902
|
viewScaleInfo,
|
|
892
903
|
viewSizeInfo
|
|
@@ -903,7 +914,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
903
914
|
ctx.fill();
|
|
904
915
|
ctx.clip();
|
|
905
916
|
ctx.drawImage(content, x22, y22, w22, h22);
|
|
906
|
-
ctx.globalAlpha =
|
|
917
|
+
ctx.globalAlpha = parentOpacity;
|
|
907
918
|
ctx.restore();
|
|
908
919
|
}
|
|
909
920
|
}
|
|
@@ -914,39 +925,37 @@ var __privateMethod = (obj, member, method) => {
|
|
|
914
925
|
}
|
|
915
926
|
function drawSVG(ctx, elem, opts) {
|
|
916
927
|
const content = opts.loader.getContent(elem);
|
|
917
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
928
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
918
929
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
919
930
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
920
931
|
if (!content) {
|
|
921
932
|
opts.loader.load(elem, opts.elementAssets || {});
|
|
922
933
|
}
|
|
923
934
|
if (elem.type === "svg" && content) {
|
|
924
|
-
|
|
925
|
-
ctx.globalAlpha = opacity ? opacity : 1;
|
|
935
|
+
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
926
936
|
ctx.drawImage(content, x2, y2, w2, h2);
|
|
927
|
-
ctx.globalAlpha =
|
|
937
|
+
ctx.globalAlpha = parentOpacity;
|
|
928
938
|
}
|
|
929
939
|
});
|
|
930
940
|
}
|
|
931
941
|
function drawHTML(ctx, elem, opts) {
|
|
932
942
|
const content = opts.loader.getContent(elem);
|
|
933
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
943
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
934
944
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
935
945
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
936
946
|
if (!content) {
|
|
937
947
|
opts.loader.load(elem, opts.elementAssets || {});
|
|
938
948
|
}
|
|
939
949
|
if (elem.type === "html" && content) {
|
|
940
|
-
|
|
941
|
-
ctx.globalAlpha = opacity ? opacity : 1;
|
|
950
|
+
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
942
951
|
ctx.drawImage(content, x2, y2, w2, h2);
|
|
943
|
-
ctx.globalAlpha =
|
|
952
|
+
ctx.globalAlpha = parentOpacity;
|
|
944
953
|
}
|
|
945
954
|
});
|
|
946
955
|
}
|
|
947
956
|
const detailConfig = getDefaultElementDetailConfig();
|
|
948
957
|
function drawText(ctx, elem, opts) {
|
|
949
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
958
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
950
959
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
951
960
|
const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
|
|
952
961
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
@@ -955,6 +964,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
955
964
|
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
956
965
|
viewScaleInfo,
|
|
957
966
|
viewSizeInfo,
|
|
967
|
+
parentOpacity,
|
|
958
968
|
renderContent: () => {
|
|
959
969
|
const detail = {
|
|
960
970
|
...detailConfig,
|
|
@@ -1052,7 +1062,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1052
1062
|
function drawPath(ctx, elem, opts) {
|
|
1053
1063
|
const { detail } = elem;
|
|
1054
1064
|
const { originX, originY, originW, originH } = detail;
|
|
1055
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
1065
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
1056
1066
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
1057
1067
|
const scaleW = w2 / originW;
|
|
1058
1068
|
const scaleH = h2 / originH;
|
|
@@ -1068,6 +1078,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1068
1078
|
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
1069
1079
|
viewScaleInfo,
|
|
1070
1080
|
viewSizeInfo,
|
|
1081
|
+
parentOpacity,
|
|
1071
1082
|
renderContent: () => {
|
|
1072
1083
|
drawBoxShadow(ctx, viewElem, {
|
|
1073
1084
|
viewScaleInfo,
|
|
@@ -1151,10 +1162,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1151
1162
|
}
|
|
1152
1163
|
}
|
|
1153
1164
|
function drawGroup(ctx, elem, opts) {
|
|
1154
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
1165
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
1155
1166
|
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator == null ? void 0 : calculator.elementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h, angle: elem.angle }, viewScaleInfo, viewSizeInfo)) || elem;
|
|
1156
1167
|
const viewElem = { ...elem, ...{ x: x2, y: y2, w: w2, h: h2, angle: angle2 } };
|
|
1157
1168
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
1169
|
+
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
1158
1170
|
drawBoxShadow(ctx, viewElem, {
|
|
1159
1171
|
viewScaleInfo,
|
|
1160
1172
|
viewSizeInfo,
|
|
@@ -1164,6 +1176,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1164
1176
|
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
1165
1177
|
viewScaleInfo,
|
|
1166
1178
|
viewSizeInfo,
|
|
1179
|
+
parentOpacity,
|
|
1167
1180
|
renderContent: () => {
|
|
1168
1181
|
const { x: x22, y: y22, w: w22, h: h22, radiusList } = calcViewBoxSize(viewElem, {
|
|
1169
1182
|
viewScaleInfo,
|
|
@@ -1207,26 +1220,27 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1207
1220
|
}
|
|
1208
1221
|
}
|
|
1209
1222
|
try {
|
|
1210
|
-
drawElement(ctx, child, { ...opts });
|
|
1223
|
+
drawElement(ctx, child, { ...opts, ...{ parentOpacity: parentOpacity * getOpacity(elem) } });
|
|
1211
1224
|
} catch (err) {
|
|
1212
1225
|
console.error(err);
|
|
1213
1226
|
}
|
|
1214
1227
|
}
|
|
1215
1228
|
}
|
|
1216
1229
|
if (elem.detail.overflow === "hidden") {
|
|
1217
|
-
ctx.globalAlpha = 1;
|
|
1218
1230
|
ctx.restore();
|
|
1219
1231
|
}
|
|
1220
1232
|
}
|
|
1221
1233
|
});
|
|
1222
1234
|
}
|
|
1223
1235
|
});
|
|
1236
|
+
ctx.globalAlpha = parentOpacity;
|
|
1224
1237
|
});
|
|
1225
1238
|
}
|
|
1226
1239
|
const defaultDetail = getDefaultElementDetailConfig();
|
|
1227
1240
|
function drawElementList(ctx, data, opts) {
|
|
1228
1241
|
var _a;
|
|
1229
1242
|
const { elements = [] } = data;
|
|
1243
|
+
const { parentOpacity } = opts;
|
|
1230
1244
|
for (let i = 0; i < elements.length; i++) {
|
|
1231
1245
|
const element = elements[i];
|
|
1232
1246
|
const elem = {
|
|
@@ -1244,7 +1258,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1244
1258
|
}
|
|
1245
1259
|
}
|
|
1246
1260
|
try {
|
|
1247
|
-
drawElement(ctx, elem,
|
|
1261
|
+
drawElement(ctx, elem, {
|
|
1262
|
+
...opts,
|
|
1263
|
+
...{
|
|
1264
|
+
parentOpacity
|
|
1265
|
+
}
|
|
1266
|
+
});
|
|
1248
1267
|
} catch (err) {
|
|
1249
1268
|
console.error(err);
|
|
1250
1269
|
}
|
|
@@ -1296,8 +1315,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1296
1315
|
var _a;
|
|
1297
1316
|
const html2 = ((_a = assets[elem.detail.html]) == null ? void 0 : _a.value) || elem.detail.html;
|
|
1298
1317
|
const content = await loadHTML(html2, {
|
|
1299
|
-
width: elem.detail.
|
|
1300
|
-
height: elem.detail.
|
|
1318
|
+
width: elem.detail.originW || elem.w,
|
|
1319
|
+
height: elem.detail.originH || elem.h
|
|
1301
1320
|
});
|
|
1302
1321
|
return {
|
|
1303
1322
|
uuid: elem.uuid,
|
|
@@ -1459,6 +1478,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1459
1478
|
calculator,
|
|
1460
1479
|
parentElementSize,
|
|
1461
1480
|
elementAssets: data.assets,
|
|
1481
|
+
parentOpacity: 1,
|
|
1462
1482
|
...opts
|
|
1463
1483
|
});
|
|
1464
1484
|
}
|
package/dist/index.global.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var iDrawRenderer=function(e){"use strict";var t,n,i,o,l,a,r,s,c,d,h,f,u,g,w,v,y,m,p,S,x,b=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},I=(e,t,n)=>(b(e,t,"read from private field"),n?n.call(e):t.get(e)),z=(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)=>(b(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),T=(e,t,n)=>(b(e,t,"access private method"),n);function C(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 k(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function W(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/${W(t.toString(16).padEnd(4,i))}${W(e.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${W(e.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${W(e.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${W(e.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${W(e.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${W(e.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${W(o.padEnd(4,i).padEnd(4,o))}`}function P(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const M={type(e,t){const n=P(e);return!0===t?n.toLocaleLowerCase():n},array:e=>"Array"===P(e),json:e=>"Object"===P(e),function:e=>"Function"===P(e),asyncFunction:e=>"AsyncFunction"===P(e),string:e=>"String"===P(e),number:e=>"Number"===P(e),undefined:e=>"Undefined"===P(e),null:e=>"Null"===P(e),promise:e=>"Promise"===P(e)};var O=function(e,t,n,i){return new(n||(n=Promise))((function(o,l){function a(e){try{s(i.next(e))}catch(e){l(e)}}function r(e){try{s(i.throw(e))}catch(e){l(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(a,r)}s((i=i.apply(e,t||[])).next())}))};const{Image:R}=window;function L(e){return new Promise(((t,n)=>{const i=new R;i.crossOrigin="anonymous",i.onload=function(){t(i)},i.onabort=n,i.onerror=n,i.src=e}))}function D(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 L(t)}))}function B(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 l=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"}),a=new FileReader;a.readAsDataURL(l),a.onload=function(e){var n;const i=null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result;t(i)},a.onerror=function(e){o(e)}}))}(e,t);return yield L(n)}))}function F(e){return"number"==typeof e&&(e>0||e<=0)}function H(e){return"number"==typeof e&&e>=0}function X(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function Y(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const _={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 C(e)},imageSrc:function(e){return Y(e)||X(e)},imageURL:X,imageBase64:Y,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}};class j{constructor(){this._listeners=new Map}on(e,t){if(this._listeners.has(e)){const n=this._listeners.get(e)||[];null==n||n.push(t),this._listeners.set(e,n)}else this._listeners.set(e,[t])}off(e,t){if(this._listeners.has(e)){const n=this._listeners.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}this._listeners.set(e,n||[])}}trigger(e,t){const n=this._listeners.get(e);return!!Array.isArray(n)&&(n.forEach((e=>{e(t)})),!0)}has(e){if(this._listeners.has(e)){const t=this._listeners.get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}}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 q(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 G(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}const N={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function V(e,t){const{viewScaleInfo:n}=t,{scale:i}=n;let{borderRadius:o}=e.detail;const{boxSizing:l=N.boxSizing,borderWidth:a}=e.detail;"number"!=typeof a&&(o=0);let{x:r,y:s,w:c,h:d}=e,h=[0,0,0,0];if("number"==typeof o){const e=o*i;h=[e,e,e,e]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(h=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let f=0;return"number"==typeof a&&(f=(a||0)*i),"border-box"===l?(r=e.x+f/2,s=e.y+f/2,c=e.w-f,d=e.h-f):"content-box"===l?(r=e.x-f/2,s=e.y-f/2,c=e.w+f,d=e.h+f):(r=e.x,s=e.y,c=e.w,d=e.h),c=Math.max(c,1),d=Math.max(d,1),h=h.map((e=>Math.min(e,c/2,d/2))),{x:r,y:s,w:c,h:d,radiusList:h}}function J(e,t,n){if("string"==typeof t)return t;const{viewElementSize:i,viewScaleInfo:o,opacity:l=1}=n,{x:a,y:r}=i,{scale:s}=o;if("linear-gradient"===(null==t?void 0:t.type)){const{start:n,end:i,stops:o}=t,c={x:a+n.x*s,y:r+n.y*s},d={x:a+i.x*s,y:r+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,l))})),h}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:n,outer:i,stops:o}=t,c={x:a+n.x*s,y:r+n.y*s,radius:n.radius*s},d={x:a+i.x*s,y:r+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,l))})),h}return"#000000"}const K={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function Q(e,t,n){const{pattern:i,renderContent:o,originElem:l,calcElemSize:a,viewScaleInfo:r,viewSizeInfo:s}=n||{};!function(e,t,n){const{renderContent:i,originElem:o,calcElemSize:l,viewScaleInfo:a,viewSizeInfo:r}=n,s=a.scale*r.devicePixelRatio,{clipPath:c}=(null==o?void 0:o.detail)||{};if(c&&l&&c.commands){const{x:n,y:o,w:a,h:r}=l,{originW:d,originH:h,originX:f,originY:u}=c,g=a/d,w=r/h,v=n-f*g,y=o-u*w;e.save(),e.translate(v,y),e.scale(s*g,s*w);const m=G(c.commands||[]),p=new Path2D(m);e.clip(p),e.translate(0-v,0-y),e.setTransform(1,0,0,1,0,0),q(e,{...t},(()=>{null==i||i()})),e.restore()}else null==i||i()}(e,t,{originElem:l,calcElemSize:a,viewScaleInfo:r,viewSizeInfo:s,renderContent:()=>{var n,l;void 0!==(null==(n=null==t?void 0:t.detail)?void 0:n.opacity)&&(null==(l=null==t?void 0:t.detail)?void 0:l.opacity)>=0?e.globalAlpha=t.detail.opacity:e.globalAlpha=1,function(e,t,n){var i,o;const{pattern:l,viewScaleInfo:a,viewSizeInfo:r}=n,s=[];if(t.detail,t.detail,t.detail.background||l){const{x:n,y:c,w:d,h:h,radiusList:f}=V(t,{viewScaleInfo:a,viewSizeInfo:r});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 l)e.fillStyle=l;else if(["CanvasPattern"].includes(M.type(l)))e.fillStyle=l;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=J(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:a,opacity:e.globalAlpha});e.fillStyle=i}else if("radial-gradient"===(null==(o=t.detail.background)?void 0:o.type)){const i=J(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:a,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)}}(e,t,{pattern:i,viewScaleInfo:r,viewSizeInfo:s}),null==o||o(),function(e,t,n){var i,o;if(0===t.detail.borderWidth)return;if(!C(t.detail.borderColor))return;void 0!==(null==(i=null==t?void 0:t.detail)?void 0:i.opacity)&&(null==(o=null==t?void 0:t.detail)?void 0:o.opacity)>=0?e.globalAlpha=t.detail.opacity:e.globalAlpha=1;const{viewScaleInfo:l}=n,{scale:a}=l;let r=K.borderColor;!0===C(t.detail.borderColor)&&(r=t.detail.borderColor);const{borderWidth:s,borderRadius:c,borderDash:d,boxSizing:h=K.boxSizing}=t.detail;let f=0;"number"==typeof s&&(f=s||1);f*=a;let u=[0,0,0,0];if("number"==typeof c){const e=c*a;u=[e,e,e,e]}else Array.isArray(c)&&4===(null==c?void 0:c.length)&&(u=[c[0]*a,c[1]*a,c[2]*a,c[3]*a]);e.strokeStyle=r;let g=[];Array.isArray(d)&&d.length>0&&(g=d.map((e=>Math.ceil(e*a))));let w=0,v=0,y=0,m=0;Array.isArray(s)&&(w=(s[0]||0)*a,v=(s[1]||0)*a,y=(s[2]||0)*a,m=(s[3]||0)*a);if(m||v||w||y){e.lineCap="butt";let{x:n,y:i,w:o,h:l}=t;"border-box"===h?(n+=m/2,i+=w/2,o=o-m/2-v/2,l=l-w/2-y/2):"content-box"===h?(n-=m/2,i-=w/2,o=o+m/2+v/2,l=l+w/2+y/2):(n=t.x,i=t.y,o=t.w,l=t.h),w&&(e.beginPath(),e.lineWidth=w,e.moveTo(n-m/2,i),e.lineTo(n+o+v/2,i),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(n+o,i-w/2),e.lineTo(n+o,i+l+y/2),e.closePath(),e.stroke()),y&&(e.beginPath(),e.lineWidth=y,e.moveTo(n-m/2,i+l),e.lineTo(n+o+v/2,i+l),e.closePath(),e.stroke()),m&&(e.beginPath(),e.lineWidth=m,e.moveTo(n,i-w/2),e.lineTo(n,i+l+y/2),e.closePath(),e.stroke())}else{let{x:n,y:i,w:o,h:l}=t;"border-box"===h?(n=t.x+f/2,i=t.y+f/2,o=t.w-f,l=t.h-f):"content-box"===h?(n=t.x-f/2,i=t.y-f/2,o=t.w+f,l=t.h+f):(n=t.x,i=t.y,o=t.w,l=t.h),g.length>0?e.lineCap="butt":e.lineCap="square",o=Math.max(o,1),l=Math.max(l,1),u=u.map((e=>Math.min(e,o/2,l/2))),e.setLineDash(g),e.lineWidth=f,e.beginPath(),e.moveTo(n+u[0],i),e.arcTo(n+o,i,n+o,i+l,u[1]),e.arcTo(n+o,i+l,n,i+l,u[2]),e.arcTo(n,i+l,n,i,u[3]),e.arcTo(n,i,n+o,i,u[0]),e.closePath(),e.stroke(),e.globalAlpha=1}e.setLineDash([])}(e,t,{viewScaleInfo:r,viewSizeInfo:s}),e.globalAlpha=1}})}function Z(e,t,n){const{detail:i}=t,{viewScaleInfo:o,renderContent:l}=n,{shadowColor:a,shadowOffsetX:r,shadowOffsetY:s,shadowBlur:c}=i;_.number(c)?(e.save(),e.shadowColor=a||K.shadowColor,e.shadowOffsetX=(r||0)*o.scale,e.shadowOffsetY=(s||0)*o.scale,e.shadowBlur=(c||0)*o.scale,l(),e.restore()):l()}const ee={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function te(e,t,n){var i;if(!0!==(null==(i=null==t?void 0:t.operations)?void 0:i.invisible))try{switch(t.type){case"rect":!function(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:l}=n,{x:a,y:r,w:s,h:c,angle:d}=(null==i?void 0:i.elementSize(t,o,l))||t,h={...t,x:a,y:r,w:s,h:c,angle:d};q(e,{x:a,y:r,w:s,h:c,angle:d},(()=>{Z(e,h,{viewScaleInfo:o,viewSizeInfo:l,renderContent:()=>{Q(e,h,{originElem:t,calcElemSize:{x:a,y:r,w:s,h:c,angle:d},viewScaleInfo:o,viewSizeInfo:l,renderContent:()=>{}})}})}))}(e,t,n);break;case"circle":!function(e,t,n){const{detail:i,angle:o}=t,{background:l="#000000",borderColor:a="#000000",borderWidth:r=0}=i,{calculator:s,viewScaleInfo:c,viewSizeInfo:d}=n,{x:h,y:f,w:u,h:g}=(null==s?void 0:s.elementSize({x:t.x,y:t.y,w:t.w,h:t.h},c,d))||t,w={...t,x:h,y:f,w:u,h:g,angle:o};q(e,{x:h,y:f,w:u,h:g,angle:o},(()=>{Z(e,w,{viewScaleInfo:c,viewSizeInfo:d,renderContent:()=>{var n,i;const o=u/2,s=g/2,d=h+o,w=f+s;if(void 0!==(null==(n=null==t?void 0:t.detail)?void 0:n.opacity)&&(null==(i=null==t?void 0:t.detail)?void 0:i.opacity)>=0?e.globalAlpha=t.detail.opacity:e.globalAlpha=1,"number"==typeof r&&r>0){const t=r/2+o,n=r/2+s;e.beginPath(),e.strokeStyle=a,e.lineWidth=r,e.circle(d,w,t,n,0,0,2*Math.PI),e.closePath(),e.stroke()}e.beginPath();const v=J(e,l,{viewElementSize:{x:h,y:f,w:u,h:g},viewScaleInfo:c,opacity:e.globalAlpha});e.fillStyle=v,e.circle(d,w,o,s,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=1}})}))}(e,t,n);break;case"text":!function(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:l}=n,{x:a,y:r,w:s,h:c,angle:d}=(null==i?void 0:i.elementSize(t,o,l))||t,h={...t,x:a,y:r,w:s,h:c,angle:d};q(e,{x:a,y:r,w:s,h:c,angle:d},(()=>{Q(e,h,{originElem:t,calcElemSize:{x:a,y:r,w:s,h:c,angle:d},viewScaleInfo:o,viewSizeInfo:l,renderContent:()=>{const n={...ee,...t.detail},i=(n.fontSize||ee.fontSize)*o.scale,l=n.lineHeight?n.lineHeight*o.scale:i;e.fillStyle=t.detail.color||ee.color,e.textBaseline="top",e.$setFont({fontWeight:n.fontWeight,fontSize:i,fontFamily:n.fontFamily});const d=n.text.replace(/\r\n/gi,"\n"),h=l,f=d.split("\n"),u=[];let g=0;f.forEach(((t,n)=>{let i="";if(t.length>0){for(let o=0;o<t.length&&(e.measureText(i+(t[o]||"")).width<e.$doPixelRatio(s)?i+=t[o]||"":(u.push({text:i,width:e.$undoPixelRatio(e.measureText(i).width)}),i=t[o]||"",g++),!((g+1)*h>c));o++)if(t.length-1===o&&(g+1)*h<c){u.push({text:i,width:e.$undoPixelRatio(e.measureText(i).width)}),n<f.length-1&&g++;break}}else u.push({text:"",width:0})}));let w=0;u.length*h<c&&("top"===t.detail.verticalAlign?w=0:"bottom"===t.detail.verticalAlign?w+=c-u.length*h:w+=(c-u.length*h)/2);{const t=r+w;void 0!==n.textShadowColor&&C(n.textShadowColor)&&(e.shadowColor=n.textShadowColor),void 0!==n.textShadowOffsetX&&_.number(n.textShadowOffsetX)&&(e.shadowOffsetX=n.textShadowOffsetX),void 0!==n.textShadowOffsetY&&_.number(n.textShadowOffsetY)&&(e.shadowOffsetY=n.textShadowOffsetY),void 0!==n.textShadowBlur&&_.number(n.textShadowBlur)&&(e.shadowBlur=n.textShadowBlur),u.forEach(((i,o)=>{let l=a;"center"===n.textAlign?l=a+(s-i.width)/2:"right"===n.textAlign&&(l=a+(s-i.width)),e.fillText(i.text,l,t+h*o)}))}}})}))}(e,t,n);break;case"image":!function(e,t,n){const i=n.loader.getContent(t),{calculator:o,viewScaleInfo:l,viewSizeInfo:a}=n,{x:r,y:s,w:c,h:d,angle:h}=(null==o?void 0:o.elementSize(t,l,a))||t,f={...t,x:r,y:s,w:c,h:d,angle:h};q(e,{x:r,y:s,w:c,h:d,angle:h},(()=>{Z(e,f,{viewScaleInfo:l,viewSizeInfo:a,renderContent:()=>{Q(e,f,{originElem:t,calcElemSize:{x:r,y:s,w:c,h:d,angle:h},viewScaleInfo:l,viewSizeInfo:a,renderContent:()=>{if(i||n.loader.load(t,n.elementAssets||{}),"image"===t.type&&i){const{opacity:n}=t.detail;e.globalAlpha=n||1;const{x:o,y:r,w:s,h:c,radiusList:d}=V(f,{viewScaleInfo:l,viewSizeInfo:a});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(o+d[0],r),e.arcTo(o+s,r,o+s,r+c,d[1]),e.arcTo(o+s,r+c,o,r+c,d[2]),e.arcTo(o,r+c,o,r,d[3]),e.arcTo(o,r,o+s,r,d[0]),e.closePath(),e.fill(),e.clip(),e.drawImage(i,o,r,s,c),e.globalAlpha=1,e.restore()}}})}})}))}(e,t,n);break;case"svg":!function(e,t,n){const i=n.loader.getContent(t),{calculator:o,viewScaleInfo:l,viewSizeInfo:a}=n,{x:r,y:s,w:c,h:d,angle:h}=(null==o?void 0:o.elementSize(t,l,a))||t;q(e,{x:r,y:s,w:c,h:d,angle:h},(()=>{if(i||n.loader.load(t,n.elementAssets||{}),"svg"===t.type&&i){const{opacity:n}=t.detail;e.globalAlpha=n||1,e.drawImage(i,r,s,c,d),e.globalAlpha=1}}))}(e,t,n);break;case"html":!function(e,t,n){const i=n.loader.getContent(t),{calculator:o,viewScaleInfo:l,viewSizeInfo:a}=n,{x:r,y:s,w:c,h:d,angle:h}=(null==o?void 0:o.elementSize(t,l,a))||t;q(e,{x:r,y:s,w:c,h:d,angle:h},(()=>{if(i||n.loader.load(t,n.elementAssets||{}),"html"===t.type&&i){const{opacity:n}=t.detail;e.globalAlpha=n||1,e.drawImage(i,r,s,c,d),e.globalAlpha=1}}))}(e,t,n);break;case"path":!function(e,t,n){const{detail:i}=t,{originX:o,originY:l,originW:a,originH:r}=i,{calculator:s,viewScaleInfo:c,viewSizeInfo:d}=n,{x:h,y:f,w:u,h:g,angle:w}=(null==s?void 0:s.elementSize(t,c,d))||t,v=u/a,y=g/r,m=h-o*v,p=f-l*y,S=c.scale*d.devicePixelRatio,x={...t,x:h,y:f,w:u,h:g,angle:w};q(e,{x:h,y:f,w:u,h:g,angle:w},(()=>{Q(e,x,{originElem:t,calcElemSize:{x:h,y:f,w:u,h:g,angle:w},viewScaleInfo:c,viewSizeInfo:d,renderContent:()=>{Z(e,x,{viewScaleInfo:c,viewSizeInfo:d,renderContent:()=>{e.save(),e.translate(m,p),e.scale(S*v/c.scale,S*y/c.scale);const t=G(i.commands||[]),n=new Path2D(t);i.fill&&(e.fillStyle=i.fill,e.fill(n)),i.stroke&&0!==i.strokeWidth&&(e.strokeStyle=i.stroke,e.lineWidth=(i.strokeWidth||1)/d.devicePixelRatio,e.lineCap=i.strokeLineCap||"square",e.stroke(n)),e.translate(-m,-p),e.restore()}})}})}))}(e,t,n);break;case"group":{const i={...n.elementAssets||{},...t.detail.assets||{}};!function(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:l}=n,{x:a,y:r,w:s,h:c,angle:d}=(null==i?void 0:i.elementSize({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},o,l))||t,h={...t,x:a,y:r,w:s,h:c,angle:d};q(e,{x:a,y:r,w:s,h:c,angle:d},(()=>{Z(e,h,{viewScaleInfo:o,viewSizeInfo:l,renderContent:()=>{Q(e,h,{originElem:t,calcElemSize:{x:a,y:r,w:s,h:c,angle:d},viewScaleInfo:o,viewSizeInfo:l,renderContent:()=>{const{x:i,y:a,w:r,h:s,radiusList:c}=V(h,{viewScaleInfo:o,viewSizeInfo:l});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(i+c[0],a),e.arcTo(i+r,a,i+r,a+s,c[1]),e.arcTo(i+r,a+s,i,a+s,c[2]),e.arcTo(i,a+s,i,a,c[3]),e.arcTo(i,a,i+r,a,c[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:l}=n;for(let i=0;i<t.detail.children.length;i++){let a=t.detail.children[i];if(a={...a,x:o.x+a.x,y:o.y+a.y},!0===n.forceDrawAll||(null==l?void 0:l.isElementInView(a,n.viewScaleInfo,n.viewSizeInfo)))try{te(e,a,{...n})}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&(e.globalAlpha=1,e.restore())}})}})}))}(e,t,{...n,elementAssets:i});break}}}catch(e){console.error(e)}}const ne={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};const ie=["image","svg","html"],oe=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):$(`${k()}-${e.uuid}-${k()}-${k()}`)};class le extends j{constructor(){super(),z(this,o),z(this,a),z(this,s),z(this,d),z(this,f),z(this,g),z(this,v),z(this,t,{}),z(this,n,{}),z(this,i,{}),T(this,o,l).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 L(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}})),T(this,o,l).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 B(i,{width:e.detail.width||e.w,height:e.detail.height||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:o}})),T(this,o,l).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 D(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}}))}load(e,t){T(this,v,y).call(this,e)||ie.includes(e.type)&&T(this,g,w).call(this,e,t)}getContent(e){var t,n;const o=oe(e);return(null==(n=null==(t=I(this,i))?void 0:t[o])?void 0:n.content)||null}getLoadItemMap(){return I(this,i)}setLoadItemMap(e){A(this,i,e)}}t=new WeakMap,n=new WeakMap,i=new WeakMap,o=new WeakSet,l=function(e,n){I(this,t)[e]=n},a=new WeakSet,r=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=new WeakSet,c=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:T(this,a,r).call(this,e)}},d=new WeakSet,h=function(e){const t=oe(e.element),n=I(this,i)[t];n?n.startTime<e.startTime&&(I(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})):(I(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime}))},f=new WeakSet,u=function(e){const t=oe(e.element),n=I(this,i)[t];n?n.startTime<e.startTime&&(I(this,i)[t]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})):(I(this,i)[t]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime}))},g=new WeakSet,w=function(e,i){const o=T(this,s,c).call(this,e),l=oe(e);I(this,n)[l]=o;const a=I(this,t)[e.type];"function"==typeof a&&(o.startTime=Date.now(),a(e,i).then((e=>{o.content=e.content,o.endTime=Date.now(),o.status="load",T(this,d,h).call(this,o)})).catch((t=>{console.warn(`Load element source "${o.source}" fail`,t,e),o.endTime=Date.now(),o.status="error",o.error=t,T(this,f,u).call(this,o)})))},v=new WeakSet,y=function(e){var t;const i=oe(e),o=null==(t=I(this,n))?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==T(this,a,r).call(this,e))};return m=new WeakMap,p=new WeakMap,S=new WeakSet,x=function(){const e=I(this,p);e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(()=>{}))},e.Renderer=class extends j{constructor(e){super(),z(this,S),z(this,m,void 0),z(this,p,new le),A(this,m,e),T(this,S,x).call(this)}updateOptions(e){A(this,m,e)}drawData(e,t){const n=I(this,p),{calculator:i}=I(this,m),o=I(this,m).viewContext;o.clearRect(0,0,o.canvas.width,o.canvas.height);!function(e,t,n){var i;const{elements:o=[]}=t;for(let t=0;t<o.length;t++){const l=o[t],a={...l,detail:{...ne,...null==l?void 0:l.detail}};if(!0===n.forceDrawAll||(null==(i=n.calculator)?void 0:i.isElementInView(a,n.viewScaleInfo,n.viewSizeInfo)))try{te(e,a,n)}catch(e){console.error(e)}}}(o,e,{loader:n,calculator:i,parentElementSize:{x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height},elementAssets:e.assets,...t})}scale(e){const{sharer:t}=I(this,m);if(!t)return;const{data:n,offsetTop:i,offsetBottom:o,offsetLeft:l,offsetRight:a,width:r,height:s,contextHeight:c,contextWidth:d,devicePixelRatio:h}=t.getActiveStoreSnapshot();n&&this.drawData(n,{viewScaleInfo:{scale:e,offsetTop:i,offsetBottom:o,offsetLeft:l,offsetRight:a},viewSizeInfo:{width:r,height:s,contextHeight:c,contextWidth:d,devicePixelRatio:h}})}setLoadItemMap(e){I(this,p).setLoadItemMap(e)}getLoadItemMap(){return I(this,p).getLoadItemMap()}},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,g,w,v,y,p,m,x,S,b=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},I=(e,t,n)=>(b(e,t,"read from private field"),n?n.call(e):t.get(e)),z=(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)=>(b(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),T=(e,t,n)=>(b(e,t,"access private method"),n);function C(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 k(){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 W(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 $(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const P={type(e,t){const n=$(e);return!0===t?n.toLocaleLowerCase():n},array:e=>"Array"===$(e),json:e=>"Object"===$(e),function:e=>"Function"===$(e),asyncFunction:e=>"AsyncFunction"===$(e),string:e=>"String"===$(e),number:e=>"Number"===$(e),undefined:e=>"Undefined"===$(e),null:e=>"Null"===$(e),promise:e=>"Promise"===$(e)};var M=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:R}=window;function L(e){return new Promise(((t,n)=>{const i=new R;i.crossOrigin="anonymous",i.onload=function(){t(i)},i.onabort=n,i.onerror=n,i.src=e}))}function D(e){return M(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 L(t)}))}function B(e,t){return M(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 L(n)}))}function F(e){return"number"==typeof e&&(e>0||e<=0)}function H(e){return"number"==typeof e&&e>=0}function X(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function Y(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const _={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 C(e)},imageSrc:function(e){return Y(e)||X(e)},imageURL:X,imageBase64:Y,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}};class j{constructor(){this._listeners=new Map}on(e,t){if(this._listeners.has(e)){const n=this._listeners.get(e)||[];null==n||n.push(t),this._listeners.set(e,n)}else this._listeners.set(e,[t])}off(e,t){if(this._listeners.has(e)){const n=this._listeners.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}this._listeners.set(e,n||[])}}trigger(e,t){const n=this._listeners.get(e);return!!Array.isArray(n)&&(n.forEach((e=>{e(t)})),!0)}has(e){if(this._listeners.has(e)){const t=this._listeners.get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}}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 q(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 G(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}const N={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function V(e,t){const{viewScaleInfo:n}=t,{scale:i}=n;let{borderRadius:o}=e.detail;const{boxSizing:a=N.boxSizing,borderWidth:r}=e.detail;Array.isArray(r)&&(o=0);let{x:l,y:s,w:c,h:d}=e,h=[0,0,0,0];if("number"==typeof o){const e=o*i;h=[e,e,e,e]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(h=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let f=0;return"number"==typeof r&&(f=(r||0)*i),"border-box"===a?(l=e.x+f/2,s=e.y+f/2,c=e.w-f,d=e.h-f):"content-box"===a?(l=e.x-f/2,s=e.y-f/2,c=e.w+f,d=e.h+f):(l=e.x,s=e.y,c=e.w,d=e.h),c=Math.max(c,1),d=Math.max(d,1),h=h.map((e=>Math.min(e,c/2,d/2))),{x:l,y:s,w:c,h:d,radiusList:h}}function J(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 K={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function Q(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 Z(e,t,n){const{pattern:i,renderContent:o,originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s}=n||{},{parentOpacity:c}=n,d=Q(a)*c;!function(e,t,n){const{renderContent:i,originElem:o,calcElemSize:a,viewScaleInfo:r,viewSizeInfo:l}=n,s=r.scale*l.devicePixelRatio,{clipPath:c}=(null==o?void 0:o.detail)||{};if(c&&a&&c.commands){const{x:n,y:o,w:r,h:l}=a,{originW:d,originH:h,originX:f,originY:u}=c,g=r/d,w=l/h,v=n-f*g,y=o-u*w;e.save(),e.translate(v,y),e.scale(s*g,s*w);const p=G(c.commands||[]),m=new Path2D(p);e.clip(m),e.translate(0-v,0-y),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:()=>{e.globalAlpha=d,function(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}=V(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=J(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=J(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)}}(e,t,{pattern:i,viewScaleInfo:l,viewSizeInfo:s}),null==o||o(),function(e,t,n){if(0===t.detail.borderWidth)return;if(!C(t.detail.borderColor))return;const{viewScaleInfo:i}=n,{scale:o}=i;let a=K.borderColor;!0===C(t.detail.borderColor)&&(a=t.detail.borderColor);const{borderWidth:r,borderRadius:l,borderDash:s,boxSizing:c=K.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,g=0,w=0,v=0;Array.isArray(r)&&(u=(r[0]||0)*o,g=(r[1]||0)*o,w=(r[2]||0)*o,v=(r[3]||0)*o);if(v||g||u||w){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-g/2,a=a-u/2-w/2):"content-box"===c?(n-=v/2,i-=u/2,o=o+v/2+g/2,a=a+u/2+w/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+g/2,i),e.closePath(),e.stroke()),g&&(e.beginPath(),e.lineWidth=g,e.moveTo(n+o,i-u/2),e.lineTo(n+o,i+a+w/2),e.closePath(),e.stroke()),w&&(e.beginPath(),e.lineWidth=w,e.moveTo(n-v/2,i+a),e.lineTo(n+o+g/2,i+a),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(n,i-u/2),e.lineTo(n,i+a+w/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([])}(e,t,{viewScaleInfo:l,viewSizeInfo:s}),e.globalAlpha=c}})}function ee(e,t,n){const{detail:i}=t,{viewScaleInfo:o,renderContent:a}=n,{shadowColor:r,shadowOffsetX:l,shadowOffsetY:s,shadowBlur:c}=i;_.number(c)?(e.save(),e.shadowColor=r||K.shadowColor,e.shadowOffsetX=(l||0)*o.scale,e.shadowOffsetY=(s||0)*o.scale,e.shadowBlur=(c||0)*o.scale,a(),e.restore()):a()}const te={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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function ne(e,t,n){var i;if(!0!==(null==(i=null==t?void 0:t.operations)?void 0:i.invisible))try{switch(t.type){case"rect":!function(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=(null==i?void 0:i.elementSize(t,o,a))||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},(()=>{ee(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{Z(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:c,h:d,angle:h},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{}})}})}))}(e,t,n);break;case"circle":!function(e,t,n){const{detail:i,angle:o}=t,{background:a="#000000",borderColor:r="#000000",boxSizing:l,borderWidth:s=0}=i;let c=0;"number"==typeof s&&s>0?c=s:Array.isArray(s)&&"number"==typeof s[0]&&s[0]>0&&(c=s[0]);const{calculator:d,viewScaleInfo:h,viewSizeInfo:f,parentOpacity:u}=n,{x:g,y:w,w:v,h:y}=(null==d?void 0:d.elementSize({x:t.x,y:t.y,w:t.w,h:t.h},h,f))||t,p={...t,x:g,y:w,w:v,h:y,angle:o};q(e,{x:g,y:w,w:v,h:y,angle:o},(()=>{ee(e,p,{viewScaleInfo:h,viewSizeInfo:f,renderContent:()=>{let t=v/2,n=y/2;const i=g+t,o=w+n;c>0&&("border-box"===l?(t-=c,n-=c):"center-line"===l?(t-=c/2,n-=c/2):(t-=c,n-=c));const d=Q(p)*u;if(e.globalAlpha=d,"number"==typeof s&&s>0){const a=s/2+t,l=s/2+n;e.beginPath(),e.strokeStyle=r,e.lineWidth=s,e.circle(i,o,a,l,0,0,2*Math.PI),e.closePath(),e.stroke()}e.beginPath();const f=J(e,a,{viewElementSize:{x:g,y:w,w:v,h:y},viewScaleInfo:h,opacity:e.globalAlpha});e.fillStyle=f,e.circle(i,o,t,n,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=u}})}))}(e,t,n);break;case"text":!function(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=(null==i?void 0:i.elementSize(t,o,a))||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},(()=>{Z(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:c,h:d,angle:h},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{const n={...te,...t.detail},i=(n.fontSize||te.fontSize)*o.scale,a=n.lineHeight?n.lineHeight*o.scale:i;e.fillStyle=t.detail.color||te.color,e.textBaseline="top",e.$setFont({fontWeight:n.fontWeight,fontSize:i,fontFamily:n.fontFamily});const r=n.text.replace(/\r\n/gi,"\n"),h=a,f=r.split("\n"),u=[];let g=0;f.forEach(((t,n)=>{let i="";if(t.length>0){for(let o=0;o<t.length&&(e.measureText(i+(t[o]||"")).width<e.$doPixelRatio(c)?i+=t[o]||"":(u.push({text:i,width:e.$undoPixelRatio(e.measureText(i).width)}),i=t[o]||"",g++),!((g+1)*h>d));o++)if(t.length-1===o&&(g+1)*h<d){u.push({text:i,width:e.$undoPixelRatio(e.measureText(i).width)}),n<f.length-1&&g++;break}}else u.push({text:"",width:0})}));let w=0;u.length*h<d&&("top"===t.detail.verticalAlign?w=0:"bottom"===t.detail.verticalAlign?w+=d-u.length*h:w+=(d-u.length*h)/2);{const t=s+w;void 0!==n.textShadowColor&&C(n.textShadowColor)&&(e.shadowColor=n.textShadowColor),void 0!==n.textShadowOffsetX&&_.number(n.textShadowOffsetX)&&(e.shadowOffsetX=n.textShadowOffsetX),void 0!==n.textShadowOffsetY&&_.number(n.textShadowOffsetY)&&(e.shadowOffsetY=n.textShadowOffsetY),void 0!==n.textShadowBlur&&_.number(n.textShadowBlur)&&(e.shadowBlur=n.textShadowBlur),u.forEach(((i,o)=>{let a=l;"center"===n.textAlign?a=l+(c-i.width)/2:"right"===n.textAlign&&(a=l+(c-i.width)),e.fillText(i.text,a,t+h*o)}))}}})}))}(e,t,n);break;case"image":!function(e,t,n){const i=n.loader.getContent(t),{calculator:o,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=n,{x:s,y:c,w:d,h:h,angle:f}=(null==o?void 0:o.elementSize(t,a,r))||t,u={...t,x:s,y:c,w:d,h:h,angle:f};q(e,{x:s,y:c,w:d,h:h,angle:f},(()=>{ee(e,u,{viewScaleInfo:a,viewSizeInfo:r,renderContent:()=>{Z(e,u,{originElem:t,calcElemSize:{x:s,y:c,w:d,h:h,angle:f},viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l,renderContent:()=>{if(i||n.loader.load(t,n.elementAssets||{}),"image"===t.type&&i){e.globalAlpha=Q(t)*l;const{x:n,y:o,w:s,h:c,radiusList:d}=V(u,{viewScaleInfo:a,viewSizeInfo:r});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(n+d[0],o),e.arcTo(n+s,o,n+s,o+c,d[1]),e.arcTo(n+s,o+c,n,o+c,d[2]),e.arcTo(n,o+c,n,o,d[3]),e.arcTo(n,o,n+s,o,d[0]),e.closePath(),e.fill(),e.clip(),e.drawImage(i,n,o,s,c),e.globalAlpha=l,e.restore()}}})}})}))}(e,t,n);break;case"svg":!function(e,t,n){const i=n.loader.getContent(t),{calculator:o,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=n,{x:s,y:c,w:d,h:h,angle:f}=(null==o?void 0:o.elementSize(t,a,r))||t;q(e,{x:s,y:c,w:d,h:h,angle:f},(()=>{i||n.loader.load(t,n.elementAssets||{}),"svg"===t.type&&i&&(e.globalAlpha=Q(t)*l,e.drawImage(i,s,c,d,h),e.globalAlpha=l)}))}(e,t,n);break;case"html":!function(e,t,n){const i=n.loader.getContent(t),{calculator:o,viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=n,{x:s,y:c,w:d,h:h,angle:f}=(null==o?void 0:o.elementSize(t,a,r))||t;q(e,{x:s,y:c,w:d,h:h,angle:f},(()=>{i||n.loader.load(t,n.elementAssets||{}),"html"===t.type&&i&&(e.globalAlpha=Q(t)*l,e.drawImage(i,s,c,d,h),e.globalAlpha=l)}))}(e,t,n);break;case"path":!function(e,t,n){const{detail:i}=t,{originX:o,originY:a,originW:r,originH:l}=i,{calculator:s,viewScaleInfo:c,viewSizeInfo:d,parentOpacity:h}=n,{x:f,y:u,w:g,h:w,angle:v}=(null==s?void 0:s.elementSize(t,c,d))||t,y=g/r,p=w/l,m=f-o*y,x=u-a*p,S=c.scale*d.devicePixelRatio,b={...t,x:f,y:u,w:g,h:w,angle:v};q(e,{x:f,y:u,w:g,h:w,angle:v},(()=>{Z(e,b,{originElem:t,calcElemSize:{x:f,y:u,w:g,h:w,angle:v},viewScaleInfo:c,viewSizeInfo:d,parentOpacity:h,renderContent:()=>{ee(e,b,{viewScaleInfo:c,viewSizeInfo:d,renderContent:()=>{e.save(),e.translate(m,x),e.scale(S*y/c.scale,S*p/c.scale);const t=G(i.commands||[]),n=new Path2D(t);i.fill&&(e.fillStyle=i.fill,e.fill(n)),i.stroke&&0!==i.strokeWidth&&(e.strokeStyle=i.stroke,e.lineWidth=(i.strokeWidth||1)/d.devicePixelRatio,e.lineCap=i.strokeLineCap||"square",e.stroke(n)),e.translate(-m,-x),e.restore()}})}})}))}(e,t,n);break;case"group":{const i={...n.elementAssets||{},...t.detail.assets||{}};!function(e,t,n){const{calculator:i,viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=(null==i?void 0:i.elementSize({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},o,a))||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},(()=>{e.globalAlpha=Q(t)*r,ee(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{Z(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:c,h:d,angle:h},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{const{x:i,y:l,w:s,h:c,radiusList:d}=V(f,{viewScaleInfo:o,viewSizeInfo:a});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(i+d[0],l),e.arcTo(i+s,l,i+s,l+c,d[1]),e.arcTo(i+s,l+c,i,l+c,d[2]),e.arcTo(i,l+c,i,l,d[3]),e.arcTo(i,l,i+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:a}=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==a?void 0:a.isElementInView(l,n.viewScaleInfo,n.viewSizeInfo)))try{ne(e,l,{...n,parentOpacity:r*Q(t)})}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&e.restore()}})}}),e.globalAlpha=r}))}(e,t,{...n,elementAssets:i});break}}}catch(e){console.error(e)}}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,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};const oe=["image","svg","html"],ae=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:W(o):W(`${k()}-${e.uuid}-${k()}-${k()}`)};class re extends j{constructor(){super(),z(this,o),z(this,r),z(this,s),z(this,d),z(this,f),z(this,g),z(this,v),z(this,t,{}),z(this,n,{}),z(this,i,{}),T(this,o,a).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 L(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}})),T(this,o,a).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 B(i,{width:e.detail.originW||e.w,height:e.detail.originH||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:o}})),T(this,o,a).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 D(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}}))}load(e,t){T(this,v,y).call(this,e)||oe.includes(e.type)&&T(this,g,w).call(this,e,t)}getContent(e){var t,n;const o=ae(e);return(null==(n=null==(t=I(this,i))?void 0:t[o])?void 0:n.content)||null}getLoadItemMap(){return I(this,i)}setLoadItemMap(e){A(this,i,e)}}t=new WeakMap,n=new WeakMap,i=new WeakMap,o=new WeakSet,a=function(e,n){I(this,t)[e]=n},r=new WeakSet,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=new WeakSet,c=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:T(this,r,l).call(this,e)}},d=new WeakSet,h=function(e){const t=ae(e.element),n=I(this,i)[t];n?n.startTime<e.startTime&&(I(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})):(I(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime}))},f=new WeakSet,u=function(e){const t=ae(e.element),n=I(this,i)[t];n?n.startTime<e.startTime&&(I(this,i)[t]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})):(I(this,i)[t]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime}))},g=new WeakSet,w=function(e,i){const o=T(this,s,c).call(this,e),a=ae(e);I(this,n)[a]=o;const r=I(this,t)[e.type];"function"==typeof r&&(o.startTime=Date.now(),r(e,i).then((e=>{o.content=e.content,o.endTime=Date.now(),o.status="load",T(this,d,h).call(this,o)})).catch((t=>{console.warn(`Load element source "${o.source}" fail`,t,e),o.endTime=Date.now(),o.status="error",o.error=t,T(this,f,u).call(this,o)})))},v=new WeakSet,y=function(e){var t;const i=ae(e),o=null==(t=I(this,n))?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==T(this,r,l).call(this,e))};return p=new WeakMap,m=new WeakMap,x=new WeakSet,S=function(){const e=I(this,m);e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(()=>{}))},e.Renderer=class extends j{constructor(e){super(),z(this,x),z(this,p,void 0),z(this,m,new re),A(this,p,e),T(this,x,S).call(this)}updateOptions(e){A(this,p,e)}drawData(e,t){const n=I(this,m),{calculator:i}=I(this,p),o=I(this,p).viewContext;o.clearRect(0,0,o.canvas.width,o.canvas.height);!function(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:{...ie,...null==r?void 0:r.detail}};if(!0===n.forceDrawAll||(null==(i=n.calculator)?void 0:i.isElementInView(l,n.viewScaleInfo,n.viewSizeInfo)))try{ne(e,l,{...n,parentOpacity:a})}catch(e){console.error(e)}}}(o,e,{loader:n,calculator:i,parentElementSize:{x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height},elementAssets:e.assets,parentOpacity:1,...t})}scale(e){const{sharer:t}=I(this,p);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){I(this,m).setLoadItemMap(e)}getLoadItemMap(){return I(this,m).getLoadItemMap()}},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.6",
|
|
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.6"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@idraw/util": "^0.4.0-beta.
|
|
28
|
+
"@idraw/util": "^0.4.0-beta.6"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public",
|