@leafer-draw/miniapp 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/miniapp.cjs +27 -15
- package/dist/miniapp.esm.js +27 -15
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.module.js +107 -69
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +7 -7
package/dist/miniapp.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!1}init(){const{config:e}=this;let n=e.view||e.canvas;n?("string"==typeof n?("#"!==n[0]&&(n="#"+n),this.viewSelect=t.Platform.miniapp.select(n)):n.fields?this.viewSelect=n:this.initView(n),this.viewSelect&&t.Platform.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(e){e?this.view=e.view||e:(e={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:n,height:i,pixelRatio:s}=this.config,o={width:n||e.width,height:i||e.height,pixelRatio:s};this.resize(o),this.context&&(this.viewSelect&&(t.Platform.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,n,i,s){this.context.roundRect(t,e,n,i,"number"==typeof s?[s]:s)}),t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(e){this.viewSelect&&t.Platform.miniapp.getBounds(this.viewSelect).then((t=>{this.clientBounds=t,e&&e()}))}startAutoLayout(e,n){this.resizeListener=n,e&&(this.checkSize=this.checkSize.bind(this),t.Platform.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:n}=this,i={width:t,height:e,pixelRatio:n};this.isSameSize(i)||this.emitResize(i)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,t.Platform.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}}const{mineType:i,fileType:s}=t.FileHelper;function o(e,n){t.Platform.origin={createCanvas:(t,e,i)=>{const s={type:"2d",width:t,height:e};n.createOffscreenCanvas?n.createOffscreenCanvas(s):n.createOffScreenCanvas(s)},canvasToDataURL:(t,e,n)=>t.toDataURL(i(e),n),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(e,n,o)=>{let a=e.toDataURL(i(s(n)),o);return a=a.substring(a.indexOf("64,")+3),t.Platform.origin.download(a,n)},download:(e,i)=>new Promise(((s,o)=>{let a;i.includes("/")||(i=`${n.env.USER_DATA_PATH}/`+i,a=!0);const r=n.getFileSystemManager();r.writeFile({filePath:i,data:e,encoding:"base64",success(){a?t.Platform.miniapp.saveToAlbum(i).then((()=>{r.unlink({filePath:i}),s()})):s()},fail(t){o(t)}})})),loadImage:e=>new Promise(((n,i)=>{const s=t.Platform.canvas.view.createImage();s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)})),noRepeat:"repeat-x"},t.Platform.miniapp={select:t=>n.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const n=t[1];e({x:n.top,y:n.left,width:n.width,height:n.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const n=t[0];e({view:n.node,width:n.width,height:n.height})}))})),saveToAlbum:t=>new Promise((e=>{n.getSetting({success:i=>{i.authSetting["scope.writePhotosAlbum"]?n.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):n.authorize({scope:"scope.writePhotosAlbum",success:()=>{n.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){n.onWindowResize(t)},offWindowResize(t){n.offWindowResize(t)}},t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="miniapp",t.Platform.requestRender=function(e){const{view:n}=t.Platform.renderCanvas||t.Platform.canvas;n.requestAnimationFrame?n.requestAnimationFrame(e):setTimeout(e,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class a{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:r,updateBounds:l,updateAllWorldOpacity:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:h}=t.BranchHelper;const{worldBounds:u}=t.LeafBoundsHelper,f={x:0,y:0,width:1e5,height:1e5};class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,u)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(f):this.afterBounds.setListWithFn(t,u),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:g,updateAllChange:_}=t.LeafHelper,w=t.Debug.get("Layouter");class m{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:o,LAYOUT:a,AFTER:u}=t.LayoutEvent,f=this.getBlocks(s);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,f,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(r(t,!0),e.add(t),t.isBranch&&c(t,e),h(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),h(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||l(i[t])}l(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&d(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(a,f,this.times)),i.emitEvent(new t.LayoutEvent(u,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:o}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,a,this.times)),m.fullLayout(n),a.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,a,this.times)),n.emitEvent(new t.LayoutEvent(o,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new p([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new p(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const v=t.Debug.get("Renderer");class y{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return v.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),o=e.includes(this.target.__world),a=new t.Bounds(s);i.save(),o&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,o,a),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function x(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}function b(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?E(t,!0,e,n):R(e,n);break;case"inside":B("inside",t,s,e,n);break;case"outside":B("outside",t,s,e,n)}}function B(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?E(e,!0,i,r):R(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",x(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function R(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}function E(t,n,i,s){let o;for(let a=0,r=t.length;a<r;a++)o=t[a],o.image&&e.PaintImage.checkImage(i,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),n?R(i,s):s.stroke(),s.restoreBlendMode()):n?R(i,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new a(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new y(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=m.fullLayout;const{getSpread:S,getOuterOf:L,getByMove:k,getIntersectData:P}=t.BoundsHelper;let A;function C(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:s}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:a,color:r,opacity:l}=n;return{type:o,blendMode:a,style:e.ColorConvert.string(r,l)};case"image":return e.PaintImage.image(i,t,n,s,!A||!A[n.url]);case"linear":return e.PaintGradient.linearGradient(n,s);case"radial":return e.PaintGradient.radialGradient(n,s);case"angular":return e.PaintGradient.conicGradient(n,s);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const W={compute:function(t,n){const i=n.__,s=[];let o,a=i.__input[t];a instanceof Array||(a=[a]),A=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=a.length;i<o;i++)e=C(t,a[i],n),e&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?x(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let s;const{windingRule:o,__font:a}=n.__;for(let r=0,l=t.length;r<l;r++)s=t[r],s.image&&e.PaintImage.checkImage(n,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?x(n,i):o?i.fill(o):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?x(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):a?x(n,i):o?i.fill(o):i.fill())},fillText:x,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)b(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)b(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),E(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),E(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),E(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:b,drawTextStroke:R,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=P(i?S(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=L(s,a),o=k(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let O={};const{get:T,rotateOfOuter:M,translate:I,scaleOfOuter:D,scale:z,rotate:H}=t.MatrixHelper;function F(t,e,n,i,s,o,a){const r=T();I(r,e.x+n,e.y+i),z(r,s,o),a&&M(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Y(t,e,n,i,s,o,a){const r=T();I(r,e.x+n,e.y+i),s&&z(r,s,o),a&&H(r,a),t.transform=r}function j(t,e,n,i,s,o,a,r,l,d){const c=T();if(l)if("center"===d)M(c,{x:n/2,y:i/2},l);else switch(H(c,l),l){case 90:I(c,i,0);break;case 180:I(c,n,i);break;case 270:I(c,0,n)}O.x=e.x+s,O.y=e.y+o,I(c,O.x,O.y),a&&D(c,O,a,r),t.transform=c}const{get:G,translate:U}=t.MatrixHelper,V=new t.Bounds,X={},N={};function q(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Q(n,i,e)}function Q(e,n,i){let{width:s,height:o}=i;e.padding&&(n=V.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:a,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===s&&n.height===o,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?o:s,m=_?s:o;let v,y,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,N),v=N.scaleX,y=N.scaleY);else if(!p||u){const t=n.width/w,e=n.height/m;v=y="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-s*v)/2,b+=(n.height-o*y)/2}if(l){const e={x:x,y:b,width:w,height:m};v&&(e.width*=v,e.height*=y),t.AlignHelper.toPoint(l,e,n,X,!0),x+=X.x,b+=X.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(s=n.width,o=n.height);break;case"normal":case"clip":(x||b||v||u)&&Y(g,n,x,b,v,y,u);break;case"repeat":(!p||v||u)&&j(g,n,s,o,x,b,v,y,u,l),f||(g.repeat="repeat");break;default:v&&F(g,n,x,b,v,y,u)}return g.transform||(n.x||n.y)&&(g.transform=G(),U(g.transform,n.x,n.y)),v&&"stretch"!==r&&(g.scaleX=v,g.scaleY=y),g.width=s,g.height=o,a&&(g.opacity=a),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let J,Z=new t.Bounds;const{isSame:$}=t.BoundsHelper;function K(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||q(s,i,n,o),!0}function tt(e,n){it(e,t.ImageEvent.LOAD,n)}function et(e,n){it(e,t.ImageEvent.LOADED,n)}function nt(e,n,i){n.error=i,e.forceUpdate("surface"),it(e,t.ImageEvent.ERROR,n)}function it(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function st(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ot,scale:at,copy:rt}=t.MatrixHelper,{ceil:lt,abs:dt}=Math;function ct(e,n,i){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||e.destroyed)return!1;{s=dt(s),o=dt(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=ot(),rt(d,g),at(d,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const w=c*h;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(l=Math.sqrt(w/m)),l&&(s/=l,o/=l,c/=l,h/=l),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(d||(d=ot(),g&&rt(d,g)),at(d,1/s,1/o));const v=e.getCanvas(lt(c)||1,lt(h)||1,p),y=e.getPattern(v,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=y,n.patternId=a,!0}}function ht(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ut}=Math;const ft={image:function(e,n,i,s,o){let a,r;const l=t.ImageManager.get(i);return J&&i===J.paint&&$(s,J.boxBounds)?a=J.leafPaint:(a={type:i.type,image:l},J=l.use>1?{leafPaint:a,paint:i,boxBounds:Z.set(s)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(K(e,n,i,l,a,s),o&&(tt(e,r),et(e,r))):l.error?o&&nt(e,r,l.error):(o&&(st(e,!0),tt(e,r)),a.loadId=l.load((()=>{st(e,!1),e.destroyed||(K(e,n,i,l,a,s)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),et(e,r)),a.loadId=null}),(t=>{st(e,!1),nt(e,r,t),a.loadId=null}))),a},checkImage:function(n,i,s,o){const{scaleX:a,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i;if(!s.data||s.patternId===a+"-"+r+"-"+l&&!e.Export.running)return!1;{const{data:d}=s;if(o)if(d.repeat)o=!1;else{let{width:n,height:i}=d;n*=ut(a)*l,i*=ut(r)*l,d.scaleX&&(n*=d.scaleX,i*=d.scaleY),o=n*i>t.Platform.image.maxCacheSize||e.Export.running}return o?(i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(s.image.view,0,0,d.width,d.height),i.restore(),!0):(!s.style||s.sync||e.Export.running?ct(n,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>ht(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&ct(n,s,l),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ct,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,o,a,r;for(let l=0,d=i.length;l<d;l++)s=i[l].image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(s),s.loading&&(a||(a=n.__input&&n.__input[e]||[],a instanceof Array||(a=[a])),s.unload(i[l].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:q,getPatternData:Q,fillOrFitMode:F,clipMode:Y,repeatMode:j},{toPoint:pt}=t.AroundHelper,gt={},_t={};function wt(t,n,i){if(n){let s;for(let o=0,a=n.length;o<a;o++)s=n[o],"string"==typeof s?t.addColorStop(o/(a-1),e.ColorConvert.string(s,i)):t.addColorStop(s.offset,e.ColorConvert.string(s.color,i))}}const{getAngle:mt,getDistance:vt}=t.PointHelper,{get:yt,rotateOfOuter:xt,scaleOfOuter:bt}=t.MatrixHelper,{toPoint:Bt}=t.AroundHelper,Rt={},Et={};function St(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=mt(e,n);o=yt(),s?(bt(o,e,a/r*(i||1),1),xt(o,e,t+90)):(bt(o,e,1,a/r*(i||1)),xt(o,e,t))}return o}const{getDistance:Lt}=t.PointHelper,{toPoint:kt}=t.AroundHelper,Pt={},At={};const Ct={linearGradient:function(e,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=e;pt(i||"top",n,gt),pt(s||"bottom",n,_t);const l=t.Platform.canvas.createLinearGradient(gt.x,gt.y,_t.x,_t.y);wt(l,e.stops,r);const d={type:o,style:l};return a&&(d.blendMode=a),d},radialGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Bt(i||"center",n,Rt),Bt(s||"bottom",n,Et);const d=t.Platform.canvas.createRadialGradient(Rt.x,Rt.y,0,Rt.x,Rt.y,vt(Rt,Et));wt(d,e.stops,a);const c={type:o,style:d},h=St(n,Rt,Et,l,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;kt(i||"center",n,Pt),kt(s||"bottom",n,At);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Pt.x,Pt.y):t.Platform.canvas.createRadialGradient(Pt.x,Pt.y,0,Pt.x,Pt.y,Lt(Pt,At));wt(d,e.stops,a);const c={type:o,style:d},h=St(n,Pt,At,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:St},{copy:Wt,toOffsetOutBounds:Ot}=t.BoundsHelper,Tt={},Mt={};function It(e,n,i,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(Wt(Tt,e.bounds),Tt.x+=n.x-a.x,Tt.y+=n.y-a.y,i){const{matrix:t}=s;Tt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Tt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Tt.width*=i,Tt.height*=i}e.copyWorld(s.canvas,e.bounds,Tt)}else i&&(Wt(Tt,n),Tt.x-=n.width/2*(i-1),Tt.y-=n.height/2*(i-1),Tt.width*=i,Tt.height*=i),e.copyWorld(s.canvas,a,i?Tt:n)}const{toOffsetOutBounds:Dt}=t.BoundsHelper,zt={};const Ht={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ot(d,Mt),r.forEach(((r,g)=>{f.setWorldShadow(Mt.offsetX+r.x*h,Mt.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,It(f,Mt,s,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,o,"copy"),i=o),l?f.copyWorld(l,o,o,"destination-out"):f.copyWorld(n.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Dt(d,zt),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(zt.offsetX+r.x*h,zt.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,It(f,zt,s,n),f.restore(),l?(f.copyWorld(f,d,o,"copy"),f.copyWorld(l,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Ft}=t.LeafBoundsHelper;function Yt(t,e,n,i,s,o){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Gt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Gt(t,n,i,o);break;case"path":n.restore()}}function jt(t){return t.getSameCanvas(!1,!0)}function Gt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,o,a;const{children:r}=this;for(let l=0,d=r.length;l<d;l++)n=r[l],n.__.mask&&(a&&(Yt(this,a,t,s,i,o),i=s=null),"path"===n.__.mask?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=jt(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="alpha",i||(i=jt(t)),s||(s=jt(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Ft(n,e)||n.__render(s||t,e);Yt(this,a,t,s,i,o)};const Ut=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Vt=Ut+"_#~&*+\\=|≮≯≈≠=…",Xt=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Nt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const qt=Nt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Qt=Nt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Jt=Nt(Ut),Zt=Nt(Vt),$t=Nt("- —/~|┆·");var Kt;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(Kt||(Kt={}));const{Letter:te,Single:ee,Before:ne,After:ie,Symbol:se,Break:oe}=Kt;function ae(t){return qt[t]?te:$t[t]?oe:Qt[t]?ne:Jt[t]?ie:Zt[t]?se:Xt.test(t)?ee:te}const re={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function le(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:de}=re,{Letter:ce,Single:he,Before:ue,After:fe,Symbol:pe,Break:ge}=Kt;let _e,we,me,ve,ye,xe,be,Be,Re,Ee,Se,Le,ke,Pe,Ae,Ce,We,Oe=[];function Te(t,e){Re&&!Be&&(Be=Re),_e.data.push({char:t,width:e}),me+=e}function Me(){ve+=me,_e.width=me,we.words.push(_e),_e={data:[]},me=0}function Ie(){Pe&&(Ae.paraNumber++,we.paraStart=!0,Pe=!1),Re&&(we.startCharSize=Be,we.endCharSize=Re,Be=0),we.width=ve,Ce.width?de(we):We&&De(),Oe.push(we),we={words:[]},ve=0}function De(){ve>(Ae.maxWidth||0)&&(Ae.maxWidth=ve)}const ze=0,He=1,Fe=2;const{top:Ye,right:je,bottom:Ge,left:Ue}=t.Direction4;function Ve(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Xe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(o?(i=d[Ue],o-=d[je]+d[Ue]):n.autoSizeAlign||(i=d[Ue]),a?(s=d[Ye],a-=d[Ye]+d[Ge]):n.autoSizeAlign||(s=d[Ye]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Ae=e,Oe=e.rows,Ce=e.bounds,We=!Ce.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=t.Platform,{width:l,height:d}=Ce;if(l||d||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;Pe=!0,Se=null,Be=be=Re=me=ve=0,_e={data:[]},we={words:[]};for(let i=0,d=n.length;i<d;i++)xe=n[i],"\n"===xe?(me&&Me(),we.paraEnd=!0,Ie(),Pe=!0):(Ee=ae(xe),Ee===ce&&"none"!==a&&(xe=le(xe,a,!me)),be=r.measureText(xe).width,s&&(s<0&&(Re=be),be+=s),Le=Ee===he&&(Se===he||Se===ce)||Se===he&&Ee!==fe,ke=!(Ee!==ue&&Ee!==he||Se!==pe&&Se!==fe),ye=Pe&&o?l-o:l,t&&l&&ve+me+be>ye&&(e?(me&&Me(),ve&&Ie()):(ke||(ke=Ee===ce&&Se==fe),Le||ke||Ee===ge||Ee===ue||Ee===he||me+be>ye?(me&&Me(),ve&&Ie()):ve&&Ie()))," "===xe&&!0!==Pe&&ve+me===0||(Ee===ge?(" "===xe&&me&&Me(),Te(xe,be),Me()):Le||ke?(me&&Me(),Te(xe,be)):Te(xe,be)),Se=Ee);me&&Me(),ve&&Ie(),Oe.length>0&&(Oe[Oe.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ae.paraNumber++,ve=r.measureText(t).width,Oe.push({x:o||0,text:t,width:ve,paraStart:!0}),We&&De()}))}(c,e,n),d&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ve(e,"x",t[Ue]);break;case"right":Ve(e,"x",-t[je])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ve(e,"y",t[Ye]);break;case"bottom":Ve(e,"y",-t[Ge])}}(d,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=i,_=s*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,s),t.overflow=n.length;else if(g||h)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,v,y,x=p||h?p:t.maxWidth;for(let o=0,d=n.length;o<d;o++){if(m=n[o],m.x=u,m.width<p||m.width>p&&!r)switch(l){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=s,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,y=m.width,a<0&&(m.width<0?(y=-m.width+e.fontSize+a,v-=y,y+=e.fontSize):y-=a),v<i.x&&(i.x=v),y>i.width&&(i.width=y),r&&p&&p<y&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let l,d,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,d=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?ze:d>.01?He:Fe,t.isOverflow&&!r&&(t.textMode=!0),h===Fe?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,l=t.x,t.data=[],t.words.forEach((e=>{h===He?(u={char:"",x:l},l=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,l,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):l=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,l,t.data,t.isOverflow),!t.paraEnd&&d&&(l+=d,t.width+=d)}))),t.words=null)}))}(c,n,o),c.overflow&&function(e,n,i,s){if(!s)return;const{rows:o,overflow:a}=e;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+s-d;("none"===n.textWrap?o:[o[a-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Ne={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=n);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}},{setPoint:qe,addPoint:Qe,toBounds:Je}=t.TwoPointBoundsHelper;const Ze={export(e,n,i){this.running=!0;const s=t.FileHelper.fileType(n),o=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){$e||($e=new t.TaskProcessor);return new Promise((t=>{$e.add((()=>ht(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((a=>new Promise((r=>{const l=t=>{a(t),r(),this.running=!1},{toURL:d}=t.Platform,{download:c}=t.Platform.origin;if("json"===s)return o&&c(d(JSON.stringify(e.toJSON(i.json)),"text"),n),l({data:!!o||e.toJSON(i.json)});if("svg"===s)return o&&c(d(e.toSVG(),"svg"),n),l({data:!!o||e.toSVG()});const{leafer:h}=e;h?(Ke(e),h.waitViewCompleted((()=>ht(this,void 0,void 0,(function*(){let s,o,a=1,r=1;const{worldTransform:d,isLeafer:c,isFrame:u}=e,{slice:f,trim:p,onCanvas:g}=i,_=void 0===i.smooth?h.config.smooth:i.smooth,w=i.contextSettings||h.config.contextSettings,m=i.screenshot||e.isApp,v=c&&m&&void 0===i.fill?e.fill:i.fill,y=t.FileHelper.isOpaqueImage(n)||v,x=new t.Matrix;if(m)s=!0===m?c?h.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(c?"inner":"local");switch(a=d.scaleX,r=d.scaleY,t){case"inner":x.set(d);break;case"local":x.set(d).divide(e.localTransform),a/=e.scaleX,r/=e.scaleY;break;case"world":a=1,r=1;break;case"page":t=e.leafer;default:x.set(d).divide(e.getTransform(t));const n=t.worldTransform;a/=a/n.scaleX,r/=r/n.scaleY}s=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,s,b);let B=i.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:R,y:E,width:S,height:L}=new t.Bounds(s).scale(b.scaleX,b.scaleY),k={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-R,-E).withScale(1/a*b.scaleX,1/r*b.scaleY)};let P,A=t.Creator.canvas({width:Math.round(S),height:Math.round(L),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(P=e,P.__worldOpacity=0,e=h,k.bounds=A.bounds),A.save(),u&&void 0!==v){const t=e.get("fill");e.fill="",e.__render(A,k),e.fill=t}else e.__render(A,k);if(A.restore(),P&&P.__updateWorldOpacity(),p){o=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let o,a,r,l=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(o=l%n,a=(l-o)/n,r?Qe(r,o,a):qe(r={},o,a)),l++;const d=new t.Bounds;return Je(r,d),d.scale(1/e.pixelRatio).ceil()}(A);const e=A,{width:n,height:i}=o,s={x:0,y:0,width:n,height:i,pixelRatio:B};A=t.Creator.canvas(s),A.copyWorld(e,o,s)}y&&A.fillWorld(A.bounds,v||"#FFFFFF","destination-over"),g&&g(A);const C="canvas"===n?A:yield A.export(n,i);l({data:C,width:A.pixelWidth,height:A.pixelHeight,renderBounds:s,trimBounds:o})}))))):l({data:!1})}))))}};let $e;function Ke(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Ke(t)))}const tn=t.LeaferCanvasBase.prototype,en=t.Debug.get("@leafer-ui/export");tn.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},tn.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{en.error(t),i(null)}))}))},tn.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},tn.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{en.error(t),i(!1)}))}))},Object.assign(e.TextConvert,Xe),Object.assign(e.ColorConvert,Ne),Object.assign(e.Paint,W),Object.assign(e.PaintImage,ft),Object.assign(e.PaintGradient,Ct),Object.assign(e.Effect,Ht),Object.assign(e.Export,Ze);try{wx&&o(0,wx)}catch(t){}Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=n,exports.Renderer=y,exports.Watcher=a,exports.useCanvas=o,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]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!1}init(){const{config:e}=this;let n=e.view||e.canvas;n?("string"==typeof n?("#"!==n[0]&&(n="#"+n),this.viewSelect=t.Platform.miniapp.select(n)):n.fields?this.viewSelect=n:this.initView(n),this.viewSelect&&t.Platform.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(e){e?this.view=e.view||e:(e={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:n,height:i,pixelRatio:s}=this.config,a={width:n||e.width,height:i||e.height,pixelRatio:s};this.resize(a),this.context&&(this.viewSelect&&(t.Platform.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,n,i,s){this.context.roundRect(t,e,n,i,"number"==typeof s?[s]:s)}),t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(e){this.viewSelect&&t.Platform.miniapp.getBounds(this.viewSelect).then((t=>{this.clientBounds=t,e&&e()}))}startAutoLayout(e,n){this.resizeListener=n,e&&(this.checkSize=this.checkSize.bind(this),t.Platform.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:n}=this,i={width:t,height:e,pixelRatio:n};this.isSameSize(i)||this.emitResize(i)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,t.Platform.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}}const{mineType:i,fileType:s}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas:(t,e,i)=>{const s={type:"2d",width:t,height:e};return n.createOffscreenCanvas?n.createOffscreenCanvas(s):n.createOffScreenCanvas(s)},canvasToDataURL:(t,e,n)=>t.toDataURL(i(e),n),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(e,n,a)=>{let o=e.toDataURL(i(s(n)),a);return o=o.substring(o.indexOf("64,")+3),t.Platform.origin.download(o,n)},download:(e,i)=>new Promise(((s,a)=>{let o;i.includes("/")||(i=`${n.env.USER_DATA_PATH}/`+i,o=!0);const r=n.getFileSystemManager();r.writeFile({filePath:i,data:e,encoding:"base64",success(){o?t.Platform.miniapp.saveToAlbum(i).then((()=>{r.unlink({filePath:i}),s()})):s()},fail(t){a(t)}})})),loadImage:e=>new Promise(((n,i)=>{const s=t.Platform.canvas.view.createImage();s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)})),noRepeat:"repeat-x"},t.Platform.miniapp={select:t=>n.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const n=t[1];e({x:n.top,y:n.left,width:n.width,height:n.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const n=t[0];e({view:n.node,width:n.width,height:n.height})}))})),saveToAlbum:t=>new Promise((e=>{n.getSetting({success:i=>{i.authSetting["scope.writePhotosAlbum"]?n.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):n.authorize({scope:"scope.writePhotosAlbum",success:()=>{n.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){n.onWindowResize(t)},offWindowResize(t){n.offWindowResize(t)}},t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="miniapp",t.Platform.requestRender=function(e){const{view:n}=t.Platform.renderCanvas||t.Platform.canvas;n.requestAnimationFrame?n.requestAnimationFrame(e):setTimeout(e,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class o{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:r,updateBounds:l,updateAllWorldOpacity:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:h}=t.BranchHelper;const{worldBounds:u}=t.LeafBoundsHelper,f={x:0,y:0,width:1e5,height:1e5};class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,u)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(f):this.afterBounds.setListWithFn(t,u),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:g,updateAllChange:_}=t.LeafHelper,w=t.Debug.get("Layouter");class m{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:o,AFTER:u}=t.LayoutEvent,f=this.getBlocks(s);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(a,f,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(r(t,!0),e.add(t),t.isBranch&&c(t,e),h(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),h(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||l(i[t])}l(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&d(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(o,f,this.times)),i.emitEvent(new t.LayoutEvent(u,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,o,this.times)),m.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,o,this.times)),n.emitEvent(new t.LayoutEvent(a,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new p([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new p(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const v=t.Debug.get("Renderer");class y{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{n.isApp||n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return v.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),a=e.includes(this.target.__world),o=new t.Bounds(s);i.save(),a&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,a,o),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function x(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,a)}function b(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?E(t,!0,e,n):R(e,n);break;case"inside":B("inside",t,s,e,n);break;case"outside":B("outside",t,s,e,n)}}function B(t,e,n,i,s){const{__strokeWidth:a,__font:o}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*a,i.__),r.font=o,n?E(e,!0,i,r):R(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",x(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function R(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,a)}function E(t,n,i,s){let a;for(let o=0,r=t.length;o<r;o++)a=t[o],a.image&&e.PaintImage.checkImage(i,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),n?R(i,s):s.stroke(),s.restoreBlendMode()):n?R(i,s):s.stroke())}function S(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new o(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new y(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=m.fullLayout;const{getSpread:L,getOuterOf:P,getByMove:k,getIntersectData:A}=t.BoundsHelper;let C;function W(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:s}=i.__layout;switch(n.type){case"solid":let{type:a,blendMode:o,color:r,opacity:l}=n;return{type:a,blendMode:o,style:e.ColorConvert.string(r,l)};case"image":return e.PaintImage.image(i,t,n,s,!C||!C[n.url]);case"linear":return e.PaintGradient.linearGradient(n,s);case"radial":return e.PaintGradient.radialGradient(n,s);case"angular":return e.PaintGradient.conicGradient(n,s);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const O={compute:function(t,n){const i=n.__,s=[];let a,o=i.__input[t];o instanceof Array||(o=[o]),C=e.PaintImage.recycleImage(t,i);for(let e,i=0,a=o.length;i<a;i++)e=W(t,o[i],n),e&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(a=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=a:i.__pixelStroke=a},fill:function(t,e,n){n.fillStyle=t,e.__.__font?x(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let s;const{windingRule:a,__font:o}=n.__;for(let r=0,l=t.length;r<l;r++)s=t[r],s.image&&e.PaintImage.checkImage(n,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?x(n,i):a?i.fill(a):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?x(n,i):a?i.fill(a):i.fill(),i.restoreBlendMode()):o?x(n,i):a?i.fill(a):i.fill())},fillText:x,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)b(t,e,n);else switch(a){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&&S(e,n);break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const a=n.getSameCanvas(!0,!0);a.setStroke(t,2*s,i),e.__drawRenderPath(a),a.stroke(),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)b(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),E(t,!1,e,n),i.__useArrow&&S(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),E(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,i),E(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:b,drawTextStroke:R,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=i,a=r=s;else{const{renderShapeSpread:i}=t.__layout,h=A(i?L(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,s);o=e.bounds.getFitMatrix(h);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=P(s,o),a=k(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:o,bounds:a,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let T={};const{get:M,rotateOfOuter:I,translate:D,scaleOfOuter:z,scale:H,rotate:F}=t.MatrixHelper;function Y(t,e,n,i,s,a,o){const r=M();D(r,e.x+n,e.y+i),H(r,s,a),o&&I(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function j(t,e,n,i,s,a,o){const r=M();D(r,e.x+n,e.y+i),s&&H(r,s,a),o&&F(r,o),t.transform=r}function G(t,e,n,i,s,a,o,r,l,d){const c=M();if(l)if("center"===d)I(c,{x:n/2,y:i/2},l);else switch(F(c,l),l){case 90:D(c,i,0);break;case 180:D(c,n,i);break;case 270:D(c,0,n)}T.x=e.x+s,T.y=e.y+a,D(c,T.x,T.y),o&&z(c,T,o,r),t.transform=c}const{get:U,translate:V}=t.MatrixHelper,X=new t.Bounds,N={},q={};function Q(t,e,n,i){const{blendMode:s,sync:a}=n;s&&(t.blendMode=s),a&&(t.sync=a),t.data=J(n,i,e)}function J(e,n,i){let{width:s,height:a}=i;e.padding&&(n=X.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:o,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===s&&n.height===a,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?a:s,m=_?s:a;let v,y,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,q),v=q.scaleX,y=q.scaleY);else if(!p||u){const t=n.width/w,e=n.height/m;v=y="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-s*v)/2,b+=(n.height-a*y)/2}if(l){const e={x:x,y:b,width:w,height:m};v&&(e.width*=v,e.height*=y),t.AlignHelper.toPoint(l,e,n,N,!0),x+=N.x,b+=N.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(s=n.width,a=n.height);break;case"normal":case"clip":(x||b||v||u)&&j(g,n,x,b,v,y,u);break;case"repeat":(!p||v||u)&&G(g,n,s,a,x,b,v,y,u,l),f||(g.repeat="repeat");break;default:v&&Y(g,n,x,b,v,y,u)}return g.transform||(n.x||n.y)&&(g.transform=U(),V(g.transform,n.x,n.y)),v&&"stretch"!==r&&(g.scaleX=v,g.scaleY=y),g.width=s,g.height=a,o&&(g.opacity=o),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let Z,$=new t.Bounds;const{isSame:K}=t.BoundsHelper;function tt(t,e,n,i,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Q(s,i,n,a),!0}function et(e,n){st(e,t.ImageEvent.LOAD,n)}function nt(e,n){st(e,t.ImageEvent.LOADED,n)}function it(e,n,i){n.error=i,e.forceUpdate("surface"),st(e,t.ImageEvent.ERROR,n)}function st(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function at(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ot,scale:rt,copy:lt}=t.MatrixHelper,{ceil:dt,abs:ct}=Math;function ht(e,n,i){let{scaleX:s,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=s+"-"+a+"-"+i;if(n.patternId===o||e.destroyed)return!1;{s=ct(s),a=ct(a);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=ot(),lt(d,g),rt(d,1/u,1/f),s*=u,a*=f),s*=i,a*=i,c*=s,h*=a;const w=c*h;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(l=Math.sqrt(w/m)),l&&(s/=l,a/=l,c/=l,h/=l),u&&(s/=u,a/=f),(g||1!==s||1!==a)&&(d||(d=ot(),g&<(d,g)),rt(d,1/s,1/a));const v=e.getCanvas(dt(c)||1,dt(h)||1,p),y=e.getPattern(v,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=y,n.patternId=o,!0}}function ut(t,e,n,i){return new(n||(n=Promise))((function(s,a){function o(t){try{l(i.next(t))}catch(t){a(t)}}function r(t){try{l(i.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ft}=Math;const pt={image:function(e,n,i,s,a){let o,r;const l=t.ImageManager.get(i);return Z&&i===Z.paint&&K(s,Z.boxBounds)?o=Z.leafPaint:(o={type:i.type,image:l},Z=l.use>1?{leafPaint:o,paint:i,boxBounds:$.set(s)}:null),(a||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(tt(e,n,i,l,o,s),a&&(et(e,r),nt(e,r))):l.error?a&&it(e,r,l.error):(a&&(at(e,!0),et(e,r)),o.loadId=l.load((()=>{at(e,!1),e.destroyed||(tt(e,n,i,l,o,s)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),nt(e,r)),o.loadId=null}),(t=>{at(e,!1),it(e,r,t),o.loadId=null}))),o},checkImage:function(n,i,s,a){const{scaleX:o,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i;if(!s.data||s.patternId===o+"-"+r+"-"+l&&!e.Export.running)return!1;{const{data:d}=s;if(a)if(d.repeat)a=!1;else{let{width:n,height:i}=d;n*=ft(o)*l,i*=ft(r)*l,d.scaleX&&(n*=d.scaleX,i*=d.scaleY),a=n*i>t.Platform.image.maxCacheSize||e.Export.running}return a?(i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(s.image.view,0,0,d.width,d.height),i.restore(),!0):(!s.style||s.sync||e.Export.running?ht(n,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>ut(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&ht(n,s,l),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ht,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,a,o,r;for(let l=0,d=i.length;l<d;l++)s=i[l].image,r=s&&s.url,r&&(a||(a={}),a[r]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),s.unload(i[l].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:Q,getPatternData:J,fillOrFitMode:Y,clipMode:j,repeatMode:G},{toPoint:gt}=t.AroundHelper,_t={},wt={};function mt(t,n,i){if(n){let s;for(let a=0,o=n.length;a<o;a++)s=n[a],"string"==typeof s?t.addColorStop(a/(o-1),e.ColorConvert.string(s,i)):t.addColorStop(s.offset,e.ColorConvert.string(s.color,i))}}const{getAngle:vt,getDistance:yt}=t.PointHelper,{get:xt,rotateOfOuter:bt,scaleOfOuter:Bt}=t.MatrixHelper,{toPoint:Rt}=t.AroundHelper,Et={},St={};function Lt(t,e,n,i,s){let a;const{width:o,height:r}=t;if(o!==r||i){const t=vt(e,n);a=xt(),s?(Bt(a,e,o/r*(i||1),1),bt(a,e,t+90)):(Bt(a,e,1,o/r*(i||1)),bt(a,e,t))}return a}const{getDistance:Pt}=t.PointHelper,{toPoint:kt}=t.AroundHelper,At={},Ct={};const Wt={linearGradient:function(e,n){let{from:i,to:s,type:a,blendMode:o,opacity:r}=e;gt(i||"top",n,_t),gt(s||"bottom",n,wt);const l=t.Platform.canvas.createLinearGradient(_t.x,_t.y,wt.x,wt.y);mt(l,e.stops,r);const d={type:a,style:l};return o&&(d.blendMode=o),d},radialGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:l}=e;Rt(i||"center",n,Et),Rt(s||"bottom",n,St);const d=t.Platform.canvas.createRadialGradient(Et.x,Et.y,0,Et.x,Et.y,yt(Et,St));mt(d,e.stops,o);const c={type:a,style:d},h=Lt(n,Et,St,l,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:l}=e;kt(i||"center",n,At),kt(s||"bottom",n,Ct);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,At.x,At.y):t.Platform.canvas.createRadialGradient(At.x,At.y,0,At.x,At.y,Pt(At,Ct));mt(d,e.stops,o);const c={type:a,style:d},h=Lt(n,At,Ct,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:Lt},{copy:Ot,toOffsetOutBounds:Tt}=t.BoundsHelper,Mt={},It={};function Dt(e,n,i,s){const{bounds:a,shapeBounds:o}=s;if(t.Platform.fullImageShadow){if(Ot(Mt,e.bounds),Mt.x+=n.x-o.x,Mt.y+=n.y-o.y,i){const{matrix:t}=s;Mt.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),Mt.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),Mt.width*=i,Mt.height*=i}e.copyWorld(s.canvas,e.bounds,Mt)}else i&&(Ot(Mt,n),Mt.x-=n.width/2*(i-1),Mt.y-=n.height/2*(i-1),Mt.width*=i,Mt.height*=i),e.copyWorld(s.canvas,o,i?Mt:n)}const{toOffsetOutBounds:zt}=t.BoundsHelper,Ht={};const Ft={shadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Tt(d,It),r.forEach(((r,g)=>{f.setWorldShadow(It.offsetX+r.x*h,It.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Dt(f,It,s,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,a,"copy"),i=a),l?f.copyWorld(l,a,a,"destination-out"):f.copyWorld(n.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;zt(d,Ht),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Ht.offsetX+r.x*h,Ht.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Dt(f,Ht,s,n),f.restore(),l?(f.copyWorld(f,d,a,"copy"),f.copyWorld(l,a,a,"source-out"),i=a):(f.copyWorld(n.canvas,c,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Yt}=t.LeafBoundsHelper;function jt(t,e,n,i,s,a){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Ut(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Ut(t,n,i,a);break;case"path":n.restore()}}function Gt(t){return t.getSameCanvas(!1,!0)}function Ut(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,a,o,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],r=n.__.mask,r&&(o&&(jt(this,o,t,s,i,a),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(o="opacity-path",a=n.opacity,s||(s=Gt(t))):(o="path",t.save()),n.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",i||(i=Gt(t)),s||(s=Gt(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Yt(n,e)||n.__render(s||t,e);jt(this,o,t,s,i,a)};const Vt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Xt=Vt+"_#~&*+\\=|≮≯≈≠=…",Nt=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function qt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Qt=qt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Jt=qt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Zt=qt(Vt),$t=qt(Xt),Kt=qt("- —/~|┆·");var te;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(te||(te={}));const{Letter:ee,Single:ne,Before:ie,After:se,Symbol:ae,Break:oe}=te;function re(t){return Qt[t]?ee:Kt[t]?oe:Jt[t]?ie:Zt[t]?se:$t[t]?ae:Nt.test(t)?ne:ee}const le={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function de(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ce}=le,{Letter:he,Single:ue,Before:fe,After:pe,Symbol:ge,Break:_e}=te;let we,me,ve,ye,xe,be,Be,Re,Ee,Se,Le,Pe,ke,Ae,Ce,We,Oe,Te=[];function Me(t,e){Ee&&!Re&&(Re=Ee),we.data.push({char:t,width:e}),ve+=e}function Ie(){ye+=ve,we.width=ve,me.words.push(we),we={data:[]},ve=0}function De(){Ae&&(Ce.paraNumber++,me.paraStart=!0,Ae=!1),Ee&&(me.startCharSize=Re,me.endCharSize=Ee,Re=0),me.width=ye,We.width?ce(me):Oe&&ze(),Te.push(me),me={words:[]},ye=0}function ze(){ye>(Ce.maxWidth||0)&&(Ce.maxWidth=ye)}const He=0,Fe=1,Ye=2;const{top:je,right:Ge,bottom:Ue,left:Ve}=t.Direction4;function Xe(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Ne={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,a=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(a?(i=d[Ve],a-=d[Ge]+d[Ve]):n.autoSizeAlign||(i=d[Ve]),o?(s=d[je],o-=d[je]+d[Ue]):n.autoSizeAlign||(s=d[je]));const c={bounds:{x:i,y:s,width:a,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Ce=e,Te=e.rows,We=e.bounds,Oe=!We.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=i,{canvas:r}=t.Platform,{width:l,height:d}=We;if(l||d||s||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;Ae=!0,Le=null,Re=Be=Ee=ve=ye=0,we={data:[]},me={words:[]};for(let i=0,d=n.length;i<d;i++)be=n[i],"\n"===be?(ve&&Ie(),me.paraEnd=!0,De(),Ae=!0):(Se=re(be),Se===he&&"none"!==o&&(be=de(be,o,!ve)),Be=r.measureText(be).width,s&&(s<0&&(Ee=Be),Be+=s),Pe=Se===ue&&(Le===ue||Le===he)||Le===ue&&Se!==pe,ke=!(Se!==fe&&Se!==ue||Le!==ge&&Le!==pe),xe=Ae&&a?l-a:l,t&&l&&ye+ve+Be>xe&&(e?(ve&&Ie(),ye&&De()):(ke||(ke=Se===he&&Le==pe),Pe||ke||Se===_e||Se===fe||Se===ue||ve+Be>xe?(ve&&Ie(),ye&&De()):ye&&De()))," "===be&&!0!==Ae&&ye+ve===0||(Se===_e?(" "===be&&ve&&Ie(),Me(be,Be),Ie()):Pe||ke?(ve&&Ie(),Me(be,Be)):Me(be,Be)),Le=Se);ve&&Ie(),ye&&De(),Te.length>0&&(Te[Te.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ce.paraNumber++,ye=r.measureText(t).width,Te.push({x:a||0,text:t,width:ye,paraStart:!0}),Oe&&ze()}))}(c,e,n),d&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Xe(e,"x",t[Ve]);break;case"right":Xe(e,"x",-t[Ge])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Xe(e,"y",t[je]);break;case"bottom":Xe(e,"y",-t[Ue])}}(d,c,n,a,o),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=i,_=s*n.length+(c?c*(t.paraNumber-1):0),w=a;if(r&&_>g)_=Math.max(g,s),t.overflow=n.length;else if(g||h)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,v,y,x=p||h?p:t.maxWidth;for(let a=0,d=n.length;a<d;a++){if(m=n[a],m.x=u,m.width<p||m.width>p&&!r)switch(l){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&c&&a>0&&(w+=c),m.y=w,w+=s,t.overflow>a&&w>_&&(m.isOverflow=!0,t.overflow=a+1),v=m.x,y=m.width,o<0&&(m.width<0?(y=-m.width+e.fontSize+o,v-=y,y+=e.fontSize):y-=o),v<i.x&&(i.x=v),y>i.width&&(i.width=y),r&&p&&p<y&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let l,d,c,h,u;s.forEach((t=>{t.words&&(c=o&&t.paraStart?o:0,d=n&&"justify"===a&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?He:d>.01?Fe:Ye,t.isOverflow&&!r&&(t.textMode=!0),h===Ye?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,l=t.x,t.data=[],t.words.forEach((e=>{h===Fe?(u={char:"",x:l},l=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,l,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):l=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,l,t.data,t.isOverflow),!t.paraEnd&&d&&(l+=d,t.width+=d)}))),t.words=null)}))}(c,n,a),c.overflow&&function(e,n,i,s){if(!s)return;const{rows:a,overflow:o}=e;let{textOverflow:r}=n;if(a.splice(o),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+s-d;("none"===n.textWrap?a:[a[o-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n,i,a),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const qe={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=n);const a=t.r+","+t.g+","+t.b;return 1===s?"rgb("+a+")":"rgba("+a+","+s+")"}},{setPoint:Qe,addPoint:Je,toBounds:Ze}=t.TwoPointBoundsHelper;const $e={export(e,n,i){this.running=!0;const s=t.FileHelper.fileType(n),a=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){Ke||(Ke=new t.TaskProcessor);return new Promise((t=>{Ke.add((()=>ut(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((o=>new Promise((r=>{const l=t=>{o(t),r(),this.running=!1},{toURL:d}=t.Platform,{download:c}=t.Platform.origin;if("json"===s)return a&&c(d(JSON.stringify(e.toJSON(i.json)),"text"),n),l({data:!!a||e.toJSON(i.json)});if("svg"===s)return a&&c(d(e.toSVG(),"svg"),n),l({data:!!a||e.toSVG()});const{leafer:h}=e;h?(tn(e),h.waitViewCompleted((()=>ut(this,void 0,void 0,(function*(){let s,a,o=1,r=1;const{worldTransform:d,isLeafer:c,isFrame:u}=e,{slice:f,trim:p,onCanvas:g}=i,_=void 0===i.smooth?h.config.smooth:i.smooth,w=i.contextSettings||h.config.contextSettings,m=i.screenshot||e.isApp,v=c&&m&&void 0===i.fill?e.fill:i.fill,y=t.FileHelper.isOpaqueImage(n)||v,x=new t.Matrix;if(m)s=!0===m?c?h.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(c?"inner":"local");switch(o=d.scaleX,r=d.scaleY,t){case"inner":x.set(d);break;case"local":x.set(d).divide(e.localTransform),o/=e.scaleX,r/=e.scaleY;break;case"world":o=1,r=1;break;case"page":t=e.leafer;default:x.set(d).divide(e.getTransform(t));const n=t.worldTransform;o/=o/n.scaleX,r/=r/n.scaleY}s=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,s,b);let B=i.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:R,y:E,width:S,height:L}=new t.Bounds(s).scale(b.scaleX,b.scaleY),P={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-R,-E).withScale(1/o*b.scaleX,1/r*b.scaleY)};let k,A=t.Creator.canvas({width:Math.round(S),height:Math.round(L),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(k=e,k.__worldOpacity=0,e=h,P.bounds=A.bounds),A.save(),u&&void 0!==v){const t=e.get("fill");e.fill="",e.__render(A,P),e.fill=t}else e.__render(A,P);if(A.restore(),k&&k.__updateWorldOpacity(),p){a=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let a,o,r,l=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=l%n,o=(l-a)/n,r?Je(r,a,o):Qe(r={},a,o)),l++;const d=new t.Bounds;return Ze(r,d),d.scale(1/e.pixelRatio).ceil()}(A);const e=A,{width:n,height:i}=a,s={x:0,y:0,width:n,height:i,pixelRatio:B};A=t.Creator.canvas(s),A.copyWorld(e,a,s)}y&&A.fillWorld(A.bounds,v||"#FFFFFF","destination-over"),g&&g(A);const C="canvas"===n?A:yield A.export(n,i);l({data:C,width:A.pixelWidth,height:A.pixelHeight,renderBounds:s,trimBounds:a})}))))):l({data:!1})}))))}};let Ke;function tn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>tn(t)))}const en=t.LeaferCanvasBase.prototype,nn=t.Debug.get("@leafer-ui/export");en.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},en.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{nn.error(t),i(null)}))}))},en.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},en.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{nn.error(t),i(!1)}))}))},Object.assign(e.TextConvert,Ne),Object.assign(e.ColorConvert,qe),Object.assign(e.Paint,O),Object.assign(e.PaintImage,pt),Object.assign(e.PaintGradient,Wt),Object.assign(e.Effect,Ft),Object.assign(e.Export,$e);try{wx&&a(0,wx)}catch(t){}Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=n,exports.Renderer=y,exports.Watcher=o,exports.useCanvas=a,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]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|
package/dist/miniapp.module.js
CHANGED
|
@@ -108,7 +108,7 @@ const MathHelper = {
|
|
|
108
108
|
return rotation - oldRotation;
|
|
109
109
|
},
|
|
110
110
|
float(num, maxLength) {
|
|
111
|
-
const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
|
|
111
|
+
const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
|
|
112
112
|
num = round(num * a) / a;
|
|
113
113
|
return num === -0 ? 0 : num;
|
|
114
114
|
},
|
|
@@ -1411,14 +1411,13 @@ const UICreator = {
|
|
|
1411
1411
|
list: {},
|
|
1412
1412
|
register(UI) {
|
|
1413
1413
|
const { __tag: tag } = UI.prototype;
|
|
1414
|
-
if (list$1[tag])
|
|
1414
|
+
if (list$1[tag])
|
|
1415
1415
|
debug$c.repeat(tag);
|
|
1416
|
-
|
|
1417
|
-
else {
|
|
1418
|
-
list$1[tag] = UI;
|
|
1419
|
-
}
|
|
1416
|
+
list$1[tag] = UI;
|
|
1420
1417
|
},
|
|
1421
1418
|
get(tag, data, x, y, width, height) {
|
|
1419
|
+
if (!list$1[tag])
|
|
1420
|
+
debug$c.error('not register ' + tag);
|
|
1422
1421
|
const ui = new list$1[tag](data);
|
|
1423
1422
|
if (x !== undefined) {
|
|
1424
1423
|
ui.x = x;
|
|
@@ -1442,7 +1441,7 @@ const EventCreator = {
|
|
|
1442
1441
|
Object.keys(Event).forEach(key => {
|
|
1443
1442
|
name = Event[key];
|
|
1444
1443
|
if (typeof name === 'string')
|
|
1445
|
-
nameList[name]
|
|
1444
|
+
nameList[name] && debug$b.repeat(name), nameList[name] = Event;
|
|
1446
1445
|
});
|
|
1447
1446
|
},
|
|
1448
1447
|
changeName(oldName, newName) {
|
|
@@ -1644,7 +1643,7 @@ class LeafData {
|
|
|
1644
1643
|
const t = this;
|
|
1645
1644
|
if (t.blendMode === 'pass-through') {
|
|
1646
1645
|
const leaf = this.__leaf;
|
|
1647
|
-
if ((t.opacity < 1 && leaf.isBranch) || leaf.__hasEraser || t.eraser) {
|
|
1646
|
+
if ((t.opacity < 1 && (leaf.isBranch || t.__hasMultiPaint)) || leaf.__hasEraser || t.eraser) {
|
|
1648
1647
|
t.__single = true;
|
|
1649
1648
|
}
|
|
1650
1649
|
else if (t.__single) {
|
|
@@ -2042,8 +2041,9 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2042
2041
|
takeCanvas = this.getSameCanvas();
|
|
2043
2042
|
takeCanvas.copyWorld(this);
|
|
2044
2043
|
}
|
|
2045
|
-
|
|
2046
|
-
|
|
2044
|
+
const s = this.size;
|
|
2045
|
+
DataHelper.copyAttrs(s, size, canvasSizeAttrs);
|
|
2046
|
+
canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
|
|
2047
2047
|
this.bounds = new Bounds(0, 0, this.width, this.height);
|
|
2048
2048
|
if (this.context && !this.unreal) {
|
|
2049
2049
|
this.updateViewSize();
|
|
@@ -2157,6 +2157,17 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2157
2157
|
if (!onlyResetTransform)
|
|
2158
2158
|
this.useWorldTransform();
|
|
2159
2159
|
}
|
|
2160
|
+
useGrayscaleAlpha(bounds) {
|
|
2161
|
+
this.setTempBounds(bounds, true, true);
|
|
2162
|
+
let alpha, pixel;
|
|
2163
|
+
const { context } = this, imageData = context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height), { data } = imageData;
|
|
2164
|
+
for (let i = 0, len = data.length; i < len; i += 4) {
|
|
2165
|
+
pixel = data[i] * 0.299 + data[i + 1] * 0.587 + data[i + 2] * 0.114;
|
|
2166
|
+
if (alpha = data[i + 3])
|
|
2167
|
+
data[i + 3] = alpha === 255 ? pixel : alpha * (pixel / 255);
|
|
2168
|
+
}
|
|
2169
|
+
context.putImageData(imageData, tempBounds$1.x, tempBounds$1.y);
|
|
2170
|
+
}
|
|
2160
2171
|
useMask(maskCanvas, fromBounds, toBounds) {
|
|
2161
2172
|
this.copyWorld(maskCanvas, fromBounds, toBounds, 'destination-in');
|
|
2162
2173
|
}
|
|
@@ -2167,7 +2178,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2167
2178
|
if (blendMode)
|
|
2168
2179
|
this.blendMode = blendMode;
|
|
2169
2180
|
this.fillStyle = color;
|
|
2170
|
-
|
|
2181
|
+
this.setTempBounds(bounds);
|
|
2171
2182
|
this.fillRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2172
2183
|
if (blendMode)
|
|
2173
2184
|
this.blendMode = 'source-over';
|
|
@@ -2176,22 +2187,18 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2176
2187
|
if (blendMode)
|
|
2177
2188
|
this.blendMode = blendMode;
|
|
2178
2189
|
this.strokeStyle = color;
|
|
2179
|
-
|
|
2190
|
+
this.setTempBounds(bounds);
|
|
2180
2191
|
this.strokeRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2181
2192
|
if (blendMode)
|
|
2182
2193
|
this.blendMode = 'source-over';
|
|
2183
2194
|
}
|
|
2184
2195
|
clearWorld(bounds, ceilPixel) {
|
|
2185
|
-
|
|
2186
|
-
if (ceilPixel)
|
|
2187
|
-
tempBounds$1.ceil();
|
|
2196
|
+
this.setTempBounds(bounds, ceilPixel);
|
|
2188
2197
|
this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2189
2198
|
}
|
|
2190
2199
|
clipWorld(bounds, ceilPixel) {
|
|
2191
2200
|
this.beginPath();
|
|
2192
|
-
|
|
2193
|
-
if (ceilPixel)
|
|
2194
|
-
tempBounds$1.ceil();
|
|
2201
|
+
this.setTempBounds(bounds, ceilPixel);
|
|
2195
2202
|
this.rect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
2196
2203
|
this.clip();
|
|
2197
2204
|
}
|
|
@@ -2199,6 +2206,14 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2199
2206
|
const { pixelRatio } = this;
|
|
2200
2207
|
this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
|
|
2201
2208
|
}
|
|
2209
|
+
setTempBounds(bounds, ceil, intersect) {
|
|
2210
|
+
tempBounds$1.set(bounds);
|
|
2211
|
+
if (intersect)
|
|
2212
|
+
tempBounds$1.intersect(this.bounds);
|
|
2213
|
+
tempBounds$1.scale(this.pixelRatio);
|
|
2214
|
+
if (ceil)
|
|
2215
|
+
tempBounds$1.ceil();
|
|
2216
|
+
}
|
|
2202
2217
|
isSameSize(size) {
|
|
2203
2218
|
return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
|
|
2204
2219
|
}
|
|
@@ -4150,20 +4165,17 @@ const LeafHelper = {
|
|
|
4150
4165
|
}
|
|
4151
4166
|
return true;
|
|
4152
4167
|
},
|
|
4153
|
-
moveWorld(t, x, y = 0, isInnerPoint) {
|
|
4168
|
+
moveWorld(t, x, y = 0, isInnerPoint, transition) {
|
|
4154
4169
|
const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
|
|
4155
4170
|
isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
|
|
4156
|
-
L.moveLocal(t, local.x, local.y);
|
|
4171
|
+
L.moveLocal(t, local.x, local.y, transition);
|
|
4157
4172
|
},
|
|
4158
|
-
moveLocal(t, x, y = 0) {
|
|
4159
|
-
if (typeof x === 'object')
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
t.x += x;
|
|
4165
|
-
t.y += y;
|
|
4166
|
-
}
|
|
4173
|
+
moveLocal(t, x, y = 0, transition) {
|
|
4174
|
+
if (typeof x === 'object')
|
|
4175
|
+
y = x.y, x = x.x;
|
|
4176
|
+
x += t.x;
|
|
4177
|
+
y += t.y;
|
|
4178
|
+
transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
|
|
4167
4179
|
},
|
|
4168
4180
|
zoomOfWorld(t, origin, scaleX, scaleY, resize) {
|
|
4169
4181
|
L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
|
|
@@ -5212,13 +5224,14 @@ const BranchRender = {
|
|
|
5212
5224
|
this.__.__checkSingle();
|
|
5213
5225
|
},
|
|
5214
5226
|
__render(canvas, options) {
|
|
5227
|
+
this.__nowWorld = this.__getNowWorld(options);
|
|
5215
5228
|
if (this.__worldOpacity) {
|
|
5216
5229
|
if (this.__.__single) {
|
|
5217
5230
|
if (this.__.eraser === 'path')
|
|
5218
5231
|
return this.__renderEraser(canvas, options);
|
|
5219
5232
|
const tempCanvas = canvas.getSameCanvas(false, true);
|
|
5220
5233
|
this.__renderBranch(tempCanvas, options);
|
|
5221
|
-
const nowWorld = this.
|
|
5234
|
+
const nowWorld = this.__nowWorld;
|
|
5222
5235
|
canvas.opacity = this.__.opacity;
|
|
5223
5236
|
canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, this.__.__blendMode, true);
|
|
5224
5237
|
tempCanvas.recycle(nowWorld);
|
|
@@ -5542,11 +5555,11 @@ let Leaf = class Leaf {
|
|
|
5542
5555
|
transform(matrix, resize) {
|
|
5543
5556
|
transform(this, matrix, resize);
|
|
5544
5557
|
}
|
|
5545
|
-
move(x, y) {
|
|
5546
|
-
moveLocal(this, x, y);
|
|
5558
|
+
move(x, y, transition) {
|
|
5559
|
+
moveLocal(this, x, y, transition);
|
|
5547
5560
|
}
|
|
5548
|
-
moveInner(x, y) {
|
|
5549
|
-
moveWorld(this, x, y, true);
|
|
5561
|
+
moveInner(x, y, transition) {
|
|
5562
|
+
moveWorld(this, x, y, true, transition);
|
|
5550
5563
|
}
|
|
5551
5564
|
scaleOf(origin, scaleX, scaleY, resize) {
|
|
5552
5565
|
zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
|
|
@@ -5560,8 +5573,8 @@ let Leaf = class Leaf {
|
|
|
5560
5573
|
transformWorld(worldTransform, resize) {
|
|
5561
5574
|
transformWorld(this, worldTransform, resize);
|
|
5562
5575
|
}
|
|
5563
|
-
moveWorld(x, y) {
|
|
5564
|
-
moveWorld(this, x, y);
|
|
5576
|
+
moveWorld(x, y, transition) {
|
|
5577
|
+
moveWorld(this, x, y, false, transition);
|
|
5565
5578
|
}
|
|
5566
5579
|
scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
|
|
5567
5580
|
zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
|
|
@@ -5959,7 +5972,7 @@ class LeafLevelList {
|
|
|
5959
5972
|
}
|
|
5960
5973
|
}
|
|
5961
5974
|
|
|
5962
|
-
const version = "1.0
|
|
5975
|
+
const version = "1.1.0";
|
|
5963
5976
|
|
|
5964
5977
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5965
5978
|
get allowBackgroundColor() { return false; }
|
|
@@ -6072,7 +6085,7 @@ function useCanvas(_canvasType, app) {
|
|
|
6072
6085
|
Platform.origin = {
|
|
6073
6086
|
createCanvas: (width, height, _format) => {
|
|
6074
6087
|
const data = { type: '2d', width, height };
|
|
6075
|
-
app.createOffscreenCanvas ? app.createOffscreenCanvas(data) : app.createOffScreenCanvas(data);
|
|
6088
|
+
return app.createOffscreenCanvas ? app.createOffscreenCanvas(data) : app.createOffScreenCanvas(data);
|
|
6076
6089
|
},
|
|
6077
6090
|
canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
|
|
6078
6091
|
canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, { quality }),
|
|
@@ -6183,7 +6196,7 @@ function useCanvas(_canvasType, app) {
|
|
|
6183
6196
|
}
|
|
6184
6197
|
Platform.name = 'miniapp';
|
|
6185
6198
|
Platform.requestRender = function (render) {
|
|
6186
|
-
const { view } =
|
|
6199
|
+
const { view } = Platform.renderCanvas || Platform.canvas;
|
|
6187
6200
|
view.requestAnimationFrame ? view.requestAnimationFrame(render) : setTimeout(render, 16);
|
|
6188
6201
|
};
|
|
6189
6202
|
defineKey(Platform, 'devicePixelRatio', { get() { return Math.max(1, wx.getSystemInfoSync().pixelRatio); } });
|
|
@@ -6568,7 +6581,8 @@ class Renderer {
|
|
|
6568
6581
|
this.totalBounds = new Bounds();
|
|
6569
6582
|
debug$3.log(target.innerName, '--->');
|
|
6570
6583
|
try {
|
|
6571
|
-
target.
|
|
6584
|
+
if (!target.isApp)
|
|
6585
|
+
target.app.emit(RenderEvent.CHILD_START, target);
|
|
6572
6586
|
this.emitRender(RenderEvent.START);
|
|
6573
6587
|
this.renderOnce(callback);
|
|
6574
6588
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -6849,6 +6863,12 @@ class UIData extends LeafData {
|
|
|
6849
6863
|
return strokeWidth;
|
|
6850
6864
|
}
|
|
6851
6865
|
get __hasStroke() { return this.stroke && this.strokeWidth; }
|
|
6866
|
+
get __hasMultiPaint() {
|
|
6867
|
+
const t = this;
|
|
6868
|
+
if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
|
|
6869
|
+
return true;
|
|
6870
|
+
return t.fill && this.__hasStroke;
|
|
6871
|
+
}
|
|
6852
6872
|
get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
|
|
6853
6873
|
get __autoWidth() { return !this._width; }
|
|
6854
6874
|
get __autoHeight() { return !this._height; }
|
|
@@ -7218,9 +7238,8 @@ const RectRender = {
|
|
|
7218
7238
|
canvas.strokeRect(half, half, width, height);
|
|
7219
7239
|
canvas.restore();
|
|
7220
7240
|
}
|
|
7221
|
-
else
|
|
7241
|
+
else
|
|
7222
7242
|
canvas.strokeRect(half, half, width, height);
|
|
7223
|
-
}
|
|
7224
7243
|
break;
|
|
7225
7244
|
case 'outside':
|
|
7226
7245
|
canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
|
|
@@ -7250,11 +7269,15 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7250
7269
|
super(data);
|
|
7251
7270
|
}
|
|
7252
7271
|
reset(_data) { }
|
|
7253
|
-
set(data,
|
|
7254
|
-
if (
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7272
|
+
set(data, transition) {
|
|
7273
|
+
if (transition) {
|
|
7274
|
+
if (transition === 'temp') {
|
|
7275
|
+
this.lockNormalStyle = true;
|
|
7276
|
+
Object.assign(this, data);
|
|
7277
|
+
this.lockNormalStyle = false;
|
|
7278
|
+
}
|
|
7279
|
+
else
|
|
7280
|
+
this.animate(data, transition);
|
|
7258
7281
|
}
|
|
7259
7282
|
else
|
|
7260
7283
|
Object.assign(this, data);
|
|
@@ -7445,6 +7468,15 @@ __decorate([
|
|
|
7445
7468
|
__decorate([
|
|
7446
7469
|
boundsType(0)
|
|
7447
7470
|
], UI.prototype, "padding", void 0);
|
|
7471
|
+
__decorate([
|
|
7472
|
+
boundsType(false)
|
|
7473
|
+
], UI.prototype, "lockRatio", void 0);
|
|
7474
|
+
__decorate([
|
|
7475
|
+
boundsType()
|
|
7476
|
+
], UI.prototype, "widthRange", void 0);
|
|
7477
|
+
__decorate([
|
|
7478
|
+
boundsType()
|
|
7479
|
+
], UI.prototype, "heightRange", void 0);
|
|
7448
7480
|
__decorate([
|
|
7449
7481
|
dataType(false)
|
|
7450
7482
|
], UI.prototype, "draggable", void 0);
|
|
@@ -7555,17 +7587,17 @@ let Group = class Group extends UI {
|
|
|
7555
7587
|
if (!this.children)
|
|
7556
7588
|
this.children = [];
|
|
7557
7589
|
}
|
|
7558
|
-
set(data,
|
|
7590
|
+
set(data, transition) {
|
|
7559
7591
|
if (data.children) {
|
|
7560
7592
|
const { children } = data;
|
|
7561
7593
|
delete data.children;
|
|
7562
7594
|
this.children ? this.clear() : this.__setBranch();
|
|
7563
|
-
super.set(data,
|
|
7595
|
+
super.set(data, transition);
|
|
7564
7596
|
children.forEach(child => this.add(child));
|
|
7565
7597
|
data.children = children;
|
|
7566
7598
|
}
|
|
7567
7599
|
else
|
|
7568
|
-
super.set(data,
|
|
7600
|
+
super.set(data, transition);
|
|
7569
7601
|
}
|
|
7570
7602
|
toJSON(options) {
|
|
7571
7603
|
const data = super.toJSON(options);
|
|
@@ -7678,8 +7710,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7678
7710
|
}
|
|
7679
7711
|
onInit() { }
|
|
7680
7712
|
initType(_type) { }
|
|
7681
|
-
set(data) {
|
|
7682
|
-
this.waitInit(() => { super.set(data); });
|
|
7713
|
+
set(data, transition) {
|
|
7714
|
+
this.waitInit(() => { super.set(data, transition); });
|
|
7683
7715
|
}
|
|
7684
7716
|
start() {
|
|
7685
7717
|
clearTimeout(this.__startTimer);
|
|
@@ -7736,8 +7768,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7736
7768
|
__onResize(event) {
|
|
7737
7769
|
this.emitEvent(event);
|
|
7738
7770
|
DataHelper.copyAttrs(this.__, event, canvasSizeAttrs);
|
|
7739
|
-
if (!event.width || !event.height)
|
|
7740
|
-
debug$1.warn('w = 0 or h = 0');
|
|
7741
7771
|
setTimeout(() => { if (this.canvasManager)
|
|
7742
7772
|
this.canvasManager.clearRecycled(); }, 0);
|
|
7743
7773
|
}
|
|
@@ -8062,9 +8092,6 @@ __decorate([
|
|
|
8062
8092
|
__decorate([
|
|
8063
8093
|
dataType(false)
|
|
8064
8094
|
], Box.prototype, "resizeChildren", void 0);
|
|
8065
|
-
__decorate([
|
|
8066
|
-
dataType(false)
|
|
8067
|
-
], Box.prototype, "textBox", void 0);
|
|
8068
8095
|
__decorate([
|
|
8069
8096
|
affectRenderBoundsType('show')
|
|
8070
8097
|
], Box.prototype, "overflow", void 0);
|
|
@@ -8779,6 +8806,8 @@ function stroke(stroke, ui, canvas) {
|
|
|
8779
8806
|
case 'center':
|
|
8780
8807
|
canvas.setStroke(stroke, __strokeWidth, options);
|
|
8781
8808
|
canvas.stroke();
|
|
8809
|
+
if (options.__useArrow)
|
|
8810
|
+
strokeArrow(ui, canvas);
|
|
8782
8811
|
break;
|
|
8783
8812
|
case 'inside':
|
|
8784
8813
|
canvas.save();
|
|
@@ -8816,6 +8845,8 @@ function strokes(strokes, ui, canvas) {
|
|
|
8816
8845
|
case 'center':
|
|
8817
8846
|
canvas.setStroke(undefined, __strokeWidth, options);
|
|
8818
8847
|
drawStrokesStyle(strokes, false, ui, canvas);
|
|
8848
|
+
if (options.__useArrow)
|
|
8849
|
+
strokeArrow(ui, canvas);
|
|
8819
8850
|
break;
|
|
8820
8851
|
case 'inside':
|
|
8821
8852
|
canvas.save();
|
|
@@ -8841,6 +8872,14 @@ function strokes(strokes, ui, canvas) {
|
|
|
8841
8872
|
}
|
|
8842
8873
|
}
|
|
8843
8874
|
}
|
|
8875
|
+
function strokeArrow(ui, canvas) {
|
|
8876
|
+
if (ui.__.dashPattern) {
|
|
8877
|
+
canvas.beginPath();
|
|
8878
|
+
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
8879
|
+
canvas.dashPattern = null;
|
|
8880
|
+
canvas.stroke();
|
|
8881
|
+
}
|
|
8882
|
+
}
|
|
8844
8883
|
|
|
8845
8884
|
const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
|
|
8846
8885
|
function shape(ui, current, options) {
|
|
@@ -9526,16 +9565,16 @@ const EffectModule = {
|
|
|
9526
9565
|
|
|
9527
9566
|
const { excludeRenderBounds } = LeafBoundsHelper;
|
|
9528
9567
|
Group.prototype.__renderMask = function (canvas, options) {
|
|
9529
|
-
let child, maskCanvas, contentCanvas, maskOpacity, currentMask;
|
|
9568
|
+
let child, maskCanvas, contentCanvas, maskOpacity, currentMask, mask;
|
|
9530
9569
|
const { children } = this;
|
|
9531
9570
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
9532
|
-
child = children[i];
|
|
9533
|
-
if (
|
|
9571
|
+
child = children[i], mask = child.__.mask;
|
|
9572
|
+
if (mask) {
|
|
9534
9573
|
if (currentMask) {
|
|
9535
9574
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
|
|
9536
9575
|
maskCanvas = contentCanvas = null;
|
|
9537
9576
|
}
|
|
9538
|
-
if (
|
|
9577
|
+
if (mask === 'path' || mask === 'clipping-path') {
|
|
9539
9578
|
if (child.opacity < 1) {
|
|
9540
9579
|
currentMask = 'opacity-path';
|
|
9541
9580
|
maskOpacity = child.opacity;
|
|
@@ -9549,14 +9588,14 @@ Group.prototype.__renderMask = function (canvas, options) {
|
|
|
9549
9588
|
child.__clip(contentCanvas || canvas, options);
|
|
9550
9589
|
}
|
|
9551
9590
|
else {
|
|
9552
|
-
currentMask = 'alpha';
|
|
9591
|
+
currentMask = mask === 'grayscale' ? 'grayscale' : 'alpha';
|
|
9553
9592
|
if (!maskCanvas)
|
|
9554
9593
|
maskCanvas = getCanvas(canvas);
|
|
9555
9594
|
if (!contentCanvas)
|
|
9556
9595
|
contentCanvas = getCanvas(canvas);
|
|
9557
9596
|
child.__render(maskCanvas, options);
|
|
9558
9597
|
}
|
|
9559
|
-
if (
|
|
9598
|
+
if (!(mask === 'clipping' || mask === 'clipping-path'))
|
|
9560
9599
|
continue;
|
|
9561
9600
|
}
|
|
9562
9601
|
if (excludeRenderBounds(child, options))
|
|
@@ -9567,6 +9606,8 @@ Group.prototype.__renderMask = function (canvas, options) {
|
|
|
9567
9606
|
};
|
|
9568
9607
|
function maskEnd(leaf, maskMode, canvas, contentCanvas, maskCanvas, maskOpacity) {
|
|
9569
9608
|
switch (maskMode) {
|
|
9609
|
+
case 'grayscale':
|
|
9610
|
+
maskCanvas.useGrayscaleAlpha(leaf.__nowWorld);
|
|
9570
9611
|
case 'alpha':
|
|
9571
9612
|
usePixelMask(leaf, canvas, contentCanvas, maskCanvas);
|
|
9572
9613
|
break;
|
|
@@ -10271,15 +10312,12 @@ const canvas = LeaferCanvasBase.prototype;
|
|
|
10271
10312
|
const debug = Debug.get('@leafer-ui/export');
|
|
10272
10313
|
canvas.export = function (filename, options) {
|
|
10273
10314
|
const { quality, blob } = FileHelper.getExportOptions(options);
|
|
10274
|
-
if (filename.includes('.'))
|
|
10315
|
+
if (filename.includes('.'))
|
|
10275
10316
|
return this.saveAs(filename, quality);
|
|
10276
|
-
|
|
10277
|
-
else if (blob) {
|
|
10317
|
+
else if (blob)
|
|
10278
10318
|
return this.toBlob(filename, quality);
|
|
10279
|
-
|
|
10280
|
-
else {
|
|
10319
|
+
else
|
|
10281
10320
|
return this.toDataURL(filename, quality);
|
|
10282
|
-
}
|
|
10283
10321
|
};
|
|
10284
10322
|
canvas.toBlob = function (type, quality) {
|
|
10285
10323
|
return new Promise((resolve) => {
|