@rohal12/spindle 0.59.14 → 0.59.16

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.
@@ -69,6 +69,11 @@ var LINK_SEPARATORS = [
69
69
  ];
70
70
  var NO_SELECTORS = {};
71
71
  /**
72
+ * A CommonMark email autolink, `<` an address `>` (without braces, which
73
+ * are markup), as markdown reads one.
74
+ */
75
+ var EMAIL_AUTOLINK = /^<[a-zA-Z0-9.!#$%&'*+/=?^_`|~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*>$/;
76
+ /**
72
77
  * A link's display text and target, from its text `inner` (at `at` in the
73
78
  * input), with where the target is written.
74
79
  */
@@ -346,10 +351,11 @@ function peg$parse(input, options) {
346
351
  const peg$c10 = " ";
347
352
  const peg$c11 = "}";
348
353
  const peg$c12 = "/";
349
- const peg$c13 = "</";
350
- const peg$c14 = "=";
351
- const peg$c15 = "\"";
352
- const peg$c16 = "'";
354
+ const peg$c13 = "@";
355
+ const peg$c14 = "</";
356
+ const peg$c15 = "=";
357
+ const peg$c16 = "\"";
358
+ const peg$c17 = "'";
353
359
  const peg$r0 = /^[^\\{[<]/;
354
360
  const peg$r1 = /^[{}]/;
355
361
  const peg$r2 = /^[$_@%(!\/a-zA-Z]/;
@@ -360,14 +366,16 @@ function peg$parse(input, options) {
360
366
  const peg$r7 = /^[$_@%(!]/;
361
367
  const peg$r8 = /^[a-zA-Z]/;
362
368
  const peg$r9 = /^[^ \t\n\r\v\f\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF}]/;
363
- const peg$r10 = /^[\t-\r \/>\xA0\u1680\u2000-\u200A\u2028-\u2029\u202F\u205F\u3000\uFEFF]/;
364
- const peg$r11 = /^[a-zA-Z0-9\-]/;
365
- const peg$r12 = /^[\t-\r "'\/<->{}\xA0\u1680\u2000-\u200A\u2028-\u2029\u202F\u205F\u3000\uFEFF]/;
366
- const peg$r13 = /^[^"]/;
367
- const peg$r14 = /^[^']/;
368
- const peg$r15 = /^["']/;
369
- const peg$r16 = /^[^ \t\n\r\v\f\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF>]/;
370
- const peg$r17 = /^[ \t\n\r\v\f\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/;
369
+ const peg$r10 = /^[a-zA-Z0-9.!#$%&'*+\/=?\^_`|~\-]/;
370
+ const peg$r11 = /^[a-zA-Z0-9.\-]/;
371
+ const peg$r12 = /^[\t-\r \/>\xA0\u1680\u2000-\u200A\u2028-\u2029\u202F\u205F\u3000\uFEFF]/;
372
+ const peg$r13 = /^[a-zA-Z0-9\-]/;
373
+ const peg$r14 = /^[\t-\r "'\/<->{}\xA0\u1680\u2000-\u200A\u2028-\u2029\u202F\u205F\u3000\uFEFF]/;
374
+ const peg$r15 = /^[^"]/;
375
+ const peg$r16 = /^[^']/;
376
+ const peg$r17 = /^["']/;
377
+ const peg$r18 = /^[^ \t\n\r\v\f\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF>]/;
378
+ const peg$r19 = /^[ \t\n\r\v\f\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/;
371
379
  const peg$e0 = peg$anyExpectation();
372
380
  const peg$e1 = peg$classExpectation([
373
381
  "\\",
@@ -449,6 +457,37 @@ function peg$parse(input, options) {
449
457
  "}"
450
458
  ], true, false, false);
451
459
  const peg$e24 = peg$classExpectation([
460
+ ["a", "z"],
461
+ ["A", "Z"],
462
+ ["0", "9"],
463
+ ".",
464
+ "!",
465
+ "#",
466
+ "$",
467
+ "%",
468
+ "&",
469
+ "'",
470
+ "*",
471
+ "+",
472
+ "/",
473
+ "=",
474
+ "?",
475
+ "^",
476
+ "_",
477
+ "`",
478
+ "|",
479
+ "~",
480
+ "-"
481
+ ], false, false, false);
482
+ const peg$e25 = peg$literalExpectation("@", false);
483
+ const peg$e26 = peg$classExpectation([
484
+ ["a", "z"],
485
+ ["A", "Z"],
486
+ ["0", "9"],
487
+ ".",
488
+ "-"
489
+ ], false, false, false);
490
+ const peg$e27 = peg$classExpectation([
452
491
  [" ", "\r"],
453
492
  " ",
454
493
  "/",
@@ -462,14 +501,14 @@ function peg$parse(input, options) {
462
501
  " ",
463
502
  ""
464
503
  ], false, false, false);
465
- const peg$e25 = peg$literalExpectation("</", false);
466
- const peg$e26 = peg$classExpectation([
504
+ const peg$e28 = peg$literalExpectation("</", false);
505
+ const peg$e29 = peg$classExpectation([
467
506
  ["a", "z"],
468
507
  ["A", "Z"],
469
508
  ["0", "9"],
470
509
  "-"
471
510
  ], false, false, false);
472
- const peg$e27 = peg$classExpectation([
511
+ const peg$e30 = peg$classExpectation([
473
512
  [" ", "\r"],
474
513
  " ",
475
514
  "\"",
@@ -487,13 +526,13 @@ function peg$parse(input, options) {
487
526
  " ",
488
527
  ""
489
528
  ], false, false, false);
490
- const peg$e28 = peg$literalExpectation("=", false);
491
- const peg$e29 = peg$literalExpectation("\"", false);
492
- const peg$e30 = peg$classExpectation(["\""], true, false, false);
493
- const peg$e31 = peg$literalExpectation("'", false);
494
- const peg$e32 = peg$classExpectation(["'"], true, false, false);
495
- const peg$e33 = peg$classExpectation(["\"", "'"], false, false, false);
496
- const peg$e34 = peg$classExpectation([
529
+ const peg$e31 = peg$literalExpectation("=", false);
530
+ const peg$e32 = peg$literalExpectation("\"", false);
531
+ const peg$e33 = peg$classExpectation(["\""], true, false, false);
532
+ const peg$e34 = peg$literalExpectation("'", false);
533
+ const peg$e35 = peg$classExpectation(["'"], true, false, false);
534
+ const peg$e36 = peg$classExpectation(["\"", "'"], false, false, false);
535
+ const peg$e37 = peg$classExpectation([
497
536
  " ",
498
537
  " ",
499
538
  "\n",
@@ -511,7 +550,7 @@ function peg$parse(input, options) {
511
550
  "",
512
551
  ">"
513
552
  ], true, false, false);
514
- const peg$e35 = peg$classExpectation([
553
+ const peg$e38 = peg$classExpectation([
515
554
  " ",
516
555
  " ",
517
556
  "\n",
@@ -804,16 +843,22 @@ function peg$parse(input, options) {
804
843
  function peg$f67(s) {
805
844
  fail("A closing tag starts with a letter after " + LB + "/", location());
806
845
  }
807
- function peg$f68() {
846
+ function peg$f68(value) {
847
+ return EMAIL_AUTOLINK.test(value);
848
+ }
849
+ function peg$f69(value) {
850
+ return lexeme("text", location(), { value });
851
+ }
852
+ function peg$f70() {
808
853
  return !textMode;
809
854
  }
810
- function peg$f69(tag) {
855
+ function peg$f71(tag) {
811
856
  return VOID_TAGS.has(tag.lower);
812
857
  }
813
- function peg$f70(tag) {
858
+ function peg$f72(tag) {
814
859
  return null;
815
860
  }
816
- function peg$f71(tag, list, slash) {
861
+ function peg$f73(tag, list, slash) {
817
862
  const lower = tag.toLowerCase();
818
863
  return lexeme("html", location(), {
819
864
  tag,
@@ -823,7 +868,7 @@ function peg$parse(input, options) {
823
868
  isSelfClose: !!slash || VOID_TAGS.has(lower)
824
869
  });
825
870
  }
826
- function peg$f72(tag, bad) {
871
+ function peg$f74(tag, bad) {
827
872
  const c = input.charAt(bad);
828
873
  if (!c) fail("Unclosed tag <" + tag + ": no > ends it (write &lt; for a < that starts no tag)", location());
829
874
  const at = {
@@ -841,7 +886,7 @@ function peg$parse(input, options) {
841
886
  };
842
887
  fail("Unexpected " + JSON.stringify(c) + " in the tag <" + tag + ">: expected an attribute, or > to end the tag", at);
843
888
  }
844
- function peg$f73(tag) {
889
+ function peg$f75(tag) {
845
890
  return lexeme("html", location(), {
846
891
  tag,
847
892
  lower: tag.toLowerCase(),
@@ -850,44 +895,44 @@ function peg$parse(input, options) {
850
895
  isSelfClose: false
851
896
  });
852
897
  }
853
- function peg$f74(name) {
898
+ function peg$f76(name) {
854
899
  attrCode = hooks.isCodeAttribute(name);
855
900
  return true;
856
901
  }
857
- function peg$f75(name, v) {
902
+ function peg$f77(name, v) {
858
903
  return v;
859
904
  }
860
- function peg$f76(name, value) {
905
+ function peg$f78(name, value) {
861
906
  return [name, value ?? ""];
862
907
  }
863
- function peg$f77(v) {
908
+ function peg$f79(v) {
864
909
  return v;
865
910
  }
866
- function peg$f78(v) {
911
+ function peg$f80(v) {
867
912
  return v;
868
913
  }
869
- function peg$f79(q) {
914
+ function peg$f81(q) {
870
915
  fail("Unclosed attribute value: the " + q + " here has no closing " + q, location());
871
916
  }
872
- function peg$f80() {
917
+ function peg$f82() {
873
918
  return !attrCode;
874
919
  }
875
- function peg$f81(bs) {
920
+ function peg$f83(bs) {
876
921
  return bs.length % 2 === 1;
877
922
  }
878
- function peg$f82() {
923
+ function peg$f84() {
879
924
  return !attrCode;
880
925
  }
881
- function peg$f83(start, nameEnd) {
926
+ function peg$f85(start, nameEnd) {
882
927
  return skipTo(hooks.closeBrace(input, nameEnd, start));
883
928
  }
884
- function peg$f84(start, nameEnd) {
929
+ function peg$f86(start, nameEnd) {
885
930
  return skipEnd - offset();
886
931
  }
887
- function peg$f85() {
932
+ function peg$f87() {
888
933
  return !attrCode;
889
934
  }
890
- function peg$f86() {
935
+ function peg$f88() {
891
936
  return attrCode;
892
937
  }
893
938
  let peg$currPos = options.peg$currPos | 0;
@@ -1078,14 +1123,17 @@ function peg$parse(input, options) {
1078
1123
  if (s0 === peg$FAILED) {
1079
1124
  s0 = peg$parseLinkLexeme();
1080
1125
  if (s0 === peg$FAILED) {
1081
- s0 = peg$parseHtmlElement();
1126
+ s0 = peg$parseEmailAutolink();
1082
1127
  if (s0 === peg$FAILED) {
1083
- s0 = peg$parseVoidCloser();
1128
+ s0 = peg$parseHtmlElement();
1084
1129
  if (s0 === peg$FAILED) {
1085
- s0 = peg$parseValue();
1130
+ s0 = peg$parseVoidCloser();
1086
1131
  if (s0 === peg$FAILED) {
1087
- s0 = peg$parseMacroElement();
1088
- if (s0 === peg$FAILED) s0 = peg$parseLiteral();
1132
+ s0 = peg$parseValue();
1133
+ if (s0 === peg$FAILED) {
1134
+ s0 = peg$parseMacroElement();
1135
+ if (s0 === peg$FAILED) s0 = peg$parseLiteral();
1136
+ }
1089
1137
  }
1090
1138
  }
1091
1139
  }
@@ -1433,35 +1481,18 @@ function peg$parse(input, options) {
1433
1481
  if (s0 === peg$FAILED) {
1434
1482
  s0 = peg$parseLinkLexeme();
1435
1483
  if (s0 === peg$FAILED) {
1436
- s0 = peg$currPos;
1437
- peg$savedPos = peg$currPos;
1438
- s1 = peg$f29();
1439
- if (s1) s1 = void 0;
1440
- else s1 = peg$FAILED;
1441
- if (s1 !== peg$FAILED) {
1442
- s2 = peg$parseHtmlOpen();
1443
- if (s2 !== peg$FAILED) {
1444
- peg$savedPos = s0;
1445
- s0 = peg$f30(s2);
1446
- } else {
1447
- peg$currPos = s0;
1448
- s0 = peg$FAILED;
1449
- }
1450
- } else {
1451
- peg$currPos = s0;
1452
- s0 = peg$FAILED;
1453
- }
1484
+ s0 = peg$parseEmailAutolink();
1454
1485
  if (s0 === peg$FAILED) {
1455
1486
  s0 = peg$currPos;
1456
1487
  peg$savedPos = peg$currPos;
1457
- s1 = peg$f31();
1488
+ s1 = peg$f29();
1458
1489
  if (s1) s1 = void 0;
1459
1490
  else s1 = peg$FAILED;
1460
1491
  if (s1 !== peg$FAILED) {
1461
- s2 = peg$parseHtmlClose();
1492
+ s2 = peg$parseHtmlOpen();
1462
1493
  if (s2 !== peg$FAILED) {
1463
1494
  peg$savedPos = s0;
1464
- s0 = peg$f32(s2);
1495
+ s0 = peg$f30(s2);
1465
1496
  } else {
1466
1497
  peg$currPos = s0;
1467
1498
  s0 = peg$FAILED;
@@ -1471,37 +1502,57 @@ function peg$parse(input, options) {
1471
1502
  s0 = peg$FAILED;
1472
1503
  }
1473
1504
  if (s0 === peg$FAILED) {
1474
- s0 = peg$parseValue();
1505
+ s0 = peg$currPos;
1506
+ peg$savedPos = peg$currPos;
1507
+ s1 = peg$f31();
1508
+ if (s1) s1 = void 0;
1509
+ else s1 = peg$FAILED;
1510
+ if (s1 !== peg$FAILED) {
1511
+ s2 = peg$parseHtmlClose();
1512
+ if (s2 !== peg$FAILED) {
1513
+ peg$savedPos = s0;
1514
+ s0 = peg$f32(s2);
1515
+ } else {
1516
+ peg$currPos = s0;
1517
+ s0 = peg$FAILED;
1518
+ }
1519
+ } else {
1520
+ peg$currPos = s0;
1521
+ s0 = peg$FAILED;
1522
+ }
1475
1523
  if (s0 === peg$FAILED) {
1476
- s0 = peg$currPos;
1477
- s1 = peg$parseMacroTag();
1478
- if (s1 !== peg$FAILED) {
1479
- s2 = peg$currPos;
1480
- peg$savedPos = peg$currPos;
1481
- s3 = peg$f33(s1);
1482
- if (s3) s3 = void 0;
1483
- else s3 = peg$FAILED;
1484
- if (s3 !== peg$FAILED) {
1485
- s4 = peg$parseRawTokens();
1486
- if (s4 !== peg$FAILED) {
1487
- peg$savedPos = s2;
1488
- s2 = peg$f34(s1, s4);
1524
+ s0 = peg$parseValue();
1525
+ if (s0 === peg$FAILED) {
1526
+ s0 = peg$currPos;
1527
+ s1 = peg$parseMacroTag();
1528
+ if (s1 !== peg$FAILED) {
1529
+ s2 = peg$currPos;
1530
+ peg$savedPos = peg$currPos;
1531
+ s3 = peg$f33(s1);
1532
+ if (s3) s3 = void 0;
1533
+ else s3 = peg$FAILED;
1534
+ if (s3 !== peg$FAILED) {
1535
+ s4 = peg$parseRawTokens();
1536
+ if (s4 !== peg$FAILED) {
1537
+ peg$savedPos = s2;
1538
+ s2 = peg$f34(s1, s4);
1539
+ } else {
1540
+ peg$currPos = s2;
1541
+ s2 = peg$FAILED;
1542
+ }
1489
1543
  } else {
1490
1544
  peg$currPos = s2;
1491
1545
  s2 = peg$FAILED;
1492
1546
  }
1547
+ if (s2 === peg$FAILED) s2 = null;
1548
+ peg$savedPos = s0;
1549
+ s0 = peg$f35(s1, s2);
1493
1550
  } else {
1494
- peg$currPos = s2;
1495
- s2 = peg$FAILED;
1551
+ peg$currPos = s0;
1552
+ s0 = peg$FAILED;
1496
1553
  }
1497
- if (s2 === peg$FAILED) s2 = null;
1498
- peg$savedPos = s0;
1499
- s0 = peg$f35(s1, s2);
1500
- } else {
1501
- peg$currPos = s0;
1502
- s0 = peg$FAILED;
1554
+ if (s0 === peg$FAILED) s0 = peg$parseLiteral();
1503
1555
  }
1504
- if (s0 === peg$FAILED) s0 = peg$parseLiteral();
1505
1556
  }
1506
1557
  }
1507
1558
  }
@@ -2643,23 +2694,136 @@ function peg$parse(input, options) {
2643
2694
  else s0 = s1;
2644
2695
  return s0;
2645
2696
  }
2697
+ function peg$parseEmailAutolink() {
2698
+ let s0, s1, s2, s3, s4, s5, s6, s7;
2699
+ s0 = peg$currPos;
2700
+ s1 = peg$currPos;
2701
+ s2 = peg$currPos;
2702
+ if (input.charCodeAt(peg$currPos) === 60) {
2703
+ s3 = peg$c6;
2704
+ peg$currPos++;
2705
+ } else {
2706
+ s3 = peg$FAILED;
2707
+ if (peg$silentFails === 0) peg$fail(peg$e10);
2708
+ }
2709
+ if (s3 !== peg$FAILED) {
2710
+ s4 = [];
2711
+ s5 = input.charAt(peg$currPos);
2712
+ if (peg$r10.test(s5)) peg$currPos++;
2713
+ else {
2714
+ s5 = peg$FAILED;
2715
+ if (peg$silentFails === 0) peg$fail(peg$e24);
2716
+ }
2717
+ if (s5 !== peg$FAILED) while (s5 !== peg$FAILED) {
2718
+ s4.push(s5);
2719
+ s5 = input.charAt(peg$currPos);
2720
+ if (peg$r10.test(s5)) peg$currPos++;
2721
+ else {
2722
+ s5 = peg$FAILED;
2723
+ if (peg$silentFails === 0) peg$fail(peg$e24);
2724
+ }
2725
+ }
2726
+ else s4 = peg$FAILED;
2727
+ if (s4 !== peg$FAILED) {
2728
+ if (input.charCodeAt(peg$currPos) === 64) {
2729
+ s5 = peg$c13;
2730
+ peg$currPos++;
2731
+ } else {
2732
+ s5 = peg$FAILED;
2733
+ if (peg$silentFails === 0) peg$fail(peg$e25);
2734
+ }
2735
+ if (s5 !== peg$FAILED) {
2736
+ s6 = [];
2737
+ s7 = input.charAt(peg$currPos);
2738
+ if (peg$r11.test(s7)) peg$currPos++;
2739
+ else {
2740
+ s7 = peg$FAILED;
2741
+ if (peg$silentFails === 0) peg$fail(peg$e26);
2742
+ }
2743
+ if (s7 !== peg$FAILED) while (s7 !== peg$FAILED) {
2744
+ s6.push(s7);
2745
+ s7 = input.charAt(peg$currPos);
2746
+ if (peg$r11.test(s7)) peg$currPos++;
2747
+ else {
2748
+ s7 = peg$FAILED;
2749
+ if (peg$silentFails === 0) peg$fail(peg$e26);
2750
+ }
2751
+ }
2752
+ else s6 = peg$FAILED;
2753
+ if (s6 !== peg$FAILED) {
2754
+ if (input.charCodeAt(peg$currPos) === 62) {
2755
+ s7 = peg$c1;
2756
+ peg$currPos++;
2757
+ } else {
2758
+ s7 = peg$FAILED;
2759
+ if (peg$silentFails === 0) peg$fail(peg$e3);
2760
+ }
2761
+ if (s7 !== peg$FAILED) {
2762
+ s3 = [
2763
+ s3,
2764
+ s4,
2765
+ s5,
2766
+ s6,
2767
+ s7
2768
+ ];
2769
+ s2 = s3;
2770
+ } else {
2771
+ peg$currPos = s2;
2772
+ s2 = peg$FAILED;
2773
+ }
2774
+ } else {
2775
+ peg$currPos = s2;
2776
+ s2 = peg$FAILED;
2777
+ }
2778
+ } else {
2779
+ peg$currPos = s2;
2780
+ s2 = peg$FAILED;
2781
+ }
2782
+ } else {
2783
+ peg$currPos = s2;
2784
+ s2 = peg$FAILED;
2785
+ }
2786
+ } else {
2787
+ peg$currPos = s2;
2788
+ s2 = peg$FAILED;
2789
+ }
2790
+ if (s2 !== peg$FAILED) s1 = input.substring(s1, peg$currPos);
2791
+ else s1 = s2;
2792
+ if (s1 !== peg$FAILED) {
2793
+ peg$savedPos = peg$currPos;
2794
+ s2 = peg$f68(s1);
2795
+ if (s2) s2 = void 0;
2796
+ else s2 = peg$FAILED;
2797
+ if (s2 !== peg$FAILED) {
2798
+ peg$savedPos = s0;
2799
+ s0 = peg$f69(s1);
2800
+ } else {
2801
+ peg$currPos = s0;
2802
+ s0 = peg$FAILED;
2803
+ }
2804
+ } else {
2805
+ peg$currPos = s0;
2806
+ s0 = peg$FAILED;
2807
+ }
2808
+ return s0;
2809
+ }
2646
2810
  function peg$parseVoidCloser() {
2647
2811
  let s0, s1, s2, s3;
2648
2812
  s0 = peg$currPos;
2649
2813
  peg$savedPos = peg$currPos;
2650
- s1 = peg$f68();
2814
+ s1 = peg$f70();
2651
2815
  if (s1) s1 = void 0;
2652
2816
  else s1 = peg$FAILED;
2653
2817
  if (s1 !== peg$FAILED) {
2654
2818
  s2 = peg$parseHtmlClose();
2655
2819
  if (s2 !== peg$FAILED) {
2656
2820
  peg$savedPos = peg$currPos;
2657
- s3 = peg$f69(s2);
2821
+ s3 = peg$f71(s2);
2658
2822
  if (s3) s3 = void 0;
2659
2823
  else s3 = peg$FAILED;
2660
2824
  if (s3 !== peg$FAILED) {
2661
2825
  peg$savedPos = s0;
2662
- s0 = peg$f70(s2);
2826
+ s0 = peg$f72(s2);
2663
2827
  } else {
2664
2828
  peg$currPos = s0;
2665
2829
  s0 = peg$FAILED;
@@ -2711,7 +2875,7 @@ function peg$parse(input, options) {
2711
2875
  }
2712
2876
  if (s6 !== peg$FAILED) {
2713
2877
  peg$savedPos = s0;
2714
- s0 = peg$f71(s2, s3, s5);
2878
+ s0 = peg$f73(s2, s3, s5);
2715
2879
  } else {
2716
2880
  peg$currPos = s0;
2717
2881
  s0 = peg$FAILED;
@@ -2739,10 +2903,10 @@ function peg$parse(input, options) {
2739
2903
  s3 = peg$currPos;
2740
2904
  peg$silentFails++;
2741
2905
  s4 = input.charAt(peg$currPos);
2742
- if (peg$r10.test(s4)) peg$currPos++;
2906
+ if (peg$r12.test(s4)) peg$currPos++;
2743
2907
  else {
2744
2908
  s4 = peg$FAILED;
2745
- if (peg$silentFails === 0) peg$fail(peg$e24);
2909
+ if (peg$silentFails === 0) peg$fail(peg$e27);
2746
2910
  }
2747
2911
  if (s4 === peg$FAILED) {
2748
2912
  s4 = peg$currPos;
@@ -2776,7 +2940,7 @@ function peg$parse(input, options) {
2776
2940
  s5 = peg$parse_();
2777
2941
  s6 = peg$parseHere();
2778
2942
  peg$savedPos = s0;
2779
- s0 = peg$f72(s2, s6);
2943
+ s0 = peg$f74(s2, s6);
2780
2944
  } else {
2781
2945
  peg$currPos = s0;
2782
2946
  s0 = peg$FAILED;
@@ -2795,12 +2959,12 @@ function peg$parse(input, options) {
2795
2959
  function peg$parseHtmlClose() {
2796
2960
  let s0, s1, s2, s4;
2797
2961
  s0 = peg$currPos;
2798
- if (input.substr(peg$currPos, 2) === peg$c13) {
2799
- s1 = peg$c13;
2962
+ if (input.substr(peg$currPos, 2) === peg$c14) {
2963
+ s1 = peg$c14;
2800
2964
  peg$currPos += 2;
2801
2965
  } else {
2802
2966
  s1 = peg$FAILED;
2803
- if (peg$silentFails === 0) peg$fail(peg$e25);
2967
+ if (peg$silentFails === 0) peg$fail(peg$e28);
2804
2968
  }
2805
2969
  if (s1 !== peg$FAILED) {
2806
2970
  s2 = peg$parseTagName();
@@ -2815,7 +2979,7 @@ function peg$parse(input, options) {
2815
2979
  }
2816
2980
  if (s4 !== peg$FAILED) {
2817
2981
  peg$savedPos = s0;
2818
- s0 = peg$f73(s2);
2982
+ s0 = peg$f75(s2);
2819
2983
  } else {
2820
2984
  peg$currPos = s0;
2821
2985
  s0 = peg$FAILED;
@@ -2843,18 +3007,18 @@ function peg$parse(input, options) {
2843
3007
  if (s2 !== peg$FAILED) {
2844
3008
  s3 = [];
2845
3009
  s4 = input.charAt(peg$currPos);
2846
- if (peg$r11.test(s4)) peg$currPos++;
3010
+ if (peg$r13.test(s4)) peg$currPos++;
2847
3011
  else {
2848
3012
  s4 = peg$FAILED;
2849
- if (peg$silentFails === 0) peg$fail(peg$e26);
3013
+ if (peg$silentFails === 0) peg$fail(peg$e29);
2850
3014
  }
2851
3015
  while (s4 !== peg$FAILED) {
2852
3016
  s3.push(s4);
2853
3017
  s4 = input.charAt(peg$currPos);
2854
- if (peg$r11.test(s4)) peg$currPos++;
3018
+ if (peg$r13.test(s4)) peg$currPos++;
2855
3019
  else {
2856
3020
  s4 = peg$FAILED;
2857
- if (peg$silentFails === 0) peg$fail(peg$e26);
3021
+ if (peg$silentFails === 0) peg$fail(peg$e29);
2858
3022
  }
2859
3023
  }
2860
3024
  s2 = [s2, s3];
@@ -2877,10 +3041,10 @@ function peg$parse(input, options) {
2877
3041
  s5 = peg$currPos;
2878
3042
  peg$silentFails++;
2879
3043
  s6 = input.charAt(peg$currPos);
2880
- if (peg$r12.test(s6)) peg$currPos++;
3044
+ if (peg$r14.test(s6)) peg$currPos++;
2881
3045
  else {
2882
3046
  s6 = peg$FAILED;
2883
- if (peg$silentFails === 0) peg$fail(peg$e27);
3047
+ if (peg$silentFails === 0) peg$fail(peg$e30);
2884
3048
  }
2885
3049
  peg$silentFails--;
2886
3050
  if (s6 === peg$FAILED) s5 = void 0;
@@ -2913,10 +3077,10 @@ function peg$parse(input, options) {
2913
3077
  s5 = peg$currPos;
2914
3078
  peg$silentFails++;
2915
3079
  s6 = input.charAt(peg$currPos);
2916
- if (peg$r12.test(s6)) peg$currPos++;
3080
+ if (peg$r14.test(s6)) peg$currPos++;
2917
3081
  else {
2918
3082
  s6 = peg$FAILED;
2919
- if (peg$silentFails === 0) peg$fail(peg$e27);
3083
+ if (peg$silentFails === 0) peg$fail(peg$e30);
2920
3084
  }
2921
3085
  peg$silentFails--;
2922
3086
  if (s6 === peg$FAILED) s5 = void 0;
@@ -2949,25 +3113,25 @@ function peg$parse(input, options) {
2949
3113
  else s2 = s3;
2950
3114
  if (s2 !== peg$FAILED) {
2951
3115
  peg$savedPos = peg$currPos;
2952
- s3 = peg$f74(s2);
3116
+ s3 = peg$f76(s2);
2953
3117
  if (s3) s3 = void 0;
2954
3118
  else s3 = peg$FAILED;
2955
3119
  if (s3 !== peg$FAILED) {
2956
3120
  s4 = peg$currPos;
2957
3121
  s5 = peg$parse_();
2958
3122
  if (input.charCodeAt(peg$currPos) === 61) {
2959
- s6 = peg$c14;
3123
+ s6 = peg$c15;
2960
3124
  peg$currPos++;
2961
3125
  } else {
2962
3126
  s6 = peg$FAILED;
2963
- if (peg$silentFails === 0) peg$fail(peg$e28);
3127
+ if (peg$silentFails === 0) peg$fail(peg$e31);
2964
3128
  }
2965
3129
  if (s6 !== peg$FAILED) {
2966
3130
  peg$parse_();
2967
3131
  s8 = peg$parseAttrValue();
2968
3132
  if (s8 !== peg$FAILED) {
2969
3133
  peg$savedPos = s4;
2970
- s4 = peg$f75(s2, s8);
3134
+ s4 = peg$f77(s2, s8);
2971
3135
  } else {
2972
3136
  peg$currPos = s4;
2973
3137
  s4 = peg$FAILED;
@@ -2978,7 +3142,7 @@ function peg$parse(input, options) {
2978
3142
  }
2979
3143
  if (s4 === peg$FAILED) s4 = null;
2980
3144
  peg$savedPos = s0;
2981
- s0 = peg$f76(s2, s4);
3145
+ s0 = peg$f78(s2, s4);
2982
3146
  } else {
2983
3147
  peg$currPos = s0;
2984
3148
  s0 = peg$FAILED;
@@ -2993,11 +3157,11 @@ function peg$parse(input, options) {
2993
3157
  let s0, s1, s2, s3, s4;
2994
3158
  s0 = peg$currPos;
2995
3159
  if (input.charCodeAt(peg$currPos) === 34) {
2996
- s1 = peg$c15;
3160
+ s1 = peg$c16;
2997
3161
  peg$currPos++;
2998
3162
  } else {
2999
3163
  s1 = peg$FAILED;
3000
- if (peg$silentFails === 0) peg$fail(peg$e29);
3164
+ if (peg$silentFails === 0) peg$fail(peg$e32);
3001
3165
  }
3002
3166
  if (s1 !== peg$FAILED) {
3003
3167
  s2 = peg$currPos;
@@ -3005,10 +3169,10 @@ function peg$parse(input, options) {
3005
3169
  s4 = peg$parseValuePart();
3006
3170
  if (s4 === peg$FAILED) {
3007
3171
  s4 = input.charAt(peg$currPos);
3008
- if (peg$r13.test(s4)) peg$currPos++;
3172
+ if (peg$r15.test(s4)) peg$currPos++;
3009
3173
  else {
3010
3174
  s4 = peg$FAILED;
3011
- if (peg$silentFails === 0) peg$fail(peg$e30);
3175
+ if (peg$silentFails === 0) peg$fail(peg$e33);
3012
3176
  }
3013
3177
  }
3014
3178
  while (s4 !== peg$FAILED) {
@@ -3016,24 +3180,24 @@ function peg$parse(input, options) {
3016
3180
  s4 = peg$parseValuePart();
3017
3181
  if (s4 === peg$FAILED) {
3018
3182
  s4 = input.charAt(peg$currPos);
3019
- if (peg$r13.test(s4)) peg$currPos++;
3183
+ if (peg$r15.test(s4)) peg$currPos++;
3020
3184
  else {
3021
3185
  s4 = peg$FAILED;
3022
- if (peg$silentFails === 0) peg$fail(peg$e30);
3186
+ if (peg$silentFails === 0) peg$fail(peg$e33);
3023
3187
  }
3024
3188
  }
3025
3189
  }
3026
3190
  s2 = input.substring(s2, peg$currPos);
3027
3191
  if (input.charCodeAt(peg$currPos) === 34) {
3028
- s3 = peg$c15;
3192
+ s3 = peg$c16;
3029
3193
  peg$currPos++;
3030
3194
  } else {
3031
3195
  s3 = peg$FAILED;
3032
- if (peg$silentFails === 0) peg$fail(peg$e29);
3196
+ if (peg$silentFails === 0) peg$fail(peg$e32);
3033
3197
  }
3034
3198
  if (s3 !== peg$FAILED) {
3035
3199
  peg$savedPos = s0;
3036
- s0 = peg$f77(s2);
3200
+ s0 = peg$f79(s2);
3037
3201
  } else {
3038
3202
  peg$currPos = s0;
3039
3203
  s0 = peg$FAILED;
@@ -3045,11 +3209,11 @@ function peg$parse(input, options) {
3045
3209
  if (s0 === peg$FAILED) {
3046
3210
  s0 = peg$currPos;
3047
3211
  if (input.charCodeAt(peg$currPos) === 39) {
3048
- s1 = peg$c16;
3212
+ s1 = peg$c17;
3049
3213
  peg$currPos++;
3050
3214
  } else {
3051
3215
  s1 = peg$FAILED;
3052
- if (peg$silentFails === 0) peg$fail(peg$e31);
3216
+ if (peg$silentFails === 0) peg$fail(peg$e34);
3053
3217
  }
3054
3218
  if (s1 !== peg$FAILED) {
3055
3219
  s2 = peg$currPos;
@@ -3057,10 +3221,10 @@ function peg$parse(input, options) {
3057
3221
  s4 = peg$parseValuePart();
3058
3222
  if (s4 === peg$FAILED) {
3059
3223
  s4 = input.charAt(peg$currPos);
3060
- if (peg$r14.test(s4)) peg$currPos++;
3224
+ if (peg$r16.test(s4)) peg$currPos++;
3061
3225
  else {
3062
3226
  s4 = peg$FAILED;
3063
- if (peg$silentFails === 0) peg$fail(peg$e32);
3227
+ if (peg$silentFails === 0) peg$fail(peg$e35);
3064
3228
  }
3065
3229
  }
3066
3230
  while (s4 !== peg$FAILED) {
@@ -3068,24 +3232,24 @@ function peg$parse(input, options) {
3068
3232
  s4 = peg$parseValuePart();
3069
3233
  if (s4 === peg$FAILED) {
3070
3234
  s4 = input.charAt(peg$currPos);
3071
- if (peg$r14.test(s4)) peg$currPos++;
3235
+ if (peg$r16.test(s4)) peg$currPos++;
3072
3236
  else {
3073
3237
  s4 = peg$FAILED;
3074
- if (peg$silentFails === 0) peg$fail(peg$e32);
3238
+ if (peg$silentFails === 0) peg$fail(peg$e35);
3075
3239
  }
3076
3240
  }
3077
3241
  }
3078
3242
  s2 = input.substring(s2, peg$currPos);
3079
3243
  if (input.charCodeAt(peg$currPos) === 39) {
3080
- s3 = peg$c16;
3244
+ s3 = peg$c17;
3081
3245
  peg$currPos++;
3082
3246
  } else {
3083
3247
  s3 = peg$FAILED;
3084
- if (peg$silentFails === 0) peg$fail(peg$e31);
3248
+ if (peg$silentFails === 0) peg$fail(peg$e34);
3085
3249
  }
3086
3250
  if (s3 !== peg$FAILED) {
3087
3251
  peg$savedPos = s0;
3088
- s0 = peg$f78(s2);
3252
+ s0 = peg$f80(s2);
3089
3253
  } else {
3090
3254
  peg$currPos = s0;
3091
3255
  s0 = peg$FAILED;
@@ -3097,32 +3261,32 @@ function peg$parse(input, options) {
3097
3261
  if (s0 === peg$FAILED) {
3098
3262
  s0 = peg$currPos;
3099
3263
  s1 = input.charAt(peg$currPos);
3100
- if (peg$r15.test(s1)) peg$currPos++;
3264
+ if (peg$r17.test(s1)) peg$currPos++;
3101
3265
  else {
3102
3266
  s1 = peg$FAILED;
3103
- if (peg$silentFails === 0) peg$fail(peg$e33);
3267
+ if (peg$silentFails === 0) peg$fail(peg$e36);
3104
3268
  }
3105
3269
  if (s1 !== peg$FAILED) {
3106
3270
  peg$savedPos = s0;
3107
- s1 = peg$f79(s1);
3271
+ s1 = peg$f81(s1);
3108
3272
  }
3109
3273
  s0 = s1;
3110
3274
  if (s0 === peg$FAILED) {
3111
3275
  s0 = peg$currPos;
3112
3276
  s1 = [];
3113
3277
  s2 = input.charAt(peg$currPos);
3114
- if (peg$r16.test(s2)) peg$currPos++;
3278
+ if (peg$r18.test(s2)) peg$currPos++;
3115
3279
  else {
3116
3280
  s2 = peg$FAILED;
3117
- if (peg$silentFails === 0) peg$fail(peg$e34);
3281
+ if (peg$silentFails === 0) peg$fail(peg$e37);
3118
3282
  }
3119
3283
  while (s2 !== peg$FAILED) {
3120
3284
  s1.push(s2);
3121
3285
  s2 = input.charAt(peg$currPos);
3122
- if (peg$r16.test(s2)) peg$currPos++;
3286
+ if (peg$r18.test(s2)) peg$currPos++;
3123
3287
  else {
3124
3288
  s2 = peg$FAILED;
3125
- if (peg$silentFails === 0) peg$fail(peg$e34);
3289
+ if (peg$silentFails === 0) peg$fail(peg$e37);
3126
3290
  }
3127
3291
  }
3128
3292
  s0 = input.substring(s0, peg$currPos);
@@ -3135,7 +3299,7 @@ function peg$parse(input, options) {
3135
3299
  let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13;
3136
3300
  s0 = peg$currPos;
3137
3301
  peg$savedPos = peg$currPos;
3138
- s1 = peg$f80();
3302
+ s1 = peg$f82();
3139
3303
  if (s1) s1 = void 0;
3140
3304
  else s1 = peg$FAILED;
3141
3305
  if (s1 !== peg$FAILED) {
@@ -3164,7 +3328,7 @@ function peg$parse(input, options) {
3164
3328
  if (s2 !== peg$FAILED) {
3165
3329
  s3 = peg$currPos;
3166
3330
  peg$savedPos = peg$currPos;
3167
- s4 = peg$f81(s2);
3331
+ s4 = peg$f83(s2);
3168
3332
  if (s4) s4 = void 0;
3169
3333
  else s4 = peg$FAILED;
3170
3334
  if (s4 !== peg$FAILED) {
@@ -3203,7 +3367,7 @@ function peg$parse(input, options) {
3203
3367
  if (s0 === peg$FAILED) {
3204
3368
  s0 = peg$currPos;
3205
3369
  peg$savedPos = peg$currPos;
3206
- s1 = peg$f82();
3370
+ s1 = peg$f84();
3207
3371
  if (s1) s1 = void 0;
3208
3372
  else s1 = peg$FAILED;
3209
3373
  if (s1 !== peg$FAILED) {
@@ -3230,12 +3394,12 @@ function peg$parse(input, options) {
3230
3394
  if (s6 !== peg$FAILED) {
3231
3395
  s7 = peg$parseHere();
3232
3396
  peg$savedPos = peg$currPos;
3233
- s8 = peg$f83(s4, s7);
3397
+ s8 = peg$f85(s4, s7);
3234
3398
  if (s8) s8 = void 0;
3235
3399
  else s8 = peg$FAILED;
3236
3400
  if (s8 !== peg$FAILED) {
3237
3401
  s9 = peg$currPos;
3238
- s10 = peg$f84(s4, s7);
3402
+ s10 = peg$f86(s4, s7);
3239
3403
  s11 = peg$currPos;
3240
3404
  s12 = [];
3241
3405
  if (s12.length >= (s10 | 0)) s13 = peg$FAILED;
@@ -3317,7 +3481,7 @@ function peg$parse(input, options) {
3317
3481
  if (s0 === peg$FAILED) {
3318
3482
  s0 = peg$currPos;
3319
3483
  peg$savedPos = peg$currPos;
3320
- s1 = peg$f85();
3484
+ s1 = peg$f87();
3321
3485
  if (s1) s1 = void 0;
3322
3486
  else s1 = peg$FAILED;
3323
3487
  if (s1 !== peg$FAILED) {
@@ -3408,7 +3572,7 @@ function peg$parse(input, options) {
3408
3572
  if (s0 === peg$FAILED) {
3409
3573
  s0 = peg$currPos;
3410
3574
  peg$savedPos = peg$currPos;
3411
- s1 = peg$f86();
3575
+ s1 = peg$f88();
3412
3576
  if (s1) s1 = void 0;
3413
3577
  else s1 = peg$FAILED;
3414
3578
  if (s1 !== peg$FAILED) {
@@ -3490,10 +3654,10 @@ function peg$parse(input, options) {
3490
3654
  function peg$parse_c() {
3491
3655
  let s0;
3492
3656
  s0 = input.charAt(peg$currPos);
3493
- if (peg$r17.test(s0)) peg$currPos++;
3657
+ if (peg$r19.test(s0)) peg$currPos++;
3494
3658
  else {
3495
3659
  s0 = peg$FAILED;
3496
- if (peg$silentFails === 0) peg$fail(peg$e35);
3660
+ if (peg$silentFails === 0) peg$fail(peg$e38);
3497
3661
  }
3498
3662
  return s0;
3499
3663
  }
@@ -9961,7 +10125,30 @@ function errorMessage(err, fallback) {
9961
10125
  return fallback ?? String(err);
9962
10126
  }
9963
10127
  //#endregion
10128
+ //#region src/utils/listeners.ts
10129
+ /**
10130
+ * A set of listeners to call when something happens: `subscribe` adds one and
10131
+ * returns the function that removes it, `notify` calls each one. A listener
10132
+ * removed or added while they are called is called or not as the set was
10133
+ * when `notify` started.
10134
+ */
10135
+ function createListeners() {
10136
+ const listeners = /* @__PURE__ */ new Set();
10137
+ return {
10138
+ subscribe(listener) {
10139
+ listeners.add(listener);
10140
+ return () => {
10141
+ listeners.delete(listener);
10142
+ };
10143
+ },
10144
+ notify() {
10145
+ for (const listener of [...listeners]) listener();
10146
+ }
10147
+ };
10148
+ }
10149
+ //#endregion
9964
10150
  //#region src/runtime-errors.ts
10151
+ var listeners = createListeners();
9965
10152
  /**
9966
10153
  * The error for `name`, a passage name that names no passage, used in the
9967
10154
  * passage `from`.
@@ -9969,6 +10156,7 @@ function errorMessage(err, fallback) {
9969
10156
  function noPassageError(name, from) {
9970
10157
  return /* @__PURE__ */ new Error(`No passage named ${JSON.stringify(name)} (in passage ${JSON.stringify(from)})`);
9971
10158
  }
10159
+ listeners.subscribe;
9972
10160
  //#endregion
9973
10161
  //#region src/components/macros/arg-utils.ts
9974
10162
  /**
@@ -11086,16 +11274,25 @@ var VALID_VAR_TYPES = new Set([
11086
11274
  "string",
11087
11275
  "boolean"
11088
11276
  ]);
11089
- function inferSchema(value) {
11277
+ /**
11278
+ * The schema of a default value. An object met again (a backreference, a
11279
+ * shared subtree) has the schema made for it the first time, so a cyclic
11280
+ * default gives a schema that refers to itself instead of recursing forever.
11281
+ */
11282
+ function inferSchema(value, seen = /* @__PURE__ */ new Map()) {
11090
11283
  if (Array.isArray(value)) return { type: "array" };
11091
11284
  if (value === null) return { type: "null" };
11092
11285
  if (typeof value === "object") {
11286
+ const known = seen.get(value);
11287
+ if (known) return known;
11093
11288
  const fields = /* @__PURE__ */ new Map();
11094
- for (const [key, val] of Object.entries(value)) fields.set(key, inferSchema(val));
11095
- return {
11289
+ const schema = {
11096
11290
  type: "object",
11097
11291
  fields
11098
11292
  };
11293
+ seen.set(value, schema);
11294
+ for (const [key, val] of Object.entries(value)) fields.set(key, inferSchema(val, seen));
11295
+ return schema;
11099
11296
  }
11100
11297
  const jsType = typeof value;
11101
11298
  if (!VALID_VAR_TYPES.has(jsType)) throw new Error(`Unsupported type "${jsType}" for value ${String(value)}. Expected number, string, boolean, array, or object.`);