@leafer-draw/node 1.11.0 → 1.11.2
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/node.cjs +9 -0
- package/dist/node.esm.js +10 -1
- package/dist/node.esm.min.js +1 -1
- package/dist/node.esm.min.js.map +1 -1
- package/dist/node.min.cjs +1 -1
- package/dist/node.min.cjs.map +1 -1
- package/package.json +10 -10
package/dist/node.cjs
CHANGED
|
@@ -6,6 +6,15 @@ var fs = require("fs");
|
|
|
6
6
|
|
|
7
7
|
var draw = require("@leafer-ui/draw");
|
|
8
8
|
|
|
9
|
+
exports.PathNodeHandleType = void 0;
|
|
10
|
+
|
|
11
|
+
(function(PathNodeHandleType) {
|
|
12
|
+
PathNodeHandleType[PathNodeHandleType["none"] = 1] = "none";
|
|
13
|
+
PathNodeHandleType[PathNodeHandleType["free"] = 2] = "free";
|
|
14
|
+
PathNodeHandleType[PathNodeHandleType["mirrorAngle"] = 3] = "mirrorAngle";
|
|
15
|
+
PathNodeHandleType[PathNodeHandleType["mirror"] = 4] = "mirror";
|
|
16
|
+
})(exports.PathNodeHandleType || (exports.PathNodeHandleType = {}));
|
|
17
|
+
|
|
9
18
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
10
19
|
function adopt(value) {
|
|
11
20
|
return value instanceof P ? value : new P(function(resolve) {
|
package/dist/node.esm.js
CHANGED
|
@@ -10,6 +10,15 @@ import { Paint, PaintImage, ColorConvert, PaintGradient, Effect, Group, TextConv
|
|
|
10
10
|
|
|
11
11
|
export * from "@leafer-ui/draw";
|
|
12
12
|
|
|
13
|
+
var PathNodeHandleType;
|
|
14
|
+
|
|
15
|
+
(function(PathNodeHandleType) {
|
|
16
|
+
PathNodeHandleType[PathNodeHandleType["none"] = 1] = "none";
|
|
17
|
+
PathNodeHandleType[PathNodeHandleType["free"] = 2] = "free";
|
|
18
|
+
PathNodeHandleType[PathNodeHandleType["mirrorAngle"] = 3] = "mirrorAngle";
|
|
19
|
+
PathNodeHandleType[PathNodeHandleType["mirror"] = 4] = "mirror";
|
|
20
|
+
})(PathNodeHandleType || (PathNodeHandleType = {}));
|
|
21
|
+
|
|
13
22
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
14
23
|
function adopt(value) {
|
|
15
24
|
return value instanceof P ? value : new P(function(resolve) {
|
|
@@ -2613,4 +2622,4 @@ UI.prototype.syncExport = function(filename, options) {
|
|
|
2613
2622
|
return Export.syncExport(this, filename, options);
|
|
2614
2623
|
};
|
|
2615
2624
|
|
|
2616
|
-
export { Layouter, LeaferCanvas, Renderer, Watcher, useCanvas };
|
|
2625
|
+
export { Layouter, LeaferCanvas, PathNodeHandleType, Renderer, Watcher, useCanvas };
|
package/dist/node.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as a,FileHelper as s,Creator as i,LeaferImage as n,defineKey as o,LeafList as r,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as g,Bounds as _,isArray as w,Debug as m,LeafLevelList as y,LayoutEvent as v,Run as x,ImageManager as S,ResizeEvent as b,isObject as k,BoundsHelper as B,FourNumberHelper as R,Matrix as E,isUndefined as T,isString as L,ImageEvent as A,MatrixHelper as O,MathHelper as P,AlignHelper as C,PointHelper as M,getMatrixData as W,AroundHelper as D,Direction4 as I,isNumber as F}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as Y}from"fs";import{Paint as U,PaintImage as X,ColorConvert as N,PaintGradient as q,Effect as z,Group as j,TextConvert as G,TwoPointBoundsHelper as H,Bounds as V,Export as Q,FileHelper as J,Platform as Z,isUndefined as $,Matrix as K,MathHelper as tt,Creator as et,TaskProcessor as at,Resource as st,LeaferCanvasBase as it,Debug as nt,Plugin as ot,UI as rt}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function lt(t,e,a,s){return new(a||(a=Promise))(function(i,n){function o(t){try{l(s.next(t))}catch(t){n(t)}}function r(t){try{l(s.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof a?e:new a(function(t){t(e)})).then(o,r)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class dt extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,a(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:a}=this;this.view.width=Math.ceil(t*a),this.view.height=Math.ceil(e*a),this.clientBounds=this.bounds}}const{mineType:ct,fileType:ht}=s;function ut(t,a){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:s}=a;e.origin={createCanvas:(e,a,s)=>new t(e,a,s),canvasToDataURL:(t,e,a)=>t.toDataURLSync(e,{quality:a}),canvasToBolb:(t,e,a)=>t.toBuffer(e,{quality:a}),canvasSaveAs:(t,e,a)=>t.saveAs(e,{quality:a}),download(t,e){},loadImage:t=>s(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:s}=a;e.origin={createCanvas:(e,a,s)=>new t(e,a,s),canvasToDataURL:(t,e,a)=>t.toDataURL(ct(e),a),canvasToBolb:(t,e,a)=>lt(this,void 0,void 0,function*(){return t.toBuffer(ct(e),a)}),canvasSaveAs:(t,e,a)=>lt(this,void 0,void 0,function*(){return Y(e,t.toBuffer(ct(ht(e)),a))}),download(t,e){},loadImage:t=>s(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=i.canvas()}}Object.assign(i,{canvas:(t,e)=>new dt(t,e),image:t=>new n(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},o(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class ft{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new r,this.target=t,e&&(this.config=l.default(e,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(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,a=e.length;t<a;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:pt,updateBounds:gt,updateChange:_t}=f,{pushAllChildBranch:wt,pushAllParent:mt}=p;const{worldBounds:yt}=g;class vt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,yt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,yt),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:xt,updateAllChange:St}=f,bt=m.get("Layouter");class kt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=l.default(e,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.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(v.START),this.layoutOnce(),t.emitEvent(new v(v.END,this.layoutedBlocks,this.times))}catch(t){bt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?bt.warn("layouting"):this.times>3?bt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=x.start("PartLayout"),{target:a,__updatedList:s}=this,{BEFORE:i,LAYOUT:n,AFTER:o}=v,r=this.getBlocks(s);r.forEach(t=>t.setBefore()),a.emitEvent(new v(i,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let a;t.list.forEach(t=>{a=t.__layout,e.without(t)&&!a.proxyZoom&&(a.matrixChanged?(pt(t,!0),e.add(t),t.isBranch&&wt(t,e),mt(t,e)):a.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),mt(t,e)))})}(s,this.__levelList),function(t){let e,a,s;t.sort(!0),t.levels.forEach(i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(a=e[t],a.isBranch&&a.__tempNumber){s=a.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||gt(s[t])}gt(a)}})}(this.__levelList),function(t){t.list.forEach(_t)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),a.emitEvent(new v(n,r,this.times)),a.emitEvent(new v(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:a,LAYOUT:s,AFTER:i}=v,n=this.getBlocks(new r(e));e.emitEvent(new v(a,n,this.times)),kt.fullLayout(e),n.forEach(t=>{t.setAfter()}),e.emitEvent(new v(s,n,this.times)),e.emitEvent(new v(i,n,this.times)),this.addBlocks(n),x.end(t)}static fullLayout(t){xt(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),St(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:a}=this.extraBlock||(this.extraBlock=new vt([]));e.length?a.add(t.__world):a.set(t.__world),e.add(t)}}createBlock(t){return new vt(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(){this.__eventIds=[this.target.on_([[v.REQUEST,this.layout,this],[v.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Bt=m.get("Renderer");class Rt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,a){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,a&&(this.config=l.default(a,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(v.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,Bt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),S.clearRecycled()}catch(t){this.rendering=!1,Bt.error(t)}Bt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Bt.warn("rendering");if(this.times>3)return Bt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.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;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=x.start("PartRender"),{canvas:a}=this,s=t.getIntersect(a.bounds),i=new _(s);a.save(),s.spread(Rt.clipSpread).ceil(),a.clearWorld(s),a.clipWorld(s),this.__render(s,i),a.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),x.end(t)}__render(t,a){const{canvas:s}=this,i=t.includes(this.target.__world),n=i?{includes:i}:{bounds:t,includes:i};this.needFill&&s.fillWorld(t,this.config.fill),m.showRepaint&&m.drawRepaint(s,t),e.render(this.target,s,n),this.renderBounds=a=a||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=a:this.totalBounds.add(a),s.updateRender(a)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const a=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return e.requestRender(a);const{frames:i}=this;i.length>30&&i.shift(),i.push(t),this.FPS=Math.round(i.reduce((t,e)=>t+e,0)/i.length),this.requestTime=0,this.checkRender()};e.requestRender(a)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:a}=t.old;if(!new _(0,0,e,a).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__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||Bt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,a){this.target.emitEvent(new d(t,this.times,e,a))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[v.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[b.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function Et(t,e,a){t.__.__font?U.fillText(t,e,a):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Tt(t,e,a,s,i){const n=a.__;k(t)?U.drawStrokesStyle(t,e,!1,a,s,i):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&U.strokeArrow(t,a,s,i)}function Lt(t,e,a,s,i){const n=a.__;k(t)?U.drawStrokesStyle(t,e,!0,a,s,i):(s.setStroke(t,n.__strokeWidth*e,n),U.drawTextStroke(a,s,i))}function At(t,e,a,s,i){const n=s.getSameCanvas(!0,!0);n.font=a.__.__font,Lt(t,2,a,n,i),n.blendMode="outside"===e?"destination-out":"destination-in",U.fillText(a,n,i),n.blendMode="normal",f.copyCanvasByWorld(a,s,n),n.recycle(a.__nowWorld)}Rt.clipSpread=10,Object.assign(i,{watcher:(t,e)=>new ft(t,e),layouter:(t,e)=>new kt(t,e),renderer:(t,e,a)=>new Rt(t,e,a),selector:(t,e)=>{},interaction:(t,e,a,s)=>{}}),e.layout=kt.fullLayout,e.render=function(t,e,a){const s=Object.assign(Object.assign({},a),{topRendering:!0});a.topList=new r,t.__render(e,a),a.topList.length&&a.topList.forEach(t=>t.__render(e,s))};const{getSpread:Ot,copyAndSpread:Pt,toOuterOf:Ct,getOuterOf:Mt,getByMove:Wt,move:Dt,getIntersectData:It}=B,Ft={};let Yt;const{stintSet:Ut}=l,{hasTransparent:Xt}=N;function Nt(t,e,a){if(!k(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:i}=a.__layout;switch(e.type){case"image":s=X.image(a,t,e,i,!Yt||!Yt[e.url]);break;case"linear":s=q.linearGradient(e,i);break;case"radial":s=q.radialGradient(e,i);break;case"angular":s=q.conicGradient(e,i);break;case"solid":const{type:n,color:o,opacity:r}=e;s={type:n,style:N.string(o,r)};break;default:T(e.r)||(s={type:"solid",style:N.string(e)})}if(s&&(s.originPaint=e,L(s.style)&&Xt(s.style)&&(s.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}return s}const qt={compute:function(t,e){const a=e.__,s=[];let i,n,o,r=a.__input[t];w(r)||(r=[r]),Yt=X.recycleImage(t,a);for(let a,i=0,n=r.length;i<n;i++)(a=Nt(t,r[i],e))&&(s.push(a),a.strokeStyle&&(o||(o=1),a.strokeStyle.strokeWidth&&(o=Math.max(o,a.strokeStyle.strokeWidth))));a["_"+t]=s.length?s:void 0,s.length?(s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(i=!0),n=!0),"fill"===t?(Ut(a,"__isAlphaPixelFill",i),Ut(a,"__isTransparentFill",n)):(Ut(a,"__isAlphaPixelStroke",i),Ut(a,"__isTransparentStroke",n),Ut(a,"__hasMultiStrokeStyle",o))):a.__removePaint(t,!1)},fill:function(t,e,a,s){a.fillStyle=t,Et(e,a,s)},fills:function(t,e,a,s){let i,n,o;for(let r=0,l=t.length;r<l;r++){if(i=t[r],n=i.originPaint,i.image){if(o?o++:o=1,X.checkImage(i,!e.__.__font,e,a,s))continue;if(!i.style){1===o&&i.image.isPlacehold&&e.drawImagePlaceholder(i,a,s);continue}}if(a.fillStyle=i.style,i.transform||n.scaleFixed){if(a.save(),i.transform&&a.transform(i.transform),n.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===n.scaleFixed||"zoom-in"===n.scaleFixed&&t>1&&s>1)&&a.scale(1/t,1/s)}n.blendMode&&(a.blendMode=n.blendMode),Et(e,a,s),a.restore()}else n.blendMode?(a.saveBlendMode(n.blendMode),Et(e,a,s),a.restoreBlendMode()):Et(e,a,s)}},fillPathOrText:Et,fillText:function(t,e,a){const s=t.__,{rows:i,decorationY:n}=s.__textDrawData;let o;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,a=i.length;t<a;t++)o=i[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach(t=>{e.fillText(t.char,t.x,o.y)});if(n){const{decorationColor:t,decorationHeight:a}=s.__textDrawData;t&&(e.fillStyle=t),i.forEach(t=>n.forEach(s=>e.fillRect(t.x,t.y+s,t.width,a)))}},stroke:function(t,e,a,s){const i=e.__;if(i.__strokeWidth)if(i.__font)U.strokeText(t,e,a,s);else switch(i.strokeAlign){case"center":Tt(t,1,e,a,s);break;case"inside":!function(t,e,a,s){a.save(),a.clipUI(e),Tt(t,2,e,a,s),a.restore()}(t,e,a,s);break;case"outside":!function(t,e,a,s){const i=e.__;if(i.__fillAfterStroke)Tt(t,2,e,a,s);else{const{renderBounds:n}=e.__layout,o=a.getSameCanvas(!0,!0);e.__drawRenderPath(o),Tt(t,2,e,o,s),o.clipUI(i),o.clearWorld(n),f.copyCanvasByWorld(e,a,o),o.recycle(e.__nowWorld)}}(t,e,a,s)}},strokes:function(t,e,a,s){U.stroke(t,e,a,s)},strokeText:function(t,e,a,s){switch(e.__.strokeAlign){case"center":Lt(t,1,e,a,s);break;case"inside":At(t,"inside",e,a,s);break;case"outside":e.__.__fillAfterStroke?Lt(t,2,e,a,s):At(t,"outside",e,a,s)}},drawTextStroke:function(t,e,a){let s,i=t.__.__textDrawData;const{rows:n,decorationY:o}=i;for(let t=0,a=n.length;t<a;t++)s=n[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(o){const{decorationHeight:t}=i;n.forEach(a=>o.forEach(s=>e.strokeRect(a.x,a.y+s,a.width,t)))}},drawStrokesStyle:function(t,e,a,s,i,n){let o;const r=s.__,{__hasMultiStrokeStyle:l}=r;l||i.setStroke(void 0,r.__strokeWidth*e,r);for(let d=0,c=t.length;d<c;d++)if(o=t[d],(!o.image||!X.checkImage(o,!1,s,i,n))&&o.style){if(l){const{strokeStyle:t}=o;t?i.setStroke(o.style,r.__getRealStrokeWidth(t)*e,r,t):i.setStroke(o.style,r.__strokeWidth*e,r)}else i.strokeStyle=o.style;o.originPaint.blendMode?(i.saveBlendMode(o.originPaint.blendMode),a?U.drawTextStroke(s,i,n):i.stroke(),i.restoreBlendMode()):a?U.drawTextStroke(s,i,n):i.stroke()}},shape:function(t,a,s){const i=a.getSameCanvas(),n=a.bounds,o=t.__nowWorld,r=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,p;Ct(r.strokeSpread?(Pt(Ft,r.boxBounds,r.strokeSpread),Ft):r.boxBounds,o,l);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(l))p=i,d=f=l,c=o;else{let i;if(e.fullImageShadow)i=l;else{const t=r.renderShapeSpread?Ot(n,R.swapAndScale(r.renderShapeSpread,g,_)):n;i=It(t,l)}u=n.getFitMatrix(i);let{a:w,d:m}=u;u.a<1&&(p=a.getSameCanvas(),t.__renderShape(p,s),g*=w,_*=m),f=Mt(l,u),d=Wt(f,-u.e,-u.f),c=Mt(o,u),Dt(c,-u.e,-u.f);const y=s.matrix;y?(h=new E(u),h.multiply(y),w*=y.scaleX,m*=y.scaleY):h=u,h.withScale(w,m),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(i,s),{canvas:i,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let zt,jt=new _;const{isSame:Gt}=B;function Ht(t,e,a,s,i,n){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return i.data||X.createData(i,s,a,n),!0}function Vt(t,e){Zt(t,A.LOAD,e)}function Qt(t,e){Zt(t,A.LOADED,e)}function Jt(t,e,a){e.error=a,t.forceUpdate("surface"),Zt(t,A.ERROR,e)}function Zt(t,e,a){t.hasEvent(e)&&t.emitEvent(new A(e,a))}function $t(t,e){const{leafer:a}=t;a&&a.viewReady&&(a.renderer.ignore=e)}const{get:Kt,translate:te}=O,ee=new _,ae={},se={};function ie(t,e,a,s){const i=L(t)||s?(s?a-s*e:a%e)/((s||Math.floor(a/e))-1):t;return"auto"===t&&i<0?0:i}let ne={},oe=W();const{get:re,set:le,rotateOfOuter:de,translate:ce,scaleOfOuter:he,multiplyParent:ue,scale:fe,rotate:pe,skew:ge}=O;function _e(t,e,a,s,i,n,o,r){o&&pe(t,o),r&&ge(t,r.x,r.y),i&&fe(t,i,n),ce(t,e.x+a,e.y+s)}const{get:we,scale:me,copy:ye}=O,{getFloorScale:ve}=P,{abs:xe}=Math;const Se={image:function(t,e,a,s,i){let n,o;const r=S.get(a);return zt&&a===zt.paint&&Gt(s,zt.boxBounds)?n=zt.leafPaint:(n={type:a.type,image:r},r.hasAlphaPixel&&(n.isTransparent=!0),zt=r.use>1?{leafPaint:n,paint:a,boxBounds:jt.set(s)}:null),(i||r.loading)&&(o={image:r,attrName:e,attrValue:a}),r.ready?(Ht(t,e,a,r,n,s),i&&(Vt(t,o),Qt(t,o))):r.error?i&&Jt(t,o,r.error):(i&&($t(t,!0),Vt(t,o)),n.loadId=r.load(()=>{$t(t,!1),t.destroyed||(Ht(t,e,a,r,n,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Qt(t,o)),n.loadId=void 0},e=>{$t(t,!1),Jt(t,o,e),n.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):r.isPlacehold=!0)),n},checkImage:function(t,a,s,i,n){const{scaleX:o,scaleY:r}=X.getImageRenderScaleData(t,s,i,n),{image:l,data:d,originPaint:c}=t,{exporting:h}=n;return!(!d||t.patternId===o+"-"+r&&!h)&&(a&&(d.repeat?a=!1:c.changeful||"miniapp"===e.name&&b.isResizing(s)||h||(a=e.image.isLarge(l,o,r))),a?(s.__.__isFastShadow&&(i.fillStyle=t.style||"#000",i.fill()),X.drawImage(t,o,r,s,i,n),!0):(!t.style||c.sync||h?X.createPattern(t,s,i,n):X.createPatternTask(t,s,i,n),!1))},drawImage:function(t,e,a,s,i,n){const{data:o,image:r}=t,{blendMode:l}=t.originPaint,{opacity:d,transform:c}=o,h=r.getFull(o.filters),u=s.__;let f,{width:p,height:g}=r;(f=c&&!c.onlyScale||u.path||u.cornerRadius)||d||l?(i.save(),f&&i.clipUI(s),l&&(i.blendMode=l),d&&(i.opacity*=d),c&&i.transform(c),i.drawImage(h,0,0,p,g),i.restore()):(o.scaleX&&(p*=o.scaleX,g*=o.scaleY),i.drawImage(h,0,0,p,g))},getImageRenderScaleData:function(t,e,a,s){const i=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:n}=t;if(a){const{pixelRatio:t}=a;i.scaleX*=t,i.scaleY*=t}return n&&n.scaleX&&(i.scaleX*=Math.abs(n.scaleX),i.scaleY*=Math.abs(n.scaleY)),i},recycleImage:function(t,e){const a=e["_"+t];if(w(a)){let s,i,n,o,r;for(let l=0,d=a.length;l<d;l++)s=a[l],i=s.image,r=i&&i.url,r&&(n||(n={}),n[r]=!0,S.recycle(i),i.loading&&(o||(o=e.__input&&e.__input[t]||[],w(o)||(o=[o])),i.unload(a[l].loadId,!o.some(t=>t.url===r))));return n}return null},createPatternTask:function(t,e,a,s){t.patternTask||(t.patternTask=S.patternTasker.add(()=>lt(this,void 0,void 0,function*(){t.patternTask=null,a.bounds.hit(e.__nowWorld)&&X.createPattern(t,e,a,s),e.forceUpdate("surface")}),300))},createPattern:function(t,a,s,i){let{scaleX:n,scaleY:o}=X.getImageRenderScaleData(t,a,s,i),r=n+"-"+o;if(t.patternId!==r&&!a.destroyed&&(!e.image.isLarge(t.image,n,o)||t.data.repeat)){const{image:s,data:i}=t,{transform:l,gap:d}=i,c=X.getPatternFixScale(t,n,o);let h,u,f,{width:p,height:g}=s;c&&(n*=c,o*=c),p*=n,g*=o,d&&(u=d.x*n/xe(i.scaleX||1),f=d.y*o/xe(i.scaleY||1)),(l||1!==n||1!==o)&&(n*=ve(p+(u||0)),o*=ve(g+(f||0)),h=we(),l&&ye(h,l),me(h,1/n,1/o));const _=s.getCanvas(p,g,i.opacity,i.filters,u,f,a.leafer&&a.leafer.config.smooth),w=s.getPattern(_,i.repeat||e.origin.noRepeat||"no-repeat",h,t);t.style=w,t.patternId=r}},getPatternFixScale:function(t,a,s){const{image:i}=t;let n,o=e.image.maxPatternSize,r=i.width*i.height;return i.isSVG?a>1&&(n=Math.ceil(a)/a):o>r&&(o=r),(r*=a*s)>o&&(n=Math.sqrt(o/r)),n},createData:function(t,e,a,s){t.data=X.getPatternData(a,s,e)},getPatternData:function(t,e,a){t.padding&&(e=ee.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:s,height:i}=a,{opacity:n,mode:o,align:r,offset:l,scale:d,size:c,rotation:h,skew:u,clipSize:f,repeat:p,gap:g,filters:_}=t,w=e.width===s&&e.height===i,m={mode:o},y="center"!==r&&(h||0)%180==90;let v,x;switch(B.set(se,0,0,y?i:s,y?s:i),o&&"cover"!==o&&"fit"!==o?((d||c)&&(P.getScaleData(d,c,a,ae),v=ae.scaleX,x=ae.scaleY),(r||g||p)&&(v&&B.scale(se,v,x,!0),r&&C.toPoint(r,se,e,se,!0,!0))):w&&!h||(v=x=B.getFitScale(e,se,"fit"!==o),B.put(e,a,r,v,!1,se),B.scale(se,v,x,!0)),l&&M.move(se,l),o){case"stretch":w?v&&(v=x=void 0):(v=e.width/s,x=e.height/i,X.stretchMode(m,e,v,x));break;case"normal":case"clip":if(se.x||se.y||v||f||h||u){let t,a;f&&(t=e.width/f.width,a=e.height/f.height),X.clipMode(m,e,se.x,se.y,v,x,h,u,t,a),t&&(v=v?v*t:t,x=x?x*a:a)}break;case"repeat":(!w||v||h||u)&&X.repeatMode(m,e,s,i,se.x,se.y,v,x,h,u,r,t.freeTransform),p||(m.repeat="repeat");const a=k(p);(g||a)&&(m.gap=function(t,e,a,s,i){let n,o;k(t)?(n=t.x,o=t.y):n=o=t;return{x:ie(n,a,i.width,e&&e.x),y:ie(o,s,i.height,e&&e.y)}}(g,a&&p,se.width,se.height,e));break;default:v&&X.fillOrFitMode(m,e,se.x,se.y,v,x,h)}return m.transform||(e.x||e.y)&&te(m.transform=Kt(),e.x,e.y),v&&(m.scaleX=v,m.scaleY=x),n&&n<1&&(m.opacity=n),_&&(m.filters=_),p&&(m.repeat=L(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),m},stretchMode:function(t,e,a,s){const i=re(),{x:n,y:o}=e;n||o?ce(i,n,o):i.onlyScale=!0,fe(i,a,s),t.transform=i},fillOrFitMode:function(t,e,a,s,i,n,o){const r=re();ce(r,e.x+a,e.y+s),fe(r,i,n),o&&de(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r},clipMode:function(t,e,a,s,i,n,o,r,l,d){const c=re();_e(c,e,a,s,i,n,o,r),l&&(o||r?(le(oe),he(oe,e,l,d),ue(c,oe)):he(c,e,l,d)),t.transform=c},repeatMode:function(t,e,a,s,i,n,o,r,l,d,c,h){const u=re();if(h)_e(u,e,i,n,o,r,l,d);else{if(l)if("center"===c)de(u,{x:a/2,y:s/2},l);else switch(pe(u,l),l){case 90:ce(u,s,0);break;case 180:ce(u,a,s);break;case 270:ce(u,0,a)}ne.x=e.x+i,ne.y=e.y+n,ce(u,ne.x,ne.y),o&&he(u,ne,o,r)}t.transform=u}},{toPoint:be}=D,{hasTransparent:ke}=N,Be={},Re={};function Ee(t,e,a,s){if(a){let i,n,o,r;for(let t=0,l=a.length;t<l;t++)i=a[t],L(i)?(o=t/(l-1),n=N.string(i,s)):(o=i.offset,n=N.string(i.color,s)),e.addColorStop(o,n),!r&&ke(n)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:Te,getDistance:Le}=M,{get:Ae,rotateOfOuter:Oe,scaleOfOuter:Pe}=O,{toPoint:Ce}=D,Me={},We={};function De(t,e,a,s,i){let n;const{width:o,height:r}=t;if(o!==r||s){const t=Te(e,a);n=Ae(),i?(Pe(n,e,o/r*(s||1),1),Oe(n,e,t+90)):(Pe(n,e,1,o/r*(s||1)),Oe(n,e,t))}return n}const{getDistance:Ie}=M,{toPoint:Fe}=D,Ye={},Ue={};const Xe={linearGradient:function(t,a){let{from:s,to:i,type:n,opacity:o}=t;be(s||"top",a,Be),be(i||"bottom",a,Re);const r=e.canvas.createLinearGradient(Be.x,Be.y,Re.x,Re.y),l={type:n,style:r};return Ee(l,r,t.stops,o),l},radialGradient:function(t,a){let{from:s,to:i,type:n,opacity:o,stretch:r}=t;Ce(s||"center",a,Me),Ce(i||"bottom",a,We);const l=e.canvas.createRadialGradient(Me.x,Me.y,0,Me.x,Me.y,Le(Me,We)),d={type:n,style:l};Ee(d,l,t.stops,o);const c=De(a,Me,We,r,!0);return c&&(d.transform=c),d},conicGradient:function(t,a){let{from:s,to:i,type:n,opacity:o,stretch:r}=t;Fe(s||"center",a,Ye),Fe(i||"bottom",a,Ue);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ye.x,Ye.y):e.canvas.createRadialGradient(Ye.x,Ye.y,0,Ye.x,Ye.y,Ie(Ye,Ue)),d={type:n,style:l};Ee(d,l,t.stops,o);const c=De(a,Ye,Ue,r||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:De},{copy:Ne,move:qe,toOffsetOutBounds:ze}=B,{max:je,abs:Ge}=Math,He={},Ve=new E,Qe={};function Je(t,e){let a,s,i,n,o=0,r=0,l=0,d=0;return e.forEach(t=>{a=t.x||0,s=t.y||0,n=1.5*(t.blur||0),i=Ge(t.spread||0),o=je(o,i+n-s),r=je(r,i+n+a),l=je(l,i+n+s),d=je(d,i+n-a)}),o===r&&r===l&&l===d?o:[o,r,l,d]}function Ze(t,a,s){const{shapeBounds:i}=s;let n,o;e.fullImageShadow?(Ne(He,t.bounds),qe(He,a.x-i.x,a.y-i.y),n=t.bounds,o=He):(n=i,o=a),t.copyWorld(s.canvas,n,o)}const{toOffsetOutBounds:$e}=B,Ke={};const ta=Je;const ea={shadow:function(t,e,a){let s,i;const{__nowWorld:n}=t,{shadow:o}=t.__,{worldCanvas:r,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=a,p=e.getSameCanvas(),g=o.length-1;ze(l,Qe,d),o.forEach((o,_)=>{let w=1;if(o.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(w=1/t)}p.setWorldShadow(Qe.offsetX+(o.x||0)*h*w,Qe.offsetY+(o.y||0)*u*w,(o.blur||0)*h*w,N.string(o.color)),i=z.getShadowTransform(t,p,a,o,Qe,w),i&&p.setTransform(i),Ze(p,Qe,a),i&&p.resetTransform(),s=d,o.box&&(p.restore(),p.save(),r&&(p.copyWorld(p,d,n,"copy"),s=n),r?p.copyWorld(r,n,n,"destination-out"):p.copyWorld(a.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,p,s,o.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},innerShadow:function(t,e,a){let s,i;const{__nowWorld:n}=t,{innerShadow:o}=t.__,{worldCanvas:r,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=a,p=e.getSameCanvas(),g=o.length-1;$e(l,Ke,d),o.forEach((o,_)=>{let w=1;if(o.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(w=1/t)}p.save(),p.setWorldShadow(Ke.offsetX+(o.x||0)*h*w,Ke.offsetY+(o.y||0)*u*w,(o.blur||0)*h*w),i=z.getShadowTransform(t,p,a,o,Ke,w,!0),i&&p.setTransform(i),Ze(p,Ke,a),p.restore(),r?(p.copyWorld(p,d,n,"copy"),p.copyWorld(r,n,n,"source-out"),s=n):(p.copyWorld(a.canvas,c,l,"source-out"),s=d),p.fillWorld(s,N.string(o.color),"source-in"),f.copyCanvasByWorld(t,e,p,s,o.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},blur:function(t,e,a){const{blur:s}=t.__;a.setWorldBlur(s*t.__nowWorld.a),a.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),a.filter="none"},backgroundBlur:function(t,e,a){},getShadowRenderSpread:Je,getShadowTransform:function(t,e,a,s,i,n,o){if(s.spread){const a=2*s.spread*n*(o?-1:1),{width:r,height:l}=t.__layout.strokeBounds;return Ve.set().scaleOfOuter({x:(i.x+i.width/2)*e.pixelRatio,y:(i.y+i.height/2)*e.pixelRatio},1+a/r,1+a/l),Ve}},isTransformShadow(t){},getInnerShadowSpread:ta},{excludeRenderBounds:aa}=g;let sa;function ia(t,e,a,s,i,n,o,r){switch(e){case"grayscale":sa||(sa=!0,i.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,a,s,i,n){const o=t.__nowWorld;a.resetTransform(),a.opacity=1,a.useMask(s,o),n&&s.recycle(o);oa(t,e,a,1,i,n)}(t,a,s,i,o,r);break;case"opacity-path":oa(t,a,s,n,o,r);break;case"path":r&&a.restore()}}function na(t){return t.getSameCanvas(!1,!0)}function oa(t,e,a,s,i,n){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(a,o,void 0,i),n?a.recycle(o):a.clearWorld(o)}j.prototype.__renderMask=function(t,e){let a,s,i,n,o,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(a=l[d],r=a.__.mask,r){o&&(ia(this,o,t,i,s,n,void 0,!0),s=i=null),"clipping"!==r&&"clipping-path"!==r||aa(a,e)||a.__render(t,e),n=a.__.opacity,sa=!1,"path"===r||"clipping-path"===r?(n<1?(o="opacity-path",i||(i=na(t))):(o="path",t.save()),a.__clip(i||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=na(t)),i||(i=na(t)),a.__render(s,e));continue}const c=1===n&&a.__.__blendMode;c&&ia(this,o,t,i,s,n,void 0,!1),aa(a,e)||a.__render(i||t,e),c&&ia(this,o,t,i,s,n,c,!1)}ia(this,o,t,i,s,n,void 0,!0)};const ra=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",la=ra+"_#~&*+\\=|≮≯≈≠=…",da=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 ca(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ha=ca("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ua=ca("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),fa=ca(ra),pa=ca(la),ga=ca("- —/~|┆·");var _a;!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"}(_a||(_a={}));const{Letter:wa,Single:ma,Before:ya,After:va,Symbol:xa,Break:Sa}=_a;function ba(t){return ha[t]?wa:ga[t]?Sa:ua[t]?ya:fa[t]?va:pa[t]?xa:da.test(t)?ma:wa}const ka={trimRight(t){const{words:e}=t;let a,s=0,i=e.length;for(let n=i-1;n>-1&&(a=e[n].data[0]," "===a.char);n--)s++,t.width-=a.width;s&&e.splice(i-s,s)}};function Ba(t,e,a){switch(e){case"title":return a?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Ra}=ka,{Letter:Ea,Single:Ta,Before:La,After:Aa,Symbol:Oa,Break:Pa}=_a;let Ca,Ma,Wa,Da,Ia,Fa,Ya,Ua,Xa,Na,qa,za,ja,Ga,Ha,Va,Qa,Ja=[];function Za(t,e){Xa&&!Ua&&(Ua=Xa),Ca.data.push({char:t,width:e}),Wa+=e}function $a(){Da+=Wa,Ca.width=Wa,Ma.words.push(Ca),Ca={data:[]},Wa=0}function Ka(){Ga&&(Ha.paraNumber++,Ma.paraStart=!0,Ga=!1),Xa&&(Ma.startCharSize=Ua,Ma.endCharSize=Xa,Ua=0),Ma.width=Da,Va.width?Ra(Ma):Qa&&ts(),Ja.push(Ma),Ma={words:[]},Da=0}function ts(){Da>(Ha.maxWidth||0)&&(Ha.maxWidth=Da)}const{top:es,right:as,bottom:ss,left:is}=I;function ns(t,e,a){const{bounds:s,rows:i}=t;s[e]+=a;for(let t=0;t<i.length;t++)i[t][e]+=a}const os={getDrawData:function(t,a){L(t)||(t=String(t));let s=0,i=0,n=a.__getInput("width")||0,o=a.__getInput("height")||0;const{__padding:r}=a;r&&(n?(s=r[is],n-=r[as]+r[is],!n&&(n=.01)):a.autoSizeAlign||(s=r[is]),o?(i=r[es],o-=r[es]+r[ss],!o&&(o=.01)):a.autoSizeAlign||(i=r[es]));const l={bounds:{x:s,y:i,width:n,height:o},rows:[],paraNumber:0,font:e.canvas.font=a.__font};return function(t,a,s){Ha=t,Ja=t.rows,Va=t.bounds,Qa=!Va.width&&!s.autoSizeAlign;const{__letterSpacing:i,paraIndent:n,textCase:o}=s,{canvas:r}=e,{width:l}=Va;if(s.__isCharMode){const t="none"!==s.textWrap,e="break"===s.textWrap;Ga=!0,qa=null,Ua=Ya=Xa=Wa=Da=0,Ca={data:[]},Ma={words:[]},i&&(a=[...a]);for(let s=0,d=a.length;s<d;s++)Fa=a[s],"\n"===Fa?(Wa&&$a(),Ma.paraEnd=!0,Ka(),Ga=!0):(Na=ba(Fa),Na===Ea&&"none"!==o&&(Fa=Ba(Fa,o,!Wa)),Ya=r.measureText(Fa).width,i&&(i<0&&(Xa=Ya),Ya+=i),za=Na===Ta&&(qa===Ta||qa===Ea)||qa===Ta&&Na!==Aa,ja=!(Na!==La&&Na!==Ta||qa!==Oa&&qa!==Aa),Ia=Ga&&n?l-n:l,t&&l&&Da+Wa+Ya>Ia&&(e?(Wa&&$a(),Da&&Ka()):(ja||(ja=Na===Ea&&qa==Aa),za||ja||Na===Pa||Na===La||Na===Ta||Wa+Ya>Ia?(Wa&&$a(),Da&&Ka()):Da&&Ka()))," "===Fa&&!0!==Ga&&Da+Wa===0||(Na===Pa?(" "===Fa&&Wa&&$a(),Za(Fa,Ya),$a()):za||ja?(Wa&&$a(),Za(Fa,Ya)):Za(Fa,Ya)),qa=Na);Wa&&$a(),Da&&Ka(),Ja.length>0&&(Ja[Ja.length-1].paraEnd=!0)}else a.split("\n").forEach(t=>{Ha.paraNumber++,Da=r.measureText(t).width,Ja.push({x:n||0,text:t,width:Da,paraStart:!0}),Qa&&ts()})}(l,t,a),r&&function(t,e,a,s,i){if(!s&&a.autoSizeAlign)switch(a.textAlign){case"left":ns(e,"x",t[is]);break;case"right":ns(e,"x",-t[as])}if(!i&&a.autoSizeAlign)switch(a.verticalAlign){case"top":ns(e,"y",t[es]);break;case"bottom":ns(e,"y",-t[ss])}}(r,l,a,n,o),function(t,e){const{rows:a,bounds:s}=t,i=a.length,{__lineHeight:n,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=n*i+(h?h*(t.paraNumber-1):0),m=o;if(l&&w>_)w=Math.max(_,n),i>1&&(t.overflow=i);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,v,x,S=g||u?g:t.maxWidth;for(let o=0,c=i;o<c;o++){if(y=a[o],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&h&&o>0&&(m+=h),y.y=m,m+=n,t.overflow>o&&m>w&&(y.isOverflow=!0,t.overflow=o+1),v=y.x,x=y.width,r<0&&(y.width<0?(x=-y.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=a.length))}s.y=p,s.height=w}(l,a),a.__isCharMode&&function(t,e,a){const{rows:s}=t,{textAlign:i,paraIndent:n,letterSpacing:o}=e,r=a&&i.includes("both"),l=r||a&&i.includes("justify"),d=l&&i.includes("letter");let c,h,u,f,p,g,_,w,m,y;s.forEach(t=>{t.words&&(p=n&&t.paraStart?n:0,w=t.words.length,l&&(y=!t.paraEnd||r,h=a-t.width-p,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?h/(w-1):0),g=o||t.isOverflow||d?0:u?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===g?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,c=t.x,t.data=[],t.words.forEach((e,a)=>{1===g?(_={char:"",x:c},c=function(t,e,a){return t.forEach(t=>{a.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,a,s,i){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,a.push(t)),e+=t.width,i&&(e+=i)}),e}(e.data,c,t.data,t.isOverflow,y&&f),y&&(m=a===w-1,u?m||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(m?1:0))))})),t.words=null)})}(l,a,n),l.overflow&&function(t,a,s,i){if(!i)return;const{rows:n,overflow:o}=t;let{textOverflow:r}=a;if(n.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,c=s+i-d;("none"===a.textWrap?n:[n[o-1]]).forEach(e=>{if(e.isOverflow&&e.data){let a=e.data.length-1;for(let s=a;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===a&&l<c));s--){if(l<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,a,s,n),"none"!==a.textDecoration&&function(t,e){let a,s=0;const{fontSize:i,textDecoration:n}=e;switch(t.decorationHeight=i/11,k(n)?(a=n.type,n.color&&(t.decorationColor=N.string(n.color)),n.offset&&(s=Math.min(.3*i,Math.max(n.offset,.15*-i)))):a=n,a){case"under":t.decorationY=[.15*i+s];break;case"delete":t.decorationY=[.35*-i];break;case"under-delete":t.decorationY=[.15*i+s,.35*-i]}}(l,a),l}};const rs={string:function(t,e){if(!t)return"#000";const a=F(e)&&e<1;if(L(t)){if(!a||!N.object)return t;t=N.object(t)}let s=T(t.a)?1:t.a;a&&(s*=e);const i=t.r+","+t.g+","+t.b;return 1===s?"rgb("+i+")":"rgba("+i+","+s+")"}};Object.assign(G,os),Object.assign(N,rs),Object.assign(U,qt),Object.assign(X,Se),Object.assign(q,Xe),Object.assign(z,ea);const{setPoint:ls,addPoint:ds,toBounds:cs}=H;const hs={syncExport(t,e,a){let s;Q.running=!0;try{const i=J.fileType(e),n=e.includes(".");a=J.getExportOptions(a);const{toURL:o}=Z,{download:r}=Z.origin;if("json"===i)n&&r(o(JSON.stringify(t.toJSON(a.json)),"text"),e),s={data:!!n||t.toJSON(a.json)};else if("svg"===i)n&&r(o(t.toSVG(),"svg"),e),s={data:!!n||t.toSVG()};else{let i,n,o=1,r=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:h}=t,{slice:u,clip:f,trim:p,screenshot:g,padding:_,onCanvas:w}=a,m=$(a.smooth)?!c||c.config.smooth:a.smooth,y=a.contextSettings||(c?c.config.contextSettings:void 0),v=d&&g&&$(a.fill)?t.fill:a.fill,x=J.isOpaqueImage(e)||v,S=new K;if(g)i=!0===g?d?c.canvas.bounds:t.worldRenderBounds:g;else{let e=a.relative||(d?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":S.set(l);break;case"local":S.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=c||t;default:S.set(l).divide(t.getTransform(e));const a=e.worldTransform;o/=o/a.scaleX,r/=r/a.scaleY}i=t.getBounds("render",e)}const b={scaleX:1,scaleY:1};tt.getScaleData(a.scale,a.size,i,b);let k=a.pixelRatio||1,{x:B,y:R,width:E,height:T}=new V(i).scale(b.scaleX,b.scaleY);f&&(B+=f.x,R+=f.y,E=f.width,T=f.height);const L={exporting:!0,matrix:S.scale(1/b.scaleX,1/b.scaleY).invert().translate(-B,-R).withScale(1/o*b.scaleX,1/r*b.scaleY)};let A,O=et.canvas({width:Math.floor(E),height:Math.floor(T),pixelRatio:k,smooth:m,contextSettings:y});u&&(A=t,A.__worldOpacity=0,t=c||t,L.bounds=O.bounds),O.save();const P=h&&!$(v),C=t.get("fill");if(P&&(t.fill=""),Z.render(t,O,L),P&&(t.fill=C),O.restore(),A&&A.__updateWorldOpacity(),p){n=function(t){const{width:e,height:a}=t.view,{data:s}=t.context.getImageData(0,0,e,a);let i,n,o,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(i=r%e,n=(r-i)/e,o?ds(o,i,n):ls(o={},i,n)),r++;const l=new V;return o&&(cs(o,l),l.scale(1/t.pixelRatio).ceil()),l}(O);const t=O,{width:e,height:a}=n,s={x:0,y:0,width:e,height:a,pixelRatio:k};O=et.canvas(s),O.copyWorld(t,n,s),t.destroy()}if(_){const[t,e,a,s]=tt.fourNumber(_),i=O,{width:n,height:o}=i;O=et.canvas({width:n+s+e,height:o+t+a,pixelRatio:k}),O.copyWorld(i,i.bounds,{x:s,y:t,width:n,height:o}),i.destroy()}x&&O.fillWorld(O.bounds,v||"#FFFFFF","destination-over"),w&&w(O);s={data:"canvas"===e?O:O.export(e,a),width:O.pixelWidth,height:O.pixelHeight,renderBounds:i,trimBounds:n};const M=c&&c.app;M&&M.canvasManager&&M.canvasManager.clearRecycled()}}catch(t){s={data:"",error:t}}return Q.running=!1,s},export(t,e,a){return Q.running=!0,function(t){us||(us=new at);return new Promise(e=>{us.add(()=>lt(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(s=>new Promise(i=>{const n=()=>lt(this,void 0,void 0,function*(){if(!st.isComplete)return Z.requestRender(n);const o=Q.syncExport(t,e,a);o.data instanceof Promise&&(o.data=yield o.data),s(o),i()});t.updateLayout(),fs(t);const{leafer:o}=t;o?o.waitViewCompleted(n):n()}))}};let us;function fs(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>fs(t))}const ps=it.prototype,gs=nt.get("@leafer-in/export");ps.export=function(t,e){const{quality:a,blob:s}=J.getExportOptions(e);return t.includes(".")?this.saveAs(t,a):s?this.toBlob(t,a):this.toDataURL(t,a)},ps.toBlob=function(t,e){return new Promise(a=>{Z.origin.canvasToBolb(this.view,t,e).then(t=>{a(t)}).catch(t=>{gs.error(t),a(null)})})},ps.toDataURL=function(t,e){return Z.origin.canvasToDataURL(this.view,t,e)},ps.saveAs=function(t,e){return new Promise(a=>{Z.origin.canvasSaveAs(this.view,t,e).then(()=>{a(!0)}).catch(t=>{gs.error(t),a(!1)})})},ot.add("export"),Object.assign(Q,hs),rt.prototype.export=function(t,e){return Q.export(this,t,e)},rt.prototype.syncExport=function(t,e){return Q.syncExport(this,t,e)};export{kt as Layouter,dt as LeaferCanvas,Rt as Renderer,ft as Watcher,ut as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as a,FileHelper as i,Creator as s,LeaferImage as n,defineKey as o,LeafList as r,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as g,Bounds as _,isArray as w,Debug as m,LeafLevelList as y,LayoutEvent as v,Run as x,ImageManager as S,ResizeEvent as b,isObject as k,BoundsHelper as B,FourNumberHelper as R,Matrix as E,isUndefined as T,isString as L,ImageEvent as A,MatrixHelper as O,MathHelper as P,AlignHelper as C,PointHelper as M,getMatrixData as W,AroundHelper as D,Direction4 as I,isNumber as F}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as Y}from"fs";import{Paint as U,PaintImage as X,ColorConvert as N,PaintGradient as q,Effect as z,Group as j,TextConvert as G,TwoPointBoundsHelper as H,Bounds as V,Export as Q,FileHelper as J,Platform as Z,isUndefined as $,Matrix as K,MathHelper as tt,Creator as et,TaskProcessor as at,Resource as it,LeaferCanvasBase as st,Debug as nt,Plugin as ot,UI as rt}from"@leafer-ui/draw";export*from"@leafer-ui/draw";var lt;function dt(t,e,a,i){return new(a||(a=Promise))(function(s,n){function o(t){try{l(i.next(t))}catch(t){n(t)}}function r(t){try{l(i.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof a?e:new a(function(t){t(e)})).then(o,r)}l((i=i.apply(t,e||[])).next())})}!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(lt||(lt={})),"function"==typeof SuppressedError&&SuppressedError;class ct extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,a(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:a}=this;this.view.width=Math.ceil(t*a),this.view.height=Math.ceil(e*a),this.clientBounds=this.bounds}}const{mineType:ht,fileType:ut}=i;function ft(t,a){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:i}=a;e.origin={createCanvas:(e,a,i)=>new t(e,a,i),canvasToDataURL:(t,e,a)=>t.toDataURLSync(e,{quality:a}),canvasToBolb:(t,e,a)=>t.toBuffer(e,{quality:a}),canvasSaveAs:(t,e,a)=>t.saveAs(e,{quality:a}),download(t,e){},loadImage:t=>i(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:i}=a;e.origin={createCanvas:(e,a,i)=>new t(e,a,i),canvasToDataURL:(t,e,a)=>t.toDataURL(ht(e),a),canvasToBolb:(t,e,a)=>dt(this,void 0,void 0,function*(){return t.toBuffer(ht(e),a)}),canvasSaveAs:(t,e,a)=>dt(this,void 0,void 0,function*(){return Y(e,t.toBuffer(ht(ut(e)),a))}),download(t,e){},loadImage:t=>i(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=s.canvas()}}Object.assign(s,{canvas:(t,e)=>new ct(t,e),image:t=>new n(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},o(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class pt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new r,this.target=t,e&&(this.config=l.default(e,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(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,a=e.length;t<a;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:gt,updateBounds:_t,updateChange:wt}=f,{pushAllChildBranch:mt,pushAllParent:yt}=p;const{worldBounds:vt}=g;class xt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,vt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,vt),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:St,updateAllChange:bt}=f,kt=m.get("Layouter");class Bt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=l.default(e,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.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(v.START),this.layoutOnce(),t.emitEvent(new v(v.END,this.layoutedBlocks,this.times))}catch(t){kt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?kt.warn("layouting"):this.times>3?kt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=x.start("PartLayout"),{target:a,__updatedList:i}=this,{BEFORE:s,LAYOUT:n,AFTER:o}=v,r=this.getBlocks(i);r.forEach(t=>t.setBefore()),a.emitEvent(new v(s,r,this.times)),this.extraBlock=null,i.sort(),function(t,e){let a;t.list.forEach(t=>{a=t.__layout,e.without(t)&&!a.proxyZoom&&(a.matrixChanged?(gt(t,!0),e.add(t),t.isBranch&&mt(t,e),yt(t,e)):a.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),yt(t,e)))})}(i,this.__levelList),function(t){let e,a,i;t.sort(!0),t.levels.forEach(s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(a=e[t],a.isBranch&&a.__tempNumber){i=a.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||_t(i[t])}_t(a)}})}(this.__levelList),function(t){t.list.forEach(wt)}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),a.emitEvent(new v(n,r,this.times)),a.emitEvent(new v(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:a,LAYOUT:i,AFTER:s}=v,n=this.getBlocks(new r(e));e.emitEvent(new v(a,n,this.times)),Bt.fullLayout(e),n.forEach(t=>{t.setAfter()}),e.emitEvent(new v(i,n,this.times)),e.emitEvent(new v(s,n,this.times)),this.addBlocks(n),x.end(t)}static fullLayout(t){St(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),bt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:a}=this.extraBlock||(this.extraBlock=new xt([]));e.length?a.add(t.__world):a.set(t.__world),e.add(t)}}createBlock(t){return new xt(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(){this.__eventIds=[this.target.on_([[v.REQUEST,this.layout,this],[v.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Rt=m.get("Renderer");class Et{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,a){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,a&&(this.config=l.default(a,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(v.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,Rt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),S.clearRecycled()}catch(t){this.rendering=!1,Rt.error(t)}Rt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Rt.warn("rendering");if(this.times>3)return Rt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.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;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=x.start("PartRender"),{canvas:a}=this,i=t.getIntersect(a.bounds),s=new _(i);a.save(),i.spread(Et.clipSpread).ceil(),a.clearWorld(i),a.clipWorld(i),this.__render(i,s),a.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),x.end(t)}__render(t,a){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),m.showRepaint&&m.drawRepaint(i,t),e.render(this.target,i,n),this.renderBounds=a=a||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=a:this.totalBounds.add(a),i.updateRender(a)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const a=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:i}=this.config;if(i&&t>i)return e.requestRender(a);const{frames:s}=this;s.length>30&&s.shift(),s.push(t),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};e.requestRender(a)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:a}=t.old;if(!new _(0,0,e,a).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__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||Rt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,a){this.target.emitEvent(new d(t,this.times,e,a))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[v.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[b.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function Tt(t,e,a){t.__.__font?U.fillText(t,e,a):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Lt(t,e,a,i,s){const n=a.__;k(t)?U.drawStrokesStyle(t,e,!1,a,i,s):(i.setStroke(t,n.__strokeWidth*e,n),i.stroke()),n.__useArrow&&U.strokeArrow(t,a,i,s)}function At(t,e,a,i,s){const n=a.__;k(t)?U.drawStrokesStyle(t,e,!0,a,i,s):(i.setStroke(t,n.__strokeWidth*e,n),U.drawTextStroke(a,i,s))}function Ot(t,e,a,i,s){const n=i.getSameCanvas(!0,!0);n.font=a.__.__font,At(t,2,a,n,s),n.blendMode="outside"===e?"destination-out":"destination-in",U.fillText(a,n,s),n.blendMode="normal",f.copyCanvasByWorld(a,i,n),n.recycle(a.__nowWorld)}Et.clipSpread=10,Object.assign(s,{watcher:(t,e)=>new pt(t,e),layouter:(t,e)=>new Bt(t,e),renderer:(t,e,a)=>new Et(t,e,a),selector:(t,e)=>{},interaction:(t,e,a,i)=>{}}),e.layout=Bt.fullLayout,e.render=function(t,e,a){const i=Object.assign(Object.assign({},a),{topRendering:!0});a.topList=new r,t.__render(e,a),a.topList.length&&a.topList.forEach(t=>t.__render(e,i))};const{getSpread:Pt,copyAndSpread:Ct,toOuterOf:Mt,getOuterOf:Wt,getByMove:Dt,move:It,getIntersectData:Ft}=B,Yt={};let Ut;const{stintSet:Xt}=l,{hasTransparent:Nt}=N;function qt(t,e,a){if(!k(e)||!1===e.visible||0===e.opacity)return;let i;const{boxBounds:s}=a.__layout;switch(e.type){case"image":i=X.image(a,t,e,s,!Ut||!Ut[e.url]);break;case"linear":i=q.linearGradient(e,s);break;case"radial":i=q.radialGradient(e,s);break;case"angular":i=q.conicGradient(e,s);break;case"solid":const{type:n,color:o,opacity:r}=e;i={type:n,style:N.string(o,r)};break;default:T(e.r)||(i={type:"solid",style:N.string(e)})}if(i&&(i.originPaint=e,L(i.style)&&Nt(i.style)&&(i.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;i.strokeStyle=e.style}return i}const zt={compute:function(t,e){const a=e.__,i=[];let s,n,o,r=a.__input[t];w(r)||(r=[r]),Ut=X.recycleImage(t,a);for(let a,s=0,n=r.length;s<n;s++)(a=qt(t,r[s],e))&&(i.push(a),a.strokeStyle&&(o||(o=1),a.strokeStyle.strokeWidth&&(o=Math.max(o,a.strokeStyle.strokeWidth))));a["_"+t]=i.length?i:void 0,i.length?(i.every(t=>t.isTransparent)&&(i.some(t=>t.image)&&(s=!0),n=!0),"fill"===t?(Xt(a,"__isAlphaPixelFill",s),Xt(a,"__isTransparentFill",n)):(Xt(a,"__isAlphaPixelStroke",s),Xt(a,"__isTransparentStroke",n),Xt(a,"__hasMultiStrokeStyle",o))):a.__removePaint(t,!1)},fill:function(t,e,a,i){a.fillStyle=t,Tt(e,a,i)},fills:function(t,e,a,i){let s,n,o;for(let r=0,l=t.length;r<l;r++){if(s=t[r],n=s.originPaint,s.image){if(o?o++:o=1,X.checkImage(s,!e.__.__font,e,a,i))continue;if(!s.style){1===o&&s.image.isPlacehold&&e.drawImagePlaceholder(s,a,i);continue}}if(a.fillStyle=s.style,s.transform||n.scaleFixed){if(a.save(),s.transform&&a.transform(s.transform),n.scaleFixed){const{scaleX:t,scaleY:i}=e.getRenderScaleData(!0);(!0===n.scaleFixed||"zoom-in"===n.scaleFixed&&t>1&&i>1)&&a.scale(1/t,1/i)}n.blendMode&&(a.blendMode=n.blendMode),Tt(e,a,i),a.restore()}else n.blendMode?(a.saveBlendMode(n.blendMode),Tt(e,a,i),a.restoreBlendMode()):Tt(e,a,i)}},fillPathOrText:Tt,fillText:function(t,e,a){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,a=s.length;t<a;t++)o=s[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach(t=>{e.fillText(t.char,t.x,o.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}},stroke:function(t,e,a,i){const s=e.__;if(s.__strokeWidth)if(s.__font)U.strokeText(t,e,a,i);else switch(s.strokeAlign){case"center":Lt(t,1,e,a,i);break;case"inside":!function(t,e,a,i){a.save(),a.clipUI(e),Lt(t,2,e,a,i),a.restore()}(t,e,a,i);break;case"outside":!function(t,e,a,i){const s=e.__;if(s.__fillAfterStroke)Lt(t,2,e,a,i);else{const{renderBounds:n}=e.__layout,o=a.getSameCanvas(!0,!0);e.__drawRenderPath(o),Lt(t,2,e,o,i),o.clipUI(s),o.clearWorld(n),f.copyCanvasByWorld(e,a,o),o.recycle(e.__nowWorld)}}(t,e,a,i)}},strokes:function(t,e,a,i){U.stroke(t,e,a,i)},strokeText:function(t,e,a,i){switch(e.__.strokeAlign){case"center":At(t,1,e,a,i);break;case"inside":Ot(t,"inside",e,a,i);break;case"outside":e.__.__fillAfterStroke?At(t,2,e,a,i):Ot(t,"outside",e,a,i)}},drawTextStroke:function(t,e,a){let i,s=t.__.__textDrawData;const{rows:n,decorationY:o}=s;for(let t=0,a=n.length;t<a;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(o){const{decorationHeight:t}=s;n.forEach(a=>o.forEach(i=>e.strokeRect(a.x,a.y+i,a.width,t)))}},drawStrokesStyle:function(t,e,a,i,s,n){let o;const r=i.__,{__hasMultiStrokeStyle:l}=r;l||s.setStroke(void 0,r.__strokeWidth*e,r);for(let d=0,c=t.length;d<c;d++)if(o=t[d],(!o.image||!X.checkImage(o,!1,i,s,n))&&o.style){if(l){const{strokeStyle:t}=o;t?s.setStroke(o.style,r.__getRealStrokeWidth(t)*e,r,t):s.setStroke(o.style,r.__strokeWidth*e,r)}else s.strokeStyle=o.style;o.originPaint.blendMode?(s.saveBlendMode(o.originPaint.blendMode),a?U.drawTextStroke(i,s,n):s.stroke(),s.restoreBlendMode()):a?U.drawTextStroke(i,s,n):s.stroke()}},shape:function(t,a,i){const s=a.getSameCanvas(),n=a.bounds,o=t.__nowWorld,r=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,p;Mt(r.strokeSpread?(Ct(Yt,r.boxBounds,r.strokeSpread),Yt):r.boxBounds,o,l);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(l))p=s,d=f=l,c=o;else{let s;if(e.fullImageShadow)s=l;else{const t=r.renderShapeSpread?Pt(n,R.swapAndScale(r.renderShapeSpread,g,_)):n;s=Ft(t,l)}u=n.getFitMatrix(s);let{a:w,d:m}=u;u.a<1&&(p=a.getSameCanvas(),t.__renderShape(p,i),g*=w,_*=m),f=Wt(l,u),d=Dt(f,-u.e,-u.f),c=Wt(o,u),It(c,-u.e,-u.f);const y=i.matrix;y?(h=new E(u),h.multiply(y),w*=y.scaleX,m*=y.scaleY):h=u,h.withScale(w,m),i=Object.assign(Object.assign({},i),{matrix:h})}return t.__renderShape(s,i),{canvas:s,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let jt,Gt=new _;const{isSame:Ht}=B;function Vt(t,e,a,i,s,n){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||X.createData(s,i,a,n),!0}function Qt(t,e){$t(t,A.LOAD,e)}function Jt(t,e){$t(t,A.LOADED,e)}function Zt(t,e,a){e.error=a,t.forceUpdate("surface"),$t(t,A.ERROR,e)}function $t(t,e,a){t.hasEvent(e)&&t.emitEvent(new A(e,a))}function Kt(t,e){const{leafer:a}=t;a&&a.viewReady&&(a.renderer.ignore=e)}const{get:te,translate:ee}=O,ae=new _,ie={},se={};function ne(t,e,a,i){const s=L(t)||i?(i?a-i*e:a%e)/((i||Math.floor(a/e))-1):t;return"auto"===t&&s<0?0:s}let oe={},re=W();const{get:le,set:de,rotateOfOuter:ce,translate:he,scaleOfOuter:ue,multiplyParent:fe,scale:pe,rotate:ge,skew:_e}=O;function we(t,e,a,i,s,n,o,r){o&&ge(t,o),r&&_e(t,r.x,r.y),s&&pe(t,s,n),he(t,e.x+a,e.y+i)}const{get:me,scale:ye,copy:ve}=O,{getFloorScale:xe}=P,{abs:Se}=Math;const be={image:function(t,e,a,i,s){let n,o;const r=S.get(a);return jt&&a===jt.paint&&Ht(i,jt.boxBounds)?n=jt.leafPaint:(n={type:a.type,image:r},r.hasAlphaPixel&&(n.isTransparent=!0),jt=r.use>1?{leafPaint:n,paint:a,boxBounds:Gt.set(i)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:a}),r.ready?(Vt(t,e,a,r,n,i),s&&(Qt(t,o),Jt(t,o))):r.error?s&&Zt(t,o,r.error):(s&&(Kt(t,!0),Qt(t,o)),n.loadId=r.load(()=>{Kt(t,!1),t.destroyed||(Vt(t,e,a,r,n,i)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Jt(t,o)),n.loadId=void 0},e=>{Kt(t,!1),Zt(t,o,e),n.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):r.isPlacehold=!0)),n},checkImage:function(t,a,i,s,n){const{scaleX:o,scaleY:r}=X.getImageRenderScaleData(t,i,s,n),{image:l,data:d,originPaint:c}=t,{exporting:h}=n;return!(!d||t.patternId===o+"-"+r&&!h)&&(a&&(d.repeat?a=!1:c.changeful||"miniapp"===e.name&&b.isResizing(i)||h||(a=e.image.isLarge(l,o,r))),a?(i.__.__isFastShadow&&(s.fillStyle=t.style||"#000",s.fill()),X.drawImage(t,o,r,i,s,n),!0):(!t.style||c.sync||h?X.createPattern(t,i,s,n):X.createPatternTask(t,i,s,n),!1))},drawImage:function(t,e,a,i,s,n){const{data:o,image:r}=t,{blendMode:l}=t.originPaint,{opacity:d,transform:c}=o,h=r.getFull(o.filters),u=i.__;let f,{width:p,height:g}=r;(f=c&&!c.onlyScale||u.path||u.cornerRadius)||d||l?(s.save(),f&&s.clipUI(i),l&&(s.blendMode=l),d&&(s.opacity*=d),c&&s.transform(c),s.drawImage(h,0,0,p,g),s.restore()):(o.scaleX&&(p*=o.scaleX,g*=o.scaleY),s.drawImage(h,0,0,p,g))},getImageRenderScaleData:function(t,e,a,i){const s=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:n}=t;if(a){const{pixelRatio:t}=a;s.scaleX*=t,s.scaleY*=t}return n&&n.scaleX&&(s.scaleX*=Math.abs(n.scaleX),s.scaleY*=Math.abs(n.scaleY)),s},recycleImage:function(t,e){const a=e["_"+t];if(w(a)){let i,s,n,o,r;for(let l=0,d=a.length;l<d;l++)i=a[l],s=i.image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,S.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],w(o)||(o=[o])),s.unload(a[l].loadId,!o.some(t=>t.url===r))));return n}return null},createPatternTask:function(t,e,a,i){t.patternTask||(t.patternTask=S.patternTasker.add(()=>dt(this,void 0,void 0,function*(){t.patternTask=null,a.bounds.hit(e.__nowWorld)&&X.createPattern(t,e,a,i),e.forceUpdate("surface")}),300))},createPattern:function(t,a,i,s){let{scaleX:n,scaleY:o}=X.getImageRenderScaleData(t,a,i,s),r=n+"-"+o;if(t.patternId!==r&&!a.destroyed&&(!e.image.isLarge(t.image,n,o)||t.data.repeat)){const{image:i,data:s}=t,{transform:l,gap:d}=s,c=X.getPatternFixScale(t,n,o);let h,u,f,{width:p,height:g}=i;c&&(n*=c,o*=c),p*=n,g*=o,d&&(u=d.x*n/Se(s.scaleX||1),f=d.y*o/Se(s.scaleY||1)),(l||1!==n||1!==o)&&(n*=xe(p+(u||0)),o*=xe(g+(f||0)),h=me(),l&&ve(h,l),ye(h,1/n,1/o));const _=i.getCanvas(p,g,s.opacity,s.filters,u,f,a.leafer&&a.leafer.config.smooth),w=i.getPattern(_,s.repeat||e.origin.noRepeat||"no-repeat",h,t);t.style=w,t.patternId=r}},getPatternFixScale:function(t,a,i){const{image:s}=t;let n,o=e.image.maxPatternSize,r=s.width*s.height;return s.isSVG?a>1&&(n=Math.ceil(a)/a):o>r&&(o=r),(r*=a*i)>o&&(n=Math.sqrt(o/r)),n},createData:function(t,e,a,i){t.data=X.getPatternData(a,i,e)},getPatternData:function(t,e,a){t.padding&&(e=ae.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:i,height:s}=a,{opacity:n,mode:o,align:r,offset:l,scale:d,size:c,rotation:h,skew:u,clipSize:f,repeat:p,gap:g,filters:_}=t,w=e.width===i&&e.height===s,m={mode:o},y="center"!==r&&(h||0)%180==90;let v,x;switch(B.set(se,0,0,y?s:i,y?i:s),o&&"cover"!==o&&"fit"!==o?((d||c)&&(P.getScaleData(d,c,a,ie),v=ie.scaleX,x=ie.scaleY),(r||g||p)&&(v&&B.scale(se,v,x,!0),r&&C.toPoint(r,se,e,se,!0,!0))):w&&!h||(v=x=B.getFitScale(e,se,"fit"!==o),B.put(e,a,r,v,!1,se),B.scale(se,v,x,!0)),l&&M.move(se,l),o){case"stretch":w?v&&(v=x=void 0):(v=e.width/i,x=e.height/s,X.stretchMode(m,e,v,x));break;case"normal":case"clip":if(se.x||se.y||v||f||h||u){let t,a;f&&(t=e.width/f.width,a=e.height/f.height),X.clipMode(m,e,se.x,se.y,v,x,h,u,t,a),t&&(v=v?v*t:t,x=x?x*a:a)}break;case"repeat":(!w||v||h||u)&&X.repeatMode(m,e,i,s,se.x,se.y,v,x,h,u,r,t.freeTransform),p||(m.repeat="repeat");const a=k(p);(g||a)&&(m.gap=function(t,e,a,i,s){let n,o;k(t)?(n=t.x,o=t.y):n=o=t;return{x:ne(n,a,s.width,e&&e.x),y:ne(o,i,s.height,e&&e.y)}}(g,a&&p,se.width,se.height,e));break;default:v&&X.fillOrFitMode(m,e,se.x,se.y,v,x,h)}return m.transform||(e.x||e.y)&&ee(m.transform=te(),e.x,e.y),v&&(m.scaleX=v,m.scaleY=x),n&&n<1&&(m.opacity=n),_&&(m.filters=_),p&&(m.repeat=L(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),m},stretchMode:function(t,e,a,i){const s=le(),{x:n,y:o}=e;n||o?he(s,n,o):s.onlyScale=!0,pe(s,a,i),t.transform=s},fillOrFitMode:function(t,e,a,i,s,n,o){const r=le();he(r,e.x+a,e.y+i),pe(r,s,n),o&&ce(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r},clipMode:function(t,e,a,i,s,n,o,r,l,d){const c=le();we(c,e,a,i,s,n,o,r),l&&(o||r?(de(re),ue(re,e,l,d),fe(c,re)):ue(c,e,l,d)),t.transform=c},repeatMode:function(t,e,a,i,s,n,o,r,l,d,c,h){const u=le();if(h)we(u,e,s,n,o,r,l,d);else{if(l)if("center"===c)ce(u,{x:a/2,y:i/2},l);else switch(ge(u,l),l){case 90:he(u,i,0);break;case 180:he(u,a,i);break;case 270:he(u,0,a)}oe.x=e.x+s,oe.y=e.y+n,he(u,oe.x,oe.y),o&&ue(u,oe,o,r)}t.transform=u}},{toPoint:ke}=D,{hasTransparent:Be}=N,Re={},Ee={};function Te(t,e,a,i){if(a){let s,n,o,r;for(let t=0,l=a.length;t<l;t++)s=a[t],L(s)?(o=t/(l-1),n=N.string(s,i)):(o=s.offset,n=N.string(s.color,i)),e.addColorStop(o,n),!r&&Be(n)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:Le,getDistance:Ae}=M,{get:Oe,rotateOfOuter:Pe,scaleOfOuter:Ce}=O,{toPoint:Me}=D,We={},De={};function Ie(t,e,a,i,s){let n;const{width:o,height:r}=t;if(o!==r||i){const t=Le(e,a);n=Oe(),s?(Ce(n,e,o/r*(i||1),1),Pe(n,e,t+90)):(Ce(n,e,1,o/r*(i||1)),Pe(n,e,t))}return n}const{getDistance:Fe}=M,{toPoint:Ye}=D,Ue={},Xe={};const Ne={linearGradient:function(t,a){let{from:i,to:s,type:n,opacity:o}=t;ke(i||"top",a,Re),ke(s||"bottom",a,Ee);const r=e.canvas.createLinearGradient(Re.x,Re.y,Ee.x,Ee.y),l={type:n,style:r};return Te(l,r,t.stops,o),l},radialGradient:function(t,a){let{from:i,to:s,type:n,opacity:o,stretch:r}=t;Me(i||"center",a,We),Me(s||"bottom",a,De);const l=e.canvas.createRadialGradient(We.x,We.y,0,We.x,We.y,Ae(We,De)),d={type:n,style:l};Te(d,l,t.stops,o);const c=Ie(a,We,De,r,!0);return c&&(d.transform=c),d},conicGradient:function(t,a){let{from:i,to:s,type:n,opacity:o,stretch:r}=t;Ye(i||"center",a,Ue),Ye(s||"bottom",a,Xe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ue.x,Ue.y):e.canvas.createRadialGradient(Ue.x,Ue.y,0,Ue.x,Ue.y,Fe(Ue,Xe)),d={type:n,style:l};Te(d,l,t.stops,o);const c=Ie(a,Ue,Xe,r||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Ie},{copy:qe,move:ze,toOffsetOutBounds:je}=B,{max:Ge,abs:He}=Math,Ve={},Qe=new E,Je={};function Ze(t,e){let a,i,s,n,o=0,r=0,l=0,d=0;return e.forEach(t=>{a=t.x||0,i=t.y||0,n=1.5*(t.blur||0),s=He(t.spread||0),o=Ge(o,s+n-i),r=Ge(r,s+n+a),l=Ge(l,s+n+i),d=Ge(d,s+n-a)}),o===r&&r===l&&l===d?o:[o,r,l,d]}function $e(t,a,i){const{shapeBounds:s}=i;let n,o;e.fullImageShadow?(qe(Ve,t.bounds),ze(Ve,a.x-s.x,a.y-s.y),n=t.bounds,o=Ve):(n=s,o=a),t.copyWorld(i.canvas,n,o)}const{toOffsetOutBounds:Ke}=B,ta={};const ea=Ze;const aa={shadow:function(t,e,a){let i,s;const{__nowWorld:n}=t,{shadow:o}=t.__,{worldCanvas:r,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=a,p=e.getSameCanvas(),g=o.length-1;je(l,Je,d),o.forEach((o,_)=>{let w=1;if(o.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(w=1/t)}p.setWorldShadow(Je.offsetX+(o.x||0)*h*w,Je.offsetY+(o.y||0)*u*w,(o.blur||0)*h*w,N.string(o.color)),s=z.getShadowTransform(t,p,a,o,Je,w),s&&p.setTransform(s),$e(p,Je,a),s&&p.resetTransform(),i=d,o.box&&(p.restore(),p.save(),r&&(p.copyWorld(p,d,n,"copy"),i=n),r?p.copyWorld(r,n,n,"destination-out"):p.copyWorld(a.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,p,i,o.blendMode),g&&_<g&&p.clearWorld(i)}),p.recycle(i)},innerShadow:function(t,e,a){let i,s;const{__nowWorld:n}=t,{innerShadow:o}=t.__,{worldCanvas:r,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=a,p=e.getSameCanvas(),g=o.length-1;Ke(l,ta,d),o.forEach((o,_)=>{let w=1;if(o.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(w=1/t)}p.save(),p.setWorldShadow(ta.offsetX+(o.x||0)*h*w,ta.offsetY+(o.y||0)*u*w,(o.blur||0)*h*w),s=z.getShadowTransform(t,p,a,o,ta,w,!0),s&&p.setTransform(s),$e(p,ta,a),p.restore(),r?(p.copyWorld(p,d,n,"copy"),p.copyWorld(r,n,n,"source-out"),i=n):(p.copyWorld(a.canvas,c,l,"source-out"),i=d),p.fillWorld(i,N.string(o.color),"source-in"),f.copyCanvasByWorld(t,e,p,i,o.blendMode),g&&_<g&&p.clearWorld(i)}),p.recycle(i)},blur:function(t,e,a){const{blur:i}=t.__;a.setWorldBlur(i*t.__nowWorld.a),a.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),a.filter="none"},backgroundBlur:function(t,e,a){},getShadowRenderSpread:Ze,getShadowTransform:function(t,e,a,i,s,n,o){if(i.spread){const a=2*i.spread*n*(o?-1:1),{width:r,height:l}=t.__layout.strokeBounds;return Qe.set().scaleOfOuter({x:(s.x+s.width/2)*e.pixelRatio,y:(s.y+s.height/2)*e.pixelRatio},1+a/r,1+a/l),Qe}},isTransformShadow(t){},getInnerShadowSpread:ea},{excludeRenderBounds:ia}=g;let sa;function na(t,e,a,i,s,n,o,r){switch(e){case"grayscale":sa||(sa=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,a,i,s,n){const o=t.__nowWorld;a.resetTransform(),a.opacity=1,a.useMask(i,o),n&&i.recycle(o);ra(t,e,a,1,s,n)}(t,a,i,s,o,r);break;case"opacity-path":ra(t,a,i,n,o,r);break;case"path":r&&a.restore()}}function oa(t){return t.getSameCanvas(!1,!0)}function ra(t,e,a,i,s,n){const o=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(a,o,void 0,s),n?a.recycle(o):a.clearWorld(o)}j.prototype.__renderMask=function(t,e){let a,i,s,n,o,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(a=l[d],r=a.__.mask,r){o&&(na(this,o,t,s,i,n,void 0,!0),i=s=null),"clipping"!==r&&"clipping-path"!==r||ia(a,e)||a.__render(t,e),n=a.__.opacity,sa=!1,"path"===r||"clipping-path"===r?(n<1?(o="opacity-path",s||(s=oa(t))):(o="path",t.save()),a.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",i||(i=oa(t)),s||(s=oa(t)),a.__render(i,e));continue}const c=1===n&&a.__.__blendMode;c&&na(this,o,t,s,i,n,void 0,!1),ia(a,e)||a.__render(s||t,e),c&&na(this,o,t,s,i,n,c,!1)}na(this,o,t,s,i,n,void 0,!0)};const la=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",da=la+"_#~&*+\\=|≮≯≈≠=…",ca=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 ha(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ua=ha("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),fa=ha("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),pa=ha(la),ga=ha(da),_a=ha("- —/~|┆·");var wa;!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"}(wa||(wa={}));const{Letter:ma,Single:ya,Before:va,After:xa,Symbol:Sa,Break:ba}=wa;function ka(t){return ua[t]?ma:_a[t]?ba:fa[t]?va:pa[t]?xa:ga[t]?Sa:ca.test(t)?ya:ma}const Ba={trimRight(t){const{words:e}=t;let a,i=0,s=e.length;for(let n=s-1;n>-1&&(a=e[n].data[0]," "===a.char);n--)i++,t.width-=a.width;i&&e.splice(s-i,i)}};function Ra(t,e,a){switch(e){case"title":return a?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Ea}=Ba,{Letter:Ta,Single:La,Before:Aa,After:Oa,Symbol:Pa,Break:Ca}=wa;let Ma,Wa,Da,Ia,Fa,Ya,Ua,Xa,Na,qa,za,ja,Ga,Ha,Va,Qa,Ja,Za=[];function $a(t,e){Na&&!Xa&&(Xa=Na),Ma.data.push({char:t,width:e}),Da+=e}function Ka(){Ia+=Da,Ma.width=Da,Wa.words.push(Ma),Ma={data:[]},Da=0}function ti(){Ha&&(Va.paraNumber++,Wa.paraStart=!0,Ha=!1),Na&&(Wa.startCharSize=Xa,Wa.endCharSize=Na,Xa=0),Wa.width=Ia,Qa.width?Ea(Wa):Ja&&ei(),Za.push(Wa),Wa={words:[]},Ia=0}function ei(){Ia>(Va.maxWidth||0)&&(Va.maxWidth=Ia)}const{top:ai,right:ii,bottom:si,left:ni}=I;function oi(t,e,a){const{bounds:i,rows:s}=t;i[e]+=a;for(let t=0;t<s.length;t++)s[t][e]+=a}const ri={getDrawData:function(t,a){L(t)||(t=String(t));let i=0,s=0,n=a.__getInput("width")||0,o=a.__getInput("height")||0;const{__padding:r}=a;r&&(n?(i=r[ni],n-=r[ii]+r[ni],!n&&(n=.01)):a.autoSizeAlign||(i=r[ni]),o?(s=r[ai],o-=r[ai]+r[si],!o&&(o=.01)):a.autoSizeAlign||(s=r[ai]));const l={bounds:{x:i,y:s,width:n,height:o},rows:[],paraNumber:0,font:e.canvas.font=a.__font};return function(t,a,i){Va=t,Za=t.rows,Qa=t.bounds,Ja=!Qa.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:n,textCase:o}=i,{canvas:r}=e,{width:l}=Qa;if(i.__isCharMode){const t="none"!==i.textWrap,e="break"===i.textWrap;Ha=!0,za=null,Xa=Ua=Na=Da=Ia=0,Ma={data:[]},Wa={words:[]},s&&(a=[...a]);for(let i=0,d=a.length;i<d;i++)Ya=a[i],"\n"===Ya?(Da&&Ka(),Wa.paraEnd=!0,ti(),Ha=!0):(qa=ka(Ya),qa===Ta&&"none"!==o&&(Ya=Ra(Ya,o,!Da)),Ua=r.measureText(Ya).width,s&&(s<0&&(Na=Ua),Ua+=s),ja=qa===La&&(za===La||za===Ta)||za===La&&qa!==Oa,Ga=!(qa!==Aa&&qa!==La||za!==Pa&&za!==Oa),Fa=Ha&&n?l-n:l,t&&l&&Ia+Da+Ua>Fa&&(e?(Da&&Ka(),Ia&&ti()):(Ga||(Ga=qa===Ta&&za==Oa),ja||Ga||qa===Ca||qa===Aa||qa===La||Da+Ua>Fa?(Da&&Ka(),Ia&&ti()):Ia&&ti()))," "===Ya&&!0!==Ha&&Ia+Da===0||(qa===Ca?(" "===Ya&&Da&&Ka(),$a(Ya,Ua),Ka()):ja||Ga?(Da&&Ka(),$a(Ya,Ua)):$a(Ya,Ua)),za=qa);Da&&Ka(),Ia&&ti(),Za.length>0&&(Za[Za.length-1].paraEnd=!0)}else a.split("\n").forEach(t=>{Va.paraNumber++,Ia=r.measureText(t).width,Za.push({x:n||0,text:t,width:Ia,paraStart:!0}),Ja&&ei()})}(l,t,a),r&&function(t,e,a,i,s){if(!i&&a.autoSizeAlign)switch(a.textAlign){case"left":oi(e,"x",t[ni]);break;case"right":oi(e,"x",-t[ii])}if(!s&&a.autoSizeAlign)switch(a.verticalAlign){case"top":oi(e,"y",t[ai]);break;case"bottom":oi(e,"y",-t[si])}}(r,l,a,n,o),function(t,e){const{rows:a,bounds:i}=t,s=a.length,{__lineHeight:n,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=i,w=n*s+(h?h*(t.paraNumber-1):0),m=o;if(l&&w>_)w=Math.max(_,n),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,v,x,S=g||u?g:t.maxWidth;for(let o=0,c=s;o<c;o++){if(y=a[o],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&h&&o>0&&(m+=h),y.y=m,m+=n,t.overflow>o&&m>w&&(y.isOverflow=!0,t.overflow=o+1),v=y.x,x=y.width,r<0&&(y.width<0?(x=-y.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<i.x&&(i.x=v),x>i.width&&(i.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=a.length))}i.y=p,i.height=w}(l,a),a.__isCharMode&&function(t,e,a){const{rows:i}=t,{textAlign:s,paraIndent:n,letterSpacing:o}=e,r=a&&s.includes("both"),l=r||a&&s.includes("justify"),d=l&&s.includes("letter");let c,h,u,f,p,g,_,w,m,y;i.forEach(t=>{t.words&&(p=n&&t.paraStart?n:0,w=t.words.length,l&&(y=!t.paraEnd||r,h=a-t.width-p,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?h/(w-1):0),g=o||t.isOverflow||d?0:u?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===g?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,c=t.x,t.data=[],t.words.forEach((e,a)=>{1===g?(_={char:"",x:c},c=function(t,e,a){return t.forEach(t=>{a.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,a,i,s){return t.forEach(t=>{(i||" "!==t.char)&&(t.x=e,a.push(t)),e+=t.width,s&&(e+=s)}),e}(e.data,c,t.data,t.isOverflow,y&&f),y&&(m=a===w-1,u?m||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(m?1:0))))})),t.words=null)})}(l,a,n),l.overflow&&function(t,a,i,s){if(!s)return;const{rows:n,overflow:o}=t;let{textOverflow:r}=a;if(n.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,c=i+s-d;("none"===a.textWrap?n:[n[o-1]]).forEach(e=>{if(e.isOverflow&&e.data){let a=e.data.length-1;for(let i=a;i>-1&&(t=e.data[i],l=t.x+t.width,!(i===a&&l<c));i--){if(l<c&&" "!==t.char||!i){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,a,i,n),"none"!==a.textDecoration&&function(t,e){let a,i=0;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,k(n)?(a=n.type,n.color&&(t.decorationColor=N.string(n.color)),n.offset&&(i=Math.min(.3*s,Math.max(n.offset,.15*-s)))):a=n,a){case"under":t.decorationY=[.15*s+i];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s+i,.35*-s]}}(l,a),l}};const li={string:function(t,e){if(!t)return"#000";const a=F(e)&&e<1;if(L(t)){if(!a||!N.object)return t;t=N.object(t)}let i=T(t.a)?1:t.a;a&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}};Object.assign(G,ri),Object.assign(N,li),Object.assign(U,zt),Object.assign(X,be),Object.assign(q,Ne),Object.assign(z,aa);const{setPoint:di,addPoint:ci,toBounds:hi}=H;const ui={syncExport(t,e,a){let i;Q.running=!0;try{const s=J.fileType(e),n=e.includes(".");a=J.getExportOptions(a);const{toURL:o}=Z,{download:r}=Z.origin;if("json"===s)n&&r(o(JSON.stringify(t.toJSON(a.json)),"text"),e),i={data:!!n||t.toJSON(a.json)};else if("svg"===s)n&&r(o(t.toSVG(),"svg"),e),i={data:!!n||t.toSVG()};else{let s,n,o=1,r=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:h}=t,{slice:u,clip:f,trim:p,screenshot:g,padding:_,onCanvas:w}=a,m=$(a.smooth)?!c||c.config.smooth:a.smooth,y=a.contextSettings||(c?c.config.contextSettings:void 0),v=d&&g&&$(a.fill)?t.fill:a.fill,x=J.isOpaqueImage(e)||v,S=new K;if(g)s=!0===g?d?c.canvas.bounds:t.worldRenderBounds:g;else{let e=a.relative||(d?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":S.set(l);break;case"local":S.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=c||t;default:S.set(l).divide(t.getTransform(e));const a=e.worldTransform;o/=o/a.scaleX,r/=r/a.scaleY}s=t.getBounds("render",e)}const b={scaleX:1,scaleY:1};tt.getScaleData(a.scale,a.size,s,b);let k=a.pixelRatio||1,{x:B,y:R,width:E,height:T}=new V(s).scale(b.scaleX,b.scaleY);f&&(B+=f.x,R+=f.y,E=f.width,T=f.height);const L={exporting:!0,matrix:S.scale(1/b.scaleX,1/b.scaleY).invert().translate(-B,-R).withScale(1/o*b.scaleX,1/r*b.scaleY)};let A,O=et.canvas({width:Math.floor(E),height:Math.floor(T),pixelRatio:k,smooth:m,contextSettings:y});u&&(A=t,A.__worldOpacity=0,t=c||t,L.bounds=O.bounds),O.save();const P=h&&!$(v),C=t.get("fill");if(P&&(t.fill=""),Z.render(t,O,L),P&&(t.fill=C),O.restore(),A&&A.__updateWorldOpacity(),p){n=function(t){const{width:e,height:a}=t.view,{data:i}=t.context.getImageData(0,0,e,a);let s,n,o,r=0;for(let t=0;t<i.length;t+=4)0!==i[t+3]&&(s=r%e,n=(r-s)/e,o?ci(o,s,n):di(o={},s,n)),r++;const l=new V;return o&&(hi(o,l),l.scale(1/t.pixelRatio).ceil()),l}(O);const t=O,{width:e,height:a}=n,i={x:0,y:0,width:e,height:a,pixelRatio:k};O=et.canvas(i),O.copyWorld(t,n,i),t.destroy()}if(_){const[t,e,a,i]=tt.fourNumber(_),s=O,{width:n,height:o}=s;O=et.canvas({width:n+i+e,height:o+t+a,pixelRatio:k}),O.copyWorld(s,s.bounds,{x:i,y:t,width:n,height:o}),s.destroy()}x&&O.fillWorld(O.bounds,v||"#FFFFFF","destination-over"),w&&w(O);i={data:"canvas"===e?O:O.export(e,a),width:O.pixelWidth,height:O.pixelHeight,renderBounds:s,trimBounds:n};const M=c&&c.app;M&&M.canvasManager&&M.canvasManager.clearRecycled()}}catch(t){i={data:"",error:t}}return Q.running=!1,i},export(t,e,a){return Q.running=!0,function(t){fi||(fi=new at);return new Promise(e=>{fi.add(()=>dt(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(i=>new Promise(s=>{const n=()=>dt(this,void 0,void 0,function*(){if(!it.isComplete)return Z.requestRender(n);const o=Q.syncExport(t,e,a);o.data instanceof Promise&&(o.data=yield o.data),i(o),s()});t.updateLayout(),pi(t);const{leafer:o}=t;o?o.waitViewCompleted(n):n()}))}};let fi;function pi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>pi(t))}const gi=st.prototype,_i=nt.get("@leafer-in/export");gi.export=function(t,e){const{quality:a,blob:i}=J.getExportOptions(e);return t.includes(".")?this.saveAs(t,a):i?this.toBlob(t,a):this.toDataURL(t,a)},gi.toBlob=function(t,e){return new Promise(a=>{Z.origin.canvasToBolb(this.view,t,e).then(t=>{a(t)}).catch(t=>{_i.error(t),a(null)})})},gi.toDataURL=function(t,e){return Z.origin.canvasToDataURL(this.view,t,e)},gi.saveAs=function(t,e){return new Promise(a=>{Z.origin.canvasSaveAs(this.view,t,e).then(()=>{a(!0)}).catch(t=>{_i.error(t),a(!1)})})},ot.add("export"),Object.assign(Q,ui),rt.prototype.export=function(t,e){return Q.export(this,t,e)},rt.prototype.syncExport=function(t,e){return Q.syncExport(this,t,e)};export{Bt as Layouter,ct as LeaferCanvas,lt as PathNodeHandleType,Et as Renderer,pt as Watcher,ft as useCanvas};
|
|
2
2
|
//# sourceMappingURL=node.esm.min.js.map
|