@necrolab/dashboard 0.4.3

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.
Files changed (240) hide show
  1. package/.claude/settings.local.json +45 -0
  2. package/.eslintrc.js +24 -0
  3. package/.prettierignore +1 -0
  4. package/.prettierrc +10 -0
  5. package/.vscode/extensions.json +3 -0
  6. package/ICONS.md +21 -0
  7. package/README.md +65 -0
  8. package/backend/api.js +430 -0
  9. package/backend/auth.js +62 -0
  10. package/backend/batching.js +43 -0
  11. package/backend/endpoints.js +343 -0
  12. package/backend/index.js +23 -0
  13. package/backend/mock-data.js +66 -0
  14. package/backend/mock-src/classes/logger.js +112 -0
  15. package/backend/mock-src/classes/utils.js +42 -0
  16. package/backend/mock-src/ticketmaster.js +92 -0
  17. package/backend/validator.js +62 -0
  18. package/config/configs.json +20 -0
  19. package/config/filter.json +3 -0
  20. package/config/presale.csv +3 -0
  21. package/config/proxies.txt +6 -0
  22. package/config/used-codes.json +4 -0
  23. package/index.html +114 -0
  24. package/index.js +2 -0
  25. package/jsconfig.json +16 -0
  26. package/package.json +48 -0
  27. package/postcss.config.js +6 -0
  28. package/postinstall.js +9 -0
  29. package/public/android-chrome-192x192.png +0 -0
  30. package/public/android-chrome-512x512.png +0 -0
  31. package/public/apple-touch-icon.png +0 -0
  32. package/public/favicon-16x16.png +0 -0
  33. package/public/favicon-32x32.png +0 -0
  34. package/public/favicon.ico +0 -0
  35. package/public/flags/ae.svg +1 -0
  36. package/public/flags/at.svg +1 -0
  37. package/public/flags/au.svg +1 -0
  38. package/public/flags/be.svg +1 -0
  39. package/public/flags/ch.svg +1 -0
  40. package/public/flags/cz.svg +1 -0
  41. package/public/flags/de.svg +1 -0
  42. package/public/flags/dk.svg +1 -0
  43. package/public/flags/es.svg +1 -0
  44. package/public/flags/nl.svg +1 -0
  45. package/public/flags/no.svg +1 -0
  46. package/public/flags/nz.svg +1 -0
  47. package/public/flags/pl.svg +1 -0
  48. package/public/flags/se.svg +1 -0
  49. package/public/flags/uk.svg +1 -0
  50. package/public/flags/us.svg +1 -0
  51. package/public/img/award.svg +3 -0
  52. package/public/img/background.svg +14 -0
  53. package/public/img/bag_w.svg +12 -0
  54. package/public/img/banks/amex.svg +4 -0
  55. package/public/img/banks/mastercard.svg +4 -0
  56. package/public/img/banks/visa.svg +4 -0
  57. package/public/img/camera.svg +3 -0
  58. package/public/img/close.svg +3 -0
  59. package/public/img/controls/disable.svg +5 -0
  60. package/public/img/controls/enable.svg +5 -0
  61. package/public/img/groups.svg +3 -0
  62. package/public/img/hand.svg +3 -0
  63. package/public/img/key.svg +3 -0
  64. package/public/img/logo.png +0 -0
  65. package/public/img/logo_icon.png +0 -0
  66. package/public/img/logo_icon_2.png +0 -0
  67. package/public/img/logo_trans.png +0 -0
  68. package/public/img/loyalty.svg +3 -0
  69. package/public/img/mail.svg +3 -0
  70. package/public/img/pencil.svg +3 -0
  71. package/public/img/profile.svg +4 -0
  72. package/public/img/reload.svg +3 -0
  73. package/public/img/sandclock.svg +25 -0
  74. package/public/img/save.svg +5 -0
  75. package/public/img/savings.svg +3 -0
  76. package/public/img/scanner.svg +3 -0
  77. package/public/img/sell.svg +3 -0
  78. package/public/img/shield.svg +3 -0
  79. package/public/img/ski.svg +3 -0
  80. package/public/img/stadium.svg +8 -0
  81. package/public/img/stadium_w.svg +8 -0
  82. package/public/img/timer.svg +3 -0
  83. package/public/manifest.json +27 -0
  84. package/public/robots.txt +2 -0
  85. package/run +10 -0
  86. package/src/App.vue +307 -0
  87. package/src/assets/css/_input.scss +197 -0
  88. package/src/assets/css/main.scss +269 -0
  89. package/src/assets/css/tailwind.css +3 -0
  90. package/src/assets/img/award.svg +3 -0
  91. package/src/assets/img/background.svg +11 -0
  92. package/src/assets/img/camera.svg +3 -0
  93. package/src/assets/img/close.svg +3 -0
  94. package/src/assets/img/eyes/closed.svg +13 -0
  95. package/src/assets/img/eyes/open.svg +12 -0
  96. package/src/assets/img/groups.svg +3 -0
  97. package/src/assets/img/hand.svg +3 -0
  98. package/src/assets/img/key.svg +3 -0
  99. package/src/assets/img/logo.png +0 -0
  100. package/src/assets/img/logo_icon.png +0 -0
  101. package/src/assets/img/logo_icon_2.png +0 -0
  102. package/src/assets/img/logo_trans.png +0 -0
  103. package/src/assets/img/loyalty.svg +3 -0
  104. package/src/assets/img/mail.svg +3 -0
  105. package/src/assets/img/pencil.svg +3 -0
  106. package/src/assets/img/reload.svg +3 -0
  107. package/src/assets/img/savings.svg +3 -0
  108. package/src/assets/img/scanner.svg +3 -0
  109. package/src/assets/img/sell.svg +3 -0
  110. package/src/assets/img/shield.svg +3 -0
  111. package/src/assets/img/ski.svg +3 -0
  112. package/src/assets/img/square_check.svg +5 -0
  113. package/src/assets/img/square_uncheck.svg +5 -0
  114. package/src/assets/img/stadium.svg +8 -0
  115. package/src/assets/img/timer.svg +3 -0
  116. package/src/assets/img/wildcard.svg +7 -0
  117. package/src/components/Auth/LoginForm.vue +48 -0
  118. package/src/components/Editors/Account/Account.vue +119 -0
  119. package/src/components/Editors/Account/AccountCreator.vue +147 -0
  120. package/src/components/Editors/Account/AccountView.vue +87 -0
  121. package/src/components/Editors/Account/CreateAccount.vue +106 -0
  122. package/src/components/Editors/Profile/CreateProfile.vue +321 -0
  123. package/src/components/Editors/Profile/Profile.vue +142 -0
  124. package/src/components/Editors/Profile/ProfileCountryChooser.vue +75 -0
  125. package/src/components/Editors/Profile/ProfileView.vue +96 -0
  126. package/src/components/Editors/TagLabel.vue +16 -0
  127. package/src/components/Editors/TagToggle.vue +41 -0
  128. package/src/components/Filter/Filter.vue +409 -0
  129. package/src/components/Filter/FilterPreview.vue +236 -0
  130. package/src/components/Filter/PriceSortToggle.vue +105 -0
  131. package/src/components/Table/Header.vue +5 -0
  132. package/src/components/Table/Row.vue +5 -0
  133. package/src/components/Table/Table.vue +14 -0
  134. package/src/components/Table/index.js +4 -0
  135. package/src/components/Tasks/CheckStock.vue +62 -0
  136. package/src/components/Tasks/Controls/DesktopControls.vue +73 -0
  137. package/src/components/Tasks/Controls/MobileControls.vue +32 -0
  138. package/src/components/Tasks/Controls/index.js +3 -0
  139. package/src/components/Tasks/CreateTaskAXS.vue +339 -0
  140. package/src/components/Tasks/CreateTaskTM.vue +459 -0
  141. package/src/components/Tasks/MassEdit.vue +50 -0
  142. package/src/components/Tasks/QuickSettings.vue +167 -0
  143. package/src/components/Tasks/ScrapeVenue.vue +42 -0
  144. package/src/components/Tasks/Stats.vue +66 -0
  145. package/src/components/Tasks/Task.vue +296 -0
  146. package/src/components/Tasks/TaskLabel.vue +20 -0
  147. package/src/components/Tasks/TaskView.vue +126 -0
  148. package/src/components/Tasks/Utilities.vue +33 -0
  149. package/src/components/icons/Award.vue +8 -0
  150. package/src/components/icons/Bag.vue +8 -0
  151. package/src/components/icons/BagWhite.vue +8 -0
  152. package/src/components/icons/Box.vue +8 -0
  153. package/src/components/icons/Camera.vue +8 -0
  154. package/src/components/icons/Cart.vue +8 -0
  155. package/src/components/icons/Check.vue +5 -0
  156. package/src/components/icons/Checkmark.vue +11 -0
  157. package/src/components/icons/Click.vue +8 -0
  158. package/src/components/icons/Close.vue +21 -0
  159. package/src/components/icons/CloseX.vue +5 -0
  160. package/src/components/icons/Console.vue +13 -0
  161. package/src/components/icons/Down.vue +8 -0
  162. package/src/components/icons/Edit.vue +13 -0
  163. package/src/components/icons/Event.vue +8 -0
  164. package/src/components/icons/Expand.vue +8 -0
  165. package/src/components/icons/Filter.vue +13 -0
  166. package/src/components/icons/Gear.vue +8 -0
  167. package/src/components/icons/Group.vue +8 -0
  168. package/src/components/icons/Hand.vue +8 -0
  169. package/src/components/icons/Key.vue +21 -0
  170. package/src/components/icons/Logout.vue +13 -0
  171. package/src/components/icons/Loyalty.vue +8 -0
  172. package/src/components/icons/Mail.vue +8 -0
  173. package/src/components/icons/Menu.vue +8 -0
  174. package/src/components/icons/Pause.vue +5 -0
  175. package/src/components/icons/Pencil.vue +21 -0
  176. package/src/components/icons/Play.vue +8 -0
  177. package/src/components/icons/Plus.vue +8 -0
  178. package/src/components/icons/Profile.vue +18 -0
  179. package/src/components/icons/Reload.vue +7 -0
  180. package/src/components/icons/Sandclock.vue +33 -0
  181. package/src/components/icons/Savings.vue +8 -0
  182. package/src/components/icons/Scanner.vue +8 -0
  183. package/src/components/icons/Scrape.vue +8 -0
  184. package/src/components/icons/Sell.vue +21 -0
  185. package/src/components/icons/Shield.vue +8 -0
  186. package/src/components/icons/Shrink.vue +8 -0
  187. package/src/components/icons/Ski.vue +8 -0
  188. package/src/components/icons/Spinner.vue +42 -0
  189. package/src/components/icons/SquareCheck.vue +18 -0
  190. package/src/components/icons/SquareUncheck.vue +18 -0
  191. package/src/components/icons/Stadium.vue +13 -0
  192. package/src/components/icons/StadiumWhite.vue +13 -0
  193. package/src/components/icons/Status.vue +8 -0
  194. package/src/components/icons/Tag.vue +8 -0
  195. package/src/components/icons/Tasks.vue +13 -0
  196. package/src/components/icons/Ticket.vue +8 -0
  197. package/src/components/icons/Timer.vue +8 -0
  198. package/src/components/icons/Trash.vue +8 -0
  199. package/src/components/icons/Up.vue +10 -0
  200. package/src/components/icons/Wildcard.vue +18 -0
  201. package/src/components/icons/index.js +111 -0
  202. package/src/components/ui/Modal.vue +61 -0
  203. package/src/components/ui/Navbar.vue +207 -0
  204. package/src/components/ui/ReconnectIndicator.vue +90 -0
  205. package/src/components/ui/Splash.vue +24 -0
  206. package/src/components/ui/controls/CountryChooser.vue +87 -0
  207. package/src/components/ui/controls/EyeToggle.vue +11 -0
  208. package/src/components/ui/controls/atomic/Checkbox.vue +28 -0
  209. package/src/components/ui/controls/atomic/Dropdown.vue +138 -0
  210. package/src/components/ui/controls/atomic/LoadingButton.vue +45 -0
  211. package/src/components/ui/controls/atomic/MultiDropdown.vue +262 -0
  212. package/src/components/ui/controls/atomic/Switch.vue +84 -0
  213. package/src/libs/Filter.js +593 -0
  214. package/src/libs/ansii.js +565 -0
  215. package/src/libs/panzoom.js +1413 -0
  216. package/src/main.js +23 -0
  217. package/src/registerServiceWorker.js +32 -0
  218. package/src/router/index.js +65 -0
  219. package/src/stores/cities.json +1 -0
  220. package/src/stores/connection.js +399 -0
  221. package/src/stores/countries.js +88 -0
  222. package/src/stores/logger.js +103 -0
  223. package/src/stores/requests.js +88 -0
  224. package/src/stores/sampleData.js +1034 -0
  225. package/src/stores/ui.js +584 -0
  226. package/src/stores/utils.js +554 -0
  227. package/src/types/index.js +42 -0
  228. package/src/utils/debug.js +1 -0
  229. package/src/views/Accounts.vue +191 -0
  230. package/src/views/Console.vue +224 -0
  231. package/src/views/Editor.vue +785 -0
  232. package/src/views/FilterBuilder.vue +785 -0
  233. package/src/views/Login.vue +27 -0
  234. package/src/views/Profiles.vue +209 -0
  235. package/src/views/Tasks.vue +157 -0
  236. package/static/offline.html +184 -0
  237. package/tailwind.config.js +57 -0
  238. package/vite.config.js +63 -0
  239. package/vue.config.js +32 -0
  240. package/workbox-config.js +66 -0
