@leafer-draw/miniapp 1.0.0-rc.27 → 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/miniapp.esm.js +19 -7
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.module.js +40 -13
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +7 -7
package/dist/miniapp.esm.js
CHANGED
|
@@ -139,12 +139,12 @@ function useCanvas(_canvasType, app) {
|
|
|
139
139
|
});
|
|
140
140
|
});
|
|
141
141
|
},
|
|
142
|
-
loadImage(
|
|
142
|
+
loadImage(src) {
|
|
143
143
|
return new Promise((resolve, reject) => {
|
|
144
144
|
const img = Platform.canvas.view.createImage();
|
|
145
145
|
img.onload = () => { resolve(img); };
|
|
146
146
|
img.onerror = (error) => { reject(error); };
|
|
147
|
-
img.src =
|
|
147
|
+
img.src = Platform.image.getRealURL(src);
|
|
148
148
|
});
|
|
149
149
|
},
|
|
150
150
|
noRepeat: 'repeat-x'
|
|
@@ -1426,7 +1426,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1426
1426
|
width *= data.scaleX;
|
|
1427
1427
|
height *= data.scaleY;
|
|
1428
1428
|
}
|
|
1429
|
-
allowPaint = width * height > Platform.image.maxCacheSize;
|
|
1429
|
+
allowPaint = (width * height > Platform.image.maxCacheSize) || Export.running;
|
|
1430
1430
|
}
|
|
1431
1431
|
else {
|
|
1432
1432
|
allowPaint = false;
|
|
@@ -1938,7 +1938,8 @@ function createRows(drawData, content, style) {
|
|
|
1938
1938
|
if (breakAll) {
|
|
1939
1939
|
if (wordWidth)
|
|
1940
1940
|
addWord();
|
|
1941
|
-
|
|
1941
|
+
if (rowWidth)
|
|
1942
|
+
addRow();
|
|
1942
1943
|
}
|
|
1943
1944
|
else {
|
|
1944
1945
|
if (!afterBreak)
|
|
@@ -1946,10 +1947,12 @@ function createRows(drawData, content, style) {
|
|
|
1946
1947
|
if (langBreak || afterBreak || charType === Break || charType === Before || charType === Single || (wordWidth + charWidth > realWidth)) {
|
|
1947
1948
|
if (wordWidth)
|
|
1948
1949
|
addWord();
|
|
1949
|
-
|
|
1950
|
+
if (rowWidth)
|
|
1951
|
+
addRow();
|
|
1950
1952
|
}
|
|
1951
1953
|
else {
|
|
1952
|
-
|
|
1954
|
+
if (rowWidth)
|
|
1955
|
+
addRow();
|
|
1953
1956
|
}
|
|
1954
1957
|
}
|
|
1955
1958
|
}
|
|
@@ -2335,6 +2338,7 @@ const ExportModule = {
|
|
|
2335
2338
|
}
|
|
2336
2339
|
const { leafer } = leaf;
|
|
2337
2340
|
if (leafer) {
|
|
2341
|
+
checkLazy(leaf);
|
|
2338
2342
|
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
|
2339
2343
|
options = FileHelper.getExportOptions(options);
|
|
2340
2344
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
@@ -2342,6 +2346,8 @@ const ExportModule = {
|
|
|
2342
2346
|
const { slice, trim, onCanvas } = options;
|
|
2343
2347
|
let scale = options.scale || 1;
|
|
2344
2348
|
let pixelRatio = options.pixelRatio || 1;
|
|
2349
|
+
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
2350
|
+
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
2345
2351
|
if (leaf.isApp) {
|
|
2346
2352
|
scale *= pixelRatio;
|
|
2347
2353
|
pixelRatio = leaf.app.pixelRatio;
|
|
@@ -2380,7 +2386,7 @@ const ExportModule = {
|
|
|
2380
2386
|
renderBounds = leaf.getBounds('render', relative);
|
|
2381
2387
|
}
|
|
2382
2388
|
const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
|
|
2383
|
-
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio });
|
|
2389
|
+
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
2384
2390
|
const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
|
|
2385
2391
|
if (slice) {
|
|
2386
2392
|
leaf = leafer;
|
|
@@ -2426,6 +2432,12 @@ function addTask(task) {
|
|
|
2426
2432
|
tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
|
|
2427
2433
|
});
|
|
2428
2434
|
}
|
|
2435
|
+
function checkLazy(leaf) {
|
|
2436
|
+
if (leaf.__.__needComputePaint)
|
|
2437
|
+
leaf.__.__computePaint();
|
|
2438
|
+
if (leaf.isBranch)
|
|
2439
|
+
leaf.children.forEach(child => checkLazy(child));
|
|
2440
|
+
}
|
|
2429
2441
|
|
|
2430
2442
|
const canvas = LeaferCanvasBase.prototype;
|
|
2431
2443
|
const debug = Debug.get('@leafer-ui/export');
|
package/dist/miniapp.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as n,canvasSizeAttrs as s,ResizeEvent as o,Creator as a,LeaferImage as r,FileHelper as d,LeafList as l,RenderEvent as c,ChildEvent as h,WatchEvent as u,PropertyEvent as f,LeafHelper as p,BranchHelper as g,Bounds as _,LeafBoundsHelper as w,Debug as y,LeafLevelList as m,LayoutEvent as v,Run as x,ImageManager as b,AnimateEvent as B,BoundsHelper as R,MatrixHelper as S,AlignHelper as k,ImageEvent as E,AroundHelper as L,PointHelper as A,Direction4 as W,TwoPointBoundsHelper as T,TaskProcessor as O,Matrix as M}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as C,ColorConvert as P,PaintGradient as I,Export as D,Group as F,TextConvert as z,Paint as U,Effect as V}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class N extends t{get allowBackgroundColor(){return!1}init(){let{view:t}=this.config;t?("string"==typeof t?("#"!==t[0]&&(t="#"+t),this.viewSelect=e.miniapp.select(t)):t.fields?this.viewSelect=t:this.initView(t),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.__createContext();const{width:e,height:n,pixelRatio:s}=this.config,o={width:e||t.width,height:n||t.height,pixelRatio:s};this.resize(o),this.context.roundRect&&(this.roundRect=function(t,e,i,n,s){this.context.roundRect(t,e,i,n,"number"==typeof s?[s]:s)}),i(this.context.__proto__)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize)}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,a={width:t,height:e,pixelRatio:i};if(!this.isSameSize(a)){const t={};n.copyAttrs(t,this,s),this.resize(a),void 0!==this.width&&this.resizeListener(new o(a,t))}}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}}const{mineType:Y,fileType:G}=d;function X(t,i){e.origin||(e.origin={createCanvas:(t,e,n)=>i.createOffscreenCanvas({type:"2d",width:t,height:e}),canvasToDataURL:(t,e,i)=>t.toDataURL(Y(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,n)=>{let s=t.toDataURL(Y(G(i)),n);return s=s.substring(s.indexOf("64,")+3),e.origin.download(s,i)},download:(t,n)=>new Promise(((s,o)=>{let a;n.includes("/")||(n=`${i.env.USER_DATA_PATH}/`+n,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:n,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(n).then((()=>{r.unlink({filePath:n}),s()})):s()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,n)=>{const s=e.canvas.view.createImage();s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=t})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:n=>{n.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient)}Object.assign(a,{canvas:(t,e)=>new N(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){e.canvas.view.requestAnimationFrame(t)},e.devicePixelRatio=wx.getSystemInfoSync().pixelRatio;class j{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new l;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 l,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===h.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 u(u.DATA,{updatedList:this.updatedList})),this.__updatedList=new l,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(f.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(u.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:H,updateAllWorldOpacity:Q}=p,{pushAllChildBranch:J,pushAllParent:Z}=g;const{worldBounds:$}=w,K={x:0,y:0,width:1e5,height:1e5};class tt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new l(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,$)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(K):this.afterBounds.setListWithFn(t,$),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:et,updateAllChange:it}=p,nt=y.get("Layouter");class st{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){nt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?nt.warn("layouting"):this.times>3?nt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(u.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&&J(t,e),Z(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Z(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||H(n[t])}H(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&Q(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 l(e));e.emitEvent(new v(i,o,this.times)),st.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){et(t,!0),t.isBranch?g.updateBounds(t):p.updateBounds(t),it(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new tt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new tt(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_(u.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ot=y.get("Renderer");class at{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 _,ot.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,ot.error(t)}ot.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ot.warn("rendering");if(this.times>3)return ot.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,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 ot.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=x.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),o=new _(n);i.save(),s&&!y.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,o),i.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),x.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),y.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),y.showHitView&&this.renderHitView(n),y.showBoundsView&&this.renderBoundsView(n),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 _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.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 _(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 _(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||ot.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 rt(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 dt(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?ht(t,!0,e,i):ct(e,i);break;case"inside":lt("inside",t,s,e,i);break;case"outside":lt("outside",t,s,e,i)}}function lt(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?ht(e,!0,n,r):ct(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",rt(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 ct(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 ht(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&C.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?ct(i,n):n.stroke(),n.restoreBlendMode()):e?ct(i,n):n.stroke())}Object.assign(a,{watcher:(t,e)=>new j(t,e),layouter:(t,e)=>new st(t,e),renderer:(t,e,i)=>new at(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),e.layout=st.fullLayout;const{getSpread:ut,getOuterOf:ft,getByMove:pt,getIntersectData:gt}=R;let _t;function wt(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:P.string(a,r)};case"image":return C.image(i,t,e,n,!_t||!_t[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:P.string(e)}:void 0}}const yt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),_t=C.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=wt(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?rt(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&&C.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?rt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?rt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?rt(e,i):s?i.fill(s):i.fill())},fillText:rt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)dt(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)dt(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),ht(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ht(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),ht(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:dt,drawTextStroke:ct,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,h=gt(n?ut(e.bounds,l===c?n*l:[n*c,n*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=f),r=ft(s,a),o=pt(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:c}}};let mt={};const{get:vt,rotateOfOuter:xt,translate:bt,scaleOfOuter:Bt,scale:Rt,rotate:St}=S;function kt(t,e,i,n,s,o,a){const r=vt();bt(r,e.x+i,e.y+n),Rt(r,s,o),a&&xt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Et(t,e,i,n,s,o,a){const r=vt();bt(r,e.x+i,e.y+n),s&&Rt(r,s,o),a&&St(r,a),t.transform=r}function Lt(t,e,i,n,s,o,a,r,d,l){const c=vt();if(d)if("center"===l)xt(c,{x:i/2,y:n/2},d);else switch(St(c,d),d){case 90:bt(c,n,0);break;case 180:bt(c,i,n);break;case 270:bt(c,0,i)}mt.x=e.x+s,mt.y=e.y+o,bt(c,mt.x,mt.y),a&&Bt(c,mt,a,r),t.transform=c}const{get:At,translate:Wt}=S,Tt=new _,Ot={};function Mt(t,e,i,n){const{blendMode:s}=i;s&&(t.blendMode=s),t.data=Ct(i,n,e)}function Ct(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:c,rotation:h,repeat:u}=t,f=e.width===n&&e.height===s,p={mode:a},g="center"!==r&&(h||0)%180==90,_=g?s:n,w=g?n:s;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)c?(y=("number"==typeof c?c:c.width)/n,m=("number"==typeof c?c:c.height)/s):l&&(y="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y);else if(!f||h){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),k.toPoint(r,t,e,Ot,!0),v+=Ot.x,x+=Ot.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||h)&&Et(p,e,v,x,y,m,h);break;case"repeat":(!f||y||h)&&Lt(p,e,n,s,v,x,y,m,h,r),u||(p.repeat="repeat");break;default:y&&kt(p,e,v,x,y,m,h)}return p.transform||(e.x||e.y)&&(p.transform=At(),Wt(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,It=new _;const{isSame:Dt}=R;function Ft(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||Mt(s,n,i,o),!0}function zt(t,e){Nt(t,E.LOAD,e)}function Ut(t,e){Nt(t,E.LOADED,e)}function Vt(t,e,i){e.error=i,t.forceUpdate("surface"),Nt(t,E.ERROR,e)}function Nt(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function Yt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Gt,scale:Xt,copy:jt}=S,{ceil:qt,abs:Ht}=Math;function Qt(t,i,n){let{scaleX:s,scaleY:o}=b.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o;if(i.patternId===a||t.destroyed)return!1;{s=Ht(s),o=Ht(o);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=Gt(),jt(l,g),Xt(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,c*=s,h*=o;const w=c*h;if(!_&&w>e.image.maxCacheSize)return!1;let y=e.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,c/=d,h/=d),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(l||(l=Gt(),g&&jt(l,g)),Xt(l,1/s,1/o));const m=t.getCanvas(qt(c)||1,qt(h)||1,p),v=t.getPattern(m,_||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=a,!0}}function Jt(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:Zt}=Math;const $t={image:function(t,e,i,n,s){let o,a;const r=b.get(i);return Pt&&i===Pt.paint&&Dt(n,Pt.boxBounds)?o=Pt.leafPaint:(o={type:i.type,image:r},Pt=r.use>1?{leafPaint:o,paint:i,boxBounds:It.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Ft(t,e,i,r,o,n),s&&(zt(t,a),Ut(t,a))):r.error?s&&Vt(t,a,r.error):(Yt(t,!0),s&&zt(t,a),o.loadId=r.load((()=>{Yt(t,!1),t.destroyed||(Ft(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Ut(t,a)),o.loadId=null}),(e=>{Yt(t,!1),Vt(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,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*=Zt(o)*i.pixelRatio,n*=Zt(a)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,n*=r.scaleY),s=t*n>e.image.maxCacheSize}return s?(i.save(),i.clip(),n.blendMode&&(i.blendMode=n.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(n.image.view,0,0,r.width,r.height),i.restore(),!0):(!n.style||D.running?Qt(t,n,i.pixelRatio):n.patternTask||(n.patternTask=b.patternTasker.add((()=>Jt(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&Qt(t,n,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},createPattern:Qt,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:Mt,getPatternData:Ct,fillOrFitMode:kt,clipMode:Et,repeatMode:Lt},{toPoint:Kt}=L,te={},ee={};function ie(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),P.string(n,i)):t.addColorStop(n.offset,P.string(n.color,i))}const{getAngle:ne,getDistance:se}=A,{get:oe,rotateOfOuter:ae,scaleOfOuter:re}=S,{toPoint:de}=L,le={},ce={};function he(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=ne(e,i);o=oe(),s?(re(o,e,a/r*(n||1),1),ae(o,e,t+90)):(re(o,e,1,a/r*(n||1)),ae(o,e,t))}return o}const{getDistance:ue}=A,{toPoint:fe}=L,pe={},ge={};const _e={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;Kt(n||"top",i,te),Kt(s||"bottom",i,ee);const d=e.canvas.createLinearGradient(te.x,te.y,ee.x,ee.y);ie(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;de(n||"center",i,le),de(s||"bottom",i,ce);const l=e.canvas.createRadialGradient(le.x,le.y,0,le.x,le.y,se(le,ce));ie(l,t.stops,a);const c={type:o,style:l},h=he(i,le,ce,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;fe(n||"center",i,pe),fe(s||"bottom",i,ge);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,pe.x,pe.y):e.canvas.createRadialGradient(pe.x,pe.y,0,pe.x,pe.y,ue(pe,ge));ie(l,t.stops,a);const c={type:o,style:l},h=he(i,pe,ge,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:he},{copy:we,toOffsetOutBounds:ye}=R,me={},ve={};function xe(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(we(me,t.bounds),me.x+=i.x-a.x,me.y+=i.y-a.y,n){const{matrix:t}=s;me.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),me.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),me.width*=n,me.height*=n}t.copyWorld(s.canvas,t.bounds,me)}else n&&(we(me,i),me.x-=i.width/2*(n-1),me.y-=i.height/2*(n-1),me.width*=n,me.height*=n),t.copyWorld(s.canvas,a,n?me:i)}const{toOffsetOutBounds:be}=R,Be={};const Re={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ye(l,ve),r.forEach(((r,g)=>{f.setWorldShadow(ve.offsetX+r.x*h,ve.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,xe(f,ve,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,c,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:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;be(l,Be),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Be.offsetX+r.x*h,Be.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,xe(f,Be,s,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,c,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}=w;function ke(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),Le(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Le(t,i,n,o);break;case"path":i.restore()}}function Ee(t){return t.getSameCanvas(!1,!0)}function Le(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&&(ke(this,a,t,s,n,o),n=s=null),"path"===i.__.mask?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Ee(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="alpha",n||(n=Ee(t)),s||(s=Ee(t)),i.__render(n,e)),"clipping"!==i.__.mask)||Se(i,e)||i.__render(s||t,e);ke(this,a,t,s,n,o)};const Ae=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",We=Ae+"_#~&*+\\=|≮≯≈≠=…",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 Oe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Me=Oe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ce=Oe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Pe=Oe(Ae),Ie=Oe(We),De=Oe("- —/~|┆·");var Fe;!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"}(Fe||(Fe={}));const{Letter:ze,Single:Ue,Before:Ve,After:Ne,Symbol:Ye,Break:Ge}=Fe;function Xe(t){return Me[t]?ze:De[t]?Ge:Ce[t]?Ve:Pe[t]?Ne:Ie[t]?Ye:Te.test(t)?Ue:ze}const je={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:He}=je,{Letter:Qe,Single:Je,Before:Ze,After:$e,Symbol:Ke,Break:ti}=Fe;let ei,ii,ni,si,oi,ai,ri,di,li,ci,hi,ui,fi,pi,gi,_i,wi=[];function yi(t,e){li&&!di&&(di=li),ei.data.push({char:t,width:e}),ni+=e}function mi(){si+=ni,ei.width=ni,ii.words.push(ei),ei={data:[]},ni=0}function vi(){pi&&(gi.paraNumber++,ii.paraStart=!0,pi=!1),li&&(ii.startCharSize=di,ii.endCharSize=li,di=0),ii.width=si,_i.width&&He(ii),wi.push(ii),ii={words:[]},si=0}const xi=0,bi=1,Bi=2;const{top:Ri,right:Si,bottom:ki,left:Ei}=W;function Li(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 Ai={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(o&&(n=l[Ei],o-=l[Si]+l[Ei]),a&&(s=l[Ri],a-=l[Ri]+l[ki]));const c={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){gi=t,wi=t.rows,_i=t.bounds;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:d,height:l}=_i;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;pi=!0,hi=null,di=ri=li=ni=si=0,ei={data:[]},ii={words:[]};for(let n=0,l=i.length;n<l;n++)ai=i[n],"\n"===ai?(ni&&mi(),ii.paraEnd=!0,vi(),pi=!0):(ci=Xe(ai),ci===Qe&&"none"!==a&&(ai=qe(ai,a,!ni)),ri=r.measureText(ai).width,s&&(s<0&&(li=ri),ri+=s),ui=ci===Je&&(hi===Je||hi===Qe)||hi===Je&&ci!==$e,fi=!(ci!==Ze&&ci!==Je||hi!==Ke&&hi!==$e),oi=pi&&o?d-o:d,t&&d&&si+ni+ri>oi&&(e?(ni&&mi(),vi()):(fi||(fi=ci===Qe&&hi==$e),ui||fi||ci===ti||ci===Ze||ci===Je||ni+ri>oi?(ni&&mi(),vi()):vi()))," "===ai&&!0!==pi&&si+ni===0||(ci===ti?(" "===ai&&ni&&mi(),yi(ai,ri),mi()):ui||fi?(ni&&mi(),yi(ai,ri)):yi(ai,ri)),hi=ci);ni&&mi(),si&&vi(),wi.length>0&&(wi[wi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{gi.paraNumber++,wi.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,t,i),l&&function(t,e,i,n,s){if(!n)switch(i.textAlign){case"left":Li(e,"x",t[Ei]);break;case"right":Li(e,"x",-t[Si])}if(!s)switch(i.verticalAlign){case"top":Li(e,"y",t[Ri]);break;case"bottom":Li(e,"y",-t[ki])}}(l,c,i,o,a),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c}=e;let h,u,f,{x:p,y:g,width:_,height:w}=n,y=s*i.length+(c?c*(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(h=i[o],h.x=p,h.width<_||h.width>_&&!r)switch(d){case"center":h.x+=(_-h.width)/2;break;case"right":h.x+=_-h.width}h.paraStart&&c&&o>0&&(m+=c),h.y=m,m+=s,t.overflow>o&&m>y&&(h.isOverflow=!0,t.overflow=o+1),u=h.x,f=h.width,a<0&&(h.width<0?(f=-h.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&&(h.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=g,n.height=y}(c,i),function(t,e,i,n){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?xi:l>.01?bi:Bi,t.isOverflow&&!r&&(t.textMode=!0),h===Bi?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===bi?(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)}))}(c,i,o),c.overflow&&function(t,i){const{rows:n,overflow:s}=t;let{textOverflow:o}=i;if(n.splice(s),o&&"show"!==o){let t,a;"hide"===o?o="":"ellipsis"===o&&(o="...");const r=o?e.canvas.measureText(o).width:0,d=i.x+i.width-r;("none"===i.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)}}))}}(c,i),"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}}(c,i),c}};const Wi={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:Oi,toBounds:Mi}=T;const Ci={export(t,i,n){return this.running=!0,function(t){Pi||(Pi=new O);return new Promise((e=>{Pi.add((()=>Jt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((o=>{const r=t=>{s(t),o(),this.running=!1},{toURL:l}=e,{download:c}=e.origin,h=d.fileType(i);if("json"===i)return r({data:t.toJSON()});if("json"===h)return c(l(JSON.stringify(t.toJSON()),"text"),i),r({data:!0});if("svg"===i)return r({data:t.toSVG()});if("svg"===h)return c(l(t.toSVG(),"svg"),i),r({data:!0});const{leafer:u}=t;u?u.waitViewCompleted((()=>Jt(this,void 0,void 0,(function*(){n=d.getExportOptions(n);let e,s,o=1,l=1;const{worldTransform:c,isLeafer:h,isFrame:f}=t,{slice:p,trim:g,onCanvas:w}=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=h&&v&&void 0===n.fill?t.fill:n.fill,b=d.isOpaqueImage(i)||x,B=new M;if(v)e=!0===v?h?u.canvas.bounds:t.worldRenderBounds:v;else{let i=n.relative||(h?"inner":"local");switch(o=c.scaleX,l=c.scaleY,i){case"inner":B.set(c);break;case"local":B.set(c).divide(t.localTransform),o/=t.scaleX,l/=t.scaleY;break;case"world":o=1,l=1;break;case"page":i=t.leafer;default:B.set(c).divide(t.getTransform(i));const e=i.worldTransform;o/=o/e.scaleX,l/=l/e.scaleY}e=t.getBounds("render",i)}const{x:R,y:S,width:k,height:E}=new _(e).scale(y);let L=a.canvas({width:Math.round(k),height:Math.round(E),pixelRatio:m});const A={matrix:B.scale(1/y).invert().translate(-R,-S).withScale(1/o*y,1/l*y)};if(p&&(t=u,A.bounds=L.bounds),L.save(),f&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(L,A),t.fill=e}else t.__render(L,A);if(L.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?Oi(a,s,o):Ti(a={},s,o)),r++;const d=new _;return Mi(a,d),d.scale(1/t.pixelRatio).ceil()}(L);const t=L,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:m};L=a.canvas(n),L.copyWorld(t,s,n)}b&&L.fillWorld(L.bounds,x||"#FFFFFF","destination-over"),w&&w(L);const W="canvas"===i?L:yield L.export(i,n);r({data:W,width:L.pixelWidth,height:L.pixelHeight,renderBounds:e,trimBounds:s})})))):r({data:!1})}))))}};let Pi;const Ii=t.prototype,Di=y.get("@leafer-ui/export");Ii.export=function(t,e){const{quality:i,blob:n}=d.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Ii.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{Di.error(t),n(null)}))}))},Ii.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Ii.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{Di.error(t),n(!1)}))}))},Object.assign(z,Ai),Object.assign(P,Wi),Object.assign(U,yt),Object.assign(C,$t),Object.assign(I,_e),Object.assign(V,Re),Object.assign(D,Ci);try{X(0,wx)}catch(t){}export{st as Layouter,N as LeaferCanvas,at as Renderer,j as Watcher,X as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as n,canvasSizeAttrs as s,ResizeEvent as o,Creator as a,LeaferImage as r,FileHelper as d,LeafList as l,RenderEvent as c,ChildEvent as h,WatchEvent as u,PropertyEvent as f,LeafHelper as p,BranchHelper as g,Bounds as _,LeafBoundsHelper as w,Debug as m,LeafLevelList as y,LayoutEvent as v,Run as x,ImageManager as b,AnimateEvent as B,BoundsHelper as R,MatrixHelper as S,AlignHelper as k,ImageEvent as E,AroundHelper as L,PointHelper as A,Direction4 as W,TwoPointBoundsHelper as T,TaskProcessor as O,Matrix as M}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as C,ColorConvert as P,PaintGradient as I,Export as D,Group as F,TextConvert as z,Paint as U,Effect as V}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class N extends t{get allowBackgroundColor(){return!1}init(){let{view:t}=this.config;t?("string"==typeof t?("#"!==t[0]&&(t="#"+t),this.viewSelect=e.miniapp.select(t)):t.fields?this.viewSelect=t:this.initView(t),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.__createContext();const{width:e,height:n,pixelRatio:s}=this.config,o={width:e||t.width,height:n||t.height,pixelRatio:s};this.resize(o),this.context.roundRect&&(this.roundRect=function(t,e,i,n,s){this.context.roundRect(t,e,i,n,"number"==typeof s?[s]:s)}),i(this.context.__proto__)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize)}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,a={width:t,height:e,pixelRatio:i};if(!this.isSameSize(a)){const t={};n.copyAttrs(t,this,s),this.resize(a),void 0!==this.width&&this.resizeListener(new o(a,t))}}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}}const{mineType:Y,fileType:G}=d;function X(t,i){e.origin||(e.origin={createCanvas:(t,e,n)=>i.createOffscreenCanvas({type:"2d",width:t,height:e}),canvasToDataURL:(t,e,i)=>t.toDataURL(Y(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,n)=>{let s=t.toDataURL(Y(G(i)),n);return s=s.substring(s.indexOf("64,")+3),e.origin.download(s,i)},download:(t,n)=>new Promise(((s,o)=>{let a;n.includes("/")||(n=`${i.env.USER_DATA_PATH}/`+n,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:n,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(n).then((()=>{r.unlink({filePath:n}),s()})):s()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,n)=>{const s=e.canvas.view.createImage();s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=e.image.getRealURL(t)})),noRepeat:"repeat-x"},e.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:n=>{n.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient)}Object.assign(a,{canvas:(t,e)=>new N(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){e.canvas.view.requestAnimationFrame(t)},e.devicePixelRatio=wx.getSystemInfoSync().pixelRatio;class j{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new l;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 l,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===h.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 u(u.DATA,{updatedList:this.updatedList})),this.__updatedList=new l,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(f.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(u.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:H,updateAllWorldOpacity:Q}=p,{pushAllChildBranch:J,pushAllParent:Z}=g;const{worldBounds:$}=w,K={x:0,y:0,width:1e5,height:1e5};class tt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new l(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,$)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(K):this.afterBounds.setListWithFn(t,$),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:et,updateAllChange:it}=p,nt=m.get("Layouter");class st{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,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){nt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?nt.warn("layouting"):this.times>3?nt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(u.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&&J(t,e),Z(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),Z(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||H(n[t])}H(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&Q(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 l(e));e.emitEvent(new v(i,o,this.times)),st.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){et(t,!0),t.isBranch?g.updateBounds(t):p.updateBounds(t),it(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new tt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new tt(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_(u.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ot=m.get("Renderer");class at{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 _,ot.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,ot.error(t)}ot.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ot.warn("rendering");if(this.times>3)return ot.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,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 ot.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=x.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),o=new _(n);i.save(),s&&!m.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,o),i.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),x.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),m.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),m.showHitView&&this.renderHitView(n),m.showBoundsView&&this.renderBoundsView(n),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 _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.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 _(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 _(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||ot.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 rt(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 dt(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?ht(t,!0,e,i):ct(e,i);break;case"inside":lt("inside",t,s,e,i);break;case"outside":lt("outside",t,s,e,i)}}function lt(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?ht(e,!0,n,r):ct(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",rt(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 ct(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 ht(t,e,i,n){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&C.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?ct(i,n):n.stroke(),n.restoreBlendMode()):e?ct(i,n):n.stroke())}Object.assign(a,{watcher:(t,e)=>new j(t,e),layouter:(t,e)=>new st(t,e),renderer:(t,e,i)=>new at(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),e.layout=st.fullLayout;const{getSpread:ut,getOuterOf:ft,getByMove:pt,getIntersectData:gt}=R;let _t;function wt(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:P.string(a,r)};case"image":return C.image(i,t,e,n,!_t||!_t[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:P.string(e)}:void 0}}const mt={compute:function(t,e){const i=e.__,n=[];let s,o=i.__input[t];o instanceof Array||(o=[o]),_t=C.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=wt(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?rt(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&&C.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?rt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),o?rt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):o?rt(e,i):s?i.fill(s):i.fill())},fillText:rt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)dt(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)dt(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),ht(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),ht(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),ht(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:dt,drawTextStroke:ct,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,h=gt(n?ut(e.bounds,l===c?n*l:[n*c,n*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,c*=f),r=ft(s,a),o=pt(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:c}}};let yt={};const{get:vt,rotateOfOuter:xt,translate:bt,scaleOfOuter:Bt,scale:Rt,rotate:St}=S;function kt(t,e,i,n,s,o,a){const r=vt();bt(r,e.x+i,e.y+n),Rt(r,s,o),a&&xt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function Et(t,e,i,n,s,o,a){const r=vt();bt(r,e.x+i,e.y+n),s&&Rt(r,s,o),a&&St(r,a),t.transform=r}function Lt(t,e,i,n,s,o,a,r,d,l){const c=vt();if(d)if("center"===l)xt(c,{x:i/2,y:n/2},d);else switch(St(c,d),d){case 90:bt(c,n,0);break;case 180:bt(c,i,n);break;case 270:bt(c,0,i)}yt.x=e.x+s,yt.y=e.y+o,bt(c,yt.x,yt.y),a&&Bt(c,yt,a,r),t.transform=c}const{get:At,translate:Wt}=S,Tt=new _,Ot={};function Mt(t,e,i,n){const{blendMode:s}=i;s&&(t.blendMode=s),t.data=Ct(i,n,e)}function Ct(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:c,rotation:h,repeat:u}=t,f=e.width===n&&e.height===s,p={mode:a},g="center"!==r&&(h||0)%180==90,_=g?s:n,w=g?n:s;let m,y,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)c?(m=("number"==typeof c?c:c.width)/n,y=("number"==typeof c?c:c.height)/s):l&&(m="number"==typeof l?l:l.x,y="number"==typeof l?l:l.y);else if(!f||h){const t=e.width/_,i=e.height/w;m=y="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-n*m)/2,x+=(e.height-s*y)/2}if(r){const t={x:v,y:x,width:_,height:w};m&&(t.width*=m,t.height*=y),k.toPoint(r,t,e,Ot,!0),v+=Ot.x,x+=Ot.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||m||h)&&Et(p,e,v,x,m,y,h);break;case"repeat":(!f||m||h)&&Lt(p,e,n,s,v,x,m,y,h,r),u||(p.repeat="repeat");break;default:m&&kt(p,e,v,x,m,y,h)}return p.transform||(e.x||e.y)&&(p.transform=At(),Wt(p.transform,e.x,e.y)),m&&"strench"!==a&&(p.scaleX=m,p.scaleY=y),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,It=new _;const{isSame:Dt}=R;function Ft(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||Mt(s,n,i,o),!0}function zt(t,e){Nt(t,E.LOAD,e)}function Ut(t,e){Nt(t,E.LOADED,e)}function Vt(t,e,i){e.error=i,t.forceUpdate("surface"),Nt(t,E.ERROR,e)}function Nt(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function Yt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Gt,scale:Xt,copy:jt}=S,{ceil:qt,abs:Ht}=Math;function Qt(t,i,n){let{scaleX:s,scaleY:o}=b.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o;if(i.patternId===a||t.destroyed)return!1;{s=Ht(s),o=Ht(o);const{image:t,data:r}=i;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=Gt(),jt(l,g),Xt(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,c*=s,h*=o;const w=c*h;if(!_&&w>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;m>e&&(m=e)}w>m&&(d=Math.sqrt(w/m)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(l||(l=Gt(),g&&jt(l,g)),Xt(l,1/s,1/o));const y=t.getCanvas(qt(c)||1,qt(h)||1,p),v=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=a,!0}}function Jt(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:Zt}=Math;const $t={image:function(t,e,i,n,s){let o,a;const r=b.get(i);return Pt&&i===Pt.paint&&Dt(n,Pt.boxBounds)?o=Pt.leafPaint:(o={type:i.type,image:r},Pt=r.use>1?{leafPaint:o,paint:i,boxBounds:It.set(n)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(Ft(t,e,i,r,o,n),s&&(zt(t,a),Ut(t,a))):r.error?s&&Vt(t,a,r.error):(Yt(t,!0),s&&zt(t,a),o.loadId=r.load((()=>{Yt(t,!1),t.destroyed||(Ft(t,e,i,r,o,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Ut(t,a)),o.loadId=null}),(e=>{Yt(t,!1),Vt(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,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*=Zt(o)*i.pixelRatio,n*=Zt(a)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,n*=r.scaleY),s=t*n>e.image.maxCacheSize||D.running}return s?(i.save(),i.clip(),n.blendMode&&(i.blendMode=n.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(n.image.view,0,0,r.width,r.height),i.restore(),!0):(!n.style||D.running?Qt(t,n,i.pixelRatio):n.patternTask||(n.patternTask=b.patternTasker.add((()=>Jt(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&Qt(t,n,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},createPattern:Qt,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:Mt,getPatternData:Ct,fillOrFitMode:kt,clipMode:Et,repeatMode:Lt},{toPoint:Kt}=L,te={},ee={};function ie(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),P.string(n,i)):t.addColorStop(n.offset,P.string(n.color,i))}const{getAngle:ne,getDistance:se}=A,{get:oe,rotateOfOuter:ae,scaleOfOuter:re}=S,{toPoint:de}=L,le={},ce={};function he(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=ne(e,i);o=oe(),s?(re(o,e,a/r*(n||1),1),ae(o,e,t+90)):(re(o,e,1,a/r*(n||1)),ae(o,e,t))}return o}const{getDistance:ue}=A,{toPoint:fe}=L,pe={},ge={};const _e={linearGradient:function(t,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=t;Kt(n||"top",i,te),Kt(s||"bottom",i,ee);const d=e.canvas.createLinearGradient(te.x,te.y,ee.x,ee.y);ie(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;de(n||"center",i,le),de(s||"bottom",i,ce);const l=e.canvas.createRadialGradient(le.x,le.y,0,le.x,le.y,se(le,ce));ie(l,t.stops,a);const c={type:o,style:l},h=he(i,le,ce,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;fe(n||"center",i,pe),fe(s||"bottom",i,ge);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,pe.x,pe.y):e.canvas.createRadialGradient(pe.x,pe.y,0,pe.x,pe.y,ue(pe,ge));ie(l,t.stops,a);const c={type:o,style:l},h=he(i,pe,ge,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:he},{copy:we,toOffsetOutBounds:me}=R,ye={},ve={};function xe(t,i,n,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(we(ye,t.bounds),ye.x+=i.x-a.x,ye.y+=i.y-a.y,n){const{matrix:t}=s;ye.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),ye.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),ye.width*=n,ye.height*=n}t.copyWorld(s.canvas,t.bounds,ye)}else n&&(we(ye,i),ye.x-=i.width/2*(n-1),ye.y-=i.height/2*(n-1),ye.width*=n,ye.height*=n),t.copyWorld(s.canvas,a,n?ye:i)}const{toOffsetOutBounds:be}=R,Be={};const Re={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;me(l,ve),r.forEach(((r,g)=>{f.setWorldShadow(ve.offsetX+r.x*h,ve.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,xe(f,ve,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,c,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:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;be(l,Be),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Be.offsetX+r.x*h,Be.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,xe(f,Be,s,i),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),n=o):(f.copyWorld(i.canvas,c,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}=w;function ke(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),Le(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Le(t,i,n,o);break;case"path":i.restore()}}function Ee(t){return t.getSameCanvas(!1,!0)}function Le(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&&(ke(this,a,t,s,n,o),n=s=null),"path"===i.__.mask?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Ee(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="alpha",n||(n=Ee(t)),s||(s=Ee(t)),i.__render(n,e)),"clipping"!==i.__.mask)||Se(i,e)||i.__render(s||t,e);ke(this,a,t,s,n,o)};const Ae=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",We=Ae+"_#~&*+\\=|≮≯≈≠=…",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 Oe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Me=Oe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ce=Oe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Pe=Oe(Ae),Ie=Oe(We),De=Oe("- —/~|┆·");var Fe;!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"}(Fe||(Fe={}));const{Letter:ze,Single:Ue,Before:Ve,After:Ne,Symbol:Ye,Break:Ge}=Fe;function Xe(t){return Me[t]?ze:De[t]?Ge:Ce[t]?Ve:Pe[t]?Ne:Ie[t]?Ye:Te.test(t)?Ue:ze}const je={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:He}=je,{Letter:Qe,Single:Je,Before:Ze,After:$e,Symbol:Ke,Break:ti}=Fe;let ei,ii,ni,si,oi,ai,ri,di,li,ci,hi,ui,fi,pi,gi,_i,wi=[];function mi(t,e){li&&!di&&(di=li),ei.data.push({char:t,width:e}),ni+=e}function yi(){si+=ni,ei.width=ni,ii.words.push(ei),ei={data:[]},ni=0}function vi(){pi&&(gi.paraNumber++,ii.paraStart=!0,pi=!1),li&&(ii.startCharSize=di,ii.endCharSize=li,di=0),ii.width=si,_i.width&&He(ii),wi.push(ii),ii={words:[]},si=0}const xi=0,bi=1,Bi=2;const{top:Ri,right:Si,bottom:ki,left:Ei}=W;function Li(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 Ai={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(o&&(n=l[Ei],o-=l[Si]+l[Ei]),a&&(s=l[Ri],a-=l[Ri]+l[ki]));const c={bounds:{x:n,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){gi=t,wi=t.rows,_i=t.bounds;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=e,{width:d,height:l}=_i;if(d||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;pi=!0,hi=null,di=ri=li=ni=si=0,ei={data:[]},ii={words:[]};for(let n=0,l=i.length;n<l;n++)ai=i[n],"\n"===ai?(ni&&yi(),ii.paraEnd=!0,vi(),pi=!0):(ci=Xe(ai),ci===Qe&&"none"!==a&&(ai=qe(ai,a,!ni)),ri=r.measureText(ai).width,s&&(s<0&&(li=ri),ri+=s),ui=ci===Je&&(hi===Je||hi===Qe)||hi===Je&&ci!==$e,fi=!(ci!==Ze&&ci!==Je||hi!==Ke&&hi!==$e),oi=pi&&o?d-o:d,t&&d&&si+ni+ri>oi&&(e?(ni&&yi(),si&&vi()):(fi||(fi=ci===Qe&&hi==$e),ui||fi||ci===ti||ci===Ze||ci===Je||ni+ri>oi?(ni&&yi(),si&&vi()):si&&vi()))," "===ai&&!0!==pi&&si+ni===0||(ci===ti?(" "===ai&&ni&&yi(),mi(ai,ri),yi()):ui||fi?(ni&&yi(),mi(ai,ri)):mi(ai,ri)),hi=ci);ni&&yi(),si&&vi(),wi.length>0&&(wi[wi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{gi.paraNumber++,wi.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,t,i),l&&function(t,e,i,n,s){if(!n)switch(i.textAlign){case"left":Li(e,"x",t[Ei]);break;case"right":Li(e,"x",-t[Si])}if(!s)switch(i.verticalAlign){case"top":Li(e,"y",t[Ri]);break;case"bottom":Li(e,"y",-t[ki])}}(l,c,i,o,a),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c}=e;let h,u,f,{x:p,y:g,width:_,height:w}=n,m=s*i.length+(c?c*(t.paraNumber-1):0),y=o;if(r&&m>w)m=Math.max(w,s),t.overflow=i.length;else switch(l){case"middle":g+=(w-m)/2;break;case"bottom":g+=w-m}y+=g;for(let o=0,l=i.length;o<l;o++){if(h=i[o],h.x=p,h.width<_||h.width>_&&!r)switch(d){case"center":h.x+=(_-h.width)/2;break;case"right":h.x+=_-h.width}h.paraStart&&c&&o>0&&(y+=c),h.y=y,y+=s,t.overflow>o&&y>m&&(h.isOverflow=!0,t.overflow=o+1),u=h.x,f=h.width,a<0&&(h.width<0?(f=-h.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&&(h.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=g,n.height=m}(c,i),function(t,e,i,n){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?xi:l>.01?bi:Bi,t.isOverflow&&!r&&(t.textMode=!0),h===Bi?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===bi?(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)}))}(c,i,o),c.overflow&&function(t,i){const{rows:n,overflow:s}=t;let{textOverflow:o}=i;if(n.splice(s),o&&"show"!==o){let t,a;"hide"===o?o="":"ellipsis"===o&&(o="...");const r=o?e.canvas.measureText(o).width:0,d=i.x+i.width-r;("none"===i.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)}}))}}(c,i),"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}}(c,i),c}};const Wi={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:Oi,toBounds:Mi}=T;const Ci={export(t,i,n){return this.running=!0,function(t){Pi||(Pi=new O);return new Promise((e=>{Pi.add((()=>Jt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((o=>{const r=t=>{s(t),o(),this.running=!1},{toURL:l}=e,{download:c}=e.origin,h=d.fileType(i);if("json"===i)return r({data:t.toJSON()});if("json"===h)return c(l(JSON.stringify(t.toJSON()),"text"),i),r({data:!0});if("svg"===i)return r({data:t.toSVG()});if("svg"===h)return c(l(t.toSVG(),"svg"),i),r({data:!0});const{leafer:u}=t;u?(Ii(t),u.waitViewCompleted((()=>Jt(this,void 0,void 0,(function*(){n=d.getExportOptions(n);let e,s,o=1,l=1;const{worldTransform:c,isLeafer:h,isFrame:f}=t,{slice:p,trim:g,onCanvas:w}=n;let m=n.scale||1,y=n.pixelRatio||1;const v=void 0===n.smooth?u.config.smooth:n.smooth,x=n.contextSettings||u.config.contextSettings;t.isApp&&(m*=y,y=t.app.pixelRatio);const b=n.screenshot||t.isApp,B=h&&b&&void 0===n.fill?t.fill:n.fill,R=d.isOpaqueImage(i)||B,S=new M;if(b)e=!0===b?h?u.canvas.bounds:t.worldRenderBounds:b;else{let i=n.relative||(h?"inner":"local");switch(o=c.scaleX,l=c.scaleY,i){case"inner":S.set(c);break;case"local":S.set(c).divide(t.localTransform),o/=t.scaleX,l/=t.scaleY;break;case"world":o=1,l=1;break;case"page":i=t.leafer;default:S.set(c).divide(t.getTransform(i));const e=i.worldTransform;o/=o/e.scaleX,l/=l/e.scaleY}e=t.getBounds("render",i)}const{x:k,y:E,width:L,height:A}=new _(e).scale(m);let W=a.canvas({width:Math.round(L),height:Math.round(A),pixelRatio:y,smooth:v,contextSettings:x});const T={matrix:S.scale(1/m).invert().translate(-k,-E).withScale(1/o*m,1/l*m)};if(p&&(t=u,T.bounds=W.bounds),W.save(),f&&void 0!==B){const e=t.get("fill");t.fill="",t.__render(W,T),t.fill=e}else t.__render(W,T);if(W.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?Oi(a,s,o):Ti(a={},s,o)),r++;const d=new _;return Mi(a,d),d.scale(1/t.pixelRatio).ceil()}(W);const t=W,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:y};W=a.canvas(n),W.copyWorld(t,s,n)}R&&W.fillWorld(W.bounds,B||"#FFFFFF","destination-over"),w&&w(W);const O="canvas"===i?W:yield W.export(i,n);r({data:O,width:W.pixelWidth,height:W.pixelHeight,renderBounds:e,trimBounds:s})}))))):r({data:!1})}))))}};let Pi;function Ii(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Ii(t)))}const Di=t.prototype,Fi=m.get("@leafer-ui/export");Di.export=function(t,e){const{quality:i,blob:n}=d.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Di.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{Fi.error(t),n(null)}))}))},Di.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Di.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{Fi.error(t),n(!1)}))}))},Object.assign(z,Ai),Object.assign(P,Wi),Object.assign(U,mt),Object.assign(C,$t),Object.assign(I,_e),Object.assign(V,Re),Object.assign(D,Ci);try{X(0,wx)}catch(t){}export{st as Layouter,N as LeaferCanvas,at as Renderer,j as Watcher,X as useCanvas};
|
package/dist/miniapp.module.js
CHANGED
|
@@ -11,8 +11,15 @@ const Platform = {
|
|
|
11
11
|
hitCanvasSize: 100,
|
|
12
12
|
maxCacheSize: 2560 * 1600,
|
|
13
13
|
maxPatternSize: 4096 * 2160,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
crossOrigin: 'anonymous',
|
|
15
|
+
getRealURL(url) {
|
|
16
|
+
const { prefix, suffix } = Platform.image;
|
|
17
|
+
if (suffix && !url.startsWith('data:') && !url.startsWith('blob:'))
|
|
18
|
+
url += (url.includes("?") ? "&" : "?") + suffix;
|
|
19
|
+
if (prefix && url[0] === '/')
|
|
20
|
+
url = prefix + url;
|
|
21
|
+
return url;
|
|
22
|
+
}
|
|
16
23
|
}
|
|
17
24
|
};
|
|
18
25
|
|
|
@@ -5126,6 +5133,7 @@ let Leaf = class Leaf {
|
|
|
5126
5133
|
get __worldFlipped() { return this.__world.scaleX < 0 || this.__world.scaleY < 0; }
|
|
5127
5134
|
get __onlyHitMask() { return this.__hasMask && !this.__.hitChildren; }
|
|
5128
5135
|
get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
|
|
5136
|
+
get __inLazyBounds() { const { leafer } = this; return leafer && leafer.created && leafer.lazyBounds.hit(this.__world); }
|
|
5129
5137
|
get pathInputed() { return this.__.__pathInputed; }
|
|
5130
5138
|
constructor(data) {
|
|
5131
5139
|
this.innerId = create(LEAF);
|
|
@@ -5210,6 +5218,9 @@ let Leaf = class Leaf {
|
|
|
5210
5218
|
findOne(_condition, _options) { return undefined; }
|
|
5211
5219
|
findId(_id) { return undefined; }
|
|
5212
5220
|
focus(_value) { }
|
|
5221
|
+
updateLayout() {
|
|
5222
|
+
this.__layout.update();
|
|
5223
|
+
}
|
|
5213
5224
|
forceUpdate(attrName) {
|
|
5214
5225
|
if (attrName === undefined)
|
|
5215
5226
|
attrName = 'width';
|
|
@@ -5219,8 +5230,8 @@ let Leaf = class Leaf {
|
|
|
5219
5230
|
this.__[attrName] = value === undefined ? null : undefined;
|
|
5220
5231
|
this[attrName] = value;
|
|
5221
5232
|
}
|
|
5222
|
-
|
|
5223
|
-
this.
|
|
5233
|
+
forceRender(_bounds) {
|
|
5234
|
+
this.forceUpdate('surface');
|
|
5224
5235
|
}
|
|
5225
5236
|
__updateWorldMatrix() { }
|
|
5226
5237
|
__updateLocalMatrix() { }
|
|
@@ -5890,12 +5901,12 @@ function useCanvas(_canvasType, app) {
|
|
|
5890
5901
|
});
|
|
5891
5902
|
});
|
|
5892
5903
|
},
|
|
5893
|
-
loadImage(
|
|
5904
|
+
loadImage(src) {
|
|
5894
5905
|
return new Promise((resolve, reject) => {
|
|
5895
5906
|
const img = Platform.canvas.view.createImage();
|
|
5896
5907
|
img.onload = () => { resolve(img); };
|
|
5897
5908
|
img.onerror = (error) => { reject(error); };
|
|
5898
|
-
img.src =
|
|
5909
|
+
img.src = Platform.image.getRealURL(src);
|
|
5899
5910
|
});
|
|
5900
5911
|
},
|
|
5901
5912
|
noRepeat: 'repeat-x'
|
|
@@ -7059,7 +7070,7 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7059
7070
|
__onUpdateSize() {
|
|
7060
7071
|
if (this.__.__input) {
|
|
7061
7072
|
const data = this.__;
|
|
7062
|
-
(data.lazy && this.
|
|
7073
|
+
(data.lazy && !this.__inLazyBounds && !Export.running) ? data.__needComputePaint = true : data.__computePaint();
|
|
7063
7074
|
}
|
|
7064
7075
|
}
|
|
7065
7076
|
__updateRenderPath() {
|
|
@@ -7617,6 +7628,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7617
7628
|
if (!this.parent)
|
|
7618
7629
|
this.canvas.hittable = newValue;
|
|
7619
7630
|
}
|
|
7631
|
+
else if (attrName === 'zIndex') {
|
|
7632
|
+
this.canvas.zIndex = newValue;
|
|
7633
|
+
setTimeout(() => this.parent && this.parent.__updateSortChildren());
|
|
7634
|
+
}
|
|
7620
7635
|
}
|
|
7621
7636
|
return super.__setAttr(attrName, newValue);
|
|
7622
7637
|
}
|
|
@@ -8235,7 +8250,7 @@ let Canvas = class Canvas extends Rect {
|
|
|
8235
8250
|
__drawAfterFill(canvas, _options) {
|
|
8236
8251
|
const origin = this.canvas.view;
|
|
8237
8252
|
const { width, height } = this;
|
|
8238
|
-
if (this.__.cornerRadius) {
|
|
8253
|
+
if (this.__.cornerRadius || this.pathInputed) {
|
|
8239
8254
|
canvas.save();
|
|
8240
8255
|
canvas.clip();
|
|
8241
8256
|
canvas.drawImage(this.canvas.view, 0, 0, origin.width, origin.height, 0, 0, width, height);
|
|
@@ -9116,7 +9131,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
9116
9131
|
width *= data.scaleX;
|
|
9117
9132
|
height *= data.scaleY;
|
|
9118
9133
|
}
|
|
9119
|
-
allowPaint = width * height > Platform.image.maxCacheSize;
|
|
9134
|
+
allowPaint = (width * height > Platform.image.maxCacheSize) || Export.running;
|
|
9120
9135
|
}
|
|
9121
9136
|
else {
|
|
9122
9137
|
allowPaint = false;
|
|
@@ -9628,7 +9643,8 @@ function createRows(drawData, content, style) {
|
|
|
9628
9643
|
if (breakAll) {
|
|
9629
9644
|
if (wordWidth)
|
|
9630
9645
|
addWord();
|
|
9631
|
-
|
|
9646
|
+
if (rowWidth)
|
|
9647
|
+
addRow();
|
|
9632
9648
|
}
|
|
9633
9649
|
else {
|
|
9634
9650
|
if (!afterBreak)
|
|
@@ -9636,10 +9652,12 @@ function createRows(drawData, content, style) {
|
|
|
9636
9652
|
if (langBreak || afterBreak || charType === Break || charType === Before || charType === Single || (wordWidth + charWidth > realWidth)) {
|
|
9637
9653
|
if (wordWidth)
|
|
9638
9654
|
addWord();
|
|
9639
|
-
|
|
9655
|
+
if (rowWidth)
|
|
9656
|
+
addRow();
|
|
9640
9657
|
}
|
|
9641
9658
|
else {
|
|
9642
|
-
|
|
9659
|
+
if (rowWidth)
|
|
9660
|
+
addRow();
|
|
9643
9661
|
}
|
|
9644
9662
|
}
|
|
9645
9663
|
}
|
|
@@ -10025,6 +10043,7 @@ const ExportModule = {
|
|
|
10025
10043
|
}
|
|
10026
10044
|
const { leafer } = leaf;
|
|
10027
10045
|
if (leafer) {
|
|
10046
|
+
checkLazy(leaf);
|
|
10028
10047
|
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
|
10029
10048
|
options = FileHelper.getExportOptions(options);
|
|
10030
10049
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
@@ -10032,6 +10051,8 @@ const ExportModule = {
|
|
|
10032
10051
|
const { slice, trim, onCanvas } = options;
|
|
10033
10052
|
let scale = options.scale || 1;
|
|
10034
10053
|
let pixelRatio = options.pixelRatio || 1;
|
|
10054
|
+
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
10055
|
+
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
10035
10056
|
if (leaf.isApp) {
|
|
10036
10057
|
scale *= pixelRatio;
|
|
10037
10058
|
pixelRatio = leaf.app.pixelRatio;
|
|
@@ -10070,7 +10091,7 @@ const ExportModule = {
|
|
|
10070
10091
|
renderBounds = leaf.getBounds('render', relative);
|
|
10071
10092
|
}
|
|
10072
10093
|
const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
|
|
10073
|
-
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio });
|
|
10094
|
+
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
10074
10095
|
const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
|
|
10075
10096
|
if (slice) {
|
|
10076
10097
|
leaf = leafer;
|
|
@@ -10116,6 +10137,12 @@ function addTask(task) {
|
|
|
10116
10137
|
tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
|
|
10117
10138
|
});
|
|
10118
10139
|
}
|
|
10140
|
+
function checkLazy(leaf) {
|
|
10141
|
+
if (leaf.__.__needComputePaint)
|
|
10142
|
+
leaf.__.__computePaint();
|
|
10143
|
+
if (leaf.isBranch)
|
|
10144
|
+
leaf.children.forEach(child => checkLazy(child));
|
|
10145
|
+
}
|
|
10119
10146
|
|
|
10120
10147
|
const canvas = LeaferCanvasBase.prototype;
|
|
10121
10148
|
const debug = Debug.get('@leafer-ui/export');
|