@sfirew/minecraft-motd-parser 1.1.3 → 1.1.4

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/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var b=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames,k=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var M=(t,e,o)=>e in t?b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,S=(t,e)=>{for(var o in e||(e={}))N.call(e,o)&&M(t,o,e[o]);if(k)for(var o of k(e))R.call(e,o)&&M(t,o,e[o]);return t};var _=(t,e)=>{for(var o in e)b(t,o,{get:e[o],enumerable:!0})},$=(t,e,o,f)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of J(e))!N.call(t,p)&&p!==o&&b(t,p,{get:()=>e[p],enumerable:!(f=E(e,p))||f.enumerable});return t};var K=t=>$(b({},"__esModule",{value:!0}),t);var P={};_(P,{JSONRender:()=>A,JSONToCleanedText:()=>y,JSONToHTML:()=>T,autoCleanToText:()=>O,autoToHTML:()=>h,cleanCodes:()=>d,cleanHtmlTags:()=>L,default:()=>X,htmlStringFormatting:()=>F,isMotdJSONType:()=>g,textToHTML:()=>m,textToJSON:()=>u});module.exports=K(P);function g(t){return!!t}function F(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/\n/g,"<br/>")}function L(t){return t.replace(/<[^>]*>?/gm,"")}function d(t){let e=/(?:§)([0-9a-fA-FklmnorFKLMNOR])/g,o="";return o=t.replace(e,""),o}var C={"\xA7k":"obfuscated;","\xA7l":"font-weight: bold;","\xA7m":"text-decoration: line-through;","\xA7n":"text-decoration: underline;","\xA7o":"font-style: italic;","\xA7r":"color: inherit;text-decoration: none !important;font-weight:normal!important;font-style: normal!important;"},H={bold:"font-weight: bold;",italic:"font-style: italic;",underlined:"text-decoration:underline;",strikethrough:"text-decoration: line-through;",obfuscated:"mc_obfuscated;",reset:"color: inherit;text-decoration: none !important;font-weight:normal!important;font-style: normal!important;"},w={"\xA7k":"obfuscated","\xA7l":"bold","\xA7m":"strikethrough","\xA7n":"underlined","\xA7o":"italic","\xA7r":"reset"},c={"\xA70":"#000000","\xA71":"#0000AA","\xA72":"#00AA00","\xA73":"#00AAAA","\xA74":"#AA0000","\xA75":"#AA00AA","\xA76":"#FFAA00","\xA77":"#AAAAAA","\xA78":"#555555","\xA79":"#5555FF","\xA7a":"#55FF55","\xA7b":"#55FFFF","\xA7c":"#FF5555","\xA7d":"#FF55FF","\xA7e":"#FFFF55","\xA7f":"#FFFFFF"},j={black:"#000000",dark_blue:"#0000AA",dark_green:"#00AA00",dark_aqua:"#00AAAA",dark_red:"#AA0000",dark_purple:"#AA00AA",gold:"#FFAA00",gray:"#AAAAAA",dark_gray:"#555555",blue:"#5555FF",green:"#55FF55",aqua:"#55FFFF",red:"#FF5555",light_purple:"#FF55FF",yellow:"#FFFF55",white:"#FFFFFF"};function m(t){let e=t,o=/([§][0-9a-f0-9a-fA-FklmnorFKLMNOR])/g,f=new RegExp(o.source),p=e.split(f).filter(l=>l!==""),r="",i="",n="";return p.forEach(l=>{let a=l.toLowerCase();if(Object.hasOwn(c,a))i=c[a],a==="\xA7f"&&(r="");else if(Object.hasOwn(C,a))a==="\xA7r"?(i="",r=""):r+=C[a];else{let x="",s=l;i!==""&&(x=`color:${i};`),s!==""&&(s=F(s),x.length!==0||r.length!==0?n+=`<span style="${x}${r}">${s}</span>`:n+=s)}}),n}function T(t){let e="",o="",f="";for(let r of Object.keys(t)){if(r=r.toLowerCase(),Object.hasOwn(H,r)&&t[r]&&(f+=`${H[r]}`),r==="color"){let i=t[r],n="";typeof i=="string"&&(Object.hasOwn(j,i)?n=j[i]:Object.hasOwn(c,i)?n=c[i]:n=i),n!==""&&(o=`color:${n};`)}if(r==="extra"&&typeof t.extra=="object"){t.text!==void 0&&(typeof t.text=="string"||typeof t.text=="number")&&(e+=m(String(t.text)));for(let i of t.extra)g(i)&&(e+=T(i))}}if(t.extra===void 0&&t.text!==void 0){let r=t.text;(typeof t.text=="string"||typeof t.text=="number")&&(e+=m(String(r)))}let p="";return f.length!==0||o.length!==0?p=`<span style="${o+f}">${e}</span>`:p=e,p}function y(t){let e="";for(let o of Object.keys(t))if(o=o.toLowerCase(),o==="extra"&&typeof t.extra=="object"){t.text!==void 0&&(typeof t.text=="string"||typeof t.text=="number")&&(e+=d(String(t.text)));for(let f of t.extra)g(f)&&(e+=y(f))}if(t.extra===void 0&&t.text!==void 0){let o=t.text;(typeof t.text=="string"||typeof t.text=="number")&&(e+=d(String(o)))}return e}function u(t){let e=t,o=/([§][0-9a-f0-9a-fA-FklmnorFKLMNOR])/g,f=new RegExp(o.source),p=e.split(f),r="",i="",n={text:"",extra:[]};p.forEach(a=>{let x=a.toLowerCase();if(Object.hasOwn(c,x))i=c[x],x==="\xA7f"&&(r="");else if(Object.hasOwn(w,x))x==="\xA7r"?(r="",i=""):r=w[x];else{let s={text:"",extra:[]};r!==""&&(s[r]=!0),s.text=a,i!==""&&(s.color=i),typeof n.extra=="object"&&n.extra.push(s)}});let l=[];return n.extra&&(n.extra.length>1?n.extra.forEach((a,x)=>{a.text===""?n.extra&&typeof n.extra[x+1]=="object"&&l.push(S(S({},a),n.extra[x+1])):a.text!==(l[l.length-1]&&l[l.length-1].text)&&l.push(a)}):l.push(n.extra[0])),l=l.filter(a=>a.text!==""),{text:n.text,extra:l}}function A(t){return T(t)}function h(t){return typeof t=="object"?A(t):typeof t=="string"?m(t):"unknown motd data type"}function q(t){return typeof t=="object"?y(t):typeof t=="string"?d(t):"unknown motd data type"}var O=q;var G={textToHTML:m,textToJSON:u,JSONToHTML:T,JSONRender:A,autoToHTML:h,htmlStringFormatting:F,cleanCodes:d,cleanHtmlTags:L,JSONToCleanedText:y,autoCleanToText:O},X=G;0&&(module.exports={JSONRender,JSONToCleanedText,JSONToHTML,autoCleanToText,autoToHTML,cleanCodes,cleanHtmlTags,htmlStringFormatting,isMotdJSONType,textToHTML,textToJSON});
1
+ var b=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames,k=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var M=(t,e,o)=>e in t?b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,S=(t,e)=>{for(var o in e||(e={}))N.call(e,o)&&M(t,o,e[o]);if(k)for(var o of k(e))R.call(e,o)&&M(t,o,e[o]);return t};var _=(t,e)=>{for(var o in e)b(t,o,{get:e[o],enumerable:!0})},$=(t,e,o,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of J(e))!N.call(t,p)&&p!==o&&b(t,p,{get:()=>e[p],enumerable:!(l=E(e,p))||l.enumerable});return t};var K=t=>$(b({},"__esModule",{value:!0}),t);var P={};_(P,{JSONRender:()=>A,JSONToCleanedText:()=>y,JSONToHTML:()=>T,autoCleanToText:()=>O,autoToHTML:()=>h,cleanCodes:()=>c,cleanHtmlTags:()=>L,default:()=>X,htmlStringFormatting:()=>F,isMotdJSONType:()=>g,textToHTML:()=>s,textToJSON:()=>u});module.exports=K(P);function g(t){return!!t}function F(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/\n/g,"<br/>")}function L(t){return t.replace(/<[^>]*>?/gm,"")}function c(t){let e=/(?:§)([0-9a-fA-FklmnorFKLMNOR])/g,o="";return o=t.replace(e,""),o}var C={"\xA7k":"obfuscated;","\xA7l":"font-weight: bold;","\xA7m":"text-decoration: line-through;","\xA7n":"text-decoration: underline;","\xA7o":"font-style: italic;","\xA7r":"color: inherit;text-decoration: none !important;font-weight:normal!important;font-style: normal!important;"},H={bold:"font-weight: bold;",italic:"font-style: italic;",underlined:"text-decoration:underline;",strikethrough:"text-decoration: line-through;",obfuscated:"mc_obfuscated;",reset:"color: inherit;text-decoration: none !important;font-weight:normal!important;font-style: normal!important;"},w={"\xA7k":"obfuscated","\xA7l":"bold","\xA7m":"strikethrough","\xA7n":"underlined","\xA7o":"italic","\xA7r":"reset"},d={"\xA70":"#000000","\xA71":"#0000AA","\xA72":"#00AA00","\xA73":"#00AAAA","\xA74":"#AA0000","\xA75":"#AA00AA","\xA76":"#FFAA00","\xA77":"#AAAAAA","\xA78":"#555555","\xA79":"#5555FF","\xA7a":"#55FF55","\xA7b":"#55FFFF","\xA7c":"#FF5555","\xA7d":"#FF55FF","\xA7e":"#FFFF55","\xA7f":"#FFFFFF"},j={black:"#000000",dark_blue:"#0000AA",dark_green:"#00AA00",dark_aqua:"#00AAAA",dark_red:"#AA0000",dark_purple:"#AA00AA",gold:"#FFAA00",gray:"#AAAAAA",dark_gray:"#555555",blue:"#5555FF",green:"#55FF55",aqua:"#55FFFF",red:"#FF5555",light_purple:"#FF55FF",yellow:"#FFFF55",white:"#FFFFFF"};function s(t){let e=t,o=/([§][0-9a-f0-9a-fA-FklmnorFKLMNOR])/g,l=new RegExp(o.source),p=e.split(l).filter(f=>f!==""),r="",n="",i="";return p.forEach(f=>{let a=f.toLowerCase();if(Object.hasOwn(d,a))n=d[a],a==="\xA7f"&&(r="");else if(Object.hasOwn(C,a))a==="\xA7r"?(n="",r=""):r+=C[a];else{let x="",m=f;n!==""&&(x=`color:${n};`),m!==""&&(m=F(m),x.length!==0||r.length!==0?i+=`<span style="${x}${r}">${m}</span>`:i+=m)}}),i}function T(t){let e="",o="",l="";for(let r of Object.keys(t)){if(r=r.toLowerCase(),Object.hasOwn(H,r)&&t[r]&&(l+=`${H[r]}`),r==="color"){let n=t[r],i="";typeof n=="string"&&(Object.hasOwn(j,n)?i=j[n]:Object.hasOwn(d,n)?i=d[n]:i=n),i!==""&&(o=`color:${i};`)}if(r==="extra"&&typeof t.extra=="object"){t.text!==void 0&&(typeof t.text=="string"||typeof t.text=="number")&&(e+=s(String(t.text)));for(let n of t.extra)typeof n=="string"?e+=s(n):g(n)&&(e+=T(n))}}if(t.extra===void 0&&t.text!==void 0){let r=t.text;(typeof t.text=="string"||typeof t.text=="number")&&(e+=s(String(r)))}let p="";return l.length!==0||o.length!==0?p=`<span style="${o+l}">${e}</span>`:p=e,p}function y(t){let e="";for(let o of Object.keys(t))if(o=o.toLowerCase(),o==="extra"&&typeof t.extra=="object"){t.text!==void 0&&(typeof t.text=="string"||typeof t.text=="number")&&(e+=c(String(t.text)));for(let l of t.extra)typeof l=="string"?e+=c(l):g(l)&&(e+=y(l))}if(t.extra===void 0&&t.text!==void 0){let o=t.text;(typeof t.text=="string"||typeof t.text=="number")&&(e+=c(String(o)))}return e}function u(t){let e=t,o=/([§][0-9a-f0-9a-fA-FklmnorFKLMNOR])/g,l=new RegExp(o.source),p=e.split(l),r="",n="",i={text:"",extra:[]};p.forEach(a=>{let x=a.toLowerCase();if(Object.hasOwn(d,x))n=d[x],x==="\xA7f"&&(r="");else if(Object.hasOwn(w,x))x==="\xA7r"?(r="",n=""):r=w[x];else{let m={text:"",extra:[]};r!==""&&(m[r]=!0),m.text=a,n!==""&&(m.color=n),typeof i.extra=="object"&&i.extra.push(m)}});let f=[];return i.extra&&(i.extra.length>1?i.extra.forEach((a,x)=>{a.text===""?i.extra&&typeof i.extra[x+1]=="object"&&f.push(S(S({},a),i.extra[x+1])):a.text!==(f[f.length-1]&&f[f.length-1].text)&&f.push(a)}):f.push(i.extra[0])),f=f.filter(a=>a.text!==""),{text:i.text,extra:f}}function A(t){return T(t)}function h(t){return typeof t=="object"?A(t):typeof t=="string"?s(t):"unknown motd data type"}function q(t){return typeof t=="object"?y(t):typeof t=="string"?c(t):"unknown motd data type"}var O=q;var G={textToHTML:s,textToJSON:u,JSONToHTML:T,JSONRender:A,autoToHTML:h,htmlStringFormatting:F,cleanCodes:c,cleanHtmlTags:L,JSONToCleanedText:y,autoCleanToText:O},X=G;0&&(module.exports={JSONRender,JSONToCleanedText,JSONToHTML,autoCleanToText,autoToHTML,cleanCodes,cleanHtmlTags,htmlStringFormatting,isMotdJSONType,textToHTML,textToJSON});
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/utils.ts","../src/styleLibrary.ts","../src/parser/textToHTML.ts","../src/parser/JSONToHTML.ts","../src/parser/JSONToCleanedText.ts","../src/parser/textToJSON.ts","../src/parser/autoToHTML.ts","../src/parser/autoCleanToText.ts"],"sourcesContent":["/*\n * minecraft motd parser\n * (c) 2021 Kevin Zheng\n * Released under the MIT license\n */\nimport {\n htmlStringFormatting,\n cleanCodes,\n cleanHtmlTags,\n} from \"./utils\";\nimport {\n JSONToHTML,\n JSONToCleanedText,\n\n textToHTML,\n textToJSON,\n\n JSONRender,\n autoToHTML,\n autoCleanToText,\n} from \"./parser\";\n\n\n\n\n\n\nexport * from './utils';\nexport * from \"./parser\";\n\n\n\n/*\n * #### minecraft motd parser\n * * [github](https://github.com/SnowFireWolf/minecraft-motd-parser/tree/main#minecraft-server-motd-parser)\n * * [npm](https://www.npmjs.com/package/@sfirew/minecraft-motd-parser)\n *\n * (c) 2021 Kevin Zheng\n *\n * Released under the MIT license\n */\nconst motdParser = {\n // --- normal format ---\n // text convert to HTML\n textToHTML,\n // text convert to JSON\n textToJSON,\n // JSON convert to HTML\n JSONToHTML,\n // JSON string to JSON object and convert to HTML\n JSONRender,\n // auto check type to convert\n autoToHTML,\n\n // --- utils ---\n // html string formatter\n htmlStringFormatting,\n // clean all motd codes\n cleanCodes,\n // clean all html tags\n cleanHtmlTags,\n // json to not html text\n JSONToCleanedText,\n // auto check type and convert to cleaned text\n autoCleanToText,\n};\n\nexport default motdParser;\n","/*\n * minecraft motd parser\n * (c) 2023 Kevin Zheng\n * Released under the MIT license\n */\n\nimport { motdJsonType } from \"./types\";\n\n\n\n\n// 類型檢查\nexport function isMotdJSONType(object: object): object is motdJsonType {\n return !!object;\n};\n\n\n\n/**\n *\n * replace all html tags to &...\n */\nexport function htmlStringFormatting(text: string): string {\n return (\n text\n // space\n // .replace(/ /g, \"\\u00a0\")\n //\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#39;\")\n // return\n .replace(/\\n/g, \"<br/>\")\n );\n // .replace(/\\//g, '&#x2F;');\n};\n\n\n\n/**\n * clean html tags\n * \n * @param text\n * example: `<span>hello world</span>`\n * \n * result: `hello world`\n */\nexport function cleanHtmlTags(text: string): string {\n return text.replace(/<[^>]*>?/gm, '');\n};\n\n\n\n/**\n * clean motd codes\n * \n * Clean all codes from motd source string.\n * \n * @param {string} text - motd string include tag § will remove\n */\nexport function cleanCodes(text: string) {\n const REGEX = /(?:§)([0-9a-fA-FklmnorFKLMNOR])/g;\n let textResult = \"\";\n\n textResult = text.replace(REGEX, \"\");\n\n return textResult;\n};\n","import { extraLibraryType } from \"./types\";\n\n\n\n// color code to font styles\nconst extras: extraLibraryType = {\n \"§k\": \"obfuscated;\",\n \"§l\": \"font-weight: bold;\",\n \"§m\": \"text-decoration: line-through;\",\n \"§n\": \"text-decoration: underline;\",\n \"§o\": \"font-style: italic;\",\n \"§r\": \"color: inherit;text-decoration: none !important;font-weight:normal!important;font-style: normal!important;\",\n};\n\n// json extra font styles\nconst extraFontStyles: extraLibraryType = {\n bold: \"font-weight: bold;\",\n italic: \"font-style: italic;\",\n underlined: \"text-decoration:underline;\",\n strikethrough: \"text-decoration: line-through;\",\n obfuscated: \"mc_obfuscated;\",\n reset: \"color: inherit;text-decoration: none !important;font-weight:normal!important;font-style: normal!important;\",\n};\n\n// text to json extra name\nconst textToJsonExtras: extraLibraryType = {\n \"§k\": \"obfuscated\",\n \"§l\": \"bold\",\n \"§m\": \"strikethrough\",\n \"§n\": \"underlined\",\n \"§o\": \"italic\",\n \"§r\": \"reset\",\n};\n\n// base color hex\nconst colorCodeToHex: extraLibraryType = {\n \"§0\": \"#000000\",\n \"§1\": \"#0000AA\",\n \"§2\": \"#00AA00\",\n \"§3\": \"#00AAAA\",\n \"§4\": \"#AA0000\",\n \"§5\": \"#AA00AA\",\n \"§6\": \"#FFAA00\",\n \"§7\": \"#AAAAAA\",\n \"§8\": \"#555555\",\n \"§9\": \"#5555FF\",\n \"§a\": \"#55FF55\",\n \"§b\": \"#55FFFF\",\n \"§c\": \"#FF5555\",\n \"§d\": \"#FF55FF\",\n \"§e\": \"#FFFF55\",\n \"§f\": \"#FFFFFF\",\n};\n\n// json extra to hex color\nconst extraColorsToHex: extraLibraryType = {\n black: \"#000000\",\n dark_blue: \"#0000AA\",\n dark_green: \"#00AA00\",\n dark_aqua: \"#00AAAA\",\n dark_red: \"#AA0000\",\n dark_purple: \"#AA00AA\",\n gold: \"#FFAA00\",\n gray: \"#AAAAAA\",\n dark_gray: \"#555555\",\n blue: \"#5555FF\",\n green: \"#55FF55\",\n aqua: \"#55FFFF\",\n red: \"#FF5555\",\n light_purple: \"#FF55FF\",\n yellow: \"#FFFF55\",\n white: \"#FFFFFF\",\n};\n\n\n\nexport {\n extras,\n extraFontStyles,\n textToJsonExtras,\n colorCodeToHex,\n extraColorsToHex,\n};\n","import {\n extras,\n colorCodeToHex,\n} from '../styleLibrary';\nimport {\n htmlStringFormatting,\n} from \"../utils\";\n\n\n\n/**\n * Convert motd text to html.\n * @param motdString\n */\nexport default function textToHTML(motdString: string) {\n const motdText = motdString;\n\n const colorCodeReg = /([§][0-9a-f0-9a-fA-FklmnorFKLMNOR])/g;\n const codeREGEX = new RegExp(colorCodeReg.source);\n const codeSplit = motdText.split(codeREGEX).filter(item => item !== '');\n\n let fontStyle = \"\";\n let colorHex = \"\";\n let resultHTML = \"\";\n\n codeSplit.forEach((item) => {\n const motdStringToLowerCase = item.toLowerCase();\n // console.log('motdStringToLowerCase', motdStringToLowerCase);\n\n // 過濾 hex\n if (Object.hasOwn(colorCodeToHex, motdStringToLowerCase)) {\n //console.log(`偵測出 ${ colorCodeToHex[item] }`)\n colorHex = colorCodeToHex[motdStringToLowerCase];\n\n // §f reset\n if(motdStringToLowerCase === \"§f\") {\n fontStyle = \"\";\n }\n // 過濾文字 style\n } else if (Object.hasOwn(extras, motdStringToLowerCase)) {\n if(motdStringToLowerCase === \"§r\") {\n colorHex = \"\";\n fontStyle = \"\";\n } else {\n // font style code 轉換\n // console.log(`偵測出 style ${ extras[motdStringToLowerCase] }`);\n fontStyle += extras[motdStringToLowerCase];\n }\n // console.log('motdStringToLowerCase', motdStringToLowerCase);\n // console.log('textFont: ' + fontStyle);\n // 正常文字\n } else {\n let resultColor = \"\";\n let textContent = item;\n //console.log(fontStyle)\n\n // 檢查 Hex color\n if (colorHex !== \"\") {\n resultColor = `color:${colorHex};`;\n }\n\n if (textContent !== \"\") {\n //console.log('font: ' + fontStyle)\n //console.log('color: ' + colorHex)\n //console.log('text: ' + item)\n //console.log('---------------------------------')\n // replace html tags\n textContent = htmlStringFormatting(textContent);\n\n if (resultColor.length !== 0 || fontStyle.length !== 0) {\n resultHTML += `<span style=\"${resultColor}${fontStyle}\">${textContent}</span>`;\n } else {\n resultHTML += textContent;\n }\n }\n }\n });\n\n return resultHTML;\n}\n","import { motdJsonType } from \"../types\";\nimport {\n extraFontStyles,\n colorCodeToHex,\n extraColorsToHex,\n} from '../styleLibrary';\nimport {\n isMotdJSONType,\n} from \"../utils\";\nimport textToHTML from \"./textToHTML\";\n\n\n\n/**\n * Convert JSON to HTML.\n * \n * @param sourceJson\n */\nexport default function parseJSONToHTML(\n sourceJson: motdJsonType,\n) {\n let htmlElement = \"\";\n let colorStyle = \"\";\n let fontStyle = \"\";\n\n // console.log('sourceJson', sourceJson);\n // console.log('---------');\n\n for (let key of Object.keys(sourceJson)) {\n // console.log('sourceJson key', key);\n key = key.toLowerCase();\n\n // text styles\n if (Object.hasOwn(extraFontStyles, key)) {\n if (sourceJson[key]) {\n fontStyle += `${extraFontStyles[key]}`;\n }\n }\n\n // ---------- old text process ----------\n // if (key === \"text\") {\n // if (\n // typeof sourceJson.text === \"string\" ||\n // typeof sourceJson.text === \"number\"\n // ) {\n // // convert all type to string\n // htmlElement += textToHTML(String(sourceJson.text));\n // }\n // }\n\n // color\n if (key === \"color\") {\n const colorKey = sourceJson[key];\n let colorHex = \"\";\n\n if (typeof colorKey === \"string\") {\n // Hex color\n if (Object.hasOwn(extraColorsToHex, colorKey)) {\n colorHex = extraColorsToHex[colorKey];\n // color code\n } else if (Object.hasOwn(colorCodeToHex, colorKey)) {\n colorHex = colorCodeToHex[colorKey];\n // custom color\n } else {\n // custom hex color code mode\n colorHex = colorKey;\n }\n }\n\n if(colorHex !== \"\") {\n colorStyle = `color:${colorHex};`;\n }\n }\n\n // extra\n if (key === \"extra\" && typeof sourceJson.extra === \"object\") {\n // ---------- with extra text ----------\n if (sourceJson.text !== undefined\n && (typeof sourceJson.text === \"string\" || typeof sourceJson.text === \"number\")\n ) {\n // content to html\n htmlElement += textToHTML(String(sourceJson.text));\n }\n\n // ---------- foreach extra data and parse ----------\n for (const sourceJsonExtra of sourceJson.extra) {\n // console.log('sourceJsonExtra', sourceJsonExtra);\n if (isMotdJSONType(sourceJsonExtra)) {\n htmlElement += parseJSONToHTML(sourceJsonExtra);\n }\n }\n }\n }\n\n // ---------- without extra text content ----------\n if (sourceJson.extra === undefined && sourceJson.text !== undefined) {\n const currentText = sourceJson.text;\n if (\n typeof sourceJson.text === \"string\" ||\n typeof sourceJson.text === \"number\"\n ) {\n // convert all type to string\n htmlElement += textToHTML(String(currentText));\n }\n }\n\n\n\n let returnHTML = \"\";\n if (fontStyle.length !== 0 || colorStyle.length !== 0) {\n returnHTML = `<span style=\"${colorStyle + fontStyle}\">${htmlElement}</span>`;\n } else {\n returnHTML = htmlElement;\n }\n\n return returnHTML;\n}\n","import { motdJsonType } from \"../types\";\nimport {\n isMotdJSONType,\n cleanCodes\n} from \"../utils\";\n\n\n\n/**\n * Convert JSON to Cleaned Text.\n * \n * @param sourceJson\n */\nexport default function JSONToCleanedText(\n sourceJson: motdJsonType,\n) {\n let textString = \"\";\n\n for (let key of Object.keys(sourceJson)) {\n key = key.toLowerCase();\n\n // extra\n if (key === \"extra\" && typeof sourceJson.extra === \"object\") {\n // ---------- with extra text ----------\n if (sourceJson.text !== undefined\n && (typeof sourceJson.text === \"string\" || typeof sourceJson.text === \"number\")\n ) {\n // content to html\n textString += cleanCodes(String(sourceJson.text));\n }\n\n // ---------- foreach extra data and parse ----------\n for (const sourceJsonExtra of sourceJson.extra) {\n // console.log('sourceJsonExtra', sourceJsonExtra);\n if (isMotdJSONType(sourceJsonExtra)) {\n textString += JSONToCleanedText(sourceJsonExtra);\n }\n }\n }\n }\n\n // ---------- without extra text content ----------\n if (sourceJson.extra === undefined && sourceJson.text !== undefined) {\n const currentText = sourceJson.text;\n if (\n typeof sourceJson.text === \"string\" ||\n typeof sourceJson.text === \"number\"\n ) {\n // convert all type to string\n textString += cleanCodes(String(currentText));\n }\n }\n\n return textString;\n}\n","import { motdJsonType } from \"../types\";\nimport {\n textToJsonExtras,\n colorCodeToHex,\n} from '../styleLibrary';\n\n\n\n/**\n * Convert motd text to JSON.\n * \n * @param text\n */\nexport default function parseTextToJSON(text: string) {\n const motdText = text;\n\n // color code regex: /([§][0-9a-fklmnor])/g\n // color hex regex: /^#(?:[0-9a-f]{3}){1,2}$/g\n const colorCodeReg = /([§][0-9a-f0-9a-fA-FklmnorFKLMNOR])/g;\n const codeREGEX = new RegExp(colorCodeReg.source);\n const textSplit = motdText.split(codeREGEX);\n let fontStyle = \"\";\n let colorHex = \"\";\n\n const resultObject: motdJsonType = {\n text: \"\",\n extra: [],\n };\n\n // console.log('textSplit', textSplit);\n textSplit.forEach((item) => {\n const stringToLowerCase = item.toLowerCase();\n\n // color code 轉換成 hex\n if (Object.hasOwn(colorCodeToHex, stringToLowerCase)) {\n //console.log(`偵測出 ${ colorCodeToHex[item] }`)\n colorHex = colorCodeToHex[stringToLowerCase];\n // §f reset\n if(stringToLowerCase === \"§f\") {\n fontStyle = \"\";\n }\n } else if (Object.hasOwn(textToJsonExtras, stringToLowerCase)) {\n if(stringToLowerCase === \"§r\") {\n fontStyle = \"\";\n colorHex = \"\";\n } else {\n // font style code 轉換\n //console.log(`偵測出 style ${ textToJsonExtras[item] }`)\n fontStyle = textToJsonExtras[stringToLowerCase];\n }\n } else {\n const innerObject: motdJsonType = {\n text: \"\",\n extra: [],\n };\n\n // 其餘字串\n if (fontStyle !== \"\") {\n innerObject[fontStyle] = true;\n }\n\n innerObject.text = item;\n\n if (colorHex !== \"\") {\n innerObject.color = colorHex;\n }\n\n if (typeof resultObject.extra === \"object\") {\n resultObject.extra.push(innerObject);\n }\n }\n });\n\n // code styles merge\n let newExtra: Array<motdJsonType> = [];\n // console.log('resultObject', resultObject);\n if (resultObject.extra) {\n if (resultObject.extra.length > 1) {\n // if text is '', remove it and merge to next array\n resultObject.extra.forEach((item, index) => {\n // console.log('item', item);\n if (item.text === \"\") {\n if (\n resultObject.extra\n && typeof resultObject.extra[index + 1] === \"object\"\n ) {\n newExtra.push({\n ...(item as motdJsonType),\n ...resultObject.extra[index + 1],\n });\n }\n } else {\n if (\n item.text !== (newExtra[newExtra.length - 1]\n && newExtra[newExtra.length - 1].text)\n ) {\n newExtra.push(item as motdJsonType);\n }\n }\n });\n } else {\n newExtra.push(resultObject.extra[0] as motdJsonType);\n }\n }\n\n // console.log('newExtra', newExtra);\n // remove blank content\n newExtra = newExtra.filter((item) => item.text !== \"\");\n // console.log('newExtra', newExtra);\n\n return {\n text: resultObject.text,\n extra: newExtra,\n };\n}\n","import { motdJsonType } from \"../types\";\nimport {\n JSONToHTML,\n textToHTML,\n} from \"./\";\n\n\n\n// make sure JSON data is JSON object and then convert.\nexport function JSONRender(json: object) {\n return JSONToHTML(json as motdJsonType);\n}\n\n/**\n * auto check data type then convert to html.\n */\nexport function autoToHTML(motd: string | object): string {\n // type check\n if (typeof motd === \"object\") {\n // console.log('process mode: Object mode');\n return JSONRender(motd);\n } else if (typeof motd === \"string\") {\n // console.log('process mode: String mode');\n // console.log('textToJSON(motd)', textToJSON(motd));\n return textToHTML(motd);\n // return jsonRender(textToJSON(motd));\n } else {\n return \"unknown motd data type\";\n }\n}\n\n\n\nexport default autoToHTML;\n","import { motdJsonType } from \"../types\";\nimport {\n JSONToCleanedText,\n} from \".\";\nimport { cleanCodes } from \"../utils\";\n\n\n\n/**\n * auto check data type then convert to html.\n */\nexport function autoCleanToText(motd: string | object): string {\n // type check\n if (typeof motd === \"object\") {\n // console.log('process mode: Object mode');\n return JSONToCleanedText(motd as motdJsonType);\n } else if (typeof motd === \"string\") {\n // console.log('process mode: String mode');\n return cleanCodes(motd);\n } else {\n return \"unknown motd data type\";\n }\n}\n\n\n\nexport default autoCleanToText;\n"],"mappings":"+qBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,sBAAAC,EAAA,eAAAC,EAAA,oBAAAC,EAAA,eAAAC,EAAA,eAAAC,EAAA,kBAAAC,EAAA,YAAAC,EAAA,yBAAAC,EAAA,mBAAAC,EAAA,eAAAC,EAAA,eAAAC,IAAA,eAAAC,EAAAd,GCYO,SAASe,EAAeC,EAAwC,CACrE,MAAO,CAAC,CAACA,CACX,CAQO,SAASC,EAAqBC,EAAsB,CACzD,OACEA,EAIG,QAAQ,KAAM,OAAO,EACrB,QAAQ,KAAM,MAAM,EACpB,QAAQ,KAAM,MAAM,EACpB,QAAQ,KAAM,QAAQ,EACtB,QAAQ,KAAM,OAAO,EAErB,QAAQ,MAAO,OAAO,CAG7B,CAYO,SAASC,EAAcD,EAAsB,CAClD,OAAOA,EAAK,QAAQ,aAAc,EAAE,CACtC,CAWO,SAASE,EAAWF,EAAc,CACvC,IAAMG,EAAQ,mCACVC,EAAa,GAEjB,OAAAA,EAAaJ,EAAK,QAAQG,EAAO,EAAE,EAE5BC,CACT,CChEA,IAAMC,EAA2B,CAC/B,QAAM,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AU,UAChCA,EAAa,MAAM,KAAKK,CAAW,CAEvC,CACF,CAAC,EAGD,IAAIC,EAAgC,CAAC,EAErC,OAAIN,EAAa,QACXA,EAAa,MAAM,OAAS,EAE9BA,EAAa,MAAM,QAAQ,CAACC,EAAMM,IAAU,CAEtCN,EAAK,OAAS,GAEdD,EAAa,OACV,OAAOA,EAAa,MAAMO,EAAQ,CAAC,GAAM,UAE5CD,EAAS,KAAKE,IAAA,GACRP,GACDD,EAAa,MAAMO,EAAQ,CAAC,EAChC,EAIDN,EAAK,QAAUK,EAASA,EAAS,OAAS,CAAC,GACtCA,EAASA,EAAS,OAAS,CAAC,EAAE,OAEnCA,EAAS,KAAKL,CAAoB,CAGxC,CAAC,EAEDK,EAAS,KAAKN,EAAa,MAAM,CAAC,CAAiB,GAMvDM,EAAWA,EAAS,OAAQL,GAASA,EAAK,OAAS,EAAE,EAG9C,CACL,KAAMD,EAAa,KACnB,MAAOM,CACT,CACF,CCzGO,SAASG,EAAWC,EAAc,CACvC,OAAOC,EAAWD,CAAoB,CACxC,CAKO,SAASE,EAAWC,EAA+B,CAExD,OAAI,OAAOA,GAAS,SAEXJ,EAAWI,CAAI,EACb,OAAOA,GAAS,SAGlBC,EAAWD,CAAI,EAGf,wBAEX,CClBO,SAASE,EAAgBC,EAA+B,CAE7D,OAAI,OAAOA,GAAS,SAEXC,EAAkBD,CAAoB,EACpC,OAAOA,GAAS,SAElBE,EAAWF,CAAI,EAEf,wBAEX,CAIA,IAAOG,EAAQJ,ERef,IAAMK,EAAa,CAGjB,WAAAC,EAEA,WAAAC,EAEA,WAAAC,EAEA,WAAAC,EAEA,WAAAC,EAIA,qBAAAC,EAEA,WAAAC,EAEA,cAAAC,EAEA,kBAAAC,EAEA,gBAAAC,CACF,EAEOC,EAAQX","names":["src_exports","__export","JSONRender","JSONToCleanedText","parseJSONToHTML","autoCleanToText_default","autoToHTML","cleanCodes","cleanHtmlTags","src_default","htmlStringFormatting","isMotdJSONType","textToHTML","parseTextToJSON","__toCommonJS","isMotdJSONType","object","htmlStringFormatting","text","cleanHtmlTags","cleanCodes","REGEX","textResult","extras","extraFontStyles","textToJsonExtras","colorCodeToHex","extraColorsToHex","textToHTML","motdString","motdText","colorCodeReg","codeREGEX","codeSplit","item","fontStyle","colorHex","resultHTML","motdStringToLowerCase","colorCodeToHex","extras","resultColor","textContent","htmlStringFormatting","parseJSONToHTML","sourceJson","htmlElement","colorStyle","fontStyle","key","extraFontStyles","colorKey","colorHex","extraColorsToHex","colorCodeToHex","textToHTML","sourceJsonExtra","isMotdJSONType","currentText","returnHTML","JSONToCleanedText","sourceJson","textString","key","cleanCodes","sourceJsonExtra","isMotdJSONType","currentText","parseTextToJSON","text","motdText","colorCodeReg","codeREGEX","textSplit","fontStyle","colorHex","resultObject","item","stringToLowerCase","colorCodeToHex","textToJsonExtras","innerObject","newExtra","index","__spreadValues","JSONRender","json","parseJSONToHTML","autoToHTML","motd","textToHTML","autoCleanToText","motd","JSONToCleanedText","cleanCodes","autoCleanToText_default","motdParser","textToHTML","parseTextToJSON","parseJSONToHTML","JSONRender","autoToHTML","htmlStringFormatting","cleanCodes","cleanHtmlTags","JSONToCleanedText","autoCleanToText_default","src_default"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/utils.ts","../src/styleLibrary.ts","../src/parser/textToHTML.ts","../src/parser/JSONToHTML.ts","../src/parser/JSONToCleanedText.ts","../src/parser/textToJSON.ts","../src/parser/autoToHTML.ts","../src/parser/autoCleanToText.ts"],"sourcesContent":["/*\n * minecraft motd parser\n * (c) 2021 Kevin Zheng\n * Released under the MIT license\n */\nimport {\n htmlStringFormatting,\n cleanCodes,\n cleanHtmlTags,\n} from \"./utils\";\nimport {\n JSONToHTML,\n JSONToCleanedText,\n\n textToHTML,\n textToJSON,\n\n JSONRender,\n autoToHTML,\n autoCleanToText,\n} from \"./parser\";\n\n\n\n\n\n\nexport * from './utils';\nexport * from \"./parser\";\n\n\n\n/*\n * #### minecraft motd parser\n * * [github](https://github.com/SnowFireWolf/minecraft-motd-parser/tree/main#minecraft-server-motd-parser)\n * * [npm](https://www.npmjs.com/package/@sfirew/minecraft-motd-parser)\n *\n * (c) 2021 Kevin Zheng\n *\n * Released under the MIT license\n */\nconst motdParser = {\n // --- normal format ---\n // text convert to HTML\n textToHTML,\n // text convert to JSON\n textToJSON,\n // JSON convert to HTML\n JSONToHTML,\n // JSON string to JSON object and convert to HTML\n JSONRender,\n // auto check type to convert\n autoToHTML,\n\n // --- utils ---\n // html string formatter\n htmlStringFormatting,\n // clean all motd codes\n cleanCodes,\n // clean all html tags\n cleanHtmlTags,\n // json to not html text\n JSONToCleanedText,\n // auto check type and convert to cleaned text\n autoCleanToText,\n};\n\nexport default motdParser;\n","/*\n * minecraft motd parser\n * (c) 2023 Kevin Zheng\n * Released under the MIT license\n */\n\nimport { motdJsonType } from \"./types\";\n\n\n\n\n// 類型檢查\nexport function isMotdJSONType(object: object): object is motdJsonType {\n return !!object;\n};\n\n\n\n/**\n *\n * replace all html tags to &...\n */\nexport function htmlStringFormatting(text: string): string {\n return (\n text\n // space\n // .replace(/ /g, \"\\u00a0\")\n //\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#39;\")\n // return\n .replace(/\\n/g, \"<br/>\")\n );\n // .replace(/\\//g, '&#x2F;');\n};\n\n\n\n/**\n * clean html tags\n * \n * @param text\n * example: `<span>hello world</span>`\n * \n * result: `hello world`\n */\nexport function cleanHtmlTags(text: string): string {\n return text.replace(/<[^>]*>?/gm, '');\n};\n\n\n\n/**\n * clean motd codes\n * \n * Clean all codes from motd source string.\n * \n * @param {string} text - motd string include tag § will remove\n */\nexport function cleanCodes(text: string) {\n const REGEX = /(?:§)([0-9a-fA-FklmnorFKLMNOR])/g;\n let textResult = \"\";\n\n textResult = text.replace(REGEX, \"\");\n\n return textResult;\n};\n","import { extraLibraryType } from \"./types\";\n\n\n\n// color code to font styles\nconst extras: extraLibraryType = {\n \"§k\": \"obfuscated;\",\n \"§l\": \"font-weight: bold;\",\n \"§m\": \"text-decoration: line-through;\",\n \"§n\": \"text-decoration: underline;\",\n \"§o\": \"font-style: italic;\",\n \"§r\": \"color: inherit;text-decoration: none !important;font-weight:normal!important;font-style: normal!important;\",\n};\n\n// json extra font styles\nconst extraFontStyles: extraLibraryType = {\n bold: \"font-weight: bold;\",\n italic: \"font-style: italic;\",\n underlined: \"text-decoration:underline;\",\n strikethrough: \"text-decoration: line-through;\",\n obfuscated: \"mc_obfuscated;\",\n reset: \"color: inherit;text-decoration: none !important;font-weight:normal!important;font-style: normal!important;\",\n};\n\n// text to json extra name\nconst textToJsonExtras: extraLibraryType = {\n \"§k\": \"obfuscated\",\n \"§l\": \"bold\",\n \"§m\": \"strikethrough\",\n \"§n\": \"underlined\",\n \"§o\": \"italic\",\n \"§r\": \"reset\",\n};\n\n// base color hex\nconst colorCodeToHex: extraLibraryType = {\n \"§0\": \"#000000\",\n \"§1\": \"#0000AA\",\n \"§2\": \"#00AA00\",\n \"§3\": \"#00AAAA\",\n \"§4\": \"#AA0000\",\n \"§5\": \"#AA00AA\",\n \"§6\": \"#FFAA00\",\n \"§7\": \"#AAAAAA\",\n \"§8\": \"#555555\",\n \"§9\": \"#5555FF\",\n \"§a\": \"#55FF55\",\n \"§b\": \"#55FFFF\",\n \"§c\": \"#FF5555\",\n \"§d\": \"#FF55FF\",\n \"§e\": \"#FFFF55\",\n \"§f\": \"#FFFFFF\",\n};\n\n// json extra to hex color\nconst extraColorsToHex: extraLibraryType = {\n black: \"#000000\",\n dark_blue: \"#0000AA\",\n dark_green: \"#00AA00\",\n dark_aqua: \"#00AAAA\",\n dark_red: \"#AA0000\",\n dark_purple: \"#AA00AA\",\n gold: \"#FFAA00\",\n gray: \"#AAAAAA\",\n dark_gray: \"#555555\",\n blue: \"#5555FF\",\n green: \"#55FF55\",\n aqua: \"#55FFFF\",\n red: \"#FF5555\",\n light_purple: \"#FF55FF\",\n yellow: \"#FFFF55\",\n white: \"#FFFFFF\",\n};\n\n\n\nexport {\n extras,\n extraFontStyles,\n textToJsonExtras,\n colorCodeToHex,\n extraColorsToHex,\n};\n","import {\n extras,\n colorCodeToHex,\n} from '../styleLibrary';\nimport {\n htmlStringFormatting,\n} from \"../utils\";\n\n\n\n/**\n * Convert motd text to html.\n * @param motdString\n */\nexport default function textToHTML(motdString: string) {\n const motdText = motdString;\n\n const colorCodeReg = /([§][0-9a-f0-9a-fA-FklmnorFKLMNOR])/g;\n const codeREGEX = new RegExp(colorCodeReg.source);\n const codeSplit = motdText.split(codeREGEX).filter(item => item !== '');\n\n let fontStyle = \"\";\n let colorHex = \"\";\n let resultHTML = \"\";\n\n codeSplit.forEach((item) => {\n const motdStringToLowerCase = item.toLowerCase();\n // console.log('motdStringToLowerCase', motdStringToLowerCase);\n\n // 過濾 hex\n if (Object.hasOwn(colorCodeToHex, motdStringToLowerCase)) {\n //console.log(`偵測出 ${ colorCodeToHex[item] }`)\n colorHex = colorCodeToHex[motdStringToLowerCase];\n\n // §f reset\n if(motdStringToLowerCase === \"§f\") {\n fontStyle = \"\";\n }\n // 過濾文字 style\n } else if (Object.hasOwn(extras, motdStringToLowerCase)) {\n if(motdStringToLowerCase === \"§r\") {\n colorHex = \"\";\n fontStyle = \"\";\n } else {\n // font style code 轉換\n // console.log(`偵測出 style ${ extras[motdStringToLowerCase] }`);\n fontStyle += extras[motdStringToLowerCase];\n }\n // console.log('motdStringToLowerCase', motdStringToLowerCase);\n // console.log('textFont: ' + fontStyle);\n // 正常文字\n } else {\n let resultColor = \"\";\n let textContent = item;\n //console.log(fontStyle)\n\n // 檢查 Hex color\n if (colorHex !== \"\") {\n resultColor = `color:${colorHex};`;\n }\n\n if (textContent !== \"\") {\n //console.log('font: ' + fontStyle)\n //console.log('color: ' + colorHex)\n //console.log('text: ' + item)\n //console.log('---------------------------------')\n // replace html tags\n textContent = htmlStringFormatting(textContent);\n\n if (resultColor.length !== 0 || fontStyle.length !== 0) {\n resultHTML += `<span style=\"${resultColor}${fontStyle}\">${textContent}</span>`;\n } else {\n resultHTML += textContent;\n }\n }\n }\n });\n\n return resultHTML;\n}\n","import { motdJsonType } from \"../types\";\nimport {\n extraFontStyles,\n colorCodeToHex,\n extraColorsToHex,\n} from '../styleLibrary';\nimport {\n isMotdJSONType,\n} from \"../utils\";\nimport textToHTML from \"./textToHTML\";\n\n\n\n/**\n * Convert JSON to HTML.\n * \n * @param sourceJson\n */\nexport default function parseJSONToHTML(\n sourceJson: motdJsonType,\n) {\n let htmlElement = \"\";\n let colorStyle = \"\";\n let fontStyle = \"\";\n\n // console.log('sourceJson', sourceJson);\n // console.log('---------');\n\n for (let key of Object.keys(sourceJson)) {\n // console.log('sourceJson key', key);\n key = key.toLowerCase();\n\n // text styles\n if (Object.hasOwn(extraFontStyles, key)) {\n if (sourceJson[key]) {\n fontStyle += `${extraFontStyles[key]}`;\n }\n }\n\n // ---------- old text process ----------\n // if (key === \"text\") {\n // if (\n // typeof sourceJson.text === \"string\" ||\n // typeof sourceJson.text === \"number\"\n // ) {\n // // convert all type to string\n // htmlElement += textToHTML(String(sourceJson.text));\n // }\n // }\n\n // color\n if (key === \"color\") {\n const colorKey = sourceJson[key];\n let colorHex = \"\";\n\n if (typeof colorKey === \"string\") {\n // Hex color\n if (Object.hasOwn(extraColorsToHex, colorKey)) {\n colorHex = extraColorsToHex[colorKey];\n // color code\n } else if (Object.hasOwn(colorCodeToHex, colorKey)) {\n colorHex = colorCodeToHex[colorKey];\n // custom color\n } else {\n // custom hex color code mode\n colorHex = colorKey;\n }\n }\n\n if(colorHex !== \"\") {\n colorStyle = `color:${colorHex};`;\n }\n }\n\n // extra\n if (key === \"extra\" && typeof sourceJson.extra === \"object\") {\n // ---------- with extra text ----------\n if (sourceJson.text !== undefined\n && (typeof sourceJson.text === \"string\" || typeof sourceJson.text === \"number\")\n ) {\n // content to html\n htmlElement += textToHTML(String(sourceJson.text));\n }\n\n // ---------- foreach extra data and parse ----------\n for (const sourceJsonExtra of sourceJson.extra) {\n // console.log('sourceJsonExtra', sourceJsonExtra);\n if (typeof sourceJsonExtra === 'string') {\n // Process string elements directly with textToHTML\n htmlElement += textToHTML(sourceJsonExtra);\n } else if (isMotdJSONType(sourceJsonExtra)) {\n htmlElement += parseJSONToHTML(sourceJsonExtra);\n }\n }\n }\n }\n\n // ---------- without extra text content ----------\n if (sourceJson.extra === undefined && sourceJson.text !== undefined) {\n const currentText = sourceJson.text;\n if (\n typeof sourceJson.text === \"string\" ||\n typeof sourceJson.text === \"number\"\n ) {\n // convert all type to string\n htmlElement += textToHTML(String(currentText));\n }\n }\n\n\n\n let returnHTML = \"\";\n if (fontStyle.length !== 0 || colorStyle.length !== 0) {\n returnHTML = `<span style=\"${colorStyle + fontStyle}\">${htmlElement}</span>`;\n } else {\n returnHTML = htmlElement;\n }\n\n return returnHTML;\n}\n","import { motdJsonType } from \"../types\";\nimport {\n isMotdJSONType,\n cleanCodes\n} from \"../utils\";\n\n\n\n/**\n * Convert JSON to Cleaned Text.\n * \n * @param sourceJson\n */\nexport default function JSONToCleanedText(\n sourceJson: motdJsonType,\n) {\n let textString = \"\";\n\n for (let key of Object.keys(sourceJson)) {\n key = key.toLowerCase();\n\n // extra\n if (key === \"extra\" && typeof sourceJson.extra === \"object\") {\n // ---------- with extra text ----------\n if (sourceJson.text !== undefined\n && (typeof sourceJson.text === \"string\" || typeof sourceJson.text === \"number\")\n ) {\n // content to html\n textString += cleanCodes(String(sourceJson.text));\n }\n\n // ---------- foreach extra data and parse ----------\n for (const sourceJsonExtra of sourceJson.extra) {\n // console.log('sourceJsonExtra', sourceJsonExtra);\n if (typeof sourceJsonExtra === 'string') {\n // Add string elements directly to the output\n textString += cleanCodes(sourceJsonExtra);\n } else if (isMotdJSONType(sourceJsonExtra)) {\n textString += JSONToCleanedText(sourceJsonExtra);\n }\n }\n }\n }\n\n // ---------- without extra text content ----------\n if (sourceJson.extra === undefined && sourceJson.text !== undefined) {\n const currentText = sourceJson.text;\n if (\n typeof sourceJson.text === \"string\" ||\n typeof sourceJson.text === \"number\"\n ) {\n // convert all type to string\n textString += cleanCodes(String(currentText));\n }\n }\n\n return textString;\n}\n","import { motdJsonType } from \"../types\";\nimport {\n textToJsonExtras,\n colorCodeToHex,\n} from '../styleLibrary';\n\n\n\n/**\n * Convert motd text to JSON.\n * \n * @param text\n */\nexport default function parseTextToJSON(text: string) {\n const motdText = text;\n\n // color code regex: /([§][0-9a-fklmnor])/g\n // color hex regex: /^#(?:[0-9a-f]{3}){1,2}$/g\n const colorCodeReg = /([§][0-9a-f0-9a-fA-FklmnorFKLMNOR])/g;\n const codeREGEX = new RegExp(colorCodeReg.source);\n const textSplit = motdText.split(codeREGEX);\n let fontStyle = \"\";\n let colorHex = \"\";\n\n const resultObject: motdJsonType = {\n text: \"\",\n extra: [],\n };\n\n // console.log('textSplit', textSplit);\n textSplit.forEach((item) => {\n const stringToLowerCase = item.toLowerCase();\n\n // color code 轉換成 hex\n if (Object.hasOwn(colorCodeToHex, stringToLowerCase)) {\n //console.log(`偵測出 ${ colorCodeToHex[item] }`)\n colorHex = colorCodeToHex[stringToLowerCase];\n // §f reset\n if(stringToLowerCase === \"§f\") {\n fontStyle = \"\";\n }\n } else if (Object.hasOwn(textToJsonExtras, stringToLowerCase)) {\n if(stringToLowerCase === \"§r\") {\n fontStyle = \"\";\n colorHex = \"\";\n } else {\n // font style code 轉換\n //console.log(`偵測出 style ${ textToJsonExtras[item] }`)\n fontStyle = textToJsonExtras[stringToLowerCase];\n }\n } else {\n const innerObject: motdJsonType = {\n text: \"\",\n extra: [],\n };\n\n // 其餘字串\n if (fontStyle !== \"\") {\n innerObject[fontStyle] = true;\n }\n\n innerObject.text = item;\n\n if (colorHex !== \"\") {\n innerObject.color = colorHex;\n }\n\n if (typeof resultObject.extra === \"object\") {\n resultObject.extra.push(innerObject);\n }\n }\n });\n\n // code styles merge\n let newExtra: Array<motdJsonType> = [];\n // console.log('resultObject', resultObject);\n if (resultObject.extra) {\n if (resultObject.extra.length > 1) {\n // if text is '', remove it and merge to next array\n resultObject.extra.forEach((item, index) => {\n // console.log('item', item);\n if (item.text === \"\") {\n if (\n resultObject.extra\n && typeof resultObject.extra[index + 1] === \"object\"\n ) {\n newExtra.push({\n ...(item as motdJsonType),\n ...resultObject.extra[index + 1],\n });\n }\n } else {\n if (\n item.text !== (newExtra[newExtra.length - 1]\n && newExtra[newExtra.length - 1].text)\n ) {\n newExtra.push(item as motdJsonType);\n }\n }\n });\n } else {\n newExtra.push(resultObject.extra[0] as motdJsonType);\n }\n }\n\n // console.log('newExtra', newExtra);\n // remove blank content\n newExtra = newExtra.filter((item) => item.text !== \"\");\n // console.log('newExtra', newExtra);\n\n return {\n text: resultObject.text,\n extra: newExtra,\n };\n}\n","import { motdJsonType } from \"../types\";\nimport {\n JSONToHTML,\n textToHTML,\n} from \"./\";\n\n\n\n// make sure JSON data is JSON object and then convert.\nexport function JSONRender(json: object) {\n return JSONToHTML(json as motdJsonType);\n}\n\n/**\n * auto check data type then convert to html.\n */\nexport function autoToHTML(motd: string | object): string {\n // type check\n if (typeof motd === \"object\") {\n // console.log('process mode: Object mode');\n return JSONRender(motd);\n } else if (typeof motd === \"string\") {\n // console.log('process mode: String mode');\n // console.log('textToJSON(motd)', textToJSON(motd));\n return textToHTML(motd);\n // return jsonRender(textToJSON(motd));\n } else {\n return \"unknown motd data type\";\n }\n}\n\n\n\nexport default autoToHTML;\n","import { motdJsonType } from \"../types\";\nimport {\n JSONToCleanedText,\n} from \".\";\nimport { cleanCodes } from \"../utils\";\n\n\n\n/**\n * auto check data type then convert to html.\n */\nexport function autoCleanToText(motd: string | object): string {\n // type check\n if (typeof motd === \"object\") {\n // console.log('process mode: Object mode');\n return JSONToCleanedText(motd as motdJsonType);\n } else if (typeof motd === \"string\") {\n // console.log('process mode: String mode');\n return cleanCodes(motd);\n } else {\n return \"unknown motd data type\";\n }\n}\n\n\n\nexport default autoCleanToText;\n"],"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KL,CAAoB,CAGxC,CAAC,EAEDK,EAAS,KAAKN,EAAa,MAAM,CAAC,CAAiB,GAMvDM,EAAWA,EAAS,OAAQL,GAASA,EAAK,OAAS,EAAE,EAG9C,CACL,KAAMD,EAAa,KACnB,MAAOM,CACT,CACF,CCzGO,SAASG,EAAWC,EAAc,CACvC,OAAOC,EAAWD,CAAoB,CACxC,CAKO,SAASE,EAAWC,EAA+B,CAExD,OAAI,OAAOA,GAAS,SAEXJ,EAAWI,CAAI,EACb,OAAOA,GAAS,SAGlBC,EAAWD,CAAI,EAGf,wBAEX,CClBO,SAASE,EAAgBC,EAA+B,CAE7D,OAAI,OAAOA,GAAS,SAEXC,EAAkBD,CAAoB,EACpC,OAAOA,GAAS,SAElBE,EAAWF,CAAI,EAEf,wBAEX,CAIA,IAAOG,EAAQJ,ERef,IAAMK,EAAa,CAGjB,WAAAC,EAEA,WAAAC,EAEA,WAAAC,EAEA,WAAAC,EAEA,WAAAC,EAIA,qBAAAC,EAEA,WAAAC,EAEA,cAAAC,EAEA,kBAAAC,EAEA,gBAAAC,CACF,EAEOC,EAAQX","names":["index_exports","__export","JSONRender","JSONToCleanedText","parseJSONToHTML","autoCleanToText_default","autoToHTML","cleanCodes","cleanHtmlTags","index_default","htmlStringFormatting","isMotdJSONType","textToHTML","parseTextToJSON","__toCommonJS","isMotdJSONType","object","htmlStringFormatting","text","cleanHtmlTags","cleanCodes","REGEX","textResult","extras","extraFontStyles","textToJsonExtras","colorCodeToHex","extraColorsToHex","textToHTML","motdString","motdText","colorCodeReg","codeREGEX","codeSplit","item","fontStyle","colorHex","resultHTML","motdStringToLowerCase","colorCodeToHex","extras","resultColor","textContent","htmlStringFormatting","parseJSONToHTML","sourceJson","htmlElement","colorStyle","fontStyle","key","extraFontStyles","colorKey","colorHex","extraColorsToHex","colorCodeToHex","textToHTML","sourceJsonExtra","isMotdJSONType","currentText","returnHTML","JSONToCleanedText","sourceJson","textString","key","cleanCodes","sourceJsonExtra","isMotdJSONType","currentText","parseTextToJSON","text","motdText","colorCodeReg","codeREGEX","textSplit","fontStyle","colorHex","resultObject","item","stringToLowerCase","colorCodeToHex","textToJsonExtras","innerObject","newExtra","index","__spreadValues","JSONRender","json","parseJSONToHTML","autoToHTML","motd","textToHTML","autoCleanToText","motd","JSONToCleanedText","cleanCodes","autoCleanToText_default","motdParser","textToHTML","parseTextToJSON","parseJSONToHTML","JSONRender","autoToHTML","htmlStringFormatting","cleanCodes","cleanHtmlTags","JSONToCleanedText","autoCleanToText_default","index_default"]}
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var M=Object.defineProperty;var w=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var j=(t,e,o)=>e in t?M(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,b=(t,e)=>{for(var o in e||(e={}))N.call(e,o)&&j(t,o,e[o]);if(w)for(var o of w(e))E.call(e,o)&&j(t,o,e[o]);return t};function g(t){return!!t}function F(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/\n/g,"<br/>")}function k(t){return t.replace(/<[^>]*>?/gm,"")}function d(t){let e=/(?:§)([0-9a-fA-FklmnorFKLMNOR])/g,o="";return o=t.replace(e,""),o}var h={"\xA7k":"obfuscated;","\xA7l":"font-weight: bold;","\xA7m":"text-decoration: line-through;","\xA7n":"text-decoration: underline;","\xA7o":"font-style: italic;","\xA7r":"color: inherit;text-decoration: none !important;font-weight:normal!important;font-style: normal!important;"},O={bold:"font-weight: bold;",italic:"font-style: italic;",underlined:"text-decoration:underline;",strikethrough:"text-decoration: line-through;",obfuscated:"mc_obfuscated;",reset:"color: inherit;text-decoration: none !important;font-weight:normal!important;font-style: normal!important;"},S={"\xA7k":"obfuscated","\xA7l":"bold","\xA7m":"strikethrough","\xA7n":"underlined","\xA7o":"italic","\xA7r":"reset"},s={"\xA70":"#000000","\xA71":"#0000AA","\xA72":"#00AA00","\xA73":"#00AAAA","\xA74":"#AA0000","\xA75":"#AA00AA","\xA76":"#FFAA00","\xA77":"#AAAAAA","\xA78":"#555555","\xA79":"#5555FF","\xA7a":"#55FF55","\xA7b":"#55FFFF","\xA7c":"#FF5555","\xA7d":"#FF55FF","\xA7e":"#FFFF55","\xA7f":"#FFFFFF"},L={black:"#000000",dark_blue:"#0000AA",dark_green:"#00AA00",dark_aqua:"#00AAAA",dark_red:"#AA0000",dark_purple:"#AA00AA",gold:"#FFAA00",gray:"#AAAAAA",dark_gray:"#555555",blue:"#5555FF",green:"#55FF55",aqua:"#55FFFF",red:"#FF5555",light_purple:"#FF55FF",yellow:"#FFFF55",white:"#FFFFFF"};function m(t){let e=t,o=/([§][0-9a-f0-9a-fA-FklmnorFKLMNOR])/g,p=new RegExp(o.source),c=e.split(p).filter(l=>l!==""),r="",i="",n="";return c.forEach(l=>{let a=l.toLowerCase();if(Object.hasOwn(s,a))i=s[a],a==="\xA7f"&&(r="");else if(Object.hasOwn(h,a))a==="\xA7r"?(i="",r=""):r+=h[a];else{let f="",x=l;i!==""&&(f=`color:${i};`),x!==""&&(x=F(x),f.length!==0||r.length!==0?n+=`<span style="${f}${r}">${x}</span>`:n+=x)}}),n}function T(t){let e="",o="",p="";for(let r of Object.keys(t)){if(r=r.toLowerCase(),Object.hasOwn(O,r)&&t[r]&&(p+=`${O[r]}`),r==="color"){let i=t[r],n="";typeof i=="string"&&(Object.hasOwn(L,i)?n=L[i]:Object.hasOwn(s,i)?n=s[i]:n=i),n!==""&&(o=`color:${n};`)}if(r==="extra"&&typeof t.extra=="object"){t.text!==void 0&&(typeof t.text=="string"||typeof t.text=="number")&&(e+=m(String(t.text)));for(let i of t.extra)g(i)&&(e+=T(i))}}if(t.extra===void 0&&t.text!==void 0){let r=t.text;(typeof t.text=="string"||typeof t.text=="number")&&(e+=m(String(r)))}let c="";return p.length!==0||o.length!==0?c=`<span style="${o+p}">${e}</span>`:c=e,c}function y(t){let e="";for(let o of Object.keys(t))if(o=o.toLowerCase(),o==="extra"&&typeof t.extra=="object"){t.text!==void 0&&(typeof t.text=="string"||typeof t.text=="number")&&(e+=d(String(t.text)));for(let p of t.extra)g(p)&&(e+=y(p))}if(t.extra===void 0&&t.text!==void 0){let o=t.text;(typeof t.text=="string"||typeof t.text=="number")&&(e+=d(String(o)))}return e}function u(t){let e=t,o=/([§][0-9a-f0-9a-fA-FklmnorFKLMNOR])/g,p=new RegExp(o.source),c=e.split(p),r="",i="",n={text:"",extra:[]};c.forEach(a=>{let f=a.toLowerCase();if(Object.hasOwn(s,f))i=s[f],f==="\xA7f"&&(r="");else if(Object.hasOwn(S,f))f==="\xA7r"?(r="",i=""):r=S[f];else{let x={text:"",extra:[]};r!==""&&(x[r]=!0),x.text=a,i!==""&&(x.color=i),typeof n.extra=="object"&&n.extra.push(x)}});let l=[];return n.extra&&(n.extra.length>1?n.extra.forEach((a,f)=>{a.text===""?n.extra&&typeof n.extra[f+1]=="object"&&l.push(b(b({},a),n.extra[f+1])):a.text!==(l[l.length-1]&&l[l.length-1].text)&&l.push(a)}):l.push(n.extra[0])),l=l.filter(a=>a.text!==""),{text:n.text,extra:l}}function A(t){return T(t)}function C(t){return typeof t=="object"?A(t):typeof t=="string"?m(t):"unknown motd data type"}function J(t){return typeof t=="object"?y(t):typeof t=="string"?d(t):"unknown motd data type"}var H=J;var R={textToHTML:m,textToJSON:u,JSONToHTML:T,JSONRender:A,autoToHTML:C,htmlStringFormatting:F,cleanCodes:d,cleanHtmlTags:k,JSONToCleanedText:y,autoCleanToText:H},st=R;export{A as JSONRender,y as JSONToCleanedText,T as JSONToHTML,H as autoCleanToText,C as autoToHTML,d as cleanCodes,k as cleanHtmlTags,st as default,F as htmlStringFormatting,g as isMotdJSONType,m as textToHTML,u as textToJSON};
1
+ var M=Object.defineProperty;var w=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var j=(t,e,o)=>e in t?M(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,b=(t,e)=>{for(var o in e||(e={}))N.call(e,o)&&j(t,o,e[o]);if(w)for(var o of w(e))E.call(e,o)&&j(t,o,e[o]);return t};function g(t){return!!t}function F(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/\n/g,"<br/>")}function k(t){return t.replace(/<[^>]*>?/gm,"")}function c(t){let e=/(?:§)([0-9a-fA-FklmnorFKLMNOR])/g,o="";return o=t.replace(e,""),o}var h={"\xA7k":"obfuscated;","\xA7l":"font-weight: bold;","\xA7m":"text-decoration: line-through;","\xA7n":"text-decoration: underline;","\xA7o":"font-style: italic;","\xA7r":"color: inherit;text-decoration: none !important;font-weight:normal!important;font-style: normal!important;"},O={bold:"font-weight: bold;",italic:"font-style: italic;",underlined:"text-decoration:underline;",strikethrough:"text-decoration: line-through;",obfuscated:"mc_obfuscated;",reset:"color: inherit;text-decoration: none !important;font-weight:normal!important;font-style: normal!important;"},S={"\xA7k":"obfuscated","\xA7l":"bold","\xA7m":"strikethrough","\xA7n":"underlined","\xA7o":"italic","\xA7r":"reset"},m={"\xA70":"#000000","\xA71":"#0000AA","\xA72":"#00AA00","\xA73":"#00AAAA","\xA74":"#AA0000","\xA75":"#AA00AA","\xA76":"#FFAA00","\xA77":"#AAAAAA","\xA78":"#555555","\xA79":"#5555FF","\xA7a":"#55FF55","\xA7b":"#55FFFF","\xA7c":"#FF5555","\xA7d":"#FF55FF","\xA7e":"#FFFF55","\xA7f":"#FFFFFF"},L={black:"#000000",dark_blue:"#0000AA",dark_green:"#00AA00",dark_aqua:"#00AAAA",dark_red:"#AA0000",dark_purple:"#AA00AA",gold:"#FFAA00",gray:"#AAAAAA",dark_gray:"#555555",blue:"#5555FF",green:"#55FF55",aqua:"#55FFFF",red:"#FF5555",light_purple:"#FF55FF",yellow:"#FFFF55",white:"#FFFFFF"};function s(t){let e=t,o=/([§][0-9a-f0-9a-fA-FklmnorFKLMNOR])/g,p=new RegExp(o.source),d=e.split(p).filter(l=>l!==""),r="",n="",i="";return d.forEach(l=>{let a=l.toLowerCase();if(Object.hasOwn(m,a))n=m[a],a==="\xA7f"&&(r="");else if(Object.hasOwn(h,a))a==="\xA7r"?(n="",r=""):r+=h[a];else{let f="",x=l;n!==""&&(f=`color:${n};`),x!==""&&(x=F(x),f.length!==0||r.length!==0?i+=`<span style="${f}${r}">${x}</span>`:i+=x)}}),i}function T(t){let e="",o="",p="";for(let r of Object.keys(t)){if(r=r.toLowerCase(),Object.hasOwn(O,r)&&t[r]&&(p+=`${O[r]}`),r==="color"){let n=t[r],i="";typeof n=="string"&&(Object.hasOwn(L,n)?i=L[n]:Object.hasOwn(m,n)?i=m[n]:i=n),i!==""&&(o=`color:${i};`)}if(r==="extra"&&typeof t.extra=="object"){t.text!==void 0&&(typeof t.text=="string"||typeof t.text=="number")&&(e+=s(String(t.text)));for(let n of t.extra)typeof n=="string"?e+=s(n):g(n)&&(e+=T(n))}}if(t.extra===void 0&&t.text!==void 0){let r=t.text;(typeof t.text=="string"||typeof t.text=="number")&&(e+=s(String(r)))}let d="";return p.length!==0||o.length!==0?d=`<span style="${o+p}">${e}</span>`:d=e,d}function y(t){let e="";for(let o of Object.keys(t))if(o=o.toLowerCase(),o==="extra"&&typeof t.extra=="object"){t.text!==void 0&&(typeof t.text=="string"||typeof t.text=="number")&&(e+=c(String(t.text)));for(let p of t.extra)typeof p=="string"?e+=c(p):g(p)&&(e+=y(p))}if(t.extra===void 0&&t.text!==void 0){let o=t.text;(typeof t.text=="string"||typeof t.text=="number")&&(e+=c(String(o)))}return e}function u(t){let e=t,o=/([§][0-9a-f0-9a-fA-FklmnorFKLMNOR])/g,p=new RegExp(o.source),d=e.split(p),r="",n="",i={text:"",extra:[]};d.forEach(a=>{let f=a.toLowerCase();if(Object.hasOwn(m,f))n=m[f],f==="\xA7f"&&(r="");else if(Object.hasOwn(S,f))f==="\xA7r"?(r="",n=""):r=S[f];else{let x={text:"",extra:[]};r!==""&&(x[r]=!0),x.text=a,n!==""&&(x.color=n),typeof i.extra=="object"&&i.extra.push(x)}});let l=[];return i.extra&&(i.extra.length>1?i.extra.forEach((a,f)=>{a.text===""?i.extra&&typeof i.extra[f+1]=="object"&&l.push(b(b({},a),i.extra[f+1])):a.text!==(l[l.length-1]&&l[l.length-1].text)&&l.push(a)}):l.push(i.extra[0])),l=l.filter(a=>a.text!==""),{text:i.text,extra:l}}function A(t){return T(t)}function C(t){return typeof t=="object"?A(t):typeof t=="string"?s(t):"unknown motd data type"}function J(t){return typeof t=="object"?y(t):typeof t=="string"?c(t):"unknown motd data type"}var H=J;var R={textToHTML:s,textToJSON:u,JSONToHTML:T,JSONRender:A,autoToHTML:C,htmlStringFormatting:F,cleanCodes:c,cleanHtmlTags:k,JSONToCleanedText:y,autoCleanToText:H},st=R;export{A as JSONRender,y as JSONToCleanedText,T as JSONToHTML,H as autoCleanToText,C as autoToHTML,c as cleanCodes,k as cleanHtmlTags,st as default,F as htmlStringFormatting,g as isMotdJSONType,s as textToHTML,u as textToJSON};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils.ts","../src/styleLibrary.ts","../src/parser/textToHTML.ts","../src/parser/JSONToHTML.ts","../src/parser/JSONToCleanedText.ts","../src/parser/textToJSON.ts","../src/parser/autoToHTML.ts","../src/parser/autoCleanToText.ts","../src/index.ts"],"sourcesContent":["/*\n * minecraft motd parser\n * (c) 2023 Kevin Zheng\n * Released under the MIT license\n */\n\nimport { motdJsonType } from \"./types\";\n\n\n\n\n// 類型檢查\nexport function isMotdJSONType(object: object): object is motdJsonType {\n return !!object;\n};\n\n\n\n/**\n *\n * replace all html tags to &...\n */\nexport function htmlStringFormatting(text: string): string {\n return (\n text\n // space\n // .replace(/ /g, \"\\u00a0\")\n //\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#39;\")\n // return\n .replace(/\\n/g, \"<br/>\")\n );\n // .replace(/\\//g, '&#x2F;');\n};\n\n\n\n/**\n * clean html tags\n * \n * @param text\n * example: `<span>hello world</span>`\n * \n * result: `hello world`\n */\nexport function cleanHtmlTags(text: string): string {\n return text.replace(/<[^>]*>?/gm, '');\n};\n\n\n\n/**\n * clean motd codes\n * \n * Clean all codes from motd source string.\n * \n * @param {string} text - motd string include tag § will remove\n */\nexport function cleanCodes(text: string) {\n const REGEX = /(?:§)([0-9a-fA-FklmnorFKLMNOR])/g;\n let textResult = \"\";\n\n textResult = text.replace(REGEX, \"\");\n\n return textResult;\n};\n","import { extraLibraryType } from \"./types\";\n\n\n\n// color code to font styles\nconst extras: extraLibraryType = {\n \"§k\": \"obfuscated;\",\n \"§l\": \"font-weight: bold;\",\n \"§m\": \"text-decoration: line-through;\",\n \"§n\": \"text-decoration: underline;\",\n \"§o\": \"font-style: italic;\",\n \"§r\": \"color: inherit;text-decoration: none !important;font-weight:normal!important;font-style: normal!important;\",\n};\n\n// json extra font styles\nconst extraFontStyles: extraLibraryType = {\n bold: \"font-weight: bold;\",\n italic: \"font-style: italic;\",\n underlined: \"text-decoration:underline;\",\n strikethrough: \"text-decoration: line-through;\",\n obfuscated: \"mc_obfuscated;\",\n reset: \"color: inherit;text-decoration: none !important;font-weight:normal!important;font-style: normal!important;\",\n};\n\n// text to json extra name\nconst textToJsonExtras: extraLibraryType = {\n \"§k\": \"obfuscated\",\n \"§l\": \"bold\",\n \"§m\": \"strikethrough\",\n \"§n\": \"underlined\",\n \"§o\": \"italic\",\n \"§r\": \"reset\",\n};\n\n// base color hex\nconst colorCodeToHex: extraLibraryType = {\n \"§0\": \"#000000\",\n \"§1\": \"#0000AA\",\n \"§2\": \"#00AA00\",\n \"§3\": \"#00AAAA\",\n \"§4\": \"#AA0000\",\n \"§5\": \"#AA00AA\",\n \"§6\": \"#FFAA00\",\n \"§7\": \"#AAAAAA\",\n \"§8\": \"#555555\",\n \"§9\": \"#5555FF\",\n \"§a\": \"#55FF55\",\n \"§b\": \"#55FFFF\",\n \"§c\": \"#FF5555\",\n \"§d\": \"#FF55FF\",\n \"§e\": \"#FFFF55\",\n \"§f\": \"#FFFFFF\",\n};\n\n// json extra to hex color\nconst extraColorsToHex: extraLibraryType = {\n black: \"#000000\",\n dark_blue: \"#0000AA\",\n dark_green: \"#00AA00\",\n dark_aqua: \"#00AAAA\",\n dark_red: \"#AA0000\",\n dark_purple: \"#AA00AA\",\n gold: \"#FFAA00\",\n gray: \"#AAAAAA\",\n dark_gray: \"#555555\",\n blue: \"#5555FF\",\n green: \"#55FF55\",\n aqua: \"#55FFFF\",\n red: \"#FF5555\",\n light_purple: \"#FF55FF\",\n yellow: \"#FFFF55\",\n white: \"#FFFFFF\",\n};\n\n\n\nexport {\n extras,\n extraFontStyles,\n textToJsonExtras,\n colorCodeToHex,\n extraColorsToHex,\n};\n","import {\n extras,\n colorCodeToHex,\n} from '../styleLibrary';\nimport {\n htmlStringFormatting,\n} from \"../utils\";\n\n\n\n/**\n * Convert motd text to html.\n * @param motdString\n */\nexport default function textToHTML(motdString: string) {\n const motdText = motdString;\n\n const colorCodeReg = /([§][0-9a-f0-9a-fA-FklmnorFKLMNOR])/g;\n const codeREGEX = new RegExp(colorCodeReg.source);\n const codeSplit = motdText.split(codeREGEX).filter(item => item !== '');\n\n let fontStyle = \"\";\n let colorHex = \"\";\n let resultHTML = \"\";\n\n codeSplit.forEach((item) => {\n const motdStringToLowerCase = item.toLowerCase();\n // console.log('motdStringToLowerCase', motdStringToLowerCase);\n\n // 過濾 hex\n if (Object.hasOwn(colorCodeToHex, motdStringToLowerCase)) {\n //console.log(`偵測出 ${ colorCodeToHex[item] }`)\n colorHex = colorCodeToHex[motdStringToLowerCase];\n\n // §f reset\n if(motdStringToLowerCase === \"§f\") {\n fontStyle = \"\";\n }\n // 過濾文字 style\n } else if (Object.hasOwn(extras, motdStringToLowerCase)) {\n if(motdStringToLowerCase === \"§r\") {\n colorHex = \"\";\n fontStyle = \"\";\n } else {\n // font style code 轉換\n // console.log(`偵測出 style ${ extras[motdStringToLowerCase] }`);\n fontStyle += extras[motdStringToLowerCase];\n }\n // console.log('motdStringToLowerCase', motdStringToLowerCase);\n // console.log('textFont: ' + fontStyle);\n // 正常文字\n } else {\n let resultColor = \"\";\n let textContent = item;\n //console.log(fontStyle)\n\n // 檢查 Hex color\n if (colorHex !== \"\") {\n resultColor = `color:${colorHex};`;\n }\n\n if (textContent !== \"\") {\n //console.log('font: ' + fontStyle)\n //console.log('color: ' + colorHex)\n //console.log('text: ' + item)\n //console.log('---------------------------------')\n // replace html tags\n textContent = htmlStringFormatting(textContent);\n\n if (resultColor.length !== 0 || fontStyle.length !== 0) {\n resultHTML += `<span style=\"${resultColor}${fontStyle}\">${textContent}</span>`;\n } else {\n resultHTML += textContent;\n }\n }\n }\n });\n\n return resultHTML;\n}\n","import { motdJsonType } from \"../types\";\nimport {\n extraFontStyles,\n colorCodeToHex,\n extraColorsToHex,\n} from '../styleLibrary';\nimport {\n isMotdJSONType,\n} from \"../utils\";\nimport textToHTML from \"./textToHTML\";\n\n\n\n/**\n * Convert JSON to HTML.\n * \n * @param sourceJson\n */\nexport default function parseJSONToHTML(\n sourceJson: motdJsonType,\n) {\n let htmlElement = \"\";\n let colorStyle = \"\";\n let fontStyle = \"\";\n\n // console.log('sourceJson', sourceJson);\n // console.log('---------');\n\n for (let key of Object.keys(sourceJson)) {\n // console.log('sourceJson key', key);\n key = key.toLowerCase();\n\n // text styles\n if (Object.hasOwn(extraFontStyles, key)) {\n if (sourceJson[key]) {\n fontStyle += `${extraFontStyles[key]}`;\n }\n }\n\n // ---------- old text process ----------\n // if (key === \"text\") {\n // if (\n // typeof sourceJson.text === \"string\" ||\n // typeof sourceJson.text === \"number\"\n // ) {\n // // convert all type to string\n // htmlElement += textToHTML(String(sourceJson.text));\n // }\n // }\n\n // color\n if (key === \"color\") {\n const colorKey = sourceJson[key];\n let colorHex = \"\";\n\n if (typeof colorKey === \"string\") {\n // Hex color\n if (Object.hasOwn(extraColorsToHex, colorKey)) {\n colorHex = extraColorsToHex[colorKey];\n // color code\n } else if (Object.hasOwn(colorCodeToHex, colorKey)) {\n colorHex = colorCodeToHex[colorKey];\n // custom color\n } else {\n // custom hex color code mode\n colorHex = colorKey;\n }\n }\n\n if(colorHex !== \"\") {\n colorStyle = `color:${colorHex};`;\n }\n }\n\n // extra\n if (key === \"extra\" && typeof sourceJson.extra === \"object\") {\n // ---------- with extra text ----------\n if (sourceJson.text !== undefined\n && (typeof sourceJson.text === \"string\" || typeof sourceJson.text === \"number\")\n ) {\n // content to html\n htmlElement += textToHTML(String(sourceJson.text));\n }\n\n // ---------- foreach extra data and parse ----------\n for (const sourceJsonExtra of sourceJson.extra) {\n // console.log('sourceJsonExtra', sourceJsonExtra);\n if (isMotdJSONType(sourceJsonExtra)) {\n htmlElement += parseJSONToHTML(sourceJsonExtra);\n }\n }\n }\n }\n\n // ---------- without extra text content ----------\n if (sourceJson.extra === undefined && sourceJson.text !== undefined) {\n const currentText = sourceJson.text;\n if (\n typeof sourceJson.text === \"string\" ||\n typeof sourceJson.text === \"number\"\n ) {\n // convert all type to string\n htmlElement += textToHTML(String(currentText));\n }\n }\n\n\n\n let returnHTML = \"\";\n if (fontStyle.length !== 0 || colorStyle.length !== 0) {\n returnHTML = `<span style=\"${colorStyle + fontStyle}\">${htmlElement}</span>`;\n } else {\n returnHTML = htmlElement;\n }\n\n return returnHTML;\n}\n","import { motdJsonType } from \"../types\";\nimport {\n isMotdJSONType,\n cleanCodes\n} from \"../utils\";\n\n\n\n/**\n * Convert JSON to Cleaned Text.\n * \n * @param sourceJson\n */\nexport default function JSONToCleanedText(\n sourceJson: motdJsonType,\n) {\n let textString = \"\";\n\n for (let key of Object.keys(sourceJson)) {\n key = key.toLowerCase();\n\n // extra\n if (key === \"extra\" && typeof sourceJson.extra === \"object\") {\n // ---------- with extra text ----------\n if (sourceJson.text !== undefined\n && (typeof sourceJson.text === \"string\" || typeof sourceJson.text === \"number\")\n ) {\n // content to html\n textString += cleanCodes(String(sourceJson.text));\n }\n\n // ---------- foreach extra data and parse ----------\n for (const sourceJsonExtra of sourceJson.extra) {\n // console.log('sourceJsonExtra', sourceJsonExtra);\n if (isMotdJSONType(sourceJsonExtra)) {\n textString += JSONToCleanedText(sourceJsonExtra);\n }\n }\n }\n }\n\n // ---------- without extra text content ----------\n if (sourceJson.extra === undefined && sourceJson.text !== undefined) {\n const currentText = sourceJson.text;\n if (\n typeof sourceJson.text === \"string\" ||\n typeof sourceJson.text === \"number\"\n ) {\n // convert all type to string\n textString += cleanCodes(String(currentText));\n }\n }\n\n return textString;\n}\n","import { motdJsonType } from \"../types\";\nimport {\n textToJsonExtras,\n colorCodeToHex,\n} from '../styleLibrary';\n\n\n\n/**\n * Convert motd text to JSON.\n * \n * @param text\n */\nexport default function parseTextToJSON(text: string) {\n const motdText = text;\n\n // color code regex: /([§][0-9a-fklmnor])/g\n // color hex regex: /^#(?:[0-9a-f]{3}){1,2}$/g\n const colorCodeReg = /([§][0-9a-f0-9a-fA-FklmnorFKLMNOR])/g;\n const codeREGEX = new RegExp(colorCodeReg.source);\n const textSplit = motdText.split(codeREGEX);\n let fontStyle = \"\";\n let colorHex = \"\";\n\n const resultObject: motdJsonType = {\n text: \"\",\n extra: [],\n };\n\n // console.log('textSplit', textSplit);\n textSplit.forEach((item) => {\n const stringToLowerCase = item.toLowerCase();\n\n // color code 轉換成 hex\n if (Object.hasOwn(colorCodeToHex, stringToLowerCase)) {\n //console.log(`偵測出 ${ colorCodeToHex[item] }`)\n colorHex = colorCodeToHex[stringToLowerCase];\n // §f reset\n if(stringToLowerCase === \"§f\") {\n fontStyle = \"\";\n }\n } else if (Object.hasOwn(textToJsonExtras, stringToLowerCase)) {\n if(stringToLowerCase === \"§r\") {\n fontStyle = \"\";\n colorHex = \"\";\n } else {\n // font style code 轉換\n //console.log(`偵測出 style ${ textToJsonExtras[item] }`)\n fontStyle = textToJsonExtras[stringToLowerCase];\n }\n } else {\n const innerObject: motdJsonType = {\n text: \"\",\n extra: [],\n };\n\n // 其餘字串\n if (fontStyle !== \"\") {\n innerObject[fontStyle] = true;\n }\n\n innerObject.text = item;\n\n if (colorHex !== \"\") {\n innerObject.color = colorHex;\n }\n\n if (typeof resultObject.extra === \"object\") {\n resultObject.extra.push(innerObject);\n }\n }\n });\n\n // code styles merge\n let newExtra: Array<motdJsonType> = [];\n // console.log('resultObject', resultObject);\n if (resultObject.extra) {\n if (resultObject.extra.length > 1) {\n // if text is '', remove it and merge to next array\n resultObject.extra.forEach((item, index) => {\n // console.log('item', item);\n if (item.text === \"\") {\n if (\n resultObject.extra\n && typeof resultObject.extra[index + 1] === \"object\"\n ) {\n newExtra.push({\n ...(item as motdJsonType),\n ...resultObject.extra[index + 1],\n });\n }\n } else {\n if (\n item.text !== (newExtra[newExtra.length - 1]\n && newExtra[newExtra.length - 1].text)\n ) {\n newExtra.push(item as motdJsonType);\n }\n }\n });\n } else {\n newExtra.push(resultObject.extra[0] as motdJsonType);\n }\n }\n\n // console.log('newExtra', newExtra);\n // remove blank content\n newExtra = newExtra.filter((item) => item.text !== \"\");\n // console.log('newExtra', newExtra);\n\n return {\n text: resultObject.text,\n extra: newExtra,\n };\n}\n","import { motdJsonType } from \"../types\";\nimport {\n JSONToHTML,\n textToHTML,\n} from \"./\";\n\n\n\n// make sure JSON data is JSON object and then convert.\nexport function JSONRender(json: object) {\n return JSONToHTML(json as motdJsonType);\n}\n\n/**\n * auto check data type then convert to html.\n */\nexport function autoToHTML(motd: string | object): string {\n // type check\n if (typeof motd === \"object\") {\n // console.log('process mode: Object mode');\n return JSONRender(motd);\n } else if (typeof motd === \"string\") {\n // console.log('process mode: String mode');\n // console.log('textToJSON(motd)', textToJSON(motd));\n return textToHTML(motd);\n // return jsonRender(textToJSON(motd));\n } else {\n return \"unknown motd data type\";\n }\n}\n\n\n\nexport default autoToHTML;\n","import { motdJsonType } from \"../types\";\nimport {\n JSONToCleanedText,\n} from \".\";\nimport { cleanCodes } from \"../utils\";\n\n\n\n/**\n * auto check data type then convert to html.\n */\nexport function autoCleanToText(motd: string | object): string {\n // type check\n if (typeof motd === \"object\") {\n // console.log('process mode: Object mode');\n return JSONToCleanedText(motd as motdJsonType);\n } else if (typeof motd === \"string\") {\n // console.log('process mode: String mode');\n return cleanCodes(motd);\n } else {\n return \"unknown motd data type\";\n }\n}\n\n\n\nexport default autoCleanToText;\n","/*\n * minecraft motd parser\n * (c) 2021 Kevin Zheng\n * Released under the MIT license\n */\nimport {\n htmlStringFormatting,\n cleanCodes,\n cleanHtmlTags,\n} from \"./utils\";\nimport {\n JSONToHTML,\n JSONToCleanedText,\n\n textToHTML,\n textToJSON,\n\n JSONRender,\n autoToHTML,\n autoCleanToText,\n} from \"./parser\";\n\n\n\n\n\n\nexport * from './utils';\nexport * from \"./parser\";\n\n\n\n/*\n * #### minecraft motd parser\n * * [github](https://github.com/SnowFireWolf/minecraft-motd-parser/tree/main#minecraft-server-motd-parser)\n * * [npm](https://www.npmjs.com/package/@sfirew/minecraft-motd-parser)\n *\n * (c) 2021 Kevin Zheng\n *\n * Released under the MIT license\n */\nconst motdParser = {\n // --- normal format ---\n // text convert to HTML\n textToHTML,\n // text convert to JSON\n textToJSON,\n // JSON convert to HTML\n JSONToHTML,\n // JSON string to JSON object and convert to HTML\n JSONRender,\n // auto check type to convert\n autoToHTML,\n\n // --- utils ---\n // html string formatter\n htmlStringFormatting,\n // clean all motd codes\n cleanCodes,\n // clean all html tags\n cleanHtmlTags,\n // json to not html text\n JSONToCleanedText,\n // auto check type and convert to cleaned text\n autoCleanToText,\n};\n\nexport default motdParser;\n"],"mappings":"yVAYO,SAASA,EAAeC,EAAwC,CACrE,MAAO,CAAC,CAACA,CACX,CAQO,SAASC,EAAqBC,EAAsB,CACzD,OACEA,EAIG,QAAQ,KAAM,OAAO,EACrB,QAAQ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AAWF,CAAI,EAEf,wBAEX,CAIA,IAAOG,EAAQJ,ECef,IAAMK,EAAa,CAGjB,WAAAC,EAEA,WAAAC,EAEA,WAAAC,EAEA,WAAAC,EAEA,WAAAC,EAIA,qBAAAC,EAEA,WAAAC,EAEA,cAAAC,EAEA,kBAAAC,EAEA,gBAAAC,CACF,EAEOC,GAAQX","names":["isMotdJSONType","object","htmlStringFormatting","text","cleanHtmlTags","cleanCodes","REGEX","textResult","extras","extraFontStyles","textToJsonExtras","colorCodeToHex","extraColorsToHex","textToHTML","motdString","motdText","colorCodeReg","codeREGEX","codeSplit","item","fontStyle","colorHex","resultHTML","motdStringToLowerCase","colorCodeToHex","extras","resultColor","textContent","htmlStringFormatting","parseJSONToHTML","sourceJson","htmlElement","colorStyle","fontStyle","key","extraFontStyles","colorKey","colorHex","extraColorsToHex","colorCodeToHex","textToHTML","sourceJsonExtra","isMotdJSONType","currentText","returnHTML","JSONToCleanedText","sourceJson","textString","key","cleanCodes","sourceJsonExtra","isMotdJSONType","currentText","parseTextToJSON","text","motdText","colorCodeReg","codeREGEX","textSplit","fontStyle","colorHex","resultObject","item","stringToLowerCase","colorCodeToHex","textToJsonExtras","innerObject","newExtra","index","__spreadValues","JSONRender","json","parseJSONToHTML","autoToHTML","motd","textToHTML","autoCleanToText","motd","JSONToCleanedText","cleanCodes","autoCleanToText_default","motdParser","textToHTML","parseTextToJSON","parseJSONToHTML","JSONRender","autoToHTML","htmlStringFormatting","cleanCodes","cleanHtmlTags","JSONToCleanedText","autoCleanToText_default","src_default"]}
1
+ {"version":3,"sources":["../src/utils.ts","../src/styleLibrary.ts","../src/parser/textToHTML.ts","../src/parser/JSONToHTML.ts","../src/parser/JSONToCleanedText.ts","../src/parser/textToJSON.ts","../src/parser/autoToHTML.ts","../src/parser/autoCleanToText.ts","../src/index.ts"],"sourcesContent":["/*\n * minecraft motd parser\n * (c) 2023 Kevin Zheng\n * Released under the MIT license\n */\n\nimport { motdJsonType } from \"./types\";\n\n\n\n\n// 類型檢查\nexport function isMotdJSONType(object: object): object is motdJsonType {\n return !!object;\n};\n\n\n\n/**\n *\n * replace all html tags to &...\n */\nexport function htmlStringFormatting(text: string): string {\n return (\n text\n // space\n // .replace(/ /g, \"\\u00a0\")\n //\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#39;\")\n // return\n .replace(/\\n/g, \"<br/>\")\n );\n // .replace(/\\//g, '&#x2F;');\n};\n\n\n\n/**\n * clean html tags\n * \n * @param text\n * example: `<span>hello world</span>`\n * \n * result: `hello world`\n */\nexport function cleanHtmlTags(text: string): string {\n return text.replace(/<[^>]*>?/gm, '');\n};\n\n\n\n/**\n * clean motd codes\n * \n * Clean all codes from motd source string.\n * \n * @param {string} text - motd string include tag § will remove\n */\nexport function cleanCodes(text: string) {\n const REGEX = /(?:§)([0-9a-fA-FklmnorFKLMNOR])/g;\n let textResult = \"\";\n\n textResult = text.replace(REGEX, \"\");\n\n return textResult;\n};\n","import { extraLibraryType } from \"./types\";\n\n\n\n// color code to font styles\nconst extras: extraLibraryType = {\n \"§k\": \"obfuscated;\",\n \"§l\": \"font-weight: bold;\",\n \"§m\": \"text-decoration: line-through;\",\n \"§n\": \"text-decoration: underline;\",\n \"§o\": \"font-style: italic;\",\n \"§r\": \"color: inherit;text-decoration: none !important;font-weight:normal!important;font-style: normal!important;\",\n};\n\n// json extra font styles\nconst extraFontStyles: extraLibraryType = {\n bold: \"font-weight: bold;\",\n italic: \"font-style: italic;\",\n underlined: \"text-decoration:underline;\",\n strikethrough: \"text-decoration: line-through;\",\n obfuscated: \"mc_obfuscated;\",\n reset: \"color: inherit;text-decoration: none !important;font-weight:normal!important;font-style: normal!important;\",\n};\n\n// text to json extra name\nconst textToJsonExtras: extraLibraryType = {\n \"§k\": \"obfuscated\",\n \"§l\": \"bold\",\n \"§m\": \"strikethrough\",\n \"§n\": \"underlined\",\n \"§o\": \"italic\",\n \"§r\": \"reset\",\n};\n\n// base color hex\nconst colorCodeToHex: extraLibraryType = {\n \"§0\": \"#000000\",\n \"§1\": \"#0000AA\",\n \"§2\": \"#00AA00\",\n \"§3\": \"#00AAAA\",\n \"§4\": \"#AA0000\",\n \"§5\": \"#AA00AA\",\n \"§6\": \"#FFAA00\",\n \"§7\": \"#AAAAAA\",\n \"§8\": \"#555555\",\n \"§9\": \"#5555FF\",\n \"§a\": \"#55FF55\",\n \"§b\": \"#55FFFF\",\n \"§c\": \"#FF5555\",\n \"§d\": \"#FF55FF\",\n \"§e\": \"#FFFF55\",\n \"§f\": \"#FFFFFF\",\n};\n\n// json extra to hex color\nconst extraColorsToHex: extraLibraryType = {\n black: \"#000000\",\n dark_blue: \"#0000AA\",\n dark_green: \"#00AA00\",\n dark_aqua: \"#00AAAA\",\n dark_red: \"#AA0000\",\n dark_purple: \"#AA00AA\",\n gold: \"#FFAA00\",\n gray: \"#AAAAAA\",\n dark_gray: \"#555555\",\n blue: \"#5555FF\",\n green: \"#55FF55\",\n aqua: \"#55FFFF\",\n red: \"#FF5555\",\n light_purple: \"#FF55FF\",\n yellow: \"#FFFF55\",\n white: \"#FFFFFF\",\n};\n\n\n\nexport {\n extras,\n extraFontStyles,\n textToJsonExtras,\n colorCodeToHex,\n extraColorsToHex,\n};\n","import {\n extras,\n colorCodeToHex,\n} from '../styleLibrary';\nimport {\n htmlStringFormatting,\n} from \"../utils\";\n\n\n\n/**\n * Convert motd text to html.\n * @param motdString\n */\nexport default function textToHTML(motdString: string) {\n const motdText = motdString;\n\n const colorCodeReg = /([§][0-9a-f0-9a-fA-FklmnorFKLMNOR])/g;\n const codeREGEX = new RegExp(colorCodeReg.source);\n const codeSplit = motdText.split(codeREGEX).filter(item => item !== '');\n\n let fontStyle = \"\";\n let colorHex = \"\";\n let resultHTML = \"\";\n\n codeSplit.forEach((item) => {\n const motdStringToLowerCase = item.toLowerCase();\n // console.log('motdStringToLowerCase', motdStringToLowerCase);\n\n // 過濾 hex\n if (Object.hasOwn(colorCodeToHex, motdStringToLowerCase)) {\n //console.log(`偵測出 ${ colorCodeToHex[item] }`)\n colorHex = colorCodeToHex[motdStringToLowerCase];\n\n // §f reset\n if(motdStringToLowerCase === \"§f\") {\n fontStyle = \"\";\n }\n // 過濾文字 style\n } else if (Object.hasOwn(extras, motdStringToLowerCase)) {\n if(motdStringToLowerCase === \"§r\") {\n colorHex = \"\";\n fontStyle = \"\";\n } else {\n // font style code 轉換\n // console.log(`偵測出 style ${ extras[motdStringToLowerCase] }`);\n fontStyle += extras[motdStringToLowerCase];\n }\n // console.log('motdStringToLowerCase', motdStringToLowerCase);\n // console.log('textFont: ' + fontStyle);\n // 正常文字\n } else {\n let resultColor = \"\";\n let textContent = item;\n //console.log(fontStyle)\n\n // 檢查 Hex color\n if (colorHex !== \"\") {\n resultColor = `color:${colorHex};`;\n }\n\n if (textContent !== \"\") {\n //console.log('font: ' + fontStyle)\n //console.log('color: ' + colorHex)\n //console.log('text: ' + item)\n //console.log('---------------------------------')\n // replace html tags\n textContent = htmlStringFormatting(textContent);\n\n if (resultColor.length !== 0 || fontStyle.length !== 0) {\n resultHTML += `<span style=\"${resultColor}${fontStyle}\">${textContent}</span>`;\n } else {\n resultHTML += textContent;\n }\n }\n }\n });\n\n return resultHTML;\n}\n","import { motdJsonType } from \"../types\";\nimport {\n extraFontStyles,\n colorCodeToHex,\n extraColorsToHex,\n} from '../styleLibrary';\nimport {\n isMotdJSONType,\n} from \"../utils\";\nimport textToHTML from \"./textToHTML\";\n\n\n\n/**\n * Convert JSON to HTML.\n * \n * @param sourceJson\n */\nexport default function parseJSONToHTML(\n sourceJson: motdJsonType,\n) {\n let htmlElement = \"\";\n let colorStyle = \"\";\n let fontStyle = \"\";\n\n // console.log('sourceJson', sourceJson);\n // console.log('---------');\n\n for (let key of Object.keys(sourceJson)) {\n // console.log('sourceJson key', key);\n key = key.toLowerCase();\n\n // text styles\n if (Object.hasOwn(extraFontStyles, key)) {\n if (sourceJson[key]) {\n fontStyle += `${extraFontStyles[key]}`;\n }\n }\n\n // ---------- old text process ----------\n // if (key === \"text\") {\n // if (\n // typeof sourceJson.text === \"string\" ||\n // typeof sourceJson.text === \"number\"\n // ) {\n // // convert all type to string\n // htmlElement += textToHTML(String(sourceJson.text));\n // }\n // }\n\n // color\n if (key === \"color\") {\n const colorKey = sourceJson[key];\n let colorHex = \"\";\n\n if (typeof colorKey === \"string\") {\n // Hex color\n if (Object.hasOwn(extraColorsToHex, colorKey)) {\n colorHex = extraColorsToHex[colorKey];\n // color code\n } else if (Object.hasOwn(colorCodeToHex, colorKey)) {\n colorHex = colorCodeToHex[colorKey];\n // custom color\n } else {\n // custom hex color code mode\n colorHex = colorKey;\n }\n }\n\n if(colorHex !== \"\") {\n colorStyle = `color:${colorHex};`;\n }\n }\n\n // extra\n if (key === \"extra\" && typeof sourceJson.extra === \"object\") {\n // ---------- with extra text ----------\n if (sourceJson.text !== undefined\n && (typeof sourceJson.text === \"string\" || typeof sourceJson.text === \"number\")\n ) {\n // content to html\n htmlElement += textToHTML(String(sourceJson.text));\n }\n\n // ---------- foreach extra data and parse ----------\n for (const sourceJsonExtra of sourceJson.extra) {\n // console.log('sourceJsonExtra', sourceJsonExtra);\n if (typeof sourceJsonExtra === 'string') {\n // Process string elements directly with textToHTML\n htmlElement += textToHTML(sourceJsonExtra);\n } else if (isMotdJSONType(sourceJsonExtra)) {\n htmlElement += parseJSONToHTML(sourceJsonExtra);\n }\n }\n }\n }\n\n // ---------- without extra text content ----------\n if (sourceJson.extra === undefined && sourceJson.text !== undefined) {\n const currentText = sourceJson.text;\n if (\n typeof sourceJson.text === \"string\" ||\n typeof sourceJson.text === \"number\"\n ) {\n // convert all type to string\n htmlElement += textToHTML(String(currentText));\n }\n }\n\n\n\n let returnHTML = \"\";\n if (fontStyle.length !== 0 || colorStyle.length !== 0) {\n returnHTML = `<span style=\"${colorStyle + fontStyle}\">${htmlElement}</span>`;\n } else {\n returnHTML = htmlElement;\n }\n\n return returnHTML;\n}\n","import { motdJsonType } from \"../types\";\nimport {\n isMotdJSONType,\n cleanCodes\n} from \"../utils\";\n\n\n\n/**\n * Convert JSON to Cleaned Text.\n * \n * @param sourceJson\n */\nexport default function JSONToCleanedText(\n sourceJson: motdJsonType,\n) {\n let textString = \"\";\n\n for (let key of Object.keys(sourceJson)) {\n key = key.toLowerCase();\n\n // extra\n if (key === \"extra\" && typeof sourceJson.extra === \"object\") {\n // ---------- with extra text ----------\n if (sourceJson.text !== undefined\n && (typeof sourceJson.text === \"string\" || typeof sourceJson.text === \"number\")\n ) {\n // content to html\n textString += cleanCodes(String(sourceJson.text));\n }\n\n // ---------- foreach extra data and parse ----------\n for (const sourceJsonExtra of sourceJson.extra) {\n // console.log('sourceJsonExtra', sourceJsonExtra);\n if (typeof sourceJsonExtra === 'string') {\n // Add string elements directly to the output\n textString += cleanCodes(sourceJsonExtra);\n } else if (isMotdJSONType(sourceJsonExtra)) {\n textString += JSONToCleanedText(sourceJsonExtra);\n }\n }\n }\n }\n\n // ---------- without extra text content ----------\n if (sourceJson.extra === undefined && sourceJson.text !== undefined) {\n const currentText = sourceJson.text;\n if (\n typeof sourceJson.text === \"string\" ||\n typeof sourceJson.text === \"number\"\n ) {\n // convert all type to string\n textString += cleanCodes(String(currentText));\n }\n }\n\n return textString;\n}\n","import { motdJsonType } from \"../types\";\nimport {\n textToJsonExtras,\n colorCodeToHex,\n} from '../styleLibrary';\n\n\n\n/**\n * Convert motd text to JSON.\n * \n * @param text\n */\nexport default function parseTextToJSON(text: string) {\n const motdText = text;\n\n // color code regex: /([§][0-9a-fklmnor])/g\n // color hex regex: /^#(?:[0-9a-f]{3}){1,2}$/g\n const colorCodeReg = /([§][0-9a-f0-9a-fA-FklmnorFKLMNOR])/g;\n const codeREGEX = new RegExp(colorCodeReg.source);\n const textSplit = motdText.split(codeREGEX);\n let fontStyle = \"\";\n let colorHex = \"\";\n\n const resultObject: motdJsonType = {\n text: \"\",\n extra: [],\n };\n\n // console.log('textSplit', textSplit);\n textSplit.forEach((item) => {\n const stringToLowerCase = item.toLowerCase();\n\n // color code 轉換成 hex\n if (Object.hasOwn(colorCodeToHex, stringToLowerCase)) {\n //console.log(`偵測出 ${ colorCodeToHex[item] }`)\n colorHex = colorCodeToHex[stringToLowerCase];\n // §f reset\n if(stringToLowerCase === \"§f\") {\n fontStyle = \"\";\n }\n } else if (Object.hasOwn(textToJsonExtras, stringToLowerCase)) {\n if(stringToLowerCase === \"§r\") {\n fontStyle = \"\";\n colorHex = \"\";\n } else {\n // font style code 轉換\n //console.log(`偵測出 style ${ textToJsonExtras[item] }`)\n fontStyle = textToJsonExtras[stringToLowerCase];\n }\n } else {\n const innerObject: motdJsonType = {\n text: \"\",\n extra: [],\n };\n\n // 其餘字串\n if (fontStyle !== \"\") {\n innerObject[fontStyle] = true;\n }\n\n innerObject.text = item;\n\n if (colorHex !== \"\") {\n innerObject.color = colorHex;\n }\n\n if (typeof resultObject.extra === \"object\") {\n resultObject.extra.push(innerObject);\n }\n }\n });\n\n // code styles merge\n let newExtra: Array<motdJsonType> = [];\n // console.log('resultObject', resultObject);\n if (resultObject.extra) {\n if (resultObject.extra.length > 1) {\n // if text is '', remove it and merge to next array\n resultObject.extra.forEach((item, index) => {\n // console.log('item', item);\n if (item.text === \"\") {\n if (\n resultObject.extra\n && typeof resultObject.extra[index + 1] === \"object\"\n ) {\n newExtra.push({\n ...(item as motdJsonType),\n ...resultObject.extra[index + 1],\n });\n }\n } else {\n if (\n item.text !== (newExtra[newExtra.length - 1]\n && newExtra[newExtra.length - 1].text)\n ) {\n newExtra.push(item as motdJsonType);\n }\n }\n });\n } else {\n newExtra.push(resultObject.extra[0] as motdJsonType);\n }\n }\n\n // console.log('newExtra', newExtra);\n // remove blank content\n newExtra = newExtra.filter((item) => item.text !== \"\");\n // console.log('newExtra', newExtra);\n\n return {\n text: resultObject.text,\n extra: newExtra,\n };\n}\n","import { motdJsonType } from \"../types\";\nimport {\n JSONToHTML,\n textToHTML,\n} from \"./\";\n\n\n\n// make sure JSON data is JSON object and then convert.\nexport function JSONRender(json: object) {\n return JSONToHTML(json as motdJsonType);\n}\n\n/**\n * auto check data type then convert to html.\n */\nexport function autoToHTML(motd: string | object): string {\n // type check\n if (typeof motd === \"object\") {\n // console.log('process mode: Object mode');\n return JSONRender(motd);\n } else if (typeof motd === \"string\") {\n // console.log('process mode: String mode');\n // console.log('textToJSON(motd)', textToJSON(motd));\n return textToHTML(motd);\n // return jsonRender(textToJSON(motd));\n } else {\n return \"unknown motd data type\";\n }\n}\n\n\n\nexport default autoToHTML;\n","import { motdJsonType } from \"../types\";\nimport {\n JSONToCleanedText,\n} from \".\";\nimport { cleanCodes } from \"../utils\";\n\n\n\n/**\n * auto check data type then convert to html.\n */\nexport function autoCleanToText(motd: string | object): string {\n // type check\n if (typeof motd === \"object\") {\n // console.log('process mode: Object mode');\n return JSONToCleanedText(motd as motdJsonType);\n } else if (typeof motd === \"string\") {\n // console.log('process mode: String mode');\n return cleanCodes(motd);\n } else {\n return \"unknown motd data type\";\n }\n}\n\n\n\nexport default autoCleanToText;\n","/*\n * minecraft motd parser\n * (c) 2021 Kevin Zheng\n * Released under the MIT license\n */\nimport {\n htmlStringFormatting,\n cleanCodes,\n cleanHtmlTags,\n} from \"./utils\";\nimport {\n JSONToHTML,\n JSONToCleanedText,\n\n textToHTML,\n textToJSON,\n\n JSONRender,\n autoToHTML,\n autoCleanToText,\n} from \"./parser\";\n\n\n\n\n\n\nexport * from './utils';\nexport * from \"./parser\";\n\n\n\n/*\n * #### minecraft motd parser\n * * [github](https://github.com/SnowFireWolf/minecraft-motd-parser/tree/main#minecraft-server-motd-parser)\n * * [npm](https://www.npmjs.com/package/@sfirew/minecraft-motd-parser)\n *\n * (c) 2021 Kevin Zheng\n *\n * Released under the MIT license\n */\nconst motdParser = {\n // --- normal format ---\n // text convert to HTML\n textToHTML,\n // text convert to JSON\n textToJSON,\n // JSON convert to HTML\n JSONToHTML,\n // JSON string to JSON object and convert to HTML\n JSONRender,\n // auto check type to convert\n autoToHTML,\n\n // --- utils ---\n // html string formatter\n htmlStringFormatting,\n // clean all motd codes\n cleanCodes,\n // clean all html tags\n cleanHtmlTags,\n // json to not html text\n JSONToCleanedText,\n // auto check type and convert to cleaned text\n autoCleanToText,\n};\n\nexport default motdParser;\n"],"mappings":"yVAYO,SAASA,EAAeC,EAAwC,CACrE,MAAO,CAAC,CAACA,CACX,CAQO,SAASC,EAAqBC,EAAsB,CACzD,OACEA,EAIG,QAAQ,KAAM,OAAO,EACrB,QAAQ,KAAM,MAAM,EACpB,QAAQ,KAAM,MAAM,EACpB,QAAQ,KAAM,QAAQ,EACtB,QAAQ,KAAM,OAAO,EAErB,QAAQ,MAAO,OAAO,CAG7B,CAYO,SAASC,EAAcD,EAAsB,CAClD,OAAOA,EAAK,QAAQ,aAAc,EAAE,CACtC,CAWO,SAASE,EAAWF,EAAc,CACvC,IAAMG,EAAQ,mCACVC,EAAa,GAEjB,OAAAA,EAAaJ,EAAK,QAAQG,EAAO,EAAE,EAE5BC,CACT,CChEA,IAAMC,EAA2B,CAC/B,QAAM,cACN,QAAM,qBACN,QAAM,iCACN,QAAM,8BACN,QAAM,sBACN,QAAM,4GACR,EAGMC,EAAoC,CACxC,KAAM,qBACN,OAAQ,sBACR,WAAY,6BACZ,cAAe,iCACf,WAAY,iBACZ,MAAO,4GACT,EAGMC,EAAqC,CACzC,QAAM,aACN,QAAM,OACN,QAAM,gBACN,QAAM,aACN,QAAM,SACN,QAAM,OACR,EAGMC,EAAmC,CACvC,QAAM,UACN,QAAM,UACN,QAAM,UACN,QAAM,UACN,QAAM,UACN,QAAM,UACN,QAAM,UACN,QAAM,UACN,QAAM,UACN,QAAM,UACN,QAAM,UACN,QAAM,UACN,QAAM,UACN,QAAM,UACN,QAAM,UACN,QAAM,SACR,EAGMC,EAAqC,CACzC,MAAO,UACP,UAAW,UACX,WAAY,UACZ,UAAW,UACX,SAAU,UACV,YAAa,UACb,KAAM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,CAGxC,CAAC,EAEDK,EAAS,KAAKN,EAAa,MAAM,CAAC,CAAiB,GAMvDM,EAAWA,EAAS,OAAQL,GAASA,EAAK,OAAS,EAAE,EAG9C,CACL,KAAMD,EAAa,KACnB,MAAOM,CACT,CACF,CCzGO,SAASG,EAAWC,EAAc,CACvC,OAAOC,EAAWD,CAAoB,CACxC,CAKO,SAASE,EAAWC,EAA+B,CAExD,OAAI,OAAOA,GAAS,SAEXJ,EAAWI,CAAI,EACb,OAAOA,GAAS,SAGlBC,EAAWD,CAAI,EAGf,wBAEX,CClBO,SAASE,EAAgBC,EAA+B,CAE7D,OAAI,OAAOA,GAAS,SAEXC,EAAkBD,CAAoB,EACpC,OAAOA,GAAS,SAElBE,EAAWF,CAAI,EAEf,wBAEX,CAIA,IAAOG,EAAQJ,ECef,IAAMK,EAAa,CAGjB,WAAAC,EAEA,WAAAC,EAEA,WAAAC,EAEA,WAAAC,EAEA,WAAAC,EAIA,qBAAAC,EAEA,WAAAC,EAEA,cAAAC,EAEA,kBAAAC,EAEA,gBAAAC,CACF,EAEOC,GAAQX","names":["isMotdJSONType","object","htmlStringFormatting","text","cleanHtmlTags","cleanCodes","REGEX","textResult","extras","extraFontStyles","textToJsonExtras","colorCodeToHex","extraColorsToHex","textToHTML","motdString","motdText","colorCodeReg","codeREGEX","codeSplit","item","fontStyle","colorHex","resultHTML","motdStringToLowerCase","colorCodeToHex","extras","resultColor","textContent","htmlStringFormatting","parseJSONToHTML","sourceJson","htmlElement","colorStyle","fontStyle","key","extraFontStyles","colorKey","colorHex","extraColorsToHex","colorCodeToHex","textToHTML","sourceJsonExtra","isMotdJSONType","currentText","returnHTML","JSONToCleanedText","sourceJson","textString","key","cleanCodes","sourceJsonExtra","isMotdJSONType","currentText","parseTextToJSON","text","motdText","colorCodeReg","codeREGEX","textSplit","fontStyle","colorHex","resultObject","item","stringToLowerCase","colorCodeToHex","textToJsonExtras","innerObject","newExtra","index","__spreadValues","JSONRender","json","parseJSONToHTML","autoToHTML","motd","textToHTML","autoCleanToText","motd","JSONToCleanedText","cleanCodes","autoCleanToText_default","motdParser","textToHTML","parseTextToJSON","parseJSONToHTML","JSONRender","autoToHTML","htmlStringFormatting","cleanCodes","cleanHtmlTags","JSONToCleanedText","autoCleanToText_default","index_default"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sfirew/minecraft-motd-parser",
3
3
  "description": "Minecraft Server MOTD Parser, can convert to html, json, text.",
4
- "version": "1.1.3",
4
+ "version": "1.1.4",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "types/index.d.ts",
@@ -33,7 +33,7 @@
33
33
  "prettier": "^2.7.1",
34
34
  "ts-jest": "^29.2.2",
35
35
  "ts-node": "^10.9.2",
36
- "tsup": "^8.1.0",
36
+ "tsup": "^8.4.0",
37
37
  "typescript": "^5.5.3"
38
38
  },
39
39
  "repository": "https://github.com/SnowFireWolf/minecraft-motd-parser.git",