@galacean/effects-plugin-rich-text 2.7.4 → 2.8.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alipay.js +1 -1
- package/dist/alipay.js.map +1 -1
- package/dist/alipay.mjs +1 -1
- package/dist/alipay.mjs.map +1 -1
- package/dist/douyin.js +1 -1
- package/dist/douyin.js.map +1 -1
- package/dist/douyin.mjs +1 -1
- package/dist/douyin.mjs.map +1 -1
- package/dist/index.js +1007 -272
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +1008 -273
- package/dist/index.mjs.map +1 -1
- package/dist/rich-text-component.d.ts +61 -18
- package/dist/rich-text-layout.d.ts +61 -0
- package/dist/strategies/align/rich-horizontal-align.d.ts +10 -0
- package/dist/strategies/align/rich-vertical-align.d.ts +10 -0
- package/dist/strategies/overflow/rich-clipped-overflow.d.ts +10 -0
- package/dist/strategies/overflow/rich-display-overflow.d.ts +10 -0
- package/dist/strategies/overflow/rich-visible-overflow.d.ts +10 -0
- package/dist/strategies/rich-text-factory.d.ts +26 -0
- package/dist/strategies/rich-text-interfaces.d.ts +104 -0
- package/dist/strategies/wrap/rich-wrap-disabled.d.ts +15 -0
- package/dist/strategies/wrap/rich-wrap-enabled.d.ts +15 -0
- package/dist/weapp.js +1 -1
- package/dist/weapp.js.map +1 -1
- package/dist/weapp.mjs +1 -1
- package/dist/weapp.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.min.js
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* Description: Galacean Effects player rich text plugin
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 云垣
|
|
6
|
-
* Version: v2.
|
|
7
|
-
*/function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@galacean/effects")):"function"==typeof define&&define.amd?define(["exports","@galacean/effects"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ge=t.ge||{},t.ge.richTextPlugin={}),t.ge)}(this,function(t,e){"use strict";var i,n,r=function(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(i){if("default"!==i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}}),e.default=t,Object.freeze(e)}(e);function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}var s=function(t){function e(){var e;return e=t.apply(this,arguments)||this,e.name="rich-text",e}return a(e,t),e}(e.AbstractPlugin);function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=Array(e);i<e;i++)n[i]=t[i];return n}function l(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(i)return(i=i.call(t)).next.bind(i);if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return h(t,void 0);var i=Object.prototype.toString.call(t).slice(8,-1);if("Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i)return Array.from(i);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return h(t,void 0)}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(i=n||(n={})).ContextStart="ContextStart",i.Text="Text",i.ContextEnd="ContextEnd",i.EscapedChar="EscapedChar";var c=/^<([a-z]+)(=([^>]+))?>$/,f=/^<\/([a-z]+)>$/,u=[["EscapedChar",/^\\([=<>\\/])/],["ContextStart",/^<[a-z]+(=[^>]+)?>/],["ContextEnd",/^<\/[a-z]+>/],["Text",/^[^</>=\\]+/]],p=function(t,e,i){if(void 0===e&&(e=[]),void 0===i&&(i=0),!t)return e;var n=/^\\([=<>\\/])/.exec(t);if(n){var r=n[1];return p(t.slice(2),e.concat({tokenType:"Text",value:r}),i+2)}for(var o,a=l(u);!(o=a()).done;){var s=o.value,h=s[0],c=s[1];if("EscapedChar"!==h){var f=c.exec(t);if(f){var d=f[0],x=d.length;return p(t.slice(x),e.concat({tokenType:h,value:d}),i+x)}}}if(t.length>0)return p(t.slice(1),e.concat({tokenType:"Text",value:t[0]}),i+1);throw Error('Unexpected token: "'+t[0]+'" at position '+i+' while reading "'+t+'"')},d=function(t){var e=function(){for(var t,e="",i=!1;r.length>0&&(null==(t=r[0])?void 0:t.tokenType)==="Text";){var n=a();n&&(e+=n.value,i=!0)}return i?e:void 0},i=function(){var t=s();if((null==t?void 0:t.tokenType)==="ContextStart"){a();var e,i=t.value.match(c);if(i)return{attributeName:i[1],attributeParam:null!=(e=i[3])?e:""};throw Error("Expected a start tag marker at position "+o)}return{}},n=function(){var t=s();if((null==t?void 0:t.tokenType)==="ContextEnd"){a();var e=t.value.match(f);if(e)return{attributeName:e[1]};throw Error("Expect an end tag marker at position "+o)}return{}},r=p(t),o=0,a=function(){var t,e=r.shift();return o+=null!=(t=null==e?void 0:e.value.length)?t:0,e},s=function(){return r[0]},h=[];return!function t(r,a){for(void 0===r&&(r=[]),void 0===a&&(a="");;){var s=e();if(s){h.push({attributes:r,text:s});continue}var l=i(),c=l.attributeName,f=l.attributeParam;if(c){t(r.concat({attributeName:c,attributeParam:null!=f?f:""}),c);continue}if(a){var u=n().attributeName;if(!u)throw Error('Expect an end tag marker "'+a+'" at position '+o+" but found no tag!");if(u!==a)throw Error('Expect an end tag marker "'+a+'" at position '+o+' but found tag "'+u+'"');return}break}}(),h};function x(t){return function(e){for(var i,n=d(e),r=l(n);!(i=r()).done;){var o=i.value;t(o.text,o.attributes.reduce(function(t,e){var i=e.attributeName,n=e.attributeParam;return i&&(t[i]=n),t},{}))}}}function g(t,e){if(void 0===e&&(e=1),(3===(t=t.replace(/^#/,"")).length||4===t.length)&&(t=t.split("").map(function(t){return t+t}).join("")),8===t.length){var i=parseInt(t.slice(6,8),16)/255;t=t.slice(0,6),e=i}var n=parseInt(t,16);return[n>>16&255,n>>8&255,255&n,e]}"function"==typeof SuppressedError&&SuppressedError;var v=0;t.RichTextComponent=function(t){function i(e){var i;return(i=t.call(this,e)||this).processedTextOptions=[],i.singleLineHeight=1.571,i.size=null,i.initialized=!1,i.canvasSize=null,i.name="MRichText"+v++,i}a(i,t);var n=i.prototype;return n.generateTextProgram=function(t){var i=this;this.processedTextOptions=[],x(function(t,n){/^\n+$/.test(t)&&(t=t.replace(/\n/g,"\n ")),t.split("\n").forEach(function(t,r){var o={text:t,fontSize:i.textStyle.fontSize,isNewLine:!1};r>0&&(o.isNewLine=!0),"b"in n&&(o.fontWeight=e.spec.TextWeight.bold),"i"in n&&(o.fontStyle=e.spec.FontStyle.italic),"size"in n&&n.size&&(o.fontSize=parseInt(n.size,10)),"color"in n&&n.color&&(o.fontColor=function(t,e){if(void 0===e&&(e=1),"string"!=typeof t||!t)throw Error("Invalid color string");return t.startsWith("#")?g(t,e):g(function(t){if("string"!=typeof t||!t)throw Error("Invalid color name provided");if("undefined"==typeof document)throw Error("This method requires a browser environment");var e=document.createElement("canvas"),i=e.getContext("2d");if(i)try{return i.fillStyle=t,i.fillStyle}finally{e.remove()}throw Error("Failed to get 2D context for color conversion!")}(t))}(n.color)),i.processedTextOptions.push(o)})})(t)},n.updateTexture=function(t){if(void 0===t&&(t=!0),this.isDirty&&this.context&&this.canvas){var e=!0===this.textLayout.useLegacyRichText;this.singleLineHeight=e?1.571:1,e?this.updateTextureLegacy(t):this.updateTextureModern(t)}},n.updateTextureLegacy=function(t){var i=this;if(this.isDirty&&this.context&&this.canvas){this.generateTextProgram(this.text);var n=this.textLayout,r=this.textStyle,o=n.overflow,a=n.letterSpace,s=void 0===a?0:a,h=this.context,l=0,c=0;h.save();var f=[],u=r.fontSize*this.textStyle.fontScale,p={richOptions:[],offsetX:[],width:0,lineHeight:u*this.singleLineHeight,offsetY:u*(this.singleLineHeight-1)/2};if(this.processedTextOptions.forEach(function(t){var e=t.text,n=t.isNewLine,o=t.fontSize;n&&(f.push(p),l=Math.max(l,p.width),p={richOptions:[],offsetX:[],width:0,lineHeight:u*i.singleLineHeight,offsetY:u*(i.singleLineHeight-1)/2},c+=p.lineHeight),h.font=(t.fontWeight||r.textWeight)+" 10px "+(t.fontFamily||r.fontFamily);var a=h.measureText(e),d=a.width;if(void 0!==a.actualBoundingBoxLeft&&void 0!==a.actualBoundingBoxRight){var x=a.actualBoundingBoxLeft+a.actualBoundingBoxRight;x>0&&(d=Math.max(d,x))}var g=o*i.singleLineHeight*i.textStyle.fontScale;g>p.lineHeight&&(c+=g-p.lineHeight,p.lineHeight=g,p.offsetY=o*i.textStyle.fontScale*(i.singleLineHeight-1)/2),p.offsetX.push(p.width),p.width+=(d<=0?0:d)*o*i.SCALE_FACTOR*i.textStyle.fontScale+e.length*s,p.richOptions.push(t)}),f.push(p),l=Math.max(l,p.width),c+=p.lineHeight,0===l||0===c){this.isDirty=!1,h.restore();return}(void 0===this.size||null===this.size)&&(this.size=this.item.transform.size.clone());var d=this.size,x=d.x,g=d.y;if(!this.initialized){this.canvasSize=this.canvasSize?this.canvasSize:new e.math.Vector2(l,c);var v=this.canvasSize,y=v.x,m=v.y;this.item.transform.size.set((void 0===x?1:x)*y*this.SCALE_FACTOR*this.SCALE_FACTOR,(void 0===g?1:g)*m*this.SCALE_FACTOR*this.SCALE_FACTOR),this.size=this.item.transform.size.clone(),this.initialized=!0}e.assertExist(this.canvasSize);var S=this.canvasSize,T=S.x,w=S.y;if(this.textLayout.width=T/r.fontScale,this.textLayout.height=w/r.fontScale,this.canvas.width=T,this.canvas.height=w,h.clearRect(0,0,T,w),h.fillStyle="rgba(255, 255, 255, "+this.ALPHA_FIX_VALUE+")",t||(h.translate(0,w),h.scale(1,-1)),0===f.length){h.restore();return}var E=n.getOffsetY(r,f.length,u*this.singleLineHeight,r.fontSize);f.forEach(function(t,n){var a=t.richOptions,s=t.offsetX,l=t.width,c=l,f=s;if(o===e.spec.TextOverflow.display&&l>T){var u=T/l;c*=u,f=s.map(function(t){return t*u})}var p=i.textLayout.getOffsetX(r,c);n>0&&(E+=t.lineHeight-t.offsetY),a.forEach(function(t,i){var n=r.fontScale,a=r.textColor,s=r.fontFamily,c=r.textWeight,u=r.fontStyle,d=t.text,x=t.fontSize,g=t.fontColor,v=void 0===g?a:g,y=t.fontFamily,m=t.fontWeight,S=t.fontStyle,w=x;o===e.spec.TextOverflow.display&&l>T&&(w/=l/T);var C=f[i]+p;h.font=(void 0===S?u:S)+" "+(void 0===m?c:m)+" "+w*n+"px "+(void 0===y?s:y),h.fillStyle="rgba("+v[0]+", "+v[1]+", "+v[2]+", "+v[3]+")",h.fillText(d,C,E)})});var C=h.getImageData(0,0,this.canvas.width,this.canvas.height),L=e.Texture.createWithData(this.engine,{data:new Uint8Array(C.data),width:C.width,height:C.height},{flipY:t,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR,wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE});this.disposeTextTexture(),this.renderer.texture=L,this.material.setTexture("_MainTex",L),this.isDirty=!1,h.restore()}},n.updateTextureModern=function(t){var i,n,r,o=this;this.generateTextProgram(this.text);var a=this.textLayout,s=this.textStyle,h=a.overflow,l=a.letterSpace,c=void 0===l?0:l,f=this.context,u=0,p=0;if(f){f.save();var d=[],x=s.fontSize*this.textStyle.fontScale,g={richOptions:[],offsetX:[],width:0,lineHeight:x*this.singleLineHeight+(this.textLayout.lineGap||0)*this.textStyle.fontScale,offsetY:(this.textLayout.lineGap||0)*this.textStyle.fontScale/2,chars:[]};if(this.processedTextOptions.forEach(function(t){var e=t.text,i=t.isNewLine,n=t.fontSize;i&&(p+=g.lineHeight,d.push(g),u=Math.max(u,g.width),g={richOptions:[],offsetX:[],width:0,lineHeight:x*o.singleLineHeight+(o.textLayout.lineGap||0)*o.textStyle.fontScale,offsetY:(o.textLayout.lineGap||0)*o.textStyle.fontScale/2,chars:[]}),f.font=(t.fontWeight||s.textWeight)+" 10px "+(t.fontFamily||s.fontFamily);var r=n*o.singleLineHeight*o.textStyle.fontScale+(o.textLayout.lineGap||0)*o.textStyle.fontScale;r>g.lineHeight&&(g.lineHeight=r,g.offsetY=(o.textLayout.lineGap||0)*o.textStyle.fontScale/2),g.offsetX.push(g.width);for(var a=0,h=[],l=0;l<e.length;l++){var v=e[l],y=f.measureText(v).width,m=(y<=0?0:y)*n*o.SCALE_FACTOR*o.textStyle.fontScale;h.push({char:v,x:a,width:m}),a+=m+c}g.chars.push(h),g.width+=a,g.richOptions.push(t)}),p+=g.lineHeight,d.push(g),0===(u=Math.max(u,g.width))||0===p){this.isDirty=!1,f.restore();return}(void 0===this.size||null===this.size)&&(this.size=this.item.transform.size.clone());var v=this.size,y=v.x,m=v.y;if(!this.initialized){this.canvasSize=this.canvasSize?this.canvasSize:new e.math.Vector2(u,p);var S=this.canvasSize,T=S.x,w=S.y;this.item.transform.size.set((void 0===y?1:y)*T*this.SCALE_FACTOR*this.SCALE_FACTOR,(void 0===m?1:m)*w*this.SCALE_FACTOR*this.SCALE_FACTOR),this.size=this.item.transform.size.clone(),this.initialized=!0}e.assertExist(this.canvasSize);var E=this.canvasSize,C=E.x,L=E.y;if(this.textLayout.width=C/s.fontScale,this.textLayout.height=L/s.fontScale,this.canvas.width=C,this.canvas.height=L,f.clearRect(0,0,C,L),f.fillStyle="rgba(255, 255, 255, "+this.ALPHA_FIX_VALUE+")",t||(f.translate(0,L),f.scale(1,-1)),0===d.length){f.restore();return}var z=d.map(function(t){return t.lineHeight}),b=d[0],O=(i=Math).max.apply(i,[].concat(null!=(r=null==b?void 0:null==(n=b.richOptions)?void 0:n.map(function(t){return t.fontSize}))?r:[this.textStyle.fontSize]))*this.textStyle.fontScale*this.singleLineHeight,A=a.getOffsetYRich(this.textStyle,z,O);d.forEach(function(t,i){var n=t.richOptions,r=t.offsetX,a=t.width,l=t.chars,c=a,u=r;if(h===e.spec.TextOverflow.display&&a>C){var p=C/a;c*=p,u=r.map(function(t){return t*p}),l.forEach(function(t){t.forEach(function(t){t.x*=p,t.width*=p})})}var x=o.textLayout.getOffsetX(s,c);n.forEach(function(i,n){var r=s.fontScale,o=s.textColor,l=s.fontFamily,c=s.textWeight,p=s.fontStyle,d=i.fontSize,g=i.fontColor,v=void 0===g?o:g,y=i.fontFamily,m=i.fontWeight,S=i.fontStyle,T=d;h===e.spec.TextOverflow.display&&a>C&&(T/=a/C);var w=u[n]+x;f.font=(void 0===S?p:S)+" "+(void 0===m?c:m)+" "+T*r+"px "+(void 0===y?l:y),f.fillStyle="rgba("+v[0]+", "+v[1]+", "+v[2]+", "+v[3]+")",t.chars[n].forEach(function(t){f.fillText(t.char,w+t.x,A)})}),i<d.length-1&&(A+=z[i+1])});var R=f.getImageData(0,0,this.canvas.width,this.canvas.height),_=e.Texture.createWithData(this.engine,{data:new Uint8Array(R.data),width:R.width,height:R.height},{flipY:t,magFilter:e.glContext.LINEAR,minFilter:e.glContext.LINEAR,wrapS:e.glContext.CLAMP_TO_EDGE,wrapT:e.glContext.CLAMP_TO_EDGE});this.renderer.texture=_,this.material.setTexture("_MainTex",_),this.isDirty=!1,f.restore()}},n.setShadowOffsetY=function(t){throw Error("Method not implemented.")},n.setShadowBlur=function(t){throw Error("Method not implemented.")},n.setShadowOffsetX=function(t){throw Error("Method not implemented.")},n.setShadowColor=function(t){throw Error("Method not implemented.")},n.setOutlineWidth=function(t){throw Error("Method not implemented.")},n.setAutoWidth=function(t){throw Error("Method not implemented.")},n.updateWithOptions=function(t){this.textStyle=new e.TextStyle(t),this.textLayout=new e.TextLayout(t),this.textLayout.textBaseline=t.textBaseline||e.spec.TextBaseline.middle,this.text=t.text?t.text.toString():" "},n.renderText=function(t){var i=t.size;i&&(this.canvasSize=new e.math.Vector2(i[0],i[1])),this.updateTexture()},i}(e.TextComponent),t.RichTextComponent=function(t,e,i,n){var r,o=arguments.length,a=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(a=(o<3?r(a):o>3?r(e,i,a):r(e,i))||a);return o>3&&a&&Object.defineProperty(e,i,a),a}([e.effectsClass(e.spec.DataType.RichTextComponent)],t.RichTextComponent);var y="2.7.4";e.registerPlugin("rich-text",s,e.VFXItem),e.logger.info("Plugin rich text version: "+y+"."),y!==r.version&&console.error("注意:请统一 RichText 插件与 Player 版本,不统一的版本混用会有不可预知的后果!","\nAttention: Please ensure the RichText plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!"),t.RichTextLoader=s,t.escape=function(t){if("string"!=typeof t)throw Error("Input must be a string");return t.replace(/\\/g,"\\\\").replace(/=/g,"\\=").replace(/</g,"\\<").replace(/>/g,"\\>").replace(/\//g,"\\/")},t.generateProgram=x,t.isRichText=function(t){var e=p(t).filter(function(t){var e=t.tokenType;return"ContextStart"===e||"ContextEnd"===e}),i=e.filter(function(t){return"ContextStart"===t.tokenType}),n=e.filter(function(t){return"ContextEnd"===t.tokenType});return i.length===n.length&&!!i.length&&function t(e,i){var n=e[0],r=e.slice(1);if(void 0===i&&(i=[]),!n)return 0===i.length;if("ContextStart"===n.tokenType)return t(r,i.concat(n.value));if("ContextEnd"===n.tokenType)return i[i.length-1]===n.value&&t(r,i.slice(0,-1));throw Error("Unexpected token: "+n.tokenType)}(e.map(function(t){var e=t.tokenType,i=t.value;return{tokenType:e,value:"ContextStart"===e?i.match(c)[1]:i.match(f)[1]}}))},t.lexer=p,t.richTextParser=d,t.unescape=function(t){if("string"!=typeof t)throw Error("Input must be a string");return t.replace(/\\\//g,"/").replace(/\\>/g,">").replace(/\\</g,"<").replace(/\\=/g,"=").replace(/\\\\/g,"\\")},t.version=y,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
6
|
+
* Version: v2.8.0-alpha.1
|
|
7
|
+
*/function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@galacean/effects")):"function"==typeof define&&define.amd?define(["exports","@galacean/effects"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ge=t.ge||{},t.ge.richTextPlugin={}),t.ge)}(this,function(t,e){"use strict";var i,n,r=function(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(i){if("default"!==i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}}),e.default=t,Object.freeze(e)}(e);function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&a(t,e)}var s=function(t){function e(){var e;return e=t.apply(this,arguments)||this,e.name="rich-text",e}return o(e,t),e}(e.AbstractPlugin);function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=Array(e);i<e;i++)n[i]=t[i];return n}function c(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(i)return(i=i.call(t)).next.bind(i);if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return l(t,void 0);var i=Object.prototype.toString.call(t).slice(8,-1);if("Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i)return Array.from(i);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return l(t,void 0)}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(i=n||(n={})).ContextStart="ContextStart",i.Text="Text",i.ContextEnd="ContextEnd",i.EscapedChar="EscapedChar";var h=/^<([a-z]+)(=([^>]+))?>$/,f=/^<\/([a-z]+)>$/,u=[["EscapedChar",/^\\([=<>\\/])/],["ContextStart",/^<[a-z]+(=[^>]+)?>/],["ContextEnd",/^<\/[a-z]+>/],["Text",/^[^</>=\\]+/]],g=function(t,e,i){if(void 0===e&&(e=[]),void 0===i&&(i=0),!t)return e;var n=/^\\([=<>\\/])/.exec(t);if(n){var r=n[1];return g(t.slice(2),e.concat({tokenType:"Text",value:r}),i+2)}for(var a,o=c(u);!(a=o()).done;){var s=a.value,l=s[0],h=s[1];if("EscapedChar"!==l){var f=h.exec(t);if(f){var p=f[0],x=p.length;return g(t.slice(x),e.concat({tokenType:l,value:p}),i+x)}}}if(t.length>0)return g(t.slice(1),e.concat({tokenType:"Text",value:t[0]}),i+1);throw Error('Unexpected token: "'+t[0]+'" at position '+i+' while reading "'+t+'"')},p=function(t){var e=function(){for(var t,e="",i=!1;r.length>0&&(null==(t=r[0])?void 0:t.tokenType)==="Text";){var n=o();n&&(e+=n.value,i=!0)}return i?e:void 0},i=function(){var t=s();if((null==t?void 0:t.tokenType)==="ContextStart"){o();var e,i=t.value.match(h);if(i)return{attributeName:i[1],attributeParam:null!=(e=i[3])?e:""};throw Error("Expected a start tag marker at position "+a)}return{}},n=function(){var t=s();if((null==t?void 0:t.tokenType)==="ContextEnd"){o();var e=t.value.match(f);if(e)return{attributeName:e[1]};throw Error("Expect an end tag marker at position "+a)}return{}},r=g(t),a=0,o=function(){var t,e=r.shift();return a+=null!=(t=null==e?void 0:e.value.length)?t:0,e},s=function(){return r[0]},l=[];return!function t(r,o){for(void 0===r&&(r=[]),void 0===o&&(o="");;){var s=e();if(s){l.push({attributes:r,text:s});continue}var c=i(),h=c.attributeName,f=c.attributeParam;if(h){t(r.concat({attributeName:h,attributeParam:null!=f?f:""}),h);continue}if(o){var u=n().attributeName;if(!u)throw Error('Expect an end tag marker "'+o+'" at position '+a+" but found no tag!");if(u!==o)throw Error('Expect an end tag marker "'+o+'" at position '+a+' but found tag "'+u+'"');return}break}}(),l};function x(t){return function(e){for(var i,n=p(e),r=c(n);!(i=r()).done;){var a=i.value;t(a.text,a.attributes.reduce(function(t,e){var i=e.attributeName,n=e.attributeParam;return i&&(t[i]=n),t},{}))}}}"function"==typeof SuppressedError&&SuppressedError;var d=function(){function t(t){this.width=0,this.height=0;var i=t.size,n=t.textOverflow,r=void 0===n?e.spec.TextOverflow.clip:n,a=t.textVerticalAlign,o=void 0===a?e.spec.TextVerticalAlign.middle:a,s=t.textAlign,l=void 0===s?e.spec.TextAlignment.left:s,c=t.letterSpace,h=t.lineHeight,f=t.wrapEnabled,u=t.maxTextWidth,g=t.maxTextHeight,p=t.sizeMode,x=void 0===p?e.spec.TextSizeMode.autoWidth:p,d=t.useLegacyRichText;this.letterSpace=void 0===c?0:c,this.lineHeight=void 0===h?.571:h,this.useLegacyRichText=void 0!==d&&d,this.overflow=r,this.textVerticalAlign=o,this.textAlign=l,this.width=i?i[0]:100,this.height=i?i[1]:100,this.wrapEnabled=void 0!==f&&f,this.maxTextWidth=void 0===u?350:u,this.maxTextHeight=void 0===g?1e3:g,this.sizeMode=x}var i=t.prototype;return i.getOffsetY=function(t,i,n,r,a){var o=t.outlineWidth,s=t.fontScale,l=(n-r)/3,c=r+o*s,h=void 0!==a?a:n*(i-1),f=0;switch(this.textVerticalAlign){case e.spec.TextVerticalAlign.top:f=c+l;break;case e.spec.TextVerticalAlign.middle:f=(this.height*s-h+c)/2;break;case e.spec.TextVerticalAlign.bottom:f=this.height*s-h-l}return f},i.getOffsetX=function(t,i){var n=0;switch(this.textAlign){case e.spec.TextAlignment.left:n=t.outlineWidth*t.fontScale;break;case e.spec.TextAlignment.middle:n=(this.width*t.fontScale-i)/2;break;case e.spec.TextAlignment.right:n=this.width*t.fontScale-i}return n},i.getOffsetYRich=function(t,i,n){if(0===i.length)return 0;var r=t.outlineWidth,a=t.fontScale,o=i.reduce(function(t,e){return t+e},0),s=(i[0]-n)/3,l=n+r*a,c=o-i[0],h=0;switch(this.textVerticalAlign){case e.spec.TextVerticalAlign.top:h=l+s;break;case e.spec.TextVerticalAlign.middle:h=(this.height*a-o)/2+l;break;case e.spec.TextVerticalAlign.bottom:h=this.height*a-c-s}return h},i.getOffsetXRich=function(t,i,n){switch(this.textAlign){case e.spec.TextAlignment.left:return t.outlineWidth;case e.spec.TextAlignment.middle:return(i-n)/2;case e.spec.TextAlignment.right:return i-n;default:return 0}},i.setSize=function(t,e){this.width=t,this.height=e},t}();function v(t,e){if(void 0===e&&(e=1),(3===(t=t.replace(/^#/,"")).length||4===t.length)&&(t=t.split("").map(function(t){return t+t}).join("")),8===t.length){var i=parseInt(t.slice(6,8),16)/255;t=t.slice(0,6),e=i}var n=parseInt(t,16);return[n>>16&255,n>>8&255,255&n,e]}var m=function(){function t(){}var e=t.prototype;return e.computeLines=function(t,e,i,n,r,a,o,s){var l=this,c=[],h=[],f=(n.lineHeight||0)*a,u=this.createNewLine(),g=0,p=0,x=function(){if(0!==u.chars.length){u.lineHeight=0===c.length?(u.lineAscent||0)+(u.lineDescent||0):f;var t=0===c.length?0:h[h.length-1]+f;h.push(t),p+=u.lineHeight,c.push(u),g=Math.max(g,u.width),u=l.createNewLine()}};t.forEach(function(t){var n=t.text,r=t.isNewLine,l=t.fontSize;r&&x();var c=t.fontStyle||i.fontStyle||"normal";e.font=c+" "+(t.fontWeight||i.textWeight)+" 10px "+(t.fontFamily||i.fontFamily),u.offsetX.push(u.width);for(var h=0,f=[],g=0,p=0,d=0;d<n.length;d++){var v=n[d],m=e.measureText(v),y=m.width,S=(y<=0?0:y)*l*s*a,T=l*a*s,b=m.actualBoundingBoxAscent*T,w=m.actualBoundingBoxDescent*T;g=Math.max(g,b),p=Math.max(p,w),d>0&&(h+=o),f.push({char:v,x:h}),h+=S}u.chars.push(f),u.width+=h,u.richOptions.push(t),u.lineAscent=Math.max(u.lineAscent||0,g),u.lineDescent=Math.max(u.lineDescent||0,p)}),x();var d=1/0,v=-1/0;if(0===c.length)return{lines:c,maxLineWidth:g,totalHeight:p,bboxTop:0,bboxBottom:0,bboxHeight:0};for(var m=0;m<c.length;m++)d=Math.min(d,h[m]-(c[m].lineAscent||0)),v=Math.max(v,h[m]+(c[m].lineDescent||0));var y=v-d;return{lines:c,maxLineWidth:g,totalHeight:p,bboxTop:d,bboxBottom:v,bboxHeight:y}},e.createNewLine=function(){return{richOptions:[],offsetX:[],width:0,lineHeight:0,offsetY:0,chars:[],lineAscent:0,lineDescent:0}},t}(),y=function(){function t(){}var e=t.prototype;return e.computeLines=function(t,e,i,n,r,a,o,s){var l=this,c=[],h=[],f=(n.lineHeight||0)*a,u=this.createNewLine(),g=0,p=0,x=null,d=0,v=[],m=null,y=function(){if(S(),0!==u.chars.length){u.lineHeight=0===c.length?(u.lineAscent||0)+(u.lineDescent||0):f;var t=0===c.length?0:h[h.length-1]+f;h.push(t),p+=u.lineHeight,c.push(u),g=Math.max(g,u.width),u=l.createNewLine(),x=null,d=0,v=[],m=null}},S=function(){0!==v.length&&(null===x&&(x=u.width),u.offsetX.push(x),u.chars.push(v),m&&u.richOptions.push(m),x=null,d=0,v=[],m=null)};t.forEach(function(t){var r=t.text,l=t.isNewLine,c=t.fontSize,h=t.fontStyle||i.fontStyle||"normal";e.font=h+" "+(t.fontWeight||i.textWeight)+" 10px "+(t.fontFamily||i.fontFamily),l&&(S(),y());for(var f=0;f<r.length;f++){var g=r[f],p=e.measureText(g),T=p.width,b=(T<=0?0:T)*c*s*a,w=c*a*s,A=p.actualBoundingBoxAscent*w,O=p.actualBoundingBoxDescent*w,z=v.length>0?o:0;u.width+z+b>(n.maxTextWidth||1/0)&&(S(),y()),null===x&&(x=u.width,m=t),v.length>0&&(d+=o,u.width+=o),v.push({char:g,x:d}),u.lineAscent=Math.max(u.lineAscent||0,A),u.lineDescent=Math.max(u.lineDescent||0,O),d+=b,u.width+=b}S()}),y();for(var T=1/0,b=-1/0,w=0;w<c.length;w++)T=Math.min(T,h[w]-(c[w].lineAscent||0)),b=Math.max(b,h[w]+(c[w].lineDescent||0));var A=b-T;return{lines:c,maxLineWidth:g,totalHeight:p,bboxTop:T,bboxBottom:b,bboxHeight:A}},e.createNewLine=function(){return{richOptions:[],offsetX:[],width:0,lineHeight:0,offsetY:0,chars:[],lineAscent:0,lineDescent:0}},t}(),S=function(){function t(){}return t.prototype.apply=function(t,e,i,n){var r=function(t,e){return Math.abs(e)>1e-5?t/e:1},a=Math.max(1,i.maxTextWidth||e.canvasWidth),o=Math.max(1,i.maxTextHeight||e.canvasHeight),s=Math.max(1,null!=(f=e.contentWidth)?f:e.canvasWidth),l=Math.max(1,null!=(u=e.bboxHeight)?u:e.canvasHeight),h=Math.min(1,r(a,s),r(o,l));if(h>.9999)return{globalScale:1};for(var f,u,g,p=c(t);!(g=p()).done;){var x=g.value;if(x.width*=h,x.lineHeight*=h,x.offsetX)for(var d=0;d<x.offsetX.length;d++)x.offsetX[d]*=h;for(var v,m=c(x.chars||[]);!(v=m()).done;)for(var y,S=v.value,T=c(S);!(y=T()).done;){var b=y.value;b.x*=h}for(var w,A=c(x.richOptions||[]);!(w=A()).done;){var O=w.value;O.fontSize*=h}null!=x.lineAscent&&(x.lineAscent*=h),null!=x.lineDescent&&(x.lineDescent*=h)}return{globalScale:h}},t}(),T=function(){function t(){}return t.prototype.apply=function(t,e,i,n){return{globalScale:1}},t}(),b=function(){function t(){}return t.prototype.apply=function(t,e,i,n){return{globalScale:1}},t}(),w=function(){function t(){}return t.prototype.getHorizontalOffsets=function(t,i,n,r,a){var o=r.maxTextWidth,s=i.baselineCompensationX||0,l=t.map(function(t){return r.getOffsetXRich(a,o,t.width)});return{lineOffsets:r.overflow===e.spec.TextOverflow.visible?l.map(function(t){return t+s}):l}},t}(),A=function(){function t(){}return t.prototype.getVerticalOffsets=function(t,i,n,r,a,o){var s=t.map(function(t){return t.lineHeight}),l=i.baselineCompensationY||0,c=0;if(0===t.length)return{baselineY:0,lineYOffsets:[]};switch(r.overflow){case e.spec.TextOverflow.visible:var h,f,u,g,p=r.maxTextHeight,x=null!=(h=i.bboxTop)?h:0,d=null!=(u=i.bboxBottom)?u:x+(null!=(f=i.bboxHeight)?f:0),v=null!=(g=i.bboxHeight)?g:d-x,m=0;switch(r.textVerticalAlign){case e.spec.TextVerticalAlign.top:m=-x;break;case e.spec.TextVerticalAlign.middle:m=(p-v)/2-x;break;case e.spec.TextVerticalAlign.bottom:m=p-v-x}c=m+l;break;case e.spec.TextOverflow.clip:var y=t[0];if(y){var S,T=y.richOptions.map(function(t){return t.fontSize}),b=(S=Math).max.apply(S,[].concat(T.length?T:[a.fontSize]))*a.fontScale*o;c=r.getOffsetYRich(a,s,b)+l}else c=r.getOffsetYRich(a,s,a.fontSize*a.fontScale)+l;break;case e.spec.TextOverflow.display:for(var w=r.maxTextHeight,A=[0],O=1;O<t.length;O++)A[O]=A[O-1]+t[O].lineHeight;for(var z=1/0,C=-1/0,L=0;L<t.length;L++){var H,E,W=null!=(H=t[L].lineAscent)?H:0,V=null!=(E=t[L].lineDescent)?E:0;z=Math.min(z,A[L]-W),C=Math.max(C,A[L]+V)}var R=C-z,k=0;switch(r.textVerticalAlign){case e.spec.TextVerticalAlign.top:k=-z;break;case e.spec.TextVerticalAlign.middle:k=(w-R)/2-z;break;case e.spec.TextVerticalAlign.bottom:k=w-R-z}for(var M=[],F=k,D=0;D<t.length;D++)M.push(F),D<t.length-1&&(F+=t[D+1].lineHeight);return{baselineY:k,lineYOffsets:M}}var _=[],B=c;return t.forEach(function(e,i){_.push(B),i<t.length-1&&(B+=t[i+1].lineHeight)}),{baselineY:c,lineYOffsets:_}},t}(),O=function(){function t(){}return t.createWrapStrategy=function(t){return t?new y:new m},t.createOverflowStrategy=function(t){switch(t){case e.spec.TextOverflow.clip:return new T;case e.spec.TextOverflow.display:return new S;case e.spec.TextOverflow.visible:default:return new b}},t.createHorizontalAlignStrategy=function(){return new w},t.createVerticalAlignStrategy=function(){return new A},t}(),z=0;t.RichTextComponent=function(t){function i(i){var n;return(n=t.call(this,i)||this).isDirty=!0,n.text="",n.processedTextOptions=[],n.singleLineHeight=1.571,n.size=null,n.initialized=!1,n.canvasSize=null,n.SCALE_FACTOR=.1,n.ALPHA_FIX_VALUE=1/255,n.name="MRichText"+z++,n.initTextBase(i),n.richWrapStrategy=O.createWrapStrategy(),n.richOverflowStrategy=O.createOverflowStrategy(e.spec.TextOverflow.display),n.richHorizontalAlignStrategy=O.createHorizontalAlignStrategy(),n.richVerticalAlignStrategy=O.createVerticalAlignStrategy(),n}o(i,t);var n=i.prototype;return n.onUpdate=function(e){t.prototype.onUpdate.call(this,e),this.updateTexture()},n.onDestroy=function(){t.prototype.onDestroy.call(this),this.disposeTextTexture()},n.fromData=function(i){t.prototype.fromData.call(this,i);var n=i.interaction,r=i.options;this.interaction=n,this.textStyle=new e.TextStyle(r),this.textLayout=new d(r),this.text=r.text?r.text.toString():" ",this.textLayout.useLegacyRichText&&(this.textLayout.textVerticalAlign=e.spec.TextVerticalAlign.middle),this.updateStrategies(),this.renderText(r),this.material.setColor("_Color",new e.math.Color(1,1,1,1))},n.updateStrategies=function(){var t=this.textLayout;t&&(this.richWrapStrategy=O.createWrapStrategy(t.wrapEnabled),this.richOverflowStrategy=O.createOverflowStrategy(t.overflow))},n.generateTextProgram=function(t){var i=this;this.processedTextOptions=[],x(function(t,n){/^\n+$/.test(t)&&(t=t.replace(/\n/g,"\n ")),t.split("\n").forEach(function(t,r){var a={text:t,fontSize:i.textStyle.fontSize,isNewLine:!1};r>0&&(a.isNewLine=!0),"b"in n&&(a.fontWeight=e.spec.TextWeight.bold),"i"in n&&(a.fontStyle=e.spec.FontStyle.italic),"size"in n&&n.size&&(a.fontSize=parseInt(n.size,10)),"color"in n&&n.color&&(a.fontColor=function(t,e){if(void 0===e&&(e=1),"string"!=typeof t||!t)throw Error("Invalid color string");return t.startsWith("#")?v(t,e):v(function(t){if("string"!=typeof t||!t)throw Error("Invalid color name provided");if("undefined"==typeof document)throw Error("This method requires a browser environment");var e=document.createElement("canvas"),i=e.getContext("2d");if(i)try{return i.fillStyle=t,i.fillStyle}finally{e.remove()}throw Error("Failed to get 2D context for color conversion!")}(t))}(n.color)),i.processedTextOptions.push(a)})})(t)},n.updateWithOptions=function(t){this.textStyle=new e.TextStyle(t),this.textLayout=new d(t),this.text=t.text?t.text.toString():" ",this.textLayout.useLegacyRichText&&(this.textLayout.textVerticalAlign=e.spec.TextVerticalAlign.middle),this.updateStrategies(),this.isDirty=!0},n.renderText=function(t){var i=t.size;i&&(this.canvasSize=new e.math.Vector2(i[0],i[1])),this.updateTexture()},n.updateTexture=function(t){if(void 0===t&&(t=!0),this.isDirty&&this.context&&this.canvas&&this.textStyle&&this.textLayout){var e=!0===this.textLayout.useLegacyRichText;this.singleLineHeight=e?1.571:1,e?this.updateTextureLegacy(t):this.updateTextureWithStrategies(t)}},n.updateTextureLegacy=function(t){var i=this;if(this.isDirty&&this.context&&this.canvas&&this.textStyle){this.generateTextProgram(this.text);var n=0,r=0,a=this.textLayout,o=this.textStyle,s=a.overflow,l=a.letterSpace,c=void 0===l?0:l,h=this.context,f=[],u=o.fontSize*o.fontScale,g={richOptions:[],offsetX:[],width:0,lineHeight:u*this.singleLineHeight,offsetY:u*(this.singleLineHeight-1)/2};if(this.processedTextOptions.forEach(function(t){var e=t.text,a=t.isNewLine,s=t.fontSize;a&&(f.push(g),n=Math.max(n,g.width),g={richOptions:[],offsetX:[],width:0,lineHeight:u*i.singleLineHeight,offsetY:u*(i.singleLineHeight-1)/2},r+=g.lineHeight),h.font=(t.fontWeight||o.textWeight)+" 10px "+(t.fontFamily||o.fontFamily);var l=h.measureText(e),p=l.width;if(void 0!==l.actualBoundingBoxLeft&&void 0!==l.actualBoundingBoxRight){var x=l.actualBoundingBoxLeft+l.actualBoundingBoxRight;x>0&&(p=Math.max(p,x))}var d=s*i.singleLineHeight*o.fontScale;d>g.lineHeight&&(r+=d-g.lineHeight,g.lineHeight=d,g.offsetY=s*o.fontScale*(i.singleLineHeight-1)/2),g.offsetX.push(g.width),g.width+=(p<=0?0:p)*s*i.SCALE_FACTOR*o.fontScale+e.length*c,g.richOptions.push(t)}),f.push(g),n=Math.max(n,g.width),r+=g.lineHeight,0===n||0===r){this.isDirty=!1;return}(void 0===this.size||null===this.size)&&(this.size=this.item.transform.size.clone());var p=this.size,x=p.x,d=p.y;if(!this.initialized){this.canvasSize=this.canvasSize?this.canvasSize:new e.math.Vector2(n,r);var v=this.canvasSize,m=v.x,y=v.y;this.item.transform.size.set((void 0===x?1:x)*m*this.SCALE_FACTOR*this.SCALE_FACTOR,(void 0===d?1:d)*y*this.SCALE_FACTOR*this.SCALE_FACTOR),this.size=this.item.transform.size.clone(),this.initialized=!0}e.assertExist(this.canvasSize);var S=this.canvasSize,T=S.x,b=S.y;a.width=T/o.fontScale,a.height=b/o.fontScale,this.renderToTexture(T,b,t,function(t){if(0!==f.length){var n=a.getOffsetY(o,f.length,u*i.singleLineHeight,o.fontSize);f.forEach(function(i,r){var l=i.richOptions,c=i.offsetX,h=i.width,f=h,u=c;if(s===e.spec.TextOverflow.display&&h>T){var g=T/h;f*=g,u=c.map(function(t){return t*g})}var p=a.getOffsetX(o,f);r>0&&(n+=i.lineHeight-i.offsetY),l.forEach(function(i,r){var a=o.fontScale,l=o.textColor,c=o.fontFamily,f=o.textWeight,g=o.fontStyle,x=i.text,d=i.fontSize,v=i.fontColor,m=void 0===v?l:v,y=i.fontFamily,S=i.fontWeight,b=i.fontStyle,w=d;s===e.spec.TextOverflow.display&&h>T&&(w/=h/T);var A=u[r]+p;t.font=(void 0===b?g:b)+" "+(void 0===S?f:S)+" "+w*a+"px "+(void 0===y?c:y);var O=m[0],z=m[1],C=m[2],L=m[3];t.fillStyle="rgba("+O+", "+z+", "+C+", "+L+")",t.fillText(x,A,n)})})}},{disposeOld:!1}),this.isDirty=!1}},n.updateTextureWithStrategies=function(t){var i=this;if(this.isDirty&&this.context&&this.canvas){this.generateTextProgram(this.text);var n=this.textLayout,r=n.letterSpace,a=this.context;if(a){var o=this.richWrapStrategy.computeLines(this.processedTextOptions,a,this.textStyle,n,this.singleLineHeight,this.textStyle.fontScale,void 0===r?0:r,this.SCALE_FACTOR);if(0===o.lines.length||0===o.maxLineWidth||0===o.totalHeight){this.isDirty=!1;return}var s=this.resolveCanvasSize(o,n,this.textStyle,this.singleLineHeight);this.setCanvasSize(s);var l=this.richOverflowStrategy.apply(o.lines,s,n,this.textStyle),c=this.richHorizontalAlignStrategy.getHorizontalOffsets(o.lines,s,l,n,this.textStyle),h=this.richVerticalAlignStrategy.getVerticalOffsets(o.lines,s,l,n,this.textStyle,this.singleLineHeight);e.assertExist(this.canvasSize);var f=this.canvasSize,u=f.x,g=f.y;n.width=u/this.textStyle.fontScale,n.height=g/this.textStyle.fontScale,this.renderToTexture(u,g,t,function(t){i.drawTextWithStrategies(t,o.lines,c,h,l,i.textStyle)},{disposeOld:!1}),this.isDirty=!1}}},n.setCanvasSize=function(t){var i=this;(void 0===this.size||null===this.size)&&(this.size=this.item.transform.size.clone());var n=this.size,r=n.x,a=n.y,o=this.textLayout;switch(o.overflow){case e.spec.TextOverflow.visible:var s,l,c,h,f,u,g=o.maxTextWidth,p=o.maxTextHeight,x=null!=(l=t.bboxTop)?l:0,d=null!=(h=t.bboxBottom)?h:x+(null!=(c=t.bboxHeight)?c:0),v=null!=(f=t.bboxHeight)?f:d-x,m=0;switch(o.textVerticalAlign){case e.spec.TextVerticalAlign.top:m=-x;break;case e.spec.TextVerticalAlign.middle:m=(p-v)/2-x;break;case e.spec.TextVerticalAlign.bottom:m=p-v-x}var y=Math.max(0,-(m+x)),S=Math.max(0,m+d-p),T=y,b=S;switch(o.textVerticalAlign){case e.spec.TextVerticalAlign.top:T=S,b=S;break;case e.spec.TextVerticalAlign.bottom:T=y,b=y;break;case e.spec.TextVerticalAlign.middle:T=y,b=S}var w=T,A=(t.lines||[]).map(function(t){return o.getOffsetXRich(i.textStyle,g,t.width)}),O=Math.max(0,-(A.length>0?(s=Math).min.apply(s,[].concat(A)):0)),z=g+O+O,C=p+T+b;t.baselineCompensationX=O,t.baselineCompensationY=w,t.canvasWidth=z,t.canvasHeight=C,this.canvasSize=new e.math.Vector2(z,C);var L=null!=(u=this.size)?u:this.item.transform.size,H=L.x,E=L.y;this.item.transform.size.set((void 0===H?1:H)*z*this.SCALE_FACTOR*this.SCALE_FACTOR,(void 0===E?1:E)*C*this.SCALE_FACTOR*this.SCALE_FACTOR),this.size=this.item.transform.size.clone(),this.initialized=!0;break;case e.spec.TextOverflow.clip:var W,V=o.maxTextWidth,R=o.maxTextHeight;t.canvasWidth=V,t.canvasHeight=R,t.baselineCompensationX=0,t.baselineCompensationY=0,this.canvasSize=new e.math.Vector2(V,R),o.width=V/this.textStyle.fontScale,o.height=R/this.textStyle.fontScale;var k=null!=(W=this.size)?W:this.item.transform.size,M=k.x,F=k.y;this.item.transform.size.set((void 0===M?1:M)*V*this.SCALE_FACTOR*this.SCALE_FACTOR,(void 0===F?1:F)*R*this.SCALE_FACTOR*this.SCALE_FACTOR),this.size=this.item.transform.size.clone(),this.initialized=!0;break;case e.spec.TextOverflow.display:this.initialized||(this.canvasSize=new e.math.Vector2(o.maxTextWidth,o.maxTextHeight),this.item.transform.size.set((void 0===r?1:r)*this.canvasSize.x*this.SCALE_FACTOR*this.SCALE_FACTOR,(void 0===a?1:a)*this.canvasSize.y*this.SCALE_FACTOR*this.SCALE_FACTOR),this.size=this.item.transform.size.clone(),this.initialized=!0)}},n.resolveCanvasSize=function(t,e,i,n){var r=Math.max(1,t.maxLineWidth||0),a=Math.max(1,t.totalHeight||0);return e.width=r/i.fontScale,e.height=a/i.fontScale,{canvasWidth:r,canvasHeight:a,contentWidth:t.maxLineWidth,bboxTop:t.bboxTop,bboxBottom:t.bboxBottom,bboxHeight:t.bboxHeight,lines:t.lines}},n.drawTextWithStrategies=function(t,e,i,n,r,a){var o=n.baselineY,s=i.lineOffsets;e.forEach(function(i,n){var r=i.richOptions,l=i.chars,c=s[n],h=o;r.forEach(function(e,n){var r=a.fontScale,o=a.textColor,s=a.fontFamily,f=a.textWeight,u=a.fontStyle,g=e.fontSize,p=e.fontColor,x=void 0===p?o:p,d=e.fontFamily,v=e.fontWeight,m=e.fontStyle;t.font=(void 0===m?u:m)+" "+(void 0===v?f:v)+" "+g*r+"px "+(void 0===d?s:d);var y=x[0],S=x[1],T=x[2],b=x[3];t.fillStyle="rgba("+y+", "+S+", "+T+", "+b+")";var w=i.offsetX&&i.offsetX[n]?i.offsetX[n]:0;l[n].forEach(function(e){t.fillText(e.char,c+w+e.x,h)})}),n<e.length-1&&(o+=e[n+1].lineHeight)})},n.unsupported=function(t){throw Error("RichTextComponent does not support "+t+" at runtime.")},n.setShadowOffsetY=function(t){this.unsupported("setShadowOffsetY")},n.setShadowBlur=function(t){this.unsupported("setShadowBlur")},n.setShadowOffsetX=function(t){this.unsupported("setShadowOffsetX")},n.setShadowColor=function(t){this.unsupported("setShadowColor")},n.setOutlineWidth=function(t){this.unsupported("setOutlineWidth")},n.setAutoWidth=function(t){this.unsupported("setAutoWidth")},n.setFontSize=function(t){this.unsupported("setFontSize")},n.setTextBaseline=function(t){console.warn("setTextBaseline 已废弃,请改用 setTextVerticalAlign。本次调用将转调用 setTextVerticalAlign。"),this.setTextVerticalAlign(t)},i}(e.MaskableGraphic),t.RichTextComponent=function(t,e,i,n){var r,a=arguments.length,o=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(o=(a<3?r(o):a>3?r(e,i,o):r(e,i))||o);return a>3&&o&&Object.defineProperty(e,i,o),o}([e.effectsClass(e.spec.DataType.RichTextComponent)],t.RichTextComponent),e.applyMixins(t.RichTextComponent,[e.TextComponentBase]);var C="2.8.0-alpha.1";e.registerPlugin("rich-text",s,e.VFXItem),e.logger.info("Plugin rich text version: "+C+"."),C!==r.version&&console.error("注意:请统一 RichText 插件与 Player 版本,不统一的版本混用会有不可预知的后果!","\nAttention: Please ensure the RichText plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!"),t.RichTextLoader=s,t.escape=function(t){if("string"!=typeof t)throw Error("Input must be a string");return t.replace(/\\/g,"\\\\").replace(/=/g,"\\=").replace(/</g,"\\<").replace(/>/g,"\\>").replace(/\//g,"\\/")},t.generateProgram=x,t.isRichText=function(t){var e=g(t).filter(function(t){var e=t.tokenType;return"ContextStart"===e||"ContextEnd"===e}),i=e.filter(function(t){return"ContextStart"===t.tokenType}),n=e.filter(function(t){return"ContextEnd"===t.tokenType});return i.length===n.length&&!!i.length&&function t(e,i){var n=e[0],r=e.slice(1);if(void 0===i&&(i=[]),!n)return 0===i.length;if("ContextStart"===n.tokenType)return t(r,i.concat(n.value));if("ContextEnd"===n.tokenType)return i[i.length-1]===n.value&&t(r,i.slice(0,-1));throw Error("Unexpected token: "+n.tokenType)}(e.map(function(t){var e=t.tokenType,i=t.value;return{tokenType:e,value:"ContextStart"===e?i.match(h)[1]:i.match(f)[1]}}))},t.lexer=g,t.richTextParser=p,t.unescape=function(t){if("string"!=typeof t)throw Error("Input must be a string");return t.replace(/\\\//g,"/").replace(/\\>/g,">").replace(/\\</g,"<").replace(/\\=/g,"=").replace(/\\\\/g,"\\")},t.version=C,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
8
8
|
//# sourceMappingURL=index.min.js.map
|