jssm 5.141.5 → 5.141.8

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.
@@ -326,7 +326,7 @@ function peg$parse(input, options) {
326
326
  var peg$FAILED = {}, peg$startRuleFunctions = { Document: peg$parseDocument }, peg$startRuleFunction = peg$parseDocument, peg$c0 = function (e) { return e; }, peg$c1 = "default", peg$c2 = peg$literalExpectation("default", false), peg$c3 = "ocean", peg$c4 = peg$literalExpectation("ocean", false), peg$c5 = "modern", peg$c6 = peg$literalExpectation("modern", false), peg$c7 = "plain", peg$c8 = peg$literalExpectation("plain", false), peg$c9 = "bold", peg$c10 = peg$literalExpectation("bold", false), peg$c11 = "[", peg$c12 = peg$literalExpectation("[", false), peg$c13 = "]", peg$c14 = peg$literalExpectation("]", false), peg$c15 = function (ths, th) { const themes = ths.map(t => t[0]); if (th)
327
327
  themes.push(th); return themes; }, peg$c16 = function (th) { return [th]; }, peg$c17 = "box3d", peg$c18 = peg$literalExpectation("box3d", false), peg$c19 = "polygon", peg$c20 = peg$literalExpectation("polygon", false), peg$c21 = "ellipse", peg$c22 = peg$literalExpectation("ellipse", false), peg$c23 = "oval", peg$c24 = peg$literalExpectation("oval", false), peg$c25 = "circle", peg$c26 = peg$literalExpectation("circle", false), peg$c27 = "point", peg$c28 = peg$literalExpectation("point", false), peg$c29 = "egg", peg$c30 = peg$literalExpectation("egg", false), peg$c31 = "triangle", peg$c32 = peg$literalExpectation("triangle", false), peg$c33 = "plaintext", peg$c34 = peg$literalExpectation("plaintext", false), peg$c35 = "diamond", peg$c36 = peg$literalExpectation("diamond", false), peg$c37 = "trapezium", peg$c38 = peg$literalExpectation("trapezium", false), peg$c39 = "parallelogram", peg$c40 = peg$literalExpectation("parallelogram", false), peg$c41 = "house", peg$c42 = peg$literalExpectation("house", false), peg$c43 = "pentagon", peg$c44 = peg$literalExpectation("pentagon", false), peg$c45 = "hexagon", peg$c46 = peg$literalExpectation("hexagon", false), peg$c47 = "septagon", peg$c48 = peg$literalExpectation("septagon", false), peg$c49 = "octagon", peg$c50 = peg$literalExpectation("octagon", false), peg$c51 = "doublecircle", peg$c52 = peg$literalExpectation("doublecircle", false), peg$c53 = "doubleoctagon", peg$c54 = peg$literalExpectation("doubleoctagon", false), peg$c55 = "tripleoctagon", peg$c56 = peg$literalExpectation("tripleoctagon", false), peg$c57 = "invtriangle", peg$c58 = peg$literalExpectation("invtriangle", false), peg$c59 = "invtrapezium", peg$c60 = peg$literalExpectation("invtrapezium", false), peg$c61 = "invhouse", peg$c62 = peg$literalExpectation("invhouse", false), peg$c63 = "Mdiamond", peg$c64 = peg$literalExpectation("Mdiamond", false), peg$c65 = "Msquare", peg$c66 = peg$literalExpectation("Msquare", false), peg$c67 = "Mcircle", peg$c68 = peg$literalExpectation("Mcircle", false), peg$c69 = "rectangle", peg$c70 = peg$literalExpectation("rectangle", false), peg$c71 = "rect", peg$c72 = peg$literalExpectation("rect", false), peg$c73 = "square", peg$c74 = peg$literalExpectation("square", false), peg$c75 = "star", peg$c76 = peg$literalExpectation("star", false), peg$c77 = "none", peg$c78 = peg$literalExpectation("none", false), peg$c79 = "underline", peg$c80 = peg$literalExpectation("underline", false), peg$c81 = "cylinder", peg$c82 = peg$literalExpectation("cylinder", false), peg$c83 = "note", peg$c84 = peg$literalExpectation("note", false), peg$c85 = "tab", peg$c86 = peg$literalExpectation("tab", false), peg$c87 = "folder", peg$c88 = peg$literalExpectation("folder", false), peg$c89 = "box", peg$c90 = peg$literalExpectation("box", false), peg$c91 = "component", peg$c92 = peg$literalExpectation("component", false), peg$c93 = "promoter", peg$c94 = peg$literalExpectation("promoter", false), peg$c95 = "cds", peg$c96 = peg$literalExpectation("cds", false), peg$c97 = "terminator", peg$c98 = peg$literalExpectation("terminator", false), peg$c99 = "utr", peg$c100 = peg$literalExpectation("utr", false), peg$c101 = "primersite", peg$c102 = peg$literalExpectation("primersite", false), peg$c103 = "restrictionsite", peg$c104 = peg$literalExpectation("restrictionsite", false), peg$c105 = "fivepoverhang", peg$c106 = peg$literalExpectation("fivepoverhang", false), peg$c107 = "threepoverhang", peg$c108 = peg$literalExpectation("threepoverhang", false), peg$c109 = "noverhang", peg$c110 = peg$literalExpectation("noverhang", false), peg$c111 = "assembly", peg$c112 = peg$literalExpectation("assembly", false), peg$c113 = "signature", peg$c114 = peg$literalExpectation("signature", false), peg$c115 = "insulator", peg$c116 = peg$literalExpectation("insulator", false), peg$c117 = "ribosite", peg$c118 = peg$literalExpectation("ribosite", false), peg$c119 = "rnastab", peg$c120 = peg$literalExpectation("rnastab", false), peg$c121 = "proteasesite", peg$c122 = peg$literalExpectation("proteasesite", false), peg$c123 = "proteinstab", peg$c124 = peg$literalExpectation("proteinstab", false), peg$c125 = "rpromoter", peg$c126 = peg$literalExpectation("rpromoter", false), peg$c127 = "rarrow", peg$c128 = peg$literalExpectation("rarrow", false), peg$c129 = "larrow", peg$c130 = peg$literalExpectation("larrow", false), peg$c131 = "lpromoter", peg$c132 = peg$literalExpectation("lpromoter", false), peg$c133 = "record", peg$c134 = peg$literalExpectation("record", false), peg$c135 = peg$otherExpectation("forward light arrow ->"), peg$c136 = "->", peg$c137 = peg$literalExpectation("->", false), peg$c138 = "\u2192", peg$c139 = peg$literalExpectation("\u2192", false), peg$c140 = function () { return "->"; }, peg$c141 = peg$otherExpectation("two way light arrow <->"), peg$c142 = "<->", peg$c143 = peg$literalExpectation("<->", false), peg$c144 = "\u2194", peg$c145 = peg$literalExpectation("\u2194", false), peg$c146 = function () { return "<->"; }, peg$c147 = peg$otherExpectation("back light arrow <-"), peg$c148 = "<-", peg$c149 = peg$literalExpectation("<-", false), peg$c150 = "\u2190", peg$c151 = peg$literalExpectation("\u2190", false), peg$c152 = function () { return "<-"; }, peg$c153 = peg$otherExpectation("forward fat arrow =>"), peg$c154 = "=>", peg$c155 = peg$literalExpectation("=>", false), peg$c156 = "\u21D2", peg$c157 = peg$literalExpectation("\u21D2", false), peg$c158 = function () { return "=>"; }, peg$c159 = peg$otherExpectation("two way fat arrow <=>"), peg$c160 = "<=>", peg$c161 = peg$literalExpectation("<=>", false), peg$c162 = "\u21D4", peg$c163 = peg$literalExpectation("\u21D4", false), peg$c164 = function () { return "<=>"; }, peg$c165 = peg$otherExpectation("back fat arrow <="), peg$c166 = "<=", peg$c167 = peg$literalExpectation("<=", false), peg$c168 = "\u21D0", peg$c169 = peg$literalExpectation("\u21D0", false), peg$c170 = function () { return "<="; }, peg$c171 = peg$otherExpectation("forward tilde arrow ~>"), peg$c172 = "~>", peg$c173 = peg$literalExpectation("~>", false), peg$c174 = "\u219B", peg$c175 = peg$literalExpectation("\u219B", false), peg$c176 = function () { return "~>"; }, peg$c177 = peg$otherExpectation("two way tilde arrow <~>"), peg$c178 = "<~>", peg$c179 = peg$literalExpectation("<~>", false), peg$c180 = "\u21AE", peg$c181 = peg$literalExpectation("\u21AE", false), peg$c182 = function () { return "<~>"; }, peg$c183 = peg$otherExpectation("back tilde arrow <~"), peg$c184 = "<~", peg$c185 = peg$literalExpectation("<~", false), peg$c186 = "\u219A", peg$c187 = peg$literalExpectation("\u219A", false), peg$c188 = function () { return "<~"; }, peg$c189 = peg$otherExpectation("light fat arrow <-=>"), peg$c190 = "<-=>", peg$c191 = peg$literalExpectation("<-=>", false), peg$c192 = "\u2190\u21D2", peg$c193 = peg$literalExpectation("\u2190\u21D2", false), peg$c194 = function () { return "<-=>"; }, peg$c195 = peg$otherExpectation("light tilde arrow <-~>"), peg$c196 = "<-~>", peg$c197 = peg$literalExpectation("<-~>", false), peg$c198 = "\u2190\u219B", peg$c199 = peg$literalExpectation("\u2190\u219B", false), peg$c200 = function () { return "<-~>"; }, peg$c201 = peg$otherExpectation("fat light arrow <=->"), peg$c202 = "<=->", peg$c203 = peg$literalExpectation("<=->", false), peg$c204 = "\u21D0\u2192", peg$c205 = peg$literalExpectation("\u21D0\u2192", false), peg$c206 = function () { return "<=->"; }, peg$c207 = peg$otherExpectation("fat tilde arrow <=~>"), peg$c208 = "<=~>", peg$c209 = peg$literalExpectation("<=~>", false), peg$c210 = "\u21D0\u219B", peg$c211 = peg$literalExpectation("\u21D0\u219B", false), peg$c212 = function () { return "<=~>"; }, peg$c213 = peg$otherExpectation("tilde light arrow <~->"), peg$c214 = "<~->", peg$c215 = peg$literalExpectation("<~->", false), peg$c216 = "\u219A\u2192", peg$c217 = peg$literalExpectation("\u219A\u2192", false), peg$c218 = function () { return "<~->"; }, peg$c219 = peg$otherExpectation("tilde fat arrow <~=>"), peg$c220 = "<~=>", peg$c221 = peg$literalExpectation("<~=>", false), peg$c222 = "\u219A\u21D2", peg$c223 = peg$literalExpectation("\u219A\u21D2", false), peg$c224 = function () { return "<~=>"; }, peg$c225 = peg$otherExpectation("light arrow"), peg$c226 = peg$otherExpectation("fat arrow"), peg$c227 = peg$otherExpectation("tilde arrow"), peg$c228 = peg$otherExpectation("mixed arrow"), peg$c229 = peg$otherExpectation("arrow"), peg$c230 = "true", peg$c231 = peg$literalExpectation("true", false), peg$c232 = function () { return true; }, peg$c233 = "false", peg$c234 = peg$literalExpectation("false", false), peg$c235 = function () { return false; }, peg$c236 = "regular", peg$c237 = peg$literalExpectation("regular", false), peg$c238 = "rounded", peg$c239 = peg$literalExpectation("rounded", false), peg$c240 = "lined", peg$c241 = peg$literalExpectation("lined", false), peg$c242 = "solid", peg$c243 = peg$literalExpectation("solid", false), peg$c244 = "dotted", peg$c245 = peg$literalExpectation("dotted", false), peg$c246 = "dashed", peg$c247 = peg$literalExpectation("dashed", false), peg$c248 = "\"", peg$c249 = peg$literalExpectation("\"", false), peg$c250 = "\\", peg$c251 = peg$literalExpectation("\\", false), peg$c252 = "/", peg$c253 = peg$literalExpectation("/", false), peg$c254 = "b", peg$c255 = peg$literalExpectation("b", false), peg$c256 = function () { return "\b"; }, peg$c257 = "f", peg$c258 = peg$literalExpectation("f", false), peg$c259 = function () { return "\f"; }, peg$c260 = "n", peg$c261 = peg$literalExpectation("n", false), peg$c262 = function () { return "\n"; }, peg$c263 = "r", peg$c264 = peg$literalExpectation("r", false), peg$c265 = function () { return "\r"; }, peg$c266 = "t", peg$c267 = peg$literalExpectation("t", false), peg$c268 = function () { return "\t"; }, peg$c269 = "v", peg$c270 = peg$literalExpectation("v", false), peg$c271 = function () { return "\v"; }, peg$c272 = "u", peg$c273 = peg$literalExpectation("u", false), peg$c274 = function (digits) {
328
328
  return String.fromCharCode(parseInt(digits, 16));
329
- }, peg$c275 = function (Sequence) { return Sequence; }, peg$c276 = "null", peg$c277 = peg$literalExpectation("null", false), peg$c278 = function () { return null; }, peg$c279 = "undefined", peg$c280 = peg$literalExpectation("undefined", false), peg$c281 = function () { return undefined; }, peg$c282 = /^[\0-!#-[\]-\uFFFF]/, peg$c283 = peg$classExpectation([["\0", "!"], ["#", "["], ["]", "\uFFFF"]], false, false), peg$c284 = "'", peg$c285 = peg$literalExpectation("'", false), peg$c286 = /^[ -&(-[\]-\uFFFF]/, peg$c287 = peg$classExpectation([[" ", "&"], ["(", "["], ["]", "\uFFFF"]], false, false), peg$c288 = peg$otherExpectation("action label"), peg$c289 = function (chars) { return chars.join(""); }, peg$c290 = /^[\n\r\u2028\u2029]/, peg$c291 = peg$classExpectation(["\n", "\r", "\u2028", "\u2029"], false, false), peg$c292 = "*/", peg$c293 = peg$literalExpectation("*/", false), peg$c294 = peg$anyExpectation(), peg$c295 = peg$otherExpectation("block comment"), peg$c296 = "/*", peg$c297 = peg$literalExpectation("/*", false), peg$c298 = peg$otherExpectation("line comment"), peg$c299 = "//", peg$c300 = peg$literalExpectation("//", false), peg$c301 = peg$otherExpectation("whitespace"), peg$c302 = /^[ \t\r\n\x0B]/, peg$c303 = peg$classExpectation([" ", "\t", "\r", "\n", "\x0B"], false, false), peg$c304 = peg$otherExpectation("string"), peg$c305 = /^[0-9a-zA-Z._!$\^*!?,\x80-\uFFFF]/, peg$c306 = peg$classExpectation([["0", "9"], ["a", "z"], ["A", "Z"], ".", "_", "!", "$", "^", "*", "!", "?", ",", ["\x80", "\uFFFF"]], false, false), peg$c307 = /^[0-9a-zA-Z.+_\^()*&$#@!?,\x80-\uFFFF]/, peg$c308 = peg$classExpectation([["0", "9"], ["a", "z"], ["A", "Z"], ".", "+", "_", "^", "(", ")", "*", "&", "$", "#", "@", "!", "?", ",", ["\x80", "\uFFFF"]], false, false), peg$c309 = peg$otherExpectation("atom"), peg$c310 = function (firstletter, text) {
329
+ }, peg$c275 = function (Sequence) { return Sequence; }, peg$c276 = "null", peg$c277 = peg$literalExpectation("null", false), peg$c278 = function () { return null; }, peg$c279 = "undefined", peg$c280 = peg$literalExpectation("undefined", false), peg$c281 = function () { return undefined; }, peg$c282 = /^[\0-!#-[\]-\uFFFF]/, peg$c283 = peg$classExpectation([["\0", "!"], ["#", "["], ["]", "\uFFFF"]], false, false), peg$c284 = "'", peg$c285 = peg$literalExpectation("'", false), peg$c286 = /^[ -&(-[\]-\uFFFF]/, peg$c287 = peg$classExpectation([[" ", "&"], ["(", "["], ["]", "\uFFFF"]], false, false), peg$c288 = peg$otherExpectation("action label"), peg$c289 = function (chars) { return chars.join(""); }, peg$c290 = /^[\n\r\u2028\u2029]/, peg$c291 = peg$classExpectation(["\n", "\r", "\u2028", "\u2029"], false, false), peg$c292 = peg$otherExpectation("block comment"), peg$c293 = "/*", peg$c294 = peg$literalExpectation("/*", false), peg$c295 = "*/", peg$c296 = peg$literalExpectation("*/", false), peg$c297 = peg$anyExpectation(), peg$c298 = peg$otherExpectation("line comment"), peg$c299 = "//", peg$c300 = peg$literalExpectation("//", false), peg$c301 = peg$otherExpectation("whitespace"), peg$c302 = /^[ \t\r\n\x0B]/, peg$c303 = peg$classExpectation([" ", "\t", "\r", "\n", "\x0B"], false, false), peg$c304 = peg$otherExpectation("string"), peg$c305 = /^[0-9a-zA-Z._!$\^*!?,\x80-\uFFFF]/, peg$c306 = peg$classExpectation([["0", "9"], ["a", "z"], ["A", "Z"], ".", "_", "!", "$", "^", "*", "!", "?", ",", ["\x80", "\uFFFF"]], false, false), peg$c307 = /^[0-9a-zA-Z.+_\^()*&$#@!?,\x80-\uFFFF]/, peg$c308 = peg$classExpectation([["0", "9"], ["a", "z"], ["A", "Z"], ".", "+", "_", "^", "(", ")", "*", "&", "$", "#", "@", "!", "?", ",", ["\x80", "\uFFFF"]], false, false), peg$c309 = peg$otherExpectation("atom"), peg$c310 = function (firstletter, text) {
330
330
  return firstletter + ((text || []).join(''));
331
331
  }, peg$c311 = peg$otherExpectation("label"), peg$c312 = "0", peg$c313 = peg$literalExpectation("0", false), peg$c314 = /^[0-9]/, peg$c315 = peg$classExpectation([["0", "9"]], false, false), peg$c316 = /^[1-9]/, peg$c317 = peg$classExpectation([["1", "9"]], false, false), peg$c318 = /^[0-9a-f]/i, peg$c319 = peg$classExpectation([["0", "9"], ["a", "f"]], false, true), peg$c320 = /^[0-1]/, peg$c321 = peg$classExpectation([["0", "1"]], false, false), peg$c322 = /^[0-7]/, peg$c323 = peg$classExpectation([["0", "7"]], false, false), peg$c324 = peg$otherExpectation("nonneg number"), peg$c325 = ".", peg$c326 = peg$literalExpectation(".", false), peg$c327 = function () { return parseFloat(text()); }, peg$c328 = peg$otherExpectation("number"), peg$c329 = function (literal) { return literal; }, peg$c330 = "NaN", peg$c331 = peg$literalExpectation("NaN", false), peg$c332 = function () { return NaN; }, peg$c333 = "NegativeInfinity", peg$c334 = peg$literalExpectation("NegativeInfinity", false), peg$c335 = function () { return Number.NEGATIVE_INFINITY; }, peg$c336 = "NegativeInf", peg$c337 = peg$literalExpectation("NegativeInf", false), peg$c338 = "NegInfinity", peg$c339 = peg$literalExpectation("NegInfinity", false), peg$c340 = "NegInf", peg$c341 = peg$literalExpectation("NegInf", false), peg$c342 = "NInfinity", peg$c343 = peg$literalExpectation("NInfinity", false), peg$c344 = "NInf", peg$c345 = peg$literalExpectation("NInf", false), peg$c346 = "-\u221E", peg$c347 = peg$literalExpectation("-\u221E", false), peg$c348 = "PInfinity", peg$c349 = peg$literalExpectation("PInfinity", false), peg$c350 = function () { return Number.POSITIVE_INFINITY; }, peg$c351 = "Infinity", peg$c352 = peg$literalExpectation("Infinity", false), peg$c353 = "PInf", peg$c354 = peg$literalExpectation("PInf", false), peg$c355 = "Inf", peg$c356 = peg$literalExpectation("Inf", false), peg$c357 = "\u221E", peg$c358 = peg$literalExpectation("\u221E", false), peg$c359 = "Epsilon", peg$c360 = peg$literalExpectation("Epsilon", false), peg$c361 = function () { return Number.EPSILON; }, peg$c362 = "\uD835\uDF00", peg$c363 = peg$literalExpectation("\uD835\uDF00", false), peg$c364 = "\u03B5", peg$c365 = peg$literalExpectation("\u03B5", false), peg$c366 = "Pi", peg$c367 = peg$literalExpectation("Pi", false), peg$c368 = function () { return Math.PI; }, peg$c369 = "\uD835\uDF0B", peg$c370 = peg$literalExpectation("\uD835\uDF0B", false), peg$c371 = "\u03C0", peg$c372 = peg$literalExpectation("\u03C0", false), peg$c373 = "EulerNumber", peg$c374 = peg$literalExpectation("EulerNumber", false), peg$c375 = function () { return Math.E; }, peg$c376 = "E", peg$c377 = peg$literalExpectation("E", false), peg$c378 = "e", peg$c379 = peg$literalExpectation("e", false), peg$c380 = "\u0190", peg$c381 = peg$literalExpectation("\u0190", false), peg$c382 = "\u2107", peg$c383 = peg$literalExpectation("\u2107", false), peg$c384 = "Root2", peg$c385 = peg$literalExpectation("Root2", false), peg$c386 = function () { return Math.SQRT2; }, peg$c387 = "RootHalf", peg$c388 = peg$literalExpectation("RootHalf", false), peg$c389 = function () { return Math.SQRT1_2; }, peg$c390 = "Ln2", peg$c391 = peg$literalExpectation("Ln2", false), peg$c392 = function () { return Math.LN2; }, peg$c393 = "NatLog2", peg$c394 = peg$literalExpectation("NatLog2", false), peg$c395 = "Ln10", peg$c396 = peg$literalExpectation("Ln10", false), peg$c397 = function () { return Math.LN10; }, peg$c398 = "NatLog10", peg$c399 = peg$literalExpectation("NatLog10", false), peg$c400 = "Log2E", peg$c401 = peg$literalExpectation("Log2E", false), peg$c402 = function () { return Math.LOG2E; }, peg$c403 = "Log10E", peg$c404 = peg$literalExpectation("Log10E", false), peg$c405 = function () { return Math.LOG10E; }, peg$c406 = "MaxSafeInt", peg$c407 = peg$literalExpectation("MaxSafeInt", false), peg$c408 = function () { return Number.MAX_SAFE_INTEGER; }, peg$c409 = "MinSafeInt", peg$c410 = peg$literalExpectation("MinSafeInt", false), peg$c411 = function () { return Number.MIN_SAFE_INTEGER; }, peg$c412 = "MaxPosNum", peg$c413 = peg$literalExpectation("MaxPosNum", false), peg$c414 = function () { return Number.MAX_VALUE; }, peg$c415 = "MinPosNum", peg$c416 = peg$literalExpectation("MinPosNum", false), peg$c417 = function () { return Number.MIN_VALUE; }, peg$c418 = "Phi", peg$c419 = peg$literalExpectation("Phi", false), peg$c420 = function () { return 1.61803398874989484820; }, peg$c421 = "\uD835\uDF11", peg$c422 = peg$literalExpectation("\uD835\uDF11", false), peg$c423 = "\uD835\uDF19", peg$c424 = peg$literalExpectation("\uD835\uDF19", false), peg$c425 = "\u03D5", peg$c426 = peg$literalExpectation("\u03D5", false), peg$c427 = "\u03C6", peg$c428 = peg$literalExpectation("\u03C6", false), peg$c429 = "EulerConstant", peg$c430 = peg$literalExpectation("EulerConstant", false), peg$c431 = function () { return 0.57721566490153286060; }, peg$c432 = "\u03B3", peg$c433 = peg$literalExpectation("\u03B3", false), peg$c434 = "\uD835\uDEFE", peg$c435 = peg$literalExpectation("\uD835\uDEFE", false), peg$c436 = peg$literalExpectation("e", true), peg$c437 = /^[+\-]/, peg$c438 = peg$classExpectation(["+", "-"], false, false), peg$c439 = "0x", peg$c440 = peg$literalExpectation("0x", true), peg$c441 = function (digits) {
332
332
  return parseInt(digits, 16);
@@ -2902,67 +2902,134 @@ function peg$parse(input, options) {
2902
2902
  }
2903
2903
  return s0;
2904
2904
  }
2905
- function peg$parseBlockCommentTail() {
2906
- var s0, s1, s2;
2907
- if (input.substr(peg$currPos, 2) === peg$c292) {
2908
- s0 = peg$c292;
2905
+ function peg$parseBlockComment() {
2906
+ var s0, s1, s2, s3, s4, s5;
2907
+ peg$silentFails++;
2908
+ s0 = peg$currPos;
2909
+ if (input.substr(peg$currPos, 2) === peg$c293) {
2910
+ s1 = peg$c293;
2909
2911
  peg$currPos += 2;
2910
2912
  }
2911
2913
  else {
2912
- s0 = peg$FAILED;
2914
+ s1 = peg$FAILED;
2913
2915
  if (peg$silentFails === 0) {
2914
- peg$fail(peg$c293);
2916
+ peg$fail(peg$c294);
2915
2917
  }
2916
2918
  }
2917
- if (s0 === peg$FAILED) {
2918
- s0 = peg$currPos;
2919
- if (input.length > peg$currPos) {
2920
- s1 = input.charAt(peg$currPos);
2921
- peg$currPos++;
2919
+ if (s1 !== peg$FAILED) {
2920
+ s2 = [];
2921
+ s3 = peg$currPos;
2922
+ s4 = peg$currPos;
2923
+ peg$silentFails++;
2924
+ if (input.substr(peg$currPos, 2) === peg$c295) {
2925
+ s5 = peg$c295;
2926
+ peg$currPos += 2;
2922
2927
  }
2923
2928
  else {
2924
- s1 = peg$FAILED;
2929
+ s5 = peg$FAILED;
2925
2930
  if (peg$silentFails === 0) {
2926
- peg$fail(peg$c294);
2931
+ peg$fail(peg$c296);
2927
2932
  }
2928
2933
  }
2929
- if (s1 !== peg$FAILED) {
2930
- s2 = peg$parseBlockCommentTail();
2931
- if (s2 !== peg$FAILED) {
2932
- s1 = [s1, s2];
2933
- s0 = s1;
2934
+ peg$silentFails--;
2935
+ if (s5 === peg$FAILED) {
2936
+ s4 = void 0;
2937
+ }
2938
+ else {
2939
+ peg$currPos = s4;
2940
+ s4 = peg$FAILED;
2941
+ }
2942
+ if (s4 !== peg$FAILED) {
2943
+ if (input.length > peg$currPos) {
2944
+ s5 = input.charAt(peg$currPos);
2945
+ peg$currPos++;
2934
2946
  }
2935
2947
  else {
2936
- peg$currPos = s0;
2937
- s0 = peg$FAILED;
2948
+ s5 = peg$FAILED;
2949
+ if (peg$silentFails === 0) {
2950
+ peg$fail(peg$c297);
2951
+ }
2952
+ }
2953
+ if (s5 !== peg$FAILED) {
2954
+ s4 = [s4, s5];
2955
+ s3 = s4;
2956
+ }
2957
+ else {
2958
+ peg$currPos = s3;
2959
+ s3 = peg$FAILED;
2938
2960
  }
2939
2961
  }
2940
2962
  else {
2941
- peg$currPos = s0;
2942
- s0 = peg$FAILED;
2963
+ peg$currPos = s3;
2964
+ s3 = peg$FAILED;
2943
2965
  }
2944
- }
2945
- return s0;
2946
- }
2947
- function peg$parseBlockComment() {
2948
- var s0, s1, s2;
2949
- peg$silentFails++;
2950
- s0 = peg$currPos;
2951
- if (input.substr(peg$currPos, 2) === peg$c296) {
2952
- s1 = peg$c296;
2953
- peg$currPos += 2;
2954
- }
2955
- else {
2956
- s1 = peg$FAILED;
2957
- if (peg$silentFails === 0) {
2958
- peg$fail(peg$c297);
2966
+ while (s3 !== peg$FAILED) {
2967
+ s2.push(s3);
2968
+ s3 = peg$currPos;
2969
+ s4 = peg$currPos;
2970
+ peg$silentFails++;
2971
+ if (input.substr(peg$currPos, 2) === peg$c295) {
2972
+ s5 = peg$c295;
2973
+ peg$currPos += 2;
2974
+ }
2975
+ else {
2976
+ s5 = peg$FAILED;
2977
+ if (peg$silentFails === 0) {
2978
+ peg$fail(peg$c296);
2979
+ }
2980
+ }
2981
+ peg$silentFails--;
2982
+ if (s5 === peg$FAILED) {
2983
+ s4 = void 0;
2984
+ }
2985
+ else {
2986
+ peg$currPos = s4;
2987
+ s4 = peg$FAILED;
2988
+ }
2989
+ if (s4 !== peg$FAILED) {
2990
+ if (input.length > peg$currPos) {
2991
+ s5 = input.charAt(peg$currPos);
2992
+ peg$currPos++;
2993
+ }
2994
+ else {
2995
+ s5 = peg$FAILED;
2996
+ if (peg$silentFails === 0) {
2997
+ peg$fail(peg$c297);
2998
+ }
2999
+ }
3000
+ if (s5 !== peg$FAILED) {
3001
+ s4 = [s4, s5];
3002
+ s3 = s4;
3003
+ }
3004
+ else {
3005
+ peg$currPos = s3;
3006
+ s3 = peg$FAILED;
3007
+ }
3008
+ }
3009
+ else {
3010
+ peg$currPos = s3;
3011
+ s3 = peg$FAILED;
3012
+ }
2959
3013
  }
2960
- }
2961
- if (s1 !== peg$FAILED) {
2962
- s2 = peg$parseBlockCommentTail();
2963
3014
  if (s2 !== peg$FAILED) {
2964
- s1 = [s1, s2];
2965
- s0 = s1;
3015
+ if (input.substr(peg$currPos, 2) === peg$c295) {
3016
+ s3 = peg$c295;
3017
+ peg$currPos += 2;
3018
+ }
3019
+ else {
3020
+ s3 = peg$FAILED;
3021
+ if (peg$silentFails === 0) {
3022
+ peg$fail(peg$c296);
3023
+ }
3024
+ }
3025
+ if (s3 !== peg$FAILED) {
3026
+ s1 = [s1, s2, s3];
3027
+ s0 = s1;
3028
+ }
3029
+ else {
3030
+ peg$currPos = s0;
3031
+ s0 = peg$FAILED;
3032
+ }
2966
3033
  }
2967
3034
  else {
2968
3035
  peg$currPos = s0;
@@ -2977,7 +3044,7 @@ function peg$parse(input, options) {
2977
3044
  if (s0 === peg$FAILED) {
2978
3045
  s1 = peg$FAILED;
2979
3046
  if (peg$silentFails === 0) {
2980
- peg$fail(peg$c295);
3047
+ peg$fail(peg$c292);
2981
3048
  }
2982
3049
  }
2983
3050
  return s0;
@@ -2993,7 +3060,7 @@ function peg$parse(input, options) {
2993
3060
  else {
2994
3061
  s1 = peg$FAILED;
2995
3062
  if (peg$silentFails === 0) {
2996
- peg$fail(peg$c294);
3063
+ peg$fail(peg$c297);
2997
3064
  }
2998
3065
  }
2999
3066
  peg$silentFails--;
@@ -3006,44 +3073,8 @@ function peg$parse(input, options) {
3006
3073
  }
3007
3074
  return s0;
3008
3075
  }
3009
- function peg$parseLineCommentTail() {
3010
- var s0, s1, s2;
3011
- s0 = peg$parseLineTerminator();
3012
- if (s0 === peg$FAILED) {
3013
- s0 = peg$parseEOF();
3014
- if (s0 === peg$FAILED) {
3015
- s0 = peg$currPos;
3016
- if (input.length > peg$currPos) {
3017
- s1 = input.charAt(peg$currPos);
3018
- peg$currPos++;
3019
- }
3020
- else {
3021
- s1 = peg$FAILED;
3022
- if (peg$silentFails === 0) {
3023
- peg$fail(peg$c294);
3024
- }
3025
- }
3026
- if (s1 !== peg$FAILED) {
3027
- s2 = peg$parseLineCommentTail();
3028
- if (s2 !== peg$FAILED) {
3029
- s1 = [s1, s2];
3030
- s0 = s1;
3031
- }
3032
- else {
3033
- peg$currPos = s0;
3034
- s0 = peg$FAILED;
3035
- }
3036
- }
3037
- else {
3038
- peg$currPos = s0;
3039
- s0 = peg$FAILED;
3040
- }
3041
- }
3042
- }
3043
- return s0;
3044
- }
3045
3076
  function peg$parseLineComment() {
3046
- var s0, s1, s2;
3077
+ var s0, s1, s2, s3, s4, s5;
3047
3078
  peg$silentFails++;
3048
3079
  s0 = peg$currPos;
3049
3080
  if (input.substr(peg$currPos, 2) === peg$c299) {
@@ -3057,10 +3088,95 @@ function peg$parse(input, options) {
3057
3088
  }
3058
3089
  }
3059
3090
  if (s1 !== peg$FAILED) {
3060
- s2 = peg$parseLineCommentTail();
3091
+ s2 = [];
3092
+ s3 = peg$currPos;
3093
+ s4 = peg$currPos;
3094
+ peg$silentFails++;
3095
+ s5 = peg$parseLineTerminator();
3096
+ peg$silentFails--;
3097
+ if (s5 === peg$FAILED) {
3098
+ s4 = void 0;
3099
+ }
3100
+ else {
3101
+ peg$currPos = s4;
3102
+ s4 = peg$FAILED;
3103
+ }
3104
+ if (s4 !== peg$FAILED) {
3105
+ if (input.length > peg$currPos) {
3106
+ s5 = input.charAt(peg$currPos);
3107
+ peg$currPos++;
3108
+ }
3109
+ else {
3110
+ s5 = peg$FAILED;
3111
+ if (peg$silentFails === 0) {
3112
+ peg$fail(peg$c297);
3113
+ }
3114
+ }
3115
+ if (s5 !== peg$FAILED) {
3116
+ s4 = [s4, s5];
3117
+ s3 = s4;
3118
+ }
3119
+ else {
3120
+ peg$currPos = s3;
3121
+ s3 = peg$FAILED;
3122
+ }
3123
+ }
3124
+ else {
3125
+ peg$currPos = s3;
3126
+ s3 = peg$FAILED;
3127
+ }
3128
+ while (s3 !== peg$FAILED) {
3129
+ s2.push(s3);
3130
+ s3 = peg$currPos;
3131
+ s4 = peg$currPos;
3132
+ peg$silentFails++;
3133
+ s5 = peg$parseLineTerminator();
3134
+ peg$silentFails--;
3135
+ if (s5 === peg$FAILED) {
3136
+ s4 = void 0;
3137
+ }
3138
+ else {
3139
+ peg$currPos = s4;
3140
+ s4 = peg$FAILED;
3141
+ }
3142
+ if (s4 !== peg$FAILED) {
3143
+ if (input.length > peg$currPos) {
3144
+ s5 = input.charAt(peg$currPos);
3145
+ peg$currPos++;
3146
+ }
3147
+ else {
3148
+ s5 = peg$FAILED;
3149
+ if (peg$silentFails === 0) {
3150
+ peg$fail(peg$c297);
3151
+ }
3152
+ }
3153
+ if (s5 !== peg$FAILED) {
3154
+ s4 = [s4, s5];
3155
+ s3 = s4;
3156
+ }
3157
+ else {
3158
+ peg$currPos = s3;
3159
+ s3 = peg$FAILED;
3160
+ }
3161
+ }
3162
+ else {
3163
+ peg$currPos = s3;
3164
+ s3 = peg$FAILED;
3165
+ }
3166
+ }
3061
3167
  if (s2 !== peg$FAILED) {
3062
- s1 = [s1, s2];
3063
- s0 = s1;
3168
+ s3 = peg$parseLineTerminator();
3169
+ if (s3 === peg$FAILED) {
3170
+ s3 = peg$parseEOF();
3171
+ }
3172
+ if (s3 !== peg$FAILED) {
3173
+ s1 = [s1, s2, s3];
3174
+ s0 = s1;
3175
+ }
3176
+ else {
3177
+ peg$currPos = s0;
3178
+ s0 = peg$FAILED;
3179
+ }
3064
3180
  }
3065
3181
  else {
3066
3182
  peg$currPos = s0;
@@ -3083,49 +3199,45 @@ function peg$parse(input, options) {
3083
3199
  function peg$parseWS() {
3084
3200
  var s0, s1, s2;
3085
3201
  peg$silentFails++;
3086
- s0 = peg$currPos;
3087
- s1 = peg$parseBlockComment();
3088
- if (s1 !== peg$FAILED) {
3089
- s2 = peg$parseWS();
3090
- if (s2 === peg$FAILED) {
3091
- s2 = null;
3092
- }
3093
- if (s2 !== peg$FAILED) {
3094
- s1 = [s1, s2];
3095
- s0 = s1;
3096
- }
3097
- else {
3098
- peg$currPos = s0;
3099
- s0 = peg$FAILED;
3100
- }
3202
+ s0 = [];
3203
+ s1 = [];
3204
+ if (peg$c302.test(input.charAt(peg$currPos))) {
3205
+ s2 = input.charAt(peg$currPos);
3206
+ peg$currPos++;
3101
3207
  }
3102
3208
  else {
3103
- peg$currPos = s0;
3104
- s0 = peg$FAILED;
3209
+ s2 = peg$FAILED;
3210
+ if (peg$silentFails === 0) {
3211
+ peg$fail(peg$c303);
3212
+ }
3105
3213
  }
3106
- if (s0 === peg$FAILED) {
3107
- s0 = peg$currPos;
3108
- s1 = peg$parseLineComment();
3109
- if (s1 !== peg$FAILED) {
3110
- s2 = peg$parseWS();
3111
- if (s2 === peg$FAILED) {
3112
- s2 = null;
3113
- }
3114
- if (s2 !== peg$FAILED) {
3115
- s1 = [s1, s2];
3116
- s0 = s1;
3214
+ if (s2 !== peg$FAILED) {
3215
+ while (s2 !== peg$FAILED) {
3216
+ s1.push(s2);
3217
+ if (peg$c302.test(input.charAt(peg$currPos))) {
3218
+ s2 = input.charAt(peg$currPos);
3219
+ peg$currPos++;
3117
3220
  }
3118
3221
  else {
3119
- peg$currPos = s0;
3120
- s0 = peg$FAILED;
3222
+ s2 = peg$FAILED;
3223
+ if (peg$silentFails === 0) {
3224
+ peg$fail(peg$c303);
3225
+ }
3121
3226
  }
3122
3227
  }
3123
- else {
3124
- peg$currPos = s0;
3125
- s0 = peg$FAILED;
3228
+ }
3229
+ else {
3230
+ s1 = peg$FAILED;
3231
+ }
3232
+ if (s1 === peg$FAILED) {
3233
+ s1 = peg$parseBlockComment();
3234
+ if (s1 === peg$FAILED) {
3235
+ s1 = peg$parseLineComment();
3126
3236
  }
3127
- if (s0 === peg$FAILED) {
3128
- s0 = peg$currPos;
3237
+ }
3238
+ if (s1 !== peg$FAILED) {
3239
+ while (s1 !== peg$FAILED) {
3240
+ s0.push(s1);
3129
3241
  s1 = [];
3130
3242
  if (peg$c302.test(input.charAt(peg$currPos))) {
3131
3243
  s2 = input.charAt(peg$currPos);
@@ -3155,26 +3267,17 @@ function peg$parse(input, options) {
3155
3267
  else {
3156
3268
  s1 = peg$FAILED;
3157
3269
  }
3158
- if (s1 !== peg$FAILED) {
3159
- s2 = peg$parseWS();
3160
- if (s2 === peg$FAILED) {
3161
- s2 = null;
3162
- }
3163
- if (s2 !== peg$FAILED) {
3164
- s1 = [s1, s2];
3165
- s0 = s1;
3166
- }
3167
- else {
3168
- peg$currPos = s0;
3169
- s0 = peg$FAILED;
3270
+ if (s1 === peg$FAILED) {
3271
+ s1 = peg$parseBlockComment();
3272
+ if (s1 === peg$FAILED) {
3273
+ s1 = peg$parseLineComment();
3170
3274
  }
3171
3275
  }
3172
- else {
3173
- peg$currPos = s0;
3174
- s0 = peg$FAILED;
3175
- }
3176
3276
  }
3177
3277
  }
3278
+ else {
3279
+ s0 = peg$FAILED;
3280
+ }
3178
3281
  peg$silentFails--;
3179
3282
  if (s0 === peg$FAILED) {
3180
3283
  s1 = peg$FAILED;
@@ -21246,7 +21349,7 @@ theme_mapping.set('bold', bold_theme);
21246
21349
  * import { state_name_chars } from 'jssm';
21247
21350
  * state_name_chars.some(r => 'A' >= r.from && 'A' <= r.to); // => true
21248
21351
  */
21249
- // keep in sync with src/ts/fsl_parser.peg:278
21352
+ // keep in sync with src/ts/fsl_parser.peg:267
21250
21353
  const state_name_chars$1 = Object.freeze([
21251
21354
  { from: '0', to: '9' },
21252
21355
  { from: 'a', to: 'z' },
@@ -21279,7 +21382,7 @@ const state_name_chars$1 = Object.freeze([
21279
21382
  * import { state_name_first_chars } from 'jssm';
21280
21383
  * state_name_first_chars.some(r => '+' >= r.from && '+' <= r.to); // => false
21281
21384
  */
21282
- // keep in sync with src/ts/fsl_parser.peg:275
21385
+ // keep in sync with src/ts/fsl_parser.peg:264
21283
21386
  const state_name_first_chars$1 = Object.freeze([
21284
21387
  { from: '0', to: '9' },
21285
21388
  { from: 'a', to: 'z' },
@@ -21327,7 +21430,7 @@ var constants = /*#__PURE__*/Object.freeze({
21327
21430
  * Useful for runtime diagnostics and for embedding in serialized machine
21328
21431
  * snapshots so that deserializers can detect version-skew.
21329
21432
  */
21330
- const version = "5.141.5";
21433
+ const version = "5.141.8";
21331
21434
 
21332
21435
  // whargarbl lots of these return arrays could/should be sets
21333
21436
  const { state_name_chars, state_name_first_chars, action_label_chars } = constants;
@@ -23848,6 +23951,44 @@ class Machine {
23848
23951
  throw new JssmError(this, "Code specifies no override, but config tries to permit; config may not be less strict than code");
23849
23952
  }
23850
23953
  }
23954
+ /*********
23955
+ *
23956
+ * Fire a `'rejection'` event caused by a hook vetoing a pending transition.
23957
+ * Extracted from the per-call closures inside {@link transition_impl} so
23958
+ * that it is allocated once at class-definition time rather than on every
23959
+ * hooked transition.
23960
+ *
23961
+ * @param hook_name Name of the hook that rejected (e.g. `'exit'`).
23962
+ * @param fromState State the machine was in when the transition was
23963
+ * attempted; used as the `from` field of the rejection event.
23964
+ * @param newState State that would have been entered had the hook
23965
+ * passed; used as the `to` field of the rejection event.
23966
+ * @param fromAction Action name when the transition was initiated by an
23967
+ * action call; `undefined` for plain state transitions.
23968
+ * @param oldData Machine data at the moment the transition was
23969
+ * attempted, before any hook mutations.
23970
+ * @param newData The `next_data` value passed to the transition call.
23971
+ * @param wasForced Whether the transition was attempted via
23972
+ * `force_transition`.
23973
+ *
23974
+ * @see transition_impl
23975
+ * @see _fire
23976
+ *
23977
+ * @internal
23978
+ *
23979
+ */
23980
+ _fire_hook_rejection(hook_name, fromState, newState, fromAction, oldData, newData, wasForced) {
23981
+ this._fire('rejection', {
23982
+ from: fromState,
23983
+ to: newState,
23984
+ action: fromAction,
23985
+ data: oldData,
23986
+ next_data: newData,
23987
+ reason: 'hook',
23988
+ hook_name,
23989
+ forced: wasForced
23990
+ });
23991
+ }
23851
23992
  /*********
23852
23993
  *
23853
23994
  * Shared transition core used by {@link transition}, {@link force_transition},
@@ -23939,14 +24080,19 @@ class Machine {
23939
24080
  const hook_args = hook_args_obj;
23940
24081
  // 'action' event fires when an action is attempted, regardless of whether
23941
24082
  // it ultimately succeeds — matches the issue spec for observation events.
24083
+ // Gated on live listener count so we skip the detail-object allocation
24084
+ // when nothing is subscribed. Gate is read at fire time, so a listener
24085
+ // registered inside a pre-hook still receives the event. #671
23942
24086
  if (wasAction) {
23943
- this._fire('action', {
23944
- action: newStateOrAction,
23945
- from: this._state,
23946
- to: newState,
23947
- data: this._data,
23948
- next_data: newData
23949
- });
24087
+ if (this._event_listener_count !== 0) {
24088
+ this._fire('action', {
24089
+ action: newStateOrAction,
24090
+ from: this._state,
24091
+ to: newState,
24092
+ data: this._data,
24093
+ next_data: newData
24094
+ });
24095
+ }
23950
24096
  }
23951
24097
  // Captured pre-transition source state so 'data-change' detail and similar
23952
24098
  // events can name where we came from.
@@ -23956,75 +24102,68 @@ class Machine {
23956
24102
  if (this._has_hooks) {
23957
24103
  // once validity is known, clear old 'after' timeout clause
23958
24104
  this.clear_state_timeout();
23959
- function update_fields(res) {
23960
- if (res.hasOwnProperty('data')) {
23961
- hook_args.data = res.data;
23962
- hook_args.next_data = res.next_data;
23963
- data_changed = true;
23964
- }
23965
- }
23966
24105
  let data_changed = false;
23967
- const fire_rejection = (hook_name) => {
23968
- this._fire('rejection', {
23969
- from: fromState,
23970
- to: newState,
23971
- action: fromAction,
23972
- data: oldData,
23973
- next_data: newData,
23974
- reason: 'hook',
23975
- hook_name,
23976
- forced: wasForced
23977
- });
23978
- };
23979
24106
  // 0. pre everything hook (fires before all other pre-hooks)
23980
24107
  if (this._pre_everything_hook !== undefined) {
23981
24108
  const outcome = abstract_everything_hook_step(this._pre_everything_hook, Object.assign(Object.assign({}, hook_args), { hook_name: 'pre everything' }));
23982
24109
  if (outcome.pass === false) {
23983
- fire_rejection('pre everything');
24110
+ this._fire_hook_rejection('pre everything', fromState, newState, fromAction, oldData, newData, wasForced);
23984
24111
  return false;
23985
24112
  }
23986
- update_fields(outcome);
24113
+ if (_update_hook_fields(hook_args, outcome)) {
24114
+ data_changed = true;
24115
+ }
23987
24116
  }
23988
24117
  if (wasAction) {
23989
24118
  // 1a. any action hook
23990
24119
  const outcome = abstract_hook_step(this._any_action_hook, hook_args);
23991
24120
  if (outcome.pass === false) {
23992
- fire_rejection('any action');
24121
+ this._fire_hook_rejection('any action', fromState, newState, fromAction, oldData, newData, wasForced);
23993
24122
  return false;
23994
24123
  }
23995
- update_fields(outcome);
24124
+ if (_update_hook_fields(hook_args, outcome)) {
24125
+ data_changed = true;
24126
+ }
23996
24127
  // 1b. global specific action hook
23997
24128
  const outcome2 = abstract_hook_step(this._global_action_hooks.get(newStateOrAction), hook_args);
23998
24129
  if (outcome2.pass === false) {
23999
- fire_rejection('global action');
24130
+ this._fire_hook_rejection('global action', fromState, newState, fromAction, oldData, newData, wasForced);
24000
24131
  return false;
24001
24132
  }
24002
- update_fields(outcome2);
24133
+ if (_update_hook_fields(hook_args, outcome2)) {
24134
+ data_changed = true;
24135
+ }
24003
24136
  }
24004
24137
  // 2. after hook
24005
24138
  if (this._has_after_hooks) {
24006
24139
  const ah = this._after_hooks.get(newStateOrAction);
24007
24140
  const outcome = abstract_hook_step(ah, hook_args);
24008
- // there's no such thing as after not passing, so, omit the result pass check
24009
- update_fields(outcome);
24141
+ // there's no such thing as after not passing, so, omit the result pass check.
24142
+ // after hooks are post-exit and informational — their outcome never changes
24143
+ // data, so there's no data_changed branch here (it would be unreachable).
24144
+ _update_hook_fields(hook_args, outcome);
24010
24145
  }
24011
24146
  // 3. any transition hook
24012
24147
  if (this._any_transition_hook !== undefined) {
24013
24148
  const outcome = abstract_hook_step(this._any_transition_hook, hook_args);
24014
24149
  if (outcome.pass === false) {
24015
- fire_rejection('any transition');
24150
+ this._fire_hook_rejection('any transition', fromState, newState, fromAction, oldData, newData, wasForced);
24016
24151
  return false;
24017
24152
  }
24018
- update_fields(outcome);
24153
+ if (_update_hook_fields(hook_args, outcome)) {
24154
+ data_changed = true;
24155
+ }
24019
24156
  }
24020
24157
  // 4. exit hook
24021
24158
  if (this._has_exit_hooks) {
24022
24159
  const outcome = abstract_hook_step(this._exit_hooks.get(this._state), hook_args);
24023
24160
  if (outcome.pass === false) {
24024
- fire_rejection('exit');
24161
+ this._fire_hook_rejection('exit', fromState, newState, fromAction, oldData, newData, wasForced);
24025
24162
  return false;
24026
24163
  }
24027
- update_fields(outcome);
24164
+ if (_update_hook_fields(hook_args, outcome)) {
24165
+ data_changed = true;
24166
+ }
24028
24167
  }
24029
24168
  // 5. named transition / action hook
24030
24169
  if (this._has_named_hooks) {
@@ -24036,10 +24175,12 @@ class Machine {
24036
24175
  const nh = byAct === undefined ? undefined : byAct.get(newStateOrAction);
24037
24176
  const outcome = abstract_hook_step(nh, hook_args);
24038
24177
  if (outcome.pass === false) {
24039
- fire_rejection('named');
24178
+ this._fire_hook_rejection('named', fromState, newState, fromAction, oldData, newData, wasForced);
24040
24179
  return false;
24041
24180
  }
24042
- update_fields(outcome);
24181
+ if (_update_hook_fields(hook_args, outcome)) {
24182
+ data_changed = true;
24183
+ }
24043
24184
  }
24044
24185
  }
24045
24186
  // 6. regular hook
@@ -24049,56 +24190,68 @@ class Machine {
24049
24190
  const h = byTo === undefined ? undefined : byTo.get(newState);
24050
24191
  const outcome = abstract_hook_step(h, hook_args);
24051
24192
  if (outcome.pass === false) {
24052
- fire_rejection('hook');
24193
+ this._fire_hook_rejection('hook', fromState, newState, fromAction, oldData, newData, wasForced);
24053
24194
  return false;
24054
24195
  }
24055
- update_fields(outcome);
24196
+ if (_update_hook_fields(hook_args, outcome)) {
24197
+ data_changed = true;
24198
+ }
24056
24199
  }
24057
24200
  // 7. edge type hook
24058
24201
  // 7a. standard transition hook
24059
24202
  if (trans_type === 'legal') {
24060
24203
  const outcome = abstract_hook_step(this._standard_transition_hook, hook_args);
24061
24204
  if (outcome.pass === false) {
24062
- fire_rejection('standard transition');
24205
+ this._fire_hook_rejection('standard transition', fromState, newState, fromAction, oldData, newData, wasForced);
24063
24206
  return false;
24064
24207
  }
24065
- update_fields(outcome);
24208
+ if (_update_hook_fields(hook_args, outcome)) {
24209
+ data_changed = true;
24210
+ }
24066
24211
  }
24067
24212
  // 7b. main type hook
24068
24213
  if (trans_type === 'main') {
24069
24214
  const outcome = abstract_hook_step(this._main_transition_hook, hook_args);
24070
24215
  if (outcome.pass === false) {
24071
- fire_rejection('main transition');
24216
+ this._fire_hook_rejection('main transition', fromState, newState, fromAction, oldData, newData, wasForced);
24072
24217
  return false;
24073
24218
  }
24074
- update_fields(outcome);
24219
+ if (_update_hook_fields(hook_args, outcome)) {
24220
+ data_changed = true;
24221
+ }
24075
24222
  }
24076
24223
  // 7c. forced transition hook
24077
24224
  if (trans_type === 'forced') {
24078
24225
  const outcome = abstract_hook_step(this._forced_transition_hook, hook_args);
24079
24226
  if (outcome.pass === false) {
24080
- fire_rejection('forced transition');
24227
+ this._fire_hook_rejection('forced transition', fromState, newState, fromAction, oldData, newData, wasForced);
24081
24228
  return false;
24082
24229
  }
24083
- update_fields(outcome);
24230
+ if (_update_hook_fields(hook_args, outcome)) {
24231
+ data_changed = true;
24232
+ }
24084
24233
  }
24085
24234
  // 8. entry hook
24086
24235
  if (this._has_entry_hooks) {
24087
24236
  const outcome = abstract_hook_step(this._entry_hooks.get(newState), hook_args);
24088
24237
  if (outcome.pass === false) {
24089
- fire_rejection('entry');
24238
+ this._fire_hook_rejection('entry', fromState, newState, fromAction, oldData, newData, wasForced);
24090
24239
  return false;
24091
24240
  }
24092
- update_fields(outcome);
24241
+ if (_update_hook_fields(hook_args, outcome)) {
24242
+ data_changed = true;
24243
+ }
24093
24244
  }
24094
24245
  // 9. everything hook (fires after all other pre-hooks)
24095
24246
  if (this._everything_hook !== undefined) {
24096
24247
  const outcome = abstract_everything_hook_step(this._everything_hook, Object.assign(Object.assign({}, hook_args), { hook_name: 'everything' }));
24097
24248
  if (outcome.pass === false) {
24098
- fire_rejection('everything');
24249
+ this._fire_hook_rejection('everything', fromState, newState, fromAction, oldData, newData, wasForced);
24099
24250
  return false;
24100
24251
  }
24101
- update_fields(outcome);
24252
+ if (_update_hook_fields(hook_args, outcome)) {
24253
+ data_changed = true;
24254
+ }
24102
24255
  }
24103
24256
  // all hooks passed! let's now establish the result
24104
24257
  if (this._history_length) {
@@ -24131,15 +24284,20 @@ class Machine {
24131
24284
  // not valid
24132
24285
  }
24133
24286
  else {
24134
- this._fire('rejection', {
24135
- from: fromState,
24136
- to: newStateOrAction,
24137
- action: fromAction,
24138
- data: oldData,
24139
- next_data: newData,
24140
- reason: 'invalid',
24141
- forced: wasForced
24142
- });
24287
+ // Gated on live listener count so we skip the detail-object allocation
24288
+ // when nothing is subscribed. A listener still receives the event
24289
+ // because the gate is read at fire time. #671
24290
+ if (this._event_listener_count !== 0) {
24291
+ this._fire('rejection', {
24292
+ from: fromState,
24293
+ to: newStateOrAction,
24294
+ action: fromAction,
24295
+ data: oldData,
24296
+ next_data: newData,
24297
+ reason: 'invalid',
24298
+ forced: wasForced
24299
+ });
24300
+ }
24143
24301
  return false;
24144
24302
  }
24145
24303
  // posthooks begin here
@@ -25024,6 +25182,46 @@ function is_hook_complex_result(hr) {
25024
25182
  }
25025
25183
  return false;
25026
25184
  }
25185
+ /**
25186
+ *
25187
+ * Apply any data-field updates from a hook's complex result into `hook_args`,
25188
+ * and return whether data actually changed.
25189
+ *
25190
+ * This is the hoisted, allocation-free replacement for the `update_fields`
25191
+ * inner function that used to be re-created on every hooked transition inside
25192
+ * {@link Machine.transition_impl}. By moving it to module scope the function
25193
+ * object is allocated once at module load time.
25194
+ *
25195
+ * When the result does not carry a `data` property (the common case —
25196
+ * most hooks return `true` or `undefined`) the function returns `false`
25197
+ * immediately without touching `hook_args`.
25198
+ *
25199
+ * ```typescript
25200
+ * const args = { data: 'old', next_data: undefined, ... };
25201
+ * const changed = _update_hook_fields(args, { pass: true, data: 'new', next_data: undefined });
25202
+ * // changed === true, args.data === 'new'
25203
+ * ```
25204
+ *
25205
+ * @param hook_args The shared hook-argument object for the current
25206
+ * transition. Mutated in-place when the result carries `data`.
25207
+ * @param res The normalised complex result returned by
25208
+ * {@link abstract_hook_step} or {@link abstract_everything_hook_step}.
25209
+ *
25210
+ * @returns `true` if `res` contained a `data` property (i.e. the hook
25211
+ * mutated the machine's data); `false` otherwise.
25212
+ *
25213
+ * @see Machine.transition_impl
25214
+ * @see abstract_hook_step
25215
+ *
25216
+ */
25217
+ function _update_hook_fields(hook_args, res) {
25218
+ if (Object.prototype.hasOwnProperty.call(res, 'data')) {
25219
+ hook_args.data = res.data;
25220
+ hook_args.next_data = res.next_data;
25221
+ return true;
25222
+ }
25223
+ return false;
25224
+ }
25027
25225
  /**
25028
25226
  *
25029
25227
  * Invoke an optional transition/action hook and normalize its return value