@leafer-ui/core 1.0.0-rc.2 → 1.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +8 -3
- package/dist/core.esm.js +8 -3
- 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
|
@@ -970,14 +970,19 @@ exports.Polygon = class Polygon extends exports.UI {
|
|
|
970
970
|
__updateRenderPath() {
|
|
971
971
|
if (this.__.points && this.__.curve) {
|
|
972
972
|
drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, true);
|
|
973
|
-
this.__updateNaturalSize();
|
|
974
973
|
}
|
|
975
974
|
else {
|
|
976
975
|
super.__updateRenderPath();
|
|
977
976
|
}
|
|
978
977
|
}
|
|
979
978
|
__updateBoxBounds() {
|
|
980
|
-
|
|
979
|
+
if (this.__.points) {
|
|
980
|
+
toBounds$2(this.__.__pathForRender, this.__layout.boxBounds);
|
|
981
|
+
this.__updateNaturalSize();
|
|
982
|
+
}
|
|
983
|
+
else {
|
|
984
|
+
super.__updateBoxBounds();
|
|
985
|
+
}
|
|
981
986
|
}
|
|
982
987
|
};
|
|
983
988
|
__decorate([
|
|
@@ -1071,7 +1076,7 @@ exports.Line = class Line extends exports.UI {
|
|
|
1071
1076
|
}
|
|
1072
1077
|
__updateBoxBounds() {
|
|
1073
1078
|
if (this.points) {
|
|
1074
|
-
toBounds$1(this.__.
|
|
1079
|
+
toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
|
|
1075
1080
|
this.__updateNaturalSize();
|
|
1076
1081
|
}
|
|
1077
1082
|
else {
|
package/dist/core.esm.js
CHANGED
|
@@ -969,14 +969,19 @@ let Polygon = class Polygon extends UI {
|
|
|
969
969
|
__updateRenderPath() {
|
|
970
970
|
if (this.__.points && this.__.curve) {
|
|
971
971
|
drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, true);
|
|
972
|
-
this.__updateNaturalSize();
|
|
973
972
|
}
|
|
974
973
|
else {
|
|
975
974
|
super.__updateRenderPath();
|
|
976
975
|
}
|
|
977
976
|
}
|
|
978
977
|
__updateBoxBounds() {
|
|
979
|
-
|
|
978
|
+
if (this.__.points) {
|
|
979
|
+
toBounds$2(this.__.__pathForRender, this.__layout.boxBounds);
|
|
980
|
+
this.__updateNaturalSize();
|
|
981
|
+
}
|
|
982
|
+
else {
|
|
983
|
+
super.__updateBoxBounds();
|
|
984
|
+
}
|
|
980
985
|
}
|
|
981
986
|
};
|
|
982
987
|
__decorate([
|
|
@@ -1070,7 +1075,7 @@ let Line = class Line extends UI {
|
|
|
1070
1075
|
}
|
|
1071
1076
|
__updateBoxBounds() {
|
|
1072
1077
|
if (this.points) {
|
|
1073
|
-
toBounds$1(this.__.
|
|
1078
|
+
toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
|
|
1074
1079
|
this.__updateNaturalSize();
|
|
1075
1080
|
}
|
|
1076
1081
|
else {
|
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 r,PathConvert as o,defineLeafAttr as a,OneRadian as h,Platform as n,dataProcessor as _,dataType as d,surfaceType as p,opacityType as l,maskType as c,eraserType as u,sortType as y,positionType as v,boundsType as g,scaleType as f,rotationType as w,hitType as m,strokeType as R,cursorType as x,pathType as k,rewrite as S,PathDrawer as b,useModule as C,rewriteAble as A,Leaf as B,PathCorner as E,UICreator as P,Branch as D,registerUI as F,affectRenderBoundsType as L,BoundsHelper as T,PathCommandDataHelper as M,PathBounds as z,affectStrokeBoundsType as W,PointHelper as I,ImageEvent as O,Creator as V,Matrix as N,PathCreator as H,DataHelper as U,CanvasManager as Y,HitCanvasManager as X,PluginManager as j,LeaferEvent as G,canvasSizeAttrs as J,ResizeEvent as $,AutoBounds as q,WaitHelper as K,ImageManager as Z,Run as Q,LayoutEvent as tt,RenderEvent as et,WatchEvent as st,PropertyEvent as it}from"@leafer/core";export*from"@leafer/core";function rt(t,e,s,i){var r,o=arguments.length,a=o<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--)(r=t[h])&&(a=(o<3?r(a):o>3?r(e,s,a):r(e,s))||a);return o>3&&a&&Object.defineProperty(e,s,a),a}function ot(t){const{config:e}=t;e.move.dragOut=!1}"function"==typeof SuppressedError&&SuppressedError;const at=i.get("LeaferTypeCreator"),ht={list:{},register(t,e){nt[t]?at.repeat(t):nt[t]=e},run(t,e){const s=ht.list[t];s?s(e):at.error("no",t)}},{list:nt}=ht;ht.register("draw",ot),ht.register("user",ot),ht.register("design",(function(i){i.isApp||i.__eventIds.push(i.on_(t.BEFORE_MOVE,(t=>{e.moveWorld(i.moveLayer,t.moveX,t.moveY)})),i.on_(s.BEFORE_ZOOM,(t=>{const{scaleX:s}=i.zoomLayer.__,{min:r,max:o}=i.config.zoom;let{scale:a}=t;a*Math.abs(s)<r?a=r/s:a*Math.abs(s)>o&&(a=o/s),1!==a&&e.zoomOfWorld(i.zoomLayer,t,a)})))}));const _t={},dt={},pt={},lt={},ct={},ut={},yt={},vt=i.get("UIData");class gt extends r{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,vt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,vt.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=yt)):(this.__isFills&&(this.__removeInput("fill"),dt.recycleImage(this,"fill"),this.__isFills=!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=yt)):(this.__isStrokes&&(this.__removeInput("stroke"),dt.recycleImage(this,"stroke"),this.__isStrokes=!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 ft={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class wt extends gt{}class mt extends wt{get __boxStroke(){return!0}}class Rt extends gt{get __boxStroke(){return!0}}const{parse:xt}=o;const kt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class St extends Rt{}function bt(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 Ct(t){return(e,s)=>{a(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}const At={__updateStrokeSpread(){let t=0,e=0;const{stroke:s,hitStroke:i,strokeAlign:r,strokeWidth:o}=this.__;if((s||"all"===i)&&o&&"inside"!==r&&(e=t="center"===r?o/2:o,!this.__.__boxStroke)){const{miterLimit:e,strokeCap:s}=this.__,i="Line"!==this.__tag?1/Math.sin(e*h/2)*Math.sqrt(o)-t:0,r="none"===s?0:o;t+=Math.max(i,r)}return this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:i,backgroundBlur:r}=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 o=t=Math.ceil(t);return s&&s.forEach((t=>{o=Math.max(o,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),r&&(o=Math.max(o,r)),this.__layout.renderShapeSpread=o,t}},Bt={__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"===n.name&&this.__drawHitPath(e);const{fill:s,hitFill:i,windingRule:r}=this.__,o=s&&"path"===i||"all"===i,a=e.hitFill(t,r);if(o&&a)return!0;const{stroke:h,hitStroke:_,strokeWidth:d,strokeAlign:p}=this.__,l=h&&"path"===_||"all"===_,c=2*t.radiusX;let u=c;if(l)switch(p){case"inside":if(u+=2*d,!o&&a&&e.hitStroke(t,u))return!0;u=c;break;case"center":u+=d;break;case"outside":if(u+=2*d,!o){if(!a&&e.hitStroke(t,u))return!0;u=c}}return!!u&&e.hitStroke(t,u)}},Et={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:i,backgroundBlur:r}=this.__;t.__useEffect=!!(e||s||i||r)}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:r}=this.__;this.__drawRenderPath(t),s&&dt.fill(this,t,s),r&&this.__drawAfterFill(t,e),i&&dt.stroke(this,t,i)},__draw(t,e){if(this.__.__complex){const{fill:s,stroke:i,__drawAfterFill:r}=this.__;if(this.__drawRenderPath(t),this.__.__useEffect){const o=dt.shape(this,t,e),{shadow:a,innerShadow:h}=this.__;a&&_t.shadow(this,t,o,e),s&&(this.__.__isFills?dt.fills(this,t,s):dt.fill(this,t,s)),r&&this.__drawAfterFill(t,e),h&&_t.innerShadow(this,t,o,e),i&&(this.__.__isStrokes?dt.strokes(this,t,i):dt.stroke(this,t,i)),o.worldCanvas&&o.worldCanvas.recycle(),o.canvas.recycle()}else s&&(this.__.__isFills?dt.fills(this,t,s):dt.fill(this,t,s)),r&&this.__drawAfterFill(t,e),i&&(this.__.__isStrokes?dt.strokes(this,t,i):dt.stroke(this,t,i))}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&&dt.fill(this,t,"#000000"),i&&dt.stroke(this,t,"#000000")}},Pt={__drawFast(t,e){const{width:s,height:i,fill:r,stroke:o,__drawAfterFill:a}=this.__;if(r&&(t.fillStyle=r,t.fillRect(0,0,s,i)),a&&this.__drawAfterFill(t,e),o){const{strokeAlign:e,strokeWidth:r}=this.__;t.setStroke(o,r,this.__);const a=r/2;switch(e){case"center":t.strokeRect(0,0,s,i);break;case"inside":t.strokeRect(a,a,s-r,i-r);break;case"outside":t.strokeRect(-a,-a,s+r,i+r)}}}};var Dt;let Ft=Dt=class extends B{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)}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}getPath(t){const e=this.__.path;return e?t?o.toCanvasData(e,!0):e:[]}getPathString(t){return o.stringify(this.getPath(t))}__onUpdateSize(){if(this.__.__input){const{fill:t,stroke:e}=this.__.__input;t&&dt.compute(this,"fill"),e&&dt.compute(this,"stroke")}}__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){}export(t,e){return ut.export(this,t,e)}clone(){return Dt.one(this.toJSON())}static one(t,e,s,i,r){return P.get(t.tag||this.prototype.__tag,t,e,s,i,r)}destroy(){this.fill=this.stroke=null,super.destroy()}};rt([_(gt)],Ft.prototype,"__",void 0),rt([d("")],Ft.prototype,"id",void 0),rt([d("")],Ft.prototype,"name",void 0),rt([d("")],Ft.prototype,"className",void 0),rt([p("pass-through")],Ft.prototype,"blendMode",void 0),rt([l(1)],Ft.prototype,"opacity",void 0),rt([l(!0)],Ft.prototype,"visible",void 0),rt([c(!1)],Ft.prototype,"isMask",void 0),rt([u(!1)],Ft.prototype,"isEraser",void 0),rt([y(0)],Ft.prototype,"zIndex",void 0),rt([d()],Ft.prototype,"locked",void 0),rt([v(0)],Ft.prototype,"x",void 0),rt([v(0)],Ft.prototype,"y",void 0),rt([g(100)],Ft.prototype,"width",void 0),rt([g(100)],Ft.prototype,"height",void 0),rt([f(1)],Ft.prototype,"scaleX",void 0),rt([f(1)],Ft.prototype,"scaleY",void 0),rt([w(0)],Ft.prototype,"rotation",void 0),rt([w(0)],Ft.prototype,"skewX",void 0),rt([w(0)],Ft.prototype,"skewY",void 0),rt([v()],Ft.prototype,"around",void 0),rt([d(!1)],Ft.prototype,"draggable",void 0),rt([m(!0)],Ft.prototype,"hittable",void 0),rt([m("path")],Ft.prototype,"hitFill",void 0),rt([R("path")],Ft.prototype,"hitStroke",void 0),rt([m(!0)],Ft.prototype,"hitChildren",void 0),rt([m(!0)],Ft.prototype,"hitSelf",void 0),rt([m()],Ft.prototype,"hitRadius",void 0),rt([x("default")],Ft.prototype,"cursor",void 0),rt([p()],Ft.prototype,"fill",void 0),rt([R()],Ft.prototype,"stroke",void 0),rt([R("inside")],Ft.prototype,"strokeAlign",void 0),rt([R(1)],Ft.prototype,"strokeWidth",void 0),rt([R("none")],Ft.prototype,"strokeCap",void 0),rt([R("miter")],Ft.prototype,"strokeJoin",void 0),rt([R()],Ft.prototype,"dashPattern",void 0),rt([R()],Ft.prototype,"dashOffset",void 0),rt([R(10)],Ft.prototype,"miterLimit",void 0),rt([k()],Ft.prototype,"cornerRadius",void 0),rt([k()],Ft.prototype,"cornerSmoothing",void 0),rt([bt()],Ft.prototype,"shadow",void 0),rt([bt()],Ft.prototype,"innerShadow",void 0),rt([bt()],Ft.prototype,"blur",void 0),rt([bt()],Ft.prototype,"backgroundBlur",void 0),rt([bt()],Ft.prototype,"grayscale",void 0),rt([S(b.drawPathByData)],Ft.prototype,"__drawPathByData",null),Ft=Dt=rt([C(At),C(Bt),C(Et),A()],Ft);let Lt=class extends Ft{get __tag(){return"Group"}get resizeable(){return!1}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.__setBranch(),super.set(t),e.forEach((t=>{s=P.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}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){}};rt([_(wt)],Lt.prototype,"__",void 0),Lt=rt([C(D),F()],Lt);let Tt=class extends Ft{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){const{width:s,height:i,cornerRadius:r}=this.__;r?t.roundRect(0,0,s,i,r):t.rect(0,0,s,i)}};rt([_(Rt)],Tt.prototype,"__",void 0),Tt=rt([C(Pt),F()],Tt);const Mt=Tt.prototype,zt=Lt.prototype,Wt={},{copy:It,add:Ot}=T;let Vt=class extends Lt{get __tag(){return"Box"}get resizeable(){return!0}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderChanged||this.__layout.renderChange()}__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}__updateBoxBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;It(Wt,t),super.__updateRenderBounds(),Ot(t,Wt)}}__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)}};rt([_(mt)],Vt.prototype,"__",void 0),rt([L("show")],Vt.prototype,"overflow",void 0),rt([S(Mt.__updateStrokeSpread)],Vt.prototype,"__updateStrokeSpread",null),rt([S(Mt.__updateRenderSpread)],Vt.prototype,"__updateRectRenderSpread",null),rt([S(Mt.__updateBoxBounds)],Vt.prototype,"__updateBoxBounds",null),rt([S(Mt.__updateStrokeBounds)],Vt.prototype,"__updateStrokeBounds",null),rt([S(Mt.__updateRenderBounds)],Vt.prototype,"__updateRectRenderBounds",null),rt([S(Mt.__updateChange)],Vt.prototype,"__updateRectChange",null),rt([S(Mt.__drawPathByData)],Vt.prototype,"__drawPathByData",null),rt([S(Mt.__render)],Vt.prototype,"__renderRect",null),rt([S(zt.__render)],Vt.prototype,"__renderGroup",null),Vt=rt([A(),F()],Vt);let Nt=class extends Vt{get __tag(){return"Frame"}constructor(t){super(t),this.__.fill||(this.__.fill="#FFFFFF")}};rt([_(class extends mt{})],Nt.prototype,"__",void 0),rt([L("hide")],Nt.prototype,"overflow",void 0),Nt=rt([F()],Nt);const{moveTo:Ht,closePath:Ut,ellipse:Yt}=M;let Xt=class extends Ft{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:s,startAngle:i,endAngle:r}=this.__,o=t/2,a=e/2,h=this.__.path=[];s?i||r?(s<1&&Yt(h,o,a,o*s,a*s,0,i,r,!1),Yt(h,o,a,o,a,0,r,i,!0),s<1&&Ut(h)):(s<1&&(Yt(h,o,a,o*s,a*s),Ht(h,t,a)),Yt(h,o,a,o,a,0,0,360,!0)):i||r?(Ht(h,o,a),Yt(h,o,a,o,a,0,i,r,!1),Ut(h)):Yt(h,o,a,o,a)}};rt([_(class extends gt{get __boxStroke(){return!0}})],Xt.prototype,"__",void 0),rt([k(0)],Xt.prototype,"innerRadius",void 0),rt([k(0)],Xt.prototype,"startAngle",void 0),rt([k(0)],Xt.prototype,"endAngle",void 0),Xt=rt([F()],Xt);const{sin:jt,cos:Gt,PI:Jt}=Math,{moveTo:$t,lineTo:qt,closePath:Kt,drawPoints:Zt}=M,{toBounds:Qt}=z;let te=class extends Ft{get __tag(){return"Polygon"}get resizeable(){return!this.points}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Zt(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:i}=this.__,r=e/2,o=s/2;$t(t,r,0);for(let e=1;e<i;e++)qt(t,r+r*jt(2*e*Jt/i),o-o*Gt(2*e*Jt/i))}Kt(t)}__updateRenderPath(){this.__.points&&this.__.curve?(Zt(this.__.__pathForRender=[],this.__.points,this.__.curve,!0),this.__updateNaturalSize()):super.__updateRenderPath()}__updateBoxBounds(){this.__.points?Qt(this.__.path,this.__layout.boxBounds):super.__updateBoxBounds()}};rt([_(class extends gt{})],te.prototype,"__",void 0),rt([k(3)],te.prototype,"sides",void 0),rt([k()],te.prototype,"points",void 0),rt([k(0)],te.prototype,"curve",void 0),te=rt([F()],te);const{sin:ee,cos:se,PI:ie}=Math,{moveTo:re,lineTo:oe,closePath:ae}=M;let he=class extends Ft{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:i}=this.__,r=t/2,o=e/2,a=this.__.path=[];re(a,r,0);for(let t=1;t<2*s;t++)oe(a,r+(t%2==0?r:r*i)*ee(t*ie/s),o-(t%2==0?o:o*i)*se(t*ie/s));ae(a)}};rt([_(class extends gt{})],he.prototype,"__",void 0),rt([k(5)],he.prototype,"corners",void 0),rt([k(.382)],he.prototype,"innerRadius",void 0),he=rt([F()],he);const{moveTo:ne,lineTo:_e,drawPoints:de}=M,{rotate:pe,getAngle:le,getDistance:ce,defaultPoint:ue}=I,{toBounds:ye}=z;let ve=class extends Ft{get __tag(){return"Line"}get resizeable(){return!this.points}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=ce(ue,t),this.rotation=le(ue,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?de(t,this.__.points,!1):(ne(t,0,0),_e(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?de(this.__.__pathForRender=[],this.__.points,this.__.curve,!1):super.__updateRenderPath()}__updateBoxBounds(){this.points?(ye(this.__.path,this.__layout.boxBounds),this.__updateNaturalSize()):super.__updateBoxBounds()}};rt([_(class extends gt{})],ve.prototype,"__",void 0),rt([W("center")],ve.prototype,"strokeAlign",void 0),rt([g(0)],ve.prototype,"height",void 0),rt([k()],ve.prototype,"points",void 0),rt([k(0)],ve.prototype,"curve",void 0),ve=rt([F()],ve);let ge=class extends Tt{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(O.LOADED,(t=>this.image=t.image))),super.__updateBoxBounds()}destroy(){this.image=null,super.destroy()}};rt([_(St)],ge.prototype,"__",void 0),rt([g("")],ge.prototype,"url",void 0),ge=rt([F()],ge);let fe=class extends Tt{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=V.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(t,e,s,i){t.__layout.checkUpdate();const r=new N(t.__world);r.invert();const o=new N;e&&o.translate(e.x,e.y),s&&("number"==typeof s?o.scale(s):o.scale(s.x,s.y)),i&&o.rotate(i),r.preMultiply(o),t.__render(this.canvas,{matrix:r}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:i,height:r}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,i,r),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,i,r)}__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()}};rt([_(St)],fe.prototype,"__",void 0),rt([Ct(100)],fe.prototype,"width",void 0),rt([Ct(100)],fe.prototype,"height",void 0),rt([Ct(n.devicePixelRatio)],fe.prototype,"pixelRatio",void 0),rt([Ct(!0)],fe.prototype,"smooth",void 0),rt([m("all")],fe.prototype,"hitFill",void 0),fe=rt([F()],fe);const{copyAndSpread:we,includes:me,spread:Re}=T;let xe=class extends Ft{get __tag(){return"Text"}get textDrawData(){return this.__layout.checkUpdate(),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:r,height:o}=this.__layout.boxBounds;t.rect(s,i,r,o)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=lt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:s,letterSpacing:i,fontFamily:r,fontSize:o,fontWeight:a,italic:h,textCase:n}=t;t.__lineHeight=ft.number(s,o),t.__letterSpacing=ft.number(i,o),t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*o)/2,t.__font=`${h?"italic ":""}${"small-caps"===n?"small-caps ":""}${"normal"!==a?a+" ":""}${o}px ${r}`,this.__updateTextDrawData();const{bounds:_}=t.__textDrawData,d=e.boxBounds;t.__lineHeight<o&&Re(_,o/2);const p=t.__getInput("width"),l=t.__getInput("height");p&&l?super.__updateBoxBounds():(d.x=p?0:_.x,d.y=l?0:_.y,d.width=p||_.width,d.height=l||_.height,this.__updateNaturalSize());const c=me(d,_)?d:_;c!==e.contentBounds&&(e.contentBounds=c,e.renderChanged=!0)}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){we(this.__layout.renderBounds,this.__layout.contentBounds,this.__layout.renderSpread)}};rt([_(class extends gt{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=kt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}})],xe.prototype,"__",void 0),rt([g(0)],xe.prototype,"width",void 0),rt([g(0)],xe.prototype,"height",void 0),rt([g(0)],xe.prototype,"padding",void 0),rt([W("outside")],xe.prototype,"strokeAlign",void 0),rt([g("")],xe.prototype,"text",void 0),rt([g("L")],xe.prototype,"fontFamily",void 0),rt([g(12)],xe.prototype,"fontSize",void 0),rt([g("normal")],xe.prototype,"fontWeight",void 0),rt([g(!1)],xe.prototype,"italic",void 0),rt([g("none")],xe.prototype,"textCase",void 0),rt([g("none")],xe.prototype,"textDecoration",void 0),rt([g(0)],xe.prototype,"letterSpacing",void 0),rt([g({type:"percent",value:150})],xe.prototype,"lineHeight",void 0),rt([g(0)],xe.prototype,"paraIndent",void 0),rt([g(0)],xe.prototype,"paraSpacing",void 0),rt([g("left")],xe.prototype,"textAlign",void 0),rt([g("top")],xe.prototype,"verticalAlign",void 0),rt([g("show")],xe.prototype,"textOverflow",void 0),xe=rt([F()],xe);const{toBounds:ke}=z;let Se=class extends Ft{get __tag(){return"Path"}get resizeable(){return!1}constructor(t){super(t)}__updateBoxBounds(){ke(this.__.path,this.__layout.boxBounds),this.__updateNaturalSize()}};rt([_(class extends gt{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=xt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}})],Se.prototype,"__",void 0),rt([k()],Se.prototype,"path",void 0),rt([k()],Se.prototype,"windingRule",void 0),rt([W("center")],Se.prototype,"strokeAlign",void 0),Se=rt([F()],Se);let be=class extends Lt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Se(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,r,o){return this}quadraticCurveTo(t,e,s,i){return this}closePath(){return this}rect(t,e,s,i){return this}roundRect(t,e,s,i,r){return this}ellipse(t,e,s,i,r,o,a,h){return this}arc(t,e,s,i,r,o){return this}arcTo(t,e,s,i,r){return this}drawEllipse(t,e,s,i,r,o,a,h){return this}drawArc(t,e,s,i,r,o){return this}drawPoints(t,e,s){return this}paint(){this.pathElement.forceUpdate("path")}clear(){this.removeAll(!0)}};rt([_(class extends wt{})],be.prototype,"__",void 0),be=rt([C(H,["beginPath"]),F()],be);const Ce=i.get("Leafer");let Ae=class extends Lt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}constructor(t,e){super(e),this.zoomLayer=this,this.moveLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,dragOut:!0,autoDistance:2}},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&&U.assign(this.config,t);const{config:i}=this;ht.run(i.type,this),this.canvas=V.canvas(i),this.__controllers.push(this.renderer=V.renderer(this,this.canvas,i),this.watcher=V.watcher(this,i),this.layouter=V.layouter(this,i)),this.isApp&&this.__setApp(),this.__checkAutoLayout(i),this.view=this.canvas.view,e?(this.__bindApp(e),s=e.running):(this.selector=V.selector(this),this.__controllers.unshift(this.interaction=V.interaction(this,this.canvas,this.selector,i)),this.canvasManager=new Y,this.hitCanvasManager=new X,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))),j.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(G.RESTART):this.emitLeafer(G.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(G.STOP))}resize(t){const e=U.copyAttrs({},t,J);Object.keys(e).forEach((t=>this[t]=e[t]))}forceLayout(){this.__layout.checkUpdate(!0)}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=U.copyAttrs({},this.canvas,J);this.canvas.resize(t),this.__onResize(new $(t,e))}__onResize(t){this.emitEvent(t),U.copyAttrs(this.__,t,J),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,e){this.zoomLayer=t,this.moveLayer=e||t}__checkAutoLayout(t){t.width&&t.height||(this.autoLayout=new q(t),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){this.canvas&&(J.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&&J.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const s=U.copyAttrs({},this.canvas,J);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(G.BEFORE_READY),this.emitLeafer(G.READY),this.emitLeafer(G.AFTER_READY),K.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(G.VIEW_READY),K.run(this.__viewReadyWait))}__onRenderEnd(t){this.viewReady||this.__onViewReady();const e=this.__checkViewCompleted();e&&this.__onViewCompleted(),this.viewCompleted=e,K.run(this.__nextRenderWait)}__checkViewCompleted(){return this.viewReady&&!this.watcher.changed&&Z.isComplete}__onViewCompleted(){this.viewCompleted||(this.emitLeafer(G.VIEW_COMPLETED),K.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.checkUpdate()}emitLeafer(t){this.emitEvent(new G(t,this))}__listenEvents(){const t=Q.start("FirstCreate "+this.innerName);this.once(G.START,(()=>Q.end(t))),this.once(tt.END,(()=>this.__onReady())),this.once(et.START,(()=>this.__onCreated())),this.__eventIds.push(this.on_(st.DATA,this.__onWatchData,this),this.on_(et.END,this.__onRenderEnd,this),this.on_(tt.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 G(G.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((()=>{Z.clearRecycled()}),100)}catch(t){Ce.error(t)}}))}};rt([_(class extends wt{})],Ae.prototype,"__",void 0),rt([g()],Ae.prototype,"pixelRatio",void 0),Ae=rt([F()],Ae);let Be=class extends Ae{get __tag(){return"App"}get isApp(){return!0}__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_(it.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>{t.start()}))}stop(){this.children.forEach((t=>{t.stop()})),super.stop()}addLeafer(t){const e=new Ae(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.checkUpdate()}))}__getChildConfig(t){let e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&U.assign(e,t),this.autoLayout&&U.copyAttrs(e,this,J),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once(tt.END,(()=>this.__onReady())),t.once(et.START,(()=>this.__onCreated())),t.once(et.END,(t=>this.__onRenderEnd(t))),this.realCanvas&&this.__eventIds.push(t.on_(et.END,this.__onChildRenderEnd,this))}};Be=rt([F()],Be);export{pt as Animate,Be as App,Vt as Box,fe as Canvas,ct as ColorConvert,_t as Effect,Xt as Ellipse,ut as Export,Nt as Frame,Lt as Group,ge as Image,Ae as Leafer,ht as LeaferTypeCreator,ve as Line,dt as Paint,Se as Path,be as Pen,te as Polygon,Tt as Rect,Pt as RectRender,he as Star,xe as Text,lt as TextConvert,Ft as UI,At as UIBounds,Bt as UIHit,Et as UIRender,bt as effectType,Ct as resizeType};
|
|
1
|
+
import{MoveEvent as t,LeafHelper as e,ZoomEvent as s,Debug as i,LeafData as r,PathConvert as o,defineLeafAttr as a,OneRadian as h,Platform as n,dataProcessor as _,dataType as d,surfaceType as p,opacityType as l,maskType as c,eraserType as u,sortType as y,positionType as v,boundsType as g,scaleType as f,rotationType as w,hitType as m,strokeType as R,cursorType as x,pathType as k,rewrite as S,PathDrawer as b,useModule as C,rewriteAble as A,Leaf as B,PathCorner as E,UICreator as P,Branch as F,registerUI as D,affectRenderBoundsType as L,BoundsHelper as T,PathCommandDataHelper as M,PathBounds as z,affectStrokeBoundsType as W,PointHelper as I,ImageEvent as O,Creator as V,Matrix as N,PathCreator as H,DataHelper as U,CanvasManager as Y,HitCanvasManager as X,PluginManager as j,LeaferEvent as G,canvasSizeAttrs as J,ResizeEvent as $,AutoBounds as q,WaitHelper as K,ImageManager as Z,Run as Q,LayoutEvent as tt,RenderEvent as et,WatchEvent as st,PropertyEvent as it}from"@leafer/core";export*from"@leafer/core";function rt(t,e,s,i){var r,o=arguments.length,a=o<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--)(r=t[h])&&(a=(o<3?r(a):o>3?r(e,s,a):r(e,s))||a);return o>3&&a&&Object.defineProperty(e,s,a),a}function ot(t){const{config:e}=t;e.move.dragOut=!1}"function"==typeof SuppressedError&&SuppressedError;const at=i.get("LeaferTypeCreator"),ht={list:{},register(t,e){nt[t]?at.repeat(t):nt[t]=e},run(t,e){const s=ht.list[t];s?s(e):at.error("no",t)}},{list:nt}=ht;ht.register("draw",ot),ht.register("user",ot),ht.register("design",(function(i){i.isApp||i.__eventIds.push(i.on_(t.BEFORE_MOVE,(t=>{e.moveWorld(i.moveLayer,t.moveX,t.moveY)})),i.on_(s.BEFORE_ZOOM,(t=>{const{scaleX:s}=i.zoomLayer.__,{min:r,max:o}=i.config.zoom;let{scale:a}=t;a*Math.abs(s)<r?a=r/s:a*Math.abs(s)>o&&(a=o/s),1!==a&&e.zoomOfWorld(i.zoomLayer,t,a)})))}));const _t={},dt={},pt={},lt={},ct={},ut={},yt={},vt=i.get("UIData");class gt extends r{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,vt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,vt.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=yt)):(this.__isFills&&(this.__removeInput("fill"),dt.recycleImage(this,"fill"),this.__isFills=!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=yt)):(this.__isStrokes&&(this.__removeInput("stroke"),dt.recycleImage(this,"stroke"),this.__isStrokes=!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 ft={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class wt extends gt{}class mt extends wt{get __boxStroke(){return!0}}class Rt extends gt{get __boxStroke(){return!0}}const{parse:xt}=o;const kt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class St extends Rt{}function bt(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 Ct(t){return(e,s)=>{a(e,s,t,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}const At={__updateStrokeSpread(){let t=0,e=0;const{stroke:s,hitStroke:i,strokeAlign:r,strokeWidth:o}=this.__;if((s||"all"===i)&&o&&"inside"!==r&&(e=t="center"===r?o/2:o,!this.__.__boxStroke)){const{miterLimit:e,strokeCap:s}=this.__,i="Line"!==this.__tag?1/Math.sin(e*h/2)*Math.sqrt(o)-t:0,r="none"===s?0:o;t+=Math.max(i,r)}return this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:s,blur:i,backgroundBlur:r}=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 o=t=Math.ceil(t);return s&&s.forEach((t=>{o=Math.max(o,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),r&&(o=Math.max(o,r)),this.__layout.renderShapeSpread=o,t}},Bt={__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"===n.name&&this.__drawHitPath(e);const{fill:s,hitFill:i,windingRule:r}=this.__,o=s&&"path"===i||"all"===i,a=e.hitFill(t,r);if(o&&a)return!0;const{stroke:h,hitStroke:_,strokeWidth:d,strokeAlign:p}=this.__,l=h&&"path"===_||"all"===_,c=2*t.radiusX;let u=c;if(l)switch(p){case"inside":if(u+=2*d,!o&&a&&e.hitStroke(t,u))return!0;u=c;break;case"center":u+=d;break;case"outside":if(u+=2*d,!o){if(!a&&e.hitStroke(t,u))return!0;u=c}}return!!u&&e.hitStroke(t,u)}},Et={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:s,blur:i,backgroundBlur:r}=this.__;t.__useEffect=!!(e||s||i||r)}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:r}=this.__;this.__drawRenderPath(t),s&&dt.fill(this,t,s),r&&this.__drawAfterFill(t,e),i&&dt.stroke(this,t,i)},__draw(t,e){if(this.__.__complex){const{fill:s,stroke:i,__drawAfterFill:r}=this.__;if(this.__drawRenderPath(t),this.__.__useEffect){const o=dt.shape(this,t,e),{shadow:a,innerShadow:h}=this.__;a&&_t.shadow(this,t,o,e),s&&(this.__.__isFills?dt.fills(this,t,s):dt.fill(this,t,s)),r&&this.__drawAfterFill(t,e),h&&_t.innerShadow(this,t,o,e),i&&(this.__.__isStrokes?dt.strokes(this,t,i):dt.stroke(this,t,i)),o.worldCanvas&&o.worldCanvas.recycle(),o.canvas.recycle()}else s&&(this.__.__isFills?dt.fills(this,t,s):dt.fill(this,t,s)),r&&this.__drawAfterFill(t,e),i&&(this.__.__isStrokes?dt.strokes(this,t,i):dt.stroke(this,t,i))}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&&dt.fill(this,t,"#000000"),i&&dt.stroke(this,t,"#000000")}},Pt={__drawFast(t,e){const{width:s,height:i,fill:r,stroke:o,__drawAfterFill:a}=this.__;if(r&&(t.fillStyle=r,t.fillRect(0,0,s,i)),a&&this.__drawAfterFill(t,e),o){const{strokeAlign:e,strokeWidth:r}=this.__;t.setStroke(o,r,this.__);const a=r/2;switch(e){case"center":t.strokeRect(0,0,s,i);break;case"inside":t.strokeRect(a,a,s-r,i-r);break;case"outside":t.strokeRect(-a,-a,s+r,i+r)}}}};var Ft;let Dt=Ft=class extends B{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)}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}getPath(t){const e=this.__.path;return e?t?o.toCanvasData(e,!0):e:[]}getPathString(t){return o.stringify(this.getPath(t))}__onUpdateSize(){if(this.__.__input){const{fill:t,stroke:e}=this.__.__input;t&&dt.compute(this,"fill"),e&&dt.compute(this,"stroke")}}__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){}export(t,e){return ut.export(this,t,e)}clone(){return Ft.one(this.toJSON())}static one(t,e,s,i,r){return P.get(t.tag||this.prototype.__tag,t,e,s,i,r)}destroy(){this.fill=this.stroke=null,super.destroy()}};rt([_(gt)],Dt.prototype,"__",void 0),rt([d("")],Dt.prototype,"id",void 0),rt([d("")],Dt.prototype,"name",void 0),rt([d("")],Dt.prototype,"className",void 0),rt([p("pass-through")],Dt.prototype,"blendMode",void 0),rt([l(1)],Dt.prototype,"opacity",void 0),rt([l(!0)],Dt.prototype,"visible",void 0),rt([c(!1)],Dt.prototype,"isMask",void 0),rt([u(!1)],Dt.prototype,"isEraser",void 0),rt([y(0)],Dt.prototype,"zIndex",void 0),rt([d()],Dt.prototype,"locked",void 0),rt([v(0)],Dt.prototype,"x",void 0),rt([v(0)],Dt.prototype,"y",void 0),rt([g(100)],Dt.prototype,"width",void 0),rt([g(100)],Dt.prototype,"height",void 0),rt([f(1)],Dt.prototype,"scaleX",void 0),rt([f(1)],Dt.prototype,"scaleY",void 0),rt([w(0)],Dt.prototype,"rotation",void 0),rt([w(0)],Dt.prototype,"skewX",void 0),rt([w(0)],Dt.prototype,"skewY",void 0),rt([v()],Dt.prototype,"around",void 0),rt([d(!1)],Dt.prototype,"draggable",void 0),rt([m(!0)],Dt.prototype,"hittable",void 0),rt([m("path")],Dt.prototype,"hitFill",void 0),rt([R("path")],Dt.prototype,"hitStroke",void 0),rt([m(!0)],Dt.prototype,"hitChildren",void 0),rt([m(!0)],Dt.prototype,"hitSelf",void 0),rt([m()],Dt.prototype,"hitRadius",void 0),rt([x("default")],Dt.prototype,"cursor",void 0),rt([p()],Dt.prototype,"fill",void 0),rt([R()],Dt.prototype,"stroke",void 0),rt([R("inside")],Dt.prototype,"strokeAlign",void 0),rt([R(1)],Dt.prototype,"strokeWidth",void 0),rt([R("none")],Dt.prototype,"strokeCap",void 0),rt([R("miter")],Dt.prototype,"strokeJoin",void 0),rt([R()],Dt.prototype,"dashPattern",void 0),rt([R()],Dt.prototype,"dashOffset",void 0),rt([R(10)],Dt.prototype,"miterLimit",void 0),rt([k()],Dt.prototype,"cornerRadius",void 0),rt([k()],Dt.prototype,"cornerSmoothing",void 0),rt([bt()],Dt.prototype,"shadow",void 0),rt([bt()],Dt.prototype,"innerShadow",void 0),rt([bt()],Dt.prototype,"blur",void 0),rt([bt()],Dt.prototype,"backgroundBlur",void 0),rt([bt()],Dt.prototype,"grayscale",void 0),rt([S(b.drawPathByData)],Dt.prototype,"__drawPathByData",null),Dt=Ft=rt([C(At),C(Bt),C(Et),A()],Dt);let Lt=class extends Dt{get __tag(){return"Group"}get resizeable(){return!1}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.__setBranch(),super.set(t),e.forEach((t=>{s=P.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}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){}};rt([_(wt)],Lt.prototype,"__",void 0),Lt=rt([C(F),D()],Lt);let Tt=class extends Dt{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){const{width:s,height:i,cornerRadius:r}=this.__;r?t.roundRect(0,0,s,i,r):t.rect(0,0,s,i)}};rt([_(Rt)],Tt.prototype,"__",void 0),Tt=rt([C(Pt),D()],Tt);const Mt=Tt.prototype,zt=Lt.prototype,Wt={},{copy:It,add:Ot}=T;let Vt=class extends Lt{get __tag(){return"Box"}get resizeable(){return!0}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderChanged||this.__layout.renderChange()}__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}__updateBoxBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;It(Wt,t),super.__updateRenderBounds(),Ot(t,Wt)}}__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)}};rt([_(mt)],Vt.prototype,"__",void 0),rt([L("show")],Vt.prototype,"overflow",void 0),rt([S(Mt.__updateStrokeSpread)],Vt.prototype,"__updateStrokeSpread",null),rt([S(Mt.__updateRenderSpread)],Vt.prototype,"__updateRectRenderSpread",null),rt([S(Mt.__updateBoxBounds)],Vt.prototype,"__updateBoxBounds",null),rt([S(Mt.__updateStrokeBounds)],Vt.prototype,"__updateStrokeBounds",null),rt([S(Mt.__updateRenderBounds)],Vt.prototype,"__updateRectRenderBounds",null),rt([S(Mt.__updateChange)],Vt.prototype,"__updateRectChange",null),rt([S(Mt.__drawPathByData)],Vt.prototype,"__drawPathByData",null),rt([S(Mt.__render)],Vt.prototype,"__renderRect",null),rt([S(zt.__render)],Vt.prototype,"__renderGroup",null),Vt=rt([A(),D()],Vt);let Nt=class extends Vt{get __tag(){return"Frame"}constructor(t){super(t),this.__.fill||(this.__.fill="#FFFFFF")}};rt([_(class extends mt{})],Nt.prototype,"__",void 0),rt([L("hide")],Nt.prototype,"overflow",void 0),Nt=rt([D()],Nt);const{moveTo:Ht,closePath:Ut,ellipse:Yt}=M;let Xt=class extends Dt{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:s,startAngle:i,endAngle:r}=this.__,o=t/2,a=e/2,h=this.__.path=[];s?i||r?(s<1&&Yt(h,o,a,o*s,a*s,0,i,r,!1),Yt(h,o,a,o,a,0,r,i,!0),s<1&&Ut(h)):(s<1&&(Yt(h,o,a,o*s,a*s),Ht(h,t,a)),Yt(h,o,a,o,a,0,0,360,!0)):i||r?(Ht(h,o,a),Yt(h,o,a,o,a,0,i,r,!1),Ut(h)):Yt(h,o,a,o,a)}};rt([_(class extends gt{get __boxStroke(){return!0}})],Xt.prototype,"__",void 0),rt([k(0)],Xt.prototype,"innerRadius",void 0),rt([k(0)],Xt.prototype,"startAngle",void 0),rt([k(0)],Xt.prototype,"endAngle",void 0),Xt=rt([D()],Xt);const{sin:jt,cos:Gt,PI:Jt}=Math,{moveTo:$t,lineTo:qt,closePath:Kt,drawPoints:Zt}=M,{toBounds:Qt}=z;let te=class extends Dt{get __tag(){return"Polygon"}get resizeable(){return!this.points}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Zt(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:i}=this.__,r=e/2,o=s/2;$t(t,r,0);for(let e=1;e<i;e++)qt(t,r+r*jt(2*e*Jt/i),o-o*Gt(2*e*Jt/i))}Kt(t)}__updateRenderPath(){this.__.points&&this.__.curve?Zt(this.__.__pathForRender=[],this.__.points,this.__.curve,!0):super.__updateRenderPath()}__updateBoxBounds(){this.__.points?(Qt(this.__.__pathForRender,this.__layout.boxBounds),this.__updateNaturalSize()):super.__updateBoxBounds()}};rt([_(class extends gt{})],te.prototype,"__",void 0),rt([k(3)],te.prototype,"sides",void 0),rt([k()],te.prototype,"points",void 0),rt([k(0)],te.prototype,"curve",void 0),te=rt([D()],te);const{sin:ee,cos:se,PI:ie}=Math,{moveTo:re,lineTo:oe,closePath:ae}=M;let he=class extends Dt{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:s,innerRadius:i}=this.__,r=t/2,o=e/2,a=this.__.path=[];re(a,r,0);for(let t=1;t<2*s;t++)oe(a,r+(t%2==0?r:r*i)*ee(t*ie/s),o-(t%2==0?o:o*i)*se(t*ie/s));ae(a)}};rt([_(class extends gt{})],he.prototype,"__",void 0),rt([k(5)],he.prototype,"corners",void 0),rt([k(.382)],he.prototype,"innerRadius",void 0),he=rt([D()],he);const{moveTo:ne,lineTo:_e,drawPoints:de}=M,{rotate:pe,getAngle:le,getDistance:ce,defaultPoint:ue}=I,{toBounds:ye}=z;let ve=class extends Dt{get __tag(){return"Line"}get resizeable(){return!this.points}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=ce(ue,t),this.rotation=le(ue,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?de(t,this.__.points,!1):(ne(t,0,0),_e(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?de(this.__.__pathForRender=[],this.__.points,this.__.curve,!1):super.__updateRenderPath()}__updateBoxBounds(){this.points?(ye(this.__.__pathForRender,this.__layout.boxBounds),this.__updateNaturalSize()):super.__updateBoxBounds()}};rt([_(class extends gt{})],ve.prototype,"__",void 0),rt([W("center")],ve.prototype,"strokeAlign",void 0),rt([g(0)],ve.prototype,"height",void 0),rt([k()],ve.prototype,"points",void 0),rt([k(0)],ve.prototype,"curve",void 0),ve=rt([D()],ve);let ge=class extends Tt{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(O.LOADED,(t=>this.image=t.image))),super.__updateBoxBounds()}destroy(){this.image=null,super.destroy()}};rt([_(St)],ge.prototype,"__",void 0),rt([g("")],ge.prototype,"url",void 0),ge=rt([D()],ge);let fe=class extends Tt{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=V.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(t,e,s,i){t.__layout.checkUpdate();const r=new N(t.__world);r.invert();const o=new N;e&&o.translate(e.x,e.y),s&&("number"==typeof s?o.scale(s):o.scale(s.x,s.y)),i&&o.rotate(i),r.preMultiply(o),t.__render(this.canvas,{matrix:r}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:i,height:r}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,i,r),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,i,r)}__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()}};rt([_(St)],fe.prototype,"__",void 0),rt([Ct(100)],fe.prototype,"width",void 0),rt([Ct(100)],fe.prototype,"height",void 0),rt([Ct(n.devicePixelRatio)],fe.prototype,"pixelRatio",void 0),rt([Ct(!0)],fe.prototype,"smooth",void 0),rt([m("all")],fe.prototype,"hitFill",void 0),fe=rt([D()],fe);const{copyAndSpread:we,includes:me,spread:Re}=T;let xe=class extends Dt{get __tag(){return"Text"}get textDrawData(){return this.__layout.checkUpdate(),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:r,height:o}=this.__layout.boxBounds;t.rect(s,i,r,o)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=lt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:s,letterSpacing:i,fontFamily:r,fontSize:o,fontWeight:a,italic:h,textCase:n}=t;t.__lineHeight=ft.number(s,o),t.__letterSpacing=ft.number(i,o),t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*o)/2,t.__font=`${h?"italic ":""}${"small-caps"===n?"small-caps ":""}${"normal"!==a?a+" ":""}${o}px ${r}`,this.__updateTextDrawData();const{bounds:_}=t.__textDrawData,d=e.boxBounds;t.__lineHeight<o&&Re(_,o/2);const p=t.__getInput("width"),l=t.__getInput("height");p&&l?super.__updateBoxBounds():(d.x=p?0:_.x,d.y=l?0:_.y,d.width=p||_.width,d.height=l||_.height,this.__updateNaturalSize());const c=me(d,_)?d:_;c!==e.contentBounds&&(e.contentBounds=c,e.renderChanged=!0)}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){we(this.__layout.renderBounds,this.__layout.contentBounds,this.__layout.renderSpread)}};rt([_(class extends gt{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=kt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}})],xe.prototype,"__",void 0),rt([g(0)],xe.prototype,"width",void 0),rt([g(0)],xe.prototype,"height",void 0),rt([g(0)],xe.prototype,"padding",void 0),rt([W("outside")],xe.prototype,"strokeAlign",void 0),rt([g("")],xe.prototype,"text",void 0),rt([g("L")],xe.prototype,"fontFamily",void 0),rt([g(12)],xe.prototype,"fontSize",void 0),rt([g("normal")],xe.prototype,"fontWeight",void 0),rt([g(!1)],xe.prototype,"italic",void 0),rt([g("none")],xe.prototype,"textCase",void 0),rt([g("none")],xe.prototype,"textDecoration",void 0),rt([g(0)],xe.prototype,"letterSpacing",void 0),rt([g({type:"percent",value:150})],xe.prototype,"lineHeight",void 0),rt([g(0)],xe.prototype,"paraIndent",void 0),rt([g(0)],xe.prototype,"paraSpacing",void 0),rt([g("left")],xe.prototype,"textAlign",void 0),rt([g("top")],xe.prototype,"verticalAlign",void 0),rt([g("show")],xe.prototype,"textOverflow",void 0),xe=rt([D()],xe);const{toBounds:ke}=z;let Se=class extends Dt{get __tag(){return"Path"}get resizeable(){return!1}constructor(t){super(t)}__updateBoxBounds(){ke(this.__.path,this.__layout.boxBounds),this.__updateNaturalSize()}};rt([_(class extends gt{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=xt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}})],Se.prototype,"__",void 0),rt([k()],Se.prototype,"path",void 0),rt([k()],Se.prototype,"windingRule",void 0),rt([W("center")],Se.prototype,"strokeAlign",void 0),Se=rt([D()],Se);let be=class extends Lt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Se(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,r,o){return this}quadraticCurveTo(t,e,s,i){return this}closePath(){return this}rect(t,e,s,i){return this}roundRect(t,e,s,i,r){return this}ellipse(t,e,s,i,r,o,a,h){return this}arc(t,e,s,i,r,o){return this}arcTo(t,e,s,i,r){return this}drawEllipse(t,e,s,i,r,o,a,h){return this}drawArc(t,e,s,i,r,o){return this}drawPoints(t,e,s){return this}paint(){this.pathElement.forceUpdate("path")}clear(){this.removeAll(!0)}};rt([_(class extends wt{})],be.prototype,"__",void 0),be=rt([C(H,["beginPath"]),D()],be);const Ce=i.get("Leafer");let Ae=class extends Lt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}constructor(t,e){super(e),this.zoomLayer=this,this.moveLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,dragOut:!0,autoDistance:2}},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&&U.assign(this.config,t);const{config:i}=this;ht.run(i.type,this),this.canvas=V.canvas(i),this.__controllers.push(this.renderer=V.renderer(this,this.canvas,i),this.watcher=V.watcher(this,i),this.layouter=V.layouter(this,i)),this.isApp&&this.__setApp(),this.__checkAutoLayout(i),this.view=this.canvas.view,e?(this.__bindApp(e),s=e.running):(this.selector=V.selector(this),this.__controllers.unshift(this.interaction=V.interaction(this,this.canvas,this.selector,i)),this.canvasManager=new Y,this.hitCanvasManager=new X,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))),j.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(G.RESTART):this.emitLeafer(G.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(G.STOP))}resize(t){const e=U.copyAttrs({},t,J);Object.keys(e).forEach((t=>this[t]=e[t]))}forceLayout(){this.__layout.checkUpdate(!0)}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=U.copyAttrs({},this.canvas,J);this.canvas.resize(t),this.__onResize(new $(t,e))}__onResize(t){this.emitEvent(t),U.copyAttrs(this.__,t,J),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,e){this.zoomLayer=t,this.moveLayer=e||t}__checkAutoLayout(t){t.width&&t.height||(this.autoLayout=new q(t),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){this.canvas&&(J.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&&J.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const s=U.copyAttrs({},this.canvas,J);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(G.BEFORE_READY),this.emitLeafer(G.READY),this.emitLeafer(G.AFTER_READY),K.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(G.VIEW_READY),K.run(this.__viewReadyWait))}__onRenderEnd(t){this.viewReady||this.__onViewReady();const e=this.__checkViewCompleted();e&&this.__onViewCompleted(),this.viewCompleted=e,K.run(this.__nextRenderWait)}__checkViewCompleted(){return this.viewReady&&!this.watcher.changed&&Z.isComplete}__onViewCompleted(){this.viewCompleted||(this.emitLeafer(G.VIEW_COMPLETED),K.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.checkUpdate()}emitLeafer(t){this.emitEvent(new G(t,this))}__listenEvents(){const t=Q.start("FirstCreate "+this.innerName);this.once(G.START,(()=>Q.end(t))),this.once(tt.END,(()=>this.__onReady())),this.once(et.START,(()=>this.__onCreated())),this.__eventIds.push(this.on_(st.DATA,this.__onWatchData,this),this.on_(et.END,this.__onRenderEnd,this),this.on_(tt.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 G(G.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((()=>{Z.clearRecycled()}),100)}catch(t){Ce.error(t)}}))}};rt([_(class extends wt{})],Ae.prototype,"__",void 0),rt([g()],Ae.prototype,"pixelRatio",void 0),Ae=rt([D()],Ae);let Be=class extends Ae{get __tag(){return"App"}get isApp(){return!0}__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_(it.CHANGE,this.__onPropertyChange,this))}start(){super.start(),this.children.forEach((t=>{t.start()}))}stop(){this.children.forEach((t=>{t.stop()})),super.stop()}addLeafer(t){const e=new Ae(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.checkUpdate()}))}__getChildConfig(t){let e=Object.assign({},this.config);return e.hittable=e.realCanvas=void 0,t&&U.assign(e,t),this.autoLayout&&U.copyAttrs(e,this,J),e.view=this.realCanvas?void 0:this.view,e.fill=void 0,e}__listenChildEvents(t){t.once(tt.END,(()=>this.__onReady())),t.once(et.START,(()=>this.__onCreated())),t.once(et.END,(t=>this.__onRenderEnd(t))),this.realCanvas&&this.__eventIds.push(t.on_(et.END,this.__onChildRenderEnd,this))}};Be=rt([D()],Be);export{pt as Animate,Be as App,Vt as Box,fe as Canvas,ct as ColorConvert,_t as Effect,Xt as Ellipse,ut as Export,Nt as Frame,Lt as Group,ge as Image,Ae as Leafer,ht as LeaferTypeCreator,ve as Line,dt as Paint,Se as Path,be as Pen,te as Polygon,Tt as Rect,Pt as RectRender,he as Star,xe as Text,lt as TextConvert,Dt as UI,At as UIBounds,Bt as UIHit,Et as UIRender,bt as effectType,Ct 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.moveLayer,s.moveX,s.moveY)})),e.on_(t.ZoomEvent.BEFORE_ZOOM,(s=>{const{scaleX:r}=e.zoomLayer.__,{min:o,max:i}=e.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{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(this,"fill"),this.__isFills=!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(this,"stroke"),this.__isStrokes=!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 c={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class u extends l{}class y extends u{get __boxStroke(){return!0}}class x extends l{get __boxStroke(){return!0}}const{parse:v}=t.PathConvert;const g={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class f extends x{}function w(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 m(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}const R={__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}},T={__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,c=2*e.radiusX;let u=c;if(l)switch(d){case"inside":if(u+=2*_,!a&&n&&s.hitStroke(e,u))return!0;u=c;break;case"center":u+=_;break;case"outside":if(u+=2*_,!a){if(!n&&s.hitStroke(e,u))return!0;u=c}}return!!u&&s.hitStroke(e,u)}},b={__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(this,t,s),o&&this.__drawAfterFill(t,e),r&&n.stroke(this,t,r)},__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(this,t,s):n.fill(this,t,s)),o&&this.__drawAfterFill(t,e),p&&a.innerShadow(this,t,i,e),r&&(this.__.__isStrokes?n.strokes(this,t,r):n.stroke(this,t,r)),i.worldCanvas&&i.worldCanvas.recycle(),i.canvas.recycle()}else s&&(this.__.__isFills?n.fills(this,t,s):n.fill(this,t,s)),o&&this.__drawAfterFill(t,e),r&&(this.__.__isStrokes?n.strokes(this,t,r):n.stroke(this,t,r))}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&&n.fill(this,t,"#000000"),r&&n.stroke(this,t,"#000000")}},C={__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 P;exports.UI=P=class extends t.Leaf{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)}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}getPath(e){const s=this.__.path;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(this,"fill"),e&&n.compute(this,"stroke")}}__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){}export(t,e){return p.export(this,t,e)}clone(){return P.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.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.dataType()],exports.UI.prototype,"locked",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.positionType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",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(!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("default")],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()],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([w()],exports.UI.prototype,"shadow",void 0),e([w()],exports.UI.prototype,"innerShadow",void 0),e([w()],exports.UI.prototype,"blur",void 0),e([w()],exports.UI.prototype,"backgroundBlur",void 0),e([w()],exports.UI.prototype,"grayscale",void 0),e([t.rewrite(t.PathDrawer.drawPathByData)],exports.UI.prototype,"__drawPathByData",null),exports.UI=P=e([t.useModule(R),t.useModule(T),t.useModule(b),t.rewriteAble()],exports.UI),exports.Group=class extends exports.UI{get __tag(){return"Group"}get resizeable(){return!1}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.__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}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(u)],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){const{width:s,height:r,cornerRadius:o}=this.__;o?t.roundRect(0,0,s,r,o):t.rect(0,0,s,r)}},e([t.dataProcessor(x)],exports.Rect.prototype,"__",void 0),exports.Rect=e([t.useModule(C),t.registerUI()],exports.Rect);const k=exports.Rect.prototype,I=exports.Group.prototype,S={},{copy:B,add:E}=t.BoundsHelper;exports.Box=class extends exports.Group{get __tag(){return"Box"}get resizeable(){return!0}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderChanged||this.__layout.renderChange()}__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}__updateBoxBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;B(S,t),super.__updateRenderBounds(),E(t,S)}}__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(k.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(k.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(k.__updateBoxBounds)],exports.Box.prototype,"__updateBoxBounds",null),e([t.rewrite(k.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(k.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(k.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(k.__drawPathByData)],exports.Box.prototype,"__drawPathByData",null),e([t.rewrite(k.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(I.__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.__.fill||(this.__.fill="#FFFFFF")}},e([t.dataProcessor(class extends y{})],exports.Frame.prototype,"__",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo:A,closePath:U,ellipse:L}=t.PathCommandDataHelper;exports.Ellipse=class extends exports.UI{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:s,startAngle:r,endAngle:o}=this.__,i=t/2,a=e/2,n=this.__.path=[];s?r||o?(s<1&&L(n,i,a,i*s,a*s,0,r,o,!1),L(n,i,a,i,a,0,o,r,!0),s<1&&U(n)):(s<1&&(L(n,i,a,i*s,a*s),A(n,t,a)),L(n,i,a,i,a,0,0,360,!0)):r||o?(A(n,i,a),L(n,i,a,i,a,0,r,o,!1),U(n)):L(n,i,a,i,a)}},e([t.dataProcessor(class extends l{get __boxStroke(){return!0}})],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{sin:D,cos:F,PI:M}=Math,{moveTo:z,lineTo:W,closePath:H,drawPoints:O}=t.PathCommandDataHelper,{toBounds:V}=t.PathBounds;exports.Polygon=class extends exports.UI{get __tag(){return"Polygon"}get resizeable(){return!this.points}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)O(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:r}=this.__,o=e/2,i=s/2;z(t,o,0);for(let e=1;e<r;e++)W(t,o+o*D(2*e*M/r),i-i*F(2*e*M/r))}H(t)}__updateRenderPath(){this.__.points&&this.__.curve?(O(this.__.__pathForRender=[],this.__.points,this.__.curve,!0),this.__updateNaturalSize()):super.__updateRenderPath()}__updateBoxBounds(){this.__.points?V(this.__.path,this.__layout.boxBounds):super.__updateBoxBounds()}},e([t.dataProcessor(class extends l{})],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),exports.Polygon=e([t.registerUI()],exports.Polygon);const{sin:N,cos:G,PI:j}=Math,{moveTo:Y,lineTo:X,closePath:J}=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=[];Y(a,o,0);for(let t=1;t<2*s;t++)X(a,o+(t%2==0?o:o*r)*N(t*j/s),i-(t%2==0?i:i*r)*G(t*j/s));J(a)}},e([t.dataProcessor(class extends l{})],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);const{moveTo:$,lineTo:q,drawPoints:Z}=t.PathCommandDataHelper,{rotate:K,getAngle:Q,getDistance:tt,defaultPoint:et}=t.PointHelper,{toBounds:st}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get resizeable(){return!this.points}get toPoint(){const{width:t,rotation:e}=this.__,s={x:0,y:0};return t&&(s.x=t),e&&K(s,e),s}set toPoint(t){this.width=tt(et,t),this.rotation=Q(et,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?Z(t,this.__.points,!1):($(t,0,0),q(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?Z(this.__.__pathForRender=[],this.__.points,this.__.curve,!1):super.__updateRenderPath()}__updateBoxBounds(){this.points?(st(this.__.path,this.__layout.boxBounds),this.__updateNaturalSize()):super.__updateBoxBounds()}},e([t.dataProcessor(class extends l{})],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),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(f)],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.checkUpdate();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.preMultiply(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(f)],exports.Canvas.prototype,"__",void 0),e([m(100)],exports.Canvas.prototype,"width",void 0),e([m(100)],exports.Canvas.prototype,"height",void 0),e([m(t.Platform.devicePixelRatio)],exports.Canvas.prototype,"pixelRatio",void 0),e([m(!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:rt,includes:ot,spread:it}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get textDrawData(){return this.__layout.checkUpdate(),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 t=this.__,e=this.__layout,{lineHeight:s,letterSpacing:r,fontFamily:o,fontSize:i,fontWeight:a,italic:n,textCase:h}=t;t.__lineHeight=c.number(s,i),t.__letterSpacing=c.number(r,i),t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*i)/2,t.__font=`${n?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==a?a+" ":""}${i}px ${o}`,this.__updateTextDrawData();const{bounds:p}=t.__textDrawData,_=e.boxBounds;t.__lineHeight<i&&it(p,i/2);const d=t.__getInput("width"),l=t.__getInput("height");d&&l?super.__updateBoxBounds():(_.x=d?0:p.x,_.y=l?0:p.y,_.width=d||p.width,_.height=l||p.height,this.__updateNaturalSize());const u=ot(_,p)?_:p;u!==e.contentBounds&&(e.contentBounds=u,e.renderChanged=!0)}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){rt(this.__layout.renderBounds,this.__layout.contentBounds,this.__layout.renderSpread)}},e([t.dataProcessor(class extends l{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=g[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}})],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.affectStrokeBoundsType("outside")],exports.Text.prototype,"strokeAlign",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("show")],exports.Text.prototype,"textOverflow",void 0),exports.Text=e([t.registerUI()],exports.Text);const{toBounds:at}=t.PathBounds;exports.Path=class extends exports.UI{get __tag(){return"Path"}get resizeable(){return!1}constructor(t){super(t)}__updateBoxBounds(){at(this.__.path,this.__layout.boxBounds),this.__updateNaturalSize()}},e([t.dataProcessor(class extends l{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=v(t)):(this.__input&&this.__removeInput("path"),this._path=t)}})],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(class extends u{})],exports.Pen.prototype,"__",void 0),exports.Pen=e([t.useModule(t.PathCreator,["beginPath"]),t.registerUI()],exports.Pen);const nt=t.Debug.get("Leafer");exports.Leafer=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}constructor(t,e){super(e),this.zoomLayer=this,this.moveLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,dragOut:!0,autoDistance:2}},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))}resize(e){const s=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(s).forEach((t=>this[t]=s[t]))}forceLayout(){this.__layout.checkUpdate(!0)}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,e){this.zoomLayer=t,this.moveLayer=e||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.checkUpdate()}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){nt.error(t)}}))}},e([t.dataProcessor(class extends u{})],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}__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()}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.checkUpdate()}))}__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.ColorConvert={},exports.Effect=a,exports.Export=p,exports.LeaferTypeCreator=o,exports.Paint=n,exports.RectRender=C,exports.TextConvert=h,exports.UIBounds=R,exports.UIHit=T,exports.UIRender=b,exports.effectType=w,exports.resizeType=m,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.moveLayer,s.moveX,s.moveY)})),e.on_(t.ZoomEvent.BEFORE_ZOOM,(s=>{const{scaleX:r}=e.zoomLayer.__,{min:o,max:i}=e.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{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(this,"fill"),this.__isFills=!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(this,"stroke"),this.__isStrokes=!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 c={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class u extends l{}class y extends u{get __boxStroke(){return!0}}class x extends l{get __boxStroke(){return!0}}const{parse:v}=t.PathConvert;const g={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class f extends x{}function w(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 m(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}const R={__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}},T={__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,c=2*e.radiusX;let u=c;if(l)switch(d){case"inside":if(u+=2*_,!a&&n&&s.hitStroke(e,u))return!0;u=c;break;case"center":u+=_;break;case"outside":if(u+=2*_,!a){if(!n&&s.hitStroke(e,u))return!0;u=c}}return!!u&&s.hitStroke(e,u)}},b={__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(this,t,s),o&&this.__drawAfterFill(t,e),r&&n.stroke(this,t,r)},__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(this,t,s):n.fill(this,t,s)),o&&this.__drawAfterFill(t,e),p&&a.innerShadow(this,t,i,e),r&&(this.__.__isStrokes?n.strokes(this,t,r):n.stroke(this,t,r)),i.worldCanvas&&i.worldCanvas.recycle(),i.canvas.recycle()}else s&&(this.__.__isFills?n.fills(this,t,s):n.fill(this,t,s)),o&&this.__drawAfterFill(t,e),r&&(this.__.__isStrokes?n.strokes(this,t,r):n.stroke(this,t,r))}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&&n.fill(this,t,"#000000"),r&&n.stroke(this,t,"#000000")}},C={__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 P;exports.UI=P=class extends t.Leaf{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)}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}getPath(e){const s=this.__.path;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(this,"fill"),e&&n.compute(this,"stroke")}}__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){}export(t,e){return p.export(this,t,e)}clone(){return P.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.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.dataType()],exports.UI.prototype,"locked",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.positionType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",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(!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("default")],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()],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([w()],exports.UI.prototype,"shadow",void 0),e([w()],exports.UI.prototype,"innerShadow",void 0),e([w()],exports.UI.prototype,"blur",void 0),e([w()],exports.UI.prototype,"backgroundBlur",void 0),e([w()],exports.UI.prototype,"grayscale",void 0),e([t.rewrite(t.PathDrawer.drawPathByData)],exports.UI.prototype,"__drawPathByData",null),exports.UI=P=e([t.useModule(R),t.useModule(T),t.useModule(b),t.rewriteAble()],exports.UI),exports.Group=class extends exports.UI{get __tag(){return"Group"}get resizeable(){return!1}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.__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}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(u)],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){const{width:s,height:r,cornerRadius:o}=this.__;o?t.roundRect(0,0,s,r,o):t.rect(0,0,s,r)}},e([t.dataProcessor(x)],exports.Rect.prototype,"__",void 0),exports.Rect=e([t.useModule(C),t.registerUI()],exports.Rect);const k=exports.Rect.prototype,I=exports.Group.prototype,S={},{copy:B,add:E}=t.BoundsHelper;exports.Box=class extends exports.Group{get __tag(){return"Box"}get resizeable(){return!0}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderChanged||this.__layout.renderChange()}__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}__updateBoxBounds(){}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;B(S,t),super.__updateRenderBounds(),E(t,S)}}__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(k.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(k.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(k.__updateBoxBounds)],exports.Box.prototype,"__updateBoxBounds",null),e([t.rewrite(k.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(k.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(k.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(k.__drawPathByData)],exports.Box.prototype,"__drawPathByData",null),e([t.rewrite(k.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(I.__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.__.fill||(this.__.fill="#FFFFFF")}},e([t.dataProcessor(class extends y{})],exports.Frame.prototype,"__",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo:A,closePath:U,ellipse:L}=t.PathCommandDataHelper;exports.Ellipse=class extends exports.UI{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:s,startAngle:r,endAngle:o}=this.__,i=t/2,a=e/2,n=this.__.path=[];s?r||o?(s<1&&L(n,i,a,i*s,a*s,0,r,o,!1),L(n,i,a,i,a,0,o,r,!0),s<1&&U(n)):(s<1&&(L(n,i,a,i*s,a*s),A(n,t,a)),L(n,i,a,i,a,0,0,360,!0)):r||o?(A(n,i,a),L(n,i,a,i,a,0,r,o,!1),U(n)):L(n,i,a,i,a)}},e([t.dataProcessor(class extends l{get __boxStroke(){return!0}})],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{sin:D,cos:F,PI:M}=Math,{moveTo:z,lineTo:W,closePath:H,drawPoints:O}=t.PathCommandDataHelper,{toBounds:V}=t.PathBounds;exports.Polygon=class extends exports.UI{get __tag(){return"Polygon"}get resizeable(){return!this.points}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)O(t,this.__.points,!1,!0);else{const{width:e,height:s,sides:r}=this.__,o=e/2,i=s/2;z(t,o,0);for(let e=1;e<r;e++)W(t,o+o*D(2*e*M/r),i-i*F(2*e*M/r))}H(t)}__updateRenderPath(){this.__.points&&this.__.curve?O(this.__.__pathForRender=[],this.__.points,this.__.curve,!0):super.__updateRenderPath()}__updateBoxBounds(){this.__.points?(V(this.__.__pathForRender,this.__layout.boxBounds),this.__updateNaturalSize()):super.__updateBoxBounds()}},e([t.dataProcessor(class extends l{})],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),exports.Polygon=e([t.registerUI()],exports.Polygon);const{sin:N,cos:G,PI:j}=Math,{moveTo:Y,lineTo:X,closePath:J}=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=[];Y(a,o,0);for(let t=1;t<2*s;t++)X(a,o+(t%2==0?o:o*r)*N(t*j/s),i-(t%2==0?i:i*r)*G(t*j/s));J(a)}},e([t.dataProcessor(class extends l{})],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);const{moveTo:$,lineTo:q,drawPoints:Z}=t.PathCommandDataHelper,{rotate:K,getAngle:Q,getDistance:tt,defaultPoint:et}=t.PointHelper,{toBounds:st}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get resizeable(){return!this.points}get toPoint(){const{width:t,rotation:e}=this.__,s={x:0,y:0};return t&&(s.x=t),e&&K(s,e),s}set toPoint(t){this.width=tt(et,t),this.rotation=Q(et,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?Z(t,this.__.points,!1):($(t,0,0),q(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?Z(this.__.__pathForRender=[],this.__.points,this.__.curve,!1):super.__updateRenderPath()}__updateBoxBounds(){this.points?(st(this.__.__pathForRender,this.__layout.boxBounds),this.__updateNaturalSize()):super.__updateBoxBounds()}},e([t.dataProcessor(class extends l{})],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),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(f)],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.checkUpdate();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.preMultiply(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(f)],exports.Canvas.prototype,"__",void 0),e([m(100)],exports.Canvas.prototype,"width",void 0),e([m(100)],exports.Canvas.prototype,"height",void 0),e([m(t.Platform.devicePixelRatio)],exports.Canvas.prototype,"pixelRatio",void 0),e([m(!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:rt,includes:ot,spread:it}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get textDrawData(){return this.__layout.checkUpdate(),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 t=this.__,e=this.__layout,{lineHeight:s,letterSpacing:r,fontFamily:o,fontSize:i,fontWeight:a,italic:n,textCase:h}=t;t.__lineHeight=c.number(s,i),t.__letterSpacing=c.number(r,i),t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*i)/2,t.__font=`${n?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==a?a+" ":""}${i}px ${o}`,this.__updateTextDrawData();const{bounds:p}=t.__textDrawData,_=e.boxBounds;t.__lineHeight<i&&it(p,i/2);const d=t.__getInput("width"),l=t.__getInput("height");d&&l?super.__updateBoxBounds():(_.x=d?0:p.x,_.y=l?0:p.y,_.width=d||p.width,_.height=l||p.height,this.__updateNaturalSize());const u=ot(_,p)?_:p;u!==e.contentBounds&&(e.contentBounds=u,e.renderChanged=!0)}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){rt(this.__layout.renderBounds,this.__layout.contentBounds,this.__layout.renderSpread)}},e([t.dataProcessor(class extends l{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=g[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}})],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.affectStrokeBoundsType("outside")],exports.Text.prototype,"strokeAlign",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("show")],exports.Text.prototype,"textOverflow",void 0),exports.Text=e([t.registerUI()],exports.Text);const{toBounds:at}=t.PathBounds;exports.Path=class extends exports.UI{get __tag(){return"Path"}get resizeable(){return!1}constructor(t){super(t)}__updateBoxBounds(){at(this.__.path,this.__layout.boxBounds),this.__updateNaturalSize()}},e([t.dataProcessor(class extends l{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=v(t)):(this.__input&&this.__removeInput("path"),this._path=t)}})],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(class extends u{})],exports.Pen.prototype,"__",void 0),exports.Pen=e([t.useModule(t.PathCreator,["beginPath"]),t.registerUI()],exports.Pen);const nt=t.Debug.get("Leafer");exports.Leafer=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}constructor(t,e){super(e),this.zoomLayer=this,this.moveLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,dragOut:!0,autoDistance:2}},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))}resize(e){const s=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(s).forEach((t=>this[t]=s[t]))}forceLayout(){this.__layout.checkUpdate(!0)}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,e){this.zoomLayer=t,this.moveLayer=e||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.checkUpdate()}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){nt.error(t)}}))}},e([t.dataProcessor(class extends u{})],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}__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()}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.checkUpdate()}))}__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.ColorConvert={},exports.Effect=a,exports.Export=p,exports.LeaferTypeCreator=o,exports.Paint=n,exports.RectRender=C,exports.TextConvert=h,exports.UIBounds=R,exports.UIHit=T,exports.UIRender=b,exports.effectType=w,exports.resizeType=m,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.3",
|
|
4
4
|
"description": "@leafer-ui/core",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"leaferjs"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@leafer/core": "1.0.0-rc.
|
|
32
|
-
"@leafer-ui/app": "1.0.0-rc.
|
|
33
|
-
"@leafer-ui/display": "1.0.0-rc.
|
|
34
|
-
"@leafer-ui/decorator": "1.0.0-rc.
|
|
35
|
-
"@leafer-ui/display-module": "1.0.0-rc.
|
|
36
|
-
"@leafer-ui/external": "1.0.0-rc.
|
|
37
|
-
"@leafer-ui/type": "1.0.0-rc.
|
|
31
|
+
"@leafer/core": "1.0.0-rc.3",
|
|
32
|
+
"@leafer-ui/app": "1.0.0-rc.3",
|
|
33
|
+
"@leafer-ui/display": "1.0.0-rc.3",
|
|
34
|
+
"@leafer-ui/decorator": "1.0.0-rc.3",
|
|
35
|
+
"@leafer-ui/display-module": "1.0.0-rc.3",
|
|
36
|
+
"@leafer-ui/external": "1.0.0-rc.3",
|
|
37
|
+
"@leafer-ui/type": "1.0.0-rc.3"
|
|
38
38
|
}
|
|
39
39
|
}
|