@rohal12/spindle 0.59.14 → 0.59.15
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/dist/pkg/format.js +1 -1
- package/dist/pkg/headless.js +537 -238
- package/dist/pkg/story-variables.js +313 -149
- package/package.json +1 -1
- package/src/class-registry.ts +105 -35
- package/src/components/Passage.tsx +21 -13
- package/src/components/PassageDialog.tsx +12 -2
- package/src/components/macros/Radiobutton.tsx +4 -1
- package/src/execute-mutation.ts +3 -2
- package/src/markup/render.tsx +17 -1
- package/src/markup/spindle.peggy +16 -0
- package/src/store.ts +12 -2
- package/src/structural.ts +74 -38
- package/src/triggers.ts +6 -2
- package/src/utils/stable-key.ts +8 -4
- package/src/utils/value-kinds.ts +42 -0
- package/types/index.d.ts +3 -1
package/dist/pkg/headless.js
CHANGED
|
@@ -124,6 +124,11 @@ var LINK_SEPARATORS = [
|
|
|
124
124
|
];
|
|
125
125
|
var NO_SELECTORS = {};
|
|
126
126
|
/**
|
|
127
|
+
* A CommonMark email autolink, `<` an address `>` (without braces, which
|
|
128
|
+
* are markup), as markdown reads one.
|
|
129
|
+
*/
|
|
130
|
+
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])?)*>$/;
|
|
131
|
+
/**
|
|
127
132
|
* A link's display text and target, from its text `inner` (at `at` in the
|
|
128
133
|
* input), with where the target is written.
|
|
129
134
|
*/
|
|
@@ -401,10 +406,11 @@ function peg$parse(input, options) {
|
|
|
401
406
|
const peg$c10 = " ";
|
|
402
407
|
const peg$c11 = "}";
|
|
403
408
|
const peg$c12 = "/";
|
|
404
|
-
const peg$c13 = "
|
|
405
|
-
const peg$c14 = "
|
|
406
|
-
const peg$c15 = "
|
|
407
|
-
const peg$c16 = "
|
|
409
|
+
const peg$c13 = "@";
|
|
410
|
+
const peg$c14 = "</";
|
|
411
|
+
const peg$c15 = "=";
|
|
412
|
+
const peg$c16 = "\"";
|
|
413
|
+
const peg$c17 = "'";
|
|
408
414
|
const peg$r0 = /^[^\\{[<]/;
|
|
409
415
|
const peg$r1 = /^[{}]/;
|
|
410
416
|
const peg$r2 = /^[$_@%(!\/a-zA-Z]/;
|
|
@@ -415,14 +421,16 @@ function peg$parse(input, options) {
|
|
|
415
421
|
const peg$r7 = /^[$_@%(!]/;
|
|
416
422
|
const peg$r8 = /^[a-zA-Z]/;
|
|
417
423
|
const peg$r9 = /^[^ \t\n\r\v\f\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF}]/;
|
|
418
|
-
const peg$r10 = /^[
|
|
419
|
-
const peg$r11 = /^[a-zA-Z0-9
|
|
420
|
-
const peg$r12 = /^[\t-\r
|
|
421
|
-
const peg$r13 = /^[
|
|
422
|
-
const peg$r14 = /^[
|
|
423
|
-
const peg$r15 = /^["
|
|
424
|
-
const peg$r16 = /^[^
|
|
425
|
-
const peg$r17 = /^[
|
|
424
|
+
const peg$r10 = /^[a-zA-Z0-9.!#$%&'*+\/=?\^_`|~\-]/;
|
|
425
|
+
const peg$r11 = /^[a-zA-Z0-9.\-]/;
|
|
426
|
+
const peg$r12 = /^[\t-\r \/>\xA0\u1680\u2000-\u200A\u2028-\u2029\u202F\u205F\u3000\uFEFF]/;
|
|
427
|
+
const peg$r13 = /^[a-zA-Z0-9\-]/;
|
|
428
|
+
const peg$r14 = /^[\t-\r "'\/<->{}\xA0\u1680\u2000-\u200A\u2028-\u2029\u202F\u205F\u3000\uFEFF]/;
|
|
429
|
+
const peg$r15 = /^[^"]/;
|
|
430
|
+
const peg$r16 = /^[^']/;
|
|
431
|
+
const peg$r17 = /^["']/;
|
|
432
|
+
const peg$r18 = /^[^ \t\n\r\v\f\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF>]/;
|
|
433
|
+
const peg$r19 = /^[ \t\n\r\v\f\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/;
|
|
426
434
|
const peg$e0 = peg$anyExpectation();
|
|
427
435
|
const peg$e1 = peg$classExpectation([
|
|
428
436
|
"\\",
|
|
@@ -504,6 +512,37 @@ function peg$parse(input, options) {
|
|
|
504
512
|
"}"
|
|
505
513
|
], true, false, false);
|
|
506
514
|
const peg$e24 = peg$classExpectation([
|
|
515
|
+
["a", "z"],
|
|
516
|
+
["A", "Z"],
|
|
517
|
+
["0", "9"],
|
|
518
|
+
".",
|
|
519
|
+
"!",
|
|
520
|
+
"#",
|
|
521
|
+
"$",
|
|
522
|
+
"%",
|
|
523
|
+
"&",
|
|
524
|
+
"'",
|
|
525
|
+
"*",
|
|
526
|
+
"+",
|
|
527
|
+
"/",
|
|
528
|
+
"=",
|
|
529
|
+
"?",
|
|
530
|
+
"^",
|
|
531
|
+
"_",
|
|
532
|
+
"`",
|
|
533
|
+
"|",
|
|
534
|
+
"~",
|
|
535
|
+
"-"
|
|
536
|
+
], false, false, false);
|
|
537
|
+
const peg$e25 = peg$literalExpectation("@", false);
|
|
538
|
+
const peg$e26 = peg$classExpectation([
|
|
539
|
+
["a", "z"],
|
|
540
|
+
["A", "Z"],
|
|
541
|
+
["0", "9"],
|
|
542
|
+
".",
|
|
543
|
+
"-"
|
|
544
|
+
], false, false, false);
|
|
545
|
+
const peg$e27 = peg$classExpectation([
|
|
507
546
|
[" ", "\r"],
|
|
508
547
|
" ",
|
|
509
548
|
"/",
|
|
@@ -517,14 +556,14 @@ function peg$parse(input, options) {
|
|
|
517
556
|
" ",
|
|
518
557
|
""
|
|
519
558
|
], false, false, false);
|
|
520
|
-
const peg$
|
|
521
|
-
const peg$
|
|
559
|
+
const peg$e28 = peg$literalExpectation("</", false);
|
|
560
|
+
const peg$e29 = peg$classExpectation([
|
|
522
561
|
["a", "z"],
|
|
523
562
|
["A", "Z"],
|
|
524
563
|
["0", "9"],
|
|
525
564
|
"-"
|
|
526
565
|
], false, false, false);
|
|
527
|
-
const peg$
|
|
566
|
+
const peg$e30 = peg$classExpectation([
|
|
528
567
|
[" ", "\r"],
|
|
529
568
|
" ",
|
|
530
569
|
"\"",
|
|
@@ -542,13 +581,13 @@ function peg$parse(input, options) {
|
|
|
542
581
|
" ",
|
|
543
582
|
""
|
|
544
583
|
], false, false, false);
|
|
545
|
-
const peg$
|
|
546
|
-
const peg$
|
|
547
|
-
const peg$
|
|
548
|
-
const peg$
|
|
549
|
-
const peg$
|
|
550
|
-
const peg$
|
|
551
|
-
const peg$
|
|
584
|
+
const peg$e31 = peg$literalExpectation("=", false);
|
|
585
|
+
const peg$e32 = peg$literalExpectation("\"", false);
|
|
586
|
+
const peg$e33 = peg$classExpectation(["\""], true, false, false);
|
|
587
|
+
const peg$e34 = peg$literalExpectation("'", false);
|
|
588
|
+
const peg$e35 = peg$classExpectation(["'"], true, false, false);
|
|
589
|
+
const peg$e36 = peg$classExpectation(["\"", "'"], false, false, false);
|
|
590
|
+
const peg$e37 = peg$classExpectation([
|
|
552
591
|
" ",
|
|
553
592
|
" ",
|
|
554
593
|
"\n",
|
|
@@ -566,7 +605,7 @@ function peg$parse(input, options) {
|
|
|
566
605
|
"",
|
|
567
606
|
">"
|
|
568
607
|
], true, false, false);
|
|
569
|
-
const peg$
|
|
608
|
+
const peg$e38 = peg$classExpectation([
|
|
570
609
|
" ",
|
|
571
610
|
" ",
|
|
572
611
|
"\n",
|
|
@@ -859,16 +898,22 @@ function peg$parse(input, options) {
|
|
|
859
898
|
function peg$f67(s) {
|
|
860
899
|
fail("A closing tag starts with a letter after " + LB + "/", location());
|
|
861
900
|
}
|
|
862
|
-
function peg$f68() {
|
|
901
|
+
function peg$f68(value) {
|
|
902
|
+
return EMAIL_AUTOLINK.test(value);
|
|
903
|
+
}
|
|
904
|
+
function peg$f69(value) {
|
|
905
|
+
return lexeme("text", location(), { value });
|
|
906
|
+
}
|
|
907
|
+
function peg$f70() {
|
|
863
908
|
return !textMode;
|
|
864
909
|
}
|
|
865
|
-
function peg$
|
|
910
|
+
function peg$f71(tag) {
|
|
866
911
|
return VOID_TAGS.has(tag.lower);
|
|
867
912
|
}
|
|
868
|
-
function peg$
|
|
913
|
+
function peg$f72(tag) {
|
|
869
914
|
return null;
|
|
870
915
|
}
|
|
871
|
-
function peg$
|
|
916
|
+
function peg$f73(tag, list, slash) {
|
|
872
917
|
const lower = tag.toLowerCase();
|
|
873
918
|
return lexeme("html", location(), {
|
|
874
919
|
tag,
|
|
@@ -878,7 +923,7 @@ function peg$parse(input, options) {
|
|
|
878
923
|
isSelfClose: !!slash || VOID_TAGS.has(lower)
|
|
879
924
|
});
|
|
880
925
|
}
|
|
881
|
-
function peg$
|
|
926
|
+
function peg$f74(tag, bad) {
|
|
882
927
|
const c = input.charAt(bad);
|
|
883
928
|
if (!c) fail("Unclosed tag <" + tag + ": no > ends it (write < for a < that starts no tag)", location());
|
|
884
929
|
const at = {
|
|
@@ -896,7 +941,7 @@ function peg$parse(input, options) {
|
|
|
896
941
|
};
|
|
897
942
|
fail("Unexpected " + JSON.stringify(c) + " in the tag <" + tag + ">: expected an attribute, or > to end the tag", at);
|
|
898
943
|
}
|
|
899
|
-
function peg$
|
|
944
|
+
function peg$f75(tag) {
|
|
900
945
|
return lexeme("html", location(), {
|
|
901
946
|
tag,
|
|
902
947
|
lower: tag.toLowerCase(),
|
|
@@ -905,44 +950,44 @@ function peg$parse(input, options) {
|
|
|
905
950
|
isSelfClose: false
|
|
906
951
|
});
|
|
907
952
|
}
|
|
908
|
-
function peg$
|
|
953
|
+
function peg$f76(name) {
|
|
909
954
|
attrCode = hooks.isCodeAttribute(name);
|
|
910
955
|
return true;
|
|
911
956
|
}
|
|
912
|
-
function peg$
|
|
957
|
+
function peg$f77(name, v) {
|
|
913
958
|
return v;
|
|
914
959
|
}
|
|
915
|
-
function peg$
|
|
960
|
+
function peg$f78(name, value) {
|
|
916
961
|
return [name, value ?? ""];
|
|
917
962
|
}
|
|
918
|
-
function peg$
|
|
963
|
+
function peg$f79(v) {
|
|
919
964
|
return v;
|
|
920
965
|
}
|
|
921
|
-
function peg$
|
|
966
|
+
function peg$f80(v) {
|
|
922
967
|
return v;
|
|
923
968
|
}
|
|
924
|
-
function peg$
|
|
969
|
+
function peg$f81(q) {
|
|
925
970
|
fail("Unclosed attribute value: the " + q + " here has no closing " + q, location());
|
|
926
971
|
}
|
|
927
|
-
function peg$
|
|
972
|
+
function peg$f82() {
|
|
928
973
|
return !attrCode;
|
|
929
974
|
}
|
|
930
|
-
function peg$
|
|
975
|
+
function peg$f83(bs) {
|
|
931
976
|
return bs.length % 2 === 1;
|
|
932
977
|
}
|
|
933
|
-
function peg$
|
|
978
|
+
function peg$f84() {
|
|
934
979
|
return !attrCode;
|
|
935
980
|
}
|
|
936
|
-
function peg$
|
|
981
|
+
function peg$f85(start, nameEnd) {
|
|
937
982
|
return skipTo(hooks.closeBrace(input, nameEnd, start));
|
|
938
983
|
}
|
|
939
|
-
function peg$
|
|
984
|
+
function peg$f86(start, nameEnd) {
|
|
940
985
|
return skipEnd - offset();
|
|
941
986
|
}
|
|
942
|
-
function peg$
|
|
987
|
+
function peg$f87() {
|
|
943
988
|
return !attrCode;
|
|
944
989
|
}
|
|
945
|
-
function peg$
|
|
990
|
+
function peg$f88() {
|
|
946
991
|
return attrCode;
|
|
947
992
|
}
|
|
948
993
|
let peg$currPos = options.peg$currPos | 0;
|
|
@@ -1133,14 +1178,17 @@ function peg$parse(input, options) {
|
|
|
1133
1178
|
if (s0 === peg$FAILED) {
|
|
1134
1179
|
s0 = peg$parseLinkLexeme();
|
|
1135
1180
|
if (s0 === peg$FAILED) {
|
|
1136
|
-
s0 = peg$
|
|
1181
|
+
s0 = peg$parseEmailAutolink();
|
|
1137
1182
|
if (s0 === peg$FAILED) {
|
|
1138
|
-
s0 = peg$
|
|
1183
|
+
s0 = peg$parseHtmlElement();
|
|
1139
1184
|
if (s0 === peg$FAILED) {
|
|
1140
|
-
s0 = peg$
|
|
1185
|
+
s0 = peg$parseVoidCloser();
|
|
1141
1186
|
if (s0 === peg$FAILED) {
|
|
1142
|
-
s0 = peg$
|
|
1143
|
-
if (s0 === peg$FAILED)
|
|
1187
|
+
s0 = peg$parseValue();
|
|
1188
|
+
if (s0 === peg$FAILED) {
|
|
1189
|
+
s0 = peg$parseMacroElement();
|
|
1190
|
+
if (s0 === peg$FAILED) s0 = peg$parseLiteral();
|
|
1191
|
+
}
|
|
1144
1192
|
}
|
|
1145
1193
|
}
|
|
1146
1194
|
}
|
|
@@ -1488,35 +1536,18 @@ function peg$parse(input, options) {
|
|
|
1488
1536
|
if (s0 === peg$FAILED) {
|
|
1489
1537
|
s0 = peg$parseLinkLexeme();
|
|
1490
1538
|
if (s0 === peg$FAILED) {
|
|
1491
|
-
s0 = peg$
|
|
1492
|
-
peg$savedPos = peg$currPos;
|
|
1493
|
-
s1 = peg$f29();
|
|
1494
|
-
if (s1) s1 = void 0;
|
|
1495
|
-
else s1 = peg$FAILED;
|
|
1496
|
-
if (s1 !== peg$FAILED) {
|
|
1497
|
-
s2 = peg$parseHtmlOpen();
|
|
1498
|
-
if (s2 !== peg$FAILED) {
|
|
1499
|
-
peg$savedPos = s0;
|
|
1500
|
-
s0 = peg$f30(s2);
|
|
1501
|
-
} else {
|
|
1502
|
-
peg$currPos = s0;
|
|
1503
|
-
s0 = peg$FAILED;
|
|
1504
|
-
}
|
|
1505
|
-
} else {
|
|
1506
|
-
peg$currPos = s0;
|
|
1507
|
-
s0 = peg$FAILED;
|
|
1508
|
-
}
|
|
1539
|
+
s0 = peg$parseEmailAutolink();
|
|
1509
1540
|
if (s0 === peg$FAILED) {
|
|
1510
1541
|
s0 = peg$currPos;
|
|
1511
1542
|
peg$savedPos = peg$currPos;
|
|
1512
|
-
s1 = peg$
|
|
1543
|
+
s1 = peg$f29();
|
|
1513
1544
|
if (s1) s1 = void 0;
|
|
1514
1545
|
else s1 = peg$FAILED;
|
|
1515
1546
|
if (s1 !== peg$FAILED) {
|
|
1516
|
-
s2 = peg$
|
|
1547
|
+
s2 = peg$parseHtmlOpen();
|
|
1517
1548
|
if (s2 !== peg$FAILED) {
|
|
1518
1549
|
peg$savedPos = s0;
|
|
1519
|
-
s0 = peg$
|
|
1550
|
+
s0 = peg$f30(s2);
|
|
1520
1551
|
} else {
|
|
1521
1552
|
peg$currPos = s0;
|
|
1522
1553
|
s0 = peg$FAILED;
|
|
@@ -1526,37 +1557,57 @@ function peg$parse(input, options) {
|
|
|
1526
1557
|
s0 = peg$FAILED;
|
|
1527
1558
|
}
|
|
1528
1559
|
if (s0 === peg$FAILED) {
|
|
1529
|
-
s0 = peg$
|
|
1560
|
+
s0 = peg$currPos;
|
|
1561
|
+
peg$savedPos = peg$currPos;
|
|
1562
|
+
s1 = peg$f31();
|
|
1563
|
+
if (s1) s1 = void 0;
|
|
1564
|
+
else s1 = peg$FAILED;
|
|
1565
|
+
if (s1 !== peg$FAILED) {
|
|
1566
|
+
s2 = peg$parseHtmlClose();
|
|
1567
|
+
if (s2 !== peg$FAILED) {
|
|
1568
|
+
peg$savedPos = s0;
|
|
1569
|
+
s0 = peg$f32(s2);
|
|
1570
|
+
} else {
|
|
1571
|
+
peg$currPos = s0;
|
|
1572
|
+
s0 = peg$FAILED;
|
|
1573
|
+
}
|
|
1574
|
+
} else {
|
|
1575
|
+
peg$currPos = s0;
|
|
1576
|
+
s0 = peg$FAILED;
|
|
1577
|
+
}
|
|
1530
1578
|
if (s0 === peg$FAILED) {
|
|
1531
|
-
s0 = peg$
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
if (
|
|
1542
|
-
|
|
1543
|
-
|
|
1579
|
+
s0 = peg$parseValue();
|
|
1580
|
+
if (s0 === peg$FAILED) {
|
|
1581
|
+
s0 = peg$currPos;
|
|
1582
|
+
s1 = peg$parseMacroTag();
|
|
1583
|
+
if (s1 !== peg$FAILED) {
|
|
1584
|
+
s2 = peg$currPos;
|
|
1585
|
+
peg$savedPos = peg$currPos;
|
|
1586
|
+
s3 = peg$f33(s1);
|
|
1587
|
+
if (s3) s3 = void 0;
|
|
1588
|
+
else s3 = peg$FAILED;
|
|
1589
|
+
if (s3 !== peg$FAILED) {
|
|
1590
|
+
s4 = peg$parseRawTokens();
|
|
1591
|
+
if (s4 !== peg$FAILED) {
|
|
1592
|
+
peg$savedPos = s2;
|
|
1593
|
+
s2 = peg$f34(s1, s4);
|
|
1594
|
+
} else {
|
|
1595
|
+
peg$currPos = s2;
|
|
1596
|
+
s2 = peg$FAILED;
|
|
1597
|
+
}
|
|
1544
1598
|
} else {
|
|
1545
1599
|
peg$currPos = s2;
|
|
1546
1600
|
s2 = peg$FAILED;
|
|
1547
1601
|
}
|
|
1602
|
+
if (s2 === peg$FAILED) s2 = null;
|
|
1603
|
+
peg$savedPos = s0;
|
|
1604
|
+
s0 = peg$f35(s1, s2);
|
|
1548
1605
|
} else {
|
|
1549
|
-
peg$currPos =
|
|
1550
|
-
|
|
1606
|
+
peg$currPos = s0;
|
|
1607
|
+
s0 = peg$FAILED;
|
|
1551
1608
|
}
|
|
1552
|
-
if (
|
|
1553
|
-
peg$savedPos = s0;
|
|
1554
|
-
s0 = peg$f35(s1, s2);
|
|
1555
|
-
} else {
|
|
1556
|
-
peg$currPos = s0;
|
|
1557
|
-
s0 = peg$FAILED;
|
|
1609
|
+
if (s0 === peg$FAILED) s0 = peg$parseLiteral();
|
|
1558
1610
|
}
|
|
1559
|
-
if (s0 === peg$FAILED) s0 = peg$parseLiteral();
|
|
1560
1611
|
}
|
|
1561
1612
|
}
|
|
1562
1613
|
}
|
|
@@ -2698,23 +2749,136 @@ function peg$parse(input, options) {
|
|
|
2698
2749
|
else s0 = s1;
|
|
2699
2750
|
return s0;
|
|
2700
2751
|
}
|
|
2752
|
+
function peg$parseEmailAutolink() {
|
|
2753
|
+
let s0, s1, s2, s3, s4, s5, s6, s7;
|
|
2754
|
+
s0 = peg$currPos;
|
|
2755
|
+
s1 = peg$currPos;
|
|
2756
|
+
s2 = peg$currPos;
|
|
2757
|
+
if (input.charCodeAt(peg$currPos) === 60) {
|
|
2758
|
+
s3 = peg$c6;
|
|
2759
|
+
peg$currPos++;
|
|
2760
|
+
} else {
|
|
2761
|
+
s3 = peg$FAILED;
|
|
2762
|
+
if (peg$silentFails === 0) peg$fail(peg$e10);
|
|
2763
|
+
}
|
|
2764
|
+
if (s3 !== peg$FAILED) {
|
|
2765
|
+
s4 = [];
|
|
2766
|
+
s5 = input.charAt(peg$currPos);
|
|
2767
|
+
if (peg$r10.test(s5)) peg$currPos++;
|
|
2768
|
+
else {
|
|
2769
|
+
s5 = peg$FAILED;
|
|
2770
|
+
if (peg$silentFails === 0) peg$fail(peg$e24);
|
|
2771
|
+
}
|
|
2772
|
+
if (s5 !== peg$FAILED) while (s5 !== peg$FAILED) {
|
|
2773
|
+
s4.push(s5);
|
|
2774
|
+
s5 = input.charAt(peg$currPos);
|
|
2775
|
+
if (peg$r10.test(s5)) peg$currPos++;
|
|
2776
|
+
else {
|
|
2777
|
+
s5 = peg$FAILED;
|
|
2778
|
+
if (peg$silentFails === 0) peg$fail(peg$e24);
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
else s4 = peg$FAILED;
|
|
2782
|
+
if (s4 !== peg$FAILED) {
|
|
2783
|
+
if (input.charCodeAt(peg$currPos) === 64) {
|
|
2784
|
+
s5 = peg$c13;
|
|
2785
|
+
peg$currPos++;
|
|
2786
|
+
} else {
|
|
2787
|
+
s5 = peg$FAILED;
|
|
2788
|
+
if (peg$silentFails === 0) peg$fail(peg$e25);
|
|
2789
|
+
}
|
|
2790
|
+
if (s5 !== peg$FAILED) {
|
|
2791
|
+
s6 = [];
|
|
2792
|
+
s7 = input.charAt(peg$currPos);
|
|
2793
|
+
if (peg$r11.test(s7)) peg$currPos++;
|
|
2794
|
+
else {
|
|
2795
|
+
s7 = peg$FAILED;
|
|
2796
|
+
if (peg$silentFails === 0) peg$fail(peg$e26);
|
|
2797
|
+
}
|
|
2798
|
+
if (s7 !== peg$FAILED) while (s7 !== peg$FAILED) {
|
|
2799
|
+
s6.push(s7);
|
|
2800
|
+
s7 = input.charAt(peg$currPos);
|
|
2801
|
+
if (peg$r11.test(s7)) peg$currPos++;
|
|
2802
|
+
else {
|
|
2803
|
+
s7 = peg$FAILED;
|
|
2804
|
+
if (peg$silentFails === 0) peg$fail(peg$e26);
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
else s6 = peg$FAILED;
|
|
2808
|
+
if (s6 !== peg$FAILED) {
|
|
2809
|
+
if (input.charCodeAt(peg$currPos) === 62) {
|
|
2810
|
+
s7 = peg$c1;
|
|
2811
|
+
peg$currPos++;
|
|
2812
|
+
} else {
|
|
2813
|
+
s7 = peg$FAILED;
|
|
2814
|
+
if (peg$silentFails === 0) peg$fail(peg$e3);
|
|
2815
|
+
}
|
|
2816
|
+
if (s7 !== peg$FAILED) {
|
|
2817
|
+
s3 = [
|
|
2818
|
+
s3,
|
|
2819
|
+
s4,
|
|
2820
|
+
s5,
|
|
2821
|
+
s6,
|
|
2822
|
+
s7
|
|
2823
|
+
];
|
|
2824
|
+
s2 = s3;
|
|
2825
|
+
} else {
|
|
2826
|
+
peg$currPos = s2;
|
|
2827
|
+
s2 = peg$FAILED;
|
|
2828
|
+
}
|
|
2829
|
+
} else {
|
|
2830
|
+
peg$currPos = s2;
|
|
2831
|
+
s2 = peg$FAILED;
|
|
2832
|
+
}
|
|
2833
|
+
} else {
|
|
2834
|
+
peg$currPos = s2;
|
|
2835
|
+
s2 = peg$FAILED;
|
|
2836
|
+
}
|
|
2837
|
+
} else {
|
|
2838
|
+
peg$currPos = s2;
|
|
2839
|
+
s2 = peg$FAILED;
|
|
2840
|
+
}
|
|
2841
|
+
} else {
|
|
2842
|
+
peg$currPos = s2;
|
|
2843
|
+
s2 = peg$FAILED;
|
|
2844
|
+
}
|
|
2845
|
+
if (s2 !== peg$FAILED) s1 = input.substring(s1, peg$currPos);
|
|
2846
|
+
else s1 = s2;
|
|
2847
|
+
if (s1 !== peg$FAILED) {
|
|
2848
|
+
peg$savedPos = peg$currPos;
|
|
2849
|
+
s2 = peg$f68(s1);
|
|
2850
|
+
if (s2) s2 = void 0;
|
|
2851
|
+
else s2 = peg$FAILED;
|
|
2852
|
+
if (s2 !== peg$FAILED) {
|
|
2853
|
+
peg$savedPos = s0;
|
|
2854
|
+
s0 = peg$f69(s1);
|
|
2855
|
+
} else {
|
|
2856
|
+
peg$currPos = s0;
|
|
2857
|
+
s0 = peg$FAILED;
|
|
2858
|
+
}
|
|
2859
|
+
} else {
|
|
2860
|
+
peg$currPos = s0;
|
|
2861
|
+
s0 = peg$FAILED;
|
|
2862
|
+
}
|
|
2863
|
+
return s0;
|
|
2864
|
+
}
|
|
2701
2865
|
function peg$parseVoidCloser() {
|
|
2702
2866
|
let s0, s1, s2, s3;
|
|
2703
2867
|
s0 = peg$currPos;
|
|
2704
2868
|
peg$savedPos = peg$currPos;
|
|
2705
|
-
s1 = peg$
|
|
2869
|
+
s1 = peg$f70();
|
|
2706
2870
|
if (s1) s1 = void 0;
|
|
2707
2871
|
else s1 = peg$FAILED;
|
|
2708
2872
|
if (s1 !== peg$FAILED) {
|
|
2709
2873
|
s2 = peg$parseHtmlClose();
|
|
2710
2874
|
if (s2 !== peg$FAILED) {
|
|
2711
2875
|
peg$savedPos = peg$currPos;
|
|
2712
|
-
s3 = peg$
|
|
2876
|
+
s3 = peg$f71(s2);
|
|
2713
2877
|
if (s3) s3 = void 0;
|
|
2714
2878
|
else s3 = peg$FAILED;
|
|
2715
2879
|
if (s3 !== peg$FAILED) {
|
|
2716
2880
|
peg$savedPos = s0;
|
|
2717
|
-
s0 = peg$
|
|
2881
|
+
s0 = peg$f72(s2);
|
|
2718
2882
|
} else {
|
|
2719
2883
|
peg$currPos = s0;
|
|
2720
2884
|
s0 = peg$FAILED;
|
|
@@ -2766,7 +2930,7 @@ function peg$parse(input, options) {
|
|
|
2766
2930
|
}
|
|
2767
2931
|
if (s6 !== peg$FAILED) {
|
|
2768
2932
|
peg$savedPos = s0;
|
|
2769
|
-
s0 = peg$
|
|
2933
|
+
s0 = peg$f73(s2, s3, s5);
|
|
2770
2934
|
} else {
|
|
2771
2935
|
peg$currPos = s0;
|
|
2772
2936
|
s0 = peg$FAILED;
|
|
@@ -2794,10 +2958,10 @@ function peg$parse(input, options) {
|
|
|
2794
2958
|
s3 = peg$currPos;
|
|
2795
2959
|
peg$silentFails++;
|
|
2796
2960
|
s4 = input.charAt(peg$currPos);
|
|
2797
|
-
if (peg$
|
|
2961
|
+
if (peg$r12.test(s4)) peg$currPos++;
|
|
2798
2962
|
else {
|
|
2799
2963
|
s4 = peg$FAILED;
|
|
2800
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
2964
|
+
if (peg$silentFails === 0) peg$fail(peg$e27);
|
|
2801
2965
|
}
|
|
2802
2966
|
if (s4 === peg$FAILED) {
|
|
2803
2967
|
s4 = peg$currPos;
|
|
@@ -2831,7 +2995,7 @@ function peg$parse(input, options) {
|
|
|
2831
2995
|
s5 = peg$parse_();
|
|
2832
2996
|
s6 = peg$parseHere();
|
|
2833
2997
|
peg$savedPos = s0;
|
|
2834
|
-
s0 = peg$
|
|
2998
|
+
s0 = peg$f74(s2, s6);
|
|
2835
2999
|
} else {
|
|
2836
3000
|
peg$currPos = s0;
|
|
2837
3001
|
s0 = peg$FAILED;
|
|
@@ -2850,12 +3014,12 @@ function peg$parse(input, options) {
|
|
|
2850
3014
|
function peg$parseHtmlClose() {
|
|
2851
3015
|
let s0, s1, s2, s4;
|
|
2852
3016
|
s0 = peg$currPos;
|
|
2853
|
-
if (input.substr(peg$currPos, 2) === peg$
|
|
2854
|
-
s1 = peg$
|
|
3017
|
+
if (input.substr(peg$currPos, 2) === peg$c14) {
|
|
3018
|
+
s1 = peg$c14;
|
|
2855
3019
|
peg$currPos += 2;
|
|
2856
3020
|
} else {
|
|
2857
3021
|
s1 = peg$FAILED;
|
|
2858
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3022
|
+
if (peg$silentFails === 0) peg$fail(peg$e28);
|
|
2859
3023
|
}
|
|
2860
3024
|
if (s1 !== peg$FAILED) {
|
|
2861
3025
|
s2 = peg$parseTagName();
|
|
@@ -2870,7 +3034,7 @@ function peg$parse(input, options) {
|
|
|
2870
3034
|
}
|
|
2871
3035
|
if (s4 !== peg$FAILED) {
|
|
2872
3036
|
peg$savedPos = s0;
|
|
2873
|
-
s0 = peg$
|
|
3037
|
+
s0 = peg$f75(s2);
|
|
2874
3038
|
} else {
|
|
2875
3039
|
peg$currPos = s0;
|
|
2876
3040
|
s0 = peg$FAILED;
|
|
@@ -2898,18 +3062,18 @@ function peg$parse(input, options) {
|
|
|
2898
3062
|
if (s2 !== peg$FAILED) {
|
|
2899
3063
|
s3 = [];
|
|
2900
3064
|
s4 = input.charAt(peg$currPos);
|
|
2901
|
-
if (peg$
|
|
3065
|
+
if (peg$r13.test(s4)) peg$currPos++;
|
|
2902
3066
|
else {
|
|
2903
3067
|
s4 = peg$FAILED;
|
|
2904
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3068
|
+
if (peg$silentFails === 0) peg$fail(peg$e29);
|
|
2905
3069
|
}
|
|
2906
3070
|
while (s4 !== peg$FAILED) {
|
|
2907
3071
|
s3.push(s4);
|
|
2908
3072
|
s4 = input.charAt(peg$currPos);
|
|
2909
|
-
if (peg$
|
|
3073
|
+
if (peg$r13.test(s4)) peg$currPos++;
|
|
2910
3074
|
else {
|
|
2911
3075
|
s4 = peg$FAILED;
|
|
2912
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3076
|
+
if (peg$silentFails === 0) peg$fail(peg$e29);
|
|
2913
3077
|
}
|
|
2914
3078
|
}
|
|
2915
3079
|
s2 = [s2, s3];
|
|
@@ -2932,10 +3096,10 @@ function peg$parse(input, options) {
|
|
|
2932
3096
|
s5 = peg$currPos;
|
|
2933
3097
|
peg$silentFails++;
|
|
2934
3098
|
s6 = input.charAt(peg$currPos);
|
|
2935
|
-
if (peg$
|
|
3099
|
+
if (peg$r14.test(s6)) peg$currPos++;
|
|
2936
3100
|
else {
|
|
2937
3101
|
s6 = peg$FAILED;
|
|
2938
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3102
|
+
if (peg$silentFails === 0) peg$fail(peg$e30);
|
|
2939
3103
|
}
|
|
2940
3104
|
peg$silentFails--;
|
|
2941
3105
|
if (s6 === peg$FAILED) s5 = void 0;
|
|
@@ -2968,10 +3132,10 @@ function peg$parse(input, options) {
|
|
|
2968
3132
|
s5 = peg$currPos;
|
|
2969
3133
|
peg$silentFails++;
|
|
2970
3134
|
s6 = input.charAt(peg$currPos);
|
|
2971
|
-
if (peg$
|
|
3135
|
+
if (peg$r14.test(s6)) peg$currPos++;
|
|
2972
3136
|
else {
|
|
2973
3137
|
s6 = peg$FAILED;
|
|
2974
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3138
|
+
if (peg$silentFails === 0) peg$fail(peg$e30);
|
|
2975
3139
|
}
|
|
2976
3140
|
peg$silentFails--;
|
|
2977
3141
|
if (s6 === peg$FAILED) s5 = void 0;
|
|
@@ -3004,25 +3168,25 @@ function peg$parse(input, options) {
|
|
|
3004
3168
|
else s2 = s3;
|
|
3005
3169
|
if (s2 !== peg$FAILED) {
|
|
3006
3170
|
peg$savedPos = peg$currPos;
|
|
3007
|
-
s3 = peg$
|
|
3171
|
+
s3 = peg$f76(s2);
|
|
3008
3172
|
if (s3) s3 = void 0;
|
|
3009
3173
|
else s3 = peg$FAILED;
|
|
3010
3174
|
if (s3 !== peg$FAILED) {
|
|
3011
3175
|
s4 = peg$currPos;
|
|
3012
3176
|
s5 = peg$parse_();
|
|
3013
3177
|
if (input.charCodeAt(peg$currPos) === 61) {
|
|
3014
|
-
s6 = peg$
|
|
3178
|
+
s6 = peg$c15;
|
|
3015
3179
|
peg$currPos++;
|
|
3016
3180
|
} else {
|
|
3017
3181
|
s6 = peg$FAILED;
|
|
3018
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3182
|
+
if (peg$silentFails === 0) peg$fail(peg$e31);
|
|
3019
3183
|
}
|
|
3020
3184
|
if (s6 !== peg$FAILED) {
|
|
3021
3185
|
peg$parse_();
|
|
3022
3186
|
s8 = peg$parseAttrValue();
|
|
3023
3187
|
if (s8 !== peg$FAILED) {
|
|
3024
3188
|
peg$savedPos = s4;
|
|
3025
|
-
s4 = peg$
|
|
3189
|
+
s4 = peg$f77(s2, s8);
|
|
3026
3190
|
} else {
|
|
3027
3191
|
peg$currPos = s4;
|
|
3028
3192
|
s4 = peg$FAILED;
|
|
@@ -3033,7 +3197,7 @@ function peg$parse(input, options) {
|
|
|
3033
3197
|
}
|
|
3034
3198
|
if (s4 === peg$FAILED) s4 = null;
|
|
3035
3199
|
peg$savedPos = s0;
|
|
3036
|
-
s0 = peg$
|
|
3200
|
+
s0 = peg$f78(s2, s4);
|
|
3037
3201
|
} else {
|
|
3038
3202
|
peg$currPos = s0;
|
|
3039
3203
|
s0 = peg$FAILED;
|
|
@@ -3048,11 +3212,11 @@ function peg$parse(input, options) {
|
|
|
3048
3212
|
let s0, s1, s2, s3, s4;
|
|
3049
3213
|
s0 = peg$currPos;
|
|
3050
3214
|
if (input.charCodeAt(peg$currPos) === 34) {
|
|
3051
|
-
s1 = peg$
|
|
3215
|
+
s1 = peg$c16;
|
|
3052
3216
|
peg$currPos++;
|
|
3053
3217
|
} else {
|
|
3054
3218
|
s1 = peg$FAILED;
|
|
3055
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3219
|
+
if (peg$silentFails === 0) peg$fail(peg$e32);
|
|
3056
3220
|
}
|
|
3057
3221
|
if (s1 !== peg$FAILED) {
|
|
3058
3222
|
s2 = peg$currPos;
|
|
@@ -3060,10 +3224,10 @@ function peg$parse(input, options) {
|
|
|
3060
3224
|
s4 = peg$parseValuePart();
|
|
3061
3225
|
if (s4 === peg$FAILED) {
|
|
3062
3226
|
s4 = input.charAt(peg$currPos);
|
|
3063
|
-
if (peg$
|
|
3227
|
+
if (peg$r15.test(s4)) peg$currPos++;
|
|
3064
3228
|
else {
|
|
3065
3229
|
s4 = peg$FAILED;
|
|
3066
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3230
|
+
if (peg$silentFails === 0) peg$fail(peg$e33);
|
|
3067
3231
|
}
|
|
3068
3232
|
}
|
|
3069
3233
|
while (s4 !== peg$FAILED) {
|
|
@@ -3071,24 +3235,24 @@ function peg$parse(input, options) {
|
|
|
3071
3235
|
s4 = peg$parseValuePart();
|
|
3072
3236
|
if (s4 === peg$FAILED) {
|
|
3073
3237
|
s4 = input.charAt(peg$currPos);
|
|
3074
|
-
if (peg$
|
|
3238
|
+
if (peg$r15.test(s4)) peg$currPos++;
|
|
3075
3239
|
else {
|
|
3076
3240
|
s4 = peg$FAILED;
|
|
3077
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3241
|
+
if (peg$silentFails === 0) peg$fail(peg$e33);
|
|
3078
3242
|
}
|
|
3079
3243
|
}
|
|
3080
3244
|
}
|
|
3081
3245
|
s2 = input.substring(s2, peg$currPos);
|
|
3082
3246
|
if (input.charCodeAt(peg$currPos) === 34) {
|
|
3083
|
-
s3 = peg$
|
|
3247
|
+
s3 = peg$c16;
|
|
3084
3248
|
peg$currPos++;
|
|
3085
3249
|
} else {
|
|
3086
3250
|
s3 = peg$FAILED;
|
|
3087
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3251
|
+
if (peg$silentFails === 0) peg$fail(peg$e32);
|
|
3088
3252
|
}
|
|
3089
3253
|
if (s3 !== peg$FAILED) {
|
|
3090
3254
|
peg$savedPos = s0;
|
|
3091
|
-
s0 = peg$
|
|
3255
|
+
s0 = peg$f79(s2);
|
|
3092
3256
|
} else {
|
|
3093
3257
|
peg$currPos = s0;
|
|
3094
3258
|
s0 = peg$FAILED;
|
|
@@ -3100,11 +3264,11 @@ function peg$parse(input, options) {
|
|
|
3100
3264
|
if (s0 === peg$FAILED) {
|
|
3101
3265
|
s0 = peg$currPos;
|
|
3102
3266
|
if (input.charCodeAt(peg$currPos) === 39) {
|
|
3103
|
-
s1 = peg$
|
|
3267
|
+
s1 = peg$c17;
|
|
3104
3268
|
peg$currPos++;
|
|
3105
3269
|
} else {
|
|
3106
3270
|
s1 = peg$FAILED;
|
|
3107
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3271
|
+
if (peg$silentFails === 0) peg$fail(peg$e34);
|
|
3108
3272
|
}
|
|
3109
3273
|
if (s1 !== peg$FAILED) {
|
|
3110
3274
|
s2 = peg$currPos;
|
|
@@ -3112,10 +3276,10 @@ function peg$parse(input, options) {
|
|
|
3112
3276
|
s4 = peg$parseValuePart();
|
|
3113
3277
|
if (s4 === peg$FAILED) {
|
|
3114
3278
|
s4 = input.charAt(peg$currPos);
|
|
3115
|
-
if (peg$
|
|
3279
|
+
if (peg$r16.test(s4)) peg$currPos++;
|
|
3116
3280
|
else {
|
|
3117
3281
|
s4 = peg$FAILED;
|
|
3118
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3282
|
+
if (peg$silentFails === 0) peg$fail(peg$e35);
|
|
3119
3283
|
}
|
|
3120
3284
|
}
|
|
3121
3285
|
while (s4 !== peg$FAILED) {
|
|
@@ -3123,24 +3287,24 @@ function peg$parse(input, options) {
|
|
|
3123
3287
|
s4 = peg$parseValuePart();
|
|
3124
3288
|
if (s4 === peg$FAILED) {
|
|
3125
3289
|
s4 = input.charAt(peg$currPos);
|
|
3126
|
-
if (peg$
|
|
3290
|
+
if (peg$r16.test(s4)) peg$currPos++;
|
|
3127
3291
|
else {
|
|
3128
3292
|
s4 = peg$FAILED;
|
|
3129
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3293
|
+
if (peg$silentFails === 0) peg$fail(peg$e35);
|
|
3130
3294
|
}
|
|
3131
3295
|
}
|
|
3132
3296
|
}
|
|
3133
3297
|
s2 = input.substring(s2, peg$currPos);
|
|
3134
3298
|
if (input.charCodeAt(peg$currPos) === 39) {
|
|
3135
|
-
s3 = peg$
|
|
3299
|
+
s3 = peg$c17;
|
|
3136
3300
|
peg$currPos++;
|
|
3137
3301
|
} else {
|
|
3138
3302
|
s3 = peg$FAILED;
|
|
3139
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3303
|
+
if (peg$silentFails === 0) peg$fail(peg$e34);
|
|
3140
3304
|
}
|
|
3141
3305
|
if (s3 !== peg$FAILED) {
|
|
3142
3306
|
peg$savedPos = s0;
|
|
3143
|
-
s0 = peg$
|
|
3307
|
+
s0 = peg$f80(s2);
|
|
3144
3308
|
} else {
|
|
3145
3309
|
peg$currPos = s0;
|
|
3146
3310
|
s0 = peg$FAILED;
|
|
@@ -3152,32 +3316,32 @@ function peg$parse(input, options) {
|
|
|
3152
3316
|
if (s0 === peg$FAILED) {
|
|
3153
3317
|
s0 = peg$currPos;
|
|
3154
3318
|
s1 = input.charAt(peg$currPos);
|
|
3155
|
-
if (peg$
|
|
3319
|
+
if (peg$r17.test(s1)) peg$currPos++;
|
|
3156
3320
|
else {
|
|
3157
3321
|
s1 = peg$FAILED;
|
|
3158
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3322
|
+
if (peg$silentFails === 0) peg$fail(peg$e36);
|
|
3159
3323
|
}
|
|
3160
3324
|
if (s1 !== peg$FAILED) {
|
|
3161
3325
|
peg$savedPos = s0;
|
|
3162
|
-
s1 = peg$
|
|
3326
|
+
s1 = peg$f81(s1);
|
|
3163
3327
|
}
|
|
3164
3328
|
s0 = s1;
|
|
3165
3329
|
if (s0 === peg$FAILED) {
|
|
3166
3330
|
s0 = peg$currPos;
|
|
3167
3331
|
s1 = [];
|
|
3168
3332
|
s2 = input.charAt(peg$currPos);
|
|
3169
|
-
if (peg$
|
|
3333
|
+
if (peg$r18.test(s2)) peg$currPos++;
|
|
3170
3334
|
else {
|
|
3171
3335
|
s2 = peg$FAILED;
|
|
3172
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3336
|
+
if (peg$silentFails === 0) peg$fail(peg$e37);
|
|
3173
3337
|
}
|
|
3174
3338
|
while (s2 !== peg$FAILED) {
|
|
3175
3339
|
s1.push(s2);
|
|
3176
3340
|
s2 = input.charAt(peg$currPos);
|
|
3177
|
-
if (peg$
|
|
3341
|
+
if (peg$r18.test(s2)) peg$currPos++;
|
|
3178
3342
|
else {
|
|
3179
3343
|
s2 = peg$FAILED;
|
|
3180
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3344
|
+
if (peg$silentFails === 0) peg$fail(peg$e37);
|
|
3181
3345
|
}
|
|
3182
3346
|
}
|
|
3183
3347
|
s0 = input.substring(s0, peg$currPos);
|
|
@@ -3190,7 +3354,7 @@ function peg$parse(input, options) {
|
|
|
3190
3354
|
let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13;
|
|
3191
3355
|
s0 = peg$currPos;
|
|
3192
3356
|
peg$savedPos = peg$currPos;
|
|
3193
|
-
s1 = peg$
|
|
3357
|
+
s1 = peg$f82();
|
|
3194
3358
|
if (s1) s1 = void 0;
|
|
3195
3359
|
else s1 = peg$FAILED;
|
|
3196
3360
|
if (s1 !== peg$FAILED) {
|
|
@@ -3219,7 +3383,7 @@ function peg$parse(input, options) {
|
|
|
3219
3383
|
if (s2 !== peg$FAILED) {
|
|
3220
3384
|
s3 = peg$currPos;
|
|
3221
3385
|
peg$savedPos = peg$currPos;
|
|
3222
|
-
s4 = peg$
|
|
3386
|
+
s4 = peg$f83(s2);
|
|
3223
3387
|
if (s4) s4 = void 0;
|
|
3224
3388
|
else s4 = peg$FAILED;
|
|
3225
3389
|
if (s4 !== peg$FAILED) {
|
|
@@ -3258,7 +3422,7 @@ function peg$parse(input, options) {
|
|
|
3258
3422
|
if (s0 === peg$FAILED) {
|
|
3259
3423
|
s0 = peg$currPos;
|
|
3260
3424
|
peg$savedPos = peg$currPos;
|
|
3261
|
-
s1 = peg$
|
|
3425
|
+
s1 = peg$f84();
|
|
3262
3426
|
if (s1) s1 = void 0;
|
|
3263
3427
|
else s1 = peg$FAILED;
|
|
3264
3428
|
if (s1 !== peg$FAILED) {
|
|
@@ -3285,12 +3449,12 @@ function peg$parse(input, options) {
|
|
|
3285
3449
|
if (s6 !== peg$FAILED) {
|
|
3286
3450
|
s7 = peg$parseHere();
|
|
3287
3451
|
peg$savedPos = peg$currPos;
|
|
3288
|
-
s8 = peg$
|
|
3452
|
+
s8 = peg$f85(s4, s7);
|
|
3289
3453
|
if (s8) s8 = void 0;
|
|
3290
3454
|
else s8 = peg$FAILED;
|
|
3291
3455
|
if (s8 !== peg$FAILED) {
|
|
3292
3456
|
s9 = peg$currPos;
|
|
3293
|
-
s10 = peg$
|
|
3457
|
+
s10 = peg$f86(s4, s7);
|
|
3294
3458
|
s11 = peg$currPos;
|
|
3295
3459
|
s12 = [];
|
|
3296
3460
|
if (s12.length >= (s10 | 0)) s13 = peg$FAILED;
|
|
@@ -3372,7 +3536,7 @@ function peg$parse(input, options) {
|
|
|
3372
3536
|
if (s0 === peg$FAILED) {
|
|
3373
3537
|
s0 = peg$currPos;
|
|
3374
3538
|
peg$savedPos = peg$currPos;
|
|
3375
|
-
s1 = peg$
|
|
3539
|
+
s1 = peg$f87();
|
|
3376
3540
|
if (s1) s1 = void 0;
|
|
3377
3541
|
else s1 = peg$FAILED;
|
|
3378
3542
|
if (s1 !== peg$FAILED) {
|
|
@@ -3463,7 +3627,7 @@ function peg$parse(input, options) {
|
|
|
3463
3627
|
if (s0 === peg$FAILED) {
|
|
3464
3628
|
s0 = peg$currPos;
|
|
3465
3629
|
peg$savedPos = peg$currPos;
|
|
3466
|
-
s1 = peg$
|
|
3630
|
+
s1 = peg$f88();
|
|
3467
3631
|
if (s1) s1 = void 0;
|
|
3468
3632
|
else s1 = peg$FAILED;
|
|
3469
3633
|
if (s1 !== peg$FAILED) {
|
|
@@ -3545,10 +3709,10 @@ function peg$parse(input, options) {
|
|
|
3545
3709
|
function peg$parse_c() {
|
|
3546
3710
|
let s0;
|
|
3547
3711
|
s0 = input.charAt(peg$currPos);
|
|
3548
|
-
if (peg$
|
|
3712
|
+
if (peg$r19.test(s0)) peg$currPos++;
|
|
3549
3713
|
else {
|
|
3550
3714
|
s0 = peg$FAILED;
|
|
3551
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3715
|
+
if (peg$silentFails === 0) peg$fail(peg$e38);
|
|
3552
3716
|
}
|
|
3553
3717
|
return s0;
|
|
3554
3718
|
}
|
|
@@ -11890,6 +12054,19 @@ var InlineContext = createContext(false);
|
|
|
11890
12054
|
*/
|
|
11891
12055
|
var RawTextContext = createContext(false);
|
|
11892
12056
|
/**
|
|
12057
|
+
* The view content is rendered in: '' for the story interface, and an id of
|
|
12058
|
+
* its own for each passage and dialog on display (see useViewScope). The
|
|
12059
|
+
* radiobuttons of a variable form a native group within their view only:
|
|
12060
|
+
* one group across views would let a dialog's checked button uncheck the
|
|
12061
|
+
* passage's when it mounts (#396).
|
|
12062
|
+
*/
|
|
12063
|
+
var ViewScopeContext = createContext("");
|
|
12064
|
+
var viewScopes = 0;
|
|
12065
|
+
/** A new view scope (see ViewScopeContext), kept while mounted. */
|
|
12066
|
+
function useViewScope() {
|
|
12067
|
+
return useState(() => `v${++viewScopes}`)[0];
|
|
12068
|
+
}
|
|
12069
|
+
/**
|
|
11893
12070
|
* True inside an `<svg>` element. SVG attributes are case-sensitive and have
|
|
11894
12071
|
* no live form properties, so they are set as written (see splitAttributes).
|
|
11895
12072
|
*/
|
|
@@ -13323,11 +13500,60 @@ function extraKeys(collection) {
|
|
|
13323
13500
|
const keys = Object.keys(collection);
|
|
13324
13501
|
return Array.isArray(collection) ? keys.filter((k) => !isIndexKey(k)) : keys;
|
|
13325
13502
|
}
|
|
13503
|
+
/** The entries of a Map, as the built-in iterator gives them. */
|
|
13504
|
+
function mapEntries(map) {
|
|
13505
|
+
return isDraft(map) ? map.entries() : Map.prototype.entries.call(map);
|
|
13506
|
+
}
|
|
13507
|
+
/** The members of a Set, as the built-in iterator gives them. */
|
|
13508
|
+
function setMembers(set) {
|
|
13509
|
+
return isDraft(set) ? set.values() : Set.prototype.values.call(set);
|
|
13510
|
+
}
|
|
13511
|
+
/** The number of entries of a Map or members of a Set. */
|
|
13512
|
+
function collectionSize(collection) {
|
|
13513
|
+
if (isDraft(collection)) return collection.size;
|
|
13514
|
+
const proto = collection instanceof Map ? Map.prototype : Set.prototype;
|
|
13515
|
+
return Reflect.get(proto, "size", collection);
|
|
13516
|
+
}
|
|
13517
|
+
/** The value a Map holds for `key`. */
|
|
13518
|
+
function mapGet(map, key) {
|
|
13519
|
+
return isDraft(map) ? map.get(key) : Map.prototype.get.call(map, key);
|
|
13520
|
+
}
|
|
13521
|
+
/** Make a Map hold `value` for `key`. */
|
|
13522
|
+
function mapSet(map, key, value) {
|
|
13523
|
+
if (isDraft(map)) map.set(key, value);
|
|
13524
|
+
else Map.prototype.set.call(map, key, value);
|
|
13525
|
+
}
|
|
13326
13526
|
//#endregion
|
|
13327
13527
|
//#region src/class-registry.ts
|
|
13328
13528
|
var registry = /* @__PURE__ */ new Map();
|
|
13329
13529
|
var ctorToName = /* @__PURE__ */ new Map();
|
|
13530
|
+
/**
|
|
13531
|
+
* Built-ins whose instances hold their value in internal slots that a save
|
|
13532
|
+
* cannot rebuild: a registered class cannot extend them. (Array, Map, Set,
|
|
13533
|
+
* Date, RegExp and Error can be extended, see classData.)
|
|
13534
|
+
*/
|
|
13535
|
+
var UNSUPPORTED_BASES = [
|
|
13536
|
+
ArrayBuffer,
|
|
13537
|
+
DataView,
|
|
13538
|
+
Object.getPrototypeOf(Int8Array),
|
|
13539
|
+
URL,
|
|
13540
|
+
URLSearchParams,
|
|
13541
|
+
Number,
|
|
13542
|
+
String,
|
|
13543
|
+
Boolean,
|
|
13544
|
+
Promise,
|
|
13545
|
+
WeakMap,
|
|
13546
|
+
WeakSet,
|
|
13547
|
+
Function
|
|
13548
|
+
];
|
|
13549
|
+
/**
|
|
13550
|
+
* Register `ctor` as `name`, so that its instances keep their class through
|
|
13551
|
+
* copies, history and saves. Throws for a class extending a built-in whose
|
|
13552
|
+
* instances cannot be saved (see UNSUPPORTED_BASES).
|
|
13553
|
+
*/
|
|
13330
13554
|
function registerClass(name, ctor) {
|
|
13555
|
+
const base = typeof ctor === "function" ? UNSUPPORTED_BASES.find((b) => ctor.prototype instanceof b) : void 0;
|
|
13556
|
+
if (base) throw new TypeError(`spindle: Cannot register class "${name}": it extends ${base.name}, whose instances cannot be saved (a registered class may extend Array, Map, Set, Date, RegExp or Error)`);
|
|
13331
13557
|
registry.set(name, ctor);
|
|
13332
13558
|
ctorToName.set(ctor, name);
|
|
13333
13559
|
}
|
|
@@ -13394,16 +13620,22 @@ function ownData(value, keys = Object.keys(value)) {
|
|
|
13394
13620
|
for (const key of keys) defineData(data, key, value[key]);
|
|
13395
13621
|
return data;
|
|
13396
13622
|
}
|
|
13397
|
-
/**
|
|
13398
|
-
|
|
13623
|
+
/**
|
|
13624
|
+
* The built-ins a registered class may extend whose value is not in its
|
|
13625
|
+
* keys, saved as their kind (see classData).
|
|
13626
|
+
*/
|
|
13627
|
+
var BUILTIN_KINDS = {
|
|
13399
13628
|
Array,
|
|
13400
13629
|
Map,
|
|
13401
|
-
Set
|
|
13630
|
+
Set,
|
|
13631
|
+
Date,
|
|
13632
|
+
RegExp
|
|
13402
13633
|
};
|
|
13403
13634
|
/**
|
|
13404
13635
|
* The saved form of a registered class instance: its own data (see
|
|
13405
|
-
* ownData), or for a
|
|
13406
|
-
* with the built-in methods, which a
|
|
13636
|
+
* ownData), or for a subclass of a built-in kind (see BUILTIN_KINDS) its
|
|
13637
|
+
* kind, contents and extra keys, read with the built-in methods, which a
|
|
13638
|
+
* subclass may override (#391, #393).
|
|
13407
13639
|
*/
|
|
13408
13640
|
function classData(value) {
|
|
13409
13641
|
const extra = () => ownData(value, extraKeys(value));
|
|
@@ -13418,12 +13650,26 @@ function classData(value) {
|
|
|
13418
13650
|
}
|
|
13419
13651
|
if (value instanceof Map) return [
|
|
13420
13652
|
"Map",
|
|
13421
|
-
Array.from(
|
|
13653
|
+
Array.from(mapEntries(value)),
|
|
13422
13654
|
extra()
|
|
13423
13655
|
];
|
|
13424
13656
|
if (value instanceof Set) return [
|
|
13425
13657
|
"Set",
|
|
13426
|
-
Array.from(
|
|
13658
|
+
Array.from(setMembers(value)),
|
|
13659
|
+
extra()
|
|
13660
|
+
];
|
|
13661
|
+
if (value instanceof Date) return [
|
|
13662
|
+
"Date",
|
|
13663
|
+
Date.prototype.getTime.call(value),
|
|
13664
|
+
extra()
|
|
13665
|
+
];
|
|
13666
|
+
if (value instanceof RegExp) return [
|
|
13667
|
+
"RegExp",
|
|
13668
|
+
[
|
|
13669
|
+
Reflect.get(RegExp.prototype, "source", value),
|
|
13670
|
+
Reflect.get(RegExp.prototype, "flags", value),
|
|
13671
|
+
value.lastIndex
|
|
13672
|
+
],
|
|
13427
13673
|
extra()
|
|
13428
13674
|
];
|
|
13429
13675
|
return ownData(value);
|
|
@@ -13459,22 +13705,44 @@ function reducers() {
|
|
|
13459
13705
|
return out;
|
|
13460
13706
|
}
|
|
13461
13707
|
/**
|
|
13462
|
-
* The
|
|
13463
|
-
*
|
|
13464
|
-
|
|
13465
|
-
|
|
13708
|
+
* The RegExp of a `[source, flags, lastIndex]` list (an `R` entry, or the
|
|
13709
|
+
* contents of a RegExp subclass), or undefined if the list is malformed.
|
|
13710
|
+
*/
|
|
13711
|
+
function newRegExp(data) {
|
|
13712
|
+
if (!Array.isArray(data) || typeof data[0] !== "string" || typeof data[1] !== "string" || !Number.isSafeInteger(data[2])) return;
|
|
13713
|
+
const re = new RegExp(data[0], data[1]);
|
|
13714
|
+
re.lastIndex = data[2];
|
|
13715
|
+
return re;
|
|
13716
|
+
}
|
|
13717
|
+
/**
|
|
13718
|
+
* A new Date or RegExp holding `contents` (see classData), or undefined if
|
|
13719
|
+
* they are malformed.
|
|
13720
|
+
*/
|
|
13721
|
+
function newAtomic(kind, contents) {
|
|
13722
|
+
if (kind === "RegExp") return newRegExp(contents);
|
|
13723
|
+
return typeof contents === "number" ? new Date(contents) : void 0;
|
|
13724
|
+
}
|
|
13725
|
+
/**
|
|
13726
|
+
* The built-in of a registered class that a `[kind, contents, keys]` list
|
|
13727
|
+
* holds (see classData). A cycle through a collection revives it before its
|
|
13728
|
+
* list is complete (devalue holds unread parts as holes), so the instance
|
|
13729
|
+
* is kept per list and filled with what the list holds so far. (The
|
|
13730
|
+
* contents of a Date or RegExp hold no objects, so they are complete.)
|
|
13466
13731
|
*/
|
|
13467
13732
|
var collections = /* @__PURE__ */ new WeakMap();
|
|
13468
|
-
function
|
|
13733
|
+
function reviveBuiltin(name, ctor, list) {
|
|
13469
13734
|
const [kind, contents, keys] = list;
|
|
13470
|
-
const base = typeof kind === "string" && hasOwn(
|
|
13471
|
-
|
|
13735
|
+
const base = typeof kind === "string" && hasOwn(BUILTIN_KINDS, kind) ? BUILTIN_KINDS[kind] : void 0;
|
|
13736
|
+
const atomic = kind === "Date" || kind === "RegExp";
|
|
13737
|
+
if (list.length !== 3 || !base || !(ctor.prototype instanceof base) || !atomic && hasOwn(list, 1) && !Array.isArray(contents) || hasOwn(list, 2) && !isPlainData(keys)) throw malformedClass(name);
|
|
13472
13738
|
let made = collections.get(list);
|
|
13473
13739
|
if (!made) {
|
|
13474
|
-
|
|
13740
|
+
const value = atomic ? newAtomic(kind, contents) : new base();
|
|
13741
|
+
if (!value) throw malformedClass(name);
|
|
13742
|
+
made = Object.setPrototypeOf(value, ctor.prototype);
|
|
13475
13743
|
collections.set(list, made);
|
|
13476
13744
|
}
|
|
13477
|
-
if (Array.isArray(contents)) fillCollection(made, contents);
|
|
13745
|
+
if (!atomic && Array.isArray(contents)) fillCollection(made, contents);
|
|
13478
13746
|
if (isPlainData(keys)) for (const key of Object.keys(keys)) defineData(made, key, keys[key]);
|
|
13479
13747
|
return made;
|
|
13480
13748
|
}
|
|
@@ -13498,13 +13766,13 @@ function fillCollection(made, contents) {
|
|
|
13498
13766
|
/** Restore a registered class instance in place, so cycles through it hold. */
|
|
13499
13767
|
function reviveClass(name) {
|
|
13500
13768
|
return (data) => {
|
|
13501
|
-
if (Array.isArray(data)) return
|
|
13769
|
+
if (Array.isArray(data)) return reviveBuiltin(name, registeredCtor(name), data);
|
|
13502
13770
|
if (!isPlainData(data)) {
|
|
13503
13771
|
if (isObject(data) && registeredClassName(data) === name) return data;
|
|
13504
13772
|
throw malformedClass(name);
|
|
13505
13773
|
}
|
|
13506
13774
|
const ctor = registeredCtor(name);
|
|
13507
|
-
if (Object.values(
|
|
13775
|
+
if (Object.values(BUILTIN_KINDS).some((c) => ctor.prototype instanceof c)) throw malformedClass(name);
|
|
13508
13776
|
Object.setPrototypeOf(data, ctor.prototype);
|
|
13509
13777
|
if (data instanceof Error) hideErrorKeys(data);
|
|
13510
13778
|
return data;
|
|
@@ -13566,9 +13834,8 @@ function reviverFor(key) {
|
|
|
13566
13834
|
};
|
|
13567
13835
|
if (key === KEYS_TAG) return reviveKeyed;
|
|
13568
13836
|
if (key === REGEXP_TAG) return (data) => {
|
|
13569
|
-
|
|
13570
|
-
|
|
13571
|
-
re.lastIndex = data[2];
|
|
13837
|
+
const re = newRegExp(data);
|
|
13838
|
+
if (!re) throw new TypeError("spindle: Malformed regular expression");
|
|
13572
13839
|
return re;
|
|
13573
13840
|
};
|
|
13574
13841
|
if (key.startsWith(CLASS_PREFIX)) return reviveClass(key.slice(2));
|
|
@@ -14248,13 +14515,13 @@ function isPlainObject(value) {
|
|
|
14248
14515
|
return proto === Object.prototype || proto === null;
|
|
14249
14516
|
}
|
|
14250
14517
|
/**
|
|
14251
|
-
* `empty`, a new
|
|
14252
|
-
* like it: an instance of a registered subclass keeps its class
|
|
14253
|
-
* extra keys (#391), with the values `value` gives for them;
|
|
14254
|
-
*
|
|
14518
|
+
* `empty`, a new built-in (an Array, Map, Set, Date or RegExp) standing for
|
|
14519
|
+
* `obj`, made like it: an instance of a registered subclass keeps its class
|
|
14520
|
+
* and its extra keys (#391, #393), with the values `value` gives for them;
|
|
14521
|
+
* other built-ins are plain. `made` gets it before its keys are filled, so
|
|
14255
14522
|
* that cycles through it find it.
|
|
14256
14523
|
*/
|
|
14257
|
-
function
|
|
14524
|
+
function builtinLike(obj, empty, made, value) {
|
|
14258
14525
|
made(empty);
|
|
14259
14526
|
if (registeredClassName(obj) === void 0) return empty;
|
|
14260
14527
|
Object.setPrototypeOf(empty, Object.getPrototypeOf(obj));
|
|
@@ -14287,11 +14554,11 @@ function deepClone(value, options = {}) {
|
|
|
14287
14554
|
return copy;
|
|
14288
14555
|
}
|
|
14289
14556
|
function cloneBuiltin(val) {
|
|
14290
|
-
if (val instanceof Date) return
|
|
14557
|
+
if (val instanceof Date) return builtin(val, new Date(Date.prototype.getTime.call(val)));
|
|
14291
14558
|
if (val instanceof RegExp) {
|
|
14292
|
-
const copy = new RegExp(
|
|
14559
|
+
const copy = new RegExp(Reflect.get(RegExp.prototype, "source", val), Reflect.get(RegExp.prototype, "flags", val));
|
|
14293
14560
|
copy.lastIndex = val.lastIndex;
|
|
14294
|
-
return
|
|
14561
|
+
return builtin(val, copy);
|
|
14295
14562
|
}
|
|
14296
14563
|
if (val instanceof ArrayBuffer) return keep(val, val.slice(0));
|
|
14297
14564
|
if (ArrayBuffer.isView(val)) {
|
|
@@ -14322,29 +14589,29 @@ function deepClone(value, options = {}) {
|
|
|
14322
14589
|
const settle = options.settle;
|
|
14323
14590
|
return settle && isObjectValue(copy) && isObjectValue(original) ? settle(copy, original) : copy;
|
|
14324
14591
|
}
|
|
14325
|
-
/** `empty`, made the copy of the
|
|
14326
|
-
const
|
|
14592
|
+
/** `empty`, made the copy of the built-in `obj` (see builtinLike). */
|
|
14593
|
+
const builtin = (obj, empty) => builtinLike(obj, empty, (copy) => keep(obj, copy), (key) => clone(obj[key]));
|
|
14327
14594
|
function clone(val) {
|
|
14328
14595
|
if (val === null || typeof val !== "object") return val;
|
|
14329
14596
|
const obj = val;
|
|
14330
14597
|
if (seen.has(obj)) return seen.get(obj);
|
|
14331
14598
|
if (Array.isArray(val)) {
|
|
14332
|
-
const arr =
|
|
14599
|
+
const arr = builtin(obj, new Array(val.length));
|
|
14333
14600
|
for (let i = 0; i < val.length; i++) if (i in val) arr[i] = clone(val[i]);
|
|
14334
14601
|
return arr;
|
|
14335
14602
|
}
|
|
14336
14603
|
if (val instanceof Map) {
|
|
14337
|
-
const copy =
|
|
14338
|
-
for (const [k, v] of val) Map.prototype.set.call(copy, settled(clone(k), k), clone(v));
|
|
14604
|
+
const copy = builtin(obj, /* @__PURE__ */ new Map());
|
|
14605
|
+
for (const [k, v] of mapEntries(val)) Map.prototype.set.call(copy, settled(clone(k), k), clone(v));
|
|
14339
14606
|
return copy;
|
|
14340
14607
|
}
|
|
14341
14608
|
if (val instanceof Set) {
|
|
14342
|
-
const copy =
|
|
14343
|
-
for (const v of val) Set.prototype.add.call(copy, settled(clone(v), v));
|
|
14609
|
+
const copy = builtin(obj, /* @__PURE__ */ new Set());
|
|
14610
|
+
for (const v of setMembers(val)) Set.prototype.add.call(copy, settled(clone(v), v));
|
|
14344
14611
|
return copy;
|
|
14345
14612
|
}
|
|
14346
|
-
const
|
|
14347
|
-
if (
|
|
14613
|
+
const copied = cloneBuiltin(obj);
|
|
14614
|
+
if (copied !== void 0) return copied;
|
|
14348
14615
|
const keepsProto = registeredClassName(obj) !== void 0 || isPlainObject(val);
|
|
14349
14616
|
if (!keepsProto && options.keepUnregistered) return val;
|
|
14350
14617
|
return copyKeys(obj, keep(obj, keepsProto ? Object.create(Object.getPrototypeOf(obj)) : {}));
|
|
@@ -14447,11 +14714,11 @@ function shareEqual(prev, curr) {
|
|
|
14447
14714
|
const cr = c;
|
|
14448
14715
|
/** What the result holds at `key` of `c`. */
|
|
14449
14716
|
const shareKey = (key) => share(hasOwn(pr, key) ? pr[key] : void 0, cr[key]);
|
|
14450
|
-
/** `empty`, made the result for the collection `c` (see
|
|
14451
|
-
const collection = (empty) =>
|
|
14717
|
+
/** `empty`, made the result for the collection `c` (see builtinLike). */
|
|
14718
|
+
const collection = (empty) => builtinLike(c, empty, (out) => done.set(c, out), shareKey);
|
|
14452
14719
|
if (c instanceof Map && p instanceof Map) {
|
|
14453
14720
|
const out = collection(/* @__PURE__ */ new Map());
|
|
14454
|
-
for (const [k, v] of c) Map.prototype.set.call(out, fresh(k), share(p
|
|
14721
|
+
for (const [k, v] of mapEntries(c)) Map.prototype.set.call(out, fresh(k), share(mapGet(p, k), v));
|
|
14455
14722
|
return out;
|
|
14456
14723
|
}
|
|
14457
14724
|
if (Array.isArray(c) && Array.isArray(p)) {
|
|
@@ -14479,8 +14746,14 @@ function equalBytes(a, b) {
|
|
|
14479
14746
|
}
|
|
14480
14747
|
/** Equality of the content of atomic built-ins (see isAtomic) but Map/Set. */
|
|
14481
14748
|
function equalBuiltin(a, b, assumed) {
|
|
14482
|
-
if (a instanceof Date)
|
|
14483
|
-
|
|
14749
|
+
if (a instanceof Date) {
|
|
14750
|
+
const time = Date.prototype.getTime;
|
|
14751
|
+
return Object.is(time.call(a), time.call(b)) && equalExtraKeys(a, b, assumed);
|
|
14752
|
+
}
|
|
14753
|
+
if (a instanceof RegExp) {
|
|
14754
|
+
const text = RegExp.prototype.toString;
|
|
14755
|
+
return text.call(a) === text.call(b) && a.lastIndex === b.lastIndex && equalExtraKeys(a, b, assumed);
|
|
14756
|
+
}
|
|
14484
14757
|
if (ArrayBuffer.isView(a)) {
|
|
14485
14758
|
const v = b;
|
|
14486
14759
|
return a.byteOffset === v.byteOffset && a.byteLength === v.byteLength && equal(a.buffer, v.buffer, assumed);
|
|
@@ -14499,18 +14772,20 @@ function equalKeys(a, b, assumed, keysOf = Object.keys) {
|
|
|
14499
14772
|
for (const key of keys) if (!hasOwn(bo, key) || !equal(ao[key], bo[key], assumed)) return false;
|
|
14500
14773
|
return true;
|
|
14501
14774
|
}
|
|
14502
|
-
/** Built-in
|
|
14503
|
-
var
|
|
14775
|
+
/** Built-in prototypes (see builtinLike), whose instances hold no extra keys. */
|
|
14776
|
+
var BUILTIN_PROTOS = new Set([
|
|
14504
14777
|
Array.prototype,
|
|
14505
14778
|
Map.prototype,
|
|
14506
|
-
Set.prototype
|
|
14779
|
+
Set.prototype,
|
|
14780
|
+
Date.prototype,
|
|
14781
|
+
RegExp.prototype
|
|
14507
14782
|
]);
|
|
14508
14783
|
/**
|
|
14509
|
-
* Equality of the extra keys (see extraKeys) of two
|
|
14784
|
+
* Equality of the extra keys (see extraKeys) of two built-ins of one
|
|
14510
14785
|
* class: those of a subclass instance are part of its value.
|
|
14511
14786
|
*/
|
|
14512
14787
|
function equalExtraKeys(a, b, assumed) {
|
|
14513
|
-
return
|
|
14788
|
+
return BUILTIN_PROTOS.has(Object.getPrototypeOf(a)) || equalKeys(a, b, assumed, extraKeys);
|
|
14514
14789
|
}
|
|
14515
14790
|
/** `assumed` tracks the pairs of objects met (see Pairs). */
|
|
14516
14791
|
function equal(a, b, assumed) {
|
|
@@ -14521,9 +14796,9 @@ function equal(a, b, assumed) {
|
|
|
14521
14796
|
if (met !== void 0) return met;
|
|
14522
14797
|
if (a instanceof Map || a instanceof Set) {
|
|
14523
14798
|
const bc = b;
|
|
14524
|
-
if (a
|
|
14525
|
-
const ai = a
|
|
14526
|
-
const bi = bc
|
|
14799
|
+
if (collectionSize(a) !== collectionSize(bc)) return false;
|
|
14800
|
+
const ai = a instanceof Map ? mapEntries(a) : setMembers(a);
|
|
14801
|
+
const bi = bc instanceof Map ? mapEntries(bc) : setMembers(bc);
|
|
14527
14802
|
for (let x = ai.next(), y = bi.next(); !x.done; x = ai.next(), y = bi.next()) if (!equal(x.value, y.value, assumed)) return false;
|
|
14528
14803
|
return equalExtraKeys(a, b, assumed);
|
|
14529
14804
|
}
|
|
@@ -14703,13 +14978,13 @@ function entryChildren(value) {
|
|
|
14703
14978
|
const children = [];
|
|
14704
14979
|
if (value instanceof Map) {
|
|
14705
14980
|
let index = 0;
|
|
14706
|
-
for (const [k, v] of value) {
|
|
14981
|
+
for (const [k, v] of mapEntries(value)) {
|
|
14707
14982
|
children.push([entryKey("k", index), k], [entryKey("v", index), v]);
|
|
14708
14983
|
index++;
|
|
14709
14984
|
}
|
|
14710
14985
|
} else if (value instanceof Set) {
|
|
14711
14986
|
let index = 0;
|
|
14712
|
-
for (const member of value) children.push([entryKey("s", index++), member]);
|
|
14987
|
+
for (const member of setMembers(value)) children.push([entryKey("s", index++), member]);
|
|
14713
14988
|
} else if (value instanceof Error) {
|
|
14714
14989
|
for (const key of ["cause", "errors"]) if (hasOwn(value, key)) children.push([entryKey(key === "cause" ? "c" : "e", 0), value[key]]);
|
|
14715
14990
|
} else if (ArrayBuffer.isView(value)) children.push([entryKey("b", 0), value.buffer]);
|
|
@@ -14741,8 +15016,9 @@ function setEntryValue(root, path, value) {
|
|
|
14741
15016
|
const holder = getByEntryPath(root, path.slice(0, -1));
|
|
14742
15017
|
const match = /^\0v(\d+)$/.exec(path[path.length - 1]);
|
|
14743
15018
|
if (!(holder instanceof Map) || !match) return false;
|
|
14744
|
-
const
|
|
14745
|
-
|
|
15019
|
+
const entry = [...mapEntries(holder)][Number(match[1])];
|
|
15020
|
+
if (!entry) return false;
|
|
15021
|
+
mapSet(holder, entry[0], value);
|
|
14746
15022
|
return true;
|
|
14747
15023
|
}
|
|
14748
15024
|
/**
|
|
@@ -14811,7 +15087,8 @@ function aliasMoved(x, y, at, earlier, later) {
|
|
|
14811
15087
|
if (xs && ys) {
|
|
14812
15088
|
if (Object.getPrototypeOf(x) !== Object.getPrototypeOf(y)) return false;
|
|
14813
15089
|
if (x instanceof Map || x instanceof Set) {
|
|
14814
|
-
|
|
15090
|
+
const ySize = collectionSize(y);
|
|
15091
|
+
if (collectionSize(x) !== ySize) return false;
|
|
14815
15092
|
}
|
|
14816
15093
|
const held = new Map(ys);
|
|
14817
15094
|
for (const [segment, a] of xs) if (held.has(segment)) pairs.push([
|
|
@@ -15827,9 +16104,9 @@ function deeplyFrozen(value, seen = /* @__PURE__ */ new Set()) {
|
|
|
15827
16104
|
if (!Object.isFrozen(value)) return false;
|
|
15828
16105
|
seen.add(value);
|
|
15829
16106
|
if (value instanceof Map) {
|
|
15830
|
-
for (const [key, entry] of value) if (!deeplyFrozen(key, seen) || !deeplyFrozen(entry, seen)) return false;
|
|
16107
|
+
for (const [key, entry] of mapEntries(value)) if (!deeplyFrozen(key, seen) || !deeplyFrozen(entry, seen)) return false;
|
|
15831
16108
|
} else if (value instanceof Set) {
|
|
15832
|
-
for (const member of value) if (!deeplyFrozen(member, seen)) return false;
|
|
16109
|
+
for (const member of setMembers(value)) if (!deeplyFrozen(member, seen)) return false;
|
|
15833
16110
|
}
|
|
15834
16111
|
return Reflect.ownKeys(value).every((key) => {
|
|
15835
16112
|
const desc = Object.getOwnPropertyDescriptor(value, key);
|
|
@@ -16375,10 +16652,14 @@ function connectTriggersToStore() {
|
|
|
16375
16652
|
function reinitTriggerState() {
|
|
16376
16653
|
for (const trigger of triggers) trigger.lastResult = evalCondition(trigger.condition);
|
|
16377
16654
|
}
|
|
16655
|
+
/**
|
|
16656
|
+
* Forget every watcher and close every dialog on display, whoever opened it
|
|
16657
|
+
* (restart): a `{dialog}` or menubar dialog of the story interface, which
|
|
16658
|
+
* stays mounted, would otherwise stay open over the new game (#397).
|
|
16659
|
+
*/
|
|
16378
16660
|
function resetTriggers() {
|
|
16379
16661
|
triggers = [];
|
|
16380
|
-
|
|
16381
|
-
dialogHostCallbacks?.closeAll();
|
|
16662
|
+
closeAllOpenDialogs();
|
|
16382
16663
|
}
|
|
16383
16664
|
function subscribeTriggerDialogs(cb) {
|
|
16384
16665
|
dialogNotify = cb;
|
|
@@ -16690,6 +16971,15 @@ function startVariables(defaults) {
|
|
|
16690
16971
|
return initialVars;
|
|
16691
16972
|
}
|
|
16692
16973
|
/**
|
|
16974
|
+
* Fresh transient variables from their declared defaults (init, restart,
|
|
16975
|
+
* load). Transients are never saved, so an instance of an unregistered
|
|
16976
|
+
* class (an engine, a library object) is kept as it is, as mutation code
|
|
16977
|
+
* keeps it (#321): a copy would lose its class and methods (#398).
|
|
16978
|
+
*/
|
|
16979
|
+
function freshTransients(defaults) {
|
|
16980
|
+
return createNamespace(deepClone(defaults, { keepUnregistered: true }));
|
|
16981
|
+
}
|
|
16982
|
+
/**
|
|
16693
16983
|
* Enter the start passage with `variables`, as the only history moment
|
|
16694
16984
|
* (init, restart). Call it inside a store update.
|
|
16695
16985
|
*/
|
|
@@ -16697,7 +16987,7 @@ function enterStart(state, passage, variables, transientDefaults) {
|
|
|
16697
16987
|
state.currentPassage = passage;
|
|
16698
16988
|
state.navigationId++;
|
|
16699
16989
|
state.variables = variables;
|
|
16700
|
-
state.transient =
|
|
16990
|
+
state.transient = freshTransients(transientDefaults);
|
|
16701
16991
|
state.temporary = createNamespace();
|
|
16702
16992
|
state.history = [{
|
|
16703
16993
|
passage,
|
|
@@ -17456,7 +17746,7 @@ var useStoryStore = create()(storyStore((set, get) => ({
|
|
|
17456
17746
|
state.visitCounts = createCounts(payload.visitCounts);
|
|
17457
17747
|
state.renderCounts = createCounts(payload.renderCounts);
|
|
17458
17748
|
state.temporary = createNamespace();
|
|
17459
|
-
state.transient =
|
|
17749
|
+
state.transient = freshTransients(get().transientDefaults);
|
|
17460
17750
|
});
|
|
17461
17751
|
if (payload.watchers) restoreMacroWatchers(payload.watchers);
|
|
17462
17752
|
reinitTriggerState();
|
|
@@ -17686,6 +17976,7 @@ function PassageDialog({ passageName, fallbackMarkup, panelClass, onClose, dismi
|
|
|
17686
17976
|
}
|
|
17687
17977
|
}, [markup, nobr]);
|
|
17688
17978
|
const panelRef = useRef(null);
|
|
17979
|
+
const viewScope = useViewScope();
|
|
17689
17980
|
useModalFocus(panelRef, ".dialog-body", dismissible, stableOnClose);
|
|
17690
17981
|
useLayoutEffect(() => registerOpenDialog(stableOnClose), [stableOnClose]);
|
|
17691
17982
|
useLayoutEffect(() => {
|
|
@@ -17715,7 +18006,10 @@ function PassageDialog({ passageName, fallbackMarkup, panelClass, onClose, dismi
|
|
|
17715
18006
|
children: "✕"
|
|
17716
18007
|
}), /* @__PURE__ */ jsx("div", {
|
|
17717
18008
|
class: "dialog-body",
|
|
17718
|
-
children:
|
|
18009
|
+
children: /* @__PURE__ */ jsx(ViewScopeContext.Provider, {
|
|
18010
|
+
value: viewScope,
|
|
18011
|
+
children: content
|
|
18012
|
+
})
|
|
17719
18013
|
})]
|
|
17720
18014
|
})
|
|
17721
18015
|
})
|
|
@@ -19764,13 +20058,13 @@ function keyOf(val, ancestors) {
|
|
|
19764
20058
|
const obj = val;
|
|
19765
20059
|
const depth = ancestors.indexOf(obj);
|
|
19766
20060
|
if (depth !== -1) return `<cycle ${ancestors.length - depth}>`;
|
|
19767
|
-
if (val instanceof Date) return `Date(${
|
|
19768
|
-
if (val instanceof RegExp) return `RegExp(${
|
|
20061
|
+
if (val instanceof Date) return `Date(${Date.prototype.getTime.call(val)})`;
|
|
20062
|
+
if (val instanceof RegExp) return `RegExp(${RegExp.prototype.toString.call(val)}@${val.lastIndex})`;
|
|
19769
20063
|
ancestors.push(obj);
|
|
19770
20064
|
try {
|
|
19771
20065
|
if (Array.isArray(val)) return `[${Array.from(val, (v) => keyOf(v, ancestors)).join(",")}]`;
|
|
19772
|
-
if (val instanceof Map) return `Map[${[...val].map(([k, v]) => `[${keyOf(k, ancestors)},${keyOf(v, ancestors)}]`).join(",")}]`;
|
|
19773
|
-
if (val instanceof Set) return `Set[${[...val].map((v) => keyOf(v, ancestors)).join(",")}]`;
|
|
20066
|
+
if (val instanceof Map) return `Map[${[...mapEntries(val)].map(([k, v]) => `[${keyOf(k, ancestors)},${keyOf(v, ancestors)}]`).join(",")}]`;
|
|
20067
|
+
if (val instanceof Set) return `Set[${[...setMembers(val)].map((v) => keyOf(v, ancestors)).join(",")}]`;
|
|
19774
20068
|
const record = obj;
|
|
19775
20069
|
const body = Object.keys(record).map((k) => `${JSON.stringify(k)}:${keyOf(record[k], ancestors)}`).join(",");
|
|
19776
20070
|
const className = registeredClassName(obj);
|
|
@@ -21162,6 +21456,7 @@ defineMacro({
|
|
|
21162
21456
|
render(_props, ctx) {
|
|
21163
21457
|
const radioValue = ctx.args.value ?? "";
|
|
21164
21458
|
const label = ctx.args.label ?? "";
|
|
21459
|
+
const view = ctx.hooks.useContext(ViewScopeContext);
|
|
21165
21460
|
useVariableAction(ctx, {
|
|
21166
21461
|
type: "radiobutton",
|
|
21167
21462
|
key: `$${ctx.varName}:${radioValue}`,
|
|
@@ -21173,7 +21468,7 @@ defineMacro({
|
|
|
21173
21468
|
class: ctx.cls,
|
|
21174
21469
|
children: [/* @__PURE__ */ jsx("input", {
|
|
21175
21470
|
type: "radio",
|
|
21176
|
-
name: `radio-${ctx.varName}`,
|
|
21471
|
+
name: view ? `radio-${view}-${ctx.varName}` : `radio-${ctx.varName}`,
|
|
21177
21472
|
checked: ctx.value === radioValue,
|
|
21178
21473
|
onChange: () => ctx.setValue(radioValue)
|
|
21179
21474
|
}), label ? ` ${label}` : null]
|
|
@@ -21332,27 +21627,31 @@ function Passage({ passage, dataTransition, navigationId }) {
|
|
|
21332
21627
|
if (elRef.current) emitFromRender("passagerender", passage.name, elRef.current);
|
|
21333
21628
|
}, [passage.name, navigationId]);
|
|
21334
21629
|
const nobr = passage.tags.includes("nobr");
|
|
21335
|
-
const
|
|
21336
|
-
|
|
21337
|
-
|
|
21338
|
-
"
|
|
21339
|
-
|
|
21340
|
-
|
|
21341
|
-
|
|
21342
|
-
|
|
21343
|
-
|
|
21344
|
-
|
|
21345
|
-
|
|
21346
|
-
|
|
21347
|
-
|
|
21348
|
-
|
|
21349
|
-
|
|
21350
|
-
|
|
21351
|
-
|
|
21352
|
-
|
|
21353
|
-
|
|
21354
|
-
|
|
21355
|
-
|
|
21630
|
+
const viewScope = useViewScope();
|
|
21631
|
+
const inner = /* @__PURE__ */ jsx(ViewScopeContext.Provider, {
|
|
21632
|
+
value: viewScope,
|
|
21633
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
21634
|
+
ref: elRef,
|
|
21635
|
+
class: "passage",
|
|
21636
|
+
"data-passage": passage.name,
|
|
21637
|
+
"data-tags": passage.tags.join(" "),
|
|
21638
|
+
"data-transition": dataTransition,
|
|
21639
|
+
children: [
|
|
21640
|
+
headerContent && /* @__PURE__ */ jsx("div", {
|
|
21641
|
+
class: "passage-header",
|
|
21642
|
+
children: headerContent
|
|
21643
|
+
}),
|
|
21644
|
+
content,
|
|
21645
|
+
footerContent && /* @__PURE__ */ jsx("div", {
|
|
21646
|
+
class: "passage-footer",
|
|
21647
|
+
children: footerContent
|
|
21648
|
+
}),
|
|
21649
|
+
doneContent && /* @__PURE__ */ jsx("div", {
|
|
21650
|
+
hidden: true,
|
|
21651
|
+
children: doneContent
|
|
21652
|
+
})
|
|
21653
|
+
]
|
|
21654
|
+
})
|
|
21356
21655
|
});
|
|
21357
21656
|
return nobr ? /* @__PURE__ */ jsx(NobrContext.Provider, {
|
|
21358
21657
|
value: true,
|