@softwarefactory-project/re-ansi 0.6.0 → 0.7.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 +12 -4
- package/package.json +17 -14
- package/{bsconfig.json → rescript.json} +6 -7
- package/src/{Ansi.re → Ansi.res} +57 -54
- package/src/Ansi.res.js +919 -0
- package/src/Ansi.bs.js +0 -969
- package/src/old.js +0 -0
package/src/Ansi.bs.js
DELETED
|
@@ -1,969 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var Curry = require("bs-platform/lib/js/curry.js");
|
|
4
|
-
var React = require("react");
|
|
5
|
-
var Belt_List = require("bs-platform/lib/js/belt_List.js");
|
|
6
|
-
var Belt_Option = require("bs-platform/lib/js/belt_Option.js");
|
|
7
|
-
var Caml_option = require("bs-platform/lib/js/caml_option.js");
|
|
8
|
-
|
|
9
|
-
function fourBitColors(code) {
|
|
10
|
-
switch (code) {
|
|
11
|
-
case 0 :
|
|
12
|
-
return "black";
|
|
13
|
-
case 1 :
|
|
14
|
-
return "red";
|
|
15
|
-
case 2 :
|
|
16
|
-
return "green";
|
|
17
|
-
case 3 :
|
|
18
|
-
return "yellow";
|
|
19
|
-
case 4 :
|
|
20
|
-
return "blue";
|
|
21
|
-
case 5 :
|
|
22
|
-
return "magenta";
|
|
23
|
-
case 6 :
|
|
24
|
-
return "cyan";
|
|
25
|
-
case 8 :
|
|
26
|
-
console.log("Unknown color value:", code);
|
|
27
|
-
return ;
|
|
28
|
-
case 9 :
|
|
29
|
-
return "initial";
|
|
30
|
-
case 10 :
|
|
31
|
-
return "grey";
|
|
32
|
-
case 11 :
|
|
33
|
-
return "#DA2647";
|
|
34
|
-
case 12 :
|
|
35
|
-
return "#87FF2A";
|
|
36
|
-
case 13 :
|
|
37
|
-
return "#FFF700";
|
|
38
|
-
case 14 :
|
|
39
|
-
return "#5DADEC";
|
|
40
|
-
case 15 :
|
|
41
|
-
return "#FF3399";
|
|
42
|
-
case 16 :
|
|
43
|
-
return "#8DD9CC";
|
|
44
|
-
case 7 :
|
|
45
|
-
case 17 :
|
|
46
|
-
return "white";
|
|
47
|
-
default:
|
|
48
|
-
console.log("Unknown color value:", code);
|
|
49
|
-
return ;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function threeBitColors(code) {
|
|
54
|
-
switch (code) {
|
|
55
|
-
case 0 :
|
|
56
|
-
return "grey";
|
|
57
|
-
case 1 :
|
|
58
|
-
return "red";
|
|
59
|
-
case 2 :
|
|
60
|
-
return "green";
|
|
61
|
-
case 3 :
|
|
62
|
-
return "yellow";
|
|
63
|
-
case 4 :
|
|
64
|
-
return "blue";
|
|
65
|
-
case 5 :
|
|
66
|
-
return "magenta";
|
|
67
|
-
case 6 :
|
|
68
|
-
return "cyan";
|
|
69
|
-
case 7 :
|
|
70
|
-
return "white";
|
|
71
|
-
default:
|
|
72
|
-
console.log("Unknown color value:", code);
|
|
73
|
-
return ;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function combine(css1, css2) {
|
|
78
|
-
return Object.assign({}, css1, css2);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function addWeight(fontWeight) {
|
|
82
|
-
return {
|
|
83
|
-
fontWeight: fontWeight
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function addStyle(fontStyle) {
|
|
88
|
-
return {
|
|
89
|
-
fontStyle: fontStyle
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function addDecoration(textDecoration) {
|
|
94
|
-
return {
|
|
95
|
-
textDecoration: textDecoration
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function int_of_cp(c) {
|
|
100
|
-
return c - 48 | 0;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function getColorStyle(colorMode, colorValue) {
|
|
104
|
-
switch (colorMode) {
|
|
105
|
-
case 3 :
|
|
106
|
-
return {
|
|
107
|
-
TAG: /* Foreground */0,
|
|
108
|
-
_0: colorValue
|
|
109
|
-
};
|
|
110
|
-
case 0 :
|
|
111
|
-
case 4 :
|
|
112
|
-
return {
|
|
113
|
-
TAG: /* Background */2,
|
|
114
|
-
_0: colorValue
|
|
115
|
-
};
|
|
116
|
-
case 1 :
|
|
117
|
-
case 2 :
|
|
118
|
-
case 5 :
|
|
119
|
-
case 6 :
|
|
120
|
-
case 7 :
|
|
121
|
-
case 8 :
|
|
122
|
-
break;
|
|
123
|
-
case 9 :
|
|
124
|
-
return {
|
|
125
|
-
TAG: /* BrightForeground */1,
|
|
126
|
-
_0: colorValue
|
|
127
|
-
};
|
|
128
|
-
default:
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
console.log("Unknown color code:", colorMode, colorValue);
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function getColorStyleCss(color) {
|
|
136
|
-
switch (color.TAG | 0) {
|
|
137
|
-
case /* Foreground */0 :
|
|
138
|
-
return Belt_Option.flatMap(fourBitColors(color._0), (function (color) {
|
|
139
|
-
return {
|
|
140
|
-
color: color
|
|
141
|
-
};
|
|
142
|
-
}));
|
|
143
|
-
case /* BrightForeground */1 :
|
|
144
|
-
return Belt_Option.flatMap(threeBitColors(color._0), (function (color) {
|
|
145
|
-
return {
|
|
146
|
-
color: color,
|
|
147
|
-
fontWeight: "bold"
|
|
148
|
-
};
|
|
149
|
-
}));
|
|
150
|
-
case /* Background */2 :
|
|
151
|
-
return Belt_Option.flatMap(fourBitColors(color._0), (function (background) {
|
|
152
|
-
return {
|
|
153
|
-
background: background
|
|
154
|
-
};
|
|
155
|
-
}));
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function get(colorMode, colorValue) {
|
|
161
|
-
return Belt_Option.flatMap(getColorStyle(colorMode - 48 | 0, colorValue - 48 | 0), getColorStyleCss);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
var ColorCss = {
|
|
165
|
-
getColorStyle: getColorStyle,
|
|
166
|
-
getColorStyleCss: getColorStyleCss,
|
|
167
|
-
get: get
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
function getFontStyle(fontMode) {
|
|
171
|
-
switch (fontMode) {
|
|
172
|
-
case 1 :
|
|
173
|
-
return /* FontStyle */{
|
|
174
|
-
_0: addWeight("bold")
|
|
175
|
-
};
|
|
176
|
-
case 2 :
|
|
177
|
-
return /* FontStyle */{
|
|
178
|
-
_0: addWeight("lighter")
|
|
179
|
-
};
|
|
180
|
-
case 3 :
|
|
181
|
-
return /* FontStyle */{
|
|
182
|
-
_0: addStyle("italic")
|
|
183
|
-
};
|
|
184
|
-
case 4 :
|
|
185
|
-
return /* FontStyle */{
|
|
186
|
-
_0: addDecoration("underline")
|
|
187
|
-
};
|
|
188
|
-
case 0 :
|
|
189
|
-
case 7 :
|
|
190
|
-
return /* Regular */0;
|
|
191
|
-
case 5 :
|
|
192
|
-
case 6 :
|
|
193
|
-
case 8 :
|
|
194
|
-
return ;
|
|
195
|
-
case 9 :
|
|
196
|
-
return /* FontStyle */{
|
|
197
|
-
_0: addDecoration("line-through")
|
|
198
|
-
};
|
|
199
|
-
default:
|
|
200
|
-
return ;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function getFontStyleCss(font) {
|
|
205
|
-
if (font) {
|
|
206
|
-
return Caml_option.some(font._0);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
function get$1(fontMode) {
|
|
212
|
-
return Belt_Option.flatMap(getFontStyle(fontMode - 48 | 0), getFontStyleCss);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
var FontCss = {
|
|
216
|
-
getFontStyle: getFontStyle,
|
|
217
|
-
getFontStyleCss: getFontStyleCss,
|
|
218
|
-
get: get$1
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
var linkRe = /^(http(s)?:\/\/[^\s]+)/;
|
|
222
|
-
|
|
223
|
-
function get$2(txt) {
|
|
224
|
-
return Belt_Option.getWithDefault(Belt_Option.flatMap(Caml_option.null_to_opt(linkRe.exec(txt)), (function (res) {
|
|
225
|
-
return Belt_Option.flatMap(res.length !== 3 ? undefined : Caml_option.nullable_to_opt(res[0]), (function (url) {
|
|
226
|
-
return [
|
|
227
|
-
url.length,
|
|
228
|
-
{
|
|
229
|
-
TAG: /* HRef */0,
|
|
230
|
-
_0: url
|
|
231
|
-
}
|
|
232
|
-
];
|
|
233
|
-
}));
|
|
234
|
-
})), [
|
|
235
|
-
1,
|
|
236
|
-
undefined
|
|
237
|
-
]);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
var HttpLink = {
|
|
241
|
-
linkRe: linkRe,
|
|
242
|
-
get: get$2
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
function parse(txt, pos) {
|
|
246
|
-
var match = txt.codePointAt(pos);
|
|
247
|
-
var exit = 0;
|
|
248
|
-
if (match === undefined) {
|
|
249
|
-
return [
|
|
250
|
-
0,
|
|
251
|
-
undefined
|
|
252
|
-
];
|
|
253
|
-
}
|
|
254
|
-
if (match >= 14) {
|
|
255
|
-
if (match !== 27) {
|
|
256
|
-
if (match !== 104) {
|
|
257
|
-
return [
|
|
258
|
-
0,
|
|
259
|
-
undefined
|
|
260
|
-
];
|
|
261
|
-
}
|
|
262
|
-
var func = function (param, param$1) {
|
|
263
|
-
return param$1.slice(pos, param);
|
|
264
|
-
};
|
|
265
|
-
return get$2(Curry._2(func, 512, txt));
|
|
266
|
-
}
|
|
267
|
-
exit = 1;
|
|
268
|
-
} else {
|
|
269
|
-
if (match === 10) {
|
|
270
|
-
return [
|
|
271
|
-
1,
|
|
272
|
-
/* CarriageReturn */2
|
|
273
|
-
];
|
|
274
|
-
}
|
|
275
|
-
if (match < 13) {
|
|
276
|
-
return [
|
|
277
|
-
0,
|
|
278
|
-
undefined
|
|
279
|
-
];
|
|
280
|
-
}
|
|
281
|
-
exit = 1;
|
|
282
|
-
}
|
|
283
|
-
if (exit === 1) {
|
|
284
|
-
var cps = function (_idx, _acc) {
|
|
285
|
-
while(true) {
|
|
286
|
-
var acc = _acc;
|
|
287
|
-
var idx = _idx;
|
|
288
|
-
var match = idx > 10;
|
|
289
|
-
var match$1 = txt.codePointAt(pos + idx | 0);
|
|
290
|
-
if (match) {
|
|
291
|
-
return acc;
|
|
292
|
-
}
|
|
293
|
-
if (match$1 === undefined) {
|
|
294
|
-
return acc;
|
|
295
|
-
}
|
|
296
|
-
if (match$1 === 109) {
|
|
297
|
-
return acc;
|
|
298
|
-
}
|
|
299
|
-
_acc = Belt_List.add(acc, match$1);
|
|
300
|
-
_idx = idx + 1 | 0;
|
|
301
|
-
continue ;
|
|
302
|
-
};
|
|
303
|
-
};
|
|
304
|
-
var codePoints = Belt_List.reverse(cps(1, /* [] */0));
|
|
305
|
-
var length = Belt_List.length(codePoints) + 2 | 0;
|
|
306
|
-
var exit$1 = 0;
|
|
307
|
-
var colorMode;
|
|
308
|
-
var colorValue;
|
|
309
|
-
var xs;
|
|
310
|
-
var colorMode$1;
|
|
311
|
-
var colorValue$1;
|
|
312
|
-
var style;
|
|
313
|
-
var style$1;
|
|
314
|
-
var cm1;
|
|
315
|
-
var cv1;
|
|
316
|
-
var cm2;
|
|
317
|
-
var cv2;
|
|
318
|
-
var xs$1;
|
|
319
|
-
if (!codePoints) {
|
|
320
|
-
return [
|
|
321
|
-
1,
|
|
322
|
-
undefined
|
|
323
|
-
];
|
|
324
|
-
}
|
|
325
|
-
var match$1 = codePoints.hd;
|
|
326
|
-
if (match$1 !== 10) {
|
|
327
|
-
if (match$1 !== 91) {
|
|
328
|
-
return [
|
|
329
|
-
1,
|
|
330
|
-
undefined
|
|
331
|
-
];
|
|
332
|
-
}
|
|
333
|
-
var match$2 = codePoints.tl;
|
|
334
|
-
if (!match$2) {
|
|
335
|
-
return [
|
|
336
|
-
length,
|
|
337
|
-
/* Clear */0
|
|
338
|
-
];
|
|
339
|
-
}
|
|
340
|
-
var style$2 = match$2.hd;
|
|
341
|
-
var exit$2 = 0;
|
|
342
|
-
var exit$3 = 0;
|
|
343
|
-
var match$3 = match$2.tl;
|
|
344
|
-
if (match$3) {
|
|
345
|
-
if (match$3.hd === 75) {
|
|
346
|
-
return [
|
|
347
|
-
4,
|
|
348
|
-
/* EraseLine */1
|
|
349
|
-
];
|
|
350
|
-
}
|
|
351
|
-
exit$3 = 6;
|
|
352
|
-
} else {
|
|
353
|
-
exit$3 = 6;
|
|
354
|
-
}
|
|
355
|
-
if (exit$3 === 6) {
|
|
356
|
-
var switcher = style$2 - 48 | 0;
|
|
357
|
-
if (switcher === 0 || switcher === 1) {
|
|
358
|
-
if (switcher !== 0) {
|
|
359
|
-
var match$4 = match$2.tl;
|
|
360
|
-
if (match$4) {
|
|
361
|
-
var match$5 = match$4.tl;
|
|
362
|
-
if (match$5 && !match$5.tl) {
|
|
363
|
-
colorMode = match$4.hd;
|
|
364
|
-
colorValue = match$5.hd;
|
|
365
|
-
xs = codePoints;
|
|
366
|
-
exit$1 = 2;
|
|
367
|
-
} else {
|
|
368
|
-
exit$2 = 5;
|
|
369
|
-
}
|
|
370
|
-
} else {
|
|
371
|
-
exit$2 = 5;
|
|
372
|
-
}
|
|
373
|
-
} else {
|
|
374
|
-
var match$6 = match$2.tl;
|
|
375
|
-
if (!match$6) {
|
|
376
|
-
return [
|
|
377
|
-
length,
|
|
378
|
-
/* Clear */0
|
|
379
|
-
];
|
|
380
|
-
}
|
|
381
|
-
var style$3 = match$6.hd;
|
|
382
|
-
var exit$4 = 0;
|
|
383
|
-
if (style$3 !== 48) {
|
|
384
|
-
exit$4 = 7;
|
|
385
|
-
} else {
|
|
386
|
-
if (!match$6.tl) {
|
|
387
|
-
return [
|
|
388
|
-
length,
|
|
389
|
-
/* Clear */0
|
|
390
|
-
];
|
|
391
|
-
}
|
|
392
|
-
exit$4 = 7;
|
|
393
|
-
}
|
|
394
|
-
if (exit$4 === 7) {
|
|
395
|
-
var match$7 = match$6.tl;
|
|
396
|
-
if (match$7 && match$7.hd === 59) {
|
|
397
|
-
var match$8 = match$7.tl;
|
|
398
|
-
if (!match$8) {
|
|
399
|
-
return [
|
|
400
|
-
1,
|
|
401
|
-
undefined
|
|
402
|
-
];
|
|
403
|
-
}
|
|
404
|
-
var match$9 = match$8.tl;
|
|
405
|
-
if (match$9) {
|
|
406
|
-
var match$10 = match$9.tl;
|
|
407
|
-
var colorValue$2 = match$9.hd;
|
|
408
|
-
var colorMode$2 = match$8.hd;
|
|
409
|
-
if (match$10) {
|
|
410
|
-
if (match$10.hd !== 59) {
|
|
411
|
-
exit$2 = 5;
|
|
412
|
-
} else {
|
|
413
|
-
var match$11 = match$10.tl;
|
|
414
|
-
if (!match$11) {
|
|
415
|
-
return [
|
|
416
|
-
1,
|
|
417
|
-
undefined
|
|
418
|
-
];
|
|
419
|
-
}
|
|
420
|
-
var cm2$1 = match$11.hd;
|
|
421
|
-
var match$12 = match$11.tl;
|
|
422
|
-
if (match$12) {
|
|
423
|
-
if (match$12.tl) {
|
|
424
|
-
if (cm2$1 !== 49) {
|
|
425
|
-
exit$2 = 5;
|
|
426
|
-
} else {
|
|
427
|
-
var match$13 = match$11.tl;
|
|
428
|
-
var match$14 = match$13.tl;
|
|
429
|
-
if (match$14.tl) {
|
|
430
|
-
return [
|
|
431
|
-
1,
|
|
432
|
-
undefined
|
|
433
|
-
];
|
|
434
|
-
}
|
|
435
|
-
style$1 = style$3;
|
|
436
|
-
cm1 = colorMode$2;
|
|
437
|
-
cv1 = colorValue$2;
|
|
438
|
-
cm2 = match$13.hd;
|
|
439
|
-
cv2 = match$14.hd;
|
|
440
|
-
xs$1 = codePoints;
|
|
441
|
-
exit$1 = 4;
|
|
442
|
-
}
|
|
443
|
-
} else {
|
|
444
|
-
style$1 = style$3;
|
|
445
|
-
cm1 = colorMode$2;
|
|
446
|
-
cv1 = colorValue$2;
|
|
447
|
-
cm2 = cm2$1;
|
|
448
|
-
cv2 = match$12.hd;
|
|
449
|
-
xs$1 = codePoints;
|
|
450
|
-
exit$1 = 4;
|
|
451
|
-
}
|
|
452
|
-
} else {
|
|
453
|
-
exit$2 = 5;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
} else {
|
|
457
|
-
colorMode$1 = colorMode$2;
|
|
458
|
-
colorValue$1 = colorValue$2;
|
|
459
|
-
style = style$3;
|
|
460
|
-
exit$1 = 3;
|
|
461
|
-
}
|
|
462
|
-
} else {
|
|
463
|
-
exit$2 = 5;
|
|
464
|
-
}
|
|
465
|
-
} else {
|
|
466
|
-
exit$2 = 5;
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
} else {
|
|
472
|
-
if (switcher === 27) {
|
|
473
|
-
return [
|
|
474
|
-
3,
|
|
475
|
-
/* EraseLine */1
|
|
476
|
-
];
|
|
477
|
-
}
|
|
478
|
-
exit$2 = 5;
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
if (exit$2 === 5) {
|
|
482
|
-
var match$15 = match$2.tl;
|
|
483
|
-
if (!match$15) {
|
|
484
|
-
return [
|
|
485
|
-
length,
|
|
486
|
-
Belt_Option.flatMap(get$1(style$2), (function (style) {
|
|
487
|
-
return {
|
|
488
|
-
TAG: /* Style */1,
|
|
489
|
-
_0: style
|
|
490
|
-
};
|
|
491
|
-
}))
|
|
492
|
-
];
|
|
493
|
-
}
|
|
494
|
-
var colorValue$3 = match$15.hd;
|
|
495
|
-
var exit$5 = 0;
|
|
496
|
-
var match$16 = match$15.tl;
|
|
497
|
-
if (match$16) {
|
|
498
|
-
if (match$16.hd !== 59) {
|
|
499
|
-
exit$5 = 6;
|
|
500
|
-
} else {
|
|
501
|
-
var match$17 = match$16.tl;
|
|
502
|
-
if (!match$17) {
|
|
503
|
-
return [
|
|
504
|
-
1,
|
|
505
|
-
undefined
|
|
506
|
-
];
|
|
507
|
-
}
|
|
508
|
-
if (match$17.tl) {
|
|
509
|
-
exit$5 = 6;
|
|
510
|
-
} else {
|
|
511
|
-
colorMode$1 = style$2;
|
|
512
|
-
colorValue$1 = colorValue$3;
|
|
513
|
-
style = match$17.hd;
|
|
514
|
-
exit$1 = 3;
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
} else {
|
|
518
|
-
colorMode = style$2;
|
|
519
|
-
colorValue = colorValue$3;
|
|
520
|
-
xs = codePoints;
|
|
521
|
-
exit$1 = 2;
|
|
522
|
-
}
|
|
523
|
-
if (exit$5 === 6) {
|
|
524
|
-
if (colorValue$3 !== 59) {
|
|
525
|
-
return [
|
|
526
|
-
1,
|
|
527
|
-
undefined
|
|
528
|
-
];
|
|
529
|
-
}
|
|
530
|
-
var match$18 = match$15.tl;
|
|
531
|
-
var match$19 = match$18.tl;
|
|
532
|
-
if (!match$19) {
|
|
533
|
-
return [
|
|
534
|
-
1,
|
|
535
|
-
undefined
|
|
536
|
-
];
|
|
537
|
-
}
|
|
538
|
-
var match$20 = match$19.tl;
|
|
539
|
-
var colorValue$4 = match$19.hd;
|
|
540
|
-
var colorMode$3 = match$18.hd;
|
|
541
|
-
if (match$20) {
|
|
542
|
-
if (match$20.hd !== 59) {
|
|
543
|
-
return [
|
|
544
|
-
1,
|
|
545
|
-
undefined
|
|
546
|
-
];
|
|
547
|
-
}
|
|
548
|
-
var match$21 = match$20.tl;
|
|
549
|
-
if (!match$21) {
|
|
550
|
-
return [
|
|
551
|
-
1,
|
|
552
|
-
undefined
|
|
553
|
-
];
|
|
554
|
-
}
|
|
555
|
-
var cm2$2 = match$21.hd;
|
|
556
|
-
var match$22 = match$21.tl;
|
|
557
|
-
if (!match$22) {
|
|
558
|
-
return [
|
|
559
|
-
1,
|
|
560
|
-
undefined
|
|
561
|
-
];
|
|
562
|
-
}
|
|
563
|
-
if (match$22.tl) {
|
|
564
|
-
if (cm2$2 !== 49) {
|
|
565
|
-
return [
|
|
566
|
-
1,
|
|
567
|
-
undefined
|
|
568
|
-
];
|
|
569
|
-
}
|
|
570
|
-
var match$23 = match$21.tl;
|
|
571
|
-
var match$24 = match$23.tl;
|
|
572
|
-
if (match$24.tl) {
|
|
573
|
-
return [
|
|
574
|
-
1,
|
|
575
|
-
undefined
|
|
576
|
-
];
|
|
577
|
-
}
|
|
578
|
-
style$1 = style$2;
|
|
579
|
-
cm1 = colorMode$3;
|
|
580
|
-
cv1 = colorValue$4;
|
|
581
|
-
cm2 = match$23.hd;
|
|
582
|
-
cv2 = match$24.hd;
|
|
583
|
-
xs$1 = codePoints;
|
|
584
|
-
exit$1 = 4;
|
|
585
|
-
} else {
|
|
586
|
-
style$1 = style$2;
|
|
587
|
-
cm1 = colorMode$3;
|
|
588
|
-
cv1 = colorValue$4;
|
|
589
|
-
cm2 = cm2$2;
|
|
590
|
-
cv2 = match$22.hd;
|
|
591
|
-
xs$1 = codePoints;
|
|
592
|
-
exit$1 = 4;
|
|
593
|
-
}
|
|
594
|
-
} else {
|
|
595
|
-
colorMode$1 = colorMode$3;
|
|
596
|
-
colorValue$1 = colorValue$4;
|
|
597
|
-
style = style$2;
|
|
598
|
-
exit$1 = 3;
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
} else {
|
|
605
|
-
var match$25 = codePoints.tl;
|
|
606
|
-
if (!match$25) {
|
|
607
|
-
return [
|
|
608
|
-
1,
|
|
609
|
-
undefined
|
|
610
|
-
];
|
|
611
|
-
}
|
|
612
|
-
if (match$25.hd !== 27) {
|
|
613
|
-
return [
|
|
614
|
-
1,
|
|
615
|
-
undefined
|
|
616
|
-
];
|
|
617
|
-
}
|
|
618
|
-
var match$26 = match$25.tl;
|
|
619
|
-
if (!match$26) {
|
|
620
|
-
return [
|
|
621
|
-
1,
|
|
622
|
-
undefined
|
|
623
|
-
];
|
|
624
|
-
}
|
|
625
|
-
if (match$26.hd !== 91) {
|
|
626
|
-
return [
|
|
627
|
-
1,
|
|
628
|
-
undefined
|
|
629
|
-
];
|
|
630
|
-
}
|
|
631
|
-
var match$27 = match$26.tl;
|
|
632
|
-
if (!match$27) {
|
|
633
|
-
return [
|
|
634
|
-
1,
|
|
635
|
-
undefined
|
|
636
|
-
];
|
|
637
|
-
}
|
|
638
|
-
if (match$27.hd !== 49) {
|
|
639
|
-
return [
|
|
640
|
-
1,
|
|
641
|
-
undefined
|
|
642
|
-
];
|
|
643
|
-
}
|
|
644
|
-
var match$28 = match$27.tl;
|
|
645
|
-
if (!match$28) {
|
|
646
|
-
return [
|
|
647
|
-
1,
|
|
648
|
-
undefined
|
|
649
|
-
];
|
|
650
|
-
}
|
|
651
|
-
if (match$28.hd !== 65) {
|
|
652
|
-
return [
|
|
653
|
-
1,
|
|
654
|
-
undefined
|
|
655
|
-
];
|
|
656
|
-
}
|
|
657
|
-
var match$29 = match$28.tl;
|
|
658
|
-
if (!match$29) {
|
|
659
|
-
return [
|
|
660
|
-
1,
|
|
661
|
-
undefined
|
|
662
|
-
];
|
|
663
|
-
}
|
|
664
|
-
if (match$29.hd !== 27) {
|
|
665
|
-
return [
|
|
666
|
-
1,
|
|
667
|
-
undefined
|
|
668
|
-
];
|
|
669
|
-
}
|
|
670
|
-
var match$30 = match$29.tl;
|
|
671
|
-
if (!match$30) {
|
|
672
|
-
return [
|
|
673
|
-
1,
|
|
674
|
-
undefined
|
|
675
|
-
];
|
|
676
|
-
}
|
|
677
|
-
if (match$30.hd !== 91) {
|
|
678
|
-
return [
|
|
679
|
-
1,
|
|
680
|
-
undefined
|
|
681
|
-
];
|
|
682
|
-
}
|
|
683
|
-
var match$31 = match$30.tl;
|
|
684
|
-
if (match$31 && match$31.hd === 74) {
|
|
685
|
-
return [
|
|
686
|
-
9,
|
|
687
|
-
/* EraseLine */1
|
|
688
|
-
];
|
|
689
|
-
} else {
|
|
690
|
-
return [
|
|
691
|
-
1,
|
|
692
|
-
undefined
|
|
693
|
-
];
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
switch (exit$1) {
|
|
697
|
-
case 2 :
|
|
698
|
-
return [
|
|
699
|
-
length,
|
|
700
|
-
Belt_Option.flatMap(get(colorMode, colorValue + (
|
|
701
|
-
Belt_List.length(xs) === 4 ? 10 : 0
|
|
702
|
-
) | 0), (function (colorCss) {
|
|
703
|
-
return {
|
|
704
|
-
TAG: /* Style */1,
|
|
705
|
-
_0: colorCss
|
|
706
|
-
};
|
|
707
|
-
}))
|
|
708
|
-
];
|
|
709
|
-
case 3 :
|
|
710
|
-
return [
|
|
711
|
-
length,
|
|
712
|
-
Belt_Option.flatMap(get(colorMode$1, colorValue$1), (function (colorCss) {
|
|
713
|
-
var fontCss = get$1(style);
|
|
714
|
-
if (fontCss !== undefined) {
|
|
715
|
-
return {
|
|
716
|
-
TAG: /* Style */1,
|
|
717
|
-
_0: Object.assign({}, colorCss, Caml_option.valFromOption(fontCss))
|
|
718
|
-
};
|
|
719
|
-
} else {
|
|
720
|
-
return {
|
|
721
|
-
TAG: /* Style */1,
|
|
722
|
-
_0: colorCss
|
|
723
|
-
};
|
|
724
|
-
}
|
|
725
|
-
}))
|
|
726
|
-
];
|
|
727
|
-
case 4 :
|
|
728
|
-
return [
|
|
729
|
-
length,
|
|
730
|
-
Belt_Option.flatMap(get(cm1, cv1), (function (colorCss1) {
|
|
731
|
-
return Belt_Option.flatMap(get(cm2, cv2 + (
|
|
732
|
-
Belt_List.length(xs$1) === 9 ? 10 : 0
|
|
733
|
-
) | 0), (function (colorCss2) {
|
|
734
|
-
var css = Object.assign({}, colorCss1, colorCss2);
|
|
735
|
-
var fontCss = get$1(style$1);
|
|
736
|
-
if (fontCss !== undefined) {
|
|
737
|
-
return {
|
|
738
|
-
TAG: /* Style */1,
|
|
739
|
-
_0: Object.assign({}, css, Caml_option.valFromOption(fontCss))
|
|
740
|
-
};
|
|
741
|
-
} else {
|
|
742
|
-
return {
|
|
743
|
-
TAG: /* Style */1,
|
|
744
|
-
_0: css
|
|
745
|
-
};
|
|
746
|
-
}
|
|
747
|
-
}));
|
|
748
|
-
}))
|
|
749
|
-
];
|
|
750
|
-
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
var AnsiCode = {
|
|
757
|
-
fourBitColors: fourBitColors,
|
|
758
|
-
threeBitColors: threeBitColors,
|
|
759
|
-
combine: combine,
|
|
760
|
-
addWeight: addWeight,
|
|
761
|
-
addStyle: addStyle,
|
|
762
|
-
addDecoration: addDecoration,
|
|
763
|
-
int_of_cp: int_of_cp,
|
|
764
|
-
ColorCss: ColorCss,
|
|
765
|
-
FontCss: FontCss,
|
|
766
|
-
HttpLink: HttpLink,
|
|
767
|
-
parse: parse
|
|
768
|
-
};
|
|
769
|
-
|
|
770
|
-
function text(txt, from, to_) {
|
|
771
|
-
var func = function (param, param$1) {
|
|
772
|
-
return param$1.slice(from, param);
|
|
773
|
-
};
|
|
774
|
-
return {
|
|
775
|
-
TAG: /* Text */0,
|
|
776
|
-
_0: Curry._2(func, to_, txt)
|
|
777
|
-
};
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
function parse$1(txt, length, pos) {
|
|
781
|
-
var go = function (_pos, _prev) {
|
|
782
|
-
while(true) {
|
|
783
|
-
var prev = _prev;
|
|
784
|
-
var pos = _pos;
|
|
785
|
-
var match = pos === length;
|
|
786
|
-
var match$1 = parse(txt, pos);
|
|
787
|
-
if (match) {
|
|
788
|
-
return [
|
|
789
|
-
pos,
|
|
790
|
-
{
|
|
791
|
-
hd: text(txt, prev, pos),
|
|
792
|
-
tl: /* [] */0
|
|
793
|
-
}
|
|
794
|
-
];
|
|
795
|
-
}
|
|
796
|
-
var code = match$1[1];
|
|
797
|
-
if (code !== undefined) {
|
|
798
|
-
var prevElem = text(txt, prev, pos);
|
|
799
|
-
var pos$1 = pos + match$1[0] | 0;
|
|
800
|
-
if (typeof code === "number") {
|
|
801
|
-
switch (code) {
|
|
802
|
-
case /* Clear */0 :
|
|
803
|
-
return [
|
|
804
|
-
pos$1,
|
|
805
|
-
{
|
|
806
|
-
hd: prevElem,
|
|
807
|
-
tl: /* [] */0
|
|
808
|
-
}
|
|
809
|
-
];
|
|
810
|
-
case /* EraseLine */1 :
|
|
811
|
-
_prev = pos$1;
|
|
812
|
-
_pos = pos$1;
|
|
813
|
-
continue ;
|
|
814
|
-
case /* CarriageReturn */2 :
|
|
815
|
-
return [
|
|
816
|
-
pos$1,
|
|
817
|
-
{
|
|
818
|
-
hd: prevElem,
|
|
819
|
-
tl: {
|
|
820
|
-
hd: /* LineBreak */0,
|
|
821
|
-
tl: /* [] */0
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
];
|
|
825
|
-
|
|
826
|
-
}
|
|
827
|
-
} else {
|
|
828
|
-
if (!code.TAG) {
|
|
829
|
-
return [
|
|
830
|
-
pos$1,
|
|
831
|
-
{
|
|
832
|
-
hd: prevElem,
|
|
833
|
-
tl: {
|
|
834
|
-
hd: {
|
|
835
|
-
TAG: /* Link */1,
|
|
836
|
-
_0: code._0
|
|
837
|
-
},
|
|
838
|
-
tl: /* [] */0
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
];
|
|
842
|
-
}
|
|
843
|
-
var match$2 = go(pos$1, pos$1);
|
|
844
|
-
var styled = match$2[1];
|
|
845
|
-
if (styled !== undefined) {
|
|
846
|
-
return [
|
|
847
|
-
match$2[0],
|
|
848
|
-
{
|
|
849
|
-
hd: prevElem,
|
|
850
|
-
tl: {
|
|
851
|
-
hd: {
|
|
852
|
-
TAG: /* DocStyle */2,
|
|
853
|
-
_0: code._0,
|
|
854
|
-
_1: styled
|
|
855
|
-
},
|
|
856
|
-
tl: /* [] */0
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
];
|
|
860
|
-
} else {
|
|
861
|
-
return [
|
|
862
|
-
pos$1,
|
|
863
|
-
undefined
|
|
864
|
-
];
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
} else {
|
|
868
|
-
_pos = pos + 1 | 0;
|
|
869
|
-
continue ;
|
|
870
|
-
}
|
|
871
|
-
};
|
|
872
|
-
};
|
|
873
|
-
return go(pos, pos);
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
var $$Document = {
|
|
877
|
-
text: text,
|
|
878
|
-
parse: parse$1
|
|
879
|
-
};
|
|
880
|
-
|
|
881
|
-
function parse$2(txt) {
|
|
882
|
-
var go = function (_txt, _acc) {
|
|
883
|
-
while(true) {
|
|
884
|
-
var acc = _acc;
|
|
885
|
-
var txt = _txt;
|
|
886
|
-
var length = txt.length;
|
|
887
|
-
var match = parse$1(txt, length, 0);
|
|
888
|
-
var doc = match[1];
|
|
889
|
-
var pos = match[0];
|
|
890
|
-
if (doc === undefined) {
|
|
891
|
-
return acc;
|
|
892
|
-
}
|
|
893
|
-
if (pos === length) {
|
|
894
|
-
return Belt_List.add(acc, doc);
|
|
895
|
-
}
|
|
896
|
-
_acc = Belt_List.add(acc, doc);
|
|
897
|
-
_txt = txt.slice(pos);
|
|
898
|
-
continue ;
|
|
899
|
-
};
|
|
900
|
-
};
|
|
901
|
-
return Belt_List.flatten(Belt_List.reverse(go(txt, /* [] */0)));
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
function render(doc) {
|
|
905
|
-
var go = function (_xs, _idx, _acc) {
|
|
906
|
-
while(true) {
|
|
907
|
-
var acc = _acc;
|
|
908
|
-
var idx = _idx;
|
|
909
|
-
var xs = _xs;
|
|
910
|
-
if (!xs) {
|
|
911
|
-
return Belt_List.toArray(Belt_List.reverse(acc));
|
|
912
|
-
}
|
|
913
|
-
var txt = xs.hd;
|
|
914
|
-
if (typeof txt === "number") {
|
|
915
|
-
_acc = Belt_List.add(acc, React.createElement("br", {
|
|
916
|
-
key: String(idx)
|
|
917
|
-
}));
|
|
918
|
-
_idx = idx + 1 | 0;
|
|
919
|
-
_xs = xs.tl;
|
|
920
|
-
continue ;
|
|
921
|
-
}
|
|
922
|
-
switch (txt.TAG | 0) {
|
|
923
|
-
case /* Text */0 :
|
|
924
|
-
_acc = Belt_List.add(acc, txt._0);
|
|
925
|
-
_idx = idx + 1 | 0;
|
|
926
|
-
_xs = xs.tl;
|
|
927
|
-
continue ;
|
|
928
|
-
case /* Link */1 :
|
|
929
|
-
var href = txt._0;
|
|
930
|
-
_acc = Belt_List.add(acc, React.createElement("a", {
|
|
931
|
-
key: String(idx),
|
|
932
|
-
href: href
|
|
933
|
-
}, href));
|
|
934
|
-
_idx = idx + 1 | 0;
|
|
935
|
-
_xs = xs.tl;
|
|
936
|
-
continue ;
|
|
937
|
-
case /* DocStyle */2 :
|
|
938
|
-
_acc = Belt_List.add(acc, React.createElement("span", {
|
|
939
|
-
key: String(idx),
|
|
940
|
-
style: txt._0
|
|
941
|
-
}, go(txt._1, 0, /* [] */0)));
|
|
942
|
-
_idx = idx + 1 | 0;
|
|
943
|
-
_xs = xs.tl;
|
|
944
|
-
continue ;
|
|
945
|
-
|
|
946
|
-
}
|
|
947
|
-
};
|
|
948
|
-
};
|
|
949
|
-
return go(doc, 0, /* [] */0);
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
function Ansi(Props) {
|
|
953
|
-
var log = Props.log;
|
|
954
|
-
return React.createElement("div", undefined, render(parse$2(log)));
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
var make = Ansi;
|
|
958
|
-
|
|
959
|
-
var $$default = Ansi;
|
|
960
|
-
|
|
961
|
-
exports.AnsiCode = AnsiCode;
|
|
962
|
-
exports.$$Document = $$Document;
|
|
963
|
-
exports.parse = parse$2;
|
|
964
|
-
exports.render = render;
|
|
965
|
-
exports.make = make;
|
|
966
|
-
exports.$$default = $$default;
|
|
967
|
-
exports.default = $$default;
|
|
968
|
-
exports.__esModule = true;
|
|
969
|
-
/* react Not a pure module */
|