diff --git a/lib/depject/page/html/render/chess.js b/lib/depject/page/html/render/chess.js index fb45064b..68720cdd 100644 --- a/lib/depject/page/html/render/chess.js +++ b/lib/depject/page/html/render/chess.js @@ -2,7 +2,7 @@ const { h } = require("mutant"); const nest = require("depnest"); const SsbChessDataAccess = require("ssb-chess-data-access"); const SsbChessMithril = require("ssb-chess-mithril"); -const { onceTrue } = require("mutant"); +const { onceTrue, computed } = require("mutant"); exports.needs = nest({ "sbot.obs.connection": "first", @@ -15,8 +15,11 @@ exports.create = function (api) { return nest("page.html.render", function channel(path) { if (path !== "/chess") return; + let chessComponent = null; + let removed = false; + const page = - h("div.wrapper", [ + h("div.wrapper", { className: 'Scroller' }, [ h( "section.content", h("div", { id: "ssb-chess-mithril-plugin", style: { 'margin-top':'20px' } }), @@ -29,22 +32,28 @@ exports.create = function (api) { "ssb-chess-mithril-plugin", ); - if (!attachToElement) { + if (!attachToElement && !removed) { console.log("no element, loop"); setTimeout(() => { loadChess(); }, 500); return; + } else if (!removed) { + const dataAccess = new SsbChessDataAccess.SbotClassic(ssb); + chessComponent = SsbChessMithril(attachToElement, dataAccess); } - - const dataAccess = new SsbChessDataAccess.SbotClassic(ssb); - - SsbChessMithril(attachToElement, dataAccess); }; - loadChess(); - }); + loadChess() + }) + + + return computed(page, p => p, {onUnlisten: () => { + removed = true; - return page; + if (chessComponent) { + chessComponent.destroy(); + } + }}); }); }; diff --git a/package-lock.json b/package-lock.json index 50ae1a13..05e26172 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ssb-ponchowonky", - "version": "5.6.3", + "version": "5.6.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ssb-ponchowonky", - "version": "5.6.3", + "version": "5.6.5", "license": "AGPL-3.0", "dependencies": { "@electron/remote": "^2.1.3", @@ -79,7 +79,7 @@ "ssb-blobs": "^2.0.1", "ssb-book-schema": "^1.0.3", "ssb-chess-data-access": "^2.1.4", - "ssb-chess-mithril": "2.0.9", + "ssb-chess-mithril": "2.1.4", "ssb-client": "^4.9.0", "ssb-config": "^3.4.4", "ssb-conn": "~1.0.0", @@ -710,6 +710,7 @@ "dev": true, "license": "BSD-2-Clause", "optional": true, + "peer": true, "dependencies": { "cross-dirname": "^0.1.0", "debug": "^4.3.4", @@ -731,6 +732,7 @@ "dev": true, "license": "MIT", "optional": true, + "peer": true, "dependencies": { "ms": "^2.1.3" }, @@ -750,6 +752,7 @@ "dev": true, "license": "MIT", "optional": true, + "peer": true, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -760,7 +763,8 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true, "license": "MIT", - "optional": true + "optional": true, + "peer": true }, "node_modules/@eslint/eslintrc": { "version": "0.2.2", @@ -845,6 +849,19 @@ "node": ">=18.0.0" } }, + "node_modules/@lichess-org/chessground": { + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/@lichess-org/chessground/-/chessground-10.5.0.tgz", + "integrity": "sha512-LmTNnzCQ67RQsryzouWY0jYoN24LlpubtPyYko1gmdpTj5HSfz0VgUGB4Gpo6oifg0MyeT9YeV2TdZEbOP6byA==", + "license": "GPL-3.0-or-later", + "engines": { + "node": ">=24", + "pnpm": ">=12" + }, + "funding": { + "url": "https://lichess.org/patron" + } + }, "node_modules/@malept/cross-spawn-promise": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@malept/cross-spawn-promise/-/cross-spawn-promise-2.0.0.tgz", @@ -1266,7 +1283,6 @@ "node_modules/acorn": { "version": "7.1.1", "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -3150,13 +3166,6 @@ "version": "3.0.1", "license": "MIT" }, - "node_modules/chessground": { - "version": "7.6.8", - "resolved": "https://registry.npmjs.org/chessground/-/chessground-7.6.8.tgz", - "integrity": "sha512-8Yj9e7qnmunRguPWLeTyPLJJb6mcAyb1JihacqT3aMDTQbKMyBr2w93VAakvlJGDRB1pJsliR7bBl2FfUl08mw==", - "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", - "license": "GPL-3.0" - }, "node_modules/chloride": { "version": "2.4.0", "license": "MIT", @@ -3698,7 +3707,8 @@ "integrity": "sha512-+R08/oI0nl3vfPcqftZRpytksBXDzOUveBq/NBVx0sUp1axwzPQrKinNx5yd5sxPu8j1wIy8AfnVQ+5eFdha6Q==", "dev": true, "license": "MIT", - "optional": true + "optional": true, + "peer": true }, "node_modules/cross-spawn": { "version": "4.0.2", @@ -4043,7 +4053,6 @@ "integrity": "sha512-EAw1f2iGkICmUvAVBOjm7v5mxJdB7/+OZSycHFhKBimiTkCXtvkCC6wBKzHo7ZQYi58C2MmwIleRbgRnROlK2Q==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "app-builder-lib": "26.17.0", "builder-util": "26.16.0", @@ -4277,7 +4286,6 @@ "resolved": "https://registry.npmjs.org/electron/-/electron-44.7.0.tgz", "integrity": "sha512-aUq9/zLAAFYc+a9gy6cd0C3Y/N/RmovLCD8TV8LhIzNhuND6HEgsu96jJz9cbAxvckSPv+Trf2PKEjktoZgFkw==", "license": "MIT", - "peer": true, "dependencies": { "@electron-internal/extract-zip": "^1.0.1", "@electron/get": "^5.0.0", @@ -4620,6 +4628,7 @@ "dev": true, "hasInstallScript": true, "license": "MIT", + "peer": true, "dependencies": { "@electron/asar": "^3.2.1", "debug": "^4.1.1", @@ -4640,6 +4649,7 @@ "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "ms": "^2.1.3" }, @@ -4658,6 +4668,7 @@ "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "graceful-fs": "^4.1.2", "jsonfile": "^4.0.0", @@ -4672,7 +4683,8 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/electron-winstaller/node_modules/universalify": { "version": "0.1.2", @@ -4680,6 +4692,7 @@ "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">= 4.0.0" } @@ -5056,7 +5069,6 @@ "version": "7.13.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.0.0", "@eslint/eslintrc": "^0.2.1", @@ -5209,7 +5221,6 @@ "version": "2.22.1", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "array-includes": "^3.1.1", "array.prototype.flat": "^1.2.3", @@ -5259,7 +5270,6 @@ "version": "11.1.0", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "eslint-plugin-es": "^3.0.0", "eslint-utils": "^2.0.0", @@ -5287,7 +5297,6 @@ "version": "4.2.1", "dev": true, "license": "ISC", - "peer": true, "engines": { "node": ">=6" } @@ -5296,7 +5305,6 @@ "version": "7.21.5", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "array-includes": "^3.1.1", "array.prototype.flatmap": "^1.2.3", @@ -8457,14 +8465,10 @@ } }, "node_modules/mithril": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/mithril/-/mithril-1.1.7.tgz", - "integrity": "sha512-1SAkGeVrIVvkUHlPHvR3pXdWzNfTzmS/fBAe+rC2ApEBfZFFc+idi8Qg/M5JoW/sZkIDXSfQYVgvENMIhBIVAg==", - "license": "MIT", - "bin": { - "bundle": "bundler/bin/bundle", - "ospec": "ospec/bin/ospec" - } + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/mithril/-/mithril-2.3.6.tgz", + "integrity": "sha512-e9A50asV9nNO96wHcEFPlPNrMjMz6WTlgUBmEALE5zlI4Ynt99wvyvBrzco0qMqh7iMfkUwGDJjuaOlSe8uN/g==", + "license": "MIT" }, "node_modules/mkdirp": { "version": "3.0.1", @@ -9742,7 +9746,6 @@ "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -9944,6 +9947,7 @@ "dev": true, "license": "MIT", "optional": true, + "peer": true, "dependencies": { "commander": "^9.4.0" }, @@ -9961,6 +9965,7 @@ "dev": true, "license": "MIT", "optional": true, + "peer": true, "engines": { "node": "^12.20.0 || >=14" } @@ -9974,7 +9979,6 @@ "node_modules/prettier": { "version": "2.2.1", "license": "MIT", - "peer": true, "bin": { "prettier": "bin-prettier.js" }, @@ -11551,7 +11555,6 @@ "node_modules/secret-stack": { "version": "6.3.2", "license": "MIT", - "peer": true, "dependencies": { "debug": "^4.1.0", "hoox": "0.0.1", @@ -12185,9 +12188,9 @@ "license": "CC0-1.0" }, "node_modules/ssb-chess": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/ssb-chess/-/ssb-chess-4.0.5.tgz", - "integrity": "sha512-iT6TgXh7alif1WIDYj9LJSm8eLAEZ2tJ0xWSac/yLkCAnVd7b2iCCpCW9psehMUGuFJLVypS8Id8J1cMAGvm/Q==", + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/ssb-chess/-/ssb-chess-4.0.9.tgz", + "integrity": "sha512-6feAw6Vkxt2uO9uV7pzlHIToOQz/39gaY5Fu1bKFXRrHbfmvJ4aCB1IwL/tMyO1vYe+dP/kcEgdUS/RNpSPwzA==", "license": "GPL-2.0", "dependencies": { "bluebird": "^3.7.2", @@ -12200,6 +12203,7 @@ "pull-cat": "^1.1.11", "pull-high-watermark": "^0.2.0", "pull-many": "^1.0.8", + "pull-pause": "^0.0.2", "pull-resolve": "^1.2.0", "pull-scan": "^1.0.0", "pull-stream": "^3.6.14", @@ -12234,22 +12238,22 @@ } }, "node_modules/ssb-chess-mithril": { - "version": "2.0.9", - "resolved": "https://registry.npmjs.org/ssb-chess-mithril/-/ssb-chess-mithril-2.0.9.tgz", - "integrity": "sha512-zovDFhTfqRg+O2fKClIt1cIcBh1h/fdc41g3d3mmwk6rtwKrJ2RntrwZc4dP7a/dL846I+VsnsAibx80/SQhNw==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/ssb-chess-mithril/-/ssb-chess-mithril-2.1.4.tgz", + "integrity": "sha512-lUY4eiinkzcypDUt/kFIHBAHM/oGupYxgyhuAQp/d8v5Jd6wNEsRbht2Gl/dnwdW2iMiJ/RIB2VntpTzmhnNtw==", "license": "GPL-3.0", "dependencies": { - "chessground": "7.6.8", + "@lichess-org/chessground": "^10.4.2", "howler": "^2.0.15", "human-time": "0.0.2", "hyperscript": "^2.0.2", - "mithril": "1.1.7", + "mithril": "2.3.6", "mutant": "3.29.0", "pubsub-js": "^1.7.0", "pull-scroll": "^1.0.9", "pull-stream": "^3.6.14", "ramda": "^0.25.0", - "ssb-chess": "4.0.5", + "ssb-chess": "4.0.9", "ssb-embedded-chat": "2.0.2" } }, @@ -14177,6 +14181,7 @@ "integrity": "sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "mkdirp": "^0.5.1", "rimraf": "~2.6.2" @@ -14231,6 +14236,7 @@ "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", "dev": true, "license": "ISC", + "peer": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -14252,6 +14258,7 @@ "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", "dev": true, "license": "MIT", + "peer": true, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -14262,6 +14269,7 @@ "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "minimist": "^1.2.6" }, @@ -14276,6 +14284,7 @@ "deprecated": "Rimraf versions prior to v4 are no longer supported", "dev": true, "license": "ISC", + "peer": true, "dependencies": { "glob": "^7.1.3" }, diff --git a/package.json b/package.json index e6ff5004..f182cd17 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "ssb-blobs": "^2.0.1", "ssb-book-schema": "^1.0.3", "ssb-chess-data-access": "^2.1.4", - "ssb-chess-mithril": "2.0.9", + "ssb-chess-mithril": "2.1.4", "ssb-client": "^4.9.0", "ssb-config": "^3.4.4", "ssb-conn": "~1.0.0", @@ -137,4 +137,4 @@ "overrides": { "epidemic-broadcast-trees": "soapdog/epidemic-broadcast-trees#068dd5347c68a40c6d7cefb913cbaa53c20c5464" } -} \ No newline at end of file +}