@leafer-ui/draw 1.0.0-rc.10

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.
@@ -0,0 +1 @@
1
+ import{defineLeafAttr as t,Debug as e,LeafData as i,PathConvert as s,OneRadian as o,dataProcessor as r,dataType as a,surfaceType as _,opacityType as h,sortType as n,maskType as d,eraserType as p,positionType as l,boundsType as u,scaleType as c,rotationType as y,autoLayoutType as v,hitType as g,strokeType as f,cursorType as w,pathType as x,rewrite as m,Leaf as R,PathDrawer as k,useModule as B,rewriteAble as S,PathCreator as b,PathCorner as P,UICreator as A,Branch as C,registerUI as F,ImageManager as D,DataHelper as E,Creator as L,CanvasManager as T,LeaferEvent as W,canvasSizeAttrs as I,Bounds as M,ResizeEvent as z,AutoBounds as O,WaitHelper as N,Run as H,LayoutEvent as V,RenderEvent as Y,WatchEvent as X,affectRenderBoundsType as j,BoundsHelper as U,Platform as G,PathCommandDataHelper as J,affectStrokeBoundsType as $,getPointData as K,PointHelper as q,PathBounds as Z,ImageEvent as Q,Matrix as tt,MathHelper as et}from"@leafer/core";export*from"@leafer/core";function it(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var _=t.length-1;_>=0;_--)(o=t[_])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}function st(e){return(i,s)=>{t(i,s,e,{set(t){this.__setAttr(s,t),t&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})}}function ot(e){return(i,s)=>{t(i,s,e,{set(t){this.__setAttr(s,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}"function"==typeof SuppressedError&&SuppressedError;const rt={},at={},_t={},ht={},nt={},dt={},pt={},lt={},ut=e.get("UIData");class ct extends i{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){let{scaleX:e}=this.__leaf.__world;return e<0&&(e=-e),e>1?t/e:t}return t}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoBounds(){return!this._width&&!this._height}setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,ut.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,ut.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=lt)):(this.__isFills&&(this.__removeInput("fill"),ht.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=lt)):(this.__isStrokes&&(this.__removeInput("stroke"),ht.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&_t.compute("fill",this.__leaf),e&&_t.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const yt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class vt extends ct{}class gt extends vt{get __boxStroke(){return!0}}class ft extends vt{}class wt extends gt{}class xt extends ct{}class mt extends xt{}class Rt extends ct{get __boxStroke(){return!0}}class kt extends ct{get __boxStroke(){return!0}}class Bt extends ct{}class St extends ct{}const{parse:bt}=s;class Pt extends ct{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=bt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}}class At extends vt{}const Ct={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Ft extends ct{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Ct[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Dt extends Rt{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}class Et extends Rt{}const Lt={__updateStrokeSpread(){let t=0,e=0;const{stroke:i,hitStroke:s,strokeAlign:r,strokeWidth:a}=this.__;if((i||"all"===s)&&a&&"inside"!==r&&(e=t="center"===r?a/2:a,!this.__.__boxStroke)){const{miterLimit:e,strokeCap:i}=this.__,s="Line"!==this.__tag?1/Math.sin(e*o/2)*Math.sqrt(a)-t:0,r="none"===i?0:a;t+=Math.max(s,r)}return this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;e&&e.forEach((e=>{t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur)})),s&&(t=Math.max(t,s));let r=t=Math.ceil(t);return i&&i.forEach((t=>{r=Math.max(r,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur)})),o&&(r=Math.max(r,o)),this.__layout.renderShapeSpread=r,t}},Tt={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;t.__useEffect=!!(e||i||s||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){const{fill:i,stroke:s,__drawAfterFill:o}=this.__;this.__drawRenderPath(t),i&&_t.fill(i,this,t),o&&this.__drawAfterFill(t,e),s&&_t.stroke(s,this,t)},__draw(t,e){if(this.__.__complex){const i=this.__;i.__needComputePaint&&i.__computePaint();const{fill:s,stroke:o,__drawAfterFill:r}=i;if(this.__drawRenderPath(t),i.__useEffect){const a=_t.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:_,innerShadow:h}=i;_&&dt.shadow(this,t,a),s&&(i.__isFills?_t.fills(s,this,t):_t.fill(s,this,t)),r&&this.__drawAfterFill(t,e),h&&dt.innerShadow(this,t,a),o&&(i.__isStrokes?_t.strokes(o,this,t):_t.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else s&&(i.__isFills?_t.fills(s,this,t):_t.fill(s,this,t)),r&&this.__drawAfterFill(t,e),o&&(i.__isStrokes?_t.strokes(o,this,t):_t.stroke(o,this,t))}else this.__drawFast(t,e)},__renderShape(t,e){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:i,stroke:s}=this.__;this.__drawRenderPath(t),i&&(this.__.__pixelFill?_t.fills(i,this,t):_t.fill("#000000",this,t)),s&&(this.__.__pixelStroke?_t.strokes(s,this,t):_t.stroke("#000000",this,t))}}},Wt={__drawFast(t,e){const{width:i,height:s,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,i,s)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:e,__strokeWidth:o}=this.__;if(!o)return;t.setStroke(r,o,this.__);const a=o/2;switch(e){case"center":t.strokeRect(0,0,i,s);break;case"inside":t.strokeRect(a,a,i-o,s-o);break;case"outside":t.strokeRect(-a,-a,i+o,s+o)}}}};var It;let Mt=It=class extends R{get app(){return this.leafer&&this.leafer.app}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}createProxyData(){}find(t,e){}findOne(t,e){}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;if(!i){i=[];const{width:t,height:e}=this.boxBounds;(t||e)&&this.__drawPathByBox(new b(i))}return t?s.toCanvasData(i,!0):i}getPathString(t,e){return s.stringify(this.getPath(t,e))}__onUpdateSize(){if(this.__.__input){const t=this.__;if(t.__needComputePaint=!0,t.lazy&&this.leafer&&!this.leafer.canvas.bounds.hit(this.__world))return;t.__computePaint()}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?P.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;this.__.cornerRadius?t.roundRect(e,i,s,o,this.__.cornerRadius):t.rect(e,i,s,o)}export(t,e){return pt.export(this,t,e)}clone(){return It.one(this.toJSON())}static one(t,e,i,s,o){return A.get(t.tag||this.prototype.__tag,t,e,i,s,o)}destroy(){this.fill=this.stroke=null,super.destroy()}};it([r(ct)],Mt.prototype,"__",void 0),it([a("")],Mt.prototype,"id",void 0),it([a("")],Mt.prototype,"name",void 0),it([a("")],Mt.prototype,"className",void 0),it([_("pass-through")],Mt.prototype,"blendMode",void 0),it([h(1)],Mt.prototype,"opacity",void 0),it([h(!0)],Mt.prototype,"visible",void 0),it([a(!1)],Mt.prototype,"locked",void 0),it([n(0)],Mt.prototype,"zIndex",void 0),it([d(!1)],Mt.prototype,"mask",void 0),it([_("pixel")],Mt.prototype,"maskType",void 0),it([p(!1)],Mt.prototype,"eraser",void 0),it([l(0)],Mt.prototype,"x",void 0),it([l(0)],Mt.prototype,"y",void 0),it([u(100)],Mt.prototype,"width",void 0),it([u(100)],Mt.prototype,"height",void 0),it([c(1)],Mt.prototype,"scaleX",void 0),it([c(1)],Mt.prototype,"scaleY",void 0),it([y(0)],Mt.prototype,"rotation",void 0),it([y(0)],Mt.prototype,"skewX",void 0),it([y(0)],Mt.prototype,"skewY",void 0),it([v()],Mt.prototype,"around",void 0),it([a(!1)],Mt.prototype,"draggable",void 0),it([a(!1)],Mt.prototype,"editable",void 0),it([a("size")],Mt.prototype,"editSize",void 0),it([g(!0)],Mt.prototype,"hittable",void 0),it([g("path")],Mt.prototype,"hitFill",void 0),it([f("path")],Mt.prototype,"hitStroke",void 0),it([g(!1)],Mt.prototype,"hitBox",void 0),it([g(!0)],Mt.prototype,"hitChildren",void 0),it([g(!0)],Mt.prototype,"hitSelf",void 0),it([g()],Mt.prototype,"hitRadius",void 0),it([w("")],Mt.prototype,"cursor",void 0),it([_()],Mt.prototype,"fill",void 0),it([f()],Mt.prototype,"stroke",void 0),it([f("inside")],Mt.prototype,"strokeAlign",void 0),it([f(1)],Mt.prototype,"strokeWidth",void 0),it([f(!1)],Mt.prototype,"strokeWidthFixed",void 0),it([f("none")],Mt.prototype,"strokeCap",void 0),it([f("miter")],Mt.prototype,"strokeJoin",void 0),it([f()],Mt.prototype,"dashPattern",void 0),it([f()],Mt.prototype,"dashOffset",void 0),it([f(10)],Mt.prototype,"miterLimit",void 0),it([a(!1)],Mt.prototype,"lazy",void 0),it([f("none")],Mt.prototype,"startArrow",void 0),it([f("none")],Mt.prototype,"endArrow",void 0),it([x(0)],Mt.prototype,"cornerRadius",void 0),it([x()],Mt.prototype,"cornerSmoothing",void 0),it([st()],Mt.prototype,"shadow",void 0),it([st()],Mt.prototype,"innerShadow",void 0),it([st()],Mt.prototype,"blur",void 0),it([st()],Mt.prototype,"backgroundBlur",void 0),it([st()],Mt.prototype,"grayscale",void 0),it([m(R.prototype.reset)],Mt.prototype,"reset",null),it([m(k.drawPathByData)],Mt.prototype,"__drawPathByData",null),Mt=It=it([B(Lt),B(Tt),S()],Mt);let zt=class extends Mt{get __tag(){return"Group"}constructor(t){super(t),this.__setBranch()}__setBranch(){this.isBranch=!0,this.children||(this.children=[])}set(t){if(t.children){const{children:e}=t;let i;delete t.children,this.children?this.removeAll(!0):this.__setBranch(),super.set(t),e.forEach((t=>{i=A.get(t.tag,t),this.add(i)})),t.children=e}else super.set(t)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};it([r(vt)],zt.prototype,"__",void 0),zt=it([B(C),F()],zt);const Ot=e.get("Leafer");let Nt=class extends zt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get imageReady(){return this.viewReady&&D.isComplete}get layoutLocked(){return!this.layouter.running}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.zoomLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,dragOut:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t)}init(t,e){if(this.canvas)return;let i;this.__setLeafer(this),t&&E.assign(this.config,t);const{config:s}=this;this.initType(s.type),this.canvas=L.canvas(s),this.__controllers.push(this.renderer=L.renderer(this,this.canvas,s),this.watcher=L.watcher(this,s),this.layouter=L.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s),this.view=this.canvas.view,e?(this.__bindApp(e),i=e.running):(this.selector=L.selector(this),this.interaction=L.interaction(this,this.canvas,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=L.hitCanvasManager()),this.canvasManager=new T,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),this.onInit()}onInit(){}initType(t){}set(t){this.children?super.set(t):setTimeout((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(W.RESTART):this.emitLeafer(W.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(W.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=E.copyAttrs({},t,I);Object.keys(e).forEach((t=>this[t]=e[t]))}forceFullRender(){this.forceRender()}forceRender(t){this.renderer.addBlock(new M(t)||this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}__doResize(t){if(!this.canvas||this.canvas.isSameSize(t))return;const e=E.copyAttrs({},this.canvas,I);this.canvas.resize(t),this.__onResize(new z(t,e))}__onResize(t){this.emitEvent(t),E.copyAttrs(this.__,t,I),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.isLeafer=!!t,this.__level=1}setZoomLayer(t){this.zoomLayer=t}__checkAutoLayout(t){t.width&&t.height||(this.autoLayout=new O(t),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){this.canvas&&(I.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&&I.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=E.copyAttrs({},this.canvas,I);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(W.BEFORE_READY),this.emitLeafer(W.READY),this.emitLeafer(W.AFTER_READY),N.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(W.VIEW_READY),N.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){N.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1)}}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(W.VIEW_COMPLETED),N.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitReady(t){this.ready?t():this.__readyWait.push(t)}waitViewReady(t){this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t){this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e){const i=this.__nextRenderWait;if(e){for(let e=0;e<i.length;e++)if(i[e]===t){i.splice(e,1);break}}else i.push(t)}__checkUpdateLayout(){this.__layout.update()}emitLeafer(t){this.emitEvent(new W(t,this))}__listenEvents(){const t=H.start("FirstCreate "+this.innerName);this.once(W.START,(()=>H.end(t))),this.once(V.END,(()=>this.__onReady())),this.once(Y.START,(()=>this.__onCreated())),this.once(Y.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(X.DATA,this.__onWatchData,this),this.on_(Y.NEXT,this.__onNextRender,this),this.on_(V.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 W(W.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>{this.parent&&t===this.interaction||t.destroy()})),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{D.clearRecycled()}),100)}catch(t){Ot.error(t)}}))}};it([r(ft)],Nt.prototype,"__",void 0),it([u()],Nt.prototype,"pixelRatio",void 0),Nt=it([F()],Nt);let Ht=class extends Mt{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){}};it([r(Rt)],Ht.prototype,"__",void 0),it([m(Mt.prototype.__drawPathByBox)],Ht.prototype,"__drawPathByData",null),Ht=it([B(Wt),S(),F()],Ht);const Vt=Ht.prototype,Yt=zt.prototype,Xt={},{copy:jt,add:Ut}=U;let Gt=class extends zt{get __tag(){return"Box"}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}__updateRectBoxBounds(){}__updateBoxBounds(){this.__.__autoBounds&&this.children.length?super.__updateBoxBounds():this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;jt(Xt,t),super.__updateRenderBounds(),Ut(t,Xt)}}__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)}};it([r(gt)],Gt.prototype,"__",void 0),it([j("show")],Gt.prototype,"overflow",void 0),it([m(Vt.__updateStrokeSpread)],Gt.prototype,"__updateStrokeSpread",null),it([m(Vt.__updateRenderSpread)],Gt.prototype,"__updateRectRenderSpread",null),it([m(Vt.__updateBoxBounds)],Gt.prototype,"__updateRectBoxBounds",null),it([m(Vt.__updateStrokeBounds)],Gt.prototype,"__updateStrokeBounds",null),it([m(Vt.__updateRenderBounds)],Gt.prototype,"__updateRectRenderBounds",null),it([m(Vt.__updateChange)],Gt.prototype,"__updateRectChange",null),it([m(Vt.__drawPathByData)],Gt.prototype,"__drawPathByData",null),it([m(Vt.__render)],Gt.prototype,"__renderRect",null),it([m(Yt.__render)],Gt.prototype,"__renderGroup",null),Gt=it([S(),F()],Gt);let Jt=class extends Gt{get __tag(){return"Frame"}constructor(t){super(t),this.isFrame=!0}};it([r(wt)],Jt.prototype,"__",void 0),it([_("#FFFFFF")],Jt.prototype,"fill",void 0),it([j("hide")],Jt.prototype,"overflow",void 0),Jt=it([F()],Jt);const{moveTo:$t,closePath:Kt,ellipse:qt}=J;let Zt=class extends Mt{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,_=this.__.path=[];i?(s||o?(i<1&&qt(_,r,a,r*i,a*i,0,s,o,!1),qt(_,r,a,r,a,0,o,s,!0),i<1&&Kt(_)):(i<1&&(qt(_,r,a,r*i,a*i),$t(_,t,a)),qt(_,r,a,r,a,0,360,0,!0)),G.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?($t(_,r,a),qt(_,r,a,r,a,0,s,o,!1),Kt(_)):qt(_,r,a,r,a)}};it([r(kt)],Zt.prototype,"__",void 0),it([x(0)],Zt.prototype,"innerRadius",void 0),it([x(0)],Zt.prototype,"startAngle",void 0),it([x(0)],Zt.prototype,"endAngle",void 0),Zt=it([F()],Zt);const{moveTo:Qt,lineTo:te,drawPoints:ee}=J,{rotate:ie,getAngle:se,getDistance:oe,defaultPoint:re}=q,{toBounds:ae}=Z;let _e=class extends Mt{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=K();return t&&(i.x=t),e&&ie(i,e),i}set toPoint(t){this.width=oe(re,t),this.rotation=se(re,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?ee(t,this.__.points,!1):(Qt(t,0,0),te(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?ee(this.__.__pathForRender=[],this.__.points,this.__.curve,"Line"!==this.__tag):super.__updateRenderPath()}__updateBoxBounds(){this.points?ae(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};it([r(xt)],_e.prototype,"__",void 0),it([$("center")],_e.prototype,"strokeAlign",void 0),it([u(0)],_e.prototype,"height",void 0),it([x()],_e.prototype,"points",void 0),it([x(0)],_e.prototype,"curve",void 0),_e=it([F()],_e);const{sin:he,cos:ne,PI:de}=Math,{moveTo:pe,lineTo:le,closePath:ue,drawPoints:ce}=J,ye=_e.prototype;let ve=class extends Mt{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)ce(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;pe(t,o,0);for(let e=1;e<s;e++)le(t,o+o*he(2*e*de/s),r-r*ne(2*e*de/s))}ue(t)}__updateRenderPath(){}__updateBoxBounds(){}};it([r(Bt)],ve.prototype,"__",void 0),it([x(3)],ve.prototype,"sides",void 0),it([x()],ve.prototype,"points",void 0),it([x(0)],ve.prototype,"curve",void 0),it([m(ye.__updateRenderPath)],ve.prototype,"__updateRenderPath",null),it([m(ye.__updateBoxBounds)],ve.prototype,"__updateBoxBounds",null),ve=it([S(),F()],ve);const{sin:ge,cos:fe,PI:we}=Math,{moveTo:xe,lineTo:me,closePath:Re}=J;let ke=class extends Mt{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];xe(a,o,0);for(let t=1;t<2*i;t++)me(a,o+(t%2==0?o:o*s)*ge(t*we/i),r-(t%2==0?r:r*s)*fe(t*we/i));Re(a)}};it([r(St)],ke.prototype,"__",void 0),it([x(5)],ke.prototype,"corners",void 0),it([x(.382)],ke.prototype,"innerRadius",void 0),ke=it([F()],ke);let Be=class extends Ht{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(Q.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};it([r(Dt)],Be.prototype,"__",void 0),it([u("")],Be.prototype,"url",void 0),Be=it([F()],Be);let Se=class extends Ht{get __tag(){return"Canvas"}constructor(t){super(t),this.canvas=L.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(t,e,i,s){t.__layout.update();const o=new tt(t.__world).invert(),r=new tt;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const i=this.canvas.view,{width:s,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,o),t.restore()):t.drawImage(this.canvas.view,0,0,i.width,i.height,0,0,s,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()}};it([r(Dt)],Se.prototype,"__",void 0),it([ot(100)],Se.prototype,"width",void 0),it([ot(100)],Se.prototype,"height",void 0),it([ot(G.devicePixelRatio)],Se.prototype,"pixelRatio",void 0),it([ot(!0)],Se.prototype,"smooth",void 0),it([g("all")],Se.prototype,"hitFill",void 0),Se=it([F()],Se);const{copyAndSpread:be,includes:Pe,spread:Ae,setList:Ce}=U;let Fe=class extends Mt{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:i,__textDrawData:s}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):s.rows.forEach((s=>t.rect(s.x,s.y-i,s.width,e)))}__drawPathByData(t,e){const{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;t.rect(i,s,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=rt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{lineHeight:i,letterSpacing:s,fontFamily:o,fontSize:r,fontWeight:a,italic:_,textCase:h,textOverflow:n,padding:d}=t,p=t.__autoWidth,l=t.__autoHeight;t.__lineHeight=yt.number(i,r),t.__letterSpacing=yt.number(s,r),t.__padding=d?et.fourNumber(d):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*r)/2,t.__font=`${_?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==a?a+" ":""}${r}px ${o}`,t.__clipText="show"!==n&&!t.__autoBounds,this.__updateTextDrawData();const{bounds:u}=t.__textDrawData,c=e.boxBounds;if(t.__lineHeight<r&&Ae(u,r/2),p||l){if(c.x=p?u.x:0,c.y=l?u.y:0,c.width=p?u.width:t.width,c.height=l?u.height:t.height,d){const[e,i,s,o]=t.__padding;p&&(c.x-=o,c.width+=i+o),l&&(c.y-=e,c.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();const y=Pe(c,u)?c:u;y!==e.contentBounds?(e.contentBounds=y,e.renderChanged=!0,Ce(t.__textBoxBounds={},[c,u])):t.__textBoxBounds=y}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){be(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};it([r(Ft)],Fe.prototype,"__",void 0),it([u(0)],Fe.prototype,"width",void 0),it([u(0)],Fe.prototype,"height",void 0),it([u(0)],Fe.prototype,"padding",void 0),it([_("#000000")],Fe.prototype,"fill",void 0),it([$("outside")],Fe.prototype,"strokeAlign",void 0),it([g("all")],Fe.prototype,"hitFill",void 0),it([u("")],Fe.prototype,"text",void 0),it([u("L")],Fe.prototype,"fontFamily",void 0),it([u(12)],Fe.prototype,"fontSize",void 0),it([u("normal")],Fe.prototype,"fontWeight",void 0),it([u(!1)],Fe.prototype,"italic",void 0),it([u("none")],Fe.prototype,"textCase",void 0),it([u("none")],Fe.prototype,"textDecoration",void 0),it([u(0)],Fe.prototype,"letterSpacing",void 0),it([u({type:"percent",value:150})],Fe.prototype,"lineHeight",void 0),it([u(0)],Fe.prototype,"paraIndent",void 0),it([u(0)],Fe.prototype,"paraSpacing",void 0),it([u("left")],Fe.prototype,"textAlign",void 0),it([u("top")],Fe.prototype,"verticalAlign",void 0),it([u("normal")],Fe.prototype,"textWrap",void 0),it([u("show")],Fe.prototype,"textOverflow",void 0),Fe=it([F()],Fe);const{toBounds:De}=Z;let Ee=class extends Mt{get __tag(){return"Path"}constructor(t){super(t)}__updateBoxBounds(){De(this.__.path,this.__layout.boxBounds)}};it([r(Pt)],Ee.prototype,"__",void 0),it([x()],Ee.prototype,"path",void 0),it([x()],Ee.prototype,"windingRule",void 0),it([$("center")],Ee.prototype,"strokeAlign",void 0),Ee=it([F()],Ee);let Le=class extends zt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Ee(t);return this.pathStyle=t,this.path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this.path.length=0,this.paint(),this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,_){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,_){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}paint(){this.pathElement.forceUpdate("path")}};it([r(At)],Le.prototype,"__",void 0),Le=it([B(b,["beginPath"]),F()],Le);export{mt as ArrowData,Gt as Box,gt as BoxData,Se as Canvas,Et as CanvasData,at as ColorConvert,dt as Effect,Zt as Ellipse,kt as EllipseData,pt as Export,Jt as Frame,wt as FrameData,zt as Group,vt as GroupData,Be as Image,Dt as ImageData,Nt as Leafer,ft as LeaferData,_e as Line,xt as LineData,_t as Paint,nt as PaintGradient,ht as PaintImage,Ee as Path,Pt as PathData,Le as Pen,At as PenData,ve as Polygon,Bt as PolygonData,Ht as Rect,Rt as RectData,Wt as RectRender,ke as Star,St as StarData,Fe as Text,rt as TextConvert,Ft as TextData,Mt as UI,Lt as UIBounds,ct as UIData,Tt as UIRender,yt as UnitConvert,st as effectType,ot as resizeType};
@@ -0,0 +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(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 r(e){return(s,r)=>{t.defineLeafAttr(s,r,e,{set(t){this.__setAttr(r,t),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})}}"function"==typeof SuppressedError&&SuppressedError;const o={},i={},a={},n={},p={},h={},_=t.Debug.get("UIData");class d extends t.LeafData{get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){let{scaleX:e}=this.__leaf.__world;return e<0&&(e=-e),e>1?t/e:t}return t}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoBounds(){return!this._width&&!this._height}setVisible(t){this.__leaf.leafer&&(this.__leaf.leafer.watcher.hasVisible=!0),this._visible=t}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,_.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,_.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=h)):(this.__isFills&&(this.__removeInput("fill"),a.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=h)):(this.__isStrokes&&(this.__removeInput("stroke"),a.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t?!1===t.visible?null:[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t?!1===t.visible?null:[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&i.compute("fill",this.__leaf),e&&i.compute("stroke",this.__leaf),this.__needComputePaint=!1}}const l={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value/100*e:t.value:t};class u extends d{}class c extends u{get __boxStroke(){return!0}}class x extends u{}class y extends c{}class v extends d{}class g extends d{get __boxStroke(){return!0}}class f extends d{get __boxStroke(){return!0}}class w extends d{}class m extends d{}const{parse:T}=t.PathConvert;class R extends d{setPath(t){"string"==typeof t?(this.__setInput("path",t),this._path=T(t)):(this.__input&&this.__removeInput("path"),this._path=t)}}class P extends u{}const I={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class B extends d{setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=I[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class b extends g{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"strench",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(){const t=super.__getInputData();return delete t.fill,t}}const k={__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}},S={__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&&i.fill(s,this,t),o&&this.__drawAfterFill(t,e),r&&i.stroke(r,this,t)},__draw(t,e){if(this.__.__complex){const s=this.__;s.__needComputePaint&&s.__computePaint();const{fill:r,stroke:o,__drawAfterFill:a}=s;if(this.__drawRenderPath(t),s.__useEffect){const p=i.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:h,innerShadow:_}=s;h&&n.shadow(this,t,p),r&&(s.__isFills?i.fills(r,this,t):i.fill(r,this,t)),a&&this.__drawAfterFill(t,e),_&&n.innerShadow(this,t,p),o&&(s.__isStrokes?i.strokes(o,this,t):i.stroke(o,this,t)),p.worldCanvas&&p.worldCanvas.recycle(),p.canvas.recycle()}else r&&(s.__isFills?i.fills(r,this,t):i.fill(r,this,t)),a&&this.__drawAfterFill(t,e),o&&(s.__isStrokes?i.strokes(o,this,t):i.stroke(o,this,t))}else this.__drawFast(t,e)},__renderShape(t,e){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:s,stroke:r}=this.__;this.__drawRenderPath(t),s&&(this.__.__pixelFill?i.fills(s,this,t):i.fill("#000000",this,t)),r&&(this.__.__pixelStroke?i.strokes(r,this,t):i.stroke("#000000",this,t))}}},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.__;if(!o)return;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 U;exports.UI=U=class extends t.Leaf{get app(){return this.leafer&&this.leafer.app}set scale(t){"number"==typeof t?this.scaleX=this.scaleY=t:(this.scaleX=t.x,this.scaleY=t.y)}get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}constructor(t){super(t)}reset(t){}set(t){Object.assign(this,t)}get(){return this.__.__getInputData()}createProxyData(){}find(t,e){}findOne(t,e){}getPath(e,s){this.__layout.update();let r=s?this.__.__pathForRender:this.__.path;if(!r){r=[];const{width:e,height:s}=this.boxBounds;(e||s)&&this.__drawPathByBox(new t.PathCreator(r))}return e?t.PathConvert.toCanvasData(r,!0):r}getPathString(e,s){return t.PathConvert.stringify(this.getPath(e,s))}__onUpdateSize(){if(this.__.__input){const t=this.__;if(t.__needComputePaint=!0,t.lazy&&this.leafer&&!this.leafer.canvas.bounds.hit(this.__world))return;t.__computePaint()}}__updateRenderPath(){if(this.__.path){const e=this.__;e.__pathForRender=e.cornerRadius?t.PathCorner.smooth(e.path,e.cornerRadius,e.cornerSmoothing):e.path}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){}__drawPathByBox(t){const{x:e,y:s,width:r,height:o}=this.__layout.boxBounds;this.__.cornerRadius?t.roundRect(e,s,r,o,this.__.cornerRadius):t.rect(e,s,r,o)}export(t,e){return p.export(this,t,e)}clone(){return U.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(d)],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.dataType(!1)],exports.UI.prototype,"locked",void 0),e([t.sortType(0)],exports.UI.prototype,"zIndex",void 0),e([t.maskType(!1)],exports.UI.prototype,"mask",void 0),e([t.surfaceType("pixel")],exports.UI.prototype,"maskType",void 0),e([t.eraserType(!1)],exports.UI.prototype,"eraser",void 0),e([t.positionType(0)],exports.UI.prototype,"x",void 0),e([t.positionType(0)],exports.UI.prototype,"y",void 0),e([t.boundsType(100)],exports.UI.prototype,"width",void 0),e([t.boundsType(100)],exports.UI.prototype,"height",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleX",void 0),e([t.scaleType(1)],exports.UI.prototype,"scaleY",void 0),e([t.rotationType(0)],exports.UI.prototype,"rotation",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewX",void 0),e([t.rotationType(0)],exports.UI.prototype,"skewY",void 0),e([t.autoLayoutType()],exports.UI.prototype,"around",void 0),e([t.dataType(!1)],exports.UI.prototype,"draggable",void 0),e([t.dataType(!1)],exports.UI.prototype,"editable",void 0),e([t.dataType("size")],exports.UI.prototype,"editSize",void 0),e([t.hitType(!0)],exports.UI.prototype,"hittable",void 0),e([t.hitType("path")],exports.UI.prototype,"hitFill",void 0),e([t.strokeType("path")],exports.UI.prototype,"hitStroke",void 0),e([t.hitType(!1)],exports.UI.prototype,"hitBox",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitChildren",void 0),e([t.hitType(!0)],exports.UI.prototype,"hitSelf",void 0),e([t.hitType()],exports.UI.prototype,"hitRadius",void 0),e([t.cursorType("")],exports.UI.prototype,"cursor",void 0),e([t.surfaceType()],exports.UI.prototype,"fill",void 0),e([t.strokeType()],exports.UI.prototype,"stroke",void 0),e([t.strokeType("inside")],exports.UI.prototype,"strokeAlign",void 0),e([t.strokeType(1)],exports.UI.prototype,"strokeWidth",void 0),e([t.strokeType(!1)],exports.UI.prototype,"strokeWidthFixed",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.dataType(!1)],exports.UI.prototype,"lazy",void 0),e([t.strokeType("none")],exports.UI.prototype,"startArrow",void 0),e([t.strokeType("none")],exports.UI.prototype,"endArrow",void 0),e([t.pathType(0)],exports.UI.prototype,"cornerRadius",void 0),e([t.pathType()],exports.UI.prototype,"cornerSmoothing",void 0),e([s()],exports.UI.prototype,"shadow",void 0),e([s()],exports.UI.prototype,"innerShadow",void 0),e([s()],exports.UI.prototype,"blur",void 0),e([s()],exports.UI.prototype,"backgroundBlur",void 0),e([s()],exports.UI.prototype,"grayscale",void 0),e([t.rewrite(t.Leaf.prototype.reset)],exports.UI.prototype,"reset",null),e([t.rewrite(t.PathDrawer.drawPathByData)],exports.UI.prototype,"__drawPathByData",null),exports.UI=U=e([t.useModule(k),t.useModule(S),t.rewriteAble()],exports.UI),exports.Group=class extends exports.UI{get __tag(){return"Group"}constructor(t){super(t),this.__setBranch()}__setBranch(){this.isBranch=!0,this.children||(this.children=[])}set(e){if(e.children){const{children:s}=e;let r;delete e.children,this.children?this.removeAll(!0):this.__setBranch(),super.set(e),s.forEach((e=>{r=t.UICreator.get(e.tag,e),this.add(r)})),e.children=s}else super.set(e)}toJSON(){const t=super.toJSON();return t.children=this.children.map((t=>t.toJSON())),t}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}},e([t.dataProcessor(u)],exports.Group.prototype,"__",void 0),exports.Group=e([t.useModule(t.Branch),t.registerUI()],exports.Group);const A=t.Debug.get("Leafer");exports.Leafer=class extends exports.Group{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get imageReady(){return this.viewReady&&t.ImageManager.isComplete}get layoutLocked(){return!this.layouter.running}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}constructor(t,e){super(e),this.zoomLayer=this,this.config={type:"design",start:!0,hittable:!0,smooth:!0,zoom:{min:.02,max:256},move:{holdSpaceKey:!0,holdMiddleKey:!0,dragOut:!0,autoDistance:2}},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t)}init(e,s){if(this.canvas)return;let r;this.__setLeafer(this),e&&t.DataHelper.assign(this.config,e);const{config:o}=this;this.initType(o.type),this.canvas=t.Creator.canvas(o),this.__controllers.push(this.renderer=t.Creator.renderer(this,this.canvas,o),this.watcher=t.Creator.watcher(this,o),this.layouter=t.Creator.layouter(this,o)),this.isApp&&this.__setApp(),this.__checkAutoLayout(o),this.view=this.canvas.view,s?(this.__bindApp(s),r=s.running):(this.selector=t.Creator.selector(this),this.interaction=t.Creator.interaction(this,this.canvas,this.selector,o),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=t.Creator.hitCanvasManager()),this.canvasManager=new t.CanvasManager,r=o.start),this.hittable=o.hittable,this.fill=o.fill,this.canvasManager.add(this.canvas),this.__listenEvents(),r&&(this.__startTimer=setTimeout(this.start.bind(this))),this.onInit()}onInit(){}initType(t){}set(t){this.children?super.set(t):setTimeout((()=>{super.set(t)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.ready?this.emitLeafer(t.LeaferEvent.RESTART):this.emitLeafer(t.LeaferEvent.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render(),this.running=!0)}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(t.LeaferEvent.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(e){const s=t.DataHelper.copyAttrs({},e,t.canvasSizeAttrs);Object.keys(s).forEach((t=>this[t]=s[t]))}forceFullRender(){this.forceRender()}forceRender(e){this.renderer.addBlock(new t.Bounds(e)||this.canvas.bounds),this.viewReady&&this.renderer.update()}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}__doResize(e){if(!this.canvas||this.canvas.isSameSize(e))return;const s=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);this.canvas.resize(e),this.__onResize(new t.ResizeEvent(e,s))}__onResize(e){this.emitEvent(e),t.DataHelper.copyAttrs(this.__,e,t.canvasSizeAttrs),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.isLeafer=!!t,this.__level=1}setZoomLayer(t){this.zoomLayer=t}__checkAutoLayout(e){e.width&&e.height||(this.autoLayout=new t.AutoBounds(e),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(e,s){this.canvas&&(t.canvasSizeAttrs.includes(e)?this.__changeCanvasSize(e,s):"fill"===e?this.__changeFill(s):"hittable"===e&&(this.canvas.hittable=s)),super.__setAttr(e,s)}__getAttr(e){return this.canvas&&t.canvasSizeAttrs.includes(e)?this.canvas[e]:super.__getAttr(e)}__changeCanvasSize(e,s){const r=t.DataHelper.copyAttrs({},this.canvas,t.canvasSizeAttrs);r[e]=this.config[e]=s,s&&this.canvas.stopAutoLayout(),this.__doResize(r)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceFullRender()}__onCreated(){this.created=!0}__onReady(){this.ready||(this.ready=!0,this.emitLeafer(t.LeaferEvent.BEFORE_READY),this.emitLeafer(t.LeaferEvent.READY),this.emitLeafer(t.LeaferEvent.AFTER_READY),t.WaitHelper.run(this.__readyWait))}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(t.LeaferEvent.VIEW_READY),t.WaitHelper.run(this.__viewReadyWait))}__onNextRender(){if(this.viewReady){t.WaitHelper.run(this.__nextRenderWait);const{imageReady:e}=this;e&&!this.viewCompleted&&this.__checkViewCompleted(),e||(this.viewCompleted=!1)}}__checkViewCompleted(e=!0){this.nextRender((()=>{this.imageReady&&(e&&this.emitLeafer(t.LeaferEvent.VIEW_COMPLETED),t.WaitHelper.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitReady(t){this.ready?t():this.__readyWait.push(t)}waitViewReady(t){this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t){this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e){const s=this.__nextRenderWait;if(e){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t)}__checkUpdateLayout(){this.__layout.update()}emitLeafer(e){this.emitEvent(new t.LeaferEvent(e,this))}__listenEvents(){const e=t.Run.start("FirstCreate "+this.innerName);this.once(t.LeaferEvent.START,(()=>t.Run.end(e))),this.once(t.LayoutEvent.END,(()=>this.__onReady())),this.once(t.RenderEvent.START,(()=>this.__onCreated())),this.once(t.RenderEvent.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(t.WatchEvent.DATA,this.__onWatchData,this),this.on_(t.RenderEvent.NEXT,this.__onNextRender,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&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{t.ImageManager.clearRecycled()}),100)}catch(t){A.error(t)}}))}},e([t.dataProcessor(x)],exports.Leafer.prototype,"__",void 0),e([t.boundsType()],exports.Leafer.prototype,"pixelRatio",void 0),exports.Leafer=e([t.registerUI()],exports.Leafer),exports.Rect=class extends exports.UI{get __tag(){return"Rect"}constructor(t){super(t)}__drawPathByData(t,e){}},e([t.dataProcessor(g)],exports.Rect.prototype,"__",void 0),e([t.rewrite(exports.UI.prototype.__drawPathByBox)],exports.Rect.prototype,"__drawPathByData",null),exports.Rect=e([t.useModule(C),t.rewriteAble(),t.registerUI()],exports.Rect);const D=exports.Rect.prototype,L=exports.Group.prototype,E={},{copy:F,add:W}=t.BoundsHelper;exports.Box=class extends exports.Group{get __tag(){return"Box"}constructor(t){super(t),this.isBranchLeaf=!0,this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){let t=this.__updateRectRenderSpread()||super.__updateRenderSpread();return this.__.__drawAfterFill="hide"===this.__.overflow,t||(t=this.__.__drawAfterFill?0:1),t}__updateRectBoxBounds(){}__updateBoxBounds(){this.__.__autoBounds&&this.children.length?super.__updateBoxBounds():this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){if(this.__updateRectRenderBounds(),!this.__.__drawAfterFill){const{renderBounds:t}=this.__layout;F(E,t),super.__updateRenderBounds(),W(t,E)}}__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(c)],exports.Box.prototype,"__",void 0),e([t.affectRenderBoundsType("show")],exports.Box.prototype,"overflow",void 0),e([t.rewrite(D.__updateStrokeSpread)],exports.Box.prototype,"__updateStrokeSpread",null),e([t.rewrite(D.__updateRenderSpread)],exports.Box.prototype,"__updateRectRenderSpread",null),e([t.rewrite(D.__updateBoxBounds)],exports.Box.prototype,"__updateRectBoxBounds",null),e([t.rewrite(D.__updateStrokeBounds)],exports.Box.prototype,"__updateStrokeBounds",null),e([t.rewrite(D.__updateRenderBounds)],exports.Box.prototype,"__updateRectRenderBounds",null),e([t.rewrite(D.__updateChange)],exports.Box.prototype,"__updateRectChange",null),e([t.rewrite(D.__drawPathByData)],exports.Box.prototype,"__drawPathByData",null),e([t.rewrite(D.__render)],exports.Box.prototype,"__renderRect",null),e([t.rewrite(L.__render)],exports.Box.prototype,"__renderGroup",null),exports.Box=e([t.rewriteAble(),t.registerUI()],exports.Box),exports.Frame=class extends exports.Box{get __tag(){return"Frame"}constructor(t){super(t),this.isFrame=!0}},e([t.dataProcessor(y)],exports.Frame.prototype,"__",void 0),e([t.surfaceType("#FFFFFF")],exports.Frame.prototype,"fill",void 0),e([t.affectRenderBoundsType("hide")],exports.Frame.prototype,"overflow",void 0),exports.Frame=e([t.registerUI()],exports.Frame);const{moveTo:M,closePath:z,ellipse:H}=t.PathCommandDataHelper;exports.Ellipse=class extends exports.UI{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:e,height:s,innerRadius:r,startAngle:o,endAngle:i}=this.__,a=e/2,n=s/2,p=this.__.path=[];r?(o||i?(r<1&&H(p,a,n,a*r,n*r,0,o,i,!1),H(p,a,n,a,n,0,i,o,!0),r<1&&z(p)):(r<1&&(H(p,a,n,a*r,n*r),M(p,e,n)),H(p,a,n,a,n,0,360,0,!0)),t.Platform.ellipseToCurve&&(this.__.path=this.getPath(!0))):o||i?(M(p,a,n),H(p,a,n,a,n,0,o,i,!1),z(p)):H(p,a,n,a,n)}},e([t.dataProcessor(f)],exports.Ellipse.prototype,"__",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"innerRadius",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"startAngle",void 0),e([t.pathType(0)],exports.Ellipse.prototype,"endAngle",void 0),exports.Ellipse=e([t.registerUI()],exports.Ellipse);const{moveTo:O,lineTo:N,drawPoints:G}=t.PathCommandDataHelper,{rotate:V,getAngle:j,getDistance:Y,defaultPoint:X}=t.PointHelper,{toBounds:J}=t.PathBounds;exports.Line=class extends exports.UI{get __tag(){return"Line"}get toPoint(){const{width:e,rotation:s}=this.__,r=t.getPointData();return e&&(r.x=e),s&&V(r,s),r}set toPoint(t){this.width=Y(X,t),this.rotation=j(X,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];this.__.points?G(t,this.__.points,!1):(O(t,0,0),N(t,this.width,0))}__updateRenderPath(){this.__.points&&this.__.curve?G(this.__.__pathForRender=[],this.__.points,this.__.curve,"Line"!==this.__tag):super.__updateRenderPath()}__updateBoxBounds(){this.points?J(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}},e([t.dataProcessor(v)],exports.Line.prototype,"__",void 0),e([t.affectStrokeBoundsType("center")],exports.Line.prototype,"strokeAlign",void 0),e([t.boundsType(0)],exports.Line.prototype,"height",void 0),e([t.pathType()],exports.Line.prototype,"points",void 0),e([t.pathType(0)],exports.Line.prototype,"curve",void 0),exports.Line=e([t.registerUI()],exports.Line);const{sin:$,cos:q,PI:K}=Math,{moveTo:Z,lineTo:Q,closePath:tt,drawPoints:et}=t.PathCommandDataHelper,st=exports.Line.prototype;exports.Polygon=class extends exports.UI{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)et(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++)Q(t,o+o*$(2*e*K/r),i-i*q(2*e*K/r))}tt(t)}__updateRenderPath(){}__updateBoxBounds(){}},e([t.dataProcessor(w)],exports.Polygon.prototype,"__",void 0),e([t.pathType(3)],exports.Polygon.prototype,"sides",void 0),e([t.pathType()],exports.Polygon.prototype,"points",void 0),e([t.pathType(0)],exports.Polygon.prototype,"curve",void 0),e([t.rewrite(st.__updateRenderPath)],exports.Polygon.prototype,"__updateRenderPath",null),e([t.rewrite(st.__updateBoxBounds)],exports.Polygon.prototype,"__updateBoxBounds",null),exports.Polygon=e([t.rewriteAble(),t.registerUI()],exports.Polygon);const{sin:rt,cos:ot,PI:it}=Math,{moveTo:at,lineTo:nt,closePath:pt}=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=[];at(a,o,0);for(let t=1;t<2*s;t++)nt(a,o+(t%2==0?o:o*r)*rt(t*it/s),i-(t%2==0?i:i*r)*ot(t*it/s));pt(a)}},e([t.dataProcessor(m)],exports.Star.prototype,"__",void 0),e([t.pathType(5)],exports.Star.prototype,"corners",void 0),e([t.pathType(.382)],exports.Star.prototype,"innerRadius",void 0),exports.Star=e([t.registerUI()],exports.Star),exports.Image=class extends exports.Rect{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(e){super(e),this.on(t.ImageEvent.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}},e([t.dataProcessor(b)],exports.Image.prototype,"__",void 0),e([t.boundsType("")],exports.Image.prototype,"url",void 0),exports.Image=e([t.registerUI()],exports.Image),exports.Canvas=class extends exports.Rect{get __tag(){return"Canvas"}constructor(e){super(e),this.canvas=t.Creator.canvas(this.__),this.context=this.canvas.context,this.__.__drawAfterFill=!0}draw(e,s,r,o){e.__layout.update();const i=new t.Matrix(e.__world).invert(),a=new t.Matrix;s&&a.translate(s.x,s.y),r&&("number"==typeof r?a.scale(r):a.scale(r.x,r.y)),o&&a.rotate(o),i.multiplyParent(a),e.__render(this.canvas,{matrix:i.withScale()}),this.paint()}paint(){this.forceUpdate("fill")}__drawAfterFill(t,e){const s=this.canvas.view,{width:r,height:o}=this;this.__.cornerRadius?(t.save(),t.clip(),t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o),t.restore()):t.drawImage(this.canvas.view,0,0,s.width,s.height,0,0,r,o)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e}=this.__;t.smooth!==e&&(t.smooth=e),t.resize(this.__)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=null,this.context=null),super.destroy()}},e([t.dataProcessor(b)],exports.Canvas.prototype,"__",void 0),e([r(100)],exports.Canvas.prototype,"width",void 0),e([r(100)],exports.Canvas.prototype,"height",void 0),e([r(t.Platform.devicePixelRatio)],exports.Canvas.prototype,"pixelRatio",void 0),e([r(!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:ht,includes:_t,spread:dt,setList:lt}=t.BoundsHelper;exports.Text=class extends exports.UI{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,__baseLine:s,__textDrawData:r}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):r.rows.forEach((r=>t.rect(r.x,r.y-s,r.width,e)))}__drawPathByData(t,e){const{x:s,y:r,width:o,height:i}=this.__layout.boxBounds;t.rect(s,r,o,i)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__;t.__textDrawData=o.getDrawData(t.text,this.__)}__updateBoxBounds(){const e=this.__,s=this.__layout,{lineHeight:r,letterSpacing:o,fontFamily:i,fontSize:a,fontWeight:n,italic:p,textCase:h,textOverflow:_,padding:d}=e,u=e.__autoWidth,c=e.__autoHeight;e.__lineHeight=l.number(r,a),e.__letterSpacing=l.number(o,a),e.__padding=d?t.MathHelper.fourNumber(d):void 0,e.__baseLine=e.__lineHeight-(e.__lineHeight-.7*a)/2,e.__font=`${p?"italic ":""}${"small-caps"===h?"small-caps ":""}${"normal"!==n?n+" ":""}${a}px ${i}`,e.__clipText="show"!==_&&!e.__autoBounds,this.__updateTextDrawData();const{bounds:x}=e.__textDrawData,y=s.boxBounds;if(e.__lineHeight<a&&dt(x,a/2),u||c){if(y.x=u?x.x:0,y.y=c?x.y:0,y.width=u?x.width:e.width,y.height=c?x.height:e.height,d){const[t,s,r,o]=e.__padding;u&&(y.x-=o,y.width+=s+o),c&&(y.y-=t,y.height+=r+t)}this.__updateNaturalSize()}else super.__updateBoxBounds();const v=_t(y,x)?y:x;v!==s.contentBounds?(s.contentBounds=v,s.renderChanged=!0,lt(e.__textBoxBounds={},[y,x])):e.__textBoxBounds=v}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){ht(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}},e([t.dataProcessor(B)],exports.Text.prototype,"__",void 0),e([t.boundsType(0)],exports.Text.prototype,"width",void 0),e([t.boundsType(0)],exports.Text.prototype,"height",void 0),e([t.boundsType(0)],exports.Text.prototype,"padding",void 0),e([t.surfaceType("#000000")],exports.Text.prototype,"fill",void 0),e([t.affectStrokeBoundsType("outside")],exports.Text.prototype,"strokeAlign",void 0),e([t.hitType("all")],exports.Text.prototype,"hitFill",void 0),e([t.boundsType("")],exports.Text.prototype,"text",void 0),e([t.boundsType("L")],exports.Text.prototype,"fontFamily",void 0),e([t.boundsType(12)],exports.Text.prototype,"fontSize",void 0),e([t.boundsType("normal")],exports.Text.prototype,"fontWeight",void 0),e([t.boundsType(!1)],exports.Text.prototype,"italic",void 0),e([t.boundsType("none")],exports.Text.prototype,"textCase",void 0),e([t.boundsType("none")],exports.Text.prototype,"textDecoration",void 0),e([t.boundsType(0)],exports.Text.prototype,"letterSpacing",void 0),e([t.boundsType({type:"percent",value:150})],exports.Text.prototype,"lineHeight",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraIndent",void 0),e([t.boundsType(0)],exports.Text.prototype,"paraSpacing",void 0),e([t.boundsType("left")],exports.Text.prototype,"textAlign",void 0),e([t.boundsType("top")],exports.Text.prototype,"verticalAlign",void 0),e([t.boundsType("normal")],exports.Text.prototype,"textWrap",void 0),e([t.boundsType("show")],exports.Text.prototype,"textOverflow",void 0),exports.Text=e([t.registerUI()],exports.Text);const{toBounds:ut}=t.PathBounds;exports.Path=class extends exports.UI{get __tag(){return"Path"}constructor(t){super(t)}__updateBoxBounds(){ut(this.__.path,this.__layout.boxBounds)}},e([t.dataProcessor(R)],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")}},e([t.dataProcessor(P)],exports.Pen.prototype,"__",void 0),exports.Pen=e([t.useModule(t.PathCreator,["beginPath"]),t.registerUI()],exports.Pen),exports.ArrowData=class extends v{},exports.BoxData=c,exports.CanvasData=class extends g{},exports.ColorConvert={},exports.Effect=n,exports.EllipseData=f,exports.Export=p,exports.FrameData=y,exports.GroupData=u,exports.ImageData=b,exports.LeaferData=x,exports.LineData=v,exports.Paint=i,exports.PaintGradient={},exports.PaintImage=a,exports.PathData=R,exports.PenData=P,exports.PolygonData=w,exports.RectData=g,exports.RectRender=C,exports.StarData=m,exports.TextConvert=o,exports.TextData=B,exports.UIBounds=k,exports.UIData=d,exports.UIRender=S,exports.UnitConvert=l,exports.effectType=s,exports.resizeType=r,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 ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@leafer-ui/draw",
3
+ "version": "1.0.0-rc.10",
4
+ "description": "@leafer-ui/draw",
5
+ "author": "Chao (Leafer) Wan",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "lib/draw.esm.js",
9
+ "exports": {
10
+ "import": "./lib/draw.esm.js",
11
+ "require": "./lib/draw.cjs",
12
+ "types": "./types/index.d.ts"
13
+ },
14
+ "types": "types/index.d.ts",
15
+ "files": [
16
+ "src",
17
+ "types",
18
+ "lib"
19
+ ],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/leaferjs/ui.git"
23
+ },
24
+ "homepage": "https://github.com/leaferjs/ui/tree/main/packages/core/draw",
25
+ "bugs": "https://github.com/leaferjs/ui/issues",
26
+ "keywords": [
27
+ "leafer draw",
28
+ "leafer-ui",
29
+ "leaferjs"
30
+ ],
31
+ "dependencies": {
32
+ "@leafer/core": "1.0.0-rc.10",
33
+ "@leafer-ui/display": "1.0.0-rc.10",
34
+ "@leafer-ui/display-module": "1.0.0-rc.10",
35
+ "@leafer-ui/decorator": "1.0.0-rc.10",
36
+ "@leafer-ui/external": "1.0.0-rc.10"
37
+ }
38
+ }
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from '@leafer/core'
2
+
3
+ export * from '@leafer-ui/display'
4
+ export * from '@leafer-ui/display-module'
5
+ export * from '@leafer-ui/decorator'
6
+
7
+ export * from '@leafer-ui/external'
@@ -0,0 +1,5 @@
1
+ export * from '@leafer/core';
2
+ export * from '@leafer-ui/display';
3
+ export * from '@leafer-ui/display-module';
4
+ export * from '@leafer-ui/decorator';
5
+ export * from '@leafer-ui/external';