@leafer-ui/draw 1.0.4 → 1.0.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/lib/draw.cjs +85 -126
- package/lib/draw.esm.js +85 -126
- package/lib/draw.esm.min.js +1 -1
- package/lib/draw.min.cjs +1 -1
- package/package.json +9 -9
package/lib/draw.esm.js
CHANGED
|
@@ -66,6 +66,13 @@ function zoomLayerType() {
|
|
|
66
66
|
|
|
67
67
|
const TextConvert = {};
|
|
68
68
|
const ColorConvert = {};
|
|
69
|
+
const UnitConvert = {
|
|
70
|
+
number(value, percentRefer) {
|
|
71
|
+
if (typeof value === 'object')
|
|
72
|
+
return value.type === 'percent' ? value.value * percentRefer : value.value;
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
69
76
|
const PathArrow = {};
|
|
70
77
|
const Paint = {};
|
|
71
78
|
const PaintImage = {};
|
|
@@ -86,7 +93,7 @@ const Transition = {
|
|
|
86
93
|
}
|
|
87
94
|
};
|
|
88
95
|
|
|
89
|
-
const { parse } = PathConvert;
|
|
96
|
+
const { parse, objectToCanvasData } = PathConvert;
|
|
90
97
|
const emptyPaint = {};
|
|
91
98
|
const debug$1 = Debug.get('UIData');
|
|
92
99
|
class UIData extends LeafData {
|
|
@@ -100,10 +107,11 @@ class UIData extends LeafData {
|
|
|
100
107
|
scaleX = -scaleX;
|
|
101
108
|
return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
|
|
102
109
|
}
|
|
103
|
-
else
|
|
110
|
+
else
|
|
104
111
|
return strokeWidth;
|
|
105
|
-
}
|
|
106
112
|
}
|
|
113
|
+
get __hasStroke() { return this.stroke && this.strokeWidth; }
|
|
114
|
+
get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
|
|
107
115
|
get __autoWidth() { return !this._width; }
|
|
108
116
|
get __autoHeight() { return !this._height; }
|
|
109
117
|
get __autoSide() { return !this._width || !this._height; }
|
|
@@ -120,9 +128,8 @@ class UIData extends LeafData {
|
|
|
120
128
|
this.__leaf.scaleX *= -1;
|
|
121
129
|
debug$1.warn('width < 0, instead -scaleX ', this);
|
|
122
130
|
}
|
|
123
|
-
else
|
|
131
|
+
else
|
|
124
132
|
this._width = value;
|
|
125
|
-
}
|
|
126
133
|
}
|
|
127
134
|
setHeight(value) {
|
|
128
135
|
if (value < 0) {
|
|
@@ -130,9 +137,8 @@ class UIData extends LeafData {
|
|
|
130
137
|
this.__leaf.scaleY *= -1;
|
|
131
138
|
debug$1.warn('height < 0, instead -scaleY', this);
|
|
132
139
|
}
|
|
133
|
-
else
|
|
140
|
+
else
|
|
134
141
|
this._height = value;
|
|
135
|
-
}
|
|
136
142
|
}
|
|
137
143
|
setFill(value) {
|
|
138
144
|
if (this.__naturalWidth)
|
|
@@ -173,9 +179,10 @@ class UIData extends LeafData {
|
|
|
173
179
|
}
|
|
174
180
|
}
|
|
175
181
|
setPath(value) {
|
|
176
|
-
|
|
182
|
+
const isString = typeof value === 'string';
|
|
183
|
+
if (isString || (value && typeof value[0] === 'object')) {
|
|
177
184
|
this.__setInput('path', value);
|
|
178
|
-
this._path = parse(value);
|
|
185
|
+
this._path = isString ? parse(value) : objectToCanvasData(value);
|
|
179
186
|
}
|
|
180
187
|
else {
|
|
181
188
|
if (this.__input)
|
|
@@ -190,12 +197,8 @@ class UIData extends LeafData {
|
|
|
190
197
|
value = value.filter((item) => item.visible !== false);
|
|
191
198
|
this._shadow = value.length ? value : null;
|
|
192
199
|
}
|
|
193
|
-
else
|
|
194
|
-
this._shadow = value.visible
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
this._shadow = null;
|
|
198
|
-
}
|
|
200
|
+
else
|
|
201
|
+
this._shadow = value && value.visible !== false ? [value] : null;
|
|
199
202
|
}
|
|
200
203
|
setInnerShadow(value) {
|
|
201
204
|
this.__setInput('innerShadow', value);
|
|
@@ -204,12 +207,8 @@ class UIData extends LeafData {
|
|
|
204
207
|
value = value.filter((item) => item.visible !== false);
|
|
205
208
|
this._innerShadow = value.length ? value : null;
|
|
206
209
|
}
|
|
207
|
-
else
|
|
208
|
-
this._innerShadow = value.visible
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
this._innerShadow = null;
|
|
212
|
-
}
|
|
210
|
+
else
|
|
211
|
+
this._innerShadow = value && value.visible !== false ? [value] : null;
|
|
213
212
|
}
|
|
214
213
|
__computePaint() {
|
|
215
214
|
const { fill, stroke } = this.__input;
|
|
@@ -220,24 +219,19 @@ class UIData extends LeafData {
|
|
|
220
219
|
this.__needComputePaint = false;
|
|
221
220
|
}
|
|
222
221
|
}
|
|
223
|
-
const UnitConvert = {
|
|
224
|
-
number(value, percentRefer) {
|
|
225
|
-
if (typeof value === 'object')
|
|
226
|
-
return value.type === 'percent' ? value.value * percentRefer : value.value;
|
|
227
|
-
return value;
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
222
|
|
|
231
223
|
class GroupData extends UIData {
|
|
232
224
|
}
|
|
233
225
|
|
|
234
226
|
class BoxData extends GroupData {
|
|
235
227
|
get __boxStroke() { return !this.__pathInputed; }
|
|
228
|
+
get __drawAfterFill() { return this.overflow === 'hide' && this.__clipAfterFill && this.__leaf.children.length; }
|
|
229
|
+
get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
|
|
236
230
|
}
|
|
237
231
|
|
|
238
232
|
class LeaferData extends GroupData {
|
|
239
|
-
__getInputData() {
|
|
240
|
-
const data = super.__getInputData();
|
|
233
|
+
__getInputData(names, options) {
|
|
234
|
+
const data = super.__getInputData(names, options);
|
|
241
235
|
canvasSizeAttrs.forEach(key => delete data[key]);
|
|
242
236
|
return data;
|
|
243
237
|
}
|
|
@@ -264,6 +258,7 @@ class StarData extends UIData {
|
|
|
264
258
|
}
|
|
265
259
|
|
|
266
260
|
class PathData extends UIData {
|
|
261
|
+
get __pathInputed() { return 2; }
|
|
267
262
|
}
|
|
268
263
|
|
|
269
264
|
class PenData extends GroupData {
|
|
@@ -310,16 +305,18 @@ class ImageData extends RectData {
|
|
|
310
305
|
delete data.fill;
|
|
311
306
|
return data;
|
|
312
307
|
}
|
|
313
|
-
__getInputData() {
|
|
314
|
-
const data = super.__getInputData();
|
|
308
|
+
__getInputData(names, options) {
|
|
309
|
+
const data = super.__getInputData(names, options);
|
|
315
310
|
delete data.fill;
|
|
316
311
|
return data;
|
|
317
312
|
}
|
|
318
313
|
}
|
|
319
314
|
|
|
320
315
|
class CanvasData extends RectData {
|
|
321
|
-
|
|
322
|
-
|
|
316
|
+
get __isCanvas() { return true; }
|
|
317
|
+
get __drawAfterFill() { return true; }
|
|
318
|
+
__getInputData(names, options) {
|
|
319
|
+
const data = super.__getInputData(names, options);
|
|
323
320
|
data.url = this.__leaf.canvas.toDataURL('image/png');
|
|
324
321
|
return data;
|
|
325
322
|
}
|
|
@@ -346,16 +343,12 @@ const UIBounds = {
|
|
|
346
343
|
let width = 0;
|
|
347
344
|
const { shadow, innerShadow, blur, backgroundBlur } = this.__;
|
|
348
345
|
if (shadow)
|
|
349
|
-
shadow.forEach(item =>
|
|
350
|
-
width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5);
|
|
351
|
-
});
|
|
346
|
+
shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
|
|
352
347
|
if (blur)
|
|
353
348
|
width = Math.max(width, blur);
|
|
354
349
|
let shapeWidth = width = Math.ceil(width);
|
|
355
350
|
if (innerShadow)
|
|
356
|
-
innerShadow.forEach(item =>
|
|
357
|
-
shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5);
|
|
358
|
-
});
|
|
351
|
+
innerShadow.forEach(item => shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5));
|
|
359
352
|
if (backgroundBlur)
|
|
360
353
|
shapeWidth = Math.max(shapeWidth, backgroundBlur);
|
|
361
354
|
this.__layout.renderShapeSpread = shapeWidth;
|
|
@@ -437,6 +430,16 @@ const UIRender = {
|
|
|
437
430
|
if (stroke && !ignoreStroke)
|
|
438
431
|
this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
439
432
|
}
|
|
433
|
+
},
|
|
434
|
+
__drawAfterFill(canvas, options) {
|
|
435
|
+
if (this.__.__clipAfterFill) {
|
|
436
|
+
canvas.save();
|
|
437
|
+
this.windingRule ? canvas.clip(this.windingRule) : canvas.clip();
|
|
438
|
+
this.__drawContent(canvas, options);
|
|
439
|
+
canvas.restore();
|
|
440
|
+
}
|
|
441
|
+
else
|
|
442
|
+
this.__drawContent(canvas, options);
|
|
440
443
|
}
|
|
441
444
|
};
|
|
442
445
|
function drawFast(ui, canvas, options) {
|
|
@@ -503,8 +506,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
503
506
|
return pen;
|
|
504
507
|
}
|
|
505
508
|
get editConfig() { return undefined; }
|
|
506
|
-
get editOuter() { return
|
|
507
|
-
get editInner() { return '
|
|
509
|
+
get editOuter() { return ''; }
|
|
510
|
+
get editInner() { return ''; }
|
|
508
511
|
constructor(data) {
|
|
509
512
|
super(data);
|
|
510
513
|
}
|
|
@@ -515,9 +518,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
515
518
|
Object.assign(this, data);
|
|
516
519
|
this.lockNormalStyle = false;
|
|
517
520
|
}
|
|
518
|
-
else
|
|
521
|
+
else
|
|
519
522
|
Object.assign(this, data);
|
|
520
|
-
}
|
|
521
523
|
}
|
|
522
524
|
get(name) {
|
|
523
525
|
return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
|
|
@@ -563,12 +565,7 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
563
565
|
this.__drawPathByData(canvas, this.__.path);
|
|
564
566
|
}
|
|
565
567
|
__drawPathByData(drawer, data) {
|
|
566
|
-
|
|
567
|
-
PathDrawer.drawPathByData(drawer, data);
|
|
568
|
-
}
|
|
569
|
-
else {
|
|
570
|
-
this.__drawPathByBox(drawer);
|
|
571
|
-
}
|
|
568
|
+
data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
|
|
572
569
|
}
|
|
573
570
|
__drawPathByBox(drawer) {
|
|
574
571
|
const { x, y, width, height } = this.__layout.boxBounds;
|
|
@@ -576,9 +573,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
576
573
|
const { cornerRadius } = this.__;
|
|
577
574
|
drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
|
|
578
575
|
}
|
|
579
|
-
else
|
|
576
|
+
else
|
|
580
577
|
drawer.rect(x, y, width, height);
|
|
581
|
-
}
|
|
582
578
|
}
|
|
583
579
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
584
580
|
return needPlugin('animate');
|
|
@@ -825,23 +821,13 @@ let Group = class Group extends UI {
|
|
|
825
821
|
if (data.children) {
|
|
826
822
|
const { children } = data;
|
|
827
823
|
delete data.children;
|
|
828
|
-
|
|
829
|
-
this.__setBranch();
|
|
830
|
-
}
|
|
831
|
-
else {
|
|
832
|
-
this.clear();
|
|
833
|
-
}
|
|
824
|
+
this.children ? this.clear() : this.__setBranch();
|
|
834
825
|
super.set(data, isTemp);
|
|
835
|
-
|
|
836
|
-
children.forEach(childData => {
|
|
837
|
-
child = childData.__ ? childData : UICreator.get(childData.tag, childData);
|
|
838
|
-
this.add(child);
|
|
839
|
-
});
|
|
826
|
+
children.forEach(child => this.add(child));
|
|
840
827
|
data.children = children;
|
|
841
828
|
}
|
|
842
|
-
else
|
|
829
|
+
else
|
|
843
830
|
super.set(data, isTemp);
|
|
844
|
-
}
|
|
845
831
|
}
|
|
846
832
|
toJSON(options) {
|
|
847
833
|
const data = super.toJSON(options);
|
|
@@ -1261,10 +1247,9 @@ Rect = __decorate([
|
|
|
1261
1247
|
registerUI()
|
|
1262
1248
|
], Rect);
|
|
1263
1249
|
|
|
1264
|
-
const
|
|
1265
|
-
const group = Group.prototype;
|
|
1250
|
+
const { copy, add, includes: includes$1 } = BoundsHelper;
|
|
1251
|
+
const rect = Rect.prototype, group = Group.prototype;
|
|
1266
1252
|
const childrenRenderBounds = {};
|
|
1267
|
-
const { copy, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
1268
1253
|
let Box = class Box extends Group {
|
|
1269
1254
|
get __tag() { return 'Box'; }
|
|
1270
1255
|
get isBranchLeaf() { return true; }
|
|
@@ -1274,37 +1259,31 @@ let Box = class Box extends Group {
|
|
|
1274
1259
|
}
|
|
1275
1260
|
__updateStrokeSpread() { return 0; }
|
|
1276
1261
|
__updateRectRenderSpread() { return 0; }
|
|
1277
|
-
__updateRenderSpread() {
|
|
1278
|
-
return this.__updateRectRenderSpread() || -1;
|
|
1279
|
-
}
|
|
1262
|
+
__updateRenderSpread() { return this.__updateRectRenderSpread() || -1; }
|
|
1280
1263
|
__updateRectBoxBounds() { }
|
|
1281
|
-
__updateBoxBounds(
|
|
1264
|
+
__updateBoxBounds(_secondLayout) {
|
|
1282
1265
|
const data = this.__;
|
|
1283
1266
|
if (this.children.length) {
|
|
1284
1267
|
if (data.__autoSide) {
|
|
1285
|
-
if (this.leafer && this.leafer.ready)
|
|
1286
|
-
this.leafer.layouter.addExtra(this);
|
|
1287
1268
|
super.__updateBoxBounds();
|
|
1288
1269
|
const { boxBounds } = this.__layout;
|
|
1289
1270
|
if (!data.__autoSize) {
|
|
1290
|
-
if (data.__autoWidth)
|
|
1291
|
-
boxBounds.width += boxBounds.x, boxBounds.
|
|
1292
|
-
|
|
1293
|
-
|
|
1271
|
+
if (data.__autoWidth) {
|
|
1272
|
+
boxBounds.width += boxBounds.x, boxBounds.x = 0;
|
|
1273
|
+
boxBounds.height = data.height, boxBounds.y = 0;
|
|
1274
|
+
}
|
|
1275
|
+
else {
|
|
1276
|
+
boxBounds.height += boxBounds.y, boxBounds.y = 0;
|
|
1277
|
+
boxBounds.width = data.width, boxBounds.x = 0;
|
|
1278
|
+
}
|
|
1294
1279
|
}
|
|
1295
|
-
if (secondLayout && data.flow && data.padding)
|
|
1296
|
-
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
1297
1280
|
this.__updateNaturalSize();
|
|
1298
1281
|
}
|
|
1299
|
-
else
|
|
1282
|
+
else
|
|
1300
1283
|
this.__updateRectBoxBounds();
|
|
1301
|
-
}
|
|
1302
|
-
if (data.flow)
|
|
1303
|
-
this.__updateContentBounds();
|
|
1304
1284
|
}
|
|
1305
|
-
else
|
|
1285
|
+
else
|
|
1306
1286
|
this.__updateRectBoxBounds();
|
|
1307
|
-
}
|
|
1308
1287
|
}
|
|
1309
1288
|
__updateStrokeBounds() { }
|
|
1310
1289
|
__updateRenderBounds() {
|
|
@@ -1314,14 +1293,13 @@ let Box = class Box extends Group {
|
|
|
1314
1293
|
super.__updateRenderBounds();
|
|
1315
1294
|
copy(childrenRenderBounds, renderBounds);
|
|
1316
1295
|
this.__updateRectRenderBounds();
|
|
1317
|
-
isOverflow = !includes$1(renderBounds, childrenRenderBounds)
|
|
1296
|
+
isOverflow = !includes$1(renderBounds, childrenRenderBounds);
|
|
1297
|
+
if (isOverflow && this.__.overflow !== 'hide')
|
|
1298
|
+
add(renderBounds, childrenRenderBounds);
|
|
1318
1299
|
}
|
|
1319
|
-
else
|
|
1300
|
+
else
|
|
1320
1301
|
this.__updateRectRenderBounds();
|
|
1321
|
-
|
|
1322
|
-
this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
|
|
1323
|
-
if (!(this.__.__drawAfterFill = this.__.overflow === 'hide') && isOverflow)
|
|
1324
|
-
add(renderBounds, childrenRenderBounds);
|
|
1302
|
+
!this.isOverflow !== !isOverflow && (this.isOverflow = isOverflow);
|
|
1325
1303
|
}
|
|
1326
1304
|
__updateRectRenderBounds() { }
|
|
1327
1305
|
__updateRectChange() { }
|
|
@@ -1341,20 +1319,9 @@ let Box = class Box extends Group {
|
|
|
1341
1319
|
this.__renderGroup(canvas, options);
|
|
1342
1320
|
}
|
|
1343
1321
|
}
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
if (this.
|
|
1347
|
-
canvas.save();
|
|
1348
|
-
canvas.clip();
|
|
1349
|
-
if (length)
|
|
1350
|
-
this.__renderGroup(canvas, options);
|
|
1351
|
-
canvas.restore();
|
|
1352
|
-
}
|
|
1353
|
-
else {
|
|
1354
|
-
if (length)
|
|
1355
|
-
this.__renderGroup(canvas, options);
|
|
1356
|
-
}
|
|
1357
|
-
if (this.__.stroke && length) {
|
|
1322
|
+
__drawContent(canvas, options) {
|
|
1323
|
+
this.__renderGroup(canvas, options);
|
|
1324
|
+
if (this.__.__hasStroke) {
|
|
1358
1325
|
canvas.setWorld(this.__nowWorld);
|
|
1359
1326
|
this.__drawRenderPath(canvas);
|
|
1360
1327
|
}
|
|
@@ -1366,6 +1333,9 @@ __decorate([
|
|
|
1366
1333
|
__decorate([
|
|
1367
1334
|
dataType(false)
|
|
1368
1335
|
], Box.prototype, "resizeChildren", void 0);
|
|
1336
|
+
__decorate([
|
|
1337
|
+
dataType(false)
|
|
1338
|
+
], Box.prototype, "textBox", void 0);
|
|
1369
1339
|
__decorate([
|
|
1370
1340
|
affectRenderBoundsType('show')
|
|
1371
1341
|
], Box.prototype, "overflow", void 0);
|
|
@@ -1515,17 +1485,15 @@ let Line = class Line extends UI {
|
|
|
1515
1485
|
if (data.__useArrow)
|
|
1516
1486
|
PathArrow.addArrows(this, false);
|
|
1517
1487
|
}
|
|
1518
|
-
else
|
|
1488
|
+
else
|
|
1519
1489
|
super.__updateRenderPath();
|
|
1520
|
-
}
|
|
1521
1490
|
}
|
|
1522
1491
|
__updateBoxBounds() {
|
|
1523
1492
|
if (this.points) {
|
|
1524
1493
|
toBounds(this.__.__pathForRender, this.__layout.boxBounds);
|
|
1525
1494
|
}
|
|
1526
|
-
else
|
|
1495
|
+
else
|
|
1527
1496
|
super.__updateBoxBounds();
|
|
1528
|
-
}
|
|
1529
1497
|
}
|
|
1530
1498
|
};
|
|
1531
1499
|
__decorate([
|
|
@@ -1663,7 +1631,6 @@ let Canvas = class Canvas extends Rect {
|
|
|
1663
1631
|
super(data);
|
|
1664
1632
|
this.canvas = Creator.canvas(this.__);
|
|
1665
1633
|
this.context = this.canvas.context;
|
|
1666
|
-
this.__.__isCanvas = this.__.__drawAfterFill = true;
|
|
1667
1634
|
if (data && data.url)
|
|
1668
1635
|
this.drawImage(data.url);
|
|
1669
1636
|
}
|
|
@@ -1676,8 +1643,7 @@ let Canvas = class Canvas extends Rect {
|
|
|
1676
1643
|
});
|
|
1677
1644
|
}
|
|
1678
1645
|
draw(ui, offset, scale, rotation) {
|
|
1679
|
-
ui.
|
|
1680
|
-
const matrix = new Matrix(ui.__world).invert();
|
|
1646
|
+
const matrix = new Matrix(ui.worldTransform).invert();
|
|
1681
1647
|
const m = new Matrix();
|
|
1682
1648
|
if (offset)
|
|
1683
1649
|
m.translate(offset.x, offset.y);
|
|
@@ -1692,17 +1658,9 @@ let Canvas = class Canvas extends Rect {
|
|
|
1692
1658
|
paint() {
|
|
1693
1659
|
this.forceRender();
|
|
1694
1660
|
}
|
|
1695
|
-
|
|
1696
|
-
const { width, height
|
|
1697
|
-
|
|
1698
|
-
canvas.save();
|
|
1699
|
-
canvas.clip();
|
|
1700
|
-
canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
|
|
1701
|
-
canvas.restore();
|
|
1702
|
-
}
|
|
1703
|
-
else {
|
|
1704
|
-
canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
|
|
1705
|
-
}
|
|
1661
|
+
__drawContent(canvas, _options) {
|
|
1662
|
+
const { width, height } = this.__, { view } = this.canvas;
|
|
1663
|
+
canvas.drawImage(view, 0, 0, view.width, view.height, 0, 0, width, height);
|
|
1706
1664
|
}
|
|
1707
1665
|
__updateSize() {
|
|
1708
1666
|
const { canvas } = this;
|
|
@@ -1746,7 +1704,6 @@ Canvas = __decorate([
|
|
|
1746
1704
|
const { copyAndSpread, includes, isSame, spread, setList } = BoundsHelper;
|
|
1747
1705
|
let Text = class Text extends UI {
|
|
1748
1706
|
get __tag() { return 'Text'; }
|
|
1749
|
-
get editInner() { return 'TextEditor'; }
|
|
1750
1707
|
get textDrawData() {
|
|
1751
1708
|
this.__layout.update();
|
|
1752
1709
|
return this.__.__textDrawData;
|
|
@@ -1895,6 +1852,9 @@ __decorate([
|
|
|
1895
1852
|
__decorate([
|
|
1896
1853
|
boundsType('top')
|
|
1897
1854
|
], Text.prototype, "verticalAlign", void 0);
|
|
1855
|
+
__decorate([
|
|
1856
|
+
boundsType(true)
|
|
1857
|
+
], Text.prototype, "autoSizeAlign", void 0);
|
|
1898
1858
|
__decorate([
|
|
1899
1859
|
boundsType('normal')
|
|
1900
1860
|
], Text.prototype, "textWrap", void 0);
|
|
@@ -1909,7 +1869,6 @@ let Path = class Path extends UI {
|
|
|
1909
1869
|
get __tag() { return 'Path'; }
|
|
1910
1870
|
constructor(data) {
|
|
1911
1871
|
super(data);
|
|
1912
|
-
this.__.__pathInputed = 2;
|
|
1913
1872
|
}
|
|
1914
1873
|
};
|
|
1915
1874
|
__decorate([
|
package/lib/draw.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{decorateLeafAttr as t,attr as e,defineKey as i,needPlugin as s,Debug as o,LeafData as r,PathConvert as a,canvasSizeAttrs as n,dataProcessor as _,dataType as h,surfaceType as d,opacityType as p,visibleType as l,sortType as u,maskType as c,eraserType as y,positionType as g,boundsType as v,scaleType as f,rotationType as w,autoLayoutType as x,naturalBoundsType as m,pathInputType as R,pathType as S,hitType as k,strokeType as B,cursorType as b,rewrite as C,Leaf as P,useModule as A,rewriteAble as I,MathHelper as E,pen as D,PathCorner as F,PathDrawer as L,UICreator as W,registerUI as T,Branch as z,LeafList as M,ImageManager as O,DataHelper as N,Creator as V,CanvasManager as H,WaitHelper as Y,LeaferEvent as j,Bounds as U,ResizeEvent as X,AutoBounds as G,Run as J,LayoutEvent as $,RenderEvent as K,WatchEvent as q,affectRenderBoundsType as Q,BoundsHelper as Z,Platform as tt,PathCommandDataHelper as et,affectStrokeBoundsType as it,getPointData as st,PointHelper as ot,PathBounds as rt,ImageEvent as at,LeaferImage as nt,Matrix as _t,PathCreator as ht}from"@leafer/core";export*from"@leafer/core";function dt(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}function pt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function lt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function ut(){return(t,e)=>{const s="_"+e;i(t,e,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}"function"==typeof SuppressedError&&SuppressedError;const ct={},yt={},gt={},vt={},ft={},wt={},xt={},mt={},Rt={setStyleName:(t,e,i)=>s("state"),set:(t,e)=>s("state")},St={list:{},register(t,e){St.list[t]=e},get:t=>St.list[t]},{parse:kt}=a,Bt={},bt=o.get("UIData");class Ct extends r{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,bt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,bt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=Bt)):(this.__isFills&&(this.__removeInput("fill"),ft.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=Bt)):(this.__isStrokes&&(this.__removeInput("stroke"),ft.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=kt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&vt.compute("fill",this.__leaf),e&&vt.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const Pt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t};class At extends Ct{}class It extends At{get __boxStroke(){return!this.__pathInputed}}class Et extends At{__getInputData(){const t=super.__getInputData();return n.forEach((e=>delete t[e])),t}}class Dt extends It{}class Ft extends Ct{}class Lt extends Ct{get __boxStroke(){return!this.__pathInputed}}class Wt extends Ct{get __boxStroke(){return!this.__pathInputed}}class Tt extends Ct{}class zt extends Ct{}class Mt extends Ct{}class Ot extends At{}const Nt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Vt extends Ct{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Nt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Ht extends Lt{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class Yt extends Lt{__getInputData(){const t=super.__getInputData();return t.url=this.__leaf.canvas.toDataURL("image/png"),t}}const jt={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:o}=i;if((i.stroke||"all"===i.hitStroke)&&o&&"inside"!==s&&(e=t="center"===s?o/2:o,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:o;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*o),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),s&&(t=Math.max(t,s));let r=t=Math.ceil(t);return i&&i.forEach((t=>{r=Math.max(r,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(r=Math.max(r,o)),this.__layout.renderShapeSpread=r,t+(this.__layout.strokeSpread||0)}},Ut={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;t.__useEffect=!!(e||i||s||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){Xt(this,t,e)},__draw(t,e){const i=this.__;if(i.__complex){i.__needComputePaint&&i.__computePaint();const{fill:s,stroke:o,__drawAfterFill:r}=i;if(this.__drawRenderPath(t),i.__useEffect){const a=vt.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:n,innerShadow:_}=i;n&&xt.shadow(this,t,a),s&&(i.__isFills?vt.fills(s,this,t):vt.fill(s,this,t)),r&&this.__drawAfterFill(t,e),_&&xt.innerShadow(this,t,a),o&&(i.__isStrokes?vt.strokes(o,this,t):vt.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else s&&(i.__isFills?vt.fills(s,this,t):vt.fill(s,this,t)),r&&this.__drawAfterFill(t,e),o&&(i.__isStrokes?vt.strokes(o,this,t):vt.stroke(o,this,t))}else i.__pathInputed?Xt(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:r}=this.__;this.__drawRenderPath(t),o&&!i&&(this.__.__pixelFill?vt.fills(o,this,t):vt.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),r&&!s&&(this.__.__pixelStroke?vt.strokes(r,this,t):vt.stroke("#000000",this,t))}}};function Xt(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r}=t.__;t.__drawRenderPath(e),s&&vt.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&vt.stroke(o,t,e)}const Gt={__drawFast(t,e){let{width:i,height:s,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,i,s)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:o,__strokeWidth:a}=this.__;if(!a)return;t.setStroke(r,a,this.__);const n=a/2;switch(o){case"center":t.strokeRect(0,0,i,s);break;case"inside":i-=a,s-=a,i<0||s<0?(t.save(),this.__clip(t,e),t.strokeRect(n,n,i,s),t.restore()):t.strokeRect(n,n,i,s);break;case"outside":t.strokeRect(-n,-n,i+a,s+a)}}}};var Jt;let $t=Jt=class extends P{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){E.assignScale(this,t)}get scale(){return this.__.scale}get pen(){const{path:t}=this.__;return D.set(this.path=t||[]),t||this.__drawPathByBox(D),D}get editConfig(){}get editOuter(){return this.__.__isLinePath?"LineEditTool":"EditTool"}get editInner(){return"PathEditor"}constructor(t){super(t)}reset(t){}set(t,e){e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(D.set(i=[]),this.__drawPathByBox(D)),t?a.toCanvasData(i,!0):i}getPathString(t,e){return a.stringify(this.getPath(t,e))}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||mt.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?F.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&>.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?L.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:r}=this.__;t.roundRect(e,i,s,o,"number"==typeof r?[r]:r)}else t.rect(e,i,s,o)}animate(t,e,i,o){return s("animate")}killAnimate(t){}export(t,e){return mt.export(this,t,e)}clone(t){const e=this.toJSON();return t&&Object.assign(e,t),Jt.one(e)}static one(t,e,i,s,o){return W.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){T()(this)}static registerData(t){_(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};dt([_(Ct)],$t.prototype,"__",void 0),dt([ut()],$t.prototype,"zoomLayer",void 0),dt([h("")],$t.prototype,"id",void 0),dt([h("")],$t.prototype,"name",void 0),dt([h("")],$t.prototype,"className",void 0),dt([d("pass-through")],$t.prototype,"blendMode",void 0),dt([p(1)],$t.prototype,"opacity",void 0),dt([l(!0)],$t.prototype,"visible",void 0),dt([d(!1)],$t.prototype,"locked",void 0),dt([u(0)],$t.prototype,"zIndex",void 0),dt([c(!1)],$t.prototype,"mask",void 0),dt([y(!1)],$t.prototype,"eraser",void 0),dt([g(0,!0)],$t.prototype,"x",void 0),dt([g(0,!0)],$t.prototype,"y",void 0),dt([v(100,!0)],$t.prototype,"width",void 0),dt([v(100,!0)],$t.prototype,"height",void 0),dt([f(1,!0)],$t.prototype,"scaleX",void 0),dt([f(1,!0)],$t.prototype,"scaleY",void 0),dt([w(0,!0)],$t.prototype,"rotation",void 0),dt([w(0,!0)],$t.prototype,"skewX",void 0),dt([w(0,!0)],$t.prototype,"skewY",void 0),dt([g(0,!0)],$t.prototype,"offsetX",void 0),dt([g(0,!0)],$t.prototype,"offsetY",void 0),dt([g(0,!0)],$t.prototype,"scrollX",void 0),dt([g(0,!0)],$t.prototype,"scrollY",void 0),dt([x()],$t.prototype,"origin",void 0),dt([x()],$t.prototype,"around",void 0),dt([h(!1)],$t.prototype,"lazy",void 0),dt([m(1)],$t.prototype,"pixelRatio",void 0),dt([R()],$t.prototype,"path",void 0),dt([S()],$t.prototype,"windingRule",void 0),dt([S(!0)],$t.prototype,"closed",void 0),dt([v(0)],$t.prototype,"padding",void 0),dt([h(!1)],$t.prototype,"draggable",void 0),dt([h()],$t.prototype,"dragBounds",void 0),dt([h(!1)],$t.prototype,"editable",void 0),dt([k(!0)],$t.prototype,"hittable",void 0),dt([k("path")],$t.prototype,"hitFill",void 0),dt([B("path")],$t.prototype,"hitStroke",void 0),dt([k(!1)],$t.prototype,"hitBox",void 0),dt([k(!0)],$t.prototype,"hitChildren",void 0),dt([k(!0)],$t.prototype,"hitSelf",void 0),dt([k()],$t.prototype,"hitRadius",void 0),dt([b("")],$t.prototype,"cursor",void 0),dt([d()],$t.prototype,"fill",void 0),dt([B()],$t.prototype,"stroke",void 0),dt([B("inside")],$t.prototype,"strokeAlign",void 0),dt([B(1)],$t.prototype,"strokeWidth",void 0),dt([B(!1)],$t.prototype,"strokeWidthFixed",void 0),dt([B("none")],$t.prototype,"strokeCap",void 0),dt([B("miter")],$t.prototype,"strokeJoin",void 0),dt([B()],$t.prototype,"dashPattern",void 0),dt([B()],$t.prototype,"dashOffset",void 0),dt([B(10)],$t.prototype,"miterLimit",void 0),dt([S(0)],$t.prototype,"cornerRadius",void 0),dt([S()],$t.prototype,"cornerSmoothing",void 0),dt([pt()],$t.prototype,"shadow",void 0),dt([pt()],$t.prototype,"innerShadow",void 0),dt([pt()],$t.prototype,"blur",void 0),dt([pt()],$t.prototype,"backgroundBlur",void 0),dt([pt()],$t.prototype,"grayscale",void 0),dt([h({})],$t.prototype,"data",void 0),dt([C(P.prototype.reset)],$t.prototype,"reset",null),$t=Jt=dt([A(jt),A(Ut),I()],$t);let Kt=class extends $t{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t.children){const{children:i}=t;let s;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach((t=>{s=t.__?t:W.get(t.tag,t),this.add(s)})),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var qt;dt([_(At)],Kt.prototype,"__",void 0),Kt=dt([A(z),T()],Kt);const Qt=o.get("Leafer");let Zt=qt=class extends Kt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&O.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds()}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),qt.list.add(this)}init(t,e){if(this.canvas)return;let i;this.__setLeafer(this),t&&N.assign(this.config,t);const{config:s}=this;this.initType(s.type);const o=this.canvas=V.canvas(s);this.__controllers.push(this.renderer=V.renderer(this,o,s),this.watcher=V.watcher(this,s),this.layouter=V.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s,e),this.view=o.view,e?(this.__bindApp(e),i=e.running):(this.selector=V.selector(this),this.interaction=V.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=V.hitCanvasManager()),this.canvasManager=new H,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),Y.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(j.RESTART):this.emitLeafer(j.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(j.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=N.copyAttrs({},t,n);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t){this.renderer.addBlock(t?new U(t):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=N.copyAttrs({},this.canvas,n);e.resize(t),this.updateLazyBounds(),this.__onResize(new X(t,i))}__onResize(t){this.emitEvent(t),N.copyAttrs(this.__,t,n),t.width&&t.height||Qt.warn("w = 0 or h = 0"),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t,e){e||(t.width&&t.height||(this.autoLayout=new G(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(n.includes(t)?(e||Qt.warn(t+" is 0"),this.__changeCanvasSize(t,e)):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&n.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=N.copyAttrs({},this.canvas,n);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(j.BEFORE_READY),this.emitLeafer(j.READY),this.emitLeafer(j.AFTER_READY),Y.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(j.VIEW_READY),Y.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){Y.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1)}}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(j.VIEW_COMPLETED),Y.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t)}zoom(t,e,i){return s("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new j(t,this))}__listenEvents(){const t=J.start("FirstCreate "+this.innerName);this.once(j.START,(()=>J.end(t))),this.once($.START,(()=>this.updateLazyBounds())),this.once($.END,(()=>this.__onReady())),this.once(K.START,(()=>this.__onCreated())),this.once(K.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(q.DATA,this.__onWatchData,this),this.on_(K.NEXT,this.__onNextRender,this),this.on_($.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){qt.list.remove(this);try{this.stop(),this.emitEvent(new j(j.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{O.clearRecycled()}),100)}catch(t){Qt.error(t)}}};t?e():setTimeout(e)}};Zt.list=new M,dt([_(Et)],Zt.prototype,"__",void 0),dt([v()],Zt.prototype,"pixelRatio",void 0),Zt=qt=dt([T()],Zt);let te=class extends $t{get __tag(){return"Rect"}constructor(t){super(t)}};dt([_(Lt)],te.prototype,"__",void 0),te=dt([A(Gt),I(),T()],te);const ee=te.prototype,ie=Kt.prototype,se={},{copy:oe,add:re,includes:ae,copyAndSpread:ne}=Z;let _e=class extends Kt{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length){if(e.__autoSide){this.leafer&&this.leafer.ready&&this.leafer.layouter.addExtra(this),super.__updateBoxBounds();const{boxBounds:i}=this.__layout;e.__autoSize||(e.__autoWidth?(i.width+=i.x,i.height=e.height,i.y=i.x=0):(i.height+=i.y,i.width=e.width,i.x=i.y=0)),t&&e.flow&&e.padding&&ne(i,i,e.padding,!1,e.__autoSize?null:e.__autoWidth?"width":"height"),this.__updateNaturalSize()}else this.__updateRectBoxBounds();e.flow&&this.__updateContentBounds()}else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),oe(se,e),this.__updateRectRenderBounds(),t=!ae(e,se)||!this.pathInputed||!this.__.cornerRadius):this.__updateRectRenderBounds(),this.isOverflow!==t&&(this.isOverflow=t),!(this.__.__drawAfterFill="hide"===this.__.overflow)&&t&&re(e,se)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawAfterFill(t,e){const{length:i}=this.children;this.isOverflow?(t.save(),t.clip(),i&&this.__renderGroup(t,e),t.restore()):i&&this.__renderGroup(t,e),this.__.stroke&&i&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};dt([_(It)],_e.prototype,"__",void 0),dt([h(!1)],_e.prototype,"resizeChildren",void 0),dt([Q("show")],_e.prototype,"overflow",void 0),dt([C(ee.__updateStrokeSpread)],_e.prototype,"__updateStrokeSpread",null),dt([C(ee.__updateRenderSpread)],_e.prototype,"__updateRectRenderSpread",null),dt([C(ee.__updateBoxBounds)],_e.prototype,"__updateRectBoxBounds",null),dt([C(ee.__updateStrokeBounds)],_e.prototype,"__updateStrokeBounds",null),dt([C(ee.__updateRenderBounds)],_e.prototype,"__updateRectRenderBounds",null),dt([C(ee.__updateChange)],_e.prototype,"__updateRectChange",null),dt([C(ee.__render)],_e.prototype,"__renderRect",null),dt([C(ie.__render)],_e.prototype,"__renderGroup",null),_e=dt([I(),T()],_e);let he=class extends _e{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};dt([_(Dt)],he.prototype,"__",void 0),dt([d("#FFFFFF")],he.prototype,"fill",void 0),dt([Q("hide")],he.prototype,"overflow",void 0),he=dt([T()],he);const{moveTo:de,closePath:pe,ellipse:le}=et;let ue=class extends $t{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,n=this.__.path=[];i?(s||o?(i<1&&le(n,r,a,r*i,a*i,0,s,o,!1),le(n,r,a,r,a,0,o,s,!0),i<1&&pe(n)):(i<1&&(le(n,r,a,r*i,a*i),de(n,t,a)),le(n,r,a,r,a,0,360,0,!0)),tt.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(de(n,r,a),le(n,r,a,r,a,0,s,o,!1),pe(n)):le(n,r,a,r,a)}};dt([_(Wt)],ue.prototype,"__",void 0),dt([S(0)],ue.prototype,"innerRadius",void 0),dt([S(0)],ue.prototype,"startAngle",void 0),dt([S(0)],ue.prototype,"endAngle",void 0),ue=dt([T()],ue);const{moveTo:ce,lineTo:ye,drawPoints:ge}=et,{rotate:ve,getAngle:fe,getDistance:we,defaultPoint:xe}=ot,{toBounds:me}=rt;let Re=class extends $t{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=st();return t&&(i.x=t),e&&ve(i,e),i}set toPoint(t){this.width=we(xe,t),this.rotation=fe(xe,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?ge(e,t.points,!1,t.closed):(ce(e,0,0),ye(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(ge(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&>.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?me(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};dt([_(Ft)],Re.prototype,"__",void 0),dt([it("center")],Re.prototype,"strokeAlign",void 0),dt([v(0)],Re.prototype,"height",void 0),dt([S()],Re.prototype,"points",void 0),dt([S(0)],Re.prototype,"curve",void 0),dt([S(!1)],Re.prototype,"closed",void 0),Re=dt([T()],Re);const{sin:Se,cos:ke,PI:Be}=Math,{moveTo:be,lineTo:Ce,closePath:Pe,drawPoints:Ae}=et,Ie=Re.prototype;let Ee=class extends $t{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Ae(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;be(t,o,0);for(let e=1;e<s;e++)Ce(t,o+o*Se(2*e*Be/s),r-r*ke(2*e*Be/s))}Pe(t)}__updateRenderPath(){}__updateBoxBounds(){}};dt([_(Tt)],Ee.prototype,"__",void 0),dt([S(3)],Ee.prototype,"sides",void 0),dt([S()],Ee.prototype,"points",void 0),dt([S(0)],Ee.prototype,"curve",void 0),dt([C(Ie.__updateRenderPath)],Ee.prototype,"__updateRenderPath",null),dt([C(Ie.__updateBoxBounds)],Ee.prototype,"__updateBoxBounds",null),Ee=dt([I(),T()],Ee);const{sin:De,cos:Fe,PI:Le}=Math,{moveTo:We,lineTo:Te,closePath:ze}=et;let Me=class extends $t{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];We(a,o,0);for(let t=1;t<2*i;t++)Te(a,o+(t%2==0?o:o*s)*De(t*Le/i),r-(t%2==0?r:r*s)*Fe(t*Le/i));ze(a)}};dt([_(zt)],Me.prototype,"__",void 0),dt([S(5)],Me.prototype,"corners",void 0),dt([S(.382)],Me.prototype,"innerRadius",void 0),Me=dt([T()],Me);let Oe=class extends te{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(at.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};dt([_(Ht)],Oe.prototype,"__",void 0),dt([v("")],Oe.prototype,"url",void 0),Oe=dt([T()],Oe);const Ne=Oe;let Ve=class extends te{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(t){super(t),this.canvas=V.canvas(this.__),this.context=this.canvas.context,this.__.__isCanvas=this.__.__drawAfterFill=!0,t&&t.url&&this.drawImage(t.url)}drawImage(t){new nt({url:t}).load((t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new at(at.LOADED,{image:t}))}))}draw(t,e,i,s){t.__layout.update();const o=new _t(t.__world).invert(),r=new _t;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceRender()}__drawAfterFill(t,e){const{width:i,height:s,cornerRadius:o}=this.__,{view:r}=this.canvas;o||this.pathInputed?(t.save(),t.clip(),t.drawImage(r,0,0,r.width,r.height,0,0,i,s),t.restore()):t.drawImage(r,0,0,r.width,r.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}};dt([_(Yt)],Ve.prototype,"__",void 0),dt([lt(100)],Ve.prototype,"width",void 0),dt([lt(100)],Ve.prototype,"height",void 0),dt([lt(1)],Ve.prototype,"pixelRatio",void 0),dt([lt(!0)],Ve.prototype,"smooth",void 0),dt([lt()],Ve.prototype,"contextSettings",void 0),Ve=dt([T()],Ve);const{copyAndSpread:He,includes:Ye,isSame:je,spread:Ue,setList:Xe}=Z;let Ge=class extends $t{get __tag(){return"Text"}get editInner(){return"TextEditor"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__textDrawData:o}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):o.rows.forEach((o=>t.rect(o.x,o.y-s,o.width,e<i?i:e)))}__drawPathByData(t,e){const{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;t.rect(i,s,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=ct.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:i,letterSpacing:s,fontFamily:o,fontSize:r,fontWeight:a,italic:n,textCase:_,textOverflow:h,padding:d}=t,p=t.__autoWidth,l=t.__autoHeight;t.__lineHeight=Pt.number(i,r),t.__letterSpacing=Pt.number(s,r),t.__padding=d?E.fourNumber(d):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*r)/2,t.__font=`${n?"italic ":""}${"small-caps"===_?"small-caps ":""}${"normal"!==a?a+" ":""}${r}px ${o}`,t.__clipText="show"!==h&&!t.__autoSize,this.__updateTextDrawData();const{bounds:u}=t.__textDrawData,c=e.boxBounds;if(t.__lineHeight<r&&Ue(u,r/2),p||l){if(c.x=p?u.x:0,c.y=l?u.y:0,c.width=p?u.width:t.width,c.height=l?u.height:t.height,d){const[e,i,s,o]=t.__padding;p&&(c.x-=o,c.width+=i+o),l&&(c.y-=e,c.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();n&&(c.width+=.16*r);const y=Ye(c,u)?c:u;je(y,e.contentBounds)?t.__textBoxBounds=y:(e.contentBounds=y,e.renderChanged=!0,Xe(t.__textBoxBounds={},[c,u]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){He(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};dt([_(Vt)],Ge.prototype,"__",void 0),dt([v(0)],Ge.prototype,"width",void 0),dt([v(0)],Ge.prototype,"height",void 0),dt([h(!1)],Ge.prototype,"resizeFontSize",void 0),dt([d("#000000")],Ge.prototype,"fill",void 0),dt([it("outside")],Ge.prototype,"strokeAlign",void 0),dt([k("all")],Ge.prototype,"hitFill",void 0),dt([v("")],Ge.prototype,"text",void 0),dt([v("L")],Ge.prototype,"fontFamily",void 0),dt([v(12)],Ge.prototype,"fontSize",void 0),dt([v("normal")],Ge.prototype,"fontWeight",void 0),dt([v(!1)],Ge.prototype,"italic",void 0),dt([v("none")],Ge.prototype,"textCase",void 0),dt([v("none")],Ge.prototype,"textDecoration",void 0),dt([v(0)],Ge.prototype,"letterSpacing",void 0),dt([v({type:"percent",value:1.5})],Ge.prototype,"lineHeight",void 0),dt([v(0)],Ge.prototype,"paraIndent",void 0),dt([v(0)],Ge.prototype,"paraSpacing",void 0),dt([v("left")],Ge.prototype,"textAlign",void 0),dt([v("top")],Ge.prototype,"verticalAlign",void 0),dt([v("normal")],Ge.prototype,"textWrap",void 0),dt([v("show")],Ge.prototype,"textOverflow",void 0),Ge=dt([T()],Ge);let Je=class extends $t{get __tag(){return"Path"}constructor(t){super(t),this.__.__pathInputed=2}};dt([_(Mt)],Je.prototype,"__",void 0),dt([it("center")],Je.prototype,"strokeAlign",void 0),Je=dt([T()],Je);let $e=class extends Kt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Je(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,n){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,n){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};dt([_(Ot)],$e.prototype,"__",void 0),dt([(t,e)=>{i(t,e,{get(){return this.__path}})}],$e.prototype,"path",void 0),$e=dt([A(ht,["set","beginPath","path","paint"]),T()],$e);export{_e as Box,It as BoxData,Ve as Canvas,Yt as CanvasData,yt as ColorConvert,xt as Effect,ue as Ellipse,Wt as EllipseData,mt as Export,he as Frame,Dt as FrameData,Kt as Group,At as GroupData,Oe as Image,Ht as ImageData,Zt as Leafer,Et as LeaferData,Re as Line,Ft as LineData,Ne as MyImage,vt as Paint,wt as PaintGradient,ft as PaintImage,Je as Path,gt as PathArrow,Mt as PathData,$e as Pen,Ot as PenData,Ee as Polygon,Tt as PolygonData,te as Rect,Lt as RectData,Gt as RectRender,Me as Star,zt as StarData,Rt as State,Ge as Text,ct as TextConvert,Vt as TextData,St as Transition,$t as UI,jt as UIBounds,Ct as UIData,Ut as UIRender,Pt as UnitConvert,pt as effectType,lt as resizeType,ut as zoomLayerType};
|
|
1
|
+
import{decorateLeafAttr as t,attr as e,defineKey as i,needPlugin as s,Debug as o,LeafData as r,PathConvert as a,canvasSizeAttrs as n,dataProcessor as _,dataType as h,surfaceType as d,opacityType as p,visibleType as l,sortType as u,maskType as c,eraserType as y,positionType as g,boundsType as v,scaleType as f,rotationType as w,autoLayoutType as x,naturalBoundsType as m,pathInputType as R,pathType as S,hitType as k,strokeType as B,cursorType as b,rewrite as C,Leaf as A,useModule as P,rewriteAble as F,MathHelper as D,pen as I,PathCorner as E,PathDrawer as L,UICreator as W,registerUI as T,Branch as z,LeafList as M,ImageManager as O,DataHelper as N,Creator as V,CanvasManager as j,WaitHelper as H,LeaferEvent as Y,Bounds as U,ResizeEvent as X,AutoBounds as G,Run as J,LayoutEvent as $,RenderEvent as K,WatchEvent as q,affectRenderBoundsType as Q,BoundsHelper as Z,Platform as tt,PathCommandDataHelper as et,affectStrokeBoundsType as it,getPointData as st,PointHelper as ot,PathBounds as rt,ImageEvent as at,LeaferImage as nt,Matrix as _t,PathCreator as ht}from"@leafer/core";export*from"@leafer/core";function dt(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}function pt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function lt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function ut(){return(t,e)=>{const s="_"+e;i(t,e,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}"function"==typeof SuppressedError&&SuppressedError;const ct={},yt={},gt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t},vt={},ft={},wt={},xt={},mt={},Rt={},St={setStyleName:(t,e,i)=>s("state"),set:(t,e)=>s("state")},kt={list:{},register(t,e){kt.list[t]=e},get:t=>kt.list[t]},{parse:Bt,objectToCanvasData:bt}=a,Ct={},At=o.get("UIData");class Pt extends r{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __hasStroke(){return this.stroke&&this.strokeWidth}get __clipAfterFill(){return this.cornerRadius||this.__pathInputed}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,At.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,At.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=Ct)):(this.__isFills&&(this.__removeInput("fill"),wt.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=Ct)):(this.__isStrokes&&(this.__removeInput("stroke"),wt.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){const e="string"==typeof t;e||t&&"object"==typeof t[0]?(this.__setInput("path",t),this._path=e?Bt(t):bt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t&&!1!==t.visible?[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t&&!1!==t.visible?[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&ft.compute("fill",this.__leaf),e&&ft.compute("stroke",this.__leaf),this.__needComputePaint=!1}}class Ft extends Pt{}class Dt extends Ft{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){return"hide"===this.overflow&&this.__clipAfterFill&&this.__leaf.children.length}get __clipAfterFill(){return this.__leaf.isOverflow||super.__clipAfterFill}}class It extends Ft{__getInputData(t,e){const i=super.__getInputData(t,e);return n.forEach((t=>delete i[t])),i}}class Et extends Dt{}class Lt extends Pt{}class Wt extends Pt{get __boxStroke(){return!this.__pathInputed}}class Tt extends Pt{get __boxStroke(){return!this.__pathInputed}}class zt extends Pt{}class Mt extends Pt{}class Ot extends Pt{get __pathInputed(){return 2}}class Nt extends Ft{}const Vt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class jt extends Pt{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Vt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Ht extends Wt{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return delete i.fill,i}}class Yt extends Wt{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const Ut={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:o}=i;if((i.stroke||"all"===i.hitStroke)&&o&&"inside"!==s&&(e=t="center"===s?o/2:o,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:o;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*o),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;e&&e.forEach((e=>t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur))),s&&(t=Math.max(t,s));let r=t=Math.ceil(t);return i&&i.forEach((t=>r=Math.max(r,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur))),o&&(r=Math.max(r,o)),this.__layout.renderShapeSpread=r,t+(this.__layout.strokeSpread||0)}},Xt={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;t.__useEffect=!!(e||i||s||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){Gt(this,t,e)},__draw(t,e){const i=this.__;if(i.__complex){i.__needComputePaint&&i.__computePaint();const{fill:s,stroke:o,__drawAfterFill:r}=i;if(this.__drawRenderPath(t),i.__useEffect){const a=ft.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:n,innerShadow:_}=i;n&&mt.shadow(this,t,a),s&&(i.__isFills?ft.fills(s,this,t):ft.fill(s,this,t)),r&&this.__drawAfterFill(t,e),_&&mt.innerShadow(this,t,a),o&&(i.__isStrokes?ft.strokes(o,this,t):ft.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else s&&(i.__isFills?ft.fills(s,this,t):ft.fill(s,this,t)),r&&this.__drawAfterFill(t,e),o&&(i.__isStrokes?ft.strokes(o,this,t):ft.stroke(o,this,t))}else i.__pathInputed?Gt(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:r}=this.__;this.__drawRenderPath(t),o&&!i&&(this.__.__pixelFill?ft.fills(o,this,t):ft.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),r&&!s&&(this.__.__pixelStroke?ft.strokes(r,this,t):ft.stroke("#000000",this,t))}},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),this.windingRule?t.clip(this.windingRule):t.clip(),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function Gt(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r}=t.__;t.__drawRenderPath(e),s&&ft.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&ft.stroke(o,t,e)}const Jt={__drawFast(t,e){let{width:i,height:s,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,i,s)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:o,__strokeWidth:a}=this.__;if(!a)return;t.setStroke(r,a,this.__);const n=a/2;switch(o){case"center":t.strokeRect(0,0,i,s);break;case"inside":i-=a,s-=a,i<0||s<0?(t.save(),this.__clip(t,e),t.strokeRect(n,n,i,s),t.restore()):t.strokeRect(n,n,i,s);break;case"outside":t.strokeRect(-n,-n,i+a,s+a)}}}};var $t;let Kt=$t=class extends A{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){D.assignScale(this,t)}get scale(){return this.__.scale}get pen(){const{path:t}=this.__;return I.set(this.path=t||[]),t||this.__drawPathByBox(I),I}get editConfig(){}get editOuter(){return""}get editInner(){return""}constructor(t){super(t)}reset(t){}set(t,e){e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):Object.assign(this,t)}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){}findTag(t){return this.find({tag:t})}findOne(t,e){}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(I.set(i=[]),this.__drawPathByBox(I)),t?a.toCanvasData(i,!0):i}getPathString(t,e){return a.stringify(this.getPath(t,e))}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||Rt.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?E.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&vt.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?L.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:r}=this.__;t.roundRect(e,i,s,o,"number"==typeof r?[r]:r)}else t.rect(e,i,s,o)}animate(t,e,i,o){return s("animate")}killAnimate(t){}export(t,e){return Rt.export(this,t,e)}clone(t){const e=this.toJSON();return t&&Object.assign(e,t),$t.one(e)}static one(t,e,i,s,o){return W.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){T()(this)}static registerData(t){_(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};dt([_(Pt)],Kt.prototype,"__",void 0),dt([ut()],Kt.prototype,"zoomLayer",void 0),dt([h("")],Kt.prototype,"id",void 0),dt([h("")],Kt.prototype,"name",void 0),dt([h("")],Kt.prototype,"className",void 0),dt([d("pass-through")],Kt.prototype,"blendMode",void 0),dt([p(1)],Kt.prototype,"opacity",void 0),dt([l(!0)],Kt.prototype,"visible",void 0),dt([d(!1)],Kt.prototype,"locked",void 0),dt([u(0)],Kt.prototype,"zIndex",void 0),dt([c(!1)],Kt.prototype,"mask",void 0),dt([y(!1)],Kt.prototype,"eraser",void 0),dt([g(0,!0)],Kt.prototype,"x",void 0),dt([g(0,!0)],Kt.prototype,"y",void 0),dt([v(100,!0)],Kt.prototype,"width",void 0),dt([v(100,!0)],Kt.prototype,"height",void 0),dt([f(1,!0)],Kt.prototype,"scaleX",void 0),dt([f(1,!0)],Kt.prototype,"scaleY",void 0),dt([w(0,!0)],Kt.prototype,"rotation",void 0),dt([w(0,!0)],Kt.prototype,"skewX",void 0),dt([w(0,!0)],Kt.prototype,"skewY",void 0),dt([g(0,!0)],Kt.prototype,"offsetX",void 0),dt([g(0,!0)],Kt.prototype,"offsetY",void 0),dt([g(0,!0)],Kt.prototype,"scrollX",void 0),dt([g(0,!0)],Kt.prototype,"scrollY",void 0),dt([x()],Kt.prototype,"origin",void 0),dt([x()],Kt.prototype,"around",void 0),dt([h(!1)],Kt.prototype,"lazy",void 0),dt([m(1)],Kt.prototype,"pixelRatio",void 0),dt([R()],Kt.prototype,"path",void 0),dt([S()],Kt.prototype,"windingRule",void 0),dt([S(!0)],Kt.prototype,"closed",void 0),dt([v(0)],Kt.prototype,"padding",void 0),dt([h(!1)],Kt.prototype,"draggable",void 0),dt([h()],Kt.prototype,"dragBounds",void 0),dt([h(!1)],Kt.prototype,"editable",void 0),dt([k(!0)],Kt.prototype,"hittable",void 0),dt([k("path")],Kt.prototype,"hitFill",void 0),dt([B("path")],Kt.prototype,"hitStroke",void 0),dt([k(!1)],Kt.prototype,"hitBox",void 0),dt([k(!0)],Kt.prototype,"hitChildren",void 0),dt([k(!0)],Kt.prototype,"hitSelf",void 0),dt([k()],Kt.prototype,"hitRadius",void 0),dt([b("")],Kt.prototype,"cursor",void 0),dt([d()],Kt.prototype,"fill",void 0),dt([B()],Kt.prototype,"stroke",void 0),dt([B("inside")],Kt.prototype,"strokeAlign",void 0),dt([B(1)],Kt.prototype,"strokeWidth",void 0),dt([B(!1)],Kt.prototype,"strokeWidthFixed",void 0),dt([B("none")],Kt.prototype,"strokeCap",void 0),dt([B("miter")],Kt.prototype,"strokeJoin",void 0),dt([B()],Kt.prototype,"dashPattern",void 0),dt([B()],Kt.prototype,"dashOffset",void 0),dt([B(10)],Kt.prototype,"miterLimit",void 0),dt([S(0)],Kt.prototype,"cornerRadius",void 0),dt([S()],Kt.prototype,"cornerSmoothing",void 0),dt([pt()],Kt.prototype,"shadow",void 0),dt([pt()],Kt.prototype,"innerShadow",void 0),dt([pt()],Kt.prototype,"blur",void 0),dt([pt()],Kt.prototype,"backgroundBlur",void 0),dt([pt()],Kt.prototype,"grayscale",void 0),dt([h({})],Kt.prototype,"data",void 0),dt([C(A.prototype.reset)],Kt.prototype,"reset",null),Kt=$t=dt([P(Ut),P(Xt),F()],Kt);let qt=class extends Kt{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t.children){const{children:i}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach((t=>this.add(t))),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var Qt;dt([_(Ft)],qt.prototype,"__",void 0),qt=dt([P(z),T()],qt);const Zt=o.get("Leafer");let te=Qt=class extends qt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&O.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds()}constructor(t,e){super(e),this.config={type:"design",start:!0,hittable:!0,smooth:!0,lazySpeard:100,zoom:{min:.01,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),Qt.list.add(this)}init(t,e){if(this.canvas)return;let i;this.__setLeafer(this),t&&N.assign(this.config,t);const{config:s}=this;this.initType(s.type);const o=this.canvas=V.canvas(s);this.__controllers.push(this.renderer=V.renderer(this,o,s),this.watcher=V.watcher(this,s),this.layouter=V.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s,e),this.view=o.view,e?(this.__bindApp(e),i=e.running):(this.selector=V.selector(this),this.interaction=V.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=V.hitCanvasManager()),this.canvasManager=new j,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),H.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t){this.waitInit((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(Y.RESTART):this.emitLeafer(Y.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(Y.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=N.copyAttrs({},t,n);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t){this.renderer.addBlock(t?new U(t):this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=N.copyAttrs({},this.canvas,n);e.resize(t),this.updateLazyBounds(),this.__onResize(new X(t,i))}__onResize(t){this.emitEvent(t),N.copyAttrs(this.__,t,n),t.width&&t.height||Zt.warn("w = 0 or h = 0"),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t,e){e||(t.width&&t.height||(this.autoLayout=new G(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(n.includes(t)?(e||Zt.warn(t+" is 0"),this.__changeCanvasSize(t,e)):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&n.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=N.copyAttrs({},this.canvas,n);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(Y.BEFORE_READY),this.emitLeafer(Y.READY),this.emitLeafer(Y.AFTER_READY),H.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(Y.VIEW_READY),H.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){H.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1)}}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(Y.VIEW_COMPLETED),H.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t)}zoom(t,e,i){return s("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new Y(t,this))}__listenEvents(){const t=J.start("FirstCreate "+this.innerName);this.once(Y.START,(()=>J.end(t))),this.once($.START,(()=>this.updateLazyBounds())),this.once($.END,(()=>this.__onReady())),this.once(K.START,(()=>this.__onCreated())),this.once(K.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(q.DATA,this.__onWatchData,this),this.on_(K.NEXT,this.__onNextRender,this),this.on_($.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){Qt.list.remove(this);try{this.stop(),this.emitEvent(new Y(Y.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{O.clearRecycled()}),100)}catch(t){Zt.error(t)}}};t?e():setTimeout(e)}};te.list=new M,dt([_(It)],te.prototype,"__",void 0),dt([v()],te.prototype,"pixelRatio",void 0),te=Qt=dt([T()],te);let ee=class extends Kt{get __tag(){return"Rect"}constructor(t){super(t)}};dt([_(Wt)],ee.prototype,"__",void 0),ee=dt([P(Jt),F(),T()],ee);const{copy:ie,add:se,includes:oe}=Z,re=ee.prototype,ae=qt.prototype,ne={};let _e=class extends qt{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length)if(e.__autoSide){super.__updateBoxBounds();const{boxBounds:t}=this.__layout;e.__autoSize||(e.__autoWidth?(t.width+=t.x,t.x=0,t.height=e.height,t.y=0):(t.height+=t.y,t.y=0,t.width=e.width,t.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds();else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),ie(ne,e),this.__updateRectRenderBounds(),t=!oe(e,ne),t&&"hide"!==this.__.overflow&&se(e,ne)):this.__updateRectRenderBounds(),!this.isOverflow!=!t&&(this.isOverflow=t)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawContent(t,e){this.__renderGroup(t,e),this.__.__hasStroke&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};dt([_(Dt)],_e.prototype,"__",void 0),dt([h(!1)],_e.prototype,"resizeChildren",void 0),dt([h(!1)],_e.prototype,"textBox",void 0),dt([Q("show")],_e.prototype,"overflow",void 0),dt([C(re.__updateStrokeSpread)],_e.prototype,"__updateStrokeSpread",null),dt([C(re.__updateRenderSpread)],_e.prototype,"__updateRectRenderSpread",null),dt([C(re.__updateBoxBounds)],_e.prototype,"__updateRectBoxBounds",null),dt([C(re.__updateStrokeBounds)],_e.prototype,"__updateStrokeBounds",null),dt([C(re.__updateRenderBounds)],_e.prototype,"__updateRectRenderBounds",null),dt([C(re.__updateChange)],_e.prototype,"__updateRectChange",null),dt([C(re.__render)],_e.prototype,"__renderRect",null),dt([C(ae.__render)],_e.prototype,"__renderGroup",null),_e=dt([F(),T()],_e);let he=class extends _e{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};dt([_(Et)],he.prototype,"__",void 0),dt([d("#FFFFFF")],he.prototype,"fill",void 0),dt([Q("hide")],he.prototype,"overflow",void 0),he=dt([T()],he);const{moveTo:de,closePath:pe,ellipse:le}=et;let ue=class extends Kt{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,n=this.__.path=[];i?(s||o?(i<1&&le(n,r,a,r*i,a*i,0,s,o,!1),le(n,r,a,r,a,0,o,s,!0),i<1&&pe(n)):(i<1&&(le(n,r,a,r*i,a*i),de(n,t,a)),le(n,r,a,r,a,0,360,0,!0)),tt.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(de(n,r,a),le(n,r,a,r,a,0,s,o,!1),pe(n)):le(n,r,a,r,a)}};dt([_(Tt)],ue.prototype,"__",void 0),dt([S(0)],ue.prototype,"innerRadius",void 0),dt([S(0)],ue.prototype,"startAngle",void 0),dt([S(0)],ue.prototype,"endAngle",void 0),ue=dt([T()],ue);const{moveTo:ce,lineTo:ye,drawPoints:ge}=et,{rotate:ve,getAngle:fe,getDistance:we,defaultPoint:xe}=ot,{toBounds:me}=rt;let Re=class extends Kt{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=st();return t&&(i.x=t),e&&ve(i,e),i}set toPoint(t){this.width=we(xe,t),this.rotation=fe(xe,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?ge(e,t.points,!1,t.closed):(ce(e,0,0),ye(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(ge(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&vt.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?me(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};dt([_(Lt)],Re.prototype,"__",void 0),dt([it("center")],Re.prototype,"strokeAlign",void 0),dt([v(0)],Re.prototype,"height",void 0),dt([S()],Re.prototype,"points",void 0),dt([S(0)],Re.prototype,"curve",void 0),dt([S(!1)],Re.prototype,"closed",void 0),Re=dt([T()],Re);const{sin:Se,cos:ke,PI:Be}=Math,{moveTo:be,lineTo:Ce,closePath:Ae,drawPoints:Pe}=et,Fe=Re.prototype;let De=class extends Kt{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Pe(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;be(t,o,0);for(let e=1;e<s;e++)Ce(t,o+o*Se(2*e*Be/s),r-r*ke(2*e*Be/s))}Ae(t)}__updateRenderPath(){}__updateBoxBounds(){}};dt([_(zt)],De.prototype,"__",void 0),dt([S(3)],De.prototype,"sides",void 0),dt([S()],De.prototype,"points",void 0),dt([S(0)],De.prototype,"curve",void 0),dt([C(Fe.__updateRenderPath)],De.prototype,"__updateRenderPath",null),dt([C(Fe.__updateBoxBounds)],De.prototype,"__updateBoxBounds",null),De=dt([F(),T()],De);const{sin:Ie,cos:Ee,PI:Le}=Math,{moveTo:We,lineTo:Te,closePath:ze}=et;let Me=class extends Kt{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];We(a,o,0);for(let t=1;t<2*i;t++)Te(a,o+(t%2==0?o:o*s)*Ie(t*Le/i),r-(t%2==0?r:r*s)*Ee(t*Le/i));ze(a)}};dt([_(Mt)],Me.prototype,"__",void 0),dt([S(5)],Me.prototype,"corners",void 0),dt([S(.382)],Me.prototype,"innerRadius",void 0),Me=dt([T()],Me);let Oe=class extends ee{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(at.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};dt([_(Ht)],Oe.prototype,"__",void 0),dt([v("")],Oe.prototype,"url",void 0),Oe=dt([T()],Oe);const Ne=Oe;let Ve=class extends ee{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(t){super(t),this.canvas=V.canvas(this.__),this.context=this.canvas.context,t&&t.url&&this.drawImage(t.url)}drawImage(t){new nt({url:t}).load((t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new at(at.LOADED,{image:t}))}))}draw(t,e,i,s){const o=new _t(t.worldTransform).invert(),r=new _t;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:o}=this.canvas;t.drawImage(o,0,0,o.width,o.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}};dt([_(Yt)],Ve.prototype,"__",void 0),dt([lt(100)],Ve.prototype,"width",void 0),dt([lt(100)],Ve.prototype,"height",void 0),dt([lt(1)],Ve.prototype,"pixelRatio",void 0),dt([lt(!0)],Ve.prototype,"smooth",void 0),dt([lt()],Ve.prototype,"contextSettings",void 0),Ve=dt([T()],Ve);const{copyAndSpread:je,includes:He,isSame:Ye,spread:Ue,setList:Xe}=Z;let Ge=class extends Kt{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__textDrawData:o}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):o.rows.forEach((o=>t.rect(o.x,o.y-s,o.width,e<i?i:e)))}__drawPathByData(t,e){const{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;t.rect(i,s,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=ct.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:i,letterSpacing:s,fontFamily:o,fontSize:r,fontWeight:a,italic:n,textCase:_,textOverflow:h,padding:d}=t,p=t.__autoWidth,l=t.__autoHeight;t.__lineHeight=gt.number(i,r),t.__letterSpacing=gt.number(s,r),t.__padding=d?D.fourNumber(d):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*r)/2,t.__font=`${n?"italic ":""}${"small-caps"===_?"small-caps ":""}${"normal"!==a?a+" ":""}${r}px ${o}`,t.__clipText="show"!==h&&!t.__autoSize,this.__updateTextDrawData();const{bounds:u}=t.__textDrawData,c=e.boxBounds;if(t.__lineHeight<r&&Ue(u,r/2),p||l){if(c.x=p?u.x:0,c.y=l?u.y:0,c.width=p?u.width:t.width,c.height=l?u.height:t.height,d){const[e,i,s,o]=t.__padding;p&&(c.x-=o,c.width+=i+o),l&&(c.y-=e,c.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();n&&(c.width+=.16*r);const y=He(c,u)?c:u;Ye(y,e.contentBounds)?t.__textBoxBounds=y:(e.contentBounds=y,e.renderChanged=!0,Xe(t.__textBoxBounds={},[c,u]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){je(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};dt([_(jt)],Ge.prototype,"__",void 0),dt([v(0)],Ge.prototype,"width",void 0),dt([v(0)],Ge.prototype,"height",void 0),dt([h(!1)],Ge.prototype,"resizeFontSize",void 0),dt([d("#000000")],Ge.prototype,"fill",void 0),dt([it("outside")],Ge.prototype,"strokeAlign",void 0),dt([k("all")],Ge.prototype,"hitFill",void 0),dt([v("")],Ge.prototype,"text",void 0),dt([v("L")],Ge.prototype,"fontFamily",void 0),dt([v(12)],Ge.prototype,"fontSize",void 0),dt([v("normal")],Ge.prototype,"fontWeight",void 0),dt([v(!1)],Ge.prototype,"italic",void 0),dt([v("none")],Ge.prototype,"textCase",void 0),dt([v("none")],Ge.prototype,"textDecoration",void 0),dt([v(0)],Ge.prototype,"letterSpacing",void 0),dt([v({type:"percent",value:1.5})],Ge.prototype,"lineHeight",void 0),dt([v(0)],Ge.prototype,"paraIndent",void 0),dt([v(0)],Ge.prototype,"paraSpacing",void 0),dt([v("left")],Ge.prototype,"textAlign",void 0),dt([v("top")],Ge.prototype,"verticalAlign",void 0),dt([v(!0)],Ge.prototype,"autoSizeAlign",void 0),dt([v("normal")],Ge.prototype,"textWrap",void 0),dt([v("show")],Ge.prototype,"textOverflow",void 0),Ge=dt([T()],Ge);let Je=class extends Kt{get __tag(){return"Path"}constructor(t){super(t)}};dt([_(Ot)],Je.prototype,"__",void 0),dt([it("center")],Je.prototype,"strokeAlign",void 0),Je=dt([T()],Je);let $e=class extends qt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Je(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.__path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,n){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,n){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};dt([_(Nt)],$e.prototype,"__",void 0),dt([(t,e)=>{i(t,e,{get(){return this.__path}})}],$e.prototype,"path",void 0),$e=dt([P(ht,["set","beginPath","path","paint"]),T()],$e);export{_e as Box,Dt as BoxData,Ve as Canvas,Yt as CanvasData,yt as ColorConvert,mt as Effect,ue as Ellipse,Tt as EllipseData,Rt as Export,he as Frame,Et as FrameData,qt as Group,Ft as GroupData,Oe as Image,Ht as ImageData,te as Leafer,It as LeaferData,Re as Line,Lt as LineData,Ne as MyImage,ft as Paint,xt as PaintGradient,wt as PaintImage,Je as Path,vt as PathArrow,Ot as PathData,$e as Pen,Nt as PenData,De as Polygon,zt as PolygonData,ee as Rect,Wt as RectData,Jt as RectRender,Me as Star,Mt as StarData,St as State,Ge as Text,ct as TextConvert,jt as TextData,kt as Transition,Kt as UI,Ut as UIBounds,Pt as UIData,Xt as UIRender,gt as UnitConvert,pt as effectType,lt as resizeType,ut as zoomLayerType};
|