@softwarefactory-project/re-ansi 0.7.3 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -79,8 +79,23 @@ Then build and run tests with `yarn test`.
79
79
 
80
80
  Make sure to read about [React][reason-react] and [Reason][rescript-lang] too.
81
81
 
82
+ To make a release:
83
+
84
+ - Update the version number in packages.json
85
+ - Run `npm run build && npm run bundle`
86
+ - Then: `npm publish`
87
+ - Tag and push the commit
88
+
82
89
  ## Changes
83
90
 
91
+ ### 0.7.5
92
+
93
+ - Fix link parsing when escape sequences at end of URL.
94
+
95
+ ### 0.7.4
96
+
97
+ - Add the missing `Ansi.res.js` to the release.
98
+
84
99
  ### 0.7.3
85
100
 
86
101
  - Better parse url.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softwarefactory-project/re-ansi",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "description": "ANSI code to HTML",
5
5
  "files": [
6
6
  "README.md",
@@ -15,7 +15,7 @@
15
15
  "homepage": "https://github.com/softwarefactory-project/re-ansi",
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "git+https://softwarefactory-project.io/r/software-factory/re-ansi.git"
18
+ "url": "https://github.com/softwarefactory-project/re-ansi.git"
19
19
  },
20
20
  "scripts": {
21
21
  "build": "rescript",
package/src/Ansi.res CHANGED
@@ -153,7 +153,7 @@ module AnsiCode = {
153
153
 
154
154
  // Link management
155
155
  module HttpLink = {
156
- let linkRe = RegExp.fromString("^(http(s)?:\\/\\/[^\\)>\\s]+)");
156
+ let linkRe = RegExp.fromString("^(http(s)?:\\/\\/[^\\)>\\s\x1b]+)");
157
157
 
158
158
  let get = (txt: string): parser<code> =>
159
159
  linkRe
@@ -0,0 +1,1133 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // node_modules/rescript/lib/es6/caml_option.js
5
+ function some(x) {
6
+ if (x === void 0) {
7
+ return {
8
+ BS_PRIVATE_NESTED_SOME_NONE: 0
9
+ };
10
+ } else if (x !== null && x.BS_PRIVATE_NESTED_SOME_NONE !== void 0) {
11
+ return {
12
+ BS_PRIVATE_NESTED_SOME_NONE: x.BS_PRIVATE_NESTED_SOME_NONE + 1 | 0
13
+ };
14
+ } else {
15
+ return x;
16
+ }
17
+ }
18
+ __name(some, "some");
19
+ function nullable_to_opt(x) {
20
+ if (x == null) {
21
+ return;
22
+ } else {
23
+ return some(x);
24
+ }
25
+ }
26
+ __name(nullable_to_opt, "nullable_to_opt");
27
+ function valFromOption(x) {
28
+ if (!(x !== null && x.BS_PRIVATE_NESTED_SOME_NONE !== void 0)) {
29
+ return x;
30
+ }
31
+ var depth = x.BS_PRIVATE_NESTED_SOME_NONE;
32
+ if (depth === 0) {
33
+ return;
34
+ } else {
35
+ return {
36
+ BS_PRIVATE_NESTED_SOME_NONE: depth - 1 | 0
37
+ };
38
+ }
39
+ }
40
+ __name(valFromOption, "valFromOption");
41
+
42
+ // node_modules/rescript/lib/es6/js_string.js
43
+ function codePointAt(arg1, obj) {
44
+ return obj.codePointAt(arg1);
45
+ }
46
+ __name(codePointAt, "codePointAt");
47
+ function slice(from, to_, obj) {
48
+ return obj.slice(from, to_);
49
+ }
50
+ __name(slice, "slice");
51
+ function sliceToEnd(from, obj) {
52
+ return obj.slice(from);
53
+ }
54
+ __name(sliceToEnd, "sliceToEnd");
55
+
56
+ // node_modules/@rescript/core/src/Core__List.res.mjs
57
+ function add(xs, x) {
58
+ return {
59
+ hd: x,
60
+ tl: xs
61
+ };
62
+ }
63
+ __name(add, "add");
64
+ function copyAuxCont(_cellX, _prec) {
65
+ while (true) {
66
+ var prec = _prec;
67
+ var cellX = _cellX;
68
+ if (!cellX) {
69
+ return prec;
70
+ }
71
+ var next = {
72
+ hd: cellX.hd,
73
+ tl: (
74
+ /* [] */
75
+ 0
76
+ )
77
+ };
78
+ prec.tl = next;
79
+ _prec = next;
80
+ _cellX = cellX.tl;
81
+ continue;
82
+ }
83
+ ;
84
+ }
85
+ __name(copyAuxCont, "copyAuxCont");
86
+ function length(xs) {
87
+ var _x = xs;
88
+ var _acc = 0;
89
+ while (true) {
90
+ var acc = _acc;
91
+ var x = _x;
92
+ if (!x) {
93
+ return acc;
94
+ }
95
+ _acc = acc + 1 | 0;
96
+ _x = x.tl;
97
+ continue;
98
+ }
99
+ ;
100
+ }
101
+ __name(length, "length");
102
+ function fillAux(arr, _i, _x) {
103
+ while (true) {
104
+ var x = _x;
105
+ var i = _i;
106
+ if (!x) {
107
+ return;
108
+ }
109
+ arr[i] = x.hd;
110
+ _x = x.tl;
111
+ _i = i + 1 | 0;
112
+ continue;
113
+ }
114
+ ;
115
+ }
116
+ __name(fillAux, "fillAux");
117
+ function toArray(x) {
118
+ var len = length(x);
119
+ var arr = new Array(len);
120
+ fillAux(arr, 0, x);
121
+ return arr;
122
+ }
123
+ __name(toArray, "toArray");
124
+ function reverseConcat(_l1, _l2) {
125
+ while (true) {
126
+ var l2 = _l2;
127
+ var l1 = _l1;
128
+ if (!l1) {
129
+ return l2;
130
+ }
131
+ _l2 = {
132
+ hd: l1.hd,
133
+ tl: l2
134
+ };
135
+ _l1 = l1.tl;
136
+ continue;
137
+ }
138
+ ;
139
+ }
140
+ __name(reverseConcat, "reverseConcat");
141
+ function reverse(l) {
142
+ return reverseConcat(
143
+ l,
144
+ /* [] */
145
+ 0
146
+ );
147
+ }
148
+ __name(reverse, "reverse");
149
+ function flatAux(_prec, _xs) {
150
+ while (true) {
151
+ var xs = _xs;
152
+ var prec = _prec;
153
+ if (xs) {
154
+ _xs = xs.tl;
155
+ _prec = copyAuxCont(xs.hd, prec);
156
+ continue;
157
+ }
158
+ prec.tl = /* [] */
159
+ 0;
160
+ return;
161
+ }
162
+ ;
163
+ }
164
+ __name(flatAux, "flatAux");
165
+ function flat(_xs) {
166
+ while (true) {
167
+ var xs = _xs;
168
+ if (!xs) {
169
+ return (
170
+ /* [] */
171
+ 0
172
+ );
173
+ }
174
+ var match = xs.hd;
175
+ if (match) {
176
+ var cell = {
177
+ hd: match.hd,
178
+ tl: (
179
+ /* [] */
180
+ 0
181
+ )
182
+ };
183
+ flatAux(copyAuxCont(match.tl, cell), xs.tl);
184
+ return cell;
185
+ }
186
+ _xs = xs.tl;
187
+ continue;
188
+ }
189
+ ;
190
+ }
191
+ __name(flat, "flat");
192
+
193
+ // node_modules/@rescript/core/src/Core__Option.res.mjs
194
+ function flatMap(opt, f) {
195
+ if (opt !== void 0) {
196
+ return f(valFromOption(opt));
197
+ }
198
+ }
199
+ __name(flatMap, "flatMap");
200
+ function getOr(opt, $$default2) {
201
+ if (opt !== void 0) {
202
+ return valFromOption(opt);
203
+ } else {
204
+ return $$default2;
205
+ }
206
+ }
207
+ __name(getOr, "getOr");
208
+
209
+ // src/Ansi.res.mjs
210
+ import * as JsxRuntime from "react/jsx-runtime";
211
+ function fourBitColors(code) {
212
+ switch (code) {
213
+ case 0:
214
+ return "black";
215
+ case 1:
216
+ return "red";
217
+ case 2:
218
+ return "green";
219
+ case 3:
220
+ return "yellow";
221
+ case 4:
222
+ return "blue";
223
+ case 5:
224
+ return "magenta";
225
+ case 6:
226
+ return "cyan";
227
+ case 9:
228
+ return "initial";
229
+ case 10:
230
+ return "grey";
231
+ case 11:
232
+ return "#DA2647";
233
+ case 12:
234
+ return "#87FF2A";
235
+ case 13:
236
+ return "#FFF700";
237
+ case 14:
238
+ return "#5DADEC";
239
+ case 15:
240
+ return "#FF3399";
241
+ case 16:
242
+ return "#8DD9CC";
243
+ case 7:
244
+ case 17:
245
+ return "white";
246
+ default:
247
+ console.log("Unknown color value:", code);
248
+ return;
249
+ }
250
+ }
251
+ __name(fourBitColors, "fourBitColors");
252
+ function threeBitColors(code) {
253
+ switch (code) {
254
+ case 0:
255
+ return "grey";
256
+ case 1:
257
+ return "red";
258
+ case 2:
259
+ return "green";
260
+ case 3:
261
+ return "yellow";
262
+ case 4:
263
+ return "blue";
264
+ case 5:
265
+ return "magenta";
266
+ case 6:
267
+ return "cyan";
268
+ case 7:
269
+ return "white";
270
+ default:
271
+ console.log("Unknown color value:", code);
272
+ return;
273
+ }
274
+ }
275
+ __name(threeBitColors, "threeBitColors");
276
+ function combine(css1, css2) {
277
+ return Object.assign({}, css1, css2);
278
+ }
279
+ __name(combine, "combine");
280
+ function addWeight(fontWeight) {
281
+ return {
282
+ fontWeight
283
+ };
284
+ }
285
+ __name(addWeight, "addWeight");
286
+ function addStyle(fontStyle) {
287
+ return {
288
+ fontStyle
289
+ };
290
+ }
291
+ __name(addStyle, "addStyle");
292
+ function addDecoration(textDecoration) {
293
+ return {
294
+ textDecoration
295
+ };
296
+ }
297
+ __name(addDecoration, "addDecoration");
298
+ function int_of_cp(c) {
299
+ return c - 48 | 0;
300
+ }
301
+ __name(int_of_cp, "int_of_cp");
302
+ function getColorStyle(colorMode, colorValue) {
303
+ switch (colorMode) {
304
+ case 3:
305
+ return {
306
+ TAG: "Foreground",
307
+ _0: colorValue
308
+ };
309
+ case 0:
310
+ case 4:
311
+ return {
312
+ TAG: "Background",
313
+ _0: colorValue
314
+ };
315
+ case 9:
316
+ return {
317
+ TAG: "BrightForeground",
318
+ _0: colorValue
319
+ };
320
+ default:
321
+ }
322
+ console.log("Unknown color code:", colorMode, colorValue);
323
+ }
324
+ __name(getColorStyle, "getColorStyle");
325
+ function getColorStyleCss(color) {
326
+ switch (color.TAG) {
327
+ case "Foreground":
328
+ return flatMap(fourBitColors(color._0), function(color2) {
329
+ return {
330
+ color: color2
331
+ };
332
+ });
333
+ case "BrightForeground":
334
+ return flatMap(threeBitColors(color._0), function(color2) {
335
+ return {
336
+ color: color2,
337
+ fontWeight: "bold"
338
+ };
339
+ });
340
+ case "Background":
341
+ return flatMap(fourBitColors(color._0), function(background) {
342
+ return {
343
+ background
344
+ };
345
+ });
346
+ }
347
+ }
348
+ __name(getColorStyleCss, "getColorStyleCss");
349
+ function get(colorMode, colorValue) {
350
+ return flatMap(getColorStyle(colorMode - 48 | 0, colorValue - 48 | 0), getColorStyleCss);
351
+ }
352
+ __name(get, "get");
353
+ var ColorCss = {
354
+ getColorStyle,
355
+ getColorStyleCss,
356
+ get
357
+ };
358
+ function getFontStyle(fontMode) {
359
+ switch (fontMode) {
360
+ case 1:
361
+ return {
362
+ TAG: "FontStyle",
363
+ _0: addWeight("bold")
364
+ };
365
+ case 2:
366
+ return {
367
+ TAG: "FontStyle",
368
+ _0: addWeight("lighter")
369
+ };
370
+ case 3:
371
+ return {
372
+ TAG: "FontStyle",
373
+ _0: addStyle("italic")
374
+ };
375
+ case 4:
376
+ return {
377
+ TAG: "FontStyle",
378
+ _0: addDecoration("underline")
379
+ };
380
+ case 0:
381
+ case 7:
382
+ return "Regular";
383
+ case 9:
384
+ return {
385
+ TAG: "FontStyle",
386
+ _0: addDecoration("line-through")
387
+ };
388
+ default:
389
+ return;
390
+ }
391
+ }
392
+ __name(getFontStyle, "getFontStyle");
393
+ function getFontStyleCss(font) {
394
+ if (typeof font !== "object") {
395
+ return;
396
+ } else {
397
+ return font._0;
398
+ }
399
+ }
400
+ __name(getFontStyleCss, "getFontStyleCss");
401
+ function get$1(fontMode) {
402
+ return flatMap(getFontStyle(fontMode - 48 | 0), getFontStyleCss);
403
+ }
404
+ __name(get$1, "get$1");
405
+ var FontCss = {
406
+ getFontStyle,
407
+ getFontStyleCss,
408
+ get: get$1
409
+ };
410
+ var linkRe = new RegExp("^(http(s)?:\\/\\/[^\\)>\\s\x1B]+)");
411
+ function get$2(txt) {
412
+ return getOr(flatMap(nullable_to_opt(linkRe.exec(txt)), function(res) {
413
+ return flatMap(res[0], function(url) {
414
+ return [
415
+ url.length,
416
+ {
417
+ TAG: "HRef",
418
+ _0: url
419
+ }
420
+ ];
421
+ });
422
+ }), [
423
+ 1,
424
+ void 0
425
+ ]);
426
+ }
427
+ __name(get$2, "get$2");
428
+ var HttpLink = {
429
+ linkRe,
430
+ get: get$2
431
+ };
432
+ function parse(txt, pos) {
433
+ var match = codePointAt(pos, txt);
434
+ var exit = 0;
435
+ if (match === void 0) {
436
+ return [
437
+ 0,
438
+ void 0
439
+ ];
440
+ }
441
+ if (match >= 14) {
442
+ if (match !== 27) {
443
+ if (match !== 104) {
444
+ return [
445
+ 0,
446
+ void 0
447
+ ];
448
+ } else {
449
+ return get$2(slice(pos, 512, txt));
450
+ }
451
+ }
452
+ exit = 1;
453
+ } else {
454
+ if (match === 10) {
455
+ return [
456
+ 1,
457
+ "CarriageReturn"
458
+ ];
459
+ }
460
+ if (match < 13) {
461
+ return [
462
+ 0,
463
+ void 0
464
+ ];
465
+ }
466
+ exit = 1;
467
+ }
468
+ if (exit === 1) {
469
+ var codePoints = [];
470
+ var readCodePoints = /* @__PURE__ */ __name(function(_idx) {
471
+ while (true) {
472
+ var idx = _idx;
473
+ var match2 = idx > 10;
474
+ var match$110 = codePointAt(pos + idx | 0, txt);
475
+ if (match2) {
476
+ return;
477
+ }
478
+ if (match$110 === void 0) {
479
+ return;
480
+ }
481
+ if (match$110 === 109) {
482
+ return;
483
+ }
484
+ codePoints.push(match$110);
485
+ _idx = idx + 1 | 0;
486
+ continue;
487
+ }
488
+ ;
489
+ }, "readCodePoints");
490
+ readCodePoints(1);
491
+ var length2 = codePoints.length + 2 | 0;
492
+ var exit$1 = 0;
493
+ var colorMode;
494
+ var colorValue;
495
+ var xs;
496
+ var colorMode$1;
497
+ var colorValue$1;
498
+ var style;
499
+ var style$1;
500
+ var cm1;
501
+ var cv1;
502
+ var cm2;
503
+ var cv2;
504
+ var xs$1;
505
+ if (codePoints[0] === 10 && codePoints[1] === 27 && codePoints[2] === 91 && codePoints[3] === 49 && codePoints[4] === 65 && codePoints[5] === 27 && codePoints[6] === 91 && codePoints[7] === 74) {
506
+ return [
507
+ 9,
508
+ "EraseLine"
509
+ ];
510
+ }
511
+ if (codePoints[0] === 91 && codePoints[2] === 75) {
512
+ return [
513
+ 4,
514
+ "EraseLine"
515
+ ];
516
+ }
517
+ if (codePoints[0] === 91 && codePoints[1] === 75) {
518
+ return [
519
+ 3,
520
+ "EraseLine"
521
+ ];
522
+ }
523
+ var len = codePoints.length;
524
+ if (len >= 11) {
525
+ return [
526
+ 1,
527
+ void 0
528
+ ];
529
+ }
530
+ switch (len) {
531
+ case 1:
532
+ var match$1 = codePoints[0];
533
+ if (match$1 !== 91) {
534
+ return [
535
+ 1,
536
+ void 0
537
+ ];
538
+ } else {
539
+ return [
540
+ length2,
541
+ "Clear"
542
+ ];
543
+ }
544
+ case 2:
545
+ var match$2 = codePoints[0];
546
+ if (match$2 !== 91) {
547
+ return [
548
+ 1,
549
+ void 0
550
+ ];
551
+ }
552
+ var style$2 = codePoints[1];
553
+ if (style$2 !== 48) {
554
+ return [
555
+ length2,
556
+ flatMap(get$1(style$2), function(style2) {
557
+ return {
558
+ TAG: "Style",
559
+ _0: style2
560
+ };
561
+ })
562
+ ];
563
+ } else {
564
+ return [
565
+ length2,
566
+ "Clear"
567
+ ];
568
+ }
569
+ case 3:
570
+ var match$3 = codePoints[0];
571
+ if (match$3 !== 91) {
572
+ return [
573
+ 1,
574
+ void 0
575
+ ];
576
+ }
577
+ var colorMode$2 = codePoints[1];
578
+ var exit$2 = 0;
579
+ if (colorMode$2 !== 48) {
580
+ exit$2 = 5;
581
+ } else {
582
+ var match$4 = codePoints[2];
583
+ if (match$4 === 48) {
584
+ return [
585
+ length2,
586
+ "Clear"
587
+ ];
588
+ }
589
+ exit$2 = 5;
590
+ }
591
+ if (exit$2 === 5) {
592
+ var colorValue$2 = codePoints[2];
593
+ colorMode = colorMode$2;
594
+ colorValue = colorValue$2;
595
+ xs = codePoints;
596
+ exit$1 = 2;
597
+ }
598
+ break;
599
+ case 4:
600
+ var match$5 = codePoints[0];
601
+ if (match$5 !== 91) {
602
+ return [
603
+ 1,
604
+ void 0
605
+ ];
606
+ }
607
+ var match$6 = codePoints[1];
608
+ if (match$6 !== 49) {
609
+ return [
610
+ 1,
611
+ void 0
612
+ ];
613
+ }
614
+ var colorMode$3 = codePoints[2];
615
+ var colorValue$3 = codePoints[3];
616
+ colorMode = colorMode$3;
617
+ colorValue = colorValue$3;
618
+ xs = codePoints;
619
+ exit$1 = 2;
620
+ break;
621
+ case 5:
622
+ var match$7 = codePoints[0];
623
+ if (match$7 !== 91) {
624
+ return [
625
+ 1,
626
+ void 0
627
+ ];
628
+ }
629
+ var colorMode$4 = codePoints[1];
630
+ var colorValue$4 = codePoints[2];
631
+ var match$8 = codePoints[3];
632
+ if (match$8 !== 59) {
633
+ if (colorValue$4 !== 59) {
634
+ return [
635
+ 1,
636
+ void 0
637
+ ];
638
+ }
639
+ var colorMode$5 = codePoints[3];
640
+ var colorValue$5 = codePoints[4];
641
+ colorMode$1 = colorMode$5;
642
+ colorValue$1 = colorValue$5;
643
+ style = colorMode$4;
644
+ exit$1 = 3;
645
+ } else {
646
+ var style$3 = codePoints[4];
647
+ colorMode$1 = colorMode$4;
648
+ colorValue$1 = colorValue$4;
649
+ style = style$3;
650
+ exit$1 = 3;
651
+ }
652
+ break;
653
+ case 6:
654
+ var match$9 = codePoints[0];
655
+ if (match$9 !== 91) {
656
+ return [
657
+ 1,
658
+ void 0
659
+ ];
660
+ }
661
+ var match$10 = codePoints[1];
662
+ if (match$10 !== 48) {
663
+ return [
664
+ 1,
665
+ void 0
666
+ ];
667
+ }
668
+ var style$4 = codePoints[2];
669
+ var match$11 = codePoints[3];
670
+ if (match$11 !== 59) {
671
+ return [
672
+ 1,
673
+ void 0
674
+ ];
675
+ }
676
+ var colorMode$6 = codePoints[4];
677
+ var colorValue$6 = codePoints[5];
678
+ colorMode$1 = colorMode$6;
679
+ colorValue$1 = colorValue$6;
680
+ style = style$4;
681
+ exit$1 = 3;
682
+ break;
683
+ case 0:
684
+ case 7:
685
+ return [
686
+ 1,
687
+ void 0
688
+ ];
689
+ case 8:
690
+ var match$12 = codePoints[0];
691
+ if (match$12 !== 91) {
692
+ return [
693
+ 1,
694
+ void 0
695
+ ];
696
+ }
697
+ var style$5 = codePoints[1];
698
+ var match$13 = codePoints[2];
699
+ if (match$13 !== 59) {
700
+ return [
701
+ 1,
702
+ void 0
703
+ ];
704
+ }
705
+ var cm1$1 = codePoints[3];
706
+ var cv1$1 = codePoints[4];
707
+ var match$14 = codePoints[5];
708
+ if (match$14 !== 59) {
709
+ return [
710
+ 1,
711
+ void 0
712
+ ];
713
+ }
714
+ var cm2$1 = codePoints[6];
715
+ var cv2$1 = codePoints[7];
716
+ style$1 = style$5;
717
+ cm1 = cm1$1;
718
+ cv1 = cv1$1;
719
+ cm2 = cm2$1;
720
+ cv2 = cv2$1;
721
+ xs$1 = codePoints;
722
+ exit$1 = 4;
723
+ break;
724
+ case 9:
725
+ var match$15 = codePoints[0];
726
+ if (match$15 !== 91) {
727
+ return [
728
+ 1,
729
+ void 0
730
+ ];
731
+ }
732
+ var style$6 = codePoints[1];
733
+ var exit$3 = 0;
734
+ if (style$6 !== 48) {
735
+ exit$3 = 5;
736
+ } else {
737
+ var style$7 = codePoints[2];
738
+ var match$16 = codePoints[3];
739
+ if (match$16 !== 59) {
740
+ exit$3 = 5;
741
+ } else {
742
+ var cm1$2 = codePoints[4];
743
+ var cv1$2 = codePoints[5];
744
+ var match$17 = codePoints[6];
745
+ if (match$17 !== 59) {
746
+ exit$3 = 5;
747
+ } else {
748
+ var cm2$2 = codePoints[7];
749
+ var cv2$2 = codePoints[8];
750
+ style$1 = style$7;
751
+ cm1 = cm1$2;
752
+ cv1 = cv1$2;
753
+ cm2 = cm2$2;
754
+ cv2 = cv2$2;
755
+ xs$1 = codePoints;
756
+ exit$1 = 4;
757
+ }
758
+ }
759
+ }
760
+ if (exit$3 === 5) {
761
+ var match$18 = codePoints[2];
762
+ if (match$18 !== 59) {
763
+ return [
764
+ 1,
765
+ void 0
766
+ ];
767
+ }
768
+ var cm1$3 = codePoints[3];
769
+ var cv1$3 = codePoints[4];
770
+ var match$19 = codePoints[5];
771
+ if (match$19 !== 59) {
772
+ return [
773
+ 1,
774
+ void 0
775
+ ];
776
+ }
777
+ var match$20 = codePoints[6];
778
+ if (match$20 !== 49) {
779
+ return [
780
+ 1,
781
+ void 0
782
+ ];
783
+ }
784
+ var cm2$3 = codePoints[7];
785
+ var cv2$3 = codePoints[8];
786
+ style$1 = style$6;
787
+ cm1 = cm1$3;
788
+ cv1 = cv1$3;
789
+ cm2 = cm2$3;
790
+ cv2 = cv2$3;
791
+ xs$1 = codePoints;
792
+ exit$1 = 4;
793
+ }
794
+ break;
795
+ case 10:
796
+ var match$21 = codePoints[0];
797
+ if (match$21 !== 91) {
798
+ return [
799
+ 1,
800
+ void 0
801
+ ];
802
+ }
803
+ var match$22 = codePoints[1];
804
+ if (match$22 !== 48) {
805
+ return [
806
+ 1,
807
+ void 0
808
+ ];
809
+ }
810
+ var style$8 = codePoints[2];
811
+ var match$23 = codePoints[3];
812
+ if (match$23 !== 59) {
813
+ return [
814
+ 1,
815
+ void 0
816
+ ];
817
+ }
818
+ var cm1$4 = codePoints[4];
819
+ var cv1$4 = codePoints[5];
820
+ var match$24 = codePoints[6];
821
+ if (match$24 !== 59) {
822
+ return [
823
+ 1,
824
+ void 0
825
+ ];
826
+ }
827
+ var match$25 = codePoints[7];
828
+ if (match$25 !== 49) {
829
+ return [
830
+ 1,
831
+ void 0
832
+ ];
833
+ }
834
+ var cm2$4 = codePoints[8];
835
+ var cv2$4 = codePoints[9];
836
+ style$1 = style$8;
837
+ cm1 = cm1$4;
838
+ cv1 = cv1$4;
839
+ cm2 = cm2$4;
840
+ cv2 = cv2$4;
841
+ xs$1 = codePoints;
842
+ exit$1 = 4;
843
+ break;
844
+ }
845
+ switch (exit$1) {
846
+ case 2:
847
+ return [
848
+ length2,
849
+ flatMap(get(colorMode, colorValue + (xs.length === 4 ? 10 : 0) | 0), function(colorCss) {
850
+ return {
851
+ TAG: "Style",
852
+ _0: colorCss
853
+ };
854
+ })
855
+ ];
856
+ case 3:
857
+ return [
858
+ length2,
859
+ flatMap(get(colorMode$1, colorValue$1), function(colorCss) {
860
+ var fontCss = get$1(style);
861
+ if (fontCss !== void 0) {
862
+ return {
863
+ TAG: "Style",
864
+ _0: Object.assign({}, colorCss, fontCss)
865
+ };
866
+ } else {
867
+ return {
868
+ TAG: "Style",
869
+ _0: colorCss
870
+ };
871
+ }
872
+ })
873
+ ];
874
+ case 4:
875
+ return [
876
+ length2,
877
+ flatMap(get(cm1, cv1), function(colorCss1) {
878
+ return flatMap(get(cm2, cv2 + (xs$1.length === 9 ? 10 : 0) | 0), function(colorCss2) {
879
+ var css = Object.assign({}, colorCss1, colorCss2);
880
+ var fontCss = get$1(style$1);
881
+ if (fontCss !== void 0) {
882
+ return {
883
+ TAG: "Style",
884
+ _0: Object.assign({}, css, fontCss)
885
+ };
886
+ } else {
887
+ return {
888
+ TAG: "Style",
889
+ _0: css
890
+ };
891
+ }
892
+ });
893
+ })
894
+ ];
895
+ }
896
+ }
897
+ }
898
+ __name(parse, "parse");
899
+ var AnsiCode = {
900
+ fourBitColors,
901
+ threeBitColors,
902
+ combine,
903
+ addWeight,
904
+ addStyle,
905
+ addDecoration,
906
+ int_of_cp,
907
+ ColorCss,
908
+ FontCss,
909
+ HttpLink,
910
+ parse
911
+ };
912
+ function text(txt, from, to_) {
913
+ return {
914
+ TAG: "Text",
915
+ _0: slice(from, to_, txt)
916
+ };
917
+ }
918
+ __name(text, "text");
919
+ function parse$1(txt, length2, pos) {
920
+ var go = /* @__PURE__ */ __name(function(_pos, _prev) {
921
+ while (true) {
922
+ var prev = _prev;
923
+ var pos2 = _pos;
924
+ var match = pos2 === length2;
925
+ var match$1 = parse(txt, pos2);
926
+ if (match) {
927
+ return [
928
+ pos2,
929
+ {
930
+ hd: text(txt, prev, pos2),
931
+ tl: (
932
+ /* [] */
933
+ 0
934
+ )
935
+ }
936
+ ];
937
+ }
938
+ var code = match$1[1];
939
+ if (code !== void 0) {
940
+ var prevElem = text(txt, prev, pos2);
941
+ var pos$1 = pos2 + match$1[0] | 0;
942
+ if (typeof code !== "object") {
943
+ switch (code) {
944
+ case "Clear":
945
+ return [
946
+ pos$1,
947
+ {
948
+ hd: prevElem,
949
+ tl: (
950
+ /* [] */
951
+ 0
952
+ )
953
+ }
954
+ ];
955
+ case "EraseLine":
956
+ _prev = pos$1;
957
+ _pos = pos$1;
958
+ continue;
959
+ case "CarriageReturn":
960
+ return [
961
+ pos$1,
962
+ {
963
+ hd: prevElem,
964
+ tl: {
965
+ hd: "LineBreak",
966
+ tl: (
967
+ /* [] */
968
+ 0
969
+ )
970
+ }
971
+ }
972
+ ];
973
+ }
974
+ } else {
975
+ if (code.TAG === "HRef") {
976
+ return [
977
+ pos$1,
978
+ {
979
+ hd: prevElem,
980
+ tl: {
981
+ hd: {
982
+ TAG: "Link",
983
+ _0: code._0
984
+ },
985
+ tl: (
986
+ /* [] */
987
+ 0
988
+ )
989
+ }
990
+ }
991
+ ];
992
+ }
993
+ var match$2 = go(pos$1, pos$1);
994
+ var styled = match$2[1];
995
+ if (styled !== void 0) {
996
+ return [
997
+ match$2[0],
998
+ {
999
+ hd: prevElem,
1000
+ tl: {
1001
+ hd: {
1002
+ TAG: "DocStyle",
1003
+ _0: code._0,
1004
+ _1: styled
1005
+ },
1006
+ tl: (
1007
+ /* [] */
1008
+ 0
1009
+ )
1010
+ }
1011
+ }
1012
+ ];
1013
+ } else {
1014
+ return [
1015
+ pos$1,
1016
+ void 0
1017
+ ];
1018
+ }
1019
+ }
1020
+ } else {
1021
+ _pos = pos2 + 1 | 0;
1022
+ continue;
1023
+ }
1024
+ }
1025
+ ;
1026
+ }, "go");
1027
+ return go(pos, pos);
1028
+ }
1029
+ __name(parse$1, "parse$1");
1030
+ var $$Document = {
1031
+ text,
1032
+ parse: parse$1
1033
+ };
1034
+ function parse$2(txt) {
1035
+ var go = /* @__PURE__ */ __name(function(_txt, _acc) {
1036
+ while (true) {
1037
+ var acc = _acc;
1038
+ var txt2 = _txt;
1039
+ var length2 = txt2.length;
1040
+ var match = parse$1(txt2, length2, 0);
1041
+ var doc = match[1];
1042
+ var pos = match[0];
1043
+ if (doc === void 0) {
1044
+ return acc;
1045
+ }
1046
+ if (pos === length2) {
1047
+ return add(acc, doc);
1048
+ }
1049
+ _acc = add(acc, doc);
1050
+ _txt = sliceToEnd(pos, txt2);
1051
+ continue;
1052
+ }
1053
+ ;
1054
+ }, "go");
1055
+ return flat(reverse(go(
1056
+ txt,
1057
+ /* [] */
1058
+ 0
1059
+ )));
1060
+ }
1061
+ __name(parse$2, "parse$2");
1062
+ function render(doc) {
1063
+ var go = /* @__PURE__ */ __name(function(_xs, _idx, _acc) {
1064
+ while (true) {
1065
+ var acc = _acc;
1066
+ var idx = _idx;
1067
+ var xs = _xs;
1068
+ if (!xs) {
1069
+ return toArray(reverse(acc));
1070
+ }
1071
+ var txt = xs.hd;
1072
+ if (typeof txt !== "object") {
1073
+ _acc = add(acc, JsxRuntime.jsx("br", {}, String(idx)));
1074
+ _idx = idx + 1 | 0;
1075
+ _xs = xs.tl;
1076
+ continue;
1077
+ }
1078
+ switch (txt.TAG) {
1079
+ case "Text":
1080
+ _acc = add(acc, txt._0);
1081
+ _idx = idx + 1 | 0;
1082
+ _xs = xs.tl;
1083
+ continue;
1084
+ case "Link":
1085
+ var href = txt._0;
1086
+ _acc = add(acc, JsxRuntime.jsx("a", {
1087
+ children: href,
1088
+ href
1089
+ }, String(idx)));
1090
+ _idx = idx + 1 | 0;
1091
+ _xs = xs.tl;
1092
+ continue;
1093
+ case "DocStyle":
1094
+ _acc = add(acc, JsxRuntime.jsx("span", {
1095
+ children: go(
1096
+ txt._1,
1097
+ 0,
1098
+ /* [] */
1099
+ 0
1100
+ ),
1101
+ style: txt._0
1102
+ }, String(idx)));
1103
+ _idx = idx + 1 | 0;
1104
+ _xs = xs.tl;
1105
+ continue;
1106
+ }
1107
+ }
1108
+ ;
1109
+ }, "go");
1110
+ return go(
1111
+ doc,
1112
+ 0,
1113
+ /* [] */
1114
+ 0
1115
+ );
1116
+ }
1117
+ __name(render, "render");
1118
+ function Ansi(props) {
1119
+ return JsxRuntime.jsx("div", {
1120
+ children: render(parse$2(props.log))
1121
+ });
1122
+ }
1123
+ __name(Ansi, "Ansi");
1124
+ var make = Ansi;
1125
+ var $$default = Ansi;
1126
+ export {
1127
+ $$Document,
1128
+ AnsiCode,
1129
+ $$default as default,
1130
+ make,
1131
+ parse$2 as parse,
1132
+ render
1133
+ };