From be181191d99888436c735b1f1e9783f93f0fea98 Mon Sep 17 00:00:00 2001 From: Rever Date: Mon, 19 May 2025 20:05:19 -0400 Subject: [PATCH 01/46] First commit First --- git-hash.sh | 0 nodesource_setup.sh | 113 ++++++++++++++++++++++++++ sample/exec.js | 0 src-ui/img/evolmino.png | Bin src-ui/img/kuroclone.png | Bin src-ui/js/ui/AuxEditor.js | 16 ++++ src-ui/js/ui/Misc.js | 0 src-ui/js/ui/ToolArea.js | 6 ++ src-ui/p.html | 2 +- src/puzzle/Board.js | 146 ++++++++++++++++++++++++++++++++++ src/puzzle/Config.js | 34 ++++++++ src/puzzle/Graphic.js | 3 + src/puzzle/Piece.js | 14 ++++ src/pzpr/variety.js | 1 + src/variety-common/Graphic.js | 61 +++++++++++--- src/variety/araf.js | 0 test/script/araf.js | 0 test/script/canal.js | 0 test/script/cbanana.js | 0 test/script/maxi.js | 0 20 files changed, 386 insertions(+), 10 deletions(-) mode change 100755 => 100644 git-hash.sh create mode 100644 nodesource_setup.sh mode change 100755 => 100644 sample/exec.js mode change 100755 => 100644 src-ui/img/evolmino.png mode change 100755 => 100644 src-ui/img/kuroclone.png mode change 100755 => 100644 src-ui/js/ui/Misc.js mode change 100755 => 100644 src/pzpr/variety.js mode change 100755 => 100644 src/variety/araf.js mode change 100755 => 100644 test/script/araf.js mode change 100755 => 100644 test/script/canal.js mode change 100755 => 100644 test/script/cbanana.js mode change 100755 => 100644 test/script/maxi.js diff --git a/git-hash.sh b/git-hash.sh old mode 100755 new mode 100644 diff --git a/nodesource_setup.sh b/nodesource_setup.sh new file mode 100644 index 000000000..4b112d096 --- /dev/null +++ b/nodesource_setup.sh @@ -0,0 +1,113 @@ +#!/bin/bash + +# Logger Function +log() { + local message="$1" + local type="$2" + local timestamp=$(date '+%Y-%m-%d %H:%M:%S') + local color + local endcolor="\033[0m" + + case "$type" in + "info") color="\033[38;5;79m" ;; + "success") color="\033[1;32m" ;; + "error") color="\033[1;31m" ;; + *) color="\033[1;34m" ;; + esac + + echo -e "${color}${timestamp} - ${message}${endcolor}" +} + +# Error handler function +handle_error() { + local exit_code=$1 + local error_message="$2" + log "Error: $error_message (Exit Code: $exit_code)" "error" + exit $exit_code +} + +# Function to check for command availability +command_exists() { + command -v "$1" &> /dev/null +} + +check_os() { + if ! [ -f "/etc/debian_version" ]; then + echo "Error: This script is only supported on Debian-based systems." + exit 1 + fi +} + +# Function to Install the script pre-requisites +install_pre_reqs() { + log "Installing pre-requisites" "info" + + # Run 'apt-get update' + if ! apt-get update -y; then + handle_error "$?" "Failed to run 'apt-get update'" + fi + + # Run 'apt-get install' + if ! apt-get install -y apt-transport-https ca-certificates curl gnupg; then + handle_error "$?" "Failed to install packages" + fi + + if ! mkdir -p /usr/share/keyrings; then + handle_error "$?" "Makes sure the path /usr/share/keyrings exist or run ' mkdir -p /usr/share/keyrings' with sudo" + fi + + rm -f /usr/share/keyrings/nodesource.gpg || true + rm -f /etc/apt/sources.list.d/nodesource.list || true + + # Run 'curl' and 'gpg' to download and import the NodeSource signing key + if ! curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg; then + handle_error "$?" "Failed to download and import the NodeSource signing key" + fi + + # Explicitly set the permissions to ensure the file is readable by all + if ! chmod 644 /usr/share/keyrings/nodesource.gpg; then + handle_error "$?" "Failed to set correct permissions on /usr/share/keyrings/nodesource.gpg" + fi +} + +# Function to configure the Repo +configure_repo() { + local node_version=$1 + + arch=$(dpkg --print-architecture) + if [ "$arch" != "amd64" ] && [ "$arch" != "arm64" ] && [ "$arch" != "armhf" ]; then + handle_error "1" "Unsupported architecture: $arch. Only amd64, arm64, and armhf are supported." + fi + + echo "deb [arch=$arch signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$node_version nodistro main" | tee /etc/apt/sources.list.d/nodesource.list > /dev/null + + # N|solid Config + echo "Package: nsolid" | tee /etc/apt/preferences.d/nsolid > /dev/null + echo "Pin: origin deb.nodesource.com" | tee -a /etc/apt/preferences.d/nsolid > /dev/null + echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/nsolid > /dev/null + + # Nodejs Config + echo "Package: nodejs" | tee /etc/apt/preferences.d/nodejs > /dev/null + echo "Pin: origin deb.nodesource.com" | tee -a /etc/apt/preferences.d/nodejs > /dev/null + echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/nodejs > /dev/null + + # Run 'apt-get update' + if ! apt-get update -y; then + handle_error "$?" "Failed to run 'apt-get update'" + else + log "Repository configured successfully." + log "To install Node.js, run: apt-get install nodejs -y" "info" + log "You can use N|solid Runtime as a node.js alternative" "info" + log "To install N|solid Runtime, run: apt-get install nsolid -y \n" "success" + fi +} + +# Define Node.js version +NODE_VERSION="23.x" + +# Check OS +check_os + +# Main execution +install_pre_reqs || handle_error $? "Failed installing pre-requisites" +configure_repo "$NODE_VERSION" || handle_error $? "Failed configuring repository" diff --git a/sample/exec.js b/sample/exec.js old mode 100755 new mode 100644 diff --git a/src-ui/img/evolmino.png b/src-ui/img/evolmino.png old mode 100755 new mode 100644 diff --git a/src-ui/img/kuroclone.png b/src-ui/img/kuroclone.png old mode 100755 new mode 100644 diff --git a/src-ui/js/ui/AuxEditor.js b/src-ui/js/ui/AuxEditor.js index b23703467..89900232e 100644 --- a/src-ui/js/ui/AuxEditor.js +++ b/src-ui/js/ui/AuxEditor.js @@ -64,6 +64,22 @@ ui.popupmgr.addpopup("auxeditor", { adjust_aux: function(e) { ui.auxeditor.puzzle.board.operate(e.target.name); + }, + + solver_answer_first: function() { + ui.auxeditor.puzzle.board.locateAnswer(-2) + }, + solver_answer_prev: function() { + ui.auxeditor.puzzle.board.locateAnswer(-1) + }, + solver_answer_next: function() { + ui.auxeditor.puzzle.board.locateAnswer(1) + }, + solver_answer_last: function() { + ui.auxeditor.puzzle.board.locateAnswer(2) + }, + solver_stop: function() { + ui.auxeditor.puzzle.board.solverRunning && window.solveNumberlinkAsyncTerminate() } }); diff --git a/src-ui/js/ui/Misc.js b/src-ui/js/ui/Misc.js old mode 100755 new mode 100644 diff --git a/src-ui/js/ui/ToolArea.js b/src-ui/js/ui/ToolArea.js index cd4543fce..298cc9afa 100644 --- a/src-ui/js/ui/ToolArea.js +++ b/src-ui/js/ui/ToolArea.js @@ -342,6 +342,12 @@ ui.toolarea = { irowake: function() { ui.puzzle.irowake(); }, + run_autosolver: function() { + ui.puzzle.board.autoSolve(true) + }, + open_solver: function() { + ui.puzzle.board.openSolver() + }, encolorall: function() { ui.puzzle.board.encolorall(); } /* 天体ショーのボタン */, diff --git a/src-ui/p.html b/src-ui/p.html index 63ca8a2d1..50f9cd9fc 100644 --- a/src-ui/p.html +++ b/src-ui/p.html @@ -819,4 +819,4 @@

読み込み中です...

- + \ No newline at end of file diff --git a/src/puzzle/Board.js b/src/puzzle/Board.js index 10eccd7b9..efce0bdd5 100644 --- a/src/puzzle/Board.js +++ b/src/puzzle/Board.js @@ -97,6 +97,146 @@ pzpr.classmgr.makeCommon({ return 1; }, + autoSolve: function(b) { + this.answers = null; + var c = "nurimisaki" === this.pid || "nurikabe" === this.pid || "lits" === this.pid || "heyawake" === this.pid || "yajilin" === this.pid || "lightup" === this.pid || "shakashaka" === this.pid || "aqre" === this.pid || "tapa" === this.pid || "yajilin-regions" === this.pid || "shimaguni" === this.pid || "norinori" === this.pid || "sudoku" === this.pid, + d = "slither" === this.pid || "mashu" === this.pid || "yajilin" === this.pid || "simpleloop" === this.pid || "yajilin-regions" === this.pid || "castle" === this.pid || "numlin-aux" === this.pid; + if (!this.is_autosolve && !b) { + var e = !1; + return c && this.clearSolverAnswerForCells() && (e = !0), d && this.clearSolverAnswerForBorders() && (e = !0), void(e && this.puzzle.painter.paintAll()) + } + var url = ui.puzzle.getURL(pzpr.parser.URL_PZPRV3); + if ("simpleloop" !== this.pid || "/" !== url.substring(url.length - 1)) { + var g, h = null; + if ("numlin-aux" === this.pid) { + var e = !1; + c && this.clearSolverAnswerForCells() && (e = !0), d && this.clearSolverAnswerForBorders() && (e = !0), e && this.puzzle.painter.paintAll(), h = parseInt(document.num_max_answer.nummax.value); + for (var i = this.maxbx / 2, j = this.maxby / 2, k = [], l = 0; l < j; ++l) { + for (var m = [], n = 0; n < i; ++n){ + m.push(0);} + k.push(m); + } + for (var o = 0; o < this.cell.length; ++o) { + var p = this.cell[o]; + p.qnum >= 1 && (k[Math.floor(p.id / i)][p.id % i] = p.qnum) + } + ui.popupmgr.popups.auxeditor.pop.querySelector(".solver-answer-locator").innerText = "Now solving...", this.solverRunning = !0; + var q = this; + return void window.solveNumberlinkAsync(k, h).then(function(a) { + q.answers = a, q.answerIndex = 0, q.solverRunning = !1, q.showAnswer() + }).catch(function(a) { + q.answers = "terminated", q.answerIndex = 0, q.solverRunning = !1, q.showAnswer() + }) + } + g = window.solveProblem(url, h), c && this.updateSolverAnswerForCells(g), d && this.updateSolverAnswerForBorders(g), this.puzzle.painter.paintAll() + } + }, + + clearSolverAnswerForCells: function() { + for (var a = !1, b = 0; b < this.cell.length; ++b) { + var c = this.cell[b]; + 0 === c.qansBySolver && 0 === c.qsubBySolver || (c.qansBySolver = 0, c.qsubBySolver = 0, a = !0), null !== c.qcandBySolver && (c.qcandBySolver = null, a = !0) + } + return a + }, + + updateSolverAnswerForCells: function(a) { + if (this.clearSolverAnswerForCells(), "string" !== typeof a) { + for (var b = [], c = 0; c < this.rows; ++c) { + for (var d = [], e = 0; e < this.cols; ++e){ + d.push([]);} + b.push(d); + } + for (var f = a.data, g = 0; g < f.length; ++g) { + var h = f[g]; + "green" === h.color && (h.x % 2 === 1 && h.y % 2 === 1 && b[(h.y - 1) / 2][(h.x - 1) / 2].push(h.item)) + } + for (var g = 0; g < this.cell.length; ++g){ + for (var i = this.cell[g], j = b[(i.by - 1) / 2][(i.bx - 1) / 2], k = 0; k < j.length; ++k){ + if ("block" === j[k] || "fill" === j[k] || "circle" === j[k]){ + i.qansBySolver = 1;} + else if ("dot" === j[k]){ + i.qsubBySolver = 1;} + else if ("aboloUpperLeft" === j[k]){ + i.qansBySolver = 5;} + else if ("aboloUpperRight" === j[k]){ + i.qansBySolver = 4;} + else if ("aboloLowerLeft" === j[k]){ + i.qansBySolver = 2;} + else if ("aboloLowerRight" === j[k]){ + i.qansBySolver = 3;} + else if (j[k].kind){ + if ("text" === j[k].kind){ + i.qansBySolver = parseInt(j[k].data);} + else if ("sudokuCandidateSet" === j[k].kind) { + i.qcandBySolver = []; + for (var l = 0; l < this.rows; ++l){ + i.qcandBySolver.push(!1);} + for (var l = 0; l < j[k].values.length; ++l) { + var e = j[k].values[l]; + 1 <= e && e <= this.rows && (i.qcandBySolver[e - 1] = !0) + }} + } + else{ + for (var m = "shakashaka" === this.pid ? 2 : 1, g = 0; g < this.cell.length; ++g) { + var i = this.cell[g], + c = (i.by - 1) / 2, + e = (i.bx - 1) / 2; + c % 2 === e % 2 && (i.qansBySolver = m) + }} + }}}}, + + clearSolverAnswerForBorders: function() { + for (var a = !1, b = 0; b < this.border.length; ++b) { + var c = this.border[b]; + 0 === c.lineBySolver && 0 === c.qsubBySolver || (c.lineBySolver = 0, c.qsubBySolver = 0, a = !0) + } + return a + }, + + updateSolverAnswerForBorders: function(a) { + if (this.clearSolverAnswerForBorders(), "string" !== typeof a) { + for (var b = [], c = 0; c < 2 * this.rows + 1; ++c) { + for (var d = [], e = 0; e < 2 * this.cols + 1; ++e) + {d.push([]);} + b.push(d) + } + for (var f = a.data, g = 0; g < f.length; ++g) { + var h = f[g]; + "green" === h.color && (h.x % 2 !== h.y % 2 && b[h.y][h.x].push(h.item)) + } + for (var g = 0; g < this.border.length; ++g) { + for (var i = this.border[g], j = b[i.by][i.bx], k = 0; k < j.length; ++k){ + "line" === j[k] || "wall" === j[k] ? i.lineBySolver = 1 : "cross" === j[k] && (i.qsubBySolver = 2)}} + } else { + for (var g = 0; g < this.border.length; ++g) { + var i = this.border[g]; + i.qsubBySolver = 2 + } + } + }, + showAnswer: function() { + if (this.answers) { + var a, b, c = this.answerIndex; + "string" === typeof this.answers ? (a = this.answers, b = 0) : (a = this.answers.answers[c], b = this.answers.answers.length); + var d = ui.popupmgr.popups.auxeditor.pop.querySelector(".solver-answer-locator"); + "terminated" === this.answers ? d.innerText = "Terminated" : d.innerText = c + 1 + "/" + b; + "numlin-aux" === this.pid && this.updateSolverAnswerForBorders(a), this.puzzle.painter.paintAll() + } + }, + + locateAnswer: function(a) { + if (null !== this.answers) { + var b; + b = "string" === typeof this.answers ? 0 : this.answers.answers.length, -2 === a ? this.answerIndex = 0 : -1 === a ? (this.answerIndex -= 1, this.answerIndex < 0 && (this.answerIndex = 0)) : 1 === a ? (this.answerIndex += 1, this.answerIndex >= b && (this.answerIndex = b - 1)) : this.answerIndex = b - 1, this.showAnswer() + } + }, + is_autosolve: !1, + + updateIsAutosolve: function(a) { + this.is_autosolve !== a && (this.is_autosolve = a, this.autoSolve()) + }, + //--------------------------------------------------------------------------- // bd.initBoardSize() 指定されたサイズで盤面の初期化を行う //--------------------------------------------------------------------------- @@ -172,6 +312,12 @@ pzpr.classmgr.makeCommon({ groups2.allclear(false); } groups.length = len; + for (var id = 0; id < len; id++) { + groups[id].qansBySolver = 0; + groups[id].qsubBySolver = 0; + groups[id].lineBySolver = 0; + groups[id].qcandBySolver = null; + } return len - clen; }, getGroup: function(group) { diff --git a/src/puzzle/Config.js b/src/puzzle/Config.js index 3a8a2fb4e..24826cb9f 100644 --- a/src/puzzle/Config.js +++ b/src/puzzle/Config.js @@ -169,6 +169,9 @@ this.add("discolor", false); /* tentaisho: 色分け無効化 */ /* その他の特殊項目(保存なし) */ this.add("uramashu", false, { volatile: true }); /* 裏ましゅにする */ + this.add("autosolver", false, { volatile: true }); + this.add("run_autosolver", false, { volatile: true }); + this.add("open_solver", false, { volatile: true }) }, add: function(name, defvalue, extoption) { if (!extoption) { @@ -544,6 +547,32 @@ "wataridori" ].indexOf(pid) >= 0; break; + case "autosolver": + case "run_autosolver": + exec = + [ + "nurimisaki", + "nurikabe", + "lits", + "heyawake", + "slither", + "mashu", + "yajilin", + "lightup", + "shakashaka", + "aqre", + "tapa", + "simpleloop", + "yajilin-regions", + "castle", + "shimaguni", + "norinori", + "sudoku" + ].indexOf(pid) >= 0; + break; + case "open_solver": + exec = pid === "numlin"; + break; default: exec = !!this.list[name]; } @@ -595,6 +624,11 @@ puzzle.board.revCircleConfig(newval); puzzle.redraw(); break; + case "autosolver": + puzzle.board.updateIsAutosolve(newval); + break; + case "run_autosolver": + puzzle.board.autoSolve(true); } } }; diff --git a/src/puzzle/Graphic.js b/src/puzzle/Graphic.js index 1f7e4a09e..3f7144708 100644 --- a/src/puzzle/Graphic.js +++ b/src/puzzle/Graphic.js @@ -63,6 +63,9 @@ subcolor: "rgb(127, 127, 255)", subshadecolor: "rgb(220, 220, 255)", + solvercolor: "rgb(192, 192, 255)", + solverqanscolor: "rgb(0, 160, 192)", + // 黒マスの色 shadecolor: "black", errcolor1: "rgb(192, 0, 0)", diff --git a/src/puzzle/Piece.js b/src/puzzle/Piece.js index 9c3197fe9..0025db114 100644 --- a/src/puzzle/Piece.js +++ b/src/puzzle/Piece.js @@ -30,6 +30,9 @@ pzpr.classmgr.makeCommon({ /* 回答データを保持するプロパティ */ qans: 0, // cell :(1:黒マス/あかり 2-5:三角形 11-13:棒 31-32:斜線 41-50:ふとん) // border:(回答の境界線) + qansBySolver: 0, + qsubBySolver: 0, + lineBySolver: 0, anum: -1, // cell :(セルの数字/○△□/単体矢印) line: 0, // border:(ましゅやスリリンなどの線) @@ -185,6 +188,10 @@ pzpr.classmgr.makeCommon({ if (trialstage > 0) { this.trial = trialstage; } + + if (this.puzzle.editmode) { + this.board.autoSolve(); + } this.board.modifyInfo(this, this.group + "." + prop); @@ -591,6 +598,10 @@ pzpr.classmgr.makeCommon({ return this.qsub === 1; }, + isDotBySolver: function() { + return this.qsubBySolver === 1; + }, + //--------------------------------------------------------------------------- // cell.isEmpty() / cell.isValid() 不定形盤面などで、入力できるマスか判定する //--------------------------------------------------------------------------- @@ -916,6 +927,9 @@ pzpr.classmgr.makeCommon({ isLine: function() { return this.line > 0; }, + isLineBySolver: function() { + return this.lineBySolver > 0; + }, setLine: function(id) { this.setLineVal(1); if (this.qsub === 2) { diff --git a/src/pzpr/variety.js b/src/pzpr/variety.js old mode 100755 new mode 100644 index 3bb981235..0a6c7abf8 --- a/src/pzpr/variety.js +++ b/src/pzpr/variety.js @@ -316,6 +316,7 @@ "", { kanpen: "numberlink" } ], + "numlin-aux": [0, 0, "ソルバー", "Solver"], numrope: [0, 0, "ナンバーロープ", "Number Rope", "kakuru"], nuribou: [1, 0, "ぬりぼう", "Nuribou", "nurikabe"], nurikabe: [0, 1, "ぬりかべ", "Nurikabe", "nurikabe"], diff --git a/src/variety-common/Graphic.js b/src/variety-common/Graphic.js index 8bc532843..95e17b6ec 100644 --- a/src/variety-common/Graphic.js +++ b/src/variety-common/Graphic.js @@ -38,6 +38,10 @@ pzpr.classmgr.makeCommon({ return this.quescolor; }, + getColorSolverAware: function(a, b, c) { + return a && b ? this.solverqanscolor : b ? this.solvercolor : c || this.qanscolor + }, + //--------------------------------------------------------------------------- // pc.drawShadedCells() Cellの、境界線の上から描画される回答の黒マスをCanvasに書き込む // pc.getShadedCellColor() 回答の黒マスの設定・描画判定する @@ -47,7 +51,7 @@ pzpr.classmgr.makeCommon({ this.drawCells_common("c_fulls_", this.getShadedCellColor); }, getShadedCellColor: function(cell) { - if (cell.qans !== 1) { + if (cell.qans !== 1 && cell.qansBySolver !==1) { return null; } var hasinfo = this.board.haserror || this.board.hasinfo; @@ -61,7 +65,7 @@ pzpr.classmgr.makeCommon({ } else if (this.puzzle.execConfig("irowakeblk") && !hasinfo) { return cell.sblk.color; } - return this.shadecolor; + return this.getColorSolverAware(1 === cell.qans, 1 === cell.qansBySolver, this.shadecolor); }, //--------------------------------------------------------------------------- @@ -120,7 +124,7 @@ pzpr.classmgr.makeCommon({ getBGCellColor_qsub1: function(cell) { if ((cell.error || cell.qinfo) === 1) { return this.errbcolor1; - } else if (cell.qsub === 1) { + } else if (cell.qsub === 1 || cell.qsubBySolver === 1) { return this.bcolor; } return null; @@ -234,8 +238,8 @@ pzpr.classmgr.makeCommon({ var cell = clist[i]; g.vid = "c_dot_" + cell.id; - if (cell.isDot()) { - g.fillStyle = !cell.trial ? this.qanscolor : this.trialcolor; + if (cell.isDot() || cell.isDotBySolver()) { + g.fillStyle = !cell.trial ? this.getColorSolverAware(1 === cell.qsub, 1 === cell.qsubBySolver) : this.trialcolor; g.fillCircle(cell.bx * this.bw, cell.by * this.bh, dsize); } else { g.vhide(); @@ -522,6 +526,15 @@ pzpr.classmgr.makeCommon({ {} ); }, + drawSolverAnsNumbers: function() { + this.vinc("cell_solver_ans_number", "auto"); + this.drawNumbers_com( + this.getSolverAnsNumberText, + this.getSolverAnsNumberColor, + "cell_solver_ans_text_", + {} + ); + }, drawHatenas: function() { function getQuesHatenaText(cell) { return cell.ques === -2 || cell.qnum === -2 ? "?" : ""; @@ -565,6 +578,11 @@ pzpr.classmgr.makeCommon({ getAnsNumberText: function(cell) { return this.getNumberText(cell, cell.anum); }, + getSolverAnsNumberText: function(cell) { + if (cell.qansBySolver === 0) {return ""} + return this.getNumberText(cell, cell.qansBySolver); + }, + getNumberText: function(cell, num) { if (!cell.numberAsLetter) { return this.getNumberTextCore(num); @@ -632,6 +650,10 @@ pzpr.classmgr.makeCommon({ return !cell.trial ? this.qanscolor : this.trialcolor; }, + getSolverAnsNumberColor: function(cell) { + return this.solvercolor + }, + //--------------------------------------------------------------------------- // pc.drawNumbersExCell() ExCellの数字をCanvasに書き込む //--------------------------------------------------------------------------- @@ -688,6 +710,14 @@ pzpr.classmgr.makeCommon({ } }, + drawCandidateNumbers: function(a) { + for (var b = this.vinc("cell_candnumber", "auto"), c = Math.round(Math.sqrt(a)), d = this.range.cells, e = 0; e < d.length; e++){ + for (var f = d[e], g = f.qcandBySolver, h = 0; h < a; ++h) { + b.vid = "cell_candtext_" + f.id + "_" + h; + g && g[h] ? (b.fillStyle = this.solvercolor, this.disptext(h + 1 + "", (f.bx + (h % c + .5) / c * 2 - 1) * this.bw, (f.by + (Math.floor(h / c) + .5) / c * 2 - 1) * this.bh, {ratio: 1 / c * .9, hoffset: 0 + })) : b.vhide() + }}}, + //--------------------------------------------------------------------------- // pc.drawArrowNumbers() Cellの数字と矢印をCanvasに書き込む //--------------------------------------------------------------------------- @@ -1279,7 +1309,7 @@ pzpr.classmgr.makeCommon({ }, getLineColor: function(border) { this.addlw = 0; - if (border.isLine()) { + if (border.isLine() || border.isLineBySolver()) { var info = border.error || border.qinfo, puzzle = this.puzzle; var isIrowake = @@ -1301,7 +1331,7 @@ pzpr.classmgr.makeCommon({ } else if (isIrowake) { return border.path.color; } else { - return border.trial ? this.linetrialcolor : this.linecolor; + return border.trial ? this.linetrialcolor : this.getColorSolverAware(1 === border.line, 1 === border.lineBySolver); } } return null; @@ -1424,8 +1454,8 @@ pzpr.classmgr.makeCommon({ for (var i = 0; i < blist.length; i++) { var border = blist[i]; g.vid = "b_peke_" + border.id; - if (border.qsub === 2) { - g.strokeStyle = !border.trial ? this.pekecolor : this.trialcolor; + if (border.qsub === 2 || border.qsubBySolver === 2) { + g.strokeStyle = !border.trial ? this.getColorSolverAware(2 === border.qsub, 2 === border.qsubBySolver) : this.trialcolor; g.strokeCross(border.bx * this.bw, border.by * this.bh, size - 1); } else { g.vhide(); @@ -1461,6 +1491,19 @@ pzpr.classmgr.makeCommon({ var g = this.vinc("cell_triangle", "crispEdges"); var clist = this.range.cells; + for (var i = 0; i < clist; i++) { + var cell = clist[i], + num = cell.qansBySolver; + + g.vid = "c_tri_solver_" + cell.id; + if (num >= 2 && num <= 5) { + g.fillStyle = this.solvercolor; + this.drawTriangle1(cell.bx * this.bw, cell.by * this.bh, num); + } else { + g.vhide(); + } + } + for (var i = 0; i < clist.length; i++) { var cell = clist[i], num = cell.ques !== 0 ? cell.ques : cell.qans; diff --git a/src/variety/araf.js b/src/variety/araf.js old mode 100755 new mode 100644 diff --git a/test/script/araf.js b/test/script/araf.js old mode 100755 new mode 100644 diff --git a/test/script/canal.js b/test/script/canal.js old mode 100755 new mode 100644 diff --git a/test/script/cbanana.js b/test/script/cbanana.js old mode 100755 new mode 100644 diff --git a/test/script/maxi.js b/test/script/maxi.js old mode 100755 new mode 100644 From c20ba3288191fbe00278bbc5cd1a2cdc1fc9d6dd Mon Sep 17 00:00:00 2001 From: Rever Date: Wed, 4 Jun 2025 15:11:31 -0400 Subject: [PATCH 02/46] In case something goes wrong things are pushed --- .eslintignore | 1 + Gruntfile.js | 30 +- package-lock.json | 624 ++++----- package.json | 5 +- src-ui/p.html | 12 + src-ui/res/p.en.json | 2 + src/.eslintrc.json | 54 +- src/puzzle/Board.js | 131 +- src/puzzle/Config.js | 19 +- src/puzzle/Graphic.js | 6 +- src/puzzle/Piece.js | 10 +- src/pzpr/parser.js | 2 +- src/solver.js | 6 + src/solver/SolverBridge.js | 20 + src/solver/cspuz_solver_backend.js | 2082 ++++++++++++++++++++++++++++ src/variety-common/Graphic.js | 70 +- src/variety/aquapelago.js | 4 +- src/variety/chainedb.js | 4 +- src/variety/hakoiri.js | 35 +- src/variety/lightup.js | 4 +- src/variety/shimaguni.js | 8 +- src/variety/yajilin.js | 4 +- 22 files changed, 2645 insertions(+), 488 deletions(-) create mode 100644 src/solver.js create mode 100644 src/solver/SolverBridge.js create mode 100644 src/solver/cspuz_solver_backend.js diff --git a/.eslintignore b/.eslintignore index 8df7d4b32..fdc47f874 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ src/lib/*.js src/common/*.js src-ui/js/common/*.js +src/solver/*.js diff --git a/Gruntfile.js b/Gruntfile.js index 9c84dda51..5f7e4be54 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -59,7 +59,8 @@ module.exports = function(grunt){ files : [ { expand: true, cwd: 'src-ui/css', src: ['*.css'], dest: 'dist/css' }, { expand: true, cwd: 'src-ui/img', src: ['*.png'], dest: 'dist/img' }, - { expand: true, cwd: 'src-ui', src: ['*'], dest: 'dist' } + { expand: true, cwd: 'src-ui', src: ['*'], dest: 'dist' }, + { expand: true, cwd: 'src-ui/js', src: ['solver.js'], dest: 'dist/js' } ] } }, @@ -76,7 +77,15 @@ module.exports = function(grunt){ files: [ { src: require('./src/pzpr.js').files, dest: 'dist/js/pzpr.concat.js' } ] - }, + }, + solver: { + options: { + sourceMap: !PRODUCTION + }, + files: [ + { src: require('./src/solver.js').files, dest: 'dist/js/solver.concat.js' } + ] + }, ui: { options:{ sourceMap: !PRODUCTION @@ -117,7 +126,17 @@ module.exports = function(grunt){ files: [ { src: 'dist/js/pzpr.concat.js', dest: 'dist/js/pzpr.js'} ] - }, + }, + solver: { + options: (PRODUCTION ? {} : { + sourceMap: 'dist/js/solver.js.map', + sourceMapIn: 'dist/js/solver.concat.js.map', + sourceMapIncludeSources: true + }), + files: [ + { src: 'dist/js/solver.concat.js', dest: 'dist/js/solver.js' } + ] + }, variety:{ options: (PRODUCTION ? {} : { sourceMap : function(filename){ return filename+'.map';} @@ -150,8 +169,9 @@ module.exports = function(grunt){ grunt.registerTask('default', ['build']); grunt.registerTask('release', ['build']); - grunt.registerTask('build', ['build:pzpr', 'build:variety', 'build:samples', 'build:ui']); - grunt.registerTask('build:pzpr', ['concat:pzpr', 'uglify:pzpr']); + grunt.registerTask('build', ['build:pzpr', 'build:solver', 'build:variety', 'build:samples', 'build:ui']); + grunt.registerTask('build:pzpr', ['concat:pzpr', 'uglify:pzpr']); + grunt.registerTask('build:solver', ['concat:solver', 'uglify:solver']) grunt.registerTask('build:ui', ['copy:ui', 'concat:ui', 'uglify:ui']); grunt.registerTask('build:variety',['uglify:variety']); grunt.registerTask('build:samples',['concat:samples', 'uglify:samples']); diff --git a/package-lock.json b/package-lock.json index 171246aaa..a9f53ca0a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,10 +9,12 @@ "version": "0.12.0", "license": "MIT", "dependencies": { + "promise": "^8.3.0", "pzpr-canvas": "0.8.2", "source-map-support": "^0.5.21" }, "devDependencies": { + "@babel/eslint-parser": "^7.27.1", "del-cli": "^4.0.1", "eslint": "^8.43.0", "grunt": "^1.5.3", @@ -41,80 +43,20 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.22.13", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", - "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz", + "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/highlight": "^7.22.13", - "chalk": "^2.4.2" + "@babel/helper-validator-identifier": "^7.27.1", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/code-frame/node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/code-frame/node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/code-frame/node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/@babel/code-frame/node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true - }, - "node_modules/@babel/code-frame/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/code-frame/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/@babel/compat-data": { "version": "7.20.1", "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.20.1.tgz", @@ -154,6 +96,35 @@ "url": "https://opencollective.com/babel" } }, + "node_modules/@babel/eslint-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.27.1.tgz", + "integrity": "sha512-q8rjOuadH0V6Zo4XLMkJ3RMQ9MSBqwaDByyYB0izsYdaIWGNLmEblbCOf1vyFHICcg16CD7Fsi51vcQnYxmt6Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nicolo-ribaudo/eslint-scope-5-internals": "5.1.1-v1", + "eslint-visitor-keys": "^2.1.0", + "semver": "^6.3.1" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || >=14.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.11.0", + "eslint": "^7.5.0 || ^8.0.0 || ^9.0.0" + } + }, + "node_modules/@babel/eslint-parser/node_modules/eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=10" + } + }, "node_modules/@babel/generator": { "version": "7.23.0", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", @@ -291,19 +262,21 @@ } }, "node_modules/@babel/helper-string-parser": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", - "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.20", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", - "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz", + "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -318,100 +291,28 @@ } }, "node_modules/@babel/helpers": { - "version": "7.20.1", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.20.1.tgz", - "integrity": "sha512-J77mUVaDTUJFZ5BpP6mMn6OIl3rEWymk2ZxDBQJUG3P+PbmyMcF3bYWvz0ma69Af1oobDqT/iAsvzhB58xhQUg==", - "dev": true, - "dependencies": { - "@babel/template": "^7.18.10", - "@babel/traverse": "^7.20.1", - "@babel/types": "^7.20.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/highlight": { - "version": "7.22.20", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.20.tgz", - "integrity": "sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.27.1.tgz", + "integrity": "sha512-FCvFTm0sWV8Fxhpp2McP5/W53GPllQ9QeQ7SiqGWjMf/LVG07lFa5+pgK05IRhVwtvafT22KF+ZSnM9I545CvQ==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-validator-identifier": "^7.22.20", - "chalk": "^2.4.2", - "js-tokens": "^4.0.0" + "@babel/template": "^7.27.1", + "@babel/types": "^7.27.1" }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/highlight/node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/@babel/highlight/node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true - }, - "node_modules/@babel/highlight/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "node_modules/@babel/parser": { + "version": "7.27.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.27.2.tgz", + "integrity": "sha512-QYLs8299NA7WM/bZAdp+CviYYkVoYXlDW2rzliy3chxd1PQjej7JORuMJDJXJUb9g0TT+B99EwaVLKmX+sPXWw==", "dev": true, + "license": "MIT", "dependencies": { - "has-flag": "^3.0.0" + "@babel/types": "^7.27.1" }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/parser": { - "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", - "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", - "dev": true, "bin": { "parser": "bin/babel-parser.js" }, @@ -420,14 +321,15 @@ } }, "node_modules/@babel/template": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", - "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", + "version": "7.27.2", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.27.2.tgz", + "integrity": "sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.22.13", - "@babel/parser": "^7.22.15", - "@babel/types": "^7.22.15" + "@babel/code-frame": "^7.27.1", + "@babel/parser": "^7.27.2", + "@babel/types": "^7.27.1" }, "engines": { "node": ">=6.9.0" @@ -464,14 +366,14 @@ } }, "node_modules/@babel/types": { - "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", - "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.27.1.tgz", + "integrity": "sha512-+EzkxvLNfiUeKMgy/3luqfsCWFRXLb7U6wNQTk60tovuckwB15B191tJWvpp4HjiQWdJkCxO3Wbvc6jlk3Xb2Q==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.20", - "to-fast-properties": "^2.0.0" + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.27.1" }, "engines": { "node": ">=6.9.0" @@ -672,6 +574,40 @@ "@jridgewell/sourcemap-codec": "1.4.14" } }, + "node_modules/@nicolo-ribaudo/eslint-scope-5-internals": { + "version": "5.1.1-v1", + "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz", + "integrity": "sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-scope": "5.1.1" + } + }, + "node_modules/@nicolo-ribaudo/eslint-scope-5-internals/node_modules/eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@nicolo-ribaudo/eslint-scope-5-internals/node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -900,6 +836,12 @@ "node": ">=0.10.0" } }, + "node_modules/asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", + "license": "MIT" + }, "node_modules/balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -1169,10 +1111,11 @@ "dev": true }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, + "license": "MIT", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -1514,13 +1457,11 @@ } }, "node_modules/del-cli/node_modules/semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, + "license": "ISC", "bin": { "semver": "bin/semver.js" }, @@ -3269,7 +3210,8 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/js-yaml": { "version": "4.1.1", @@ -3544,12 +3486,13 @@ } }, "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, + "license": "MIT", "dependencies": { - "braces": "^3.0.2", + "braces": "^3.0.3", "picomatch": "^2.3.1" }, "engines": { @@ -4155,10 +4098,11 @@ } }, "node_modules/picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" }, "node_modules/picomatch": { "version": "2.3.1", @@ -4238,6 +4182,15 @@ "node": ">=8" } }, + "node_modules/promise": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/promise/-/promise-8.3.0.tgz", + "integrity": "sha512-rZPNPKTOYVNEEKFaq1HqTgOwZD+4/YHS5ukLzQCypkj+OkYx7iv0mA91lJlpPPZ8vMau3IIGj5Qlwrx+8iiSmg==", + "license": "MIT", + "dependencies": { + "asap": "~2.0.6" + } + }, "node_modules/punycode": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", @@ -4437,10 +4390,11 @@ "dev": true }, "node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, + "license": "ISC", "bin": { "semver": "bin/semver.js" } @@ -4720,15 +4674,6 @@ "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, - "node_modules/to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -5118,65 +5063,14 @@ } }, "@babel/code-frame": { - "version": "7.22.13", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", - "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz", + "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==", "dev": true, "requires": { - "@babel/highlight": "^7.22.13", - "chalk": "^2.4.2" - }, - "dependencies": { - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } + "@babel/helper-validator-identifier": "^7.27.1", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" } }, "@babel/compat-data": { @@ -5208,6 +5102,25 @@ "semver": "^6.3.0" } }, + "@babel/eslint-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.27.1.tgz", + "integrity": "sha512-q8rjOuadH0V6Zo4XLMkJ3RMQ9MSBqwaDByyYB0izsYdaIWGNLmEblbCOf1vyFHICcg16CD7Fsi51vcQnYxmt6Q==", + "dev": true, + "requires": { + "@nicolo-ribaudo/eslint-scope-5-internals": "5.1.1-v1", + "eslint-visitor-keys": "^2.1.0", + "semver": "^6.3.1" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true + } + } + }, "@babel/generator": { "version": "7.23.0", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", @@ -5314,15 +5227,15 @@ } }, "@babel/helper-string-parser": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", - "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", "dev": true }, "@babel/helper-validator-identifier": { - "version": "7.22.20", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", - "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz", + "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==", "dev": true }, "@babel/helper-validator-option": { @@ -5332,94 +5245,33 @@ "dev": true }, "@babel/helpers": { - "version": "7.20.1", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.20.1.tgz", - "integrity": "sha512-J77mUVaDTUJFZ5BpP6mMn6OIl3rEWymk2ZxDBQJUG3P+PbmyMcF3bYWvz0ma69Af1oobDqT/iAsvzhB58xhQUg==", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.27.1.tgz", + "integrity": "sha512-FCvFTm0sWV8Fxhpp2McP5/W53GPllQ9QeQ7SiqGWjMf/LVG07lFa5+pgK05IRhVwtvafT22KF+ZSnM9I545CvQ==", "dev": true, "requires": { - "@babel/template": "^7.18.10", - "@babel/traverse": "^7.20.1", - "@babel/types": "^7.20.0" + "@babel/template": "^7.27.1", + "@babel/types": "^7.27.1" } }, - "@babel/highlight": { - "version": "7.22.20", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.20.tgz", - "integrity": "sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==", + "@babel/parser": { + "version": "7.27.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.27.2.tgz", + "integrity": "sha512-QYLs8299NA7WM/bZAdp+CviYYkVoYXlDW2rzliy3chxd1PQjej7JORuMJDJXJUb9g0TT+B99EwaVLKmX+sPXWw==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.22.20", - "chalk": "^2.4.2", - "js-tokens": "^4.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } + "@babel/types": "^7.27.1" } }, - "@babel/parser": { - "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", - "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", - "dev": true - }, "@babel/template": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", - "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", + "version": "7.27.2", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.27.2.tgz", + "integrity": "sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==", "dev": true, "requires": { - "@babel/code-frame": "^7.22.13", - "@babel/parser": "^7.22.15", - "@babel/types": "^7.22.15" + "@babel/code-frame": "^7.27.1", + "@babel/parser": "^7.27.2", + "@babel/types": "^7.27.1" } }, "@babel/traverse": { @@ -5449,14 +5301,13 @@ } }, "@babel/types": { - "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", - "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.27.1.tgz", + "integrity": "sha512-+EzkxvLNfiUeKMgy/3luqfsCWFRXLb7U6wNQTk60tovuckwB15B191tJWvpp4HjiQWdJkCxO3Wbvc6jlk3Xb2Q==", "dev": true, "requires": { - "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.20", - "to-fast-properties": "^2.0.0" + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.27.1" } }, "@eslint-community/eslint-utils": { @@ -5606,6 +5457,33 @@ "@jridgewell/sourcemap-codec": "1.4.14" } }, + "@nicolo-ribaudo/eslint-scope-5-internals": { + "version": "5.1.1-v1", + "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz", + "integrity": "sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==", + "dev": true, + "requires": { + "eslint-scope": "5.1.1" + }, + "dependencies": { + "eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + } + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true + } + } + }, "@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -5780,6 +5658,11 @@ "integrity": "sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA==", "dev": true }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==" + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -5975,9 +5858,9 @@ "dev": true }, "cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "requires": { "path-key": "^3.1.0", @@ -6212,13 +6095,10 @@ } }, "semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "dev": true }, "strip-indent": { "version": "4.0.0", @@ -7715,12 +7595,12 @@ "dev": true }, "micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "requires": { - "braces": "^3.0.2", + "braces": "^3.0.3", "picomatch": "^2.3.1" } }, @@ -8175,9 +8055,9 @@ "dev": true }, "picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", "dev": true }, "picomatch": { @@ -8228,6 +8108,14 @@ "fromentries": "^1.2.0" } }, + "promise": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/promise/-/promise-8.3.0.tgz", + "integrity": "sha512-rZPNPKTOYVNEEKFaq1HqTgOwZD+4/YHS5ukLzQCypkj+OkYx7iv0mA91lJlpPPZ8vMau3IIGj5Qlwrx+8iiSmg==", + "requires": { + "asap": "~2.0.6" + } + }, "punycode": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", @@ -8352,9 +8240,9 @@ "dev": true }, "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true }, "serialize-javascript": { @@ -8574,12 +8462,6 @@ "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, - "to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", - "dev": true - }, "to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", diff --git a/package.json b/package.json index 8919b63e6..fd233093f 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "node": ">= 14.0" }, "scripts": { - "build": "eslint --cache --quiet src src-ui && \"./git-hash.sh\" && grunt default", + "build": "eslint --cache --quiet src src-ui && grunt default", "release": "npm run clean && eslint --cache --quiet src && grunt release", "clean": "del dist/* pzpr-*.{zip,tar.gz,tar.bz2,tgz}", "format": "prettier --write \"{src,src-ui,test}/**/*.{js,css}\"", @@ -32,6 +32,7 @@ "prepublishOnly": "npm test" }, "devDependencies": { + "@babel/eslint-parser": "^7.27.1", "del-cli": "^4.0.1", "eslint": "^8.43.0", "grunt": "^1.5.3", @@ -42,7 +43,9 @@ "nyc": "^15.1.0", "prettier": "^1.19.1" }, + "dependencies": { + "promise": "^8.3.0", "pzpr-canvas": "0.8.2", "source-map-support": "^0.5.21" } diff --git a/src-ui/p.html b/src-ui/p.html index 50f9cd9fc..25b2da55f 100644 --- a/src-ui/p.html +++ b/src-ui/p.html @@ -24,6 +24,7 @@ + puzz.link player @@ -364,6 +365,17 @@

読み込み中です...

+
+ + + + + + +

- + +
+ 領域+黒マス系 + Areas and Shading Puzzles +
    + +
  • +
  • +
  • +
  • +
  • +
  • + +
  • + +
+
+
+ 連黒分断禁系 + No Adjacent, No Divide +
    +
  • + +
  • + +
  • + +
  • + +
  • + +
  • +
  • +
  • + +
+
+
+ ループ系 + Make a Loop +
    +
  • + +
  • +
  • +
  • + +
  • + +
  • +
  • +
  • + +
  • + +
  • + +
  • + +
+
+
+ 交差ありループ系 + Make a Crossing Loop +
    +
  • + +
  • +
  • +
  • +
  • + +
+
+
+ アイスバーン系 + Icebarn like Puzzles +
    + +
  • + +
  • +
+
+
+ 線でつなぐパズル + Connecting Puzzles +
    + +
+
+
+ ひとつながりにするパズル + Connection Puzzles +
    +
  • +
  • +
  • +
  • + +
+
+
+ 移動系パズル + Moving Puzzles +
    +
  • +
  • + +
+
+
+ 領域分割系 + Divide into Areas +
    +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
+
+
+ 領域分割系 (数字なし) + Divide into Areas (without number) +
    +
+
+
+ タタミ系 + Tatami Puzzles +
    +
  • +
+
+
+ 数字系 + Number Puzzles +
    +
  • +
  • +
  • +
+
+
+ 領域+数字系 + Areas and Numbers +
    +
  • +
  • +
  • +
+
+
+ その他 (線を引く) + Drawing Puzzles +
    +
  • +
  • +
+
+
+ その他 (数字あり) + Variety Puzzles (with numbers) +
    +
  • +
  • +
  • +
  • +
+
+
+ その他 (数字なし) + Variety Puzzles (without numbers) +
    +
  • +
  • +
  • +
+
+ + - + diff --git a/src/puzzle/Board.js b/src/puzzle/Board.js index c5995fbc9..617fd192d 100644 --- a/src/puzzle/Board.js +++ b/src/puzzle/Board.js @@ -102,30 +102,7 @@ pzpr.classmgr.makeCommon({ autoSolve: function(force) { this.answers = null; - var updateCells = - /*[ - "nurimisaki", - "nurikabe", - "lits", - "heyawake", - "cave", - "lightup", - "shakashaka", - "aqre", - "tapa", - "shimaguni", - "norinori", - "kakuro", - "sudoku", - "cbanana", - "clamp", - "stostone", - "kakuro", - "chainedb", - "kurotto", - "nothree", - "creek" - ].indexOf(this.pid) >= 0;*/ true; + var updateCells = !(this.pid === "kouchoku"); var updateBorders = /* [ "slither", @@ -159,7 +136,7 @@ pzpr.classmgr.makeCommon({ if (updateBorders) { this.updateSolverAnswerForBorders(result); } - + this.updateSolverAnswerForCrosses(result); this.puzzle.painter.paintAll(); }, @@ -167,7 +144,7 @@ pzpr.classmgr.makeCommon({ clearSolverAnswerForCells: function() { for (var a = !1, b = 0; b < this.cell.length; ++b) { var c = this.cell[b]; - 0 === c.qansBySolver && 0 === c.qsubBySolver && -1 === c.qnumBySolver || (c.qansBySolver = 0, c.qsubBySolver = 0, c.qnumBySolver = -1, a = !0), null !== c.qcandBySolver && (c.qcandBySolver = null, a = !0) + 0 === c.qansBySolver && 0 === c.qsubBySolver && -1 === c.qnumBySolver || (c.qansBySolver = 0, c.qsubBySolver = 0, c.qnumBySolver = -1, a = !0), null !== c.qcandBySolver && (c.qcandBySolver = null, a = !0), [] !== c.destBySolver && (c.destBySolver = [], a = !0) } return a }, @@ -192,15 +169,15 @@ pzpr.classmgr.makeCommon({ } } for (var g = 0; g < this.cell.length; ++g) { - var i = this.cell[g] + var i = this.cell[g]; for (j = b[(i.by - 1) / 2][(i.bx - 1) / 2], k = 0; k < j.length; ++k) { - if ("block" === j[k] || "fill" === j[k] || ("circle" === j[k] && "doppelblock" !== this.pid)) { + if ("block" === j[k] || ("fill" === j[k] && "firewalk" !== this.pid) || ("circle" === j[k] && "doppelblock" !== this.pid) || "firewalkCellUl" === j[k] || "firewalkCellDr" === j[k] || "firewalkCellUlDr" === j[k]) { i.qansBySolver = 1; } - else if ("triangle" === j[k]) { + else if ("triangle" === j[k] || "firewalkCellUr" === j[k] || "firewalkCellDl" === j[k] || "firewalkCellUrDl" === j[k]) { i.qansBySolver = 2; } - else if ("square" === j[k]) { + else if ("square" === j[k] || "firewalkCellUnknown" === j[k]) { i.qansBySolver = 3; } else if ("dot" === j[k] || ("circle" === j[k] && "doppelblock" === this.pid)) { @@ -218,6 +195,24 @@ pzpr.classmgr.makeCommon({ else if ("aboloLowerRight" === j[k]) { i.qansBySolver = 3; } + else if ("pencilUp" === j[k]) { + i.qansBySolver = 6; + } + else if ("pencilLeft" === j[k]) { + i.qansBySolver = 7; + } + else if ("pencilDown" === j[k]) { + i.qansBySolver = 8; + } + else if ("pencilRight" === j[k]) { + i.qansBySolver = 9; + } + else if ("slash" === j[k]) { + i.qansBySolver = 32; + } + else if ("backslash" === j[k]) { + i.qansBySolver = 31; + } else if (j[k].kind) { if ("text" === j[k].kind) { i.qnumBySolver = parseInt(j[k].data); @@ -278,6 +273,7 @@ pzpr.classmgr.makeCommon({ for (var g = 0; g < this.border.length; ++g) { for (var i = this.border[g], j = b[i.by][i.bx], k = 0; k < j.length; ++k) { if ("line" === j[k] || "wall" === j[k]) { i.lineBySolver = 1; } + else if ("doubleLine" === j[k]) { i.lineBySolver = 2; } else if ("boldWall" === j[k]) { "firefly" === this.pid ? i.lineBySolver = 1 : i.edgeBySolver = 1; } @@ -291,6 +287,48 @@ pzpr.classmgr.makeCommon({ } } }, + + clearSolverAnswerForCrosses: function () { + for (var a = !1, b = 0; b < this.cross.length; ++b) { + var c = this.cross[b]; + 0 === c.qansBySolver && -1 === c.qsubBySolver && -1 === c.qnumBySolver || (c.qansBySolver = 0, c.qsubBySolver = -1, c.qnumBySolver = -1, a = !0), null !== c.qcandBySolver && (c.qcandBySolver = null, a = !0), [] !== c.destBySolver && (c.destBySolver = [], a = !0) + } + return a + }, + updateSolverAnswerForCrosses: function (result) { + if (this.clearSolverAnswerForCrosses(), "string" !== typeof result) { + for (var b = [], c = 0; c < 2 * this.rows + 1; ++c) { + for (var d = [], e = 0; e < 2 * this.cols + 1; ++e) { d.push([]); } + b.push(d) + } + for (var f = result.data, g = 0; g < f.length; ++g) { + var h = f[g]; + if ("kouchoku" === this.pid) { "green" === h.color && (h.x % 2 === 1 && h.y % 2 === 1 && b[(h.y-1)][(h.x-1)].push(h.item)) } + } + + for (var g = 0; g < this.cross.length; ++g) { + for (var i = this.cross[g], j = b[i.by][i.bx], k = 0; k < j.length; ++k) { + i.qansBySolver = 1; + if (j[k].kind) { + if ("lineTo" === j[k].kind) { + i.qansBySolver = 1; + for (var p = 0; p < this.cross.length; p++) { + if (j[k].destX - 1 === this.cross[p].bx && j[k].destY - 1 === this.cross[p].by) { this.cross[p].destBySolver.push(i.id); break; } + } + } + } + } + } + + } + else { + for (var g = 0; g < this.cross.length; ++g) { + var i = this.cross[g] + i.qansBySolver = 1; + i.destBySolver.push(this.cross[0].id); + } + } + }, showAnswer: function() { if (this.answers) { var a, b, c = this.answerIndex; diff --git a/src/puzzle/Piece.js b/src/puzzle/Piece.js index bdc806d9b..fbd5e755f 100644 --- a/src/puzzle/Piece.js +++ b/src/puzzle/Piece.js @@ -36,7 +36,7 @@ pzpr.classmgr.makeCommon({ qsubBySolver: 0, lineBySolver: 0, edgeBySolver: 0, - numsBySolver: [], + destBySolver: [], anum: -1, // cell :(セルの数字/○△□/単体矢印) line: 0, // border:(ましゅやスリリンなどの線) diff --git a/src/variety-common/Graphic.js b/src/variety-common/Graphic.js index b07d763cd..2d04fa936 100644 --- a/src/variety-common/Graphic.js +++ b/src/variety-common/Graphic.js @@ -42,6 +42,14 @@ pzpr.classmgr.makeCommon({ return a && b ? this.solverqanscolor : b ? this.solvercolor : c || this.qanscolor }, + isSameSymbol: function (answerKey, answerDict, solverKey, solverDict) { + var l = answerDict.length; + var overlap = 0; + for (var i = 0; i < l; i++) { + if (answerKey === answerDict[i] && solverKey === solverDict[i]) { overlap = 1; } + } + return overlap; + }, //--------------------------------------------------------------------------- // pc.drawShadedCells() Cellの、境界線の上から描画される回答の黒マスをCanvasに書き込む @@ -446,6 +454,8 @@ pzpr.classmgr.makeCommon({ g.vid = "c_slash_" + slash + "_" + cell.id; var isQues = cell.ques >= 31 && cell.ques <= 33; + var isSolv = cell.qansBySolver >= 31 && cell.qansBySolver <= 33; + var isAns = cell.qans >= 31 && cell.qans <= 33; var value = isQues ? cell.ques : cell.qans; if (value === 33 || value === (slash ? 32 : 31)) { @@ -485,7 +495,99 @@ pzpr.classmgr.makeCommon({ } else if (cell.trial) { color = this.linetrialcolor; } else { - color = this.linecolor; + color = (1 === this.isSameSymbol(cell.qans, [31, 32, 33], cell.qansBySolver, [31, 32, 33])) ? this.solverqanscolor : this.linecolor; + } + + g.lineWidth = basewidth + addwidth; + g.strokeStyle = color; + g.beginPath(); + var px = cell.bx * this.bw, + py = cell.by * this.bh; + if (!slash) { + g.setOffsetLinePath( + px, + py, + -this.bw, + -this.bh, + this.bw, + this.bh, + true + ); + } else { + g.setOffsetLinePath( + px, + py, + this.bw, + -this.bh, + -this.bw, + this.bh, + true + ); + } + g.stroke(); + } else { + g.vhide(); + } + } + } + this.drawSlashesForSolver(); + }, + + drawSlashesForSolver: function () { + var g = this.vinc("cell_slash_for_solver", "auto"); + + var basewidth = Math.max(this.bw / 4, 2); + var irowake = this.puzzle.execConfig("irowake"); + + var clist = this.range.cells; + for (var slash = 0; slash <= 1; slash++) { + for (var i = 0; i < clist.length; i++) { + var cell = clist[i]; + g.vid = "c_slash_solver_" + slash + "_" + cell.id; + + var isQues = cell.ques >= 31 && cell.ques <= 33; + var isSolv = cell.qansBySolver >= 31 && cell.qansBySolver <= 33; + var isAns = cell.qans >= 31 && cell.qans <= 33; + var value = cell.qansBySolver; + + if (value === 33 || value === (slash ? 32 : 31)) { + var info = cell.qinfo || cell.error, + addwidth = 0, + color; + if (isQues) { + addwidth = -basewidth / 2; + } else if (cell.trial && this.puzzle.execConfig("irowake")) { + addwidth = -basewidth / 2; + } else if ( + (this.pid === "gokigen" || this.pid === "wagiri") && + (info === 1 || info === 3) + ) { + addwidth = basewidth / 2; + } + + if (isQues) { + color = this.quescolor; + } else if (this.pid !== "kinkonkan" && info > 0) { + if (info & (slash ? 4 : 8)) { + color = this.noerrcolor; + } else if (info & 1) { + color = this.errcolor1; + } else if (info & 2) { + color = this.errcolor2; + } + } else if (info === -1) { + color = this.noerrcolor; + } else if (irowake && value === 33) { + color = + !!slash === cell.parity() ? cell.path.color : cell.path2.color; + } else if (irowake && cell.path && cell.path.color) { + color = cell.path.color; + } else if (irowake && cell.path2 && cell.path2.color) { + color = cell.path2.color; + } else if (cell.trial) { + color = this.linetrialcolor; + } else { + color = (1 === this.isSameSymbol(cell.qans, [31, 32, 33], cell.qansBySolver, [31, 32, 33])) ? this.solverqanscolor : this.solvercolor; } g.lineWidth = basewidth + addwidth; @@ -547,6 +649,7 @@ pzpr.classmgr.makeCommon({ {} ); this.drawSolverAnsNumbers(); + this.drawCandidateNumbers(); }, drawSolverAnsNumbers: function() { this.vinc("cell_solver_ans_number", "auto"); diff --git a/src/variety/hakoiri.js b/src/variety/hakoiri.js index 69b740095..b104a6246 100644 --- a/src/variety/hakoiri.js +++ b/src/variety/hakoiri.js @@ -268,7 +268,7 @@ g.strokeStyle = cell.qnum !== -1 ? this.getQuesNumberColor(cell) - : this.getColorSolverAware((cell.getNum() > 0) && (cell.getNum() < 4), (cell.qansBySolver > 0) && (cell.qansBySolver < 4), this.getAnsNumberColor(cell)); + : ((1 === this.isSameSymbol(cell.getNum(), [1, 2, 3], cell.qansBySolver, [1, 2, 3])) ? this.solverqanscolor : this.getAnsNumberColor(cell)) var px = cell.bx * this.bw, py = cell.by * this.bh; switch (cell.getNum()) { @@ -299,7 +299,7 @@ } g.vid = "c_mk_solver" + cell.id; - g.strokeStyle = this.getColorSolverAware((cell.getNum() > 0) && (cell.getNum() < 4), (cell.qansBySolver > 0) && (cell.qansBySolver < 4), this.getAnsNumberColor(cell) ); + g.strokeStyle = (1 === this.isSameSymbol(cell.getNum(), [1, 2, 3], cell.qansBySolver, [1, 2, 3])) ? this.solverqanscolor : this.solvercolor; switch (cell.qansBySolver) { case 1: g.strokeCircle(px, py, rsize); diff --git a/src/variety/hashikake.js b/src/variety/hashikake.js index 3a513b7fc..202a0117e 100644 --- a/src/variety/hashikake.js +++ b/src/variety/hashikake.js @@ -280,7 +280,7 @@ var blist = this.range.borders; for (var i = 0; i < blist.length; i++) { var border = blist[i], - color = this.getLineColor(border); + color = this.getColorSolverAware(border.isLine(), border.isLineBySolver(), this.getLineColor(border)); var isvert = border.isVert(); var px = border.bx * this.bw, py = border.by * this.bh; @@ -288,7 +288,7 @@ g.fillStyle = color; g.vid = "b_line_" + border.id; - if (!!color && border.line === 1) { + if (!!color && (border.line === 1 || border.lineBySolver === 1)) { if (!isvert) { g.fillRectCenter(px, py, lm, this.bh + lm); } else { @@ -299,7 +299,7 @@ } g.vid = "b_dline_" + border.id; - if (!!color && border.line === 2) { + if (!!color && (border.line === 2 || border.lineBySolver === 2)) { g.beginPath(); if (!isvert) { g.rectcenter(px - ls, py, lm, this.bh + lm); diff --git a/src/variety/icewalk.js b/src/variety/icewalk.js index 88de95363..6d7f2dcb4 100644 --- a/src/variety/icewalk.js +++ b/src/variety/icewalk.js @@ -213,6 +213,133 @@ } } }, + + drawArcBackgroundForSolver: function () { + var g = this.vinc("arc_back_solver", "crispEdges"); + var clist = this.range.borders.cellinside(); + var pad = this.lw, + bigpad = this.bw / 2; + for (var i = 0; i < clist.length; i++) { + var cell = clist[i], + color = cell.qansBySolver ? this.getBGCellColor(cell) : null; + g.vid = "c_arc_bg_solver_" + cell.id; + if (!!color) { + g.fillStyle = color; + + if (cell.lcnt === 4) { + g.fillRectCenter( + cell.bx * this.bw, + cell.by * this.bh, + this.bw - pad, + this.bh - pad + ); + } else if (cell.qansBySolver === 3) { + g.fillRectCenter( + cell.bx * this.bw, + cell.by * this.bh, + this.bw / 2, + this.bh / 2 + ); + } else { + var adj = cell.adjborder; + var ox, oy; + if ( + (cell.qansBySolver === 1 && adj.top.isLineBySolver() && adj.left.isLineBySolver()) || + (cell.qansBySolver === 2 && adj.bottom.isLineBySolver() && adj.left.isLineBySolver()) + ) { + ox = (cell.bx - 1) * this.bw - pad + bigpad; + } else { + ox = cell.bx * this.bw + pad - bigpad; + } + if ( + (cell.qansBySolver === 1 && adj.left.isLineBySolver() && adj.top.isLineBySolver()) || + (cell.qansBySolver === 2 && adj.right.isLineBySolver() && adj.top.isLineBySolver()) + ) { + oy = (cell.by - 1) * this.bh - pad + bigpad; + } else { + oy = cell.by * this.bh + pad - bigpad; + } + + var w = this.bw + bigpad - pad * 2; + var h = this.bw + bigpad - pad * 2; + g.fillRect(ox, oy, w, h); + } + } else { + g.vhide(); + } + } + }, + drawArcCorners: function () { + var g = this.vinc("arcs", "auto", true); + g.lineWidth = this.lm * 2; + var rsize = this.bw; + var clist = this.range.borders.cellinside(); + for (var i = 0; i < clist.length; i++) { + var cell = clist[i]; + var px1 = (cell.bx - 1) * this.bw, + py1 = (cell.by - 1) * this.bh, + px2 = (cell.bx + 1) * this.bw, + py2 = (cell.by + 1) * this.bh; + + var adj = cell.adjborder; + + for (var arc = 0; arc < 4; arc++) { + var showArc = false; + var color = null; + switch (arc) { + case 0: + showArc = + cell.qans === 1 && adj.top.isLine() && adj.left.isLine(); + color = showArc ? this.getColorSolverAware(cell.qans === 1 && adj.top.isLine() && adj.left.isLine(), + cell.qansBySolver === 1 && adj.top.isLineBySolver() && adj.left.isLineBySolver(), this.getLineColor(adj.top)) : null; + break; + case 1: + showArc = + cell.qans === 2 && adj.top.isLine() && adj.right.isLine(); + color = showArc ? this.getColorSolverAware(cell.qans === 2 && adj.top.isLine() && adj.right.isLine(), + cell.qansBySolver === 2 && adj.top.isLineBySolver() && adj.right.isLineBySolver(), this.getLineColor(adj.top)) : null; + break; + case 2: + showArc = + cell.qans === 1 && adj.bottom.isLine() && adj.right.isLine(); + color = showArc ? this.getColorSolverAware(cell.qans === 1 && adj.bottom.isLine() && adj.right.isLine(), + cell.qansBySolver === 1 && adj.bottom.isLineBySolver() && adj.right.isLineBySolver(), this.getLineColor(adj.bottom)) : null; + break; + case 3: + showArc = + cell.qans === 2 && adj.bottom.isLine() && adj.left.isLine(); + color = showArc ? this.getColorSolverAware(cell.qans === 2 && adj.bottom.isLine() && adj.left.isLine(), + cell.qansBySolver === 2 && adj.bottom.isLineBySolver() && adj.left.isLineBySolver(), this.getLineColor(adj.bottom)) : null; + break; + } + g.vid = "c_arc_" + arc + "_" + cell.id; + if (!!color) { + g.beginPath(); + g.strokeStyle = color; + + switch (arc) { + case 0: + g.arc(px1, py1, rsize, 0, Math.PI / 2); + break; + case 1: + g.arc(px2, py1, rsize, Math.PI / 2, Math.PI); + break; + case 2: + g.arc(px2, py2, rsize, Math.PI, Math.PI * 1.5); + break; + case 3: + g.arc(px1, py2, rsize, Math.PI * 1.5, Math.PI * 2); + break; + } + g.stroke(); + } else { + g.vhide(); + } + } + } + + this.drawArcBackgroundForSolver(); + }, Border: { enableLineNG: true, isLineNG: function() { @@ -473,6 +600,7 @@ g.vhide(); } } + }, drawArcCorners: function() { var g = this.vinc("arcs", "auto", true); @@ -485,7 +613,6 @@ py1 = (cell.by - 1) * this.bh, px2 = (cell.bx + 1) * this.bw, py2 = (cell.by + 1) * this.bh; - var adj = cell.adjborder; for (var arc = 0; arc < 4; arc++) { @@ -538,9 +665,80 @@ g.vhide(); } } + } + this.drawArcCornersForSolver(); + }, + drawArcCornersForSolver: function() { + var g = this.vinc("arcs_solver", "auto", true); + g.lineWidth = this.lm * 2; + var rsize = this.bw; + var clist = this.range.borders.cellinside(); + for (var i = 0; i < clist.length; i++) { + var cell = clist[i]; + var px1 = (cell.bx - 1) * this.bw, + py1 = (cell.by - 1) * this.bh, + px2 = (cell.bx + 1) * this.bw, + py2 = (cell.by + 1) * this.bh; + + var adj = cell.adjborder; + + for (var arc = 0; arc < 4; arc++) { + var showArc = false; + var color = null; + switch (arc) { + case 0: + showArc = + (cell.qansBySolver === 1 && adj.top.isLineBySolver() && adj.left.isLineBySolver()); + color = showArc ? this.getColorSolverAware(cell.qans === 1 && adj.top.isLine() && adj.left.isLine(), + cell.qansBySolver === 1 && adj.top.isLineBySolver() && adj.left.isLineBySolver(), this.getLineColor(adj.top)) : null; + break; + case 1: + showArc = + cell.qansBySolver === 2 && adj.top.isLineBySolver() && adj.right.isLineBySolver(); + color = showArc ? this.getColorSolverAware(cell.qans === 2 && adj.top.isLine() && adj.right.isLine(), + cell.qansBySolver === 2 && adj.top.isLineBySolver() && adj.right.isLineBySolver(), this.getLineColor(adj.top)) : null; + break; + case 2: + showArc = + cell.qansBySolver === 1 && adj.bottom.isLineBySolver() && adj.right.isLineBySolver(); + color = showArc ? this.getColorSolverAware(cell.qans === 1 && adj.bottom.isLine() && adj.right.isLine(), + cell.qansBySolver === 1 && adj.bottom.isLineBySolver() && adj.right.isLineBySolver(), this.getLineColor(adj.bottom)) : null; + break; + case 3: + showArc = + cell.qansBySolver === 2 && adj.bottom.isLineBySolver() && adj.left.isLineBySolver(); + color = showArc ? this.getColorSolverAware(cell.qans === 2 && adj.bottom.isLine() && adj.left.isLine(), + cell.qansBySolver === 2 && adj.bottom.isLineBySolver() && adj.left.isLineBySolver(), this.getLineColor(adj.bottom)) : null; + break; + } + + g.vid = "c_arc_by_solver_" + arc + "_" + cell.id; + if (!!color) { + g.beginPath(); + g.strokeStyle = color; + + switch (arc) { + case 0: + g.arc(px1, py1, rsize, 0, Math.PI / 2); + break; + case 1: + g.arc(px2, py1, rsize, Math.PI / 2, Math.PI); + break; + case 2: + g.arc(px2, py2, rsize, Math.PI, Math.PI * 1.5); + break; + case 3: + g.arc(px1, py2, rsize, Math.PI * 1.5, Math.PI * 2); + break; + } + g.stroke(); + } else { + g.vhide(); + } } } - }, + } + }, LineGraph: { enabled: true }, diff --git a/src/variety/kouchoku.js b/src/variety/kouchoku.js index 8b7d7ebca..c6ceac6a1 100644 --- a/src/variety/kouchoku.js +++ b/src/variety/kouchoku.js @@ -1193,6 +1193,31 @@ for (var i = 0; i < segs.length; i++) { this.drawSegment1(segs[i], true); } + this.drawSolverSegments(); + }, + + drawSolverSegments: function () { + var g = this.vinc("segment_solver", "auto", true); + var clist = this.range.crosses; + g.strokeStyle = this.solvercolor; + g.lineWidth = this.lw; + for (var i = 0; i < clist.length; i++) { + var celli = clist[i]; + for (var j = 0; j < clist.length; j++) { + var cellj = clist[j]; + g.vid = ["seg_solver", i, j].join("_"); + if (celli.qansBySolver === 1 && cellj.destBySolver.includes(celli.id)) { + var px1 = (celli.bx ) * this.bw, + px2 = (cellj.bx ) * this.bw, + py1 = (celli.by ) * this.bh, + py2 = (cellj.by ) * this.bh; + g.strokeLine(px1, py1, px2, py2); + } + + + else { g.vhide(); } + } + } }, eraseSegment1: function(seg) { this.vinc("segment", "auto"); diff --git a/src/variety/pencils.js b/src/variety/pencils.js index eae266dc4..4beb7f2fc 100644 --- a/src/variety/pencils.js +++ b/src/variety/pencils.js @@ -613,11 +613,11 @@ getBorderColor: function(border) { if (border.ques === 1) { return this.quescolor; - } else if (border.qans === 1) { + } else if (border.qans === 1 || border.isBorderBySolver()) { return border.error ? "red" : !border.trial - ? this.qanscolor + ? this.getColorSolverAware(border.isBorder(), border.isBorderBySolver(), this.qanscolor) : this.trialcolor; } return null; @@ -633,7 +633,7 @@ for (var i = 0; i < clist.length; i++) { var cell = clist[i]; var dir = cell.getPencilDir(); - var color = this.getCellArrowColor(cell); + var color = (1 === this.isSameSymbol(cell.getPencilDir(), [cell.UP, cell.DN, cell.LT, cell.RT], this.qansBySolver, [8, 6, 9, 7])) ? this.solverqanscolor : this.getCellArrowColor(cell); g.lineWidth = (this.lw + this.addlw) / 2; if (!!color) { @@ -692,8 +692,78 @@ g.vhide(); } } + this.drawCellArrowsForSolver(); }, + drawCellArrowsForSolver: function () { + var g = this.vinc("cell_arrow_solver", "crispEdges"); + var outer = this.cw * 0.5; + var inner = this.cw * 0.25; + + var clist = this.range.cells; + for (var i = 0; i < clist.length; i++) { + var cell = clist[i]; + var dir = cell.qansBySolver; + var color = (1 === this.isSameSymbol(cell.getPencilDir(), [cell.UP, cell.DN, cell.LT, cell.RT], dir, [8, 6, 9, 7])) ? this.solverqanscolor : this.solvercolor; + + g.lineWidth = (this.lw + this.addlw) / 2; + if (!!color) { + g.fillStyle = color; + g.strokeStyle = color; + var px = cell.bx * this.bw, + py = cell.by * this.bh; + var idx = [0, 0, 0, 0]; + + switch (dir) { + case 8: + idx = [1, 1, -1, 1]; + break; + case 6: + idx = [1, -1, -1, -1]; + break; + case 9: + idx = [1, -1, 1, 1]; + break; + case 7: + idx = [-1, -1, -1, 1]; + break; + } + + g.vid = "c_arrow_solver_" + cell.id; + g.setOffsetLinePath( + px, + py, + 0, + 0, + idx[0] * inner, + idx[1] * inner, + idx[2] * inner, + idx[3] * inner, + true + ); + g.fill(); + + g.vid = "c_arrow_outer_solver_" + cell.id; + g.setOffsetLinePath( + px, + py, + 0, + 0, + idx[0] * outer, + idx[1] * outer, + idx[2] * outer, + idx[3] * outer, + true + ); + g.stroke(); + } else { + g.vid = "c_arrow_solver_" + cell.id; + g.vhide(); + g.vid = "c_arrow_outer_solver_" + cell.id; + g.vhide(); + } + } + }, getCellArrowColor: function(cell) { if (cell.getPencilDir()) { if (cell.qdir) { diff --git a/src/variety/slashpack.js b/src/variety/slashpack.js index 7f9816204..a8eee1106 100644 --- a/src/variety/slashpack.js +++ b/src/variety/slashpack.js @@ -324,12 +324,12 @@ for (var i = 0; i < clist.length; i++) { var cell = clist[i]; - if (cell.qsub & 1) { + if (cell.qsub & 1 || cell.qsubBySolver & 1) { var px = cell.bx * this.bw; var py = cell.by * this.bh; g.vid = "c_MB_" + cell.id; g.lineWidth = 1; - g.strokeStyle = !cell.trial ? this.mbcolor : "rgb(192, 192, 192)"; + g.strokeStyle = !cell.trial ? this.getColorSolverAware(cell.qsub & 1, cell.qsubBySolver & 1, this.mbcolor) : "rgb(192, 192, 192)"; g.strokeCircle(px, py, rsize); } else { g.vid = "c_MB_" + cell.id; From 5c9aafcbc823c8db801fade01beb19df5c5f86f0 Mon Sep 17 00:00:00 2001 From: Rever Date: Mon, 23 Jun 2025 17:41:47 -0400 Subject: [PATCH 07/46] Added fourcells and tetrominous (solver) --- src-ui/list.html | 8 ++++---- src/solver/SolverBridge.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src-ui/list.html b/src-ui/list.html index 912496655..805d9279d 100644 --- a/src-ui/list.html +++ b/src-ui/list.html @@ -278,8 +278,8 @@

パズルの種類のリスト
  • +
  • @@ -288,8 +288,8 @@

    パズルの種類のリスト
  • -
  • - +
  • From f402d73f9d0641d5d46186f94efacf4119572af3 Mon Sep 17 00:00:00 2001 From: ReverM Date: Wed, 20 Aug 2025 17:00:22 -0400 Subject: [PATCH 10/46] added chocona --- src-ui/list.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src-ui/list.html b/src-ui/list.html index a302554ec..a8af32b13 100644 --- a/src-ui/list.html +++ b/src-ui/list.html @@ -89,8 +89,8 @@

    パズルの種類のリスト
  • - +
  • - + +
  • -
  • --> +
  • +
  • -
  • +
  • +
  • +
  • +
  • +
  • --> +
  • @@ -356,15 +356,15 @@

    パズルの種類のリスト-->
  • +
  • +
  • -
  • --> +
  • -
  • @@ -72,10 +72,10 @@

    パズルの種類のリスト
  • -
  • +
  • -->
  • - --> +

    @@ -167,8 +167,8 @@

    パズルの種類のリスト +
  • +
  • --> +
  • +
  • @@ -261,8 +261,8 @@

    パズルの種類のリスト
  • -
  • -
  • +
  • --> +
  • @@ -280,8 +280,8 @@

    パズルの種類のリスト
  • -->
  • +
  • --> +
  • @@ -299,8 +299,8 @@

    パズルの種類のリスト
  • -
  • -
  • +
  • --> +
  • diff --git a/src/puzzle/Board.js b/src/puzzle/Board.js index 560937351..92e49e622 100644 --- a/src/puzzle/Board.js +++ b/src/puzzle/Board.js @@ -275,6 +275,7 @@ pzpr.classmgr.makeCommon({ updateSolverAnswerForCells: function(result) { + console.log(result); if (this.clearSolverAnswerForCells(), "string" !== typeof result) { for (var b = [], c = 0; c < this.rows; ++c) { for (var d = [], e = 0; e < this.cols; ++e) { @@ -306,7 +307,7 @@ pzpr.classmgr.makeCommon({ b[(h.y - 3) / 2][(h.x - 3) / 2].push(h.item); } else { - ("statuepark" === this.pid || "green" === h.color) && (h.x % 2 === 1 && h.y % 2 === 1 && b[(h.y - 1) / 2][(h.x - 1) / 2].push(h.item)) + ("statuepark" === this.pid || "circlesquare" === this.pid || "green" === h.color) && (h.x % 2 === 1 && h.y % 2 === 1 && b[(h.y - 1) / 2][(h.x - 1) / 2].push(h.item)) } } for (var g = 0; g < this.cell.length; ++g) { diff --git a/src/pzpr/parser.js b/src/pzpr/parser.js index cb2cce762..f43a135ee 100644 --- a/src/pzpr/parser.js +++ b/src/pzpr/parser.js @@ -219,7 +219,7 @@ if (pzpr.env.node) { url = "http://pzv.jp/p.html"; } else { - url = "https://puzz.link/p"; + url = "https://pzprxs.vercel.app/p"; } switch (this.type) { case URL_PZPRV3: From 39a996b5d1bf7d3c2258c8acbaa1206f69512df8 Mon Sep 17 00:00:00 2001 From: ReverM Date: Tue, 16 Dec 2025 19:03:59 -0500 Subject: [PATCH 16/46] Formatting! --- src-ui/js/ui/AuxEditor.js | 11 +- src-ui/js/ui/ToolArea.js | 8 +- src/puzzle/Board.js | 441 +- src/puzzle/Config.js | 16 +- src/puzzle/Piece.js | 3 +- src/solver - Copie.js:Zone.Identifier | Bin 0 -> 25 bytes src/solver.js | 11 +- .../SolverBridge - Copie.js:Zone.Identifier | Bin 0 -> 25 bytes src/solver/SolverBridge.js | 23 +- src/solver/SolverBridgeNoWorker.js | 17 +- src/solver/cspuz_solver_backend.js | 4231 +++++++++-------- .../cspuz_solver_backend.js:Zone.Identifier | 0 src/variety-common/Graphic.js | 141 +- src/variety/aquapelago.js | 4 +- src/variety/chainedb.js | 4 +- src/variety/evolmino.js | 14 +- src/variety/hakoiri.js | 25 +- src/variety/hashikake.js | 6 +- src/variety/herugolf.js | 27 +- src/variety/icewalk.js | 267 +- src/variety/kouchoku.js | 22 +- src/variety/lightup.js | 6 +- src/variety/pencils.js | 30 +- src/variety/shimaguni.js | 14 +- src/variety/slashpack.js | 8 +- src/variety/starbattle.js | 9 +- src/variety/yajilin.js | 6 +- 27 files changed, 2986 insertions(+), 2358 deletions(-) create mode 100644 src/solver - Copie.js:Zone.Identifier create mode 100644 src/solver/SolverBridge - Copie.js:Zone.Identifier create mode 100644 src/solver/cspuz_solver_backend.js:Zone.Identifier diff --git a/src-ui/js/ui/AuxEditor.js b/src-ui/js/ui/AuxEditor.js index 89900232e..5491eea7f 100644 --- a/src-ui/js/ui/AuxEditor.js +++ b/src-ui/js/ui/AuxEditor.js @@ -67,19 +67,20 @@ ui.popupmgr.addpopup("auxeditor", { }, solver_answer_first: function() { - ui.auxeditor.puzzle.board.locateAnswer(-2) + ui.auxeditor.puzzle.board.locateAnswer(-2); }, solver_answer_prev: function() { - ui.auxeditor.puzzle.board.locateAnswer(-1) + ui.auxeditor.puzzle.board.locateAnswer(-1); }, solver_answer_next: function() { - ui.auxeditor.puzzle.board.locateAnswer(1) + ui.auxeditor.puzzle.board.locateAnswer(1); }, solver_answer_last: function() { - ui.auxeditor.puzzle.board.locateAnswer(2) + ui.auxeditor.puzzle.board.locateAnswer(2); }, solver_stop: function() { - ui.auxeditor.puzzle.board.solverRunning && window.solveNumberlinkAsyncTerminate() + ui.auxeditor.puzzle.board.solverRunning && + window.solveNumberlinkAsyncTerminate(); } }); diff --git a/src-ui/js/ui/ToolArea.js b/src-ui/js/ui/ToolArea.js index 9d25e8e16..1ecd08f35 100644 --- a/src-ui/js/ui/ToolArea.js +++ b/src-ui/js/ui/ToolArea.js @@ -219,7 +219,9 @@ ui.toolarea = { var net = ui.network.mode !== ""; var isRunning = ui.puzzle.board.isRunning; - getEL("solver.status").textContent = isRunning ? ui.i18n("solver.status.running") : ui.i18n("solver.status.running"); + getEL("solver.status").textContent = isRunning + ? ui.i18n("solver.status.running") + : ui.i18n("solver.status.running"); getEL("solver.status").style.visibility = isRunning ? "visible" : "hidden"; if (idname === "operation") { @@ -347,10 +349,10 @@ ui.toolarea = { ui.puzzle.irowake(); }, run_autosolver: function() { - ui.puzzle.board.autoSolve(true) + ui.puzzle.board.autoSolve(true); }, open_solver: function() { - ui.puzzle.board.openSolver() + ui.puzzle.board.openSolver(); }, encolorall: function() { ui.puzzle.board.encolorall(); diff --git a/src/puzzle/Board.js b/src/puzzle/Board.js index 92e49e622..98d300066 100644 --- a/src/puzzle/Board.js +++ b/src/puzzle/Board.js @@ -7,7 +7,7 @@ pzpr.classmgr.makeCommon({ //--------------------------------------------------------- - + Board: { initialize: function() { var classes = this.klass; @@ -104,7 +104,6 @@ pzpr.classmgr.makeCommon({ return 1; }, - autoSolve: function(force) { this.answers = null; var updateCells = !(this.pid === "kouchoku"); @@ -144,80 +143,82 @@ pzpr.classmgr.makeCommon({ this.solverWorker = null; } return; + } + + var url = ui.puzzle.getURL(pzpr.parser.URL_PZPRV3); + if (this.puzzle.getConfig("solver_erase")) { + if (updateCells) { + this.clearSolverAnswerForCells(); } + this.clearSolverAnswerForBorders(); + this.puzzle.painter.paintAll(); + } - var url = ui.puzzle.getURL(pzpr.parser.URL_PZPRV3); - if (this.puzzle.getConfig("solver_erase")) { - if (updateCells) { - this.clearSolverAnswerForCells(); - } - this.clearSolverAnswerForBorders() - this.puzzle.painter.paintAll(); + if (window.Worker) { + if (!this.solverWorker) { + this.solverWorker = new Worker("js/SolverWorker.js", { + type: "module" + }); } - - if (window.Worker) { - if (!this.solverWorker) { - this.solverWorker = new Worker("js/SolverWorker.js", { type: "module"}); - } - if (!this.solverWorkerAlt) { - this.solverWorkerAlt = new Worker("js/SolverWorker.js", { type: "module"}); - } - - var bd = this.board; - - if (!this.isRunning) { - this.isRunning = true; - ui.setdisplay(); - if (this.isAlt) { - this.solverWorkerAlt.postMessage(url); - } - else { - this.solverWorker.postMessage(url); - } + if (!this.solverWorkerAlt) { + this.solverWorkerAlt = new Worker("js/SolverWorker.js", { + type: "module" + }); + } + + var bd = this.board; + + if (!this.isRunning) { + this.isRunning = true; + ui.setdisplay(); + if (this.isAlt) { + this.solverWorkerAlt.postMessage(url); + } else { + this.solverWorker.postMessage(url); } - else { - if (this.isAlt) { - if (!!this.solverWorker) { - this.solverWorker.terminate(); - } - this.solverWorker = new Worker("js/SolverWorker.js", { type: "module"}); - this.solverWorker.postMessage(url); + } else { + if (this.isAlt) { + if (!!this.solverWorker) { + this.solverWorker.terminate(); } - else { - if (!!this.solverWorkerAlt) { - this.solverWorkerAlt.terminate(); - } - this.solverWorkerAlt = new Worker("js/SolverWorker.js", { type: "module"}); - this.solverWorkerAlt.postMessage(url); + this.solverWorker = new Worker("js/SolverWorker.js", { + type: "module" + }); + this.solverWorker.postMessage(url); + } else { + if (!!this.solverWorkerAlt) { + this.solverWorkerAlt.terminate(); } + this.solverWorkerAlt = new Worker("js/SolverWorker.js", { + type: "module" + }); + this.solverWorkerAlt.postMessage(url); } - - if (!!this.solverWorker) { - this.solverWorker.onmessage = function(message) { - var result = message.data; - var solverUrl = result[0]; - var solution = result[1]; - - if (ui.puzzle.getURL(pzpr.parser.URL_PZPRV3) !== solverUrl) { - this.postMessage(ui.puzzle.getURL(pzpr.parser.URL_PZPRV3)); - } - - else { - bd.isRunning = false; - if (updateCells) { - bd.updateSolverAnswerForCells(solution); - } + } - bd.updateSolverAnswerForBorders(solution); - bd.updateSolverAnswerForCrosses(solution); + if (!!this.solverWorker) { + this.solverWorker.onmessage = function(message) { + var result = message.data; + var solverUrl = result[0]; + var solution = result[1]; - bd.isAlt = bd.isAlt ? !bd.isAlt: bd.isAlt; - ui.setdisplay(); - bd.puzzle.painter.paintAll(); + if (ui.puzzle.getURL(pzpr.parser.URL_PZPRV3) !== solverUrl) { + this.postMessage(ui.puzzle.getURL(pzpr.parser.URL_PZPRV3)); + } else { + bd.isRunning = false; + if (updateCells) { + bd.updateSolverAnswerForCells(solution); } + bd.updateSolverAnswerForBorders(solution); + bd.updateSolverAnswerForCrosses(solution); + + bd.isAlt = bd.isAlt ? !bd.isAlt : bd.isAlt; + ui.setdisplay(); + bd.puzzle.painter.paintAll(); } - } + }; + } if (!!this.solverWorkerAlt) { this.solverWorkerAlt.onmessage = function(message) { @@ -227,10 +228,7 @@ pzpr.classmgr.makeCommon({ if (ui.puzzle.getURL(pzpr.parser.URL_PZPRV3) !== solverUrl) { this.postMessage(ui.puzzle.getURL(pzpr.parser.URL_PZPRV3)); - } - - else { - + } else { bd.isRunning = false; if (updateCells) { bd.updateSolverAnswerForCells(solution); @@ -239,16 +237,13 @@ pzpr.classmgr.makeCommon({ bd.updateSolverAnswerForBorders(solution); bd.updateSolverAnswerForCrosses(solution); - bd.isAlt = !bd.isAlt ? !bd.isAlt: bd.isAlt; + bd.isAlt = !bd.isAlt ? !bd.isAlt : bd.isAlt; ui.setdisplay(); bd.puzzle.painter.paintAll(); } - - } + }; } - } - - else { + } else { this.isRunning = true; ui.setdisplay(); var result = window.solveProblemAlt(url); @@ -264,19 +259,24 @@ pzpr.classmgr.makeCommon({ } }, - clearSolverAnswerForCells: function() { for (var a = !1, b = 0; b < this.cell.length; ++b) { var c = this.cell[b]; - 0 === c.qansBySolver && 0 === c.qsubBySolver && -1 === c.qnumBySolver || (c.qansBySolver = 0, c.qsubBySolver = 0, c.qnumBySolver = -1, a = !0), null !== c.qcandBySolver && (c.qcandBySolver = null, a = !0), c.destBySolver.length !== 0 && (c.destBySolver = [], a = !0) + (0 === c.qansBySolver && + 0 === c.qsubBySolver && + -1 === c.qnumBySolver) || + ((c.qansBySolver = 0), + (c.qsubBySolver = 0), + (c.qnumBySolver = -1), + (a = !0)), + null !== c.qcandBySolver && ((c.qcandBySolver = null), (a = !0)), + c.destBySolver.length !== 0 && ((c.destBySolver = []), (a = !0)); } - return a + return a; }, - updateSolverAnswerForCells: function(result) { - console.log(result); - if (this.clearSolverAnswerForCells(), "string" !== typeof result) { + if ((this.clearSolverAnswerForCells(), "string" !== typeof result)) { for (var b = [], c = 0; c < this.rows; ++c) { for (var d = [], e = 0; e < this.cols; ++e) { d.push([]); @@ -303,95 +303,115 @@ pzpr.classmgr.makeCommon({ var solution = result.data; for (var g = 0; g < solution.length; ++g) { var h = solution[g]; - if (("kakuro" === this.pid || "doppelblock" === this.pid) && ("green" === h.color) && (h.x % 2 === 1) && (h.y % 2 === 1)) { + if ( + ("kakuro" === this.pid || "doppelblock" === this.pid) && + "green" === h.color && + h.x % 2 === 1 && + h.y % 2 === 1 + ) { b[(h.y - 3) / 2][(h.x - 3) / 2].push(h.item); - } - else { - ("statuepark" === this.pid || "circlesquare" === this.pid || "green" === h.color) && (h.x % 2 === 1 && h.y % 2 === 1 && b[(h.y - 1) / 2][(h.x - 1) / 2].push(h.item)) + } else { + ("statuepark" === this.pid || + "circlesquare" === this.pid || + "green" === h.color) && + h.x % 2 === 1 && + h.y % 2 === 1 && + b[(h.y - 1) / 2][(h.x - 1) / 2].push(h.item); } } for (var g = 0; g < this.cell.length; ++g) { var i = this.cell[g]; - for (j = b[(i.by - 1) / 2][(i.bx - 1) / 2], k = 0; k < j.length; ++k) { - if ("block" === j[k] || "filledCircle" === j[k] || ("fill" === j[k] && "firewalk" !== this.pid) || ("circle" === j[k] && "doppelblock" !== this.pid && "yinyang" !== this.pid) || "firewalkCellUl" === j[k] || "firewalkCellDr" === j[k] || "firewalkCellUlDr" === j[k]) { + for ( + j = b[(i.by - 1) / 2][(i.bx - 1) / 2], k = 0; + k < j.length; + ++k + ) { + if ( + "block" === j[k] || + "filledCircle" === j[k] || + ("fill" === j[k] && "firewalk" !== this.pid) || + ("circle" === j[k] && + "doppelblock" !== this.pid && + "yinyang" !== this.pid) || + "firewalkCellUl" === j[k] || + "firewalkCellDr" === j[k] || + "firewalkCellUlDr" === j[k] + ) { i.qansBySolver = 1; - } - else if ("triangle" === j[k] || "firewalkCellUr" === j[k] || "firewalkCellDl" === j[k] || "firewalkCellUrDl" === j[k]) { + } else if ( + "triangle" === j[k] || + "firewalkCellUr" === j[k] || + "firewalkCellDl" === j[k] || + "firewalkCellUrDl" === j[k] + ) { i.qansBySolver = 2; - } - else if ("square" === j[k] || "firewalkCellUnknown" === j[k]) { + } else if ("square" === j[k] || "firewalkCellUnknown" === j[k]) { i.qansBySolver = 3; - } - else if ("dot" === j[k] || ("circle" === j[k] && ("doppelblock" === this.pid || "yinyang" === this.pid)) ) { + } else if ( + "dot" === j[k] || + ("circle" === j[k] && + ("doppelblock" === this.pid || "yinyang" === this.pid)) + ) { i.qsubBySolver = 1; - } - else if ("aboloUpperLeft" === j[k]) { + } else if ("aboloUpperLeft" === j[k]) { i.qansBySolver = 5; - } - else if ("aboloUpperRight" === j[k]) { + } else if ("aboloUpperRight" === j[k]) { i.qansBySolver = 4; - } - else if ("aboloLowerLeft" === j[k]) { + } else if ("aboloLowerLeft" === j[k]) { i.qansBySolver = 2; - } - else if ("aboloLowerRight" === j[k]) { + } else if ("aboloLowerRight" === j[k]) { i.qansBySolver = 3; - } - else if ("pencilUp" === j[k]) { + } else if ("pencilUp" === j[k]) { i.qansBySolver = 6; - } - else if ("pencilLeft" === j[k]) { + } else if ("pencilLeft" === j[k]) { i.qansBySolver = 7; - } - else if ("pencilDown" === j[k]) { + } else if ("pencilDown" === j[k]) { i.qansBySolver = 8; - } - else if ("pencilRight" === j[k]) { + } else if ("pencilRight" === j[k]) { i.qansBySolver = 9; - } - else if ("slash" === j[k]) { + } else if ("slash" === j[k]) { i.qansBySolver = 32; - } - else if ("backslash" === j[k]) { + } else if ("backslash" === j[k]) { i.qansBySolver = 31; - } - else if (j[k].kind) { + } else if (j[k].kind) { if ("text" === j[k].kind) { if ("bosanowa" === this.pid) { - bd.getc(i.bx - 1 + x1,i.by - 1 + y1).qnumBySolver = parseInt(j[k].data); - } - else { + bd.getc(i.bx - 1 + x1, i.by - 1 + y1).qnumBySolver = parseInt( + j[k].data + ); + } else { i.qnumBySolver = parseInt(j[k].data); } - } - else if ("sudokuCandidateSet" === j[k].kind) { + } else if ("sudokuCandidateSet" === j[k].kind) { i.qcandBySolver = []; for (var l = 0; l < this.rows; ++l) { i.qcandBySolver.push(!1); } for (var l = 0; l < j[k].values.length; ++l) { var e = j[k].values[l]; - 1 <= e && e <= this.rows && (i.qcandBySolver[e - 1] = !0) + 1 <= e && e <= this.rows && (i.qcandBySolver[e - 1] = !0); } } - } - else { - for (var m = "shakashaka" === this.pid ? 2 : 1, g = 0; g < this.cell.length; ++g) { + } else { + for ( + var m = "shakashaka" === this.pid ? 2 : 1, g = 0; + g < this.cell.length; + ++g + ) { var i = this.cell[g], c = (i.by - 1) / 2, e = (i.bx - 1) / 2; - c % 2 === e % 2 && (i.qansBySolver = m) + c % 2 === e % 2 && (i.qansBySolver = m); } } } } - } - else { + } else { for (var g = 0; g < this.cell.length; ++g) { - var i = this.cell[g] - i.qansBySolver = (i.bx + i.by) % 4 + 1; - i.qsubBySolver = (i.bx + i.by) % 4 + 1; + var i = this.cell[g]; + i.qansBySolver = ((i.bx + i.by) % 4) + 1; + i.qsubBySolver = ((i.bx + i.by) % 4) + 1; i.qnumBySolver = 0; } } @@ -400,103 +420,168 @@ pzpr.classmgr.makeCommon({ clearSolverAnswerForBorders: function() { for (var a = !1, b = 0; b < this.border.length; ++b) { var c = this.border[b]; - 0 === c.lineBySolver && 0 === c.qsubBySolver && c.edgeBySolver === 0 || (c.lineBySolver = 0, c.qsubBySolver = 0, c.edgeBySolver = 0, a = !0) + (0 === c.lineBySolver && + 0 === c.qsubBySolver && + c.edgeBySolver === 0) || + ((c.lineBySolver = 0), + (c.qsubBySolver = 0), + (c.edgeBySolver = 0), + (a = !0)); } - return a + return a; }, updateSolverAnswerForBorders: function(result) { - if (this.clearSolverAnswerForBorders(), "string" !== typeof result) { + if ((this.clearSolverAnswerForBorders(), "string" !== typeof result)) { for (var b = [], c = 0; c < 2 * this.rows + 1; ++c) { - for (var d = [], e = 0; e < 2 * this.cols + 1; ++e) - {d.push([]);} - b.push(d) + for (var d = [], e = 0; e < 2 * this.cols + 1; ++e) { + d.push([]); + } + b.push(d); } for (var f = result.data, g = 0; g < f.length; ++g) { var h = f[g]; - if ("firefly" === this.pid) { "green" === h.color && (h.x+1 % 2 !== h.y+1 % 2 && b[h.y+1][h.x+1].push(h.item)) } - else { "green" === h.color && (h.x % 2 !== h.y % 2 && b[h.y][h.x].push(h.item)) } - + if ("firefly" === this.pid) { + "green" === h.color && + h.x + (1 % 2) !== h.y + (1 % 2) && + b[h.y + 1][h.x + 1].push(h.item); + } else { + "green" === h.color && + h.x % 2 !== h.y % 2 && + b[h.y][h.x].push(h.item); + } } for (var g = 0; g < this.border.length; ++g) { - for (var i = this.border[g], j = b[i.by][i.bx], k = 0; k < j.length; ++k) { - if ("line" === j[k] || "wall" === j[k]) { i.lineBySolver = 1; } - else if ("doubleLine" === j[k]) { i.lineBySolver = 2; } - else if ("boldWall" === j[k]) { - "firefly" === this.pid ? i.lineBySolver = 1 : i.edgeBySolver = 1; + for ( + var i = this.border[g], j = b[i.by][i.bx], k = 0; + k < j.length; + ++k + ) { + if ("line" === j[k] || "wall" === j[k]) { + i.lineBySolver = 1; + } else if ("doubleLine" === j[k]) { + i.lineBySolver = 2; + } else if ("boldWall" === j[k]) { + "firefly" === this.pid + ? (i.lineBySolver = 1) + : (i.edgeBySolver = 1); + } else if ("cross" === j[k]) { + i.qsubBySolver = 2; } - else if ("cross" === j[k]) { i.qsubBySolver = 2; } } } } else { for (var g = 0; g < this.border.length; ++g) { var i = this.border[g]; - i.qsubBySolver = 2 + i.qsubBySolver = 2; } } }, - clearSolverAnswerForCrosses: function () { + clearSolverAnswerForCrosses: function() { for (var a = !1, b = 0; b < this.cross.length; ++b) { var c = this.cross[b]; - 0 === c.qansBySolver && -1 === c.qsubBySolver && -1 === c.qnumBySolver || (c.qansBySolver = 0, c.qsubBySolver = -1, c.qnumBySolver = -1, a = !0), null !== c.qcandBySolver && (c.qcandBySolver = null, a = !0), c.destBySolver.length !== 0 && (c.destBySolver = [], a = !0) + (0 === c.qansBySolver && + -1 === c.qsubBySolver && + -1 === c.qnumBySolver) || + ((c.qansBySolver = 0), + (c.qsubBySolver = -1), + (c.qnumBySolver = -1), + (a = !0)), + null !== c.qcandBySolver && ((c.qcandBySolver = null), (a = !0)), + c.destBySolver.length !== 0 && ((c.destBySolver = []), (a = !0)); } - return a + return a; }, - updateSolverAnswerForCrosses: function (result) { - if (this.clearSolverAnswerForCrosses(), "string" !== typeof result) { + updateSolverAnswerForCrosses: function(result) { + if ((this.clearSolverAnswerForCrosses(), "string" !== typeof result)) { for (var b = [], c = 0; c < 2 * this.rows + 1; ++c) { - for (var d = [], e = 0; e < 2 * this.cols + 1; ++e) { d.push([]); } - b.push(d) + for (var d = [], e = 0; e < 2 * this.cols + 1; ++e) { + d.push([]); + } + b.push(d); } for (var f = result.data, g = 0; g < f.length; ++g) { var h = f[g]; - if ("kouchoku" === this.pid) { "green" === h.color && (h.x % 2 === 1 && h.y % 2 === 1 && b[(h.y-1)][(h.x-1)].push(h.item)) } - } - - for (var g = 0; g < this.cross.length; ++g) { - for (var i = this.cross[g], j = b[i.by][i.bx], k = 0; k < j.length; ++k) { - i.qansBySolver = 1; - if (j[k].kind) { - if ("lineTo" === j[k].kind) { - i.qansBySolver = 1; - for (var p = 0; p < this.cross.length; p++) { - if (j[k].destX - 1 === this.cross[p].bx && j[k].destY - 1 === this.cross[p].by) { this.cross[p].destBySolver.push(i.id); break; } - } - } + if ("kouchoku" === this.pid) { + "green" === h.color && + h.x % 2 === 1 && + h.y % 2 === 1 && + b[h.y - 1][h.x - 1].push(h.item); } } - } - } - else { - for (var g = 0; g < this.cross.length; ++g) { - var i = this.cross[g] + for (var g = 0; g < this.cross.length; ++g) { + for ( + var i = this.cross[g], j = b[i.by][i.bx], k = 0; + k < j.length; + ++k + ) { i.qansBySolver = 1; - i.destBySolver.push(this.cross[0].id); + if (j[k].kind) { + if ("lineTo" === j[k].kind) { + i.qansBySolver = 1; + for (var p = 0; p < this.cross.length; p++) { + if ( + j[k].destX - 1 === this.cross[p].bx && + j[k].destY - 1 === this.cross[p].by + ) { + this.cross[p].destBySolver.push(i.id); + break; + } + } + } + } } } + } else { + for (var g = 0; g < this.cross.length; ++g) { + var i = this.cross[g]; + i.qansBySolver = 1; + i.destBySolver.push(this.cross[0].id); + } + } }, showAnswer: function() { if (this.answers) { - var a, b, c = this.answerIndex; - "string" === typeof this.answers ? (a = this.answers, b = 0) : (a = this.answers.answers[c], b = this.answers.answers.length); - var d = ui.popupmgr.popups.auxeditor.pop.querySelector(".solver-answer-locator"); - "terminated" === this.answers ? d.innerText = "Terminated" : d.innerText = c + 1 + "/" + b; - "numlin-aux" === this.pid && this.updateSolverAnswerForBorders(a), this.puzzle.painter.paintAll() + var a, + b, + c = this.answerIndex; + "string" === typeof this.answers + ? ((a = this.answers), (b = 0)) + : ((a = this.answers.answers[c]), (b = this.answers.answers.length)); + var d = ui.popupmgr.popups.auxeditor.pop.querySelector( + ".solver-answer-locator" + ); + "terminated" === this.answers + ? (d.innerText = "Terminated") + : (d.innerText = c + 1 + "/" + b); + "numlin-aux" === this.pid && this.updateSolverAnswerForBorders(a), + this.puzzle.painter.paintAll(); } }, locateAnswer: function(a) { if (null !== this.answers) { var b; - b = "string" === typeof this.answers ? 0 : this.answers.answers.length, -2 === a ? this.answerIndex = 0 : -1 === a ? (this.answerIndex -= 1, this.answerIndex < 0 && (this.answerIndex = 0)) : 1 === a ? (this.answerIndex += 1, this.answerIndex >= b && (this.answerIndex = b - 1)) : this.answerIndex = b - 1, this.showAnswer() + (b = + "string" === typeof this.answers ? 0 : this.answers.answers.length), + -2 === a + ? (this.answerIndex = 0) + : -1 === a + ? ((this.answerIndex -= 1), + this.answerIndex < 0 && (this.answerIndex = 0)) + : 1 === a + ? ((this.answerIndex += 1), + this.answerIndex >= b && (this.answerIndex = b - 1)) + : (this.answerIndex = b - 1), + this.showAnswer(); } }, is_autosolve: !1, updateIsAutosolve: function(a) { - this.is_autosolve !== a && (this.is_autosolve = a, this.autoSolve()) + this.is_autosolve !== a && ((this.is_autosolve = a), this.autoSolve()); }, //--------------------------------------------------------------------------- diff --git a/src/puzzle/Config.js b/src/puzzle/Config.js index 7d9c8b810..5fa2d7792 100644 --- a/src/puzzle/Config.js +++ b/src/puzzle/Config.js @@ -172,7 +172,7 @@ this.add("autosolver", false, { volatile: true }); this.add("run_autosolver", false, { volatile: true }); this.add("solver_erase", true, { volatile: false }); - this.add("open_solver", false, { volatile: true }) + this.add("open_solver", false, { volatile: true }); }, add: function(name, defvalue, extoption) { if (!extoption) { @@ -549,9 +549,9 @@ ].indexOf(pid) >= 0; break; case "autosolver": - case "run_autosolver": - exec = true; - /*[ + case "run_autosolver": + exec = true; + /*[ "nurimisaki", "nurikabe", "lits", @@ -580,10 +580,10 @@ "chainedb", "nothree" ].indexOf(pid) >= 0;*/ - break; - case "open_solver": - exec = pid === "numlin"; - break; + break; + case "open_solver": + exec = pid === "numlin"; + break; default: exec = !!this.list[name]; } diff --git a/src/puzzle/Piece.js b/src/puzzle/Piece.js index fbd5e755f..a8adc78a6 100644 --- a/src/puzzle/Piece.js +++ b/src/puzzle/Piece.js @@ -184,7 +184,6 @@ pzpr.classmgr.makeCommon({ if (this.prehook[prop].call(this, num) && !force) { return; } - } this.addOpe(prop, this[prop], num); @@ -194,7 +193,7 @@ pzpr.classmgr.makeCommon({ if (trialstage > 0) { this.trial = trialstage; } - + if (this.puzzle.editmode) { this.board.autoSolve(); } diff --git a/src/solver - Copie.js:Zone.Identifier b/src/solver - Copie.js:Zone.Identifier new file mode 100644 index 0000000000000000000000000000000000000000..d6c1ec682968c796b9f5e9e080cc6f674b57c766 GIT binary patch literal 25 dcma!!%Fjy;DN4*MPD?F{<>dl#JyUFr831@K2xdl#JyUFr831@K2x { - const resolveRef = resolve; - Module().then(function (mod) { - Solver = mod; - resolveRef(); - }); +const moduleLoaded = new Promise(resolve => { + const resolveRef = resolve; + Module().then(function(mod) { + Solver = mod; + resolveRef(); + }); }); - export async function solveProblem(url) { if (Solver === null) { await moduleLoaded; @@ -20,8 +19,14 @@ export async function solveProblem(url) { var ans = Solver._solve_problem(buf, urlEncoded.length); Solver._free(buf); - var length = Solver.HEAPU8[ans] | (Solver.HEAPU8[ans + 1] << 8) | (Solver.HEAPU8[ans + 2] << 16) | (Solver.HEAPU8[ans + 3] << 24); - var resultStr = new TextDecoder().decode(Solver.HEAPU8.slice(ans + 4, ans + 4 + length)); + var length = + Solver.HEAPU8[ans] | + (Solver.HEAPU8[ans + 1] << 8) | + (Solver.HEAPU8[ans + 2] << 16) | + (Solver.HEAPU8[ans + 3] << 24); + var resultStr = new TextDecoder().decode( + Solver.HEAPU8.slice(ans + 4, ans + 4 + length) + ); var result = JSON.parse(resultStr.substring(0, resultStr.length)); return result["description"]; } diff --git a/src/solver/SolverBridgeNoWorker.js b/src/solver/SolverBridgeNoWorker.js index 568ddb5c3..c8cdc808a 100644 --- a/src/solver/SolverBridgeNoWorker.js +++ b/src/solver/SolverBridgeNoWorker.js @@ -1,11 +1,10 @@ var Solver = null; -Module().then(function (mod) { +Module().then(function(mod) { Solver = mod; }); - -window.solveProblemAlt = function (url) { +window.solveProblemAlt = function(url) { var urlEncoded = new TextEncoder().encode(url); var buf = Solver._malloc(urlEncoded.length); Solver.HEAPU8.set(urlEncoded, buf); @@ -13,8 +12,14 @@ window.solveProblemAlt = function (url) { var ans = Solver._solve_problem(buf, urlEncoded.length); Solver._free(buf); - var length = Solver.HEAPU8[ans] | (Solver.HEAPU8[ans + 1] << 8) | (Solver.HEAPU8[ans + 2] << 16) | (Solver.HEAPU8[ans + 3] << 24); - var resultStr = new TextDecoder().decode(Solver.HEAPU8.slice(ans + 4, ans + 4 + length)); + var length = + Solver.HEAPU8[ans] | + (Solver.HEAPU8[ans + 1] << 8) | + (Solver.HEAPU8[ans + 2] << 16) | + (Solver.HEAPU8[ans + 3] << 24); + var resultStr = new TextDecoder().decode( + Solver.HEAPU8.slice(ans + 4, ans + 4 + length) + ); var result = JSON.parse(resultStr.substring(0, resultStr.length)); return result["description"]; -} +}; diff --git a/src/solver/cspuz_solver_backend.js b/src/solver/cspuz_solver_backend.js index 899ba5ac3..84d1d6493 100644 --- a/src/solver/cspuz_solver_backend.js +++ b/src/solver/cspuz_solver_backend.js @@ -4,1976 +4,2271 @@ // When targetting node and ES6 we use `await import ..` in the generated code // so the outer function needs to be marked as async. async function Module(moduleArg = {}) { - var moduleRtn; - -// include: shell.js -// include: minimum_runtime_check.js -(function() { - // "30.0.0" -> 300000 - function humanReadableVersionToPacked(str) { - str = str.split('-')[0]; // Remove any trailing part from e.g. "12.53.3-alpha" - var vers = str.split('.').slice(0, 3); - while(vers.length < 3) vers.push('00'); - vers = vers.map((n, i, arr) => n.padStart(2, '0')); - return vers.join(''); - } - // 300000 -> "30.0.0" - var packedVersionToHumanReadable = n => [n / 10000 | 0, (n / 100 | 0) % 100, n % 100].join('.'); - - var TARGET_NOT_SUPPORTED = 2147483647; - - var currentNodeVersion = typeof process !== 'undefined' && process?.versions?.node ? humanReadableVersionToPacked(process.versions.node) : TARGET_NOT_SUPPORTED; - if (currentNodeVersion < 160000) { - throw new Error(`This emscripten-generated code requires node v${ packedVersionToHumanReadable(160000) } (detected v${packedVersionToHumanReadable(currentNodeVersion)})`); - } - - var currentSafariVersion = typeof navigator !== 'undefined' && navigator?.userAgent?.includes("Safari/") && navigator.userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/) ? humanReadableVersionToPacked(navigator.userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/)[1]) : TARGET_NOT_SUPPORTED; - if (currentSafariVersion < 150000) { - throw new Error(`This emscripten-generated code requires Safari v${ packedVersionToHumanReadable(150000) } (detected v${currentSafariVersion})`); - } - - var currentFirefoxVersion = typeof navigator !== 'undefined' && navigator?.userAgent?.match(/Firefox\/(\d+(?:\.\d+)?)/) ? parseFloat(navigator.userAgent.match(/Firefox\/(\d+(?:\.\d+)?)/)[1]) : TARGET_NOT_SUPPORTED; - if (currentFirefoxVersion < 79) { - throw new Error(`This emscripten-generated code requires Firefox v79 (detected v${currentFirefoxVersion})`); - } - - var currentChromeVersion = typeof navigator !== 'undefined' && navigator?.userAgent?.match(/Chrome\/(\d+(?:\.\d+)?)/) ? parseFloat(navigator.userAgent.match(/Chrome\/(\d+(?:\.\d+)?)/)[1]) : TARGET_NOT_SUPPORTED; - if (currentChromeVersion < 85) { - throw new Error(`This emscripten-generated code requires Chrome v85 (detected v${currentChromeVersion})`); - } -})(); - -// end include: minimum_runtime_check.js -// The Module object: Our interface to the outside world. We import -// and export values on it. There are various ways Module can be used: -// 1. Not defined. We create it here -// 2. A function parameter, function(moduleArg) => Promise -// 3. pre-run appended it, var Module = {}; ..generated code.. -// 4. External script tag defines var Module. -// We need to check if Module already exists (e.g. case 3 above). -// Substitution will be replaced with actual code on later stage of the build, -// this way Closure Compiler will not mangle it (e.g. case 4. above). -// Note that if you want to run closure, and also to use Module -// after the generated code, you will need to define var Module = {}; -// before the code. Then that object will be used in the code, and you -// can continue to use Module afterwards as well. -var Module = moduleArg; - -// Determine the runtime environment we are in. You can customize this by -// setting the ENVIRONMENT setting at compile time (see settings.js). - -// Attempt to auto-detect the environment -var ENVIRONMENT_IS_WEB = !!globalThis.window; -var ENVIRONMENT_IS_WORKER = !!globalThis.WorkerGlobalScope; -// N.b. Electron.js environment is simultaneously a NODE-environment, but -// also a web environment. -var ENVIRONMENT_IS_NODE = globalThis.process?.versions?.node && globalThis.process?.type != 'renderer'; -var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER; - -if (ENVIRONMENT_IS_NODE) { - // When building an ES module `require` is not normally available. - // We need to use `createRequire()` to construct the require()` function. - const { createRequire } = await import('module'); - /** @suppress{duplicate} */ - var require = createRequire(import.meta.url); - -} - -// --pre-jses are emitted after the Module integration code, so that they can -// refer to Module (if they choose; they can also define Module) - - -var arguments_ = []; -var thisProgram = './this.program'; -var quit_ = (status, toThrow) => { - throw toThrow; -}; - -var _scriptName = import.meta.url; - -// `/` should be present at the end if `scriptDirectory` is not empty -var scriptDirectory = ''; -function locateFile(path) { - if (Module['locateFile']) { - return Module['locateFile'](path, scriptDirectory); - } - return scriptDirectory + path; -} - -// Hooks that are implemented differently in different runtime environments. -var readAsync, readBinary; - -if (ENVIRONMENT_IS_NODE) { - const isNode = globalThis.process?.versions?.node && globalThis.process?.type != 'renderer'; - if (!isNode) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)'); - - // These modules will usually be used on Node.js. Load them eagerly to avoid - // the complexity of lazy-loading. - var fs = require('fs'); - - if (_scriptName.startsWith('file:')) { - scriptDirectory = require('path').dirname(require('url').fileURLToPath(_scriptName)) + '/'; - } - -// include: node_shell_read.js -readBinary = (filename) => { - // We need to re-wrap `file://` strings to URLs. - filename = isFileURI(filename) ? new URL(filename) : filename; - var ret = fs.readFileSync(filename); - assert(Buffer.isBuffer(ret)); - return ret; -}; - -readAsync = async (filename, binary = true) => { - // See the comment in the `readBinary` function. - filename = isFileURI(filename) ? new URL(filename) : filename; - var ret = fs.readFileSync(filename, binary ? undefined : 'utf8'); - assert(binary ? Buffer.isBuffer(ret) : typeof ret == 'string'); - return ret; -}; -// end include: node_shell_read.js - if (process.argv.length > 1) { - thisProgram = process.argv[1].replace(/\\/g, '/'); - } - - arguments_ = process.argv.slice(2); - - quit_ = (status, toThrow) => { - process.exitCode = status; - throw toThrow; - }; - -} else -if (ENVIRONMENT_IS_SHELL) { - -} else - -// Note that this includes Node.js workers when relevant (pthreads is enabled). -// Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and -// ENVIRONMENT_IS_NODE. -if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { - try { - scriptDirectory = new URL('.', _scriptName).href; // includes trailing slash - } catch { - // Must be a `blob:` or `data:` URL (e.g. `blob:http://site.com/etc/etc`), we cannot - // infer anything from them. - } - - if (!(globalThis.window || globalThis.WorkerGlobalScope)) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)'); - - { -// include: web_or_worker_shell_read.js -if (ENVIRONMENT_IS_WORKER) { - readBinary = (url) => { - var xhr = new XMLHttpRequest(); - xhr.open('GET', url, false); - xhr.responseType = 'arraybuffer'; - xhr.send(null); - return new Uint8Array(/** @type{!ArrayBuffer} */(xhr.response)); - }; - } - - readAsync = async (url) => { - assert(!isFileURI(url), "readAsync does not work with file:// URLs"); - var response = await fetch(url, { credentials: 'same-origin' }); - if (response.ok) { - return response.arrayBuffer(); - } - throw new Error(response.status + ' : ' + response.url); - }; -// end include: web_or_worker_shell_read.js - } -} else -{ - throw new Error('environment detection error'); -} - -var out = console.log.bind(console); -var err = console.error.bind(console); - -var IDBFS = 'IDBFS is no longer included by default; build with -lidbfs.js'; -var PROXYFS = 'PROXYFS is no longer included by default; build with -lproxyfs.js'; -var WORKERFS = 'WORKERFS is no longer included by default; build with -lworkerfs.js'; -var FETCHFS = 'FETCHFS is no longer included by default; build with -lfetchfs.js'; -var ICASEFS = 'ICASEFS is no longer included by default; build with -licasefs.js'; -var JSFILEFS = 'JSFILEFS is no longer included by default; build with -ljsfilefs.js'; -var OPFS = 'OPFS is no longer included by default; build with -lopfs.js'; - -var NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js'; - -// perform assertions in shell.js after we set up out() and err(), as otherwise -// if an assertion fails it cannot print the message - -assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.'); - -// end include: shell.js - -// include: preamble.js -// === Preamble library stuff === - -// Documentation for the public APIs defined in this file must be updated in: -// site/source/docs/api_reference/preamble.js.rst -// A prebuilt local version of the documentation is available at: -// site/build/text/docs/api_reference/preamble.js.txt -// You can also build docs locally as HTML or other formats in site/ -// An online HTML version (which may be of a different version of Emscripten) -// is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html - -var wasmBinary; - -if (!globalThis.WebAssembly) { - err('no native wasm support detected'); -} - -// Wasm globals - -//======================================== -// Runtime essentials -//======================================== - -// whether we are quitting the application. no code should run after this. -// set in exit() and abort() -var ABORT = false; - -// set by exit() and abort(). Passed to 'onExit' handler. -// NOTE: This is also used as the process return code code in shell environments -// but only when noExitRuntime is false. -var EXITSTATUS; - -// In STRICT mode, we only define assert() when ASSERTIONS is set. i.e. we -// don't define it at all in release modes. This matches the behaviour of -// MINIMAL_RUNTIME. -// TODO(sbc): Make this the default even without STRICT enabled. -/** @type {function(*, string=)} */ -function assert(condition, text) { - if (!condition) { - abort('Assertion failed' + (text ? ': ' + text : '')); - } -} - -// We used to include malloc/free by default in the past. Show a helpful error in -// builds with assertions. - -/** - * Indicates whether filename is delivered via file protocol (as opposed to http/https) - * @noinline - */ -var isFileURI = (filename) => filename.startsWith('file://'); - -// include: runtime_common.js -// include: runtime_stack_check.js -// Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode. -function writeStackCookie() { - var max = _emscripten_stack_get_end(); - assert((max & 3) == 0); - // If the stack ends at address zero we write our cookies 4 bytes into the - // stack. This prevents interference with SAFE_HEAP and ASAN which also - // monitor writes to address zero. - if (max == 0) { - max += 4; - } - // The stack grow downwards towards _emscripten_stack_get_end. - // We write cookies to the final two words in the stack and detect if they are - // ever overwritten. - HEAPU32[((max)>>2)] = 0x02135467; - HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE; - // Also test the global address 0 for integrity. - HEAPU32[((0)>>2)] = 1668509029; -} - -function checkStackCookie() { - if (ABORT) return; - var max = _emscripten_stack_get_end(); - // See writeStackCookie(). - if (max == 0) { - max += 4; - } - var cookie1 = HEAPU32[((max)>>2)]; - var cookie2 = HEAPU32[(((max)+(4))>>2)]; - if (cookie1 != 0x02135467 || cookie2 != 0x89BACDFE) { - abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString(cookie2)} ${ptrToString(cookie1)}`); - } - // Also test the global address 0 for integrity. - if (HEAPU32[((0)>>2)] != 0x63736d65 /* 'emsc' */) { - abort('Runtime error: The application has corrupted its heap memory area (address zero)!'); - } -} -// end include: runtime_stack_check.js -// include: runtime_exceptions.js -// end include: runtime_exceptions.js -// include: runtime_debug.js -var runtimeDebug = true; // Switch to false at runtime to disable logging at the right times - -// Used by XXXXX_DEBUG settings to output debug messages. -function dbg(...args) { - if (!runtimeDebug && typeof runtimeDebug != 'undefined') return; - // TODO(sbc): Make this configurable somehow. Its not always convenient for - // logging to show up as warnings. - console.warn(...args); -} - -// Endianness check -(() => { - var h16 = new Int16Array(1); - var h8 = new Int8Array(h16.buffer); - h16[0] = 0x6373; - if (h8[0] !== 0x73 || h8[1] !== 0x63) abort('Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)'); -})(); - -function consumedModuleProp(prop) { - if (!Object.getOwnPropertyDescriptor(Module, prop)) { - Object.defineProperty(Module, prop, { - configurable: true, - set() { - abort(`Attempt to set \`Module.${prop}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`); - - } - }); - } -} - -function makeInvalidEarlyAccess(name) { - return () => assert(false, `call to '${name}' via reference taken before Wasm module initialization`); - -} - -function ignoredModuleProp(prop) { - if (Object.getOwnPropertyDescriptor(Module, prop)) { - abort(`\`Module.${prop}\` was supplied but \`${prop}\` not included in INCOMING_MODULE_JS_API`); - } -} - -// forcing the filesystem exports a few things by default -function isExportedByForceFilesystem(name) { - return name === 'FS_createPath' || - name === 'FS_createDataFile' || - name === 'FS_createPreloadedFile' || - name === 'FS_preloadFile' || - name === 'FS_unlink' || - name === 'addRunDependency' || - // The old FS has some functionality that WasmFS lacks. - name === 'FS_createLazyFile' || - name === 'FS_createDevice' || - name === 'removeRunDependency'; -} - -function missingLibrarySymbol(sym) { - - // Any symbol that is not included from the JS library is also (by definition) - // not exported on the Module object. - unexportedRuntimeSymbol(sym); -} - -function unexportedRuntimeSymbol(sym) { - if (!Object.getOwnPropertyDescriptor(Module, sym)) { - Object.defineProperty(Module, sym, { - configurable: true, - get() { - var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`; - if (isExportedByForceFilesystem(sym)) { - msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you'; - } - abort(msg); - }, - }); - } -} - -// end include: runtime_debug.js -var readyPromiseResolve, readyPromiseReject; - -// Memory management -var -/** @type {!Int8Array} */ - HEAP8, -/** @type {!Uint8Array} */ - HEAPU8, -/** @type {!Int16Array} */ - HEAP16, -/** @type {!Uint16Array} */ - HEAPU16, -/** @type {!Int32Array} */ - HEAP32, -/** @type {!Uint32Array} */ - HEAPU32, -/** @type {!Float32Array} */ - HEAPF32, -/** @type {!Float64Array} */ - HEAPF64; - -// BigInt64Array type is not correctly defined in closure -var -/** not-@type {!BigInt64Array} */ - HEAP64, -/* BigUint64Array type is not correctly defined in closure + var moduleRtn; + + // include: shell.js + // include: minimum_runtime_check.js + (function() { + // "30.0.0" -> 300000 + function humanReadableVersionToPacked(str) { + str = str.split("-")[0]; // Remove any trailing part from e.g. "12.53.3-alpha" + var vers = str.split(".").slice(0, 3); + while (vers.length < 3) vers.push("00"); + vers = vers.map((n, i, arr) => n.padStart(2, "0")); + return vers.join(""); + } + // 300000 -> "30.0.0" + var packedVersionToHumanReadable = n => + [(n / 10000) | 0, ((n / 100) | 0) % 100, n % 100].join("."); + + var TARGET_NOT_SUPPORTED = 2147483647; + + var currentNodeVersion = + typeof process !== "undefined" && process?.versions?.node + ? humanReadableVersionToPacked(process.versions.node) + : TARGET_NOT_SUPPORTED; + if (currentNodeVersion < 160000) { + throw new Error( + `This emscripten-generated code requires node v${packedVersionToHumanReadable( + 160000 + )} (detected v${packedVersionToHumanReadable(currentNodeVersion)})` + ); + } + + var currentSafariVersion = + typeof navigator !== "undefined" && + navigator?.userAgent?.includes("Safari/") && + navigator.userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/) + ? humanReadableVersionToPacked( + navigator.userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/)[1] + ) + : TARGET_NOT_SUPPORTED; + if (currentSafariVersion < 150000) { + throw new Error( + `This emscripten-generated code requires Safari v${packedVersionToHumanReadable( + 150000 + )} (detected v${currentSafariVersion})` + ); + } + + var currentFirefoxVersion = + typeof navigator !== "undefined" && + navigator?.userAgent?.match(/Firefox\/(\d+(?:\.\d+)?)/) + ? parseFloat(navigator.userAgent.match(/Firefox\/(\d+(?:\.\d+)?)/)[1]) + : TARGET_NOT_SUPPORTED; + if (currentFirefoxVersion < 79) { + throw new Error( + `This emscripten-generated code requires Firefox v79 (detected v${currentFirefoxVersion})` + ); + } + + var currentChromeVersion = + typeof navigator !== "undefined" && + navigator?.userAgent?.match(/Chrome\/(\d+(?:\.\d+)?)/) + ? parseFloat(navigator.userAgent.match(/Chrome\/(\d+(?:\.\d+)?)/)[1]) + : TARGET_NOT_SUPPORTED; + if (currentChromeVersion < 85) { + throw new Error( + `This emscripten-generated code requires Chrome v85 (detected v${currentChromeVersion})` + ); + } + })(); + + // end include: minimum_runtime_check.js + // The Module object: Our interface to the outside world. We import + // and export values on it. There are various ways Module can be used: + // 1. Not defined. We create it here + // 2. A function parameter, function(moduleArg) => Promise + // 3. pre-run appended it, var Module = {}; ..generated code.. + // 4. External script tag defines var Module. + // We need to check if Module already exists (e.g. case 3 above). + // Substitution will be replaced with actual code on later stage of the build, + // this way Closure Compiler will not mangle it (e.g. case 4. above). + // Note that if you want to run closure, and also to use Module + // after the generated code, you will need to define var Module = {}; + // before the code. Then that object will be used in the code, and you + // can continue to use Module afterwards as well. + var Module = moduleArg; + + // Determine the runtime environment we are in. You can customize this by + // setting the ENVIRONMENT setting at compile time (see settings.js). + + // Attempt to auto-detect the environment + var ENVIRONMENT_IS_WEB = !!globalThis.window; + var ENVIRONMENT_IS_WORKER = !!globalThis.WorkerGlobalScope; + // N.b. Electron.js environment is simultaneously a NODE-environment, but + // also a web environment. + var ENVIRONMENT_IS_NODE = + globalThis.process?.versions?.node && + globalThis.process?.type != "renderer"; + var ENVIRONMENT_IS_SHELL = + !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER; + + if (ENVIRONMENT_IS_NODE) { + // When building an ES module `require` is not normally available. + // We need to use `createRequire()` to construct the require()` function. + const { createRequire } = await import("module"); + /** @suppress{duplicate} */ + var require = createRequire(import.meta.url); + } + + // --pre-jses are emitted after the Module integration code, so that they can + // refer to Module (if they choose; they can also define Module) + + var arguments_ = []; + var thisProgram = "./this.program"; + var quit_ = (status, toThrow) => { + throw toThrow; + }; + + var _scriptName = import.meta.url; + + // `/` should be present at the end if `scriptDirectory` is not empty + var scriptDirectory = ""; + function locateFile(path) { + if (Module["locateFile"]) { + return Module["locateFile"](path, scriptDirectory); + } + return scriptDirectory + path; + } + + // Hooks that are implemented differently in different runtime environments. + var readAsync, readBinary; + + if (ENVIRONMENT_IS_NODE) { + const isNode = + globalThis.process?.versions?.node && + globalThis.process?.type != "renderer"; + if (!isNode) + throw new Error( + "not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)" + ); + + // These modules will usually be used on Node.js. Load them eagerly to avoid + // the complexity of lazy-loading. + var fs = require("fs"); + + if (_scriptName.startsWith("file:")) { + scriptDirectory = + require("path").dirname(require("url").fileURLToPath(_scriptName)) + + "/"; + } + + // include: node_shell_read.js + readBinary = filename => { + // We need to re-wrap `file://` strings to URLs. + filename = isFileURI(filename) ? new URL(filename) : filename; + var ret = fs.readFileSync(filename); + assert(Buffer.isBuffer(ret)); + return ret; + }; + + readAsync = async (filename, binary = true) => { + // See the comment in the `readBinary` function. + filename = isFileURI(filename) ? new URL(filename) : filename; + var ret = fs.readFileSync(filename, binary ? undefined : "utf8"); + assert(binary ? Buffer.isBuffer(ret) : typeof ret == "string"); + return ret; + }; + // end include: node_shell_read.js + if (process.argv.length > 1) { + thisProgram = process.argv[1].replace(/\\/g, "/"); + } + + arguments_ = process.argv.slice(2); + + quit_ = (status, toThrow) => { + process.exitCode = status; + throw toThrow; + }; + } else if (ENVIRONMENT_IS_SHELL) { + } + + // Note that this includes Node.js workers when relevant (pthreads is enabled). + // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and + // ENVIRONMENT_IS_NODE. + else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { + try { + scriptDirectory = new URL(".", _scriptName).href; // includes trailing slash + } catch { + // Must be a `blob:` or `data:` URL (e.g. `blob:http://site.com/etc/etc`), we cannot + // infer anything from them. + } + + if (!(globalThis.window || globalThis.WorkerGlobalScope)) + throw new Error( + "not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)" + ); + + { + // include: web_or_worker_shell_read.js + if (ENVIRONMENT_IS_WORKER) { + readBinary = url => { + var xhr = new XMLHttpRequest(); + xhr.open("GET", url, false); + xhr.responseType = "arraybuffer"; + xhr.send(null); + return new Uint8Array(/** @type{!ArrayBuffer} */ (xhr.response)); + }; + } + + readAsync = async url => { + assert(!isFileURI(url), "readAsync does not work with file:// URLs"); + var response = await fetch(url, { credentials: "same-origin" }); + if (response.ok) { + return response.arrayBuffer(); + } + throw new Error(response.status + " : " + response.url); + }; + // end include: web_or_worker_shell_read.js + } + } else { + throw new Error("environment detection error"); + } + + var out = console.log.bind(console); + var err = console.error.bind(console); + + var IDBFS = "IDBFS is no longer included by default; build with -lidbfs.js"; + var PROXYFS = + "PROXYFS is no longer included by default; build with -lproxyfs.js"; + var WORKERFS = + "WORKERFS is no longer included by default; build with -lworkerfs.js"; + var FETCHFS = + "FETCHFS is no longer included by default; build with -lfetchfs.js"; + var ICASEFS = + "ICASEFS is no longer included by default; build with -licasefs.js"; + var JSFILEFS = + "JSFILEFS is no longer included by default; build with -ljsfilefs.js"; + var OPFS = "OPFS is no longer included by default; build with -lopfs.js"; + + var NODEFS = + "NODEFS is no longer included by default; build with -lnodefs.js"; + + // perform assertions in shell.js after we set up out() and err(), as otherwise + // if an assertion fails it cannot print the message + + assert( + !ENVIRONMENT_IS_SHELL, + "shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable." + ); + + // end include: shell.js + + // include: preamble.js + // === Preamble library stuff === + + // Documentation for the public APIs defined in this file must be updated in: + // site/source/docs/api_reference/preamble.js.rst + // A prebuilt local version of the documentation is available at: + // site/build/text/docs/api_reference/preamble.js.txt + // You can also build docs locally as HTML or other formats in site/ + // An online HTML version (which may be of a different version of Emscripten) + // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html + + var wasmBinary; + + if (!globalThis.WebAssembly) { + err("no native wasm support detected"); + } + + // Wasm globals + + //======================================== + // Runtime essentials + //======================================== + + // whether we are quitting the application. no code should run after this. + // set in exit() and abort() + var ABORT = false; + + // set by exit() and abort(). Passed to 'onExit' handler. + // NOTE: This is also used as the process return code code in shell environments + // but only when noExitRuntime is false. + var EXITSTATUS; + + // In STRICT mode, we only define assert() when ASSERTIONS is set. i.e. we + // don't define it at all in release modes. This matches the behaviour of + // MINIMAL_RUNTIME. + // TODO(sbc): Make this the default even without STRICT enabled. + /** @type {function(*, string=)} */ + function assert(condition, text) { + if (!condition) { + abort("Assertion failed" + (text ? ": " + text : "")); + } + } + + // We used to include malloc/free by default in the past. Show a helpful error in + // builds with assertions. + + /** + * Indicates whether filename is delivered via file protocol (as opposed to http/https) + * @noinline + */ + var isFileURI = filename => filename.startsWith("file://"); + + // include: runtime_common.js + // include: runtime_stack_check.js + // Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode. + function writeStackCookie() { + var max = _emscripten_stack_get_end(); + assert((max & 3) == 0); + // If the stack ends at address zero we write our cookies 4 bytes into the + // stack. This prevents interference with SAFE_HEAP and ASAN which also + // monitor writes to address zero. + if (max == 0) { + max += 4; + } + // The stack grow downwards towards _emscripten_stack_get_end. + // We write cookies to the final two words in the stack and detect if they are + // ever overwritten. + HEAPU32[max >> 2] = 0x02135467; + HEAPU32[(max + 4) >> 2] = 0x89bacdfe; + // Also test the global address 0 for integrity. + HEAPU32[0 >> 2] = 1668509029; + } + + function checkStackCookie() { + if (ABORT) return; + var max = _emscripten_stack_get_end(); + // See writeStackCookie(). + if (max == 0) { + max += 4; + } + var cookie1 = HEAPU32[max >> 2]; + var cookie2 = HEAPU32[(max + 4) >> 2]; + if (cookie1 != 0x02135467 || cookie2 != 0x89bacdfe) { + abort( + `Stack overflow! Stack cookie has been overwritten at ${ptrToString( + max + )}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString( + cookie2 + )} ${ptrToString(cookie1)}` + ); + } + // Also test the global address 0 for integrity. + if (HEAPU32[0 >> 2] != 0x63736d65 /* 'emsc' */) { + abort( + "Runtime error: The application has corrupted its heap memory area (address zero)!" + ); + } + } + // end include: runtime_stack_check.js + // include: runtime_exceptions.js + // end include: runtime_exceptions.js + // include: runtime_debug.js + var runtimeDebug = true; // Switch to false at runtime to disable logging at the right times + + // Used by XXXXX_DEBUG settings to output debug messages. + function dbg(...args) { + if (!runtimeDebug && typeof runtimeDebug != "undefined") return; + // TODO(sbc): Make this configurable somehow. Its not always convenient for + // logging to show up as warnings. + console.warn(...args); + } + + // Endianness check + (() => { + var h16 = new Int16Array(1); + var h8 = new Int8Array(h16.buffer); + h16[0] = 0x6373; + if (h8[0] !== 0x73 || h8[1] !== 0x63) + abort( + "Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)" + ); + })(); + + function consumedModuleProp(prop) { + if (!Object.getOwnPropertyDescriptor(Module, prop)) { + Object.defineProperty(Module, prop, { + configurable: true, + set() { + abort( + `Attempt to set \`Module.${prop}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'` + ); + } + }); + } + } + + function makeInvalidEarlyAccess(name) { + return () => + assert( + false, + `call to '${name}' via reference taken before Wasm module initialization` + ); + } + + function ignoredModuleProp(prop) { + if (Object.getOwnPropertyDescriptor(Module, prop)) { + abort( + `\`Module.${prop}\` was supplied but \`${prop}\` not included in INCOMING_MODULE_JS_API` + ); + } + } + + // forcing the filesystem exports a few things by default + function isExportedByForceFilesystem(name) { + return ( + name === "FS_createPath" || + name === "FS_createDataFile" || + name === "FS_createPreloadedFile" || + name === "FS_preloadFile" || + name === "FS_unlink" || + name === "addRunDependency" || + // The old FS has some functionality that WasmFS lacks. + name === "FS_createLazyFile" || + name === "FS_createDevice" || + name === "removeRunDependency" + ); + } + + function missingLibrarySymbol(sym) { + // Any symbol that is not included from the JS library is also (by definition) + // not exported on the Module object. + unexportedRuntimeSymbol(sym); + } + + function unexportedRuntimeSymbol(sym) { + if (!Object.getOwnPropertyDescriptor(Module, sym)) { + Object.defineProperty(Module, sym, { + configurable: true, + get() { + var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`; + if (isExportedByForceFilesystem(sym)) { + msg += + ". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"; + } + abort(msg); + } + }); + } + } + + // end include: runtime_debug.js + var readyPromiseResolve, readyPromiseReject; + + // Memory management + var /** @type {!Int8Array} */ + HEAP8, + /** @type {!Uint8Array} */ + HEAPU8, + /** @type {!Int16Array} */ + HEAP16, + /** @type {!Uint16Array} */ + HEAPU16, + /** @type {!Int32Array} */ + HEAP32, + /** @type {!Uint32Array} */ + HEAPU32, + /** @type {!Float32Array} */ + HEAPF32, + /** @type {!Float64Array} */ + HEAPF64; + + // BigInt64Array type is not correctly defined in closure + var /** not-@type {!BigInt64Array} */ + HEAP64, + /* BigUint64Array type is not correctly defined in closure /** not-@type {!BigUint64Array} */ - HEAPU64; - -var runtimeInitialized = false; - - - -function updateMemoryViews() { - var b = wasmMemory.buffer; - HEAP8 = new Int8Array(b); - HEAP16 = new Int16Array(b); - Module['HEAPU8'] = HEAPU8 = new Uint8Array(b); - HEAPU16 = new Uint16Array(b); - HEAP32 = new Int32Array(b); - HEAPU32 = new Uint32Array(b); - HEAPF32 = new Float32Array(b); - HEAPF64 = new Float64Array(b); - HEAP64 = new BigInt64Array(b); - HEAPU64 = new BigUint64Array(b); -} - -// include: memoryprofiler.js -// end include: memoryprofiler.js -// end include: runtime_common.js -assert(globalThis.Int32Array && globalThis.Float64Array && Int32Array.prototype.subarray && Int32Array.prototype.set, - 'JS engine does not provide full typed array support'); - -function preRun() { - if (Module['preRun']) { - if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']]; - while (Module['preRun'].length) { - addOnPreRun(Module['preRun'].shift()); - } - } - consumedModuleProp('preRun'); - // Begin ATPRERUNS hooks - callRuntimeCallbacks(onPreRuns); - // End ATPRERUNS hooks -} - -function initRuntime() { - assert(!runtimeInitialized); - runtimeInitialized = true; - - checkStackCookie(); - - // No ATINITS hooks - - wasmExports['__wasm_call_ctors'](); - - // No ATPOSTCTORS hooks -} - -function postRun() { - checkStackCookie(); - // PThreads reuse the runtime from the main thread. - - if (Module['postRun']) { - if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']]; - while (Module['postRun'].length) { - addOnPostRun(Module['postRun'].shift()); - } - } - consumedModuleProp('postRun'); - - // Begin ATPOSTRUNS hooks - callRuntimeCallbacks(onPostRuns); - // End ATPOSTRUNS hooks -} - -/** @param {string|number=} what */ -function abort(what) { - Module['onAbort']?.(what); - - what = 'Aborted(' + what + ')'; - // TODO(sbc): Should we remove printing and leave it up to whoever - // catches the exception? - err(what); - - ABORT = true; - - // Use a wasm runtime error, because a JS error might be seen as a foreign - // exception, which means we'd run destructors on it. We need the error to - // simply make the program stop. - // FIXME This approach does not work in Wasm EH because it currently does not assume - // all RuntimeErrors are from traps; it decides whether a RuntimeError is from - // a trap or not based on a hidden field within the object. So at the moment - // we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that - // allows this in the wasm spec. - - // Suppress closure compiler warning here. Closure compiler's builtin extern - // definition for WebAssembly.RuntimeError claims it takes no arguments even - // though it can. - // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed. - /** @suppress {checkTypes} */ - var e = new WebAssembly.RuntimeError(what); - - readyPromiseReject?.(e); - // Throw the error whether or not MODULARIZE is set because abort is used - // in code paths apart from instantiation where an exception is expected - // to be thrown when abort is called. - throw e; -} - -// show errors on likely calls to FS when it was not included -var FS = { - error() { - abort('Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM'); - }, - init() { FS.error() }, - createDataFile() { FS.error() }, - createPreloadedFile() { FS.error() }, - createLazyFile() { FS.error() }, - open() { FS.error() }, - mkdev() { FS.error() }, - registerDevice() { FS.error() }, - analyzePath() { FS.error() }, - - ErrnoError() { FS.error() }, -}; - - -function createExportWrapper(name, nargs) { - return (...args) => { - assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`); - var f = wasmExports[name]; - assert(f, `exported native function \`${name}\` not found`); - // Only assert for too many arguments. Too few can be valid since the missing arguments will be zero filled. - assert(args.length <= nargs, `native function \`${name}\` called with ${args.length} args but expects ${nargs}`); - return f(...args); - }; -} - -var wasmBinaryFile; - -function findWasmBinary() { - - if (Module['locateFile']) { - return locateFile('cspuz_solver_backend.wasm'); - } - - // Use bundler-friendly `new URL(..., import.meta.url)` pattern; works in browsers too. - return new URL('cspuz_solver_backend.wasm', import.meta.url).href; - -} - -function getBinarySync(file) { - if (file == wasmBinaryFile && wasmBinary) { - return new Uint8Array(wasmBinary); - } - if (readBinary) { - return readBinary(file); - } - // Throwing a plain string here, even though it not normally adviables since - // this gets turning into an `abort` in instantiateArrayBuffer. - throw 'both async and sync fetching of the wasm failed'; -} - -async function getWasmBinary(binaryFile) { - // If we don't have the binary yet, load it asynchronously using readAsync. - if (!wasmBinary) { - // Fetch the binary using readAsync - try { - var response = await readAsync(binaryFile); - return new Uint8Array(response); - } catch { - // Fall back to getBinarySync below; - } - } - - // Otherwise, getBinarySync should be able to get it synchronously - return getBinarySync(binaryFile); -} - -async function instantiateArrayBuffer(binaryFile, imports) { - try { - var binary = await getWasmBinary(binaryFile); - var instance = await WebAssembly.instantiate(binary, imports); - return instance; - } catch (reason) { - err(`failed to asynchronously prepare wasm: ${reason}`); - - // Warn on some common problems. - if (isFileURI(binaryFile)) { - err(`warning: Loading from a file URI (${binaryFile}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`); - } - abort(reason); - } -} - -async function instantiateAsync(binary, binaryFile, imports) { - if (!binary - // Avoid instantiateStreaming() on Node.js environment for now, as while - // Node.js v18.1.0 implements it, it does not have a full fetch() - // implementation yet. - // - // Reference: - // https://github.com/emscripten-core/emscripten/pull/16917 - && !ENVIRONMENT_IS_NODE - ) { - try { - var response = fetch(binaryFile, { credentials: 'same-origin' }); - var instantiationResult = await WebAssembly.instantiateStreaming(response, imports); - return instantiationResult; - } catch (reason) { - // We expect the most common failure cause to be a bad MIME type for the binary, - // in which case falling back to ArrayBuffer instantiation should work. - err(`wasm streaming compile failed: ${reason}`); - err('falling back to ArrayBuffer instantiation'); - // fall back of instantiateArrayBuffer below - }; - } - return instantiateArrayBuffer(binaryFile, imports); -} - -function getWasmImports() { - // prepare imports - var imports = { - 'env': wasmImports, - 'wasi_snapshot_preview1': wasmImports, - }; - return imports; -} - -// Create the wasm instance. -// Receives the wasm imports, returns the exports. -async function createWasm() { - // Load the wasm module and create an instance of using native support in the JS engine. - // handle a generated wasm instance, receiving its exports and - // performing other necessary setup - /** @param {WebAssembly.Module=} module*/ - function receiveInstance(instance, module) { - wasmExports = instance.exports; - - assignWasmExports(wasmExports); - - updateMemoryViews(); - - return wasmExports; - } - - // Prefer streaming instantiation if available. - // Async compilation can be confusing when an error on the page overwrites Module - // (for example, if the order of elements is wrong, and the one defining Module is - // later), so we save Module and check it later. - var trueModule = Module; - function receiveInstantiationResult(result) { - // 'result' is a ResultObject object which has both the module and instance. - // receiveInstance() will swap in the exports (to Module.asm) so they can be called - assert(Module === trueModule, 'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?'); - trueModule = null; - // TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193, the above line no longer optimizes out down to the following line. - // When the regression is fixed, can restore the above PTHREADS-enabled path. - return receiveInstance(result['instance']); - } - - var info = getWasmImports(); - - // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback - // to manually instantiate the Wasm module themselves. This allows pages to - // run the instantiation parallel to any other async startup actions they are - // performing. - // Also pthreads and wasm workers initialize the wasm instance through this - // path. - if (Module['instantiateWasm']) { - return new Promise((resolve, reject) => { - try { - Module['instantiateWasm'](info, (inst, mod) => { - resolve(receiveInstance(inst, mod)); - }); - } catch(e) { - err(`Module.instantiateWasm callback failed with error: ${e}`); - reject(e); - } - }); - } - - wasmBinaryFile ??= findWasmBinary(); - var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info); - var exports = receiveInstantiationResult(result); - return exports; -} - -// end include: preamble.js - -// Begin JS library code - - - class ExitStatus { - name = 'ExitStatus'; - constructor(status) { - this.message = `Program terminated with exit(${status})`; - this.status = status; - } - } - - var callRuntimeCallbacks = (callbacks) => { - while (callbacks.length > 0) { - // Pass the module as the first argument. - callbacks.shift()(Module); - } - }; - var onPostRuns = []; - var addOnPostRun = (cb) => onPostRuns.push(cb); - - var onPreRuns = []; - var addOnPreRun = (cb) => onPreRuns.push(cb); - - - - /** - * @param {number} ptr - * @param {string} type - */ - function getValue(ptr, type = 'i8') { - if (type.endsWith('*')) type = '*'; - switch (type) { - case 'i1': return HEAP8[ptr]; - case 'i8': return HEAP8[ptr]; - case 'i16': return HEAP16[((ptr)>>1)]; - case 'i32': return HEAP32[((ptr)>>2)]; - case 'i64': return HEAP64[((ptr)>>3)]; - case 'float': return HEAPF32[((ptr)>>2)]; - case 'double': return HEAPF64[((ptr)>>3)]; - case '*': return HEAPU32[((ptr)>>2)]; - default: abort(`invalid type for getValue: ${type}`); - } - } - - var noExitRuntime = true; - - var ptrToString = (ptr) => { - assert(typeof ptr === 'number', `ptrToString expects a number, got ${typeof ptr}`); - // Convert to 32-bit unsigned value - ptr >>>= 0; - return '0x' + ptr.toString(16).padStart(8, '0'); - }; - - - /** - * @param {number} ptr - * @param {number} value - * @param {string} type - */ - function setValue(ptr, value, type = 'i8') { - if (type.endsWith('*')) type = '*'; - switch (type) { - case 'i1': HEAP8[ptr] = value; break; - case 'i8': HEAP8[ptr] = value; break; - case 'i16': HEAP16[((ptr)>>1)] = value; break; - case 'i32': HEAP32[((ptr)>>2)] = value; break; - case 'i64': HEAP64[((ptr)>>3)] = BigInt(value); break; - case 'float': HEAPF32[((ptr)>>2)] = value; break; - case 'double': HEAPF64[((ptr)>>3)] = value; break; - case '*': HEAPU32[((ptr)>>2)] = value; break; - default: abort(`invalid type for setValue: ${type}`); - } - } - - var stackRestore = (val) => __emscripten_stack_restore(val); - - var stackSave = () => _emscripten_stack_get_current(); - - var warnOnce = (text) => { - warnOnce.shown ||= {}; - if (!warnOnce.shown[text]) { - warnOnce.shown[text] = 1; - if (ENVIRONMENT_IS_NODE) text = 'warning: ' + text; - err(text); - } - }; - - - - var UTF8Decoder = globalThis.TextDecoder && new TextDecoder(); - - var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => { - var maxIdx = idx + maxBytesToRead; - if (ignoreNul) return maxIdx; - // TextDecoder needs to know the byte length in advance, it doesn't stop on - // null terminator by itself. - // As a tiny code save trick, compare idx against maxIdx using a negation, - // so that maxBytesToRead=undefined/NaN means Infinity. - while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx; - return idx; - }; - - - /** - * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given - * array that contains uint8 values, returns a copy of that string as a - * Javascript String object. - * heapOrArray is either a regular array, or a JavaScript typed array view. - * @param {number=} idx - * @param {number=} maxBytesToRead - * @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character. - * @return {string} - */ - var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead, ignoreNul) => { - - var endPtr = findStringEnd(heapOrArray, idx, maxBytesToRead, ignoreNul); - - // When using conditional TextDecoder, skip it for short strings as the overhead of the native call is not worth it. - if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) { - return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr)); - } - var str = ''; - while (idx < endPtr) { - // For UTF8 byte structure, see: - // http://en.wikipedia.org/wiki/UTF-8#Description - // https://www.ietf.org/rfc/rfc2279.txt - // https://tools.ietf.org/html/rfc3629 - var u0 = heapOrArray[idx++]; - if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; } - var u1 = heapOrArray[idx++] & 63; - if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; } - var u2 = heapOrArray[idx++] & 63; - if ((u0 & 0xF0) == 0xE0) { - u0 = ((u0 & 15) << 12) | (u1 << 6) | u2; - } else { - if ((u0 & 0xF8) != 0xF0) warnOnce('Invalid UTF-8 leading byte ' + ptrToString(u0) + ' encountered when deserializing a UTF-8 string in wasm memory to a JS string!'); - u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63); - } - - if (u0 < 0x10000) { - str += String.fromCharCode(u0); - } else { - var ch = u0 - 0x10000; - str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF)); - } - } - return str; - }; - - /** - * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the - * emscripten HEAP, returns a copy of that string as a Javascript String object. - * - * @param {number} ptr - * @param {number=} maxBytesToRead - An optional length that specifies the - * maximum number of bytes to read. You can omit this parameter to scan the - * string until the first 0 byte. If maxBytesToRead is passed, and the string - * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the - * string will cut short at that byte index. - * @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character. - * @return {string} - */ - var UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => { - assert(typeof ptr == 'number', `UTF8ToString expects a number (got ${typeof ptr})`); - return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead, ignoreNul) : ''; - }; - var ___assert_fail = (condition, filename, line, func) => - abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']); - - var exceptionLast = 0; - - class ExceptionInfo { - // excPtr - Thrown object pointer to wrap. Metadata pointer is calculated from it. - constructor(excPtr) { - this.excPtr = excPtr; - this.ptr = excPtr - 24; - } - - set_type(type) { - HEAPU32[(((this.ptr)+(4))>>2)] = type; - } - - get_type() { - return HEAPU32[(((this.ptr)+(4))>>2)]; - } - - set_destructor(destructor) { - HEAPU32[(((this.ptr)+(8))>>2)] = destructor; - } - - get_destructor() { - return HEAPU32[(((this.ptr)+(8))>>2)]; - } - - set_caught(caught) { - caught = caught ? 1 : 0; - HEAP8[(this.ptr)+(12)] = caught; - } - - get_caught() { - return HEAP8[(this.ptr)+(12)] != 0; - } - - set_rethrown(rethrown) { - rethrown = rethrown ? 1 : 0; - HEAP8[(this.ptr)+(13)] = rethrown; - } - - get_rethrown() { - return HEAP8[(this.ptr)+(13)] != 0; - } - - // Initialize native structure fields. Should be called once after allocated. - init(type, destructor) { - this.set_adjusted_ptr(0); - this.set_type(type); - this.set_destructor(destructor); - } - - set_adjusted_ptr(adjustedPtr) { - HEAPU32[(((this.ptr)+(16))>>2)] = adjustedPtr; - } - - get_adjusted_ptr() { - return HEAPU32[(((this.ptr)+(16))>>2)]; - } - } - - - var setTempRet0 = (val) => __emscripten_tempret_set(val); - var findMatchingCatch = (args) => { - var thrown = - exceptionLast; - if (!thrown) { - // just pass through the null ptr - setTempRet0(0); - return 0; - } - var info = new ExceptionInfo(thrown); - info.set_adjusted_ptr(thrown); - var thrownType = info.get_type(); - if (!thrownType) { - // just pass through the thrown ptr - setTempRet0(0); - return thrown; - } - - // can_catch receives a **, add indirection - // The different catch blocks are denoted by different types. - // Due to inheritance, those types may not precisely match the - // type of the thrown object. Find one which matches, and - // return the type of the catch block which should be called. - for (var caughtType of args) { - if (caughtType === 0 || caughtType === thrownType) { - // Catch all clause matched or exactly the same type is caught - break; - } - var adjusted_ptr_addr = info.ptr + 16; - if (___cxa_can_catch(caughtType, thrownType, adjusted_ptr_addr)) { - setTempRet0(caughtType); - return thrown; - } - } - setTempRet0(thrownType); - return thrown; - }; - var ___cxa_find_matching_catch_2 = () => findMatchingCatch([]); - - var ___resumeException = (ptr) => { - if (!exceptionLast) { - exceptionLast = ptr; - } - assert(false, 'Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.'); - }; - - var SYSCALLS = { - varargs:undefined, - getStr(ptr) { - var ret = UTF8ToString(ptr); - return ret; - }, - }; - var ___syscall_getcwd = (buf, size) => { - abort('it should not be possible to operate on streams when !SYSCALLS_REQUIRE_FILESYSTEM'); - }; - - var __abort_js = () => - abort('native code called abort()'); - - var _emscripten_get_now = () => performance.now(); - - var _emscripten_date_now = () => Date.now(); - - var nowIsMonotonic = 1; - - var checkWasiClock = (clock_id) => clock_id >= 0 && clock_id <= 3; - - var INT53_MAX = 9007199254740992; - - var INT53_MIN = -9007199254740992; - var bigintToI53Checked = (num) => (num < INT53_MIN || num > INT53_MAX) ? NaN : Number(num); - function _clock_time_get(clk_id, ignored_precision, ptime) { - ignored_precision = bigintToI53Checked(ignored_precision); - - - if (!checkWasiClock(clk_id)) { - return 28; - } - var now; - // all wasi clocks but realtime are monotonic - if (clk_id === 0) { - now = _emscripten_date_now(); - } else if (nowIsMonotonic) { - now = _emscripten_get_now(); - } else { - return 52; - } - // "now" is in ms, and wasi times are in ns. - var nsec = Math.round(now * 1000 * 1000); - HEAP64[((ptime)>>3)] = BigInt(nsec); - return 0; - ; - } - - var getHeapMax = () => - // Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate - // full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side - // for any code that deals with heap sizes, which would require special - // casing all heap size related code to treat 0 specially. - 2147483648; - - var alignMemory = (size, alignment) => { - assert(alignment, "alignment argument is required"); - return Math.ceil(size / alignment) * alignment; - }; - - var growMemory = (size) => { - var oldHeapSize = wasmMemory.buffer.byteLength; - var pages = ((size - oldHeapSize + 65535) / 65536) | 0; - try { - // round size grow request up to wasm page size (fixed 64KB per spec) - wasmMemory.grow(pages); // .grow() takes a delta compared to the previous size - updateMemoryViews(); - return 1 /*success*/; - } catch(e) { - err(`growMemory: Attempted to grow heap from ${oldHeapSize} bytes to ${size} bytes, but got error: ${e}`); - } - // implicit 0 return to save code size (caller will cast "undefined" into 0 - // anyhow) - }; - var _emscripten_resize_heap = (requestedSize) => { - var oldSize = HEAPU8.length; - // With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned. - requestedSize >>>= 0; - // With multithreaded builds, races can happen (another thread might increase the size - // in between), so return a failure, and let the caller retry. - assert(requestedSize > oldSize); - - // Memory resize rules: - // 1. Always increase heap size to at least the requested size, rounded up - // to next page multiple. - // 2a. If MEMORY_GROWTH_LINEAR_STEP == -1, excessively resize the heap - // geometrically: increase the heap size according to - // MEMORY_GROWTH_GEOMETRIC_STEP factor (default +20%), At most - // overreserve by MEMORY_GROWTH_GEOMETRIC_CAP bytes (default 96MB). - // 2b. If MEMORY_GROWTH_LINEAR_STEP != -1, excessively resize the heap - // linearly: increase the heap size by at least - // MEMORY_GROWTH_LINEAR_STEP bytes. - // 3. Max size for the heap is capped at 2048MB-WASM_PAGE_SIZE, or by - // MAXIMUM_MEMORY, or by ASAN limit, depending on which is smallest - // 4. If we were unable to allocate as much memory, it may be due to - // over-eager decision to excessively reserve due to (3) above. - // Hence if an allocation fails, cut down on the amount of excess - // growth, in an attempt to succeed to perform a smaller allocation. - - // A limit is set for how much we can grow. We should not exceed that - // (the wasm binary specifies it, so if we tried, we'd fail anyhow). - var maxHeapSize = getHeapMax(); - if (requestedSize > maxHeapSize) { - err(`Cannot enlarge memory, requested ${requestedSize} bytes, but the limit is ${maxHeapSize} bytes!`); - return false; - } - - // Loop through potential heap size increases. If we attempt a too eager - // reservation that fails, cut down on the attempted size and reserve a - // smaller bump instead. (max 3 times, chosen somewhat arbitrarily) - for (var cutDown = 1; cutDown <= 4; cutDown *= 2) { - var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown); // ensure geometric growth - // but limit overreserving (default to capping at +96MB overgrowth at most) - overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296 ); - - var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536)); - - var replacement = growMemory(newSize); - if (replacement) { - - return true; - } - } - err(`Failed to grow the heap from ${oldSize} bytes to ${newSize} bytes, not enough memory!`); - return false; - }; - - var ENV = { - }; - - var getExecutableName = () => thisProgram || './this.program'; - var getEnvStrings = () => { - if (!getEnvStrings.strings) { - // Default values. - // Browser language detection #8751 - var lang = ((typeof navigator == 'object' && navigator.language) || 'C').replace('-', '_') + '.UTF-8'; - var env = { - 'USER': 'web_user', - 'LOGNAME': 'web_user', - 'PATH': '/', - 'PWD': '/', - 'HOME': '/home/web_user', - 'LANG': lang, - '_': getExecutableName() - }; - // Apply the user-provided values, if any. - for (var x in ENV) { - // x is a key in ENV; if ENV[x] is undefined, that means it was - // explicitly set to be so. We allow user code to do that to - // force variables with default values to remain unset. - if (ENV[x] === undefined) delete env[x]; - else env[x] = ENV[x]; - } - var strings = []; - for (var x in env) { - strings.push(`${x}=${env[x]}`); - } - getEnvStrings.strings = strings; - } - return getEnvStrings.strings; - }; - - var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => { - assert(typeof str === 'string', `stringToUTF8Array expects a string (got ${typeof str})`); - // Parameter maxBytesToWrite is not optional. Negative values, 0, null, - // undefined and false each don't write out any bytes. - if (!(maxBytesToWrite > 0)) - return 0; - - var startIdx = outIdx; - var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator. - for (var i = 0; i < str.length; ++i) { - // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description - // and https://www.ietf.org/rfc/rfc2279.txt - // and https://tools.ietf.org/html/rfc3629 - var u = str.codePointAt(i); - if (u <= 0x7F) { - if (outIdx >= endIdx) break; - heap[outIdx++] = u; - } else if (u <= 0x7FF) { - if (outIdx + 1 >= endIdx) break; - heap[outIdx++] = 0xC0 | (u >> 6); - heap[outIdx++] = 0x80 | (u & 63); - } else if (u <= 0xFFFF) { - if (outIdx + 2 >= endIdx) break; - heap[outIdx++] = 0xE0 | (u >> 12); - heap[outIdx++] = 0x80 | ((u >> 6) & 63); - heap[outIdx++] = 0x80 | (u & 63); - } else { - if (outIdx + 3 >= endIdx) break; - if (u > 0x10FFFF) warnOnce('Invalid Unicode code point ' + ptrToString(u) + ' encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).'); - heap[outIdx++] = 0xF0 | (u >> 18); - heap[outIdx++] = 0x80 | ((u >> 12) & 63); - heap[outIdx++] = 0x80 | ((u >> 6) & 63); - heap[outIdx++] = 0x80 | (u & 63); - // Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16. - // We need to manually skip over the second code unit for correct iteration. - i++; - } - } - // Null-terminate the pointer to the buffer. - heap[outIdx] = 0; - return outIdx - startIdx; - }; - var stringToUTF8 = (str, outPtr, maxBytesToWrite) => { - assert(typeof maxBytesToWrite == 'number', 'stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!'); - return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite); - }; - var _environ_get = (__environ, environ_buf) => { - var bufSize = 0; - var envp = 0; - for (var string of getEnvStrings()) { - var ptr = environ_buf + bufSize; - HEAPU32[(((__environ)+(envp))>>2)] = ptr; - bufSize += stringToUTF8(string, ptr, Infinity) + 1; - envp += 4; - } - return 0; - }; - - - var lengthBytesUTF8 = (str) => { - var len = 0; - for (var i = 0; i < str.length; ++i) { - // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code - // unit, not a Unicode code point of the character! So decode - // UTF16->UTF32->UTF8. - // See http://unicode.org/faq/utf_bom.html#utf16-3 - var c = str.charCodeAt(i); // possibly a lead surrogate - if (c <= 0x7F) { - len++; - } else if (c <= 0x7FF) { - len += 2; - } else if (c >= 0xD800 && c <= 0xDFFF) { - len += 4; ++i; - } else { - len += 3; - } - } - return len; - }; - var _environ_sizes_get = (penviron_count, penviron_buf_size) => { - var strings = getEnvStrings(); - HEAPU32[((penviron_count)>>2)] = strings.length; - var bufSize = 0; - for (var string of strings) { - bufSize += lengthBytesUTF8(string) + 1; - } - HEAPU32[((penviron_buf_size)>>2)] = bufSize; - return 0; - }; - - - var runtimeKeepaliveCounter = 0; - var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0; - var _proc_exit = (code) => { - EXITSTATUS = code; - if (!keepRuntimeAlive()) { - Module['onExit']?.(code); - ABORT = true; - } - quit_(code, new ExitStatus(code)); - }; - - - /** @param {boolean|number=} implicit */ - var exitJS = (status, implicit) => { - EXITSTATUS = status; - - checkUnflushedContent(); - - // if exit() was called explicitly, warn the user if the runtime isn't actually being shut down - if (keepRuntimeAlive() && !implicit) { - var msg = `program exited (with status: ${status}), but keepRuntimeAlive() is set (counter=${runtimeKeepaliveCounter}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`; - readyPromiseReject?.(msg); - err(msg); - } - - _proc_exit(status); - }; - var _exit = exitJS; - - var _fd_close = (fd) => { - abort('fd_close called without SYSCALLS_REQUIRE_FILESYSTEM'); - }; - - function _fd_seek(fd, offset, whence, newOffset) { - offset = bigintToI53Checked(offset); - - - return 70; - ; - } - - var printCharBuffers = [null,[],[]]; - - var printChar = (stream, curr) => { - var buffer = printCharBuffers[stream]; - assert(buffer); - if (curr === 0 || curr === 10) { - (stream === 1 ? out : err)(UTF8ArrayToString(buffer)); - buffer.length = 0; - } else { - buffer.push(curr); - } - }; - - var flush_NO_FILESYSTEM = () => { - // flush anything remaining in the buffers during shutdown - _fflush(0); - if (printCharBuffers[1].length) printChar(1, 10); - if (printCharBuffers[2].length) printChar(2, 10); - }; - - - var _fd_write = (fd, iov, iovcnt, pnum) => { - // hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0 - var num = 0; - for (var i = 0; i < iovcnt; i++) { - var ptr = HEAPU32[((iov)>>2)]; - var len = HEAPU32[(((iov)+(4))>>2)]; - iov += 8; - for (var j = 0; j < len; j++) { - printChar(fd, HEAPU8[ptr+j]); - } - num += len; - } - HEAPU32[((pnum)>>2)] = num; - return 0; - }; - - var wasmTableMirror = []; - - - var getWasmTableEntry = (funcPtr) => { - var func = wasmTableMirror[funcPtr]; - if (!func) { - /** @suppress {checkTypes} */ - wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr); - } - /** @suppress {checkTypes} */ - assert(wasmTable.get(funcPtr) == func, 'JavaScript-side Wasm function table mirror is out of date!'); - return func; - }; -// End JS library code - -// include: postlibrary.js -// This file is included after the automatically-generated JS library code -// but before the wasm module is created. - -{ - - // Begin ATMODULES hooks - if (Module['noExitRuntime']) noExitRuntime = Module['noExitRuntime']; -if (Module['print']) out = Module['print']; -if (Module['printErr']) err = Module['printErr']; -if (Module['wasmBinary']) wasmBinary = Module['wasmBinary']; - -Module['FS_createDataFile'] = FS.createDataFile; -Module['FS_createPreloadedFile'] = FS.createPreloadedFile; - - // End ATMODULES hooks - - checkIncomingModuleAPI(); - - if (Module['arguments']) arguments_ = Module['arguments']; - if (Module['thisProgram']) thisProgram = Module['thisProgram']; - - // Assertions on removed incoming Module JS APIs. - assert(typeof Module['memoryInitializerPrefixURL'] == 'undefined', 'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead'); - assert(typeof Module['pthreadMainPrefixURL'] == 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead'); - assert(typeof Module['cdInitializerPrefixURL'] == 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead'); - assert(typeof Module['filePackagePrefixURL'] == 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead'); - assert(typeof Module['read'] == 'undefined', 'Module.read option was removed'); - assert(typeof Module['readAsync'] == 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)'); - assert(typeof Module['readBinary'] == 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)'); - assert(typeof Module['setWindowTitle'] == 'undefined', 'Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)'); - assert(typeof Module['TOTAL_MEMORY'] == 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY'); - assert(typeof Module['ENVIRONMENT'] == 'undefined', 'Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)'); - assert(typeof Module['STACK_SIZE'] == 'undefined', 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time') - // If memory is defined in wasm, the user can't provide it, or set INITIAL_MEMORY - assert(typeof Module['wasmMemory'] == 'undefined', 'Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally'); - assert(typeof Module['INITIAL_MEMORY'] == 'undefined', 'Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically'); - - if (Module['preInit']) { - if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']]; - while (Module['preInit'].length > 0) { - Module['preInit'].shift()(); - } - } - consumedModuleProp('preInit'); -} - -// Begin runtime exports - var missingLibrarySymbols = [ - 'writeI53ToI64', - 'writeI53ToI64Clamped', - 'writeI53ToI64Signaling', - 'writeI53ToU64Clamped', - 'writeI53ToU64Signaling', - 'readI53FromI64', - 'readI53FromU64', - 'convertI32PairToI53', - 'convertI32PairToI53Checked', - 'convertU32PairToI53', - 'stackAlloc', - 'getTempRet0', - 'createNamedFunction', - 'zeroMemory', - 'withStackSave', - 'strError', - 'inetPton4', - 'inetNtop4', - 'inetPton6', - 'inetNtop6', - 'readSockaddr', - 'writeSockaddr', - 'readEmAsmArgs', - 'jstoi_q', - 'autoResumeAudioContext', - 'getDynCaller', - 'dynCall', - 'handleException', - 'runtimeKeepalivePush', - 'runtimeKeepalivePop', - 'callUserCallback', - 'maybeExit', - 'asyncLoad', - 'asmjsMangle', - 'mmapAlloc', - 'HandleAllocator', - 'getUniqueRunDependency', - 'addRunDependency', - 'removeRunDependency', - 'addOnInit', - 'addOnPostCtor', - 'addOnPreMain', - 'addOnExit', - 'STACK_SIZE', - 'STACK_ALIGN', - 'POINTER_SIZE', - 'ASSERTIONS', - 'ccall', - 'cwrap', - 'convertJsFunctionToWasm', - 'getEmptyTableSlot', - 'updateTableMap', - 'getFunctionAddress', - 'addFunction', - 'removeFunction', - 'intArrayFromString', - 'intArrayToString', - 'AsciiToString', - 'stringToAscii', - 'UTF16ToString', - 'stringToUTF16', - 'lengthBytesUTF16', - 'UTF32ToString', - 'stringToUTF32', - 'lengthBytesUTF32', - 'stringToNewUTF8', - 'stringToUTF8OnStack', - 'writeArrayToMemory', - 'registerKeyEventCallback', - 'maybeCStringToJsString', - 'findEventTarget', - 'getBoundingClientRect', - 'fillMouseEventData', - 'registerMouseEventCallback', - 'registerWheelEventCallback', - 'registerUiEventCallback', - 'registerFocusEventCallback', - 'fillDeviceOrientationEventData', - 'registerDeviceOrientationEventCallback', - 'fillDeviceMotionEventData', - 'registerDeviceMotionEventCallback', - 'screenOrientation', - 'fillOrientationChangeEventData', - 'registerOrientationChangeEventCallback', - 'fillFullscreenChangeEventData', - 'registerFullscreenChangeEventCallback', - 'JSEvents_requestFullscreen', - 'JSEvents_resizeCanvasForFullscreen', - 'registerRestoreOldStyle', - 'hideEverythingExceptGivenElement', - 'restoreHiddenElements', - 'setLetterbox', - 'softFullscreenResizeWebGLRenderTarget', - 'doRequestFullscreen', - 'fillPointerlockChangeEventData', - 'registerPointerlockChangeEventCallback', - 'registerPointerlockErrorEventCallback', - 'requestPointerLock', - 'fillVisibilityChangeEventData', - 'registerVisibilityChangeEventCallback', - 'registerTouchEventCallback', - 'fillGamepadEventData', - 'registerGamepadEventCallback', - 'registerBeforeUnloadEventCallback', - 'fillBatteryEventData', - 'registerBatteryEventCallback', - 'setCanvasElementSize', - 'getCanvasElementSize', - 'jsStackTrace', - 'getCallstack', - 'convertPCtoSourceLocation', - 'wasiRightsToMuslOFlags', - 'wasiOFlagsToMuslOFlags', - 'initRandomFill', - 'randomFill', - 'safeSetTimeout', - 'setImmediateWrapped', - 'safeRequestAnimationFrame', - 'clearImmediateWrapped', - 'registerPostMainLoop', - 'registerPreMainLoop', - 'getPromise', - 'makePromise', - 'idsToPromises', - 'makePromiseCallback', - 'Browser_asyncPrepareDataCounter', - 'isLeapYear', - 'ydayFromDate', - 'arraySum', - 'addDays', - 'getSocketFromFD', - 'getSocketAddress', - 'heapObjectForWebGLType', - 'toTypedArrayIndex', - 'webgl_enable_ANGLE_instanced_arrays', - 'webgl_enable_OES_vertex_array_object', - 'webgl_enable_WEBGL_draw_buffers', - 'webgl_enable_WEBGL_multi_draw', - 'webgl_enable_EXT_polygon_offset_clamp', - 'webgl_enable_EXT_clip_control', - 'webgl_enable_WEBGL_polygon_mode', - 'emscriptenWebGLGet', - 'computeUnpackAlignedImageSize', - 'colorChannelsInGlTextureFormat', - 'emscriptenWebGLGetTexPixelData', - 'emscriptenWebGLGetUniform', - 'webglGetUniformLocation', - 'webglPrepareUniformLocationsBeforeFirstUse', - 'webglGetLeftBracePos', - 'emscriptenWebGLGetVertexAttrib', - '__glGetActiveAttribOrUniform', - 'writeGLArray', - 'registerWebGlEventCallback', - 'runAndAbortIfError', - 'ALLOC_NORMAL', - 'ALLOC_STACK', - 'allocate', - 'writeStringToMemory', - 'writeAsciiToMemory', - 'allocateUTF8', - 'allocateUTF8OnStack', - 'demangle', - 'stackTrace', - 'getNativeTypeSize', -]; -missingLibrarySymbols.forEach(missingLibrarySymbol) - - var unexportedSymbols = [ - 'run', - 'out', - 'err', - 'callMain', - 'abort', - 'wasmExports', - 'HEAPF32', - 'HEAPF64', - 'HEAP8', - 'HEAP16', - 'HEAPU16', - 'HEAP32', - 'HEAPU32', - 'HEAP64', - 'HEAPU64', - 'writeStackCookie', - 'checkStackCookie', - 'INT53_MAX', - 'INT53_MIN', - 'bigintToI53Checked', - 'stackSave', - 'stackRestore', - 'setTempRet0', - 'ptrToString', - 'exitJS', - 'getHeapMax', - 'growMemory', - 'ENV', - 'ERRNO_CODES', - 'DNS', - 'Protocols', - 'Sockets', - 'timers', - 'warnOnce', - 'readEmAsmArgsArray', - 'getExecutableName', - 'keepRuntimeAlive', - 'alignMemory', - 'wasmTable', - 'wasmMemory', - 'noExitRuntime', - 'addOnPreRun', - 'addOnPostRun', - 'freeTableIndexes', - 'functionsInTableMap', - 'setValue', - 'getValue', - 'PATH', - 'PATH_FS', - 'UTF8Decoder', - 'UTF8ArrayToString', - 'UTF8ToString', - 'stringToUTF8Array', - 'stringToUTF8', - 'lengthBytesUTF8', - 'UTF16Decoder', - 'JSEvents', - 'specialHTMLTargets', - 'findCanvasEventTarget', - 'currentFullscreenStrategy', - 'restoreOldWindowedStyle', - 'UNWIND_CACHE', - 'ExitStatus', - 'getEnvStrings', - 'checkWasiClock', - 'flush_NO_FILESYSTEM', - 'emSetImmediate', - 'emClearImmediate_deps', - 'emClearImmediate', - 'promiseMap', - 'uncaughtExceptionCount', - 'exceptionLast', - 'exceptionCaught', - 'ExceptionInfo', - 'findMatchingCatch', - 'Browser', - 'requestFullscreen', - 'requestFullScreen', - 'setCanvasSize', - 'getUserMedia', - 'createContext', - 'getPreloadedImageData__data', - 'wget', - 'MONTH_DAYS_REGULAR', - 'MONTH_DAYS_LEAP', - 'MONTH_DAYS_REGULAR_CUMULATIVE', - 'MONTH_DAYS_LEAP_CUMULATIVE', - 'SYSCALLS', - 'tempFixedLengthArray', - 'miniTempWebGLFloatBuffers', - 'miniTempWebGLIntBuffers', - 'GL', - 'AL', - 'GLUT', - 'EGL', - 'GLEW', - 'IDBStore', - 'SDL', - 'SDL_gfx', - 'print', - 'printErr', - 'jstoi_s', -]; -unexportedSymbols.forEach(unexportedRuntimeSymbol); - - // End runtime exports - // Begin JS library exports - // End JS library exports - -// end include: postlibrary.js - -function checkIncomingModuleAPI() { - ignoredModuleProp('fetchSettings'); -} - -// Imports from the Wasm binary. -var _solve_problem = Module['_solve_problem'] = makeInvalidEarlyAccess('_solve_problem'); -var _enumerate_answers_problem = Module['_enumerate_answers_problem'] = makeInvalidEarlyAccess('_enumerate_answers_problem'); -var _free = Module['_free'] = makeInvalidEarlyAccess('_free'); -var _malloc = Module['_malloc'] = makeInvalidEarlyAccess('_malloc'); -var _fflush = makeInvalidEarlyAccess('_fflush'); -var _emscripten_stack_get_end = makeInvalidEarlyAccess('_emscripten_stack_get_end'); -var _emscripten_stack_get_base = makeInvalidEarlyAccess('_emscripten_stack_get_base'); -var _htonl = makeInvalidEarlyAccess('_htonl'); -var _htons = makeInvalidEarlyAccess('_htons'); -var _ntohs = makeInvalidEarlyAccess('_ntohs'); -var __emscripten_tempret_set = makeInvalidEarlyAccess('__emscripten_tempret_set'); -var _emscripten_stack_init = makeInvalidEarlyAccess('_emscripten_stack_init'); -var _emscripten_stack_get_free = makeInvalidEarlyAccess('_emscripten_stack_get_free'); -var __emscripten_stack_restore = makeInvalidEarlyAccess('__emscripten_stack_restore'); -var __emscripten_stack_alloc = makeInvalidEarlyAccess('__emscripten_stack_alloc'); -var _emscripten_stack_get_current = makeInvalidEarlyAccess('_emscripten_stack_get_current'); -var ___cxa_can_catch = makeInvalidEarlyAccess('___cxa_can_catch'); -var memory = makeInvalidEarlyAccess('memory'); -var __indirect_function_table = makeInvalidEarlyAccess('__indirect_function_table'); -var wasmMemory = makeInvalidEarlyAccess('wasmMemory'); -var wasmTable = makeInvalidEarlyAccess('wasmTable'); - -function assignWasmExports(wasmExports) { - assert(typeof wasmExports['solve_problem'] != 'undefined', 'missing Wasm export: solve_problem'); - _solve_problem = Module['_solve_problem'] = createExportWrapper('solve_problem', 2); - assert(typeof wasmExports['enumerate_answers_problem'] != 'undefined', 'missing Wasm export: enumerate_answers_problem'); - _enumerate_answers_problem = Module['_enumerate_answers_problem'] = createExportWrapper('enumerate_answers_problem', 3); - assert(typeof wasmExports['free'] != 'undefined', 'missing Wasm export: free'); - _free = Module['_free'] = createExportWrapper('free', 1); - assert(typeof wasmExports['malloc'] != 'undefined', 'missing Wasm export: malloc'); - _malloc = Module['_malloc'] = createExportWrapper('malloc', 1); - assert(typeof wasmExports['fflush'] != 'undefined', 'missing Wasm export: fflush'); - _fflush = createExportWrapper('fflush', 1); - assert(typeof wasmExports['emscripten_stack_get_end'] != 'undefined', 'missing Wasm export: emscripten_stack_get_end'); - _emscripten_stack_get_end = wasmExports['emscripten_stack_get_end']; - assert(typeof wasmExports['emscripten_stack_get_base'] != 'undefined', 'missing Wasm export: emscripten_stack_get_base'); - _emscripten_stack_get_base = wasmExports['emscripten_stack_get_base']; - assert(typeof wasmExports['htonl'] != 'undefined', 'missing Wasm export: htonl'); - _htonl = createExportWrapper('htonl', 1); - assert(typeof wasmExports['htons'] != 'undefined', 'missing Wasm export: htons'); - _htons = createExportWrapper('htons', 1); - assert(typeof wasmExports['ntohs'] != 'undefined', 'missing Wasm export: ntohs'); - _ntohs = createExportWrapper('ntohs', 1); - assert(typeof wasmExports['_emscripten_tempret_set'] != 'undefined', 'missing Wasm export: _emscripten_tempret_set'); - __emscripten_tempret_set = createExportWrapper('_emscripten_tempret_set', 1); - assert(typeof wasmExports['emscripten_stack_init'] != 'undefined', 'missing Wasm export: emscripten_stack_init'); - _emscripten_stack_init = wasmExports['emscripten_stack_init']; - assert(typeof wasmExports['emscripten_stack_get_free'] != 'undefined', 'missing Wasm export: emscripten_stack_get_free'); - _emscripten_stack_get_free = wasmExports['emscripten_stack_get_free']; - assert(typeof wasmExports['_emscripten_stack_restore'] != 'undefined', 'missing Wasm export: _emscripten_stack_restore'); - __emscripten_stack_restore = wasmExports['_emscripten_stack_restore']; - assert(typeof wasmExports['_emscripten_stack_alloc'] != 'undefined', 'missing Wasm export: _emscripten_stack_alloc'); - __emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc']; - assert(typeof wasmExports['emscripten_stack_get_current'] != 'undefined', 'missing Wasm export: emscripten_stack_get_current'); - _emscripten_stack_get_current = wasmExports['emscripten_stack_get_current']; - assert(typeof wasmExports['__cxa_can_catch'] != 'undefined', 'missing Wasm export: __cxa_can_catch'); - ___cxa_can_catch = createExportWrapper('__cxa_can_catch', 3); - assert(typeof wasmExports['memory'] != 'undefined', 'missing Wasm export: memory'); - memory = wasmMemory = wasmExports['memory']; - assert(typeof wasmExports['__indirect_function_table'] != 'undefined', 'missing Wasm export: __indirect_function_table'); - __indirect_function_table = wasmTable = wasmExports['__indirect_function_table']; -} - -var wasmImports = { - /** @export */ - __assert_fail: ___assert_fail, - /** @export */ - __cxa_find_matching_catch_2: ___cxa_find_matching_catch_2, - /** @export */ - __resumeException: ___resumeException, - /** @export */ - __syscall_getcwd: ___syscall_getcwd, - /** @export */ - _abort_js: __abort_js, - /** @export */ - clock_time_get: _clock_time_get, - /** @export */ - emscripten_resize_heap: _emscripten_resize_heap, - /** @export */ - environ_get: _environ_get, - /** @export */ - environ_sizes_get: _environ_sizes_get, - /** @export */ - exit: _exit, - /** @export */ - fd_close: _fd_close, - /** @export */ - fd_seek: _fd_seek, - /** @export */ - fd_write: _fd_write, - /** @export */ - invoke_ii, - /** @export */ - invoke_iiii, - /** @export */ - invoke_iiiiii, - /** @export */ - invoke_vi, - /** @export */ - invoke_vii, - /** @export */ - invoke_viii, - /** @export */ - invoke_viiii, - /** @export */ - invoke_viiiii -}; - -function invoke_vi(index,a1) { - var sp = stackSave(); - try { - getWasmTableEntry(index)(a1); - } catch(e) { - stackRestore(sp); - if (e !== e+0) throw e; - _setThrew(1, 0); - } -} - -function invoke_vii(index,a1,a2) { - var sp = stackSave(); - try { - getWasmTableEntry(index)(a1,a2); - } catch(e) { - stackRestore(sp); - if (e !== e+0) throw e; - _setThrew(1, 0); - } -} - -function invoke_viii(index,a1,a2,a3) { - var sp = stackSave(); - try { - getWasmTableEntry(index)(a1,a2,a3); - } catch(e) { - stackRestore(sp); - if (e !== e+0) throw e; - _setThrew(1, 0); - } -} - -function invoke_ii(index,a1) { - var sp = stackSave(); - try { - return getWasmTableEntry(index)(a1); - } catch(e) { - stackRestore(sp); - if (e !== e+0) throw e; - _setThrew(1, 0); - } -} - -function invoke_viiiii(index,a1,a2,a3,a4,a5) { - var sp = stackSave(); - try { - getWasmTableEntry(index)(a1,a2,a3,a4,a5); - } catch(e) { - stackRestore(sp); - if (e !== e+0) throw e; - _setThrew(1, 0); - } -} - -function invoke_viiii(index,a1,a2,a3,a4) { - var sp = stackSave(); - try { - getWasmTableEntry(index)(a1,a2,a3,a4); - } catch(e) { - stackRestore(sp); - if (e !== e+0) throw e; - _setThrew(1, 0); - } -} - -function invoke_iiii(index,a1,a2,a3) { - var sp = stackSave(); - try { - return getWasmTableEntry(index)(a1,a2,a3); - } catch(e) { - stackRestore(sp); - if (e !== e+0) throw e; - _setThrew(1, 0); - } -} - -function invoke_iiiiii(index,a1,a2,a3,a4,a5) { - var sp = stackSave(); - try { - return getWasmTableEntry(index)(a1,a2,a3,a4,a5); - } catch(e) { - stackRestore(sp); - if (e !== e+0) throw e; - _setThrew(1, 0); - } -} - - -// include: postamble.js -// === Auto-generated postamble setup entry stuff === - -var calledRun; - -function stackCheckInit() { - // This is normally called automatically during __wasm_call_ctors but need to - // get these values before even running any of the ctors so we call it redundantly - // here. - _emscripten_stack_init(); - // TODO(sbc): Move writeStackCookie to native to to avoid this. - writeStackCookie(); -} - -function run() { - - stackCheckInit(); - - preRun(); - - function doRun() { - // run may have just been called through dependencies being fulfilled just in this very frame, - // or while the async setStatus time below was happening - assert(!calledRun); - calledRun = true; - Module['calledRun'] = true; - - if (ABORT) return; - - initRuntime(); - - readyPromiseResolve?.(Module); - Module['onRuntimeInitialized']?.(); - consumedModuleProp('onRuntimeInitialized'); - - assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'); - - postRun(); - } - - if (Module['setStatus']) { - Module['setStatus']('Running...'); - setTimeout(() => { - setTimeout(() => Module['setStatus'](''), 1); - doRun(); - }, 1); - } else - { - doRun(); - } - checkStackCookie(); -} - -function checkUnflushedContent() { - // Compiler settings do not allow exiting the runtime, so flushing - // the streams is not possible. but in ASSERTIONS mode we check - // if there was something to flush, and if so tell the user they - // should request that the runtime be exitable. - // Normally we would not even include flush() at all, but in ASSERTIONS - // builds we do so just for this check, and here we see if there is any - // content to flush, that is, we check if there would have been - // something a non-ASSERTIONS build would have not seen. - // How we flush the streams depends on whether we are in SYSCALLS_REQUIRE_FILESYSTEM=0 - // mode (which has its own special function for this; otherwise, all - // the code is inside libc) - var oldOut = out; - var oldErr = err; - var has = false; - out = err = (x) => { - has = true; - } - try { // it doesn't matter if it fails - flush_NO_FILESYSTEM(); - } catch(e) {} - out = oldOut; - err = oldErr; - if (has) { - warnOnce('stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc.'); - warnOnce('(this may also be due to not including full filesystem support - try building with -sFORCE_FILESYSTEM)'); - } -} - -var wasmExports; - -// In modularize mode the generated code is within a factory function so we -// can use await here (since it's not top-level-await). -wasmExports = await (createWasm()); - -run(); - -// end include: postamble.js - -// include: postamble_modularize.js -// In MODULARIZE mode we wrap the generated code in a factory function -// and return either the Module itself, or a promise of the module. -// -// We assign to the `moduleRtn` global here and configure closure to see -// this as and extern so it won't get minified. - -if (runtimeInitialized) { - moduleRtn = Module; -} else { - // Set up the promise that indicates the Module is initialized - moduleRtn = new Promise((resolve, reject) => { - readyPromiseResolve = resolve; - readyPromiseReject = reject; - }); -} - -// Assertion for attempting to access module properties on the incoming -// moduleArg. In the past we used this object as the prototype of the module -// and assigned properties to it, but now we return a distinct object. This -// keeps the instance private until it is ready (i.e the promise has been -// resolved). -for (const prop of Object.keys(Module)) { - if (!(prop in moduleArg)) { - Object.defineProperty(moduleArg, prop, { - configurable: true, - get() { - abort(`Access to module property ('${prop}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`) - } - }); - } -} -// end include: postamble_modularize.js - - - - return moduleRtn; + HEAPU64; + + var runtimeInitialized = false; + + function updateMemoryViews() { + var b = wasmMemory.buffer; + HEAP8 = new Int8Array(b); + HEAP16 = new Int16Array(b); + Module["HEAPU8"] = HEAPU8 = new Uint8Array(b); + HEAPU16 = new Uint16Array(b); + HEAP32 = new Int32Array(b); + HEAPU32 = new Uint32Array(b); + HEAPF32 = new Float32Array(b); + HEAPF64 = new Float64Array(b); + HEAP64 = new BigInt64Array(b); + HEAPU64 = new BigUint64Array(b); + } + + // include: memoryprofiler.js + // end include: memoryprofiler.js + // end include: runtime_common.js + assert( + globalThis.Int32Array && + globalThis.Float64Array && + Int32Array.prototype.subarray && + Int32Array.prototype.set, + "JS engine does not provide full typed array support" + ); + + function preRun() { + if (Module["preRun"]) { + if (typeof Module["preRun"] == "function") + Module["preRun"] = [Module["preRun"]]; + while (Module["preRun"].length) { + addOnPreRun(Module["preRun"].shift()); + } + } + consumedModuleProp("preRun"); + // Begin ATPRERUNS hooks + callRuntimeCallbacks(onPreRuns); + // End ATPRERUNS hooks + } + + function initRuntime() { + assert(!runtimeInitialized); + runtimeInitialized = true; + + checkStackCookie(); + + // No ATINITS hooks + + wasmExports["__wasm_call_ctors"](); + + // No ATPOSTCTORS hooks + } + + function postRun() { + checkStackCookie(); + // PThreads reuse the runtime from the main thread. + + if (Module["postRun"]) { + if (typeof Module["postRun"] == "function") + Module["postRun"] = [Module["postRun"]]; + while (Module["postRun"].length) { + addOnPostRun(Module["postRun"].shift()); + } + } + consumedModuleProp("postRun"); + + // Begin ATPOSTRUNS hooks + callRuntimeCallbacks(onPostRuns); + // End ATPOSTRUNS hooks + } + + /** @param {string|number=} what */ + function abort(what) { + Module["onAbort"]?.(what); + + what = "Aborted(" + what + ")"; + // TODO(sbc): Should we remove printing and leave it up to whoever + // catches the exception? + err(what); + + ABORT = true; + + // Use a wasm runtime error, because a JS error might be seen as a foreign + // exception, which means we'd run destructors on it. We need the error to + // simply make the program stop. + // FIXME This approach does not work in Wasm EH because it currently does not assume + // all RuntimeErrors are from traps; it decides whether a RuntimeError is from + // a trap or not based on a hidden field within the object. So at the moment + // we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that + // allows this in the wasm spec. + + // Suppress closure compiler warning here. Closure compiler's builtin extern + // definition for WebAssembly.RuntimeError claims it takes no arguments even + // though it can. + // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed. + /** @suppress {checkTypes} */ + var e = new WebAssembly.RuntimeError(what); + + readyPromiseReject?.(e); + // Throw the error whether or not MODULARIZE is set because abort is used + // in code paths apart from instantiation where an exception is expected + // to be thrown when abort is called. + throw e; + } + + // show errors on likely calls to FS when it was not included + var FS = { + error() { + abort( + "Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM" + ); + }, + init() { + FS.error(); + }, + createDataFile() { + FS.error(); + }, + createPreloadedFile() { + FS.error(); + }, + createLazyFile() { + FS.error(); + }, + open() { + FS.error(); + }, + mkdev() { + FS.error(); + }, + registerDevice() { + FS.error(); + }, + analyzePath() { + FS.error(); + }, + + ErrnoError() { + FS.error(); + } + }; + + function createExportWrapper(name, nargs) { + return (...args) => { + assert( + runtimeInitialized, + `native function \`${name}\` called before runtime initialization` + ); + var f = wasmExports[name]; + assert(f, `exported native function \`${name}\` not found`); + // Only assert for too many arguments. Too few can be valid since the missing arguments will be zero filled. + assert( + args.length <= nargs, + `native function \`${name}\` called with ${args.length} args but expects ${nargs}` + ); + return f(...args); + }; + } + + var wasmBinaryFile; + + function findWasmBinary() { + if (Module["locateFile"]) { + return locateFile("cspuz_solver_backend.wasm"); + } + + // Use bundler-friendly `new URL(..., import.meta.url)` pattern; works in browsers too. + return new URL("cspuz_solver_backend.wasm", import.meta.url).href; + } + + function getBinarySync(file) { + if (file == wasmBinaryFile && wasmBinary) { + return new Uint8Array(wasmBinary); + } + if (readBinary) { + return readBinary(file); + } + // Throwing a plain string here, even though it not normally adviables since + // this gets turning into an `abort` in instantiateArrayBuffer. + throw "both async and sync fetching of the wasm failed"; + } + + async function getWasmBinary(binaryFile) { + // If we don't have the binary yet, load it asynchronously using readAsync. + if (!wasmBinary) { + // Fetch the binary using readAsync + try { + var response = await readAsync(binaryFile); + return new Uint8Array(response); + } catch { + // Fall back to getBinarySync below; + } + } + + // Otherwise, getBinarySync should be able to get it synchronously + return getBinarySync(binaryFile); + } + + async function instantiateArrayBuffer(binaryFile, imports) { + try { + var binary = await getWasmBinary(binaryFile); + var instance = await WebAssembly.instantiate(binary, imports); + return instance; + } catch (reason) { + err(`failed to asynchronously prepare wasm: ${reason}`); + + // Warn on some common problems. + if (isFileURI(binaryFile)) { + err( + `warning: Loading from a file URI (${binaryFile}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing` + ); + } + abort(reason); + } + } + + async function instantiateAsync(binary, binaryFile, imports) { + if ( + !binary && + // Avoid instantiateStreaming() on Node.js environment for now, as while + // Node.js v18.1.0 implements it, it does not have a full fetch() + // implementation yet. + // + // Reference: + // https://github.com/emscripten-core/emscripten/pull/16917 + !ENVIRONMENT_IS_NODE + ) { + try { + var response = fetch(binaryFile, { credentials: "same-origin" }); + var instantiationResult = await WebAssembly.instantiateStreaming( + response, + imports + ); + return instantiationResult; + } catch (reason) { + // We expect the most common failure cause to be a bad MIME type for the binary, + // in which case falling back to ArrayBuffer instantiation should work. + err(`wasm streaming compile failed: ${reason}`); + err("falling back to ArrayBuffer instantiation"); + // fall back of instantiateArrayBuffer below + } + } + return instantiateArrayBuffer(binaryFile, imports); + } + + function getWasmImports() { + // prepare imports + var imports = { + env: wasmImports, + wasi_snapshot_preview1: wasmImports + }; + return imports; + } + + // Create the wasm instance. + // Receives the wasm imports, returns the exports. + async function createWasm() { + // Load the wasm module and create an instance of using native support in the JS engine. + // handle a generated wasm instance, receiving its exports and + // performing other necessary setup + /** @param {WebAssembly.Module=} module*/ + function receiveInstance(instance, module) { + wasmExports = instance.exports; + + assignWasmExports(wasmExports); + + updateMemoryViews(); + + return wasmExports; + } + + // Prefer streaming instantiation if available. + // Async compilation can be confusing when an error on the page overwrites Module + // (for example, if the order of elements is wrong, and the one defining Module is + // later), so we save Module and check it later. + var trueModule = Module; + function receiveInstantiationResult(result) { + // 'result' is a ResultObject object which has both the module and instance. + // receiveInstance() will swap in the exports (to Module.asm) so they can be called + assert( + Module === trueModule, + "the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?" + ); + trueModule = null; + // TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193, the above line no longer optimizes out down to the following line. + // When the regression is fixed, can restore the above PTHREADS-enabled path. + return receiveInstance(result["instance"]); + } + + var info = getWasmImports(); + + // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback + // to manually instantiate the Wasm module themselves. This allows pages to + // run the instantiation parallel to any other async startup actions they are + // performing. + // Also pthreads and wasm workers initialize the wasm instance through this + // path. + if (Module["instantiateWasm"]) { + return new Promise((resolve, reject) => { + try { + Module["instantiateWasm"](info, (inst, mod) => { + resolve(receiveInstance(inst, mod)); + }); + } catch (e) { + err(`Module.instantiateWasm callback failed with error: ${e}`); + reject(e); + } + }); + } + + wasmBinaryFile ??= findWasmBinary(); + var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info); + var exports = receiveInstantiationResult(result); + return exports; + } + + // end include: preamble.js + + // Begin JS library code + + class ExitStatus { + name = "ExitStatus"; + constructor(status) { + this.message = `Program terminated with exit(${status})`; + this.status = status; + } + } + + var callRuntimeCallbacks = callbacks => { + while (callbacks.length > 0) { + // Pass the module as the first argument. + callbacks.shift()(Module); + } + }; + var onPostRuns = []; + var addOnPostRun = cb => onPostRuns.push(cb); + + var onPreRuns = []; + var addOnPreRun = cb => onPreRuns.push(cb); + + /** + * @param {number} ptr + * @param {string} type + */ + function getValue(ptr, type = "i8") { + if (type.endsWith("*")) type = "*"; + switch (type) { + case "i1": + return HEAP8[ptr]; + case "i8": + return HEAP8[ptr]; + case "i16": + return HEAP16[ptr >> 1]; + case "i32": + return HEAP32[ptr >> 2]; + case "i64": + return HEAP64[ptr >> 3]; + case "float": + return HEAPF32[ptr >> 2]; + case "double": + return HEAPF64[ptr >> 3]; + case "*": + return HEAPU32[ptr >> 2]; + default: + abort(`invalid type for getValue: ${type}`); + } + } + + var noExitRuntime = true; + + var ptrToString = ptr => { + assert( + typeof ptr === "number", + `ptrToString expects a number, got ${typeof ptr}` + ); + // Convert to 32-bit unsigned value + ptr >>>= 0; + return "0x" + ptr.toString(16).padStart(8, "0"); + }; + + /** + * @param {number} ptr + * @param {number} value + * @param {string} type + */ + function setValue(ptr, value, type = "i8") { + if (type.endsWith("*")) type = "*"; + switch (type) { + case "i1": + HEAP8[ptr] = value; + break; + case "i8": + HEAP8[ptr] = value; + break; + case "i16": + HEAP16[ptr >> 1] = value; + break; + case "i32": + HEAP32[ptr >> 2] = value; + break; + case "i64": + HEAP64[ptr >> 3] = BigInt(value); + break; + case "float": + HEAPF32[ptr >> 2] = value; + break; + case "double": + HEAPF64[ptr >> 3] = value; + break; + case "*": + HEAPU32[ptr >> 2] = value; + break; + default: + abort(`invalid type for setValue: ${type}`); + } + } + + var stackRestore = val => __emscripten_stack_restore(val); + + var stackSave = () => _emscripten_stack_get_current(); + + var warnOnce = text => { + warnOnce.shown ||= {}; + if (!warnOnce.shown[text]) { + warnOnce.shown[text] = 1; + if (ENVIRONMENT_IS_NODE) text = "warning: " + text; + err(text); + } + }; + + var UTF8Decoder = globalThis.TextDecoder && new TextDecoder(); + + var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => { + var maxIdx = idx + maxBytesToRead; + if (ignoreNul) return maxIdx; + // TextDecoder needs to know the byte length in advance, it doesn't stop on + // null terminator by itself. + // As a tiny code save trick, compare idx against maxIdx using a negation, + // so that maxBytesToRead=undefined/NaN means Infinity. + while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx; + return idx; + }; + + /** + * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given + * array that contains uint8 values, returns a copy of that string as a + * Javascript String object. + * heapOrArray is either a regular array, or a JavaScript typed array view. + * @param {number=} idx + * @param {number=} maxBytesToRead + * @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character. + * @return {string} + */ + var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead, ignoreNul) => { + var endPtr = findStringEnd(heapOrArray, idx, maxBytesToRead, ignoreNul); + + // When using conditional TextDecoder, skip it for short strings as the overhead of the native call is not worth it. + if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) { + return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr)); + } + var str = ""; + while (idx < endPtr) { + // For UTF8 byte structure, see: + // http://en.wikipedia.org/wiki/UTF-8#Description + // https://www.ietf.org/rfc/rfc2279.txt + // https://tools.ietf.org/html/rfc3629 + var u0 = heapOrArray[idx++]; + if (!(u0 & 0x80)) { + str += String.fromCharCode(u0); + continue; + } + var u1 = heapOrArray[idx++] & 63; + if ((u0 & 0xe0) == 0xc0) { + str += String.fromCharCode(((u0 & 31) << 6) | u1); + continue; + } + var u2 = heapOrArray[idx++] & 63; + if ((u0 & 0xf0) == 0xe0) { + u0 = ((u0 & 15) << 12) | (u1 << 6) | u2; + } else { + if ((u0 & 0xf8) != 0xf0) + warnOnce( + "Invalid UTF-8 leading byte " + + ptrToString(u0) + + " encountered when deserializing a UTF-8 string in wasm memory to a JS string!" + ); + u0 = + ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63); + } + + if (u0 < 0x10000) { + str += String.fromCharCode(u0); + } else { + var ch = u0 - 0x10000; + str += String.fromCharCode(0xd800 | (ch >> 10), 0xdc00 | (ch & 0x3ff)); + } + } + return str; + }; + + /** + * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the + * emscripten HEAP, returns a copy of that string as a Javascript String object. + * + * @param {number} ptr + * @param {number=} maxBytesToRead - An optional length that specifies the + * maximum number of bytes to read. You can omit this parameter to scan the + * string until the first 0 byte. If maxBytesToRead is passed, and the string + * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the + * string will cut short at that byte index. + * @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character. + * @return {string} + */ + var UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => { + assert( + typeof ptr == "number", + `UTF8ToString expects a number (got ${typeof ptr})` + ); + return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead, ignoreNul) : ""; + }; + var ___assert_fail = (condition, filename, line, func) => + abort( + `Assertion failed: ${UTF8ToString(condition)}, at: ` + + [ + filename ? UTF8ToString(filename) : "unknown filename", + line, + func ? UTF8ToString(func) : "unknown function" + ] + ); + + var exceptionLast = 0; + + class ExceptionInfo { + // excPtr - Thrown object pointer to wrap. Metadata pointer is calculated from it. + constructor(excPtr) { + this.excPtr = excPtr; + this.ptr = excPtr - 24; + } + + set_type(type) { + HEAPU32[(this.ptr + 4) >> 2] = type; + } + + get_type() { + return HEAPU32[(this.ptr + 4) >> 2]; + } + + set_destructor(destructor) { + HEAPU32[(this.ptr + 8) >> 2] = destructor; + } + + get_destructor() { + return HEAPU32[(this.ptr + 8) >> 2]; + } + + set_caught(caught) { + caught = caught ? 1 : 0; + HEAP8[this.ptr + 12] = caught; + } + + get_caught() { + return HEAP8[this.ptr + 12] != 0; + } + + set_rethrown(rethrown) { + rethrown = rethrown ? 1 : 0; + HEAP8[this.ptr + 13] = rethrown; + } + + get_rethrown() { + return HEAP8[this.ptr + 13] != 0; + } + + // Initialize native structure fields. Should be called once after allocated. + init(type, destructor) { + this.set_adjusted_ptr(0); + this.set_type(type); + this.set_destructor(destructor); + } + + set_adjusted_ptr(adjustedPtr) { + HEAPU32[(this.ptr + 16) >> 2] = adjustedPtr; + } + + get_adjusted_ptr() { + return HEAPU32[(this.ptr + 16) >> 2]; + } + } + + var setTempRet0 = val => __emscripten_tempret_set(val); + var findMatchingCatch = args => { + var thrown = exceptionLast; + if (!thrown) { + // just pass through the null ptr + setTempRet0(0); + return 0; + } + var info = new ExceptionInfo(thrown); + info.set_adjusted_ptr(thrown); + var thrownType = info.get_type(); + if (!thrownType) { + // just pass through the thrown ptr + setTempRet0(0); + return thrown; + } + + // can_catch receives a **, add indirection + // The different catch blocks are denoted by different types. + // Due to inheritance, those types may not precisely match the + // type of the thrown object. Find one which matches, and + // return the type of the catch block which should be called. + for (var caughtType of args) { + if (caughtType === 0 || caughtType === thrownType) { + // Catch all clause matched or exactly the same type is caught + break; + } + var adjusted_ptr_addr = info.ptr + 16; + if (___cxa_can_catch(caughtType, thrownType, adjusted_ptr_addr)) { + setTempRet0(caughtType); + return thrown; + } + } + setTempRet0(thrownType); + return thrown; + }; + var ___cxa_find_matching_catch_2 = () => findMatchingCatch([]); + + var ___resumeException = ptr => { + if (!exceptionLast) { + exceptionLast = ptr; + } + assert( + false, + "Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch." + ); + }; + + var SYSCALLS = { + varargs: undefined, + getStr(ptr) { + var ret = UTF8ToString(ptr); + return ret; + } + }; + var ___syscall_getcwd = (buf, size) => { + abort( + "it should not be possible to operate on streams when !SYSCALLS_REQUIRE_FILESYSTEM" + ); + }; + + var __abort_js = () => abort("native code called abort()"); + + var _emscripten_get_now = () => performance.now(); + + var _emscripten_date_now = () => Date.now(); + + var nowIsMonotonic = 1; + + var checkWasiClock = clock_id => clock_id >= 0 && clock_id <= 3; + + var INT53_MAX = 9007199254740992; + + var INT53_MIN = -9007199254740992; + var bigintToI53Checked = num => + num < INT53_MIN || num > INT53_MAX ? NaN : Number(num); + function _clock_time_get(clk_id, ignored_precision, ptime) { + ignored_precision = bigintToI53Checked(ignored_precision); + + if (!checkWasiClock(clk_id)) { + return 28; + } + var now; + // all wasi clocks but realtime are monotonic + if (clk_id === 0) { + now = _emscripten_date_now(); + } else if (nowIsMonotonic) { + now = _emscripten_get_now(); + } else { + return 52; + } + // "now" is in ms, and wasi times are in ns. + var nsec = Math.round(now * 1000 * 1000); + HEAP64[ptime >> 3] = BigInt(nsec); + return 0; + } + + var getHeapMax = () => + // Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate + // full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side + // for any code that deals with heap sizes, which would require special + // casing all heap size related code to treat 0 specially. + 2147483648; + + var alignMemory = (size, alignment) => { + assert(alignment, "alignment argument is required"); + return Math.ceil(size / alignment) * alignment; + }; + + var growMemory = size => { + var oldHeapSize = wasmMemory.buffer.byteLength; + var pages = ((size - oldHeapSize + 65535) / 65536) | 0; + try { + // round size grow request up to wasm page size (fixed 64KB per spec) + wasmMemory.grow(pages); // .grow() takes a delta compared to the previous size + updateMemoryViews(); + return 1 /*success*/; + } catch (e) { + err( + `growMemory: Attempted to grow heap from ${oldHeapSize} bytes to ${size} bytes, but got error: ${e}` + ); + } + // implicit 0 return to save code size (caller will cast "undefined" into 0 + // anyhow) + }; + var _emscripten_resize_heap = requestedSize => { + var oldSize = HEAPU8.length; + // With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned. + requestedSize >>>= 0; + // With multithreaded builds, races can happen (another thread might increase the size + // in between), so return a failure, and let the caller retry. + assert(requestedSize > oldSize); + + // Memory resize rules: + // 1. Always increase heap size to at least the requested size, rounded up + // to next page multiple. + // 2a. If MEMORY_GROWTH_LINEAR_STEP == -1, excessively resize the heap + // geometrically: increase the heap size according to + // MEMORY_GROWTH_GEOMETRIC_STEP factor (default +20%), At most + // overreserve by MEMORY_GROWTH_GEOMETRIC_CAP bytes (default 96MB). + // 2b. If MEMORY_GROWTH_LINEAR_STEP != -1, excessively resize the heap + // linearly: increase the heap size by at least + // MEMORY_GROWTH_LINEAR_STEP bytes. + // 3. Max size for the heap is capped at 2048MB-WASM_PAGE_SIZE, or by + // MAXIMUM_MEMORY, or by ASAN limit, depending on which is smallest + // 4. If we were unable to allocate as much memory, it may be due to + // over-eager decision to excessively reserve due to (3) above. + // Hence if an allocation fails, cut down on the amount of excess + // growth, in an attempt to succeed to perform a smaller allocation. + + // A limit is set for how much we can grow. We should not exceed that + // (the wasm binary specifies it, so if we tried, we'd fail anyhow). + var maxHeapSize = getHeapMax(); + if (requestedSize > maxHeapSize) { + err( + `Cannot enlarge memory, requested ${requestedSize} bytes, but the limit is ${maxHeapSize} bytes!` + ); + return false; + } + + // Loop through potential heap size increases. If we attempt a too eager + // reservation that fails, cut down on the attempted size and reserve a + // smaller bump instead. (max 3 times, chosen somewhat arbitrarily) + for (var cutDown = 1; cutDown <= 4; cutDown *= 2) { + var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown); // ensure geometric growth + // but limit overreserving (default to capping at +96MB overgrowth at most) + overGrownHeapSize = Math.min( + overGrownHeapSize, + requestedSize + 100663296 + ); + + var newSize = Math.min( + maxHeapSize, + alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536) + ); + + var replacement = growMemory(newSize); + if (replacement) { + return true; + } + } + err( + `Failed to grow the heap from ${oldSize} bytes to ${newSize} bytes, not enough memory!` + ); + return false; + }; + + var ENV = {}; + + var getExecutableName = () => thisProgram || "./this.program"; + var getEnvStrings = () => { + if (!getEnvStrings.strings) { + // Default values. + // Browser language detection #8751 + var lang = + ((typeof navigator == "object" && navigator.language) || "C").replace( + "-", + "_" + ) + ".UTF-8"; + var env = { + USER: "web_user", + LOGNAME: "web_user", + PATH: "/", + PWD: "/", + HOME: "/home/web_user", + LANG: lang, + _: getExecutableName() + }; + // Apply the user-provided values, if any. + for (var x in ENV) { + // x is a key in ENV; if ENV[x] is undefined, that means it was + // explicitly set to be so. We allow user code to do that to + // force variables with default values to remain unset. + if (ENV[x] === undefined) delete env[x]; + else env[x] = ENV[x]; + } + var strings = []; + for (var x in env) { + strings.push(`${x}=${env[x]}`); + } + getEnvStrings.strings = strings; + } + return getEnvStrings.strings; + }; + + var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => { + assert( + typeof str === "string", + `stringToUTF8Array expects a string (got ${typeof str})` + ); + // Parameter maxBytesToWrite is not optional. Negative values, 0, null, + // undefined and false each don't write out any bytes. + if (!(maxBytesToWrite > 0)) return 0; + + var startIdx = outIdx; + var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator. + for (var i = 0; i < str.length; ++i) { + // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description + // and https://www.ietf.org/rfc/rfc2279.txt + // and https://tools.ietf.org/html/rfc3629 + var u = str.codePointAt(i); + if (u <= 0x7f) { + if (outIdx >= endIdx) break; + heap[outIdx++] = u; + } else if (u <= 0x7ff) { + if (outIdx + 1 >= endIdx) break; + heap[outIdx++] = 0xc0 | (u >> 6); + heap[outIdx++] = 0x80 | (u & 63); + } else if (u <= 0xffff) { + if (outIdx + 2 >= endIdx) break; + heap[outIdx++] = 0xe0 | (u >> 12); + heap[outIdx++] = 0x80 | ((u >> 6) & 63); + heap[outIdx++] = 0x80 | (u & 63); + } else { + if (outIdx + 3 >= endIdx) break; + if (u > 0x10ffff) + warnOnce( + "Invalid Unicode code point " + + ptrToString(u) + + " encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF)." + ); + heap[outIdx++] = 0xf0 | (u >> 18); + heap[outIdx++] = 0x80 | ((u >> 12) & 63); + heap[outIdx++] = 0x80 | ((u >> 6) & 63); + heap[outIdx++] = 0x80 | (u & 63); + // Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16. + // We need to manually skip over the second code unit for correct iteration. + i++; + } + } + // Null-terminate the pointer to the buffer. + heap[outIdx] = 0; + return outIdx - startIdx; + }; + var stringToUTF8 = (str, outPtr, maxBytesToWrite) => { + assert( + typeof maxBytesToWrite == "number", + "stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!" + ); + return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite); + }; + var _environ_get = (__environ, environ_buf) => { + var bufSize = 0; + var envp = 0; + for (var string of getEnvStrings()) { + var ptr = environ_buf + bufSize; + HEAPU32[(__environ + envp) >> 2] = ptr; + bufSize += stringToUTF8(string, ptr, Infinity) + 1; + envp += 4; + } + return 0; + }; + + var lengthBytesUTF8 = str => { + var len = 0; + for (var i = 0; i < str.length; ++i) { + // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code + // unit, not a Unicode code point of the character! So decode + // UTF16->UTF32->UTF8. + // See http://unicode.org/faq/utf_bom.html#utf16-3 + var c = str.charCodeAt(i); // possibly a lead surrogate + if (c <= 0x7f) { + len++; + } else if (c <= 0x7ff) { + len += 2; + } else if (c >= 0xd800 && c <= 0xdfff) { + len += 4; + ++i; + } else { + len += 3; + } + } + return len; + }; + var _environ_sizes_get = (penviron_count, penviron_buf_size) => { + var strings = getEnvStrings(); + HEAPU32[penviron_count >> 2] = strings.length; + var bufSize = 0; + for (var string of strings) { + bufSize += lengthBytesUTF8(string) + 1; + } + HEAPU32[penviron_buf_size >> 2] = bufSize; + return 0; + }; + + var runtimeKeepaliveCounter = 0; + var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0; + var _proc_exit = code => { + EXITSTATUS = code; + if (!keepRuntimeAlive()) { + Module["onExit"]?.(code); + ABORT = true; + } + quit_(code, new ExitStatus(code)); + }; + + /** @param {boolean|number=} implicit */ + var exitJS = (status, implicit) => { + EXITSTATUS = status; + + checkUnflushedContent(); + + // if exit() was called explicitly, warn the user if the runtime isn't actually being shut down + if (keepRuntimeAlive() && !implicit) { + var msg = `program exited (with status: ${status}), but keepRuntimeAlive() is set (counter=${runtimeKeepaliveCounter}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`; + readyPromiseReject?.(msg); + err(msg); + } + + _proc_exit(status); + }; + var _exit = exitJS; + + var _fd_close = fd => { + abort("fd_close called without SYSCALLS_REQUIRE_FILESYSTEM"); + }; + + function _fd_seek(fd, offset, whence, newOffset) { + offset = bigintToI53Checked(offset); + + return 70; + } + + var printCharBuffers = [null, [], []]; + + var printChar = (stream, curr) => { + var buffer = printCharBuffers[stream]; + assert(buffer); + if (curr === 0 || curr === 10) { + (stream === 1 ? out : err)(UTF8ArrayToString(buffer)); + buffer.length = 0; + } else { + buffer.push(curr); + } + }; + + var flush_NO_FILESYSTEM = () => { + // flush anything remaining in the buffers during shutdown + _fflush(0); + if (printCharBuffers[1].length) printChar(1, 10); + if (printCharBuffers[2].length) printChar(2, 10); + }; + + var _fd_write = (fd, iov, iovcnt, pnum) => { + // hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0 + var num = 0; + for (var i = 0; i < iovcnt; i++) { + var ptr = HEAPU32[iov >> 2]; + var len = HEAPU32[(iov + 4) >> 2]; + iov += 8; + for (var j = 0; j < len; j++) { + printChar(fd, HEAPU8[ptr + j]); + } + num += len; + } + HEAPU32[pnum >> 2] = num; + return 0; + }; + + var wasmTableMirror = []; + + var getWasmTableEntry = funcPtr => { + var func = wasmTableMirror[funcPtr]; + if (!func) { + /** @suppress {checkTypes} */ + wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr); + } + /** @suppress {checkTypes} */ + assert( + wasmTable.get(funcPtr) == func, + "JavaScript-side Wasm function table mirror is out of date!" + ); + return func; + }; + // End JS library code + + // include: postlibrary.js + // This file is included after the automatically-generated JS library code + // but before the wasm module is created. + + { + // Begin ATMODULES hooks + if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"]; + if (Module["print"]) out = Module["print"]; + if (Module["printErr"]) err = Module["printErr"]; + if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"]; + + Module["FS_createDataFile"] = FS.createDataFile; + Module["FS_createPreloadedFile"] = FS.createPreloadedFile; + + // End ATMODULES hooks + + checkIncomingModuleAPI(); + + if (Module["arguments"]) arguments_ = Module["arguments"]; + if (Module["thisProgram"]) thisProgram = Module["thisProgram"]; + + // Assertions on removed incoming Module JS APIs. + assert( + typeof Module["memoryInitializerPrefixURL"] == "undefined", + "Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead" + ); + assert( + typeof Module["pthreadMainPrefixURL"] == "undefined", + "Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead" + ); + assert( + typeof Module["cdInitializerPrefixURL"] == "undefined", + "Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead" + ); + assert( + typeof Module["filePackagePrefixURL"] == "undefined", + "Module.filePackagePrefixURL option was removed, use Module.locateFile instead" + ); + assert( + typeof Module["read"] == "undefined", + "Module.read option was removed" + ); + assert( + typeof Module["readAsync"] == "undefined", + "Module.readAsync option was removed (modify readAsync in JS)" + ); + assert( + typeof Module["readBinary"] == "undefined", + "Module.readBinary option was removed (modify readBinary in JS)" + ); + assert( + typeof Module["setWindowTitle"] == "undefined", + "Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)" + ); + assert( + typeof Module["TOTAL_MEMORY"] == "undefined", + "Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY" + ); + assert( + typeof Module["ENVIRONMENT"] == "undefined", + "Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)" + ); + assert( + typeof Module["STACK_SIZE"] == "undefined", + "STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time" + ); + // If memory is defined in wasm, the user can't provide it, or set INITIAL_MEMORY + assert( + typeof Module["wasmMemory"] == "undefined", + "Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally" + ); + assert( + typeof Module["INITIAL_MEMORY"] == "undefined", + "Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically" + ); + + if (Module["preInit"]) { + if (typeof Module["preInit"] == "function") + Module["preInit"] = [Module["preInit"]]; + while (Module["preInit"].length > 0) { + Module["preInit"].shift()(); + } + } + consumedModuleProp("preInit"); + } + + // Begin runtime exports + var missingLibrarySymbols = [ + "writeI53ToI64", + "writeI53ToI64Clamped", + "writeI53ToI64Signaling", + "writeI53ToU64Clamped", + "writeI53ToU64Signaling", + "readI53FromI64", + "readI53FromU64", + "convertI32PairToI53", + "convertI32PairToI53Checked", + "convertU32PairToI53", + "stackAlloc", + "getTempRet0", + "createNamedFunction", + "zeroMemory", + "withStackSave", + "strError", + "inetPton4", + "inetNtop4", + "inetPton6", + "inetNtop6", + "readSockaddr", + "writeSockaddr", + "readEmAsmArgs", + "jstoi_q", + "autoResumeAudioContext", + "getDynCaller", + "dynCall", + "handleException", + "runtimeKeepalivePush", + "runtimeKeepalivePop", + "callUserCallback", + "maybeExit", + "asyncLoad", + "asmjsMangle", + "mmapAlloc", + "HandleAllocator", + "getUniqueRunDependency", + "addRunDependency", + "removeRunDependency", + "addOnInit", + "addOnPostCtor", + "addOnPreMain", + "addOnExit", + "STACK_SIZE", + "STACK_ALIGN", + "POINTER_SIZE", + "ASSERTIONS", + "ccall", + "cwrap", + "convertJsFunctionToWasm", + "getEmptyTableSlot", + "updateTableMap", + "getFunctionAddress", + "addFunction", + "removeFunction", + "intArrayFromString", + "intArrayToString", + "AsciiToString", + "stringToAscii", + "UTF16ToString", + "stringToUTF16", + "lengthBytesUTF16", + "UTF32ToString", + "stringToUTF32", + "lengthBytesUTF32", + "stringToNewUTF8", + "stringToUTF8OnStack", + "writeArrayToMemory", + "registerKeyEventCallback", + "maybeCStringToJsString", + "findEventTarget", + "getBoundingClientRect", + "fillMouseEventData", + "registerMouseEventCallback", + "registerWheelEventCallback", + "registerUiEventCallback", + "registerFocusEventCallback", + "fillDeviceOrientationEventData", + "registerDeviceOrientationEventCallback", + "fillDeviceMotionEventData", + "registerDeviceMotionEventCallback", + "screenOrientation", + "fillOrientationChangeEventData", + "registerOrientationChangeEventCallback", + "fillFullscreenChangeEventData", + "registerFullscreenChangeEventCallback", + "JSEvents_requestFullscreen", + "JSEvents_resizeCanvasForFullscreen", + "registerRestoreOldStyle", + "hideEverythingExceptGivenElement", + "restoreHiddenElements", + "setLetterbox", + "softFullscreenResizeWebGLRenderTarget", + "doRequestFullscreen", + "fillPointerlockChangeEventData", + "registerPointerlockChangeEventCallback", + "registerPointerlockErrorEventCallback", + "requestPointerLock", + "fillVisibilityChangeEventData", + "registerVisibilityChangeEventCallback", + "registerTouchEventCallback", + "fillGamepadEventData", + "registerGamepadEventCallback", + "registerBeforeUnloadEventCallback", + "fillBatteryEventData", + "registerBatteryEventCallback", + "setCanvasElementSize", + "getCanvasElementSize", + "jsStackTrace", + "getCallstack", + "convertPCtoSourceLocation", + "wasiRightsToMuslOFlags", + "wasiOFlagsToMuslOFlags", + "initRandomFill", + "randomFill", + "safeSetTimeout", + "setImmediateWrapped", + "safeRequestAnimationFrame", + "clearImmediateWrapped", + "registerPostMainLoop", + "registerPreMainLoop", + "getPromise", + "makePromise", + "idsToPromises", + "makePromiseCallback", + "Browser_asyncPrepareDataCounter", + "isLeapYear", + "ydayFromDate", + "arraySum", + "addDays", + "getSocketFromFD", + "getSocketAddress", + "heapObjectForWebGLType", + "toTypedArrayIndex", + "webgl_enable_ANGLE_instanced_arrays", + "webgl_enable_OES_vertex_array_object", + "webgl_enable_WEBGL_draw_buffers", + "webgl_enable_WEBGL_multi_draw", + "webgl_enable_EXT_polygon_offset_clamp", + "webgl_enable_EXT_clip_control", + "webgl_enable_WEBGL_polygon_mode", + "emscriptenWebGLGet", + "computeUnpackAlignedImageSize", + "colorChannelsInGlTextureFormat", + "emscriptenWebGLGetTexPixelData", + "emscriptenWebGLGetUniform", + "webglGetUniformLocation", + "webglPrepareUniformLocationsBeforeFirstUse", + "webglGetLeftBracePos", + "emscriptenWebGLGetVertexAttrib", + "__glGetActiveAttribOrUniform", + "writeGLArray", + "registerWebGlEventCallback", + "runAndAbortIfError", + "ALLOC_NORMAL", + "ALLOC_STACK", + "allocate", + "writeStringToMemory", + "writeAsciiToMemory", + "allocateUTF8", + "allocateUTF8OnStack", + "demangle", + "stackTrace", + "getNativeTypeSize" + ]; + missingLibrarySymbols.forEach(missingLibrarySymbol); + + var unexportedSymbols = [ + "run", + "out", + "err", + "callMain", + "abort", + "wasmExports", + "HEAPF32", + "HEAPF64", + "HEAP8", + "HEAP16", + "HEAPU16", + "HEAP32", + "HEAPU32", + "HEAP64", + "HEAPU64", + "writeStackCookie", + "checkStackCookie", + "INT53_MAX", + "INT53_MIN", + "bigintToI53Checked", + "stackSave", + "stackRestore", + "setTempRet0", + "ptrToString", + "exitJS", + "getHeapMax", + "growMemory", + "ENV", + "ERRNO_CODES", + "DNS", + "Protocols", + "Sockets", + "timers", + "warnOnce", + "readEmAsmArgsArray", + "getExecutableName", + "keepRuntimeAlive", + "alignMemory", + "wasmTable", + "wasmMemory", + "noExitRuntime", + "addOnPreRun", + "addOnPostRun", + "freeTableIndexes", + "functionsInTableMap", + "setValue", + "getValue", + "PATH", + "PATH_FS", + "UTF8Decoder", + "UTF8ArrayToString", + "UTF8ToString", + "stringToUTF8Array", + "stringToUTF8", + "lengthBytesUTF8", + "UTF16Decoder", + "JSEvents", + "specialHTMLTargets", + "findCanvasEventTarget", + "currentFullscreenStrategy", + "restoreOldWindowedStyle", + "UNWIND_CACHE", + "ExitStatus", + "getEnvStrings", + "checkWasiClock", + "flush_NO_FILESYSTEM", + "emSetImmediate", + "emClearImmediate_deps", + "emClearImmediate", + "promiseMap", + "uncaughtExceptionCount", + "exceptionLast", + "exceptionCaught", + "ExceptionInfo", + "findMatchingCatch", + "Browser", + "requestFullscreen", + "requestFullScreen", + "setCanvasSize", + "getUserMedia", + "createContext", + "getPreloadedImageData__data", + "wget", + "MONTH_DAYS_REGULAR", + "MONTH_DAYS_LEAP", + "MONTH_DAYS_REGULAR_CUMULATIVE", + "MONTH_DAYS_LEAP_CUMULATIVE", + "SYSCALLS", + "tempFixedLengthArray", + "miniTempWebGLFloatBuffers", + "miniTempWebGLIntBuffers", + "GL", + "AL", + "GLUT", + "EGL", + "GLEW", + "IDBStore", + "SDL", + "SDL_gfx", + "print", + "printErr", + "jstoi_s" + ]; + unexportedSymbols.forEach(unexportedRuntimeSymbol); + + // End runtime exports + // Begin JS library exports + // End JS library exports + + // end include: postlibrary.js + + function checkIncomingModuleAPI() { + ignoredModuleProp("fetchSettings"); + } + + // Imports from the Wasm binary. + var _solve_problem = (Module["_solve_problem"] = makeInvalidEarlyAccess( + "_solve_problem" + )); + var _enumerate_answers_problem = (Module[ + "_enumerate_answers_problem" + ] = makeInvalidEarlyAccess("_enumerate_answers_problem")); + var _free = (Module["_free"] = makeInvalidEarlyAccess("_free")); + var _malloc = (Module["_malloc"] = makeInvalidEarlyAccess("_malloc")); + var _fflush = makeInvalidEarlyAccess("_fflush"); + var _emscripten_stack_get_end = makeInvalidEarlyAccess( + "_emscripten_stack_get_end" + ); + var _emscripten_stack_get_base = makeInvalidEarlyAccess( + "_emscripten_stack_get_base" + ); + var _htonl = makeInvalidEarlyAccess("_htonl"); + var _htons = makeInvalidEarlyAccess("_htons"); + var _ntohs = makeInvalidEarlyAccess("_ntohs"); + var __emscripten_tempret_set = makeInvalidEarlyAccess( + "__emscripten_tempret_set" + ); + var _emscripten_stack_init = makeInvalidEarlyAccess("_emscripten_stack_init"); + var _emscripten_stack_get_free = makeInvalidEarlyAccess( + "_emscripten_stack_get_free" + ); + var __emscripten_stack_restore = makeInvalidEarlyAccess( + "__emscripten_stack_restore" + ); + var __emscripten_stack_alloc = makeInvalidEarlyAccess( + "__emscripten_stack_alloc" + ); + var _emscripten_stack_get_current = makeInvalidEarlyAccess( + "_emscripten_stack_get_current" + ); + var ___cxa_can_catch = makeInvalidEarlyAccess("___cxa_can_catch"); + var memory = makeInvalidEarlyAccess("memory"); + var __indirect_function_table = makeInvalidEarlyAccess( + "__indirect_function_table" + ); + var wasmMemory = makeInvalidEarlyAccess("wasmMemory"); + var wasmTable = makeInvalidEarlyAccess("wasmTable"); + + function assignWasmExports(wasmExports) { + assert( + typeof wasmExports["solve_problem"] != "undefined", + "missing Wasm export: solve_problem" + ); + _solve_problem = Module["_solve_problem"] = createExportWrapper( + "solve_problem", + 2 + ); + assert( + typeof wasmExports["enumerate_answers_problem"] != "undefined", + "missing Wasm export: enumerate_answers_problem" + ); + _enumerate_answers_problem = Module[ + "_enumerate_answers_problem" + ] = createExportWrapper("enumerate_answers_problem", 3); + assert( + typeof wasmExports["free"] != "undefined", + "missing Wasm export: free" + ); + _free = Module["_free"] = createExportWrapper("free", 1); + assert( + typeof wasmExports["malloc"] != "undefined", + "missing Wasm export: malloc" + ); + _malloc = Module["_malloc"] = createExportWrapper("malloc", 1); + assert( + typeof wasmExports["fflush"] != "undefined", + "missing Wasm export: fflush" + ); + _fflush = createExportWrapper("fflush", 1); + assert( + typeof wasmExports["emscripten_stack_get_end"] != "undefined", + "missing Wasm export: emscripten_stack_get_end" + ); + _emscripten_stack_get_end = wasmExports["emscripten_stack_get_end"]; + assert( + typeof wasmExports["emscripten_stack_get_base"] != "undefined", + "missing Wasm export: emscripten_stack_get_base" + ); + _emscripten_stack_get_base = wasmExports["emscripten_stack_get_base"]; + assert( + typeof wasmExports["htonl"] != "undefined", + "missing Wasm export: htonl" + ); + _htonl = createExportWrapper("htonl", 1); + assert( + typeof wasmExports["htons"] != "undefined", + "missing Wasm export: htons" + ); + _htons = createExportWrapper("htons", 1); + assert( + typeof wasmExports["ntohs"] != "undefined", + "missing Wasm export: ntohs" + ); + _ntohs = createExportWrapper("ntohs", 1); + assert( + typeof wasmExports["_emscripten_tempret_set"] != "undefined", + "missing Wasm export: _emscripten_tempret_set" + ); + __emscripten_tempret_set = createExportWrapper( + "_emscripten_tempret_set", + 1 + ); + assert( + typeof wasmExports["emscripten_stack_init"] != "undefined", + "missing Wasm export: emscripten_stack_init" + ); + _emscripten_stack_init = wasmExports["emscripten_stack_init"]; + assert( + typeof wasmExports["emscripten_stack_get_free"] != "undefined", + "missing Wasm export: emscripten_stack_get_free" + ); + _emscripten_stack_get_free = wasmExports["emscripten_stack_get_free"]; + assert( + typeof wasmExports["_emscripten_stack_restore"] != "undefined", + "missing Wasm export: _emscripten_stack_restore" + ); + __emscripten_stack_restore = wasmExports["_emscripten_stack_restore"]; + assert( + typeof wasmExports["_emscripten_stack_alloc"] != "undefined", + "missing Wasm export: _emscripten_stack_alloc" + ); + __emscripten_stack_alloc = wasmExports["_emscripten_stack_alloc"]; + assert( + typeof wasmExports["emscripten_stack_get_current"] != "undefined", + "missing Wasm export: emscripten_stack_get_current" + ); + _emscripten_stack_get_current = wasmExports["emscripten_stack_get_current"]; + assert( + typeof wasmExports["__cxa_can_catch"] != "undefined", + "missing Wasm export: __cxa_can_catch" + ); + ___cxa_can_catch = createExportWrapper("__cxa_can_catch", 3); + assert( + typeof wasmExports["memory"] != "undefined", + "missing Wasm export: memory" + ); + memory = wasmMemory = wasmExports["memory"]; + assert( + typeof wasmExports["__indirect_function_table"] != "undefined", + "missing Wasm export: __indirect_function_table" + ); + __indirect_function_table = wasmTable = + wasmExports["__indirect_function_table"]; + } + + var wasmImports = { + /** @export */ + __assert_fail: ___assert_fail, + /** @export */ + __cxa_find_matching_catch_2: ___cxa_find_matching_catch_2, + /** @export */ + __resumeException: ___resumeException, + /** @export */ + __syscall_getcwd: ___syscall_getcwd, + /** @export */ + _abort_js: __abort_js, + /** @export */ + clock_time_get: _clock_time_get, + /** @export */ + emscripten_resize_heap: _emscripten_resize_heap, + /** @export */ + environ_get: _environ_get, + /** @export */ + environ_sizes_get: _environ_sizes_get, + /** @export */ + exit: _exit, + /** @export */ + fd_close: _fd_close, + /** @export */ + fd_seek: _fd_seek, + /** @export */ + fd_write: _fd_write, + /** @export */ + invoke_ii, + /** @export */ + invoke_iiii, + /** @export */ + invoke_iiiiii, + /** @export */ + invoke_vi, + /** @export */ + invoke_vii, + /** @export */ + invoke_viii, + /** @export */ + invoke_viiii, + /** @export */ + invoke_viiiii + }; + + function invoke_vi(index, a1) { + var sp = stackSave(); + try { + getWasmTableEntry(index)(a1); + } catch (e) { + stackRestore(sp); + if (e !== e + 0) throw e; + _setThrew(1, 0); + } + } + + function invoke_vii(index, a1, a2) { + var sp = stackSave(); + try { + getWasmTableEntry(index)(a1, a2); + } catch (e) { + stackRestore(sp); + if (e !== e + 0) throw e; + _setThrew(1, 0); + } + } + + function invoke_viii(index, a1, a2, a3) { + var sp = stackSave(); + try { + getWasmTableEntry(index)(a1, a2, a3); + } catch (e) { + stackRestore(sp); + if (e !== e + 0) throw e; + _setThrew(1, 0); + } + } + + function invoke_ii(index, a1) { + var sp = stackSave(); + try { + return getWasmTableEntry(index)(a1); + } catch (e) { + stackRestore(sp); + if (e !== e + 0) throw e; + _setThrew(1, 0); + } + } + + function invoke_viiiii(index, a1, a2, a3, a4, a5) { + var sp = stackSave(); + try { + getWasmTableEntry(index)(a1, a2, a3, a4, a5); + } catch (e) { + stackRestore(sp); + if (e !== e + 0) throw e; + _setThrew(1, 0); + } + } + + function invoke_viiii(index, a1, a2, a3, a4) { + var sp = stackSave(); + try { + getWasmTableEntry(index)(a1, a2, a3, a4); + } catch (e) { + stackRestore(sp); + if (e !== e + 0) throw e; + _setThrew(1, 0); + } + } + + function invoke_iiii(index, a1, a2, a3) { + var sp = stackSave(); + try { + return getWasmTableEntry(index)(a1, a2, a3); + } catch (e) { + stackRestore(sp); + if (e !== e + 0) throw e; + _setThrew(1, 0); + } + } + + function invoke_iiiiii(index, a1, a2, a3, a4, a5) { + var sp = stackSave(); + try { + return getWasmTableEntry(index)(a1, a2, a3, a4, a5); + } catch (e) { + stackRestore(sp); + if (e !== e + 0) throw e; + _setThrew(1, 0); + } + } + + // include: postamble.js + // === Auto-generated postamble setup entry stuff === + + var calledRun; + + function stackCheckInit() { + // This is normally called automatically during __wasm_call_ctors but need to + // get these values before even running any of the ctors so we call it redundantly + // here. + _emscripten_stack_init(); + // TODO(sbc): Move writeStackCookie to native to to avoid this. + writeStackCookie(); + } + + function run() { + stackCheckInit(); + + preRun(); + + function doRun() { + // run may have just been called through dependencies being fulfilled just in this very frame, + // or while the async setStatus time below was happening + assert(!calledRun); + calledRun = true; + Module["calledRun"] = true; + + if (ABORT) return; + + initRuntime(); + + readyPromiseResolve?.(Module); + Module["onRuntimeInitialized"]?.(); + consumedModuleProp("onRuntimeInitialized"); + + assert( + !Module["_main"], + 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]' + ); + + postRun(); + } + + if (Module["setStatus"]) { + Module["setStatus"]("Running..."); + setTimeout(() => { + setTimeout(() => Module["setStatus"](""), 1); + doRun(); + }, 1); + } else { + doRun(); + } + checkStackCookie(); + } + + function checkUnflushedContent() { + // Compiler settings do not allow exiting the runtime, so flushing + // the streams is not possible. but in ASSERTIONS mode we check + // if there was something to flush, and if so tell the user they + // should request that the runtime be exitable. + // Normally we would not even include flush() at all, but in ASSERTIONS + // builds we do so just for this check, and here we see if there is any + // content to flush, that is, we check if there would have been + // something a non-ASSERTIONS build would have not seen. + // How we flush the streams depends on whether we are in SYSCALLS_REQUIRE_FILESYSTEM=0 + // mode (which has its own special function for this; otherwise, all + // the code is inside libc) + var oldOut = out; + var oldErr = err; + var has = false; + out = err = x => { + has = true; + }; + try { + // it doesn't matter if it fails + flush_NO_FILESYSTEM(); + } catch (e) {} + out = oldOut; + err = oldErr; + if (has) { + warnOnce( + "stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc." + ); + warnOnce( + "(this may also be due to not including full filesystem support - try building with -sFORCE_FILESYSTEM)" + ); + } + } + + var wasmExports; + + // In modularize mode the generated code is within a factory function so we + // can use await here (since it's not top-level-await). + wasmExports = await createWasm(); + + run(); + + // end include: postamble.js + + // include: postamble_modularize.js + // In MODULARIZE mode we wrap the generated code in a factory function + // and return either the Module itself, or a promise of the module. + // + // We assign to the `moduleRtn` global here and configure closure to see + // this as and extern so it won't get minified. + + if (runtimeInitialized) { + moduleRtn = Module; + } else { + // Set up the promise that indicates the Module is initialized + moduleRtn = new Promise((resolve, reject) => { + readyPromiseResolve = resolve; + readyPromiseReject = reject; + }); + } + + // Assertion for attempting to access module properties on the incoming + // moduleArg. In the past we used this object as the prototype of the module + // and assigned properties to it, but now we return a distinct object. This + // keeps the instance private until it is ready (i.e the promise has been + // resolved). + for (const prop of Object.keys(Module)) { + if (!(prop in moduleArg)) { + Object.defineProperty(moduleArg, prop, { + configurable: true, + get() { + abort( + `Access to module property ('${prop}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.` + ); + } + }); + } + } + // end include: postamble_modularize.js + + return moduleRtn; } // Export using a UMD style export, or ES6 exports if selected export default Module; - diff --git a/src/solver/cspuz_solver_backend.js:Zone.Identifier b/src/solver/cspuz_solver_backend.js:Zone.Identifier new file mode 100644 index 000000000..e69de29bb diff --git a/src/variety-common/Graphic.js b/src/variety-common/Graphic.js index 2d04fa936..13516e551 100644 --- a/src/variety-common/Graphic.js +++ b/src/variety-common/Graphic.js @@ -39,14 +39,20 @@ pzpr.classmgr.makeCommon({ }, getColorSolverAware: function(a, b, c) { - return a && b ? this.solverqanscolor : b ? this.solvercolor : c || this.qanscolor + return a && b + ? this.solverqanscolor + : b + ? this.solvercolor + : c || this.qanscolor; }, - isSameSymbol: function (answerKey, answerDict, solverKey, solverDict) { + isSameSymbol: function(answerKey, answerDict, solverKey, solverDict) { var l = answerDict.length; var overlap = 0; for (var i = 0; i < l; i++) { - if (answerKey === answerDict[i] && solverKey === solverDict[i]) { overlap = 1; } + if (answerKey === answerDict[i] && solverKey === solverDict[i]) { + overlap = 1; + } } return overlap; }, @@ -60,7 +66,7 @@ pzpr.classmgr.makeCommon({ this.drawCells_common("c_fulls_", this.getShadedCellColor); }, getShadedCellColor: function(cell) { - if (cell.qans !== 1 && cell.qansBySolver !==1) { + if (cell.qans !== 1 && cell.qansBySolver !== 1) { return null; } var hasinfo = this.board.haserror || this.board.hasinfo; @@ -74,7 +80,11 @@ pzpr.classmgr.makeCommon({ } else if (this.puzzle.execConfig("irowakeblk") && !hasinfo) { return cell.sblk.color; } - return this.getColorSolverAware(1 === cell.qans, 1 === cell.qansBySolver, this.shadecolor); + return this.getColorSolverAware( + 1 === cell.qans, + 1 === cell.qansBySolver, + this.shadecolor + ); }, //--------------------------------------------------------------------------- @@ -131,7 +141,7 @@ pzpr.classmgr.makeCommon({ } return null; }, - getBGCellColor_qsub1: function (cell) { + getBGCellColor_qsub1: function(cell) { if ((cell.error || cell.qinfo) === 1) { return this.errbcolor1; } else if (cell.qsub === 1 /*|| cell.qsubBySolver === 1*/) { @@ -249,7 +259,9 @@ pzpr.classmgr.makeCommon({ g.vid = "c_dot_" + cell.id; if (cell.isDot()) { - g.fillStyle = !cell.trial ? this.getColorSolverAware(1 === cell.qsub, 1 === cell.qsubBySolver) : this.trialcolor; + g.fillStyle = !cell.trial + ? this.getColorSolverAware(1 === cell.qsub, 1 === cell.qsubBySolver) + : this.trialcolor; g.fillCircle(cell.bx * this.bw, cell.by * this.bh, dsize); } else { g.vhide(); @@ -258,7 +270,7 @@ pzpr.classmgr.makeCommon({ this.drawDotForSolverCells(); }, - drawDotForSolverCells: function () { + drawDotForSolverCells: function() { var g = this.vinc("cell_dot_for_solver", "auto", true); var dsize = Math.max(this.cw * 0.06, 2); @@ -268,7 +280,9 @@ pzpr.classmgr.makeCommon({ g.vid = "c_dot_for_solver" + cell.id; if (cell.isDotBySolver()) { - g.fillStyle = !cell.trial ? this.getColorSolverAware(1 === cell.qsub, 1 === cell.qsubBySolver) : this.trialcolor; + g.fillStyle = !cell.trial + ? this.getColorSolverAware(1 === cell.qsub, 1 === cell.qsubBySolver) + : this.trialcolor; g.fillCircle(cell.bx * this.bw, cell.by * this.bh, dsize); } else { g.vhide(); @@ -495,7 +509,15 @@ pzpr.classmgr.makeCommon({ } else if (cell.trial) { color = this.linetrialcolor; } else { - color = (1 === this.isSameSymbol(cell.qans, [31, 32, 33], cell.qansBySolver, [31, 32, 33])) ? this.solverqanscolor : this.linecolor; + color = + 1 === + this.isSameSymbol(cell.qans, [31, 32, 33], cell.qansBySolver, [ + 31, + 32, + 33 + ]) + ? this.solverqanscolor + : this.linecolor; } g.lineWidth = basewidth + addwidth; @@ -533,7 +555,7 @@ pzpr.classmgr.makeCommon({ this.drawSlashesForSolver(); }, - drawSlashesForSolver: function () { + drawSlashesForSolver: function() { var g = this.vinc("cell_slash_for_solver", "auto"); var basewidth = Math.max(this.bw / 4, 2); @@ -587,7 +609,15 @@ pzpr.classmgr.makeCommon({ } else if (cell.trial) { color = this.linetrialcolor; } else { - color = (1 === this.isSameSymbol(cell.qans, [31, 32, 33], cell.qansBySolver, [31, 32, 33])) ? this.solverqanscolor : this.solvercolor; + color = + 1 === + this.isSameSymbol(cell.qans, [31, 32, 33], cell.qansBySolver, [ + 31, + 32, + 33 + ]) + ? this.solverqanscolor + : this.solvercolor; } g.lineWidth = basewidth + addwidth; @@ -652,14 +682,14 @@ pzpr.classmgr.makeCommon({ this.drawCandidateNumbers(); }, drawSolverAnsNumbers: function() { - this.vinc("cell_solver_ans_number", "auto"); + this.vinc("cell_solver_ans_number", "auto"); this.drawNumbers_com( - this.getSolverAnsNumberText, - this.getSolverAnsNumberColor, + this.getSolverAnsNumberText, + this.getSolverAnsNumberColor, "cell_solver_ans_text_", - {} + {} ); - }, + }, drawHatenas: function() { function getQuesHatenaText(cell) { return cell.ques === -2 || cell.qnum === -2 ? "?" : ""; @@ -704,9 +734,11 @@ pzpr.classmgr.makeCommon({ return this.getNumberText(cell, cell.anum); }, getSolverAnsNumberText: function(cell) { - if (cell.qnumBySolver === -1) {return ""} - return this.getNumberText(cell, cell.qnumBySolver); - }, + if (cell.qnumBySolver === -1) { + return ""; + } + return this.getNumberText(cell, cell.qnumBySolver); + }, getNumberText: function(cell, num) { if (!cell.numberAsLetter) { @@ -776,8 +808,8 @@ pzpr.classmgr.makeCommon({ }, getSolverAnsNumberColor: function(cell) { - return this.solvercolor - }, + return this.solvercolor; + }, //--------------------------------------------------------------------------- // pc.drawNumbersExCell() ExCellの数字をCanvasに書き込む @@ -836,15 +868,28 @@ pzpr.classmgr.makeCommon({ }, drawCandidateNumbers: function(a) { - for (var b = this.vinc("cell_candnumber", "auto"), c = Math.round(Math.sqrt(a)), d = this.range.cells, e = 0; e < d.length; e++){ + for ( + var b = this.vinc("cell_candnumber", "auto"), + c = Math.round(Math.sqrt(a)), + d = this.range.cells, + e = 0; + e < d.length; + e++ + ) { for (var f = d[e], g = f.qcandBySolver, h = 0; h < a; ++h) { - b.vid = "cell_candtext_" + f.id + "_" + h; - g && g[h] ? (b.fillStyle = this.solvercolor, this.disptext(h + 1 + "", - (f.bx + (h % c + .5) / c * 2 - 1) * this.bw, (f.by + (Math.floor(h / c) + .5) - / c * 2 - 1) * this.bh, {ratio: 1 / c * .9, hoffset: 0 - })) : b.vhide() - }}}, - + b.vid = "cell_candtext_" + f.id + "_" + h; + g && g[h] + ? ((b.fillStyle = this.solvercolor), + this.disptext( + h + 1 + "", + (f.bx + (((h % c) + 0.5) / c) * 2 - 1) * this.bw, + (f.by + ((Math.floor(h / c) + 0.5) / c) * 2 - 1) * this.bh, + { ratio: (1 / c) * 0.9, hoffset: 0 } + )) + : b.vhide(); + } + } + }, //--------------------------------------------------------------------------- // pc.drawArrowNumbers() Cellの数字と矢印をCanvasに書き込む @@ -1206,7 +1251,10 @@ pzpr.classmgr.makeCommon({ } else if (border.trial) { return this.linetrialcolor; } else { - return this.getColorSolverAware(border.isBorder(), 1 === border.edgeBySolver); + return this.getColorSolverAware( + border.isBorder(), + 1 === border.edgeBySolver + ); } } else if (!!border.isCmp && border.isCmp()) { return this.qcmpcolor; @@ -1272,7 +1320,13 @@ pzpr.classmgr.makeCommon({ if (border.qsub === 1 || border.qsubBySolver === 2) { var px = border.bx * this.bw + this.getBorderHorizontalOffset(border), py = border.by * this.bh; - g.fillStyle = !border.trial ? this.getColorSolverAware(1 === border.qsub, 2 === border.qsubBySolver, this.pekecolor) : this.linetrialcolor; + g.fillStyle = !border.trial + ? this.getColorSolverAware( + 1 === border.qsub, + 2 === border.qsubBySolver, + this.pekecolor + ) + : this.linetrialcolor; if (border.isHorz()) { g.fillRectCenter(px, py, 0.5, this.bh - m); } else { @@ -1460,7 +1514,12 @@ pzpr.classmgr.makeCommon({ } else if (isIrowake) { return border.path.color; } else { - return border.trial ? this.linetrialcolor : this.getColorSolverAware(1 === border.line, 1 === border.lineBySolver); + return border.trial + ? this.linetrialcolor + : this.getColorSolverAware( + 1 === border.line, + 1 === border.lineBySolver + ); } } return null; @@ -1584,7 +1643,12 @@ pzpr.classmgr.makeCommon({ var border = blist[i]; g.vid = "b_peke_" + border.id; if (border.qsub === 2 || border.qsubBySolver === 2) { - g.strokeStyle = !border.trial ? this.getColorSolverAware(2 === border.qsub, 2 === border.qsubBySolver) : this.trialcolor; + g.strokeStyle = !border.trial + ? this.getColorSolverAware( + 2 === border.qsub, + 2 === border.qsubBySolver + ) + : this.trialcolor; g.strokeCross(border.bx * this.bw, border.by * this.bh, size - 1); } else { g.vhide(); @@ -1624,22 +1688,19 @@ pzpr.classmgr.makeCommon({ for (var i = 0; i < clist.length; i++) { var cell = clist[i], num = cell.ques !== 0 ? cell.ques : cell.qans; - snum = cell.qansBySolver; + snum = cell.qansBySolver; g.vid = "c_tri_" + cell.id; if (num >= 2 && num <= 5) { g.fillStyle = this.getTriangleColor(cell); this.drawTriangle1(cell.bx * this.bw, cell.by * this.bh, num); - } - else { + } else { g.vhide(); } g.vid = "c_tri_solver_" + cell.id; if (snum >= 2 && snum <= 5) { - g.fillStyle = this.solvercolor; this.drawTriangle1(cell.bx * this.bw, cell.by * this.bh, snum); - } - else { + } else { g.vhide(); } } diff --git a/src/variety/aquapelago.js b/src/variety/aquapelago.js index 2a260e39b..0142afb80 100644 --- a/src/variety/aquapelago.js +++ b/src/variety/aquapelago.js @@ -173,7 +173,9 @@ } else if (cell.trial) { return this.trialcolor; } - return cell.qnum !== -1 ? this.shadecolor : this.getColorSolverAware(cell.isShade(), 1 === cell.qansBySolver); + return cell.qnum !== -1 + ? this.shadecolor + : this.getColorSolverAware(cell.isShade(), 1 === cell.qansBySolver); }, getQuesNumberColor: function(cell) { return cell.qcmp === 1 ? this.qcmpcolor : this.fontShadecolor; diff --git a/src/variety/chainedb.js b/src/variety/chainedb.js index 0ce62ed01..83acec332 100644 --- a/src/variety/chainedb.js +++ b/src/variety/chainedb.js @@ -139,7 +139,9 @@ } else if (info === -1) { return this.noerrcolor; } - return cell.qnum !== -1 ? this.shadecolor : this.getColorSolverAware(cell.isShade(), 1 === cell.qansBySolver); + return cell.qnum !== -1 + ? this.shadecolor + : this.getColorSolverAware(cell.isShade(), 1 === cell.qansBySolver); } }, "Graphic@mrtile,archipelago": { diff --git a/src/variety/evolmino.js b/src/variety/evolmino.js index 019dccf33..b599ca6fd 100644 --- a/src/variety/evolmino.js +++ b/src/variety/evolmino.js @@ -510,7 +510,11 @@ : cell.qnum === 1 ? this.sq_qcolor : !cell.trial - ? this.getColorSolverAware(cell.anum === 1, cell.qansBySolver === 3 , this.sq_anscolor) + ? this.getColorSolverAware( + cell.anum === 1, + cell.qansBySolver === 3, + this.sq_anscolor + ) : this.sq_trialcolor; g.strokeRectCenter(cell.bx * this.bw, cell.by * this.bh, rw, rh); } else { @@ -528,7 +532,13 @@ var cell = clist[i]; g.vid = "c_dot_" + cell.id; if (cell.isDot() || cell.isDotBySolver()) { - g.fillStyle = !cell.trial ? this.getColorSolverAware(cell.isDot(), cell.isDotBySolver(), this.dot_anscolor ) : this.dot_trialcolor; + g.fillStyle = !cell.trial + ? this.getColorSolverAware( + cell.isDot(), + cell.isDotBySolver(), + this.dot_anscolor + ) + : this.dot_trialcolor; g.fillCircle(cell.bx * this.bw, cell.by * this.bh, dsize); } else { g.vhide(); diff --git a/src/variety/hakoiri.js b/src/variety/hakoiri.js index b104a6246..26599d732 100644 --- a/src/variety/hakoiri.js +++ b/src/variety/hakoiri.js @@ -231,7 +231,7 @@ Graphic: { enablebcolor: true, - paint: function () { + paint: function() { this.drawBGCells(); this.drawTargetSubNumber(); this.drawGrid(); @@ -247,14 +247,14 @@ this.drawCursor(); }, - getNumberTextCore: function (num) { + getNumberTextCore: function(num) { if (num > 0) { return "○△◻"[num - 1]; } return null; }, - drawQnumMarks: function () { + drawQnumMarks: function() { var g = this.vinc("cell_mark", "auto"); g.lineWidth = Math.max(this.cw / 18, 2); @@ -268,7 +268,14 @@ g.strokeStyle = cell.qnum !== -1 ? this.getQuesNumberColor(cell) - : ((1 === this.isSameSymbol(cell.getNum(), [1, 2, 3], cell.qansBySolver, [1, 2, 3])) ? this.solverqanscolor : this.getAnsNumberColor(cell)) + : 1 === + this.isSameSymbol(cell.getNum(), [1, 2, 3], cell.qansBySolver, [ + 1, + 2, + 3 + ]) + ? this.solverqanscolor + : this.getAnsNumberColor(cell); var px = cell.bx * this.bw, py = cell.by * this.bh; switch (cell.getNum()) { @@ -299,7 +306,15 @@ } g.vid = "c_mk_solver" + cell.id; - g.strokeStyle = (1 === this.isSameSymbol(cell.getNum(), [1, 2, 3], cell.qansBySolver, [1, 2, 3])) ? this.solverqanscolor : this.solvercolor; + g.strokeStyle = + 1 === + this.isSameSymbol(cell.getNum(), [1, 2, 3], cell.qansBySolver, [ + 1, + 2, + 3 + ]) + ? this.solverqanscolor + : this.solvercolor; switch (cell.qansBySolver) { case 1: g.strokeCircle(px, py, rsize); diff --git a/src/variety/hashikake.js b/src/variety/hashikake.js index 202a0117e..ea13f2d5d 100644 --- a/src/variety/hashikake.js +++ b/src/variety/hashikake.js @@ -280,7 +280,11 @@ var blist = this.range.borders; for (var i = 0; i < blist.length; i++) { var border = blist[i], - color = this.getColorSolverAware(border.isLine(), border.isLineBySolver(), this.getLineColor(border)); + color = this.getColorSolverAware( + border.isLine(), + border.isLineBySolver(), + this.getLineColor(border) + ); var isvert = border.isVert(); var px = border.bx * this.bw, py = border.by * this.bh; diff --git a/src/variety/herugolf.js b/src/variety/herugolf.js index 98021ddc5..6754bf7f1 100644 --- a/src/variety/herugolf.js +++ b/src/variety/herugolf.js @@ -430,15 +430,28 @@ } var dists = [border.sidecell[0].distance, border.sidecell[1].distance]; - var isvalidline = border.isLineBySolver() || - dists[0] !== null && - dists[0] >= 0 && - dists[1] !== null && - dists[1] >= 0; + var isvalidline = + border.isLineBySolver() || + (dists[0] !== null && + dists[0] >= 0 && + dists[1] !== null && + dists[1] >= 0); if (this.puzzle.execConfig("dispmove")) { - return isvalidline ? this.getColorSolverAware(border.isLine(), border.isLineBySolver(), this.movelinecolor) : this.errlinecolor; + return isvalidline + ? this.getColorSolverAware( + border.isLine(), + border.isLineBySolver(), + this.movelinecolor + ) + : this.errlinecolor; } else { - return isvalidline ? this.getColorSolverAware(border.isLine(), border.isLineBySolver(),this.linecolor) : this.invalidlinecolor; + return isvalidline + ? this.getColorSolverAware( + border.isLine(), + border.isLineBySolver(), + this.linecolor + ) + : this.invalidlinecolor; } } return null; diff --git a/src/variety/icewalk.js b/src/variety/icewalk.js index 6d7f2dcb4..2e93db6a8 100644 --- a/src/variety/icewalk.js +++ b/src/variety/icewalk.js @@ -214,7 +214,7 @@ } }, - drawArcBackgroundForSolver: function () { + drawArcBackgroundForSolver: function() { var g = this.vinc("arc_back_solver", "crispEdges"); var clist = this.range.borders.cellinside(); var pad = this.lw, @@ -244,16 +244,24 @@ var adj = cell.adjborder; var ox, oy; if ( - (cell.qansBySolver === 1 && adj.top.isLineBySolver() && adj.left.isLineBySolver()) || - (cell.qansBySolver === 2 && adj.bottom.isLineBySolver() && adj.left.isLineBySolver()) + (cell.qansBySolver === 1 && + adj.top.isLineBySolver() && + adj.left.isLineBySolver()) || + (cell.qansBySolver === 2 && + adj.bottom.isLineBySolver() && + adj.left.isLineBySolver()) ) { ox = (cell.bx - 1) * this.bw - pad + bigpad; } else { ox = cell.bx * this.bw + pad - bigpad; } if ( - (cell.qansBySolver === 1 && adj.left.isLineBySolver() && adj.top.isLineBySolver()) || - (cell.qansBySolver === 2 && adj.right.isLineBySolver() && adj.top.isLineBySolver()) + (cell.qansBySolver === 1 && + adj.left.isLineBySolver() && + adj.top.isLineBySolver()) || + (cell.qansBySolver === 2 && + adj.right.isLineBySolver() && + adj.top.isLineBySolver()) ) { oy = (cell.by - 1) * this.bh - pad + bigpad; } else { @@ -269,7 +277,7 @@ } } }, - drawArcCorners: function () { + drawArcCorners: function() { var g = this.vinc("arcs", "auto", true); g.lineWidth = this.lm * 2; var rsize = this.bw; @@ -290,54 +298,84 @@ case 0: showArc = cell.qans === 1 && adj.top.isLine() && adj.left.isLine(); - color = showArc ? this.getColorSolverAware(cell.qans === 1 && adj.top.isLine() && adj.left.isLine(), - cell.qansBySolver === 1 && adj.top.isLineBySolver() && adj.left.isLineBySolver(), this.getLineColor(adj.top)) : null; + color = showArc + ? this.getColorSolverAware( + cell.qans === 1 && adj.top.isLine() && adj.left.isLine(), + cell.qansBySolver === 1 && + adj.top.isLineBySolver() && + adj.left.isLineBySolver(), + this.getLineColor(adj.top) + ) + : null; break; case 1: showArc = cell.qans === 2 && adj.top.isLine() && adj.right.isLine(); - color = showArc ? this.getColorSolverAware(cell.qans === 2 && adj.top.isLine() && adj.right.isLine(), - cell.qansBySolver === 2 && adj.top.isLineBySolver() && adj.right.isLineBySolver(), this.getLineColor(adj.top)) : null; + color = showArc + ? this.getColorSolverAware( + cell.qans === 2 && adj.top.isLine() && adj.right.isLine(), + cell.qansBySolver === 2 && + adj.top.isLineBySolver() && + adj.right.isLineBySolver(), + this.getLineColor(adj.top) + ) + : null; break; case 2: showArc = cell.qans === 1 && adj.bottom.isLine() && adj.right.isLine(); - color = showArc ? this.getColorSolverAware(cell.qans === 1 && adj.bottom.isLine() && adj.right.isLine(), - cell.qansBySolver === 1 && adj.bottom.isLineBySolver() && adj.right.isLineBySolver(), this.getLineColor(adj.bottom)) : null; + color = showArc + ? this.getColorSolverAware( + cell.qans === 1 && + adj.bottom.isLine() && + adj.right.isLine(), + cell.qansBySolver === 1 && + adj.bottom.isLineBySolver() && + adj.right.isLineBySolver(), + this.getLineColor(adj.bottom) + ) + : null; break; case 3: showArc = cell.qans === 2 && adj.bottom.isLine() && adj.left.isLine(); - color = showArc ? this.getColorSolverAware(cell.qans === 2 && adj.bottom.isLine() && adj.left.isLine(), - cell.qansBySolver === 2 && adj.bottom.isLineBySolver() && adj.left.isLineBySolver(), this.getLineColor(adj.bottom)) : null; + color = showArc + ? this.getColorSolverAware( + cell.qans === 2 && adj.bottom.isLine() && adj.left.isLine(), + cell.qansBySolver === 2 && + adj.bottom.isLineBySolver() && + adj.left.isLineBySolver(), + this.getLineColor(adj.bottom) + ) + : null; break; } g.vid = "c_arc_" + arc + "_" + cell.id; - if (!!color) { - g.beginPath(); - g.strokeStyle = color; + if (!!color) { + g.beginPath(); + g.strokeStyle = color; - switch (arc) { - case 0: - g.arc(px1, py1, rsize, 0, Math.PI / 2); - break; - case 1: - g.arc(px2, py1, rsize, Math.PI / 2, Math.PI); - break; - case 2: - g.arc(px2, py2, rsize, Math.PI, Math.PI * 1.5); - break; - case 3: - g.arc(px1, py2, rsize, Math.PI * 1.5, Math.PI * 2); - break; - } - g.stroke(); - } else { - g.vhide(); + switch (arc) { + case 0: + g.arc(px1, py1, rsize, 0, Math.PI / 2); + break; + case 1: + g.arc(px2, py1, rsize, Math.PI / 2, Math.PI); + break; + case 2: + g.arc(px2, py2, rsize, Math.PI, Math.PI * 1.5); + break; + case 3: + g.arc(px1, py2, rsize, Math.PI * 1.5, Math.PI * 2); + break; + } + g.stroke(); + } else { + g.vhide(); } } } - + this.drawArcBackgroundForSolver(); }, Border: { @@ -600,7 +638,6 @@ g.vhide(); } } - }, drawArcCorners: function() { var g = this.vinc("arcs", "auto", true); @@ -665,80 +702,120 @@ g.vhide(); } } - } - this.drawArcCornersForSolver(); - }, - drawArcCornersForSolver: function() { - var g = this.vinc("arcs_solver", "auto", true); - g.lineWidth = this.lm * 2; - var rsize = this.bw; - var clist = this.range.borders.cellinside(); - for (var i = 0; i < clist.length; i++) { - var cell = clist[i]; - var px1 = (cell.bx - 1) * this.bw, - py1 = (cell.by - 1) * this.bh, - px2 = (cell.bx + 1) * this.bw, - py2 = (cell.by + 1) * this.bh; - - var adj = cell.adjborder; - - for (var arc = 0; arc < 4; arc++) { - var showArc = false; - var color = null; - switch (arc) { - case 0: - showArc = - (cell.qansBySolver === 1 && adj.top.isLineBySolver() && adj.left.isLineBySolver()); - color = showArc ? this.getColorSolverAware(cell.qans === 1 && adj.top.isLine() && adj.left.isLine(), - cell.qansBySolver === 1 && adj.top.isLineBySolver() && adj.left.isLineBySolver(), this.getLineColor(adj.top)) : null; - break; - case 1: - showArc = - cell.qansBySolver === 2 && adj.top.isLineBySolver() && adj.right.isLineBySolver(); - color = showArc ? this.getColorSolverAware(cell.qans === 2 && adj.top.isLine() && adj.right.isLine(), - cell.qansBySolver === 2 && adj.top.isLineBySolver() && adj.right.isLineBySolver(), this.getLineColor(adj.top)) : null; - break; - case 2: - showArc = - cell.qansBySolver === 1 && adj.bottom.isLineBySolver() && adj.right.isLineBySolver(); - color = showArc ? this.getColorSolverAware(cell.qans === 1 && adj.bottom.isLine() && adj.right.isLine(), - cell.qansBySolver === 1 && adj.bottom.isLineBySolver() && adj.right.isLineBySolver(), this.getLineColor(adj.bottom)) : null; - break; - case 3: - showArc = - cell.qansBySolver === 2 && adj.bottom.isLineBySolver() && adj.left.isLineBySolver(); - color = showArc ? this.getColorSolverAware(cell.qans === 2 && adj.bottom.isLine() && adj.left.isLine(), - cell.qansBySolver === 2 && adj.bottom.isLineBySolver() && adj.left.isLineBySolver(), this.getLineColor(adj.bottom)) : null; - break; - } + } + this.drawArcCornersForSolver(); + }, + drawArcCornersForSolver: function() { + var g = this.vinc("arcs_solver", "auto", true); + g.lineWidth = this.lm * 2; + var rsize = this.bw; + var clist = this.range.borders.cellinside(); + for (var i = 0; i < clist.length; i++) { + var cell = clist[i]; + var px1 = (cell.bx - 1) * this.bw, + py1 = (cell.by - 1) * this.bh, + px2 = (cell.bx + 1) * this.bw, + py2 = (cell.by + 1) * this.bh; - g.vid = "c_arc_by_solver_" + arc + "_" + cell.id; - if (!!color) { - g.beginPath(); - g.strokeStyle = color; + var adj = cell.adjborder; + for (var arc = 0; arc < 4; arc++) { + var showArc = false; + var color = null; switch (arc) { case 0: - g.arc(px1, py1, rsize, 0, Math.PI / 2); + showArc = + cell.qansBySolver === 1 && + adj.top.isLineBySolver() && + adj.left.isLineBySolver(); + color = showArc + ? this.getColorSolverAware( + cell.qans === 1 && adj.top.isLine() && adj.left.isLine(), + cell.qansBySolver === 1 && + adj.top.isLineBySolver() && + adj.left.isLineBySolver(), + this.getLineColor(adj.top) + ) + : null; break; case 1: - g.arc(px2, py1, rsize, Math.PI / 2, Math.PI); + showArc = + cell.qansBySolver === 2 && + adj.top.isLineBySolver() && + adj.right.isLineBySolver(); + color = showArc + ? this.getColorSolverAware( + cell.qans === 2 && adj.top.isLine() && adj.right.isLine(), + cell.qansBySolver === 2 && + adj.top.isLineBySolver() && + adj.right.isLineBySolver(), + this.getLineColor(adj.top) + ) + : null; break; case 2: - g.arc(px2, py2, rsize, Math.PI, Math.PI * 1.5); + showArc = + cell.qansBySolver === 1 && + adj.bottom.isLineBySolver() && + adj.right.isLineBySolver(); + color = showArc + ? this.getColorSolverAware( + cell.qans === 1 && + adj.bottom.isLine() && + adj.right.isLine(), + cell.qansBySolver === 1 && + adj.bottom.isLineBySolver() && + adj.right.isLineBySolver(), + this.getLineColor(adj.bottom) + ) + : null; break; case 3: - g.arc(px1, py2, rsize, Math.PI * 1.5, Math.PI * 2); + showArc = + cell.qansBySolver === 2 && + adj.bottom.isLineBySolver() && + adj.left.isLineBySolver(); + color = showArc + ? this.getColorSolverAware( + cell.qans === 2 && + adj.bottom.isLine() && + adj.left.isLine(), + cell.qansBySolver === 2 && + adj.bottom.isLineBySolver() && + adj.left.isLineBySolver(), + this.getLineColor(adj.bottom) + ) + : null; break; } - g.stroke(); - } else { - g.vhide(); + + g.vid = "c_arc_by_solver_" + arc + "_" + cell.id; + if (!!color) { + g.beginPath(); + g.strokeStyle = color; + + switch (arc) { + case 0: + g.arc(px1, py1, rsize, 0, Math.PI / 2); + break; + case 1: + g.arc(px2, py1, rsize, Math.PI / 2, Math.PI); + break; + case 2: + g.arc(px2, py2, rsize, Math.PI, Math.PI * 1.5); + break; + case 3: + g.arc(px1, py2, rsize, Math.PI * 1.5, Math.PI * 2); + break; + } + g.stroke(); + } else { + g.vhide(); + } } } } - } - }, + }, LineGraph: { enabled: true }, diff --git a/src/variety/kouchoku.js b/src/variety/kouchoku.js index c6ceac6a1..2eafa8aaf 100644 --- a/src/variety/kouchoku.js +++ b/src/variety/kouchoku.js @@ -1196,26 +1196,28 @@ this.drawSolverSegments(); }, - drawSolverSegments: function () { + drawSolverSegments: function() { var g = this.vinc("segment_solver", "auto", true); var clist = this.range.crosses; g.strokeStyle = this.solvercolor; g.lineWidth = this.lw; for (var i = 0; i < clist.length; i++) { - var celli = clist[i]; + var celli = clist[i]; for (var j = 0; j < clist.length; j++) { var cellj = clist[j]; g.vid = ["seg_solver", i, j].join("_"); - if (celli.qansBySolver === 1 && cellj.destBySolver.includes(celli.id)) { - var px1 = (celli.bx ) * this.bw, - px2 = (cellj.bx ) * this.bw, - py1 = (celli.by ) * this.bh, - py2 = (cellj.by ) * this.bh; + if ( + celli.qansBySolver === 1 && + cellj.destBySolver.includes(celli.id) + ) { + var px1 = celli.bx * this.bw, + px2 = cellj.bx * this.bw, + py1 = celli.by * this.bh, + py2 = cellj.by * this.bh; g.strokeLine(px1, py1, px2, py2); + } else { + g.vhide(); } - - - else { g.vhide(); } } } }, diff --git a/src/variety/lightup.js b/src/variety/lightup.js index 298587308..1fef60a9a 100644 --- a/src/variety/lightup.js +++ b/src/variety/lightup.js @@ -288,7 +288,11 @@ cell.error === 4 ? this.errcolor1 : !cell.trial - ? this.getColorSolverAware(cell.isAkari(), cell.qansBySolver === 1, lampcolor) + ? this.getColorSolverAware( + cell.isAkari(), + cell.qansBySolver === 1, + lampcolor + ) : this.trialcolor; g.fillCircle(cell.bx * this.bw, cell.by * this.bh, rsize); } else { diff --git a/src/variety/pencils.js b/src/variety/pencils.js index 4beb7f2fc..98ce8992a 100644 --- a/src/variety/pencils.js +++ b/src/variety/pencils.js @@ -617,7 +617,11 @@ return border.error ? "red" : !border.trial - ? this.getColorSolverAware(border.isBorder(), border.isBorderBySolver(), this.qanscolor) + ? this.getColorSolverAware( + border.isBorder(), + border.isBorderBySolver(), + this.qanscolor + ) : this.trialcolor; } return null; @@ -633,7 +637,16 @@ for (var i = 0; i < clist.length; i++) { var cell = clist[i]; var dir = cell.getPencilDir(); - var color = (1 === this.isSameSymbol(cell.getPencilDir(), [cell.UP, cell.DN, cell.LT, cell.RT], this.qansBySolver, [8, 6, 9, 7])) ? this.solverqanscolor : this.getCellArrowColor(cell); + var color = + 1 === + this.isSameSymbol( + cell.getPencilDir(), + [cell.UP, cell.DN, cell.LT, cell.RT], + this.qansBySolver, + [8, 6, 9, 7] + ) + ? this.solverqanscolor + : this.getCellArrowColor(cell); g.lineWidth = (this.lw + this.addlw) / 2; if (!!color) { @@ -694,7 +707,7 @@ } this.drawCellArrowsForSolver(); }, - drawCellArrowsForSolver: function () { + drawCellArrowsForSolver: function() { var g = this.vinc("cell_arrow_solver", "crispEdges"); var outer = this.cw * 0.5; @@ -704,7 +717,16 @@ for (var i = 0; i < clist.length; i++) { var cell = clist[i]; var dir = cell.qansBySolver; - var color = (1 === this.isSameSymbol(cell.getPencilDir(), [cell.UP, cell.DN, cell.LT, cell.RT], dir, [8, 6, 9, 7])) ? this.solverqanscolor : this.solvercolor; + var color = + 1 === + this.isSameSymbol( + cell.getPencilDir(), + [cell.UP, cell.DN, cell.LT, cell.RT], + dir, + [8, 6, 9, 7] + ) + ? this.solverqanscolor + : this.solvercolor; g.lineWidth = (this.lw + this.addlw) / 2; if (!!color) { diff --git a/src/variety/shimaguni.js b/src/variety/shimaguni.js index 3e111480d..ff4ea272f 100644 --- a/src/variety/shimaguni.js +++ b/src/variety/shimaguni.js @@ -435,7 +435,13 @@ g.vid = "c_dot_" + cell.id; if (cell.qsub === 1 || cell.qsubBySolver === 1) { - g.fillStyle = !cell.trial ? this.getColorSolverAware(1 === cell.qsub, 1 === cell.qsubBySolver, this.bcolor) : this.trialcolor; + g.fillStyle = !cell.trial + ? this.getColorSolverAware( + 1 === cell.qsub, + 1 === cell.qsubBySolver, + this.bcolor + ) + : this.trialcolor; g.fillCircle(cell.bx * this.bw, cell.by * this.bh, dsize); } else { g.vhide(); @@ -479,7 +485,11 @@ } else if (this.puzzle.execConfig("irowakeblk")) { return cell.stone.color; } - return this.getColorSolverAware(1 === cell.qans, 1 === cell.qansBySolver, this.shadecolor); + return this.getColorSolverAware( + 1 === cell.qans, + 1 === cell.qansBySolver, + this.shadecolor + ); }, getBorderColor: function(border) { if (this.board.falling) { diff --git a/src/variety/slashpack.js b/src/variety/slashpack.js index a8eee1106..199239ca6 100644 --- a/src/variety/slashpack.js +++ b/src/variety/slashpack.js @@ -329,7 +329,13 @@ var py = cell.by * this.bh; g.vid = "c_MB_" + cell.id; g.lineWidth = 1; - g.strokeStyle = !cell.trial ? this.getColorSolverAware(cell.qsub & 1, cell.qsubBySolver & 1, this.mbcolor) : "rgb(192, 192, 192)"; + g.strokeStyle = !cell.trial + ? this.getColorSolverAware( + cell.qsub & 1, + cell.qsubBySolver & 1, + this.mbcolor + ) + : "rgb(192, 192, 192)"; g.strokeCircle(px, py, rsize); } else { g.vid = "c_MB_" + cell.id; diff --git a/src/variety/starbattle.js b/src/variety/starbattle.js index 9c9e1c527..5d4f7696b 100644 --- a/src/variety/starbattle.js +++ b/src/variety/starbattle.js @@ -384,8 +384,13 @@ var cell = clist[i]; g.vid = "c_star_" + cell.id; if (cell.qans === 1 || cell.qansBySolver === 1) { - g.fillStyle = !cell.trial ? this.getColorSolverAware(cell.qans === 1, cell.qansBySolver === 1, this.qanscolor) - : this.trialcolor;; + g.fillStyle = !cell.trial + ? this.getColorSolverAware( + cell.qans === 1, + cell.qansBySolver === 1, + this.qanscolor + ) + : this.trialcolor; this.fillStar( g, cell.bx * this.bw, diff --git a/src/variety/yajilin.js b/src/variety/yajilin.js index 899d385fe..185d1b32e 100644 --- a/src/variety/yajilin.js +++ b/src/variety/yajilin.js @@ -575,7 +575,11 @@ } else if (cell.trial) { return this.trialcolor; } - return this.getColorSolverAware(cell.qans === 1, cell.qansBySolver === 1, this.shadecolor); + return this.getColorSolverAware( + cell.qans === 1, + cell.qansBySolver === 1, + this.shadecolor + ); } else if (info === 1) { return this.errbcolor1; } From e093c6b869673bf0be59cb6182215bf00a4d2b68 Mon Sep 17 00:00:00 2001 From: ReverM Date: Tue, 16 Dec 2025 19:37:54 -0500 Subject: [PATCH 17/46] fixed formatting --- src-ui/list.html | 808 +++++++++++++++++++++++------------------------ 1 file changed, 403 insertions(+), 405 deletions(-) diff --git a/src-ui/list.html b/src-ui/list.html index bf1e98e9b..cab17773f 100644 --- a/src-ui/list.html +++ b/src-ui/list.html @@ -35,413 +35,411 @@

    パズルの種類のリスト黒マス配置系 Shading Puzzles
      -
    • - -
    • - -
    • -
    • - -
    • -
    • -
    • - -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • -
    • -
    • -
    • -
    • - -
    • -
    • - +
    • + +
    • + +
    • +
    • + +
    • +
    • +
    • + +
    • + +
    • +
    • + +
    • +
    • + +
    • +
    • +
    • +
    • +
    • +
    • + +
    • +
    - -
    - 領域+黒マス系 - Areas and Shading Puzzles -
      - -
    • -
    • -
    • -
    • -
    • -
    • - -
    • -
    • - -
    -
    -
    - 連黒分断禁系 - No Adjacent, No Divide -
      -
    • -
    • -
    • - -
    • - -
    • - -
    • - -
    • -
    • -
    • - -
    -
    -
    - ループ系 - Make a Loop -
      -
    • - -
    • -
    • -
    • - -
    • -
    • - -
    • -
    • -
    • - -
    • - -
    • - -
    • -
    • -
    • - -
    • -
    • -
    -
    -
    - 交差ありループ系 - Make a Crossing Loop -
      -
    • - -
    • -
    • -
    • -
    • - -
    -
    -
    - アイスバーン系 - Icebarn like Puzzles -
      - -
    • - -
    • -
    -
    -
    - 線でつなぐパズル - Connecting Puzzles -
      - -
    -
    -
    - ひとつながりにするパズル - Connection Puzzles -
      -
    • -
    • -
    • -
    • - -
    -
    -
    - 移動系パズル - Moving Puzzles -
      -
    • -
    • -
    • - -
    -
    -
    - 領域分割系 - Divide into Areas -
      -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    -
    -
    - 領域分割系 (数字なし) - Divide into Areas (without number) -
      -
    -
    -
    - タタミ系 - Tatami Puzzles -
      -
    • -
    -
    -
    - 数字系 - Number Puzzles -
      -
    • -
    • -
    • -
    • -
    • -
    • -
    -
    -
    - 領域+数字系 - Areas and Numbers -
      -
    • -
    • -
    • -
    • -
    • -
    -
    -
    - その他 (線を引く) - Drawing Puzzles -
      -
    • -
    • -
    -
    -
    - その他 (数字あり) - Variety Puzzles (with numbers) -
      -
    • -
    • -
    • -
    • -
    -
    -
    - その他 (数字なし) - Variety Puzzles (without numbers) -
      -
    • -
    • -
    • -
    • -
    • -
    -
    - - + +
    + 領域+黒マス系 + Areas and Shading Puzzles +
      + +
    • +
    • +
    • +
    • +
    • +
    • + +
    • +
    • + +
    +
    +
    + 連黒分断禁系 + No Adjacent, No Divide +
      +
    • +
    • +
    • + +
    • + +
    • + +
    • + +
    • +
    • +
    • + +
    +
    +
    + ループ系 + Make a Loop +
      +
    • + +
    • +
    • +
    • + +
    • +
    • + +
    • +
    • +
    • + +
    • + +
    • + +
    • +
    • +
    • + +
    • +
    • +
    +
    +
    + 交差ありループ系 + Make a Crossing Loop +
      +
    • + +
    • +
    • +
    • +
    • + +
    +
    +
    + アイスバーン系 + Icebarn like Puzzles +
      + +
    • + +
    • +
    +
    +
    + 線でつなぐパズル + Connecting Puzzles +
      + +
    +
    +
    + ひとつながりにするパズル + Connection Puzzles +
      +
    • +
    • +
    • +
    • + +
    +
    +
    + 移動系パズル + Moving Puzzles +
      +
    • +
    • +
    • + +
    +
    +
    + 領域分割系 + Divide into Areas +
      +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    +
    +
    + 領域分割系 (数字なし) + Divide into Areas (without number) +
      + +
    +
    +
    + タタミ系 + Tatami Puzzles +
      + +
    • +
    +
    +
    + 数字系 + Number Puzzles +
      +
    • +
    • +
    • +
    • +
    • +
    • +
    +
    +
    + 領域+数字系 + Areas and Numbers +
      +
    • +
    • +
    • +
    • +
    • +
    +
    +
    + その他 (線を引く) + Drawing Puzzles +
      + +
    • +
    • +
    +
    +
    + その他 (数字あり) + Variety Puzzles (with numbers) +
      +
    • +
    • +
    • +
    • +
    +
    +
    + その他 (数字なし) + Variety Puzzles (without numbers) +
      + +
    • +
    • +
    • +
    • +
    • +
    +
    + + - + From 404e484c4e59789e64a6eb00bcaa0c08dc7ffc2f Mon Sep 17 00:00:00 2001 From: ReverM Date: Tue, 16 Dec 2025 19:40:49 -0500 Subject: [PATCH 18/46] for conflict --- src-ui/list.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src-ui/list.html b/src-ui/list.html index cab17773f..17e574ae0 100644 --- a/src-ui/list.html +++ b/src-ui/list.html @@ -244,8 +244,8 @@

    パズルの種類のリスト
  • -->
  • - + +
  • @@ -299,7 +299,8 @@

    パズルの種類のリスト
  • -->
  • +
  • +
  • -->

    From 9dcc78282701c744812c6837206dfbb9948b8e26 Mon Sep 17 00:00:00 2001 From: ReverM Date: Tue, 16 Dec 2025 19:41:41 -0500 Subject: [PATCH 19/46] for conflict (for real this time) --- src-ui/list.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src-ui/list.html b/src-ui/list.html index 17e574ae0..84cfc801f 100644 --- a/src-ui/list.html +++ b/src-ui/list.html @@ -300,7 +300,8 @@

    パズルの種類のリスト-->
  • +
  • + -->

    From 6e3b3296bec63d66244f0cdcbf0d2475c6073b0f Mon Sep 17 00:00:00 2001 From: ReverM Date: Tue, 16 Dec 2025 19:44:38 -0500 Subject: [PATCH 20/46] will revert in a bit --- src-ui/list.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src-ui/list.html b/src-ui/list.html index 84cfc801f..8a578f5a8 100644 --- a/src-ui/list.html +++ b/src-ui/list.html @@ -298,10 +298,9 @@

    パズルの種類のリスト
  • --> -
  • From dff3e5605cd1d1c589145a2a0ecb2a1d8483f61e Mon Sep 17 00:00:00 2001 From: ReverM Date: Tue, 16 Dec 2025 19:46:03 -0500 Subject: [PATCH 21/46] why are you like this --- src-ui/list.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src-ui/list.html b/src-ui/list.html index 8a578f5a8..01ffe22d0 100644 --- a/src-ui/list.html +++ b/src-ui/list.html @@ -298,10 +298,10 @@

    パズルの種類のリスト
  • --> -
  • +
  • +

    領域分割系 (数字なし) From ebcf764b86e7fe30d447cba7779ee2aaf8af4bdc Mon Sep 17 00:00:00 2001 From: ReverM Date: Tue, 16 Dec 2025 19:47:05 -0500 Subject: [PATCH 22/46] now will you be happy? --- src-ui/list.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src-ui/list.html b/src-ui/list.html index 01ffe22d0..7dc135257 100644 --- a/src-ui/list.html +++ b/src-ui/list.html @@ -298,9 +298,9 @@

    パズルの種類のリスト
  • --> -
  • +
  • From 755194b196d778dd61d8fc792986d4f9fa2860e5 Mon Sep 17 00:00:00 2001 From: ReverM Date: Tue, 16 Dec 2025 20:33:08 -0500 Subject: [PATCH 23/46] New genres! --- src-ui/list.html | 18 +- src/puzzle/Board.js | 2 +- src/solver/cspuz_solver_backend.js | 2276 +--------------------------- 3 files changed, 12 insertions(+), 2284 deletions(-) diff --git a/src-ui/list.html b/src-ui/list.html index 899e311a6..c767bed2b 100644 --- a/src-ui/list.html +++ b/src-ui/list.html @@ -89,8 +89,8 @@

    パズルの種類のリスト
  • -
  • @@ -99,9 +99,9 @@

    パズルの種類のリスト
  • -
  • +
  • -->
  • -
  • --> +
  • @@ -299,10 +299,10 @@

    パズルの種類のリスト
  • --> -
  • +
  • +

    領域分割系 (数字なし) @@ -369,8 +369,8 @@

    パズルの種類のリスト
  • -
  • -
  • --> +
  • --> +
  • diff --git a/src/puzzle/Board.js b/src/puzzle/Board.js index 98d300066..629efa448 100644 --- a/src/puzzle/Board.js +++ b/src/puzzle/Board.js @@ -304,7 +304,7 @@ pzpr.classmgr.makeCommon({ for (var g = 0; g < solution.length; ++g) { var h = solution[g]; if ( - ("kakuro" === this.pid || "doppelblock" === this.pid) && + ("kakuro" === this.pid || "doppelblock" === this.pid || "aquarium" === this.pid ) && "green" === h.color && h.x % 2 === 1 && h.y % 2 === 1 diff --git a/src/solver/cspuz_solver_backend.js b/src/solver/cspuz_solver_backend.js index 84d1d6493..82c0d4efe 100644 --- a/src/solver/cspuz_solver_backend.js +++ b/src/solver/cspuz_solver_backend.js @@ -1,2274 +1,2 @@ -// This code implements the `-sMODULARIZE` settings by taking the generated -// JS program code (INNER_JS_CODE) and wrapping it in a factory function. - -// When targetting node and ES6 we use `await import ..` in the generated code -// so the outer function needs to be marked as async. -async function Module(moduleArg = {}) { - var moduleRtn; - - // include: shell.js - // include: minimum_runtime_check.js - (function() { - // "30.0.0" -> 300000 - function humanReadableVersionToPacked(str) { - str = str.split("-")[0]; // Remove any trailing part from e.g. "12.53.3-alpha" - var vers = str.split(".").slice(0, 3); - while (vers.length < 3) vers.push("00"); - vers = vers.map((n, i, arr) => n.padStart(2, "0")); - return vers.join(""); - } - // 300000 -> "30.0.0" - var packedVersionToHumanReadable = n => - [(n / 10000) | 0, ((n / 100) | 0) % 100, n % 100].join("."); - - var TARGET_NOT_SUPPORTED = 2147483647; - - var currentNodeVersion = - typeof process !== "undefined" && process?.versions?.node - ? humanReadableVersionToPacked(process.versions.node) - : TARGET_NOT_SUPPORTED; - if (currentNodeVersion < 160000) { - throw new Error( - `This emscripten-generated code requires node v${packedVersionToHumanReadable( - 160000 - )} (detected v${packedVersionToHumanReadable(currentNodeVersion)})` - ); - } - - var currentSafariVersion = - typeof navigator !== "undefined" && - navigator?.userAgent?.includes("Safari/") && - navigator.userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/) - ? humanReadableVersionToPacked( - navigator.userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/)[1] - ) - : TARGET_NOT_SUPPORTED; - if (currentSafariVersion < 150000) { - throw new Error( - `This emscripten-generated code requires Safari v${packedVersionToHumanReadable( - 150000 - )} (detected v${currentSafariVersion})` - ); - } - - var currentFirefoxVersion = - typeof navigator !== "undefined" && - navigator?.userAgent?.match(/Firefox\/(\d+(?:\.\d+)?)/) - ? parseFloat(navigator.userAgent.match(/Firefox\/(\d+(?:\.\d+)?)/)[1]) - : TARGET_NOT_SUPPORTED; - if (currentFirefoxVersion < 79) { - throw new Error( - `This emscripten-generated code requires Firefox v79 (detected v${currentFirefoxVersion})` - ); - } - - var currentChromeVersion = - typeof navigator !== "undefined" && - navigator?.userAgent?.match(/Chrome\/(\d+(?:\.\d+)?)/) - ? parseFloat(navigator.userAgent.match(/Chrome\/(\d+(?:\.\d+)?)/)[1]) - : TARGET_NOT_SUPPORTED; - if (currentChromeVersion < 85) { - throw new Error( - `This emscripten-generated code requires Chrome v85 (detected v${currentChromeVersion})` - ); - } - })(); - - // end include: minimum_runtime_check.js - // The Module object: Our interface to the outside world. We import - // and export values on it. There are various ways Module can be used: - // 1. Not defined. We create it here - // 2. A function parameter, function(moduleArg) => Promise - // 3. pre-run appended it, var Module = {}; ..generated code.. - // 4. External script tag defines var Module. - // We need to check if Module already exists (e.g. case 3 above). - // Substitution will be replaced with actual code on later stage of the build, - // this way Closure Compiler will not mangle it (e.g. case 4. above). - // Note that if you want to run closure, and also to use Module - // after the generated code, you will need to define var Module = {}; - // before the code. Then that object will be used in the code, and you - // can continue to use Module afterwards as well. - var Module = moduleArg; - - // Determine the runtime environment we are in. You can customize this by - // setting the ENVIRONMENT setting at compile time (see settings.js). - - // Attempt to auto-detect the environment - var ENVIRONMENT_IS_WEB = !!globalThis.window; - var ENVIRONMENT_IS_WORKER = !!globalThis.WorkerGlobalScope; - // N.b. Electron.js environment is simultaneously a NODE-environment, but - // also a web environment. - var ENVIRONMENT_IS_NODE = - globalThis.process?.versions?.node && - globalThis.process?.type != "renderer"; - var ENVIRONMENT_IS_SHELL = - !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER; - - if (ENVIRONMENT_IS_NODE) { - // When building an ES module `require` is not normally available. - // We need to use `createRequire()` to construct the require()` function. - const { createRequire } = await import("module"); - /** @suppress{duplicate} */ - var require = createRequire(import.meta.url); - } - - // --pre-jses are emitted after the Module integration code, so that they can - // refer to Module (if they choose; they can also define Module) - - var arguments_ = []; - var thisProgram = "./this.program"; - var quit_ = (status, toThrow) => { - throw toThrow; - }; - - var _scriptName = import.meta.url; - - // `/` should be present at the end if `scriptDirectory` is not empty - var scriptDirectory = ""; - function locateFile(path) { - if (Module["locateFile"]) { - return Module["locateFile"](path, scriptDirectory); - } - return scriptDirectory + path; - } - - // Hooks that are implemented differently in different runtime environments. - var readAsync, readBinary; - - if (ENVIRONMENT_IS_NODE) { - const isNode = - globalThis.process?.versions?.node && - globalThis.process?.type != "renderer"; - if (!isNode) - throw new Error( - "not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)" - ); - - // These modules will usually be used on Node.js. Load them eagerly to avoid - // the complexity of lazy-loading. - var fs = require("fs"); - - if (_scriptName.startsWith("file:")) { - scriptDirectory = - require("path").dirname(require("url").fileURLToPath(_scriptName)) + - "/"; - } - - // include: node_shell_read.js - readBinary = filename => { - // We need to re-wrap `file://` strings to URLs. - filename = isFileURI(filename) ? new URL(filename) : filename; - var ret = fs.readFileSync(filename); - assert(Buffer.isBuffer(ret)); - return ret; - }; - - readAsync = async (filename, binary = true) => { - // See the comment in the `readBinary` function. - filename = isFileURI(filename) ? new URL(filename) : filename; - var ret = fs.readFileSync(filename, binary ? undefined : "utf8"); - assert(binary ? Buffer.isBuffer(ret) : typeof ret == "string"); - return ret; - }; - // end include: node_shell_read.js - if (process.argv.length > 1) { - thisProgram = process.argv[1].replace(/\\/g, "/"); - } - - arguments_ = process.argv.slice(2); - - quit_ = (status, toThrow) => { - process.exitCode = status; - throw toThrow; - }; - } else if (ENVIRONMENT_IS_SHELL) { - } - - // Note that this includes Node.js workers when relevant (pthreads is enabled). - // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and - // ENVIRONMENT_IS_NODE. - else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { - try { - scriptDirectory = new URL(".", _scriptName).href; // includes trailing slash - } catch { - // Must be a `blob:` or `data:` URL (e.g. `blob:http://site.com/etc/etc`), we cannot - // infer anything from them. - } - - if (!(globalThis.window || globalThis.WorkerGlobalScope)) - throw new Error( - "not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)" - ); - - { - // include: web_or_worker_shell_read.js - if (ENVIRONMENT_IS_WORKER) { - readBinary = url => { - var xhr = new XMLHttpRequest(); - xhr.open("GET", url, false); - xhr.responseType = "arraybuffer"; - xhr.send(null); - return new Uint8Array(/** @type{!ArrayBuffer} */ (xhr.response)); - }; - } - - readAsync = async url => { - assert(!isFileURI(url), "readAsync does not work with file:// URLs"); - var response = await fetch(url, { credentials: "same-origin" }); - if (response.ok) { - return response.arrayBuffer(); - } - throw new Error(response.status + " : " + response.url); - }; - // end include: web_or_worker_shell_read.js - } - } else { - throw new Error("environment detection error"); - } - - var out = console.log.bind(console); - var err = console.error.bind(console); - - var IDBFS = "IDBFS is no longer included by default; build with -lidbfs.js"; - var PROXYFS = - "PROXYFS is no longer included by default; build with -lproxyfs.js"; - var WORKERFS = - "WORKERFS is no longer included by default; build with -lworkerfs.js"; - var FETCHFS = - "FETCHFS is no longer included by default; build with -lfetchfs.js"; - var ICASEFS = - "ICASEFS is no longer included by default; build with -licasefs.js"; - var JSFILEFS = - "JSFILEFS is no longer included by default; build with -ljsfilefs.js"; - var OPFS = "OPFS is no longer included by default; build with -lopfs.js"; - - var NODEFS = - "NODEFS is no longer included by default; build with -lnodefs.js"; - - // perform assertions in shell.js after we set up out() and err(), as otherwise - // if an assertion fails it cannot print the message - - assert( - !ENVIRONMENT_IS_SHELL, - "shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable." - ); - - // end include: shell.js - - // include: preamble.js - // === Preamble library stuff === - - // Documentation for the public APIs defined in this file must be updated in: - // site/source/docs/api_reference/preamble.js.rst - // A prebuilt local version of the documentation is available at: - // site/build/text/docs/api_reference/preamble.js.txt - // You can also build docs locally as HTML or other formats in site/ - // An online HTML version (which may be of a different version of Emscripten) - // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html - - var wasmBinary; - - if (!globalThis.WebAssembly) { - err("no native wasm support detected"); - } - - // Wasm globals - - //======================================== - // Runtime essentials - //======================================== - - // whether we are quitting the application. no code should run after this. - // set in exit() and abort() - var ABORT = false; - - // set by exit() and abort(). Passed to 'onExit' handler. - // NOTE: This is also used as the process return code code in shell environments - // but only when noExitRuntime is false. - var EXITSTATUS; - - // In STRICT mode, we only define assert() when ASSERTIONS is set. i.e. we - // don't define it at all in release modes. This matches the behaviour of - // MINIMAL_RUNTIME. - // TODO(sbc): Make this the default even without STRICT enabled. - /** @type {function(*, string=)} */ - function assert(condition, text) { - if (!condition) { - abort("Assertion failed" + (text ? ": " + text : "")); - } - } - - // We used to include malloc/free by default in the past. Show a helpful error in - // builds with assertions. - - /** - * Indicates whether filename is delivered via file protocol (as opposed to http/https) - * @noinline - */ - var isFileURI = filename => filename.startsWith("file://"); - - // include: runtime_common.js - // include: runtime_stack_check.js - // Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode. - function writeStackCookie() { - var max = _emscripten_stack_get_end(); - assert((max & 3) == 0); - // If the stack ends at address zero we write our cookies 4 bytes into the - // stack. This prevents interference with SAFE_HEAP and ASAN which also - // monitor writes to address zero. - if (max == 0) { - max += 4; - } - // The stack grow downwards towards _emscripten_stack_get_end. - // We write cookies to the final two words in the stack and detect if they are - // ever overwritten. - HEAPU32[max >> 2] = 0x02135467; - HEAPU32[(max + 4) >> 2] = 0x89bacdfe; - // Also test the global address 0 for integrity. - HEAPU32[0 >> 2] = 1668509029; - } - - function checkStackCookie() { - if (ABORT) return; - var max = _emscripten_stack_get_end(); - // See writeStackCookie(). - if (max == 0) { - max += 4; - } - var cookie1 = HEAPU32[max >> 2]; - var cookie2 = HEAPU32[(max + 4) >> 2]; - if (cookie1 != 0x02135467 || cookie2 != 0x89bacdfe) { - abort( - `Stack overflow! Stack cookie has been overwritten at ${ptrToString( - max - )}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString( - cookie2 - )} ${ptrToString(cookie1)}` - ); - } - // Also test the global address 0 for integrity. - if (HEAPU32[0 >> 2] != 0x63736d65 /* 'emsc' */) { - abort( - "Runtime error: The application has corrupted its heap memory area (address zero)!" - ); - } - } - // end include: runtime_stack_check.js - // include: runtime_exceptions.js - // end include: runtime_exceptions.js - // include: runtime_debug.js - var runtimeDebug = true; // Switch to false at runtime to disable logging at the right times - - // Used by XXXXX_DEBUG settings to output debug messages. - function dbg(...args) { - if (!runtimeDebug && typeof runtimeDebug != "undefined") return; - // TODO(sbc): Make this configurable somehow. Its not always convenient for - // logging to show up as warnings. - console.warn(...args); - } - - // Endianness check - (() => { - var h16 = new Int16Array(1); - var h8 = new Int8Array(h16.buffer); - h16[0] = 0x6373; - if (h8[0] !== 0x73 || h8[1] !== 0x63) - abort( - "Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)" - ); - })(); - - function consumedModuleProp(prop) { - if (!Object.getOwnPropertyDescriptor(Module, prop)) { - Object.defineProperty(Module, prop, { - configurable: true, - set() { - abort( - `Attempt to set \`Module.${prop}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'` - ); - } - }); - } - } - - function makeInvalidEarlyAccess(name) { - return () => - assert( - false, - `call to '${name}' via reference taken before Wasm module initialization` - ); - } - - function ignoredModuleProp(prop) { - if (Object.getOwnPropertyDescriptor(Module, prop)) { - abort( - `\`Module.${prop}\` was supplied but \`${prop}\` not included in INCOMING_MODULE_JS_API` - ); - } - } - - // forcing the filesystem exports a few things by default - function isExportedByForceFilesystem(name) { - return ( - name === "FS_createPath" || - name === "FS_createDataFile" || - name === "FS_createPreloadedFile" || - name === "FS_preloadFile" || - name === "FS_unlink" || - name === "addRunDependency" || - // The old FS has some functionality that WasmFS lacks. - name === "FS_createLazyFile" || - name === "FS_createDevice" || - name === "removeRunDependency" - ); - } - - function missingLibrarySymbol(sym) { - // Any symbol that is not included from the JS library is also (by definition) - // not exported on the Module object. - unexportedRuntimeSymbol(sym); - } - - function unexportedRuntimeSymbol(sym) { - if (!Object.getOwnPropertyDescriptor(Module, sym)) { - Object.defineProperty(Module, sym, { - configurable: true, - get() { - var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`; - if (isExportedByForceFilesystem(sym)) { - msg += - ". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"; - } - abort(msg); - } - }); - } - } - - // end include: runtime_debug.js - var readyPromiseResolve, readyPromiseReject; - - // Memory management - var /** @type {!Int8Array} */ - HEAP8, - /** @type {!Uint8Array} */ - HEAPU8, - /** @type {!Int16Array} */ - HEAP16, - /** @type {!Uint16Array} */ - HEAPU16, - /** @type {!Int32Array} */ - HEAP32, - /** @type {!Uint32Array} */ - HEAPU32, - /** @type {!Float32Array} */ - HEAPF32, - /** @type {!Float64Array} */ - HEAPF64; - - // BigInt64Array type is not correctly defined in closure - var /** not-@type {!BigInt64Array} */ - HEAP64, - /* BigUint64Array type is not correctly defined in closure -/** not-@type {!BigUint64Array} */ - HEAPU64; - - var runtimeInitialized = false; - - function updateMemoryViews() { - var b = wasmMemory.buffer; - HEAP8 = new Int8Array(b); - HEAP16 = new Int16Array(b); - Module["HEAPU8"] = HEAPU8 = new Uint8Array(b); - HEAPU16 = new Uint16Array(b); - HEAP32 = new Int32Array(b); - HEAPU32 = new Uint32Array(b); - HEAPF32 = new Float32Array(b); - HEAPF64 = new Float64Array(b); - HEAP64 = new BigInt64Array(b); - HEAPU64 = new BigUint64Array(b); - } - - // include: memoryprofiler.js - // end include: memoryprofiler.js - // end include: runtime_common.js - assert( - globalThis.Int32Array && - globalThis.Float64Array && - Int32Array.prototype.subarray && - Int32Array.prototype.set, - "JS engine does not provide full typed array support" - ); - - function preRun() { - if (Module["preRun"]) { - if (typeof Module["preRun"] == "function") - Module["preRun"] = [Module["preRun"]]; - while (Module["preRun"].length) { - addOnPreRun(Module["preRun"].shift()); - } - } - consumedModuleProp("preRun"); - // Begin ATPRERUNS hooks - callRuntimeCallbacks(onPreRuns); - // End ATPRERUNS hooks - } - - function initRuntime() { - assert(!runtimeInitialized); - runtimeInitialized = true; - - checkStackCookie(); - - // No ATINITS hooks - - wasmExports["__wasm_call_ctors"](); - - // No ATPOSTCTORS hooks - } - - function postRun() { - checkStackCookie(); - // PThreads reuse the runtime from the main thread. - - if (Module["postRun"]) { - if (typeof Module["postRun"] == "function") - Module["postRun"] = [Module["postRun"]]; - while (Module["postRun"].length) { - addOnPostRun(Module["postRun"].shift()); - } - } - consumedModuleProp("postRun"); - - // Begin ATPOSTRUNS hooks - callRuntimeCallbacks(onPostRuns); - // End ATPOSTRUNS hooks - } - - /** @param {string|number=} what */ - function abort(what) { - Module["onAbort"]?.(what); - - what = "Aborted(" + what + ")"; - // TODO(sbc): Should we remove printing and leave it up to whoever - // catches the exception? - err(what); - - ABORT = true; - - // Use a wasm runtime error, because a JS error might be seen as a foreign - // exception, which means we'd run destructors on it. We need the error to - // simply make the program stop. - // FIXME This approach does not work in Wasm EH because it currently does not assume - // all RuntimeErrors are from traps; it decides whether a RuntimeError is from - // a trap or not based on a hidden field within the object. So at the moment - // we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that - // allows this in the wasm spec. - - // Suppress closure compiler warning here. Closure compiler's builtin extern - // definition for WebAssembly.RuntimeError claims it takes no arguments even - // though it can. - // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed. - /** @suppress {checkTypes} */ - var e = new WebAssembly.RuntimeError(what); - - readyPromiseReject?.(e); - // Throw the error whether or not MODULARIZE is set because abort is used - // in code paths apart from instantiation where an exception is expected - // to be thrown when abort is called. - throw e; - } - - // show errors on likely calls to FS when it was not included - var FS = { - error() { - abort( - "Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM" - ); - }, - init() { - FS.error(); - }, - createDataFile() { - FS.error(); - }, - createPreloadedFile() { - FS.error(); - }, - createLazyFile() { - FS.error(); - }, - open() { - FS.error(); - }, - mkdev() { - FS.error(); - }, - registerDevice() { - FS.error(); - }, - analyzePath() { - FS.error(); - }, - - ErrnoError() { - FS.error(); - } - }; - - function createExportWrapper(name, nargs) { - return (...args) => { - assert( - runtimeInitialized, - `native function \`${name}\` called before runtime initialization` - ); - var f = wasmExports[name]; - assert(f, `exported native function \`${name}\` not found`); - // Only assert for too many arguments. Too few can be valid since the missing arguments will be zero filled. - assert( - args.length <= nargs, - `native function \`${name}\` called with ${args.length} args but expects ${nargs}` - ); - return f(...args); - }; - } - - var wasmBinaryFile; - - function findWasmBinary() { - if (Module["locateFile"]) { - return locateFile("cspuz_solver_backend.wasm"); - } - - // Use bundler-friendly `new URL(..., import.meta.url)` pattern; works in browsers too. - return new URL("cspuz_solver_backend.wasm", import.meta.url).href; - } - - function getBinarySync(file) { - if (file == wasmBinaryFile && wasmBinary) { - return new Uint8Array(wasmBinary); - } - if (readBinary) { - return readBinary(file); - } - // Throwing a plain string here, even though it not normally adviables since - // this gets turning into an `abort` in instantiateArrayBuffer. - throw "both async and sync fetching of the wasm failed"; - } - - async function getWasmBinary(binaryFile) { - // If we don't have the binary yet, load it asynchronously using readAsync. - if (!wasmBinary) { - // Fetch the binary using readAsync - try { - var response = await readAsync(binaryFile); - return new Uint8Array(response); - } catch { - // Fall back to getBinarySync below; - } - } - - // Otherwise, getBinarySync should be able to get it synchronously - return getBinarySync(binaryFile); - } - - async function instantiateArrayBuffer(binaryFile, imports) { - try { - var binary = await getWasmBinary(binaryFile); - var instance = await WebAssembly.instantiate(binary, imports); - return instance; - } catch (reason) { - err(`failed to asynchronously prepare wasm: ${reason}`); - - // Warn on some common problems. - if (isFileURI(binaryFile)) { - err( - `warning: Loading from a file URI (${binaryFile}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing` - ); - } - abort(reason); - } - } - - async function instantiateAsync(binary, binaryFile, imports) { - if ( - !binary && - // Avoid instantiateStreaming() on Node.js environment for now, as while - // Node.js v18.1.0 implements it, it does not have a full fetch() - // implementation yet. - // - // Reference: - // https://github.com/emscripten-core/emscripten/pull/16917 - !ENVIRONMENT_IS_NODE - ) { - try { - var response = fetch(binaryFile, { credentials: "same-origin" }); - var instantiationResult = await WebAssembly.instantiateStreaming( - response, - imports - ); - return instantiationResult; - } catch (reason) { - // We expect the most common failure cause to be a bad MIME type for the binary, - // in which case falling back to ArrayBuffer instantiation should work. - err(`wasm streaming compile failed: ${reason}`); - err("falling back to ArrayBuffer instantiation"); - // fall back of instantiateArrayBuffer below - } - } - return instantiateArrayBuffer(binaryFile, imports); - } - - function getWasmImports() { - // prepare imports - var imports = { - env: wasmImports, - wasi_snapshot_preview1: wasmImports - }; - return imports; - } - - // Create the wasm instance. - // Receives the wasm imports, returns the exports. - async function createWasm() { - // Load the wasm module and create an instance of using native support in the JS engine. - // handle a generated wasm instance, receiving its exports and - // performing other necessary setup - /** @param {WebAssembly.Module=} module*/ - function receiveInstance(instance, module) { - wasmExports = instance.exports; - - assignWasmExports(wasmExports); - - updateMemoryViews(); - - return wasmExports; - } - - // Prefer streaming instantiation if available. - // Async compilation can be confusing when an error on the page overwrites Module - // (for example, if the order of elements is wrong, and the one defining Module is - // later), so we save Module and check it later. - var trueModule = Module; - function receiveInstantiationResult(result) { - // 'result' is a ResultObject object which has both the module and instance. - // receiveInstance() will swap in the exports (to Module.asm) so they can be called - assert( - Module === trueModule, - "the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?" - ); - trueModule = null; - // TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193, the above line no longer optimizes out down to the following line. - // When the regression is fixed, can restore the above PTHREADS-enabled path. - return receiveInstance(result["instance"]); - } - - var info = getWasmImports(); - - // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback - // to manually instantiate the Wasm module themselves. This allows pages to - // run the instantiation parallel to any other async startup actions they are - // performing. - // Also pthreads and wasm workers initialize the wasm instance through this - // path. - if (Module["instantiateWasm"]) { - return new Promise((resolve, reject) => { - try { - Module["instantiateWasm"](info, (inst, mod) => { - resolve(receiveInstance(inst, mod)); - }); - } catch (e) { - err(`Module.instantiateWasm callback failed with error: ${e}`); - reject(e); - } - }); - } - - wasmBinaryFile ??= findWasmBinary(); - var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info); - var exports = receiveInstantiationResult(result); - return exports; - } - - // end include: preamble.js - - // Begin JS library code - - class ExitStatus { - name = "ExitStatus"; - constructor(status) { - this.message = `Program terminated with exit(${status})`; - this.status = status; - } - } - - var callRuntimeCallbacks = callbacks => { - while (callbacks.length > 0) { - // Pass the module as the first argument. - callbacks.shift()(Module); - } - }; - var onPostRuns = []; - var addOnPostRun = cb => onPostRuns.push(cb); - - var onPreRuns = []; - var addOnPreRun = cb => onPreRuns.push(cb); - - /** - * @param {number} ptr - * @param {string} type - */ - function getValue(ptr, type = "i8") { - if (type.endsWith("*")) type = "*"; - switch (type) { - case "i1": - return HEAP8[ptr]; - case "i8": - return HEAP8[ptr]; - case "i16": - return HEAP16[ptr >> 1]; - case "i32": - return HEAP32[ptr >> 2]; - case "i64": - return HEAP64[ptr >> 3]; - case "float": - return HEAPF32[ptr >> 2]; - case "double": - return HEAPF64[ptr >> 3]; - case "*": - return HEAPU32[ptr >> 2]; - default: - abort(`invalid type for getValue: ${type}`); - } - } - - var noExitRuntime = true; - - var ptrToString = ptr => { - assert( - typeof ptr === "number", - `ptrToString expects a number, got ${typeof ptr}` - ); - // Convert to 32-bit unsigned value - ptr >>>= 0; - return "0x" + ptr.toString(16).padStart(8, "0"); - }; - - /** - * @param {number} ptr - * @param {number} value - * @param {string} type - */ - function setValue(ptr, value, type = "i8") { - if (type.endsWith("*")) type = "*"; - switch (type) { - case "i1": - HEAP8[ptr] = value; - break; - case "i8": - HEAP8[ptr] = value; - break; - case "i16": - HEAP16[ptr >> 1] = value; - break; - case "i32": - HEAP32[ptr >> 2] = value; - break; - case "i64": - HEAP64[ptr >> 3] = BigInt(value); - break; - case "float": - HEAPF32[ptr >> 2] = value; - break; - case "double": - HEAPF64[ptr >> 3] = value; - break; - case "*": - HEAPU32[ptr >> 2] = value; - break; - default: - abort(`invalid type for setValue: ${type}`); - } - } - - var stackRestore = val => __emscripten_stack_restore(val); - - var stackSave = () => _emscripten_stack_get_current(); - - var warnOnce = text => { - warnOnce.shown ||= {}; - if (!warnOnce.shown[text]) { - warnOnce.shown[text] = 1; - if (ENVIRONMENT_IS_NODE) text = "warning: " + text; - err(text); - } - }; - - var UTF8Decoder = globalThis.TextDecoder && new TextDecoder(); - - var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => { - var maxIdx = idx + maxBytesToRead; - if (ignoreNul) return maxIdx; - // TextDecoder needs to know the byte length in advance, it doesn't stop on - // null terminator by itself. - // As a tiny code save trick, compare idx against maxIdx using a negation, - // so that maxBytesToRead=undefined/NaN means Infinity. - while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx; - return idx; - }; - - /** - * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given - * array that contains uint8 values, returns a copy of that string as a - * Javascript String object. - * heapOrArray is either a regular array, or a JavaScript typed array view. - * @param {number=} idx - * @param {number=} maxBytesToRead - * @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character. - * @return {string} - */ - var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead, ignoreNul) => { - var endPtr = findStringEnd(heapOrArray, idx, maxBytesToRead, ignoreNul); - - // When using conditional TextDecoder, skip it for short strings as the overhead of the native call is not worth it. - if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) { - return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr)); - } - var str = ""; - while (idx < endPtr) { - // For UTF8 byte structure, see: - // http://en.wikipedia.org/wiki/UTF-8#Description - // https://www.ietf.org/rfc/rfc2279.txt - // https://tools.ietf.org/html/rfc3629 - var u0 = heapOrArray[idx++]; - if (!(u0 & 0x80)) { - str += String.fromCharCode(u0); - continue; - } - var u1 = heapOrArray[idx++] & 63; - if ((u0 & 0xe0) == 0xc0) { - str += String.fromCharCode(((u0 & 31) << 6) | u1); - continue; - } - var u2 = heapOrArray[idx++] & 63; - if ((u0 & 0xf0) == 0xe0) { - u0 = ((u0 & 15) << 12) | (u1 << 6) | u2; - } else { - if ((u0 & 0xf8) != 0xf0) - warnOnce( - "Invalid UTF-8 leading byte " + - ptrToString(u0) + - " encountered when deserializing a UTF-8 string in wasm memory to a JS string!" - ); - u0 = - ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63); - } - - if (u0 < 0x10000) { - str += String.fromCharCode(u0); - } else { - var ch = u0 - 0x10000; - str += String.fromCharCode(0xd800 | (ch >> 10), 0xdc00 | (ch & 0x3ff)); - } - } - return str; - }; - - /** - * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the - * emscripten HEAP, returns a copy of that string as a Javascript String object. - * - * @param {number} ptr - * @param {number=} maxBytesToRead - An optional length that specifies the - * maximum number of bytes to read. You can omit this parameter to scan the - * string until the first 0 byte. If maxBytesToRead is passed, and the string - * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the - * string will cut short at that byte index. - * @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character. - * @return {string} - */ - var UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => { - assert( - typeof ptr == "number", - `UTF8ToString expects a number (got ${typeof ptr})` - ); - return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead, ignoreNul) : ""; - }; - var ___assert_fail = (condition, filename, line, func) => - abort( - `Assertion failed: ${UTF8ToString(condition)}, at: ` + - [ - filename ? UTF8ToString(filename) : "unknown filename", - line, - func ? UTF8ToString(func) : "unknown function" - ] - ); - - var exceptionLast = 0; - - class ExceptionInfo { - // excPtr - Thrown object pointer to wrap. Metadata pointer is calculated from it. - constructor(excPtr) { - this.excPtr = excPtr; - this.ptr = excPtr - 24; - } - - set_type(type) { - HEAPU32[(this.ptr + 4) >> 2] = type; - } - - get_type() { - return HEAPU32[(this.ptr + 4) >> 2]; - } - - set_destructor(destructor) { - HEAPU32[(this.ptr + 8) >> 2] = destructor; - } - - get_destructor() { - return HEAPU32[(this.ptr + 8) >> 2]; - } - - set_caught(caught) { - caught = caught ? 1 : 0; - HEAP8[this.ptr + 12] = caught; - } - - get_caught() { - return HEAP8[this.ptr + 12] != 0; - } - - set_rethrown(rethrown) { - rethrown = rethrown ? 1 : 0; - HEAP8[this.ptr + 13] = rethrown; - } - - get_rethrown() { - return HEAP8[this.ptr + 13] != 0; - } - - // Initialize native structure fields. Should be called once after allocated. - init(type, destructor) { - this.set_adjusted_ptr(0); - this.set_type(type); - this.set_destructor(destructor); - } - - set_adjusted_ptr(adjustedPtr) { - HEAPU32[(this.ptr + 16) >> 2] = adjustedPtr; - } - - get_adjusted_ptr() { - return HEAPU32[(this.ptr + 16) >> 2]; - } - } - - var setTempRet0 = val => __emscripten_tempret_set(val); - var findMatchingCatch = args => { - var thrown = exceptionLast; - if (!thrown) { - // just pass through the null ptr - setTempRet0(0); - return 0; - } - var info = new ExceptionInfo(thrown); - info.set_adjusted_ptr(thrown); - var thrownType = info.get_type(); - if (!thrownType) { - // just pass through the thrown ptr - setTempRet0(0); - return thrown; - } - - // can_catch receives a **, add indirection - // The different catch blocks are denoted by different types. - // Due to inheritance, those types may not precisely match the - // type of the thrown object. Find one which matches, and - // return the type of the catch block which should be called. - for (var caughtType of args) { - if (caughtType === 0 || caughtType === thrownType) { - // Catch all clause matched or exactly the same type is caught - break; - } - var adjusted_ptr_addr = info.ptr + 16; - if (___cxa_can_catch(caughtType, thrownType, adjusted_ptr_addr)) { - setTempRet0(caughtType); - return thrown; - } - } - setTempRet0(thrownType); - return thrown; - }; - var ___cxa_find_matching_catch_2 = () => findMatchingCatch([]); - - var ___resumeException = ptr => { - if (!exceptionLast) { - exceptionLast = ptr; - } - assert( - false, - "Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch." - ); - }; - - var SYSCALLS = { - varargs: undefined, - getStr(ptr) { - var ret = UTF8ToString(ptr); - return ret; - } - }; - var ___syscall_getcwd = (buf, size) => { - abort( - "it should not be possible to operate on streams when !SYSCALLS_REQUIRE_FILESYSTEM" - ); - }; - - var __abort_js = () => abort("native code called abort()"); - - var _emscripten_get_now = () => performance.now(); - - var _emscripten_date_now = () => Date.now(); - - var nowIsMonotonic = 1; - - var checkWasiClock = clock_id => clock_id >= 0 && clock_id <= 3; - - var INT53_MAX = 9007199254740992; - - var INT53_MIN = -9007199254740992; - var bigintToI53Checked = num => - num < INT53_MIN || num > INT53_MAX ? NaN : Number(num); - function _clock_time_get(clk_id, ignored_precision, ptime) { - ignored_precision = bigintToI53Checked(ignored_precision); - - if (!checkWasiClock(clk_id)) { - return 28; - } - var now; - // all wasi clocks but realtime are monotonic - if (clk_id === 0) { - now = _emscripten_date_now(); - } else if (nowIsMonotonic) { - now = _emscripten_get_now(); - } else { - return 52; - } - // "now" is in ms, and wasi times are in ns. - var nsec = Math.round(now * 1000 * 1000); - HEAP64[ptime >> 3] = BigInt(nsec); - return 0; - } - - var getHeapMax = () => - // Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate - // full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side - // for any code that deals with heap sizes, which would require special - // casing all heap size related code to treat 0 specially. - 2147483648; - - var alignMemory = (size, alignment) => { - assert(alignment, "alignment argument is required"); - return Math.ceil(size / alignment) * alignment; - }; - - var growMemory = size => { - var oldHeapSize = wasmMemory.buffer.byteLength; - var pages = ((size - oldHeapSize + 65535) / 65536) | 0; - try { - // round size grow request up to wasm page size (fixed 64KB per spec) - wasmMemory.grow(pages); // .grow() takes a delta compared to the previous size - updateMemoryViews(); - return 1 /*success*/; - } catch (e) { - err( - `growMemory: Attempted to grow heap from ${oldHeapSize} bytes to ${size} bytes, but got error: ${e}` - ); - } - // implicit 0 return to save code size (caller will cast "undefined" into 0 - // anyhow) - }; - var _emscripten_resize_heap = requestedSize => { - var oldSize = HEAPU8.length; - // With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned. - requestedSize >>>= 0; - // With multithreaded builds, races can happen (another thread might increase the size - // in between), so return a failure, and let the caller retry. - assert(requestedSize > oldSize); - - // Memory resize rules: - // 1. Always increase heap size to at least the requested size, rounded up - // to next page multiple. - // 2a. If MEMORY_GROWTH_LINEAR_STEP == -1, excessively resize the heap - // geometrically: increase the heap size according to - // MEMORY_GROWTH_GEOMETRIC_STEP factor (default +20%), At most - // overreserve by MEMORY_GROWTH_GEOMETRIC_CAP bytes (default 96MB). - // 2b. If MEMORY_GROWTH_LINEAR_STEP != -1, excessively resize the heap - // linearly: increase the heap size by at least - // MEMORY_GROWTH_LINEAR_STEP bytes. - // 3. Max size for the heap is capped at 2048MB-WASM_PAGE_SIZE, or by - // MAXIMUM_MEMORY, or by ASAN limit, depending on which is smallest - // 4. If we were unable to allocate as much memory, it may be due to - // over-eager decision to excessively reserve due to (3) above. - // Hence if an allocation fails, cut down on the amount of excess - // growth, in an attempt to succeed to perform a smaller allocation. - - // A limit is set for how much we can grow. We should not exceed that - // (the wasm binary specifies it, so if we tried, we'd fail anyhow). - var maxHeapSize = getHeapMax(); - if (requestedSize > maxHeapSize) { - err( - `Cannot enlarge memory, requested ${requestedSize} bytes, but the limit is ${maxHeapSize} bytes!` - ); - return false; - } - - // Loop through potential heap size increases. If we attempt a too eager - // reservation that fails, cut down on the attempted size and reserve a - // smaller bump instead. (max 3 times, chosen somewhat arbitrarily) - for (var cutDown = 1; cutDown <= 4; cutDown *= 2) { - var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown); // ensure geometric growth - // but limit overreserving (default to capping at +96MB overgrowth at most) - overGrownHeapSize = Math.min( - overGrownHeapSize, - requestedSize + 100663296 - ); - - var newSize = Math.min( - maxHeapSize, - alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536) - ); - - var replacement = growMemory(newSize); - if (replacement) { - return true; - } - } - err( - `Failed to grow the heap from ${oldSize} bytes to ${newSize} bytes, not enough memory!` - ); - return false; - }; - - var ENV = {}; - - var getExecutableName = () => thisProgram || "./this.program"; - var getEnvStrings = () => { - if (!getEnvStrings.strings) { - // Default values. - // Browser language detection #8751 - var lang = - ((typeof navigator == "object" && navigator.language) || "C").replace( - "-", - "_" - ) + ".UTF-8"; - var env = { - USER: "web_user", - LOGNAME: "web_user", - PATH: "/", - PWD: "/", - HOME: "/home/web_user", - LANG: lang, - _: getExecutableName() - }; - // Apply the user-provided values, if any. - for (var x in ENV) { - // x is a key in ENV; if ENV[x] is undefined, that means it was - // explicitly set to be so. We allow user code to do that to - // force variables with default values to remain unset. - if (ENV[x] === undefined) delete env[x]; - else env[x] = ENV[x]; - } - var strings = []; - for (var x in env) { - strings.push(`${x}=${env[x]}`); - } - getEnvStrings.strings = strings; - } - return getEnvStrings.strings; - }; - - var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => { - assert( - typeof str === "string", - `stringToUTF8Array expects a string (got ${typeof str})` - ); - // Parameter maxBytesToWrite is not optional. Negative values, 0, null, - // undefined and false each don't write out any bytes. - if (!(maxBytesToWrite > 0)) return 0; - - var startIdx = outIdx; - var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator. - for (var i = 0; i < str.length; ++i) { - // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description - // and https://www.ietf.org/rfc/rfc2279.txt - // and https://tools.ietf.org/html/rfc3629 - var u = str.codePointAt(i); - if (u <= 0x7f) { - if (outIdx >= endIdx) break; - heap[outIdx++] = u; - } else if (u <= 0x7ff) { - if (outIdx + 1 >= endIdx) break; - heap[outIdx++] = 0xc0 | (u >> 6); - heap[outIdx++] = 0x80 | (u & 63); - } else if (u <= 0xffff) { - if (outIdx + 2 >= endIdx) break; - heap[outIdx++] = 0xe0 | (u >> 12); - heap[outIdx++] = 0x80 | ((u >> 6) & 63); - heap[outIdx++] = 0x80 | (u & 63); - } else { - if (outIdx + 3 >= endIdx) break; - if (u > 0x10ffff) - warnOnce( - "Invalid Unicode code point " + - ptrToString(u) + - " encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF)." - ); - heap[outIdx++] = 0xf0 | (u >> 18); - heap[outIdx++] = 0x80 | ((u >> 12) & 63); - heap[outIdx++] = 0x80 | ((u >> 6) & 63); - heap[outIdx++] = 0x80 | (u & 63); - // Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16. - // We need to manually skip over the second code unit for correct iteration. - i++; - } - } - // Null-terminate the pointer to the buffer. - heap[outIdx] = 0; - return outIdx - startIdx; - }; - var stringToUTF8 = (str, outPtr, maxBytesToWrite) => { - assert( - typeof maxBytesToWrite == "number", - "stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!" - ); - return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite); - }; - var _environ_get = (__environ, environ_buf) => { - var bufSize = 0; - var envp = 0; - for (var string of getEnvStrings()) { - var ptr = environ_buf + bufSize; - HEAPU32[(__environ + envp) >> 2] = ptr; - bufSize += stringToUTF8(string, ptr, Infinity) + 1; - envp += 4; - } - return 0; - }; - - var lengthBytesUTF8 = str => { - var len = 0; - for (var i = 0; i < str.length; ++i) { - // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code - // unit, not a Unicode code point of the character! So decode - // UTF16->UTF32->UTF8. - // See http://unicode.org/faq/utf_bom.html#utf16-3 - var c = str.charCodeAt(i); // possibly a lead surrogate - if (c <= 0x7f) { - len++; - } else if (c <= 0x7ff) { - len += 2; - } else if (c >= 0xd800 && c <= 0xdfff) { - len += 4; - ++i; - } else { - len += 3; - } - } - return len; - }; - var _environ_sizes_get = (penviron_count, penviron_buf_size) => { - var strings = getEnvStrings(); - HEAPU32[penviron_count >> 2] = strings.length; - var bufSize = 0; - for (var string of strings) { - bufSize += lengthBytesUTF8(string) + 1; - } - HEAPU32[penviron_buf_size >> 2] = bufSize; - return 0; - }; - - var runtimeKeepaliveCounter = 0; - var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0; - var _proc_exit = code => { - EXITSTATUS = code; - if (!keepRuntimeAlive()) { - Module["onExit"]?.(code); - ABORT = true; - } - quit_(code, new ExitStatus(code)); - }; - - /** @param {boolean|number=} implicit */ - var exitJS = (status, implicit) => { - EXITSTATUS = status; - - checkUnflushedContent(); - - // if exit() was called explicitly, warn the user if the runtime isn't actually being shut down - if (keepRuntimeAlive() && !implicit) { - var msg = `program exited (with status: ${status}), but keepRuntimeAlive() is set (counter=${runtimeKeepaliveCounter}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`; - readyPromiseReject?.(msg); - err(msg); - } - - _proc_exit(status); - }; - var _exit = exitJS; - - var _fd_close = fd => { - abort("fd_close called without SYSCALLS_REQUIRE_FILESYSTEM"); - }; - - function _fd_seek(fd, offset, whence, newOffset) { - offset = bigintToI53Checked(offset); - - return 70; - } - - var printCharBuffers = [null, [], []]; - - var printChar = (stream, curr) => { - var buffer = printCharBuffers[stream]; - assert(buffer); - if (curr === 0 || curr === 10) { - (stream === 1 ? out : err)(UTF8ArrayToString(buffer)); - buffer.length = 0; - } else { - buffer.push(curr); - } - }; - - var flush_NO_FILESYSTEM = () => { - // flush anything remaining in the buffers during shutdown - _fflush(0); - if (printCharBuffers[1].length) printChar(1, 10); - if (printCharBuffers[2].length) printChar(2, 10); - }; - - var _fd_write = (fd, iov, iovcnt, pnum) => { - // hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0 - var num = 0; - for (var i = 0; i < iovcnt; i++) { - var ptr = HEAPU32[iov >> 2]; - var len = HEAPU32[(iov + 4) >> 2]; - iov += 8; - for (var j = 0; j < len; j++) { - printChar(fd, HEAPU8[ptr + j]); - } - num += len; - } - HEAPU32[pnum >> 2] = num; - return 0; - }; - - var wasmTableMirror = []; - - var getWasmTableEntry = funcPtr => { - var func = wasmTableMirror[funcPtr]; - if (!func) { - /** @suppress {checkTypes} */ - wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr); - } - /** @suppress {checkTypes} */ - assert( - wasmTable.get(funcPtr) == func, - "JavaScript-side Wasm function table mirror is out of date!" - ); - return func; - }; - // End JS library code - - // include: postlibrary.js - // This file is included after the automatically-generated JS library code - // but before the wasm module is created. - - { - // Begin ATMODULES hooks - if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"]; - if (Module["print"]) out = Module["print"]; - if (Module["printErr"]) err = Module["printErr"]; - if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"]; - - Module["FS_createDataFile"] = FS.createDataFile; - Module["FS_createPreloadedFile"] = FS.createPreloadedFile; - - // End ATMODULES hooks - - checkIncomingModuleAPI(); - - if (Module["arguments"]) arguments_ = Module["arguments"]; - if (Module["thisProgram"]) thisProgram = Module["thisProgram"]; - - // Assertions on removed incoming Module JS APIs. - assert( - typeof Module["memoryInitializerPrefixURL"] == "undefined", - "Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead" - ); - assert( - typeof Module["pthreadMainPrefixURL"] == "undefined", - "Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead" - ); - assert( - typeof Module["cdInitializerPrefixURL"] == "undefined", - "Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead" - ); - assert( - typeof Module["filePackagePrefixURL"] == "undefined", - "Module.filePackagePrefixURL option was removed, use Module.locateFile instead" - ); - assert( - typeof Module["read"] == "undefined", - "Module.read option was removed" - ); - assert( - typeof Module["readAsync"] == "undefined", - "Module.readAsync option was removed (modify readAsync in JS)" - ); - assert( - typeof Module["readBinary"] == "undefined", - "Module.readBinary option was removed (modify readBinary in JS)" - ); - assert( - typeof Module["setWindowTitle"] == "undefined", - "Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)" - ); - assert( - typeof Module["TOTAL_MEMORY"] == "undefined", - "Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY" - ); - assert( - typeof Module["ENVIRONMENT"] == "undefined", - "Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)" - ); - assert( - typeof Module["STACK_SIZE"] == "undefined", - "STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time" - ); - // If memory is defined in wasm, the user can't provide it, or set INITIAL_MEMORY - assert( - typeof Module["wasmMemory"] == "undefined", - "Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally" - ); - assert( - typeof Module["INITIAL_MEMORY"] == "undefined", - "Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically" - ); - - if (Module["preInit"]) { - if (typeof Module["preInit"] == "function") - Module["preInit"] = [Module["preInit"]]; - while (Module["preInit"].length > 0) { - Module["preInit"].shift()(); - } - } - consumedModuleProp("preInit"); - } - - // Begin runtime exports - var missingLibrarySymbols = [ - "writeI53ToI64", - "writeI53ToI64Clamped", - "writeI53ToI64Signaling", - "writeI53ToU64Clamped", - "writeI53ToU64Signaling", - "readI53FromI64", - "readI53FromU64", - "convertI32PairToI53", - "convertI32PairToI53Checked", - "convertU32PairToI53", - "stackAlloc", - "getTempRet0", - "createNamedFunction", - "zeroMemory", - "withStackSave", - "strError", - "inetPton4", - "inetNtop4", - "inetPton6", - "inetNtop6", - "readSockaddr", - "writeSockaddr", - "readEmAsmArgs", - "jstoi_q", - "autoResumeAudioContext", - "getDynCaller", - "dynCall", - "handleException", - "runtimeKeepalivePush", - "runtimeKeepalivePop", - "callUserCallback", - "maybeExit", - "asyncLoad", - "asmjsMangle", - "mmapAlloc", - "HandleAllocator", - "getUniqueRunDependency", - "addRunDependency", - "removeRunDependency", - "addOnInit", - "addOnPostCtor", - "addOnPreMain", - "addOnExit", - "STACK_SIZE", - "STACK_ALIGN", - "POINTER_SIZE", - "ASSERTIONS", - "ccall", - "cwrap", - "convertJsFunctionToWasm", - "getEmptyTableSlot", - "updateTableMap", - "getFunctionAddress", - "addFunction", - "removeFunction", - "intArrayFromString", - "intArrayToString", - "AsciiToString", - "stringToAscii", - "UTF16ToString", - "stringToUTF16", - "lengthBytesUTF16", - "UTF32ToString", - "stringToUTF32", - "lengthBytesUTF32", - "stringToNewUTF8", - "stringToUTF8OnStack", - "writeArrayToMemory", - "registerKeyEventCallback", - "maybeCStringToJsString", - "findEventTarget", - "getBoundingClientRect", - "fillMouseEventData", - "registerMouseEventCallback", - "registerWheelEventCallback", - "registerUiEventCallback", - "registerFocusEventCallback", - "fillDeviceOrientationEventData", - "registerDeviceOrientationEventCallback", - "fillDeviceMotionEventData", - "registerDeviceMotionEventCallback", - "screenOrientation", - "fillOrientationChangeEventData", - "registerOrientationChangeEventCallback", - "fillFullscreenChangeEventData", - "registerFullscreenChangeEventCallback", - "JSEvents_requestFullscreen", - "JSEvents_resizeCanvasForFullscreen", - "registerRestoreOldStyle", - "hideEverythingExceptGivenElement", - "restoreHiddenElements", - "setLetterbox", - "softFullscreenResizeWebGLRenderTarget", - "doRequestFullscreen", - "fillPointerlockChangeEventData", - "registerPointerlockChangeEventCallback", - "registerPointerlockErrorEventCallback", - "requestPointerLock", - "fillVisibilityChangeEventData", - "registerVisibilityChangeEventCallback", - "registerTouchEventCallback", - "fillGamepadEventData", - "registerGamepadEventCallback", - "registerBeforeUnloadEventCallback", - "fillBatteryEventData", - "registerBatteryEventCallback", - "setCanvasElementSize", - "getCanvasElementSize", - "jsStackTrace", - "getCallstack", - "convertPCtoSourceLocation", - "wasiRightsToMuslOFlags", - "wasiOFlagsToMuslOFlags", - "initRandomFill", - "randomFill", - "safeSetTimeout", - "setImmediateWrapped", - "safeRequestAnimationFrame", - "clearImmediateWrapped", - "registerPostMainLoop", - "registerPreMainLoop", - "getPromise", - "makePromise", - "idsToPromises", - "makePromiseCallback", - "Browser_asyncPrepareDataCounter", - "isLeapYear", - "ydayFromDate", - "arraySum", - "addDays", - "getSocketFromFD", - "getSocketAddress", - "heapObjectForWebGLType", - "toTypedArrayIndex", - "webgl_enable_ANGLE_instanced_arrays", - "webgl_enable_OES_vertex_array_object", - "webgl_enable_WEBGL_draw_buffers", - "webgl_enable_WEBGL_multi_draw", - "webgl_enable_EXT_polygon_offset_clamp", - "webgl_enable_EXT_clip_control", - "webgl_enable_WEBGL_polygon_mode", - "emscriptenWebGLGet", - "computeUnpackAlignedImageSize", - "colorChannelsInGlTextureFormat", - "emscriptenWebGLGetTexPixelData", - "emscriptenWebGLGetUniform", - "webglGetUniformLocation", - "webglPrepareUniformLocationsBeforeFirstUse", - "webglGetLeftBracePos", - "emscriptenWebGLGetVertexAttrib", - "__glGetActiveAttribOrUniform", - "writeGLArray", - "registerWebGlEventCallback", - "runAndAbortIfError", - "ALLOC_NORMAL", - "ALLOC_STACK", - "allocate", - "writeStringToMemory", - "writeAsciiToMemory", - "allocateUTF8", - "allocateUTF8OnStack", - "demangle", - "stackTrace", - "getNativeTypeSize" - ]; - missingLibrarySymbols.forEach(missingLibrarySymbol); - - var unexportedSymbols = [ - "run", - "out", - "err", - "callMain", - "abort", - "wasmExports", - "HEAPF32", - "HEAPF64", - "HEAP8", - "HEAP16", - "HEAPU16", - "HEAP32", - "HEAPU32", - "HEAP64", - "HEAPU64", - "writeStackCookie", - "checkStackCookie", - "INT53_MAX", - "INT53_MIN", - "bigintToI53Checked", - "stackSave", - "stackRestore", - "setTempRet0", - "ptrToString", - "exitJS", - "getHeapMax", - "growMemory", - "ENV", - "ERRNO_CODES", - "DNS", - "Protocols", - "Sockets", - "timers", - "warnOnce", - "readEmAsmArgsArray", - "getExecutableName", - "keepRuntimeAlive", - "alignMemory", - "wasmTable", - "wasmMemory", - "noExitRuntime", - "addOnPreRun", - "addOnPostRun", - "freeTableIndexes", - "functionsInTableMap", - "setValue", - "getValue", - "PATH", - "PATH_FS", - "UTF8Decoder", - "UTF8ArrayToString", - "UTF8ToString", - "stringToUTF8Array", - "stringToUTF8", - "lengthBytesUTF8", - "UTF16Decoder", - "JSEvents", - "specialHTMLTargets", - "findCanvasEventTarget", - "currentFullscreenStrategy", - "restoreOldWindowedStyle", - "UNWIND_CACHE", - "ExitStatus", - "getEnvStrings", - "checkWasiClock", - "flush_NO_FILESYSTEM", - "emSetImmediate", - "emClearImmediate_deps", - "emClearImmediate", - "promiseMap", - "uncaughtExceptionCount", - "exceptionLast", - "exceptionCaught", - "ExceptionInfo", - "findMatchingCatch", - "Browser", - "requestFullscreen", - "requestFullScreen", - "setCanvasSize", - "getUserMedia", - "createContext", - "getPreloadedImageData__data", - "wget", - "MONTH_DAYS_REGULAR", - "MONTH_DAYS_LEAP", - "MONTH_DAYS_REGULAR_CUMULATIVE", - "MONTH_DAYS_LEAP_CUMULATIVE", - "SYSCALLS", - "tempFixedLengthArray", - "miniTempWebGLFloatBuffers", - "miniTempWebGLIntBuffers", - "GL", - "AL", - "GLUT", - "EGL", - "GLEW", - "IDBStore", - "SDL", - "SDL_gfx", - "print", - "printErr", - "jstoi_s" - ]; - unexportedSymbols.forEach(unexportedRuntimeSymbol); - - // End runtime exports - // Begin JS library exports - // End JS library exports - - // end include: postlibrary.js - - function checkIncomingModuleAPI() { - ignoredModuleProp("fetchSettings"); - } - - // Imports from the Wasm binary. - var _solve_problem = (Module["_solve_problem"] = makeInvalidEarlyAccess( - "_solve_problem" - )); - var _enumerate_answers_problem = (Module[ - "_enumerate_answers_problem" - ] = makeInvalidEarlyAccess("_enumerate_answers_problem")); - var _free = (Module["_free"] = makeInvalidEarlyAccess("_free")); - var _malloc = (Module["_malloc"] = makeInvalidEarlyAccess("_malloc")); - var _fflush = makeInvalidEarlyAccess("_fflush"); - var _emscripten_stack_get_end = makeInvalidEarlyAccess( - "_emscripten_stack_get_end" - ); - var _emscripten_stack_get_base = makeInvalidEarlyAccess( - "_emscripten_stack_get_base" - ); - var _htonl = makeInvalidEarlyAccess("_htonl"); - var _htons = makeInvalidEarlyAccess("_htons"); - var _ntohs = makeInvalidEarlyAccess("_ntohs"); - var __emscripten_tempret_set = makeInvalidEarlyAccess( - "__emscripten_tempret_set" - ); - var _emscripten_stack_init = makeInvalidEarlyAccess("_emscripten_stack_init"); - var _emscripten_stack_get_free = makeInvalidEarlyAccess( - "_emscripten_stack_get_free" - ); - var __emscripten_stack_restore = makeInvalidEarlyAccess( - "__emscripten_stack_restore" - ); - var __emscripten_stack_alloc = makeInvalidEarlyAccess( - "__emscripten_stack_alloc" - ); - var _emscripten_stack_get_current = makeInvalidEarlyAccess( - "_emscripten_stack_get_current" - ); - var ___cxa_can_catch = makeInvalidEarlyAccess("___cxa_can_catch"); - var memory = makeInvalidEarlyAccess("memory"); - var __indirect_function_table = makeInvalidEarlyAccess( - "__indirect_function_table" - ); - var wasmMemory = makeInvalidEarlyAccess("wasmMemory"); - var wasmTable = makeInvalidEarlyAccess("wasmTable"); - - function assignWasmExports(wasmExports) { - assert( - typeof wasmExports["solve_problem"] != "undefined", - "missing Wasm export: solve_problem" - ); - _solve_problem = Module["_solve_problem"] = createExportWrapper( - "solve_problem", - 2 - ); - assert( - typeof wasmExports["enumerate_answers_problem"] != "undefined", - "missing Wasm export: enumerate_answers_problem" - ); - _enumerate_answers_problem = Module[ - "_enumerate_answers_problem" - ] = createExportWrapper("enumerate_answers_problem", 3); - assert( - typeof wasmExports["free"] != "undefined", - "missing Wasm export: free" - ); - _free = Module["_free"] = createExportWrapper("free", 1); - assert( - typeof wasmExports["malloc"] != "undefined", - "missing Wasm export: malloc" - ); - _malloc = Module["_malloc"] = createExportWrapper("malloc", 1); - assert( - typeof wasmExports["fflush"] != "undefined", - "missing Wasm export: fflush" - ); - _fflush = createExportWrapper("fflush", 1); - assert( - typeof wasmExports["emscripten_stack_get_end"] != "undefined", - "missing Wasm export: emscripten_stack_get_end" - ); - _emscripten_stack_get_end = wasmExports["emscripten_stack_get_end"]; - assert( - typeof wasmExports["emscripten_stack_get_base"] != "undefined", - "missing Wasm export: emscripten_stack_get_base" - ); - _emscripten_stack_get_base = wasmExports["emscripten_stack_get_base"]; - assert( - typeof wasmExports["htonl"] != "undefined", - "missing Wasm export: htonl" - ); - _htonl = createExportWrapper("htonl", 1); - assert( - typeof wasmExports["htons"] != "undefined", - "missing Wasm export: htons" - ); - _htons = createExportWrapper("htons", 1); - assert( - typeof wasmExports["ntohs"] != "undefined", - "missing Wasm export: ntohs" - ); - _ntohs = createExportWrapper("ntohs", 1); - assert( - typeof wasmExports["_emscripten_tempret_set"] != "undefined", - "missing Wasm export: _emscripten_tempret_set" - ); - __emscripten_tempret_set = createExportWrapper( - "_emscripten_tempret_set", - 1 - ); - assert( - typeof wasmExports["emscripten_stack_init"] != "undefined", - "missing Wasm export: emscripten_stack_init" - ); - _emscripten_stack_init = wasmExports["emscripten_stack_init"]; - assert( - typeof wasmExports["emscripten_stack_get_free"] != "undefined", - "missing Wasm export: emscripten_stack_get_free" - ); - _emscripten_stack_get_free = wasmExports["emscripten_stack_get_free"]; - assert( - typeof wasmExports["_emscripten_stack_restore"] != "undefined", - "missing Wasm export: _emscripten_stack_restore" - ); - __emscripten_stack_restore = wasmExports["_emscripten_stack_restore"]; - assert( - typeof wasmExports["_emscripten_stack_alloc"] != "undefined", - "missing Wasm export: _emscripten_stack_alloc" - ); - __emscripten_stack_alloc = wasmExports["_emscripten_stack_alloc"]; - assert( - typeof wasmExports["emscripten_stack_get_current"] != "undefined", - "missing Wasm export: emscripten_stack_get_current" - ); - _emscripten_stack_get_current = wasmExports["emscripten_stack_get_current"]; - assert( - typeof wasmExports["__cxa_can_catch"] != "undefined", - "missing Wasm export: __cxa_can_catch" - ); - ___cxa_can_catch = createExportWrapper("__cxa_can_catch", 3); - assert( - typeof wasmExports["memory"] != "undefined", - "missing Wasm export: memory" - ); - memory = wasmMemory = wasmExports["memory"]; - assert( - typeof wasmExports["__indirect_function_table"] != "undefined", - "missing Wasm export: __indirect_function_table" - ); - __indirect_function_table = wasmTable = - wasmExports["__indirect_function_table"]; - } - - var wasmImports = { - /** @export */ - __assert_fail: ___assert_fail, - /** @export */ - __cxa_find_matching_catch_2: ___cxa_find_matching_catch_2, - /** @export */ - __resumeException: ___resumeException, - /** @export */ - __syscall_getcwd: ___syscall_getcwd, - /** @export */ - _abort_js: __abort_js, - /** @export */ - clock_time_get: _clock_time_get, - /** @export */ - emscripten_resize_heap: _emscripten_resize_heap, - /** @export */ - environ_get: _environ_get, - /** @export */ - environ_sizes_get: _environ_sizes_get, - /** @export */ - exit: _exit, - /** @export */ - fd_close: _fd_close, - /** @export */ - fd_seek: _fd_seek, - /** @export */ - fd_write: _fd_write, - /** @export */ - invoke_ii, - /** @export */ - invoke_iiii, - /** @export */ - invoke_iiiiii, - /** @export */ - invoke_vi, - /** @export */ - invoke_vii, - /** @export */ - invoke_viii, - /** @export */ - invoke_viiii, - /** @export */ - invoke_viiiii - }; - - function invoke_vi(index, a1) { - var sp = stackSave(); - try { - getWasmTableEntry(index)(a1); - } catch (e) { - stackRestore(sp); - if (e !== e + 0) throw e; - _setThrew(1, 0); - } - } - - function invoke_vii(index, a1, a2) { - var sp = stackSave(); - try { - getWasmTableEntry(index)(a1, a2); - } catch (e) { - stackRestore(sp); - if (e !== e + 0) throw e; - _setThrew(1, 0); - } - } - - function invoke_viii(index, a1, a2, a3) { - var sp = stackSave(); - try { - getWasmTableEntry(index)(a1, a2, a3); - } catch (e) { - stackRestore(sp); - if (e !== e + 0) throw e; - _setThrew(1, 0); - } - } - - function invoke_ii(index, a1) { - var sp = stackSave(); - try { - return getWasmTableEntry(index)(a1); - } catch (e) { - stackRestore(sp); - if (e !== e + 0) throw e; - _setThrew(1, 0); - } - } - - function invoke_viiiii(index, a1, a2, a3, a4, a5) { - var sp = stackSave(); - try { - getWasmTableEntry(index)(a1, a2, a3, a4, a5); - } catch (e) { - stackRestore(sp); - if (e !== e + 0) throw e; - _setThrew(1, 0); - } - } - - function invoke_viiii(index, a1, a2, a3, a4) { - var sp = stackSave(); - try { - getWasmTableEntry(index)(a1, a2, a3, a4); - } catch (e) { - stackRestore(sp); - if (e !== e + 0) throw e; - _setThrew(1, 0); - } - } - - function invoke_iiii(index, a1, a2, a3) { - var sp = stackSave(); - try { - return getWasmTableEntry(index)(a1, a2, a3); - } catch (e) { - stackRestore(sp); - if (e !== e + 0) throw e; - _setThrew(1, 0); - } - } - - function invoke_iiiiii(index, a1, a2, a3, a4, a5) { - var sp = stackSave(); - try { - return getWasmTableEntry(index)(a1, a2, a3, a4, a5); - } catch (e) { - stackRestore(sp); - if (e !== e + 0) throw e; - _setThrew(1, 0); - } - } - - // include: postamble.js - // === Auto-generated postamble setup entry stuff === - - var calledRun; - - function stackCheckInit() { - // This is normally called automatically during __wasm_call_ctors but need to - // get these values before even running any of the ctors so we call it redundantly - // here. - _emscripten_stack_init(); - // TODO(sbc): Move writeStackCookie to native to to avoid this. - writeStackCookie(); - } - - function run() { - stackCheckInit(); - - preRun(); - - function doRun() { - // run may have just been called through dependencies being fulfilled just in this very frame, - // or while the async setStatus time below was happening - assert(!calledRun); - calledRun = true; - Module["calledRun"] = true; - - if (ABORT) return; - - initRuntime(); - - readyPromiseResolve?.(Module); - Module["onRuntimeInitialized"]?.(); - consumedModuleProp("onRuntimeInitialized"); - - assert( - !Module["_main"], - 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]' - ); - - postRun(); - } - - if (Module["setStatus"]) { - Module["setStatus"]("Running..."); - setTimeout(() => { - setTimeout(() => Module["setStatus"](""), 1); - doRun(); - }, 1); - } else { - doRun(); - } - checkStackCookie(); - } - - function checkUnflushedContent() { - // Compiler settings do not allow exiting the runtime, so flushing - // the streams is not possible. but in ASSERTIONS mode we check - // if there was something to flush, and if so tell the user they - // should request that the runtime be exitable. - // Normally we would not even include flush() at all, but in ASSERTIONS - // builds we do so just for this check, and here we see if there is any - // content to flush, that is, we check if there would have been - // something a non-ASSERTIONS build would have not seen. - // How we flush the streams depends on whether we are in SYSCALLS_REQUIRE_FILESYSTEM=0 - // mode (which has its own special function for this; otherwise, all - // the code is inside libc) - var oldOut = out; - var oldErr = err; - var has = false; - out = err = x => { - has = true; - }; - try { - // it doesn't matter if it fails - flush_NO_FILESYSTEM(); - } catch (e) {} - out = oldOut; - err = oldErr; - if (has) { - warnOnce( - "stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc." - ); - warnOnce( - "(this may also be due to not including full filesystem support - try building with -sFORCE_FILESYSTEM)" - ); - } - } - - var wasmExports; - - // In modularize mode the generated code is within a factory function so we - // can use await here (since it's not top-level-await). - wasmExports = await createWasm(); - - run(); - - // end include: postamble.js - - // include: postamble_modularize.js - // In MODULARIZE mode we wrap the generated code in a factory function - // and return either the Module itself, or a promise of the module. - // - // We assign to the `moduleRtn` global here and configure closure to see - // this as and extern so it won't get minified. - - if (runtimeInitialized) { - moduleRtn = Module; - } else { - // Set up the promise that indicates the Module is initialized - moduleRtn = new Promise((resolve, reject) => { - readyPromiseResolve = resolve; - readyPromiseReject = reject; - }); - } - - // Assertion for attempting to access module properties on the incoming - // moduleArg. In the past we used this object as the prototype of the module - // and assigned properties to it, but now we return a distinct object. This - // keeps the instance private until it is ready (i.e the promise has been - // resolved). - for (const prop of Object.keys(Module)) { - if (!(prop in moduleArg)) { - Object.defineProperty(moduleArg, prop, { - configurable: true, - get() { - abort( - `Access to module property ('${prop}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.` - ); - } - }); - } - } - // end include: postamble_modularize.js - - return moduleRtn; -} - -// Export using a UMD style export, or ES6 exports if selected -export default Module; +async function Module(moduleArg={}){var moduleRtn;var Module=moduleArg;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(ENVIRONMENT_IS_NODE){const{createRequire}=await import("module");var require=createRequire(import.meta.url)}var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var _scriptName=import.meta.url;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs");if(_scriptName.startsWith("file:")){scriptDirectory=require("path").dirname(require("url").fileURLToPath(_scriptName))+"/"}readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;var EXITSTATUS;var isFileURI=filename=>filename.startsWith("file://");var readyPromiseResolve,readyPromiseReject;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var HEAP64,HEAPU64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;HEAP8=new Int8Array(b);HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["w"]()}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject?.(e);throw e}var wasmBinaryFile;function findWasmBinary(){if(Module["locateFile"]){return locateFile("cspuz_solver_backend.wasm")}return new URL("cspuz_solver_backend.wasm",import.meta.url).href}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&!ENVIRONMENT_IS_NODE){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){var imports={a:wasmImports};return imports}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;assignWasmExports(wasmExports);updateMemoryViews();return wasmExports}function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(inst,mod)=>{resolve(receiveInstance(inst,mod))})})}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var noExitRuntime=true;var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var UTF8Decoder=globalThis.TextDecoder&&new TextDecoder;var findStringEnd=(heapOrArray,idx,maxBytesToRead,ignoreNul)=>{var maxIdx=idx+maxBytesToRead;if(ignoreNul)return maxIdx;while(heapOrArray[idx]&&!(idx>=maxIdx))++idx;return idx};var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead,ignoreNul)=>{var endPtr=findStringEnd(heapOrArray,idx,maxBytesToRead,ignoreNul);if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead,ignoreNul)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead,ignoreNul):"";var ___assert_fail=(condition,filename,line,func)=>abort(`Assertion failed: ${UTF8ToString(condition)}, at: `+[filename?UTF8ToString(filename):"unknown filename",line,func?UTF8ToString(func):"unknown function"]);var exceptionLast=0;class ExceptionInfo{constructor(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24}set_type(type){HEAPU32[this.ptr+4>>2]=type}get_type(){return HEAPU32[this.ptr+4>>2]}set_destructor(destructor){HEAPU32[this.ptr+8>>2]=destructor}get_destructor(){return HEAPU32[this.ptr+8>>2]}set_caught(caught){caught=caught?1:0;HEAP8[this.ptr+12]=caught}get_caught(){return HEAP8[this.ptr+12]!=0}set_rethrown(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13]=rethrown}get_rethrown(){return HEAP8[this.ptr+13]!=0}init(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)}set_adjusted_ptr(adjustedPtr){HEAPU32[this.ptr+16>>2]=adjustedPtr}get_adjusted_ptr(){return HEAPU32[this.ptr+16>>2]}}var setTempRet0=val=>__emscripten_tempret_set(val);var findMatchingCatch=args=>{var thrown=exceptionLast;if(!thrown){setTempRet0(0);return 0}var info=new ExceptionInfo(thrown);info.set_adjusted_ptr(thrown);var thrownType=info.get_type();if(!thrownType){setTempRet0(0);return thrown}for(var caughtType of args){if(caughtType===0||caughtType===thrownType){break}var adjusted_ptr_addr=info.ptr+16;if(___cxa_can_catch(caughtType,thrownType,adjusted_ptr_addr)){setTempRet0(caughtType);return thrown}}setTempRet0(thrownType);return thrown};var ___cxa_find_matching_catch_2=()=>findMatchingCatch([]);var ___resumeException=ptr=>{if(!exceptionLast){exceptionLast=ptr}throw exceptionLast};var ___syscall_getcwd=(buf,size)=>{};var __abort_js=()=>abort("");var _emscripten_get_now=()=>performance.now();var _emscripten_date_now=()=>Date.now();var nowIsMonotonic=1;var checkWasiClock=clock_id=>clock_id>=0&&clock_id<=3;var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>numINT53_MAX?NaN:Number(num);function _clock_time_get(clk_id,ignored_precision,ptime){ignored_precision=bigintToI53Checked(ignored_precision);if(!checkWasiClock(clk_id)){return 28}var now;if(clk_id===0){now=_emscripten_date_now()}else if(nowIsMonotonic){now=_emscripten_get_now()}else{return 52}var nsec=Math.round(now*1e3*1e3);HEAP64[ptime>>3]=BigInt(nsec);return 0}var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var ENV={};var getExecutableName=()=>thisProgram||"./this.program";var getEnvStrings=()=>{if(!getEnvStrings.strings){var lang=(typeof navigator=="object"&&navigator.language||"C").replace("-","_")+".UTF-8";var env={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:lang,_:getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(`${x}=${env[x]}`)}getEnvStrings.strings=strings}return getEnvStrings.strings};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63;i++}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var _environ_get=(__environ,environ_buf)=>{var bufSize=0;var envp=0;for(var string of getEnvStrings()){var ptr=environ_buf+bufSize;HEAPU32[__environ+envp>>2]=ptr;bufSize+=stringToUTF8(string,ptr,Infinity)+1;envp+=4}return 0};var lengthBytesUTF8=str=>{var len=0;for(var i=0;i=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var _environ_sizes_get=(penviron_count,penviron_buf_size)=>{var strings=getEnvStrings();HEAPU32[penviron_count>>2]=strings.length;var bufSize=0;for(var string of strings){bufSize+=lengthBytesUTF8(string)+1}HEAPU32[penviron_buf_size>>2]=bufSize;return 0};var runtimeKeepaliveCounter=0;var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var _proc_exit=code=>{EXITSTATUS=code;if(!keepRuntimeAlive()){Module["onExit"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))};var exitJS=(status,implicit)=>{EXITSTATUS=status;_proc_exit(status)};var _exit=exitJS;var _fd_close=fd=>52;function _fd_seek(fd,offset,whence,newOffset){offset=bigintToI53Checked(offset);return 70}var printCharBuffers=[null,[],[]];var printChar=(stream,curr)=>{var buffer=printCharBuffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer));buffer.length=0}else{buffer.push(curr)}};var _fd_write=(fd,iov,iovcnt,pnum)=>{var num=0;for(var i=0;i>2];var len=HEAPU32[iov+4>>2];iov+=8;for(var j=0;j>2]=num;return 0};var wasmTableMirror=[];var getWasmTableEntry=funcPtr=>{var func=wasmTableMirror[funcPtr];if(!func){wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};{if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].shift()()}}}var _solve_problem,_enumerate_answers_problem,_free,_malloc,__emscripten_tempret_set,__emscripten_stack_restore,_emscripten_stack_get_current,___cxa_can_catch,memory,__indirect_function_table,wasmMemory,wasmTable;function assignWasmExports(wasmExports){_solve_problem=Module["_solve_problem"]=wasmExports["y"];_enumerate_answers_problem=Module["_enumerate_answers_problem"]=wasmExports["z"];_free=Module["_free"]=wasmExports["A"];_malloc=Module["_malloc"]=wasmExports["B"];__emscripten_tempret_set=wasmExports["C"];__emscripten_stack_restore=wasmExports["D"];_emscripten_stack_get_current=wasmExports["E"];___cxa_can_catch=wasmExports["F"];memory=wasmMemory=wasmExports["v"];__indirect_function_table=wasmTable=wasmExports["x"]}var wasmImports={a:___assert_fail,b:___cxa_find_matching_catch_2,c:___resumeException,o:___syscall_getcwd,r:__abort_js,q:_clock_time_get,m:_emscripten_resize_heap,s:_environ_get,t:_environ_sizes_get,i:_exit,p:_fd_close,n:_fd_seek,k:_fd_write,j:invoke_ii,g:invoke_iiii,u:invoke_iiiiii,d:invoke_vi,e:invoke_vii,f:invoke_viii,l:invoke_viiii,h:invoke_viiiii};function invoke_vi(index,a1){var sp=stackSave();try{getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiii(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function run(){preRun();function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve?.(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}var wasmExports;wasmExports=await (createWasm());run();if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})} +;return moduleRtn}export default Module; From 642313278960939076fa0e42e7f074f5f03ebe89 Mon Sep 17 00:00:00 2001 From: ReverM Date: Thu, 18 Dec 2025 17:06:09 -0500 Subject: [PATCH 24/46] Added city space --- src-ui/list.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src-ui/list.html b/src-ui/list.html index c767bed2b..f207aa724 100644 --- a/src-ui/list.html +++ b/src-ui/list.html @@ -70,8 +70,8 @@

    パズルの種類のリスト +
  • From 0a8db3e2a4b4bebde520f50b04fbf5bcdb0978d5 Mon Sep 17 00:00:00 2001 From: ReverM Date: Thu, 18 Dec 2025 17:29:52 -0500 Subject: [PATCH 25/46] Fixed bug with kouchoku --- src/puzzle/Board.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/puzzle/Board.js b/src/puzzle/Board.js index 629efa448..e3e808b01 100644 --- a/src/puzzle/Board.js +++ b/src/puzzle/Board.js @@ -126,6 +126,9 @@ pzpr.classmgr.makeCommon({ if (updateBorders && this.clearSolverAnswerForBorders()) { needUpdateField = true; } + if (this.clearSolverAnswerForCrosses()) { + needUpdateField = true; + } if (needUpdateField) { this.puzzle.painter.paintAll(); } @@ -269,8 +272,7 @@ pzpr.classmgr.makeCommon({ (c.qsubBySolver = 0), (c.qnumBySolver = -1), (a = !0)), - null !== c.qcandBySolver && ((c.qcandBySolver = null), (a = !0)), - c.destBySolver.length !== 0 && ((c.destBySolver = []), (a = !0)); + null !== c.qcandBySolver && ((c.qcandBySolver = null), (a = !0)); } return a; }, @@ -304,7 +306,9 @@ pzpr.classmgr.makeCommon({ for (var g = 0; g < solution.length; ++g) { var h = solution[g]; if ( - ("kakuro" === this.pid || "doppelblock" === this.pid || "aquarium" === this.pid ) && + ("kakuro" === this.pid || + "doppelblock" === this.pid || + "aquarium" === this.pid) && "green" === h.color && h.x % 2 === 1 && h.y % 2 === 1 From ea7b0745327332e9bc52aebb2545f65b3cba10bd Mon Sep 17 00:00:00 2001 From: ReverM Date: Sat, 14 Feb 2026 17:32:45 -0500 Subject: [PATCH 26/46] Added various solvers --- src-ui/list.html | 12 +-- src/puzzle/Board.js | 16 +-- src/variety-common/Graphic.js | 186 ++++++++++++++++++---------------- src/variety/roma.js | 4 + 4 files changed, 115 insertions(+), 103 deletions(-) diff --git a/src-ui/list.html b/src-ui/list.html index f207aa724..2901f065a 100644 --- a/src-ui/list.html +++ b/src-ui/list.html @@ -285,8 +285,8 @@

    パズルの種類のリスト
  • -
  • +
  • +
  • +
  • --> +
  • @@ -418,8 +418,8 @@

    パズルの種類のリストVariety Puzzles (without numbers)
      +
    • diff --git a/src/puzzle/Board.js b/src/puzzle/Board.js index e3e808b01..818b58c8b 100644 --- a/src/puzzle/Board.js +++ b/src/puzzle/Board.js @@ -278,7 +278,7 @@ pzpr.classmgr.makeCommon({ }, updateSolverAnswerForCells: function(result) { - if ((this.clearSolverAnswerForCells(), "string" !== typeof result)) { + if ((this.clearSolverAnswerForCells(), "string" !== typeof result) && result.hasAnswer) { for (var b = [], c = 0; c < this.rows; ++c) { for (var d = [], e = 0; e < this.cols; ++e) { d.push([]); @@ -340,17 +340,19 @@ pzpr.classmgr.makeCommon({ "yinyang" !== this.pid) || "firewalkCellUl" === j[k] || "firewalkCellDr" === j[k] || - "firewalkCellUlDr" === j[k] + "firewalkCellUlDr" === j[k] || + "arrowUp" === j[k] ) { i.qansBySolver = 1; } else if ( "triangle" === j[k] || "firewalkCellUr" === j[k] || "firewalkCellDl" === j[k] || - "firewalkCellUrDl" === j[k] + "firewalkCellUrDl" === j[k] || + "arrowDown" === j[k] ) { i.qansBySolver = 2; - } else if ("square" === j[k] || "firewalkCellUnknown" === j[k]) { + } else if ("square" === j[k] || "firewalkCellUnknown" === j[k] || "arrowLeft" === j[k]) { i.qansBySolver = 3; } else if ( "dot" === j[k] || @@ -360,7 +362,7 @@ pzpr.classmgr.makeCommon({ i.qsubBySolver = 1; } else if ("aboloUpperLeft" === j[k]) { i.qansBySolver = 5; - } else if ("aboloUpperRight" === j[k]) { + } else if ("aboloUpperRight" === j[k] || "arrowRight" === j[k]) { i.qansBySolver = 4; } else if ("aboloLowerLeft" === j[k]) { i.qansBySolver = 2; @@ -436,7 +438,7 @@ pzpr.classmgr.makeCommon({ }, updateSolverAnswerForBorders: function(result) { - if ((this.clearSolverAnswerForBorders(), "string" !== typeof result)) { + if ((this.clearSolverAnswerForBorders(), "string" !== typeof result) && result.hasAnswer) { for (var b = [], c = 0; c < 2 * this.rows + 1; ++c) { for (var d = [], e = 0; e < 2 * this.cols + 1; ++e) { d.push([]); @@ -498,7 +500,7 @@ pzpr.classmgr.makeCommon({ return a; }, updateSolverAnswerForCrosses: function(result) { - if ((this.clearSolverAnswerForCrosses(), "string" !== typeof result)) { + if ((this.clearSolverAnswerForCrosses(), "string" !== typeof result) && result.hasAnswer) { for (var b = [], c = 0; c < 2 * this.rows + 1; ++c) { for (var d = [], e = 0; e < 2 * this.cols + 1; ++e) { d.push([]); diff --git a/src/variety-common/Graphic.js b/src/variety-common/Graphic.js index 13516e551..421fb9bfd 100644 --- a/src/variety-common/Graphic.js +++ b/src/variety-common/Graphic.js @@ -38,12 +38,12 @@ pzpr.classmgr.makeCommon({ return this.quescolor; }, - getColorSolverAware: function(a, b, c) { - return a && b + getColorSolverAware: function(answerBool, solverBool, color) { + return answerBool && solverBool ? this.solverqanscolor - : b + : solverBool ? this.solvercolor - : c || this.qanscolor; + : color || this.qanscolor; }, isSameSymbol: function(answerKey, answerDict, solverKey, solverDict) { @@ -327,12 +327,17 @@ pzpr.classmgr.makeCommon({ } for (var i = 0; i < clist.length; i++) { - var cell = clist[i], - dir = !!cell.getArrow - ? cell.getArrow() - : !cell.numberAsObject - ? cell.qdir - : cell.getNum(); + var cell = clist[i]; + var dir; + if (!!cell.getArrow) { + dir = cell.getArrow(); + } + else if (!cell.numberAsObject) { + dir = cell.qdir; + } + else { + dir = cell.getNum(); + } var color = dir >= 1 && dir <= 4 ? func.call(this, cell) : null; g.vid = "c_arrow_" + item + "_" + cell.id; @@ -344,88 +349,89 @@ pzpr.classmgr.makeCommon({ py = cell.by * this.bh; switch (dir) { case cell.UP: - g.setOffsetLinePath( - px, - py, - 0, - -al, - -tw, - -tl, - -aw, - -tl, - -aw, - al, - aw, - al, - aw, - -tl, - tw, - -tl, - true - ); + g.setOffsetLinePath(px, py, 0, -al, -tw, -tl, -aw, -tl, -aw, al, aw, al, aw, -tl, tw, -tl, true); + break; + case cell.DN: + g.setOffsetLinePath(px, py, 0, al, -tw, tl, -aw, tl, -aw, -al, aw, -al, aw, tl, tw, tl, true); + break; + case cell.LT: + g.setOffsetLinePath(px, py, -al, 0, -tl, -tw, -tl, -aw, al, -aw, al, aw, -tl, aw, -tl, tw, true); + break; + case cell.RT: + g.setOffsetLinePath(px, py, al, 0, tl, -tw, tl, -aw, -al, -aw, -al, aw, tl, aw, tl, tw, true); + break; + } + if (item === 1) { + g.stroke(); + } else { + g.fill(); + } + } else { + g.vhide(); + } + } + } + }, + drawCellSolverArrows: function(wide) { + var g = this.vinc("cell_solver_arrow", "auto"); + var al, aw, tl, tw; + + if (!wide) { + al = this.cw * 0.4; // ArrowLength + aw = this.cw * 0.03; // ArrowWidth + tl = this.cw * 0.16; // 矢じりの長さの座標(中心-長さ) + tw = this.cw * 0.16; // 矢じりの幅 + } else if (wide === 0.5) { + /* 太い矢印 */ + al = this.cw * 0.35; // ArrowLength + aw = this.cw * 0.1; // ArrowWidth + tl = 0; // 矢じりの長さの座標(中心-長さ) + tw = this.cw * 0.27; // 矢じりの幅 + } else { + /* 太い矢印 */ + al = this.cw * 0.35; // ArrowLength + aw = this.cw * 0.12; // ArrowWidth + tl = 0; // 矢じりの長さの座標(中心-長さ) + tw = this.cw * 0.35; // 矢じりの幅 + } + aw = aw >= 1 ? aw : 1; + tw = tw >= 5 ? tw : 5; + + var clist = this.range.cells; + for (var item = 0; item < 2; item++) { + var func = + item === 1 ? this.getCellArrowOutline : this.getCellArrowColor; + if (!func) { + continue; + } + + for (var i = 0; i < clist.length; i++) { + var cell = clist[i]; + var dir; + if (!!cell.getSolverArrow) { + dir = cell.getSolverArrow(); + } + var color = dir >= 1 && dir <= 4 ? func.call(this, cell) : null; + + g.vid = "c_solver_arrow_" + item + "_" + cell.id; + if (!!color) { + g.lineWidth = 1.5; + g.strokeStyle = g.fillStyle = color; + g.beginPath(); + var px = cell.bx * this.bw, + py = cell.by * this.bh; + switch (dir) { + case cell.UP: + g.setOffsetLinePath(px, py, 0, -al, -tw, -tl, -aw, -tl, -aw, al, aw, al, aw, -tl, tw, -tl, true); break; case cell.DN: - g.setOffsetLinePath( - px, - py, - 0, - al, - -tw, - tl, - -aw, - tl, - -aw, - -al, - aw, - -al, - aw, - tl, - tw, - tl, - true - ); + g.setOffsetLinePath(px, py, 0, al, -tw, tl, -aw, tl, -aw, -al, aw, -al, aw, tl, tw, tl, true); break; case cell.LT: - g.setOffsetLinePath( - px, - py, - -al, - 0, - -tl, - -tw, - -tl, - -aw, - al, - -aw, - al, - aw, - -tl, - aw, - -tl, - tw, - true - ); + g.setOffsetLinePath(px, py, -al, 0, -tl, -tw, -tl, -aw, al, -aw, al, aw, -tl, aw, -tl, tw, true); break; case cell.RT: - g.setOffsetLinePath( - px, - py, - al, - 0, - tl, - -tw, - tl, - -aw, - -al, - -aw, - -al, - aw, - tl, - aw, - tl, - tw, - true - ); + g.setOffsetLinePath(px, py, al, 0, tl, -tw, tl, -aw, -al, -aw, -al, aw, tl, aw, tl, tw, true); break; } if (item === 1) { @@ -442,11 +448,12 @@ pzpr.classmgr.makeCommon({ getCellArrowOutline: null, getCellArrowColor: function(cell) { var dir = !cell.numberAsObject ? cell.qdir : cell.getNum(); - if (dir >= 1 && dir <= 4) { + var solverdir = cell.qansBySolver; + if ((dir >= 1 && dir <= 4) || (solverdir >= 1 && solverdir <= 4)) { if (!cell.numberAsObject || cell.qnum !== -1) { return this.quescolor; } else { - return !cell.trial ? this.qanscolor : this.trialcolor; + return !cell.trial ? this.getColorSolverAware(dir >= 1 && dir <= 4, solverdir >= 1 && solverdir <= 4, this.qanscolor ) : this.trialcolor; } } return null; @@ -931,8 +938,7 @@ pzpr.classmgr.makeCommon({ case cell.UP: g.setOffsetLinePath( px + dx[digit] * scale, - py, - 0, + py, 0, -al, -tw, -tl, diff --git a/src/variety/roma.js b/src/variety/roma.js index ce50560c6..b78f5f510 100644 --- a/src/variety/roma.js +++ b/src/variety/roma.js @@ -170,6 +170,9 @@ getArrow: function() { return this.getNum(); }, + getSolverArrow: function() { + return this.qansBySolver; + }, isGoal: function() { return this.getNum() === 5; } @@ -318,6 +321,7 @@ } this.drawCellArrows(); + this.drawCellSolverArrows(); if (this.pid === "roma") { this.drawGoals(); this.drawHatenas(); From b04be0652c98440696ad278750e27ad5a772b5ee Mon Sep 17 00:00:00 2001 From: ReverM Date: Sat, 14 Feb 2026 19:22:09 -0500 Subject: [PATCH 27/46] Added battleship --- src-ui/list.html | 6 +-- src/variety/statuepark.js | 92 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 3 deletions(-) diff --git a/src-ui/list.html b/src-ui/list.html index 2901f065a..af2d09053 100644 --- a/src-ui/list.html +++ b/src-ui/list.html @@ -1,4 +1,4 @@ - +cd @@ -404,8 +404,8 @@

      パズルの種類のリスト
    • -
    • -
    • +
    • --> +
    • -
    • +
    • +
    • +
    • -
    • +
    • +
    • +
    • - +
    • - +
    • @@ -111,7 +111,7 @@

      パズルの種類のリスト
    • - +
    • @@ -122,8 +122,8 @@

      パズルの種類のリスト
    • +
    @@ -144,8 +144,8 @@

    パズルの種類のリスト +
  • @@ -154,7 +154,7 @@

    パズルの種類のリスト
  • -->
  • - +
  • @@ -339,11 +339,11 @@

    パズルの種類のリスト-->
  • -
  • +
  • +
  • +
  • --> +
  • diff --git a/src/puzzle/Board.js b/src/puzzle/Board.js index 3ce2be876..2281553bd 100644 --- a/src/puzzle/Board.js +++ b/src/puzzle/Board.js @@ -310,7 +310,8 @@ pzpr.classmgr.makeCommon({ "doppelblock" === this.pid || "battleship" === this.pid || "tents" === this.pid || - "aquarium" === this.pid) && + "aquarium" === this.pid || + "easyasabc" === this.pid) && "green" === h.color && h.x % 2 === 1 && h.y % 2 === 1 @@ -339,7 +340,7 @@ pzpr.classmgr.makeCommon({ ("fill" === j[k] && "firewalk" !== this.pid) || ("circle" === j[k] && "doppelblock" !== this.pid && - "yinyang" !== this.pid) || + "yinyang" !== this.pid && "usoone" !== this.pid) || "firewalkCellUl" === j[k] || "firewalkCellDr" === j[k] || "firewalkCellUlDr" === j[k] || @@ -362,6 +363,10 @@ pzpr.classmgr.makeCommon({ ("doppelblock" === this.pid || "yinyang" === this.pid)) ) { i.qsubBySolver = 1; + } else if ("cross" === j[k]) { + i.qsubBySolver = 2; + } else if ("circle" === j[k] && "usoone" === this.pid) { + i.qsubBySolver = 3; } else if ("aboloUpperLeft" === j[k]) { i.qansBySolver = 5; } else if ("aboloUpperRight" === j[k] || "arrowRight" === j[k]) { diff --git a/src/variety/kurotto.js b/src/variety/kurotto.js index ada7296ac..1c1ade26a 100644 --- a/src/variety/kurotto.js +++ b/src/variety/kurotto.js @@ -245,7 +245,7 @@ }, getShadedCellColor: function(cell) { - if (cell.qans !== 1) { + if (cell.qans !== 1 && cell.qansBySolver !== 1) { return null; } var hasinfo = this.board.haserror || this.board.hasinfo; @@ -259,7 +259,7 @@ } else if (this.puzzle.execConfig("irowakeblk") && !hasinfo) { return cell.island.color; } - return this.shadecolor; + return this.getColorSolverAware(cell.qans === 1, cell.qansBySolver === 1, this.shadecolor); } }, "Graphic@mines": { diff --git a/src/variety/usoone.js b/src/variety/usoone.js index dc330d79f..7810e45c3 100644 --- a/src/variety/usoone.js +++ b/src/variety/usoone.js @@ -196,26 +196,26 @@ var cell = clist[i], px, py; - if (cell.qcmp > 0) { + if (cell.qcmp > 0 || cell.qsubBySolver > 1) { px = cell.bx * this.bw; py = cell.by * this.bh; } g.vid = "c_MB1_" + cell.id; - if (cell.qcmp === 1) { - g.strokeStyle = !cell.trial ? this.mbcolor : this.trialcolor; + if (cell.qcmp === 1 || cell.qsubBySolver === 3) { + g.strokeStyle = !cell.trial ? this.getColorSolverAware(cell.qcmp === 1, cell.qsubBySolver === 3, this.mbcolor) : this.trialcolor; g.strokeCircle(px, py, rsize); } else { g.vhide(); } g.vid = "c_MB2_" + cell.id; - if (cell.qcmp === 2) { - g.strokeStyle = !cell.trial ? this.shadecolor : this.trialcolor; + if (cell.qcmp === 2 || cell.qsubBySolver === 2) { + g.strokeStyle = !cell.trial ? this.getColorSolverAware(cell.qcmp === 2, cell.qsubBySolver === 2, this.shadecolor) : this.trialcolor; g.strokeCross(px, py, rsize); } else { g.vhide(); - } + } } } }, From f2b4a0fa61e4f4c91cb782b196a74efbd7ea5ad2 Mon Sep 17 00:00:00 2001 From: ReverM Date: Fri, 6 Mar 2026 15:10:55 -0500 Subject: [PATCH 39/46] Added solver for skyscrapers --- src-ui/list.html | 4 ++-- src/puzzle/Board.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src-ui/list.html b/src-ui/list.html index b29ff8690..f8cf7fe3f 100644 --- a/src-ui/list.html +++ b/src-ui/list.html @@ -337,8 +337,8 @@

    パズルの種類のリスト -
  • +
  • +
  • -
  • +
  • +
  • -
  • +
  • +
  • @@ -377,8 +377,8 @@

    パズルの種類のリストその他 (線を引く) Drawing Puzzles
      - +
    • diff --git a/src/puzzle/Board.js b/src/puzzle/Board.js index 5df6bab17..765cb4023 100644 --- a/src/puzzle/Board.js +++ b/src/puzzle/Board.js @@ -319,8 +319,9 @@ pzpr.classmgr.makeCommon({ ) { b[(h.y - 3) / 2][(h.x - 3) / 2].push(h.item); } else { - ("statuepark" === this.pid || - "circlesquare" === this.pid || + ((("statuepark" === this.pid || + "isowatari" === this.pid || + "circlesquare" === this.pid) && "black" === h.color)|| "green" === h.color) && h.x % 2 === 1 && h.y % 2 === 1 && @@ -340,7 +341,7 @@ pzpr.classmgr.makeCommon({ "filledCircle" === j[k] || ("fill" === j[k] && "firewalk" !== this.pid) || ("circle" === j[k] && - "doppelblock" !== this.pid && + "doppelblock" !== this.pid && "statuepark" !== this.pid && "isowatari" !== this.pid && "yinyang" !== this.pid && "usoone" !== this.pid) || "firewalkCellUl" === j[k] || "firewalkCellDr" === j[k] || @@ -361,7 +362,7 @@ pzpr.classmgr.makeCommon({ } else if ( "dot" === j[k] || ("circle" === j[k] && - ("doppelblock" === this.pid || "yinyang" === this.pid)) + ("doppelblock" === this.pid || "yinyang" === this.pid || "statuepark" === this.pid || "isowatari" === this.pid )) ) { i.qsubBySolver = 1; } else if ("cross" === j[k]) { diff --git a/src/variety/isowatari.js b/src/variety/isowatari.js index aad6744e5..634c05429 100644 --- a/src/variety/isowatari.js +++ b/src/variety/isowatari.js @@ -218,6 +218,7 @@ this.board.maxbx, -1 ); + this.board.autoSolve() } }, "ClusterSizeOperation:Operation": { diff --git a/src/variety/lightshadow.js b/src/variety/lightshadow.js index 768211131..c9717e6dc 100644 --- a/src/variety/lightshadow.js +++ b/src/variety/lightshadow.js @@ -33,7 +33,7 @@ return; } cell.ques = 1 - cell.ques; - this.board.autoSolve(true); + this.board.autoSolve(); cell.draw(); } } @@ -63,8 +63,9 @@ cell.setQnum(-2); } } + this.board.autoSolve(); } - this.board.autoSolve(true); + cell.draw(); }, decIC: function(cell) { @@ -167,7 +168,7 @@ } this.key_inputqnum(ca); } - this.board.autoSolve(true); + this.board.autoSolve(); } } }, diff --git a/src/variety/shugaku.js b/src/variety/shugaku.js index a548b1749..3ab36d687 100644 --- a/src/variety/shugaku.js +++ b/src/variety/shugaku.js @@ -279,7 +279,11 @@ } else { return !!this.isbdh_cc1[qa1] || !!this.isbdh_cc2[qa2]; } + }, + isBorderBySolver: function() { + return this.edgeBySolver !== 0 } + }, Board: { @@ -454,16 +458,19 @@ } g.vid = "c_pillow_" + cell.id; - if (isdraw) { + if (isdraw || cell.qsubBySolver !== 0) { g.lineWidth = 1; - g.strokeStyle = !cell.trial ? "black" : this.trialcolor; + g.strokeStyle = !cell.trial ? this.getColorSolverAwareEdge(isdraw, cell.qsubBySolver !== 0, "black") : this.trialcolor; if (inputting && tc === cell) { g.fillStyle = this.targetbgcolor; } else if (cell.error === 1) { g.fillStyle = this.errbcolor1; - } else { + } else if (isdraw) { g.fillStyle = "white"; } + else { + g.fillStyle = null; + } g.shapeRectCenter(cell.bx * this.bw, cell.by * this.bh, rw, rh); } else { g.vhide(); @@ -471,6 +478,14 @@ } }, + getColorSolverAwareEdge: function(answerBool, solverBool, color) { + return answerBool && solverBool + ? this.solverqanscolor + : solverBool + ? "rgb(120, 120, 160)" + : color || this.qanscolor; + }, + getBorderColor: function(border) { var isdraw = border.isBorder(), mv = this.puzzle.mouse, @@ -500,7 +515,7 @@ (cell2.trial || cell2.qans === 0); } - return isdraw ? (!trial ? this.shadecolor : this.trialcolor) : null; + return (isdraw | border.isBorderBySolver()) ? ((!trial || border.isBorderBySolver()) ? this.getColorSolverAwareEdge(border.isBorder(), border.isBorderBySolver(), this.shadecolor) : this.trialcolor) : null; } }, From 9486a4cc61ea6ad23da1c9415aae393a66c83edd Mon Sep 17 00:00:00 2001 From: ReverM Date: Thu, 9 Apr 2026 15:16:43 -0400 Subject: [PATCH 43/46] The beds were backward --- src/variety/shugaku.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/variety/shugaku.js b/src/variety/shugaku.js index 3ab36d687..ebbc6923d 100644 --- a/src/variety/shugaku.js +++ b/src/variety/shugaku.js @@ -458,9 +458,9 @@ } g.vid = "c_pillow_" + cell.id; - if (isdraw || cell.qsubBySolver !== 0) { + if (isdraw || cell.qansBySolver === 3) { g.lineWidth = 1; - g.strokeStyle = !cell.trial ? this.getColorSolverAwareEdge(isdraw, cell.qsubBySolver !== 0, "black") : this.trialcolor; + g.strokeStyle = !cell.trial ? this.getColorSolverAwareEdge(isdraw, cell.qansBySolver === 3, "black") : this.trialcolor; if (inputting && tc === cell) { g.fillStyle = this.targetbgcolor; } else if (cell.error === 1) { From b72a866666c98c9580f3a39baaaa1dc11defd875 Mon Sep 17 00:00:00 2001 From: ReverM Date: Tue, 21 Apr 2026 15:09:47 -0400 Subject: [PATCH 44/46] Added new solver and tweaked for ABC --- src-ui/list.html | 6 +++--- src/puzzle/Board.js | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src-ui/list.html b/src-ui/list.html index c6cac95f7..c3f36f109 100644 --- a/src-ui/list.html +++ b/src-ui/list.html @@ -48,7 +48,7 @@

      パズルの種類のリスト
    • - +
    • @@ -164,8 +164,8 @@

      パズルの種類のリスト
    • -->
    • - +
    • -
    • +
    • +
    @@ -325,16 +325,16 @@

    パズルの種類のリスト-->
  • - + +
  • タタミ系 Tatami Puzzles
      - +
    • diff --git a/src/puzzle/Board.js b/src/puzzle/Board.js index ed62425bf..9ed3d6c93 100644 --- a/src/puzzle/Board.js +++ b/src/puzzle/Board.js @@ -278,7 +278,6 @@ pzpr.classmgr.makeCommon({ }, updateSolverAnswerForCells: function(result) { - console.log(result); if ((this.clearSolverAnswerForCells(), "string" !== typeof result) && result.hasAnswer) { for (var b = [], c = 0; c < this.rows; ++c) { for (var d = [], e = 0; e < this.cols; ++e) { From 70c787f470d18a9ca60936e4ce5835406986356e Mon Sep 17 00:00:00 2001 From: ReverM Date: Fri, 3 Jul 2026 11:10:10 -0400 Subject: [PATCH 46/46] partial step --- src-ui/list.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src-ui/list.html b/src-ui/list.html index 1c316d09b..bf1b4d706 100644 --- a/src-ui/list.html +++ b/src-ui/list.html @@ -90,7 +90,7 @@

      パズルの種類のリスト
    • - +
    • - +
    • @@ -174,8 +174,8 @@

      パズルの種類のリスト -->
    • +
    • --> +