@rohal12/spindle 0.62.1 → 0.62.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 +642 -330
- package/dist/pkg/story-variables.js +701 -430
- package/dist/pkg/tooling.js +1 -0
- package/package.json +1 -1
- package/src/code-check.ts +25 -10
- package/src/completion-context.ts +226 -0
- package/src/components/Passage.tsx +28 -3
- package/src/define-macro.ts +6 -1
- package/src/format/source-lines.ts +4 -14
- package/src/hooks/use-modal-focus.ts +140 -46
- package/src/index.tsx +29 -10
- package/src/js-bindings.ts +29 -3
- package/src/macro-discovery.ts +34 -18
- package/src/markup/ast.ts +11 -6
- package/src/markup/code-attributes.ts +10 -3
- package/src/markup/line-column.ts +19 -0
- package/src/markup/pair.ts +4 -2
- package/src/markup/parse.ts +30 -9
- package/src/markup/spindle.d.peggy.ts +2 -0
- package/src/markup/spindle.peggy +22 -13
- package/src/markup/validate.ts +30 -3
- package/src/passage-render-state.ts +7 -0
- package/src/saves/format.ts +4 -0
- package/src/saves/types.ts +6 -6
- package/src/static-literal.ts +24 -22
- package/src/store.ts +42 -16
- package/src/story-variables.ts +14 -3
- package/src/tooling.ts +14 -3
- package/src/triggers.ts +107 -0
- package/src/twine-editor/references.ts +9 -11
- package/src/widgets/ast-scanner.ts +40 -44
- package/src/widgets/widget-def.ts +74 -45
- package/types/tooling.d.ts +17 -0
package/dist/pkg/headless.js
CHANGED
|
@@ -1087,23 +1087,29 @@ function peg$parse(input, options) {
|
|
|
1087
1087
|
return [body ? lexeme("text", loc, { value: body }) : null, end];
|
|
1088
1088
|
}
|
|
1089
1089
|
function peg$f16() {
|
|
1090
|
+
return completionMode;
|
|
1091
|
+
}
|
|
1092
|
+
function peg$f17(body) {
|
|
1093
|
+
return lexeme("text", location(), { value: body });
|
|
1094
|
+
}
|
|
1095
|
+
function peg$f18() {
|
|
1090
1096
|
return offset();
|
|
1091
1097
|
}
|
|
1092
|
-
function peg$
|
|
1098
|
+
function peg$f19(value) {
|
|
1093
1099
|
return lexeme("text", location(), { value });
|
|
1094
1100
|
}
|
|
1095
|
-
function peg$
|
|
1101
|
+
function peg$f20(value) {
|
|
1096
1102
|
const node = lexeme("text", location(), { value });
|
|
1097
1103
|
node.comment = true;
|
|
1098
1104
|
return node;
|
|
1099
1105
|
}
|
|
1100
|
-
function peg$
|
|
1106
|
+
function peg$f21(bs) {
|
|
1101
1107
|
return bs.length % 2 === 1;
|
|
1102
1108
|
}
|
|
1103
|
-
function peg$
|
|
1109
|
+
function peg$f22(bs, c) {
|
|
1104
1110
|
return c;
|
|
1105
1111
|
}
|
|
1106
|
-
function peg$
|
|
1112
|
+
function peg$f23(bs, brace) {
|
|
1107
1113
|
const loc = location();
|
|
1108
1114
|
const next = input.charAt(loc.end.offset);
|
|
1109
1115
|
if (textMode) {
|
|
@@ -1120,48 +1126,48 @@ function peg$parse(input, options) {
|
|
|
1120
1126
|
escaped.escape = true;
|
|
1121
1127
|
return bs.length > 1 ? [before, escaped] : escaped;
|
|
1122
1128
|
}
|
|
1123
|
-
function peg$
|
|
1129
|
+
function peg$f24() {
|
|
1124
1130
|
return lexeme("text", location(), { value: LB });
|
|
1125
1131
|
}
|
|
1126
|
-
function peg$
|
|
1132
|
+
function peg$f25() {
|
|
1127
1133
|
return !textMode;
|
|
1128
1134
|
}
|
|
1129
|
-
function peg$
|
|
1135
|
+
function peg$f26() {
|
|
1130
1136
|
return lexeme("text", location(), { value: "<" });
|
|
1131
1137
|
}
|
|
1132
|
-
function peg$
|
|
1138
|
+
function peg$f27() {
|
|
1133
1139
|
return lexeme("text", location(), { value: "[" });
|
|
1134
1140
|
}
|
|
1135
|
-
function peg$
|
|
1141
|
+
function peg$f28() {
|
|
1136
1142
|
return !textMode;
|
|
1137
1143
|
}
|
|
1138
|
-
function peg$
|
|
1144
|
+
function peg$f29(ss, s, at, inner) {
|
|
1139
1145
|
const link = lexeme("link", location(), parseLink(inner, at, (separator) => linkSeparatorIndex(inner, at, separator)));
|
|
1140
1146
|
link.selectorSpan = selectorSpan(s, ss, at);
|
|
1141
1147
|
return withSelectors(link, s);
|
|
1142
1148
|
}
|
|
1143
|
-
function peg$
|
|
1149
|
+
function peg$f30() {
|
|
1144
1150
|
return !textMode;
|
|
1145
1151
|
}
|
|
1146
|
-
function peg$
|
|
1152
|
+
function peg$f31() {
|
|
1147
1153
|
fail("Unclosed link: [[ without ]]", location(), "unclosed-link");
|
|
1148
1154
|
}
|
|
1149
|
-
function peg$
|
|
1155
|
+
function peg$f32(parts) {
|
|
1150
1156
|
return selectorsOf(parts);
|
|
1151
1157
|
}
|
|
1152
|
-
function peg$
|
|
1158
|
+
function peg$f33() {
|
|
1153
1159
|
return NO_SELECTORS;
|
|
1154
1160
|
}
|
|
1155
|
-
function peg$
|
|
1161
|
+
function peg$f34(s, end) {
|
|
1156
1162
|
return {
|
|
1157
1163
|
...s,
|
|
1158
1164
|
end
|
|
1159
1165
|
};
|
|
1160
1166
|
}
|
|
1161
|
-
function peg$
|
|
1167
|
+
function peg$f35(prefix, name) {
|
|
1162
1168
|
return [prefix, name];
|
|
1163
1169
|
}
|
|
1164
|
-
function peg$
|
|
1170
|
+
function peg$f36(ss, s, sigil, nameStart, name) {
|
|
1165
1171
|
const variable = lexeme("variable", location(), {
|
|
1166
1172
|
name,
|
|
1167
1173
|
nameStart,
|
|
@@ -1171,7 +1177,7 @@ function peg$parse(input, options) {
|
|
|
1171
1177
|
variable.selectorSpan = selectorSpan(s, ss, nameStart - 1);
|
|
1172
1178
|
return withSelectors(variable, s);
|
|
1173
1179
|
}
|
|
1174
|
-
function peg$
|
|
1180
|
+
function peg$f37(ss, s, after, expression) {
|
|
1175
1181
|
const node = lexeme("expression", location(), {
|
|
1176
1182
|
expression,
|
|
1177
1183
|
expressionStart: after,
|
|
@@ -1180,28 +1186,33 @@ function peg$parse(input, options) {
|
|
|
1180
1186
|
node.selectorSpan = selectorSpan(s, ss, after);
|
|
1181
1187
|
return withSelectors(node, s);
|
|
1182
1188
|
}
|
|
1183
|
-
function peg$
|
|
1189
|
+
function peg$f38() {
|
|
1184
1190
|
fail("Unclosed {" + input.substr(location().end.offset, 1) + "…: no } ends it", location(), "unclosed-expression");
|
|
1185
1191
|
}
|
|
1186
|
-
function peg$
|
|
1187
|
-
|
|
1192
|
+
function peg$f39(start) {
|
|
1193
|
+
const end = hooks.closeBrace(input, start, start);
|
|
1194
|
+
return skipTo(end < 0 && completionMode ? input.length : end);
|
|
1188
1195
|
}
|
|
1189
|
-
function peg$
|
|
1196
|
+
function peg$f40(start) {
|
|
1190
1197
|
return skipEnd - offset();
|
|
1191
1198
|
}
|
|
1192
|
-
function peg$
|
|
1199
|
+
function peg$f41(start, code) {
|
|
1193
1200
|
return code;
|
|
1194
1201
|
}
|
|
1195
|
-
function peg$
|
|
1196
|
-
return
|
|
1202
|
+
function peg$f42() {
|
|
1203
|
+
return completionMode;
|
|
1197
1204
|
}
|
|
1198
|
-
function peg$
|
|
1205
|
+
function peg$f43(ss, s, start, close, name, nameEnd) {
|
|
1206
|
+
const end = hooks.closeBrace(input, nameEnd, start);
|
|
1207
|
+
return skipTo(end < 0 && completionMode ? input.length : end);
|
|
1208
|
+
}
|
|
1209
|
+
function peg$f44(ss, s, start, close, name, nameEnd) {
|
|
1199
1210
|
return skipEnd - offset();
|
|
1200
1211
|
}
|
|
1201
|
-
function peg$
|
|
1212
|
+
function peg$f45(ss, s, start, close, name, nameEnd, args) {
|
|
1202
1213
|
return args;
|
|
1203
1214
|
}
|
|
1204
|
-
function peg$
|
|
1215
|
+
function peg$f46(ss, s, start, close, name, nameEnd, tail) {
|
|
1205
1216
|
const loc = location();
|
|
1206
1217
|
const lower = name.toLowerCase();
|
|
1207
1218
|
const tag = lexeme("macro", loc, {
|
|
@@ -1214,7 +1225,7 @@ function peg$parse(input, options) {
|
|
|
1214
1225
|
tag.nameEnd = nameEnd;
|
|
1215
1226
|
tag.selectorSpan = selectorSpan(s, ss, start);
|
|
1216
1227
|
if (tail === null) fail("Unclosed {" + (close ? "/" : "") + name + "…: no } ends the macro", loc, "unclosed-macro");
|
|
1217
|
-
tag.rawArgs = tail.trim();
|
|
1228
|
+
tag.rawArgs = completionMode ? tail.trimStart() : tail.trim();
|
|
1218
1229
|
tag.argsStart = tag.rawArgs ? nameEnd + tail.length - tail.trimStart().length : nameEnd;
|
|
1219
1230
|
tag.argsEnd = tag.argsStart + tag.rawArgs.length;
|
|
1220
1231
|
if (close) {
|
|
@@ -1227,19 +1238,19 @@ function peg$parse(input, options) {
|
|
|
1227
1238
|
}
|
|
1228
1239
|
return tag;
|
|
1229
1240
|
}
|
|
1230
|
-
function peg$
|
|
1241
|
+
function peg$f47(s) {
|
|
1231
1242
|
fail("A closing tag starts with a letter after {/", location(), "invalid-closer");
|
|
1232
1243
|
}
|
|
1233
|
-
function peg$
|
|
1244
|
+
function peg$f48(value) {
|
|
1234
1245
|
return EMAIL_AUTOLINK.test(value);
|
|
1235
1246
|
}
|
|
1236
|
-
function peg$
|
|
1247
|
+
function peg$f49(value) {
|
|
1237
1248
|
return lexeme("text", location(), { value });
|
|
1238
1249
|
}
|
|
1239
|
-
function peg$
|
|
1250
|
+
function peg$f50(value) {
|
|
1240
1251
|
return lexeme("text", location(), { value });
|
|
1241
1252
|
}
|
|
1242
|
-
function peg$
|
|
1253
|
+
function peg$f51(tagStart, tag, list, slash) {
|
|
1243
1254
|
const lower = tag.toLowerCase();
|
|
1244
1255
|
return lexeme("html", location(), {
|
|
1245
1256
|
tag,
|
|
@@ -1252,7 +1263,7 @@ function peg$parse(input, options) {
|
|
|
1252
1263
|
isSelfClose: !!slash || VOID_TAGS.has(lower)
|
|
1253
1264
|
});
|
|
1254
1265
|
}
|
|
1255
|
-
function peg$
|
|
1266
|
+
function peg$f52(tag, bad) {
|
|
1256
1267
|
const c = input.charAt(bad);
|
|
1257
1268
|
if (!c) fail("Unclosed tag <" + tag + ": no > ends it (write < for a < that starts no tag)", location(), "unclosed-tag");
|
|
1258
1269
|
const at = {
|
|
@@ -1270,7 +1281,7 @@ function peg$parse(input, options) {
|
|
|
1270
1281
|
};
|
|
1271
1282
|
fail("Unexpected " + JSON.stringify(c) + " in the tag <" + tag + ">: expected an attribute, or > to end the tag", at, "unexpected-character");
|
|
1272
1283
|
}
|
|
1273
|
-
function peg$
|
|
1284
|
+
function peg$f53(tagStart, tag) {
|
|
1274
1285
|
return lexeme("html", location(), {
|
|
1275
1286
|
tag,
|
|
1276
1287
|
lower: tag.toLowerCase(),
|
|
@@ -1282,14 +1293,14 @@ function peg$parse(input, options) {
|
|
|
1282
1293
|
isSelfClose: false
|
|
1283
1294
|
});
|
|
1284
1295
|
}
|
|
1285
|
-
function peg$
|
|
1296
|
+
function peg$f54(nameStart, name) {
|
|
1286
1297
|
attrCode = hooks.isCodeAttribute(name);
|
|
1287
1298
|
return true;
|
|
1288
1299
|
}
|
|
1289
|
-
function peg$
|
|
1300
|
+
function peg$f55(nameStart, name, v) {
|
|
1290
1301
|
return v;
|
|
1291
1302
|
}
|
|
1292
|
-
function peg$
|
|
1303
|
+
function peg$f56(nameStart, name, value) {
|
|
1293
1304
|
const attribute = {
|
|
1294
1305
|
name,
|
|
1295
1306
|
value: value ? value.value : "",
|
|
@@ -1303,7 +1314,7 @@ function peg$parse(input, options) {
|
|
|
1303
1314
|
}
|
|
1304
1315
|
return attribute;
|
|
1305
1316
|
}
|
|
1306
|
-
function peg$
|
|
1317
|
+
function peg$f57(start, value, end) {
|
|
1307
1318
|
return {
|
|
1308
1319
|
value,
|
|
1309
1320
|
start,
|
|
@@ -1311,7 +1322,7 @@ function peg$parse(input, options) {
|
|
|
1311
1322
|
quote: "\""
|
|
1312
1323
|
};
|
|
1313
1324
|
}
|
|
1314
|
-
function peg$
|
|
1325
|
+
function peg$f58(start, value, end) {
|
|
1315
1326
|
return {
|
|
1316
1327
|
value,
|
|
1317
1328
|
start,
|
|
@@ -1319,35 +1330,36 @@ function peg$parse(input, options) {
|
|
|
1319
1330
|
quote: "'"
|
|
1320
1331
|
};
|
|
1321
1332
|
}
|
|
1322
|
-
function peg$
|
|
1333
|
+
function peg$f59(q) {
|
|
1323
1334
|
fail("Unclosed attribute value: the " + q + " here has no closing " + q, location(), "unclosed-attribute");
|
|
1324
1335
|
}
|
|
1325
|
-
function peg$
|
|
1336
|
+
function peg$f60(start, value, end) {
|
|
1326
1337
|
return {
|
|
1327
1338
|
value,
|
|
1328
1339
|
start,
|
|
1329
1340
|
end
|
|
1330
1341
|
};
|
|
1331
1342
|
}
|
|
1332
|
-
function peg$
|
|
1343
|
+
function peg$f61() {
|
|
1333
1344
|
return !attrCode;
|
|
1334
1345
|
}
|
|
1335
|
-
function peg$
|
|
1346
|
+
function peg$f62(bs) {
|
|
1336
1347
|
return bs.length % 2 === 1;
|
|
1337
1348
|
}
|
|
1338
|
-
function peg$
|
|
1349
|
+
function peg$f63() {
|
|
1339
1350
|
return !attrCode;
|
|
1340
1351
|
}
|
|
1341
|
-
function peg$
|
|
1342
|
-
|
|
1352
|
+
function peg$f64(start, nameEnd) {
|
|
1353
|
+
const end = hooks.closeBrace(input, nameEnd, start);
|
|
1354
|
+
return skipTo(end < 0 && completionMode ? input.length : end);
|
|
1343
1355
|
}
|
|
1344
|
-
function peg$
|
|
1356
|
+
function peg$f65(start, nameEnd) {
|
|
1345
1357
|
return skipEnd - offset();
|
|
1346
1358
|
}
|
|
1347
|
-
function peg$
|
|
1359
|
+
function peg$f66() {
|
|
1348
1360
|
return !attrCode;
|
|
1349
1361
|
}
|
|
1350
|
-
function peg$
|
|
1362
|
+
function peg$f67() {
|
|
1351
1363
|
return attrCode;
|
|
1352
1364
|
}
|
|
1353
1365
|
let peg$currPos = options.peg$currPos | 0;
|
|
@@ -1686,6 +1698,40 @@ function peg$parse(input, options) {
|
|
|
1686
1698
|
peg$currPos = s0;
|
|
1687
1699
|
s0 = peg$FAILED;
|
|
1688
1700
|
}
|
|
1701
|
+
if (s0 === peg$FAILED) {
|
|
1702
|
+
s0 = peg$currPos;
|
|
1703
|
+
peg$savedPos = peg$currPos;
|
|
1704
|
+
s1 = peg$f16();
|
|
1705
|
+
if (s1) s1 = void 0;
|
|
1706
|
+
else s1 = peg$FAILED;
|
|
1707
|
+
if (s1 !== peg$FAILED) {
|
|
1708
|
+
s2 = peg$currPos;
|
|
1709
|
+
s3 = [];
|
|
1710
|
+
if (input.length > peg$currPos) {
|
|
1711
|
+
s4 = input.charAt(peg$currPos);
|
|
1712
|
+
peg$currPos++;
|
|
1713
|
+
} else {
|
|
1714
|
+
s4 = peg$FAILED;
|
|
1715
|
+
if (peg$silentFails === 0) peg$fail(peg$e0);
|
|
1716
|
+
}
|
|
1717
|
+
while (s4 !== peg$FAILED) {
|
|
1718
|
+
s3.push(s4);
|
|
1719
|
+
if (input.length > peg$currPos) {
|
|
1720
|
+
s4 = input.charAt(peg$currPos);
|
|
1721
|
+
peg$currPos++;
|
|
1722
|
+
} else {
|
|
1723
|
+
s4 = peg$FAILED;
|
|
1724
|
+
if (peg$silentFails === 0) peg$fail(peg$e0);
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
s2 = input.substring(s2, peg$currPos);
|
|
1728
|
+
peg$savedPos = s0;
|
|
1729
|
+
s0 = peg$f17(s2);
|
|
1730
|
+
} else {
|
|
1731
|
+
peg$currPos = s0;
|
|
1732
|
+
s0 = peg$FAILED;
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1689
1735
|
return s0;
|
|
1690
1736
|
}
|
|
1691
1737
|
function peg$parseHere() {
|
|
@@ -1693,7 +1739,7 @@ function peg$parse(input, options) {
|
|
|
1693
1739
|
s0 = peg$currPos;
|
|
1694
1740
|
s1 = "";
|
|
1695
1741
|
peg$savedPos = s0;
|
|
1696
|
-
s1 = peg$
|
|
1742
|
+
s1 = peg$f18();
|
|
1697
1743
|
s0 = s1;
|
|
1698
1744
|
return s0;
|
|
1699
1745
|
}
|
|
@@ -1722,7 +1768,7 @@ function peg$parse(input, options) {
|
|
|
1722
1768
|
else s1 = s2;
|
|
1723
1769
|
if (s1 !== peg$FAILED) {
|
|
1724
1770
|
peg$savedPos = s0;
|
|
1725
|
-
s1 = peg$
|
|
1771
|
+
s1 = peg$f19(s1);
|
|
1726
1772
|
}
|
|
1727
1773
|
s0 = s1;
|
|
1728
1774
|
return s0;
|
|
@@ -1838,6 +1884,7 @@ function peg$parse(input, options) {
|
|
|
1838
1884
|
s6 = peg$FAILED;
|
|
1839
1885
|
if (peg$silentFails === 0) peg$fail(peg$e5);
|
|
1840
1886
|
}
|
|
1887
|
+
if (s6 === peg$FAILED) s6 = peg$parseOpenEnd();
|
|
1841
1888
|
if (s6 !== peg$FAILED) {
|
|
1842
1889
|
s5 = [s5, s6];
|
|
1843
1890
|
s4 = s5;
|
|
@@ -1862,7 +1909,7 @@ function peg$parse(input, options) {
|
|
|
1862
1909
|
else s1 = s2;
|
|
1863
1910
|
if (s1 !== peg$FAILED) {
|
|
1864
1911
|
peg$savedPos = s0;
|
|
1865
|
-
s1 = peg$
|
|
1912
|
+
s1 = peg$f20(s1);
|
|
1866
1913
|
}
|
|
1867
1914
|
s0 = s1;
|
|
1868
1915
|
return s0;
|
|
@@ -1895,7 +1942,7 @@ function peg$parse(input, options) {
|
|
|
1895
1942
|
if (s1 !== peg$FAILED) {
|
|
1896
1943
|
s2 = peg$currPos;
|
|
1897
1944
|
peg$savedPos = peg$currPos;
|
|
1898
|
-
s3 = peg$
|
|
1945
|
+
s3 = peg$f21(s1);
|
|
1899
1946
|
if (s3) s3 = void 0;
|
|
1900
1947
|
else s3 = peg$FAILED;
|
|
1901
1948
|
if (s3 !== peg$FAILED) {
|
|
@@ -1907,7 +1954,7 @@ function peg$parse(input, options) {
|
|
|
1907
1954
|
}
|
|
1908
1955
|
if (s4 !== peg$FAILED) {
|
|
1909
1956
|
peg$savedPos = s2;
|
|
1910
|
-
s2 = peg$
|
|
1957
|
+
s2 = peg$f22(s1, s4);
|
|
1911
1958
|
} else {
|
|
1912
1959
|
peg$currPos = s2;
|
|
1913
1960
|
s2 = peg$FAILED;
|
|
@@ -1918,7 +1965,7 @@ function peg$parse(input, options) {
|
|
|
1918
1965
|
}
|
|
1919
1966
|
if (s2 === peg$FAILED) s2 = null;
|
|
1920
1967
|
peg$savedPos = s0;
|
|
1921
|
-
s0 = peg$
|
|
1968
|
+
s0 = peg$f23(s1, s2);
|
|
1922
1969
|
} else {
|
|
1923
1970
|
peg$currPos = s0;
|
|
1924
1971
|
s0 = peg$FAILED;
|
|
@@ -1966,7 +2013,7 @@ function peg$parse(input, options) {
|
|
|
1966
2013
|
}
|
|
1967
2014
|
if (s2 !== peg$FAILED) {
|
|
1968
2015
|
peg$savedPos = s0;
|
|
1969
|
-
s0 = peg$
|
|
2016
|
+
s0 = peg$f24();
|
|
1970
2017
|
} else {
|
|
1971
2018
|
peg$currPos = s0;
|
|
1972
2019
|
s0 = peg$FAILED;
|
|
@@ -1981,7 +2028,7 @@ function peg$parse(input, options) {
|
|
|
1981
2028
|
peg$silentFails++;
|
|
1982
2029
|
s2 = peg$currPos;
|
|
1983
2030
|
peg$savedPos = peg$currPos;
|
|
1984
|
-
s3 = peg$
|
|
2031
|
+
s3 = peg$f25();
|
|
1985
2032
|
if (s3) s3 = void 0;
|
|
1986
2033
|
else s3 = peg$FAILED;
|
|
1987
2034
|
if (s3 !== peg$FAILED) {
|
|
@@ -2013,7 +2060,7 @@ function peg$parse(input, options) {
|
|
|
2013
2060
|
}
|
|
2014
2061
|
if (s2 !== peg$FAILED) {
|
|
2015
2062
|
peg$savedPos = s0;
|
|
2016
|
-
s0 = peg$
|
|
2063
|
+
s0 = peg$f26();
|
|
2017
2064
|
} else {
|
|
2018
2065
|
peg$currPos = s0;
|
|
2019
2066
|
s0 = peg$FAILED;
|
|
@@ -2033,7 +2080,7 @@ function peg$parse(input, options) {
|
|
|
2033
2080
|
}
|
|
2034
2081
|
if (s1 !== peg$FAILED) {
|
|
2035
2082
|
peg$savedPos = s0;
|
|
2036
|
-
s1 = peg$
|
|
2083
|
+
s1 = peg$f27();
|
|
2037
2084
|
}
|
|
2038
2085
|
s0 = s1;
|
|
2039
2086
|
}
|
|
@@ -2044,7 +2091,7 @@ function peg$parse(input, options) {
|
|
|
2044
2091
|
let s0, s1, s2, s3, s4, s5, s6, s7;
|
|
2045
2092
|
s0 = peg$currPos;
|
|
2046
2093
|
peg$savedPos = peg$currPos;
|
|
2047
|
-
s1 = peg$
|
|
2094
|
+
s1 = peg$f28();
|
|
2048
2095
|
if (s1) s1 = void 0;
|
|
2049
2096
|
else s1 = peg$FAILED;
|
|
2050
2097
|
if (s1 !== peg$FAILED) {
|
|
@@ -2070,9 +2117,10 @@ function peg$parse(input, options) {
|
|
|
2070
2117
|
s7 = peg$FAILED;
|
|
2071
2118
|
if (peg$silentFails === 0) peg$fail(peg$e13);
|
|
2072
2119
|
}
|
|
2120
|
+
if (s7 === peg$FAILED) s7 = peg$parseOpenEnd();
|
|
2073
2121
|
if (s7 !== peg$FAILED) {
|
|
2074
2122
|
peg$savedPos = s0;
|
|
2075
|
-
s0 = peg$
|
|
2123
|
+
s0 = peg$f29(s3, s4, s5, s6);
|
|
2076
2124
|
} else {
|
|
2077
2125
|
peg$currPos = s0;
|
|
2078
2126
|
s0 = peg$FAILED;
|
|
@@ -2092,7 +2140,7 @@ function peg$parse(input, options) {
|
|
|
2092
2140
|
if (s0 === peg$FAILED) {
|
|
2093
2141
|
s0 = peg$currPos;
|
|
2094
2142
|
peg$savedPos = peg$currPos;
|
|
2095
|
-
s1 = peg$
|
|
2143
|
+
s1 = peg$f30();
|
|
2096
2144
|
if (s1) s1 = void 0;
|
|
2097
2145
|
else s1 = peg$FAILED;
|
|
2098
2146
|
if (s1 !== peg$FAILED) {
|
|
@@ -2105,7 +2153,7 @@ function peg$parse(input, options) {
|
|
|
2105
2153
|
}
|
|
2106
2154
|
if (s2 !== peg$FAILED) {
|
|
2107
2155
|
peg$savedPos = s0;
|
|
2108
|
-
s0 = peg$
|
|
2156
|
+
s0 = peg$f31();
|
|
2109
2157
|
} else {
|
|
2110
2158
|
peg$currPos = s0;
|
|
2111
2159
|
s0 = peg$FAILED;
|
|
@@ -2233,7 +2281,7 @@ function peg$parse(input, options) {
|
|
|
2233
2281
|
}
|
|
2234
2282
|
if (s2 === peg$FAILED) s2 = null;
|
|
2235
2283
|
peg$savedPos = s0;
|
|
2236
|
-
s0 = peg$
|
|
2284
|
+
s0 = peg$f32(s1);
|
|
2237
2285
|
} else {
|
|
2238
2286
|
peg$currPos = s0;
|
|
2239
2287
|
s0 = peg$FAILED;
|
|
@@ -2242,7 +2290,7 @@ function peg$parse(input, options) {
|
|
|
2242
2290
|
s0 = peg$currPos;
|
|
2243
2291
|
s1 = "";
|
|
2244
2292
|
peg$savedPos = s0;
|
|
2245
|
-
s1 = peg$
|
|
2293
|
+
s1 = peg$f33();
|
|
2246
2294
|
s0 = s1;
|
|
2247
2295
|
}
|
|
2248
2296
|
return s0;
|
|
@@ -2272,7 +2320,7 @@ function peg$parse(input, options) {
|
|
|
2272
2320
|
}
|
|
2273
2321
|
}
|
|
2274
2322
|
peg$savedPos = s0;
|
|
2275
|
-
s0 = peg$
|
|
2323
|
+
s0 = peg$f34(s1, s2);
|
|
2276
2324
|
} else {
|
|
2277
2325
|
peg$currPos = s0;
|
|
2278
2326
|
s0 = peg$FAILED;
|
|
@@ -2298,7 +2346,7 @@ function peg$parse(input, options) {
|
|
|
2298
2346
|
}
|
|
2299
2347
|
s2 = input.substring(s2, peg$currPos);
|
|
2300
2348
|
peg$savedPos = s0;
|
|
2301
|
-
s0 = peg$
|
|
2349
|
+
s0 = peg$f35(s1, s2);
|
|
2302
2350
|
} else {
|
|
2303
2351
|
peg$currPos = s0;
|
|
2304
2352
|
s0 = peg$FAILED;
|
|
@@ -2416,16 +2464,10 @@ function peg$parse(input, options) {
|
|
|
2416
2464
|
}
|
|
2417
2465
|
}
|
|
2418
2466
|
s6 = input.substring(s6, peg$currPos);
|
|
2419
|
-
|
|
2420
|
-
s7 = peg$c11;
|
|
2421
|
-
peg$currPos++;
|
|
2422
|
-
} else {
|
|
2423
|
-
s7 = peg$FAILED;
|
|
2424
|
-
if (peg$silentFails === 0) peg$fail(peg$e19);
|
|
2425
|
-
}
|
|
2467
|
+
s7 = peg$parseBraceEnd();
|
|
2426
2468
|
if (s7 !== peg$FAILED) {
|
|
2427
2469
|
peg$savedPos = s0;
|
|
2428
|
-
s0 = peg$
|
|
2470
|
+
s0 = peg$f36(s2, s3, s4, s5, s6);
|
|
2429
2471
|
} else {
|
|
2430
2472
|
peg$currPos = s0;
|
|
2431
2473
|
s0 = peg$FAILED;
|
|
@@ -2472,16 +2514,10 @@ function peg$parse(input, options) {
|
|
|
2472
2514
|
if (s5 !== peg$FAILED) {
|
|
2473
2515
|
s6 = peg$parseCodeToBrace();
|
|
2474
2516
|
if (s6 !== peg$FAILED) {
|
|
2475
|
-
|
|
2476
|
-
s7 = peg$c11;
|
|
2477
|
-
peg$currPos++;
|
|
2478
|
-
} else {
|
|
2479
|
-
s7 = peg$FAILED;
|
|
2480
|
-
if (peg$silentFails === 0) peg$fail(peg$e19);
|
|
2481
|
-
}
|
|
2517
|
+
s7 = peg$parseBraceEnd();
|
|
2482
2518
|
if (s7 !== peg$FAILED) {
|
|
2483
2519
|
peg$savedPos = s0;
|
|
2484
|
-
s0 = peg$
|
|
2520
|
+
s0 = peg$f37(s2, s3, s4, s6);
|
|
2485
2521
|
} else {
|
|
2486
2522
|
peg$currPos = s0;
|
|
2487
2523
|
s0 = peg$FAILED;
|
|
@@ -2529,7 +2565,7 @@ function peg$parse(input, options) {
|
|
|
2529
2565
|
} else s3 = peg$FAILED;
|
|
2530
2566
|
if (s3 !== peg$FAILED) {
|
|
2531
2567
|
peg$savedPos = s0;
|
|
2532
|
-
s0 = peg$
|
|
2568
|
+
s0 = peg$f38();
|
|
2533
2569
|
} else {
|
|
2534
2570
|
peg$currPos = s0;
|
|
2535
2571
|
s0 = peg$FAILED;
|
|
@@ -2551,12 +2587,12 @@ function peg$parse(input, options) {
|
|
|
2551
2587
|
s0 = peg$currPos;
|
|
2552
2588
|
s1 = peg$parseHere();
|
|
2553
2589
|
peg$savedPos = peg$currPos;
|
|
2554
|
-
s2 = peg$
|
|
2590
|
+
s2 = peg$f39(s1);
|
|
2555
2591
|
if (s2) s2 = void 0;
|
|
2556
2592
|
else s2 = peg$FAILED;
|
|
2557
2593
|
if (s2 !== peg$FAILED) {
|
|
2558
2594
|
s3 = peg$currPos;
|
|
2559
|
-
s4 = peg$
|
|
2595
|
+
s4 = peg$f40(s1);
|
|
2560
2596
|
s5 = peg$currPos;
|
|
2561
2597
|
s6 = [];
|
|
2562
2598
|
if (s6.length >= (s4 | 0)) s7 = peg$FAILED;
|
|
@@ -2587,7 +2623,7 @@ function peg$parse(input, options) {
|
|
|
2587
2623
|
else s3 = s4;
|
|
2588
2624
|
if (s3 !== peg$FAILED) {
|
|
2589
2625
|
peg$savedPos = s0;
|
|
2590
|
-
s0 = peg$
|
|
2626
|
+
s0 = peg$f41(s1, s3);
|
|
2591
2627
|
} else {
|
|
2592
2628
|
peg$currPos = s0;
|
|
2593
2629
|
s0 = peg$FAILED;
|
|
@@ -2598,6 +2634,54 @@ function peg$parse(input, options) {
|
|
|
2598
2634
|
}
|
|
2599
2635
|
return s0;
|
|
2600
2636
|
}
|
|
2637
|
+
function peg$parseOpenEnd() {
|
|
2638
|
+
let s0, s1, s2, s3;
|
|
2639
|
+
s0 = peg$currPos;
|
|
2640
|
+
peg$savedPos = peg$currPos;
|
|
2641
|
+
s1 = peg$f42();
|
|
2642
|
+
if (s1) s1 = void 0;
|
|
2643
|
+
else s1 = peg$FAILED;
|
|
2644
|
+
if (s1 !== peg$FAILED) {
|
|
2645
|
+
s2 = peg$currPos;
|
|
2646
|
+
peg$silentFails++;
|
|
2647
|
+
if (input.length > peg$currPos) {
|
|
2648
|
+
s3 = input.charAt(peg$currPos);
|
|
2649
|
+
peg$currPos++;
|
|
2650
|
+
} else {
|
|
2651
|
+
s3 = peg$FAILED;
|
|
2652
|
+
if (peg$silentFails === 0) peg$fail(peg$e0);
|
|
2653
|
+
}
|
|
2654
|
+
peg$silentFails--;
|
|
2655
|
+
if (s3 === peg$FAILED) s2 = void 0;
|
|
2656
|
+
else {
|
|
2657
|
+
peg$currPos = s2;
|
|
2658
|
+
s2 = peg$FAILED;
|
|
2659
|
+
}
|
|
2660
|
+
if (s2 !== peg$FAILED) {
|
|
2661
|
+
s1 = [s1, s2];
|
|
2662
|
+
s0 = s1;
|
|
2663
|
+
} else {
|
|
2664
|
+
peg$currPos = s0;
|
|
2665
|
+
s0 = peg$FAILED;
|
|
2666
|
+
}
|
|
2667
|
+
} else {
|
|
2668
|
+
peg$currPos = s0;
|
|
2669
|
+
s0 = peg$FAILED;
|
|
2670
|
+
}
|
|
2671
|
+
return s0;
|
|
2672
|
+
}
|
|
2673
|
+
function peg$parseBraceEnd() {
|
|
2674
|
+
let s0;
|
|
2675
|
+
if (input.charCodeAt(peg$currPos) === 125) {
|
|
2676
|
+
s0 = peg$c11;
|
|
2677
|
+
peg$currPos++;
|
|
2678
|
+
} else {
|
|
2679
|
+
s0 = peg$FAILED;
|
|
2680
|
+
if (peg$silentFails === 0) peg$fail(peg$e19);
|
|
2681
|
+
}
|
|
2682
|
+
if (s0 === peg$FAILED) s0 = peg$parseOpenEnd();
|
|
2683
|
+
return s0;
|
|
2684
|
+
}
|
|
2601
2685
|
function peg$parseMacroTag() {
|
|
2602
2686
|
let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14;
|
|
2603
2687
|
s0 = peg$currPos;
|
|
@@ -2626,12 +2710,12 @@ function peg$parse(input, options) {
|
|
|
2626
2710
|
s7 = peg$parseHere();
|
|
2627
2711
|
s8 = peg$currPos;
|
|
2628
2712
|
peg$savedPos = peg$currPos;
|
|
2629
|
-
s9 = peg$
|
|
2713
|
+
s9 = peg$f43(s2, s3, s4, s5, s6, s7);
|
|
2630
2714
|
if (s9) s9 = void 0;
|
|
2631
2715
|
else s9 = peg$FAILED;
|
|
2632
2716
|
if (s9 !== peg$FAILED) {
|
|
2633
2717
|
s10 = peg$currPos;
|
|
2634
|
-
s11 = peg$
|
|
2718
|
+
s11 = peg$f44(s2, s3, s4, s5, s6, s7);
|
|
2635
2719
|
s12 = peg$currPos;
|
|
2636
2720
|
s13 = [];
|
|
2637
2721
|
if (s13.length >= (s11 | 0)) s14 = peg$FAILED;
|
|
@@ -2661,16 +2745,10 @@ function peg$parse(input, options) {
|
|
|
2661
2745
|
if (s11 !== peg$FAILED) s10 = input.substring(s10, peg$currPos);
|
|
2662
2746
|
else s10 = s11;
|
|
2663
2747
|
if (s10 !== peg$FAILED) {
|
|
2664
|
-
|
|
2665
|
-
s11 = peg$c11;
|
|
2666
|
-
peg$currPos++;
|
|
2667
|
-
} else {
|
|
2668
|
-
s11 = peg$FAILED;
|
|
2669
|
-
if (peg$silentFails === 0) peg$fail(peg$e19);
|
|
2670
|
-
}
|
|
2748
|
+
s11 = peg$parseBraceEnd();
|
|
2671
2749
|
if (s11 !== peg$FAILED) {
|
|
2672
2750
|
peg$savedPos = s8;
|
|
2673
|
-
s8 = peg$
|
|
2751
|
+
s8 = peg$f45(s2, s3, s4, s5, s6, s7, s10);
|
|
2674
2752
|
} else {
|
|
2675
2753
|
peg$currPos = s8;
|
|
2676
2754
|
s8 = peg$FAILED;
|
|
@@ -2685,7 +2763,7 @@ function peg$parse(input, options) {
|
|
|
2685
2763
|
}
|
|
2686
2764
|
if (s8 === peg$FAILED) s8 = null;
|
|
2687
2765
|
peg$savedPos = s0;
|
|
2688
|
-
s0 = peg$
|
|
2766
|
+
s0 = peg$f46(s2, s3, s4, s5, s6, s7, s8);
|
|
2689
2767
|
} else {
|
|
2690
2768
|
peg$currPos = s0;
|
|
2691
2769
|
s0 = peg$FAILED;
|
|
@@ -2719,7 +2797,7 @@ function peg$parse(input, options) {
|
|
|
2719
2797
|
}
|
|
2720
2798
|
if (s3 !== peg$FAILED) {
|
|
2721
2799
|
peg$savedPos = s0;
|
|
2722
|
-
s0 = peg$
|
|
2800
|
+
s0 = peg$f47(s2);
|
|
2723
2801
|
} else {
|
|
2724
2802
|
peg$currPos = s0;
|
|
2725
2803
|
s0 = peg$FAILED;
|
|
@@ -2869,12 +2947,12 @@ function peg$parse(input, options) {
|
|
|
2869
2947
|
else s1 = s2;
|
|
2870
2948
|
if (s1 !== peg$FAILED) {
|
|
2871
2949
|
peg$savedPos = peg$currPos;
|
|
2872
|
-
s2 = peg$
|
|
2950
|
+
s2 = peg$f48(s1);
|
|
2873
2951
|
if (s2) s2 = void 0;
|
|
2874
2952
|
else s2 = peg$FAILED;
|
|
2875
2953
|
if (s2 !== peg$FAILED) {
|
|
2876
2954
|
peg$savedPos = s0;
|
|
2877
|
-
s0 = peg$
|
|
2955
|
+
s0 = peg$f49(s1);
|
|
2878
2956
|
} else {
|
|
2879
2957
|
peg$currPos = s0;
|
|
2880
2958
|
s0 = peg$FAILED;
|
|
@@ -3051,7 +3129,7 @@ function peg$parse(input, options) {
|
|
|
3051
3129
|
else s1 = s2;
|
|
3052
3130
|
if (s1 !== peg$FAILED) {
|
|
3053
3131
|
peg$savedPos = s0;
|
|
3054
|
-
s1 = peg$
|
|
3132
|
+
s1 = peg$f50(s1);
|
|
3055
3133
|
}
|
|
3056
3134
|
s0 = s1;
|
|
3057
3135
|
return s0;
|
|
@@ -3092,9 +3170,10 @@ function peg$parse(input, options) {
|
|
|
3092
3170
|
s7 = peg$FAILED;
|
|
3093
3171
|
if (peg$silentFails === 0) peg$fail(peg$e3);
|
|
3094
3172
|
}
|
|
3173
|
+
if (s7 === peg$FAILED) s7 = peg$parseOpenEnd();
|
|
3095
3174
|
if (s7 !== peg$FAILED) {
|
|
3096
3175
|
peg$savedPos = s0;
|
|
3097
|
-
s0 = peg$
|
|
3176
|
+
s0 = peg$f51(s2, s3, s4, s6);
|
|
3098
3177
|
} else {
|
|
3099
3178
|
peg$currPos = s0;
|
|
3100
3179
|
s0 = peg$FAILED;
|
|
@@ -3159,7 +3238,7 @@ function peg$parse(input, options) {
|
|
|
3159
3238
|
s5 = peg$parse_();
|
|
3160
3239
|
s6 = peg$parseHere();
|
|
3161
3240
|
peg$savedPos = s0;
|
|
3162
|
-
s0 = peg$
|
|
3241
|
+
s0 = peg$f52(s2, s6);
|
|
3163
3242
|
} else {
|
|
3164
3243
|
peg$currPos = s0;
|
|
3165
3244
|
s0 = peg$FAILED;
|
|
@@ -3199,7 +3278,7 @@ function peg$parse(input, options) {
|
|
|
3199
3278
|
}
|
|
3200
3279
|
if (s5 !== peg$FAILED) {
|
|
3201
3280
|
peg$savedPos = s0;
|
|
3202
|
-
s0 = peg$
|
|
3281
|
+
s0 = peg$f53(s2, s3);
|
|
3203
3282
|
} else {
|
|
3204
3283
|
peg$currPos = s0;
|
|
3205
3284
|
s0 = peg$FAILED;
|
|
@@ -3334,7 +3413,7 @@ function peg$parse(input, options) {
|
|
|
3334
3413
|
else s3 = s4;
|
|
3335
3414
|
if (s3 !== peg$FAILED) {
|
|
3336
3415
|
peg$savedPos = peg$currPos;
|
|
3337
|
-
s4 = peg$
|
|
3416
|
+
s4 = peg$f54(s2, s3);
|
|
3338
3417
|
if (s4) s4 = void 0;
|
|
3339
3418
|
else s4 = peg$FAILED;
|
|
3340
3419
|
if (s4 !== peg$FAILED) {
|
|
@@ -3352,7 +3431,7 @@ function peg$parse(input, options) {
|
|
|
3352
3431
|
s9 = peg$parseAttrValue();
|
|
3353
3432
|
if (s9 !== peg$FAILED) {
|
|
3354
3433
|
peg$savedPos = s5;
|
|
3355
|
-
s5 = peg$
|
|
3434
|
+
s5 = peg$f55(s2, s3, s9);
|
|
3356
3435
|
} else {
|
|
3357
3436
|
peg$currPos = s5;
|
|
3358
3437
|
s5 = peg$FAILED;
|
|
@@ -3363,7 +3442,7 @@ function peg$parse(input, options) {
|
|
|
3363
3442
|
}
|
|
3364
3443
|
if (s5 === peg$FAILED) s5 = null;
|
|
3365
3444
|
peg$savedPos = s0;
|
|
3366
|
-
s0 = peg$
|
|
3445
|
+
s0 = peg$f56(s2, s3, s5);
|
|
3367
3446
|
} else {
|
|
3368
3447
|
peg$currPos = s0;
|
|
3369
3448
|
s0 = peg$FAILED;
|
|
@@ -3418,9 +3497,10 @@ function peg$parse(input, options) {
|
|
|
3418
3497
|
s5 = peg$FAILED;
|
|
3419
3498
|
if (peg$silentFails === 0) peg$fail(peg$e35);
|
|
3420
3499
|
}
|
|
3500
|
+
if (s5 === peg$FAILED) s5 = peg$parseOpenEnd();
|
|
3421
3501
|
if (s5 !== peg$FAILED) {
|
|
3422
3502
|
peg$savedPos = s0;
|
|
3423
|
-
s0 = peg$
|
|
3503
|
+
s0 = peg$f57(s2, s3, s4);
|
|
3424
3504
|
} else {
|
|
3425
3505
|
peg$currPos = s0;
|
|
3426
3506
|
s0 = peg$FAILED;
|
|
@@ -3472,9 +3552,10 @@ function peg$parse(input, options) {
|
|
|
3472
3552
|
s5 = peg$FAILED;
|
|
3473
3553
|
if (peg$silentFails === 0) peg$fail(peg$e37);
|
|
3474
3554
|
}
|
|
3555
|
+
if (s5 === peg$FAILED) s5 = peg$parseOpenEnd();
|
|
3475
3556
|
if (s5 !== peg$FAILED) {
|
|
3476
3557
|
peg$savedPos = s0;
|
|
3477
|
-
s0 = peg$
|
|
3558
|
+
s0 = peg$f58(s2, s3, s4);
|
|
3478
3559
|
} else {
|
|
3479
3560
|
peg$currPos = s0;
|
|
3480
3561
|
s0 = peg$FAILED;
|
|
@@ -3493,7 +3574,7 @@ function peg$parse(input, options) {
|
|
|
3493
3574
|
}
|
|
3494
3575
|
if (s1 !== peg$FAILED) {
|
|
3495
3576
|
peg$savedPos = s0;
|
|
3496
|
-
s1 = peg$
|
|
3577
|
+
s1 = peg$f59(s1);
|
|
3497
3578
|
}
|
|
3498
3579
|
s0 = s1;
|
|
3499
3580
|
if (s0 === peg$FAILED) {
|
|
@@ -3519,7 +3600,7 @@ function peg$parse(input, options) {
|
|
|
3519
3600
|
s2 = input.substring(s2, peg$currPos);
|
|
3520
3601
|
s3 = peg$parseHere();
|
|
3521
3602
|
peg$savedPos = s0;
|
|
3522
|
-
s0 = peg$
|
|
3603
|
+
s0 = peg$f60(s1, s2, s3);
|
|
3523
3604
|
}
|
|
3524
3605
|
}
|
|
3525
3606
|
}
|
|
@@ -3529,7 +3610,7 @@ function peg$parse(input, options) {
|
|
|
3529
3610
|
let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13;
|
|
3530
3611
|
s0 = peg$currPos;
|
|
3531
3612
|
peg$savedPos = peg$currPos;
|
|
3532
|
-
s1 = peg$
|
|
3613
|
+
s1 = peg$f61();
|
|
3533
3614
|
if (s1) s1 = void 0;
|
|
3534
3615
|
else s1 = peg$FAILED;
|
|
3535
3616
|
if (s1 !== peg$FAILED) {
|
|
@@ -3558,7 +3639,7 @@ function peg$parse(input, options) {
|
|
|
3558
3639
|
if (s2 !== peg$FAILED) {
|
|
3559
3640
|
s3 = peg$currPos;
|
|
3560
3641
|
peg$savedPos = peg$currPos;
|
|
3561
|
-
s4 = peg$
|
|
3642
|
+
s4 = peg$f62(s2);
|
|
3562
3643
|
if (s4) s4 = void 0;
|
|
3563
3644
|
else s4 = peg$FAILED;
|
|
3564
3645
|
if (s4 !== peg$FAILED) {
|
|
@@ -3597,7 +3678,7 @@ function peg$parse(input, options) {
|
|
|
3597
3678
|
if (s0 === peg$FAILED) {
|
|
3598
3679
|
s0 = peg$currPos;
|
|
3599
3680
|
peg$savedPos = peg$currPos;
|
|
3600
|
-
s1 = peg$
|
|
3681
|
+
s1 = peg$f63();
|
|
3601
3682
|
if (s1) s1 = void 0;
|
|
3602
3683
|
else s1 = peg$FAILED;
|
|
3603
3684
|
if (s1 !== peg$FAILED) {
|
|
@@ -3624,12 +3705,12 @@ function peg$parse(input, options) {
|
|
|
3624
3705
|
if (s6 !== peg$FAILED) {
|
|
3625
3706
|
s7 = peg$parseHere();
|
|
3626
3707
|
peg$savedPos = peg$currPos;
|
|
3627
|
-
s8 = peg$
|
|
3708
|
+
s8 = peg$f64(s4, s7);
|
|
3628
3709
|
if (s8) s8 = void 0;
|
|
3629
3710
|
else s8 = peg$FAILED;
|
|
3630
3711
|
if (s8 !== peg$FAILED) {
|
|
3631
3712
|
s9 = peg$currPos;
|
|
3632
|
-
s10 = peg$
|
|
3713
|
+
s10 = peg$f65(s4, s7);
|
|
3633
3714
|
s11 = peg$currPos;
|
|
3634
3715
|
s12 = [];
|
|
3635
3716
|
if (s12.length >= (s10 | 0)) s13 = peg$FAILED;
|
|
@@ -3659,13 +3740,7 @@ function peg$parse(input, options) {
|
|
|
3659
3740
|
if (s10 !== peg$FAILED) s9 = input.substring(s9, peg$currPos);
|
|
3660
3741
|
else s9 = s10;
|
|
3661
3742
|
if (s9 !== peg$FAILED) {
|
|
3662
|
-
|
|
3663
|
-
s10 = peg$c11;
|
|
3664
|
-
peg$currPos++;
|
|
3665
|
-
} else {
|
|
3666
|
-
s10 = peg$FAILED;
|
|
3667
|
-
if (peg$silentFails === 0) peg$fail(peg$e19);
|
|
3668
|
-
}
|
|
3743
|
+
s10 = peg$parseBraceEnd();
|
|
3669
3744
|
if (s10 !== peg$FAILED) {
|
|
3670
3745
|
s1 = [
|
|
3671
3746
|
s1,
|
|
@@ -3711,7 +3786,7 @@ function peg$parse(input, options) {
|
|
|
3711
3786
|
if (s0 === peg$FAILED) {
|
|
3712
3787
|
s0 = peg$currPos;
|
|
3713
3788
|
peg$savedPos = peg$currPos;
|
|
3714
|
-
s1 = peg$
|
|
3789
|
+
s1 = peg$f66();
|
|
3715
3790
|
if (s1) s1 = void 0;
|
|
3716
3791
|
else s1 = peg$FAILED;
|
|
3717
3792
|
if (s1 !== peg$FAILED) {
|
|
@@ -3758,13 +3833,7 @@ function peg$parse(input, options) {
|
|
|
3758
3833
|
if (s4 !== peg$FAILED) {
|
|
3759
3834
|
s5 = peg$parseCodeToBrace();
|
|
3760
3835
|
if (s5 !== peg$FAILED) {
|
|
3761
|
-
|
|
3762
|
-
s6 = peg$c11;
|
|
3763
|
-
peg$currPos++;
|
|
3764
|
-
} else {
|
|
3765
|
-
s6 = peg$FAILED;
|
|
3766
|
-
if (peg$silentFails === 0) peg$fail(peg$e19);
|
|
3767
|
-
}
|
|
3836
|
+
s6 = peg$parseBraceEnd();
|
|
3768
3837
|
if (s6 !== peg$FAILED) {
|
|
3769
3838
|
s1 = [
|
|
3770
3839
|
s1,
|
|
@@ -3802,7 +3871,7 @@ function peg$parse(input, options) {
|
|
|
3802
3871
|
if (s0 === peg$FAILED) {
|
|
3803
3872
|
s0 = peg$currPos;
|
|
3804
3873
|
peg$savedPos = peg$currPos;
|
|
3805
|
-
s1 = peg$
|
|
3874
|
+
s1 = peg$f67();
|
|
3806
3875
|
if (s1) s1 = void 0;
|
|
3807
3876
|
else s1 = peg$FAILED;
|
|
3808
3877
|
if (s1 !== peg$FAILED) {
|
|
@@ -3830,13 +3899,7 @@ function peg$parse(input, options) {
|
|
|
3830
3899
|
if (s3 !== peg$FAILED) {
|
|
3831
3900
|
s4 = peg$parseCodeToBrace();
|
|
3832
3901
|
if (s4 !== peg$FAILED) {
|
|
3833
|
-
|
|
3834
|
-
s5 = peg$c11;
|
|
3835
|
-
peg$currPos++;
|
|
3836
|
-
} else {
|
|
3837
|
-
s5 = peg$FAILED;
|
|
3838
|
-
if (peg$silentFails === 0) peg$fail(peg$e19);
|
|
3839
|
-
}
|
|
3902
|
+
s5 = peg$parseBraceEnd();
|
|
3840
3903
|
if (s5 !== peg$FAILED) {
|
|
3841
3904
|
s1 = [
|
|
3842
3905
|
s1,
|
|
@@ -3892,6 +3955,7 @@ function peg$parse(input, options) {
|
|
|
3892
3955
|
return s0;
|
|
3893
3956
|
}
|
|
3894
3957
|
const textMode = options.text === true;
|
|
3958
|
+
const completionMode = options.completion === true;
|
|
3895
3959
|
const hooks = options.hooks;
|
|
3896
3960
|
/** End of the stretch a `.|n|` repetition consumes (see skipTo). */
|
|
3897
3961
|
let skipEnd = -1;
|
|
@@ -4045,6 +4109,8 @@ var BLOCK_MACROS = new NameSet([
|
|
|
4045
4109
|
* definition is, whereas the macros in BLOCK_MACROS stay blocks.
|
|
4046
4110
|
*/
|
|
4047
4111
|
var BLOCK_WIDGETS = new NameSet();
|
|
4112
|
+
/** All widgets, including inline ones, override built-in parsing semantics. */
|
|
4113
|
+
var WIDGETS = new NameSet();
|
|
4048
4114
|
/** Classification owned by defineMacro, independent of explicit registrations. */
|
|
4049
4115
|
var DEFINED_BLOCK_MACROS = new NameSet();
|
|
4050
4116
|
function setDefinedBlockMacro(name, isBlock) {
|
|
@@ -4058,8 +4124,8 @@ function setClassification(names, name, block) {
|
|
|
4058
4124
|
/** Macros whose body is JavaScript source, kept verbatim. */
|
|
4059
4125
|
var RAW_BODY_MACROS = /* @__PURE__ */ new Set(["do"]);
|
|
4060
4126
|
/** Whether a macro's body is JavaScript, kept verbatim (`{do}`). */
|
|
4061
|
-
function isRawMacro(name) {
|
|
4062
|
-
return RAW_BODY_MACROS.has(name);
|
|
4127
|
+
function isRawMacro(name, widget = WIDGETS.has(name)) {
|
|
4128
|
+
return RAW_BODY_MACROS.has(name.toLowerCase()) && !widget;
|
|
4063
4129
|
}
|
|
4064
4130
|
/** Whether a macro takes a body closed by `{/name}`. */
|
|
4065
4131
|
function isBlockMacro(name) {
|
|
@@ -4070,6 +4136,7 @@ function isBlockMacro(name) {
|
|
|
4070
4136
|
* does. A block macro registered under the same name stays a block.
|
|
4071
4137
|
*/
|
|
4072
4138
|
function setBlockWidget(name, isBlock) {
|
|
4139
|
+
WIDGETS.add(name);
|
|
4073
4140
|
setClassification(BLOCK_WIDGETS, name, isBlock);
|
|
4074
4141
|
}
|
|
4075
4142
|
/** Macros whose branches render as one: the node holds one per branch. */
|
|
@@ -4125,7 +4192,8 @@ function astNode({ token, body }) {
|
|
|
4125
4192
|
};
|
|
4126
4193
|
if (!body) return withSelectors$1(node, token);
|
|
4127
4194
|
const children = buildAst(body.children);
|
|
4128
|
-
|
|
4195
|
+
const branching = BRANCHING.has(name) && !WIDGETS.has(name);
|
|
4196
|
+
if (!branching && body.branches.length === 0) {
|
|
4129
4197
|
node.children = children;
|
|
4130
4198
|
return withSelectors$1(node, token);
|
|
4131
4199
|
}
|
|
@@ -4133,9 +4201,9 @@ function astNode({ token, body }) {
|
|
|
4133
4201
|
rawArgs: tag.rawArgs,
|
|
4134
4202
|
children: branchChildren
|
|
4135
4203
|
}, tag);
|
|
4136
|
-
if (!
|
|
4137
|
-
node.branches = [...
|
|
4138
|
-
return
|
|
4204
|
+
if (!branching) node.children = children;
|
|
4205
|
+
node.branches = [...branching ? [branch(token, children)] : [], ...body.branches.map(({ tag, children: c }) => branch(tag, buildAst(c)))];
|
|
4206
|
+
return branching ? node : withSelectors$1(node, token);
|
|
4139
4207
|
}
|
|
4140
4208
|
}
|
|
4141
4209
|
}
|
|
@@ -4279,6 +4347,25 @@ function lineColumn(text, offset) {
|
|
|
4279
4347
|
column: offset - lineStart + 1
|
|
4280
4348
|
};
|
|
4281
4349
|
}
|
|
4350
|
+
/** Index one source once; offsets and columns count UTF-16 code units. */
|
|
4351
|
+
function sourcePositions(text) {
|
|
4352
|
+
const starts = [0];
|
|
4353
|
+
for (let i = 0; i < text.length; i++) if (text[i] === "\n") starts.push(i + 1);
|
|
4354
|
+
return (offset) => {
|
|
4355
|
+
let low = 0;
|
|
4356
|
+
let high = starts.length;
|
|
4357
|
+
while (low < high) {
|
|
4358
|
+
const mid = low + high >>> 1;
|
|
4359
|
+
if (starts[mid] <= offset) low = mid + 1;
|
|
4360
|
+
else high = mid;
|
|
4361
|
+
}
|
|
4362
|
+
const line = Math.max(1, low);
|
|
4363
|
+
return {
|
|
4364
|
+
line,
|
|
4365
|
+
column: offset - starts[line - 1] + 1
|
|
4366
|
+
};
|
|
4367
|
+
};
|
|
4368
|
+
}
|
|
4282
4369
|
//#endregion
|
|
4283
4370
|
//#region src/markup/pair.ts
|
|
4284
4371
|
/**
|
|
@@ -4330,9 +4417,11 @@ function pairMarkup(tokens, options = {}) {
|
|
|
4330
4417
|
};
|
|
4331
4418
|
const errors = [];
|
|
4332
4419
|
const noticedAtEnd = (tokens[tokens.length - 1]?.end ?? 0) + 1;
|
|
4420
|
+
let position;
|
|
4333
4421
|
const where = (offset) => {
|
|
4334
4422
|
if (options.source === void 0) return `offset ${offset}`;
|
|
4335
|
-
|
|
4423
|
+
position ??= sourcePositions(options.source);
|
|
4424
|
+
const { line, column } = position(offset);
|
|
4336
4425
|
return `line ${line}, column ${column}`;
|
|
4337
4426
|
};
|
|
4338
4427
|
const report = (code, token, message, noticedAt, data) => {
|
|
@@ -10679,7 +10768,7 @@ function isCodeAttribute(name) {
|
|
|
10679
10768
|
* sigil is not followed by a word character (`{$(…)}`) is code, kept
|
|
10680
10769
|
* verbatim: not resolved, and not decoded like text.
|
|
10681
10770
|
*/
|
|
10682
|
-
function splitSigilTemplate(template) {
|
|
10771
|
+
function splitSigilTemplate(template, incomplete = false) {
|
|
10683
10772
|
const parts = [];
|
|
10684
10773
|
let text = "";
|
|
10685
10774
|
let i = 0;
|
|
@@ -10691,7 +10780,8 @@ function splitSigilTemplate(template) {
|
|
|
10691
10780
|
}
|
|
10692
10781
|
text += template.slice(i, brace);
|
|
10693
10782
|
i = brace + 1;
|
|
10694
|
-
|
|
10783
|
+
let end = isSigil(template[i]) ? defaultCodeEnd.closeBrace(template, i, i) : -1;
|
|
10784
|
+
if (end === -1 && incomplete && isSigil(template[i])) end = template.length;
|
|
10695
10785
|
if (end === -1) {
|
|
10696
10786
|
text += "{";
|
|
10697
10787
|
continue;
|
|
@@ -10699,7 +10789,7 @@ function splitSigilTemplate(template) {
|
|
|
10699
10789
|
if (text) parts.push({ text });
|
|
10700
10790
|
text = "";
|
|
10701
10791
|
const block = template.slice(i, end);
|
|
10702
|
-
parts.push(/^.\w/.test(block) ? { expr: block } : { verbatim: `{${block}}` });
|
|
10792
|
+
parts.push(/^.\w/.test(block) || incomplete && block.length === 1 && end === template.length ? { expr: block } : { verbatim: `{${block}}` });
|
|
10703
10793
|
i = end + 1;
|
|
10704
10794
|
}
|
|
10705
10795
|
if (text) parts.push({ text });
|
|
@@ -10732,7 +10822,7 @@ var MarkupError = class extends Error {
|
|
|
10732
10822
|
this.name = "MarkupError";
|
|
10733
10823
|
}
|
|
10734
10824
|
};
|
|
10735
|
-
function run$2(source, startRule, options) {
|
|
10825
|
+
function run$2(source, startRule, options, completion = false) {
|
|
10736
10826
|
const hooks = options.hooks ? {
|
|
10737
10827
|
...defaultHooks,
|
|
10738
10828
|
...options.hooks
|
|
@@ -10741,7 +10831,8 @@ function run$2(source, startRule, options) {
|
|
|
10741
10831
|
return peg$parse(source, {
|
|
10742
10832
|
startRule,
|
|
10743
10833
|
text: options.text === true,
|
|
10744
|
-
hooks
|
|
10834
|
+
hooks,
|
|
10835
|
+
completion
|
|
10745
10836
|
});
|
|
10746
10837
|
} catch (err) {
|
|
10747
10838
|
const { location, code } = err;
|
|
@@ -10778,7 +10869,8 @@ function analyzeMarkup(source, options = {}) {
|
|
|
10778
10869
|
};
|
|
10779
10870
|
const inDamage = (start) => errors.some((e, i) => start >= damage[i] && start <= e.offset);
|
|
10780
10871
|
const noticed = errors.map((e, i) => [damage[i] + .5, e]);
|
|
10781
|
-
|
|
10872
|
+
const position = paired.errors.length ? sourcePositions(source) : void 0;
|
|
10873
|
+
for (const error of paired.errors) if (!inDamage(error.start)) noticed.push([error.noticedAt, pairingError(position, error)]);
|
|
10782
10874
|
noticed.sort((a, b) => a[0] - b[0]);
|
|
10783
10875
|
return {
|
|
10784
10876
|
tokens,
|
|
@@ -10797,8 +10889,8 @@ function parseMarkup(source, options = {}) {
|
|
|
10797
10889
|
return buildAst(nodes);
|
|
10798
10890
|
}
|
|
10799
10891
|
/** A pairing problem as the MarkupError it is for `source`. */
|
|
10800
|
-
function pairingError(
|
|
10801
|
-
const { line, column } =
|
|
10892
|
+
function pairingError(position, error) {
|
|
10893
|
+
const { line, column } = position(error.start);
|
|
10802
10894
|
return new MarkupError(error.message, error.start, line, column, error.code, error.end, error.data);
|
|
10803
10895
|
}
|
|
10804
10896
|
/**
|
|
@@ -10829,10 +10921,11 @@ function tokenizeMarkupTolerant(source, options = {}) {
|
|
|
10829
10921
|
* each error starts (`damage[i]` for `errors[i]`): the tag that is
|
|
10830
10922
|
* malformed, which an error inside it (an attribute value) is after.
|
|
10831
10923
|
*/
|
|
10832
|
-
function scanMarkupTolerant(source, options = {}) {
|
|
10924
|
+
function scanMarkupTolerant(source, options = {}, completion = false) {
|
|
10833
10925
|
const tokens = [];
|
|
10834
10926
|
const errors = [];
|
|
10835
10927
|
const damage = [];
|
|
10928
|
+
let position;
|
|
10836
10929
|
const lastBrace = source.lastIndexOf("}");
|
|
10837
10930
|
const { closeBrace } = {
|
|
10838
10931
|
...defaultHooks,
|
|
@@ -10845,10 +10938,10 @@ function scanMarkupTolerant(source, options = {}) {
|
|
|
10845
10938
|
closeBrace: (input, codeStart, lenientStart) => base + Math.min(codeStart, lenientStart) > lastBrace ? -1 : closeBrace(input, codeStart, lenientStart)
|
|
10846
10939
|
};
|
|
10847
10940
|
try {
|
|
10848
|
-
return
|
|
10941
|
+
return run$2(text, "Tokens", {
|
|
10849
10942
|
...options,
|
|
10850
10943
|
hooks
|
|
10851
|
-
}).map((token) => shiftOffsets(token, base));
|
|
10944
|
+
}, completion).map((token) => shiftOffsets(token, base));
|
|
10852
10945
|
} catch (error) {
|
|
10853
10946
|
if (!(error instanceof MarkupError)) throw error;
|
|
10854
10947
|
return error;
|
|
@@ -10863,7 +10956,8 @@ function scanMarkupTolerant(source, options = {}) {
|
|
|
10863
10956
|
break;
|
|
10864
10957
|
}
|
|
10865
10958
|
const at = base + result.offset;
|
|
10866
|
-
|
|
10959
|
+
position ??= sourcePositions(source);
|
|
10960
|
+
const { line, column } = position(at);
|
|
10867
10961
|
errors.push(new MarkupError(result.reason, at, line, column, result.code, base + result.end));
|
|
10868
10962
|
let cut = result.offset;
|
|
10869
10963
|
let prefix = attempt(rest.slice(0, cut), base);
|
|
@@ -11889,14 +11983,16 @@ function* codeAndText(src, tokens, parametersOf) {
|
|
|
11889
11983
|
* `src`. In source order, a nested piece after the text it is in.
|
|
11890
11984
|
*/
|
|
11891
11985
|
function* passagePiecesOf(src, tokens, parametersOf, options = {}) {
|
|
11892
|
-
|
|
11986
|
+
let position;
|
|
11987
|
+
const locate = (offset) => (position ??= sourcePositions(src))(offset);
|
|
11988
|
+
yield* expand(src, src, tokens, parametersOf, options, (i) => i, void 0, locate);
|
|
11893
11989
|
}
|
|
11894
11990
|
/**
|
|
11895
11991
|
* The pieces of `tokens`, the tokens of `src`, which is the text described by
|
|
11896
11992
|
* `where` (none for `root`, the markup of the whole passage), and whose
|
|
11897
11993
|
* offsets `toRoot` turns into offsets in `root`.
|
|
11898
11994
|
*/
|
|
11899
|
-
function* expand(root, src, tokens, parametersOf, options, toRoot, where) {
|
|
11995
|
+
function* expand(root, src, tokens, parametersOf, options, toRoot, where, locate) {
|
|
11900
11996
|
for (const flat of codeAndText(src, tokens, parametersOf)) {
|
|
11901
11997
|
const piece = where ? nestedPiece(flat, toRoot, where) : flat;
|
|
11902
11998
|
if (flat.kind !== "text" || !flat.text.includes("{")) {
|
|
@@ -11906,17 +12002,20 @@ function* expand(root, src, tokens, parametersOf, options, toRoot, where) {
|
|
|
11906
12002
|
const toText = (i) => toRoot(pieceOffset(flat, i));
|
|
11907
12003
|
const inner = analyzeMarkup(flat.text, {
|
|
11908
12004
|
text: true,
|
|
11909
|
-
hooks:
|
|
12005
|
+
hooks: {
|
|
12006
|
+
...options.isBlock && { isBlock: options.isBlock },
|
|
12007
|
+
isRaw: (name) => isRawMacro(name, parametersOf.widget?.(name) !== void 0)
|
|
12008
|
+
}
|
|
11910
12009
|
});
|
|
11911
12010
|
yield {
|
|
11912
12011
|
...piece,
|
|
11913
12012
|
tokens: inner.tokens.map((t) => mapOffsets(t, toText)),
|
|
11914
12013
|
errors: inner.errors.map((e) => {
|
|
11915
|
-
const { line, column } =
|
|
12014
|
+
const { line, column } = locate(toText(e.offset));
|
|
11916
12015
|
return new MarkupError(e.reason, toText(e.offset), line, column, e.code, toText(e.end), e.data);
|
|
11917
12016
|
})
|
|
11918
12017
|
};
|
|
11919
|
-
yield* expand(root, flat.text, inner.tokens, parametersOf, options, toText, flat.where);
|
|
12018
|
+
yield* expand(root, flat.text, inner.tokens, parametersOf, options, toText, flat.where, locate);
|
|
11920
12019
|
}
|
|
11921
12020
|
}
|
|
11922
12021
|
/** `piece`, of a text in another, with its offsets turned by `toRoot`. */
|
|
@@ -12194,25 +12293,29 @@ var registeredParameters = (name) => parameterLookup(getMacroRegistry())(name);
|
|
|
12194
12293
|
* Whether the text of an attribute value or macro label renders a
|
|
12195
12294
|
* `{@children}`: it is markup, parsed as the renderer parses it.
|
|
12196
12295
|
*/
|
|
12197
|
-
function textContainsChildren(text, parametersOf) {
|
|
12296
|
+
function textContainsChildren(text, parametersOf, hooks) {
|
|
12198
12297
|
if (!text.includes("{")) return false;
|
|
12199
12298
|
let nodes;
|
|
12200
12299
|
try {
|
|
12201
|
-
nodes = parseMarkup(text, {
|
|
12300
|
+
nodes = parseMarkup(text, {
|
|
12301
|
+
text: true,
|
|
12302
|
+
hooks
|
|
12303
|
+
});
|
|
12202
12304
|
} catch {
|
|
12203
12305
|
return false;
|
|
12204
12306
|
}
|
|
12205
|
-
return astContainsChildren(nodes, parametersOf);
|
|
12307
|
+
return astContainsChildren(nodes, parametersOf, hooks);
|
|
12206
12308
|
}
|
|
12207
12309
|
/**
|
|
12208
12310
|
* Whether a tag renders a `{@children}` in an attribute value or a macro
|
|
12209
12311
|
* argument that holds markup (`<span title="{@children}">`,
|
|
12210
12312
|
* `{button "{@children}"}`). Literal arguments and code are not markup.
|
|
12211
12313
|
* `src` is the text a flat token's offsets index into (its attribute values
|
|
12212
|
-
* are read from it); a token made from an AST has none.
|
|
12314
|
+
* are read from it); a token made from an AST has none. Discovery hooks
|
|
12315
|
+
* also apply inside these texts, before widgets have been registered.
|
|
12213
12316
|
*/
|
|
12214
|
-
function tokenTextContainsChildren(token, parametersOf = registeredParameters, src = "") {
|
|
12215
|
-
for (const piece of codeAndText(src, [token], parametersOf)) if (piece.kind === "text" && textContainsChildren(piece.text, parametersOf)) return true;
|
|
12317
|
+
function tokenTextContainsChildren(token, parametersOf = registeredParameters, src = "", hooks) {
|
|
12318
|
+
for (const piece of codeAndText(src, [token], parametersOf)) if (piece.kind === "text" && textContainsChildren(piece.text, parametersOf, hooks)) return true;
|
|
12216
12319
|
return false;
|
|
12217
12320
|
}
|
|
12218
12321
|
/**
|
|
@@ -12222,36 +12325,33 @@ function tokenTextContainsChildren(token, parametersOf = registeredParameters, s
|
|
|
12222
12325
|
* entered: its slot belongs to the innermost widget (as widgetDefinitions
|
|
12223
12326
|
* reads it), and a definition renders nothing of its own.
|
|
12224
12327
|
*/
|
|
12225
|
-
function astContainsChildren(nodes, parametersOf = registeredParameters) {
|
|
12328
|
+
function astContainsChildren(nodes, parametersOf = registeredParameters, hooks) {
|
|
12226
12329
|
for (const node of nodes) {
|
|
12227
12330
|
if (node.type === "variable" && node.scope === "local" && node.name === "children") return true;
|
|
12228
|
-
if (node.type
|
|
12229
|
-
|
|
12230
|
-
|
|
12231
|
-
|
|
12232
|
-
|
|
12233
|
-
|
|
12234
|
-
|
|
12235
|
-
|
|
12236
|
-
|
|
12237
|
-
|
|
12238
|
-
|
|
12239
|
-
|
|
12240
|
-
|
|
12241
|
-
|
|
12242
|
-
|
|
12243
|
-
|
|
12244
|
-
|
|
12245
|
-
|
|
12246
|
-
|
|
12247
|
-
|
|
12248
|
-
|
|
12249
|
-
|
|
12250
|
-
|
|
12251
|
-
|
|
12252
|
-
if (node.branches) {
|
|
12253
|
-
for (const branch of node.branches) if (astContainsChildren(branch.children, parametersOf)) return true;
|
|
12254
|
-
}
|
|
12331
|
+
if (node.type !== "html" && node.type !== "macro") continue;
|
|
12332
|
+
if (node.type === "macro" && node.name.toLowerCase() === "widget") continue;
|
|
12333
|
+
const span = {
|
|
12334
|
+
isClose: false,
|
|
12335
|
+
start: 0,
|
|
12336
|
+
end: 0
|
|
12337
|
+
};
|
|
12338
|
+
if (tokenTextContainsChildren(node.type === "html" ? {
|
|
12339
|
+
...node,
|
|
12340
|
+
...span,
|
|
12341
|
+
isSelfClose: false,
|
|
12342
|
+
tagNameStart: 0,
|
|
12343
|
+
tagNameEnd: 0,
|
|
12344
|
+
attributeSpans: []
|
|
12345
|
+
} : {
|
|
12346
|
+
...node,
|
|
12347
|
+
...span,
|
|
12348
|
+
nameStart: 0,
|
|
12349
|
+
nameEnd: 0,
|
|
12350
|
+
argsStart: 0,
|
|
12351
|
+
argsEnd: 0
|
|
12352
|
+
}, parametersOf, "", hooks) || astContainsChildren(node.children, parametersOf, hooks)) return true;
|
|
12353
|
+
if (node.type === "macro" && node.branches) {
|
|
12354
|
+
for (const branch of node.branches) if (astContainsChildren(branch.children, parametersOf, hooks)) return true;
|
|
12255
12355
|
}
|
|
12256
12356
|
}
|
|
12257
12357
|
return false;
|
|
@@ -12333,42 +12433,48 @@ function nameSpan(rawArgs) {
|
|
|
12333
12433
|
* nested definitions, it belongs to the innermost.
|
|
12334
12434
|
*/
|
|
12335
12435
|
function widgetDefinitions(passages, parametersOf = registeredParameters) {
|
|
12336
|
-
const
|
|
12337
|
-
|
|
12338
|
-
|
|
12339
|
-
const
|
|
12340
|
-
const
|
|
12341
|
-
|
|
12342
|
-
|
|
12343
|
-
|
|
12344
|
-
|
|
12345
|
-
|
|
12346
|
-
|
|
12347
|
-
|
|
12348
|
-
if (def) done.push({
|
|
12349
|
-
...def,
|
|
12350
|
-
closeStart: token.start
|
|
12436
|
+
const list = [...passages];
|
|
12437
|
+
const scan = (replacesDo) => {
|
|
12438
|
+
const found = [];
|
|
12439
|
+
const hooks = { isRaw: (name) => isRawMacro(name, replacesDo || parametersOf.widget?.(name) !== void 0) };
|
|
12440
|
+
for (const passage of list) {
|
|
12441
|
+
if (passage.name !== "StoryInit" && !passage.tags?.includes("widget")) continue;
|
|
12442
|
+
const open = [];
|
|
12443
|
+
const done = [];
|
|
12444
|
+
for (const token of tokenizeMarkupTolerant(passage.content, { hooks }).tokens) if (token.type === "macro" && token.name.toLowerCase() === "widget") {
|
|
12445
|
+
if (!token.isClose) open.push({
|
|
12446
|
+
token,
|
|
12447
|
+
isBlock: false
|
|
12351
12448
|
});
|
|
12352
|
-
|
|
12353
|
-
|
|
12354
|
-
|
|
12355
|
-
|
|
12356
|
-
|
|
12357
|
-
|
|
12358
|
-
|
|
12359
|
-
|
|
12360
|
-
|
|
12361
|
-
|
|
12362
|
-
|
|
12363
|
-
|
|
12364
|
-
|
|
12365
|
-
|
|
12366
|
-
|
|
12367
|
-
|
|
12368
|
-
|
|
12369
|
-
|
|
12370
|
-
|
|
12371
|
-
|
|
12449
|
+
else {
|
|
12450
|
+
const def = open.pop();
|
|
12451
|
+
if (def) done.push({
|
|
12452
|
+
...def,
|
|
12453
|
+
closeStart: token.start
|
|
12454
|
+
});
|
|
12455
|
+
}
|
|
12456
|
+
} else if (open.length > 0 && (token.type === "variable" && token.scope === "local" && token.name === "children" || tokenTextContainsChildren(token, parametersOf, passage.content, hooks))) open[open.length - 1].isBlock = true;
|
|
12457
|
+
done.push(...open);
|
|
12458
|
+
const defs = [];
|
|
12459
|
+
for (const { token, isBlock, closeStart } of done) try {
|
|
12460
|
+
const [from, to] = nameSpan(token.rawArgs);
|
|
12461
|
+
defs.push({
|
|
12462
|
+
...parseWidgetDef(token.rawArgs),
|
|
12463
|
+
block: isBlock,
|
|
12464
|
+
passage: passage.name,
|
|
12465
|
+
start: token.start,
|
|
12466
|
+
end: token.end,
|
|
12467
|
+
nameStart: token.argsStart + from,
|
|
12468
|
+
nameEnd: token.argsStart + to,
|
|
12469
|
+
...closeStart === void 0 ? {} : { closeStart }
|
|
12470
|
+
});
|
|
12471
|
+
} catch {}
|
|
12472
|
+
found.push(...defs.sort((a, b) => a.start - b.start));
|
|
12473
|
+
}
|
|
12474
|
+
return found;
|
|
12475
|
+
};
|
|
12476
|
+
const initial = scan(false);
|
|
12477
|
+
return effectiveWidgetDefinitions(initial).some((def) => def.name.toLowerCase() === "do") ? scan(true) : initial;
|
|
12372
12478
|
}
|
|
12373
12479
|
/**
|
|
12374
12480
|
* The definitions the runtime ends up with, one per widget name: the closed
|
|
@@ -17044,7 +17150,25 @@ function executeMutation(code, mergedLocals, scopeUpdate) {
|
|
|
17044
17150
|
for (const key of Object.keys(mergedLocals)) if (!hasOwn(localsClone, key)) scopeUpdate(key, void 0);
|
|
17045
17151
|
}
|
|
17046
17152
|
//#endregion
|
|
17153
|
+
//#region src/passage-render-state.ts
|
|
17154
|
+
/** Initial render of a deferred passage subtree, until its first commit. */
|
|
17155
|
+
var EntryRenderContext = createContext(null);
|
|
17156
|
+
/**
|
|
17157
|
+
* Navigation id (the store's `navigationId`) of the passage most recently
|
|
17158
|
+
* mounted by <Passage> (null until the first render, e.g. when the story
|
|
17159
|
+
* interface has no {passage}). Lets Story.waitForActions() tell whether the
|
|
17160
|
+
* current navigation is on screen, also when it revisits the passage shown.
|
|
17161
|
+
*/
|
|
17162
|
+
var renderedNavigationId = null;
|
|
17163
|
+
function markPassageRendered(navigationId) {
|
|
17164
|
+
renderedNavigationId = navigationId;
|
|
17165
|
+
}
|
|
17166
|
+
function getRenderedNavigationId() {
|
|
17167
|
+
return renderedNavigationId;
|
|
17168
|
+
}
|
|
17169
|
+
//#endregion
|
|
17047
17170
|
//#region src/triggers.ts
|
|
17171
|
+
var registrations = 0;
|
|
17048
17172
|
var triggers = [];
|
|
17049
17173
|
var checking = false;
|
|
17050
17174
|
var dialogQueue = [];
|
|
@@ -17064,6 +17188,7 @@ function registerTrigger(condition, callbackOrOptions, macroKey) {
|
|
|
17064
17188
|
const options = isCallback ? void 0 : callbackOrOptions;
|
|
17065
17189
|
const callback = isCallback ? callbackOrOptions : void 0;
|
|
17066
17190
|
const trigger = {
|
|
17191
|
+
order: registrations++,
|
|
17067
17192
|
name: options?.name,
|
|
17068
17193
|
condition,
|
|
17069
17194
|
callback,
|
|
@@ -17095,6 +17220,73 @@ function addMacroTrigger(condition, options) {
|
|
|
17095
17220
|
if (triggers.some((t) => t.macroKey === macroKey)) return;
|
|
17096
17221
|
registerTrigger(condition, options, macroKey);
|
|
17097
17222
|
}
|
|
17223
|
+
var macroRenderDepth = 0;
|
|
17224
|
+
var entryRenderDepth = 0;
|
|
17225
|
+
var replayNavigation = -1;
|
|
17226
|
+
var replayRemoved = /* @__PURE__ */ new Map();
|
|
17227
|
+
/** Entry lifecycle callbacks and deferred initial passage subtrees replay on load. */
|
|
17228
|
+
function duringEntryRender(render) {
|
|
17229
|
+
entryRenderDepth++;
|
|
17230
|
+
try {
|
|
17231
|
+
return render();
|
|
17232
|
+
} finally {
|
|
17233
|
+
entryRenderDepth--;
|
|
17234
|
+
}
|
|
17235
|
+
}
|
|
17236
|
+
function isEntryRender() {
|
|
17237
|
+
return entryRenderDepth > 0 || macroRenderDepth > 0 && getRenderedNavigationId() !== useStoryStore.getState().navigationId;
|
|
17238
|
+
}
|
|
17239
|
+
function duringMacroRender(render) {
|
|
17240
|
+
macroRenderDepth++;
|
|
17241
|
+
try {
|
|
17242
|
+
return render();
|
|
17243
|
+
} finally {
|
|
17244
|
+
macroRenderDepth--;
|
|
17245
|
+
}
|
|
17246
|
+
}
|
|
17247
|
+
/** Forget replay removals whose effects have become part of a recorded entry. */
|
|
17248
|
+
function clearReplayWatchers() {
|
|
17249
|
+
replayRemoved.clear();
|
|
17250
|
+
}
|
|
17251
|
+
function replayRemovals() {
|
|
17252
|
+
const navigation = useStoryStore.getState().navigationId;
|
|
17253
|
+
if (navigation !== replayNavigation) {
|
|
17254
|
+
replayRemoved.clear();
|
|
17255
|
+
replayNavigation = navigation;
|
|
17256
|
+
}
|
|
17257
|
+
return replayRemoved;
|
|
17258
|
+
}
|
|
17259
|
+
function rememberRemoval(trigger) {
|
|
17260
|
+
const removed = replayRemovals();
|
|
17261
|
+
if (!trigger.macroKey || !trigger.options) return;
|
|
17262
|
+
if (isEntryRender()) {
|
|
17263
|
+
if (removed.has(trigger.macroKey)) return;
|
|
17264
|
+
removed.set(trigger.macroKey, {
|
|
17265
|
+
watcher: {
|
|
17266
|
+
condition: trigger.condition,
|
|
17267
|
+
options: { ...trigger.options }
|
|
17268
|
+
},
|
|
17269
|
+
order: trigger.order
|
|
17270
|
+
});
|
|
17271
|
+
} else removed.delete(trigger.macroKey);
|
|
17272
|
+
}
|
|
17273
|
+
/** Entry-render removals plus still active watchers, absent when none need replay. */
|
|
17274
|
+
function savedReplayWatchers() {
|
|
17275
|
+
const removed = replayRemovals();
|
|
17276
|
+
if (!removed.size) return void 0;
|
|
17277
|
+
const all = new Map(removed);
|
|
17278
|
+
for (const trigger of triggers) {
|
|
17279
|
+
if (!trigger.macroKey || !trigger.options || all.has(trigger.macroKey)) continue;
|
|
17280
|
+
all.set(trigger.macroKey, {
|
|
17281
|
+
watcher: {
|
|
17282
|
+
condition: trigger.condition,
|
|
17283
|
+
options: { ...trigger.options }
|
|
17284
|
+
},
|
|
17285
|
+
order: trigger.order
|
|
17286
|
+
});
|
|
17287
|
+
}
|
|
17288
|
+
return [...all.values()].sort((a, b) => a.order - b.order).map(({ watcher }) => watcher);
|
|
17289
|
+
}
|
|
17098
17290
|
/** Canonical identity includes every option, so an imported action cannot change it. */
|
|
17099
17291
|
function watcherKey(condition, options) {
|
|
17100
17292
|
const sorted = Object.fromEntries(Object.entries(options).sort(([a], [b]) => a < b ? -1 : 1));
|
|
@@ -17182,6 +17374,10 @@ function restoreMacroWatchers(watchers, interfaceSaved) {
|
|
|
17182
17374
|
for (const { condition, options } of interfaceWatches) addMacroTrigger(condition, options);
|
|
17183
17375
|
}
|
|
17184
17376
|
function removeTrigger(name) {
|
|
17377
|
+
for (const trigger of triggers) if (trigger.name === name) rememberRemoval(trigger);
|
|
17378
|
+
if (!isEntryRender()) {
|
|
17379
|
+
for (const [key, { watcher }] of replayRemovals()) if (watcher.options.name === name) replayRemoved.delete(key);
|
|
17380
|
+
}
|
|
17185
17381
|
triggers = triggers.filter((t) => t.name !== name);
|
|
17186
17382
|
}
|
|
17187
17383
|
function fireTrigger(trigger) {
|
|
@@ -17214,7 +17410,10 @@ function runCheckLoop() {
|
|
|
17214
17410
|
trigger.lastResult = result;
|
|
17215
17411
|
if (result && wasFalse) {
|
|
17216
17412
|
anyFired = true;
|
|
17217
|
-
if (trigger.options?.once)
|
|
17413
|
+
if (trigger.options?.once) {
|
|
17414
|
+
rememberRemoval(trigger);
|
|
17415
|
+
triggers = triggers.filter((t) => t !== trigger);
|
|
17416
|
+
}
|
|
17218
17417
|
fireTrigger(trigger);
|
|
17219
17418
|
}
|
|
17220
17419
|
}
|
|
@@ -17284,6 +17483,7 @@ function reinitTriggerState() {
|
|
|
17284
17483
|
*/
|
|
17285
17484
|
function resetTriggers() {
|
|
17286
17485
|
triggers = [];
|
|
17486
|
+
replayRemoved.clear();
|
|
17287
17487
|
resets++;
|
|
17288
17488
|
closeAllOpenDialogs();
|
|
17289
17489
|
resetListeners.notify();
|
|
@@ -17468,7 +17668,7 @@ function isPayload(value) {
|
|
|
17468
17668
|
if (!Array.isArray(history) || history.length === 0) return false;
|
|
17469
17669
|
if (!everyEntry(history, isMoment)) return false;
|
|
17470
17670
|
if (typeof historyIndex !== "number" || !Number.isInteger(historyIndex) || historyIndex < 0 || historyIndex >= history.length || history[historyIndex].passage !== value.passage) return false;
|
|
17471
|
-
return isCountsMap(value.visitCounts) && isCountsMap(value.renderCounts) && isOptionalPRNGSnapshot(value.prng) && isWatchers(value.watchers) && (value.interfaceWatchers === void 0 || typeof value.interfaceWatchers === "boolean");
|
|
17671
|
+
return isCountsMap(value.visitCounts) && isCountsMap(value.renderCounts) && isOptionalPRNGSnapshot(value.prng) && isWatchers(value.watchers) && isWatchers(value.replayWatchers) && (value.interfaceWatchers === void 0 || typeof value.interfaceWatchers === "boolean");
|
|
17472
17672
|
}
|
|
17473
17673
|
var mapToCounts = (counts) => counts instanceof Map ? createCounts(Object.fromEntries(counts)) : void 0;
|
|
17474
17674
|
/**
|
|
@@ -17486,6 +17686,7 @@ function decodePayload(encoded) {
|
|
|
17486
17686
|
if (!isPayload(body)) throw invalid();
|
|
17487
17687
|
assertArrayLengths(body, MAX_SAVE_ARRAY_LENGTH);
|
|
17488
17688
|
assertTrustedWatchers(body.watchers ?? []);
|
|
17689
|
+
assertTrustedWatchers(body.replayWatchers ?? []);
|
|
17489
17690
|
const payload = {
|
|
17490
17691
|
...body,
|
|
17491
17692
|
visitCounts: mapToCounts(body.visitCounts),
|
|
@@ -18858,6 +19059,7 @@ function computeVarPatches(prev, curr) {
|
|
|
18858
19059
|
* applyPatches copies each value, and recurses forever on a cycle).
|
|
18859
19060
|
*/
|
|
18860
19061
|
function applyVarPatches(vars, changes) {
|
|
19062
|
+
if (changes.length === 0) return vars;
|
|
18861
19063
|
const next = Object.create(Object.getPrototypeOf(vars));
|
|
18862
19064
|
for (const key of Object.keys(vars)) setOwn(next, key, vars[key]);
|
|
18863
19065
|
for (const change of changes) if (change.deleted) delete next[change.key];
|
|
@@ -18931,6 +19133,7 @@ function persistSession(get) {
|
|
|
18931
19133
|
renderCounts,
|
|
18932
19134
|
prng: snapshotPRNG(),
|
|
18933
19135
|
watchers: savedMacroWatchers(),
|
|
19136
|
+
replayWatchers: savedReplayWatchers(),
|
|
18934
19137
|
interfaceWatchers: interfaceMounted()
|
|
18935
19138
|
});
|
|
18936
19139
|
}
|
|
@@ -19002,6 +19205,7 @@ function finishEnteredMoment(get, set) {
|
|
|
19002
19205
|
const moment = enteredMoment;
|
|
19003
19206
|
enteredMoment = null;
|
|
19004
19207
|
if (!moment || get().navigationId !== moment.navigationId) return;
|
|
19208
|
+
clearReplayWatchers();
|
|
19005
19209
|
if (get().variables !== moment.variables) rerecordNewestMoment(get().variables);
|
|
19006
19210
|
lastNavigationVars = get().variables;
|
|
19007
19211
|
const prng = snapshotPRNG();
|
|
@@ -19110,6 +19314,7 @@ function recordStoryInitState() {
|
|
|
19110
19314
|
const { history, historyIndex, variables } = useStoryStore.getState();
|
|
19111
19315
|
if (history.length !== 1 || historyIndex !== 0) return;
|
|
19112
19316
|
resetModuleState(variables);
|
|
19317
|
+
clearReplayWatchers();
|
|
19113
19318
|
const prng = snapshotPRNG();
|
|
19114
19319
|
useStoryStore.setState((state) => {
|
|
19115
19320
|
state.history[0].prng = prng;
|
|
@@ -19874,6 +20079,7 @@ var useStoryStore = create()(storyStore((set, get) => ({
|
|
|
19874
20079
|
renderCounts: { ...renderCounts },
|
|
19875
20080
|
prng: snapshotPRNG(),
|
|
19876
20081
|
watchers: savedMacroWatchers(),
|
|
20082
|
+
replayWatchers: savedReplayWatchers(),
|
|
19877
20083
|
interfaceWatchers: interfaceMounted()
|
|
19878
20084
|
};
|
|
19879
20085
|
},
|
|
@@ -19902,6 +20108,7 @@ var useStoryStore = create()(storyStore((set, get) => ({
|
|
|
19902
20108
|
}
|
|
19903
20109
|
assertPassagesExist(get().storyData, payload);
|
|
19904
20110
|
assertTrustedWatchers(payload.watchers ?? []);
|
|
20111
|
+
assertTrustedWatchers(payload.replayWatchers ?? []);
|
|
19905
20112
|
applyReplacement(replacement);
|
|
19906
20113
|
leavingPlaythrough = leaving;
|
|
19907
20114
|
try {
|
|
@@ -19913,27 +20120,37 @@ var useStoryStore = create()(storyStore((set, get) => ({
|
|
|
19913
20120
|
const ifid = get().storyData?.ifid;
|
|
19914
20121
|
if (playthroughId && ifid) switchToLoadedPlaythrough(ifid, playthroughId);
|
|
19915
20122
|
const entry = loadedEntryMoment(payload);
|
|
19916
|
-
const
|
|
20123
|
+
const index = Math.max(0, Math.min(payload.historyIndex, payload.history.length - 1));
|
|
20124
|
+
const start = Math.min(index, Math.max(0, payload.history.length - get().maxHistory));
|
|
20125
|
+
const retained = payload.history.slice(start, start + get().maxHistory);
|
|
20126
|
+
const namespaces = /* @__PURE__ */ new Map();
|
|
20127
|
+
const snapshots = deepClone(retained.map((m) => m.variables)).map((vars) => {
|
|
20128
|
+
let normalized = namespaces.get(vars);
|
|
20129
|
+
if (!normalized) {
|
|
20130
|
+
normalized = createNamespace(vars);
|
|
20131
|
+
namespaces.set(vars, normalized);
|
|
20132
|
+
}
|
|
20133
|
+
return normalized;
|
|
20134
|
+
});
|
|
19917
20135
|
variableBase = deepClone(snapshots[0]);
|
|
19918
|
-
patchEntries = snapshots.slice(1).map((curr, i) => computeVarPatches(snapshots[i], curr));
|
|
19919
|
-
sessionMoments =
|
|
20136
|
+
patchEntries = snapshots.slice(1).map((curr, i) => curr === snapshots[i] ? { forward: [] } : computeVarPatches(snapshots[i], curr));
|
|
20137
|
+
sessionMoments = retained.map((m, i) => savedMoment(m, snapshots[i]));
|
|
19920
20138
|
set((state) => {
|
|
19921
20139
|
state.currentPassage = payload.passage;
|
|
19922
20140
|
state.navigationId++;
|
|
19923
20141
|
state.variables = createNamespace(deepClone(entry?.variables ?? payload.variables));
|
|
19924
|
-
state.history =
|
|
20142
|
+
state.history = retained.map((m) => ({
|
|
19925
20143
|
passage: m.passage,
|
|
19926
20144
|
timestamp: m.timestamp,
|
|
19927
20145
|
prng: m.prng
|
|
19928
20146
|
}));
|
|
19929
|
-
state.historyIndex =
|
|
19930
|
-
trimHistory(state);
|
|
20147
|
+
state.historyIndex = index - start;
|
|
19931
20148
|
state.visitCounts = createCounts(payload.visitCounts);
|
|
19932
20149
|
state.renderCounts = createCounts(payload.renderCounts);
|
|
19933
20150
|
state.temporary = createNamespace();
|
|
19934
20151
|
state.transient = freshTransients(get().transientDefaults);
|
|
19935
20152
|
});
|
|
19936
|
-
if (payload.watchers) restoreMacroWatchers(payload.watchers, payload.interfaceWatchers);
|
|
20153
|
+
if (payload.watchers) restoreMacroWatchers(payload.replayWatchers ?? payload.watchers, payload.interfaceWatchers);
|
|
19937
20154
|
reinitTriggerState();
|
|
19938
20155
|
lastNavigationVars = reconstructVarsAt(get().historyIndex);
|
|
19939
20156
|
restorePRNGFrom(entry?.prng !== void 0 ? entry.prng : payload.prng);
|
|
@@ -20015,12 +20232,34 @@ var FOCUSABLE = [
|
|
|
20015
20232
|
"[contenteditable]",
|
|
20016
20233
|
"[tabindex]"
|
|
20017
20234
|
].join(",");
|
|
20235
|
+
/** The parent in the rendered tree, including slots and shadow hosts. */
|
|
20236
|
+
function composedParent(el) {
|
|
20237
|
+
return el.assignedSlot ?? el.parentElement ?? el.getRootNode().host ?? null;
|
|
20238
|
+
}
|
|
20239
|
+
function composedChildren(root) {
|
|
20240
|
+
if (root.localName === "slot") return root.assignedNodes({ flatten: true }).filter((node) => node.nodeType === 1);
|
|
20241
|
+
return Array.from(root.children);
|
|
20242
|
+
}
|
|
20243
|
+
/** Authored elements in rendered order; unassigned light DOM is not rendered. */
|
|
20244
|
+
function* composedElements(root) {
|
|
20245
|
+
for (const el of composedChildren(root)) {
|
|
20246
|
+
yield el;
|
|
20247
|
+
yield* composedElements(el.shadowRoot ?? el);
|
|
20248
|
+
}
|
|
20249
|
+
}
|
|
20018
20250
|
/**
|
|
20019
20251
|
* Whether `el` can be focused at all: shown, rendered, enabled (also by its
|
|
20020
20252
|
* fieldset) and not inert.
|
|
20021
20253
|
*/
|
|
20022
20254
|
function isAvailable(el) {
|
|
20023
|
-
|
|
20255
|
+
if (!isRendered(el)) return false;
|
|
20256
|
+
for (let at = el; at; at = composedParent(at)) {
|
|
20257
|
+
if (at.hasAttribute("hidden") || at.hasAttribute("inert")) return false;
|
|
20258
|
+
if (at.ownerDocument.defaultView?.getComputedStyle(at).display === "none") return false;
|
|
20259
|
+
const parent = composedParent(at);
|
|
20260
|
+
if (parent?.localName === "details" && !parent.hasAttribute("open") && at !== Array.from(parent.children).find((child) => child.localName === "summary")) return false;
|
|
20261
|
+
}
|
|
20262
|
+
return !el.matches(":disabled");
|
|
20024
20263
|
}
|
|
20025
20264
|
/** The `tabindex` of `el` as an integer, or null when absent or invalid. */
|
|
20026
20265
|
function tabIndexAttr(el) {
|
|
@@ -20055,9 +20294,30 @@ function isTabStop(el) {
|
|
|
20055
20294
|
* others in document order.
|
|
20056
20295
|
*/
|
|
20057
20296
|
function focusables(root) {
|
|
20058
|
-
const
|
|
20297
|
+
const scopes = [];
|
|
20298
|
+
const collect = (parent) => {
|
|
20299
|
+
for (const element of composedChildren(parent)) {
|
|
20300
|
+
const el = element;
|
|
20301
|
+
const nested = el.shadowRoot ?? (el.localName === "slot" ? el : null);
|
|
20302
|
+
const stop = el.matches(FOCUSABLE) && isAvailable(el) && isTabStop(el);
|
|
20303
|
+
if (nested) {
|
|
20304
|
+
if ((tabIndexAttr(el) ?? 0) < 0) continue;
|
|
20305
|
+
scopes.push({
|
|
20306
|
+
el,
|
|
20307
|
+
stops: [...stop && !el.shadowRoot?.delegatesFocus ? [el] : [], ...focusables(nested)]
|
|
20308
|
+
});
|
|
20309
|
+
} else {
|
|
20310
|
+
if (stop) scopes.push({
|
|
20311
|
+
el,
|
|
20312
|
+
stops: [el]
|
|
20313
|
+
});
|
|
20314
|
+
collect(el);
|
|
20315
|
+
}
|
|
20316
|
+
}
|
|
20317
|
+
};
|
|
20318
|
+
collect(root);
|
|
20059
20319
|
const positive = (el) => Math.max(tabIndexAttr(el) ?? 0, 0);
|
|
20060
|
-
return [...
|
|
20320
|
+
return [...scopes.filter(({ el }) => positive(el) > 0).sort((a, b) => positive(a.el) - positive(b.el)), ...scopes.filter(({ el }) => positive(el) === 0)].flatMap(({ stops }) => stops);
|
|
20061
20321
|
}
|
|
20062
20322
|
/** Open modal dialogs, innermost last. Only the topmost handles keys. */
|
|
20063
20323
|
var openModals = [];
|
|
@@ -20096,6 +20356,21 @@ function frameDocument(frame) {
|
|
|
20096
20356
|
return null;
|
|
20097
20357
|
}
|
|
20098
20358
|
}
|
|
20359
|
+
/** Focus an element, entering accessible frames at the appropriate edge. */
|
|
20360
|
+
function enter(el, backwards) {
|
|
20361
|
+
if (isFrame(el)) {
|
|
20362
|
+
const doc = frameDocument(el);
|
|
20363
|
+
const inner = doc ? focusables(doc) : [];
|
|
20364
|
+
const edge = backwards ? inner[inner.length - 1] : inner[0];
|
|
20365
|
+
if (edge) return enter(edge, backwards);
|
|
20366
|
+
}
|
|
20367
|
+
el.focus();
|
|
20368
|
+
}
|
|
20369
|
+
/** document.activeElement exposes a shadow host; follow it to the control. */
|
|
20370
|
+
function activeElement(root) {
|
|
20371
|
+
const el = root.activeElement;
|
|
20372
|
+
return el?.shadowRoot?.activeElement ? activeElement(el.shadowRoot) : el;
|
|
20373
|
+
}
|
|
20099
20374
|
/** The iframe element that holds `doc`, null for the top document. */
|
|
20100
20375
|
function frameOf(doc) {
|
|
20101
20376
|
try {
|
|
@@ -20112,8 +20387,10 @@ function frameOf(doc) {
|
|
|
20112
20387
|
function nextStop(items, root, from, backwards) {
|
|
20113
20388
|
const at = from ? items.indexOf(from) : -1;
|
|
20114
20389
|
if (at !== -1) return items[at + (backwards ? -1 : 1)];
|
|
20115
|
-
|
|
20116
|
-
|
|
20390
|
+
const order = from ? [...composedElements(root)] : [];
|
|
20391
|
+
const position = order.indexOf(from);
|
|
20392
|
+
if (position !== -1) {
|
|
20393
|
+
const after = (el) => order.indexOf(el) > position;
|
|
20117
20394
|
return backwards ? items.filter((el) => !after(el)).pop() : items.find(after);
|
|
20118
20395
|
}
|
|
20119
20396
|
return backwards ? items[items.length - 1] : items[0];
|
|
@@ -20128,13 +20405,13 @@ function nextStop(items, root, from, backwards) {
|
|
|
20128
20405
|
*/
|
|
20129
20406
|
function activeChain() {
|
|
20130
20407
|
const chain = [];
|
|
20131
|
-
let
|
|
20132
|
-
while (
|
|
20133
|
-
const el =
|
|
20134
|
-
if (!el || chain.length > 0 && el ===
|
|
20408
|
+
let root = document;
|
|
20409
|
+
while (root) {
|
|
20410
|
+
const el = root.activeElement;
|
|
20411
|
+
if (!el || chain.length > 0 && el === root.body) break;
|
|
20135
20412
|
if (typeof el.focus !== "function") break;
|
|
20136
20413
|
chain.push(el);
|
|
20137
|
-
|
|
20414
|
+
root = el.shadowRoot?.activeElement ? el.shadowRoot : isFrame(el) ? frameDocument(el) : null;
|
|
20138
20415
|
}
|
|
20139
20416
|
return chain;
|
|
20140
20417
|
}
|
|
@@ -20162,7 +20439,7 @@ function useModalFocus(panelRef, bodySelector, dismissible, onClose) {
|
|
|
20162
20439
|
};
|
|
20163
20440
|
openModals.push(entry);
|
|
20164
20441
|
const body = panel.querySelector(bodySelector) ?? panel;
|
|
20165
|
-
(
|
|
20442
|
+
enter([...composedElements(panel)].find((el) => el.hasAttribute("autofocus") && isAvailable(el)) ?? focusables(body)[0] ?? panel, false);
|
|
20166
20443
|
return () => {
|
|
20167
20444
|
const i = openModals.indexOf(entry);
|
|
20168
20445
|
if (i !== -1) openModals.splice(i, 1);
|
|
@@ -20178,16 +20455,6 @@ function useModalFocus(panelRef, bodySelector, dismissible, onClose) {
|
|
|
20178
20455
|
const panel = panelRef.current;
|
|
20179
20456
|
if (!panel) return;
|
|
20180
20457
|
const top = () => openModals[openModals.length - 1]?.panel === panel;
|
|
20181
|
-
/** Focus `el`; a frame is entered at its first (or last) control (#460). */
|
|
20182
|
-
const enter = (el, backwards) => {
|
|
20183
|
-
if (isFrame(el)) {
|
|
20184
|
-
const doc = frameDocument(el);
|
|
20185
|
-
const inner = doc ? focusables(doc) : [];
|
|
20186
|
-
const edge = backwards ? inner[inner.length - 1] : inner[0];
|
|
20187
|
-
if (edge) return enter(edge, backwards);
|
|
20188
|
-
}
|
|
20189
|
-
el.focus();
|
|
20190
|
-
};
|
|
20191
20458
|
/**
|
|
20192
20459
|
* Move focus to the next (or previous) modal control from `from`. The
|
|
20193
20460
|
* order is computed here, never left to the browser: its positive-tabindex
|
|
@@ -20212,8 +20479,7 @@ function useModalFocus(panelRef, bodySelector, dismissible, onClose) {
|
|
|
20212
20479
|
panel.focus();
|
|
20213
20480
|
return;
|
|
20214
20481
|
}
|
|
20215
|
-
|
|
20216
|
-
enter(next ?? (backwards ? last : first), backwards);
|
|
20482
|
+
enter(nextStop(items, panel, from, backwards) ?? (backwards ? last : first), backwards);
|
|
20217
20483
|
};
|
|
20218
20484
|
let steppingNative = null;
|
|
20219
20485
|
const keyHandler = (doc, frame) => {
|
|
@@ -20227,7 +20493,7 @@ function useModalFocus(panelRef, bodySelector, dismissible, onClose) {
|
|
|
20227
20493
|
return;
|
|
20228
20494
|
}
|
|
20229
20495
|
if (e.key !== "Tab") return;
|
|
20230
|
-
const active = doc
|
|
20496
|
+
const active = activeElement(doc);
|
|
20231
20497
|
if (frame) {
|
|
20232
20498
|
steppingNative = null;
|
|
20233
20499
|
const inner = focusables(doc);
|
|
@@ -20250,20 +20516,20 @@ function useModalFocus(panelRef, bodySelector, dismissible, onClose) {
|
|
|
20250
20516
|
steppingNative = null;
|
|
20251
20517
|
};
|
|
20252
20518
|
const onFocusIn = (e) => {
|
|
20253
|
-
const target = e.target;
|
|
20519
|
+
const target = e.composedPath()[0] ?? e.target;
|
|
20254
20520
|
if (steppingNative && target !== steppingNative.el && top()) {
|
|
20255
20521
|
const { from, backwards } = steppingNative;
|
|
20256
20522
|
steppingNative = null;
|
|
20257
20523
|
moveFocus(from, backwards);
|
|
20258
20524
|
return;
|
|
20259
20525
|
}
|
|
20260
|
-
if (!top() || !(target instanceof Node) || panel.contains(target)) return;
|
|
20526
|
+
if (!top() || !(target instanceof Node) || target instanceof Element && [...composedElements(panel)].includes(target) || panel.contains(target)) return;
|
|
20261
20527
|
if (target === document.body || target === document.documentElement) return;
|
|
20262
20528
|
moveFocus(null, false);
|
|
20263
20529
|
};
|
|
20264
20530
|
const onFocusOut = (e) => {
|
|
20265
20531
|
const pending = steppingNative;
|
|
20266
|
-
if (!pending || e.target !== pending.el || e.relatedTarget || !top()) return;
|
|
20532
|
+
if (!pending || (e.composedPath()[0] ?? e.target) !== pending.el || e.relatedTarget || !top()) return;
|
|
20267
20533
|
steppingNative = null;
|
|
20268
20534
|
moveFocus(pending.from, pending.backwards);
|
|
20269
20535
|
};
|
|
@@ -20279,15 +20545,25 @@ function useModalFocus(panelRef, bodySelector, dismissible, onClose) {
|
|
|
20279
20545
|
};
|
|
20280
20546
|
const frameDocs = /* @__PURE__ */ new Map();
|
|
20281
20547
|
const observers = [];
|
|
20548
|
+
const watched = /* @__PURE__ */ new WeakSet();
|
|
20282
20549
|
const attachFrame = (frame) => {
|
|
20283
20550
|
const doc = frameDocument(frame);
|
|
20284
20551
|
if (!doc || frameDocs.get(frame) === doc) return;
|
|
20285
20552
|
frameDocs.set(frame, doc);
|
|
20286
20553
|
listen(doc, frame);
|
|
20287
20554
|
watchFrames(doc);
|
|
20555
|
+
const chain = activeChain();
|
|
20556
|
+
if (top() && chain[chain.length - 1] === frame) enter(frame, false);
|
|
20288
20557
|
};
|
|
20289
20558
|
const watchFrames = (root) => {
|
|
20290
|
-
|
|
20559
|
+
if (watched.has(root)) return;
|
|
20560
|
+
watched.add(root);
|
|
20561
|
+
const attachAll = () => {
|
|
20562
|
+
for (const el of composedElements(root)) {
|
|
20563
|
+
if (el.shadowRoot) watchFrames(el.shadowRoot);
|
|
20564
|
+
if (isFrame(el)) attachFrame(el);
|
|
20565
|
+
}
|
|
20566
|
+
};
|
|
20291
20567
|
root.addEventListener("load", (e) => {
|
|
20292
20568
|
if (e.target && isFrame(e.target)) attachFrame(e.target);
|
|
20293
20569
|
}, {
|
|
@@ -20930,6 +21206,7 @@ function defineMacro(config, source = "builtin") {
|
|
|
20930
21206
|
checkParameterTypes(config.name, parameters);
|
|
20931
21207
|
const acts = actingMacros.has(config.name);
|
|
20932
21208
|
function Wrapper(props) {
|
|
21209
|
+
const entryRender = useContext(EntryRenderContext);
|
|
20933
21210
|
const displayOnly = useContext(DisplayOnlyContext);
|
|
20934
21211
|
if (displayOnly && acts) return h(MacroError, {
|
|
20935
21212
|
macro: config.name,
|
|
@@ -21032,7 +21309,7 @@ function defineMacro(config, source = "builtin") {
|
|
|
21032
21309
|
};
|
|
21033
21310
|
}
|
|
21034
21311
|
try {
|
|
21035
|
-
return config.render(props, ctx);
|
|
21312
|
+
return entryRender?.pending ? duringEntryRender(() => config.render(props, ctx)) : duringMacroRender(() => config.render(props, ctx));
|
|
21036
21313
|
} catch (error) {
|
|
21037
21314
|
if (error instanceof MacroArgumentError) return h(MacroError, {
|
|
21038
21315
|
macro: config.name,
|
|
@@ -21062,21 +21339,6 @@ function defineMacro(config, source = "builtin") {
|
|
|
21062
21339
|
setDefinedBlockMacro(config.name, isBlock);
|
|
21063
21340
|
}
|
|
21064
21341
|
//#endregion
|
|
21065
|
-
//#region src/passage-render-state.ts
|
|
21066
|
-
/**
|
|
21067
|
-
* Navigation id (the store's `navigationId`) of the passage most recently
|
|
21068
|
-
* mounted by <Passage> (null until the first render, e.g. when the story
|
|
21069
|
-
* interface has no {passage}). Lets Story.waitForActions() tell whether the
|
|
21070
|
-
* current navigation is on screen, also when it revisits the passage shown.
|
|
21071
|
-
*/
|
|
21072
|
-
var renderedNavigationId = null;
|
|
21073
|
-
function markPassageRendered(navigationId) {
|
|
21074
|
-
renderedNavigationId = navigationId;
|
|
21075
|
-
}
|
|
21076
|
-
function getRenderedNavigationId() {
|
|
21077
|
-
return renderedNavigationId;
|
|
21078
|
-
}
|
|
21079
|
-
//#endregion
|
|
21080
21342
|
//#region src/story-context-passage.ts
|
|
21081
21343
|
/**
|
|
21082
21344
|
* The macros a display-only passage may not use besides the input macros:
|
|
@@ -21824,14 +22086,23 @@ function distance(a, b) {
|
|
|
21824
22086
|
}
|
|
21825
22087
|
/** The known name closest to `name`, if one is close. */
|
|
21826
22088
|
function closestName(name, names) {
|
|
22089
|
+
if (name.length > 256) return void 0;
|
|
21827
22090
|
const lower = name.toLowerCase();
|
|
21828
22091
|
let best;
|
|
21829
22092
|
let bestDistance = Math.max(2, Math.floor(lower.length / 3)) + 1;
|
|
22093
|
+
let budget = 1e5;
|
|
22094
|
+
let candidates = 1e3;
|
|
21830
22095
|
for (const candidate of names) {
|
|
22096
|
+
if (--candidates < 0) break;
|
|
22097
|
+
if (candidate.length > 256) continue;
|
|
22098
|
+
if (Math.abs(candidate.length - lower.length) >= bestDistance) continue;
|
|
22099
|
+
budget -= lower.length * candidate.length;
|
|
22100
|
+
if (budget < 0) break;
|
|
21831
22101
|
const d = distance(lower, candidate.toLowerCase());
|
|
21832
22102
|
if (d < bestDistance) {
|
|
21833
22103
|
best = candidate;
|
|
21834
22104
|
bestDistance = d;
|
|
22105
|
+
if (d === 0) break;
|
|
21835
22106
|
}
|
|
21836
22107
|
}
|
|
21837
22108
|
return best;
|
|
@@ -21856,12 +22127,19 @@ function widgetName(rawArgs) {
|
|
|
21856
22127
|
*/
|
|
21857
22128
|
function validateMarkup(passages, options) {
|
|
21858
22129
|
const diagnostics = [];
|
|
22130
|
+
const positions = /* @__PURE__ */ new Map();
|
|
21859
22131
|
const hooks = {
|
|
21860
22132
|
...options.isBlockMacro && { isBlock: options.isBlockMacro },
|
|
21861
|
-
...options.branchParents && { branchParents: options.branchParents }
|
|
22133
|
+
...options.branchParents && { branchParents: options.branchParents },
|
|
22134
|
+
isRaw: (name) => isRawMacro(name, options.parametersOf ? options.parametersOf.widget?.(name) !== void 0 : void 0)
|
|
21862
22135
|
};
|
|
21863
22136
|
const report = (passage, start, end, code, message, data) => {
|
|
21864
|
-
|
|
22137
|
+
let position = positions.get(passage);
|
|
22138
|
+
if (!position) {
|
|
22139
|
+
position = sourcePositions(passage.content);
|
|
22140
|
+
positions.set(passage, position);
|
|
22141
|
+
}
|
|
22142
|
+
const { line, column } = position(start);
|
|
21865
22143
|
const d = {
|
|
21866
22144
|
passage: passage.name,
|
|
21867
22145
|
line,
|
|
@@ -21907,7 +22185,7 @@ function validateMarkup(passages, options) {
|
|
|
21907
22185
|
continue;
|
|
21908
22186
|
}
|
|
21909
22187
|
try {
|
|
21910
|
-
const tokens = tokenizeMarkup(passage.content);
|
|
22188
|
+
const tokens = tokenizeMarkup(passage.content, { hooks });
|
|
21911
22189
|
addWidgets(tokens);
|
|
21912
22190
|
if (!reported) continue;
|
|
21913
22191
|
parseMarkup(passage.content, { hooks });
|
|
@@ -22342,22 +22620,40 @@ var Reader = class {
|
|
|
22342
22620
|
}
|
|
22343
22621
|
/** Skip an array literal (or any bracketed group) at the cursor. */
|
|
22344
22622
|
skipBalanced() {
|
|
22345
|
-
const { src } = this;
|
|
22346
22623
|
const close = {
|
|
22347
22624
|
"[": "]",
|
|
22348
22625
|
"{": "}",
|
|
22349
22626
|
"(": ")"
|
|
22350
|
-
}[src.charAt(this.i)];
|
|
22351
|
-
|
|
22627
|
+
}[this.src.charAt(this.i)];
|
|
22628
|
+
return close ? this.skipNested(close) : false;
|
|
22629
|
+
}
|
|
22630
|
+
/** Skip groups and template interpolations with an explicit stack. */
|
|
22631
|
+
skipNested(close) {
|
|
22632
|
+
const { src } = this;
|
|
22633
|
+
const stack = [close];
|
|
22352
22634
|
this.i++;
|
|
22353
|
-
while (this.i < src.length) {
|
|
22354
|
-
|
|
22635
|
+
while (this.i < src.length && stack.length) {
|
|
22636
|
+
const c = src.charAt(this.i);
|
|
22637
|
+
const top = stack[stack.length - 1];
|
|
22638
|
+
if (c === top) {
|
|
22639
|
+
stack.pop();
|
|
22355
22640
|
this.i++;
|
|
22356
|
-
|
|
22357
|
-
|
|
22358
|
-
|
|
22641
|
+
} else if (top === "`") {
|
|
22642
|
+
if (c === "\\") this.i += 2;
|
|
22643
|
+
else if (c === "$" && src.charAt(this.i + 1) === "{") {
|
|
22644
|
+
stack.push("}");
|
|
22645
|
+
this.i += 2;
|
|
22646
|
+
} else this.i++;
|
|
22647
|
+
} else if (c === "`" || c === "[" || c === "{" || c === "(") {
|
|
22648
|
+
stack.push(c === "`" ? "`" : {
|
|
22649
|
+
"[": "]",
|
|
22650
|
+
"{": "}",
|
|
22651
|
+
"(": ")"
|
|
22652
|
+
}[c]);
|
|
22653
|
+
this.i++;
|
|
22654
|
+
} else if (!this.skipOne()) return false;
|
|
22359
22655
|
}
|
|
22360
|
-
return
|
|
22656
|
+
return stack.length === 0;
|
|
22361
22657
|
}
|
|
22362
22658
|
/** Skip one character, or one string, template, comment or group. */
|
|
22363
22659
|
skipOne() {
|
|
@@ -22384,20 +22680,7 @@ var Reader = class {
|
|
|
22384
22680
|
}
|
|
22385
22681
|
/** Skip a template literal, with the expressions in it. */
|
|
22386
22682
|
skipTemplate() {
|
|
22387
|
-
|
|
22388
|
-
this.i++;
|
|
22389
|
-
while (this.i < src.length) {
|
|
22390
|
-
const c = src.charAt(this.i);
|
|
22391
|
-
if (c === "\\") this.i += 2;
|
|
22392
|
-
else if (c === "`") {
|
|
22393
|
-
this.i++;
|
|
22394
|
-
return true;
|
|
22395
|
-
} else if (c === "$" && src.charAt(this.i + 1) === "{") {
|
|
22396
|
-
this.i++;
|
|
22397
|
-
if (!this.skipBalanced()) return false;
|
|
22398
|
-
} else this.i++;
|
|
22399
|
-
}
|
|
22400
|
-
return false;
|
|
22683
|
+
return this.skipNested("`");
|
|
22401
22684
|
}
|
|
22402
22685
|
};
|
|
22403
22686
|
//#endregion
|
|
@@ -22406,10 +22689,14 @@ var Reader = class {
|
|
|
22406
22689
|
* The tokens of markup, or none if it is malformed (validateMarkup reports
|
|
22407
22690
|
* that, with its position); in tolerant mode, those of the well-formed parts.
|
|
22408
22691
|
*/
|
|
22409
|
-
function tokensOf(text, textMode, { tolerant } = {}) {
|
|
22410
|
-
|
|
22692
|
+
function tokensOf(text, textMode, { tolerant, parametersOf } = {}) {
|
|
22693
|
+
const options = {
|
|
22694
|
+
text: textMode,
|
|
22695
|
+
hooks: parametersOf && { isRaw: (name) => isRawMacro(name, parametersOf.widget?.(name) !== void 0) }
|
|
22696
|
+
};
|
|
22697
|
+
if (tolerant) return tokenizeMarkupTolerant(text, options).tokens;
|
|
22411
22698
|
try {
|
|
22412
|
-
return tokenizeMarkup(text,
|
|
22699
|
+
return tokenizeMarkup(text, options);
|
|
22413
22700
|
} catch (err) {
|
|
22414
22701
|
if (err instanceof MarkupError) return [];
|
|
22415
22702
|
throw err;
|
|
@@ -22965,6 +23252,17 @@ var CODE_PASSAGES = /* @__PURE__ */ new Set([
|
|
|
22965
23252
|
"PassageFooter",
|
|
22966
23253
|
"PassageDone"
|
|
22967
23254
|
]);
|
|
23255
|
+
/** PassageDone mounts after the main passage committed, but replays on load. */
|
|
23256
|
+
function EntryRenderBoundary({ children }) {
|
|
23257
|
+
const phase = useRef({ pending: true });
|
|
23258
|
+
useLayoutEffect(() => {
|
|
23259
|
+
phase.current.pending = false;
|
|
23260
|
+
}, []);
|
|
23261
|
+
return /* @__PURE__ */ jsx(EntryRenderContext.Provider, {
|
|
23262
|
+
value: phase.current,
|
|
23263
|
+
children
|
|
23264
|
+
});
|
|
23265
|
+
}
|
|
22968
23266
|
function Passage({ passage, dataTransition, navigationId }) {
|
|
22969
23267
|
const { storyData } = useStoryFields("storyData");
|
|
22970
23268
|
const isCodePassage = CODE_PASSAGES.has(passage.name);
|
|
@@ -23000,7 +23298,12 @@ function Passage({ passage, dataTransition, navigationId }) {
|
|
|
23000
23298
|
const elRef = useRef(null);
|
|
23001
23299
|
useLayoutEffect(() => {
|
|
23002
23300
|
if (navigationId !== void 0) markPassageRendered(navigationId);
|
|
23003
|
-
if (elRef.current)
|
|
23301
|
+
if (elRef.current) {
|
|
23302
|
+
const element = elRef.current;
|
|
23303
|
+
const emit = () => emitFromRender("passagerender", passage.name, element);
|
|
23304
|
+
if (navigationId !== void 0) duringEntryRender(emit);
|
|
23305
|
+
else emit();
|
|
23306
|
+
}
|
|
23004
23307
|
}, [passage.name, navigationId]);
|
|
23005
23308
|
const nobr = passage.tags.includes("nobr");
|
|
23006
23309
|
const viewScope = useViewScope();
|
|
@@ -23024,10 +23327,10 @@ function Passage({ passage, dataTransition, navigationId }) {
|
|
|
23024
23327
|
class: "passage-footer",
|
|
23025
23328
|
children: footerContent
|
|
23026
23329
|
}),
|
|
23027
|
-
doneContent && /* @__PURE__ */ jsx("div", {
|
|
23330
|
+
doneContent && /* @__PURE__ */ jsx(EntryRenderBoundary, { children: /* @__PURE__ */ jsx("div", {
|
|
23028
23331
|
hidden: true,
|
|
23029
23332
|
children: doneContent
|
|
23030
|
-
})
|
|
23333
|
+
}) })
|
|
23031
23334
|
]
|
|
23032
23335
|
})
|
|
23033
23336
|
})
|
|
@@ -25684,8 +25987,15 @@ function orStop(parse, where = "") {
|
|
|
25684
25987
|
* the declared parameters of macros and what the parameters of widgets hold.
|
|
25685
25988
|
* (The markup and the variable references are read by the same.)
|
|
25686
25989
|
*/
|
|
25687
|
-
function knownParameters() {
|
|
25688
|
-
return parameterLookup([
|
|
25990
|
+
function knownParameters(declared = []) {
|
|
25991
|
+
return parameterLookup([
|
|
25992
|
+
...getMacroRegistry(),
|
|
25993
|
+
...declared.map((widget) => ({
|
|
25994
|
+
name: widget.name,
|
|
25995
|
+
widget
|
|
25996
|
+
})),
|
|
25997
|
+
...widgetMacros()
|
|
25998
|
+
]);
|
|
25689
25999
|
}
|
|
25690
26000
|
/** The names of the registered macros that bind a variable (the inputs). */
|
|
25691
26001
|
function storeVarMacroNames() {
|
|
@@ -25696,19 +26006,19 @@ function storeVarMacroNames() {
|
|
|
25696
26006
|
* the input macros that bind a variable (registered by author JS or
|
|
25697
26007
|
* StoryInit) and the roles of their parameters decide what is a reference.
|
|
25698
26008
|
*/
|
|
25699
|
-
function variableErrors(storyData, schema, only = () => true) {
|
|
25700
|
-
return validatePassages(new Map([...storyData.passages].filter(([, passage]) => only(passage))), schema, storeVarMacroNames(),
|
|
26009
|
+
function variableErrors(storyData, schema, only = () => true, parametersOf = knownParameters()) {
|
|
26010
|
+
return validatePassages(new Map([...storyData.passages].filter(([, passage]) => only(passage))), schema, storeVarMacroNames(), parametersOf);
|
|
25701
26011
|
}
|
|
25702
26012
|
/**
|
|
25703
26013
|
* The markup errors (malformed markup, unknown macros, syntax errors in
|
|
25704
26014
|
* code) of the passages for which `only` holds, with the macros and widgets
|
|
25705
26015
|
* known now.
|
|
25706
26016
|
*/
|
|
25707
|
-
function markupErrors(storyData, only) {
|
|
26017
|
+
function markupErrors(storyData, only, parametersOf = knownParameters()) {
|
|
25708
26018
|
return validateMarkup(storyData.passages.values(), {
|
|
25709
26019
|
isKnownMacro: (name) => !!getMacro(name) || isSubMacro(name) || !!getWidget(name),
|
|
25710
26020
|
macroNames: getMacroRegistry().map((m) => m.name),
|
|
25711
|
-
parametersOf
|
|
26021
|
+
parametersOf,
|
|
25712
26022
|
only
|
|
25713
26023
|
}).map(formatDiagnostic);
|
|
25714
26024
|
}
|
|
@@ -25747,9 +26057,11 @@ function boot() {
|
|
|
25747
26057
|
throw new Error(`spindle: ${msg}`);
|
|
25748
26058
|
}
|
|
25749
26059
|
const schema = orStop(() => parseStoryVariables(storyVarsPassage.content));
|
|
25750
|
-
|
|
25751
|
-
const
|
|
25752
|
-
|
|
26060
|
+
const widgets = orStop(() => effectiveWidgets(storyData.passages.values()));
|
|
26061
|
+
for (const { name, block } of widgets) setBlockWidget(name, block);
|
|
26062
|
+
const startupParameters = knownParameters(widgets);
|
|
26063
|
+
const errors = variableErrors(storyData, schema, (p) => p.name === "StoryInit", startupParameters);
|
|
26064
|
+
errors.push(...markupErrors(storyData, (p) => p.name === "StoryInit", startupParameters));
|
|
25753
26065
|
let transientDefaults = {};
|
|
25754
26066
|
const storyTransientsPassage = storyData.passages.get("StoryTransients");
|
|
25755
26067
|
if (storyTransientsPassage) {
|