New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pixi-multistyle-text

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pixi-multistyle-text - npm Package Compare versions

Comparing version 0.8.0 to 0.9.0

15

CHANGELOG.md

@@ -1,5 +0,18 @@

# Change Log
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [0.9.0](https://github.com/tleunen/pixi-multistyle-text/compare/v0.8.0...v0.9.0) (2020-01-24)
### ⚠ BREAKING CHANGES
* The support for Pixi v4 has been dropped
Co-authored-by: Romain <benzen@hotmail.fr>
### Features
* Support PIXI v5 ([#88](https://github.com/tleunen/pixi-multistyle-text/issues/88)) ([eee5534](https://github.com/tleunen/pixi-multistyle-text/commit/eee5534b268b2c4ad6d2cb4dba8fb61ba7f9d22f))
<a name="0.8.0"></a>

@@ -6,0 +19,0 @@ # [0.8.0](https://github.com/tleunen/pixi-multistyle-text/compare/v0.7.0...v0.8.0) (2019-11-12)

/// <reference types="pixi.js" />
export interface ExtendedTextStyle extends PIXI.TextStyleOptions {
interface TextStyle {
align?: string;
breakWords?: boolean;
dropShadow?: boolean;
dropShadowAlpha?: number;
dropShadowAngle?: number;
dropShadowBlur?: number;
dropShadowColor?: string | number;
dropShadowDistance?: number;
fill?: string | string[] | number | number[] | CanvasGradient | CanvasPattern;
fillGradientType?: number;
fillGradientStops?: number[];
fontFamily?: string | string[];
fontSize?: number | string;
fontStyle?: string;
fontVariant?: string;
fontWeight?: string;
leading?: number;
letterSpacing?: number;
lineHeight?: number;
lineJoin?: string;
miterLimit?: number;
padding?: number;
stroke?: string | number;
strokeThickness?: number;
trim?: boolean;
textBaseline?: string;
whiteSpace?: string;
wordWrap?: boolean;
wordWrapWidth?: number;
}
export interface ExtendedTextStyle extends TextStyle {
valign?: "top" | "middle" | "bottom" | "baseline" | number;

@@ -41,3 +72,3 @@ debug?: boolean;

private handleInteraction;
styles: TextStyleSet;
set styles(styles: TextStyleSet);
setTagStyle(tag: string, style: ExtendedTextStyle): void;

@@ -52,2 +83,3 @@ deleteTagStyle(tag: string): void;

private getDropShadowPadding;
private withPrivateMembers;
updateText(): void;

@@ -58,1 +90,2 @@ protected wordWrap(text: string): string;

}
export {};

2

dist/pixi-multistyle-text.js

@@ -1,2 +0,2 @@

var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};var e=["pointerover","pointerenter","pointerdown","pointermove","pointerup","pointercancel","pointerout","pointerleave","gotpointercapture","lostpointercapture","mouseover","mouseenter","mousedown","mousemove","mouseup","mousecancel","mouseout","mouseleave","touchover","touchenter","touchdown","touchmove","touchup","touchcancel","touchout","touchleave"],n="bbcode",o={bbcode:["[","]"],xml:["<",">"]},s=function(s){function i(t,n){var o=s.call(this,t)||this;return o.styles=n,e.forEach(function(t){o.on(t,function(t){return o.handleInteraction(t)})}),o}return function(e,n){function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}(i,s),i.prototype.handleInteraction=function(t){var e=t,n=t.data.getLocalPosition(this),o=this.hitboxes.reduce(function(t,e){return void 0!==t?t:e.hitbox.contains(n.x,n.y)?e:void 0},void 0);e.targetTag=void 0===o?void 0:o.tag},Object.defineProperty(i.prototype,"styles",{set:function(t){for(var e in this.textStyles={},this.textStyles.default=this.assign({},i.DEFAULT_TAG_STYLE),t)"default"===e?this.assign(this.textStyles.default,t[e]):this.textStyles[e]=this.assign({},t[e]);this.textStyles.default.tagStyle===n&&(this.textStyles.b=this.assign({},{fontStyle:"bold"}),this.textStyles.i=this.assign({},{fontStyle:"italic"}),this.textStyles.color=this.assign({},{fill:""}),this.textStyles.outline=this.assign({},{stroke:"",strokeThickness:6}),this.textStyles.font=this.assign({},{fontFamily:""}),this.textStyles.shadow=this.assign({},{dropShadowColor:"",dropShadow:!0,dropShadowBlur:3,dropShadowDistance:3,dropShadowAngle:2}),this.textStyles.size=this.assign({},{fontSize:"px"}),this.textStyles.spacing=this.assign({},{letterSpacing:""}),this.textStyles.align=this.assign({},{align:""})),this._style=new PIXI.TextStyle(this.textStyles.default),this.dirty=!0},enumerable:!0,configurable:!0}),i.prototype.setTagStyle=function(t,e){t in this.textStyles?this.assign(this.textStyles[t],e):this.textStyles[t]=this.assign({},e),this._style=new PIXI.TextStyle(this.textStyles.default),this.dirty=!0},i.prototype.deleteTagStyle=function(t){"default"===t?this.textStyles.default=this.assign({},i.DEFAULT_TAG_STYLE):delete this.textStyles[t],this._style=new PIXI.TextStyle(this.textStyles.default),this.dirty=!0},i.prototype.getTagRegex=function(t,e){var s=Object.keys(this.textStyles).join("|");s=t?"("+s+")":"(?:"+s+")";var i=this.textStyles.default.tagStyle===n?"\\"+o.bbcode[0]+s+"(?:\\=(?:[A-Za-z0-9_\\-\\#]+|'(?:[^']+|\\\\')*'))*\\s*\\"+o.bbcode[1]+"|\\"+o.bbcode[0]+"\\/"+s+"\\s*\\"+o.bbcode[1]:"\\"+o.xml[0]+s+"(?:\\s+[A-Za-z0-9_\\-]+=(?:\"(?:[^\"]+|\\\\\")*\"|'(?:[^']+|\\\\')*'))*\\s*\\"+o.xml[1]+"|\\"+o.xml[0]+"\\/"+s+"\\s*\\"+o.xml[1];return e&&(i="("+i+")"),new RegExp(i,"g")},i.prototype.getPropertyRegex=function(){return new RegExp("([A-Za-z0-9_\\-]+)=(?:\"((?:[^\"]+|\\\\\")*)\"|'((?:[^']+|\\\\')*)')","g")},i.prototype.getBBcodePropertyRegex=function(){return new RegExp("[A-Za-z0-9_\\-]+=([A-Za-z0-9_\\-\\#]+)","g")},i.prototype._getTextDataPerLine=function(t){for(var e=[],s=this.getTagRegex(!0,!1),i=[this.assign({},this.textStyles.default)],r=[{name:"default",properties:{}}],a=0;a<t.length;a++){for(var h=[],l=[],c=void 0;c=s.exec(t[a]);)l.push(c);if(0===l.length)h.push(this.createTextData(t[a],i[i.length-1],r[r.length-1]));else{for(var x=0,d=function(e){if(l[e].index>x&&h.push(g.createTextData(t[a].substring(x,l[e].index),i[i.length-1],r[r.length-1])),"/"===l[e][0][1])i.length>1&&(i.pop(),r.pop());else{for(var o={},s=g.getPropertyRegex(),c=void 0;c=s.exec(l[e][0]);)o[c[1]]=c[2]||c[3];if(r.push({name:l[e][1],properties:o}),g.textStyles.default.tagStyle===n&&l[e][0].includes("=")&&g.textStyles[l[e][1]]){var d=g.getBBcodePropertyRegex().exec(l[e][0]),u={};Object.entries(g.textStyles[l[e][1]]).forEach(function(t){u[t[0]]="string"!=typeof t[1]?t[1]:d[1]+t[1]}),i.push(g.assign({},i[i.length-1],u))}else i.push(g.assign({},i[i.length-1],g.textStyles[l[e][1]]))}x=l[e].index+l[e][0].length},g=this,u=0;u<l.length;u++)d(u);if(x<t[a].length){var p=this.createTextData(x?t[a].substring(x):t[a],i[i.length-1],r[r.length-1]);h.push(p)}}e.push(h)}var f=this.textStyles.default.tagStyle;return e[e.length-1].map(function(t){t.text.includes(o[f][0])&&(t.text=t.text.match(f===n?/^(.*)\[/:/^(.*)\</)[1])}),e},i.prototype.getFontString=function(t){return new PIXI.TextStyle(t).toFontString()},i.prototype.createTextData=function(t,e,n){return{text:t,style:e,width:0,height:0,fontProperties:void 0,tag:n}},i.prototype.getDropShadowPadding=function(){var t=this,e=0,n=0;return Object.keys(this.textStyles).forEach(function(o){var s=t.textStyles[o],i=s.dropShadowBlur;e=Math.max(e,s.dropShadowDistance||0),n=Math.max(n,i||0)}),e+n},i.prototype.updateText=function(){var t=this;if(this.dirty){this.hitboxes=[],this.texture.baseTexture.resolution=this.resolution;var e=this.textStyles,n=this.text;this._style.wordWrap&&(n=this.wordWrap(this.text));for(var o=n.split(/(?:\r\n|\r|\n)/),s=this._getTextDataPerLine(o),r=[],a=[],h=[],l=0,c=0;c<o.length;c++){for(var x=0,d=0,g=0,u=0;u<s[c].length;u++){var p=s[c][u].style;this.context.font=this.getFontString(p),s[c][u].width=this.context.measureText(s[c][u].text).width,0!==s[c][u].text.length&&(s[c][u].width+=(s[c][u].text.length-1)*p.letterSpacing,u>0&&(x+=p.letterSpacing/2),u<s[c].length-1&&(x+=p.letterSpacing/2)),x+=s[c][u].width,s[c][u].fontProperties=PIXI.TextMetrics.measureFont(this.context.font),s[c][u].height=s[c][u].fontProperties.fontSize,"number"==typeof p.valign?(d=Math.min(d,p.valign-s[c][u].fontProperties.descent),g=Math.max(g,p.valign+s[c][u].fontProperties.ascent)):(d=Math.min(d,-s[c][u].fontProperties.descent),g=Math.max(g,s[c][u].fontProperties.ascent))}r[c]=x,a[c]=d,h[c]=g,l=Math.max(l,x)}var f=Object.keys(e).map(function(t){return e[t]}).reduce(function(t,e){return Math.max(t,e.strokeThickness||0)},0),y=this.getDropShadowPadding(),S=l+2*f+2*y,b=h.reduce(function(t,e){return t+e},0)-a.reduce(function(t,e){return t+e},0)+2*f+2*y;this.canvas.width=S*this.resolution,this.canvas.height=b*this.resolution,this.context.scale(this.resolution,this.resolution),this.context.textBaseline="alphabetic",this.context.lineJoin="round";var v=y+f,w=[];for(c=0;c<s.length;c++){var m=s[c],T=void 0;switch(this._style.align){case"left":T=y+f;break;case"center":T=y+f+(l-r[c])/2;break;case"right":T=y+f+l-r[c]}for(u=0;u<m.length;u++){var k=m[u],P=k.style,_=k.text,I=k.fontProperties,O=k.width,A=k.tag,F=v+I.ascent;switch(P.valign){case"top":break;case"baseline":F+=h[c]-I.ascent;break;case"middle":F+=(h[c]-a[c]-I.ascent-I.descent)/2;break;case"bottom":F+=h[c]-a[c]-I.ascent-I.descent;break;default:F+=h[c]-I.ascent-P.valign}if(0===P.letterSpacing)w.push({text:_,style:P,x:T,y:F,width:O,ascent:I.ascent,descent:I.descent,tag:A}),T+=m[u].width;else{this.context.font=this.getFontString(m[u].style);for(var E=0;E<_.length;E++){(E>0||u>0)&&(T+=P.letterSpacing/2);var D=this.context.measureText(_.charAt(E)).width;w.push({text:_.charAt(E),style:P,x:T,y:F,width:D,ascent:I.ascent,descent:I.descent,tag:A}),T+=D,(E<_.length-1||u<m.length-1)&&(T+=P.letterSpacing/2)}}}v+=h[c]-a[c]}this.context.save(),w.forEach(function(e){var n=e.style,o=e.text,s=e.x,i=e.y;if(n.dropShadow){t.context.font=t.getFontString(n);var r=n.dropShadowColor;"number"==typeof r&&(r=PIXI.utils.hex2string(r)),t.context.shadowColor=r,t.context.shadowBlur=n.dropShadowBlur,t.context.shadowOffsetX=Math.cos(n.dropShadowAngle)*n.dropShadowDistance*t.resolution,t.context.shadowOffsetY=Math.sin(n.dropShadowAngle)*n.dropShadowDistance*t.resolution,t.context.fillText(o,s,i)}}),this.context.restore(),w.forEach(function(e){var n=e.style,o=e.text,s=e.x,i=e.y;if(void 0!==n.stroke&&n.strokeThickness){t.context.font=t.getFontString(n);var r=n.stroke;"number"==typeof r&&(r=PIXI.utils.hex2string(r)),t.context.strokeStyle=r,t.context.lineWidth=n.strokeThickness,t.context.strokeText(o,s,i)}}),w.forEach(function(e){var n=e.style,o=e.text,s=e.x,i=e.y;if(void 0!==n.fill){t.context.font=t.getFontString(n);var r=n.fill;if("number"==typeof r)r=PIXI.utils.hex2string(r);else if(Array.isArray(r))for(var a=0;a<r.length;a++){var h=r[a];"number"==typeof h&&(r[a]=PIXI.utils.hex2string(h))}t.context.fillStyle=t._generateFillStyle(new PIXI.TextStyle(n),[o]),t.context.fillText(o,s,i)}}),w.forEach(function(e){var n=e.style,o=e.x,s=e.y,r=e.width,a=e.ascent,h=e.descent,l=e.tag,c=-t._style.padding-t.getDropShadowPadding();t.hitboxes.push({tag:l,hitbox:new PIXI.Rectangle(o+c,s-a+c,r,a+h)}),(void 0===n.debug?i.debugOptions.spans.enabled:n.debug)&&(t.context.lineWidth=1,i.debugOptions.spans.bounding&&(t.context.fillStyle=i.debugOptions.spans.bounding,t.context.strokeStyle=i.debugOptions.spans.bounding,t.context.beginPath(),t.context.rect(o,s-a,r,a+h),t.context.fill(),t.context.stroke(),t.context.stroke()),i.debugOptions.spans.baseline&&(t.context.strokeStyle=i.debugOptions.spans.baseline,t.context.beginPath(),t.context.moveTo(o,s),t.context.lineTo(o+r,s),t.context.closePath(),t.context.stroke()),i.debugOptions.spans.top&&(t.context.strokeStyle=i.debugOptions.spans.top,t.context.beginPath(),t.context.moveTo(o,s-a),t.context.lineTo(o+r,s-a),t.context.closePath(),t.context.stroke()),i.debugOptions.spans.bottom&&(t.context.strokeStyle=i.debugOptions.spans.bottom,t.context.beginPath(),t.context.moveTo(o,s+h),t.context.lineTo(o+r,s+h),t.context.closePath(),t.context.stroke()),i.debugOptions.spans.text&&(t.context.fillStyle="#ffffff",t.context.strokeStyle="#000000",t.context.lineWidth=2,t.context.font="8px monospace",t.context.strokeText(l.name,o,s-a+8),t.context.fillText(l.name,o,s-a+8),t.context.strokeText(r.toFixed(2)+"x"+(a+h).toFixed(2),o,s-a+16),t.context.fillText(r.toFixed(2)+"x"+(a+h).toFixed(2),o,s-a+16)))}),i.debugOptions.objects.enabled&&(i.debugOptions.objects.bounding&&(this.context.fillStyle=i.debugOptions.objects.bounding,this.context.beginPath(),this.context.rect(0,0,S,b),this.context.fill()),i.debugOptions.objects.text&&(this.context.fillStyle="#ffffff",this.context.strokeStyle="#000000",this.context.lineWidth=2,this.context.font="8px monospace",this.context.strokeText(S.toFixed(2)+"x"+b.toFixed(2),0,8,S),this.context.fillText(S.toFixed(2)+"x"+b.toFixed(2),0,8,S))),this.updateTexture()}},i.prototype.wordWrap=function(t){var e="",n=this.getTagRegex(!0,!0),o=t.split("\n"),s=this._style.wordWrapWidth,i=[this.assign({},this.textStyles.default)];this.context.font=this.getFontString(this.textStyles.default);for(var r=0;r<o.length;r++){for(var a=s,h=o[r].split(n),l=!0,c=0;c<h.length;c++)if(n.test(h[c]))e+=h[c],"/"===h[c][1]?(c+=2,i.pop()):(i.push(this.assign({},i[i.length-1],this.textStyles[h[++c]])),c++),this.context.font=this.getFontString(i[i.length-1]);else for(var x=h[c].split(" "),d=0;d<x.length;d++){var g=this.context.measureText(x[d]).width;if(this._style.breakWords&&g>a){var u=x[d].split("");d>0&&(e+=" ",a-=this.context.measureText(" ").width);for(var p=0;p<u.length;p++){var f=this.context.measureText(u[p]).width;f>a?(e+="\n"+u[p],a=s-f):(e+=u[p],a-=f)}}else if(this._style.breakWords)e+=x[d],a-=g;else{var y=g+(d>0?this.context.measureText(" ").width:0);y>a?(l||(e+="\n"),e+=x[d],a=s-g):(a-=y,d>0&&(e+=" "),e+=x[d])}l=!1}r<o.length-1&&(e+="\n")}return e},i.prototype.updateTexture=function(){var t=this._texture,e=this.getDropShadowPadding();t.baseTexture.hasLoaded=!0,t.baseTexture.resolution=this.resolution,t.baseTexture.realWidth=this.canvas.width,t.baseTexture.realHeight=this.canvas.height,t.baseTexture.width=this.canvas.width/this.resolution,t.baseTexture.height=this.canvas.height/this.resolution,t.trim.width=t.frame.width=this.canvas.width/this.resolution,t.trim.height=t.frame.height=this.canvas.height/this.resolution,t.trim.x=-this._style.padding-e,t.trim.y=-this._style.padding-e,t.orig.width=t.frame.width-2*(this._style.padding+e),t.orig.height=t.frame.height-2*(this._style.padding+e),this._onTextureUpdate(),t.baseTexture.emit("update",t.baseTexture),this.dirty=!1},i.prototype.assign=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var o=0,s=e;o<s.length;o++){var i=s[o];for(var r in i)t[r]=i[r]}return t},i.DEFAULT_TAG_STYLE={align:"left",breakWords:!1,dropShadow:!1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"#000000",dropShadowDistance:5,fill:"black",fillGradientType:PIXI.TEXT_GRADIENT.LINEAR_VERTICAL,fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",valign:"baseline",wordWrap:!1,wordWrapWidth:100,tagStyle:"xml"},i.debugOptions={spans:{enabled:!1,baseline:"#44BB44",top:"#BB4444",bottom:"#4444BB",bounding:"rgba(255, 255, 255, 0.1)",text:!0},objects:{enabled:!1,bounding:"rgba(255, 255, 255, 0.05)",text:!0}},i}(PIXI.Text);module.exports=s;
var t=["pointerover","pointerenter","pointerdown","pointermove","pointerup","pointercancel","pointerout","pointerleave","gotpointercapture","lostpointercapture","mouseover","mouseenter","mousedown","mousemove","mouseup","mousecancel","mouseout","mouseleave","touchover","touchenter","touchdown","touchmove","touchup","touchcancel","touchout","touchleave"],e={bbcode:["[","]"],xml:["<",">"]},i=function(i){function s(e,s){var o=this;i.call(this,e),this.styles=s,t.forEach(function(t){o.on(t,function(t){return o.handleInteraction(t)})})}i&&(s.__proto__=i),(s.prototype=Object.create(i&&i.prototype)).constructor=s;var o={styles:{configurable:!0}};return s.prototype.handleInteraction=function(t){var e=t,i=t.data.getLocalPosition(this),s=this.hitboxes.reduce(function(t,e){return void 0!==t?t:e.hitbox.contains(i.x,i.y)?e:void 0},void 0);e.targetTag=void 0===s?void 0:s.tag},o.styles.set=function(t){for(var e in this.textStyles={},this.textStyles.default=this.assign({},s.DEFAULT_TAG_STYLE),t)"default"===e?this.assign(this.textStyles.default,t[e]):this.textStyles[e]=this.assign({},t[e]);"bbcode"===this.textStyles.default.tagStyle&&(this.textStyles.b=this.assign({},{fontStyle:"bold"}),this.textStyles.i=this.assign({},{fontStyle:"italic"}),this.textStyles.color=this.assign({},{fill:""}),this.textStyles.outline=this.assign({},{stroke:"",strokeThickness:6}),this.textStyles.font=this.assign({},{fontFamily:""}),this.textStyles.shadow=this.assign({},{dropShadowColor:"",dropShadow:!0,dropShadowBlur:3,dropShadowDistance:3,dropShadowAngle:2}),this.textStyles.size=this.assign({},{fontSize:"px"}),this.textStyles.spacing=this.assign({},{letterSpacing:""}),this.textStyles.align=this.assign({},{align:""})),this.withPrivateMembers()._style=new PIXI.TextStyle(this.textStyles.default),this.withPrivateMembers().dirty=!0},s.prototype.setTagStyle=function(t,e){t in this.textStyles?this.assign(this.textStyles[t],e):this.textStyles[t]=this.assign({},e),this.withPrivateMembers()._style=new PIXI.TextStyle(this.textStyles.default),this.withPrivateMembers().dirty=!0},s.prototype.deleteTagStyle=function(t){"default"===t?this.textStyles.default=this.assign({},s.DEFAULT_TAG_STYLE):delete this.textStyles[t],this.withPrivateMembers()._style=new PIXI.TextStyle(this.textStyles.default),this.withPrivateMembers().dirty=!0},s.prototype.getTagRegex=function(t,i){var s=Object.keys(this.textStyles).join("|");s=t?"("+s+")":"(?:"+s+")";var o="bbcode"===this.textStyles.default.tagStyle?"\\"+e.bbcode[0]+s+"(?:\\=(?:[A-Za-z0-9_\\-\\#]+|'(?:[^']+|\\\\')*'))*\\s*\\"+e.bbcode[1]+"|\\"+e.bbcode[0]+"\\/"+s+"\\s*\\"+e.bbcode[1]:"\\"+e.xml[0]+s+"(?:\\s+[A-Za-z0-9_\\-]+=(?:\"(?:[^\"]+|\\\\\")*\"|'(?:[^']+|\\\\')*'))*\\s*\\"+e.xml[1]+"|\\"+e.xml[0]+"\\/"+s+"\\s*\\"+e.xml[1];return i&&(o="("+o+")"),new RegExp(o,"g")},s.prototype.getPropertyRegex=function(){return new RegExp("([A-Za-z0-9_\\-]+)=(?:\"((?:[^\"]+|\\\\\")*)\"|'((?:[^']+|\\\\')*)')","g")},s.prototype.getBBcodePropertyRegex=function(){return new RegExp("[A-Za-z0-9_\\-]+=([A-Za-z0-9_\\-\\#]+)","g")},s.prototype._getTextDataPerLine=function(t){for(var i=[],s=this.getTagRegex(!0,!1),o=[this.assign({},this.textStyles.default)],n=[{name:"default",properties:{}}],r=0;r<t.length;r++){for(var a=[],h=[],l=void 0;l=s.exec(t[r]);)h.push(l);if(0===h.length)a.push(this.createTextData(t[r],o[o.length-1],n[n.length-1]));else{for(var c=0,x=0;x<h.length;x++){if(h[x].index>c&&a.push(this.createTextData(t[r].substring(c,h[x].index),o[o.length-1],n[n.length-1])),"/"===h[x][0][1])o.length>1&&(o.pop(),n.pop());else{for(var d={},g=this.getPropertyRegex(),p=void 0;p=g.exec(h[x][0]);)d[p[1]]=p[2]||p[3];if(n.push({name:h[x][1],properties:d}),"bbcode"===this.textStyles.default.tagStyle&&h[x][0].includes("=")&&this.textStyles[h[x][1]]){var u=this.getBBcodePropertyRegex().exec(h[x][0]),f={};Object.entries(this.textStyles[h[x][1]]).forEach(function(t){f[t[0]]="string"!=typeof t[1]?t[1]:u[1]+t[1]}),o.push(this.assign({},o[o.length-1],f))}else o.push(this.assign({},o[o.length-1],this.textStyles[h[x][1]]))}c=h[x].index+h[x][0].length}if(c<t[r].length){var y=this.createTextData(c?t[r].substring(c):t[r],o[o.length-1],n[n.length-1]);a.push(y)}}i.push(a)}var b=this.textStyles.default.tagStyle;return i[i.length-1].map(function(t){t.text.includes(e[b][0])&&(t.text=t.text.match("bbcode"===b?/^(.*)\[/:/^(.*)\</)[1])}),i},s.prototype.getFontString=function(t){return new PIXI.TextStyle(t).toFontString()},s.prototype.createTextData=function(t,e,i){return{text:t,style:e,width:0,height:0,fontProperties:void 0,tag:i}},s.prototype.getDropShadowPadding=function(){var t=this,e=0,i=0;return Object.keys(this.textStyles).forEach(function(s){var o=t.textStyles[s],n=o.dropShadowBlur;e=Math.max(e,o.dropShadowDistance||0),i=Math.max(i,n||0)}),e+i},s.prototype.withPrivateMembers=function(){return this},s.prototype.updateText=function(){var t=this;if(this.withPrivateMembers().dirty){this.hitboxes=[],this.texture.baseTexture.resolution=this.resolution;var e=this.textStyles,i=this.text;this.withPrivateMembers()._style.wordWrap&&(i=this.wordWrap(this.text));for(var o=i.split(/(?:\r\n|\r|\n)/),n=this._getTextDataPerLine(o),r=[],a=[],h=[],l=0,c=0;c<o.length;c++){for(var x=0,d=0,g=0,p=0;p<n[c].length;p++){var u=n[c][p].style;this.context.font=this.getFontString(u),n[c][p].width=this.context.measureText(n[c][p].text).width,0!==n[c][p].text.length&&(n[c][p].width+=(n[c][p].text.length-1)*u.letterSpacing,p>0&&(x+=u.letterSpacing/2),p<n[c].length-1&&(x+=u.letterSpacing/2)),x+=n[c][p].width,n[c][p].fontProperties=PIXI.TextMetrics.measureFont(this.context.font),n[c][p].height=n[c][p].fontProperties.fontSize,"number"==typeof u.valign?(d=Math.min(d,u.valign-n[c][p].fontProperties.descent),g=Math.max(g,u.valign+n[c][p].fontProperties.ascent)):(d=Math.min(d,-n[c][p].fontProperties.descent),g=Math.max(g,n[c][p].fontProperties.ascent))}r[c]=x,a[c]=d,h[c]=g,l=Math.max(l,x)}var f=Object.keys(e).map(function(t){return e[t]}).reduce(function(t,e){return Math.max(t,e.strokeThickness||0)},0),y=this.getDropShadowPadding(),b=l+2*f+2*y,S=h.reduce(function(t,e){return t+e},0)-a.reduce(function(t,e){return t+e},0)+2*f+2*y;this.canvas.width=b*this.resolution,this.canvas.height=S*this.resolution,this.context.scale(this.resolution,this.resolution),this.context.textBaseline="alphabetic",this.context.lineJoin="round";for(var v=y+f,m=[],w=0;w<n.length;w++){var T=n[w],P=void 0;switch(this.withPrivateMembers()._style.align){case"left":P=y+f;break;case"center":P=y+f+(l-r[w])/2;break;case"right":P=y+f+l-r[w]}for(var k=0;k<T.length;k++){var _=T[k],M=_.style,I=_.text,F=_.fontProperties,O=_.width,A=_.tag,E=v+F.ascent;switch(M.valign){case"top":break;case"baseline":E+=h[w]-F.ascent;break;case"middle":E+=(h[w]-a[w]-F.ascent-F.descent)/2;break;case"bottom":E+=h[w]-a[w]-F.ascent-F.descent;break;default:E+=h[w]-F.ascent-M.valign}if(0===M.letterSpacing)m.push({text:I,style:M,x:P,y:E,width:O,ascent:F.ascent,descent:F.descent,tag:A}),P+=T[k].width;else{this.context.font=this.getFontString(T[k].style);for(var D=0;D<I.length;D++){(D>0||k>0)&&(P+=M.letterSpacing/2);var B=this.context.measureText(I.charAt(D)).width;m.push({text:I.charAt(D),style:M,x:P,y:E,width:B,ascent:F.ascent,descent:F.descent,tag:A}),P+=B,(D<I.length-1||k<T.length-1)&&(P+=M.letterSpacing/2)}}}v+=h[w]-a[w]}this.context.save(),m.forEach(function(e){var i=e.style,s=e.text,o=e.x,n=e.y;if(i.dropShadow){t.context.font=t.getFontString(i);var r=i.dropShadowColor;"number"==typeof r&&(r=PIXI.utils.hex2string(r)),t.context.shadowColor=r,t.context.shadowBlur=i.dropShadowBlur,t.context.shadowOffsetX=Math.cos(i.dropShadowAngle)*i.dropShadowDistance*t.resolution,t.context.shadowOffsetY=Math.sin(i.dropShadowAngle)*i.dropShadowDistance*t.resolution,t.context.fillText(s,o,n)}}),this.context.restore(),m.forEach(function(e){var i=e.style,s=e.text,o=e.x,n=e.y;if(void 0!==i.stroke&&i.strokeThickness){t.context.font=t.getFontString(i);var r=i.stroke;"number"==typeof r&&(r=PIXI.utils.hex2string(r)),t.context.strokeStyle=r,t.context.lineWidth=i.strokeThickness,t.context.strokeText(s,o,n)}}),m.forEach(function(e){var i=e.style,s=e.text,o=e.x,n=e.y;if(void 0!==i.fill){t.context.font=t.getFontString(i);var r=i.fill;if("number"==typeof r)r=PIXI.utils.hex2string(r);else if(Array.isArray(r))for(var a=0;a<r.length;a++){var h=r[a];"number"==typeof h&&(r[a]=PIXI.utils.hex2string(h))}t.context.fillStyle=t._generateFillStyle(new PIXI.TextStyle(i),[s]),t.context.fillText(s,o,n)}}),m.forEach(function(e){var i=e.style,o=e.x,n=e.y,r=e.width,a=e.ascent,h=e.descent,l=e.tag,c=-t.withPrivateMembers()._style.padding-t.getDropShadowPadding();t.hitboxes.push({tag:l,hitbox:new PIXI.Rectangle(o+c,n-a+c,r,a+h)}),(void 0===i.debug?s.debugOptions.spans.enabled:i.debug)&&(t.context.lineWidth=1,s.debugOptions.spans.bounding&&(t.context.fillStyle=s.debugOptions.spans.bounding,t.context.strokeStyle=s.debugOptions.spans.bounding,t.context.beginPath(),t.context.rect(o,n-a,r,a+h),t.context.fill(),t.context.stroke(),t.context.stroke()),s.debugOptions.spans.baseline&&(t.context.strokeStyle=s.debugOptions.spans.baseline,t.context.beginPath(),t.context.moveTo(o,n),t.context.lineTo(o+r,n),t.context.closePath(),t.context.stroke()),s.debugOptions.spans.top&&(t.context.strokeStyle=s.debugOptions.spans.top,t.context.beginPath(),t.context.moveTo(o,n-a),t.context.lineTo(o+r,n-a),t.context.closePath(),t.context.stroke()),s.debugOptions.spans.bottom&&(t.context.strokeStyle=s.debugOptions.spans.bottom,t.context.beginPath(),t.context.moveTo(o,n+h),t.context.lineTo(o+r,n+h),t.context.closePath(),t.context.stroke()),s.debugOptions.spans.text&&(t.context.fillStyle="#ffffff",t.context.strokeStyle="#000000",t.context.lineWidth=2,t.context.font="8px monospace",t.context.strokeText(l.name,o,n-a+8),t.context.fillText(l.name,o,n-a+8),t.context.strokeText(r.toFixed(2)+"x"+(a+h).toFixed(2),o,n-a+16),t.context.fillText(r.toFixed(2)+"x"+(a+h).toFixed(2),o,n-a+16)))}),s.debugOptions.objects.enabled&&(s.debugOptions.objects.bounding&&(this.context.fillStyle=s.debugOptions.objects.bounding,this.context.beginPath(),this.context.rect(0,0,b,S),this.context.fill()),s.debugOptions.objects.text&&(this.context.fillStyle="#ffffff",this.context.strokeStyle="#000000",this.context.lineWidth=2,this.context.font="8px monospace",this.context.strokeText(b.toFixed(2)+"x"+S.toFixed(2),0,8,b),this.context.fillText(b.toFixed(2)+"x"+S.toFixed(2),0,8,b))),this.updateTexture()}},s.prototype.wordWrap=function(t){var e="",i=this.getTagRegex(!0,!0),s=t.split("\n"),o=this.withPrivateMembers()._style.wordWrapWidth,n=[this.assign({},this.textStyles.default)];this.context.font=this.getFontString(this.textStyles.default);for(var r=0;r<s.length;r++){for(var a=o,h=s[r].split(i),l=!0,c=0;c<h.length;c++)if(i.test(h[c]))e+=h[c],"/"===h[c][1]?(c+=2,n.pop()):(n.push(this.assign({},n[n.length-1],this.textStyles[h[++c]])),c++),this.context.font=this.getFontString(n[n.length-1]);else for(var x=h[c].split(" "),d=0;d<x.length;d++){var g=this.context.measureText(x[d]).width;if(this.withPrivateMembers()._style.breakWords&&g>a){var p=x[d].split("");d>0&&(e+=" ",a-=this.context.measureText(" ").width);for(var u=0;u<p.length;u++){var f=this.context.measureText(p[u]).width;f>a?(e+="\n"+p[u],a=o-f):(e+=p[u],a-=f)}}else if(this.withPrivateMembers()._style.breakWords)e+=x[d],a-=g;else{var y=g+(d>0?this.context.measureText(" ").width:0);y>a?(l||(e+="\n"),e+=x[d],a=o-g):(a-=y,d>0&&(e+=" "),e+=x[d])}l=!1}r<s.length-1&&(e+="\n")}return e},s.prototype.updateTexture=function(){var t=this.withPrivateMembers()._texture,e=this.getDropShadowPadding();t.baseTexture.setRealSize(this.canvas.width,this.canvas.height,this.resolution),t.trim.width=t.frame.width=this.canvas.width/this.resolution,t.trim.height=t.frame.height=this.canvas.height/this.resolution,t.trim.x=-this.withPrivateMembers()._style.padding-e,t.trim.y=-this.withPrivateMembers()._style.padding-e,t.orig.width=t.frame.width-2*(this.withPrivateMembers()._style.padding+e),t.orig.height=t.frame.height-2*(this.withPrivateMembers()._style.padding+e),this.withPrivateMembers()._onTextureUpdate(),t.baseTexture.emit("update",t.baseTexture),this.withPrivateMembers().dirty=!1},s.prototype.assign=function(t){for(var e=[],i=arguments.length-1;i-- >0;)e[i]=arguments[i+1];for(var s=0,o=e;s<o.length;s+=1){var n=o[s];for(var r in n)t[r]=n[r]}return t},Object.defineProperties(s.prototype,o),s}(PIXI.Text);i.DEFAULT_TAG_STYLE={align:"left",breakWords:!1,dropShadow:!1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"#000000",dropShadowDistance:5,fill:"black",fillGradientType:PIXI.TEXT_GRADIENT.LINEAR_VERTICAL,fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",valign:"baseline",wordWrap:!1,wordWrapWidth:100,tagStyle:"xml"},i.debugOptions={spans:{enabled:!1,baseline:"#44BB44",top:"#BB4444",bottom:"#4444BB",bounding:"rgba(255, 255, 255, 0.1)",text:!0},objects:{enabled:!1,bounding:"rgba(255, 255, 255, 0.05)",text:!0}},module.exports=i;
//# sourceMappingURL=pixi-multistyle-text.js.map

@@ -1,2 +0,2 @@

var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};var e=["pointerover","pointerenter","pointerdown","pointermove","pointerup","pointercancel","pointerout","pointerleave","gotpointercapture","lostpointercapture","mouseover","mouseenter","mousedown","mousemove","mouseup","mousecancel","mouseout","mouseleave","touchover","touchenter","touchdown","touchmove","touchup","touchcancel","touchout","touchleave"],n="bbcode",o={bbcode:["[","]"],xml:["<",">"]};export default(function(s){function i(t,n){var o=s.call(this,t)||this;return o.styles=n,e.forEach(function(t){o.on(t,function(t){return o.handleInteraction(t)})}),o}return function(e,n){function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}(i,s),i.prototype.handleInteraction=function(t){var e=t,n=t.data.getLocalPosition(this),o=this.hitboxes.reduce(function(t,e){return void 0!==t?t:e.hitbox.contains(n.x,n.y)?e:void 0},void 0);e.targetTag=void 0===o?void 0:o.tag},Object.defineProperty(i.prototype,"styles",{set:function(t){for(var e in this.textStyles={},this.textStyles.default=this.assign({},i.DEFAULT_TAG_STYLE),t)"default"===e?this.assign(this.textStyles.default,t[e]):this.textStyles[e]=this.assign({},t[e]);this.textStyles.default.tagStyle===n&&(this.textStyles.b=this.assign({},{fontStyle:"bold"}),this.textStyles.i=this.assign({},{fontStyle:"italic"}),this.textStyles.color=this.assign({},{fill:""}),this.textStyles.outline=this.assign({},{stroke:"",strokeThickness:6}),this.textStyles.font=this.assign({},{fontFamily:""}),this.textStyles.shadow=this.assign({},{dropShadowColor:"",dropShadow:!0,dropShadowBlur:3,dropShadowDistance:3,dropShadowAngle:2}),this.textStyles.size=this.assign({},{fontSize:"px"}),this.textStyles.spacing=this.assign({},{letterSpacing:""}),this.textStyles.align=this.assign({},{align:""})),this._style=new PIXI.TextStyle(this.textStyles.default),this.dirty=!0},enumerable:!0,configurable:!0}),i.prototype.setTagStyle=function(t,e){t in this.textStyles?this.assign(this.textStyles[t],e):this.textStyles[t]=this.assign({},e),this._style=new PIXI.TextStyle(this.textStyles.default),this.dirty=!0},i.prototype.deleteTagStyle=function(t){"default"===t?this.textStyles.default=this.assign({},i.DEFAULT_TAG_STYLE):delete this.textStyles[t],this._style=new PIXI.TextStyle(this.textStyles.default),this.dirty=!0},i.prototype.getTagRegex=function(t,e){var s=Object.keys(this.textStyles).join("|");s=t?"("+s+")":"(?:"+s+")";var i=this.textStyles.default.tagStyle===n?"\\"+o.bbcode[0]+s+"(?:\\=(?:[A-Za-z0-9_\\-\\#]+|'(?:[^']+|\\\\')*'))*\\s*\\"+o.bbcode[1]+"|\\"+o.bbcode[0]+"\\/"+s+"\\s*\\"+o.bbcode[1]:"\\"+o.xml[0]+s+"(?:\\s+[A-Za-z0-9_\\-]+=(?:\"(?:[^\"]+|\\\\\")*\"|'(?:[^']+|\\\\')*'))*\\s*\\"+o.xml[1]+"|\\"+o.xml[0]+"\\/"+s+"\\s*\\"+o.xml[1];return e&&(i="("+i+")"),new RegExp(i,"g")},i.prototype.getPropertyRegex=function(){return new RegExp("([A-Za-z0-9_\\-]+)=(?:\"((?:[^\"]+|\\\\\")*)\"|'((?:[^']+|\\\\')*)')","g")},i.prototype.getBBcodePropertyRegex=function(){return new RegExp("[A-Za-z0-9_\\-]+=([A-Za-z0-9_\\-\\#]+)","g")},i.prototype._getTextDataPerLine=function(t){for(var e=[],s=this.getTagRegex(!0,!1),i=[this.assign({},this.textStyles.default)],r=[{name:"default",properties:{}}],a=0;a<t.length;a++){for(var h=[],l=[],c=void 0;c=s.exec(t[a]);)l.push(c);if(0===l.length)h.push(this.createTextData(t[a],i[i.length-1],r[r.length-1]));else{for(var x=0,d=function(e){if(l[e].index>x&&h.push(g.createTextData(t[a].substring(x,l[e].index),i[i.length-1],r[r.length-1])),"/"===l[e][0][1])i.length>1&&(i.pop(),r.pop());else{for(var o={},s=g.getPropertyRegex(),c=void 0;c=s.exec(l[e][0]);)o[c[1]]=c[2]||c[3];if(r.push({name:l[e][1],properties:o}),g.textStyles.default.tagStyle===n&&l[e][0].includes("=")&&g.textStyles[l[e][1]]){var d=g.getBBcodePropertyRegex().exec(l[e][0]),u={};Object.entries(g.textStyles[l[e][1]]).forEach(function(t){u[t[0]]="string"!=typeof t[1]?t[1]:d[1]+t[1]}),i.push(g.assign({},i[i.length-1],u))}else i.push(g.assign({},i[i.length-1],g.textStyles[l[e][1]]))}x=l[e].index+l[e][0].length},g=this,u=0;u<l.length;u++)d(u);if(x<t[a].length){var p=this.createTextData(x?t[a].substring(x):t[a],i[i.length-1],r[r.length-1]);h.push(p)}}e.push(h)}var f=this.textStyles.default.tagStyle;return e[e.length-1].map(function(t){t.text.includes(o[f][0])&&(t.text=t.text.match(f===n?/^(.*)\[/:/^(.*)\</)[1])}),e},i.prototype.getFontString=function(t){return new PIXI.TextStyle(t).toFontString()},i.prototype.createTextData=function(t,e,n){return{text:t,style:e,width:0,height:0,fontProperties:void 0,tag:n}},i.prototype.getDropShadowPadding=function(){var t=this,e=0,n=0;return Object.keys(this.textStyles).forEach(function(o){var s=t.textStyles[o],i=s.dropShadowBlur;e=Math.max(e,s.dropShadowDistance||0),n=Math.max(n,i||0)}),e+n},i.prototype.updateText=function(){var t=this;if(this.dirty){this.hitboxes=[],this.texture.baseTexture.resolution=this.resolution;var e=this.textStyles,n=this.text;this._style.wordWrap&&(n=this.wordWrap(this.text));for(var o=n.split(/(?:\r\n|\r|\n)/),s=this._getTextDataPerLine(o),r=[],a=[],h=[],l=0,c=0;c<o.length;c++){for(var x=0,d=0,g=0,u=0;u<s[c].length;u++){var p=s[c][u].style;this.context.font=this.getFontString(p),s[c][u].width=this.context.measureText(s[c][u].text).width,0!==s[c][u].text.length&&(s[c][u].width+=(s[c][u].text.length-1)*p.letterSpacing,u>0&&(x+=p.letterSpacing/2),u<s[c].length-1&&(x+=p.letterSpacing/2)),x+=s[c][u].width,s[c][u].fontProperties=PIXI.TextMetrics.measureFont(this.context.font),s[c][u].height=s[c][u].fontProperties.fontSize,"number"==typeof p.valign?(d=Math.min(d,p.valign-s[c][u].fontProperties.descent),g=Math.max(g,p.valign+s[c][u].fontProperties.ascent)):(d=Math.min(d,-s[c][u].fontProperties.descent),g=Math.max(g,s[c][u].fontProperties.ascent))}r[c]=x,a[c]=d,h[c]=g,l=Math.max(l,x)}var f=Object.keys(e).map(function(t){return e[t]}).reduce(function(t,e){return Math.max(t,e.strokeThickness||0)},0),y=this.getDropShadowPadding(),S=l+2*f+2*y,b=h.reduce(function(t,e){return t+e},0)-a.reduce(function(t,e){return t+e},0)+2*f+2*y;this.canvas.width=S*this.resolution,this.canvas.height=b*this.resolution,this.context.scale(this.resolution,this.resolution),this.context.textBaseline="alphabetic",this.context.lineJoin="round";var v=y+f,w=[];for(c=0;c<s.length;c++){var m=s[c],T=void 0;switch(this._style.align){case"left":T=y+f;break;case"center":T=y+f+(l-r[c])/2;break;case"right":T=y+f+l-r[c]}for(u=0;u<m.length;u++){var k=m[u],P=k.style,_=k.text,I=k.fontProperties,O=k.width,A=k.tag,F=v+I.ascent;switch(P.valign){case"top":break;case"baseline":F+=h[c]-I.ascent;break;case"middle":F+=(h[c]-a[c]-I.ascent-I.descent)/2;break;case"bottom":F+=h[c]-a[c]-I.ascent-I.descent;break;default:F+=h[c]-I.ascent-P.valign}if(0===P.letterSpacing)w.push({text:_,style:P,x:T,y:F,width:O,ascent:I.ascent,descent:I.descent,tag:A}),T+=m[u].width;else{this.context.font=this.getFontString(m[u].style);for(var E=0;E<_.length;E++){(E>0||u>0)&&(T+=P.letterSpacing/2);var D=this.context.measureText(_.charAt(E)).width;w.push({text:_.charAt(E),style:P,x:T,y:F,width:D,ascent:I.ascent,descent:I.descent,tag:A}),T+=D,(E<_.length-1||u<m.length-1)&&(T+=P.letterSpacing/2)}}}v+=h[c]-a[c]}this.context.save(),w.forEach(function(e){var n=e.style,o=e.text,s=e.x,i=e.y;if(n.dropShadow){t.context.font=t.getFontString(n);var r=n.dropShadowColor;"number"==typeof r&&(r=PIXI.utils.hex2string(r)),t.context.shadowColor=r,t.context.shadowBlur=n.dropShadowBlur,t.context.shadowOffsetX=Math.cos(n.dropShadowAngle)*n.dropShadowDistance*t.resolution,t.context.shadowOffsetY=Math.sin(n.dropShadowAngle)*n.dropShadowDistance*t.resolution,t.context.fillText(o,s,i)}}),this.context.restore(),w.forEach(function(e){var n=e.style,o=e.text,s=e.x,i=e.y;if(void 0!==n.stroke&&n.strokeThickness){t.context.font=t.getFontString(n);var r=n.stroke;"number"==typeof r&&(r=PIXI.utils.hex2string(r)),t.context.strokeStyle=r,t.context.lineWidth=n.strokeThickness,t.context.strokeText(o,s,i)}}),w.forEach(function(e){var n=e.style,o=e.text,s=e.x,i=e.y;if(void 0!==n.fill){t.context.font=t.getFontString(n);var r=n.fill;if("number"==typeof r)r=PIXI.utils.hex2string(r);else if(Array.isArray(r))for(var a=0;a<r.length;a++){var h=r[a];"number"==typeof h&&(r[a]=PIXI.utils.hex2string(h))}t.context.fillStyle=t._generateFillStyle(new PIXI.TextStyle(n),[o]),t.context.fillText(o,s,i)}}),w.forEach(function(e){var n=e.style,o=e.x,s=e.y,r=e.width,a=e.ascent,h=e.descent,l=e.tag,c=-t._style.padding-t.getDropShadowPadding();t.hitboxes.push({tag:l,hitbox:new PIXI.Rectangle(o+c,s-a+c,r,a+h)}),(void 0===n.debug?i.debugOptions.spans.enabled:n.debug)&&(t.context.lineWidth=1,i.debugOptions.spans.bounding&&(t.context.fillStyle=i.debugOptions.spans.bounding,t.context.strokeStyle=i.debugOptions.spans.bounding,t.context.beginPath(),t.context.rect(o,s-a,r,a+h),t.context.fill(),t.context.stroke(),t.context.stroke()),i.debugOptions.spans.baseline&&(t.context.strokeStyle=i.debugOptions.spans.baseline,t.context.beginPath(),t.context.moveTo(o,s),t.context.lineTo(o+r,s),t.context.closePath(),t.context.stroke()),i.debugOptions.spans.top&&(t.context.strokeStyle=i.debugOptions.spans.top,t.context.beginPath(),t.context.moveTo(o,s-a),t.context.lineTo(o+r,s-a),t.context.closePath(),t.context.stroke()),i.debugOptions.spans.bottom&&(t.context.strokeStyle=i.debugOptions.spans.bottom,t.context.beginPath(),t.context.moveTo(o,s+h),t.context.lineTo(o+r,s+h),t.context.closePath(),t.context.stroke()),i.debugOptions.spans.text&&(t.context.fillStyle="#ffffff",t.context.strokeStyle="#000000",t.context.lineWidth=2,t.context.font="8px monospace",t.context.strokeText(l.name,o,s-a+8),t.context.fillText(l.name,o,s-a+8),t.context.strokeText(r.toFixed(2)+"x"+(a+h).toFixed(2),o,s-a+16),t.context.fillText(r.toFixed(2)+"x"+(a+h).toFixed(2),o,s-a+16)))}),i.debugOptions.objects.enabled&&(i.debugOptions.objects.bounding&&(this.context.fillStyle=i.debugOptions.objects.bounding,this.context.beginPath(),this.context.rect(0,0,S,b),this.context.fill()),i.debugOptions.objects.text&&(this.context.fillStyle="#ffffff",this.context.strokeStyle="#000000",this.context.lineWidth=2,this.context.font="8px monospace",this.context.strokeText(S.toFixed(2)+"x"+b.toFixed(2),0,8,S),this.context.fillText(S.toFixed(2)+"x"+b.toFixed(2),0,8,S))),this.updateTexture()}},i.prototype.wordWrap=function(t){var e="",n=this.getTagRegex(!0,!0),o=t.split("\n"),s=this._style.wordWrapWidth,i=[this.assign({},this.textStyles.default)];this.context.font=this.getFontString(this.textStyles.default);for(var r=0;r<o.length;r++){for(var a=s,h=o[r].split(n),l=!0,c=0;c<h.length;c++)if(n.test(h[c]))e+=h[c],"/"===h[c][1]?(c+=2,i.pop()):(i.push(this.assign({},i[i.length-1],this.textStyles[h[++c]])),c++),this.context.font=this.getFontString(i[i.length-1]);else for(var x=h[c].split(" "),d=0;d<x.length;d++){var g=this.context.measureText(x[d]).width;if(this._style.breakWords&&g>a){var u=x[d].split("");d>0&&(e+=" ",a-=this.context.measureText(" ").width);for(var p=0;p<u.length;p++){var f=this.context.measureText(u[p]).width;f>a?(e+="\n"+u[p],a=s-f):(e+=u[p],a-=f)}}else if(this._style.breakWords)e+=x[d],a-=g;else{var y=g+(d>0?this.context.measureText(" ").width:0);y>a?(l||(e+="\n"),e+=x[d],a=s-g):(a-=y,d>0&&(e+=" "),e+=x[d])}l=!1}r<o.length-1&&(e+="\n")}return e},i.prototype.updateTexture=function(){var t=this._texture,e=this.getDropShadowPadding();t.baseTexture.hasLoaded=!0,t.baseTexture.resolution=this.resolution,t.baseTexture.realWidth=this.canvas.width,t.baseTexture.realHeight=this.canvas.height,t.baseTexture.width=this.canvas.width/this.resolution,t.baseTexture.height=this.canvas.height/this.resolution,t.trim.width=t.frame.width=this.canvas.width/this.resolution,t.trim.height=t.frame.height=this.canvas.height/this.resolution,t.trim.x=-this._style.padding-e,t.trim.y=-this._style.padding-e,t.orig.width=t.frame.width-2*(this._style.padding+e),t.orig.height=t.frame.height-2*(this._style.padding+e),this._onTextureUpdate(),t.baseTexture.emit("update",t.baseTexture),this.dirty=!1},i.prototype.assign=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var o=0,s=e;o<s.length;o++){var i=s[o];for(var r in i)t[r]=i[r]}return t},i.DEFAULT_TAG_STYLE={align:"left",breakWords:!1,dropShadow:!1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"#000000",dropShadowDistance:5,fill:"black",fillGradientType:PIXI.TEXT_GRADIENT.LINEAR_VERTICAL,fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",valign:"baseline",wordWrap:!1,wordWrapWidth:100,tagStyle:"xml"},i.debugOptions={spans:{enabled:!1,baseline:"#44BB44",top:"#BB4444",bottom:"#4444BB",bounding:"rgba(255, 255, 255, 0.1)",text:!0},objects:{enabled:!1,bounding:"rgba(255, 255, 255, 0.05)",text:!0}},i}(PIXI.Text));
var t=["pointerover","pointerenter","pointerdown","pointermove","pointerup","pointercancel","pointerout","pointerleave","gotpointercapture","lostpointercapture","mouseover","mouseenter","mousedown","mousemove","mouseup","mousecancel","mouseout","mouseleave","touchover","touchenter","touchdown","touchmove","touchup","touchcancel","touchout","touchleave"],e={bbcode:["[","]"],xml:["<",">"]},i=function(i){function s(e,s){var o=this;i.call(this,e),this.styles=s,t.forEach(function(t){o.on(t,function(t){return o.handleInteraction(t)})})}i&&(s.__proto__=i),(s.prototype=Object.create(i&&i.prototype)).constructor=s;var o={styles:{configurable:!0}};return s.prototype.handleInteraction=function(t){var e=t,i=t.data.getLocalPosition(this),s=this.hitboxes.reduce(function(t,e){return void 0!==t?t:e.hitbox.contains(i.x,i.y)?e:void 0},void 0);e.targetTag=void 0===s?void 0:s.tag},o.styles.set=function(t){for(var e in this.textStyles={},this.textStyles.default=this.assign({},s.DEFAULT_TAG_STYLE),t)"default"===e?this.assign(this.textStyles.default,t[e]):this.textStyles[e]=this.assign({},t[e]);"bbcode"===this.textStyles.default.tagStyle&&(this.textStyles.b=this.assign({},{fontStyle:"bold"}),this.textStyles.i=this.assign({},{fontStyle:"italic"}),this.textStyles.color=this.assign({},{fill:""}),this.textStyles.outline=this.assign({},{stroke:"",strokeThickness:6}),this.textStyles.font=this.assign({},{fontFamily:""}),this.textStyles.shadow=this.assign({},{dropShadowColor:"",dropShadow:!0,dropShadowBlur:3,dropShadowDistance:3,dropShadowAngle:2}),this.textStyles.size=this.assign({},{fontSize:"px"}),this.textStyles.spacing=this.assign({},{letterSpacing:""}),this.textStyles.align=this.assign({},{align:""})),this.withPrivateMembers()._style=new PIXI.TextStyle(this.textStyles.default),this.withPrivateMembers().dirty=!0},s.prototype.setTagStyle=function(t,e){t in this.textStyles?this.assign(this.textStyles[t],e):this.textStyles[t]=this.assign({},e),this.withPrivateMembers()._style=new PIXI.TextStyle(this.textStyles.default),this.withPrivateMembers().dirty=!0},s.prototype.deleteTagStyle=function(t){"default"===t?this.textStyles.default=this.assign({},s.DEFAULT_TAG_STYLE):delete this.textStyles[t],this.withPrivateMembers()._style=new PIXI.TextStyle(this.textStyles.default),this.withPrivateMembers().dirty=!0},s.prototype.getTagRegex=function(t,i){var s=Object.keys(this.textStyles).join("|");s=t?"("+s+")":"(?:"+s+")";var o="bbcode"===this.textStyles.default.tagStyle?"\\"+e.bbcode[0]+s+"(?:\\=(?:[A-Za-z0-9_\\-\\#]+|'(?:[^']+|\\\\')*'))*\\s*\\"+e.bbcode[1]+"|\\"+e.bbcode[0]+"\\/"+s+"\\s*\\"+e.bbcode[1]:"\\"+e.xml[0]+s+"(?:\\s+[A-Za-z0-9_\\-]+=(?:\"(?:[^\"]+|\\\\\")*\"|'(?:[^']+|\\\\')*'))*\\s*\\"+e.xml[1]+"|\\"+e.xml[0]+"\\/"+s+"\\s*\\"+e.xml[1];return i&&(o="("+o+")"),new RegExp(o,"g")},s.prototype.getPropertyRegex=function(){return new RegExp("([A-Za-z0-9_\\-]+)=(?:\"((?:[^\"]+|\\\\\")*)\"|'((?:[^']+|\\\\')*)')","g")},s.prototype.getBBcodePropertyRegex=function(){return new RegExp("[A-Za-z0-9_\\-]+=([A-Za-z0-9_\\-\\#]+)","g")},s.prototype._getTextDataPerLine=function(t){for(var i=[],s=this.getTagRegex(!0,!1),o=[this.assign({},this.textStyles.default)],n=[{name:"default",properties:{}}],r=0;r<t.length;r++){for(var a=[],h=[],l=void 0;l=s.exec(t[r]);)h.push(l);if(0===h.length)a.push(this.createTextData(t[r],o[o.length-1],n[n.length-1]));else{for(var c=0,x=0;x<h.length;x++){if(h[x].index>c&&a.push(this.createTextData(t[r].substring(c,h[x].index),o[o.length-1],n[n.length-1])),"/"===h[x][0][1])o.length>1&&(o.pop(),n.pop());else{for(var d={},g=this.getPropertyRegex(),p=void 0;p=g.exec(h[x][0]);)d[p[1]]=p[2]||p[3];if(n.push({name:h[x][1],properties:d}),"bbcode"===this.textStyles.default.tagStyle&&h[x][0].includes("=")&&this.textStyles[h[x][1]]){var u=this.getBBcodePropertyRegex().exec(h[x][0]),f={};Object.entries(this.textStyles[h[x][1]]).forEach(function(t){f[t[0]]="string"!=typeof t[1]?t[1]:u[1]+t[1]}),o.push(this.assign({},o[o.length-1],f))}else o.push(this.assign({},o[o.length-1],this.textStyles[h[x][1]]))}c=h[x].index+h[x][0].length}if(c<t[r].length){var y=this.createTextData(c?t[r].substring(c):t[r],o[o.length-1],n[n.length-1]);a.push(y)}}i.push(a)}var b=this.textStyles.default.tagStyle;return i[i.length-1].map(function(t){t.text.includes(e[b][0])&&(t.text=t.text.match("bbcode"===b?/^(.*)\[/:/^(.*)\</)[1])}),i},s.prototype.getFontString=function(t){return new PIXI.TextStyle(t).toFontString()},s.prototype.createTextData=function(t,e,i){return{text:t,style:e,width:0,height:0,fontProperties:void 0,tag:i}},s.prototype.getDropShadowPadding=function(){var t=this,e=0,i=0;return Object.keys(this.textStyles).forEach(function(s){var o=t.textStyles[s],n=o.dropShadowBlur;e=Math.max(e,o.dropShadowDistance||0),i=Math.max(i,n||0)}),e+i},s.prototype.withPrivateMembers=function(){return this},s.prototype.updateText=function(){var t=this;if(this.withPrivateMembers().dirty){this.hitboxes=[],this.texture.baseTexture.resolution=this.resolution;var e=this.textStyles,i=this.text;this.withPrivateMembers()._style.wordWrap&&(i=this.wordWrap(this.text));for(var o=i.split(/(?:\r\n|\r|\n)/),n=this._getTextDataPerLine(o),r=[],a=[],h=[],l=0,c=0;c<o.length;c++){for(var x=0,d=0,g=0,p=0;p<n[c].length;p++){var u=n[c][p].style;this.context.font=this.getFontString(u),n[c][p].width=this.context.measureText(n[c][p].text).width,0!==n[c][p].text.length&&(n[c][p].width+=(n[c][p].text.length-1)*u.letterSpacing,p>0&&(x+=u.letterSpacing/2),p<n[c].length-1&&(x+=u.letterSpacing/2)),x+=n[c][p].width,n[c][p].fontProperties=PIXI.TextMetrics.measureFont(this.context.font),n[c][p].height=n[c][p].fontProperties.fontSize,"number"==typeof u.valign?(d=Math.min(d,u.valign-n[c][p].fontProperties.descent),g=Math.max(g,u.valign+n[c][p].fontProperties.ascent)):(d=Math.min(d,-n[c][p].fontProperties.descent),g=Math.max(g,n[c][p].fontProperties.ascent))}r[c]=x,a[c]=d,h[c]=g,l=Math.max(l,x)}var f=Object.keys(e).map(function(t){return e[t]}).reduce(function(t,e){return Math.max(t,e.strokeThickness||0)},0),y=this.getDropShadowPadding(),b=l+2*f+2*y,S=h.reduce(function(t,e){return t+e},0)-a.reduce(function(t,e){return t+e},0)+2*f+2*y;this.canvas.width=b*this.resolution,this.canvas.height=S*this.resolution,this.context.scale(this.resolution,this.resolution),this.context.textBaseline="alphabetic",this.context.lineJoin="round";for(var v=y+f,m=[],w=0;w<n.length;w++){var T=n[w],P=void 0;switch(this.withPrivateMembers()._style.align){case"left":P=y+f;break;case"center":P=y+f+(l-r[w])/2;break;case"right":P=y+f+l-r[w]}for(var k=0;k<T.length;k++){var _=T[k],M=_.style,I=_.text,F=_.fontProperties,O=_.width,A=_.tag,E=v+F.ascent;switch(M.valign){case"top":break;case"baseline":E+=h[w]-F.ascent;break;case"middle":E+=(h[w]-a[w]-F.ascent-F.descent)/2;break;case"bottom":E+=h[w]-a[w]-F.ascent-F.descent;break;default:E+=h[w]-F.ascent-M.valign}if(0===M.letterSpacing)m.push({text:I,style:M,x:P,y:E,width:O,ascent:F.ascent,descent:F.descent,tag:A}),P+=T[k].width;else{this.context.font=this.getFontString(T[k].style);for(var D=0;D<I.length;D++){(D>0||k>0)&&(P+=M.letterSpacing/2);var B=this.context.measureText(I.charAt(D)).width;m.push({text:I.charAt(D),style:M,x:P,y:E,width:B,ascent:F.ascent,descent:F.descent,tag:A}),P+=B,(D<I.length-1||k<T.length-1)&&(P+=M.letterSpacing/2)}}}v+=h[w]-a[w]}this.context.save(),m.forEach(function(e){var i=e.style,s=e.text,o=e.x,n=e.y;if(i.dropShadow){t.context.font=t.getFontString(i);var r=i.dropShadowColor;"number"==typeof r&&(r=PIXI.utils.hex2string(r)),t.context.shadowColor=r,t.context.shadowBlur=i.dropShadowBlur,t.context.shadowOffsetX=Math.cos(i.dropShadowAngle)*i.dropShadowDistance*t.resolution,t.context.shadowOffsetY=Math.sin(i.dropShadowAngle)*i.dropShadowDistance*t.resolution,t.context.fillText(s,o,n)}}),this.context.restore(),m.forEach(function(e){var i=e.style,s=e.text,o=e.x,n=e.y;if(void 0!==i.stroke&&i.strokeThickness){t.context.font=t.getFontString(i);var r=i.stroke;"number"==typeof r&&(r=PIXI.utils.hex2string(r)),t.context.strokeStyle=r,t.context.lineWidth=i.strokeThickness,t.context.strokeText(s,o,n)}}),m.forEach(function(e){var i=e.style,s=e.text,o=e.x,n=e.y;if(void 0!==i.fill){t.context.font=t.getFontString(i);var r=i.fill;if("number"==typeof r)r=PIXI.utils.hex2string(r);else if(Array.isArray(r))for(var a=0;a<r.length;a++){var h=r[a];"number"==typeof h&&(r[a]=PIXI.utils.hex2string(h))}t.context.fillStyle=t._generateFillStyle(new PIXI.TextStyle(i),[s]),t.context.fillText(s,o,n)}}),m.forEach(function(e){var i=e.style,o=e.x,n=e.y,r=e.width,a=e.ascent,h=e.descent,l=e.tag,c=-t.withPrivateMembers()._style.padding-t.getDropShadowPadding();t.hitboxes.push({tag:l,hitbox:new PIXI.Rectangle(o+c,n-a+c,r,a+h)}),(void 0===i.debug?s.debugOptions.spans.enabled:i.debug)&&(t.context.lineWidth=1,s.debugOptions.spans.bounding&&(t.context.fillStyle=s.debugOptions.spans.bounding,t.context.strokeStyle=s.debugOptions.spans.bounding,t.context.beginPath(),t.context.rect(o,n-a,r,a+h),t.context.fill(),t.context.stroke(),t.context.stroke()),s.debugOptions.spans.baseline&&(t.context.strokeStyle=s.debugOptions.spans.baseline,t.context.beginPath(),t.context.moveTo(o,n),t.context.lineTo(o+r,n),t.context.closePath(),t.context.stroke()),s.debugOptions.spans.top&&(t.context.strokeStyle=s.debugOptions.spans.top,t.context.beginPath(),t.context.moveTo(o,n-a),t.context.lineTo(o+r,n-a),t.context.closePath(),t.context.stroke()),s.debugOptions.spans.bottom&&(t.context.strokeStyle=s.debugOptions.spans.bottom,t.context.beginPath(),t.context.moveTo(o,n+h),t.context.lineTo(o+r,n+h),t.context.closePath(),t.context.stroke()),s.debugOptions.spans.text&&(t.context.fillStyle="#ffffff",t.context.strokeStyle="#000000",t.context.lineWidth=2,t.context.font="8px monospace",t.context.strokeText(l.name,o,n-a+8),t.context.fillText(l.name,o,n-a+8),t.context.strokeText(r.toFixed(2)+"x"+(a+h).toFixed(2),o,n-a+16),t.context.fillText(r.toFixed(2)+"x"+(a+h).toFixed(2),o,n-a+16)))}),s.debugOptions.objects.enabled&&(s.debugOptions.objects.bounding&&(this.context.fillStyle=s.debugOptions.objects.bounding,this.context.beginPath(),this.context.rect(0,0,b,S),this.context.fill()),s.debugOptions.objects.text&&(this.context.fillStyle="#ffffff",this.context.strokeStyle="#000000",this.context.lineWidth=2,this.context.font="8px monospace",this.context.strokeText(b.toFixed(2)+"x"+S.toFixed(2),0,8,b),this.context.fillText(b.toFixed(2)+"x"+S.toFixed(2),0,8,b))),this.updateTexture()}},s.prototype.wordWrap=function(t){var e="",i=this.getTagRegex(!0,!0),s=t.split("\n"),o=this.withPrivateMembers()._style.wordWrapWidth,n=[this.assign({},this.textStyles.default)];this.context.font=this.getFontString(this.textStyles.default);for(var r=0;r<s.length;r++){for(var a=o,h=s[r].split(i),l=!0,c=0;c<h.length;c++)if(i.test(h[c]))e+=h[c],"/"===h[c][1]?(c+=2,n.pop()):(n.push(this.assign({},n[n.length-1],this.textStyles[h[++c]])),c++),this.context.font=this.getFontString(n[n.length-1]);else for(var x=h[c].split(" "),d=0;d<x.length;d++){var g=this.context.measureText(x[d]).width;if(this.withPrivateMembers()._style.breakWords&&g>a){var p=x[d].split("");d>0&&(e+=" ",a-=this.context.measureText(" ").width);for(var u=0;u<p.length;u++){var f=this.context.measureText(p[u]).width;f>a?(e+="\n"+p[u],a=o-f):(e+=p[u],a-=f)}}else if(this.withPrivateMembers()._style.breakWords)e+=x[d],a-=g;else{var y=g+(d>0?this.context.measureText(" ").width:0);y>a?(l||(e+="\n"),e+=x[d],a=o-g):(a-=y,d>0&&(e+=" "),e+=x[d])}l=!1}r<s.length-1&&(e+="\n")}return e},s.prototype.updateTexture=function(){var t=this.withPrivateMembers()._texture,e=this.getDropShadowPadding();t.baseTexture.setRealSize(this.canvas.width,this.canvas.height,this.resolution),t.trim.width=t.frame.width=this.canvas.width/this.resolution,t.trim.height=t.frame.height=this.canvas.height/this.resolution,t.trim.x=-this.withPrivateMembers()._style.padding-e,t.trim.y=-this.withPrivateMembers()._style.padding-e,t.orig.width=t.frame.width-2*(this.withPrivateMembers()._style.padding+e),t.orig.height=t.frame.height-2*(this.withPrivateMembers()._style.padding+e),this.withPrivateMembers()._onTextureUpdate(),t.baseTexture.emit("update",t.baseTexture),this.withPrivateMembers().dirty=!1},s.prototype.assign=function(t){for(var e=[],i=arguments.length-1;i-- >0;)e[i]=arguments[i+1];for(var s=0,o=e;s<o.length;s+=1){var n=o[s];for(var r in n)t[r]=n[r]}return t},Object.defineProperties(s.prototype,o),s}(PIXI.Text);i.DEFAULT_TAG_STYLE={align:"left",breakWords:!1,dropShadow:!1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"#000000",dropShadowDistance:5,fill:"black",fillGradientType:PIXI.TEXT_GRADIENT.LINEAR_VERTICAL,fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",valign:"baseline",wordWrap:!1,wordWrapWidth:100,tagStyle:"xml"},i.debugOptions={spans:{enabled:!1,baseline:"#44BB44",top:"#BB4444",bottom:"#4444BB",bounding:"rgba(255, 255, 255, 0.1)",text:!0},objects:{enabled:!1,bounding:"rgba(255, 255, 255, 0.05)",text:!0}};export default i;
//# sourceMappingURL=pixi-multistyle-text.m.js.map

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.MultiStyleText=e()}(this,function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};var e=["pointerover","pointerenter","pointerdown","pointermove","pointerup","pointercancel","pointerout","pointerleave","gotpointercapture","lostpointercapture","mouseover","mouseenter","mousedown","mousemove","mouseup","mousecancel","mouseout","mouseleave","touchover","touchenter","touchdown","touchmove","touchup","touchcancel","touchout","touchleave"],n="bbcode",o={bbcode:["[","]"],xml:["<",">"]};return function(i){function s(t,n){var o=i.call(this,t)||this;return o.styles=n,e.forEach(function(t){o.on(t,function(t){return o.handleInteraction(t)})}),o}return function(e,n){function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}(s,i),s.prototype.handleInteraction=function(t){var e=t,n=t.data.getLocalPosition(this),o=this.hitboxes.reduce(function(t,e){return void 0!==t?t:e.hitbox.contains(n.x,n.y)?e:void 0},void 0);e.targetTag=void 0===o?void 0:o.tag},Object.defineProperty(s.prototype,"styles",{set:function(t){for(var e in this.textStyles={},this.textStyles.default=this.assign({},s.DEFAULT_TAG_STYLE),t)"default"===e?this.assign(this.textStyles.default,t[e]):this.textStyles[e]=this.assign({},t[e]);this.textStyles.default.tagStyle===n&&(this.textStyles.b=this.assign({},{fontStyle:"bold"}),this.textStyles.i=this.assign({},{fontStyle:"italic"}),this.textStyles.color=this.assign({},{fill:""}),this.textStyles.outline=this.assign({},{stroke:"",strokeThickness:6}),this.textStyles.font=this.assign({},{fontFamily:""}),this.textStyles.shadow=this.assign({},{dropShadowColor:"",dropShadow:!0,dropShadowBlur:3,dropShadowDistance:3,dropShadowAngle:2}),this.textStyles.size=this.assign({},{fontSize:"px"}),this.textStyles.spacing=this.assign({},{letterSpacing:""}),this.textStyles.align=this.assign({},{align:""})),this._style=new PIXI.TextStyle(this.textStyles.default),this.dirty=!0},enumerable:!0,configurable:!0}),s.prototype.setTagStyle=function(t,e){t in this.textStyles?this.assign(this.textStyles[t],e):this.textStyles[t]=this.assign({},e),this._style=new PIXI.TextStyle(this.textStyles.default),this.dirty=!0},s.prototype.deleteTagStyle=function(t){"default"===t?this.textStyles.default=this.assign({},s.DEFAULT_TAG_STYLE):delete this.textStyles[t],this._style=new PIXI.TextStyle(this.textStyles.default),this.dirty=!0},s.prototype.getTagRegex=function(t,e){var i=Object.keys(this.textStyles).join("|");i=t?"("+i+")":"(?:"+i+")";var s=this.textStyles.default.tagStyle===n?"\\"+o.bbcode[0]+i+"(?:\\=(?:[A-Za-z0-9_\\-\\#]+|'(?:[^']+|\\\\')*'))*\\s*\\"+o.bbcode[1]+"|\\"+o.bbcode[0]+"\\/"+i+"\\s*\\"+o.bbcode[1]:"\\"+o.xml[0]+i+"(?:\\s+[A-Za-z0-9_\\-]+=(?:\"(?:[^\"]+|\\\\\")*\"|'(?:[^']+|\\\\')*'))*\\s*\\"+o.xml[1]+"|\\"+o.xml[0]+"\\/"+i+"\\s*\\"+o.xml[1];return e&&(s="("+s+")"),new RegExp(s,"g")},s.prototype.getPropertyRegex=function(){return new RegExp("([A-Za-z0-9_\\-]+)=(?:\"((?:[^\"]+|\\\\\")*)\"|'((?:[^']+|\\\\')*)')","g")},s.prototype.getBBcodePropertyRegex=function(){return new RegExp("[A-Za-z0-9_\\-]+=([A-Za-z0-9_\\-\\#]+)","g")},s.prototype._getTextDataPerLine=function(t){for(var e=[],i=this.getTagRegex(!0,!1),s=[this.assign({},this.textStyles.default)],r=[{name:"default",properties:{}}],a=0;a<t.length;a++){for(var h=[],l=[],c=void 0;c=i.exec(t[a]);)l.push(c);if(0===l.length)h.push(this.createTextData(t[a],s[s.length-1],r[r.length-1]));else{for(var x=0,d=function(e){if(l[e].index>x&&h.push(g.createTextData(t[a].substring(x,l[e].index),s[s.length-1],r[r.length-1])),"/"===l[e][0][1])s.length>1&&(s.pop(),r.pop());else{for(var o={},i=g.getPropertyRegex(),c=void 0;c=i.exec(l[e][0]);)o[c[1]]=c[2]||c[3];if(r.push({name:l[e][1],properties:o}),g.textStyles.default.tagStyle===n&&l[e][0].includes("=")&&g.textStyles[l[e][1]]){var d=g.getBBcodePropertyRegex().exec(l[e][0]),u={};Object.entries(g.textStyles[l[e][1]]).forEach(function(t){u[t[0]]="string"!=typeof t[1]?t[1]:d[1]+t[1]}),s.push(g.assign({},s[s.length-1],u))}else s.push(g.assign({},s[s.length-1],g.textStyles[l[e][1]]))}x=l[e].index+l[e][0].length},g=this,u=0;u<l.length;u++)d(u);if(x<t[a].length){var p=this.createTextData(x?t[a].substring(x):t[a],s[s.length-1],r[r.length-1]);h.push(p)}}e.push(h)}var f=this.textStyles.default.tagStyle;return e[e.length-1].map(function(t){t.text.includes(o[f][0])&&(t.text=t.text.match(f===n?/^(.*)\[/:/^(.*)\</)[1])}),e},s.prototype.getFontString=function(t){return new PIXI.TextStyle(t).toFontString()},s.prototype.createTextData=function(t,e,n){return{text:t,style:e,width:0,height:0,fontProperties:void 0,tag:n}},s.prototype.getDropShadowPadding=function(){var t=this,e=0,n=0;return Object.keys(this.textStyles).forEach(function(o){var i=t.textStyles[o],s=i.dropShadowBlur;e=Math.max(e,i.dropShadowDistance||0),n=Math.max(n,s||0)}),e+n},s.prototype.updateText=function(){var t=this;if(this.dirty){this.hitboxes=[],this.texture.baseTexture.resolution=this.resolution;var e=this.textStyles,n=this.text;this._style.wordWrap&&(n=this.wordWrap(this.text));for(var o=n.split(/(?:\r\n|\r|\n)/),i=this._getTextDataPerLine(o),r=[],a=[],h=[],l=0,c=0;c<o.length;c++){for(var x=0,d=0,g=0,u=0;u<i[c].length;u++){var p=i[c][u].style;this.context.font=this.getFontString(p),i[c][u].width=this.context.measureText(i[c][u].text).width,0!==i[c][u].text.length&&(i[c][u].width+=(i[c][u].text.length-1)*p.letterSpacing,u>0&&(x+=p.letterSpacing/2),u<i[c].length-1&&(x+=p.letterSpacing/2)),x+=i[c][u].width,i[c][u].fontProperties=PIXI.TextMetrics.measureFont(this.context.font),i[c][u].height=i[c][u].fontProperties.fontSize,"number"==typeof p.valign?(d=Math.min(d,p.valign-i[c][u].fontProperties.descent),g=Math.max(g,p.valign+i[c][u].fontProperties.ascent)):(d=Math.min(d,-i[c][u].fontProperties.descent),g=Math.max(g,i[c][u].fontProperties.ascent))}r[c]=x,a[c]=d,h[c]=g,l=Math.max(l,x)}var f=Object.keys(e).map(function(t){return e[t]}).reduce(function(t,e){return Math.max(t,e.strokeThickness||0)},0),y=this.getDropShadowPadding(),S=l+2*f+2*y,b=h.reduce(function(t,e){return t+e},0)-a.reduce(function(t,e){return t+e},0)+2*f+2*y;this.canvas.width=S*this.resolution,this.canvas.height=b*this.resolution,this.context.scale(this.resolution,this.resolution),this.context.textBaseline="alphabetic",this.context.lineJoin="round";var v=y+f,m=[];for(c=0;c<i.length;c++){var w=i[c],T=void 0;switch(this._style.align){case"left":T=y+f;break;case"center":T=y+f+(l-r[c])/2;break;case"right":T=y+f+l-r[c]}for(u=0;u<w.length;u++){var k=w[u],P=k.style,_=k.text,I=k.fontProperties,O=k.width,A=k.tag,F=v+I.ascent;switch(P.valign){case"top":break;case"baseline":F+=h[c]-I.ascent;break;case"middle":F+=(h[c]-a[c]-I.ascent-I.descent)/2;break;case"bottom":F+=h[c]-a[c]-I.ascent-I.descent;break;default:F+=h[c]-I.ascent-P.valign}if(0===P.letterSpacing)m.push({text:_,style:P,x:T,y:F,width:O,ascent:I.ascent,descent:I.descent,tag:A}),T+=w[u].width;else{this.context.font=this.getFontString(w[u].style);for(var E=0;E<_.length;E++){(E>0||u>0)&&(T+=P.letterSpacing/2);var D=this.context.measureText(_.charAt(E)).width;m.push({text:_.charAt(E),style:P,x:T,y:F,width:D,ascent:I.ascent,descent:I.descent,tag:A}),T+=D,(E<_.length-1||u<w.length-1)&&(T+=P.letterSpacing/2)}}}v+=h[c]-a[c]}this.context.save(),m.forEach(function(e){var n=e.style,o=e.text,i=e.x,s=e.y;if(n.dropShadow){t.context.font=t.getFontString(n);var r=n.dropShadowColor;"number"==typeof r&&(r=PIXI.utils.hex2string(r)),t.context.shadowColor=r,t.context.shadowBlur=n.dropShadowBlur,t.context.shadowOffsetX=Math.cos(n.dropShadowAngle)*n.dropShadowDistance*t.resolution,t.context.shadowOffsetY=Math.sin(n.dropShadowAngle)*n.dropShadowDistance*t.resolution,t.context.fillText(o,i,s)}}),this.context.restore(),m.forEach(function(e){var n=e.style,o=e.text,i=e.x,s=e.y;if(void 0!==n.stroke&&n.strokeThickness){t.context.font=t.getFontString(n);var r=n.stroke;"number"==typeof r&&(r=PIXI.utils.hex2string(r)),t.context.strokeStyle=r,t.context.lineWidth=n.strokeThickness,t.context.strokeText(o,i,s)}}),m.forEach(function(e){var n=e.style,o=e.text,i=e.x,s=e.y;if(void 0!==n.fill){t.context.font=t.getFontString(n);var r=n.fill;if("number"==typeof r)r=PIXI.utils.hex2string(r);else if(Array.isArray(r))for(var a=0;a<r.length;a++){var h=r[a];"number"==typeof h&&(r[a]=PIXI.utils.hex2string(h))}t.context.fillStyle=t._generateFillStyle(new PIXI.TextStyle(n),[o]),t.context.fillText(o,i,s)}}),m.forEach(function(e){var n=e.style,o=e.x,i=e.y,r=e.width,a=e.ascent,h=e.descent,l=e.tag,c=-t._style.padding-t.getDropShadowPadding();t.hitboxes.push({tag:l,hitbox:new PIXI.Rectangle(o+c,i-a+c,r,a+h)}),(void 0===n.debug?s.debugOptions.spans.enabled:n.debug)&&(t.context.lineWidth=1,s.debugOptions.spans.bounding&&(t.context.fillStyle=s.debugOptions.spans.bounding,t.context.strokeStyle=s.debugOptions.spans.bounding,t.context.beginPath(),t.context.rect(o,i-a,r,a+h),t.context.fill(),t.context.stroke(),t.context.stroke()),s.debugOptions.spans.baseline&&(t.context.strokeStyle=s.debugOptions.spans.baseline,t.context.beginPath(),t.context.moveTo(o,i),t.context.lineTo(o+r,i),t.context.closePath(),t.context.stroke()),s.debugOptions.spans.top&&(t.context.strokeStyle=s.debugOptions.spans.top,t.context.beginPath(),t.context.moveTo(o,i-a),t.context.lineTo(o+r,i-a),t.context.closePath(),t.context.stroke()),s.debugOptions.spans.bottom&&(t.context.strokeStyle=s.debugOptions.spans.bottom,t.context.beginPath(),t.context.moveTo(o,i+h),t.context.lineTo(o+r,i+h),t.context.closePath(),t.context.stroke()),s.debugOptions.spans.text&&(t.context.fillStyle="#ffffff",t.context.strokeStyle="#000000",t.context.lineWidth=2,t.context.font="8px monospace",t.context.strokeText(l.name,o,i-a+8),t.context.fillText(l.name,o,i-a+8),t.context.strokeText(r.toFixed(2)+"x"+(a+h).toFixed(2),o,i-a+16),t.context.fillText(r.toFixed(2)+"x"+(a+h).toFixed(2),o,i-a+16)))}),s.debugOptions.objects.enabled&&(s.debugOptions.objects.bounding&&(this.context.fillStyle=s.debugOptions.objects.bounding,this.context.beginPath(),this.context.rect(0,0,S,b),this.context.fill()),s.debugOptions.objects.text&&(this.context.fillStyle="#ffffff",this.context.strokeStyle="#000000",this.context.lineWidth=2,this.context.font="8px monospace",this.context.strokeText(S.toFixed(2)+"x"+b.toFixed(2),0,8,S),this.context.fillText(S.toFixed(2)+"x"+b.toFixed(2),0,8,S))),this.updateTexture()}},s.prototype.wordWrap=function(t){var e="",n=this.getTagRegex(!0,!0),o=t.split("\n"),i=this._style.wordWrapWidth,s=[this.assign({},this.textStyles.default)];this.context.font=this.getFontString(this.textStyles.default);for(var r=0;r<o.length;r++){for(var a=i,h=o[r].split(n),l=!0,c=0;c<h.length;c++)if(n.test(h[c]))e+=h[c],"/"===h[c][1]?(c+=2,s.pop()):(s.push(this.assign({},s[s.length-1],this.textStyles[h[++c]])),c++),this.context.font=this.getFontString(s[s.length-1]);else for(var x=h[c].split(" "),d=0;d<x.length;d++){var g=this.context.measureText(x[d]).width;if(this._style.breakWords&&g>a){var u=x[d].split("");d>0&&(e+=" ",a-=this.context.measureText(" ").width);for(var p=0;p<u.length;p++){var f=this.context.measureText(u[p]).width;f>a?(e+="\n"+u[p],a=i-f):(e+=u[p],a-=f)}}else if(this._style.breakWords)e+=x[d],a-=g;else{var y=g+(d>0?this.context.measureText(" ").width:0);y>a?(l||(e+="\n"),e+=x[d],a=i-g):(a-=y,d>0&&(e+=" "),e+=x[d])}l=!1}r<o.length-1&&(e+="\n")}return e},s.prototype.updateTexture=function(){var t=this._texture,e=this.getDropShadowPadding();t.baseTexture.hasLoaded=!0,t.baseTexture.resolution=this.resolution,t.baseTexture.realWidth=this.canvas.width,t.baseTexture.realHeight=this.canvas.height,t.baseTexture.width=this.canvas.width/this.resolution,t.baseTexture.height=this.canvas.height/this.resolution,t.trim.width=t.frame.width=this.canvas.width/this.resolution,t.trim.height=t.frame.height=this.canvas.height/this.resolution,t.trim.x=-this._style.padding-e,t.trim.y=-this._style.padding-e,t.orig.width=t.frame.width-2*(this._style.padding+e),t.orig.height=t.frame.height-2*(this._style.padding+e),this._onTextureUpdate(),t.baseTexture.emit("update",t.baseTexture),this.dirty=!1},s.prototype.assign=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var o=0,i=e;o<i.length;o++){var s=i[o];for(var r in s)t[r]=s[r]}return t},s.DEFAULT_TAG_STYLE={align:"left",breakWords:!1,dropShadow:!1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"#000000",dropShadowDistance:5,fill:"black",fillGradientType:PIXI.TEXT_GRADIENT.LINEAR_VERTICAL,fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",valign:"baseline",wordWrap:!1,wordWrapWidth:100,tagStyle:"xml"},s.debugOptions={spans:{enabled:!1,baseline:"#44BB44",top:"#BB4444",bottom:"#4444BB",bounding:"rgba(255, 255, 255, 0.1)",text:!0},objects:{enabled:!1,bounding:"rgba(255, 255, 255, 0.05)",text:!0}},s}(PIXI.Text)});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.MultiStyleText=e()}(this,function(){var t=["pointerover","pointerenter","pointerdown","pointermove","pointerup","pointercancel","pointerout","pointerleave","gotpointercapture","lostpointercapture","mouseover","mouseenter","mousedown","mousemove","mouseup","mousecancel","mouseout","mouseleave","touchover","touchenter","touchdown","touchmove","touchup","touchcancel","touchout","touchleave"],e={bbcode:["[","]"],xml:["<",">"]},i=function(i){function s(e,s){var o=this;i.call(this,e),this.styles=s,t.forEach(function(t){o.on(t,function(t){return o.handleInteraction(t)})})}i&&(s.__proto__=i),(s.prototype=Object.create(i&&i.prototype)).constructor=s;var o={styles:{configurable:!0}};return s.prototype.handleInteraction=function(t){var e=t,i=t.data.getLocalPosition(this),s=this.hitboxes.reduce(function(t,e){return void 0!==t?t:e.hitbox.contains(i.x,i.y)?e:void 0},void 0);e.targetTag=void 0===s?void 0:s.tag},o.styles.set=function(t){for(var e in this.textStyles={},this.textStyles.default=this.assign({},s.DEFAULT_TAG_STYLE),t)"default"===e?this.assign(this.textStyles.default,t[e]):this.textStyles[e]=this.assign({},t[e]);"bbcode"===this.textStyles.default.tagStyle&&(this.textStyles.b=this.assign({},{fontStyle:"bold"}),this.textStyles.i=this.assign({},{fontStyle:"italic"}),this.textStyles.color=this.assign({},{fill:""}),this.textStyles.outline=this.assign({},{stroke:"",strokeThickness:6}),this.textStyles.font=this.assign({},{fontFamily:""}),this.textStyles.shadow=this.assign({},{dropShadowColor:"",dropShadow:!0,dropShadowBlur:3,dropShadowDistance:3,dropShadowAngle:2}),this.textStyles.size=this.assign({},{fontSize:"px"}),this.textStyles.spacing=this.assign({},{letterSpacing:""}),this.textStyles.align=this.assign({},{align:""})),this.withPrivateMembers()._style=new PIXI.TextStyle(this.textStyles.default),this.withPrivateMembers().dirty=!0},s.prototype.setTagStyle=function(t,e){t in this.textStyles?this.assign(this.textStyles[t],e):this.textStyles[t]=this.assign({},e),this.withPrivateMembers()._style=new PIXI.TextStyle(this.textStyles.default),this.withPrivateMembers().dirty=!0},s.prototype.deleteTagStyle=function(t){"default"===t?this.textStyles.default=this.assign({},s.DEFAULT_TAG_STYLE):delete this.textStyles[t],this.withPrivateMembers()._style=new PIXI.TextStyle(this.textStyles.default),this.withPrivateMembers().dirty=!0},s.prototype.getTagRegex=function(t,i){var s=Object.keys(this.textStyles).join("|");s=t?"("+s+")":"(?:"+s+")";var o="bbcode"===this.textStyles.default.tagStyle?"\\"+e.bbcode[0]+s+"(?:\\=(?:[A-Za-z0-9_\\-\\#]+|'(?:[^']+|\\\\')*'))*\\s*\\"+e.bbcode[1]+"|\\"+e.bbcode[0]+"\\/"+s+"\\s*\\"+e.bbcode[1]:"\\"+e.xml[0]+s+"(?:\\s+[A-Za-z0-9_\\-]+=(?:\"(?:[^\"]+|\\\\\")*\"|'(?:[^']+|\\\\')*'))*\\s*\\"+e.xml[1]+"|\\"+e.xml[0]+"\\/"+s+"\\s*\\"+e.xml[1];return i&&(o="("+o+")"),new RegExp(o,"g")},s.prototype.getPropertyRegex=function(){return new RegExp("([A-Za-z0-9_\\-]+)=(?:\"((?:[^\"]+|\\\\\")*)\"|'((?:[^']+|\\\\')*)')","g")},s.prototype.getBBcodePropertyRegex=function(){return new RegExp("[A-Za-z0-9_\\-]+=([A-Za-z0-9_\\-\\#]+)","g")},s.prototype._getTextDataPerLine=function(t){for(var i=[],s=this.getTagRegex(!0,!1),o=[this.assign({},this.textStyles.default)],n=[{name:"default",properties:{}}],r=0;r<t.length;r++){for(var a=[],h=[],l=void 0;l=s.exec(t[r]);)h.push(l);if(0===h.length)a.push(this.createTextData(t[r],o[o.length-1],n[n.length-1]));else{for(var c=0,d=0;d<h.length;d++){if(h[d].index>c&&a.push(this.createTextData(t[r].substring(c,h[d].index),o[o.length-1],n[n.length-1])),"/"===h[d][0][1])o.length>1&&(o.pop(),n.pop());else{for(var x={},g=this.getPropertyRegex(),p=void 0;p=g.exec(h[d][0]);)x[p[1]]=p[2]||p[3];if(n.push({name:h[d][1],properties:x}),"bbcode"===this.textStyles.default.tagStyle&&h[d][0].includes("=")&&this.textStyles[h[d][1]]){var u=this.getBBcodePropertyRegex().exec(h[d][0]),f={};Object.entries(this.textStyles[h[d][1]]).forEach(function(t){f[t[0]]="string"!=typeof t[1]?t[1]:u[1]+t[1]}),o.push(this.assign({},o[o.length-1],f))}else o.push(this.assign({},o[o.length-1],this.textStyles[h[d][1]]))}c=h[d].index+h[d][0].length}if(c<t[r].length){var y=this.createTextData(c?t[r].substring(c):t[r],o[o.length-1],n[n.length-1]);a.push(y)}}i.push(a)}var b=this.textStyles.default.tagStyle;return i[i.length-1].map(function(t){t.text.includes(e[b][0])&&(t.text=t.text.match("bbcode"===b?/^(.*)\[/:/^(.*)\</)[1])}),i},s.prototype.getFontString=function(t){return new PIXI.TextStyle(t).toFontString()},s.prototype.createTextData=function(t,e,i){return{text:t,style:e,width:0,height:0,fontProperties:void 0,tag:i}},s.prototype.getDropShadowPadding=function(){var t=this,e=0,i=0;return Object.keys(this.textStyles).forEach(function(s){var o=t.textStyles[s],n=o.dropShadowBlur;e=Math.max(e,o.dropShadowDistance||0),i=Math.max(i,n||0)}),e+i},s.prototype.withPrivateMembers=function(){return this},s.prototype.updateText=function(){var t=this;if(this.withPrivateMembers().dirty){this.hitboxes=[],this.texture.baseTexture.resolution=this.resolution;var e=this.textStyles,i=this.text;this.withPrivateMembers()._style.wordWrap&&(i=this.wordWrap(this.text));for(var o=i.split(/(?:\r\n|\r|\n)/),n=this._getTextDataPerLine(o),r=[],a=[],h=[],l=0,c=0;c<o.length;c++){for(var d=0,x=0,g=0,p=0;p<n[c].length;p++){var u=n[c][p].style;this.context.font=this.getFontString(u),n[c][p].width=this.context.measureText(n[c][p].text).width,0!==n[c][p].text.length&&(n[c][p].width+=(n[c][p].text.length-1)*u.letterSpacing,p>0&&(d+=u.letterSpacing/2),p<n[c].length-1&&(d+=u.letterSpacing/2)),d+=n[c][p].width,n[c][p].fontProperties=PIXI.TextMetrics.measureFont(this.context.font),n[c][p].height=n[c][p].fontProperties.fontSize,"number"==typeof u.valign?(x=Math.min(x,u.valign-n[c][p].fontProperties.descent),g=Math.max(g,u.valign+n[c][p].fontProperties.ascent)):(x=Math.min(x,-n[c][p].fontProperties.descent),g=Math.max(g,n[c][p].fontProperties.ascent))}r[c]=d,a[c]=x,h[c]=g,l=Math.max(l,d)}var f=Object.keys(e).map(function(t){return e[t]}).reduce(function(t,e){return Math.max(t,e.strokeThickness||0)},0),y=this.getDropShadowPadding(),b=l+2*f+2*y,S=h.reduce(function(t,e){return t+e},0)-a.reduce(function(t,e){return t+e},0)+2*f+2*y;this.canvas.width=b*this.resolution,this.canvas.height=S*this.resolution,this.context.scale(this.resolution,this.resolution),this.context.textBaseline="alphabetic",this.context.lineJoin="round";for(var v=y+f,m=[],w=0;w<n.length;w++){var T=n[w],P=void 0;switch(this.withPrivateMembers()._style.align){case"left":P=y+f;break;case"center":P=y+f+(l-r[w])/2;break;case"right":P=y+f+l-r[w]}for(var k=0;k<T.length;k++){var _=T[k],M=_.style,I=_.text,F=_.fontProperties,O=_.width,A=_.tag,E=v+F.ascent;switch(M.valign){case"top":break;case"baseline":E+=h[w]-F.ascent;break;case"middle":E+=(h[w]-a[w]-F.ascent-F.descent)/2;break;case"bottom":E+=h[w]-a[w]-F.ascent-F.descent;break;default:E+=h[w]-F.ascent-M.valign}if(0===M.letterSpacing)m.push({text:I,style:M,x:P,y:E,width:O,ascent:F.ascent,descent:F.descent,tag:A}),P+=T[k].width;else{this.context.font=this.getFontString(T[k].style);for(var D=0;D<I.length;D++){(D>0||k>0)&&(P+=M.letterSpacing/2);var B=this.context.measureText(I.charAt(D)).width;m.push({text:I.charAt(D),style:M,x:P,y:E,width:B,ascent:F.ascent,descent:F.descent,tag:A}),P+=B,(D<I.length-1||k<T.length-1)&&(P+=M.letterSpacing/2)}}}v+=h[w]-a[w]}this.context.save(),m.forEach(function(e){var i=e.style,s=e.text,o=e.x,n=e.y;if(i.dropShadow){t.context.font=t.getFontString(i);var r=i.dropShadowColor;"number"==typeof r&&(r=PIXI.utils.hex2string(r)),t.context.shadowColor=r,t.context.shadowBlur=i.dropShadowBlur,t.context.shadowOffsetX=Math.cos(i.dropShadowAngle)*i.dropShadowDistance*t.resolution,t.context.shadowOffsetY=Math.sin(i.dropShadowAngle)*i.dropShadowDistance*t.resolution,t.context.fillText(s,o,n)}}),this.context.restore(),m.forEach(function(e){var i=e.style,s=e.text,o=e.x,n=e.y;if(void 0!==i.stroke&&i.strokeThickness){t.context.font=t.getFontString(i);var r=i.stroke;"number"==typeof r&&(r=PIXI.utils.hex2string(r)),t.context.strokeStyle=r,t.context.lineWidth=i.strokeThickness,t.context.strokeText(s,o,n)}}),m.forEach(function(e){var i=e.style,s=e.text,o=e.x,n=e.y;if(void 0!==i.fill){t.context.font=t.getFontString(i);var r=i.fill;if("number"==typeof r)r=PIXI.utils.hex2string(r);else if(Array.isArray(r))for(var a=0;a<r.length;a++){var h=r[a];"number"==typeof h&&(r[a]=PIXI.utils.hex2string(h))}t.context.fillStyle=t._generateFillStyle(new PIXI.TextStyle(i),[s]),t.context.fillText(s,o,n)}}),m.forEach(function(e){var i=e.style,o=e.x,n=e.y,r=e.width,a=e.ascent,h=e.descent,l=e.tag,c=-t.withPrivateMembers()._style.padding-t.getDropShadowPadding();t.hitboxes.push({tag:l,hitbox:new PIXI.Rectangle(o+c,n-a+c,r,a+h)}),(void 0===i.debug?s.debugOptions.spans.enabled:i.debug)&&(t.context.lineWidth=1,s.debugOptions.spans.bounding&&(t.context.fillStyle=s.debugOptions.spans.bounding,t.context.strokeStyle=s.debugOptions.spans.bounding,t.context.beginPath(),t.context.rect(o,n-a,r,a+h),t.context.fill(),t.context.stroke(),t.context.stroke()),s.debugOptions.spans.baseline&&(t.context.strokeStyle=s.debugOptions.spans.baseline,t.context.beginPath(),t.context.moveTo(o,n),t.context.lineTo(o+r,n),t.context.closePath(),t.context.stroke()),s.debugOptions.spans.top&&(t.context.strokeStyle=s.debugOptions.spans.top,t.context.beginPath(),t.context.moveTo(o,n-a),t.context.lineTo(o+r,n-a),t.context.closePath(),t.context.stroke()),s.debugOptions.spans.bottom&&(t.context.strokeStyle=s.debugOptions.spans.bottom,t.context.beginPath(),t.context.moveTo(o,n+h),t.context.lineTo(o+r,n+h),t.context.closePath(),t.context.stroke()),s.debugOptions.spans.text&&(t.context.fillStyle="#ffffff",t.context.strokeStyle="#000000",t.context.lineWidth=2,t.context.font="8px monospace",t.context.strokeText(l.name,o,n-a+8),t.context.fillText(l.name,o,n-a+8),t.context.strokeText(r.toFixed(2)+"x"+(a+h).toFixed(2),o,n-a+16),t.context.fillText(r.toFixed(2)+"x"+(a+h).toFixed(2),o,n-a+16)))}),s.debugOptions.objects.enabled&&(s.debugOptions.objects.bounding&&(this.context.fillStyle=s.debugOptions.objects.bounding,this.context.beginPath(),this.context.rect(0,0,b,S),this.context.fill()),s.debugOptions.objects.text&&(this.context.fillStyle="#ffffff",this.context.strokeStyle="#000000",this.context.lineWidth=2,this.context.font="8px monospace",this.context.strokeText(b.toFixed(2)+"x"+S.toFixed(2),0,8,b),this.context.fillText(b.toFixed(2)+"x"+S.toFixed(2),0,8,b))),this.updateTexture()}},s.prototype.wordWrap=function(t){var e="",i=this.getTagRegex(!0,!0),s=t.split("\n"),o=this.withPrivateMembers()._style.wordWrapWidth,n=[this.assign({},this.textStyles.default)];this.context.font=this.getFontString(this.textStyles.default);for(var r=0;r<s.length;r++){for(var a=o,h=s[r].split(i),l=!0,c=0;c<h.length;c++)if(i.test(h[c]))e+=h[c],"/"===h[c][1]?(c+=2,n.pop()):(n.push(this.assign({},n[n.length-1],this.textStyles[h[++c]])),c++),this.context.font=this.getFontString(n[n.length-1]);else for(var d=h[c].split(" "),x=0;x<d.length;x++){var g=this.context.measureText(d[x]).width;if(this.withPrivateMembers()._style.breakWords&&g>a){var p=d[x].split("");x>0&&(e+=" ",a-=this.context.measureText(" ").width);for(var u=0;u<p.length;u++){var f=this.context.measureText(p[u]).width;f>a?(e+="\n"+p[u],a=o-f):(e+=p[u],a-=f)}}else if(this.withPrivateMembers()._style.breakWords)e+=d[x],a-=g;else{var y=g+(x>0?this.context.measureText(" ").width:0);y>a?(l||(e+="\n"),e+=d[x],a=o-g):(a-=y,x>0&&(e+=" "),e+=d[x])}l=!1}r<s.length-1&&(e+="\n")}return e},s.prototype.updateTexture=function(){var t=this.withPrivateMembers()._texture,e=this.getDropShadowPadding();t.baseTexture.setRealSize(this.canvas.width,this.canvas.height,this.resolution),t.trim.width=t.frame.width=this.canvas.width/this.resolution,t.trim.height=t.frame.height=this.canvas.height/this.resolution,t.trim.x=-this.withPrivateMembers()._style.padding-e,t.trim.y=-this.withPrivateMembers()._style.padding-e,t.orig.width=t.frame.width-2*(this.withPrivateMembers()._style.padding+e),t.orig.height=t.frame.height-2*(this.withPrivateMembers()._style.padding+e),this.withPrivateMembers()._onTextureUpdate(),t.baseTexture.emit("update",t.baseTexture),this.withPrivateMembers().dirty=!1},s.prototype.assign=function(t){for(var e=[],i=arguments.length-1;i-- >0;)e[i]=arguments[i+1];for(var s=0,o=e;s<o.length;s+=1){var n=o[s];for(var r in n)t[r]=n[r]}return t},Object.defineProperties(s.prototype,o),s}(PIXI.Text);return i.DEFAULT_TAG_STYLE={align:"left",breakWords:!1,dropShadow:!1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"#000000",dropShadowDistance:5,fill:"black",fillGradientType:PIXI.TEXT_GRADIENT.LINEAR_VERTICAL,fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",valign:"baseline",wordWrap:!1,wordWrapWidth:100,tagStyle:"xml"},i.debugOptions={spans:{enabled:!1,baseline:"#44BB44",top:"#BB4444",bottom:"#4444BB",bounding:"rgba(255, 255, 255, 0.1)",text:!0},objects:{enabled:!1,bounding:"rgba(255, 255, 255, 0.05)",text:!0}},i});
//# sourceMappingURL=pixi-multistyle-text.umd.js.map
{
"name": "pixi-multistyle-text",
"version": "0.8.0",
"version": "0.9.0",
"description": "Multi-Style Text for pixi.js",

@@ -38,14 +38,13 @@ "source": "src/pixi-multistyle-text.ts",

"devDependencies": {
"@types/pixi.js": "^4.8.2",
"argos-cli": "0.0.9",
"fs-extra": "^7.0.0",
"argos-cli": "0.1.3",
"fs-extra": "^8.1.0",
"happo": "^5.0.0",
"happo-target-firefox": "^5.0.3",
"microbundle": "^0.7.0",
"pixi.js": "^4.8.2",
"standard-version": "^4.4.0",
"typescript": "^3.1.3"
"happo-target-firefox": "^5.1.2",
"microbundle": "^0.11.0",
"pixi.js-legacy": "^5.2.0",
"standard-version": "^7.1.0",
"typescript": "^3.7.5"
},
"peerDependencies": {
"pixi.js": "^4.5.6"
"pixi.js": "^5.2.0"
},

@@ -52,0 +51,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc