mepcli 1.3.2 → 2.0.0-beta.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.
Files changed (291) hide show
  1. package/README.md +11 -2
  2. package/dist/{ansi.js → src/ansi.js} +17 -9
  3. package/dist/src/ansi.js.map +1 -0
  4. package/dist/{base.js → src/base.js} +82 -70
  5. package/dist/src/base.js.map +1 -0
  6. package/dist/{core.js → src/core.js} +266 -320
  7. package/dist/src/core.js.map +1 -0
  8. package/dist/src/data/countries.js +569 -0
  9. package/dist/src/data/countries.js.map +1 -0
  10. package/dist/src/data/licenses.js +480 -0
  11. package/dist/src/data/licenses.js.map +1 -0
  12. package/dist/{highlight.js → src/highlight.js} +77 -69
  13. package/dist/src/highlight.js.map +1 -0
  14. package/dist/src/index.js +66 -0
  15. package/dist/src/index.js.map +1 -0
  16. package/dist/{input.js → src/input.js} +47 -41
  17. package/dist/src/input.js.map +1 -0
  18. package/dist/src/pipeline.js +273 -0
  19. package/dist/src/pipeline.js.map +1 -0
  20. package/dist/{prompts → src/prompts}/autocomplete.js +58 -57
  21. package/dist/src/prompts/autocomplete.js.map +1 -0
  22. package/dist/{prompts → src/prompts}/box.js +86 -53
  23. package/dist/src/prompts/box.js.map +1 -0
  24. package/dist/{prompts → src/prompts}/breadcrumb-search.js +110 -98
  25. package/dist/src/prompts/breadcrumb-search.js.map +1 -0
  26. package/dist/{prompts → src/prompts}/breadcrumb.js +126 -121
  27. package/dist/src/prompts/breadcrumb.js.map +1 -0
  28. package/dist/{prompts → src/prompts}/byte.js +69 -52
  29. package/dist/src/prompts/byte.js.map +1 -0
  30. package/dist/{prompts → src/prompts}/calculator.js +79 -56
  31. package/dist/src/prompts/calculator.js.map +1 -0
  32. package/dist/{prompts → src/prompts}/calendar.js +167 -127
  33. package/dist/src/prompts/calendar.js.map +1 -0
  34. package/dist/{prompts → src/prompts}/checkbox.js +53 -49
  35. package/dist/src/prompts/checkbox.js.map +1 -0
  36. package/dist/{prompts → src/prompts}/code.js +88 -76
  37. package/dist/src/prompts/code.js.map +1 -0
  38. package/dist/{prompts → src/prompts}/color.js +68 -50
  39. package/dist/src/prompts/color.js.map +1 -0
  40. package/dist/{prompts → src/prompts}/confirm.js +22 -15
  41. package/dist/src/prompts/confirm.js.map +1 -0
  42. package/dist/{prompts → src/prompts}/connection-string.js +59 -36
  43. package/dist/src/prompts/connection-string.js.map +1 -0
  44. package/dist/{prompts → src/prompts}/cron.js +90 -59
  45. package/dist/src/prompts/cron.js.map +1 -0
  46. package/dist/src/prompts/curl-utils.js +71 -0
  47. package/dist/src/prompts/curl-utils.js.map +1 -0
  48. package/dist/{prompts → src/prompts}/curl.js +153 -132
  49. package/dist/src/prompts/curl.js.map +1 -0
  50. package/dist/{prompts → src/prompts}/data-inspector.js +96 -91
  51. package/dist/src/prompts/data-inspector.js.map +1 -0
  52. package/dist/{prompts → src/prompts}/date.js +64 -57
  53. package/dist/src/prompts/date.js.map +1 -0
  54. package/dist/{prompts → src/prompts}/dependency.js +84 -80
  55. package/dist/src/prompts/dependency.js.map +1 -0
  56. package/dist/{prompts → src/prompts}/dial.js +49 -35
  57. package/dist/src/prompts/dial.js.map +1 -0
  58. package/dist/src/prompts/diff.js +118 -0
  59. package/dist/src/prompts/diff.js.map +1 -0
  60. package/dist/{prompts → src/prompts}/draw.js +83 -80
  61. package/dist/src/prompts/draw.js.map +1 -0
  62. package/dist/src/prompts/editor.js +234 -0
  63. package/dist/src/prompts/editor.js.map +1 -0
  64. package/dist/{prompts → src/prompts}/emoji.js +80 -82
  65. package/dist/src/prompts/emoji.js.map +1 -0
  66. package/dist/{prompts → src/prompts}/exec.js +60 -46
  67. package/dist/src/prompts/exec.js.map +1 -0
  68. package/dist/src/prompts/file.js +217 -0
  69. package/dist/src/prompts/file.js.map +1 -0
  70. package/dist/{prompts → src/prompts}/form.js +63 -54
  71. package/dist/src/prompts/form.js.map +1 -0
  72. package/dist/{prompts → src/prompts}/fuzzy-multi-column.js +65 -53
  73. package/dist/src/prompts/fuzzy-multi-column.js.map +1 -0
  74. package/dist/{prompts → src/prompts}/fuzzy.js +66 -55
  75. package/dist/src/prompts/fuzzy.js.map +1 -0
  76. package/dist/src/prompts/gauge.js +137 -0
  77. package/dist/src/prompts/gauge.js.map +1 -0
  78. package/dist/{prompts → src/prompts}/grid.js +70 -57
  79. package/dist/src/prompts/grid.js.map +1 -0
  80. package/dist/{prompts → src/prompts}/heatmap.js +70 -64
  81. package/dist/src/prompts/heatmap.js.map +1 -0
  82. package/dist/{prompts → src/prompts}/ip.js +56 -36
  83. package/dist/src/prompts/ip.js.map +1 -0
  84. package/dist/{prompts → src/prompts}/kanban.js +63 -58
  85. package/dist/src/prompts/kanban.js.map +1 -0
  86. package/dist/src/prompts/keypress.js +54 -0
  87. package/dist/src/prompts/keypress.js.map +1 -0
  88. package/dist/src/prompts/license.js +144 -0
  89. package/dist/src/prompts/license.js.map +1 -0
  90. package/dist/{prompts → src/prompts}/list.js +46 -31
  91. package/dist/src/prompts/list.js.map +1 -0
  92. package/dist/{prompts → src/prompts}/map.js +93 -77
  93. package/dist/src/prompts/map.js.map +1 -0
  94. package/dist/{prompts → src/prompts}/match.js +91 -95
  95. package/dist/src/prompts/match.js.map +1 -0
  96. package/dist/{prompts → src/prompts}/miller.js +74 -67
  97. package/dist/src/prompts/miller.js.map +1 -0
  98. package/dist/{prompts → src/prompts}/multi-column-select.js +54 -44
  99. package/dist/src/prompts/multi-column-select.js.map +1 -0
  100. package/dist/{prompts → src/prompts}/multi-range.js +70 -52
  101. package/dist/src/prompts/multi-range.js.map +1 -0
  102. package/dist/{prompts → src/prompts}/multi-select.js +67 -58
  103. package/dist/src/prompts/multi-select.js.map +1 -0
  104. package/dist/{prompts → src/prompts}/number.js +51 -39
  105. package/dist/src/prompts/number.js.map +1 -0
  106. package/dist/{prompts → src/prompts}/otp.js +43 -27
  107. package/dist/src/prompts/otp.js.map +1 -0
  108. package/dist/{prompts → src/prompts}/pattern.js +74 -71
  109. package/dist/src/prompts/pattern.js.map +1 -0
  110. package/dist/{prompts → src/prompts}/phone.js +107 -118
  111. package/dist/src/prompts/phone.js.map +1 -0
  112. package/dist/src/prompts/quiz-select.js +114 -0
  113. package/dist/src/prompts/quiz-select.js.map +1 -0
  114. package/dist/src/prompts/quiz-text.js +98 -0
  115. package/dist/src/prompts/quiz-text.js.map +1 -0
  116. package/dist/{prompts → src/prompts}/range.js +85 -61
  117. package/dist/src/prompts/range.js.map +1 -0
  118. package/dist/{prompts → src/prompts}/rating.js +29 -24
  119. package/dist/src/prompts/rating.js.map +1 -0
  120. package/dist/{prompts → src/prompts}/regex.js +50 -36
  121. package/dist/src/prompts/regex.js.map +1 -0
  122. package/dist/{prompts → src/prompts}/region.js +62 -56
  123. package/dist/src/prompts/region.js.map +1 -0
  124. package/dist/{prompts → src/prompts}/schedule.js +82 -75
  125. package/dist/src/prompts/schedule.js.map +1 -0
  126. package/dist/{prompts → src/prompts}/scroll.js +61 -58
  127. package/dist/src/prompts/scroll.js.map +1 -0
  128. package/dist/src/prompts/seat.js +164 -0
  129. package/dist/src/prompts/seat.js.map +1 -0
  130. package/dist/{prompts → src/prompts}/select-range.js +58 -46
  131. package/dist/src/prompts/select-range.js.map +1 -0
  132. package/dist/{prompts → src/prompts}/select.js +65 -66
  133. package/dist/src/prompts/select.js.map +1 -0
  134. package/dist/{prompts → src/prompts}/semver.js +24 -13
  135. package/dist/src/prompts/semver.js.map +1 -0
  136. package/dist/src/prompts/shortcut.js +133 -0
  137. package/dist/src/prompts/shortcut.js.map +1 -0
  138. package/dist/{prompts → src/prompts}/slider.js +28 -23
  139. package/dist/src/prompts/slider.js.map +1 -0
  140. package/dist/src/prompts/slot.js +117 -0
  141. package/dist/src/prompts/slot.js.map +1 -0
  142. package/dist/{prompts → src/prompts}/snippet.js +82 -61
  143. package/dist/src/prompts/snippet.js.map +1 -0
  144. package/dist/{prompts → src/prompts}/sort-grid.js +64 -59
  145. package/dist/src/prompts/sort-grid.js.map +1 -0
  146. package/dist/{prompts → src/prompts}/sort.js +59 -49
  147. package/dist/src/prompts/sort.js.map +1 -0
  148. package/dist/src/prompts/spam.js +80 -0
  149. package/dist/src/prompts/spam.js.map +1 -0
  150. package/dist/{prompts → src/prompts}/spreadsheet.js +71 -70
  151. package/dist/src/prompts/spreadsheet.js.map +1 -0
  152. package/dist/{prompts → src/prompts}/table.js +52 -38
  153. package/dist/src/prompts/table.js.map +1 -0
  154. package/dist/{prompts → src/prompts}/text.js +74 -70
  155. package/dist/src/prompts/text.js.map +1 -0
  156. package/dist/{prompts → src/prompts}/time.js +105 -96
  157. package/dist/src/prompts/time.js.map +1 -0
  158. package/dist/src/prompts/toggle.js +53 -0
  159. package/dist/src/prompts/toggle.js.map +1 -0
  160. package/dist/{prompts → src/prompts}/transfer.js +71 -67
  161. package/dist/src/prompts/transfer.js.map +1 -0
  162. package/dist/{prompts → src/prompts}/tree-select.js +83 -86
  163. package/dist/src/prompts/tree-select.js.map +1 -0
  164. package/dist/{prompts → src/prompts}/tree.js +69 -67
  165. package/dist/src/prompts/tree.js.map +1 -0
  166. package/dist/src/prompts/wait.js +79 -0
  167. package/dist/src/prompts/wait.js.map +1 -0
  168. package/dist/src/spinner.js +105 -0
  169. package/dist/src/spinner.js.map +1 -0
  170. package/dist/{symbols.js → src/symbols.js} +32 -7
  171. package/dist/src/symbols.js.map +1 -0
  172. package/dist/{tasks.js → src/tasks.js} +104 -79
  173. package/dist/src/tasks.js.map +1 -0
  174. package/dist/src/theme.js +29 -0
  175. package/dist/src/theme.js.map +1 -0
  176. package/dist/src/types.js +8 -0
  177. package/dist/src/types.js.map +1 -0
  178. package/dist/{utils.js → src/utils.js} +196 -152
  179. package/dist/src/utils.js.map +1 -0
  180. package/package.json +16 -13
  181. package/dist/ansi.d.ts +0 -36
  182. package/dist/base.d.ts +0 -60
  183. package/dist/core.d.ts +0 -1072
  184. package/dist/data/countries.d.ts +0 -2
  185. package/dist/data/countries.js +0 -105
  186. package/dist/data/licenses.d.ts +0 -2
  187. package/dist/data/licenses.js +0 -109
  188. package/dist/highlight.d.ts +0 -7
  189. package/dist/index.d.ts +0 -48
  190. package/dist/index.js +0 -64
  191. package/dist/input.d.ts +0 -14
  192. package/dist/pipeline.d.ts +0 -39
  193. package/dist/pipeline.js +0 -54
  194. package/dist/prompts/autocomplete.d.ts +0 -22
  195. package/dist/prompts/box.d.ts +0 -21
  196. package/dist/prompts/breadcrumb-search.d.ts +0 -14
  197. package/dist/prompts/breadcrumb.d.ts +0 -32
  198. package/dist/prompts/byte.d.ts +0 -13
  199. package/dist/prompts/calculator.d.ts +0 -17
  200. package/dist/prompts/calendar.d.ts +0 -33
  201. package/dist/prompts/checkbox.d.ts +0 -13
  202. package/dist/prompts/code.d.ts +0 -19
  203. package/dist/prompts/color.d.ts +0 -14
  204. package/dist/prompts/confirm.d.ts +0 -8
  205. package/dist/prompts/connection-string.d.ts +0 -18
  206. package/dist/prompts/cron.d.ts +0 -13
  207. package/dist/prompts/curl-utils.d.ts +0 -25
  208. package/dist/prompts/curl-utils.js +0 -41
  209. package/dist/prompts/curl.d.ts +0 -41
  210. package/dist/prompts/data-inspector.d.ts +0 -22
  211. package/dist/prompts/date.d.ts +0 -12
  212. package/dist/prompts/dependency.d.ts +0 -16
  213. package/dist/prompts/dial.d.ts +0 -10
  214. package/dist/prompts/diff.d.ts +0 -10
  215. package/dist/prompts/diff.js +0 -101
  216. package/dist/prompts/draw.d.ts +0 -20
  217. package/dist/prompts/editor.d.ts +0 -14
  218. package/dist/prompts/editor.js +0 -203
  219. package/dist/prompts/emoji.d.ts +0 -18
  220. package/dist/prompts/exec.d.ts +0 -17
  221. package/dist/prompts/file.d.ts +0 -21
  222. package/dist/prompts/file.js +0 -210
  223. package/dist/prompts/form.d.ts +0 -18
  224. package/dist/prompts/fuzzy-multi-column.d.ts +0 -12
  225. package/dist/prompts/fuzzy.d.ts +0 -12
  226. package/dist/prompts/gauge.d.ts +0 -21
  227. package/dist/prompts/gauge.js +0 -130
  228. package/dist/prompts/grid.d.ts +0 -14
  229. package/dist/prompts/heatmap.d.ts +0 -13
  230. package/dist/prompts/ip.d.ts +0 -11
  231. package/dist/prompts/kanban.d.ts +0 -17
  232. package/dist/prompts/keypress.d.ts +0 -7
  233. package/dist/prompts/keypress.js +0 -55
  234. package/dist/prompts/license.d.ts +0 -9
  235. package/dist/prompts/license.js +0 -105
  236. package/dist/prompts/list.d.ts +0 -9
  237. package/dist/prompts/map.d.ts +0 -17
  238. package/dist/prompts/match.d.ts +0 -19
  239. package/dist/prompts/miller.d.ts +0 -15
  240. package/dist/prompts/multi-column-select.d.ts +0 -10
  241. package/dist/prompts/multi-range.d.ts +0 -9
  242. package/dist/prompts/multi-select.d.ts +0 -15
  243. package/dist/prompts/number.d.ts +0 -11
  244. package/dist/prompts/otp.d.ts +0 -10
  245. package/dist/prompts/pattern.d.ts +0 -22
  246. package/dist/prompts/phone.d.ts +0 -41
  247. package/dist/prompts/quiz-select.d.ts +0 -10
  248. package/dist/prompts/quiz-select.js +0 -104
  249. package/dist/prompts/quiz-text.d.ts +0 -11
  250. package/dist/prompts/quiz-text.js +0 -82
  251. package/dist/prompts/range.d.ts +0 -9
  252. package/dist/prompts/rating.d.ts +0 -8
  253. package/dist/prompts/regex.d.ts +0 -13
  254. package/dist/prompts/region.d.ts +0 -11
  255. package/dist/prompts/schedule.d.ts +0 -20
  256. package/dist/prompts/scroll.d.ts +0 -13
  257. package/dist/prompts/seat.d.ts +0 -17
  258. package/dist/prompts/seat.js +0 -165
  259. package/dist/prompts/select-range.d.ts +0 -8
  260. package/dist/prompts/select.d.ts +0 -15
  261. package/dist/prompts/semver.d.ts +0 -6
  262. package/dist/prompts/shortcut.d.ts +0 -9
  263. package/dist/prompts/shortcut.js +0 -135
  264. package/dist/prompts/slider.d.ts +0 -8
  265. package/dist/prompts/slot.d.ts +0 -16
  266. package/dist/prompts/slot.js +0 -107
  267. package/dist/prompts/snippet.d.ts +0 -19
  268. package/dist/prompts/sort-grid.d.ts +0 -16
  269. package/dist/prompts/sort.d.ts +0 -14
  270. package/dist/prompts/spam.d.ts +0 -17
  271. package/dist/prompts/spam.js +0 -62
  272. package/dist/prompts/spreadsheet.d.ts +0 -21
  273. package/dist/prompts/table.d.ts +0 -14
  274. package/dist/prompts/text.d.ts +0 -17
  275. package/dist/prompts/time.d.ts +0 -12
  276. package/dist/prompts/toggle.d.ts +0 -8
  277. package/dist/prompts/toggle.js +0 -47
  278. package/dist/prompts/transfer.d.ts +0 -18
  279. package/dist/prompts/tree-select.d.ts +0 -31
  280. package/dist/prompts/tree.d.ts +0 -20
  281. package/dist/prompts/wait.d.ts +0 -18
  282. package/dist/prompts/wait.js +0 -62
  283. package/dist/spinner.d.ts +0 -33
  284. package/dist/spinner.js +0 -89
  285. package/dist/symbols.d.ts +0 -33
  286. package/dist/tasks.d.ts +0 -57
  287. package/dist/theme.d.ts +0 -2
  288. package/dist/theme.js +0 -20
  289. package/dist/types.d.ts +0 -503
  290. package/dist/types.js +0 -5
  291. package/dist/utils.d.ts +0 -81
