Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pixi/text-html

Package Overview
Dependencies
Maintainers
3
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/text-html - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

6

dist/html-text.cjs.js
/*!
* @pixi/text-html - v2.1.2
* Compiled Thu, 06 Oct 2022 16:24:31 UTC
* @pixi/text-html - v2.1.3
* Compiled Fri, 04 Nov 2022 11:24:41 UTC
*

@@ -8,3 +8,3 @@ * @pixi/text-html is licensed under the MIT License.

*/
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@pixi/sprite"),e=require("@pixi/settings"),i=require("@pixi/core"),s=require("@pixi/math"),o=require("@pixi/utils"),n=require("@pixi/text"),r=function(t){function r(o,n,r){void 0===o&&(o=""),void 0===n&&(n={}),(r=r||document.createElement("canvas")).width=3,r.height=3;var h=i.Texture.from(r,{scaleMode:e.settings.SCALE_MODE});h.orig=new s.Rectangle,h.trim=new s.Rectangle,t.call(this,h);var a="http://www.w3.org/2000/svg",l=document.createElementNS(a,"svg"),d=document.createElementNS(a,"foreignObject"),u=document.createElementNS("http://www.w3.org/1999/xhtml","div");d.setAttribute("height","100%"),d.setAttribute("width","100%"),l.appendChild(d),this._domElement=u,this._svgRoot=l,this._foreignObject=d,this._image=new Image,this.canvas=r,this.context=this.canvas.getContext("2d"),this._resolution=e.settings.RESOLUTION,this._autoResolution=!0,this._text=null,this._style=null,this._loading=!1,this.text=o,this.style=n,this.localStyleID=-1}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var h={width:{configurable:!0},height:{configurable:!0},style:{configurable:!0},text:{configurable:!0},resolution:{configurable:!0}};return r.prototype.updateText=function(t){var e=this,i=this.style,s=this.canvas,n=this.context,r=this.resolution;if(this.localStyleID!==i.styleID&&(this.dirty=!0,this.localStyleID=i.styleID),this.dirty||!t){var h="\n display:inline-block;\n color:"+i.fill+";\n font-size: "+i.fontSize+"px;\n font-family:"+i.fontFamily+";\n font-weight:"+i.fontWeight+";\n font-style:"+i.fontStyle+";\n font-variant:"+i.fontVariant+";\n letter-spacing:"+i.letterSpacing+"px;\n text-align:"+i.align+";\n padding:"+i.padding+"px;\n ";if(i.lineHeight&&(h+="line-height:"+i.lineHeight+"px;"),i.wordWrap&&(h+="word-wrap:"+(i.breakWords?"break-all":"break-word")+";",h+="width:"+i.wordWrapWidth+"px;"),i.strokeThickness){var a=i.stroke;"number"==typeof color&&(a=o.hex2string(a)),h+="-webkit-text-stroke-width: "+i.strokeThickness+"px;",h+="-webkit-text-stroke-color: "+a+";",h+="text-stroke-width: "+i.strokeThickness+"px;",h+="text-stroke-color: "+a+";",h+="paint-order: stroke;"}if(i.dropShadow){var l=i.dropShadowAngle,d=i.dropShadowDistance,u=i.dropShadowBlur,c=i.dropShadowColor,p=i.dropShadowAlpha,g=Math.round(Math.cos(l)*d),x=Math.round(Math.sin(l)*d),y=c;if("number"==typeof y&&(y=o.hex2string(y)),"#"===y.charAt(0)&&p<1){var _=o.hex2rgb(parseInt(y.replace("#",""),16));y="rgba("+(255*_[0]|0)+", "+(255*_[1]|0)+", "+(255*_[2]|0)+", "+p+")"}h+="text-shadow: "+g+"px "+x+"px "+u+"px "+y+";"}var f=this._domElement;Object.assign(f,{innerHTML:this._text,style:h}),document.body.appendChild(f);var w=f.getBoundingClientRect(),m=w.width,v=w.height;if(document.body.removeChild(f),this._foreignObject.appendChild(f),this._svgRoot.setAttribute("width",m),this._svgRoot.setAttribute("height",v),s.width=Math.ceil((Math.max(1,m)+2*i.padding)*r),s.height=Math.ceil((Math.max(1,v)+2*i.padding)*r),!this._loading){var b=this._image,S=(new XMLSerializer).serializeToString(this._svgRoot);this._loading=!0,b.src="data:image/svg+xml;charset=utf8,"+encodeURIComponent(S),b.onload=function(){n.scale(r,r),n.clearRect(0,0,s.width,s.height),n.drawImage(b,0,0,m,v,0,0,m,v),b.src="",b.onload=void 0,e._loading=!1,e.updateTexture()}}}},r.prototype.updateTexture=function(){var t=this.canvas,e=this.context,i=this.style,s=this.texture,n=this.resolution;if(i.trim){var r=o.trimCanvas(t),h=r.width,a=r.height,l=r.data;l&&(t.width=h,t.height=a,e.putImageData(l,0,0))}var d=i.trim?0:i.padding,u=s.baseTexture;s.trim.width=s._frame.width=t.width/n,s.trim.height=s._frame.height=t.height/n,s.trim.x=-d,s.trim.y=-d,s.orig.width=s._frame.width-2*d,s.orig.height=s._frame.height-2*d,this._onTextureUpdate(),u.setRealSize(t.width,t.height,n),this.dirty=!1},r.prototype._render=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._render.call(this,e)},r.prototype._renderCanvas=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._renderCanvas.call(this,e)},r.prototype.getLocalBounds=function(e){return this.updateText(!0),t.prototype.getLocalBounds.call(this,e)},r.prototype._calculateBounds=function(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)},r.prototype._onStyleChange=function(){this.dirty=!0},r.prototype.destroy=function(e){void 0===e&&(e=!0),t.prototype.destroy.call(this,e),this.context=null,this.canvas.width=this.canvas.height=0,this.canvas=null,this._style=null,this._svgRoot=null,this._domElement=null,this._foreignObject=null,this._image.onload=null,this._image.src="",this._image=null},h.width.get=function(){return this.updateText(!0),Math.abs(this.scale.x)*this.canvas.width/this.resolution},h.width.set=function(t){this.updateText(!0);var e=o.sign(this.scale.x)||1;this.scale.x=e*t/this.canvas.width/this.resolution,this._width=t},h.height.get=function(){return this.updateText(!0),Math.abs(this.scale.y)*this.canvas.height/this.resolution},h.height.set=function(t){this.updateText(!0);var e=o.sign(this.scale.y)||1;this.scale.y=e*t/this.canvas.height/this.resolution,this._height=t},h.style.get=function(){return this._style},h.style.set=function(t){(t=t||{})instanceof n.TextStyle?this._style=t:this._style=new n.TextStyle(t),this.localStyleID=-1,this.dirty=!0},h.text.get=function(){return this._text},h.text.set=function(t){t=String(""===t||null==t?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)},h.resolution.get=function(){return this._resolution},h.resolution.set=function(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)},r.prototype.sanitiseText=function(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;")},Object.defineProperties(r.prototype,h),r}(t.Sprite);exports.HTMLText=r;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@pixi/sprite"),e=require("@pixi/settings"),i=require("@pixi/core"),s=require("@pixi/math"),o=require("@pixi/utils"),n=require("@pixi/text"),r=function(t){function r(o,n,r){void 0===o&&(o=""),void 0===n&&(n={}),(r=r||document.createElement("canvas")).width=3,r.height=3;var h=i.Texture.from(r,{scaleMode:e.settings.SCALE_MODE});h.orig=new s.Rectangle,h.trim=new s.Rectangle,t.call(this,h);var a="http://www.w3.org/2000/svg",l=document.createElementNS(a,"svg"),d=document.createElementNS(a,"foreignObject"),u=document.createElementNS("http://www.w3.org/1999/xhtml","div");d.setAttribute("height","100%"),d.setAttribute("width","100%"),l.appendChild(d),this._domElement=u,this._svgRoot=l,this._foreignObject=d,this._image=new Image,this.canvas=r,this.context=this.canvas.getContext("2d"),this._resolution=e.settings.RESOLUTION,this._autoResolution=!0,this._text=null,this._style=null,this._loading=!1,this.text=o,this.style=n,this.localStyleID=-1}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var h={width:{configurable:!0},height:{configurable:!0},style:{configurable:!0},text:{configurable:!0},resolution:{configurable:!0}};return r.prototype.updateText=function(t){var e=this,i=this.style,s=this.canvas,n=this.context,r=this.resolution;if(this.localStyleID!==i.styleID&&(this.dirty=!0,this.localStyleID=i.styleID),this.dirty||!t){var h="\n display:inline-block;\n color:"+i.fill+";\n font-size: "+i.fontSize+"px;\n font-family:"+i.fontFamily+";\n font-weight:"+i.fontWeight+";\n font-style:"+i.fontStyle+";\n font-variant:"+i.fontVariant+";\n letter-spacing:"+i.letterSpacing+"px;\n text-align:"+i.align+";\n padding:"+i.padding+"px;\n ";if(i.lineHeight&&(h+="line-height:"+i.lineHeight+"px;"),i.wordWrap&&(h+="word-wrap:"+(i.breakWords?"break-all":"break-word")+";",h+="max-width:"+i.wordWrapWidth+"px;"),i.strokeThickness){var a=i.stroke;"number"==typeof color&&(a=o.hex2string(a)),h+="-webkit-text-stroke-width: "+i.strokeThickness+"px;",h+="-webkit-text-stroke-color: "+a+";",h+="text-stroke-width: "+i.strokeThickness+"px;",h+="text-stroke-color: "+a+";",h+="paint-order: stroke;"}if(i.dropShadow){var l=i.dropShadowAngle,d=i.dropShadowDistance,u=i.dropShadowBlur,c=i.dropShadowColor,p=i.dropShadowAlpha,g=Math.round(Math.cos(l)*d),x=Math.round(Math.sin(l)*d),y=c;if("number"==typeof y&&(y=o.hex2string(y)),"#"===y.charAt(0)&&p<1){var _=o.hex2rgb(parseInt(y.replace("#",""),16));y="rgba("+(255*_[0]|0)+", "+(255*_[1]|0)+", "+(255*_[2]|0)+", "+p+")"}h+="text-shadow: "+g+"px "+x+"px "+u+"px "+y+";"}var f=this._domElement;Object.assign(f,{innerHTML:this._text,style:h}),document.body.appendChild(f);var w=f.getBoundingClientRect(),m=w.width,v=w.height;if(document.body.removeChild(f),this._foreignObject.appendChild(f),this._svgRoot.setAttribute("width",m),this._svgRoot.setAttribute("height",v),s.width=Math.ceil((Math.max(1,m)+2*i.padding)*r),s.height=Math.ceil((Math.max(1,v)+2*i.padding)*r),!this._loading){var b=this._image,S=(new XMLSerializer).serializeToString(this._svgRoot);this._loading=!0,b.src="data:image/svg+xml;charset=utf8,"+encodeURIComponent(S),b.onload=function(){n.scale(r,r),n.clearRect(0,0,s.width,s.height),n.drawImage(b,0,0,m,v,0,0,m,v),b.src="",b.onload=void 0,e._loading=!1,e.updateTexture()}}}},r.prototype.updateTexture=function(){var t=this.canvas,e=this.context,i=this.style,s=this.texture,n=this.resolution;if(i.trim){var r=o.trimCanvas(t),h=r.width,a=r.height,l=r.data;l&&(t.width=h,t.height=a,e.putImageData(l,0,0))}var d=i.trim?0:i.padding,u=s.baseTexture;s.trim.width=s._frame.width=t.width/n,s.trim.height=s._frame.height=t.height/n,s.trim.x=-d,s.trim.y=-d,s.orig.width=s._frame.width-2*d,s.orig.height=s._frame.height-2*d,this._onTextureUpdate(),u.setRealSize(t.width,t.height,n),this.dirty=!1},r.prototype._render=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._render.call(this,e)},r.prototype._renderCanvas=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._renderCanvas.call(this,e)},r.prototype.getLocalBounds=function(e){return this.updateText(!0),t.prototype.getLocalBounds.call(this,e)},r.prototype._calculateBounds=function(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)},r.prototype._onStyleChange=function(){this.dirty=!0},r.prototype.destroy=function(e){void 0===e&&(e=!0),t.prototype.destroy.call(this,e),this.context=null,this.canvas.width=this.canvas.height=0,this.canvas=null,this._style=null,this._svgRoot=null,this._domElement=null,this._foreignObject=null,this._image.onload=null,this._image.src="",this._image=null},h.width.get=function(){return this.updateText(!0),Math.abs(this.scale.x)*this.canvas.width/this.resolution},h.width.set=function(t){this.updateText(!0);var e=o.sign(this.scale.x)||1;this.scale.x=e*t/this.canvas.width/this.resolution,this._width=t},h.height.get=function(){return this.updateText(!0),Math.abs(this.scale.y)*this.canvas.height/this.resolution},h.height.set=function(t){this.updateText(!0);var e=o.sign(this.scale.y)||1;this.scale.y=e*t/this.canvas.height/this.resolution,this._height=t},h.style.get=function(){return this._style},h.style.set=function(t){(t=t||{})instanceof n.TextStyle?this._style=t:this._style=new n.TextStyle(t),this.localStyleID=-1,this.dirty=!0},h.text.get=function(){return this._text},h.text.set=function(t){t=String(""===t||null==t?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)},h.resolution.get=function(){return this._resolution},h.resolution.set=function(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)},r.prototype.sanitiseText=function(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;")},Object.defineProperties(r.prototype,h),r}(t.Sprite);exports.HTMLText=r;
//# sourceMappingURL=html-text.cjs.js.map
/*!
* @pixi/text-html - v2.1.2
* Compiled Thu, 06 Oct 2022 16:24:31 UTC
* @pixi/text-html - v2.1.3
* Compiled Fri, 04 Nov 2022 11:24:41 UTC
*

@@ -8,3 +8,3 @@ * @pixi/text-html is licensed under the MIT License.

*/
var _pixi_htmltext=function(t,e,i,s,o,n,h){"use strict";var r=function(t){function e(e,n,h){void 0===e&&(e=""),void 0===n&&(n={}),(h=h||document.createElement("canvas")).width=3,h.height=3;var r=s.Texture.from(h,{scaleMode:i.settings.SCALE_MODE});r.orig=new o.Rectangle,r.trim=new o.Rectangle,t.call(this,r);var a="http://www.w3.org/2000/svg",l=document.createElementNS(a,"svg"),d=document.createElementNS(a,"foreignObject"),u=document.createElementNS("http://www.w3.org/1999/xhtml","div");d.setAttribute("height","100%"),d.setAttribute("width","100%"),l.appendChild(d),this._domElement=u,this._svgRoot=l,this._foreignObject=d,this._image=new Image,this.canvas=h,this.context=this.canvas.getContext("2d"),this._resolution=i.settings.RESOLUTION,this._autoResolution=!0,this._text=null,this._style=null,this._loading=!1,this.text=e,this.style=n,this.localStyleID=-1}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={width:{configurable:!0},height:{configurable:!0},style:{configurable:!0},text:{configurable:!0},resolution:{configurable:!0}};return e.prototype.updateText=function(t){var e=this,i=this.style,s=this.canvas,o=this.context,h=this.resolution;if(this.localStyleID!==i.styleID&&(this.dirty=!0,this.localStyleID=i.styleID),this.dirty||!t){var r="\n display:inline-block;\n color:"+i.fill+";\n font-size: "+i.fontSize+"px;\n font-family:"+i.fontFamily+";\n font-weight:"+i.fontWeight+";\n font-style:"+i.fontStyle+";\n font-variant:"+i.fontVariant+";\n letter-spacing:"+i.letterSpacing+"px;\n text-align:"+i.align+";\n padding:"+i.padding+"px;\n ";if(i.lineHeight&&(r+="line-height:"+i.lineHeight+"px;"),i.wordWrap&&(r+="word-wrap:"+(i.breakWords?"break-all":"break-word")+";",r+="width:"+i.wordWrapWidth+"px;"),i.strokeThickness){var a=i.stroke;"number"==typeof color&&(a=n.hex2string(a)),r+="-webkit-text-stroke-width: "+i.strokeThickness+"px;",r+="-webkit-text-stroke-color: "+a+";",r+="text-stroke-width: "+i.strokeThickness+"px;",r+="text-stroke-color: "+a+";",r+="paint-order: stroke;"}if(i.dropShadow){var l=i.dropShadowAngle,d=i.dropShadowDistance,u=i.dropShadowBlur,c=i.dropShadowColor,g=i.dropShadowAlpha,p=Math.round(Math.cos(l)*d),x=Math.round(Math.sin(l)*d),_=c;if("number"==typeof _&&(_=n.hex2string(_)),"#"===_.charAt(0)&&g<1){var y=n.hex2rgb(parseInt(_.replace("#",""),16));_="rgba("+(255*y[0]|0)+", "+(255*y[1]|0)+", "+(255*y[2]|0)+", "+g+")"}r+="text-shadow: "+p+"px "+x+"px "+u+"px "+_+";"}var f=this._domElement;Object.assign(f,{innerHTML:this._text,style:r}),document.body.appendChild(f);var w=f.getBoundingClientRect(),m=w.width,v=w.height;if(document.body.removeChild(f),this._foreignObject.appendChild(f),this._svgRoot.setAttribute("width",m),this._svgRoot.setAttribute("height",v),s.width=Math.ceil((Math.max(1,m)+2*i.padding)*h),s.height=Math.ceil((Math.max(1,v)+2*i.padding)*h),!this._loading){var b=this._image,I=(new XMLSerializer).serializeToString(this._svgRoot);this._loading=!0,b.src="data:image/svg+xml;charset=utf8,"+encodeURIComponent(I),b.onload=function(){o.scale(h,h),o.clearRect(0,0,s.width,s.height),o.drawImage(b,0,0,m,v,0,0,m,v),b.src="",b.onload=void 0,e._loading=!1,e.updateTexture()}}}},e.prototype.updateTexture=function(){var t=this.canvas,e=this.context,i=this.style,s=this.texture,o=this.resolution;if(i.trim){var h=n.trimCanvas(t),r=h.width,a=h.height,l=h.data;l&&(t.width=r,t.height=a,e.putImageData(l,0,0))}var d=i.trim?0:i.padding,u=s.baseTexture;s.trim.width=s._frame.width=t.width/o,s.trim.height=s._frame.height=t.height/o,s.trim.x=-d,s.trim.y=-d,s.orig.width=s._frame.width-2*d,s.orig.height=s._frame.height-2*d,this._onTextureUpdate(),u.setRealSize(t.width,t.height,o),this.dirty=!1},e.prototype._render=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._render.call(this,e)},e.prototype._renderCanvas=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._renderCanvas.call(this,e)},e.prototype.getLocalBounds=function(e){return this.updateText(!0),t.prototype.getLocalBounds.call(this,e)},e.prototype._calculateBounds=function(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)},e.prototype._onStyleChange=function(){this.dirty=!0},e.prototype.destroy=function(e){void 0===e&&(e=!0),t.prototype.destroy.call(this,e),this.context=null,this.canvas.width=this.canvas.height=0,this.canvas=null,this._style=null,this._svgRoot=null,this._domElement=null,this._foreignObject=null,this._image.onload=null,this._image.src="",this._image=null},r.width.get=function(){return this.updateText(!0),Math.abs(this.scale.x)*this.canvas.width/this.resolution},r.width.set=function(t){this.updateText(!0);var e=n.sign(this.scale.x)||1;this.scale.x=e*t/this.canvas.width/this.resolution,this._width=t},r.height.get=function(){return this.updateText(!0),Math.abs(this.scale.y)*this.canvas.height/this.resolution},r.height.set=function(t){this.updateText(!0);var e=n.sign(this.scale.y)||1;this.scale.y=e*t/this.canvas.height/this.resolution,this._height=t},r.style.get=function(){return this._style},r.style.set=function(t){(t=t||{})instanceof h.TextStyle?this._style=t:this._style=new h.TextStyle(t),this.localStyleID=-1,this.dirty=!0},r.text.get=function(){return this._text},r.text.set=function(t){t=String(""===t||null==t?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)},r.resolution.get=function(){return this._resolution},r.resolution.set=function(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)},e.prototype.sanitiseText=function(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;")},Object.defineProperties(e.prototype,r),e}(e.Sprite);return t.HTMLText=r,t}({},PIXI,PIXI,PIXI,PIXI,PIXI.utils,PIXI);Object.assign(PIXI,_pixi_htmltext);
var _pixi_htmltext=function(t,e,i,s,o,n,h){"use strict";var r=function(t){function e(e,n,h){void 0===e&&(e=""),void 0===n&&(n={}),(h=h||document.createElement("canvas")).width=3,h.height=3;var r=s.Texture.from(h,{scaleMode:i.settings.SCALE_MODE});r.orig=new o.Rectangle,r.trim=new o.Rectangle,t.call(this,r);var a="http://www.w3.org/2000/svg",l=document.createElementNS(a,"svg"),d=document.createElementNS(a,"foreignObject"),u=document.createElementNS("http://www.w3.org/1999/xhtml","div");d.setAttribute("height","100%"),d.setAttribute("width","100%"),l.appendChild(d),this._domElement=u,this._svgRoot=l,this._foreignObject=d,this._image=new Image,this.canvas=h,this.context=this.canvas.getContext("2d"),this._resolution=i.settings.RESOLUTION,this._autoResolution=!0,this._text=null,this._style=null,this._loading=!1,this.text=e,this.style=n,this.localStyleID=-1}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={width:{configurable:!0},height:{configurable:!0},style:{configurable:!0},text:{configurable:!0},resolution:{configurable:!0}};return e.prototype.updateText=function(t){var e=this,i=this.style,s=this.canvas,o=this.context,h=this.resolution;if(this.localStyleID!==i.styleID&&(this.dirty=!0,this.localStyleID=i.styleID),this.dirty||!t){var r="\n display:inline-block;\n color:"+i.fill+";\n font-size: "+i.fontSize+"px;\n font-family:"+i.fontFamily+";\n font-weight:"+i.fontWeight+";\n font-style:"+i.fontStyle+";\n font-variant:"+i.fontVariant+";\n letter-spacing:"+i.letterSpacing+"px;\n text-align:"+i.align+";\n padding:"+i.padding+"px;\n ";if(i.lineHeight&&(r+="line-height:"+i.lineHeight+"px;"),i.wordWrap&&(r+="word-wrap:"+(i.breakWords?"break-all":"break-word")+";",r+="max-width:"+i.wordWrapWidth+"px;"),i.strokeThickness){var a=i.stroke;"number"==typeof color&&(a=n.hex2string(a)),r+="-webkit-text-stroke-width: "+i.strokeThickness+"px;",r+="-webkit-text-stroke-color: "+a+";",r+="text-stroke-width: "+i.strokeThickness+"px;",r+="text-stroke-color: "+a+";",r+="paint-order: stroke;"}if(i.dropShadow){var l=i.dropShadowAngle,d=i.dropShadowDistance,u=i.dropShadowBlur,c=i.dropShadowColor,g=i.dropShadowAlpha,p=Math.round(Math.cos(l)*d),x=Math.round(Math.sin(l)*d),_=c;if("number"==typeof _&&(_=n.hex2string(_)),"#"===_.charAt(0)&&g<1){var y=n.hex2rgb(parseInt(_.replace("#",""),16));_="rgba("+(255*y[0]|0)+", "+(255*y[1]|0)+", "+(255*y[2]|0)+", "+g+")"}r+="text-shadow: "+p+"px "+x+"px "+u+"px "+_+";"}var f=this._domElement;Object.assign(f,{innerHTML:this._text,style:r}),document.body.appendChild(f);var w=f.getBoundingClientRect(),m=w.width,v=w.height;if(document.body.removeChild(f),this._foreignObject.appendChild(f),this._svgRoot.setAttribute("width",m),this._svgRoot.setAttribute("height",v),s.width=Math.ceil((Math.max(1,m)+2*i.padding)*h),s.height=Math.ceil((Math.max(1,v)+2*i.padding)*h),!this._loading){var b=this._image,I=(new XMLSerializer).serializeToString(this._svgRoot);this._loading=!0,b.src="data:image/svg+xml;charset=utf8,"+encodeURIComponent(I),b.onload=function(){o.scale(h,h),o.clearRect(0,0,s.width,s.height),o.drawImage(b,0,0,m,v,0,0,m,v),b.src="",b.onload=void 0,e._loading=!1,e.updateTexture()}}}},e.prototype.updateTexture=function(){var t=this.canvas,e=this.context,i=this.style,s=this.texture,o=this.resolution;if(i.trim){var h=n.trimCanvas(t),r=h.width,a=h.height,l=h.data;l&&(t.width=r,t.height=a,e.putImageData(l,0,0))}var d=i.trim?0:i.padding,u=s.baseTexture;s.trim.width=s._frame.width=t.width/o,s.trim.height=s._frame.height=t.height/o,s.trim.x=-d,s.trim.y=-d,s.orig.width=s._frame.width-2*d,s.orig.height=s._frame.height-2*d,this._onTextureUpdate(),u.setRealSize(t.width,t.height,o),this.dirty=!1},e.prototype._render=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._render.call(this,e)},e.prototype._renderCanvas=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._renderCanvas.call(this,e)},e.prototype.getLocalBounds=function(e){return this.updateText(!0),t.prototype.getLocalBounds.call(this,e)},e.prototype._calculateBounds=function(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)},e.prototype._onStyleChange=function(){this.dirty=!0},e.prototype.destroy=function(e){void 0===e&&(e=!0),t.prototype.destroy.call(this,e),this.context=null,this.canvas.width=this.canvas.height=0,this.canvas=null,this._style=null,this._svgRoot=null,this._domElement=null,this._foreignObject=null,this._image.onload=null,this._image.src="",this._image=null},r.width.get=function(){return this.updateText(!0),Math.abs(this.scale.x)*this.canvas.width/this.resolution},r.width.set=function(t){this.updateText(!0);var e=n.sign(this.scale.x)||1;this.scale.x=e*t/this.canvas.width/this.resolution,this._width=t},r.height.get=function(){return this.updateText(!0),Math.abs(this.scale.y)*this.canvas.height/this.resolution},r.height.set=function(t){this.updateText(!0);var e=n.sign(this.scale.y)||1;this.scale.y=e*t/this.canvas.height/this.resolution,this._height=t},r.style.get=function(){return this._style},r.style.set=function(t){(t=t||{})instanceof h.TextStyle?this._style=t:this._style=new h.TextStyle(t),this.localStyleID=-1,this.dirty=!0},r.text.get=function(){return this._text},r.text.set=function(t){t=String(""===t||null==t?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)},r.resolution.get=function(){return this._resolution},r.resolution.set=function(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)},e.prototype.sanitiseText=function(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/&nbsp;/gi,"&#160;")},Object.defineProperties(e.prototype,r),e}(e.Sprite);return t.HTMLText=r,t}({},PIXI,PIXI,PIXI,PIXI,PIXI.utils,PIXI);Object.assign(PIXI,_pixi_htmltext);
//# sourceMappingURL=html-text.js.map
{
"name": "@pixi/text-html",
"version": "2.1.2",
"version": "2.1.3",
"description": "Multi-Style Text Rendering Plugin for PixiJS",

@@ -5,0 +5,0 @@ "main": "dist/html-text.cjs.js",

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

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