@leafer-ui/miniapp 1.0.0-rc.5 → 1.0.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/miniapp.esm.js +158 -134
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.module.js +386 -235
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +6 -6
package/dist/miniapp.module.js
CHANGED
|
@@ -126,13 +126,13 @@ const MatrixHelper = {
|
|
|
126
126
|
t.d *= y;
|
|
127
127
|
},
|
|
128
128
|
scaleOfOuter(t, origin, x, y = x) {
|
|
129
|
-
M$
|
|
130
|
-
M$
|
|
129
|
+
M$6.toInnerPoint(t, origin, tempPoint$1);
|
|
130
|
+
M$6.scaleOfInner(t, tempPoint$1, x, y);
|
|
131
131
|
},
|
|
132
132
|
scaleOfInner(t, origin, x, y = x) {
|
|
133
|
-
M$
|
|
134
|
-
M$
|
|
135
|
-
M$
|
|
133
|
+
M$6.translateInner(t, origin.x, origin.y);
|
|
134
|
+
M$6.scale(t, x, y);
|
|
135
|
+
M$6.translateInner(t, -origin.x, -origin.y);
|
|
136
136
|
},
|
|
137
137
|
rotate(t, angle) {
|
|
138
138
|
angle *= OneRadian;
|
|
@@ -145,13 +145,13 @@ const MatrixHelper = {
|
|
|
145
145
|
t.d = (c * sinR) + (d * cosR);
|
|
146
146
|
},
|
|
147
147
|
rotateOfOuter(t, origin, angle) {
|
|
148
|
-
M$
|
|
149
|
-
M$
|
|
148
|
+
M$6.toInnerPoint(t, origin, tempPoint$1);
|
|
149
|
+
M$6.rotateOfInner(t, tempPoint$1, angle);
|
|
150
150
|
},
|
|
151
151
|
rotateOfInner(t, origin, angle) {
|
|
152
|
-
M$
|
|
153
|
-
M$
|
|
154
|
-
M$
|
|
152
|
+
M$6.translateInner(t, origin.x, origin.y);
|
|
153
|
+
M$6.rotate(t, angle);
|
|
154
|
+
M$6.translateInner(t, -origin.x, -origin.y);
|
|
155
155
|
},
|
|
156
156
|
skew(t, x, y) {
|
|
157
157
|
const { a, b, c, d } = t;
|
|
@@ -167,13 +167,13 @@ const MatrixHelper = {
|
|
|
167
167
|
}
|
|
168
168
|
},
|
|
169
169
|
skewOfOuter(t, origin, x, y) {
|
|
170
|
-
M$
|
|
171
|
-
M$
|
|
170
|
+
M$6.toInnerPoint(t, origin, tempPoint$1);
|
|
171
|
+
M$6.skewOfInner(t, tempPoint$1, x, y);
|
|
172
172
|
},
|
|
173
173
|
skewOfInner(t, origin, x, y) {
|
|
174
|
-
M$
|
|
175
|
-
M$
|
|
176
|
-
M$
|
|
174
|
+
M$6.translateInner(t, origin.x, origin.y);
|
|
175
|
+
M$6.skew(t, x, y);
|
|
176
|
+
M$6.translateInner(t, -origin.x, -origin.y);
|
|
177
177
|
},
|
|
178
178
|
multiply(t, matrix) {
|
|
179
179
|
const { a, b, c, d, e, f } = t;
|
|
@@ -196,12 +196,12 @@ const MatrixHelper = {
|
|
|
196
196
|
t.f = (e * matrix.b) + (f * matrix.d) + matrix.f;
|
|
197
197
|
},
|
|
198
198
|
divide(t, matrix) {
|
|
199
|
-
M$
|
|
199
|
+
M$6.preMultiply(t, M$6.tempInvert(matrix));
|
|
200
200
|
},
|
|
201
201
|
tempInvert(t) {
|
|
202
|
-
const { tempMatrix: temp } = M$
|
|
203
|
-
M$
|
|
204
|
-
M$
|
|
202
|
+
const { tempMatrix: temp } = M$6;
|
|
203
|
+
M$6.copy(temp, t);
|
|
204
|
+
M$6.invert(temp);
|
|
205
205
|
return temp;
|
|
206
206
|
},
|
|
207
207
|
invert(t) {
|
|
@@ -264,10 +264,10 @@ const MatrixHelper = {
|
|
|
264
264
|
return { x: t.e, y: t.f, scaleX, scaleY, rotation, skewX, skewY };
|
|
265
265
|
},
|
|
266
266
|
reset(t) {
|
|
267
|
-
M$
|
|
267
|
+
M$6.set(t);
|
|
268
268
|
}
|
|
269
269
|
};
|
|
270
|
-
const M$
|
|
270
|
+
const M$6 = MatrixHelper;
|
|
271
271
|
|
|
272
272
|
const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$2 } = MatrixHelper;
|
|
273
273
|
const { sin: sin$5, cos: cos$5, abs: abs$1, sqrt: sqrt$2, atan2: atan2$2 } = Math;
|
|
@@ -587,9 +587,7 @@ const BoundsHelper = {
|
|
|
587
587
|
}
|
|
588
588
|
B.move(to, -to.offsetX, -to.offsetY);
|
|
589
589
|
},
|
|
590
|
-
scale(t, scaleX, scaleY) {
|
|
591
|
-
if (!scaleY)
|
|
592
|
-
scaleY = scaleX;
|
|
590
|
+
scale(t, scaleX, scaleY = scaleX) {
|
|
593
591
|
if (t.x)
|
|
594
592
|
t.x *= scaleX;
|
|
595
593
|
if (t.y)
|
|
@@ -597,6 +595,12 @@ const BoundsHelper = {
|
|
|
597
595
|
t.width *= scaleX;
|
|
598
596
|
t.height *= scaleY;
|
|
599
597
|
},
|
|
598
|
+
scaleOf(t, origin, scaleX, scaleY) {
|
|
599
|
+
t.x += (t.x - origin.x) * (scaleX - 1);
|
|
600
|
+
t.y += (t.y - origin.y) * (scaleY - 1);
|
|
601
|
+
t.width *= scaleX;
|
|
602
|
+
t.height *= scaleY;
|
|
603
|
+
},
|
|
600
604
|
tempToOuterOf(t, matrix) {
|
|
601
605
|
B.copy(B.tempBounds, t);
|
|
602
606
|
B.toOuterOf(B.tempBounds, matrix);
|
|
@@ -788,6 +792,10 @@ class Bounds {
|
|
|
788
792
|
BoundsHelper.scale(this, scaleX, scaleY);
|
|
789
793
|
return this;
|
|
790
794
|
}
|
|
795
|
+
scaleOf(origin, scaleX, scaleY) {
|
|
796
|
+
BoundsHelper.scaleOf(this, origin, scaleX, scaleY);
|
|
797
|
+
return this;
|
|
798
|
+
}
|
|
791
799
|
toOuterOf(matrix, to) {
|
|
792
800
|
BoundsHelper.toOuterOf(this, matrix, to);
|
|
793
801
|
return this;
|
|
@@ -1340,14 +1348,22 @@ class LeafData {
|
|
|
1340
1348
|
if (this.__input && this.__input[name] !== undefined)
|
|
1341
1349
|
this.__input[name] = undefined;
|
|
1342
1350
|
}
|
|
1343
|
-
__getInputData() {
|
|
1351
|
+
__getInputData(options) {
|
|
1344
1352
|
const data = { tag: this.__leaf.tag }, { __input } = this;
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1353
|
+
if (options) {
|
|
1354
|
+
for (let key in this) {
|
|
1355
|
+
if (key[0] !== '_')
|
|
1356
|
+
data[key] = this[key];
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
else {
|
|
1360
|
+
let realKey, value;
|
|
1361
|
+
for (let key in this) {
|
|
1362
|
+
realKey = key.substring(1);
|
|
1363
|
+
if (this[realKey] !== undefined) {
|
|
1364
|
+
value = __input ? __input[realKey] : undefined;
|
|
1365
|
+
data[realKey] = value === undefined ? this[key] : value;
|
|
1366
|
+
}
|
|
1351
1367
|
}
|
|
1352
1368
|
}
|
|
1353
1369
|
return data;
|
|
@@ -2086,11 +2102,11 @@ const RectHelper = {
|
|
|
2086
2102
|
const { sin: sin$4, cos: cos$4, atan2: atan2$1, ceil, abs, PI: PI$2, sqrt: sqrt$1, pow } = Math;
|
|
2087
2103
|
const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
|
|
2088
2104
|
const { set: set$2 } = PointHelper;
|
|
2089
|
-
const { M: M$
|
|
2105
|
+
const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
|
|
2090
2106
|
const tempPoint = {};
|
|
2091
2107
|
const BezierHelper = {
|
|
2092
2108
|
points(data, points, curve, close) {
|
|
2093
|
-
data.push(M$
|
|
2109
|
+
data.push(M$5, points[0], points[1]);
|
|
2094
2110
|
if (curve && points.length > 5) {
|
|
2095
2111
|
let aX, aY, bX, bY, cX, cY, c1X, c1Y, c2X, c2Y;
|
|
2096
2112
|
let ba, cb, d, len = points.length;
|
|
@@ -2120,7 +2136,7 @@ const BezierHelper = {
|
|
|
2120
2136
|
data.push(Q$4, c1X, c1Y, bX, bY);
|
|
2121
2137
|
}
|
|
2122
2138
|
else {
|
|
2123
|
-
data.push(C$
|
|
2139
|
+
data.push(C$5, c2X, c2Y, c1X, c1Y, bX, bY);
|
|
2124
2140
|
}
|
|
2125
2141
|
c2X = bX + cb * cX;
|
|
2126
2142
|
c2Y = bY + cb * cY;
|
|
@@ -2130,11 +2146,11 @@ const BezierHelper = {
|
|
|
2130
2146
|
}
|
|
2131
2147
|
else {
|
|
2132
2148
|
for (let i = 2, len = points.length; i < len; i += 2) {
|
|
2133
|
-
data.push(L$
|
|
2149
|
+
data.push(L$6, points[i], points[i + 1]);
|
|
2134
2150
|
}
|
|
2135
2151
|
}
|
|
2136
2152
|
if (close)
|
|
2137
|
-
data.push(Z$
|
|
2153
|
+
data.push(Z$5);
|
|
2138
2154
|
},
|
|
2139
2155
|
rect(data, x, y, width, height) {
|
|
2140
2156
|
PathHelper.creator.path = data;
|
|
@@ -2157,7 +2173,7 @@ const BezierHelper = {
|
|
|
2157
2173
|
totalRadian += PI2;
|
|
2158
2174
|
if (totalRadian === PI$2 || (abs(BAx + BAy) < 1.e-12) || (abs(CBx + CBy) < 1.e-12)) {
|
|
2159
2175
|
if (data)
|
|
2160
|
-
data.push(L$
|
|
2176
|
+
data.push(L$6, x1, y1);
|
|
2161
2177
|
if (setPointBounds) {
|
|
2162
2178
|
setPoint$1(setPointBounds, fromX, fromY);
|
|
2163
2179
|
addPoint$1(setPointBounds, x1, y1);
|
|
@@ -2210,7 +2226,7 @@ const BezierHelper = {
|
|
|
2210
2226
|
let startY = y = rotationSin * radiusX * startCos + rotationCos * radiusY * startSin;
|
|
2211
2227
|
let fromX = cx + x, fromY = cy + y;
|
|
2212
2228
|
if (data)
|
|
2213
|
-
data.push(L$
|
|
2229
|
+
data.push(L$6, fromX, fromY);
|
|
2214
2230
|
if (setPointBounds)
|
|
2215
2231
|
setPoint$1(setPointBounds, fromX, fromY);
|
|
2216
2232
|
if (setStartPoint)
|
|
@@ -2225,7 +2241,7 @@ const BezierHelper = {
|
|
|
2225
2241
|
x2 = cx + x + control * (rotationCos * radiusX * endSin + rotationSin * radiusY * endCos);
|
|
2226
2242
|
y2 = cy + y + control * (rotationSin * radiusX * endSin - rotationCos * radiusY * endCos);
|
|
2227
2243
|
if (data)
|
|
2228
|
-
data.push(C$
|
|
2244
|
+
data.push(C$5, x1, y1, x2, y2, cx + x, cy + y);
|
|
2229
2245
|
if (setPointBounds)
|
|
2230
2246
|
toTwoPointBounds$1(cx + startX, cy + startY, x1, y1, x2, y2, cx + x, cy + y, setPointBounds, true);
|
|
2231
2247
|
startX = x;
|
|
@@ -2239,7 +2255,7 @@ const BezierHelper = {
|
|
|
2239
2255
|
set$2(setEndPoint, cx + x, cy + y);
|
|
2240
2256
|
},
|
|
2241
2257
|
quadraticCurveTo(data, fromX, fromY, x1, y1, toX, toY) {
|
|
2242
|
-
data.push(C$
|
|
2258
|
+
data.push(C$5, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY);
|
|
2243
2259
|
},
|
|
2244
2260
|
toTwoPointBoundsByQuadraticCurve(fromX, fromY, x1, y1, toX, toY, pointBounds, addMode) {
|
|
2245
2261
|
toTwoPointBounds$1(fromX, fromY, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY, pointBounds, addMode);
|
|
@@ -2333,7 +2349,7 @@ const EllipseHelper = {
|
|
|
2333
2349
|
const centerX = fromX + halfX + rotationCos * cx - rotationSin * cy;
|
|
2334
2350
|
const centerY = fromY + halfY + rotationSin * cx + rotationCos * cy;
|
|
2335
2351
|
const anticlockwise = totalRadian < 0 ? 1 : 0;
|
|
2336
|
-
if (curveMode || Platform.
|
|
2352
|
+
if (curveMode || Platform.ellipseToCurve) {
|
|
2337
2353
|
ellipse$5(data, centerX, centerY, radiusX, radiusY, rotation, startRadian / OneRadian, endRadian / OneRadian, anticlockwise);
|
|
2338
2354
|
}
|
|
2339
2355
|
else {
|
|
@@ -2347,7 +2363,7 @@ const EllipseHelper = {
|
|
|
2347
2363
|
}
|
|
2348
2364
|
};
|
|
2349
2365
|
|
|
2350
|
-
const { M: M$
|
|
2366
|
+
const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$4, c, S, s, Q: Q$3, q, T, t, A, a, Z: Z$4, z, N: N$3, D: D$3, X: X$3, G: G$3, F: F$3, O: O$3, P: P$3, U: U$4 } = PathCommandMap;
|
|
2351
2367
|
const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$2, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
|
|
2352
2368
|
const { ellipticalArc } = EllipseHelper;
|
|
2353
2369
|
const debug$a = Debug.get('PathConvert');
|
|
@@ -2435,33 +2451,33 @@ const PathConvert = {
|
|
|
2435
2451
|
case m:
|
|
2436
2452
|
old[i + 1] += x;
|
|
2437
2453
|
old[i + 2] += y;
|
|
2438
|
-
case M$
|
|
2454
|
+
case M$4:
|
|
2439
2455
|
x = old[i + 1];
|
|
2440
2456
|
y = old[i + 2];
|
|
2441
|
-
data.push(M$
|
|
2457
|
+
data.push(M$4, x, y);
|
|
2442
2458
|
i += 3;
|
|
2443
2459
|
break;
|
|
2444
2460
|
case h:
|
|
2445
2461
|
old[i + 1] += x;
|
|
2446
2462
|
case H:
|
|
2447
2463
|
x = old[i + 1];
|
|
2448
|
-
data.push(L$
|
|
2464
|
+
data.push(L$5, x, y);
|
|
2449
2465
|
i += 2;
|
|
2450
2466
|
break;
|
|
2451
2467
|
case v:
|
|
2452
2468
|
old[i + 1] += y;
|
|
2453
2469
|
case V:
|
|
2454
2470
|
y = old[i + 1];
|
|
2455
|
-
data.push(L$
|
|
2471
|
+
data.push(L$5, x, y);
|
|
2456
2472
|
i += 2;
|
|
2457
2473
|
break;
|
|
2458
2474
|
case l:
|
|
2459
2475
|
old[i + 1] += x;
|
|
2460
2476
|
old[i + 2] += y;
|
|
2461
|
-
case L$
|
|
2477
|
+
case L$5:
|
|
2462
2478
|
x = old[i + 1];
|
|
2463
2479
|
y = old[i + 2];
|
|
2464
|
-
data.push(L$
|
|
2480
|
+
data.push(L$5, x, y);
|
|
2465
2481
|
i += 3;
|
|
2466
2482
|
break;
|
|
2467
2483
|
case s:
|
|
@@ -2471,14 +2487,14 @@ const PathConvert = {
|
|
|
2471
2487
|
old[i + 4] += y;
|
|
2472
2488
|
command = S;
|
|
2473
2489
|
case S:
|
|
2474
|
-
smooth = (lastCommand === C$
|
|
2490
|
+
smooth = (lastCommand === C$4) || (lastCommand === S);
|
|
2475
2491
|
x1 = smooth ? (x * 2 - controlX) : old[i + 1];
|
|
2476
2492
|
y1 = smooth ? (y * 2 - controlY) : old[i + 2];
|
|
2477
2493
|
controlX = old[i + 1];
|
|
2478
2494
|
controlY = old[i + 2];
|
|
2479
2495
|
x = old[i + 3];
|
|
2480
2496
|
y = old[i + 4];
|
|
2481
|
-
data.push(C$
|
|
2497
|
+
data.push(C$4, x1, y1, controlX, controlY, x, y);
|
|
2482
2498
|
i += 5;
|
|
2483
2499
|
break;
|
|
2484
2500
|
case c:
|
|
@@ -2488,13 +2504,13 @@ const PathConvert = {
|
|
|
2488
2504
|
old[i + 4] += y;
|
|
2489
2505
|
old[i + 5] += x;
|
|
2490
2506
|
old[i + 6] += y;
|
|
2491
|
-
command = C$
|
|
2492
|
-
case C$
|
|
2507
|
+
command = C$4;
|
|
2508
|
+
case C$4:
|
|
2493
2509
|
controlX = old[i + 3];
|
|
2494
2510
|
controlY = old[i + 4];
|
|
2495
2511
|
x = old[i + 5];
|
|
2496
2512
|
y = old[i + 6];
|
|
2497
|
-
data.push(C$
|
|
2513
|
+
data.push(C$4, old[i + 1], old[i + 2], controlX, controlY, x, y);
|
|
2498
2514
|
i += 7;
|
|
2499
2515
|
break;
|
|
2500
2516
|
case t:
|
|
@@ -2534,8 +2550,8 @@ const PathConvert = {
|
|
|
2534
2550
|
i += 8;
|
|
2535
2551
|
break;
|
|
2536
2552
|
case z:
|
|
2537
|
-
case Z$
|
|
2538
|
-
data.push(Z$
|
|
2553
|
+
case Z$4:
|
|
2554
|
+
data.push(Z$4);
|
|
2539
2555
|
i++;
|
|
2540
2556
|
break;
|
|
2541
2557
|
case N$3:
|
|
@@ -2580,7 +2596,7 @@ const PathConvert = {
|
|
|
2580
2596
|
y = old[i + 2];
|
|
2581
2597
|
i += 4;
|
|
2582
2598
|
break;
|
|
2583
|
-
case U$
|
|
2599
|
+
case U$4:
|
|
2584
2600
|
arcTo$2(curveMode ? data : copyData(data, old, i, 6), x, y, old[i + 1], old[i + 2], old[i + 3], old[i + 4], old[i + 5], null, setEndPoint$1);
|
|
2585
2601
|
x = setEndPoint$1.x;
|
|
2586
2602
|
y = setEndPoint$1.y;
|
|
@@ -2611,26 +2627,26 @@ const PathConvert = {
|
|
|
2611
2627
|
};
|
|
2612
2628
|
const { current, pushData, copyData } = PathConvert;
|
|
2613
2629
|
|
|
2614
|
-
const { M: M$
|
|
2630
|
+
const { M: M$3, L: L$4, C: C$3, Q: Q$2, Z: Z$3, N: N$2, D: D$2, X: X$2, G: G$2, F: F$2, O: O$2, P: P$2, U: U$3 } = PathCommandMap;
|
|
2615
2631
|
const startPoint = {};
|
|
2616
2632
|
const PathCommandDataHelper = {
|
|
2617
2633
|
beginPath(data) {
|
|
2618
2634
|
data.length = 0;
|
|
2619
2635
|
},
|
|
2620
2636
|
moveTo(data, x, y) {
|
|
2621
|
-
data.push(M$
|
|
2637
|
+
data.push(M$3, x, y);
|
|
2622
2638
|
},
|
|
2623
2639
|
lineTo(data, x, y) {
|
|
2624
|
-
data.push(L$
|
|
2640
|
+
data.push(L$4, x, y);
|
|
2625
2641
|
},
|
|
2626
2642
|
bezierCurveTo(data, x1, y1, x2, y2, x, y) {
|
|
2627
|
-
data.push(C$
|
|
2643
|
+
data.push(C$3, x1, y1, x2, y2, x, y);
|
|
2628
2644
|
},
|
|
2629
2645
|
quadraticCurveTo(data, x1, y1, x, y) {
|
|
2630
2646
|
data.push(Q$2, x1, y1, x, y);
|
|
2631
2647
|
},
|
|
2632
2648
|
closePath(data) {
|
|
2633
|
-
data.push(Z$
|
|
2649
|
+
data.push(Z$3);
|
|
2634
2650
|
},
|
|
2635
2651
|
rect(data, x, y, width, height) {
|
|
2636
2652
|
data.push(N$2, x, y, width, height);
|
|
@@ -2672,7 +2688,7 @@ const PathCommandDataHelper = {
|
|
|
2672
2688
|
}
|
|
2673
2689
|
},
|
|
2674
2690
|
arcTo(data, x1, y1, x2, y2, radius) {
|
|
2675
|
-
data.push(U$
|
|
2691
|
+
data.push(U$3, x1, y1, x2, y2, radius);
|
|
2676
2692
|
},
|
|
2677
2693
|
drawEllipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2678
2694
|
if (rotation === undefined)
|
|
@@ -2682,7 +2698,7 @@ const PathCommandDataHelper = {
|
|
|
2682
2698
|
if (endAngle === undefined)
|
|
2683
2699
|
endAngle = 360;
|
|
2684
2700
|
BezierHelper.ellipse(null, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise, null, null, startPoint);
|
|
2685
|
-
data.push(M$
|
|
2701
|
+
data.push(M$3, startPoint.x, startPoint.y);
|
|
2686
2702
|
ellipse$3(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
|
|
2687
2703
|
},
|
|
2688
2704
|
drawArc(data, x, y, radius, startAngle, endAngle, anticlockwise) {
|
|
@@ -2691,7 +2707,7 @@ const PathCommandDataHelper = {
|
|
|
2691
2707
|
if (endAngle === undefined)
|
|
2692
2708
|
endAngle = 360;
|
|
2693
2709
|
BezierHelper.arc(null, x, y, radius, startAngle, endAngle, anticlockwise, null, null, startPoint);
|
|
2694
|
-
data.push(M$
|
|
2710
|
+
data.push(M$3, startPoint.x, startPoint.y);
|
|
2695
2711
|
arc$2(data, x, y, radius, startAngle, endAngle, anticlockwise);
|
|
2696
2712
|
},
|
|
2697
2713
|
drawPoints(data, points, curve, close) {
|
|
@@ -2768,7 +2784,7 @@ class PathCreator {
|
|
|
2768
2784
|
}
|
|
2769
2785
|
}
|
|
2770
2786
|
|
|
2771
|
-
const { M: M$
|
|
2787
|
+
const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$1, O: O$1, P: P$1, U: U$2 } = PathCommandMap;
|
|
2772
2788
|
const debug$9 = Debug.get('PathDrawer');
|
|
2773
2789
|
const PathDrawer = {
|
|
2774
2790
|
drawPathByData(drawer, data) {
|
|
@@ -2779,15 +2795,15 @@ const PathDrawer = {
|
|
|
2779
2795
|
while (i < len) {
|
|
2780
2796
|
command = data[i];
|
|
2781
2797
|
switch (command) {
|
|
2782
|
-
case M$
|
|
2798
|
+
case M$2:
|
|
2783
2799
|
drawer.moveTo(data[i + 1], data[i + 2]);
|
|
2784
2800
|
i += 3;
|
|
2785
2801
|
break;
|
|
2786
|
-
case L$
|
|
2802
|
+
case L$3:
|
|
2787
2803
|
drawer.lineTo(data[i + 1], data[i + 2]);
|
|
2788
2804
|
i += 3;
|
|
2789
2805
|
break;
|
|
2790
|
-
case C$
|
|
2806
|
+
case C$2:
|
|
2791
2807
|
drawer.bezierCurveTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
|
|
2792
2808
|
i += 7;
|
|
2793
2809
|
break;
|
|
@@ -2795,7 +2811,7 @@ const PathDrawer = {
|
|
|
2795
2811
|
drawer.quadraticCurveTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4]);
|
|
2796
2812
|
i += 5;
|
|
2797
2813
|
break;
|
|
2798
|
-
case Z$
|
|
2814
|
+
case Z$2:
|
|
2799
2815
|
drawer.closePath();
|
|
2800
2816
|
i += 1;
|
|
2801
2817
|
break;
|
|
@@ -2827,7 +2843,7 @@ const PathDrawer = {
|
|
|
2827
2843
|
drawer.arc(data[i + 1], data[i + 2], data[i + 3], 0, PI2, false);
|
|
2828
2844
|
i += 4;
|
|
2829
2845
|
break;
|
|
2830
|
-
case U$
|
|
2846
|
+
case U$2:
|
|
2831
2847
|
drawer.arcTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5]);
|
|
2832
2848
|
i += 6;
|
|
2833
2849
|
break;
|
|
@@ -2839,7 +2855,7 @@ const PathDrawer = {
|
|
|
2839
2855
|
}
|
|
2840
2856
|
};
|
|
2841
2857
|
|
|
2842
|
-
const { M, L: L$
|
|
2858
|
+
const { M: M$1, L: L$2, C: C$1, Q, Z: Z$1, N, D, X, G, F, O, P, U: U$1 } = PathCommandMap;
|
|
2843
2859
|
const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo, arc, ellipse: ellipse$1 } = BezierHelper;
|
|
2844
2860
|
const { add: add$1, copy: copy$6, addPoint, setPoint, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
|
|
2845
2861
|
const debug$8 = Debug.get('PathBounds');
|
|
@@ -2861,7 +2877,7 @@ const PathBounds = {
|
|
|
2861
2877
|
while (i < len) {
|
|
2862
2878
|
command = data[i];
|
|
2863
2879
|
if (i === 0) {
|
|
2864
|
-
if (command === Z || command === C || command === Q) {
|
|
2880
|
+
if (command === Z$1 || command === C$1 || command === Q) {
|
|
2865
2881
|
setPoint(setPointBounds, x, y);
|
|
2866
2882
|
}
|
|
2867
2883
|
else {
|
|
@@ -2869,14 +2885,14 @@ const PathBounds = {
|
|
|
2869
2885
|
}
|
|
2870
2886
|
}
|
|
2871
2887
|
switch (command) {
|
|
2872
|
-
case M:
|
|
2873
|
-
case L$
|
|
2888
|
+
case M$1:
|
|
2889
|
+
case L$2:
|
|
2874
2890
|
x = data[i + 1];
|
|
2875
2891
|
y = data[i + 2];
|
|
2876
2892
|
addPoint(setPointBounds, x, y);
|
|
2877
2893
|
i += 3;
|
|
2878
2894
|
break;
|
|
2879
|
-
case C:
|
|
2895
|
+
case C$1:
|
|
2880
2896
|
toX = data[i + 5];
|
|
2881
2897
|
toY = data[i + 6];
|
|
2882
2898
|
toTwoPointBounds(x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], toX, toY, tempPointBounds);
|
|
@@ -2896,7 +2912,7 @@ const PathBounds = {
|
|
|
2896
2912
|
y = toY;
|
|
2897
2913
|
i += 5;
|
|
2898
2914
|
break;
|
|
2899
|
-
case Z:
|
|
2915
|
+
case Z$1:
|
|
2900
2916
|
i += 1;
|
|
2901
2917
|
break;
|
|
2902
2918
|
case N:
|
|
@@ -2943,7 +2959,7 @@ const PathBounds = {
|
|
|
2943
2959
|
x += radius;
|
|
2944
2960
|
i += 4;
|
|
2945
2961
|
break;
|
|
2946
|
-
case U:
|
|
2962
|
+
case U$1:
|
|
2947
2963
|
arcTo(null, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], tempPointBounds, setEndPoint);
|
|
2948
2964
|
i === 0 ? copy$6(setPointBounds, tempPointBounds) : add$1(setPointBounds, tempPointBounds);
|
|
2949
2965
|
x = setEndPoint.x;
|
|
@@ -2958,9 +2974,60 @@ const PathBounds = {
|
|
|
2958
2974
|
}
|
|
2959
2975
|
};
|
|
2960
2976
|
|
|
2977
|
+
const { M, L: L$1, C, Z, U } = PathCommandMap;
|
|
2961
2978
|
const PathCorner = {
|
|
2962
|
-
smooth(data,
|
|
2963
|
-
|
|
2979
|
+
smooth(data, cornerRadius, _cornerSmoothing) {
|
|
2980
|
+
let command;
|
|
2981
|
+
let i = 0, x = 0, y = 0, startX, startY = 0, centerX = 0, centerY = 0;
|
|
2982
|
+
const len = data.length;
|
|
2983
|
+
const smooth = [];
|
|
2984
|
+
while (i < len) {
|
|
2985
|
+
command = data[i];
|
|
2986
|
+
switch (command) {
|
|
2987
|
+
case M:
|
|
2988
|
+
startX = data[i + 1];
|
|
2989
|
+
startY = data[i + 2];
|
|
2990
|
+
i += 3;
|
|
2991
|
+
if (data[i] === L$1) {
|
|
2992
|
+
centerX = startX + (data[i + 1] - startX) / 2;
|
|
2993
|
+
centerY = startY + (data[i + 2] - startY) / 2;
|
|
2994
|
+
smooth.push(M, centerX, centerY);
|
|
2995
|
+
}
|
|
2996
|
+
else {
|
|
2997
|
+
smooth.push(M, startX, startY);
|
|
2998
|
+
}
|
|
2999
|
+
break;
|
|
3000
|
+
case L$1:
|
|
3001
|
+
x = data[i + 1];
|
|
3002
|
+
y = data[i + 2];
|
|
3003
|
+
i += 3;
|
|
3004
|
+
switch (data[i]) {
|
|
3005
|
+
case L$1:
|
|
3006
|
+
smooth.push(U, x, y, data[i + 1], data[i + 2], cornerRadius);
|
|
3007
|
+
break;
|
|
3008
|
+
case Z:
|
|
3009
|
+
smooth.push(U, x, y, startX, startY, cornerRadius);
|
|
3010
|
+
break;
|
|
3011
|
+
default:
|
|
3012
|
+
smooth.push(L$1, x, y);
|
|
3013
|
+
}
|
|
3014
|
+
break;
|
|
3015
|
+
case C:
|
|
3016
|
+
smooth.push(C, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
|
|
3017
|
+
i += 7;
|
|
3018
|
+
break;
|
|
3019
|
+
case Z:
|
|
3020
|
+
smooth.push(U, startX, startY, centerX, centerY, cornerRadius);
|
|
3021
|
+
smooth.push(Z);
|
|
3022
|
+
i += 1;
|
|
3023
|
+
break;
|
|
3024
|
+
}
|
|
3025
|
+
}
|
|
3026
|
+
if (command !== Z) {
|
|
3027
|
+
smooth[1] = startX;
|
|
3028
|
+
smooth[2] = startY;
|
|
3029
|
+
}
|
|
3030
|
+
return smooth;
|
|
2964
3031
|
}
|
|
2965
3032
|
};
|
|
2966
3033
|
|
|
@@ -3012,9 +3079,7 @@ class TaskItem {
|
|
|
3012
3079
|
}
|
|
3013
3080
|
|
|
3014
3081
|
class TaskProcessor {
|
|
3015
|
-
get total() {
|
|
3016
|
-
return this.list.length + this.delayNumber;
|
|
3017
|
-
}
|
|
3082
|
+
get total() { return this.list.length + this.delayNumber; }
|
|
3018
3083
|
get finishedIndex() {
|
|
3019
3084
|
return this.isComplete ? 0 : this.index + this.parallelSuccessNumber;
|
|
3020
3085
|
}
|
|
@@ -3070,8 +3135,10 @@ class TaskProcessor {
|
|
|
3070
3135
|
else {
|
|
3071
3136
|
this.delayNumber++;
|
|
3072
3137
|
setTimeout(() => {
|
|
3073
|
-
this.delayNumber
|
|
3074
|
-
|
|
3138
|
+
if (this.delayNumber) {
|
|
3139
|
+
this.delayNumber--;
|
|
3140
|
+
this.push(task, start);
|
|
3141
|
+
}
|
|
3075
3142
|
}, delay);
|
|
3076
3143
|
}
|
|
3077
3144
|
this.isComplete = false;
|
|
@@ -3088,6 +3155,7 @@ class TaskProcessor {
|
|
|
3088
3155
|
this.parallelSuccessNumber = 0;
|
|
3089
3156
|
this.list = [];
|
|
3090
3157
|
this.parallelList = [];
|
|
3158
|
+
this.delayNumber = 0;
|
|
3091
3159
|
}
|
|
3092
3160
|
start() {
|
|
3093
3161
|
if (!this.running) {
|
|
@@ -4137,6 +4205,17 @@ const LeafHelper = {
|
|
|
4137
4205
|
parent.worldToInner(position);
|
|
4138
4206
|
t.set(position);
|
|
4139
4207
|
parent.add(t);
|
|
4208
|
+
},
|
|
4209
|
+
hasParent(t, parent) {
|
|
4210
|
+
if (!parent)
|
|
4211
|
+
return false;
|
|
4212
|
+
let p = t;
|
|
4213
|
+
while (p) {
|
|
4214
|
+
if (parent === p)
|
|
4215
|
+
return true;
|
|
4216
|
+
p = p.parent;
|
|
4217
|
+
}
|
|
4218
|
+
return false;
|
|
4140
4219
|
}
|
|
4141
4220
|
};
|
|
4142
4221
|
const L = LeafHelper;
|
|
@@ -5213,6 +5292,8 @@ const LeafDataProxy = {
|
|
|
5213
5292
|
const oldValue = this.__.__getInput(name);
|
|
5214
5293
|
if (typeof newValue === 'object' || oldValue !== newValue) {
|
|
5215
5294
|
this.__[name] = newValue;
|
|
5295
|
+
if (this.proxyData)
|
|
5296
|
+
this.setProxyAttr(name, newValue);
|
|
5216
5297
|
const { CHANGE } = PropertyEvent;
|
|
5217
5298
|
const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue);
|
|
5218
5299
|
if (this.hasEvent(CHANGE) && !this.isLeafer)
|
|
@@ -5222,10 +5303,21 @@ const LeafDataProxy = {
|
|
|
5222
5303
|
}
|
|
5223
5304
|
else {
|
|
5224
5305
|
this.__[name] = newValue;
|
|
5306
|
+
if (this.proxyData)
|
|
5307
|
+
this.setProxyAttr(name, newValue);
|
|
5225
5308
|
}
|
|
5226
5309
|
},
|
|
5227
5310
|
__getAttr(name) {
|
|
5311
|
+
if (this.proxyData)
|
|
5312
|
+
return this.getProxyAttr(name);
|
|
5228
5313
|
return this.__.__get(name);
|
|
5314
|
+
},
|
|
5315
|
+
setProxyAttr(name, newValue) {
|
|
5316
|
+
if (this.proxyData[name] !== newValue)
|
|
5317
|
+
this.proxyData[name] = newValue;
|
|
5318
|
+
},
|
|
5319
|
+
getProxyAttr(name) {
|
|
5320
|
+
return this.proxyData[name];
|
|
5229
5321
|
}
|
|
5230
5322
|
};
|
|
5231
5323
|
|
|
@@ -5435,6 +5527,10 @@ const LeafHit = {
|
|
|
5435
5527
|
setRadius(point, this.__.hitRadius);
|
|
5436
5528
|
}
|
|
5437
5529
|
toInnerRadiusPointOf(point, this.__world, inner);
|
|
5530
|
+
if (this.__.hitBox) {
|
|
5531
|
+
if (BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner))
|
|
5532
|
+
return true;
|
|
5533
|
+
}
|
|
5438
5534
|
return this.__hit(inner);
|
|
5439
5535
|
},
|
|
5440
5536
|
__drawHitPath(canvas) {
|
|
@@ -5478,12 +5574,21 @@ const LeafMask = {
|
|
|
5478
5574
|
__updateMask(value) {
|
|
5479
5575
|
this.__hasMask = value ? true : this.children.some(item => item.__.isMask);
|
|
5480
5576
|
},
|
|
5481
|
-
__renderMask(canvas, content, mask) {
|
|
5577
|
+
__renderMask(canvas, content, mask, recycle) {
|
|
5578
|
+
content.opacity = 1;
|
|
5482
5579
|
content.resetTransform();
|
|
5483
5580
|
content.useMask(mask);
|
|
5484
|
-
canvas.resetTransform();
|
|
5485
5581
|
canvas.opacity = this.__worldOpacity;
|
|
5582
|
+
canvas.resetTransform();
|
|
5486
5583
|
canvas.copyWorld(content);
|
|
5584
|
+
if (recycle) {
|
|
5585
|
+
content.recycle();
|
|
5586
|
+
mask.recycle();
|
|
5587
|
+
}
|
|
5588
|
+
else {
|
|
5589
|
+
content.clear();
|
|
5590
|
+
mask.clear();
|
|
5591
|
+
}
|
|
5487
5592
|
},
|
|
5488
5593
|
__removeMask(child) {
|
|
5489
5594
|
if (child) {
|
|
@@ -5538,15 +5643,13 @@ const BranchRender = {
|
|
|
5538
5643
|
const { children } = this;
|
|
5539
5644
|
if (this.__hasMask && children.length > 1) {
|
|
5540
5645
|
let mask;
|
|
5541
|
-
|
|
5542
|
-
|
|
5646
|
+
const maskCanvas = canvas.getSameCanvas();
|
|
5647
|
+
const contentCanvas = canvas.getSameCanvas();
|
|
5543
5648
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
5544
5649
|
child = children[i];
|
|
5545
5650
|
if (child.isMask) {
|
|
5546
5651
|
if (mask) {
|
|
5547
5652
|
this.__renderMask(canvas, contentCanvas, maskCanvas);
|
|
5548
|
-
maskCanvas.clear();
|
|
5549
|
-
contentCanvas.clear();
|
|
5550
5653
|
}
|
|
5551
5654
|
else {
|
|
5552
5655
|
mask = true;
|
|
@@ -5554,11 +5657,9 @@ const BranchRender = {
|
|
|
5554
5657
|
child.__render(maskCanvas, options);
|
|
5555
5658
|
continue;
|
|
5556
5659
|
}
|
|
5557
|
-
child.__render(contentCanvas, options);
|
|
5660
|
+
child.__render(mask ? contentCanvas : canvas, options);
|
|
5558
5661
|
}
|
|
5559
|
-
this.__renderMask(canvas, contentCanvas, maskCanvas);
|
|
5560
|
-
maskCanvas.recycle();
|
|
5561
|
-
contentCanvas.recycle();
|
|
5662
|
+
this.__renderMask(canvas, contentCanvas, maskCanvas, true);
|
|
5562
5663
|
}
|
|
5563
5664
|
else {
|
|
5564
5665
|
const { bounds, hideBounds } = options;
|
|
@@ -5652,6 +5753,7 @@ let Leaf = class Leaf {
|
|
|
5652
5753
|
}
|
|
5653
5754
|
}
|
|
5654
5755
|
set(_data) { }
|
|
5756
|
+
get(_options) { return undefined; }
|
|
5655
5757
|
toJSON() {
|
|
5656
5758
|
return this.__.__getInputData();
|
|
5657
5759
|
}
|
|
@@ -5660,6 +5762,10 @@ let Leaf = class Leaf {
|
|
|
5660
5762
|
}
|
|
5661
5763
|
__setAttr(_attrName, _newValue) { }
|
|
5662
5764
|
__getAttr(_attrName) { return undefined; }
|
|
5765
|
+
setProxyAttr(_attrName, _newValue) { }
|
|
5766
|
+
getProxyAttr(_attrName) { return undefined; }
|
|
5767
|
+
find(_condition) { return undefined; }
|
|
5768
|
+
findOne(_condition) { return undefined; }
|
|
5663
5769
|
forceUpdate(attrName) {
|
|
5664
5770
|
if (attrName === undefined)
|
|
5665
5771
|
attrName = 'width';
|
|
@@ -5684,7 +5790,7 @@ let Leaf = class Leaf {
|
|
|
5684
5790
|
__onUpdateSize() { }
|
|
5685
5791
|
__updateEraser(_value) { }
|
|
5686
5792
|
__updateMask(_value) { }
|
|
5687
|
-
__renderMask(_canvas, _content, _mask) { }
|
|
5793
|
+
__renderMask(_canvas, _content, _mask, _recycle) { }
|
|
5688
5794
|
__removeMask(_child) { }
|
|
5689
5795
|
getWorld(attrName) {
|
|
5690
5796
|
this.__layout.checkUpdate();
|
|
@@ -6541,7 +6647,7 @@ class Renderer {
|
|
|
6541
6647
|
}
|
|
6542
6648
|
|
|
6543
6649
|
const { hitRadiusPoint } = BoundsHelper;
|
|
6544
|
-
class
|
|
6650
|
+
class Pather {
|
|
6545
6651
|
constructor(target, selector) {
|
|
6546
6652
|
this.target = target;
|
|
6547
6653
|
this.selector = selector;
|
|
@@ -6661,117 +6767,108 @@ class FindPath {
|
|
|
6661
6767
|
class Selector {
|
|
6662
6768
|
constructor(target, userConfig) {
|
|
6663
6769
|
this.config = {};
|
|
6664
|
-
this.
|
|
6665
|
-
this.
|
|
6666
|
-
this.
|
|
6667
|
-
|
|
6770
|
+
this.innerIdMap = {};
|
|
6771
|
+
this.idMap = {};
|
|
6772
|
+
this.methods = {
|
|
6773
|
+
id: (leaf, name) => leaf.id === name ? this.idMap[name] = leaf : 0,
|
|
6774
|
+
innerId: (leaf, innerId) => leaf.innerId === innerId ? this.innerIdMap[innerId] = leaf : 0,
|
|
6775
|
+
className: (leaf, name) => leaf.className === name ? 1 : 0,
|
|
6776
|
+
tag: (leaf, name) => leaf.__tag === name ? 1 : 0
|
|
6777
|
+
};
|
|
6668
6778
|
this.target = target;
|
|
6669
6779
|
if (userConfig)
|
|
6670
6780
|
this.config = DataHelper.default(userConfig, this.config);
|
|
6671
|
-
this.
|
|
6781
|
+
this.pather = new Pather(target, this);
|
|
6672
6782
|
this.__listenEvents();
|
|
6673
6783
|
}
|
|
6674
6784
|
getByPoint(hitPoint, hitRadius, options) {
|
|
6675
6785
|
if (Platform.name === 'node')
|
|
6676
6786
|
this.target.emit(LayoutEvent.CHECK_UPDATE);
|
|
6677
|
-
return this.
|
|
6678
|
-
}
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6787
|
+
return this.pather.getByPoint(hitPoint, hitRadius, options);
|
|
6788
|
+
}
|
|
6789
|
+
getBy(condition, branch, one, options) {
|
|
6790
|
+
switch (typeof condition) {
|
|
6791
|
+
case 'number':
|
|
6792
|
+
const leaf = this.getByInnerId(condition, branch);
|
|
6793
|
+
return one ? leaf : (leaf ? [leaf] : []);
|
|
6794
|
+
case 'string':
|
|
6795
|
+
switch (condition[0]) {
|
|
6796
|
+
case '#':
|
|
6797
|
+
const leaf = this.getById(condition.substring(1), branch);
|
|
6798
|
+
return one ? leaf : (leaf ? [leaf] : []);
|
|
6799
|
+
case '.':
|
|
6800
|
+
return this.getByMethod(this.methods.className, branch, one, condition.substring(1));
|
|
6801
|
+
default:
|
|
6802
|
+
return this.getByMethod(this.methods.tag, branch, one, condition);
|
|
6803
|
+
}
|
|
6804
|
+
case 'function':
|
|
6805
|
+
return this.getByMethod(condition, branch, one, options);
|
|
6691
6806
|
}
|
|
6692
6807
|
}
|
|
6693
|
-
getByInnerId(
|
|
6694
|
-
|
|
6808
|
+
getByInnerId(innerId, branch) {
|
|
6809
|
+
const cache = this.innerIdMap[innerId];
|
|
6695
6810
|
if (cache)
|
|
6696
6811
|
return cache;
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
let find;
|
|
6700
|
-
this.loopFind(branch, (leaf) => {
|
|
6701
|
-
if (leaf.innerId === name) {
|
|
6702
|
-
find = leaf;
|
|
6703
|
-
this.innerIdList[name] = find;
|
|
6704
|
-
return true;
|
|
6705
|
-
}
|
|
6706
|
-
else {
|
|
6707
|
-
return false;
|
|
6708
|
-
}
|
|
6709
|
-
});
|
|
6710
|
-
return find;
|
|
6812
|
+
this.eachFind(this.toChildren(branch), this.methods.innerId, null, innerId);
|
|
6813
|
+
return this.findLeaf;
|
|
6711
6814
|
}
|
|
6712
|
-
getById(
|
|
6713
|
-
|
|
6714
|
-
if (cache)
|
|
6815
|
+
getById(id, branch) {
|
|
6816
|
+
const cache = this.idMap[id];
|
|
6817
|
+
if (cache && LeafHelper.hasParent(cache, branch || this.target))
|
|
6715
6818
|
return cache;
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
let find;
|
|
6719
|
-
this.loopFind(branch, (leaf) => {
|
|
6720
|
-
if (leaf.id === name) {
|
|
6721
|
-
find = leaf;
|
|
6722
|
-
this.idList[name] = find;
|
|
6723
|
-
return true;
|
|
6724
|
-
}
|
|
6725
|
-
else {
|
|
6726
|
-
return false;
|
|
6727
|
-
}
|
|
6728
|
-
});
|
|
6729
|
-
return find;
|
|
6819
|
+
this.eachFind(this.toChildren(branch), this.methods.id, null, id);
|
|
6820
|
+
return this.findLeaf;
|
|
6730
6821
|
}
|
|
6731
|
-
getByClassName(
|
|
6732
|
-
|
|
6733
|
-
branch = this.target;
|
|
6734
|
-
let find = [];
|
|
6735
|
-
this.loopFind(branch, (leaf) => {
|
|
6736
|
-
if (leaf.className === name)
|
|
6737
|
-
find.push(leaf);
|
|
6738
|
-
return false;
|
|
6739
|
-
});
|
|
6740
|
-
return find;
|
|
6822
|
+
getByClassName(className, branch) {
|
|
6823
|
+
return this.getByMethod(this.methods.className, branch, false, className);
|
|
6741
6824
|
}
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
branch = this.target;
|
|
6745
|
-
let find = [];
|
|
6746
|
-
this.loopFind(branch, (leaf) => {
|
|
6747
|
-
if (leaf.__tag === name)
|
|
6748
|
-
find.push(leaf);
|
|
6749
|
-
return false;
|
|
6750
|
-
});
|
|
6751
|
-
return find;
|
|
6825
|
+
getByTag(tag, branch) {
|
|
6826
|
+
return this.getByMethod(this.methods.tag, branch, false, tag);
|
|
6752
6827
|
}
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6828
|
+
getByMethod(method, branch, one, options) {
|
|
6829
|
+
const list = one ? null : [];
|
|
6830
|
+
this.eachFind(this.toChildren(branch), method, list, options);
|
|
6831
|
+
return list || this.findLeaf;
|
|
6832
|
+
}
|
|
6833
|
+
eachFind(children, method, list, options) {
|
|
6834
|
+
let child;
|
|
6757
6835
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
6758
|
-
|
|
6759
|
-
if (
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6836
|
+
child = children[i];
|
|
6837
|
+
if (method(child, options)) {
|
|
6838
|
+
if (list) {
|
|
6839
|
+
list.push(child);
|
|
6840
|
+
}
|
|
6841
|
+
else {
|
|
6842
|
+
this.findLeaf = child;
|
|
6843
|
+
return;
|
|
6844
|
+
}
|
|
6845
|
+
}
|
|
6846
|
+
if (child.isBranch)
|
|
6847
|
+
this.eachFind(child.children, method, list, options);
|
|
6763
6848
|
}
|
|
6764
6849
|
}
|
|
6850
|
+
toChildren(branch) {
|
|
6851
|
+
this.findLeaf = null;
|
|
6852
|
+
return [branch || this.target];
|
|
6853
|
+
}
|
|
6765
6854
|
__onRemoveChild(event) {
|
|
6766
|
-
const
|
|
6767
|
-
if (this.
|
|
6768
|
-
this.
|
|
6769
|
-
if (this.
|
|
6770
|
-
this.
|
|
6855
|
+
const { id, innerId } = event.child;
|
|
6856
|
+
if (this.idMap[id])
|
|
6857
|
+
delete this.idMap[id];
|
|
6858
|
+
if (this.innerIdMap[innerId])
|
|
6859
|
+
delete this.innerIdMap[innerId];
|
|
6860
|
+
}
|
|
6861
|
+
__checkIdChange(event) {
|
|
6862
|
+
if (event.attrName === 'id') {
|
|
6863
|
+
const id = event.oldValue;
|
|
6864
|
+
if (this.idMap[id])
|
|
6865
|
+
delete this.idMap[id];
|
|
6866
|
+
}
|
|
6771
6867
|
}
|
|
6772
6868
|
__listenEvents() {
|
|
6773
6869
|
this.__eventIds = [
|
|
6774
|
-
this.target.on_(ChildEvent.REMOVE, this.__onRemoveChild, this)
|
|
6870
|
+
this.target.on_(ChildEvent.REMOVE, this.__onRemoveChild, this),
|
|
6871
|
+
this.target.on_(PropertyEvent.CHANGE, this.__checkIdChange, this)
|
|
6775
6872
|
];
|
|
6776
6873
|
}
|
|
6777
6874
|
__removeListenEvents() {
|
|
@@ -6781,11 +6878,10 @@ class Selector {
|
|
|
6781
6878
|
destroy() {
|
|
6782
6879
|
if (this.__eventIds.length) {
|
|
6783
6880
|
this.__removeListenEvents();
|
|
6784
|
-
this.
|
|
6785
|
-
this.
|
|
6786
|
-
this.
|
|
6787
|
-
this.
|
|
6788
|
-
this.tagNameList = {};
|
|
6881
|
+
this.pather.destroy();
|
|
6882
|
+
this.findLeaf = null;
|
|
6883
|
+
this.innerIdMap = {};
|
|
6884
|
+
this.idMap = {};
|
|
6789
6885
|
}
|
|
6790
6886
|
}
|
|
6791
6887
|
}
|
|
@@ -7573,8 +7669,15 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7573
7669
|
set(data) {
|
|
7574
7670
|
Object.assign(this, data);
|
|
7575
7671
|
}
|
|
7576
|
-
get() {
|
|
7577
|
-
return this.__.__getInputData();
|
|
7672
|
+
get(options) {
|
|
7673
|
+
return this.__.__getInputData(options);
|
|
7674
|
+
}
|
|
7675
|
+
getProxyData() { return undefined; }
|
|
7676
|
+
find(condition) {
|
|
7677
|
+
return this.leafer ? this.leafer.selector.getBy(condition, this) : [];
|
|
7678
|
+
}
|
|
7679
|
+
findOne(condition) {
|
|
7680
|
+
return this.leafer ? this.leafer.selector.getBy(condition, this, true) : null;
|
|
7578
7681
|
}
|
|
7579
7682
|
getPath(curve) {
|
|
7580
7683
|
const path = this.__.path;
|
|
@@ -7698,6 +7801,9 @@ __decorate([
|
|
|
7698
7801
|
__decorate([
|
|
7699
7802
|
strokeType('path')
|
|
7700
7803
|
], UI.prototype, "hitStroke", void 0);
|
|
7804
|
+
__decorate([
|
|
7805
|
+
hitType(false)
|
|
7806
|
+
], UI.prototype, "hitBox", void 0);
|
|
7701
7807
|
__decorate([
|
|
7702
7808
|
hitType(true)
|
|
7703
7809
|
], UI.prototype, "hitChildren", void 0);
|
|
@@ -8006,7 +8112,7 @@ let Ellipse = class Ellipse extends UI {
|
|
|
8006
8112
|
}
|
|
8007
8113
|
ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
|
|
8008
8114
|
}
|
|
8009
|
-
if (Platform.
|
|
8115
|
+
if (Platform.ellipseToCurve)
|
|
8010
8116
|
this.__.path = PathConvert.toCanvasData(path, true);
|
|
8011
8117
|
}
|
|
8012
8118
|
else {
|
|
@@ -8317,7 +8423,7 @@ Canvas = __decorate([
|
|
|
8317
8423
|
registerUI()
|
|
8318
8424
|
], Canvas);
|
|
8319
8425
|
|
|
8320
|
-
const { copyAndSpread, includes, spread } = BoundsHelper;
|
|
8426
|
+
const { copyAndSpread, includes, spread, setByList } = BoundsHelper;
|
|
8321
8427
|
let Text = class Text extends UI {
|
|
8322
8428
|
get __tag() { return 'Text'; }
|
|
8323
8429
|
get textDrawData() {
|
|
@@ -8351,18 +8457,19 @@ let Text = class Text extends UI {
|
|
|
8351
8457
|
__updateBoxBounds() {
|
|
8352
8458
|
const data = this.__;
|
|
8353
8459
|
const layout = this.__layout;
|
|
8354
|
-
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase } = data;
|
|
8460
|
+
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow } = data;
|
|
8461
|
+
const width = data.__getInput('width');
|
|
8462
|
+
const height = data.__getInput('height');
|
|
8355
8463
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
8356
8464
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
8357
8465
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
|
|
8358
8466
|
data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
|
|
8467
|
+
data.__clipText = textOverflow !== 'show' && (width || height);
|
|
8359
8468
|
this.__updateTextDrawData();
|
|
8360
8469
|
const { bounds } = data.__textDrawData;
|
|
8361
8470
|
const b = layout.boxBounds;
|
|
8362
8471
|
if (data.__lineHeight < fontSize)
|
|
8363
8472
|
spread(bounds, fontSize / 2);
|
|
8364
|
-
const width = data.__getInput('width');
|
|
8365
|
-
const height = data.__getInput('height');
|
|
8366
8473
|
if (width && height) {
|
|
8367
8474
|
super.__updateBoxBounds();
|
|
8368
8475
|
}
|
|
@@ -8377,6 +8484,10 @@ let Text = class Text extends UI {
|
|
|
8377
8484
|
if (contentBounds !== layout.contentBounds) {
|
|
8378
8485
|
layout.contentBounds = contentBounds;
|
|
8379
8486
|
layout.renderChanged = true;
|
|
8487
|
+
setByList(data.__textBoxBounds = {}, [b, bounds]);
|
|
8488
|
+
}
|
|
8489
|
+
else {
|
|
8490
|
+
data.__textBoxBounds = contentBounds;
|
|
8380
8491
|
}
|
|
8381
8492
|
}
|
|
8382
8493
|
__updateRenderSpread() {
|
|
@@ -8386,7 +8497,7 @@ let Text = class Text extends UI {
|
|
|
8386
8497
|
return width;
|
|
8387
8498
|
}
|
|
8388
8499
|
__updateRenderBounds() {
|
|
8389
|
-
copyAndSpread(this.__layout.renderBounds, this.
|
|
8500
|
+
copyAndSpread(this.__layout.renderBounds, this.__.__textBoxBounds, this.__layout.renderSpread);
|
|
8390
8501
|
}
|
|
8391
8502
|
};
|
|
8392
8503
|
__decorate([
|
|
@@ -8404,6 +8515,9 @@ __decorate([
|
|
|
8404
8515
|
__decorate([
|
|
8405
8516
|
affectStrokeBoundsType('outside')
|
|
8406
8517
|
], Text.prototype, "strokeAlign", void 0);
|
|
8518
|
+
__decorate([
|
|
8519
|
+
hitType('all')
|
|
8520
|
+
], Text.prototype, "hitFill", void 0);
|
|
8407
8521
|
__decorate([
|
|
8408
8522
|
boundsType('')
|
|
8409
8523
|
], Text.prototype, "text", void 0);
|
|
@@ -8443,6 +8557,9 @@ __decorate([
|
|
|
8443
8557
|
__decorate([
|
|
8444
8558
|
boundsType('top')
|
|
8445
8559
|
], Text.prototype, "verticalAlign", void 0);
|
|
8560
|
+
__decorate([
|
|
8561
|
+
boundsType('normal')
|
|
8562
|
+
], Text.prototype, "textWrap", void 0);
|
|
8446
8563
|
__decorate([
|
|
8447
8564
|
boundsType('show')
|
|
8448
8565
|
], Text.prototype, "textOverflow", void 0);
|
|
@@ -9173,8 +9290,9 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
9173
9290
|
if (!paint.patternTask) {
|
|
9174
9291
|
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
|
|
9175
9292
|
paint.patternTask = null;
|
|
9176
|
-
if (canvas.bounds.hit(ui.__world)
|
|
9177
|
-
ui.
|
|
9293
|
+
if (canvas.bounds.hit(ui.__world))
|
|
9294
|
+
createPattern(ui, paint, canvas.pixelRatio);
|
|
9295
|
+
ui.forceUpdate('surface');
|
|
9178
9296
|
}), 300);
|
|
9179
9297
|
}
|
|
9180
9298
|
}
|
|
@@ -9838,6 +9956,8 @@ function createRows(drawData, content, style) {
|
|
|
9838
9956
|
const { width, height } = bounds;
|
|
9839
9957
|
const charMode = width || height || __letterSpacing || (textCase !== 'none');
|
|
9840
9958
|
if (charMode) {
|
|
9959
|
+
const wrap = style.textWrap !== 'none';
|
|
9960
|
+
const breakAll = style.textWrap === 'break';
|
|
9841
9961
|
paraStart = true;
|
|
9842
9962
|
lastCharType = null;
|
|
9843
9963
|
startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
|
|
@@ -9864,16 +9984,23 @@ function createRows(drawData, content, style) {
|
|
|
9864
9984
|
langBreak = (charType === Single && (lastCharType === Single || lastCharType === Letter)) || (lastCharType === Single && charType !== After);
|
|
9865
9985
|
afterBreak = ((charType === Before || charType === Single) && (lastCharType === Symbol || lastCharType === After));
|
|
9866
9986
|
realWidth = paraStart && paraIndent ? width - paraIndent : width;
|
|
9867
|
-
if (width && rowWidth + wordWidth + charWidth > realWidth) {
|
|
9868
|
-
if (
|
|
9869
|
-
afterBreak = charType === Letter && lastCharType == After;
|
|
9870
|
-
if (langBreak || afterBreak || charType === Break || charType === Before || charType === Single || (wordWidth + charWidth > realWidth)) {
|
|
9987
|
+
if (wrap && (width && rowWidth + wordWidth + charWidth > realWidth)) {
|
|
9988
|
+
if (breakAll) {
|
|
9871
9989
|
if (wordWidth)
|
|
9872
9990
|
addWord();
|
|
9873
9991
|
addRow();
|
|
9874
9992
|
}
|
|
9875
9993
|
else {
|
|
9876
|
-
|
|
9994
|
+
if (!afterBreak)
|
|
9995
|
+
afterBreak = charType === Letter && lastCharType == After;
|
|
9996
|
+
if (langBreak || afterBreak || charType === Break || charType === Before || charType === Single || (wordWidth + charWidth > realWidth)) {
|
|
9997
|
+
if (wordWidth)
|
|
9998
|
+
addWord();
|
|
9999
|
+
addRow();
|
|
10000
|
+
}
|
|
10001
|
+
else {
|
|
10002
|
+
addRow();
|
|
10003
|
+
}
|
|
9877
10004
|
}
|
|
9878
10005
|
}
|
|
9879
10006
|
if (char === ' ' && paraStart !== true && (rowWidth + wordWidth) === 0) ;
|
|
@@ -9943,7 +10070,7 @@ function addRow() {
|
|
|
9943
10070
|
|
|
9944
10071
|
const CharMode = 0;
|
|
9945
10072
|
const WordMode = 1;
|
|
9946
|
-
const
|
|
10073
|
+
const TextMode = 2;
|
|
9947
10074
|
function layoutChar(drawData, style, width, _height) {
|
|
9948
10075
|
const { rows } = drawData;
|
|
9949
10076
|
const { textAlign, paraIndent, letterSpacing } = style;
|
|
@@ -9952,15 +10079,12 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
9952
10079
|
if (row.words) {
|
|
9953
10080
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
9954
10081
|
addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
9955
|
-
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode :
|
|
9956
|
-
if (
|
|
9957
|
-
row.
|
|
10082
|
+
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
10083
|
+
if (row.isOverflow && !letterSpacing)
|
|
10084
|
+
row.textMode = true;
|
|
10085
|
+
if (mode === TextMode) {
|
|
9958
10086
|
row.x += indentWidth;
|
|
9959
|
-
row
|
|
9960
|
-
word.data.forEach(char => {
|
|
9961
|
-
row.text += char.char;
|
|
9962
|
-
});
|
|
9963
|
-
});
|
|
10087
|
+
toTextChar$1(row);
|
|
9964
10088
|
}
|
|
9965
10089
|
else {
|
|
9966
10090
|
row.x += indentWidth;
|
|
@@ -9986,6 +10110,14 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
9986
10110
|
}
|
|
9987
10111
|
});
|
|
9988
10112
|
}
|
|
10113
|
+
function toTextChar$1(row) {
|
|
10114
|
+
row.text = '';
|
|
10115
|
+
row.words.forEach(word => {
|
|
10116
|
+
word.data.forEach(char => {
|
|
10117
|
+
row.text += char.char;
|
|
10118
|
+
});
|
|
10119
|
+
});
|
|
10120
|
+
}
|
|
9989
10121
|
function toWordChar(data, charX, wordChar) {
|
|
9990
10122
|
data.forEach(char => {
|
|
9991
10123
|
wordChar.char += char.char;
|
|
@@ -10006,10 +10138,10 @@ function toChar(data, charX, rowData) {
|
|
|
10006
10138
|
|
|
10007
10139
|
function layoutText(drawData, style) {
|
|
10008
10140
|
const { rows, bounds } = drawData;
|
|
10009
|
-
const { __lineHeight, __baseLine, __letterSpacing, textAlign, verticalAlign, paraSpacing
|
|
10141
|
+
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
|
|
10010
10142
|
let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
10011
10143
|
let starY = __baseLine;
|
|
10012
|
-
if (
|
|
10144
|
+
if (__clipText && realHeight > height) {
|
|
10013
10145
|
realHeight = Math.max(height, __lineHeight);
|
|
10014
10146
|
drawData.overflow = rows.length;
|
|
10015
10147
|
}
|
|
@@ -10058,39 +10190,58 @@ function layoutText(drawData, style) {
|
|
|
10058
10190
|
bounds.x = rowX;
|
|
10059
10191
|
if (rowWidth > bounds.width)
|
|
10060
10192
|
bounds.width = rowWidth;
|
|
10193
|
+
if (__clipText && width && width < rowWidth) {
|
|
10194
|
+
row.isOverflow = true;
|
|
10195
|
+
if (!drawData.overflow)
|
|
10196
|
+
drawData.overflow = rows.length;
|
|
10197
|
+
}
|
|
10061
10198
|
}
|
|
10062
10199
|
bounds.y = y;
|
|
10063
10200
|
bounds.height = realHeight;
|
|
10064
10201
|
}
|
|
10065
10202
|
|
|
10066
|
-
function clipText(drawData,
|
|
10203
|
+
function clipText(drawData, style) {
|
|
10067
10204
|
const { rows, overflow } = drawData;
|
|
10205
|
+
let { textOverflow } = style;
|
|
10068
10206
|
rows.splice(overflow);
|
|
10069
10207
|
if (textOverflow !== 'hide') {
|
|
10070
10208
|
if (textOverflow === 'ellipsis')
|
|
10071
10209
|
textOverflow = '...';
|
|
10210
|
+
let char, charRight;
|
|
10072
10211
|
const ellipsisWidth = Platform.canvas.measureText(textOverflow).width;
|
|
10073
|
-
const
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
|
|
10084
|
-
|
|
10085
|
-
|
|
10086
|
-
|
|
10212
|
+
const right = style.x + style.width - ellipsisWidth;
|
|
10213
|
+
const list = style.textWrap === 'none' ? rows : [rows[overflow - 1]];
|
|
10214
|
+
list.forEach(row => {
|
|
10215
|
+
if (row.isOverflow && row.data) {
|
|
10216
|
+
let end = row.data.length - 1;
|
|
10217
|
+
for (let i = end; i > -1; i--) {
|
|
10218
|
+
char = row.data[i];
|
|
10219
|
+
charRight = char.x + char.width;
|
|
10220
|
+
if (i === end && charRight < right) {
|
|
10221
|
+
break;
|
|
10222
|
+
}
|
|
10223
|
+
else if (charRight < right && char.char !== ' ') {
|
|
10224
|
+
row.data.splice(i + 1);
|
|
10225
|
+
row.width -= char.width;
|
|
10226
|
+
break;
|
|
10227
|
+
}
|
|
10228
|
+
row.width -= char.width;
|
|
10229
|
+
}
|
|
10230
|
+
row.width += ellipsisWidth;
|
|
10231
|
+
row.data.push({ char: textOverflow, x: charRight });
|
|
10232
|
+
if (row.textMode)
|
|
10233
|
+
toTextChar(row);
|
|
10087
10234
|
}
|
|
10088
|
-
|
|
10089
|
-
}
|
|
10090
|
-
row.width += ellipsisWidth;
|
|
10091
|
-
row.data.push({ char: textOverflow, x: charRight });
|
|
10235
|
+
});
|
|
10092
10236
|
}
|
|
10093
10237
|
}
|
|
10238
|
+
function toTextChar(row) {
|
|
10239
|
+
row.text = '';
|
|
10240
|
+
row.data.forEach(char => {
|
|
10241
|
+
row.text += char.char;
|
|
10242
|
+
});
|
|
10243
|
+
row.data = null;
|
|
10244
|
+
}
|
|
10094
10245
|
|
|
10095
10246
|
function decorationText(drawData, style) {
|
|
10096
10247
|
const { fontSize } = style;
|
|
@@ -10111,7 +10262,7 @@ const TextConvert = {
|
|
|
10111
10262
|
let x = 0, y = 0;
|
|
10112
10263
|
let width = style.__getInput('width') || 0;
|
|
10113
10264
|
let height = style.__getInput('height') || 0;
|
|
10114
|
-
const { textDecoration,
|
|
10265
|
+
const { textDecoration, __font, padding } = style;
|
|
10115
10266
|
if (padding) {
|
|
10116
10267
|
const [top, right, bottom, left] = MathHelper.fourNumber(padding);
|
|
10117
10268
|
if (width) {
|
|
@@ -10133,7 +10284,7 @@ const TextConvert = {
|
|
|
10133
10284
|
layoutText(drawData, style);
|
|
10134
10285
|
layoutChar(drawData, style, width);
|
|
10135
10286
|
if (drawData.overflow)
|
|
10136
|
-
clipText(drawData,
|
|
10287
|
+
clipText(drawData, style);
|
|
10137
10288
|
if (textDecoration !== 'none')
|
|
10138
10289
|
decorationText(drawData, style);
|
|
10139
10290
|
return drawData;
|