@rohal12/spindle 0.59.13 → 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 +817 -272
- package/dist/pkg/story-variables.js +330 -160
- package/package.json +1 -1
- package/src/class-registry.ts +213 -24
- package/src/components/Passage.tsx +21 -13
- package/src/components/PassageDialog.tsx +12 -2
- package/src/components/macros/Radiobutton.tsx +4 -1
- package/src/components/macros/WidgetInvocation.tsx +7 -2
- package/src/execute-mutation.ts +11 -0
- package/src/hooks/use-modal-focus.ts +46 -16
- package/src/interpolation.ts +25 -5
- package/src/markup/render.tsx +28 -5
- package/src/markup/spindle.peggy +16 -0
- package/src/store.ts +12 -2
- package/src/structural.ts +136 -36
- package/src/triggers.ts +6 -2
- package/src/utils/stable-key.ts +8 -4
- package/src/utils/value-kinds.ts +56 -0
- package/src/widgets/widget-def.ts +27 -15
- 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
|
}
|
|
@@ -9893,6 +10057,86 @@ function parseMarkup(source, options = {}) {
|
|
|
9893
10057
|
function tokenizeMarkup(source, options = {}) {
|
|
9894
10058
|
return run$2(source, "Tokens", options);
|
|
9895
10059
|
}
|
|
10060
|
+
/**
|
|
10061
|
+
* `tokenizeMarkup` for half-typed markup: the tokens it can read, and every
|
|
10062
|
+
* error, instead of throwing at the first. At a malformed tag, the tokens
|
|
10063
|
+
* before it are kept, its first character is read as text and tokenizing
|
|
10064
|
+
* resumes after it, so what follows is read as if the tag had not been
|
|
10065
|
+
* started. Tokens and errors have offsets in `source`; for well-formed
|
|
10066
|
+
* markup the tokens are those of `tokenizeMarkup` and there are no errors.
|
|
10067
|
+
*/
|
|
10068
|
+
function tokenizeMarkupTolerant(source, options = {}) {
|
|
10069
|
+
const tokens = [];
|
|
10070
|
+
const errors = [];
|
|
10071
|
+
const lastBrace = source.lastIndexOf("}");
|
|
10072
|
+
const { closeBrace } = {
|
|
10073
|
+
...defaultHooks,
|
|
10074
|
+
...options.hooks
|
|
10075
|
+
};
|
|
10076
|
+
/** `text` shifted by `base`, tokenized: the tokens or the error. */
|
|
10077
|
+
const attempt = (text, base) => {
|
|
10078
|
+
const hooks = {
|
|
10079
|
+
...options.hooks,
|
|
10080
|
+
closeBrace: (input, codeStart, lenientStart) => base + Math.min(codeStart, lenientStart) > lastBrace ? -1 : closeBrace(input, codeStart, lenientStart)
|
|
10081
|
+
};
|
|
10082
|
+
try {
|
|
10083
|
+
return tokenizeMarkup(text, {
|
|
10084
|
+
...options,
|
|
10085
|
+
hooks
|
|
10086
|
+
}).map((token) => shift(token, base));
|
|
10087
|
+
} catch (error) {
|
|
10088
|
+
if (!(error instanceof MarkupError)) throw error;
|
|
10089
|
+
return error;
|
|
10090
|
+
}
|
|
10091
|
+
};
|
|
10092
|
+
let base = 0;
|
|
10093
|
+
while (base <= source.length) {
|
|
10094
|
+
const rest = source.slice(base);
|
|
10095
|
+
const result = attempt(rest, base);
|
|
10096
|
+
if (Array.isArray(result)) {
|
|
10097
|
+
tokens.push(...result);
|
|
10098
|
+
break;
|
|
10099
|
+
}
|
|
10100
|
+
const at = base + result.offset;
|
|
10101
|
+
const { line, column } = lineColumn(source, at);
|
|
10102
|
+
errors.push(new MarkupError(result.reason, at, line, column));
|
|
10103
|
+
let cut = result.offset;
|
|
10104
|
+
let prefix = attempt(rest.slice(0, cut), base);
|
|
10105
|
+
while (!Array.isArray(prefix)) {
|
|
10106
|
+
cut = prefix.offset;
|
|
10107
|
+
prefix = attempt(rest.slice(0, cut), base);
|
|
10108
|
+
}
|
|
10109
|
+
tokens.push(...prefix);
|
|
10110
|
+
if (cut < rest.length) {
|
|
10111
|
+
const start = base + cut;
|
|
10112
|
+
tokens.push({
|
|
10113
|
+
type: "text",
|
|
10114
|
+
value: rest[cut],
|
|
10115
|
+
start,
|
|
10116
|
+
end: start + 1
|
|
10117
|
+
});
|
|
10118
|
+
}
|
|
10119
|
+
base += cut + 1;
|
|
10120
|
+
}
|
|
10121
|
+
return {
|
|
10122
|
+
tokens,
|
|
10123
|
+
errors
|
|
10124
|
+
};
|
|
10125
|
+
}
|
|
10126
|
+
/** `token` with its offsets moved `by` on. */
|
|
10127
|
+
function shift(token, by) {
|
|
10128
|
+
if (by === 0) return token;
|
|
10129
|
+
const moved = {
|
|
10130
|
+
...token,
|
|
10131
|
+
start: token.start + by,
|
|
10132
|
+
end: token.end + by
|
|
10133
|
+
};
|
|
10134
|
+
if (moved.type === "link") {
|
|
10135
|
+
moved.targetStart += by;
|
|
10136
|
+
moved.targetEnd += by;
|
|
10137
|
+
}
|
|
10138
|
+
return moved;
|
|
10139
|
+
}
|
|
9896
10140
|
//#endregion
|
|
9897
10141
|
//#region src/utils/namespace.ts
|
|
9898
10142
|
/** The variable name no namespace can hold. */
|
|
@@ -10567,28 +10811,34 @@ function parseWidgetDef(rawArgs) {
|
|
|
10567
10811
|
return widgetDef(parseMacroArgs(rawArgs, WIDGET_PARAMETERS));
|
|
10568
10812
|
}
|
|
10569
10813
|
/**
|
|
10570
|
-
* A definition: its arguments (read like a {widget} macro's, see
|
|
10571
|
-
* parseWidgetDef) and its body. Macro names are not case-sensitive.
|
|
10572
|
-
*/
|
|
10573
|
-
var WIDGET_DEFINITION = /\{widget\s+([^}]*)\}([\s\S]*?)\{\/widget\}/gi;
|
|
10574
|
-
/** `{@children}`, also with selectors such as `{.highlight @children}`. */
|
|
10575
|
-
var CHILDREN_PLACEHOLDER = /\{[^{}]*@children\s*\}/;
|
|
10576
|
-
/**
|
|
10577
10814
|
* The names of the block widgets (those whose body renders `{@children}`)
|
|
10578
10815
|
* that StoryInit and the passages tagged `widget` define. They must be
|
|
10579
10816
|
* known as block macros before any passage is parsed, so that passages
|
|
10580
10817
|
* invoking them nest their content whatever the passage order.
|
|
10818
|
+
*
|
|
10819
|
+
* The passages are read as flat tokens, which need no block macros to be
|
|
10820
|
+
* known, so a `{@children}` in an HTML comment or in a `{do}` body is text
|
|
10821
|
+
* here as it is to the parser, and does not make a block widget (#387).
|
|
10581
10822
|
*/
|
|
10582
10823
|
function blockWidgetNames(passages) {
|
|
10583
10824
|
const names = [];
|
|
10584
10825
|
for (const passage of passages) {
|
|
10585
10826
|
if (passage.name !== "StoryInit" && !passage.tags?.includes("widget")) continue;
|
|
10586
|
-
|
|
10587
|
-
|
|
10827
|
+
const open = [];
|
|
10828
|
+
for (const token of tokenizeMarkupTolerant(passage.content).tokens) if (token.type === "macro" && token.name.toLowerCase() === "widget") {
|
|
10829
|
+
if (!token.isClose) {
|
|
10830
|
+
open.push({
|
|
10831
|
+
rawArgs: token.rawArgs,
|
|
10832
|
+
isBlock: false
|
|
10833
|
+
});
|
|
10834
|
+
continue;
|
|
10835
|
+
}
|
|
10836
|
+
const def = open.pop();
|
|
10837
|
+
if (!def?.isBlock) continue;
|
|
10588
10838
|
try {
|
|
10589
|
-
names.push(parseWidgetDef(
|
|
10839
|
+
names.push(parseWidgetDef(def.rawArgs).name);
|
|
10590
10840
|
} catch {}
|
|
10591
|
-
}
|
|
10841
|
+
} else if (token.type === "variable" && token.scope === "local" && token.name === "children" && open.length > 0) open[open.length - 1].isBlock = true;
|
|
10592
10842
|
}
|
|
10593
10843
|
return names;
|
|
10594
10844
|
}
|
|
@@ -11108,6 +11358,13 @@ function wrapContent(className, id, content) {
|
|
|
11108
11358
|
function hasInterpolation(s) {
|
|
11109
11359
|
return s.includes("{") || s.includes("}");
|
|
11110
11360
|
}
|
|
11361
|
+
/** The children context for an invocation's `children`, or null if none. */
|
|
11362
|
+
function widgetChildrenOf(children, outer) {
|
|
11363
|
+
return children?.length ? {
|
|
11364
|
+
nodes: children,
|
|
11365
|
+
outer: outer ?? null
|
|
11366
|
+
} : null;
|
|
11367
|
+
}
|
|
11111
11368
|
var parseCache = /* @__PURE__ */ new Map();
|
|
11112
11369
|
var PARSE_CACHE_LIMIT = 2e3;
|
|
11113
11370
|
/**
|
|
@@ -11193,7 +11450,7 @@ var TextEvaluator = class {
|
|
|
11193
11450
|
if (node.scope === "local" && node.name === "children") {
|
|
11194
11451
|
const children = scope.widgetChildren;
|
|
11195
11452
|
if (!children) return "";
|
|
11196
|
-
return this.nested("children", children, scope, depth, { widgetChildren:
|
|
11453
|
+
return this.nested("children", children.nodes, scope, depth, { widgetChildren: children.outer });
|
|
11197
11454
|
}
|
|
11198
11455
|
return this.variable(node.scope, node.name, scope);
|
|
11199
11456
|
case "expression": try {
|
|
@@ -11256,7 +11513,7 @@ var TextEvaluator = class {
|
|
|
11256
11513
|
}
|
|
11257
11514
|
return this.nested(node.name, widget.body, scope, depth, {
|
|
11258
11515
|
locals,
|
|
11259
|
-
widgetChildren: node.children
|
|
11516
|
+
widgetChildren: widgetChildrenOf(node.children, scope.widgetChildren)
|
|
11260
11517
|
});
|
|
11261
11518
|
}
|
|
11262
11519
|
const text = getMacroText(node.name);
|
|
@@ -11514,7 +11771,8 @@ function WidgetInvocation(props) {
|
|
|
11514
11771
|
function WidgetContent({ body, params, rawArgs, invocationChildren }) {
|
|
11515
11772
|
const parentValues = useRenderOptions().locals;
|
|
11516
11773
|
const [mergedVars, mergedTemps, mergedLocals, mergedTrans] = useMergedLocals();
|
|
11517
|
-
const
|
|
11774
|
+
const outerChildren = useContext(WidgetChildrenContext);
|
|
11775
|
+
const childrenValue = useMemo(() => widgetChildrenOf(invocationChildren, outerChildren), [invocationChildren, outerChildren]);
|
|
11518
11776
|
const argExprs = rawArgs ? splitArgs(rawArgs) : [];
|
|
11519
11777
|
const values = [];
|
|
11520
11778
|
for (let i = 0; i < params.length; i++) {
|
|
@@ -11796,6 +12054,19 @@ var InlineContext = createContext(false);
|
|
|
11796
12054
|
*/
|
|
11797
12055
|
var RawTextContext = createContext(false);
|
|
11798
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
|
+
/**
|
|
11799
12070
|
* True inside an `<svg>` element. SVG attributes are case-sensitive and have
|
|
11800
12071
|
* no live form properties, so they are set as written (see splitAttributes).
|
|
11801
12072
|
*/
|
|
@@ -12282,10 +12553,13 @@ function HtmlNodeRenderer({ node }) {
|
|
|
12282
12553
|
}) : element);
|
|
12283
12554
|
}
|
|
12284
12555
|
function ChildrenSlot() {
|
|
12285
|
-
const
|
|
12556
|
+
const children = useContext(WidgetChildrenContext);
|
|
12286
12557
|
const renderOptions = useRenderOptions();
|
|
12287
|
-
if (!
|
|
12288
|
-
return /* @__PURE__ */ jsx(
|
|
12558
|
+
if (!children) return null;
|
|
12559
|
+
return /* @__PURE__ */ jsx(WidgetChildrenContext.Provider, {
|
|
12560
|
+
value: children.outer,
|
|
12561
|
+
children: renderNodes(children.nodes, renderOptions)
|
|
12562
|
+
});
|
|
12289
12563
|
}
|
|
12290
12564
|
/**
|
|
12291
12565
|
* Stable per-node keys. Keying rendered children by AST node identity (not
|
|
@@ -13194,10 +13468,92 @@ function stringify_primitive(thing) {
|
|
|
13194
13468
|
return String(thing);
|
|
13195
13469
|
}
|
|
13196
13470
|
//#endregion
|
|
13471
|
+
//#region src/utils/value-kinds.ts
|
|
13472
|
+
var toStringTag = (value) => Object.prototype.toString.call(value).slice(8, -1);
|
|
13473
|
+
/** Temporal values are immutable: copies may share them. */
|
|
13474
|
+
var isTemporal = (value) => toStringTag(value).startsWith("Temporal.");
|
|
13475
|
+
/** new Number(), new String(), new Boolean(), Object(1n). */
|
|
13476
|
+
var isBoxed = (value) => value instanceof Number || value instanceof String || value instanceof Boolean || toStringTag(value) === "BigInt";
|
|
13477
|
+
/**
|
|
13478
|
+
* Values compared and copied as a whole, by their content: they have no
|
|
13479
|
+
* own keys to merge by, or their keys are not the data (a property written
|
|
13480
|
+
* into one would be dropped by clones and saves, and by Immer for Map and
|
|
13481
|
+
* Set).
|
|
13482
|
+
*/
|
|
13483
|
+
function isAtomic(value) {
|
|
13484
|
+
return value instanceof Date || value instanceof RegExp || value instanceof Map || value instanceof Set || ArrayBuffer.isView(value) || value instanceof ArrayBuffer || value instanceof URL || value instanceof URLSearchParams || value instanceof Error || isBoxed(value) || isTemporal(value);
|
|
13485
|
+
}
|
|
13486
|
+
/** "a Map", "an Error", ... for an atomic value (see isAtomic), else undefined. */
|
|
13487
|
+
function atomicName(value) {
|
|
13488
|
+
if (!isAtomic(value)) return void 0;
|
|
13489
|
+
const tag = value instanceof Error ? "Error" : toStringTag(value);
|
|
13490
|
+
return `${/^[AEIOU]/.test(tag) ? "an" : "a"} ${tag}`;
|
|
13491
|
+
}
|
|
13492
|
+
/** Whether `key` is an index of an array element. */
|
|
13493
|
+
var isIndexKey = (key) => key !== "4294967295" && String(Number(key) >>> 0) === key;
|
|
13494
|
+
/**
|
|
13495
|
+
* The own enumerable string keys of a collection (an Array, Map or Set) that
|
|
13496
|
+
* are not its elements: what an instance of a subclass may hold besides
|
|
13497
|
+
* them.
|
|
13498
|
+
*/
|
|
13499
|
+
function extraKeys(collection) {
|
|
13500
|
+
const keys = Object.keys(collection);
|
|
13501
|
+
return Array.isArray(collection) ? keys.filter((k) => !isIndexKey(k)) : keys;
|
|
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
|
+
}
|
|
13526
|
+
//#endregion
|
|
13197
13527
|
//#region src/class-registry.ts
|
|
13198
13528
|
var registry = /* @__PURE__ */ new Map();
|
|
13199
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
|
+
*/
|
|
13200
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)`);
|
|
13201
13557
|
registry.set(name, ctor);
|
|
13202
13558
|
ctorToName.set(ctor, name);
|
|
13203
13559
|
}
|
|
@@ -13233,6 +13589,9 @@ var ERROR_HIDDEN_KEYS$1 = [
|
|
|
13233
13589
|
"errors"
|
|
13234
13590
|
];
|
|
13235
13591
|
var isObject = (v) => typeof v === "object" && v !== null;
|
|
13592
|
+
/** Whether `v` is a plain object (as devalue revives one). */
|
|
13593
|
+
var isPlainData = (v) => isObject(v) && Object.getPrototypeOf(v) === Object.prototype;
|
|
13594
|
+
var malformedClass = (name) => /* @__PURE__ */ new TypeError(`spindle: Malformed data for class "${name}"`);
|
|
13236
13595
|
var defineData = (target, key, value) => {
|
|
13237
13596
|
Object.defineProperty(target, key, {
|
|
13238
13597
|
value,
|
|
@@ -13252,15 +13611,69 @@ function refuseSymbolKeys(value) {
|
|
|
13252
13611
|
* Own enumerable keys of `value`, as a plain object; for an error also its
|
|
13253
13612
|
* message, cause and (AggregateError) errors, which are not enumerable.
|
|
13254
13613
|
*/
|
|
13255
|
-
function ownData(value) {
|
|
13614
|
+
function ownData(value, keys = Object.keys(value)) {
|
|
13256
13615
|
refuseSymbolKeys(value);
|
|
13257
13616
|
const data = {};
|
|
13258
13617
|
if (value instanceof Error) {
|
|
13259
13618
|
for (const key of ERROR_HIDDEN_KEYS$1) if (hasOwn(value, key)) defineData(data, key, value[key]);
|
|
13260
13619
|
}
|
|
13261
|
-
for (const key of
|
|
13620
|
+
for (const key of keys) defineData(data, key, value[key]);
|
|
13262
13621
|
return data;
|
|
13263
13622
|
}
|
|
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 = {
|
|
13628
|
+
Array,
|
|
13629
|
+
Map,
|
|
13630
|
+
Set,
|
|
13631
|
+
Date,
|
|
13632
|
+
RegExp
|
|
13633
|
+
};
|
|
13634
|
+
/**
|
|
13635
|
+
* The saved form of a registered class instance: its own data (see
|
|
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).
|
|
13639
|
+
*/
|
|
13640
|
+
function classData(value) {
|
|
13641
|
+
const extra = () => ownData(value, extraKeys(value));
|
|
13642
|
+
if (Array.isArray(value)) {
|
|
13643
|
+
const items = new Array(value.length);
|
|
13644
|
+
for (let i = 0; i < value.length; i++) if (i in value) items[i] = value[i];
|
|
13645
|
+
return [
|
|
13646
|
+
"Array",
|
|
13647
|
+
items,
|
|
13648
|
+
extra()
|
|
13649
|
+
];
|
|
13650
|
+
}
|
|
13651
|
+
if (value instanceof Map) return [
|
|
13652
|
+
"Map",
|
|
13653
|
+
Array.from(mapEntries(value)),
|
|
13654
|
+
extra()
|
|
13655
|
+
];
|
|
13656
|
+
if (value instanceof Set) return [
|
|
13657
|
+
"Set",
|
|
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
|
+
],
|
|
13673
|
+
extra()
|
|
13674
|
+
];
|
|
13675
|
+
return ownData(value);
|
|
13676
|
+
}
|
|
13264
13677
|
/** Make an error's message, cause and errors non-enumerable again. */
|
|
13265
13678
|
function hideErrorKeys(value) {
|
|
13266
13679
|
for (const key of ERROR_HIDDEN_KEYS$1) if (hasOwn(value, key)) Object.defineProperty(value, key, { enumerable: false });
|
|
@@ -13269,7 +13682,7 @@ function hideErrorKeys(value) {
|
|
|
13269
13682
|
var isEscapedOneCharKey = (key) => key.length === 1 && JSON.stringify(key).length > 3;
|
|
13270
13683
|
function reducers() {
|
|
13271
13684
|
const out = {};
|
|
13272
|
-
for (const [name, ctor] of registry) out[CLASS_PREFIX + name] = (v) => isObject(v) && Object.getPrototypeOf(v) === ctor.prototype &&
|
|
13685
|
+
for (const [name, ctor] of registry) out[CLASS_PREFIX + name] = (v) => isObject(v) && Object.getPrototypeOf(v) === ctor.prototype && classData(v);
|
|
13273
13686
|
for (const [proto, name] of BUILTIN_ERRORS) out[ERROR_PREFIX + name] = (v) => isObject(v) && Object.getPrototypeOf(v) === proto && ownData(v);
|
|
13274
13687
|
out[SYMBOL_TAG] = (v) => {
|
|
13275
13688
|
if (typeof v !== "symbol") return false;
|
|
@@ -13282,7 +13695,7 @@ function reducers() {
|
|
|
13282
13695
|
v.lastIndex
|
|
13283
13696
|
];
|
|
13284
13697
|
out[KEYS_TAG] = (v) => {
|
|
13285
|
-
if (!
|
|
13698
|
+
if (!isPlainData(v)) return false;
|
|
13286
13699
|
const keys = Object.keys(v);
|
|
13287
13700
|
if (!keys.some(isEscapedOneCharKey)) return false;
|
|
13288
13701
|
refuseSymbolKeys(v);
|
|
@@ -13291,27 +13704,93 @@ function reducers() {
|
|
|
13291
13704
|
};
|
|
13292
13705
|
return out;
|
|
13293
13706
|
}
|
|
13707
|
+
/**
|
|
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.)
|
|
13731
|
+
*/
|
|
13732
|
+
var collections = /* @__PURE__ */ new WeakMap();
|
|
13733
|
+
function reviveBuiltin(name, ctor, list) {
|
|
13734
|
+
const [kind, contents, keys] = list;
|
|
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);
|
|
13738
|
+
let made = collections.get(list);
|
|
13739
|
+
if (!made) {
|
|
13740
|
+
const value = atomic ? newAtomic(kind, contents) : new base();
|
|
13741
|
+
if (!value) throw malformedClass(name);
|
|
13742
|
+
made = Object.setPrototypeOf(value, ctor.prototype);
|
|
13743
|
+
collections.set(list, made);
|
|
13744
|
+
}
|
|
13745
|
+
if (!atomic && Array.isArray(contents)) fillCollection(made, contents);
|
|
13746
|
+
if (isPlainData(keys)) for (const key of Object.keys(keys)) defineData(made, key, keys[key]);
|
|
13747
|
+
return made;
|
|
13748
|
+
}
|
|
13749
|
+
/** Set the elements of a revived collection, with the built-in methods. */
|
|
13750
|
+
function fillCollection(made, contents) {
|
|
13751
|
+
if (Array.isArray(made)) {
|
|
13752
|
+
made.length = contents.length;
|
|
13753
|
+
for (let i = 0; i < contents.length; i++) if (hasOwn(contents, i)) made[i] = contents[i];
|
|
13754
|
+
else delete made[i];
|
|
13755
|
+
} else if (made instanceof Map) {
|
|
13756
|
+
Map.prototype.clear.call(made);
|
|
13757
|
+
for (const entry of contents) {
|
|
13758
|
+
if (!Array.isArray(entry) || entry.length !== 2) throw new TypeError("spindle: Malformed map entries");
|
|
13759
|
+
Map.prototype.set.call(made, entry[0], entry[1]);
|
|
13760
|
+
}
|
|
13761
|
+
} else {
|
|
13762
|
+
Set.prototype.clear.call(made);
|
|
13763
|
+
for (const member of contents) Set.prototype.add.call(made, member);
|
|
13764
|
+
}
|
|
13765
|
+
}
|
|
13294
13766
|
/** Restore a registered class instance in place, so cycles through it hold. */
|
|
13295
13767
|
function reviveClass(name) {
|
|
13296
13768
|
return (data) => {
|
|
13297
|
-
if (
|
|
13769
|
+
if (Array.isArray(data)) return reviveBuiltin(name, registeredCtor(name), data);
|
|
13770
|
+
if (!isPlainData(data)) {
|
|
13298
13771
|
if (isObject(data) && registeredClassName(data) === name) return data;
|
|
13299
|
-
throw
|
|
13772
|
+
throw malformedClass(name);
|
|
13300
13773
|
}
|
|
13301
|
-
const ctor =
|
|
13302
|
-
if (
|
|
13774
|
+
const ctor = registeredCtor(name);
|
|
13775
|
+
if (Object.values(BUILTIN_KINDS).some((c) => ctor.prototype instanceof c)) throw malformedClass(name);
|
|
13303
13776
|
Object.setPrototypeOf(data, ctor.prototype);
|
|
13304
13777
|
if (data instanceof Error) hideErrorKeys(data);
|
|
13305
13778
|
return data;
|
|
13306
13779
|
};
|
|
13307
13780
|
}
|
|
13781
|
+
/** The class registered as `name`; throws if there is none. */
|
|
13782
|
+
function registeredCtor(name) {
|
|
13783
|
+
const ctor = registry.get(name);
|
|
13784
|
+
if (!ctor) throw new TypeError(`spindle: The save holds an instance of class "${name}", which is not registered`);
|
|
13785
|
+
return ctor;
|
|
13786
|
+
}
|
|
13308
13787
|
/** Restore a built-in error in place, like a class instance. */
|
|
13309
13788
|
function reviveError(name) {
|
|
13310
13789
|
const ctor = ERROR_CTORS.get(name);
|
|
13311
13790
|
if (!ctor) return void 0;
|
|
13312
13791
|
return (data) => {
|
|
13313
13792
|
if (Object.getPrototypeOf(data) === ctor.prototype) return data;
|
|
13314
|
-
if (!
|
|
13793
|
+
if (!isPlainData(data)) throw new TypeError(`spindle: Malformed data for "${name}"`);
|
|
13315
13794
|
Object.setPrototypeOf(data, ctor.prototype);
|
|
13316
13795
|
hideErrorKeys(data);
|
|
13317
13796
|
return data;
|
|
@@ -13355,9 +13834,8 @@ function reviverFor(key) {
|
|
|
13355
13834
|
};
|
|
13356
13835
|
if (key === KEYS_TAG) return reviveKeyed;
|
|
13357
13836
|
if (key === REGEXP_TAG) return (data) => {
|
|
13358
|
-
|
|
13359
|
-
|
|
13360
|
-
re.lastIndex = data[2];
|
|
13837
|
+
const re = newRegExp(data);
|
|
13838
|
+
if (!re) throw new TypeError("spindle: Malformed regular expression");
|
|
13361
13839
|
return re;
|
|
13362
13840
|
};
|
|
13363
13841
|
if (key.startsWith(CLASS_PREFIX)) return reviveClass(key.slice(2));
|
|
@@ -13908,28 +14386,6 @@ function getBackendType() {
|
|
|
13908
14386
|
return _backend?.type ?? "memory";
|
|
13909
14387
|
}
|
|
13910
14388
|
//#endregion
|
|
13911
|
-
//#region src/utils/value-kinds.ts
|
|
13912
|
-
var toStringTag = (value) => Object.prototype.toString.call(value).slice(8, -1);
|
|
13913
|
-
/** Temporal values are immutable: copies may share them. */
|
|
13914
|
-
var isTemporal = (value) => toStringTag(value).startsWith("Temporal.");
|
|
13915
|
-
/** new Number(), new String(), new Boolean(), Object(1n). */
|
|
13916
|
-
var isBoxed = (value) => value instanceof Number || value instanceof String || value instanceof Boolean || toStringTag(value) === "BigInt";
|
|
13917
|
-
/**
|
|
13918
|
-
* Values compared and copied as a whole, by their content: they have no
|
|
13919
|
-
* own keys to merge by, or their keys are not the data (a property written
|
|
13920
|
-
* into one would be dropped by clones and saves, and by Immer for Map and
|
|
13921
|
-
* Set).
|
|
13922
|
-
*/
|
|
13923
|
-
function isAtomic(value) {
|
|
13924
|
-
return value instanceof Date || value instanceof RegExp || value instanceof Map || value instanceof Set || ArrayBuffer.isView(value) || value instanceof ArrayBuffer || value instanceof URL || value instanceof URLSearchParams || value instanceof Error || isBoxed(value) || isTemporal(value);
|
|
13925
|
-
}
|
|
13926
|
-
/** "a Map", "an Error", ... for an atomic value (see isAtomic), else undefined. */
|
|
13927
|
-
function atomicName(value) {
|
|
13928
|
-
if (!isAtomic(value)) return void 0;
|
|
13929
|
-
const tag = value instanceof Error ? "Error" : toStringTag(value);
|
|
13930
|
-
return `${/^[AEIOU]/.test(tag) ? "an" : "a"} ${tag}`;
|
|
13931
|
-
}
|
|
13932
|
-
//#endregion
|
|
13933
14389
|
//#region src/utils/object-path.ts
|
|
13934
14390
|
/**
|
|
13935
14391
|
* Traverse dot-path segments on an object and return the nested value.
|
|
@@ -14058,6 +14514,20 @@ function isPlainObject(value) {
|
|
|
14058
14514
|
const proto = Object.getPrototypeOf(value);
|
|
14059
14515
|
return proto === Object.prototype || proto === null;
|
|
14060
14516
|
}
|
|
14517
|
+
/**
|
|
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
|
|
14522
|
+
* that cycles through it find it.
|
|
14523
|
+
*/
|
|
14524
|
+
function builtinLike(obj, empty, made, value) {
|
|
14525
|
+
made(empty);
|
|
14526
|
+
if (registeredClassName(obj) === void 0) return empty;
|
|
14527
|
+
Object.setPrototypeOf(empty, Object.getPrototypeOf(obj));
|
|
14528
|
+
for (const key of extraKeys(obj)) setOwn(empty, key, value(key));
|
|
14529
|
+
return empty;
|
|
14530
|
+
}
|
|
14061
14531
|
/** Own keys of an error that are not enumerable but are data. */
|
|
14062
14532
|
var ERROR_HIDDEN_KEYS = [
|
|
14063
14533
|
"message",
|
|
@@ -14084,11 +14554,11 @@ function deepClone(value, options = {}) {
|
|
|
14084
14554
|
return copy;
|
|
14085
14555
|
}
|
|
14086
14556
|
function cloneBuiltin(val) {
|
|
14087
|
-
if (val instanceof Date) return
|
|
14557
|
+
if (val instanceof Date) return builtin(val, new Date(Date.prototype.getTime.call(val)));
|
|
14088
14558
|
if (val instanceof RegExp) {
|
|
14089
|
-
const copy = new RegExp(
|
|
14559
|
+
const copy = new RegExp(Reflect.get(RegExp.prototype, "source", val), Reflect.get(RegExp.prototype, "flags", val));
|
|
14090
14560
|
copy.lastIndex = val.lastIndex;
|
|
14091
|
-
return
|
|
14561
|
+
return builtin(val, copy);
|
|
14092
14562
|
}
|
|
14093
14563
|
if (val instanceof ArrayBuffer) return keep(val, val.slice(0));
|
|
14094
14564
|
if (ArrayBuffer.isView(val)) {
|
|
@@ -14119,27 +14589,29 @@ function deepClone(value, options = {}) {
|
|
|
14119
14589
|
const settle = options.settle;
|
|
14120
14590
|
return settle && isObjectValue(copy) && isObjectValue(original) ? settle(copy, original) : copy;
|
|
14121
14591
|
}
|
|
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]));
|
|
14122
14594
|
function clone(val) {
|
|
14123
14595
|
if (val === null || typeof val !== "object") return val;
|
|
14124
14596
|
const obj = val;
|
|
14125
14597
|
if (seen.has(obj)) return seen.get(obj);
|
|
14126
14598
|
if (Array.isArray(val)) {
|
|
14127
|
-
const arr =
|
|
14599
|
+
const arr = builtin(obj, new Array(val.length));
|
|
14128
14600
|
for (let i = 0; i < val.length; i++) if (i in val) arr[i] = clone(val[i]);
|
|
14129
14601
|
return arr;
|
|
14130
14602
|
}
|
|
14131
14603
|
if (val instanceof Map) {
|
|
14132
|
-
const copy =
|
|
14133
|
-
for (const [k, v] of val)
|
|
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));
|
|
14134
14606
|
return copy;
|
|
14135
14607
|
}
|
|
14136
14608
|
if (val instanceof Set) {
|
|
14137
|
-
const copy =
|
|
14138
|
-
for (const v of val)
|
|
14609
|
+
const copy = builtin(obj, /* @__PURE__ */ new Set());
|
|
14610
|
+
for (const v of setMembers(val)) Set.prototype.add.call(copy, settled(clone(v), v));
|
|
14139
14611
|
return copy;
|
|
14140
14612
|
}
|
|
14141
|
-
const
|
|
14142
|
-
if (
|
|
14613
|
+
const copied = cloneBuiltin(obj);
|
|
14614
|
+
if (copied !== void 0) return copied;
|
|
14143
14615
|
const keepsProto = registeredClassName(obj) !== void 0 || isPlainObject(val);
|
|
14144
14616
|
if (!keepsProto && options.keepUnregistered) return val;
|
|
14145
14617
|
return copyKeys(obj, keep(obj, keepsProto ? Object.create(Object.getPrototypeOf(obj)) : {}));
|
|
@@ -14238,23 +14710,26 @@ function shareEqual(prev, curr) {
|
|
|
14238
14710
|
if (placed !== void 0) return placed;
|
|
14239
14711
|
if (!isObjectValue(p)) return fresh(c);
|
|
14240
14712
|
if (reuse(p, c)) return p;
|
|
14713
|
+
const pr = p;
|
|
14714
|
+
const cr = c;
|
|
14715
|
+
/** What the result holds at `key` of `c`. */
|
|
14716
|
+
const shareKey = (key) => share(hasOwn(pr, key) ? pr[key] : void 0, cr[key]);
|
|
14717
|
+
/** `empty`, made the result for the collection `c` (see builtinLike). */
|
|
14718
|
+
const collection = (empty) => builtinLike(c, empty, (out) => done.set(c, out), shareKey);
|
|
14241
14719
|
if (c instanceof Map && p instanceof Map) {
|
|
14242
|
-
const out = /* @__PURE__ */ new Map();
|
|
14243
|
-
|
|
14244
|
-
for (const [k, v] of c) out.set(fresh(k), share(p.get(k), v));
|
|
14720
|
+
const out = collection(/* @__PURE__ */ new Map());
|
|
14721
|
+
for (const [k, v] of mapEntries(c)) Map.prototype.set.call(out, fresh(k), share(mapGet(p, k), v));
|
|
14245
14722
|
return out;
|
|
14246
14723
|
}
|
|
14247
14724
|
if (Array.isArray(c) && Array.isArray(p)) {
|
|
14248
|
-
const out = new Array(c.length);
|
|
14249
|
-
done.set(c, out);
|
|
14725
|
+
const out = collection(new Array(c.length));
|
|
14250
14726
|
for (let i = 0; i < c.length; i++) if (i in c) out[i] = share(p[i], c[i]);
|
|
14251
14727
|
return out;
|
|
14252
14728
|
}
|
|
14253
14729
|
if (mergesWith(p, c, false)) {
|
|
14254
14730
|
const out = Object.create(Object.getPrototypeOf(c));
|
|
14255
14731
|
done.set(c, out);
|
|
14256
|
-
const cr
|
|
14257
|
-
for (const key of Object.keys(cr)) setOwn(out, key, share(hasOwn(p, key) ? p[key] : void 0, cr[key]));
|
|
14732
|
+
for (const key of Object.keys(cr)) setOwn(out, key, shareKey(key));
|
|
14258
14733
|
return out;
|
|
14259
14734
|
}
|
|
14260
14735
|
return fresh(c);
|
|
@@ -14271,8 +14746,14 @@ function equalBytes(a, b) {
|
|
|
14271
14746
|
}
|
|
14272
14747
|
/** Equality of the content of atomic built-ins (see isAtomic) but Map/Set. */
|
|
14273
14748
|
function equalBuiltin(a, b, assumed) {
|
|
14274
|
-
if (a instanceof Date)
|
|
14275
|
-
|
|
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
|
+
}
|
|
14276
14757
|
if (ArrayBuffer.isView(a)) {
|
|
14277
14758
|
const v = b;
|
|
14278
14759
|
return a.byteOffset === v.byteOffset && a.byteLength === v.byteLength && equal(a.buffer, v.buffer, assumed);
|
|
@@ -14283,14 +14764,29 @@ function equalBuiltin(a, b, assumed) {
|
|
|
14283
14764
|
if (isTemporal(a)) return String(a) === String(b);
|
|
14284
14765
|
if (a instanceof Error) return ERROR_HIDDEN_KEYS.every((key) => hasOwn(a, key) === hasOwn(b, key) && equal(a[key], b[key], assumed)) && equalKeys(a, b, assumed);
|
|
14285
14766
|
}
|
|
14286
|
-
function equalKeys(a, b, assumed) {
|
|
14767
|
+
function equalKeys(a, b, assumed, keysOf = Object.keys) {
|
|
14287
14768
|
const ao = a;
|
|
14288
14769
|
const bo = b;
|
|
14289
|
-
const keys =
|
|
14290
|
-
if (keys.length !==
|
|
14770
|
+
const keys = keysOf(ao);
|
|
14771
|
+
if (keys.length !== keysOf(bo).length) return false;
|
|
14291
14772
|
for (const key of keys) if (!hasOwn(bo, key) || !equal(ao[key], bo[key], assumed)) return false;
|
|
14292
14773
|
return true;
|
|
14293
14774
|
}
|
|
14775
|
+
/** Built-in prototypes (see builtinLike), whose instances hold no extra keys. */
|
|
14776
|
+
var BUILTIN_PROTOS = new Set([
|
|
14777
|
+
Array.prototype,
|
|
14778
|
+
Map.prototype,
|
|
14779
|
+
Set.prototype,
|
|
14780
|
+
Date.prototype,
|
|
14781
|
+
RegExp.prototype
|
|
14782
|
+
]);
|
|
14783
|
+
/**
|
|
14784
|
+
* Equality of the extra keys (see extraKeys) of two built-ins of one
|
|
14785
|
+
* class: those of a subclass instance are part of its value.
|
|
14786
|
+
*/
|
|
14787
|
+
function equalExtraKeys(a, b, assumed) {
|
|
14788
|
+
return BUILTIN_PROTOS.has(Object.getPrototypeOf(a)) || equalKeys(a, b, assumed, extraKeys);
|
|
14789
|
+
}
|
|
14294
14790
|
/** `assumed` tracks the pairs of objects met (see Pairs). */
|
|
14295
14791
|
function equal(a, b, assumed) {
|
|
14296
14792
|
if (Object.is(a, b) && !(assumed.strict && isObjectValue(a))) return true;
|
|
@@ -14300,11 +14796,11 @@ function equal(a, b, assumed) {
|
|
|
14300
14796
|
if (met !== void 0) return met;
|
|
14301
14797
|
if (a instanceof Map || a instanceof Set) {
|
|
14302
14798
|
const bc = b;
|
|
14303
|
-
if (a
|
|
14304
|
-
const ai = a
|
|
14305
|
-
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);
|
|
14306
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;
|
|
14307
|
-
return
|
|
14803
|
+
return equalExtraKeys(a, b, assumed);
|
|
14308
14804
|
}
|
|
14309
14805
|
const builtin = equalBuiltin(a, b, assumed);
|
|
14310
14806
|
if (builtin !== void 0) return builtin;
|
|
@@ -14312,7 +14808,7 @@ function equal(a, b, assumed) {
|
|
|
14312
14808
|
const bc = b;
|
|
14313
14809
|
if (a.length !== bc.length) return false;
|
|
14314
14810
|
for (let i = 0; i < a.length; i++) if (i in a !== i in bc || !equal(a[i], bc[i], assumed)) return false;
|
|
14315
|
-
return
|
|
14811
|
+
return equalExtraKeys(a, b, assumed);
|
|
14316
14812
|
}
|
|
14317
14813
|
return equalKeys(a, b, assumed);
|
|
14318
14814
|
}
|
|
@@ -14331,7 +14827,7 @@ function isMergeable(value) {
|
|
|
14331
14827
|
* one class (see isMergeable), or, with `arrays`, both are arrays.
|
|
14332
14828
|
*/
|
|
14333
14829
|
function mergesWith(a, b, arrays) {
|
|
14334
|
-
if (arrays && (Array.isArray(a) || Array.isArray(b))) return Array.isArray(a) && Array.isArray(b);
|
|
14830
|
+
if (arrays && (Array.isArray(a) || Array.isArray(b))) return Array.isArray(a) && Array.isArray(b) && Object.getPrototypeOf(a) === Object.getPrototypeOf(b);
|
|
14335
14831
|
return isMergeable(a) && isMergeable(b) && Object.getPrototypeOf(a) === Object.getPrototypeOf(b);
|
|
14336
14832
|
}
|
|
14337
14833
|
/**
|
|
@@ -14482,13 +14978,13 @@ function entryChildren(value) {
|
|
|
14482
14978
|
const children = [];
|
|
14483
14979
|
if (value instanceof Map) {
|
|
14484
14980
|
let index = 0;
|
|
14485
|
-
for (const [k, v] of value) {
|
|
14981
|
+
for (const [k, v] of mapEntries(value)) {
|
|
14486
14982
|
children.push([entryKey("k", index), k], [entryKey("v", index), v]);
|
|
14487
14983
|
index++;
|
|
14488
14984
|
}
|
|
14489
14985
|
} else if (value instanceof Set) {
|
|
14490
14986
|
let index = 0;
|
|
14491
|
-
for (const member of value) children.push([entryKey("s", index++), member]);
|
|
14987
|
+
for (const member of setMembers(value)) children.push([entryKey("s", index++), member]);
|
|
14492
14988
|
} else if (value instanceof Error) {
|
|
14493
14989
|
for (const key of ["cause", "errors"]) if (hasOwn(value, key)) children.push([entryKey(key === "cause" ? "c" : "e", 0), value[key]]);
|
|
14494
14990
|
} else if (ArrayBuffer.isView(value)) children.push([entryKey("b", 0), value.buffer]);
|
|
@@ -14520,8 +15016,9 @@ function setEntryValue(root, path, value) {
|
|
|
14520
15016
|
const holder = getByEntryPath(root, path.slice(0, -1));
|
|
14521
15017
|
const match = /^\0v(\d+)$/.exec(path[path.length - 1]);
|
|
14522
15018
|
if (!(holder instanceof Map) || !match) return false;
|
|
14523
|
-
const
|
|
14524
|
-
|
|
15019
|
+
const entry = [...mapEntries(holder)][Number(match[1])];
|
|
15020
|
+
if (!entry) return false;
|
|
15021
|
+
mapSet(holder, entry[0], value);
|
|
14525
15022
|
return true;
|
|
14526
15023
|
}
|
|
14527
15024
|
/**
|
|
@@ -14590,7 +15087,8 @@ function aliasMoved(x, y, at, earlier, later) {
|
|
|
14590
15087
|
if (xs && ys) {
|
|
14591
15088
|
if (Object.getPrototypeOf(x) !== Object.getPrototypeOf(y)) return false;
|
|
14592
15089
|
if (x instanceof Map || x instanceof Set) {
|
|
14593
|
-
|
|
15090
|
+
const ySize = collectionSize(y);
|
|
15091
|
+
if (collectionSize(x) !== ySize) return false;
|
|
14594
15092
|
}
|
|
14595
15093
|
const held = new Map(ys);
|
|
14596
15094
|
for (const [segment, a] of xs) if (held.has(segment)) pairs.push([
|
|
@@ -15605,6 +16103,11 @@ function deeplyFrozen(value, seen = /* @__PURE__ */ new Set()) {
|
|
|
15605
16103
|
if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) return true;
|
|
15606
16104
|
if (!Object.isFrozen(value)) return false;
|
|
15607
16105
|
seen.add(value);
|
|
16106
|
+
if (value instanceof Map) {
|
|
16107
|
+
for (const [key, entry] of mapEntries(value)) if (!deeplyFrozen(key, seen) || !deeplyFrozen(entry, seen)) return false;
|
|
16108
|
+
} else if (value instanceof Set) {
|
|
16109
|
+
for (const member of setMembers(value)) if (!deeplyFrozen(member, seen)) return false;
|
|
16110
|
+
}
|
|
15608
16111
|
return Reflect.ownKeys(value).every((key) => {
|
|
15609
16112
|
const desc = Object.getOwnPropertyDescriptor(value, key);
|
|
15610
16113
|
return !desc || !("value" in desc) || deeplyFrozen(desc.value, seen);
|
|
@@ -16149,10 +16652,14 @@ function connectTriggersToStore() {
|
|
|
16149
16652
|
function reinitTriggerState() {
|
|
16150
16653
|
for (const trigger of triggers) trigger.lastResult = evalCondition(trigger.condition);
|
|
16151
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
|
+
*/
|
|
16152
16660
|
function resetTriggers() {
|
|
16153
16661
|
triggers = [];
|
|
16154
|
-
|
|
16155
|
-
dialogHostCallbacks?.closeAll();
|
|
16662
|
+
closeAllOpenDialogs();
|
|
16156
16663
|
}
|
|
16157
16664
|
function subscribeTriggerDialogs(cb) {
|
|
16158
16665
|
dialogNotify = cb;
|
|
@@ -16464,6 +16971,15 @@ function startVariables(defaults) {
|
|
|
16464
16971
|
return initialVars;
|
|
16465
16972
|
}
|
|
16466
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
|
+
/**
|
|
16467
16983
|
* Enter the start passage with `variables`, as the only history moment
|
|
16468
16984
|
* (init, restart). Call it inside a store update.
|
|
16469
16985
|
*/
|
|
@@ -16471,7 +16987,7 @@ function enterStart(state, passage, variables, transientDefaults) {
|
|
|
16471
16987
|
state.currentPassage = passage;
|
|
16472
16988
|
state.navigationId++;
|
|
16473
16989
|
state.variables = variables;
|
|
16474
|
-
state.transient =
|
|
16990
|
+
state.transient = freshTransients(transientDefaults);
|
|
16475
16991
|
state.temporary = createNamespace();
|
|
16476
16992
|
state.history = [{
|
|
16477
16993
|
passage,
|
|
@@ -17230,7 +17746,7 @@ var useStoryStore = create()(storyStore((set, get) => ({
|
|
|
17230
17746
|
state.visitCounts = createCounts(payload.visitCounts);
|
|
17231
17747
|
state.renderCounts = createCounts(payload.renderCounts);
|
|
17232
17748
|
state.temporary = createNamespace();
|
|
17233
|
-
state.transient =
|
|
17749
|
+
state.transient = freshTransients(get().transientDefaults);
|
|
17234
17750
|
});
|
|
17235
17751
|
if (payload.watchers) restoreMacroWatchers(payload.watchers);
|
|
17236
17752
|
reinitTriggerState();
|
|
@@ -17307,15 +17823,34 @@ var FOCUSABLE = [
|
|
|
17307
17823
|
"[tabindex]"
|
|
17308
17824
|
].join(",");
|
|
17309
17825
|
/**
|
|
17826
|
+
* Whether `el` is in a closed `<details>`, other than in the summary that
|
|
17827
|
+
* toggles it: the browser renders none of that content (#389).
|
|
17828
|
+
*/
|
|
17829
|
+
function inClosedDetails(el) {
|
|
17830
|
+
for (let e = el.parentElement; e; e = e.parentElement) {
|
|
17831
|
+
if (e.localName !== "details" || e.hasAttribute("open")) continue;
|
|
17832
|
+
if (!Array.from(e.children).find((c) => c.localName === "summary")?.contains(el)) return true;
|
|
17833
|
+
}
|
|
17834
|
+
return false;
|
|
17835
|
+
}
|
|
17836
|
+
/**
|
|
17310
17837
|
* Whether CSS leaves `el` in the tab sequence: not `visibility: hidden`
|
|
17311
|
-
* (inherited, so the computed value covers ancestors)
|
|
17312
|
-
* `display: none` element
|
|
17838
|
+
* (inherited, so the computed value covers ancestors), not inside a
|
|
17839
|
+
* `display: none` element and not in the hidden content of a closed
|
|
17840
|
+
* `<details>`.
|
|
17313
17841
|
*/
|
|
17314
17842
|
function isRendered(el) {
|
|
17315
17843
|
const { visibility } = getComputedStyle(el);
|
|
17316
17844
|
if (visibility === "hidden" || visibility === "collapse") return false;
|
|
17317
17845
|
for (let e = el; e; e = e.parentElement) if (getComputedStyle(e).display === "none") return false;
|
|
17318
|
-
return
|
|
17846
|
+
return !inClosedDetails(el);
|
|
17847
|
+
}
|
|
17848
|
+
/**
|
|
17849
|
+
* Whether `el` can be focused at all: shown, rendered, enabled (also by its
|
|
17850
|
+
* fieldset) and not inert.
|
|
17851
|
+
*/
|
|
17852
|
+
function isAvailable(el) {
|
|
17853
|
+
return !el.hidden && !el.closest("[hidden], [inert]") && !el.matches(":disabled") && isRendered(el);
|
|
17319
17854
|
}
|
|
17320
17855
|
/** The `tabindex` of `el` as an integer, or null when absent or invalid. */
|
|
17321
17856
|
function tabIndexAttr(el) {
|
|
@@ -17324,9 +17859,10 @@ function tabIndexAttr(el) {
|
|
|
17324
17859
|
return parseInt(raw, 10);
|
|
17325
17860
|
}
|
|
17326
17861
|
/**
|
|
17327
|
-
* Whether the tab key can reach `el
|
|
17328
|
-
* scripted focus, and of a
|
|
17329
|
-
* member only (the first one
|
|
17862
|
+
* Whether the tab key can reach `el`, an available element (see
|
|
17863
|
+
* isAvailable): a negative tabindex only allows scripted focus, and of a
|
|
17864
|
+
* radio group the browser tabs to the checked member only (the first one
|
|
17865
|
+
* when none is checked), of the members it can reach.
|
|
17330
17866
|
*/
|
|
17331
17867
|
function isTabStop(el) {
|
|
17332
17868
|
const tabIndex = tabIndexAttr(el);
|
|
@@ -17337,7 +17873,7 @@ function isTabStop(el) {
|
|
|
17337
17873
|
if (details?.localName !== "details" || Array.from(details.children).find((c) => c.localName === "summary") !== el) return tabIndex !== null;
|
|
17338
17874
|
}
|
|
17339
17875
|
if (el instanceof HTMLInputElement && el.type === "radio" && el.name) {
|
|
17340
|
-
const group = Array.from((el.form ?? el.getRootNode()).querySelectorAll("input[type=\"radio\"]")).filter((r) => r.name === el.name && r.form === el.form &&
|
|
17876
|
+
const group = Array.from((el.form ?? el.getRootNode()).querySelectorAll("input[type=\"radio\"]")).filter((r) => r.name === el.name && r.form === el.form && (tabIndexAttr(r) ?? 0) >= 0 && isAvailable(r));
|
|
17341
17877
|
return el === (group.find((r) => r.checked) ?? group[0]);
|
|
17342
17878
|
}
|
|
17343
17879
|
return true;
|
|
@@ -17347,7 +17883,7 @@ function isTabStop(el) {
|
|
|
17347
17883
|
* first, ascending, then the others in document order.
|
|
17348
17884
|
*/
|
|
17349
17885
|
function focusables(root) {
|
|
17350
|
-
const stops = Array.from(root.querySelectorAll(FOCUSABLE)).filter((el) =>
|
|
17886
|
+
const stops = Array.from(root.querySelectorAll(FOCUSABLE)).filter((el) => isAvailable(el) && isTabStop(el));
|
|
17351
17887
|
const positive = (el) => Math.max(tabIndexAttr(el) ?? 0, 0);
|
|
17352
17888
|
return [...stops.filter((el) => positive(el) > 0).sort((a, b) => positive(a) - positive(b)), ...stops.filter((el) => positive(el) === 0)];
|
|
17353
17889
|
}
|
|
@@ -17440,6 +17976,7 @@ function PassageDialog({ passageName, fallbackMarkup, panelClass, onClose, dismi
|
|
|
17440
17976
|
}
|
|
17441
17977
|
}, [markup, nobr]);
|
|
17442
17978
|
const panelRef = useRef(null);
|
|
17979
|
+
const viewScope = useViewScope();
|
|
17443
17980
|
useModalFocus(panelRef, ".dialog-body", dismissible, stableOnClose);
|
|
17444
17981
|
useLayoutEffect(() => registerOpenDialog(stableOnClose), [stableOnClose]);
|
|
17445
17982
|
useLayoutEffect(() => {
|
|
@@ -17469,7 +18006,10 @@ function PassageDialog({ passageName, fallbackMarkup, panelClass, onClose, dismi
|
|
|
17469
18006
|
children: "✕"
|
|
17470
18007
|
}), /* @__PURE__ */ jsx("div", {
|
|
17471
18008
|
class: "dialog-body",
|
|
17472
|
-
children:
|
|
18009
|
+
children: /* @__PURE__ */ jsx(ViewScopeContext.Provider, {
|
|
18010
|
+
value: viewScope,
|
|
18011
|
+
children: content
|
|
18012
|
+
})
|
|
17473
18013
|
})]
|
|
17474
18014
|
})
|
|
17475
18015
|
})
|
|
@@ -19518,13 +20058,13 @@ function keyOf(val, ancestors) {
|
|
|
19518
20058
|
const obj = val;
|
|
19519
20059
|
const depth = ancestors.indexOf(obj);
|
|
19520
20060
|
if (depth !== -1) return `<cycle ${ancestors.length - depth}>`;
|
|
19521
|
-
if (val instanceof Date) return `Date(${
|
|
19522
|
-
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})`;
|
|
19523
20063
|
ancestors.push(obj);
|
|
19524
20064
|
try {
|
|
19525
20065
|
if (Array.isArray(val)) return `[${Array.from(val, (v) => keyOf(v, ancestors)).join(",")}]`;
|
|
19526
|
-
if (val instanceof Map) return `Map[${[...val].map(([k, v]) => `[${keyOf(k, ancestors)},${keyOf(v, ancestors)}]`).join(",")}]`;
|
|
19527
|
-
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(",")}]`;
|
|
19528
20068
|
const record = obj;
|
|
19529
20069
|
const body = Object.keys(record).map((k) => `${JSON.stringify(k)}:${keyOf(record[k], ancestors)}`).join(",");
|
|
19530
20070
|
const className = registeredClassName(obj);
|
|
@@ -20916,6 +21456,7 @@ defineMacro({
|
|
|
20916
21456
|
render(_props, ctx) {
|
|
20917
21457
|
const radioValue = ctx.args.value ?? "";
|
|
20918
21458
|
const label = ctx.args.label ?? "";
|
|
21459
|
+
const view = ctx.hooks.useContext(ViewScopeContext);
|
|
20919
21460
|
useVariableAction(ctx, {
|
|
20920
21461
|
type: "radiobutton",
|
|
20921
21462
|
key: `$${ctx.varName}:${radioValue}`,
|
|
@@ -20927,7 +21468,7 @@ defineMacro({
|
|
|
20927
21468
|
class: ctx.cls,
|
|
20928
21469
|
children: [/* @__PURE__ */ jsx("input", {
|
|
20929
21470
|
type: "radio",
|
|
20930
|
-
name: `radio-${ctx.varName}`,
|
|
21471
|
+
name: view ? `radio-${view}-${ctx.varName}` : `radio-${ctx.varName}`,
|
|
20931
21472
|
checked: ctx.value === radioValue,
|
|
20932
21473
|
onChange: () => ctx.setValue(radioValue)
|
|
20933
21474
|
}), label ? ` ${label}` : null]
|
|
@@ -21086,27 +21627,31 @@ function Passage({ passage, dataTransition, navigationId }) {
|
|
|
21086
21627
|
if (elRef.current) emitFromRender("passagerender", passage.name, elRef.current);
|
|
21087
21628
|
}, [passage.name, navigationId]);
|
|
21088
21629
|
const nobr = passage.tags.includes("nobr");
|
|
21089
|
-
const
|
|
21090
|
-
|
|
21091
|
-
|
|
21092
|
-
"
|
|
21093
|
-
|
|
21094
|
-
|
|
21095
|
-
|
|
21096
|
-
|
|
21097
|
-
|
|
21098
|
-
|
|
21099
|
-
|
|
21100
|
-
|
|
21101
|
-
|
|
21102
|
-
|
|
21103
|
-
|
|
21104
|
-
|
|
21105
|
-
|
|
21106
|
-
|
|
21107
|
-
|
|
21108
|
-
|
|
21109
|
-
|
|
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
|
+
})
|
|
21110
21655
|
});
|
|
21111
21656
|
return nobr ? /* @__PURE__ */ jsx(NobrContext.Provider, {
|
|
21112
21657
|
value: true,
|