@sfirew/minecraft-motd-parser 1.1.3 → 1.1.5-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,307 +1,211 @@
1
1
  # Minecraft Server MOTD Parser
2
+
2
3
  ![Version](https://img.shields.io/github/languages/top/SnowFireWolf/minecraft-motd-parser?style=for-the-badge)
3
4
  [![npm version](https://img.shields.io/npm/v/@sfirew/minecraft-motd-parser?label=version&style=for-the-badge)](https://www.npmjs.com/package/@sfirew/minecraft-motd-parser?style=for-the-badge)
4
5
  [![License](https://img.shields.io/npm/l/minecraft-server-util?style=for-the-badge)](https://github.com/SnowFireWolf/minecraft-motd-parser/blob/master/LICENSE)
5
6
  ![npm weekly downloads](https://img.shields.io/npm/dw/@sfirew/minecraft-motd-parser?style=for-the-badge)
6
7
 
8
+ A powerful and lightweight library to parse Minecraft server MOTD (Message of the Day) data into various formats.
9
+
10
+
11
+
12
+ ## Table of Contents
7
13
 
14
+ - [Features](#features)
15
+ - [Installation](#installation)
16
+ - [Quick Start](#quick-start)
17
+ - [API Reference](#api-reference)
18
+ - [Auto Detection](#auto-detection)
19
+ - [Text Parsing](#text-parsing)
20
+ - [JSON Parsing](#json-parsing)
21
+ - [Clean Text](#clean-text)
22
+ - [Examples](#examples)
23
+ - [Visual Examples](#visual-examples)
24
+ - [Contributing](#contributing)
8
25
 
9
- ## Introduction
10
- This package support **CommonJS**, **ES Module**, and **tree shaking**
11
26
 
12
- Can convert minecraft server MOTD data to text, json, html, and clean codes.
13
27
 
14
- Support **1.16** custom **hex color**, and auto check motd data type.
28
+ ## Features
15
29
 
16
- Don't have other dependencies.
30
+ **Zero Dependencies** - Lightweight and fast
31
+ 🔄 **Auto Detection** - Automatically detects MOTD data type
32
+ 🎨 **Multiple Formats** - Convert to HTML, JSON, or clean text
33
+ 🌈 **Full Color Support** - Including Minecraft 1.16+ hex colors
34
+ 📦 **Module Support** - CommonJS, ES Modules, and tree shaking
35
+ 🎯 **TypeScript Ready** - Full TypeScript support
17
36
 
18
37
 
19
38
 
20
39
  ## Installation
21
- choose your favorite package manager
40
+
41
+ Choose your favorite package manager:
42
+
22
43
  ```bash
23
44
  # npm
24
- $ npm install @sfirew/minecraft-motd-parser
45
+ npm install @sfirew/minecraft-motd-parser
25
46
 
26
47
  # yarn
27
- $ yarn add @sfirew/minecraft-motd-parser
48
+ yarn add @sfirew/minecraft-motd-parser
28
49
 
29
50
  # pnpm
30
- $ pnpm add @sfirew/minecraft-motd-parser
51
+ pnpm add @sfirew/minecraft-motd-parser
31
52
  ```
32
53
 
33
54
 
34
55
 
35
- ## Usage
36
- ### CommonJS
37
- ```typescript
38
- const { autoToHTML } = require('@sfirew/minecraft-motd-parser');
39
- ```
56
+ ## Quick Start
40
57
 
41
58
  ### ES6 Modules
42
59
  ```typescript
43
60
  import { autoToHTML } from '@sfirew/minecraft-motd-parser'
61
+
62
+ const motd = "§aHypixel Network §7§c1.8/1.9/1.10/1.11/1.12 §e§lNEW PTL GAME:§b§l THE BRIDGE";
63
+ const html = autoToHTML(motd);
64
+ console.log(html);
44
65
  ```
45
66
 
46
- ### Simple use example
67
+ ### CommonJS
47
68
  ```typescript
48
- import { autoToHTML as motdParser } from '@sfirew/minecraft-motd-parser'
49
- // or
50
- import motdParser from '@sfirew/minecraft-motd-parser'
51
- // motdParser.autoToHTML('motdString...');
52
-
53
- const hypixelMotdString = "§aHypixel Network §7§c1.8/1.9/1.10/1.11/1.12 §e§lNEW PTL GAME:§b§l THE BRIDGE";
54
-
55
- console.log(motdParser(hypixelMotdString));
56
-
57
- /* result
58
- <span style="color:#55FF55;">Hypixel Network </span><span style="color:#FF5555;">1.8/1.9/1.10/1.11/1.12 </span><span style="color:#FFFF55;font-weight: bold;">NEW PTL GAME:</span><span style="color:#55FFFF;font-weight: bold;"> THE BRIDGE</span>
59
- */
69
+ const { autoToHTML } = require('@sfirew/minecraft-motd-parser');
60
70
  ```
61
71
 
72
+ ### Default Import
73
+ ```typescript
74
+ import motdParser from '@sfirew/minecraft-motd-parser'
75
+ motdParser.autoToHTML('motdString...');
76
+ ```
62
77
 
63
- ### Some good custom motd hex color servers
64
- The parser does not have the Minecraft font by default.
65
78
 
66
- #### Minecraft font example
67
- ![Image_2022_01_2022d-2022h_58___002](https://user-images.githubusercontent.com/14024836/149810729-71909ca5-5705-43cf-ab3c-bdd66db00b78.png)
68
79
 
69
- ![Image_2022_01_2022d-2022h_00___004](https://user-images.githubusercontent.com/14024836/149811040-5ddc35a0-38cf-4434-856a-968c94a4d6b4.png)
80
+ ## API Reference
70
81
 
71
- #### No Minecraft font
72
- ![Image_2022_01_2022d-2022h_04___003](https://user-images.githubusercontent.com/14024836/149811501-d1376d90-d9ad-4092-912a-de1f78fa42eb.png)
82
+ ### Auto Detection
73
83
 
74
- ![Image_2022_01_2022d-2022h_01___002](https://user-images.githubusercontent.com/14024836/149811151-d9270d63-aead-46f9-b496-c88eb3b00c72.png)
84
+ #### `autoToHTML(data: string | object): string`
85
+ Automatically detects the MOTD data type and converts it to HTML.
75
86
 
87
+ ```typescript
88
+ import { autoToHTML } from '@sfirew/minecraft-motd-parser'
76
89
 
77
- You can try server status view in my created service
78
- [https://mcsv.top/server/mc.hypixel.net](https://mcsv.top/server/mc.hypixel.net)
90
+ // Works with both text and JSON formats
91
+ const textMOTD = "§aHypixel Network §c1.8-1.19";
92
+ const jsonMOTD = { text: "", extra: [{ color: "green", text: "Hello World" }] };
79
93
 
94
+ console.log(autoToHTML(textMOTD));
95
+ console.log(autoToHTML(jsonMOTD));
96
+ ```
80
97
 
98
+ #### `autoCleanToText(data: string | object): string`
99
+ Automatically detects the MOTD data type and returns clean text without formatting codes.
81
100
 
82
- ## Example and main formatter
83
- Some examples here, you can use **TypeScript** or **JavaScript**.
101
+ ```typescript
102
+ import { autoCleanToText } from '@sfirew/minecraft-motd-parser'
84
103
 
104
+ const motd = "§aHypixel Network §c1.8-1.19";
105
+ console.log(autoCleanToText(motd)); // "Hypixel Network 1.8-1.19"
106
+ ```
85
107
 
108
+ ### Text Parsing
86
109
 
87
- ### `autoToHTML(string | object)`
88
- auto check MOTD data type then return same html result.
110
+ #### `textToHTML(text: string): string`
111
+ Converts MOTD text format to HTML.
89
112
 
90
113
  ```typescript
91
- import motdParser from '@sfirew/minecraft-motd-parser'
114
+ import { textToHTML } from '@sfirew/minecraft-motd-parser'
92
115
 
93
- let jsonExample = {
94
- "extra": [
95
- {
96
- "bold": true,
97
- "color": "gold",
98
- "text": "Viper "
99
- },
100
- {
101
- "color": "gray",
102
- "text": "┃ "
103
- },
104
- {
105
- "color": "yellow",
106
- "text": "Summer Sale"
107
- },
108
- {
109
- "color": "white",
110
- "text": " at "
111
- },
112
- {
113
- "color": "gold",
114
- "text": "store.vipermc.net\n"
115
- },
116
- {
117
- "color": "gray",
118
- "text": "► "
119
- },
120
- {
121
- "color": "yellow",
122
- "text": "EOTW "
123
- },
124
- {
125
- "color": "white",
126
- "text": "on "
127
- },
128
- {
129
- "color": "gold",
130
- "text": "Infernal"
131
- },
132
- {
133
- "color": "white",
134
- "text": " is this Thursday at "
135
- },
136
- {
137
- "color": "yellow",
138
- "text": "5PM ET"
139
- },
140
- {
141
- "color": "white",
142
- "text": "."
143
- }
144
- ],
145
- "text": ""
146
- };
147
- let autoJsonResult = motdParser.autoToHTML(jsonExample);
148
- console.log(autoJsonResult);
149
-
150
- /* auto JSON Result, callback HTML:
151
- <span style="color: #FFAA00;font-weight: bold;">Viper </span><span style="color: #AAAAAA;">┃ </span><span style="color: #FFFF55;">Summer Sale</span><span style="color: #FFFFFF;"> at </span><span style="color: #FFAA00;">store.vipermc.net<br/></span><span style="color: #AAAAAA;">► </span><span style="color: #FFFF55;">EOTW </span><span style="color: #FFFFFF;">on </span><span style="color: #FFAA00;">Infernal</span><span style="color: #FFFFFF;"> is this Thursday at </span><span style="color: #FFFF55;">5PM ET</span><span style="color: #FFFFFF;">.</span>
152
- */
153
-
154
- let textExample = "§aHypixel Network §7§c1.8/1.9/1.10/1.11/1.12 §e§lNEW PTL GAME:§b§l THE BRIDGE";
155
- let autoTextResult = motdParser.autoToHTML(textExample);
156
- console.log(autoTextResult);
157
-
158
- /* auto Text Result, callback HTML:
159
- <span style="color: #55FF55;">Hypixel Network <span style="color: #AAAAAA;"><span style="color: #FF5555;">1.8/1.9/1.10/1.11/1.12 <span style="color: #FFFF55;"><span style="font-weight: bold;">NEW PTL GAME:<span style="color: acqua;"><span style="font-weight: bold;"> THE BRIDGE</span></span></span></span></span></span></span>
160
- */
116
+ const motd = "§aGreen §lBold §rReset §cRed";
117
+ const html = textToHTML(motd);
118
+ // Output: <span style="color:#55FF55;">Green <span style="font-weight:bold;">Bold </span></span><span style="color:#FF5555;">Red</span>
161
119
  ```
162
120
 
121
+ #### `textToJSON(text: string): object`
122
+ Converts MOTD text format to JSON structure.
163
123
 
124
+ ```typescript
125
+ import { textToJSON } from '@sfirew/minecraft-motd-parser'
164
126
 
127
+ const motd = "§aHello §bWorld";
128
+ const json = textToJSON(motd);
129
+ console.log(json);
130
+ ```
165
131
 
132
+ ### JSON Parsing
166
133
 
134
+ #### `JSONToHTML(json: object): string`
135
+ Converts MOTD JSON format to HTML.
167
136
 
168
- ## clean codes formatter
169
- ### `cleanCodes(string)`
170
- clean motd text color codes.
171
137
  ```typescript
172
- import motdParser from '@sfirew/minecraft-motd-parser'
173
- import { cleanCodes } from '@sfirew/minecraft-motd-parser'
138
+ import { JSONToHTML } from '@sfirew/minecraft-motd-parser'
174
139
 
175
- const motdText = "§aHypixel Network §7§c1.8/1.9/1.10/1.11/1.12 §e§lNEW PTL GAME:§b§l THE BRIDGE";
176
- const result = cleanCodes(motdText);
177
- console.log(result);
140
+ const motdJson = {
141
+ text: "",
142
+ extra: [
143
+ { color: "green", text: "Hello " },
144
+ { color: "blue", text: "World", bold: true }
145
+ ]
146
+ };
178
147
 
179
- /* result, callback Text:
180
- * Hypixel Network 1.8/1.9/1.10/1.11/1.12 NEW PTL GAME: THE BRIDGE
181
- */
148
+ const html = JSONToHTML(motdJson);
182
149
  ```
183
150
 
151
+ ### Clean Text
184
152
 
153
+ #### `cleanCodes(text: string): string`
154
+ Removes all formatting codes from MOTD text.
185
155
 
186
- ### `autoCleanToText(string | object)`
187
- auto check MOTD data type then return same cleaned text.
188
156
  ```typescript
189
- import motdParser from '@sfirew/minecraft-motd-parser'
190
- import { autoCleanToText } from '@sfirew/minecraft-motd-parser'
191
-
192
- const motdText = "§aHypixel Network §7§c1.8/1.9/1.10/1.11/1.12 §e§lNEW PTL GAME:§b§l THE BRIDGE";
193
- const result = autoCleanToText(motdText);
194
- console.log(result);
157
+ import { cleanCodes } from '@sfirew/minecraft-motd-parser'
195
158
 
196
- /* result, callback Text:
197
- * Hypixel Network 1.8/1.9/1.10/1.11/1.12 NEW PTL GAME: THE BRIDGE
198
- */
159
+ const motd = "§aHypixel Network §c1.8-1.19";
160
+ const clean = cleanCodes(motd);
161
+ console.log(clean); // "Hypixel Network 1.8-1.19"
199
162
  ```
200
163
 
201
164
 
202
165
 
166
+ ## Examples
203
167
 
168
+ ### Complex MOTD with Multiple Formats
204
169
 
205
-
206
- ## origin formatter
207
- ### `textToHTML(string)`
208
- convert motd text to html.
209
170
  ```typescript
210
- let motdText = "§aHypixel Network §7§c1.8/1.9/1.10/1.11/1.12 §e§lNEW PTL GAME:§b§l THE BRIDGE";
211
- let result = motdParser.textToHTML(motdText);
212
- console.log(result);
171
+ import motdParser from '@sfirew/minecraft-motd-parser'
213
172
 
214
- /* result, callback HTML:
215
- * <span style="color: #55FF55;">Hypixel Network <span style="color: #AAAAAA;"><span style="color: #FF5555;">1.8/1.9/1.10/1.11/1.12 <span style="color: #FFFF55;"><span style="font-weight: bold;">NEW PTL GAME:<span style="color: acqua;"><span style="font-weight: bold;"> THE BRIDGE</span></span></span></span></span></span></span>
216
- */
173
+ // Text format example
174
+ const textExample = "§aHypixel Network §7§c1.8/1.9/1.10/1.11/1.12 §e§lNEW PTL GAME:§b§l THE BRIDGE";
175
+ console.log(motdParser.autoToHTML(textExample));
176
+
177
+ // JSON format example
178
+ const jsonExample = {
179
+ "text": "",
180
+ "extra": [
181
+ { "bold": true, "color": "gold", "text": "Viper " },
182
+ { "color": "gray", "text": "┃ " },
183
+ { "color": "yellow", "text": "Summer Sale" },
184
+ { "color": "white", "text": " at " },
185
+ { "color": "gold", "text": "store.vipermc.net\n" }
186
+ ]
187
+ };
188
+ console.log(motdParser.autoToHTML(jsonExample));
217
189
  ```
218
190
 
219
- ![Image_2021_08_2021d-2021h_23___001](https://user-images.githubusercontent.com/14024836/129277576-e94914f3-35f7-45a6-8ba3-58163f71d5a1.png)
191
+ ## Visual Examples
220
192
 
193
+ The parser supports rich formatting including colors, bold, italic, underline, and strikethrough text.
221
194
 
195
+ ### With Minecraft Font
196
+ ![Minecraft Font Example](https://user-images.githubusercontent.com/14024836/149810729-71909ca5-5705-43cf-ab3c-bdd66db00b78.png)
222
197
 
198
+ ### Standard Font
199
+ ![Standard Font Example](https://user-images.githubusercontent.com/14024836/149811501-d1376d90-d9ad-4092-912a-de1f78fa42eb.png)
223
200
 
224
- ### `textToJSON(string)`
225
- convert motd json to html.
226
- ```typescript
227
- let motdText = "§aHypixel Network §7§c1.8/1.9/1.10/1.11/1.12 §e§lNEW PTL GAME:§b§l THE BRIDGE";
228
- let result = motdParser.textToJSON(motdText);
229
- console.log(result);
201
+ > **Try it live**: Check out the [Minecraft Server Status Viewer](https://mcsv.top/server/mc.hypixel.net) to see the parser in action.
230
202
 
231
- /* result, callback JSON:
232
- {
233
- text: '',
234
- extra: [
235
- { text: '', extra: [] },
236
- { text: 'Hypixel Network ', extra: [], color: '#55FF55' },
237
- { text: '', extra: [], color: '#AAAAAA' },
238
- { text: '1.8/1.9/1.10/1.11/1.12 ', extra: [], color: '#FF5555' },
239
- { text: '', extra: [], color: '#FFFF55' },
240
- { text: 'NEW PTL GAME:', extra: [], bold: true, color: '#FFFF55' },
241
- { text: '', extra: [], bold: true, color: '#55FFFF' },
242
- { text: ' THE BRIDGE', extra: [], bold: true, color: '#55FFFF' }
243
- ]
244
- }
245
- */
246
- ```
203
+ ## Contributing
247
204
 
205
+ Contributions are welcome! Please feel free to submit a Pull Request.
248
206
 
249
- ### `JSONToHTML(object)`
250
- convert text to motd json.
251
- ```typescript
252
- let mcfalloutJson = {
253
- "extra": [
254
- {
255
- "color": "gray",
256
- "text": " "
257
- },
258
- {
259
- "color": "gold",
260
- "text": "廢土伺服器 "
261
- },
262
- {
263
- "color": "white",
264
- "text": "mcFallout.net"
265
- },
266
- {
267
- "color": "dark_gray",
268
- "text": " - "
269
- },
270
- {
271
- "color": "gray",
272
- "text": "版本 1.17.1 "
273
- },
274
- {
275
- "color": "gold",
276
- "text": "洞穴"
277
- },
278
- {
279
- "color": "light_purple",
280
- "text": "與"
281
- },
282
- {
283
- "color": "aqua",
284
- "text": "山崖\n"
285
- },
286
- {
287
- "color": "gray",
288
- "text": " "
289
- },
290
- {
291
- "color": "dark_gray",
292
- "text": "享受工廠、農場、建築與紅石"
293
- }
294
- ],
295
- "text": ""
296
- }
297
- let result = motdParser.JSONToHTML(mcfalloutJson);
298
- console.log(result)
299
-
300
- /* result, callback HTML:
301
- <span style="color: #AAAAAA;">  </span><span style="color: #FFAA00;">廢土伺服器  </span><span style="color: #FFFFFF;">mcFallout.net</span><span style="color: #555555;"> - </span><span style="color: #AAAAAA;">版本 1.17.1 </span><span style="color: #FFAA00;">洞穴</span><span style="color: #FF55FF;">與</span><span style="color: #55FFFF;">山崖<br/></span><span style="color: #AAAAAA;">  </span><span style="color: #555555;">享受工廠、農場、建築與紅石</span>
302
- */
303
- ```
207
+ ## License
304
208
 
305
- ![Image_2021_08_2021d-2021h_24___001](https://user-images.githubusercontent.com/14024836/129277638-fe8c5735-54fe-4ff1-afc5-4b5493706be9.png)
209
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
306
210
 
307
211
 
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 S=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames,k=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;var j=(t,e,o)=>e in t?S(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,L=(t,e)=>{for(var o in e||(e={}))R.call(e,o)&&j(t,o,e[o]);if(k)for(var o of k(e))X.call(e,o)&&j(t,o,e[o]);return t};var K=(t,e)=>{for(var o in e)S(t,o,{get:e[o],enumerable:!0})},$=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of _(e))!R.call(t,n)&&n!==o&&S(t,n,{get:()=>e[n],enumerable:!(s=J(e,n))||s.enumerable});return t};var G=t=>$(S({},"__esModule",{value:!0}),t);var I={};K(I,{JSONRender:()=>b,JSONToCleanedText:()=>y,JSONToHTML:()=>g,autoCleanToText:()=>C,autoToHTML:()=>O,baseColorCodeRegex:()=>u,cleanCodes:()=>m,cleanHtmlTags:()=>w,default:()=>B,htmlStringFormatting:()=>A,isMotdJSONType:()=>F,textToHTML:()=>x,textToJSON:()=>h});module.exports=G(I);var u=/([§][0-9a-fA-FklmnorKLMNOR])/g;function F(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e="text"in t,o="translate"in t,s="extra"in t&&Array.isArray(t.extra);return e||o||s}function A(t){return!t||typeof t!="string"?"":t.replace(/&(?!(?:amp|lt|gt|quot|#39|#x[0-9A-Fa-f]+|#[0-9]+);)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/\n/g,"<br/>")}function w(t){if(!t||typeof t!="string")return"";let e="",o=new Set(["script","style","noscript","iframe","object","embed","applet","svg","math","foreignobject"]),s;(T=>(T[T.TEXT=0]="TEXT",T[T.TAG=1]="TAG",T[T.SKIP_BLOCK=2]="SKIP_BLOCK",T[T.COMMENT=3]="COMMENT"))(s||(s={}));let n=0,l="",f="",a=t.length;for(let r=0;r<a;r++){let p=t[r];if(n===0&&p==="<"){if(t.slice(r,r+4)==="<!--"){n=3;continue}let i=r+1,c=!1;for(i<a&&t[i]==="/"&&(c=!0,i++);i<a&&/\s/.test(t[i]);)i++;let T=i;for(;i<a&&/[A-Za-z0-9-]/.test(t[i]);)i++;l=t.slice(T,i).toLowerCase(),!c&&o.has(l)?(n=2,f=`</${l}>`):n=1;continue}if(n===1){p===">"&&(n=0);continue}if(n===3){t.slice(r,r+3)==="-->"&&(r+=2,n=0);continue}if(n===2){p==="<"&&t.slice(r,r+f.length).toLowerCase()===f&&(r+=f.length-1,n=0);continue}n===0&&(e+=p)}return e.trim()}function m(t){let e=/(?:§)([0-9a-fA-FklmnorFKLMNOR])/g,o="";return o=t.replace(e,""),o}var E={"\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;"},M={"\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"},N={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 x(t){let e=u,o=new RegExp(e.source),s=t.split(o).filter(a=>a!==""),n="",l="",f="";return s.forEach(a=>{let r=a.toLowerCase();if(Object.hasOwn(d,r))l=d[r],r==="\xA7f"&&(n="");else if(Object.hasOwn(E,r))r==="\xA7r"?(l="",n=""):n+=E[r];else{let p="",i=a;l!==""&&(p=`color:${l};`),i!==""&&(i=A(i),p.length!==0||n.length!==0?f+=`<span style="${p}${n}">${i}</span>`:f+=i)}}),f}function g(t){let e="",o="",s="";for(let l of Object.keys(t)){if(l=l.toLowerCase(),Object.hasOwn(H,l)&&t[l]&&(s+=String(H[l])),l==="color"){let f=t[l],a="";if(typeof f=="string")if(Object.hasOwn(N,f))a=N[f];else if(Object.hasOwn(d,f))a=d[f];else{let r=f.match(/^#([-+]?0+|\+?0*[1-9A-Fa-f][0-9A-Fa-f]{0,5})$/);r!==null&&(a="#"+r[1].replace(/^[-+]?0*/,"").padStart(6,"0"))}a!==""&&(o=`color:${a};`)}if(l==="extra"&&typeof t.extra=="object"){(typeof t.text=="string"||typeof t.text=="number")&&(e+=x(String(t.text)));for(let f of t.extra)typeof f=="string"?e+=x(f):F(f)&&(e+=g(f))}}if(t.extra===void 0&&t.text!==void 0){let l=t.text;(typeof t.text=="string"||typeof t.text=="number")&&(e+=x(String(l)))}let n="";return s.length!==0||o.length!==0?n=`<span style="${o+s}">${e}</span>`:n=e,n}function y(t){let e="";for(let o of Object.keys(t))if(o=o.toLowerCase(),o==="extra"&&typeof t.extra=="object"){(typeof t.text=="string"||typeof t.text=="number")&&(e+=m(String(t.text)));for(let s of t.extra)typeof s=="string"?e+=m(s):F(s)&&(e+=y(s))}if(t.extra===void 0&&t.text!==void 0){let o=t.text;(typeof t.text=="string"||typeof t.text=="number")&&(e+=m(String(o)))}return e}function h(t){let e=t,o=u,s=new RegExp(o.source),n=e.split(s),l="",f="",a={text:"",extra:[]};n.forEach(p=>{let i=p.toLowerCase();if(Object.hasOwn(d,i))f=d[i],i==="\xA7f"&&(l="");else if(Object.hasOwn(M,i))i==="\xA7r"?(l="",f=""):l=M[i];else{let c={text:"",extra:[]};l!==""&&(c[l]=!0),c.text=p,f!==""&&(c.color=f),typeof a.extra=="object"&&a.extra.push(c)}});let r=[];return a.extra&&(a.extra.length>1?a.extra.forEach((p,i)=>{var c;p.text===""?a.extra&&typeof a.extra[i+1]=="object"&&r.push(L(L({},p),a.extra[i+1])):p.text!==((c=r[r.length-1])==null?void 0:c.text)&&r.push(p)}):r.push(a.extra[0])),r=r.filter(p=>p.text!==""),{text:a.text,extra:r}}function b(t){return g(t)}function O(t){return typeof t=="object"?b(t):typeof t=="string"?x(t):"unknown motd data type"}function q(t){return typeof t=="object"?y(t):typeof t=="string"?m(t):"unknown motd data type"}var C=q;var P={textToHTML:x,textToJSON:h,JSONToHTML:g,JSONRender:b,autoToHTML:O,htmlStringFormatting:A,cleanCodes:m,cleanHtmlTags:w,JSONToCleanedText:y,autoCleanToText:C},B=P;0&&(module.exports={JSONRender,JSONToCleanedText,JSONToHTML,autoCleanToText,autoToHTML,baseColorCodeRegex,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,gBAA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AAOM,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/**\n * Base color code regex\n */\nexport const baseColorCodeRegex = /([§][0-9a-fA-FklmnorKLMNOR])/g;\n\n\n\n// Type checking function\nexport function isMotdJSONType(object: unknown): object is motdJsonType {\n // basic type check\n if (!object || typeof object !== \"object\" || Array.isArray(object)) {\n return false;\n }\n\n // check if has necessary property\n const hasText = \"text\" in object;\n const hasTranslate = \"translate\" in object;\n const hasExtra = \"extra\" in object && Array.isArray(object.extra);\n\n // MOTD JSON at least need one of text, translate or extra\n return hasText || hasTranslate || hasExtra;\n}\n\n\n\n/**\n * Replace all HTML special characters with HTML entities\n * Prevents HTML injection by safely encoding special characters\n */\nexport function htmlStringFormatting(text: string): string {\n if (!text || typeof text !== \"string\") {\n return \"\";\n }\n\n return (\n text\n // First handle & character, but avoid breaking existing HTML entities\n // Use negative lookahead to prevent double-encoding existing HTML entities\n .replace(/&(?!(?:amp|lt|gt|quot|#39|#x[0-9A-Fa-f]+|#[0-9]+);)/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#39;\")\n // Convert newlines to HTML line breaks\n .replace(/\\n/g, \"<br/>\")\n );\n};\n\n\n\n/**\n * Clean HTML tags safely\n * \n * Safely removes HTML tags and prevents HTML injection vulnerabilities.\n * \n * @param text - Input text that may contain HTML tags\n * @example `<span>hello world</span>` → `hello world`\n * \n * @returns Clean text without HTML tags\n */\nexport function cleanHtmlTags(text: string): string {\n if (!text || typeof text !== \"string\") {\n return \"\";\n }\n\n let cleanedText = \"\";\n\n // === Config ===\n const DANGEROUS_TAGS = new Set([\n \"script\", \"style\", \"noscript\",\n \"iframe\", \"object\", \"embed\", \"applet\",\n \"svg\", \"math\", \"foreignobject\",\n ]);\n\n // === FSM States ===\n enum State {\n TEXT, // Normal text\n TAG, // Currently consuming a normal tag until >\n SKIP_BLOCK, // Currently skipping dangerous block until </tag>\n COMMENT // HTML comment <!-- ... -->\n }\n\n let state = State.TEXT;\n let tagName = \"\"; // Temporary storage for encountered tag name\n let skipUntil = \"\"; // Corresponding \"</tag>\" for dangerous block\n const len = text.length;\n\n for (let i = 0; i < len; i++) {\n const ch = text[i];\n\n /* --------------- TEXT -> TAG/COMMENT --------------- */\n if (state === State.TEXT && ch === \"<\") {\n // Check if it's an HTML comment\n if (text.slice(i, i + 4) === \"<!--\") {\n state = State.COMMENT;\n continue;\n }\n\n // Try to extract tag name\n let j = i + 1;\n let isClosing = false;\n\n // Skip '/'\n if (j < len && text[j] === \"/\") {\n isClosing = true;\n j++;\n }\n // Skip whitespace\n while (j < len && /\\s/.test(text[j])) j++;\n\n // Extract tagName (a~z or A~Z or 0-9 or -)\n const start = j;\n while (j < len && /[A-Za-z0-9-]/.test(text[j])) j++;\n\n tagName = text.slice(start, j).toLowerCase();\n\n /* Dangerous block ── only \"opening tag\" starts skip */\n if (!isClosing && DANGEROUS_TAGS.has(tagName)) {\n state = State.SKIP_BLOCK;\n skipUntil = `</${tagName}>`;\n } else {\n state = State.TAG;\n }\n continue;\n }\n\n /* --------------- TAG -> TEXT --------------- */\n if (state === State.TAG) {\n if (ch === \">\") state = State.TEXT;\n // Don't write to output\n continue;\n }\n\n /* --------------- COMMENT -> TEXT --------------- */\n if (state === State.COMMENT) {\n // Check for comment end -->\n if (text.slice(i, i + 3) === \"-->\") {\n i += 2; // Skip '-->'\n state = State.TEXT;\n }\n continue;\n }\n\n /* --------------- SKIP_BLOCK Logic --------------- */\n if (state === State.SKIP_BLOCK) {\n // Transition: SKIP_BLOCK -> TEXT\n // Check if the current segment matches the end tag (e.g., </script>)\n if (\n ch === \"<\" &&\n text.slice(i, i + skipUntil.length).toLowerCase() === skipUntil\n ) {\n // Skip the entire end tag (case-insensitive match)\n i += skipUntil.length - 1;\n state = State.TEXT; // Return to TEXT state\n }\n continue; // Consume all content until the end tag is found\n }\n\n /* --------------- TEXT State: Normal output --------------- */\n if (state === State.TEXT) {\n cleanedText += ch;\n }\n }\n\n return cleanedText.trim();\n}\n\n\n\n/**\n * Clean MOTD color codes\n * \n * Clean all formatting codes from MOTD source string.\n * \n * @param {string} text - MOTD string with § formatting codes to be removed\n * @returns {string} Text without MOTD formatting codes\n */\nexport function cleanCodes(text: string): 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 baseColorCodeRegex,\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 colorCodeReg = baseColorCodeRegex;\n const codeREGEX = new RegExp(colorCodeReg.source);\n const codeSplit = motdString.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 += String(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 const customHexColorMatches = colorKey.match(\n /^#([-+]?0+|\\+?0*[1-9A-Fa-f][0-9A-Fa-f]{0,5})$/,\n );\n\n if (customHexColorMatches !== null) {\n // custom hex color code mode\n colorHex =\n \"#\" +\n customHexColorMatches[1].replace(/^[-+]?0*/, \"\").padStart(6, \"0\");\n }\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 (typeof sourceJson.text === \"string\" || typeof sourceJson.text === \"number\") {\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 (typeof sourceJson.text === \"string\" || typeof sourceJson.text === \"number\") {\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\";\nimport { baseColorCodeRegex } from \"../utils\";\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 const colorCodeReg = baseColorCodeRegex;\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: 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]?.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,uBAAAC,EAAA,eAAAC,EAAA,kBAAAC,EAAA,YAAAC,EAAA,yBAAAC,EAAA,mBAAAC,EAAA,eAAAC,EAAA,eAAAC,IAAA,eAAAC,EAAAf,GCcO,IAAMgB,EAAqB,gCAK3B,SAASC,EAAeC,EAAyC,CAEtE,GAAI,CAACA,GAAU,OAAOA,GAAW,UAAY,MAAM,QAAQA,CAAM,EAC/D,MAAO,GAIT,IAAMC,EAAU,SAAUD,EACpBE,EAAe,cAAeF,EAC9BG,EAAW,UAAWH,GAAU,MAAM,QAAQA,EAAO,KAAK,EAGhE,OAAOC,GAAWC,GAAgBC,CACpC,CAQO,SAASC,EAAqBC,EAAsB,CACzD,MAAI,CAACA,GAAQ,OAAOA,GAAS,SACpB,GAIPA,EAGG,QAAQ,uDAAwD,OAAO,EACvE,QAAQ,KAAM,MAAM,EACpB,QAAQ,KAAM,MAAM,EACpB,QAAQ,KAAM,QAAQ,EACtB,QAAQ,KAAM,OAAO,EAErB,QAAQ,MAAO,OAAO,CAE7B,CAcO,SAASC,EAAcD,EAAsB,CAClD,GAAI,CAACA,GAAQ,OAAOA,GAAS,SAC3B,MAAO,GAGT,IAAIE,EAAc,GAGZC,EAAiB,IAAI,IAAI,CAC7B,SAAU,QAAS,WACnB,SAAU,SAAU,QAAS,SAC7B,MAAO,OAAQ,eACjB,CAAC,EAGIC,OACHA,IAAA,eACAA,IAAA,a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EA,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","baseColorCodeRegex","cleanCodes","cleanHtmlTags","index_default","htmlStringFormatting","isMotdJSONType","textToHTML","parseTextToJSON","__toCommonJS","baseColorCodeRegex","isMotdJSONType","object","hasText","hasTranslate","hasExtra","htmlStringFormatting","text","cleanHtmlTags","cleanedText","DANGEROUS_TAGS","State","state","tagName","skipUntil","len","i","ch","j","isClosing","start","cleanCodes","REGEX","textResult","extras","extraFontStyles","textToJsonExtras","colorCodeToHex","extraColorsToHex","textToHTML","motdString","colorCodeReg","baseColorCodeRegex","codeREGEX","codeSplit","item","fontStyle","colorHex","resultHTML","motdStringToLowerCase","colorCodeToHex","extras","resultColor","textContent","htmlStringFormatting","parseJSONToHTML","sourceJson","htmlElement","colorStyle","fontStyle","key","extraFontStyles","colorKey","colorHex","extraColorsToHex","colorCodeToHex","customHexColorMatches","textToHTML","sourceJsonExtra","isMotdJSONType","currentText","returnHTML","JSONToCleanedText","sourceJson","textString","key","cleanCodes","sourceJsonExtra","isMotdJSONType","currentText","parseTextToJSON","text","motdText","colorCodeReg","baseColorCodeRegex","codeREGEX","textSplit","fontStyle","colorHex","resultObject","item","stringToLowerCase","colorCodeToHex","textToJsonExtras","innerObject","newExtra","index","_a","__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"]}