@@ -1,23 +1,45 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.highlightJson = highlightJson;
4
- exports.highlightEnv = highlightEnv;
5
- exports.highlightToml = highlightToml;
6
- exports.highlightCsv = highlightCsv;
7
- exports.highlightShell = highlightShell;
8
- exports.highlightProperties = highlightProperties;
9
- exports.highlight = highlight;
10
- const ansi_1 = require("./ansi");
11
- const theme_1 = require("./theme");
12
- // --- 1. JSON Highlighter ---
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get highlight () {
13
+ return highlight;
14
+ },
15
+ get highlightCsv () {
16
+ return highlightCsv;
17
+ },
18
+ get highlightEnv () {
19
+ return highlightEnv;
20
+ },
21
+ get highlightJson () {
22
+ return highlightJson;
23
+ },
24
+ get highlightProperties () {
25
+ return highlightProperties;
26
+ },
27
+ get highlightShell () {
28
+ return highlightShell;
29
+ },
30
+ get highlightToml () {
31
+ return highlightToml;
32
+ }
33
+ });
34
+ const _ansi = require("./ansi");
35
+ const _theme = require("./theme");
13
36
  function highlightJson(json) {
14
- if (!json)
15
- return '';
37
+ if (!json) return '';
16
38
  const tokenRegex = /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"?)|(-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?)|(true|false|null)|([{}[\],:])/g;
17
39
  let result = '';
18
40
  let lastIndex = 0;
19
41
  let match;
20
- while ((match = tokenRegex.exec(json)) !== null) {
42
+ while((match = tokenRegex.exec(json)) !== null){
21
43
  if (match.index > lastIndex) {
22
44
  result += json.substring(lastIndex, match.index);
23
45
  }
@@ -26,24 +48,17 @@ function highlightJson(json) {
26
48
  const remaining = json.substring(tokenRegex.lastIndex);
27
49
  // Heuristic for keys: followed by optional whitespace and a colon
28
50
  if (/^\s*:/.test(remaining)) {
29
- result += `${theme_1.theme.syntax.key}${token}${ansi_1.ANSI.RESET}`;
51
+ result += `${_theme.theme.syntax.key}${token}${_ansi.ANSI.RESET}`;
52
+ } else {
53
+ result += `${_theme.theme.syntax.string}${token}${_ansi.ANSI.RESET}`;
30
54
  }
31
- else {
32
- result += `${theme_1.theme.syntax.string}${token}${ansi_1.ANSI.RESET}`;
33
- }
34
- }
35
- else if (/^-?\d/.test(token)) {
36
- result += `${theme_1.theme.syntax.number}${token}${ansi_1.ANSI.RESET}`;
37
- }
38
- else if (/^(true|false|null)$/.test(token)) {
39
- result += (token === 'null')
40
- ? `${theme_1.theme.syntax.null}${token}${ansi_1.ANSI.RESET}`
41
- : `${theme_1.theme.syntax.boolean}${token}${ansi_1.ANSI.RESET}`;
42
- }
43
- else if (/^[{}[\],:]$/.test(token)) {
44
- result += `${theme_1.theme.syntax.punctuation}${token}${ansi_1.ANSI.RESET}`;
45
- }
46
- else {
55
+ } else if (/^-?\d/.test(token)) {
56
+ result += `${_theme.theme.syntax.number}${token}${_ansi.ANSI.RESET}`;
57
+ } else if (/^(true|false|null)$/.test(token)) {
58
+ result += token === 'null' ? `${_theme.theme.syntax.null}${token}${_ansi.ANSI.RESET}` : `${_theme.theme.syntax.boolean}${token}${_ansi.ANSI.RESET}`;
59
+ } else if (/^[{}[\],:]$/.test(token)) {
60
+ result += `${_theme.theme.syntax.punctuation}${token}${_ansi.ANSI.RESET}`;
61
+ } else {
47
62
  result += token;
48
63
  }
49
64
  lastIndex = tokenRegex.lastIndex;
@@ -53,34 +68,30 @@ function highlightJson(json) {
53
68
  }
54
69
  return result;
55
70
  }
56
- // --- 2. ENV Highlighter ---
57
71
  function highlightEnv(env) {
58
- if (!env)
59
- return '';
60
- return env.split('\n').map(line => {
72
+ if (!env) return '';
73
+ return env.split('\n').map((line)=>{
61
74
  if (line.trim().startsWith('#')) {
62
- return `${theme_1.theme.muted}${line}${ansi_1.ANSI.RESET}`;
75
+ return `${_theme.theme.muted}${line}${_ansi.ANSI.RESET}`;
63
76
  }
64
77
  const match = line.match(/^([^=]+)=(.*)$/);
65
78
  if (match) {
66
79
  const [, key, value] = match;
67
- return `${theme_1.theme.syntax.key}${key}${theme_1.theme.syntax.punctuation}=${theme_1.theme.syntax.string}${value}${ansi_1.ANSI.RESET}`;
80
+ return `${_theme.theme.syntax.key}${key}${_theme.theme.syntax.punctuation}=${_theme.theme.syntax.string}${value}${_ansi.ANSI.RESET}`;
68
81
  }
69
82
  return line;
70
83
  }).join('\n');
71
84
  }
72
- // --- 3. TOML Highlighter ---
73
85
  function highlightToml(toml) {
74
- if (!toml)
75
- return '';
76
- return toml.split('\n').map(line => {
86
+ if (!toml) return '';
87
+ return toml.split('\n').map((line)=>{
77
88
  const trimmed = line.trim();
78
89
  if (trimmed.startsWith('#')) {
79
- return `${theme_1.theme.muted}${line}${ansi_1.ANSI.RESET}`;
90
+ return `${_theme.theme.muted}${line}${_ansi.ANSI.RESET}`;
80
91
  }
81
92
  // [section]
82
93
  if (trimmed.startsWith('[') && trimmed.endsWith(']')) {
83
- return `${theme_1.theme.syntax.key}${line}${ansi_1.ANSI.RESET}`;
94
+ return `${_theme.theme.syntax.key}${line}${_ansi.ANSI.RESET}`;
84
95
  }
85
96
  // Key = Value
86
97
  const match = line.match(/^(\s*[\w\d_-]+)(\s*=)/);
@@ -89,66 +100,61 @@ function highlightToml(toml) {
89
100
  const keyPart = match[1];
90
101
  const eqPart = match[2];
91
102
  const rest = line.substring(fullMatch.length);
92
- return `${theme_1.theme.syntax.key}${keyPart}${ansi_1.ANSI.RESET}${theme_1.theme.syntax.punctuation}${eqPart}${theme_1.theme.syntax.string}${rest}${ansi_1.ANSI.RESET}`;
103
+ return `${_theme.theme.syntax.key}${keyPart}${_ansi.ANSI.RESET}${_theme.theme.syntax.punctuation}${eqPart}${_theme.theme.syntax.string}${rest}${_ansi.ANSI.RESET}`;
93
104
  }
94
105
  return line;
95
106
  }).join('\n');
96
107
  }
97
- // --- 4. CSV Highlighter ---
98
108
  function highlightCsv(csv) {
99
- if (!csv)
100
- return '';
109
+ if (!csv) return '';
101
110
  // Cycle through colors to differentiate columns
102
- const colors = [theme_1.theme.syntax.string, theme_1.theme.syntax.key, theme_1.theme.syntax.number, theme_1.theme.syntax.boolean];
103
- return csv.split('\n').map(line => {
104
- if (!line.trim())
105
- return line;
111
+ const colors = [
112
+ _theme.theme.syntax.string,
113
+ _theme.theme.syntax.key,
114
+ _theme.theme.syntax.number,
115
+ _theme.theme.syntax.boolean
116
+ ];
117
+ return csv.split('\n').map((line)=>{
118
+ if (!line.trim()) return line;
106
119
  // Split by comma, ignoring commas inside double quotes
107
120
  // Regex explanation: Match comma only if followed by an even number of quotes (or 0) until end of line
108
121
  const parts = line.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/);
109
- return parts.map((part, index) => {
122
+ return parts.map((part, index)=>{
110
123
  const color = colors[index % colors.length];
111
- return `${color}${part}${ansi_1.ANSI.RESET}`;
112
- }).join(`${theme_1.theme.syntax.punctuation},${ansi_1.ANSI.RESET}`);
124
+ return `${color}${part}${_ansi.ANSI.RESET}`;
125
+ }).join(`${_theme.theme.syntax.punctuation},${_ansi.ANSI.RESET}`);
113
126
  }).join('\n');
114
127
  }
115
- // --- 5. Shell/Bash Highlighter ---
116
128
  function highlightShell(script) {
117
- if (!script)
118
- return '';
129
+ if (!script) return '';
119
130
  // Simple replacements for common shell patterns
120
131
  // 1. Comments
121
132
  // 2. Keywords
122
133
  // 3. Variables
123
134
  const keywords = /\b(if|then|else|elif|fi|for|in|do|done|while|case|esac|return|exit|export|source|echo|printf)\b/g;
124
- return script.split('\n').map(line => {
135
+ return script.split('\n').map((line)=>{
125
136
  if (line.trim().startsWith('#')) {
126
- return `${theme_1.theme.muted}${line}${ansi_1.ANSI.RESET}`;
137
+ return `${_theme.theme.muted}${line}${_ansi.ANSI.RESET}`;
127
138
  }
128
139
  // Temporarily hide strings properly is hard with regex replace,
129
140
  // so we just do best-effort highlights for keywords and vars outside of checking quote context.
130
- const processed = line
131
- .replace(keywords, match => `${theme_1.theme.syntax.boolean}${match}${ansi_1.ANSI.RESET}`)
132
- .replace(/(\$[\w\d_]+|\$\{[^}]+\})/g, match => `${theme_1.theme.syntax.key}${match}${ansi_1.ANSI.RESET}`)
133
- .replace(/(\s|^)(-{1,2}[a-zA-Z0-9_-]+)/g, (_match, prefix, flag) => `${prefix}${theme_1.theme.syntax.number}${flag}${ansi_1.ANSI.RESET}`);
141
+ const processed = line.replace(keywords, (match)=>`${_theme.theme.syntax.boolean}${match}${_ansi.ANSI.RESET}`).replace(/(\$[\w\d_]+|\$\{[^}]+\})/g, (match)=>`${_theme.theme.syntax.key}${match}${_ansi.ANSI.RESET}`).replace(/(\s|^)(-{1,2}[a-zA-Z0-9_-]+)/g, (_match, prefix, flag)=>`${prefix}${_theme.theme.syntax.number}${flag}${_ansi.ANSI.RESET}`);
134
142
  return processed;
135
143
  }).join('\n');
136
144
  }
137
- // --- 6. Properties Highlighter ---
138
145
  function highlightProperties(props) {
139
- if (!props)
140
- return '';
141
- return props.split('\n').map(line => {
146
+ if (!props) return '';
147
+ return props.split('\n').map((line)=>{
142
148
  const trimmed = line.trim();
143
149
  // Supports # or ! for comments
144
150
  if (trimmed.startsWith('#') || trimmed.startsWith('!')) {
145
- return `${theme_1.theme.muted}${line}${ansi_1.ANSI.RESET}`;
151
+ return `${_theme.theme.muted}${line}${_ansi.ANSI.RESET}`;
146
152
  }
147
153
  // Keys can be separated by = or :
148
154
  const match = line.match(/^([^=:]+)([=:])(.*)$/);
149
155
  if (match) {
150
156
  const [, key, sep, value] = match;
151
- return `${theme_1.theme.syntax.key}${key}${theme_1.theme.syntax.punctuation}${sep}${theme_1.theme.syntax.string}${value}${ansi_1.ANSI.RESET}`;
157
+ return `${_theme.theme.syntax.key}${key}${_theme.theme.syntax.punctuation}${sep}${_theme.theme.syntax.string}${value}${_ansi.ANSI.RESET}`;
152
158
  }
153
159
  return line;
154
160
  }).join('\n');
@@ -175,3 +181,5 @@ function highlight(code, language) {
175
181
  // Fallback: If no highlighter found, return original code
176
182
  return code;
177
183
  }
184
+
185
+ //# sourceMappingURL=highlight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/highlight.ts"],"sourcesContent":["import { ANSI } from './ansi';\nimport { theme } from './theme';\n\ntype Highlighter = (code: string) => string;\n\n// --- 1. JSON Highlighter ---\nexport function highlightJson(json: string): string {\n if (!json) return '';\n const tokenRegex = /(\"(\\\\u[a-zA-Z0-9]{4}|\\\\[^u]|[^\\\\\"])*\"?)|(-?\\d+(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)|(true|false|null)|([{}[\\],:])/g;\n\n let result = '';\n let lastIndex = 0;\n let match;\n\n while ((match = tokenRegex.exec(json)) !== null) {\n if (match.index > lastIndex) {\n result += json.substring(lastIndex, match.index);\n }\n\n const token = match[0];\n\n if (token.startsWith('\"')) {\n const remaining = json.substring(tokenRegex.lastIndex);\n // Heuristic for keys: followed by optional whitespace and a colon\n if (/^\\s*:/.test(remaining)) {\n result += `${theme.syntax.key}${token}${ANSI.RESET}`;\n } else {\n result += `${theme.syntax.string}${token}${ANSI.RESET}`;\n }\n }\n else if (/^-?\\d/.test(token)) {\n result += `${theme.syntax.number}${token}${ANSI.RESET}`;\n }\n else if (/^(true|false|null)$/.test(token)) {\n result += (token === 'null')\n ? `${theme.syntax.null}${token}${ANSI.RESET}`\n : `${theme.syntax.boolean}${token}${ANSI.RESET}`;\n }\n else if (/^[{}[\\],:]$/.test(token)) {\n result += `${theme.syntax.punctuation}${token}${ANSI.RESET}`;\n }\n else {\n result += token;\n }\n\n lastIndex = tokenRegex.lastIndex;\n }\n\n if (lastIndex < json.length) {\n result += json.substring(lastIndex);\n }\n return result;\n}\n\n// --- 2. ENV Highlighter ---\nexport function highlightEnv(env: string): string {\n if (!env) return '';\n return env.split('\\n').map(line => {\n if (line.trim().startsWith('#')) {\n return `${theme.muted}${line}${ANSI.RESET}`;\n }\n const match = line.match(/^([^=]+)=(.*)$/);\n if (match) {\n const [, key, value] = match;\n return `${theme.syntax.key}${key}${theme.syntax.punctuation}=${theme.syntax.string}${value}${ANSI.RESET}`;\n }\n return line;\n }).join('\\n');\n}\n\n// --- 3. TOML Highlighter ---\nexport function highlightToml(toml: string): string {\n if (!toml) return '';\n return toml.split('\\n').map(line => {\n const trimmed = line.trim();\n if (trimmed.startsWith('#')) {\n return `${theme.muted}${line}${ANSI.RESET}`;\n }\n // [section]\n if (trimmed.startsWith('[') && trimmed.endsWith(']')) {\n return `${theme.syntax.key}${line}${ANSI.RESET}`;\n }\n // Key = Value\n const match = line.match(/^(\\s*[\\w\\d_-]+)(\\s*=)/);\n if (match) {\n const fullMatch = match[0];\n const keyPart = match[1];\n const eqPart = match[2];\n const rest = line.substring(fullMatch.length);\n return `${theme.syntax.key}${keyPart}${ANSI.RESET}${theme.syntax.punctuation}${eqPart}${theme.syntax.string}${rest}${ANSI.RESET}`;\n }\n return line;\n }).join('\\n');\n}\n\n// --- 4. CSV Highlighter ---\nexport function highlightCsv(csv: string): string {\n if (!csv) return '';\n // Cycle through colors to differentiate columns\n const colors = [theme.syntax.string, theme.syntax.key, theme.syntax.number, theme.syntax.boolean];\n\n return csv.split('\\n').map(line => {\n if (!line.trim()) return line;\n // Split by comma, ignoring commas inside double quotes\n // Regex explanation: Match comma only if followed by an even number of quotes (or 0) until end of line\n const parts = line.split(/,(?=(?:(?:[^\"]*\"){2})*[^\"]*$)/);\n\n return parts.map((part, index) => {\n const color = colors[index % colors.length];\n return `${color}${part}${ANSI.RESET}`;\n }).join(`${theme.syntax.punctuation},${ANSI.RESET}`);\n }).join('\\n');\n}\n\n// --- 5. Shell/Bash Highlighter ---\nexport function highlightShell(script: string): string {\n if (!script) return '';\n\n // Simple replacements for common shell patterns\n // 1. Comments\n // 2. Keywords\n // 3. Variables\n\n const keywords = /\\b(if|then|else|elif|fi|for|in|do|done|while|case|esac|return|exit|export|source|echo|printf)\\b/g;\n\n return script.split('\\n').map(line => {\n if (line.trim().startsWith('#')) {\n return `${theme.muted}${line}${ANSI.RESET}`;\n }\n\n // Temporarily hide strings properly is hard with regex replace, \n // so we just do best-effort highlights for keywords and vars outside of checking quote context.\n const processed = line\n .replace(keywords, match => `${theme.syntax.boolean}${match}${ANSI.RESET}`)\n .replace(/(\\$[\\w\\d_]+|\\$\\{[^}]+\\})/g, match => `${theme.syntax.key}${match}${ANSI.RESET}`)\n .replace(/(\\s|^)(-{1,2}[a-zA-Z0-9_-]+)/g, (_match, prefix, flag) => `${prefix}${theme.syntax.number}${flag}${ANSI.RESET}`);\n\n return processed;\n }).join('\\n');\n}\n\n// --- 6. Properties Highlighter ---\nexport function highlightProperties(props: string): string {\n if (!props) return '';\n return props.split('\\n').map(line => {\n const trimmed = line.trim();\n // Supports # or ! for comments\n if (trimmed.startsWith('#') || trimmed.startsWith('!')) {\n return `${theme.muted}${line}${ANSI.RESET}`;\n }\n // Keys can be separated by = or :\n const match = line.match(/^([^=:]+)([=:])(.*)$/);\n if (match) {\n const [, key, sep, value] = match;\n return `${theme.syntax.key}${key}${theme.syntax.punctuation}${sep}${theme.syntax.string}${value}${ANSI.RESET}`;\n }\n return line;\n }).join('\\n');\n}\n\n// --- Main Mapping ---\nconst highlighters: Record<string, Highlighter> = {\n 'json': highlightJson,\n 'env': highlightEnv,\n 'toml': highlightToml,\n 'csv': highlightCsv,\n 'sh': highlightShell,\n 'bash': highlightShell,\n 'zsh': highlightShell,\n 'properties': highlightProperties,\n 'props': highlightProperties,\n 'conf': highlightProperties // loose convention\n};\n\nexport function highlight(code: string, language: string): string {\n const lang = language.toLowerCase();\n const highlightFunc = highlighters[lang];\n\n if (highlightFunc) {\n return highlightFunc(code);\n }\n\n // Fallback: If no highlighter found, return original code\n return code;\n}"],"names":["highlight","highlightCsv","highlightEnv","highlightJson","highlightProperties","highlightShell","highlightToml","json","tokenRegex","result","lastIndex","match","exec","index","substring","token","startsWith","remaining","test","theme","syntax","key","ANSI","RESET","string","number","null","boolean","punctuation","length","env","split","map","line","trim","muted","value","join","toml","trimmed","endsWith","fullMatch","keyPart","eqPart","rest","csv","colors","parts","part","color","script","keywords","processed","replace","_match","prefix","flag","props","sep","highlighters","code","language","lang","toLowerCase","highlightFunc"],"mappings":";;;;;;;;;;;QA8KgBA;eAAAA;;QA9EAC;eAAAA;;QAzCAC;eAAAA;;QAjDAC;eAAAA;;QAwIAC;eAAAA;;QA3BAC;eAAAA;;QA5CAC;eAAAA;;;sBAvEK;uBACC;AAKf,SAASH,cAAcI,IAAY;IACtC,IAAI,CAACA,MAAM,OAAO;IAClB,MAAMC,aAAa;IAEnB,IAAIC,SAAS;IACb,IAAIC,YAAY;IAChB,IAAIC;IAEJ,MAAO,AAACA,CAAAA,QAAQH,WAAWI,IAAI,CAACL,KAAI,MAAO,KAAM;QAC7C,IAAII,MAAME,KAAK,GAAGH,WAAW;YACzBD,UAAUF,KAAK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ACP,QAAQI;IACR,OAAOL;IACP,MAAMI;IACN,QAAQA;IACR,OAAOA;IACP,cAAcD;IACd,SAASA;IACT,QAAQA,oBAAoB,mBAAmB;AACnD;AAEO,SAASJ,UAAU4D,IAAY,EAAEC,QAAgB;IACpD,MAAMC,OAAOD,SAASE,WAAW;IACjC,MAAMC,gBAAgBL,YAAY,CAACG,KAAK;IAExC,IAAIE,eAAe;QACf,OAAOA,cAAcJ;IACzB;IAEA,0DAA0D;IAC1D,OAAOA;AACX"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Mep (A Interactive CLI Prompt)
3
+ * Export file
4
+ */ "use strict";
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ _export_star(require("./types"), exports);
9
+ _export_star(require("./core"), exports);
10
+ _export_star(require("./prompts/map"), exports);
11
+ _export_star(require("./prompts/semver"), exports);
12
+ _export_star(require("./prompts/ip"), exports);
13
+ _export_star(require("./prompts/kanban"), exports);
14
+ _export_star(require("./prompts/time"), exports);
15
+ _export_star(require("./prompts/heatmap"), exports);
16
+ _export_star(require("./prompts/byte"), exports);
17
+ _export_star(require("./prompts/slot"), exports);
18
+ _export_star(require("./prompts/gauge"), exports);
19
+ _export_star(require("./prompts/calculator"), exports);
20
+ _export_star(require("./prompts/emoji"), exports);
21
+ _export_star(require("./prompts/match"), exports);
22
+ _export_star(require("./prompts/diff"), exports);
23
+ _export_star(require("./prompts/dial"), exports);
24
+ _export_star(require("./prompts/draw"), exports);
25
+ _export_star(require("./prompts/multi-column-select"), exports);
26
+ _export_star(require("./prompts/fuzzy"), exports);
27
+ _export_star(require("./prompts/miller"), exports);
28
+ _export_star(require("./prompts/pattern"), exports);
29
+ _export_star(require("./prompts/region"), exports);
30
+ _export_star(require("./prompts/spreadsheet"), exports);
31
+ _export_star(require("./prompts/scroll"), exports);
32
+ _export_star(require("./prompts/breadcrumb"), exports);
33
+ _export_star(require("./prompts/schedule"), exports);
34
+ _export_star(require("./prompts/data-inspector"), exports);
35
+ _export_star(require("./prompts/exec"), exports);
36
+ _export_star(require("./prompts/shortcut"), exports);
37
+ _export_star(require("./prompts/seat"), exports);
38
+ _export_star(require("./prompts/select-range"), exports);
39
+ _export_star(require("./prompts/sort-grid"), exports);
40
+ _export_star(require("./prompts/dependency"), exports);
41
+ _export_star(require("./prompts/license"), exports);
42
+ _export_star(require("./prompts/regex"), exports);
43
+ _export_star(require("./prompts/box"), exports);
44
+ _export_star(require("./prompts/connection-string"), exports);
45
+ _export_star(require("./prompts/curl"), exports);
46
+ _export_star(require("./prompts/phone"), exports);
47
+ _export_star(require("./prompts/fuzzy-multi-column"), exports);
48
+ _export_star(require("./prompts/multi-range"), exports);
49
+ _export_star(require("./prompts/breadcrumb-search"), exports);
50
+ _export_star(require("./pipeline"), exports);
51
+ _export_star(require("./tasks"), exports);
52
+ function _export_star(from, to) {
53
+ Object.keys(from).forEach(function(k) {
54
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
55
+ Object.defineProperty(to, k, {
56
+ enumerable: true,
57
+ get: function() {
58
+ return from[k];
59
+ }
60
+ });
61
+ }
62
+ });
63
+ return from;
64
+ }
65
+
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * Mep (A Interactive CLI Prompt)\n * Export file\n */\n\nexport * from './types';\nexport * from './core';\nexport * from './prompts/map';\nexport * from './prompts/semver';\nexport * from './prompts/ip';\nexport * from './prompts/kanban';\nexport * from './prompts/time';\nexport * from './prompts/heatmap';\nexport * from './prompts/byte';\nexport * from './prompts/slot';\nexport * from './prompts/gauge';\nexport * from './prompts/calculator';\nexport * from './prompts/emoji';\nexport * from './prompts/match';\nexport * from './prompts/diff';\nexport * from './prompts/dial';\nexport * from './prompts/draw';\nexport * from './prompts/multi-column-select';\nexport * from './prompts/fuzzy';\nexport * from './prompts/miller';\nexport * from './prompts/pattern';\nexport * from './prompts/region';\nexport * from './prompts/spreadsheet';\nexport * from './prompts/scroll';\nexport * from './prompts/breadcrumb';\nexport * from './prompts/schedule';\nexport * from './prompts/data-inspector';\nexport * from './prompts/exec';\nexport * from './prompts/shortcut';\nexport * from './prompts/seat';\nexport * from './prompts/select-range';\nexport * from './prompts/sort-grid';\nexport * from './prompts/dependency';\nexport * from './prompts/license';\nexport * from './prompts/regex';\nexport * from './prompts/box';\nexport * from './prompts/connection-string';\nexport * from './prompts/curl';\nexport * from './prompts/phone';\nexport * from './prompts/fuzzy-multi-column';\nexport * from './prompts/multi-range';\nexport * from './prompts/breadcrumb-search';\nexport * from './pipeline';\nexport * from './tasks';\n"],"names":[],"mappings":"AAAA;;;CAGC;;;;qBAEa;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
@@ -1,21 +1,34 @@
1
- "use strict";
2
1
  // src/input.ts
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.InputParser = void 0;
5
- const events_1 = require("events");
6
- class InputParser extends events_1.EventEmitter {
7
- constructor() {
8
- super();
9
- this.buffer = '';
10
- this.timeout = null;
11
- this.state = 'NORMAL';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "InputParser", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return InputParser;
12
10
  }
11
+ });
12
+ const _events = require("events");
13
+ function _define_property(obj, key, value) {
14
+ if (key in obj) {
15
+ Object.defineProperty(obj, key, {
16
+ value: value,
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true
20
+ });
21
+ } else {
22
+ obj[key] = value;
23
+ }
24
+ return obj;
25
+ }
26
+ let InputParser = class InputParser extends _events.EventEmitter {
13
27
  /**
14
28
  * Feed data into the parser.
15
- */
16
- feed(data) {
29
+ */ feed(data) {
17
30
  const input = data.toString('utf-8');
18
- for (let i = 0; i < input.length; i++) {
31
+ for(let i = 0; i < input.length; i++){
19
32
  const char = input[i];
20
33
  this.processChar(char);
21
34
  }
@@ -26,38 +39,32 @@ class InputParser extends events_1.EventEmitter {
26
39
  this.state = 'ESC';
27
40
  this.buffer = char;
28
41
  // Start a short timeout to detect bare ESC
29
- this.timeout = setTimeout(() => {
42
+ this.timeout = setTimeout(()=>{
30
43
  this.emitKey(this.buffer);
31
44
  this.buffer = '';
32
45
  this.state = 'NORMAL';
33
46
  }, 20); // 20ms timeout
34
- }
35
- else {
47
+ } else {
36
48
  this.emitKey(char);
37
49
  }
38
- }
39
- else if (this.state === 'ESC') {
50
+ } else if (this.state === 'ESC') {
40
51
  // Cancel timeout as we received more data
41
- if (this.timeout)
42
- clearTimeout(this.timeout);
52
+ if (this.timeout) clearTimeout(this.timeout);
43
53
  this.timeout = null;
44
54
  this.buffer += char;
45
55
  if (char === '[') {
46
56
  this.state = 'CSI';
47
- }
48
- else if (char === 'O') {
57
+ } else if (char === 'O') {
49
58
  // SS3 sequence like \x1b O A (Application Cursor Keys)
50
59
  // Treat as similar to CSI for collecting the next char
51
60
  this.state = 'CSI';
52
- }
53
- else {
61
+ } else {
54
62
  // Alt + Key or similar (\x1b + char)
55
63
  this.emitKey(this.buffer);
56
64
  this.buffer = '';
57
65
  this.state = 'NORMAL';
58
66
  }
59
- }
60
- else if (this.state === 'CSI') {
67
+ } else if (this.state === 'CSI') {
61
68
  this.buffer += char;
62
69
  if (char === '<') {
63
70
  this.state = 'MOUSE_SGR';
@@ -70,9 +77,8 @@ class InputParser extends events_1.EventEmitter {
70
77
  this.buffer = '';
71
78
  this.state = 'NORMAL';
72
79
  }
73
- // Otherwise, we keep buffering (params like 1;2)
74
- }
75
- else if (this.state === 'MOUSE_SGR') {
80
+ // Otherwise, we keep buffering (params like 1;2)
81
+ } else if (this.state === 'MOUSE_SGR') {
76
82
  this.buffer += char;
77
83
  // SGR sequences end with 'm' (release) or 'M' (press)
78
84
  if (char === 'm' || char === 'M') {
@@ -102,7 +108,7 @@ class InputParser extends events_1.EventEmitter {
102
108
  // 64: Scroll (bit 6)
103
109
  if (b & 64) {
104
110
  action = 'scroll';
105
- const scroll = (b & 1) ? 'down' : 'up';
111
+ const scroll = b & 1 ? 'down' : 'up';
106
112
  this.emit('mouse', {
107
113
  name: 'mouse',
108
114
  x,
@@ -114,16 +120,13 @@ class InputParser extends events_1.EventEmitter {
114
120
  ctrl,
115
121
  meta
116
122
  });
117
- if (scroll === 'up')
118
- this.emit('scrollup');
119
- else
120
- this.emit('scrolldown');
123
+ if (scroll === 'up') this.emit('scrollup');
124
+ else this.emit('scrolldown');
121
125
  return;
122
126
  }
123
127
  if (type === 'm') {
124
128
  action = 'release';
125
- }
126
- else {
129
+ } else {
127
130
  action = 'press';
128
131
  // Check if motion
129
132
  if (b & 32) {
@@ -134,7 +137,7 @@ class InputParser extends events_1.EventEmitter {
134
137
  name: 'mouse',
135
138
  x,
136
139
  y,
137
- button: b & 3, // Strip modifiers to get raw button 0-2
140
+ button: b & 3,
138
141
  action,
139
142
  shift,
140
143
  ctrl,
@@ -144,9 +147,12 @@ class InputParser extends events_1.EventEmitter {
144
147
  }
145
148
  emitKey(key) {
146
149
  // Normalize Enter
147
- if (key === '\r')
148
- key = '\n';
150
+ if (key === '\r') key = '\n';
149
151
  this.emit('keypress', key, Buffer.from(key));
150
152
  }
151
- }
152
- exports.InputParser = InputParser;
153
+ constructor(){
154
+ super(), _define_property(this, "buffer", ''), _define_property(this, "timeout", null), _define_property(this, "state", 'NORMAL');
155
+ }
156
+ };
157
+
158
+ //# sourceMappingURL=input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/input.ts"],"sourcesContent":["// src/input.ts\n\nimport { EventEmitter } from 'events';\n\nexport class InputParser extends EventEmitter {\n private buffer: string = '';\n private timeout: NodeJS.Timeout | null = null;\n private state: 'NORMAL' | 'ESC' | 'CSI' | 'MOUSE_SGR' = 'NORMAL';\n\n constructor() {\n super();\n }\n\n /**\n * Feed data into the parser.\n */\n public feed(data: Buffer) {\n\n const input = data.toString('utf-8');\n\n for (let i = 0; i < input.length; i++) {\n const char = input[i];\n this.processChar(char);\n }\n }\n\n private processChar(char: string) {\n if (this.state === 'NORMAL') {\n if (char === '\\x1b') {\n this.state = 'ESC';\n this.buffer = char;\n // Start a short timeout to detect bare ESC\n this.timeout = setTimeout(() => {\n this.emitKey(this.buffer);\n this.buffer = '';\n this.state = 'NORMAL';\n }, 20); // 20ms timeout\n } else {\n this.emitKey(char);\n }\n } else if (this.state === 'ESC') {\n // Cancel timeout as we received more data\n if (this.timeout) clearTimeout(this.timeout);\n this.timeout = null;\n\n this.buffer += char;\n\n if (char === '[') {\n this.state = 'CSI';\n } else if (char === 'O') {\n // SS3 sequence like \\x1b O A (Application Cursor Keys)\n // Treat as similar to CSI for collecting the next char\n this.state = 'CSI';\n } else {\n // Alt + Key or similar (\\x1b + char)\n this.emitKey(this.buffer);\n this.buffer = '';\n this.state = 'NORMAL';\n }\n } else if (this.state === 'CSI') {\n this.buffer += char;\n\n if (char === '<') {\n this.state = 'MOUSE_SGR';\n this.buffer = '<';\n return;\n }\n\n // CSI sequences end with 0x40-0x7E\n if (char >= '@' && char <= '~') {\n this.emitKey(this.buffer);\n this.buffer = '';\n this.state = 'NORMAL';\n }\n // Otherwise, we keep buffering (params like 1;2)\n } else if (this.state === 'MOUSE_SGR') {\n this.buffer += char;\n // SGR sequences end with 'm' (release) or 'M' (press)\n if (char === 'm' || char === 'M') {\n this.parseSGRMouse(this.buffer);\n this.buffer = '';\n this.state = 'NORMAL';\n }\n }\n }\n\n private parseSGRMouse(buffer: string) {\n // console.log('Parsing SGR:', buffer);\n // format: <b;x;yM or <b;x;ym\n // buffer includes the leading < and trailing M/m\n const content = buffer.slice(1, -1);\n const type = buffer.slice(-1); // m or M\n const parts = content.split(';').map(Number);\n\n if (parts.length >= 3) {\n const [b, x, y] = parts;\n let action: 'press' | 'release' | 'move' | 'scroll' = 'press';\n\n // Extract modifiers\n const shift = !!(b & 4);\n const meta = !!(b & 8);\n const ctrl = !!(b & 16);\n\n // Interpret button codes\n // 0: Left, 1: Middle, 2: Right\n // +32: Motion\n // 64: Scroll (bit 6)\n\n if (b & 64) {\n action = 'scroll';\n const scroll = (b & 1) ? 'down' : 'up';\n this.emit('mouse', {\n name: 'mouse',\n x,\n y,\n button: 0,\n action,\n scroll,\n shift,\n ctrl,\n meta\n });\n if (scroll === 'up') this.emit('scrollup');\n else this.emit('scrolldown');\n return;\n }\n\n if (type === 'm') {\n action = 'release';\n } else {\n action = 'press';\n // Check if motion\n if (b & 32) {\n action = 'move';\n }\n }\n\n this.emit('mouse', {\n name: 'mouse',\n x,\n y,\n button: b & 3, // Strip modifiers to get raw button 0-2\n action,\n shift,\n ctrl,\n meta\n });\n }\n }\n\n private emitKey(key: string) {\n // Normalize Enter\n if (key === '\\r') key = '\\n';\n\n this.emit('keypress', key, Buffer.from(key));\n }\n}\n"],"names":["InputParser","EventEmitter","feed","data","input","toString","i","length","char","processChar","state","buffer","timeout","setTimeout","emitKey","clearTimeout","parseSGRMouse","content","slice","type","parts","split","map","Number","b","x","y","action","shift","meta","ctrl","scroll","emit","name","button","key","Buffer","from"],"mappings":"AAAA,eAAe;;;;;+BAIFA;;;eAAAA;;;wBAFgB;;;;;;;;;;;;;;AAEtB,IAAA,AAAMA,cAAN,MAAMA,oBAAoBC,oBAAY;IASzC;;KAEC,GACD,AAAOC,KAAKC,IAAY,EAAE;QAEtB,MAAMC,QAAQD,KAAKE,QAAQ,CAAC;QAE5B,IAAK,IAAIC,IAAI,GAAGA,IAAIF,MAAMG,MAAM,EAAED,IAAK;YACnC,MAAME,OAAOJ,KAAK,CAACE,EAAE;YACrB,IAAI,CAACG,WAAW,CAACD;QACrB;IACJ;IAEQ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