-
Notifications
You must be signed in to change notification settings - Fork 3
/
minitex.min.js
1 lines (1 loc) · 46.4 KB
/
minitex.min.js
1
!function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).MiniTex=f()}}((function(){return function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,(function(r){return o(e[i][1][r]||r)}),p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}({1:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Paragraph=exports.drawParagraph=void 0;const drawer_1=require("../impl/drawer"),layout_1=require("../impl/layout"),span_1=require("../impl/span"),logger_1=require("../logger"),skia_1=require("./skia");let drawParagraphSharedPaint;exports.drawParagraph=function(CanvasKit,skCanvas,paragraph,dx,dy){let drawStartTime;logger_1.logger.profileMode&&(drawStartTime=(new Date).getTime());let canvasImg=paragraph.skImageCache;if(!canvasImg){const imageData=new drawer_1.Drawer(paragraph).draw();canvasImg=CanvasKit.MakeImage({width:imageData.width,height:imageData.height,alphaType:CanvasKit.AlphaType.Unpremul,colorType:CanvasKit.ColorType.RGBA_8888,colorSpace:CanvasKit.ColorSpace.SRGB},imageData.data,4*imageData.width),paragraph.skImageCache=canvasImg,paragraph.skImageWidth=imageData.width,paragraph.skImageHeight=imageData.height}const srcRect=CanvasKit.XYWHRect(0,0,paragraph.skImageWidth,paragraph.skImageHeight),dstRect=CanvasKit.XYWHRect(Math.ceil(dx),Math.ceil(dy),paragraph.skImageWidth/drawer_1.Drawer.pixelRatio,paragraph.skImageHeight/drawer_1.Drawer.pixelRatio),skPaint=null!=drawParagraphSharedPaint?drawParagraphSharedPaint:new CanvasKit.Paint;if(drawParagraphSharedPaint=skPaint,skCanvas.drawImageRect(canvasImg,srcRect,dstRect,skPaint),logger_1.logger.profileMode){const drawCostTime=(new Date).getTime()-drawStartTime;logger_1.logger.profile("drawParagraph cost",drawCostTime)}};class Paragraph extends skia_1.SkEmbindObject{constructor(spans,paragraphStyle,iconFontData){super(),this.spans=spans,this.paragraphStyle=paragraphStyle,this.iconFontData=iconFontData,this._type="SkParagraph",this.isMiniTex=!0,this._textLayout=new layout_1.TextLayout(this),this.iconFontData&&(this.iconFontMap=JSON.parse(this.iconFontData))}delete(){this.skImageCache&&(this.skImageCache.delete(),this.skImageCache=void 0),super.delete()}didExceedMaxLines(){return this._textLayout.didExceedMaxLines}getAlphabeticBaseline(){return 0}getGlyphPositionAtCoordinate(dx,dy){this._textLayout.measureGlyphIfNeeded();for(let index=0;index<this._textLayout.glyphInfos.length;index++){const glyphInfo=this._textLayout.glyphInfos[index],left=glyphInfo.graphemeLayoutBounds[0],top=glyphInfo.graphemeLayoutBounds[1],width=glyphInfo.graphemeLayoutBounds[2]-left,height=glyphInfo.graphemeLayoutBounds[3]-top;if(dx>=left&&dx<=left+width&&dy>=top&&dy<=top+height)return{pos:index,affinity:{value:skia_1.Affinity.Downstream}}}for(let index=0;index<this._textLayout.lineMetrics.length;index++){const lineMetrics=this._textLayout.lineMetrics[index],isLastLine=index===this._textLayout.lineMetrics.length-1,top=lineMetrics.yOffset,width=lineMetrics.width,height=lineMetrics.height;if(dy>=top&&dy<=top+height){if(dx<=0)return{pos:lineMetrics.startIndex,affinity:{value:skia_1.Affinity.Downstream}};if(dx>=width)return{pos:lineMetrics.endIndex,affinity:{value:skia_1.Affinity.Downstream}}}if(dy>=top+height&&isLastLine)return{pos:lineMetrics.endIndex,affinity:{value:skia_1.Affinity.Downstream}}}return{pos:0,affinity:{value:skia_1.Affinity.Upstream}}}getClosestGlyphInfoAtCoordinate(dx,dy){return this.getGlyphInfoAt(this.getGlyphPositionAtCoordinate(dx,dy).pos)}getGlyphInfoAt(index){var _a;return this._textLayout.measureGlyphIfNeeded(),null!==(_a=this._textLayout.glyphInfos[index])&&void 0!==_a?_a:null}getHeight(){const lineMetrics=this.getLineMetrics();let height=0;for(let i=0;i<lineMetrics.length;i++)height+=lineMetrics[i].height*lineMetrics[i].heightMultiplier,i>0&&i<lineMetrics.length&&(height+=.15*lineMetrics[i].height);return height}getIdeographicBaseline(){return 0}getLineNumberAt(index){var _a,_b;return null!==(_b=null===(_a=this.getLineMetricsOfRange(index,index)[0])||void 0===_a?void 0:_a.lineNumber)&&void 0!==_b?_b:0}getLineMetrics(){return this._textLayout.lineMetrics}getLineMetricsAt(lineNumber){var _a;return null!==(_a=this._textLayout.lineMetrics[lineNumber])&&void 0!==_a?_a:null}getLineMetricsOfRange(start,end){let lineMetrics=[];return this._textLayout.lineMetrics.forEach((it=>{const range0=[start,end],range1=[it.startIndex,it.endIndex];range0[1]>=range1[0]&&range1[1]>=range0[0]&&lineMetrics.push(it)})),lineMetrics}getLongestLine(){return 0}getMaxIntrinsicWidth(){var _a;const lineMetrics=this.getLineMetrics();let maxWidth=0;for(let i=0;i<lineMetrics.length;i++)maxWidth=Math.max(maxWidth,null!==(_a=lineMetrics[i].justifyWidth)&&void 0!==_a?_a:lineMetrics[i].width);return maxWidth}getMaxWidth(){var _a;const lineMetrics=this.getLineMetrics();let maxWidth=0;for(let i=0;i<lineMetrics.length;i++)maxWidth=Math.max(maxWidth,null!==(_a=lineMetrics[i].justifyWidth)&&void 0!==_a?_a:lineMetrics[i].width);return maxWidth}getMinIntrinsicWidth(){const lineMetrics=this.getLineMetrics();let width=0;for(let i=0;i<lineMetrics.length;i++)width=Math.max(width,lineMetrics[i].width);return width}getNumberOfLines(){return this._textLayout.lineMetrics.length}getRectsForPlaceholders(){return[]}getRectsForRange(start,end,hStyle,wStyle){this._textLayout.measureGlyphIfNeeded();let result=[];if(this._textLayout.lineMetrics.forEach((it=>{const range0=[start,end],range1=[it.startIndex,it.endIndex];if(range0[1]>range1[0]&&range1[1]>range0[0]){const intersecRange=[Math.max(range0[0],range1[0]),Math.min(range0[1],range1[1])];let currentLineLeft=-1,currentLineTop=-1,currentLineWidth=0,currentLineHeight=0;for(let index=intersecRange[0];index<intersecRange[1];index++){const glyphInfo=this._textLayout.glyphInfos[index];glyphInfo&&(currentLineLeft<0&&(currentLineLeft=glyphInfo.graphemeLayoutBounds[0]),currentLineTop<0&&(currentLineTop=glyphInfo.graphemeLayoutBounds[1]),currentLineTop=Math.min(currentLineTop,glyphInfo.graphemeLayoutBounds[1]),currentLineWidth=glyphInfo.graphemeLayoutBounds[2]-currentLineLeft,currentLineHeight=Math.max(currentLineHeight,glyphInfo.graphemeLayoutBounds[3]-currentLineTop))}result.push({rect:new Float32Array([currentLineLeft,currentLineTop,currentLineLeft+currentLineWidth,currentLineTop+currentLineHeight]),dir:{value:skia_1.TextDirection.LTR}})}})),0===result.length){const lastSpan=this.spans[this.spans.length-1],lastLine=this._textLayout.lineMetrics[this._textLayout.lineMetrics.length-1];if(end>lastLine.endIndex&&lastSpan instanceof span_1.TextSpan&&lastSpan.originText.endsWith("\n"))return[{rect:new Float32Array([0,lastLine.yOffset,0,lastLine.yOffset+lastLine.height]),dir:{value:skia_1.TextDirection.LTR}}]}return result}getWordBoundary(offset){return{start:offset,end:offset}}getShapedLines(){return[]}layout(width){this.skImageCache&&this.skImageCache.delete(),this.skImageCache=void 0,this._textLayout.layout(width)}unresolvedCodepoints(){return[]}}exports.Paragraph=Paragraph},{"../impl/drawer":4,"../impl/layout":5,"../impl/span":6,"../logger":8,"./skia":3}],2:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ParagraphBuilder=void 0;const span_1=require("../impl/span"),logger_1=require("../logger"),paragraph_1=require("./paragraph"),skia_1=require("./skia");class ParagraphBuilder extends skia_1.SkEmbindObject{static MakeFromFontCollection(originMakeFromFontCollectionMethod,style,fontCollection,embeddingFonts,iconFonts){var _a;const fontFamilies=null===(_a=style.textStyle)||void 0===_a?void 0:_a.fontFamilies;return fontFamilies&&"MiniTex"===fontFamilies[0]?(logger_1.logger.info("use minitex paragraph builder.",fontFamilies),new ParagraphBuilder(style)):fontFamilies&&iconFonts&&iconFonts[fontFamilies[0]]?(logger_1.logger.info("use fontPaths paragraph builder.",fontFamilies),new ParagraphBuilder(style,iconFonts[fontFamilies[0]])):ParagraphBuilder.usingPolyfill?(logger_1.logger.info("usingPolyfill, so use minitex paragraph builder.",fontFamilies),new ParagraphBuilder(style)):fontFamilies&&0===fontFamilies.filter((it=>embeddingFonts.indexOf(it)>=0)).length?(logger_1.logger.info("use minitex paragraph builder.",fontFamilies),new ParagraphBuilder(style)):(logger_1.logger.info("use skia paragraph builder.",fontFamilies),originMakeFromFontCollectionMethod(style,fontCollection))}constructor(style,iconFontData){super(),this.style=style,this.iconFontData=iconFontData,this.isMiniTex=!0,this.spans=[],this.styles=[]}addPlaceholder(width,height,alignment,baseline,offset){}addText(str){logger_1.logger.debug("ParagraphBuilder.addText",str);let mergedStyle={};this.styles.forEach((it=>{Object.assign(mergedStyle,it)}));const span=new span_1.TextSpan(str,mergedStyle);this.spans.push(span)}build(){return new paragraph_1.Paragraph(this.spans,this.style,this.iconFontData)}setWordsUtf8(words){}setWordsUtf16(words){}setGraphemeBreaksUtf8(graphemes){}setGraphemeBreaksUtf16(graphemes){}setLineBreaksUtf8(lineBreaks){}setLineBreaksUtf16(lineBreaks){}getText(){let text="";if(this.spans.forEach((it=>{it instanceof span_1.TextSpan&&(text+=it.originText)})),"object"==typeof window&&window.TextEncoder){const view=(new window.TextEncoder).encode(text);return String.fromCharCode(...Array.from(view))}return text}pop(){logger_1.logger.debug("ParagraphBuilder.pop"),this.styles.pop()}pushStyle(textStyle){logger_1.logger.debug("ParagraphBuilder.pushStyle",textStyle),this.styles.push(textStyle)}pushPaintStyle(textStyle,fg,bg){logger_1.logger.debug("ParagraphBuilder.pushPaintStyle",textStyle,fg,bg),this.styles.push(textStyle)}reset(){logger_1.logger.debug("ParagraphBuilder.reset"),this.spans=[],this.styles=[]}}exports.ParagraphBuilder=ParagraphBuilder,ParagraphBuilder.usingPolyfill=!1},{"../impl/span":6,"../logger":8,"./paragraph":1,"./skia":3}],3:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TextHeightBehavior=exports.DecorationStyle=exports.FontSlant=exports.FontWidth=exports.FontWeight=exports.LineThroughDecoration=exports.OverlineDecoration=exports.UnderlineDecoration=exports.NoDecoration=exports.TextAlign=exports.Affinity=exports.RectWidthStyle=exports.RectHeightStyle=exports.TextDirection=exports.TextBaseline=exports.StrokeJoin=exports.StrokeCap=exports.PlaceholderAlignment=exports.SkEmbindObject=void 0;var PlaceholderAlignment,StrokeCap,StrokeJoin,TextBaseline,TextDirection,RectHeightStyle,RectWidthStyle,Affinity,TextAlign,FontWeight,FontWidth,FontSlant,DecorationStyle,TextHeightBehavior;exports.SkEmbindObject=class{constructor(){this._type="",this._deleted=!1}delete(){this._deleted=!0}deleteLater(){this._deleted=!0}isAliasOf(other){return other._type===this._type}isDeleted(){return this._deleted}},function(PlaceholderAlignment){PlaceholderAlignment.Baseline="Baseline",PlaceholderAlignment.AboveBaseline="AboveBaseline",PlaceholderAlignment.BelowBaseline="BelowBaseline",PlaceholderAlignment.Top="Top",PlaceholderAlignment.Bottom="Bottom",PlaceholderAlignment.Middle="Middle"}(PlaceholderAlignment||(exports.PlaceholderAlignment=PlaceholderAlignment={})),function(StrokeCap){StrokeCap.Butt="Butt",StrokeCap.Round="Round",StrokeCap.Square="Square"}(StrokeCap||(exports.StrokeCap=StrokeCap={})),function(StrokeJoin){StrokeJoin.Bevel="Bevel",StrokeJoin.Miter="Miter",StrokeJoin.Round="Round"}(StrokeJoin||(exports.StrokeJoin=StrokeJoin={})),function(TextBaseline){TextBaseline[TextBaseline.Alphabetic=0]="Alphabetic",TextBaseline[TextBaseline.Ideographic=1]="Ideographic"}(TextBaseline||(exports.TextBaseline=TextBaseline={})),function(TextDirection){TextDirection[TextDirection.RTL=0]="RTL",TextDirection[TextDirection.LTR=1]="LTR"}(TextDirection||(exports.TextDirection=TextDirection={})),function(RectHeightStyle){RectHeightStyle[RectHeightStyle.Tight=0]="Tight",RectHeightStyle[RectHeightStyle.Max=1]="Max",RectHeightStyle[RectHeightStyle.IncludeLineSpacingMiddle=2]="IncludeLineSpacingMiddle",RectHeightStyle[RectHeightStyle.IncludeLineSpacingTop=3]="IncludeLineSpacingTop",RectHeightStyle[RectHeightStyle.IncludeLineSpacingBottom=4]="IncludeLineSpacingBottom",RectHeightStyle[RectHeightStyle.Strut=5]="Strut"}(RectHeightStyle||(exports.RectHeightStyle=RectHeightStyle={})),function(RectWidthStyle){RectWidthStyle[RectWidthStyle.Tight=0]="Tight",RectWidthStyle[RectWidthStyle.Max=1]="Max"}(RectWidthStyle||(exports.RectWidthStyle=RectWidthStyle={})),function(Affinity){Affinity[Affinity.Upstream=0]="Upstream",Affinity[Affinity.Downstream=1]="Downstream"}(Affinity||(exports.Affinity=Affinity={})),function(TextAlign){TextAlign[TextAlign.Left=0]="Left",TextAlign[TextAlign.Right=1]="Right",TextAlign[TextAlign.Center=2]="Center",TextAlign[TextAlign.Justify=3]="Justify",TextAlign[TextAlign.Start=4]="Start",TextAlign[TextAlign.End=5]="End"}(TextAlign||(exports.TextAlign=TextAlign={})),exports.NoDecoration=0,exports.UnderlineDecoration=1,exports.OverlineDecoration=2,exports.LineThroughDecoration=4,function(FontWeight){FontWeight[FontWeight.Invisible=0]="Invisible",FontWeight[FontWeight.Thin=100]="Thin",FontWeight[FontWeight.ExtraLight=200]="ExtraLight",FontWeight[FontWeight.Light=300]="Light",FontWeight[FontWeight.Normal=400]="Normal",FontWeight[FontWeight.Medium=500]="Medium",FontWeight[FontWeight.SemiBold=600]="SemiBold",FontWeight[FontWeight.Bold=700]="Bold",FontWeight[FontWeight.ExtraBold=800]="ExtraBold",FontWeight[FontWeight.Black=900]="Black",FontWeight[FontWeight.ExtraBlack=1e3]="ExtraBlack"}(FontWeight||(exports.FontWeight=FontWeight={})),function(FontWidth){FontWidth[FontWidth.UltraCondensed=0]="UltraCondensed",FontWidth[FontWidth.ExtraCondensed=1]="ExtraCondensed",FontWidth[FontWidth.Condensed=2]="Condensed",FontWidth[FontWidth.SemiCondensed=3]="SemiCondensed",FontWidth[FontWidth.Normal=4]="Normal",FontWidth[FontWidth.SemiExpanded=5]="SemiExpanded",FontWidth[FontWidth.Expanded=6]="Expanded",FontWidth[FontWidth.ExtraExpanded=7]="ExtraExpanded",FontWidth[FontWidth.UltraExpanded=8]="UltraExpanded"}(FontWidth||(exports.FontWidth=FontWidth={})),function(FontSlant){FontSlant[FontSlant.Upright=0]="Upright",FontSlant[FontSlant.Italic=1]="Italic",FontSlant[FontSlant.Oblique=2]="Oblique"}(FontSlant||(exports.FontSlant=FontSlant={})),function(DecorationStyle){DecorationStyle[DecorationStyle.Solid=0]="Solid",DecorationStyle[DecorationStyle.Double=1]="Double",DecorationStyle[DecorationStyle.Dotted=2]="Dotted",DecorationStyle[DecorationStyle.Dashed=3]="Dashed",DecorationStyle[DecorationStyle.Wavy=4]="Wavy"}(DecorationStyle||(exports.DecorationStyle=DecorationStyle={})),function(TextHeightBehavior){TextHeightBehavior[TextHeightBehavior.All=0]="All",TextHeightBehavior[TextHeightBehavior.DisableFirstAscent=1]="DisableFirstAscent",TextHeightBehavior[TextHeightBehavior.DisableLastDescent=2]="DisableLastDescent",TextHeightBehavior[TextHeightBehavior.DisableAll=3]="DisableAll"}(TextHeightBehavior||(exports.TextHeightBehavior=TextHeightBehavior={}))},{}],4:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Drawer=void 0;const skia_1=require("../adapter/skia"),skia_2=require("../adapter/skia"),span_1=require("./span"),util_1=require("../util"),logger_1=require("../logger");class Drawer{constructor(paragraph){this.paragraph=paragraph}initCanvas(){Drawer.sharedRenderCanvas||(Drawer.sharedRenderCanvas=(0,util_1.createCanvas)(Math.min(4e3,1e3*Drawer.pixelRatio),Math.min(4e3,1e3*Drawer.pixelRatio)),Drawer.sharedRenderContext=Drawer.sharedRenderCanvas.getContext("2d"))}draw(){this.initCanvas();const width=(0,util_1.convertToUpwardToPixelRatio)(this.paragraph.getMaxWidth()*Drawer.pixelRatio,Drawer.pixelRatio),height=(0,util_1.convertToUpwardToPixelRatio)(this.paragraph.getHeight()*Drawer.pixelRatio,Drawer.pixelRatio);if(width<=0||height<=0){const context=Drawer.sharedRenderContext;return context.clearRect(0,0,1,1),context.getImageData(0,0,1,1)}const context=Drawer.sharedRenderContext;context.clearRect(0,0,width,height),context.save(),context.scale(Drawer.pixelRatio,Drawer.pixelRatio);let didExceedMaxLines=!1,spanLetterStartIndex=0,linesDrawingRightBounds={};const spans=(0,span_1.spanWithNewline)(this.paragraph.spans);let linesUndrawed={};return this.paragraph.getLineMetrics().forEach((it=>{linesUndrawed[it.lineNumber]=it.endIndex-it.startIndex})),spans.forEach((span=>{var _a,_b,_c,_d,_e,_f,_g;if(!didExceedMaxLines&&span instanceof span_1.TextSpan){if(span instanceof span_1.NewlineSpan)return void spanLetterStartIndex++;let spanUndrawLength=span.charSequence.length,spanLetterEndIndex=spanLetterStartIndex+span.charSequence.length;const lineMetrics=this.paragraph.getLineMetricsOfRange(spanLetterStartIndex,spanLetterEndIndex);for(context.font=span.toCanvasFont();spanUndrawLength>0;){let currentDrawLine,currentDrawText=[];for(let index=0;index<lineMetrics.length;index++){const line=lineMetrics[index];if(linesUndrawed[line.lineNumber]>0){const currentDrawLength=Math.min(linesUndrawed[line.lineNumber],spanUndrawLength);currentDrawText=span.charSequence.slice(span.charSequence.length-spanUndrawLength,span.charSequence.length-spanUndrawLength+currentDrawLength),spanUndrawLength-=currentDrawLength,linesUndrawed[line.lineNumber]-=currentDrawLength,currentDrawLine=line;break}}if(!currentDrawLine)break;if(this.paragraph.didExceedMaxLines()&&this.paragraph.paragraphStyle.maxLines===currentDrawLine.lineNumber+1&&linesUndrawed[currentDrawLine.lineNumber]<=0){const trimLength=(0,util_1.isSquareCharacter)(currentDrawText[currentDrawText.length-1])?1:3;currentDrawText=currentDrawText.slice(0,currentDrawText.length-trimLength),currentDrawText.push(...Array.from(null!==(_a=this.paragraph.paragraphStyle.ellipsis)&&void 0!==_a?_a:"...")),didExceedMaxLines=!0}let drawingLeft=(()=>{var _a,_b;if(void 0===linesDrawingRightBounds[currentDrawLine.lineNumber]){const textAlign=null===(_a=this.paragraph.paragraphStyle.textAlign)||void 0===_a?void 0:_a.value,textDirection=null===(_b=this.paragraph.paragraphStyle.textDirection)||void 0===_b?void 0:_b.value;textAlign===skia_1.TextAlign.Center?linesDrawingRightBounds[currentDrawLine.lineNumber]=(this.paragraph.getMaxWidth()-currentDrawLine.width)/2:textAlign===skia_1.TextAlign.Right||textAlign===skia_1.TextAlign.End&&textDirection!==skia_1.TextDirection.RTL||textAlign===skia_1.TextAlign.Start&&textDirection===skia_1.TextDirection.RTL?linesDrawingRightBounds[currentDrawLine.lineNumber]=this.paragraph.getMaxWidth()-currentDrawLine.width:linesDrawingRightBounds[currentDrawLine.lineNumber]=0}return linesDrawingRightBounds[currentDrawLine.lineNumber]})();const drawingRight=drawingLeft+(()=>{if(1===currentDrawText.length&&"\n"===currentDrawText[0])return 0;const extraLetterSpacing=span.hasLetterSpacing()?currentDrawText.length*span.style.letterSpacing:0;return context.measureText(currentDrawText.join("")).width+extraLetterSpacing})();linesDrawingRightBounds[currentDrawLine.lineNumber]=drawingRight;const textTop=currentDrawLine.baseline*currentDrawLine.heightMultiplier-span.letterBaseline,textBaseline=currentDrawLine.baseline*currentDrawLine.heightMultiplier,textHeight=span.letterHeight;if(this.drawBackground(span,context,{currentDrawLine:currentDrawLine,drawingLeft:drawingLeft,drawingRight:drawingRight,textBaseline:textBaseline,textTop:textTop,textHeight:textHeight}),context.save(),span.style.shadows&&span.style.shadows.length>0&&(context.shadowColor=span.style.shadows[0].color?(0,util_1.colorToHex)(span.style.shadows[0].color):"transparent",context.shadowOffsetX=null!==(_c=null===(_b=span.style.shadows[0].offset)||void 0===_b?void 0:_b[0])&&void 0!==_c?_c:0,context.shadowOffsetY=null!==(_e=null===(_d=span.style.shadows[0].offset)||void 0===_d?void 0:_d[1])&&void 0!==_e?_e:0,context.shadowBlur=null!==(_f=span.style.shadows[0].blurRadius)&&void 0!==_f?_f:0),context.fillStyle=span.toTextFillStyle(),this.paragraph.iconFontData)for(let index=0;index<currentDrawText.length;index++){const currentDrawLetter=currentDrawText[index],letterWidth=null!==(_g=span.style.fontSize)&&void 0!==_g?_g:14;this.fillIcon(context,currentDrawLetter,letterWidth,drawingLeft,textBaseline+currentDrawLine.yOffset),drawingLeft+=letterWidth}else if(span.hasLetterSpacing()||span.hasWordSpacing()||span.hasJustifySpacing(this.paragraph.paragraphStyle)){const letterSpacing=span.hasLetterSpacing()?span.style.letterSpacing:0,justifySpacing=span.hasJustifySpacing(this.paragraph.paragraphStyle)&&!currentDrawLine.isLastLine?this.computeJustifySpacing(currentDrawText,currentDrawLine.width,currentDrawLine.justifyWidth):0;for(let index=0;index<currentDrawText.length;index++){const currentDrawLetter=currentDrawText[index];context.fillText(currentDrawLetter,drawingLeft,textBaseline+currentDrawLine.yOffset);const letterWidth=context.measureText(currentDrawLetter).width;span.hasWordSpacing()&&" "===currentDrawLetter&&(0,util_1.isEnglishWord)(currentDrawText[index-1])?drawingLeft+=span.style.wordSpacing:drawingLeft+=letterWidth+letterSpacing,(0,util_1.isEnglishWord)(currentDrawText[index])||(drawingLeft+=justifySpacing)}}else context.fillText(currentDrawText.join(""),drawingLeft,textBaseline+currentDrawLine.yOffset);if(context.restore(),logger_1.logger.debug("Drawer.draw.fillText",currentDrawText,drawingLeft,textBaseline+currentDrawLine.yOffset),this.drawDecoration(span,context,{currentDrawLine:currentDrawLine,drawingLeft:drawingLeft,drawingRight:drawingRight,textBaseline:textBaseline,textTop:textTop,textHeight:textHeight}),didExceedMaxLines)break}spanLetterStartIndex=spanLetterEndIndex}})),context.restore(),context.getImageData(0,0,width,height)}fillIcon(context,text,fontSize,x,y){var _a;const svgPath=null===(_a=this.paragraph.iconFontMap)||void 0===_a?void 0:_a[text];if(!svgPath)return void console.log("fill icon not found",text.charCodeAt(0).toString(16));const pathCommands=svgPath.match(/[A-Za-z]\d+([\.\d,]+)?/g);if(!pathCommands)return;context.save(),context.beginPath();let lastControlPoint=null;pathCommands.forEach((command=>{const type=command.charAt(0),args=command.substring(1).split(",").map(parseFloat).map(((it,index)=>{let value=it;return index%2==1&&(value=150-value+150),value*(fontSize/300)}));"M"===type?context.moveTo(args[0],args[1]):"L"===type?context.lineTo(args[0],args[1]):"C"===type?(context.bezierCurveTo(args[0],args[1],args[2],args[3],args[4],args[5]),lastControlPoint=[args[2],args[3]]):"Q"===type?(context.quadraticCurveTo(args[0],args[1],args[2],args[3]),lastControlPoint=[args[0],args[1]]):"A"===type||"Z"===type&&context.closePath()})),context.fill(),context.restore()}computeJustifySpacing(text,lineWidth,justifyWidth){let count=0;for(let index=0;index<text.length;index++)(0,util_1.isEnglishWord)(text[index])||count++;return(justifyWidth-lineWidth)/(count-1)}drawBackground(span,context,options){if(span.style.backgroundColor){const{currentDrawLine:currentDrawLine,drawingLeft:drawingLeft,drawingRight:drawingRight,textTop:textTop,textHeight:textHeight}=options;context.fillStyle=span.toBackgroundFillStyle(),context.fillRect(drawingLeft,textTop+currentDrawLine.yOffset,drawingRight-drawingLeft,textHeight)}}drawDecoration(span,context,options){var _a,_b,_c;const{currentDrawLine:currentDrawLine,drawingLeft:drawingLeft,drawingRight:drawingRight,textBaseline:textBaseline,textTop:textTop,textHeight:textHeight}=options;if(span.style.decoration){context.save(),context.strokeStyle=span.toDecorationStrokeStyle(),context.lineWidth=(null!==(_a=span.style.decorationThickness)&&void 0!==_a?_a:1)*Math.max(1,(null!==(_b=span.style.fontSize)&&void 0!==_b?_b:12)/14);const decorationStyle=null===(_c=span.style.decorationStyle)||void 0===_c?void 0:_c.value;switch(decorationStyle){case skia_2.DecorationStyle.Dashed:context.lineCap="butt",context.setLineDash([4,2]);break;case skia_2.DecorationStyle.Dotted:context.lineCap="butt",context.setLineDash([2,2])}span.style.decoration&skia_2.UnderlineDecoration&&(context.beginPath(),context.moveTo(drawingLeft,currentDrawLine.yOffset+textBaseline+1),context.lineTo(drawingRight,currentDrawLine.yOffset+textBaseline+1),context.stroke(),decorationStyle===skia_2.DecorationStyle.Double&&(context.beginPath(),context.moveTo(drawingLeft,currentDrawLine.yOffset+textBaseline+3),context.lineTo(drawingRight,currentDrawLine.yOffset+textBaseline+3),context.stroke())),span.style.decoration&skia_2.LineThroughDecoration&&(context.beginPath(),context.moveTo(drawingLeft,currentDrawLine.yOffset+textTop+textHeight/2),context.lineTo(drawingRight,currentDrawLine.yOffset+textTop+textHeight/2),decorationStyle===skia_2.DecorationStyle.Double&&(context.moveTo(drawingLeft,currentDrawLine.yOffset+textTop+textHeight/2+2),context.lineTo(drawingRight,currentDrawLine.yOffset+textTop+textHeight/2+2)),context.stroke()),span.style.decoration&skia_2.OverlineDecoration&&(context.beginPath(),context.moveTo(drawingLeft,currentDrawLine.yOffset+textTop),context.lineTo(drawingRight,currentDrawLine.yOffset+textTop),decorationStyle===skia_2.DecorationStyle.Double&&(context.moveTo(drawingLeft,currentDrawLine.yOffset+textTop+2),context.lineTo(drawingRight,currentDrawLine.yOffset+textTop+2)),context.stroke()),context.restore()}}}exports.Drawer=Drawer,Drawer.pixelRatio=1},{"../adapter/skia":3,"../logger":8,"../util":11,"./span":6}],5:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TextLayout=void 0;const skia_1=require("../adapter/skia"),skia_2=require("../adapter/skia"),logger_1=require("../logger"),util_1=require("../util"),span_1=require("./span");class LetterMeasurer{static measureLetters(span,context){let advances=[0],curPosWidth=0;for(let index=0;index<span.charSequence.length;index++){const letter=span.charSequence[index];let wordWidth=(()=>(0,util_1.isSquareCharacter)(letter)?this.measureSquareCharacter(context):this.measureNormalLetter(letter,context))();span.hasWordSpacing()&&" "===letter&&(0,util_1.isEnglishWord)(span.charSequence[index-1])?wordWidth=span.style.wordSpacing:span.hasLetterSpacing()&&(wordWidth+=span.style.letterSpacing),curPosWidth+=wordWidth,advances.push(curPosWidth)}return{advances:advances}}static measureNormalLetter(letter,context){var _a;const width=null!==(_a=this.widthFromCache(context,letter))&&void 0!==_a?_a:context.measureText(letter).width;return this.setWidthToCache(context,letter,width),width}static measureSquareCharacter(context){var _a;const width=null!==(_a=this.widthFromCache(context,"测"))&&void 0!==_a?_a:context.measureText("测").width;return this.setWidthToCache(context,"测",width),width}static widthFromCache(context,word){var _a;const cacheKey=context.font+"_"+word;return null===(_a=this.measureLRUCache[cacheKey])||void 0===_a?void 0:_a.width}static setWidthToCache(context,word,width){const cacheKey=context.font+"_"+word;this.measureLRUCache[cacheKey]?this.measureLRUCache[cacheKey].useCount++:(this.measureLRUCache[cacheKey]={useCount:1,width:width},Object.keys(this.measureLRUCache).length>this.LRUConfig.maxCacheCount&&this.clearCache())}static clearCache(){Object.keys(this.measureLRUCache).sort(((a,b)=>this.measureLRUCache[a].useCount>this.measureLRUCache[b].useCount?1:-1)).slice(0,this.LRUConfig.maxCacheCount-this.LRUConfig.minCacheCount).forEach((it=>{delete this.measureLRUCache[it]}))}}LetterMeasurer.LRUConfig={maxCacheCount:1e3,minCacheCount:200},LetterMeasurer.measureLRUCache={};class TextLayout{constructor(paragraph){this.paragraph=paragraph,this.glyphInfos=[],this.lineMetrics=[],this.didExceedMaxLines=!1,this.previousLayoutWidth=0}initCanvas(){TextLayout.sharedLayoutCanvas||(TextLayout.sharedLayoutCanvas=(0,util_1.createCanvas)(1,1),TextLayout.sharedLayoutContext=TextLayout.sharedLayoutCanvas.getContext("2d"))}measureGlyphIfNeeded(){Object.keys(this.glyphInfos).length<=0&&this.layout(-1,!0)}layout(layoutWidth,forceCalcGlyphInfos=!1){var _a,_b;let layoutStartTime;logger_1.logger.profileMode&&(layoutStartTime=(new Date).getTime()),layoutWidth<0&&(layoutWidth=this.previousLayoutWidth),this.previousLayoutWidth=layoutWidth,this.initCanvas(),this.glyphInfos=[];let currentLineMetrics={startIndex:0,endIndex:0,endExcludingWhitespaces:0,endIncludingNewline:0,isHardBreak:!1,ascent:0,descent:0,height:0,heightMultiplier:Math.max(1,(null!==(_a=this.paragraph.paragraphStyle.heightMultiplier)&&void 0!==_a?_a:1.5)/1.5),width:0,justifyWidth:(null===(_b=this.paragraph.paragraphStyle.textAlign)||void 0===_b?void 0:_b.value)===skia_1.TextAlign.Justify?layoutWidth:void 0,left:0,yOffset:0,baseline:0,lineNumber:0,isLastLine:!1},lineMetrics=[];if((0,span_1.spanWithNewline)(this.paragraph.spans).forEach((span=>{var _a,_b,_c,_d;if(span instanceof span_1.TextSpan){TextLayout.sharedLayoutContext.font=span.toCanvasFont();const matrics=TextLayout.sharedLayoutContext.measureText(span.originText);let iconFontWidth=0;if(this.paragraph.iconFontData){const fontSize=null!==(_a=span.style.fontSize)&&void 0!==_a?_a:14;iconFontWidth=fontSize,currentLineMetrics.ascent=fontSize,currentLineMetrics.descent=0,span.letterBaseline=fontSize,span.letterHeight=fontSize}else{const mHeight=TextLayout.sharedLayoutContext.measureText("M").width;currentLineMetrics.ascent=1.15*mHeight,currentLineMetrics.descent=.35*mHeight,span.letterBaseline=1.15*mHeight,span.letterHeight=1.15*mHeight+.35*mHeight}if(span.style.heightMultiplier&&span.style.heightMultiplier>0&&(currentLineMetrics.heightMultiplier=Math.max(currentLineMetrics.heightMultiplier,span.style.heightMultiplier/1.5)),currentLineMetrics.height=Math.max(currentLineMetrics.height,currentLineMetrics.ascent+currentLineMetrics.descent),currentLineMetrics.baseline=Math.max(currentLineMetrics.baseline,currentLineMetrics.ascent),this.paragraph.iconFontData){const textWidth=span.charSequence.length*iconFontWidth;currentLineMetrics.endIndex+=span.charSequence.length,currentLineMetrics.width+=textWidth}else if(currentLineMetrics.width+matrics.width<layoutWidth&&!span.hasLetterSpacing()&&!span.hasWordSpacing()&&!forceCalcGlyphInfos)if(span instanceof span_1.NewlineSpan){const newLineMatrics=this.createNewLine(currentLineMetrics);lineMetrics.push(currentLineMetrics),currentLineMetrics=newLineMatrics}else currentLineMetrics.endIndex+=span.charSequence.length,currentLineMetrics.width+=matrics.width,(null===(_c=null===(_b=span.style.fontStyle)||void 0===_b?void 0:_b.slant)||void 0===_c?void 0:_c.value)===skia_2.FontSlant.Italic&&(currentLineMetrics.width+=2);else{let advances=LetterMeasurer.measureLetters(span,TextLayout.sharedLayoutContext).advances;span instanceof span_1.NewlineSpan&&(advances=[0,0]),Math.abs(advances[advances.length-1]-layoutWidth)<10&&layoutWidth===this.previousLayoutWidth&&(layoutWidth=advances[advances.length-1]);let currentWord="",currentWordWidth=0,currentWordLength=0,nextWordWidth=0,canBreak=!0,forceBreak=!1;for(let index=0;index<span.charSequence.length;index++){currentWord+=span.charSequence[index];let currentLetterLeft=currentWordWidth,spanEnded=void 0===span.charSequence[index+1],nextWord=null!==(_d=currentWord+span.charSequence[index+1])&&void 0!==_d?_d:"";void 0===advances[index+1]?currentWordWidth+=advances[index]-advances[index-1]:currentWordWidth+=advances[index+1]-advances[index],nextWordWidth=void 0===advances[index+2]?currentWordWidth:currentWordWidth+(advances[index+2]-advances[index+1]),currentWordLength+=1,canBreak=!0,forceBreak=!1,spanEnded?canBreak=!0:(0,util_1.isEnglishWord)(nextWord)&&(canBreak=!1),(0,util_1.isPunctuation)(nextWord[nextWord.length-1])&¤tLineMetrics.width+nextWordWidth>=layoutWidth&&(forceBreak=!0),span instanceof span_1.NewlineSpan&&(forceBreak=!0);const currentGlyphLeft=currentLineMetrics.width+currentLetterLeft,currentGlyphTop=currentLineMetrics.yOffset,currentGlyphWidth=void 0===advances[index+1]?advances[index]-advances[index-1]:advances[index+1]-advances[index],currentGlyphHeight=currentLineMetrics.height,currentGlyphInfo={graphemeLayoutBounds:(0,util_1.valueOfRectXYWH)(currentGlyphLeft,currentGlyphTop,currentGlyphWidth,currentGlyphHeight),graphemeClusterTextRange:{start:index,end:index+1},dir:{value:skia_1.TextDirection.LTR},isEllipsis:!1};if(this.glyphInfos.push(currentGlyphInfo),canBreak)if(!forceBreak&¤tLineMetrics.width+currentWordWidth<=layoutWidth)currentLineMetrics.width+=currentWordWidth,currentLineMetrics.endIndex+=currentWordLength,currentWord="",currentWordWidth=0,currentWordLength=0,canBreak=!0;else if(forceBreak||currentLineMetrics.width+currentWordWidth>layoutWidth){const newLineMatrics=this.createNewLine(currentLineMetrics);lineMetrics.push(currentLineMetrics),currentLineMetrics=newLineMatrics,currentLineMetrics.width+=currentWordWidth,currentLineMetrics.endIndex+=currentWordLength,currentWord="",currentWordWidth=0,currentWordLength=0,canBreak=!0}}currentWord.length>0&&(currentLineMetrics.width+=currentWordWidth,currentLineMetrics.endIndex+=currentWordLength)}}})),lineMetrics.push(currentLineMetrics),this.paragraph.paragraphStyle.maxLines&&lineMetrics.length>this.paragraph.paragraphStyle.maxLines?(this.didExceedMaxLines=!0,lineMetrics=lineMetrics.slice(0,this.paragraph.paragraphStyle.maxLines)):this.didExceedMaxLines=!1,logger_1.logger.debug("TextLayout.layout.lineMetrics",lineMetrics),logger_1.logger.profileMode){const layoutCostTime=(new Date).getTime()-layoutStartTime;logger_1.logger.profile("Layout cost",layoutCostTime)}lineMetrics[lineMetrics.length-1].isLastLine=!0,this.lineMetrics=lineMetrics}createNewLine(currentLineMetrics){var _a;return{startIndex:currentLineMetrics.endIndex,endIndex:currentLineMetrics.endIndex,endExcludingWhitespaces:0,endIncludingNewline:0,isHardBreak:!1,ascent:currentLineMetrics.ascent,descent:currentLineMetrics.descent,height:currentLineMetrics.height,heightMultiplier:Math.max(1,(null!==(_a=this.paragraph.paragraphStyle.heightMultiplier)&&void 0!==_a?_a:1.5)/1.5),width:0,justifyWidth:currentLineMetrics.justifyWidth,left:0,yOffset:currentLineMetrics.yOffset+currentLineMetrics.height*currentLineMetrics.heightMultiplier+.15*currentLineMetrics.height,baseline:currentLineMetrics.baseline,lineNumber:currentLineMetrics.lineNumber+1,isLastLine:!1}}}exports.TextLayout=TextLayout},{"../adapter/skia":3,"../logger":8,"../util":11,"./span":6}],6:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.spanWithNewline=exports.NewlineSpan=exports.TextSpan=exports.Span=void 0;const skia_1=require("../adapter/skia"),util_1=require("../util");class Span{constructor(){this.letterBaseline=0,this.letterHeight=0,this.lettersBounding=[]}}exports.Span=Span;class TextSpan extends Span{constructor(text,style){super(),this.text=text,this.style=style,this.charSequence=Array.from(text),this.originText=text}hasLetterSpacing(){return void 0!==this.style.letterSpacing&&this.style.letterSpacing>1}hasWordSpacing(){return void 0!==this.style.wordSpacing&&this.style.wordSpacing>1}hasJustifySpacing(paragraphStyle){var _a;return(null===(_a=paragraphStyle.textAlign)||void 0===_a?void 0:_a.value)===skia_1.TextAlign.Justify}toBackgroundFillStyle(){return this.style.backgroundColor?(0,util_1.colorToHex)(this.style.backgroundColor):"#000000"}toTextFillStyle(){return this.style.color?(0,util_1.colorToHex)(this.style.color):"#000000"}toDecorationStrokeStyle(){return this.style.decorationColor?(0,util_1.colorToHex)(this.style.decorationColor):"#000000"}toCanvasFont(){var _a,_b,_c,_d;let font=`${this.style.fontSize}px system-ui, Roboto`;const fontWeight=null===(_b=null===(_a=this.style.fontStyle)||void 0===_a?void 0:_a.weight)||void 0===_b?void 0:_b.value;fontWeight&&400!==fontWeight&&(font=fontWeight>=900?"900 "+font:fontWeight.toFixed(0)+" "+font);const slant=null===(_d=null===(_c=this.style.fontStyle)||void 0===_c?void 0:_c.slant)||void 0===_d?void 0:_d.value;if(slant)switch(slant){case skia_1.FontSlant.Italic:font="italic "+font;break;case skia_1.FontSlant.Oblique:font="oblique "+font}return font}}exports.TextSpan=TextSpan;class NewlineSpan extends TextSpan{constructor(){super("\n",{})}}exports.NewlineSpan=NewlineSpan;exports.spanWithNewline=spans=>{let result=[];return spans.forEach((span=>{if(span instanceof TextSpan&&span.originText.indexOf("\n")>=0){const components=span.originText.split("\n");for(let index=0;index<components.length;index++){const component=components[index];index>0&&result.push(new NewlineSpan),result.push(new TextSpan(component,span.style))}}else result.push(span)})),result}},{"../adapter/skia":3,"../util":11}],7:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MiniTex=void 0;const drawer_1=require("./impl/drawer"),paragraph_1=require("./adapter/paragraph"),paragraph_builder_1=require("./adapter/paragraph_builder"),logger_1=require("./logger"),polyfill_1=require("./polyfill");exports.MiniTex=class{static install(canvasKit,pixelRatio,embeddingFonts,iconFonts){void 0===canvasKit.ParagraphBuilder&&((0,polyfill_1.installPolyfill)(canvasKit),paragraph_builder_1.ParagraphBuilder.usingPolyfill=!0),logger_1.logger.setLogLevel(logger_1.LogLevel.ERROR),drawer_1.Drawer.pixelRatio=pixelRatio;const originMakeFromFontCollectionMethod=canvasKit.ParagraphBuilder.MakeFromFontCollection;canvasKit.ParagraphBuilder.MakeFromFontCollection=function(style,fontCollection){return paragraph_builder_1.ParagraphBuilder.MakeFromFontCollection(originMakeFromFontCollectionMethod,style,fontCollection,embeddingFonts,iconFonts)};const originDrawParagraphMethod=canvasKit.Canvas.prototype.drawParagraph;canvasKit.Canvas.prototype.drawParagraph=function(paragraph,dx,dy){!0===paragraph.isMiniTex?(0,paragraph_1.drawParagraph)(canvasKit,this,paragraph,dx,dy):originDrawParagraphMethod.apply(this,[paragraph,dx,dy])}}}},{"./adapter/paragraph":1,"./adapter/paragraph_builder":2,"./impl/drawer":4,"./logger":8,"./polyfill":9}],8:[function(require,module,exports){"use strict";var LogLevel;Object.defineProperty(exports,"__esModule",{value:!0}),exports.logger=exports.Logger=exports.LogLevel=void 0,function(LogLevel){LogLevel[LogLevel.DEBUG=0]="DEBUG",LogLevel[LogLevel.INFO=1]="INFO",LogLevel[LogLevel.WARN=2]="WARN",LogLevel[LogLevel.ERROR=3]="ERROR"}(LogLevel||(exports.LogLevel=LogLevel={}));class Logger{constructor(logLevel=LogLevel.ERROR){this.profileMode=!1,this.logLevel=logLevel}setLogLevel(logLevel=LogLevel.DEBUG){this.logLevel=logLevel}log(level,...args){if(level>=this.logLevel){const message=1===args.length?args[0]:args;console.log(`[${LogLevel[level]}]`,...message)}}debug(...args){this.log(LogLevel.DEBUG,...args)}info(...args){this.log(LogLevel.INFO,...args)}warn(...args){this.log(LogLevel.WARN,...args)}error(...args){this.log(LogLevel.ERROR,...args)}profile(...args){this.profileMode&&console.info("[PROFILE]",...args)}}exports.Logger=Logger,exports.logger=new Logger(LogLevel.ERROR)},{}],9:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.installPolyfill=void 0;const skia_1=require("./adapter/skia"),polyfill_types_1=require("./polyfill.types");exports.installPolyfill=canvasKit=>{canvasKit.ParagraphBuilder=new _ParagraphBuilderFactory,canvasKit.FontCollection=new _FontCollectionFactory,canvasKit.FontMgr=new _FontMgrFactory,canvasKit.Typeface=new _TypefaceFactory,canvasKit.TypefaceFontProvider=new _TypefaceFontProviderFactory,canvasKit.Font=_Font,canvasKit.ParagraphStyle=properties=>new _ParagraphStyle(properties),canvasKit.TextStyle=properties=>new _TextStyle(properties),canvasKit.TextAlign=new polyfill_types_1.TextAlignEnumValues,canvasKit.TextDirection=new polyfill_types_1.TextDirectionEnumValues,canvasKit.TextBaseline=new polyfill_types_1.TextBaselineEnumValues,canvasKit.RectHeightStyle=new polyfill_types_1.RectHeightStyleEnumValues,canvasKit.RectWidthStyle=new polyfill_types_1.RectWidthStyleEnumValues,canvasKit.Affinity=new polyfill_types_1.AffinityEnumValues,canvasKit.FontWeight=new polyfill_types_1.FontWeightEnumValues,canvasKit.FontWidth=new polyfill_types_1.FontWidthEnumValues,canvasKit.FontSlant=new polyfill_types_1.FontSlantEnumValues,canvasKit.DecorationStyle=new polyfill_types_1.DecorationStyleEnumValues,canvasKit.TextHeightBehavior=new polyfill_types_1.TextHeightBehaviorEnumValues,canvasKit.NoDecoration=0,canvasKit.UnderlineDecoration=1,canvasKit.OverlineDecoration=2,canvasKit.LineThroughDecoration=3};class _ParagraphBuilderFactory{Make(style,fontManager){return this.MakeFromFontCollection(style,{})}MakeFromFontCollection(style,fontCollection){throw new Error("MakeFromFontCollection not implemented.")}RequiresClientICU(){return!1}}class _ParagraphStyle extends skia_1.SkEmbindObject{constructor(properties){super(),Object.assign(this,properties)}}class _TextStyle extends skia_1.SkEmbindObject{constructor(properties){super(),Object.assign(this,properties)}}class _FontCollection extends skia_1.SkEmbindObject{setDefaultFontManager(fontManager){}enableFontFallback(){}}class _FontCollectionFactory{Make(){return new _FontCollection}}class _FontMgr extends skia_1.SkEmbindObject{countFamilies(){return 0}getFamilyName(index){return""}}class _FontMgrFactory{FromData(...buffers){return new _FontMgr}}class _TypefaceFactory{GetDefault(){return new _Typeface}MakeTypefaceFromData(fontData){return new _Typeface}MakeFreeTypeFaceFromData(fontData){return new _Typeface}}class _TypefaceFontProvider extends skia_1.SkEmbindObject{registerFont(bytes,family){}countFamilies(){return 0}getFamilyName(index){return""}}class _TypefaceFontProviderFactory{Make(){return new _TypefaceFontProvider}}class _Typeface extends skia_1.SkEmbindObject{getGlyphIDs(str,numCodePoints,output){return new Uint16Array([])}}class _Font extends skia_1.SkEmbindObject{constructor(face,size,scaleX,skewX){super()}getMetrics(){return{ascent:0,descent:0,leading:0}}getGlyphBounds(glyphs,paint,output){return new Float32Array([0,0,0,0])}getGlyphIDs(str,numCodePoints,output){return new Uint16Array([])}getGlyphWidths(glyphs,paint,output){return new Float32Array([])}getGlyphIntercepts(glyphs,positions,top,bottom){return new Float32Array([])}getScaleX(){return 1}getSize(){return 0}getSkewX(){return 1}isEmbolden(){return!1}getTypeface(){return new _Typeface}setEdging(edging){}setEmbeddedBitmaps(embeddedBitmaps){}setHinting(hinting){}setLinearMetrics(linearMetrics){}setScaleX(sx){}setSize(points){}setSkewX(sx){}setEmbolden(embolden){}setSubpixel(subpixel){}setTypeface(face){}}},{"./adapter/skia":3,"./polyfill.types":10}],10:[function(require,module,exports){"use strict";var FontEdging,FontHinting;Object.defineProperty(exports,"__esModule",{value:!0}),exports.TextHeightBehaviorEnumValues=exports.DecorationStyleEnumValues=exports.FontSlantEnumValues=exports.FontWidthEnumValues=exports.FontWeightEnumValues=exports.AffinityEnumValues=exports.RectWidthStyleEnumValues=exports.RectHeightStyleEnumValues=exports.TextBaselineEnumValues=exports.TextDirectionEnumValues=exports.TextAlignEnumValues=exports.FontHinting=exports.FontEdging=void 0,function(FontEdging){FontEdging[FontEdging.Alias=0]="Alias",FontEdging[FontEdging.AntiAlias=1]="AntiAlias",FontEdging[FontEdging.SubpixelAntiAlias=2]="SubpixelAntiAlias"}(FontEdging||(exports.FontEdging=FontEdging={})),function(FontHinting){FontHinting[FontHinting.None=0]="None",FontHinting[FontHinting.Slight=1]="Slight",FontHinting[FontHinting.Normal=2]="Normal",FontHinting[FontHinting.Full=3]="Full"}(FontHinting||(exports.FontHinting=FontHinting={}));exports.TextAlignEnumValues=class{constructor(){this.Left={value:0},this.Right={value:1},this.Center={value:2},this.Justify={value:3},this.Start={value:4},this.End={value:5}}};exports.TextDirectionEnumValues=class{constructor(){this.RTL={value:0},this.LTR={value:1}}};exports.TextBaselineEnumValues=class{constructor(){this.Alphabetic={value:0},this.Ideographic={value:1}}};exports.RectHeightStyleEnumValues=class{constructor(){this.Tight={value:0},this.Max={value:1},this.IncludeLineSpacingMiddle={value:2},this.IncludeLineSpacingTop={value:3},this.IncludeLineSpacingBottom={value:4},this.Strut={value:5}}};exports.RectWidthStyleEnumValues=class{constructor(){this.Tight={value:0},this.Max={value:1}}};exports.AffinityEnumValues=class{constructor(){this.Upstream={value:0},this.Downstream={value:1}}};exports.FontWeightEnumValues=class{constructor(){this.Invisible={value:0},this.Thin={value:100},this.ExtraLight={value:200},this.Light={value:300},this.Normal={value:400},this.Medium={value:500},this.SemiBold={value:600},this.Bold={value:700},this.ExtraBold={value:800},this.Black={value:900},this.ExtraBlack={value:1e3}}};exports.FontWidthEnumValues=class{constructor(){this.UltraCondensed={value:0},this.ExtraCondensed={value:1},this.Condensed={value:2},this.SemiCondensed={value:3},this.Normal={value:4},this.SemiExpanded={value:5},this.Expanded={value:6},this.ExtraExpanded={value:7},this.UltraExpanded={value:8}}};exports.FontSlantEnumValues=class{constructor(){this.Upright={value:0},this.Italic={value:1},this.Oblique={value:2}}};exports.DecorationStyleEnumValues=class{constructor(){this.Solid={value:0},this.Double={value:1},this.Dotted={value:2},this.Dashed={value:3},this.Wavy={value:4}}};exports.TextHeightBehaviorEnumValues=class{constructor(){this.All={value:0},this.DisableFirstAscent={value:1},this.DisableLastDescent={value:2},this.DisableAll={value:3}}}},{}],11:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createCanvas=exports.convertToUpwardToPixelRatio=exports.isPunctuation=exports.isSquareCharacter=exports.isEnglishWord=exports.valueOfRectXYWH=exports.valueOfRGBAInt=exports.colorToHex=void 0;exports.colorToHex=rgbaColor=>{const r=Math.round(255*rgbaColor[0]).toString(16),g=Math.round(255*rgbaColor[1]).toString(16),b=Math.round(255*rgbaColor[2]).toString(16),a=Math.round(255*rgbaColor[3]).toString(16),padHex=hex=>1===hex.length?"0"+hex:hex;return"#"+padHex(r)+padHex(g)+padHex(b)+padHex(a)};exports.valueOfRGBAInt=(r,g,b,a)=>Float32Array.from([r,g,b,a]);exports.valueOfRectXYWH=(x,y,w,h)=>Float32Array.from([x,y,x+w,y+h]),exports.isEnglishWord=function(str){return/^[A-Za-z,.]+$/.test(str)},exports.isSquareCharacter=function(str){return/[\u4e00-\u9fa5]/.test(str)};const mapOfPunctuation={"!":1,"?":1,"。":1,",":1,"、":1,"“":1,"”":1,"‘":1,"’":1,";":1,":":1,"【":1,"】":1,"『":1,"』":1,"(":1,")":1,"《":1,"》":1,"〈":1,"〉":1,"〔":1,"〕":1,"[":1,"]":1,"{":1,"}":1,"〖":1,"〗":1,"〘":1,"〙":1,"〚":1,"〛":1,"〝":1,"〞":1,"〟":1,"﹏":1,"…":1,"—":1,"~":1,"·":1,"•":1,",":1,".":1};exports.isPunctuation=function(char){return 1===mapOfPunctuation[char]},exports.convertToUpwardToPixelRatio=function(number,pixelRatio){const upwardInt=Math.ceil(number),remainder=upwardInt%pixelRatio;return 0===remainder?upwardInt:upwardInt+(pixelRatio-remainder)},exports.createCanvas=function(width,height){if("object"==typeof wx&&"function"==typeof wx.createOffscreenCanvas)return wx.createOffscreenCanvas({type:"2d",width:width,height:height});if("object"==typeof window){const canvas=document.createElement("canvas");return canvas.width=width,canvas.height=height,canvas}throw"can not create canvas"}},{}]},{},[7])(7)}));