leafer-draw 1.0.0-rc.26 → 1.0.0-rc.28

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/web.esm.js CHANGED
@@ -6,6 +6,24 @@ export * from '@leafer-ui/draw';
6
6
 
7
7
  const debug$3 = Debug.get('LeaferCanvas');
8
8
  class LeaferCanvas extends LeaferCanvasBase {
9
+ set zIndex(zIndex) {
10
+ const { style } = this.view;
11
+ style.zIndex = zIndex;
12
+ this.setAbsolute(this.view);
13
+ }
14
+ set childIndex(index) {
15
+ const { view, parentView } = this;
16
+ if (view && parentView) {
17
+ const beforeNode = parentView.children[index];
18
+ if (beforeNode) {
19
+ this.setAbsolute(beforeNode);
20
+ parentView.insertBefore(view, beforeNode);
21
+ }
22
+ else {
23
+ parentView.appendChild(beforeNode);
24
+ }
25
+ }
26
+ }
9
27
  init() {
10
28
  const { view } = this.config;
11
29
  view ? this.__createViewFrom(view) : this.__createView();
@@ -50,9 +68,7 @@ class LeaferCanvas extends LeaferCanvasBase {
50
68
  this.__createView();
51
69
  const view = this.view;
52
70
  if (parent.hasChildNodes()) {
53
- const { style } = view;
54
- style.position = 'absolute';
55
- style.top = style.left = '0px';
71
+ this.setAbsolute(view);
56
72
  parent.style.position || (parent.style.position = 'relative');
57
73
  }
58
74
  parent.appendChild(view);
@@ -63,6 +79,11 @@ class LeaferCanvas extends LeaferCanvasBase {
63
79
  this.__createView();
64
80
  }
65
81
  }
82
+ setAbsolute(view) {
83
+ const { style } = view;
84
+ style.position = 'absolute';
85
+ style.top = style.left = '0px';
86
+ }
66
87
  updateViewSize() {
67
88
  const { width, height, pixelRatio } = this;
68
89
  const { style } = this.view;
@@ -182,16 +203,14 @@ function useCanvas(_canvasType, _power) {
182
203
  loadImage(src) {
183
204
  return new Promise((resolve, reject) => {
184
205
  const img = new Image();
185
- const { suffix, crossOrigin } = Platform.image;
206
+ const { crossOrigin } = Platform.image;
186
207
  if (crossOrigin) {
187
208
  img.setAttribute('crossOrigin', crossOrigin);
188
209
  img.crossOrigin = crossOrigin;
189
210
  }
190
211
  img.onload = () => { resolve(img); };
191
212
  img.onerror = (e) => { reject(e); };
192
- if (suffix && !src.startsWith('data:') && !src.startsWith('blob:'))
193
- src += (src.includes("?") ? "&" : "?") + suffix;
194
- img.src = src;
213
+ img.src = Platform.image.getRealURL(src);
195
214
  });
196
215
  }
197
216
  };
@@ -1438,7 +1457,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
1438
1457
  width *= data.scaleX;
1439
1458
  height *= data.scaleY;
1440
1459
  }
1441
- allowPaint = width * height > Platform.image.maxCacheSize;
1460
+ allowPaint = (width * height > Platform.image.maxCacheSize) || Export.running;
1442
1461
  }
1443
1462
  else {
1444
1463
  allowPaint = false;
@@ -1950,7 +1969,8 @@ function createRows(drawData, content, style) {
1950
1969
  if (breakAll) {
1951
1970
  if (wordWidth)
1952
1971
  addWord();
1953
- addRow();
1972
+ if (rowWidth)
1973
+ addRow();
1954
1974
  }
1955
1975
  else {
1956
1976
  if (!afterBreak)
@@ -1958,10 +1978,12 @@ function createRows(drawData, content, style) {
1958
1978
  if (langBreak || afterBreak || charType === Break || charType === Before || charType === Single || (wordWidth + charWidth > realWidth)) {
1959
1979
  if (wordWidth)
1960
1980
  addWord();
1961
- addRow();
1981
+ if (rowWidth)
1982
+ addRow();
1962
1983
  }
1963
1984
  else {
1964
- addRow();
1985
+ if (rowWidth)
1986
+ addRow();
1965
1987
  }
1966
1988
  }
1967
1989
  }
@@ -2347,6 +2369,7 @@ const ExportModule = {
2347
2369
  }
2348
2370
  const { leafer } = leaf;
2349
2371
  if (leafer) {
2372
+ checkLazy(leaf);
2350
2373
  leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
2351
2374
  options = FileHelper.getExportOptions(options);
2352
2375
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
@@ -2354,6 +2377,8 @@ const ExportModule = {
2354
2377
  const { slice, trim, onCanvas } = options;
2355
2378
  let scale = options.scale || 1;
2356
2379
  let pixelRatio = options.pixelRatio || 1;
2380
+ const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
2381
+ const contextSettings = options.contextSettings || leafer.config.contextSettings;
2357
2382
  if (leaf.isApp) {
2358
2383
  scale *= pixelRatio;
2359
2384
  pixelRatio = leaf.app.pixelRatio;
@@ -2392,7 +2417,7 @@ const ExportModule = {
2392
2417
  renderBounds = leaf.getBounds('render', relative);
2393
2418
  }
2394
2419
  const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
2395
- let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio });
2420
+ let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
2396
2421
  const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
2397
2422
  if (slice) {
2398
2423
  leaf = leafer;
@@ -2438,6 +2463,12 @@ function addTask(task) {
2438
2463
  tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
2439
2464
  });
2440
2465
  }
2466
+ function checkLazy(leaf) {
2467
+ if (leaf.__.__needComputePaint)
2468
+ leaf.__.__computePaint();
2469
+ if (leaf.isBranch)
2470
+ leaf.children.forEach(child => checkLazy(child));
2471
+ }
2441
2472
 
2442
2473
  const canvas = LeaferCanvasBase.prototype;
2443
2474
  const debug = Debug.get('@leafer-ui/export');
@@ -1 +1 @@
1
- import{Debug as t,LeaferCanvasBase as e,Platform as i,DataHelper as n,canvasSizeAttrs as s,ResizeEvent as o,canvasPatch as a,Creator as r,LeaferImage as d,FileHelper as l,LeafList as h,RenderEvent as c,ChildEvent as u,WatchEvent as f,PropertyEvent as p,LeafHelper as g,BranchHelper as _,Bounds as w,LeafBoundsHelper as y,LeafLevelList as m,LayoutEvent as v,Run as x,ImageManager as b,AnimateEvent as B,BoundsHelper as R,MatrixHelper as k,AlignHelper as E,ImageEvent as L,AroundHelper as S,PointHelper as O,Direction4 as A,TwoPointBoundsHelper as W,TaskProcessor as C,Matrix as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as M,ColorConvert as D,PaintGradient as I,Export as P,Group as F,TextConvert as V,Paint as z,Effect as U}from"@leafer-ui/draw";export*from"@leafer-ui/draw";const Y=t.get("LeaferCanvas");class N extends e{init(){const{view:t}=this.config;t?this.__createViewFrom(t):this.__createView();const{style:e}=this.view;if(e.display||(e.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(e.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(this.config)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;if(t.hasChildNodes()){const{style:e}=i;e.position="absolute",e.top=e.left="0px",t.style.position||(t.style.position="relative")}t.appendChild(i)}else Y.error(`no id: ${t}`),this.__createView()}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:n}=this.view;n.width=t+"px",n.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.clientBounds=this.view.getBoundingClientRect()}startAutoLayout(t,e){this.autoBounds=t,this.resizeListener=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t&&(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect()))}catch(t){this.imitateResizeObserver()}}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const e=this.view,{x:i,y:a,width:r,height:d}=this.autoBounds.getBoundsFrom(t);if(r!==this.width||d!==this.height){const{style:t}=e,{pixelRatio:l}=this;t.marginLeft=i+"px",t.marginTop=a+"px";const h={width:r,height:d,pixelRatio:l},c={};n.copyAttrs(c,this,s),this.resize(h),void 0!==this.width&&this.resizeListener(new o(h,c))}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}a(CanvasRenderingContext2D.prototype),a(Path2D.prototype);const{mineType:G,fileType:X}=l;function j(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>t.toDataURL(G(e),i),canvasToBolb:(t,e,i)=>new Promise((n=>t.toBlob(n,G(e),i))),canvasSaveAs:(t,e,n)=>{const s=t.toDataURL(G(X(e)),n);return i.origin.download(s,e)},download:(t,e)=>new Promise((i=>{let n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),i()})),loadImage:t=>new Promise(((e,n)=>{const s=new Image,{suffix:o,crossOrigin:a}=i.image;a&&(s.setAttribute("crossOrigin",a),s.crossOrigin=a),s.onload=()=>{e(s)},s.onerror=t=>{n(t)},!o||t.startsWith("data:")||t.startsWith("blob:")||(t+=(t.includes("?")?"&":"?")+o),s.src=t}))},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=r.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(r,{canvas:(t,e)=>new N(t,e),image:t=>new d(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},i.devicePixelRatio=Math.max(1,devicePixelRatio);const{userAgent:q}=navigator;q.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):q.indexOf("Safari")>-1&&-1===q.indexOf("Chrome")&&(i.fullImageShadow=!0),q.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):q.indexOf("Mac")>-1?i.os="Mac":q.indexOf("Linux")>-1&&(i.os="Linux");class H{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new h;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 h,this.target=t,e&&(this.config=n.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(c.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===u.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,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new h,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(p.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.REMOVE],this.__onChildEvent,this),t.on_(f.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:Q,updateBounds:J,updateAllWorldOpacity:Z}=g,{pushAllChildBranch:$,pushAllParent:K}=_;const{worldBounds:tt}=y,et={x:0,y:0,width:1e5,height:1e5};class it{constructor(t){this.updatedBounds=new w,this.beforeBounds=new w,this.afterBounds=new w,t instanceof Array&&(t=new h(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,tt)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(et):this.afterBounds.setListWithFn(t,tt),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:nt,updateAllChange:st}=g,ot=t.get("Layouter");class at{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=n.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.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){ot.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ot.warn("layouting"):this.times>3?ot.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.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:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=v,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new v(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(Q(t,!0),e.add(t),t.isBranch&&$(t,e),K(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),K(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||J(n[t])}J(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&Z(t),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new v(o,r,this.times)),i.emitEvent(new v(a,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:i,LAYOUT:n,AFTER:s}=v,o=this.getBlocks(new h(e));e.emitEvent(new v(i,o,this.times)),at.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new v(n,o,this.times)),e.emitEvent(new v(s,o,this.times)),this.addBlocks(o),x.end(t)}static fullLayout(t){nt(t,!0),t.isBranch?_.updateBounds(t):g.updateBounds(t),st(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new it([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new it(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:t}=this;this.__eventIds=[t.on_(v.REQUEST,this.layout,this),t.on_(v.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const rt=t.get("Renderer");class dt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=n.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(v.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new w,rt.log(e.innerName,"---\x3e");try{this.emitRender(c.START),this.renderOnce(t),this.emitRender(c.END,this.totalBounds),b.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 w,this.renderOptions={},t)this.emitRender(c.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(c.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(c.RENDER,this.renderBounds,this.renderOptions),this.emitRender(c.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 rt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=x.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),o=e.includes(this.target.__world),a=new w(s);n.save(),o&&!t.showRepaint?n.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(s,!0),n.clipWorld(s,!0)),this.__render(s,o,a),n.restore(),x.end(i)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),x.end(t)}__render(e,i,n){const s=e.includes(this.target.__world)?{includes:i}:{bounds:e,includes:i};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=n||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.showHitView&&this.renderHitView(s),t.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new w;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();i.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(B.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(c.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new w(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new w(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||rt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new c(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.REQUEST,this.update,this),t.on_(v.END,this.__onLayoutEnd,this),t.on_(c.AGAIN,this.renderAgain,this),t.on_(o.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 lt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,o)}function ht(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?ft(t,!0,e,i):ut(e,i);break;case"inside":ct("inside",t,s,e,i);break;case"outside":ct("outside",t,s,e,i)}}function ct(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?ft(e,!0,n,r):ut(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",lt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function ut(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;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)})),s&&e.strokeRect(i.x,i.y+s,i.width,o)}function ft(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&M.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?ut(i,n):n.stroke(),n.restoreBlendMode()):e?ut(i,n):n.stroke())}Object.assign(r,{watcher:(t,e)=>new H(t,e),layouter:(t,e)=>new at(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),i.layout=at.fullLayout;const{getSpread:pt,getOuterOf:gt,getByMove:_t,getIntersectData:wt}=R;let yt;function mt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:D.string(a,r)};case"image":return M.image(i,t,e,n,!yt||!yt[e.url]);case"linear":return I.linearGradient(e,n);case"radial":return I.radialGradient(e,n);case"angular":return I.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:D.string(e)}:void 0}}const vt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),yt=M.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=mt(t,o[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?lt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&M.checkImage(e,i,n,!o)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),o?lt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?lt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?lt(e,i):s?i.fill(s):i.fill())},fillText:lt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)ht(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)ht(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),ft(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ft(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),ft(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:ht,drawTextStroke:ut,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,c=wt(n?pt(e.bounds,l===h?n*l:[n*h,n*l]):e.bounds,s);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),r=gt(s,a),o=_t(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let xt={};const{get:bt,rotateOfOuter:Bt,translate:Rt,scaleOfOuter:kt,scale:Et,rotate:Lt}=k;function St(t,e,i,n,s,o,a){const r=bt();Rt(r,e.x+i,e.y+n),Et(r,s,o),a&&Bt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Ot(t,e,i,n,s,o,a){const r=bt();Rt(r,e.x+i,e.y+n),s&&Et(r,s,o),a&&Lt(r,a),t.transform=r}function At(t,e,i,n,s,o,a,r,d,l){const h=bt();if(d)if("center"===l)Bt(h,{x:i/2,y:n/2},d);else switch(Lt(h,d),d){case 90:Rt(h,n,0);break;case 180:Rt(h,i,n);break;case 270:Rt(h,0,i)}xt.x=e.x+s,xt.y=e.y+o,Rt(h,xt.x,xt.y),a&&kt(h,xt,a,r),t.transform=h}const{get:Wt,translate:Ct}=k,Tt=new w,Mt={};function Dt(t,e,i,n){const{blendMode:s}=i;s&&(t.blendMode=s),t.data=It(i,n,e)}function It(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Tt.set(e).shrink(t.padding));const{opacity:o,mode:a,align:r,offset:d,scale:l,size:h,rotation:c,repeat:u}=t,f=e.width===n&&e.height===s,p={mode:a},g="center"!==r&&(c||0)%180==90,_=g?s:n,w=g?n:s;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)h?(y=("number"==typeof h?h:h.width)/n,m=("number"==typeof h?h:h.height)/s):l&&(y="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y);else if(!f||c){const t=e.width/_,i=e.height/w;y=m="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-n*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:_,height:w};y&&(t.width*=y,t.height*=m),E.toPoint(r,t,e,Mt,!0),v+=Mt.x,x+=Mt.y}switch(d&&(v+=d.x,x+=d.y),a){case"strench":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||c)&&Ot(p,e,v,x,y,m,c);break;case"repeat":(!f||y||c)&&At(p,e,n,s,v,x,y,m,c,r),u||(p.repeat="repeat");break;default:y&&St(p,e,v,x,y,m,c)}return p.transform||(e.x||e.y)&&(p.transform=Wt(),Ct(p.transform,e.x,e.y)),y&&"strench"!==a&&(p.scaleX=y,p.scaleY=m),p.width=n,p.height=s,o&&(p.opacity=o),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let Pt,Ft=new w;const{isSame:Vt}=R;function zt(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.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||Dt(s,n,i,o),!0}function Ut(t,e){Gt(t,L.LOAD,e)}function Yt(t,e){Gt(t,L.LOADED,e)}function Nt(t,e,i){e.error=i,t.forceUpdate("surface"),Gt(t,L.ERROR,e)}function Gt(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function Xt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:jt,scale:qt,copy:Ht}=k,{ceil:Qt,abs:Jt}=Math;function Zt(t,e,n){let{scaleX:s,scaleY:o}=b.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o;if(e.patternId===a||t.destroyed)return!1;{s=Jt(s),o=Jt(o);const{image:t,data:r}=e;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=jt(),Ht(l,g),qt(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,h*=s,c*=o;const w=h*c;if(!_&&w>i.image.maxCacheSize)return!1;let y=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,o/=d,h/=d,c/=d),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(l||(l=jt(),g&&Ht(l,g)),qt(l,1/s,1/o));const m=t.getCanvas(Qt(h)||1,Qt(c)||1,p),v=t.getPattern(m,_||i.origin.noRepeat||"no-repeat",l,e);return e.style=v,e.patternId=a,!0}}function $t(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{d(n.next(t))}catch(t){o(t)}}function r(t){try{d(n.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Kt}=Math;const te={image:function(t,e,i,n,s){let o,a;const r=b.get(i);return Pt&&i===Pt.paint&&Vt(n,Pt.boxBounds)?o=Pt.leafPaint:(o={type:i.type,image:r},Pt=r.use>1?{leafPaint:o,paint:i,boxBounds:Ft.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(zt(t,e,i,r,o,n),s&&(Ut(t,a),Yt(t,a))):r.error?s&&Nt(t,a,r.error):(Xt(t,!0),s&&Ut(t,a),o.loadId=r.load((()=>{Xt(t,!1),t.destroyed||(zt(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Yt(t,a)),o.loadId=null}),(e=>{Xt(t,!1),Nt(t,a,e),o.loadId=null}))),o},checkImage:function(t,e,n,s){const{scaleX:o,scaleY:a}=b.patternLocked?t.__world:t.__nowWorld;if(n.data&&n.patternId!==o+"-"+a){const{data:r}=n;if(s)if(r.repeat)s=!1;else{let{width:t,height:n}=r;t*=Kt(o)*e.pixelRatio,n*=Kt(a)*e.pixelRatio,r.scaleX&&(t*=r.scaleX,n*=r.scaleY),s=t*n>i.image.maxCacheSize}return s?(e.save(),e.clip(),n.blendMode&&(e.blendMode=n.blendMode),r.opacity&&(e.opacity*=r.opacity),r.transform&&e.transform(r.transform),e.drawImage(n.image.view,0,0,r.width,r.height),e.restore(),!0):(!n.style||P.running?Zt(t,n,e.pixelRatio):n.patternTask||(n.patternTask=b.patternTasker.add((()=>$t(this,void 0,void 0,(function*(){n.patternTask=null,e.bounds.hit(t.__nowWorld)&&Zt(t,n,e.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},createPattern:Zt,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,a;for(let r=0,d=i.length;r<d;r++)n=i[r].image,a=n&&n.url,a&&(s||(s={}),s[a]=!0,b.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:Dt,getPatternData:It,fillOrFitMode:St,clipMode:Ot,repeatMode:At},{toPoint:ee}=S,ie={},ne={};function se(t,e,i){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),D.string(n,i)):t.addColorStop(n.offset,D.string(n.color,i))}const{getAngle:oe,getDistance:ae}=O,{get:re,rotateOfOuter:de,scaleOfOuter:le}=k,{toPoint:he}=S,ce={},ue={};function fe(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=oe(e,i);o=re(),s?(le(o,e,a/r*(n||1),1),de(o,e,t+90)):(le(o,e,1,a/r*(n||1)),de(o,e,t))}return o}const{getDistance:pe}=O,{toPoint:ge}=S,_e={},we={};const ye={linearGradient:function(t,e){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;ee(n||"top",e,ie),ee(s||"bottom",e,ne);const d=i.canvas.createLinearGradient(ie.x,ie.y,ne.x,ne.y);se(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,e){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;he(n||"center",e,ce),he(s||"bottom",e,ue);const l=i.canvas.createRadialGradient(ce.x,ce.y,0,ce.x,ce.y,ae(ce,ue));se(l,t.stops,a);const h={type:o,style:l},c=fe(e,ce,ue,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(t,e){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ge(n||"center",e,_e),ge(s||"bottom",e,we);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,_e.x,_e.y):i.canvas.createRadialGradient(_e.x,_e.y,0,_e.x,_e.y,pe(_e,we));se(l,t.stops,a);const h={type:o,style:l},c=fe(e,_e,we,d||1,i.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:fe},{copy:me,toOffsetOutBounds:ve}=R,xe={},be={};function Be(t,e,n,s){const{bounds:o,shapeBounds:a}=s;if(i.fullImageShadow){if(me(xe,t.bounds),xe.x+=e.x-a.x,xe.y+=e.y-a.y,n){const{matrix:t}=s;xe.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),xe.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),xe.width*=n,xe.height*=n}t.copyWorld(s.canvas,t.bounds,xe)}else n&&(me(xe,e),xe.x-=e.width/2*(n-1),xe.y-=e.height/2*(n-1),xe.width*=n,xe.height*=n),t.copyWorld(s.canvas,a,n?xe:e)}const{toOffsetOutBounds:Re}=R,ke={};const Ee={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ve(l,be),r.forEach(((r,g)=>{f.setWorldShadow(be.offsetX+r.x*c,be.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Be(f,be,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),n=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Re(l,ke),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(ke.offsetX+r.x*c,ke.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Be(f,ke,s,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,h,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Le}=y;function Se(t,e,i,n,s,o){switch(e){case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Ae(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ae(t,i,n,o);break;case"path":i.restore()}}function Oe(t){return t.getSameCanvas(!1,!0)}function Ae(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}F.prototype.__renderMask=function(t,e){let i,n,s,o,a;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)i=r[d],i.__.mask&&(a&&(Se(this,a,t,s,n,o),n=s=null),"path"===i.__.mask?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Oe(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="alpha",n||(n=Oe(t)),s||(s=Oe(t)),i.__render(n,e)),"clipping"!==i.__.mask)||Le(i,e)||i.__render(s||t,e);Se(this,a,t,s,n,o)};const We=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ce=We+"_#~&*+\\=|≮≯≈≠=…",Te=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 Me(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const De=Me("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ie=Me("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Pe=Me(We),Fe=Me(Ce),Ve=Me("- —/~|┆·");var ze;!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"}(ze||(ze={}));const{Letter:Ue,Single:Ye,Before:Ne,After:Ge,Symbol:Xe,Break:je}=ze;function qe(t){return De[t]?Ue:Ve[t]?je:Ie[t]?Ne:Pe[t]?Ge:Fe[t]?Xe:Te.test(t)?Ye:Ue}const He={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Qe(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Je}=He,{Letter:Ze,Single:$e,Before:Ke,After:ti,Symbol:ei,Break:ii}=ze;let ni,si,oi,ai,ri,di,li,hi,ci,ui,fi,pi,gi,_i,wi,yi,mi=[];function vi(t,e){ci&&!hi&&(hi=ci),ni.data.push({char:t,width:e}),oi+=e}function xi(){ai+=oi,ni.width=oi,si.words.push(ni),ni={data:[]},oi=0}function bi(){_i&&(wi.paraNumber++,si.paraStart=!0,_i=!1),ci&&(si.startCharSize=hi,si.endCharSize=ci,hi=0),si.width=ai,yi.width&&Je(si),mi.push(si),si={words:[]},ai=0}const Bi=0,Ri=1,ki=2;const{top:Ei,right:Li,bottom:Si,left:Oi}=A;function Ai(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Wi={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=e;l&&(o&&(n=l[Oi],o-=l[Li]+l[Oi]),a&&(s=l[Ei],a-=l[Ei]+l[Si]));const h={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:i.canvas.font=d};return function(t,e,n){wi=t,mi=t.rows,yi=t.bounds;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=i,{width:d,height:l}=yi;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,i="break"===n.textWrap;_i=!0,fi=null,hi=li=ci=oi=ai=0,ni={data:[]},si={words:[]};for(let n=0,l=e.length;n<l;n++)di=e[n],"\n"===di?(oi&&xi(),si.paraEnd=!0,bi(),_i=!0):(ui=qe(di),ui===Ze&&"none"!==a&&(di=Qe(di,a,!oi)),li=r.measureText(di).width,s&&(s<0&&(ci=li),li+=s),pi=ui===$e&&(fi===$e||fi===Ze)||fi===$e&&ui!==ti,gi=!(ui!==Ke&&ui!==$e||fi!==ei&&fi!==ti),ri=_i&&o?d-o:d,t&&d&&ai+oi+li>ri&&(i?(oi&&xi(),bi()):(gi||(gi=ui===Ze&&fi==ti),pi||gi||ui===ii||ui===Ke||ui===$e||oi+li>ri?(oi&&xi(),bi()):bi()))," "===di&&!0!==_i&&ai+oi===0||(ui===ii?(" "===di&&oi&&xi(),vi(di,li),xi()):pi||gi?(oi&&xi(),vi(di,li)):vi(di,li)),fi=ui);oi&&xi(),ai&&bi(),mi.length>0&&(mi[mi.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{wi.paraNumber++,mi.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(h,t,e),l&&function(t,e,i,n,s){if(!n)switch(i.textAlign){case"left":Ai(e,"x",t[Oi]);break;case"right":Ai(e,"x",-t[Li])}if(!s)switch(i.verticalAlign){case"top":Ai(e,"y",t[Ei]);break;case"bottom":Ai(e,"y",-t[Si])}}(l,h,e,o,a),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:h}=e;let c,u,f,{x:p,y:g,width:_,height:w}=n,y=s*i.length+(h?h*(t.paraNumber-1):0),m=o;if(r&&y>w)y=Math.max(w,s),t.overflow=i.length;else switch(l){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let o=0,l=i.length;o<l;o++){if(c=i[o],c.x=p,c.width<_||c.width>_&&!r)switch(d){case"center":c.x+=(_-c.width)/2;break;case"right":c.x+=_-c.width}c.paraStart&&h&&o>0&&(m+=h),c.y=m,m+=s,t.overflow>o&&m>y&&(c.isOverflow=!0,t.overflow=o+1),u=c.x,f=c.width,a<0&&(c.width<0?(f=-c.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<n.x&&(n.x=u),f>n.width&&(n.width=f),r&&_&&_<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=g,n.height=y}(h,e),function(t,e,i,n){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=a&&t.paraStart?a:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?Bi:l>.01?Ri:ki,t.isOverflow&&!r&&(t.textMode=!0),c===ki?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{c===Ri?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(h,e,o),h.overflow&&function(t,e){const{rows:n,overflow:s}=t;let{textOverflow:o}=e;if(n.splice(s),o&&"show"!==o){let t,a;"hide"===o?o="":"ellipsis"===o&&(o="...");const r=o?i.canvas.measureText(o).width:0,d=e.x+e.width-r;("none"===e.textWrap?n:[n[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],a=t.x+t.width,!(n===i&&a<d));n--){if(a<d&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:o,x:a}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,e),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(h,e),h}};const Ci={string:function(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const n=t.r+","+t.g+","+t.b;return 1===i?"rgb("+n+")":"rgba("+n+","+i+")"}},{setPoint:Ti,addPoint:Mi,toBounds:Di}=W;const Ii={export(t,e,n){return this.running=!0,function(t){Pi||(Pi=new C);return new Promise((e=>{Pi.add((()=>$t(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((o=>{const a=t=>{s(t),o(),this.running=!1},{toURL:d}=i,{download:h}=i.origin,c=l.fileType(e);if("json"===e)return a({data:t.toJSON()});if("json"===c)return h(d(JSON.stringify(t.toJSON()),"text"),e),a({data:!0});if("svg"===e)return a({data:t.toSVG()});if("svg"===c)return h(d(t.toSVG(),"svg"),e),a({data:!0});const{leafer:u}=t;u?u.waitViewCompleted((()=>$t(this,void 0,void 0,(function*(){n=l.getExportOptions(n);let i,s,o=1,d=1;const{worldTransform:h,isLeafer:c,isFrame:f}=t,{slice:p,trim:g,onCanvas:_}=n;let y=n.scale||1,m=n.pixelRatio||1;t.isApp&&(y*=m,m=t.app.pixelRatio);const v=n.screenshot||t.isApp,x=c&&v&&void 0===n.fill?t.fill:n.fill,b=l.isOpaqueImage(e)||x,B=new T;if(v)i=!0===v?c?u.canvas.bounds:t.worldRenderBounds:v;else{let e=n.relative||(c?"inner":"local");switch(o=h.scaleX,d=h.scaleY,e){case"inner":B.set(h);break;case"local":B.set(h).divide(t.localTransform),o/=t.scaleX,d/=t.scaleY;break;case"world":o=1,d=1;break;case"page":e=t.leafer;default:B.set(h).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,d/=d/i.scaleY}i=t.getBounds("render",e)}const{x:R,y:k,width:E,height:L}=new w(i).scale(y);let S=r.canvas({width:Math.round(E),height:Math.round(L),pixelRatio:m});const O={matrix:B.scale(1/y).invert().translate(-R,-k).withScale(1/o*y,1/d*y)};if(p&&(t=u,O.bounds=S.bounds),S.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(S,O),t.fill=e}else t.__render(S,O);if(S.restore(),g){s=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,o,a,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,o=(r-s)/e,a?Mi(a,s,o):Ti(a={},s,o)),r++;const d=new w;return Di(a,d),d.scale(1/t.pixelRatio).ceil()}(S);const t=S,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:m};S=r.canvas(n),S.copyWorld(t,s,n)}b&&S.fillWorld(S.bounds,x||"#FFFFFF","destination-over"),_&&_(S);const A="canvas"===e?S:yield S.export(e,n);a({data:A,width:S.pixelWidth,height:S.pixelHeight,renderBounds:i,trimBounds:s})})))):a({data:!1})}))))}};let Pi;const Fi=e.prototype,Vi=t.get("@leafer-ui/export");Fi.export=function(t,e){const{quality:i,blob:n}=l.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Fi.toBlob=function(t,e){return new Promise((n=>{i.origin.canvasToBolb(this.view,t,e).then((t=>{n(t)})).catch((t=>{Vi.error(t),n(null)}))}))},Fi.toDataURL=function(t,e){return i.origin.canvasToDataURL(this.view,t,e)},Fi.saveAs=function(t,e){return new Promise((n=>{i.origin.canvasSaveAs(this.view,t,e).then((()=>{n(!0)})).catch((t=>{Vi.error(t),n(!1)}))}))},Object.assign(V,Wi),Object.assign(D,Ci),Object.assign(z,vt),Object.assign(M,te),Object.assign(I,ye),Object.assign(U,Ee),Object.assign(P,Ii),j();export{at as Layouter,N as LeaferCanvas,dt as Renderer,H as Watcher,j as useCanvas};
1
+ import{Debug as t,LeaferCanvasBase as e,Platform as i,DataHelper as n,canvasSizeAttrs as s,ResizeEvent as o,canvasPatch as a,Creator as r,LeaferImage as d,FileHelper as l,LeafList as h,RenderEvent as c,ChildEvent as u,WatchEvent as f,PropertyEvent as p,LeafHelper as g,BranchHelper as _,Bounds as w,LeafBoundsHelper as y,LeafLevelList as m,LayoutEvent as v,Run as x,ImageManager as b,AnimateEvent as B,BoundsHelper as R,MatrixHelper as k,AlignHelper as E,ImageEvent as S,AroundHelper as L,PointHelper as A,Direction4 as O,TwoPointBoundsHelper as W,TaskProcessor as C,Matrix as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as M,ColorConvert as D,PaintGradient as I,Export as P,Group as F,TextConvert as V,Paint as z,Effect as U}from"@leafer-ui/draw";export*from"@leafer-ui/draw";const Y=t.get("LeaferCanvas");class N extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{view:t}=this.config;t?this.__createViewFrom(t):this.__createView();const{style:e}=this.view;if(e.display||(e.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(e.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(this.config)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else Y.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:n}=this.view;n.width=t+"px",n.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.clientBounds=this.view.getBoundingClientRect()}startAutoLayout(t,e){this.autoBounds=t,this.resizeListener=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t&&(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect()))}catch(t){this.imitateResizeObserver()}}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const e=this.view,{x:i,y:a,width:r,height:d}=this.autoBounds.getBoundsFrom(t);if(r!==this.width||d!==this.height){const{style:t}=e,{pixelRatio:l}=this;t.marginLeft=i+"px",t.marginTop=a+"px";const h={width:r,height:d,pixelRatio:l},c={};n.copyAttrs(c,this,s),this.resize(h),void 0!==this.width&&this.resizeListener(new o(h,c))}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}a(CanvasRenderingContext2D.prototype),a(Path2D.prototype);const{mineType:G,fileType:X}=l;function j(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>t.toDataURL(G(e),i),canvasToBolb:(t,e,i)=>new Promise((n=>t.toBlob(n,G(e),i))),canvasSaveAs:(t,e,n)=>{const s=t.toDataURL(G(X(e)),n);return i.origin.download(s,e)},download:(t,e)=>new Promise((i=>{let n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),i()})),loadImage:t=>new Promise(((e,n)=>{const s=new Image,{crossOrigin:o}=i.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{e(s)},s.onerror=t=>{n(t)},s.src=i.image.getRealURL(t)}))},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=r.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(r,{canvas:(t,e)=>new N(t,e),image:t=>new d(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},i.devicePixelRatio=Math.max(1,devicePixelRatio);const{userAgent:q}=navigator;q.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):q.indexOf("Safari")>-1&&-1===q.indexOf("Chrome")&&(i.fullImageShadow=!0),q.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):q.indexOf("Mac")>-1?i.os="Mac":q.indexOf("Linux")>-1&&(i.os="Linux");class H{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new h;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 h,this.target=t,e&&(this.config=n.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(c.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===u.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,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new h,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(p.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.REMOVE],this.__onChildEvent,this),t.on_(f.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:Q,updateBounds:J,updateAllWorldOpacity:Z}=g,{pushAllChildBranch:$,pushAllParent:K}=_;const{worldBounds:tt}=y,et={x:0,y:0,width:1e5,height:1e5};class it{constructor(t){this.updatedBounds=new w,this.beforeBounds=new w,this.afterBounds=new w,t instanceof Array&&(t=new h(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,tt)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(et):this.afterBounds.setListWithFn(t,tt),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:nt,updateAllChange:st}=g,ot=t.get("Layouter");class at{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=n.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.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){ot.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ot.warn("layouting"):this.times>3?ot.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.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:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=v,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new v(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(Q(t,!0),e.add(t),t.isBranch&&$(t,e),K(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),K(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||J(n[t])}J(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&Z(t),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new v(o,r,this.times)),i.emitEvent(new v(a,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:i,LAYOUT:n,AFTER:s}=v,o=this.getBlocks(new h(e));e.emitEvent(new v(i,o,this.times)),at.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new v(n,o,this.times)),e.emitEvent(new v(s,o,this.times)),this.addBlocks(o),x.end(t)}static fullLayout(t){nt(t,!0),t.isBranch?_.updateBounds(t):g.updateBounds(t),st(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new it([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new it(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:t}=this;this.__eventIds=[t.on_(v.REQUEST,this.layout,this),t.on_(v.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const rt=t.get("Renderer");class dt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=n.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(v.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new w,rt.log(e.innerName,"---\x3e");try{this.emitRender(c.START),this.renderOnce(t),this.emitRender(c.END,this.totalBounds),b.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 w,this.renderOptions={},t)this.emitRender(c.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(c.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(c.RENDER,this.renderBounds,this.renderOptions),this.emitRender(c.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 rt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=x.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),o=e.includes(this.target.__world),a=new w(s);n.save(),o&&!t.showRepaint?n.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(s,!0),n.clipWorld(s,!0)),this.__render(s,o,a),n.restore(),x.end(i)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),x.end(t)}__render(e,i,n){const s=e.includes(this.target.__world)?{includes:i}:{bounds:e,includes:i};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=n||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.showHitView&&this.renderHitView(s),t.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new w;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();i.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(B.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(c.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new w(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new w(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||rt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new c(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.REQUEST,this.update,this),t.on_(v.END,this.__onLayoutEnd,this),t.on_(c.AGAIN,this.renderAgain,this),t.on_(o.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 lt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,o)}function ht(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?ft(t,!0,e,i):ut(e,i);break;case"inside":ct("inside",t,s,e,i);break;case"outside":ct("outside",t,s,e,i)}}function ct(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?ft(e,!0,n,r):ut(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",lt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function ut(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;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)})),s&&e.strokeRect(i.x,i.y+s,i.width,o)}function ft(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&M.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?ut(i,n):n.stroke(),n.restoreBlendMode()):e?ut(i,n):n.stroke())}Object.assign(r,{watcher:(t,e)=>new H(t,e),layouter:(t,e)=>new at(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),i.layout=at.fullLayout;const{getSpread:pt,getOuterOf:gt,getByMove:_t,getIntersectData:wt}=R;let yt;function mt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:D.string(a,r)};case"image":return M.image(i,t,e,n,!yt||!yt[e.url]);case"linear":return I.linearGradient(e,n);case"radial":return I.radialGradient(e,n);case"angular":return I.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:D.string(e)}:void 0}}const vt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),yt=M.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=mt(t,o[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?lt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&M.checkImage(e,i,n,!o)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),o?lt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?lt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?lt(e,i):s?i.fill(s):i.fill())},fillText:lt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)ht(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)ht(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),ft(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ft(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),ft(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:ht,drawTextStroke:ut,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,c=wt(n?pt(e.bounds,l===h?n*l:[n*h,n*l]):e.bounds,s);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),r=gt(s,a),o=_t(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let xt={};const{get:bt,rotateOfOuter:Bt,translate:Rt,scaleOfOuter:kt,scale:Et,rotate:St}=k;function Lt(t,e,i,n,s,o,a){const r=bt();Rt(r,e.x+i,e.y+n),Et(r,s,o),a&&Bt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function At(t,e,i,n,s,o,a){const r=bt();Rt(r,e.x+i,e.y+n),s&&Et(r,s,o),a&&St(r,a),t.transform=r}function Ot(t,e,i,n,s,o,a,r,d,l){const h=bt();if(d)if("center"===l)Bt(h,{x:i/2,y:n/2},d);else switch(St(h,d),d){case 90:Rt(h,n,0);break;case 180:Rt(h,i,n);break;case 270:Rt(h,0,i)}xt.x=e.x+s,xt.y=e.y+o,Rt(h,xt.x,xt.y),a&&kt(h,xt,a,r),t.transform=h}const{get:Wt,translate:Ct}=k,Tt=new w,Mt={};function Dt(t,e,i,n){const{blendMode:s}=i;s&&(t.blendMode=s),t.data=It(i,n,e)}function It(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Tt.set(e).shrink(t.padding));const{opacity:o,mode:a,align:r,offset:d,scale:l,size:h,rotation:c,repeat:u}=t,f=e.width===n&&e.height===s,p={mode:a},g="center"!==r&&(c||0)%180==90,_=g?s:n,w=g?n:s;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)h?(y=("number"==typeof h?h:h.width)/n,m=("number"==typeof h?h:h.height)/s):l&&(y="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y);else if(!f||c){const t=e.width/_,i=e.height/w;y=m="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-n*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:_,height:w};y&&(t.width*=y,t.height*=m),E.toPoint(r,t,e,Mt,!0),v+=Mt.x,x+=Mt.y}switch(d&&(v+=d.x,x+=d.y),a){case"strench":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||c)&&At(p,e,v,x,y,m,c);break;case"repeat":(!f||y||c)&&Ot(p,e,n,s,v,x,y,m,c,r),u||(p.repeat="repeat");break;default:y&&Lt(p,e,v,x,y,m,c)}return p.transform||(e.x||e.y)&&(p.transform=Wt(),Ct(p.transform,e.x,e.y)),y&&"strench"!==a&&(p.scaleX=y,p.scaleY=m),p.width=n,p.height=s,o&&(p.opacity=o),u&&(p.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),p}let Pt,Ft=new w;const{isSame:Vt}=R;function zt(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.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||Dt(s,n,i,o),!0}function Ut(t,e){Gt(t,S.LOAD,e)}function Yt(t,e){Gt(t,S.LOADED,e)}function Nt(t,e,i){e.error=i,t.forceUpdate("surface"),Gt(t,S.ERROR,e)}function Gt(t,e,i){t.hasEvent(e)&&t.emitEvent(new S(e,i))}function Xt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:jt,scale:qt,copy:Ht}=k,{ceil:Qt,abs:Jt}=Math;function Zt(t,e,n){let{scaleX:s,scaleY:o}=b.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o;if(e.patternId===a||t.destroyed)return!1;{s=Jt(s),o=Jt(o);const{image:t,data:r}=e;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=jt(),Ht(l,g),qt(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,h*=s,c*=o;const w=h*c;if(!_&&w>i.image.maxCacheSize)return!1;let y=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,o/=d,h/=d,c/=d),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(l||(l=jt(),g&&Ht(l,g)),qt(l,1/s,1/o));const m=t.getCanvas(Qt(h)||1,Qt(c)||1,p),v=t.getPattern(m,_||i.origin.noRepeat||"no-repeat",l,e);return e.style=v,e.patternId=a,!0}}function $t(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{d(n.next(t))}catch(t){o(t)}}function r(t){try{d(n.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Kt}=Math;const te={image:function(t,e,i,n,s){let o,a;const r=b.get(i);return Pt&&i===Pt.paint&&Vt(n,Pt.boxBounds)?o=Pt.leafPaint:(o={type:i.type,image:r},Pt=r.use>1?{leafPaint:o,paint:i,boxBounds:Ft.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(zt(t,e,i,r,o,n),s&&(Ut(t,a),Yt(t,a))):r.error?s&&Nt(t,a,r.error):(Xt(t,!0),s&&Ut(t,a),o.loadId=r.load((()=>{Xt(t,!1),t.destroyed||(zt(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Yt(t,a)),o.loadId=null}),(e=>{Xt(t,!1),Nt(t,a,e),o.loadId=null}))),o},checkImage:function(t,e,n,s){const{scaleX:o,scaleY:a}=b.patternLocked?t.__world:t.__nowWorld;if(n.data&&n.patternId!==o+"-"+a){const{data:r}=n;if(s)if(r.repeat)s=!1;else{let{width:t,height:n}=r;t*=Kt(o)*e.pixelRatio,n*=Kt(a)*e.pixelRatio,r.scaleX&&(t*=r.scaleX,n*=r.scaleY),s=t*n>i.image.maxCacheSize||P.running}return s?(e.save(),e.clip(),n.blendMode&&(e.blendMode=n.blendMode),r.opacity&&(e.opacity*=r.opacity),r.transform&&e.transform(r.transform),e.drawImage(n.image.view,0,0,r.width,r.height),e.restore(),!0):(!n.style||P.running?Zt(t,n,e.pixelRatio):n.patternTask||(n.patternTask=b.patternTasker.add((()=>$t(this,void 0,void 0,(function*(){n.patternTask=null,e.bounds.hit(t.__nowWorld)&&Zt(t,n,e.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},createPattern:Zt,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,o,a;for(let r=0,d=i.length;r<d;r++)n=i[r].image,a=n&&n.url,a&&(s||(s={}),s[a]=!0,b.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:Dt,getPatternData:It,fillOrFitMode:Lt,clipMode:At,repeatMode:Ot},{toPoint:ee}=L,ie={},ne={};function se(t,e,i){let n;for(let s=0,o=e.length;s<o;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(o-1),D.string(n,i)):t.addColorStop(n.offset,D.string(n.color,i))}const{getAngle:oe,getDistance:ae}=A,{get:re,rotateOfOuter:de,scaleOfOuter:le}=k,{toPoint:he}=L,ce={},ue={};function fe(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=oe(e,i);o=re(),s?(le(o,e,a/r*(n||1),1),de(o,e,t+90)):(le(o,e,1,a/r*(n||1)),de(o,e,t))}return o}const{getDistance:pe}=A,{toPoint:ge}=L,_e={},we={};const ye={linearGradient:function(t,e){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;ee(n||"top",e,ie),ee(s||"bottom",e,ne);const d=i.canvas.createLinearGradient(ie.x,ie.y,ne.x,ne.y);se(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,e){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;he(n||"center",e,ce),he(s||"bottom",e,ue);const l=i.canvas.createRadialGradient(ce.x,ce.y,0,ce.x,ce.y,ae(ce,ue));se(l,t.stops,a);const h={type:o,style:l},c=fe(e,ce,ue,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(t,e){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ge(n||"center",e,_e),ge(s||"bottom",e,we);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,_e.x,_e.y):i.canvas.createRadialGradient(_e.x,_e.y,0,_e.x,_e.y,pe(_e,we));se(l,t.stops,a);const h={type:o,style:l},c=fe(e,_e,we,d||1,i.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:fe},{copy:me,toOffsetOutBounds:ve}=R,xe={},be={};function Be(t,e,n,s){const{bounds:o,shapeBounds:a}=s;if(i.fullImageShadow){if(me(xe,t.bounds),xe.x+=e.x-a.x,xe.y+=e.y-a.y,n){const{matrix:t}=s;xe.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),xe.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),xe.width*=n,xe.height*=n}t.copyWorld(s.canvas,t.bounds,xe)}else n&&(me(xe,e),xe.x-=e.width/2*(n-1),xe.y-=e.height/2*(n-1),xe.width*=n,xe.height*=n),t.copyWorld(s.canvas,a,n?xe:e)}const{toOffsetOutBounds:Re}=R,ke={};const Ee={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ve(l,be),r.forEach(((r,g)=>{f.setWorldShadow(be.offsetX+r.x*c,be.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Be(f,be,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),n=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Re(l,ke),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(ke.offsetX+r.x*c,ke.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Be(f,ke,s,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,h,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,o,r.blendMode):e.copyWorldToInner(f,n,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Se}=y;function Le(t,e,i,n,s,o){switch(e){case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Oe(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Oe(t,i,n,o);break;case"path":i.restore()}}function Ae(t){return t.getSameCanvas(!1,!0)}function Oe(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}F.prototype.__renderMask=function(t,e){let i,n,s,o,a;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)i=r[d],i.__.mask&&(a&&(Le(this,a,t,s,n,o),n=s=null),"path"===i.__.mask?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Ae(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="alpha",n||(n=Ae(t)),s||(s=Ae(t)),i.__render(n,e)),"clipping"!==i.__.mask)||Se(i,e)||i.__render(s||t,e);Le(this,a,t,s,n,o)};const We=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ce=We+"_#~&*+\\=|≮≯≈≠=…",Te=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 Me(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const De=Me("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ie=Me("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Pe=Me(We),Fe=Me(Ce),Ve=Me("- —/~|┆·");var ze;!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"}(ze||(ze={}));const{Letter:Ue,Single:Ye,Before:Ne,After:Ge,Symbol:Xe,Break:je}=ze;function qe(t){return De[t]?Ue:Ve[t]?je:Ie[t]?Ne:Pe[t]?Ge:Fe[t]?Xe:Te.test(t)?Ye:Ue}const He={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Qe(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Je}=He,{Letter:Ze,Single:$e,Before:Ke,After:ti,Symbol:ei,Break:ii}=ze;let ni,si,oi,ai,ri,di,li,hi,ci,ui,fi,pi,gi,_i,wi,yi,mi=[];function vi(t,e){ci&&!hi&&(hi=ci),ni.data.push({char:t,width:e}),oi+=e}function xi(){ai+=oi,ni.width=oi,si.words.push(ni),ni={data:[]},oi=0}function bi(){_i&&(wi.paraNumber++,si.paraStart=!0,_i=!1),ci&&(si.startCharSize=hi,si.endCharSize=ci,hi=0),si.width=ai,yi.width&&Je(si),mi.push(si),si={words:[]},ai=0}const Bi=0,Ri=1,ki=2;const{top:Ei,right:Si,bottom:Li,left:Ai}=O;function Oi(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Wi={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=e;l&&(o&&(n=l[Ai],o-=l[Si]+l[Ai]),a&&(s=l[Ei],a-=l[Ei]+l[Li]));const h={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:i.canvas.font=d};return function(t,e,n){wi=t,mi=t.rows,yi=t.bounds;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=i,{width:d,height:l}=yi;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,i="break"===n.textWrap;_i=!0,fi=null,hi=li=ci=oi=ai=0,ni={data:[]},si={words:[]};for(let n=0,l=e.length;n<l;n++)di=e[n],"\n"===di?(oi&&xi(),si.paraEnd=!0,bi(),_i=!0):(ui=qe(di),ui===Ze&&"none"!==a&&(di=Qe(di,a,!oi)),li=r.measureText(di).width,s&&(s<0&&(ci=li),li+=s),pi=ui===$e&&(fi===$e||fi===Ze)||fi===$e&&ui!==ti,gi=!(ui!==Ke&&ui!==$e||fi!==ei&&fi!==ti),ri=_i&&o?d-o:d,t&&d&&ai+oi+li>ri&&(i?(oi&&xi(),ai&&bi()):(gi||(gi=ui===Ze&&fi==ti),pi||gi||ui===ii||ui===Ke||ui===$e||oi+li>ri?(oi&&xi(),ai&&bi()):ai&&bi()))," "===di&&!0!==_i&&ai+oi===0||(ui===ii?(" "===di&&oi&&xi(),vi(di,li),xi()):pi||gi?(oi&&xi(),vi(di,li)):vi(di,li)),fi=ui);oi&&xi(),ai&&bi(),mi.length>0&&(mi[mi.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{wi.paraNumber++,mi.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(h,t,e),l&&function(t,e,i,n,s){if(!n)switch(i.textAlign){case"left":Oi(e,"x",t[Ai]);break;case"right":Oi(e,"x",-t[Si])}if(!s)switch(i.verticalAlign){case"top":Oi(e,"y",t[Ei]);break;case"bottom":Oi(e,"y",-t[Li])}}(l,h,e,o,a),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:h}=e;let c,u,f,{x:p,y:g,width:_,height:w}=n,y=s*i.length+(h?h*(t.paraNumber-1):0),m=o;if(r&&y>w)y=Math.max(w,s),t.overflow=i.length;else switch(l){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let o=0,l=i.length;o<l;o++){if(c=i[o],c.x=p,c.width<_||c.width>_&&!r)switch(d){case"center":c.x+=(_-c.width)/2;break;case"right":c.x+=_-c.width}c.paraStart&&h&&o>0&&(m+=h),c.y=m,m+=s,t.overflow>o&&m>y&&(c.isOverflow=!0,t.overflow=o+1),u=c.x,f=c.width,a<0&&(c.width<0?(f=-c.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<n.x&&(n.x=u),f>n.width&&(n.width=f),r&&_&&_<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=g,n.height=y}(h,e),function(t,e,i,n){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=a&&t.paraStart?a:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?Bi:l>.01?Ri:ki,t.isOverflow&&!r&&(t.textMode=!0),c===ki?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{c===Ri?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(h,e,o),h.overflow&&function(t,e){const{rows:n,overflow:s}=t;let{textOverflow:o}=e;if(n.splice(s),o&&"show"!==o){let t,a;"hide"===o?o="":"ellipsis"===o&&(o="...");const r=o?i.canvas.measureText(o).width:0,d=e.x+e.width-r;("none"===e.textWrap?n:[n[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],a=t.x+t.width,!(n===i&&a<d));n--){if(a<d&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:o,x:a}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,e),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(h,e),h}};const Ci={string:function(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const n=t.r+","+t.g+","+t.b;return 1===i?"rgb("+n+")":"rgba("+n+","+i+")"}},{setPoint:Ti,addPoint:Mi,toBounds:Di}=W;const Ii={export(t,e,n){return this.running=!0,function(t){Pi||(Pi=new C);return new Promise((e=>{Pi.add((()=>$t(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((o=>{const a=t=>{s(t),o(),this.running=!1},{toURL:d}=i,{download:h}=i.origin,c=l.fileType(e);if("json"===e)return a({data:t.toJSON()});if("json"===c)return h(d(JSON.stringify(t.toJSON()),"text"),e),a({data:!0});if("svg"===e)return a({data:t.toSVG()});if("svg"===c)return h(d(t.toSVG(),"svg"),e),a({data:!0});const{leafer:u}=t;u?(Fi(t),u.waitViewCompleted((()=>$t(this,void 0,void 0,(function*(){n=l.getExportOptions(n);let i,s,o=1,d=1;const{worldTransform:h,isLeafer:c,isFrame:f}=t,{slice:p,trim:g,onCanvas:_}=n;let y=n.scale||1,m=n.pixelRatio||1;const v=void 0===n.smooth?u.config.smooth:n.smooth,x=n.contextSettings||u.config.contextSettings;t.isApp&&(y*=m,m=t.app.pixelRatio);const b=n.screenshot||t.isApp,B=c&&b&&void 0===n.fill?t.fill:n.fill,R=l.isOpaqueImage(e)||B,k=new T;if(b)i=!0===b?c?u.canvas.bounds:t.worldRenderBounds:b;else{let e=n.relative||(c?"inner":"local");switch(o=h.scaleX,d=h.scaleY,e){case"inner":k.set(h);break;case"local":k.set(h).divide(t.localTransform),o/=t.scaleX,d/=t.scaleY;break;case"world":o=1,d=1;break;case"page":e=t.leafer;default:k.set(h).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,d/=d/i.scaleY}i=t.getBounds("render",e)}const{x:E,y:S,width:L,height:A}=new w(i).scale(y);let O=r.canvas({width:Math.round(L),height:Math.round(A),pixelRatio:m,smooth:v,contextSettings:x});const W={matrix:k.scale(1/y).invert().translate(-E,-S).withScale(1/o*y,1/d*y)};if(p&&(t=u,W.bounds=O.bounds),O.save(),f&&void 0!==B){const e=t.get("fill");t.fill="",t.__render(O,W),t.fill=e}else t.__render(O,W);if(O.restore(),g){s=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,o,a,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,o=(r-s)/e,a?Mi(a,s,o):Ti(a={},s,o)),r++;const d=new w;return Di(a,d),d.scale(1/t.pixelRatio).ceil()}(O);const t=O,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:m};O=r.canvas(n),O.copyWorld(t,s,n)}R&&O.fillWorld(O.bounds,B||"#FFFFFF","destination-over"),_&&_(O);const C="canvas"===e?O:yield O.export(e,n);a({data:C,width:O.pixelWidth,height:O.pixelHeight,renderBounds:i,trimBounds:s})}))))):a({data:!1})}))))}};let Pi;function Fi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Fi(t)))}const Vi=e.prototype,zi=t.get("@leafer-ui/export");Vi.export=function(t,e){const{quality:i,blob:n}=l.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Vi.toBlob=function(t,e){return new Promise((n=>{i.origin.canvasToBolb(this.view,t,e).then((t=>{n(t)})).catch((t=>{zi.error(t),n(null)}))}))},Vi.toDataURL=function(t,e){return i.origin.canvasToDataURL(this.view,t,e)},Vi.saveAs=function(t,e){return new Promise((n=>{i.origin.canvasSaveAs(this.view,t,e).then((()=>{n(!0)})).catch((t=>{zi.error(t),n(!1)}))}))},Object.assign(V,Wi),Object.assign(D,Ci),Object.assign(z,vt),Object.assign(M,te),Object.assign(I,ye),Object.assign(U,Ee),Object.assign(P,Ii),j();export{at as Layouter,N as LeaferCanvas,dt as Renderer,H as Watcher,j as useCanvas};
package/dist/web.js CHANGED
@@ -14,8 +14,15 @@ var LeaferUI = (function (exports) {
14
14
  hitCanvasSize: 100,
15
15
  maxCacheSize: 2560 * 1600,
16
16
  maxPatternSize: 4096 * 2160,
17
- suffix: '',
18
- crossOrigin: 'anonymous'
17
+ crossOrigin: 'anonymous',
18
+ getRealURL(url) {
19
+ const { prefix, suffix } = Platform.image;
20
+ if (suffix && !url.startsWith('data:') && !url.startsWith('blob:'))
21
+ url += (url.includes("?") ? "&" : "?") + suffix;
22
+ if (prefix && url[0] === '/')
23
+ url = prefix + url;
24
+ return url;
25
+ }
19
26
  }
20
27
  };
21
28
 
@@ -5129,6 +5136,7 @@ var LeaferUI = (function (exports) {
5129
5136
  get __worldFlipped() { return this.__world.scaleX < 0 || this.__world.scaleY < 0; }
5130
5137
  get __onlyHitMask() { return this.__hasMask && !this.__.hitChildren; }
5131
5138
  get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
5139
+ get __inLazyBounds() { const { leafer } = this; return leafer && leafer.created && leafer.lazyBounds.hit(this.__world); }
5132
5140
  get pathInputed() { return this.__.__pathInputed; }
5133
5141
  constructor(data) {
5134
5142
  this.innerId = create(LEAF);
@@ -5192,6 +5200,9 @@ var LeaferUI = (function (exports) {
5192
5200
  }
5193
5201
  set(_data) { }
5194
5202
  get(_name) { return undefined; }
5203
+ setAttr(name, value) { this[name] = value; }
5204
+ getAttr(name) { return this[name]; }
5205
+ getComputedAttr(name) { return this.__[name]; }
5195
5206
  toJSON() {
5196
5207
  return this.__.__getInputData();
5197
5208
  }
@@ -5210,6 +5221,9 @@ var LeaferUI = (function (exports) {
5210
5221
  findOne(_condition, _options) { return undefined; }
5211
5222
  findId(_id) { return undefined; }
5212
5223
  focus(_value) { }
5224
+ updateLayout() {
5225
+ this.__layout.update();
5226
+ }
5213
5227
  forceUpdate(attrName) {
5214
5228
  if (attrName === undefined)
5215
5229
  attrName = 'width';
@@ -5219,8 +5233,8 @@ var LeaferUI = (function (exports) {
5219
5233
  this.__[attrName] = value === undefined ? null : undefined;
5220
5234
  this[attrName] = value;
5221
5235
  }
5222
- updateLayout() {
5223
- this.__layout.update();
5236
+ forceRender(_bounds) {
5237
+ this.forceUpdate('surface');
5224
5238
  }
5225
5239
  __updateWorldMatrix() { }
5226
5240
  __updateLocalMatrix() { }
@@ -5752,11 +5766,29 @@ var LeaferUI = (function (exports) {
5752
5766
  }
5753
5767
  }
5754
5768
 
5755
- const version = "1.0.0-rc.26";
5769
+ const version = "1.0.0-rc.27";
5756
5770
  const inviteCode = {};
5757
5771
 
5758
5772
  const debug$5 = Debug.get('LeaferCanvas');
5759
5773
  class LeaferCanvas extends LeaferCanvasBase {
5774
+ set zIndex(zIndex) {
5775
+ const { style } = this.view;
5776
+ style.zIndex = zIndex;
5777
+ this.setAbsolute(this.view);
5778
+ }
5779
+ set childIndex(index) {
5780
+ const { view, parentView } = this;
5781
+ if (view && parentView) {
5782
+ const beforeNode = parentView.children[index];
5783
+ if (beforeNode) {
5784
+ this.setAbsolute(beforeNode);
5785
+ parentView.insertBefore(view, beforeNode);
5786
+ }
5787
+ else {
5788
+ parentView.appendChild(beforeNode);
5789
+ }
5790
+ }
5791
+ }
5760
5792
  init() {
5761
5793
  const { view } = this.config;
5762
5794
  view ? this.__createViewFrom(view) : this.__createView();
@@ -5801,9 +5833,7 @@ var LeaferUI = (function (exports) {
5801
5833
  this.__createView();
5802
5834
  const view = this.view;
5803
5835
  if (parent.hasChildNodes()) {
5804
- const { style } = view;
5805
- style.position = 'absolute';
5806
- style.top = style.left = '0px';
5836
+ this.setAbsolute(view);
5807
5837
  parent.style.position || (parent.style.position = 'relative');
5808
5838
  }
5809
5839
  parent.appendChild(view);
@@ -5814,6 +5844,11 @@ var LeaferUI = (function (exports) {
5814
5844
  this.__createView();
5815
5845
  }
5816
5846
  }
5847
+ setAbsolute(view) {
5848
+ const { style } = view;
5849
+ style.position = 'absolute';
5850
+ style.top = style.left = '0px';
5851
+ }
5817
5852
  updateViewSize() {
5818
5853
  const { width, height, pixelRatio } = this;
5819
5854
  const { style } = this.view;
@@ -5933,16 +5968,14 @@ var LeaferUI = (function (exports) {
5933
5968
  loadImage(src) {
5934
5969
  return new Promise((resolve, reject) => {
5935
5970
  const img = new Image();
5936
- const { suffix, crossOrigin } = Platform.image;
5971
+ const { crossOrigin } = Platform.image;
5937
5972
  if (crossOrigin) {
5938
5973
  img.setAttribute('crossOrigin', crossOrigin);
5939
5974
  img.crossOrigin = crossOrigin;
5940
5975
  }
5941
5976
  img.onload = () => { resolve(img); };
5942
5977
  img.onerror = (e) => { reject(e); };
5943
- if (suffix && !src.startsWith('data:') && !src.startsWith('blob:'))
5944
- src += (src.includes("?") ? "&" : "?") + suffix;
5945
- img.src = src;
5978
+ img.src = Platform.image.getRealURL(src);
5946
5979
  });
5947
5980
  }
5948
5981
  };
@@ -6956,6 +6989,8 @@ var LeaferUI = (function (exports) {
6956
6989
  this.__drawRenderPath(canvas);
6957
6990
  if (fill && !ignoreFill)
6958
6991
  this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
6992
+ if (this.__.__isCanvas)
6993
+ this.__drawAfterFill(canvas, options);
6959
6994
  if (stroke && !ignoreStroke)
6960
6995
  this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
6961
6996
  }
@@ -7069,7 +7104,7 @@ var LeaferUI = (function (exports) {
7069
7104
  __onUpdateSize() {
7070
7105
  if (this.__.__input) {
7071
7106
  const data = this.__;
7072
- (data.lazy && this.leafer && this.leafer.created && !this.leafer.lazyBounds.hit(this.__world)) ? data.__needComputePaint = true : data.__computePaint();
7107
+ (data.lazy && !this.__inLazyBounds && !Export.running) ? data.__needComputePaint = true : data.__computePaint();
7073
7108
  }
7074
7109
  }
7075
7110
  __updateRenderPath() {
@@ -7378,6 +7413,9 @@ var LeaferUI = (function (exports) {
7378
7413
  __decorate([
7379
7414
  dataType()
7380
7415
  ], exports.UI.prototype, "disabledStyle", void 0);
7416
+ __decorate([
7417
+ dataType({})
7418
+ ], exports.UI.prototype, "data", void 0);
7381
7419
  __decorate([
7382
7420
  rewrite(exports.Leaf.prototype.reset)
7383
7421
  ], exports.UI.prototype, "reset", null);
@@ -7624,6 +7662,10 @@ var LeaferUI = (function (exports) {
7624
7662
  if (!this.parent)
7625
7663
  this.canvas.hittable = newValue;
7626
7664
  }
7665
+ else if (attrName === 'zIndex') {
7666
+ this.canvas.zIndex = newValue;
7667
+ setTimeout(() => this.parent && this.parent.__updateSortChildren());
7668
+ }
7627
7669
  }
7628
7670
  return super.__setAttr(attrName, newValue);
7629
7671
  }
@@ -8220,7 +8262,7 @@ var LeaferUI = (function (exports) {
8220
8262
  super(data);
8221
8263
  this.canvas = Creator.canvas(this.__);
8222
8264
  this.context = this.canvas.context;
8223
- this.__.__drawAfterFill = true;
8265
+ this.__.__isCanvas = this.__.__drawAfterFill = true;
8224
8266
  }
8225
8267
  draw(ui, offset, scale, rotation) {
8226
8268
  ui.__layout.update();
@@ -8242,7 +8284,7 @@ var LeaferUI = (function (exports) {
8242
8284
  __drawAfterFill(canvas, _options) {
8243
8285
  const origin = this.canvas.view;
8244
8286
  const { width, height } = this;
8245
- if (this.__.cornerRadius) {
8287
+ if (this.__.cornerRadius || this.pathInputed) {
8246
8288
  canvas.save();
8247
8289
  canvas.clip();
8248
8290
  canvas.drawImage(this.canvas.view, 0, 0, origin.width, origin.height, 0, 0, width, height);
@@ -8288,9 +8330,6 @@ var LeaferUI = (function (exports) {
8288
8330
  __decorate([
8289
8331
  resizeType()
8290
8332
  ], exports.Canvas.prototype, "contextSettings", void 0);
8291
- __decorate([
8292
- hitType('all')
8293
- ], exports.Canvas.prototype, "hitFill", void 0);
8294
8333
  exports.Canvas = __decorate([
8295
8334
  registerUI()
8296
8335
  ], exports.Canvas);
@@ -9126,7 +9165,7 @@ var LeaferUI = (function (exports) {
9126
9165
  width *= data.scaleX;
9127
9166
  height *= data.scaleY;
9128
9167
  }
9129
- allowPaint = width * height > Platform.image.maxCacheSize;
9168
+ allowPaint = (width * height > Platform.image.maxCacheSize) || Export.running;
9130
9169
  }
9131
9170
  else {
9132
9171
  allowPaint = false;
@@ -9638,7 +9677,8 @@ var LeaferUI = (function (exports) {
9638
9677
  if (breakAll) {
9639
9678
  if (wordWidth)
9640
9679
  addWord();
9641
- addRow();
9680
+ if (rowWidth)
9681
+ addRow();
9642
9682
  }
9643
9683
  else {
9644
9684
  if (!afterBreak)
@@ -9646,10 +9686,12 @@ var LeaferUI = (function (exports) {
9646
9686
  if (langBreak || afterBreak || charType === Break || charType === Before || charType === Single || (wordWidth + charWidth > realWidth)) {
9647
9687
  if (wordWidth)
9648
9688
  addWord();
9649
- addRow();
9689
+ if (rowWidth)
9690
+ addRow();
9650
9691
  }
9651
9692
  else {
9652
- addRow();
9693
+ if (rowWidth)
9694
+ addRow();
9653
9695
  }
9654
9696
  }
9655
9697
  }
@@ -10035,6 +10077,7 @@ var LeaferUI = (function (exports) {
10035
10077
  }
10036
10078
  const { leafer } = leaf;
10037
10079
  if (leafer) {
10080
+ checkLazy(leaf);
10038
10081
  leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
10039
10082
  options = FileHelper.getExportOptions(options);
10040
10083
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
@@ -10042,6 +10085,8 @@ var LeaferUI = (function (exports) {
10042
10085
  const { slice, trim, onCanvas } = options;
10043
10086
  let scale = options.scale || 1;
10044
10087
  let pixelRatio = options.pixelRatio || 1;
10088
+ const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
10089
+ const contextSettings = options.contextSettings || leafer.config.contextSettings;
10045
10090
  if (leaf.isApp) {
10046
10091
  scale *= pixelRatio;
10047
10092
  pixelRatio = leaf.app.pixelRatio;
@@ -10080,7 +10125,7 @@ var LeaferUI = (function (exports) {
10080
10125
  renderBounds = leaf.getBounds('render', relative);
10081
10126
  }
10082
10127
  const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
10083
- let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio });
10128
+ let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
10084
10129
  const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
10085
10130
  if (slice) {
10086
10131
  leaf = leafer;
@@ -10126,6 +10171,12 @@ var LeaferUI = (function (exports) {
10126
10171
  tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
10127
10172
  });
10128
10173
  }
10174
+ function checkLazy(leaf) {
10175
+ if (leaf.__.__needComputePaint)
10176
+ leaf.__.__computePaint();
10177
+ if (leaf.isBranch)
10178
+ leaf.children.forEach(child => checkLazy(child));
10179
+ }
10129
10180
 
10130
10181
  const canvas = LeaferCanvasBase.prototype;
10131
10182
  const debug = Debug.get('@leafer-ui/export');