@@ -0,0 +1,565 @@
1
+ const defaults = {
2
+ fg: "#FFF",
3
+ bg: "#000",
4
+ newline: false,
5
+ escapeXML: false,
6
+ stream: false,
7
+ colors: getDefaultColors()
8
+ };
9
+
10
+ function getDefaultColors() {
11
+ const colors = {
12
+ 0: "#000",
13
+ 1: "#A00",
14
+ 2: "#0A0",
15
+ 3: "#A50",
16
+ 4: "#00A",
17
+ 5: "#A0A",
18
+ 6: "#0AA",
19
+ 7: "#AAA",
20
+ 8: "#555",
21
+ 9: "#F55",
22
+ 10: "#5F5",
23
+ 11: "#FF5",
24
+ 12: "#55F",
25
+ 13: "#F5F",
26
+ 14: "#5FF",
27
+ 15: "#FFF"
28
+ };
29
+
30
+ range(0, 5).forEach((red) => {
31
+ range(0, 5).forEach((green) => {
32
+ range(0, 5).forEach((blue) => setStyleColor(red, green, blue, colors));
33
+ });
34
+ });
35
+
36
+ range(0, 23).forEach(function (gray) {
37
+ const c = gray + 232;
38
+ const l = toHexString(gray * 10 + 8);
39
+
40
+ colors[c] = "#" + l + l + l;
41
+ });
42
+
43
+ return colors;
44
+ }
45
+
46
+ /**
47
+ * @param {number} red
48
+ * @param {number} green
49
+ * @param {number} blue
50
+ * @param {object} colors
51
+ */
52
+ function setStyleColor(red, green, blue, colors) {
53
+ const c = 16 + red * 36 + green * 6 + blue;
54
+ const r = red > 0 ? red * 40 + 55 : 0;
55
+ const g = green > 0 ? green * 40 + 55 : 0;
56
+ const b = blue > 0 ? blue * 40 + 55 : 0;
57
+
58
+ colors[c] = toColorHexString([r, g, b]);
59
+ }
60
+
61
+ /**
62
+ * Converts from a number like 15 to a hex string like 'F'
63
+ * @param {number} num
64
+ * @returns {string}
65
+ */
66
+ function toHexString(num) {
67
+ let str = num.toString(16);
68
+
69
+ while (str.length < 2) {
70
+ str = "0" + str;
71
+ }
72
+
73
+ return str;
74
+ }
75
+
76
+ /**
77
+ * Converts from an array of numbers like [15, 15, 15] to a hex string like 'FFF'
78
+ * @param {[red, green, blue]} ref
79
+ * @returns {string}
80
+ */
81
+ function toColorHexString(ref) {
82
+ const results = [];
83
+
84
+ for (const r of ref) {
85
+ results.push(toHexString(r));
86
+ }
87
+
88
+ return "#" + results.join("");
89
+ }
90
+
91
+ /**
92
+ * @param {Array} stack
93
+ * @param {string} token
94
+ * @param {*} data
95
+ * @param {object} options
96
+ */
97
+ function generateOutput(stack, token, data, options) {
98
+ let result;
99
+
100
+ if (token === "text") {
101
+ result = pushText(data);
102
+ } else if (token === "display") {
103
+ result = handleDisplay(stack, data, options);
104
+ } else if (token === "xterm256Foreground") {
105
+ result = pushForegroundColor(stack, options.colors[data]);
106
+ } else if (token === "xterm256Background") {
107
+ result = pushBackgroundColor(stack, options.colors[data]);
108
+ } else if (token === "rgb") {
109
+ result = handleRgb(stack, data);
110
+ }
111
+
112
+ return result;
113
+ }
114
+
115
+ /**
116
+ * @param {Array} stack
117
+ * @param {string} data
118
+ * @returns {*}
119
+ */
120
+ function handleRgb(stack, data) {
121
+ data = data.substring(2).slice(0, -1);
122
+ const operation = +data.substr(0, 2);
123
+
124
+ const color = data.substring(5).split(";");
125
+ const rgb = color
126
+ .map(function (value) {
127
+ return ("0" + Number(value).toString(16)).substr(-2);
128
+ })
129
+ .join("");
130
+
131
+ return pushStyle(stack, (operation === 38 ? "color:#" : "background-color:#") + rgb);
132
+ }
133
+
134
+ /**
135
+ * @param {Array} stack
136
+ * @param {number} code
137
+ * @param {object} options
138
+ * @returns {*}
139
+ */
140
+ function handleDisplay(stack, code, options) {
141
+ code = parseInt(code, 10);
142
+
143
+ const codeMap = {
144
+ "-1": () => "<br/>",
145
+ 0: () => stack.length && resetStyles(stack),
146
+ 1: () => pushTag(stack, "b"),
147
+ 3: () => pushTag(stack, "i"),
148
+ 4: () => pushTag(stack, "u"),
149
+ 8: () => pushStyle(stack, "display:none"),
150
+ 9: () => pushTag(stack, "strike"),
151
+ 22: () => pushStyle(stack, "font-weight:normal;text-decoration:none;font-style:normal"),
152
+ 23: () => closeTag(stack, "i"),
153
+ 24: () => closeTag(stack, "u"),
154
+ 39: () => pushForegroundColor(stack, options.fg),
155
+ 49: () => pushBackgroundColor(stack, options.bg),
156
+ 53: () => pushStyle(stack, "text-decoration:overline")
157
+ };
158
+
159
+ let result;
160
+ if (codeMap[code]) {
161
+ result = codeMap[code]();
162
+ } else if (4 < code && code < 7) {
163
+ result = pushTag(stack, "blink");
164
+ } else if (29 < code && code < 38) {
165
+ result = pushForegroundColor(stack, options.colors[code - 30]);
166
+ } else if (39 < code && code < 48) {
167
+ result = pushBackgroundColor(stack, options.colors[code - 40]);
168
+ } else if (89 < code && code < 98) {
169
+ result = pushForegroundColor(stack, options.colors[8 + (code - 90)]);
170
+ } else if (99 < code && code < 108) {
171
+ result = pushBackgroundColor(stack, options.colors[8 + (code - 100)]);
172
+ }
173
+
174
+ return result;
175
+ }
176
+
177
+ /**
178
+ * Clear all the styles
179
+ * @returns {string}
180
+ */
181
+ function resetStyles(stack) {
182
+ const stackClone = stack.slice(0);
183
+
184
+ stack.length = 0;
185
+
186
+ return stackClone
187
+ .reverse()
188
+ .map(function (tag) {
189
+ return "</" + tag + ">";
190
+ })
191
+ .join("");
192
+ }
193
+
194
+ /**
195
+ * Creates an array of numbers ranging from low to high
196
+ * @param {number} low
197
+ * @param {number} high
198
+ * @returns {Array}
199
+ * @example range(3, 7); // creates [3, 4, 5, 6, 7]
200
+ */
201
+ function range(low, high) {
202
+ const results = [];
203
+
204
+ for (let j = low; j <= high; j++) {
205
+ results.push(j);
206
+ }
207
+
208
+ return results;
209
+ }
210
+
211
+ /**
212
+ * Returns a new function that is true if value is NOT the same category
213
+ * @param {string} category
214
+ * @returns {function}
215
+ */
216
+ function notCategory(category) {
217
+ return function (e) {
218
+ return (category === null || e.category !== category) && category !== "all";
219
+ };
220
+ }
221
+
222
+ /**
223
+ * Converts a code into an ansi token type
224
+ * @param {number} code
225
+ * @returns {string}
226
+ */
227
+ function categoryForCode(code) {
228
+ code = parseInt(code, 10);
229
+ let result = null;
230
+
231
+ if (code === 0) {
232
+ result = "all";
233
+ } else if (code === 1) {
234
+ result = "bold";
235
+ } else if (2 < code && code < 5) {
236
+ result = "underline";
237
+ } else if (4 < code && code < 7) {
238
+ result = "blink";
239
+ } else if (code === 8) {
240
+ result = "hide";
241
+ } else if (code === 9) {
242
+ result = "strike";
243
+ } else if ((29 < code && code < 38) || code === 39 || (89 < code && code < 98)) {
244
+ result = "foreground-color";
245
+ } else if ((39 < code && code < 48) || code === 49 || (99 < code && code < 108)) {
246
+ result = "background-color";
247
+ }
248
+
249
+ return result;
250
+ }
251
+
252
+ /**
253
+ * @param {string} text
254
+ * @param {object} options
255
+ * @returns {string}
256
+ */
257
+ function pushText(text) {
258
+ return text;
259
+ }
260
+
261
+ /**
262
+ * @param {Array} stack
263
+ * @param {string} tag
264
+ * @param {string} [style='']
265
+ * @returns {string}
266
+ */
267
+ function pushTag(stack, tag, style) {
268
+ if (!style) {
269
+ style = "";
270
+ }
271
+
272
+ stack.push(tag);
273
+
274
+ return `<${tag}${style ? ` style="${style}"` : ""}>`;
275
+ }
276
+
277
+ /**
278
+ * @param {Array} stack
279
+ * @param {string} style
280
+ * @returns {string}
281
+ */
282
+ function pushStyle(stack, style) {
283
+ return pushTag(stack, "span", style);
284
+ }
285
+
286
+ function pushForegroundColor(stack, color) {
287
+ return pushTag(stack, "span", "color:" + color);
288
+ }
289
+
290
+ function pushBackgroundColor(stack, color) {
291
+ return pushTag(stack, "span", "background-color:" + color);
292
+ }
293
+
294
+ /**
295
+ * @param {Array} stack
296
+ * @param {string} style
297
+ * @returns {string}
298
+ */
299
+ function closeTag(stack, style) {
300
+ let last;
301
+
302
+ if (stack.slice(-1)[0] === style) {
303
+ last = stack.pop();
304
+ }
305
+
306
+ if (last) {
307
+ return "</" + style + ">";
308
+ }
309
+ }
310
+
311
+ /**
312
+ * @param {string} text
313
+ * @param {object} options
314
+ * @param {function} callback
315
+ * @returns {Array}
316
+ */
317
+ function tokenize(text, options, callback) {
318
+ let ansiMatch = false;
319
+ const ansiHandler = 3;
320
+
321
+ function remove() {
322
+ return "";
323
+ }
324
+
325
+ function removeXterm256Foreground(m, g1) {
326
+ callback("xterm256Foreground", g1);
327
+ return "";
328
+ }
329
+
330
+ function removeXterm256Background(m, g1) {
331
+ callback("xterm256Background", g1);
332
+ return "";
333
+ }
334
+
335
+ function newline(m) {
336
+ if (options.newline) {
337
+ callback("display", -1);
338
+ } else {
339
+ callback("text", m);
340
+ }
341
+
342
+ return "";
343
+ }
344
+
345
+ function ansiMess(m, g1) {
346
+ ansiMatch = true;
347
+ if (g1.trim().length === 0) {
348
+ g1 = "0";
349
+ }
350
+
351
+ g1 = g1.trimRight(";").split(";");
352
+
353
+ for (const g of g1) {
354
+ callback("display", g);
355
+ }
356
+
357
+ return "";
358
+ }
359
+
360
+ function realText(m) {
361
+ callback("text", m);
362
+
363
+ return "";
364
+ }
365
+
366
+ function rgb(m) {
367
+ callback("rgb", m);
368
+
369
+ return "";
370
+ }
371
+
372
+ /* eslint no-control-regex:0 */
373
+ const tokens = [
374
+ {
375
+ pattern: /^\x08+/,
376
+ sub: remove
377
+ },
378
+ {
379
+ pattern: /^\x1b\[[012]?K/,
380
+ sub: remove
381
+ },
382
+ {
383
+ pattern: /^\x1b\[\(B/,
384
+ sub: remove
385
+ },
386
+ {
387
+ pattern: /^\x1b\[[34]8;2;\d+;\d+;\d+m/,
388
+ sub: rgb
389
+ },
390
+ {
391
+ pattern: /^\x1b\[38;5;(\d+)m/,
392
+ sub: removeXterm256Foreground
393
+ },
394
+ {
395
+ pattern: /^\x1b\[48;5;(\d+)m/,
396
+ sub: removeXterm256Background
397
+ },
398
+ {
399
+ pattern: /^\n/,
400
+ sub: newline
401
+ },
402
+ {
403
+ pattern: /^\r+\n/,
404
+ sub: newline
405
+ },
406
+ {
407
+ pattern: /^\r/,
408
+ sub: newline
409
+ },
410
+ {
411
+ pattern: /^\x1b\[((?:\d{1,3};?)+|)m/,
412
+ sub: ansiMess
413
+ },
414
+ {
415
+ // CSI n J
416
+ // ED - Erase in Display Clears part of the screen.
417
+ // If n is 0 (or missing), clear from cursor to end of screen.
418
+ // If n is 1, clear from cursor to beginning of the screen.
419
+ // If n is 2, clear entire screen (and moves cursor to upper left on DOS ANSI.SYS).
420
+ // If n is 3, clear entire screen and delete all lines saved in the scrollback buffer
421
+ // (this feature was added for xterm and is supported by other terminal applications).
422
+ pattern: /^\x1b\[\d?J/,
423
+ sub: remove
424
+ },
425
+ {
426
+ // CSI n ; m f
427
+ // HVP - Horizontal Vertical Position Same as CUP
428
+ pattern: /^\x1b\[\d{0,3};\d{0,3}f/,
429
+ sub: remove
430
+ },
431
+ {
432
+ // catch-all for CSI sequences?
433
+ pattern: /^\x1b\[?[\d;]{0,3}/,
434
+ sub: remove
435
+ },
436
+ {
437
+ /**
438
+ * extracts real text - not containing:
439
+ * - `\x1b' - ESC - escape (Ascii 27)
440
+ * - '\x08' - BS - backspace (Ascii 8)
441
+ * - `\n` - Newline - linefeed (LF) (ascii 10)
442
+ * - `\r` - Windows Carriage Return (CR)
443
+ */
444
+ pattern: /^(([^\x1b\x08\r\n])+)/,
445
+ sub: realText
446
+ }
447
+ ];
448
+
449
+ function process(handler, i) {
450
+ if (i > ansiHandler && ansiMatch) {
451
+ return;
452
+ }
453
+
454
+ ansiMatch = false;
455
+
456
+ text = text.replace(handler.pattern, handler.sub);
457
+ }
458
+
459
+ const results1 = [];
460
+ let { length } = text;
461
+
462
+ outer: while (length > 0) {
463
+ for (let i = 0, o = 0, len = tokens.length; o < len; i = ++o) {
464
+ const handler = tokens[i];
465
+ process(handler, i);
466
+
467
+ if (text.length !== length) {
468
+ // We matched a token and removed it from the text. We need to
469
+ // start matching *all* tokens against the new text.
470
+ length = text.length;
471
+ continue outer;
472
+ }
473
+ }
474
+
475
+ if (text.length === length) {
476
+ break;
477
+ }
478
+ results1.push(0);
479
+
480
+ length = text.length;
481
+ }
482
+
483
+ return results1;
484
+ }
485
+
486
+ /**
487
+ * If streaming, then the stack is "sticky"
488
+ *
489
+ * @param {Array} stickyStack
490
+ * @param {string} token
491
+ * @param {*} data
492
+ * @returns {Array}
493
+ */
494
+ function updateStickyStack(stickyStack, token, data) {
495
+ if (token !== "text") {
496
+ stickyStack = stickyStack.filter(notCategory(categoryForCode(data)));
497
+ stickyStack.push({
498
+ token,
499
+ data,
500
+ category: categoryForCode(data)
501
+ });
502
+ }
503
+
504
+ return stickyStack;
505
+ }
506
+
507
+ class Filter {
508
+ /**
509
+ * @param {object} options
510
+ * @param {string=} options.fg The default foreground color used when reset color codes are encountered.
511
+ * @param {string=} options.bg The default background color used when reset color codes are encountered.
512
+ * @param {boolean=} options.newline Convert newline characters to `<br/>`.
513
+ * @param {boolean=} options.escapeXML Generate HTML/XML entities.
514
+ * @param {boolean=} options.stream Save style state across invocations of `toHtml()`.
515
+ * @param {(string[] | {[code: number]: string})=} options.colors Can override specific colors or the entire ANSI palette.
516
+ */
517
+ constructor(options) {
518
+ options = options || {};
519
+
520
+ if (options.colors) {
521
+ options.colors = Object.assign({}, defaults.colors, options.colors);
522
+ }
523
+
524
+ this.options = Object.assign({}, defaults, options);
525
+ this.stack = [];
526
+ this.stickyStack = [];
527
+ }
528
+ /**
529
+ * @param {string | string[]} input
530
+ * @returns {string}
531
+ */
532
+ toHtml(input) {
533
+ input = typeof input === "string" ? [input] : input;
534
+ const { stack, options } = this;
535
+ const buf = [];
536
+
537
+ this.stickyStack.forEach((element) => {
538
+ const output = generateOutput(stack, element.token, element.data, options);
539
+
540
+ if (output) {
541
+ buf.push(output);
542
+ }
543
+ });
544
+
545
+ tokenize(input.join(""), options, (token, data) => {
546
+ const output = generateOutput(stack, token, data, options);
547
+
548
+ if (output) {
549
+ buf.push(output);
550
+ }
551
+
552
+ if (options.stream) {
553
+ this.stickyStack = updateStickyStack(this.stickyStack, token, data);
554
+ }
555
+ });
556
+
557
+ if (stack.length) {
558
+ buf.push(resetStyles(stack));
559
+ }
560
+
561
+ return buf.join("");
562
+ }
563
+ }
564
+
565
+ export default Filter;