@rohal12/spindle 0.61.1 → 0.61.3
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 +570 -331
- package/dist/pkg/story-variables.js +449 -216
- package/package.json +2 -2
- package/src/format/format-passage.ts +26 -3
- package/src/format/{fenced-code.ts → markdown-lines.ts} +6 -4
- package/src/js-lexer.ts +2 -0
- package/src/markup/spindle.peggy +6 -0
- package/src/observe/observable-text.ts +19 -7
- package/src/observe/observe.ts +30 -5
- package/src/story-context-passage.ts +2 -1
- package/src/utils/element-visibility.ts +15 -10
- package/types/headless.d.ts +1 -1
- package/types/index.d.ts +13 -2
- package/types/play.d.ts +2 -2
package/dist/pkg/headless.js
CHANGED
|
@@ -61,19 +61,19 @@ var NOT_TEXT = /* @__PURE__ */ new Set([
|
|
|
61
61
|
"NOSCRIPT"
|
|
62
62
|
]);
|
|
63
63
|
/**
|
|
64
|
-
* Whether the
|
|
65
|
-
*
|
|
66
|
-
* `display: none` and `aria-hidden="true"`.
|
|
64
|
+
* Whether the element hides its whole subtree, including stylesheet rules.
|
|
65
|
+
* This needs computed styles but no layout, so it also works headlessly.
|
|
67
66
|
*/
|
|
68
67
|
function isHidden(el) {
|
|
69
|
-
return el.hasAttribute("hidden") || el.getAttribute("aria-hidden") === "true" || /(^|;)\s*display\s*:\s*none\b/i.test(el.getAttribute("style") ?? "") || NOT_TEXT.has(el.tagName) || el.parentElement?.tagName === "DETAILS" && !el.parentElement.hasAttribute("open") && el !== Array.from(el.parentElement.children).find((c) => c.tagName === "SUMMARY");
|
|
68
|
+
return el.hasAttribute("hidden") || el.getAttribute("aria-hidden") === "true" || /(^|;)\s*display\s*:\s*none\b/i.test(el.getAttribute("style") ?? "") || el.ownerDocument.defaultView?.getComputedStyle(el).display === "none" || NOT_TEXT.has(el.tagName) || el.parentElement?.tagName === "DETAILS" && !el.parentElement.hasAttribute("open") && el !== Array.from(el.parentElement.children).find((c) => c.tagName === "SUMMARY");
|
|
70
69
|
}
|
|
71
70
|
/**
|
|
72
71
|
* Whether `el` is in a closed `<details>`, other than in the summary that
|
|
73
72
|
* toggles it: the browser renders none of that content (#389).
|
|
74
73
|
*/
|
|
75
|
-
function inClosedDetails(el) {
|
|
76
|
-
|
|
74
|
+
function inClosedDetails(el, root) {
|
|
75
|
+
const stop = root?.parentElement;
|
|
76
|
+
for (let e = el.parentElement; e && e !== stop; e = e.parentElement) {
|
|
77
77
|
if (e.localName !== "details" || e.hasAttribute("open")) continue;
|
|
78
78
|
if (!Array.from(e.children).find((c) => c.localName === "summary")?.contains(el)) return true;
|
|
79
79
|
}
|
|
@@ -83,13 +83,18 @@ function inClosedDetails(el) {
|
|
|
83
83
|
* Whether CSS leaves `el` in the tab sequence: not `visibility: hidden`
|
|
84
84
|
* (inherited, so the computed value covers ancestors), not inside a
|
|
85
85
|
* `display: none` element and not in the hidden content of a closed
|
|
86
|
-
* `<details>`.
|
|
86
|
+
* `<details>`. An optional root bounds ancestor checks, so observations can
|
|
87
|
+
* read StoryContext inside its deliberately hidden host.
|
|
87
88
|
*/
|
|
88
|
-
function isRendered(el) {
|
|
89
|
-
const
|
|
89
|
+
function isRendered(el, root) {
|
|
90
|
+
const style = (e) => e.ownerDocument.defaultView?.getComputedStyle(e);
|
|
91
|
+
const visibility = style(el)?.visibility;
|
|
90
92
|
if (visibility === "hidden" || visibility === "collapse") return false;
|
|
91
|
-
for (let e = el; e; e = e.parentElement)
|
|
92
|
-
|
|
93
|
+
for (let e = el; e; e = e.parentElement) {
|
|
94
|
+
if (style(e)?.display === "none") return false;
|
|
95
|
+
if (e === root) break;
|
|
96
|
+
}
|
|
97
|
+
return !inClosedDetails(el, root);
|
|
93
98
|
}
|
|
94
99
|
/** Visibility shared by reader observations and native control handling. */
|
|
95
100
|
function isReaderVisible(el) {
|
|
@@ -793,10 +798,11 @@ function peg$parse(input, options) {
|
|
|
793
798
|
const peg$c11 = "}";
|
|
794
799
|
const peg$c12 = "/";
|
|
795
800
|
const peg$c13 = "@";
|
|
796
|
-
const peg$c14 = "
|
|
797
|
-
const peg$c15 = "
|
|
798
|
-
const peg$c16 = "
|
|
799
|
-
const peg$c17 = "
|
|
801
|
+
const peg$c14 = ":";
|
|
802
|
+
const peg$c15 = "</";
|
|
803
|
+
const peg$c16 = "=";
|
|
804
|
+
const peg$c17 = "\"";
|
|
805
|
+
const peg$c18 = "'";
|
|
800
806
|
const peg$r0 = /^[^\\{[<]/;
|
|
801
807
|
const peg$r1 = /^[{}]/;
|
|
802
808
|
const peg$r2 = /^[$_@%(!\/a-zA-Z]/;
|
|
@@ -809,14 +815,16 @@ function peg$parse(input, options) {
|
|
|
809
815
|
const peg$r9 = /^[^ \t\n\r\v\f\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF}]/;
|
|
810
816
|
const peg$r10 = /^[a-zA-Z0-9.!#$%&'*+\/=?\^_`|~\-]/;
|
|
811
817
|
const peg$r11 = /^[a-zA-Z0-9.\-]/;
|
|
812
|
-
const peg$r12 = /^[
|
|
813
|
-
const peg$r13 = /^[
|
|
814
|
-
const peg$r14 = /^[\t-\r
|
|
815
|
-
const peg$r15 = /^[
|
|
816
|
-
const peg$r16 = /^[
|
|
817
|
-
const peg$r17 = /^["
|
|
818
|
-
const peg$r18 = /^[^
|
|
819
|
-
const peg$r19 = /^[
|
|
818
|
+
const peg$r12 = /^[a-zA-Z0-9+.\-]/;
|
|
819
|
+
const peg$r13 = /^[^\0- \x7F<>{}]/;
|
|
820
|
+
const peg$r14 = /^[\t-\r \/>\xA0\u1680\u2000-\u200A\u2028-\u2029\u202F\u205F\u3000\uFEFF]/;
|
|
821
|
+
const peg$r15 = /^[a-zA-Z0-9\-]/;
|
|
822
|
+
const peg$r16 = /^[\t-\r "'\/<->{}\xA0\u1680\u2000-\u200A\u2028-\u2029\u202F\u205F\u3000\uFEFF]/;
|
|
823
|
+
const peg$r17 = /^[^"]/;
|
|
824
|
+
const peg$r18 = /^[^']/;
|
|
825
|
+
const peg$r19 = /^["']/;
|
|
826
|
+
const peg$r20 = /^[^ \t\n\r\v\f\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF>]/;
|
|
827
|
+
const peg$r21 = /^[ \t\n\r\v\f\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/;
|
|
820
828
|
const peg$e0 = peg$anyExpectation();
|
|
821
829
|
const peg$e1 = peg$classExpectation([
|
|
822
830
|
"\\",
|
|
@@ -929,6 +937,23 @@ function peg$parse(input, options) {
|
|
|
929
937
|
"-"
|
|
930
938
|
], false, false, false);
|
|
931
939
|
const peg$e27 = peg$classExpectation([
|
|
940
|
+
["a", "z"],
|
|
941
|
+
["A", "Z"],
|
|
942
|
+
["0", "9"],
|
|
943
|
+
"+",
|
|
944
|
+
".",
|
|
945
|
+
"-"
|
|
946
|
+
], false, false, false);
|
|
947
|
+
const peg$e28 = peg$literalExpectation(":", false);
|
|
948
|
+
const peg$e29 = peg$classExpectation([
|
|
949
|
+
["\0", " "],
|
|
950
|
+
"",
|
|
951
|
+
"<",
|
|
952
|
+
">",
|
|
953
|
+
"{",
|
|
954
|
+
"}"
|
|
955
|
+
], true, false, false);
|
|
956
|
+
const peg$e30 = peg$classExpectation([
|
|
932
957
|
[" ", "\r"],
|
|
933
958
|
" ",
|
|
934
959
|
"/",
|
|
@@ -942,14 +967,14 @@ function peg$parse(input, options) {
|
|
|
942
967
|
" ",
|
|
943
968
|
""
|
|
944
969
|
], false, false, false);
|
|
945
|
-
const peg$
|
|
946
|
-
const peg$
|
|
970
|
+
const peg$e31 = peg$literalExpectation("</", false);
|
|
971
|
+
const peg$e32 = peg$classExpectation([
|
|
947
972
|
["a", "z"],
|
|
948
973
|
["A", "Z"],
|
|
949
974
|
["0", "9"],
|
|
950
975
|
"-"
|
|
951
976
|
], false, false, false);
|
|
952
|
-
const peg$
|
|
977
|
+
const peg$e33 = peg$classExpectation([
|
|
953
978
|
[" ", "\r"],
|
|
954
979
|
" ",
|
|
955
980
|
"\"",
|
|
@@ -967,13 +992,13 @@ function peg$parse(input, options) {
|
|
|
967
992
|
" ",
|
|
968
993
|
""
|
|
969
994
|
], false, false, false);
|
|
970
|
-
const peg$
|
|
971
|
-
const peg$
|
|
972
|
-
const peg$
|
|
973
|
-
const peg$
|
|
974
|
-
const peg$
|
|
975
|
-
const peg$
|
|
976
|
-
const peg$
|
|
995
|
+
const peg$e34 = peg$literalExpectation("=", false);
|
|
996
|
+
const peg$e35 = peg$literalExpectation("\"", false);
|
|
997
|
+
const peg$e36 = peg$classExpectation(["\""], true, false, false);
|
|
998
|
+
const peg$e37 = peg$literalExpectation("'", false);
|
|
999
|
+
const peg$e38 = peg$classExpectation(["'"], true, false, false);
|
|
1000
|
+
const peg$e39 = peg$classExpectation(["\"", "'"], false, false, false);
|
|
1001
|
+
const peg$e40 = peg$classExpectation([
|
|
977
1002
|
" ",
|
|
978
1003
|
" ",
|
|
979
1004
|
"\n",
|
|
@@ -991,7 +1016,7 @@ function peg$parse(input, options) {
|
|
|
991
1016
|
"",
|
|
992
1017
|
">"
|
|
993
1018
|
], true, false, false);
|
|
994
|
-
const peg$
|
|
1019
|
+
const peg$e41 = peg$classExpectation([
|
|
995
1020
|
" ",
|
|
996
1021
|
" ",
|
|
997
1022
|
"\n",
|
|
@@ -1014,68 +1039,71 @@ function peg$parse(input, options) {
|
|
|
1014
1039
|
function peg$f1() {
|
|
1015
1040
|
return !textMode;
|
|
1016
1041
|
}
|
|
1017
|
-
function peg$f2(
|
|
1042
|
+
function peg$f2() {
|
|
1043
|
+
return !textMode;
|
|
1044
|
+
}
|
|
1045
|
+
function peg$f3(tag) {
|
|
1018
1046
|
return tag;
|
|
1019
1047
|
}
|
|
1020
|
-
function peg$
|
|
1048
|
+
function peg$f4() {
|
|
1021
1049
|
return !textMode;
|
|
1022
1050
|
}
|
|
1023
|
-
function peg$
|
|
1051
|
+
function peg$f5(tag) {
|
|
1024
1052
|
return VOID_TAGS.has(tag.lower) ? null : tag;
|
|
1025
1053
|
}
|
|
1026
|
-
function peg$
|
|
1054
|
+
function peg$f6(tag) {
|
|
1027
1055
|
rawName = tag.lower;
|
|
1028
1056
|
return tag.kind === "open" && hooks.isRaw(rawName);
|
|
1029
1057
|
}
|
|
1030
|
-
function peg$
|
|
1058
|
+
function peg$f7(tag, b) {
|
|
1031
1059
|
return b;
|
|
1032
1060
|
}
|
|
1033
|
-
function peg$
|
|
1061
|
+
function peg$f8(tag, body) {
|
|
1034
1062
|
return body ? [tag, body] : tag;
|
|
1035
1063
|
}
|
|
1036
|
-
function peg$
|
|
1064
|
+
function peg$f9(tag) {
|
|
1037
1065
|
return tag.kind === "close";
|
|
1038
1066
|
}
|
|
1039
|
-
function peg$
|
|
1067
|
+
function peg$f10(tag) {
|
|
1040
1068
|
return tag;
|
|
1041
1069
|
}
|
|
1042
|
-
function peg$
|
|
1070
|
+
function peg$f11() {
|
|
1043
1071
|
return !textMode;
|
|
1044
1072
|
}
|
|
1045
|
-
function peg$
|
|
1073
|
+
function peg$f12(tag) {
|
|
1046
1074
|
return tag;
|
|
1047
1075
|
}
|
|
1048
|
-
function peg$
|
|
1076
|
+
function peg$f13(start) {
|
|
1049
1077
|
return skipTo(hooks.rawBodyEnd(input, start, rawName));
|
|
1050
1078
|
}
|
|
1051
|
-
function peg$
|
|
1079
|
+
function peg$f14(start) {
|
|
1052
1080
|
return skipEnd - offset();
|
|
1053
1081
|
}
|
|
1054
|
-
function peg$
|
|
1082
|
+
function peg$f15(start, body, end) {
|
|
1055
1083
|
const loc = {
|
|
1056
1084
|
start: { offset: start },
|
|
1057
1085
|
end: { offset: start + body.length }
|
|
1058
1086
|
};
|
|
1059
1087
|
return [body ? lexeme("text", loc, { value: body }) : null, end];
|
|
1060
1088
|
}
|
|
1061
|
-
function peg$
|
|
1089
|
+
function peg$f16() {
|
|
1062
1090
|
return offset();
|
|
1063
1091
|
}
|
|
1064
|
-
function peg$
|
|
1092
|
+
function peg$f17(value) {
|
|
1065
1093
|
return lexeme("text", location(), { value });
|
|
1066
1094
|
}
|
|
1067
|
-
function peg$
|
|
1095
|
+
function peg$f18(value) {
|
|
1068
1096
|
const node = lexeme("text", location(), { value });
|
|
1069
1097
|
node.comment = true;
|
|
1070
1098
|
return node;
|
|
1071
1099
|
}
|
|
1072
|
-
function peg$
|
|
1100
|
+
function peg$f19(bs) {
|
|
1073
1101
|
return bs.length % 2 === 1;
|
|
1074
1102
|
}
|
|
1075
|
-
function peg$
|
|
1103
|
+
function peg$f20(bs, c) {
|
|
1076
1104
|
return c;
|
|
1077
1105
|
}
|
|
1078
|
-
function peg$
|
|
1106
|
+
function peg$f21(bs, brace) {
|
|
1079
1107
|
const loc = location();
|
|
1080
1108
|
const next = input.charAt(loc.end.offset);
|
|
1081
1109
|
if (textMode) {
|
|
@@ -1092,48 +1120,48 @@ function peg$parse(input, options) {
|
|
|
1092
1120
|
escaped.escape = true;
|
|
1093
1121
|
return bs.length > 1 ? [before, escaped] : escaped;
|
|
1094
1122
|
}
|
|
1095
|
-
function peg$
|
|
1123
|
+
function peg$f22() {
|
|
1096
1124
|
return lexeme("text", location(), { value: LB });
|
|
1097
1125
|
}
|
|
1098
|
-
function peg$
|
|
1126
|
+
function peg$f23() {
|
|
1099
1127
|
return !textMode;
|
|
1100
1128
|
}
|
|
1101
|
-
function peg$
|
|
1129
|
+
function peg$f24() {
|
|
1102
1130
|
return lexeme("text", location(), { value: "<" });
|
|
1103
1131
|
}
|
|
1104
|
-
function peg$
|
|
1132
|
+
function peg$f25() {
|
|
1105
1133
|
return lexeme("text", location(), { value: "[" });
|
|
1106
1134
|
}
|
|
1107
|
-
function peg$
|
|
1135
|
+
function peg$f26() {
|
|
1108
1136
|
return !textMode;
|
|
1109
1137
|
}
|
|
1110
|
-
function peg$
|
|
1138
|
+
function peg$f27(ss, s, at, inner) {
|
|
1111
1139
|
const link = lexeme("link", location(), parseLink(inner, at, (separator) => linkSeparatorIndex(inner, at, separator)));
|
|
1112
1140
|
link.selectorSpan = selectorSpan(s, ss, at);
|
|
1113
1141
|
return withSelectors(link, s);
|
|
1114
1142
|
}
|
|
1115
|
-
function peg$
|
|
1143
|
+
function peg$f28() {
|
|
1116
1144
|
return !textMode;
|
|
1117
1145
|
}
|
|
1118
|
-
function peg$
|
|
1146
|
+
function peg$f29() {
|
|
1119
1147
|
fail("Unclosed link: [[ without ]]", location(), "unclosed-link");
|
|
1120
1148
|
}
|
|
1121
|
-
function peg$
|
|
1149
|
+
function peg$f30(parts) {
|
|
1122
1150
|
return selectorsOf(parts);
|
|
1123
1151
|
}
|
|
1124
|
-
function peg$
|
|
1152
|
+
function peg$f31() {
|
|
1125
1153
|
return NO_SELECTORS;
|
|
1126
1154
|
}
|
|
1127
|
-
function peg$
|
|
1155
|
+
function peg$f32(s, end) {
|
|
1128
1156
|
return {
|
|
1129
1157
|
...s,
|
|
1130
1158
|
end
|
|
1131
1159
|
};
|
|
1132
1160
|
}
|
|
1133
|
-
function peg$
|
|
1161
|
+
function peg$f33(prefix, name) {
|
|
1134
1162
|
return [prefix, name];
|
|
1135
1163
|
}
|
|
1136
|
-
function peg$
|
|
1164
|
+
function peg$f34(ss, s, sigil, nameStart, name) {
|
|
1137
1165
|
const variable = lexeme("variable", location(), {
|
|
1138
1166
|
name,
|
|
1139
1167
|
nameStart,
|
|
@@ -1143,7 +1171,7 @@ function peg$parse(input, options) {
|
|
|
1143
1171
|
variable.selectorSpan = selectorSpan(s, ss, nameStart - 1);
|
|
1144
1172
|
return withSelectors(variable, s);
|
|
1145
1173
|
}
|
|
1146
|
-
function peg$
|
|
1174
|
+
function peg$f35(ss, s, after, expression) {
|
|
1147
1175
|
const node = lexeme("expression", location(), {
|
|
1148
1176
|
expression,
|
|
1149
1177
|
expressionStart: after,
|
|
@@ -1152,28 +1180,28 @@ function peg$parse(input, options) {
|
|
|
1152
1180
|
node.selectorSpan = selectorSpan(s, ss, after);
|
|
1153
1181
|
return withSelectors(node, s);
|
|
1154
1182
|
}
|
|
1155
|
-
function peg$
|
|
1183
|
+
function peg$f36() {
|
|
1156
1184
|
fail("Unclosed {" + input.substr(location().end.offset, 1) + "…: no } ends it", location(), "unclosed-expression");
|
|
1157
1185
|
}
|
|
1158
|
-
function peg$
|
|
1186
|
+
function peg$f37(start) {
|
|
1159
1187
|
return skipTo(hooks.closeBrace(input, start, start));
|
|
1160
1188
|
}
|
|
1161
|
-
function peg$
|
|
1189
|
+
function peg$f38(start) {
|
|
1162
1190
|
return skipEnd - offset();
|
|
1163
1191
|
}
|
|
1164
|
-
function peg$
|
|
1192
|
+
function peg$f39(start, code) {
|
|
1165
1193
|
return code;
|
|
1166
1194
|
}
|
|
1167
|
-
function peg$
|
|
1195
|
+
function peg$f40(ss, s, start, close, name, nameEnd) {
|
|
1168
1196
|
return skipTo(hooks.closeBrace(input, nameEnd, start));
|
|
1169
1197
|
}
|
|
1170
|
-
function peg$
|
|
1198
|
+
function peg$f41(ss, s, start, close, name, nameEnd) {
|
|
1171
1199
|
return skipEnd - offset();
|
|
1172
1200
|
}
|
|
1173
|
-
function peg$
|
|
1201
|
+
function peg$f42(ss, s, start, close, name, nameEnd, args) {
|
|
1174
1202
|
return args;
|
|
1175
1203
|
}
|
|
1176
|
-
function peg$
|
|
1204
|
+
function peg$f43(ss, s, start, close, name, nameEnd, tail) {
|
|
1177
1205
|
const loc = location();
|
|
1178
1206
|
const lower = name.toLowerCase();
|
|
1179
1207
|
const tag = lexeme("macro", loc, {
|
|
@@ -1199,16 +1227,19 @@ function peg$parse(input, options) {
|
|
|
1199
1227
|
}
|
|
1200
1228
|
return tag;
|
|
1201
1229
|
}
|
|
1202
|
-
function peg$
|
|
1230
|
+
function peg$f44(s) {
|
|
1203
1231
|
fail("A closing tag starts with a letter after {/", location(), "invalid-closer");
|
|
1204
1232
|
}
|
|
1205
|
-
function peg$
|
|
1233
|
+
function peg$f45(value) {
|
|
1206
1234
|
return EMAIL_AUTOLINK.test(value);
|
|
1207
1235
|
}
|
|
1208
|
-
function peg$
|
|
1236
|
+
function peg$f46(value) {
|
|
1237
|
+
return lexeme("text", location(), { value });
|
|
1238
|
+
}
|
|
1239
|
+
function peg$f47(value) {
|
|
1209
1240
|
return lexeme("text", location(), { value });
|
|
1210
1241
|
}
|
|
1211
|
-
function peg$
|
|
1242
|
+
function peg$f48(tagStart, tag, list, slash) {
|
|
1212
1243
|
const lower = tag.toLowerCase();
|
|
1213
1244
|
return lexeme("html", location(), {
|
|
1214
1245
|
tag,
|
|
@@ -1221,7 +1252,7 @@ function peg$parse(input, options) {
|
|
|
1221
1252
|
isSelfClose: !!slash || VOID_TAGS.has(lower)
|
|
1222
1253
|
});
|
|
1223
1254
|
}
|
|
1224
|
-
function peg$
|
|
1255
|
+
function peg$f49(tag, bad) {
|
|
1225
1256
|
const c = input.charAt(bad);
|
|
1226
1257
|
if (!c) fail("Unclosed tag <" + tag + ": no > ends it (write < for a < that starts no tag)", location(), "unclosed-tag");
|
|
1227
1258
|
const at = {
|
|
@@ -1239,7 +1270,7 @@ function peg$parse(input, options) {
|
|
|
1239
1270
|
};
|
|
1240
1271
|
fail("Unexpected " + JSON.stringify(c) + " in the tag <" + tag + ">: expected an attribute, or > to end the tag", at, "unexpected-character");
|
|
1241
1272
|
}
|
|
1242
|
-
function peg$
|
|
1273
|
+
function peg$f50(tagStart, tag) {
|
|
1243
1274
|
return lexeme("html", location(), {
|
|
1244
1275
|
tag,
|
|
1245
1276
|
lower: tag.toLowerCase(),
|
|
@@ -1251,14 +1282,14 @@ function peg$parse(input, options) {
|
|
|
1251
1282
|
isSelfClose: false
|
|
1252
1283
|
});
|
|
1253
1284
|
}
|
|
1254
|
-
function peg$
|
|
1285
|
+
function peg$f51(nameStart, name) {
|
|
1255
1286
|
attrCode = hooks.isCodeAttribute(name);
|
|
1256
1287
|
return true;
|
|
1257
1288
|
}
|
|
1258
|
-
function peg$
|
|
1289
|
+
function peg$f52(nameStart, name, v) {
|
|
1259
1290
|
return v;
|
|
1260
1291
|
}
|
|
1261
|
-
function peg$
|
|
1292
|
+
function peg$f53(nameStart, name, value) {
|
|
1262
1293
|
const attribute = {
|
|
1263
1294
|
name,
|
|
1264
1295
|
value: value ? value.value : "",
|
|
@@ -1272,7 +1303,7 @@ function peg$parse(input, options) {
|
|
|
1272
1303
|
}
|
|
1273
1304
|
return attribute;
|
|
1274
1305
|
}
|
|
1275
|
-
function peg$
|
|
1306
|
+
function peg$f54(start, value, end) {
|
|
1276
1307
|
return {
|
|
1277
1308
|
value,
|
|
1278
1309
|
start,
|
|
@@ -1280,7 +1311,7 @@ function peg$parse(input, options) {
|
|
|
1280
1311
|
quote: "\""
|
|
1281
1312
|
};
|
|
1282
1313
|
}
|
|
1283
|
-
function peg$
|
|
1314
|
+
function peg$f55(start, value, end) {
|
|
1284
1315
|
return {
|
|
1285
1316
|
value,
|
|
1286
1317
|
start,
|
|
@@ -1288,35 +1319,35 @@ function peg$parse(input, options) {
|
|
|
1288
1319
|
quote: "'"
|
|
1289
1320
|
};
|
|
1290
1321
|
}
|
|
1291
|
-
function peg$
|
|
1322
|
+
function peg$f56(q) {
|
|
1292
1323
|
fail("Unclosed attribute value: the " + q + " here has no closing " + q, location(), "unclosed-attribute");
|
|
1293
1324
|
}
|
|
1294
|
-
function peg$
|
|
1325
|
+
function peg$f57(start, value, end) {
|
|
1295
1326
|
return {
|
|
1296
1327
|
value,
|
|
1297
1328
|
start,
|
|
1298
1329
|
end
|
|
1299
1330
|
};
|
|
1300
1331
|
}
|
|
1301
|
-
function peg$
|
|
1332
|
+
function peg$f58() {
|
|
1302
1333
|
return !attrCode;
|
|
1303
1334
|
}
|
|
1304
|
-
function peg$
|
|
1335
|
+
function peg$f59(bs) {
|
|
1305
1336
|
return bs.length % 2 === 1;
|
|
1306
1337
|
}
|
|
1307
|
-
function peg$
|
|
1338
|
+
function peg$f60() {
|
|
1308
1339
|
return !attrCode;
|
|
1309
1340
|
}
|
|
1310
|
-
function peg$
|
|
1341
|
+
function peg$f61(start, nameEnd) {
|
|
1311
1342
|
return skipTo(hooks.closeBrace(input, nameEnd, start));
|
|
1312
1343
|
}
|
|
1313
|
-
function peg$
|
|
1344
|
+
function peg$f62(start, nameEnd) {
|
|
1314
1345
|
return skipEnd - offset();
|
|
1315
1346
|
}
|
|
1316
|
-
function peg$
|
|
1347
|
+
function peg$f63() {
|
|
1317
1348
|
return !attrCode;
|
|
1318
1349
|
}
|
|
1319
|
-
function peg$
|
|
1350
|
+
function peg$f64() {
|
|
1320
1351
|
return attrCode;
|
|
1321
1352
|
}
|
|
1322
1353
|
let peg$currPos = options.peg$currPos | 0;
|
|
@@ -1464,10 +1495,10 @@ function peg$parse(input, options) {
|
|
|
1464
1495
|
if (s1) s1 = void 0;
|
|
1465
1496
|
else s1 = peg$FAILED;
|
|
1466
1497
|
if (s1 !== peg$FAILED) {
|
|
1467
|
-
s2 = peg$
|
|
1498
|
+
s2 = peg$parseUriAutolink();
|
|
1468
1499
|
if (s2 !== peg$FAILED) {
|
|
1469
|
-
|
|
1470
|
-
s0 =
|
|
1500
|
+
s1 = [s1, s2];
|
|
1501
|
+
s0 = s1;
|
|
1471
1502
|
} else {
|
|
1472
1503
|
peg$currPos = s0;
|
|
1473
1504
|
s0 = peg$FAILED;
|
|
@@ -1479,14 +1510,14 @@ function peg$parse(input, options) {
|
|
|
1479
1510
|
if (s0 === peg$FAILED) {
|
|
1480
1511
|
s0 = peg$currPos;
|
|
1481
1512
|
peg$savedPos = peg$currPos;
|
|
1482
|
-
s1 = peg$
|
|
1513
|
+
s1 = peg$f2();
|
|
1483
1514
|
if (s1) s1 = void 0;
|
|
1484
1515
|
else s1 = peg$FAILED;
|
|
1485
1516
|
if (s1 !== peg$FAILED) {
|
|
1486
|
-
s2 = peg$
|
|
1517
|
+
s2 = peg$parseHtmlOpen();
|
|
1487
1518
|
if (s2 !== peg$FAILED) {
|
|
1488
1519
|
peg$savedPos = s0;
|
|
1489
|
-
s0 = peg$
|
|
1520
|
+
s0 = peg$f3(s2);
|
|
1490
1521
|
} else {
|
|
1491
1522
|
peg$currPos = s0;
|
|
1492
1523
|
s0 = peg$FAILED;
|
|
@@ -1496,37 +1527,57 @@ function peg$parse(input, options) {
|
|
|
1496
1527
|
s0 = peg$FAILED;
|
|
1497
1528
|
}
|
|
1498
1529
|
if (s0 === peg$FAILED) {
|
|
1499
|
-
s0 = peg$
|
|
1530
|
+
s0 = peg$currPos;
|
|
1531
|
+
peg$savedPos = peg$currPos;
|
|
1532
|
+
s1 = peg$f4();
|
|
1533
|
+
if (s1) s1 = void 0;
|
|
1534
|
+
else s1 = peg$FAILED;
|
|
1535
|
+
if (s1 !== peg$FAILED) {
|
|
1536
|
+
s2 = peg$parseHtmlClose();
|
|
1537
|
+
if (s2 !== peg$FAILED) {
|
|
1538
|
+
peg$savedPos = s0;
|
|
1539
|
+
s0 = peg$f5(s2);
|
|
1540
|
+
} else {
|
|
1541
|
+
peg$currPos = s0;
|
|
1542
|
+
s0 = peg$FAILED;
|
|
1543
|
+
}
|
|
1544
|
+
} else {
|
|
1545
|
+
peg$currPos = s0;
|
|
1546
|
+
s0 = peg$FAILED;
|
|
1547
|
+
}
|
|
1500
1548
|
if (s0 === peg$FAILED) {
|
|
1501
|
-
s0 = peg$
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
if (
|
|
1512
|
-
|
|
1513
|
-
|
|
1549
|
+
s0 = peg$parseValue();
|
|
1550
|
+
if (s0 === peg$FAILED) {
|
|
1551
|
+
s0 = peg$currPos;
|
|
1552
|
+
s1 = peg$parseMacroTag();
|
|
1553
|
+
if (s1 !== peg$FAILED) {
|
|
1554
|
+
s2 = peg$currPos;
|
|
1555
|
+
peg$savedPos = peg$currPos;
|
|
1556
|
+
s3 = peg$f6(s1);
|
|
1557
|
+
if (s3) s3 = void 0;
|
|
1558
|
+
else s3 = peg$FAILED;
|
|
1559
|
+
if (s3 !== peg$FAILED) {
|
|
1560
|
+
s4 = peg$parseRawTokens();
|
|
1561
|
+
if (s4 !== peg$FAILED) {
|
|
1562
|
+
peg$savedPos = s2;
|
|
1563
|
+
s2 = peg$f7(s1, s4);
|
|
1564
|
+
} else {
|
|
1565
|
+
peg$currPos = s2;
|
|
1566
|
+
s2 = peg$FAILED;
|
|
1567
|
+
}
|
|
1514
1568
|
} else {
|
|
1515
1569
|
peg$currPos = s2;
|
|
1516
1570
|
s2 = peg$FAILED;
|
|
1517
1571
|
}
|
|
1572
|
+
if (s2 === peg$FAILED) s2 = null;
|
|
1573
|
+
peg$savedPos = s0;
|
|
1574
|
+
s0 = peg$f8(s1, s2);
|
|
1518
1575
|
} else {
|
|
1519
|
-
peg$currPos =
|
|
1520
|
-
|
|
1576
|
+
peg$currPos = s0;
|
|
1577
|
+
s0 = peg$FAILED;
|
|
1521
1578
|
}
|
|
1522
|
-
if (
|
|
1523
|
-
peg$savedPos = s0;
|
|
1524
|
-
s0 = peg$f7(s1, s2);
|
|
1525
|
-
} else {
|
|
1526
|
-
peg$currPos = s0;
|
|
1527
|
-
s0 = peg$FAILED;
|
|
1579
|
+
if (s0 === peg$FAILED) s0 = peg$parseLiteral();
|
|
1528
1580
|
}
|
|
1529
|
-
if (s0 === peg$FAILED) s0 = peg$parseLiteral();
|
|
1530
1581
|
}
|
|
1531
1582
|
}
|
|
1532
1583
|
}
|
|
@@ -1543,12 +1594,12 @@ function peg$parse(input, options) {
|
|
|
1543
1594
|
s1 = peg$parseMacroTag();
|
|
1544
1595
|
if (s1 !== peg$FAILED) {
|
|
1545
1596
|
peg$savedPos = peg$currPos;
|
|
1546
|
-
s2 = peg$
|
|
1597
|
+
s2 = peg$f9(s1);
|
|
1547
1598
|
if (s2) s2 = void 0;
|
|
1548
1599
|
else s2 = peg$FAILED;
|
|
1549
1600
|
if (s2 !== peg$FAILED) {
|
|
1550
1601
|
peg$savedPos = s0;
|
|
1551
|
-
s0 = peg$
|
|
1602
|
+
s0 = peg$f10(s1);
|
|
1552
1603
|
} else {
|
|
1553
1604
|
peg$currPos = s0;
|
|
1554
1605
|
s0 = peg$FAILED;
|
|
@@ -1560,14 +1611,14 @@ function peg$parse(input, options) {
|
|
|
1560
1611
|
if (s0 === peg$FAILED) {
|
|
1561
1612
|
s0 = peg$currPos;
|
|
1562
1613
|
peg$savedPos = peg$currPos;
|
|
1563
|
-
s1 = peg$
|
|
1614
|
+
s1 = peg$f11();
|
|
1564
1615
|
if (s1) s1 = void 0;
|
|
1565
1616
|
else s1 = peg$FAILED;
|
|
1566
1617
|
if (s1 !== peg$FAILED) {
|
|
1567
1618
|
s2 = peg$parseHtmlClose();
|
|
1568
1619
|
if (s2 !== peg$FAILED) {
|
|
1569
1620
|
peg$savedPos = s0;
|
|
1570
|
-
s0 = peg$
|
|
1621
|
+
s0 = peg$f12(s2);
|
|
1571
1622
|
} else {
|
|
1572
1623
|
peg$currPos = s0;
|
|
1573
1624
|
s0 = peg$FAILED;
|
|
@@ -1584,12 +1635,12 @@ function peg$parse(input, options) {
|
|
|
1584
1635
|
s0 = peg$currPos;
|
|
1585
1636
|
s1 = peg$parseHere();
|
|
1586
1637
|
peg$savedPos = peg$currPos;
|
|
1587
|
-
s2 = peg$
|
|
1638
|
+
s2 = peg$f13(s1);
|
|
1588
1639
|
if (s2) s2 = void 0;
|
|
1589
1640
|
else s2 = peg$FAILED;
|
|
1590
1641
|
if (s2 !== peg$FAILED) {
|
|
1591
1642
|
s3 = peg$currPos;
|
|
1592
|
-
s4 = peg$
|
|
1643
|
+
s4 = peg$f14(s1);
|
|
1593
1644
|
s5 = peg$currPos;
|
|
1594
1645
|
s6 = [];
|
|
1595
1646
|
if (s6.length >= (s4 | 0)) s7 = peg$FAILED;
|
|
@@ -1622,7 +1673,7 @@ function peg$parse(input, options) {
|
|
|
1622
1673
|
s4 = peg$parseCloseTag();
|
|
1623
1674
|
if (s4 !== peg$FAILED) {
|
|
1624
1675
|
peg$savedPos = s0;
|
|
1625
|
-
s0 = peg$
|
|
1676
|
+
s0 = peg$f15(s1, s3, s4);
|
|
1626
1677
|
} else {
|
|
1627
1678
|
peg$currPos = s0;
|
|
1628
1679
|
s0 = peg$FAILED;
|
|
@@ -1642,7 +1693,7 @@ function peg$parse(input, options) {
|
|
|
1642
1693
|
s0 = peg$currPos;
|
|
1643
1694
|
s1 = "";
|
|
1644
1695
|
peg$savedPos = s0;
|
|
1645
|
-
s1 = peg$
|
|
1696
|
+
s1 = peg$f16();
|
|
1646
1697
|
s0 = s1;
|
|
1647
1698
|
return s0;
|
|
1648
1699
|
}
|
|
@@ -1671,7 +1722,7 @@ function peg$parse(input, options) {
|
|
|
1671
1722
|
else s1 = s2;
|
|
1672
1723
|
if (s1 !== peg$FAILED) {
|
|
1673
1724
|
peg$savedPos = s0;
|
|
1674
|
-
s1 = peg$
|
|
1725
|
+
s1 = peg$f17(s1);
|
|
1675
1726
|
}
|
|
1676
1727
|
s0 = s1;
|
|
1677
1728
|
return s0;
|
|
@@ -1811,7 +1862,7 @@ function peg$parse(input, options) {
|
|
|
1811
1862
|
else s1 = s2;
|
|
1812
1863
|
if (s1 !== peg$FAILED) {
|
|
1813
1864
|
peg$savedPos = s0;
|
|
1814
|
-
s1 = peg$
|
|
1865
|
+
s1 = peg$f18(s1);
|
|
1815
1866
|
}
|
|
1816
1867
|
s0 = s1;
|
|
1817
1868
|
return s0;
|
|
@@ -1844,7 +1895,7 @@ function peg$parse(input, options) {
|
|
|
1844
1895
|
if (s1 !== peg$FAILED) {
|
|
1845
1896
|
s2 = peg$currPos;
|
|
1846
1897
|
peg$savedPos = peg$currPos;
|
|
1847
|
-
s3 = peg$
|
|
1898
|
+
s3 = peg$f19(s1);
|
|
1848
1899
|
if (s3) s3 = void 0;
|
|
1849
1900
|
else s3 = peg$FAILED;
|
|
1850
1901
|
if (s3 !== peg$FAILED) {
|
|
@@ -1856,7 +1907,7 @@ function peg$parse(input, options) {
|
|
|
1856
1907
|
}
|
|
1857
1908
|
if (s4 !== peg$FAILED) {
|
|
1858
1909
|
peg$savedPos = s2;
|
|
1859
|
-
s2 = peg$
|
|
1910
|
+
s2 = peg$f20(s1, s4);
|
|
1860
1911
|
} else {
|
|
1861
1912
|
peg$currPos = s2;
|
|
1862
1913
|
s2 = peg$FAILED;
|
|
@@ -1867,7 +1918,7 @@ function peg$parse(input, options) {
|
|
|
1867
1918
|
}
|
|
1868
1919
|
if (s2 === peg$FAILED) s2 = null;
|
|
1869
1920
|
peg$savedPos = s0;
|
|
1870
|
-
s0 = peg$
|
|
1921
|
+
s0 = peg$f21(s1, s2);
|
|
1871
1922
|
} else {
|
|
1872
1923
|
peg$currPos = s0;
|
|
1873
1924
|
s0 = peg$FAILED;
|
|
@@ -1915,7 +1966,7 @@ function peg$parse(input, options) {
|
|
|
1915
1966
|
}
|
|
1916
1967
|
if (s2 !== peg$FAILED) {
|
|
1917
1968
|
peg$savedPos = s0;
|
|
1918
|
-
s0 = peg$
|
|
1969
|
+
s0 = peg$f22();
|
|
1919
1970
|
} else {
|
|
1920
1971
|
peg$currPos = s0;
|
|
1921
1972
|
s0 = peg$FAILED;
|
|
@@ -1930,7 +1981,7 @@ function peg$parse(input, options) {
|
|
|
1930
1981
|
peg$silentFails++;
|
|
1931
1982
|
s2 = peg$currPos;
|
|
1932
1983
|
peg$savedPos = peg$currPos;
|
|
1933
|
-
s3 = peg$
|
|
1984
|
+
s3 = peg$f23();
|
|
1934
1985
|
if (s3) s3 = void 0;
|
|
1935
1986
|
else s3 = peg$FAILED;
|
|
1936
1987
|
if (s3 !== peg$FAILED) {
|
|
@@ -1962,7 +2013,7 @@ function peg$parse(input, options) {
|
|
|
1962
2013
|
}
|
|
1963
2014
|
if (s2 !== peg$FAILED) {
|
|
1964
2015
|
peg$savedPos = s0;
|
|
1965
|
-
s0 = peg$
|
|
2016
|
+
s0 = peg$f24();
|
|
1966
2017
|
} else {
|
|
1967
2018
|
peg$currPos = s0;
|
|
1968
2019
|
s0 = peg$FAILED;
|
|
@@ -1982,7 +2033,7 @@ function peg$parse(input, options) {
|
|
|
1982
2033
|
}
|
|
1983
2034
|
if (s1 !== peg$FAILED) {
|
|
1984
2035
|
peg$savedPos = s0;
|
|
1985
|
-
s1 = peg$
|
|
2036
|
+
s1 = peg$f25();
|
|
1986
2037
|
}
|
|
1987
2038
|
s0 = s1;
|
|
1988
2039
|
}
|
|
@@ -1993,7 +2044,7 @@ function peg$parse(input, options) {
|
|
|
1993
2044
|
let s0, s1, s2, s3, s4, s5, s6, s7;
|
|
1994
2045
|
s0 = peg$currPos;
|
|
1995
2046
|
peg$savedPos = peg$currPos;
|
|
1996
|
-
s1 = peg$
|
|
2047
|
+
s1 = peg$f26();
|
|
1997
2048
|
if (s1) s1 = void 0;
|
|
1998
2049
|
else s1 = peg$FAILED;
|
|
1999
2050
|
if (s1 !== peg$FAILED) {
|
|
@@ -2021,7 +2072,7 @@ function peg$parse(input, options) {
|
|
|
2021
2072
|
}
|
|
2022
2073
|
if (s7 !== peg$FAILED) {
|
|
2023
2074
|
peg$savedPos = s0;
|
|
2024
|
-
s0 = peg$
|
|
2075
|
+
s0 = peg$f27(s3, s4, s5, s6);
|
|
2025
2076
|
} else {
|
|
2026
2077
|
peg$currPos = s0;
|
|
2027
2078
|
s0 = peg$FAILED;
|
|
@@ -2041,7 +2092,7 @@ function peg$parse(input, options) {
|
|
|
2041
2092
|
if (s0 === peg$FAILED) {
|
|
2042
2093
|
s0 = peg$currPos;
|
|
2043
2094
|
peg$savedPos = peg$currPos;
|
|
2044
|
-
s1 = peg$
|
|
2095
|
+
s1 = peg$f28();
|
|
2045
2096
|
if (s1) s1 = void 0;
|
|
2046
2097
|
else s1 = peg$FAILED;
|
|
2047
2098
|
if (s1 !== peg$FAILED) {
|
|
@@ -2054,7 +2105,7 @@ function peg$parse(input, options) {
|
|
|
2054
2105
|
}
|
|
2055
2106
|
if (s2 !== peg$FAILED) {
|
|
2056
2107
|
peg$savedPos = s0;
|
|
2057
|
-
s0 = peg$
|
|
2108
|
+
s0 = peg$f29();
|
|
2058
2109
|
} else {
|
|
2059
2110
|
peg$currPos = s0;
|
|
2060
2111
|
s0 = peg$FAILED;
|
|
@@ -2182,7 +2233,7 @@ function peg$parse(input, options) {
|
|
|
2182
2233
|
}
|
|
2183
2234
|
if (s2 === peg$FAILED) s2 = null;
|
|
2184
2235
|
peg$savedPos = s0;
|
|
2185
|
-
s0 = peg$
|
|
2236
|
+
s0 = peg$f30(s1);
|
|
2186
2237
|
} else {
|
|
2187
2238
|
peg$currPos = s0;
|
|
2188
2239
|
s0 = peg$FAILED;
|
|
@@ -2191,7 +2242,7 @@ function peg$parse(input, options) {
|
|
|
2191
2242
|
s0 = peg$currPos;
|
|
2192
2243
|
s1 = "";
|
|
2193
2244
|
peg$savedPos = s0;
|
|
2194
|
-
s1 = peg$
|
|
2245
|
+
s1 = peg$f31();
|
|
2195
2246
|
s0 = s1;
|
|
2196
2247
|
}
|
|
2197
2248
|
return s0;
|
|
@@ -2221,7 +2272,7 @@ function peg$parse(input, options) {
|
|
|
2221
2272
|
}
|
|
2222
2273
|
}
|
|
2223
2274
|
peg$savedPos = s0;
|
|
2224
|
-
s0 = peg$
|
|
2275
|
+
s0 = peg$f32(s1, s2);
|
|
2225
2276
|
} else {
|
|
2226
2277
|
peg$currPos = s0;
|
|
2227
2278
|
s0 = peg$FAILED;
|
|
@@ -2247,7 +2298,7 @@ function peg$parse(input, options) {
|
|
|
2247
2298
|
}
|
|
2248
2299
|
s2 = input.substring(s2, peg$currPos);
|
|
2249
2300
|
peg$savedPos = s0;
|
|
2250
|
-
s0 = peg$
|
|
2301
|
+
s0 = peg$f33(s1, s2);
|
|
2251
2302
|
} else {
|
|
2252
2303
|
peg$currPos = s0;
|
|
2253
2304
|
s0 = peg$FAILED;
|
|
@@ -2374,7 +2425,7 @@ function peg$parse(input, options) {
|
|
|
2374
2425
|
}
|
|
2375
2426
|
if (s7 !== peg$FAILED) {
|
|
2376
2427
|
peg$savedPos = s0;
|
|
2377
|
-
s0 = peg$
|
|
2428
|
+
s0 = peg$f34(s2, s3, s4, s5, s6);
|
|
2378
2429
|
} else {
|
|
2379
2430
|
peg$currPos = s0;
|
|
2380
2431
|
s0 = peg$FAILED;
|
|
@@ -2430,7 +2481,7 @@ function peg$parse(input, options) {
|
|
|
2430
2481
|
}
|
|
2431
2482
|
if (s7 !== peg$FAILED) {
|
|
2432
2483
|
peg$savedPos = s0;
|
|
2433
|
-
s0 = peg$
|
|
2484
|
+
s0 = peg$f35(s2, s3, s4, s6);
|
|
2434
2485
|
} else {
|
|
2435
2486
|
peg$currPos = s0;
|
|
2436
2487
|
s0 = peg$FAILED;
|
|
@@ -2478,7 +2529,7 @@ function peg$parse(input, options) {
|
|
|
2478
2529
|
} else s3 = peg$FAILED;
|
|
2479
2530
|
if (s3 !== peg$FAILED) {
|
|
2480
2531
|
peg$savedPos = s0;
|
|
2481
|
-
s0 = peg$
|
|
2532
|
+
s0 = peg$f36();
|
|
2482
2533
|
} else {
|
|
2483
2534
|
peg$currPos = s0;
|
|
2484
2535
|
s0 = peg$FAILED;
|
|
@@ -2500,12 +2551,12 @@ function peg$parse(input, options) {
|
|
|
2500
2551
|
s0 = peg$currPos;
|
|
2501
2552
|
s1 = peg$parseHere();
|
|
2502
2553
|
peg$savedPos = peg$currPos;
|
|
2503
|
-
s2 = peg$
|
|
2554
|
+
s2 = peg$f37(s1);
|
|
2504
2555
|
if (s2) s2 = void 0;
|
|
2505
2556
|
else s2 = peg$FAILED;
|
|
2506
2557
|
if (s2 !== peg$FAILED) {
|
|
2507
2558
|
s3 = peg$currPos;
|
|
2508
|
-
s4 = peg$
|
|
2559
|
+
s4 = peg$f38(s1);
|
|
2509
2560
|
s5 = peg$currPos;
|
|
2510
2561
|
s6 = [];
|
|
2511
2562
|
if (s6.length >= (s4 | 0)) s7 = peg$FAILED;
|
|
@@ -2536,7 +2587,7 @@ function peg$parse(input, options) {
|
|
|
2536
2587
|
else s3 = s4;
|
|
2537
2588
|
if (s3 !== peg$FAILED) {
|
|
2538
2589
|
peg$savedPos = s0;
|
|
2539
|
-
s0 = peg$
|
|
2590
|
+
s0 = peg$f39(s1, s3);
|
|
2540
2591
|
} else {
|
|
2541
2592
|
peg$currPos = s0;
|
|
2542
2593
|
s0 = peg$FAILED;
|
|
@@ -2575,12 +2626,12 @@ function peg$parse(input, options) {
|
|
|
2575
2626
|
s7 = peg$parseHere();
|
|
2576
2627
|
s8 = peg$currPos;
|
|
2577
2628
|
peg$savedPos = peg$currPos;
|
|
2578
|
-
s9 = peg$
|
|
2629
|
+
s9 = peg$f40(s2, s3, s4, s5, s6, s7);
|
|
2579
2630
|
if (s9) s9 = void 0;
|
|
2580
2631
|
else s9 = peg$FAILED;
|
|
2581
2632
|
if (s9 !== peg$FAILED) {
|
|
2582
2633
|
s10 = peg$currPos;
|
|
2583
|
-
s11 = peg$
|
|
2634
|
+
s11 = peg$f41(s2, s3, s4, s5, s6, s7);
|
|
2584
2635
|
s12 = peg$currPos;
|
|
2585
2636
|
s13 = [];
|
|
2586
2637
|
if (s13.length >= (s11 | 0)) s14 = peg$FAILED;
|
|
@@ -2619,7 +2670,7 @@ function peg$parse(input, options) {
|
|
|
2619
2670
|
}
|
|
2620
2671
|
if (s11 !== peg$FAILED) {
|
|
2621
2672
|
peg$savedPos = s8;
|
|
2622
|
-
s8 = peg$
|
|
2673
|
+
s8 = peg$f42(s2, s3, s4, s5, s6, s7, s10);
|
|
2623
2674
|
} else {
|
|
2624
2675
|
peg$currPos = s8;
|
|
2625
2676
|
s8 = peg$FAILED;
|
|
@@ -2634,7 +2685,7 @@ function peg$parse(input, options) {
|
|
|
2634
2685
|
}
|
|
2635
2686
|
if (s8 === peg$FAILED) s8 = null;
|
|
2636
2687
|
peg$savedPos = s0;
|
|
2637
|
-
s0 = peg$
|
|
2688
|
+
s0 = peg$f43(s2, s3, s4, s5, s6, s7, s8);
|
|
2638
2689
|
} else {
|
|
2639
2690
|
peg$currPos = s0;
|
|
2640
2691
|
s0 = peg$FAILED;
|
|
@@ -2668,7 +2719,7 @@ function peg$parse(input, options) {
|
|
|
2668
2719
|
}
|
|
2669
2720
|
if (s3 !== peg$FAILED) {
|
|
2670
2721
|
peg$savedPos = s0;
|
|
2671
|
-
s0 = peg$
|
|
2722
|
+
s0 = peg$f44(s2);
|
|
2672
2723
|
} else {
|
|
2673
2724
|
peg$currPos = s0;
|
|
2674
2725
|
s0 = peg$FAILED;
|
|
@@ -2818,12 +2869,12 @@ function peg$parse(input, options) {
|
|
|
2818
2869
|
else s1 = s2;
|
|
2819
2870
|
if (s1 !== peg$FAILED) {
|
|
2820
2871
|
peg$savedPos = peg$currPos;
|
|
2821
|
-
s2 = peg$
|
|
2872
|
+
s2 = peg$f45(s1);
|
|
2822
2873
|
if (s2) s2 = void 0;
|
|
2823
2874
|
else s2 = peg$FAILED;
|
|
2824
2875
|
if (s2 !== peg$FAILED) {
|
|
2825
2876
|
peg$savedPos = s0;
|
|
2826
|
-
s0 = peg$
|
|
2877
|
+
s0 = peg$f46(s1);
|
|
2827
2878
|
} else {
|
|
2828
2879
|
peg$currPos = s0;
|
|
2829
2880
|
s0 = peg$FAILED;
|
|
@@ -2834,6 +2885,177 @@ function peg$parse(input, options) {
|
|
|
2834
2885
|
}
|
|
2835
2886
|
return s0;
|
|
2836
2887
|
}
|
|
2888
|
+
function peg$parseUriAutolink() {
|
|
2889
|
+
let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
|
|
2890
|
+
s0 = peg$currPos;
|
|
2891
|
+
s1 = peg$currPos;
|
|
2892
|
+
s2 = peg$currPos;
|
|
2893
|
+
if (input.charCodeAt(peg$currPos) === 60) {
|
|
2894
|
+
s3 = peg$c6;
|
|
2895
|
+
peg$currPos++;
|
|
2896
|
+
} else {
|
|
2897
|
+
s3 = peg$FAILED;
|
|
2898
|
+
if (peg$silentFails === 0) peg$fail(peg$e10);
|
|
2899
|
+
}
|
|
2900
|
+
if (s3 !== peg$FAILED) {
|
|
2901
|
+
s4 = input.charAt(peg$currPos);
|
|
2902
|
+
if (peg$r8.test(s4)) peg$currPos++;
|
|
2903
|
+
else {
|
|
2904
|
+
s4 = peg$FAILED;
|
|
2905
|
+
if (peg$silentFails === 0) peg$fail(peg$e22);
|
|
2906
|
+
}
|
|
2907
|
+
if (s4 !== peg$FAILED) {
|
|
2908
|
+
s5 = peg$currPos;
|
|
2909
|
+
s6 = [];
|
|
2910
|
+
s7 = input.charAt(peg$currPos);
|
|
2911
|
+
if (peg$r12.test(s7)) peg$currPos++;
|
|
2912
|
+
else {
|
|
2913
|
+
s7 = peg$FAILED;
|
|
2914
|
+
if (peg$silentFails === 0) peg$fail(peg$e27);
|
|
2915
|
+
}
|
|
2916
|
+
while (s7 !== peg$FAILED) {
|
|
2917
|
+
s6.push(s7);
|
|
2918
|
+
if (s6.length >= 31) s7 = peg$FAILED;
|
|
2919
|
+
else {
|
|
2920
|
+
s7 = input.charAt(peg$currPos);
|
|
2921
|
+
if (peg$r12.test(s7)) peg$currPos++;
|
|
2922
|
+
else {
|
|
2923
|
+
s7 = peg$FAILED;
|
|
2924
|
+
if (peg$silentFails === 0) peg$fail(peg$e27);
|
|
2925
|
+
}
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
if (s6.length < 1) {
|
|
2929
|
+
peg$currPos = s5;
|
|
2930
|
+
s5 = peg$FAILED;
|
|
2931
|
+
} else s5 = s6;
|
|
2932
|
+
if (s5 !== peg$FAILED) {
|
|
2933
|
+
if (input.charCodeAt(peg$currPos) === 58) {
|
|
2934
|
+
s6 = peg$c14;
|
|
2935
|
+
peg$currPos++;
|
|
2936
|
+
} else {
|
|
2937
|
+
s6 = peg$FAILED;
|
|
2938
|
+
if (peg$silentFails === 0) peg$fail(peg$e28);
|
|
2939
|
+
}
|
|
2940
|
+
if (s6 !== peg$FAILED) {
|
|
2941
|
+
s7 = [];
|
|
2942
|
+
s8 = peg$currPos;
|
|
2943
|
+
s9 = peg$currPos;
|
|
2944
|
+
peg$silentFails++;
|
|
2945
|
+
if (input.substr(peg$currPos, 2) === peg$c8) {
|
|
2946
|
+
s10 = peg$c8;
|
|
2947
|
+
peg$currPos += 2;
|
|
2948
|
+
} else {
|
|
2949
|
+
s10 = peg$FAILED;
|
|
2950
|
+
if (peg$silentFails === 0) peg$fail(peg$e12);
|
|
2951
|
+
}
|
|
2952
|
+
peg$silentFails--;
|
|
2953
|
+
if (s10 === peg$FAILED) s9 = void 0;
|
|
2954
|
+
else {
|
|
2955
|
+
peg$currPos = s9;
|
|
2956
|
+
s9 = peg$FAILED;
|
|
2957
|
+
}
|
|
2958
|
+
if (s9 !== peg$FAILED) {
|
|
2959
|
+
s10 = input.charAt(peg$currPos);
|
|
2960
|
+
if (peg$r13.test(s10)) peg$currPos++;
|
|
2961
|
+
else {
|
|
2962
|
+
s10 = peg$FAILED;
|
|
2963
|
+
if (peg$silentFails === 0) peg$fail(peg$e29);
|
|
2964
|
+
}
|
|
2965
|
+
if (s10 !== peg$FAILED) {
|
|
2966
|
+
s9 = [s9, s10];
|
|
2967
|
+
s8 = s9;
|
|
2968
|
+
} else {
|
|
2969
|
+
peg$currPos = s8;
|
|
2970
|
+
s8 = peg$FAILED;
|
|
2971
|
+
}
|
|
2972
|
+
} else {
|
|
2973
|
+
peg$currPos = s8;
|
|
2974
|
+
s8 = peg$FAILED;
|
|
2975
|
+
}
|
|
2976
|
+
while (s8 !== peg$FAILED) {
|
|
2977
|
+
s7.push(s8);
|
|
2978
|
+
s8 = peg$currPos;
|
|
2979
|
+
s9 = peg$currPos;
|
|
2980
|
+
peg$silentFails++;
|
|
2981
|
+
if (input.substr(peg$currPos, 2) === peg$c8) {
|
|
2982
|
+
s10 = peg$c8;
|
|
2983
|
+
peg$currPos += 2;
|
|
2984
|
+
} else {
|
|
2985
|
+
s10 = peg$FAILED;
|
|
2986
|
+
if (peg$silentFails === 0) peg$fail(peg$e12);
|
|
2987
|
+
}
|
|
2988
|
+
peg$silentFails--;
|
|
2989
|
+
if (s10 === peg$FAILED) s9 = void 0;
|
|
2990
|
+
else {
|
|
2991
|
+
peg$currPos = s9;
|
|
2992
|
+
s9 = peg$FAILED;
|
|
2993
|
+
}
|
|
2994
|
+
if (s9 !== peg$FAILED) {
|
|
2995
|
+
s10 = input.charAt(peg$currPos);
|
|
2996
|
+
if (peg$r13.test(s10)) peg$currPos++;
|
|
2997
|
+
else {
|
|
2998
|
+
s10 = peg$FAILED;
|
|
2999
|
+
if (peg$silentFails === 0) peg$fail(peg$e29);
|
|
3000
|
+
}
|
|
3001
|
+
if (s10 !== peg$FAILED) {
|
|
3002
|
+
s9 = [s9, s10];
|
|
3003
|
+
s8 = s9;
|
|
3004
|
+
} else {
|
|
3005
|
+
peg$currPos = s8;
|
|
3006
|
+
s8 = peg$FAILED;
|
|
3007
|
+
}
|
|
3008
|
+
} else {
|
|
3009
|
+
peg$currPos = s8;
|
|
3010
|
+
s8 = peg$FAILED;
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
if (input.charCodeAt(peg$currPos) === 62) {
|
|
3014
|
+
s8 = peg$c1;
|
|
3015
|
+
peg$currPos++;
|
|
3016
|
+
} else {
|
|
3017
|
+
s8 = peg$FAILED;
|
|
3018
|
+
if (peg$silentFails === 0) peg$fail(peg$e3);
|
|
3019
|
+
}
|
|
3020
|
+
if (s8 !== peg$FAILED) {
|
|
3021
|
+
s3 = [
|
|
3022
|
+
s3,
|
|
3023
|
+
s4,
|
|
3024
|
+
s5,
|
|
3025
|
+
s6,
|
|
3026
|
+
s7,
|
|
3027
|
+
s8
|
|
3028
|
+
];
|
|
3029
|
+
s2 = s3;
|
|
3030
|
+
} else {
|
|
3031
|
+
peg$currPos = s2;
|
|
3032
|
+
s2 = peg$FAILED;
|
|
3033
|
+
}
|
|
3034
|
+
} else {
|
|
3035
|
+
peg$currPos = s2;
|
|
3036
|
+
s2 = peg$FAILED;
|
|
3037
|
+
}
|
|
3038
|
+
} else {
|
|
3039
|
+
peg$currPos = s2;
|
|
3040
|
+
s2 = peg$FAILED;
|
|
3041
|
+
}
|
|
3042
|
+
} else {
|
|
3043
|
+
peg$currPos = s2;
|
|
3044
|
+
s2 = peg$FAILED;
|
|
3045
|
+
}
|
|
3046
|
+
} else {
|
|
3047
|
+
peg$currPos = s2;
|
|
3048
|
+
s2 = peg$FAILED;
|
|
3049
|
+
}
|
|
3050
|
+
if (s2 !== peg$FAILED) s1 = input.substring(s1, peg$currPos);
|
|
3051
|
+
else s1 = s2;
|
|
3052
|
+
if (s1 !== peg$FAILED) {
|
|
3053
|
+
peg$savedPos = s0;
|
|
3054
|
+
s1 = peg$f47(s1);
|
|
3055
|
+
}
|
|
3056
|
+
s0 = s1;
|
|
3057
|
+
return s0;
|
|
3058
|
+
}
|
|
2837
3059
|
function peg$parseHtmlOpen() {
|
|
2838
3060
|
let s0, s1, s2, s3, s4, s5, s6, s7;
|
|
2839
3061
|
s0 = peg$currPos;
|
|
@@ -2872,7 +3094,7 @@ function peg$parse(input, options) {
|
|
|
2872
3094
|
}
|
|
2873
3095
|
if (s7 !== peg$FAILED) {
|
|
2874
3096
|
peg$savedPos = s0;
|
|
2875
|
-
s0 = peg$
|
|
3097
|
+
s0 = peg$f48(s2, s3, s4, s6);
|
|
2876
3098
|
} else {
|
|
2877
3099
|
peg$currPos = s0;
|
|
2878
3100
|
s0 = peg$FAILED;
|
|
@@ -2900,10 +3122,10 @@ function peg$parse(input, options) {
|
|
|
2900
3122
|
s3 = peg$currPos;
|
|
2901
3123
|
peg$silentFails++;
|
|
2902
3124
|
s4 = input.charAt(peg$currPos);
|
|
2903
|
-
if (peg$
|
|
3125
|
+
if (peg$r14.test(s4)) peg$currPos++;
|
|
2904
3126
|
else {
|
|
2905
3127
|
s4 = peg$FAILED;
|
|
2906
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3128
|
+
if (peg$silentFails === 0) peg$fail(peg$e30);
|
|
2907
3129
|
}
|
|
2908
3130
|
if (s4 === peg$FAILED) {
|
|
2909
3131
|
s4 = peg$currPos;
|
|
@@ -2937,7 +3159,7 @@ function peg$parse(input, options) {
|
|
|
2937
3159
|
s5 = peg$parse_();
|
|
2938
3160
|
s6 = peg$parseHere();
|
|
2939
3161
|
peg$savedPos = s0;
|
|
2940
|
-
s0 = peg$
|
|
3162
|
+
s0 = peg$f49(s2, s6);
|
|
2941
3163
|
} else {
|
|
2942
3164
|
peg$currPos = s0;
|
|
2943
3165
|
s0 = peg$FAILED;
|
|
@@ -2956,12 +3178,12 @@ function peg$parse(input, options) {
|
|
|
2956
3178
|
function peg$parseHtmlClose() {
|
|
2957
3179
|
let s0, s1, s2, s3, s5;
|
|
2958
3180
|
s0 = peg$currPos;
|
|
2959
|
-
if (input.substr(peg$currPos, 2) === peg$
|
|
2960
|
-
s1 = peg$
|
|
3181
|
+
if (input.substr(peg$currPos, 2) === peg$c15) {
|
|
3182
|
+
s1 = peg$c15;
|
|
2961
3183
|
peg$currPos += 2;
|
|
2962
3184
|
} else {
|
|
2963
3185
|
s1 = peg$FAILED;
|
|
2964
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3186
|
+
if (peg$silentFails === 0) peg$fail(peg$e31);
|
|
2965
3187
|
}
|
|
2966
3188
|
if (s1 !== peg$FAILED) {
|
|
2967
3189
|
s2 = peg$parseHere();
|
|
@@ -2977,7 +3199,7 @@ function peg$parse(input, options) {
|
|
|
2977
3199
|
}
|
|
2978
3200
|
if (s5 !== peg$FAILED) {
|
|
2979
3201
|
peg$savedPos = s0;
|
|
2980
|
-
s0 = peg$
|
|
3202
|
+
s0 = peg$f50(s2, s3);
|
|
2981
3203
|
} else {
|
|
2982
3204
|
peg$currPos = s0;
|
|
2983
3205
|
s0 = peg$FAILED;
|
|
@@ -3005,18 +3227,18 @@ function peg$parse(input, options) {
|
|
|
3005
3227
|
if (s2 !== peg$FAILED) {
|
|
3006
3228
|
s3 = [];
|
|
3007
3229
|
s4 = input.charAt(peg$currPos);
|
|
3008
|
-
if (peg$
|
|
3230
|
+
if (peg$r15.test(s4)) peg$currPos++;
|
|
3009
3231
|
else {
|
|
3010
3232
|
s4 = peg$FAILED;
|
|
3011
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3233
|
+
if (peg$silentFails === 0) peg$fail(peg$e32);
|
|
3012
3234
|
}
|
|
3013
3235
|
while (s4 !== peg$FAILED) {
|
|
3014
3236
|
s3.push(s4);
|
|
3015
3237
|
s4 = input.charAt(peg$currPos);
|
|
3016
|
-
if (peg$
|
|
3238
|
+
if (peg$r15.test(s4)) peg$currPos++;
|
|
3017
3239
|
else {
|
|
3018
3240
|
s4 = peg$FAILED;
|
|
3019
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3241
|
+
if (peg$silentFails === 0) peg$fail(peg$e32);
|
|
3020
3242
|
}
|
|
3021
3243
|
}
|
|
3022
3244
|
s2 = [s2, s3];
|
|
@@ -3040,10 +3262,10 @@ function peg$parse(input, options) {
|
|
|
3040
3262
|
s6 = peg$currPos;
|
|
3041
3263
|
peg$silentFails++;
|
|
3042
3264
|
s7 = input.charAt(peg$currPos);
|
|
3043
|
-
if (peg$
|
|
3265
|
+
if (peg$r16.test(s7)) peg$currPos++;
|
|
3044
3266
|
else {
|
|
3045
3267
|
s7 = peg$FAILED;
|
|
3046
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3268
|
+
if (peg$silentFails === 0) peg$fail(peg$e33);
|
|
3047
3269
|
}
|
|
3048
3270
|
peg$silentFails--;
|
|
3049
3271
|
if (s7 === peg$FAILED) s6 = void 0;
|
|
@@ -3076,10 +3298,10 @@ function peg$parse(input, options) {
|
|
|
3076
3298
|
s6 = peg$currPos;
|
|
3077
3299
|
peg$silentFails++;
|
|
3078
3300
|
s7 = input.charAt(peg$currPos);
|
|
3079
|
-
if (peg$
|
|
3301
|
+
if (peg$r16.test(s7)) peg$currPos++;
|
|
3080
3302
|
else {
|
|
3081
3303
|
s7 = peg$FAILED;
|
|
3082
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3304
|
+
if (peg$silentFails === 0) peg$fail(peg$e33);
|
|
3083
3305
|
}
|
|
3084
3306
|
peg$silentFails--;
|
|
3085
3307
|
if (s7 === peg$FAILED) s6 = void 0;
|
|
@@ -3112,25 +3334,25 @@ function peg$parse(input, options) {
|
|
|
3112
3334
|
else s3 = s4;
|
|
3113
3335
|
if (s3 !== peg$FAILED) {
|
|
3114
3336
|
peg$savedPos = peg$currPos;
|
|
3115
|
-
s4 = peg$
|
|
3337
|
+
s4 = peg$f51(s2, s3);
|
|
3116
3338
|
if (s4) s4 = void 0;
|
|
3117
3339
|
else s4 = peg$FAILED;
|
|
3118
3340
|
if (s4 !== peg$FAILED) {
|
|
3119
3341
|
s5 = peg$currPos;
|
|
3120
3342
|
s6 = peg$parse_();
|
|
3121
3343
|
if (input.charCodeAt(peg$currPos) === 61) {
|
|
3122
|
-
s7 = peg$
|
|
3344
|
+
s7 = peg$c16;
|
|
3123
3345
|
peg$currPos++;
|
|
3124
3346
|
} else {
|
|
3125
3347
|
s7 = peg$FAILED;
|
|
3126
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3348
|
+
if (peg$silentFails === 0) peg$fail(peg$e34);
|
|
3127
3349
|
}
|
|
3128
3350
|
if (s7 !== peg$FAILED) {
|
|
3129
3351
|
peg$parse_();
|
|
3130
3352
|
s9 = peg$parseAttrValue();
|
|
3131
3353
|
if (s9 !== peg$FAILED) {
|
|
3132
3354
|
peg$savedPos = s5;
|
|
3133
|
-
s5 = peg$
|
|
3355
|
+
s5 = peg$f52(s2, s3, s9);
|
|
3134
3356
|
} else {
|
|
3135
3357
|
peg$currPos = s5;
|
|
3136
3358
|
s5 = peg$FAILED;
|
|
@@ -3141,7 +3363,7 @@ function peg$parse(input, options) {
|
|
|
3141
3363
|
}
|
|
3142
3364
|
if (s5 === peg$FAILED) s5 = null;
|
|
3143
3365
|
peg$savedPos = s0;
|
|
3144
|
-
s0 = peg$
|
|
3366
|
+
s0 = peg$f53(s2, s3, s5);
|
|
3145
3367
|
} else {
|
|
3146
3368
|
peg$currPos = s0;
|
|
3147
3369
|
s0 = peg$FAILED;
|
|
@@ -3156,11 +3378,11 @@ function peg$parse(input, options) {
|
|
|
3156
3378
|
let s0, s1, s2, s3, s4, s5;
|
|
3157
3379
|
s0 = peg$currPos;
|
|
3158
3380
|
if (input.charCodeAt(peg$currPos) === 34) {
|
|
3159
|
-
s1 = peg$
|
|
3381
|
+
s1 = peg$c17;
|
|
3160
3382
|
peg$currPos++;
|
|
3161
3383
|
} else {
|
|
3162
3384
|
s1 = peg$FAILED;
|
|
3163
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3385
|
+
if (peg$silentFails === 0) peg$fail(peg$e35);
|
|
3164
3386
|
}
|
|
3165
3387
|
if (s1 !== peg$FAILED) {
|
|
3166
3388
|
s2 = peg$parseHere();
|
|
@@ -3169,10 +3391,10 @@ function peg$parse(input, options) {
|
|
|
3169
3391
|
s5 = peg$parseValuePart();
|
|
3170
3392
|
if (s5 === peg$FAILED) {
|
|
3171
3393
|
s5 = input.charAt(peg$currPos);
|
|
3172
|
-
if (peg$
|
|
3394
|
+
if (peg$r17.test(s5)) peg$currPos++;
|
|
3173
3395
|
else {
|
|
3174
3396
|
s5 = peg$FAILED;
|
|
3175
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3397
|
+
if (peg$silentFails === 0) peg$fail(peg$e36);
|
|
3176
3398
|
}
|
|
3177
3399
|
}
|
|
3178
3400
|
while (s5 !== peg$FAILED) {
|
|
@@ -3180,25 +3402,25 @@ function peg$parse(input, options) {
|
|
|
3180
3402
|
s5 = peg$parseValuePart();
|
|
3181
3403
|
if (s5 === peg$FAILED) {
|
|
3182
3404
|
s5 = input.charAt(peg$currPos);
|
|
3183
|
-
if (peg$
|
|
3405
|
+
if (peg$r17.test(s5)) peg$currPos++;
|
|
3184
3406
|
else {
|
|
3185
3407
|
s5 = peg$FAILED;
|
|
3186
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3408
|
+
if (peg$silentFails === 0) peg$fail(peg$e36);
|
|
3187
3409
|
}
|
|
3188
3410
|
}
|
|
3189
3411
|
}
|
|
3190
3412
|
s3 = input.substring(s3, peg$currPos);
|
|
3191
3413
|
s4 = peg$parseHere();
|
|
3192
3414
|
if (input.charCodeAt(peg$currPos) === 34) {
|
|
3193
|
-
s5 = peg$
|
|
3415
|
+
s5 = peg$c17;
|
|
3194
3416
|
peg$currPos++;
|
|
3195
3417
|
} else {
|
|
3196
3418
|
s5 = peg$FAILED;
|
|
3197
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3419
|
+
if (peg$silentFails === 0) peg$fail(peg$e35);
|
|
3198
3420
|
}
|
|
3199
3421
|
if (s5 !== peg$FAILED) {
|
|
3200
3422
|
peg$savedPos = s0;
|
|
3201
|
-
s0 = peg$
|
|
3423
|
+
s0 = peg$f54(s2, s3, s4);
|
|
3202
3424
|
} else {
|
|
3203
3425
|
peg$currPos = s0;
|
|
3204
3426
|
s0 = peg$FAILED;
|
|
@@ -3210,11 +3432,11 @@ function peg$parse(input, options) {
|
|
|
3210
3432
|
if (s0 === peg$FAILED) {
|
|
3211
3433
|
s0 = peg$currPos;
|
|
3212
3434
|
if (input.charCodeAt(peg$currPos) === 39) {
|
|
3213
|
-
s1 = peg$
|
|
3435
|
+
s1 = peg$c18;
|
|
3214
3436
|
peg$currPos++;
|
|
3215
3437
|
} else {
|
|
3216
3438
|
s1 = peg$FAILED;
|
|
3217
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3439
|
+
if (peg$silentFails === 0) peg$fail(peg$e37);
|
|
3218
3440
|
}
|
|
3219
3441
|
if (s1 !== peg$FAILED) {
|
|
3220
3442
|
s2 = peg$parseHere();
|
|
@@ -3223,10 +3445,10 @@ function peg$parse(input, options) {
|
|
|
3223
3445
|
s5 = peg$parseValuePart();
|
|
3224
3446
|
if (s5 === peg$FAILED) {
|
|
3225
3447
|
s5 = input.charAt(peg$currPos);
|
|
3226
|
-
if (peg$
|
|
3448
|
+
if (peg$r18.test(s5)) peg$currPos++;
|
|
3227
3449
|
else {
|
|
3228
3450
|
s5 = peg$FAILED;
|
|
3229
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3451
|
+
if (peg$silentFails === 0) peg$fail(peg$e38);
|
|
3230
3452
|
}
|
|
3231
3453
|
}
|
|
3232
3454
|
while (s5 !== peg$FAILED) {
|
|
@@ -3234,25 +3456,25 @@ function peg$parse(input, options) {
|
|
|
3234
3456
|
s5 = peg$parseValuePart();
|
|
3235
3457
|
if (s5 === peg$FAILED) {
|
|
3236
3458
|
s5 = input.charAt(peg$currPos);
|
|
3237
|
-
if (peg$
|
|
3459
|
+
if (peg$r18.test(s5)) peg$currPos++;
|
|
3238
3460
|
else {
|
|
3239
3461
|
s5 = peg$FAILED;
|
|
3240
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3462
|
+
if (peg$silentFails === 0) peg$fail(peg$e38);
|
|
3241
3463
|
}
|
|
3242
3464
|
}
|
|
3243
3465
|
}
|
|
3244
3466
|
s3 = input.substring(s3, peg$currPos);
|
|
3245
3467
|
s4 = peg$parseHere();
|
|
3246
3468
|
if (input.charCodeAt(peg$currPos) === 39) {
|
|
3247
|
-
s5 = peg$
|
|
3469
|
+
s5 = peg$c18;
|
|
3248
3470
|
peg$currPos++;
|
|
3249
3471
|
} else {
|
|
3250
3472
|
s5 = peg$FAILED;
|
|
3251
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3473
|
+
if (peg$silentFails === 0) peg$fail(peg$e37);
|
|
3252
3474
|
}
|
|
3253
3475
|
if (s5 !== peg$FAILED) {
|
|
3254
3476
|
peg$savedPos = s0;
|
|
3255
|
-
s0 = peg$
|
|
3477
|
+
s0 = peg$f55(s2, s3, s4);
|
|
3256
3478
|
} else {
|
|
3257
3479
|
peg$currPos = s0;
|
|
3258
3480
|
s0 = peg$FAILED;
|
|
@@ -3264,14 +3486,14 @@ function peg$parse(input, options) {
|
|
|
3264
3486
|
if (s0 === peg$FAILED) {
|
|
3265
3487
|
s0 = peg$currPos;
|
|
3266
3488
|
s1 = input.charAt(peg$currPos);
|
|
3267
|
-
if (peg$
|
|
3489
|
+
if (peg$r19.test(s1)) peg$currPos++;
|
|
3268
3490
|
else {
|
|
3269
3491
|
s1 = peg$FAILED;
|
|
3270
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3492
|
+
if (peg$silentFails === 0) peg$fail(peg$e39);
|
|
3271
3493
|
}
|
|
3272
3494
|
if (s1 !== peg$FAILED) {
|
|
3273
3495
|
peg$savedPos = s0;
|
|
3274
|
-
s1 = peg$
|
|
3496
|
+
s1 = peg$f56(s1);
|
|
3275
3497
|
}
|
|
3276
3498
|
s0 = s1;
|
|
3277
3499
|
if (s0 === peg$FAILED) {
|
|
@@ -3280,24 +3502,24 @@ function peg$parse(input, options) {
|
|
|
3280
3502
|
s2 = peg$currPos;
|
|
3281
3503
|
s3 = [];
|
|
3282
3504
|
s4 = input.charAt(peg$currPos);
|
|
3283
|
-
if (peg$
|
|
3505
|
+
if (peg$r20.test(s4)) peg$currPos++;
|
|
3284
3506
|
else {
|
|
3285
3507
|
s4 = peg$FAILED;
|
|
3286
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3508
|
+
if (peg$silentFails === 0) peg$fail(peg$e40);
|
|
3287
3509
|
}
|
|
3288
3510
|
while (s4 !== peg$FAILED) {
|
|
3289
3511
|
s3.push(s4);
|
|
3290
3512
|
s4 = input.charAt(peg$currPos);
|
|
3291
|
-
if (peg$
|
|
3513
|
+
if (peg$r20.test(s4)) peg$currPos++;
|
|
3292
3514
|
else {
|
|
3293
3515
|
s4 = peg$FAILED;
|
|
3294
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3516
|
+
if (peg$silentFails === 0) peg$fail(peg$e40);
|
|
3295
3517
|
}
|
|
3296
3518
|
}
|
|
3297
3519
|
s2 = input.substring(s2, peg$currPos);
|
|
3298
3520
|
s3 = peg$parseHere();
|
|
3299
3521
|
peg$savedPos = s0;
|
|
3300
|
-
s0 = peg$
|
|
3522
|
+
s0 = peg$f57(s1, s2, s3);
|
|
3301
3523
|
}
|
|
3302
3524
|
}
|
|
3303
3525
|
}
|
|
@@ -3307,7 +3529,7 @@ function peg$parse(input, options) {
|
|
|
3307
3529
|
let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13;
|
|
3308
3530
|
s0 = peg$currPos;
|
|
3309
3531
|
peg$savedPos = peg$currPos;
|
|
3310
|
-
s1 = peg$
|
|
3532
|
+
s1 = peg$f58();
|
|
3311
3533
|
if (s1) s1 = void 0;
|
|
3312
3534
|
else s1 = peg$FAILED;
|
|
3313
3535
|
if (s1 !== peg$FAILED) {
|
|
@@ -3336,7 +3558,7 @@ function peg$parse(input, options) {
|
|
|
3336
3558
|
if (s2 !== peg$FAILED) {
|
|
3337
3559
|
s3 = peg$currPos;
|
|
3338
3560
|
peg$savedPos = peg$currPos;
|
|
3339
|
-
s4 = peg$
|
|
3561
|
+
s4 = peg$f59(s2);
|
|
3340
3562
|
if (s4) s4 = void 0;
|
|
3341
3563
|
else s4 = peg$FAILED;
|
|
3342
3564
|
if (s4 !== peg$FAILED) {
|
|
@@ -3375,7 +3597,7 @@ function peg$parse(input, options) {
|
|
|
3375
3597
|
if (s0 === peg$FAILED) {
|
|
3376
3598
|
s0 = peg$currPos;
|
|
3377
3599
|
peg$savedPos = peg$currPos;
|
|
3378
|
-
s1 = peg$
|
|
3600
|
+
s1 = peg$f60();
|
|
3379
3601
|
if (s1) s1 = void 0;
|
|
3380
3602
|
else s1 = peg$FAILED;
|
|
3381
3603
|
if (s1 !== peg$FAILED) {
|
|
@@ -3402,12 +3624,12 @@ function peg$parse(input, options) {
|
|
|
3402
3624
|
if (s6 !== peg$FAILED) {
|
|
3403
3625
|
s7 = peg$parseHere();
|
|
3404
3626
|
peg$savedPos = peg$currPos;
|
|
3405
|
-
s8 = peg$
|
|
3627
|
+
s8 = peg$f61(s4, s7);
|
|
3406
3628
|
if (s8) s8 = void 0;
|
|
3407
3629
|
else s8 = peg$FAILED;
|
|
3408
3630
|
if (s8 !== peg$FAILED) {
|
|
3409
3631
|
s9 = peg$currPos;
|
|
3410
|
-
s10 = peg$
|
|
3632
|
+
s10 = peg$f62(s4, s7);
|
|
3411
3633
|
s11 = peg$currPos;
|
|
3412
3634
|
s12 = [];
|
|
3413
3635
|
if (s12.length >= (s10 | 0)) s13 = peg$FAILED;
|
|
@@ -3489,7 +3711,7 @@ function peg$parse(input, options) {
|
|
|
3489
3711
|
if (s0 === peg$FAILED) {
|
|
3490
3712
|
s0 = peg$currPos;
|
|
3491
3713
|
peg$savedPos = peg$currPos;
|
|
3492
|
-
s1 = peg$
|
|
3714
|
+
s1 = peg$f63();
|
|
3493
3715
|
if (s1) s1 = void 0;
|
|
3494
3716
|
else s1 = peg$FAILED;
|
|
3495
3717
|
if (s1 !== peg$FAILED) {
|
|
@@ -3580,7 +3802,7 @@ function peg$parse(input, options) {
|
|
|
3580
3802
|
if (s0 === peg$FAILED) {
|
|
3581
3803
|
s0 = peg$currPos;
|
|
3582
3804
|
peg$savedPos = peg$currPos;
|
|
3583
|
-
s1 = peg$
|
|
3805
|
+
s1 = peg$f64();
|
|
3584
3806
|
if (s1) s1 = void 0;
|
|
3585
3807
|
else s1 = peg$FAILED;
|
|
3586
3808
|
if (s1 !== peg$FAILED) {
|
|
@@ -3662,10 +3884,10 @@ function peg$parse(input, options) {
|
|
|
3662
3884
|
function peg$parse_c() {
|
|
3663
3885
|
let s0;
|
|
3664
3886
|
s0 = input.charAt(peg$currPos);
|
|
3665
|
-
if (peg$
|
|
3887
|
+
if (peg$r21.test(s0)) peg$currPos++;
|
|
3666
3888
|
else {
|
|
3667
3889
|
s0 = peg$FAILED;
|
|
3668
|
-
if (peg$silentFails === 0) peg$fail(peg$
|
|
3890
|
+
if (peg$silentFails === 0) peg$fail(peg$e41);
|
|
3669
3891
|
}
|
|
3670
3892
|
return s0;
|
|
3671
3893
|
}
|
|
@@ -9572,6 +9794,7 @@ var SigilParser = class extends Parser {
|
|
|
9572
9794
|
braceIsBlock(prevType) {
|
|
9573
9795
|
if (prevType === types$1.colon && this.colonEndsTernary) return false;
|
|
9574
9796
|
if (prevType === types$1.braceR && this.closedBlock) return true;
|
|
9797
|
+
if (prevType === types$1._do) return true;
|
|
9575
9798
|
if (prevType === types$1.name && this.prevValue === "static") return true;
|
|
9576
9799
|
if (this.breakHere && OPERAND_ENDS.has(prevType)) {
|
|
9577
9800
|
const { context } = this;
|
|
@@ -20779,7 +21002,8 @@ function StoryContextView({ ast }) {
|
|
|
20779
21002
|
* story has none. It is mounted on the first call, hidden from the page and
|
|
20780
21003
|
* with its controls registering no actions, and stays mounted: it follows the
|
|
20781
21004
|
* story's variables, also across a restart. The element itself is not hidden
|
|
20782
|
-
* (its parent is), so
|
|
21005
|
+
* (its parent is), so observations bound visibility checks at the container.
|
|
21006
|
+
* A passage that can't be
|
|
20783
21007
|
* parsed or rendered shows its error as text in the element; this never
|
|
20784
21008
|
* throws.
|
|
20785
21009
|
*/
|
|
@@ -20866,15 +21090,17 @@ function controlMarker(el) {
|
|
|
20866
21090
|
* The text a reader sees in the element, as lines: blocks and `<br>` break
|
|
20867
21091
|
* lines, hidden elements are left out, and a control with a `data-action`
|
|
20868
21092
|
* becomes a marker such as `[textbox $name: "Alice"]`. Elements inside `el`
|
|
20869
|
-
* that match `skip` are left out with their content.
|
|
21093
|
+
* that match `skip` are left out with their content. `visibilityRoot` bounds
|
|
21094
|
+
* ancestor checks when reading StoryContext inside its hidden host.
|
|
20870
21095
|
*/
|
|
20871
|
-
function observableText(el, skip) {
|
|
21096
|
+
function observableText(el, skip, visibilityRoot) {
|
|
20872
21097
|
let out = "";
|
|
20873
21098
|
const endLine = () => {
|
|
20874
21099
|
if (out !== "" && !out.endsWith("\n")) out += "\n";
|
|
20875
21100
|
};
|
|
20876
21101
|
const walk = (node, inPre) => {
|
|
20877
21102
|
if (node.nodeType === 3) {
|
|
21103
|
+
if (node.parentElement && !isRendered(node.parentElement, visibilityRoot)) return;
|
|
20878
21104
|
const data = node.textContent ?? "";
|
|
20879
21105
|
if (inPre) out += data;
|
|
20880
21106
|
else {
|
|
@@ -20887,11 +21113,12 @@ function observableText(el, skip) {
|
|
|
20887
21113
|
const child = node;
|
|
20888
21114
|
if (isHidden(child) || skip && child !== el && child.matches(skip)) return;
|
|
20889
21115
|
if (child.hasAttribute("data-action") && (child.matches("input, textarea, select") || getAction(child.getAttribute("data-action"))?.type === "cycle")) {
|
|
21116
|
+
if (!isRendered(child, visibilityRoot)) return;
|
|
20890
21117
|
out += controlMarker(child);
|
|
20891
21118
|
return;
|
|
20892
21119
|
}
|
|
20893
21120
|
if (child.tagName === "BR") {
|
|
20894
|
-
out += "\n";
|
|
21121
|
+
if (isRendered(child, visibilityRoot)) out += "\n";
|
|
20895
21122
|
return;
|
|
20896
21123
|
}
|
|
20897
21124
|
const block = BLOCKS.has(child.tagName);
|
|
@@ -20909,7 +21136,7 @@ function observableText(el, skip) {
|
|
|
20909
21136
|
* the reader can't see (inside a hidden element, as observableText() does)
|
|
20910
21137
|
* and those inside an element within `el` that matches `skip`.
|
|
20911
21138
|
*/
|
|
20912
|
-
function observableErrors(el, skip) {
|
|
21139
|
+
function observableErrors(el, skip, visibilityRoot) {
|
|
20913
21140
|
const left = (e) => {
|
|
20914
21141
|
for (let at = e; at; at = at.parentElement) {
|
|
20915
21142
|
if (isHidden(at)) return true;
|
|
@@ -20918,10 +21145,123 @@ function observableErrors(el, skip) {
|
|
|
20918
21145
|
}
|
|
20919
21146
|
return false;
|
|
20920
21147
|
};
|
|
20921
|
-
return Array.from(el.querySelectorAll(".error")).filter((e) => !left(e)).map((e) => (e
|
|
21148
|
+
return Array.from(el.querySelectorAll(".error")).filter((e) => !left(e) && isRendered(e, visibilityRoot)).map((e) => observableText(e, skip, visibilityRoot).trim());
|
|
21149
|
+
}
|
|
21150
|
+
//#endregion
|
|
21151
|
+
//#region src/utils/stable-key.ts
|
|
21152
|
+
/**
|
|
21153
|
+
* Content-derived string key for a value, used to remount components when
|
|
21154
|
+
* the value's contents change (e.g. {for} iterations, #45).
|
|
21155
|
+
*
|
|
21156
|
+
* A tree of JSON-compatible values (strings, finite numbers, booleans, null,
|
|
21157
|
+
* arrays and plain objects of those) produces exactly its `JSON.stringify`
|
|
21158
|
+
* output. Other values get distinct, unambiguous markers so their contents
|
|
21159
|
+
* are reflected too: Map and Set entries (nested at any depth), Date,
|
|
21160
|
+
* RegExp, BigInt, undefined, NaN/±Infinity, symbols (by description),
|
|
21161
|
+
* functions (by name) and registered class instances, with the class name
|
|
21162
|
+
* and, for a subclass of a built-in, its own fields (#407). The atomic
|
|
21163
|
+
* built-ins (see isAtomic) have their contents in the key: the bytes of a
|
|
21164
|
+
* buffer, the place of a view in its buffer, the text of a URL or
|
|
21165
|
+
* URLSearchParams, the class, message, cause and errors of an Error, the
|
|
21166
|
+
* value of a boxed primitive (#418). As for deepEqual and a save, -0 is not
|
|
21167
|
+
* 0 (#498) and a hole in an array is not an undefined element (#497), so
|
|
21168
|
+
* only the keys of -0 and of arrays with holes differ from JSON.stringify.
|
|
21169
|
+
*
|
|
21170
|
+
* An object met again, through a cycle or a second reference to it, is a
|
|
21171
|
+
* marker naming where it was first met rather than another copy of its
|
|
21172
|
+
* contents, so the key grows with the objects a value holds, not with the
|
|
21173
|
+
* paths to them (#406). The function never throws.
|
|
21174
|
+
*/
|
|
21175
|
+
function stableKey(value) {
|
|
21176
|
+
try {
|
|
21177
|
+
return keyOf(value, /* @__PURE__ */ new Map());
|
|
21178
|
+
} catch {
|
|
21179
|
+
return "<unkeyable>";
|
|
21180
|
+
}
|
|
21181
|
+
}
|
|
21182
|
+
/** The key of an array slot that holds no element. */
|
|
21183
|
+
var HOLE = "<hole>";
|
|
21184
|
+
/**
|
|
21185
|
+
* The key of `val`. `seen` numbers the objects keyed so far, in the order
|
|
21186
|
+
* they were first met.
|
|
21187
|
+
*/
|
|
21188
|
+
function keyOf(val, seen) {
|
|
21189
|
+
switch (typeof val) {
|
|
21190
|
+
case "string": return JSON.stringify(val);
|
|
21191
|
+
case "number":
|
|
21192
|
+
if (Object.is(val, -0)) return "-0";
|
|
21193
|
+
return Number.isFinite(val) ? JSON.stringify(val) : String(val);
|
|
21194
|
+
case "boolean": return String(val);
|
|
21195
|
+
case "bigint": return `${val}n`;
|
|
21196
|
+
case "undefined": return "undefined";
|
|
21197
|
+
case "symbol": return val.description === void 0 ? "Symbol()" : `Symbol(${JSON.stringify(val.description)})`;
|
|
21198
|
+
case "function": return `<function ${JSON.stringify(val.name)}>`;
|
|
21199
|
+
}
|
|
21200
|
+
if (val === null) return "null";
|
|
21201
|
+
const obj = val;
|
|
21202
|
+
const first = seen.get(obj);
|
|
21203
|
+
if (first !== void 0) return `<ref ${first}>`;
|
|
21204
|
+
const className = registeredClassName(obj);
|
|
21205
|
+
const named = (key) => className === void 0 ? key : `Class(${JSON.stringify(className)})${key}`;
|
|
21206
|
+
const withFields = (key) => {
|
|
21207
|
+
const keys = className === void 0 ? [] : extraKeys(obj);
|
|
21208
|
+
return named(keys.length ? `${key}${fieldsOf(obj, keys, seen)}` : key);
|
|
21209
|
+
};
|
|
21210
|
+
if (val instanceof Date || val instanceof RegExp) {
|
|
21211
|
+
if (className !== void 0 && extraKeys(obj).length) seen.set(obj, seen.size);
|
|
21212
|
+
return withFields(val instanceof Date ? `Date(${Date.prototype.getTime.call(val)})` : `RegExp(${regExpText(val)}@${val.lastIndex})`);
|
|
21213
|
+
}
|
|
21214
|
+
seen.set(obj, seen.size);
|
|
21215
|
+
if (Array.isArray(val)) {
|
|
21216
|
+
const items = [];
|
|
21217
|
+
for (let i = 0; i < val.length; i++) items.push(i in val ? keyOf(val[i], seen) : HOLE);
|
|
21218
|
+
return withFields(`[${items.join(",")}]`);
|
|
21219
|
+
}
|
|
21220
|
+
const atomic = atomicKey(obj, seen);
|
|
21221
|
+
if (atomic !== void 0) return named(atomic);
|
|
21222
|
+
if (val instanceof Map) return withFields(`Map[${Array.from(mapEntries(val), ([k, v]) => `[${keyOf(k, seen)},${keyOf(v, seen)}]`).join(",")}]`);
|
|
21223
|
+
if (val instanceof Set) return withFields(`Set[${Array.from(setMembers(val), (v) => keyOf(v, seen)).join(",")}]`);
|
|
21224
|
+
return named(fieldsOf(obj, Object.keys(obj), seen));
|
|
21225
|
+
}
|
|
21226
|
+
/**
|
|
21227
|
+
* The key of an atomic built-in other than a Map, Set, Date or RegExp (see
|
|
21228
|
+
* isAtomic), or undefined for any other object. Read with the built-in
|
|
21229
|
+
* methods, as a subclass may override them.
|
|
21230
|
+
*/
|
|
21231
|
+
function atomicKey(obj, seen) {
|
|
21232
|
+
if (obj instanceof ArrayBuffer) return `ArrayBuffer[${new Uint8Array(obj).join(",")}]`;
|
|
21233
|
+
if (ArrayBuffer.isView(obj)) return `${toStringTag(obj)}(${obj.byteOffset},${obj.byteLength},${keyOf(obj.buffer, seen)})`;
|
|
21234
|
+
let key;
|
|
21235
|
+
if (obj instanceof URL) key = `URL(${JSON.stringify(Object.getOwnPropertyDescriptor(URL.prototype, "href").get.call(obj))})`;
|
|
21236
|
+
else if (obj instanceof URLSearchParams) key = `URLSearchParams(${JSON.stringify(URLSearchParams.prototype.toString.call(obj))})`;
|
|
21237
|
+
else if (isBoxed(obj)) key = `${toStringTag(obj)}(${keyOf(obj.valueOf(), seen)})`;
|
|
21238
|
+
else if (isTemporal(obj)) key = `${toStringTag(obj)}(${JSON.stringify(String(obj))})`;
|
|
21239
|
+
else if (obj instanceof Error) {
|
|
21240
|
+
const record = obj;
|
|
21241
|
+
const held = ERROR_HIDDEN_KEYS$1.filter((k) => hasOwn(obj, k)).map((k) => `${k}:${keyOf(record[k], seen)}`);
|
|
21242
|
+
const ctor = Object.getPrototypeOf(obj)?.constructor;
|
|
21243
|
+
const name = typeof ctor === "function" ? ctor.name : "";
|
|
21244
|
+
key = `Error(${JSON.stringify(name)},${held.join(",")})`;
|
|
21245
|
+
} else return;
|
|
21246
|
+
const keys = Object.keys(obj);
|
|
21247
|
+
return keys.length ? `${key}${fieldsOf(obj, keys, seen)}` : key;
|
|
21248
|
+
}
|
|
21249
|
+
/** `{"key":value,...}` for the `keys` of `obj`. */
|
|
21250
|
+
function fieldsOf(obj, keys, seen) {
|
|
21251
|
+
const record = obj;
|
|
21252
|
+
return `{${keys.map((k) => `${JSON.stringify(k)}:${keyOf(record[k], seen)}`).join(",")}}`;
|
|
20922
21253
|
}
|
|
20923
21254
|
//#endregion
|
|
20924
21255
|
//#region src/observe/observe.ts
|
|
21256
|
+
/** JSON trees as snapshots; other values use the shared value description. */
|
|
21257
|
+
function observedValue(value) {
|
|
21258
|
+
const description = stableKey(value);
|
|
21259
|
+
try {
|
|
21260
|
+
return JSON.parse(description);
|
|
21261
|
+
} catch {
|
|
21262
|
+
return description;
|
|
21263
|
+
}
|
|
21264
|
+
}
|
|
20925
21265
|
/**
|
|
20926
21266
|
* Leaving the story's history, restarting, saving and loading, and the
|
|
20927
21267
|
* menubar's Saves and Settings dialogs (`dialog`) are not moves in the story.
|
|
@@ -20941,7 +21281,10 @@ var DEFAULT_EXCLUDED = /* @__PURE__ */ new Set([
|
|
|
20941
21281
|
*/
|
|
20942
21282
|
function filterObservedActions(actions, rules) {
|
|
20943
21283
|
const matchesAny = (action, matchers) => matchers?.some((m) => actionMatches(action, m)) ?? false;
|
|
20944
|
-
return actions.filter((action) => !matchesAny(action, rules.exclude) && (!DEFAULT_EXCLUDED.has(action.type) || matchesAny(action, rules.include))).map(({ perform: _perform, ...rest }) => rest
|
|
21284
|
+
return actions.filter((action) => !matchesAny(action, rules.exclude) && (!DEFAULT_EXCLUDED.has(action.type) || matchesAny(action, rules.include))).map(({ perform: _perform, value, ...rest }) => value === void 0 ? rest : {
|
|
21285
|
+
...rest,
|
|
21286
|
+
value: observedValue(value)
|
|
21287
|
+
});
|
|
20945
21288
|
}
|
|
20946
21289
|
var observedRules = {};
|
|
20947
21290
|
/**
|
|
@@ -20991,12 +21334,12 @@ function observe() {
|
|
|
20991
21334
|
passageEl,
|
|
20992
21335
|
...bodies.map((d) => d.body),
|
|
20993
21336
|
contextEl
|
|
20994
|
-
].flatMap((el) => el ? observableErrors(el, DIALOG) : []);
|
|
21337
|
+
].flatMap((el) => el ? observableErrors(el, DIALOG, el === contextEl ? el : void 0) : []);
|
|
20995
21338
|
for (const { context, message } of getRuntimeErrors()) errors.push(`${context.replace(/:$/, "")}: ${message}`);
|
|
20996
21339
|
return {
|
|
20997
21340
|
passage: currentPassage,
|
|
20998
21341
|
text: passageEl ? observableText(passageEl, DIALOG) : "",
|
|
20999
|
-
context: contextEl ? observableText(contextEl) : null,
|
|
21342
|
+
context: contextEl ? observableText(contextEl, void 0, contextEl) : null,
|
|
21000
21343
|
dialogs,
|
|
21001
21344
|
actions: filterObservedActions(offeredActions(), observedRules),
|
|
21002
21345
|
errors,
|
|
@@ -23240,110 +23583,6 @@ defineMacro({
|
|
|
23240
23583
|
}
|
|
23241
23584
|
});
|
|
23242
23585
|
//#endregion
|
|
23243
|
-
//#region src/utils/stable-key.ts
|
|
23244
|
-
/**
|
|
23245
|
-
* Content-derived string key for a value, used to remount components when
|
|
23246
|
-
* the value's contents change (e.g. {for} iterations, #45).
|
|
23247
|
-
*
|
|
23248
|
-
* A tree of JSON-compatible values (strings, finite numbers, booleans, null,
|
|
23249
|
-
* arrays and plain objects of those) produces exactly its `JSON.stringify`
|
|
23250
|
-
* output. Other values get distinct, unambiguous markers so their contents
|
|
23251
|
-
* are reflected too: Map and Set entries (nested at any depth), Date,
|
|
23252
|
-
* RegExp, BigInt, undefined, NaN/±Infinity, symbols (by description),
|
|
23253
|
-
* functions (by name) and registered class instances, with the class name
|
|
23254
|
-
* and, for a subclass of a built-in, its own fields (#407). The atomic
|
|
23255
|
-
* built-ins (see isAtomic) have their contents in the key: the bytes of a
|
|
23256
|
-
* buffer, the place of a view in its buffer, the text of a URL or
|
|
23257
|
-
* URLSearchParams, the class, message, cause and errors of an Error, the
|
|
23258
|
-
* value of a boxed primitive (#418). As for deepEqual and a save, -0 is not
|
|
23259
|
-
* 0 (#498) and a hole in an array is not an undefined element (#497), so
|
|
23260
|
-
* only the keys of -0 and of arrays with holes differ from JSON.stringify.
|
|
23261
|
-
*
|
|
23262
|
-
* An object met again, through a cycle or a second reference to it, is a
|
|
23263
|
-
* marker naming where it was first met rather than another copy of its
|
|
23264
|
-
* contents, so the key grows with the objects a value holds, not with the
|
|
23265
|
-
* paths to them (#406). The function never throws.
|
|
23266
|
-
*/
|
|
23267
|
-
function stableKey(value) {
|
|
23268
|
-
try {
|
|
23269
|
-
return keyOf(value, /* @__PURE__ */ new Map());
|
|
23270
|
-
} catch {
|
|
23271
|
-
return "<unkeyable>";
|
|
23272
|
-
}
|
|
23273
|
-
}
|
|
23274
|
-
/** The key of an array slot that holds no element. */
|
|
23275
|
-
var HOLE = "<hole>";
|
|
23276
|
-
/**
|
|
23277
|
-
* The key of `val`. `seen` numbers the objects keyed so far, in the order
|
|
23278
|
-
* they were first met.
|
|
23279
|
-
*/
|
|
23280
|
-
function keyOf(val, seen) {
|
|
23281
|
-
switch (typeof val) {
|
|
23282
|
-
case "string": return JSON.stringify(val);
|
|
23283
|
-
case "number":
|
|
23284
|
-
if (Object.is(val, -0)) return "-0";
|
|
23285
|
-
return Number.isFinite(val) ? JSON.stringify(val) : String(val);
|
|
23286
|
-
case "boolean": return String(val);
|
|
23287
|
-
case "bigint": return `${val}n`;
|
|
23288
|
-
case "undefined": return "undefined";
|
|
23289
|
-
case "symbol": return val.description === void 0 ? "Symbol()" : `Symbol(${JSON.stringify(val.description)})`;
|
|
23290
|
-
case "function": return `<function ${JSON.stringify(val.name)}>`;
|
|
23291
|
-
}
|
|
23292
|
-
if (val === null) return "null";
|
|
23293
|
-
const obj = val;
|
|
23294
|
-
const first = seen.get(obj);
|
|
23295
|
-
if (first !== void 0) return `<ref ${first}>`;
|
|
23296
|
-
const className = registeredClassName(obj);
|
|
23297
|
-
const named = (key) => className === void 0 ? key : `Class(${JSON.stringify(className)})${key}`;
|
|
23298
|
-
const withFields = (key) => {
|
|
23299
|
-
const keys = className === void 0 ? [] : extraKeys(obj);
|
|
23300
|
-
return named(keys.length ? `${key}${fieldsOf(obj, keys, seen)}` : key);
|
|
23301
|
-
};
|
|
23302
|
-
if (val instanceof Date || val instanceof RegExp) {
|
|
23303
|
-
if (className !== void 0 && extraKeys(obj).length) seen.set(obj, seen.size);
|
|
23304
|
-
return withFields(val instanceof Date ? `Date(${Date.prototype.getTime.call(val)})` : `RegExp(${regExpText(val)}@${val.lastIndex})`);
|
|
23305
|
-
}
|
|
23306
|
-
seen.set(obj, seen.size);
|
|
23307
|
-
if (Array.isArray(val)) {
|
|
23308
|
-
const items = [];
|
|
23309
|
-
for (let i = 0; i < val.length; i++) items.push(i in val ? keyOf(val[i], seen) : HOLE);
|
|
23310
|
-
return withFields(`[${items.join(",")}]`);
|
|
23311
|
-
}
|
|
23312
|
-
const atomic = atomicKey(obj, seen);
|
|
23313
|
-
if (atomic !== void 0) return named(atomic);
|
|
23314
|
-
if (val instanceof Map) return withFields(`Map[${Array.from(mapEntries(val), ([k, v]) => `[${keyOf(k, seen)},${keyOf(v, seen)}]`).join(",")}]`);
|
|
23315
|
-
if (val instanceof Set) return withFields(`Set[${Array.from(setMembers(val), (v) => keyOf(v, seen)).join(",")}]`);
|
|
23316
|
-
return named(fieldsOf(obj, Object.keys(obj), seen));
|
|
23317
|
-
}
|
|
23318
|
-
/**
|
|
23319
|
-
* The key of an atomic built-in other than a Map, Set, Date or RegExp (see
|
|
23320
|
-
* isAtomic), or undefined for any other object. Read with the built-in
|
|
23321
|
-
* methods, as a subclass may override them.
|
|
23322
|
-
*/
|
|
23323
|
-
function atomicKey(obj, seen) {
|
|
23324
|
-
if (obj instanceof ArrayBuffer) return `ArrayBuffer[${new Uint8Array(obj).join(",")}]`;
|
|
23325
|
-
if (ArrayBuffer.isView(obj)) return `${toStringTag(obj)}(${obj.byteOffset},${obj.byteLength},${keyOf(obj.buffer, seen)})`;
|
|
23326
|
-
let key;
|
|
23327
|
-
if (obj instanceof URL) key = `URL(${JSON.stringify(Object.getOwnPropertyDescriptor(URL.prototype, "href").get.call(obj))})`;
|
|
23328
|
-
else if (obj instanceof URLSearchParams) key = `URLSearchParams(${JSON.stringify(URLSearchParams.prototype.toString.call(obj))})`;
|
|
23329
|
-
else if (isBoxed(obj)) key = `${toStringTag(obj)}(${keyOf(obj.valueOf(), seen)})`;
|
|
23330
|
-
else if (isTemporal(obj)) key = `${toStringTag(obj)}(${JSON.stringify(String(obj))})`;
|
|
23331
|
-
else if (obj instanceof Error) {
|
|
23332
|
-
const record = obj;
|
|
23333
|
-
const held = ERROR_HIDDEN_KEYS$1.filter((k) => hasOwn(obj, k)).map((k) => `${k}:${keyOf(record[k], seen)}`);
|
|
23334
|
-
const ctor = Object.getPrototypeOf(obj)?.constructor;
|
|
23335
|
-
const name = typeof ctor === "function" ? ctor.name : "";
|
|
23336
|
-
key = `Error(${JSON.stringify(name)},${held.join(",")})`;
|
|
23337
|
-
} else return;
|
|
23338
|
-
const keys = Object.keys(obj);
|
|
23339
|
-
return keys.length ? `${key}${fieldsOf(obj, keys, seen)}` : key;
|
|
23340
|
-
}
|
|
23341
|
-
/** `{"key":value,...}` for the `keys` of `obj`. */
|
|
23342
|
-
function fieldsOf(obj, keys, seen) {
|
|
23343
|
-
const record = obj;
|
|
23344
|
-
return `{${keys.map((k) => `${JSON.stringify(k)}:${keyOf(record[k], seen)}`).join(",")}}`;
|
|
23345
|
-
}
|
|
23346
|
-
//#endregion
|
|
23347
23586
|
//#region src/components/macros/For.tsx
|
|
23348
23587
|
/**
|
|
23349
23588
|
* Check the arguments of "@item, @i of $list" or "@item of $list".
|