@leafer-ui/core 1.0.0-rc.7 → 1.0.0-rc.9
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/core.cjs +69 -58
- package/dist/core.esm.js +70 -60
- package/dist/core.esm.min.js +1 -1
- package/dist/core.min.cjs +1 -1
- package/package.json +8 -8
package/dist/core.cjs
CHANGED
|
@@ -206,6 +206,9 @@ class FrameData extends BoxData {
|
|
|
206
206
|
class LineData extends UIData {
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
class ArrowData extends LineData {
|
|
210
|
+
}
|
|
211
|
+
|
|
209
212
|
class RectData extends UIData {
|
|
210
213
|
get __boxStroke() { return true; }
|
|
211
214
|
}
|
|
@@ -264,6 +267,25 @@ class TextData extends UIData {
|
|
|
264
267
|
}
|
|
265
268
|
|
|
266
269
|
class ImageData extends RectData {
|
|
270
|
+
setUrl(value) {
|
|
271
|
+
this.__setImageFill(value);
|
|
272
|
+
this._url = value;
|
|
273
|
+
}
|
|
274
|
+
__setImageFill(value) {
|
|
275
|
+
if (this.__leaf.image)
|
|
276
|
+
this.__leaf.image = null;
|
|
277
|
+
this.fill = value ? { type: 'image', mode: 'strench', url: value } : undefined;
|
|
278
|
+
}
|
|
279
|
+
__getData() {
|
|
280
|
+
const data = super.__getData();
|
|
281
|
+
delete data.fill;
|
|
282
|
+
return data;
|
|
283
|
+
}
|
|
284
|
+
__getInputData() {
|
|
285
|
+
const data = super.__getInputData();
|
|
286
|
+
delete data.fill;
|
|
287
|
+
return data;
|
|
288
|
+
}
|
|
267
289
|
}
|
|
268
290
|
|
|
269
291
|
class CanvasData extends RectData {
|
|
@@ -510,14 +532,15 @@ exports.UI = UI_1 = class UI extends core.Leaf {
|
|
|
510
532
|
findOne(condition, options) {
|
|
511
533
|
return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
|
|
512
534
|
}
|
|
513
|
-
getPath(curve) {
|
|
514
|
-
|
|
535
|
+
getPath(curve, pathForRender) {
|
|
536
|
+
this.__layout.update();
|
|
537
|
+
let path = pathForRender ? this.__.__pathForRender : this.__.path;
|
|
515
538
|
if (!path)
|
|
516
|
-
|
|
539
|
+
this.__drawPathByBox(new core.PathCreator(path = []));
|
|
517
540
|
return curve ? core.PathConvert.toCanvasData(path, true) : path;
|
|
518
541
|
}
|
|
519
|
-
getPathString(curve) {
|
|
520
|
-
return core.PathConvert.stringify(this.getPath(curve));
|
|
542
|
+
getPathString(curve, pathForRender) {
|
|
543
|
+
return core.PathConvert.stringify(this.getPath(curve, pathForRender));
|
|
521
544
|
}
|
|
522
545
|
__onUpdateSize() {
|
|
523
546
|
if (this.__.__input) {
|
|
@@ -689,6 +712,12 @@ __decorate([
|
|
|
689
712
|
__decorate([
|
|
690
713
|
core.strokeType(10)
|
|
691
714
|
], exports.UI.prototype, "miterLimit", void 0);
|
|
715
|
+
__decorate([
|
|
716
|
+
core.strokeType('none')
|
|
717
|
+
], exports.UI.prototype, "startArrow", void 0);
|
|
718
|
+
__decorate([
|
|
719
|
+
core.strokeType('none')
|
|
720
|
+
], exports.UI.prototype, "endArrow", void 0);
|
|
692
721
|
__decorate([
|
|
693
722
|
core.pathType(0)
|
|
694
723
|
], exports.UI.prototype, "cornerRadius", void 0);
|
|
@@ -1185,26 +1214,10 @@ exports.Image = class Image extends exports.Rect {
|
|
|
1185
1214
|
get ready() { return this.image ? this.image.ready : false; }
|
|
1186
1215
|
constructor(data) {
|
|
1187
1216
|
super(data);
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
const fill = this.fill;
|
|
1193
|
-
if (fill) {
|
|
1194
|
-
if (fill.url !== url)
|
|
1195
|
-
update = true;
|
|
1196
|
-
}
|
|
1197
|
-
else {
|
|
1198
|
-
if (url)
|
|
1199
|
-
update = true;
|
|
1200
|
-
}
|
|
1201
|
-
if (update) {
|
|
1202
|
-
if (this.image)
|
|
1203
|
-
this.image = null;
|
|
1204
|
-
this.fill = url ? { type: 'image', mode: 'strench', url } : undefined;
|
|
1205
|
-
this.once(core.ImageEvent.LOADED, (e) => this.image = e.image);
|
|
1206
|
-
}
|
|
1207
|
-
super.__updateBoxBounds();
|
|
1217
|
+
this.on(core.ImageEvent.LOADED, (e) => {
|
|
1218
|
+
if (e.attrName === 'fill' && e.attrValue.url === this.url)
|
|
1219
|
+
this.image = e.image;
|
|
1220
|
+
});
|
|
1208
1221
|
}
|
|
1209
1222
|
destroy() {
|
|
1210
1223
|
this.image = null;
|
|
@@ -1334,11 +1347,12 @@ exports.Text = class Text extends exports.UI {
|
|
|
1334
1347
|
__updateBoxBounds() {
|
|
1335
1348
|
const data = this.__;
|
|
1336
1349
|
const layout = this.__layout;
|
|
1337
|
-
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow } = data;
|
|
1350
|
+
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data;
|
|
1338
1351
|
const autoWidth = data.__autoWidth;
|
|
1339
1352
|
const autoHeight = data.__autoHeight;
|
|
1340
1353
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
1341
1354
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
1355
|
+
data.__padding = padding ? core.MathHelper.fourNumber(padding) : undefined;
|
|
1342
1356
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
|
|
1343
1357
|
data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
|
|
1344
1358
|
data.__clipText = textOverflow !== 'show' && !data.__autoBounds;
|
|
@@ -1352,9 +1366,8 @@ exports.Text = class Text extends exports.UI {
|
|
|
1352
1366
|
b.y = autoHeight ? bounds.y : 0;
|
|
1353
1367
|
b.width = autoWidth ? bounds.width : data.width;
|
|
1354
1368
|
b.height = autoHeight ? bounds.height : data.height;
|
|
1355
|
-
const { padding } = data;
|
|
1356
1369
|
if (padding) {
|
|
1357
|
-
const [top, right, bottom, left] =
|
|
1370
|
+
const [top, right, bottom, left] = data.__padding;
|
|
1358
1371
|
if (autoWidth) {
|
|
1359
1372
|
b.x -= left;
|
|
1360
1373
|
b.width += (right + left);
|
|
@@ -1539,6 +1552,7 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
1539
1552
|
get __tag() { return 'Leafer'; }
|
|
1540
1553
|
get isApp() { return false; }
|
|
1541
1554
|
get app() { return this.parent || this; }
|
|
1555
|
+
get imageReady() { return this.viewReady && core.ImageManager.isComplete; }
|
|
1542
1556
|
get layoutLocked() { return !this.layouter.running; }
|
|
1543
1557
|
get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
|
|
1544
1558
|
constructor(userConfig, data) {
|
|
@@ -1741,23 +1755,26 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
1741
1755
|
this.emitLeafer(core.LeaferEvent.VIEW_READY);
|
|
1742
1756
|
core.WaitHelper.run(this.__viewReadyWait);
|
|
1743
1757
|
}
|
|
1744
|
-
|
|
1745
|
-
if (
|
|
1746
|
-
this.
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
this.
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1758
|
+
__onAnimateFrame() {
|
|
1759
|
+
if (this.viewReady) {
|
|
1760
|
+
if (this.__nextRenderWait.length)
|
|
1761
|
+
core.WaitHelper.run(this.__nextRenderWait);
|
|
1762
|
+
const { imageReady } = this;
|
|
1763
|
+
if (imageReady && !this.viewCompleted)
|
|
1764
|
+
this.__checkViewCompleted();
|
|
1765
|
+
if (!imageReady)
|
|
1766
|
+
this.viewCompleted = false;
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
__checkViewCompleted(emit = true) {
|
|
1770
|
+
this.nextRender(() => {
|
|
1771
|
+
if (this.imageReady) {
|
|
1772
|
+
if (emit)
|
|
1773
|
+
this.emitLeafer(core.LeaferEvent.VIEW_COMPLETED);
|
|
1774
|
+
core.WaitHelper.run(this.__viewCompletedWait);
|
|
1775
|
+
this.viewCompleted = true;
|
|
1776
|
+
}
|
|
1777
|
+
});
|
|
1761
1778
|
}
|
|
1762
1779
|
__onWatchData() {
|
|
1763
1780
|
if (this.watcher.childrenChanged && this.interaction) {
|
|
@@ -1771,22 +1788,17 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
1771
1788
|
this.viewReady ? item() : this.__viewReadyWait.push(item);
|
|
1772
1789
|
}
|
|
1773
1790
|
waitViewCompleted(item) {
|
|
1791
|
+
this.__viewCompletedWait.push(item);
|
|
1774
1792
|
if (this.viewCompleted) {
|
|
1775
|
-
|
|
1793
|
+
this.__checkViewCompleted(false);
|
|
1776
1794
|
}
|
|
1777
1795
|
else {
|
|
1778
|
-
this.__viewCompletedWait.push(item);
|
|
1779
1796
|
if (!this.running)
|
|
1780
1797
|
this.start();
|
|
1781
1798
|
}
|
|
1782
1799
|
}
|
|
1783
1800
|
nextRender(item) {
|
|
1784
|
-
|
|
1785
|
-
item();
|
|
1786
|
-
}
|
|
1787
|
-
else {
|
|
1788
|
-
this.__nextRenderWait.push(item);
|
|
1789
|
-
}
|
|
1801
|
+
this.__nextRenderWait.push(item);
|
|
1790
1802
|
}
|
|
1791
1803
|
__checkUpdateLayout() {
|
|
1792
1804
|
this.__layout.update();
|
|
@@ -1799,7 +1811,8 @@ exports.Leafer = class Leafer extends exports.Group {
|
|
|
1799
1811
|
this.once(core.LeaferEvent.START, () => core.Run.end(runId));
|
|
1800
1812
|
this.once(core.LayoutEvent.END, () => this.__onReady());
|
|
1801
1813
|
this.once(core.RenderEvent.START, () => this.__onCreated());
|
|
1802
|
-
this.
|
|
1814
|
+
this.once(core.RenderEvent.END, () => this.__onViewReady());
|
|
1815
|
+
this.__eventIds.push(this.on_(core.WatchEvent.DATA, this.__onWatchData, this), this.on_(core.AnimateEvent.FRAME, this.__onAnimateFrame, this), this.on_(core.LayoutEvent.CHECK_UPDATE, this.__checkUpdateLayout, this));
|
|
1803
1816
|
}
|
|
1804
1817
|
__removeListenEvents() {
|
|
1805
1818
|
this.off_(this.__eventIds);
|
|
@@ -1926,9 +1939,6 @@ exports.App = class App extends exports.Leafer {
|
|
|
1926
1939
|
if (this.children.every(child => child.viewReady))
|
|
1927
1940
|
super.__onViewReady();
|
|
1928
1941
|
}
|
|
1929
|
-
__checkViewCompleted() {
|
|
1930
|
-
return this.children.every(item => item.viewCompleted);
|
|
1931
|
-
}
|
|
1932
1942
|
__onChildRenderEnd(e) {
|
|
1933
1943
|
this.renderer.addBlock(e.renderBounds);
|
|
1934
1944
|
if (this.viewReady)
|
|
@@ -1958,7 +1968,7 @@ exports.App = class App extends exports.Leafer {
|
|
|
1958
1968
|
__listenChildEvents(leafer) {
|
|
1959
1969
|
leafer.once(core.LayoutEvent.END, () => this.__onReady());
|
|
1960
1970
|
leafer.once(core.RenderEvent.START, () => this.__onCreated());
|
|
1961
|
-
leafer.once(core.RenderEvent.END, (
|
|
1971
|
+
leafer.once(core.RenderEvent.END, () => this.__onViewReady());
|
|
1962
1972
|
if (this.realCanvas)
|
|
1963
1973
|
this.__eventIds.push(leafer.on_(core.RenderEvent.END, this.__onChildRenderEnd, this));
|
|
1964
1974
|
}
|
|
@@ -1968,6 +1978,7 @@ exports.App = __decorate([
|
|
|
1968
1978
|
], exports.App);
|
|
1969
1979
|
|
|
1970
1980
|
exports.Animate = Animate;
|
|
1981
|
+
exports.ArrowData = ArrowData;
|
|
1971
1982
|
exports.BoxData = BoxData;
|
|
1972
1983
|
exports.CanvasData = CanvasData;
|
|
1973
1984
|
exports.ColorConvert = ColorConvert;
|
package/dist/core.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MoveEvent, LeafHelper, ZoomEvent, Debug, LeafData, PathConvert, defineLeafAttr, OneRadian, Platform, dataProcessor, dataType, surfaceType, opacityType, maskType, eraserType, sortType, positionType, boundsType, scaleType, rotationType, autoLayoutType, hitType, strokeType, cursorType, pathType, rewrite, Leaf, PathDrawer, useModule, rewriteAble, PathCorner, UICreator, MatrixHelper, Branch, registerUI, affectRenderBoundsType, BoundsHelper, PathCommandDataHelper, affectStrokeBoundsType, PathScaler, PointHelper, PathBounds, ImageEvent, Creator, Matrix, MathHelper,
|
|
1
|
+
import { MoveEvent, LeafHelper, ZoomEvent, Debug, LeafData, PathConvert, defineLeafAttr, OneRadian, Platform, dataProcessor, dataType, surfaceType, opacityType, maskType, eraserType, sortType, positionType, boundsType, scaleType, rotationType, autoLayoutType, hitType, strokeType, cursorType, pathType, rewrite, Leaf, PathDrawer, useModule, rewriteAble, PathCreator, PathCorner, UICreator, MatrixHelper, Branch, registerUI, affectRenderBoundsType, BoundsHelper, PathCommandDataHelper, affectStrokeBoundsType, PathScaler, PointHelper, PathBounds, ImageEvent, Creator, Matrix, MathHelper, ImageManager, DataHelper, CanvasManager, HitCanvasManager, PluginManager, LeaferEvent, canvasSizeAttrs, ResizeEvent, AutoBounds, WaitHelper, Run, LayoutEvent, RenderEvent, WatchEvent, AnimateEvent, PropertyEvent } from '@leafer/core';
|
|
2
2
|
export * from '@leafer/core';
|
|
3
3
|
|
|
4
4
|
/******************************************************************************
|
|
@@ -205,6 +205,9 @@ class FrameData extends BoxData {
|
|
|
205
205
|
class LineData extends UIData {
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
+
class ArrowData extends LineData {
|
|
209
|
+
}
|
|
210
|
+
|
|
208
211
|
class RectData extends UIData {
|
|
209
212
|
get __boxStroke() { return true; }
|
|
210
213
|
}
|
|
@@ -263,6 +266,25 @@ class TextData extends UIData {
|
|
|
263
266
|
}
|
|
264
267
|
|
|
265
268
|
class ImageData extends RectData {
|
|
269
|
+
setUrl(value) {
|
|
270
|
+
this.__setImageFill(value);
|
|
271
|
+
this._url = value;
|
|
272
|
+
}
|
|
273
|
+
__setImageFill(value) {
|
|
274
|
+
if (this.__leaf.image)
|
|
275
|
+
this.__leaf.image = null;
|
|
276
|
+
this.fill = value ? { type: 'image', mode: 'strench', url: value } : undefined;
|
|
277
|
+
}
|
|
278
|
+
__getData() {
|
|
279
|
+
const data = super.__getData();
|
|
280
|
+
delete data.fill;
|
|
281
|
+
return data;
|
|
282
|
+
}
|
|
283
|
+
__getInputData() {
|
|
284
|
+
const data = super.__getInputData();
|
|
285
|
+
delete data.fill;
|
|
286
|
+
return data;
|
|
287
|
+
}
|
|
266
288
|
}
|
|
267
289
|
|
|
268
290
|
class CanvasData extends RectData {
|
|
@@ -509,14 +531,15 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
509
531
|
findOne(condition, options) {
|
|
510
532
|
return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
|
|
511
533
|
}
|
|
512
|
-
getPath(curve) {
|
|
513
|
-
|
|
534
|
+
getPath(curve, pathForRender) {
|
|
535
|
+
this.__layout.update();
|
|
536
|
+
let path = pathForRender ? this.__.__pathForRender : this.__.path;
|
|
514
537
|
if (!path)
|
|
515
|
-
|
|
538
|
+
this.__drawPathByBox(new PathCreator(path = []));
|
|
516
539
|
return curve ? PathConvert.toCanvasData(path, true) : path;
|
|
517
540
|
}
|
|
518
|
-
getPathString(curve) {
|
|
519
|
-
return PathConvert.stringify(this.getPath(curve));
|
|
541
|
+
getPathString(curve, pathForRender) {
|
|
542
|
+
return PathConvert.stringify(this.getPath(curve, pathForRender));
|
|
520
543
|
}
|
|
521
544
|
__onUpdateSize() {
|
|
522
545
|
if (this.__.__input) {
|
|
@@ -688,6 +711,12 @@ __decorate([
|
|
|
688
711
|
__decorate([
|
|
689
712
|
strokeType(10)
|
|
690
713
|
], UI.prototype, "miterLimit", void 0);
|
|
714
|
+
__decorate([
|
|
715
|
+
strokeType('none')
|
|
716
|
+
], UI.prototype, "startArrow", void 0);
|
|
717
|
+
__decorate([
|
|
718
|
+
strokeType('none')
|
|
719
|
+
], UI.prototype, "endArrow", void 0);
|
|
691
720
|
__decorate([
|
|
692
721
|
pathType(0)
|
|
693
722
|
], UI.prototype, "cornerRadius", void 0);
|
|
@@ -1184,26 +1213,10 @@ let Image = class Image extends Rect {
|
|
|
1184
1213
|
get ready() { return this.image ? this.image.ready : false; }
|
|
1185
1214
|
constructor(data) {
|
|
1186
1215
|
super(data);
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
const fill = this.fill;
|
|
1192
|
-
if (fill) {
|
|
1193
|
-
if (fill.url !== url)
|
|
1194
|
-
update = true;
|
|
1195
|
-
}
|
|
1196
|
-
else {
|
|
1197
|
-
if (url)
|
|
1198
|
-
update = true;
|
|
1199
|
-
}
|
|
1200
|
-
if (update) {
|
|
1201
|
-
if (this.image)
|
|
1202
|
-
this.image = null;
|
|
1203
|
-
this.fill = url ? { type: 'image', mode: 'strench', url } : undefined;
|
|
1204
|
-
this.once(ImageEvent.LOADED, (e) => this.image = e.image);
|
|
1205
|
-
}
|
|
1206
|
-
super.__updateBoxBounds();
|
|
1216
|
+
this.on(ImageEvent.LOADED, (e) => {
|
|
1217
|
+
if (e.attrName === 'fill' && e.attrValue.url === this.url)
|
|
1218
|
+
this.image = e.image;
|
|
1219
|
+
});
|
|
1207
1220
|
}
|
|
1208
1221
|
destroy() {
|
|
1209
1222
|
this.image = null;
|
|
@@ -1333,11 +1346,12 @@ let Text = class Text extends UI {
|
|
|
1333
1346
|
__updateBoxBounds() {
|
|
1334
1347
|
const data = this.__;
|
|
1335
1348
|
const layout = this.__layout;
|
|
1336
|
-
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow } = data;
|
|
1349
|
+
const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data;
|
|
1337
1350
|
const autoWidth = data.__autoWidth;
|
|
1338
1351
|
const autoHeight = data.__autoHeight;
|
|
1339
1352
|
data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
|
|
1340
1353
|
data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
|
|
1354
|
+
data.__padding = padding ? MathHelper.fourNumber(padding) : undefined;
|
|
1341
1355
|
data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
|
|
1342
1356
|
data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
|
|
1343
1357
|
data.__clipText = textOverflow !== 'show' && !data.__autoBounds;
|
|
@@ -1351,9 +1365,8 @@ let Text = class Text extends UI {
|
|
|
1351
1365
|
b.y = autoHeight ? bounds.y : 0;
|
|
1352
1366
|
b.width = autoWidth ? bounds.width : data.width;
|
|
1353
1367
|
b.height = autoHeight ? bounds.height : data.height;
|
|
1354
|
-
const { padding } = data;
|
|
1355
1368
|
if (padding) {
|
|
1356
|
-
const [top, right, bottom, left] =
|
|
1369
|
+
const [top, right, bottom, left] = data.__padding;
|
|
1357
1370
|
if (autoWidth) {
|
|
1358
1371
|
b.x -= left;
|
|
1359
1372
|
b.width += (right + left);
|
|
@@ -1538,6 +1551,7 @@ let Leafer = class Leafer extends Group {
|
|
|
1538
1551
|
get __tag() { return 'Leafer'; }
|
|
1539
1552
|
get isApp() { return false; }
|
|
1540
1553
|
get app() { return this.parent || this; }
|
|
1554
|
+
get imageReady() { return this.viewReady && ImageManager.isComplete; }
|
|
1541
1555
|
get layoutLocked() { return !this.layouter.running; }
|
|
1542
1556
|
get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
|
|
1543
1557
|
constructor(userConfig, data) {
|
|
@@ -1740,23 +1754,26 @@ let Leafer = class Leafer extends Group {
|
|
|
1740
1754
|
this.emitLeafer(LeaferEvent.VIEW_READY);
|
|
1741
1755
|
WaitHelper.run(this.__viewReadyWait);
|
|
1742
1756
|
}
|
|
1743
|
-
|
|
1744
|
-
if (
|
|
1745
|
-
this.
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
this.
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1757
|
+
__onAnimateFrame() {
|
|
1758
|
+
if (this.viewReady) {
|
|
1759
|
+
if (this.__nextRenderWait.length)
|
|
1760
|
+
WaitHelper.run(this.__nextRenderWait);
|
|
1761
|
+
const { imageReady } = this;
|
|
1762
|
+
if (imageReady && !this.viewCompleted)
|
|
1763
|
+
this.__checkViewCompleted();
|
|
1764
|
+
if (!imageReady)
|
|
1765
|
+
this.viewCompleted = false;
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
__checkViewCompleted(emit = true) {
|
|
1769
|
+
this.nextRender(() => {
|
|
1770
|
+
if (this.imageReady) {
|
|
1771
|
+
if (emit)
|
|
1772
|
+
this.emitLeafer(LeaferEvent.VIEW_COMPLETED);
|
|
1773
|
+
WaitHelper.run(this.__viewCompletedWait);
|
|
1774
|
+
this.viewCompleted = true;
|
|
1775
|
+
}
|
|
1776
|
+
});
|
|
1760
1777
|
}
|
|
1761
1778
|
__onWatchData() {
|
|
1762
1779
|
if (this.watcher.childrenChanged && this.interaction) {
|
|
@@ -1770,22 +1787,17 @@ let Leafer = class Leafer extends Group {
|
|
|
1770
1787
|
this.viewReady ? item() : this.__viewReadyWait.push(item);
|
|
1771
1788
|
}
|
|
1772
1789
|
waitViewCompleted(item) {
|
|
1790
|
+
this.__viewCompletedWait.push(item);
|
|
1773
1791
|
if (this.viewCompleted) {
|
|
1774
|
-
|
|
1792
|
+
this.__checkViewCompleted(false);
|
|
1775
1793
|
}
|
|
1776
1794
|
else {
|
|
1777
|
-
this.__viewCompletedWait.push(item);
|
|
1778
1795
|
if (!this.running)
|
|
1779
1796
|
this.start();
|
|
1780
1797
|
}
|
|
1781
1798
|
}
|
|
1782
1799
|
nextRender(item) {
|
|
1783
|
-
|
|
1784
|
-
item();
|
|
1785
|
-
}
|
|
1786
|
-
else {
|
|
1787
|
-
this.__nextRenderWait.push(item);
|
|
1788
|
-
}
|
|
1800
|
+
this.__nextRenderWait.push(item);
|
|
1789
1801
|
}
|
|
1790
1802
|
__checkUpdateLayout() {
|
|
1791
1803
|
this.__layout.update();
|
|
@@ -1798,7 +1810,8 @@ let Leafer = class Leafer extends Group {
|
|
|
1798
1810
|
this.once(LeaferEvent.START, () => Run.end(runId));
|
|
1799
1811
|
this.once(LayoutEvent.END, () => this.__onReady());
|
|
1800
1812
|
this.once(RenderEvent.START, () => this.__onCreated());
|
|
1801
|
-
this.
|
|
1813
|
+
this.once(RenderEvent.END, () => this.__onViewReady());
|
|
1814
|
+
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(AnimateEvent.FRAME, this.__onAnimateFrame, this), this.on_(LayoutEvent.CHECK_UPDATE, this.__checkUpdateLayout, this));
|
|
1802
1815
|
}
|
|
1803
1816
|
__removeListenEvents() {
|
|
1804
1817
|
this.off_(this.__eventIds);
|
|
@@ -1925,9 +1938,6 @@ let App = class App extends Leafer {
|
|
|
1925
1938
|
if (this.children.every(child => child.viewReady))
|
|
1926
1939
|
super.__onViewReady();
|
|
1927
1940
|
}
|
|
1928
|
-
__checkViewCompleted() {
|
|
1929
|
-
return this.children.every(item => item.viewCompleted);
|
|
1930
|
-
}
|
|
1931
1941
|
__onChildRenderEnd(e) {
|
|
1932
1942
|
this.renderer.addBlock(e.renderBounds);
|
|
1933
1943
|
if (this.viewReady)
|
|
@@ -1957,7 +1967,7 @@ let App = class App extends Leafer {
|
|
|
1957
1967
|
__listenChildEvents(leafer) {
|
|
1958
1968
|
leafer.once(LayoutEvent.END, () => this.__onReady());
|
|
1959
1969
|
leafer.once(RenderEvent.START, () => this.__onCreated());
|
|
1960
|
-
leafer.once(RenderEvent.END, (
|
|
1970
|
+
leafer.once(RenderEvent.END, () => this.__onViewReady());
|
|
1961
1971
|
if (this.realCanvas)
|
|
1962
1972
|
this.__eventIds.push(leafer.on_(RenderEvent.END, this.__onChildRenderEnd, this));
|
|
1963
1973
|
}
|
|
@@ -1966,4 +1976,4 @@ App = __decorate([
|
|
|
1966
1976
|
registerUI()
|
|
1967
1977
|
], App);
|
|
1968
1978
|
|
|
1969
|
-
export { Animate, App, Box, BoxData, Canvas, CanvasData, ColorConvert, Effect, Ellipse, EllipseData, Export, Frame, FrameData, Group, GroupData, Image, ImageData, Leafer, LeaferData, LeaferTypeCreator, Line, LineData, Paint, Path, PathData, Pen, PenData, Polygon, PolygonData, Rect, RectData, RectRender, Star, StarData, Text, TextConvert, TextData, UI, UIBounds, UIData, UIHit, UIRender, UnitConvert, effectType, resizeType };
|
|
1979
|
+
export { Animate, App, ArrowData, Box, BoxData, Canvas, CanvasData, ColorConvert, Effect, Ellipse, EllipseData, Export, Frame, FrameData, Group, GroupData, Image, ImageData, Leafer, LeaferData, LeaferTypeCreator, Line, LineData, Paint, Path, PathData, Pen, PenData, Polygon, PolygonData, Rect, RectData, RectRender, Star, StarData, Text, TextConvert, TextData, UI, UIBounds, UIData, UIHit, UIRender, UnitConvert, effectType, resizeType };
|
package/dist/core.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MoveEvent as t,LeafHelper as e,ZoomEvent as s,Debug as i,LeafData as o,PathConvert as r,defineLeafAttr as a,OneRadian as h,Platform as _,dataProcessor as n,dataType as d,surfaceType as l,opacityType as p,maskType as c,eraserType as u,sortType as y,positionType as v,boundsType as g,scaleType as f,rotationType as w,autoLayoutType as x,hitType as m,strokeType as R,cursorType as k,pathType as B,rewrite as S,Leaf as C,PathDrawer as b,useModule as A,rewriteAble as P,PathCorner as E,UICreator as L,MatrixHelper as F,Branch as D,registerUI as T,affectRenderBoundsType as z,BoundsHelper as M,PathCommandDataHelper as W,affectStrokeBoundsType as I,PathScaler as O,PointHelper as H,PathBounds as V,ImageEvent as N,Creator as Y,Matrix as X,MathHelper as j,PathCreator as U,DataHelper as G,CanvasManager as J,HitCanvasManager as $,PluginManager as q,LeaferEvent as K,canvasSizeAttrs as Z,ResizeEvent as Q,AutoBounds as tt,WaitHelper as et,ImageManager as st,Run as it,LayoutEvent as ot,RenderEvent as rt,WatchEvent as at,PropertyEvent as ht}from"@leafer/core";export*from"@leafer/core";function _t(t,e,s,i){var o,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,i);else for(var h=t.length-1;h>=0;h--)(o=t[h])&&(a=(r<3?o(a):r>3?o(e,s,a):o(e,s))||a);return r>3&&a&&Object.defineProperty(e,s,a),a}function nt(t){const{config:e}=t;e.move.dragOut=!1}"function"==typeof SuppressedError&&SuppressedError;const dt=i.get("LeaferTypeCreator"),lt={list:{},register(t,e){pt[t]?dt.repeat(t):pt[t]=e},run(t,e){const s=lt.list[t];s?s(e):dt.error("no",t)}},{list:pt}=lt;lt.register("draw",nt),lt.register("user",nt),lt.register("design",(function(i){i.isApp||i.__eventIds.push(i.on_(t.BEFORE_MOVE,(t=>{e.moveWorld(i.zoomLayer,t.moveX,t.moveY)})),i.on_(s.BEFORE_ZOOM,(t=>{const{scaleX:s}=i.zoomLayer.__,{min:o,max:r}=i.app.config.zoom;let{scale:a}=t;a*Math.abs(s)<o?a=o/s:a*Math.abs(s)>r&&(a=r/s),1!==a&&e.zoomOfWorld(i.zoomLayer,t,a)})))}));const ct={},ut={},yt={},vt={},gt={},ft={},wt={},xt=i.get("UIData");class mt extends o{get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoBounds(){return!this._width&&!this._height}setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,xt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,xt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&(this.__naturalWidth=this.__naturalHeight=void 0),"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=wt)):(this.__isFills&&(this.__removeInput("fill"),ut.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=wt)):(this.__isStrokes&&(this.__removeInput("stroke"),ut.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=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}}const Rt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class kt extends mt{}class Bt extends kt{get __boxStroke(){return!0}}class St extends kt{}class Ct extends Bt{}class bt extends mt{}class At extends mt{get __boxStroke(){return!0}}class Pt extends mt{get __boxStroke(){return!0}}class Et extends mt{}class Lt extends mt{}const{parse:Ft}=r;class Dt extends mt{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=Ft(t)):(this.__input&&this.__removeInput("path"),this._path=t)}}class Tt extends kt{}const zt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Mt extends mt{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=zt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Wt extends At{}class It extends At{}function Ot(t){return(e,s)=>{a(e,s,t,{set(t){this.__setAttr(s,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function Ht(t){return(e,s)=>{a(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}const Vt={__updateStrokeSpread(){let t=0,e=0;const{stroke:s,hitStroke:i,strokeAlign:o,strokeWidth:r}=this.__;if((s||"all"===i)&&r&&"inside"!==o&&(e=t="center"===o?r/2:r,!this.__.__boxStroke)){const{miterLimit:e,strokeCap:s}=this.__,i="Line"!==this.__tag?1/Math.sin(e*h/2)*Math.sqrt(r)-t:0,o="none"===s?0:r;t+=Math.max(i,o)}return this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:i,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)})),i&&(t=Math.max(t,i));let r=t=Math.ceil(t);return s&&s.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}},Nt={__updateHitCanvas(){this.__hitCanvas||(this.__hitCanvas=this.leafer.hitCanvasManager.getPathType(this));const t=this.__hitCanvas;this.__drawHitPath(t),t.setStrokeOptions(this.__)},__hit(t){const{__hitCanvas:e}=this;"miniapp"===_.name&&this.__drawHitPath(e);const{fill:s,hitFill:i,windingRule:o}=this.__,r=s&&"path"===i||"all"===i,a=e.hitFill(t,o);if(r&&a)return!0;const{stroke:h,hitStroke:n,strokeWidth:d,strokeAlign:l}=this.__,p=h&&"path"===n||"all"===n,c=2*t.radiusX;let u=c;if(p)switch(l){case"inside":if(u+=2*d,!r&&a&&e.hitStroke(t,u))return!0;u=c;break;case"center":u+=d;break;case"outside":if(u+=2*d,!r){if(!a&&e.hitStroke(t,u))return!0;u=c}}return!!u&&e.hitStroke(t,u)}},Yt={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:i,backgroundBlur:o}=this.__;t.__useEffect=!!(e||s||i||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){const{fill:s,stroke:i,__drawAfterFill:o}=this.__;this.__drawRenderPath(t),s&&ut.fill(s,this,t),o&&this.__drawAfterFill(t,e),i&&ut.stroke(i,this,t,e)},__draw(t,e){if(this.__.__complex){const{fill:s,stroke:i,__drawAfterFill:o}=this.__;if(this.__drawRenderPath(t),this.__.__useEffect){const r=ut.shape(this,t,e),{shadow:a,innerShadow:h}=this.__;a&&ct.shadow(this,t,r,e),s&&(this.__.__isFills?ut.fills(s,this,t):ut.fill(s,this,t)),o&&this.__drawAfterFill(t,e),h&&ct.innerShadow(this,t,r,e),i&&(this.__.__isStrokes?ut.strokes(i,this,t,e):ut.stroke(i,this,t,e)),r.worldCanvas&&r.worldCanvas.recycle(),r.canvas.recycle()}else s&&(this.__.__isFills?ut.fills(s,this,t):ut.fill(s,this,t)),o&&this.__drawAfterFill(t,e),i&&(this.__.__isStrokes?ut.strokes(i,this,t,e):ut.stroke(i,this,t,e))}else this.__drawFast(t,e)},__renderShape(t,e){if(!this.__worldOpacity)return;t.setWorld(this.__world,e.matrix);const{fill:s,stroke:i}=this.__;this.__drawRenderPath(t),s&&(this.__.__pixelFill?ut.fills(s,this,t):ut.fill("#000000",this,t)),i&&(this.__.__pixelStroke?ut.strokes(i,this,t,e):ut.stroke("#000000",this,t,e))}},Xt={__drawFast(t,e){const{width:s,height:i,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,s,i)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:e,strokeWidth:o}=this.__;t.setStroke(r,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,s,i);break;case"inside":t.strokeRect(a,a,s-o,i-o);break;case"outside":t.strokeRect(-a,-a,s+o,i+o)}}}};var jt;let Ut=jt=class extends C{get app(){return this.leafer&&this.leafer.app}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}createProxyData(){}find(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!1,e):[]}findOne(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!0,e):null}getPath(t){const{path:e}=this.__;return e?t?r.toCanvasData(e,!0):e:[]}getPathString(t){return r.stringify(this.getPath(t))}__onUpdateSize(){if(this.__.__input){const{fill:t,stroke:e}=this.__.__input;t&&ut.compute("fill",this),e&&ut.compute("stroke",this)}}__updateRenderPath(){if(this.__.path){const{__:t}=this;t.__pathForRender=t.cornerRadius?E.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){}__drawPathByBox(t){const{x:e,y:s,width:i,height:o}=this.__layout.boxBounds;this.__.cornerRadius?t.roundRect(e,s,i,o,this.__.cornerRadius):t.rect(e,s,i,o)}export(t,e){return ft.export(this,t,e)}clone(){return jt.one(this.toJSON())}static one(t,e,s,i,o){return L.get(t.tag||this.prototype.__tag,t,e,s,i,o)}destroy(){this.fill=this.stroke=null,super.destroy()}};_t([n(mt)],Ut.prototype,"__",void 0),_t([d("")],Ut.prototype,"id",void 0),_t([d("")],Ut.prototype,"name",void 0),_t([d("")],Ut.prototype,"className",void 0),_t([l("pass-through")],Ut.prototype,"blendMode",void 0),_t([p(1)],Ut.prototype,"opacity",void 0),_t([p(!0)],Ut.prototype,"visible",void 0),_t([c(!1)],Ut.prototype,"isMask",void 0),_t([u(!1)],Ut.prototype,"isEraser",void 0),_t([d(!1)],Ut.prototype,"locked",void 0),_t([y(0)],Ut.prototype,"zIndex",void 0),_t([v(0)],Ut.prototype,"x",void 0),_t([v(0)],Ut.prototype,"y",void 0),_t([g(100)],Ut.prototype,"width",void 0),_t([g(100)],Ut.prototype,"height",void 0),_t([f(1)],Ut.prototype,"scaleX",void 0),_t([f(1)],Ut.prototype,"scaleY",void 0),_t([w(0)],Ut.prototype,"rotation",void 0),_t([w(0)],Ut.prototype,"skewX",void 0),_t([w(0)],Ut.prototype,"skewY",void 0),_t([x()],Ut.prototype,"around",void 0),_t([d(!1)],Ut.prototype,"draggable",void 0),_t([d(!1)],Ut.prototype,"editable",void 0),_t([d("size")],Ut.prototype,"editSize",void 0),_t([m(!0)],Ut.prototype,"hittable",void 0),_t([m("path")],Ut.prototype,"hitFill",void 0),_t([R("path")],Ut.prototype,"hitStroke",void 0),_t([m(!1)],Ut.prototype,"hitBox",void 0),_t([m(!0)],Ut.prototype,"hitChildren",void 0),_t([m(!0)],Ut.prototype,"hitSelf",void 0),_t([m()],Ut.prototype,"hitRadius",void 0),_t([k("")],Ut.prototype,"cursor",void 0),_t([l()],Ut.prototype,"fill",void 0),_t([R()],Ut.prototype,"stroke",void 0),_t([R("inside")],Ut.prototype,"strokeAlign",void 0),_t([R(1)],Ut.prototype,"strokeWidth",void 0),_t([R("none")],Ut.prototype,"strokeCap",void 0),_t([R("miter")],Ut.prototype,"strokeJoin",void 0),_t([R()],Ut.prototype,"dashPattern",void 0),_t([R()],Ut.prototype,"dashOffset",void 0),_t([R(10)],Ut.prototype,"miterLimit",void 0),_t([B(0)],Ut.prototype,"cornerRadius",void 0),_t([B()],Ut.prototype,"cornerSmoothing",void 0),_t([Ot()],Ut.prototype,"shadow",void 0),_t([Ot()],Ut.prototype,"innerShadow",void 0),_t([Ot()],Ut.prototype,"blur",void 0),_t([Ot()],Ut.prototype,"backgroundBlur",void 0),_t([Ot()],Ut.prototype,"grayscale",void 0),_t([S(C.prototype.reset)],Ut.prototype,"reset",null),_t([S(b.drawPathByData)],Ut.prototype,"__drawPathByData",null),Ut=jt=_t([A(Vt),A(Nt),A(Yt),P()],Ut);const Gt=F.get();let Jt=class extends Ut{get __tag(){return"Group"}set mask(t){this.__hasMask&&this.__removeMask(),t&&(t.isMask=!0,this.addAt(t,0))}get mask(){return this.children.find((t=>t.isMask))}constructor(t){super(t),this.__setBranch()}__setBranch(){this.isBranch=!0,this.children||(this.children=[])}set(t){if(t.children){const{children:e}=t;let s;delete t.children,this.children?this.removeAll(!0):this.__setBranch(),super.set(t),e.forEach((t=>{s=L.get(t.tag,t),this.add(s)})),t.children=e}else super.set(t)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}__scaleResize(t,e){const{children:s}=this;for(let i=0;i<s.length;i++)Gt.a=t,Gt.d=e,s[i].transform(Gt,!0)}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){}};_t([n(kt)],Jt.prototype,"__",void 0),Jt=_t([A(D),T()],Jt);let $t=class extends Ut{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){}};_t([n(At)],$t.prototype,"__",void 0),_t([S(Ut.prototype.__drawPathByBox)],$t.prototype,"__drawPathByData",null),$t=_t([A(Xt),P(),T()],$t);const qt=$t.prototype,Kt=Jt.prototype,Zt={},{copy:Qt,add:te}=M;let ee=class extends Jt{get __tag(){return"Box"}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderChanged||this.__layout.renderChange()}__scaleResize(t,e){this.__.__autoBounds&&this.children.length?super.__scaleResize(t,e):(this.width*=t,this.height*=e)}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateRectBoxBounds(){}__updateBoxBounds(){this.__.__autoBounds&&this.children.length?super.__updateBoxBounds():this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;Qt(Zt,t),super.__updateRenderBounds(),te(t,Zt)}}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__drawPathByData(t,e){}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}};_t([n(Bt)],ee.prototype,"__",void 0),_t([z("show")],ee.prototype,"overflow",void 0),_t([S(qt.__updateStrokeSpread)],ee.prototype,"__updateStrokeSpread",null),_t([S(qt.__updateRenderSpread)],ee.prototype,"__updateRectRenderSpread",null),_t([S(qt.__updateBoxBounds)],ee.prototype,"__updateRectBoxBounds",null),_t([S(qt.__updateStrokeBounds)],ee.prototype,"__updateStrokeBounds",null),_t([S(qt.__updateRenderBounds)],ee.prototype,"__updateRectRenderBounds",null),_t([S(qt.__updateChange)],ee.prototype,"__updateRectChange",null),_t([S(qt.__drawPathByData)],ee.prototype,"__drawPathByData",null),_t([S(qt.__render)],ee.prototype,"__renderRect",null),_t([S(Kt.__render)],ee.prototype,"__renderGroup",null),ee=_t([P(),T()],ee);let se=class extends ee{get __tag(){return"Frame"}constructor(t){super(t),this.isFrame=!0,this.__.fill||(this.__.fill="#FFFFFF")}};_t([n(Ct)],se.prototype,"__",void 0),_t([z("hide")],se.prototype,"overflow",void 0),se=_t([T()],se);const{moveTo:ie,closePath:oe,ellipse:re}=W;let ae=class extends Ut{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:s,startAngle:i,endAngle:o}=this.__,r=t/2,a=e/2,h=this.__.path=[];s?(i||o?(s<1&&re(h,r,a,r*s,a*s,0,i,o,!1),re(h,r,a,r,a,0,o,i,!0),s<1&&oe(h)):(s<1&&(re(h,r,a,r*s,a*s),ie(h,t,a)),re(h,r,a,r,a,0,360,0,!0)),_.ellipseToCurve&&(this.__.path=this.getPath(!0))):i||o?(ie(h,r,a),re(h,r,a,r,a,0,i,o,!1),oe(h)):re(h,r,a,r,a)}};_t([n(Pt)],ae.prototype,"__",void 0),_t([B(0)],ae.prototype,"innerRadius",void 0),_t([B(0)],ae.prototype,"startAngle",void 0),_t([B(0)],ae.prototype,"endAngle",void 0),ae=_t([T()],ae);const{moveTo:he,lineTo:_e,drawPoints:ne}=W,{rotate:de,getAngle:le,getDistance:pe,defaultPoint:ce}=H,{toBounds:ue}=V;let ye=class extends Ut{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,s={x:0,y:0};return t&&(s.x=t),e&&de(s,e),s}set toPoint(t){this.width=pe(ce,t),this.rotation=le(ce,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?ne(t,this.__.points,!1):(he(t,0,0),_e(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?ne(this.__.__pathForRender=[],this.__.points,this.__.curve,"Line"!==this.__tag):super.__updateRenderPath()}__updateBoxBounds(){this.points?ue(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}__scaleResize(t,e){if(this.points)O.scalePoints(this.__.points,t,e),this.points=this.__.points;else if("Line"===this.__tag){const s=this.toPoint;s.x*=t,s.y*=e,this.toPoint=s}else super.__scaleResize(t,e)}};_t([n(bt)],ye.prototype,"__",void 0),_t([I("center")],ye.prototype,"strokeAlign",void 0),_t([g(0)],ye.prototype,"height",void 0),_t([B()],ye.prototype,"points",void 0),_t([B(0)],ye.prototype,"curve",void 0),ye=_t([T()],ye);const{sin:ve,cos:ge,PI:fe}=Math,{moveTo:we,lineTo:xe,closePath:me,drawPoints:Re}=W,ke=ye.prototype;let Be=class extends Ut{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Re(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:i}=this.__,o=e/2,r=s/2;we(t,o,0);for(let e=1;e<i;e++)xe(t,o+o*ve(2*e*fe/i),r-r*ge(2*e*fe/i))}me(t)}__updateRenderPath(){}__updateBoxBounds(){}__scaleResize(t,e){}};_t([n(Et)],Be.prototype,"__",void 0),_t([B(3)],Be.prototype,"sides",void 0),_t([B()],Be.prototype,"points",void 0),_t([B(0)],Be.prototype,"curve",void 0),_t([S(ke.__updateRenderPath)],Be.prototype,"__updateRenderPath",null),_t([S(ke.__updateBoxBounds)],Be.prototype,"__updateBoxBounds",null),_t([S(ke.__scaleResize)],Be.prototype,"__scaleResize",null),Be=_t([P(),T()],Be);const{sin:Se,cos:Ce,PI:be}=Math,{moveTo:Ae,lineTo:Pe,closePath:Ee}=W;let Le=class extends Ut{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:i}=this.__,o=t/2,r=e/2,a=this.__.path=[];Ae(a,o,0);for(let t=1;t<2*s;t++)Pe(a,o+(t%2==0?o:o*i)*Se(t*be/s),r-(t%2==0?r:r*i)*Ce(t*be/s));Ee(a)}};_t([n(Lt)],Le.prototype,"__",void 0),_t([B(5)],Le.prototype,"corners",void 0),_t([B(.382)],Le.prototype,"innerRadius",void 0),Le=_t([T()],Le);let Fe=class extends $t{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t)}__updateBoxBounds(){let t;const{url:e}=this,s=this.fill;s?s.url!==e&&(t=!0):e&&(t=!0),t&&(this.image&&(this.image=null),this.fill=e?{type:"image",mode:"strench",url:e}:void 0,this.once(N.LOADED,(t=>this.image=t.image))),super.__updateBoxBounds()}destroy(){this.image=null,super.destroy()}};_t([n(Wt)],Fe.prototype,"__",void 0),_t([g("")],Fe.prototype,"url",void 0),Fe=_t([T()],Fe);let De=class extends $t{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=Y.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(t,e,s,i){t.__layout.update();const o=new X(t.__world);o.invert();const r=new X;e&&r.translate(e.x,e.y),s&&("number"==typeof s?r.scale(s):r.scale(s.x,s.y)),i&&r.rotate(i),o.multiplyParent(r),t.__render(this.canvas,{matrix:o}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:i,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,i,o),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,i,o)}__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=null,this.context=null),super.destroy()}};_t([n(Wt)],De.prototype,"__",void 0),_t([Ht(100)],De.prototype,"width",void 0),_t([Ht(100)],De.prototype,"height",void 0),_t([Ht(_.devicePixelRatio)],De.prototype,"pixelRatio",void 0),_t([Ht(!0)],De.prototype,"smooth",void 0),_t([m("all")],De.prototype,"hitFill",void 0),De=_t([T()],De);const{copyAndSpread:Te,includes:ze,spread:Me,setList:We}=M;let Ie=class extends Ut{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:s,__textDrawData:i}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):i.rows.forEach((i=>t.rect(i.x,i.y-s,i.width,e)))}__drawPathByData(t,e){const{x:s,y:i,width:o,height:r}=this.__layout.boxBounds;t.rect(s,i,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=vt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:s,letterSpacing:i,fontFamily:o,fontSize:r,fontWeight:a,italic:h,textCase:_,textOverflow:n}=t,d=t.__autoWidth,l=t.__autoHeight;t.__lineHeight=Rt.number(s,r),t.__letterSpacing=Rt.number(i,r),t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*r)/2,t.__font=`${h?"italic ":""}${"small-caps"===_?"small-caps ":""}${"normal"!==a?a+" ":""}${r}px ${o}`,t.__clipText="show"!==n&&!t.__autoBounds,this.__updateTextDrawData();const{bounds:p}=t.__textDrawData,c=e.boxBounds;if(t.__lineHeight<r&&Me(p,r/2),d||l){c.x=d?p.x:0,c.y=l?p.y:0,c.width=d?p.width:t.width,c.height=l?p.height:t.height;const{padding:e}=t;if(e){const[t,s,i,o]=j.fourNumber(e);d&&(c.x-=o,c.width+=s+o),l&&(c.y-=t,c.height+=i+t)}this.__updateNaturalSize()}else super.__updateBoxBounds();const u=ze(c,p)?c:p;u!==e.contentBounds?(e.contentBounds=u,e.renderChanged=!0,We(t.__textBoxBounds={},[c,p])):t.__textBoxBounds=u}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){Te(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};_t([n(Mt)],Ie.prototype,"__",void 0),_t([g(0)],Ie.prototype,"width",void 0),_t([g(0)],Ie.prototype,"height",void 0),_t([g(0)],Ie.prototype,"padding",void 0),_t([l("#000000")],Ie.prototype,"fill",void 0),_t([I("outside")],Ie.prototype,"strokeAlign",void 0),_t([m("all")],Ie.prototype,"hitFill",void 0),_t([g("")],Ie.prototype,"text",void 0),_t([g("L")],Ie.prototype,"fontFamily",void 0),_t([g(12)],Ie.prototype,"fontSize",void 0),_t([g("normal")],Ie.prototype,"fontWeight",void 0),_t([g(!1)],Ie.prototype,"italic",void 0),_t([g("none")],Ie.prototype,"textCase",void 0),_t([g("none")],Ie.prototype,"textDecoration",void 0),_t([g(0)],Ie.prototype,"letterSpacing",void 0),_t([g({type:"percent",value:150})],Ie.prototype,"lineHeight",void 0),_t([g(0)],Ie.prototype,"paraIndent",void 0),_t([g(0)],Ie.prototype,"paraSpacing",void 0),_t([g("left")],Ie.prototype,"textAlign",void 0),_t([g("top")],Ie.prototype,"verticalAlign",void 0),_t([g("normal")],Ie.prototype,"textWrap",void 0),_t([g("show")],Ie.prototype,"textOverflow",void 0),Ie=_t([T()],Ie);const{toBounds:Oe}=V;let He=class extends Ut{get __tag(){return"Path"}constructor(t){super(t)}__scaleResize(t,e){O.scale(this.__.path,t,e),this.path=this.__.path}__updateBoxBounds(){Oe(this.__.path,this.__layout.boxBounds)}};_t([n(Dt)],He.prototype,"__",void 0),_t([B()],He.prototype,"path",void 0),_t([B()],He.prototype,"windingRule",void 0),_t([I("center")],He.prototype,"strokeAlign",void 0),He=_t([T()],He);let Ve=class extends Jt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new He(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,s,i,o,r){return this}quadraticCurveTo(t,e,s,i){return this}closePath(){return this}rect(t,e,s,i){return this}roundRect(t,e,s,i,o){return this}ellipse(t,e,s,i,o,r,a,h){return this}arc(t,e,s,i,o,r){return this}arcTo(t,e,s,i,o){return this}drawEllipse(t,e,s,i,o,r,a,h){return this}drawArc(t,e,s,i,o,r){return this}drawPoints(t,e,s){return this}paint(){this.pathElement.forceUpdate("path")}clear(){this.removeAll(!0)}};_t([n(Tt)],Ve.prototype,"__",void 0),Ve=_t([A(U,["beginPath"]),T()],Ve);const Ne=i.get("Leafer");let Ye=class extends Jt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get layoutLocked(){return!this.layouter.running}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.zoomLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,dragOut:!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)}init(t,e){if(this.canvas)return;let s;this.__setLeafer(this),t&&G.assign(this.config,t);const{config:i}=this;lt.run(i.type,this),this.canvas=Y.canvas(i),this.__controllers.push(this.renderer=Y.renderer(this,this.canvas,i),this.watcher=Y.watcher(this,i),this.layouter=Y.layouter(this,i)),this.isApp&&this.__setApp(),this.__checkAutoLayout(i),this.view=this.canvas.view,e?(this.__bindApp(e),s=e.running):(this.selector=Y.selector(this),this.__controllers.unshift(this.interaction=Y.interaction(this,this.canvas,this.selector,i)),this.canvasManager=new J,this.hitCanvasManager=new $,s=i.start),this.hittable=i.hittable,this.fill=i.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),s&&(this.__startTimer=setTimeout(this.start.bind(this))),q.onLeafer(this)}set(t){this.children?super.set(t):setTimeout((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(K.RESTART):this.emitLeafer(K.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(K.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=G.copyAttrs({},t,Z);Object.keys(e).forEach((t=>this[t]=e[t]))}forceFullRender(){this.renderer.addBlock(this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(){this.interaction&&this.interaction.updateCursor()}__doResize(t){if(!this.canvas||this.canvas.isSameSize(t))return;const e=G.copyAttrs({},this.canvas,Z);this.canvas.resize(t),this.__onResize(new Q(t,e))}__onResize(t){this.emitEvent(t),G.copyAttrs(this.__,t,Z),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.isLeafer=!!t,this.__level=1}setZoomLayer(t){this.zoomLayer=t}__checkAutoLayout(t){t.width&&t.height||(this.autoLayout=new tt(t),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){this.canvas&&(Z.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t&&(this.canvas.hittable=e)),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Z.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const s=G.copyAttrs({},this.canvas,Z);s[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(s)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(K.BEFORE_READY),this.emitLeafer(K.READY),this.emitLeafer(K.AFTER_READY),et.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(K.VIEW_READY),et.run(this.__viewReadyWait))}__onRenderEnd(t){this.viewReady||this.__onViewReady();const e=this.__checkViewCompleted();e&&this.__onViewCompleted(),this.viewCompleted=e,et.run(this.__nextRenderWait)}__checkViewCompleted(){return this.viewReady&&!this.watcher.changed&&st.isComplete}__onViewCompleted(){this.viewCompleted||(this.emitLeafer(K.VIEW_COMPLETED),et.run(this.__viewCompletedWait))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitReady(t){this.ready?t():this.__readyWait.push(t)}waitViewReady(t){this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t){this.viewCompleted?t():(this.__viewCompletedWait.push(t),this.running||this.start())}nextRender(t){this.watcher&&!this.watcher.changed?t():this.__nextRenderWait.push(t)}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new K(t,this))}__listenEvents(){const t=it.start("FirstCreate "+this.innerName);this.once(K.START,(()=>it.end(t))),this.once(ot.END,(()=>this.__onReady())),this.once(rt.START,(()=>this.__onCreated())),this.__eventIds.push(this.on_(at.DATA,this.__onWatchData,this),this.on_(rt.END,this.__onRenderEnd,this),this.on_(ot.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){setTimeout((()=>{if(!this.destroyed)try{this.stop(),this.emitEvent(new K(K.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector.destroy(),this.canvasManager.destroy(),this.hitCanvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{st.clearRecycled()}),100)}catch(t){Ne.error(t)}}))}};_t([n(St)],Ye.prototype,"__",void 0),_t([g()],Ye.prototype,"pixelRatio",void 0),Ye=_t([T()],Ye);let Xe=class extends Ye{get __tag(){return"App"}get isApp(){return!0}constructor(t,e){if(super(t,e),t){const{ground:e,tree:s,sky:i,editor:o}=t;e&&(this.ground=this.addLeafer(e)),(s||o)&&(this.tree=this.addLeafer(s)),(i||o)&&(this.sky=this.addLeafer(i||{type:"draw",usePartRender:!1})),o&&(this.editor=Y.editor(o),this.sky.add(this.editor))}}__setApp(){const{canvas:t}=this,{realCanvas:e,view:s}=this.config;e||s===this.canvas.view||!t.parentView?this.realCanvas=!0:t.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable(),this.__eventIds.push(this.on_(ht.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>t.start()))}stop(){this.children.forEach((t=>t.stop())),super.stop()}unlockLayout(){super.unlockLayout(),this.children.forEach((t=>t.unlockLayout()))}lockLayout(){super.lockLayout(),this.children.forEach((t=>t.lockLayout()))}addLeafer(t){const e=new Ye(t);return this.add(e),e}add(t){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout((()=>this.add(t)),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t),this.__listenChildEvents(t)}__onPropertyChange(){i.showHitView&&this.children.forEach((t=>t.forceUpdate("surface")))}__onCreated(){this.created=this.children.every((t=>t.created))}__onReady(){this.children.every((t=>t.ready))&&super.__onReady()}__onViewReady(){this.children.every((t=>t.viewReady))&&super.__onViewReady()}__checkViewCompleted(){return this.children.every((t=>t.viewCompleted))}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){this.children.forEach((e=>t.copyWorld(e.canvas)))}__onResize(t){this.children.forEach((e=>e.resize(t))),super.__onResize(t)}__checkUpdateLayout(){this.children.forEach((t=>t.__layout.update()))}__getChildConfig(t){let e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&G.assign(e,t),this.autoLayout&&G.copyAttrs(e,this,Z),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once(ot.END,(()=>this.__onReady())),t.once(rt.START,(()=>this.__onCreated())),t.once(rt.END,(t=>this.__onRenderEnd(t))),this.realCanvas&&this.__eventIds.push(t.on_(rt.END,this.__onChildRenderEnd,this))}};Xe=_t([T()],Xe);export{yt as Animate,Xe as App,ee as Box,Bt as BoxData,De as Canvas,It as CanvasData,gt as ColorConvert,ct as Effect,ae as Ellipse,Pt as EllipseData,ft as Export,se as Frame,Ct as FrameData,Jt as Group,kt as GroupData,Fe as Image,Wt as ImageData,Ye as Leafer,St as LeaferData,lt as LeaferTypeCreator,ye as Line,bt as LineData,ut as Paint,He as Path,Dt as PathData,Ve as Pen,Tt as PenData,Be as Polygon,Et as PolygonData,$t as Rect,At as RectData,Xt as RectRender,Le as Star,Lt as StarData,Ie as Text,vt as TextConvert,Mt as TextData,Ut as UI,Vt as UIBounds,mt as UIData,Nt as UIHit,Yt as UIRender,Rt as UnitConvert,Ot as effectType,Ht as resizeType};
|
|
1
|
+
import{MoveEvent as t,LeafHelper as e,ZoomEvent as s,Debug as i,LeafData as o,PathConvert as r,defineLeafAttr as a,OneRadian as h,Platform as _,dataProcessor as n,dataType as d,surfaceType as l,opacityType as p,maskType as c,eraserType as u,sortType as y,positionType as v,boundsType as g,scaleType as f,rotationType as w,autoLayoutType as m,hitType as x,strokeType as R,cursorType as k,pathType as B,rewrite as S,Leaf as b,PathDrawer as C,useModule as A,rewriteAble as P,PathCreator as E,PathCorner as F,UICreator as L,MatrixHelper as D,Branch as T,registerUI as z,affectRenderBoundsType as M,BoundsHelper as W,PathCommandDataHelper as I,affectStrokeBoundsType as O,PathScaler as H,PointHelper as V,PathBounds as N,ImageEvent as Y,Creator as U,Matrix as X,MathHelper as j,ImageManager as G,DataHelper as J,CanvasManager as $,HitCanvasManager as q,PluginManager as K,LeaferEvent as Z,canvasSizeAttrs as Q,ResizeEvent as tt,AutoBounds as et,WaitHelper as st,Run as it,LayoutEvent as ot,RenderEvent as rt,WatchEvent as at,AnimateEvent as ht,PropertyEvent as _t}from"@leafer/core";export*from"@leafer/core";function nt(t,e,s,i){var o,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,i);else for(var h=t.length-1;h>=0;h--)(o=t[h])&&(a=(r<3?o(a):r>3?o(e,s,a):o(e,s))||a);return r>3&&a&&Object.defineProperty(e,s,a),a}function dt(t){const{config:e}=t;e.move.dragOut=!1}"function"==typeof SuppressedError&&SuppressedError;const lt=i.get("LeaferTypeCreator"),pt={list:{},register(t,e){ct[t]?lt.repeat(t):ct[t]=e},run(t,e){const s=pt.list[t];s?s(e):lt.error("no",t)}},{list:ct}=pt;pt.register("draw",dt),pt.register("user",dt),pt.register("design",(function(i){i.isApp||i.__eventIds.push(i.on_(t.BEFORE_MOVE,(t=>{e.moveWorld(i.zoomLayer,t.moveX,t.moveY)})),i.on_(s.BEFORE_ZOOM,(t=>{const{scaleX:s}=i.zoomLayer.__,{min:o,max:r}=i.app.config.zoom;let{scale:a}=t;a*Math.abs(s)<o?a=o/s:a*Math.abs(s)>r&&(a=r/s),1!==a&&e.zoomOfWorld(i.zoomLayer,t,a)})))}));const ut={},yt={},vt={},gt={},ft={},wt={},mt={},xt=i.get("UIData");class Rt extends o{get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoBounds(){return!this._width&&!this._height}setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,xt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,xt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&(this.__naturalWidth=this.__naturalHeight=void 0),"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=mt)):(this.__isFills&&(this.__removeInput("fill"),yt.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=mt)):(this.__isStrokes&&(this.__removeInput("stroke"),yt.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=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}}const kt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class Bt extends Rt{}class St extends Bt{get __boxStroke(){return!0}}class bt extends Bt{}class Ct extends St{}class At extends Rt{}class Pt extends At{}class Et extends Rt{get __boxStroke(){return!0}}class Ft extends Rt{get __boxStroke(){return!0}}class Lt extends Rt{}class Dt extends Rt{}const{parse:Tt}=r;class zt extends Rt{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=Tt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}}class Mt extends Bt{}const Wt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class It extends Rt{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Wt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Ot extends Et{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"strench",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 Ht extends Et{}function Vt(t){return(e,s)=>{a(e,s,t,{set(t){this.__setAttr(s,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function Nt(t){return(e,s)=>{a(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}const Yt={__updateStrokeSpread(){let t=0,e=0;const{stroke:s,hitStroke:i,strokeAlign:o,strokeWidth:r}=this.__;if((s||"all"===i)&&r&&"inside"!==o&&(e=t="center"===o?r/2:r,!this.__.__boxStroke)){const{miterLimit:e,strokeCap:s}=this.__,i="Line"!==this.__tag?1/Math.sin(e*h/2)*Math.sqrt(r)-t:0,o="none"===s?0:r;t+=Math.max(i,o)}return this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:i,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)})),i&&(t=Math.max(t,i));let r=t=Math.ceil(t);return s&&s.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}},Ut={__updateHitCanvas(){this.__hitCanvas||(this.__hitCanvas=this.leafer.hitCanvasManager.getPathType(this));const t=this.__hitCanvas;this.__drawHitPath(t),t.setStrokeOptions(this.__)},__hit(t){const{__hitCanvas:e}=this;"miniapp"===_.name&&this.__drawHitPath(e);const{fill:s,hitFill:i,windingRule:o}=this.__,r=s&&"path"===i||"all"===i,a=e.hitFill(t,o);if(r&&a)return!0;const{stroke:h,hitStroke:n,strokeWidth:d,strokeAlign:l}=this.__,p=h&&"path"===n||"all"===n,c=2*t.radiusX;let u=c;if(p)switch(l){case"inside":if(u+=2*d,!r&&a&&e.hitStroke(t,u))return!0;u=c;break;case"center":u+=d;break;case"outside":if(u+=2*d,!r){if(!a&&e.hitStroke(t,u))return!0;u=c}}return!!u&&e.hitStroke(t,u)}},Xt={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:i,backgroundBlur:o}=this.__;t.__useEffect=!!(e||s||i||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){const{fill:s,stroke:i,__drawAfterFill:o}=this.__;this.__drawRenderPath(t),s&&yt.fill(s,this,t),o&&this.__drawAfterFill(t,e),i&&yt.stroke(i,this,t,e)},__draw(t,e){if(this.__.__complex){const{fill:s,stroke:i,__drawAfterFill:o}=this.__;if(this.__drawRenderPath(t),this.__.__useEffect){const r=yt.shape(this,t,e),{shadow:a,innerShadow:h}=this.__;a&&ut.shadow(this,t,r,e),s&&(this.__.__isFills?yt.fills(s,this,t):yt.fill(s,this,t)),o&&this.__drawAfterFill(t,e),h&&ut.innerShadow(this,t,r,e),i&&(this.__.__isStrokes?yt.strokes(i,this,t,e):yt.stroke(i,this,t,e)),r.worldCanvas&&r.worldCanvas.recycle(),r.canvas.recycle()}else s&&(this.__.__isFills?yt.fills(s,this,t):yt.fill(s,this,t)),o&&this.__drawAfterFill(t,e),i&&(this.__.__isStrokes?yt.strokes(i,this,t,e):yt.stroke(i,this,t,e))}else this.__drawFast(t,e)},__renderShape(t,e){if(!this.__worldOpacity)return;t.setWorld(this.__world,e.matrix);const{fill:s,stroke:i}=this.__;this.__drawRenderPath(t),s&&(this.__.__pixelFill?yt.fills(s,this,t):yt.fill("#000000",this,t)),i&&(this.__.__pixelStroke?yt.strokes(i,this,t,e):yt.stroke("#000000",this,t,e))}},jt={__drawFast(t,e){const{width:s,height:i,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,s,i)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:e,strokeWidth:o}=this.__;t.setStroke(r,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,s,i);break;case"inside":t.strokeRect(a,a,s-o,i-o);break;case"outside":t.strokeRect(-a,-a,s+o,i+o)}}}};var Gt;let Jt=Gt=class extends b{get app(){return this.leafer&&this.leafer.app}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}createProxyData(){}find(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!1,e):[]}findOne(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!0,e):null}getPath(t,e){this.__layout.update();let s=e?this.__.__pathForRender:this.__.path;return s||this.__drawPathByBox(new E(s=[])),t?r.toCanvasData(s,!0):s}getPathString(t,e){return r.stringify(this.getPath(t,e))}__onUpdateSize(){if(this.__.__input){const{fill:t,stroke:e}=this.__.__input;t&&yt.compute("fill",this),e&&yt.compute("stroke",this)}}__updateRenderPath(){if(this.__.path){const{__:t}=this;t.__pathForRender=t.cornerRadius?F.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){}__drawPathByBox(t){const{x:e,y:s,width:i,height:o}=this.__layout.boxBounds;this.__.cornerRadius?t.roundRect(e,s,i,o,this.__.cornerRadius):t.rect(e,s,i,o)}export(t,e){return wt.export(this,t,e)}clone(){return Gt.one(this.toJSON())}static one(t,e,s,i,o){return L.get(t.tag||this.prototype.__tag,t,e,s,i,o)}destroy(){this.fill=this.stroke=null,super.destroy()}};nt([n(Rt)],Jt.prototype,"__",void 0),nt([d("")],Jt.prototype,"id",void 0),nt([d("")],Jt.prototype,"name",void 0),nt([d("")],Jt.prototype,"className",void 0),nt([l("pass-through")],Jt.prototype,"blendMode",void 0),nt([p(1)],Jt.prototype,"opacity",void 0),nt([p(!0)],Jt.prototype,"visible",void 0),nt([c(!1)],Jt.prototype,"isMask",void 0),nt([u(!1)],Jt.prototype,"isEraser",void 0),nt([d(!1)],Jt.prototype,"locked",void 0),nt([y(0)],Jt.prototype,"zIndex",void 0),nt([v(0)],Jt.prototype,"x",void 0),nt([v(0)],Jt.prototype,"y",void 0),nt([g(100)],Jt.prototype,"width",void 0),nt([g(100)],Jt.prototype,"height",void 0),nt([f(1)],Jt.prototype,"scaleX",void 0),nt([f(1)],Jt.prototype,"scaleY",void 0),nt([w(0)],Jt.prototype,"rotation",void 0),nt([w(0)],Jt.prototype,"skewX",void 0),nt([w(0)],Jt.prototype,"skewY",void 0),nt([m()],Jt.prototype,"around",void 0),nt([d(!1)],Jt.prototype,"draggable",void 0),nt([d(!1)],Jt.prototype,"editable",void 0),nt([d("size")],Jt.prototype,"editSize",void 0),nt([x(!0)],Jt.prototype,"hittable",void 0),nt([x("path")],Jt.prototype,"hitFill",void 0),nt([R("path")],Jt.prototype,"hitStroke",void 0),nt([x(!1)],Jt.prototype,"hitBox",void 0),nt([x(!0)],Jt.prototype,"hitChildren",void 0),nt([x(!0)],Jt.prototype,"hitSelf",void 0),nt([x()],Jt.prototype,"hitRadius",void 0),nt([k("")],Jt.prototype,"cursor",void 0),nt([l()],Jt.prototype,"fill",void 0),nt([R()],Jt.prototype,"stroke",void 0),nt([R("inside")],Jt.prototype,"strokeAlign",void 0),nt([R(1)],Jt.prototype,"strokeWidth",void 0),nt([R("none")],Jt.prototype,"strokeCap",void 0),nt([R("miter")],Jt.prototype,"strokeJoin",void 0),nt([R()],Jt.prototype,"dashPattern",void 0),nt([R()],Jt.prototype,"dashOffset",void 0),nt([R(10)],Jt.prototype,"miterLimit",void 0),nt([R("none")],Jt.prototype,"startArrow",void 0),nt([R("none")],Jt.prototype,"endArrow",void 0),nt([B(0)],Jt.prototype,"cornerRadius",void 0),nt([B()],Jt.prototype,"cornerSmoothing",void 0),nt([Vt()],Jt.prototype,"shadow",void 0),nt([Vt()],Jt.prototype,"innerShadow",void 0),nt([Vt()],Jt.prototype,"blur",void 0),nt([Vt()],Jt.prototype,"backgroundBlur",void 0),nt([Vt()],Jt.prototype,"grayscale",void 0),nt([S(b.prototype.reset)],Jt.prototype,"reset",null),nt([S(C.drawPathByData)],Jt.prototype,"__drawPathByData",null),Jt=Gt=nt([A(Yt),A(Ut),A(Xt),P()],Jt);const $t=D.get();let qt=class extends Jt{get __tag(){return"Group"}set mask(t){this.__hasMask&&this.__removeMask(),t&&(t.isMask=!0,this.addAt(t,0))}get mask(){return this.children.find((t=>t.isMask))}constructor(t){super(t),this.__setBranch()}__setBranch(){this.isBranch=!0,this.children||(this.children=[])}set(t){if(t.children){const{children:e}=t;let s;delete t.children,this.children?this.removeAll(!0):this.__setBranch(),super.set(t),e.forEach((t=>{s=L.get(t.tag,t),this.add(s)})),t.children=e}else super.set(t)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}__scaleResize(t,e){const{children:s}=this;for(let i=0;i<s.length;i++)$t.a=t,$t.d=e,s[i].transform($t,!0)}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){}};nt([n(Bt)],qt.prototype,"__",void 0),qt=nt([A(T),z()],qt);let Kt=class extends Jt{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){}};nt([n(Et)],Kt.prototype,"__",void 0),nt([S(Jt.prototype.__drawPathByBox)],Kt.prototype,"__drawPathByData",null),Kt=nt([A(jt),P(),z()],Kt);const Zt=Kt.prototype,Qt=qt.prototype,te={},{copy:ee,add:se}=W;let ie=class extends qt{get __tag(){return"Box"}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderChanged||this.__layout.renderChange()}__scaleResize(t,e){this.__.__autoBounds&&this.children.length?super.__scaleResize(t,e):(this.width*=t,this.height*=e)}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateRectBoxBounds(){}__updateBoxBounds(){this.__.__autoBounds&&this.children.length?super.__updateBoxBounds():this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;ee(te,t),super.__updateRenderBounds(),se(t,te)}}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__drawPathByData(t,e){}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}};nt([n(St)],ie.prototype,"__",void 0),nt([M("show")],ie.prototype,"overflow",void 0),nt([S(Zt.__updateStrokeSpread)],ie.prototype,"__updateStrokeSpread",null),nt([S(Zt.__updateRenderSpread)],ie.prototype,"__updateRectRenderSpread",null),nt([S(Zt.__updateBoxBounds)],ie.prototype,"__updateRectBoxBounds",null),nt([S(Zt.__updateStrokeBounds)],ie.prototype,"__updateStrokeBounds",null),nt([S(Zt.__updateRenderBounds)],ie.prototype,"__updateRectRenderBounds",null),nt([S(Zt.__updateChange)],ie.prototype,"__updateRectChange",null),nt([S(Zt.__drawPathByData)],ie.prototype,"__drawPathByData",null),nt([S(Zt.__render)],ie.prototype,"__renderRect",null),nt([S(Qt.__render)],ie.prototype,"__renderGroup",null),ie=nt([P(),z()],ie);let oe=class extends ie{get __tag(){return"Frame"}constructor(t){super(t),this.isFrame=!0,this.__.fill||(this.__.fill="#FFFFFF")}};nt([n(Ct)],oe.prototype,"__",void 0),nt([M("hide")],oe.prototype,"overflow",void 0),oe=nt([z()],oe);const{moveTo:re,closePath:ae,ellipse:he}=I;let _e=class extends Jt{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:s,startAngle:i,endAngle:o}=this.__,r=t/2,a=e/2,h=this.__.path=[];s?(i||o?(s<1&&he(h,r,a,r*s,a*s,0,i,o,!1),he(h,r,a,r,a,0,o,i,!0),s<1&&ae(h)):(s<1&&(he(h,r,a,r*s,a*s),re(h,t,a)),he(h,r,a,r,a,0,360,0,!0)),_.ellipseToCurve&&(this.__.path=this.getPath(!0))):i||o?(re(h,r,a),he(h,r,a,r,a,0,i,o,!1),ae(h)):he(h,r,a,r,a)}};nt([n(Ft)],_e.prototype,"__",void 0),nt([B(0)],_e.prototype,"innerRadius",void 0),nt([B(0)],_e.prototype,"startAngle",void 0),nt([B(0)],_e.prototype,"endAngle",void 0),_e=nt([z()],_e);const{moveTo:ne,lineTo:de,drawPoints:le}=I,{rotate:pe,getAngle:ce,getDistance:ue,defaultPoint:ye}=V,{toBounds:ve}=N;let ge=class extends Jt{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,s={x:0,y:0};return t&&(s.x=t),e&&pe(s,e),s}set toPoint(t){this.width=ue(ye,t),this.rotation=ce(ye,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?le(t,this.__.points,!1):(ne(t,0,0),de(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?le(this.__.__pathForRender=[],this.__.points,this.__.curve,"Line"!==this.__tag):super.__updateRenderPath()}__updateBoxBounds(){this.points?ve(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}__scaleResize(t,e){if(this.points)H.scalePoints(this.__.points,t,e),this.points=this.__.points;else if("Line"===this.__tag){const s=this.toPoint;s.x*=t,s.y*=e,this.toPoint=s}else super.__scaleResize(t,e)}};nt([n(At)],ge.prototype,"__",void 0),nt([O("center")],ge.prototype,"strokeAlign",void 0),nt([g(0)],ge.prototype,"height",void 0),nt([B()],ge.prototype,"points",void 0),nt([B(0)],ge.prototype,"curve",void 0),ge=nt([z()],ge);const{sin:fe,cos:we,PI:me}=Math,{moveTo:xe,lineTo:Re,closePath:ke,drawPoints:Be}=I,Se=ge.prototype;let be=class extends Jt{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Be(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:i}=this.__,o=e/2,r=s/2;xe(t,o,0);for(let e=1;e<i;e++)Re(t,o+o*fe(2*e*me/i),r-r*we(2*e*me/i))}ke(t)}__updateRenderPath(){}__updateBoxBounds(){}__scaleResize(t,e){}};nt([n(Lt)],be.prototype,"__",void 0),nt([B(3)],be.prototype,"sides",void 0),nt([B()],be.prototype,"points",void 0),nt([B(0)],be.prototype,"curve",void 0),nt([S(Se.__updateRenderPath)],be.prototype,"__updateRenderPath",null),nt([S(Se.__updateBoxBounds)],be.prototype,"__updateBoxBounds",null),nt([S(Se.__scaleResize)],be.prototype,"__scaleResize",null),be=nt([P(),z()],be);const{sin:Ce,cos:Ae,PI:Pe}=Math,{moveTo:Ee,lineTo:Fe,closePath:Le}=I;let De=class extends Jt{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:i}=this.__,o=t/2,r=e/2,a=this.__.path=[];Ee(a,o,0);for(let t=1;t<2*s;t++)Fe(a,o+(t%2==0?o:o*i)*Ce(t*Pe/s),r-(t%2==0?r:r*i)*Ae(t*Pe/s));Le(a)}};nt([n(Dt)],De.prototype,"__",void 0),nt([B(5)],De.prototype,"corners",void 0),nt([B(.382)],De.prototype,"innerRadius",void 0),De=nt([z()],De);let Te=class extends Kt{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(Y.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};nt([n(Ot)],Te.prototype,"__",void 0),nt([g("")],Te.prototype,"url",void 0),Te=nt([z()],Te);let ze=class extends Kt{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=U.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(t,e,s,i){t.__layout.update();const o=new X(t.__world);o.invert();const r=new X;e&&r.translate(e.x,e.y),s&&("number"==typeof s?r.scale(s):r.scale(s.x,s.y)),i&&r.rotate(i),o.multiplyParent(r),t.__render(this.canvas,{matrix:o}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:i,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,i,o),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,i,o)}__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=null,this.context=null),super.destroy()}};nt([n(Ot)],ze.prototype,"__",void 0),nt([Nt(100)],ze.prototype,"width",void 0),nt([Nt(100)],ze.prototype,"height",void 0),nt([Nt(_.devicePixelRatio)],ze.prototype,"pixelRatio",void 0),nt([Nt(!0)],ze.prototype,"smooth",void 0),nt([x("all")],ze.prototype,"hitFill",void 0),ze=nt([z()],ze);const{copyAndSpread:Me,includes:We,spread:Ie,setList:Oe}=W;let He=class extends Jt{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:s,__textDrawData:i}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):i.rows.forEach((i=>t.rect(i.x,i.y-s,i.width,e)))}__drawPathByData(t,e){const{x:s,y:i,width:o,height:r}=this.__layout.boxBounds;t.rect(s,i,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=gt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:s,letterSpacing:i,fontFamily:o,fontSize:r,fontWeight:a,italic:h,textCase:_,textOverflow:n,padding:d}=t,l=t.__autoWidth,p=t.__autoHeight;t.__lineHeight=kt.number(s,r),t.__letterSpacing=kt.number(i,r),t.__padding=d?j.fourNumber(d):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*r)/2,t.__font=`${h?"italic ":""}${"small-caps"===_?"small-caps ":""}${"normal"!==a?a+" ":""}${r}px ${o}`,t.__clipText="show"!==n&&!t.__autoBounds,this.__updateTextDrawData();const{bounds:c}=t.__textDrawData,u=e.boxBounds;if(t.__lineHeight<r&&Ie(c,r/2),l||p){if(u.x=l?c.x:0,u.y=p?c.y:0,u.width=l?c.width:t.width,u.height=p?c.height:t.height,d){const[e,s,i,o]=t.__padding;l&&(u.x-=o,u.width+=s+o),p&&(u.y-=e,u.height+=i+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();const y=We(u,c)?u:c;y!==e.contentBounds?(e.contentBounds=y,e.renderChanged=!0,Oe(t.__textBoxBounds={},[u,c])):t.__textBoxBounds=y}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){Me(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};nt([n(It)],He.prototype,"__",void 0),nt([g(0)],He.prototype,"width",void 0),nt([g(0)],He.prototype,"height",void 0),nt([g(0)],He.prototype,"padding",void 0),nt([l("#000000")],He.prototype,"fill",void 0),nt([O("outside")],He.prototype,"strokeAlign",void 0),nt([x("all")],He.prototype,"hitFill",void 0),nt([g("")],He.prototype,"text",void 0),nt([g("L")],He.prototype,"fontFamily",void 0),nt([g(12)],He.prototype,"fontSize",void 0),nt([g("normal")],He.prototype,"fontWeight",void 0),nt([g(!1)],He.prototype,"italic",void 0),nt([g("none")],He.prototype,"textCase",void 0),nt([g("none")],He.prototype,"textDecoration",void 0),nt([g(0)],He.prototype,"letterSpacing",void 0),nt([g({type:"percent",value:150})],He.prototype,"lineHeight",void 0),nt([g(0)],He.prototype,"paraIndent",void 0),nt([g(0)],He.prototype,"paraSpacing",void 0),nt([g("left")],He.prototype,"textAlign",void 0),nt([g("top")],He.prototype,"verticalAlign",void 0),nt([g("normal")],He.prototype,"textWrap",void 0),nt([g("show")],He.prototype,"textOverflow",void 0),He=nt([z()],He);const{toBounds:Ve}=N;let Ne=class extends Jt{get __tag(){return"Path"}constructor(t){super(t)}__scaleResize(t,e){H.scale(this.__.path,t,e),this.path=this.__.path}__updateBoxBounds(){Ve(this.__.path,this.__layout.boxBounds)}};nt([n(zt)],Ne.prototype,"__",void 0),nt([B()],Ne.prototype,"path",void 0),nt([B()],Ne.prototype,"windingRule",void 0),nt([O("center")],Ne.prototype,"strokeAlign",void 0),Ne=nt([z()],Ne);let Ye=class extends qt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Ne(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,s,i,o,r){return this}quadraticCurveTo(t,e,s,i){return this}closePath(){return this}rect(t,e,s,i){return this}roundRect(t,e,s,i,o){return this}ellipse(t,e,s,i,o,r,a,h){return this}arc(t,e,s,i,o,r){return this}arcTo(t,e,s,i,o){return this}drawEllipse(t,e,s,i,o,r,a,h){return this}drawArc(t,e,s,i,o,r){return this}drawPoints(t,e,s){return this}paint(){this.pathElement.forceUpdate("path")}clear(){this.removeAll(!0)}};nt([n(Mt)],Ye.prototype,"__",void 0),Ye=nt([A(E,["beginPath"]),z()],Ye);const Ue=i.get("Leafer");let Xe=class extends qt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get imageReady(){return this.viewReady&&G.isComplete}get layoutLocked(){return!this.layouter.running}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.zoomLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,dragOut:!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)}init(t,e){if(this.canvas)return;let s;this.__setLeafer(this),t&&J.assign(this.config,t);const{config:i}=this;pt.run(i.type,this),this.canvas=U.canvas(i),this.__controllers.push(this.renderer=U.renderer(this,this.canvas,i),this.watcher=U.watcher(this,i),this.layouter=U.layouter(this,i)),this.isApp&&this.__setApp(),this.__checkAutoLayout(i),this.view=this.canvas.view,e?(this.__bindApp(e),s=e.running):(this.selector=U.selector(this),this.__controllers.unshift(this.interaction=U.interaction(this,this.canvas,this.selector,i)),this.canvasManager=new $,this.hitCanvasManager=new q,s=i.start),this.hittable=i.hittable,this.fill=i.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),s&&(this.__startTimer=setTimeout(this.start.bind(this))),K.onLeafer(this)}set(t){this.children?super.set(t):setTimeout((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(Z.RESTART):this.emitLeafer(Z.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(Z.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=J.copyAttrs({},t,Q);Object.keys(e).forEach((t=>this[t]=e[t]))}forceFullRender(){this.renderer.addBlock(this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(){this.interaction&&this.interaction.updateCursor()}__doResize(t){if(!this.canvas||this.canvas.isSameSize(t))return;const e=J.copyAttrs({},this.canvas,Q);this.canvas.resize(t),this.__onResize(new tt(t,e))}__onResize(t){this.emitEvent(t),J.copyAttrs(this.__,t,Q),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.isLeafer=!!t,this.__level=1}setZoomLayer(t){this.zoomLayer=t}__checkAutoLayout(t){t.width&&t.height||(this.autoLayout=new et(t),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){this.canvas&&(Q.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t&&(this.canvas.hittable=e)),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&Q.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const s=J.copyAttrs({},this.canvas,Q);s[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(s)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(Z.BEFORE_READY),this.emitLeafer(Z.READY),this.emitLeafer(Z.AFTER_READY),st.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(Z.VIEW_READY),st.run(this.__viewReadyWait))}__onAnimateFrame(){if(this.viewReady){this.__nextRenderWait.length&&st.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(Z.VIEW_COMPLETED),st.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitReady(t){this.ready?t():this.__readyWait.push(t)}waitViewReady(t){this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t){this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t){this.__nextRenderWait.push(t)}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new Z(t,this))}__listenEvents(){const t=it.start("FirstCreate "+this.innerName);this.once(Z.START,(()=>it.end(t))),this.once(ot.END,(()=>this.__onReady())),this.once(rt.START,(()=>this.__onCreated())),this.once(rt.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(at.DATA,this.__onWatchData,this),this.on_(ht.FRAME,this.__onAnimateFrame,this),this.on_(ot.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){setTimeout((()=>{if(!this.destroyed)try{this.stop(),this.emitEvent(new Z(Z.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector.destroy(),this.canvasManager.destroy(),this.hitCanvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{G.clearRecycled()}),100)}catch(t){Ue.error(t)}}))}};nt([n(bt)],Xe.prototype,"__",void 0),nt([g()],Xe.prototype,"pixelRatio",void 0),Xe=nt([z()],Xe);let je=class extends Xe{get __tag(){return"App"}get isApp(){return!0}constructor(t,e){if(super(t,e),t){const{ground:e,tree:s,sky:i,editor:o}=t;e&&(this.ground=this.addLeafer(e)),(s||o)&&(this.tree=this.addLeafer(s)),(i||o)&&(this.sky=this.addLeafer(i||{type:"draw",usePartRender:!1})),o&&(this.editor=U.editor(o),this.sky.add(this.editor))}}__setApp(){const{canvas:t}=this,{realCanvas:e,view:s}=this.config;e||s===this.canvas.view||!t.parentView?this.realCanvas=!0:t.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable(),this.__eventIds.push(this.on_(_t.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>t.start()))}stop(){this.children.forEach((t=>t.stop())),super.stop()}unlockLayout(){super.unlockLayout(),this.children.forEach((t=>t.unlockLayout()))}lockLayout(){super.lockLayout(),this.children.forEach((t=>t.lockLayout()))}addLeafer(t){const e=new Xe(t);return this.add(e),e}add(t){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout((()=>this.add(t)),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t),this.__listenChildEvents(t)}__onPropertyChange(){i.showHitView&&this.children.forEach((t=>t.forceUpdate("surface")))}__onCreated(){this.created=this.children.every((t=>t.created))}__onReady(){this.children.every((t=>t.ready))&&super.__onReady()}__onViewReady(){this.children.every((t=>t.viewReady))&&super.__onViewReady()}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){this.children.forEach((e=>t.copyWorld(e.canvas)))}__onResize(t){this.children.forEach((e=>e.resize(t))),super.__onResize(t)}__checkUpdateLayout(){this.children.forEach((t=>t.__layout.update()))}__getChildConfig(t){let e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&J.assign(e,t),this.autoLayout&&J.copyAttrs(e,this,Q),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once(ot.END,(()=>this.__onReady())),t.once(rt.START,(()=>this.__onCreated())),t.once(rt.END,(()=>this.__onViewReady())),this.realCanvas&&this.__eventIds.push(t.on_(rt.END,this.__onChildRenderEnd,this))}};je=nt([z()],je);export{vt as Animate,je as App,Pt as ArrowData,ie as Box,St as BoxData,ze as Canvas,Ht as CanvasData,ft as ColorConvert,ut as Effect,_e as Ellipse,Ft as EllipseData,wt as Export,oe as Frame,Ct as FrameData,qt as Group,Bt as GroupData,Te as Image,Ot as ImageData,Xe as Leafer,bt as LeaferData,pt as LeaferTypeCreator,ge as Line,At as LineData,yt as Paint,Ne as Path,zt as PathData,Ye as Pen,Mt as PenData,be as Polygon,Lt as PolygonData,Kt as Rect,Et as RectData,jt as RectRender,De as Star,Dt as StarData,He as Text,gt as TextConvert,It as TextData,Jt as UI,Yt as UIBounds,Rt as UIData,Ut as UIHit,Xt as UIRender,kt as UnitConvert,Vt as effectType,Nt as resizeType};
|
package/dist/core.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core");function e(t,e,s,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,r);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(i<3?o(a):i>3?o(e,s,a):o(e,s))||a);return i>3&&a&&Object.defineProperty(e,s,a),a}function s(t){const{config:e}=t;e.move.dragOut=!1}"function"==typeof SuppressedError&&SuppressedError;const r=t.Debug.get("LeaferTypeCreator"),o={list:{},register(t,e){i[t]?r.repeat(t):i[t]=e},run(t,e){const s=o.list[t];s?s(e):r.error("no",t)}},{list:i}=o;o.register("draw",s),o.register("user",s),o.register("design",(function(e){e.isApp||e.__eventIds.push(e.on_(t.MoveEvent.BEFORE_MOVE,(s=>{t.LeafHelper.moveWorld(e.zoomLayer,s.moveX,s.moveY)})),e.on_(t.ZoomEvent.BEFORE_ZOOM,(s=>{const{scaleX:r}=e.zoomLayer.__,{min:o,max:i}=e.app.config.zoom;let{scale:a}=s;a*Math.abs(r)<o?a=o/r:a*Math.abs(r)>i&&(a=i/r),1!==a&&t.LeafHelper.zoomOfWorld(e.zoomLayer,s,a)})))}));const a={},n={},h={},p={},_={},d=t.Debug.get("UIData");class l extends t.LeafData{get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoBounds(){return!this._width&&!this._height}setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,d.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,d.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&(this.__naturalWidth=this.__naturalHeight=void 0),"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=_)):(this.__isFills&&(this.__removeInput("fill"),n.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=_)):(this.__isStrokes&&(this.__removeInput("stroke"),n.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=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}}const u={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class c extends l{}class y extends c{get __boxStroke(){return!0}}class x extends c{}class v extends y{}class g extends l{}class f extends l{get __boxStroke(){return!0}}class w extends l{get __boxStroke(){return!0}}class m extends l{}class R extends l{}const{parse:T}=t.PathConvert;class P extends l{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=T(t)):(this.__input&&this.__removeInput("path"),this._path=t)}}class B extends c{}const k={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class C extends l{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=k[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class b extends f{}function I(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function S(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}const E={__updateStrokeSpread(){let e=0,s=0;const{stroke:r,hitStroke:o,strokeAlign:i,strokeWidth:a}=this.__;if((r||"all"===o)&&a&&"inside"!==i&&(s=e="center"===i?a/2:a,!this.__.__boxStroke)){const{miterLimit:s,strokeCap:r}=this.__,o="Line"!==this.__tag?1/Math.sin(s*t.OneRadian/2)*Math.sqrt(a)-e:0,i="none"===r?0:a;e+=Math.max(o,i)}return this.__layout.strokeBoxSpread=s,e},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:r,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)})),r&&(t=Math.max(t,r));let i=t=Math.ceil(t);return s&&s.forEach((t=>{i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(i=Math.max(i,o)),this.__layout.renderShapeSpread=i,t}},L={__updateHitCanvas(){this.__hitCanvas||(this.__hitCanvas=this.leafer.hitCanvasManager.getPathType(this));const t=this.__hitCanvas;this.__drawHitPath(t),t.setStrokeOptions(this.__)},__hit(e){const{__hitCanvas:s}=this;"miniapp"===t.Platform.name&&this.__drawHitPath(s);const{fill:r,hitFill:o,windingRule:i}=this.__,a=r&&"path"===o||"all"===o,n=s.hitFill(e,i);if(a&&n)return!0;const{stroke:h,hitStroke:p,strokeWidth:_,strokeAlign:d}=this.__,l=h&&"path"===p||"all"===p,u=2*e.radiusX;let c=u;if(l)switch(d){case"inside":if(c+=2*_,!a&&n&&s.hitStroke(e,c))return!0;c=u;break;case"center":c+=_;break;case"outside":if(c+=2*_,!a){if(!n&&s.hitStroke(e,c))return!0;c=u}}return!!c&&s.hitStroke(e,c)}},A={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;t.__useEffect=!!(e||s||r||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){const{fill:s,stroke:r,__drawAfterFill:o}=this.__;this.__drawRenderPath(t),s&&n.fill(s,this,t),o&&this.__drawAfterFill(t,e),r&&n.stroke(r,this,t,e)},__draw(t,e){if(this.__.__complex){const{fill:s,stroke:r,__drawAfterFill:o}=this.__;if(this.__drawRenderPath(t),this.__.__useEffect){const i=n.shape(this,t,e),{shadow:h,innerShadow:p}=this.__;h&&a.shadow(this,t,i,e),s&&(this.__.__isFills?n.fills(s,this,t):n.fill(s,this,t)),o&&this.__drawAfterFill(t,e),p&&a.innerShadow(this,t,i,e),r&&(this.__.__isStrokes?n.strokes(r,this,t,e):n.stroke(r,this,t,e)),i.worldCanvas&&i.worldCanvas.recycle(),i.canvas.recycle()}else s&&(this.__.__isFills?n.fills(s,this,t):n.fill(s,this,t)),o&&this.__drawAfterFill(t,e),r&&(this.__.__isStrokes?n.strokes(r,this,t,e):n.stroke(r,this,t,e))}else this.__drawFast(t,e)},__renderShape(t,e){if(!this.__worldOpacity)return;t.setWorld(this.__world,e.matrix);const{fill:s,stroke:r}=this.__;this.__drawRenderPath(t),s&&(this.__.__pixelFill?n.fills(s,this,t):n.fill("#000000",this,t)),r&&(this.__.__pixelStroke?n.strokes(r,this,t,e):n.stroke("#000000",this,t,e))}},U={__drawFast(t,e){const{width:s,height:r,fill:o,stroke:i,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,s,r)),a&&this.__drawAfterFill(t,e),i){const{strokeAlign:e,strokeWidth:o}=this.__;t.setStroke(i,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,s,r);break;case"inside":t.strokeRect(a,a,s-o,r-o);break;case"outside":t.strokeRect(-a,-a,s+o,r+o)}}}};var D;exports.UI=D=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}createProxyData(){}find(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!1,e):[]}findOne(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!0,e):null}getPath(e){const{path:s}=this.__;return s?e?t.PathConvert.toCanvasData(s,!0):s:[]}getPathString(e){return t.PathConvert.stringify(this.getPath(e))}__onUpdateSize(){if(this.__.__input){const{fill:t,stroke:e}=this.__.__input;t&&n.compute("fill",this),e&&n.compute("stroke",this)}}__updateRenderPath(){if(this.__.path){const{__:e}=this;e.__pathForRender=e.cornerRadius?t.PathCorner.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){}__drawPathByBox(t){const{x:e,y:s,width:r,height:o}=this.__layout.boxBounds;this.__.cornerRadius?t.roundRect(e,s,r,o,this.__.cornerRadius):t.rect(e,s,r,o)}export(t,e){return p.export(this,t,e)}clone(){return D.one(this.toJSON())}static one(e,s,r,o,i){return t.UICreator.get(e.tag||this.prototype.__tag,e,s,r,o,i)}destroy(){this.fill=this.stroke=null,super.destroy()}},e([t.dataProcessor(l)],exports.UI.prototype,"__",void 0),e([t.dataType("")],exports.UI.prototype,"id",void 0),e([t.dataType("")],exports.UI.prototype,"name",void 0),e([t.dataType("")],exports.UI.prototype,"className",void 0),e([t.surfaceType("pass-through")],exports.UI.prototype,"blendMode",void 0),e([t.opacityType(1)],exports.UI.prototype,"opacity",void 0),e([t.opacityType(!0)],exports.UI.prototype,"visible",void 0),e([t.maskType(!1)],exports.UI.prototype,"isMask",void 0),e([t.eraserType(!1)],exports.UI.prototype,"isEraser",void 0),e([t.dataType(!1)],exports.UI.prototype,"locked",void 0),e([t.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.positionType(0)],exports.UI.prototype,"x",void 0),e([t.positionType(0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100)],exports.UI.prototype,"width",void 0),e([t.boundsType(100)],exports.UI.prototype,"height",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewY",void 0),e([t.autoLayoutType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",void 0),e([t.dataType(!1)],exports.UI.prototype,"editable",void 0),e([t.dataType("size")],exports.UI.prototype,"editSize",void 0),e([t.hitType(!0)],exports.UI.prototype,"hittable",void 0),e([t.hitType("path")],exports.UI.prototype,"hitFill",void 0),e([t.strokeType("path")],exports.UI.prototype,"hitStroke",void 0),e([t.hitType(!1)],exports.UI.prototype,"hitBox",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitChildren",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitSelf",void 0),e([t.hitType()],exports.UI.prototype,"hitRadius",void 0),e([t.cursorType("")],exports.UI.prototype,"cursor",void 0),e([t.surfaceType()],exports.UI.prototype,"fill",void 0),e([t.strokeType()],exports.UI.prototype,"stroke",void 0),e([t.strokeType("inside")],exports.UI.prototype,"strokeAlign",void 0),e([t.strokeType(1)],exports.UI.prototype,"strokeWidth",void 0),e([t.strokeType("none")],exports.UI.prototype,"strokeCap",void 0),e([t.strokeType("miter")],exports.UI.prototype,"strokeJoin",void 0),e([t.strokeType()],exports.UI.prototype,"dashPattern",void 0),e([t.strokeType()],exports.UI.prototype,"dashOffset",void 0),e([t.strokeType(10)],exports.UI.prototype,"miterLimit",void 0),e([t.pathType(0)],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([I()],exports.UI.prototype,"shadow",void 0),e([I()],exports.UI.prototype,"innerShadow",void 0),e([I()],exports.UI.prototype,"blur",void 0),e([I()],exports.UI.prototype,"backgroundBlur",void 0),e([I()],exports.UI.prototype,"grayscale",void 0),e([t.rewrite(t.Leaf.prototype.reset)],exports.UI.prototype,"reset",null),e([t.rewrite(t.PathDrawer.drawPathByData)],exports.UI.prototype,"__drawPathByData",null),exports.UI=D=e([t.useModule(E),t.useModule(L),t.useModule(A),t.rewriteAble()],exports.UI);const F=t.MatrixHelper.get();exports.Group=class extends exports.UI{get __tag(){return"Group"}set mask(t){this.__hasMask&&this.__removeMask(),t&&(t.isMask=!0,this.addAt(t,0))}get mask(){return this.children.find((t=>t.isMask))}constructor(t){super(t),this.__setBranch()}__setBranch(){this.isBranch=!0,this.children||(this.children=[])}set(e){if(e.children){const{children:s}=e;let r;delete e.children,this.children?this.removeAll(!0):this.__setBranch(),super.set(e),s.forEach((e=>{r=t.UICreator.get(e.tag,e),this.add(r)})),e.children=s}else super.set(e)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}__scaleResize(t,e){const{children:s}=this;for(let r=0;r<s.length;r++)F.a=t,F.d=e,s[r].transform(F,!0)}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){}},e([t.dataProcessor(c)],exports.Group.prototype,"__",void 0),exports.Group=e([t.useModule(t.Branch),t.registerUI()],exports.Group),exports.Rect=class extends exports.UI{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){}},e([t.dataProcessor(f)],exports.Rect.prototype,"__",void 0),e([t.rewrite(exports.UI.prototype.__drawPathByBox)],exports.Rect.prototype,"__drawPathByData",null),exports.Rect=e([t.useModule(U),t.rewriteAble(),t.registerUI()],exports.Rect);const M=exports.Rect.prototype,z=exports.Group.prototype,H={},{copy:W,add:O}=t.BoundsHelper;exports.Box=class extends exports.Group{get __tag(){return"Box"}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderChanged||this.__layout.renderChange()}__scaleResize(t,e){this.__.__autoBounds&&this.children.length?super.__scaleResize(t,e):(this.width*=t,this.height*=e)}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateRectBoxBounds(){}__updateBoxBounds(){this.__.__autoBounds&&this.children.length?super.__updateBoxBounds():this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;W(H,t),super.__updateRenderBounds(),O(t,H)}}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__drawPathByData(t,e){}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}},e([t.dataProcessor(y)],exports.Box.prototype,"__",void 0),e([t.affectRenderBoundsType("show")],exports.Box.prototype,"overflow",void 0),e([t.rewrite(M.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(M.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(M.__updateBoxBounds)],exports.Box.prototype,"__updateRectBoxBounds",null),e([t.rewrite(M.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(M.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(M.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(M.__drawPathByData)],exports.Box.prototype,"__drawPathByData",null),e([t.rewrite(M.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(z.__render)],exports.Box.prototype,"__renderGroup",null),exports.Box=e([t.rewriteAble(),t.registerUI()],exports.Box),exports.Frame=class extends exports.Box{get __tag(){return"Frame"}constructor(t){super(t),this.isFrame=!0,this.__.fill||(this.__.fill="#FFFFFF")}},e([t.dataProcessor(v)],exports.Frame.prototype,"__",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo:V,closePath:G,ellipse:N}=t.PathCommandDataHelper;exports.Ellipse=class extends exports.UI{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:s,innerRadius:r,startAngle:o,endAngle:i}=this.__,a=e/2,n=s/2,h=this.__.path=[];r?(o||i?(r<1&&N(h,a,n,a*r,n*r,0,o,i,!1),N(h,a,n,a,n,0,i,o,!0),r<1&&G(h)):(r<1&&(N(h,a,n,a*r,n*r),V(h,e,n)),N(h,a,n,a,n,0,360,0,!0)),t.Platform.ellipseToCurve&&(this.__.path=this.getPath(!0))):o||i?(V(h,a,n),N(h,a,n,a,n,0,o,i,!1),G(h)):N(h,a,n,a,n)}},e([t.dataProcessor(w)],exports.Ellipse.prototype,"__",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"innerRadius",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"startAngle",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"endAngle",void 0),exports.Ellipse=e([t.registerUI()],exports.Ellipse);const{moveTo:j,lineTo:Y,drawPoints:X}=t.PathCommandDataHelper,{rotate:J,getAngle:$,getDistance:q,defaultPoint:Z}=t.PointHelper,{toBounds:K}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,s={x:0,y:0};return t&&(s.x=t),e&&J(s,e),s}set toPoint(t){this.width=q(Z,t),this.rotation=$(Z,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?X(t,this.__.points,!1):(j(t,0,0),Y(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?X(this.__.__pathForRender=[],this.__.points,this.__.curve,"Line"!==this.__tag):super.__updateRenderPath()}__updateBoxBounds(){this.points?K(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}__scaleResize(e,s){if(this.points)t.PathScaler.scalePoints(this.__.points,e,s),this.points=this.__.points;else if("Line"===this.__tag){const t=this.toPoint;t.x*=e,t.y*=s,this.toPoint=t}else super.__scaleResize(e,s)}},e([t.dataProcessor(g)],exports.Line.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Line.prototype,"strokeAlign",void 0),e([t.boundsType(0)],exports.Line.prototype,"height",void 0),e([t.pathType()],exports.Line.prototype,"points",void 0),e([t.pathType(0)],exports.Line.prototype,"curve",void 0),exports.Line=e([t.registerUI()],exports.Line);const{sin:Q,cos:tt,PI:et}=Math,{moveTo:st,lineTo:rt,closePath:ot,drawPoints:it}=t.PathCommandDataHelper,at=exports.Line.prototype;exports.Polygon=class extends exports.UI{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)it(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:r}=this.__,o=e/2,i=s/2;st(t,o,0);for(let e=1;e<r;e++)rt(t,o+o*Q(2*e*et/r),i-i*tt(2*e*et/r))}ot(t)}__updateRenderPath(){}__updateBoxBounds(){}__scaleResize(t,e){}},e([t.dataProcessor(m)],exports.Polygon.prototype,"__",void 0),e([t.pathType(3)],exports.Polygon.prototype,"sides",void 0),e([t.pathType()],exports.Polygon.prototype,"points",void 0),e([t.pathType(0)],exports.Polygon.prototype,"curve",void 0),e([t.rewrite(at.__updateRenderPath)],exports.Polygon.prototype,"__updateRenderPath",null),e([t.rewrite(at.__updateBoxBounds)],exports.Polygon.prototype,"__updateBoxBounds",null),e([t.rewrite(at.__scaleResize)],exports.Polygon.prototype,"__scaleResize",null),exports.Polygon=e([t.rewriteAble(),t.registerUI()],exports.Polygon);const{sin:nt,cos:ht,PI:pt}=Math,{moveTo:_t,lineTo:dt,closePath:lt}=t.PathCommandDataHelper;exports.Star=class extends exports.UI{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:r}=this.__,o=t/2,i=e/2,a=this.__.path=[];_t(a,o,0);for(let t=1;t<2*s;t++)dt(a,o+(t%2==0?o:o*r)*nt(t*pt/s),i-(t%2==0?i:i*r)*ht(t*pt/s));lt(a)}},e([t.dataProcessor(R)],exports.Star.prototype,"__",void 0),e([t.pathType(5)],exports.Star.prototype,"corners",void 0),e([t.pathType(.382)],exports.Star.prototype,"innerRadius",void 0),exports.Star=e([t.registerUI()],exports.Star),exports.Image=class extends exports.Rect{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t)}__updateBoxBounds(){let e;const{url:s}=this,r=this.fill;r?r.url!==s&&(e=!0):s&&(e=!0),e&&(this.image&&(this.image=null),this.fill=s?{type:"image",mode:"strench",url:s}:void 0,this.once(t.ImageEvent.LOADED,(t=>this.image=t.image))),super.__updateBoxBounds()}destroy(){this.image=null,super.destroy()}},e([t.dataProcessor(b)],exports.Image.prototype,"__",void 0),e([t.boundsType("")],exports.Image.prototype,"url",void 0),exports.Image=e([t.registerUI()],exports.Image),exports.Canvas=class extends exports.Rect{get __tag(){return"Canvas"}constructor(e){super(e),this.canvas=t.Creator.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(e,s,r,o){e.__layout.update();const i=new t.Matrix(e.__world);i.invert();const a=new t.Matrix;s&&a.translate(s.x,s.y),r&&("number"==typeof r?a.scale(r):a.scale(r.x,r.y)),o&&a.rotate(o),i.multiplyParent(a),e.__render(this.canvas,{matrix:i}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:r,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o)}__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=null,this.context=null),super.destroy()}},e([t.dataProcessor(b)],exports.Canvas.prototype,"__",void 0),e([S(100)],exports.Canvas.prototype,"width",void 0),e([S(100)],exports.Canvas.prototype,"height",void 0),e([S(t.Platform.devicePixelRatio)],exports.Canvas.prototype,"pixelRatio",void 0),e([S(!0)],exports.Canvas.prototype,"smooth",void 0),e([t.hitType("all")],exports.Canvas.prototype,"hitFill",void 0),exports.Canvas=e([t.registerUI()],exports.Canvas);const{copyAndSpread:ut,includes:ct,spread:yt,setList:xt}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:s,__textDrawData:r}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):r.rows.forEach((r=>t.rect(r.x,r.y-s,r.width,e)))}__drawPathByData(t,e){const{x:s,y:r,width:o,height:i}=this.__layout.boxBounds;t.rect(s,r,o,i)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=h.getDrawData(t.text,this.__)}__updateBoxBounds(){const e=this.__,s=this.__layout,{lineHeight:r,letterSpacing:o,fontFamily:i,fontSize:a,fontWeight:n,italic:h,textCase:p,textOverflow:_}=e,d=e.__autoWidth,l=e.__autoHeight;e.__lineHeight=u.number(r,a),e.__letterSpacing=u.number(o,a),e.__baseLine=e.__lineHeight-(e.__lineHeight-.7*a)/2,e.__font=`${h?"italic ":""}${"small-caps"===p?"small-caps ":""}${"normal"!==n?n+" ":""}${a}px ${i}`,e.__clipText="show"!==_&&!e.__autoBounds,this.__updateTextDrawData();const{bounds:c}=e.__textDrawData,y=s.boxBounds;if(e.__lineHeight<a&&yt(c,a/2),d||l){y.x=d?c.x:0,y.y=l?c.y:0,y.width=d?c.width:e.width,y.height=l?c.height:e.height;const{padding:s}=e;if(s){const[e,r,o,i]=t.MathHelper.fourNumber(s);d&&(y.x-=i,y.width+=r+i),l&&(y.y-=e,y.height+=o+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();const x=ct(y,c)?y:c;x!==s.contentBounds?(s.contentBounds=x,s.renderChanged=!0,xt(e.__textBoxBounds={},[y,c])):e.__textBoxBounds=x}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){ut(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}},e([t.dataProcessor(C)],exports.Text.prototype,"__",void 0),e([t.boundsType(0)],exports.Text.prototype,"width",void 0),e([t.boundsType(0)],exports.Text.prototype,"height",void 0),e([t.boundsType(0)],exports.Text.prototype,"padding",void 0),e([t.surfaceType("#000000")],exports.Text.prototype,"fill",void 0),e([t.affectStrokeBoundsType("outside")],exports.Text.prototype,"strokeAlign",void 0),e([t.hitType("all")],exports.Text.prototype,"hitFill",void 0),e([t.boundsType("")],exports.Text.prototype,"text",void 0),e([t.boundsType("L")],exports.Text.prototype,"fontFamily",void 0),e([t.boundsType(12)],exports.Text.prototype,"fontSize",void 0),e([t.boundsType("normal")],exports.Text.prototype,"fontWeight",void 0),e([t.boundsType(!1)],exports.Text.prototype,"italic",void 0),e([t.boundsType("none")],exports.Text.prototype,"textCase",void 0),e([t.boundsType("none")],exports.Text.prototype,"textDecoration",void 0),e([t.boundsType(0)],exports.Text.prototype,"letterSpacing",void 0),e([t.boundsType({type:"percent",value:150})],exports.Text.prototype,"lineHeight",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraIndent",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraSpacing",void 0),e([t.boundsType("left")],exports.Text.prototype,"textAlign",void 0),e([t.boundsType("top")],exports.Text.prototype,"verticalAlign",void 0),e([t.boundsType("normal")],exports.Text.prototype,"textWrap",void 0),e([t.boundsType("show")],exports.Text.prototype,"textOverflow",void 0),exports.Text=e([t.registerUI()],exports.Text);const{toBounds:vt}=t.PathBounds;exports.Path=class extends exports.UI{get __tag(){return"Path"}constructor(t){super(t)}__scaleResize(e,s){t.PathScaler.scale(this.__.path,e,s),this.path=this.__.path}__updateBoxBounds(){vt(this.__.path,this.__layout.boxBounds)}},e([t.dataProcessor(P)],exports.Path.prototype,"__",void 0),e([t.pathType()],exports.Path.prototype,"path",void 0),e([t.pathType()],exports.Path.prototype,"windingRule",void 0),e([t.affectStrokeBoundsType("center")],exports.Path.prototype,"strokeAlign",void 0),exports.Path=e([t.registerUI()],exports.Path),exports.Pen=class extends exports.Group{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new exports.Path(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,s,r,o,i){return this}quadraticCurveTo(t,e,s,r){return this}closePath(){return this}rect(t,e,s,r){return this}roundRect(t,e,s,r,o){return this}ellipse(t,e,s,r,o,i,a,n){return this}arc(t,e,s,r,o,i){return this}arcTo(t,e,s,r,o){return this}drawEllipse(t,e,s,r,o,i,a,n){return this}drawArc(t,e,s,r,o,i){return this}drawPoints(t,e,s){return this}paint(){this.pathElement.forceUpdate("path")}clear(){this.removeAll(!0)}},e([t.dataProcessor(B)],exports.Pen.prototype,"__",void 0),exports.Pen=e([t.useModule(t.PathCreator,["beginPath"]),t.registerUI()],exports.Pen);const gt=t.Debug.get("Leafer");exports.Leafer=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get layoutLocked(){return!this.layouter.running}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.zoomLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,dragOut:!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)}init(e,s){if(this.canvas)return;let r;this.__setLeafer(this),e&&t.DataHelper.assign(this.config,e);const{config:i}=this;o.run(i.type,this),this.canvas=t.Creator.canvas(i),this.__controllers.push(this.renderer=t.Creator.renderer(this,this.canvas,i),this.watcher=t.Creator.watcher(this,i),this.layouter=t.Creator.layouter(this,i)),this.isApp&&this.__setApp(),this.__checkAutoLayout(i),this.view=this.canvas.view,s?(this.__bindApp(s),r=s.running):(this.selector=t.Creator.selector(this),this.__controllers.unshift(this.interaction=t.Creator.interaction(this,this.canvas,this.selector,i)),this.canvasManager=new t.CanvasManager,this.hitCanvasManager=new t.HitCanvasManager,r=i.start),this.hittable=i.hittable,this.fill=i.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),r&&(this.__startTimer=setTimeout(this.start.bind(this))),t.PluginManager.onLeafer(this)}set(t){this.children?super.set(t):setTimeout((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(t.LeaferEvent.RESTART):this.emitLeafer(t.LeaferEvent.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(t.LeaferEvent.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(e){const s=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(s).forEach((t=>this[t]=s[t]))}forceFullRender(){this.renderer.addBlock(this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(){this.interaction&&this.interaction.updateCursor()}__doResize(e){if(!this.canvas||this.canvas.isSameSize(e))return;const s=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);this.canvas.resize(e),this.__onResize(new t.ResizeEvent(e,s))}__onResize(e){this.emitEvent(e),t.DataHelper.copyAttrs(this.__,e,t.canvasSizeAttrs),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.isLeafer=!!t,this.__level=1}setZoomLayer(t){this.zoomLayer=t}__checkAutoLayout(e){e.width&&e.height||(this.autoLayout=new t.AutoBounds(e),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(e,s){this.canvas&&(t.canvasSizeAttrs.includes(e)?this.__changeCanvasSize(e,s):"fill"===e?this.__changeFill(s):"hittable"===e&&(this.canvas.hittable=s)),super.__setAttr(e,s)}__getAttr(e){return this.canvas&&t.canvasSizeAttrs.includes(e)?this.canvas[e]:super.__getAttr(e)}__changeCanvasSize(e,s){const r=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);r[e]=this.config[e]=s,s&&this.canvas.stopAutoLayout(),this.__doResize(r)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(t.LeaferEvent.BEFORE_READY),this.emitLeafer(t.LeaferEvent.READY),this.emitLeafer(t.LeaferEvent.AFTER_READY),t.WaitHelper.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(t.LeaferEvent.VIEW_READY),t.WaitHelper.run(this.__viewReadyWait))}__onRenderEnd(e){this.viewReady||this.__onViewReady();const s=this.__checkViewCompleted();s&&this.__onViewCompleted(),this.viewCompleted=s,t.WaitHelper.run(this.__nextRenderWait)}__checkViewCompleted(){return this.viewReady&&!this.watcher.changed&&t.ImageManager.isComplete}__onViewCompleted(){this.viewCompleted||(this.emitLeafer(t.LeaferEvent.VIEW_COMPLETED),t.WaitHelper.run(this.__viewCompletedWait))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitReady(t){this.ready?t():this.__readyWait.push(t)}waitViewReady(t){this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t){this.viewCompleted?t():(this.__viewCompletedWait.push(t),this.running||this.start())}nextRender(t){this.watcher&&!this.watcher.changed?t():this.__nextRenderWait.push(t)}__checkUpdateLayout(){this.__layout.update()}emitLeafer(e){this.emitEvent(new t.LeaferEvent(e,this))}__listenEvents(){const e=t.Run.start("FirstCreate "+this.innerName);this.once(t.LeaferEvent.START,(()=>t.Run.end(e))),this.once(t.LayoutEvent.END,(()=>this.__onReady())),this.once(t.RenderEvent.START,(()=>this.__onCreated())),this.__eventIds.push(this.on_(t.WatchEvent.DATA,this.__onWatchData,this),this.on_(t.RenderEvent.END,this.__onRenderEnd,this),this.on_(t.LayoutEvent.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){setTimeout((()=>{if(!this.destroyed)try{this.stop(),this.emitEvent(new t.LeaferEvent(t.LeaferEvent.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector.destroy(),this.canvasManager.destroy(),this.hitCanvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{t.ImageManager.clearRecycled()}),100)}catch(t){gt.error(t)}}))}},e([t.dataProcessor(x)],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=e([t.registerUI()],exports.Leafer),exports.App=class extends exports.Leafer{get __tag(){return"App"}get isApp(){return!0}constructor(e,s){if(super(e,s),e){const{ground:s,tree:r,sky:o,editor:i}=e;s&&(this.ground=this.addLeafer(s)),(r||i)&&(this.tree=this.addLeafer(r)),(o||i)&&(this.sky=this.addLeafer(o||{type:"draw",usePartRender:!1})),i&&(this.editor=t.Creator.editor(i),this.sky.add(this.editor))}}__setApp(){const{canvas:e}=this,{realCanvas:s,view:r}=this.config;s||r===this.canvas.view||!e.parentView?this.realCanvas=!0:e.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable(),this.__eventIds.push(this.on_(t.PropertyEvent.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>t.start()))}stop(){this.children.forEach((t=>t.stop())),super.stop()}unlockLayout(){super.unlockLayout(),this.children.forEach((t=>t.unlockLayout()))}lockLayout(){super.lockLayout(),this.children.forEach((t=>t.lockLayout()))}addLeafer(t){const e=new exports.Leafer(t);return this.add(e),e}add(t){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout((()=>this.add(t)),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t),this.__listenChildEvents(t)}__onPropertyChange(){t.Debug.showHitView&&this.children.forEach((t=>t.forceUpdate("surface")))}__onCreated(){this.created=this.children.every((t=>t.created))}__onReady(){this.children.every((t=>t.ready))&&super.__onReady()}__onViewReady(){this.children.every((t=>t.viewReady))&&super.__onViewReady()}__checkViewCompleted(){return this.children.every((t=>t.viewCompleted))}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){this.children.forEach((e=>t.copyWorld(e.canvas)))}__onResize(t){this.children.forEach((e=>e.resize(t))),super.__onResize(t)}__checkUpdateLayout(){this.children.forEach((t=>t.__layout.update()))}__getChildConfig(e){let s=Object.assign({},this.config);return s.hittable=s.realCanvas=void 0,e&&t.DataHelper.assign(s,e),this.autoLayout&&t.DataHelper.copyAttrs(s,this,t.canvasSizeAttrs),s.view=this.realCanvas?void 0:this.view,s.fill=void 0,s}__listenChildEvents(e){e.once(t.LayoutEvent.END,(()=>this.__onReady())),e.once(t.RenderEvent.START,(()=>this.__onCreated())),e.once(t.RenderEvent.END,(t=>this.__onRenderEnd(t))),this.realCanvas&&this.__eventIds.push(e.on_(t.RenderEvent.END,this.__onChildRenderEnd,this))}},exports.App=e([t.registerUI()],exports.App),exports.Animate={},exports.BoxData=y,exports.CanvasData=class extends f{},exports.ColorConvert={},exports.Effect=a,exports.EllipseData=w,exports.Export=p,exports.FrameData=v,exports.GroupData=c,exports.ImageData=b,exports.LeaferData=x,exports.LeaferTypeCreator=o,exports.LineData=g,exports.Paint=n,exports.PathData=P,exports.PenData=B,exports.PolygonData=m,exports.RectData=f,exports.RectRender=U,exports.StarData=R,exports.TextConvert=h,exports.TextData=C,exports.UIBounds=E,exports.UIData=l,exports.UIHit=L,exports.UIRender=A,exports.UnitConvert=u,exports.effectType=I,exports.resizeType=S,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core");function e(t,e,s,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,r);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(i<3?o(a):i>3?o(e,s,a):o(e,s))||a);return i>3&&a&&Object.defineProperty(e,s,a),a}function s(t){const{config:e}=t;e.move.dragOut=!1}"function"==typeof SuppressedError&&SuppressedError;const r=t.Debug.get("LeaferTypeCreator"),o={list:{},register(t,e){i[t]?r.repeat(t):i[t]=e},run(t,e){const s=o.list[t];s?s(e):r.error("no",t)}},{list:i}=o;o.register("draw",s),o.register("user",s),o.register("design",(function(e){e.isApp||e.__eventIds.push(e.on_(t.MoveEvent.BEFORE_MOVE,(s=>{t.LeafHelper.moveWorld(e.zoomLayer,s.moveX,s.moveY)})),e.on_(t.ZoomEvent.BEFORE_ZOOM,(s=>{const{scaleX:r}=e.zoomLayer.__,{min:o,max:i}=e.app.config.zoom;let{scale:a}=s;a*Math.abs(r)<o?a=o/r:a*Math.abs(r)>i&&(a=i/r),1!==a&&t.LeafHelper.zoomOfWorld(e.zoomLayer,s,a)})))}));const a={},n={},h={},p={},_={},d=t.Debug.get("UIData");class l extends t.LeafData{get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoBounds(){return!this._width&&!this._height}setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,d.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,d.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&(this.__naturalWidth=this.__naturalHeight=void 0),"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=_)):(this.__isFills&&(this.__removeInput("fill"),n.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=_)):(this.__isStrokes&&(this.__removeInput("stroke"),n.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=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}}const u={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class c extends l{}class y extends c{get __boxStroke(){return!0}}class x extends c{}class v extends y{}class g extends l{}class f extends l{get __boxStroke(){return!0}}class w extends l{get __boxStroke(){return!0}}class m extends l{}class R extends l{}const{parse:T}=t.PathConvert;class P extends l{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=T(t)):(this.__input&&this.__removeInput("path"),this._path=t)}}class k extends c{}const I={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class B extends l{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=I[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class C extends f{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}function b(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function S(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}const E={__updateStrokeSpread(){let e=0,s=0;const{stroke:r,hitStroke:o,strokeAlign:i,strokeWidth:a}=this.__;if((r||"all"===o)&&a&&"inside"!==i&&(s=e="center"===i?a/2:a,!this.__.__boxStroke)){const{miterLimit:s,strokeCap:r}=this.__,o="Line"!==this.__tag?1/Math.sin(s*t.OneRadian/2)*Math.sqrt(a)-e:0,i="none"===r?0:a;e+=Math.max(o,i)}return this.__layout.strokeBoxSpread=s,e},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:r,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)})),r&&(t=Math.max(t,r));let i=t=Math.ceil(t);return s&&s.forEach((t=>{i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(i=Math.max(i,o)),this.__layout.renderShapeSpread=i,t}},A={__updateHitCanvas(){this.__hitCanvas||(this.__hitCanvas=this.leafer.hitCanvasManager.getPathType(this));const t=this.__hitCanvas;this.__drawHitPath(t),t.setStrokeOptions(this.__)},__hit(e){const{__hitCanvas:s}=this;"miniapp"===t.Platform.name&&this.__drawHitPath(s);const{fill:r,hitFill:o,windingRule:i}=this.__,a=r&&"path"===o||"all"===o,n=s.hitFill(e,i);if(a&&n)return!0;const{stroke:h,hitStroke:p,strokeWidth:_,strokeAlign:d}=this.__,l=h&&"path"===p||"all"===p,u=2*e.radiusX;let c=u;if(l)switch(d){case"inside":if(c+=2*_,!a&&n&&s.hitStroke(e,c))return!0;c=u;break;case"center":c+=_;break;case"outside":if(c+=2*_,!a){if(!n&&s.hitStroke(e,c))return!0;c=u}}return!!c&&s.hitStroke(e,c)}},L={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:r,backgroundBlur:o}=this.__;t.__useEffect=!!(e||s||r||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){const{fill:s,stroke:r,__drawAfterFill:o}=this.__;this.__drawRenderPath(t),s&&n.fill(s,this,t),o&&this.__drawAfterFill(t,e),r&&n.stroke(r,this,t,e)},__draw(t,e){if(this.__.__complex){const{fill:s,stroke:r,__drawAfterFill:o}=this.__;if(this.__drawRenderPath(t),this.__.__useEffect){const i=n.shape(this,t,e),{shadow:h,innerShadow:p}=this.__;h&&a.shadow(this,t,i,e),s&&(this.__.__isFills?n.fills(s,this,t):n.fill(s,this,t)),o&&this.__drawAfterFill(t,e),p&&a.innerShadow(this,t,i,e),r&&(this.__.__isStrokes?n.strokes(r,this,t,e):n.stroke(r,this,t,e)),i.worldCanvas&&i.worldCanvas.recycle(),i.canvas.recycle()}else s&&(this.__.__isFills?n.fills(s,this,t):n.fill(s,this,t)),o&&this.__drawAfterFill(t,e),r&&(this.__.__isStrokes?n.strokes(r,this,t,e):n.stroke(r,this,t,e))}else this.__drawFast(t,e)},__renderShape(t,e){if(!this.__worldOpacity)return;t.setWorld(this.__world,e.matrix);const{fill:s,stroke:r}=this.__;this.__drawRenderPath(t),s&&(this.__.__pixelFill?n.fills(s,this,t):n.fill("#000000",this,t)),r&&(this.__.__pixelStroke?n.strokes(r,this,t,e):n.stroke("#000000",this,t,e))}},U={__drawFast(t,e){const{width:s,height:r,fill:o,stroke:i,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,s,r)),a&&this.__drawAfterFill(t,e),i){const{strokeAlign:e,strokeWidth:o}=this.__;t.setStroke(i,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,s,r);break;case"inside":t.strokeRect(a,a,s-o,r-o);break;case"outside":t.strokeRect(-a,-a,s+o,r+o)}}}};var D;exports.UI=D=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}createProxyData(){}find(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!1,e):[]}findOne(t,e){return this.leafer?this.leafer.selector.getBy(t,this,!0,e):null}getPath(e,s){this.__layout.update();let r=s?this.__.__pathForRender:this.__.path;return r||this.__drawPathByBox(new t.PathCreator(r=[])),e?t.PathConvert.toCanvasData(r,!0):r}getPathString(e,s){return t.PathConvert.stringify(this.getPath(e,s))}__onUpdateSize(){if(this.__.__input){const{fill:t,stroke:e}=this.__.__input;t&&n.compute("fill",this),e&&n.compute("stroke",this)}}__updateRenderPath(){if(this.__.path){const{__:e}=this;e.__pathForRender=e.cornerRadius?t.PathCorner.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){}__drawPathByBox(t){const{x:e,y:s,width:r,height:o}=this.__layout.boxBounds;this.__.cornerRadius?t.roundRect(e,s,r,o,this.__.cornerRadius):t.rect(e,s,r,o)}export(t,e){return p.export(this,t,e)}clone(){return D.one(this.toJSON())}static one(e,s,r,o,i){return t.UICreator.get(e.tag||this.prototype.__tag,e,s,r,o,i)}destroy(){this.fill=this.stroke=null,super.destroy()}},e([t.dataProcessor(l)],exports.UI.prototype,"__",void 0),e([t.dataType("")],exports.UI.prototype,"id",void 0),e([t.dataType("")],exports.UI.prototype,"name",void 0),e([t.dataType("")],exports.UI.prototype,"className",void 0),e([t.surfaceType("pass-through")],exports.UI.prototype,"blendMode",void 0),e([t.opacityType(1)],exports.UI.prototype,"opacity",void 0),e([t.opacityType(!0)],exports.UI.prototype,"visible",void 0),e([t.maskType(!1)],exports.UI.prototype,"isMask",void 0),e([t.eraserType(!1)],exports.UI.prototype,"isEraser",void 0),e([t.dataType(!1)],exports.UI.prototype,"locked",void 0),e([t.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.positionType(0)],exports.UI.prototype,"x",void 0),e([t.positionType(0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100)],exports.UI.prototype,"width",void 0),e([t.boundsType(100)],exports.UI.prototype,"height",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewY",void 0),e([t.autoLayoutType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",void 0),e([t.dataType(!1)],exports.UI.prototype,"editable",void 0),e([t.dataType("size")],exports.UI.prototype,"editSize",void 0),e([t.hitType(!0)],exports.UI.prototype,"hittable",void 0),e([t.hitType("path")],exports.UI.prototype,"hitFill",void 0),e([t.strokeType("path")],exports.UI.prototype,"hitStroke",void 0),e([t.hitType(!1)],exports.UI.prototype,"hitBox",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitChildren",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitSelf",void 0),e([t.hitType()],exports.UI.prototype,"hitRadius",void 0),e([t.cursorType("")],exports.UI.prototype,"cursor",void 0),e([t.surfaceType()],exports.UI.prototype,"fill",void 0),e([t.strokeType()],exports.UI.prototype,"stroke",void 0),e([t.strokeType("inside")],exports.UI.prototype,"strokeAlign",void 0),e([t.strokeType(1)],exports.UI.prototype,"strokeWidth",void 0),e([t.strokeType("none")],exports.UI.prototype,"strokeCap",void 0),e([t.strokeType("miter")],exports.UI.prototype,"strokeJoin",void 0),e([t.strokeType()],exports.UI.prototype,"dashPattern",void 0),e([t.strokeType()],exports.UI.prototype,"dashOffset",void 0),e([t.strokeType(10)],exports.UI.prototype,"miterLimit",void 0),e([t.strokeType("none")],exports.UI.prototype,"startArrow",void 0),e([t.strokeType("none")],exports.UI.prototype,"endArrow",void 0),e([t.pathType(0)],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([b()],exports.UI.prototype,"shadow",void 0),e([b()],exports.UI.prototype,"innerShadow",void 0),e([b()],exports.UI.prototype,"blur",void 0),e([b()],exports.UI.prototype,"backgroundBlur",void 0),e([b()],exports.UI.prototype,"grayscale",void 0),e([t.rewrite(t.Leaf.prototype.reset)],exports.UI.prototype,"reset",null),e([t.rewrite(t.PathDrawer.drawPathByData)],exports.UI.prototype,"__drawPathByData",null),exports.UI=D=e([t.useModule(E),t.useModule(A),t.useModule(L),t.rewriteAble()],exports.UI);const F=t.MatrixHelper.get();exports.Group=class extends exports.UI{get __tag(){return"Group"}set mask(t){this.__hasMask&&this.__removeMask(),t&&(t.isMask=!0,this.addAt(t,0))}get mask(){return this.children.find((t=>t.isMask))}constructor(t){super(t),this.__setBranch()}__setBranch(){this.isBranch=!0,this.children||(this.children=[])}set(e){if(e.children){const{children:s}=e;let r;delete e.children,this.children?this.removeAll(!0):this.__setBranch(),super.set(e),s.forEach((e=>{r=t.UICreator.get(e.tag,e),this.add(r)})),e.children=s}else super.set(e)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}__scaleResize(t,e){const{children:s}=this;for(let r=0;r<s.length;r++)F.a=t,F.d=e,s[r].transform(F,!0)}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){}},e([t.dataProcessor(c)],exports.Group.prototype,"__",void 0),exports.Group=e([t.useModule(t.Branch),t.registerUI()],exports.Group),exports.Rect=class extends exports.UI{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){}},e([t.dataProcessor(f)],exports.Rect.prototype,"__",void 0),e([t.rewrite(exports.UI.prototype.__drawPathByBox)],exports.Rect.prototype,"__drawPathByData",null),exports.Rect=e([t.useModule(U),t.rewriteAble(),t.registerUI()],exports.Rect);const M=exports.Rect.prototype,z=exports.Group.prototype,W={},{copy:H,add:O}=t.BoundsHelper;exports.Box=class extends exports.Group{get __tag(){return"Box"}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderChanged||this.__layout.renderChange()}__scaleResize(t,e){this.__.__autoBounds&&this.children.length?super.__scaleResize(t,e):(this.width*=t,this.height*=e)}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateRectBoxBounds(){}__updateBoxBounds(){this.__.__autoBounds&&this.children.length?super.__updateBoxBounds():this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;H(W,t),super.__updateRenderBounds(),O(t,W)}}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__drawPathByData(t,e){}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.__renderGroup(t,e))}__drawAfterFill(t,e){t.save(),t.clip(),this.__renderGroup(t,e),t.restore(),this.__.stroke&&this.__drawRenderPath(t)}},e([t.dataProcessor(y)],exports.Box.prototype,"__",void 0),e([t.affectRenderBoundsType("show")],exports.Box.prototype,"overflow",void 0),e([t.rewrite(M.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(M.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(M.__updateBoxBounds)],exports.Box.prototype,"__updateRectBoxBounds",null),e([t.rewrite(M.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(M.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(M.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(M.__drawPathByData)],exports.Box.prototype,"__drawPathByData",null),e([t.rewrite(M.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(z.__render)],exports.Box.prototype,"__renderGroup",null),exports.Box=e([t.rewriteAble(),t.registerUI()],exports.Box),exports.Frame=class extends exports.Box{get __tag(){return"Frame"}constructor(t){super(t),this.isFrame=!0,this.__.fill||(this.__.fill="#FFFFFF")}},e([t.dataProcessor(v)],exports.Frame.prototype,"__",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo:V,closePath:N,ellipse:G}=t.PathCommandDataHelper;exports.Ellipse=class extends exports.UI{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:s,innerRadius:r,startAngle:o,endAngle:i}=this.__,a=e/2,n=s/2,h=this.__.path=[];r?(o||i?(r<1&&G(h,a,n,a*r,n*r,0,o,i,!1),G(h,a,n,a,n,0,i,o,!0),r<1&&N(h)):(r<1&&(G(h,a,n,a*r,n*r),V(h,e,n)),G(h,a,n,a,n,0,360,0,!0)),t.Platform.ellipseToCurve&&(this.__.path=this.getPath(!0))):o||i?(V(h,a,n),G(h,a,n,a,n,0,o,i,!1),N(h)):G(h,a,n,a,n)}},e([t.dataProcessor(w)],exports.Ellipse.prototype,"__",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"innerRadius",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"startAngle",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"endAngle",void 0),exports.Ellipse=e([t.registerUI()],exports.Ellipse);const{moveTo:j,lineTo:Y,drawPoints:X}=t.PathCommandDataHelper,{rotate:J,getAngle:$,getDistance:q,defaultPoint:Z}=t.PointHelper,{toBounds:K}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,s={x:0,y:0};return t&&(s.x=t),e&&J(s,e),s}set toPoint(t){this.width=q(Z,t),this.rotation=$(Z,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?X(t,this.__.points,!1):(j(t,0,0),Y(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?X(this.__.__pathForRender=[],this.__.points,this.__.curve,"Line"!==this.__tag):super.__updateRenderPath()}__updateBoxBounds(){this.points?K(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}__scaleResize(e,s){if(this.points)t.PathScaler.scalePoints(this.__.points,e,s),this.points=this.__.points;else if("Line"===this.__tag){const t=this.toPoint;t.x*=e,t.y*=s,this.toPoint=t}else super.__scaleResize(e,s)}},e([t.dataProcessor(g)],exports.Line.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Line.prototype,"strokeAlign",void 0),e([t.boundsType(0)],exports.Line.prototype,"height",void 0),e([t.pathType()],exports.Line.prototype,"points",void 0),e([t.pathType(0)],exports.Line.prototype,"curve",void 0),exports.Line=e([t.registerUI()],exports.Line);const{sin:Q,cos:tt,PI:et}=Math,{moveTo:st,lineTo:rt,closePath:ot,drawPoints:it}=t.PathCommandDataHelper,at=exports.Line.prototype;exports.Polygon=class extends exports.UI{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)it(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:r}=this.__,o=e/2,i=s/2;st(t,o,0);for(let e=1;e<r;e++)rt(t,o+o*Q(2*e*et/r),i-i*tt(2*e*et/r))}ot(t)}__updateRenderPath(){}__updateBoxBounds(){}__scaleResize(t,e){}},e([t.dataProcessor(m)],exports.Polygon.prototype,"__",void 0),e([t.pathType(3)],exports.Polygon.prototype,"sides",void 0),e([t.pathType()],exports.Polygon.prototype,"points",void 0),e([t.pathType(0)],exports.Polygon.prototype,"curve",void 0),e([t.rewrite(at.__updateRenderPath)],exports.Polygon.prototype,"__updateRenderPath",null),e([t.rewrite(at.__updateBoxBounds)],exports.Polygon.prototype,"__updateBoxBounds",null),e([t.rewrite(at.__scaleResize)],exports.Polygon.prototype,"__scaleResize",null),exports.Polygon=e([t.rewriteAble(),t.registerUI()],exports.Polygon);const{sin:nt,cos:ht,PI:pt}=Math,{moveTo:_t,lineTo:dt,closePath:lt}=t.PathCommandDataHelper;exports.Star=class extends exports.UI{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:r}=this.__,o=t/2,i=e/2,a=this.__.path=[];_t(a,o,0);for(let t=1;t<2*s;t++)dt(a,o+(t%2==0?o:o*r)*nt(t*pt/s),i-(t%2==0?i:i*r)*ht(t*pt/s));lt(a)}},e([t.dataProcessor(R)],exports.Star.prototype,"__",void 0),e([t.pathType(5)],exports.Star.prototype,"corners",void 0),e([t.pathType(.382)],exports.Star.prototype,"innerRadius",void 0),exports.Star=e([t.registerUI()],exports.Star),exports.Image=class extends exports.Rect{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(e){super(e),this.on(t.ImageEvent.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}},e([t.dataProcessor(C)],exports.Image.prototype,"__",void 0),e([t.boundsType("")],exports.Image.prototype,"url",void 0),exports.Image=e([t.registerUI()],exports.Image),exports.Canvas=class extends exports.Rect{get __tag(){return"Canvas"}constructor(e){super(e),this.canvas=t.Creator.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(e,s,r,o){e.__layout.update();const i=new t.Matrix(e.__world);i.invert();const a=new t.Matrix;s&&a.translate(s.x,s.y),r&&("number"==typeof r?a.scale(r):a.scale(r.x,r.y)),o&&a.rotate(o),i.multiplyParent(a),e.__render(this.canvas,{matrix:i}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:r,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o)}__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=null,this.context=null),super.destroy()}},e([t.dataProcessor(C)],exports.Canvas.prototype,"__",void 0),e([S(100)],exports.Canvas.prototype,"width",void 0),e([S(100)],exports.Canvas.prototype,"height",void 0),e([S(t.Platform.devicePixelRatio)],exports.Canvas.prototype,"pixelRatio",void 0),e([S(!0)],exports.Canvas.prototype,"smooth",void 0),e([t.hitType("all")],exports.Canvas.prototype,"hitFill",void 0),exports.Canvas=e([t.registerUI()],exports.Canvas);const{copyAndSpread:ut,includes:ct,spread:yt,setList:xt}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:s,__textDrawData:r}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):r.rows.forEach((r=>t.rect(r.x,r.y-s,r.width,e)))}__drawPathByData(t,e){const{x:s,y:r,width:o,height:i}=this.__layout.boxBounds;t.rect(s,r,o,i)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=h.getDrawData(t.text,this.__)}__updateBoxBounds(){const e=this.__,s=this.__layout,{lineHeight:r,letterSpacing:o,fontFamily:i,fontSize:a,fontWeight:n,italic:h,textCase:p,textOverflow:_,padding:d}=e,l=e.__autoWidth,c=e.__autoHeight;e.__lineHeight=u.number(r,a),e.__letterSpacing=u.number(o,a),e.__padding=d?t.MathHelper.fourNumber(d):void 0,e.__baseLine=e.__lineHeight-(e.__lineHeight-.7*a)/2,e.__font=`${h?"italic ":""}${"small-caps"===p?"small-caps ":""}${"normal"!==n?n+" ":""}${a}px ${i}`,e.__clipText="show"!==_&&!e.__autoBounds,this.__updateTextDrawData();const{bounds:y}=e.__textDrawData,x=s.boxBounds;if(e.__lineHeight<a&&yt(y,a/2),l||c){if(x.x=l?y.x:0,x.y=c?y.y:0,x.width=l?y.width:e.width,x.height=c?y.height:e.height,d){const[t,s,r,o]=e.__padding;l&&(x.x-=o,x.width+=s+o),c&&(x.y-=t,x.height+=r+t)}this.__updateNaturalSize()}else super.__updateBoxBounds();const v=ct(x,y)?x:y;v!==s.contentBounds?(s.contentBounds=v,s.renderChanged=!0,xt(e.__textBoxBounds={},[x,y])):e.__textBoxBounds=v}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){ut(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}},e([t.dataProcessor(B)],exports.Text.prototype,"__",void 0),e([t.boundsType(0)],exports.Text.prototype,"width",void 0),e([t.boundsType(0)],exports.Text.prototype,"height",void 0),e([t.boundsType(0)],exports.Text.prototype,"padding",void 0),e([t.surfaceType("#000000")],exports.Text.prototype,"fill",void 0),e([t.affectStrokeBoundsType("outside")],exports.Text.prototype,"strokeAlign",void 0),e([t.hitType("all")],exports.Text.prototype,"hitFill",void 0),e([t.boundsType("")],exports.Text.prototype,"text",void 0),e([t.boundsType("L")],exports.Text.prototype,"fontFamily",void 0),e([t.boundsType(12)],exports.Text.prototype,"fontSize",void 0),e([t.boundsType("normal")],exports.Text.prototype,"fontWeight",void 0),e([t.boundsType(!1)],exports.Text.prototype,"italic",void 0),e([t.boundsType("none")],exports.Text.prototype,"textCase",void 0),e([t.boundsType("none")],exports.Text.prototype,"textDecoration",void 0),e([t.boundsType(0)],exports.Text.prototype,"letterSpacing",void 0),e([t.boundsType({type:"percent",value:150})],exports.Text.prototype,"lineHeight",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraIndent",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraSpacing",void 0),e([t.boundsType("left")],exports.Text.prototype,"textAlign",void 0),e([t.boundsType("top")],exports.Text.prototype,"verticalAlign",void 0),e([t.boundsType("normal")],exports.Text.prototype,"textWrap",void 0),e([t.boundsType("show")],exports.Text.prototype,"textOverflow",void 0),exports.Text=e([t.registerUI()],exports.Text);const{toBounds:vt}=t.PathBounds;exports.Path=class extends exports.UI{get __tag(){return"Path"}constructor(t){super(t)}__scaleResize(e,s){t.PathScaler.scale(this.__.path,e,s),this.path=this.__.path}__updateBoxBounds(){vt(this.__.path,this.__layout.boxBounds)}},e([t.dataProcessor(P)],exports.Path.prototype,"__",void 0),e([t.pathType()],exports.Path.prototype,"path",void 0),e([t.pathType()],exports.Path.prototype,"windingRule",void 0),e([t.affectStrokeBoundsType("center")],exports.Path.prototype,"strokeAlign",void 0),exports.Path=e([t.registerUI()],exports.Path),exports.Pen=class extends exports.Group{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new exports.Path(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,s,r,o,i){return this}quadraticCurveTo(t,e,s,r){return this}closePath(){return this}rect(t,e,s,r){return this}roundRect(t,e,s,r,o){return this}ellipse(t,e,s,r,o,i,a,n){return this}arc(t,e,s,r,o,i){return this}arcTo(t,e,s,r,o){return this}drawEllipse(t,e,s,r,o,i,a,n){return this}drawArc(t,e,s,r,o,i){return this}drawPoints(t,e,s){return this}paint(){this.pathElement.forceUpdate("path")}clear(){this.removeAll(!0)}},e([t.dataProcessor(k)],exports.Pen.prototype,"__",void 0),exports.Pen=e([t.useModule(t.PathCreator,["beginPath"]),t.registerUI()],exports.Pen);const gt=t.Debug.get("Leafer");exports.Leafer=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get imageReady(){return this.viewReady&&t.ImageManager.isComplete}get layoutLocked(){return!this.layouter.running}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.zoomLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,dragOut:!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)}init(e,s){if(this.canvas)return;let r;this.__setLeafer(this),e&&t.DataHelper.assign(this.config,e);const{config:i}=this;o.run(i.type,this),this.canvas=t.Creator.canvas(i),this.__controllers.push(this.renderer=t.Creator.renderer(this,this.canvas,i),this.watcher=t.Creator.watcher(this,i),this.layouter=t.Creator.layouter(this,i)),this.isApp&&this.__setApp(),this.__checkAutoLayout(i),this.view=this.canvas.view,s?(this.__bindApp(s),r=s.running):(this.selector=t.Creator.selector(this),this.__controllers.unshift(this.interaction=t.Creator.interaction(this,this.canvas,this.selector,i)),this.canvasManager=new t.CanvasManager,this.hitCanvasManager=new t.HitCanvasManager,r=i.start),this.hittable=i.hittable,this.fill=i.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),r&&(this.__startTimer=setTimeout(this.start.bind(this))),t.PluginManager.onLeafer(this)}set(t){this.children?super.set(t):setTimeout((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(t.LeaferEvent.RESTART):this.emitLeafer(t.LeaferEvent.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(t.LeaferEvent.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(e){const s=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(s).forEach((t=>this[t]=s[t]))}forceFullRender(){this.renderer.addBlock(this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(){this.interaction&&this.interaction.updateCursor()}__doResize(e){if(!this.canvas||this.canvas.isSameSize(e))return;const s=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);this.canvas.resize(e),this.__onResize(new t.ResizeEvent(e,s))}__onResize(e){this.emitEvent(e),t.DataHelper.copyAttrs(this.__,e,t.canvasSizeAttrs),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.isLeafer=!!t,this.__level=1}setZoomLayer(t){this.zoomLayer=t}__checkAutoLayout(e){e.width&&e.height||(this.autoLayout=new t.AutoBounds(e),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(e,s){this.canvas&&(t.canvasSizeAttrs.includes(e)?this.__changeCanvasSize(e,s):"fill"===e?this.__changeFill(s):"hittable"===e&&(this.canvas.hittable=s)),super.__setAttr(e,s)}__getAttr(e){return this.canvas&&t.canvasSizeAttrs.includes(e)?this.canvas[e]:super.__getAttr(e)}__changeCanvasSize(e,s){const r=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);r[e]=this.config[e]=s,s&&this.canvas.stopAutoLayout(),this.__doResize(r)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(t.LeaferEvent.BEFORE_READY),this.emitLeafer(t.LeaferEvent.READY),this.emitLeafer(t.LeaferEvent.AFTER_READY),t.WaitHelper.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(t.LeaferEvent.VIEW_READY),t.WaitHelper.run(this.__viewReadyWait))}__onAnimateFrame(){if(this.viewReady){this.__nextRenderWait.length&&t.WaitHelper.run(this.__nextRenderWait);const{imageReady:e}=this;e&&!this.viewCompleted&&this.__checkViewCompleted(),e||(this.viewCompleted=!1)}}__checkViewCompleted(e=!0){this.nextRender((()=>{this.imageReady&&(e&&this.emitLeafer(t.LeaferEvent.VIEW_COMPLETED),t.WaitHelper.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitReady(t){this.ready?t():this.__readyWait.push(t)}waitViewReady(t){this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t){this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t){this.__nextRenderWait.push(t)}__checkUpdateLayout(){this.__layout.update()}emitLeafer(e){this.emitEvent(new t.LeaferEvent(e,this))}__listenEvents(){const e=t.Run.start("FirstCreate "+this.innerName);this.once(t.LeaferEvent.START,(()=>t.Run.end(e))),this.once(t.LayoutEvent.END,(()=>this.__onReady())),this.once(t.RenderEvent.START,(()=>this.__onCreated())),this.once(t.RenderEvent.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(t.WatchEvent.DATA,this.__onWatchData,this),this.on_(t.AnimateEvent.FRAME,this.__onAnimateFrame,this),this.on_(t.LayoutEvent.CHECK_UPDATE,this.__checkUpdateLayout,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){setTimeout((()=>{if(!this.destroyed)try{this.stop(),this.emitEvent(new t.LeaferEvent(t.LeaferEvent.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector.destroy(),this.canvasManager.destroy(),this.hitCanvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{t.ImageManager.clearRecycled()}),100)}catch(t){gt.error(t)}}))}},e([t.dataProcessor(x)],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=e([t.registerUI()],exports.Leafer),exports.App=class extends exports.Leafer{get __tag(){return"App"}get isApp(){return!0}constructor(e,s){if(super(e,s),e){const{ground:s,tree:r,sky:o,editor:i}=e;s&&(this.ground=this.addLeafer(s)),(r||i)&&(this.tree=this.addLeafer(r)),(o||i)&&(this.sky=this.addLeafer(o||{type:"draw",usePartRender:!1})),i&&(this.editor=t.Creator.editor(i),this.sky.add(this.editor))}}__setApp(){const{canvas:e}=this,{realCanvas:s,view:r}=this.config;s||r===this.canvas.view||!e.parentView?this.realCanvas=!0:e.unrealCanvas(),this.leafer=this,this.watcher.disable(),this.layouter.disable(),this.__eventIds.push(this.on_(t.PropertyEvent.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>t.start()))}stop(){this.children.forEach((t=>t.stop())),super.stop()}unlockLayout(){super.unlockLayout(),this.children.forEach((t=>t.unlockLayout()))}lockLayout(){super.lockLayout(),this.children.forEach((t=>t.lockLayout()))}addLeafer(t){const e=new exports.Leafer(t);return this.add(e),e}add(t){if(!t.view){if(this.realCanvas&&!this.canvas.bounds)return void setTimeout((()=>this.add(t)),10);t.init(this.__getChildConfig(t.userConfig),this)}super.add(t),this.__listenChildEvents(t)}__onPropertyChange(){t.Debug.showHitView&&this.children.forEach((t=>t.forceUpdate("surface")))}__onCreated(){this.created=this.children.every((t=>t.created))}__onReady(){this.children.every((t=>t.ready))&&super.__onReady()}__onViewReady(){this.children.every((t=>t.viewReady))&&super.__onViewReady()}__onChildRenderEnd(t){this.renderer.addBlock(t.renderBounds),this.viewReady&&this.renderer.update()}__render(t,e){this.children.forEach((e=>t.copyWorld(e.canvas)))}__onResize(t){this.children.forEach((e=>e.resize(t))),super.__onResize(t)}__checkUpdateLayout(){this.children.forEach((t=>t.__layout.update()))}__getChildConfig(e){let s=Object.assign({},this.config);return s.hittable=s.realCanvas=void 0,e&&t.DataHelper.assign(s,e),this.autoLayout&&t.DataHelper.copyAttrs(s,this,t.canvasSizeAttrs),s.view=this.realCanvas?void 0:this.view,s.fill=void 0,s}__listenChildEvents(e){e.once(t.LayoutEvent.END,(()=>this.__onReady())),e.once(t.RenderEvent.START,(()=>this.__onCreated())),e.once(t.RenderEvent.END,(()=>this.__onViewReady())),this.realCanvas&&this.__eventIds.push(e.on_(t.RenderEvent.END,this.__onChildRenderEnd,this))}},exports.App=e([t.registerUI()],exports.App),exports.Animate={},exports.ArrowData=class extends g{},exports.BoxData=y,exports.CanvasData=class extends f{},exports.ColorConvert={},exports.Effect=a,exports.EllipseData=w,exports.Export=p,exports.FrameData=v,exports.GroupData=c,exports.ImageData=C,exports.LeaferData=x,exports.LeaferTypeCreator=o,exports.LineData=g,exports.Paint=n,exports.PathData=P,exports.PenData=k,exports.PolygonData=m,exports.RectData=f,exports.RectRender=U,exports.StarData=R,exports.TextConvert=h,exports.TextData=B,exports.UIBounds=E,exports.UIData=l,exports.UIHit=A,exports.UIRender=L,exports.UnitConvert=u,exports.effectType=b,exports.resizeType=S,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/core",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.9",
|
|
4
4
|
"description": "@leafer-ui/core",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"leaferjs"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@leafer/core": "1.0.0-rc.
|
|
33
|
-
"@leafer-ui/app": "1.0.0-rc.
|
|
34
|
-
"@leafer-ui/display": "1.0.0-rc.
|
|
35
|
-
"@leafer-ui/decorator": "1.0.0-rc.
|
|
36
|
-
"@leafer-ui/display-module": "1.0.0-rc.
|
|
37
|
-
"@leafer-ui/external": "1.0.0-rc.
|
|
38
|
-
"@leafer-ui/type": "1.0.0-rc.
|
|
32
|
+
"@leafer/core": "1.0.0-rc.9",
|
|
33
|
+
"@leafer-ui/app": "1.0.0-rc.9",
|
|
34
|
+
"@leafer-ui/display": "1.0.0-rc.9",
|
|
35
|
+
"@leafer-ui/decorator": "1.0.0-rc.9",
|
|
36
|
+
"@leafer-ui/display-module": "1.0.0-rc.9",
|
|
37
|
+
"@leafer-ui/external": "1.0.0-rc.9",
|
|
38
|
+
"@leafer-ui/type": "1.0.0-rc.9"
|
|
39
39
|
}
|
|
40
40
|
}
|