@rohal12/spindle 0.62.2 → 0.62.4
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 +464 -272
- package/dist/pkg/play-worker.js +95 -7
- package/dist/pkg/play.js +3 -3
- package/dist/pkg/story-variables.js +590 -386
- package/dist/pkg/tooling.js +1 -0
- package/package.json +1 -1
- package/src/code-check.ts +1 -1
- package/src/completion-context.ts +226 -0
- package/src/components/Passage.tsx +28 -3
- package/src/define-macro.ts +6 -1
- package/src/hooks/use-render-options.ts +4 -0
- package/src/macro-discovery.ts +27 -15
- package/src/markup/code-attributes.ts +10 -3
- package/src/markup/parse.ts +19 -4
- package/src/markup/render.tsx +6 -4
- package/src/markup/spindle.d.peggy.ts +2 -0
- package/src/markup/spindle.peggy +22 -13
- package/src/passage-render-state.ts +7 -0
- package/src/play/session.ts +3 -3
- package/src/play/window-events.ts +63 -0
- package/src/play/worker.ts +62 -9
- 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/tooling.ts +4 -0
- 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/play.d.ts +6 -5
- 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;
|
|
1204
|
+
}
|
|
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);
|
|
1197
1208
|
}
|
|
1198
|
-
function peg$
|
|
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;
|
|
@@ -10704,7 +10768,7 @@ function isCodeAttribute(name) {
|
|
|
10704
10768
|
* sigil is not followed by a word character (`{$(…)}`) is code, kept
|
|
10705
10769
|
* verbatim: not resolved, and not decoded like text.
|
|
10706
10770
|
*/
|
|
10707
|
-
function splitSigilTemplate(template) {
|
|
10771
|
+
function splitSigilTemplate(template, incomplete = false) {
|
|
10708
10772
|
const parts = [];
|
|
10709
10773
|
let text = "";
|
|
10710
10774
|
let i = 0;
|
|
@@ -10716,7 +10780,8 @@ function splitSigilTemplate(template) {
|
|
|
10716
10780
|
}
|
|
10717
10781
|
text += template.slice(i, brace);
|
|
10718
10782
|
i = brace + 1;
|
|
10719
|
-
|
|
10783
|
+
let end = isSigil(template[i]) ? defaultCodeEnd.closeBrace(template, i, i) : -1;
|
|
10784
|
+
if (end === -1 && incomplete && isSigil(template[i])) end = template.length;
|
|
10720
10785
|
if (end === -1) {
|
|
10721
10786
|
text += "{";
|
|
10722
10787
|
continue;
|
|
@@ -10724,7 +10789,7 @@ function splitSigilTemplate(template) {
|
|
|
10724
10789
|
if (text) parts.push({ text });
|
|
10725
10790
|
text = "";
|
|
10726
10791
|
const block = template.slice(i, end);
|
|
10727
|
-
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}}` });
|
|
10728
10793
|
i = end + 1;
|
|
10729
10794
|
}
|
|
10730
10795
|
if (text) parts.push({ text });
|
|
@@ -10757,7 +10822,7 @@ var MarkupError = class extends Error {
|
|
|
10757
10822
|
this.name = "MarkupError";
|
|
10758
10823
|
}
|
|
10759
10824
|
};
|
|
10760
|
-
function run$2(source, startRule, options) {
|
|
10825
|
+
function run$2(source, startRule, options, completion = false) {
|
|
10761
10826
|
const hooks = options.hooks ? {
|
|
10762
10827
|
...defaultHooks,
|
|
10763
10828
|
...options.hooks
|
|
@@ -10766,7 +10831,8 @@ function run$2(source, startRule, options) {
|
|
|
10766
10831
|
return peg$parse(source, {
|
|
10767
10832
|
startRule,
|
|
10768
10833
|
text: options.text === true,
|
|
10769
|
-
hooks
|
|
10834
|
+
hooks,
|
|
10835
|
+
completion
|
|
10770
10836
|
});
|
|
10771
10837
|
} catch (err) {
|
|
10772
10838
|
const { location, code } = err;
|
|
@@ -10855,7 +10921,7 @@ function tokenizeMarkupTolerant(source, options = {}) {
|
|
|
10855
10921
|
* each error starts (`damage[i]` for `errors[i]`): the tag that is
|
|
10856
10922
|
* malformed, which an error inside it (an attribute value) is after.
|
|
10857
10923
|
*/
|
|
10858
|
-
function scanMarkupTolerant(source, options = {}) {
|
|
10924
|
+
function scanMarkupTolerant(source, options = {}, completion = false) {
|
|
10859
10925
|
const tokens = [];
|
|
10860
10926
|
const errors = [];
|
|
10861
10927
|
const damage = [];
|
|
@@ -10872,10 +10938,10 @@ function scanMarkupTolerant(source, options = {}) {
|
|
|
10872
10938
|
closeBrace: (input, codeStart, lenientStart) => base + Math.min(codeStart, lenientStart) > lastBrace ? -1 : closeBrace(input, codeStart, lenientStart)
|
|
10873
10939
|
};
|
|
10874
10940
|
try {
|
|
10875
|
-
return
|
|
10941
|
+
return run$2(text, "Tokens", {
|
|
10876
10942
|
...options,
|
|
10877
10943
|
hooks
|
|
10878
|
-
}).map((token) => shiftOffsets(token, base));
|
|
10944
|
+
}, completion).map((token) => shiftOffsets(token, base));
|
|
10879
10945
|
} catch (error) {
|
|
10880
10946
|
if (!(error instanceof MarkupError)) throw error;
|
|
10881
10947
|
return error;
|
|
@@ -12227,25 +12293,29 @@ var registeredParameters = (name) => parameterLookup(getMacroRegistry())(name);
|
|
|
12227
12293
|
* Whether the text of an attribute value or macro label renders a
|
|
12228
12294
|
* `{@children}`: it is markup, parsed as the renderer parses it.
|
|
12229
12295
|
*/
|
|
12230
|
-
function textContainsChildren(text, parametersOf) {
|
|
12296
|
+
function textContainsChildren(text, parametersOf, hooks) {
|
|
12231
12297
|
if (!text.includes("{")) return false;
|
|
12232
12298
|
let nodes;
|
|
12233
12299
|
try {
|
|
12234
|
-
nodes = parseMarkup(text, {
|
|
12300
|
+
nodes = parseMarkup(text, {
|
|
12301
|
+
text: true,
|
|
12302
|
+
hooks
|
|
12303
|
+
});
|
|
12235
12304
|
} catch {
|
|
12236
12305
|
return false;
|
|
12237
12306
|
}
|
|
12238
|
-
return astContainsChildren(nodes, parametersOf);
|
|
12307
|
+
return astContainsChildren(nodes, parametersOf, hooks);
|
|
12239
12308
|
}
|
|
12240
12309
|
/**
|
|
12241
12310
|
* Whether a tag renders a `{@children}` in an attribute value or a macro
|
|
12242
12311
|
* argument that holds markup (`<span title="{@children}">`,
|
|
12243
12312
|
* `{button "{@children}"}`). Literal arguments and code are not markup.
|
|
12244
12313
|
* `src` is the text a flat token's offsets index into (its attribute values
|
|
12245
|
-
* 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.
|
|
12246
12316
|
*/
|
|
12247
|
-
function tokenTextContainsChildren(token, parametersOf = registeredParameters, src = "") {
|
|
12248
|
-
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;
|
|
12249
12319
|
return false;
|
|
12250
12320
|
}
|
|
12251
12321
|
/**
|
|
@@ -12255,36 +12325,33 @@ function tokenTextContainsChildren(token, parametersOf = registeredParameters, s
|
|
|
12255
12325
|
* entered: its slot belongs to the innermost widget (as widgetDefinitions
|
|
12256
12326
|
* reads it), and a definition renders nothing of its own.
|
|
12257
12327
|
*/
|
|
12258
|
-
function astContainsChildren(nodes, parametersOf = registeredParameters) {
|
|
12328
|
+
function astContainsChildren(nodes, parametersOf = registeredParameters, hooks) {
|
|
12259
12329
|
for (const node of nodes) {
|
|
12260
12330
|
if (node.type === "variable" && node.scope === "local" && node.name === "children") return true;
|
|
12261
|
-
if (node.type
|
|
12262
|
-
|
|
12263
|
-
|
|
12264
|
-
|
|
12265
|
-
|
|
12266
|
-
|
|
12267
|
-
|
|
12268
|
-
|
|
12269
|
-
|
|
12270
|
-
|
|
12271
|
-
|
|
12272
|
-
|
|
12273
|
-
|
|
12274
|
-
|
|
12275
|
-
|
|
12276
|
-
|
|
12277
|
-
|
|
12278
|
-
|
|
12279
|
-
|
|
12280
|
-
|
|
12281
|
-
|
|
12282
|
-
|
|
12283
|
-
|
|
12284
|
-
|
|
12285
|
-
if (node.branches) {
|
|
12286
|
-
for (const branch of node.branches) if (astContainsChildren(branch.children, parametersOf)) return true;
|
|
12287
|
-
}
|
|
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;
|
|
12288
12355
|
}
|
|
12289
12356
|
}
|
|
12290
12357
|
return false;
|
|
@@ -12366,42 +12433,48 @@ function nameSpan(rawArgs) {
|
|
|
12366
12433
|
* nested definitions, it belongs to the innermost.
|
|
12367
12434
|
*/
|
|
12368
12435
|
function widgetDefinitions(passages, parametersOf = registeredParameters) {
|
|
12369
|
-
const
|
|
12370
|
-
|
|
12371
|
-
|
|
12372
|
-
const
|
|
12373
|
-
const
|
|
12374
|
-
|
|
12375
|
-
|
|
12376
|
-
|
|
12377
|
-
|
|
12378
|
-
|
|
12379
|
-
|
|
12380
|
-
|
|
12381
|
-
if (def) done.push({
|
|
12382
|
-
...def,
|
|
12383
|
-
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
|
|
12384
12448
|
});
|
|
12385
|
-
|
|
12386
|
-
|
|
12387
|
-
|
|
12388
|
-
|
|
12389
|
-
|
|
12390
|
-
|
|
12391
|
-
|
|
12392
|
-
|
|
12393
|
-
|
|
12394
|
-
|
|
12395
|
-
|
|
12396
|
-
|
|
12397
|
-
|
|
12398
|
-
|
|
12399
|
-
|
|
12400
|
-
|
|
12401
|
-
|
|
12402
|
-
|
|
12403
|
-
|
|
12404
|
-
|
|
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;
|
|
12405
12478
|
}
|
|
12406
12479
|
/**
|
|
12407
12480
|
* The definitions the runtime ends up with, one per widget name: the closed
|
|
@@ -13403,6 +13476,7 @@ function useRenderOptions() {
|
|
|
13403
13476
|
inline: useContext(InlineContext),
|
|
13404
13477
|
raw: useContext(RawTextContext),
|
|
13405
13478
|
structural: useContext(StructuralContext),
|
|
13479
|
+
preserveEdges: true,
|
|
13406
13480
|
locals: useContext(LocalsValuesContext)
|
|
13407
13481
|
};
|
|
13408
13482
|
}
|
|
@@ -14445,7 +14519,7 @@ function renderNodes(nodes, options) {
|
|
|
14445
14519
|
const lead = combined.slice(0, skipChars(combined, 0, 1, EDGE_WS));
|
|
14446
14520
|
const trail = lead.length === combined.length ? "" : combined.slice(skipChars(combined, combined.length, -1, EDGE_WS));
|
|
14447
14521
|
const core = combined.slice(lead.length, combined.length - trail.length);
|
|
14448
|
-
const edges = (content) => unwrapParagraphs && (lead || trail) ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
14522
|
+
const edges = (content) => (unwrapParagraphs || options?.preserveEdges) && (lead || trail) ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
14449
14523
|
lead,
|
|
14450
14524
|
content,
|
|
14451
14525
|
trail
|
|
@@ -17077,7 +17151,25 @@ function executeMutation(code, mergedLocals, scopeUpdate) {
|
|
|
17077
17151
|
for (const key of Object.keys(mergedLocals)) if (!hasOwn(localsClone, key)) scopeUpdate(key, void 0);
|
|
17078
17152
|
}
|
|
17079
17153
|
//#endregion
|
|
17154
|
+
//#region src/passage-render-state.ts
|
|
17155
|
+
/** Initial render of a deferred passage subtree, until its first commit. */
|
|
17156
|
+
var EntryRenderContext = createContext(null);
|
|
17157
|
+
/**
|
|
17158
|
+
* Navigation id (the store's `navigationId`) of the passage most recently
|
|
17159
|
+
* mounted by <Passage> (null until the first render, e.g. when the story
|
|
17160
|
+
* interface has no {passage}). Lets Story.waitForActions() tell whether the
|
|
17161
|
+
* current navigation is on screen, also when it revisits the passage shown.
|
|
17162
|
+
*/
|
|
17163
|
+
var renderedNavigationId = null;
|
|
17164
|
+
function markPassageRendered(navigationId) {
|
|
17165
|
+
renderedNavigationId = navigationId;
|
|
17166
|
+
}
|
|
17167
|
+
function getRenderedNavigationId() {
|
|
17168
|
+
return renderedNavigationId;
|
|
17169
|
+
}
|
|
17170
|
+
//#endregion
|
|
17080
17171
|
//#region src/triggers.ts
|
|
17172
|
+
var registrations = 0;
|
|
17081
17173
|
var triggers = [];
|
|
17082
17174
|
var checking = false;
|
|
17083
17175
|
var dialogQueue = [];
|
|
@@ -17097,6 +17189,7 @@ function registerTrigger(condition, callbackOrOptions, macroKey) {
|
|
|
17097
17189
|
const options = isCallback ? void 0 : callbackOrOptions;
|
|
17098
17190
|
const callback = isCallback ? callbackOrOptions : void 0;
|
|
17099
17191
|
const trigger = {
|
|
17192
|
+
order: registrations++,
|
|
17100
17193
|
name: options?.name,
|
|
17101
17194
|
condition,
|
|
17102
17195
|
callback,
|
|
@@ -17128,6 +17221,73 @@ function addMacroTrigger(condition, options) {
|
|
|
17128
17221
|
if (triggers.some((t) => t.macroKey === macroKey)) return;
|
|
17129
17222
|
registerTrigger(condition, options, macroKey);
|
|
17130
17223
|
}
|
|
17224
|
+
var macroRenderDepth = 0;
|
|
17225
|
+
var entryRenderDepth = 0;
|
|
17226
|
+
var replayNavigation = -1;
|
|
17227
|
+
var replayRemoved = /* @__PURE__ */ new Map();
|
|
17228
|
+
/** Entry lifecycle callbacks and deferred initial passage subtrees replay on load. */
|
|
17229
|
+
function duringEntryRender(render) {
|
|
17230
|
+
entryRenderDepth++;
|
|
17231
|
+
try {
|
|
17232
|
+
return render();
|
|
17233
|
+
} finally {
|
|
17234
|
+
entryRenderDepth--;
|
|
17235
|
+
}
|
|
17236
|
+
}
|
|
17237
|
+
function isEntryRender() {
|
|
17238
|
+
return entryRenderDepth > 0 || macroRenderDepth > 0 && getRenderedNavigationId() !== useStoryStore.getState().navigationId;
|
|
17239
|
+
}
|
|
17240
|
+
function duringMacroRender(render) {
|
|
17241
|
+
macroRenderDepth++;
|
|
17242
|
+
try {
|
|
17243
|
+
return render();
|
|
17244
|
+
} finally {
|
|
17245
|
+
macroRenderDepth--;
|
|
17246
|
+
}
|
|
17247
|
+
}
|
|
17248
|
+
/** Forget replay removals whose effects have become part of a recorded entry. */
|
|
17249
|
+
function clearReplayWatchers() {
|
|
17250
|
+
replayRemoved.clear();
|
|
17251
|
+
}
|
|
17252
|
+
function replayRemovals() {
|
|
17253
|
+
const navigation = useStoryStore.getState().navigationId;
|
|
17254
|
+
if (navigation !== replayNavigation) {
|
|
17255
|
+
replayRemoved.clear();
|
|
17256
|
+
replayNavigation = navigation;
|
|
17257
|
+
}
|
|
17258
|
+
return replayRemoved;
|
|
17259
|
+
}
|
|
17260
|
+
function rememberRemoval(trigger) {
|
|
17261
|
+
const removed = replayRemovals();
|
|
17262
|
+
if (!trigger.macroKey || !trigger.options) return;
|
|
17263
|
+
if (isEntryRender()) {
|
|
17264
|
+
if (removed.has(trigger.macroKey)) return;
|
|
17265
|
+
removed.set(trigger.macroKey, {
|
|
17266
|
+
watcher: {
|
|
17267
|
+
condition: trigger.condition,
|
|
17268
|
+
options: { ...trigger.options }
|
|
17269
|
+
},
|
|
17270
|
+
order: trigger.order
|
|
17271
|
+
});
|
|
17272
|
+
} else removed.delete(trigger.macroKey);
|
|
17273
|
+
}
|
|
17274
|
+
/** Entry-render removals plus still active watchers, absent when none need replay. */
|
|
17275
|
+
function savedReplayWatchers() {
|
|
17276
|
+
const removed = replayRemovals();
|
|
17277
|
+
if (!removed.size) return void 0;
|
|
17278
|
+
const all = new Map(removed);
|
|
17279
|
+
for (const trigger of triggers) {
|
|
17280
|
+
if (!trigger.macroKey || !trigger.options || all.has(trigger.macroKey)) continue;
|
|
17281
|
+
all.set(trigger.macroKey, {
|
|
17282
|
+
watcher: {
|
|
17283
|
+
condition: trigger.condition,
|
|
17284
|
+
options: { ...trigger.options }
|
|
17285
|
+
},
|
|
17286
|
+
order: trigger.order
|
|
17287
|
+
});
|
|
17288
|
+
}
|
|
17289
|
+
return [...all.values()].sort((a, b) => a.order - b.order).map(({ watcher }) => watcher);
|
|
17290
|
+
}
|
|
17131
17291
|
/** Canonical identity includes every option, so an imported action cannot change it. */
|
|
17132
17292
|
function watcherKey(condition, options) {
|
|
17133
17293
|
const sorted = Object.fromEntries(Object.entries(options).sort(([a], [b]) => a < b ? -1 : 1));
|
|
@@ -17215,6 +17375,10 @@ function restoreMacroWatchers(watchers, interfaceSaved) {
|
|
|
17215
17375
|
for (const { condition, options } of interfaceWatches) addMacroTrigger(condition, options);
|
|
17216
17376
|
}
|
|
17217
17377
|
function removeTrigger(name) {
|
|
17378
|
+
for (const trigger of triggers) if (trigger.name === name) rememberRemoval(trigger);
|
|
17379
|
+
if (!isEntryRender()) {
|
|
17380
|
+
for (const [key, { watcher }] of replayRemovals()) if (watcher.options.name === name) replayRemoved.delete(key);
|
|
17381
|
+
}
|
|
17218
17382
|
triggers = triggers.filter((t) => t.name !== name);
|
|
17219
17383
|
}
|
|
17220
17384
|
function fireTrigger(trigger) {
|
|
@@ -17247,7 +17411,10 @@ function runCheckLoop() {
|
|
|
17247
17411
|
trigger.lastResult = result;
|
|
17248
17412
|
if (result && wasFalse) {
|
|
17249
17413
|
anyFired = true;
|
|
17250
|
-
if (trigger.options?.once)
|
|
17414
|
+
if (trigger.options?.once) {
|
|
17415
|
+
rememberRemoval(trigger);
|
|
17416
|
+
triggers = triggers.filter((t) => t !== trigger);
|
|
17417
|
+
}
|
|
17251
17418
|
fireTrigger(trigger);
|
|
17252
17419
|
}
|
|
17253
17420
|
}
|
|
@@ -17317,6 +17484,7 @@ function reinitTriggerState() {
|
|
|
17317
17484
|
*/
|
|
17318
17485
|
function resetTriggers() {
|
|
17319
17486
|
triggers = [];
|
|
17487
|
+
replayRemoved.clear();
|
|
17320
17488
|
resets++;
|
|
17321
17489
|
closeAllOpenDialogs();
|
|
17322
17490
|
resetListeners.notify();
|
|
@@ -17501,7 +17669,7 @@ function isPayload(value) {
|
|
|
17501
17669
|
if (!Array.isArray(history) || history.length === 0) return false;
|
|
17502
17670
|
if (!everyEntry(history, isMoment)) return false;
|
|
17503
17671
|
if (typeof historyIndex !== "number" || !Number.isInteger(historyIndex) || historyIndex < 0 || historyIndex >= history.length || history[historyIndex].passage !== value.passage) return false;
|
|
17504
|
-
return isCountsMap(value.visitCounts) && isCountsMap(value.renderCounts) && isOptionalPRNGSnapshot(value.prng) && isWatchers(value.watchers) && (value.interfaceWatchers === void 0 || typeof value.interfaceWatchers === "boolean");
|
|
17672
|
+
return isCountsMap(value.visitCounts) && isCountsMap(value.renderCounts) && isOptionalPRNGSnapshot(value.prng) && isWatchers(value.watchers) && isWatchers(value.replayWatchers) && (value.interfaceWatchers === void 0 || typeof value.interfaceWatchers === "boolean");
|
|
17505
17673
|
}
|
|
17506
17674
|
var mapToCounts = (counts) => counts instanceof Map ? createCounts(Object.fromEntries(counts)) : void 0;
|
|
17507
17675
|
/**
|
|
@@ -17519,6 +17687,7 @@ function decodePayload(encoded) {
|
|
|
17519
17687
|
if (!isPayload(body)) throw invalid();
|
|
17520
17688
|
assertArrayLengths(body, MAX_SAVE_ARRAY_LENGTH);
|
|
17521
17689
|
assertTrustedWatchers(body.watchers ?? []);
|
|
17690
|
+
assertTrustedWatchers(body.replayWatchers ?? []);
|
|
17522
17691
|
const payload = {
|
|
17523
17692
|
...body,
|
|
17524
17693
|
visitCounts: mapToCounts(body.visitCounts),
|
|
@@ -18891,6 +19060,7 @@ function computeVarPatches(prev, curr) {
|
|
|
18891
19060
|
* applyPatches copies each value, and recurses forever on a cycle).
|
|
18892
19061
|
*/
|
|
18893
19062
|
function applyVarPatches(vars, changes) {
|
|
19063
|
+
if (changes.length === 0) return vars;
|
|
18894
19064
|
const next = Object.create(Object.getPrototypeOf(vars));
|
|
18895
19065
|
for (const key of Object.keys(vars)) setOwn(next, key, vars[key]);
|
|
18896
19066
|
for (const change of changes) if (change.deleted) delete next[change.key];
|
|
@@ -18964,6 +19134,7 @@ function persistSession(get) {
|
|
|
18964
19134
|
renderCounts,
|
|
18965
19135
|
prng: snapshotPRNG(),
|
|
18966
19136
|
watchers: savedMacroWatchers(),
|
|
19137
|
+
replayWatchers: savedReplayWatchers(),
|
|
18967
19138
|
interfaceWatchers: interfaceMounted()
|
|
18968
19139
|
});
|
|
18969
19140
|
}
|
|
@@ -19035,6 +19206,7 @@ function finishEnteredMoment(get, set) {
|
|
|
19035
19206
|
const moment = enteredMoment;
|
|
19036
19207
|
enteredMoment = null;
|
|
19037
19208
|
if (!moment || get().navigationId !== moment.navigationId) return;
|
|
19209
|
+
clearReplayWatchers();
|
|
19038
19210
|
if (get().variables !== moment.variables) rerecordNewestMoment(get().variables);
|
|
19039
19211
|
lastNavigationVars = get().variables;
|
|
19040
19212
|
const prng = snapshotPRNG();
|
|
@@ -19143,6 +19315,7 @@ function recordStoryInitState() {
|
|
|
19143
19315
|
const { history, historyIndex, variables } = useStoryStore.getState();
|
|
19144
19316
|
if (history.length !== 1 || historyIndex !== 0) return;
|
|
19145
19317
|
resetModuleState(variables);
|
|
19318
|
+
clearReplayWatchers();
|
|
19146
19319
|
const prng = snapshotPRNG();
|
|
19147
19320
|
useStoryStore.setState((state) => {
|
|
19148
19321
|
state.history[0].prng = prng;
|
|
@@ -19907,6 +20080,7 @@ var useStoryStore = create()(storyStore((set, get) => ({
|
|
|
19907
20080
|
renderCounts: { ...renderCounts },
|
|
19908
20081
|
prng: snapshotPRNG(),
|
|
19909
20082
|
watchers: savedMacroWatchers(),
|
|
20083
|
+
replayWatchers: savedReplayWatchers(),
|
|
19910
20084
|
interfaceWatchers: interfaceMounted()
|
|
19911
20085
|
};
|
|
19912
20086
|
},
|
|
@@ -19935,6 +20109,7 @@ var useStoryStore = create()(storyStore((set, get) => ({
|
|
|
19935
20109
|
}
|
|
19936
20110
|
assertPassagesExist(get().storyData, payload);
|
|
19937
20111
|
assertTrustedWatchers(payload.watchers ?? []);
|
|
20112
|
+
assertTrustedWatchers(payload.replayWatchers ?? []);
|
|
19938
20113
|
applyReplacement(replacement);
|
|
19939
20114
|
leavingPlaythrough = leaving;
|
|
19940
20115
|
try {
|
|
@@ -19946,27 +20121,37 @@ var useStoryStore = create()(storyStore((set, get) => ({
|
|
|
19946
20121
|
const ifid = get().storyData?.ifid;
|
|
19947
20122
|
if (playthroughId && ifid) switchToLoadedPlaythrough(ifid, playthroughId);
|
|
19948
20123
|
const entry = loadedEntryMoment(payload);
|
|
19949
|
-
const
|
|
20124
|
+
const index = Math.max(0, Math.min(payload.historyIndex, payload.history.length - 1));
|
|
20125
|
+
const start = Math.min(index, Math.max(0, payload.history.length - get().maxHistory));
|
|
20126
|
+
const retained = payload.history.slice(start, start + get().maxHistory);
|
|
20127
|
+
const namespaces = /* @__PURE__ */ new Map();
|
|
20128
|
+
const snapshots = deepClone(retained.map((m) => m.variables)).map((vars) => {
|
|
20129
|
+
let normalized = namespaces.get(vars);
|
|
20130
|
+
if (!normalized) {
|
|
20131
|
+
normalized = createNamespace(vars);
|
|
20132
|
+
namespaces.set(vars, normalized);
|
|
20133
|
+
}
|
|
20134
|
+
return normalized;
|
|
20135
|
+
});
|
|
19950
20136
|
variableBase = deepClone(snapshots[0]);
|
|
19951
|
-
patchEntries = snapshots.slice(1).map((curr, i) => computeVarPatches(snapshots[i], curr));
|
|
19952
|
-
sessionMoments =
|
|
20137
|
+
patchEntries = snapshots.slice(1).map((curr, i) => curr === snapshots[i] ? { forward: [] } : computeVarPatches(snapshots[i], curr));
|
|
20138
|
+
sessionMoments = retained.map((m, i) => savedMoment(m, snapshots[i]));
|
|
19953
20139
|
set((state) => {
|
|
19954
20140
|
state.currentPassage = payload.passage;
|
|
19955
20141
|
state.navigationId++;
|
|
19956
20142
|
state.variables = createNamespace(deepClone(entry?.variables ?? payload.variables));
|
|
19957
|
-
state.history =
|
|
20143
|
+
state.history = retained.map((m) => ({
|
|
19958
20144
|
passage: m.passage,
|
|
19959
20145
|
timestamp: m.timestamp,
|
|
19960
20146
|
prng: m.prng
|
|
19961
20147
|
}));
|
|
19962
|
-
state.historyIndex =
|
|
19963
|
-
trimHistory(state);
|
|
20148
|
+
state.historyIndex = index - start;
|
|
19964
20149
|
state.visitCounts = createCounts(payload.visitCounts);
|
|
19965
20150
|
state.renderCounts = createCounts(payload.renderCounts);
|
|
19966
20151
|
state.temporary = createNamespace();
|
|
19967
20152
|
state.transient = freshTransients(get().transientDefaults);
|
|
19968
20153
|
});
|
|
19969
|
-
if (payload.watchers) restoreMacroWatchers(payload.watchers, payload.interfaceWatchers);
|
|
20154
|
+
if (payload.watchers) restoreMacroWatchers(payload.replayWatchers ?? payload.watchers, payload.interfaceWatchers);
|
|
19970
20155
|
reinitTriggerState();
|
|
19971
20156
|
lastNavigationVars = reconstructVarsAt(get().historyIndex);
|
|
19972
20157
|
restorePRNGFrom(entry?.prng !== void 0 ? entry.prng : payload.prng);
|
|
@@ -21022,6 +21207,7 @@ function defineMacro(config, source = "builtin") {
|
|
|
21022
21207
|
checkParameterTypes(config.name, parameters);
|
|
21023
21208
|
const acts = actingMacros.has(config.name);
|
|
21024
21209
|
function Wrapper(props) {
|
|
21210
|
+
const entryRender = useContext(EntryRenderContext);
|
|
21025
21211
|
const displayOnly = useContext(DisplayOnlyContext);
|
|
21026
21212
|
if (displayOnly && acts) return h(MacroError, {
|
|
21027
21213
|
macro: config.name,
|
|
@@ -21124,7 +21310,7 @@ function defineMacro(config, source = "builtin") {
|
|
|
21124
21310
|
};
|
|
21125
21311
|
}
|
|
21126
21312
|
try {
|
|
21127
|
-
return config.render(props, ctx);
|
|
21313
|
+
return entryRender?.pending ? duringEntryRender(() => config.render(props, ctx)) : duringMacroRender(() => config.render(props, ctx));
|
|
21128
21314
|
} catch (error) {
|
|
21129
21315
|
if (error instanceof MacroArgumentError) return h(MacroError, {
|
|
21130
21316
|
macro: config.name,
|
|
@@ -21154,21 +21340,6 @@ function defineMacro(config, source = "builtin") {
|
|
|
21154
21340
|
setDefinedBlockMacro(config.name, isBlock);
|
|
21155
21341
|
}
|
|
21156
21342
|
//#endregion
|
|
21157
|
-
//#region src/passage-render-state.ts
|
|
21158
|
-
/**
|
|
21159
|
-
* Navigation id (the store's `navigationId`) of the passage most recently
|
|
21160
|
-
* mounted by <Passage> (null until the first render, e.g. when the story
|
|
21161
|
-
* interface has no {passage}). Lets Story.waitForActions() tell whether the
|
|
21162
|
-
* current navigation is on screen, also when it revisits the passage shown.
|
|
21163
|
-
*/
|
|
21164
|
-
var renderedNavigationId = null;
|
|
21165
|
-
function markPassageRendered(navigationId) {
|
|
21166
|
-
renderedNavigationId = navigationId;
|
|
21167
|
-
}
|
|
21168
|
-
function getRenderedNavigationId() {
|
|
21169
|
-
return renderedNavigationId;
|
|
21170
|
-
}
|
|
21171
|
-
//#endregion
|
|
21172
21343
|
//#region src/story-context-passage.ts
|
|
21173
21344
|
/**
|
|
21174
21345
|
* The macros a display-only passage may not use besides the input macros:
|
|
@@ -22450,22 +22621,40 @@ var Reader = class {
|
|
|
22450
22621
|
}
|
|
22451
22622
|
/** Skip an array literal (or any bracketed group) at the cursor. */
|
|
22452
22623
|
skipBalanced() {
|
|
22453
|
-
const { src } = this;
|
|
22454
22624
|
const close = {
|
|
22455
22625
|
"[": "]",
|
|
22456
22626
|
"{": "}",
|
|
22457
22627
|
"(": ")"
|
|
22458
|
-
}[src.charAt(this.i)];
|
|
22459
|
-
|
|
22628
|
+
}[this.src.charAt(this.i)];
|
|
22629
|
+
return close ? this.skipNested(close) : false;
|
|
22630
|
+
}
|
|
22631
|
+
/** Skip groups and template interpolations with an explicit stack. */
|
|
22632
|
+
skipNested(close) {
|
|
22633
|
+
const { src } = this;
|
|
22634
|
+
const stack = [close];
|
|
22460
22635
|
this.i++;
|
|
22461
|
-
while (this.i < src.length) {
|
|
22462
|
-
|
|
22636
|
+
while (this.i < src.length && stack.length) {
|
|
22637
|
+
const c = src.charAt(this.i);
|
|
22638
|
+
const top = stack[stack.length - 1];
|
|
22639
|
+
if (c === top) {
|
|
22640
|
+
stack.pop();
|
|
22463
22641
|
this.i++;
|
|
22464
|
-
|
|
22465
|
-
|
|
22466
|
-
|
|
22642
|
+
} else if (top === "`") {
|
|
22643
|
+
if (c === "\\") this.i += 2;
|
|
22644
|
+
else if (c === "$" && src.charAt(this.i + 1) === "{") {
|
|
22645
|
+
stack.push("}");
|
|
22646
|
+
this.i += 2;
|
|
22647
|
+
} else this.i++;
|
|
22648
|
+
} else if (c === "`" || c === "[" || c === "{" || c === "(") {
|
|
22649
|
+
stack.push(c === "`" ? "`" : {
|
|
22650
|
+
"[": "]",
|
|
22651
|
+
"{": "}",
|
|
22652
|
+
"(": ")"
|
|
22653
|
+
}[c]);
|
|
22654
|
+
this.i++;
|
|
22655
|
+
} else if (!this.skipOne()) return false;
|
|
22467
22656
|
}
|
|
22468
|
-
return
|
|
22657
|
+
return stack.length === 0;
|
|
22469
22658
|
}
|
|
22470
22659
|
/** Skip one character, or one string, template, comment or group. */
|
|
22471
22660
|
skipOne() {
|
|
@@ -22492,20 +22681,7 @@ var Reader = class {
|
|
|
22492
22681
|
}
|
|
22493
22682
|
/** Skip a template literal, with the expressions in it. */
|
|
22494
22683
|
skipTemplate() {
|
|
22495
|
-
|
|
22496
|
-
this.i++;
|
|
22497
|
-
while (this.i < src.length) {
|
|
22498
|
-
const c = src.charAt(this.i);
|
|
22499
|
-
if (c === "\\") this.i += 2;
|
|
22500
|
-
else if (c === "`") {
|
|
22501
|
-
this.i++;
|
|
22502
|
-
return true;
|
|
22503
|
-
} else if (c === "$" && src.charAt(this.i + 1) === "{") {
|
|
22504
|
-
this.i++;
|
|
22505
|
-
if (!this.skipBalanced()) return false;
|
|
22506
|
-
} else this.i++;
|
|
22507
|
-
}
|
|
22508
|
-
return false;
|
|
22684
|
+
return this.skipNested("`");
|
|
22509
22685
|
}
|
|
22510
22686
|
};
|
|
22511
22687
|
//#endregion
|
|
@@ -23077,6 +23253,17 @@ var CODE_PASSAGES = /* @__PURE__ */ new Set([
|
|
|
23077
23253
|
"PassageFooter",
|
|
23078
23254
|
"PassageDone"
|
|
23079
23255
|
]);
|
|
23256
|
+
/** PassageDone mounts after the main passage committed, but replays on load. */
|
|
23257
|
+
function EntryRenderBoundary({ children }) {
|
|
23258
|
+
const phase = useRef({ pending: true });
|
|
23259
|
+
useLayoutEffect(() => {
|
|
23260
|
+
phase.current.pending = false;
|
|
23261
|
+
}, []);
|
|
23262
|
+
return /* @__PURE__ */ jsx(EntryRenderContext.Provider, {
|
|
23263
|
+
value: phase.current,
|
|
23264
|
+
children
|
|
23265
|
+
});
|
|
23266
|
+
}
|
|
23080
23267
|
function Passage({ passage, dataTransition, navigationId }) {
|
|
23081
23268
|
const { storyData } = useStoryFields("storyData");
|
|
23082
23269
|
const isCodePassage = CODE_PASSAGES.has(passage.name);
|
|
@@ -23112,7 +23299,12 @@ function Passage({ passage, dataTransition, navigationId }) {
|
|
|
23112
23299
|
const elRef = useRef(null);
|
|
23113
23300
|
useLayoutEffect(() => {
|
|
23114
23301
|
if (navigationId !== void 0) markPassageRendered(navigationId);
|
|
23115
|
-
if (elRef.current)
|
|
23302
|
+
if (elRef.current) {
|
|
23303
|
+
const element = elRef.current;
|
|
23304
|
+
const emit = () => emitFromRender("passagerender", passage.name, element);
|
|
23305
|
+
if (navigationId !== void 0) duringEntryRender(emit);
|
|
23306
|
+
else emit();
|
|
23307
|
+
}
|
|
23116
23308
|
}, [passage.name, navigationId]);
|
|
23117
23309
|
const nobr = passage.tags.includes("nobr");
|
|
23118
23310
|
const viewScope = useViewScope();
|
|
@@ -23136,10 +23328,10 @@ function Passage({ passage, dataTransition, navigationId }) {
|
|
|
23136
23328
|
class: "passage-footer",
|
|
23137
23329
|
children: footerContent
|
|
23138
23330
|
}),
|
|
23139
|
-
doneContent && /* @__PURE__ */ jsx("div", {
|
|
23331
|
+
doneContent && /* @__PURE__ */ jsx(EntryRenderBoundary, { children: /* @__PURE__ */ jsx("div", {
|
|
23140
23332
|
hidden: true,
|
|
23141
23333
|
children: doneContent
|
|
23142
|
-
})
|
|
23334
|
+
}) })
|
|
23143
23335
|
]
|
|
23144
23336
|
})
|
|
23145
23337
|
})
|