@antv/g-canvas 1.5.0 → 1.5.3
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/index.esm.js +3 -4
- package/dist/index.js +3 -4
- package/dist/index.umd.js +354 -115
- package/dist/index.umd.min.js +6 -6
- package/package.json +8 -8
package/dist/index.esm.js
CHANGED
|
@@ -517,11 +517,10 @@ var Canvas2DContextService = /*#__PURE__*/function () {
|
|
|
517
517
|
this.$canvas.width = this.dpr * width;
|
|
518
518
|
this.$canvas.height = this.dpr * height; // set CSS style width & height
|
|
519
519
|
|
|
520
|
-
setDOMSize(this.$canvas, width, height);
|
|
521
|
-
|
|
520
|
+
setDOMSize(this.$canvas, width, height); // const dpr = this.getDPR();
|
|
521
|
+
// scale all drawing operations by the dpr
|
|
522
522
|
// @see https://www.html5rocks.com/en/tutorials/canvas/hidpi/
|
|
523
|
-
|
|
524
|
-
this.context.scale(dpr, dpr);
|
|
523
|
+
// this.context.scale(dpr, dpr);
|
|
525
524
|
}
|
|
526
525
|
};
|
|
527
526
|
|
package/dist/index.js
CHANGED
|
@@ -536,11 +536,10 @@ var Canvas2DContextService = /*#__PURE__*/function () {
|
|
|
536
536
|
this.$canvas.width = this.dpr * width;
|
|
537
537
|
this.$canvas.height = this.dpr * height; // set CSS style width & height
|
|
538
538
|
|
|
539
|
-
g.setDOMSize(this.$canvas, width, height);
|
|
540
|
-
|
|
539
|
+
g.setDOMSize(this.$canvas, width, height); // const dpr = this.getDPR();
|
|
540
|
+
// scale all drawing operations by the dpr
|
|
541
541
|
// @see https://www.html5rocks.com/en/tutorials/canvas/hidpi/
|
|
542
|
-
|
|
543
|
-
this.context.scale(dpr, dpr);
|
|
542
|
+
// this.context.scale(dpr, dpr);
|
|
544
543
|
}
|
|
545
544
|
};
|
|
546
545
|
|
package/dist/index.umd.js
CHANGED
|
@@ -1547,7 +1547,7 @@
|
|
|
1547
1547
|
|
|
1548
1548
|
renderingService.hooks.pick.tapPromise(CanvasPickerPlugin_1.tag, /*#__PURE__*/function () {
|
|
1549
1549
|
var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee(result) {
|
|
1550
|
-
var topmost, _result$position, x, y, position, rBushNodes, queriedIds, hitTestList, pickedDisplayObjects, _i, _hitTestList, displayObject,
|
|
1550
|
+
var topmost, _result$position, x, y, position, rBushNodes, queriedIds, hitTestList, pickedDisplayObjects, _i, _hitTestList, displayObject, worldTransform, isHitOriginShape, clipPath, isHitClipPath;
|
|
1551
1551
|
|
|
1552
1552
|
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
1553
1553
|
while (1) {
|
|
@@ -1584,52 +1584,79 @@
|
|
|
1584
1584
|
|
|
1585
1585
|
hitTestList.sort(function (a, b) {
|
|
1586
1586
|
return b.sortable.renderOrder - a.sortable.renderOrder;
|
|
1587
|
-
});
|
|
1587
|
+
}); // test with clip path & origin shape
|
|
1588
|
+
// @see https://github.com/antvis/g/issues/1064
|
|
1589
|
+
|
|
1588
1590
|
pickedDisplayObjects = [];
|
|
1589
1591
|
_i = 0, _hitTestList = hitTestList;
|
|
1590
1592
|
|
|
1591
1593
|
case 9:
|
|
1592
1594
|
if (!(_i < _hitTestList.length)) {
|
|
1593
|
-
_context.next =
|
|
1595
|
+
_context.next = 36;
|
|
1594
1596
|
break;
|
|
1595
1597
|
}
|
|
1596
1598
|
|
|
1597
|
-
displayObject = _hitTestList[_i];
|
|
1599
|
+
displayObject = _hitTestList[_i];
|
|
1600
|
+
worldTransform = displayObject.getWorldTransform();
|
|
1601
|
+
isHitOriginShape = _this2.isHit(displayObject, position, worldTransform);
|
|
1602
|
+
|
|
1603
|
+
if (!isHitOriginShape) {
|
|
1604
|
+
_context.next = 33;
|
|
1605
|
+
break;
|
|
1606
|
+
}
|
|
1598
1607
|
|
|
1599
1608
|
clipPath = displayObject.parsedStyle.clipPath;
|
|
1600
|
-
objectToTest = clipPath || displayObject;
|
|
1601
|
-
worldTransform = displayObject.getWorldTransform(); // clipped's world matrix * clipPath's local matrix
|
|
1602
1609
|
|
|
1603
|
-
if (clipPath) {
|
|
1604
|
-
|
|
1610
|
+
if (!clipPath) {
|
|
1611
|
+
_context.next = 27;
|
|
1612
|
+
break;
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
worldTransform = multiply(create(), worldTransform, clipPath.getLocalTransform());
|
|
1616
|
+
isHitClipPath = _this2.isHit(clipPath, position, worldTransform);
|
|
1617
|
+
|
|
1618
|
+
if (!isHitClipPath) {
|
|
1619
|
+
_context.next = 25;
|
|
1620
|
+
break;
|
|
1605
1621
|
}
|
|
1606
1622
|
|
|
1607
|
-
if (!
|
|
1608
|
-
_context.next =
|
|
1623
|
+
if (!topmost) {
|
|
1624
|
+
_context.next = 24;
|
|
1609
1625
|
break;
|
|
1610
1626
|
}
|
|
1611
1627
|
|
|
1628
|
+
result.picked = [displayObject];
|
|
1629
|
+
return _context.abrupt("return", result);
|
|
1630
|
+
|
|
1631
|
+
case 24:
|
|
1632
|
+
pickedDisplayObjects.push(displayObject);
|
|
1633
|
+
|
|
1634
|
+
case 25:
|
|
1635
|
+
_context.next = 33;
|
|
1636
|
+
break;
|
|
1637
|
+
|
|
1638
|
+
case 27:
|
|
1612
1639
|
if (!topmost) {
|
|
1613
|
-
_context.next =
|
|
1640
|
+
_context.next = 32;
|
|
1614
1641
|
break;
|
|
1615
1642
|
}
|
|
1616
1643
|
|
|
1617
1644
|
result.picked = [displayObject];
|
|
1618
1645
|
return _context.abrupt("return", result);
|
|
1619
1646
|
|
|
1620
|
-
case
|
|
1647
|
+
case 32:
|
|
1621
1648
|
pickedDisplayObjects.push(displayObject);
|
|
1622
1649
|
|
|
1623
|
-
case
|
|
1650
|
+
case 33:
|
|
1624
1651
|
_i++;
|
|
1625
1652
|
_context.next = 9;
|
|
1626
1653
|
break;
|
|
1627
1654
|
|
|
1628
|
-
case
|
|
1655
|
+
case 36:
|
|
1629
1656
|
result.picked = pickedDisplayObjects;
|
|
1630
1657
|
return _context.abrupt("return", result);
|
|
1631
1658
|
|
|
1632
|
-
case
|
|
1659
|
+
case 38:
|
|
1633
1660
|
case "end":
|
|
1634
1661
|
return _context.stop();
|
|
1635
1662
|
}
|
|
@@ -2179,7 +2206,7 @@
|
|
|
2179
2206
|
increasedLineWidthForHitTesting = _displayObject$parsed.increasedLineWidthForHitTesting,
|
|
2180
2207
|
clipPathTargets = _displayObject$parsed.clipPathTargets;
|
|
2181
2208
|
var r = rInPixels.value;
|
|
2182
|
-
var halfLineWidth = ((lineWidth
|
|
2209
|
+
var halfLineWidth = (((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0)) / 2;
|
|
2183
2210
|
var absDistance = distance$1(r, r, position.x, position.y);
|
|
2184
2211
|
var isClipPath = !!(clipPathTargets === null || clipPathTargets === void 0 ? void 0 : clipPathTargets.length);
|
|
2185
2212
|
var hasFill = fill && !fill.isNone;
|
|
@@ -2220,7 +2247,7 @@
|
|
|
2220
2247
|
var hasStroke = stroke && !stroke.isNone;
|
|
2221
2248
|
var rx = rxInPixels.value;
|
|
2222
2249
|
var ry = ryInPixels.value;
|
|
2223
|
-
var halfLineWith = (((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + increasedLineWidthForHitTesting.value) / 2;
|
|
2250
|
+
var halfLineWith = (((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0)) / 2;
|
|
2224
2251
|
var squareX = (x - rx) * (x - rx);
|
|
2225
2252
|
var squareY = (y - ry) * (y - ry); // 使用椭圆的公式: x*x/rx*rx + y*y/ry*ry = 1;
|
|
2226
2253
|
|
|
@@ -2251,7 +2278,7 @@
|
|
|
2251
2278
|
x = _displayObject$parsed2 === void 0 ? 0 : _displayObject$parsed2,
|
|
2252
2279
|
_displayObject$parsed3 = _displayObject$parsed.defY,
|
|
2253
2280
|
y = _displayObject$parsed3 === void 0 ? 0 : _displayObject$parsed3;
|
|
2254
|
-
return inLine(x1.value, y1.value, x2.value, y2.value, lineWidth.value + increasedLineWidthForHitTesting.value, position.x + x, position.y + y);
|
|
2281
|
+
return inLine(x1.value, y1.value, x2.value, y2.value, ((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0), position.x + x, position.y + y);
|
|
2255
2282
|
}
|
|
2256
2283
|
|
|
2257
2284
|
function isPointInStroke(segments, lineWidth, px, py, length, x, y) {
|
|
@@ -2322,7 +2349,7 @@
|
|
|
2322
2349
|
var isHit = false;
|
|
2323
2350
|
|
|
2324
2351
|
if (hasStroke || isClipPath) {
|
|
2325
|
-
isHit = isPointInStroke(segments, lineWidth.value + increasedLineWidthForHitTesting.value, position.x + x, position.y + y, totalLength);
|
|
2352
|
+
isHit = isPointInStroke(segments, ((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0), position.x + x, position.y + y, totalLength);
|
|
2326
2353
|
}
|
|
2327
2354
|
|
|
2328
2355
|
if (!isHit && (hasFill || isClipPath)) {
|
|
@@ -2356,7 +2383,7 @@
|
|
|
2356
2383
|
var isHit = false;
|
|
2357
2384
|
|
|
2358
2385
|
if (hasStroke || isClipPath) {
|
|
2359
|
-
isHit = inPolyline(points.points, lineWidth.value + increasedLineWidthForHitTesting.value, position.x + x, position.y + y, true);
|
|
2386
|
+
isHit = inPolyline(points.points, ((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0), position.x + x, position.y + y, true);
|
|
2360
2387
|
}
|
|
2361
2388
|
|
|
2362
2389
|
if (!isHit && (hasFill || isClipPath)) {
|
|
@@ -2384,7 +2411,7 @@
|
|
|
2384
2411
|
return false;
|
|
2385
2412
|
}
|
|
2386
2413
|
|
|
2387
|
-
return inPolyline(points.points, lineWidth.value + increasedLineWidthForHitTesting.value, position.x + x, position.y + y, false);
|
|
2414
|
+
return inPolyline(points.points, ((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0), position.x + x, position.y + y, false);
|
|
2388
2415
|
}
|
|
2389
2416
|
|
|
2390
2417
|
function isPointInPath$6(displayObject, position, isPointInPath) {
|
|
@@ -2418,7 +2445,7 @@
|
|
|
2418
2445
|
height = heightValue;
|
|
2419
2446
|
}
|
|
2420
2447
|
|
|
2421
|
-
var lineWidthForHitTesting = lineWidth.value + increasedLineWidthForHitTesting.value; // 无圆角时的策略
|
|
2448
|
+
var lineWidthForHitTesting = ((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0); // 无圆角时的策略
|
|
2422
2449
|
|
|
2423
2450
|
if (!hasRadius) {
|
|
2424
2451
|
var halfWidth = lineWidthForHitTesting / 2; // 同时填充和带有边框
|
|
@@ -3650,6 +3677,184 @@
|
|
|
3650
3677
|
out[15] = 1;
|
|
3651
3678
|
return out;
|
|
3652
3679
|
}
|
|
3680
|
+
/**
|
|
3681
|
+
* Copy the values from one mat4 to another
|
|
3682
|
+
*
|
|
3683
|
+
* @param {mat4} out the receiving matrix
|
|
3684
|
+
* @param {ReadonlyMat4} a the source matrix
|
|
3685
|
+
* @returns {mat4} out
|
|
3686
|
+
*/
|
|
3687
|
+
|
|
3688
|
+
|
|
3689
|
+
function copy(out, a) {
|
|
3690
|
+
out[0] = a[0];
|
|
3691
|
+
out[1] = a[1];
|
|
3692
|
+
out[2] = a[2];
|
|
3693
|
+
out[3] = a[3];
|
|
3694
|
+
out[4] = a[4];
|
|
3695
|
+
out[5] = a[5];
|
|
3696
|
+
out[6] = a[6];
|
|
3697
|
+
out[7] = a[7];
|
|
3698
|
+
out[8] = a[8];
|
|
3699
|
+
out[9] = a[9];
|
|
3700
|
+
out[10] = a[10];
|
|
3701
|
+
out[11] = a[11];
|
|
3702
|
+
out[12] = a[12];
|
|
3703
|
+
out[13] = a[13];
|
|
3704
|
+
out[14] = a[14];
|
|
3705
|
+
out[15] = a[15];
|
|
3706
|
+
return out;
|
|
3707
|
+
}
|
|
3708
|
+
/**
|
|
3709
|
+
* Multiplies two mat4s
|
|
3710
|
+
*
|
|
3711
|
+
* @param {mat4} out the receiving matrix
|
|
3712
|
+
* @param {ReadonlyMat4} a the first operand
|
|
3713
|
+
* @param {ReadonlyMat4} b the second operand
|
|
3714
|
+
* @returns {mat4} out
|
|
3715
|
+
*/
|
|
3716
|
+
|
|
3717
|
+
|
|
3718
|
+
function multiply$1(out, a, b) {
|
|
3719
|
+
var a00 = a[0],
|
|
3720
|
+
a01 = a[1],
|
|
3721
|
+
a02 = a[2],
|
|
3722
|
+
a03 = a[3];
|
|
3723
|
+
var a10 = a[4],
|
|
3724
|
+
a11 = a[5],
|
|
3725
|
+
a12 = a[6],
|
|
3726
|
+
a13 = a[7];
|
|
3727
|
+
var a20 = a[8],
|
|
3728
|
+
a21 = a[9],
|
|
3729
|
+
a22 = a[10],
|
|
3730
|
+
a23 = a[11];
|
|
3731
|
+
var a30 = a[12],
|
|
3732
|
+
a31 = a[13],
|
|
3733
|
+
a32 = a[14],
|
|
3734
|
+
a33 = a[15]; // Cache only the current line of the second matrix
|
|
3735
|
+
|
|
3736
|
+
var b0 = b[0],
|
|
3737
|
+
b1 = b[1],
|
|
3738
|
+
b2 = b[2],
|
|
3739
|
+
b3 = b[3];
|
|
3740
|
+
out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
3741
|
+
out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
3742
|
+
out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
3743
|
+
out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
3744
|
+
b0 = b[4];
|
|
3745
|
+
b1 = b[5];
|
|
3746
|
+
b2 = b[6];
|
|
3747
|
+
b3 = b[7];
|
|
3748
|
+
out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
3749
|
+
out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
3750
|
+
out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
3751
|
+
out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
3752
|
+
b0 = b[8];
|
|
3753
|
+
b1 = b[9];
|
|
3754
|
+
b2 = b[10];
|
|
3755
|
+
b3 = b[11];
|
|
3756
|
+
out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
3757
|
+
out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
3758
|
+
out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
3759
|
+
out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
3760
|
+
b0 = b[12];
|
|
3761
|
+
b1 = b[13];
|
|
3762
|
+
b2 = b[14];
|
|
3763
|
+
b3 = b[15];
|
|
3764
|
+
out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
3765
|
+
out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
3766
|
+
out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
3767
|
+
out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
3768
|
+
return out;
|
|
3769
|
+
}
|
|
3770
|
+
/**
|
|
3771
|
+
* Translate a mat4 by the given vector
|
|
3772
|
+
*
|
|
3773
|
+
* @param {mat4} out the receiving matrix
|
|
3774
|
+
* @param {ReadonlyMat4} a the matrix to translate
|
|
3775
|
+
* @param {ReadonlyVec3} v vector to translate by
|
|
3776
|
+
* @returns {mat4} out
|
|
3777
|
+
*/
|
|
3778
|
+
|
|
3779
|
+
|
|
3780
|
+
function translate(out, a, v) {
|
|
3781
|
+
var x = v[0],
|
|
3782
|
+
y = v[1],
|
|
3783
|
+
z = v[2];
|
|
3784
|
+
var a00, a01, a02, a03;
|
|
3785
|
+
var a10, a11, a12, a13;
|
|
3786
|
+
var a20, a21, a22, a23;
|
|
3787
|
+
|
|
3788
|
+
if (a === out) {
|
|
3789
|
+
out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];
|
|
3790
|
+
out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];
|
|
3791
|
+
out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];
|
|
3792
|
+
out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];
|
|
3793
|
+
} else {
|
|
3794
|
+
a00 = a[0];
|
|
3795
|
+
a01 = a[1];
|
|
3796
|
+
a02 = a[2];
|
|
3797
|
+
a03 = a[3];
|
|
3798
|
+
a10 = a[4];
|
|
3799
|
+
a11 = a[5];
|
|
3800
|
+
a12 = a[6];
|
|
3801
|
+
a13 = a[7];
|
|
3802
|
+
a20 = a[8];
|
|
3803
|
+
a21 = a[9];
|
|
3804
|
+
a22 = a[10];
|
|
3805
|
+
a23 = a[11];
|
|
3806
|
+
out[0] = a00;
|
|
3807
|
+
out[1] = a01;
|
|
3808
|
+
out[2] = a02;
|
|
3809
|
+
out[3] = a03;
|
|
3810
|
+
out[4] = a10;
|
|
3811
|
+
out[5] = a11;
|
|
3812
|
+
out[6] = a12;
|
|
3813
|
+
out[7] = a13;
|
|
3814
|
+
out[8] = a20;
|
|
3815
|
+
out[9] = a21;
|
|
3816
|
+
out[10] = a22;
|
|
3817
|
+
out[11] = a23;
|
|
3818
|
+
out[12] = a00 * x + a10 * y + a20 * z + a[12];
|
|
3819
|
+
out[13] = a01 * x + a11 * y + a21 * z + a[13];
|
|
3820
|
+
out[14] = a02 * x + a12 * y + a22 * z + a[14];
|
|
3821
|
+
out[15] = a03 * x + a13 * y + a23 * z + a[15];
|
|
3822
|
+
}
|
|
3823
|
+
|
|
3824
|
+
return out;
|
|
3825
|
+
}
|
|
3826
|
+
/**
|
|
3827
|
+
* Creates a matrix from a vector scaling
|
|
3828
|
+
* This is equivalent to (but much faster than):
|
|
3829
|
+
*
|
|
3830
|
+
* mat4.identity(dest);
|
|
3831
|
+
* mat4.scale(dest, dest, vec);
|
|
3832
|
+
*
|
|
3833
|
+
* @param {mat4} out mat4 receiving operation result
|
|
3834
|
+
* @param {ReadonlyVec3} v Scaling vector
|
|
3835
|
+
* @returns {mat4} out
|
|
3836
|
+
*/
|
|
3837
|
+
|
|
3838
|
+
|
|
3839
|
+
function fromScaling(out, v) {
|
|
3840
|
+
out[0] = v[0];
|
|
3841
|
+
out[1] = 0;
|
|
3842
|
+
out[2] = 0;
|
|
3843
|
+
out[3] = 0;
|
|
3844
|
+
out[4] = 0;
|
|
3845
|
+
out[5] = v[1];
|
|
3846
|
+
out[6] = 0;
|
|
3847
|
+
out[7] = 0;
|
|
3848
|
+
out[8] = 0;
|
|
3849
|
+
out[9] = 0;
|
|
3850
|
+
out[10] = v[2];
|
|
3851
|
+
out[11] = 0;
|
|
3852
|
+
out[12] = 0;
|
|
3853
|
+
out[13] = 0;
|
|
3854
|
+
out[14] = 0;
|
|
3855
|
+
out[15] = 1;
|
|
3856
|
+
return out;
|
|
3857
|
+
}
|
|
3653
3858
|
/**
|
|
3654
3859
|
* 3 Dimensional Vector
|
|
3655
3860
|
* @module vec3
|
|
@@ -4262,8 +4467,10 @@
|
|
|
4262
4467
|
this.renderQueue = [];
|
|
4263
4468
|
this.restoreStack = [];
|
|
4264
4469
|
this.clearFullScreen = false;
|
|
4265
|
-
this.
|
|
4470
|
+
this.vpMatrix = create$3();
|
|
4471
|
+
this.dprMatrix = create$3();
|
|
4266
4472
|
this.tmpMat4 = create$3();
|
|
4473
|
+
this.tmpVec3 = create$1$1();
|
|
4267
4474
|
}
|
|
4268
4475
|
|
|
4269
4476
|
var _proto = CanvasRendererPlugin.prototype;
|
|
@@ -4295,7 +4502,7 @@
|
|
|
4295
4502
|
};
|
|
4296
4503
|
|
|
4297
4504
|
renderingService.hooks.init.tapPromise(CanvasRendererPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee() {
|
|
4298
|
-
var _this$canvasConfig, width, height, context;
|
|
4505
|
+
var dpr, _this$canvasConfig, width, height, context;
|
|
4299
4506
|
|
|
4300
4507
|
return _regeneratorRuntime$3().wrap(function _callee$(_context) {
|
|
4301
4508
|
while (1) {
|
|
@@ -4306,12 +4513,15 @@
|
|
|
4306
4513
|
_this.renderingContext.root.addEventListener(g.ElementEvent.CULLED, handleCulled); // clear fullscreen
|
|
4307
4514
|
|
|
4308
4515
|
|
|
4516
|
+
dpr = _this.contextService.getDPR();
|
|
4309
4517
|
_this$canvasConfig = _this.canvasConfig, width = _this$canvasConfig.width, height = _this$canvasConfig.height;
|
|
4310
4518
|
context = _this.contextService.getContext();
|
|
4311
4519
|
|
|
4312
|
-
_this.clearRect(context, 0, 0, width, height);
|
|
4520
|
+
_this.clearRect(context, 0, 0, width * dpr, height * dpr);
|
|
4313
4521
|
|
|
4314
|
-
|
|
4522
|
+
fromScaling(_this.dprMatrix, fromValues$1(dpr, dpr, 1));
|
|
4523
|
+
|
|
4524
|
+
case 7:
|
|
4315
4525
|
case "end":
|
|
4316
4526
|
return _context.stop();
|
|
4317
4527
|
}
|
|
@@ -4326,34 +4536,43 @@
|
|
|
4326
4536
|
renderingService.hooks.beginFrame.tap(CanvasRendererPlugin_1.tag, function () {
|
|
4327
4537
|
var context = _this.contextService.getContext();
|
|
4328
4538
|
|
|
4539
|
+
var dpr = _this.contextService.getDPR();
|
|
4540
|
+
|
|
4329
4541
|
var _this$canvasConfig2 = _this.canvasConfig,
|
|
4330
4542
|
width = _this$canvasConfig2.width,
|
|
4331
|
-
height = _this$canvasConfig2.height; //
|
|
4332
|
-
// 1. dirty rectangle rendering disabled
|
|
4333
|
-
// 2. camera changed
|
|
4543
|
+
height = _this$canvasConfig2.height; // some heuristic conditions such as 80% object changed
|
|
4334
4544
|
|
|
4335
|
-
|
|
4545
|
+
var _renderingService$get = renderingService.getStats(),
|
|
4546
|
+
total = _renderingService$get.total,
|
|
4547
|
+
rendered = _renderingService$get.rendered;
|
|
4336
4548
|
|
|
4337
|
-
|
|
4338
|
-
|
|
4549
|
+
var ratio = rendered / total;
|
|
4550
|
+
_this.clearFullScreen = renderingService.disableDirtyRectangleRendering() || rendered > 100 && ratio > 0.8;
|
|
4339
4551
|
|
|
4552
|
+
if (context) {
|
|
4340
4553
|
if (_this.clearFullScreen) {
|
|
4341
|
-
|
|
4342
|
-
} // account for camera's world matrix
|
|
4343
|
-
|
|
4554
|
+
context.resetTransform();
|
|
4344
4555
|
|
|
4345
|
-
|
|
4556
|
+
_this.clearRect(context, 0, 0, width * dpr, height * dpr);
|
|
4557
|
+
}
|
|
4346
4558
|
}
|
|
4347
4559
|
}); // render at the end of frame
|
|
4348
4560
|
|
|
4349
4561
|
renderingService.hooks.endFrame.tap(CanvasRendererPlugin_1.tag, function () {
|
|
4350
|
-
var context = _this.contextService.getContext();
|
|
4562
|
+
var context = _this.contextService.getContext(); // clear & clip dirty rectangle
|
|
4563
|
+
|
|
4351
4564
|
|
|
4352
|
-
|
|
4565
|
+
multiply$1(_this.vpMatrix, _this.dprMatrix, _this.camera.getOrthoMatrix());
|
|
4566
|
+
|
|
4567
|
+
if (_this.clearFullScreen) {
|
|
4568
|
+
_this.renderingContext.root.forEach(function (object) {
|
|
4569
|
+
if (object.isVisible() && !object.isCulled()) {
|
|
4570
|
+
_this.renderDisplayObject(object, renderingService);
|
|
4571
|
+
}
|
|
4572
|
+
});
|
|
4573
|
+
} else {
|
|
4353
4574
|
// merge removed AABB
|
|
4354
|
-
var dirtyRenderBounds = _this.safeMergeAABB.apply(_this, [_this.mergeDirtyAABBs(
|
|
4355
|
-
// this.renderQueue.filter((o) => o.nodeName !== Shape.GROUP)),
|
|
4356
|
-
_this.renderQueue)].concat(_this.removedRBushNodeAABBs.map(function (_ref2) {
|
|
4575
|
+
var dirtyRenderBounds = _this.safeMergeAABB.apply(_this, [_this.mergeDirtyAABBs(_this.renderQueue)].concat(_this.removedRBushNodeAABBs.map(function (_ref2) {
|
|
4357
4576
|
var minX = _ref2.minX,
|
|
4358
4577
|
minY = _ref2.minY,
|
|
4359
4578
|
maxX = _ref2.maxX,
|
|
@@ -4368,14 +4587,17 @@
|
|
|
4368
4587
|
if (g.AABB.isEmpty(dirtyRenderBounds)) {
|
|
4369
4588
|
_this.renderQueue = [];
|
|
4370
4589
|
return;
|
|
4371
|
-
}
|
|
4372
|
-
|
|
4590
|
+
}
|
|
4373
4591
|
|
|
4374
4592
|
var _this$convertAABB2Rec = _this.convertAABB2Rect(dirtyRenderBounds),
|
|
4375
4593
|
x = _this$convertAABB2Rec.x,
|
|
4376
4594
|
y = _this$convertAABB2Rec.y,
|
|
4377
4595
|
width = _this$convertAABB2Rec.width,
|
|
4378
|
-
height = _this$convertAABB2Rec.height;
|
|
4596
|
+
height = _this$convertAABB2Rec.height; // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
4597
|
+
|
|
4598
|
+
|
|
4599
|
+
context.setTransform(_this.vpMatrix[0], _this.vpMatrix[1], _this.vpMatrix[4], _this.vpMatrix[5], _this.vpMatrix[12], _this.vpMatrix[13]);
|
|
4600
|
+
context.save();
|
|
4379
4601
|
|
|
4380
4602
|
_this.clearRect(context, x, y, width, height);
|
|
4381
4603
|
|
|
@@ -4402,7 +4624,8 @@
|
|
|
4402
4624
|
if (object && object.isVisible() && !object.isCulled()) {
|
|
4403
4625
|
_this.renderDisplayObject(object, renderingService);
|
|
4404
4626
|
}
|
|
4405
|
-
});
|
|
4627
|
+
});
|
|
4628
|
+
context.restore(); // save dirty AABBs in last frame
|
|
4406
4629
|
|
|
4407
4630
|
_this.renderQueue.forEach(function (object) {
|
|
4408
4631
|
_this.saveDirtyAABB(object);
|
|
@@ -4412,22 +4635,17 @@
|
|
|
4412
4635
|
_this.renderQueue = [];
|
|
4413
4636
|
} // pop restore stack, eg. root -> parent -> child
|
|
4414
4637
|
|
|
4415
|
-
|
|
4638
|
+
|
|
4639
|
+
_this.restoreStack.forEach(function () {
|
|
4416
4640
|
context.restore();
|
|
4417
4641
|
}); // clear restore stack
|
|
4418
4642
|
|
|
4419
4643
|
|
|
4420
4644
|
_this.restoreStack = [];
|
|
4421
4645
|
_this.clearFullScreen = false;
|
|
4422
|
-
context.restore();
|
|
4423
4646
|
});
|
|
4424
4647
|
renderingService.hooks.render.tap(CanvasRendererPlugin_1.tag, function (object) {
|
|
4425
|
-
if (_this.clearFullScreen) {
|
|
4426
|
-
if (object.isVisible() && !object.isCulled()) {
|
|
4427
|
-
// render immediately
|
|
4428
|
-
_this.renderDisplayObject(object, renderingService);
|
|
4429
|
-
}
|
|
4430
|
-
} else {
|
|
4648
|
+
if (!_this.clearFullScreen) {
|
|
4431
4649
|
// render at the end of frame
|
|
4432
4650
|
_this.renderQueue.push(object);
|
|
4433
4651
|
}
|
|
@@ -4461,21 +4679,18 @@
|
|
|
4461
4679
|
this.styleRendererFactoryCache[nodeName] = this.styleRendererFactory(nodeName);
|
|
4462
4680
|
}
|
|
4463
4681
|
|
|
4464
|
-
var styleRenderer = this.styleRendererFactoryCache[nodeName];
|
|
4682
|
+
var styleRenderer = this.styleRendererFactoryCache[nodeName];
|
|
4465
4683
|
|
|
4466
|
-
|
|
4684
|
+
if (this.pathGeneratorFactoryCache[nodeName] === undefined) {
|
|
4685
|
+
this.pathGeneratorFactoryCache[nodeName] = this.pathGeneratorFactory(nodeName);
|
|
4686
|
+
}
|
|
4467
4687
|
|
|
4468
|
-
this.
|
|
4688
|
+
var generatePath = this.pathGeneratorFactoryCache[nodeName]; // clip path
|
|
4469
4689
|
|
|
4470
|
-
var clipPathShape = object.
|
|
4690
|
+
var clipPathShape = object.parsedStyle.clipPath;
|
|
4471
4691
|
|
|
4472
4692
|
if (clipPathShape) {
|
|
4473
|
-
context.
|
|
4474
|
-
// (object.parentElement as DisplayObject)?.getWorldTransform() || mat4.identity(this.tmpMat4);
|
|
4475
|
-
// mat4.multiply(this.tmpMat4, parentTransform, clipPathShape.getLocalTransform());
|
|
4476
|
-
// apply clip shape's RTS
|
|
4477
|
-
|
|
4478
|
-
this.applyTransform(context, clipPathShape.getLocalTransform()); // generate path in local space
|
|
4693
|
+
this.applyWorldTransform(context, clipPathShape, object.getWorldTransform()); // generate path in local space
|
|
4479
4694
|
|
|
4480
4695
|
if (this.pathGeneratorFactoryCache[clipPathShape.nodeName] === undefined) {
|
|
4481
4696
|
this.pathGeneratorFactoryCache[clipPathShape.nodeName] = this.pathGeneratorFactory(clipPathShape.nodeName);
|
|
@@ -4484,31 +4699,26 @@
|
|
|
4484
4699
|
var _generatePath = this.pathGeneratorFactoryCache[clipPathShape.nodeName];
|
|
4485
4700
|
|
|
4486
4701
|
if (_generatePath) {
|
|
4487
|
-
|
|
4702
|
+
context.save(); // save clip
|
|
4703
|
+
|
|
4704
|
+
this.restoreStack.push(object);
|
|
4488
4705
|
context.beginPath();
|
|
4489
4706
|
|
|
4490
4707
|
_generatePath(context, clipPathShape.parsedStyle);
|
|
4491
4708
|
|
|
4492
4709
|
context.closePath();
|
|
4710
|
+
context.clip();
|
|
4493
4711
|
}
|
|
4494
|
-
|
|
4495
|
-
context.restore();
|
|
4496
|
-
context.clip();
|
|
4497
4712
|
} // fill & stroke
|
|
4498
4713
|
|
|
4499
4714
|
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
this.useAnchor(context, object); // generate path in local space
|
|
4715
|
+
if (styleRenderer) {
|
|
4716
|
+
this.applyWorldTransform(context, object);
|
|
4717
|
+
context.save(); // apply attributes to context
|
|
4505
4718
|
|
|
4506
|
-
|
|
4507
|
-
this.pathGeneratorFactoryCache[object.nodeName] = this.pathGeneratorFactory(object.nodeName);
|
|
4719
|
+
this.applyAttributesToContext(context, object);
|
|
4508
4720
|
}
|
|
4509
4721
|
|
|
4510
|
-
var generatePath = this.pathGeneratorFactoryCache[object.nodeName];
|
|
4511
|
-
|
|
4512
4722
|
if (generatePath) {
|
|
4513
4723
|
context.beginPath();
|
|
4514
4724
|
generatePath(context, object.parsedStyle);
|
|
@@ -4520,23 +4730,13 @@
|
|
|
4520
4730
|
|
|
4521
4731
|
|
|
4522
4732
|
if (styleRenderer) {
|
|
4523
|
-
styleRenderer.render(context, object.parsedStyle, object, renderingService);
|
|
4524
|
-
} // restore applied attributes, eg. shadowBlur shadowColor...
|
|
4733
|
+
styleRenderer.render(context, object.parsedStyle, object, renderingService); // restore applied attributes, eg. shadowBlur shadowColor...
|
|
4525
4734
|
|
|
4735
|
+
context.restore();
|
|
4736
|
+
} // finish rendering, clear dirty flag
|
|
4526
4737
|
|
|
4527
|
-
context.restore(); // finish rendering, clear dirty flag
|
|
4528
4738
|
|
|
4529
4739
|
object.renderable.dirty = false;
|
|
4530
|
-
this.restoreStack.push(object);
|
|
4531
|
-
};
|
|
4532
|
-
|
|
4533
|
-
_proto.shouldClearFullScreen = function shouldClearFullScreen() {
|
|
4534
|
-
var renderer = this.canvasConfig.renderer;
|
|
4535
|
-
|
|
4536
|
-
var _renderer$getConfig = renderer.getConfig(),
|
|
4537
|
-
enableDirtyRectangleRendering = _renderer$getConfig.enableDirtyRectangleRendering;
|
|
4538
|
-
|
|
4539
|
-
return !enableDirtyRectangleRendering || this.renderingContext.renderReasons.has(g.RenderReason.CAMERA_CHANGED);
|
|
4540
4740
|
};
|
|
4541
4741
|
|
|
4542
4742
|
_proto.convertAABB2Rect = function convertAABB2Rect(aabb) {
|
|
@@ -4616,12 +4816,11 @@
|
|
|
4616
4816
|
// save last dirty aabb
|
|
4617
4817
|
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
4618
4818
|
}
|
|
4619
|
-
}
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
};
|
|
4819
|
+
}
|
|
4820
|
+
/**
|
|
4821
|
+
* TODO: batch the same global attributes
|
|
4822
|
+
*/
|
|
4823
|
+
;
|
|
4625
4824
|
|
|
4626
4825
|
_proto.applyAttributesToContext = function applyAttributesToContext(context, object) {
|
|
4627
4826
|
var _object$parsedStyle = object.parsedStyle,
|
|
@@ -4664,7 +4863,7 @@
|
|
|
4664
4863
|
context.filter = object.style.filter;
|
|
4665
4864
|
}
|
|
4666
4865
|
|
|
4667
|
-
var hasShadow = !g.isNil(shadowColor) && shadowBlur.value > 0;
|
|
4866
|
+
var hasShadow = !g.isNil(shadowColor) && (shadowBlur === null || shadowBlur === void 0 ? void 0 : shadowBlur.value) > 0;
|
|
4668
4867
|
|
|
4669
4868
|
if (hasShadow) {
|
|
4670
4869
|
context.shadowColor = shadowColor.toString();
|
|
@@ -4674,21 +4873,45 @@
|
|
|
4674
4873
|
}
|
|
4675
4874
|
};
|
|
4676
4875
|
|
|
4677
|
-
_proto.
|
|
4876
|
+
_proto.applyWorldTransform = function applyWorldTransform(context, object, matrix) {
|
|
4877
|
+
var tx = 0;
|
|
4878
|
+
var ty = 0;
|
|
4879
|
+
|
|
4678
4880
|
var _ref4 = object.parsedStyle || {},
|
|
4679
4881
|
anchor = _ref4.anchor;
|
|
4680
4882
|
|
|
4681
|
-
var
|
|
4682
|
-
var
|
|
4683
|
-
var height = bounds && bounds.halfExtents[1] * 2 || 0;
|
|
4684
|
-
var tx = -((anchor && anchor[0].value || 0) * width);
|
|
4685
|
-
var ty = -((anchor && anchor[1].value || 0) * height);
|
|
4883
|
+
var anchorX = anchor && anchor[0].value || 0;
|
|
4884
|
+
var anchorY = anchor && anchor[1].value || 0;
|
|
4686
4885
|
|
|
4687
|
-
if (
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4886
|
+
if (anchorX !== 0 || anchorY !== 0) {
|
|
4887
|
+
var bounds = object.getGeometryBounds();
|
|
4888
|
+
var width = bounds && bounds.halfExtents[0] * 2 || 0;
|
|
4889
|
+
var height = bounds && bounds.halfExtents[1] * 2 || 0;
|
|
4890
|
+
tx = -(anchorX * width);
|
|
4891
|
+
ty = -(anchorY * height);
|
|
4892
|
+
} // apply clip shape's RTS
|
|
4893
|
+
|
|
4894
|
+
|
|
4895
|
+
if (matrix) {
|
|
4896
|
+
copy(this.tmpMat4, object.getLocalTransform());
|
|
4897
|
+
this.tmpVec3[0] = tx;
|
|
4898
|
+
this.tmpVec3[1] = ty;
|
|
4899
|
+
this.tmpVec3[2] = 0;
|
|
4900
|
+
translate(this.tmpMat4, this.tmpMat4, this.tmpVec3);
|
|
4901
|
+
multiply$1(this.tmpMat4, matrix, this.tmpMat4);
|
|
4902
|
+
multiply$1(this.tmpMat4, this.vpMatrix, this.tmpMat4);
|
|
4903
|
+
} else {
|
|
4904
|
+
// apply RTS transformation in world space
|
|
4905
|
+
copy(this.tmpMat4, object.getWorldTransform());
|
|
4906
|
+
this.tmpVec3[0] = tx;
|
|
4907
|
+
this.tmpVec3[1] = ty;
|
|
4908
|
+
this.tmpVec3[2] = 0;
|
|
4909
|
+
translate(this.tmpMat4, this.tmpMat4, this.tmpVec3);
|
|
4910
|
+
multiply$1(this.tmpMat4, this.vpMatrix, this.tmpMat4);
|
|
4911
|
+
} // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
|
|
4912
|
+
|
|
4913
|
+
|
|
4914
|
+
context.setTransform(this.tmpMat4[0], this.tmpMat4[1], this.tmpMat4[4], this.tmpMat4[5], this.tmpMat4[12], this.tmpMat4[13]);
|
|
4692
4915
|
};
|
|
4693
4916
|
|
|
4694
4917
|
_proto.safeMergeAABB = function safeMergeAABB() {
|
|
@@ -5776,6 +5999,11 @@
|
|
|
5776
5999
|
_proto.apply = function apply(renderingService) {
|
|
5777
6000
|
var _this = this;
|
|
5778
6001
|
|
|
6002
|
+
var setTransform = function setTransform(object, $el) {
|
|
6003
|
+
var worldTransform = object.getWorldTransform();
|
|
6004
|
+
$el.style.transform = "matrix(" + [worldTransform[0], worldTransform[1], worldTransform[4], worldTransform[5], worldTransform[12], worldTransform[13]].join(',') + ")";
|
|
6005
|
+
};
|
|
6006
|
+
|
|
5779
6007
|
var handleMounted = function handleMounted(e) {
|
|
5780
6008
|
var object = e.target;
|
|
5781
6009
|
|
|
@@ -5790,6 +6018,7 @@
|
|
|
5790
6018
|
Object.keys(object.attributes).forEach(function (name) {
|
|
5791
6019
|
_this.updateAttribute(name, object);
|
|
5792
6020
|
});
|
|
6021
|
+
setTransform(object, $el);
|
|
5793
6022
|
}
|
|
5794
6023
|
};
|
|
5795
6024
|
|
|
@@ -5821,6 +6050,16 @@
|
|
|
5821
6050
|
}
|
|
5822
6051
|
};
|
|
5823
6052
|
|
|
6053
|
+
var handleBoundsChanged = function handleBoundsChanged(e) {
|
|
6054
|
+
var object = e.target;
|
|
6055
|
+
|
|
6056
|
+
if (object.nodeName === g.Shape.HTML) {
|
|
6057
|
+
var $el = _this.getOrCreateEl(object);
|
|
6058
|
+
|
|
6059
|
+
setTransform(object, $el);
|
|
6060
|
+
}
|
|
6061
|
+
};
|
|
6062
|
+
|
|
5824
6063
|
renderingService.hooks.init.tapPromise(HTMLRenderingPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$5( /*#__PURE__*/_regeneratorRuntime$5().mark(function _callee() {
|
|
5825
6064
|
return _regeneratorRuntime$5().wrap(function _callee$(_context) {
|
|
5826
6065
|
while (1) {
|
|
@@ -5832,7 +6071,9 @@
|
|
|
5832
6071
|
|
|
5833
6072
|
_this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
5834
6073
|
|
|
5835
|
-
|
|
6074
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
6075
|
+
|
|
6076
|
+
case 4:
|
|
5836
6077
|
case "end":
|
|
5837
6078
|
return _context.stop();
|
|
5838
6079
|
}
|
|
@@ -5845,6 +6086,8 @@
|
|
|
5845
6086
|
_this.renderingContext.root.removeEventListener(g.ElementEvent.UNMOUNTED, handleUnmounted);
|
|
5846
6087
|
|
|
5847
6088
|
_this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
6089
|
+
|
|
6090
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
5848
6091
|
});
|
|
5849
6092
|
};
|
|
5850
6093
|
|
|
@@ -5905,12 +6148,9 @@
|
|
|
5905
6148
|
|
|
5906
6149
|
break;
|
|
5907
6150
|
|
|
5908
|
-
case 'modelMatrix':
|
|
5909
6151
|
case 'transformOrigin':
|
|
5910
6152
|
var transformOrigin = object.parsedStyle.transformOrigin;
|
|
5911
6153
|
$el.style['transform-origin'] = transformOrigin[0].value + " " + transformOrigin[1].value;
|
|
5912
|
-
var worldTransform = object.getWorldTransform();
|
|
5913
|
-
$el.style.transform = "matrix(" + [worldTransform[0], worldTransform[1], worldTransform[4], worldTransform[5], worldTransform[12], worldTransform[13]].join(',') + ")";
|
|
5914
6154
|
break;
|
|
5915
6155
|
|
|
5916
6156
|
case 'width':
|
|
@@ -6135,11 +6375,10 @@
|
|
|
6135
6375
|
this.$canvas.width = this.dpr * width;
|
|
6136
6376
|
this.$canvas.height = this.dpr * height; // set CSS style width & height
|
|
6137
6377
|
|
|
6138
|
-
g.setDOMSize(this.$canvas, width, height);
|
|
6139
|
-
|
|
6378
|
+
g.setDOMSize(this.$canvas, width, height); // const dpr = this.getDPR();
|
|
6379
|
+
// scale all drawing operations by the dpr
|
|
6140
6380
|
// @see https://www.html5rocks.com/en/tutorials/canvas/hidpi/
|
|
6141
|
-
|
|
6142
|
-
this.context.scale(dpr, dpr);
|
|
6381
|
+
// this.context.scale(dpr, dpr);
|
|
6143
6382
|
}
|
|
6144
6383
|
};
|
|
6145
6384
|
|
package/dist/index.umd.min.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/g")):"function"==typeof define&&define.amd?define(["exports","@antv/g"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.ImageExporter={}),t.window.G)}(this,(function(t,e){"use strict";function r(){
|
|
2
2
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
3
|
-
r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=Object.create((e&&e.prototype instanceof f?e:f).prototype),i=new P(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return k()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var h={};function f(){}function v(){}function d(){}var p={};u(p,i,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(C([])));g&&g!==e&&n.call(g,i)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function r(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var s=u.arg,h=s.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(h).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=l(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function C(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:k}}function k(){return{value:void 0,done:!0}}return v.prototype=d,u(m,"constructor",d),u(d,"constructor",v),v.displayName=u(d,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,u(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},w(x.prototype),u(x.prototype,a,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(m),u(m,c,"Generator"),u(m,i,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=C,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(this.prev>=i.tryLoc){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return r(i.catchLoc,!0);if(i.finallyLoc>this.prev)return r(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(this.prev>=o.tryLoc&&n.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:C(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function n(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function o(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function c(t){n(a,o,i,c,u,"next",t)}function u(t){n(a,o,i,c,u,"throw",t)}c(void 0)}))}}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}var a=e.Syringe.defineToken("PathGeneratorFactory"),c=e.Syringe.defineToken("PathGenerator");function u(t,e){var r=e.r;t.arc(r.value,r.value,r.value,0,2*Math.PI,!1)}function s(t,e){var r=e.rx.value,n=e.ry.value;if(t.ellipse)t.ellipse(r,n,r,n,0,0,2*Math.PI,!1);else{var o=r>n?r:n,i=r>n?1:r/n,a=r>n?n/r:1;t.save(),t.scale(i,a),t.arc(0,0,o,0,2*Math.PI)}}function l(t,e){var r=e.x2,n=e.y2,o=e.defX,i=void 0===o?0:o,a=e.defY,c=void 0===a?0:a;t.moveTo(e.x1.value-i,e.y1.value-c),t.lineTo(r.value-i,n.value-c)}function h(t,e){var r=e.defX,n=void 0===r?0:r,o=e.defY,i=void 0===o?0:o,a=e.path,c=a.zCommandIndexes,u=[].concat(a.curve);c.forEach((function(t,e){u.splice(t+e,1,["Z"])}));for(var s=0;u.length>s;s++){var l=u[s];switch(l[0]){case"M":t.moveTo(l[1]-n,l[2]-i);break;case"C":t.bezierCurveTo(l[1]-n,l[2]-i,l[3]-n,l[4]-i,l[5]-n,l[6]-i);break;case"Z":t.closePath()}}}function f(t,e){var r=e.defX,n=void 0===r?0:r,o=e.defY,i=void 0===o?0:o,a=e.points.points,c=a.length,u=a[c-1][0]-n,s=a[c-1][1]-i;t.moveTo(a[0][0]-n,a[0][1]-i);for(var l=0;c-1>l;l++){var h=a[l];t.lineTo(h[0]-n,h[1]-i)}t.lineTo(u,s)}function v(t,e){var r=e.defX,n=void 0===r?0:r,o=e.defY,i=void 0===o?0:o,a=e.points.points,c=a.length,u=a[c-1][0]-n,s=a[c-1][1]-i;t.moveTo(a[0][0]-n,a[0][1]-i);for(var l=0;c-1>l;l++){var h=a[l];t.lineTo(h[0]-n,h[1]-i)}t.lineTo(u,s)}function d(t,r){var n=r.radius,o=r.width,i=r.height,a=o.value,c=i.value;if(n&&n.some((function(t){return 0!==t.value}))){var u=o.value>0?1:-1,s=i.value>0?1:-1,l=u+s===0,h=n.map((function(t){return e.clamp(t.value,0,Math.min(Math.abs(a)/2,Math.abs(c)/2))})),f=h[0],v=h[1],d=h[2],p=h[3];t.moveTo(u*f,0),t.lineTo(a-u*v,0),0!==v&&t.arc(a-u*v,s*v,v,-s*Math.PI/2,u>0?0:Math.PI,l),t.lineTo(a,c-s*d),0!==d&&t.arc(a-u*d,c-s*d,d,u>0?0:Math.PI,s>0?Math.PI/2:1.5*Math.PI,l),t.lineTo(u*p,c),0!==p&&t.arc(u*p,c-s*p,p,s>0?Math.PI/2:-Math.PI/2,u>0?Math.PI:0,l),t.lineTo(0,s*f),0!==f&&t.arc(u*f,s*f,f,u>0?Math.PI:0,s>0?1.5*Math.PI:Math.PI/2,l)}else t.rect(0,0,a,c)}var p=e.Module((function(t){t({token:{token:c,named:e.Shape.CIRCLE},useValue:u}),t({token:{token:c,named:e.Shape.ELLIPSE},useValue:s}),t({token:{token:c,named:e.Shape.RECT},useValue:d}),t({token:{token:c,named:e.Shape.LINE},useValue:l}),t({token:{token:c,named:e.Shape.POLYLINE},useValue:v}),t({token:{token:c,named:e.Shape.POLYGON},useValue:f}),t({token:{token:c,named:e.Shape.PATH},useValue:h}),t({token:a,useFactory:function(t){return function(e){return t.container.isBoundNamed(c,e)?t.container.getNamed(c,e):null}}})})),y=function(){function t(){this.name="canvas-path-generator"}var e=t.prototype;return e.init=function(t){t.load(p,!0)},e.destroy=function(t){t.unload(p)},t}(),g=Object.freeze({__proto__:null,PathGenerator:c,PathGeneratorFactory:a,Plugin:y});function m(t,e,r,n){var o,i=arguments.length,a=3>i?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,n);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(a=(3>i?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a}function w(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function x(){
|
|
3
|
+
r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=Object.create((e&&e.prototype instanceof f?e:f).prototype),i=new P(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return S()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var h={};function f(){}function v(){}function d(){}var p={};u(p,i,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(k([])));g&&g!==e&&n.call(g,i)&&(p=g);var m=d.prototype=f.prototype=Object.create(p);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function r(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var s=u.arg,h=s.value;return h&&"object"==typeof h&&n.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(h).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=l(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function k(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:S}}function S(){return{value:void 0,done:!0}}return v.prototype=d,u(m,"constructor",d),u(d,"constructor",v),v.displayName=u(d,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,u(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},w(x.prototype),u(x.prototype,a,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(s(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(m),u(m,c,"Generator"),u(m,i,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(this.prev>=i.tryLoc){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return r(i.catchLoc,!0);if(i.finallyLoc>this.prev)return r(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(this.prev>=o.tryLoc&&n.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function n(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function o(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function c(t){n(a,o,i,c,u,"next",t)}function u(t){n(a,o,i,c,u,"throw",t)}c(void 0)}))}}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}var a=e.Syringe.defineToken("PathGeneratorFactory"),c=e.Syringe.defineToken("PathGenerator");function u(t,e){var r=e.r;t.arc(r.value,r.value,r.value,0,2*Math.PI,!1)}function s(t,e){var r=e.rx.value,n=e.ry.value;if(t.ellipse)t.ellipse(r,n,r,n,0,0,2*Math.PI,!1);else{var o=r>n?r:n,i=r>n?1:r/n,a=r>n?n/r:1;t.save(),t.scale(i,a),t.arc(0,0,o,0,2*Math.PI)}}function l(t,e){var r=e.x2,n=e.y2,o=e.defX,i=void 0===o?0:o,a=e.defY,c=void 0===a?0:a;t.moveTo(e.x1.value-i,e.y1.value-c),t.lineTo(r.value-i,n.value-c)}function h(t,e){var r=e.defX,n=void 0===r?0:r,o=e.defY,i=void 0===o?0:o,a=e.path,c=a.zCommandIndexes,u=[].concat(a.curve);c.forEach((function(t,e){u.splice(t+e,1,["Z"])}));for(var s=0;u.length>s;s++){var l=u[s];switch(l[0]){case"M":t.moveTo(l[1]-n,l[2]-i);break;case"C":t.bezierCurveTo(l[1]-n,l[2]-i,l[3]-n,l[4]-i,l[5]-n,l[6]-i);break;case"Z":t.closePath()}}}function f(t,e){var r=e.defX,n=void 0===r?0:r,o=e.defY,i=void 0===o?0:o,a=e.points.points,c=a.length,u=a[c-1][0]-n,s=a[c-1][1]-i;t.moveTo(a[0][0]-n,a[0][1]-i);for(var l=0;c-1>l;l++){var h=a[l];t.lineTo(h[0]-n,h[1]-i)}t.lineTo(u,s)}function v(t,e){var r=e.defX,n=void 0===r?0:r,o=e.defY,i=void 0===o?0:o,a=e.points.points,c=a.length,u=a[c-1][0]-n,s=a[c-1][1]-i;t.moveTo(a[0][0]-n,a[0][1]-i);for(var l=0;c-1>l;l++){var h=a[l];t.lineTo(h[0]-n,h[1]-i)}t.lineTo(u,s)}function d(t,r){var n=r.radius,o=r.width,i=r.height,a=o.value,c=i.value;if(n&&n.some((function(t){return 0!==t.value}))){var u=o.value>0?1:-1,s=i.value>0?1:-1,l=u+s===0,h=n.map((function(t){return e.clamp(t.value,0,Math.min(Math.abs(a)/2,Math.abs(c)/2))})),f=h[0],v=h[1],d=h[2],p=h[3];t.moveTo(u*f,0),t.lineTo(a-u*v,0),0!==v&&t.arc(a-u*v,s*v,v,-s*Math.PI/2,u>0?0:Math.PI,l),t.lineTo(a,c-s*d),0!==d&&t.arc(a-u*d,c-s*d,d,u>0?0:Math.PI,s>0?Math.PI/2:1.5*Math.PI,l),t.lineTo(u*p,c),0!==p&&t.arc(u*p,c-s*p,p,s>0?Math.PI/2:-Math.PI/2,u>0?Math.PI:0,l),t.lineTo(0,s*f),0!==f&&t.arc(u*f,s*f,f,u>0?Math.PI:0,s>0?1.5*Math.PI:Math.PI/2,l)}else t.rect(0,0,a,c)}var p=e.Module((function(t){t({token:{token:c,named:e.Shape.CIRCLE},useValue:u}),t({token:{token:c,named:e.Shape.ELLIPSE},useValue:s}),t({token:{token:c,named:e.Shape.RECT},useValue:d}),t({token:{token:c,named:e.Shape.LINE},useValue:l}),t({token:{token:c,named:e.Shape.POLYLINE},useValue:v}),t({token:{token:c,named:e.Shape.POLYGON},useValue:f}),t({token:{token:c,named:e.Shape.PATH},useValue:h}),t({token:a,useFactory:function(t){return function(e){return t.container.isBoundNamed(c,e)?t.container.getNamed(c,e):null}}})})),y=function(){function t(){this.name="canvas-path-generator"}var e=t.prototype;return e.init=function(t){t.load(p,!0)},e.destroy=function(t){t.unload(p)},t}(),g=Object.freeze({__proto__:null,PathGenerator:c,PathGeneratorFactory:a,Plugin:y});function m(t,e,r,n){var o,i=arguments.length,a=3>i?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,n);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(a=(3>i?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a}function w(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function x(){
|
|
4
4
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
5
|
-
x=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),i=new P(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return k()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function h(){}function f(){}function v(){}var d={};c(d,o,(function(){return this}));var p=Object.getPrototypeOf,y=p&&p(p(C([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=v.prototype=h.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function C(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:k}}function k(){return{value:void 0,done:!0}}return f.prototype=v,c(g,"constructor",v),c(v,"constructor",f),f.displayName=c(v,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,c(t,a,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(w.prototype),c(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},m(g),c(g,a,"Generator"),c(g,o,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=C,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(this.prev>=i.tryLoc){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return n(i.catchLoc,!0);if(i.finallyLoc>this.prev)return n(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(this.prev>=o.tryLoc&&r.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:C(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var E="undefined"!=typeof Float32Array?Float32Array:Array;function L(){var t=new E(16);return E!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function P(){var t=new E(3);return E!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function C(t,e,r){var n=new E(3);return n[0]=t,n[1]=e,n[2]=r,n}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var k;k=P();!function(){var t,e=(t=new E(2),E!=Float32Array&&(t[0]=0,t[1]=0),t)}();var S,O,T=e.Syringe.defineToken("PointInPathPicker"),N=(S=function(){function t(){var t=this;this.displayObjectPool=void 0,this.canvasConfig=void 0,this.offscreenCanvas=void 0,this.rBush=void 0,this.pathGeneratorFactory=void 0,this.pathGeneratorFactoryCache={},this.pointInPathPickerFactory=void 0,this.isHit=function(r,n,o){var i,a,c,u,s,l,h,f,v,d,p,y,g,m,w,x,b,E,k,S,O,T,N,j,_,A,M,R,G,I,F,B=t.pointInPathPickerFactory(r.nodeName);if(B){var D=(i=L(),(F=(k=(c=(a=o)[0])*(f=a[5])-(u=a[1])*(h=a[4]))*(I=(g=a[10])*(E=a[15])-(m=a[11])*(b=a[14]))-(S=c*(v=a[6])-(s=a[2])*h)*(G=(y=a[9])*E-m*(x=a[13]))+(O=c*(d=a[7])-(l=a[3])*h)*(R=y*b-g*x)+(T=u*v-s*f)*(M=(p=a[8])*E-m*(w=a[12]))-(N=u*d-l*f)*(A=p*b-g*w)+(j=s*d-l*v)*(_=p*x-y*w))?(i[0]=(f*I-v*G+d*R)*(F=1/F),i[1]=(s*G-u*I-l*R)*F,i[2]=(x*j-b*N+E*T)*F,i[3]=(g*N-y*j-m*T)*F,i[4]=(v*M-h*I-d*A)*F,i[5]=(c*I-s*M+l*A)*F,i[6]=(b*O-w*j-E*S)*F,i[7]=(p*j-g*O+m*S)*F,i[8]=(h*G-f*M+d*_)*F,i[9]=(u*M-c*G-l*_)*F,i[10]=(w*N-x*O+E*k)*F,i[11]=(y*O-p*N-m*k)*F,i[12]=(f*A-h*R-v*_)*F,i[13]=(c*R-u*A+s*_)*F,i[14]=(x*S-w*T-b*k)*F,i[15]=(p*T-y*S+g*k)*F,i):null),Y=function(t,e,r){var n=e[0],o=e[1],i=e[2],a=r[3]*n+r[7]*o+r[11]*i+r[15];return t[0]=(r[0]*n+r[4]*o+r[8]*i+r[12])/(a=a||1),t[1]=(r[1]*n+r[5]*o+r[9]*i+r[13])/a,t[2]=(r[2]*n+r[6]*o+r[10]*i+r[14])/a,t}(P(),C(n[0],n[1],0),D),$=r.getGeometryBounds().halfExtents,H=r.parsedStyle.anchor;if(Y[0]+=(H&&H[0].value||0)*$[0]*2,Y[1]+=(H&&H[1].value||0)*$[1]*2,B(r,new e.Point(Y[0],Y[1]),t.isPointInPath))return!0}return!1},this.isPointInPath=function(e,r){var n=t.offscreenCanvas.getOrCreateContext(t.canvasConfig.offscreenCanvas);void 0===t.pathGeneratorFactoryCache[e.nodeName]&&(t.pathGeneratorFactoryCache[e.nodeName]=t.pathGeneratorFactory(e.nodeName));var o=t.pathGeneratorFactoryCache[e.nodeName];return o&&(n.beginPath(),o(n,e.parsedStyle),n.closePath()),n.isPointInPath(r.x,r.y)}}return t.prototype.apply=function(t){var e=this;t.hooks.pick.tapPromise(O.tag,function(){var t,r=(t=x().mark((function t(r){var n,o,i,a,c,u,s,l,h,f,v,d,p;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=r.topmost,i=C((o=r.position).x,o.y,0),a=e.rBush.search({minX:i[0],minY:i[1],maxX:i[0],maxY:i[1]}),c=a.map((function(t){return t.id})),u=[],a.forEach((function(t){var r=e.displayObjectPool.getByEntity(t.id);if(r.isVisible()&&!r.isCulled()&&r.isInteractive()){if(r.parentNode&&-1===c.indexOf(r.parentNode.entity))return;u.push(r)}})),u.sort((function(t,e){return e.sortable.renderOrder-t.sortable.renderOrder})),s=[],l=0,h=u;case 9:if(l>=h.length){t.next=25;break}if(d=(v=(f=h[l]).parsedStyle.clipPath)||f,p=f.getWorldTransform(),v&&(y=L(),g=p,m=v.getLocalTransform(),w=void 0,x=void 0,b=void 0,E=void 0,P=void 0,k=void 0,S=void 0,O=void 0,T=void 0,N=void 0,j=void 0,_=void 0,A=void 0,M=void 0,R=void 0,G=void 0,I=void 0,F=void 0,B=void 0,D=void 0,x=g[1],b=g[2],E=g[3],k=g[5],S=g[6],O=g[7],N=g[9],j=g[10],_=g[11],M=g[13],R=g[14],G=g[15],y[0]=(I=m[0])*(w=g[0])+(F=m[1])*(P=g[4])+(B=m[2])*(T=g[8])+(D=m[3])*(A=g[12]),y[1]=I*x+F*k+B*N+D*M,y[2]=I*b+F*S+B*j+D*R,y[3]=I*E+F*O+B*_+D*G,y[4]=(I=m[4])*w+(F=m[5])*P+(B=m[6])*T+(D=m[7])*A,y[5]=I*x+F*k+B*N+D*M,y[6]=I*b+F*S+B*j+D*R,y[7]=I*E+F*O+B*_+D*G,y[8]=(I=m[8])*w+(F=m[9])*P+(B=m[10])*T+(D=m[11])*A,y[9]=I*x+F*k+B*N+D*M,y[10]=I*b+F*S+B*j+D*R,y[11]=I*E+F*O+B*_+D*G,y[12]=(I=m[12])*w+(F=m[13])*P+(B=m[14])*T+(D=m[15])*A,y[13]=I*x+F*k+B*N+D*M,y[14]=I*b+F*S+B*j+D*R,y[15]=I*E+F*O+B*_+D*G,p=y),!e.isHit(d,i,p)){t.next=22;break}if(!n){t.next=21;break}return r.picked=[f],t.abrupt("return",r);case 21:s.push(f);case 22:l++,t.next=9;break;case 25:return r.picked=s,t.abrupt("return",r);case 27:case"end":return t.stop()}var y,g,m,w,x,b,E,P,k,S,O,T,N,j,_,A,M,R,G,I,F,B,D}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return r.apply(this,arguments)}}())},t}(),S.tag="CanvasPicker",O=S);function j(t,e,r,n){var o=t-r,i=e-n;return Math.sqrt(o*o+i*i)}function _(t,e){return.001>Math.abs(t-e)}function A(t,e){var r=Math.min.apply(Math,t),n=Math.min.apply(Math,e);return{x:r,y:n,width:Math.max.apply(Math,t)-r,height:Math.max.apply(Math,e)-n}}m([e.inject(e.DisplayObjectPool),w("design:type",e.DisplayObjectPool)],N.prototype,"displayObjectPool",void 0),m([e.inject(e.CanvasConfig),w("design:type",Object)],N.prototype,"canvasConfig",void 0),m([e.inject(e.OffscreenCanvasCreator),w("design:type",e.OffscreenCanvasCreator)],N.prototype,"offscreenCanvas",void 0),m([e.inject(e.RBushRoot),w("design:type",e.RBush)],N.prototype,"rBush",void 0),m([e.inject(a),w("design:type",Function)],N.prototype,"pathGeneratorFactory",void 0),m([e.inject(T),w("design:type",Function)],N.prototype,"pointInPathPickerFactory",void 0),N=O=m([e.singleton({contrib:e.RenderingPluginContribution})],N);var M=function(t,e,r,n,o){return{x:(1-o)*t+o*r,y:(1-o)*e+o*n}},R=function(t,e,r,n,o,i){var a=[r-t,n-e];if(function(t,e){return t[0]===e[0]&&t[1]===e[1]}(a,[0,0]))return Math.sqrt((o-t)*(o-t)+(i-e)*(i-e));var c=[-a[1],a[0]];return function(t,e){var r=e[0],n=e[1],o=r*r+n*n;o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o}(c,c),Math.abs(function(t,e){return t[0]*e[0]+t[1]*e[1]}([o-t,i-e],c))};function G(t,e,r,n,o){var i=1-o;return i*i*i*t+3*e*o*i*i+3*r*o*o*i+n*o*o*o}function I(t,e,r,n,o){var i=1-o;return 3*(i*i*(e-t)+2*i*o*(r-e)+o*o*(n-r))}function F(t,e,r,n){var o,i,a,c=-3*t+9*e-9*r+3*n,u=6*t-12*e+6*r,s=3*e-3*t,l=[];if(_(c,0))_(u,0)||0>(o=-s/u)||o>1||l.push(o);else{var h=u*u-4*c*s;_(h,0)?l.push(-u/(2*c)):h>0&&(i=(-u-(a=Math.sqrt(h)))/(2*c),0>(o=(-u+a)/(2*c))||o>1||l.push(o),0>i||i>1||l.push(i))}return l}function B(t,e,r,n,o,i,a,c,u){var s=G(t,r,o,a,u),l=G(e,n,i,c,u),h=M(t,e,r,n,u),f=M(r,n,o,i,u),v=M(o,i,a,c,u),d=M(h.x,h.y,f.x,f.y,u),p=M(f.x,f.y,v.x,v.y,u);return[[t,e,h.x,h.y,d.x,d.y,s,l],[s,l,p.x,p.y,v.x,v.y,a,c]]}function D(t,e,r,n,o,i,a,c,u){if(0===u)return function(t,e){for(var r=0,n=t.length,o=0;n>o;o++)r+=j(t[o],e[o],t[(o+1)%n],e[(o+1)%n]);return r/2}([t,r,o,a],[e,n,i,c]);var s=B(t,e,r,n,o,i,a,c,.5),l=[].concat(s[0],[u-1]),h=[].concat(s[1],[u-1]);return D.apply(void 0,l)+D.apply(void 0,h)}var Y={extrema:F,box:function(t,e,r,n,o,i,a,c){for(var u=[t,a],s=[e,c],l=F(t,r,o,a),h=F(e,n,i,c),f=0;l.length>f;f++)u.push(G(t,r,o,a,l[f]));for(var v=0;h.length>v;v++)s.push(G(e,n,i,c,h[v]));return A(u,s)},length:function(t,e,r,n,o,i,a,c){return D(t,e,r,n,o,i,a,c,3)},nearestPoint:function(t,e,r,n,o,i,a,c,u,s,l){return function(t,e,r,n,o,i){var a=-1,c=1/0,u=[r,n],s=20;i&&i>200&&(s=i/10);for(var l=1/s,h=l/10,f=0;s>=f;f++){var v=f*l,d=[o.apply(void 0,t.concat([v])),o.apply(void 0,e.concat([v]))],p=j(u[0],u[1],d[0],d[1]);c>p&&(a=v,c=p)}if(0===a)return{x:t[0],y:e[0]};if(1===a){var y=t.length;return{x:t[y-1],y:e[y-1]}}c=1/0;for(var g=0;32>g&&h>=1e-4;g++){var m=a-h,w=a+h,x=[o.apply(void 0,t.concat([m])),o.apply(void 0,e.concat([m]))],b=j(u[0],u[1],x[0],x[1]);if(m>=0&&c>b)a=m,c=b;else{var E=[o.apply(void 0,t.concat([w])),o.apply(void 0,e.concat([w]))],L=j(u[0],u[1],E[0],E[1]);1>=w&&c>L?(a=w,c=L):h*=.5}}return{x:o.apply(void 0,t.concat([a])),y:o.apply(void 0,e.concat([a]))}}([t,r,o,a],[e,n,i,c],u,s,G,l)},pointDistance:function(t,e,r,n,o,i,a,c,u,s,l){var h=this.nearestPoint(t,e,r,n,o,i,a,c,u,s,l);return j(h.x,h.y,u,s)},interpolationAt:G,pointAt:function(t,e,r,n,o,i,a,c,u){return{x:G(t,r,o,a,u),y:G(e,n,i,c,u)}},divide:function(t,e,r,n,o,i,a,c,u){return B(t,e,r,n,o,i,a,c,u)},tangentAngle:function(t,e,r,n,o,i,a,c,u){var s=I(t,r,o,a,u),l=I(e,n,i,c,u);return(Math.atan2(l,s)+2*Math.PI)%(2*Math.PI)}};function $(t,e,r,n){var o=t-r,i=e-n;return Math.sqrt(o*o+i*i)}function H(t,e,r,n,o,i){return!(t>o||o>t+r||e>i||i>e+n)}function W(t,e,r,n,o,i,a,c){var u=(Math.atan2(c-e,a-t)+2*Math.PI)%(2*Math.PI);if(n>u||u>o)return!1;var s={x:t+r*Math.cos(u),y:e+r*Math.sin(u)};return $(s.x,s.y,a,c)<=i/2}function U(t,e,r,n,o,i,a){var c=Math.min(t,r),u=Math.max(t,r),s=Math.min(e,n),l=Math.max(e,n),h=o/2;return!(c-h>i||i>u+h||s-h>a||a>l+h)&&R(t,e,r,n,i,a)<=o/2}function X(t,e,r,n,o){var i=t.length;if(2>i)return!1;for(var a=0;i-1>a;a++){if(U(t[a][0],t[a][1],t[a+1][0],t[a+1][1],e,r,n))return!0}if(o){var c=t[0],u=t[i-1];if(U(c[0],c[1],u[0],u[1],e,r,n))return!0}return!1}function z(t){return 1e-6>Math.abs(t)?0:0>t?-1:1}function V(t,e,r){return!((r[0]-t[0])*(e[1]-t[1])!=(e[0]-t[0])*(r[1]-t[1])||Math.min(t[0],e[0])>r[0]||r[0]>Math.max(t[0],e[0])||Math.min(t[1],e[1])>r[1]||r[1]>Math.max(t[1],e[1]))}function q(t,e,r){var n=!1,o=t.length;if(2>=o)return!1;for(var i=0;o>i;i++){var a=t[i],c=t[(i+1)%o];if(V(a,c,[e,r]))return!0;z(a[1]-r)>0!=z(c[1]-r)>0&&0>z(e-(r-a[1])*(a[0]-c[0])/(a[1]-c[1])-a[0])&&(n=!n)}return n}function Q(t,e,r){for(var n=!1,o=0;t.length>o;o++){if(n=q(t[o],e,r))break}return n}function J(t,e){var r=t.parsedStyle,n=r.fill,o=r.stroke,i=r.lineWidth,a=r.increasedLineWidthForHitTesting,c=r.clipPathTargets,u=r.r.value,s=((i&&i.value||0)+(a&&a.value||0))/2,l=$(u,u,e.x,e.y),h=n&&!n.isNone,f=o&&!o.isNone;return h&&f||!!(null==c?void 0:c.length)?u+s>=l:h?u>=l:!!f&&(l>=u-s&&u+s>=l)}function K(t,e,r,n){return t/(r*r)+e/(n*n)}function Z(t,e){var r=e.x,n=e.y,o=t.parsedStyle,i=o.fill,a=o.stroke,c=o.lineWidth,u=o.clipPathTargets,s=i&&!i.isNone,l=a&&!a.isNone,h=o.rx.value,f=o.ry.value,v=(((null==c?void 0:c.value)||0)+o.increasedLineWidthForHitTesting.value)/2,d=(r-h)*(r-h),p=(n-f)*(n-f);return s&&l||!!(null==u?void 0:u.length)?1>=K(d,p,h+v,f+v):s?1>=K(d,p,h,f):!!l&&(K(d,p,h-v,f-v)>=1&&1>=K(d,p,h+v,f+v))}function tt(t,e){var r=t.parsedStyle,n=r.defX,o=r.defY;return U(r.x1.value,r.y1.value,r.x2.value,r.y2.value,r.lineWidth.value+r.increasedLineWidthForHitTesting.value,e.x+(void 0===n?0:n),e.y+(void 0===o?0:o))}function et(t,e,r){var n=t.parsedStyle,o=n.stroke,i=n.fill,a=n.defX,c=void 0===a?0:a,u=n.defY,s=void 0===u?0:u,l=n.clipPathTargets,h=n.path,f=i&&!i.isNone,v=h.hasArc,d=h.polylines,p=h.polygons,y=!!(null==l?void 0:l.length),g=!1;return(o&&!o.isNone||y)&&(g=function(t,e,r,n,o,i,a){for(var c=!1,u=0;t.length>u;u++){var s=t[u],l=s.currentPoint,h=s.params,f=s.prePoint;switch(s.command){case"L":case"Z":c=U(f[0],f[1],l[0],l[1],e,r,n);break;case"C":c=e/2>=Y.pointDistance(f[0],f[1],h[1],h[2],h[3],h[4],h[5],h[6],r,n,o)}if(c)break}return c}(h.segments,n.lineWidth.value+n.increasedLineWidthForHitTesting.value,e.x+c,e.y+s,h.totalLength)),g||!f&&!y||(g=v?r(t,e):Q(p,e.x+c,e.y+s)||Q(d,e.x+c,e.y+s)),g}function rt(t,e){var r=t.parsedStyle,n=r.stroke,o=r.fill,i=r.points,a=r.defX,c=void 0===a?0:a,u=r.defY,s=void 0===u?0:u,l=r.clipPathTargets,h=!!(null==l?void 0:l.length),f=o&&!o.isNone,v=!1;return(n&&!n.isNone||h)&&(v=X(i.points,r.lineWidth.value+r.increasedLineWidthForHitTesting.value,e.x+c,e.y+s,!0)),v||!f&&!h||(v=q(i.points,e.x+c,e.y+s)),v}function nt(t,e){var r=t.parsedStyle,n=r.stroke,o=r.lineWidth,i=r.defX,a=r.defY,c=r.clipPathTargets;return!((!n||n.isNone)&&!(null==c?void 0:c.length)||!o)&&X(r.points.points,o.value+r.increasedLineWidthForHitTesting.value,e.x+(void 0===i?0:i),e.y+(void 0===a?0:a),!1)}function ot(t,r,n){var o=t.parsedStyle,i=o.radius,a=o.fill,c=o.stroke,u=o.lineWidth,s=o.increasedLineWidthForHitTesting,l=o.width,h=o.height,f=o.clipPathTargets,v=!!(null==f?void 0:f.length),d=a&&!a.isNone,p=c&&!c.isNone,y=i&&i.some((function(t){return 0!==t.value})),g=l.unit,m=h.unit,w=0,x=0;g!==e.UnitType.kNumber&&g!==e.UnitType.kPixels||(w=l.value),m!==e.UnitType.kNumber&&m!==e.UnitType.kPixels||(x=h.value);var b=u.value+s.value;if(y){var E=!1;return(p||v)&&(E=function(t,e,r,n,o,i,a,c){var u=o[0],s=o[1],l=o[2],h=o[3];return U(t+u,e,t+r-s,e,i,a,c)||U(t+r,e+s,t+r,e+n-l,i,a,c)||U(t+r-l,e+n,t+h,e+n,i,a,c)||U(t,e+n-h,t,e+u,i,a,c)||W(t+r-s,e+s,s,1.5*Math.PI,2*Math.PI,i,a,c)||W(t+r-l,e+n-l,l,0,.5*Math.PI,i,a,c)||W(t+h,e+n-h,h,.5*Math.PI,Math.PI,i,a,c)||W(t+u,e+u,u,Math.PI,1.5*Math.PI,i,a,c)}(0,0,w,x,i.map((function(t){return e.clamp(t.value,0,Math.min(Math.abs(w)/2,Math.abs(x)/2))})),b,r.x,r.y)),E||!d&&!v||(E=n(t,r)),E}var L=b/2;return d&&p||v?H(0-L,0-L,w+L,x+L,r.x,r.y):d?H(0,0,w,x,r.x,r.y):!!p&&function(t,e,r,n,o,i,a){var c=o/2;return H(t-c,e-c,r,o,i,a)||H(t+r-c,e-c,o,n,i,a)||H(t+c,e+n-c,r,o,i,a)||H(t-c,e+c,o,n,i,a)}(0,0,w,x,b,r.x,r.y)}var it,at,ct=e.Module((function(t){t({token:T,useFactory:function(t){return function(t){return t===e.Shape.CIRCLE?J:t===e.Shape.ELLIPSE?Z:t===e.Shape.RECT?ot:t===e.Shape.LINE?tt:t===e.Shape.POLYLINE?nt:t===e.Shape.POLYGON?rt:t===e.Shape.PATH?et:t===e.Shape.IMAGE||t===e.Shape.TEXT?function(){return!0}:null}}}),t(N)})),ut=function(){function t(){this.name="canvas-picker"}var e=t.prototype;return e.init=function(t){t.load(ct,!0)},e.destroy=function(t){t.unload(ct)},t}(),st=Object.freeze({__proto__:null,Plugin:ut}),lt=function(){function t(){this.imageCache={},this.gradientCache={},this.patternCache={},this.canvasConfig=void 0}var r=t.prototype;return r.getImageSync=function(t,e){return this.imageCache[t]||this.getOrCreateImage(t).then((function(){e&&e()})),this.imageCache[t]},r.getOrCreateImage=function(t){var r=this;if(this.imageCache[t])return Promise.resolve(this.imageCache[t]);var n=this.canvasConfig.createImage;return new Promise((function(o,i){var a;n?a=n(t):e.isBrowser&&(a=new window.Image),a&&(a.onload=function(){o(a)},a.onerror=function(t){i(t)},a.crossOrigin="Anonymous",a.src=t,r.imageCache[t]=a)}))},r.getOrCreatePatternSync=function(t,r,n){var o=this.generatePatternKey(t);if(o&&this.patternCache[o])return this.patternCache[o];var i,a=t.image,c=t.repetition,u=(i=e.isString(a)?this.getImageSync(a,n):a)&&r.createPattern(i,c);return o&&u&&(this.patternCache[o]=u),u},r.getOrCreateGradient=function(t,r){var n=this.generateGradientKey(t),o=t.type,i=t.steps,a=t.width,c=t.height,u=t.cx,s=t.cy;if(this.gradientCache[n])return this.gradientCache[n];var l=null;if(o===e.GradientType.LinearGradient){var h=e.computeLinearGradient(a,c,t.angle);l=r.createLinearGradient(h.x1,h.y1,h.x2,h.y2)}else if(o===e.GradientType.RadialGradient){var f=e.computeRadialGradient(a,c,u,s),v=f.x,d=f.y;l=r.createRadialGradient(v,d,0,v,d,f.r)}return l&&(i.forEach((function(t){var e;null===(e=l)||void 0===e||e.addColorStop(t[0],t[1])})),this.gradientCache[n]=l),this.gradientCache[n]},r.generateGradientKey=function(t){return"gradient-"+t.type+"-"+(t.angle||0)+"-"+(t.cx||0)+"-"+(t.cy||0)+"-"+t.width+"-"+t.height+"-"+t.steps.map((function(t){return t.join("")})).join("-")},r.generatePatternKey=function(t){var r=t.image,n=t.repetition;if(e.isString(r))return"pattern-"+r+"-"+n},t}();function ht(){
|
|
5
|
+
x=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),i=new P(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return S()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function h(){}function f(){}function v(){}var d={};c(d,o,(function(){return this}));var p=Object.getPrototypeOf,y=p&&p(p(k([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=v.prototype=h.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return f.prototype=v,c(g,"constructor",v),c(v,"constructor",f),f.displayName=c(v,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,c(t,a,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(w.prototype),c(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},m(g),c(g,a,"Generator"),c(g,o,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(this.prev>=i.tryLoc){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return n(i.catchLoc,!0);if(i.finallyLoc>this.prev)return n(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(this.prev>=o.tryLoc&&r.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function b(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var E="undefined"!=typeof Float32Array?Float32Array:Array;function L(){var t=new E(16);return E!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function P(){var t=new E(3);return E!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function k(t,e,r){var n=new E(3);return n[0]=t,n[1]=e,n[2]=r,n}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var S;S=P();!function(){var t,e=(t=new E(2),E!=Float32Array&&(t[0]=0,t[1]=0),t)}();var C,O,T=e.Syringe.defineToken("PointInPathPicker"),N=(C=function(){function t(){var t=this;this.displayObjectPool=void 0,this.canvasConfig=void 0,this.offscreenCanvas=void 0,this.rBush=void 0,this.pathGeneratorFactory=void 0,this.pathGeneratorFactoryCache={},this.pointInPathPickerFactory=void 0,this.isHit=function(r,n,o){var i,a,c,u,s,l,h,f,v,d,p,y,g,m,w,x,b,E,S,C,O,T,N,M,j,_,A,R,G,I,F,B=t.pointInPathPickerFactory(r.nodeName);if(B){var D=(i=L(),(F=(S=(c=(a=o)[0])*(f=a[5])-(u=a[1])*(h=a[4]))*(I=(g=a[10])*(E=a[15])-(m=a[11])*(b=a[14]))-(C=c*(v=a[6])-(s=a[2])*h)*(G=(y=a[9])*E-m*(x=a[13]))+(O=c*(d=a[7])-(l=a[3])*h)*(R=y*b-g*x)+(T=u*v-s*f)*(A=(p=a[8])*E-m*(w=a[12]))-(N=u*d-l*f)*(_=p*b-g*w)+(M=s*d-l*v)*(j=p*x-y*w))?(i[0]=(f*I-v*G+d*R)*(F=1/F),i[1]=(s*G-u*I-l*R)*F,i[2]=(x*M-b*N+E*T)*F,i[3]=(g*N-y*M-m*T)*F,i[4]=(v*A-h*I-d*_)*F,i[5]=(c*I-s*A+l*_)*F,i[6]=(b*O-w*M-E*C)*F,i[7]=(p*M-g*O+m*C)*F,i[8]=(h*G-f*A+d*j)*F,i[9]=(u*A-c*G-l*j)*F,i[10]=(w*N-x*O+E*S)*F,i[11]=(y*O-p*N-m*S)*F,i[12]=(f*_-h*R-v*j)*F,i[13]=(c*R-u*_+s*j)*F,i[14]=(x*C-w*T-b*S)*F,i[15]=(p*T-y*C+g*S)*F,i):null),Y=function(t,e,r){var n=e[0],o=e[1],i=e[2],a=r[3]*n+r[7]*o+r[11]*i+r[15];return t[0]=(r[0]*n+r[4]*o+r[8]*i+r[12])/(a=a||1),t[1]=(r[1]*n+r[5]*o+r[9]*i+r[13])/a,t[2]=(r[2]*n+r[6]*o+r[10]*i+r[14])/a,t}(P(),k(n[0],n[1],0),D),W=r.getGeometryBounds().halfExtents,$=r.parsedStyle.anchor;if(Y[0]+=($&&$[0].value||0)*W[0]*2,Y[1]+=($&&$[1].value||0)*W[1]*2,B(r,new e.Point(Y[0],Y[1]),t.isPointInPath))return!0}return!1},this.isPointInPath=function(e,r){var n=t.offscreenCanvas.getOrCreateContext(t.canvasConfig.offscreenCanvas);void 0===t.pathGeneratorFactoryCache[e.nodeName]&&(t.pathGeneratorFactoryCache[e.nodeName]=t.pathGeneratorFactory(e.nodeName));var o=t.pathGeneratorFactoryCache[e.nodeName];return o&&(n.beginPath(),o(n,e.parsedStyle),n.closePath()),n.isPointInPath(r.x,r.y)}}return t.prototype.apply=function(t){var e=this;t.hooks.pick.tapPromise(O.tag,function(){var t,r=(t=x().mark((function t(r){var n,o,i,a,c,u,s,l,h,f,v,d;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=r.topmost,i=k((o=r.position).x,o.y,0),a=e.rBush.search({minX:i[0],minY:i[1],maxX:i[0],maxY:i[1]}),c=a.map((function(t){return t.id})),u=[],a.forEach((function(t){var r=e.displayObjectPool.getByEntity(t.id);if(r.isVisible()&&!r.isCulled()&&r.isInteractive()){if(r.parentNode&&-1===c.indexOf(r.parentNode.entity))return;u.push(r)}})),u.sort((function(t,e){return e.sortable.renderOrder-t.sortable.renderOrder})),s=[],l=0,h=u;case 9:if(l>=h.length){t.next=36;break}if(v=(f=h[l]).getWorldTransform(),!e.isHit(f,i,v)){t.next=33;break}if(!(d=f.parsedStyle.clipPath)){t.next=27;break}if(p=L(),y=v,g=d.getLocalTransform(),m=void 0,w=void 0,x=void 0,b=void 0,E=void 0,P=void 0,S=void 0,C=void 0,O=void 0,T=void 0,N=void 0,M=void 0,j=void 0,_=void 0,A=void 0,R=void 0,G=void 0,I=void 0,F=void 0,B=void 0,w=y[1],x=y[2],b=y[3],P=y[5],S=y[6],C=y[7],T=y[9],N=y[10],M=y[11],_=y[13],A=y[14],R=y[15],p[0]=(G=g[0])*(m=y[0])+(I=g[1])*(E=y[4])+(F=g[2])*(O=y[8])+(B=g[3])*(j=y[12]),p[1]=G*w+I*P+F*T+B*_,p[2]=G*x+I*S+F*N+B*A,p[3]=G*b+I*C+F*M+B*R,p[4]=(G=g[4])*m+(I=g[5])*E+(F=g[6])*O+(B=g[7])*j,p[5]=G*w+I*P+F*T+B*_,p[6]=G*x+I*S+F*N+B*A,p[7]=G*b+I*C+F*M+B*R,p[8]=(G=g[8])*m+(I=g[9])*E+(F=g[10])*O+(B=g[11])*j,p[9]=G*w+I*P+F*T+B*_,p[10]=G*x+I*S+F*N+B*A,p[11]=G*b+I*C+F*M+B*R,p[12]=(G=g[12])*m+(I=g[13])*E+(F=g[14])*O+(B=g[15])*j,p[13]=G*w+I*P+F*T+B*_,p[14]=G*x+I*S+F*N+B*A,p[15]=G*b+I*C+F*M+B*R,!e.isHit(d,i,v=p)){t.next=25;break}if(!n){t.next=24;break}return r.picked=[f],t.abrupt("return",r);case 24:s.push(f);case 25:t.next=33;break;case 27:if(!n){t.next=32;break}return r.picked=[f],t.abrupt("return",r);case 32:s.push(f);case 33:l++,t.next=9;break;case 36:return r.picked=s,t.abrupt("return",r);case 38:case"end":return t.stop()}var p,y,g,m,w,x,b,E,P,S,C,O,T,N,M,j,_,A,R,G,I,F,B}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){b(i,n,o,a,c,"next",t)}function c(t){b(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t){return r.apply(this,arguments)}}())},t}(),C.tag="CanvasPicker",O=C);function M(t,e,r,n){var o=t-r,i=e-n;return Math.sqrt(o*o+i*i)}function j(t,e){return.001>Math.abs(t-e)}function _(t,e){var r=Math.min.apply(Math,t),n=Math.min.apply(Math,e);return{x:r,y:n,width:Math.max.apply(Math,t)-r,height:Math.max.apply(Math,e)-n}}m([e.inject(e.DisplayObjectPool),w("design:type",e.DisplayObjectPool)],N.prototype,"displayObjectPool",void 0),m([e.inject(e.CanvasConfig),w("design:type",Object)],N.prototype,"canvasConfig",void 0),m([e.inject(e.OffscreenCanvasCreator),w("design:type",e.OffscreenCanvasCreator)],N.prototype,"offscreenCanvas",void 0),m([e.inject(e.RBushRoot),w("design:type",e.RBush)],N.prototype,"rBush",void 0),m([e.inject(a),w("design:type",Function)],N.prototype,"pathGeneratorFactory",void 0),m([e.inject(T),w("design:type",Function)],N.prototype,"pointInPathPickerFactory",void 0),N=O=m([e.singleton({contrib:e.RenderingPluginContribution})],N);var A=function(t,e,r,n,o){return{x:(1-o)*t+o*r,y:(1-o)*e+o*n}},R=function(t,e,r,n,o,i){var a=[r-t,n-e];if(function(t,e){return t[0]===e[0]&&t[1]===e[1]}(a,[0,0]))return Math.sqrt((o-t)*(o-t)+(i-e)*(i-e));var c=[-a[1],a[0]];return function(t,e){var r=e[0],n=e[1],o=r*r+n*n;o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o}(c,c),Math.abs(function(t,e){return t[0]*e[0]+t[1]*e[1]}([o-t,i-e],c))};function G(t,e,r,n,o){var i=1-o;return i*i*i*t+3*e*o*i*i+3*r*o*o*i+n*o*o*o}function I(t,e,r,n,o){var i=1-o;return 3*(i*i*(e-t)+2*i*o*(r-e)+o*o*(n-r))}function F(t,e,r,n){var o,i,a,c=-3*t+9*e-9*r+3*n,u=6*t-12*e+6*r,s=3*e-3*t,l=[];if(j(c,0))j(u,0)||0>(o=-s/u)||o>1||l.push(o);else{var h=u*u-4*c*s;j(h,0)?l.push(-u/(2*c)):h>0&&(i=(-u-(a=Math.sqrt(h)))/(2*c),0>(o=(-u+a)/(2*c))||o>1||l.push(o),0>i||i>1||l.push(i))}return l}function B(t,e,r,n,o,i,a,c,u){var s=G(t,r,o,a,u),l=G(e,n,i,c,u),h=A(t,e,r,n,u),f=A(r,n,o,i,u),v=A(o,i,a,c,u),d=A(h.x,h.y,f.x,f.y,u),p=A(f.x,f.y,v.x,v.y,u);return[[t,e,h.x,h.y,d.x,d.y,s,l],[s,l,p.x,p.y,v.x,v.y,a,c]]}function D(t,e,r,n,o,i,a,c,u){if(0===u)return function(t,e){for(var r=0,n=t.length,o=0;n>o;o++)r+=M(t[o],e[o],t[(o+1)%n],e[(o+1)%n]);return r/2}([t,r,o,a],[e,n,i,c]);var s=B(t,e,r,n,o,i,a,c,.5),l=[].concat(s[0],[u-1]),h=[].concat(s[1],[u-1]);return D.apply(void 0,l)+D.apply(void 0,h)}var Y={extrema:F,box:function(t,e,r,n,o,i,a,c){for(var u=[t,a],s=[e,c],l=F(t,r,o,a),h=F(e,n,i,c),f=0;l.length>f;f++)u.push(G(t,r,o,a,l[f]));for(var v=0;h.length>v;v++)s.push(G(e,n,i,c,h[v]));return _(u,s)},length:function(t,e,r,n,o,i,a,c){return D(t,e,r,n,o,i,a,c,3)},nearestPoint:function(t,e,r,n,o,i,a,c,u,s,l){return function(t,e,r,n,o,i){var a=-1,c=1/0,u=[r,n],s=20;i&&i>200&&(s=i/10);for(var l=1/s,h=l/10,f=0;s>=f;f++){var v=f*l,d=[o.apply(void 0,t.concat([v])),o.apply(void 0,e.concat([v]))],p=M(u[0],u[1],d[0],d[1]);c>p&&(a=v,c=p)}if(0===a)return{x:t[0],y:e[0]};if(1===a){var y=t.length;return{x:t[y-1],y:e[y-1]}}c=1/0;for(var g=0;32>g&&h>=1e-4;g++){var m=a-h,w=a+h,x=[o.apply(void 0,t.concat([m])),o.apply(void 0,e.concat([m]))],b=M(u[0],u[1],x[0],x[1]);if(m>=0&&c>b)a=m,c=b;else{var E=[o.apply(void 0,t.concat([w])),o.apply(void 0,e.concat([w]))],L=M(u[0],u[1],E[0],E[1]);1>=w&&c>L?(a=w,c=L):h*=.5}}return{x:o.apply(void 0,t.concat([a])),y:o.apply(void 0,e.concat([a]))}}([t,r,o,a],[e,n,i,c],u,s,G,l)},pointDistance:function(t,e,r,n,o,i,a,c,u,s,l){var h=this.nearestPoint(t,e,r,n,o,i,a,c,u,s,l);return M(h.x,h.y,u,s)},interpolationAt:G,pointAt:function(t,e,r,n,o,i,a,c,u){return{x:G(t,r,o,a,u),y:G(e,n,i,c,u)}},divide:function(t,e,r,n,o,i,a,c,u){return B(t,e,r,n,o,i,a,c,u)},tangentAngle:function(t,e,r,n,o,i,a,c,u){var s=I(t,r,o,a,u),l=I(e,n,i,c,u);return(Math.atan2(l,s)+2*Math.PI)%(2*Math.PI)}};function W(t,e,r,n){var o=t-r,i=e-n;return Math.sqrt(o*o+i*i)}function $(t,e,r,n,o,i){return!(t>o||o>t+r||e>i||i>e+n)}function H(t,e,r,n,o,i,a,c){var u=(Math.atan2(c-e,a-t)+2*Math.PI)%(2*Math.PI);if(n>u||u>o)return!1;var s={x:t+r*Math.cos(u),y:e+r*Math.sin(u)};return W(s.x,s.y,a,c)<=i/2}function U(t,e,r,n,o,i,a){var c=Math.min(t,r),u=Math.max(t,r),s=Math.min(e,n),l=Math.max(e,n),h=o/2;return!(c-h>i||i>u+h||s-h>a||a>l+h)&&R(t,e,r,n,i,a)<=o/2}function V(t,e,r,n,o){var i=t.length;if(2>i)return!1;for(var a=0;i-1>a;a++){if(U(t[a][0],t[a][1],t[a+1][0],t[a+1][1],e,r,n))return!0}if(o){var c=t[0],u=t[i-1];if(U(c[0],c[1],u[0],u[1],e,r,n))return!0}return!1}function X(t){return 1e-6>Math.abs(t)?0:0>t?-1:1}function z(t,e,r){return!((r[0]-t[0])*(e[1]-t[1])!=(e[0]-t[0])*(r[1]-t[1])||Math.min(t[0],e[0])>r[0]||r[0]>Math.max(t[0],e[0])||Math.min(t[1],e[1])>r[1]||r[1]>Math.max(t[1],e[1]))}function q(t,e,r){var n=!1,o=t.length;if(2>=o)return!1;for(var i=0;o>i;i++){var a=t[i],c=t[(i+1)%o];if(z(a,c,[e,r]))return!0;X(a[1]-r)>0!=X(c[1]-r)>0&&0>X(e-(r-a[1])*(a[0]-c[0])/(a[1]-c[1])-a[0])&&(n=!n)}return n}function Q(t,e,r){for(var n=!1,o=0;t.length>o;o++){if(n=q(t[o],e,r))break}return n}function J(t,e){var r=t.parsedStyle,n=r.fill,o=r.stroke,i=r.lineWidth,a=r.increasedLineWidthForHitTesting,c=r.clipPathTargets,u=r.r.value,s=(((null==i?void 0:i.value)||0)+((null==a?void 0:a.value)||0))/2,l=W(u,u,e.x,e.y),h=n&&!n.isNone,f=o&&!o.isNone;return h&&f||!!(null==c?void 0:c.length)?u+s>=l:h?u>=l:!!f&&(l>=u-s&&u+s>=l)}function K(t,e,r,n){return t/(r*r)+e/(n*n)}function Z(t,e){var r=e.x,n=e.y,o=t.parsedStyle,i=o.fill,a=o.stroke,c=o.lineWidth,u=o.increasedLineWidthForHitTesting,s=o.clipPathTargets,l=i&&!i.isNone,h=a&&!a.isNone,f=o.rx.value,v=o.ry.value,d=(((null==c?void 0:c.value)||0)+((null==u?void 0:u.value)||0))/2,p=(r-f)*(r-f),y=(n-v)*(n-v);return l&&h||!!(null==s?void 0:s.length)?1>=K(p,y,f+d,v+d):l?1>=K(p,y,f,v):!!h&&(K(p,y,f-d,v-d)>=1&&1>=K(p,y,f+d,v+d))}function tt(t,e){var r=t.parsedStyle,n=r.lineWidth,o=r.increasedLineWidthForHitTesting,i=r.defX,a=r.defY;return U(r.x1.value,r.y1.value,r.x2.value,r.y2.value,((null==n?void 0:n.value)||0)+((null==o?void 0:o.value)||0),e.x+(void 0===i?0:i),e.y+(void 0===a?0:a))}function et(t,e,r){var n=t.parsedStyle,o=n.lineWidth,i=n.increasedLineWidthForHitTesting,a=n.stroke,c=n.fill,u=n.defX,s=void 0===u?0:u,l=n.defY,h=void 0===l?0:l,f=n.clipPathTargets,v=n.path,d=c&&!c.isNone,p=v.hasArc,y=v.polylines,g=v.polygons,m=!!(null==f?void 0:f.length),w=!1;return(a&&!a.isNone||m)&&(w=function(t,e,r,n,o,i,a){for(var c=!1,u=0;t.length>u;u++){var s=t[u],l=s.currentPoint,h=s.params,f=s.prePoint;switch(s.command){case"L":case"Z":c=U(f[0],f[1],l[0],l[1],e,r,n);break;case"C":c=e/2>=Y.pointDistance(f[0],f[1],h[1],h[2],h[3],h[4],h[5],h[6],r,n,o)}if(c)break}return c}(v.segments,((null==o?void 0:o.value)||0)+((null==i?void 0:i.value)||0),e.x+s,e.y+h,v.totalLength)),w||!d&&!m||(w=p?r(t,e):Q(g,e.x+s,e.y+h)||Q(y,e.x+s,e.y+h)),w}function rt(t,e){var r=t.parsedStyle,n=r.stroke,o=r.fill,i=r.lineWidth,a=r.increasedLineWidthForHitTesting,c=r.points,u=r.defX,s=void 0===u?0:u,l=r.defY,h=void 0===l?0:l,f=r.clipPathTargets,v=!!(null==f?void 0:f.length),d=o&&!o.isNone,p=!1;return(n&&!n.isNone||v)&&(p=V(c.points,((null==i?void 0:i.value)||0)+((null==a?void 0:a.value)||0),e.x+s,e.y+h,!0)),p||!d&&!v||(p=q(c.points,e.x+s,e.y+h)),p}function nt(t,e){var r=t.parsedStyle,n=r.stroke,o=r.lineWidth,i=r.increasedLineWidthForHitTesting,a=r.defX,c=r.defY,u=r.clipPathTargets;return!((!n||n.isNone)&&!(null==u?void 0:u.length)||!o)&&V(r.points.points,((null==o?void 0:o.value)||0)+((null==i?void 0:i.value)||0),e.x+(void 0===a?0:a),e.y+(void 0===c?0:c),!1)}function ot(t,r,n){var o=t.parsedStyle,i=o.radius,a=o.fill,c=o.stroke,u=o.lineWidth,s=o.increasedLineWidthForHitTesting,l=o.width,h=o.height,f=o.clipPathTargets,v=!!(null==f?void 0:f.length),d=a&&!a.isNone,p=c&&!c.isNone,y=i&&i.some((function(t){return 0!==t.value})),g=l.unit,m=h.unit,w=0,x=0;g!==e.UnitType.kNumber&&g!==e.UnitType.kPixels||(w=l.value),m!==e.UnitType.kNumber&&m!==e.UnitType.kPixels||(x=h.value);var b=((null==u?void 0:u.value)||0)+((null==s?void 0:s.value)||0);if(y){var E=!1;return(p||v)&&(E=function(t,e,r,n,o,i,a,c){var u=o[0],s=o[1],l=o[2],h=o[3];return U(t+u,e,t+r-s,e,i,a,c)||U(t+r,e+s,t+r,e+n-l,i,a,c)||U(t+r-l,e+n,t+h,e+n,i,a,c)||U(t,e+n-h,t,e+u,i,a,c)||H(t+r-s,e+s,s,1.5*Math.PI,2*Math.PI,i,a,c)||H(t+r-l,e+n-l,l,0,.5*Math.PI,i,a,c)||H(t+h,e+n-h,h,.5*Math.PI,Math.PI,i,a,c)||H(t+u,e+u,u,Math.PI,1.5*Math.PI,i,a,c)}(0,0,w,x,i.map((function(t){return e.clamp(t.value,0,Math.min(Math.abs(w)/2,Math.abs(x)/2))})),b,r.x,r.y)),E||!d&&!v||(E=n(t,r)),E}var L=b/2;return d&&p||v?$(0-L,0-L,w+L,x+L,r.x,r.y):d?$(0,0,w,x,r.x,r.y):!!p&&function(t,e,r,n,o,i,a){var c=o/2;return $(t-c,e-c,r,o,i,a)||$(t+r-c,e-c,o,n,i,a)||$(t+c,e+n-c,r,o,i,a)||$(t-c,e+c,o,n,i,a)}(0,0,w,x,b,r.x,r.y)}var it,at,ct=e.Module((function(t){t({token:T,useFactory:function(t){return function(t){return t===e.Shape.CIRCLE?J:t===e.Shape.ELLIPSE?Z:t===e.Shape.RECT?ot:t===e.Shape.LINE?tt:t===e.Shape.POLYLINE?nt:t===e.Shape.POLYGON?rt:t===e.Shape.PATH?et:t===e.Shape.IMAGE||t===e.Shape.TEXT?function(){return!0}:null}}}),t(N)})),ut=function(){function t(){this.name="canvas-picker"}var e=t.prototype;return e.init=function(t){t.load(ct,!0)},e.destroy=function(t){t.unload(ct)},t}(),st=Object.freeze({__proto__:null,Plugin:ut}),lt=function(){function t(){this.imageCache={},this.gradientCache={},this.patternCache={},this.canvasConfig=void 0}var r=t.prototype;return r.getImageSync=function(t,e){return this.imageCache[t]||this.getOrCreateImage(t).then((function(){e&&e()})),this.imageCache[t]},r.getOrCreateImage=function(t){var r=this;if(this.imageCache[t])return Promise.resolve(this.imageCache[t]);var n=this.canvasConfig.createImage;return new Promise((function(o,i){var a;n?a=n(t):e.isBrowser&&(a=new window.Image),a&&(a.onload=function(){o(a)},a.onerror=function(t){i(t)},a.crossOrigin="Anonymous",a.src=t,r.imageCache[t]=a)}))},r.getOrCreatePatternSync=function(t,r,n){var o=this.generatePatternKey(t);if(o&&this.patternCache[o])return this.patternCache[o];var i,a=t.image,c=t.repetition,u=(i=e.isString(a)?this.getImageSync(a,n):a)&&r.createPattern(i,c);return o&&u&&(this.patternCache[o]=u),u},r.getOrCreateGradient=function(t,r){var n=this.generateGradientKey(t),o=t.type,i=t.steps,a=t.width,c=t.height,u=t.cx,s=t.cy;if(this.gradientCache[n])return this.gradientCache[n];var l=null;if(o===e.GradientType.LinearGradient){var h=e.computeLinearGradient(a,c,t.angle);l=r.createLinearGradient(h.x1,h.y1,h.x2,h.y2)}else if(o===e.GradientType.RadialGradient){var f=e.computeRadialGradient(a,c,u,s),v=f.x,d=f.y;l=r.createRadialGradient(v,d,0,v,d,f.r)}return l&&(i.forEach((function(t){var e;null===(e=l)||void 0===e||e.addColorStop(t[0],t[1])})),this.gradientCache[n]=l),this.gradientCache[n]},r.generateGradientKey=function(t){return"gradient-"+t.type+"-"+(t.angle||0)+"-"+(t.cx||0)+"-"+(t.cy||0)+"-"+t.width+"-"+t.height+"-"+t.steps.map((function(t){return t.join("")})).join("-")},r.generatePatternKey=function(t){var r=t.image,n=t.repetition;if(e.isString(r))return"pattern-"+r+"-"+n},t}();function ht(){
|
|
6
6
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
7
|
-
ht=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),i=new L(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return
|
|
7
|
+
ht=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),i=new L(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return k()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function h(){}function f(){}function v(){}var d={};c(d,o,(function(){return this}));var p=Object.getPrototypeOf,y=p&&p(p(P([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=v.prototype=h.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function P(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:k}}function k(){return{value:void 0,done:!0}}return f.prototype=v,c(g,"constructor",v),c(v,"constructor",f),f.displayName=c(v,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,c(t,a,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(w.prototype),c(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},m(g),c(g,a,"Generator"),c(g,o,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=P,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(this.prev>=i.tryLoc){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return n(i.catchLoc,!0);if(i.finallyLoc>this.prev)return n(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(this.prev>=o.tryLoc&&r.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function ft(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function vt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){ft(i,n,o,a,c,"next",t)}function c(t){ft(i,n,o,a,c,"throw",t)}a(void 0)}))}}m([e.inject(e.CanvasConfig),w("design:type",Object)],lt.prototype,"canvasConfig",void 0),lt=m([e.singleton()],lt);var dt=(it=function(){function t(){this.imagePool=void 0,this.renderingContext=void 0}return t.prototype.apply=function(t){var r=this,n=function(n){var o=n.target;if(o.nodeName===e.Shape.IMAGE){var i=o.attributes.img;e.isString(i)&&r.imagePool.getImageSync(i,(function(){o.renderable.dirty=!0,t.dirtify()}))}},o=function(n){var o=n.target,i=n.newValue;o.nodeName===e.Shape.IMAGE&&"img"===n.attrName&&e.isString(i)&&r.imagePool.getOrCreateImage(i).then((function(){o.renderable.dirty=!0,t.dirtify()}))};t.hooks.init.tapPromise(at.tag,vt(ht().mark((function t(){return ht().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r.renderingContext.root.addEventListener(e.ElementEvent.MOUNTED,n),r.renderingContext.root.addEventListener(e.ElementEvent.ATTR_MODIFIED,o);case 2:case"end":return t.stop()}}),t)})))),t.hooks.destroy.tap(at.tag,(function(){r.renderingContext.root.removeEventListener(e.ElementEvent.MOUNTED,n),r.renderingContext.root.removeEventListener(e.ElementEvent.ATTR_MODIFIED,o)}))},t}(),it.tag="LoadImage",at=it);m([e.inject(lt),w("design:type",lt)],dt.prototype,"imagePool",void 0),m([e.inject(e.RenderingContext),w("design:type",Object)],dt.prototype,"renderingContext",void 0),dt=at=m([e.singleton({contrib:e.RenderingPluginContribution})],dt);var pt=e.Module((function(t){t(lt),t(dt)})),yt=function(){function t(){this.name="image-loader"}var e=t.prototype;return e.init=function(t){t.load(pt,!0)},e.destroy=function(t){t.unload(pt)},t}(),gt=Object.freeze({__proto__:null,get ImagePool(){return lt},Plugin:yt});function mt(){
|
|
8
8
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
9
|
-
mt=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),i=new L(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return C()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function h(){}function f(){}function v(){}var d={};c(d,o,(function(){return this}));var p=Object.getPrototypeOf,y=p&&p(p(P([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=v.prototype=h.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function P(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:C}}function C(){return{value:void 0,done:!0}}return f.prototype=v,c(g,"constructor",v),c(v,"constructor",f),f.displayName=c(v,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,c(t,a,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(w.prototype),c(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},m(g),c(g,a,"Generator"),c(g,o,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=P,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(this.prev>=i.tryLoc){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return n(i.catchLoc,!0);if(i.finallyLoc>this.prev)return n(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(this.prev>=o.tryLoc&&r.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function wt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function xt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){wt(i,n,o,a,c,"next",t)}function c(t){wt(i,n,o,a,c,"throw",t)}a(void 0)}))}}function bt(){return bt=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},bt.apply(this,arguments)}function Et(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,Lt(t,e)}function Lt(t,e){return Lt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Lt(t,e)}var Pt="undefined"!=typeof Float32Array?Float32Array:Array;function Ct(){var t=new Pt(3);return Pt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function kt(t,e,r){var n=new Pt(3);return n[0]=t,n[1]=e,n[2]=r,n}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});!function(){var t=Ct()}();var St=e.Syringe.defineToken("StyleRendererFactory"),Ot=e.Syringe.defineToken("CircleRenderer",{multiple:!1}),Tt=e.Syringe.defineToken("EllipseRenderer",{multiple:!1}),Nt=e.Syringe.defineToken("RectRenderer",{multiple:!1}),jt=e.Syringe.defineToken("LineRenderer",{multiple:!1}),_t=e.Syringe.defineToken("PolylineRenderer",{multiple:!1}),At=e.Syringe.defineToken("PolygonRenderer",{multiple:!1}),Mt=e.Syringe.defineToken("PathRenderer",{multiple:!1}),Rt=e.Syringe.defineToken("TextRenderer",{multiple:!1}),Gt=e.Syringe.defineToken("ImageRenderer",{multiple:!1}),It=function(){function t(){this.imagePool=void 0}return t.prototype.render=function(t,r){var n,o=r.img,i=r.width.value,a=r.height.value;if(e.isString(o)?n=this.imagePool.getImageSync(o):(i||(i=o.width),a||(a=o.height),n=o),n)try{t.drawImage(n,0,0,i,a)}catch(t){}},t}();m([e.inject(lt),w("design:type",lt)],It.prototype,"imagePool",void 0),It=m([e.singleton({token:Gt})],It);var Ft=function(){function t(){}var r=t.prototype;return r.render=function(t,r,n){var o=r.lineWidth,i=r.textAlign,a=r.textBaseline,c=r.lineJoin,u=r.miterLimit,s=void 0===u?0:u,l=r.letterSpacing,h=void 0===l?0:l,f=r.stroke,v=r.fill,d=r.fillOpacity,p=r.strokeOpacity,y=r.opacity,g=r.metrics,m=r.dx,w=r.dy,x=g.lines,b=g.height,E=g.lineHeight,L=g.lineMetrics;t.font=g.font,t.lineWidth=o.value,t.textAlign=i.value,t.textBaseline=a.value,t.lineJoin=c.value,t.miterLimit=s;var P=0;"middle"===a.value?P=-b/2-E/2:"bottom"===a.value||"alphabetic"===a.value||"ideographic"===a.value?P=-b:"top"!==a.value&&"hanging"!==a.value||(P=-E);var C=0;m&&m.unit===e.UnitType.kPixels&&(C+=m.value),w&&w.unit===e.UnitType.kPixels&&(P+=w.value);for(var k=0;x.length>k;k++){var S=o.value/2+C;P+=E,!e.isNil(f)&&!f.isNone&&o&&o.value&&this.drawLetterSpacing(t,x[k],L[k],i.value,S,P,h,d.value,p.value,y.value,!0),e.isNil(v)||this.drawLetterSpacing(t,x[k],L[k],i.value,S,P,h,d.value,p.value,y.value)}},r.drawLetterSpacing=function(t,e,r,n,o,i,a,c,u,s,l){if(void 0===l&&(l=!1),0!==a){var h=t.textAlign;t.textAlign="left";var f=o;"center"===n?f=o-r.width/2:"right"!==n&&"end"!==n||(f=o-r.width);for(var v=Array.from(e),d=t.measureText(e).width,p=0,y=0;v.length>y;++y){var g=v[y];l?this.strokeText(t,g,f,i,u):this.fillText(t,g,f,i,c,s),f+=d-(p=t.measureText(e.substring(y+1)).width)+a,d=p}t.textAlign=h}else l?this.strokeText(t,e,o,i,u):this.fillText(t,e,o,i,c,s)},r.fillText=function(t,r,n,o,i,a){var c,u=!e.isNil(i)&&1!==i;u&&(c=t.globalAlpha,t.globalAlpha=i*a),t.fillText(r,n,o),u&&(t.globalAlpha=c)},r.strokeText=function(t,r,n,o,i){var a,c=!e.isNil(i)&&1!==i;c&&(a=t.globalAlpha,t.globalAlpha=i),t.strokeText(r,n,o),c&&(t.globalAlpha=a)},t}();Ft=m([e.singleton({token:Rt})],Ft);var Bt=function(){function t(){this.imagePool=void 0}var r=t.prototype;return r.render=function(t,r,n,o){var i=r.fill,a=r.opacity,c=r.fillOpacity,u=r.stroke,s=r.strokeOpacity,l=r.lineWidth,h=r.lineCap,f=r.lineJoin,v=r.shadowColor,d=r.filter,p=r.miterLimit,y=!e.isNil(i)&&!i.isNone,g=!e.isNil(u)&&!u.isNone,m=0===i.alpha;if(y&&(e.isNil(c)||1===c.value?this.fill(t,n,i,o):(t.globalAlpha=c.value,this.fill(t,n,i,o),t.globalAlpha=a.value)),g&&l&&l.value>0){var w,x,b;!e.isNil(s)&&1!==s.value&&(t.globalAlpha=s.value),t.lineWidth=l.value,e.isNil(p)||(t.miterLimit=p),e.isNil(h)||(t.lineCap=h.value),e.isNil(f)||(t.lineJoin=f.value);var E=!e.isNil(v),L=!e.isNil(d);E&&(x=t.shadowColor,e.isNil(w=t.shadowBlur)||(t.shadowColor="transparent",t.shadowBlur=0)),L&&!e.isNil(b=t.filter)&&b.indexOf("drop-shadow")>-1&&(t.filter=b.replace(/drop-shadow\([^)]*\)/,"").trim()||"none");var P=y&&!m;P&&this.stroke(t,n,u,o),E&&(t.shadowColor=x,t.shadowBlur=w),L&&(t.filter=b),P||this.stroke(t,n,u,o)}},r.fill=function(t,r,n,o){var i=this;Array.isArray(n)?n.forEach((function(e){t.fillStyle=i.getColor(e,r,t),t.fill()})):(e.isPattern(n)&&(t.fillStyle=this.getPattern(n,r,t,o)),t.fill())},r.stroke=function(t,r,n,o){var i=this;Array.isArray(n)?n.forEach((function(e){t.strokeStyle=i.getColor(e,r,t),t.stroke()})):(e.isPattern(n)&&(t.strokeStyle=this.getPattern(n,r,t,o)),t.stroke())},r.getPattern=function(t,e,r,n){return this.imagePool.getOrCreatePatternSync(t,r,(function(){e.renderable.dirty=!0,n.dirtify()}))},r.getColor=function(t,r,n){var o;if(t.type===e.GradientType.LinearGradient||t.type===e.GradientType.RadialGradient){var i=r.getGeometryBounds();o=this.imagePool.getOrCreateGradient(bt({type:t.type},t.value,{width:i&&2*i.halfExtents[0]||1,height:i&&2*i.halfExtents[1]||1}),n)}return o},t}();m([e.inject(lt),w("design:type",lt)],Bt.prototype,"imagePool",void 0);var Dt=function(t){function e(){return t.apply(this,arguments)||this}return Et(e,t),e}(Bt=m([e.singleton()],Bt));Dt=m([e.singleton({token:Nt})],Dt);var Yt=function(t){function e(){return t.apply(this,arguments)||this}return Et(e,t),e}(Bt);Yt=m([e.singleton({token:Ot})],Yt);var $t=function(t){function e(){return t.apply(this,arguments)||this}return Et(e,t),e}(Bt);$t=m([e.singleton({token:Tt})],$t);var Ht=function(t){function e(){return t.apply(this,arguments)||this}return Et(e,t),e}(Bt);Ht=m([e.singleton({token:jt})],Ht);var Wt=function(t){function e(){return t.apply(this,arguments)||this}return Et(e,t),e}(Bt);Wt=m([e.singleton({token:_t})],Wt);var Ut=function(t){function e(){return t.apply(this,arguments)||this}return Et(e,t),e}(Bt);Ut=m([e.singleton({token:At})],Ut);var Xt,zt,Vt=function(t){function e(){return t.apply(this,arguments)||this}return Et(e,t),e}(Bt);Vt=m([e.singleton({token:Mt})],Vt);var qt=(Xt=function(){function t(){var t;this.canvasConfig=void 0,this.camera=void 0,this.contextService=void 0,this.renderingContext=void 0,this.pathGeneratorFactory=void 0,this.pathGeneratorFactoryCache={},this.styleRendererFactory=void 0,this.styleRendererFactoryCache={},this.displayObjectPool=void 0,this.rBush=void 0,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.tmpVec3=Ct(),this.tmpMat4=(t=new Pt(16),Pt!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t)}var r=t.prototype;return r.apply=function(t){var r=this,n=function(t){var e=t.target.rBushNode;e.aabb&&r.removedRBushNodeAABBs.push(e.aabb)},o=function(t){var e=t.target.rBushNode;e.aabb&&r.removedRBushNodeAABBs.push(e.aabb)};t.hooks.init.tapPromise(zt.tag,xt(mt().mark((function t(){var i,a,c,u;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r.renderingContext.root.addEventListener(e.ElementEvent.UNMOUNTED,n),r.renderingContext.root.addEventListener(e.ElementEvent.CULLED,o),a=(i=r.canvasConfig).width,c=i.height,u=r.contextService.getContext(),r.clearRect(u,0,0,a,c);case 5:case"end":return t.stop()}}),t)})))),t.hooks.destroy.tap(zt.tag,(function(){r.renderingContext.root.removeEventListener(e.ElementEvent.UNMOUNTED,n),r.renderingContext.root.removeEventListener(e.ElementEvent.CULLED,o)})),t.hooks.beginFrame.tap(zt.tag,(function(){var t=r.contextService.getContext(),e=r.canvasConfig,n=e.width,o=e.height;r.clearFullScreen=r.shouldClearFullScreen(),t&&(t.save(),r.clearFullScreen&&r.clearRect(t,0,0,n,o),r.applyTransform(t,r.camera.getOrthoMatrix()))})),t.hooks.endFrame.tap(zt.tag,(function(){var n=r.contextService.getContext();if(r.clearFullScreen);else{var o=r.safeMergeAABB.apply(r,[r.mergeDirtyAABBs(r.renderQueue)].concat(r.removedRBushNodeAABBs.map((function(t){var r=t.minX,n=t.minY,o=t.maxX,i=t.maxY,a=new e.AABB;return a.setMinMax(kt(r,n,0),kt(o,i,0)),a}))));if(r.removedRBushNodeAABBs=[],e.AABB.isEmpty(o))return void(r.renderQueue=[]);var i=r.convertAABB2Rect(o),a=i.x,c=i.y,u=i.width,s=i.height;r.clearRect(n,a,c,u,s),n.beginPath(),n.rect(a,c,u,s),n.clip(),r.searchDirtyObjects(o).sort((function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder})).forEach((function(e){e&&e.isVisible()&&!e.isCulled()&&r.renderDisplayObject(e,t)})),r.renderQueue.forEach((function(t){r.saveDirtyAABB(t)})),r.renderQueue=[]}r.restoreStack.forEach((function(t){n.restore()})),r.restoreStack=[],r.clearFullScreen=!1,n.restore()})),t.hooks.render.tap(zt.tag,(function(e){r.clearFullScreen?e.isVisible()&&!e.isCulled()&&r.renderDisplayObject(e,t):r.renderQueue.push(e)}))},r.clearRect=function(t,e,r,n,o){t.clearRect(e,r,n,o);var i=this.canvasConfig.background;i&&(t.fillStyle=i,t.fillRect(e,r,n,o))},r.renderDisplayObject=function(t,r){for(var n=this.contextService.getContext(),o=this.restoreStack[this.restoreStack.length-1];o&&t.parentNode!==o;)n.restore(),this.restoreStack.pop(),o=this.restoreStack[this.restoreStack.length-1];var i=t.nodeName;void 0===this.styleRendererFactoryCache[i]&&(this.styleRendererFactoryCache[i]=this.styleRendererFactory(i));var a=this.styleRendererFactoryCache[i];n.save(),this.applyTransform(n,t.getLocalTransform());var c=t.style.clipPath;if(c){n.save(),this.applyTransform(n,c.getLocalTransform()),void 0===this.pathGeneratorFactoryCache[c.nodeName]&&(this.pathGeneratorFactoryCache[c.nodeName]=this.pathGeneratorFactory(c.nodeName));var u=this.pathGeneratorFactoryCache[c.nodeName];u&&(this.useAnchor(n,c),n.beginPath(),u(n,c.parsedStyle),n.closePath()),n.restore(),n.clip()}n.save(),this.applyAttributesToContext(n,t),this.useAnchor(n,t),void 0===this.pathGeneratorFactoryCache[t.nodeName]&&(this.pathGeneratorFactoryCache[t.nodeName]=this.pathGeneratorFactory(t.nodeName));var s=this.pathGeneratorFactoryCache[t.nodeName];s&&(n.beginPath(),s(n,t.parsedStyle),t.nodeName!==e.Shape.LINE&&t.nodeName!==e.Shape.PATH&&t.nodeName!==e.Shape.POLYLINE&&n.closePath()),a&&a.render(n,t.parsedStyle,t,r),n.restore(),t.renderable.dirty=!1,this.restoreStack.push(t)},r.shouldClearFullScreen=function(){return!this.canvasConfig.renderer.getConfig().enableDirtyRectangleRendering||this.renderingContext.renderReasons.has(e.RenderReason.CAMERA_CHANGED)},r.convertAABB2Rect=function(t){var e=t.getMin(),r=t.getMax(),n=Math.floor(e[0]),o=Math.floor(e[1]);return{x:n,y:o,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-o}},r.mergeDirtyAABBs=function(t){var r=new e.AABB;return t.forEach((function(t){var e=t.getRenderBounds();r.add(e);var n=t.renderable.dirtyRenderBounds;n&&r.add(n)})),r},r.searchDirtyObjects=function(t){var e=this,r=t.getMin(),n=r[0],o=r[1],i=t.getMax();return this.rBush.search({minX:n,minY:o,maxX:i[0],maxY:i[1]}).map((function(t){return e.displayObjectPool.getByEntity(t.id)}))},r.saveDirtyAABB=function(t){var r=t.renderable;r.dirtyRenderBounds||(r.dirtyRenderBounds=new e.AABB);var n=t.getRenderBounds();n&&r.dirtyRenderBounds.update(n.center,n.halfExtents)},r.applyTransform=function(t,e){t.transform(e[0],e[1],e[4],e[5],e[12],e[13])},r.applyAttributesToContext=function(t,r){var n=r.parsedStyle,o=n.stroke,i=n.fill,a=n.opacity,c=n.lineDash,u=n.lineDashOffset,s=n.filter,l=n.shadowColor,h=n.shadowBlur,f=n.shadowOffsetX,v=n.shadowOffsetY;c&&Array.isArray(c)&&t.setLineDash(c.map((function(t){return t.value}))),e.isNil(u)||(t.lineDashOffset=u.value),e.isNil(a)||(t.globalAlpha*=a.value),e.isNil(o)||Array.isArray(o)||o.isNone||(t.strokeStyle=r.attributes.stroke),e.isNil(i)||Array.isArray(i)||i.isNone||(t.fillStyle=r.attributes.fill),e.isNil(s)||(t.filter=r.style.filter),!e.isNil(l)&&h.value>0&&(t.shadowColor=l.toString(),t.shadowBlur=h&&h.value||0,t.shadowOffsetX=f&&f.value||0,t.shadowOffsetY=v&&v.value||0)},r.useAnchor=function(t,e){var r=(e.parsedStyle||{}).anchor,n=e.getGeometryBounds(),o=-(r&&r[0].value||0)*(n&&2*n.halfExtents[0]||0),i=-(r&&r[1].value||0)*(n&&2*n.halfExtents[1]||0);0===o&&0===i||t.translate(o,i)},r.safeMergeAABB=function(){for(var t=new e.AABB,r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];return n.forEach((function(e){t.add(e)})),t},t}(),Xt.tag="CanvasRenderer",zt=Xt);m([e.inject(e.CanvasConfig),w("design:type",Object)],qt.prototype,"canvasConfig",void 0),m([e.inject(e.DefaultCamera),w("design:type",e.Camera)],qt.prototype,"camera",void 0),m([e.inject(e.ContextService),w("design:type",Object)],qt.prototype,"contextService",void 0),m([e.inject(e.RenderingContext),w("design:type",Object)],qt.prototype,"renderingContext",void 0),m([e.inject(a),w("design:type",Function)],qt.prototype,"pathGeneratorFactory",void 0),m([e.inject(St),w("design:type",Function)],qt.prototype,"styleRendererFactory",void 0),m([e.inject(e.DisplayObjectPool),w("design:type",e.DisplayObjectPool)],qt.prototype,"displayObjectPool",void 0),m([e.inject(e.RBushRoot),w("design:type",e.RBush)],qt.prototype,"rBush",void 0),qt=zt=m([e.singleton({contrib:e.RenderingPluginContribution})],qt);var Qt,Jt,Kt=e.Module((function(t){var r;t(Yt),t($t),t(Dt),t(It),t(Ft),t(Ht),t(Wt),t(Ut),t(Vt);var n=((r={})[e.Shape.CIRCLE]=Ot,r[e.Shape.ELLIPSE]=Tt,r[e.Shape.RECT]=Nt,r[e.Shape.IMAGE]=Gt,r[e.Shape.TEXT]=Rt,r[e.Shape.LINE]=jt,r[e.Shape.POLYLINE]=_t,r[e.Shape.POLYGON]=At,r[e.Shape.PATH]=Mt,r);t({token:St,useFactory:function(t){return function(e){var r=n[e];return r&&t.container.isBound(r)?t.container.get(r):null}}}),t(qt)})),Zt=function(){function t(){this.name="canvas-renderer"}var e=t.prototype;return e.init=function(t){t.load(Kt,!0)},e.destroy=function(t){t.unload(Kt)},t}(),te=Object.freeze({__proto__:null,get CircleRenderer(){return Yt},CircleRendererContribution:Ot,get EllipseRenderer(){return $t},EllipseRendererContribution:Tt,get ImageRenderer(){return It},ImageRendererContribution:Gt,get LineRenderer(){return Ht},LineRendererContribution:jt,get PathRenderer(){return Vt},PathRendererContribution:Mt,Plugin:Zt,get PolygonRenderer(){return Ut},PolygonRendererContribution:At,get PolylineRenderer(){return Wt},PolylineRendererContribution:_t,get RectRenderer(){return Dt},RectRendererContribution:Nt,StyleRendererFactory:St,get TextRenderer(){return Ft},TextRendererContribution:Rt});function ee(){
|
|
9
|
+
mt=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),i=new L(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return k()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function h(){}function f(){}function v(){}var d={};c(d,o,(function(){return this}));var p=Object.getPrototypeOf,y=p&&p(p(P([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=v.prototype=h.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function P(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:k}}function k(){return{value:void 0,done:!0}}return f.prototype=v,c(g,"constructor",v),c(v,"constructor",f),f.displayName=c(v,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,c(t,a,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(w.prototype),c(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},m(g),c(g,a,"Generator"),c(g,o,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=P,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(this.prev>=i.tryLoc){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return n(i.catchLoc,!0);if(i.finallyLoc>this.prev)return n(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(this.prev>=o.tryLoc&&r.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function wt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function xt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){wt(i,n,o,a,c,"next",t)}function c(t){wt(i,n,o,a,c,"throw",t)}a(void 0)}))}}function bt(){return bt=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},bt.apply(this,arguments)}function Et(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,Lt(t,e)}function Lt(t,e){return Lt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Lt(t,e)}var Pt="undefined"!=typeof Float32Array?Float32Array:Array;function kt(){var t=new Pt(16);return Pt!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function St(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Ct(t,e,r){var n=e[0],o=e[1],i=e[2],a=e[3],c=e[4],u=e[5],s=e[6],l=e[7],h=e[8],f=e[9],v=e[10],d=e[11],p=e[12],y=e[13],g=e[14],m=e[15],w=r[0],x=r[1],b=r[2],E=r[3];return t[0]=w*n+x*c+b*h+E*p,t[1]=w*o+x*u+b*f+E*y,t[2]=w*i+x*s+b*v+E*g,t[3]=w*a+x*l+b*d+E*m,t[4]=(w=r[4])*n+(x=r[5])*c+(b=r[6])*h+(E=r[7])*p,t[5]=w*o+x*u+b*f+E*y,t[6]=w*i+x*s+b*v+E*g,t[7]=w*a+x*l+b*d+E*m,t[8]=(w=r[8])*n+(x=r[9])*c+(b=r[10])*h+(E=r[11])*p,t[9]=w*o+x*u+b*f+E*y,t[10]=w*i+x*s+b*v+E*g,t[11]=w*a+x*l+b*d+E*m,t[12]=(w=r[12])*n+(x=r[13])*c+(b=r[14])*h+(E=r[15])*p,t[13]=w*o+x*u+b*f+E*y,t[14]=w*i+x*s+b*v+E*g,t[15]=w*a+x*l+b*d+E*m,t}function Ot(t,e,r){var n,o,i,a,c,u,s,l,h,f,v,d,p=r[0],y=r[1],g=r[2];return e===t?(t[12]=e[0]*p+e[4]*y+e[8]*g+e[12],t[13]=e[1]*p+e[5]*y+e[9]*g+e[13],t[14]=e[2]*p+e[6]*y+e[10]*g+e[14],t[15]=e[3]*p+e[7]*y+e[11]*g+e[15]):(o=e[1],i=e[2],a=e[3],c=e[4],u=e[5],s=e[6],l=e[7],h=e[8],f=e[9],v=e[10],d=e[11],t[0]=n=e[0],t[1]=o,t[2]=i,t[3]=a,t[4]=c,t[5]=u,t[6]=s,t[7]=l,t[8]=h,t[9]=f,t[10]=v,t[11]=d,t[12]=n*p+c*y+h*g+e[12],t[13]=o*p+u*y+f*g+e[13],t[14]=i*p+s*y+v*g+e[14],t[15]=a*p+l*y+d*g+e[15]),t}function Tt(){var t=new Pt(3);return Pt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Nt(t,e,r){var n=new Pt(3);return n[0]=t,n[1]=e,n[2]=r,n}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});!function(){var t=Tt()}();var Mt=e.Syringe.defineToken("StyleRendererFactory"),jt=e.Syringe.defineToken("CircleRenderer",{multiple:!1}),_t=e.Syringe.defineToken("EllipseRenderer",{multiple:!1}),At=e.Syringe.defineToken("RectRenderer",{multiple:!1}),Rt=e.Syringe.defineToken("LineRenderer",{multiple:!1}),Gt=e.Syringe.defineToken("PolylineRenderer",{multiple:!1}),It=e.Syringe.defineToken("PolygonRenderer",{multiple:!1}),Ft=e.Syringe.defineToken("PathRenderer",{multiple:!1}),Bt=e.Syringe.defineToken("TextRenderer",{multiple:!1}),Dt=e.Syringe.defineToken("ImageRenderer",{multiple:!1}),Yt=function(){function t(){this.imagePool=void 0}return t.prototype.render=function(t,r){var n,o=r.img,i=r.width.value,a=r.height.value;if(e.isString(o)?n=this.imagePool.getImageSync(o):(i||(i=o.width),a||(a=o.height),n=o),n)try{t.drawImage(n,0,0,i,a)}catch(t){}},t}();m([e.inject(lt),w("design:type",lt)],Yt.prototype,"imagePool",void 0),Yt=m([e.singleton({token:Dt})],Yt);var Wt=function(){function t(){}var r=t.prototype;return r.render=function(t,r,n){var o=r.lineWidth,i=r.textAlign,a=r.textBaseline,c=r.lineJoin,u=r.miterLimit,s=void 0===u?0:u,l=r.letterSpacing,h=void 0===l?0:l,f=r.stroke,v=r.fill,d=r.fillOpacity,p=r.strokeOpacity,y=r.opacity,g=r.metrics,m=r.dx,w=r.dy,x=g.lines,b=g.height,E=g.lineHeight,L=g.lineMetrics;t.font=g.font,t.lineWidth=o.value,t.textAlign=i.value,t.textBaseline=a.value,t.lineJoin=c.value,t.miterLimit=s;var P=0;"middle"===a.value?P=-b/2-E/2:"bottom"===a.value||"alphabetic"===a.value||"ideographic"===a.value?P=-b:"top"!==a.value&&"hanging"!==a.value||(P=-E);var k=0;m&&m.unit===e.UnitType.kPixels&&(k+=m.value),w&&w.unit===e.UnitType.kPixels&&(P+=w.value);for(var S=0;x.length>S;S++){var C=o.value/2+k;P+=E,!e.isNil(f)&&!f.isNone&&o&&o.value&&this.drawLetterSpacing(t,x[S],L[S],i.value,C,P,h,d.value,p.value,y.value,!0),e.isNil(v)||this.drawLetterSpacing(t,x[S],L[S],i.value,C,P,h,d.value,p.value,y.value)}},r.drawLetterSpacing=function(t,e,r,n,o,i,a,c,u,s,l){if(void 0===l&&(l=!1),0!==a){var h=t.textAlign;t.textAlign="left";var f=o;"center"===n?f=o-r.width/2:"right"!==n&&"end"!==n||(f=o-r.width);for(var v=Array.from(e),d=t.measureText(e).width,p=0,y=0;v.length>y;++y){var g=v[y];l?this.strokeText(t,g,f,i,u):this.fillText(t,g,f,i,c,s),f+=d-(p=t.measureText(e.substring(y+1)).width)+a,d=p}t.textAlign=h}else l?this.strokeText(t,e,o,i,u):this.fillText(t,e,o,i,c,s)},r.fillText=function(t,r,n,o,i,a){var c,u=!e.isNil(i)&&1!==i;u&&(c=t.globalAlpha,t.globalAlpha=i*a),t.fillText(r,n,o),u&&(t.globalAlpha=c)},r.strokeText=function(t,r,n,o,i){var a,c=!e.isNil(i)&&1!==i;c&&(a=t.globalAlpha,t.globalAlpha=i),t.strokeText(r,n,o),c&&(t.globalAlpha=a)},t}();Wt=m([e.singleton({token:Bt})],Wt);var $t=function(){function t(){this.imagePool=void 0}var r=t.prototype;return r.render=function(t,r,n,o){var i=r.fill,a=r.opacity,c=r.fillOpacity,u=r.stroke,s=r.strokeOpacity,l=r.lineWidth,h=r.lineCap,f=r.lineJoin,v=r.shadowColor,d=r.filter,p=r.miterLimit,y=!e.isNil(i)&&!i.isNone,g=!e.isNil(u)&&!u.isNone,m=0===i.alpha;if(y&&(e.isNil(c)||1===c.value?this.fill(t,n,i,o):(t.globalAlpha=c.value,this.fill(t,n,i,o),t.globalAlpha=a.value)),g&&l&&l.value>0){var w,x,b;!e.isNil(s)&&1!==s.value&&(t.globalAlpha=s.value),t.lineWidth=l.value,e.isNil(p)||(t.miterLimit=p),e.isNil(h)||(t.lineCap=h.value),e.isNil(f)||(t.lineJoin=f.value);var E=!e.isNil(v),L=!e.isNil(d);E&&(x=t.shadowColor,e.isNil(w=t.shadowBlur)||(t.shadowColor="transparent",t.shadowBlur=0)),L&&!e.isNil(b=t.filter)&&b.indexOf("drop-shadow")>-1&&(t.filter=b.replace(/drop-shadow\([^)]*\)/,"").trim()||"none");var P=y&&!m;P&&this.stroke(t,n,u,o),E&&(t.shadowColor=x,t.shadowBlur=w),L&&(t.filter=b),P||this.stroke(t,n,u,o)}},r.fill=function(t,r,n,o){var i=this;Array.isArray(n)?n.forEach((function(e){t.fillStyle=i.getColor(e,r,t),t.fill()})):(e.isPattern(n)&&(t.fillStyle=this.getPattern(n,r,t,o)),t.fill())},r.stroke=function(t,r,n,o){var i=this;Array.isArray(n)?n.forEach((function(e){t.strokeStyle=i.getColor(e,r,t),t.stroke()})):(e.isPattern(n)&&(t.strokeStyle=this.getPattern(n,r,t,o)),t.stroke())},r.getPattern=function(t,e,r,n){return this.imagePool.getOrCreatePatternSync(t,r,(function(){e.renderable.dirty=!0,n.dirtify()}))},r.getColor=function(t,r,n){var o;if(t.type===e.GradientType.LinearGradient||t.type===e.GradientType.RadialGradient){var i=r.getGeometryBounds();o=this.imagePool.getOrCreateGradient(bt({type:t.type},t.value,{width:i&&2*i.halfExtents[0]||1,height:i&&2*i.halfExtents[1]||1}),n)}return o},t}();m([e.inject(lt),w("design:type",lt)],$t.prototype,"imagePool",void 0);var Ht=function(t){function e(){return t.apply(this,arguments)||this}return Et(e,t),e}($t=m([e.singleton()],$t));Ht=m([e.singleton({token:At})],Ht);var Ut=function(t){function e(){return t.apply(this,arguments)||this}return Et(e,t),e}($t);Ut=m([e.singleton({token:jt})],Ut);var Vt=function(t){function e(){return t.apply(this,arguments)||this}return Et(e,t),e}($t);Vt=m([e.singleton({token:_t})],Vt);var Xt=function(t){function e(){return t.apply(this,arguments)||this}return Et(e,t),e}($t);Xt=m([e.singleton({token:Rt})],Xt);var zt=function(t){function e(){return t.apply(this,arguments)||this}return Et(e,t),e}($t);zt=m([e.singleton({token:Gt})],zt);var qt=function(t){function e(){return t.apply(this,arguments)||this}return Et(e,t),e}($t);qt=m([e.singleton({token:It})],qt);var Qt,Jt,Kt=function(t){function e(){return t.apply(this,arguments)||this}return Et(e,t),e}($t);Kt=m([e.singleton({token:Ft})],Kt);var Zt=(Qt=function(){function t(){this.canvasConfig=void 0,this.camera=void 0,this.contextService=void 0,this.renderingContext=void 0,this.pathGeneratorFactory=void 0,this.pathGeneratorFactoryCache={},this.styleRendererFactory=void 0,this.styleRendererFactoryCache={},this.displayObjectPool=void 0,this.rBush=void 0,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.vpMatrix=kt(),this.dprMatrix=kt(),this.tmpMat4=kt(),this.tmpVec3=Tt()}var r=t.prototype;return r.apply=function(t){var r=this,n=function(t){var e=t.target.rBushNode;e.aabb&&r.removedRBushNodeAABBs.push(e.aabb)},o=function(t){var e=t.target.rBushNode;e.aabb&&r.removedRBushNodeAABBs.push(e.aabb)};t.hooks.init.tapPromise(Jt.tag,xt(mt().mark((function t(){var i,a,c,u,s;return mt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r.renderingContext.root.addEventListener(e.ElementEvent.UNMOUNTED,n),r.renderingContext.root.addEventListener(e.ElementEvent.CULLED,o),i=r.contextService.getDPR(),c=(a=r.canvasConfig).width,u=a.height,s=r.contextService.getContext(),r.clearRect(s,0,0,c*i,u*i),l=r.dprMatrix,h=Nt(i,i,1),l[0]=h[0],l[1]=0,l[2]=0,l[3]=0,l[4]=0,l[5]=h[1],l[6]=0,l[7]=0,l[8]=0,l[9]=0,l[10]=h[2],l[11]=0,l[12]=0,l[13]=0,l[14]=0,l[15]=1;case 7:case"end":return t.stop()}var l,h}),t)})))),t.hooks.destroy.tap(Jt.tag,(function(){r.renderingContext.root.removeEventListener(e.ElementEvent.UNMOUNTED,n),r.renderingContext.root.removeEventListener(e.ElementEvent.CULLED,o)})),t.hooks.beginFrame.tap(Jt.tag,(function(){var e=r.contextService.getContext(),n=r.contextService.getDPR(),o=r.canvasConfig,i=o.width,a=o.height,c=t.getStats(),u=c.rendered,s=u/c.total;r.clearFullScreen=t.disableDirtyRectangleRendering()||u>100&&s>.8,e&&r.clearFullScreen&&(e.resetTransform(),r.clearRect(e,0,0,i*n,a*n))})),t.hooks.endFrame.tap(Jt.tag,(function(){var n=r.contextService.getContext();if(Ct(r.vpMatrix,r.dprMatrix,r.camera.getOrthoMatrix()),r.clearFullScreen)r.renderingContext.root.forEach((function(e){e.isVisible()&&!e.isCulled()&&r.renderDisplayObject(e,t)}));else{var o=r.safeMergeAABB.apply(r,[r.mergeDirtyAABBs(r.renderQueue)].concat(r.removedRBushNodeAABBs.map((function(t){var r=t.minX,n=t.minY,o=t.maxX,i=t.maxY,a=new e.AABB;return a.setMinMax(Nt(r,n,0),Nt(o,i,0)),a}))));if(r.removedRBushNodeAABBs=[],e.AABB.isEmpty(o))return void(r.renderQueue=[]);var i=r.convertAABB2Rect(o),a=i.x,c=i.y,u=i.width,s=i.height;n.setTransform(r.vpMatrix[0],r.vpMatrix[1],r.vpMatrix[4],r.vpMatrix[5],r.vpMatrix[12],r.vpMatrix[13]),n.save(),r.clearRect(n,a,c,u,s),n.beginPath(),n.rect(a,c,u,s),n.clip(),r.searchDirtyObjects(o).sort((function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder})).forEach((function(e){e&&e.isVisible()&&!e.isCulled()&&r.renderDisplayObject(e,t)})),n.restore(),r.renderQueue.forEach((function(t){r.saveDirtyAABB(t)})),r.renderQueue=[]}r.restoreStack.forEach((function(){n.restore()})),r.restoreStack=[],r.clearFullScreen=!1})),t.hooks.render.tap(Jt.tag,(function(t){r.clearFullScreen||r.renderQueue.push(t)}))},r.clearRect=function(t,e,r,n,o){t.clearRect(e,r,n,o);var i=this.canvasConfig.background;i&&(t.fillStyle=i,t.fillRect(e,r,n,o))},r.renderDisplayObject=function(t,r){for(var n=this.contextService.getContext(),o=this.restoreStack[this.restoreStack.length-1];o&&t.parentNode!==o;)n.restore(),this.restoreStack.pop(),o=this.restoreStack[this.restoreStack.length-1];var i=t.nodeName;void 0===this.styleRendererFactoryCache[i]&&(this.styleRendererFactoryCache[i]=this.styleRendererFactory(i));var a=this.styleRendererFactoryCache[i];void 0===this.pathGeneratorFactoryCache[i]&&(this.pathGeneratorFactoryCache[i]=this.pathGeneratorFactory(i));var c=this.pathGeneratorFactoryCache[i],u=t.parsedStyle.clipPath;if(u){this.applyWorldTransform(n,u,t.getWorldTransform()),void 0===this.pathGeneratorFactoryCache[u.nodeName]&&(this.pathGeneratorFactoryCache[u.nodeName]=this.pathGeneratorFactory(u.nodeName));var s=this.pathGeneratorFactoryCache[u.nodeName];s&&(n.save(),this.restoreStack.push(t),n.beginPath(),s(n,u.parsedStyle),n.closePath(),n.clip())}a&&(this.applyWorldTransform(n,t),n.save(),this.applyAttributesToContext(n,t)),c&&(n.beginPath(),c(n,t.parsedStyle),t.nodeName!==e.Shape.LINE&&t.nodeName!==e.Shape.PATH&&t.nodeName!==e.Shape.POLYLINE&&n.closePath()),a&&(a.render(n,t.parsedStyle,t,r),n.restore()),t.renderable.dirty=!1},r.convertAABB2Rect=function(t){var e=t.getMin(),r=t.getMax(),n=Math.floor(e[0]),o=Math.floor(e[1]);return{x:n,y:o,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-o}},r.mergeDirtyAABBs=function(t){var r=new e.AABB;return t.forEach((function(t){var e=t.getRenderBounds();r.add(e);var n=t.renderable.dirtyRenderBounds;n&&r.add(n)})),r},r.searchDirtyObjects=function(t){var e=this,r=t.getMin(),n=r[0],o=r[1],i=t.getMax();return this.rBush.search({minX:n,minY:o,maxX:i[0],maxY:i[1]}).map((function(t){return e.displayObjectPool.getByEntity(t.id)}))},r.saveDirtyAABB=function(t){var r=t.renderable;r.dirtyRenderBounds||(r.dirtyRenderBounds=new e.AABB);var n=t.getRenderBounds();n&&r.dirtyRenderBounds.update(n.center,n.halfExtents)},r.applyAttributesToContext=function(t,r){var n=r.parsedStyle,o=n.stroke,i=n.fill,a=n.opacity,c=n.lineDash,u=n.lineDashOffset,s=n.filter,l=n.shadowColor,h=n.shadowBlur,f=n.shadowOffsetX,v=n.shadowOffsetY;c&&Array.isArray(c)&&t.setLineDash(c.map((function(t){return t.value}))),e.isNil(u)||(t.lineDashOffset=u.value),e.isNil(a)||(t.globalAlpha*=a.value),e.isNil(o)||Array.isArray(o)||o.isNone||(t.strokeStyle=r.attributes.stroke),e.isNil(i)||Array.isArray(i)||i.isNone||(t.fillStyle=r.attributes.fill),e.isNil(s)||(t.filter=r.style.filter),!e.isNil(l)&&(null==h?void 0:h.value)>0&&(t.shadowColor=l.toString(),t.shadowBlur=h&&h.value||0,t.shadowOffsetX=f&&f.value||0,t.shadowOffsetY=v&&v.value||0)},r.applyWorldTransform=function(t,e,r){var n=0,o=0,i=(e.parsedStyle||{}).anchor,a=i&&i[0].value||0,c=i&&i[1].value||0;if(0!==a||0!==c){var u=e.getGeometryBounds();n=-a*(u&&2*u.halfExtents[0]||0),o=-c*(u&&2*u.halfExtents[1]||0)}r?(St(this.tmpMat4,e.getLocalTransform()),this.tmpVec3[0]=n,this.tmpVec3[1]=o,this.tmpVec3[2]=0,Ot(this.tmpMat4,this.tmpMat4,this.tmpVec3),Ct(this.tmpMat4,r,this.tmpMat4),Ct(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(St(this.tmpMat4,e.getWorldTransform()),this.tmpVec3[0]=n,this.tmpVec3[1]=o,this.tmpVec3[2]=0,Ot(this.tmpMat4,this.tmpMat4,this.tmpVec3),Ct(this.tmpMat4,this.vpMatrix,this.tmpMat4)),t.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])},r.safeMergeAABB=function(){for(var t=new e.AABB,r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];return n.forEach((function(e){t.add(e)})),t},t}(),Qt.tag="CanvasRenderer",Jt=Qt);m([e.inject(e.CanvasConfig),w("design:type",Object)],Zt.prototype,"canvasConfig",void 0),m([e.inject(e.DefaultCamera),w("design:type",e.Camera)],Zt.prototype,"camera",void 0),m([e.inject(e.ContextService),w("design:type",Object)],Zt.prototype,"contextService",void 0),m([e.inject(e.RenderingContext),w("design:type",Object)],Zt.prototype,"renderingContext",void 0),m([e.inject(a),w("design:type",Function)],Zt.prototype,"pathGeneratorFactory",void 0),m([e.inject(Mt),w("design:type",Function)],Zt.prototype,"styleRendererFactory",void 0),m([e.inject(e.DisplayObjectPool),w("design:type",e.DisplayObjectPool)],Zt.prototype,"displayObjectPool",void 0),m([e.inject(e.RBushRoot),w("design:type",e.RBush)],Zt.prototype,"rBush",void 0),Zt=Jt=m([e.singleton({contrib:e.RenderingPluginContribution})],Zt);var te,ee,re=e.Module((function(t){var r;t(Ut),t(Vt),t(Ht),t(Yt),t(Wt),t(Xt),t(zt),t(qt),t(Kt);var n=((r={})[e.Shape.CIRCLE]=jt,r[e.Shape.ELLIPSE]=_t,r[e.Shape.RECT]=At,r[e.Shape.IMAGE]=Dt,r[e.Shape.TEXT]=Bt,r[e.Shape.LINE]=Rt,r[e.Shape.POLYLINE]=Gt,r[e.Shape.POLYGON]=It,r[e.Shape.PATH]=Ft,r);t({token:Mt,useFactory:function(t){return function(e){var r=n[e];return r&&t.container.isBound(r)?t.container.get(r):null}}}),t(Zt)})),ne=function(){function t(){this.name="canvas-renderer"}var e=t.prototype;return e.init=function(t){t.load(re,!0)},e.destroy=function(t){t.unload(re)},t}(),oe=Object.freeze({__proto__:null,get CircleRenderer(){return Ut},CircleRendererContribution:jt,get EllipseRenderer(){return Vt},EllipseRendererContribution:_t,get ImageRenderer(){return Yt},ImageRendererContribution:Dt,get LineRenderer(){return Xt},LineRendererContribution:Rt,get PathRenderer(){return Kt},PathRendererContribution:Ft,Plugin:ne,get PolygonRenderer(){return qt},PolygonRendererContribution:It,get PolylineRenderer(){return zt},PolylineRendererContribution:Gt,get RectRenderer(){return Ht},RectRendererContribution:At,StyleRendererFactory:Mt,get TextRenderer(){return Wt},TextRendererContribution:Bt});function ie(){
|
|
10
10
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
11
|
-
|
|
11
|
+
ie=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),i=new L(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return k()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function h(){}function f(){}function v(){}var d={};c(d,o,(function(){return this}));var p=Object.getPrototypeOf,y=p&&p(p(P([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=v.prototype=h.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function P(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:k}}function k(){return{value:void 0,done:!0}}return f.prototype=v,c(g,"constructor",v),c(v,"constructor",f),f.displayName=c(v,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,c(t,a,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(w.prototype),c(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},m(g),c(g,a,"Generator"),c(g,o,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=P,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(this.prev>=i.tryLoc){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return n(i.catchLoc,!0);if(i.finallyLoc>this.prev)return n(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(this.prev>=o.tryLoc&&r.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function ae(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ce(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){ae(i,n,o,a,c,"next",t)}function c(t){ae(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ue=(te=function(){function t(){this.contextService=void 0,this.renderingContext=void 0}return t.prototype.apply=function(t){var e=this,r=this.renderingContext.root.ownerDocument.defaultView,n=function(e){t.hooks.pointerMove.call(e)},o=function(e){t.hooks.pointerUp.call(e)},i=function(e){t.hooks.pointerDown.call(e)},a=function(e){t.hooks.pointerOver.call(e)},c=function(e){t.hooks.pointerOut.call(e)},u=function(e){t.hooks.pointerCancel.call(e)},s=function(e){t.hooks.pointerWheel.call(e)},l=function(t){globalThis.document.addEventListener("pointermove",n,!0),t.addEventListener("pointerdown",i,!0),t.addEventListener("pointerleave",c,!0),t.addEventListener("pointerover",a,!0),globalThis.addEventListener("pointerup",o,!0)},h=function(t){t.addEventListener("touchstart",i,!0),t.addEventListener("touchend",o,!0),globalThis.document.addEventListener("touchmove",n,!0),t.addEventListener("touchcancel",u,!0)},f=function(t){globalThis.document.addEventListener("mousemove",n,!0),t.addEventListener("mousedown",i,!0),t.addEventListener("mouseout",c,!0),t.addEventListener("mouseover",a,!0),globalThis.addEventListener("mouseup",o,!0)};t.hooks.init.tapPromise(ee.tag,ce(ie().mark((function t(){var n;return ie().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=e.contextService.getDomElement(),globalThis.navigator.msPointerEnabled?(n.style.msContentZooming="none",n.style.msTouchAction="none"):r.supportsPointerEvents&&(n.style.touchAction="none"),r.supportsPointerEvents?l(n):f(n),r.supportsTouchEvents&&h(n),n.addEventListener("wheel",s,{passive:!0,capture:!0});case 5:case"end":return t.stop()}}),t)})))),t.hooks.destroy.tap(ee.tag,(function(){var t=e.contextService.getDomElement();r.supportsPointerEvents?function(t){globalThis.document.removeEventListener("pointermove",n,!0),t.removeEventListener("pointerdown",i,!0),t.removeEventListener("pointerleave",c,!0),t.removeEventListener("pointerover",a,!0),globalThis.removeEventListener("pointerup",o,!0)}(t):function(t){globalThis.document.removeEventListener("mousemove",n,!0),t.removeEventListener("mousedown",i,!0),t.removeEventListener("mouseout",c,!0),t.removeEventListener("mouseover",a,!0),globalThis.removeEventListener("mouseup",o,!0)}(t),r.supportsTouchEvents&&function(t){t.removeEventListener("touchstart",i,!0),t.removeEventListener("touchend",o,!0),t.removeEventListener("touchcancel",u,!0),globalThis.document.removeEventListener("touchmove",n,!0)}(t),t.removeEventListener("wheel",s,!0)}))},t}(),te.tag="DOMInteraction",ee=te);m([e.inject(e.ContextService),w("design:type",Object)],ue.prototype,"contextService",void 0),m([e.inject(e.RenderingContext),w("design:type",Object)],ue.prototype,"renderingContext",void 0),ue=ee=m([e.singleton({contrib:e.RenderingPluginContribution})],ue);var se,le,he=e.Module((function(t){t(ue)})),fe=function(){function t(){this.name="dom-interaction"}var e=t.prototype;return e.init=function(t){t.load(he,!0)},e.destroy=function(t){t.unload(he)},t}(),ve=Object.freeze({__proto__:null,Plugin:fe});function de(){
|
|
12
12
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
13
|
-
le=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),i=new L(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return C()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function h(){}function f(){}function v(){}var d={};c(d,o,(function(){return this}));var p=Object.getPrototypeOf,y=p&&p(p(P([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=v.prototype=h.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function P(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:C}}function C(){return{value:void 0,done:!0}}return f.prototype=v,c(g,"constructor",v),c(v,"constructor",f),f.displayName=c(v,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,c(t,a,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(w.prototype),c(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},m(g),c(g,a,"Generator"),c(g,o,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=P,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(this.prev>=i.tryLoc){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return n(i.catchLoc,!0);if(i.finallyLoc>this.prev)return n(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(this.prev>=o.tryLoc&&r.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function he(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function fe(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){he(i,n,o,a,c,"next",t)}function c(t){he(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ve=(ie=function(){function t(){this.contextService=void 0,this.renderingContext=void 0,this.canvasConfig=void 0,this.$camera=void 0}var r=t.prototype;return r.apply=function(t){var r=this,n=function(t){var n=t.target;if(n.nodeName===e.Shape.HTML){var o=r.getOrCreateEl(n),i=n.ownerDocument.documentElement.attributes;Object.keys(i).forEach((function(t){o.style[t]=i[t]})),Object.keys(n.attributes).forEach((function(t){r.updateAttribute(t,n)}))}},o=function(t){var n=t.target;if(n.nodeName===e.Shape.HTML){var o=r.getId(n),i=r.contextService.getDomElement().parentNode;if(i){var a=i.querySelector("#"+o);a&&i.removeChild(a)}}},i=function(t){var n=t.target;n.nodeName===e.Shape.HTML&&r.updateAttribute(t.attrName,n)};t.hooks.init.tapPromise(ae.tag,fe(le().mark((function t(){return le().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r.renderingContext.root.addEventListener(e.ElementEvent.MOUNTED,n),r.renderingContext.root.addEventListener(e.ElementEvent.UNMOUNTED,o),r.renderingContext.root.addEventListener(e.ElementEvent.ATTR_MODIFIED,i);case 3:case"end":return t.stop()}}),t)})))),t.hooks.destroy.tap(ae.tag,(function(){r.renderingContext.root.removeEventListener(e.ElementEvent.MOUNTED,n),r.renderingContext.root.removeEventListener(e.ElementEvent.UNMOUNTED,o),r.renderingContext.root.removeEventListener(e.ElementEvent.ATTR_MODIFIED,i)}))},r.getId=function(t){return t.id||"g-html-"+t.entity},r.getOrCreateEl=function(t){var e=this.canvasConfig.document,r=this.getId(t),n=this.contextService.getDomElement().parentNode;if(n){var o=n.querySelector("#"+r);if(!o){o=(e||document).createElement("div"),t.parsedStyle.$el=o,o.id=r,t.name&&o.setAttribute("name",t.name),t.className&&(o.className=t.className),n.appendChild(o),o.style.position="absolute",o.style.left="0",o.style.top="0",o.style["will-change"]="transform";var i=t.getWorldTransform();o.style.transform="matrix("+[i[0],i[1],i[4],i[5],i[12],i[13]].join(",")+")"}return o}return null},r.updateAttribute=function(t,r){var n=this.getOrCreateEl(r);switch(t){case"innerHTML":var o=r.parsedStyle.innerHTML;e.isString(o)?n.innerHTML=o:(n.innerHTML="",n.appendChild(o));break;case"modelMatrix":case"transformOrigin":var i=r.parsedStyle.transformOrigin;n.style["transform-origin"]=i[0].value+" "+i[1].value;var a=r.getWorldTransform();n.style.transform="matrix("+[a[0],a[1],a[4],a[5],a[12],a[13]].join(",")+")";break;case"width":var c=r.computedStyleMap().get("width");n.style.width=c.toString();break;case"height":var u=r.computedStyleMap().get("height");n.style.height=u.toString();break;case"zIndex":n.style["z-index"]=""+r.parsedStyle.zIndex.value;break;case"visibility":n.style.visibility=r.parsedStyle.visibility.value;break;case"pointerEvents":n.style.pointerEvents=r.parsedStyle.pointerEvents.value;break;case"opacity":n.style.opacity=""+r.parsedStyle.opacity.value;break;case"fill":var s=r.parsedStyle.fill,l="";s instanceof e.CSSRGB?l=s.isNone?"transparent":r.getAttribute("fill"):Array.isArray(s)?l=r.getAttribute("fill"):e.isPattern(s),n.style.background=l;break;case"stroke":var h=r.parsedStyle.stroke,f="";h instanceof e.CSSRGB?f=h.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(h)?f=r.getAttribute("stroke"):e.isPattern(h),n.style["border-color"]=f,n.style["border-style"]="solid";break;case"lineWidth":n.style["border-width"]=(r.parsedStyle.lineWidth.value||0)+"px";break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":n.style.filter=r.parsedStyle.filter}},t}(),ie.tag="HTMLRendering",ae=ie);m([e.inject(e.ContextService),w("design:type",Object)],ve.prototype,"contextService",void 0),m([e.inject(e.RenderingContext),w("design:type",Object)],ve.prototype,"renderingContext",void 0),m([e.inject(e.CanvasConfig),w("design:type",Object)],ve.prototype,"canvasConfig",void 0),ve=ae=m([e.singleton({contrib:e.RenderingPluginContribution})],ve);var de=e.Module((function(t){t(ve)})),pe=function(){function t(){this.name="html-renderer"}var e=t.prototype;return e.init=function(t){t.load(de,!0)},e.destroy=function(t){t.unload(de)},t}(),ye=Object.freeze({__proto__:null,Plugin:pe}),ge=function(){function t(){this.$container=void 0,this.$canvas=void 0,this.dpr=void 0,this.context=void 0,this.canvasConfig=void 0}var n=t.prototype;return n.init=function(){var t=o(r().mark((function t(){var n,o,i,a,c,u;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=(n=this.canvasConfig).container,a=n.devicePixelRatio,(i=n.canvas)?(this.$canvas=i,o&&i.parentElement!==o&&o.appendChild(i),this.$container=i.parentElement,this.canvasConfig.container=this.$container):o&&(this.$container=e.isString(o)?document.getElementById(o):o,this.$container&&(c=document.createElement("canvas"),this.$container.appendChild(c),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=c)),this.context=this.$canvas.getContext("2d"),u=1>(u=a||e.isBrowser&&window.devicePixelRatio||1)?1:Math.ceil(u),this.dpr=u,this.resize(this.canvasConfig.width,this.canvasConfig.height);case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getContext=function(){return this.context},n.getDomElement=function(){return this.$canvas},n.getDPR=function(){return this.dpr},n.getBoundingClientRect=function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()},n.destroy=function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)},n.resize=function(t,r){if(this.$canvas){this.$canvas.width=this.dpr*t,this.$canvas.height=this.dpr*r,e.setDOMSize(this.$canvas,t,r);var n=this.getDPR();this.context.scale(n,n)}},n.applyCursorStyle=function(t){this.$container&&this.$container.style&&(this.$container.style.cursor=t)},n.toDataURL=function(){var t=o(r().mark((function t(e){var n;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e={}),t.abrupt("return",this.context.canvas.toDataURL((n=e).type,n.encoderOptions));case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}();m([e.inject(e.CanvasConfig),w("design:type",Object)],ge.prototype,"canvasConfig",void 0),ge=m([e.singleton({token:e.ContextService})],ge);var me=e.Module((function(t){t(ge)})),we=function(){function t(){this.name="canvas-context-register"}var e=t.prototype;return e.init=function(t){t.load(me,!0)},e.destroy=function(t){t.unload(me)},t}(),xe=function(t){var e,r;function n(e){var r;return(r=t.call(this,e)||this).registerPlugin(new we),r.registerPlugin(new yt),r.registerPlugin(new y),r.registerPlugin(new Zt),r.registerPlugin(new ue),r.registerPlugin(new ut),r.registerPlugin(new pe),r}return r=t,(e=n).prototype=Object.create(r.prototype),e.prototype.constructor=e,i(e,r),n}(e.AbstractRenderer);t.CanvasPathGenerator=g,t.CanvasPicker=st,t.CanvasRenderer=te,t.DomInteraction=se,t.HTMLRenderer=ye,t.ImageLoader=gt,t.Renderer=xe,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
13
|
+
de=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),i=new L(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return k()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=x(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function h(){}function f(){}function v(){}var d={};c(d,o,(function(){return this}));var p=Object.getPrototypeOf,y=p&&p(p(P([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=v.prototype=h.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function P(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:k}}function k(){return{value:void 0,done:!0}}return f.prototype=v,c(g,"constructor",v),c(v,"constructor",f),f.displayName=c(v,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,c(t,a,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(w.prototype),c(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},m(g),c(g,a,"Generator"),c(g,o,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=P,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(this.prev>=i.tryLoc){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(i.catchLoc>this.prev)return n(i.catchLoc,!0);if(i.finallyLoc>this.prev)return n(i.finallyLoc)}else if(c){if(i.catchLoc>this.prev)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(this.prev>=o.tryLoc&&r.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}function pe(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function ye(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){pe(i,n,o,a,c,"next",t)}function c(t){pe(i,n,o,a,c,"throw",t)}a(void 0)}))}}var ge=(se=function(){function t(){this.contextService=void 0,this.renderingContext=void 0,this.canvasConfig=void 0,this.$camera=void 0}var r=t.prototype;return r.apply=function(t){var r=this,n=function(t,e){var r=t.getWorldTransform();e.style.transform="matrix("+[r[0],r[1],r[4],r[5],r[12],r[13]].join(",")+")"},o=function(t){var o=t.target;if(o.nodeName===e.Shape.HTML){var i=r.getOrCreateEl(o),a=o.ownerDocument.documentElement.attributes;Object.keys(a).forEach((function(t){i.style[t]=a[t]})),Object.keys(o.attributes).forEach((function(t){r.updateAttribute(t,o)})),n(o,i)}},i=function(t){var n=t.target;if(n.nodeName===e.Shape.HTML){var o=r.getId(n),i=r.contextService.getDomElement().parentNode;if(i){var a=i.querySelector("#"+o);a&&i.removeChild(a)}}},a=function(t){var n=t.target;n.nodeName===e.Shape.HTML&&r.updateAttribute(t.attrName,n)},c=function(t){var o=t.target;if(o.nodeName===e.Shape.HTML){var i=r.getOrCreateEl(o);n(o,i)}};t.hooks.init.tapPromise(le.tag,ye(de().mark((function t(){return de().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r.renderingContext.root.addEventListener(e.ElementEvent.MOUNTED,o),r.renderingContext.root.addEventListener(e.ElementEvent.UNMOUNTED,i),r.renderingContext.root.addEventListener(e.ElementEvent.ATTR_MODIFIED,a),r.renderingContext.root.addEventListener(e.ElementEvent.BOUNDS_CHANGED,c);case 4:case"end":return t.stop()}}),t)})))),t.hooks.destroy.tap(le.tag,(function(){r.renderingContext.root.removeEventListener(e.ElementEvent.MOUNTED,o),r.renderingContext.root.removeEventListener(e.ElementEvent.UNMOUNTED,i),r.renderingContext.root.removeEventListener(e.ElementEvent.ATTR_MODIFIED,a),r.renderingContext.root.removeEventListener(e.ElementEvent.BOUNDS_CHANGED,c)}))},r.getId=function(t){return t.id||"g-html-"+t.entity},r.getOrCreateEl=function(t){var e=this.canvasConfig.document,r=this.getId(t),n=this.contextService.getDomElement().parentNode;if(n){var o=n.querySelector("#"+r);if(!o){o=(e||document).createElement("div"),t.parsedStyle.$el=o,o.id=r,t.name&&o.setAttribute("name",t.name),t.className&&(o.className=t.className),n.appendChild(o),o.style.position="absolute",o.style.left="0",o.style.top="0",o.style["will-change"]="transform";var i=t.getWorldTransform();o.style.transform="matrix("+[i[0],i[1],i[4],i[5],i[12],i[13]].join(",")+")"}return o}return null},r.updateAttribute=function(t,r){var n=this.getOrCreateEl(r);switch(t){case"innerHTML":var o=r.parsedStyle.innerHTML;e.isString(o)?n.innerHTML=o:(n.innerHTML="",n.appendChild(o));break;case"transformOrigin":var i=r.parsedStyle.transformOrigin;n.style["transform-origin"]=i[0].value+" "+i[1].value;break;case"width":var a=r.computedStyleMap().get("width");n.style.width=a.toString();break;case"height":var c=r.computedStyleMap().get("height");n.style.height=c.toString();break;case"zIndex":n.style["z-index"]=""+r.parsedStyle.zIndex.value;break;case"visibility":n.style.visibility=r.parsedStyle.visibility.value;break;case"pointerEvents":n.style.pointerEvents=r.parsedStyle.pointerEvents.value;break;case"opacity":n.style.opacity=""+r.parsedStyle.opacity.value;break;case"fill":var u=r.parsedStyle.fill,s="";u instanceof e.CSSRGB?s=u.isNone?"transparent":r.getAttribute("fill"):Array.isArray(u)?s=r.getAttribute("fill"):e.isPattern(u),n.style.background=s;break;case"stroke":var l=r.parsedStyle.stroke,h="";l instanceof e.CSSRGB?h=l.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(l)?h=r.getAttribute("stroke"):e.isPattern(l),n.style["border-color"]=h,n.style["border-style"]="solid";break;case"lineWidth":n.style["border-width"]=(r.parsedStyle.lineWidth.value||0)+"px";break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":n.style.filter=r.parsedStyle.filter}},t}(),se.tag="HTMLRendering",le=se);m([e.inject(e.ContextService),w("design:type",Object)],ge.prototype,"contextService",void 0),m([e.inject(e.RenderingContext),w("design:type",Object)],ge.prototype,"renderingContext",void 0),m([e.inject(e.CanvasConfig),w("design:type",Object)],ge.prototype,"canvasConfig",void 0),ge=le=m([e.singleton({contrib:e.RenderingPluginContribution})],ge);var me=e.Module((function(t){t(ge)})),we=function(){function t(){this.name="html-renderer"}var e=t.prototype;return e.init=function(t){t.load(me,!0)},e.destroy=function(t){t.unload(me)},t}(),xe=Object.freeze({__proto__:null,Plugin:we}),be=function(){function t(){this.$container=void 0,this.$canvas=void 0,this.dpr=void 0,this.context=void 0,this.canvasConfig=void 0}var n=t.prototype;return n.init=function(){var t=o(r().mark((function t(){var n,o,i,a,c,u;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=(n=this.canvasConfig).container,a=n.devicePixelRatio,(i=n.canvas)?(this.$canvas=i,o&&i.parentElement!==o&&o.appendChild(i),this.$container=i.parentElement,this.canvasConfig.container=this.$container):o&&(this.$container=e.isString(o)?document.getElementById(o):o,this.$container&&(c=document.createElement("canvas"),this.$container.appendChild(c),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=c)),this.context=this.$canvas.getContext("2d"),u=1>(u=a||e.isBrowser&&window.devicePixelRatio||1)?1:Math.ceil(u),this.dpr=u,this.resize(this.canvasConfig.width,this.canvasConfig.height);case 7:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getContext=function(){return this.context},n.getDomElement=function(){return this.$canvas},n.getDPR=function(){return this.dpr},n.getBoundingClientRect=function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()},n.destroy=function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)},n.resize=function(t,r){this.$canvas&&(this.$canvas.width=this.dpr*t,this.$canvas.height=this.dpr*r,e.setDOMSize(this.$canvas,t,r))},n.applyCursorStyle=function(t){this.$container&&this.$container.style&&(this.$container.style.cursor=t)},n.toDataURL=function(){var t=o(r().mark((function t(e){var n;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e&&(e={}),t.abrupt("return",this.context.canvas.toDataURL((n=e).type,n.encoderOptions));case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}();m([e.inject(e.CanvasConfig),w("design:type",Object)],be.prototype,"canvasConfig",void 0),be=m([e.singleton({token:e.ContextService})],be);var Ee=e.Module((function(t){t(be)})),Le=function(){function t(){this.name="canvas-context-register"}var e=t.prototype;return e.init=function(t){t.load(Ee,!0)},e.destroy=function(t){t.unload(Ee)},t}(),Pe=function(t){var e,r;function n(e){var r;return(r=t.call(this,e)||this).registerPlugin(new Le),r.registerPlugin(new yt),r.registerPlugin(new y),r.registerPlugin(new ne),r.registerPlugin(new fe),r.registerPlugin(new ut),r.registerPlugin(new we),r}return r=t,(e=n).prototype=Object.create(r.prototype),e.prototype.constructor=e,i(e,r),n}(e.AbstractRenderer);t.CanvasPathGenerator=g,t.CanvasPicker=st,t.CanvasRenderer=oe,t.DomInteraction=ve,t.HTMLRenderer=xe,t.ImageLoader=gt,t.Renderer=Pe,Object.defineProperty(t,"__esModule",{value:!0})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g-canvas",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "A renderer implemented by Canvas 2D API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antv",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"README.md"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@antv/g-plugin-canvas-path-generator": "^0.4.
|
|
34
|
-
"@antv/g-plugin-canvas-picker": "^1.5.
|
|
35
|
-
"@antv/g-plugin-canvas-renderer": "^1.5.
|
|
36
|
-
"@antv/g-plugin-dom-interaction": "^1.5.
|
|
37
|
-
"@antv/g-plugin-html-renderer": "^1.5.
|
|
38
|
-
"@antv/g-plugin-image-loader": "^0.4.
|
|
33
|
+
"@antv/g-plugin-canvas-path-generator": "^0.4.3",
|
|
34
|
+
"@antv/g-plugin-canvas-picker": "^1.5.3",
|
|
35
|
+
"@antv/g-plugin-canvas-renderer": "^1.5.3",
|
|
36
|
+
"@antv/g-plugin-dom-interaction": "^1.5.3",
|
|
37
|
+
"@antv/g-plugin-html-renderer": "^1.5.3",
|
|
38
|
+
"@antv/g-plugin-image-loader": "^0.4.3",
|
|
39
39
|
"tslib": "^2.3.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "8f7921e8e0875bbc6ef36099e995710733293efa"
|
|
52
52
|
}
|